@stryke/json 0.9.44 → 0.10.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 (201) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/code-frames-BMkA9i6j.d.mts +17 -0
  3. package/dist/code-frames-BMkA9i6j.d.mts.map +1 -0
  4. package/dist/code-frames-BUtrssZ5.d.cts +17 -0
  5. package/dist/code-frames-BUtrssZ5.d.cts.map +1 -0
  6. package/dist/code-frames-Cv8r5tSN.cjs +82 -0
  7. package/dist/code-frames-DISWdYL6.mjs +77 -0
  8. package/dist/code-frames-DISWdYL6.mjs.map +1 -0
  9. package/dist/find-reference-BCg3dQx1.cjs +157 -0
  10. package/dist/find-reference-C-YleCds.d.cts +52 -0
  11. package/dist/find-reference-C-YleCds.d.cts.map +1 -0
  12. package/dist/find-reference-b7rRdLFx.d.mts +52 -0
  13. package/dist/find-reference-b7rRdLFx.d.mts.map +1 -0
  14. package/dist/find-reference-woYMiWzN.mjs +135 -0
  15. package/dist/find-reference-woYMiWzN.mjs.map +1 -0
  16. package/dist/index-B_e8BwCm.d.cts +1 -0
  17. package/dist/index-CDAfh8Ew.d.cts +1 -0
  18. package/dist/index-DwO9IdNa.d.mts +1 -0
  19. package/dist/index-VWno75SQ.d.mts +1 -0
  20. package/dist/index.cjs +32 -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/{type-checks/src/is-string.mjs → is-string-C2RK4Gjs.cjs} +7 -2
  31. package/dist/{type-checks/src/is-string.cjs → is-string-CLiBUSKV.mjs} +2 -2
  32. package/dist/is-string-CLiBUSKV.mjs.map +1 -0
  33. package/dist/{type-checks/src/is-undefined.cjs → is-undefined-CmyJWYGD.mjs} +2 -2
  34. package/dist/is-undefined-CmyJWYGD.mjs.map +1 -0
  35. package/dist/{type-checks/src/is-undefined.mjs → is-undefined-CnI0qe-z.cjs} +7 -2
  36. package/dist/parse-BGlhbY16.d.cts +9 -0
  37. package/dist/parse-BGlhbY16.d.cts.map +1 -0
  38. package/dist/parse-Crgv3Nl1.mjs +81 -0
  39. package/dist/parse-Crgv3Nl1.mjs.map +1 -0
  40. package/dist/parse-DZfi3d96.d.cts +51 -0
  41. package/dist/parse-DZfi3d96.d.cts.map +1 -0
  42. package/dist/parse-DgYW5BBj.d.mts +9 -0
  43. package/dist/parse-DgYW5BBj.d.mts.map +1 -0
  44. package/dist/parse-KiRakdIR.cjs +127 -0
  45. package/dist/parse-ZRTh45ZI.d.mts +51 -0
  46. package/dist/parse-ZRTh45ZI.d.mts.map +1 -0
  47. package/dist/parse-error-7K8s4vWf.d.cts +15 -0
  48. package/dist/parse-error-7K8s4vWf.d.cts.map +1 -0
  49. package/dist/parse-error-C3Qmubee.mjs +34 -0
  50. package/dist/parse-error-C3Qmubee.mjs.map +1 -0
  51. package/dist/parse-error-DY_MelEh.d.mts +15 -0
  52. package/dist/parse-error-DY_MelEh.d.mts.map +1 -0
  53. package/dist/parse-error-Dzwg4sdE.cjs +39 -0
  54. package/dist/parse-obdkJfj5.mjs +52 -0
  55. package/dist/parse-obdkJfj5.mjs.map +1 -0
  56. package/dist/parse-wxSDzBPf.cjs +62 -0
  57. package/dist/pointer/find-reference.cjs +5 -65
  58. package/dist/pointer/find-reference.d.cts +2 -52
  59. package/dist/pointer/find-reference.d.mts +2 -52
  60. package/dist/pointer/find-reference.mjs +2 -63
  61. package/dist/pointer/index.cjs +15 -14
  62. package/dist/pointer/index.d.cts +2 -2
  63. package/dist/pointer/index.d.mts +2 -2
  64. package/dist/pointer/index.mjs +3 -2
  65. package/dist/pointer/parse.cjs +9 -86
  66. package/dist/pointer/parse.d.cts +2 -44
  67. package/dist/pointer/parse.d.mts +2 -44
  68. package/dist/pointer/parse.mjs +2 -80
  69. package/dist/pointer-Cc7IR0Bj.cjs +0 -0
  70. package/dist/pointer-CiTXvh1G.mjs +0 -0
  71. package/dist/schema-B1RVJHzJ.d.cts +7 -0
  72. package/dist/schema-B1RVJHzJ.d.cts.map +1 -0
  73. package/dist/schema-CfhPLy30.mjs +9 -0
  74. package/dist/schema-CfhPLy30.mjs.map +1 -0
  75. package/dist/schema-D5Aqvh2i.cjs +14 -0
  76. package/dist/schema-ai_NU-JC.d.mts +7 -0
  77. package/dist/schema-ai_NU-JC.d.mts.map +1 -0
  78. package/dist/schema.cjs +3 -0
  79. package/dist/schema.d.cts +2 -0
  80. package/dist/schema.d.mts +3 -0
  81. package/dist/schema.mjs +3 -0
  82. package/dist/storm-json-6WpS7qnH.cjs +154 -0
  83. package/dist/storm-json-AaFeOao2.d.cts +70 -0
  84. package/dist/storm-json-AaFeOao2.d.cts.map +1 -0
  85. package/dist/storm-json-BvRkzAlR.d.mts +70 -0
  86. package/dist/storm-json-BvRkzAlR.d.mts.map +1 -0
  87. package/dist/storm-json-Cy3PuAhj.mjs +116 -0
  88. package/dist/storm-json-Cy3PuAhj.mjs.map +1 -0
  89. package/dist/storm-json.cjs +3 -116
  90. package/dist/storm-json.d.cts +2 -70
  91. package/dist/storm-json.d.mts +3 -70
  92. package/dist/storm-json.mjs +3 -115
  93. package/dist/stringify-B6iAeg0u.d.mts +13 -0
  94. package/dist/stringify-B6iAeg0u.d.mts.map +1 -0
  95. package/dist/stringify-Bc8OkhIr.d.cts +13 -0
  96. package/dist/stringify-Bc8OkhIr.d.cts.map +1 -0
  97. package/dist/stringify-D5baUfEe.mjs +68 -0
  98. package/dist/stringify-D5baUfEe.mjs.map +1 -0
  99. package/dist/stringify-DEw3S4_Z.cjs +78 -0
  100. package/dist/strip-comments-Bg3R_Y4S.d.mts +11 -0
  101. package/dist/strip-comments-Bg3R_Y4S.d.mts.map +1 -0
  102. package/dist/strip-comments-CMaAgTqz.mjs +89 -0
  103. package/dist/strip-comments-CMaAgTqz.mjs.map +1 -0
  104. package/dist/strip-comments-CtFoX0xG.cjs +94 -0
  105. package/dist/strip-comments-Cz_Wc25t.d.cts +11 -0
  106. package/dist/strip-comments-Cz_Wc25t.d.cts.map +1 -0
  107. package/dist/types-BUeTTE_U.d.cts +222 -0
  108. package/dist/types-BUeTTE_U.d.cts.map +1 -0
  109. package/dist/types-C_KlcCNw.d.mts +222 -0
  110. package/dist/types-C_KlcCNw.d.mts.map +1 -0
  111. package/dist/types.d.cts +2 -69
  112. package/dist/types.d.mts +2 -69
  113. package/dist/types.mjs +0 -1
  114. package/dist/utils/code-frames.cjs +2 -76
  115. package/dist/utils/code-frames.d.cts +2 -17
  116. package/dist/utils/code-frames.d.mts +2 -17
  117. package/dist/utils/code-frames.mjs +2 -76
  118. package/dist/utils/index.cjs +13 -12
  119. package/dist/utils/index.d.cts +5 -5
  120. package/dist/utils/index.d.mts +6 -5
  121. package/dist/utils/index.mjs +6 -5
  122. package/dist/utils/parse-error.cjs +2 -33
  123. package/dist/utils/parse-error.d.cts +2 -15
  124. package/dist/utils/parse-error.d.mts +2 -15
  125. package/dist/utils/parse-error.mjs +2 -33
  126. package/dist/utils/parse.cjs +3 -51
  127. package/dist/utils/parse.d.cts +2 -9
  128. package/dist/utils/parse.d.mts +2 -9
  129. package/dist/utils/parse.mjs +2 -51
  130. package/dist/utils/stringify.cjs +3 -67
  131. package/dist/utils/stringify.d.cts +2 -13
  132. package/dist/utils/stringify.d.mts +2 -13
  133. package/dist/utils/stringify.mjs +2 -67
  134. package/dist/utils/strip-comments.cjs +2 -85
  135. package/dist/utils/strip-comments.d.cts +2 -11
  136. package/dist/utils/strip-comments.d.mts +2 -11
  137. package/dist/utils/strip-comments.mjs +2 -86
  138. package/dist/utils-CVcIdLuL.mjs +0 -0
  139. package/dist/utils-Cz3OCwUK.cjs +0 -0
  140. package/package.json +7 -2
  141. package/dist/_virtual/rolldown_runtime.cjs +0 -29
  142. package/dist/pointer/find-reference.d.cts.map +0 -1
  143. package/dist/pointer/find-reference.d.mts.map +0 -1
  144. package/dist/pointer/find-reference.mjs.map +0 -1
  145. package/dist/pointer/parse.d.cts.map +0 -1
  146. package/dist/pointer/parse.d.mts.map +0 -1
  147. package/dist/pointer/parse.mjs.map +0 -1
  148. package/dist/storm-json.d.cts.map +0 -1
  149. package/dist/storm-json.d.mts.map +0 -1
  150. package/dist/storm-json.mjs.map +0 -1
  151. package/dist/type-checks/src/get-object-tag.cjs +0 -15
  152. package/dist/type-checks/src/get-object-tag.mjs +0 -15
  153. package/dist/type-checks/src/get-object-tag.mjs.map +0 -1
  154. package/dist/type-checks/src/is-empty.cjs +0 -20
  155. package/dist/type-checks/src/is-empty.mjs +0 -21
  156. package/dist/type-checks/src/is-empty.mjs.map +0 -1
  157. package/dist/type-checks/src/is-non-null-object.cjs +0 -16
  158. package/dist/type-checks/src/is-non-null-object.mjs +0 -17
  159. package/dist/type-checks/src/is-non-null-object.mjs.map +0 -1
  160. package/dist/type-checks/src/is-null.cjs +0 -12
  161. package/dist/type-checks/src/is-null.mjs +0 -12
  162. package/dist/type-checks/src/is-null.mjs.map +0 -1
  163. package/dist/type-checks/src/is-number.cjs +0 -18
  164. package/dist/type-checks/src/is-number.mjs +0 -18
  165. package/dist/type-checks/src/is-number.mjs.map +0 -1
  166. package/dist/type-checks/src/is-object.cjs +0 -19
  167. package/dist/type-checks/src/is-object.mjs +0 -20
  168. package/dist/type-checks/src/is-object.mjs.map +0 -1
  169. package/dist/type-checks/src/is-plain-object.mjs.map +0 -1
  170. package/dist/type-checks/src/is-set-object.cjs +0 -19
  171. package/dist/type-checks/src/is-set-object.mjs +0 -20
  172. package/dist/type-checks/src/is-set-object.mjs.map +0 -1
  173. package/dist/type-checks/src/is-set.cjs +0 -19
  174. package/dist/type-checks/src/is-set.mjs +0 -20
  175. package/dist/type-checks/src/is-set.mjs.map +0 -1
  176. package/dist/type-checks/src/is-string.mjs.map +0 -1
  177. package/dist/type-checks/src/is-undefined.mjs.map +0 -1
  178. package/dist/types/src/base.cjs +0 -6
  179. package/dist/types/src/base.mjs +0 -6
  180. package/dist/types/src/base.mjs.map +0 -1
  181. package/dist/types/src/json.d.cts +0 -12
  182. package/dist/types/src/json.d.cts.map +0 -1
  183. package/dist/types/src/json.d.mts +0 -12
  184. package/dist/types/src/json.d.mts.map +0 -1
  185. package/dist/types.d.cts.map +0 -1
  186. package/dist/types.d.mts.map +0 -1
  187. package/dist/utils/code-frames.d.cts.map +0 -1
  188. package/dist/utils/code-frames.d.mts.map +0 -1
  189. package/dist/utils/code-frames.mjs.map +0 -1
  190. package/dist/utils/parse-error.d.cts.map +0 -1
  191. package/dist/utils/parse-error.d.mts.map +0 -1
  192. package/dist/utils/parse-error.mjs.map +0 -1
  193. package/dist/utils/parse.d.cts.map +0 -1
  194. package/dist/utils/parse.d.mts.map +0 -1
  195. package/dist/utils/parse.mjs.map +0 -1
  196. package/dist/utils/stringify.d.cts.map +0 -1
  197. package/dist/utils/stringify.d.mts.map +0 -1
  198. package/dist/utils/stringify.mjs.map +0 -1
  199. package/dist/utils/strip-comments.d.cts.map +0 -1
  200. package/dist/utils/strip-comments.d.mts.map +0 -1
  201. package/dist/utils/strip-comments.mjs.map +0 -1
