@stryke/json 0.9.44 → 0.11.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.
Files changed (204) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/code-frames-BUtrssZ5.d.cts +17 -0
  3. package/dist/code-frames-BUtrssZ5.d.cts.map +1 -0
  4. package/dist/code-frames-BmUvlJ0w.cjs +82 -0
  5. package/dist/code-frames-CrTAYYSE.d.mts +17 -0
  6. package/dist/code-frames-CrTAYYSE.d.mts.map +1 -0
  7. package/dist/code-frames-DuBfTMu4.mjs +77 -0
  8. package/dist/code-frames-DuBfTMu4.mjs.map +1 -0
  9. package/dist/find-reference-B8xshNXL.d.mts +52 -0
  10. package/dist/find-reference-B8xshNXL.d.mts.map +1 -0
  11. package/dist/find-reference-C-YleCds.d.cts +52 -0
  12. package/dist/find-reference-C-YleCds.d.cts.map +1 -0
  13. package/dist/find-reference-DMSYEaaI.mjs +64 -0
  14. package/dist/find-reference-DMSYEaaI.mjs.map +1 -0
  15. package/dist/find-reference-De5vBQV2.cjs +86 -0
  16. package/dist/index-B_e8BwCm.d.cts +1 -0
  17. package/dist/index-CCt0lwyI.d.mts +1 -0
  18. package/dist/index-CDAfh8Ew.d.cts +1 -0
  19. package/dist/index-DvuJXuAN.d.mts +1 -0
  20. package/dist/index.cjs +37 -14
  21. package/dist/index.d.cts +11 -8
  22. package/dist/index.d.mts +12 -9
  23. package/dist/index.mjs +13 -8
  24. package/dist/is-number-BIwzZzyi.mjs +31 -0
  25. package/dist/is-number-BIwzZzyi.mjs.map +1 -0
  26. package/dist/is-number-c5xguIbS.cjs +42 -0
  27. package/dist/{type-checks/src/is-plain-object.mjs → is-object-BpfmzHWa.mjs} +19 -3
  28. package/dist/is-object-BpfmzHWa.mjs.map +1 -0
  29. package/dist/{type-checks/src/is-plain-object.cjs → is-object-umGh91v1.cjs} +24 -3
  30. package/dist/is-set-object-BmHip9em.cjs +108 -0
  31. package/dist/is-set-object-C1Qnj1Q8.mjs +98 -0
  32. package/dist/is-set-object-C1Qnj1Q8.mjs.map +1 -0
  33. package/dist/{type-checks/src/is-string.mjs → is-string-C2RK4Gjs.cjs} +7 -2
  34. package/dist/{type-checks/src/is-string.cjs → is-string-CLiBUSKV.mjs} +2 -2
  35. package/dist/is-string-CLiBUSKV.mjs.map +1 -0
  36. package/dist/{type-checks/src/is-undefined.cjs → is-undefined-CmyJWYGD.mjs} +2 -2
  37. package/dist/is-undefined-CmyJWYGD.mjs.map +1 -0
  38. package/dist/{type-checks/src/is-undefined.mjs → is-undefined-CnI0qe-z.cjs} +7 -2
  39. package/dist/parse-BGlhbY16.d.cts +9 -0
  40. package/dist/parse-BGlhbY16.d.cts.map +1 -0
  41. package/dist/parse-Bp6kkcQ4.cjs +127 -0
  42. package/dist/parse-ByDxRup5.cjs +62 -0
  43. package/dist/parse-Cj-YfhrI.d.mts +51 -0
  44. package/dist/parse-Cj-YfhrI.d.mts.map +1 -0
  45. package/dist/parse-DZfi3d96.d.cts +51 -0
  46. package/dist/parse-DZfi3d96.d.cts.map +1 -0
  47. package/dist/parse-Dn43ZK9y.mjs +52 -0
  48. package/dist/parse-Dn43ZK9y.mjs.map +1 -0
  49. package/dist/parse-error-7K8s4vWf.d.cts +15 -0
  50. package/dist/parse-error-7K8s4vWf.d.cts.map +1 -0
  51. package/dist/parse-error-Af4zHUQ_.mjs +34 -0
  52. package/dist/parse-error-Af4zHUQ_.mjs.map +1 -0
  53. package/dist/parse-error-DpEv3vo_.d.mts +15 -0
  54. package/dist/parse-error-DpEv3vo_.d.mts.map +1 -0
  55. package/dist/parse-error-N7UE-HMh.cjs +39 -0
  56. package/dist/parse-fXy5pbmE.d.mts +9 -0
  57. package/dist/parse-fXy5pbmE.d.mts.map +1 -0
  58. package/dist/parse-vw_qRD3F.mjs +81 -0
  59. package/dist/parse-vw_qRD3F.mjs.map +1 -0
  60. package/dist/pointer/find-reference.cjs +5 -65
  61. package/dist/pointer/find-reference.d.cts +2 -52
  62. package/dist/pointer/find-reference.d.mts +2 -52
  63. package/dist/pointer/find-reference.mjs +2 -63
  64. package/dist/pointer/index.cjs +15 -14
  65. package/dist/pointer/index.d.cts +2 -2
  66. package/dist/pointer/index.d.mts +2 -2
  67. package/dist/pointer/index.mjs +3 -2
  68. package/dist/pointer/parse.cjs +9 -86
  69. package/dist/pointer/parse.d.cts +2 -44
  70. package/dist/pointer/parse.d.mts +2 -44
  71. package/dist/pointer/parse.mjs +2 -80
  72. package/dist/pointer-B3W_Sme3.cjs +0 -0
  73. package/dist/pointer-Dn__XOdY.mjs +0 -0
  74. package/dist/schema-BO1HCrxv.d.cts +55 -0
  75. package/dist/schema-BO1HCrxv.d.cts.map +1 -0
  76. package/dist/schema-CmH1V_uI.d.mts +55 -0
  77. package/dist/schema-CmH1V_uI.d.mts.map +1 -0
  78. package/dist/schema-DGmzxHja.mjs +72 -0
  79. package/dist/schema-DGmzxHja.mjs.map +1 -0
  80. package/dist/schema-Dl018Aq4.cjs +106 -0
  81. package/dist/schema.cjs +8 -0
  82. package/dist/schema.d.cts +2 -0
  83. package/dist/schema.d.mts +3 -0
  84. package/dist/schema.mjs +3 -0
  85. package/dist/storm-json-8F9CKpXu.d.mts +70 -0
  86. package/dist/storm-json-8F9CKpXu.d.mts.map +1 -0
  87. package/dist/storm-json-BD6WFbrI.cjs +154 -0
  88. package/dist/storm-json-DvIEWMEH.d.cts +70 -0
  89. package/dist/storm-json-DvIEWMEH.d.cts.map +1 -0
  90. package/dist/storm-json-nkhJgTz4.mjs +116 -0
  91. package/dist/storm-json-nkhJgTz4.mjs.map +1 -0
  92. package/dist/storm-json.cjs +3 -116
  93. package/dist/storm-json.d.cts +2 -70
  94. package/dist/storm-json.d.mts +3 -70
  95. package/dist/storm-json.mjs +3 -115
  96. package/dist/stringify-Bc8OkhIr.d.cts +13 -0
  97. package/dist/stringify-Bc8OkhIr.d.cts.map +1 -0
  98. package/dist/stringify-BehjrfhS.cjs +78 -0
  99. package/dist/stringify-CFT1K1LE.d.mts +13 -0
  100. package/dist/stringify-CFT1K1LE.d.mts.map +1 -0
  101. package/dist/stringify-CYHjAvWm.mjs +68 -0
  102. package/dist/stringify-CYHjAvWm.mjs.map +1 -0
  103. package/dist/strip-comments-BA8MS_Fs.d.mts +11 -0
  104. package/dist/strip-comments-BA8MS_Fs.d.mts.map +1 -0
  105. package/dist/strip-comments-CmEG_smS.cjs +94 -0
  106. package/dist/strip-comments-Cz_Wc25t.d.cts +11 -0
  107. package/dist/strip-comments-Cz_Wc25t.d.cts.map +1 -0
  108. package/dist/strip-comments-Dq00N_Sg.mjs +89 -0
  109. package/dist/strip-comments-Dq00N_Sg.mjs.map +1 -0
  110. package/dist/types-Bn8rC098.d.cts +222 -0
  111. package/dist/types-Bn8rC098.d.cts.map +1 -0
  112. package/dist/types-CPQlxauZ.d.mts +222 -0
  113. package/dist/types-CPQlxauZ.d.mts.map +1 -0
  114. package/dist/types.d.cts +2 -69
  115. package/dist/types.d.mts +2 -69
  116. package/dist/types.mjs +0 -1
  117. package/dist/utils/code-frames.cjs +2 -76
  118. package/dist/utils/code-frames.d.cts +2 -17
  119. package/dist/utils/code-frames.d.mts +2 -17
  120. package/dist/utils/code-frames.mjs +2 -76
  121. package/dist/utils/index.cjs +13 -12
  122. package/dist/utils/index.d.cts +5 -5
  123. package/dist/utils/index.d.mts +6 -5
  124. package/dist/utils/index.mjs +6 -5
  125. package/dist/utils/parse-error.cjs +2 -33
  126. package/dist/utils/parse-error.d.cts +2 -15
  127. package/dist/utils/parse-error.d.mts +2 -15
  128. package/dist/utils/parse-error.mjs +2 -33
  129. package/dist/utils/parse.cjs +3 -51
  130. package/dist/utils/parse.d.cts +2 -9
  131. package/dist/utils/parse.d.mts +2 -9
  132. package/dist/utils/parse.mjs +2 -51
  133. package/dist/utils/stringify.cjs +3 -67
  134. package/dist/utils/stringify.d.cts +2 -13
  135. package/dist/utils/stringify.d.mts +2 -13
  136. package/dist/utils/stringify.mjs +2 -67
  137. package/dist/utils/strip-comments.cjs +2 -85
  138. package/dist/utils/strip-comments.d.cts +2 -11
  139. package/dist/utils/strip-comments.d.mts +2 -11
  140. package/dist/utils/strip-comments.mjs +2 -86
  141. package/dist/utils-jN2UkvqB.cjs +0 -0
  142. package/dist/utils-mEkKIcgl.mjs +0 -0
  143. package/package.json +12 -3
  144. package/dist/_virtual/rolldown_runtime.cjs +0 -29
  145. package/dist/pointer/find-reference.d.cts.map +0 -1
  146. package/dist/pointer/find-reference.d.mts.map +0 -1
  147. package/dist/pointer/find-reference.mjs.map +0 -1
  148. package/dist/pointer/parse.d.cts.map +0 -1
  149. package/dist/pointer/parse.d.mts.map +0 -1
  150. package/dist/pointer/parse.mjs.map +0 -1
  151. package/dist/storm-json.d.cts.map +0 -1
  152. package/dist/storm-json.d.mts.map +0 -1
  153. package/dist/storm-json.mjs.map +0 -1
  154. package/dist/type-checks/src/get-object-tag.cjs +0 -15
  155. package/dist/type-checks/src/get-object-tag.mjs +0 -15
  156. package/dist/type-checks/src/get-object-tag.mjs.map +0 -1
  157. package/dist/type-checks/src/is-empty.cjs +0 -20
  158. package/dist/type-checks/src/is-empty.mjs +0 -21
  159. package/dist/type-checks/src/is-empty.mjs.map +0 -1
  160. package/dist/type-checks/src/is-non-null-object.cjs +0 -16
  161. package/dist/type-checks/src/is-non-null-object.mjs +0 -17
  162. package/dist/type-checks/src/is-non-null-object.mjs.map +0 -1
  163. package/dist/type-checks/src/is-null.cjs +0 -12
  164. package/dist/type-checks/src/is-null.mjs +0 -12
  165. package/dist/type-checks/src/is-null.mjs.map +0 -1
  166. package/dist/type-checks/src/is-number.cjs +0 -18
  167. package/dist/type-checks/src/is-number.mjs +0 -18
  168. package/dist/type-checks/src/is-number.mjs.map +0 -1
  169. package/dist/type-checks/src/is-object.cjs +0 -19
  170. package/dist/type-checks/src/is-object.mjs +0 -20
  171. package/dist/type-checks/src/is-object.mjs.map +0 -1
  172. package/dist/type-checks/src/is-plain-object.mjs.map +0 -1
  173. package/dist/type-checks/src/is-set-object.cjs +0 -19
  174. package/dist/type-checks/src/is-set-object.mjs +0 -20
  175. package/dist/type-checks/src/is-set-object.mjs.map +0 -1
  176. package/dist/type-checks/src/is-set.cjs +0 -19
  177. package/dist/type-checks/src/is-set.mjs +0 -20
  178. package/dist/type-checks/src/is-set.mjs.map +0 -1
  179. package/dist/type-checks/src/is-string.mjs.map +0 -1
  180. package/dist/type-checks/src/is-undefined.mjs.map +0 -1
  181. package/dist/types/src/base.cjs +0 -6
  182. package/dist/types/src/base.mjs +0 -6
  183. package/dist/types/src/base.mjs.map +0 -1
  184. package/dist/types/src/json.d.cts +0 -12
  185. package/dist/types/src/json.d.cts.map +0 -1
  186. package/dist/types/src/json.d.mts +0 -12
  187. package/dist/types/src/json.d.mts.map +0 -1
  188. package/dist/types.d.cts.map +0 -1
  189. package/dist/types.d.mts.map +0 -1
  190. package/dist/utils/code-frames.d.cts.map +0 -1
  191. package/dist/utils/code-frames.d.mts.map +0 -1
  192. package/dist/utils/code-frames.mjs.map +0 -1
  193. package/dist/utils/parse-error.d.cts.map +0 -1
  194. package/dist/utils/parse-error.d.mts.map +0 -1
  195. package/dist/utils/parse-error.mjs.map +0 -1
  196. package/dist/utils/parse.d.cts.map +0 -1
  197. package/dist/utils/parse.d.mts.map +0 -1
  198. package/dist/utils/parse.mjs.map +0 -1
  199. package/dist/utils/stringify.d.cts.map +0 -1
  200. package/dist/utils/stringify.d.mts.map +0 -1
  201. package/dist/utils/stringify.mjs.map +0 -1
  202. package/dist/utils/strip-comments.d.cts.map +0 -1
  203. package/dist/utils/strip-comments.d.mts.map +0 -1
  204. package/dist/utils/strip-comments.mjs.map +0 -1
