fable 3.1.47 → 3.1.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fable.js +272 -144
- package/dist/fable.js.map +1 -1
- package/dist/fable.min.js +2 -2
- package/dist/fable.min.js.map +1 -1
- package/package.json +1 -1
- package/source/services/Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-Base.js +1 -1
- package/source/services/Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-ExpressionTokenizer.js +2 -1
- package/source/services/Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-ValueMarshal.js +3 -3
- package/source/services/Fable-Service-ExpressionParser.js +22 -0
- package/test/ExpressionParser_tests.js +62 -0
package/dist/fable.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";function _defineProperty2(
|
|
1
|
+
"use strict";function _defineProperty2(obj,key,value){key=_toPropertyKey2(key);if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _toPropertyKey2(t){var i=_toPrimitive2(t,"string");return"symbol"==typeof i?i:String(i);}function _toPrimitive2(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f();}else if(typeof define==="function"&&define.amd){define([],f);}else{var g;if(typeof window!=="undefined"){g=window;}else if(typeof global!=="undefined"){g=global;}else if(typeof self!=="undefined"){g=self;}else{g=this;}g.Fable=f();}})(function(){var define,module,exports;return function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a;}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r);},p,p.exports,r,e,n,t);}return n[i].exports;}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o;}return r;}()({1:[function(require,module,exports){'use strict';var eachOfLimit=require('async.util.eachoflimit');var withoutIndex=require('async.util.withoutindex');module.exports=function eachLimit(arr,limit,iterator,cb){return eachOfLimit(limit)(arr,withoutIndex(iterator),cb);};},{"async.util.eachoflimit":3,"async.util.withoutindex":14}],2:[function(require,module,exports){'use strict';module.exports=function(tasks){function makeCallback(index){function fn(){if(tasks.length){tasks[index].apply(null,arguments);}return fn.next();}fn.next=function(){return index<tasks.length-1?makeCallback(index+1):null;};return fn;}return makeCallback(0);};},{}],3:[function(require,module,exports){var once=require('async.util.once');var noop=require('async.util.noop');var onlyOnce=require('async.util.onlyonce');var keyIterator=require('async.util.keyiterator');module.exports=function eachOfLimit(limit){return function(obj,iterator,cb){cb=once(cb||noop);obj=obj||[];var nextKey=keyIterator(obj);if(limit<=0){return cb(null);}var done=false;var running=0;var errored=false;(function replenish(){if(done&&running<=0){return cb(null);}while(running<limit&&!errored){var key=nextKey();if(key===null){done=true;if(running<=0){cb(null);}return;}running+=1;iterator(obj[key],key,onlyOnce(function(err){running-=1;if(err){cb(err);errored=true;}else{replenish();}}));}})();};};},{"async.util.keyiterator":7,"async.util.noop":9,"async.util.once":10,"async.util.onlyonce":11}],4:[function(require,module,exports){'use strict';var setImmediate=require('async.util.setimmediate');var restParam=require('async.util.restparam');module.exports=function(fn){return restParam(function(args){var callback=args.pop();args.push(function(){var innerArgs=arguments;if(sync){setImmediate(function(){callback.apply(null,innerArgs);});}else{callback.apply(null,innerArgs);}});var sync=true;fn.apply(this,args);sync=false;});};},{"async.util.restparam":12,"async.util.setimmediate":13}],5:[function(require,module,exports){'use strict';module.exports=Array.isArray||function isArray(obj){return Object.prototype.toString.call(obj)==='[object Array]';};},{}],6:[function(require,module,exports){'use strict';var isArray=require('async.util.isarray');module.exports=function isArrayLike(arr){return isArray(arr)||// has a positive integer length property
|
|
2
2
|
typeof arr.length==='number'&&arr.length>=0&&arr.length%1===0;};},{"async.util.isarray":5}],7:[function(require,module,exports){'use strict';var _keys=require('async.util.keys');var isArrayLike=require('async.util.isarraylike');module.exports=function keyIterator(coll){var i=-1;var len;var keys;if(isArrayLike(coll)){len=coll.length;return function next(){i++;return i<len?i:null;};}else{keys=_keys(coll);len=keys.length;return function next(){i++;return i<len?keys[i]:null;};}};},{"async.util.isarraylike":6,"async.util.keys":8}],8:[function(require,module,exports){'use strict';module.exports=Object.keys||function keys(obj){var _keys=[];for(var k in obj){if(obj.hasOwnProperty(k)){_keys.push(k);}}return _keys;};},{}],9:[function(require,module,exports){'use strict';module.exports=function noop(){};},{}],10:[function(require,module,exports){'use strict';module.exports=function once(fn){return function(){if(fn===null)return;fn.apply(this,arguments);fn=null;};};},{}],11:[function(require,module,exports){'use strict';module.exports=function only_once(fn){return function(){if(fn===null)throw new Error('Callback was already called.');fn.apply(this,arguments);fn=null;};};},{}],12:[function(require,module,exports){'use strict';module.exports=function restParam(func,startIndex){startIndex=startIndex==null?func.length-1:+startIndex;return function(){var length=Math.max(arguments.length-startIndex,0);var rest=new Array(length);for(var index=0;index<length;index++){rest[index]=arguments[index+startIndex];}switch(startIndex){case 0:return func.call(this,rest);case 1:return func.call(this,arguments[0],rest);}};};},{}],13:[function(require,module,exports){(function(setImmediate){(function(){'use strict';var _setImmediate=typeof setImmediate==='function'&&setImmediate;var fallback=function(fn){setTimeout(fn,0);};module.exports=function setImmediate(fn){// not a direct alias for IE10 compatibility
|
|
3
3
|
return(_setImmediate||fallback)(fn);};}).call(this);}).call(this,require("timers").setImmediate);},{"timers":144}],14:[function(require,module,exports){'use strict';module.exports=function withoutIndex(iterator){return function(value,index,callback){return iterator(value,callback);};};},{}],15:[function(require,module,exports){'use strict';var once=require('async.util.once');var noop=require('async.util.noop');var isArray=require('async.util.isarray');var restParam=require('async.util.restparam');var ensureAsync=require('async.util.ensureasync');var iterator=require('async.iterator');module.exports=function(tasks,cb){cb=once(cb||noop);if(!isArray(tasks))return cb(new Error('First argument to waterfall must be an array of functions'));if(!tasks.length)return cb();function wrapIterator(iterator){return restParam(function(err,args){if(err){cb.apply(null,[err].concat(args));}else{var next=iterator.next();if(next){args.push(wrapIterator(next));}else{args.push(cb);}ensureAsync(iterator).apply(null,args);}});}wrapIterator(iterator(tasks))();};},{"async.iterator":2,"async.util.ensureasync":4,"async.util.isarray":5,"async.util.noop":9,"async.util.once":10,"async.util.restparam":12}],16:[function(require,module,exports){'use strict';exports.byteLength=byteLength;exports.toByteArray=toByteArray;exports.fromByteArray=fromByteArray;var lookup=[];var revLookup=[];var Arr=typeof Uint8Array!=='undefined'?Uint8Array:Array;var code='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';for(var i=0,len=code.length;i<len;++i){lookup[i]=code[i];revLookup[code.charCodeAt(i)]=i;}// Support decoding URL-safe base64 strings, as Node.js does.
|
|
4
4
|
// See: https://en.wikipedia.org/wiki/Base64#URL_applications
|
|
@@ -15,7 +15,7 @@ if(extraBytes===1){tmp=uint8[len-1];parts.push(lookup[tmp>>2]+lookup[tmp<<4&0x3F
|
|
|
15
15
|
* A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic.
|
|
16
16
|
* Copyright (c) 2025 Michael Mclaughlin
|
|
17
17
|
* https://github.com/MikeMcl/big.js/LICENCE.md
|
|
18
|
-
*/;(function(GLOBAL){'use strict';var Big,/************************************** EDITABLE DEFAULTS
|
|
18
|
+
*/;(function(GLOBAL){'use strict';var Big,/************************************** EDITABLE DEFAULTS *****************************************/ // The default values below must be integers within the stated ranges.
|
|
19
19
|
/*
|
|
20
20
|
* The maximum number of decimal places (DP) of the results of operations involving division:
|
|
21
21
|
* div and sqrt, and pow with negative exponents.
|
|
@@ -47,7 +47,7 @@ MAX_POWER=1E6,// 1 to 1000000
|
|
|
47
47
|
* or if valueOf is called, or if toNumber is called on a Big which cannot be converted to a
|
|
48
48
|
* primitive number without a loss of precision.
|
|
49
49
|
*/STRICT=false,// true or false
|
|
50
|
-
|
|
50
|
+
/**************************************************************************************************/ // Error messages.
|
|
51
51
|
NAME='[big.js] ',INVALID=NAME+'Invalid ',INVALID_DP=INVALID+'decimal places',INVALID_RM=INVALID+'rounding mode',DIV_BY_ZERO=NAME+'Division by zero',// The shared prototype object.
|
|
52
52
|
P={},UNDEFINED=void 0,NUMERIC=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;/*
|
|
53
53
|
* Create and return a Big constructor.
|
|
@@ -258,7 +258,7 @@ if(typeof define==='function'&&define.amd){define(function(){return Big;});// No
|
|
|
258
258
|
*
|
|
259
259
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
260
260
|
* @license MIT
|
|
261
|
-
|
|
261
|
+
*/ /* eslint-disable no-proto */'use strict';var base64=require('base64-js');var ieee754=require('ieee754');exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;var K_MAX_LENGTH=0x7fffffff;exports.kMaxLength=K_MAX_LENGTH;/**
|
|
262
262
|
* If `Buffer.TYPED_ARRAY_SUPPORT`:
|
|
263
263
|
* === true Use Uint8Array implementation (fastest)
|
|
264
264
|
* === false Print warning and recommend using `buffer` v4.x which has an Object
|
|
@@ -447,7 +447,7 @@ getNode(pHash){if(!this._HashMap.hasOwnProperty(pHash))return false;return this.
|
|
|
447
447
|
*
|
|
448
448
|
* @author Steven Velozo <steven@velozo.com>
|
|
449
449
|
* @module CashMoney
|
|
450
|
-
|
|
450
|
+
*/ /**
|
|
451
451
|
* Linked List Node Prototype
|
|
452
452
|
*
|
|
453
453
|
* @class LinkedListNode
|
|
@@ -640,7 +640,7 @@ return true;}}module.exports=BaseLogger;},{"fable-serviceproviderbase":59}],53:[
|
|
|
640
640
|
*
|
|
641
641
|
*
|
|
642
642
|
* @author Steven Velozo <steven@velozo.com>
|
|
643
|
-
|
|
643
|
+
*/ // Return the providers that are available without extensions loaded
|
|
644
644
|
var getDefaultProviders=()=>{let tmpDefaultProviders={};tmpDefaultProviders.console=require('./Fable-Log-Logger-Console.js');tmpDefaultProviders.default=tmpDefaultProviders.console;return tmpDefaultProviders;};module.exports=getDefaultProviders();},{"./Fable-Log-Logger-Console.js":55}],54:[function(require,module,exports){module.exports=[{"loggertype":"console","streamtype":"console","level":"trace"}];},{}],55:[function(require,module,exports){let libBaseLogger=require('./Fable-Log-BaseLogger.js');class ConsoleLogger extends libBaseLogger{constructor(pLogStreamSettings,pFableLog){super(pLogStreamSettings);this._ShowTimeStamps='showtimestamps'in this._Settings?this._Settings.showtimestamps==true:true;this._FormattedTimeStamps='formattedtimestamps'in this._Settings?this._Settings.formattedtimestamps==true:true;this._ContextMessage='Context'in this._Settings?`(${this._Settings.Context})`:'Product'in pFableLog._Settings?`(${pFableLog._Settings.Product})`:'Unnamed_Log_Context';// Allow the user to decide what gets output to the console
|
|
645
645
|
this._OutputLogLinesToConsole='outputloglinestoconsole'in this._Settings?this._Settings.outputloglinestoconsole:true;this._OutputObjectsToConsole='outputobjectstoconsole'in this._Settings?this._Settings.outputobjectstoconsole:true;// Precompute the prefix for each level
|
|
646
646
|
this.prefixCache={};for(let i=0;i<=this.levels.length;i++){this.prefixCache[this.levels[i]]=`[${this.levels[i]}] ${this._ContextMessage}: `;if(this._ShowTimeStamps){// If there is a timestamp we need a to prepend space before the prefixcache string, since the timestamp comes first
|
|
@@ -730,7 +730,7 @@ function autoConstruct(pSettings){return new FableSettings(pSettings);}module.ex
|
|
|
730
730
|
*
|
|
731
731
|
*
|
|
732
732
|
* @author Steven Velozo <steven@velozo.com>
|
|
733
|
-
|
|
733
|
+
*/ // Adapted from node-uuid (https://github.com/kelektiv/node-uuid)
|
|
734
734
|
// Unique ID creation requires a high quality random # generator. In the
|
|
735
735
|
// browser this is a little complicated due to unknown quality of Math.random()
|
|
736
736
|
// and inconsistent support for the `crypto` API. We do the best we can via
|
|
@@ -776,7 +776,7 @@ if(isOwn&&'get'in desc&&!('originalValue'in desc.get)){value=desc.get;}else{valu
|
|
|
776
776
|
return reflectGetProto(O);}:originalGetProto?function getProto(O){if(!O||typeof O!=='object'&&typeof O!=='function'){throw new TypeError('getProto: not an object');}// @ts-expect-error TS can't narrow inside a closure, for some reason
|
|
777
777
|
return originalGetProto(O);}:getDunderProto?function getProto(O){// @ts-expect-error TS can't narrow inside a closure, for some reason
|
|
778
778
|
return getDunderProto(O);}:null;},{"./Object.getPrototypeOf":70,"./Reflect.getPrototypeOf":71,"dunder-proto/get":40}],73:[function(require,module,exports){'use strict';/** @type {import('./gOPD')} */module.exports=Object.getOwnPropertyDescriptor;},{}],74:[function(require,module,exports){'use strict';/** @type {import('.')} */var $gOPD=require('./gOPD');if($gOPD){try{$gOPD([],'length');}catch(e){// IE 8 has a broken gOPD
|
|
779
|
-
$gOPD=null;}}module.exports=$gOPD;},{"./gOPD":73}],75:[function(require,module,exports){'use strict';var origSymbol=typeof Symbol!=='undefined'&&Symbol;var hasSymbolSham=require('./shams');/** @type {import('.')} */module.exports=function hasNativeSymbols(){if(typeof origSymbol!=='function'){return false;}if(typeof Symbol!=='function'){return false;}if(typeof origSymbol('foo')!=='symbol'){return false;}if(typeof Symbol('bar')!=='symbol'){return false;}return hasSymbolSham();};},{"./shams":76}],76:[function(require,module,exports){'use strict';/** @type {import('./shams')}
|
|
779
|
+
$gOPD=null;}}module.exports=$gOPD;},{"./gOPD":73}],75:[function(require,module,exports){'use strict';var origSymbol=typeof Symbol!=='undefined'&&Symbol;var hasSymbolSham=require('./shams');/** @type {import('.')} */module.exports=function hasNativeSymbols(){if(typeof origSymbol!=='function'){return false;}if(typeof Symbol!=='function'){return false;}if(typeof origSymbol('foo')!=='symbol'){return false;}if(typeof Symbol('bar')!=='symbol'){return false;}return hasSymbolSham();};},{"./shams":76}],76:[function(require,module,exports){'use strict';/** @type {import('./shams')} */ /* eslint complexity: [2, 18], max-statements: [2, 33] */module.exports=function hasSymbols(){if(typeof Symbol!=='function'||typeof Object.getOwnPropertySymbols!=='function'){return false;}if(typeof Symbol.iterator==='symbol'){return true;}/** @type {{ [k in symbol]?: unknown }} */var obj={};var sym=Symbol('test');var symObj=Object(sym);if(typeof sym==='string'){return false;}if(Object.prototype.toString.call(sym)!=='[object Symbol]'){return false;}if(Object.prototype.toString.call(symObj)!=='[object Symbol]'){return false;}// temp disabled per https://github.com/ljharb/object.assign/issues/17
|
|
780
780
|
// if (sym instanceof Symbol) { return false; }
|
|
781
781
|
// temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
|
|
782
782
|
// if (!(symObj instanceof Symbol)) { return false; }
|
|
@@ -801,7 +801,12 @@ module.exports=function inherits(ctor,superCtor){if(superCtor){ctor.super_=super
|
|
|
801
801
|
//
|
|
802
802
|
// TODO: Should template literals be processed? If so what state do they have access to? That should happen here if so.
|
|
803
803
|
// TODO: Make a simple class include library with these
|
|
804
|
-
|
|
804
|
+
/**
|
|
805
|
+
* @param {string} pCharacter - The character to remove from the start and end of the string
|
|
806
|
+
* @param {string} pString - The string to clean
|
|
807
|
+
*
|
|
808
|
+
* @return {string} The cleaned string
|
|
809
|
+
*/const cleanWrapCharacters=(pCharacter,pString)=>{if(pString.startsWith(pCharacter)&&pString.endsWith(pCharacter)){return pString.substring(1,pString.length-1);}else{return pString;}};module.exports=cleanWrapCharacters;},{}],82:[function(require,module,exports){/**
|
|
805
810
|
* @author <steven@velozo.com>
|
|
806
811
|
*/let libSimpleLog=require('./Manyfest-LogToConsole.js');/**
|
|
807
812
|
* Hash Translation
|
|
@@ -817,20 +822,38 @@ const cleanWrapCharacters=(pCharacter,pString)=>{if(pString.startsWith(pCharacte
|
|
|
817
822
|
* their lookups by hash.
|
|
818
823
|
*
|
|
819
824
|
* @class ManyfestHashTranslation
|
|
820
|
-
*/class ManyfestHashTranslation{
|
|
821
|
-
|
|
825
|
+
*/class ManyfestHashTranslation{/**
|
|
826
|
+
* @param {function} [pInfoLog] - (optional) A logging function for info messages
|
|
827
|
+
* @param {function} [pErrorLog] - (optional) A logging function for error messages
|
|
828
|
+
*/constructor(pInfoLog,pErrorLog){// Wire in logging
|
|
829
|
+
this.logInfo=typeof pInfoLog==='function'?pInfoLog:libSimpleLog;this.logError=typeof pErrorLog==='function'?pErrorLog:libSimpleLog;this.translationTable={};}/**
|
|
830
|
+
* @return {number} The number of translations in the table
|
|
831
|
+
*/translationCount(){return Object.keys(this.translationTable).length;}/**
|
|
832
|
+
* @param {object} pTranslation - An object containing source:destination hash pairs to add to the translation table
|
|
833
|
+
*/addTranslation(pTranslation){// This adds a translation in the form of:
|
|
822
834
|
// { "SourceHash": "DestinationHash", "SecondSourceHash":"SecondDestinationHash" }
|
|
823
|
-
if(typeof pTranslation!='object'){this.logError(`Hash translation addTranslation expected a translation be type object but was passed in ${typeof pTranslation}`);return false;}let tmpTranslationSources=Object.keys(pTranslation);tmpTranslationSources.forEach(pTranslationSource=>{if(typeof pTranslation[pTranslationSource]!='string'){this.logError(`Hash translation addTranslation expected a translation destination hash for [${pTranslationSource}] to be a string but the referrant was a ${typeof pTranslation[pTranslationSource]}`);}else{this.translationTable[pTranslationSource]=pTranslation[pTranslationSource];}});}
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
835
|
+
if(typeof pTranslation!='object'){this.logError(`Hash translation addTranslation expected a translation be type object but was passed in ${typeof pTranslation}`);return false;}let tmpTranslationSources=Object.keys(pTranslation);tmpTranslationSources.forEach(pTranslationSource=>{if(typeof pTranslation[pTranslationSource]!='string'){this.logError(`Hash translation addTranslation expected a translation destination hash for [${pTranslationSource}] to be a string but the referrant was a ${typeof pTranslation[pTranslationSource]}`);}else{this.translationTable[pTranslationSource]=pTranslation[pTranslationSource];}});}/**
|
|
836
|
+
* @param {string} pTranslationHash - The source hash to remove from the translation table
|
|
837
|
+
*/removeTranslationHash(pTranslationHash){delete this.translationTable[pTranslationHash];}/**
|
|
838
|
+
* This removes translations.
|
|
839
|
+
* If passed a string, just removes the single one.
|
|
840
|
+
* If passed an object, it does all the source keys.
|
|
841
|
+
*
|
|
842
|
+
* @param {string|object} pTranslation - Either a source hash string to remove, or an object containing source:destination hash pairs to remove
|
|
843
|
+
*
|
|
844
|
+
* @return {boolean} True if the removal was successful, false otherwise
|
|
845
|
+
*/removeTranslation(pTranslation){if(typeof pTranslation=='string'){this.removeTranslationHash(pTranslation);return true;}else if(typeof pTranslation=='object'){let tmpTranslationSources=Object.keys(pTranslation);tmpTranslationSources.forEach(pTranslationSource=>{this.removeTranslation(pTranslationSource);});return true;}else{this.logError(`Hash translation removeTranslation expected either a string or an object but the passed-in translation was type ${typeof pTranslation}`);return false;}}clearTranslations(){this.translationTable={};}/**
|
|
846
|
+
* @param {string} pTranslation - The source hash to translate
|
|
847
|
+
*
|
|
848
|
+
* @return {string} The translated hash, or the original if no translation exists
|
|
849
|
+
*/translate(pTranslation){if(pTranslation in this.translationTable){return this.translationTable[pTranslation];}else{return pTranslation;}}}module.exports=ManyfestHashTranslation;},{"./Manyfest-LogToConsole.js":83}],83:[function(require,module,exports){/**
|
|
827
850
|
* @author <steven@velozo.com>
|
|
828
|
-
|
|
851
|
+
*/ /**
|
|
829
852
|
* Manyfest simple logging shim (for browser and dependency-free running)
|
|
830
853
|
*/const logToConsole=(pLogLine,pLogObject)=>{let tmpLogLine=typeof pLogLine==='string'?pLogLine:'';console.log(`[Manyfest] ${tmpLogLine}`);if(pLogObject)console.log(JSON.stringify(pLogObject));};module.exports=logToConsole;},{}],84:[function(require,module,exports){/**
|
|
831
854
|
* @author <steven@velozo.com>
|
|
832
855
|
*/const libSimpleLog=require('./Manyfest-LogToConsole.js');// This is for resolving functions mid-address
|
|
833
|
-
const libGetObjectValue=require('./Manyfest-ObjectAddress-GetValue.js');// TODO: Just until this is a fable service.
|
|
856
|
+
const libGetObjectValue=require('./Manyfest-ObjectAddress-GetValue.js');const fCleanWrapCharacters=require('./Manyfest-CleanWrapCharacters.js');// TODO: Just until this is a fable service.
|
|
834
857
|
let _MockFable={DataFormat:require('./Manyfest-ObjectAddress-Parser.js')};/**
|
|
835
858
|
* Object Address Resolver
|
|
836
859
|
*
|
|
@@ -848,14 +871,24 @@ let _MockFable={DataFormat:require('./Manyfest-ObjectAddress-Parser.js')};/**
|
|
|
848
871
|
*
|
|
849
872
|
*
|
|
850
873
|
* @class ManyfestObjectAddressResolverCheckAddressExists
|
|
851
|
-
*/class ManyfestObjectAddressResolverCheckAddressExists{
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
//
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
874
|
+
*/class ManyfestObjectAddressResolverCheckAddressExists{/**
|
|
875
|
+
* @param {function} [pInfoLog] - (optional) Function to use for info logging
|
|
876
|
+
* @param {function} [pErrorLog] - (optional) Function to use for error logging
|
|
877
|
+
*/constructor(pInfoLog,pErrorLog){// Wire in logging
|
|
878
|
+
this.logInfo=typeof pInfoLog=='function'?pInfoLog:libSimpleLog;this.logError=typeof pErrorLog=='function'?pErrorLog:libSimpleLog;this.getObjectValueClass=new libGetObjectValue(this.logInfo,this.logError);this.cleanWrapCharacters=fCleanWrapCharacters;}/**
|
|
879
|
+
* Check if an address exists.
|
|
880
|
+
*
|
|
881
|
+
* This is necessary because the getValueAtAddress function is ambiguous on
|
|
882
|
+
* whether the element/property is actually there or not (it returns
|
|
883
|
+
* undefined whether the property exists or not). This function checks for
|
|
884
|
+
* existance and returns true or false dependent.
|
|
885
|
+
*
|
|
886
|
+
* @param {object} pObject - The object to check within
|
|
887
|
+
* @param {string} pAddress - The address to check for
|
|
888
|
+
* @param {object} [pRootObject] - (optional) The root object for function resolution context
|
|
889
|
+
*
|
|
890
|
+
* @return {boolean} - True if the address exists, false if it does not
|
|
891
|
+
*/checkAddressExists(pObject,pAddress,pRootObject){// TODO: Should these throw an error?
|
|
859
892
|
// Make sure pObject is an object
|
|
860
893
|
if(typeof pObject!='object')return false;// Make sure pAddress is a string
|
|
861
894
|
if(typeof pAddress!='string')return false;// Set the root object to the passed-in object if it isn't set yet. This is expected to be the root object.
|
|
@@ -923,19 +956,19 @@ let tmpFunctionStartIndex=tmpSubObjectName.indexOf('(');// NOTE THAT FUNCTIONS M
|
|
|
923
956
|
// 1) The start bracket is after character 0
|
|
924
957
|
if(tmpFunctionStartIndex>0// 2) The end bracket is after the start bracket
|
|
925
958
|
&&_MockFable.DataFormat.stringCountEnclosures(tmpSubObjectName)>0){let tmpFunctionAddress=tmpSubObjectName.substring(0,tmpFunctionStartIndex).trim();//tmpParentAddress = `${tmpParentAddress}${(tmpParentAddress.length > 0) ? '.' : ''}${tmpSubObjectName}`;
|
|
926
|
-
if(
|
|
959
|
+
if(typeof pObject[tmpFunctionAddress]!=='function'){// The address suggests it is a function, but it is not.
|
|
927
960
|
return false;}// Now see if the function has arguments.
|
|
928
961
|
// Implementation notes: * ARGUMENTS MUST SHARE THE SAME ROOT OBJECT CONTEXT *
|
|
929
962
|
let tmpFunctionArguments=_MockFable.DataFormat.stringGetSegments(_MockFable.DataFormat.stringGetEnclosureValueByIndex(tmpSubObjectName.substring(tmpFunctionAddress.length),0),',');if(tmpFunctionArguments.length==0||tmpFunctionArguments[0]==''){// No arguments... just call the function (bound to the scope of the object it is contained withing)
|
|
930
963
|
if(tmpFunctionAddress in pObject){try{return this.checkAddressExists(pObject[tmpFunctionAddress].apply(pObject),tmpNewAddress,tmpRootObject);}catch(pError){// The function call failed, so the address doesn't exist
|
|
931
|
-
libSimpleLog
|
|
932
|
-
libSimpleLog
|
|
964
|
+
libSimpleLog(`Error calling function ${tmpFunctionAddress} (address [${pAddress}]): ${pError.message}`);return false;}}else{// The function doesn't exist, so the address doesn't exist
|
|
965
|
+
libSimpleLog(`Function ${tmpFunctionAddress} does not exist (address [${pAddress}])`);return false;}}else{let tmpArgumentValues=[];let tmpRootObject=typeof pRootObject=='undefined'?pObject:pRootObject;// Now get the value for each argument
|
|
933
966
|
for(let i=0;i<tmpFunctionArguments.length;i++){// Resolve the values for each subsequent entry
|
|
934
967
|
// NOTE: This is where the resolves get really tricky. Recursion within recursion. Programming gom jabbar, yo.
|
|
935
968
|
tmpArgumentValues.push(this.getObjectValueClass.getValueAtAddress(tmpRootObject,tmpFunctionArguments[i]));}//return this.checkAddressExists(pObject[tmpFunctionAddress].apply(pObject, tmpArgumentValues), tmpNewAddress, tmpRootObject);
|
|
936
969
|
if(tmpFunctionAddress in pObject){try{return this.checkAddressExists(pObject[tmpFunctionAddress].apply(pObject,tmpArgumentValues),tmpNewAddress,tmpRootObject);}catch(pError){// The function call failed, so the address doesn't exist
|
|
937
|
-
libSimpleLog
|
|
938
|
-
libSimpleLog
|
|
970
|
+
libSimpleLog(`Error calling function ${tmpFunctionAddress} (address [${pAddress}]): ${pError.message}`);return false;}}else{// The function doesn't exist, so the address doesn't exist
|
|
971
|
+
libSimpleLog(`Function ${tmpFunctionAddress} does not exist (address [${pAddress}])`);return false;}}}// Boxed elements look like this:
|
|
939
972
|
// MyValues[42]
|
|
940
973
|
// MyValues['Color']
|
|
941
974
|
// MyValues["Weight"]
|
|
@@ -972,7 +1005,7 @@ return this.checkAddressExists(pObject[tmpBoxedPropertyName][tmpBoxedPropertyNum
|
|
|
972
1005
|
// then the system can't set the value in there. Error and abort!
|
|
973
1006
|
if(tmpSubObjectName in pObject&&typeof pObject[tmpSubObjectName]!=='object'){return false;}else if(tmpSubObjectName in pObject){// If there is already a subobject pass that to the recursive thingy
|
|
974
1007
|
return this.checkAddressExists(pObject[tmpSubObjectName],tmpNewAddress,tmpRootObject);}else{// Create a subobject and then pass that
|
|
975
|
-
pObject[tmpSubObjectName]={};return this.checkAddressExists(pObject[tmpSubObjectName],tmpNewAddress,tmpRootObject);}}}}
|
|
1008
|
+
pObject[tmpSubObjectName]={};return this.checkAddressExists(pObject[tmpSubObjectName],tmpNewAddress,tmpRootObject);}}}}module.exports=ManyfestObjectAddressResolverCheckAddressExists;},{"./Manyfest-CleanWrapCharacters.js":81,"./Manyfest-LogToConsole.js":83,"./Manyfest-ObjectAddress-GetValue.js":86,"./Manyfest-ObjectAddress-Parser.js":87}],85:[function(require,module,exports){/**
|
|
976
1009
|
* @author <steven@velozo.com>
|
|
977
1010
|
*/let libSimpleLog=require('./Manyfest-LogToConsole.js');let fCleanWrapCharacters=require('./Manyfest-CleanWrapCharacters.js');let fParseConditionals=require(`../source/Manyfest-ParseConditionals.js`);/**
|
|
978
1011
|
* Object Address Resolver - DeleteValue
|
|
@@ -993,10 +1026,25 @@ pObject[tmpSubObjectName]={};return this.checkAddressExists(pObject[tmpSubObject
|
|
|
993
1026
|
* three separate modules.
|
|
994
1027
|
*
|
|
995
1028
|
* @class ManyfestObjectAddressResolverDeleteValue
|
|
996
|
-
*/class ManyfestObjectAddressResolverDeleteValue{
|
|
1029
|
+
*/class ManyfestObjectAddressResolverDeleteValue{/**
|
|
1030
|
+
* @param {function} [pInfoLog] - (optional) A logging function for info messages
|
|
1031
|
+
* @param {function} [pErrorLog] - (optional) A logging function for error messages
|
|
1032
|
+
*/constructor(pInfoLog,pErrorLog){// Wire in logging
|
|
997
1033
|
this.logInfo=typeof pInfoLog=='function'?pInfoLog:libSimpleLog;this.logError=typeof pErrorLog=='function'?pErrorLog:libSimpleLog;this.cleanWrapCharacters=fCleanWrapCharacters;}// TODO: Dry me
|
|
998
|
-
|
|
999
|
-
|
|
1034
|
+
/**
|
|
1035
|
+
* @param {string} pAddress - The address being evaluated
|
|
1036
|
+
* @param {object} pRecord - The record being evaluated
|
|
1037
|
+
*
|
|
1038
|
+
* @return {boolean} True if the record passes the filters, false if it does not
|
|
1039
|
+
*/checkRecordFilters(pAddress,pRecord){return fParseConditionals(this,pAddress,pRecord);}/**
|
|
1040
|
+
* Delete the value of an element at an address
|
|
1041
|
+
*
|
|
1042
|
+
* @param {object} pObject - The object to delete the value from
|
|
1043
|
+
* @param {string} pAddress - The address to delete the value at
|
|
1044
|
+
* @param {string} [pParentAddress] - (optional) The parent address for recursion
|
|
1045
|
+
*
|
|
1046
|
+
* @return {boolean|object|undefined} - True if the value was deleted, false if it could not be deleted, undefined on error
|
|
1047
|
+
*/deleteValueAtAddress(pObject,pAddress,pParentAddress){// Make sure pObject (the object we are meant to be recursing) is an object (which could be an array or object)
|
|
1000
1048
|
if(typeof pObject!='object')return undefined;// Make sure pAddress (the address we are resolving) is a string
|
|
1001
1049
|
if(typeof pAddress!='string')return undefined;// Stash the parent address for later resolution
|
|
1002
1050
|
let tmpParentAddress="";if(typeof pParentAddress=='string'){tmpParentAddress=pParentAddress;}// TODO: Make this work for things like SomeRootObject.Metadata["Some.People.Use.Bad.Object.Property.Names"]
|
|
@@ -1120,9 +1168,25 @@ tmpParentAddress=`${tmpParentAddress}${tmpParentAddress.length>0?'.':''}${tmpSub
|
|
|
1120
1168
|
* three separate modules.
|
|
1121
1169
|
*
|
|
1122
1170
|
* @class ManyfestObjectAddressResolverGetValue
|
|
1123
|
-
*/class ManyfestObjectAddressResolverGetValue{
|
|
1124
|
-
|
|
1125
|
-
|
|
1171
|
+
*/class ManyfestObjectAddressResolverGetValue{/**
|
|
1172
|
+
* @param {function} [pInfoLog] - (optional) A logging function for info messages
|
|
1173
|
+
* @param {function} [pErrorLog] - (optional) A logging function for error messages
|
|
1174
|
+
*/constructor(pInfoLog,pErrorLog){// Wire in logging
|
|
1175
|
+
this.logInfo=typeof pInfoLog=='function'?pInfoLog:libSimpleLog;this.logError=typeof pErrorLog=='function'?pErrorLog:libSimpleLog;this.cleanWrapCharacters=fCleanWrapCharacters;}/**
|
|
1176
|
+
* @param {string} pAddress - The address of the record to check
|
|
1177
|
+
* @param {object} pRecord - The record to check against the filters
|
|
1178
|
+
*
|
|
1179
|
+
* @return {boolean} - True if the record passes the filters, false otherwise
|
|
1180
|
+
*/checkRecordFilters(pAddress,pRecord){return fParseConditionals(this,pAddress,pRecord);}/**
|
|
1181
|
+
* Get the value of an element at an address
|
|
1182
|
+
*
|
|
1183
|
+
* @param {object} pObject - The object to resolve the address against
|
|
1184
|
+
* @param {string} pAddress - The address to resolve
|
|
1185
|
+
* @param {string} [pParentAddress] - (optional) The parent address for back-navigation
|
|
1186
|
+
* @param {object} [pRootObject] - (optional) The root object for function argument resolution
|
|
1187
|
+
*
|
|
1188
|
+
* @return {any} The value at the address, or undefined if not found
|
|
1189
|
+
*/getValueAtAddress(pObject,pAddress,pParentAddress,pRootObject){// Make sure pObject (the object we are meant to be recursing) is an object (which could be an array or object)
|
|
1126
1190
|
if(typeof pObject!='object'){return undefined;}if(pObject===null){return undefined;}// Make sure pAddress (the address we are resolving) is a string
|
|
1127
1191
|
if(typeof pAddress!='string'){return undefined;}// Stash the parent address for later resolution
|
|
1128
1192
|
let tmpParentAddress="";if(typeof pParentAddress=='string'){tmpParentAddress=pParentAddress;}// Set the root object to the passed-in object if it isn't set yet. This is expected to be the root object.
|
|
@@ -1156,7 +1220,7 @@ let tmpFunctionStartIndex=pAddress.indexOf('(');// NOTE THAT FUNCTIONS MUST RESO
|
|
|
1156
1220
|
// The requirements to detect a function are:
|
|
1157
1221
|
// 1) The start bracket is after character 0
|
|
1158
1222
|
if(tmpFunctionStartIndex>0// 2) The end bracket is after the start bracket
|
|
1159
|
-
&&_MockFable.DataFormat.stringCountEnclosures(pAddress)>0){let tmpFunctionAddress=pAddress.substring(0,tmpFunctionStartIndex).trim();if(
|
|
1223
|
+
&&_MockFable.DataFormat.stringCountEnclosures(pAddress)>0){let tmpFunctionAddress=pAddress.substring(0,tmpFunctionStartIndex).trim();if(typeof pObject[tmpFunctionAddress]!=='function'){// The address suggests it is a function, but it is not.
|
|
1160
1224
|
return false;}// Now see if the function has arguments.
|
|
1161
1225
|
// Implementation notes: * ARGUMENTS MUST SHARE THE SAME ROOT OBJECT CONTEXT *
|
|
1162
1226
|
let tmpFunctionArguments=_MockFable.DataFormat.stringGetSegments(_MockFable.DataFormat.stringGetEnclosureValueByIndex(pAddress.substring(tmpFunctionAddress.length),0),',');if(tmpFunctionArguments.length==0||tmpFunctionArguments[0]==''){// No arguments... just call the function (bound to the scope of the object it is contained withing)
|
|
@@ -1223,7 +1287,7 @@ let tmpFunctionStartIndex=tmpSubObjectName.indexOf('(');// NOTE THAT FUNCTIONS M
|
|
|
1223
1287
|
// The requirements to detect a function are:
|
|
1224
1288
|
// 1) The start bracket is after character 0
|
|
1225
1289
|
if(tmpFunctionStartIndex>0// 2) The end bracket is after the start bracket
|
|
1226
|
-
&&_MockFable.DataFormat.stringCountEnclosures(tmpSubObjectName)>0){let tmpFunctionAddress=tmpSubObjectName.substring(0,tmpFunctionStartIndex).trim();tmpParentAddress=`${tmpParentAddress}${tmpParentAddress.length>0?'.':''}${tmpSubObjectName}`;if(
|
|
1290
|
+
&&_MockFable.DataFormat.stringCountEnclosures(tmpSubObjectName)>0){let tmpFunctionAddress=tmpSubObjectName.substring(0,tmpFunctionStartIndex).trim();tmpParentAddress=`${tmpParentAddress}${tmpParentAddress.length>0?'.':''}${tmpSubObjectName}`;if(typeof pObject[tmpFunctionAddress]!=='function'){// The address suggests it is a function, but it is not.
|
|
1227
1291
|
return false;}// Now see if the function has arguments.
|
|
1228
1292
|
// Implementation notes: * ARGUMENTS MUST SHARE THE SAME ROOT OBJECT CONTEXT *
|
|
1229
1293
|
let tmpFunctionArguments=_MockFable.DataFormat.stringGetSegments(_MockFable.DataFormat.stringGetEnclosureValueByIndex(tmpSubObjectName.substring(tmpFunctionAddress.length),0),',');if(tmpFunctionArguments.length==0||tmpFunctionArguments[0]==''){// No arguments... just call the function (bound to the scope of the object it is contained withing)
|
|
@@ -1297,15 +1361,16 @@ tmpParentAddress=`${tmpParentAddress}${tmpParentAddress.length>0?'.':''}${tmpSub
|
|
|
1297
1361
|
// are more or less pure javascript and as functional as they can be made to be.
|
|
1298
1362
|
// Until we shift Manyfest to be a fable service, these three functions were pulled out of
|
|
1299
1363
|
// fable to aid in parsing functions with nested enclosures.
|
|
1300
|
-
module.exports={/**
|
|
1364
|
+
const DEFAULT_START_SYMBOL_MAP={'{':0,'[':1,'(':2};const DEFAULT_END_SYMBOL_MAP={'}':0,']':1,')':2};module.exports={/**
|
|
1301
1365
|
* Count the number of segments in a string, respecting enclosures
|
|
1302
|
-
*
|
|
1303
|
-
* @param {string} pString
|
|
1304
|
-
* @param {string} pSeparator
|
|
1305
|
-
* @param {
|
|
1306
|
-
* @param {
|
|
1307
|
-
*
|
|
1308
|
-
|
|
1366
|
+
*
|
|
1367
|
+
* @param {string} pString
|
|
1368
|
+
* @param {string} [pSeparator]
|
|
1369
|
+
* @param {Record<string, number>} [pEnclosureStartSymbolMap]
|
|
1370
|
+
* @param {Record<string, number>} [pEnclosureEndSymbolMap]
|
|
1371
|
+
*
|
|
1372
|
+
* @return {number} - The number of segments in the string
|
|
1373
|
+
*/stringCountSegments:(pString,pSeparator,pEnclosureStartSymbolMap,pEnclosureEndSymbolMap)=>{let tmpString=typeof pString=='string'?pString:'';let tmpSeparator=typeof pSeparator=='string'?pSeparator:'.';let tmpEnclosureStartSymbolMap=typeof pEnclosureStartSymbolMap=='object'?pEnclosureStartSymbolMap:DEFAULT_START_SYMBOL_MAP;let tmpEnclosureEndSymbolMap=typeof pEnclosureEndSymbolMap=='object'?pEnclosureEndSymbolMap:DEFAULT_END_SYMBOL_MAP;if(pString.length<1){return 0;}let tmpSegmentCount=1;let tmpEnclosureStack=[];for(let i=0;i<tmpString.length;i++){// IF This is the start of a segment
|
|
1309
1374
|
if(tmpString[i]==tmpSeparator// AND we are not in a nested portion of the string
|
|
1310
1375
|
&&tmpEnclosureStack.length==0){// Increment the segment count
|
|
1311
1376
|
tmpSegmentCount++;}// IF This is the start of an enclosure
|
|
@@ -1315,13 +1380,14 @@ else if(tmpString[i]in tmpEnclosureEndSymbolMap// AND it matches the current nes
|
|
|
1315
1380
|
&&tmpEnclosureEndSymbolMap[tmpString[i]]==tmpEnclosureStack[tmpEnclosureStack.length-1]){// Pop it off the stack!
|
|
1316
1381
|
tmpEnclosureStack.pop();}}return tmpSegmentCount;},/**
|
|
1317
1382
|
* Get the first segment in a string, respecting enclosures
|
|
1318
|
-
*
|
|
1319
|
-
* @param {string} pString
|
|
1320
|
-
* @param {string} pSeparator
|
|
1321
|
-
* @param {
|
|
1322
|
-
* @param {
|
|
1323
|
-
*
|
|
1324
|
-
|
|
1383
|
+
*
|
|
1384
|
+
* @param {string} pString
|
|
1385
|
+
* @param {string} [pSeparator]
|
|
1386
|
+
* @param {Record<string, number>} [pEnclosureStartSymbolMap]
|
|
1387
|
+
* @param {Record<string, number>} [pEnclosureEndSymbolMap]
|
|
1388
|
+
*
|
|
1389
|
+
* @return {string} - the first segment in the string as a string
|
|
1390
|
+
*/stringGetFirstSegment:(pString,pSeparator,pEnclosureStartSymbolMap,pEnclosureEndSymbolMap)=>{let tmpString=typeof pString=='string'?pString:'';let tmpSeparator=typeof pSeparator=='string'?pSeparator:'.';let tmpEnclosureStartSymbolMap=typeof pEnclosureStartSymbolMap=='object'?pEnclosureStartSymbolMap:DEFAULT_START_SYMBOL_MAP;let tmpEnclosureEndSymbolMap=typeof pEnclosureEndSymbolMap=='object'?pEnclosureEndSymbolMap:DEFAULT_END_SYMBOL_MAP;if(pString.length<1){return'';}let tmpEnclosureStack=[];for(let i=0;i<tmpString.length;i++){// IF This is the start of a segment
|
|
1325
1391
|
if(tmpString[i]==tmpSeparator// AND we are not in a nested portion of the string
|
|
1326
1392
|
&&tmpEnclosureStack.length==0){// Return the segment
|
|
1327
1393
|
return tmpString.substring(0,i);}// IF This is the start of an enclosure
|
|
@@ -1331,13 +1397,14 @@ else if(tmpString[i]in tmpEnclosureEndSymbolMap// AND it matches the current nes
|
|
|
1331
1397
|
&&tmpEnclosureEndSymbolMap[tmpString[i]]==tmpEnclosureStack[tmpEnclosureStack.length-1]){// Pop it off the stack!
|
|
1332
1398
|
tmpEnclosureStack.pop();}}return tmpString;},/**
|
|
1333
1399
|
* Get all segments in a string, respecting enclosures
|
|
1334
|
-
*
|
|
1335
|
-
* @param {string} pString
|
|
1336
|
-
* @param {string} pSeparator
|
|
1337
|
-
* @param {
|
|
1338
|
-
* @param {
|
|
1339
|
-
*
|
|
1340
|
-
|
|
1400
|
+
*
|
|
1401
|
+
* @param {string} pString
|
|
1402
|
+
* @param {string} [pSeparator]
|
|
1403
|
+
* @param {Record<string, number>} [pEnclosureStartSymbolMap]
|
|
1404
|
+
* @param {Record<string, number>} [pEnclosureEndSymbolMap]
|
|
1405
|
+
*
|
|
1406
|
+
* @return {Array<string>} - the segments in the string as an array of strings
|
|
1407
|
+
*/stringGetSegments:(pString,pSeparator,pEnclosureStartSymbolMap,pEnclosureEndSymbolMap)=>{let tmpString=typeof pString=='string'?pString:'';let tmpSeparator=typeof pSeparator=='string'?pSeparator:'.';let tmpEnclosureStartSymbolMap=typeof pEnclosureStartSymbolMap=='object'?pEnclosureStartSymbolMap:DEFAULT_START_SYMBOL_MAP;let tmpEnclosureEndSymbolMap=typeof pEnclosureEndSymbolMap=='object'?pEnclosureEndSymbolMap:DEFAULT_END_SYMBOL_MAP;let tmpCurrentSegmentStart=0;let tmpSegmentList=[];if(pString.length<1){return tmpSegmentList;}let tmpEnclosureStack=[];for(let i=0;i<tmpString.length;i++){// IF This is the start of a segment
|
|
1341
1408
|
if(tmpString[i]==tmpSeparator// AND we are not in a nested portion of the string
|
|
1342
1409
|
&&tmpEnclosureStack.length==0){// Return the segment
|
|
1343
1410
|
tmpSegmentList.push(tmpString.substring(tmpCurrentSegmentStart,i));tmpCurrentSegmentStart=i+1;}// IF This is the start of an enclosure
|
|
@@ -1351,8 +1418,8 @@ tmpEnclosureStack.pop();}}if(tmpCurrentSegmentStart<tmpString.length){tmpSegment
|
|
|
1351
1418
|
* If no start or end characters are specified, it will default to parentheses. If the string is not a string, it will return 0.
|
|
1352
1419
|
*
|
|
1353
1420
|
* @param {string} pString
|
|
1354
|
-
* @param {string} pEnclosureStart
|
|
1355
|
-
* @param {string} pEnclosureEnd
|
|
1421
|
+
* @param {string} [pEnclosureStart]
|
|
1422
|
+
* @param {string} [pEnclosureEnd]
|
|
1356
1423
|
* @returns the count of full in the string
|
|
1357
1424
|
*/stringCountEnclosures:(pString,pEnclosureStart,pEnclosureEnd)=>{let tmpString=typeof pString=='string'?pString:'';let tmpEnclosureStart=typeof pEnclosureStart=='string'?pEnclosureStart:'(';let tmpEnclosureEnd=typeof pEnclosureEnd=='string'?pEnclosureEnd:')';let tmpEnclosureCount=0;let tmpEnclosureDepth=0;for(let i=0;i<tmpString.length;i++){// This is the start of an enclosure
|
|
1358
1425
|
if(tmpString[i]==tmpEnclosureStart){if(tmpEnclosureDepth==0){tmpEnclosureCount++;}tmpEnclosureDepth++;}else if(tmpString[i]==tmpEnclosureEnd){tmpEnclosureDepth--;}}return tmpEnclosureCount;},/**
|
|
@@ -1362,9 +1429,10 @@ if(tmpString[i]==tmpEnclosureStart){if(tmpEnclosureDepth==0){tmpEnclosureCount++
|
|
|
1362
1429
|
*
|
|
1363
1430
|
* @param {string} pString
|
|
1364
1431
|
* @param {number} pEnclosureIndexToGet
|
|
1365
|
-
* @param {string} pEnclosureStart
|
|
1366
|
-
* @param {string}
|
|
1367
|
-
*
|
|
1432
|
+
* @param {string} [pEnclosureStart]
|
|
1433
|
+
* @param {string} [pEnclosureEnd]
|
|
1434
|
+
*
|
|
1435
|
+
* @return {string} - The value of the enclosure at the specified index
|
|
1368
1436
|
*/stringGetEnclosureValueByIndex:(pString,pEnclosureIndexToGet,pEnclosureStart,pEnclosureEnd)=>{let tmpString=typeof pString=='string'?pString:'';let tmpEnclosureIndexToGet=typeof pEnclosureIndexToGet=='number'?pEnclosureIndexToGet:0;let tmpEnclosureStart=typeof pEnclosureStart=='string'?pEnclosureStart:'(';let tmpEnclosureEnd=typeof pEnclosureEnd=='string'?pEnclosureEnd:')';let tmpEnclosureCount=0;let tmpEnclosureDepth=0;let tmpMatchedEnclosureIndex=false;let tmpEnclosedValueStartIndex=0;let tmpEnclosedValueEndIndex=0;for(let i=0;i<tmpString.length;i++){// This is the start of an enclosure
|
|
1369
1437
|
if(tmpString[i]==tmpEnclosureStart){tmpEnclosureDepth++;// Only count enclosures at depth 1, but still this parses both pairs of all of them.
|
|
1370
1438
|
if(tmpEnclosureDepth==1){tmpEnclosureCount++;if(tmpEnclosureIndexToGet==tmpEnclosureCount-1){// This is the start of *the* enclosure
|
|
@@ -1390,9 +1458,19 @@ return'';}if(tmpEnclosedValueEndIndex>0&&tmpEnclosedValueEndIndex>tmpEnclosedVal
|
|
|
1390
1458
|
*
|
|
1391
1459
|
*
|
|
1392
1460
|
* @class ManyfestObjectAddressSetValue
|
|
1393
|
-
*/class ManyfestObjectAddressSetValue{
|
|
1394
|
-
|
|
1395
|
-
|
|
1461
|
+
*/class ManyfestObjectAddressSetValue{/**
|
|
1462
|
+
* @param {function} [pInfoLog] - (optional) A logging function for info messages
|
|
1463
|
+
* @param {function} [pErrorLog] - (optional) A logging function for error messages
|
|
1464
|
+
*/constructor(pInfoLog,pErrorLog){// Wire in logging
|
|
1465
|
+
this.logInfo=typeof pInfoLog=='function'?pInfoLog:libSimpleLog;this.logError=typeof pErrorLog=='function'?pErrorLog:libSimpleLog;this.cleanWrapCharacters=fCleanWrapCharacters;}/**
|
|
1466
|
+
* Set the value of an element at an address
|
|
1467
|
+
*
|
|
1468
|
+
* @param {object} pObject - The object to set the value in
|
|
1469
|
+
* @param {string} pAddress - The address to set the value at
|
|
1470
|
+
* @param {any} pValue - The value to set at the address
|
|
1471
|
+
*
|
|
1472
|
+
* @return {boolean} True if the value was set, false otherwise
|
|
1473
|
+
*/setValueAtAddress(pObject,pAddress,pValue){// Make sure pObject is an object
|
|
1396
1474
|
if(typeof pObject!='object')return false;// Make sure pAddress is a string
|
|
1397
1475
|
if(typeof pAddress!='string')return false;let tmpSeparatorIndex=pAddress.indexOf('.');if(tmpSeparatorIndex==-1){// Check if it's a boxed property
|
|
1398
1476
|
let tmpBracketStartIndex=pAddress.indexOf('[');let tmpBracketStopIndex=pAddress.indexOf(']');// Boxed elements look like this:
|
|
@@ -1489,18 +1567,28 @@ pObject[tmpSubObjectName]={};return this.setValueAtAddress(pObject[tmpSubObjectN
|
|
|
1489
1567
|
*
|
|
1490
1568
|
*
|
|
1491
1569
|
* @class ManyfestObjectAddressGeneration
|
|
1492
|
-
*/class ManyfestObjectAddressGeneration{
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
//
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1570
|
+
*/class ManyfestObjectAddressGeneration{/**
|
|
1571
|
+
* @param {function} [pInfoLog] - (optional) A logging function for info messages
|
|
1572
|
+
* @param {function} [pErrorLog] - (optional) A logging function for error messages
|
|
1573
|
+
*/constructor(pInfoLog,pErrorLog){// Wire in logging
|
|
1574
|
+
this.logInfo=typeof pInfoLog=='function'?pInfoLog:libSimpleLog;this.logError=typeof pErrorLog=='function'?pErrorLog:libSimpleLog;}/**
|
|
1575
|
+
* generateAddressses
|
|
1576
|
+
*
|
|
1577
|
+
* This flattens an object into a set of key:value pairs for *EVERY SINGLE
|
|
1578
|
+
* POSSIBLE ADDRESS* in the object. It can get ... really insane really
|
|
1579
|
+
* quickly. This is not meant to be used directly to generate schemas, but
|
|
1580
|
+
* instead as a starting point for scripts or UIs.
|
|
1581
|
+
*
|
|
1582
|
+
* This will return a mega set of key:value pairs with all possible schema
|
|
1583
|
+
* permutations and default values (when not an object) and everything else.
|
|
1584
|
+
*
|
|
1585
|
+
* @param {any} pObject - The object to generate addresses for
|
|
1586
|
+
* @param {string} [pBaseAddress] - (optional) The base address to start from
|
|
1587
|
+
* @param {object} [pSchema] - (optional) The schema object to append to
|
|
1588
|
+
*
|
|
1589
|
+
* @return {object} The generated schema object
|
|
1590
|
+
*/generateAddressses(pObject,pBaseAddress,pSchema){let tmpBaseAddress=typeof pBaseAddress=='string'?pBaseAddress:'';let tmpSchema=typeof pSchema=='object'?pSchema:{};let tmpObjectType=typeof pObject;let tmpSchemaObjectEntry={Address:tmpBaseAddress,Hash:tmpBaseAddress,Name:tmpBaseAddress,// This is so scripts and UI controls can force a developer to opt-in.
|
|
1591
|
+
InSchema:false};if(tmpObjectType=='object'&&pObject==null){tmpObjectType='undefined';}switch(tmpObjectType){case'string':tmpSchemaObjectEntry.DataType='String';tmpSchemaObjectEntry.Default=pObject;tmpSchema[tmpBaseAddress]=tmpSchemaObjectEntry;break;case'number':case'bigint':tmpSchemaObjectEntry.DataType='Number';tmpSchemaObjectEntry.Default=pObject;tmpSchema[tmpBaseAddress]=tmpSchemaObjectEntry;break;case'undefined':tmpSchemaObjectEntry.DataType='Any';tmpSchemaObjectEntry.Default=pObject;tmpSchema[tmpBaseAddress]=tmpSchemaObjectEntry;break;case'object':if(Array.isArray(pObject)){tmpSchemaObjectEntry.DataType='Array';if(tmpBaseAddress!=''){tmpSchema[tmpBaseAddress]=tmpSchemaObjectEntry;}for(let i=0;i<pObject.length;i++){this.generateAddressses(pObject[i],`${tmpBaseAddress}[${i}]`,tmpSchema);}}else{tmpSchemaObjectEntry.DataType='Object';if(tmpBaseAddress!=''){tmpSchema[tmpBaseAddress]=tmpSchemaObjectEntry;tmpBaseAddress+='.';}let tmpObjectProperties=Object.keys(pObject);for(let i=0;i<tmpObjectProperties.length;i++){this.generateAddressses(pObject[tmpObjectProperties[i]],`${tmpBaseAddress}${tmpObjectProperties[i]}`,tmpSchema);}}break;case'symbol':case'function':// Symbols and functions neither recurse nor get added to the schema
|
|
1504
1592
|
break;}return tmpSchema;}};module.exports=ManyfestObjectAddressGeneration;},{"./Manyfest-LogToConsole.js":83}],90:[function(require,module,exports){// Given a string, parse out any conditional expressions and set whether or not to keep the record.
|
|
1505
1593
|
//
|
|
1506
1594
|
// For instance:
|
|
@@ -1541,33 +1629,52 @@ tmpKeepRecord=tmpKeepRecord&&testCondition(pManyfest,pRecord,tmpSearchAddress,tm
|
|
|
1541
1629
|
* Schema Manipulation Functions
|
|
1542
1630
|
*
|
|
1543
1631
|
* @class ManyfestSchemaManipulation
|
|
1544
|
-
*/class ManyfestSchemaManipulation{
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
//
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1632
|
+
*/class ManyfestSchemaManipulation{/**
|
|
1633
|
+
* @param {function} [pInfoLog] - (optional) A logging function for info messages
|
|
1634
|
+
* @param {function} [pErrorLog] - (optional) A logging function for error messages
|
|
1635
|
+
*/constructor(pInfoLog,pErrorLog){// Wire in logging
|
|
1636
|
+
this.logInfo=typeof pInfoLog==='function'?pInfoLog:libSimpleLog;this.logError=typeof pErrorLog==='function'?pErrorLog:libSimpleLog;}/**
|
|
1637
|
+
* This translates the default address mappings to something different.
|
|
1638
|
+
*
|
|
1639
|
+
* For instance you can pass in manyfest schema descriptor object:
|
|
1640
|
+
* {
|
|
1641
|
+
* "Address.Of.a": { "Hash": "a", "Type": "Number" },
|
|
1642
|
+
* "Address.Of.b": { "Hash": "b", "Type": "Number" }
|
|
1643
|
+
* }
|
|
1644
|
+
*
|
|
1645
|
+
*
|
|
1646
|
+
* And then an address mapping (basically a Hash->Address map)
|
|
1647
|
+
* {
|
|
1648
|
+
* "a": "New.Address.Of.a",
|
|
1649
|
+
* "b": "New.Address.Of.b"
|
|
1650
|
+
* }
|
|
1651
|
+
*
|
|
1652
|
+
* NOTE: This mutates the schema object permanently, altering the base hash.
|
|
1653
|
+
* If there is a collision with an existing address, it can lead to overwrites.
|
|
1654
|
+
* TODO: Discuss what should happen on collisions.
|
|
1655
|
+
*
|
|
1656
|
+
* @param {object} pManyfestSchemaDescriptors - The manyfest schema descriptors to resolve address mappings for
|
|
1657
|
+
* @param {object} pAddressMapping - The address mapping object to use for remapping
|
|
1658
|
+
*
|
|
1659
|
+
* @return {boolean} True if successful, false if there was an error
|
|
1660
|
+
*/resolveAddressMappings(pManyfestSchemaDescriptors,pAddressMapping){if(typeof pManyfestSchemaDescriptors!='object'){this.logError(`Attempted to resolve address mapping but the descriptor was not an object.`);return false;}if(typeof pAddressMapping!='object'){// No mappings were passed in
|
|
1564
1661
|
return true;}// Get the arrays of both the schema definition and the hash mapping
|
|
1565
|
-
let tmpManyfestAddresses=Object.keys(pManyfestSchemaDescriptors);let tmpHashMapping={};tmpManyfestAddresses.forEach(pAddress=>{if('Hash'in pManyfestSchemaDescriptors[pAddress]){tmpHashMapping[pManyfestSchemaDescriptors[pAddress].Hash]=pAddress;}});let tmpAddressMappingSet=Object.keys(pAddressMapping);tmpAddressMappingSet.forEach(pInputAddress=>{let tmpNewDescriptorAddress=pAddressMapping[pInputAddress];let tmpOldDescriptorAddress=
|
|
1662
|
+
let tmpManyfestAddresses=Object.keys(pManyfestSchemaDescriptors);let tmpHashMapping={};tmpManyfestAddresses.forEach(pAddress=>{if('Hash'in pManyfestSchemaDescriptors[pAddress]){tmpHashMapping[pManyfestSchemaDescriptors[pAddress].Hash]=pAddress;}});let tmpAddressMappingSet=Object.keys(pAddressMapping);tmpAddressMappingSet.forEach(pInputAddress=>{let tmpNewDescriptorAddress=pAddressMapping[pInputAddress];let tmpOldDescriptorAddress=null;let tmpDescriptor;// See if there is a matching descriptor either by Address directly or Hash
|
|
1566
1663
|
if(pInputAddress in pManyfestSchemaDescriptors){tmpOldDescriptorAddress=pInputAddress;}else if(pInputAddress in tmpHashMapping){tmpOldDescriptorAddress=tmpHashMapping[pInputAddress];}// If there was a matching descriptor in the manifest, store it in the temporary descriptor
|
|
1567
1664
|
if(tmpOldDescriptorAddress){tmpDescriptor=pManyfestSchemaDescriptors[tmpOldDescriptorAddress];delete pManyfestSchemaDescriptors[tmpOldDescriptorAddress];}else{// Create a new descriptor! Map it to the input address.
|
|
1568
1665
|
tmpDescriptor={Hash:pInputAddress};}// Now re-add the descriptor to the manyfest schema
|
|
1569
|
-
pManyfestSchemaDescriptors[tmpNewDescriptorAddress]=tmpDescriptor;});return true;}
|
|
1570
|
-
|
|
1666
|
+
pManyfestSchemaDescriptors[tmpNewDescriptorAddress]=tmpDescriptor;});return true;}/**
|
|
1667
|
+
* @param {object} pManyfestSchemaDescriptors - The manyfest schema descriptors to resolve address mappings for
|
|
1668
|
+
* @param {object} pAddressMapping - The address mapping object to use for remapping
|
|
1669
|
+
*
|
|
1670
|
+
* @return {object} A new object containing the remapped schema descriptors
|
|
1671
|
+
*/safeResolveAddressMappings(pManyfestSchemaDescriptors,pAddressMapping){// This returns the descriptors as a new object, safely remapping without mutating the original schema Descriptors
|
|
1672
|
+
let tmpManyfestSchemaDescriptors=JSON.parse(JSON.stringify(pManyfestSchemaDescriptors));this.resolveAddressMappings(tmpManyfestSchemaDescriptors,pAddressMapping);return tmpManyfestSchemaDescriptors;}/**
|
|
1673
|
+
* @param {object} pManyfestSchemaDescriptorsDestination - The destination manyfest schema descriptors
|
|
1674
|
+
* @param {object} pManyfestSchemaDescriptorsSource - The source manyfest schema descriptors
|
|
1675
|
+
*
|
|
1676
|
+
* @return {object} A new object containing the merged schema descriptors
|
|
1677
|
+
*/mergeAddressMappings(pManyfestSchemaDescriptorsDestination,pManyfestSchemaDescriptorsSource){if(typeof pManyfestSchemaDescriptorsSource!='object'||typeof pManyfestSchemaDescriptorsDestination!='object'){this.logError(`Attempted to merge two schema descriptors but both were not objects.`);return false;}let tmpSource=JSON.parse(JSON.stringify(pManyfestSchemaDescriptorsSource));let tmpNewManyfestSchemaDescriptors=JSON.parse(JSON.stringify(pManyfestSchemaDescriptorsDestination));// The first passed-in set of descriptors takes precedence.
|
|
1571
1678
|
let tmpDescriptorAddresses=Object.keys(tmpSource);tmpDescriptorAddresses.forEach(pDescriptorAddress=>{if(!(pDescriptorAddress in tmpNewManyfestSchemaDescriptors)){tmpNewManyfestSchemaDescriptors[pDescriptorAddress]=tmpSource[pDescriptorAddress];}});return tmpNewManyfestSchemaDescriptors;}}module.exports=ManyfestSchemaManipulation;},{"./Manyfest-LogToConsole.js":83}],92:[function(require,module,exports){/**
|
|
1572
1679
|
* @author <steven@velozo.com>
|
|
1573
1680
|
*/const libFableServiceProviderBase=require('fable-serviceproviderbase');let libSimpleLog=require('./Manyfest-LogToConsole.js');let libHashTranslation=require('./Manyfest-HashTranslation.js');let libObjectAddressCheckAddressExists=require('./Manyfest-ObjectAddress-CheckAddressExists.js');let libObjectAddressGetValue=require('./Manyfest-ObjectAddress-GetValue.js');let libObjectAddressSetValue=require('./Manyfest-ObjectAddress-SetValue.js');let libObjectAddressDeleteValue=require('./Manyfest-ObjectAddress-DeleteValue.js');let libObjectAddressGeneration=require('./Manyfest-ObjectAddressGeneration.js');let libSchemaManipulation=require('./Manyfest-SchemaManipulation.js');const _DefaultConfiguration={Scope:'DEFAULT',Descriptors:{}};/**
|
|
@@ -1580,23 +1687,35 @@ let tmpDescriptorAddresses=Object.keys(tmpSource);tmpDescriptorAddresses.forEach
|
|
|
1580
1687
|
* Description?: string,
|
|
1581
1688
|
* [key: string]: any,
|
|
1582
1689
|
* }} ManifestDescriptor
|
|
1583
|
-
|
|
1690
|
+
*/ /**
|
|
1584
1691
|
* Manyfest object address-based descriptions and manipulations.
|
|
1585
1692
|
*
|
|
1586
1693
|
* @class Manyfest
|
|
1587
|
-
*/class Manyfest extends libFableServiceProviderBase{constructor(pFable,pManifest,pServiceHash){if(pFable===undefined){super({});}else{super(pFable,pManifest,pServiceHash);}/** @type {Record<string, any>} */this.options;this.serviceType='Manifest';// Wire in logging
|
|
1694
|
+
*/class Manyfest extends libFableServiceProviderBase{constructor(pFable,pManifest,pServiceHash){if(pFable===undefined){super({});}else{super(pFable,pManifest,pServiceHash);}/** @type {import('fable')} */this.fable;/** @type {Record<string, any>} */this.options;/** @type {string} */this.Hash;/** @type {string} */this.UUID;this.serviceType='Manifest';// Wire in logging
|
|
1588
1695
|
this.logInfo=libSimpleLog;this.logError=libSimpleLog;// Create an object address resolver and map in the functions
|
|
1589
|
-
this.objectAddressCheckAddressExists=new libObjectAddressCheckAddressExists(this.logInfo,this.logError);this.objectAddressGetValue=new libObjectAddressGetValue(this.logInfo,this.logError);this.objectAddressSetValue=new libObjectAddressSetValue(this.logInfo,this.logError);this.objectAddressDeleteValue=new libObjectAddressDeleteValue(this.logInfo,this.logError);if(!('defaultValues'in this.options)){this.options.defaultValues={"String":"","Number":0,"Float":0.0,"Integer":0,"PreciseNumber":"0.0","Boolean":false,"Binary":0,"DateTime":0,"Array":[],"Object":{},"Null":null};}if(!('strict'in this.options)){this.options.strict=false;}this.scope=undefined
|
|
1696
|
+
this.objectAddressCheckAddressExists=new libObjectAddressCheckAddressExists(this.logInfo,this.logError);this.objectAddressGetValue=new libObjectAddressGetValue(this.logInfo,this.logError);this.objectAddressSetValue=new libObjectAddressSetValue(this.logInfo,this.logError);this.objectAddressDeleteValue=new libObjectAddressDeleteValue(this.logInfo,this.logError);if(!('defaultValues'in this.options)){this.options.defaultValues={"String":"","Number":0,"Float":0.0,"Integer":0,"PreciseNumber":"0.0","Boolean":false,"Binary":0,"DateTime":0,"Array":[],"Object":{},"Null":null};}if(!('strict'in this.options)){this.options.strict=false;}/** @type {string} */this.scope=undefined;/** @type {Array<string>} */this.elementAddresses=undefined;/** @type {Record<string, string>} */this.elementHashes=undefined;/** @type {Record<string, ManifestDescriptor>} */this.elementDescriptors=undefined;this.reset();if(typeof this.options==='object'){this.loadManifest(this.options);}this.schemaManipulations=new libSchemaManipulation(this.logInfo,this.logError);this.objectAddressGeneration=new libObjectAddressGeneration(this.logInfo,this.logError);this.hashTranslations=new libHashTranslation(this.logInfo,this.logError);this.numberRegex=/^[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$/;}/*************************************************************************
|
|
1590
1697
|
* Schema Manifest Loading, Reading, Manipulation and Serialization Functions
|
|
1591
|
-
|
|
1698
|
+
*/ // Reset critical manifest properties
|
|
1592
1699
|
reset(){this.scope='DEFAULT';this.elementAddresses=[];this.elementHashes={};this.elementDescriptors={};}clone(){// Make a copy of the options in-place
|
|
1593
|
-
let tmpNewOptions=JSON.parse(JSON.stringify(this.options));let tmpNewManyfest=new Manyfest(this.
|
|
1700
|
+
let tmpNewOptions=JSON.parse(JSON.stringify(this.options));let tmpNewManyfest=new Manyfest(this.fable,tmpNewOptions,this.Hash);tmpNewManyfest.logInfo=this.logInfo;tmpNewManyfest.logError=this.logError;//FIXME: mostly written by co-pilot
|
|
1701
|
+
const{Scope,Descriptors,HashTranslations}=this.getManifest();tmpNewManyfest.scope=Scope;tmpNewManyfest.elementDescriptors=Descriptors;tmpNewManyfest.elementAddresses=Object.keys(Descriptors);// Rebuild the element hashes
|
|
1702
|
+
for(let i=0;i<tmpNewManyfest.elementAddresses.length;i++){let tmpAddress=tmpNewManyfest.elementAddresses[i];let tmpDescriptor=tmpNewManyfest.elementDescriptors[tmpAddress];tmpNewManyfest.elementHashes[tmpAddress]=tmpAddress;if('Hash'in tmpDescriptor){tmpNewManyfest.elementHashes[tmpDescriptor.Hash]=tmpAddress;}}// Import the hash translations
|
|
1594
1703
|
tmpNewManyfest.hashTranslations.addTranslation(this.hashTranslations.translationTable);return tmpNewManyfest;}// Deserialize a Manifest from a string
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1704
|
+
/**
|
|
1705
|
+
* @param {string} pManifestString - The manifest string to deserialize
|
|
1706
|
+
*
|
|
1707
|
+
* @return {Manyfest} The deserialized manifest
|
|
1708
|
+
*/deserialize(pManifestString){// TODO: Add guards for bad manifest string
|
|
1709
|
+
this.loadManifest(JSON.parse(pManifestString));return this;}// Load a manifest from an object
|
|
1710
|
+
loadManifest(pManifest){if(typeof pManifest!=='object'){this.logError(`(${this.scope}) Error loading manifest; expecting an object but parameter was type ${typeof pManifest}.`);}let tmpManifest=typeof pManifest=='object'?pManifest:{};let tmpDescriptorKeys=Object.keys(_DefaultConfiguration);for(let i=0;i<tmpDescriptorKeys.length;i++){if(!(tmpDescriptorKeys[i]in tmpManifest)){tmpManifest[tmpDescriptorKeys[i]]=JSON.parse(JSON.stringify(_DefaultConfiguration[tmpDescriptorKeys[i]]));}}if('Scope'in tmpManifest){if(typeof tmpManifest.Scope==='string'){this.scope=tmpManifest.Scope;}else{this.logError(`(${this.scope}) Error loading scope from manifest; expecting a string but property was type ${typeof tmpManifest.Scope}.`,tmpManifest);}}else{this.logError(`(${this.scope}) Error loading scope from manifest object. Property "Scope" does not exist in the root of the object.`,tmpManifest);}if('Descriptors'in tmpManifest){if(typeof tmpManifest.Descriptors==='object'){let tmpDescriptionAddresses=Object.keys(tmpManifest.Descriptors);for(let i=0;i<tmpDescriptionAddresses.length;i++){this.addDescriptor(tmpDescriptionAddresses[i],tmpManifest.Descriptors[tmpDescriptionAddresses[i]]);}}else{this.logError(`(${this.scope}) Error loading description object from manifest object. Expecting an object in 'Manifest.Descriptors' but the property was type ${typeof tmpManifest.Descriptors}.`,tmpManifest);}}else{this.logError(`(${this.scope}) Error loading object description from manifest object. Property "Descriptors" does not exist in the root of the Manifest object.`,tmpManifest);}if('HashTranslations'in tmpManifest){if(typeof tmpManifest.HashTranslations==='object'){for(let i=0;i<tmpManifest.HashTranslations.length;i++){// Each translation is
|
|
1711
|
+
//FIXME: ?????????
|
|
1712
|
+
}}}}/**
|
|
1713
|
+
* Serialize the Manifest to a string
|
|
1714
|
+
*
|
|
1715
|
+
* @return {string} - The serialized manifest
|
|
1716
|
+
*/serialize(){return JSON.stringify(this.getManifest());}/**
|
|
1717
|
+
* @return {{ Scope: string, Descriptors: Record<string, ManifestDescriptor>, HashTranslations: Record<string, string> }} - A copy of the manifest state.
|
|
1718
|
+
*/getManifest(){return{Scope:this.scope,Descriptors:JSON.parse(JSON.stringify(this.elementDescriptors)),HashTranslations:JSON.parse(JSON.stringify(this.hashTranslations.translationTable))};}/**
|
|
1600
1719
|
* Add a descriptor to the manifest
|
|
1601
1720
|
*
|
|
1602
1721
|
* @param {string} pAddress - The address of the element to add the descriptor for.
|
|
@@ -1619,10 +1738,10 @@ this.elementHashes[pDescriptor.Hash]=pAddress;}else{pDescriptor.Hash=pAddress;}r
|
|
|
1619
1738
|
* @param {(d: ManifestDescriptor) => void} fAction - The action function to execute for each descriptor.
|
|
1620
1739
|
*/eachDescriptor(fAction){let tmpDescriptorAddresses=Object.keys(this.elementDescriptors);for(let i=0;i<tmpDescriptorAddresses.length;i++){fAction(this.elementDescriptors[tmpDescriptorAddresses[i]]);}}/*************************************************************************
|
|
1621
1740
|
* Beginning of Object Manipulation (read & write) Functions
|
|
1622
|
-
|
|
1741
|
+
*/ // Check if an element exists by its hash
|
|
1623
1742
|
checkAddressExistsByHash(pObject,pHash){return this.checkAddressExists(pObject,this.resolveHashAddress(pHash));}// Check if an element exists at an address
|
|
1624
1743
|
checkAddressExists(pObject,pAddress){return this.objectAddressCheckAddressExists.checkAddressExists(pObject,pAddress);}// Turn a hash into an address, factoring in the translation table.
|
|
1625
|
-
resolveHashAddress(pHash){let tmpAddress=undefined;let tmpInElementHashTable=pHash in this.elementHashes;let tmpInTranslationTable=pHash in this.hashTranslations.translationTable;// The most straightforward: the hash exists, no translations.
|
|
1744
|
+
resolveHashAddress(pHash){let tmpAddress=undefined;let tmpInElementHashTable=(pHash in this.elementHashes);let tmpInTranslationTable=(pHash in this.hashTranslations.translationTable);// The most straightforward: the hash exists, no translations.
|
|
1626
1745
|
if(tmpInElementHashTable&&!tmpInTranslationTable){tmpAddress=this.elementHashes[pHash];}// There is a translation from one hash to another, and, the elementHashes contains the pointer end
|
|
1627
1746
|
else if(tmpInTranslationTable&&this.hashTranslations.translate(pHash)in this.elementHashes){tmpAddress=this.elementHashes[this.hashTranslations.translate(pHash)];}// Use the level of indirection only in the Translation Table
|
|
1628
1747
|
else if(tmpInTranslationTable){tmpAddress=this.hashTranslations.translate(pHash);}// Just treat the hash as an address.
|
|
@@ -1890,7 +2009,7 @@ process.versions={};function noop(){}process.on=noop;process.addListener=noop;pr
|
|
|
1890
2009
|
delimiter='-',// '\x2D'
|
|
1891
2010
|
/** Regular expressions */regexPunycode=/^xn--/,regexNonASCII=/[^\x20-\x7E]/,// unprintable ASCII chars + non-ASCII chars
|
|
1892
2011
|
regexSeparators=/[\x2E\u3002\uFF0E\uFF61]/g,// RFC 3490 separators
|
|
1893
|
-
/** Error messages */errors={'overflow':'Overflow: input needs wider integers to process','not-basic':'Illegal input >= 0x80 (not a basic code point)','invalid-input':'Invalid input'},/** Convenience shortcuts */baseMinusTMin=base-tMin,floor=Math.floor,stringFromCharCode=String.fromCharCode,/** Temporary variable */key
|
|
2012
|
+
/** Error messages */errors={'overflow':'Overflow: input needs wider integers to process','not-basic':'Illegal input >= 0x80 (not a basic code point)','invalid-input':'Invalid input'},/** Convenience shortcuts */baseMinusTMin=base-tMin,floor=Math.floor,stringFromCharCode=String.fromCharCode,/** Temporary variable */key;/*--------------------------------------------------------------------------*/ /**
|
|
1894
2013
|
* A generic error utility function.
|
|
1895
2014
|
* @private
|
|
1896
2015
|
* @param {String} type The error type.
|
|
@@ -2021,7 +2140,7 @@ for/* no condition */(q=delta,k=base;;k+=base){t=k<=bias?tMin:k>=bias+tMax?tMax:
|
|
|
2021
2140
|
* Unicode string.
|
|
2022
2141
|
* @returns {String} The Punycode representation of the given domain name or
|
|
2023
2142
|
* email address.
|
|
2024
|
-
*/function toASCII(input){return mapDomain(input,function(string){return regexNonASCII.test(string)?'xn--'+encode(string):string;});}
|
|
2143
|
+
*/function toASCII(input){return mapDomain(input,function(string){return regexNonASCII.test(string)?'xn--'+encode(string):string;});}/*--------------------------------------------------------------------------*/ /** Define the public API */punycode={/**
|
|
2025
2144
|
* A string representing the current Punycode.js version number.
|
|
2026
2145
|
* @memberOf punycode
|
|
2027
2146
|
* @type String
|
|
@@ -2031,7 +2150,7 @@ for/* no condition */(q=delta,k=base;;k+=base){t=k<=bias?tMin:k>=bias+tMax?tMax:
|
|
|
2031
2150
|
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
|
2032
2151
|
* @memberOf punycode
|
|
2033
2152
|
* @type Object
|
|
2034
|
-
*/'ucs2':{'decode':ucs2decode,'encode':ucs2encode},'decode':decode,'encode':encode,'toASCII':toASCII,'toUnicode':toUnicode};/** Expose `punycode`
|
|
2153
|
+
*/'ucs2':{'decode':ucs2decode,'encode':ucs2encode},'decode':decode,'encode':encode,'toASCII':toASCII,'toUnicode':toUnicode};/** Expose `punycode` */ // Some AMD build optimizers, like r.js, check for specific condition patterns
|
|
2035
2154
|
// like the following:
|
|
2036
2155
|
if(typeof define=='function'&&typeof define.amd=='object'&&define.amd){define('punycode',function(){return punycode;});}else if(freeExports&&freeModule){if(module.exports==freeExports){// in Node.js, io.js, or RingoJS v0.8.0+
|
|
2037
2156
|
freeModule.exports=punycode;}else{// in Narwhal or RingoJS v0.7.0-
|
|
@@ -2117,7 +2236,7 @@ if(maxKeys>0&&len>maxKeys){len=maxKeys;}for(var i=0;i<len;++i){var x=qs[i].repla
|
|
|
2117
2236
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
2118
2237
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
2119
2238
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
2120
|
-
'use strict';var stringifyPrimitive=function(v){switch(typeof v){case'string':return v;case'boolean':return v?'true':'false';case'number':return isFinite(v)?v:'';default:return'';}};module.exports=function(obj,sep,eq,name){sep=sep||'&';eq=eq||'=';if(obj===null){obj=undefined;}if(typeof obj==='object'){return map(objectKeys(obj),function(k){var ks=encodeURIComponent(stringifyPrimitive(k))+eq;if(isArray(obj[k])){return map(obj[k],function(v){return ks+encodeURIComponent(stringifyPrimitive(v));}).join(sep);}else{return ks+encodeURIComponent(stringifyPrimitive(obj[k]));}}).join(sep);}if(!name)return'';return encodeURIComponent(stringifyPrimitive(name))+eq+encodeURIComponent(stringifyPrimitive(obj));};var isArray=Array.isArray||function(xs){return Object.prototype.toString.call(xs)==='[object Array]';};function map(xs,f){if(xs.map)return xs.map(f);var res=[];for(var i=0;i<xs.length;i++){res.push(f(xs[i],i));}return res;}var objectKeys=Object.keys||function(obj){var res=[];for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))res.push(key);}return res;};},{}],116:[function(require,module,exports){'use strict';exports.decode=exports.parse=require('./decode');exports.encode=exports.stringify=require('./encode');},{"./decode":114,"./encode":115}],117:[function(require,module,exports){/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource>
|
|
2239
|
+
'use strict';var stringifyPrimitive=function(v){switch(typeof v){case'string':return v;case'boolean':return v?'true':'false';case'number':return isFinite(v)?v:'';default:return'';}};module.exports=function(obj,sep,eq,name){sep=sep||'&';eq=eq||'=';if(obj===null){obj=undefined;}if(typeof obj==='object'){return map(objectKeys(obj),function(k){var ks=encodeURIComponent(stringifyPrimitive(k))+eq;if(isArray(obj[k])){return map(obj[k],function(v){return ks+encodeURIComponent(stringifyPrimitive(v));}).join(sep);}else{return ks+encodeURIComponent(stringifyPrimitive(obj[k]));}}).join(sep);}if(!name)return'';return encodeURIComponent(stringifyPrimitive(name))+eq+encodeURIComponent(stringifyPrimitive(obj));};var isArray=Array.isArray||function(xs){return Object.prototype.toString.call(xs)==='[object Array]';};function map(xs,f){if(xs.map)return xs.map(f);var res=[];for(var i=0;i<xs.length;i++){res.push(f(xs[i],i));}return res;}var objectKeys=Object.keys||function(obj){var res=[];for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))res.push(key);}return res;};},{}],116:[function(require,module,exports){'use strict';exports.decode=exports.parse=require('./decode');exports.encode=exports.stringify=require('./encode');},{"./decode":114,"./encode":115}],117:[function(require,module,exports){/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */ /* eslint-disable node/no-deprecated-api */var buffer=require('buffer');var Buffer=buffer.Buffer;// alternative to using Object.keys for old browsers
|
|
2121
2240
|
function copyProps(src,dst){for(var key in src){dst[key]=src[key];}}if(Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow){module.exports=buffer;}else{// Copy properties from require('buffer')
|
|
2122
2241
|
copyProps(buffer,exports);exports.Buffer=SafeBuffer;}function SafeBuffer(arg,encodingOrOffset,length){return Buffer(arg,encodingOrOffset,length);}SafeBuffer.prototype=Object.create(Buffer.prototype);// Copy static methods from Buffer
|
|
2123
2242
|
copyProps(Buffer,SafeBuffer);SafeBuffer.from=function(arg,encodingOrOffset,length){if(typeof arg==='number'){throw new TypeError('Argument must not be a number');}return Buffer(arg,encodingOrOffset,length);};SafeBuffer.alloc=function(size,fill,encoding){if(typeof size!=='number'){throw new TypeError('Argument must be a number');}var buf=Buffer(size);if(fill!==undefined){if(typeof encoding==='string'){buf.fill(fill,encoding);}else{buf.fill(fill);}}else{buf.fill(0);}return buf;};SafeBuffer.allocUnsafe=function(size){if(typeof size!=='number'){throw new TypeError('Argument must be a number');}return Buffer(size);};SafeBuffer.allocUnsafeSlow=function(size){if(typeof size!=='number'){throw new TypeError('Argument must be a number');}return buffer.SlowBuffer(size);};},{"buffer":20}],118:[function(require,module,exports){'use strict';var inspect=require('object-inspect');var $TypeError=require('es-errors/type');/*
|
|
@@ -2125,22 +2244,22 @@ copyProps(Buffer,SafeBuffer);SafeBuffer.from=function(arg,encodingOrOffset,lengt
|
|
|
2125
2244
|
*
|
|
2126
2245
|
* That node is also moved to the head of the list, so that if it's accessed again we don't need to traverse the whole list.
|
|
2127
2246
|
* By doing so, all the recently used nodes can be accessed relatively quickly.
|
|
2128
|
-
|
|
2247
|
+
*/ /** @type {import('./list.d.ts').listGetNode} */ // eslint-disable-next-line consistent-return
|
|
2129
2248
|
var listGetNode=function(list,key,isDelete){/** @type {typeof list | NonNullable<(typeof list)['next']>} */var prev=list;/** @type {(typeof list)['next']} */var curr;// eslint-disable-next-line eqeqeq
|
|
2130
2249
|
for(;(curr=prev.next)!=null;prev=curr){if(curr.key===key){prev.next=curr.next;if(!isDelete){// eslint-disable-next-line no-extra-parens
|
|
2131
2250
|
curr.next=/** @type {NonNullable<typeof list.next>} */list.next;list.next=curr;// eslint-disable-line no-param-reassign
|
|
2132
2251
|
}return curr;}}};/** @type {import('./list.d.ts').listGet} */var listGet=function(objects,key){if(!objects){return void undefined;}var node=listGetNode(objects,key);return node&&node.value;};/** @type {import('./list.d.ts').listSet} */var listSet=function(objects,key,value){var node=listGetNode(objects,key);if(node){node.value=value;}else{// Prepend the new node to the beginning of the list
|
|
2133
2252
|
objects.next=/** @type {import('./list.d.ts').ListNode<typeof value, typeof key>} */{// eslint-disable-line no-param-reassign, no-extra-parens
|
|
2134
|
-
key:key,next:objects.next,value:value};}};/** @type {import('./list.d.ts').listHas} */var listHas=function(objects,key){if(!objects){return false;}return!!listGetNode(objects,key);};/** @type {import('./list.d.ts').listDelete}
|
|
2135
|
-
var listDelete=function(objects,key){if(objects){return listGetNode(objects,key,true);}};/** @type {import('.')} */module.exports=function getSideChannelList(){/** @typedef {ReturnType<typeof getSideChannelList>} Channel
|
|
2253
|
+
key:key,next:objects.next,value:value};}};/** @type {import('./list.d.ts').listHas} */var listHas=function(objects,key){if(!objects){return false;}return!!listGetNode(objects,key);};/** @type {import('./list.d.ts').listDelete} */ // eslint-disable-next-line consistent-return
|
|
2254
|
+
var listDelete=function(objects,key){if(objects){return listGetNode(objects,key,true);}};/** @type {import('.')} */module.exports=function getSideChannelList(){/** @typedef {ReturnType<typeof getSideChannelList>} Channel */ /** @typedef {Parameters<Channel['get']>[0]} K */ /** @typedef {Parameters<Channel['set']>[1]} V */ /** @type {import('./list.d.ts').RootNode<V, K> | undefined} */var $o;/** @type {Channel} */var channel={assert:function(key){if(!channel.has(key)){throw new $TypeError('Side channel does not contain '+inspect(key));}},'delete':function(key){var root=$o&&$o.next;var deletedNode=listDelete($o,key);if(deletedNode&&root&&root===deletedNode){$o=void undefined;}return!!deletedNode;},get:function(key){return listGet($o,key);},has:function(key){return listHas($o,key);},set:function(key,value){if(!$o){// Initialize the linked list as an empty node, so that we don't have to special-case handling of the first node: we can always refer to it as (previous node).next, instead of something like (list).head
|
|
2136
2255
|
$o={next:void undefined};}// eslint-disable-next-line no-extra-parens
|
|
2137
2256
|
listSet(/** @type {NonNullable<typeof $o>} */$o,key,value);}};// @ts-expect-error TODO: figure out why this is erroring
|
|
2138
|
-
return channel;};},{"es-errors/type":47,"object-inspect":101}],119:[function(require,module,exports){'use strict';var GetIntrinsic=require('get-intrinsic');var callBound=require('call-bound');var inspect=require('object-inspect');var $TypeError=require('es-errors/type');var $Map=GetIntrinsic('%Map%',true);/** @type {<K, V>(thisArg: Map<K, V>, key: K) => V} */var $mapGet=callBound('Map.prototype.get',true);/** @type {<K, V>(thisArg: Map<K, V>, key: K, value: V) => void} */var $mapSet=callBound('Map.prototype.set',true);/** @type {<K, V>(thisArg: Map<K, V>, key: K) => boolean} */var $mapHas=callBound('Map.prototype.has',true);/** @type {<K, V>(thisArg: Map<K, V>, key: K) => boolean} */var $mapDelete=callBound('Map.prototype.delete',true);/** @type {<K, V>(thisArg: Map<K, V>) => number} */var $mapSize=callBound('Map.prototype.size',true);/** @type {import('.')} */module.exports=!!$Map&&/** @type {Exclude<import('.'), false>} */function getSideChannelMap(){/** @typedef {ReturnType<typeof getSideChannelMap>} Channel
|
|
2257
|
+
return channel;};},{"es-errors/type":47,"object-inspect":101}],119:[function(require,module,exports){'use strict';var GetIntrinsic=require('get-intrinsic');var callBound=require('call-bound');var inspect=require('object-inspect');var $TypeError=require('es-errors/type');var $Map=GetIntrinsic('%Map%',true);/** @type {<K, V>(thisArg: Map<K, V>, key: K) => V} */var $mapGet=callBound('Map.prototype.get',true);/** @type {<K, V>(thisArg: Map<K, V>, key: K, value: V) => void} */var $mapSet=callBound('Map.prototype.set',true);/** @type {<K, V>(thisArg: Map<K, V>, key: K) => boolean} */var $mapHas=callBound('Map.prototype.has',true);/** @type {<K, V>(thisArg: Map<K, V>, key: K) => boolean} */var $mapDelete=callBound('Map.prototype.delete',true);/** @type {<K, V>(thisArg: Map<K, V>) => number} */var $mapSize=callBound('Map.prototype.size',true);/** @type {import('.')} */module.exports=!!$Map&&/** @type {Exclude<import('.'), false>} */function getSideChannelMap(){/** @typedef {ReturnType<typeof getSideChannelMap>} Channel */ /** @typedef {Parameters<Channel['get']>[0]} K */ /** @typedef {Parameters<Channel['set']>[1]} V */ /** @type {Map<K, V> | undefined} */var $m;/** @type {Channel} */var channel={assert:function(key){if(!channel.has(key)){throw new $TypeError('Side channel does not contain '+inspect(key));}},'delete':function(key){if($m){var result=$mapDelete($m,key);if($mapSize($m)===0){$m=void undefined;}return result;}return false;},get:function(key){// eslint-disable-line consistent-return
|
|
2139
2258
|
if($m){return $mapGet($m,key);}},has:function(key){if($m){return $mapHas($m,key);}return false;},set:function(key,value){if(!$m){// @ts-expect-error TS can't handle narrowing a variable inside a closure
|
|
2140
2259
|
$m=new $Map();}$mapSet($m,key,value);}};// @ts-expect-error TODO: figure out why TS is erroring here
|
|
2141
|
-
return channel;};},{"call-bound":30,"es-errors/type":47,"get-intrinsic":69,"object-inspect":101}],120:[function(require,module,exports){'use strict';var GetIntrinsic=require('get-intrinsic');var callBound=require('call-bound');var inspect=require('object-inspect');var getSideChannelMap=require('side-channel-map');var $TypeError=require('es-errors/type');var $WeakMap=GetIntrinsic('%WeakMap%',true);/** @type {<K extends object, V>(thisArg: WeakMap<K, V>, key: K) => V} */var $weakMapGet=callBound('WeakMap.prototype.get',true);/** @type {<K extends object, V>(thisArg: WeakMap<K, V>, key: K, value: V) => void} */var $weakMapSet=callBound('WeakMap.prototype.set',true);/** @type {<K extends object, V>(thisArg: WeakMap<K, V>, key: K) => boolean} */var $weakMapHas=callBound('WeakMap.prototype.has',true);/** @type {<K extends object, V>(thisArg: WeakMap<K, V>, key: K) => boolean} */var $weakMapDelete=callBound('WeakMap.prototype.delete',true);/** @type {import('.')} */module.exports=$WeakMap?/** @type {Exclude<import('.'), false>} */function getSideChannelWeakMap(){/** @typedef {ReturnType<typeof getSideChannelWeakMap>} Channel
|
|
2260
|
+
return channel;};},{"call-bound":30,"es-errors/type":47,"get-intrinsic":69,"object-inspect":101}],120:[function(require,module,exports){'use strict';var GetIntrinsic=require('get-intrinsic');var callBound=require('call-bound');var inspect=require('object-inspect');var getSideChannelMap=require('side-channel-map');var $TypeError=require('es-errors/type');var $WeakMap=GetIntrinsic('%WeakMap%',true);/** @type {<K extends object, V>(thisArg: WeakMap<K, V>, key: K) => V} */var $weakMapGet=callBound('WeakMap.prototype.get',true);/** @type {<K extends object, V>(thisArg: WeakMap<K, V>, key: K, value: V) => void} */var $weakMapSet=callBound('WeakMap.prototype.set',true);/** @type {<K extends object, V>(thisArg: WeakMap<K, V>, key: K) => boolean} */var $weakMapHas=callBound('WeakMap.prototype.has',true);/** @type {<K extends object, V>(thisArg: WeakMap<K, V>, key: K) => boolean} */var $weakMapDelete=callBound('WeakMap.prototype.delete',true);/** @type {import('.')} */module.exports=$WeakMap?/** @type {Exclude<import('.'), false>} */function getSideChannelWeakMap(){/** @typedef {ReturnType<typeof getSideChannelWeakMap>} Channel */ /** @typedef {Parameters<Channel['get']>[0]} K */ /** @typedef {Parameters<Channel['set']>[1]} V */ /** @type {WeakMap<K & object, V> | undefined} */var $wm;/** @type {Channel | undefined} */var $m;/** @type {Channel} */var channel={assert:function(key){if(!channel.has(key)){throw new $TypeError('Side channel does not contain '+inspect(key));}},'delete':function(key){if($WeakMap&&key&&(typeof key==='object'||typeof key==='function')){if($wm){return $weakMapDelete($wm,key);}}else if(getSideChannelMap){if($m){return $m['delete'](key);}}return false;},get:function(key){if($WeakMap&&key&&(typeof key==='object'||typeof key==='function')){if($wm){return $weakMapGet($wm,key);}}return $m&&$m.get(key);},has:function(key){if($WeakMap&&key&&(typeof key==='object'||typeof key==='function')){if($wm){return $weakMapHas($wm,key);}}return!!$m&&$m.has(key);},set:function(key,value){if($WeakMap&&key&&(typeof key==='object'||typeof key==='function')){if(!$wm){$wm=new $WeakMap();}$weakMapSet($wm,key,value);}else if(getSideChannelMap){if(!$m){$m=getSideChannelMap();}// eslint-disable-next-line no-extra-parens
|
|
2142
2261
|
/** @type {NonNullable<typeof $m>} */$m.set(key,value);}}};// @ts-expect-error TODO: figure out why this is erroring
|
|
2143
|
-
return channel;}:getSideChannelMap;},{"call-bound":30,"es-errors/type":47,"get-intrinsic":69,"object-inspect":101,"side-channel-map":119}],121:[function(require,module,exports){'use strict';var $TypeError=require('es-errors/type');var inspect=require('object-inspect');var getSideChannelList=require('side-channel-list');var getSideChannelMap=require('side-channel-map');var getSideChannelWeakMap=require('side-channel-weakmap');var makeChannel=getSideChannelWeakMap||getSideChannelMap||getSideChannelList;/** @type {import('.')} */module.exports=function getSideChannel(){/** @typedef {ReturnType<typeof getSideChannel>} Channel
|
|
2262
|
+
return channel;}:getSideChannelMap;},{"call-bound":30,"es-errors/type":47,"get-intrinsic":69,"object-inspect":101,"side-channel-map":119}],121:[function(require,module,exports){'use strict';var $TypeError=require('es-errors/type');var inspect=require('object-inspect');var getSideChannelList=require('side-channel-list');var getSideChannelMap=require('side-channel-map');var getSideChannelWeakMap=require('side-channel-weakmap');var makeChannel=getSideChannelWeakMap||getSideChannelMap||getSideChannelList;/** @type {import('.')} */module.exports=function getSideChannel(){/** @typedef {ReturnType<typeof getSideChannel>} Channel */ /** @type {Channel | undefined} */var $channelData;/** @type {Channel} */var channel={assert:function(key){if(!channel.has(key)){throw new $TypeError('Side channel does not contain '+inspect(key));}},'delete':function(key){return!!$channelData&&$channelData['delete'](key);},get:function(key){return $channelData&&$channelData.get(key);},has:function(key){return!!$channelData&&$channelData.has(key);},set:function(key,value){if(!$channelData){$channelData=makeChannel();}$channelData.set(key,value);}};// @ts-expect-error TODO: figure out why this is erroring
|
|
2144
2263
|
return channel;};},{"es-errors/type":47,"object-inspect":101,"side-channel-list":118,"side-channel-map":119,"side-channel-weakmap":120}],122:[function(require,module,exports){(function(Buffer){(function(){/*! simple-concat. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */module.exports=function(stream,cb){var chunks=[];stream.on('data',function(chunk){chunks.push(chunk);});stream.once('end',function(){if(cb)cb(null,Buffer.concat(chunks));cb=null;});stream.once('error',function(err){if(cb)cb(err);cb=null;});};}).call(this);}).call(this,require("buffer").Buffer);},{"buffer":20}],123:[function(require,module,exports){(function(Buffer){(function(){/*! simple-get. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */module.exports=simpleGet;const concat=require('simple-concat');const decompressResponse=require('decompress-response');// excluded from browser build
|
|
2145
2264
|
const http=require('http');const https=require('https');const once=require('once');const querystring=require('querystring');const url=require('url');const isStream=o=>o!==null&&typeof o==='object'&&typeof o.pipe==='function';function simpleGet(opts,cb){opts=Object.assign({maxRedirects:10},typeof opts==='string'?{url:opts}:opts);cb=once(cb);if(opts.url){const{hostname,port,protocol,auth,path}=url.parse(opts.url);// eslint-disable-line node/no-deprecated-api
|
|
2146
2265
|
delete opts.url;if(!hostname&&!port&&!protocol&&!auth)opts.path=path;// Relative redirect
|
|
@@ -2293,7 +2412,7 @@ this._readableState.destroyed=value;this._writableState.destroyed=value;}});}).c
|
|
|
2293
2412
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
2294
2413
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
2295
2414
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
2296
|
-
'use strict';module.exports=Readable;/*<replacement>*/var Duplex;/*</replacement>*/Readable.ReadableState=ReadableState;/*<replacement>*/var EE=require('events').EventEmitter;var EElistenerCount=function EElistenerCount(emitter,type){return emitter.listeners(type).length;};/*</replacement
|
|
2415
|
+
'use strict';module.exports=Readable;/*<replacement>*/var Duplex;/*</replacement>*/Readable.ReadableState=ReadableState;/*<replacement>*/var EE=require('events').EventEmitter;var EElistenerCount=function EElistenerCount(emitter,type){return emitter.listeners(type).length;};/*</replacement>*/ /*<replacement>*/var Stream=require('./internal/streams/stream');/*</replacement>*/var Buffer=require('buffer').Buffer;var OurUint8Array=(typeof global!=='undefined'?global:typeof window!=='undefined'?window:typeof self!=='undefined'?self:{}).Uint8Array||function(){};function _uint8ArrayToBuffer(chunk){return Buffer.from(chunk);}function _isUint8Array(obj){return Buffer.isBuffer(obj)||obj instanceof OurUint8Array;}/*<replacement>*/var debugUtil=require('util');var debug;if(debugUtil&&debugUtil.debuglog){debug=debugUtil.debuglog('stream');}else{debug=function debug(){};}/*</replacement>*/var BufferList=require('./internal/streams/buffer_list');var destroyImpl=require('./internal/streams/destroy');var _require=require('./internal/streams/state'),getHighWaterMark=_require.getHighWaterMark;var _require$codes=require('../errors').codes,ERR_INVALID_ARG_TYPE=_require$codes.ERR_INVALID_ARG_TYPE,ERR_STREAM_PUSH_AFTER_EOF=_require$codes.ERR_STREAM_PUSH_AFTER_EOF,ERR_METHOD_NOT_IMPLEMENTED=_require$codes.ERR_METHOD_NOT_IMPLEMENTED,ERR_STREAM_UNSHIFT_AFTER_END_EVENT=_require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;// Lazy loaded to improve the startup performance.
|
|
2297
2416
|
var StringDecoder;var createReadableStreamAsyncIterator;var from;require('inherits')(Readable,Stream);var errorOrDestroy=destroyImpl.errorOrDestroy;var kProxyEvents=['error','close','destroy','pause','resume'];function prependListener(emitter,event,fn){// Sadly this is not cacheable as some libraries bundle their own
|
|
2298
2417
|
// event emitter implementation with them.
|
|
2299
2418
|
if(typeof emitter.prependListener==='function')return emitter.prependListener(event,fn);// This is a hack to make sure that our error handler is attached before any
|
|
@@ -2636,7 +2755,7 @@ if(stream._writableState.length)throw new ERR_TRANSFORM_WITH_LENGTH_0();if(strea
|
|
|
2636
2755
|
// the drain event emission and buffering.
|
|
2637
2756
|
'use strict';module.exports=Writable;/* <replacement> */function WriteReq(chunk,encoding,cb){this.chunk=chunk;this.encoding=encoding;this.callback=cb;this.next=null;}// It seems a linked list but it is not
|
|
2638
2757
|
// there will be only 2 of these for each stream
|
|
2639
|
-
function CorkedRequest(state){var _this=this;this.next=null;this.entry=null;this.finish=function(){onCorkedFinish(_this,state);};}/* </replacement>
|
|
2758
|
+
function CorkedRequest(state){var _this=this;this.next=null;this.entry=null;this.finish=function(){onCorkedFinish(_this,state);};}/* </replacement> */ /*<replacement>*/var Duplex;/*</replacement>*/Writable.WritableState=WritableState;/*<replacement>*/var internalUtil={deprecate:require('util-deprecate')};/*</replacement>*/ /*<replacement>*/var Stream=require('./internal/streams/stream');/*</replacement>*/var Buffer=require('buffer').Buffer;var OurUint8Array=(typeof global!=='undefined'?global:typeof window!=='undefined'?window:typeof self!=='undefined'?self:{}).Uint8Array||function(){};function _uint8ArrayToBuffer(chunk){return Buffer.from(chunk);}function _isUint8Array(obj){return Buffer.isBuffer(obj)||obj instanceof OurUint8Array;}var destroyImpl=require('./internal/streams/destroy');var _require=require('./internal/streams/state'),getHighWaterMark=_require.getHighWaterMark;var _require$codes=require('../errors').codes,ERR_INVALID_ARG_TYPE=_require$codes.ERR_INVALID_ARG_TYPE,ERR_METHOD_NOT_IMPLEMENTED=_require$codes.ERR_METHOD_NOT_IMPLEMENTED,ERR_MULTIPLE_CALLBACK=_require$codes.ERR_MULTIPLE_CALLBACK,ERR_STREAM_CANNOT_PIPE=_require$codes.ERR_STREAM_CANNOT_PIPE,ERR_STREAM_DESTROYED=_require$codes.ERR_STREAM_DESTROYED,ERR_STREAM_NULL_VALUES=_require$codes.ERR_STREAM_NULL_VALUES,ERR_STREAM_WRITE_AFTER_END=_require$codes.ERR_STREAM_WRITE_AFTER_END,ERR_UNKNOWN_ENCODING=_require$codes.ERR_UNKNOWN_ENCODING;var errorOrDestroy=destroyImpl.errorOrDestroy;require('inherits')(Writable,Stream);function nop(){}function WritableState(options,stream,isDuplex){Duplex=Duplex||require('./_stream_duplex');options=options||{};// Duplex streams are both readable and writable, but share
|
|
2640
2759
|
// the same options object.
|
|
2641
2760
|
// However, some cases require setting options to different
|
|
2642
2761
|
// values for the readable and the writable sides of the duplex stream,
|
|
@@ -2918,10 +3037,10 @@ var simplePath=simplePathPattern.exec(rest);if(simplePath){this.path=rest;this.h
|
|
|
2918
3037
|
* ex:
|
|
2919
3038
|
* http://a@b@c/ => user:a@b host:c
|
|
2920
3039
|
* http://a@b?@c => user:a host:c path:/?@c
|
|
2921
|
-
|
|
3040
|
+
*/ /*
|
|
2922
3041
|
* v0.12 TODO(isaacs): This is not quite how Chrome does things.
|
|
2923
3042
|
* Review our test case against browsers more comprehensively.
|
|
2924
|
-
|
|
3043
|
+
*/ // find the first instance of any hostEndingChars
|
|
2925
3044
|
var hostEnd=-1;for(var i=0;i<hostEndingChars.length;i++){var hec=rest.indexOf(hostEndingChars[i]);if(hec!==-1&&(hostEnd===-1||hec<hostEnd)){hostEnd=hec;}}/*
|
|
2926
3045
|
* at this point, either we have an explicit point where the
|
|
2927
3046
|
* auth portion cannot go past, or the last @ char is the decider.
|
|
@@ -3062,10 +3181,10 @@ try{if(!global.localStorage)return false;}catch(_){return false;}var val=global.
|
|
|
3062
3181
|
// presumably different callback function.
|
|
3063
3182
|
// This makes sure that own properties are retained, so that
|
|
3064
3183
|
// decorations and such are not lost along the way.
|
|
3065
|
-
module.exports=wrappy;function wrappy(fn,cb){if(fn&&cb)return wrappy(fn)(cb);if(typeof fn!=='function')throw new TypeError('need wrapper function');Object.keys(fn).forEach(function(k){wrapper[k]=fn[k];});return wrapper;function wrapper(){var args=new Array(arguments.length);for(var i=0;i<args.length;i++){args[i]=arguments[i];}var ret=fn.apply(this,args);var cb=args[args.length-1];if(typeof ret==='function'&&ret!==cb){Object.keys(cb).forEach(function(k){ret[k]=cb[k];});}return ret;}}},{}],148:[function(require,module,exports){module.exports=extend;var hasOwnProperty=Object.prototype.hasOwnProperty;function extend(){var target={};for(var i=0;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;}},{}],149:[function(require,module,exports){module.exports={"name":"fable","version":"3.1.
|
|
3184
|
+
module.exports=wrappy;function wrappy(fn,cb){if(fn&&cb)return wrappy(fn)(cb);if(typeof fn!=='function')throw new TypeError('need wrapper function');Object.keys(fn).forEach(function(k){wrapper[k]=fn[k];});return wrapper;function wrapper(){var args=new Array(arguments.length);for(var i=0;i<args.length;i++){args[i]=arguments[i];}var ret=fn.apply(this,args);var cb=args[args.length-1];if(typeof ret==='function'&&ret!==cb){Object.keys(cb).forEach(function(k){ret[k]=cb[k];});}return ret;}}},{}],148:[function(require,module,exports){module.exports=extend;var hasOwnProperty=Object.prototype.hasOwnProperty;function extend(){var target={};for(var i=0;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;}},{}],149:[function(require,module,exports){module.exports={"name":"fable","version":"3.1.49","description":"A service dependency injection, configuration and logging library.","main":"source/Fable.js","scripts":{"start":"node source/Fable.js","coverage":"./node_modules/.bin/nyc --reporter=lcov --reporter=text-lcov ./node_modules/mocha/bin/_mocha -- -u tdd -R spec","test":"./node_modules/.bin/mocha -u tdd -R spec","build":"npx quack build","docker-dev-build":"docker build ./ -f Dockerfile_LUXURYCode -t fable-image:local","docker-dev-run":"docker run -it -d --name fable-dev -p 30001:8080 -p 38086:8086 -v \"$PWD/.config:/home/coder/.config\" -v \"$PWD:/home/coder/fable\" -u \"$(id -u):$(id -g)\" -e \"DOCKER_USER=$USER\" fable-image:local","docker-dev-shell":"docker exec -it fable-dev /bin/bash","tests":"./node_modules/mocha/bin/_mocha -u tdd --exit -R spec --grep"},"mocha":{"diff":true,"extension":["js"],"package":"./package.json","reporter":"spec","slow":"75","timeout":"5000","ui":"tdd","watch-files":["source/**/*.js","test/**/*.js"],"watch-ignore":["lib/vendor"]},"browser":{"./source/service/Fable-Service-EnvironmentData.js":"./source/service/Fable-Service-EnvironmentData-Web.js","./source/service/Fable-Service-FilePersistence.js":"./source/service/Fable-Service-FilePersistence-Web.js"},"repository":{"type":"git","url":"https://github.com/stevenvelozo/fable.git"},"keywords":["entity","behavior"],"author":"Steven Velozo <steven@velozo.com> (http://velozo.com/)","license":"MIT","bugs":{"url":"https://github.com/stevenvelozo/fable/issues"},"homepage":"https://github.com/stevenvelozo/fable","devDependencies":{"quackage":"^1.0.45"},"dependencies":{"async.eachlimit":"^0.5.2","async.waterfall":"^0.5.2","big.js":"^7.0.1","cachetrax":"^1.0.4","cookie":"^1.0.2","data-arithmatic":"^1.0.7","dayjs":"^1.11.19","fable-log":"^3.0.16","fable-serviceproviderbase":"^3.0.15","fable-settings":"^3.0.12","fable-uuid":"^3.0.11","manyfest":"^1.0.42","simple-get":"^4.0.1"}};},{}],150:[function(require,module,exports){/**
|
|
3066
3185
|
* Fable Application Services Support Library
|
|
3067
3186
|
* @author <steven@velozo.com>
|
|
3068
|
-
|
|
3187
|
+
*/ // Pre-init services
|
|
3069
3188
|
const libFableSettings=require('fable-settings');const libFableUUID=require('fable-uuid');const libFableLog=require('fable-log');const libPackage=require('../package.json');const libFableServiceBase=require('fable-serviceproviderbase');class Fable extends libFableServiceBase.CoreServiceProviderBase{constructor(pSettings){super(pSettings);// Initialization Phase 0: Set up the lowest level state (fable is a utility service manager at heart)
|
|
3070
3189
|
this.serviceType='ServiceManager';/** @type {Object} */this._Package=libPackage;// An array of the types of services available
|
|
3071
3190
|
this.serviceTypes=[];// A map of instantiated services
|
|
@@ -3183,7 +3302,7 @@ this._Regex_formatterAddCommasToNumber=/^([-+]?)(0?)(\d+)(.?)(\d+)$/g;this._Rege
|
|
|
3183
3302
|
// TODO: Use locale data for this if it's defaults all the way down.
|
|
3184
3303
|
this._Value_MoneySign_Currency='$';this._Value_NaN_Currency='--';this._Value_GroupSeparator_Number=',';this._Value_Prefix_StringHash='HSH';this._Value_Clean_formatterCleanNonAlpha='';this._UseEngineStringStartsWith=typeof String.prototype.startsWith==='function';this._UseEngineStringEndsWith=typeof String.prototype.endsWith==='function';this._SanitizeObjectKeyRegex=/[^a-zA-Z0-9_]/gi;this._SanitizeObjectKeyReplacement='_';this._SanitizeObjectKeyInvalid='INVALID';}/*************************************************************************
|
|
3185
3304
|
* String Manipulation and Comparison Functions
|
|
3186
|
-
|
|
3305
|
+
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /**
|
|
3187
3306
|
* Reverse a string
|
|
3188
3307
|
*
|
|
3189
3308
|
* @param {string} pString - The string to reverse
|
|
@@ -3301,7 +3420,7 @@ if(pString.startsWith(pWrapCharacter)&&pString.endsWith(pWrapCharacter)){return
|
|
|
3301
3420
|
* @return {string} the cleaned string, or a placeholder if the input is invalid
|
|
3302
3421
|
*/sanitizeObjectKey(pString){if(typeof pString!=='string'||pString.length<1){return this._SanitizeObjectKeyInvalid;}return pString.replace(this._SanitizeObjectKeyRegex,this._SanitizeObjectKeyReplacement);}/*************************************************************************
|
|
3303
3422
|
* Number Formatting Functions
|
|
3304
|
-
|
|
3423
|
+
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /**
|
|
3305
3424
|
* Insert commas every 3 characters from the right. Used by formatterAddCommasToNumber().
|
|
3306
3425
|
*
|
|
3307
3426
|
* @param {*} pString
|
|
@@ -3339,7 +3458,7 @@ return`$${this.formatterAddCommasToNumber(tmpDollarAmount)}`;}/**
|
|
|
3339
3458
|
*/stringGeneratePaddingString(pString,pTargetLength,pPadString){let tmpTargetLength=pTargetLength>>0;let tmpPadString=String(typeof pPadString!=='undefined'?pPadString:' ');if(pString.length>pTargetLength){// No padding string if the source string is already longer than the target length, return an empty string
|
|
3340
3459
|
return'';}else{let tmpPadLength=pTargetLength-pString.length;if(tmpPadLength>tmpPadString.length){tmpPadString+=tmpPadString.repeat(tmpTargetLength/tmpPadString.length);}return tmpPadString.slice(0,tmpPadLength);}}/*************************************************************************
|
|
3341
3460
|
* Time Formatting Functions (milliseconds)
|
|
3342
|
-
|
|
3461
|
+
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /**
|
|
3343
3462
|
* Format a time length in milliseconds into a human readable string.
|
|
3344
3463
|
* @param {number} pTimeSpan
|
|
3345
3464
|
* @returns {string} - HH:MM:SS.mmm
|
|
@@ -3352,7 +3471,7 @@ return'';}else{let tmpPadLength=pTargetLength-pString.length;if(tmpPadLength>tmp
|
|
|
3352
3471
|
*/formatTimeDelta(pTimeStart,pTimeEnd){if(typeof pTimeStart!='number'||typeof pTimeEnd!='number'){return'';}return this.formatTimeSpan(pTimeEnd-pTimeStart);}// THE FOLLOWING TERRIBLE FUNCTIONS ARE FOR QT / WKHTMLTOPDF when luxon and moment don't work so well
|
|
3353
3472
|
getMonthFromDate(pJavascriptDate){var tmpMonths=["January","February","March","April","May","June","July","August","September","October","November","December"];return tmpMonths[pJavascriptDate.getMonth()];}getMonthAbbreviatedFromDate(pJavascriptDate){var tmpMonths=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return tmpMonths[pJavascriptDate.getMonth()];}formatMonthDayYearFromDate(pJavascriptDate,pStrict){let tmpStrict=typeof pStrict!=='undefined'?pStrict:false;let tmpMonth=pJavascriptDate.getMonth()+1;let tmpDay=pJavascriptDate.getDate();let tmpYear=pJavascriptDate.getFullYear();if(tmpStrict){tmpMonth=this.stringPadStart(tmpMonth,2,'0');tmpDay=this.stringPadStart(tmpDay,2,'0');tmpYear=this.stringPadStart(tmpYear,4,'0');}return`${tmpMonth}/${tmpDay}/${tmpYear}`;}formatSortableStringFromDate(pDate){return pDate.getFullYear()+this.stringPadStart(pDate.getMonth(),2,'0')+this.stringPadStart(pDate.getDate(),2,'0');}/*************************************************************************
|
|
3354
3473
|
* String Tokenization Functions
|
|
3355
|
-
|
|
3474
|
+
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /**
|
|
3356
3475
|
* Return the string before the matched substring.
|
|
3357
3476
|
*
|
|
3358
3477
|
* If the substring is not found, the entire string is returned. This only deals with the *first* match.
|
|
@@ -3683,6 +3802,13 @@ this.LogNoisiness='LogNoisiness'in this.fable?this.fable.LogNoisiness:0;}/**
|
|
|
3683
3802
|
* @param {object} pManifest - The manifest object.
|
|
3684
3803
|
* @returns {any} The result of the solved expression.
|
|
3685
3804
|
*/solvePostfixedExpression(pPostfixedExpression,pDataDestinationObject,pResultObject,pManifest){return this.Solver.solvePostfixedExpression(pPostfixedExpression,pDataDestinationObject,pResultObject,pManifest);}/**
|
|
3805
|
+
* Add a function to the solver.
|
|
3806
|
+
*
|
|
3807
|
+
* @param {string} pFunctionName
|
|
3808
|
+
* @param {string} pFunctionAddress
|
|
3809
|
+
* @param {string} pFunctionComment
|
|
3810
|
+
*/addSolverFunction(pFunctionName,pFunctionAddress,pFunctionComment){let tmpFunctionName=(pFunctionName||'').trim().toLowerCase();if(this.functionMap.hasOwnProperty(tmpFunctionName)){this.log.warn(`PictDynamicFormsInformary: Function ${tmpFunctionName} already exists in the solver, overwriting with address [${pFunctionAddress}].`);//return false;
|
|
3811
|
+
}this.functionMap[tmpFunctionName]={Name:pFunctionComment||`Autogenerated function ${tmpFunctionName}`,Address:pFunctionAddress};}/**
|
|
3686
3812
|
* Prepares the parameters for a SERIES directive by substituting values and applying defaults.
|
|
3687
3813
|
*
|
|
3688
3814
|
* @param {Array} pParameters
|
|
@@ -3752,7 +3878,7 @@ let tmpDistributionPointValue=this.fable.Math.roundPrecise(tmpPointValue,tmpDist
|
|
|
3752
3878
|
let tmpAssignmentManifestHash=tmpResultsObject.PostfixedAssignmentAddress;if(tmpResultsObject.OriginalRawTokens[1]==='='&&typeof tmpResultsObject.OriginalRawTokens[0]==='string'&&tmpResultsObject.OriginalRawTokens[0].length>0){tmpAssignmentManifestHash=tmpResultsObject.OriginalRawTokens[0];}tmpManifest.setValueByHash(tmpDataDestinationObject,tmpAssignmentManifestHash,tmpMonteCarloOutput);return tmpMonteCarloOutput;}else// For 'SOLVE' or anything else that didn't work
|
|
3753
3879
|
{// This is where the data from variables gets marshaled into their symbols (from AppData or the like)
|
|
3754
3880
|
this.substituteValuesInTokenizedObjects(tmpResultsObject.PostfixTokenObjects,tmpDataSourceObject,tmpResultsObject,pManifest);// Finally this is the expr solving method, which returns a string and also marshals it into tmpDataDestinationObject
|
|
3755
|
-
return this.solvePostfixedExpression(tmpResultsObject.PostfixSolveList,tmpDataDestinationObject,tmpResultsObject,pManifest);}}}module.exports=FableServiceExpressionParser;},{"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-ExpressionTokenizer-DirectiveMutation.js":160,"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-ExpressionTokenizer.js":161,"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-FunctionMap.json":162,"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-Linter.js":163,"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-Messaging.js":164,"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-Postfix.js":165,"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-SolvePostfixedExpression.js":166,"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-TokenMap.json":167,"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-ValueMarshal.js":168,"fable-serviceproviderbase":59}],159:[function(require,module,exports){const libFableServiceProviderBase=require('fable-serviceproviderbase');class ExpressionParserOperationBase extends libFableServiceProviderBase{constructor(pFable,pOptions,pServiceHash){super(pFable,pOptions,pServiceHash);this.serviceType='ExpressionParserOperationBase';this.numberTest=/^-{0,1}\d*\.{0,1}\d+$/;this.ExpressionParser=false;}connectExpressionParser(pExpressionParser){this.ExpressionParser=pExpressionParser;}getTokenType(pToken){if(pToken in this.ExpressionParser.tokenMap){return`Token.${this.ExpressionParser.tokenMap[pToken].Type}`;}else if(pToken.length>2&&pToken[0]==='{'&&pToken[pToken.length-1]==='}'){return'Token.StateAddress';}else if(pToken.length>
|
|
3881
|
+
return this.solvePostfixedExpression(tmpResultsObject.PostfixSolveList,tmpDataDestinationObject,tmpResultsObject,pManifest);}}}module.exports=FableServiceExpressionParser;},{"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-ExpressionTokenizer-DirectiveMutation.js":160,"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-ExpressionTokenizer.js":161,"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-FunctionMap.json":162,"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-Linter.js":163,"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-Messaging.js":164,"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-Postfix.js":165,"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-SolvePostfixedExpression.js":166,"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-TokenMap.json":167,"./Fable-Service-ExpressionParser/Fable-Service-ExpressionParser-ValueMarshal.js":168,"fable-serviceproviderbase":59}],159:[function(require,module,exports){const libFableServiceProviderBase=require('fable-serviceproviderbase');class ExpressionParserOperationBase extends libFableServiceProviderBase{constructor(pFable,pOptions,pServiceHash){super(pFable,pOptions,pServiceHash);this.serviceType='ExpressionParserOperationBase';this.numberTest=/^-{0,1}\d*\.{0,1}\d+$/;this.ExpressionParser=false;}connectExpressionParser(pExpressionParser){this.ExpressionParser=pExpressionParser;}getTokenType(pToken){if(pToken in this.ExpressionParser.tokenMap){return`Token.${this.ExpressionParser.tokenMap[pToken].Type}`;}else if(pToken.length>2&&pToken[0]==='{'&&pToken[pToken.length-1]==='}'){return'Token.StateAddress';}else if(pToken.length>1&&pToken[0]==='"'&&pToken[pToken.length-1]==='"'){return'Token.String';}else if(this.numberTest.test(pToken)){return'Token.Constant';}else{return'Token.Symbol';}// Just for documentation sake:
|
|
3756
3882
|
// There is a fifth token type, VirtualSymbol
|
|
3757
3883
|
// This is a value that's added during solve and looked up by address in the VirtualSymbol object.
|
|
3758
3884
|
}getTokenContainerObject(pToken,pTokenType){return{Token:pToken,Type:typeof pTokenType==='undefined'?this.getTokenType(pToken):pTokenType,Descriptor:pToken in this.ExpressionParser.tokenMap?this.ExpressionParser.tokenMap[pToken]:false};}}module.exports=ExpressionParserOperationBase;},{"fable-serviceproviderbase":59}],160:[function(require,module,exports){const libExpressionParserOperationBase=require('./Fable-Service-ExpressionParser-Base.js');class ExpressionTokenizerDirectiveMutation extends libExpressionParserOperationBase{constructor(pFable,pOptions,pServiceHash){super(pFable,pOptions,pServiceHash);this.serviceType='ExpressionParser-TokenizerDirectiveMutation';this.directiveTypes={'SOLVE':{Name:'Solve Expression',Code:'SOLVE'},'SERIES':{Name:'Series',Code:'SERIES',From:null,To:null,Step:null},'MONTECARLO':{Name:'Monte Carlo Simulation',SampleCount:'1',Code:'MONTECARLO',Values:{}},'MAP':{Name:'Map',Code:'MAP',Values:{},ValueKeys:[]}};this.defaultDirective=this.directiveTypes.SOLVE;}parseSeriesDirective(pTokens){// This isn't a fancy real parse it's just taking words and stealing values after them.
|
|
@@ -3791,7 +3917,7 @@ break;}}}}return tmpResults.SolverDirectives;}}module.exports=ExpressionTokenize
|
|
|
3791
3917
|
* : could be a parenthesis e.g. "(", ")"
|
|
3792
3918
|
* - String
|
|
3793
3919
|
* : Wrapped in double quotes e.g. "Hello World", "This is a test", etc.
|
|
3794
|
-
*/let tmpCurrentTokenType=false;let tmpCurrentToken='';for(let i=0;i<pExpression.length;i++){let tmpCharacter=pExpression[i];// [ WHITESPACE ]
|
|
3920
|
+
*/ /** @type {any} */let tmpCurrentTokenType=false;let tmpCurrentToken='';for(let i=0;i<pExpression.length;i++){let tmpCharacter=pExpression[i];// [ WHITESPACE ]
|
|
3795
3921
|
// 1. Space breaks tokens except when we're in an address that's been scoped by a {} or ""
|
|
3796
3922
|
if((tmpCharacter===' '||tmpCharacter==='\t')&&tmpCurrentTokenType!=='StateAddress'&&tmpCurrentTokenType!=='String'){if(tmpCurrentToken.length>0){tmpResults.RawTokens.push(tmpCurrentToken);}tmpCurrentToken='';tmpCurrentTokenType=false;continue;}// [ STATE ADDRESS AND STRING BLOCKS ]
|
|
3797
3923
|
// 2. If we're in an address, we keep going until we hit the closing brace
|
|
@@ -3809,7 +3935,7 @@ for(let j=0;j<tmpTokenRadix.TokenKeys.length;j++){let tmpTokenKey=tmpTokenRadix.
|
|
|
3809
3935
|
/* Per this stack overflow article: https://stackoverflow.com/questions/4434076/best-way-to-alphanumeric-check-in-javascript
|
|
3810
3936
|
* We could use a regex but it is slower than the charCodeAt method.
|
|
3811
3937
|
* This also doesn't solve the problem of unicode characters, but we won't support those for now.
|
|
3812
|
-
|
|
3938
|
+
*/ // if (pExpression.charAt(i) == '.')
|
|
3813
3939
|
// {
|
|
3814
3940
|
// console.log('Found a period')
|
|
3815
3941
|
// }
|
|
@@ -3968,7 +4094,7 @@ else{tmpResults.PostfixSolveList.push(this.getPosfixSolveListOperation(tmpToken,
|
|
|
3968
4094
|
let tmpAbstractAssignToken='PostfixedAssignmentOperator'in tmpResults?this.getTokenContainerObject(tmpResults.PostfixedAssignmentOperator.Token):this.getTokenContainerObject('=');// The address we are assigning to
|
|
3969
4095
|
tmpAbstractAssignToken.VirtualSymbolName=tmpResults.PostfixedAssignmentAddress;// The address it's coming from
|
|
3970
4096
|
let tmpSolveResultToken=this.getTokenContainerObject('Result','Token.LastResult');let tmpFinalAssignmentInstruction=this.getPosfixSolveListOperation(tmpAbstractAssignToken,tmpSolveResultToken,this.getTokenContainerObject('SolverMarshal','Token.SolverMarshal'));tmpResults.PostfixSolveList.push(tmpFinalAssignmentInstruction);return tmpResults.PostfixSolveList;}}module.exports=ExpressionParserPostfix;},{"./Fable-Service-ExpressionParser-Base.js":159}],166:[function(require,module,exports){const libExpressionParserOperationBase=require('./Fable-Service-ExpressionParser-Base.js');const libSetConcatArray=require('../Fable-SetConcatArray.js');class ExpressionParserSolver extends libExpressionParserOperationBase{constructor(pFable,pOptions,pServiceHash){super(pFable,pOptions,pServiceHash);this.serviceType='ExpressionParser-Solver';}solvePostfixedExpression(pPostfixedExpression,pDataDestinationObject,pResultObject,pManifest){let tmpResults=typeof pResultObject==='object'?pResultObject:{ExpressionParserLog:[]};let tmpManifest=typeof pManifest==='object'?pManifest:this.fable.newManyfest();let tmpDataDestinationObject=typeof pDataDestinationObject==='object'?pDataDestinationObject:{};// If there was a fable passed in (e.g. the results object was a service or such), we won't decorate
|
|
3971
|
-
let tmpPassedInFable='fable'in tmpResults;if(!tmpPassedInFable){tmpResults.fable=this.fable;}if(!Array.isArray(pPostfixedExpression)){tmpResults.ExpressionParserLog.push(`ERROR: ExpressionParser.solvePostfixedExpression was passed a non-array postfixed expression.`);this.log.error(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);return false;}if(pPostfixedExpression.length<1){tmpResults.ExpressionParserLog.push(`ERROR: ExpressionParser.solvePostfixedExpression was passed an empty postfixed expression.`);this.log.error(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);return false;}// This is how the user communication magic happens.
|
|
4097
|
+
let tmpPassedInFable=('fable'in tmpResults);if(!tmpPassedInFable){tmpResults.fable=this.fable;}if(!Array.isArray(pPostfixedExpression)){tmpResults.ExpressionParserLog.push(`ERROR: ExpressionParser.solvePostfixedExpression was passed a non-array postfixed expression.`);this.log.error(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);return false;}if(pPostfixedExpression.length<1){tmpResults.ExpressionParserLog.push(`ERROR: ExpressionParser.solvePostfixedExpression was passed an empty postfixed expression.`);this.log.error(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);return false;}// This is how the user communication magic happens.
|
|
3972
4098
|
tmpResults.VirtualSymbols={};for(let i=0;i<pPostfixedExpression.length;i++){// X = SUM(15, SUM(SIN(25), 10), (5 + 2), 3)
|
|
3973
4099
|
if(pPostfixedExpression[i].Operation.Type==='Token.SolverInstruction'){continue;}let tmpStepResultObject={ExpressionStep:pPostfixedExpression[i],ExpressionStepIndex:i,ResultsObject:tmpResults,Manifest:tmpManifest};if(tmpStepResultObject.ExpressionStep.LeftValue.Type==='Token.LastResult'){tmpStepResultObject.ExpressionStep.LeftValue.Value=tmpResults.LastResult;}if(tmpStepResultObject.ExpressionStep.RightValue.Type==='Token.LastResult'){tmpStepResultObject.ExpressionStep.RightValue.Value=tmpResults.LastResult;}if(tmpStepResultObject.ExpressionStep.LeftValue.Type==='Token.VirtualSymbol'){tmpStepResultObject.ExpressionStep.LeftValue.Value=tmpManifest.getValueAtAddress(tmpResults.VirtualSymbols,tmpStepResultObject.ExpressionStep.LeftValue.Token);}if(tmpStepResultObject.ExpressionStep.RightValue.Type==='Token.VirtualSymbol'){tmpStepResultObject.ExpressionStep.RightValue.Value=tmpManifest.getValueAtAddress(tmpResults.VirtualSymbols,tmpStepResultObject.ExpressionStep.RightValue.Token);}// Resolve the parenthesis to their actual values
|
|
3974
4100
|
if(tmpStepResultObject.ExpressionStep.LeftValue.Type==='Token.Parenthesis'){tmpStepResultObject.ExpressionStep.LeftValue.Value=tmpManifest.getValueAtAddress(tmpResults.VirtualSymbols,tmpStepResultObject.ExpressionStep.LeftValue.VirtualSymbolName);}if(tmpStepResultObject.ExpressionStep.RightValue.Type==='Token.Parenthesis'){tmpStepResultObject.ExpressionStep.RightValue.Value=tmpManifest.getValueAtAddress(tmpResults.VirtualSymbols,tmpStepResultObject.ExpressionStep.RightValue.VirtualSymbolName);}// Virtual Constants
|
|
@@ -4001,7 +4127,7 @@ let tmpValue=tmpManifest.getValueByHash(tmpDataSource,tmpToken.Token);// if (!tm
|
|
|
4001
4127
|
// // If no hash resolves, try by address.
|
|
4002
4128
|
// tmpValue = tmpManifest.getValueAtAddress(tmpToken.Token, tmpDataSource);
|
|
4003
4129
|
// }
|
|
4004
|
-
if(tmpValue==null){tmpToken.Value=tmpValue;tmpToken.Resolve=true;tmpResults.ExpressionParserLog.push(`WARNING: ExpressionParser.substituteValuesInTokenizedObjects found no value for the symbol hash or address ${tmpToken.Token} at index ${i}`);this.log.warn(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);continue;}else{tmpResults.ExpressionParserLog.push(`INFO: ExpressionParser.substituteValuesInTokenizedObjects found a value [${tmpValue}] for the state address ${tmpToken.Token} at index ${i}`);if(this.LogNoisiness>1)this.log.info(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);if(typeof tmpValue==='object')// this encapsulates POJOs and arrays
|
|
4130
|
+
if(tmpValue==null){tmpToken.Value=tmpValue;tmpToken.Resolve=true;tmpResults.ExpressionParserLog.push(`WARNING: ExpressionParser.substituteValuesInTokenizedObjects found no value for the symbol hash or address ${tmpToken.Token} at index ${i}`);if(this.LogNoisiness>1)this.log.warn(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);continue;}else{tmpResults.ExpressionParserLog.push(`INFO: ExpressionParser.substituteValuesInTokenizedObjects found a value [${tmpValue}] for the state address ${tmpToken.Token} at index ${i}`);if(this.LogNoisiness>1)this.log.info(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);if(typeof tmpValue==='object')// this encapsulates POJOs and arrays
|
|
4005
4131
|
{// this must be checked first, which works around an edge case where bigNumber turns single-element arrays into numbers, which we never want
|
|
4006
4132
|
tmpToken.Resolved=true;tmpToken.Value=tmpValue;}else{try{const tmpValueParsed=new this.fable.Utility.bigNumber(tmpValue);tmpToken.Resolved=true;tmpToken.Value=tmpValueParsed.toString();}catch(pError){// TODO: Should we allow this to be a function? Good god the complexity and beauty of that...
|
|
4007
4133
|
tmpToken.Resolved=true;tmpToken.Value=tmpValue;tmpResults.ExpressionParserLog.push(`INFO: ExpressionParser.substituteValuesInTokenizedObjects found a non-numeric value for the state address ${tmpToken.Token} at index ${i}; using raw value.`);//this.log.warn(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);
|
|
@@ -4009,8 +4135,10 @@ tmpToken.Resolved=true;tmpToken.Value=tmpValue;tmpResults.ExpressionParserLog.pu
|
|
|
4009
4135
|
// Sometimes the token is wrapped in {} to indicate it's a direct address reference... we need to strip those off.
|
|
4010
4136
|
// e.g., {0x1234abcd...}
|
|
4011
4137
|
// So we need to strip off the {} if they exist.
|
|
4012
|
-
let tmpAddress=tmpToken.Token;if(tmpAddress.startsWith('{')&&tmpAddress.endsWith('}')){tmpAddress=tmpAddress.substring(1,tmpAddress.length-1);}let tmpValue=tmpManifest.getValueAtAddress(tmpDataSource,tmpAddress);if(!tmpValue){tmpResults.ExpressionParserLog.push(`WARNING: ExpressionParser.substituteValuesInTokenizedObjects found no value for the state address ${tmpToken.Token} at index ${i}`)
|
|
4013
|
-
|
|
4138
|
+
let tmpAddress=tmpToken.Token;if(tmpAddress.startsWith('{')&&tmpAddress.endsWith('}')){tmpAddress=tmpAddress.substring(1,tmpAddress.length-1);}let tmpValue=tmpManifest.getValueAtAddress(tmpDataSource,tmpAddress);if(!tmpValue){tmpResults.ExpressionParserLog.push(`WARNING: ExpressionParser.substituteValuesInTokenizedObjects found no value for the state address ${tmpToken.Token} at index ${i}`);//this.log.warn(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);
|
|
4139
|
+
continue;}else{//tmpResults.ExpressionParserLog.push(`INFO: ExpressionParser.substituteValuesInTokenizedObjects found a value [${tmpValue}] for the state address ${tmpToken.Token} at index ${i}`);
|
|
4140
|
+
//this.log.info(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);
|
|
4141
|
+
try{let tmpValueParsed=new this.fable.Utility.bigNumber(tmpValue);tmpToken.Resolved=true;tmpToken.Value=tmpValueParsed.toString();}catch(pError){tmpResults.ExpressionParserLog.push(`ERROR: ExpressionParser.substituteValuesInTokenizedObjects found a non-numeric value for the state address ${tmpToken.Token} at index ${i}`);//this.log.error(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);
|
|
4014
4142
|
tmpToken.Resolved=false;}}}if(pTokenizedObjects[i].Type==='Token.String'&&!tmpToken.Resolved){tmpResults.ExpressionParserLog.push(`INFO: ExpressionParser.substituteValuesInTokenizedObjects found a value [${tmpToken.Token}] for the string ${tmpToken.Token} at index ${i}`);if(this.LogNoisiness>1)this.log.info(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);tmpToken.Resolved=true;// Take the quotes off the string
|
|
4015
4143
|
tmpToken.Value=tmpToken.Token.substring(1,tmpToken.Token.length-1);}if(pTokenizedObjects[i].Type==='Token.Constant'&&!tmpToken.Resolved){tmpResults.ExpressionParserLog.push(`INFO: ExpressionParser.substituteValuesInTokenizedObjects found a value [${tmpToken.Token}] for the constant ${tmpToken.Token} at index ${i}`);if(this.LogNoisiness>1)this.log.info(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);try{let tmpValueParsed=new this.fable.Utility.bigNumber(tmpToken.Token);tmpToken.Resolved=true;tmpToken.Value=tmpValueParsed.toString();}catch(pError){// This constant has the right symbols but apparently isn't a parsable number.
|
|
4016
4144
|
tmpResults.ExpressionParserLog.push(`ERROR: ExpressionParser.substituteValuesInTokenizedObjects found a non-numeric value for the state address ${tmpToken.Token} at index ${i}`);//this.log.error(tmpResults.ExpressionParserLog[tmpResults.ExpressionParserLog.length-1]);
|
|
@@ -4250,7 +4378,7 @@ let tmpResult=tmpDegreesArbitraryValue.times(Math.PI).div(180);return tmpResult.
|
|
|
4250
4378
|
* on what was requested.
|
|
4251
4379
|
*
|
|
4252
4380
|
* The following functions will likely be broken into their own service.
|
|
4253
|
-
|
|
4381
|
+
*/ /**
|
|
4254
4382
|
* Counts the number of elements in a set.
|
|
4255
4383
|
*
|
|
4256
4384
|
* @param {Array|Object|any} pValueSet - The set to count the elements of.
|