@stryke/json 0.9.26 → 0.9.28
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/CHANGELOG.md +14 -0
- package/dist/_virtual/rolldown_runtime.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.mts +8 -8
- package/dist/index.mjs +1 -1
- package/dist/pointer/find-reference.cjs +1 -1
- package/dist/pointer/find-reference.d.cts +52 -2
- package/dist/pointer/find-reference.d.cts.map +1 -0
- package/dist/pointer/find-reference.d.mts +52 -2
- package/dist/pointer/find-reference.d.mts.map +1 -0
- package/dist/pointer/find-reference.mjs +2 -1
- package/dist/pointer/find-reference.mjs.map +1 -0
- package/dist/pointer/index.cjs +1 -1
- package/dist/pointer/index.d.cts +2 -2
- package/dist/pointer/index.d.mts +2 -2
- package/dist/pointer/index.mjs +1 -1
- package/dist/pointer/parse.cjs +1 -1
- package/dist/pointer/parse.d.cts +44 -2
- package/dist/pointer/parse.d.cts.map +1 -0
- package/dist/pointer/parse.d.mts +44 -2
- package/dist/pointer/parse.d.mts.map +1 -0
- package/dist/pointer/parse.mjs +2 -1
- package/dist/pointer/parse.mjs.map +1 -0
- package/dist/storm-json.cjs +1 -1
- package/dist/storm-json.d.cts +70 -2
- package/dist/storm-json.d.cts.map +1 -0
- package/dist/storm-json.d.mts +70 -3
- package/dist/storm-json.d.mts.map +1 -0
- package/dist/storm-json.mjs +2 -1
- package/dist/storm-json.mjs.map +1 -0
- package/dist/type-checks/src/get-object-tag.cjs +1 -0
- package/dist/type-checks/src/get-object-tag.mjs +2 -0
- package/dist/type-checks/src/get-object-tag.mjs.map +1 -0
- package/dist/type-checks/src/is-empty.cjs +1 -0
- package/dist/type-checks/src/is-empty.mjs +2 -0
- package/dist/type-checks/src/is-empty.mjs.map +1 -0
- package/dist/type-checks/src/is-non-null-object.cjs +1 -0
- package/dist/type-checks/src/is-non-null-object.mjs +2 -0
- package/dist/type-checks/src/is-non-null-object.mjs.map +1 -0
- package/dist/type-checks/src/is-null.cjs +1 -0
- package/dist/type-checks/src/is-null.mjs +2 -0
- package/dist/type-checks/src/is-null.mjs.map +1 -0
- package/dist/type-checks/src/is-number.cjs +1 -0
- package/dist/type-checks/src/is-number.mjs +2 -0
- package/dist/type-checks/src/is-number.mjs.map +1 -0
- package/dist/type-checks/src/is-object.cjs +1 -0
- package/dist/type-checks/src/is-object.mjs +2 -0
- package/dist/type-checks/src/is-object.mjs.map +1 -0
- package/dist/type-checks/src/is-plain-object.cjs +1 -0
- package/dist/type-checks/src/is-plain-object.mjs +2 -0
- package/dist/type-checks/src/is-plain-object.mjs.map +1 -0
- package/dist/type-checks/src/is-set-object.cjs +1 -0
- package/dist/type-checks/src/is-set-object.mjs +2 -0
- package/dist/type-checks/src/is-set-object.mjs.map +1 -0
- package/dist/type-checks/src/is-set.cjs +1 -0
- package/dist/type-checks/src/is-set.mjs +2 -0
- package/dist/type-checks/src/is-set.mjs.map +1 -0
- package/dist/{is-string-VB7nGKjX.mjs → type-checks/src/is-string.cjs} +1 -2
- package/dist/type-checks/src/is-string.mjs +2 -0
- package/dist/type-checks/src/is-string.mjs.map +1 -0
- package/dist/type-checks/src/is-undefined.cjs +1 -0
- package/dist/type-checks/src/is-undefined.mjs +2 -0
- package/dist/type-checks/src/is-undefined.mjs.map +1 -0
- package/dist/types/src/base.cjs +1 -0
- package/dist/types/src/base.mjs +2 -0
- package/dist/types/src/base.mjs.map +1 -0
- package/dist/types/src/json.d.cts +12 -0
- package/dist/types/src/json.d.cts.map +1 -0
- package/dist/types/src/json.d.mts +12 -0
- package/dist/types/src/json.d.mts.map +1 -0
- package/dist/types.d.cts +69 -2
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +69 -2
- package/dist/types.d.mts.map +1 -0
- package/dist/utils/code-frames.cjs +3 -1
- package/dist/utils/code-frames.d.cts +17 -2
- package/dist/utils/code-frames.d.cts.map +1 -0
- package/dist/utils/code-frames.d.mts +17 -2
- package/dist/utils/code-frames.d.mts.map +1 -0
- package/dist/utils/code-frames.mjs +4 -1
- package/dist/utils/code-frames.mjs.map +1 -0
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.d.cts +5 -5
- package/dist/utils/index.d.mts +5 -6
- package/dist/utils/index.mjs +1 -1
- package/dist/utils/parse-error.cjs +1 -1
- package/dist/utils/parse-error.d.cts +15 -2
- package/dist/utils/parse-error.d.cts.map +1 -0
- package/dist/utils/parse-error.d.mts +15 -2
- package/dist/utils/parse-error.d.mts.map +1 -0
- package/dist/utils/parse-error.mjs +2 -1
- package/dist/utils/parse-error.mjs.map +1 -0
- package/dist/utils/parse.cjs +1 -1
- package/dist/utils/parse.d.cts +9 -2
- package/dist/utils/parse.d.cts.map +1 -0
- package/dist/utils/parse.d.mts +9 -2
- package/dist/utils/parse.d.mts.map +1 -0
- package/dist/utils/parse.mjs +2 -1
- package/dist/utils/parse.mjs.map +1 -0
- package/dist/utils/stringify.cjs +1 -1
- package/dist/utils/stringify.d.cts +13 -2
- package/dist/utils/stringify.d.cts.map +1 -0
- package/dist/utils/stringify.d.mts +13 -2
- package/dist/utils/stringify.d.mts.map +1 -0
- package/dist/utils/stringify.mjs +2 -1
- package/dist/utils/stringify.mjs.map +1 -0
- package/dist/utils/strip-comments.cjs +4 -1
- package/dist/utils/strip-comments.d.cts +11 -2
- package/dist/utils/strip-comments.d.cts.map +1 -0
- package/dist/utils/strip-comments.d.mts +11 -2
- package/dist/utils/strip-comments.d.mts.map +1 -0
- package/dist/utils/strip-comments.mjs +5 -1
- package/dist/utils/strip-comments.mjs.map +1 -0
- package/package.json +3 -3
- package/dist/code-frames-BQI7PKd_.mjs +0 -4
- package/dist/code-frames-BQI7PKd_.mjs.map +0 -1
- package/dist/code-frames-CXX37tnR.d.mts +0 -17
- package/dist/code-frames-CXX37tnR.d.mts.map +0 -1
- package/dist/code-frames-DEWi5iIn.cjs +0 -3
- package/dist/code-frames-DViwqU8S.d.cts +0 -17
- package/dist/code-frames-DViwqU8S.d.cts.map +0 -1
- package/dist/find-reference-AvNORSzC.d.mts +0 -52
- package/dist/find-reference-AvNORSzC.d.mts.map +0 -1
- package/dist/find-reference-BUIYIOS4.mjs +0 -2
- package/dist/find-reference-BUIYIOS4.mjs.map +0 -1
- package/dist/find-reference-ChoPoDcB.d.cts +0 -52
- package/dist/find-reference-ChoPoDcB.d.cts.map +0 -1
- package/dist/find-reference-DQJK1LbJ.cjs +0 -1
- package/dist/index-CMuRFTR3.d.mts +0 -1
- package/dist/index-uTS5iDq_.d.cts +0 -1
- package/dist/is-number-CebQk_B0.mjs +0 -2
- package/dist/is-number-CebQk_B0.mjs.map +0 -1
- package/dist/is-number-wfNPC3Mj.cjs +0 -1
- package/dist/is-object-CGB7EeiA.cjs +0 -1
- package/dist/is-object-DDPbtSWR.mjs +0 -2
- package/dist/is-object-DDPbtSWR.mjs.map +0 -1
- package/dist/is-string-D5yKZC0U.cjs +0 -1
- package/dist/is-string-VB7nGKjX.mjs.map +0 -1
- package/dist/is-undefined-D6sfLkFq.mjs +0 -2
- package/dist/is-undefined-D6sfLkFq.mjs.map +0 -1
- package/dist/is-undefined-Pevixi0g.cjs +0 -1
- package/dist/parse-BYhuR8fo.mjs +0 -2
- package/dist/parse-BYhuR8fo.mjs.map +0 -1
- package/dist/parse-BpylFCf0.mjs +0 -2
- package/dist/parse-BpylFCf0.mjs.map +0 -1
- package/dist/parse-BwhwGAkA.cjs +0 -1
- package/dist/parse-D-7TqXVh.d.mts +0 -51
- package/dist/parse-D-7TqXVh.d.mts.map +0 -1
- package/dist/parse-DU-kIQN6.d.cts +0 -51
- package/dist/parse-DU-kIQN6.d.cts.map +0 -1
- package/dist/parse-DmriuGKI.cjs +0 -1
- package/dist/parse-error-0BAtatMf.cjs +0 -1
- package/dist/parse-error-CJTV0jdn.d.mts +0 -15
- package/dist/parse-error-CJTV0jdn.d.mts.map +0 -1
- package/dist/parse-error-DLuqEXmf.d.cts +0 -15
- package/dist/parse-error-DLuqEXmf.d.cts.map +0 -1
- package/dist/parse-error-DrJJkemH.mjs +0 -2
- package/dist/parse-error-DrJJkemH.mjs.map +0 -1
- package/dist/parse-fX7NFKdt.d.cts +0 -9
- package/dist/parse-fX7NFKdt.d.cts.map +0 -1
- package/dist/parse-xFkFesIF.d.mts +0 -9
- package/dist/parse-xFkFesIF.d.mts.map +0 -1
- package/dist/storm-json-BsdLpzM_.mjs +0 -2
- package/dist/storm-json-BsdLpzM_.mjs.map +0 -1
- package/dist/storm-json-CfqJ0KzG.d.mts +0 -70
- package/dist/storm-json-CfqJ0KzG.d.mts.map +0 -1
- package/dist/storm-json-DBxiMujR.cjs +0 -1
- package/dist/storm-json-Q1bOIv3-.d.cts +0 -70
- package/dist/storm-json-Q1bOIv3-.d.cts.map +0 -1
- package/dist/stringify-BpBMOhle.d.cts +0 -13
- package/dist/stringify-BpBMOhle.d.cts.map +0 -1
- package/dist/stringify-DjBDt8SC.mjs +0 -2
- package/dist/stringify-DjBDt8SC.mjs.map +0 -1
- package/dist/stringify-Dp0lF-wN.cjs +0 -1
- package/dist/stringify-ln223ZC9.d.mts +0 -13
- package/dist/stringify-ln223ZC9.d.mts.map +0 -1
- package/dist/strip-comments-BhdK_E8s.cjs +0 -4
- package/dist/strip-comments-CKLSXchM.d.cts +0 -11
- package/dist/strip-comments-CKLSXchM.d.cts.map +0 -1
- package/dist/strip-comments-DdsCzji6.d.mts +0 -11
- package/dist/strip-comments-DdsCzji6.d.mts.map +0 -1
- package/dist/strip-comments-LcqiBhvo.mjs +0 -5
- package/dist/strip-comments-LcqiBhvo.mjs.map +0 -1
- package/dist/types-CEiKQHlk.d.cts +0 -69
- package/dist/types-CEiKQHlk.d.cts.map +0 -1
- package/dist/types-CQHq94S4.d.mts +0 -69
- package/dist/types-CQHq94S4.d.mts.map +0 -1
- package/dist/utils-BkLHzBxb.mjs +0 -1
- package/dist/utils-DFU9Wltn.cjs +0 -0
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
//#region ../types/src/json.d.ts
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Matches a JSON pointer's path segments.
|
|
5
|
-
*
|
|
6
|
-
* @remarks
|
|
7
|
-
* These segments are used to navigate through the JSON object structure and point to a specific, referenced value.
|
|
8
|
-
*/
|
|
9
|
-
type JsonPointerPath = (string | number)[];
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/pointer/parse.d.ts
|
|
12
|
-
/**
|
|
13
|
-
* Escapes a JSON pointer path segment.
|
|
14
|
-
*
|
|
15
|
-
* @param segment - JSON pointer path segment.
|
|
16
|
-
* @returns Escaped JSON pointer path segment.
|
|
17
|
-
*/
|
|
18
|
-
declare function escapePointerSegment(segment: string): string;
|
|
19
|
-
/**
|
|
20
|
-
* Unescapes a JSON pointer path segment.
|
|
21
|
-
*
|
|
22
|
-
* @param segment - JSON pointer path segment.
|
|
23
|
-
* @returns Unescaped JSON pointer path segment.
|
|
24
|
-
*/
|
|
25
|
-
declare function unescapePointerSegment(segment: string): string;
|
|
26
|
-
/**
|
|
27
|
-
* Convert JSON pointer like "/foo/bar" to array like ["", "foo", "bar"], while
|
|
28
|
-
* also un-escaping reserved characters.
|
|
29
|
-
*/
|
|
30
|
-
declare function parseJsonPointer(pointer: string): JsonPointerPath;
|
|
31
|
-
/**
|
|
32
|
-
* Escape and format a path array like ["", "foo", "bar"] to JSON pointer
|
|
33
|
-
* like "/foo/bar".
|
|
34
|
-
*/
|
|
35
|
-
declare function formatJsonPointer(path: JsonPointerPath): string;
|
|
36
|
-
/**
|
|
37
|
-
* Returns true if JSON Pointer points to root value, false otherwise.
|
|
38
|
-
*/
|
|
39
|
-
declare const isRoot: (path: string | number | JsonPointerPath) => boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Returns parent path, e.g. for ['foo', 'bar', 'baz'] returns ['foo', 'bar'].
|
|
42
|
-
*/
|
|
43
|
-
declare function parent(path: JsonPointerPath): JsonPointerPath;
|
|
44
|
-
/**
|
|
45
|
-
* Check if path component can be a valid array index.
|
|
46
|
-
*/
|
|
47
|
-
declare function isValidIndex(index: string | number): boolean;
|
|
48
|
-
declare const isInteger: (str: string) => boolean;
|
|
49
|
-
//#endregion
|
|
50
|
-
export { isValidIndex as a, unescapePointerSegment as c, isRoot as i, formatJsonPointer as n, parent as o, isInteger as r, parseJsonPointer as s, escapePointerSegment as t };
|
|
51
|
-
//# sourceMappingURL=parse-D-7TqXVh.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-D-7TqXVh.d.mts","names":[],"sources":["../../types/src/json.ts","../src/pointer/parse.ts"],"sourcesContent":[],"mappings":";;;;;;;;KA6CY,eAAA;;;AAAZ;;;;ACZA;AAcA;AAYgB,iBA1BA,oBAAA,CA0BmC,OAAe,EAAA,MAAA,CAAA,EAAA,MAAA;AAalE;AAYA;AAUA;AAWA;AAUA;;iBApEgB,sBAAA;;;;;iBAYA,gBAAA,mBAAmC;;;;;iBAanC,iBAAA,OAAwB;;;;cAY3B,iCAAkC;;;;iBAU/B,MAAA,OAAa,kBAAkB;;;;iBAW/B,YAAA;cAUH"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
//#region ../types/src/json.d.ts
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Matches a JSON pointer's path segments.
|
|
5
|
-
*
|
|
6
|
-
* @remarks
|
|
7
|
-
* These segments are used to navigate through the JSON object structure and point to a specific, referenced value.
|
|
8
|
-
*/
|
|
9
|
-
type JsonPointerPath = (string | number)[];
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/pointer/parse.d.ts
|
|
12
|
-
/**
|
|
13
|
-
* Escapes a JSON pointer path segment.
|
|
14
|
-
*
|
|
15
|
-
* @param segment - JSON pointer path segment.
|
|
16
|
-
* @returns Escaped JSON pointer path segment.
|
|
17
|
-
*/
|
|
18
|
-
declare function escapePointerSegment(segment: string): string;
|
|
19
|
-
/**
|
|
20
|
-
* Unescapes a JSON pointer path segment.
|
|
21
|
-
*
|
|
22
|
-
* @param segment - JSON pointer path segment.
|
|
23
|
-
* @returns Unescaped JSON pointer path segment.
|
|
24
|
-
*/
|
|
25
|
-
declare function unescapePointerSegment(segment: string): string;
|
|
26
|
-
/**
|
|
27
|
-
* Convert JSON pointer like "/foo/bar" to array like ["", "foo", "bar"], while
|
|
28
|
-
* also un-escaping reserved characters.
|
|
29
|
-
*/
|
|
30
|
-
declare function parseJsonPointer(pointer: string): JsonPointerPath;
|
|
31
|
-
/**
|
|
32
|
-
* Escape and format a path array like ["", "foo", "bar"] to JSON pointer
|
|
33
|
-
* like "/foo/bar".
|
|
34
|
-
*/
|
|
35
|
-
declare function formatJsonPointer(path: JsonPointerPath): string;
|
|
36
|
-
/**
|
|
37
|
-
* Returns true if JSON Pointer points to root value, false otherwise.
|
|
38
|
-
*/
|
|
39
|
-
declare const isRoot: (path: string | number | JsonPointerPath) => boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Returns parent path, e.g. for ['foo', 'bar', 'baz'] returns ['foo', 'bar'].
|
|
42
|
-
*/
|
|
43
|
-
declare function parent(path: JsonPointerPath): JsonPointerPath;
|
|
44
|
-
/**
|
|
45
|
-
* Check if path component can be a valid array index.
|
|
46
|
-
*/
|
|
47
|
-
declare function isValidIndex(index: string | number): boolean;
|
|
48
|
-
declare const isInteger: (str: string) => boolean;
|
|
49
|
-
//#endregion
|
|
50
|
-
export { isValidIndex as a, unescapePointerSegment as c, isRoot as i, formatJsonPointer as n, parent as o, isInteger as r, parseJsonPointer as s, escapePointerSegment as t };
|
|
51
|
-
//# sourceMappingURL=parse-DU-kIQN6.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-DU-kIQN6.d.cts","names":[],"sources":["../../types/src/json.ts","../src/pointer/parse.ts"],"sourcesContent":[],"mappings":";;;;;;;;KA6CY,eAAA;;;AAAZ;;;;ACZA;AAcA;AAYgB,iBA1BA,oBAAA,CA0BmC,OAAe,EAAA,MAAA,CAAA,EAAA,MAAA;AAalE;AAYA;AAUA;AAWA;AAUA;;iBApEgB,sBAAA;;;;;iBAYA,gBAAA,mBAAmC;;;;;iBAanC,iBAAA,OAAwB;;;;cAY3B,iCAAkC;;;;iBAU/B,MAAA,OAAa,kBAAkB;;;;iBAW/B,YAAA;cAUH"}
|
package/dist/parse-DmriuGKI.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require(`./strip-comments-BhdK_E8s.cjs`),t=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,n=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,r=/^\s*["[{]|^\s*-?\d{1,16}(?:\.\d{1,17})?(?:E[+-]?\d+)?\s*$/i;function i(e,t){if(e===`__proto__`||e===`constructor`&&t&&typeof t==`object`&&`prototype`in t){console.warn(`Dropping "${e}" key to prevent prototype pollution.`);return}return t}function a(a,o={}){if(typeof a!=`string`)return a;let s=e.t(a);if(s[0]===`"`&&s[s.length-1]===`"`&&!s.includes(`\\`))return s.slice(1,-1);if(s=s.trim(),s.length<=9)switch(s.toLowerCase()){case`true`:return!0;case`false`:return!1;case`undefined`:return;case`null`:return null;case`nan`:return NaN;case`infinity`:return 1/0;case`-infinity`:return-1/0}if(!r.test(s)){if(o.strict)throw Error(`Invalid JSON`);return s}try{if(t.test(s)||n.test(s)){if(o.strict)throw Error(`Possible prototype pollution`);return JSON.parse(s,i)}return JSON.parse(s)}catch(e){if(o.strict)throw e;return a}}function o(e,t={}){return a(e,{...t,strict:!0})}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return a}});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require(`./storm-json-DBxiMujR.cjs`),t=require(`./code-frames-DEWi5iIn.cjs`);let n=require(`jsonc-parser`),r=require(`lines-and-columns`);function i(e,i){let{error:a,offset:o,length:s}=i,c=new r.LinesAndColumns(e).locationForIndex(o),l=c?.line??0,u=c?.column??0;return l++,u++,`${(0,n.printParseErrorCode)(a)} in JSON at ${l}:${u}\n${t.t(e,{start:{line:l,column:u},end:{line:l,column:u+s}})}\n`}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return i}});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ParseError } from "jsonc-parser";
|
|
2
|
-
|
|
3
|
-
//#region src/utils/parse-error.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Nicely formats a JSON error with context
|
|
7
|
-
*
|
|
8
|
-
* @param input - JSON content as string
|
|
9
|
-
* @param parseError - jsonc ParseError
|
|
10
|
-
* @returns
|
|
11
|
-
*/
|
|
12
|
-
declare function formatParseError(input: string, parseError: ParseError): string;
|
|
13
|
-
//#endregion
|
|
14
|
-
export { formatParseError as t };
|
|
15
|
-
//# sourceMappingURL=parse-error-CJTV0jdn.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-error-CJTV0jdn.d.mts","names":[],"sources":["../src/utils/parse-error.ts"],"sourcesContent":[],"mappings":";;;;;;AA8BA;;;;;iBAAgB,gBAAA,4BAA4C"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ParseError } from "jsonc-parser";
|
|
2
|
-
|
|
3
|
-
//#region src/utils/parse-error.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Nicely formats a JSON error with context
|
|
7
|
-
*
|
|
8
|
-
* @param input - JSON content as string
|
|
9
|
-
* @param parseError - jsonc ParseError
|
|
10
|
-
* @returns
|
|
11
|
-
*/
|
|
12
|
-
declare function formatParseError(input: string, parseError: ParseError): string;
|
|
13
|
-
//#endregion
|
|
14
|
-
export { formatParseError as t };
|
|
15
|
-
//# sourceMappingURL=parse-error-DLuqEXmf.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-error-DLuqEXmf.d.cts","names":[],"sources":["../src/utils/parse-error.ts"],"sourcesContent":[],"mappings":";;;;;;AA8BA;;;;;iBAAgB,gBAAA,4BAA4C"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./code-frames-BQI7PKd_.mjs";import{printParseErrorCode as t}from"jsonc-parser";import{LinesAndColumns as n}from"lines-and-columns";function r(r,i){let{error:a,offset:o,length:s}=i,c=new n(r).locationForIndex(o),l=c?.line??0,u=c?.column??0;return l++,u++,`${t(a)} in JSON at ${l}:${u}\n${e(r,{start:{line:l,column:u},end:{line:l,column:u+s}})}\n`}export{r as t};
|
|
2
|
-
//# sourceMappingURL=parse-error-DrJJkemH.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-error-DrJJkemH.mjs","names":[],"sources":["../src/utils/parse-error.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ParseError } from \"jsonc-parser\";\nimport { printParseErrorCode } from \"jsonc-parser\";\nimport { LinesAndColumns } from \"lines-and-columns\";\nimport { codeFrameColumns } from \"./code-frames\";\n\n/**\n * Nicely formats a JSON error with context\n *\n * @param input - JSON content as string\n * @param parseError - jsonc ParseError\n * @returns\n */\nexport function formatParseError(input: string, parseError: ParseError) {\n const { error, offset, length } = parseError;\n const result = new LinesAndColumns(input).locationForIndex(offset);\n let line = result?.line ?? 0;\n let column = result?.column ?? 0;\n\n line++;\n column++;\n\n return `${printParseErrorCode(error)} in JSON at ${line}:${column}\\n${codeFrameColumns(\n input,\n {\n start: {\n line,\n column\n },\n end: {\n line,\n column: column + length\n }\n }\n )}\\n`;\n}\n"],"mappings":"sJA8BA,SAAgB,EAAiB,EAAe,EAAwB,CACtE,GAAM,CAAE,QAAO,SAAQ,UAAW,EAC5B,EAAS,IAAI,EAAgB,EAAM,CAAC,iBAAiB,EAAO,CAC9D,EAAO,GAAQ,MAAQ,EACvB,EAAS,GAAQ,QAAU,EAK/B,MAHA,KACA,IAEO,GAAG,EAAoB,EAAM,CAAC,cAAc,EAAK,GAAG,EAAO,IAAI,EACpE,EACA,CACE,MAAO,CACL,OACA,SACD,CACD,IAAK,CACH,OACA,OAAQ,EAAS,EAClB,CACF,CACF,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
//#region src/utils/parse.d.ts
|
|
2
|
-
interface Options {
|
|
3
|
-
strict?: boolean;
|
|
4
|
-
}
|
|
5
|
-
declare function parse<T = unknown>(value: any, options?: Options): T;
|
|
6
|
-
declare function safeParse<T = unknown>(value: any, options?: Options): T;
|
|
7
|
-
//#endregion
|
|
8
|
-
export { parse as n, safeParse as r, Options as t };
|
|
9
|
-
//# sourceMappingURL=parse-fX7NFKdt.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-fX7NFKdt.d.cts","names":[],"sources":["../src/utils/parse.ts"],"sourcesContent":[],"mappings":";UA4CiB,OAAA;EAAA,MAAA,CAAA,EAAA,OAAO;AAIxB;AAmEgB,iBAnEA,KAmE4C,CAAA,IAAA,OAAgB,CAAA,CAAA,KAAA,EAAA,GAAA,EAAA,OAAA,CAAA,EAnEpB,OAmEoB,CAAA,EAnEL,CAmEK;iBAA5D,6CAA4C,UAAe"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
//#region src/utils/parse.d.ts
|
|
2
|
-
interface Options {
|
|
3
|
-
strict?: boolean;
|
|
4
|
-
}
|
|
5
|
-
declare function parse<T = unknown>(value: any, options?: Options): T;
|
|
6
|
-
declare function safeParse<T = unknown>(value: any, options?: Options): T;
|
|
7
|
-
//#endregion
|
|
8
|
-
export { parse as n, safeParse as r, Options as t };
|
|
9
|
-
//# sourceMappingURL=parse-xFkFesIF.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-xFkFesIF.d.mts","names":[],"sources":["../src/utils/parse.ts"],"sourcesContent":[],"mappings":";UA4CiB,OAAA;EAAA,MAAA,CAAA,EAAA,OAAO;AAIxB;AAmEgB,iBAnEA,KAmE4C,CAAA,IAAA,OAAgB,CAAA,CAAA,KAAA,EAAA,GAAA,EAAA,OAAA,CAAA,EAnEpB,OAmEoB,CAAA,EAnEL,CAmEK;iBAA5D,6CAA4C,UAAe"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./is-object-DDPbtSWR.mjs";import{t}from"./is-string-VB7nGKjX.mjs";import{t as n}from"./parse-BpylFCf0.mjs";import{t as r}from"./parse-error-DrJJkemH.mjs";import{n as i}from"./stringify-DjBDt8SC.mjs";import{parse as a}from"jsonc-parser";import{Buffer as o}from"node:buffer";import s from"superjson";var c=class o extends s{static#e;static get instance(){return o.#e||=new o,o.#e}static deserialize(e){return o.instance.deserialize(e)}static serialize(e){return o.instance.serialize(e)}static parse(e){return n(e)}static stringify(e,t){let n=o.instance.customTransformerRegistry.findApplicable(e),r=e;return n&&n.isApplicable(e)&&(r=n.serialize(r)),i(r)}static parseJson(e,t){try{if(t?.expectComments===!1)return o.instance.parse(e)}catch{}let n=[],i=a(e,n,{allowTrailingComma:!0,...t});if(n.length>0&&n[0])throw Error(r(e,n[0]));return i}static register(e,t,n,r){o.instance.registerCustom({isApplicable:r,serialize:t,deserialize:n},e)}static registerClass(n,r){o.instance.registerClass(n,{identifier:t(r)?r:r?.identifier||n.name,allowProps:r&&e(r)&&r?.allowProps&&Array.isArray(r.allowProps)?r.allowProps:[`__typename`]})}constructor(){super({dedupe:!0})}};c.instance.registerCustom({isApplicable:e=>o.isBuffer(e),serialize:e=>e.toString(`base64`),deserialize:e=>o.from(e,`base64`)},`Bytes`);export{c as t};
|
|
2
|
-
//# sourceMappingURL=storm-json-BsdLpzM_.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storm-json-BsdLpzM_.mjs","names":["#instance","parseValue","stringifyValue","errors: ParseError[]"],"sources":["../src/storm-json.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ParseError } from \"jsonc-parser\";\nimport type {\n Class,\n JsonParseOptions,\n JsonParserResult,\n JsonSerializeOptions,\n JsonValue\n} from \"./types\";\n// import { Decimal } from \"decimal.js\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { parse } from \"jsonc-parser\";\nimport { Buffer } from \"node:buffer\";\nimport SuperJSON from \"superjson\";\nimport { parse as parseValue } from \"./utils/parse\";\nimport { formatParseError } from \"./utils/parse-error\";\nimport { stringify as stringifyValue } from \"./utils/stringify\";\n\n/**\n * A static JSON parser class used by Storm Software to serialize and deserialize JSON data\n *\n * @remarks\n * This class uses the [SuperJSON](https://github.com/blitz-js/superjson) library under the hood.\n */\nexport class StormJSON extends SuperJSON {\n static #instance: StormJSON;\n\n public static get instance(): StormJSON {\n if (!StormJSON.#instance) {\n StormJSON.#instance = new StormJSON();\n }\n\n return StormJSON.#instance;\n }\n\n /**\n * Deserialize the given value with superjson using the given metadata\n */\n public static override deserialize<TData = unknown>(\n payload: JsonParserResult\n ): TData {\n return StormJSON.instance.deserialize(payload);\n }\n\n /**\n * Serialize the given value with superjson\n */\n public static override serialize(object: JsonValue): JsonParserResult {\n return StormJSON.instance.serialize(object);\n }\n\n /**\n * Parse the given string value with superjson using the given metadata\n *\n * @param value - The string value to parse\n * @returns The parsed data\n */\n public static override parse<TData = unknown>(value: string): TData {\n return parseValue(value);\n }\n\n /**\n * Serializes the given data to a JSON string.\n * By default the JSON string is formatted with a 2 space indentation to be easy readable.\n *\n * @param value - Object which should be serialized to JSON\n * @param _options - JSON serialize options\n * @returns the formatted JSON representation of the object\n */\n public static override stringify<T>(\n value: T,\n _options?: JsonSerializeOptions\n ): string {\n const customTransformer =\n StormJSON.instance.customTransformerRegistry.findApplicable(value);\n\n let result = value;\n if (customTransformer && customTransformer.isApplicable(value)) {\n result = customTransformer.serialize(result) as T;\n }\n\n return stringifyValue(result);\n }\n\n /**\n * Parses the given JSON string and returns the object the JSON content represents.\n * By default javascript-style comments and trailing commas are allowed.\n *\n * @param strData - JSON content as string\n * @param options - JSON parse options\n * @returns Object the JSON content represents\n */\n public static parseJson<TData = unknown>(\n strData: string,\n options?: JsonParseOptions\n ): TData {\n try {\n if (options?.expectComments === false) {\n return StormJSON.instance.parse(strData);\n }\n } catch {\n // Do nothing\n }\n\n const errors: ParseError[] = [];\n const opts = {\n allowTrailingComma: true,\n ...options\n };\n const result = parse(strData, errors, opts) as TData;\n\n if (errors.length > 0 && errors[0]) {\n throw new Error(formatParseError(strData, errors[0]));\n }\n\n return result;\n }\n\n /**\n * Register a custom schema with superjson\n *\n * @param name - The name of the schema\n * @param serialize - The function to serialize the schema\n * @param deserialize - The function to deserialize the schema\n * @param isApplicable - The function to check if the schema is applicable\n */\n public static register<\n TData = any,\n TJsonObject extends JsonValue = JsonValue\n >(\n name: string,\n serialize: (data: TData) => TJsonObject,\n deserialize: (json: TJsonObject) => TData,\n isApplicable: (data: any) => data is TData\n ) {\n StormJSON.instance.registerCustom<TData, TJsonObject>(\n {\n isApplicable,\n serialize,\n deserialize\n },\n name\n );\n }\n\n /**\n * Register a class with superjson\n *\n * @param classConstructor - The class constructor to register\n */\n public static override registerClass(\n classConstructor: Class,\n options?: { identifier?: string; allowProps?: string[] } | string\n ) {\n StormJSON.instance.registerClass(classConstructor, {\n identifier: isString(options)\n ? options\n : options?.identifier || classConstructor.name,\n allowProps:\n options &&\n isObject(options) &&\n options?.allowProps &&\n Array.isArray(options.allowProps)\n ? options.allowProps\n : [\"__typename\"]\n });\n }\n\n private constructor() {\n super({ dedupe: true });\n }\n}\n\nStormJSON.instance.registerCustom<Buffer, string>(\n {\n isApplicable: (v): v is Buffer => Buffer.isBuffer(v),\n serialize: v => v.toString(\"base64\"),\n deserialize: v => Buffer.from(v, \"base64\")\n },\n \"Bytes\"\n);\n"],"mappings":"6TA0CA,IAAa,EAAb,MAAa,UAAkB,CAAU,CACvC,OAAA,EAEA,WAAkB,UAAsB,CAKtC,MAJA,CACE,GAAA,IAAsB,IAAI,EAGrB,GAAA,EAMT,OAAuB,YACrB,EACO,CACP,OAAO,EAAU,SAAS,YAAY,EAAQ,CAMhD,OAAuB,UAAU,EAAqC,CACpE,OAAO,EAAU,SAAS,UAAU,EAAO,CAS7C,OAAuB,MAAuB,EAAsB,CAClE,OAAOC,EAAW,EAAM,CAW1B,OAAuB,UACrB,EACA,EACQ,CACR,IAAM,EACJ,EAAU,SAAS,0BAA0B,eAAe,EAAM,CAEhE,EAAS,EAKb,OAJI,GAAqB,EAAkB,aAAa,EAAM,GAC5D,EAAS,EAAkB,UAAU,EAAO,EAGvCC,EAAe,EAAO,CAW/B,OAAc,UACZ,EACA,EACO,CACP,GAAI,CACF,GAAI,GAAS,iBAAmB,GAC9B,OAAO,EAAU,SAAS,MAAM,EAAQ,MAEpC,EAIR,IAAMC,EAAuB,EAAE,CAKzB,EAAS,EAAM,EAAS,EAJjB,CACX,mBAAoB,GACpB,GAAG,EACJ,CAC0C,CAE3C,GAAI,EAAO,OAAS,GAAK,EAAO,GAC9B,MAAU,MAAM,EAAiB,EAAS,EAAO,GAAG,CAAC,CAGvD,OAAO,EAWT,OAAc,SAIZ,EACA,EACA,EACA,EACA,CACA,EAAU,SAAS,eACjB,CACE,eACA,YACA,cACD,CACD,EACD,CAQH,OAAuB,cACrB,EACA,EACA,CACA,EAAU,SAAS,cAAc,EAAkB,CACjD,WAAY,EAAS,EAAQ,CACzB,EACA,GAAS,YAAc,EAAiB,KAC5C,WACE,GACA,EAAS,EAAQ,EACjB,GAAS,YACT,MAAM,QAAQ,EAAQ,WAAW,CAC7B,EAAQ,WACR,CAAC,aAAa,CACrB,CAAC,CAGJ,aAAsB,CACpB,MAAM,CAAE,OAAQ,GAAM,CAAC,GAI3B,EAAU,SAAS,eACjB,CACE,aAAe,GAAmB,EAAO,SAAS,EAAE,CACpD,UAAW,GAAK,EAAE,SAAS,SAAS,CACpC,YAAa,GAAK,EAAO,KAAK,EAAG,SAAS,CAC3C,CACD,QACD"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { d as JsonParserResult, f as JsonSerializeOptions, l as JsonParseOptions, p as JsonValue, t as Class } from "./types-CQHq94S4.mjs";
|
|
2
|
-
import SuperJSON from "superjson";
|
|
3
|
-
|
|
4
|
-
//#region src/storm-json.d.ts
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A static JSON parser class used by Storm Software to serialize and deserialize JSON data
|
|
8
|
-
*
|
|
9
|
-
* @remarks
|
|
10
|
-
* This class uses the [SuperJSON](https://github.com/blitz-js/superjson) library under the hood.
|
|
11
|
-
*/
|
|
12
|
-
declare class StormJSON extends SuperJSON {
|
|
13
|
-
#private;
|
|
14
|
-
static get instance(): StormJSON;
|
|
15
|
-
/**
|
|
16
|
-
* Deserialize the given value with superjson using the given metadata
|
|
17
|
-
*/
|
|
18
|
-
static deserialize<TData = unknown>(payload: JsonParserResult): TData;
|
|
19
|
-
/**
|
|
20
|
-
* Serialize the given value with superjson
|
|
21
|
-
*/
|
|
22
|
-
static serialize(object: JsonValue): JsonParserResult;
|
|
23
|
-
/**
|
|
24
|
-
* Parse the given string value with superjson using the given metadata
|
|
25
|
-
*
|
|
26
|
-
* @param value - The string value to parse
|
|
27
|
-
* @returns The parsed data
|
|
28
|
-
*/
|
|
29
|
-
static parse<TData = unknown>(value: string): TData;
|
|
30
|
-
/**
|
|
31
|
-
* Serializes the given data to a JSON string.
|
|
32
|
-
* By default the JSON string is formatted with a 2 space indentation to be easy readable.
|
|
33
|
-
*
|
|
34
|
-
* @param value - Object which should be serialized to JSON
|
|
35
|
-
* @param _options - JSON serialize options
|
|
36
|
-
* @returns the formatted JSON representation of the object
|
|
37
|
-
*/
|
|
38
|
-
static stringify<T>(value: T, _options?: JsonSerializeOptions): string;
|
|
39
|
-
/**
|
|
40
|
-
* Parses the given JSON string and returns the object the JSON content represents.
|
|
41
|
-
* By default javascript-style comments and trailing commas are allowed.
|
|
42
|
-
*
|
|
43
|
-
* @param strData - JSON content as string
|
|
44
|
-
* @param options - JSON parse options
|
|
45
|
-
* @returns Object the JSON content represents
|
|
46
|
-
*/
|
|
47
|
-
static parseJson<TData = unknown>(strData: string, options?: JsonParseOptions): TData;
|
|
48
|
-
/**
|
|
49
|
-
* Register a custom schema with superjson
|
|
50
|
-
*
|
|
51
|
-
* @param name - The name of the schema
|
|
52
|
-
* @param serialize - The function to serialize the schema
|
|
53
|
-
* @param deserialize - The function to deserialize the schema
|
|
54
|
-
* @param isApplicable - The function to check if the schema is applicable
|
|
55
|
-
*/
|
|
56
|
-
static register<TData = any, TJsonObject extends JsonValue = JsonValue>(name: string, serialize: (data: TData) => TJsonObject, deserialize: (json: TJsonObject) => TData, isApplicable: (data: any) => data is TData): void;
|
|
57
|
-
/**
|
|
58
|
-
* Register a class with superjson
|
|
59
|
-
*
|
|
60
|
-
* @param classConstructor - The class constructor to register
|
|
61
|
-
*/
|
|
62
|
-
static registerClass(classConstructor: Class, options?: {
|
|
63
|
-
identifier?: string;
|
|
64
|
-
allowProps?: string[];
|
|
65
|
-
} | string): void;
|
|
66
|
-
private constructor();
|
|
67
|
-
}
|
|
68
|
-
//#endregion
|
|
69
|
-
export { StormJSON as t };
|
|
70
|
-
//# sourceMappingURL=storm-json-CfqJ0KzG.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storm-json-CfqJ0KzG.d.mts","names":[],"sources":["../src/storm-json.ts"],"sourcesContent":[],"mappings":";;;;;;;AA0CA;;;;AAuB2C,cAvB9B,SAAA,SAAkB,SAAA,CAuBY;EAAY,CAAA,OAAA;EAUS,WAAA,QAAA,CAAA,CAAA,EA9BhC,SA8BgC;EAarD;;;EAyBN,OAAA,WAAA,CAAA,QAAA,OAAA,CAAA,CAAA,OAAA,EAxDQ,gBAwDR,CAAA,EAvDA,KAuDA;EAiCmB;;;EAGQ,OAAA,SAAA,CAAA,MAAA,EApFW,SAoFX,CAAA,EApFuB,gBAoFvB;EACR;;;;;;gDA3EwC;;;;;;;;;6BAarD,cACI;;;;;;;;;+DAuBD,mBACT;;;;;;;;;mDAiCmB,YAAY,2CAGd,UAAU,iCACR,gBAAgB,4CACC;;;;;;yCAkBnB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=require(`./is-object-CGB7EeiA.cjs`),l=require(`./is-string-D5yKZC0U.cjs`),u=require(`./parse-DmriuGKI.cjs`),d=require(`./parse-error-0BAtatMf.cjs`),f=require(`./stringify-Dp0lF-wN.cjs`);let p=require(`jsonc-parser`),m=require(`node:buffer`),h=require(`superjson`);h=s(h);var g=class e extends h.default{static#e;static get instance(){return e.#e||=new e,e.#e}static deserialize(t){return e.instance.deserialize(t)}static serialize(t){return e.instance.serialize(t)}static parse(e){return u.t(e)}static stringify(t,n){let r=e.instance.customTransformerRegistry.findApplicable(t),i=t;return r&&r.isApplicable(t)&&(i=r.serialize(i)),f.n(i)}static parseJson(t,n){try{if(n?.expectComments===!1)return e.instance.parse(t)}catch{}let r=[],i=(0,p.parse)(t,r,{allowTrailingComma:!0,...n});if(r.length>0&&r[0])throw Error(d.t(t,r[0]));return i}static register(t,n,r,i){e.instance.registerCustom({isApplicable:i,serialize:n,deserialize:r},t)}static registerClass(t,n){e.instance.registerClass(t,{identifier:l.t(n)?n:n?.identifier||t.name,allowProps:n&&c.t(n)&&n?.allowProps&&Array.isArray(n.allowProps)?n.allowProps:[`__typename`]})}constructor(){super({dedupe:!0})}};g.instance.registerCustom({isApplicable:e=>m.Buffer.isBuffer(e),serialize:e=>e.toString(`base64`),deserialize:e=>m.Buffer.from(e,`base64`)},`Bytes`),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return g}});
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { d as JsonParserResult, f as JsonSerializeOptions, l as JsonParseOptions, p as JsonValue, t as Class } from "./types-CEiKQHlk.cjs";
|
|
2
|
-
import SuperJSON from "superjson";
|
|
3
|
-
|
|
4
|
-
//#region src/storm-json.d.ts
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A static JSON parser class used by Storm Software to serialize and deserialize JSON data
|
|
8
|
-
*
|
|
9
|
-
* @remarks
|
|
10
|
-
* This class uses the [SuperJSON](https://github.com/blitz-js/superjson) library under the hood.
|
|
11
|
-
*/
|
|
12
|
-
declare class StormJSON extends SuperJSON {
|
|
13
|
-
#private;
|
|
14
|
-
static get instance(): StormJSON;
|
|
15
|
-
/**
|
|
16
|
-
* Deserialize the given value with superjson using the given metadata
|
|
17
|
-
*/
|
|
18
|
-
static deserialize<TData = unknown>(payload: JsonParserResult): TData;
|
|
19
|
-
/**
|
|
20
|
-
* Serialize the given value with superjson
|
|
21
|
-
*/
|
|
22
|
-
static serialize(object: JsonValue): JsonParserResult;
|
|
23
|
-
/**
|
|
24
|
-
* Parse the given string value with superjson using the given metadata
|
|
25
|
-
*
|
|
26
|
-
* @param value - The string value to parse
|
|
27
|
-
* @returns The parsed data
|
|
28
|
-
*/
|
|
29
|
-
static parse<TData = unknown>(value: string): TData;
|
|
30
|
-
/**
|
|
31
|
-
* Serializes the given data to a JSON string.
|
|
32
|
-
* By default the JSON string is formatted with a 2 space indentation to be easy readable.
|
|
33
|
-
*
|
|
34
|
-
* @param value - Object which should be serialized to JSON
|
|
35
|
-
* @param _options - JSON serialize options
|
|
36
|
-
* @returns the formatted JSON representation of the object
|
|
37
|
-
*/
|
|
38
|
-
static stringify<T>(value: T, _options?: JsonSerializeOptions): string;
|
|
39
|
-
/**
|
|
40
|
-
* Parses the given JSON string and returns the object the JSON content represents.
|
|
41
|
-
* By default javascript-style comments and trailing commas are allowed.
|
|
42
|
-
*
|
|
43
|
-
* @param strData - JSON content as string
|
|
44
|
-
* @param options - JSON parse options
|
|
45
|
-
* @returns Object the JSON content represents
|
|
46
|
-
*/
|
|
47
|
-
static parseJson<TData = unknown>(strData: string, options?: JsonParseOptions): TData;
|
|
48
|
-
/**
|
|
49
|
-
* Register a custom schema with superjson
|
|
50
|
-
*
|
|
51
|
-
* @param name - The name of the schema
|
|
52
|
-
* @param serialize - The function to serialize the schema
|
|
53
|
-
* @param deserialize - The function to deserialize the schema
|
|
54
|
-
* @param isApplicable - The function to check if the schema is applicable
|
|
55
|
-
*/
|
|
56
|
-
static register<TData = any, TJsonObject extends JsonValue = JsonValue>(name: string, serialize: (data: TData) => TJsonObject, deserialize: (json: TJsonObject) => TData, isApplicable: (data: any) => data is TData): void;
|
|
57
|
-
/**
|
|
58
|
-
* Register a class with superjson
|
|
59
|
-
*
|
|
60
|
-
* @param classConstructor - The class constructor to register
|
|
61
|
-
*/
|
|
62
|
-
static registerClass(classConstructor: Class, options?: {
|
|
63
|
-
identifier?: string;
|
|
64
|
-
allowProps?: string[];
|
|
65
|
-
} | string): void;
|
|
66
|
-
private constructor();
|
|
67
|
-
}
|
|
68
|
-
//#endregion
|
|
69
|
-
export { StormJSON as t };
|
|
70
|
-
//# sourceMappingURL=storm-json-Q1bOIv3-.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storm-json-Q1bOIv3-.d.cts","names":[],"sources":["../src/storm-json.ts"],"sourcesContent":[],"mappings":";;;;;;;AA0CA;;;;AAuB2C,cAvB9B,SAAA,SAAkB,SAAA,CAuBY;EAAY,CAAA,OAAA;EAUS,WAAA,QAAA,CAAA,CAAA,EA9BhC,SA8BgC;EAarD;;;EAyBN,OAAA,WAAA,CAAA,QAAA,OAAA,CAAA,CAAA,OAAA,EAxDQ,gBAwDR,CAAA,EAvDA,KAuDA;EAiCmB;;;EAGQ,OAAA,SAAA,CAAA,MAAA,EApFW,SAoFX,CAAA,EApFuB,gBAoFvB;EACR;;;;;;gDA3EwC;;;;;;;;;6BAarD,cACI;;;;;;;;;+DAuBD,mBACT;;;;;;;;;mDAiCmB,YAAY,2CAGd,UAAU,iCACR,gBAAgB,4CACC;;;;;;yCAkBnB"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
//#region src/utils/stringify.d.ts
|
|
2
|
-
declare const invalidKeyChars: readonly ["@", "/", "#", "$", " ", ":", ";", ",", ".", "!", "?", "&", "=", "+", "-", "*", "%", "^", "~", "|", "\\", "\"", "'", "`", "{", "}", "[", "]", "(", ")", "<", ">"];
|
|
3
|
-
/**
|
|
4
|
-
* Stringify a value to a JSON-like string.
|
|
5
|
-
*
|
|
6
|
-
* @param value - The value to stringify
|
|
7
|
-
* @param spacing - The spacing to use for the stringification
|
|
8
|
-
* @returns The stringified value
|
|
9
|
-
*/
|
|
10
|
-
declare const stringify: (value: unknown, spacing?: string | number) => string;
|
|
11
|
-
//#endregion
|
|
12
|
-
export { stringify as n, invalidKeyChars as t };
|
|
13
|
-
//# sourceMappingURL=stringify-BpBMOhle.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stringify-BpBMOhle.d.cts","names":[],"sources":["../src/utils/stringify.ts"],"sourcesContent":[],"mappings":";cAqBa;AAAb;AA0CA;;;;;;cAAa"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./is-number-CebQk_B0.mjs";import{t}from"./is-undefined-D6sfLkFq.mjs";const n=`@/#$ :;,.!?&=+-*%^~|\\"'\`{}[]()<>`.split(``),r=(i,a=2)=>{let o=e(a)?` `.repeat(a):a;switch(i){case null:return`null`;case void 0:return`"undefined"`;case!0:return`true`;case!1:return`false`;case 1/0:return`infinity`;case-1/0:return`-infinity`}if(Array.isArray(i))return`[${o}${i.map(e=>r(e,o)).join(`,${o}`)}${o}]`;if(i instanceof Uint8Array)return i.toString();switch(typeof i){case`number`:return`${i}`;case`string`:return JSON.stringify(i);case`object`:return`{${o}${Object.keys(i).filter(e=>!t(i[e])).map(e=>`${n.some(t=>e.includes(t))?`"${e}"`:e}: ${o}${r(i[e],o)}`).join(`,${o}`)}${o}}`;default:return`null`}};export{r as n,n as t};
|
|
2
|
-
//# sourceMappingURL=stringify-DjBDt8SC.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stringify-DjBDt8SC.mjs","names":[],"sources":["../src/utils/stringify.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\n\nexport const invalidKeyChars = [\n \"@\",\n \"/\",\n \"#\",\n \"$\",\n \" \",\n \":\",\n \";\",\n \",\",\n \".\",\n \"!\",\n \"?\",\n \"&\",\n \"=\",\n \"+\",\n \"-\",\n \"*\",\n \"%\",\n \"^\",\n \"~\",\n \"|\",\n \"\\\\\",\n '\"',\n \"'\",\n \"`\",\n \"{\",\n \"}\",\n \"[\",\n \"]\",\n \"(\",\n \")\",\n \"<\",\n \">\"\n] as const;\n\n/**\n * Stringify a value to a JSON-like string.\n *\n * @param value - The value to stringify\n * @param spacing - The spacing to use for the stringification\n * @returns The stringified value\n */\nexport const stringify = (\n value: unknown,\n spacing: string | number = 2\n): string => {\n const space = isNumber(spacing) ? \" \".repeat(spacing) : spacing;\n\n switch (value) {\n case null: {\n return \"null\";\n }\n case undefined: {\n return '\"undefined\"';\n }\n case true: {\n return \"true\";\n }\n case false: {\n return \"false\";\n }\n case Number.POSITIVE_INFINITY: {\n return \"infinity\";\n }\n case Number.NEGATIVE_INFINITY: {\n return \"-infinity\";\n }\n }\n\n if (Array.isArray(value)) {\n return `[${space}${value.map(v => stringify(v, space)).join(`,${space}`)}${space}]`;\n }\n if (value instanceof Uint8Array) {\n return value.toString();\n }\n\n // eslint-disable-next-line ts/switch-exhaustiveness-check\n switch (typeof value) {\n case \"number\": {\n return `${value}`;\n }\n case \"string\": {\n return JSON.stringify(value);\n }\n case \"object\": {\n const keys = Object.keys(value as object).filter(\n key => !isUndefined((value as any)[key])\n );\n\n return `{${space}${keys\n .map(\n key =>\n `${invalidKeyChars.some(invalidKeyChar => key.includes(invalidKeyChar)) ? `\"${key}\"` : key}: ${space}${stringify((value as any)[key], space)}`\n )\n .join(`,${space}`)}${space}}`;\n }\n default:\n return \"null\";\n }\n};\n"],"mappings":"wFAqBA,MAAa,EAAkB,8CAiC9B,CASY,GACX,EACA,EAA2B,IAChB,CACX,IAAM,EAAQ,EAAS,EAAQ,CAAG,IAAI,OAAO,EAAQ,CAAG,EAExD,OAAQ,EAAR,CACE,KAAK,KACH,MAAO,OAET,KAAK,IAAA,GACH,MAAO,cAET,IAAK,GACH,MAAO,OAET,IAAK,GACH,MAAO,QAET,IAAK,KACH,MAAO,WAET,IAAK,KACH,MAAO,YAIX,GAAI,MAAM,QAAQ,EAAM,CACtB,MAAO,IAAI,IAAQ,EAAM,IAAI,GAAK,EAAU,EAAG,EAAM,CAAC,CAAC,KAAK,IAAI,IAAQ,GAAG,EAAM,GAEnF,GAAI,aAAiB,WACnB,OAAO,EAAM,UAAU,CAIzB,OAAQ,OAAO,EAAf,CACE,IAAK,SACH,MAAO,GAAG,IAEZ,IAAK,SACH,OAAO,KAAK,UAAU,EAAM,CAE9B,IAAK,SAKH,MAAO,IAAI,IAJE,OAAO,KAAK,EAAgB,CAAC,OACxC,GAAO,CAAC,EAAa,EAAc,GAAK,CACzC,CAGE,IACC,GACE,GAAG,EAAgB,KAAK,GAAkB,EAAI,SAAS,EAAe,CAAC,CAAG,IAAI,EAAI,GAAK,EAAI,IAAI,IAAQ,EAAW,EAAc,GAAM,EAAM,GAC/I,CACA,KAAK,IAAI,IAAQ,GAAG,EAAM,GAE/B,QACE,MAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require(`./is-number-wfNPC3Mj.cjs`),t=require(`./is-undefined-Pevixi0g.cjs`),n=`@/#$ :;,.!?&=+-*%^~|\\"'\`{}[]()<>`.split(``),r=(i,a=2)=>{let o=e.t(a)?` `.repeat(a):a;switch(i){case null:return`null`;case void 0:return`"undefined"`;case!0:return`true`;case!1:return`false`;case 1/0:return`infinity`;case-1/0:return`-infinity`}if(Array.isArray(i))return`[${o}${i.map(e=>r(e,o)).join(`,${o}`)}${o}]`;if(i instanceof Uint8Array)return i.toString();switch(typeof i){case`number`:return`${i}`;case`string`:return JSON.stringify(i);case`object`:return`{${o}${Object.keys(i).filter(e=>!t.t(i[e])).map(e=>`${n.some(t=>e.includes(t))?`"${e}"`:e}: ${o}${r(i[e],o)}`).join(`,${o}`)}${o}}`;default:return`null`}};Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return n}});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
//#region src/utils/stringify.d.ts
|
|
2
|
-
declare const invalidKeyChars: readonly ["@", "/", "#", "$", " ", ":", ";", ",", ".", "!", "?", "&", "=", "+", "-", "*", "%", "^", "~", "|", "\\", "\"", "'", "`", "{", "}", "[", "]", "(", ")", "<", ">"];
|
|
3
|
-
/**
|
|
4
|
-
* Stringify a value to a JSON-like string.
|
|
5
|
-
*
|
|
6
|
-
* @param value - The value to stringify
|
|
7
|
-
* @param spacing - The spacing to use for the stringification
|
|
8
|
-
* @returns The stringified value
|
|
9
|
-
*/
|
|
10
|
-
declare const stringify: (value: unknown, spacing?: string | number) => string;
|
|
11
|
-
//#endregion
|
|
12
|
-
export { stringify as n, invalidKeyChars as t };
|
|
13
|
-
//# sourceMappingURL=stringify-ln223ZC9.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stringify-ln223ZC9.d.mts","names":[],"sources":["../src/utils/stringify.ts"],"sourcesContent":[],"mappings":";cAqBa;AAAb;AA0CA;;;;;;cAAa"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
const e=``,t=Symbol(`singleComment`),n=Symbol(`multiComment`);function r(){return``}function i(e,t,n){return e.slice(t,n).replace(/\S/g,` `)}function a(e,t){let n=t-1,r=0;for(;e[n]===`\\`;)--n,r+=1;return!!(r%2)}function o(e,{whitespace:o=!0,trailingCommas:s=!1}={}){if(typeof e!=`string`)throw TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof e}\``);let c=o?i:r,l=!1,u=!1,d=0,f=``,p=``,m=-1;for(let r=0;r<e.length;r++){let i=e[r],o=e[r+1];!u&&i===`"`&&(a(e,r)||(l=!l)),!l&&(!u&&i+(o??``)===`//`?(f+=e.slice(d,r),d=r,u=t,r++):u===t&&i+(o??``)===`\r
|
|
2
|
-
`?(r++,u=!1,f+=c(e,d,r),d=r):u===t&&i===`
|
|
3
|
-
`?(u=!1,f+=c(e,d,r),d=r):!u&&i+(o??``)===`/*`?(f+=e.slice(d,r),d=r,u=n,r++):u===n&&i+(o??``)===`*/`?(r++,u=!1,f+=c(e,d,r+1),d=r+1):s&&!u&&(m===-1?i===`,`&&(p+=f+e.slice(d,r),f=``,d=r,m=r):i===`}`||i===`]`?(f+=e.slice(d,r),p+=c(f,0,1)+f.slice(1),f=``,d=r,m=-1):i!==` `&&i!==` `&&i!==`\r`&&i!==`
|
|
4
|
-
`&&(f+=e.slice(d,r),d=r,m=-1)))}return p+f+(u?c(e.slice(d)):e.slice(d))}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return o}});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
//#region src/utils/strip-comments.d.ts
|
|
2
|
-
declare function stripComments(value: string, {
|
|
3
|
-
whitespace,
|
|
4
|
-
trailingCommas
|
|
5
|
-
}?: {
|
|
6
|
-
whitespace?: boolean | undefined;
|
|
7
|
-
trailingCommas?: boolean | undefined;
|
|
8
|
-
}): string;
|
|
9
|
-
//#endregion
|
|
10
|
-
export { stripComments as t };
|
|
11
|
-
//# sourceMappingURL=strip-comments-CKLSXchM.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"strip-comments-CKLSXchM.d.cts","names":[],"sources":["../src/utils/strip-comments.ts"],"sourcesContent":[],"mappings":";iBAyCgB,aAAA;;;;EAAA,UAAA,CAAA,EAAA,OAAa,GAAA,SAEzB"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
//#region src/utils/strip-comments.d.ts
|
|
2
|
-
declare function stripComments(value: string, {
|
|
3
|
-
whitespace,
|
|
4
|
-
trailingCommas
|
|
5
|
-
}?: {
|
|
6
|
-
whitespace?: boolean | undefined;
|
|
7
|
-
trailingCommas?: boolean | undefined;
|
|
8
|
-
}): string;
|
|
9
|
-
//#endregion
|
|
10
|
-
export { stripComments as t };
|
|
11
|
-
//# sourceMappingURL=strip-comments-DdsCzji6.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"strip-comments-DdsCzji6.d.mts","names":[],"sources":["../src/utils/strip-comments.ts"],"sourcesContent":[],"mappings":";iBAyCgB,aAAA;;;;EAAA,UAAA,CAAA,EAAA,OAAa,GAAA,SAEzB"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
const e=Symbol(`singleComment`),t=Symbol(`multiComment`);function n(){return``}function r(e,t,n){return e.slice(t,n).replace(/\S/g,` `)}function i(e,t){let n=t-1,r=0;for(;e[n]===`\\`;)--n,r+=1;return!!(r%2)}function a(a,{whitespace:o=!0,trailingCommas:s=!1}={}){if(typeof a!=`string`)throw TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof a}\``);let c=o?r:n,l=!1,u=!1,d=0,f=``,p=``,m=-1;for(let n=0;n<a.length;n++){let r=a[n],o=a[n+1];!u&&r===`"`&&(i(a,n)||(l=!l)),!l&&(!u&&r+(o??``)===`//`?(f+=a.slice(d,n),d=n,u=e,n++):u===e&&r+(o??``)===`\r
|
|
2
|
-
`?(n++,u=!1,f+=c(a,d,n),d=n):u===e&&r===`
|
|
3
|
-
`?(u=!1,f+=c(a,d,n),d=n):!u&&r+(o??``)===`/*`?(f+=a.slice(d,n),d=n,u=t,n++):u===t&&r+(o??``)===`*/`?(n++,u=!1,f+=c(a,d,n+1),d=n+1):s&&!u&&(m===-1?r===`,`&&(p+=f+a.slice(d,n),f=``,d=n,m=n):r===`}`||r===`]`?(f+=a.slice(d,n),p+=c(f,0,1)+f.slice(1),f=``,d=n,m=-1):r!==` `&&r!==` `&&r!==`\r`&&r!==`
|
|
4
|
-
`&&(f+=a.slice(d,n),d=n,m=-1)))}return p+f+(u?c(a.slice(d)):a.slice(d))}export{a as t};
|
|
5
|
-
//# sourceMappingURL=strip-comments-LcqiBhvo.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"strip-comments-LcqiBhvo.mjs","names":["isInsideString: boolean | symbol","isInsideComment: boolean | symbol"],"sources":["../../types/src/base.ts","../src/utils/strip-comments.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { TypedArray } from \"./array\";\n\nexport type SerializablePrimitive =\n | null\n | undefined\n | string\n | number\n | boolean\n | bigint;\nexport type Primitive = SerializablePrimitive | symbol;\n\n/**\n * Matches any primitive, `void`, `Date`, or `RegExp` value.\n */\nexport type BuiltIns = Primitive | void | Date | RegExp;\n\n/**\n * Matches any non-primitive object\n */\n// eslint-disable-next-line ts/no-unsafe-function-type\nexport type AtomicObject = Function | Promise<any> | Date | RegExp;\n\n/** Determines if the passed value is of a specific type */\nexport type TypeTester = (value: any) => boolean;\n\n/**\n * The interface for a type mapping (key =\\> function) to use for {@link getType}.\n * export * The key represents the name of the type. The function represents the {@link TypeTester | test method}.\n * The map should be ordered by testing preference, with more specific tests first.\n * If a test returns true, it is selected, and the key is returned as the type.\n */\nexport type TypeMap = Record<string, TypeTester>;\n\ndeclare const emptyObjectSymbol: unique symbol;\n\nexport type FunctionOrValue<Value> = Value extends () => infer X ? X : Value;\n\n/**\n * A [[List]]\n *\n * @example\n * ```ts\n * type list0 = [1, 2, 3]\n * type list1 = number[]\n * ```\n *\n * @param A - its type\n * @returns [[List]]\n */\nexport type List<A = any> = ReadonlyArray<A>;\n\n/**\n * Alias to create a [[Function]]\n *\n * @example\n * ```ts\n * import { FunctionLike } from '@stryke/types'\n *\n * type test0 = FunctionLike<[string, number], boolean>\n * /// (args_0: string, args_1: number) => boolean\n * ```\n *\n * @param P - parameters\n * @param R - return type\n * @returns [[Function]]\n */\nexport type FunctionLike<P extends List = any, R = any> = (...args: P) => R;\n\nexport type AnyFunction = FunctionLike<any, any>;\nexport type Nullish = undefined | null;\nexport type Nullishable<T> = T | Nullish;\nexport type NonNullishObject = object; // not null/undefined which are Object\nexport type NativeClass = abstract new (...args: any) => any;\nexport type AnyNumber = number | number;\nexport type AnyString = string | string;\nexport type AnyBoolean = boolean | boolean;\nexport type AnyArray = any[];\nexport type PlainObject = Record<any, object>; // https://stackoverflow.com/a/75052315/130638\nexport type AnyMap = Map<any, any>;\nexport type AnyWeakMap = WeakMap<WeakKey, any>;\nexport type EmptyArray = [];\nexport interface EmptyObject {\n [emptyObjectSymbol]?: never;\n}\n\nexport type Any =\n | boolean\n | number\n | bigint\n | string\n | null\n | undefined\n | void\n | symbol\n | object\n | PlainObject\n | AnyArray\n | AnyMap\n | AnyWeakMap;\n\n/**\n * The valid types of the index for an `Indexable` type object\n */\nexport type IndexType = string | number | symbol;\n\n/**\n * The declaration of a ***dictionary-type*** object with a specific type\n *\n * @see {@link Indexable}\n * @see {@link IndexType}\n * @see {@link Dictionary}\n */\nexport type TypedIndexable<T> = Record<IndexType, T>;\n\n/**\n * The declaration of a ***dictionary-type*** object\n *\n * @see {@link TypedIndexable}\n * @see {@link IndexType}\n * @see {@link Dictionary}\n */\nexport type Indexable = TypedIndexable<any>;\n\n/**\n * The declaration of a ***dictionary-type*** object with a specific type\n *\n * @see {@link Indexable}\n * @see {@link IndexType}\n * @see {@link TypedIndexable}\n */\nexport type Dictionary<T> = Record<string, T>;\n\nexport const EMPTY_STRING = \"\";\nexport const NEWLINE_STRING = \"\\r\\n\";\nexport const EMPTY_OBJECT = {};\n\nexport type AnyCase<T extends IndexType> = string extends T\n ? string\n : T extends `${infer F1}${infer F2}${infer R}`\n ? `${Uppercase<F1> | Lowercase<F1>}${Uppercase<F2> | Lowercase<F2>}${AnyCase<R>}`\n : T extends `${infer F}${infer R}`\n ? `${Uppercase<F> | Lowercase<F>}${AnyCase<R>}`\n : typeof EMPTY_STRING;\n\nexport type Newable<T> = new (..._args: never[]) => T;\n\nexport interface Abstract<T> {\n prototype: T;\n}\n\nexport interface Clonable<T> {\n clone: () => T;\n}\n\nexport type MaybePromise<T> = T | Promise<T>;\n\nexport type ReducerFunction<TState, TAction> = (\n state: TState,\n action: TAction\n) => TState;\n\n// NOTE: for the file size optimization\nexport const TYPE_ARGUMENTS = \"Arguments\";\nexport const TYPE_ARRAY = \"Array\";\nexport const TYPE_OBJECT = \"Object\";\nexport const TYPE_MAP = \"Map\";\nexport const TYPE_SET = \"Set\";\n\nexport type Collection =\n | IArguments\n | unknown[]\n | Map<unknown, unknown>\n | Record<string | number | symbol, unknown>\n | Set<unknown>;\n\nexport type NonUndefined<T> = T extends undefined ? never : T;\n\nexport type BrowserNativeObject = Date | File;\n\nexport type DeepPartial<T> = T extends BrowserNativeObject | NestedValue\n ? T\n : {\n [K in keyof T]?: DeepPartial<T[K]>;\n };\n\nexport type Rollback = Record<\n string,\n (initialValue: any, currentValue: any) => any\n>;\n\n/**\n * Extract all required keys from the given type.\n *\n * @remarks\n * This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...\n */\nexport type RequiredKeysOf<BaseType extends object> = Exclude<\n {\n [Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]>\n ? Key\n : never;\n }[keyof BaseType],\n undefined\n>;\n\n/**\n * Returns a boolean for whether the two given types are equal.\n *\n * @remarks\n * Use-cases: If you want to make a conditional branch based on the result of a comparison of two types.\n *\n * @see https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650\n * @see https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796\n */\nexport type IsEqual<A, B> =\n (<G>() => G extends A ? 1 : 2) extends <G>() => G extends B ? 1 : 2\n ? true\n : false;\n\nexport type Filter<KeyType, ExcludeType> =\n IsEqual<KeyType, ExcludeType> extends true\n ? never\n : KeyType extends ExcludeType\n ? never\n : KeyType;\n\ninterface ExceptOptions {\n /**\n Disallow assigning non-specified properties.\n\n Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.\n\n @defaultValue false\n */\n requireExactProps?: boolean;\n}\n\n/**\n * Create a type from an object type without certain keys.\n *\n * @remarks\n * We recommend setting the `requireExactProps` option to `true`.\n *\n * This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.\n *\n * This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).\n */\nexport type Except<\n ObjectType,\n KeysType extends keyof ObjectType,\n Options extends ExceptOptions = { requireExactProps: false }\n> = {\n [KeyType in keyof ObjectType as Filter<\n KeyType,\n KeysType\n >]: ObjectType[KeyType];\n} & (Options[\"requireExactProps\"] extends true\n ? Partial<Record<KeysType, never>>\n : Record<string, never>);\n\n/**\n * Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.\n *\n * @remarks\n * Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.\n *\n * If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.\n *\n * @see https://github.com/microsoft/TypeScript/issues/15300\n */\nexport type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};\n\n/**\n * Create a type that makes the given keys required. The remaining keys are kept as is. The sister of the `SetOptional` type.\n *\n * @remarks\n * Use-case: You want to define a single model where the only thing that changes is whether or not some of the keys are required.\n */\nexport type SetRequired<\n BaseType,\n Keys extends keyof BaseType\n> = BaseType extends unknown // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types). // union into a [distributive conditional // `extends unknown` is always going to be the case and is used to convert any\n ? Simplify<\n // Pick just the keys that are optional from the base type.\n Except<BaseType, Keys> &\n // Pick the keys that should be required from the base type and make them required.\n Required<Pick<BaseType, Keys>>\n >\n : never;\n\nexport const $NestedValue: unique symbol = Symbol(\"NestedValue\");\n\nexport type NestedValue<TValue extends object = object> = {\n [$NestedValue]: never;\n} & TValue;\n\nexport interface RefObject<T> {\n current: T;\n}\n\nexport interface Identity<T = string> {\n id: T;\n}\n\nexport interface Versioned {\n version: number;\n}\n\nexport interface Sequenced {\n /**\n * The sequence number (version, or event counter, etc.) of the record\n */\n sequence: number;\n}\n\nexport interface Typed {\n /**\n * The type of the record\n */\n __type: string;\n}\n\nexport interface ClassTypeCheckable<T> extends Typed {\n /**\n * Run type check on the given value\n * @param value - The value to check\n * @returns True if the value is of the type of the class\n */\n isTypeOf: (value: unknown) => value is T;\n}\n\n/**\n * Matches non-recursive types.\n */\nexport type NonRecursiveType =\n | BuiltIns\n // eslint-disable-next-line ts/no-unsafe-function-type\n | Function\n | (new (...arguments_: any[]) => unknown);\n\nexport type IsPrimitive<T> = [T] extends [Primitive] ? true : false;\nexport type IsNever<T> = [T] extends [never] ? true : false;\nexport type IsAny<T> = 0 extends 1 & T ? true : false;\nexport type IsNull<T> = [T] extends [null] ? true : false;\nexport type IsUndefined<T> = T extends undefined ? true : false;\nexport type IsUnknown<T> = unknown extends T // `T` can be `unknown` or `any`\n ? IsNull<T> extends false // `any` can be `null`, but `unknown` can't be\n ? true\n : false\n : false;\nexport type IsNullish<T> = IsNull<T> & IsUndefined<T>;\nexport type IsFunction<T> = T extends AnyFunction ? true : false;\n\n/**\n * Declare locally scoped properties on `globalThis`.\n *\n * When defining a global variable in a declaration file is inappropriate, it can be helpful to define a `type` or `interface` (say `ExtraGlobals`) with the global variable and then cast `globalThis` via code like `globalThis as unknown as ExtraGlobals`.\n *\n * Instead of casting through `unknown`, you can update your `type` or `interface` to extend `GlobalThis` and then directly cast `globalThis`.\n *\n * @example\n * ```\n * import type { GlobalThis } from '@stryke/types';\n *\n * type ExtraGlobals = GlobalThis & {\n * readonly GLOBAL_TOKEN: string;\n * };\n *\n * (globalThis as ExtraGlobals).GLOBAL_TOKEN;\n * ```\n */\nexport type GlobalThis = typeof globalThis;\n\n/**\n * Matches a [`class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).\n */\nexport interface Class<T, Arguments extends unknown[] = any[]> {\n prototype: Pick<T, keyof T>;\n new (...arguments_: Arguments): T;\n}\n\n/**\n * Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).\n */\nexport type Constructor<T, Arguments extends unknown[] = any[]> = new (\n ...arguments_: Arguments\n) => T;\n\n/**\n * Matches an [`abstract class`](https://www.typescriptlang.org/docs/handbook/classes.html#abstract-classes).\n *\n * @privateRemarks\n * We cannot use a `type` here because TypeScript throws: 'abstract' modifier cannot appear on a type member. (1070)\n */\n\nexport interface AbstractClass<\n T,\n Arguments extends unknown[] = any[]\n> extends AbstractConstructor<T, Arguments> {\n prototype: Pick<T, keyof T>;\n}\n\n/**\n * Matches an [`abstract class`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-2.html#abstract-construct-signatures) constructor.\n */\nexport type AbstractConstructor<\n T,\n Arguments extends unknown[] = any[]\n> = abstract new (...arguments_: Arguments) => T;\n\n/**\n * Create a tuple type of the given length `<L>` and fill it with the given type `<Fill>`.\n *\n * If `<Fill>` is not provided, it will default to `unknown`.\n *\n * @see https://itnext.io/implementing-arithmetic-within-typescripts-type-system-a1ef140a6f6f\n */\nexport type BuildTuple<\n L extends number,\n Fill = unknown,\n T extends readonly unknown[] = []\n> = T[\"length\"] extends L ? T : BuildTuple<L, Fill, [...T, Fill]>;\n\n/**\n * Test if the given function has multiple call signatures.\n *\n * Needed to handle the case of a single call signature with properties.\n *\n * Multiple call signatures cannot currently be supported due to a TypeScript limitation.\n * @see https://github.com/microsoft/TypeScript/issues/29732\n */\nexport type HasMultipleCallSignatures<\n T extends (...arguments_: any[]) => unknown\n> = T extends {\n (...arguments_: infer A): unknown;\n (...arguments_: infer B): unknown;\n}\n ? B extends A\n ? A extends B\n ? false\n : true\n : true\n : false;\n\ntype StructuredCloneablePrimitive =\n | string\n | number\n | bigint\n | boolean\n | null\n | undefined\n | boolean\n | number\n | string;\n\ntype StructuredCloneableData =\n | ArrayBuffer\n | DataView\n | Date\n | Error\n | RegExp\n | TypedArray\n | Blob\n | File;\n\n// DOM exclusive types\n// | AudioData\n// | CropTarget\n// | CryptoKey\n// | DOMException\n// | DOMMatrix\n// | DOMMatrixReadOnly\n// | DOMPoint\n// | DOMPointReadOnly\n// | DOMQuad\n// | DOMRect\n// | DOMRectReadOnly\n// | FileList\n// | FileSystemDirectoryHandle\n// | FileSystemFileHandle\n// | FileSystemHandle\n// | GPUCompilationInfo\n// | GPUCompilationMessage\n// | ImageBitmap\n// | ImageData\n// | RTCCertificate\n// | VideoFrame\n\ntype StructuredCloneableCollection =\n | readonly StructuredCloneable[]\n | {\n readonly [key: string]: StructuredCloneable;\n readonly [key: number]: StructuredCloneable;\n }\n | ReadonlyMap<StructuredCloneable, StructuredCloneable>\n | ReadonlySet<StructuredCloneable>;\n\n/**\n * Matches a value that can be losslessly cloned using `structuredClone`.\n *\n * Note:\n * - Custom error types will be cloned as the base `Error` type\n * - This type doesn't include types exclusive to the TypeScript DOM library (e.g. `DOMRect` and `VideoFrame`)\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm\n *\n * @example\n * ```\n * import type { StructuredCloneable } from '@stryke/types';\n *\n * class CustomClass {}\n *\n * // @ts-expect-error\n * const error: StructuredCloneable = {\n * custom: new CustomClass(),\n * };\n *\n * structuredClone(error);\n * //=> {custom: {}}\n *\n * const good: StructuredCloneable = {\n * number: 3,\n * date: new Date(),\n * map: new Map<string, number>(),\n * }\n *\n * good.map.set('key', 1);\n *\n * structuredClone(good);\n * //=> {number: 3, date: Date(2022-10-17 22:22:35.920), map: Map {'key' -> 1}}\n * ```\n */\nexport type StructuredCloneable =\n | StructuredCloneablePrimitive\n | StructuredCloneableData\n | StructuredCloneableCollection;\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { EMPTY_STRING } from \"@stryke/types/base\";\n\nconst singleComment = Symbol(\"singleComment\");\nconst multiComment = Symbol(\"multiComment\");\n\nfunction stripWithoutWhitespace() {\n return \"\";\n}\nfunction stripWithWhitespace(value: string, start?: number, end?: number) {\n return value.slice(start, end).replace(/\\S/g, \" \");\n}\n\nfunction isEscaped(value: string, quotePosition: number) {\n let index = quotePosition - 1;\n let backslashCount = 0;\n while (value[index] === \"\\\\\") {\n index -= 1;\n backslashCount += 1;\n }\n\n return Boolean(backslashCount % 2);\n}\n\nexport function stripComments(\n value: string,\n { whitespace = true, trailingCommas = false } = {}\n) {\n if (typeof value !== \"string\") {\n throw new TypeError(\n `Expected argument \\`jsonString\\` to be a \\`string\\`, got \\`${typeof value}\\``\n );\n }\n\n const strip = whitespace ? stripWithWhitespace : stripWithoutWhitespace;\n let isInsideString: boolean | symbol = false;\n let isInsideComment: boolean | symbol = false;\n let offset = 0;\n let buffer = \"\";\n let result = \"\";\n let commaIndex = -1;\n for (let index = 0; index < value.length; index++) {\n const currentCharacter = value[index];\n const nextCharacter = value[index + 1];\n if (!isInsideComment && currentCharacter === '\"') {\n const escaped = isEscaped(value, index);\n if (!escaped) {\n isInsideString = !isInsideString;\n }\n }\n if (isInsideString) {\n continue;\n }\n if (\n !isInsideComment &&\n currentCharacter + (nextCharacter ?? EMPTY_STRING) === \"//\"\n ) {\n buffer += value.slice(offset, index);\n offset = index;\n isInsideComment = singleComment;\n index++;\n } else if (\n isInsideComment === singleComment &&\n currentCharacter + (nextCharacter ?? EMPTY_STRING) === \"\\r\\n\"\n ) {\n index++;\n isInsideComment = false;\n buffer += strip(value, offset, index);\n offset = index;\n } else if (isInsideComment === singleComment && currentCharacter === \"\\n\") {\n isInsideComment = false;\n buffer += strip(value, offset, index);\n offset = index;\n } else if (\n !isInsideComment &&\n currentCharacter + (nextCharacter ?? EMPTY_STRING) === \"/*\"\n ) {\n buffer += value.slice(offset, index);\n offset = index;\n isInsideComment = multiComment;\n index++;\n } else if (\n isInsideComment === multiComment &&\n currentCharacter + (nextCharacter ?? EMPTY_STRING) === \"*/\"\n ) {\n index++;\n isInsideComment = false;\n buffer += strip(value, offset, index + 1);\n offset = index + 1;\n } else if (trailingCommas && !isInsideComment) {\n if (commaIndex !== -1) {\n if (currentCharacter === \"}\" || currentCharacter === \"]\") {\n buffer += value.slice(offset, index);\n result += strip(buffer, 0, 1) + buffer.slice(1);\n buffer = \"\";\n offset = index;\n commaIndex = -1;\n } else if (\n currentCharacter !== \" \" &&\n currentCharacter !== \"\t\" &&\n currentCharacter !== \"\\r\" &&\n currentCharacter !== \"\\n\"\n ) {\n buffer += value.slice(offset, index);\n offset = index;\n commaIndex = -1;\n }\n } else if (currentCharacter === \",\") {\n result += buffer + value.slice(offset, index);\n buffer = \"\";\n offset = index;\n commaIndex = index;\n }\n }\n }\n\n return (\n result +\n buffer +\n (isInsideComment ? strip(value.slice(offset)) : value.slice(offset))\n );\n}\n"],"mappings":"AAsJA,MClIM,EAAgB,OAAO,gBAAgB,CACvC,EAAe,OAAO,eAAe,CAE3C,SAAS,GAAyB,CAChC,MAAO,GAET,SAAS,EAAoB,EAAe,EAAgB,EAAc,CACxE,OAAO,EAAM,MAAM,EAAO,EAAI,CAAC,QAAQ,MAAO,IAAI,CAGpD,SAAS,EAAU,EAAe,EAAuB,CACvD,IAAI,EAAQ,EAAgB,EACxB,EAAiB,EACrB,KAAO,EAAM,KAAW,MACtB,IACA,GAAkB,EAGpB,MAAO,GAAQ,EAAiB,GAGlC,SAAgB,EACd,EACA,CAAE,aAAa,GAAM,iBAAiB,IAAU,EAAE,CAClD,CACA,GAAI,OAAO,GAAU,SACnB,MAAU,UACR,8DAA8D,OAAO,EAAM,IAC5E,CAGH,IAAM,EAAQ,EAAa,EAAsB,EAC7CA,EAAmC,GACnCC,EAAoC,GACpC,EAAS,EACT,EAAS,GACT,EAAS,GACT,EAAa,GACjB,IAAK,IAAI,EAAQ,EAAG,EAAQ,EAAM,OAAQ,IAAS,CACjD,IAAM,EAAmB,EAAM,GACzB,EAAgB,EAAM,EAAQ,GAChC,CAAC,GAAmB,IAAqB,MAC3B,EAAU,EAAO,EAAM,GAErC,EAAiB,CAAC,IAGlB,KAIF,CAAC,GACD,GAAoB,GAAiB,MAAkB,MAEvD,GAAU,EAAM,MAAM,EAAQ,EAAM,CACpC,EAAS,EACT,EAAkB,EAClB,KAEA,IAAoB,GACpB,GAAoB,GAAiB,MAAkB;GAEvD,IACA,EAAkB,GAClB,GAAU,EAAM,EAAO,EAAQ,EAAM,CACrC,EAAS,GACA,IAAoB,GAAiB,IAAqB;GACnE,EAAkB,GAClB,GAAU,EAAM,EAAO,EAAQ,EAAM,CACrC,EAAS,GAET,CAAC,GACD,GAAoB,GAAiB,MAAkB,MAEvD,GAAU,EAAM,MAAM,EAAQ,EAAM,CACpC,EAAS,EACT,EAAkB,EAClB,KAEA,IAAoB,GACpB,GAAoB,GAAiB,MAAkB,MAEvD,IACA,EAAkB,GAClB,GAAU,EAAM,EAAO,EAAQ,EAAQ,EAAE,CACzC,EAAS,EAAQ,GACR,GAAkB,CAAC,IACxB,IAAe,GAiBR,IAAqB,MAC9B,GAAU,EAAS,EAAM,MAAM,EAAQ,EAAM,CAC7C,EAAS,GACT,EAAS,EACT,EAAa,GApBT,IAAqB,KAAO,IAAqB,KACnD,GAAU,EAAM,MAAM,EAAQ,EAAM,CACpC,GAAU,EAAM,EAAQ,EAAG,EAAE,CAAG,EAAO,MAAM,EAAE,CAC/C,EAAS,GACT,EAAS,EACT,EAAa,IAEb,IAAqB,KACrB,IAAqB,KACrB,IAAqB,MACrB,IAAqB;IAErB,GAAU,EAAM,MAAM,EAAQ,EAAM,CACpC,EAAS,EACT,EAAa,MAWrB,OACE,EACA,GACC,EAAkB,EAAM,EAAM,MAAM,EAAO,CAAC,CAAG,EAAM,MAAM,EAAO"}
|