@@ -0,0 +1,70 @@
1
+ import { H as JsonSerializeOptions, U as JsonValue, d as JsonParserResult, l as JsonParseOptions, t as Class } from "./types-BUeTTE_U.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-AaFeOao2.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storm-json-AaFeOao2.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,aACG;;;;;;;;;+DAuBA,mBACT;;;;;;;;;mDAiCmB,YAAY,2CAGd,UAAU,iCACR,gBAAgB,4CACC;;;;;;yCAkBnB"}
@@ -0,0 +1,70 @@
1
+ import { H as JsonSerializeOptions, U as JsonValue, d as JsonParserResult, l as JsonParseOptions, t as Class } from "./types-C_KlcCNw.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-BvRkzAlR.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storm-json-BvRkzAlR.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,aACG;;;;;;;;;+DAuBA,mBACT;;;;;;;;;mDAiCmB,YAAY,2CAGd,UAAU,iCACR,gBAAgB,4CACC;;;;;;yCAkBnB"}
@@ -0,0 +1,116 @@
1
+ import { t as isObject } from "./is-object-BpfmzHWa.mjs";
2
+ import { t as isString } from "./is-string-CLiBUSKV.mjs";
3
+ import { t as parse$1 } from "./parse-obdkJfj5.mjs";
4
+ import { t as formatParseError } from "./parse-error-C3Qmubee.mjs";
5
+ import { n as stringify } from "./stringify-D5baUfEe.mjs";
6
+ import { parse } from "jsonc-parser";
7
+ import { Buffer } from "node:buffer";
8
+ import SuperJSON from "superjson";
9
+
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, options?.spaces ?? 2);
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) => typeof Buffer.isBuffer === "function" && Buffer.isBuffer(v),
110
+ serialize: (v) => v.toString("base64"),
111
+ deserialize: (v) => Buffer.from(v, "base64")
112
+ }, "Bytes");
113
+
114
+ //#endregion
115
+ export { StormJSON as t };
116
+ //# sourceMappingURL=storm-json-Cy3PuAhj.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storm-json-Cy3PuAhj.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, options?.spaces ?? 2);\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 =>\n typeof Buffer.isBuffer === \"function\" && Buffer.isBuffer(v),\n serialize: v => v.toString(\"base64\"),\n deserialize: v => Buffer.from(v, \"base64\")\n },\n \"Bytes\"\n);\n"],"mappings":";;;;;;;;;;;;;;;;AA0CA,IAAa,YAAb,MAAa,kBAAkB,UAAU;CACvC,QAAOA;CAEP,WAAkB,WAAsB;AACtC,MAAI,CAAC,WAAUA,SACb,YAAUA,WAAY,IAAI,WAAW;AAGvC,SAAO,WAAUA;;;;;CAMnB,OAAuB,YACrB,SACO;AACP,SAAO,UAAU,SAAS,YAAY,QAAQ;;;;;CAMhD,OAAuB,UAAU,QAAqC;AACpE,SAAO,UAAU,SAAS,UAAU,OAAO;;;;;;;;CAS7C,OAAuB,MAAuB,OAAsB;AAClE,SAAOC,QAAW,MAAM;;;;;;;;;;CAW1B,OAAuB,UACrB,OACA,SACQ;EACR,MAAM,oBACJ,UAAU,SAAS,0BAA0B,eAAe,MAAM;EAEpE,IAAI,SAAS;AACb,MAAI,qBAAqB,kBAAkB,aAAa,MAAM,CAC5D,UAAS,kBAAkB,UAAU,OAAO;AAG9C,SAAOC,UAAe,QAAQ,SAAS,UAAU,EAAE;;;;;;;;;;CAWrD,OAAc,UACZ,SACA,SACO;AACP,MAAI;AACF,OAAI,SAAS,mBAAmB,MAC9B,QAAO,UAAU,SAAS,MAAM,QAAQ;UAEpC;EAIR,MAAMC,SAAuB,EAAE;EAK/B,MAAM,SAAS,MAAM,SAAS,QAJjB;GACX,oBAAoB;GACpB,GAAG;GACJ,CAC0C;AAE3C,MAAI,OAAO,SAAS,KAAK,OAAO,GAC9B,OAAM,IAAI,MAAM,iBAAiB,SAAS,OAAO,GAAG,CAAC;AAGvD,SAAO;;;;;;;;;;CAWT,OAAc,SAIZ,MACA,WACA,aACA,cACA;AACA,YAAU,SAAS,eACjB;GACE;GACA;GACA;GACD,EACD,KACD;;;;;;;CAQH,OAAuB,cACrB,kBACA,SACA;AACA,YAAU,SAAS,cAAc,kBAAkB;GACjD,YAAY,SAAS,QAAQ,GACzB,UACA,SAAS,cAAc,iBAAiB;GAC5C,YACE,WACA,SAAS,QAAQ,IACjB,SAAS,cACT,MAAM,QAAQ,QAAQ,WAAW,GAC7B,QAAQ,aACR,CAAC,aAAa;GACrB,CAAC;;CAGJ,AAAQ,cAAc;AACpB,QAAM,EAAE,QAAQ,MAAM,CAAC;;;AAI3B,UAAU,SAAS,eACjB;CACE,eAAe,MACb,OAAO,OAAO,aAAa,cAAc,OAAO,SAAS,EAAE;CAC7D,YAAW,MAAK,EAAE,SAAS,SAAS;CACpC,cAAa,MAAK,OAAO,KAAK,GAAG,SAAS;CAC3C,EACD,QACD"}
@@ -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-6WpS7qnH.cjs');
2
+ require('./parse-error-Dzwg4sdE.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-AaFeOao2.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-C_KlcCNw.mjs";
2
+ import { t as StormJSON } from "./storm-json-BvRkzAlR.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-C3Qmubee.mjs";
2
+ import { t as StormJSON } from "./storm-json-Cy3PuAhj.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 };