[ { "__docId__": 1, "kind": "external", "name": "Infinity", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Infinity", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~Infinity", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 2, "kind": "external", "name": "NaN", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~NaN", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 3, "kind": "external", "name": "undefined", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~undefined", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 4, "kind": "external", "name": "null", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~null", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 5, "kind": "external", "name": "Object", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~Object", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 6, "kind": "external", "name": "object", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~object", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 7, "kind": "external", "name": "Function", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~Function", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 8, "kind": "external", "name": "function", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~function", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 9, "kind": "external", "name": "Boolean", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~Boolean", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 10, "kind": "external", "name": "boolean", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~boolean", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 11, "kind": "external", "name": "Symbol", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~Symbol", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 12, "kind": "external", "name": "Error", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~Error", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 13, "kind": "external", "name": "EvalError", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~EvalError", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 14, "kind": "external", "name": "InternalError", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/InternalError", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~InternalError", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 15, "kind": "external", "name": "RangeError", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~RangeError", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 16, "kind": "external", "name": "ReferenceError", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~ReferenceError", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 17, "kind": "external", "name": "SyntaxError", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~SyntaxError", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 18, "kind": "external", "name": "TypeError", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~TypeError", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 19, "kind": "external", "name": "URIError", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~URIError", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 20, "kind": "external", "name": "Number", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~Number", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 21, "kind": "external", "name": "number", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~number", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 22, "kind": "external", "name": "Date", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~Date", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 23, "kind": "external", "name": "String", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~String", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 24, "kind": "external", "name": "string", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~string", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 25, "kind": "external", "name": "RegExp", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~RegExp", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 26, "kind": "external", "name": "Array", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~Array", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 27, "kind": "external", "name": "Int8Array", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~Int8Array", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 28, "kind": "external", "name": "Uint8Array", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~Uint8Array", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 29, "kind": "external", "name": "Uint8ClampedArray", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~Uint8ClampedArray", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 30, "kind": "external", "name": "Int16Array", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~Int16Array", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 31, "kind": "external", "name": "Uint16Array", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~Uint16Array", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 32, "kind": "external", "name": "Int32Array", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~Int32Array", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 33, "kind": "external", "name": "Uint32Array", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~Uint32Array", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 34, "kind": "external", "name": "Float32Array", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~Float32Array", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 35, "kind": "external", "name": "Float64Array", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~Float64Array", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 36, "kind": "external", "name": "Map", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~Map", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 37, "kind": "external", "name": "Set", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~Set", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 38, "kind": "external", "name": "WeakMap", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~WeakMap", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 39, "kind": "external", "name": "WeakSet", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~WeakSet", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 40, "kind": "external", "name": "ArrayBuffer", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~ArrayBuffer", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 41, "kind": "external", "name": "DataView", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~DataView", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 42, "kind": "external", "name": "JSON", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~JSON", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 43, "kind": "external", "name": "Promise", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~Promise", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 44, "kind": "external", "name": "Generator", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~Generator", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 45, "kind": "external", "name": "GeneratorFunction", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/GeneratorFunction", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~GeneratorFunction", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 46, "kind": "external", "name": "Reflect", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~Reflect", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 47, "kind": "external", "name": "Proxy", "externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy", "memberof": "src/.external-ecmascript.js", "static": true, "longname": "src/.external-ecmascript.js~Proxy", "access": "public", "description": "", "builtinExternal": true }, { "__docId__": 48, "kind": "file", "name": "src/Editor.js", "content": "/* eslint-disable no-underscore-dangle */\nimport { editorLogger as logger } from './configuration/LoggerConfig';\nimport * as DefaultBehaviors from './configuration/DefaultBehaviors';\nimport * as DefaultConfiguration from './configuration/DefaultConfiguration';\nimport * as DefaultStyles from './configuration/DefaultPenStyle';\nimport * as DefaultTheme from './configuration/DefaultTheme';\nimport * as InkModel from './model/InkModel';\nimport * as UndoRedoContext from './model/UndoRedoContext';\nimport * as UndoRedoManager from './model/UndoRedoManager';\nimport * as ModelStats from './util/ModelStats';\nimport * as ImageRenderer from './renderer/canvas/ImageRenderer';\nimport * as RecognizerContext from './model/RecognizerContext';\nimport * as SmartGuide from './smartguide/SmartGuide';\nimport Constants from './configuration/Constants';\nimport * as eastereggs from './eastereggs/InkImporter';\n\n\n/**\n * Trigger callbacks\n * @param {Editor} editor\n * @param {Object} data\n * @param {...String} types\n * @return {Model}\n */\nfunction triggerCallbacks(editor, data, ...types) {\n const editorRef = editor;\n types.forEach((type) => {\n switch (type) {\n case Constants.EventType.RENDERED:\n break; // Internal use only\n case Constants.EventType.UNDO:\n case Constants.EventType.REDO:\n case Constants.EventType.CLEAR:\n case Constants.EventType.CONVERT:\n case Constants.EventType.EXPORT:\n editor.callbacks.forEach(callback => callback.call(editor.domElement, type));\n break;\n case Constants.EventType.LOADED:\n case Constants.EventType.CHANGED:\n editor.callbacks.forEach(callback => callback.call(editor.domElement, type, {\n initialized: editor.initialized,\n canUndo: editor.canUndo,\n canRedo: editor.canRedo,\n canClear: editor.canClear,\n isEmpty: editor.isEmpty,\n possibleUndoCount: editor.possibleUndoCount,\n undoStackIndex: editor.undoStackIndex,\n canConvert: editor.canConvert,\n canExport: editor.canExport\n }));\n break;\n case Constants.EventType.EXPORTED:\n window.clearTimeout(editorRef.notifyTimer);\n editorRef.notifyTimer = window.setTimeout(() => {\n editor.callbacks.forEach(callback => callback.call(editor.domElement, type, {\n exports: editor.exports\n }));\n }, editorRef.configuration.processDelay);\n break;\n case Constants.EventType.SUPPORTED_IMPORT_MIMETYPES:\n editor.callbacks.forEach(callback => callback.call(editor.domElement, type, {\n mimeTypes: editor.supportedImportMimeTypes\n }));\n break;\n case Constants.EventType.ERROR:\n editor.callbacks.forEach(callback => callback.call(editor.domElement, type, data));\n break;\n case Constants.EventType.IDLE:\n editor.callbacks.forEach(callback => callback.call(editor.domElement, type, {\n idle: editor.idle\n }));\n break;\n default:\n logger.debug(`No valid trigger configured for ${type}`);\n break;\n }\n });\n}\n\n/**\n * Check if a clear is required, and does it if it is\n * @param {function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback)} resetFunc\n * @param {function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback)} func\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nfunction manageResetState(resetFunc, func, recognizerContext, model, callback, ...params) {\n // If strokes moved in the undo redo stack then a clear is mandatory before sending strokes.\n if (resetFunc && RecognizerContext.isResetRequired(recognizerContext, model)) {\n logger.debug('Reset is needed');\n resetFunc(recognizerContext, model, (err, resetedModel, ...types) => {\n if (err) {\n callback(err, resetedModel, ...types);\n } else {\n func(recognizerContext, resetedModel, callback, ...params);\n }\n });\n } else {\n func(recognizerContext, model, callback, ...params);\n }\n}\n\n/**\n * Check if the trigger in parameter is valid.\n * @param {Editor} editor\n * @param {String} type\n * @param {String} [trigger]\n * @return {Boolean}\n */\nfunction isTriggerValid(editor, type, trigger = editor.configuration.triggers[type]) {\n if (editor.recognizer &&\n editor.recognizer.getInfo().availableTriggers[type].includes(trigger)) {\n return true;\n }\n logger.error(`${trigger} is not a valid trigger for ${type}`);\n return false;\n}\n\n/**\n * Manage recognized model\n * @param {Editor} editor\n * @param {Model} model\n * @param {...String} types\n */\nfunction manageRecognizedModel(editor, model, ...types) {\n const editorRef = editor;\n const modelRef = model;\n logger.debug(`model changed callback on ${types} event(s)`, model);\n if (modelRef.creationTime === editor.model.creationTime) {\n // Merge recognized model if relevant and return current editor model\n if ((modelRef.rawStrokes.length === editor.model.rawStrokes.length) &&\n (modelRef.lastPositions.lastSentPosition >= editor.model.lastPositions.lastReceivedPosition)) {\n editorRef.model = InkModel.mergeModels(editorRef.model, modelRef);\n if (InkModel.needRedraw(editorRef.model) || types.includes(Constants.EventType.RENDERED)) {\n editor.renderer.drawModel(editor.rendererContext, editorRef.model, editor.stroker);\n }\n } else {\n editorRef.model = modelRef;\n editor.renderer.drawModel(editor.rendererContext, editorRef.model, editor.stroker);\n }\n triggerCallbacks(editor, undefined, ...types);\n }\n\n if (editor.configuration.recognitionParams.type === 'TEXT'\n && editor.configuration.recognitionParams.apiVersion === 'V4'\n && editor.configuration.recognitionParams.protocol !== 'REST'\n && editor.configuration.recognitionParams.v4.text.mimeTypes.includes(Constants.Exports.JIIX)\n && editor.configuration.recognitionParams.v4.text.smartGuide) {\n // eslint-disable-next-line no-use-before-define\n launchSmartGuide(editorRef, modelRef.exports);\n }\n\n if ((InkModel.extractPendingStrokes(model).length > 0) &&\n (!editor.recognizer.addStrokes) && // FIXME: Ugly hack to avoid double export (addStrokes + export)\n (editor.configuration.triggers.exportContent !== Constants.Trigger.DEMAND)) {\n /* eslint-disable no-use-before-define */\n launchExport(editor, model);\n /* eslint-enable no-use-before-define */\n }\n}\n\n/**\n * Recognizer callback\n * @param {Editor} editor\n * @param {Object} error\n * @param {Model} model\n * @param {...String} events\n */\nfunction recognizerCallback(editor, error, model, ...events) {\n const editorRef = editor;\n\n const handleResult = (err, res, ...types) => {\n if (err) {\n if (err.type !== 'close') {\n logger.error('Error while firing the recognition', err.stack || err); // Handle any error from all above steps\n }\n if (\n // IInk error managment before refactor\n (err.message === 'Invalid application key.') || (err.message === 'Invalid HMAC') ||\n // CDK error managment\n (err.error &&\n err.error.result &&\n err.error.result.error &&\n (err.error.result.error === 'InvalidApplicationKeyException' || err.error.result.error === 'InvalidHMACSignatureException')) ||\n // IInk error managment after refactor\n (err.code && err.code === 'access.not.granted')) {\n editorRef.error.innerText = Constants.Error.WRONG_CREDENTIALS;\n } else if (err.message === 'Session is too old. Max Session Duration Reached' ||\n (err.code && err.code === 'session.too.old')) {\n editorRef.error.innerText = Constants.Error.TOO_OLD;\n } else if ((err.code === 1006 || err.code === 1000) && editorRef.error.style.display === 'none') {\n editorRef.error.innerText = Constants.Error.NOT_REACHABLE;\n }\n if ((editorRef.error.innerText === Constants.Error.TOO_OLD || err.reason === 'CLOSE_RECOGNIZER') && RecognizerContext.canReconnect(editor.recognizerContext)) {\n logger.info('Reconnection is available', err.stack || err);\n editorRef.error.style.display = 'none';\n } else {\n editorRef.error.style.display = 'initial';\n triggerCallbacks(editor, err, Constants.EventType.ERROR, ...types);\n }\n } else {\n if (editorRef.error.style.display === 'initial') {\n editorRef.error.style.display = 'none';\n }\n manageRecognizedModel(editorRef, res, ...[...events, ...types].filter((el, i, a) => i === a.indexOf(el))); // Remove duplicate events\n }\n };\n\n logger.debug('recognition callback');\n if (editor.undoRedoManager.updateModel && !error) {\n editor.undoRedoManager.updateModel(editor.undoRedoContext, model, handleResult);\n } else {\n handleResult(error, model, ...events);\n }\n}\n\n/**\n * Launch the recognition with all editor relative configuration and state.\n * @param {Editor} editor\n * @param {Model} model\n * @param {String} [trigger]\n */\nfunction addStrokes(editor, model, trigger = editor.configuration.triggers.addStrokes) {\n if (editor.recognizer && editor.recognizer.addStrokes) {\n editor.recognizerContext.initPromise\n .then(() => {\n // Firing addStrokes only if recognizer is configure to do it\n if (isTriggerValid(editor, 'addStrokes', trigger)) {\n manageResetState(editor.recognizer.reset, editor.recognizer.addStrokes, editor.recognizerContext, model, (err, res, ...types) => {\n recognizerCallback(editor, err, res, ...types);\n });\n }\n });\n }\n}\n\n/**\n * Launch smartguide.\n * @param {Editor} editor\n * @param {Object} exports\n */\nfunction launchSmartGuide(editor, exports) {\n const editorRef = editor;\n editorRef.smartGuide = SmartGuide.launchSmartGuide(editor.smartGuide, exports);\n}\n\n/**\n * Launch ink import.\n * @param {Editor} editor\n * @param {Model} model\n * @param {PointerEvents} events\n */\nfunction launchPointerEvents(editor, model, events) {\n if (editor.recognizer && editor.recognizer.pointerEvents) {\n editor.recognizerContext.initPromise\n .then(() => {\n editor.recognizer.pointerEvents(editor.recognizerContext, model, events, (err, res, ...types) => {\n recognizerCallback(editor, err, res, ...types);\n });\n });\n }\n}\n\n/**\n * Launch the recognition with all editor relative configuration and state.\n * @param {Editor} editor\n * @param {Model} model\n * @param {String} [requestedMimeTypes]\n * @param {String} [trigger]\n */\nfunction launchExport(editor, model, requestedMimeTypes, trigger = editor.configuration.triggers.exportContent) {\n if (editor.recognizer && editor.recognizer.export_) {\n editor.recognizerContext.initPromise\n .then(() => {\n // Firing export only if recognizer is configure to do it\n if (isTriggerValid(editor, 'exportContent', trigger)) {\n const editorRef = editor;\n window.clearTimeout(editor.exportTimer);\n editorRef.exportTimer = window.setTimeout(() => {\n manageResetState(editor.recognizer.reset, editor.recognizer.export_, editor.recognizerContext, model, (err, res, ...types) => {\n recognizerCallback(editor, err, res, ...types);\n }, requestedMimeTypes);\n }, trigger === Constants.Trigger.QUIET_PERIOD ? editor.configuration.triggerDelay : 0);\n }\n });\n }\n}\n\n/**\n * Launch the import.\n * @param {Editor} editor\n * @param {Model} model\n * @param {Blob} data\n */\nfunction launchImport(editor, model, data) {\n if (editor.recognizer && editor.recognizer.import_) {\n editor.recognizerContext.initPromise\n .then(() => {\n editor.recognizer.import_(editor.recognizerContext, model, data, (err, res, ...types) => {\n recognizerCallback(editor, err, res, ...types);\n });\n });\n }\n}\n\nfunction launchGetSupportedImportMimeTypes(editor, model) {\n if (editor.recognizer && editor.recognizer.getSupportedImportMimeTypes) {\n editor.recognizerContext.initPromise\n .then(() => {\n editor.recognizer.getSupportedImportMimeTypes(editor.recognizerContext, model, (err, res, ...types) => {\n recognizerCallback(editor, err, res, ...types);\n });\n });\n }\n}\n\n/**\n * Launch the convert with all editor relative configuration and state.\n * @param {Editor} editor\n * @param {Model} model\n * @param {String} conversionState\n */\nfunction launchConvert(editor, model, conversionState) {\n if (editor.recognizer && editor.recognizer.convert) {\n editor.recognizerContext.initPromise\n .then(() => {\n editor.recognizer.convert(editor.recognizerContext, model, (err, res, ...types) => {\n recognizerCallback(editor, err, res, ...types);\n }, conversionState);\n });\n }\n}\n\nfunction launchConfig(editor, model) {\n if (editor.recognizer && editor.recognizer.sendConfiguration) {\n editor.recognizerContext.initPromise\n .then(() => {\n editor.recognizer.sendConfiguration(editor.recognizerContext, model, (err, res, ...types) => {\n recognizerCallback(editor, err, res, ...types);\n });\n });\n }\n}\n\n/**\n * Launch the resize.\n * @param {Editor} editor\n * @param {Model} model\n */\nfunction launchResize(editor, model) {\n if (editor.recognizer && editor.recognizer.resize) {\n editor.recognizerContext.initPromise\n .then(() => {\n const editorRef = editor;\n window.clearTimeout(editor.resizeTimer);\n editorRef.resizeTimer = window.setTimeout(() => {\n editor.recognizer.resize(editor.recognizerContext, model, (err, res, ...types) => {\n recognizerCallback(editor, err, res, ...types);\n }, editor.domElement);\n }, editor.configuration.resizeTriggerDelay);\n });\n SmartGuide.resize(editor.smartGuide);\n }\n}\n\n/**\n * Launch wait for idle\n * @param {Editor} editor\n * @param {Model} model\n */\nfunction launchWaitForIdle(editor, model) {\n if (editor.recognizer && editor.recognizer.waitForIdle) {\n editor.recognizerContext.initPromise\n .then(() => {\n editor.recognizer.waitForIdle(editor.recognizerContext, model, (err, res, ...types) => {\n recognizerCallback(editor, err, res, ...types);\n });\n });\n }\n}\n\n/**\n * Set pen style.\n * @param {Editor} editor\n * @param {Model} model\n */\nfunction setPenStyle(editor, model) {\n if (editor.recognizer && editor.recognizer.setPenStyle) {\n editor.recognizerContext.initPromise\n .then(() => {\n editor.recognizer.setPenStyle(editor.recognizerContext, model, editor.penStyle, (err, res, ...types) => {\n recognizerCallback(editor, err, res, ...types);\n });\n });\n }\n}\n\n/**\n * Set pen style.\n * @param {Editor} editor\n * @param {Model} model\n */\nfunction setPenStyleClasses(editor, model) {\n if (editor.recognizer && editor.recognizer.setPenStyleClasses) {\n editor.recognizerContext.initPromise\n .then(() => {\n editor.recognizer.setPenStyleClasses(editor.recognizerContext, model, editor.penStyleClasses, (err, res, ...types) => {\n recognizerCallback(editor, err, res, ...types);\n });\n });\n }\n}\n\n/**\n * Set theme.\n * @param {Editor} editor\n * @param {Model} model\n */\nfunction setTheme(editor, model) {\n if (editor.recognizer && editor.recognizer.setTheme) {\n editor.recognizerContext.initPromise\n .then(() => {\n editor.recognizer.setTheme(editor.recognizerContext, model, editor.theme, (err, res, ...types) => {\n recognizerCallback(editor, err, res, ...types);\n });\n });\n }\n}\n\n/**\n * Editor\n */\nexport class Editor {\n /**\n * @param {Element} element DOM element to attach this editor\n * @param {Configuration} [configuration] Configuration to apply\n * @param {Theme} [theme] Custom theme to apply\n * @param {PenStyle} [penStyle] Custom style to apply\n * @param {Behaviors} [behaviors] Custom behaviors to apply\n */\n constructor(element, configuration, penStyle, theme, behaviors) {\n /**\n * Inner reference to the DOM Element\n * @type {Element}\n */\n this.domElement = element;\n this.domElement.classList.add('ms-editor');\n\n // eslint-disable-next-line no-undef\n this.loader = document.createElement('div');\n this.loader.classList.add('loader');\n this.loader = this.domElement.appendChild(this.loader);\n\n // eslint-disable-next-line no-undef\n this.error = document.createElement('div');\n this.error.classList.add('error-msg');\n this.error = this.domElement.appendChild(this.error);\n\n /**\n * Launch export timer\n * @type {Number}\n */\n this.exportTimer = undefined;\n\n /**\n * Launch resize timer\n * @type {Number}\n */\n this.resizeTimer = undefined;\n\n /**\n * Notify delay timer\n * @type {Number}\n */\n this.notifyTimer = undefined;\n\n\n /**\n * @private\n * @type {Behaviors}\n */\n this.innerBehaviors = DefaultBehaviors.overrideDefaultBehaviors(behaviors);\n this.configuration = configuration;\n this.smartGuide = SmartGuide.createSmartGuide(this);\n\n /**\n * Pen color used only for pending stroke\n * @type {string}\n */\n this.localTheme = '';\n\n this.theme = theme;\n this.penStyle = penStyle;\n this.penStyleClasses = '';\n\n this.domElement.editor = this;\n }\n\n /**\n * Set the recognition parameters\n * WARNING : Need to fire a clear if user have already input some strokes.\n * @param {Configuration} configuration\n */\n set configuration(configuration) {\n this.loader.style.display = 'initial';\n this.error.style.display = 'none';\n /**\n * @private\n * @type {Configuration}\n */\n this.innerConfiguration = DefaultConfiguration.overrideDefaultConfiguration(configuration);\n this.setThemeForFont(this.innerConfiguration.recognitionParams.v4.lang);\n this.behavior = this.behaviors.getBehaviorFromConfiguration(this.behaviors, this.innerConfiguration);\n }\n\n /**\n * Get the current recognition parameters\n * @return {Configuration}\n */\n get configuration() {\n return this.innerConfiguration;\n }\n\n /**\n * Set the pen style\n * @param {PenStyle} penStyle\n */\n set penStyle(penStyle) {\n /**\n * @private\n * @type {PenStyle}\n */\n this.innerPenStyle = DefaultStyles.overrideDefaultPenStyle(penStyle);\n this.localPenStyle = this.innerPenStyle;\n setPenStyle(this, this.model);\n }\n\n /**\n * Get the pen style\n * @return {PenStyle}\n */\n get penStyle() {\n return this.innerPenStyle;\n }\n\n /**\n * Set the pen style\n * @param {String} penStyleClasses\n */\n set penStyleClasses(penStyleClasses) {\n /**\n * @private\n * @type {String}\n */\n this.innerPenStyleClasses = penStyleClasses;\n this.localPenStyle = this.theme[`.${this.innerPenStyleClasses}`];\n setPenStyleClasses(this, this.model);\n }\n\n /**\n * Get the pen style\n * @return {String}\n */\n get penStyleClasses() {\n return this.innerPenStyleClasses;\n }\n\n /**\n * Set the theme\n * @param {Theme} theme\n */\n set theme(theme) {\n /**\n * @private\n * @type {Theme}\n */\n this.innerTheme = DefaultTheme.overrideDefaultTheme(theme);\n setTheme(this, this.model);\n }\n\n /**\n * Get the theme\n * @return {Theme}\n */\n get theme() {\n return this.innerTheme;\n }\n\n /**\n * Get behaviors\n * @return {Behaviors}\n */\n get behaviors() {\n return this.innerBehaviors;\n }\n\n /**\n * @private\n * @param {Behavior} behavior\n */\n set behavior(behavior) {\n if (behavior) {\n if (this.grabber) { // Remove event handlers to avoid multiplication (detach grabber)\n this.grabber.detach(this.domElement, this.grabberContext);\n }\n /**\n * @private\n * @type {Behavior}\n */\n this.innerBehavior = behavior;\n this.renderer = this.innerBehavior.renderer;\n this.recognizer = this.innerBehavior.recognizer;\n /**\n * Current grabber context\n * @type {GrabberContext}\n */\n this.grabberContext = this.grabber.attach(this.domElement, this);\n }\n }\n\n /**\n * Get current behavior\n * @return {Behavior}\n */\n get behavior() {\n return this.innerBehavior;\n }\n\n /**\n * Set the current recognizer\n * @private\n * @param {Recognizer} recognizer\n */\n set recognizer(recognizer) {\n this.undoRedoContext = UndoRedoContext.createUndoRedoContext(this.configuration);\n this.undoRedoManager = UndoRedoManager;\n\n const initialize = (model) => {\n /**\n * @private\n * @type {Recognizer}\n */\n this.innerRecognizer = recognizer;\n if (this.innerRecognizer) {\n /**\n * Current recognition context\n * @type {RecognizerContext}\n */\n this.recognizerContext = RecognizerContext.createEmptyRecognizerContext(this);\n // FIXME: merge undo/redo manager with default recognizer\n if (this.innerRecognizer.undo && this.innerRecognizer.redo && this.innerRecognizer.clear) {\n this.undoRedoContext = this.recognizerContext;\n this.undoRedoManager = this.innerRecognizer;\n }\n\n this.innerRecognizer.init(this.recognizerContext, model, (err, res, ...types) => {\n logger.debug('Recognizer initialized', res);\n this.loader.style.display = 'none';\n recognizerCallback(this, err, res, ...types);\n });\n }\n };\n\n if (recognizer) {\n if (this.innerRecognizer) {\n this.innerRecognizer.close(this.recognizerContext, this.model, (err, res, ...types) => {\n logger.info('Recognizer closed');\n recognizerCallback(this, err, res, ...types);\n initialize(InkModel.clearModel(res));\n });\n } else {\n /**\n * Current model\n * @type {Model}\n */\n this.model = InkModel.createModel(this.configuration);\n\n // INFO: Recognizer needs model to be initialized\n initialize(this.model);\n }\n }\n }\n\n /**\n * Get current recognizer\n * @return {Recognizer}\n */\n get recognizer() {\n return this.innerRecognizer;\n }\n\n /**\n * Set the current renderer\n * @private\n * @param {Renderer} renderer\n */\n set renderer(renderer) {\n if (renderer) {\n if (this.innerRenderer) {\n this.innerRenderer.detach(this.domElement, this.rendererContext);\n }\n\n /**\n * @private\n * @type {Renderer}\n */\n this.innerRenderer = renderer;\n if (this.innerRenderer) {\n /**\n * Current rendering context\n * @type {Object}\n */\n this.rendererContext = this.innerRenderer.attach(this.domElement, this.configuration.renderingParams.minHeight, this.configuration.renderingParams.minWidth);\n }\n }\n }\n\n /**\n * Get current renderer\n * @return {Renderer}\n */\n get renderer() {\n return this.innerRenderer;\n }\n\n /**\n * Get current grabber\n * @return {Grabber}\n */\n get grabber() {\n return this.behavior ? this.behavior.grabber : undefined;\n }\n\n /**\n * Get current stroker\n * @return {Stroker}\n */\n get stroker() {\n return this.behavior ? this.behavior.stroker : undefined;\n }\n\n /**\n * Get current callbacks\n * @return {Array}\n */\n get callbacks() {\n return this.behavior ? this.behavior.callbacks : undefined;\n }\n\n /**\n * Get a PNG image data url from the data model\n * @return {String}\n */\n get png() {\n return ImageRenderer.getImage(this.model, this.stroker);\n }\n\n /**\n * Get statistics to monitor what ink size is send to the server.\n * @return {Stats}\n */\n getStats() {\n return ModelStats.computeStats(this.model);\n }\n\n /**\n * True if initialized, false otherwise\n * @return {Boolean}\n */\n get initialized() {\n return this.recognizerContext ? this.recognizerContext.initialized : false;\n }\n\n /**\n * Handle a pointer down\n * @param {{x: Number, y: Number, t: Number}} point Captured point coordinates\n * @param {String} [pointerType=mouse] Current pointer type\n * @param {String} [pointerId] Current pointer id\n */\n pointerDown(point, pointerType = 'pen', pointerId) {\n logger.trace('Pointer down', point);\n window.clearTimeout(this.notifyTimer);\n window.clearTimeout(this.exportTimer);\n this.model = InkModel.initPendingStroke(this.model, point, Object.assign({ pointerType, pointerId }, this.theme.ink, this.localPenStyle));\n this.renderer.drawCurrentStroke(this.rendererContext, this.model, this.stroker);\n // Currently no recognition on pointer down\n }\n\n /**\n * Handle a pointer move\n * @param {{x: Number, y: Number, t: Number}} point Captured point coordinates\n */\n pointerMove(point) {\n logger.trace('Pointer move', point);\n this.model = InkModel.appendToPendingStroke(this.model, point);\n this.renderer.drawCurrentStroke(this.rendererContext, this.model, this.stroker);\n // Currently no recognition on pointer move\n }\n\n /**\n * Handle a pointer up\n * @param {{x: Number, y: Number, t: Number}} point Captured point coordinates\n */\n pointerUp(point) {\n logger.trace('Pointer up', point);\n this.model = InkModel.endPendingStroke(this.model, point, this.penStyle);\n this.renderer.drawModel(this.rendererContext, this.model, this.stroker);\n\n if (this.recognizer.addStrokes) {\n addStrokes(this, this.model);\n } else {\n // Push model in undo redo manager\n recognizerCallback(this, undefined, this.model);\n }\n }\n\n removeStroke(stroke) {\n this.model.strokeGroups.forEach((group) => {\n const stringStrokes = group.strokes.map(strokeFromGroup => JSON.stringify(strokeFromGroup));\n const strokeIndex = stringStrokes.indexOf(JSON.stringify(stroke));\n if (strokeIndex !== -1) {\n group.strokes.splice(strokeIndex, 1);\n }\n });\n const stringRawStrokes = this.model.rawStrokes.map(strokes => JSON.stringify(strokes));\n const strokeIndex = stringRawStrokes.indexOf(JSON.stringify(stroke));\n if (strokeIndex !== -1) {\n this.model.rawStrokes.splice(strokeIndex, 1);\n }\n this.renderer.drawModel(this.rendererContext, this.model, this.stroker);\n recognizerCallback(this, undefined, this.model);\n if (!(this.configuration.triggers.exportContent === 'DEMAND')) {\n launchExport(this, this.model);\n }\n }\n\n /**\n * @Deprecated\n * @param rawStrokes\n * @param strokeGroups\n */\n reDraw(rawStrokes, strokeGroups) {\n rawStrokes.forEach((stroke) => {\n InkModel.addStroke(this.model, stroke);\n });\n strokeGroups.forEach((group) => {\n group.strokes.forEach((strokeFromGroup) => {\n InkModel.addStrokeToGroup(this.model, strokeFromGroup, group.penStyle);\n });\n });\n this.renderer.drawModel(this.rendererContext, this.model, this.stroker);\n recognizerCallback(this, undefined, this.model);\n }\n\n /**\n * True if idle state\n * @return {Boolean}\n */\n get idle() {\n return this.recognizerContext.idle;\n }\n\n /**\n * Wait for idle state.\n */\n waitForIdle() {\n triggerCallbacks(this, undefined, Constants.EventType.IDLE);\n launchWaitForIdle(this, this.model);\n }\n\n /**\n * True if can undo, false otherwise.\n * @return {Boolean}\n */\n get canUndo() {\n return this.undoRedoContext.canUndo;\n }\n\n /**\n * Undo the last action.\n */\n undo() {\n logger.debug('Undo current model', this.model);\n triggerCallbacks(this, undefined, Constants.EventType.UNDO);\n this.undoRedoManager.undo(this.undoRedoContext, this.model, (err, res, ...types) => {\n manageRecognizedModel(this, res, ...types);\n });\n }\n\n /**\n * True if can redo, false otherwise.\n * @return {Boolean}\n */\n get canRedo() {\n return this.undoRedoContext.canRedo;\n }\n\n /**\n * Redo the last action.\n */\n redo() {\n logger.debug('Redo current model', this.model);\n triggerCallbacks(this, undefined, Constants.EventType.REDO);\n this.undoRedoManager.redo(this.undoRedoContext, this.model, (err, res, ...types) => {\n manageRecognizedModel(this, res, ...types);\n });\n }\n\n /**\n * True if empty, false otherwise\n * @returns {boolean}\n */\n get isEmpty() {\n return this.recognizerContext.isEmpty;\n }\n\n /**\n * True if can clear, false otherwise.\n * @return {Boolean}\n */\n get canClear() {\n return this.canUndo && !this.isEmpty;\n }\n\n /**\n * Clear the output and the recognition result.\n */\n clear() {\n if (this.canClear) {\n logger.debug('Clear current model', this.model);\n triggerCallbacks(this, undefined, Constants.EventType.CLEAR);\n this.recognizer.clear(this.recognizerContext, this.model, (err, res, ...types) => {\n recognizerCallback(this, err, res, ...types);\n });\n }\n }\n\n /**\n * True if can convert, false otherwise.\n * @return {Boolean}\n */\n get canConvert() {\n return this.canUndo && this.canClear && this.recognizer && this.recognizer.convert;\n }\n\n /**\n * Convert the current content\n */\n convert(conversionState = 'DIGITAL_EDIT') {\n if (this.canConvert) {\n triggerCallbacks(this, undefined, Constants.EventType.CONVERT);\n launchConvert(this, this.model, conversionState);\n }\n }\n\n /**\n * Set the guides for text\n * @param {Boolean} [enable]\n */\n setGuides(enable = true) {\n this.configuration.recognitionParams.v4.text.guides.enable = enable;\n launchConfig(this, this.model);\n }\n\n /**\n * Return the position of the cursor identifying the current state in the internal iink undo/redo stack.\n * @returns {Number}\n */\n get possibleUndoCount() {\n return this.recognizerContext.possibleUndoCount;\n }\n\n /**\n * The number of operations that it is currently possible to undo.\n * @returns {Number}\n */\n get undoStackIndex() {\n return this.recognizerContext.undoStackIndex;\n }\n\n /**\n * True if can export, false otherwise.\n * @return {Boolean}\n */\n get canExport() {\n return this.canUndo && this.canClear && this.recognizer && this.recognizer.getInfo().availableTriggers.exportContent.includes(Constants.Trigger.DEMAND);\n }\n\n /**\n * Explicitly ask to perform an export. You have to listen to events to get the content as this function is non blocking and does not have a return type.\n * @param {Array} requestedMimeTypes Requested mime-types. Be sure to ask all the types required by the listeners of exported event.\n */\n export_(requestedMimeTypes) {\n if (this.canExport) {\n triggerCallbacks(this, undefined, Constants.EventType.EXPORT);\n launchExport(this, this.model, requestedMimeTypes, Constants.Trigger.DEMAND);\n }\n }\n\n /**\n * Import content.\n * @param {Blob|*} data Data to import\n * @param {String} [mimetype] Mimetype of the data, needed if data is not a Blob\n */\n import_(data, mimetype) {\n triggerCallbacks(this, undefined, Constants.EventType.IMPORT);\n launchImport(this, this.model, !(data instanceof Blob) ? new Blob([data], { type: mimetype }) : data);\n }\n\n /**\n * Get supported import mime types\n */\n getSupportedImportMimeTypes() {\n launchGetSupportedImportMimeTypes(this, this.model);\n }\n\n /**\n * pointer events\n * @param {PointerEvents} events\n */\n pointerEvents(events) {\n launchPointerEvents(this, this.model, events);\n }\n\n /**\n * Get current state exports\n * @return {Object}\n */\n get exports() {\n return this.model ? this.model.exports : undefined;\n }\n\n get supportedImportMimeTypes() {\n return this.recognizerContext.supportedImportMimeTypes;\n }\n\n /**\n * Function to call when the dom element link to the current ink paper has been resize.\n */\n resize() {\n logger.debug('Resizing editor');\n this.renderer.resize(this.rendererContext, this.model, this.stroker, this.configuration.renderingParams.minHeight, this.configuration.renderingParams.minWidth);\n launchResize(this, this.model);\n }\n\n /**\n * Set the theme (font family, font size and line height) depending on the language\n * @param lang\n */\n setThemeForFont(lang) {\n const defaultLang = !Object.keys(Constants.Languages).includes(lang);\n const armenian = lang === 'hy_AM';\n const fontFamily = defaultLang || armenian ? Constants.Languages.default : Constants.Languages[lang];\n const lineHeight = defaultLang || armenian ? '1.2' : '1.8';\n this.theme = {\n '.text': {\n 'font-family': fontFamily,\n 'line-height': lineHeight\n }\n };\n }\n\n /**\n * Detach event listeners from the DOM element created at editor creation.\n */\n unload() {\n if (this.grabber) { // Remove event handlers to avoid multiplication (detach grabber)\n this.grabber.detach(this.domElement, this.grabberContext);\n }\n if (this.innerRenderer) {\n this.innerRenderer.detach(this.domElement, this.rendererContext);\n }\n }\n\n /**\n * Trigger the change callbacks (and by default send a change event).\n */\n forceChange() {\n triggerCallbacks(this, undefined, Constants.EventType.CHANGED);\n }\n\n /* eslint-disable class-methods-use-this */\n /**\n * Get access to some easter egg features link ink injection. Use at your own risk (less tested and may be removed without notice).\n */\n get eastereggs() {\n return eastereggs;\n }\n /* eslint-enable class-methods-use-this */\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/Editor.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 49, "kind": "function", "name": "triggerCallbacks", "memberof": "src/Editor.js", "generator": false, "async": false, "static": true, "longname": "src/Editor.js~triggerCallbacks", "access": "public", "export": false, "importPath": "myscript/src/Editor.js", "importStyle": null, "description": "Trigger callbacks", "lineNumber": 25, "params": [ { "nullable": null, "types": [ "Editor" ], "spread": false, "optional": false, "name": "editor", "description": "" }, { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "data", "description": "" }, { "nullable": null, "types": [ "...String" ], "spread": true, "optional": false, "name": "types", "description": "" } ], "return": { "nullable": null, "types": [ "Model" ], "spread": false, "description": "" }, "ignore": true }, { "__docId__": 50, "kind": "function", "name": "manageResetState", "memberof": "src/Editor.js", "generator": false, "async": false, "static": true, "longname": "src/Editor.js~manageResetState", "access": "public", "export": false, "importPath": "myscript/src/Editor.js", "importStyle": null, "description": "Check if a clear is required, and does it if it is", "lineNumber": 88, "params": [ { "nullable": null, "types": [ "function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback)" ], "spread": false, "optional": false, "name": "resetFunc", "description": "" }, { "nullable": null, "types": [ "function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback)" ], "spread": false, "optional": false, "name": "func", "description": "" }, { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null, "ignore": true }, { "__docId__": 51, "kind": "function", "name": "isTriggerValid", "memberof": "src/Editor.js", "generator": false, "async": false, "static": true, "longname": "src/Editor.js~isTriggerValid", "access": "public", "export": false, "importPath": "myscript/src/Editor.js", "importStyle": null, "description": "Check if the trigger in parameter is valid.", "lineNumber": 111, "params": [ { "nullable": null, "types": [ "Editor" ], "spread": false, "optional": false, "name": "editor", "description": "" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "type", "description": "" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": true, "name": "trigger", "description": "" } ], "return": { "nullable": null, "types": [ "Boolean" ], "spread": false, "description": "" }, "ignore": true }, { "__docId__": 52, "kind": "function", "name": "manageRecognizedModel", "memberof": "src/Editor.js", "generator": false, "async": false, "static": true, "longname": "src/Editor.js~manageRecognizedModel", "access": "public", "export": false, "importPath": "myscript/src/Editor.js", "importStyle": null, "description": "Manage recognized model", "lineNumber": 126, "params": [ { "nullable": null, "types": [ "Editor" ], "spread": false, "optional": false, "name": "editor", "description": "" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" }, { "nullable": null, "types": [ "...String" ], "spread": true, "optional": false, "name": "types", "description": "" } ], "return": null, "ignore": true }, { "__docId__": 53, "kind": "function", "name": "recognizerCallback", "memberof": "src/Editor.js", "generator": false, "async": false, "static": true, "longname": "src/Editor.js~recognizerCallback", "access": "public", "export": false, "importPath": "myscript/src/Editor.js", "importStyle": null, "description": "Recognizer callback", "lineNumber": 170, "params": [ { "nullable": null, "types": [ "Editor" ], "spread": false, "optional": false, "name": "editor", "description": "" }, { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "error", "description": "" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" }, { "nullable": null, "types": [ "...String" ], "spread": true, "optional": false, "name": "events", "description": "" } ], "return": null, "ignore": true }, { "__docId__": 54, "kind": "function", "name": "addStrokes", "memberof": "src/Editor.js", "generator": false, "async": false, "static": true, "longname": "src/Editor.js~addStrokes", "access": "public", "export": false, "importPath": "myscript/src/Editor.js", "importStyle": null, "description": "Launch the recognition with all editor relative configuration and state.", "lineNumber": 224, "params": [ { "nullable": null, "types": [ "Editor" ], "spread": false, "optional": false, "name": "editor", "description": "" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": true, "name": "trigger", "description": "" } ], "return": null, "ignore": true }, { "__docId__": 55, "kind": "function", "name": "launchSmartGuide", "memberof": "src/Editor.js", "generator": false, "async": false, "static": true, "longname": "src/Editor.js~launchSmartGuide", "access": "public", "export": false, "importPath": "myscript/src/Editor.js", "importStyle": null, "description": "Launch smartguide.", "lineNumber": 243, "params": [ { "nullable": null, "types": [ "Editor" ], "spread": false, "optional": false, "name": "editor", "description": "" }, { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "exports", "description": "" } ], "return": null, "ignore": true }, { "__docId__": 56, "kind": "function", "name": "launchPointerEvents", "memberof": "src/Editor.js", "generator": false, "async": false, "static": true, "longname": "src/Editor.js~launchPointerEvents", "access": "public", "export": false, "importPath": "myscript/src/Editor.js", "importStyle": null, "description": "Launch ink import.", "lineNumber": 254, "params": [ { "nullable": null, "types": [ "Editor" ], "spread": false, "optional": false, "name": "editor", "description": "" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" }, { "nullable": null, "types": [ "PointerEvents" ], "spread": false, "optional": false, "name": "events", "description": "" } ], "return": null, "ignore": true }, { "__docId__": 57, "kind": "function", "name": "launchExport", "memberof": "src/Editor.js", "generator": false, "async": false, "static": true, "longname": "src/Editor.js~launchExport", "access": "public", "export": false, "importPath": "myscript/src/Editor.js", "importStyle": null, "description": "Launch the recognition with all editor relative configuration and state.", "lineNumber": 272, "params": [ { "nullable": null, "types": [ "Editor" ], "spread": false, "optional": false, "name": "editor", "description": "" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": true, "name": "requestedMimeTypes", "description": "" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": true, "name": "trigger", "description": "" } ], "return": null, "ignore": true }, { "__docId__": 58, "kind": "function", "name": "launchImport", "memberof": "src/Editor.js", "generator": false, "async": false, "static": true, "longname": "src/Editor.js~launchImport", "access": "public", "export": false, "importPath": "myscript/src/Editor.js", "importStyle": null, "description": "Launch the import.", "lineNumber": 296, "params": [ { "nullable": null, "types": [ "Editor" ], "spread": false, "optional": false, "name": "editor", "description": "" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" }, { "nullable": null, "types": [ "Blob" ], "spread": false, "optional": false, "name": "data", "description": "" } ], "return": null, "ignore": true }, { "__docId__": 59, "kind": "function", "name": "launchGetSupportedImportMimeTypes", "memberof": "src/Editor.js", "generator": false, "async": false, "static": true, "longname": "src/Editor.js~launchGetSupportedImportMimeTypes", "access": "public", "export": false, "importPath": "myscript/src/Editor.js", "importStyle": null, "description": null, "lineNumber": 307, "undocument": true, "params": [ { "name": "editor", "types": [ "*" ] }, { "name": "model", "types": [ "*" ] } ], "return": null, "ignore": true }, { "__docId__": 60, "kind": "function", "name": "launchConvert", "memberof": "src/Editor.js", "generator": false, "async": false, "static": true, "longname": "src/Editor.js~launchConvert", "access": "public", "export": false, "importPath": "myscript/src/Editor.js", "importStyle": null, "description": "Launch the convert with all editor relative configuration and state.", "lineNumber": 324, "params": [ { "nullable": null, "types": [ "Editor" ], "spread": false, "optional": false, "name": "editor", "description": "" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "conversionState", "description": "" } ], "return": null, "ignore": true }, { "__docId__": 61, "kind": "function", "name": "launchConfig", "memberof": "src/Editor.js", "generator": false, "async": false, "static": true, "longname": "src/Editor.js~launchConfig", "access": "public", "export": false, "importPath": "myscript/src/Editor.js", "importStyle": null, "description": null, "lineNumber": 335, "undocument": true, "params": [ { "name": "editor", "types": [ "*" ] }, { "name": "model", "types": [ "*" ] } ], "return": null, "ignore": true }, { "__docId__": 62, "kind": "function", "name": "launchResize", "memberof": "src/Editor.js", "generator": false, "async": false, "static": true, "longname": "src/Editor.js~launchResize", "access": "public", "export": false, "importPath": "myscript/src/Editor.js", "importStyle": null, "description": "Launch the resize.", "lineNumber": 351, "params": [ { "nullable": null, "types": [ "Editor" ], "spread": false, "optional": false, "name": "editor", "description": "" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" } ], "return": null, "ignore": true }, { "__docId__": 63, "kind": "function", "name": "launchWaitForIdle", "memberof": "src/Editor.js", "generator": false, "async": false, "static": true, "longname": "src/Editor.js~launchWaitForIdle", "access": "public", "export": false, "importPath": "myscript/src/Editor.js", "importStyle": null, "description": "Launch wait for idle", "lineNumber": 372, "params": [ { "nullable": null, "types": [ "Editor" ], "spread": false, "optional": false, "name": "editor", "description": "" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" } ], "return": null, "ignore": true }, { "__docId__": 64, "kind": "function", "name": "setPenStyle", "memberof": "src/Editor.js", "generator": false, "async": false, "static": true, "longname": "src/Editor.js~setPenStyle", "access": "public", "export": false, "importPath": "myscript/src/Editor.js", "importStyle": null, "description": "Set pen style.", "lineNumber": 388, "params": [ { "nullable": null, "types": [ "Editor" ], "spread": false, "optional": false, "name": "editor", "description": "" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" } ], "return": null, "ignore": true }, { "__docId__": 65, "kind": "function", "name": "setPenStyleClasses", "memberof": "src/Editor.js", "generator": false, "async": false, "static": true, "longname": "src/Editor.js~setPenStyleClasses", "access": "public", "export": false, "importPath": "myscript/src/Editor.js", "importStyle": null, "description": "Set pen style.", "lineNumber": 404, "params": [ { "nullable": null, "types": [ "Editor" ], "spread": false, "optional": false, "name": "editor", "description": "" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" } ], "return": null, "ignore": true }, { "__docId__": 66, "kind": "function", "name": "setTheme", "memberof": "src/Editor.js", "generator": false, "async": false, "static": true, "longname": "src/Editor.js~setTheme", "access": "public", "export": false, "importPath": "myscript/src/Editor.js", "importStyle": null, "description": "Set theme.", "lineNumber": 420, "params": [ { "nullable": null, "types": [ "Editor" ], "spread": false, "optional": false, "name": "editor", "description": "" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" } ], "return": null, "ignore": true }, { "__docId__": 67, "kind": "class", "name": "Editor", "memberof": "src/Editor.js", "static": true, "longname": "src/Editor.js~Editor", "access": "public", "export": true, "importPath": "myscript/src/Editor.js", "importStyle": "{Editor}", "description": "Editor", "lineNumber": 434, "interface": false }, { "__docId__": 68, "kind": "constructor", "name": "constructor", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#constructor", "access": "public", "description": "", "lineNumber": 442, "params": [ { "nullable": null, "types": [ "Element" ], "spread": false, "optional": false, "name": "element", "description": "DOM element to attach this editor" }, { "nullable": null, "types": [ "Configuration" ], "spread": false, "optional": true, "name": "configuration", "description": "Configuration to apply" }, { "nullable": null, "types": [ "Theme" ], "spread": false, "optional": true, "name": "theme", "description": "Custom theme to apply" }, { "nullable": null, "types": [ "PenStyle" ], "spread": false, "optional": true, "name": "penStyle", "description": "Custom style to apply" }, { "nullable": null, "types": [ "Behaviors" ], "spread": false, "optional": true, "name": "behaviors", "description": "Custom behaviors to apply" } ] }, { "__docId__": 69, "kind": "member", "name": "domElement", "memberof": "src/Editor.js~Editor", "static": false, "longname": "src/Editor.js~Editor#domElement", "access": "public", "description": "Inner reference to the DOM Element", "lineNumber": 447, "type": { "nullable": null, "types": [ "Element" ], "spread": false, "description": null } }, { "__docId__": 70, "kind": "member", "name": "loader", "memberof": "src/Editor.js~Editor", "static": false, "longname": "src/Editor.js~Editor#loader", "access": "public", "description": null, "lineNumber": 451, "undocument": true, "type": { "types": [ "*" ] } }, { "__docId__": 72, "kind": "member", "name": "error", "memberof": "src/Editor.js~Editor", "static": false, "longname": "src/Editor.js~Editor#error", "access": "public", "description": null, "lineNumber": 456, "undocument": true, "type": { "types": [ "*" ] } }, { "__docId__": 74, "kind": "member", "name": "exportTimer", "memberof": "src/Editor.js~Editor", "static": false, "longname": "src/Editor.js~Editor#exportTimer", "access": "public", "description": "Launch export timer", "lineNumber": 464, "type": { "nullable": null, "types": [ "Number" ], "spread": false, "description": null } }, { "__docId__": 75, "kind": "member", "name": "resizeTimer", "memberof": "src/Editor.js~Editor", "static": false, "longname": "src/Editor.js~Editor#resizeTimer", "access": "public", "description": "Launch resize timer", "lineNumber": 470, "type": { "nullable": null, "types": [ "Number" ], "spread": false, "description": null } }, { "__docId__": 76, "kind": "member", "name": "notifyTimer", "memberof": "src/Editor.js~Editor", "static": false, "longname": "src/Editor.js~Editor#notifyTimer", "access": "public", "description": "Notify delay timer", "lineNumber": 476, "type": { "nullable": null, "types": [ "Number" ], "spread": false, "description": null } }, { "__docId__": 77, "kind": "member", "name": "innerBehaviors", "memberof": "src/Editor.js~Editor", "static": false, "longname": "src/Editor.js~Editor#innerBehaviors", "access": "private", "description": "", "lineNumber": 483, "type": { "nullable": null, "types": [ "Behaviors" ], "spread": false, "description": null } }, { "__docId__": 79, "kind": "member", "name": "smartGuide", "memberof": "src/Editor.js~Editor", "static": false, "longname": "src/Editor.js~Editor#smartGuide", "access": "public", "description": null, "lineNumber": 485, "undocument": true, "type": { "types": [ "*" ] } }, { "__docId__": 80, "kind": "member", "name": "localTheme", "memberof": "src/Editor.js~Editor", "static": false, "longname": "src/Editor.js~Editor#localTheme", "access": "public", "description": "Pen color used only for pending stroke", "lineNumber": 491, "type": { "nullable": null, "types": [ "string" ], "spread": false, "description": null } }, { "__docId__": 84, "kind": "set", "name": "configuration", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#configuration", "access": "public", "description": "Set the recognition parameters\nWARNING : Need to fire a clear if user have already input some strokes.", "lineNumber": 505, "params": [ { "nullable": null, "types": [ "Configuration" ], "spread": false, "optional": false, "name": "configuration", "description": "" } ] }, { "__docId__": 85, "kind": "member", "name": "innerConfiguration", "memberof": "src/Editor.js~Editor", "static": false, "longname": "src/Editor.js~Editor#innerConfiguration", "access": "private", "description": "", "lineNumber": 512, "type": { "nullable": null, "types": [ "Configuration" ], "spread": false, "description": null } }, { "__docId__": 87, "kind": "get", "name": "configuration", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#configuration", "access": "public", "description": "Get the current recognition parameters", "lineNumber": 521, "return": { "nullable": null, "types": [ "Configuration" ], "spread": false, "description": "" }, "type": { "types": [ "*" ] } }, { "__docId__": 88, "kind": "set", "name": "penStyle", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#penStyle", "access": "public", "description": "Set the pen style", "lineNumber": 529, "params": [ { "nullable": null, "types": [ "PenStyle" ], "spread": false, "optional": false, "name": "penStyle", "description": "" } ] }, { "__docId__": 89, "kind": "member", "name": "innerPenStyle", "memberof": "src/Editor.js~Editor", "static": false, "longname": "src/Editor.js~Editor#innerPenStyle", "access": "private", "description": "", "lineNumber": 534, "type": { "nullable": null, "types": [ "PenStyle" ], "spread": false, "description": null } }, { "__docId__": 90, "kind": "member", "name": "localPenStyle", "memberof": "src/Editor.js~Editor", "static": false, "longname": "src/Editor.js~Editor#localPenStyle", "access": "public", "description": null, "lineNumber": 535, "undocument": true, "type": { "types": [ "*" ] } }, { "__docId__": 91, "kind": "get", "name": "penStyle", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#penStyle", "access": "public", "description": "Get the pen style", "lineNumber": 543, "return": { "nullable": null, "types": [ "PenStyle" ], "spread": false, "description": "" }, "type": { "types": [ "*" ] } }, { "__docId__": 92, "kind": "set", "name": "penStyleClasses", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#penStyleClasses", "access": "public", "description": "Set the pen style", "lineNumber": 551, "params": [ { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "penStyleClasses", "description": "" } ] }, { "__docId__": 93, "kind": "member", "name": "innerPenStyleClasses", "memberof": "src/Editor.js~Editor", "static": false, "longname": "src/Editor.js~Editor#innerPenStyleClasses", "access": "private", "description": "", "lineNumber": 556, "type": { "nullable": null, "types": [ "String" ], "spread": false, "description": null } }, { "__docId__": 95, "kind": "get", "name": "penStyleClasses", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#penStyleClasses", "access": "public", "description": "Get the pen style", "lineNumber": 565, "return": { "nullable": null, "types": [ "String" ], "spread": false, "description": "" }, "type": { "types": [ "*" ] } }, { "__docId__": 96, "kind": "set", "name": "theme", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#theme", "access": "public", "description": "Set the theme", "lineNumber": 573, "params": [ { "nullable": null, "types": [ "Theme" ], "spread": false, "optional": false, "name": "theme", "description": "" } ] }, { "__docId__": 97, "kind": "member", "name": "innerTheme", "memberof": "src/Editor.js~Editor", "static": false, "longname": "src/Editor.js~Editor#innerTheme", "access": "private", "description": "", "lineNumber": 578, "type": { "nullable": null, "types": [ "Theme" ], "spread": false, "description": null } }, { "__docId__": 98, "kind": "get", "name": "theme", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#theme", "access": "public", "description": "Get the theme", "lineNumber": 586, "return": { "nullable": null, "types": [ "Theme" ], "spread": false, "description": "" }, "type": { "types": [ "*" ] } }, { "__docId__": 99, "kind": "get", "name": "behaviors", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#behaviors", "access": "public", "description": "Get behaviors", "lineNumber": 594, "return": { "nullable": null, "types": [ "Behaviors" ], "spread": false, "description": "" }, "type": { "types": [ "*" ] } }, { "__docId__": 100, "kind": "set", "name": "behavior", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#behavior", "access": "private", "description": "", "lineNumber": 602, "params": [ { "nullable": null, "types": [ "Behavior" ], "spread": false, "optional": false, "name": "behavior", "description": "" } ] }, { "__docId__": 101, "kind": "member", "name": "innerBehavior", "memberof": "src/Editor.js~Editor", "static": false, "longname": "src/Editor.js~Editor#innerBehavior", "access": "private", "description": "", "lineNumber": 611, "type": { "nullable": null, "types": [ "Behavior" ], "spread": false, "description": null } }, { "__docId__": 104, "kind": "member", "name": "grabberContext", "memberof": "src/Editor.js~Editor", "static": false, "longname": "src/Editor.js~Editor#grabberContext", "access": "public", "description": "Current grabber context", "lineNumber": 618, "type": { "nullable": null, "types": [ "GrabberContext" ], "spread": false, "description": null } }, { "__docId__": 105, "kind": "get", "name": "behavior", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#behavior", "access": "public", "description": "Get current behavior", "lineNumber": 626, "return": { "nullable": null, "types": [ "Behavior" ], "spread": false, "description": "" }, "type": { "types": [ "*" ] } }, { "__docId__": 106, "kind": "set", "name": "recognizer", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#recognizer", "access": "private", "description": "Set the current recognizer", "lineNumber": 635, "params": [ { "nullable": null, "types": [ "Recognizer" ], "spread": false, "optional": false, "name": "recognizer", "description": "" } ] }, { "__docId__": 107, "kind": "member", "name": "undoRedoContext", "memberof": "src/Editor.js~Editor", "static": false, "longname": "src/Editor.js~Editor#undoRedoContext", "access": "public", "description": null, "lineNumber": 636, "undocument": true, "type": { "types": [ "*" ] } }, { "__docId__": 108, "kind": "member", "name": "undoRedoManager", "memberof": "src/Editor.js~Editor", "static": false, "longname": "src/Editor.js~Editor#undoRedoManager", "access": "public", "description": null, "lineNumber": 637, "undocument": true, "type": { "types": [ "*" ] } }, { "__docId__": 109, "kind": "member", "name": "innerRecognizer", "memberof": "src/Editor.js~Editor", "static": false, "longname": "src/Editor.js~Editor#innerRecognizer", "access": "private", "description": "", "lineNumber": 644, "type": { "nullable": null, "types": [ "Recognizer" ], "spread": false, "description": null } }, { "__docId__": 110, "kind": "member", "name": "recognizerContext", "memberof": "src/Editor.js~Editor", "static": false, "longname": "src/Editor.js~Editor#recognizerContext", "access": "public", "description": "Current recognition context", "lineNumber": 650, "type": { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "description": null } }, { "__docId__": 113, "kind": "member", "name": "model", "memberof": "src/Editor.js~Editor", "static": false, "longname": "src/Editor.js~Editor#model", "access": "public", "description": "Current model", "lineNumber": 677, "type": { "nullable": null, "types": [ "Model" ], "spread": false, "description": null } }, { "__docId__": 114, "kind": "get", "name": "recognizer", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#recognizer", "access": "public", "description": "Get current recognizer", "lineNumber": 689, "return": { "nullable": null, "types": [ "Recognizer" ], "spread": false, "description": "" }, "type": { "types": [ "*" ] } }, { "__docId__": 115, "kind": "set", "name": "renderer", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#renderer", "access": "private", "description": "Set the current renderer", "lineNumber": 698, "params": [ { "nullable": null, "types": [ "Renderer" ], "spread": false, "optional": false, "name": "renderer", "description": "" } ] }, { "__docId__": 116, "kind": "member", "name": "innerRenderer", "memberof": "src/Editor.js~Editor", "static": false, "longname": "src/Editor.js~Editor#innerRenderer", "access": "private", "description": "", "lineNumber": 708, "type": { "nullable": null, "types": [ "Renderer" ], "spread": false, "description": null } }, { "__docId__": 117, "kind": "member", "name": "rendererContext", "memberof": "src/Editor.js~Editor", "static": false, "longname": "src/Editor.js~Editor#rendererContext", "access": "public", "description": "Current rendering context", "lineNumber": 714, "type": { "nullable": null, "types": [ "Object" ], "spread": false, "description": null } }, { "__docId__": 118, "kind": "get", "name": "renderer", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#renderer", "access": "public", "description": "Get current renderer", "lineNumber": 723, "return": { "nullable": null, "types": [ "Renderer" ], "spread": false, "description": "" }, "type": { "types": [ "*" ] } }, { "__docId__": 119, "kind": "get", "name": "grabber", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#grabber", "access": "public", "description": "Get current grabber", "lineNumber": 731, "return": { "nullable": null, "types": [ "Grabber" ], "spread": false, "description": "" }, "type": { "types": [ "*" ] } }, { "__docId__": 120, "kind": "get", "name": "stroker", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#stroker", "access": "public", "description": "Get current stroker", "lineNumber": 739, "return": { "nullable": null, "types": [ "Stroker" ], "spread": false, "description": "" }, "type": { "types": [ "*" ] } }, { "__docId__": 121, "kind": "get", "name": "callbacks", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#callbacks", "access": "public", "description": "Get current callbacks", "lineNumber": 747, "return": { "nullable": null, "types": [ "Array" ], "spread": false, "description": "" }, "type": { "types": [ "*" ] } }, { "__docId__": 122, "kind": "get", "name": "png", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#png", "access": "public", "description": "Get a PNG image data url from the data model", "lineNumber": 755, "return": { "nullable": null, "types": [ "String" ], "spread": false, "description": "" }, "type": { "types": [ "*" ] } }, { "__docId__": 123, "kind": "method", "name": "getStats", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#getStats", "access": "public", "description": "Get statistics to monitor what ink size is send to the server.", "lineNumber": 763, "return": { "nullable": null, "types": [ "Stats" ], "spread": false, "description": "" }, "params": [] }, { "__docId__": 124, "kind": "get", "name": "initialized", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#initialized", "access": "public", "description": "True if initialized, false otherwise", "lineNumber": 771, "return": { "nullable": null, "types": [ "Boolean" ], "spread": false, "description": "" }, "type": { "types": [ "*" ] } }, { "__docId__": 125, "kind": "method", "name": "pointerDown", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#pointerDown", "access": "public", "description": "Handle a pointer down", "lineNumber": 781, "params": [ { "nullable": null, "types": [ "{x: Number, y: Number, t: Number}" ], "spread": false, "optional": false, "name": "point", "description": "Captured point coordinates" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": true, "defaultValue": "mouse", "defaultRaw": "mouse", "name": "pointerType", "description": "Current pointer type" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": true, "name": "pointerId", "description": "Current pointer id" } ], "return": null }, { "__docId__": 127, "kind": "method", "name": "pointerMove", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#pointerMove", "access": "public", "description": "Handle a pointer move", "lineNumber": 794, "params": [ { "nullable": null, "types": [ "{x: Number, y: Number, t: Number}" ], "spread": false, "optional": false, "name": "point", "description": "Captured point coordinates" } ], "return": null }, { "__docId__": 129, "kind": "method", "name": "pointerUp", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#pointerUp", "access": "public", "description": "Handle a pointer up", "lineNumber": 805, "params": [ { "nullable": null, "types": [ "{x: Number, y: Number, t: Number}" ], "spread": false, "optional": false, "name": "point", "description": "Captured point coordinates" } ], "return": null }, { "__docId__": 131, "kind": "method", "name": "removeStroke", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#removeStroke", "access": "public", "description": null, "lineNumber": 818, "undocument": true, "params": [ { "name": "stroke", "types": [ "*" ] } ], "return": null }, { "__docId__": 132, "kind": "method", "name": "reDraw", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#reDraw", "access": "public", "description": "", "lineNumber": 843, "unknown": [ { "tagName": "@Deprecated", "tagValue": "" } ], "params": [ { "nullable": null, "types": [ "*" ], "spread": false, "optional": false, "name": "rawStrokes", "description": "" }, { "nullable": null, "types": [ "*" ], "spread": false, "optional": false, "name": "strokeGroups", "description": "" } ], "return": null }, { "__docId__": 133, "kind": "get", "name": "idle", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#idle", "access": "public", "description": "True if idle state", "lineNumber": 860, "return": { "nullable": null, "types": [ "Boolean" ], "spread": false, "description": "" }, "type": { "types": [ "*" ] } }, { "__docId__": 134, "kind": "method", "name": "waitForIdle", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#waitForIdle", "access": "public", "description": "Wait for idle state.", "lineNumber": 867, "params": [], "return": null }, { "__docId__": 135, "kind": "get", "name": "canUndo", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#canUndo", "access": "public", "description": "True if can undo, false otherwise.", "lineNumber": 876, "return": { "nullable": null, "types": [ "Boolean" ], "spread": false, "description": "" }, "type": { "types": [ "*" ] } }, { "__docId__": 136, "kind": "method", "name": "undo", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#undo", "access": "public", "description": "Undo the last action.", "lineNumber": 883, "params": [], "return": null }, { "__docId__": 137, "kind": "get", "name": "canRedo", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#canRedo", "access": "public", "description": "True if can redo, false otherwise.", "lineNumber": 895, "return": { "nullable": null, "types": [ "Boolean" ], "spread": false, "description": "" }, "type": { "types": [ "*" ] } }, { "__docId__": 138, "kind": "method", "name": "redo", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#redo", "access": "public", "description": "Redo the last action.", "lineNumber": 902, "params": [], "return": null }, { "__docId__": 139, "kind": "get", "name": "isEmpty", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#isEmpty", "access": "public", "description": "True if empty, false otherwise", "lineNumber": 914, "unknown": [ { "tagName": "@returns", "tagValue": "{boolean}" } ], "return": { "nullable": null, "types": [ "boolean" ], "spread": false, "description": "" }, "type": { "types": [ "*" ] } }, { "__docId__": 140, "kind": "get", "name": "canClear", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#canClear", "access": "public", "description": "True if can clear, false otherwise.", "lineNumber": 922, "return": { "nullable": null, "types": [ "Boolean" ], "spread": false, "description": "" }, "type": { "types": [ "*" ] } }, { "__docId__": 141, "kind": "method", "name": "clear", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#clear", "access": "public", "description": "Clear the output and the recognition result.", "lineNumber": 929, "params": [], "return": null }, { "__docId__": 142, "kind": "get", "name": "canConvert", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#canConvert", "access": "public", "description": "True if can convert, false otherwise.", "lineNumber": 943, "return": { "nullable": null, "types": [ "Boolean" ], "spread": false, "description": "" }, "type": { "types": [ "*" ] } }, { "__docId__": 143, "kind": "method", "name": "convert", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#convert", "access": "public", "description": "Convert the current content", "lineNumber": 950, "params": [ { "name": "conversionState", "optional": true, "types": [ "string" ], "defaultRaw": "DIGITAL_EDIT", "defaultValue": "DIGITAL_EDIT" } ], "return": null }, { "__docId__": 144, "kind": "method", "name": "setGuides", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#setGuides", "access": "public", "description": "Set the guides for text", "lineNumber": 961, "params": [ { "nullable": null, "types": [ "Boolean" ], "spread": false, "optional": true, "name": "enable", "description": "" } ], "return": null }, { "__docId__": 145, "kind": "get", "name": "possibleUndoCount", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#possibleUndoCount", "access": "public", "description": "Return the position of the cursor identifying the current state in the internal iink undo/redo stack.", "lineNumber": 970, "unknown": [ { "tagName": "@returns", "tagValue": "{Number}" } ], "return": { "nullable": null, "types": [ "Number" ], "spread": false, "description": "" }, "type": { "types": [ "*" ] } }, { "__docId__": 146, "kind": "get", "name": "undoStackIndex", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#undoStackIndex", "access": "public", "description": "The number of operations that it is currently possible to undo.", "lineNumber": 978, "unknown": [ { "tagName": "@returns", "tagValue": "{Number}" } ], "return": { "nullable": null, "types": [ "Number" ], "spread": false, "description": "" }, "type": { "types": [ "*" ] } }, { "__docId__": 147, "kind": "get", "name": "canExport", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#canExport", "access": "public", "description": "True if can export, false otherwise.", "lineNumber": 986, "return": { "nullable": null, "types": [ "Boolean" ], "spread": false, "description": "" }, "type": { "types": [ "*" ] } }, { "__docId__": 148, "kind": "method", "name": "export_", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#export_", "access": "public", "description": "Explicitly ask to perform an export. You have to listen to events to get the content as this function is non blocking and does not have a return type.", "lineNumber": 994, "params": [ { "nullable": null, "types": [ "Array" ], "spread": false, "optional": false, "name": "requestedMimeTypes", "description": "Requested mime-types. Be sure to ask all the types required by the listeners of exported event." } ], "return": null }, { "__docId__": 149, "kind": "method", "name": "import_", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#import_", "access": "public", "description": "Import content.", "lineNumber": 1006, "params": [ { "nullable": null, "types": [ "Blob", "*" ], "spread": false, "optional": false, "name": "data", "description": "Data to import" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": true, "name": "mimetype", "description": "Mimetype of the data, needed if data is not a Blob" } ], "return": null }, { "__docId__": 150, "kind": "method", "name": "getSupportedImportMimeTypes", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#getSupportedImportMimeTypes", "access": "public", "description": "Get supported import mime types", "lineNumber": 1014, "params": [], "return": null }, { "__docId__": 151, "kind": "method", "name": "pointerEvents", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#pointerEvents", "access": "public", "description": "pointer events", "lineNumber": 1022, "params": [ { "nullable": null, "types": [ "PointerEvents" ], "spread": false, "optional": false, "name": "events", "description": "" } ], "return": null }, { "__docId__": 152, "kind": "get", "name": "exports", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#exports", "access": "public", "description": "Get current state exports", "lineNumber": 1030, "return": { "nullable": null, "types": [ "Object" ], "spread": false, "description": "" }, "type": { "types": [ "*" ] } }, { "__docId__": 153, "kind": "get", "name": "supportedImportMimeTypes", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#supportedImportMimeTypes", "access": "public", "description": null, "lineNumber": 1034, "undocument": true, "type": { "types": [ "*" ] } }, { "__docId__": 154, "kind": "method", "name": "resize", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#resize", "access": "public", "description": "Function to call when the dom element link to the current ink paper has been resize.", "lineNumber": 1041, "params": [], "return": null }, { "__docId__": 155, "kind": "method", "name": "setThemeForFont", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#setThemeForFont", "access": "public", "description": "Set the theme (font family, font size and line height) depending on the language", "lineNumber": 1051, "params": [ { "nullable": null, "types": [ "*" ], "spread": false, "optional": false, "name": "lang", "description": "" } ], "return": null }, { "__docId__": 157, "kind": "method", "name": "unload", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#unload", "access": "public", "description": "Detach event listeners from the DOM element created at editor creation.", "lineNumber": 1067, "params": [], "return": null }, { "__docId__": 158, "kind": "method", "name": "forceChange", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#forceChange", "access": "public", "description": "Trigger the change callbacks (and by default send a change event).", "lineNumber": 1079, "params": [], "return": null }, { "__docId__": 159, "kind": "get", "name": "eastereggs", "memberof": "src/Editor.js~Editor", "generator": false, "async": false, "static": false, "longname": "src/Editor.js~Editor#eastereggs", "access": "public", "description": "Get access to some easter egg features link ink injection. Use at your own risk (less tested and may be removed without notice).", "lineNumber": 1087, "type": { "types": [ "*" ] } }, { "__docId__": 160, "kind": "file", "name": "src/EditorFacade.js", "content": "import * as languagesJson from './configuration/languages.json';\nimport * as languagesJsonV3 from './configuration/languagesV3.json';\nimport { editorLogger as logger } from './configuration/LoggerConfig';\nimport { Editor } from './Editor';\nimport * as DefaultConfiguration from './configuration/DefaultConfiguration';\n\n/**\n * Attach an Editor to a DOMElement\n * @param {Element} element DOM element to attach an editor\n * @param {Configuration} [configuration] Configuration to apply\n * @param {PenStyle} [penStyle] Pen style to apply\n * @param {Theme} [theme] Theme to apply\n * @param {Behaviors} [behaviors] Custom behaviors to apply\n * @return {Editor} New editor\n */\nexport function register(element, configuration, penStyle, theme, behaviors) {\n logger.debug('Registering a new editor');\n return new Editor(element, configuration, penStyle, theme, behaviors);\n}\n\n/**\n * Return the list of available recognition languages\n * @param {Configuration} [configuration] Configuration to get the languages\n * @return {JSON} A list of available languages\n */\nexport function getAvailableLanguageList(configuration) {\n const innerConfiguration = DefaultConfiguration.overrideDefaultConfiguration(configuration);\n return innerConfiguration.recognitionParams.apiVersion === 'V4' ? languagesJson : languagesJsonV3;\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/EditorFacade.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 161, "kind": "function", "name": "register", "memberof": "src/EditorFacade.js", "generator": false, "async": false, "static": true, "longname": "src/EditorFacade.js~register", "access": "public", "export": true, "importPath": "myscript/src/EditorFacade.js", "importStyle": "{register}", "description": "Attach an Editor to a DOMElement", "lineNumber": 16, "params": [ { "nullable": null, "types": [ "Element" ], "spread": false, "optional": false, "name": "element", "description": "DOM element to attach an editor" }, { "nullable": null, "types": [ "Configuration" ], "spread": false, "optional": true, "name": "configuration", "description": "Configuration to apply" }, { "nullable": null, "types": [ "PenStyle" ], "spread": false, "optional": true, "name": "penStyle", "description": "Pen style to apply" }, { "nullable": null, "types": [ "Theme" ], "spread": false, "optional": true, "name": "theme", "description": "Theme to apply" }, { "nullable": null, "types": [ "Behaviors" ], "spread": false, "optional": true, "name": "behaviors", "description": "Custom behaviors to apply" } ], "return": { "nullable": null, "types": [ "Editor" ], "spread": false, "description": "New editor" } }, { "__docId__": 162, "kind": "function", "name": "getAvailableLanguageList", "memberof": "src/EditorFacade.js", "generator": false, "async": false, "static": true, "longname": "src/EditorFacade.js~getAvailableLanguageList", "access": "public", "export": true, "importPath": "myscript/src/EditorFacade.js", "importStyle": "{getAvailableLanguageList}", "description": "Return the list of available recognition languages", "lineNumber": 26, "params": [ { "nullable": null, "types": [ "Configuration" ], "spread": false, "optional": true, "name": "configuration", "description": "Configuration to get the languages" } ], "return": { "nullable": null, "types": [ "JSON" ], "spread": false, "description": "A list of available languages" } }, { "__docId__": 163, "kind": "file", "name": "src/callback/EventCallback.js", "content": "import { callbackLogger as logger } from '../configuration/LoggerConfig';\n\n/**\n * Emits an event when the editor state change\n * @param {String} type\n * @param {Object} data\n * @emits {Event}\n */\nexport default function eventCallback(type, data) {\n logger.info(`emitting ${type} event`, data);\n // We are making usage of a browser provided class\n // eslint-disable-next-line no-undef\n this.dispatchEvent(new CustomEvent(type, Object.assign({ bubbles: true, composed: true }, data ? { detail: data } : undefined)));\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/callback/EventCallback.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 164, "kind": "function", "name": "eventCallback", "memberof": "src/callback/EventCallback.js", "generator": false, "async": false, "static": true, "longname": "src/callback/EventCallback.js~eventCallback", "access": "public", "export": true, "importPath": "myscript/src/callback/EventCallback.js", "importStyle": "eventCallback", "description": "Emits an event when the editor state change", "lineNumber": 9, "params": [ { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "type", "description": "" }, { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "data", "description": "" } ], "emits": [ { "types": [ "Event" ], "description": "" } ], "return": null }, { "__docId__": 165, "kind": "file", "name": "src/configuration/Constants.js", "content": "/**\n * @typedef {Object} Constants\n */\n\nconst Constants = {\n EventType: {\n IDLE: 'idle',\n CHANGED: 'changed',\n IMPORTED: 'imported',\n EXPORTED: 'exported',\n CONVERTED: 'converted',\n RENDERED: 'rendered', // Internal use only\n LOADED: 'loaded',\n UNDO: 'undo',\n REDO: 'redo',\n CLEAR: 'clear',\n IMPORT: 'import',\n SUPPORTED_IMPORT_MIMETYPES: 'supportedImportMimeTypes',\n EXPORT: 'export',\n CONVERT: 'convert',\n ERROR: 'error'\n },\n RecognitionType: {\n TEXT: 'TEXT',\n MATH: 'MATH',\n SHAPE: 'SHAPE',\n MUSIC: 'MUSIC',\n ANALYZER: 'ANALYZER',\n DIAGRAM: 'DIAGRAM',\n NEBO: 'NEBO',\n RAWCONTENT: 'Raw Content'\n },\n Protocol: {\n WEBSOCKET: 'WEBSOCKET',\n REST: 'REST'\n },\n ModelState: {\n INITIALIZING: 'INITIALIZING',\n INITIALIZED: 'INITIALIZED',\n EXPORTING: 'EXPORTING',\n EXPORTED: 'EXPORTED',\n PENDING: 'PENDING',\n MODIFIED: 'MODIFIED',\n ERROR: 'ERROR'\n },\n Trigger: {\n QUIET_PERIOD: 'QUIET_PERIOD',\n POINTER_UP: 'POINTER_UP',\n DEMAND: 'DEMAND'\n },\n Logger: {\n EDITOR: 'editor',\n MODEL: 'model',\n GRABBER: 'grabber',\n RENDERER: 'renderer',\n RECOGNIZER: 'recognizer',\n CALLBACK: 'callback',\n UTIL: 'util',\n SMARTGUIDE: 'smartguide'\n },\n LogLevel: {\n TRACE: 'TRACE',\n DEBUG: 'DEBUG',\n INFO: 'INFO',\n WARN: 'WARN',\n ERROR: 'ERROR'\n },\n Languages: {\n zh_CN: 'Noto Sans CJK tc',\n zh_HK: 'Noto Sans CJK tc',\n zh_TW: 'Noto Sans CJK tc',\n ko_KR: 'Noto Sans CJK kr',\n ja_JP: 'Noto Sans CJK jp',\n hy_AM: 'Noto Sans Armenian',\n default: 'Open Sans'\n },\n Error: {\n NOT_REACHABLE: 'MyScript recognition server is not reachable. Please reload once you are connected.',\n WRONG_CREDENTIALS: 'Application credentials are invalid. Please check or regenerate your application key and hmackey.',\n TOO_OLD: 'Session is too old. Max Session Duration Reached.'\n },\n Exports: {\n JIIX: 'application/vnd.myscript.jiix'\n }\n};\nexport default Constants;\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/configuration/Constants.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 166, "kind": "typedef", "name": "Constants", "memberof": "src/configuration/Constants.js", "static": true, "longname": "src/configuration/Constants.js~Constants", "access": "public", "description": "", "lineNumber": 5, "type": { "types": [ "Object" ], "optional": false, "name": "Constants" } }, { "__docId__": 167, "kind": "file", "name": "src/configuration/DefaultBehaviors.js", "content": "import { editorLogger as logger } from './LoggerConfig';\nimport * as PointerEventGrabber from '../grabber/PointerEventGrabber';\nimport * as CanvasRenderer from '../renderer/canvas/CanvasRenderer';\nimport * as QuadraticCanvasStroker from '../renderer/canvas/stroker/QuadraticCanvasStroker';\nimport * as SVGRenderer from '../renderer/svg/SVGRenderer';\nimport * as QuadraticSVGStroker from '../renderer/svg/stroker/QuadraticSVGStroker';\nimport * as Cdkv3RestTextRecognizer from '../recognizer/rest/v3/Cdkv3RestTextRecognizer';\nimport * as Cdkv3RestMathRecognizer from '../recognizer/rest/v3/Cdkv3RestMathRecognizer';\nimport * as Cdkv3RestAnalyzerRecognizer from '../recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer';\nimport * as Cdkv3RestShapeRecognizer from '../recognizer/rest/v3/Cdkv3RestShapeRecognizer';\nimport * as Cdkv3RestMusicRecognizer from '../recognizer/rest/v3/Cdkv3RestMusicRecognizer';\nimport * as iinkRestRecognizer from '../recognizer/rest/v4/iinkRestRecognizer';\nimport * as Cdkv3WSMathRecognizer from '../recognizer/websocket/v3/Cdkv3WSMathRecognizer';\nimport * as Cdkv3WSTextRecognizer from '../recognizer/websocket/v3/Cdkv3WSTextRecognizer';\nimport * as Cdkv4WSInteractiveRecognizer from '../recognizer/websocket/v4/Cdkv4WSIInkRecognizer';\nimport eventCallback from '../callback/EventCallback';\n\n/**\n * Current behavior\n * @typedef {Object} Behavior\n * @property {Grabber} grabber Grabber to capture strokes\n * @property {Stroker} stroker Stroker to draw stroke\n * @property {Renderer} renderer Renderer to draw on the editor\n * @property {Recognizer} recognizer Recognizer to call the recognition service\n * @property {Array} callbacks Functions to handle model changes\n */\n\n/**\n * Set of behaviors to be used by the {@link Editor}\n * @typedef {Object} Behaviors\n * @property {Grabber} grabber Grabber to capture strokes\n * @property {Array} strokerList List of stroker to draw stroke\n * @property {Array} rendererList List of renderer to draw on the editor\n * @property {Array} recognizerList Recognizers to call the recognition service\n * @property {function(behaviors: Behaviors, configuration: Configuration): Behavior} getBehaviorFromConfiguration Get the current behavior to use regarding the current configuration\n * @property {Array} callbacks Functions to handle model changes\n */\n\n/**\n * Default behaviors\n * @type {Behaviors}\n */\nexport const defaultBehaviors = {\n grabber: PointerEventGrabber,\n strokerList: [QuadraticCanvasStroker, QuadraticSVGStroker],\n rendererList: [CanvasRenderer, SVGRenderer],\n recognizerList: [Cdkv3RestTextRecognizer, Cdkv3RestMathRecognizer, Cdkv3RestAnalyzerRecognizer, Cdkv3RestShapeRecognizer, Cdkv3RestMusicRecognizer, iinkRestRecognizer, Cdkv3WSTextRecognizer, Cdkv3WSMathRecognizer, Cdkv4WSInteractiveRecognizer],\n callbacks: [eventCallback],\n getBehaviorFromConfiguration: (behaviors, configuration) => {\n const behavior = {};\n behavior.grabber = behaviors.grabber;\n if (configuration) {\n if (configuration.recognitionParams.apiVersion === 'V4' && configuration.recognitionParams.protocol === 'REST') {\n behavior.stroker = QuadraticCanvasStroker;\n } else {\n behavior.stroker = behaviors.strokerList.find(item =>\n (item.getInfo().apiVersion === configuration.recognitionParams.apiVersion) &&\n (item.getInfo().name === configuration.renderingParams.stroker));\n }\n if (configuration.recognitionParams.apiVersion === 'V4' && configuration.recognitionParams.protocol === 'REST') {\n behavior.renderer = CanvasRenderer;\n } else {\n behavior.renderer = behaviors.rendererList.find(item => item.getInfo().apiVersion === configuration.recognitionParams.apiVersion);\n }\n behavior.recognizer = behaviors.recognizerList.find(item =>\n (item.getInfo()\n .types\n .includes(configuration.recognitionParams.type)) &&\n (item.getInfo().protocol === configuration.recognitionParams.protocol) &&\n (item.getInfo().apiVersion === configuration.recognitionParams.apiVersion));\n }\n behavior.callbacks = behaviors.callbacks;\n return behavior;\n }\n};\n\n/**\n * Generate behaviors\n * @param {Behaviors} behaviors Behaviors to be used\n * @return {Behaviors} Overridden behaviors\n */\nexport function overrideDefaultBehaviors(behaviors) {\n if (behaviors) {\n const currentBehaviors = {\n grabber: behaviors.grabber || defaultBehaviors.grabber,\n rendererList: behaviors.rendererList || defaultBehaviors.rendererList,\n strokerList: behaviors.strokerList || defaultBehaviors.strokerList,\n recognizerList: behaviors.recognizerList || defaultBehaviors.recognizerList,\n callbacks: behaviors.callbacks || defaultBehaviors.callbacks,\n getBehaviorFromConfiguration: behaviors.getBehaviorFromConfiguration || defaultBehaviors.getBehaviorFromConfiguration\n };\n logger.debug('Override default behaviors', currentBehaviors);\n return currentBehaviors;\n }\n return defaultBehaviors;\n}\n\nexport default defaultBehaviors;\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/configuration/DefaultBehaviors.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 168, "kind": "typedef", "name": "Behavior", "memberof": "src/configuration/DefaultBehaviors.js", "static": true, "longname": "src/configuration/DefaultBehaviors.js~Behavior", "access": "public", "description": "Current behavior", "properties": [ { "nullable": null, "types": [ "Grabber" ], "spread": false, "optional": false, "name": "grabber", "description": "Grabber to capture strokes" }, { "nullable": null, "types": [ "Stroker" ], "spread": false, "optional": false, "name": "stroker", "description": "Stroker to draw stroke" }, { "nullable": null, "types": [ "Renderer" ], "spread": false, "optional": false, "name": "renderer", "description": "Renderer to draw on the editor" }, { "nullable": null, "types": [ "Recognizer" ], "spread": false, "optional": false, "name": "recognizer", "description": "Recognizer to call the recognition service" }, { "nullable": null, "types": [ "Array" ], "spread": false, "optional": false, "name": "callbacks", "description": "Functions to handle model changes" } ], "type": { "types": [ "Object" ], "optional": false, "name": "Behavior" } }, { "__docId__": 169, "kind": "typedef", "name": "Behaviors", "memberof": "src/configuration/DefaultBehaviors.js", "static": true, "longname": "src/configuration/DefaultBehaviors.js~Behaviors", "access": "public", "description": "Set of behaviors to be used by the {@link Editor}", "properties": [ { "nullable": null, "types": [ "Grabber" ], "spread": false, "optional": false, "name": "grabber", "description": "Grabber to capture strokes" }, { "nullable": null, "types": [ "Array" ], "spread": false, "optional": false, "name": "strokerList", "description": "List of stroker to draw stroke" }, { "nullable": null, "types": [ "Array" ], "spread": false, "optional": false, "name": "rendererList", "description": "List of renderer to draw on the editor" }, { "nullable": null, "types": [ "Array" ], "spread": false, "optional": false, "name": "recognizerList", "description": "Recognizers to call the recognition service" }, { "nullable": null, "types": [ "function(behaviors: Behaviors, configuration: Configuration): Behavior" ], "spread": false, "optional": false, "name": "getBehaviorFromConfiguration", "description": "Get the current behavior to use regarding the current configuration" }, { "nullable": null, "types": [ "Array" ], "spread": false, "optional": false, "name": "callbacks", "description": "Functions to handle model changes" } ], "type": { "types": [ "Object" ], "optional": false, "name": "Behaviors" } }, { "__docId__": 170, "kind": "variable", "name": "defaultBehaviors", "memberof": "src/configuration/DefaultBehaviors.js", "static": true, "longname": "src/configuration/DefaultBehaviors.js~defaultBehaviors", "access": "public", "export": true, "importPath": "myscript/src/configuration/DefaultBehaviors.js", "importStyle": "{defaultBehaviors}", "description": "Default behaviors", "lineNumber": 43, "type": { "nullable": null, "types": [ "Behaviors" ], "spread": false, "description": null } }, { "__docId__": 171, "kind": "function", "name": "overrideDefaultBehaviors", "memberof": "src/configuration/DefaultBehaviors.js", "generator": false, "async": false, "static": true, "longname": "src/configuration/DefaultBehaviors.js~overrideDefaultBehaviors", "access": "public", "export": true, "importPath": "myscript/src/configuration/DefaultBehaviors.js", "importStyle": "{overrideDefaultBehaviors}", "description": "Generate behaviors", "lineNumber": 82, "params": [ { "nullable": null, "types": [ "Behaviors" ], "spread": false, "optional": false, "name": "behaviors", "description": "Behaviors to be used" } ], "return": { "nullable": null, "types": [ "Behaviors" ], "spread": false, "description": "Overridden behaviors" } }, { "__docId__": 172, "kind": "file", "name": "src/configuration/DefaultConfiguration.js", "content": "import assign from 'assign-deep';\nimport { editorLogger as logger } from './LoggerConfig';\n\n\n/**\n * Default configuration\n * @type {Configuration}\n * See https://developer.myscript.com/docs/interactive-ink/latest/reference/web/configuration/ for a full documentation of parameters.\n */\nconst defaultConfiguration = {\n recognitionParams: {\n type: 'TEXT',\n protocol: 'WEBSOCKET',\n apiVersion: 'V4',\n server: {\n scheme: 'https',\n host: 'cloud.myscript.com',\n applicationKey: undefined,\n hmacKey: undefined,\n useWindowLocation: false,\n websocket: {\n pingEnabled: true,\n pingDelay: 30000,\n maxPingLostCount: 10,\n autoReconnect: true,\n maxRetryCount: 2,\n fileChunkSize: 300000\n }\n },\n v4: {\n alwaysConnected: true,\n lang: 'en_US',\n export: {\n 'image-resolution': 300,\n jiix: {\n 'bounding-box': false,\n strokes: false,\n text: {\n chars: false,\n words: true\n }\n }\n },\n renderer: {\n debug: {\n 'draw-text-boxes': false,\n 'draw-image-boxes': false\n }\n },\n math: {\n mimeTypes: ['application/x-latex', 'application/mathml+xml'],\n solver: {\n enable: true,\n 'fractional-part-digits': 3,\n 'decimal-separator': '.',\n 'rounding-mode': 'half up',\n 'angle-unit': 'deg'\n },\n margin: {\n bottom: 10,\n left: 15,\n right: 15,\n top: 10\n }\n },\n text: {\n guides: {\n enable: true\n },\n smartGuide: true,\n smartGuideFadeOut: {\n enable: false,\n duration: 10000\n },\n mimeTypes: ['text/plain', 'application/vnd.myscript.jiix'],\n margin: {\n top: 20,\n left: 10,\n right: 10\n }\n },\n diagram: {\n mimeTypes: ['application/vnd.myscript.jiix'],\n margin: {\n bottom: 10,\n left: 15,\n right: 15,\n top: 10\n }\n },\n 'raw-content': {\n recognition: {\n text: false,\n shape: false\n }\n }\n },\n v3: {\n mathParameter: {\n resultTypes: ['LATEX', 'MATHML'],\n columnarOperation: false,\n userResources: [],\n scratchOutDetectionSensitivity: 1,\n },\n textParameter: {\n language: 'en_US',\n textInputMode: 'CURSIVE',\n resultDetail: 'TEXT',\n contentTypes: [],\n subsetKnowledges: [],\n userLkWords: [],\n userResources: [],\n textProperties: {\n textCandidateListSize: 1,\n wordCandidateListSize: undefined,\n wordPredictionListSize: 0,\n wordCompletionListSize: 0,\n characterCandidateListSize: undefined,\n enableOutOfLexicon: false,\n discardCaseVariations: false,\n discardAccentuationVariations: false,\n glyphDistortion: undefined,\n enableTagger: false,\n spellingDistortion: undefined\n }\n },\n shapeParameter: {\n userResources: undefined,\n rejectDetectionSensitivity: 1,\n doBeautification: true\n },\n musicParameter: {\n divisions: 480,\n resultTypes: ['MUSICXML', 'SCORETREE'],\n userResources: [],\n staff: {\n top: 100,\n count: 5,\n gap: 20\n },\n clef: {\n symbol: 'G',\n octave: 0,\n line: 2\n },\n scratchOutDetectionSensitivity: 1\n },\n analyzerParameter: {\n textParameter: {\n textProperties: {},\n language: 'en_US',\n textInputMode: 'CURSIVE'\n },\n coordinateResolution: undefined\n }\n }\n },\n // @see generated documentation on top\n listenerOptions: {\n capture: false,\n passive: true\n },\n undoRedoMaxStackSize: 20,\n xyFloatPrecision: 0,\n timestampFloatPrecision: 0,\n triggerDelay: 2000,\n processDelay: 0,\n resizeTriggerDelay: 200,\n // Configure when the action is triggered.\n // POINTER_UP : Action is triggered on every PenUP. This is the recommended mode for CDK V3 WebSocket recognitions.\n // QUIET_PERIOD : Action is triggered after a quiet period in milli-seconds on every pointer up. I value is set to 2000 for example the recognition will be fired when user stop writing 2 seconds. This is the recommended mode for all REST recognitions.\n triggers: {\n exportContent: 'POINTER_UP',\n addStrokes: 'POINTER_UP'\n },\n restConversionState: '',\n renderingParams: {\n stroker: 'quadratic',\n minHeight: 100,\n minWidth: 100\n }\n};\n\n/**\n * Generate parameters\n * @param {Configuration} configuration Configuration to be used\n * @return {Configuration} Overridden configuration\n */\nexport function overrideDefaultConfiguration(configuration) {\n const confRef = configuration;\n let currentConfiguration;\n if (confRef && confRef.recognitionParams.server && confRef.recognitionParams.server.useWindowLocation) {\n confRef.recognitionParams.server.scheme = window.location.protocol.slice(0, -1);\n confRef.recognitionParams.server.host = window.location.host;\n currentConfiguration = assign({}, defaultConfiguration, confRef === undefined ? {} : confRef);\n } else {\n currentConfiguration = assign({}, defaultConfiguration, configuration === undefined ? {} : configuration);\n }\n logger.debug('Override default configuration', currentConfiguration);\n return currentConfiguration;\n}\n\nexport default defaultConfiguration;\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/configuration/DefaultConfiguration.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 173, "kind": "function", "name": "overrideDefaultConfiguration", "memberof": "src/configuration/DefaultConfiguration.js", "generator": false, "async": false, "static": true, "longname": "src/configuration/DefaultConfiguration.js~overrideDefaultConfiguration", "access": "public", "export": true, "importPath": "myscript/src/configuration/DefaultConfiguration.js", "importStyle": "{overrideDefaultConfiguration}", "description": "Generate parameters", "lineNumber": 189, "params": [ { "nullable": null, "types": [ "Configuration" ], "spread": false, "optional": false, "name": "configuration", "description": "Configuration to be used" } ], "return": { "nullable": null, "types": [ "Configuration" ], "spread": false, "description": "Overridden configuration" } }, { "__docId__": 174, "kind": "variable", "name": "defaultConfiguration", "memberof": "src/configuration/DefaultConfiguration.js", "static": true, "longname": "src/configuration/DefaultConfiguration.js~defaultConfiguration", "access": "public", "export": true, "importPath": "myscript/src/configuration/DefaultConfiguration.js", "importStyle": "defaultConfiguration", "description": "Default configuration", "lineNumber": 10, "type": { "nullable": null, "types": [ "Configuration" ], "spread": false, "description": null } }, { "__docId__": 175, "kind": "file", "name": "src/configuration/DefaultPenStyle.js", "content": "import JsonCSS from 'json-css';\nimport assign from 'assign-deep';\nimport { editorLogger as logger } from './LoggerConfig';\n\n/**\n * @typedef {Object} PenStyle\n * @property {String} color=#000000 Color (supported formats rgb() rgba() hsl() hsla() #rgb #rgba #rrggbb #rrggbbaa)\n * @property {String} -myscript-pen-width=1 Width of strokes and primitives in mm (no other unit is supported yet)\n * @property {String} -myscript-pen-fill-style=none\n * @property {String} -myscript-pen-fill-color=#FFFFFF00 Color filled inside the area delimited by strokes and primitives\n */\n\n/**\n * Default style\n * @type {PenStyle}\n */\nconst defaultPenStyle = undefined;\nconst parser = new JsonCSS();\n\n/**\n * Generate style\n * @param {PenStyle} style Custom style to be applied\n * @return {PenStyle} Overridden style\n */\nexport function overrideDefaultPenStyle(style) {\n const currentStyle = assign({}, defaultPenStyle, style === undefined ? {} : style);\n logger.debug('Override default pen style', currentStyle);\n return currentStyle;\n}\n\nexport function toCSS(penStyle) { // FIXME Ugly hack to parse JSON to CSS inline\n const css = parser.toCSS({ css: penStyle });\n return css.substring(6, css.length - 3);\n}\n\nexport function toJSON(penStyle) { // FIXME Ugly hack to parse CSS inline to JSON\n return parser.toJSON(`css {${penStyle}}`).css;\n}\n\nexport default defaultPenStyle;\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/configuration/DefaultPenStyle.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 176, "kind": "variable", "name": "parser", "memberof": "src/configuration/DefaultPenStyle.js", "static": true, "longname": "src/configuration/DefaultPenStyle.js~parser", "access": "public", "export": false, "importPath": "myscript/src/configuration/DefaultPenStyle.js", "importStyle": null, "description": null, "lineNumber": 18, "undocument": true, "type": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 177, "kind": "function", "name": "overrideDefaultPenStyle", "memberof": "src/configuration/DefaultPenStyle.js", "generator": false, "async": false, "static": true, "longname": "src/configuration/DefaultPenStyle.js~overrideDefaultPenStyle", "access": "public", "export": true, "importPath": "myscript/src/configuration/DefaultPenStyle.js", "importStyle": "{overrideDefaultPenStyle}", "description": "Generate style", "lineNumber": 25, "params": [ { "nullable": null, "types": [ "PenStyle" ], "spread": false, "optional": false, "name": "style", "description": "Custom style to be applied" } ], "return": { "nullable": null, "types": [ "PenStyle" ], "spread": false, "description": "Overridden style" } }, { "__docId__": 178, "kind": "function", "name": "toCSS", "memberof": "src/configuration/DefaultPenStyle.js", "generator": false, "async": false, "static": true, "longname": "src/configuration/DefaultPenStyle.js~toCSS", "access": "public", "export": true, "importPath": "myscript/src/configuration/DefaultPenStyle.js", "importStyle": "{toCSS}", "description": null, "lineNumber": 31, "undocument": true, "params": [ { "name": "penStyle", "types": [ "*" ] } ], "return": { "types": [ "*" ] } }, { "__docId__": 179, "kind": "function", "name": "toJSON", "memberof": "src/configuration/DefaultPenStyle.js", "generator": false, "async": false, "static": true, "longname": "src/configuration/DefaultPenStyle.js~toJSON", "access": "public", "export": true, "importPath": "myscript/src/configuration/DefaultPenStyle.js", "importStyle": "{toJSON}", "description": null, "lineNumber": 36, "undocument": true, "params": [ { "name": "penStyle", "types": [ "*" ] } ], "return": { "types": [ "*" ] } }, { "__docId__": 180, "kind": "typedef", "name": "PenStyle", "memberof": "src/configuration/DefaultPenStyle.js", "static": true, "longname": "src/configuration/DefaultPenStyle.js~PenStyle", "access": "public", "description": "", "properties": [ { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "defaultValue": "#000000", "defaultRaw": "#000000", "name": "color", "description": "Color (supported formats rgb() rgba() hsl() hsla() #rgb #rgba #rrggbb #rrggbbaa)" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "defaultValue": "1", "defaultRaw": 1, "name": "-myscript-pen-width", "description": "Width of strokes and primitives in mm (no other unit is supported yet)" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "defaultValue": "none", "defaultRaw": "none", "name": "-myscript-pen-fill-style", "description": "" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "defaultValue": "#FFFFFF00", "defaultRaw": "#FFFFFF00", "name": "-myscript-pen-fill-color", "description": "Color filled inside the area delimited by strokes and primitives" } ], "type": { "types": [ "Object" ], "optional": false, "name": "PenStyle" } }, { "__docId__": 181, "kind": "variable", "name": "defaultPenStyle", "memberof": "src/configuration/DefaultPenStyle.js", "static": true, "longname": "src/configuration/DefaultPenStyle.js~defaultPenStyle", "access": "public", "export": true, "importPath": "myscript/src/configuration/DefaultPenStyle.js", "importStyle": "defaultPenStyle", "description": "Default style", "lineNumber": 17, "type": { "nullable": null, "types": [ "PenStyle" ], "spread": false, "description": null } }, { "__docId__": 182, "kind": "file", "name": "src/configuration/DefaultTheme.js", "content": "import JsonCSS from 'json-css';\nimport assign from 'assign-deep';\nimport { editorLogger as logger } from './LoggerConfig';\n\n/**\n * @typedef {PenStyle} InkTheme\n */\n/**\n * @typedef {Object} MathTheme\n * @property {String} font-family=STIXGeneral Font-family to be used\n */\n/**\n * @typedef {Object} GeneratedTheme\n * @property {String} font-family=STIXGeneral Font-family to be used\n * @property {String} color=#A8A8A8FF Color to be used\n */\n/**\n * @typedef {Object} TextTheme\n * @property {String} font-family=OpenSans Font-family to be used\n * @property {Number} font-size=10 Font-size to be used\n */\n/**\n * @typedef {Object} Theme\n * @property {InkTheme} ink General settings\n * @property {MathTheme} .math Math theme\n * @property {GeneratedTheme} .math-solver Theme to be used for generated items\n * @property {TextTheme} .text Text theme\n */\n\n/**\n * Default theme\n * @type {Theme}\n */\nconst defaultTheme = {\n ink: {\n color: '#000000',\n '-myscript-pen-width': 1,\n '-myscript-pen-fill-style': 'none',\n '-myscript-pen-fill-color': '#FFFFFF00'\n },\n '.math': {\n 'font-family': 'STIXGeneral'\n },\n '.math-solved': {\n 'font-family': 'STIXGeneral',\n color: '#A8A8A8FF'\n },\n '.text': {\n 'font-family': 'Open Sans',\n 'font-size': 10\n }\n};\nconst parser = new JsonCSS();\n\n/**\n * Generate theme\n * @param {Theme} theme Custom theme to be applied\n * @return {Theme} Overridden theme\n */\nexport function overrideDefaultTheme(theme) {\n const currentTheme = assign({}, defaultTheme, theme === undefined ? {} : theme);\n logger.debug('Override default theme', currentTheme);\n return currentTheme;\n}\n\nexport function toCSS(theme) {\n return parser.toCSS(theme);\n}\n\nexport function toJSON(theme) {\n return parser.toJSON(theme);\n}\n\nexport default defaultTheme;\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/configuration/DefaultTheme.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 183, "kind": "variable", "name": "parser", "memberof": "src/configuration/DefaultTheme.js", "static": true, "longname": "src/configuration/DefaultTheme.js~parser", "access": "public", "export": false, "importPath": "myscript/src/configuration/DefaultTheme.js", "importStyle": null, "description": null, "lineNumber": 53, "undocument": true, "type": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 184, "kind": "function", "name": "overrideDefaultTheme", "memberof": "src/configuration/DefaultTheme.js", "generator": false, "async": false, "static": true, "longname": "src/configuration/DefaultTheme.js~overrideDefaultTheme", "access": "public", "export": true, "importPath": "myscript/src/configuration/DefaultTheme.js", "importStyle": "{overrideDefaultTheme}", "description": "Generate theme", "lineNumber": 60, "params": [ { "nullable": null, "types": [ "Theme" ], "spread": false, "optional": false, "name": "theme", "description": "Custom theme to be applied" } ], "return": { "nullable": null, "types": [ "Theme" ], "spread": false, "description": "Overridden theme" } }, { "__docId__": 185, "kind": "function", "name": "toCSS", "memberof": "src/configuration/DefaultTheme.js", "generator": false, "async": false, "static": true, "longname": "src/configuration/DefaultTheme.js~toCSS", "access": "public", "export": true, "importPath": "myscript/src/configuration/DefaultTheme.js", "importStyle": "{toCSS}", "description": null, "lineNumber": 66, "undocument": true, "params": [ { "name": "theme", "types": [ "*" ] } ], "return": { "types": [ "*" ] } }, { "__docId__": 186, "kind": "function", "name": "toJSON", "memberof": "src/configuration/DefaultTheme.js", "generator": false, "async": false, "static": true, "longname": "src/configuration/DefaultTheme.js~toJSON", "access": "public", "export": true, "importPath": "myscript/src/configuration/DefaultTheme.js", "importStyle": "{toJSON}", "description": null, "lineNumber": 70, "undocument": true, "params": [ { "name": "theme", "types": [ "*" ] } ], "return": { "types": [ "*" ] } }, { "__docId__": 187, "kind": "typedef", "name": "InkTheme", "memberof": "src/configuration/DefaultTheme.js", "static": true, "longname": "src/configuration/DefaultTheme.js~InkTheme", "access": "public", "description": "", "type": { "types": [ "PenStyle" ], "optional": false, "name": "InkTheme" } }, { "__docId__": 188, "kind": "typedef", "name": "MathTheme", "memberof": "src/configuration/DefaultTheme.js", "static": true, "longname": "src/configuration/DefaultTheme.js~MathTheme", "access": "public", "description": "", "properties": [ { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "defaultValue": "STIXGeneral", "defaultRaw": "STIXGeneral", "name": "font-family", "description": "Font-family to be used" } ], "type": { "types": [ "Object" ], "optional": false, "name": "MathTheme" } }, { "__docId__": 189, "kind": "typedef", "name": "GeneratedTheme", "memberof": "src/configuration/DefaultTheme.js", "static": true, "longname": "src/configuration/DefaultTheme.js~GeneratedTheme", "access": "public", "description": "", "properties": [ { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "defaultValue": "STIXGeneral", "defaultRaw": "STIXGeneral", "name": "font-family", "description": "Font-family to be used" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "defaultValue": "#A8A8A8FF", "defaultRaw": "#A8A8A8FF", "name": "color", "description": "Color to be used" } ], "type": { "types": [ "Object" ], "optional": false, "name": "GeneratedTheme" } }, { "__docId__": 190, "kind": "typedef", "name": "TextTheme", "memberof": "src/configuration/DefaultTheme.js", "static": true, "longname": "src/configuration/DefaultTheme.js~TextTheme", "access": "public", "description": "", "properties": [ { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "defaultValue": "OpenSans", "defaultRaw": "OpenSans", "name": "font-family", "description": "Font-family to be used" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "defaultValue": "10", "defaultRaw": 10, "name": "font-size", "description": "Font-size to be used" } ], "type": { "types": [ "Object" ], "optional": false, "name": "TextTheme" } }, { "__docId__": 191, "kind": "typedef", "name": "Theme", "memberof": "src/configuration/DefaultTheme.js", "static": true, "longname": "src/configuration/DefaultTheme.js~Theme", "access": "public", "description": "", "properties": [ { "nullable": null, "types": [ "InkTheme" ], "spread": false, "optional": false, "name": "ink", "description": "General settings" }, { "nullable": null, "types": [ "MathTheme" ], "spread": false, "optional": false, "name": ".math", "description": "Math theme" }, { "nullable": null, "types": [ "GeneratedTheme" ], "spread": false, "optional": false, "name": ".math-solver", "description": "Theme to be used for generated items" }, { "nullable": null, "types": [ "TextTheme" ], "spread": false, "optional": false, "name": ".text", "description": "Text theme" } ], "type": { "types": [ "Object" ], "optional": false, "name": "Theme" } }, { "__docId__": 192, "kind": "variable", "name": "defaultTheme", "memberof": "src/configuration/DefaultTheme.js", "static": true, "longname": "src/configuration/DefaultTheme.js~defaultTheme", "access": "public", "export": true, "importPath": "myscript/src/configuration/DefaultTheme.js", "importStyle": "defaultTheme", "description": "Default theme", "lineNumber": 34, "type": { "nullable": null, "types": [ "Theme" ], "spread": false, "description": null } }, { "__docId__": 193, "kind": "file", "name": "src/configuration/LoggerConfig.js", "content": "import * as loglevel from 'loglevel';\nimport Constants from './Constants';\n\n/**\n * Main log instance\n * @type {Object}\n */\nconst log = loglevel.noConflict();\nexport default log;\n\n/**\n * Log editor events\n * @type {Object}\n */\nexport const editorLogger = log.getLogger(Constants.Logger.EDITOR);\neditorLogger.setDefaultLevel(Constants.LogLevel.ERROR);\n\n/**\n * Log editor events\n * @type {Object}\n */\nexport const smartGuideLogger = log.getLogger(Constants.Logger.SMARTGUIDE);\neditorLogger.setDefaultLevel(Constants.LogLevel.ERROR);\n\n/**\n * Log model events\n * @type {Object}\n */\nexport const modelLogger = log.getLogger(Constants.Logger.MODEL);\nmodelLogger.setDefaultLevel(Constants.LogLevel.ERROR);\n\n/**\n * Log grabber events\n * @type {Object}\n */\nexport const grabberLogger = log.getLogger(Constants.Logger.GRABBER);\ngrabberLogger.setDefaultLevel(Constants.LogLevel.ERROR);\n\n/**\n * Log grabber events\n * @type {Object}\n */\nexport const rendererLogger = log.getLogger(Constants.Logger.RENDERER);\nrendererLogger.setDefaultLevel(Constants.LogLevel.ERROR);\n\n/**\n * Log recognizer events\n * @type {Object}\n */\nexport const recognizerLogger = log.getLogger(Constants.Logger.RECOGNIZER);\nrecognizerLogger.setDefaultLevel(Constants.LogLevel.ERROR);\n\n/**\n * Log callback events\n * @type {Object}\n */\nexport const callbackLogger = log.getLogger(Constants.Logger.CALLBACK);\ncallbackLogger.setDefaultLevel(Constants.LogLevel.ERROR);\n\n/**\n * Log util events\n * @type {Object}\n */\nexport const utilLogger = log.getLogger(Constants.Logger.UTIL);\nutilLogger.setDefaultLevel(Constants.LogLevel.ERROR);\n\n/**\n * Log tests events\n * @type {Object}\n */\nexport const testLogger = log.getLogger('test');\ntestLogger.setDefaultLevel(Constants.LogLevel.ERROR);\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/configuration/LoggerConfig.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 194, "kind": "variable", "name": "editorLogger", "memberof": "src/configuration/LoggerConfig.js", "static": true, "longname": "src/configuration/LoggerConfig.js~editorLogger", "access": "public", "export": true, "importPath": "myscript/src/configuration/LoggerConfig.js", "importStyle": "{editorLogger}", "description": "Log editor events", "lineNumber": 15, "type": { "nullable": null, "types": [ "Object" ], "spread": false, "description": null } }, { "__docId__": 195, "kind": "variable", "name": "smartGuideLogger", "memberof": "src/configuration/LoggerConfig.js", "static": true, "longname": "src/configuration/LoggerConfig.js~smartGuideLogger", "access": "public", "export": true, "importPath": "myscript/src/configuration/LoggerConfig.js", "importStyle": "{smartGuideLogger}", "description": "Log editor events", "lineNumber": 22, "type": { "nullable": null, "types": [ "Object" ], "spread": false, "description": null } }, { "__docId__": 196, "kind": "variable", "name": "modelLogger", "memberof": "src/configuration/LoggerConfig.js", "static": true, "longname": "src/configuration/LoggerConfig.js~modelLogger", "access": "public", "export": true, "importPath": "myscript/src/configuration/LoggerConfig.js", "importStyle": "{modelLogger}", "description": "Log model events", "lineNumber": 29, "type": { "nullable": null, "types": [ "Object" ], "spread": false, "description": null } }, { "__docId__": 197, "kind": "variable", "name": "grabberLogger", "memberof": "src/configuration/LoggerConfig.js", "static": true, "longname": "src/configuration/LoggerConfig.js~grabberLogger", "access": "public", "export": true, "importPath": "myscript/src/configuration/LoggerConfig.js", "importStyle": "{grabberLogger}", "description": "Log grabber events", "lineNumber": 36, "type": { "nullable": null, "types": [ "Object" ], "spread": false, "description": null } }, { "__docId__": 198, "kind": "variable", "name": "rendererLogger", "memberof": "src/configuration/LoggerConfig.js", "static": true, "longname": "src/configuration/LoggerConfig.js~rendererLogger", "access": "public", "export": true, "importPath": "myscript/src/configuration/LoggerConfig.js", "importStyle": "{rendererLogger}", "description": "Log grabber events", "lineNumber": 43, "type": { "nullable": null, "types": [ "Object" ], "spread": false, "description": null } }, { "__docId__": 199, "kind": "variable", "name": "recognizerLogger", "memberof": "src/configuration/LoggerConfig.js", "static": true, "longname": "src/configuration/LoggerConfig.js~recognizerLogger", "access": "public", "export": true, "importPath": "myscript/src/configuration/LoggerConfig.js", "importStyle": "{recognizerLogger}", "description": "Log recognizer events", "lineNumber": 50, "type": { "nullable": null, "types": [ "Object" ], "spread": false, "description": null } }, { "__docId__": 200, "kind": "variable", "name": "callbackLogger", "memberof": "src/configuration/LoggerConfig.js", "static": true, "longname": "src/configuration/LoggerConfig.js~callbackLogger", "access": "public", "export": true, "importPath": "myscript/src/configuration/LoggerConfig.js", "importStyle": "{callbackLogger}", "description": "Log callback events", "lineNumber": 57, "type": { "nullable": null, "types": [ "Object" ], "spread": false, "description": null } }, { "__docId__": 201, "kind": "variable", "name": "utilLogger", "memberof": "src/configuration/LoggerConfig.js", "static": true, "longname": "src/configuration/LoggerConfig.js~utilLogger", "access": "public", "export": true, "importPath": "myscript/src/configuration/LoggerConfig.js", "importStyle": "{utilLogger}", "description": "Log util events", "lineNumber": 64, "type": { "nullable": null, "types": [ "Object" ], "spread": false, "description": null } }, { "__docId__": 202, "kind": "variable", "name": "testLogger", "memberof": "src/configuration/LoggerConfig.js", "static": true, "longname": "src/configuration/LoggerConfig.js~testLogger", "access": "public", "export": true, "importPath": "myscript/src/configuration/LoggerConfig.js", "importStyle": "{testLogger}", "description": "Log tests events", "lineNumber": 71, "type": { "nullable": null, "types": [ "Object" ], "spread": false, "description": null } }, { "__docId__": 203, "kind": "variable", "name": "log", "memberof": "src/configuration/LoggerConfig.js", "static": true, "longname": "src/configuration/LoggerConfig.js~log", "access": "public", "export": true, "importPath": "myscript/src/configuration/LoggerConfig.js", "importStyle": "log", "description": "Main log instance", "lineNumber": 8, "type": { "nullable": null, "types": [ "Object" ], "spread": false, "description": null } }, { "__docId__": 204, "kind": "file", "name": "src/eastereggs/InkImporter.js", "content": "/* eslint-disable no-undef */\nimport { editorLogger as logger } from '../configuration/LoggerConfig';\nimport * as InkModel from '../model/InkModel';\n\n/**\n * Function to copy past to inject ink during tutorial.\n * @param editorParam\n * @param strokes\n * @param delayBetweenStrokes\n * @param lastOneDelay\n */\nexport function inkImporter(editorParam, strokes, delayBetweenStrokes, lastOneDelay) {\n const editor = editorParam;\n logger.debug('inkImporter start importing =>', strokes);\n const origGrabber = Object.assign({}, editor.behavior.grabber);\n origGrabber.detach = editor.behavior.grabber.detach;\n editor.behavior.grabber = {};\n const actions = [];\n strokes.forEach((stroke) => {\n if (stroke.convert) {\n actions.push({ action: 'convert', value: true });\n } else if (stroke.setDelay) {\n actions.push({ action: 'setDelay', value: stroke.setDelay });\n } else {\n if (stroke.color) {\n actions.push({ action: 'setColor', value: stroke.color });\n }\n stroke.X.forEach((x, idx) => {\n let action = 'move';\n if (idx === 0) {\n action = 'down';\n } else if (idx === (stroke.X.length - 1)) {\n action = 'up';\n }\n actions.push({ action, point: { x: stroke.X[idx], y: stroke.Y[idx] } });\n });\n }\n });\n logger.debug('Array of actions =>', actions);\n const play = (actionsArray, position, delay) => {\n if (position < actionsArray.length) {\n const currentAction = actionsArray[position];\n let nextDelay = delay;\n if (currentAction.action === 'convert') {\n editor.convert();\n } else if (currentAction.action === 'setDelay') {\n nextDelay = currentAction.value;\n } else if (currentAction.action === 'setColor') {\n editor.penStyle = {\n color: currentAction.value,\n };\n } else {\n currentAction.point.t = new Date().getTime();\n if (currentAction.action === 'down') {\n editor.pointerDown(currentAction.point);\n } else if (currentAction.action === 'up') {\n editor.pointerUp(currentAction.point);\n } else if (currentAction.action === 'move') {\n editor.pointerMove(currentAction.point);\n }\n } if (lastOneDelay && position === actionsArray.map(x => x.action).lastIndexOf('down') - 1) {\n setTimeout(() => {\n play(actionsArray, position + 1, nextDelay);\n }, lastOneDelay);\n } else if (position === actionsArray.length - 1) {\n const event = new Event('drawEnded');\n document.dispatchEvent(event);\n editor.behavior.grabber = origGrabber;\n } else {\n setTimeout(() => {\n play(actionsArray, position + 1, nextDelay);\n }, nextDelay);\n }\n }\n };\n play(actions, 0, delayBetweenStrokes);\n}\n\n\nexport function importStrokeGroups(editorParam, strokeGroups) {\n strokeGroups.forEach((group) => {\n group.strokes.forEach((strokeFromGroup) => {\n InkModel.addStroke(editorParam.model, strokeFromGroup);\n InkModel.addStrokeToGroup(editorParam.model, strokeFromGroup, group.penStyle);\n });\n });\n editorParam.renderer.drawModel(editorParam.rendererContext, editorParam.model, editorParam.stroker);\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/eastereggs/InkImporter.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 205, "kind": "function", "name": "inkImporter", "memberof": "src/eastereggs/InkImporter.js", "generator": false, "async": false, "static": true, "longname": "src/eastereggs/InkImporter.js~inkImporter", "access": "public", "export": true, "importPath": "myscript/src/eastereggs/InkImporter.js", "importStyle": "{inkImporter}", "description": "Function to copy past to inject ink during tutorial.", "lineNumber": 12, "params": [ { "nullable": null, "types": [ "*" ], "spread": false, "optional": false, "name": "editorParam", "description": "" }, { "nullable": null, "types": [ "*" ], "spread": false, "optional": false, "name": "strokes", "description": "" }, { "nullable": null, "types": [ "*" ], "spread": false, "optional": false, "name": "delayBetweenStrokes", "description": "" }, { "nullable": null, "types": [ "*" ], "spread": false, "optional": false, "name": "lastOneDelay", "description": "" } ], "return": null }, { "__docId__": 206, "kind": "function", "name": "importStrokeGroups", "memberof": "src/eastereggs/InkImporter.js", "generator": false, "async": false, "static": true, "longname": "src/eastereggs/InkImporter.js~importStrokeGroups", "access": "public", "export": true, "importPath": "myscript/src/eastereggs/InkImporter.js", "importStyle": "{importStrokeGroups}", "description": null, "lineNumber": 80, "undocument": true, "params": [ { "name": "editorParam", "types": [ "*" ] }, { "name": "strokeGroups", "types": [ "*" ] } ], "return": null }, { "__docId__": 207, "kind": "file", "name": "src/grabber/PointerEventGrabber.js", "content": "import { grabberLogger as logger } from '../configuration/LoggerConfig';\n\n/**\n * Grab pointerDown, pointerMove and pointerUp events\n * @typedef {Object} Grabber\n * @property {function(element: Element, editor: Editor): GrabberContext} attach Attach events and decide when to call editor pointerDown/Move/Up methods\n * @property {function(element: Element, context: GrabberContext)} detach Detach the grabber\n */\n\n/**\n * Grabber listener\n * @typedef {Object} GrabberListener\n * @property {Array} types Event types to listen\n * @property {function(event: Event)} listener Event listener for these events\n */\n\n/**\n * Grabber context\n * @typedef {Object} GrabberContext\n * @property {Boolean|Object} options Options object that specifies characteristics about the event listener. (@see addEventListener.options for detail)\n * @property {Array} listeners Registered listeners\n */\n\nconst floatPrecisionArray = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000];\n\nfunction roundFloat(oneFloat, requestedFloatPrecision) {\n if (requestedFloatPrecision || requestedFloatPrecision === 0) {\n let floatPrecision;\n if (requestedFloatPrecision > 10) {\n floatPrecision = floatPrecisionArray[10];\n } else {\n floatPrecision = floatPrecisionArray[requestedFloatPrecision];\n }\n return Math.round(oneFloat * floatPrecision) / floatPrecision;\n }\n return oneFloat;\n}\n\nfunction extractPoint(event, domElement, configuration, offsetTop = 0, offsetLeft = 0) {\n let eventRef = event;\n if (eventRef.changedTouches) {\n eventRef = eventRef.changedTouches[0];\n }\n const rect = domElement.getBoundingClientRect();\n return {\n x: roundFloat(eventRef.clientX - rect.left - domElement.clientLeft - offsetLeft, configuration.xyFloatPrecision),\n y: roundFloat(eventRef.clientY - rect.top - domElement.clientTop - offsetTop, configuration.xyFloatPrecision),\n t: roundFloat(Date.now(), configuration.timestampFloatPrecision)\n };\n}\n\n/**\n * Listen for the desired events\n * @param {Element} element DOM element to attach events listeners\n * @param {Editor} editor Editor to received down/move/up events\n * @param {Number} [offsetTop=0]\n * @param {Number} [offsetLeft=0]\n * @return {GrabberContext} Grabber context\n * @listens {Event} pointermove: a pointer moves, similar to touchmove or mousemove.\n * @listens {Event} pointerdown: a pointer is activated, or a device button held.\n * @listens {Event} pointerup: a pointer is deactivated, or a device button released.\n * @listens {Event} pointerover: a pointer has moved onto an element.\n * @listens {Event} pointerout: a pointer is no longer on an element it once was.\n * @listens {Event} pointerenter: a pointer enters the bounding box of an element.\n * @listens {Event} pointerleave: a pointer leaves the bounding box of an element.\n * @listens {Event} pointercancel: a pointer will no longer generate events.\n */\nexport function attach(element, editor, offsetTop = 0, offsetLeft = 0) {\n let mMaxDiffX = 0;\n\n function unfocus() {\n if (window.getSelection().type !== 'None') {\n window.getSelection().removeAllRanges();\n }\n }\n\n function hideMenu(evt) {\n const moreMenuInDocument = document.querySelector('.more-menu');\n if (!evt.target.classList.contains('ellipsis') && !evt.target.classList.contains('more-menu') && !evt.target.classList.contains('options-label-button') && moreMenuInDocument && moreMenuInDocument.style.display !== 'none') {\n moreMenuInDocument.style.display = 'none';\n return true;\n }\n return false;\n }\n\n function hideCandidates(evt) {\n const candidatesInDocument = document.querySelector('.candidates');\n if (!evt.target.classList.contains('candidates') && !(evt.target.tagName === 'SPAN') && candidatesInDocument && candidatesInDocument.style.display !== 'none') {\n candidatesInDocument.style.display = 'none';\n return true;\n }\n return false;\n }\n\n function pointerDownHandler(evt) { // Trigger a pointerDown\n const pointerDownOnEditor = evt.target.id === editor.domElement.id || evt.target.classList.contains('ms-canvas');\n if (this.activePointerId !== undefined) {\n if (this.activePointerId === evt.pointerId) {\n logger.trace(`${evt.type} event with the same id without any pointer up`, evt.pointerId);\n }\n } else if ((evt.button !== 2) && (evt.buttons !== 2) && pointerDownOnEditor) { // Ignore right click\n if (!hideMenu(evt) && !hideCandidates(evt)) {\n this.activePointerId = evt.pointerId;\n // Hack for iOS 9 Safari : pointerId has to be int so -1 if > max value\n const pointerId = evt.pointerId > 2147483647 ? -1 : evt.pointerId;\n unfocus();\n evt.stopPropagation();\n editor.pointerDown(extractPoint(evt, element, editor.configuration, offsetTop, offsetLeft), evt.pointerType, pointerId);\n }\n } else if (evt.target.classList.contains('ellipsis') || evt.target.classList.contains('tag-icon')) {\n hideMenu(evt);\n hideCandidates(evt);\n } else { // FIXME add more complete verification to pointer down on smartguide\n hideMenu(evt);\n hideCandidates(evt);\n this.smartGuidePointerDown = true;\n this.downSmartGuidePoint = extractPoint(evt, element, editor.configuration);\n }\n }\n\n function pointerMoveHandler(evt) { // Trigger a pointerMove\n // Only considering the active pointer\n if (this.activePointerId !== undefined && this.activePointerId === evt.pointerId) {\n unfocus();\n editor.pointerMove(extractPoint(evt, element, editor.configuration, offsetTop, offsetLeft));\n } else if (this.smartGuidePointerDown) {\n const point = extractPoint(evt, element, editor.configuration, offsetTop, offsetLeft);\n const diffX = Math.abs(this.downSmartGuidePoint.x - point.x);\n const diffY = Math.abs(this.downSmartGuidePoint.y - point.y);\n mMaxDiffX = Math.max(diffX, mMaxDiffX);\n const cond1 = diffX < 5 && diffY > 5 && mMaxDiffX < 15;\n const cond2 = diffX > 5 && diffY > 5 && mMaxDiffX < 15;\n if (cond1 || cond2) {\n this.activePointerId = evt.pointerId;\n // Hack for iOS 9 Safari : pointerId has to be int so -1 if > max value\n const pointerId = evt.pointerId > 2147483647 ? -1 : evt.pointerId;\n unfocus();\n editor.pointerDown(this.downSmartGuidePoint, evt.pointerType, pointerId);\n }\n } else {\n logger.trace(`${evt.type} event from another pointerid (${evt.pointerId})`, this.activePointerId);\n }\n }\n\n function pointerUpHandler(evt) { // Trigger a pointerUp\n mMaxDiffX = 0;\n this.smartGuidePointerDown = false;\n const smartGuideIds = ['smartguide', 'prompter-text-container', 'prompter-text', 'tag-icon', 'ellipsis'];\n const scrollbarClasses = ['ps__rail-x', 'ps__thumb-x'];\n // Check if pointer entered into any smartguide elements or scrollbar\n // Use case : when the pointer is entering the smartguide or scrollbar, a pointerout (or leave) is fired.\n // The related target is then the DOM element that was left.\n // We don't want this to cause editor.pointerUp because the stroke isn't finished.\n const pointerEnteredSmartGuide = evt.relatedTarget && (smartGuideIds.includes(evt.relatedTarget.className) || scrollbarClasses.includes(evt.relatedTarget.className));\n // Check if pointer didn't stay in the smartguide and pointer exited the smartguide or scrollbar\n // Use case : when the pointer is leaving the smartguide or scrollbar, a pointerout (or leave) is fired.\n // The related target is then the DOM element that was left (the smart guide)\n // We are entering again the editor\n // We don't want this to cause editor.pointerUp because the stroke isn't finished.\n const pointerExitedSmartGuide = evt.relatedTarget && evt.target && (smartGuideIds.includes(evt.target.className) || scrollbarClasses.includes(evt.target.className));\n // Check if pointer moved between words in smartguide\n // Same use case as pointerEnteredSmartGuide but for the words in the smartguide (each word is a span).\n const pointerMovedWords = evt.relatedTarget && evt.target && (evt.target.tagName === 'SPAN' || evt.relatedTarget.tagName === 'SPAN');\n if (pointerEnteredSmartGuide || pointerExitedSmartGuide || pointerMovedWords) {\n evt.stopPropagation();\n } else if (this.activePointerId !== undefined && this.activePointerId === evt.pointerId) { // Only considering the active pointer\n this.activePointerId = undefined; // Managing the active pointer\n evt.stopPropagation();\n editor.pointerUp(extractPoint(evt, element, editor.configuration, offsetTop, offsetLeft));\n } else {\n logger.trace(`${evt.type} event from another pointerid (${evt.pointerId})`, this.activePointerId);\n }\n }\n\n const context = {\n options: editor.configuration.listenerOptions,\n listeners: [{\n types: ['pointerdown'],\n listener: pointerDownHandler\n }, {\n types: ['pointermove'],\n listener: pointerMoveHandler\n }, {\n types: ['pointerup', 'pointerout', 'pointerleave', 'pointercancel'],\n listener: pointerUpHandler\n }]\n };\n\n logger.debug('attaching listeners', context);\n context.listeners.forEach((item) => {\n item.types.forEach(type => element.addEventListener(type, item.listener, context.options));\n });\n return context;\n}\n\nexport function detach(element, context) {\n logger.debug('detaching listeners', context);\n context.listeners.forEach((item) => {\n item.types.forEach(type => element.removeEventListener(type, item.listener, context.options));\n });\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/grabber/PointerEventGrabber.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 208, "kind": "typedef", "name": "Grabber", "memberof": "src/grabber/PointerEventGrabber.js", "static": true, "longname": "src/grabber/PointerEventGrabber.js~Grabber", "access": "public", "description": "Grab pointerDown, pointerMove and pointerUp events", "properties": [ { "nullable": null, "types": [ "function(element: Element, editor: Editor): GrabberContext" ], "spread": false, "optional": false, "name": "attach", "description": "Attach events and decide when to call editor pointerDown/Move/Up methods" }, { "nullable": null, "types": [ "function(element: Element, context: GrabberContext)" ], "spread": false, "optional": false, "name": "detach", "description": "Detach the grabber" } ], "type": { "types": [ "Object" ], "optional": false, "name": "Grabber" } }, { "__docId__": 209, "kind": "typedef", "name": "GrabberListener", "memberof": "src/grabber/PointerEventGrabber.js", "static": true, "longname": "src/grabber/PointerEventGrabber.js~GrabberListener", "access": "public", "description": "Grabber listener", "properties": [ { "nullable": null, "types": [ "Array" ], "spread": false, "optional": false, "name": "types", "description": "Event types to listen" }, { "nullable": null, "types": [ "function(event: Event)" ], "spread": false, "optional": false, "name": "listener", "description": "Event listener for these events" } ], "type": { "types": [ "Object" ], "optional": false, "name": "GrabberListener" } }, { "__docId__": 210, "kind": "typedef", "name": "GrabberContext", "memberof": "src/grabber/PointerEventGrabber.js", "static": true, "longname": "src/grabber/PointerEventGrabber.js~GrabberContext", "access": "public", "description": "Grabber context", "lineNumber": 24, "properties": [ { "nullable": null, "types": [ "Boolean", "Object" ], "spread": false, "optional": false, "name": "options", "description": "Options object that specifies characteristics about the event listener. (@see addEventListener.options for detail)" }, { "nullable": null, "types": [ "Array" ], "spread": false, "optional": false, "name": "listeners", "description": "Registered listeners" } ], "type": { "types": [ "Object" ], "optional": false, "name": "GrabberContext" } }, { "__docId__": 211, "kind": "function", "name": "roundFloat", "memberof": "src/grabber/PointerEventGrabber.js", "generator": false, "async": false, "static": true, "longname": "src/grabber/PointerEventGrabber.js~roundFloat", "access": "public", "export": false, "importPath": "myscript/src/grabber/PointerEventGrabber.js", "importStyle": null, "description": null, "lineNumber": 26, "undocument": true, "params": [ { "name": "oneFloat", "types": [ "*" ] }, { "name": "requestedFloatPrecision", "types": [ "*" ] } ], "return": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 212, "kind": "function", "name": "extractPoint", "memberof": "src/grabber/PointerEventGrabber.js", "generator": false, "async": false, "static": true, "longname": "src/grabber/PointerEventGrabber.js~extractPoint", "access": "public", "export": false, "importPath": "myscript/src/grabber/PointerEventGrabber.js", "importStyle": null, "description": null, "lineNumber": 39, "undocument": true, "params": [ { "name": "event", "types": [ "*" ] }, { "name": "domElement", "types": [ "*" ] }, { "name": "configuration", "types": [ "*" ] }, { "name": "offsetTop", "optional": true, "types": [ "number" ], "defaultRaw": 0, "defaultValue": "0" }, { "name": "offsetLeft", "optional": true, "types": [ "number" ], "defaultRaw": 0, "defaultValue": "0" } ], "return": { "types": [ "{\"x\": *, \"y\": *, \"t\": *}" ] }, "ignore": true }, { "__docId__": 213, "kind": "function", "name": "attach", "memberof": "src/grabber/PointerEventGrabber.js", "generator": false, "async": false, "static": true, "longname": "src/grabber/PointerEventGrabber.js~attach", "access": "public", "export": true, "importPath": "myscript/src/grabber/PointerEventGrabber.js", "importStyle": "{attach}", "description": "Listen for the desired events", "lineNumber": 68, "params": [ { "nullable": null, "types": [ "Element" ], "spread": false, "optional": false, "name": "element", "description": "DOM element to attach events listeners" }, { "nullable": null, "types": [ "Editor" ], "spread": false, "optional": false, "name": "editor", "description": "Editor to received down/move/up events" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": true, "defaultValue": "0", "defaultRaw": 0, "name": "offsetTop", "description": "" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": true, "defaultValue": "0", "defaultRaw": 0, "name": "offsetLeft", "description": "" } ], "return": { "nullable": null, "types": [ "GrabberContext" ], "spread": false, "description": "Grabber context" }, "listens": [ { "types": [ "Event" ], "description": "pointermove: a pointer moves, similar to touchmove or mousemove." }, { "types": [ "Event" ], "description": "pointerdown: a pointer is activated, or a device button held." }, { "types": [ "Event" ], "description": "pointerup: a pointer is deactivated, or a device button released." }, { "types": [ "Event" ], "description": "pointerover: a pointer has moved onto an element." }, { "types": [ "Event" ], "description": "pointerout: a pointer is no longer on an element it once was." }, { "types": [ "Event" ], "description": "pointerenter: a pointer enters the bounding box of an element." }, { "types": [ "Event" ], "description": "pointerleave: a pointer leaves the bounding box of an element." }, { "types": [ "Event" ], "description": "pointercancel: a pointer will no longer generate events." } ] }, { "__docId__": 214, "kind": "function", "name": "detach", "memberof": "src/grabber/PointerEventGrabber.js", "generator": false, "async": false, "static": true, "longname": "src/grabber/PointerEventGrabber.js~detach", "access": "public", "export": true, "importPath": "myscript/src/grabber/PointerEventGrabber.js", "importStyle": "{detach}", "description": null, "lineNumber": 196, "undocument": true, "params": [ { "name": "element", "types": [ "*" ] }, { "name": "context", "types": [ "*" ] } ], "return": null }, { "__docId__": 215, "kind": "file", "name": "src/model/InkModel.js", "content": "import { modelLogger as logger } from '../configuration/LoggerConfig';\nimport * as StrokeComponent from './StrokeComponent';\nimport { getSymbolsBounds, getDefaultSymbols } from './Symbol';\n\n/**\n * Recognition positions\n * @typedef {Object} RecognitionPositions\n * @property {Number} [lastSentPosition=-1] Index of the last sent stroke.\n * @property {Number} [lastReceivedPosition=-1] Index of the last received stroke.\n * @property {Number} [lastRenderedPosition=-1] Last rendered recognized symbol position\n */\n\n/**\n * Raw results\n * @typedef {Object} RawResults\n * @property {Object} convert=undefined The convert result\n * @property {Object} exports=undefined The exports output as return by the recognition service.\n */\n\n/**\n * Editor model\n * @typedef {Object} Model\n * @property {Stroke} currentStroke=undefined Stroke in building process.\n * @property {Array} rawStrokes=[] List of captured strokes.\n * @property {Array} strokeGroups=[] Group of strokes with same pen style.\n * @property {RecognitionPositions} lastPositions Last recognition sent/received stroke indexes.\n * @property {Array} defaultSymbols=[] Default symbols, relative to the current recognition type.\n * @property {Array} recognizedSymbols=undefined Symbols to render (e.g. stroke, shape primitives, string, characters...).\n * @property {Object} exports=undefined Result of the export (e.g. mathml, latex, text...).\n * @property {RawResults} rawResults The recognition output as return by the recognition service.\n * @property {Number} creationTime Date of creation timestamp.\n * @property {Number} modificationTime=undefined Date of lastModification.\n */\n\n/**\n * Bounding box\n * @typedef {Object} Bounds\n * @property {Number} minX Minimal x coordinate\n * @property {Number} maxX Maximal x coordinate\n * @property {Number} minY Minimal y coordinate\n * @property {Number} maxY Maximal y coordinate\n */\n\n/**\n * Create a new model\n * @param {Configuration} [configuration] Parameters to use to populate default recognition symbols\n * @return {Model} New model\n */\nexport function createModel(configuration) {\n // see @typedef documentation on top\n return {\n currentStroke: undefined,\n rawStrokes: [],\n strokeGroups: [],\n lastPositions: {\n lastSentPosition: -1,\n lastReceivedPosition: -1,\n lastRenderedPosition: -1\n },\n defaultSymbols: configuration ? getDefaultSymbols(configuration) : [],\n recognizedSymbols: undefined,\n exports: undefined,\n rawResults: {\n convert: undefined,\n exports: undefined\n },\n creationTime: new Date().getTime(),\n modificationTime: undefined\n };\n}\n\n/**\n * Clear the model.\n * @param {Model} model Current model\n * @return {Model} Cleared model\n */\nexport function clearModel(model) {\n const modelReference = model;\n modelReference.currentStroke = undefined;\n modelReference.rawStrokes = [];\n modelReference.strokeGroups = [];\n modelReference.lastPositions.lastSentPosition = -1;\n modelReference.lastPositions.lastReceivedPosition = -1;\n modelReference.lastPositions.lastRenderedPosition = -1;\n modelReference.recognizedSymbols = undefined;\n modelReference.exports = undefined;\n modelReference.rawResults.convert = undefined;\n modelReference.rawResults.exports = undefined;\n return modelReference;\n}\n\n/**\n * Check if the model needs to be redrawn.\n * @param {Model} model Current model\n * @return {Boolean} True if the model needs to be redrawn, false otherwise\n */\nexport function needRedraw(model) {\n return model.recognizedSymbols ? (model.rawStrokes.length !== model.recognizedSymbols.filter(symbol => symbol.type === 'stroke').length) : false;\n}\n\n/**\n * Mutate the model given in parameter by adding the new strokeToAdd.\n * @param {Model} model Current model\n * @param {Stroke} stroke Stroke to be added to pending ones\n * @return {Model} Updated model\n */\nexport function addStroke(model, stroke) {\n // We use a reference to the model. The purpose here is to update the pending stroke only.\n const modelReference = model;\n logger.debug('addStroke', stroke);\n modelReference.rawStrokes.push(stroke);\n return modelReference;\n}\n\n/**\n * Mutate the model given in parameter by adding the new strokeToAdd and the penstyle. Used for iink REST.\n * @param {Model} model Current model\n * @param {Stroke} stroke Stroke to be added to pending ones\n * @param {PenStyle} strokePenStyle\n * @return {Model} Updated model\n */\nexport function addStrokeToGroup(model, stroke, strokePenStyle) {\n // We use a reference to the model. The purpose here is to update the pending stroke only.\n const modelReference = model;\n logger.debug('addStroke', stroke);\n const lastGroup = modelReference.strokeGroups.length - 1;\n if (modelReference.strokeGroups[lastGroup] && modelReference.strokeGroups[lastGroup].penStyle === strokePenStyle) {\n modelReference.strokeGroups[lastGroup].strokes.push(stroke);\n } else {\n const newStrokeGroup = {\n penStyle: strokePenStyle,\n strokes: []\n };\n const strokeCopy = {};\n Object.assign(strokeCopy, stroke);\n newStrokeGroup.strokes.push(strokeCopy);\n modelReference.strokeGroups.push(newStrokeGroup);\n }\n return modelReference;\n}\n\n/**\n * Get the strokes that needs to be recognized\n * @param {Model} model Current model\n * @param {Number} [position=lastReceived] Index from where to extract strokes\n * @return {Array} Pending strokes\n */\nexport function extractPendingStrokes(model, position = model.lastPositions.lastReceivedPosition + 1) {\n return model.rawStrokes.slice(position);\n}\n\n/**\n * Mutate the model by adding a point and close the current stroke.\n * @param {Model} model Current model\n * @param {{x: Number, y: Number, t: Number}} point Captured point to create current stroke\n * @param {Object} properties Properties to be applied to the current stroke\n * @param {Number} [dpi=96] The screen dpi resolution\n * @return {Model} Updated model\n */\nexport function initPendingStroke(model, point, properties, dpi = 96) {\n if (properties && properties['-myscript-pen-width']) {\n const pxWidth = (properties['-myscript-pen-width'] * dpi) / 25.4;\n Object.assign(properties, { width: pxWidth / 2 }); // FIXME hack to get better render\n }\n const modelReference = model;\n logger.trace('initPendingStroke', point);\n // Setting the current stroke to an empty one\n modelReference.currentStroke = StrokeComponent.createStrokeComponent(properties);\n modelReference.currentStroke = StrokeComponent.addPoint(modelReference.currentStroke, point);\n return modelReference;\n}\n\n/**\n * Mutate the model by adding a point to the current pending stroke.\n * @param {Model} model Current model\n * @param {{x: Number, y: Number, t: Number}} point Captured point to be append to the current stroke\n * @return {Model} Updated model\n */\nexport function appendToPendingStroke(model, point) {\n const modelReference = model;\n if (modelReference.currentStroke) {\n logger.trace('appendToPendingStroke', point);\n modelReference.currentStroke = StrokeComponent.addPoint(modelReference.currentStroke, point);\n }\n return modelReference;\n}\n\n/**\n * Mutate the model by adding the new point on a initPendingStroke.\n * @param {Model} model Current model\n * @param {{x: Number, y: Number, t: Number}} point Captured point to be append to the current stroke\n * @param {PenStyle} penStyle\n * @return {Model} Updated model\n */\nexport function endPendingStroke(model, point, penStyle) {\n const modelReference = model;\n if (modelReference.currentStroke) {\n logger.trace('endPendingStroke', point);\n const currentStroke = StrokeComponent.addPoint(modelReference.currentStroke, point);\n // Mutating pending strokes\n addStroke(modelReference, currentStroke);\n addStrokeToGroup(modelReference, currentStroke, penStyle);\n // Resetting the current stroke to an undefined one\n delete modelReference.currentStroke;\n }\n return modelReference;\n}\n\n/**\n * Get the bounds of the current model.\n * @param {Model} model Current model\n * @return {Bounds} Bounding box enclosing the current drawn model\n */\nexport function getBorderCoordinates(model) {\n let modelBounds = { minX: Number.MAX_VALUE, maxX: Number.MIN_VALUE, minY: Number.MAX_VALUE, maxY: Number.MIN_VALUE };\n\n // Default symbols\n if (model.defaultSymbols && model.defaultSymbols.length > 0) {\n modelBounds = getSymbolsBounds(model.defaultSymbols, modelBounds);\n }\n // Recognized symbols\n if (model.recognizedSymbols && model.recognizedSymbols.length > 0) {\n modelBounds = getSymbolsBounds(model.recognizedSymbols, modelBounds);\n // Pending strokes\n modelBounds = getSymbolsBounds(extractPendingStrokes(model), modelBounds);\n } else {\n modelBounds = getSymbolsBounds(model.rawStrokes, modelBounds);\n }\n return modelBounds;\n}\n\n/**\n * Extract strokes from an ink range\n * @param {Model} model Current model\n * @param {Number} firstStroke First stroke index to extract\n * @param {Number} lastStroke Last stroke index to extract\n * @param {Number} firstPoint First point index to extract\n * @param {Number} lastPoint Last point index to extract\n * @return {Array} The extracted strokes\n */\nexport function extractStrokesFromInkRange(model, firstStroke, lastStroke, firstPoint, lastPoint) {\n return model.rawStrokes.slice(firstStroke, lastStroke + 1).map((stroke, index, slicedStrokes) => {\n if (slicedStrokes.length < 2) {\n return StrokeComponent.slice(stroke, firstPoint, lastPoint + 1);\n }\n if (index === 0) {\n return StrokeComponent.slice(stroke, firstPoint);\n }\n if (index === (slicedStrokes.length - 1)) {\n return StrokeComponent.slice(stroke, 0, lastPoint + 1);\n }\n return stroke;\n });\n}\n\n/**\n * Update model lastSentPosition\n * @param {Model} model\n * @param {Number} [position]\n * @return {Model}\n */\nexport function updateModelSentPosition(model, position = model.rawStrokes.length - 1) {\n const modelReference = model;\n modelReference.lastPositions.lastSentPosition = position;\n return modelReference;\n}\n\n/**\n * Update model lastReceivedPosition regarding to lastSentPosition\n * @param {Model} model\n * @return {Model}\n */\nexport function updateModelReceivedPosition(model) {\n const modelReference = model;\n modelReference.lastPositions.lastReceivedPosition = modelReference.lastPositions.lastSentPosition;\n return modelReference;\n}\n\n/**\n * Reset model lastReceivedPosition and lastSentPosition\n * @param {Model} model\n * @return {Model}\n */\nexport function resetModelPositions(model) {\n const modelReference = model;\n modelReference.lastPositions.lastSentPosition = -1;\n modelReference.lastPositions.lastReceivedPosition = -1;\n return modelReference;\n}\n\n/**\n * Reset model lastRenderedPosition\n * @param {Model} model\n * @return {Model}\n */\nexport function resetModelRendererPosition(model) {\n const modelReference = model;\n modelReference.lastPositions.lastRenderedPosition = -1;\n return modelReference;\n}\n\n/**\n * Update model lastRenderedPosition\n * @param {Model} model\n * @param {Number} [position]\n * @return {Model}\n */\nexport function updateModelRenderedPosition(model, position = model.recognizedSymbols ? model.recognizedSymbols.length - 1 : -1) {\n const modelReference = model;\n modelReference.lastPositions.lastRenderedPosition = position;\n return modelReference;\n}\n\n/**\n * Get the symbols that needs to be rendered\n * @param {Model} model Current model\n * @param {Number} [position=lastRendered] Index from where to extract symbols\n * @return {Array}\n */\nexport function extractPendingRecognizedSymbols(model, position = model.lastPositions.lastRenderedPosition + 1) {\n return model.recognizedSymbols ? model.recognizedSymbols.slice(position) : [];\n}\n\n/**\n * Clone model\n * @param {Model} model Current model\n * @return {Model} Clone of the current model\n */\nexport function cloneModel(model) {\n const clonedModel = Object.assign({}, model);\n // We clone the properties that need to be. Take care of arrays.\n clonedModel.defaultSymbols = [...model.defaultSymbols];\n clonedModel.currentStroke = model.currentStroke ? Object.assign({}, model.currentStroke) : undefined;\n clonedModel.rawStrokes = [...model.rawStrokes];\n clonedModel.strokeGroups = JSON.parse(JSON.stringify(model.strokeGroups));\n clonedModel.lastPositions = Object.assign({}, model.lastPositions);\n clonedModel.exports = model.exports ? Object.assign({}, model.exports) : undefined;\n clonedModel.rawResults = Object.assign({}, model.rawResults);\n clonedModel.recognizedSymbols = model.recognizedSymbols ? [...model.recognizedSymbols] : undefined;\n return clonedModel;\n}\n\n/**\n * Merge models\n * @param {...Model} models Models to merge (ordered)\n * @return {Model} Updated model\n */\nexport function mergeModels(...models) {\n return models.reduce((a, b) => {\n const modelRef = a;\n modelRef.recognizedSymbols = b.recognizedSymbols;\n modelRef.lastPositions.lastSentPosition = b.lastPositions.lastSentPosition;\n modelRef.lastPositions.lastReceivedPosition = b.lastPositions.lastReceivedPosition;\n modelRef.lastPositions.lastRenderedPosition = b.lastPositions.lastRenderedPosition;\n modelRef.rawResults = b.rawResults;\n modelRef.exports = b.exports;\n return modelRef;\n });\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/model/InkModel.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 216, "kind": "typedef", "name": "RecognitionPositions", "memberof": "src/model/InkModel.js", "static": true, "longname": "src/model/InkModel.js~RecognitionPositions", "access": "public", "description": "Recognition positions", "properties": [ { "nullable": null, "types": [ "Number" ], "spread": false, "optional": true, "defaultValue": "-1", "defaultRaw": -1, "name": "lastSentPosition", "description": "Index of the last sent stroke." }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": true, "defaultValue": "-1", "defaultRaw": -1, "name": "lastReceivedPosition", "description": "Index of the last received stroke." }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": true, "defaultValue": "-1", "defaultRaw": -1, "name": "lastRenderedPosition", "description": "Last rendered recognized symbol position" } ], "type": { "types": [ "Object" ], "optional": false, "name": "RecognitionPositions" } }, { "__docId__": 217, "kind": "typedef", "name": "RawResults", "memberof": "src/model/InkModel.js", "static": true, "longname": "src/model/InkModel.js~RawResults", "access": "public", "description": "Raw results", "properties": [ { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "defaultValue": "undefined", "defaultRaw": "undefined", "name": "convert", "description": "The convert result" }, { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "defaultValue": "undefined", "defaultRaw": "undefined", "name": "exports", "description": "The exports output as return by the recognition service." } ], "type": { "types": [ "Object" ], "optional": false, "name": "RawResults" } }, { "__docId__": 218, "kind": "typedef", "name": "Model", "memberof": "src/model/InkModel.js", "static": true, "longname": "src/model/InkModel.js~Model", "access": "public", "description": "Editor model", "properties": [ { "nullable": null, "types": [ "Stroke" ], "spread": false, "optional": false, "defaultValue": "undefined", "defaultRaw": "undefined", "name": "currentStroke", "description": "Stroke in building process." }, { "nullable": null, "types": [ "Array" ], "spread": false, "optional": false, "defaultValue": "[]", "defaultRaw": [], "name": "rawStrokes", "description": "List of captured strokes." }, { "nullable": null, "types": [ "Array" ], "spread": false, "optional": false, "defaultValue": "[]", "defaultRaw": [], "name": "strokeGroups", "description": "Group of strokes with same pen style." }, { "nullable": null, "types": [ "RecognitionPositions" ], "spread": false, "optional": false, "name": "lastPositions", "description": "Last recognition sent/received stroke indexes." }, { "nullable": null, "types": [ "Array" ], "spread": false, "optional": false, "defaultValue": "[]", "defaultRaw": [], "name": "defaultSymbols", "description": "Default symbols, relative to the current recognition type." }, { "nullable": null, "types": [ "Array" ], "spread": false, "optional": false, "defaultValue": "undefined", "defaultRaw": "undefined", "name": "recognizedSymbols", "description": "Symbols to render (e.g. stroke, shape primitives, string, characters...)." }, { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "defaultValue": "undefined", "defaultRaw": "undefined", "name": "exports", "description": "Result of the export (e.g. mathml, latex, text...)." }, { "nullable": null, "types": [ "RawResults" ], "spread": false, "optional": false, "name": "rawResults", "description": "The recognition output as return by the recognition service." }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "name": "creationTime", "description": "Date of creation timestamp." }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "defaultValue": "undefined", "defaultRaw": "undefined", "name": "modificationTime", "description": "Date of lastModification." } ], "type": { "types": [ "Object" ], "optional": false, "name": "Model" } }, { "__docId__": 219, "kind": "typedef", "name": "Bounds", "memberof": "src/model/InkModel.js", "static": true, "longname": "src/model/InkModel.js~Bounds", "access": "public", "description": "Bounding box", "properties": [ { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "name": "minX", "description": "Minimal x coordinate" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "name": "maxX", "description": "Maximal x coordinate" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "name": "minY", "description": "Minimal y coordinate" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "name": "maxY", "description": "Maximal y coordinate" } ], "type": { "types": [ "Object" ], "optional": false, "name": "Bounds" } }, { "__docId__": 220, "kind": "function", "name": "createModel", "memberof": "src/model/InkModel.js", "generator": false, "async": false, "static": true, "longname": "src/model/InkModel.js~createModel", "access": "public", "export": true, "importPath": "myscript/src/model/InkModel.js", "importStyle": "{createModel}", "description": "Create a new model", "lineNumber": 49, "params": [ { "nullable": null, "types": [ "Configuration" ], "spread": false, "optional": true, "name": "configuration", "description": "Parameters to use to populate default recognition symbols" } ], "return": { "nullable": null, "types": [ "Model" ], "spread": false, "description": "New model" } }, { "__docId__": 221, "kind": "function", "name": "clearModel", "memberof": "src/model/InkModel.js", "generator": false, "async": false, "static": true, "longname": "src/model/InkModel.js~clearModel", "access": "public", "export": true, "importPath": "myscript/src/model/InkModel.js", "importStyle": "{clearModel}", "description": "Clear the model.", "lineNumber": 77, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" } ], "return": { "nullable": null, "types": [ "Model" ], "spread": false, "description": "Cleared model" } }, { "__docId__": 222, "kind": "function", "name": "needRedraw", "memberof": "src/model/InkModel.js", "generator": false, "async": false, "static": true, "longname": "src/model/InkModel.js~needRedraw", "access": "public", "export": true, "importPath": "myscript/src/model/InkModel.js", "importStyle": "{needRedraw}", "description": "Check if the model needs to be redrawn.", "lineNumber": 97, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" } ], "return": { "nullable": null, "types": [ "Boolean" ], "spread": false, "description": "True if the model needs to be redrawn, false otherwise" } }, { "__docId__": 223, "kind": "function", "name": "addStroke", "memberof": "src/model/InkModel.js", "generator": false, "async": false, "static": true, "longname": "src/model/InkModel.js~addStroke", "access": "public", "export": true, "importPath": "myscript/src/model/InkModel.js", "importStyle": "{addStroke}", "description": "Mutate the model given in parameter by adding the new strokeToAdd.", "lineNumber": 107, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "Stroke" ], "spread": false, "optional": false, "name": "stroke", "description": "Stroke to be added to pending ones" } ], "return": { "nullable": null, "types": [ "Model" ], "spread": false, "description": "Updated model" } }, { "__docId__": 224, "kind": "function", "name": "addStrokeToGroup", "memberof": "src/model/InkModel.js", "generator": false, "async": false, "static": true, "longname": "src/model/InkModel.js~addStrokeToGroup", "access": "public", "export": true, "importPath": "myscript/src/model/InkModel.js", "importStyle": "{addStrokeToGroup}", "description": "Mutate the model given in parameter by adding the new strokeToAdd and the penstyle. Used for iink REST.", "lineNumber": 122, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "Stroke" ], "spread": false, "optional": false, "name": "stroke", "description": "Stroke to be added to pending ones" }, { "nullable": null, "types": [ "PenStyle" ], "spread": false, "optional": false, "name": "strokePenStyle", "description": "" } ], "return": { "nullable": null, "types": [ "Model" ], "spread": false, "description": "Updated model" } }, { "__docId__": 225, "kind": "function", "name": "extractPendingStrokes", "memberof": "src/model/InkModel.js", "generator": false, "async": false, "static": true, "longname": "src/model/InkModel.js~extractPendingStrokes", "access": "public", "export": true, "importPath": "myscript/src/model/InkModel.js", "importStyle": "{extractPendingStrokes}", "description": "Get the strokes that needs to be recognized", "lineNumber": 148, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": true, "defaultValue": "lastReceived", "defaultRaw": "lastReceived", "name": "position", "description": "Index from where to extract strokes" } ], "return": { "nullable": null, "types": [ "Array" ], "spread": false, "description": "Pending strokes" } }, { "__docId__": 226, "kind": "function", "name": "initPendingStroke", "memberof": "src/model/InkModel.js", "generator": false, "async": false, "static": true, "longname": "src/model/InkModel.js~initPendingStroke", "access": "public", "export": true, "importPath": "myscript/src/model/InkModel.js", "importStyle": "{initPendingStroke}", "description": "Mutate the model by adding a point and close the current stroke.", "lineNumber": 160, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "{x: Number, y: Number, t: Number}" ], "spread": false, "optional": false, "name": "point", "description": "Captured point to create current stroke" }, { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "properties", "description": "Properties to be applied to the current stroke" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": true, "defaultValue": "96", "defaultRaw": 96, "name": "dpi", "description": "The screen dpi resolution" } ], "return": { "nullable": null, "types": [ "Model" ], "spread": false, "description": "Updated model" } }, { "__docId__": 227, "kind": "function", "name": "appendToPendingStroke", "memberof": "src/model/InkModel.js", "generator": false, "async": false, "static": true, "longname": "src/model/InkModel.js~appendToPendingStroke", "access": "public", "export": true, "importPath": "myscript/src/model/InkModel.js", "importStyle": "{appendToPendingStroke}", "description": "Mutate the model by adding a point to the current pending stroke.", "lineNumber": 179, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "{x: Number, y: Number, t: Number}" ], "spread": false, "optional": false, "name": "point", "description": "Captured point to be append to the current stroke" } ], "return": { "nullable": null, "types": [ "Model" ], "spread": false, "description": "Updated model" } }, { "__docId__": 228, "kind": "function", "name": "endPendingStroke", "memberof": "src/model/InkModel.js", "generator": false, "async": false, "static": true, "longname": "src/model/InkModel.js~endPendingStroke", "access": "public", "export": true, "importPath": "myscript/src/model/InkModel.js", "importStyle": "{endPendingStroke}", "description": "Mutate the model by adding the new point on a initPendingStroke.", "lineNumber": 195, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "{x: Number, y: Number, t: Number}" ], "spread": false, "optional": false, "name": "point", "description": "Captured point to be append to the current stroke" }, { "nullable": null, "types": [ "PenStyle" ], "spread": false, "optional": false, "name": "penStyle", "description": "" } ], "return": { "nullable": null, "types": [ "Model" ], "spread": false, "description": "Updated model" } }, { "__docId__": 229, "kind": "function", "name": "getBorderCoordinates", "memberof": "src/model/InkModel.js", "generator": false, "async": false, "static": true, "longname": "src/model/InkModel.js~getBorderCoordinates", "access": "public", "export": true, "importPath": "myscript/src/model/InkModel.js", "importStyle": "{getBorderCoordinates}", "description": "Get the bounds of the current model.", "lineNumber": 214, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" } ], "return": { "nullable": null, "types": [ "Bounds" ], "spread": false, "description": "Bounding box enclosing the current drawn model" } }, { "__docId__": 230, "kind": "function", "name": "extractStrokesFromInkRange", "memberof": "src/model/InkModel.js", "generator": false, "async": false, "static": true, "longname": "src/model/InkModel.js~extractStrokesFromInkRange", "access": "public", "export": true, "importPath": "myscript/src/model/InkModel.js", "importStyle": "{extractStrokesFromInkRange}", "description": "Extract strokes from an ink range", "lineNumber": 241, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "name": "firstStroke", "description": "First stroke index to extract" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "name": "lastStroke", "description": "Last stroke index to extract" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "name": "firstPoint", "description": "First point index to extract" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "name": "lastPoint", "description": "Last point index to extract" } ], "return": { "nullable": null, "types": [ "Array" ], "spread": false, "description": "The extracted strokes" } }, { "__docId__": 231, "kind": "function", "name": "updateModelSentPosition", "memberof": "src/model/InkModel.js", "generator": false, "async": false, "static": true, "longname": "src/model/InkModel.js~updateModelSentPosition", "access": "public", "export": true, "importPath": "myscript/src/model/InkModel.js", "importStyle": "{updateModelSentPosition}", "description": "Update model lastSentPosition", "lineNumber": 262, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": true, "name": "position", "description": "" } ], "return": { "nullable": null, "types": [ "Model" ], "spread": false, "description": "" } }, { "__docId__": 232, "kind": "function", "name": "updateModelReceivedPosition", "memberof": "src/model/InkModel.js", "generator": false, "async": false, "static": true, "longname": "src/model/InkModel.js~updateModelReceivedPosition", "access": "public", "export": true, "importPath": "myscript/src/model/InkModel.js", "importStyle": "{updateModelReceivedPosition}", "description": "Update model lastReceivedPosition regarding to lastSentPosition", "lineNumber": 273, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" } ], "return": { "nullable": null, "types": [ "Model" ], "spread": false, "description": "" } }, { "__docId__": 233, "kind": "function", "name": "resetModelPositions", "memberof": "src/model/InkModel.js", "generator": false, "async": false, "static": true, "longname": "src/model/InkModel.js~resetModelPositions", "access": "public", "export": true, "importPath": "myscript/src/model/InkModel.js", "importStyle": "{resetModelPositions}", "description": "Reset model lastReceivedPosition and lastSentPosition", "lineNumber": 284, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" } ], "return": { "nullable": null, "types": [ "Model" ], "spread": false, "description": "" } }, { "__docId__": 234, "kind": "function", "name": "resetModelRendererPosition", "memberof": "src/model/InkModel.js", "generator": false, "async": false, "static": true, "longname": "src/model/InkModel.js~resetModelRendererPosition", "access": "public", "export": true, "importPath": "myscript/src/model/InkModel.js", "importStyle": "{resetModelRendererPosition}", "description": "Reset model lastRenderedPosition", "lineNumber": 296, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" } ], "return": { "nullable": null, "types": [ "Model" ], "spread": false, "description": "" } }, { "__docId__": 235, "kind": "function", "name": "updateModelRenderedPosition", "memberof": "src/model/InkModel.js", "generator": false, "async": false, "static": true, "longname": "src/model/InkModel.js~updateModelRenderedPosition", "access": "public", "export": true, "importPath": "myscript/src/model/InkModel.js", "importStyle": "{updateModelRenderedPosition}", "description": "Update model lastRenderedPosition", "lineNumber": 308, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": true, "name": "position", "description": "" } ], "return": { "nullable": null, "types": [ "Model" ], "spread": false, "description": "" } }, { "__docId__": 236, "kind": "function", "name": "extractPendingRecognizedSymbols", "memberof": "src/model/InkModel.js", "generator": false, "async": false, "static": true, "longname": "src/model/InkModel.js~extractPendingRecognizedSymbols", "access": "public", "export": true, "importPath": "myscript/src/model/InkModel.js", "importStyle": "{extractPendingRecognizedSymbols}", "description": "Get the symbols that needs to be rendered", "lineNumber": 320, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": true, "defaultValue": "lastRendered", "defaultRaw": "lastRendered", "name": "position", "description": "Index from where to extract symbols" } ], "return": { "nullable": null, "types": [ "Array" ], "spread": false, "description": "" } }, { "__docId__": 237, "kind": "function", "name": "cloneModel", "memberof": "src/model/InkModel.js", "generator": false, "async": false, "static": true, "longname": "src/model/InkModel.js~cloneModel", "access": "public", "export": true, "importPath": "myscript/src/model/InkModel.js", "importStyle": "{cloneModel}", "description": "Clone model", "lineNumber": 329, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" } ], "return": { "nullable": null, "types": [ "Model" ], "spread": false, "description": "Clone of the current model" } }, { "__docId__": 238, "kind": "function", "name": "mergeModels", "memberof": "src/model/InkModel.js", "generator": false, "async": false, "static": true, "longname": "src/model/InkModel.js~mergeModels", "access": "public", "export": true, "importPath": "myscript/src/model/InkModel.js", "importStyle": "{mergeModels}", "description": "Merge models", "lineNumber": 348, "params": [ { "nullable": null, "types": [ "...Model" ], "spread": true, "optional": false, "name": "models", "description": "Models to merge (ordered)" } ], "return": { "nullable": null, "types": [ "Model" ], "spread": false, "description": "Updated model" } }, { "__docId__": 239, "kind": "file", "name": "src/model/RecognizerContext.js", "content": "import { recognizerLogger as logger } from '../configuration/LoggerConfig';\n\n/**\n * Recognition context\n * @typedef {Object} RecognitionContext\n * @property {Model} model\n * @property {Callback} callback\n */\n\n/**\n * Recognizer context\n * @typedef {Object} RecognizerContext\n * @property {Editor} editor Get a reference to the current editor\n * @property {Array} recognitionContexts=[]\n * @property {Promise} initPromise=undefined\n * @property {RecognitionPositions} lastPositions Last recognition sent/received stroke indexes.\n * @property {String} url=undefined\n * @property {WebSocket} websocket=undefined\n * @property {function} websocketCallback=undefined\n * @property {function} reconnect=undefined\n * @property {Number} currentReconnectionCount=0\n * @property {String} sessionId=undefined\n * @property {Number} contentPartCount=0\n * @property {String} currentPartId=undefined\n * @property {String} instanceId=undefined\n * @property {Boolean} canUndo=false\n * @property {Boolean} canRedo=false\n * @property {Boolean} isEmpty=false\n * @property {Array} supportedImportMimeTypes=[]\n * @property {Number} undoStackIndex=0\n * @property {Number} possibleUndoCount=0\n * @property {Boolean} idle=true\n * @property {Boolean} initialized=false\n */\n/**\n * Create a new recognizer context\n * @param {Editor} editor\n * @return {RecognizerContext} An object that contains all recognizer context\n */\nexport function createEmptyRecognizerContext(editor) {\n const id = Date.now();\n logger.info('Create empty recognizer context with ID: ' + id);\n return {\n id,\n editor,\n // websocket\n recognitionContexts: [],\n initPromise: undefined,\n lastPositions: {\n lastSentPosition: -1,\n lastReceivedPosition: -1\n },\n url: undefined,\n websocket: undefined,\n websocketCallback: undefined,\n reconnect: undefined,\n currentReconnectionCount: 0,\n sessionId: undefined,\n contentPartCount: 0,\n currentPartId: undefined,\n instanceId: undefined,\n canUndo: false,\n canRedo: false,\n isEmpty: undefined,\n supportedImportMimeTypes: [],\n undoStackIndex: 0,\n possibleUndoCount: 0,\n idle: true,\n initialized: false\n };\n}\n\n/**\n * Return true if a reset is required, false otherwise\n * @param {RecognizerContext} recognizerContext\n * @param {Model} model\n * @return {Boolean}\n */\nexport function isResetRequired(recognizerContext, model) {\n if (recognizerContext.lastPositions) {\n return recognizerContext.lastPositions.lastSentPosition >= model.rawStrokes.length - 1;\n }\n return false;\n}\n\n/**\n * Update the recognition context positions\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {RecognitionPositions} positions Current recognition positions\n * @return {RecognizerContext}\n */\nexport function updateRecognitionPositions(recognizerContext, positions) {\n const recognizerContextRef = recognizerContext;\n if (positions) {\n recognizerContextRef.lastPositions.lastSentPosition = positions.lastSentPosition;\n recognizerContextRef.lastPositions.lastReceivedPosition = positions.lastReceivedPosition;\n }\n if (recognizerContextRef.lastPositions.lastSentPosition === recognizerContextRef.lastPositions.lastReceivedPosition === -1) {\n delete recognizerContextRef.instanceId;\n }\n return recognizerContextRef;\n}\n\n/**\n * Set the recognition context\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {RecognitionContext} recognitionContext\n * @return {RecognizerContext}\n */\nexport function setRecognitionContext(recognizerContext, recognitionContext) {\n const recognizerContextRef = recognizerContext;\n recognizerContextRef.recognitionContexts[0] = recognitionContext;\n return recognizerContextRef;\n}\n\n\n/**\n * Test if it is possible to reconnect\n * @param {RecognizerContext} recognizerContext\n * @return {Boolean} True if possible, false otherwise\n */\nexport function canReconnect(recognizerContext) {\n return recognizerContext.websocket.autoReconnect === true && recognizerContext.currentReconnectionCount <= recognizerContext.websocket.maxRetryCount;\n}\n\n/**\n * Test if it should attempt immediate reconnect\n * @param {RecognizerContext} recognizerContext\n * @return {Boolean} True if should attempt reconnect, false otherwise\n */\nexport function shouldAttemptImmediateReconnect(recognizerContext) {\n const recognizerContextRef = recognizerContext;\n return recognizerContextRef.websocket.autoReconnect === true && recognizerContextRef.currentReconnectionCount++ <= recognizerContextRef.websocket.maxRetryCount;\n}\n\n/**\n * Lost connection message\n * @type {{type: string}}\n */\nexport const LOST_CONNEXION_MESSAGE = { type: 'LOST_CONNECTION' };\n\n/**\n * Explicit close message\n * @type {String}\n */\nexport const CLOSE_RECOGNIZER_MESSAGE = 'CLOSE_RECOGNIZER';\n\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/model/RecognizerContext.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 240, "kind": "typedef", "name": "RecognitionContext", "memberof": "src/model/RecognizerContext.js", "static": true, "longname": "src/model/RecognizerContext.js~RecognitionContext", "access": "public", "description": "Recognition context", "properties": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" }, { "nullable": null, "types": [ "Callback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "type": { "types": [ "Object" ], "optional": false, "name": "RecognitionContext" } }, { "__docId__": 241, "kind": "typedef", "name": "RecognizerContext", "memberof": "src/model/RecognizerContext.js", "static": true, "longname": "src/model/RecognizerContext.js~RecognizerContext", "access": "public", "description": "Recognizer context", "properties": [ { "nullable": null, "types": [ "Editor" ], "spread": false, "optional": false, "name": "editor", "description": "Get a reference to the current editor" }, { "nullable": null, "types": [ "Array" ], "spread": false, "optional": false, "defaultValue": "[]", "defaultRaw": [], "name": "recognitionContexts", "description": "" }, { "nullable": null, "types": [ "Promise" ], "spread": false, "optional": false, "defaultValue": "undefined", "defaultRaw": "undefined", "name": "initPromise", "description": "" }, { "nullable": null, "types": [ "RecognitionPositions" ], "spread": false, "optional": false, "name": "lastPositions", "description": "Last recognition sent/received stroke indexes." }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "defaultValue": "undefined", "defaultRaw": "undefined", "name": "url", "description": "" }, { "nullable": null, "types": [ "WebSocket" ], "spread": false, "optional": false, "defaultValue": "undefined", "defaultRaw": "undefined", "name": "websocket", "description": "" }, { "nullable": null, "types": [ "function" ], "spread": false, "optional": false, "defaultValue": "undefined", "defaultRaw": "undefined", "name": "websocketCallback", "description": "" }, { "nullable": null, "types": [ "function" ], "spread": false, "optional": false, "defaultValue": "undefined", "defaultRaw": "undefined", "name": "reconnect", "description": "" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "defaultValue": "0", "defaultRaw": 0, "name": "currentReconnectionCount", "description": "" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "defaultValue": "undefined", "defaultRaw": "undefined", "name": "sessionId", "description": "" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "defaultValue": "0", "defaultRaw": 0, "name": "contentPartCount", "description": "" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "defaultValue": "undefined", "defaultRaw": "undefined", "name": "currentPartId", "description": "" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "defaultValue": "undefined", "defaultRaw": "undefined", "name": "instanceId", "description": "" }, { "nullable": null, "types": [ "Boolean" ], "spread": false, "optional": false, "defaultValue": "false", "defaultRaw": false, "name": "canUndo", "description": "" }, { "nullable": null, "types": [ "Boolean" ], "spread": false, "optional": false, "defaultValue": "false", "defaultRaw": false, "name": "canRedo", "description": "" }, { "nullable": null, "types": [ "Boolean" ], "spread": false, "optional": false, "defaultValue": "false", "defaultRaw": false, "name": "isEmpty", "description": "" }, { "nullable": null, "types": [ "Array" ], "spread": false, "optional": false, "defaultValue": "[]", "defaultRaw": [], "name": "supportedImportMimeTypes", "description": "" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "defaultValue": "0", "defaultRaw": 0, "name": "undoStackIndex", "description": "" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "defaultValue": "0", "defaultRaw": 0, "name": "possibleUndoCount", "description": "" }, { "nullable": null, "types": [ "Boolean" ], "spread": false, "optional": false, "defaultValue": "true", "defaultRaw": true, "name": "idle", "description": "" }, { "nullable": null, "types": [ "Boolean" ], "spread": false, "optional": false, "defaultValue": "false", "defaultRaw": false, "name": "initialized", "description": "" } ], "type": { "types": [ "Object" ], "optional": false, "name": "RecognizerContext" } }, { "__docId__": 242, "kind": "function", "name": "createEmptyRecognizerContext", "memberof": "src/model/RecognizerContext.js", "generator": false, "async": false, "static": true, "longname": "src/model/RecognizerContext.js~createEmptyRecognizerContext", "access": "public", "export": true, "importPath": "myscript/src/model/RecognizerContext.js", "importStyle": "{createEmptyRecognizerContext}", "description": "Create a new recognizer context", "lineNumber": 40, "params": [ { "nullable": null, "types": [ "Editor" ], "spread": false, "optional": false, "name": "editor", "description": "" } ], "return": { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "description": "An object that contains all recognizer context" } }, { "__docId__": 243, "kind": "function", "name": "isResetRequired", "memberof": "src/model/RecognizerContext.js", "generator": false, "async": false, "static": true, "longname": "src/model/RecognizerContext.js~isResetRequired", "access": "public", "export": true, "importPath": "myscript/src/model/RecognizerContext.js", "importStyle": "{isResetRequired}", "description": "Return true if a reset is required, false otherwise", "lineNumber": 79, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" } ], "return": { "nullable": null, "types": [ "Boolean" ], "spread": false, "description": "" } }, { "__docId__": 244, "kind": "function", "name": "updateRecognitionPositions", "memberof": "src/model/RecognizerContext.js", "generator": false, "async": false, "static": true, "longname": "src/model/RecognizerContext.js~updateRecognitionPositions", "access": "public", "export": true, "importPath": "myscript/src/model/RecognizerContext.js", "importStyle": "{updateRecognitionPositions}", "description": "Update the recognition context positions", "lineNumber": 92, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "RecognitionPositions" ], "spread": false, "optional": false, "name": "positions", "description": "Current recognition positions" } ], "return": { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "description": "" } }, { "__docId__": 245, "kind": "function", "name": "setRecognitionContext", "memberof": "src/model/RecognizerContext.js", "generator": false, "async": false, "static": true, "longname": "src/model/RecognizerContext.js~setRecognitionContext", "access": "public", "export": true, "importPath": "myscript/src/model/RecognizerContext.js", "importStyle": "{setRecognitionContext}", "description": "Set the recognition context", "lineNumber": 110, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "RecognitionContext" ], "spread": false, "optional": false, "name": "recognitionContext", "description": "" } ], "return": { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "description": "" } }, { "__docId__": 246, "kind": "function", "name": "canReconnect", "memberof": "src/model/RecognizerContext.js", "generator": false, "async": false, "static": true, "longname": "src/model/RecognizerContext.js~canReconnect", "access": "public", "export": true, "importPath": "myscript/src/model/RecognizerContext.js", "importStyle": "{canReconnect}", "description": "Test if it is possible to reconnect", "lineNumber": 122, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "" } ], "return": { "nullable": null, "types": [ "Boolean" ], "spread": false, "description": "True if possible, false otherwise" } }, { "__docId__": 247, "kind": "function", "name": "shouldAttemptImmediateReconnect", "memberof": "src/model/RecognizerContext.js", "generator": false, "async": false, "static": true, "longname": "src/model/RecognizerContext.js~shouldAttemptImmediateReconnect", "access": "public", "export": true, "importPath": "myscript/src/model/RecognizerContext.js", "importStyle": "{shouldAttemptImmediateReconnect}", "description": "Test if it should attempt immediate reconnect", "lineNumber": 131, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "" } ], "return": { "nullable": null, "types": [ "Boolean" ], "spread": false, "description": "True if should attempt reconnect, false otherwise" } }, { "__docId__": 248, "kind": "variable", "name": "LOST_CONNEXION_MESSAGE", "memberof": "src/model/RecognizerContext.js", "static": true, "longname": "src/model/RecognizerContext.js~LOST_CONNEXION_MESSAGE", "access": "public", "export": true, "importPath": "myscript/src/model/RecognizerContext.js", "importStyle": "{LOST_CONNEXION_MESSAGE}", "description": "Lost connection message", "lineNumber": 140, "type": { "nullable": null, "types": [ "{type: string}" ], "spread": false, "description": null } }, { "__docId__": 249, "kind": "variable", "name": "CLOSE_RECOGNIZER_MESSAGE", "memberof": "src/model/RecognizerContext.js", "static": true, "longname": "src/model/RecognizerContext.js~CLOSE_RECOGNIZER_MESSAGE", "access": "public", "export": true, "importPath": "myscript/src/model/RecognizerContext.js", "importStyle": "{CLOSE_RECOGNIZER_MESSAGE}", "description": "Explicit close message", "lineNumber": 146, "type": { "nullable": null, "types": [ "String" ], "spread": false, "description": null } }, { "__docId__": 250, "kind": "file", "name": "src/model/StrokeComponent.js", "content": "import { modelLogger as logger } from '../configuration/LoggerConfig';\n\n/**\n * Stroke symbol\n * @typedef {Object} Stroke\n * @property {String} type=stroke Symbol type, 'stroke' for stroke\n * @property {String} pointerType=undefined Pointer type\n * @property {Number} pointerId=undefined Pointer id\n * @property {Array} x=[] X coordinates\n * @property {Array} y=[] Y coordinates\n * @property {Array} t=[] Timestamps matching x,y coordinates\n * @property {Array} p=[] Pressure\n * @property {Array} l=[] Length from origin\n * @property {Number} width=0 (for rendering) Pen/brush width\n * @property {String} color=undefined (for rendering) Pen/brush color\n */\n\n/**\n * pointerEvents symbol\n * @typedef {Object} pointerEvents\n * @property {String} type=pointerEvents Symbol type, 'pointerEvents' for pointerEvents\n * @property {Boolean} processGestures=False indicates if the gestures have to be processed\n * @property {Array} events=[] the events to process\n */\n\nfunction computeDistance(x, y, xArray, yArray, lastIndexPoint) {\n const distance = Math.sqrt(Math.pow((y - yArray[lastIndexPoint - 1]), 2) + Math.pow((x - xArray[lastIndexPoint - 1]), 2));\n return isNaN(distance) ? 0 : distance;\n}\n\nfunction computeLength(x, y, xArray, yArray, lArray, lastIndexPoint) {\n const length = lArray[lastIndexPoint - 1] + computeDistance(x, y, xArray, yArray, lastIndexPoint);\n return isNaN(length) ? 0 : length;\n}\n\nfunction computePressure(x, y, xArray, yArray, lArray, lastIndexPoint) {\n let ratio = 1.0;\n const distance = computeDistance(x, y, xArray, yArray, lastIndexPoint);\n const length = computeLength(x, y, xArray, yArray, lArray, lastIndexPoint);\n\n if (length === 0) {\n ratio = 0.5;\n } else if (distance === length) {\n ratio = 1.0;\n } else if (distance < 10) {\n ratio = 0.2 + Math.pow(0.1 * distance, 0.4);\n } else if (distance > length - 10) {\n ratio = 0.2 + Math.pow(0.1 * (length - distance), 0.4);\n }\n const pressure = ratio * Math.max(0.1, 1.0 - (0.1 * Math.sqrt(distance)));\n return isNaN(parseFloat(pressure)) ? 0.5 : pressure;\n}\n\nfunction filterPointByAcquisitionDelta(x, y, xArray, yArray, width) {\n const delta = (2 + (width / 4));\n let ret = false;\n if (xArray.length === 0 || yArray.length === 0 || Math.abs(xArray[xArray.length - 1] - x) >= delta || Math.abs(yArray[yArray.length - 1] - y) >= delta) {\n ret = true;\n }\n return ret;\n}\n\n/**\n * Create a new stroke\n * @param {Object} properties Properties to be applied to the stroke.\n * @return {Stroke} New stroke with properties for quadratics draw\n */\nexport function createStrokeComponent(properties) {\n const defaultStroke = {\n type: 'stroke',\n x: [],\n y: [],\n t: [],\n p: [],\n l: [],\n width: 0\n };\n return Object.assign({}, defaultStroke, properties);\n}\n\n/**\n * Get a JSON copy of a stroke by filtering its properties\n * @param {Stroke} stroke Current stroke\n * @return {{type: String, x: Array, y: Array, t: Array}} Simplified stroke object\n */\nexport function toJSON(stroke) {\n return { type: stroke.type, x: stroke.x, y: stroke.y, t: stroke.t };\n}\n\n/**\n * Get a JSON copy of a stroke by filtering its properties\n * @param {Stroke} stroke Current stroke\n * @return {{x: Array, y: Array, t: Array}} Simplified stroke object\n */\nexport function toJSONV4(stroke) {\n return { x: stroke.x, y: stroke.y, t: stroke.t };\n}\n\n/**\n * Mutate a stroke by adding a point to it.\n * @param {Stroke} stroke Current stroke\n * @param {{x: Number, y: Number, t: Number}} point Point to add\n * @return {Stroke} Updated stroke\n */\nexport function addPoint(stroke, point) {\n const strokeReference = stroke;\n if (filterPointByAcquisitionDelta(point.x, point.y, strokeReference.x, strokeReference.y, strokeReference.width)) {\n strokeReference.x.push(point.x);\n strokeReference.y.push(point.y);\n strokeReference.t.push(point.t);\n strokeReference.p.push(computePressure(point.x, point.y, strokeReference.x, strokeReference.y, strokeReference.l, strokeReference.x.length - 1));\n strokeReference.l.push(computeLength(point.x, point.y, strokeReference.x, strokeReference.y, strokeReference.l, strokeReference.x.length - 1));\n } else {\n logger.trace('ignore filtered point', point);\n }\n return strokeReference;\n}\n\n/**\n * Slice a stroke and return the sliced part of it\n * @param {Stroke} stroke Current stroke\n * @param {Number} [start=0] Zero-based index at which to begin extraction\n * @param {Number} [end=length] Zero-based index at which to end extraction\n * @return {Stroke} Sliced stroke\n */\nexport function slice(stroke, start = 0, end = stroke.x.length) {\n const slicedStroke = createStrokeComponent({ color: stroke.color, width: stroke.width });\n for (let i = start; i < end; i++) {\n addPoint(slicedStroke, {\n x: stroke.x[i],\n y: stroke.y[i],\n t: stroke.t[i]\n });\n }\n return slicedStroke;\n}\n\n/**\n * Extract point by index\n * @param {Stroke} stroke Current stroke\n * @param {Number} index Zero-based index\n * @return {{x: Number, y: Number, t: Number, p: Number, l: Number}} Point with properties for quadratics draw\n */\nexport function getPointByIndex(stroke, index) {\n let point;\n if (index !== undefined && index >= 0 && index < stroke.x.length) {\n point = {\n x: stroke.x[index],\n y: stroke.y[index],\n t: stroke.t[index],\n p: stroke.p[index],\n l: stroke.l[index]\n };\n }\n return point;\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/model/StrokeComponent.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 251, "kind": "typedef", "name": "Stroke", "memberof": "src/model/StrokeComponent.js", "static": true, "longname": "src/model/StrokeComponent.js~Stroke", "access": "public", "description": "Stroke symbol", "properties": [ { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "defaultValue": "stroke", "defaultRaw": "stroke", "name": "type", "description": "Symbol type, 'stroke' for stroke" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "defaultValue": "undefined", "defaultRaw": "undefined", "name": "pointerType", "description": "Pointer type" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "defaultValue": "undefined", "defaultRaw": "undefined", "name": "pointerId", "description": "Pointer id" }, { "nullable": null, "types": [ "Array" ], "spread": false, "optional": false, "defaultValue": "[]", "defaultRaw": [], "name": "x", "description": "X coordinates" }, { "nullable": null, "types": [ "Array" ], "spread": false, "optional": false, "defaultValue": "[]", "defaultRaw": [], "name": "y", "description": "Y coordinates" }, { "nullable": null, "types": [ "Array" ], "spread": false, "optional": false, "defaultValue": "[]", "defaultRaw": [], "name": "t", "description": "Timestamps matching x,y coordinates" }, { "nullable": null, "types": [ "Array" ], "spread": false, "optional": false, "defaultValue": "[]", "defaultRaw": [], "name": "p", "description": "Pressure" }, { "nullable": null, "types": [ "Array" ], "spread": false, "optional": false, "defaultValue": "[]", "defaultRaw": [], "name": "l", "description": "Length from origin" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "defaultValue": "0", "defaultRaw": 0, "name": "width", "description": "(for rendering) Pen/brush width" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "defaultValue": "undefined", "defaultRaw": "undefined", "name": "color", "description": "(for rendering) Pen/brush color" } ], "type": { "types": [ "Object" ], "optional": false, "name": "Stroke" } }, { "__docId__": 252, "kind": "typedef", "name": "pointerEvents", "memberof": "src/model/StrokeComponent.js", "static": true, "longname": "src/model/StrokeComponent.js~pointerEvents", "access": "public", "description": "pointerEvents symbol", "lineNumber": 26, "properties": [ { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "defaultValue": "pointerEvents", "defaultRaw": "pointerEvents", "name": "type", "description": "Symbol type, 'pointerEvents' for pointerEvents" }, { "nullable": null, "types": [ "Boolean" ], "spread": false, "optional": false, "defaultValue": "False", "defaultRaw": "False", "name": "processGestures", "description": "indicates if the gestures have to be processed" }, { "nullable": null, "types": [ "Array" ], "spread": false, "optional": false, "defaultValue": "[]", "defaultRaw": [], "name": "events", "description": "the events to process" } ], "type": { "types": [ "Object" ], "optional": false, "name": "pointerEvents" } }, { "__docId__": 253, "kind": "function", "name": "computeLength", "memberof": "src/model/StrokeComponent.js", "generator": false, "async": false, "static": true, "longname": "src/model/StrokeComponent.js~computeLength", "access": "public", "export": false, "importPath": "myscript/src/model/StrokeComponent.js", "importStyle": null, "description": null, "lineNumber": 31, "undocument": true, "params": [ { "name": "x", "types": [ "*" ] }, { "name": "y", "types": [ "*" ] }, { "name": "xArray", "types": [ "*" ] }, { "name": "yArray", "types": [ "*" ] }, { "name": "lArray", "types": [ "*" ] }, { "name": "lastIndexPoint", "types": [ "*" ] } ], "return": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 254, "kind": "function", "name": "computePressure", "memberof": "src/model/StrokeComponent.js", "generator": false, "async": false, "static": true, "longname": "src/model/StrokeComponent.js~computePressure", "access": "public", "export": false, "importPath": "myscript/src/model/StrokeComponent.js", "importStyle": null, "description": null, "lineNumber": 36, "undocument": true, "params": [ { "name": "x", "types": [ "*" ] }, { "name": "y", "types": [ "*" ] }, { "name": "xArray", "types": [ "*" ] }, { "name": "yArray", "types": [ "*" ] }, { "name": "lArray", "types": [ "*" ] }, { "name": "lastIndexPoint", "types": [ "*" ] } ], "return": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 255, "kind": "function", "name": "filterPointByAcquisitionDelta", "memberof": "src/model/StrokeComponent.js", "generator": false, "async": false, "static": true, "longname": "src/model/StrokeComponent.js~filterPointByAcquisitionDelta", "access": "public", "export": false, "importPath": "myscript/src/model/StrokeComponent.js", "importStyle": null, "description": null, "lineNumber": 54, "undocument": true, "params": [ { "name": "x", "types": [ "*" ] }, { "name": "y", "types": [ "*" ] }, { "name": "xArray", "types": [ "*" ] }, { "name": "yArray", "types": [ "*" ] }, { "name": "width", "types": [ "*" ] } ], "return": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 256, "kind": "function", "name": "createStrokeComponent", "memberof": "src/model/StrokeComponent.js", "generator": false, "async": false, "static": true, "longname": "src/model/StrokeComponent.js~createStrokeComponent", "access": "public", "export": true, "importPath": "myscript/src/model/StrokeComponent.js", "importStyle": "{createStrokeComponent}", "description": "Create a new stroke", "lineNumber": 68, "params": [ { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "properties", "description": "Properties to be applied to the stroke." } ], "return": { "nullable": null, "types": [ "Stroke" ], "spread": false, "description": "New stroke with properties for quadratics draw" } }, { "__docId__": 257, "kind": "function", "name": "toJSON", "memberof": "src/model/StrokeComponent.js", "generator": false, "async": false, "static": true, "longname": "src/model/StrokeComponent.js~toJSON", "access": "public", "export": true, "importPath": "myscript/src/model/StrokeComponent.js", "importStyle": "{toJSON}", "description": "Get a JSON copy of a stroke by filtering its properties", "lineNumber": 86, "params": [ { "nullable": null, "types": [ "Stroke" ], "spread": false, "optional": false, "name": "stroke", "description": "Current stroke" } ], "return": { "nullable": null, "types": [ "{type: String, x: Array, y: Array, t: Array}" ], "spread": false, "description": "Simplified stroke object" } }, { "__docId__": 258, "kind": "function", "name": "toJSONV4", "memberof": "src/model/StrokeComponent.js", "generator": false, "async": false, "static": true, "longname": "src/model/StrokeComponent.js~toJSONV4", "access": "public", "export": true, "importPath": "myscript/src/model/StrokeComponent.js", "importStyle": "{toJSONV4}", "description": "Get a JSON copy of a stroke by filtering its properties", "lineNumber": 95, "params": [ { "nullable": null, "types": [ "Stroke" ], "spread": false, "optional": false, "name": "stroke", "description": "Current stroke" } ], "return": { "nullable": null, "types": [ "{x: Array, y: Array, t: Array}" ], "spread": false, "description": "Simplified stroke object" } }, { "__docId__": 259, "kind": "function", "name": "addPoint", "memberof": "src/model/StrokeComponent.js", "generator": false, "async": false, "static": true, "longname": "src/model/StrokeComponent.js~addPoint", "access": "public", "export": true, "importPath": "myscript/src/model/StrokeComponent.js", "importStyle": "{addPoint}", "description": "Mutate a stroke by adding a point to it.", "lineNumber": 105, "params": [ { "nullable": null, "types": [ "Stroke" ], "spread": false, "optional": false, "name": "stroke", "description": "Current stroke" }, { "nullable": null, "types": [ "{x: Number, y: Number, t: Number}" ], "spread": false, "optional": false, "name": "point", "description": "Point to add" } ], "return": { "nullable": null, "types": [ "Stroke" ], "spread": false, "description": "Updated stroke" } }, { "__docId__": 260, "kind": "function", "name": "slice", "memberof": "src/model/StrokeComponent.js", "generator": false, "async": false, "static": true, "longname": "src/model/StrokeComponent.js~slice", "access": "public", "export": true, "importPath": "myscript/src/model/StrokeComponent.js", "importStyle": "{slice}", "description": "Slice a stroke and return the sliced part of it", "lineNumber": 126, "params": [ { "nullable": null, "types": [ "Stroke" ], "spread": false, "optional": false, "name": "stroke", "description": "Current stroke" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": true, "defaultValue": "0", "defaultRaw": 0, "name": "start", "description": "Zero-based index at which to begin extraction" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": true, "defaultValue": "length", "defaultRaw": "length", "name": "end", "description": "Zero-based index at which to end extraction" } ], "return": { "nullable": null, "types": [ "Stroke" ], "spread": false, "description": "Sliced stroke" } }, { "__docId__": 261, "kind": "function", "name": "getPointByIndex", "memberof": "src/model/StrokeComponent.js", "generator": false, "async": false, "static": true, "longname": "src/model/StrokeComponent.js~getPointByIndex", "access": "public", "export": true, "importPath": "myscript/src/model/StrokeComponent.js", "importStyle": "{getPointByIndex}", "description": "Extract point by index", "lineNumber": 144, "params": [ { "nullable": null, "types": [ "Stroke" ], "spread": false, "optional": false, "name": "stroke", "description": "Current stroke" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "name": "index", "description": "Zero-based index" } ], "return": { "nullable": null, "types": [ "{x: Number, y: Number, t: Number, p: Number, l: Number}" ], "spread": false, "description": "Point with properties for quadratics draw" } }, { "__docId__": 262, "kind": "file", "name": "src/model/Symbol.js", "content": "import { MusicClefs } from '../renderer/canvas/symbols/MusicSymbolCanvasRenderer';\nimport Constants from '../configuration/Constants';\n\nfunction mergeBounds(boundsA, boundsB) {\n return {\n minX: Math.min(boundsA.minX, boundsB.minX),\n maxX: Math.max(boundsA.maxX, boundsB.maxX),\n minY: Math.min(boundsA.minY, boundsB.minY),\n maxY: Math.max(boundsA.maxY, boundsB.maxY)\n };\n}\n\nfunction getLineBounds(line) {\n return {\n minX: Math.min(line.firstPoint.x, line.lastPoint.x),\n maxX: Math.max(line.firstPoint.x, line.lastPoint.x),\n minY: Math.min(line.firstPoint.y, line.lastPoint.y),\n maxY: Math.max(line.firstPoint.y, line.lastPoint.y)\n };\n}\n\nfunction getEllipseBounds(ellipse) {\n const angleStep = 0.02; // angle delta between interpolated points on the arc, in radian\n\n let z1 = Math.cos(ellipse.orientation);\n let z3 = Math.sin(ellipse.orientation);\n let z2 = z1;\n let z4 = z3;\n z1 *= ellipse.maxRadius;\n z2 *= ellipse.minRadius;\n z3 *= ellipse.maxRadius;\n z4 *= ellipse.minRadius;\n\n const n = Math.abs(ellipse.sweepAngle) / angleStep;\n\n const x = [];\n const y = [];\n\n for (let i = 0; i <= n; i++) {\n const angle = ellipse.startAngle + ((i / n) * ellipse.sweepAngle);\n const alpha = Math.atan2(Math.sin(angle) / ellipse.minRadius, Math.cos(angle) / ellipse.maxRadius);\n\n const cosAlpha = Math.cos(alpha);\n const sinAlpha = Math.sin(alpha);\n\n x.push(ellipse.center.x + ((z1 * cosAlpha) - (z4 * sinAlpha)));\n y.push(ellipse.center.y + ((z2 * sinAlpha) + (z3 * cosAlpha)));\n }\n\n return {\n minX: Math.min(...x),\n maxX: Math.max(...x),\n minY: Math.min(...y),\n maxY: Math.max(...y)\n };\n}\n\nfunction getTextLineBounds(textLine) {\n return {\n minX: textLine.data.topLeftPoint.x,\n maxX: textLine.data.topLeftPoint.x + textLine.data.width,\n minY: textLine.data.topLeftPoint.y,\n maxY: textLine.data.topLeftPoint.y + textLine.data.height\n };\n}\n\nfunction getClefBounds(clef) {\n return {\n minX: clef.boundingBox.x,\n maxX: clef.boundingBox.x + clef.boundingBox.width,\n minY: clef.boundingBox.y,\n maxY: clef.boundingBox.y + clef.boundingBox.height\n };\n}\n\nfunction getStrokeBounds(stroke) {\n return {\n minX: Math.min(...stroke.x),\n maxX: Math.max(...stroke.x),\n minY: Math.min(...stroke.y),\n maxY: Math.max(...stroke.y)\n };\n}\n\n/**\n * Get the box enclosing the given symbols\n * @param {Array} symbols Symbols to extract bounds from\n * @param {Bounds} [bounds] Starting bounds for recursion\n * @return {Bounds} Bounding box enclosing symbols\n */\nexport function getSymbolsBounds(symbols, bounds = { minX: Number.MAX_VALUE, maxX: Number.MIN_VALUE, minY: Number.MAX_VALUE, maxY: Number.MIN_VALUE }) {\n let boundsRef = bounds;\n boundsRef = symbols\n .filter(symbol => symbol.type === 'stroke')\n .map(getStrokeBounds)\n .reduce(mergeBounds, boundsRef);\n boundsRef = symbols\n .filter(symbol => symbol.type === 'clef')\n .map(getClefBounds)\n .reduce(mergeBounds, boundsRef);\n boundsRef = symbols\n .filter(symbol => symbol.type === 'line')\n .map(getLineBounds)\n .reduce(mergeBounds, boundsRef);\n boundsRef = symbols\n .filter(symbol => symbol.type === 'ellipse')\n .map(getEllipseBounds)\n .reduce(mergeBounds, boundsRef);\n boundsRef = symbols\n .filter(symbol => symbol.type === 'textLine')\n .map(getTextLineBounds)\n .reduce(mergeBounds, boundsRef);\n return boundsRef;\n}\n\nfunction getDefaultMusicSymbols(configuration) {\n const defaultStaff = Object.assign({}, { type: 'staff' }, configuration.recognitionParams.v3.musicParameter.staff);\n const defaultClef = {\n type: 'clef',\n value: Object.assign({}, configuration.recognitionParams.v3.musicParameter.clef)\n };\n defaultClef.value.yAnchor = defaultStaff.top + (defaultStaff.gap * (defaultStaff.count - defaultClef.value.line));\n delete defaultClef.value.line;\n defaultClef.boundingBox = MusicClefs[defaultClef.value.symbol].getBoundingBox(defaultStaff.gap, 0, defaultClef.value.yAnchor);\n return [defaultStaff, defaultClef];\n}\n\n/**\n * Get the default symbols for the current recognition type\n * @param {Configuration} configuration Current recognition parameters from which extract default symbols\n * @return {Array} Symbols matching configuration\n */\nexport function getDefaultSymbols(configuration) {\n switch (configuration.recognitionParams.type) {\n case Constants.RecognitionType.MUSIC:\n return getDefaultMusicSymbols(configuration);\n default:\n return [];\n }\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/model/Symbol.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 263, "kind": "function", "name": "mergeBounds", "memberof": "src/model/Symbol.js", "generator": false, "async": false, "static": true, "longname": "src/model/Symbol.js~mergeBounds", "access": "public", "export": false, "importPath": "myscript/src/model/Symbol.js", "importStyle": null, "description": null, "lineNumber": 4, "undocument": true, "params": [ { "name": "boundsA", "types": [ "*" ] }, { "name": "boundsB", "types": [ "*" ] } ], "return": { "types": [ "{\"minX\": *, \"maxX\": *, \"minY\": *, \"maxY\": *}" ] }, "ignore": true }, { "__docId__": 264, "kind": "function", "name": "getLineBounds", "memberof": "src/model/Symbol.js", "generator": false, "async": false, "static": true, "longname": "src/model/Symbol.js~getLineBounds", "access": "public", "export": false, "importPath": "myscript/src/model/Symbol.js", "importStyle": null, "description": null, "lineNumber": 13, "undocument": true, "params": [ { "name": "line", "types": [ "*" ] } ], "return": { "types": [ "{\"minX\": *, \"maxX\": *, \"minY\": *, \"maxY\": *}" ] }, "ignore": true }, { "__docId__": 265, "kind": "function", "name": "getEllipseBounds", "memberof": "src/model/Symbol.js", "generator": false, "async": false, "static": true, "longname": "src/model/Symbol.js~getEllipseBounds", "access": "public", "export": false, "importPath": "myscript/src/model/Symbol.js", "importStyle": null, "description": null, "lineNumber": 22, "undocument": true, "params": [ { "name": "ellipse", "types": [ "*" ] } ], "return": { "types": [ "{\"minX\": *, \"maxX\": *, \"minY\": *, \"maxY\": *}" ] }, "ignore": true }, { "__docId__": 266, "kind": "function", "name": "getTextLineBounds", "memberof": "src/model/Symbol.js", "generator": false, "async": false, "static": true, "longname": "src/model/Symbol.js~getTextLineBounds", "access": "public", "export": false, "importPath": "myscript/src/model/Symbol.js", "importStyle": null, "description": null, "lineNumber": 58, "undocument": true, "params": [ { "name": "textLine", "types": [ "*" ] } ], "return": { "types": [ "{\"minX\": *, \"maxX\": *, \"minY\": *, \"maxY\": *}" ] }, "ignore": true }, { "__docId__": 267, "kind": "function", "name": "getClefBounds", "memberof": "src/model/Symbol.js", "generator": false, "async": false, "static": true, "longname": "src/model/Symbol.js~getClefBounds", "access": "public", "export": false, "importPath": "myscript/src/model/Symbol.js", "importStyle": null, "description": null, "lineNumber": 67, "undocument": true, "params": [ { "name": "clef", "types": [ "*" ] } ], "return": { "types": [ "{\"minX\": *, \"maxX\": *, \"minY\": *, \"maxY\": *}" ] }, "ignore": true }, { "__docId__": 268, "kind": "function", "name": "getStrokeBounds", "memberof": "src/model/Symbol.js", "generator": false, "async": false, "static": true, "longname": "src/model/Symbol.js~getStrokeBounds", "access": "public", "export": false, "importPath": "myscript/src/model/Symbol.js", "importStyle": null, "description": null, "lineNumber": 76, "undocument": true, "params": [ { "name": "stroke", "types": [ "*" ] } ], "return": { "types": [ "{\"minX\": *, \"maxX\": *, \"minY\": *, \"maxY\": *}" ] }, "ignore": true }, { "__docId__": 269, "kind": "function", "name": "getSymbolsBounds", "memberof": "src/model/Symbol.js", "generator": false, "async": false, "static": true, "longname": "src/model/Symbol.js~getSymbolsBounds", "access": "public", "export": true, "importPath": "myscript/src/model/Symbol.js", "importStyle": "{getSymbolsBounds}", "description": "Get the box enclosing the given symbols", "lineNumber": 91, "params": [ { "nullable": null, "types": [ "Array" ], "spread": false, "optional": false, "name": "symbols", "description": "Symbols to extract bounds from" }, { "nullable": null, "types": [ "Bounds" ], "spread": false, "optional": true, "name": "bounds", "description": "Starting bounds for recursion" } ], "return": { "nullable": null, "types": [ "Bounds" ], "spread": false, "description": "Bounding box enclosing symbols" } }, { "__docId__": 270, "kind": "function", "name": "getDefaultMusicSymbols", "memberof": "src/model/Symbol.js", "generator": false, "async": false, "static": true, "longname": "src/model/Symbol.js~getDefaultMusicSymbols", "access": "public", "export": false, "importPath": "myscript/src/model/Symbol.js", "importStyle": null, "description": null, "lineNumber": 116, "undocument": true, "params": [ { "name": "configuration", "types": [ "*" ] } ], "return": { "types": [ "undefined[]" ] }, "ignore": true }, { "__docId__": 271, "kind": "function", "name": "getDefaultSymbols", "memberof": "src/model/Symbol.js", "generator": false, "async": false, "static": true, "longname": "src/model/Symbol.js~getDefaultSymbols", "access": "public", "export": true, "importPath": "myscript/src/model/Symbol.js", "importStyle": "{getDefaultSymbols}", "description": "Get the default symbols for the current recognition type", "lineNumber": 133, "params": [ { "nullable": null, "types": [ "Configuration" ], "spread": false, "optional": false, "name": "configuration", "description": "Current recognition parameters from which extract default symbols" } ], "return": { "nullable": null, "types": [ "Array" ], "spread": false, "description": "Symbols matching configuration" } }, { "__docId__": 272, "kind": "file", "name": "src/model/UndoRedoContext.js", "content": "import { modelLogger as logger } from '../configuration/LoggerConfig';\n\n/**\n * Undo/redo context\n * @typedef {Object} UndoRedoContext\n * @property {Array} stack=[] List of processed models.\n * @property {Number} currentPosition=-1 Current model index into the stack.\n * @property {Number} maxSize Max size of the stack.\n * @property {Boolean} canUndo=false\n * @property {Boolean} canRedo=false\n */\n\n/**\n * Create a new undo/redo context\n * @param {Configuration} configuration Current configuration\n * @return {UndoRedoContext} New undo/redo context\n */\nexport function createUndoRedoContext(configuration) {\n return {\n stack: [],\n currentPosition: -1,\n maxSize: configuration.undoRedoMaxStackSize,\n canUndo: false,\n canRedo: false\n };\n}\n\n/**\n * Update the undo/redo state\n * @param {UndoRedoContext} undoRedoContext Current undo/redo context\n * @return {UndoRedoContext} Updated undo/redo context\n */\nexport function updateUndoRedoState(undoRedoContext) {\n const undoRedoContextRef = undoRedoContext;\n undoRedoContextRef.canUndo = undoRedoContext.currentPosition > 0;\n undoRedoContextRef.canRedo = undoRedoContext.currentPosition < (undoRedoContext.stack.length - 1);\n return undoRedoContextRef;\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/model/UndoRedoContext.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 273, "kind": "typedef", "name": "UndoRedoContext", "memberof": "src/model/UndoRedoContext.js", "static": true, "longname": "src/model/UndoRedoContext.js~UndoRedoContext", "access": "public", "description": "Undo/redo context", "properties": [ { "nullable": null, "types": [ "Array" ], "spread": false, "optional": false, "defaultValue": "[]", "defaultRaw": [], "name": "stack", "description": "List of processed models." }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "defaultValue": "-1", "defaultRaw": -1, "name": "currentPosition", "description": "Current model index into the stack." }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "name": "maxSize", "description": "Max size of the stack." }, { "nullable": null, "types": [ "Boolean" ], "spread": false, "optional": false, "defaultValue": "false", "defaultRaw": false, "name": "canUndo", "description": "" }, { "nullable": null, "types": [ "Boolean" ], "spread": false, "optional": false, "defaultValue": "false", "defaultRaw": false, "name": "canRedo", "description": "" } ], "type": { "types": [ "Object" ], "optional": false, "name": "UndoRedoContext" } }, { "__docId__": 274, "kind": "function", "name": "createUndoRedoContext", "memberof": "src/model/UndoRedoContext.js", "generator": false, "async": false, "static": true, "longname": "src/model/UndoRedoContext.js~createUndoRedoContext", "access": "public", "export": true, "importPath": "myscript/src/model/UndoRedoContext.js", "importStyle": "{createUndoRedoContext}", "description": "Create a new undo/redo context", "lineNumber": 18, "params": [ { "nullable": null, "types": [ "Configuration" ], "spread": false, "optional": false, "name": "configuration", "description": "Current configuration" } ], "return": { "nullable": null, "types": [ "UndoRedoContext" ], "spread": false, "description": "New undo/redo context" } }, { "__docId__": 275, "kind": "function", "name": "updateUndoRedoState", "memberof": "src/model/UndoRedoContext.js", "generator": false, "async": false, "static": true, "longname": "src/model/UndoRedoContext.js~updateUndoRedoState", "access": "public", "export": true, "importPath": "myscript/src/model/UndoRedoContext.js", "importStyle": "{updateUndoRedoState}", "description": "Update the undo/redo state", "lineNumber": 33, "params": [ { "nullable": null, "types": [ "UndoRedoContext" ], "spread": false, "optional": false, "name": "undoRedoContext", "description": "Current undo/redo context" } ], "return": { "nullable": null, "types": [ "UndoRedoContext" ], "spread": false, "description": "Updated undo/redo context" } }, { "__docId__": 276, "kind": "file", "name": "src/model/UndoRedoManager.js", "content": "import * as InkModel from '../model/InkModel';\nimport * as UndoRedoContext from '../model/UndoRedoContext';\nimport { modelLogger as logger } from '../configuration/LoggerConfig';\nimport Constants from '../configuration/Constants';\n\n/**\n * Undo/redo manager\n * @typedef {Object} UndoRedoManager\n * @property {function(undoRedoContext: UndoRedoContext, model: Model, callback: RecognizerCallback)} updateModel Push the current model into the undo/redo context.\n * @property {function(undoRedoContext: UndoRedoContext, model: Model, callback: RecognizerCallback)} undo Undo.\n * @property {function(undoRedoContext: UndoRedoContext, model: Model, callback: RecognizerCallback)} redo Redo.\n * @property {function(undoRedoContext: UndoRedoContext, model: Model, callback: RecognizerCallback)} clear Clear.\n */\n\n/**\n * Get current model in stack\n * @param {UndoRedoContext} undoRedoContext Current undo/redo context\n * @param {function(err: Object, res: Model, types: ...String)} callback\n * @param {Boolean} [clone=true] Whether or not to clone the model\n * @param {...String} types\n */\nexport function getModel(undoRedoContext, callback, clone = true, ...types) {\n const model = undoRedoContext.stack[undoRedoContext.currentPosition];\n callback(undefined, clone ? InkModel.cloneModel(model) : model, ...types);\n}\n\n/**\n * Mutate the undoRedo stack by adding a new model to it.\n * @param {UndoRedoContext} undoRedoContext Current undo/redo context.\n * @param {Model} model Current model.\n * @param {function(err: Object, res: Model, types: ...String)} callback\n */\nexport function updateModel(undoRedoContext, model, callback) {\n // Used to update the model with the recognition result if relevant\n const modelIndex = undoRedoContext.stack.findIndex(item => (item.modificationTime === model.modificationTime) && (item.rawStrokes.length === model.rawStrokes.length));\n\n const modelReference = model;\n modelReference.modificationTime = new Date().getTime();\n\n const types = [];\n if (modelIndex > -1) {\n undoRedoContext.stack.splice(modelIndex, 1, InkModel.cloneModel(modelReference));\n logger.debug('model updated', modelReference);\n } else {\n const undoRedoContextReference = undoRedoContext;\n undoRedoContextReference.currentPosition += 1;\n undoRedoContextReference.stack = undoRedoContextReference.stack.slice(0, undoRedoContextReference.currentPosition);\n undoRedoContextReference.stack.push(InkModel.cloneModel(modelReference));\n if (undoRedoContextReference.stack.length > undoRedoContextReference.maxSize) {\n undoRedoContextReference.stack.shift();\n undoRedoContextReference.currentPosition--;\n }\n logger.debug('model pushed', modelReference);\n types.push(Constants.EventType.CHANGED);\n }\n UndoRedoContext.updateUndoRedoState(undoRedoContext);\n logger.debug('undo/redo stack updated', undoRedoContext);\n getModel(undoRedoContext, callback, false, ...types);\n}\n\n/**\n * Undo\n * @param {UndoRedoContext} undoRedoContext Current undo/redo context.\n * @param {Model} model Current model.\n * @param {function(err: Object, res: Model, types: ...String)} callback\n */\nexport function undo(undoRedoContext, model, callback) {\n const undoRedoContextReference = undoRedoContext;\n if (undoRedoContextReference.currentPosition > 0) {\n undoRedoContextReference.currentPosition -= 1;\n UndoRedoContext.updateUndoRedoState(undoRedoContext);\n logger.debug('undo index', undoRedoContextReference.currentPosition);\n }\n getModel(undoRedoContext, callback, true, Constants.EventType.CHANGED, Constants.EventType.EXPORTED);\n}\n\n/**\n * Redo\n * @param {UndoRedoContext} undoRedoContext Current undo/redo context.\n * @param {Model} model Current model.\n * @param {function(err: Object, res: Model, types: ...String)} callback\n */\nexport function redo(undoRedoContext, model, callback) {\n const undoRedoContextReference = undoRedoContext;\n if (undoRedoContextReference.currentPosition < undoRedoContextReference.stack.length - 1) {\n undoRedoContextReference.currentPosition += 1;\n UndoRedoContext.updateUndoRedoState(undoRedoContext);\n logger.debug('redo index', undoRedoContextReference.currentPosition);\n }\n getModel(undoRedoContext, callback, true, Constants.EventType.CHANGED, Constants.EventType.EXPORTED);\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/model/UndoRedoManager.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 277, "kind": "typedef", "name": "UndoRedoManager", "memberof": "src/model/UndoRedoManager.js", "static": true, "longname": "src/model/UndoRedoManager.js~UndoRedoManager", "access": "public", "description": "Undo/redo manager", "properties": [ { "nullable": null, "types": [ "function(undoRedoContext: UndoRedoContext, model: Model, callback: RecognizerCallback)" ], "spread": false, "optional": false, "name": "updateModel", "description": "Push the current model into the undo/redo context." }, { "nullable": null, "types": [ "function(undoRedoContext: UndoRedoContext, model: Model, callback: RecognizerCallback)" ], "spread": false, "optional": false, "name": "undo", "description": "Undo." }, { "nullable": null, "types": [ "function(undoRedoContext: UndoRedoContext, model: Model, callback: RecognizerCallback)" ], "spread": false, "optional": false, "name": "redo", "description": "Redo." }, { "nullable": null, "types": [ "function(undoRedoContext: UndoRedoContext, model: Model, callback: RecognizerCallback)" ], "spread": false, "optional": false, "name": "clear", "description": "Clear." } ], "type": { "types": [ "Object" ], "optional": false, "name": "UndoRedoManager" } }, { "__docId__": 278, "kind": "function", "name": "getModel", "memberof": "src/model/UndoRedoManager.js", "generator": false, "async": false, "static": true, "longname": "src/model/UndoRedoManager.js~getModel", "access": "public", "export": true, "importPath": "myscript/src/model/UndoRedoManager.js", "importStyle": "{getModel}", "description": "Get current model in stack", "lineNumber": 22, "params": [ { "nullable": null, "types": [ "UndoRedoContext" ], "spread": false, "optional": false, "name": "undoRedoContext", "description": "Current undo/redo context" }, { "nullable": null, "types": [ "function(err: Object, res: Model, types: ...String)" ], "spread": false, "optional": false, "name": "callback", "description": "" }, { "nullable": null, "types": [ "Boolean" ], "spread": false, "optional": true, "defaultValue": "true", "defaultRaw": true, "name": "clone", "description": "Whether or not to clone the model" }, { "nullable": null, "types": [ "...String" ], "spread": true, "optional": false, "name": "types", "description": "" } ], "return": null }, { "__docId__": 279, "kind": "function", "name": "updateModel", "memberof": "src/model/UndoRedoManager.js", "generator": false, "async": false, "static": true, "longname": "src/model/UndoRedoManager.js~updateModel", "access": "public", "export": true, "importPath": "myscript/src/model/UndoRedoManager.js", "importStyle": "{updateModel}", "description": "Mutate the undoRedo stack by adding a new model to it.", "lineNumber": 33, "params": [ { "nullable": null, "types": [ "UndoRedoContext" ], "spread": false, "optional": false, "name": "undoRedoContext", "description": "Current undo/redo context." }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model." }, { "nullable": null, "types": [ "function(err: Object, res: Model, types: ...String)" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 280, "kind": "function", "name": "undo", "memberof": "src/model/UndoRedoManager.js", "generator": false, "async": false, "static": true, "longname": "src/model/UndoRedoManager.js~undo", "access": "public", "export": true, "importPath": "myscript/src/model/UndoRedoManager.js", "importStyle": "{undo}", "description": "Undo", "lineNumber": 67, "params": [ { "nullable": null, "types": [ "UndoRedoContext" ], "spread": false, "optional": false, "name": "undoRedoContext", "description": "Current undo/redo context." }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model." }, { "nullable": null, "types": [ "function(err: Object, res: Model, types: ...String)" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 281, "kind": "function", "name": "redo", "memberof": "src/model/UndoRedoManager.js", "generator": false, "async": false, "static": true, "longname": "src/model/UndoRedoManager.js~redo", "access": "public", "export": true, "importPath": "myscript/src/model/UndoRedoManager.js", "importStyle": "{redo}", "description": "Redo", "lineNumber": 83, "params": [ { "nullable": null, "types": [ "UndoRedoContext" ], "spread": false, "optional": false, "name": "undoRedoContext", "description": "Current undo/redo context." }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model." }, { "nullable": null, "types": [ "function(err: Object, res: Model, types: ...String)" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 282, "kind": "file", "name": "src/myscript.js", "content": "import Constants from './configuration/Constants';\nimport LoggerConfig from './configuration/LoggerConfig';\nimport DefaultConfiguration from './configuration/DefaultConfiguration';\nimport DefaultPenStyle from './configuration/DefaultPenStyle';\nimport DefaultTheme from './configuration/DefaultTheme';\nimport DefaultBehaviors from './configuration/DefaultBehaviors';\nimport * as InkModel from './model/InkModel';\nimport { Editor } from './Editor';\nimport { register, getAvailableLanguageList } from './EditorFacade';\nimport * as RecognizerContext from './model/RecognizerContext';\n\nconst MyScript = {\n Constants,\n // Default instantiations\n DefaultConfiguration,\n DefaultBehaviors,\n DefaultPenStyle,\n DefaultTheme,\n // Helper functions\n register,\n getAvailableLanguageList,\n // Internals\n LoggerConfig,\n Editor,\n InkModel,\n RecognizerContext,\n};\n\nexport {\n MyScript as default,\n Constants,\n // Default instantiations\n DefaultConfiguration,\n DefaultBehaviors,\n DefaultPenStyle,\n DefaultTheme,\n // Helper functions\n register,\n getAvailableLanguageList,\n // Internals\n LoggerConfig,\n Editor,\n InkModel,\n RecognizerContext,\n};\n\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/myscript.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 283, "kind": "variable", "name": "MyScript", "memberof": "src/myscript.js", "static": true, "longname": "src/myscript.js~MyScript", "access": "public", "export": false, "importPath": "myscript/src/myscript.js", "importStyle": null, "description": null, "lineNumber": 12, "undocument": true, "type": { "types": [ "{\"Constants\": *, \"DefaultConfiguration\": *, \"DefaultBehaviors\": *, \"DefaultPenStyle\": *, \"DefaultTheme\": *, \"register\": *, \"getAvailableLanguageList\": *, \"LoggerConfig\": *, \"Editor\": *, \"InkModel\": *, \"RecognizerContext\": *}" ] }, "ignore": true }, { "__docId__": 284, "kind": "file", "name": "src/recognizer/CryptoHelper.js", "content": "import Hex from 'crypto-js/enc-hex';\nimport HmacSHA512 from 'crypto-js/hmac-sha512';\nimport { recognizerLogger as logger } from '../configuration/LoggerConfig';\n\n/**\n * Compute HMAC signature for server authentication\n *\n * @param {Object} input Input data to compute HMAC\n * @param {String} applicationKey Current applicationKey\n * @param {String} hmacKey Current hmacKey\n * @return {String} Signature\n */\nexport function computeHmac(input, applicationKey, hmacKey) {\n const jsonInput = (typeof input === 'object') ? JSON.stringify(input) : input;\n logger.debug('The HmacSHA512 function is loaded', HmacSHA512);\n return new HmacSHA512(jsonInput, applicationKey + hmacKey).toString(Hex);\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/recognizer/CryptoHelper.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 285, "kind": "function", "name": "computeHmac", "memberof": "src/recognizer/CryptoHelper.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/CryptoHelper.js~computeHmac", "access": "public", "export": true, "importPath": "myscript/src/recognizer/CryptoHelper.js", "importStyle": "{computeHmac}", "description": "Compute HMAC signature for server authentication", "lineNumber": 13, "params": [ { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "input", "description": "Input data to compute HMAC" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "applicationKey", "description": "Current applicationKey" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "hmacKey", "description": "Current hmacKey" } ], "return": { "nullable": null, "types": [ "String" ], "spread": false, "description": "Signature" } }, { "__docId__": 286, "kind": "file", "name": "src/recognizer/DefaultRecognizer.js", "content": "import { recognizerLogger as logger } from '../configuration/LoggerConfig';\nimport * as InkModel from '../model/InkModel';\nimport * as RecognizerContext from '../model/RecognizerContext';\nimport Constants from '../configuration/Constants';\n\n/**\n * Triggers\n * @typedef {Object} Triggers\n * @property {Array} exportContent Supported triggers for exporting content.\n * @property {Array} [addStrokes] Supported triggers for adding strokes.\n */\n\n/**\n * Recognizer info\n * @typedef {Object} RecognizerInfo\n * @property {Array} types Supported recognition types (TEXT, MATH, SHAPE, MUSIC, ANALYZER).\n * @property {String} protocol Supported protocol (REST, WEBSOCKET).\n * @property {String} apiVersion Supported API version.\n * @property {Triggers} availableTriggers Supported triggers for this recognizer.\n */\n\n/**\n * Recognizer callback\n * @typedef {function} RecognizerCallback\n * @param {Object} [err] Error\n * @param {Model} [model] Result\n * @param {...String} [types] Result types\n */\n\n/**\n * Simple callback\n * @typedef {function} Callback\n * @param {Object} [err] Error\n * @param {Object} [res] Result\n */\n\n/**\n * Recognition service entry point\n * @typedef {Object} Recognizer\n * @property {function(): RecognizerInfo} getInfo Get information about the supported configuration (protocol, type, apiVersion, ...).\n * @property {function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback)} init Initialize recognition.\n * @property {function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback)} clear Clear server context. Currently nothing to do there.\n * @property {function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback)} close Close and free all resources that will no longer be used by the recognizer.\n * @property {function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback)} [undo] Undo Undo the last done action.\n * @property {function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback)} [redo] Redo Redo the previously undone action.\n * @property {function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback, element: Element)} [resize] Resize.\n * @property {function(recognizerContext: RecognizerContext, model: Model, strokes: Array, callback: RecognizerCallback)} [pointerEvents] Pointer Events.\n * @property {function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback)} [addStrokes] Add strokes.\n * @property {function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback)} [export_] Export content.\n * @property {function(recognizerContext: RecognizerContext, model: Model, data: Blob, callback: RecognizerCallback)} [import_] Import content.\n * @property {function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback, conversionState: String)} [convert] Convert.\n * @property {function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback)} [waitForIdle] Wait for idle.\n * @property {function(recognizerContext: RecognizerContext, model: Model, penStyle: PenStyle, callback: RecognizerCallback)} [setPenStyle] Set pen style.\n * @property {function(recognizerContext: RecognizerContext, model: Model, penStyleClasses: String, callback: RecognizerCallback)} [setPenStyleClasses] Set pen style classes.\n * @property {function(recognizerContext: RecognizerContext, model: Model, theme: Theme, callback: RecognizerCallback)} [setTheme] Set theme.\n */\n\n/**\n * Initialize recognition\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function init(recognizerContext, model, callback) {\n const modelRef = InkModel.resetModelPositions(model);\n logger.debug('Updated model', modelRef);\n const recognizerContextRef = RecognizerContext.updateRecognitionPositions(recognizerContext, modelRef.lastPositions);\n recognizerContextRef.initPromise = Promise.resolve(modelRef);\n recognizerContextRef.initPromise\n .then((res) => {\n recognizerContextRef.initialized = true;\n logger.debug('Updated recognizer context', recognizerContextRef);\n callback(undefined, res, Constants.EventType.LOADED);\n });\n}\n\n/**\n * Reset server context. Currently nothing to do there.\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function reset(recognizerContext, model, callback) {\n const modelRef = InkModel.resetModelPositions(model);\n logger.debug('Updated model', modelRef);\n const recognizerContextRef = RecognizerContext.updateRecognitionPositions(recognizerContext, modelRef.lastPositions);\n delete recognizerContextRef.instanceId;\n logger.debug('Updated recognizer context', recognizerContextRef);\n callback(undefined, modelRef);\n}\n\n/**\n * Clear server context. Currently nothing to do there.\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function clear(recognizerContext, model, callback) {\n const modelRef = InkModel.clearModel(model);\n logger.debug('Updated model', modelRef);\n const recognizerContextRef = RecognizerContext.updateRecognitionPositions(recognizerContext, modelRef.lastPositions);\n delete recognizerContextRef.instanceId;\n logger.debug('Updated recognizer context', recognizerContextRef);\n callback(undefined, modelRef, Constants.EventType.CHANGED, Constants.EventType.EXPORTED, Constants.EventType.RENDERED);\n}\n\n/**\n * Close and free all resources that will no longer be used by the recognizer.\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function close(recognizerContext, model, callback) {\n const recognizerContextRef = recognizerContext;\n recognizerContextRef.initialized = false;\n delete recognizerContextRef.instanceId;\n callback(undefined, model);\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/recognizer/DefaultRecognizer.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 287, "kind": "typedef", "name": "Triggers", "memberof": "src/recognizer/DefaultRecognizer.js", "static": true, "longname": "src/recognizer/DefaultRecognizer.js~Triggers", "access": "public", "description": "Triggers", "properties": [ { "nullable": null, "types": [ "Array" ], "spread": false, "optional": false, "name": "exportContent", "description": "Supported triggers for exporting content." }, { "nullable": null, "types": [ "Array" ], "spread": false, "optional": true, "name": "addStrokes", "description": "Supported triggers for adding strokes." } ], "type": { "types": [ "Object" ], "optional": false, "name": "Triggers" } }, { "__docId__": 288, "kind": "typedef", "name": "RecognizerInfo", "memberof": "src/recognizer/DefaultRecognizer.js", "static": true, "longname": "src/recognizer/DefaultRecognizer.js~RecognizerInfo", "access": "public", "description": "Recognizer info", "properties": [ { "nullable": null, "types": [ "Array" ], "spread": false, "optional": false, "name": "types", "description": "Supported recognition types (TEXT, MATH, SHAPE, MUSIC, ANALYZER)." }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "protocol", "description": "Supported protocol (REST, WEBSOCKET)." }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "apiVersion", "description": "Supported API version." }, { "nullable": null, "types": [ "Triggers" ], "spread": false, "optional": false, "name": "availableTriggers", "description": "Supported triggers for this recognizer." } ], "type": { "types": [ "Object" ], "optional": false, "name": "RecognizerInfo" } }, { "__docId__": 289, "kind": "typedef", "name": "RecognizerCallback", "memberof": "src/recognizer/DefaultRecognizer.js", "static": true, "longname": "src/recognizer/DefaultRecognizer.js~RecognizerCallback", "access": "public", "description": "Recognizer callback", "params": [ { "nullable": null, "types": [ "Object" ], "spread": false, "optional": true, "name": "err", "description": "Error" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": true, "name": "model", "description": "Result" }, { "nullable": null, "types": [ "...String" ], "spread": true, "optional": true, "name": "types", "description": "Result types" } ], "type": { "types": [ "function" ], "optional": false, "name": "RecognizerCallback" } }, { "__docId__": 290, "kind": "typedef", "name": "Callback", "memberof": "src/recognizer/DefaultRecognizer.js", "static": true, "longname": "src/recognizer/DefaultRecognizer.js~Callback", "access": "public", "description": "Simple callback", "params": [ { "nullable": null, "types": [ "Object" ], "spread": false, "optional": true, "name": "err", "description": "Error" }, { "nullable": null, "types": [ "Object" ], "spread": false, "optional": true, "name": "res", "description": "Result" } ], "type": { "types": [ "function" ], "optional": false, "name": "Callback" } }, { "__docId__": 291, "kind": "typedef", "name": "Recognizer", "memberof": "src/recognizer/DefaultRecognizer.js", "static": true, "longname": "src/recognizer/DefaultRecognizer.js~Recognizer", "access": "public", "description": "Recognition service entry point", "properties": [ { "nullable": null, "types": [ "function(): RecognizerInfo" ], "spread": false, "optional": false, "name": "getInfo", "description": "Get information about the supported configuration (protocol, type, apiVersion, ...)." }, { "nullable": null, "types": [ "function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback)" ], "spread": false, "optional": false, "name": "init", "description": "Initialize recognition." }, { "nullable": null, "types": [ "function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback)" ], "spread": false, "optional": false, "name": "clear", "description": "Clear server context. Currently nothing to do there." }, { "nullable": null, "types": [ "function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback)" ], "spread": false, "optional": false, "name": "close", "description": "Close and free all resources that will no longer be used by the recognizer." }, { "nullable": null, "types": [ "function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback)" ], "spread": false, "optional": true, "name": "undo", "description": "Undo Undo the last done action." }, { "nullable": null, "types": [ "function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback)" ], "spread": false, "optional": true, "name": "redo", "description": "Redo Redo the previously undone action." }, { "nullable": null, "types": [ "function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback, element: Element)" ], "spread": false, "optional": true, "name": "resize", "description": "Resize." }, { "nullable": null, "types": [ "function(recognizerContext: RecognizerContext, model: Model, strokes: Array, callback: RecognizerCallback)" ], "spread": false, "optional": true, "name": "pointerEvents", "description": "Pointer Events." }, { "nullable": null, "types": [ "function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback)" ], "spread": false, "optional": true, "name": "addStrokes", "description": "Add strokes." }, { "nullable": null, "types": [ "function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback)" ], "spread": false, "optional": true, "name": "export_", "description": "Export content." }, { "nullable": null, "types": [ "function(recognizerContext: RecognizerContext, model: Model, data: Blob, callback: RecognizerCallback)" ], "spread": false, "optional": true, "name": "import_", "description": "Import content." }, { "nullable": null, "types": [ "function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback, conversionState: String)" ], "spread": false, "optional": true, "name": "convert", "description": "Convert." }, { "nullable": null, "types": [ "function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback)" ], "spread": false, "optional": true, "name": "waitForIdle", "description": "Wait for idle." }, { "nullable": null, "types": [ "function(recognizerContext: RecognizerContext, model: Model, penStyle: PenStyle, callback: RecognizerCallback)" ], "spread": false, "optional": true, "name": "setPenStyle", "description": "Set pen style." }, { "nullable": null, "types": [ "function(recognizerContext: RecognizerContext, model: Model, penStyleClasses: String, callback: RecognizerCallback)" ], "spread": false, "optional": true, "name": "setPenStyleClasses", "description": "Set pen style classes." }, { "nullable": null, "types": [ "function(recognizerContext: RecognizerContext, model: Model, theme: Theme, callback: RecognizerCallback)" ], "spread": false, "optional": true, "name": "setTheme", "description": "Set theme." } ], "type": { "types": [ "Object" ], "optional": false, "name": "Recognizer" } }, { "__docId__": 292, "kind": "function", "name": "init", "memberof": "src/recognizer/DefaultRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/DefaultRecognizer.js~init", "access": "public", "export": true, "importPath": "myscript/src/recognizer/DefaultRecognizer.js", "importStyle": "{init}", "description": "Initialize recognition", "lineNumber": 64, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 293, "kind": "function", "name": "reset", "memberof": "src/recognizer/DefaultRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/DefaultRecognizer.js~reset", "access": "public", "export": true, "importPath": "myscript/src/recognizer/DefaultRecognizer.js", "importStyle": "{reset}", "description": "Reset server context. Currently nothing to do there.", "lineNumber": 83, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 294, "kind": "function", "name": "clear", "memberof": "src/recognizer/DefaultRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/DefaultRecognizer.js~clear", "access": "public", "export": true, "importPath": "myscript/src/recognizer/DefaultRecognizer.js", "importStyle": "{clear}", "description": "Clear server context. Currently nothing to do there.", "lineNumber": 98, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 295, "kind": "function", "name": "close", "memberof": "src/recognizer/DefaultRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/DefaultRecognizer.js~close", "access": "public", "export": true, "importPath": "myscript/src/recognizer/DefaultRecognizer.js", "importStyle": "{close}", "description": "Close and free all resources that will no longer be used by the recognizer.", "lineNumber": 113, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 296, "kind": "file", "name": "src/recognizer/common/CdkCommonUtil.js", "content": "import { recognizerLogger as logger } from '../../configuration/LoggerConfig';\n\n/**\n * Extract the exports\n * @param {Model} model Current model\n * @return {Object} Recognition result\n */\nexport function extractExports(model) {\n if (model.rawResults &&\n model.rawResults.exports &&\n model.rawResults.exports.result &&\n model.rawResults.exports.result.results &&\n model.rawResults.exports.result.results.length > 0) {\n return model.rawResults.exports.result.results\n .map((item) => {\n const res = {};\n if (Object.keys(item).includes('root')) {\n res[`${item.type}`] = item.root;\n } else {\n res[`${item.type}`] = item.value;\n }\n return res;\n })\n .reduce((a, b) => Object.assign(a, b), {});\n }\n return {};\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/recognizer/common/CdkCommonUtil.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 297, "kind": "function", "name": "extractExports", "memberof": "src/recognizer/common/CdkCommonUtil.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/common/CdkCommonUtil.js~extractExports", "access": "public", "export": true, "importPath": "myscript/src/recognizer/common/CdkCommonUtil.js", "importStyle": "{extractExports}", "description": "Extract the exports", "lineNumber": 8, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" } ], "return": { "nullable": null, "types": [ "Object" ], "spread": false, "description": "Recognition result" } }, { "__docId__": 298, "kind": "file", "name": "src/recognizer/common/v3/Cdkv3CommonMathRecognizer.js", "content": "import { recognizerLogger as logger } from '../../../configuration/LoggerConfig';\n\n/**\n * Extract the recognized symbols\n * @param {Model} model Current model\n * @return {Array} Recognized symbols\n */\nexport function extractRecognizedSymbols(model) {\n // We recopy the recognized strokes to flag them as toBeRemove if they are scratched out or map with a symbol\n const strokeList = [...model.rawStrokes];\n\n if (model.rawResults &&\n model.rawResults.exports &&\n model.rawResults.exports.result &&\n model.rawResults.exports.result.scratchOutResults &&\n (model.rawResults.exports.result.scratchOutResults.length > 0)) {\n const inkRanges = model.rawResults.exports.result.scratchOutResults\n .map(scratchOutResult => scratchOutResult.erasedInkRanges.concat(scratchOutResult.inkRanges))\n .reduce((a, b) => a.concat(b));\n return strokeList.filter((stroke, index) => !inkRanges.find(inkRange => inkRange.component === index));\n }\n return strokeList;\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/recognizer/common/v3/Cdkv3CommonMathRecognizer.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 299, "kind": "function", "name": "extractRecognizedSymbols", "memberof": "src/recognizer/common/v3/Cdkv3CommonMathRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/common/v3/Cdkv3CommonMathRecognizer.js~extractRecognizedSymbols", "access": "public", "export": true, "importPath": "myscript/src/recognizer/common/v3/Cdkv3CommonMathRecognizer.js", "importStyle": "{extractRecognizedSymbols}", "description": "Extract the recognized symbols", "lineNumber": 8, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" } ], "return": { "nullable": null, "types": [ "Array" ], "spread": false, "description": "Recognized symbols" } }, { "__docId__": 300, "kind": "file", "name": "src/recognizer/common/v3/Cdkv3CommonShapeRecognizer.js", "content": "import { recognizerLogger as logger } from '../../../configuration/LoggerConfig';\nimport * as InkModel from '../../../model/InkModel';\n\n/**\n * Get style for the strokes matching the ink ranges\n * @param {Model} model\n * @param {Array} inkRanges\n * @return {{color: String, width: Number}} Style to apply\n */\nexport function getStyleFromInkRanges(model, inkRanges) {\n let strokes = model.rawStrokes;\n if (inkRanges && (inkRanges.length > 0)) {\n strokes = inkRanges\n .map(inkRange => InkModel.extractStrokesFromInkRange(model, inkRange.stroke ? inkRange.stroke : inkRange.firstStroke, inkRange.stroke ? inkRange.stroke : inkRange.lastStroke, inkRange.firstPoint, inkRange.lastPoint))\n .reduce((a, b) => a.concat(b));\n }\n // FIXME hack to apply the rendering param of the first element' stroke\n return {\n color: strokes[0].color,\n width: strokes[0].width\n };\n}\n\n/**\n * Extract recognized symbols from recognition output\n * @param {Model} model Current model\n * @param {Object} segment Shape recognition output\n * @return {Array} Recognized symbols\n */\nexport function extractShapeSymbols(model, segment) {\n if (segment.candidates && segment.candidates.length > 0) {\n const selectedCandidate = segment.candidates[segment.selectedCandidateIndex];\n switch (selectedCandidate.type) {\n case 'notRecognized':\n if (segment.inkRanges && segment.inkRanges.length > 0) {\n return segment.inkRanges\n .map(inkRange => InkModel.extractStrokesFromInkRange(model, inkRange.firstStroke, inkRange.lastStroke, inkRange.firstPoint, inkRange.lastPoint))\n .reduce((a, b) => a.concat(b));\n }\n return [];\n case 'recognizedShape':\n return selectedCandidate.primitives;\n default:\n return [];\n }\n }\n return [];\n}\n\n/**\n * Extract the recognized symbols\n * @param {Model} model Current model\n * @return {Array} Recognized symbols\n */\nexport function extractRecognizedSymbols(model) {\n if (model.rawResults &&\n model.rawResults.exports &&\n model.rawResults.exports.result &&\n model.rawResults.exports.result.segments) {\n return model.rawResults.exports.result.segments\n .map((segment) => {\n const style = getStyleFromInkRanges(model, segment.inkRanges);\n return extractShapeSymbols(model, segment).map(primitive => Object.assign(primitive, style));\n })\n .reduce((a, b) => a.concat(b));\n }\n return [];\n}\n\n/**\n * Extract the exports\n * @param {Model} model Current model\n * @return {Object} exports\n */\nexport function extractExports(model) {\n // We recopy the recognized strokes to flag them as toBeRemove if they are scratched out or map with a symbol\n if (model.rawResults &&\n model.rawResults.exports &&\n model.rawResults.exports.result &&\n model.rawResults.exports.result.segments) {\n return {\n SEGMENTS: model.rawResults.exports.result.segments\n };\n }\n return {};\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/recognizer/common/v3/Cdkv3CommonShapeRecognizer.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 301, "kind": "function", "name": "getStyleFromInkRanges", "memberof": "src/recognizer/common/v3/Cdkv3CommonShapeRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/common/v3/Cdkv3CommonShapeRecognizer.js~getStyleFromInkRanges", "access": "public", "export": true, "importPath": "myscript/src/recognizer/common/v3/Cdkv3CommonShapeRecognizer.js", "importStyle": "{getStyleFromInkRanges}", "description": "Get style for the strokes matching the ink ranges", "lineNumber": 10, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" }, { "nullable": null, "types": [ "Array" ], "spread": false, "optional": false, "name": "inkRanges", "description": "" } ], "return": { "nullable": null, "types": [ "{color: String, width: Number}" ], "spread": false, "description": "Style to apply" } }, { "__docId__": 302, "kind": "function", "name": "extractShapeSymbols", "memberof": "src/recognizer/common/v3/Cdkv3CommonShapeRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/common/v3/Cdkv3CommonShapeRecognizer.js~extractShapeSymbols", "access": "public", "export": true, "importPath": "myscript/src/recognizer/common/v3/Cdkv3CommonShapeRecognizer.js", "importStyle": "{extractShapeSymbols}", "description": "Extract recognized symbols from recognition output", "lineNumber": 30, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "segment", "description": "Shape recognition output" } ], "return": { "nullable": null, "types": [ "Array" ], "spread": false, "description": "Recognized symbols" } }, { "__docId__": 303, "kind": "function", "name": "extractRecognizedSymbols", "memberof": "src/recognizer/common/v3/Cdkv3CommonShapeRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/common/v3/Cdkv3CommonShapeRecognizer.js~extractRecognizedSymbols", "access": "public", "export": true, "importPath": "myscript/src/recognizer/common/v3/Cdkv3CommonShapeRecognizer.js", "importStyle": "{extractRecognizedSymbols}", "description": "Extract the recognized symbols", "lineNumber": 55, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" } ], "return": { "nullable": null, "types": [ "Array" ], "spread": false, "description": "Recognized symbols" } }, { "__docId__": 304, "kind": "function", "name": "extractExports", "memberof": "src/recognizer/common/v3/Cdkv3CommonShapeRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/common/v3/Cdkv3CommonShapeRecognizer.js~extractExports", "access": "public", "export": true, "importPath": "myscript/src/recognizer/common/v3/Cdkv3CommonShapeRecognizer.js", "importStyle": "{extractExports}", "description": "Extract the exports", "lineNumber": 75, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" } ], "return": { "nullable": null, "types": [ "Object" ], "spread": false, "description": "exports" } }, { "__docId__": 305, "kind": "file", "name": "src/recognizer/common/v3/Cdkv3CommonTextRecognizer.js", "content": "/**\n * Extract the exports\n * @param {Model} model Current model\n * @return {Object} exports\n */\nexport function extractExports(model) {\n // We recopy the recognized strokes to flag them as toBeRemove if they are scratched out or map with a symbol\n if (model.rawResults &&\n model.rawResults.exports &&\n model.rawResults.exports.result &&\n model.rawResults.exports.result.textSegmentResult &&\n model.rawResults.exports.result.textSegmentResult.candidates) {\n return {\n CANDIDATES: model.rawResults.exports.result,\n TEXT: model.rawResults.exports.result.textSegmentResult.candidates[model.rawResults.exports.result.textSegmentResult.selectedCandidateIdx].label\n };\n }\n return {};\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/recognizer/common/v3/Cdkv3CommonTextRecognizer.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 306, "kind": "function", "name": "extractExports", "memberof": "src/recognizer/common/v3/Cdkv3CommonTextRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/common/v3/Cdkv3CommonTextRecognizer.js~extractExports", "access": "public", "export": true, "importPath": "myscript/src/recognizer/common/v3/Cdkv3CommonTextRecognizer.js", "importStyle": "{extractExports}", "description": "Extract the exports", "lineNumber": 6, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" } ], "return": { "nullable": null, "types": [ "Object" ], "spread": false, "description": "exports" } }, { "__docId__": 307, "kind": "file", "name": "src/recognizer/rest/networkInterface.js", "content": "/* eslint-disable no-unused-expressions */\nimport * as CryptoHelper from '../CryptoHelper';\n\n/**\n * Parse JSON String to Object\n * @param {Object} req JSON string result to be parsed\n * @return {Object} Parsed response\n */\nfunction parse(req) {\n let result;\n try {\n result = JSON.parse(req.responseText);\n } catch (e) {\n result = req.responseText;\n }\n return result;\n}\n\n/**\n * Transform object data request to a list of parameters\n * @param {Object} obj Query properties\n * @return {String} URI encoded string\n */\nfunction transformRequest(obj) {\n const str = [];\n Object.keys(obj).forEach((p) => {\n if ((typeof obj[p] !== 'undefined') &&\n (typeof obj[p] !== 'function')) {\n str.push(`${encodeURIComponent(p)}=${encodeURIComponent(obj[p])}`);\n }\n });\n return str.join('&');\n}\n\n/**\n * Send request to the network and return a promise\n * @param {String} type Request type (GET/POST)\n * @param {String} url URL\n * @param {Object} data Data to be sent\n * @param {RecognizerContext} [recognizerContext] Recognizer context\n * @param {String} apiVersion api version\n * @param {String} mimeType MimeType to be used\n * @return {Promise}\n */\nfunction xhr(type, url, data, recognizerContext = {}, apiVersion, mimeType) {\n const pptxMimeType = 'application/vnd.openxmlformats-officedocument.presentationml.presentation';\n const configuration = recognizerContext.editor.configuration;\n const recognizerContextRef = recognizerContext;\n return new Promise((resolve, reject) => {\n // We are writing some browser module here so the no import found should be ignored\n // eslint-disable-next-line no-undef\n const request = new XMLHttpRequest();\n request.open(type, url, true);\n request.withCredentials = true;\n if (apiVersion === 'V3') {\n request.setRequestHeader('Accept', 'application/json');\n request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');\n } else if (apiVersion === 'V4') {\n switch (configuration.recognitionParams.type) {\n case 'TEXT':\n request.setRequestHeader('Accept', 'application/json,' + mimeType);\n break;\n case 'MATH':\n request.setRequestHeader('Accept', 'application/json,' + mimeType);\n break;\n case 'DIAGRAM':\n request.setRequestHeader('Accept', 'application/json,' + mimeType);\n break;\n case 'Raw Content':\n request.setRequestHeader('Accept', 'application/json,' + mimeType);\n break;\n default:\n break;\n }\n request.setRequestHeader('applicationKey', configuration.recognitionParams.server.applicationKey);\n request.setRequestHeader('hmac', CryptoHelper.computeHmac(JSON.stringify(data), configuration.recognitionParams.server.applicationKey, configuration.recognitionParams.server.hmacKey));\n request.setRequestHeader('Content-Type', 'application/json');\n }\n\n const isBlobType = mimeType && (mimeType === pptxMimeType || mimeType.startsWith('image/png') || mimeType.startsWith('image/jpeg'));\n if (isBlobType) {\n request.responseType = 'blob';\n }\n\n request.onerror = () => {\n reject({ msg: `Could not connect to ${url} connection error`, recoverable: false });\n };\n\n request.onload = () => {\n if (request.status >= 200 && request.status < 300) {\n isBlobType ? resolve(request.response) : resolve(parse(request));\n } else {\n reject(new Error(request.responseText));\n }\n };\n\n request.onreadystatechange = () => {\n if (request.readyState === 4) {\n if (request.status >= 200 && request.status < 300) {\n isBlobType ? resolve(request.response) : resolve(parse(request));\n }\n }\n };\n\n if (recognizerContextRef) {\n recognizerContextRef.idle = false;\n }\n if (apiVersion === 'V4') {\n request.send(JSON.stringify(data));\n } else {\n request.send(data ? transformRequest(data) : undefined);\n }\n }).then((res) => {\n if (recognizerContextRef) {\n recognizerContextRef.idle = true;\n }\n return res;\n });\n}\n\n/**\n * Get request\n * @param {RecognizerContext} recognizerContext Recognizer context\n * @param {String} url URL\n * @param {Object} params Query properties\n * @return {Promise}\n */\nexport function get(recognizerContext, url, params) {\n let queryUrl = url;\n if (params) {\n queryUrl += `?${transformRequest(params)}`;\n }\n return xhr('GET', queryUrl, undefined, recognizerContext);\n}\n\n/**\n * Post request\n * @param {RecognizerContext} recognizerContext Recognizer context\n * @param {String} url URL\n * @param {Object} data Data to be sent\n * @param {String} apiVersion api version\n * @param {String} mimeType MimeType to be used\n * @return {Promise}\n */\nexport function post(recognizerContext, url, data, apiVersion, mimeType) {\n return xhr('POST', url, data, recognizerContext, apiVersion, mimeType);\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/recognizer/rest/networkInterface.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 308, "kind": "function", "name": "parse", "memberof": "src/recognizer/rest/networkInterface.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/networkInterface.js~parse", "access": "public", "export": false, "importPath": "myscript/src/recognizer/rest/networkInterface.js", "importStyle": null, "description": "Parse JSON String to Object", "lineNumber": 9, "params": [ { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "req", "description": "JSON string result to be parsed" } ], "return": { "nullable": null, "types": [ "Object" ], "spread": false, "description": "Parsed response" }, "ignore": true }, { "__docId__": 309, "kind": "function", "name": "transformRequest", "memberof": "src/recognizer/rest/networkInterface.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/networkInterface.js~transformRequest", "access": "public", "export": false, "importPath": "myscript/src/recognizer/rest/networkInterface.js", "importStyle": null, "description": "Transform object data request to a list of parameters", "lineNumber": 24, "params": [ { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "obj", "description": "Query properties" } ], "return": { "nullable": null, "types": [ "String" ], "spread": false, "description": "URI encoded string" }, "ignore": true }, { "__docId__": 310, "kind": "function", "name": "xhr", "memberof": "src/recognizer/rest/networkInterface.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/networkInterface.js~xhr", "access": "public", "export": false, "importPath": "myscript/src/recognizer/rest/networkInterface.js", "importStyle": null, "description": "Send request to the network and return a promise", "lineNumber": 45, "params": [ { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "type", "description": "Request type (GET/POST)" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "url", "description": "URL" }, { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "data", "description": "Data to be sent" }, { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": true, "name": "recognizerContext", "description": "Recognizer context" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "apiVersion", "description": "api version" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "mimeType", "description": "MimeType to be used" } ], "return": { "nullable": null, "types": [ "Promise" ], "spread": false, "description": "" }, "ignore": true }, { "__docId__": 311, "kind": "function", "name": "get", "memberof": "src/recognizer/rest/networkInterface.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/networkInterface.js~get", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/networkInterface.js", "importStyle": "{get}", "description": "Get request", "lineNumber": 128, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Recognizer context" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "url", "description": "URL" }, { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "params", "description": "Query properties" } ], "return": { "nullable": null, "types": [ "Promise" ], "spread": false, "description": "" } }, { "__docId__": 312, "kind": "function", "name": "post", "memberof": "src/recognizer/rest/networkInterface.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/networkInterface.js~post", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/networkInterface.js", "importStyle": "{post}", "description": "Post request", "lineNumber": 145, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Recognizer context" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "url", "description": "URL" }, { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "data", "description": "Data to be sent" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "apiVersion", "description": "api version" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "mimeType", "description": "MimeType to be used" } ], "return": { "nullable": null, "types": [ "Promise" ], "spread": false, "description": "" } }, { "__docId__": 313, "kind": "file", "name": "src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js", "content": "/* eslint-disable no-underscore-dangle */\nimport { recognizerLogger as logger } from '../../../configuration/LoggerConfig';\nimport Constants from '../../../configuration/Constants';\nimport * as InkModel from '../../../model/InkModel';\nimport * as StrokeComponent from '../../../model/StrokeComponent';\nimport * as CryptoHelper from '../../CryptoHelper';\nimport * as Cdkv3RestRecognizerUtil from './Cdkv3RestRecognizerUtil';\nimport {\n extractShapeSymbols,\n getStyleFromInkRanges\n} from '../../common/v3/Cdkv3CommonShapeRecognizer';\n\nexport { init, close, clear, reset } from '../../DefaultRecognizer';\n\n/**\n * Recognizer configuration\n * @type {RecognizerInfo}\n */\nexport const analyzerRestV3Configuration = {\n types: [Constants.RecognitionType.ANALYZER],\n protocol: Constants.Protocol.REST,\n apiVersion: 'V3',\n availableTriggers: {\n exportContent: [\n Constants.Trigger.QUIET_PERIOD,\n Constants.Trigger.DEMAND\n ]\n }\n};\n\n/**\n * Get the configuration supported by this recognizer\n * @return {RecognizerInfo}\n */\nexport function getInfo() {\n return analyzerRestV3Configuration;\n}\n\n/**\n * Internal function to build the payload to ask for a recognition.\n * @param {RecognizerContext} recognizerContext\n * @param {Model} model\n * @return {Object}\n */\nfunction buildInput(recognizerContext, model) {\n const configuration = recognizerContext.editor.configuration;\n const input = {\n // Incremental\n components: model.rawStrokes.map(stroke => StrokeComponent.toJSON(stroke))\n };\n Object.assign(input, { parameter: configuration.recognitionParams.v3.analyzerParameter }); // Building the input with the suitable parameters\n\n logger.debug(`input.components size is ${input.components.length}`);\n\n const data = {\n instanceId: recognizerContext ? recognizerContext.instanceId : undefined,\n applicationKey: configuration.recognitionParams.server.applicationKey,\n analyzerInput: JSON.stringify(input)\n };\n\n if (configuration.recognitionParams.server.hmacKey) {\n data.hmac = CryptoHelper.computeHmac(data.analyzerInput, configuration.recognitionParams.server.applicationKey, configuration.recognitionParams.server.hmacKey);\n }\n InkModel.updateModelSentPosition(model);\n return data;\n}\n\nfunction extractSymbols(model, element) {\n const style = getStyleFromInkRanges(model, element.inkRanges);\n switch (element.elementType) {\n case 'table':\n return element.lines.map(line => Object.assign(line, style));\n case 'textLine':\n return [element].map(textLine => Object.assign(textLine, textLine.result.textSegmentResult.candidates[textLine.result.textSegmentResult.selectedCandidateIdx], style));\n case 'shape':\n return extractShapeSymbols(model, element).map(primitive => Object.assign(primitive, style));\n default:\n return [];\n }\n}\n\nfunction extractRecognizedSymbolsFromAnalyzerResult(model) {\n if (model.rawResults &&\n model.rawResults.exports &&\n model.rawResults.exports.result) {\n return [...model.rawResults.exports.result.shapes, ...model.rawResults.exports.result.tables, ...model.rawResults.exports.result.textLines]\n .map(element => extractSymbols(model, element))\n .reduce((a, b) => a.concat(b));\n }\n return [];\n}\n\n/**\n * Extract the exports\n * @param {Model} model Current model\n * @return {Object} exports\n */\nfunction extractExports(model) {\n if (model.rawResults &&\n model.rawResults.exports &&\n model.rawResults.exports.result) {\n return {\n ANALYSIS: model.rawResults.exports.result\n };\n }\n return {};\n}\n\nfunction resultCallback(model, res, callback) {\n logger.debug('Cdkv3RestAnalyzerRecognizer result callback', model);\n const modelReference = InkModel.updateModelReceivedPosition(model);\n modelReference.rawResults.exports = res;\n modelReference.recognizedSymbols = extractRecognizedSymbolsFromAnalyzerResult(model);\n modelReference.exports = extractExports(model);\n logger.debug('Cdkv3RestAnalyzerRecognizer model updated', modelReference);\n callback(undefined, modelReference, Constants.EventType.EXPORTED, Constants.EventType.CONVERTED, Constants.EventType.IDLE);\n}\n\n/**\n * Export content\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function export_(recognizerContext, model, callback) {\n return Cdkv3RestRecognizerUtil.postMessage('/api/v3.0/recognition/rest/analyzer/doSimpleRecognition.json', recognizerContext, model, buildInput)\n .then(res => resultCallback(model, res, callback))\n .catch(err => callback(err, model));\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 314, "kind": "variable", "name": "analyzerRestV3Configuration", "memberof": "src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js", "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js~analyzerRestV3Configuration", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js", "importStyle": "{analyzerRestV3Configuration}", "description": "Recognizer configuration", "lineNumber": 19, "type": { "nullable": null, "types": [ "RecognizerInfo" ], "spread": false, "description": null } }, { "__docId__": 315, "kind": "function", "name": "getInfo", "memberof": "src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js~getInfo", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js", "importStyle": "{getInfo}", "description": "Get the configuration supported by this recognizer", "lineNumber": 35, "return": { "nullable": null, "types": [ "RecognizerInfo" ], "spread": false, "description": "" }, "params": [] }, { "__docId__": 316, "kind": "function", "name": "buildInput", "memberof": "src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js~buildInput", "access": "public", "export": false, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js", "importStyle": null, "description": "Internal function to build the payload to ask for a recognition.", "lineNumber": 45, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" } ], "return": { "nullable": null, "types": [ "Object" ], "spread": false, "description": "" }, "ignore": true }, { "__docId__": 317, "kind": "function", "name": "extractSymbols", "memberof": "src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js~extractSymbols", "access": "public", "export": false, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js", "importStyle": null, "description": null, "lineNumber": 68, "undocument": true, "params": [ { "name": "model", "types": [ "*" ] }, { "name": "element", "types": [ "*" ] } ], "return": { "types": [ "*[]" ] }, "ignore": true }, { "__docId__": 318, "kind": "function", "name": "extractRecognizedSymbolsFromAnalyzerResult", "memberof": "src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js~extractRecognizedSymbolsFromAnalyzerResult", "access": "public", "export": false, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js", "importStyle": null, "description": null, "lineNumber": 82, "undocument": true, "params": [ { "name": "model", "types": [ "*" ] } ], "return": { "types": [ "*[]" ] }, "ignore": true }, { "__docId__": 319, "kind": "function", "name": "extractExports", "memberof": "src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js~extractExports", "access": "public", "export": false, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js", "importStyle": null, "description": "Extract the exports", "lineNumber": 98, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" } ], "return": { "nullable": null, "types": [ "Object" ], "spread": false, "description": "exports" }, "ignore": true }, { "__docId__": 320, "kind": "function", "name": "resultCallback", "memberof": "src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js~resultCallback", "access": "public", "export": false, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js", "importStyle": null, "description": null, "lineNumber": 109, "undocument": true, "params": [ { "name": "model", "types": [ "*" ] }, { "name": "res", "types": [ "*" ] }, { "name": "callback", "types": [ "*" ] } ], "return": null, "ignore": true }, { "__docId__": 321, "kind": "function", "name": "export_", "memberof": "src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js~export_", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestAnalyzerRecognizer.js", "importStyle": "{export_}", "description": "Export content", "lineNumber": 125, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": { "types": [ "*" ] } }, { "__docId__": 322, "kind": "file", "name": "src/recognizer/rest/v3/Cdkv3RestMathRecognizer.js", "content": "/* eslint-disable no-underscore-dangle */\nimport { recognizerLogger as logger } from '../../../configuration/LoggerConfig';\nimport Constants from '../../../configuration/Constants';\nimport * as InkModel from '../../../model/InkModel';\nimport * as StrokeComponent from '../../../model/StrokeComponent';\nimport * as CryptoHelper from '../../CryptoHelper';\nimport * as CdkCommonUtil from '../../common/CdkCommonUtil';\nimport * as Cdkv3RestRecognizerUtil from './Cdkv3RestRecognizerUtil';\nimport * as Cdkv3CommonMathRecognizer from '../../common/v3/Cdkv3CommonMathRecognizer';\n\nexport { init, close, clear, reset } from '../../DefaultRecognizer';\n\n/**\n * Recognizer configuration\n * @type {RecognizerInfo}\n */\nexport const mathRestV3Configuration = {\n types: [Constants.RecognitionType.MATH],\n protocol: Constants.Protocol.REST,\n apiVersion: 'V3',\n availableTriggers: {\n exportContent: [\n Constants.Trigger.QUIET_PERIOD,\n Constants.Trigger.DEMAND\n ]\n }\n};\n\n/**\n * Get the configuration supported by this recognizer\n * @return {RecognizerInfo}\n */\nexport function getInfo() {\n return mathRestV3Configuration;\n}\n\n/**\n * Internal function to build the payload to ask for a recognition.\n * @param {RecognizerContext} recognizerContext\n * @param {Model} model\n * @return {Object}\n */\nfunction buildInput(recognizerContext, model) {\n const configuration = recognizerContext.editor.configuration;\n const input = {\n // As Rest MATH recognition is non incremental we add the already recognized strokes\n components: model.rawStrokes.map(stroke => StrokeComponent.toJSON(stroke))\n };\n Object.assign(input, configuration.recognitionParams.v3.mathParameter); // Building the input with the suitable parameters\n\n logger.debug(`input.components size is ${input.components.length}`);\n\n const data = {\n instanceId: recognizerContext ? recognizerContext.instanceId : undefined,\n applicationKey: configuration.recognitionParams.server.applicationKey,\n mathInput: JSON.stringify(input)\n };\n\n if (configuration.recognitionParams.server.hmacKey) {\n data.hmac = CryptoHelper.computeHmac(data.mathInput, configuration.recognitionParams.server.applicationKey, configuration.recognitionParams.server.hmacKey);\n }\n InkModel.updateModelSentPosition(model);\n return data;\n}\n\nfunction resultCallback(model, res, callback) {\n logger.debug('Cdkv3RestMathRecognizer result callback', model);\n const modelReference = InkModel.updateModelReceivedPosition(model);\n modelReference.rawResults.exports = res;\n modelReference.recognizedSymbols = Cdkv3CommonMathRecognizer.extractRecognizedSymbols(model);\n modelReference.exports = CdkCommonUtil.extractExports(model);\n logger.debug('Cdkv3RestMathRecognizer model updated', modelReference);\n callback(undefined, modelReference, Constants.EventType.EXPORTED, Constants.EventType.IDLE);\n}\n\n/**\n * Export content\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function export_(recognizerContext, model, callback) {\n return Cdkv3RestRecognizerUtil.postMessage('/api/v3.0/recognition/rest/math/doSimpleRecognition.json', recognizerContext, model, buildInput)\n .then(res => resultCallback(model, res, callback))\n .catch(err => callback(err, model));\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/recognizer/rest/v3/Cdkv3RestMathRecognizer.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 323, "kind": "variable", "name": "mathRestV3Configuration", "memberof": "src/recognizer/rest/v3/Cdkv3RestMathRecognizer.js", "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestMathRecognizer.js~mathRestV3Configuration", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestMathRecognizer.js", "importStyle": "{mathRestV3Configuration}", "description": "Recognizer configuration", "lineNumber": 17, "type": { "nullable": null, "types": [ "RecognizerInfo" ], "spread": false, "description": null } }, { "__docId__": 324, "kind": "function", "name": "getInfo", "memberof": "src/recognizer/rest/v3/Cdkv3RestMathRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestMathRecognizer.js~getInfo", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestMathRecognizer.js", "importStyle": "{getInfo}", "description": "Get the configuration supported by this recognizer", "lineNumber": 33, "return": { "nullable": null, "types": [ "RecognizerInfo" ], "spread": false, "description": "" }, "params": [] }, { "__docId__": 325, "kind": "function", "name": "buildInput", "memberof": "src/recognizer/rest/v3/Cdkv3RestMathRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestMathRecognizer.js~buildInput", "access": "public", "export": false, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestMathRecognizer.js", "importStyle": null, "description": "Internal function to build the payload to ask for a recognition.", "lineNumber": 43, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" } ], "return": { "nullable": null, "types": [ "Object" ], "spread": false, "description": "" }, "ignore": true }, { "__docId__": 326, "kind": "function", "name": "resultCallback", "memberof": "src/recognizer/rest/v3/Cdkv3RestMathRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestMathRecognizer.js~resultCallback", "access": "public", "export": false, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestMathRecognizer.js", "importStyle": null, "description": null, "lineNumber": 66, "undocument": true, "params": [ { "name": "model", "types": [ "*" ] }, { "name": "res", "types": [ "*" ] }, { "name": "callback", "types": [ "*" ] } ], "return": null, "ignore": true }, { "__docId__": 327, "kind": "function", "name": "export_", "memberof": "src/recognizer/rest/v3/Cdkv3RestMathRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestMathRecognizer.js~export_", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestMathRecognizer.js", "importStyle": "{export_}", "description": "Export content", "lineNumber": 82, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": { "types": [ "*" ] } }, { "__docId__": 328, "kind": "file", "name": "src/recognizer/rest/v3/Cdkv3RestMusicRecognizer.js", "content": "/* eslint-disable no-underscore-dangle */\nimport { recognizerLogger as logger } from '../../../configuration/LoggerConfig';\nimport Constants from '../../../configuration/Constants';\nimport * as InkModel from '../../../model/InkModel';\nimport * as RecognizerContext from '../../../model/RecognizerContext';\nimport * as StrokeComponent from '../../../model/StrokeComponent';\nimport * as CryptoHelper from '../../CryptoHelper';\nimport * as CdkCommonUtil from '../../common/CdkCommonUtil';\nimport * as Cdkv3RestRecognizerUtil from './Cdkv3RestRecognizerUtil';\n\nexport { close, clear, reset } from '../../DefaultRecognizer';\n\n/**\n * Recognizer configuration\n * @type {RecognizerInfo}\n */\nexport const musicRestV3Configuration = {\n types: [Constants.RecognitionType.MUSIC],\n protocol: Constants.Protocol.REST,\n apiVersion: 'V3',\n availableTriggers: {\n exportContent: [\n Constants.Trigger.QUIET_PERIOD,\n Constants.Trigger.DEMAND\n ]\n }\n};\n\n/**\n * Get the configuration supported by this recognizer\n * @return {RecognizerInfo}\n */\nexport function getInfo() {\n return musicRestV3Configuration;\n}\n\n/**\n * Internal function to build the payload to ask for a recognition.\n * @param {RecognizerContext} recognizerContext\n * @param {Model} model\n * @return {Object}\n */\nfunction buildInput(recognizerContext, model) {\n const configuration = recognizerContext.editor.configuration;\n const input = {\n // As Rest MUSIC recognition is non incremental wa add the already recognized strokes\n components: []\n .concat(model.defaultSymbols, model.rawStrokes)\n .filter(symbol => symbol.type !== 'staff')\n .map((symbol) => {\n if (symbol.type === 'stroke') {\n return StrokeComponent.toJSON(symbol);\n }\n return symbol;\n })\n };\n const musicParameter = Object.assign({}, configuration.recognitionParams.v3.musicParameter);\n delete musicParameter.clef; // FIXME find a way to avoid this ugly hack\n Object.assign(input, musicParameter); // Building the input with the suitable parameters\n\n logger.debug(`input.components size is ${input.components.length}`);\n\n const data = {\n instanceId: recognizerContext ? recognizerContext.instanceId : undefined,\n applicationKey: configuration.recognitionParams.server.applicationKey,\n musicInput: JSON.stringify(input)\n };\n\n if (configuration.recognitionParams.server.hmacKey) {\n data.hmac = CryptoHelper.computeHmac(data.musicInput, configuration.recognitionParams.server.applicationKey, configuration.recognitionParams.server.hmacKey);\n }\n InkModel.updateModelSentPosition(model);\n return data;\n}\n\nfunction resultCallback(model, res, callback) {\n logger.debug('Cdkv3RestMusicRecognizer result callback', model);\n const modelReference = InkModel.updateModelReceivedPosition(model);\n modelReference.rawResults.exports = res;\n modelReference.exports = CdkCommonUtil.extractExports(model);\n logger.debug('Cdkv3RestMusicRecognizer model updated', modelReference);\n callback(undefined, modelReference, Constants.EventType.EXPORTED, Constants.EventType.IDLE);\n}\n\n/**\n * Initialize recognition\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function init(recognizerContext, model, callback) {\n const modelRef = InkModel.resetModelPositions(model);\n logger.debug('Updated model', modelRef);\n const recognizerContextRef = RecognizerContext.updateRecognitionPositions(recognizerContext, modelRef.lastPositions);\n recognizerContextRef.initPromise = Promise.resolve(modelRef);\n recognizerContextRef.initPromise\n .then((res) => {\n recognizerContextRef.initialized = true;\n logger.debug('Updated recognizer context', recognizerContextRef);\n callback(undefined, res, Constants.EventType.LOADED, Constants.EventType.RENDERED);\n });\n}\n\n/**\n * Export content\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function export_(recognizerContext, model, callback) {\n Cdkv3RestRecognizerUtil.postMessage('/api/v3.0/recognition/rest/music/doSimpleRecognition.json', recognizerContext, model, buildInput)\n .then(res => resultCallback(model, res, callback))\n .catch(err => callback(err, model));\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/recognizer/rest/v3/Cdkv3RestMusicRecognizer.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 329, "kind": "variable", "name": "musicRestV3Configuration", "memberof": "src/recognizer/rest/v3/Cdkv3RestMusicRecognizer.js", "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestMusicRecognizer.js~musicRestV3Configuration", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestMusicRecognizer.js", "importStyle": "{musicRestV3Configuration}", "description": "Recognizer configuration", "lineNumber": 17, "type": { "nullable": null, "types": [ "RecognizerInfo" ], "spread": false, "description": null } }, { "__docId__": 330, "kind": "function", "name": "getInfo", "memberof": "src/recognizer/rest/v3/Cdkv3RestMusicRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestMusicRecognizer.js~getInfo", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestMusicRecognizer.js", "importStyle": "{getInfo}", "description": "Get the configuration supported by this recognizer", "lineNumber": 33, "return": { "nullable": null, "types": [ "RecognizerInfo" ], "spread": false, "description": "" }, "params": [] }, { "__docId__": 331, "kind": "function", "name": "buildInput", "memberof": "src/recognizer/rest/v3/Cdkv3RestMusicRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestMusicRecognizer.js~buildInput", "access": "public", "export": false, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestMusicRecognizer.js", "importStyle": null, "description": "Internal function to build the payload to ask for a recognition.", "lineNumber": 43, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" } ], "return": { "nullable": null, "types": [ "Object" ], "spread": false, "description": "" }, "ignore": true }, { "__docId__": 332, "kind": "function", "name": "resultCallback", "memberof": "src/recognizer/rest/v3/Cdkv3RestMusicRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestMusicRecognizer.js~resultCallback", "access": "public", "export": false, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestMusicRecognizer.js", "importStyle": null, "description": null, "lineNumber": 76, "undocument": true, "params": [ { "name": "model", "types": [ "*" ] }, { "name": "res", "types": [ "*" ] }, { "name": "callback", "types": [ "*" ] } ], "return": null, "ignore": true }, { "__docId__": 333, "kind": "function", "name": "init", "memberof": "src/recognizer/rest/v3/Cdkv3RestMusicRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestMusicRecognizer.js~init", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestMusicRecognizer.js", "importStyle": "{init}", "description": "Initialize recognition", "lineNumber": 91, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 334, "kind": "function", "name": "export_", "memberof": "src/recognizer/rest/v3/Cdkv3RestMusicRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestMusicRecognizer.js~export_", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestMusicRecognizer.js", "importStyle": "{export_}", "description": "Export content", "lineNumber": 110, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 335, "kind": "file", "name": "src/recognizer/rest/v3/Cdkv3RestRecognizerUtil.js", "content": "import { recognizerLogger as logger } from '../../../configuration/LoggerConfig';\nimport * as NetworkInterface from '../networkInterface';\nimport * as InkModel from '../../../model/InkModel';\nimport * as RecognizerContext from '../../../model/RecognizerContext';\n\n/**\n * @param {String} suffixUrl\n * @param {RecognizerContext} recognizerContext\n * @param {Model} model\n * @param {function(recognizerContext: RecognizerContext, model: Model): Object} buildMessage\n * @return {Promise.} Promise that return an updated model as a result\n */\nexport function postMessage(suffixUrl, recognizerContext, model, buildMessage) {\n const configuration = recognizerContext.editor.configuration;\n return NetworkInterface.post(recognizerContext, `${configuration.recognitionParams.server.scheme}://${configuration.recognitionParams.server.host}${suffixUrl}`, buildMessage(recognizerContext, model), 'V3')\n .then(\n (response) => {\n logger.debug('Cdkv3RestRecognizer success', response);\n const positions = recognizerContext.lastPositions;\n positions.lastReceivedPosition = positions.lastSentPosition;\n const recognizerContextReference = RecognizerContext.updateRecognitionPositions(recognizerContext, positions);\n if (response.instanceId) {\n recognizerContextReference.instanceId = response.instanceId;\n }\n return response;\n }\n );\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/recognizer/rest/v3/Cdkv3RestRecognizerUtil.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 336, "kind": "function", "name": "postMessage", "memberof": "src/recognizer/rest/v3/Cdkv3RestRecognizerUtil.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestRecognizerUtil.js~postMessage", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestRecognizerUtil.js", "importStyle": "{postMessage}", "description": "", "lineNumber": 13, "params": [ { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "suffixUrl", "description": "" }, { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" }, { "nullable": null, "types": [ "function(recognizerContext: RecognizerContext, model: Model): Object" ], "spread": false, "optional": false, "name": "buildMessage", "description": "" } ], "return": { "nullable": null, "types": [ "Promise." ], "spread": false, "description": "Promise that return an updated model as a result" } }, { "__docId__": 337, "kind": "file", "name": "src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js", "content": "/* eslint-disable no-underscore-dangle */\nimport { recognizerLogger as logger } from '../../../configuration/LoggerConfig';\nimport Constants from '../../../configuration/Constants';\nimport * as InkModel from '../../../model/InkModel';\nimport * as StrokeComponent from '../../../model/StrokeComponent';\nimport * as CryptoHelper from '../../CryptoHelper';\nimport * as RecognizerContext from '../../../model/RecognizerContext';\nimport * as Cdkv3RestRecognizerUtil from './Cdkv3RestRecognizerUtil';\nimport * as Cdkv3CommonShapeRecognizer from '../../common/v3/Cdkv3CommonShapeRecognizer';\n\nexport { init, close } from '../../DefaultRecognizer';\n\n/**\n * Recognizer configuration\n * @type {RecognizerInfo}\n */\nexport const shapeRestV3Configuration = {\n types: [Constants.RecognitionType.SHAPE],\n protocol: Constants.Protocol.REST,\n apiVersion: 'V3',\n availableTriggers: {\n exportContent: [\n Constants.Trigger.QUIET_PERIOD,\n Constants.Trigger.DEMAND\n ]\n }\n};\n\n/**\n * Get the configuration supported by this recognizer\n * @return {RecognizerInfo}\n */\nexport function getInfo() {\n return shapeRestV3Configuration;\n}\n\n/**\n * Internal function to build the payload to ask for a recognition.\n * @param {RecognizerContext} recognizerContext\n * @param {Model} model\n * @return {Object}\n */\nfunction buildInput(recognizerContext, model) {\n const configuration = recognizerContext.editor.configuration;\n const input = {\n components: InkModel.extractPendingStrokes(model).map(stroke => StrokeComponent.toJSON(stroke))\n };\n Object.assign(input, configuration.recognitionParams.v3.shapeParameter); // Building the input with the suitable parameters\n\n logger.debug(`input.components size is ${input.components.length}`);\n\n const data = {\n instanceId: recognizerContext ? recognizerContext.instanceId : undefined,\n applicationKey: configuration.recognitionParams.server.applicationKey,\n shapeInput: JSON.stringify(input)\n };\n\n if (configuration.recognitionParams.server.hmacKey) {\n data.hmac = CryptoHelper.computeHmac(data.shapeInput, configuration.recognitionParams.server.applicationKey, configuration.recognitionParams.server.hmacKey);\n }\n InkModel.updateModelSentPosition(model);\n return data;\n}\n\nfunction buildReset(recognizerContext, model) {\n return {\n instanceSessionId: recognizerContext ? recognizerContext.instanceId : undefined\n };\n}\n\nfunction resultCallback(model, res, callback) {\n logger.debug('Cdkv3RestShapeRecognizer result callback', model);\n const modelReference = InkModel.updateModelReceivedPosition(model);\n modelReference.rawResults.exports = res;\n modelReference.recognizedSymbols = Cdkv3CommonShapeRecognizer.extractRecognizedSymbols(model);\n modelReference.exports = Cdkv3CommonShapeRecognizer.extractExports(model);\n logger.debug('Cdkv3RestShapeRecognizer model updated', modelReference);\n callback(undefined, modelReference, Constants.EventType.EXPORTED, Constants.EventType.CONVERTED, Constants.EventType.IDLE);\n}\n\n/**\n * Export content\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function export_(recognizerContext, model, callback) {\n Cdkv3RestRecognizerUtil.postMessage('/api/v3.0/recognition/rest/shape/doSimpleRecognition.json', recognizerContext, model, buildInput)\n .then(res => resultCallback(model, res, callback))\n .catch(err => callback(err, model));\n}\n\n/**\n * Reset server context.\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function reset(recognizerContext, model, callback) {\n const modelRef = InkModel.resetModelPositions(model);\n Cdkv3RestRecognizerUtil.postMessage('/api/v3.0/recognition/rest/shape/clearSessionId.json', recognizerContext, modelRef, buildReset)\n .then(res => callback(undefined, modelRef, Constants.EventType.IDLE))\n .catch(err => callback(err, modelRef));\n}\n\n/**\n * Do what is needed to clean the server context.\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function clear(recognizerContext, model, callback) {\n const modelRef = InkModel.clearModel(InkModel.cloneModel(model));\n Cdkv3RestRecognizerUtil.postMessage('/api/v3.0/recognition/rest/shape/clearSessionId.json', recognizerContext, modelRef, buildReset)\n .then(res => callback(undefined, modelRef, Constants.EventType.CHANGED, Constants.EventType.EXPORTED, Constants.EventType.CONVERTED, Constants.EventType.IDLE))\n .catch(err => callback(err, modelRef));\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 338, "kind": "variable", "name": "shapeRestV3Configuration", "memberof": "src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js", "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js~shapeRestV3Configuration", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js", "importStyle": "{shapeRestV3Configuration}", "description": "Recognizer configuration", "lineNumber": 17, "type": { "nullable": null, "types": [ "RecognizerInfo" ], "spread": false, "description": null } }, { "__docId__": 339, "kind": "function", "name": "getInfo", "memberof": "src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js~getInfo", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js", "importStyle": "{getInfo}", "description": "Get the configuration supported by this recognizer", "lineNumber": 33, "return": { "nullable": null, "types": [ "RecognizerInfo" ], "spread": false, "description": "" }, "params": [] }, { "__docId__": 340, "kind": "function", "name": "buildInput", "memberof": "src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js~buildInput", "access": "public", "export": false, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js", "importStyle": null, "description": "Internal function to build the payload to ask for a recognition.", "lineNumber": 43, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" } ], "return": { "nullable": null, "types": [ "Object" ], "spread": false, "description": "" }, "ignore": true }, { "__docId__": 341, "kind": "function", "name": "buildReset", "memberof": "src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js~buildReset", "access": "public", "export": false, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js", "importStyle": null, "description": null, "lineNumber": 65, "undocument": true, "params": [ { "name": "recognizerContext", "types": [ "*" ] }, { "name": "model", "types": [ "*" ] } ], "return": { "types": [ "{\"instanceSessionId\": *}" ] }, "ignore": true }, { "__docId__": 342, "kind": "function", "name": "resultCallback", "memberof": "src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js~resultCallback", "access": "public", "export": false, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js", "importStyle": null, "description": null, "lineNumber": 71, "undocument": true, "params": [ { "name": "model", "types": [ "*" ] }, { "name": "res", "types": [ "*" ] }, { "name": "callback", "types": [ "*" ] } ], "return": null, "ignore": true }, { "__docId__": 343, "kind": "function", "name": "export_", "memberof": "src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js~export_", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js", "importStyle": "{export_}", "description": "Export content", "lineNumber": 87, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 344, "kind": "function", "name": "reset", "memberof": "src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js~reset", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js", "importStyle": "{reset}", "description": "Reset server context.", "lineNumber": 99, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 345, "kind": "function", "name": "clear", "memberof": "src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js~clear", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestShapeRecognizer.js", "importStyle": "{clear}", "description": "Do what is needed to clean the server context.", "lineNumber": 112, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 346, "kind": "file", "name": "src/recognizer/rest/v3/Cdkv3RestTextRecognizer.js", "content": "/* eslint-disable no-underscore-dangle */\nimport { recognizerLogger as logger } from '../../../configuration/LoggerConfig';\nimport Constants from '../../../configuration/Constants';\nimport * as InkModel from '../../../model/InkModel';\nimport * as StrokeComponent from '../../../model/StrokeComponent';\nimport * as CryptoHelper from '../../CryptoHelper';\nimport * as Cdkv3RestRecognizerUtil from './Cdkv3RestRecognizerUtil';\nimport * as Cdkv3CommonTextRecognizer from '../../common/v3/Cdkv3CommonTextRecognizer';\n\nexport { init, close, clear, reset } from '../../DefaultRecognizer';\n\n/**\n * Recognizer configuration\n * @type {RecognizerInfo}\n */\nexport const textRestV3Configuration = {\n types: [Constants.RecognitionType.TEXT],\n protocol: Constants.Protocol.REST,\n apiVersion: 'V3',\n availableTriggers: {\n exportContent: [\n Constants.Trigger.QUIET_PERIOD,\n Constants.Trigger.DEMAND\n ]\n }\n};\n\n/**\n * Get the configuration supported by this recognizer\n * @return {RecognizerInfo}\n */\nexport function getInfo() {\n return textRestV3Configuration;\n}\n\n/**\n * Internal function to build the payload to ask for a recognition.\n * @param {RecognizerContext} recognizerContext\n * @param {Model} model\n * @return {Object}\n */\nexport function buildInput(recognizerContext, model) {\n const configuration = recognizerContext.editor.configuration;\n const input = {\n inputUnits: [{\n textInputType: 'MULTI_LINE_TEXT',\n // As Rest TEXT recognition is non incremental wa add the already recognized strokes\n components: model.rawStrokes.map(stroke => StrokeComponent.toJSON(stroke))\n }]\n };\n Object.assign(input, { textParameter: configuration.recognitionParams.v3.textParameter }); // Building the input with the suitable parameters\n\n logger.debug(`input.inputUnits[0].components size is ${input.inputUnits[0].components.length}`);\n\n const data = {\n instanceId: recognizerContext ? recognizerContext.instanceId : undefined,\n applicationKey: configuration.recognitionParams.server.applicationKey,\n textInput: JSON.stringify(input)\n };\n\n if (configuration.recognitionParams.server.hmacKey) {\n data.hmac = CryptoHelper.computeHmac(data.textInput, configuration.recognitionParams.server.applicationKey, configuration.recognitionParams.server.hmacKey);\n }\n InkModel.updateModelSentPosition(model);\n return data;\n}\n\nfunction resultCallback(model, res, callback) {\n logger.debug('Cdkv3RestTextRecognizer result callback', model);\n const modelReference = InkModel.updateModelReceivedPosition(model);\n modelReference.rawResults.exports = res;\n modelReference.exports = Cdkv3CommonTextRecognizer.extractExports(model);\n logger.debug('Cdkv3RestTextRecognizer model updated', modelReference);\n callback(undefined, modelReference, Constants.EventType.EXPORTED, Constants.EventType.IDLE);\n}\n\n/**\n * Export content\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function export_(recognizerContext, model, callback) {\n Cdkv3RestRecognizerUtil.postMessage('/api/v3.0/recognition/rest/text/doSimpleRecognition.json', recognizerContext, model, buildInput)\n .then(res => resultCallback(model, res, callback))\n .catch(err => callback(err, model));\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/recognizer/rest/v3/Cdkv3RestTextRecognizer.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 347, "kind": "variable", "name": "textRestV3Configuration", "memberof": "src/recognizer/rest/v3/Cdkv3RestTextRecognizer.js", "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestTextRecognizer.js~textRestV3Configuration", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestTextRecognizer.js", "importStyle": "{textRestV3Configuration}", "description": "Recognizer configuration", "lineNumber": 16, "type": { "nullable": null, "types": [ "RecognizerInfo" ], "spread": false, "description": null } }, { "__docId__": 348, "kind": "function", "name": "getInfo", "memberof": "src/recognizer/rest/v3/Cdkv3RestTextRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestTextRecognizer.js~getInfo", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestTextRecognizer.js", "importStyle": "{getInfo}", "description": "Get the configuration supported by this recognizer", "lineNumber": 32, "return": { "nullable": null, "types": [ "RecognizerInfo" ], "spread": false, "description": "" }, "params": [] }, { "__docId__": 349, "kind": "function", "name": "buildInput", "memberof": "src/recognizer/rest/v3/Cdkv3RestTextRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestTextRecognizer.js~buildInput", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestTextRecognizer.js", "importStyle": "{buildInput}", "description": "Internal function to build the payload to ask for a recognition.", "lineNumber": 42, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" } ], "return": { "nullable": null, "types": [ "Object" ], "spread": false, "description": "" } }, { "__docId__": 350, "kind": "function", "name": "resultCallback", "memberof": "src/recognizer/rest/v3/Cdkv3RestTextRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestTextRecognizer.js~resultCallback", "access": "public", "export": false, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestTextRecognizer.js", "importStyle": null, "description": null, "lineNumber": 68, "undocument": true, "params": [ { "name": "model", "types": [ "*" ] }, { "name": "res", "types": [ "*" ] }, { "name": "callback", "types": [ "*" ] } ], "return": null, "ignore": true }, { "__docId__": 351, "kind": "function", "name": "export_", "memberof": "src/recognizer/rest/v3/Cdkv3RestTextRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v3/Cdkv3RestTextRecognizer.js~export_", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/v3/Cdkv3RestTextRecognizer.js", "importStyle": "{export_}", "description": "Export content", "lineNumber": 83, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 352, "kind": "file", "name": "src/recognizer/rest/v4/iinkRestRecognizer.js", "content": "/* eslint-disable no-underscore-dangle */\nimport * as NetworkInterface from '../networkInterface';\nimport * as RecognizerContext from '../../../model/RecognizerContext';\nimport { recognizerLogger as logger } from '../../../configuration/LoggerConfig';\nimport Constants from '../../../configuration/Constants';\nimport * as InkModel from '../../../model/InkModel';\nimport * as StrokeComponent from '../../../model/StrokeComponent';\nimport * as DefaultTheme from '../../../configuration/DefaultTheme';\nimport * as DefaultPenStyle from '../../../configuration/DefaultPenStyle';\n\nexport { init, close, clear, reset } from '../../DefaultRecognizer';\n\n/**\n * Recognizer configuration\n * @type {RecognizerInfo}\n */\nexport const iinkRestConfiguration = {\n types: [Constants.RecognitionType.TEXT, Constants.RecognitionType.DIAGRAM, Constants.RecognitionType.MATH, Constants.RecognitionType.RAWCONTENT],\n protocol: Constants.Protocol.REST,\n apiVersion: 'V4',\n availableTriggers: {\n exportContent: [\n Constants.Trigger.QUIET_PERIOD,\n Constants.Trigger.DEMAND\n ]\n }\n};\n\n/**\n * Get the configuration supported by this recognizer\n * @return {RecognizerInfo}\n */\nexport function getInfo() {\n return iinkRestConfiguration;\n}\n\n\n/**\n * @param {String} suffixUrl\n * @param {RecognizerContext} recognizerContext\n * @param {Model} model\n * @param {function(recognizerContext: RecognizerContext, model: Model, conversionState: String): Object} buildMessage\n * @param {String} conversionState\n * @param {String} mimeType\n * @return {Promise.} Promise that return an updated model as a result\n */\nexport function postMessage(suffixUrl, recognizerContext, model, buildMessage, conversionState = '', mimeType) {\n const configuration = recognizerContext.editor.configuration;\n return NetworkInterface.post(recognizerContext, `${configuration.recognitionParams.server.scheme}://${configuration.recognitionParams.server.host}${suffixUrl}`, buildMessage(recognizerContext, model, conversionState), 'V4', mimeType)\n .then((response) => {\n logger.debug('iinkRestRecognizer success', response);\n const positions = recognizerContext.lastPositions;\n positions.lastReceivedPosition = positions.lastSentPosition;\n const recognizerContextReference = RecognizerContext.updateRecognitionPositions(recognizerContext, positions);\n if (response.instanceId) {\n recognizerContextReference.instanceId = response.instanceId;\n }\n return response;\n });\n}\n\nfunction buildTextConf(configuration) {\n return {\n text: configuration.recognitionParams.v4.text,\n lang: configuration.recognitionParams.v4.lang,\n export: configuration.recognitionParams.v4.export\n };\n}\n\nfunction buildMathConf(configuration) {\n return {\n math: configuration.recognitionParams.v4.math,\n lang: configuration.recognitionParams.v4.lang,\n export: configuration.recognitionParams.v4.export\n };\n}\n\nfunction buildDiagramConf(configuration) {\n return {\n diagram: configuration.recognitionParams.v4.diagram,\n lang: configuration.recognitionParams.v4.lang,\n export: configuration.recognitionParams.v4.export\n };\n}\n\nfunction buildRawContentConf(configuration) {\n return {\n 'raw-content': {\n recognition: configuration.recognitionParams.v4['raw-content'].recognition\n },\n lang: configuration.recognitionParams.v4.lang,\n export: configuration.recognitionParams.v4.export\n };\n}\n\nfunction buildData(recognizerContext, model, conversionState) {\n const configuration = recognizerContext.editor.configuration;\n let dataConf;\n\n if (configuration.recognitionParams.type === 'TEXT') {\n dataConf = buildTextConf(configuration);\n } else if (configuration.recognitionParams.type === 'MATH') {\n dataConf = buildMathConf(configuration);\n } else if (configuration.recognitionParams.type === 'DIAGRAM') {\n dataConf = buildDiagramConf(configuration);\n } else if (configuration.recognitionParams.type === 'Raw Content') {\n dataConf = buildRawContentConf(configuration);\n }\n\n const newStrokes = [];\n model.strokeGroups.forEach((group) => {\n const newPenStyle = JSON.stringify(group.penStyle) === '{}' ? null : DefaultPenStyle.toCSS(group.penStyle);\n const newGroup = {\n penStyle: newPenStyle,\n strokes: group.strokes.map(stroke => StrokeComponent.toJSONV4(stroke))\n };\n newStrokes.push(newGroup);\n });\n\n const contentType = configuration.recognitionParams.type === 'Raw Content' ? 'Raw Content' : configuration.recognitionParams.type.charAt(0)\n .toUpperCase() + configuration.recognitionParams.type.slice(1)\n .toLowerCase();\n\n const data = {\n configuration: dataConf,\n xDPI: 96,\n yDPI: 96,\n contentType,\n theme: DefaultTheme.toCSS(recognizerContext.editor.theme),\n strokeGroups: newStrokes\n };\n\n if (recognizerContext.editor.domElement) {\n data.height = recognizerContext.editor.domElement.clientHeight;\n data.width = recognizerContext.editor.domElement.clientWidth;\n }\n\n if (conversionState) {\n data.conversionState = 'DIGITAL_EDIT';\n }\n\n InkModel.updateModelSentPosition(model);\n return data;\n}\n\nfunction extractExports(configuration, mimeType, res) {\n const exports = {};\n exports[mimeType] = res;\n return exports;\n}\n\nfunction resultCallback(model, configuration, res, mimeType, callback) {\n logger.debug('iinkRestRecognizer result callback', model);\n const modelReference = InkModel.updateModelReceivedPosition(model);\n modelReference.rawResults.exports = res;\n if (modelReference.exports) {\n Object.assign(modelReference.exports, extractExports(configuration, mimeType, res));\n } else {\n modelReference.exports = extractExports(configuration, mimeType, res);\n }\n logger.debug('iinkRestRecognizer model updated', modelReference);\n callback(undefined, modelReference, Constants.EventType.EXPORTED, Constants.EventType.IDLE);\n}\n\n/**\n * Export content\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n * @param {Array[String]} requestedMimeTypes\n */\nexport function export_(recognizerContext, model, callback, requestedMimeTypes) {\n const configuration = recognizerContext.editor.configuration;\n\n function callPostMessage(mimeType) {\n postMessage('/api/v4.0/iink/batch', recognizerContext, model, buildData, configuration.restConversionState, mimeType)\n .then((res) => {\n resultCallback(model, configuration, res, mimeType, callback);\n })\n .catch((err) => {\n callback(err, model);\n });\n }\n\n if (requestedMimeTypes) {\n requestedMimeTypes.forEach((mimeType) => {\n callPostMessage(mimeType);\n });\n } else if (configuration.recognitionParams.type === 'TEXT') {\n configuration.recognitionParams.v4.text.mimeTypes.forEach((mimeType) => {\n callPostMessage(mimeType);\n });\n } else if (configuration.recognitionParams.type === 'DIAGRAM') {\n configuration.recognitionParams.v4.diagram.mimeTypes.forEach((mimeType) => {\n callPostMessage(mimeType);\n });\n } else if (configuration.recognitionParams.type === 'MATH') {\n configuration.recognitionParams.v4.math.mimeTypes.forEach((mimeType) => {\n callPostMessage(mimeType);\n });\n } else if (configuration.recognitionParams.type === 'Raw Content') {\n configuration.recognitionParams.v4['raw-content'].mimeTypes.forEach((mimeType) => {\n callPostMessage(mimeType);\n });\n }\n}\n\n/**\n * Ask for conversion using DIGITAL_EDIT\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function convert(recognizerContext, model, callback) {\n const configuration = recognizerContext.editor.configuration;\n postMessage('/api/v4.0/iink/batch', recognizerContext, model, buildData, 'DIGITAL_EDIT')\n .then(res => resultCallback(model, configuration, res, callback))\n .catch(err => callback(err, model));\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/recognizer/rest/v4/iinkRestRecognizer.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 353, "kind": "variable", "name": "iinkRestConfiguration", "memberof": "src/recognizer/rest/v4/iinkRestRecognizer.js", "static": true, "longname": "src/recognizer/rest/v4/iinkRestRecognizer.js~iinkRestConfiguration", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/v4/iinkRestRecognizer.js", "importStyle": "{iinkRestConfiguration}", "description": "Recognizer configuration", "lineNumber": 17, "type": { "nullable": null, "types": [ "RecognizerInfo" ], "spread": false, "description": null } }, { "__docId__": 354, "kind": "function", "name": "getInfo", "memberof": "src/recognizer/rest/v4/iinkRestRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v4/iinkRestRecognizer.js~getInfo", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/v4/iinkRestRecognizer.js", "importStyle": "{getInfo}", "description": "Get the configuration supported by this recognizer", "lineNumber": 33, "return": { "nullable": null, "types": [ "RecognizerInfo" ], "spread": false, "description": "" }, "params": [] }, { "__docId__": 355, "kind": "function", "name": "postMessage", "memberof": "src/recognizer/rest/v4/iinkRestRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v4/iinkRestRecognizer.js~postMessage", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/v4/iinkRestRecognizer.js", "importStyle": "{postMessage}", "description": "", "lineNumber": 47, "params": [ { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "suffixUrl", "description": "" }, { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" }, { "nullable": null, "types": [ "function(recognizerContext: RecognizerContext, model: Model, conversionState: String): Object" ], "spread": false, "optional": false, "name": "buildMessage", "description": "" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "conversionState", "description": "" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "mimeType", "description": "" } ], "return": { "nullable": null, "types": [ "Promise." ], "spread": false, "description": "Promise that return an updated model as a result" } }, { "__docId__": 356, "kind": "function", "name": "buildTextConf", "memberof": "src/recognizer/rest/v4/iinkRestRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v4/iinkRestRecognizer.js~buildTextConf", "access": "public", "export": false, "importPath": "myscript/src/recognizer/rest/v4/iinkRestRecognizer.js", "importStyle": null, "description": null, "lineNumber": 62, "undocument": true, "params": [ { "name": "configuration", "types": [ "*" ] } ], "return": { "types": [ "{\"text\": *, \"lang\": *, \"export\": *}" ] }, "ignore": true }, { "__docId__": 357, "kind": "function", "name": "buildMathConf", "memberof": "src/recognizer/rest/v4/iinkRestRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v4/iinkRestRecognizer.js~buildMathConf", "access": "public", "export": false, "importPath": "myscript/src/recognizer/rest/v4/iinkRestRecognizer.js", "importStyle": null, "description": null, "lineNumber": 70, "undocument": true, "params": [ { "name": "configuration", "types": [ "*" ] } ], "return": { "types": [ "{\"math\": *, \"lang\": *, \"export\": *}" ] }, "ignore": true }, { "__docId__": 358, "kind": "function", "name": "buildDiagramConf", "memberof": "src/recognizer/rest/v4/iinkRestRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v4/iinkRestRecognizer.js~buildDiagramConf", "access": "public", "export": false, "importPath": "myscript/src/recognizer/rest/v4/iinkRestRecognizer.js", "importStyle": null, "description": null, "lineNumber": 78, "undocument": true, "params": [ { "name": "configuration", "types": [ "*" ] } ], "return": { "types": [ "{\"diagram\": *, \"lang\": *, \"export\": *}" ] }, "ignore": true }, { "__docId__": 359, "kind": "function", "name": "buildRawContentConf", "memberof": "src/recognizer/rest/v4/iinkRestRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v4/iinkRestRecognizer.js~buildRawContentConf", "access": "public", "export": false, "importPath": "myscript/src/recognizer/rest/v4/iinkRestRecognizer.js", "importStyle": null, "description": null, "lineNumber": 86, "undocument": true, "params": [ { "name": "configuration", "types": [ "*" ] } ], "return": { "types": [ "{\"raw-content\": *, \"lang\": *, \"export\": *}" ] }, "ignore": true }, { "__docId__": 360, "kind": "function", "name": "buildData", "memberof": "src/recognizer/rest/v4/iinkRestRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v4/iinkRestRecognizer.js~buildData", "access": "public", "export": false, "importPath": "myscript/src/recognizer/rest/v4/iinkRestRecognizer.js", "importStyle": null, "description": null, "lineNumber": 96, "undocument": true, "params": [ { "name": "recognizerContext", "types": [ "*" ] }, { "name": "model", "types": [ "*" ] }, { "name": "conversionState", "types": [ "*" ] } ], "return": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 361, "kind": "function", "name": "extractExports", "memberof": "src/recognizer/rest/v4/iinkRestRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v4/iinkRestRecognizer.js~extractExports", "access": "public", "export": false, "importPath": "myscript/src/recognizer/rest/v4/iinkRestRecognizer.js", "importStyle": null, "description": null, "lineNumber": 146, "undocument": true, "params": [ { "name": "configuration", "types": [ "*" ] }, { "name": "mimeType", "types": [ "*" ] }, { "name": "res", "types": [ "*" ] } ], "return": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 362, "kind": "function", "name": "resultCallback", "memberof": "src/recognizer/rest/v4/iinkRestRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v4/iinkRestRecognizer.js~resultCallback", "access": "public", "export": false, "importPath": "myscript/src/recognizer/rest/v4/iinkRestRecognizer.js", "importStyle": null, "description": null, "lineNumber": 152, "undocument": true, "params": [ { "name": "model", "types": [ "*" ] }, { "name": "configuration", "types": [ "*" ] }, { "name": "res", "types": [ "*" ] }, { "name": "mimeType", "types": [ "*" ] }, { "name": "callback", "types": [ "*" ] } ], "return": null, "ignore": true }, { "__docId__": 363, "kind": "function", "name": "export_", "memberof": "src/recognizer/rest/v4/iinkRestRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v4/iinkRestRecognizer.js~export_", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/v4/iinkRestRecognizer.js", "importStyle": "{export_}", "description": "Export content", "lineNumber": 172, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" }, { "nullable": null, "types": [ "Array[String]" ], "spread": false, "optional": false, "name": "requestedMimeTypes", "description": "" } ], "return": null }, { "__docId__": 364, "kind": "function", "name": "convert", "memberof": "src/recognizer/rest/v4/iinkRestRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/rest/v4/iinkRestRecognizer.js~convert", "access": "public", "export": true, "importPath": "myscript/src/recognizer/rest/v4/iinkRestRecognizer.js", "importStyle": "{convert}", "description": "Ask for conversion using DIGITAL_EDIT", "lineNumber": 214, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 365, "kind": "file", "name": "src/recognizer/websocket/CdkWSRecognizerUtil.js", "content": "import { recognizerLogger as logger } from '../../configuration/LoggerConfig';\nimport Constants from '../../configuration/Constants';\nimport * as NetworkWSInterface from './networkWSInterface';\nimport * as PromiseHelper from '../../util/PromiseHelper';\nimport * as InkModel from '../../model/InkModel';\nimport * as RecognizerContext from '../../model/RecognizerContext';\n\nfunction buildUrl(configuration, suffixUrl) {\n const scheme = (configuration.recognitionParams.server.scheme === 'https') ? 'wss' : 'ws';\n return `${scheme}://${configuration.recognitionParams.server.host}${suffixUrl}`;\n}\n\nconst commonCallback = (model, err, res, callback) => {\n if (res && res.type === 'close') {\n return callback(err, model, Constants.EventType.CHANGED);\n }\n return callback(err, model);\n};\n\n/**\n * Build websocket function\n * @typedef {function} BuildWebSocketFunction\n * @param {DestructuredPromise} destructuredPromise\n * @param {RecognizerContext} recognizerContext\n * @return {Callback}\n */\n\n/**\n * Init the websocket recognizer.\n * Open the connexion and proceed to the hmac challenge.\n * @param {String} suffixUrl\n * @param {RecognizerContext} recognizerContext\n * @param {BuildWebSocketFunction} buildWebSocketCallback\n * @param {function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback)} reconnect\n * @return {Promise} Fulfilled when the init phase is over.\n */\nexport function init(suffixUrl, recognizerContext, buildWebSocketCallback, reconnect) {\n const recognitionContext = recognizerContext.recognitionContexts[0];\n const recognizerContextReference = RecognizerContext.updateRecognitionPositions(recognizerContext, recognitionContext.model.lastPositions);\n recognizerContextReference.url = buildUrl(recognizerContext.editor.configuration, suffixUrl);\n recognizerContextReference.reconnect = reconnect;\n\n const destructuredInitPromise = PromiseHelper.destructurePromise();\n recognizerContextReference.initPromise = destructuredInitPromise.promise;\n\n logger.debug('Opening the websocket for context ', recognizerContext);\n recognizerContextReference.websocketCallback = buildWebSocketCallback(destructuredInitPromise, recognizerContextReference);\n recognizerContextReference.websocket = NetworkWSInterface.openWebSocket(recognizerContextReference);\n return recognizerContextReference.initPromise.then((res) => {\n logger.debug('Init over', res);\n return res;\n });\n}\n\nexport function retry(func, recognizerContext, model, callback, ...params) {\n if (RecognizerContext.shouldAttemptImmediateReconnect(recognizerContext) && recognizerContext.reconnect) {\n logger.info('Attempting a retry', recognizerContext.currentReconnectionCount);\n recognizerContext.reconnect(recognizerContext, model, (err, res) => {\n if (!err) {\n func(recognizerContext, res, callback, ...params);\n } else {\n logger.error('Failed retry', err);\n retry(func, recognizerContext, model, callback, ...params);\n }\n });\n } else {\n callback('Unable to reconnect', model);\n }\n}\n\n/**\n * @param {RecognizerContext} recognizerContext\n * @param {function(params: ...Object): Object} buildMessage\n * @param {...Object} params\n * @return {Promise}\n */\nexport function sendMessage(recognizerContext, buildMessage, ...params) {\n return recognizerContext.initPromise\n .then(() => {\n logger.trace('Init was done. Sending message');\n const message = buildMessage(...params);\n if (message) {\n NetworkWSInterface.send(recognizerContext, message);\n const positions = recognizerContext.recognitionContexts[0].model.lastPositions;\n if (positions) {\n RecognizerContext.updateRecognitionPositions(recognizerContext, positions);\n }\n } else {\n logger.warn('empty message');\n }\n });\n}\n\n/**\n * Do what is needed to clean the server context.\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function clear(recognizerContext, model, callback) {\n const modelRef = InkModel.clearModel(model);\n const recognizerContextReference = RecognizerContext.updateRecognitionPositions(recognizerContext, modelRef.lastPositions);\n if (recognizerContextReference && recognizerContextReference.websocket) {\n // We have to send again all strokes after a clear.\n delete recognizerContextReference.instanceId;\n try {\n NetworkWSInterface.send(recognizerContextReference, { type: 'reset' });\n } catch (sendFailedException) {\n // To force failure without breaking the flow\n // FIXME not working at all\n recognizerContextReference.websocketCallback(PromiseHelper.destructurePromise(), recognizerContextReference, model);\n }\n }\n // We do not keep track of the success of clear.\n callback(undefined, modelRef);\n}\n\n/**\n * Close and free all resources that will no longer be used by the recognizer.\n * @param {RecognizerContext} recognizerContext\n * @param {Model} model\n * @param {RecognizerCallback} callback\n */\nexport function close(recognizerContext, model, callback) {\n const recognitionContext = {\n model,\n callback: (err, res) => commonCallback(model, err, res, callback)\n };\n const recognizerContextRef = recognizerContext;\n\n recognizerContext.initPromise\n .then(() => {\n recognizerContextRef.recognitionContexts[0] = recognitionContext;\n return recognizerContextRef;\n })\n .then(context => NetworkWSInterface.close(context, 1000, RecognizerContext.CLOSE_RECOGNIZER_MESSAGE));\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/recognizer/websocket/CdkWSRecognizerUtil.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 366, "kind": "function", "name": "buildUrl", "memberof": "src/recognizer/websocket/CdkWSRecognizerUtil.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/CdkWSRecognizerUtil.js~buildUrl", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/CdkWSRecognizerUtil.js", "importStyle": null, "description": null, "lineNumber": 8, "undocument": true, "params": [ { "name": "configuration", "types": [ "*" ] }, { "name": "suffixUrl", "types": [ "*" ] } ], "return": { "types": [ "string" ] }, "ignore": true }, { "__docId__": 367, "kind": "function", "name": "commonCallback", "memberof": "src/recognizer/websocket/CdkWSRecognizerUtil.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/CdkWSRecognizerUtil.js~commonCallback", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/CdkWSRecognizerUtil.js", "importStyle": null, "description": null, "lineNumber": 13, "undocument": true, "params": [ { "name": "model", "types": [ "*" ] }, { "name": "err", "types": [ "*" ] }, { "name": "res", "types": [ "*" ] }, { "name": "callback", "types": [ "*" ] } ], "return": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 368, "kind": "typedef", "name": "BuildWebSocketFunction", "memberof": "src/recognizer/websocket/CdkWSRecognizerUtil.js", "static": true, "longname": "src/recognizer/websocket/CdkWSRecognizerUtil.js~BuildWebSocketFunction", "access": "public", "description": "Build websocket function", "params": [ { "nullable": null, "types": [ "DestructuredPromise" ], "spread": false, "optional": false, "name": "destructuredPromise", "description": "" }, { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "" } ], "return": { "nullable": null, "types": [ "Callback" ], "spread": false, "description": "" }, "type": { "types": [ "function" ], "optional": false, "name": "BuildWebSocketFunction" } }, { "__docId__": 369, "kind": "function", "name": "init", "memberof": "src/recognizer/websocket/CdkWSRecognizerUtil.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/CdkWSRecognizerUtil.js~init", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/CdkWSRecognizerUtil.js", "importStyle": "{init}", "description": "Init the websocket recognizer.\nOpen the connexion and proceed to the hmac challenge.", "lineNumber": 37, "params": [ { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "suffixUrl", "description": "" }, { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "" }, { "nullable": null, "types": [ "BuildWebSocketFunction" ], "spread": false, "optional": false, "name": "buildWebSocketCallback", "description": "" }, { "nullable": null, "types": [ "function(recognizerContext: RecognizerContext, model: Model, callback: RecognizerCallback)" ], "spread": false, "optional": false, "name": "reconnect", "description": "" } ], "return": { "nullable": null, "types": [ "Promise" ], "spread": false, "description": "Fulfilled when the init phase is over." } }, { "__docId__": 370, "kind": "function", "name": "retry", "memberof": "src/recognizer/websocket/CdkWSRecognizerUtil.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/CdkWSRecognizerUtil.js~retry", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/CdkWSRecognizerUtil.js", "importStyle": "{retry}", "description": null, "lineNumber": 55, "undocument": true, "params": [ { "name": "func", "types": [ "*" ] }, { "name": "recognizerContext", "types": [ "*" ] }, { "name": "model", "types": [ "*" ] }, { "name": "callback", "types": [ "*" ] }, { "name": "params", "types": [ "...*" ], "spread": true } ], "return": null }, { "__docId__": 371, "kind": "function", "name": "sendMessage", "memberof": "src/recognizer/websocket/CdkWSRecognizerUtil.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/CdkWSRecognizerUtil.js~sendMessage", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/CdkWSRecognizerUtil.js", "importStyle": "{sendMessage}", "description": "", "lineNumber": 77, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "" }, { "nullable": null, "types": [ "function(params: ...Object): Object" ], "spread": false, "optional": false, "name": "buildMessage", "description": "" }, { "nullable": null, "types": [ "...Object" ], "spread": true, "optional": false, "name": "params", "description": "" } ], "return": { "nullable": null, "types": [ "Promise" ], "spread": false, "description": "" } }, { "__docId__": 372, "kind": "function", "name": "clear", "memberof": "src/recognizer/websocket/CdkWSRecognizerUtil.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/CdkWSRecognizerUtil.js~clear", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/CdkWSRecognizerUtil.js", "importStyle": "{clear}", "description": "Do what is needed to clean the server context.", "lineNumber": 100, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 373, "kind": "function", "name": "close", "memberof": "src/recognizer/websocket/CdkWSRecognizerUtil.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/CdkWSRecognizerUtil.js~close", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/CdkWSRecognizerUtil.js", "importStyle": "{close}", "description": "Close and free all resources that will no longer be used by the recognizer.", "lineNumber": 124, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 374, "kind": "file", "name": "src/recognizer/websocket/networkWSInterface.js", "content": "import { recognizerLogger as logger } from '../../configuration/LoggerConfig';\nimport * as RecognizerContext from '../../model/RecognizerContext';\n\nfunction infinitePing(websocket) {\n const websocketRef = websocket;\n websocketRef.pingLostCount++;\n if (websocketRef.pingLostCount > websocketRef.maxPingLost) {\n websocket.close(1000, 'PING_LOST');\n } else if (websocketRef.readyState <= 1) {\n setTimeout(() => {\n if (websocketRef.readyState <= 1) {\n websocketRef.send(JSON.stringify({ type: 'ping' }));\n infinitePing(websocketRef);\n }\n }, websocketRef.pingDelay);\n }\n}\n\n/**\n * Attach all socket attributes helping managing server connexion\n * @param {WebSocket} websocket Current WebSocket\n * @param {RecognizerContext} recognizerContext\n */\nfunction addWebsocketAttributes(websocket, recognizerContext) {\n const websocketConfiguration = recognizerContext.editor.configuration.recognitionParams.server.websocket;\n const socket = websocket;\n socket.start = new Date();\n socket.autoReconnect = websocketConfiguration.autoReconnect;\n socket.maxRetryCount = websocketConfiguration.maxRetryCount;\n socket.pingEnabled = websocketConfiguration.pingEnabled;\n socket.pingDelay = websocketConfiguration.pingDelay;\n socket.maxPingLost = websocketConfiguration.maxPingLostCount;\n socket.pingLostCount = 0;\n socket.recognizerContext = recognizerContext;\n}\n\n/**\n * @param {RecognizerContext} recognizerContext Recognizer context\n * @return {WebSocket} Opened WebSocket\n */\nexport function openWebSocket(recognizerContext) {\n let socket;\n try {\n // eslint-disable-next-line no-undef\n socket = new WebSocket(recognizerContext.url);\n } catch (error) {\n logger.error('Unable to open websocket, Check the host and your connectivity');\n }\n addWebsocketAttributes(socket, recognizerContext);\n if (socket.pingEnabled) {\n infinitePing(socket);\n }\n\n socket.onopen = (e) => {\n logger.trace('onOpen');\n recognizerContext.websocketCallback(e);\n };\n\n socket.onclose = (e) => {\n logger.trace('onClose', new Date() - socket.start);\n recognizerContext.websocketCallback(e);\n };\n\n socket.onerror = (e) => {\n logger.trace('onError');\n recognizerContext.websocketCallback(e);\n };\n\n socket.onmessage = (e) => {\n logger.trace('onMessage');\n socket.pingLostCount = 0;\n const parsedMessage = JSON.parse(e.data);\n if (parsedMessage.type !== 'pong') {\n const callBackParam = {\n type: e.type,\n data: JSON.parse(e.data)\n };\n recognizerContext.websocketCallback(callBackParam);\n }\n };\n\n return socket;\n}\n\n/**\n * Send data message\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Object} message Data message\n */\nexport function send(recognizerContext, message) {\n const recognizerContextRef = recognizerContext;\n recognizerContextRef.idle = false;\n\n const websocket = recognizerContextRef.websocket;\n if (websocket.readyState <= 1) {\n websocket.send(JSON.stringify(message));\n logger.debug(`${message.type} message sent`, message);\n } else {\n throw RecognizerContext.LOST_CONNEXION_MESSAGE;\n }\n}\n\n/**\n * Close the websocket\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Number} code Exit code\n * @param {String} reason Exit reason\n */\nexport function close(recognizerContext, code, reason) {\n const websocket = recognizerContext.websocket;\n if (websocket && websocket.readyState < 2) {\n websocket.close(code, reason);\n }\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/recognizer/websocket/networkWSInterface.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 375, "kind": "function", "name": "infinitePing", "memberof": "src/recognizer/websocket/networkWSInterface.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/networkWSInterface.js~infinitePing", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/networkWSInterface.js", "importStyle": null, "description": null, "lineNumber": 4, "undocument": true, "params": [ { "name": "websocket", "types": [ "*" ] } ], "return": null, "ignore": true }, { "__docId__": 376, "kind": "function", "name": "addWebsocketAttributes", "memberof": "src/recognizer/websocket/networkWSInterface.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/networkWSInterface.js~addWebsocketAttributes", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/networkWSInterface.js", "importStyle": null, "description": "Attach all socket attributes helping managing server connexion", "lineNumber": 24, "params": [ { "nullable": null, "types": [ "WebSocket" ], "spread": false, "optional": false, "name": "websocket", "description": "Current WebSocket" }, { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "" } ], "return": null, "ignore": true }, { "__docId__": 377, "kind": "function", "name": "openWebSocket", "memberof": "src/recognizer/websocket/networkWSInterface.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/networkWSInterface.js~openWebSocket", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/networkWSInterface.js", "importStyle": "{openWebSocket}", "description": "", "lineNumber": 41, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Recognizer context" } ], "return": { "nullable": null, "types": [ "WebSocket" ], "spread": false, "description": "Opened WebSocket" } }, { "__docId__": 378, "kind": "function", "name": "send", "memberof": "src/recognizer/websocket/networkWSInterface.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/networkWSInterface.js~send", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/networkWSInterface.js", "importStyle": "{send}", "description": "Send data message", "lineNumber": 90, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "message", "description": "Data message" } ], "return": null }, { "__docId__": 379, "kind": "function", "name": "close", "memberof": "src/recognizer/websocket/networkWSInterface.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/networkWSInterface.js~close", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/networkWSInterface.js", "importStyle": "{close}", "description": "Close the websocket", "lineNumber": 109, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "name": "code", "description": "Exit code" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "reason", "description": "Exit reason" } ], "return": null }, { "__docId__": 380, "kind": "file", "name": "src/recognizer/websocket/v3/Cdkv3WSBuilder.js", "content": "import { recognizerLogger as logger } from '../../../configuration/LoggerConfig';\nimport * as CryptoHelper from '../../CryptoHelper';\nimport * as NetworkWSInterface from '../networkWSInterface';\nimport * as RecognizerContext from '../../../model/RecognizerContext';\nimport Constants from '../../../configuration/Constants';\n\n/**\n * A CDK v3 websocket dialog have this sequence :\n * ---------- Client ------------------------------------- Server ----------------------------------\n * init (send the applicationKey) ================>\n * <=========== hmacChallenge\n * answerToHmacChallenge (send the hmac) =========>\n * <=========== init\n * start (send the parameters and first strokes ) ===============>\n * <=========== recognition with instance id\n * continue (send the other strokes ) ============>\n * <=========== recognition\n */\n\nfunction buildHmacMessage(configuration, message) {\n return {\n type: 'hmac',\n applicationKey: configuration.recognitionParams.server.applicationKey,\n challenge: message.data.challenge,\n hmac: CryptoHelper.computeHmac(message.data.challenge, configuration.recognitionParams.server.applicationKey, configuration.recognitionParams.server.hmacKey)\n };\n}\n\nfunction buildInitMessage(configuration) {\n return {\n type: 'applicationKey',\n applicationKey: configuration.recognitionParams.server.applicationKey\n };\n}\n\n/**\n * This function bind the right behaviour when a message is receive by the websocket.\n * @param {DestructuredPromise} destructuredPromise\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @return {function} Callback to handle WebSocket results\n */\nexport function buildWebSocketCallback(destructuredPromise, recognizerContext) {\n return (message) => {\n const recognizerContextRef = recognizerContext;\n // Handle websocket messages\n logger.trace(`${message.type} websocket callback`, message);\n const recognitionContext = recognizerContext.recognitionContexts[recognizerContext.recognitionContexts.length - 1];\n logger.debug('Current recognition context', recognitionContext);\n\n switch (message.type) {\n case 'open' :\n NetworkWSInterface.send(recognizerContext, buildInitMessage(recognizerContext.editor.configuration));\n break;\n case 'message' :\n logger.trace('Receiving message', message.data.type);\n switch (message.data.type) {\n case 'hmacChallenge' :\n NetworkWSInterface.send(recognizerContext, buildHmacMessage(recognizerContext.editor.configuration, message));\n break;\n case 'init' :\n recognizerContextRef.currentReconnectionCount = 0;\n recognizerContextRef.idle = true;\n recognizerContextRef.initialized = true;\n recognitionContext.callback(undefined, message.data);\n destructuredPromise.resolve(recognitionContext);\n break;\n case 'reset' :\n recognizerContextRef.idle = true;\n recognitionContext.callback(undefined, message.data);\n break;\n case 'mathResult' :\n case 'textResult' :\n recognizerContextRef.idle = true;\n if (message.data.instanceId) {\n if (recognizerContext.instanceId && recognizerContext.instanceId !== message.data.instanceId) {\n logger.debug(`Instance id switch from ${recognizerContext.instanceId} to ${message.data.instanceId} this is suspicious`);\n }\n recognizerContextRef.instanceId = message.data.instanceId;\n logger.debug('Memorizing instance id', message.data.instanceId);\n }\n recognitionContext.callback(undefined, message.data);\n break;\n case 'error' :\n logger.debug('Error detected stopping all recognition', message);\n if (recognitionContext) {\n recognitionContext.callback(message.data);\n } else {\n destructuredPromise.reject(Object.assign({}, message.data, { recoverable: false }));\n }\n break;\n default :\n logger.warn('This is something unexpected in current recognizer. Not the type of message we should have here.', message);\n }\n break;\n case 'error' :\n logger.debug('Error detected stopping all recognition', message);\n if (recognitionContext) {\n recognitionContext.callback(Object.assign({}, message, { recoverable: false }));\n } else {\n destructuredPromise.reject(Object.assign({}, message, { recoverable: false }));\n }\n break;\n case 'close' :\n logger.debug('Close detected stopping all recognition', message);\n recognizerContextRef.initialized = false;\n if (recognitionContext) {\n recognitionContext.callback(undefined, message);\n } else {\n destructuredPromise.reject(message);\n }\n break;\n default :\n logger.warn('This is something unexpected in current recognizer. Not the type of message we should have here.', message);\n }\n };\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/recognizer/websocket/v3/Cdkv3WSBuilder.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 381, "kind": "function", "name": "buildHmacMessage", "memberof": "src/recognizer/websocket/v3/Cdkv3WSBuilder.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v3/Cdkv3WSBuilder.js~buildHmacMessage", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/v3/Cdkv3WSBuilder.js", "importStyle": null, "description": "A CDK v3 websocket dialog have this sequence :\n---------- Client ------------------------------------- Server ----------------------------------\ninit (send the applicationKey) ================>\n <=========== hmacChallenge\nanswerToHmacChallenge (send the hmac) =========>\n <=========== init\nstart (send the parameters and first strokes ) ===============>\n <=========== recognition with instance id\ncontinue (send the other strokes ) ============>\n <=========== recognition", "lineNumber": 20, "params": [ { "name": "configuration", "types": [ "*" ] }, { "name": "message", "types": [ "*" ] } ], "return": { "types": [ "{\"type\": string, \"applicationKey\": *, \"challenge\": *, \"hmac\": *}" ] }, "ignore": true }, { "__docId__": 382, "kind": "function", "name": "buildInitMessage", "memberof": "src/recognizer/websocket/v3/Cdkv3WSBuilder.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v3/Cdkv3WSBuilder.js~buildInitMessage", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/v3/Cdkv3WSBuilder.js", "importStyle": null, "description": null, "lineNumber": 29, "undocument": true, "params": [ { "name": "configuration", "types": [ "*" ] } ], "return": { "types": [ "{\"type\": string, \"applicationKey\": *}" ] }, "ignore": true }, { "__docId__": 383, "kind": "function", "name": "buildWebSocketCallback", "memberof": "src/recognizer/websocket/v3/Cdkv3WSBuilder.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v3/Cdkv3WSBuilder.js~buildWebSocketCallback", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v3/Cdkv3WSBuilder.js", "importStyle": "{buildWebSocketCallback}", "description": "This function bind the right behaviour when a message is receive by the websocket.", "lineNumber": 42, "params": [ { "nullable": null, "types": [ "DestructuredPromise" ], "spread": false, "optional": false, "name": "destructuredPromise", "description": "" }, { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" } ], "return": { "nullable": null, "types": [ "function" ], "spread": false, "description": "Callback to handle WebSocket results" } }, { "__docId__": 384, "kind": "file", "name": "src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js", "content": "import { recognizerLogger as logger } from '../../../configuration/LoggerConfig';\nimport Constants from '../../../configuration/Constants';\nimport * as InkModel from '../../../model/InkModel';\nimport * as RecognizerContext from '../../../model/RecognizerContext';\nimport * as StrokeComponent from '../../../model/StrokeComponent';\nimport * as Cdkv3WSWebsocketBuilder from './Cdkv3WSBuilder';\nimport * as CdkWSRecognizerUtil from '../CdkWSRecognizerUtil';\nimport * as DefaultRecognizer from '../../DefaultRecognizer';\nimport * as CdkCommonUtil from '../../common/CdkCommonUtil';\nimport * as Cdkv3CommonMathRecognizer from '../../common/v3/Cdkv3CommonMathRecognizer';\n\nexport { close } from '../CdkWSRecognizerUtil';\n\n/**\n * Recognizer configuration\n * @type {RecognizerInfo}\n */\nexport const mathWebSocketV3Configuration = {\n types: [Constants.RecognitionType.MATH],\n protocol: Constants.Protocol.WEBSOCKET,\n apiVersion: 'V3',\n availableTriggers: {\n exportContent: [Constants.Trigger.POINTER_UP]\n }\n};\n\n/**\n * Get the configuration supported by this recognizer\n * @return {RecognizerInfo}\n */\nexport function getInfo() {\n return mathWebSocketV3Configuration;\n}\n\nfunction buildMathInput(recognizerContext, model) {\n InkModel.updateModelSentPosition(model);\n if (recognizerContext.lastPositions.lastSentPosition < 0) {\n const configuration = recognizerContext.editor.configuration;\n return {\n type: 'start',\n parameters: configuration.recognitionParams.v3.mathParameter,\n components: model.rawStrokes.map(stroke => StrokeComponent.toJSON(stroke))\n };\n }\n\n return {\n type: 'continue',\n components: InkModel.extractPendingStrokes(model, -1).map(stroke => StrokeComponent.toJSON(stroke))\n };\n}\n\nfunction buildResetMessage(model) {\n InkModel.resetModelPositions(model);\n return {\n type: 'reset'\n };\n}\n\nconst mathCallback = (model, err, res, callback) => {\n if (res) {\n if (res.type === 'init') {\n return callback(err, model, Constants.EventType.LOADED, Constants.EventType.IDLE);\n }\n if (res.type === 'close') {\n return callback(err, model, Constants.EventType.CHANGED);\n }\n const modelReference = InkModel.updateModelReceivedPosition(model);\n modelReference.rawResults.exports = res;\n modelReference.exports = CdkCommonUtil.extractExports(modelReference);\n modelReference.recognizedSymbols = Cdkv3CommonMathRecognizer.extractRecognizedSymbols(modelReference);\n return callback(err, modelReference, Constants.EventType.EXPORTED, Constants.EventType.IDLE);\n }\n return callback(err, model);\n};\n\n/**\n * Initialize recognition\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function init(recognizerContext, model, callback) {\n const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, {\n model: InkModel.resetModelPositions(model),\n callback: (err, res) => mathCallback(model, err, res, callback)\n });\n CdkWSRecognizerUtil.init('/api/v3.0/recognition/ws/math', recognizerContextRef, Cdkv3WSWebsocketBuilder.buildWebSocketCallback, init)\n .catch((err) => {\n if (RecognizerContext.shouldAttemptImmediateReconnect(recognizerContext) && recognizerContext.reconnect) {\n logger.info('Attempting a reconnect', recognizerContext.currentReconnectionCount);\n recognizerContext.reconnect(recognizerContext, model, callback);\n } else {\n logger.error('Unable to init', err);\n callback(err, model);\n }\n });\n}\n\n/**\n * Export content\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\n// eslint-disable-next-line no-underscore-dangle\nexport function export_(recognizerContext, model, callback) {\n const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, {\n model,\n callback: (err, res) => mathCallback(model, err, res, callback)\n });\n CdkWSRecognizerUtil.sendMessage(recognizerContextRef, buildMathInput, recognizerContext, model)\n .catch(exception => CdkWSRecognizerUtil.retry(export_, recognizerContext, model, callback));\n}\n\n/**\n * Reset the recognition context\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function reset(recognizerContext, model, callback) {\n const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, {\n model,\n callback: (err, res) => mathCallback(model, err, res, callback)\n });\n CdkWSRecognizerUtil.sendMessage(recognizerContextRef, buildResetMessage, model)\n .catch(exception => CdkWSRecognizerUtil.retry(reset, recognizerContext, model, callback));\n}\n\n/**\n * Clear server context. Currently nothing to do there.\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function clear(recognizerContext, model, callback) {\n DefaultRecognizer.clear(recognizerContext, model, (err, res, ...types) => {\n reset(recognizerContext, res, (err1, res1) => logger.trace('Session reset'));\n callback(err, res, ...types);\n });\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 385, "kind": "variable", "name": "mathWebSocketV3Configuration", "memberof": "src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js", "static": true, "longname": "src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js~mathWebSocketV3Configuration", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js", "importStyle": "{mathWebSocketV3Configuration}", "description": "Recognizer configuration", "lineNumber": 18, "type": { "nullable": null, "types": [ "RecognizerInfo" ], "spread": false, "description": null } }, { "__docId__": 386, "kind": "function", "name": "getInfo", "memberof": "src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js~getInfo", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js", "importStyle": "{getInfo}", "description": "Get the configuration supported by this recognizer", "lineNumber": 31, "return": { "nullable": null, "types": [ "RecognizerInfo" ], "spread": false, "description": "" }, "params": [] }, { "__docId__": 387, "kind": "function", "name": "buildMathInput", "memberof": "src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js~buildMathInput", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js", "importStyle": null, "description": null, "lineNumber": 35, "undocument": true, "params": [ { "name": "recognizerContext", "types": [ "*" ] }, { "name": "model", "types": [ "*" ] } ], "return": { "types": [ "{\"type\": string, \"components\": *}" ] }, "ignore": true }, { "__docId__": 388, "kind": "function", "name": "buildResetMessage", "memberof": "src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js~buildResetMessage", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js", "importStyle": null, "description": null, "lineNumber": 52, "undocument": true, "params": [ { "name": "model", "types": [ "*" ] } ], "return": { "types": [ "{\"type\": string}" ] }, "ignore": true }, { "__docId__": 389, "kind": "function", "name": "mathCallback", "memberof": "src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js~mathCallback", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js", "importStyle": null, "description": null, "lineNumber": 59, "undocument": true, "params": [ { "name": "model", "types": [ "*" ] }, { "name": "err", "types": [ "*" ] }, { "name": "res", "types": [ "*" ] }, { "name": "callback", "types": [ "*" ] } ], "return": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 390, "kind": "function", "name": "init", "memberof": "src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js~init", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js", "importStyle": "{init}", "description": "Initialize recognition", "lineNumber": 82, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 391, "kind": "function", "name": "export_", "memberof": "src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js~export_", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js", "importStyle": "{export_}", "description": "Export content", "lineNumber": 106, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 392, "kind": "function", "name": "reset", "memberof": "src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js~reset", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js", "importStyle": "{reset}", "description": "Reset the recognition context", "lineNumber": 121, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 393, "kind": "function", "name": "clear", "memberof": "src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js~clear", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v3/Cdkv3WSMathRecognizer.js", "importStyle": "{clear}", "description": "Clear server context. Currently nothing to do there.", "lineNumber": 136, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 394, "kind": "file", "name": "src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js", "content": "import { recognizerLogger as logger } from '../../../configuration/LoggerConfig';\nimport * as CryptoHelper from '../../CryptoHelper';\nimport Constants from '../../../configuration/Constants';\nimport * as InkModel from '../../../model/InkModel';\nimport * as RecognizerContext from '../../../model/RecognizerContext';\nimport * as StrokeComponent from '../../../model/StrokeComponent';\nimport * as Cdkv3WSWebsocketBuilder from './Cdkv3WSBuilder';\nimport * as CdkWSRecognizerUtil from '../CdkWSRecognizerUtil';\nimport * as DefaultRecognizer from '../../DefaultRecognizer';\nimport * as Cdkv3CommonTextRecognizer from '../../common/v3/Cdkv3CommonTextRecognizer';\n\nexport { close } from '../CdkWSRecognizerUtil';\n\n/**\n * Recognizer configuration\n * @type {RecognizerInfo}\n */\nexport const textWebSocketV3Configuration = {\n types: [Constants.RecognitionType.TEXT],\n protocol: Constants.Protocol.WEBSOCKET,\n apiVersion: 'V3',\n availableTriggers: {\n exportContent: [Constants.Trigger.POINTER_UP]\n }\n};\n\n/**\n * Get the configuration supported by this recognizer\n * @return {RecognizerInfo}\n */\nexport function getInfo() {\n return textWebSocketV3Configuration;\n}\n\nfunction buildTextInput(recognizerContext, model) {\n InkModel.updateModelSentPosition(model);\n if (recognizerContext.lastPositions.lastSentPosition < 0) {\n const configuration = recognizerContext.editor.configuration;\n return {\n type: 'start',\n textParameter: configuration.recognitionParams.v3.textParameter,\n inputUnits: [{\n textInputType: 'MULTI_LINE_TEXT',\n components: model.rawStrokes.map(stroke => StrokeComponent.toJSON(stroke))\n }]\n };\n }\n\n return {\n type: 'continue',\n inputUnits: [{\n textInputType: 'MULTI_LINE_TEXT',\n components: InkModel.extractPendingStrokes(model, -1).map(stroke => StrokeComponent.toJSON(stroke))\n }]\n };\n}\n\nfunction buildResetMessage(model) {\n InkModel.resetModelPositions(model);\n return {\n type: 'reset'\n };\n}\n\nconst textCallback = (model, err, res, callback) => {\n if (res) {\n if (res.type === 'init') {\n return callback(err, model, Constants.EventType.LOADED, Constants.EventType.IDLE);\n }\n if (res.type === 'close') {\n return callback(err, model, Constants.EventType.CHANGED);\n }\n const modelReference = InkModel.updateModelReceivedPosition(model);\n modelReference.rawResults.exports = res;\n modelReference.exports = Cdkv3CommonTextRecognizer.extractExports(model);\n return callback(err, modelReference, Constants.EventType.EXPORTED, Constants.EventType.IDLE);\n }\n return callback(err, model);\n};\n\n/**\n * Initialize recognition\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function init(recognizerContext, model, callback) {\n const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, {\n model: InkModel.resetModelPositions(model),\n callback: (err, res) => textCallback(model, err, res, callback)\n });\n CdkWSRecognizerUtil.init('/api/v3.0/recognition/ws/text', recognizerContextRef, Cdkv3WSWebsocketBuilder.buildWebSocketCallback, init)\n .catch((err) => {\n if (RecognizerContext.shouldAttemptImmediateReconnect(recognizerContext) && recognizerContext.reconnect) {\n logger.info('Attempting a reconnect', recognizerContext.currentReconnectionCount);\n recognizerContext.reconnect(recognizerContext, model, callback);\n } else {\n logger.error('Unable to init', err);\n callback(err, model);\n }\n });\n}\n\n/**\n * Export content\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\n// eslint-disable-next-line no-underscore-dangle\nexport function export_(recognizerContext, model, callback) {\n const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, {\n model,\n callback: (err, res) => textCallback(model, err, res, callback)\n });\n CdkWSRecognizerUtil.sendMessage(recognizerContextRef, buildTextInput, recognizerContext, model)\n .catch(exception => CdkWSRecognizerUtil.retry(export_, recognizerContext, model, callback));\n}\n\n/**\n * Reset the recognition context\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function reset(recognizerContext, model, callback) {\n const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, {\n model,\n callback: (err, res) => textCallback(model, err, res, callback)\n });\n CdkWSRecognizerUtil.sendMessage(recognizerContextRef, buildResetMessage, model)\n .catch(exception => CdkWSRecognizerUtil.retry(reset, recognizerContext, model, callback));\n}\n\n/**\n * Clear server context. Currently nothing to do there.\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function clear(recognizerContext, model, callback) {\n DefaultRecognizer.clear(recognizerContext, model, (err, res, ...types) => {\n reset(recognizerContext, res, (err1, res1) => logger.trace('Session reset'));\n callback(err, res, ...types);\n });\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 395, "kind": "variable", "name": "textWebSocketV3Configuration", "memberof": "src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js", "static": true, "longname": "src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js~textWebSocketV3Configuration", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js", "importStyle": "{textWebSocketV3Configuration}", "description": "Recognizer configuration", "lineNumber": 18, "type": { "nullable": null, "types": [ "RecognizerInfo" ], "spread": false, "description": null } }, { "__docId__": 396, "kind": "function", "name": "getInfo", "memberof": "src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js~getInfo", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js", "importStyle": "{getInfo}", "description": "Get the configuration supported by this recognizer", "lineNumber": 31, "return": { "nullable": null, "types": [ "RecognizerInfo" ], "spread": false, "description": "" }, "params": [] }, { "__docId__": 397, "kind": "function", "name": "buildTextInput", "memberof": "src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js~buildTextInput", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js", "importStyle": null, "description": null, "lineNumber": 35, "undocument": true, "params": [ { "name": "recognizerContext", "types": [ "*" ] }, { "name": "model", "types": [ "*" ] } ], "return": { "types": [ "{\"type\": string, \"inputUnits\": *}" ] }, "ignore": true }, { "__docId__": 398, "kind": "function", "name": "buildResetMessage", "memberof": "src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js~buildResetMessage", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js", "importStyle": null, "description": null, "lineNumber": 58, "undocument": true, "params": [ { "name": "model", "types": [ "*" ] } ], "return": { "types": [ "{\"type\": string}" ] }, "ignore": true }, { "__docId__": 399, "kind": "function", "name": "textCallback", "memberof": "src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js~textCallback", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js", "importStyle": null, "description": null, "lineNumber": 65, "undocument": true, "params": [ { "name": "model", "types": [ "*" ] }, { "name": "err", "types": [ "*" ] }, { "name": "res", "types": [ "*" ] }, { "name": "callback", "types": [ "*" ] } ], "return": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 400, "kind": "function", "name": "init", "memberof": "src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js~init", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js", "importStyle": "{init}", "description": "Initialize recognition", "lineNumber": 87, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 401, "kind": "function", "name": "export_", "memberof": "src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js~export_", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js", "importStyle": "{export_}", "description": "Export content", "lineNumber": 111, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 402, "kind": "function", "name": "reset", "memberof": "src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js~reset", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js", "importStyle": "{reset}", "description": "Reset the recognition context", "lineNumber": 126, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 403, "kind": "function", "name": "clear", "memberof": "src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js~clear", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v3/Cdkv3WSTextRecognizer.js", "importStyle": "{clear}", "description": "Clear server context. Currently nothing to do there.", "lineNumber": 141, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 404, "kind": "file", "name": "src/recognizer/websocket/v4/Cdkv4WSBuilder.js", "content": "import { recognizerLogger as logger } from '../../../configuration/LoggerConfig';\nimport * as CryptoHelper from '../../CryptoHelper';\nimport * as NetworkWSInterface from '../networkWSInterface';\nimport * as RecognizerContext from '../../../model/RecognizerContext';\n\nimport {\n buildNewContentPackageInput,\n buildRestoreIInkSessionInput,\n buildNewContentPart,\n buildOpenContentPart,\n buildConfiguration,\n buildSetTheme,\n buildSetPenStyle,\n buildSetPenStyleClasses\n} from './Cdkv4WSIInkRecognizer';\n\n/**\n * A CDK v4 websocket dialog have this sequence :\n * ---------- Client ------------------------------------- Server ----------------------------------\n * init (send the new content package) ================>\n * <=========== hmacChallenge\n * answerToHmacChallenge (send the hmac) =========>\n * newPart (send the parameters ) ===============>\n * <=========== update\n * addStrokes (send the strokes ) ============>\n * <=========== update\n */\n\nfunction buildHmacMessage(configuration, message) {\n return {\n type: 'hmac',\n hmac: CryptoHelper.computeHmac(message.data.hmacChallenge, configuration.recognitionParams.server.applicationKey, configuration.recognitionParams.server.hmacKey)\n };\n}\n\n/**\n * This function bind the right behaviour when a message is receive by the websocket.\n * @param {DestructuredPromise} destructuredPromise\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @return {function} Callback to handle WebSocket results\n */\nexport function buildWebSocketCallback(destructuredPromise, recognizerContext) {\n return (message) => {\n const recognizerContextRef = recognizerContext;\n // Handle websocket messages\n logger.trace(`${message.type} websocket callback`, message);\n const recognitionContext = recognizerContext.recognitionContexts[recognizerContext.recognitionContexts.length - 1];\n logger.debug('Current recognition context', recognitionContext);\n\n switch (message.type) {\n case 'open':\n if (recognizerContext.sessionId) {\n NetworkWSInterface.send(recognizerContext, buildRestoreIInkSessionInput(recognizerContext.editor.configuration, recognizerContext.editor.domElement, recognizerContext.sessionId));\n } else {\n NetworkWSInterface.send(recognizerContext, buildNewContentPackageInput(recognizerContext.editor.configuration, recognizerContext.editor.domElement));\n }\n break;\n case 'message':\n logger.debug(`Receiving ${message.data.type} message`, message);\n switch (message.data.type) {\n case 'ack':\n if (message.data.hmacChallenge) {\n NetworkWSInterface.send(recognizerContext, buildHmacMessage(recognizerContext.editor.configuration, message));\n }\n if (message.data.iinkSessionId) {\n recognizerContextRef.sessionId = message.data.iinkSessionId;\n }\n break;\n case 'newPart':\n break;\n case 'contentPackageDescription':\n recognizerContextRef.currentReconnectionCount = 0;\n recognizerContextRef.contentPartCount = message.data.contentPartCount;\n NetworkWSInterface.send(recognizerContext, buildConfiguration(recognizerContext.editor.configuration));\n if (recognizerContextRef.currentPartId) { // FIXME: Ugly hack to resolve init promise after opening part\n NetworkWSInterface.send(recognizerContext, buildOpenContentPart(recognizerContext.editor.configuration, recognizerContext.currentPartId));\n } else {\n NetworkWSInterface.send(recognizerContext, buildNewContentPart(recognizerContext.editor.configuration));\n }\n break;\n case 'partChanged':\n if (message.data.partId) {\n recognizerContextRef.currentPartId = message.data.partId;\n }\n recognizerContextRef.initialized = true;\n NetworkWSInterface.send(recognizerContext, buildSetTheme(recognizerContext.editor.theme));\n NetworkWSInterface.send(recognizerContext, buildSetPenStyle(recognizerContext.editor.penStyle));\n NetworkWSInterface.send(recognizerContext, buildSetPenStyleClasses(recognizerContext.editor.penStyleClasses));\n recognitionContext.callback(undefined, message.data);\n destructuredPromise.resolve(recognitionContext);\n break;\n case 'contentChanged':\n if (message.data.canUndo !== undefined) {\n recognizerContextRef.canUndo = message.data.canUndo;\n }\n if (message.data.canRedo !== undefined) {\n recognizerContextRef.canRedo = message.data.canRedo;\n }\n if (message.data.empty !== undefined) {\n recognizerContextRef.isEmpty = message.data.empty;\n }\n if (message.data.possibleUndoCount !== undefined) {\n recognizerContextRef.possibleUndoCount = message.data.possibleUndoCount;\n }\n if (message.data.undoStackIndex !== undefined) {\n recognizerContextRef.undoStackIndex = message.data.undoStackIndex;\n }\n recognitionContext.callback(undefined, message.data);\n break;\n case 'exported':\n recognitionContext.callback(undefined, message.data);\n break;\n case 'svgPatch':\n recognitionContext.callback(undefined, message.data);\n break;\n case 'supportedImportMimeTypes':\n recognizerContextRef.supportedImportMimeTypes = message.data.mimeTypes;\n recognitionContext.callback(undefined, message.data);\n break;\n case 'fileChunkAck':\n recognitionContext.callback(undefined, message.data);\n break;\n case 'idle':\n recognizerContextRef.idle = true;\n recognitionContext.callback(undefined, message.data);\n break;\n case 'error':\n logger.debug('Error detected stopping all recognition', message);\n if (recognitionContext) {\n recognitionContext.callback(message.data);\n } else {\n destructuredPromise.reject(Object.assign({}, message.data, { recoverable: false }));\n }\n break;\n default :\n logger.warn('This is something unexpected in current recognizer. Not the type of message we should have here.', message);\n }\n break;\n case 'error':\n logger.debug('Error detected stopping all recognition', message);\n if (recognitionContext) {\n recognitionContext.callback(Object.assign({}, message, { recoverable: false }));\n } else {\n destructuredPromise.reject(Object.assign({}, message, { recoverable: false }));\n }\n break;\n case 'close':\n logger.debug('Close detected stopping all recognition', message);\n recognizerContextRef.initialized = false;\n recognizerContextRef.canRedo = false;\n recognizerContextRef.canUndo = false;\n if (recognitionContext) {\n recognitionContext.callback(message);\n } else {\n destructuredPromise.reject(message);\n }\n break;\n default :\n logger.warn('This is something unexpected in current recognizer. Not the type of message we should have here.', message);\n }\n };\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/recognizer/websocket/v4/Cdkv4WSBuilder.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 405, "kind": "function", "name": "buildHmacMessage", "memberof": "src/recognizer/websocket/v4/Cdkv4WSBuilder.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSBuilder.js~buildHmacMessage", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSBuilder.js", "importStyle": null, "description": "A CDK v4 websocket dialog have this sequence :\n---------- Client ------------------------------------- Server ----------------------------------\ninit (send the new content package) ================>\n <=========== hmacChallenge\nanswerToHmacChallenge (send the hmac) =========>\nnewPart (send the parameters ) ===============>\n <=========== update\naddStrokes (send the strokes ) ============>\n <=========== update", "lineNumber": 29, "params": [ { "name": "configuration", "types": [ "*" ] }, { "name": "message", "types": [ "*" ] } ], "return": { "types": [ "{\"type\": string, \"hmac\": *}" ] }, "ignore": true }, { "__docId__": 406, "kind": "function", "name": "buildWebSocketCallback", "memberof": "src/recognizer/websocket/v4/Cdkv4WSBuilder.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSBuilder.js~buildWebSocketCallback", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSBuilder.js", "importStyle": "{buildWebSocketCallback}", "description": "This function bind the right behaviour when a message is receive by the websocket.", "lineNumber": 42, "params": [ { "nullable": null, "types": [ "DestructuredPromise" ], "spread": false, "optional": false, "name": "destructuredPromise", "description": "" }, { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" } ], "return": { "nullable": null, "types": [ "function" ], "spread": false, "description": "Callback to handle WebSocket results" } }, { "__docId__": 407, "kind": "file", "name": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "content": "import uuid from 'uuid-js';\nimport { recognizerLogger as logger } from '../../../configuration/LoggerConfig';\nimport Constants from '../../../configuration/Constants';\nimport * as DefaultTheme from '../../../configuration/DefaultTheme';\nimport * as DefaultPenStyle from '../../../configuration/DefaultPenStyle';\nimport * as InkModel from '../../../model/InkModel';\nimport * as RecognizerContext from '../../../model/RecognizerContext';\nimport * as DefaultRecognizer from '../../DefaultRecognizer';\nimport * as Cdkv4WSWebsocketBuilder from './Cdkv4WSBuilder';\nimport * as CdkWSRecognizerUtil from '../CdkWSRecognizerUtil';\n\nexport { close } from '../CdkWSRecognizerUtil';\n\nfunction readBlob(blob) {\n const fileReader = new FileReader();\n return new Promise((resolve, reject) => {\n fileReader.onload = event => resolve(event.target.result);\n fileReader.onerror = () => reject(this);\n fileReader.readAsText(blob);\n });\n}\n\n\nfunction getDPI(element) {\n // const startDpi = 56;\n // for (let dpi = startDpi; dpi < 2000; dpi++) {\n // if (window.matchMedia(`(max-resolution: ${dpi}dpi)`).matches === true) {\n // return dpi;\n // }\n // }\n // return startDpi;\n return 96;\n}\n\n/**\n * Recognizer configuration\n * @type {RecognizerInfo}\n */\nexport const IInkWebSocketV4Configuration = {\n types: [Constants.RecognitionType.MATH, Constants.RecognitionType.TEXT, Constants.RecognitionType.DIAGRAM, Constants.RecognitionType.NEBO],\n protocol: Constants.Protocol.WEBSOCKET,\n apiVersion: 'V4',\n availableTriggers: {\n exportContent: [Constants.Trigger.POINTER_UP, Constants.Trigger.DEMAND],\n addStrokes: [Constants.Trigger.POINTER_UP]\n }\n};\n\n/**\n * Get the configuration supported by this recognizer\n * @return {RecognizerInfo}\n */\nexport function getInfo() {\n return IInkWebSocketV4Configuration;\n}\n\nexport function buildNewContentPackageInput(configuration, element) {\n return {\n type: 'newContentPackage',\n applicationKey: configuration.recognitionParams.server.applicationKey,\n xDpi: getDPI(element),\n yDpi: getDPI(element),\n viewSizeHeight: element.clientHeight < configuration.renderingParams.minHeight ? configuration.renderingParams.minHeight : element.clientHeight,\n viewSizeWidth: element.clientWidth < configuration.renderingParams.minWidth ? configuration.renderingParams.minWidth : element.clientWidth\n };\n}\n\nexport function buildRestoreIInkSessionInput(configuration, element, sessionId) {\n return {\n type: 'restoreIInkSession',\n iinkSessionId: sessionId,\n applicationKey: configuration.recognitionParams.server.applicationKey,\n xDpi: getDPI(element),\n yDpi: getDPI(element),\n viewSizeHeight: element.clientHeight < configuration.renderingParams.minHeight ? configuration.renderingParams.minHeight : element.clientHeight,\n viewSizeWidth: element.clientWidth < configuration.renderingParams.minWidth ? configuration.renderingParams.minWidth : element.clientWidth\n };\n}\n\nexport function buildNewContentPart(configuration) {\n return {\n type: 'newContentPart',\n contentType: configuration.recognitionParams.type,\n mimeTypes: (configuration.triggers.exportContent !== Constants.Trigger.DEMAND) ?\n configuration.recognitionParams.v4[`${configuration.recognitionParams.type.toLowerCase()}`].mimeTypes : undefined\n };\n}\n\nexport function buildOpenContentPart(configuration, partId) {\n return {\n type: 'openContentPart',\n id: partId,\n mimeTypes: (configuration.triggers.exportContent !== Constants.Trigger.DEMAND) ?\n configuration.recognitionParams.v4[`${configuration.recognitionParams.type.toLowerCase()}`].mimeTypes : undefined\n };\n}\n\nexport function buildConfiguration(configuration) {\n return Object.assign({ type: 'configuration' }, configuration.recognitionParams.v4);\n}\n\nfunction buildAddStrokes(recognizerContext, model) {\n const strokes = InkModel.extractPendingStrokes(model, recognizerContext.lastPositions.lastSentPosition + 1);\n if (strokes.length > 0) {\n InkModel.updateModelSentPosition(model);\n return {\n type: 'addStrokes',\n strokes: strokes.map(stroke => Object.assign({}, {\n id: stroke.id,\n pointerType: stroke.pointerType,\n pointerId: stroke.pointerId,\n x: stroke.x,\n y: stroke.y,\n t: stroke.t,\n p: stroke.p\n }))\n };\n }\n return undefined;\n}\n\nfunction buildUndo() {\n return {\n type: 'undo'\n };\n}\n\nfunction buildRedo() {\n return {\n type: 'redo'\n };\n}\n\nfunction buildClear() {\n return {\n type: 'clear'\n };\n}\n\nfunction buildConvert(state) {\n return {\n type: 'convert',\n conversionState: state\n };\n}\n\nfunction buildZoom(value) {\n return {\n type: 'zoom',\n zoom: value\n };\n}\n\nfunction buildResize(element, minHeight = 0, minWidth = 0) {\n return {\n type: 'changeViewSize',\n height: element.clientHeight < minHeight ? minHeight : element.clientHeight,\n width: element.clientWidth < minWidth ? minWidth : element.clientWidth\n };\n}\n\nfunction buildExport(configuration, partId, requestedMimeType) {\n let usedMimeType;\n if (requestedMimeType && Object.keys(requestedMimeType).length !== 0) {\n usedMimeType = requestedMimeType;\n } else {\n usedMimeType = configuration.recognitionParams.v4[`${configuration.recognitionParams.type.toLowerCase()}`].mimeTypes;\n }\n\n return {\n type: 'export',\n partId,\n mimeTypes: usedMimeType\n };\n}\n\nfunction buildImportFile(id, mimetype) {\n return {\n type: 'importFile',\n importFileId: id,\n mimeType: mimetype\n };\n}\n\nfunction buildImportChunk(id, data, lastChunk) {\n return {\n type: 'fileChunk',\n importFileId: id,\n data,\n lastChunk\n };\n}\n\nfunction buildPointerEvents(events) {\n return Object.assign({ type: 'pointerEvents' }, events);\n}\n\nfunction buildWaitForIdle() {\n return {\n type: 'waitForIdle'\n };\n}\n\nfunction buildGetSupportedImportMimeTypes() {\n return {\n type: 'getSupportedImportMimeTypes'\n };\n}\n\nexport function buildSetPenStyle(penStyle) {\n return {\n type: 'setPenStyle',\n style: penStyle ? DefaultPenStyle.toCSS(penStyle) : ''\n };\n}\n\nexport function buildSetPenStyleClasses(penStyleClasses) {\n return {\n type: 'setPenStyleClasses',\n styleClasses: penStyleClasses\n };\n}\n\nexport function buildSetTheme(theme) {\n return {\n type: 'setTheme',\n theme: DefaultTheme.toCSS(theme)\n };\n}\n\nconst iinkCallback = (model, err, res, callback) => {\n const modelReference = InkModel.updateModelReceivedPosition(model);\n if (res) {\n if (res.updates !== undefined) {\n if (modelReference.recognizedSymbols) {\n modelReference.recognizedSymbols.push(res);\n } else {\n modelReference.recognizedSymbols = [res];\n }\n return callback(err, modelReference, Constants.EventType.RENDERED);\n }\n if (res.exports !== undefined) {\n modelReference.rawResults.exports = res;\n modelReference.exports = res.exports;\n return callback(err, modelReference, Constants.EventType.EXPORTED);\n }\n\n if ((res.canUndo !== undefined) || (res.canRedo !== undefined)) {\n return callback(err, modelReference, Constants.EventType.CHANGED);\n }\n\n if (res.type === 'supportedImportMimeTypes') {\n return callback(err, modelReference, Constants.EventType.SUPPORTED_IMPORT_MIMETYPES);\n }\n\n if (res.type === 'partChanged') {\n return callback(err, modelReference, Constants.EventType.LOADED);\n }\n\n if (res.type === 'idle') {\n return callback(err, modelReference, Constants.EventType.IDLE);\n }\n\n if (res.type === 'close') {\n return callback(err, modelReference, Constants.EventType.CHANGED);\n }\n }\n return callback(err, modelReference);\n};\n\n/**\n * Initialize recognition\n * @param {RecognizerContext} recognizerContext Current recognizer context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function init(recognizerContext, model, callback) {\n const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, {\n model: InkModel.updateModelSentPosition(model, model.lastPositions.lastReceivedPosition),\n callback: (err, res) => iinkCallback(model, err, res, callback)\n });\n CdkWSRecognizerUtil.init('/api/v4.0/iink/document', recognizerContextRef, Cdkv4WSWebsocketBuilder.buildWebSocketCallback, init)\n .catch((err) => {\n if (RecognizerContext.shouldAttemptImmediateReconnect(recognizerContext) && recognizerContext.reconnect) {\n logger.info('Attempting a reconnect', recognizerContext.currentReconnectionCount);\n recognizerContext.reconnect(recognizerContext, model, callback);\n } else {\n logger.error('Unable to reconnect', err);\n iinkCallback(model, err, undefined, callback);\n }\n });\n}\n\n/**\n * Create a new content part\n * @param {RecognizerContext} recognizerContext Current recognition context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function newContentPart(recognizerContext, model, callback) {\n const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, {\n model,\n callback: (err, res) => iinkCallback(model, err, res, callback)\n });\n CdkWSRecognizerUtil.sendMessage(recognizerContextRef, buildNewContentPart, recognizerContext.editor.configuration)\n .catch(exception => CdkWSRecognizerUtil.retry(newContentPart, recognizerContext, model, callback));\n}\n\n/**\n * Open the recognizer context content part\n * @param {RecognizerContext} recognizerContext Current recognition context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function openContentPart(recognizerContext, model, callback) {\n const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, {\n model,\n callback: (err, res) => iinkCallback(model, err, res, callback)\n });\n CdkWSRecognizerUtil.sendMessage(recognizerContextRef, buildOpenContentPart, recognizerContext.editor.configuration, recognizerContext.currentPartId)\n .catch(exception => CdkWSRecognizerUtil.retry(openContentPart, recognizerContext, model, callback));\n}\n\nexport function sendConfiguration(recognizerContext, model, callback) {\n const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, {\n model,\n callback: (err, res) => iinkCallback(model, err, res, callback)\n });\n CdkWSRecognizerUtil.sendMessage(recognizerContextRef, buildConfiguration, recognizerContext.editor.configuration)\n .catch(exception => CdkWSRecognizerUtil.retry(sendConfiguration, recognizerContext, model, callback));\n}\n\n/**\n * Pointer Events\n * @param {RecognizerContext} recognizerContext Current recognition context\n * @param {Model} model Current model\n * @param {PointerEvents} events to be imported\n * @param {RecognizerCallback} callback\n */\nexport function pointerEvents(recognizerContext, model, events, callback) {\n const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, {\n model,\n callback: (err, res) => iinkCallback(model, err, res, callback)\n });\n CdkWSRecognizerUtil.sendMessage(recognizerContextRef, buildPointerEvents, events)\n .catch(exception => CdkWSRecognizerUtil.retry(pointerEvents, recognizerContext, model, events, callback));\n}\n\n/**\n * Add strokes to the model\n * @param {RecognizerContext} recognizerContext Current recognition context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function addStrokes(recognizerContext, model, callback) {\n const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, {\n model,\n callback: (err, res) => iinkCallback(model, err, res, callback)\n });\n CdkWSRecognizerUtil.sendMessage(recognizerContextRef, buildAddStrokes, recognizerContext, model)\n .catch(exception => CdkWSRecognizerUtil.retry(addStrokes, recognizerContext, model, callback));\n}\n\n/**\n * Undo last action\n * @param {RecognizerContext} recognizerContext Current recognition context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function undo(recognizerContext, model, callback) {\n const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, {\n model,\n callback: (err, res) => iinkCallback(model, err, res, callback)\n });\n CdkWSRecognizerUtil.sendMessage(recognizerContextRef, buildUndo)\n .catch(exception => CdkWSRecognizerUtil.retry(undo, recognizerContext, model, callback));\n}\n\n/**\n * Redo last action\n * @param {RecognizerContext} recognizerContext Current recognition context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function redo(recognizerContext, model, callback) {\n const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, {\n model,\n callback: (err, res) => iinkCallback(model, err, res, callback)\n });\n CdkWSRecognizerUtil.sendMessage(recognizerContextRef, buildRedo)\n .catch(exception => CdkWSRecognizerUtil.retry(redo, recognizerContext, model, callback));\n}\n\n/**\n * Clear action\n * @param {RecognizerContext} recognizerContext Current recognition context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function clear(recognizerContext, model, callback) {\n const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, {\n model,\n callback: (err, res) => {\n DefaultRecognizer.clear(recognizerContext, model, (noerr, newModel, ...attrs) => {\n logger.debug('The model after clear is :', newModel);\n iinkCallback(newModel, err, res, callback);\n });\n }\n });\n CdkWSRecognizerUtil.sendMessage(recognizerContextRef, buildClear)\n .catch(exception => CdkWSRecognizerUtil.retry(clear, recognizerContext, model, callback));\n}\n\n/**\n * Convert action\n * @param {RecognizerContext} recognizerContext Current recognition context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n * @param {String} conversionState Conversion State, by default DigitalEdit\n */\nexport function convert(recognizerContext, model, callback, conversionState) {\n const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, {\n model,\n callback: (err, res) => iinkCallback(model, err, res, callback)\n });\n CdkWSRecognizerUtil.sendMessage(recognizerContextRef, buildConvert, conversionState)\n .catch(exception => CdkWSRecognizerUtil.retry(convert, recognizerContext, model, callback, conversionState));\n}\n\n/**\n * Export action\n * @param {RecognizerContext} recognizerContext Current recognition context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n * @param {Array[String]} requestedMimeTypes\n */\n// eslint-disable-next-line no-underscore-dangle\nexport function export_(recognizerContext, model, callback, requestedMimeTypes) {\n const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, {\n model,\n callback: (err, res) => iinkCallback(model, err, res, callback)\n });\n CdkWSRecognizerUtil.sendMessage(recognizerContextRef, buildExport, recognizerContext.editor.configuration, recognizerContext.currentPartId, requestedMimeTypes)\n .catch(exception => CdkWSRecognizerUtil.retry(export_, recognizerContext, model, callback, requestedMimeTypes));\n}\n\n/**\n * Import action\n * @param {RecognizerContext} recognizerContext Current recognition context\n * @param {Model} model Current model\n * @param {Blob} data Import data\n * @param {RecognizerCallback} callback\n */\n// eslint-disable-next-line no-underscore-dangle\nexport function import_(recognizerContext, model, data, callback) {\n const recognitionContext = {\n model,\n callback: (err, res) => iinkCallback(model, err, res, callback),\n importFileId: uuid.create(4).toString()\n };\n const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, recognitionContext);\n\n const chunkSize = recognizerContext.editor.configuration.recognitionParams.server.websocket.fileChunkSize;\n\n for (let i = 0; i < data.size; i += chunkSize) {\n if (i === 0) {\n CdkWSRecognizerUtil.sendMessage(recognizerContextRef, buildImportFile, recognitionContext.importFileId, data.type)\n .catch(exception => CdkWSRecognizerUtil.retry(import_, recognizerContext, model, data, callback));\n }\n const blobPart = data.slice(i, chunkSize, data.type);\n readBlob(blobPart).then((res) => {\n CdkWSRecognizerUtil.sendMessage(recognizerContextRef, buildImportChunk, recognitionContext.importFileId, res, i + chunkSize > data.size)\n .catch(exception => CdkWSRecognizerUtil.retry(import_, recognizerContext, model, data, callback));\n });\n }\n}\n\nexport function getSupportedImportMimeTypes(recognizerContext, model, callback) {\n const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, {\n model,\n callback: (err, res) => iinkCallback(model, err, res, callback)\n });\n CdkWSRecognizerUtil.sendMessage(recognizerContextRef, buildGetSupportedImportMimeTypes)\n .catch(exception => CdkWSRecognizerUtil.retry(getSupportedImportMimeTypes, recognizerContext, model, callback));\n}\n\n/**\n * WaitForIdle action\n * @param {RecognizerContext} recognizerContext Current recognition context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n */\nexport function waitForIdle(recognizerContext, model, callback) {\n const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, {\n model,\n callback: (err, res) => iinkCallback(model, err, res, callback)\n });\n CdkWSRecognizerUtil.sendMessage(recognizerContextRef, buildWaitForIdle)\n .catch(exception => CdkWSRecognizerUtil.retry(waitForIdle, recognizerContext, model, callback));\n}\n\n/**\n * Resize\n * @param {RecognizerContext} recognizerContext Current recognition context\n * @param {Model} model Current model\n * @param {RecognizerCallback} callback\n * @param {Element} element Current element\n */\nexport function resize(recognizerContext, model, callback, element) {\n const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, {\n model,\n callback: (err, res) => iinkCallback(model, err, res, callback)\n });\n CdkWSRecognizerUtil.sendMessage(recognizerContextRef, buildResize, element, recognizerContext.editor.configuration.renderingParams.minHeight, recognizerContext.editor.configuration.renderingParams.minWidth)\n .catch(exception => CdkWSRecognizerUtil.retry(resize, recognizerContext, model, callback, element));\n}\n\n/**\n * Zoom action\n * @param {RecognizerContext} recognizerContext Current recognition context\n * @param {Model} model Current model\n * @param {Number} value=10 Zoom value\n * @param {RecognizerCallback} callback\n */\nexport function zoom(recognizerContext, model, value = 10, callback) {\n const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, {\n model,\n callback: (err, res) => iinkCallback(model, err, res, callback)\n });\n CdkWSRecognizerUtil.sendMessage(recognizerContextRef, buildZoom, value)\n .catch(exception => CdkWSRecognizerUtil.retry(zoom, recognizerContext, model, callback));\n}\n\n/**\n * SetPenStyle action\n * @param {RecognizerContext} recognizerContext Current recognition context\n * @param {Model} model Current model\n * @param {PenStyle} penStyle Current penStyle\n * @param {RecognizerCallback} callback\n */\nexport function setPenStyle(recognizerContext, model, penStyle, callback) {\n const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, {\n model,\n callback: (err, res) => iinkCallback(model, err, res, callback)\n });\n CdkWSRecognizerUtil.sendMessage(recognizerContextRef, buildSetPenStyle, penStyle)\n .catch(exception => CdkWSRecognizerUtil.retry(setPenStyle, recognizerContext, model, callback));\n}\n\n/**\n * setPenStyleClasses action\n * @param {RecognizerContext} recognizerContext Current recognition context\n * @param {Model} model Current model\n * @param {String} penStyleClasses Current penStyleClasses\n * @param {RecognizerCallback} callback\n */\nexport function setPenStyleClasses(recognizerContext, model, penStyleClasses, callback) {\n const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, {\n model,\n callback: (err, res) => iinkCallback(model, err, res, callback)\n });\n CdkWSRecognizerUtil.sendMessage(recognizerContextRef, buildSetPenStyleClasses, penStyleClasses)\n .catch(exception => CdkWSRecognizerUtil.retry(setPenStyleClasses, recognizerContext, model, callback));\n}\n\n/**\n * SetTheme action\n * @param {RecognizerContext} recognizerContext Current recognition context\n * @param {Model} model Current model\n * @param {Theme} theme Current theme\n * @param {RecognizerCallback} callback\n */\nexport function setTheme(recognizerContext, model, theme, callback) {\n const recognizerContextRef = RecognizerContext.setRecognitionContext(recognizerContext, {\n model,\n callback: (err, res) => iinkCallback(model, err, res, callback)\n });\n CdkWSRecognizerUtil.sendMessage(recognizerContextRef, buildSetTheme, theme)\n .catch(exception => CdkWSRecognizerUtil.retry(setTheme, recognizerContext, model, callback));\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 408, "kind": "function", "name": "readBlob", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~readBlob", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": null, "description": null, "lineNumber": 14, "undocument": true, "params": [ { "name": "blob", "types": [ "*" ] } ], "return": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 409, "kind": "function", "name": "getDPI", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~getDPI", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": null, "description": null, "lineNumber": 24, "undocument": true, "params": [ { "name": "element", "types": [ "*" ] } ], "return": { "types": [ "number" ] }, "ignore": true }, { "__docId__": 410, "kind": "variable", "name": "IInkWebSocketV4Configuration", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~IInkWebSocketV4Configuration", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{IInkWebSocketV4Configuration}", "description": "Recognizer configuration", "lineNumber": 39, "type": { "nullable": null, "types": [ "RecognizerInfo" ], "spread": false, "description": null } }, { "__docId__": 411, "kind": "function", "name": "getInfo", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~getInfo", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{getInfo}", "description": "Get the configuration supported by this recognizer", "lineNumber": 53, "return": { "nullable": null, "types": [ "RecognizerInfo" ], "spread": false, "description": "" }, "params": [] }, { "__docId__": 412, "kind": "function", "name": "buildNewContentPackageInput", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~buildNewContentPackageInput", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{buildNewContentPackageInput}", "description": null, "lineNumber": 57, "undocument": true, "params": [ { "name": "configuration", "types": [ "*" ] }, { "name": "element", "types": [ "*" ] } ], "return": { "types": [ "{\"type\": string, \"applicationKey\": *, \"xDpi\": *, \"yDpi\": *, \"viewSizeHeight\": *, \"viewSizeWidth\": *}" ] } }, { "__docId__": 413, "kind": "function", "name": "buildRestoreIInkSessionInput", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~buildRestoreIInkSessionInput", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{buildRestoreIInkSessionInput}", "description": null, "lineNumber": 68, "undocument": true, "params": [ { "name": "configuration", "types": [ "*" ] }, { "name": "element", "types": [ "*" ] }, { "name": "sessionId", "types": [ "*" ] } ], "return": { "types": [ "{\"type\": string, \"iinkSessionId\": *, \"applicationKey\": *, \"xDpi\": *, \"yDpi\": *, \"viewSizeHeight\": *, \"viewSizeWidth\": *}" ] } }, { "__docId__": 414, "kind": "function", "name": "buildNewContentPart", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~buildNewContentPart", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{buildNewContentPart}", "description": null, "lineNumber": 80, "undocument": true, "params": [ { "name": "configuration", "types": [ "*" ] } ], "return": { "types": [ "{\"type\": string, \"contentType\": *, \"mimeTypes\": *}" ] } }, { "__docId__": 415, "kind": "function", "name": "buildOpenContentPart", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~buildOpenContentPart", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{buildOpenContentPart}", "description": null, "lineNumber": 89, "undocument": true, "params": [ { "name": "configuration", "types": [ "*" ] }, { "name": "partId", "types": [ "*" ] } ], "return": { "types": [ "{\"type\": string, \"id\": *, \"mimeTypes\": *}" ] } }, { "__docId__": 416, "kind": "function", "name": "buildConfiguration", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~buildConfiguration", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{buildConfiguration}", "description": null, "lineNumber": 98, "undocument": true, "params": [ { "name": "configuration", "types": [ "*" ] } ], "return": { "types": [ "*" ] } }, { "__docId__": 417, "kind": "function", "name": "buildAddStrokes", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~buildAddStrokes", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": null, "description": null, "lineNumber": 102, "undocument": true, "params": [ { "name": "recognizerContext", "types": [ "*" ] }, { "name": "model", "types": [ "*" ] } ], "return": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 418, "kind": "function", "name": "buildUndo", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~buildUndo", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": null, "description": null, "lineNumber": 122, "undocument": true, "params": [], "return": { "types": [ "{\"type\": string}" ] }, "ignore": true }, { "__docId__": 419, "kind": "function", "name": "buildRedo", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~buildRedo", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": null, "description": null, "lineNumber": 128, "undocument": true, "params": [], "return": { "types": [ "{\"type\": string}" ] }, "ignore": true }, { "__docId__": 420, "kind": "function", "name": "buildClear", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~buildClear", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": null, "description": null, "lineNumber": 134, "undocument": true, "params": [], "return": { "types": [ "{\"type\": string}" ] }, "ignore": true }, { "__docId__": 421, "kind": "function", "name": "buildConvert", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~buildConvert", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": null, "description": null, "lineNumber": 140, "undocument": true, "params": [ { "name": "state", "types": [ "*" ] } ], "return": { "types": [ "{\"type\": string, \"conversionState\": *}" ] }, "ignore": true }, { "__docId__": 422, "kind": "function", "name": "buildZoom", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~buildZoom", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": null, "description": null, "lineNumber": 147, "undocument": true, "params": [ { "name": "value", "types": [ "*" ] } ], "return": { "types": [ "{\"type\": string, \"zoom\": *}" ] }, "ignore": true }, { "__docId__": 423, "kind": "function", "name": "buildResize", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~buildResize", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": null, "description": null, "lineNumber": 154, "undocument": true, "params": [ { "name": "element", "types": [ "*" ] }, { "name": "minHeight", "optional": true, "types": [ "number" ], "defaultRaw": 0, "defaultValue": "0" }, { "name": "minWidth", "optional": true, "types": [ "number" ], "defaultRaw": 0, "defaultValue": "0" } ], "return": { "types": [ "{\"type\": string, \"height\": *, \"width\": *}" ] }, "ignore": true }, { "__docId__": 424, "kind": "function", "name": "buildExport", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~buildExport", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": null, "description": null, "lineNumber": 162, "undocument": true, "params": [ { "name": "configuration", "types": [ "*" ] }, { "name": "partId", "types": [ "*" ] }, { "name": "requestedMimeType", "types": [ "*" ] } ], "return": { "types": [ "{\"type\": string, \"partId\": *, \"mimeTypes\": *}" ] }, "ignore": true }, { "__docId__": 425, "kind": "function", "name": "buildImportFile", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~buildImportFile", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": null, "description": null, "lineNumber": 177, "undocument": true, "params": [ { "name": "id", "types": [ "*" ] }, { "name": "mimetype", "types": [ "*" ] } ], "return": { "types": [ "{\"type\": string, \"importFileId\": *, \"mimeType\": *}" ] }, "ignore": true }, { "__docId__": 426, "kind": "function", "name": "buildImportChunk", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~buildImportChunk", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": null, "description": null, "lineNumber": 185, "undocument": true, "params": [ { "name": "id", "types": [ "*" ] }, { "name": "data", "types": [ "*" ] }, { "name": "lastChunk", "types": [ "*" ] } ], "return": { "types": [ "{\"type\": string, \"importFileId\": *, \"data\": *, \"lastChunk\": *}" ] }, "ignore": true }, { "__docId__": 427, "kind": "function", "name": "buildPointerEvents", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~buildPointerEvents", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": null, "description": null, "lineNumber": 194, "undocument": true, "params": [ { "name": "events", "types": [ "*" ] } ], "return": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 428, "kind": "function", "name": "buildWaitForIdle", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~buildWaitForIdle", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": null, "description": null, "lineNumber": 198, "undocument": true, "params": [], "return": { "types": [ "{\"type\": string}" ] }, "ignore": true }, { "__docId__": 429, "kind": "function", "name": "buildGetSupportedImportMimeTypes", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~buildGetSupportedImportMimeTypes", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": null, "description": null, "lineNumber": 204, "undocument": true, "params": [], "return": { "types": [ "{\"type\": string}" ] }, "ignore": true }, { "__docId__": 430, "kind": "function", "name": "buildSetPenStyle", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~buildSetPenStyle", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{buildSetPenStyle}", "description": null, "lineNumber": 210, "undocument": true, "params": [ { "name": "penStyle", "types": [ "*" ] } ], "return": { "types": [ "{\"type\": string, \"style\": *}" ] } }, { "__docId__": 431, "kind": "function", "name": "buildSetPenStyleClasses", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~buildSetPenStyleClasses", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{buildSetPenStyleClasses}", "description": null, "lineNumber": 217, "undocument": true, "params": [ { "name": "penStyleClasses", "types": [ "*" ] } ], "return": { "types": [ "{\"type\": string, \"styleClasses\": *}" ] } }, { "__docId__": 432, "kind": "function", "name": "buildSetTheme", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~buildSetTheme", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{buildSetTheme}", "description": null, "lineNumber": 224, "undocument": true, "params": [ { "name": "theme", "types": [ "*" ] } ], "return": { "types": [ "{\"type\": string, \"theme\": *}" ] } }, { "__docId__": 433, "kind": "function", "name": "iinkCallback", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~iinkCallback", "access": "public", "export": false, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": null, "description": null, "lineNumber": 231, "undocument": true, "params": [ { "name": "model", "types": [ "*" ] }, { "name": "err", "types": [ "*" ] }, { "name": "res", "types": [ "*" ] }, { "name": "callback", "types": [ "*" ] } ], "return": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 434, "kind": "function", "name": "init", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~init", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{init}", "description": "Initialize recognition", "lineNumber": 277, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognizer context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 435, "kind": "function", "name": "newContentPart", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~newContentPart", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{newContentPart}", "description": "Create a new content part", "lineNumber": 300, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognition context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 436, "kind": "function", "name": "openContentPart", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~openContentPart", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{openContentPart}", "description": "Open the recognizer context content part", "lineNumber": 315, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognition context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 437, "kind": "function", "name": "sendConfiguration", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~sendConfiguration", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{sendConfiguration}", "description": null, "lineNumber": 324, "undocument": true, "params": [ { "name": "recognizerContext", "types": [ "*" ] }, { "name": "model", "types": [ "*" ] }, { "name": "callback", "types": [ "*" ] } ], "return": null }, { "__docId__": 438, "kind": "function", "name": "pointerEvents", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~pointerEvents", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{pointerEvents}", "description": "Pointer Events", "lineNumber": 340, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognition context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "PointerEvents" ], "spread": false, "optional": false, "name": "events", "description": "to be imported" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 439, "kind": "function", "name": "addStrokes", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~addStrokes", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{addStrokes}", "description": "Add strokes to the model", "lineNumber": 355, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognition context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 440, "kind": "function", "name": "undo", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~undo", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{undo}", "description": "Undo last action", "lineNumber": 370, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognition context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 441, "kind": "function", "name": "redo", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~redo", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{redo}", "description": "Redo last action", "lineNumber": 385, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognition context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 442, "kind": "function", "name": "clear", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~clear", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{clear}", "description": "Clear action", "lineNumber": 400, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognition context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 443, "kind": "function", "name": "convert", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~convert", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{convert}", "description": "Convert action", "lineNumber": 421, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognition context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "conversionState", "description": "Conversion State, by default DigitalEdit" } ], "return": null }, { "__docId__": 444, "kind": "function", "name": "export_", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~export_", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{export_}", "description": "Export action", "lineNumber": 438, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognition context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" }, { "nullable": null, "types": [ "Array[String]" ], "spread": false, "optional": false, "name": "requestedMimeTypes", "description": "" } ], "return": null }, { "__docId__": 445, "kind": "function", "name": "import_", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~import_", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{import_}", "description": "Import action", "lineNumber": 455, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognition context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "Blob" ], "spread": false, "optional": false, "name": "data", "description": "Import data" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 446, "kind": "function", "name": "getSupportedImportMimeTypes", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~getSupportedImportMimeTypes", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{getSupportedImportMimeTypes}", "description": null, "lineNumber": 478, "undocument": true, "params": [ { "name": "recognizerContext", "types": [ "*" ] }, { "name": "model", "types": [ "*" ] }, { "name": "callback", "types": [ "*" ] } ], "return": null }, { "__docId__": 447, "kind": "function", "name": "waitForIdle", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~waitForIdle", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{waitForIdle}", "description": "WaitForIdle action", "lineNumber": 493, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognition context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 448, "kind": "function", "name": "resize", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~resize", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{resize}", "description": "Resize", "lineNumber": 509, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognition context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" }, { "nullable": null, "types": [ "Element" ], "spread": false, "optional": false, "name": "element", "description": "Current element" } ], "return": null }, { "__docId__": 449, "kind": "function", "name": "zoom", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~zoom", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{zoom}", "description": "Zoom action", "lineNumber": 525, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognition context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "defaultValue": "10", "defaultRaw": 10, "name": "value", "description": "Zoom value" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 450, "kind": "function", "name": "setPenStyle", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~setPenStyle", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{setPenStyle}", "description": "SetPenStyle action", "lineNumber": 541, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognition context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "PenStyle" ], "spread": false, "optional": false, "name": "penStyle", "description": "Current penStyle" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 451, "kind": "function", "name": "setPenStyleClasses", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~setPenStyleClasses", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{setPenStyleClasses}", "description": "setPenStyleClasses action", "lineNumber": 557, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognition context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "penStyleClasses", "description": "Current penStyleClasses" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 452, "kind": "function", "name": "setTheme", "memberof": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "generator": false, "async": false, "static": true, "longname": "src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js~setTheme", "access": "public", "export": true, "importPath": "myscript/src/recognizer/websocket/v4/Cdkv4WSIInkRecognizer.js", "importStyle": "{setTheme}", "description": "SetTheme action", "lineNumber": 573, "params": [ { "nullable": null, "types": [ "RecognizerContext" ], "spread": false, "optional": false, "name": "recognizerContext", "description": "Current recognition context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "Theme" ], "spread": false, "optional": false, "name": "theme", "description": "Current theme" }, { "nullable": null, "types": [ "RecognizerCallback" ], "spread": false, "optional": false, "name": "callback", "description": "" } ], "return": null }, { "__docId__": 453, "kind": "file", "name": "src/renderer/QuadraticUtils.js", "content": "/** ===============================================================================================\n * Compute quadratics control points\n * ============================================================================================= */\n\n/**\n *\n * @param {{x: Number, y: Number, p: Number}} point\n * @param angle\n * @param width\n * @return {[{x: Number, y: Number},{x: Number, y: Number}]}\n */\nexport function computeLinksPoints(point, angle, width) {\n const radius = point.p * width;\n return [{\n x: (point.x - (Math.sin(angle) * radius)),\n y: (point.y + (Math.cos(angle) * radius))\n }, {\n x: (point.x + (Math.sin(angle) * radius)),\n y: (point.y - (Math.cos(angle) * radius))\n }];\n}\n\n/**\n *\n * @param {{x: Number, y: Number, p: Number}} point1\n * @param {{x: Number, y: Number, p: Number}} point2\n * @return {{x: Number, y: Number, p: Number}}\n */\nexport function computeMiddlePoint(point1, point2) {\n return {\n x: ((point2.x + point1.x) / 2),\n y: ((point2.y + point1.y) / 2),\n p: ((point2.p + point1.p) / 2)\n };\n}\n\n/**\n *\n * @param {{x: Number, y: Number}} begin\n * @param {{x: Number, y: Number}} end\n * @return {Number}\n */\nexport function computeAxeAngle(begin, end) {\n return Math.atan2(end.y - begin.y, end.x - begin.x);\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/renderer/QuadraticUtils.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 454, "kind": "function", "name": "computeLinksPoints", "memberof": "src/renderer/QuadraticUtils.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/QuadraticUtils.js~computeLinksPoints", "access": "public", "export": true, "importPath": "myscript/src/renderer/QuadraticUtils.js", "importStyle": "{computeLinksPoints}", "description": "", "lineNumber": 12, "params": [ { "nullable": null, "types": [ "{x: Number, y: Number, p: Number}" ], "spread": false, "optional": false, "name": "point", "description": "" }, { "nullable": null, "types": [ "*" ], "spread": false, "optional": false, "name": "angle", "description": "" }, { "nullable": null, "types": [ "*" ], "spread": false, "optional": false, "name": "width", "description": "" } ], "return": { "nullable": null, "types": [ "[{x: Number, y: Number},{x: Number, y: Number}]" ], "spread": false, "description": "" } }, { "__docId__": 455, "kind": "function", "name": "computeMiddlePoint", "memberof": "src/renderer/QuadraticUtils.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/QuadraticUtils.js~computeMiddlePoint", "access": "public", "export": true, "importPath": "myscript/src/renderer/QuadraticUtils.js", "importStyle": "{computeMiddlePoint}", "description": "", "lineNumber": 29, "params": [ { "nullable": null, "types": [ "{x: Number, y: Number, p: Number}" ], "spread": false, "optional": false, "name": "point1", "description": "" }, { "nullable": null, "types": [ "{x: Number, y: Number, p: Number}" ], "spread": false, "optional": false, "name": "point2", "description": "" } ], "return": { "nullable": null, "types": [ "{x: Number, y: Number, p: Number}" ], "spread": false, "description": "" } }, { "__docId__": 456, "kind": "function", "name": "computeAxeAngle", "memberof": "src/renderer/QuadraticUtils.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/QuadraticUtils.js~computeAxeAngle", "access": "public", "export": true, "importPath": "myscript/src/renderer/QuadraticUtils.js", "importStyle": "{computeAxeAngle}", "description": "", "lineNumber": 43, "params": [ { "nullable": null, "types": [ "{x: Number, y: Number}" ], "spread": false, "optional": false, "name": "begin", "description": "" }, { "nullable": null, "types": [ "{x: Number, y: Number}" ], "spread": false, "optional": false, "name": "end", "description": "" } ], "return": { "nullable": null, "types": [ "Number" ], "spread": false, "description": "" } }, { "__docId__": 457, "kind": "file", "name": "src/renderer/canvas/CanvasRenderer.js", "content": "import { rendererLogger as logger } from '../../configuration/LoggerConfig';\nimport { drawStroke } from './symbols/StrokeSymbolCanvasRenderer';\nimport { drawTextSymbol, TextSymbols } from './symbols/TextSymbolCanvasRenderer';\nimport { drawShapeSymbol, ShapeSymbols } from './symbols/ShapeSymbolCanvasRenderer';\nimport {\n drawMusicSymbol,\n getMusicClefElements,\n MusicSymbols\n} from './symbols/MusicSymbolCanvasRenderer';\nimport * as InkModel from '../../model/InkModel';\n\n/**\n * Renderer info\n * @typedef {Object} RendererInfo\n * @property {String} type Renderer type.\n * @property {String} apiVersion Supported api version.\n */\n\n/**\n * Default renderer\n * @typedef {Object} Renderer\n * @property {function(): RendererInfo} getInfo Get some information about this renderer\n * @property {function(element: Element, minHeight: Number, minWidth: Number): Object} attach Populate the DOM element to create rendering area.\n * @property {function(element: Element, context: Object)} detach Remove rendering area from the DOM element.\n * @property {function(context: Object, model: Model, stroker: Stroker)} resize Explicitly resize the rendering area.\n * @property {function(context: Object, model: Model, stroker: Stroker): Model} drawCurrentStroke Draw the model currentStroke.\n * @property {function(context: Object, model: Model, stroker: Stroker): Model} drawModel Draw the model defaultSymbols and recognizedSymbols.\n */\n\n/**\n * Get info\n * @return {RendererInfo} Information about this renderer\n */\nexport function getInfo() {\n return {\n type: 'canvas',\n apiVersion: 'V3'\n };\n}\n\nfunction getPixelRatio(canvas) {\n if (canvas) {\n const context = canvas.getContext('2d');\n // we are using a browser object\n // eslint-disable-next-line no-undef\n const devicePixelRatio = window.devicePixelRatio || 1;\n const backingStoreRatio = context.webkitBackingStorePixelRatio ||\n context.mozBackingStorePixelRatio ||\n context.msBackingStorePixelRatio ||\n context.oBackingStorePixelRatio ||\n context.backingStorePixelRatio || 1;\n return devicePixelRatio / backingStoreRatio;\n }\n return 1;\n}\n\nfunction detectPixelRatio(element) {\n // we are using a browser object\n // eslint-disable-next-line no-undef\n const tempCanvas = document.createElement('canvas');\n const canvasRatio = getPixelRatio(tempCanvas);\n // document.removeChild(tempCanvas);\n return canvasRatio;\n}\n\nfunction createCanvas(element, type) {\n // eslint-disable-next-line no-undef\n const browserDocument = document;\n const canvas = browserDocument.createElement('canvas');\n canvas.classList.add(type);\n canvas.classList.add('ms-canvas');\n element.appendChild(canvas);\n logger.debug('canvas created', canvas);\n return canvas;\n}\n\nfunction resizeContent(context) {\n const elements = [context.renderingCanvas, context.capturingCanvas];\n elements.forEach((canvas) => {\n const domElement = canvas.parentNode;\n const width = domElement.clientWidth < context.minWidth ? context.minWidth : domElement.clientWidth;\n const height = domElement.clientHeight < context.minHeight ? context.minHeight : domElement.clientHeight;\n /* eslint-disable no-param-reassign */\n canvas.width = width * context.pixelRatio;\n canvas.height = height * context.pixelRatio;\n canvas.style.width = `${width}px`;\n canvas.style.height = `${height}px`;\n /* eslint-enable no-param-reassign */\n canvas.getContext('2d').scale(context.pixelRatio, context.pixelRatio);\n logger.debug('canvas size changed', canvas);\n });\n return context;\n}\n\n/**\n * Attach the renderer to the DOM element\n * @param {Element} element DOM element to attach the rendering elements\n * @param {Number} [minHeight=0] Minimal height of the editor\n * @param {Number} [minWidth=0] Minimal width of the editor\n * @return {Object} The renderer context to give as parameter when a draw model will be call\n */\nexport function attach(element, minHeight = 0, minWidth = 0) {\n logger.debug('attach renderer', element);\n const pixelRatio = detectPixelRatio(element);\n const resources = getMusicClefElements();\n resources.forEach(clef => element.appendChild(clef));\n\n const renderingCanvas = createCanvas(element, 'ms-rendering-canvas');\n const capturingCanvas = createCanvas(element, 'ms-capture-canvas');\n\n const context = {\n pixelRatio,\n minHeight,\n minWidth,\n renderingCanvas,\n renderingCanvasContext: renderingCanvas.getContext('2d'),\n capturingCanvas,\n capturingCanvasContext: capturingCanvas.getContext('2d'),\n resources\n };\n\n return resizeContent(context);\n}\n\n/**\n * Detach the renderer from the DOM element\n * @param {Element} element DOM element to attach the rendering elements\n * @param {Object} context Current rendering context\n */\nexport function detach(element, context) {\n logger.debug('detach renderer', element);\n context.resources.forEach(res => element.removeChild(res));\n element.removeChild(context.renderingCanvas);\n element.removeChild(context.capturingCanvas);\n}\n\n/**\n * Update the rendering context size\n * @param {Object} context Current rendering context\n * @param {Model} model Current model\n * @param {Stroker} stroker Current stroker\n * @return {Model}\n */\nexport function resize(context, model, stroker) {\n return this.drawModel(resizeContent(context), model, stroker);\n}\n\nfunction drawSymbol(context, symbol, stroker) {\n const type = symbol.elementType ? symbol.elementType : symbol.type;\n logger.trace(`attempting to draw ${type} symbol`);\n if (type === 'stroke') {\n drawStroke(context, symbol, stroker);\n } else if (TextSymbols[type]) {\n drawTextSymbol(context, symbol);\n } else if (ShapeSymbols[type]) {\n drawShapeSymbol(context, symbol);\n } else if (MusicSymbols[type]) {\n drawMusicSymbol(context, symbol);\n } else {\n logger.warn(`impossible to draw ${type} symbol`);\n }\n}\n\n/**\n * Draw the current stroke from the model\n * @param {Object} context Current rendering context\n * @param {Model} model Current model\n * @param {Stroker} stroker Current stroker\n * @return {Model}\n */\nexport function drawCurrentStroke(context, model, stroker) {\n // Render the current stroke\n context.capturingCanvasContext.clearRect(0, 0, context.capturingCanvas.width, context.capturingCanvas.height);\n logger.trace('drawing current stroke ', model.currentStroke);\n drawStroke(context.capturingCanvasContext, model.currentStroke, stroker);\n return model;\n}\n\n/**\n * Draw all symbols contained into the model\n * @param {Object} context Current rendering context\n * @param {Model} model Current model\n * @param {Stroker} stroker Current stroker\n * @return {Model}\n */\nexport function drawModel(context, model, stroker) {\n context.renderingCanvasContext.clearRect(0, 0, context.renderingCanvas.width, context.renderingCanvas.height);\n // Displaying the default symbols and pending strokes\n const symbols = [...model.defaultSymbols];\n // Displaying the recognition symbols or raw strokes\n if (model.recognizedSymbols) {\n symbols.push(...model.recognizedSymbols);\n symbols.push(...InkModel.extractPendingStrokes(model));\n } else {\n symbols.push(...model.rawStrokes);\n }\n symbols.forEach(symbol => drawSymbol(context.renderingCanvasContext, symbol, stroker));\n context.capturingCanvasContext.clearRect(0, 0, context.capturingCanvas.width, context.capturingCanvas.height);\n return model;\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/renderer/canvas/CanvasRenderer.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 458, "kind": "typedef", "name": "RendererInfo", "memberof": "src/renderer/canvas/CanvasRenderer.js", "static": true, "longname": "src/renderer/canvas/CanvasRenderer.js~RendererInfo", "access": "public", "description": "Renderer info", "properties": [ { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "type", "description": "Renderer type." }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "apiVersion", "description": "Supported api version." } ], "type": { "types": [ "Object" ], "optional": false, "name": "RendererInfo" } }, { "__docId__": 459, "kind": "typedef", "name": "Renderer", "memberof": "src/renderer/canvas/CanvasRenderer.js", "static": true, "longname": "src/renderer/canvas/CanvasRenderer.js~Renderer", "access": "public", "description": "Default renderer", "properties": [ { "nullable": null, "types": [ "function(): RendererInfo" ], "spread": false, "optional": false, "name": "getInfo", "description": "Get some information about this renderer" }, { "nullable": null, "types": [ "function(element: Element, minHeight: Number, minWidth: Number): Object" ], "spread": false, "optional": false, "name": "attach", "description": "Populate the DOM element to create rendering area." }, { "nullable": null, "types": [ "function(element: Element, context: Object)" ], "spread": false, "optional": false, "name": "detach", "description": "Remove rendering area from the DOM element." }, { "nullable": null, "types": [ "function(context: Object, model: Model, stroker: Stroker)" ], "spread": false, "optional": false, "name": "resize", "description": "Explicitly resize the rendering area." }, { "nullable": null, "types": [ "function(context: Object, model: Model, stroker: Stroker): Model" ], "spread": false, "optional": false, "name": "drawCurrentStroke", "description": "Draw the model currentStroke." }, { "nullable": null, "types": [ "function(context: Object, model: Model, stroker: Stroker): Model" ], "spread": false, "optional": false, "name": "drawModel", "description": "Draw the model defaultSymbols and recognizedSymbols." } ], "type": { "types": [ "Object" ], "optional": false, "name": "Renderer" } }, { "__docId__": 460, "kind": "function", "name": "getInfo", "memberof": "src/renderer/canvas/CanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/CanvasRenderer.js~getInfo", "access": "public", "export": true, "importPath": "myscript/src/renderer/canvas/CanvasRenderer.js", "importStyle": "{getInfo}", "description": "Get info", "lineNumber": 34, "return": { "nullable": null, "types": [ "RendererInfo" ], "spread": false, "description": "Information about this renderer" }, "params": [] }, { "__docId__": 461, "kind": "function", "name": "getPixelRatio", "memberof": "src/renderer/canvas/CanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/CanvasRenderer.js~getPixelRatio", "access": "public", "export": false, "importPath": "myscript/src/renderer/canvas/CanvasRenderer.js", "importStyle": null, "description": null, "lineNumber": 41, "undocument": true, "params": [ { "name": "canvas", "types": [ "*" ] } ], "return": { "types": [ "number" ] }, "ignore": true }, { "__docId__": 462, "kind": "function", "name": "detectPixelRatio", "memberof": "src/renderer/canvas/CanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/CanvasRenderer.js~detectPixelRatio", "access": "public", "export": false, "importPath": "myscript/src/renderer/canvas/CanvasRenderer.js", "importStyle": null, "description": null, "lineNumber": 57, "undocument": true, "params": [ { "name": "element", "types": [ "*" ] } ], "return": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 463, "kind": "function", "name": "createCanvas", "memberof": "src/renderer/canvas/CanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/CanvasRenderer.js~createCanvas", "access": "public", "export": false, "importPath": "myscript/src/renderer/canvas/CanvasRenderer.js", "importStyle": null, "description": null, "lineNumber": 66, "undocument": true, "params": [ { "name": "element", "types": [ "*" ] }, { "name": "type", "types": [ "*" ] } ], "return": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 464, "kind": "function", "name": "resizeContent", "memberof": "src/renderer/canvas/CanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/CanvasRenderer.js~resizeContent", "access": "public", "export": false, "importPath": "myscript/src/renderer/canvas/CanvasRenderer.js", "importStyle": null, "description": null, "lineNumber": 77, "undocument": true, "params": [ { "name": "context", "types": [ "*" ] } ], "return": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 465, "kind": "function", "name": "attach", "memberof": "src/renderer/canvas/CanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/CanvasRenderer.js~attach", "access": "public", "export": true, "importPath": "myscript/src/renderer/canvas/CanvasRenderer.js", "importStyle": "{attach}", "description": "Attach the renderer to the DOM element", "lineNumber": 102, "params": [ { "nullable": null, "types": [ "Element" ], "spread": false, "optional": false, "name": "element", "description": "DOM element to attach the rendering elements" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": true, "defaultValue": "0", "defaultRaw": 0, "name": "minHeight", "description": "Minimal height of the editor" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": true, "defaultValue": "0", "defaultRaw": 0, "name": "minWidth", "description": "Minimal width of the editor" } ], "return": { "nullable": null, "types": [ "Object" ], "spread": false, "description": "The renderer context to give as parameter when a draw model will be call" } }, { "__docId__": 466, "kind": "function", "name": "detach", "memberof": "src/renderer/canvas/CanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/CanvasRenderer.js~detach", "access": "public", "export": true, "importPath": "myscript/src/renderer/canvas/CanvasRenderer.js", "importStyle": "{detach}", "description": "Detach the renderer from the DOM element", "lineNumber": 130, "params": [ { "nullable": null, "types": [ "Element" ], "spread": false, "optional": false, "name": "element", "description": "DOM element to attach the rendering elements" }, { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "context", "description": "Current rendering context" } ], "return": null }, { "__docId__": 467, "kind": "function", "name": "resize", "memberof": "src/renderer/canvas/CanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/CanvasRenderer.js~resize", "access": "public", "export": true, "importPath": "myscript/src/renderer/canvas/CanvasRenderer.js", "importStyle": "{resize}", "description": "Update the rendering context size", "lineNumber": 144, "params": [ { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "context", "description": "Current rendering context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "Stroker" ], "spread": false, "optional": false, "name": "stroker", "description": "Current stroker" } ], "return": { "nullable": null, "types": [ "Model" ], "spread": false, "description": "" } }, { "__docId__": 468, "kind": "function", "name": "drawSymbol", "memberof": "src/renderer/canvas/CanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/CanvasRenderer.js~drawSymbol", "access": "public", "export": false, "importPath": "myscript/src/renderer/canvas/CanvasRenderer.js", "importStyle": null, "description": null, "lineNumber": 148, "undocument": true, "params": [ { "name": "context", "types": [ "*" ] }, { "name": "symbol", "types": [ "*" ] }, { "name": "stroker", "types": [ "*" ] } ], "return": null, "ignore": true }, { "__docId__": 469, "kind": "function", "name": "drawCurrentStroke", "memberof": "src/renderer/canvas/CanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/CanvasRenderer.js~drawCurrentStroke", "access": "public", "export": true, "importPath": "myscript/src/renderer/canvas/CanvasRenderer.js", "importStyle": "{drawCurrentStroke}", "description": "Draw the current stroke from the model", "lineNumber": 171, "params": [ { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "context", "description": "Current rendering context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "Stroker" ], "spread": false, "optional": false, "name": "stroker", "description": "Current stroker" } ], "return": { "nullable": null, "types": [ "Model" ], "spread": false, "description": "" } }, { "__docId__": 470, "kind": "function", "name": "drawModel", "memberof": "src/renderer/canvas/CanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/CanvasRenderer.js~drawModel", "access": "public", "export": true, "importPath": "myscript/src/renderer/canvas/CanvasRenderer.js", "importStyle": "{drawModel}", "description": "Draw all symbols contained into the model", "lineNumber": 186, "params": [ { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "context", "description": "Current rendering context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "Stroker" ], "spread": false, "optional": false, "name": "stroker", "description": "Current stroker" } ], "return": { "nullable": null, "types": [ "Model" ], "spread": false, "description": "" } }, { "__docId__": 471, "kind": "file", "name": "src/renderer/canvas/ImageRenderer.js", "content": "import { drawModel } from './CanvasRenderer';\nimport * as InkModel from '../../model/InkModel';\n\nfunction createCanvas(borderCoordinates, margin = 10) {\n // eslint-disable-next-line no-undef\n const browserDocument = document;\n const canvas = browserDocument.createElement('canvas');\n canvas.width = Math.abs(borderCoordinates.maxX - borderCoordinates.minX) + (2 * margin);\n canvas.style.width = `${canvas.width}px`;\n canvas.height = Math.abs(borderCoordinates.maxY - borderCoordinates.minY) + (2 * margin);\n canvas.style.height = `${canvas.height}px`;\n return canvas;\n}\n\n/**\n * Generate a PNG image data url from the model\n * @param {Model} model Current model\n * @param {Stroker} stroker Current stroker\n * @param {Number} [margin=10] Margins to apply around the image\n * @return {String} Image data string result\n */\nexport function getImage(model, stroker, margin = 10) {\n if (model.rawStrokes.length > 0) {\n const borderCoordinates = InkModel.getBorderCoordinates(model);\n\n const capturingCanvas = createCanvas(borderCoordinates, margin);\n const renderingCanvas = createCanvas(borderCoordinates, margin);\n const renderStructure = {\n renderingCanvas,\n renderingCanvasContext: renderingCanvas.getContext('2d'),\n capturingCanvas,\n capturingCanvasContext: capturingCanvas.getContext('2d')\n };\n // Change canvas origin\n renderStructure.renderingCanvasContext.translate(-borderCoordinates.minX + margin, -borderCoordinates.minY + margin);\n drawModel(renderStructure, model, stroker);\n return renderStructure.renderingCanvas.toDataURL('image/png');\n }\n return null;\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/renderer/canvas/ImageRenderer.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 472, "kind": "function", "name": "createCanvas", "memberof": "src/renderer/canvas/ImageRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/ImageRenderer.js~createCanvas", "access": "public", "export": false, "importPath": "myscript/src/renderer/canvas/ImageRenderer.js", "importStyle": null, "description": null, "lineNumber": 4, "undocument": true, "params": [ { "name": "borderCoordinates", "types": [ "*" ] }, { "name": "margin", "optional": true, "types": [ "number" ], "defaultRaw": 10, "defaultValue": "10" } ], "return": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 473, "kind": "function", "name": "getImage", "memberof": "src/renderer/canvas/ImageRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/ImageRenderer.js~getImage", "access": "public", "export": true, "importPath": "myscript/src/renderer/canvas/ImageRenderer.js", "importStyle": "{getImage}", "description": "Generate a PNG image data url from the model", "lineNumber": 22, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "Stroker" ], "spread": false, "optional": false, "name": "stroker", "description": "Current stroker" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": true, "defaultValue": "10", "defaultRaw": 10, "name": "margin", "description": "Margins to apply around the image" } ], "return": { "nullable": null, "types": [ "String" ], "spread": false, "description": "Image data string result" } }, { "__docId__": 474, "kind": "file", "name": "src/renderer/canvas/stroker/QuadraticCanvasStroker.js", "content": "import * as StrokeComponent from '../../../model/StrokeComponent';\nimport { computeLinksPoints, computeMiddlePoint, computeAxeAngle } from '../../QuadraticUtils';\n\n/**\n * Stroker info\n * @typedef {Object} StrokerInfo\n * @property {String} type Renderer type.\n * @property {String} name Stroker name.\n * @property {String} apiVersion Supported api version.\n */\n\n/**\n * Define how a stroke should be drawn\n * @typedef {Object} Stroker\n * @property {function(): StrokerInfo} getInfo Get some information about this stroker\n * @property {function(context: Object, stroke: Stroke)} drawStroke Render a stroke on the current context.\n */\n\n/**\n * Get info\n * @return {StrokerInfo} Information about this stroker\n */\nexport function getInfo() {\n return {\n type: 'canvas',\n name: 'quadratic',\n apiVersion: 'V3'\n };\n}\n\nfunction renderArc(context, center, radius) {\n context.arc(center.x, center.y, radius, 0, Math.PI * 2, true);\n}\n\nfunction renderLine(context, begin, end, width) {\n const linkPoints1 = computeLinksPoints(begin, computeAxeAngle(begin, end), width);\n const linkPoints2 = computeLinksPoints(end, computeAxeAngle(begin, end), width);\n\n context.moveTo(linkPoints1[0].x, linkPoints1[0].y);\n context.lineTo(linkPoints2[0].x, linkPoints2[0].y);\n context.lineTo(linkPoints2[1].x, linkPoints2[1].y);\n context.lineTo(linkPoints1[1].x, linkPoints1[1].y);\n}\n\nfunction renderFinal(context, begin, end, width) {\n const ARCSPLIT = 6;\n const angle = computeAxeAngle(begin, end);\n const linkPoints = computeLinksPoints(end, angle, width);\n context.moveTo(linkPoints[0].x, linkPoints[0].y);\n for (let i = 1; i <= ARCSPLIT; i++) {\n const newAngle = angle - ((i * Math.PI) / ARCSPLIT);\n context.lineTo(end.x - ((end.p * width) * Math.sin(newAngle)), end.y + (end.p * width * Math.cos(newAngle)));\n }\n}\n\nfunction renderQuadratic(context, begin, end, ctrl, width) {\n const linkPoints1 = computeLinksPoints(begin, computeAxeAngle(begin, ctrl), width);\n const linkPoints2 = computeLinksPoints(end, computeAxeAngle(ctrl, end), width);\n const linkPoints3 = computeLinksPoints(ctrl, computeAxeAngle(begin, end), width);\n\n context.moveTo(linkPoints1[0].x, linkPoints1[0].y);\n context.quadraticCurveTo(linkPoints3[0].x, linkPoints3[0].y, linkPoints2[0].x, linkPoints2[0].y);\n context.lineTo(linkPoints2[1].x, linkPoints2[1].y);\n context.quadraticCurveTo(linkPoints3[1].x, linkPoints3[1].y, linkPoints1[1].x, linkPoints1[1].y);\n}\n\n/**\n * Draw a stroke on a canvas, using quadratics\n * @param {Object} context Current rendering context\n * @param {Stroke} stroke Current stroke to be drawn\n */\nexport function drawStroke(context, stroke) {\n const contextReference = context;\n const length = stroke.x.length;\n const width = stroke.width > 0 ? stroke.width : contextReference.lineWidth;\n const color = stroke.color ? stroke.color : contextReference.strokeStyle;\n const firstPoint = StrokeComponent.getPointByIndex(stroke, 0);\n const nbquadratics = length - 2;\n\n contextReference.save();\n try {\n contextReference.beginPath();\n if (length < 3) {\n renderArc(contextReference, firstPoint, width * 0.6);\n } else {\n renderArc(contextReference, firstPoint, width * firstPoint.p);\n renderLine(contextReference, firstPoint, computeMiddlePoint(firstPoint, StrokeComponent.getPointByIndex(stroke, 1)), width);\n\n // Possibility to try this (the start looks better when the ink is large)\n // var first = computeMiddlePoint(stroke[0], stroke[1]);\n // contextReference.arc(first.x, first.y, width * first.p, 0, Math.PI * 2, true);\n\n for (let i = 0; i < nbquadratics; i++) {\n renderQuadratic(contextReference, computeMiddlePoint(StrokeComponent.getPointByIndex(stroke, i), StrokeComponent.getPointByIndex(stroke, i + 1)), computeMiddlePoint(StrokeComponent.getPointByIndex(stroke, i + 1), StrokeComponent.getPointByIndex(stroke, i + 2)), StrokeComponent.getPointByIndex(stroke, i + 1), width);\n }\n renderLine(contextReference, computeMiddlePoint(StrokeComponent.getPointByIndex(stroke, length - 2), StrokeComponent.getPointByIndex(stroke, length - 1)), StrokeComponent.getPointByIndex(stroke, length - 1), width);\n renderFinal(contextReference, StrokeComponent.getPointByIndex(stroke, length - 2), StrokeComponent.getPointByIndex(stroke, length - 1), width);\n }\n contextReference.closePath();\n if (color !== undefined) {\n contextReference.fillStyle = color;\n contextReference.fill();\n }\n } finally {\n contextReference.restore();\n }\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/renderer/canvas/stroker/QuadraticCanvasStroker.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 475, "kind": "typedef", "name": "StrokerInfo", "memberof": "src/renderer/canvas/stroker/QuadraticCanvasStroker.js", "static": true, "longname": "src/renderer/canvas/stroker/QuadraticCanvasStroker.js~StrokerInfo", "access": "public", "description": "Stroker info", "properties": [ { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "type", "description": "Renderer type." }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "name", "description": "Stroker name." }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "apiVersion", "description": "Supported api version." } ], "type": { "types": [ "Object" ], "optional": false, "name": "StrokerInfo" } }, { "__docId__": 476, "kind": "typedef", "name": "Stroker", "memberof": "src/renderer/canvas/stroker/QuadraticCanvasStroker.js", "static": true, "longname": "src/renderer/canvas/stroker/QuadraticCanvasStroker.js~Stroker", "access": "public", "description": "Define how a stroke should be drawn", "properties": [ { "nullable": null, "types": [ "function(): StrokerInfo" ], "spread": false, "optional": false, "name": "getInfo", "description": "Get some information about this stroker" }, { "nullable": null, "types": [ "function(context: Object, stroke: Stroke)" ], "spread": false, "optional": false, "name": "drawStroke", "description": "Render a stroke on the current context." } ], "type": { "types": [ "Object" ], "optional": false, "name": "Stroker" } }, { "__docId__": 477, "kind": "function", "name": "getInfo", "memberof": "src/renderer/canvas/stroker/QuadraticCanvasStroker.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/stroker/QuadraticCanvasStroker.js~getInfo", "access": "public", "export": true, "importPath": "myscript/src/renderer/canvas/stroker/QuadraticCanvasStroker.js", "importStyle": "{getInfo}", "description": "Get info", "lineNumber": 23, "return": { "nullable": null, "types": [ "StrokerInfo" ], "spread": false, "description": "Information about this stroker" }, "params": [] }, { "__docId__": 478, "kind": "function", "name": "renderArc", "memberof": "src/renderer/canvas/stroker/QuadraticCanvasStroker.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/stroker/QuadraticCanvasStroker.js~renderArc", "access": "public", "export": false, "importPath": "myscript/src/renderer/canvas/stroker/QuadraticCanvasStroker.js", "importStyle": null, "description": null, "lineNumber": 31, "undocument": true, "params": [ { "name": "context", "types": [ "*" ] }, { "name": "center", "types": [ "*" ] }, { "name": "radius", "types": [ "*" ] } ], "return": null, "ignore": true }, { "__docId__": 479, "kind": "function", "name": "renderLine", "memberof": "src/renderer/canvas/stroker/QuadraticCanvasStroker.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/stroker/QuadraticCanvasStroker.js~renderLine", "access": "public", "export": false, "importPath": "myscript/src/renderer/canvas/stroker/QuadraticCanvasStroker.js", "importStyle": null, "description": null, "lineNumber": 35, "undocument": true, "params": [ { "name": "context", "types": [ "*" ] }, { "name": "begin", "types": [ "*" ] }, { "name": "end", "types": [ "*" ] }, { "name": "width", "types": [ "*" ] } ], "return": null, "ignore": true }, { "__docId__": 480, "kind": "function", "name": "renderFinal", "memberof": "src/renderer/canvas/stroker/QuadraticCanvasStroker.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/stroker/QuadraticCanvasStroker.js~renderFinal", "access": "public", "export": false, "importPath": "myscript/src/renderer/canvas/stroker/QuadraticCanvasStroker.js", "importStyle": null, "description": null, "lineNumber": 45, "undocument": true, "params": [ { "name": "context", "types": [ "*" ] }, { "name": "begin", "types": [ "*" ] }, { "name": "end", "types": [ "*" ] }, { "name": "width", "types": [ "*" ] } ], "return": null, "ignore": true }, { "__docId__": 481, "kind": "function", "name": "renderQuadratic", "memberof": "src/renderer/canvas/stroker/QuadraticCanvasStroker.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/stroker/QuadraticCanvasStroker.js~renderQuadratic", "access": "public", "export": false, "importPath": "myscript/src/renderer/canvas/stroker/QuadraticCanvasStroker.js", "importStyle": null, "description": null, "lineNumber": 56, "undocument": true, "params": [ { "name": "context", "types": [ "*" ] }, { "name": "begin", "types": [ "*" ] }, { "name": "end", "types": [ "*" ] }, { "name": "ctrl", "types": [ "*" ] }, { "name": "width", "types": [ "*" ] } ], "return": null, "ignore": true }, { "__docId__": 482, "kind": "function", "name": "drawStroke", "memberof": "src/renderer/canvas/stroker/QuadraticCanvasStroker.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/stroker/QuadraticCanvasStroker.js~drawStroke", "access": "public", "export": true, "importPath": "myscript/src/renderer/canvas/stroker/QuadraticCanvasStroker.js", "importStyle": "{drawStroke}", "description": "Draw a stroke on a canvas, using quadratics", "lineNumber": 72, "params": [ { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "context", "description": "Current rendering context" }, { "nullable": null, "types": [ "Stroke" ], "spread": false, "optional": false, "name": "stroke", "description": "Current stroke to be drawn" } ], "return": null }, { "__docId__": 483, "kind": "file", "name": "src/renderer/canvas/symbols/MathSymbolCanvasRenderer.js", "content": "import { rendererLogger as logger } from '../../../configuration/LoggerConfig';\nimport { drawStroke } from './StrokeSymbolCanvasRenderer';\nimport * as InkModel from '../../../model/InkModel';\n\n/**\n * @type {{inputCharacter: String, char: String, string: String, textLine: String}}\n */\nexport const MathSymbols = {\n nonTerminalNode: 'nonTerminalNode',\n terminalNode: 'terminalNode',\n rule: 'rule'\n};\n\nfunction drawTerminalNode(context, terminalNode, model, stroker) {\n terminalNode.inkRanges.forEach((inkRange) => {\n InkModel.extractStrokesFromInkRange(model, inkRange.component, inkRange.component, inkRange.firstItem, inkRange.lastItem)\n .forEach(stroke => drawStroke(context, stroke, stroker));\n });\n}\n\n/**\n * Draw a math symbol\n * @param {Object} context Current rendering context\n * @param {Object} symbol Symbol to draw\n * @param {Model} model Current model\n * @param {Stroker} stroker Stroker to use to render a stroke\n */\nexport function drawMathSymbol(context, symbol, model, stroker) {\n logger.debug(`draw ${symbol.type} text input`);\n const contextReference = context;\n contextReference.save();\n try {\n contextReference.lineWidth = symbol.width;\n contextReference.strokeStyle = symbol.color;\n\n switch (symbol.type) {\n case MathSymbols.nonTerminalNode:\n drawMathSymbol(contextReference, symbol.candidates[symbol.selectedCandidate], model, stroker);\n break;\n case MathSymbols.terminalNode:\n drawTerminalNode(contextReference, symbol, model, stroker);\n break;\n case MathSymbols.rule:\n symbol.children.forEach(child => drawMathSymbol(contextReference, child, model, stroker));\n break;\n default:\n logger.error(`${symbol.type} not implemented`);\n }\n } finally {\n contextReference.restore();\n }\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/renderer/canvas/symbols/MathSymbolCanvasRenderer.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 484, "kind": "variable", "name": "MathSymbols", "memberof": "src/renderer/canvas/symbols/MathSymbolCanvasRenderer.js", "static": true, "longname": "src/renderer/canvas/symbols/MathSymbolCanvasRenderer.js~MathSymbols", "access": "public", "export": true, "importPath": "myscript/src/renderer/canvas/symbols/MathSymbolCanvasRenderer.js", "importStyle": "{MathSymbols}", "description": "", "lineNumber": 8, "type": { "nullable": null, "types": [ "{inputCharacter: String, char: String, string: String, textLine: String}" ], "spread": false, "description": null } }, { "__docId__": 485, "kind": "function", "name": "drawTerminalNode", "memberof": "src/renderer/canvas/symbols/MathSymbolCanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/symbols/MathSymbolCanvasRenderer.js~drawTerminalNode", "access": "public", "export": false, "importPath": "myscript/src/renderer/canvas/symbols/MathSymbolCanvasRenderer.js", "importStyle": null, "description": null, "lineNumber": 14, "undocument": true, "params": [ { "name": "context", "types": [ "*" ] }, { "name": "terminalNode", "types": [ "*" ] }, { "name": "model", "types": [ "*" ] }, { "name": "stroker", "types": [ "*" ] } ], "return": null, "ignore": true }, { "__docId__": 486, "kind": "function", "name": "drawMathSymbol", "memberof": "src/renderer/canvas/symbols/MathSymbolCanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/symbols/MathSymbolCanvasRenderer.js~drawMathSymbol", "access": "public", "export": true, "importPath": "myscript/src/renderer/canvas/symbols/MathSymbolCanvasRenderer.js", "importStyle": "{drawMathSymbol}", "description": "Draw a math symbol", "lineNumber": 28, "params": [ { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "context", "description": "Current rendering context" }, { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "symbol", "description": "Symbol to draw" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "Stroker" ], "spread": false, "optional": false, "name": "stroker", "description": "Stroker to use to render a stroke" } ], "return": null }, { "__docId__": 487, "kind": "file", "name": "src/renderer/canvas/symbols/MusicSymbolCanvasRenderer.js", "content": "import { rendererLogger as logger } from '../../../configuration/LoggerConfig';\nimport { drawLine } from './ShapeSymbolCanvasRenderer';\n\n/**\n * @type {{F: {svg: String, getBoundingBox: function}, C: {svg: String, getBoundingBox: function}, G: {svg: String, getBoundingBox: function}}}\n */\nexport const MusicClefs = { // constants was calculated from the svg image, so it should remains together\n F: {\n svg: '',\n getBoundingBox: (gap, xAnchor, yAnchor) => ({\n height: gap * 3,\n width: (gap * 3) * (18 / 20),\n x: xAnchor,\n y: yAnchor - gap\n })\n },\n C: {\n svg: '',\n getBoundingBox: (gap, xAnchor, yAnchor) => ({\n height: gap * 3,\n width: (gap * 3) * (18 / 25),\n x: xAnchor,\n y: yAnchor - (gap * (3 / 2))\n })\n },\n G: {\n svg: '',\n getBoundingBox: (gap, xAnchor, yAnchor) => ({\n height: gap * (15 / 2),\n width: (gap * (15 / 2)) * (15 / 40),\n x: xAnchor,\n y: yAnchor - (gap * (9 / 2))\n })\n }\n};\n\n/**\n * @type {{accidental: String, arpeggiate: String, bar: String, beam: String, clef: String, decoration: String, dots: String, head: String, ledgerLine: String, rest: String, staff: String, stem: String, tieOrSlur: String, timeSignature: String}}\n */\nexport const MusicSymbols = {\n accidental: 'accidental',\n arpeggiate: 'arpeggiate',\n bar: 'bar',\n beam: 'beam',\n clef: 'clef',\n decoration: 'decoration',\n dots: 'dots',\n head: 'head',\n ledgerLine: 'ledgerLine',\n rest: 'rest',\n staff: 'staff',\n stem: 'stem',\n tieOrSlur: 'tieOrSlur',\n timeSignature: 'timeSignature',\n};\n\nfunction createImage(clef, src) {\n // eslint-disable-next-line no-undef\n const browserDocument = document;\n const img = browserDocument.createElement('img');\n img.dataset.clef = clef;\n img.src = src;\n img.style.display = 'none';\n return img;\n}\n\n/**\n * Retrieve music symbols elements\n * @return {Array} music symbols elements to attach\n */\nexport function getMusicClefElements() {\n return Object.keys(MusicClefs)\n .map(key => createImage(key, `data:image/svg+xml,${MusicClefs[key].svg}`));\n}\n\nfunction drawStaff(context, staff) {\n for (let i = 0; i < staff.count; i++) {\n const p1 = { x: 0, y: staff.top + (i * staff.gap) };\n const p2 = { x: context.canvas.width, y: staff.top + (i * staff.gap) };\n drawLine(context, p1, p2);\n }\n}\n\nfunction drawClef(context, clef) {\n // eslint-disable-next-line no-undef\n context.drawImage(context.canvas.parentElement.querySelector(`img[data-clef=${clef.value.symbol}]`), clef.boundingBox.x, clef.boundingBox.y, clef.boundingBox.width, clef.boundingBox.height);\n}\n\n/**\n * Draw a music symbol\n * @param {Object} context Current rendering context\n * @param {Object} symbol Symbol to draw\n */\nexport function drawMusicSymbol(context, symbol) {\n logger.debug(`draw ${symbol.type} symbol`);\n switch (symbol.type) {\n case MusicSymbols.clef:\n drawClef(context, symbol);\n break;\n case MusicSymbols.staff:\n drawStaff(context, symbol);\n break;\n default:\n logger.error(`${symbol.type} not implemented`);\n }\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/renderer/canvas/symbols/MusicSymbolCanvasRenderer.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 488, "kind": "variable", "name": "MusicClefs", "memberof": "src/renderer/canvas/symbols/MusicSymbolCanvasRenderer.js", "static": true, "longname": "src/renderer/canvas/symbols/MusicSymbolCanvasRenderer.js~MusicClefs", "access": "public", "export": true, "importPath": "myscript/src/renderer/canvas/symbols/MusicSymbolCanvasRenderer.js", "importStyle": "{MusicClefs}", "description": "", "lineNumber": 7, "type": { "nullable": null, "types": [ "{F: {svg: String, getBoundingBox: function}, C: {svg: String, getBoundingBox: function}, G: {svg: String, getBoundingBox: function}}" ], "spread": false, "description": null } }, { "__docId__": 489, "kind": "variable", "name": "MusicSymbols", "memberof": "src/renderer/canvas/symbols/MusicSymbolCanvasRenderer.js", "static": true, "longname": "src/renderer/canvas/symbols/MusicSymbolCanvasRenderer.js~MusicSymbols", "access": "public", "export": true, "importPath": "myscript/src/renderer/canvas/symbols/MusicSymbolCanvasRenderer.js", "importStyle": "{MusicSymbols}", "description": "", "lineNumber": 40, "type": { "nullable": null, "types": [ "{accidental: String, arpeggiate: String, bar: String, beam: String, clef: String, decoration: String, dots: String, head: String, ledgerLine: String, rest: String, staff: String, stem: String, tieOrSlur: String, timeSignature: String}" ], "spread": false, "description": null } }, { "__docId__": 490, "kind": "function", "name": "createImage", "memberof": "src/renderer/canvas/symbols/MusicSymbolCanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/symbols/MusicSymbolCanvasRenderer.js~createImage", "access": "public", "export": false, "importPath": "myscript/src/renderer/canvas/symbols/MusicSymbolCanvasRenderer.js", "importStyle": null, "description": null, "lineNumber": 57, "undocument": true, "params": [ { "name": "clef", "types": [ "*" ] }, { "name": "src", "types": [ "*" ] } ], "return": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 491, "kind": "function", "name": "getMusicClefElements", "memberof": "src/renderer/canvas/symbols/MusicSymbolCanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/symbols/MusicSymbolCanvasRenderer.js~getMusicClefElements", "access": "public", "export": true, "importPath": "myscript/src/renderer/canvas/symbols/MusicSymbolCanvasRenderer.js", "importStyle": "{getMusicClefElements}", "description": "Retrieve music symbols elements", "lineNumber": 71, "return": { "nullable": null, "types": [ "Array" ], "spread": false, "description": "music symbols elements to attach" }, "params": [] }, { "__docId__": 492, "kind": "function", "name": "drawStaff", "memberof": "src/renderer/canvas/symbols/MusicSymbolCanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/symbols/MusicSymbolCanvasRenderer.js~drawStaff", "access": "public", "export": false, "importPath": "myscript/src/renderer/canvas/symbols/MusicSymbolCanvasRenderer.js", "importStyle": null, "description": null, "lineNumber": 76, "undocument": true, "params": [ { "name": "context", "types": [ "*" ] }, { "name": "staff", "types": [ "*" ] } ], "return": null, "ignore": true }, { "__docId__": 493, "kind": "function", "name": "drawClef", "memberof": "src/renderer/canvas/symbols/MusicSymbolCanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/symbols/MusicSymbolCanvasRenderer.js~drawClef", "access": "public", "export": false, "importPath": "myscript/src/renderer/canvas/symbols/MusicSymbolCanvasRenderer.js", "importStyle": null, "description": null, "lineNumber": 84, "undocument": true, "params": [ { "name": "context", "types": [ "*" ] }, { "name": "clef", "types": [ "*" ] } ], "return": null, "ignore": true }, { "__docId__": 494, "kind": "function", "name": "drawMusicSymbol", "memberof": "src/renderer/canvas/symbols/MusicSymbolCanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/symbols/MusicSymbolCanvasRenderer.js~drawMusicSymbol", "access": "public", "export": true, "importPath": "myscript/src/renderer/canvas/symbols/MusicSymbolCanvasRenderer.js", "importStyle": "{drawMusicSymbol}", "description": "Draw a music symbol", "lineNumber": 94, "params": [ { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "context", "description": "Current rendering context" }, { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "symbol", "description": "Symbol to draw" } ], "return": null }, { "__docId__": 495, "kind": "file", "name": "src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js", "content": "import { rendererLogger as logger } from '../../../configuration/LoggerConfig';\n\n/**\n * @type {{table: String, shape: String, recognizedShape: String, ellipse: String, line: String}}\n */\nexport const ShapeSymbols = {\n table: 'table',\n shape: 'shape',\n recognizedShape: 'recognizedShape',\n ellipse: 'ellipse',\n line: 'line'\n};\n\nfunction phi(angle) {\n let returnedAngle = ((angle + Math.PI) % (Math.PI * 2)) - Math.PI;\n if (returnedAngle < -Math.PI) {\n returnedAngle += Math.PI * 2;\n }\n return returnedAngle;\n}\n\nfunction drawEllipseArc(context, centerPoint, maxRadius, minRadius, orientation, startAngle, sweepAngle) {\n const angleStep = 0.02; // angle delta between interpolated\n\n let z1 = Math.cos(orientation);\n let z3 = Math.sin(orientation);\n let z2 = z1;\n let z4 = z3;\n z1 *= maxRadius;\n z2 *= minRadius;\n z3 *= maxRadius;\n z4 *= minRadius;\n\n const n = Math.floor(Math.abs(sweepAngle) / angleStep);\n\n const boundariesPoints = [];\n\n context.save();\n try {\n context.beginPath();\n\n for (let i = 0; i <= n; i++) {\n const angle = startAngle + ((i / n) * sweepAngle); // points on the arc, in radian\n const alpha = Math.atan2(Math.sin(angle) / minRadius, Math.cos(angle) / maxRadius);\n\n const cosAlpha = Math.cos(alpha);\n const sinAlpha = Math.sin(alpha);\n\n // current point\n const x = (centerPoint.x + (z1 * cosAlpha)) - (z4 * sinAlpha);\n const y = (centerPoint.y + (z2 * sinAlpha)) + (z3 * cosAlpha);\n if (i === 0) {\n context.moveTo(x, y);\n } else {\n context.lineTo(x, y);\n }\n\n if (i === 0 || i === n) {\n boundariesPoints.push({ x, y });\n }\n }\n\n context.stroke();\n } finally {\n context.restore();\n }\n\n return boundariesPoints;\n}\n\nfunction drawArrowHead(context, headPoint, angle, length) {\n const alpha = phi(angle + (Math.PI * (7 / 8)));\n const beta = phi(angle - (Math.PI * (7 / 8)));\n\n const contextReference = context;\n contextReference.save();\n try {\n contextReference.fillStyle = contextReference.strokeStyle;\n\n contextReference.moveTo(headPoint.x, headPoint.y);\n contextReference.beginPath();\n contextReference.lineTo(headPoint.x + (length * Math.cos(alpha)), headPoint.y + (length * Math.sin(alpha)));\n contextReference.lineTo(headPoint.x + (length * Math.cos(beta)), headPoint.y + (length * Math.sin(beta)));\n contextReference.lineTo(headPoint.x, headPoint.y);\n contextReference.fill();\n } finally {\n contextReference.restore();\n }\n}\n\nfunction drawShapeEllipse(context, shapeEllipse) {\n const points = drawEllipseArc(\n context,\n shapeEllipse.center,\n shapeEllipse.maxRadius,\n shapeEllipse.minRadius,\n shapeEllipse.orientation,\n shapeEllipse.startAngle,\n shapeEllipse.sweepAngle);\n\n if (shapeEllipse.beginDecoration && shapeEllipse.beginDecoration === 'ARROW_HEAD') {\n drawArrowHead(context, points[0], shapeEllipse.beginTangentAngle, 12.0);\n }\n if (shapeEllipse.endDecoration && shapeEllipse.endDecoration === 'ARROW_HEAD') {\n drawArrowHead(context, points[1], shapeEllipse.endTangentAngle, 12.0);\n }\n}\n\n/**\n * Draw a line\n * @param {Object} context Current rendering context\n * @param {{x: Number, y: Number}} p1 Origin point\n * @param {{x: Number, y: Number}} p2 Destination point\n */\nexport function drawLine(context, p1, p2) {\n context.save();\n try {\n context.beginPath();\n context.moveTo(p1.x, p1.y);\n context.lineTo(p2.x, p2.y);\n context.stroke();\n } finally {\n context.restore();\n }\n}\n\nfunction drawShapeLine(context, shapeLine) {\n drawLine(context, shapeLine.firstPoint, shapeLine.lastPoint);\n if (shapeLine.beginDecoration === 'ARROW_HEAD') {\n drawArrowHead(context, shapeLine.firstPoint, shapeLine.beginTangentAngle, 12.0);\n }\n if (shapeLine.endDecoration === 'ARROW_HEAD') {\n drawArrowHead(context, shapeLine.lastPoint, shapeLine.endTangentAngle, 12.0);\n }\n}\n\n/**\n * Draw a shape symbol\n * @param {Object} context Current rendering context\n * @param {Object} symbol Symbol to draw\n */\nexport function drawShapeSymbol(context, symbol) {\n logger.debug(`draw ${symbol.type} symbol`);\n const contextReference = context;\n contextReference.save();\n try {\n contextReference.lineWidth = symbol.width;\n contextReference.strokeStyle = symbol.color;\n\n if (symbol.elementType) {\n switch (symbol.elementType) {\n case ShapeSymbols.shape:\n drawShapeSymbol(contextReference, symbol.candidates[symbol.selectedCandidateIndex]);\n break;\n case ShapeSymbols.table:\n symbol.lines.forEach(line => drawShapeSymbol(contextReference, line));\n break;\n case ShapeSymbols.line:\n drawLine(contextReference, symbol.data.p1, symbol.data.p2);\n break;\n default:\n logger.error(`${symbol.elementType} not implemented`);\n break;\n }\n } else {\n switch (symbol.type) {\n case ShapeSymbols.ellipse:\n drawShapeEllipse(contextReference, symbol);\n break;\n case ShapeSymbols.line:\n drawShapeLine(contextReference, symbol);\n break;\n case ShapeSymbols.recognizedShape:\n symbol.primitives.forEach(primitive => drawShapeSymbol(contextReference, primitive));\n break;\n default:\n logger.error(`${symbol.type} not implemented`);\n break;\n }\n }\n } finally {\n contextReference.restore();\n }\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 496, "kind": "variable", "name": "ShapeSymbols", "memberof": "src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js", "static": true, "longname": "src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js~ShapeSymbols", "access": "public", "export": true, "importPath": "myscript/src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js", "importStyle": "{ShapeSymbols}", "description": "", "lineNumber": 6, "type": { "nullable": null, "types": [ "{table: String, shape: String, recognizedShape: String, ellipse: String, line: String}" ], "spread": false, "description": null } }, { "__docId__": 497, "kind": "function", "name": "phi", "memberof": "src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js~phi", "access": "public", "export": false, "importPath": "myscript/src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js", "importStyle": null, "description": null, "lineNumber": 14, "undocument": true, "params": [ { "name": "angle", "types": [ "*" ] } ], "return": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 498, "kind": "function", "name": "drawEllipseArc", "memberof": "src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js~drawEllipseArc", "access": "public", "export": false, "importPath": "myscript/src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js", "importStyle": null, "description": null, "lineNumber": 22, "undocument": true, "params": [ { "name": "context", "types": [ "*" ] }, { "name": "centerPoint", "types": [ "*" ] }, { "name": "maxRadius", "types": [ "*" ] }, { "name": "minRadius", "types": [ "*" ] }, { "name": "orientation", "types": [ "*" ] }, { "name": "startAngle", "types": [ "*" ] }, { "name": "sweepAngle", "types": [ "*" ] } ], "return": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 499, "kind": "function", "name": "drawArrowHead", "memberof": "src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js~drawArrowHead", "access": "public", "export": false, "importPath": "myscript/src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js", "importStyle": null, "description": null, "lineNumber": 71, "undocument": true, "params": [ { "name": "context", "types": [ "*" ] }, { "name": "headPoint", "types": [ "*" ] }, { "name": "angle", "types": [ "*" ] }, { "name": "length", "types": [ "*" ] } ], "return": null, "ignore": true }, { "__docId__": 500, "kind": "function", "name": "drawShapeEllipse", "memberof": "src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js~drawShapeEllipse", "access": "public", "export": false, "importPath": "myscript/src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js", "importStyle": null, "description": null, "lineNumber": 91, "undocument": true, "params": [ { "name": "context", "types": [ "*" ] }, { "name": "shapeEllipse", "types": [ "*" ] } ], "return": null, "ignore": true }, { "__docId__": 501, "kind": "function", "name": "drawLine", "memberof": "src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js~drawLine", "access": "public", "export": true, "importPath": "myscript/src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js", "importStyle": "{drawLine}", "description": "Draw a line", "lineNumber": 115, "params": [ { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "context", "description": "Current rendering context" }, { "nullable": null, "types": [ "{x: Number, y: Number}" ], "spread": false, "optional": false, "name": "p1", "description": "Origin point" }, { "nullable": null, "types": [ "{x: Number, y: Number}" ], "spread": false, "optional": false, "name": "p2", "description": "Destination point" } ], "return": null }, { "__docId__": 502, "kind": "function", "name": "drawShapeLine", "memberof": "src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js~drawShapeLine", "access": "public", "export": false, "importPath": "myscript/src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js", "importStyle": null, "description": null, "lineNumber": 127, "undocument": true, "params": [ { "name": "context", "types": [ "*" ] }, { "name": "shapeLine", "types": [ "*" ] } ], "return": null, "ignore": true }, { "__docId__": 503, "kind": "function", "name": "drawShapeSymbol", "memberof": "src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js~drawShapeSymbol", "access": "public", "export": true, "importPath": "myscript/src/renderer/canvas/symbols/ShapeSymbolCanvasRenderer.js", "importStyle": "{drawShapeSymbol}", "description": "Draw a shape symbol", "lineNumber": 142, "params": [ { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "context", "description": "Current rendering context" }, { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "symbol", "description": "Symbol to draw" } ], "return": null }, { "__docId__": 504, "kind": "file", "name": "src/renderer/canvas/symbols/StrokeSymbolCanvasRenderer.js", "content": "/**\n * Draw a stroke symbol\n * @param {Object} context Current rendering context\n * @param {Stroke} stroke Stroke to be drawn\n * @param {Stroker} stroker Stroker to use to render a stroke\n */\nexport function drawStroke(context, stroke, stroker) {\n if (stroker) {\n stroker.drawStroke(context, stroke);\n }\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/renderer/canvas/symbols/StrokeSymbolCanvasRenderer.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 505, "kind": "function", "name": "drawStroke", "memberof": "src/renderer/canvas/symbols/StrokeSymbolCanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/symbols/StrokeSymbolCanvasRenderer.js~drawStroke", "access": "public", "export": true, "importPath": "myscript/src/renderer/canvas/symbols/StrokeSymbolCanvasRenderer.js", "importStyle": "{drawStroke}", "description": "Draw a stroke symbol", "lineNumber": 7, "params": [ { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "context", "description": "Current rendering context" }, { "nullable": null, "types": [ "Stroke" ], "spread": false, "optional": false, "name": "stroke", "description": "Stroke to be drawn" }, { "nullable": null, "types": [ "Stroker" ], "spread": false, "optional": false, "name": "stroker", "description": "Stroker to use to render a stroke" } ], "return": null }, { "__docId__": 506, "kind": "file", "name": "src/renderer/canvas/symbols/TextSymbolCanvasRenderer.js", "content": "import { rendererLogger as logger } from '../../../configuration/LoggerConfig';\nimport { drawLine } from './ShapeSymbolCanvasRenderer';\n\n/**\n * @type {{inputCharacter: String, char: String, string: String, textLine: String}}\n */\nexport const TextSymbols = {\n inputCharacter: 'inputCharacter',\n char: 'char',\n string: 'string',\n textLine: 'textLine'\n};\n\nfunction drawUnderline(context, underline, label, data) {\n const delta = data.width / label.length;\n const p1 = {\n x: data.topLeftPoint.x + (underline.data.firstCharacter * delta),\n y: data.topLeftPoint.y + data.height\n };\n const p2 = {\n x: data.topLeftPoint.x + (underline.data.lastCharacter * delta),\n y: data.topLeftPoint.y + data.height\n };\n drawLine(context, p1, p2);\n}\n\nfunction drawText(context, label, data) {\n const contextReference = context;\n contextReference.save();\n try {\n contextReference.font = `${data.textHeight}px serif`;\n contextReference.textAlign = (data.justificationType === 'CENTER') ? 'center' : 'left';\n contextReference.textBaseline = 'bottom';\n contextReference.fillStyle = contextReference.strokeStyle;\n contextReference.fillText(label, data.topLeftPoint.x, (data.topLeftPoint.y + data.height));\n } finally {\n contextReference.restore();\n }\n}\n\nfunction drawTextLine(context, textLine) {\n drawText(context, textLine.label, textLine.data);\n textLine.underlineList.forEach((underline) => {\n drawUnderline(context, underline, textLine.label, textLine.data);\n });\n}\n\n/**\n * Draw a text symbol\n * @param {Object} context Current rendering context\n * @param {Object} symbol Symbol to draw\n */\nexport function drawTextSymbol(context, symbol) {\n logger.debug(`draw ${symbol.type} symbol`);\n const contextReference = context;\n contextReference.save();\n try {\n contextReference.lineWidth = symbol.width;\n contextReference.strokeStyle = symbol.color;\n\n if (symbol.elementType) {\n switch (symbol.elementType) {\n case TextSymbols.textLine:\n drawTextLine(contextReference, symbol);\n break;\n default:\n logger.error(`${symbol.elementType} not implemented`);\n break;\n }\n } else {\n switch (symbol.type) {\n case TextSymbols.textLine:\n drawTextLine(contextReference, symbol);\n break;\n default:\n logger.error(`${symbol.type} not implemented`);\n }\n }\n } finally {\n contextReference.restore();\n }\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/renderer/canvas/symbols/TextSymbolCanvasRenderer.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 507, "kind": "variable", "name": "TextSymbols", "memberof": "src/renderer/canvas/symbols/TextSymbolCanvasRenderer.js", "static": true, "longname": "src/renderer/canvas/symbols/TextSymbolCanvasRenderer.js~TextSymbols", "access": "public", "export": true, "importPath": "myscript/src/renderer/canvas/symbols/TextSymbolCanvasRenderer.js", "importStyle": "{TextSymbols}", "description": "", "lineNumber": 7, "type": { "nullable": null, "types": [ "{inputCharacter: String, char: String, string: String, textLine: String}" ], "spread": false, "description": null } }, { "__docId__": 508, "kind": "function", "name": "drawUnderline", "memberof": "src/renderer/canvas/symbols/TextSymbolCanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/symbols/TextSymbolCanvasRenderer.js~drawUnderline", "access": "public", "export": false, "importPath": "myscript/src/renderer/canvas/symbols/TextSymbolCanvasRenderer.js", "importStyle": null, "description": null, "lineNumber": 14, "undocument": true, "params": [ { "name": "context", "types": [ "*" ] }, { "name": "underline", "types": [ "*" ] }, { "name": "label", "types": [ "*" ] }, { "name": "data", "types": [ "*" ] } ], "return": null, "ignore": true }, { "__docId__": 509, "kind": "function", "name": "drawText", "memberof": "src/renderer/canvas/symbols/TextSymbolCanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/symbols/TextSymbolCanvasRenderer.js~drawText", "access": "public", "export": false, "importPath": "myscript/src/renderer/canvas/symbols/TextSymbolCanvasRenderer.js", "importStyle": null, "description": null, "lineNumber": 27, "undocument": true, "params": [ { "name": "context", "types": [ "*" ] }, { "name": "label", "types": [ "*" ] }, { "name": "data", "types": [ "*" ] } ], "return": null, "ignore": true }, { "__docId__": 510, "kind": "function", "name": "drawTextLine", "memberof": "src/renderer/canvas/symbols/TextSymbolCanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/symbols/TextSymbolCanvasRenderer.js~drawTextLine", "access": "public", "export": false, "importPath": "myscript/src/renderer/canvas/symbols/TextSymbolCanvasRenderer.js", "importStyle": null, "description": null, "lineNumber": 41, "undocument": true, "params": [ { "name": "context", "types": [ "*" ] }, { "name": "textLine", "types": [ "*" ] } ], "return": null, "ignore": true }, { "__docId__": 511, "kind": "function", "name": "drawTextSymbol", "memberof": "src/renderer/canvas/symbols/TextSymbolCanvasRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/canvas/symbols/TextSymbolCanvasRenderer.js~drawTextSymbol", "access": "public", "export": true, "importPath": "myscript/src/renderer/canvas/symbols/TextSymbolCanvasRenderer.js", "importStyle": "{drawTextSymbol}", "description": "Draw a text symbol", "lineNumber": 53, "params": [ { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "context", "description": "Current rendering context" }, { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "symbol", "description": "Symbol to draw" } ], "return": null }, { "__docId__": 512, "kind": "file", "name": "src/renderer/svg/SVGRenderer.js", "content": "import * as d3 from 'd3-selection';\nimport { rendererLogger as logger } from '../../configuration/LoggerConfig';\nimport { drawStroke } from './symbols/StrokeSymbolSVGRenderer';\nimport * as InkModel from '../../model/InkModel';\n\n\n/**\n * Get info\n * @return {RendererInfo} Information about this renderer\n */\nexport function getInfo() {\n return {\n type: 'svg',\n apiVersion: 'V4'\n };\n}\n\n/**\n * Populate the dom element\n * @param {Element} element DOM element to attach the rendering elements\n * @return {Object} The renderer context to give as parameter when a draw model will be call\n */\nexport function attach(element) {\n const elementRef = element;\n logger.debug('populate root element', elementRef);\n elementRef.style.fontSize = '10px';\n return d3.select(elementRef);\n}\n\n/**\n * Detach the renderer from the DOM element\n * @param {Element} element DOM element to attach the rendering elements\n * @param {Object} context Current rendering context\n */\nexport function detach(element, context) {\n logger.debug('detach renderer', element);\n context.select('svg').remove();\n}\n\n/**\n * Update the rendering context size\n * @param {Object} context Current rendering context\n * @param {Model} model Current model\n * @param {Stroker} stroker Current stroker\n * @param {Number} minHeight Minimal height for resize\n * @param {Number} minWidth Minimal Width for resize\n * @return {Model}\n */\nexport function resize(context, model, stroker, minHeight, minWidth) {\n const rect = context.node().getBoundingClientRect();\n const svg = context.selectAll('svg');\n const width = rect.width < minWidth ? minWidth : rect.width;\n const height = rect.height < minHeight ? minHeight : rect.height;\n svg.attr('viewBox', `0 0 ${width}, ${height}`);\n svg.attr('width', `${width}px`);\n svg.attr('height', `${height}px`);\n logger.debug('svg viewBox changed', svg);\n return model;\n}\n\n/**\n * Draw the current stroke from the model\n * @param {Object} context Current rendering context\n * @param {Model} model Current model\n * @param {Stroker} stroker Current stroker\n * @return {Model}\n */\nexport function drawCurrentStroke(context, model, stroker) {\n const modelRef = model;\n // Add a pending id for pending strokes rendering\n modelRef.currentStroke.id = `pendingStroke-${model.rawStrokes.length}`;\n // Render the current stroke\n logger.trace('drawing current stroke ', model.currentStroke);\n context.select(`#pendingStrokes #${modelRef.currentStroke.id}`).remove();\n drawStroke(context.select('#pendingStrokes').append('path').attr('id', model.currentStroke.id), model.currentStroke, stroker);\n return modelRef;\n}\n\nfunction insertAdjacentSVG(element, position, html) {\n const container = element.ownerDocument.createElementNS('http://www.w3.org/2000/svg', '_');\n container.innerHTML = html;\n\n switch (position.toLowerCase()) {\n case 'beforebegin':\n element.parentNode.insertBefore(container.firstChild, element);\n break;\n case 'afterbegin':\n element.insertBefore(container.lastChild, element.firstChild);\n break;\n case 'beforeend':\n element.appendChild(container.firstChild);\n break;\n case 'afterend':\n element.parentNode.insertBefore(container.lastChild, element.nextSibling);\n break;\n default:\n logger.warn('Invalid insertAdjacentHTML position');\n break;\n }\n}\n\n/**\n * Draw all symbols contained into the model\n * @param {Object} context Current rendering context\n * @param {Model} model Current model\n * @param {Stroker} stroker Current stroker\n * @return {Model}\n */\nexport function drawModel(context, model, stroker) {\n const drawSymbol = (symbol, symbolContext) => {\n logger.trace(`attempting to draw ${symbol.type} symbol`);\n if (symbol.type === 'stroke' && !symbolContext.select('id', symbol.id)) {\n drawStroke(symbolContext.append('path').attr('id', symbol.id), symbol, stroker);\n } else {\n logger.warn(`impossible to draw ${symbol.type} symbol`);\n }\n };\n\n const updateView = (patchUpdate) => {\n // We only add in the stack patch with updates\n patchUpdate.updates.forEach((update) => {\n try {\n const svgElementSelector = 'svg[data-layer=\"' + patchUpdate.layer + '\"]';\n switch (update.type) {\n case 'REPLACE_ALL': {\n context.select(svgElementSelector).remove();\n const parent = context.node();\n if (parent.insertAdjacentHTML) {\n parent.insertAdjacentHTML('beforeEnd', update.svg);\n } else {\n insertAdjacentSVG(parent, 'beforeEnd', update.svg);\n }\n if (patchUpdate.layer === 'MODEL') {\n context.select(svgElementSelector).append('g').attr('id', 'pendingStrokes');\n }\n }\n break;\n case 'REMOVE_ELEMENT': {\n if (update.id.includes('s') || update.id.includes('MODEL')) {\n context.select(`#${update.id}`).remove();\n } else {\n context.select(`#${update.id}`).attr('class', 'removed-stroke');\n setTimeout(() => {\n context.select(`#${update.id}`).remove();\n }, 100);\n }\n break;\n }\n case 'REPLACE_ELEMENT': {\n const parent = context.select(`#${update.id}`).node().parentNode;\n context.select(`#${update.id}`).remove();\n if (parent.insertAdjacentHTML) {\n parent.insertAdjacentHTML('beforeEnd', update.svg);\n } else {\n insertAdjacentSVG(parent, 'beforeEnd', update.svg);\n context.node().insertAdjacentHTML('beforeEnd', context.select(svgElementSelector).remove().node().outerHTML);\n }\n }\n break;\n case 'REMOVE_CHILD':\n context.select(`#${update.parentId} > *:nth-child(${update.index + 1})`).remove();\n break;\n case 'APPEND_CHILD': {\n const parent = context.select(update.parentId ? `#${update.parentId}` : svgElementSelector).node();\n if (parent.insertAdjacentHTML) {\n parent.insertAdjacentHTML('beforeEnd', update.svg);\n } else {\n insertAdjacentSVG(parent, 'beforeEnd', update.svg);\n context.node().insertAdjacentHTML('beforeEnd', context.select(svgElementSelector).remove().node().outerHTML);\n }\n }\n break;\n case 'INSERT_BEFORE': {\n const parent = context.select(`#${update.refId}`).node();\n if (parent.insertAdjacentHTML) {\n parent.insertAdjacentHTML('beforeBegin', update.svg);\n } else {\n insertAdjacentSVG(parent, 'beforeBegin', update.svg);\n context.node().insertAdjacentHTML('beforeEnd', context.select(svgElementSelector).remove().node().outerHTML);\n }\n }\n break;\n case 'REMOVE_ATTRIBUTE':\n context.selectAll(update.id ? `#${update.id}` : 'svg').attr(update.name, null);\n break;\n case 'SET_ATTRIBUTE': {\n // We ignore setAttributes on the svg element because we handle the resize elsewhere to prevent a blink effect\n // that occurs if we are waiting for the server to resize.\n if (update.id) {\n context.selectAll(`#${update.id}`).attr(update.name, update.value);\n }\n break;\n }\n default:\n logger.debug(`unknown update ${update.type} action`);\n break;\n }\n } catch (e) {\n logger.error(`Invalid update ${update.type}`, update);\n logger.error('Error on svg patch', e);\n }\n });\n };\n\n const pendingRecognizedSymbols = InkModel.extractPendingRecognizedSymbols(model);\n if (pendingRecognizedSymbols) {\n pendingRecognizedSymbols.forEach(patch => updateView(patch));\n InkModel.updateModelRenderedPosition(model);\n }\n\n const pendingStrokes = InkModel.extractPendingStrokes(model);\n if (pendingStrokes) {\n pendingStrokes.forEach(stroke => drawSymbol(stroke, context.select('#pendingStrokes')));\n }\n return model;\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/renderer/svg/SVGRenderer.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 513, "kind": "function", "name": "getInfo", "memberof": "src/renderer/svg/SVGRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/svg/SVGRenderer.js~getInfo", "access": "public", "export": true, "importPath": "myscript/src/renderer/svg/SVGRenderer.js", "importStyle": "{getInfo}", "description": "Get info", "lineNumber": 11, "return": { "nullable": null, "types": [ "RendererInfo" ], "spread": false, "description": "Information about this renderer" }, "params": [] }, { "__docId__": 514, "kind": "function", "name": "attach", "memberof": "src/renderer/svg/SVGRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/svg/SVGRenderer.js~attach", "access": "public", "export": true, "importPath": "myscript/src/renderer/svg/SVGRenderer.js", "importStyle": "{attach}", "description": "Populate the dom element", "lineNumber": 23, "params": [ { "nullable": null, "types": [ "Element" ], "spread": false, "optional": false, "name": "element", "description": "DOM element to attach the rendering elements" } ], "return": { "nullable": null, "types": [ "Object" ], "spread": false, "description": "The renderer context to give as parameter when a draw model will be call" } }, { "__docId__": 515, "kind": "function", "name": "detach", "memberof": "src/renderer/svg/SVGRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/svg/SVGRenderer.js~detach", "access": "public", "export": true, "importPath": "myscript/src/renderer/svg/SVGRenderer.js", "importStyle": "{detach}", "description": "Detach the renderer from the DOM element", "lineNumber": 35, "params": [ { "nullable": null, "types": [ "Element" ], "spread": false, "optional": false, "name": "element", "description": "DOM element to attach the rendering elements" }, { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "context", "description": "Current rendering context" } ], "return": null }, { "__docId__": 516, "kind": "function", "name": "resize", "memberof": "src/renderer/svg/SVGRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/svg/SVGRenderer.js~resize", "access": "public", "export": true, "importPath": "myscript/src/renderer/svg/SVGRenderer.js", "importStyle": "{resize}", "description": "Update the rendering context size", "lineNumber": 49, "params": [ { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "context", "description": "Current rendering context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "Stroker" ], "spread": false, "optional": false, "name": "stroker", "description": "Current stroker" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "name": "minHeight", "description": "Minimal height for resize" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "name": "minWidth", "description": "Minimal Width for resize" } ], "return": { "nullable": null, "types": [ "Model" ], "spread": false, "description": "" } }, { "__docId__": 517, "kind": "function", "name": "drawCurrentStroke", "memberof": "src/renderer/svg/SVGRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/svg/SVGRenderer.js~drawCurrentStroke", "access": "public", "export": true, "importPath": "myscript/src/renderer/svg/SVGRenderer.js", "importStyle": "{drawCurrentStroke}", "description": "Draw the current stroke from the model", "lineNumber": 68, "params": [ { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "context", "description": "Current rendering context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "Stroker" ], "spread": false, "optional": false, "name": "stroker", "description": "Current stroker" } ], "return": { "nullable": null, "types": [ "Model" ], "spread": false, "description": "" } }, { "__docId__": 518, "kind": "function", "name": "insertAdjacentSVG", "memberof": "src/renderer/svg/SVGRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/svg/SVGRenderer.js~insertAdjacentSVG", "access": "public", "export": false, "importPath": "myscript/src/renderer/svg/SVGRenderer.js", "importStyle": null, "description": null, "lineNumber": 79, "undocument": true, "params": [ { "name": "element", "types": [ "*" ] }, { "name": "position", "types": [ "*" ] }, { "name": "html", "types": [ "*" ] } ], "return": null, "ignore": true }, { "__docId__": 519, "kind": "function", "name": "drawModel", "memberof": "src/renderer/svg/SVGRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/svg/SVGRenderer.js~drawModel", "access": "public", "export": true, "importPath": "myscript/src/renderer/svg/SVGRenderer.js", "importStyle": "{drawModel}", "description": "Draw all symbols contained into the model", "lineNumber": 109, "params": [ { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "context", "description": "Current rendering context" }, { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" }, { "nullable": null, "types": [ "Stroker" ], "spread": false, "optional": false, "name": "stroker", "description": "Current stroker" } ], "return": { "nullable": null, "types": [ "Model" ], "spread": false, "description": "" } }, { "__docId__": 520, "kind": "file", "name": "src/renderer/svg/stroker/QuadraticSVGStroker.js", "content": "import * as StrokeComponent from '../../../model/StrokeComponent';\nimport { computeLinksPoints, computeMiddlePoint, computeAxeAngle } from '../../QuadraticUtils';\n\n/**\n * Get info\n * @return {StrokerInfo} Information about this stroker\n */\nexport function getInfo() {\n return {\n type: 'svg',\n name: 'quadratic',\n apiVersion: 'V4'\n };\n}\n\nfunction renderArc(context, center, radius) {\n const svgPath = [\n `M ${center.x},${center.y}`,\n `m ${-radius},0`,\n `a ${radius},${radius} 0 1 0 ${radius * 2},0`,\n `a ${radius},${radius} 0 1 0 ${-(radius * 2)},0`\n ].join(' ');\n return svgPath;\n}\n\nfunction renderLine(context, begin, end, width) {\n const linkPoints1 = computeLinksPoints(begin, computeAxeAngle(begin, end), width);\n const linkPoints2 = computeLinksPoints(end, computeAxeAngle(begin, end), width);\n\n const svgPath = [\n `M ${linkPoints1[0].x},${linkPoints1[0].y}`,\n `L ${linkPoints2[0].x},${linkPoints2[0].y}`,\n `L ${linkPoints2[1].x},${linkPoints2[1].y}`,\n `L ${linkPoints1[1].x},${linkPoints1[1].y}`\n ].join(' ');\n return svgPath;\n}\n\nfunction renderFinal(context, begin, end, width) {\n const ARCSPLIT = 6;\n const angle = computeAxeAngle(begin, end);\n const linkPoints = computeLinksPoints(end, angle, width);\n\n const parts = [`M ${linkPoints[0].x},${linkPoints[0].y}`];\n for (let i = 1; i <= ARCSPLIT; i++) {\n const newAngle = angle - (i * (Math.PI / ARCSPLIT));\n parts.push(`L ${end.x - (end.p * width * Math.sin(newAngle))},${end.y + (end.p * width * Math.cos(newAngle))}`);\n }\n const svgPath = parts.join(' ');\n return svgPath;\n}\n\nfunction renderQuadratic(context, begin, end, ctrl, width) {\n const linkPoints1 = computeLinksPoints(begin, computeAxeAngle(begin, ctrl), width);\n const linkPoints2 = computeLinksPoints(end, computeAxeAngle(ctrl, end), width);\n const linkPoints3 = computeLinksPoints(ctrl, computeAxeAngle(begin, end), width);\n\n const svgPath = [\n `M ${linkPoints1[0].x},${linkPoints1[0].y}`,\n `Q ${linkPoints3[0].x},${linkPoints3[0].y} ${linkPoints2[0].x},${linkPoints2[0].y}`,\n `L ${linkPoints2[1].x},${linkPoints2[1].y}`,\n `Q ${linkPoints3[1].x},${linkPoints3[1].y} ${linkPoints1[1].x},${linkPoints1[1].y}`\n ].join(' ');\n return svgPath;\n}\n\n/**\n * Draw a stroke on a svg tag, using quadratics\n * @param {Object} context Current rendering context\n * @param {Stroke} stroke Current stroke to be drawn\n */\nexport function drawStroke(context, stroke) {\n const length = stroke.x.length;\n const width = stroke.width;\n const firstPoint = StrokeComponent.getPointByIndex(stroke, 0);\n const nbquadratics = length - 2;\n\n const parts = [];\n if (length < 3) {\n parts.push(renderArc(context, firstPoint, width * 0.6));\n } else {\n parts.push(renderArc(context, firstPoint, width * firstPoint.p));\n parts.push(renderLine(context, firstPoint, computeMiddlePoint(firstPoint, StrokeComponent.getPointByIndex(stroke, 1)), width));\n\n for (let i = 0; i < nbquadratics; i++) {\n parts.push(renderQuadratic(context, computeMiddlePoint(StrokeComponent.getPointByIndex(stroke, i), StrokeComponent.getPointByIndex(stroke, i + 1)), computeMiddlePoint(StrokeComponent.getPointByIndex(stroke, i + 1), StrokeComponent.getPointByIndex(stroke, i + 2)), StrokeComponent.getPointByIndex(stroke, i + 1), width));\n }\n parts.push(renderLine(context, computeMiddlePoint(StrokeComponent.getPointByIndex(stroke, length - 2), StrokeComponent.getPointByIndex(stroke, length - 1)), StrokeComponent.getPointByIndex(stroke, length - 1), width));\n parts.push(renderFinal(context, StrokeComponent.getPointByIndex(stroke, length - 2), StrokeComponent.getPointByIndex(stroke, length - 1), width));\n }\n const svgPath = parts.join(' ');\n\n context\n .attr('color', stroke.color)\n .style('fill', stroke.color)\n .style('stroke', 'transparent')\n .classed('pending-stroke', true)\n .attr('d', `${svgPath}Z`);\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/renderer/svg/stroker/QuadraticSVGStroker.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 521, "kind": "function", "name": "getInfo", "memberof": "src/renderer/svg/stroker/QuadraticSVGStroker.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/svg/stroker/QuadraticSVGStroker.js~getInfo", "access": "public", "export": true, "importPath": "myscript/src/renderer/svg/stroker/QuadraticSVGStroker.js", "importStyle": "{getInfo}", "description": "Get info", "lineNumber": 8, "return": { "nullable": null, "types": [ "StrokerInfo" ], "spread": false, "description": "Information about this stroker" }, "params": [] }, { "__docId__": 522, "kind": "function", "name": "renderArc", "memberof": "src/renderer/svg/stroker/QuadraticSVGStroker.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/svg/stroker/QuadraticSVGStroker.js~renderArc", "access": "public", "export": false, "importPath": "myscript/src/renderer/svg/stroker/QuadraticSVGStroker.js", "importStyle": null, "description": null, "lineNumber": 16, "undocument": true, "params": [ { "name": "context", "types": [ "*" ] }, { "name": "center", "types": [ "*" ] }, { "name": "radius", "types": [ "*" ] } ], "return": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 523, "kind": "function", "name": "renderLine", "memberof": "src/renderer/svg/stroker/QuadraticSVGStroker.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/svg/stroker/QuadraticSVGStroker.js~renderLine", "access": "public", "export": false, "importPath": "myscript/src/renderer/svg/stroker/QuadraticSVGStroker.js", "importStyle": null, "description": null, "lineNumber": 26, "undocument": true, "params": [ { "name": "context", "types": [ "*" ] }, { "name": "begin", "types": [ "*" ] }, { "name": "end", "types": [ "*" ] }, { "name": "width", "types": [ "*" ] } ], "return": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 524, "kind": "function", "name": "renderFinal", "memberof": "src/renderer/svg/stroker/QuadraticSVGStroker.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/svg/stroker/QuadraticSVGStroker.js~renderFinal", "access": "public", "export": false, "importPath": "myscript/src/renderer/svg/stroker/QuadraticSVGStroker.js", "importStyle": null, "description": null, "lineNumber": 39, "undocument": true, "params": [ { "name": "context", "types": [ "*" ] }, { "name": "begin", "types": [ "*" ] }, { "name": "end", "types": [ "*" ] }, { "name": "width", "types": [ "*" ] } ], "return": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 525, "kind": "function", "name": "renderQuadratic", "memberof": "src/renderer/svg/stroker/QuadraticSVGStroker.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/svg/stroker/QuadraticSVGStroker.js~renderQuadratic", "access": "public", "export": false, "importPath": "myscript/src/renderer/svg/stroker/QuadraticSVGStroker.js", "importStyle": null, "description": null, "lineNumber": 53, "undocument": true, "params": [ { "name": "context", "types": [ "*" ] }, { "name": "begin", "types": [ "*" ] }, { "name": "end", "types": [ "*" ] }, { "name": "ctrl", "types": [ "*" ] }, { "name": "width", "types": [ "*" ] } ], "return": { "types": [ "*" ] }, "ignore": true }, { "__docId__": 526, "kind": "function", "name": "drawStroke", "memberof": "src/renderer/svg/stroker/QuadraticSVGStroker.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/svg/stroker/QuadraticSVGStroker.js~drawStroke", "access": "public", "export": true, "importPath": "myscript/src/renderer/svg/stroker/QuadraticSVGStroker.js", "importStyle": "{drawStroke}", "description": "Draw a stroke on a svg tag, using quadratics", "lineNumber": 72, "params": [ { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "context", "description": "Current rendering context" }, { "nullable": null, "types": [ "Stroke" ], "spread": false, "optional": false, "name": "stroke", "description": "Current stroke to be drawn" } ], "return": null }, { "__docId__": 527, "kind": "file", "name": "src/renderer/svg/symbols/StrokeSymbolSVGRenderer.js", "content": "/**\n * Draw a stroke symbol\n * @param {Object} context Current rendering context\n * @param {Stroke} stroke Stroke to be drawn\n * @param {Stroker} stroker Stroker to use to render a stroke\n */\nexport function drawStroke(context, stroke, stroker) {\n if (stroker) {\n stroker.drawStroke(context, stroke);\n }\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/renderer/svg/symbols/StrokeSymbolSVGRenderer.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 528, "kind": "function", "name": "drawStroke", "memberof": "src/renderer/svg/symbols/StrokeSymbolSVGRenderer.js", "generator": false, "async": false, "static": true, "longname": "src/renderer/svg/symbols/StrokeSymbolSVGRenderer.js~drawStroke", "access": "public", "export": true, "importPath": "myscript/src/renderer/svg/symbols/StrokeSymbolSVGRenderer.js", "importStyle": "{drawStroke}", "description": "Draw a stroke symbol", "lineNumber": 7, "params": [ { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "context", "description": "Current rendering context" }, { "nullable": null, "types": [ "Stroke" ], "spread": false, "optional": false, "name": "stroke", "description": "Stroke to be drawn" }, { "nullable": null, "types": [ "Stroker" ], "spread": false, "optional": false, "name": "stroker", "description": "Stroker to use to render a stroke" } ], "return": null }, { "__docId__": 529, "kind": "file", "name": "src/smartguide/SmartGuide.js", "content": "import PerfectScrollbar from 'perfect-scrollbar';\nimport Clipboard from 'clipboard';\nimport Constants from '../configuration/Constants';\n\n/**\n * Smart guide\n * @typedef {Object} SmartGuide\n * @property {Editor} editor - A reference to the current editor.\n * @property {String} wordToChange - Word to change following a click on a word.\n * @property {String} lastWord - Keep the last word of the previous export to compare with the new and scroll if it's different.\n * @property {String} previousLabelExport - Keep the previous label export to know if we should repopulate the prompter text.\n * @property {PerfectScrollbar} perfectScrollbar - Perfect Scrollbar used to get gestures from smart guide using touch-action none anyway and get scrolling too.\n * @property {Object} elements - All the HTML elements of the smart guide.\n * @property {Number} smartGuideTimeOutId - Id of the setTimeOut from fade out animation to clear.\n * @property {String} randomString - Random string used in case of multiple smart guide.\n */\n\n/**\n * Create all the smart guide HTML elements.\n */\nfunction createHTMLElements(randomString) {\n /**\n * The smart guide element.\n * @type {HTMLDivElement}\n */\n const smartGuideElement = document.createElement('div');\n smartGuideElement.id = 'smartguide' + randomString;\n smartGuideElement.classList.add('smartguide');\n\n /**\n * The prompter text element that contains the text to get the overflow working.\n * @type {HTMLDivElement}\n */\n const textElement = document.createElement('div');\n textElement.id = 'prompter-text' + randomString;\n textElement.classList.add('prompter-text');\n textElement.setAttribute('touch-action', 'none');\n\n /**\n * The text container element that contains the text element.\n * @type {HTMLDivElement}\n */\n const textContainer = document.createElement('div');\n textContainer.id = 'prompter-text-container' + randomString;\n textContainer.classList.add('prompter-text-container');\n textContainer.appendChild(textElement);\n\n /**\n * The actions menu represented by the ellipsis character.\n * @type {HTMLDivElement}\n */\n const ellipsisElement = document.createElement('div');\n ellipsisElement.id = 'ellipsis' + randomString;\n ellipsisElement.classList.add('ellipsis');\n ellipsisElement.innerHTML = '...';\n\n /**\n * The tag element.\n * @type {HTMLDivElement}\n */\n const tagElement = document.createElement('div');\n tagElement.id = 'tag-icon' + randomString;\n tagElement.classList.add('tag-icon');\n tagElement.innerHTML = '¶';\n\n /**\n * The candidates element that contains the candidates for a word.\n * @type {HTMLDivElement}\n */\n const candidatesElement = document.createElement('div');\n candidatesElement.id = 'candidates' + randomString;\n candidatesElement.classList.add('candidates');\n\n /**\n * The menu element that contains the actions.\n * @type {HTMLDivElement}\n */\n const menuElement = document.createElement('div');\n menuElement.id = 'more-menu' + randomString;\n menuElement.classList.add('more-menu');\n\n /**\n * The convert button from actions menu.\n * @type {HTMLButtonElement}\n */\n const convertElement = document.createElement('button');\n convertElement.classList.add('options-label-button');\n convertElement.id = 'convert' + randomString;\n convertElement.innerHTML = 'Convert';\n\n /**\n * The copy button from actions menu.\n * @type {HTMLButtonElement}\n */\n const copyElement = document.createElement('button');\n copyElement.classList.add('options-label-button');\n copyElement.id = 'copy' + randomString;\n copyElement.innerHTML = 'Copy';\n\n /**\n * The delete button from actions menu.\n * @type {HTMLButtonElement}\n */\n const deleteElement = document.createElement('button');\n deleteElement.classList.add('options-label-button');\n deleteElement.id = 'delete' + randomString;\n deleteElement.innerHTML = 'Delete';\n\n return {\n smartGuideElement,\n textElement,\n textContainer,\n candidatesElement,\n menuElement,\n tagElement,\n ellipsisElement,\n convertElement,\n copyElement,\n deleteElement,\n };\n}\n\n/**\n * Check if node is in shadow dom\n * @param {Node} node - A node element.\n * @returns {boolean} true if is in shadow dom, false otherwise.\n */\nfunction isInShadow(node) {\n let parent = (node && node.parentNode);\n while (parent) {\n if (parent.toString() === '[object ShadowRoot]') {\n return true;\n }\n parent = parent.parentNode;\n }\n return false;\n}\n\n/**\n * Show the actions of the action menu.\n * @param {Event} evt - Event used to insert the option div using the event's target.\n * @param {Object} elements - All the elements of the smart guide.\n * @param {SmartGuide} smartGuide\n */\nfunction showActions(evt, elements) {\n const elementsRef = elements;\n\n const insertActions = () => {\n elementsRef.menuElement.appendChild(elementsRef.convertElement);\n elementsRef.menuElement.appendChild(elementsRef.copyElement);\n elementsRef.menuElement.appendChild(elementsRef.deleteElement);\n\n const parent = evt.target.parentNode;\n parent.insertBefore(elementsRef.menuElement, evt.target);\n };\n\n const positionActions = () => {\n // 48 to get the boundary of smart guide element.\n const left = evt.target.offsetLeft - 68;\n elementsRef.menuElement.style.left = `${left}px`;\n };\n\n const isMenuInDocument = document.contains(elementsRef.menuElement);\n if (!isInShadow(elementsRef.menuElement) && !isMenuInDocument) {\n elementsRef.menuElement.style.display = 'flex';\n positionActions();\n insertActions();\n } else if (elementsRef.menuElement.style.display === 'none') {\n positionActions();\n elementsRef.menuElement.style.display = 'flex';\n }\n}\n\n/**\n * Show the candidates of the clicked word.\n * @param {Event} evt - Event used to determine the clicked word.\n * @param {Editor} editor - A reference to the editor.\n * @param {SmartGuide} smartGuide - A reference to the smart guide.\n */\nfunction showCandidates(evt, editor, smartGuide) {\n const smartGuideRef = smartGuide;\n const elementsRef = smartGuide.elements;\n\n if (evt.target.id !== `prompter-text${smartGuide.randomString}`) {\n const id = evt.target.id.replace('word-', '').replace(smartGuide.randomString, '');\n const words = JSON.parse(editor.exports[Constants.Exports.JIIX]).words;\n smartGuideRef.wordToChange = words[id];\n smartGuideRef.wordToChange.id = id;\n elementsRef.candidatesElement.innerHTML = '';\n if (smartGuideRef.wordToChange && smartGuideRef.wordToChange.candidates) {\n elementsRef.candidatesElement.style.display = 'flex';\n smartGuideRef.wordToChange.candidates.forEach((word, index) => {\n if (smartGuideRef.wordToChange.label === word) {\n elementsRef.candidatesElement.innerHTML += `${word}`;\n } else {\n elementsRef.candidatesElement.innerHTML += `${word}`;\n }\n });\n // get the parent parent of word to insert just before smart guide, 48 to get the boundary of smart guide element.\n const top = 48;\n const left = evt.target.getBoundingClientRect().left - 60;\n elementsRef.candidatesElement.style.top = `${top}px`;\n elementsRef.candidatesElement.style.left = `${left}px`;\n\n const parent = evt.target.parentNode.parentNode.parentNode;\n parent.insertBefore(elementsRef.candidatesElement, evt.target.parentNode.parentNode);\n }\n }\n}\n\n/**\n * Call the import_ function of the editor to import the modified Jiix with the new label.\n * @param {Event} evt - Event to determine the clicked candidate.\n * @param {Editor} editor - A reference to the editor.\n * @param {SmartGuide} smartGuide - A reference to the smart guide.\n */\nfunction clickCandidate(evt, editor, smartGuide) {\n const smartGuideRef = smartGuide;\n const elementsRef = smartGuide.elements;\n const candidate = evt.target.innerText;\n\n if (candidate !== smartGuideRef.wordToChange.label && smartGuideRef.wordToChange.candidates.includes(candidate)) {\n const jiixToImport = JSON.parse(editor.exports[Constants.Exports.JIIX]);\n jiixToImport.words[smartGuideRef.wordToChange.id].label = candidate;\n // eslint-disable-next-line no-underscore-dangle\n editor.import_(JSON.stringify(jiixToImport), Constants.Exports.JIIX);\n }\n elementsRef.candidatesElement.style.display = 'none';\n}\n\n/**\n * Add the listeners to the smart guide elements.\n * @param {Editor} editor - A reference to the editor.\n * @param {SmartGuide} smartGuide - A reference to the smart guide.\n */\nfunction addListeners(editor, smartGuide) {\n const elementsRef = smartGuide.elements;\n\n elementsRef.textElement.addEventListener('click', evt => showCandidates(evt, editor, smartGuide));\n elementsRef.candidatesElement.addEventListener('click', evt => clickCandidate(evt, editor, smartGuide));\n elementsRef.ellipsisElement.addEventListener('click', evt => showActions(evt, elementsRef));\n elementsRef.copyElement.addEventListener('click', () => {\n elementsRef.menuElement.style.display = 'none';\n });\n elementsRef.convertElement.addEventListener('click', () => {\n elementsRef.menuElement.style.display = 'none';\n editor.convert();\n });\n elementsRef.deleteElement.addEventListener('click', () => {\n elementsRef.menuElement.style.display = 'none';\n editor.clear();\n });\n}\n\n/**\n * Call mutation observer to trigger fade out animation.\n * @param {number} [duration=10000] - the duration in milliseconds before calling the fade out animation.\n * @param {SmartGuide} smartGuide - A reference to the smart guide.\n */\nfunction callFadeOutObserver(duration = 10000, smartGuide) {\n const smartGuideRef = smartGuide;\n const elementsRef = smartGuide.elements;\n // eslint-disable-next-line no-undef\n const observer = new MutationObserver((mutations) => {\n mutations.forEach(() => {\n if (smartGuideRef.smartGuideTimeOutId) {\n clearTimeout(smartGuideRef.smartGuideTimeOutId);\n }\n if (elementsRef.candidatesElement.style.display === 'none' && elementsRef.menuElement.style.display === 'none') {\n smartGuideRef.smartGuideTimeOutId = setTimeout(() => {\n elementsRef.smartGuideElement.classList.add('smartguide-out');\n elementsRef.smartGuideElement.classList.remove('smartguide-in');\n }, duration);\n } else if (!document.contains(elementsRef.candidatesElement) && !document.contains(elementsRef.menuElement)) {\n smartGuideRef.smartGuideTimeOutId = setTimeout(() => {\n elementsRef.smartGuideElement.classList.add('smartguide-out');\n elementsRef.smartGuideElement.classList.remove('smartguide-in');\n }, duration);\n }\n });\n });\n observer.observe(elementsRef.smartGuideElement, { childList: true, subtree: true, attributes: true });\n}\n\n/**\n * Create a new smart guide\n * @param {Editor} editor - A reference to the editor.\n * @returns {SmartGuide} New smart guide\n */\nexport function createSmartGuide(editor) {\n const randomString = '-' + Math.random().toString(10).substring(2, 12);\n const elements = createHTMLElements(randomString);\n\n /**\n * Clipboard from clipboard.js used to get copy across all browsers.\n * @type {Clipboard}\n */\n const clipboard = new Clipboard(elements.copyElement);\n const perfectScrollbar = new PerfectScrollbar(elements.textContainer, { suppressScrollY: true, scrollXMarginOffset: 1 });\n\n const smartGuide = {\n editor,\n wordToChange: '',\n lastWord: '',\n previousLabelExport: ' ',\n perfectScrollbar,\n elements,\n smartGuideTimeOutId: 0,\n randomString\n };\n addListeners(editor, smartGuide);\n\n if (editor.configuration.recognitionParams.v4.text.smartGuideFadeOut.enable) {\n callFadeOutObserver(editor.configuration.recognitionParams.v4.text.smartGuideFadeOut.duration, smartGuide);\n }\n\n return smartGuide;\n}\n\nexport function resize(smartGuide) {\n const smartGuideRef = smartGuide;\n const elementsRef = smartGuide.elements;\n\n const mmToPixels = 3.779527559;\n let left = smartGuideRef.editor.configuration.recognitionParams.v4.text.margin.left * mmToPixels;\n\n const maxWidthTextContainer = smartGuideRef.editor.domElement.clientWidth - left - elementsRef.tagElement.offsetWidth - 35 - left;\n\n // Assign a max width to the smartguide based on the editor width, the left position and a small margin for the ellipsis (48px)\n elementsRef.textContainer.style.width = `${maxWidthTextContainer}px`;\n elementsRef.textContainer.style.maxWidth = `${maxWidthTextContainer}px`;\n\n left = elementsRef.tagElement.offsetWidth;\n left += maxWidthTextContainer;\n elementsRef.ellipsisElement.style.left = `${left}px`;\n\n elementsRef.smartGuideElement.style.width = `${elementsRef.tagElement.offsetWidth + elementsRef.textContainer.offsetWidth + elementsRef.ellipsisElement.offsetWidth}px`;\n smartGuideRef.perfectScrollbar.update();\n}\n\n/**\n * Insert the smart guide HTML elements in the DOM.\n * @param {SmartGuide} smartGuide - A reference to the smart guide.\n */\nexport function insertSmartGuide(smartGuide) {\n const smartGuideRef = smartGuide;\n const elementsRef = smartGuide.elements;\n\n const insertSmartGuideElement = (left, top) => {\n elementsRef.smartGuideElement.style.top = `${top}px`;\n elementsRef.smartGuideElement.style.left = `${left}px`;\n elementsRef.smartGuideElement.style.visibility = 'hidden';\n\n const parent = smartGuideRef.editor.domElement;\n parent.insertBefore(elementsRef.smartGuideElement, smartGuideRef.editor.loader);\n };\n const insertTag = () => {\n elementsRef.smartGuideElement.appendChild(elementsRef.tagElement);\n };\n const insertTextContainer = (left, maxWidth) => {\n elementsRef.textContainer.style.left = `${left}px`;\n\n // Assign a max width to the smartguide based on the editor width, the left position and a small margin for the ellipsis (48px)\n elementsRef.textContainer.style.width = `${maxWidth}px`;\n elementsRef.textContainer.style.maxWidth = `${maxWidth}px`;\n\n elementsRef.smartGuideElement.appendChild(elementsRef.textContainer);\n };\n const insertEllipsis = (left) => {\n elementsRef.ellipsisElement.style.left = `${left}px`;\n\n elementsRef.smartGuideElement.appendChild(elementsRef.ellipsisElement);\n };\n\n\n // FIXME Use value from contentChanged when available\n\n const mmToPixels = 3.779527559;\n\n const marginTop = smartGuideRef.editor.configuration.recognitionParams.v4.text.margin.top * mmToPixels;\n const marginLeft = smartGuideRef.editor.configuration.recognitionParams.v4.text.margin.left * mmToPixels;\n\n // 12 is the space between line in mm\n const top = marginTop - (12 * mmToPixels);\n let left = marginLeft;\n\n insertSmartGuideElement(left, top);\n insertTag();\n\n // 35 is the ellipsis element width\n const maxWidthTextContainer = smartGuideRef.editor.domElement.clientWidth - left - elementsRef.tagElement.offsetWidth - 35 - left;\n left = elementsRef.tagElement.offsetWidth;\n insertTextContainer(left, maxWidthTextContainer);\n\n left += maxWidthTextContainer;\n insertEllipsis(left);\n\n elementsRef.menuElement.style.display = 'none';\n elementsRef.menuElement.appendChild(elementsRef.convertElement);\n elementsRef.menuElement.appendChild(elementsRef.copyElement);\n elementsRef.menuElement.appendChild(elementsRef.deleteElement);\n elementsRef.smartGuideElement.appendChild(elementsRef.menuElement);\n\n elementsRef.candidatesElement.style.display = 'none';\n elementsRef.smartGuideElement.appendChild(elementsRef.candidatesElement);\n\n // 48px as set in css\n elementsRef.smartGuideElement.style.height = '48px';\n elementsRef.smartGuideElement.style.width = `${elementsRef.tagElement.offsetWidth + elementsRef.textContainer.offsetWidth + elementsRef.ellipsisElement.offsetWidth}px`;\n smartGuideRef.perfectScrollbar.update();\n}\n\n/**\n * Launch the smartguide.\n * @param {SmartGuide} smartGuide - A reference to the smart guide.\n * @param {Object} exports - The export from the editor.\n */\nexport function launchSmartGuide(smartGuide, exports) {\n const smartGuideRef = smartGuide;\n const elementsRef = smartGuide.elements;\n\n const isSmartGuideInDocument = document.contains(elementsRef.smartGuideElement);\n\n if (!isInShadow(elementsRef.smartGuideElement) && !isSmartGuideInDocument) {\n insertSmartGuide(smartGuide);\n }\n\n const addAnimationToModifiedWord = (words) => {\n if (smartGuideRef.tempWords && smartGuideRef.tempWords.length === words.length) {\n const labelWordsArray = words.map(word => word.label);\n const tempLabelWordsArray = smartGuideRef.tempWords.map(word => word.label);\n const wordChangedId = labelWordsArray.indexOf(labelWordsArray.filter(a => tempLabelWordsArray.indexOf(a) === -1)[0]);\n if (document.getElementById(`word-${wordChangedId}${smartGuide.randomString}`) && wordChangedId > -1) {\n document.getElementById(`word-${wordChangedId}${smartGuide.randomString}`).classList.add('modified-word');\n elementsRef.textContainer.scrollLeft = document.getElementById(`word-${wordChangedId}${smartGuide.randomString}`).offsetLeft - 10;\n }\n }\n smartGuideRef.tempWords = JSON.parse(exports[Constants.Exports.JIIX]).words;\n };\n\n const createWordSpan = (empty, index, word) => {\n const span = document.createElement('span');\n span.id = `word-${index}${smartGuide.randomString}`;\n if (empty) {\n span.innerHTML = ' ';\n } else {\n span.textContent = word.label;\n }\n return span;\n };\n\n // Possible optimisation ? Check if we can find a way to not repopulate the smartguide every time even if we now use Document fragment\n const populatePrompter = (words) => {\n elementsRef.textElement.innerHTML = '';\n // We use a DocumentFragment to reflow the DOM only one time as it is not part of the DOM\n const myFragment = document.createDocumentFragment();\n words.forEach((word, index) => {\n if (word.label === ' ' || word.label.includes('\\n')) {\n myFragment.appendChild(createWordSpan(true, index));\n } else if (index !== words.length - 1) {\n myFragment.appendChild(createWordSpan(false, index, word));\n } else {\n elementsRef.textElement.appendChild(myFragment);\n smartGuideRef.perfectScrollbar.update();\n if (smartGuideRef.lastWord === '') {\n smartGuideRef.lastWord = word;\n }\n const span = createWordSpan(false, index, word);\n // This is used to scroll to last word if last word is modified\n if ((smartGuideRef.lastWord.candidates !== word.candidates) && (smartGuideRef.lastWord.label !== word.label)) {\n span.classList.add('added-word');\n elementsRef.textElement.appendChild(span);\n elementsRef.textContainer.scrollLeft = span.offsetLeft;\n smartGuideRef.lastWord = word;\n } else {\n elementsRef.textElement.appendChild(span);\n elementsRef.textContainer.scrollLeft = span.offsetLeft;\n }\n }\n });\n };\n\n if (exports && JSON.parse(exports[Constants.Exports.JIIX]).words.length > 0) {\n elementsRef.smartGuideElement.classList.add('smartguide-in');\n elementsRef.smartGuideElement.classList.remove('smartguide-out');\n elementsRef.candidatesElement.style.display = 'none';\n elementsRef.menuElement.style.display = 'none';\n if (smartGuideRef.previousLabelExport && smartGuideRef.previousLabelExport !== JSON.parse(exports[Constants.Exports.JIIX]).label) {\n const words = JSON.parse(exports[Constants.Exports.JIIX]).words;\n populatePrompter(words);\n addAnimationToModifiedWord(words);\n }\n smartGuideRef.previousLabelExport = JSON.parse(exports[Constants.Exports.JIIX]).label;\n // This is required by clipboard.js to get the text to be copied.\n elementsRef.copyElement.setAttribute('data-clipboard-text', JSON.parse(exports[Constants.Exports.JIIX]).label);\n } else {\n elementsRef.smartGuideElement.classList.add('smartguide-out');\n elementsRef.smartGuideElement.classList.remove('smartguide-in');\n }\n\n return smartGuideRef;\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/smartguide/SmartGuide.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 530, "kind": "typedef", "name": "SmartGuide", "memberof": "src/smartguide/SmartGuide.js", "static": true, "longname": "src/smartguide/SmartGuide.js~SmartGuide", "access": "public", "description": "Smart guide", "properties": [ { "nullable": null, "types": [ "Editor" ], "spread": false, "optional": false, "name": "editor", "description": "A reference to the current editor." }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "wordToChange", "description": "Word to change following a click on a word." }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "lastWord", "description": "Keep the last word of the previous export to compare with the new and scroll if it's different." }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "previousLabelExport", "description": "Keep the previous label export to know if we should repopulate the prompter text." }, { "nullable": null, "types": [ "PerfectScrollbar" ], "spread": false, "optional": false, "name": "perfectScrollbar", "description": "Perfect Scrollbar used to get gestures from smart guide using touch-action none anyway and get scrolling too." }, { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "elements", "description": "All the HTML elements of the smart guide." }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "name": "smartGuideTimeOutId", "description": "Id of the setTimeOut from fade out animation to clear." }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "name": "randomString", "description": "Random string used in case of multiple smart guide." } ], "type": { "types": [ "Object" ], "optional": false, "name": "SmartGuide" } }, { "__docId__": 531, "kind": "function", "name": "createHTMLElements", "memberof": "src/smartguide/SmartGuide.js", "generator": false, "async": false, "static": true, "longname": "src/smartguide/SmartGuide.js~createHTMLElements", "access": "public", "export": false, "importPath": "myscript/src/smartguide/SmartGuide.js", "importStyle": null, "description": "Create all the smart guide HTML elements.", "lineNumber": 21, "params": [ { "name": "randomString", "types": [ "*" ] } ], "return": { "types": [ "{\"smartGuideElement\": *, \"textElement\": *, \"textContainer\": *, \"candidatesElement\": *, \"menuElement\": *, \"tagElement\": *, \"ellipsisElement\": *, \"convertElement\": *, \"copyElement\": *, \"deleteElement\": *}" ] }, "ignore": true }, { "__docId__": 532, "kind": "function", "name": "isInShadow", "memberof": "src/smartguide/SmartGuide.js", "generator": false, "async": false, "static": true, "longname": "src/smartguide/SmartGuide.js~isInShadow", "access": "public", "export": false, "importPath": "myscript/src/smartguide/SmartGuide.js", "importStyle": null, "description": "Check if node is in shadow dom", "lineNumber": 128, "unknown": [ { "tagName": "@returns", "tagValue": "{boolean} true if is in shadow dom, false otherwise." } ], "params": [ { "nullable": null, "types": [ "Node" ], "spread": false, "optional": false, "name": "node", "description": "A node element." } ], "return": { "nullable": null, "types": [ "boolean" ], "spread": false, "description": "true if is in shadow dom, false otherwise." }, "ignore": true }, { "__docId__": 533, "kind": "function", "name": "showActions", "memberof": "src/smartguide/SmartGuide.js", "generator": false, "async": false, "static": true, "longname": "src/smartguide/SmartGuide.js~showActions", "access": "public", "export": false, "importPath": "myscript/src/smartguide/SmartGuide.js", "importStyle": null, "description": "Show the actions of the action menu.", "lineNumber": 145, "params": [ { "nullable": null, "types": [ "Event" ], "spread": false, "optional": false, "name": "evt", "description": "Event used to insert the option div using the event's target." }, { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "elements", "description": "All the elements of the smart guide." }, { "nullable": null, "types": [ "SmartGuide" ], "spread": false, "optional": false, "name": "smartGuide", "description": "" } ], "return": null, "ignore": true }, { "__docId__": 534, "kind": "function", "name": "showCandidates", "memberof": "src/smartguide/SmartGuide.js", "generator": false, "async": false, "static": true, "longname": "src/smartguide/SmartGuide.js~showCandidates", "access": "public", "export": false, "importPath": "myscript/src/smartguide/SmartGuide.js", "importStyle": null, "description": "Show the candidates of the clicked word.", "lineNumber": 180, "params": [ { "nullable": null, "types": [ "Event" ], "spread": false, "optional": false, "name": "evt", "description": "Event used to determine the clicked word." }, { "nullable": null, "types": [ "Editor" ], "spread": false, "optional": false, "name": "editor", "description": "A reference to the editor." }, { "nullable": null, "types": [ "SmartGuide" ], "spread": false, "optional": false, "name": "smartGuide", "description": "A reference to the smart guide." } ], "return": null, "ignore": true }, { "__docId__": 535, "kind": "function", "name": "clickCandidate", "memberof": "src/smartguide/SmartGuide.js", "generator": false, "async": false, "static": true, "longname": "src/smartguide/SmartGuide.js~clickCandidate", "access": "public", "export": false, "importPath": "myscript/src/smartguide/SmartGuide.js", "importStyle": null, "description": "Call the import_ function of the editor to import the modified Jiix with the new label.", "lineNumber": 217, "params": [ { "nullable": null, "types": [ "Event" ], "spread": false, "optional": false, "name": "evt", "description": "Event to determine the clicked candidate." }, { "nullable": null, "types": [ "Editor" ], "spread": false, "optional": false, "name": "editor", "description": "A reference to the editor." }, { "nullable": null, "types": [ "SmartGuide" ], "spread": false, "optional": false, "name": "smartGuide", "description": "A reference to the smart guide." } ], "return": null, "ignore": true }, { "__docId__": 536, "kind": "function", "name": "addListeners", "memberof": "src/smartguide/SmartGuide.js", "generator": false, "async": false, "static": true, "longname": "src/smartguide/SmartGuide.js~addListeners", "access": "public", "export": false, "importPath": "myscript/src/smartguide/SmartGuide.js", "importStyle": null, "description": "Add the listeners to the smart guide elements.", "lineNumber": 236, "params": [ { "nullable": null, "types": [ "Editor" ], "spread": false, "optional": false, "name": "editor", "description": "A reference to the editor." }, { "nullable": null, "types": [ "SmartGuide" ], "spread": false, "optional": false, "name": "smartGuide", "description": "A reference to the smart guide." } ], "return": null, "ignore": true }, { "__docId__": 537, "kind": "function", "name": "callFadeOutObserver", "memberof": "src/smartguide/SmartGuide.js", "generator": false, "async": false, "static": true, "longname": "src/smartguide/SmartGuide.js~callFadeOutObserver", "access": "public", "export": false, "importPath": "myscript/src/smartguide/SmartGuide.js", "importStyle": null, "description": "Call mutation observer to trigger fade out animation.", "lineNumber": 260, "params": [ { "nullable": null, "types": [ "number" ], "spread": false, "optional": true, "defaultValue": "10000", "defaultRaw": 10000, "name": "duration", "description": "the duration in milliseconds before calling the fade out animation." }, { "nullable": null, "types": [ "SmartGuide" ], "spread": false, "optional": false, "name": "smartGuide", "description": "A reference to the smart guide." } ], "return": null, "ignore": true }, { "__docId__": 538, "kind": "function", "name": "createSmartGuide", "memberof": "src/smartguide/SmartGuide.js", "generator": false, "async": false, "static": true, "longname": "src/smartguide/SmartGuide.js~createSmartGuide", "access": "public", "export": true, "importPath": "myscript/src/smartguide/SmartGuide.js", "importStyle": "{createSmartGuide}", "description": "Create a new smart guide", "lineNumber": 290, "unknown": [ { "tagName": "@returns", "tagValue": "{SmartGuide} New smart guide" } ], "params": [ { "nullable": null, "types": [ "Editor" ], "spread": false, "optional": false, "name": "editor", "description": "A reference to the editor." } ], "return": { "nullable": null, "types": [ "SmartGuide" ], "spread": false, "description": "New smart guide" } }, { "__docId__": 539, "kind": "function", "name": "resize", "memberof": "src/smartguide/SmartGuide.js", "generator": false, "async": false, "static": true, "longname": "src/smartguide/SmartGuide.js~resize", "access": "public", "export": true, "importPath": "myscript/src/smartguide/SmartGuide.js", "importStyle": "{resize}", "description": null, "lineNumber": 320, "undocument": true, "params": [ { "name": "smartGuide", "types": [ "*" ] } ], "return": null }, { "__docId__": 540, "kind": "function", "name": "insertSmartGuide", "memberof": "src/smartguide/SmartGuide.js", "generator": false, "async": false, "static": true, "longname": "src/smartguide/SmartGuide.js~insertSmartGuide", "access": "public", "export": true, "importPath": "myscript/src/smartguide/SmartGuide.js", "importStyle": "{insertSmartGuide}", "description": "Insert the smart guide HTML elements in the DOM.", "lineNumber": 345, "params": [ { "nullable": null, "types": [ "SmartGuide" ], "spread": false, "optional": false, "name": "smartGuide", "description": "A reference to the smart guide." } ], "return": null }, { "__docId__": 541, "kind": "function", "name": "launchSmartGuide", "memberof": "src/smartguide/SmartGuide.js", "generator": false, "async": false, "static": true, "longname": "src/smartguide/SmartGuide.js~launchSmartGuide", "access": "public", "export": true, "importPath": "myscript/src/smartguide/SmartGuide.js", "importStyle": "{launchSmartGuide}", "description": "Launch the smartguide.", "lineNumber": 418, "params": [ { "nullable": null, "types": [ "SmartGuide" ], "spread": false, "optional": false, "name": "smartGuide", "description": "A reference to the smart guide." }, { "nullable": null, "types": [ "Object" ], "spread": false, "optional": false, "name": "exports", "description": "The export from the editor." } ], "return": { "types": [ "*" ] } }, { "__docId__": 542, "kind": "file", "name": "src/util/ModelStats.js", "content": "import { utilLogger as logger } from '../configuration/LoggerConfig';\nimport * as Cdkv3RestTextRecognizer from '../recognizer/rest/v3/Cdkv3RestTextRecognizer';\nimport * as RecognizerContext from '../model/RecognizerContext';\nimport defaultConfiguration from '../configuration/DefaultConfiguration';\n\n/**\n * @typedef {Object} Stats\n * @property {Number} strokesCount=0\n * @property {Number} pointsCount=0\n * @property {Number} byteSize=0\n * @property {Number} humanSize=0\n * @property {String} humanUnit=BYTE\n */\n\n/**\n * @param {Model} model Current model\n * @return {Stats} Statistics about recognition\n */\nexport function computeStats(model) {\n const stats = { strokesCount: 0, pointsCount: 0, byteSize: 0, humanSize: 0, humanUnit: 'BYTE' };\n if (model.rawStrokes) {\n stats.strokesCount = model.rawStrokes.length;\n\n const restMessage = Cdkv3RestTextRecognizer.buildInput(RecognizerContext.createEmptyRecognizerContext({ configuration: defaultConfiguration }), model);\n stats.pointsCount = model.rawStrokes.map(stroke => stroke.x.length).reduce((a, b) => a + b, 0);\n // We start with 270 as it is the size in bytes. Make a real computation implies to recode a doRecognition\n const byteSize = restMessage.textInput.length;\n stats.byteSize = byteSize;\n if (byteSize < 270) {\n stats.humanUnit = 'BYTE';\n stats.byteSize = 0;\n stats.humanSize = 0;\n } else if (byteSize < 2048) {\n stats.humanUnit = 'BYTES';\n stats.humanSize = byteSize;\n } else if (byteSize < 1024 * 1024) {\n stats.humanUnit = 'KiB';\n stats.humanSize = (byteSize / 1024).toFixed(2);\n } else {\n stats.humanUnit = 'MiB';\n stats.humanSize = (byteSize / 1024 / 1024).toFixed(2);\n }\n }\n logger.info('Stats', stats);\n return stats;\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/util/ModelStats.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 543, "kind": "typedef", "name": "Stats", "memberof": "src/util/ModelStats.js", "static": true, "longname": "src/util/ModelStats.js~Stats", "access": "public", "description": "", "properties": [ { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "defaultValue": "0", "defaultRaw": 0, "name": "strokesCount", "description": "" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "defaultValue": "0", "defaultRaw": 0, "name": "pointsCount", "description": "" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "defaultValue": "0", "defaultRaw": 0, "name": "byteSize", "description": "" }, { "nullable": null, "types": [ "Number" ], "spread": false, "optional": false, "defaultValue": "0", "defaultRaw": 0, "name": "humanSize", "description": "" }, { "nullable": null, "types": [ "String" ], "spread": false, "optional": false, "defaultValue": "BYTE", "defaultRaw": "BYTE", "name": "humanUnit", "description": "" } ], "type": { "types": [ "Object" ], "optional": false, "name": "Stats" } }, { "__docId__": 544, "kind": "function", "name": "computeStats", "memberof": "src/util/ModelStats.js", "generator": false, "async": false, "static": true, "longname": "src/util/ModelStats.js~computeStats", "access": "public", "export": true, "importPath": "myscript/src/util/ModelStats.js", "importStyle": "{computeStats}", "description": "", "lineNumber": 19, "params": [ { "nullable": null, "types": [ "Model" ], "spread": false, "optional": false, "name": "model", "description": "Current model" } ], "return": { "nullable": null, "types": [ "Stats" ], "spread": false, "description": "Statistics about recognition" } }, { "__docId__": 545, "kind": "file", "name": "src/util/PromiseHelper.js", "content": "/**\n * @typedef {Object} DestructuredPromise\n * @property {Promise} promise\n * @property {function(value: Object)} resolve\n * @property {function(reason: Object)} reject\n */\n\n/**\n * @return {DestructuredPromise}\n */\nexport function destructurePromise() {\n let resolve;\n let reject;\n const initPromise = new Promise(\n (resolveParam, rejectParam) => {\n resolve = resolveParam;\n reject = rejectParam;\n });\n return { promise: initPromise, resolve, reject };\n}\n", "static": true, "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/src/util/PromiseHelper.js", "access": "public", "description": null, "lineNumber": 1 }, { "__docId__": 546, "kind": "typedef", "name": "DestructuredPromise", "memberof": "src/util/PromiseHelper.js", "static": true, "longname": "src/util/PromiseHelper.js~DestructuredPromise", "access": "public", "description": "", "properties": [ { "nullable": null, "types": [ "Promise" ], "spread": false, "optional": false, "name": "promise", "description": "" }, { "nullable": null, "types": [ "function(value: Object)" ], "spread": false, "optional": false, "name": "resolve", "description": "" }, { "nullable": null, "types": [ "function(reason: Object)" ], "spread": false, "optional": false, "name": "reject", "description": "" } ], "type": { "types": [ "Object" ], "optional": false, "name": "DestructuredPromise" } }, { "__docId__": 547, "kind": "function", "name": "destructurePromise", "memberof": "src/util/PromiseHelper.js", "generator": false, "async": false, "static": true, "longname": "src/util/PromiseHelper.js~destructurePromise", "access": "public", "export": true, "importPath": "myscript/src/util/PromiseHelper.js", "importStyle": "{destructurePromise}", "description": "", "lineNumber": 11, "return": { "nullable": null, "types": [ "DestructuredPromise" ], "spread": false, "description": "" }, "params": [] }, { "kind": "index", "content": "# MyScriptJS\n\n[![npm version](https://badge.fury.io/js/myscript.svg)](https://badge.fury.io/js/myscript)\n[![Examples](https://img.shields.io/badge/Link%20to-examples-blue.svg)](https://myscript.github.io/MyScriptJS/examples/)\n[![Documentation](https://img.shields.io/badge/Link%20to-documentation-green.svg)](https://developer.myscript.com/docs/interactive-ink/latest/web/myscriptjs/)\n\n> The fastest way to integrate rich **handwriting** features in your webapp.\n\n
\n \n
\n\nMyScriptJS is a JavaScript library that can be used in every web application to bring handwriting recognition.\n\nIt integrates all you need:\n\n* Signal capture for all devices,\n* Digital ink rendering,\n* Link to MyScript Cloud to bring handwriting recognition.\n\n## Table of contents\n\n* [Examples](https://github.com/MyScript/MyScriptJS#examples)\n* [Features](https://github.com/MyScript/MyScriptJS#features)\n* [Requirements](https://github.com/MyScript/MyScriptJS#requirements)\n* [Installation](https://github.com/MyScript/MyScriptJS#installation)\n* [Usage](https://github.com/MyScript/MyScriptJS#usage)\n* [Documentation](https://github.com/MyScript/MyScriptJS#documentation)\n* [Development](https://github.com/MyScript/MyScriptJS#development)\n* [Support](https://github.com/MyScript/MyScriptJS#support)\n* [Feedback](https://github.com/MyScript/MyScriptJS#sharing-your-feedback)\n* [Contributing](https://github.com/MyScript/MyScriptJS#contributing)\n\n\n## Examples\n\nDiscover Interactive Ink with MyScriptJS and its major features with our [text demo and tutorial](http://webdemo.myscript.com/views/text.html).\n\nTry our two basic examples featuring [the text recognition](https://myscript.github.io/MyScriptJS//examples/v4/websocket_text_iink.html) and [the math recognition](https://myscript.github.io/MyScriptJS/examples/v4/websocket_math_iink.html).\n\n[All our examples](https://myscript.github.io/MyScriptJS/examples/) with the source codes in [this directory](https://github.com/MyScript/MyScriptJS/tree/master/examples).\n\nWe also provide examples of integration with the major JavaScript frameworks:\n\n| Framework | Link |\n| --- | --- |\n|
| [Example of React integration](https://github.com/MyScript/web-integration-samples/tree/master/react-integration-examples) |\n|
| [Example of Angular integration](https://github.com/MyScript/web-integration-samples/tree/master/angular-integration-examples) |\n|
| [Example of Vue integration](https://github.com/MyScript/web-integration-samples/tree/master/vue-integration-examples) |\n\n## Features\n\n* Text and Math support,\n* Easy to integrate,\n* Digital ink capture and rendering,\n* Rich editing gestures,\n* Import and export content,\n* Styling,\n* Typeset support,\n* More than 200 mathematical symbols supported,\n* 65 supported languages.\n\nYou can discover all the features on our Developer website for [Text](https://developer.myscript.com/text) and [Math](https://developer.myscript.com/math).\n\n## Requirements\n\n1. Have [npm](https://www.npmjs.com/get-npm), [yarn](https://yarnpkg.com/en/docs/install) or [bower](https://bower.io/#install-bower) installed.\n2. Have a MyScript developer account. You can create one [here](https://developer.myscript.com/support/account/registering-myscript-cloud/).\n3. Get your keys and the free monthly quota to access MyScript Cloud at [developer.myscript.com](https://developer.myscript.com/getting-started/web)\n\n## Installation\n\nMyScriptJS can be installed with the well known package managers `npm`, `yarn` and `bower`. \n\nIf you want to use `npm` or `yarn` you first have to init a project (or use an existing one). \n\n```shell\nnpm init\nOR\nyarn init \n```\n\nYou can then install MyScriptJS and use it as showed in the [Usage](https://github.com/MyScript/MyScriptJS#usage) section.\n\n```shell\nnpm install myscript\nOR\nyarn add myscript\n```\n\nYou can also install MyScriptJS using bower (with or without an existing project) and use it as showed in the [Usage](https://github.com/MyScript/MyScriptJS#usage) section replacing `node_modules` by `bower_components`.\n\n```shell\nbower install myscript\n```\n\n\n## Usage\n\n1. Create an `index.html` file in the same directory.\n\n2. Add the following lines in the `head` section of your file to use MyScriptJS and the css. We use [PEP](https://github.com/jquery/PEP) to ensure better browsers compatibilities. Note that you can also use it using dependencies from `node_modules` or `bower_components`:\n```html\n\n\n\n```\n\n3. Still in the `head` section, add a `style` and specify the height and the width of your editor:\n```html\n\n```\n\n4. In the `body` tag, create a `div` tag that will contain the editing area:\n```html\n
\n```\n\n5. In JavaScript and within a `\n \n \n \n \n
\n \n \n\n```\n\n7. Open `index.html` in your browser or serve your folder content using any web server.\n\nYou can find this guide and a more complete example on the [MyScript Developer website](https://developer.myscript.com/docs/interactive-ink/latest/web/myscriptjs/).\n\n## Documentation\n\nYou can find a complete documentation with the following sections on our Developer website:\n\n* **Get Started**: [how to use MyScriptJS with a full example](https://developer.myscript.com/docs/interactive-ink/latest/web/myscriptjs/get-started/),\n* **Editing**: [how to interact with content](https://developer.myscript.com/docs/interactive-ink/latest/web/myscriptjs/editing/),\n* **Conversion**: [how to convert your handwritten content](https://developer.myscript.com/docs/interactive-ink/latest/web/myscriptjs/conversion/),\n* **Import and Export**: [how to import and export your content](https://developer.myscript.com/docs/interactive-ink/latest/web/myscriptjs/import-and-export/),\n* **Styling**: [how to style content](https://developer.myscript.com/docs/interactive-ink/latest/web/myscriptjs/styling/).\n\nAs well as a global [Configuration page](https://developer.myscript.com/docs/interactive-ink/latest/reference/web/configuration/).\n\nWe also provide a complete [API Reference](https://myscript.github.io/MyScriptJS/docs).\n\n## Development\n\nInstructions to help you build the project and develop are available in the [SETUP.md](https://github.com/MyScript/MyScriptJS/blob/master/SETUP.md) file.\n\n\n## Getting support\n\nYou can get support and ask your questions on the [dedicated section](https://developer-support.myscript.com/support/discussions/forums/16000096021) of MyScript Developer website.\n\n## Sharing your feedback ?\n\nMade a cool app with MyScriptJS? We would love to hear about you!\nWe’re planning to showcase apps using it so let us know by sending a quick mail to [myapp@myscript.com](mailto://myapp@myscript.com).\n\n## Contributing\n\nWe welcome your contributions: if you would like to extend MyScriptJS for your needs, feel free to fork it! \n\nPlease take a look at our [contributing](https://github.com/MyScript/MyScriptJS/blob/master/CONTRIBUTING.md) guidelines before submitting your pull request.\n\n## License\nThis library is licensed under the [Apache 2.0](http://opensource.org/licenses/Apache-2.0).", "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/README.md", "name": "./README.md", "static": true, "access": "public" }, { "kind": "packageJSON", "content": "{\n \"name\": \"myscript\",\n \"version\": \"4.3.0\",\n \"main\": \"dist/myscript.min.js\",\n \"module\": \"dist/myscript.esm.js\",\n \"description\": \"MyScriptJS is the fastest way to integrate handwriting panel and recognition in your webapp\",\n \"keywords\": [\n \"myscript\",\n \"javascript\",\n \"developer\",\n \"handwriting\",\n \"recognition\",\n \"cloud\"\n ],\n \"files\": [\n \"dist\"\n ],\n \"license\": \"Apache-2.0\",\n \"homepage\": \"https://myscript.github.io/MyScriptJS/\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git://github.com/MyScript/MyScriptJS.git\"\n },\n \"dependencies\": {\n \"assign-deep\": \"^0.4.7\",\n \"clipboard\": \"^1.7.1\",\n \"crypto-js\": \"^3.1.9-1\",\n \"d3-selection\": \"^1.3.0\",\n \"json-css\": \"^1.5.6\",\n \"loglevel\": \"^1.6.1\",\n \"perfect-scrollbar\": \"^1.3.0\",\n \"uuid-js\": \"^0.7.5\"\n },\n \"devDependencies\": {\n \"babel-cli\": \"^6.26.0\",\n \"babel-core\": \"^6.26.3\",\n \"babel-loader\": \"^7.1.4\",\n \"babel-plugin-external-helpers\": \"^6.22.0\",\n \"babel-plugin-transform-runtime\": \"^6.23.0\",\n \"babel-polyfill\": \"^6.26.0\",\n \"babel-preset-env\": \"^1.7.0\",\n \"babel-register\": \"^6.26.0\",\n \"chai\": \"^4.1.2\",\n \"clean-css-cli\": \"^4.1.11\",\n \"esdoc\": \"^1.1.0\",\n \"esdoc-standard-plugin\": \"^1.0.0\",\n \"eslint\": \"^4.19.1\",\n \"eslint-config-airbnb\": \"^15.1.0\",\n \"eslint-loader\": \"^1.9.0\",\n \"eslint-plugin-import\": \"^2.11.0\",\n \"eslint-plugin-jsx-a11y\": \"^5.1.1\",\n \"eslint-plugin-react\": \"^7.8.2\",\n \"mocha\": \"^5.1.1\",\n \"npm-run-all\": \"^4.1.3\",\n \"rollup\": \"0.63.x\",\n \"rollup-plugin-babel\": \"^3.0.4\",\n \"rollup-plugin-commonjs\": \"^9.1.3\",\n \"rollup-plugin-json\": \"^2.3.1\",\n \"rollup-plugin-livereload\": \"^0.6.0\",\n \"rollup-plugin-node-resolve\": \"^3.3.0\",\n \"rollup-plugin-serve\": \"^0.4.2\",\n \"rollup-plugin-uglify\": \"^3.0.0\",\n \"sinon\": \"^2.4.1\"\n },\n \"scripts\": {\n \"lint\": \"eslint --ext js src\",\n \"docs\": \"esdoc\",\n \"minify-css\": \"cleancss -o dist/myscript.min.css src/*.css\",\n \"test:mocha\": \"mocha --require babel-core/register --recursive test/mocha/ --reporter progress\",\n \"test:mocha-xunit\": \"mocha --require babel-core/register --recursive test/mocha/ --reporter xunit --reporter-options output=./test/mocha/results/xunit.xml\",\n \"build:js\": \"rollup -c config/rollup.config.build.js --sourcemap\",\n \"build\": \"npm-run-all test:mocha lint build:js minify-css docs\",\n \"dev:js\": \"rollup -c config/rollup.config.dev.js -w --sourcemap\",\n \"dev\": \"npm-run-all minify-css dev:js\",\n \"start\": \"npm run dev\"\n }\n}\n", "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/package.json", "name": "package.json", "static": true, "access": "public" }, { "kind": "manualIndex", "content": "# [v4.3.0](https://github.com/MyScript/MyScriptJS/tree/v4.3.0)\n\n## Features\n\n- Addition of a new Recognition Assets Builder API to dynamically build text lexicons and math grammars\n- Ability to import JIIX Math content\n- Style and decoration support in the JIIX exports\n- New configuration options for a finer tuning of JIIX exports\n- Always connected is now the default mode for better end user experience\n- Text, Math and Diagram can now be exported to Word, HTML and iink format\n\n## Bugs fix\n\n- Fix multiple inputs example on Firefox\n- Fix smartguide on Edge\n- Fix vulnerabilites in dependencies\n- Fix auto-reconnect\n\n## Others\n\n- New examples :\n - Recognition asset builder\n - Export text to file (html, word, png, jpeg)\n - Use highlight to extract information\n - Import jiix with math\n - Search and highlight demoing how to manipulate JIIX label\n - Use recognition without UI for easy integration in existing ink capable applications\n\n# [v4.2.0](https://github.com/MyScript/MyScriptJS/tree/v4.2.0)\n\n## Features\n\n- New REST mode:\n - Text, math and diagram recognition\n - Examples for each recognition type\n - Support for Raw Content type\n- New build and development process:\n - We now use [Rollup](https://rollupjs.org/) to build our library,\n - Two outputs are now generated, [UMD](https://github.com/umdjs/umd) and [ES6 Modules](https://hacks.mozilla.org/2015/08/es6-in-depth-modules/),\n - We use npm scripts to launch the development process.\n- New always connected mode for WebSocket\n- New getSupportedImportMimeTypes method\n- New setGuides method used to add guides on a text part\n\n## Others\n\n- New local storage example\n- Add table of contents for examples page\n- Multiple improvements\n - Remove bower install from npm scripts\n - Replace d3 to only use d3-selection\n - Errors management\n\n# [v4.1.1](https://github.com/MyScript/MyScriptJS/tree/v4.1.1)\n\n## Features\n\n- New export in `myscript.js` for better import using frameworks (as React).\n\n## Bugs fixed\n\n- Multiple smart guides now working in case of multiple editors,\n- Stix font removed from css as useless now,\n- Languages list for v3 now displaying correct list.\n\n## Breaking changes\n\nIn order to be consistent with the native API :\n- `guide` renamed to `guides` in the configuration.\n\n# [v4.1.0](https://github.com/MyScript/MyScriptJS/tree/v4.1.0)\n\n## Features\n- New smart guide enabled by default:\n - Show real time recognized text above writings,\n - Change recognized words on click using candidates,\n - Convert, copy or delete text using the action menu,\n - Fade out animation to make the smart guide disappear after a certain duration,\n- Google Fonts support (see the [example](./examples/v4/customize_style.html))\n- Custom resources support, upload your custom resources to modify the recognition behaviour. (see the [text](./examples/v4/custom_resources_text.html) or the [math](./examples/v4/custom_resources_math.html) example.)\n- New `penStyleClasses` property. Used to change the theme using a classes passed using the `theme` property (see the [example](./examples/v4/customize_style.html)).\n- New guides for text using a svg DOM element behind the model layer.\n- No more css background if api is set to `V4`.\n- New `isEmpty`, `possibleUndoCount` and `undoStackIndex` properties in details on `changed` event to help development of custom undo/redo stacks.\n\n## Breaking changes\nIn order to be consistent with the native API :\n- `importContent()` and `exportContent()` respectively renamed to `import_()` and `export_()`.\n- `importInk(strokes)` changed to `pointerEvents(events)`.\n\n# [v4.0.0](https://github.com/MyScript/MyScriptJS/tree/v4.0.0)\n\n## Features\n- Change the underlying `InkPaper` editor to a new `Editor` class.\n- New events to be notified of editor changes.\n- New `penStyle` property. Used to change current pen style. \n- New `theme` property. Used to change the editor's theme. \n- New `configuration` property. Changing the configuration will clear the underlying editor, all currents strokes and results will be lost.\n \n## Breaking changes\n- Complete rewrite with ES6 syntax\n- Internal design improved to allow extensibility and support of upcoming recognition types. See the [documentation](./docs/index.html) and [examples](./examples/index.html) to discover new behavior. \n- Removal of all deprecated attributes and methods\n- All configuration has been merged into the `configuration` property.\n- All events has been renamed. \n- `getAvailableLanguages()` have been moved outside the editor. You can use it to retrieve the list of available languages for your configuration.\n\n# [v1.2.1](https://github.com/MyScript/MyScriptJS/tree/v1.2.1)\n\n## Bugs\n- Fixes staff disappearing after recognition result\n- Fixes retina mode was only well display after a resizing\n- Fixes scratch-out were displayed when exporting as image \n\n# [v1.2.0](https://github.com/MyScript/MyScriptJS/tree/v1.2.0)\n\n## Features\n- Change build task runner from grunt to gulp\n- Add accessors to `host` to make it mutable\n- Add accessors to `protocol` to make it mutable\n- Add accessors to `parameters` to make them mutable\n- Add accessors to `components` to make them mutable (@see mandatory clef on music)\n- Add enum style variables on string constants to ease implementation\n- Mark `globalAlpha` parameter as deprecated\n- Migrate JQuery Pointer Event Polyfill to [0.4.1](https://github.com/jquery/PEP/releases/tag/0.4.1)\n\n## Bugs\n- Fixes `parameters` constructors to allow json construction, used also to copy them\n- Fixes `components` constructors to allow json construction, used also to copy them\n- Fixes issue on shape recognition undo/redo\n- Fixes issue on music recognition undo/redo (@see mutable `components` feature)\n- Fixes issue on network interfaces (@see mutable `host` feature)\n- Fixes missing callback call when `timeout` === 0\n- Fixes set `parameters` on WebSocket recognition (@see mutable `parameters` feature)\n- Fixes ink-paper positioning issue (CSS change)\n- Fixes wrong pointer events coordinates\n- Fixes getAvailableLanguages to use correct `inputMode`\n- Fixes high-resolution rendering\n", "longname": "/home/sroulleau/myscript/projects/webcomponents/myscript-js/CHANGELOG.md", "name": "./CHANGELOG.md", "static": true, "access": "public" } ]