UNPKG

speech-rule-engine

Version:

A standalone speech rule engine for XML structures, based on the original engine from ChromeVox.

53 lines 1.83 kB
import { Variables } from './variables.js'; import { xpath, xmldom, document } from './lib_external.js'; const windowSupported = (() => !(typeof window === 'undefined'))(); const documentSupported = (() => windowSupported && !(typeof window.document === 'undefined'))(); const webworker = (() => !(typeof DedicatedWorkerGlobalScope === 'undefined'))(); const nodeRequire = () => { try { return eval('require'); } catch (_err) { return (_file) => null; } }; export const SystemExternal = { extRequire(library) { if (typeof process !== 'undefined' && typeof require !== 'undefined') { return nodeRequire()(library); } return null; }, windowSupported: windowSupported, documentSupported: documentSupported, webworker: webworker, xmldom: xmldom, document: document, fs: documentSupported || webworker ? null : nodeRequire()('fs'), url: Variables.url, jsonPath: (function () { if (documentSupported || webworker) { return Variables.url; } if (process.env.SRE_JSON_PATH || global.SRE_JSON_PATH) { return process.env.SRE_JSON_PATH || global.SRE_JSON_PATH; } try { const path = nodeRequire().resolve('speech-rule-engine'); return path.replace(/sre\.js$/, '') + 'mathmaps'; } catch (_err) { } try { const path = nodeRequire().resolve('.'); return path.replace(/sre\.js$/, '') + 'mathmaps'; } catch (_err) { } return typeof __dirname !== 'undefined' ? __dirname + (__dirname.match(/lib?$/) ? '/mathmaps' : '/lib/mathmaps') : process.cwd() + '/lib/mathmaps'; })(), xpath: xpath }; //# sourceMappingURL=system_external.js.map