@@ -1,117 +1,4 @@
1
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
- const require_is_object = require('./type-checks/src/is-object.cjs');
3
- const require_is_string = require('./type-checks/src/is-string.cjs');
4
- const require_utils_parse = require('./utils/parse.cjs');
5
- const require_utils_parse_error = require('./utils/parse-error.cjs');
6
- const require_utils_stringify = require('./utils/stringify.cjs');
7
- let jsonc_parser = require("jsonc-parser");
8
- let node_buffer = require("node:buffer");
9
- let superjson = require("superjson");
10
- superjson = require_rolldown_runtime.__toESM(superjson);
1
+ const require_storm_json = require('./storm-json-BD6WFbrI.cjs');
2
+ require('./parse-error-N7UE-HMh.cjs');
11
3
 
12
- //#region src/storm-json.ts
13
- /**
14
- * A static JSON parser class used by Storm Software to serialize and deserialize JSON data
15
- *
16
- * @remarks
17
- * This class uses the [SuperJSON](https://github.com/blitz-js/superjson) library under the hood.
18
- */
19
- var StormJSON = class StormJSON extends superjson.default {
20
- static #instance;
21
- static get instance() {
22
- if (!StormJSON.#instance) StormJSON.#instance = new StormJSON();
23
- return StormJSON.#instance;
24
- }
25
- /**
26
- * Deserialize the given value with superjson using the given metadata
27
- */
28
- static deserialize(payload) {
29
- return StormJSON.instance.deserialize(payload);
30
- }
31
- /**
32
- * Serialize the given value with superjson
33
- */
34
- static serialize(object) {
35
- return StormJSON.instance.serialize(object);
36
- }
37
- /**
38
- * Parse the given string value with superjson using the given metadata
39
- *
40
- * @param value - The string value to parse
41
- * @returns The parsed data
42
- */
43
- static parse(value) {
44
- return require_utils_parse.parse(value);
45
- }
46
- /**
47
- * Serializes the given data to a JSON string.
48
- * By default the JSON string is formatted with a 2 space indentation to be easy readable.
49
- *
50
- * @param value - Object which should be serialized to JSON
51
- * @param _options - JSON serialize options
52
- * @returns the formatted JSON representation of the object
53
- */
54
- static stringify(value, _options) {
55
- const customTransformer = StormJSON.instance.customTransformerRegistry.findApplicable(value);
56
- let result = value;
57
- if (customTransformer && customTransformer.isApplicable(value)) result = customTransformer.serialize(result);
58
- return require_utils_stringify.stringify(result);
59
- }
60
- /**
61
- * Parses the given JSON string and returns the object the JSON content represents.
62
- * By default javascript-style comments and trailing commas are allowed.
63
- *
64
- * @param strData - JSON content as string
65
- * @param options - JSON parse options
66
- * @returns Object the JSON content represents
67
- */
68
- static parseJson(strData, options) {
69
- try {
70
- if (options?.expectComments === false) return StormJSON.instance.parse(strData);
71
- } catch {}
72
- const errors = [];
73
- const result = (0, jsonc_parser.parse)(strData, errors, {
74
- allowTrailingComma: true,
75
- ...options
76
- });
77
- if (errors.length > 0 && errors[0]) throw new Error(require_utils_parse_error.formatParseError(strData, errors[0]));
78
- return result;
79
- }
80
- /**
81
- * Register a custom schema with superjson
82
- *
83
- * @param name - The name of the schema
84
- * @param serialize - The function to serialize the schema
85
- * @param deserialize - The function to deserialize the schema
86
- * @param isApplicable - The function to check if the schema is applicable
87
- */
88
- static register(name, serialize, deserialize, isApplicable) {
89
- StormJSON.instance.registerCustom({
90
- isApplicable,
91
- serialize,
92
- deserialize
93
- }, name);
94
- }
95
- /**
96
- * Register a class with superjson
97
- *
98
- * @param classConstructor - The class constructor to register
99
- */
100
- static registerClass(classConstructor, options) {
101
- StormJSON.instance.registerClass(classConstructor, {
102
- identifier: require_is_string.isString(options) ? options : options?.identifier || classConstructor.name,
103
- allowProps: options && require_is_object.isObject(options) && options?.allowProps && Array.isArray(options.allowProps) ? options.allowProps : ["__typename"]
104
- });
105
- }
106
- constructor() {
107
- super({ dedupe: true });
108
- }
109
- };
110
- StormJSON.instance.registerCustom({
111
- isApplicable: (v) => node_buffer.Buffer.isBuffer(v),
112
- serialize: (v) => v.toString("base64"),
113
- deserialize: (v) => node_buffer.Buffer.from(v, "base64")
114
- }, "Bytes");
115
-
116
- //#endregion
117
- exports.StormJSON = StormJSON;
4
+ exports.StormJSON = require_storm_json.StormJSON;
@@ -1,70 +1,2 @@
1
- import { Class, JsonParseOptions, JsonParserResult, JsonSerializeOptions, JsonValue } from "./types.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 };
70
- //# sourceMappingURL=storm-json.d.cts.map
1
+ import { t as StormJSON } from "./storm-json-DvIEWMEH.cjs";
2
+ export { StormJSON };
@@ -1,70 +1,3 @@
1
- import { Class, JsonParseOptions, JsonParserResult, JsonSerializeOptions, JsonValue } from "./types.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 };
70
- //# sourceMappingURL=storm-json.d.mts.map
1
+ import "./types-CPQlxauZ.mjs";
2
+ import { t as StormJSON } from "./storm-json-8F9CKpXu.mjs";
3
+ export { StormJSON };
@@ -1,116 +1,4 @@
1
- import { isObject } from "./type-checks/src/is-object.mjs";
2
- import { isString } from "./type-checks/src/is-string.mjs";
3
- import { parse as parse$1 } from "./utils/parse.mjs";
4
- import { formatParseError } from "./utils/parse-error.mjs";
5
- import { stringify } from "./utils/stringify.mjs";
6
- import { parse } from "jsonc-parser";
7
- import { Buffer } from "node:buffer";
8
- import SuperJSON from "superjson";
1
+ import "./parse-error-Af4zHUQ_.mjs";
2
+ import { t as StormJSON } from "./storm-json-nkhJgTz4.mjs";
9
3
 
10
- //#region src/storm-json.ts
11
- /**
12
- * A static JSON parser class used by Storm Software to serialize and deserialize JSON data
13
- *
14
- * @remarks
15
- * This class uses the [SuperJSON](https://github.com/blitz-js/superjson) library under the hood.
16
- */
17
- var StormJSON = class StormJSON extends SuperJSON {
18
- static #instance;
19
- static get instance() {
20
- if (!StormJSON.#instance) StormJSON.#instance = new StormJSON();
21
- return StormJSON.#instance;
22
- }
23
- /**
24
- * Deserialize the given value with superjson using the given metadata
25
- */
26
- static deserialize(payload) {
27
- return StormJSON.instance.deserialize(payload);
28
- }
29
- /**
30
- * Serialize the given value with superjson
31
- */
32
- static serialize(object) {
33
- return StormJSON.instance.serialize(object);
34
- }
35
- /**
36
- * Parse the given string value with superjson using the given metadata
37
- *
38
- * @param value - The string value to parse
39
- * @returns The parsed data
40
- */
41
- static parse(value) {
42
- return parse$1(value);
43
- }
44
- /**
45
- * Serializes the given data to a JSON string.
46
- * By default the JSON string is formatted with a 2 space indentation to be easy readable.
47
- *
48
- * @param value - Object which should be serialized to JSON
49
- * @param _options - JSON serialize options
50
- * @returns the formatted JSON representation of the object
51
- */
52
- static stringify(value, _options) {
53
- const customTransformer = StormJSON.instance.customTransformerRegistry.findApplicable(value);
54
- let result = value;
55
- if (customTransformer && customTransformer.isApplicable(value)) result = customTransformer.serialize(result);
56
- return stringify(result);
57
- }
58
- /**
59
- * Parses the given JSON string and returns the object the JSON content represents.
60
- * By default javascript-style comments and trailing commas are allowed.
61
- *
62
- * @param strData - JSON content as string
63
- * @param options - JSON parse options
64
- * @returns Object the JSON content represents
65
- */
66
- static parseJson(strData, options) {
67
- try {
68
- if (options?.expectComments === false) return StormJSON.instance.parse(strData);
69
- } catch {}
70
- const errors = [];
71
- const result = parse(strData, errors, {
72
- allowTrailingComma: true,
73
- ...options
74
- });
75
- if (errors.length > 0 && errors[0]) throw new Error(formatParseError(strData, errors[0]));
76
- return result;
77
- }
78
- /**
79
- * Register a custom schema with superjson
80
- *
81
- * @param name - The name of the schema
82
- * @param serialize - The function to serialize the schema
83
- * @param deserialize - The function to deserialize the schema
84
- * @param isApplicable - The function to check if the schema is applicable
85
- */
86
- static register(name, serialize, deserialize, isApplicable) {
87
- StormJSON.instance.registerCustom({
88
- isApplicable,
89
- serialize,
90
- deserialize
91
- }, name);
92
- }
93
- /**
94
- * Register a class with superjson
95
- *
96
- * @param classConstructor - The class constructor to register
97
- */
98
- static registerClass(classConstructor, options) {
99
- StormJSON.instance.registerClass(classConstructor, {
100
- identifier: isString(options) ? options : options?.identifier || classConstructor.name,
101
- allowProps: options && isObject(options) && options?.allowProps && Array.isArray(options.allowProps) ? options.allowProps : ["__typename"]
102
- });
103
- }
104
- constructor() {
105
- super({ dedupe: true });
106
- }
107
- };
108
- StormJSON.instance.registerCustom({
109
- isApplicable: (v) => Buffer.isBuffer(v),
110
- serialize: (v) => v.toString("base64"),
111
- deserialize: (v) => Buffer.from(v, "base64")
112
- }, "Bytes");
113
-
114
- //#endregion
115
- export { StormJSON };
116
- //# sourceMappingURL=storm-json.mjs.map
4
+ export { StormJSON };
@@ -0,0 +1,13 @@
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-Bc8OkhIr.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stringify-Bc8OkhIr.d.cts","names":[],"sources":["../src/utils/stringify.ts"],"sourcesContent":[],"mappings":";cAqBa;AAAb;AA0CA;;;;;;cAAa"}
@@ -0,0 +1,78 @@
1
+ const require_is_number = require('./is-number-c5xguIbS.cjs');
2
+ const require_is_undefined = require('./is-undefined-CnI0qe-z.cjs');
3
+
4
+ //#region src/utils/stringify.ts
5
+ const invalidKeyChars = [
6
+ "@",
7
+ "/",
8
+ "#",
9
+ "$",
10
+ " ",
11
+ ":",
12
+ ";",
13
+ ",",
14
+ ".",
15
+ "!",
16
+ "?",
17
+ "&",
18
+ "=",
19
+ "+",
20
+ "-",
21
+ "*",
22
+ "%",
23
+ "^",
24
+ "~",
25
+ "|",
26
+ "\\",
27
+ "\"",
28
+ "'",
29
+ "`",
30
+ "{",
31
+ "}",
32
+ "[",
33
+ "]",
34
+ "(",
35
+ ")",
36
+ "<",
37
+ ">"
38
+ ];
39
+ /**
40
+ * Stringify a value to a JSON-like string.
41
+ *
42
+ * @param value - The value to stringify
43
+ * @param spacing - The spacing to use for the stringification
44
+ * @returns The stringified value
45
+ */
46
+ const stringify = (value, spacing = 2) => {
47
+ const space = require_is_number.isNumber(spacing) ? " ".repeat(spacing) : spacing;
48
+ switch (value) {
49
+ case null: return "null";
50
+ case void 0: return "\"undefined\"";
51
+ case true: return "true";
52
+ case false: return "false";
53
+ case Number.POSITIVE_INFINITY: return "infinity";
54
+ case Number.NEGATIVE_INFINITY: return "-infinity";
55
+ }
56
+ if (Array.isArray(value)) return `[${space}${value.map((v) => stringify(v, space)).join(`,${space}`)}${space}]`;
57
+ if (value instanceof Uint8Array) return value.toString();
58
+ switch (typeof value) {
59
+ case "number": return `${value}`;
60
+ case "string": return JSON.stringify(value);
61
+ case "object": return `{${space}${Object.keys(value).filter((key) => !require_is_undefined.isUndefined(value[key])).map((key) => `${invalidKeyChars.some((invalidKeyChar) => key.includes(invalidKeyChar)) ? `"${key}"` : key}: ${space}${stringify(value[key], space)}`).join(`,${space}`)}${space}}`;
62
+ default: return "null";
63
+ }
64
+ };
65
+
66
+ //#endregion
67
+ Object.defineProperty(exports, 'invalidKeyChars', {
68
+ enumerable: true,
69
+ get: function () {
70
+ return invalidKeyChars;
71
+ }
72
+ });
73
+ Object.defineProperty(exports, 'stringify', {
74
+ enumerable: true,
75
+ get: function () {
76
+ return stringify;
77
+ }
78
+ });
@@ -0,0 +1,13 @@
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-CFT1K1LE.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stringify-CFT1K1LE.d.mts","names":[],"sources":["../src/utils/stringify.ts"],"sourcesContent":[],"mappings":";cAqBa;AAAb;AA0CA;;;;;;cAAa"}
@@ -0,0 +1,68 @@
1
+ import { t as isNumber } from "./is-number-BIwzZzyi.mjs";
2
+ import { t as isUndefined } from "./is-undefined-CmyJWYGD.mjs";
3
+
4
+ //#region src/utils/stringify.ts
5
+ const invalidKeyChars = [
6
+ "@",
7
+ "/",
8
+ "#",
9
+ "$",
10
+ " ",
11
+ ":",
12
+ ";",
13
+ ",",
14
+ ".",
15
+ "!",
16
+ "?",
17
+ "&",
18
+ "=",
19
+ "+",
20
+ "-",
21
+ "*",
22
+ "%",
23
+ "^",
24
+ "~",
25
+ "|",
26
+ "\\",
27
+ "\"",
28
+ "'",
29
+ "`",
30
+ "{",
31
+ "}",
32
+ "[",
33
+ "]",
34
+ "(",
35
+ ")",
36
+ "<",
37
+ ">"
38
+ ];
39
+ /**
40
+ * Stringify a value to a JSON-like string.
41
+ *
42
+ * @param value - The value to stringify
43
+ * @param spacing - The spacing to use for the stringification
44
+ * @returns The stringified value
45
+ */
46
+ const stringify = (value, spacing = 2) => {
47
+ const space = isNumber(spacing) ? " ".repeat(spacing) : spacing;
48
+ switch (value) {
49
+ case null: return "null";
50
+ case void 0: return "\"undefined\"";
51
+ case true: return "true";
52
+ case false: return "false";
53
+ case Number.POSITIVE_INFINITY: return "infinity";
54
+ case Number.NEGATIVE_INFINITY: return "-infinity";
55
+ }
56
+ if (Array.isArray(value)) return `[${space}${value.map((v) => stringify(v, space)).join(`,${space}`)}${space}]`;
57
+ if (value instanceof Uint8Array) return value.toString();
58
+ switch (typeof value) {
59
+ case "number": return `${value}`;
60
+ case "string": return JSON.stringify(value);
61
+ case "object": return `{${space}${Object.keys(value).filter((key) => !isUndefined(value[key])).map((key) => `${invalidKeyChars.some((invalidKeyChar) => key.includes(invalidKeyChar)) ? `"${key}"` : key}: ${space}${stringify(value[key], space)}`).join(`,${space}`)}${space}}`;
62
+ default: return "null";
63
+ }
64
+ };
65
+
66
+ //#endregion
67
+ export { stringify as n, invalidKeyChars as t };
68
+ //# sourceMappingURL=stringify-CYHjAvWm.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stringify-CYHjAvWm.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":";;;;AAqBA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;;AASD,MAAa,aACX,OACA,UAA2B,MAChB;CACX,MAAM,QAAQ,SAAS,QAAQ,GAAG,IAAI,OAAO,QAAQ,GAAG;AAExD,SAAQ,OAAR;EACE,KAAK,KACH,QAAO;EAET,KAAK,OACH,QAAO;EAET,KAAK,KACH,QAAO;EAET,KAAK,MACH,QAAO;EAET,KAAK,OAAO,kBACV,QAAO;EAET,KAAK,OAAO,kBACV,QAAO;;AAIX,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,IAAI,QAAQ,MAAM,KAAI,MAAK,UAAU,GAAG,MAAM,CAAC,CAAC,KAAK,IAAI,QAAQ,GAAG,MAAM;AAEnF,KAAI,iBAAiB,WACnB,QAAO,MAAM,UAAU;AAIzB,SAAQ,OAAO,OAAf;EACE,KAAK,SACH,QAAO,GAAG;EAEZ,KAAK,SACH,QAAO,KAAK,UAAU,MAAM;EAE9B,KAAK,SAKH,QAAO,IAAI,QAJE,OAAO,KAAK,MAAgB,CAAC,QACxC,QAAO,CAAC,YAAa,MAAc,KAAK,CACzC,CAGE,KACC,QACE,GAAG,gBAAgB,MAAK,mBAAkB,IAAI,SAAS,eAAe,CAAC,GAAG,IAAI,IAAI,KAAK,IAAI,IAAI,QAAQ,UAAW,MAAc,MAAM,MAAM,GAC/I,CACA,KAAK,IAAI,QAAQ,GAAG,MAAM;EAE/B,QACE,QAAO"}
@@ -0,0 +1,11 @@
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-BA8MS_Fs.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strip-comments-BA8MS_Fs.d.mts","names":[],"sources":["../src/utils/strip-comments.ts"],"sourcesContent":[],"mappings":";iBAyCgB,aAAA;;;;EAAA,UAAA,CAAA,EAAA,OAAa,GAAA,SAEzB"}