jtlt 0.13.0 → 0.15.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/.c8rc.json +1 -0
- package/CHANGES.md +18 -0
- package/README.md +99 -85
- package/demo/calltemplate-params-demo.js +13 -22
- package/demo/codemirror.esm.js +50 -15
- 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/dist/AbstractJoiningTransformer.d.ts +5 -5
- package/dist/AbstractJoiningTransformer.d.ts.map +1 -1
- package/dist/JSONPathTransformer.d.ts +13 -12
- package/dist/JSONPathTransformer.d.ts.map +1 -1
- package/dist/JSONPathTransformerContext.d.ts +60 -20
- package/dist/JSONPathTransformerContext.d.ts.map +1 -1
- package/dist/XPathTransformer.d.ts +9 -2
- package/dist/XPathTransformer.d.ts.map +1 -1
- package/dist/XPathTransformerContext.d.ts +56 -9
- package/dist/XPathTransformerContext.d.ts.map +1 -1
- package/dist/context-extensions.d.ts +24 -0
- package/dist/extendContext.d.ts +10 -0
- package/dist/extendContext.d.ts.map +1 -0
- package/dist/index.d.ts +121 -13
- 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 +70 -20
- package/docs/API.md +34 -4
- package/docs/TO-DO.md +17 -3
- package/eslint.config.js +11 -3
- package/package.json +22 -15
- package/pnpm-workspace.yaml +9 -0
- package/src/AbstractJoiningTransformer.js +3 -3
- package/src/JSONPathTransformer.js +48 -8
- package/src/JSONPathTransformerContext.js +175 -25
- package/src/XPathTransformer.js +33 -1
- package/src/XPathTransformerContext.js +145 -16
- package/src/context-extensions.d.ts +24 -0
- package/src/extendContext.js +21 -0
- package/src/index.js +102 -11
- package/src/indexedDB.js +530 -0
- package/src/maybeAsync.js +44 -0
- package/tsconfig.json +2 -2
|
@@ -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);
|
|
@@ -234,10 +234,10 @@ declare class AbstractJoiningTransformer<T> {
|
|
|
234
234
|
/**
|
|
235
235
|
* Invoke a registered stylesheet function with positional arguments.
|
|
236
236
|
* @param {string} name - Function name (with namespace)
|
|
237
|
-
* @param {
|
|
238
|
-
* @returns {
|
|
237
|
+
* @param {unknown[]} args - Positional arguments
|
|
238
|
+
* @returns {unknown} Function return value
|
|
239
239
|
*/
|
|
240
|
-
invokeFunctionByArity(name: string, args?:
|
|
240
|
+
invokeFunctionByArity(name: string, args?: unknown[]): unknown;
|
|
241
241
|
/**
|
|
242
242
|
* @param {string} name
|
|
243
243
|
* @param {OutputCharacters} outputCharacters
|
|
@@ -297,12 +297,12 @@ declare class AbstractJoiningTransformer<T> {
|
|
|
297
297
|
_requireSameChildren(type: string, embedType: string): void;
|
|
298
298
|
/**
|
|
299
299
|
* @param {string} prop - Configuration property name
|
|
300
|
-
* @param {
|
|
300
|
+
* @param {unknown} val - Configuration property value
|
|
301
301
|
* @param {(this: AbstractJoiningTransformer<T>) => void} [cb]
|
|
302
302
|
* Optional callback invoked with this instance
|
|
303
303
|
* @returns {void}
|
|
304
304
|
*/
|
|
305
|
-
config(prop: string, val:
|
|
305
|
+
config(prop: string, val: unknown, cb?: (this: AbstractJoiningTransformer<T>) => void): void;
|
|
306
306
|
}
|
|
307
307
|
export default AbstractJoiningTransformer;
|
|
308
308
|
//# sourceMappingURL=AbstractJoiningTransformer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractJoiningTransformer.d.ts","sourceRoot":"","sources":["../src/AbstractJoiningTransformer.js"],"names":[],"mappings":"AAKG,YAAiD,gBAAgB,GAAvD;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,EAAE,CAAkB;AAIjE,YAIG,qBAAqB,GAJd;IACR,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,GAAC,YAAY,CAAA;CAC3B,CAAuB;AAIxB,YAGG,2BAA2B,GAHpB,qBAAqB,GAAG;IAChC,QAAQ,EAAE,QAAQ,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,CAGH;AAEE,YAAkB,4BAA4B,GAC9C;IAAqB,mBAAmB,AAAxC,CACA,EADW,OAAO,CAClB;IAAqB,kBAAkB,AAAvC,CACA,EADW,OAAO,CAClB;;;;;IAAqB,eAAe,AAApC,CAEA,EAFW,OAAO,CAElB;IAAiC,IAAI,AAArC,CAAsC,EAA3B,MAAM,GAAC,YAAY,CAAQ;CAAA,CAAA;AAGtC,YAIG,8BAA8B,GAJvB,qBAAqB,GAAG;IAChC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,eAAe,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9B,MAG8B,GAF5B,MAAM,CAyBlB;IAED;;;;;OAKG;IAEH,sBAAsB,CAAE,OAAO,EAJpB,MAIoB,GAHlB,IAAI,CAMhB;IAED;;;;OAIG;IACH,qBAAqB,CAAE,QAAQ,EAHpB,MAGoB,GAFlB,IAAI,CAWhB;IAED;;;OAGG;IACH,qBAAqB,CAAE,GAAG,EAHf,MAGe,GAFb,MAAM,CAclB;IAED;;;;OAIG;IACH,oBAAoB,CAAE,IAAI,EAJf,MAIe,EAAE,SAAS,EAH1B,MAG0B,GAFxB,IAAI,CAUhB;IAED;;;;;;OAMG;IACH,MAAM,CAAE,IAAI,EAND,MAMC,EAAE,GAAG,EALN,OAKM,EAAE,EAAE,AAJlB,CAEA,EAFQ,CAAC,IAAI,EAAE,0BAA0B,CAAC,CAAC,CAAC,KAAK,IAI/B,GAFR,IAAI,CAUhB;CACF;eAEc,0BAA0B"}
|
|
@@ -18,40 +18,40 @@ declare class JSONPathTransformer<T extends "json" | "string" | "dom" = "json">
|
|
|
18
18
|
/**
|
|
19
19
|
* @template {"json"|"string"|"dom"} U
|
|
20
20
|
* @this {JSONPathTransformerContext<U>}
|
|
21
|
-
* @param {
|
|
21
|
+
* @param {unknown} value - Value
|
|
22
22
|
* @param {{mode?: string}} cfg - Configuration
|
|
23
23
|
* @returns {void}
|
|
24
24
|
*/
|
|
25
|
-
template<U extends "json" | "string" | "dom">(this: JSONPathTransformerContext<U>, value:
|
|
25
|
+
template<U extends "json" | "string" | "dom">(this: JSONPathTransformerContext<U>, value: unknown, cfg: {
|
|
26
26
|
mode?: string;
|
|
27
27
|
}): void;
|
|
28
28
|
};
|
|
29
29
|
transformPropertyNames: {
|
|
30
30
|
/**
|
|
31
|
-
* @param {
|
|
32
|
-
* @returns {
|
|
31
|
+
* @param {unknown} value - Current context value
|
|
32
|
+
* @returns {unknown}
|
|
33
33
|
*/
|
|
34
|
-
template(value:
|
|
34
|
+
template(value: unknown): unknown;
|
|
35
35
|
};
|
|
36
36
|
transformObjects: {
|
|
37
37
|
/**
|
|
38
38
|
* @this {JSONPathTransformerContext}
|
|
39
|
-
* @param {
|
|
39
|
+
* @param {unknown} value - Value
|
|
40
40
|
* @param {{mode?: string}} cfg - Configuration
|
|
41
41
|
* @returns {void}
|
|
42
42
|
*/
|
|
43
|
-
template(this: JSONPathTransformerContext, value:
|
|
43
|
+
template(this: JSONPathTransformerContext, value: unknown, cfg: {
|
|
44
44
|
mode?: string;
|
|
45
45
|
}): void;
|
|
46
46
|
};
|
|
47
47
|
transformArrays: {
|
|
48
48
|
/**
|
|
49
49
|
* @this {JSONPathTransformerContext}
|
|
50
|
-
* @param {
|
|
50
|
+
* @param {unknown} value - Value
|
|
51
51
|
* @param {{mode?: string}} cfg - Configuration
|
|
52
52
|
* @returns {void}
|
|
53
53
|
*/
|
|
54
|
-
template(this: JSONPathTransformerContext, value:
|
|
54
|
+
template(this: JSONPathTransformerContext, value: unknown, cfg: {
|
|
55
55
|
mode?: string;
|
|
56
56
|
}): void;
|
|
57
57
|
};
|
|
@@ -64,10 +64,11 @@ declare class JSONPathTransformer<T extends "json" | "string" | "dom" = "json">
|
|
|
64
64
|
};
|
|
65
65
|
transformFunctions: {
|
|
66
66
|
/**
|
|
67
|
-
* @param {(
|
|
68
|
-
*
|
|
67
|
+
* @param {(...args: unknown[]) => unknown} value - Function at current
|
|
68
|
+
* context
|
|
69
|
+
* @returns {unknown}
|
|
69
70
|
*/
|
|
70
|
-
template(value: (...args:
|
|
71
|
+
template(value: (...args: unknown[]) => unknown): unknown;
|
|
71
72
|
};
|
|
72
73
|
};
|
|
73
74
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JSONPathTransformer.d.ts","sourceRoot":"","sources":["../src/JSONPathTransformer.js"],"names":[],"mappings":"AAAA,OAAO,0BAA0B,MAAM,iCAAiC,CAAC;AAEzE;;;;;;;;GAQG;AACH,cAAM,mBAAmB,CAFa,CAAC,SAAzB,MAAM,GAAC,QAAQ,GAAC,K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,iCAAiC,EAC9C,gCAAgC,CAAC,CAAC,CAEpB,EAoClB;IAED;;OAEG;IACH,0BAA0B,IAFb,IAAI,CAShB;IAED;;;OAGG;IACH,SAAS,CAAE,IAAI,AAHZ,CACA,EADQ,MAGI,GAFF,OAAO,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC,CAwE9C;CACF;eAEc,mBAAmB"}
|
|
@@ -59,7 +59,7 @@ export type SortObject<V = unknown> = {
|
|
|
59
59
|
localeOptions?: unknown;
|
|
60
60
|
};
|
|
61
61
|
export type SortComparator<V = unknown> = (a: V, b: V, ctx: JSONPathTransformerContext) => number;
|
|
62
|
-
export type SortSpec<V = unknown> = string | SortObject | SortComparator | Array<string | SortObject
|
|
62
|
+
export type SortSpec<V = unknown> = string | SortObject | SortComparator | Array<string | SortObject> | null;
|
|
63
63
|
export type JoiningTransformerMap = {
|
|
64
64
|
json: import('./JSONJoiningTransformer.js').default;
|
|
65
65
|
string: import('./StringJoiningTransformer.js').default;
|
|
@@ -106,11 +106,21 @@ export type JSONPathTransformerContextConfig<T extends "json" | "string" | "dom"
|
|
|
106
106
|
* JSONPath
|
|
107
107
|
*/
|
|
108
108
|
preventEval?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* - When true, throw if a template returns a
|
|
111
|
+
* Promise instead of awaiting it (disables `indexedDB()`)
|
|
112
|
+
*/
|
|
113
|
+
sync?: boolean;
|
|
109
114
|
/**
|
|
110
115
|
* Priority resolver function
|
|
111
116
|
*/
|
|
112
117
|
specificityPriorityResolver?: (path: string) => number;
|
|
113
118
|
templates?: import('./index.js').JSONPathTemplateObject<T>[] | import('./index.js').JSONPathTemplateArray<T>[];
|
|
119
|
+
/**
|
|
120
|
+
* Extra methods/values
|
|
121
|
+
* merged onto this context so templates can call `this.myHelper()`
|
|
122
|
+
*/
|
|
123
|
+
extensions?: Record<string, unknown> & ThisType<import('./JSONPathTransformerContext.js').default<T> & import('./context-extensions.js').ContextExtensions>;
|
|
114
124
|
};
|
|
115
125
|
/**
|
|
116
126
|
* Decimal format symbols for number formatting.
|
|
@@ -153,7 +163,7 @@ export type JSONPathTransformerContextConfig<T extends "json" | "string" | "dom"
|
|
|
153
163
|
* ctx: JSONPathTransformerContext
|
|
154
164
|
* ) => number} SortComparator
|
|
155
165
|
* @typedef {string | SortObject | SortComparator |
|
|
156
|
-
* Array<string|SortObject>} SortSpec
|
|
166
|
+
* Array<string|SortObject> | null} SortSpec
|
|
157
167
|
*/
|
|
158
168
|
/**
|
|
159
169
|
* @typedef {object} JoiningTransformerMap
|
|
@@ -185,10 +195,17 @@ export type JSONPathTransformerContextConfig<T extends "json" | "string" | "dom"
|
|
|
185
195
|
* @property {JoiningTransformerMap[T]} joiningTransformer - Joining transformer
|
|
186
196
|
* @property {boolean} [preventEval] - Whether to prevent eval in
|
|
187
197
|
* JSONPath
|
|
198
|
+
* @property {boolean} [sync] - When true, throw if a template returns a
|
|
199
|
+
* Promise instead of awaiting it (disables `indexedDB()`)
|
|
188
200
|
* @property {(path: string) => number} [specificityPriorityResolver]
|
|
189
201
|
* Priority resolver function
|
|
190
202
|
* @property {import('./index.js').JSONPathTemplateObject<T>[]|
|
|
191
203
|
* import('./index.js').JSONPathTemplateArray<T>[]} [templates]
|
|
204
|
+
* @property {Record<string, unknown> & ThisType<
|
|
205
|
+
* import('./JSONPathTransformerContext.js').default<T> &
|
|
206
|
+
* import('./context-extensions.js').ContextExtensions
|
|
207
|
+
* >} [extensions] Extra methods/values
|
|
208
|
+
* merged onto this context so templates can call `this.myHelper()`
|
|
192
209
|
*/
|
|
193
210
|
/**
|
|
194
211
|
* Execution context for JSONPath-driven template application.
|
|
@@ -264,9 +281,9 @@ declare class JSONPathTransformerContext<T extends "json" | "string" | "dom" = "
|
|
|
264
281
|
appendOutput(item: AppendItemMap[T]): this;
|
|
265
282
|
/**
|
|
266
283
|
* Gets the current output.
|
|
267
|
-
* @returns {
|
|
284
|
+
* @returns {unknown} The output from the joining transformer
|
|
268
285
|
*/
|
|
269
|
-
getOutput():
|
|
286
|
+
getOutput(): unknown;
|
|
270
287
|
/**
|
|
271
288
|
* Get() and set() are provided as a convenience method for templates, but
|
|
272
289
|
* it should typically not be used (use valueOf or the copy methods to add
|
|
@@ -277,10 +294,10 @@ declare class JSONPathTransformerContext<T extends "json" | "string" | "dom" = "
|
|
|
277
294
|
*/
|
|
278
295
|
get(select: string, wrap: boolean): any;
|
|
279
296
|
/**
|
|
280
|
-
* @param {
|
|
297
|
+
* @param {unknown} v - Value to set
|
|
281
298
|
* @returns {this}
|
|
282
299
|
*/
|
|
283
|
-
set(v:
|
|
300
|
+
set(v: unknown): this;
|
|
284
301
|
/**
|
|
285
302
|
* Apply matching templates to nodes selected by JSONPath, optionally sorted.
|
|
286
303
|
*
|
|
@@ -337,9 +354,12 @@ declare class JSONPathTransformerContext<T extends "json" | "string" | "dom" = "
|
|
|
337
354
|
* expression matches
|
|
338
355
|
* @param {string} [options.groupEndingWith] - Ends group when expression
|
|
339
356
|
* matches
|
|
340
|
-
* @param {
|
|
357
|
+
* @param {SortSpec<V>} [options.sort] - Sort specification (same as forEach)
|
|
341
358
|
* @param {(
|
|
342
|
-
* this: JSONPathTransformerContext<T>,
|
|
359
|
+
* this: JSONPathTransformerContext<T>,
|
|
360
|
+
* key: unknown,
|
|
361
|
+
* items: unknown[],
|
|
362
|
+
* ctx: JSONPathTransformerContext<T>
|
|
343
363
|
* ) => void} cb - Callback receives (groupingKey, groupItems, context)
|
|
344
364
|
* @returns {this}
|
|
345
365
|
*/
|
|
@@ -348,8 +368,8 @@ declare class JSONPathTransformerContext<T extends "json" | "string" | "dom" = "
|
|
|
348
368
|
groupAdjacent?: string;
|
|
349
369
|
groupStartingWith?: string;
|
|
350
370
|
groupEndingWith?: string;
|
|
351
|
-
sort?:
|
|
352
|
-
}, cb: (this: JSONPathTransformerContext<T>, key:
|
|
371
|
+
sort?: SortSpec<V>;
|
|
372
|
+
}, cb: (this: JSONPathTransformerContext<T>, key: unknown, items: unknown[], ctx: JSONPathTransformerContext<T>) => void): this;
|
|
353
373
|
/**
|
|
354
374
|
* Helper to build comparator for sorting.
|
|
355
375
|
* @param {any} sortSpec
|
|
@@ -360,14 +380,34 @@ declare class JSONPathTransformerContext<T extends "json" | "string" | "dom" = "
|
|
|
360
380
|
private _buildComparator;
|
|
361
381
|
/**
|
|
362
382
|
* Returns the current group (for use within forEachGroup callback).
|
|
363
|
-
* @returns {
|
|
383
|
+
* @returns {unknown[]|undefined}
|
|
364
384
|
*/
|
|
365
|
-
currentGroup():
|
|
385
|
+
currentGroup(): unknown[] | undefined;
|
|
366
386
|
/**
|
|
367
387
|
* Returns the current grouping key (for use within forEachGroup callback).
|
|
368
|
-
* @returns {
|
|
388
|
+
* @returns {unknown}
|
|
389
|
+
*/
|
|
390
|
+
currentGroupingKey(): unknown;
|
|
391
|
+
/**
|
|
392
|
+
* Directly query IndexedDB from within a template, e.g.
|
|
393
|
+
* `await this.indexedDB('myDB', 'myStore', {index: 'byAge'})`.
|
|
394
|
+
*
|
|
395
|
+
* Since IndexedDB access is asynchronous, this is unavailable when JTLT is
|
|
396
|
+
* configured with `sync: true`.
|
|
397
|
+
* @param {string} dbName - Database name
|
|
398
|
+
* @param {string} storeName - Object store name
|
|
399
|
+
* @param {import('./indexedDB.js').QueryOptions} [options] - Query options
|
|
400
|
+
* @returns {Promise<unknown[]>} The matching records
|
|
401
|
+
*/
|
|
402
|
+
indexedDB(dbName: string, storeName: string, options?: import('./indexedDB.js').QueryOptions): Promise<unknown[]>;
|
|
403
|
+
/**
|
|
404
|
+
* Await a parsed `indexedDB(...)` expression and append its (stringified)
|
|
405
|
+
* value to the output. Used by {@link valueOf}. Callers reject `config.sync`.
|
|
406
|
+
* @param {import('./indexedDB.js').ParsedIndexedDBExpression} parsed
|
|
407
|
+
* @param {any} results - The joining transformer
|
|
408
|
+
* @returns {Promise<this>}
|
|
369
409
|
*/
|
|
370
|
-
|
|
410
|
+
_appendIndexedDBValue(parsed: import('./indexedDB.js').ParsedIndexedDBExpression, results: any): Promise<this>;
|
|
371
411
|
/**
|
|
372
412
|
* @param {string|object} [select] - JSONPath selector
|
|
373
413
|
* @returns {this}
|
|
@@ -615,10 +655,10 @@ declare class JSONPathTransformerContext<T extends "json" | "string" | "dom" = "
|
|
|
615
655
|
/**
|
|
616
656
|
* Invoke a registered stylesheet function with positional arguments.
|
|
617
657
|
* @param {string} name - Function name (with namespace)
|
|
618
|
-
* @param {
|
|
619
|
-
* @returns {
|
|
658
|
+
* @param {unknown[]} args - Positional arguments
|
|
659
|
+
* @returns {unknown} Function return value
|
|
620
660
|
*/
|
|
621
|
-
invokeFunctionByArity(name: string, args?:
|
|
661
|
+
invokeFunctionByArity(name: string, args?: unknown[]): unknown;
|
|
622
662
|
/**
|
|
623
663
|
* Create an element. Mirrors the joining transformer API so templates can
|
|
624
664
|
* call `this.element()`.
|
|
@@ -702,10 +742,10 @@ declare class JSONPathTransformerContext<T extends "json" | "string" | "dom" = "
|
|
|
702
742
|
_usePropertySets(obj: Record<string, unknown>, name: string): Record<string, unknown>;
|
|
703
743
|
/**
|
|
704
744
|
* @param {string} name - Key name
|
|
705
|
-
* @param {
|
|
706
|
-
* @returns {
|
|
745
|
+
* @param {unknown} value - Value to match
|
|
746
|
+
* @returns {unknown}
|
|
707
747
|
*/
|
|
708
|
-
getKey(name: string, value:
|
|
748
|
+
getKey(name: string, value: unknown): unknown;
|
|
709
749
|
/**
|
|
710
750
|
* @param {string} name - Key name
|
|
711
751
|
* @param {string} match - Match expression
|