UNPKG

speech-rule-engine

Version:

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

51 lines (50 loc) 1.87 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 = () => eval('require'); 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, mathmapsIePath: 'https://cdn.jsdelivr.net/npm/sre-mathmaps-ie@' + Variables.VERSION + 'mathmaps_ie.js', 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'; })(), WGXpath: Variables.WGXpath, wgxpath: null, xpath: xpath };