jtlt 0.12.0 → 0.14.0
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/CHANGES.md +15 -0
- package/README.md +100 -82
- package/demo/calltemplate-params-demo.js +29 -34
- package/demo/codemirror.esm.js +140 -70
- package/demo/codemirror.js +9 -5
- package/demo/index.js +2 -1
- package/demo/vendor/fontoxpath/dist/fontoxpath.esm.js +508 -499
- package/demo/vendor/jamilih/dist/jml.mjs +516 -225
- package/demo/vendor/jhtml/src/SAJJ/SAJJ.ObjectArrayDelegator.js +17 -17
- package/demo/vendor/jhtml/src/SAJJ/SAJJ.js +60 -61
- package/demo/vendor/jhtml/src/jhtml-browser.js +1 -0
- package/demo/vendor/jhtml/src/jhtml-node.js +1 -0
- package/demo/vendor/jhtml/src/jhtml.js +18 -15
- package/demo/vendor/jsonpath-plus/dist/index-browser-esm.js +11 -5
- package/dist/AbstractJoiningTransformer.d.ts +17 -25
- package/dist/AbstractJoiningTransformer.d.ts.map +1 -1
- package/dist/DOMJoiningTransformer.d.ts +502 -19
- package/dist/DOMJoiningTransformer.d.ts.map +1 -1
- package/dist/JSONJoiningTransformer.d.ts +41 -25
- package/dist/JSONJoiningTransformer.d.ts.map +1 -1
- package/dist/JSONPathTransformer.d.ts +30 -29
- package/dist/JSONPathTransformer.d.ts.map +1 -1
- package/dist/JSONPathTransformerContext.d.ts +152 -99
- package/dist/JSONPathTransformerContext.d.ts.map +1 -1
- package/dist/StringJoiningTransformer.d.ts +42 -28
- package/dist/StringJoiningTransformer.d.ts.map +1 -1
- package/dist/XPathTransformer.d.ts +20 -13
- package/dist/XPathTransformer.d.ts.map +1 -1
- package/dist/XPathTransformerContext.d.ts +92 -53
- package/dist/XPathTransformerContext.d.ts.map +1 -1
- package/dist/XSLTStyleJSONPathResolver.d.ts +1 -1
- package/dist/XSLTStyleJSONPathResolver.d.ts.map +1 -1
- package/dist/index-browser.d.ts +2 -2
- package/dist/index-browser.d.ts.map +1 -1
- package/dist/index-node.d.ts +2 -2
- package/dist/index-node.d.ts.map +1 -1
- package/dist/index.d.ts +224 -171
- package/dist/index.d.ts.map +1 -1
- package/dist/indexedDB.d.ts +107 -0
- package/dist/indexedDB.d.ts.map +1 -0
- package/dist/maybeAsync.d.ts +15 -0
- package/dist/maybeAsync.d.ts.map +1 -0
- package/docs/API.expanded.md +74 -22
- package/docs/API.md +34 -4
- package/docs/TO-DO.md +5 -3
- package/eslint.config.js +28 -4
- package/package.json +25 -22
- package/pnpm-workspace.yaml +41 -4
- package/rollup.config.js +42 -0
- package/src/AbstractJoiningTransformer.js +11 -4
- package/src/DOMJoiningTransformer.js +56 -27
- package/src/JSONJoiningTransformer.js +64 -44
- package/src/JSONPathTransformer.js +124 -85
- package/src/JSONPathTransformerContext.js +252 -70
- package/src/StringJoiningTransformer.js +48 -23
- package/src/XPathTransformer.js +50 -14
- package/src/XPathTransformerContext.js +309 -139
- package/src/index-browser.js +1 -0
- package/src/index-node.js +2 -0
- package/src/index.js +206 -72
- package/src/indexedDB.js +530 -0
- package/src/maybeAsync.js +44 -0
- package/test.html +17 -0
- package/test.js +45 -0
- package/tsconfig-prod.json +1 -0
- package/tsconfig.json +3 -2
- package/dist/types.d.ts +0 -204
- package/dist/types.d.ts.map +0 -1
|
@@ -7,13 +7,12 @@ import SAJJ from './SAJJ.js';
|
|
|
7
7
|
/* eslint-enable jsdoc/reject-any-type -- Arbitrary */
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* @abstract
|
|
11
|
-
* @class
|
|
12
|
-
* @todo Might add an add() method which defines how to combine result values
|
|
13
|
-
* (so as to allow for other means besides string concatenation)
|
|
14
|
-
*/
|
|
10
|
+
* @abstract
|
|
11
|
+
* @class
|
|
12
|
+
* @todo Might add an add() method which defines how to combine result values
|
|
13
|
+
* (so as to allow for other means besides string concatenation)
|
|
14
|
+
*/
|
|
15
15
|
class ObjectArrayDelegator extends SAJJ {
|
|
16
|
-
/* eslint-disable jsdoc/require-returns-check -- Abstract */
|
|
17
16
|
/**
|
|
18
17
|
* @returns {AnyDelegated}
|
|
19
18
|
*/
|
|
@@ -76,7 +75,6 @@ class ObjectArrayDelegator extends SAJJ {
|
|
|
76
75
|
) {
|
|
77
76
|
throw new Error('Abstract');
|
|
78
77
|
}
|
|
79
|
-
/* eslint-enable jsdoc/require-returns-check -- Abstract */
|
|
80
78
|
|
|
81
79
|
// It is probably not necessary to override the defaults for the following
|
|
82
80
|
// two methods and perhaps not any of the others either
|
|
@@ -109,17 +107,19 @@ class ObjectArrayDelegator extends SAJJ {
|
|
|
109
107
|
}
|
|
110
108
|
} else {
|
|
111
109
|
for (const key in value) {
|
|
112
|
-
if (Object.hasOwn(value, key)) {
|
|
113
|
-
|
|
114
|
-
this.currentObject = value[key];
|
|
115
|
-
keyVals.push(
|
|
116
|
-
this.keyValueHandler(
|
|
117
|
-
value[key], key, value, parentKey,
|
|
118
|
-
parentObjectArrayBool, false, i
|
|
119
|
-
)
|
|
120
|
-
);
|
|
121
|
-
i++;
|
|
110
|
+
if (!Object.hasOwn(value, key)) {
|
|
111
|
+
continue;
|
|
122
112
|
}
|
|
113
|
+
|
|
114
|
+
this.currentKey = key;
|
|
115
|
+
this.currentObject = value[key];
|
|
116
|
+
keyVals.push(
|
|
117
|
+
this.keyValueHandler(
|
|
118
|
+
value[key], key, value, parentKey,
|
|
119
|
+
parentObjectArrayBool, false, i
|
|
120
|
+
)
|
|
121
|
+
);
|
|
122
|
+
i++;
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
}
|
|
@@ -99,9 +99,9 @@
|
|
|
99
99
|
*/
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
|
-
* @typedef {"undefined"|"null"|"boolean"|"symbol"
|
|
103
|
-
* "number"|"nonfiniteNumber"|"bigint"
|
|
104
|
-
* "string"|"function"|"array"|"object"|"ignore"} SAJJType
|
|
102
|
+
* @typedef {"undefined"|"null"|"boolean"|"symbol"
|
|
103
|
+
* |"number"|"nonfiniteNumber"|"bigint"
|
|
104
|
+
* |"string"|"function"|"array"|"object"|"ignore"} SAJJType
|
|
105
105
|
*/
|
|
106
106
|
|
|
107
107
|
// PRIVATE STATIC UTILITIES
|
|
@@ -119,7 +119,7 @@ function _copyObject (obj, deep) {
|
|
|
119
119
|
const copyObj = {};
|
|
120
120
|
// eslint-disable-next-line guard-for-in -- Deliberate iterating of prototype
|
|
121
121
|
for (const prop in obj) {
|
|
122
|
-
copyObj[prop] = deep && obj[prop] && typeof obj[prop] === 'object'
|
|
122
|
+
copyObj[prop] = deep && obj[prop] !== null && typeof obj[prop] === 'object'
|
|
123
123
|
? _copyObject(/** @type {NestedObject} */ (obj[prop]))
|
|
124
124
|
: obj[prop];
|
|
125
125
|
}
|
|
@@ -150,6 +150,17 @@ function _copyObject (obj, deep) {
|
|
|
150
150
|
class SAJJ {
|
|
151
151
|
ret = '';
|
|
152
152
|
|
|
153
|
+
/** @type {SAJJOptions|undefined} */
|
|
154
|
+
options;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* @param {SAJJOptions} [options] See setDefaultOptions() function body for
|
|
158
|
+
* some possibilities
|
|
159
|
+
*/
|
|
160
|
+
constructor (options) {
|
|
161
|
+
this.setDefaultOptions(options);
|
|
162
|
+
}
|
|
163
|
+
|
|
153
164
|
/* eslint-disable jsdoc/require-returns-check -- Abstract */
|
|
154
165
|
/**
|
|
155
166
|
* Could override for logging; meant for allowing dropping of
|
|
@@ -398,18 +409,6 @@ class SAJJ {
|
|
|
398
409
|
}
|
|
399
410
|
/* eslint-enable jsdoc/require-returns-check -- Abstract */
|
|
400
411
|
|
|
401
|
-
/**
|
|
402
|
-
* @param {SAJJOptions} options See setDefaultOptions() function body for
|
|
403
|
-
* some possibilities
|
|
404
|
-
*/
|
|
405
|
-
constructor (options) {
|
|
406
|
-
/** @type {SAJJOptions} */
|
|
407
|
-
// eslint-disable-next-line no-unused-expressions -- TS
|
|
408
|
-
this.options;
|
|
409
|
-
|
|
410
|
-
this.setDefaultOptions(options);
|
|
411
|
-
}
|
|
412
|
-
|
|
413
412
|
// OPTIONS
|
|
414
413
|
/**
|
|
415
414
|
* @param {SAJJOptions} [options]
|
|
@@ -447,11 +446,11 @@ class SAJJ {
|
|
|
447
446
|
}
|
|
448
447
|
|
|
449
448
|
/**
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
449
|
+
* Rather than use the strategy design pattern, we'll override our prototype
|
|
450
|
+
* selectively.
|
|
451
|
+
* @param {SAJJOptions} options
|
|
452
|
+
* @returns {void}
|
|
453
|
+
*/
|
|
455
454
|
alterDefaultHandlers (options) {
|
|
456
455
|
if (this.distinguishKeysValues) {
|
|
457
456
|
this.keyValueHandler = this.keyValueDistinguishedHandler;
|
|
@@ -464,17 +463,17 @@ class SAJJ {
|
|
|
464
463
|
// PUBLIC METHODS TO INITIATE PARSING
|
|
465
464
|
|
|
466
465
|
/**
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
466
|
+
* For strings, one may wish to use Clarinet (<https://github.com/dscape/clarinet>) to
|
|
467
|
+
* avoid extra overhead or parsing twice.
|
|
468
|
+
* @param {string} str The JSON string to be walked (after complete conversion
|
|
469
|
+
* to an object)
|
|
470
|
+
* @param {object|object[]} [parentObject] The parent object or array
|
|
471
|
+
* containing the string
|
|
472
|
+
* @param {string} [parentKey] The parent object or array's key
|
|
473
|
+
* @param {boolean} [parentObjectArrayBool] Whether the parent object is an
|
|
474
|
+
* array (not another object)
|
|
475
|
+
* @returns {AnyValue}
|
|
476
|
+
*/
|
|
478
477
|
walkJSONString (str, parentObject, parentKey, parentObjectArrayBool) {
|
|
479
478
|
return this.walkJSONObject(
|
|
480
479
|
JSON.parse(str), parentObject, parentKey, parentObjectArrayBool
|
|
@@ -482,26 +481,26 @@ class SAJJ {
|
|
|
482
481
|
}
|
|
483
482
|
|
|
484
483
|
/**
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
484
|
+
*
|
|
485
|
+
* @param {import('../jhtml.js').JSONObject} obj The JSON object to walk
|
|
486
|
+
* @param {object|object[]} [parentObject] The parent object or array
|
|
487
|
+
* containing the string
|
|
488
|
+
* @param {string} [parentKey] The parent object or array's key
|
|
489
|
+
* @param {boolean} [parentObjectArrayBool] Whether the parent object is an
|
|
490
|
+
* array (not another object)
|
|
491
|
+
* @property {string|AnyValue} ret The intermediate return value (if any) from
|
|
492
|
+
* beginHandler and delegateHandlersByType delegation
|
|
493
|
+
* @returns {string} The final return value including beginHandler and
|
|
494
|
+
* delegateHandlersByType delegation plus any endHandler additions;
|
|
495
|
+
* one may build one's own intermediate values, but "ret" should be
|
|
496
|
+
* set to return the value
|
|
497
|
+
*/
|
|
499
498
|
walkJSONObject (obj, parentObject, parentKey, parentObjectArrayBool) {
|
|
500
499
|
this.root = obj;
|
|
501
|
-
const parObj = parentObject || this.options
|
|
502
|
-
parKey = parentKey || this.options
|
|
500
|
+
const parObj = parentObject || this.options?.parentObject,
|
|
501
|
+
parKey = parentKey || this.options?.parentKey,
|
|
503
502
|
parObjArrBool = parentObjectArrayBool ||
|
|
504
|
-
this.options
|
|
503
|
+
this.options?.parentObjectArrayBool ||
|
|
505
504
|
(parObj && this.isArrayType(parObj));
|
|
506
505
|
this.ret = this.beginHandler(obj, parObj, parKey, parObjArrBool);
|
|
507
506
|
this.ret += this.delegateHandlersByType(obj, parObj, parKey, parObjArrBool);
|
|
@@ -661,23 +660,23 @@ class SAJJ {
|
|
|
661
660
|
}
|
|
662
661
|
|
|
663
662
|
/**
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
663
|
+
* Could override to always return false if one wished to merge
|
|
664
|
+
* arrayHandler/objectHandler or, if in JSMode, to merge detectObjectType
|
|
665
|
+
* and this isArrayType method. To merge arrayKeyValueHandler and
|
|
666
|
+
* objectKeyValueHandler, see keyValueHandler.
|
|
667
|
+
* @param {AnyValue} obj
|
|
668
|
+
* @returns {boolean}
|
|
669
|
+
*/
|
|
671
670
|
isArrayType (obj) {
|
|
672
671
|
return Object.prototype.toString.call(obj) === '[object Array]';
|
|
673
672
|
}
|
|
674
673
|
|
|
675
674
|
/**
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
675
|
+
* Allow overriding to detect `Date`, `RegExp`, or other types (which will in
|
|
676
|
+
* turn route to corresponding names).
|
|
677
|
+
* @param {AnyValue} obj
|
|
678
|
+
* @returns {"object"}
|
|
679
|
+
*/
|
|
681
680
|
detectObjectType (
|
|
682
681
|
// eslint-disable-next-line no-unused-vars -- Signature
|
|
683
682
|
obj
|
|
@@ -106,12 +106,12 @@ function item2JSONObject (item, allowJS, throwOnSpan) {
|
|
|
106
106
|
ret = -Infinity;
|
|
107
107
|
break;
|
|
108
108
|
case 'NaN':
|
|
109
|
-
ret =
|
|
109
|
+
ret = NaN;
|
|
110
110
|
break;
|
|
111
111
|
default: {
|
|
112
112
|
// number
|
|
113
113
|
if ((/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:e(?:[+\-])?\d+)?$/vi).test(textContent)) {
|
|
114
|
-
return Number
|
|
114
|
+
return Number(textContent);
|
|
115
115
|
}
|
|
116
116
|
// function
|
|
117
117
|
const funcMatch = textContent.match(/^function \w*\s*\(([\w, ]*)\) \{([\s\S]*)\}$/v);
|
|
@@ -198,9 +198,10 @@ function item2JSONObject (item, allowJS, throwOnSpan) {
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
/** @type {JSONObjectPlain} */
|
|
201
|
-
|
|
201
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
202
|
+
(ret)[key] = item2JSONObject(/** @type {Element} */ (/** @type {Element} */ (
|
|
202
203
|
node
|
|
203
|
-
).
|
|
204
|
+
).firstElementChild), allowJS, true);
|
|
204
205
|
});
|
|
205
206
|
if (state !== 'dt') {
|
|
206
207
|
throw new Error(
|
|
@@ -239,7 +240,8 @@ function item2JSONObject (item, allowJS, throwOnSpan) {
|
|
|
239
240
|
} else {
|
|
240
241
|
/** @type {JSONObjectArray} */
|
|
241
242
|
(ret).push(item2JSONObject(
|
|
242
|
-
/** @type {Element} */
|
|
243
|
+
/** @type {Element} */
|
|
244
|
+
(/** @type {Element} */ (node).firstElementChild), allowJS, true
|
|
243
245
|
));
|
|
244
246
|
}
|
|
245
247
|
});
|
|
@@ -258,7 +260,8 @@ function escapeHTMLText (str) {
|
|
|
258
260
|
return str.replaceAll('&', '&').replaceAll('<', '<');
|
|
259
261
|
}
|
|
260
262
|
|
|
261
|
-
// eslint-disable-next-line
|
|
263
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
264
|
+
// eslint-disable-next-line unicorn/prefer-https, sonarjs/no-clear-text-protocols -- NS
|
|
262
265
|
const jhtmlNs = 'http://brett-zamir.me/ns/microdata/json-as-html/2';
|
|
263
266
|
|
|
264
267
|
/**
|
|
@@ -400,12 +403,6 @@ class JHTMLStringifier extends ObjectArrayDelegator {
|
|
|
400
403
|
return escapeHTMLText(value);
|
|
401
404
|
}
|
|
402
405
|
|
|
403
|
-
/* eslint-disable jsdoc/reject-function-type -- Generic */
|
|
404
|
-
/**
|
|
405
|
-
* @typedef {Function} GenericFunction
|
|
406
|
-
*/
|
|
407
|
-
/* eslint-enable jsdoc/reject-function-type -- Generic */
|
|
408
|
-
|
|
409
406
|
// JavaScript-only (non-JSON) (terminal) handler methods (not used or
|
|
410
407
|
// required for JSON mode)
|
|
411
408
|
/**
|
|
@@ -527,6 +524,8 @@ let _win;
|
|
|
527
524
|
* @returns {void}
|
|
528
525
|
*/
|
|
529
526
|
export const setWindow = (win) => {
|
|
527
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
528
|
+
// eslint-disable-next-line unicorn/no-top-level-assignment-in-function -- Static
|
|
530
529
|
_win = win;
|
|
531
530
|
};
|
|
532
531
|
|
|
@@ -538,11 +537,13 @@ export const setWindow = (win) => {
|
|
|
538
537
|
* @returns {JSONObject}
|
|
539
538
|
*/
|
|
540
539
|
export const toJSONObject = function (items, options) {
|
|
541
|
-
options
|
|
540
|
+
options ||= {};
|
|
542
541
|
const isElement = items && !Array.isArray(items) && items.nodeType === 1;
|
|
543
542
|
const jsonHtml = isElement
|
|
544
543
|
? [items]
|
|
545
544
|
: (/** @type {Element[]} */ (items) ||
|
|
545
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
546
|
+
// eslint-disable-next-line unicorn/require-css-escape -- That's what this is doing
|
|
546
547
|
_win.document.querySelectorAll(`[itemtype=${_win.CSS.escape(jhtmlNs)}]`));
|
|
547
548
|
const ret = [...jsonHtml].map((item) => {
|
|
548
549
|
return item2JSONObject(item, options.mode === 'JavaScript');
|
|
@@ -561,11 +562,13 @@ export const toJSONObject = function (items, options) {
|
|
|
561
562
|
* @returns {string|string[]}
|
|
562
563
|
*/
|
|
563
564
|
export const toJSONString = function (items, options) {
|
|
564
|
-
options
|
|
565
|
+
options ||= {};
|
|
565
566
|
const isElement = items && !Array.isArray(items) && items.nodeType === 1;
|
|
566
567
|
const jsonHtml = isElement
|
|
567
568
|
? [items]
|
|
568
569
|
: (/** @type {Element[]} */ (items) ||
|
|
570
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
571
|
+
// eslint-disable-next-line unicorn/require-css-escape -- That's what this is doing
|
|
569
572
|
_win.document.querySelectorAll(`[itemtype=${_win.CSS.escape(jhtmlNs)}]`));
|
|
570
573
|
const ret = [...jsonHtml].map((item) => {
|
|
571
574
|
const jsonObj = item2JSONObject(item, options.mode === 'JavaScript');
|
|
@@ -581,7 +584,7 @@ export const toJSONString = function (items, options) {
|
|
|
581
584
|
* @returns {string}
|
|
582
585
|
*/
|
|
583
586
|
export const toJHTMLString = function (jsonObj, options) {
|
|
584
|
-
options
|
|
587
|
+
options ||= {};
|
|
585
588
|
options.distinguishKeysValues = true;
|
|
586
589
|
const jhtmlStringifier = new JHTMLStringifier(options);
|
|
587
590
|
return jhtmlStringifier.walkJSONObject(jsonObj);
|
|
@@ -1203,9 +1203,10 @@ const plugin = {
|
|
|
1203
1203
|
// register plugins
|
|
1204
1204
|
jsep.plugins.register(index, plugin);
|
|
1205
1205
|
jsep.addUnaryOp('typeof');
|
|
1206
|
+
jsep.addUnaryOp('void');
|
|
1206
1207
|
jsep.addLiteral('null', null);
|
|
1207
1208
|
jsep.addLiteral('undefined', undefined);
|
|
1208
|
-
const BLOCKED_PROTO_PROPERTIES = new Set(['constructor', '__proto__', '__defineGetter__', '__defineSetter__']);
|
|
1209
|
+
const BLOCKED_PROTO_PROPERTIES = new Set(['constructor', '__proto__', '__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__']);
|
|
1209
1210
|
const SafeEval = {
|
|
1210
1211
|
/**
|
|
1211
1212
|
* @param {jsep.Expression} ast
|
|
@@ -1324,7 +1325,9 @@ const SafeEval = {
|
|
|
1324
1325
|
'~': a => ~SafeEval.evalAst(a, subs),
|
|
1325
1326
|
// eslint-disable-next-line no-implicit-coercion -- API
|
|
1326
1327
|
'+': a => +SafeEval.evalAst(a, subs),
|
|
1327
|
-
typeof: a => typeof SafeEval.evalAst(a, subs)
|
|
1328
|
+
typeof: a => typeof SafeEval.evalAst(a, subs),
|
|
1329
|
+
// eslint-disable-next-line no-void, sonarjs/void-use -- feature
|
|
1330
|
+
void: a => void SafeEval.evalAst(a, subs)
|
|
1328
1331
|
}[ast.operator](ast.argument);
|
|
1329
1332
|
return result;
|
|
1330
1333
|
},
|
|
@@ -1334,9 +1337,12 @@ const SafeEval = {
|
|
|
1334
1337
|
evalCallExpression(ast, subs) {
|
|
1335
1338
|
const args = ast.arguments.map(arg => SafeEval.evalAst(arg, subs));
|
|
1336
1339
|
const func = SafeEval.evalAst(ast.callee, subs);
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
+
/* c8 ignore start */
|
|
1341
|
+
if (func === Function) {
|
|
1342
|
+
// unreachable since BLOCKED_PROTO_PROPERTIES includes 'constructor'
|
|
1343
|
+
throw new Error('Function constructor is disabled');
|
|
1344
|
+
}
|
|
1345
|
+
/* c8 ignore end */
|
|
1340
1346
|
return func(...args);
|
|
1341
1347
|
},
|
|
1342
1348
|
evalAssignmentExpression(ast, subs) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export default AbstractJoiningTransformer;
|
|
2
1
|
export type OutputCharacters = {
|
|
3
2
|
character: string;
|
|
4
3
|
string: string;
|
|
@@ -8,28 +7,20 @@ export type BaseTransformerConfig = {
|
|
|
8
7
|
JHTMLForJSON?: boolean;
|
|
9
8
|
mode?: "JSON" | "JavaScript";
|
|
10
9
|
};
|
|
11
|
-
/**
|
|
12
|
-
* When exposeDocuments is true, get() returns an array of XMLDocument
|
|
13
|
-
* objects (one per root element) instead of a DocumentFragment.
|
|
14
|
-
*/
|
|
15
10
|
export type DOMJoiningTransformerConfig = BaseTransformerConfig & {
|
|
16
11
|
document: Document;
|
|
17
12
|
exposeDocuments?: boolean;
|
|
18
13
|
};
|
|
19
14
|
export type JSONJoiningTransformerConfig = {
|
|
20
|
-
requireSameChildren?: boolean
|
|
21
|
-
unwrapSingleResult?: boolean
|
|
15
|
+
requireSameChildren?: boolean;
|
|
16
|
+
unwrapSingleResult?: boolean;
|
|
22
17
|
/**
|
|
23
18
|
* - When true, get() returns an array
|
|
24
19
|
* of document wrapper objects (one per root element) instead of the raw array.
|
|
25
20
|
*/
|
|
26
|
-
exposeDocuments?: boolean
|
|
27
|
-
mode?: "JSON" | "JavaScript"
|
|
21
|
+
exposeDocuments?: boolean;
|
|
22
|
+
mode?: "JSON" | "JavaScript";
|
|
28
23
|
};
|
|
29
|
-
/**
|
|
30
|
-
* When exposeDocuments is true, get() returns an array of document
|
|
31
|
-
* strings (one per root element) instead of a single concatenated string.
|
|
32
|
-
*/
|
|
33
24
|
export type StringJoiningTransformerConfig = BaseTransformerConfig & {
|
|
34
25
|
xmlElements?: boolean;
|
|
35
26
|
preEscapedAttributes?: boolean;
|
|
@@ -95,10 +86,6 @@ export type JoiningTransformerConfig<T> = T extends "string" ? StringJoiningTran
|
|
|
95
86
|
* @template T
|
|
96
87
|
*/
|
|
97
88
|
declare class AbstractJoiningTransformer<T> {
|
|
98
|
-
/**
|
|
99
|
-
* @param {JoiningTransformerConfig<T>} [cfg] - Configuration object
|
|
100
|
-
*/
|
|
101
|
-
constructor(cfg?: JoiningTransformerConfig<T>);
|
|
102
89
|
_cfg: JoiningTransformerConfig<T>;
|
|
103
90
|
/** @type {Record<string, OutputCharacters>} */
|
|
104
91
|
_characterMap: Record<string, OutputCharacters>;
|
|
@@ -167,6 +154,12 @@ declare class AbstractJoiningTransformer<T> {
|
|
|
167
154
|
sequence?: string;
|
|
168
155
|
returnType?: string;
|
|
169
156
|
}>;
|
|
157
|
+
_outputConfig: import("./StringJoiningTransformer.js").OutputConfig | undefined;
|
|
158
|
+
mediaType: string | undefined;
|
|
159
|
+
/**
|
|
160
|
+
* @param {JoiningTransformerConfig<T>} [cfg] - Configuration object
|
|
161
|
+
*/
|
|
162
|
+
constructor(cfg?: JoiningTransformerConfig<T>);
|
|
170
163
|
/**
|
|
171
164
|
* @param {JoiningTransformerConfig<T>} cfg - Configuration object
|
|
172
165
|
* @returns {void}
|
|
@@ -176,9 +169,7 @@ declare class AbstractJoiningTransformer<T> {
|
|
|
176
169
|
* @param {import('./StringJoiningTransformer.js').OutputConfig} cfg
|
|
177
170
|
* @returns {this}
|
|
178
171
|
*/
|
|
179
|
-
output(cfg: import(
|
|
180
|
-
_outputConfig: import("./StringJoiningTransformer.js").OutputConfig | undefined;
|
|
181
|
-
mediaType: string | undefined;
|
|
172
|
+
output(cfg: import('./StringJoiningTransformer.js').OutputConfig): this;
|
|
182
173
|
/**
|
|
183
174
|
* Configure mode behavior (similar to xsl:mode).
|
|
184
175
|
* @param {{
|
|
@@ -243,10 +234,10 @@ declare class AbstractJoiningTransformer<T> {
|
|
|
243
234
|
/**
|
|
244
235
|
* Invoke a registered stylesheet function with positional arguments.
|
|
245
236
|
* @param {string} name - Function name (with namespace)
|
|
246
|
-
* @param {
|
|
247
|
-
* @returns {
|
|
237
|
+
* @param {unknown[]} args - Positional arguments
|
|
238
|
+
* @returns {unknown} Function return value
|
|
248
239
|
*/
|
|
249
|
-
invokeFunctionByArity(name: string, args?:
|
|
240
|
+
invokeFunctionByArity(name: string, args?: unknown[]): unknown;
|
|
250
241
|
/**
|
|
251
242
|
* @param {string} name
|
|
252
243
|
* @param {OutputCharacters} outputCharacters
|
|
@@ -306,11 +297,12 @@ declare class AbstractJoiningTransformer<T> {
|
|
|
306
297
|
_requireSameChildren(type: string, embedType: string): void;
|
|
307
298
|
/**
|
|
308
299
|
* @param {string} prop - Configuration property name
|
|
309
|
-
* @param {
|
|
300
|
+
* @param {unknown} val - Configuration property value
|
|
310
301
|
* @param {(this: AbstractJoiningTransformer<T>) => void} [cb]
|
|
311
302
|
* Optional callback invoked with this instance
|
|
312
303
|
* @returns {void}
|
|
313
304
|
*/
|
|
314
|
-
config(prop: string, val:
|
|
305
|
+
config(prop: string, val: unknown, cb?: (this: AbstractJoiningTransformer<T>) => void): void;
|
|
315
306
|
}
|
|
307
|
+
export default AbstractJoiningTransformer;
|
|
316
308
|
//# sourceMappingURL=AbstractJoiningTransformer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractJoiningTransformer.d.ts","sourceRoot":"","sources":["../src/AbstractJoiningTransformer.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AbstractJoiningTransformer.d.ts","sourceRoot":"","sources":["../src/Ab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