@stryke/url 0.3.26 → 0.3.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.
Files changed (80) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/_virtual/rolldown_runtime.cjs +29 -1
  3. package/dist/helpers.cjs +28 -1
  4. package/dist/helpers.mjs +26 -1
  5. package/dist/helpers.mjs.map +1 -1
  6. package/dist/index.cjs +5 -1
  7. package/dist/index.mjs +4 -1
  8. package/dist/json/src/storm-json.cjs +117 -1
  9. package/dist/json/src/storm-json.mjs +115 -1
  10. package/dist/json/src/storm-json.mjs.map +1 -1
  11. package/dist/json/src/utils/code-frames.cjs +77 -3
  12. package/dist/json/src/utils/code-frames.mjs +76 -3
  13. package/dist/json/src/utils/code-frames.mjs.map +1 -1
  14. package/dist/json/src/utils/parse-error.cjs +34 -1
  15. package/dist/json/src/utils/parse-error.mjs +33 -1
  16. package/dist/json/src/utils/parse-error.mjs.map +1 -1
  17. package/dist/json/src/utils/parse.cjs +45 -1
  18. package/dist/json/src/utils/parse.mjs +45 -1
  19. package/dist/json/src/utils/parse.mjs.map +1 -1
  20. package/dist/json/src/utils/stringify.cjs +67 -1
  21. package/dist/json/src/utils/stringify.mjs +67 -1
  22. package/dist/json/src/utils/stringify.mjs.map +1 -1
  23. package/dist/json/src/utils/strip-comments.cjs +86 -4
  24. package/dist/json/src/utils/strip-comments.mjs +86 -4
  25. package/dist/json/src/utils/strip-comments.mjs.map +1 -1
  26. package/dist/path/src/is-type.cjs +28 -1
  27. package/dist/path/src/is-type.mjs +28 -1
  28. package/dist/path/src/is-type.mjs.map +1 -1
  29. package/dist/path/src/join-paths.cjs +106 -1
  30. package/dist/path/src/join-paths.mjs +106 -1
  31. package/dist/path/src/join-paths.mjs.map +1 -1
  32. package/dist/path/src/regex.cjs +12 -1
  33. package/dist/path/src/regex.mjs +8 -1
  34. package/dist/path/src/regex.mjs.map +1 -1
  35. package/dist/path/src/slash.cjs +15 -1
  36. package/dist/path/src/slash.mjs +14 -1
  37. package/dist/path/src/slash.mjs.map +1 -1
  38. package/dist/storm-url.cjs +227 -1
  39. package/dist/storm-url.mjs +226 -1
  40. package/dist/storm-url.mjs.map +1 -1
  41. package/dist/type-checks/src/get-object-tag.cjs +15 -1
  42. package/dist/type-checks/src/get-object-tag.mjs +14 -1
  43. package/dist/type-checks/src/get-object-tag.mjs.map +1 -1
  44. package/dist/type-checks/src/is-empty.cjs +20 -1
  45. package/dist/type-checks/src/is-empty.mjs +20 -1
  46. package/dist/type-checks/src/is-empty.mjs.map +1 -1
  47. package/dist/type-checks/src/is-integer.cjs +14 -1
  48. package/dist/type-checks/src/is-integer.mjs +14 -1
  49. package/dist/type-checks/src/is-integer.mjs.map +1 -1
  50. package/dist/type-checks/src/is-null.cjs +12 -1
  51. package/dist/type-checks/src/is-null.mjs +11 -1
  52. package/dist/type-checks/src/is-null.mjs.map +1 -1
  53. package/dist/type-checks/src/is-number.cjs +18 -1
  54. package/dist/type-checks/src/is-number.mjs +17 -1
  55. package/dist/type-checks/src/is-number.mjs.map +1 -1
  56. package/dist/type-checks/src/is-object.cjs +19 -1
  57. package/dist/type-checks/src/is-object.mjs +19 -1
  58. package/dist/type-checks/src/is-object.mjs.map +1 -1
  59. package/dist/type-checks/src/is-plain-object.cjs +63 -1
  60. package/dist/type-checks/src/is-plain-object.mjs +63 -1
  61. package/dist/type-checks/src/is-plain-object.mjs.map +1 -1
  62. package/dist/type-checks/src/is-set-string.cjs +20 -1
  63. package/dist/type-checks/src/is-set-string.mjs +20 -1
  64. package/dist/type-checks/src/is-set-string.mjs.map +1 -1
  65. package/dist/type-checks/src/is-set.cjs +19 -1
  66. package/dist/type-checks/src/is-set.mjs +19 -1
  67. package/dist/type-checks/src/is-set.mjs.map +1 -1
  68. package/dist/type-checks/src/is-string.cjs +12 -1
  69. package/dist/type-checks/src/is-string.mjs +11 -1
  70. package/dist/type-checks/src/is-string.mjs.map +1 -1
  71. package/dist/type-checks/src/is-undefined.cjs +8 -1
  72. package/dist/type-checks/src/is-undefined.mjs +7 -1
  73. package/dist/type-checks/src/is-undefined.mjs.map +1 -1
  74. package/dist/types/src/base.cjs +6 -1
  75. package/dist/types/src/base.mjs +5 -1
  76. package/dist/types/src/base.mjs.map +1 -1
  77. package/dist/types.cjs +6 -1
  78. package/dist/types.mjs +5 -1
  79. package/dist/types.mjs.map +1 -1
  80. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  # Changelog for Stryke - URL
4
4
 
5
+ ## [0.3.27](https://github.com/storm-software/stryke/releases/tag/url%400.3.27) (01/16/2026)
6
+
7
+ ### Updated Dependencies
8
+
9
+ - Updated **type-checks** to **v0.5.19**
10
+ - Updated **json** to **v0.9.37**
11
+ - Updated **path** to **v0.25.1**
12
+
13
+ ## [0.3.26](https://github.com/storm-software/stryke/releases/tag/url%400.3.26) (01/16/2026)
14
+
15
+ ### Updated Dependencies
16
+
17
+ - Updated **path** to **v0.25.0**
18
+
5
19
  ## [0.3.25](https://github.com/storm-software/stryke/releases/tag/url%400.3.25) (01/16/2026)
6
20
 
7
21
  ### Updated Dependencies
@@ -1 +1,29 @@
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));exports.__toESM=s;
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+
29
+ exports.__toESM = __toESM;
package/dist/helpers.cjs CHANGED
@@ -1 +1,28 @@
1
- function e(e){let t=e;if(t.includes(`_`)&&(t=t.replace(/_/g,`-`)),t.includes(`-`)){let e=t.split(`-`);if(e.length>1){let n=e[0],r=e[1];n&&r&&(t=`${n}-${r}`)}}return t.toLowerCase()}function t(e){return/(?:https?:\/\/.)?(?:www\.)?[-\w@:%.+~#=]{2,256}\.[a-z]{2,6}\b[-\w@:%+.~#?&/=]*/.test(e)}exports.formatLocalePath=e,exports.isValidURL=t;
1
+
2
+ //#region src/helpers.ts
3
+ function formatLocalePath(locale) {
4
+ let result = locale;
5
+ if (result.includes("_")) result = result.replace(/_/g, "-");
6
+ if (result.includes("-")) {
7
+ const parts = result.split("-");
8
+ if (parts.length > 1) {
9
+ const lang = parts[0];
10
+ const region = parts[1];
11
+ if (lang && region) result = `${lang}-${region}`;
12
+ }
13
+ }
14
+ return result.toLowerCase();
15
+ }
16
+ /**
17
+ * Check if a string has a valid URL format.
18
+ *
19
+ * @param str - The string to check.
20
+ * @returns `true` if the string is a valid URL, otherwise `false`.
21
+ */
22
+ function isValidURL(str) {
23
+ return /(?:https?:\/\/.)?(?:www\.)?[-\w@:%.+~#=]{2,256}\.[a-z]{2,6}\b[-\w@:%+.~#?&/=]*/.test(str);
24
+ }
25
+
26
+ //#endregion
27
+ exports.formatLocalePath = formatLocalePath;
28
+ exports.isValidURL = isValidURL;
package/dist/helpers.mjs CHANGED
@@ -1,2 +1,27 @@
1
- function e(e){let t=e;if(t.includes(`_`)&&(t=t.replace(/_/g,`-`)),t.includes(`-`)){let e=t.split(`-`);if(e.length>1){let n=e[0],r=e[1];n&&r&&(t=`${n}-${r}`)}}return t.toLowerCase()}function t(e){return/(?:https?:\/\/.)?(?:www\.)?[-\w@:%.+~#=]{2,256}\.[a-z]{2,6}\b[-\w@:%+.~#?&/=]*/.test(e)}export{e as formatLocalePath,t as isValidURL};
1
+ //#region src/helpers.ts
2
+ function formatLocalePath(locale) {
3
+ let result = locale;
4
+ if (result.includes("_")) result = result.replace(/_/g, "-");
5
+ if (result.includes("-")) {
6
+ const parts = result.split("-");
7
+ if (parts.length > 1) {
8
+ const lang = parts[0];
9
+ const region = parts[1];
10
+ if (lang && region) result = `${lang}-${region}`;
11
+ }
12
+ }
13
+ return result.toLowerCase();
14
+ }
15
+ /**
16
+ * Check if a string has a valid URL format.
17
+ *
18
+ * @param str - The string to check.
19
+ * @returns `true` if the string is a valid URL, otherwise `false`.
20
+ */
21
+ function isValidURL(str) {
22
+ return /(?:https?:\/\/.)?(?:www\.)?[-\w@:%.+~#=]{2,256}\.[a-z]{2,6}\b[-\w@:%+.~#?&/=]*/.test(str);
23
+ }
24
+
25
+ //#endregion
26
+ export { formatLocalePath, isValidURL };
2
27
  //# sourceMappingURL=helpers.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.mjs","names":[],"sources":["../src/helpers.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\nexport function formatLocalePath(locale: string) {\n let result = locale;\n if (result.includes(\"_\")) {\n result = result.replace(/_/g, \"-\");\n }\n\n if (result.includes(\"-\")) {\n const parts = result.split(\"-\");\n if (parts.length > 1) {\n const lang = parts[0];\n const region = parts[1];\n if (lang && region) {\n result = `${lang}-${region}`;\n }\n }\n }\n\n return result.toLowerCase();\n}\n\n/**\n * Check if a string has a valid URL format.\n *\n * @param str - The string to check.\n * @returns `true` if the string is a valid URL, otherwise `false`.\n */\nexport function isValidURL(str: string): boolean {\n return /(?:https?:\\/\\/.)?(?:www\\.)?[-\\w@:%.+~#=]{2,256}\\.[a-z]{2,6}\\b[-\\w@:%+.~#?&/=]*/.test(\n str\n );\n}\n"],"mappings":"AAkBA,SAAgB,EAAiB,EAAgB,CAC/C,IAAI,EAAS,EAKb,GAJI,EAAO,SAAS,IAAI,GACtB,EAAS,EAAO,QAAQ,KAAM,IAAI,EAGhC,EAAO,SAAS,IAAI,CAAE,CACxB,IAAM,EAAQ,EAAO,MAAM,IAAI,CAC/B,GAAI,EAAM,OAAS,EAAG,CACpB,IAAM,EAAO,EAAM,GACb,EAAS,EAAM,GACjB,GAAQ,IACV,EAAS,GAAG,EAAK,GAAG,MAK1B,OAAO,EAAO,aAAa,CAS7B,SAAgB,EAAW,EAAsB,CAC/C,MAAO,iFAAiF,KACtF,EACD"}
1
+ {"version":3,"file":"helpers.mjs","names":[],"sources":["../src/helpers.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\nexport function formatLocalePath(locale: string) {\n let result = locale;\n if (result.includes(\"_\")) {\n result = result.replace(/_/g, \"-\");\n }\n\n if (result.includes(\"-\")) {\n const parts = result.split(\"-\");\n if (parts.length > 1) {\n const lang = parts[0];\n const region = parts[1];\n if (lang && region) {\n result = `${lang}-${region}`;\n }\n }\n }\n\n return result.toLowerCase();\n}\n\n/**\n * Check if a string has a valid URL format.\n *\n * @param str - The string to check.\n * @returns `true` if the string is a valid URL, otherwise `false`.\n */\nexport function isValidURL(str: string): boolean {\n return /(?:https?:\\/\\/.)?(?:www\\.)?[-\\w@:%.+~#=]{2,256}\\.[a-z]{2,6}\\b[-\\w@:%+.~#?&/=]*/.test(\n str\n );\n}\n"],"mappings":";AAkBA,SAAgB,iBAAiB,QAAgB;CAC/C,IAAI,SAAS;AACb,KAAI,OAAO,SAAS,IAAI,CACtB,UAAS,OAAO,QAAQ,MAAM,IAAI;AAGpC,KAAI,OAAO,SAAS,IAAI,EAAE;EACxB,MAAM,QAAQ,OAAO,MAAM,IAAI;AAC/B,MAAI,MAAM,SAAS,GAAG;GACpB,MAAM,OAAO,MAAM;GACnB,MAAM,SAAS,MAAM;AACrB,OAAI,QAAQ,OACV,UAAS,GAAG,KAAK,GAAG;;;AAK1B,QAAO,OAAO,aAAa;;;;;;;;AAS7B,SAAgB,WAAW,KAAsB;AAC/C,QAAO,iFAAiF,KACtF,IACD"}
package/dist/index.cjs CHANGED
@@ -1 +1,5 @@
1
- const e=require(`./storm-url.cjs`),t=require(`./types.cjs`);exports.PROTOCOL_RELATIVE_SYMBOL=t.PROTOCOL_RELATIVE_SYMBOL,exports.StormURL=e.StormURL;
1
+ const require_storm_url = require('./storm-url.cjs');
2
+ const require_types = require('./types.cjs');
3
+
4
+ exports.PROTOCOL_RELATIVE_SYMBOL = require_types.PROTOCOL_RELATIVE_SYMBOL;
5
+ exports.StormURL = require_storm_url.StormURL;
package/dist/index.mjs CHANGED
@@ -1 +1,4 @@
1
- import{StormURL as e}from"./storm-url.mjs";import{PROTOCOL_RELATIVE_SYMBOL as t}from"./types.mjs";export{t as PROTOCOL_RELATIVE_SYMBOL,e as StormURL};
1
+ import { StormURL } from "./storm-url.mjs";
2
+ import { PROTOCOL_RELATIVE_SYMBOL } from "./types.mjs";
3
+
4
+ export { PROTOCOL_RELATIVE_SYMBOL, StormURL };
@@ -1 +1,117 @@
1
- const e=require(`../../_virtual/rolldown_runtime.cjs`),t=require(`../../type-checks/src/is-object.cjs`),n=require(`../../type-checks/src/is-string.cjs`),r=require(`./utils/parse.cjs`),i=require(`./utils/parse-error.cjs`),a=require(`./utils/stringify.cjs`);let o=require(`jsonc-parser`),s=require(`node:buffer`),c=require(`superjson`);c=e.__toESM(c);var l=class e extends c.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 r.parse(e)}static stringify(t,n){let r=e.instance.customTransformerRegistry.findApplicable(t),i=t;return r&&r.isApplicable(t)&&(i=r.serialize(i)),a.stringify(i)}static parseJson(t,n){try{if(n?.expectComments===!1)return e.instance.parse(t)}catch{}let r=[],a=(0,o.parse)(t,r,{allowTrailingComma:!0,...n});if(r.length>0&&r[0])throw Error(i.formatParseError(t,r[0]));return a}static register(t,n,r,i){e.instance.registerCustom({isApplicable:i,serialize:n,deserialize:r},t)}static registerClass(r,i){e.instance.registerClass(r,{identifier:n.isString(i)?i:i?.identifier||r.name,allowProps:i&&t.isObject(i)&&i?.allowProps&&Array.isArray(i.allowProps)?i.allowProps:[`__typename`]})}constructor(){super({dedupe:!0})}};l.instance.registerCustom({isApplicable:e=>s.Buffer.isBuffer(e),serialize:e=>e.toString(`base64`),deserialize:e=>s.Buffer.from(e,`base64`)},`Bytes`),exports.StormJSON=l;
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_parse = require('./utils/parse.cjs');
5
+ const require_parse_error = require('./utils/parse-error.cjs');
6
+ const require_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);
11
+
12
+ //#region ../json/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_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_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_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;
@@ -1,2 +1,116 @@
1
- import{isObject as e}from"../../type-checks/src/is-object.mjs";import{isString as t}from"../../type-checks/src/is-string.mjs";import{parse as n}from"./utils/parse.mjs";import{formatParseError as r}from"./utils/parse-error.mjs";import{stringify as i}from"./utils/stringify.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 StormJSON};
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";
9
+
10
+ //#region ../json/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 };
2
116
  //# sourceMappingURL=storm-json.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"storm-json.mjs","names":["#instance","parseValue","stringifyValue","errors: ParseError[]"],"sources":["../../../../json/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":"wXA0CA,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
+ {"version":3,"file":"storm-json.mjs","names":["#instance","parseValue","stringifyValue","errors: ParseError[]"],"sources":["../../../../json/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":";;;;;;;;;;;;;;;;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,UACQ;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,OAAO;;;;;;;;;;CAW/B,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,MAAmB,OAAO,SAAS,EAAE;CACpD,YAAW,MAAK,EAAE,SAAS,SAAS;CACpC,cAAa,MAAK,OAAO,KAAK,GAAG,SAAS;CAC3C,EACD,QACD"}
@@ -1,3 +1,77 @@
1
- const e=/\r\n|[\n\r\u2028\u2029]/;function t(e,t,n={}){let r={column:0,line:-1,...e.start},i={...r,...e.end},{linesAbove:a=2,linesBelow:o=3}=n||{},s=r.line,c=r.column,l=i.line,u=i.column,d=Math.max(s-(a+1),0),f=Math.min(t.length,l+o);s===-1&&(d=0),l===-1&&(f=t.length);let p=l-s,m={};if(p)for(let e=0;e<=p;e++){let n=e+s;c?e===0?m[n]=[c,(t[n-1]?.length??0)-c+1]:e===p?m[n]=[0,u]:m[n]=[0,t[n-e]?.length??0]:m[n]=!0}else c===u?m[s]=c?[c,0]:!0:m[s]=[c,u-c];return{start:d,end:f,markerLines:m}}function n(n,r,i={}){let{start:a,end:o,markerLines:s}=t(r,n.split(e),i),c=String(o).length;return(i.highlight?i.highlight(n):n).split(e).slice(a,o).map((e,t)=>{let n=a+1+t,r=` ${` ${n}`.slice(-c)} | `,i=!!(s[n]??!1);if(i){let t=``;if(Array.isArray(i)){let n=e.slice(0,Math.max(i[0]-1,0)).replace(/[^\t]/g,` `),a=i[1]||1;t=[`
2
- `,r.replace(/\d/g,` `),n,`^`.repeat(a)].join(``)}return[`>`,r,e,t].join(``)}return` ${r}${e}`}).join(`
3
- `)}exports.codeFrameColumns=n;
1
+
2
+ //#region ../json/src/utils/code-frames.ts
3
+ /**
4
+ * RegExp to test for newlines in terminal.
5
+ */
6
+ const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
7
+ /**
8
+ * Extract what lines should be marked and highlighted.
9
+ */
10
+ function getMarkerLines(loc, source, opts = {}) {
11
+ const startLoc = {
12
+ column: 0,
13
+ line: -1,
14
+ ...loc.start
15
+ };
16
+ const endLoc = {
17
+ ...startLoc,
18
+ ...loc.end
19
+ };
20
+ const { linesAbove = 2, linesBelow = 3 } = opts || {};
21
+ const startLine = startLoc.line;
22
+ const startColumn = startLoc.column;
23
+ const endLine = endLoc.line;
24
+ const endColumn = endLoc.column;
25
+ let start = Math.max(startLine - (linesAbove + 1), 0);
26
+ let end = Math.min(source.length, endLine + linesBelow);
27
+ if (startLine === -1) start = 0;
28
+ if (endLine === -1) end = source.length;
29
+ const lineDiff = endLine - startLine;
30
+ const markerLines = {};
31
+ if (lineDiff) for (let i = 0; i <= lineDiff; i++) {
32
+ const lineNumber = i + startLine;
33
+ if (!startColumn) markerLines[lineNumber] = true;
34
+ else if (i === 0) markerLines[lineNumber] = [startColumn, (source[lineNumber - 1]?.length ?? 0) - startColumn + 1];
35
+ else if (i === lineDiff) markerLines[lineNumber] = [0, endColumn];
36
+ else markerLines[lineNumber] = [0, source[lineNumber - i]?.length ?? 0];
37
+ }
38
+ else if (startColumn === endColumn) markerLines[startLine] = startColumn ? [startColumn, 0] : true;
39
+ else markerLines[startLine] = [startColumn, endColumn - startColumn];
40
+ return {
41
+ start,
42
+ end,
43
+ markerLines
44
+ };
45
+ }
46
+ function codeFrameColumns(rawLines, loc, opts = {}) {
47
+ const { start, end, markerLines } = getMarkerLines(loc, rawLines.split(NEWLINE), opts);
48
+ const numberMaxWidth = String(end).length;
49
+ return (opts.highlight ? opts.highlight(rawLines) : rawLines).split(NEWLINE).slice(start, end).map((line, index) => {
50
+ const number = start + 1 + index;
51
+ const gutter = ` ${` ${number}`.slice(-numberMaxWidth)} | `;
52
+ const hasMarker = Boolean(markerLines[number] ?? false);
53
+ if (hasMarker) {
54
+ let markerLine = "";
55
+ if (Array.isArray(hasMarker)) {
56
+ const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
57
+ const numberOfMarkers = hasMarker[1] || 1;
58
+ markerLine = [
59
+ "\n ",
60
+ gutter.replace(/\d/g, " "),
61
+ markerSpacing,
62
+ "^".repeat(numberOfMarkers)
63
+ ].join("");
64
+ }
65
+ return [
66
+ ">",
67
+ gutter,
68
+ line,
69
+ markerLine
70
+ ].join("");
71
+ }
72
+ return ` ${gutter}${line}`;
73
+ }).join("\n");
74
+ }
75
+
76
+ //#endregion
77
+ exports.codeFrameColumns = codeFrameColumns;
@@ -1,4 +1,77 @@
1
- const e=/\r\n|[\n\r\u2028\u2029]/;function t(e,t,n={}){let r={column:0,line:-1,...e.start},i={...r,...e.end},{linesAbove:a=2,linesBelow:o=3}=n||{},s=r.line,c=r.column,l=i.line,u=i.column,d=Math.max(s-(a+1),0),f=Math.min(t.length,l+o);s===-1&&(d=0),l===-1&&(f=t.length);let p=l-s,m={};if(p)for(let e=0;e<=p;e++){let n=e+s;c?e===0?m[n]=[c,(t[n-1]?.length??0)-c+1]:e===p?m[n]=[0,u]:m[n]=[0,t[n-e]?.length??0]:m[n]=!0}else c===u?m[s]=c?[c,0]:!0:m[s]=[c,u-c];return{start:d,end:f,markerLines:m}}function n(n,r,i={}){let{start:a,end:o,markerLines:s}=t(r,n.split(e),i),c=String(o).length;return(i.highlight?i.highlight(n):n).split(e).slice(a,o).map((e,t)=>{let n=a+1+t,r=` ${` ${n}`.slice(-c)} | `,i=!!(s[n]??!1);if(i){let t=``;if(Array.isArray(i)){let n=e.slice(0,Math.max(i[0]-1,0)).replace(/[^\t]/g,` `),a=i[1]||1;t=[`
2
- `,r.replace(/\d/g,` `),n,`^`.repeat(a)].join(``)}return[`>`,r,e,t].join(``)}return` ${r}${e}`}).join(`
3
- `)}export{n as codeFrameColumns};
1
+ //#region ../json/src/utils/code-frames.ts
2
+ /**
3
+ * RegExp to test for newlines in terminal.
4
+ */
5
+ const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
6
+ /**
7
+ * Extract what lines should be marked and highlighted.
8
+ */
9
+ function getMarkerLines(loc, source, opts = {}) {
10
+ const startLoc = {
11
+ column: 0,
12
+ line: -1,
13
+ ...loc.start
14
+ };
15
+ const endLoc = {
16
+ ...startLoc,
17
+ ...loc.end
18
+ };
19
+ const { linesAbove = 2, linesBelow = 3 } = opts || {};
20
+ const startLine = startLoc.line;
21
+ const startColumn = startLoc.column;
22
+ const endLine = endLoc.line;
23
+ const endColumn = endLoc.column;
24
+ let start = Math.max(startLine - (linesAbove + 1), 0);
25
+ let end = Math.min(source.length, endLine + linesBelow);
26
+ if (startLine === -1) start = 0;
27
+ if (endLine === -1) end = source.length;
28
+ const lineDiff = endLine - startLine;
29
+ const markerLines = {};
30
+ if (lineDiff) for (let i = 0; i <= lineDiff; i++) {
31
+ const lineNumber = i + startLine;
32
+ if (!startColumn) markerLines[lineNumber] = true;
33
+ else if (i === 0) markerLines[lineNumber] = [startColumn, (source[lineNumber - 1]?.length ?? 0) - startColumn + 1];
34
+ else if (i === lineDiff) markerLines[lineNumber] = [0, endColumn];
35
+ else markerLines[lineNumber] = [0, source[lineNumber - i]?.length ?? 0];
36
+ }
37
+ else if (startColumn === endColumn) markerLines[startLine] = startColumn ? [startColumn, 0] : true;
38
+ else markerLines[startLine] = [startColumn, endColumn - startColumn];
39
+ return {
40
+ start,
41
+ end,
42
+ markerLines
43
+ };
44
+ }
45
+ function codeFrameColumns(rawLines, loc, opts = {}) {
46
+ const { start, end, markerLines } = getMarkerLines(loc, rawLines.split(NEWLINE), opts);
47
+ const numberMaxWidth = String(end).length;
48
+ return (opts.highlight ? opts.highlight(rawLines) : rawLines).split(NEWLINE).slice(start, end).map((line, index) => {
49
+ const number = start + 1 + index;
50
+ const gutter = ` ${` ${number}`.slice(-numberMaxWidth)} | `;
51
+ const hasMarker = Boolean(markerLines[number] ?? false);
52
+ if (hasMarker) {
53
+ let markerLine = "";
54
+ if (Array.isArray(hasMarker)) {
55
+ const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
56
+ const numberOfMarkers = hasMarker[1] || 1;
57
+ markerLine = [
58
+ "\n ",
59
+ gutter.replace(/\d/g, " "),
60
+ markerSpacing,
61
+ "^".repeat(numberOfMarkers)
62
+ ].join("");
63
+ }
64
+ return [
65
+ ">",
66
+ gutter,
67
+ line,
68
+ markerLine
69
+ ].join("");
70
+ }
71
+ return ` ${gutter}${line}`;
72
+ }).join("\n");
73
+ }
74
+
75
+ //#endregion
76
+ export { codeFrameColumns };
4
77
  //# sourceMappingURL=code-frames.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"code-frames.mjs","names":["startLoc: Location","endLoc: Location"],"sources":["../../../../../json/src/utils/code-frames.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\ninterface Location {\n column: number;\n line: number;\n}\n\ninterface NodeLocation {\n end?: Location;\n start?: Location;\n}\n\n// Adapted from https://raw.githubusercontent.com/babel/babel/4108524/packages/babel-code-frame/src/index.js\n\n/**\n * RegExp to test for newlines in terminal.\n */\nconst NEWLINE = /\\r\\n|[\\n\\r\\u2028\\u2029]/;\n\n/**\n * Extract what lines should be marked and highlighted.\n */\nfunction getMarkerLines(\n loc: NodeLocation,\n source: string[],\n opts: { linesAbove?: number; linesBelow?: number } = {}\n): {\n start: number;\n end: number;\n markerLines: Record<number, boolean | [number, number]>;\n} {\n const startLoc: Location = {\n column: 0,\n line: -1,\n ...loc.start\n };\n const endLoc: Location = {\n ...startLoc,\n ...loc.end\n };\n const { linesAbove = 2, linesBelow = 3 } = opts || {};\n const startLine = startLoc.line;\n const startColumn = startLoc.column;\n const endLine = endLoc.line;\n const endColumn = endLoc.column;\n\n let start = Math.max(startLine - (linesAbove + 1), 0);\n let end = Math.min(source.length, endLine + linesBelow);\n\n if (startLine === -1) {\n start = 0;\n }\n\n if (endLine === -1) {\n end = source.length;\n }\n\n const lineDiff = endLine - startLine;\n const markerLines = {} as Record<number, boolean | [number, number]>;\n\n if (lineDiff) {\n for (let i = 0; i <= lineDiff; i++) {\n const lineNumber = i + startLine;\n\n if (!startColumn) {\n markerLines[lineNumber] = true;\n } else if (i === 0) {\n const sourceLength = source[lineNumber - 1]?.length ?? 0;\n\n markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];\n } else if (i === lineDiff) {\n markerLines[lineNumber] = [0, endColumn];\n } else {\n const sourceLength = source[lineNumber - i]?.length ?? 0;\n\n markerLines[lineNumber] = [0, sourceLength];\n }\n }\n } else if (startColumn === endColumn) {\n markerLines[startLine] = startColumn ? [startColumn, 0] : true;\n } else {\n markerLines[startLine] = [startColumn, endColumn - startColumn];\n }\n\n return {\n start,\n end,\n markerLines\n };\n}\n\nexport function codeFrameColumns(\n rawLines: string,\n loc: NodeLocation,\n opts: {\n linesAbove?: number;\n linesBelow?: number;\n highlight?: (rawLines: string) => string;\n } = {}\n): string {\n const lines = rawLines.split(NEWLINE);\n const { start, end, markerLines } = getMarkerLines(loc, lines, opts);\n\n const numberMaxWidth = String(end).length;\n const highlightedLines = opts.highlight ? opts.highlight(rawLines) : rawLines;\n\n const frame = highlightedLines\n .split(NEWLINE)\n .slice(start, end)\n .map((line, index) => {\n const number = start + 1 + index;\n const paddedNumber = ` ${number}`.slice(-numberMaxWidth);\n const gutter = ` ${paddedNumber} | `;\n const hasMarker = Boolean(markerLines[number] ?? false);\n if (hasMarker) {\n let markerLine = \"\";\n if (Array.isArray(hasMarker)) {\n const markerSpacing = line\n .slice(0, Math.max(hasMarker[0] - 1, 0))\n .replace(/[^\\t]/g, \" \");\n const numberOfMarkers = hasMarker[1] || 1;\n\n markerLine = [\n \"\\n \",\n gutter.replace(/\\d/g, \" \"),\n markerSpacing,\n \"^\".repeat(numberOfMarkers)\n ].join(\"\");\n }\n return [\">\", gutter, line, markerLine].join(\"\");\n }\n return ` ${gutter}${line}`;\n })\n .join(\"\\n\");\n\n return frame;\n}\n"],"mappings":"AAiCA,MAAM,EAAU,0BAKhB,SAAS,EACP,EACA,EACA,EAAqD,EAAE,CAKvD,CACA,IAAMA,EAAqB,CACzB,OAAQ,EACR,KAAM,GACN,GAAG,EAAI,MACR,CACKC,EAAmB,CACvB,GAAG,EACH,GAAG,EAAI,IACR,CACK,CAAE,aAAa,EAAG,aAAa,GAAM,GAAQ,EAAE,CAC/C,EAAY,EAAS,KACrB,EAAc,EAAS,OACvB,EAAU,EAAO,KACjB,EAAY,EAAO,OAErB,EAAQ,KAAK,IAAI,GAAa,EAAa,GAAI,EAAE,CACjD,EAAM,KAAK,IAAI,EAAO,OAAQ,EAAU,EAAW,CAEnD,IAAc,KAChB,EAAQ,GAGN,IAAY,KACd,EAAM,EAAO,QAGf,IAAM,EAAW,EAAU,EACrB,EAAc,EAAE,CAEtB,GAAI,EACF,IAAK,IAAI,EAAI,EAAG,GAAK,EAAU,IAAK,CAClC,IAAM,EAAa,EAAI,EAElB,EAEM,IAAM,EAGf,EAAY,GAAc,CAAC,GAFN,EAAO,EAAa,IAAI,QAAU,GAEA,EAAc,EAAE,CAC9D,IAAM,EACf,EAAY,GAAc,CAAC,EAAG,EAAU,CAIxC,EAAY,GAAc,CAAC,EAFN,EAAO,EAAa,IAAI,QAAU,EAEZ,CAV3C,EAAY,GAAc,QAarB,IAAgB,EACzB,EAAY,GAAa,EAAc,CAAC,EAAa,EAAE,CAAG,GAE1D,EAAY,GAAa,CAAC,EAAa,EAAY,EAAY,CAGjE,MAAO,CACL,QACA,MACA,cACD,CAGH,SAAgB,EACd,EACA,EACA,EAII,EAAE,CACE,CAER,GAAM,CAAE,QAAO,MAAK,eAAgB,EAAe,EADrC,EAAS,MAAM,EAAQ,CAC0B,EAAK,CAE9D,EAAiB,OAAO,EAAI,CAAC,OAgCnC,OA/ByB,EAAK,UAAY,EAAK,UAAU,EAAS,CAAG,GAGlE,MAAM,EAAQ,CACd,MAAM,EAAO,EAAI,CACjB,KAAK,EAAM,IAAU,CACpB,IAAM,EAAS,EAAQ,EAAI,EAErB,EAAS,IADM,IAAI,IAAS,MAAM,CAAC,EAAe,CACxB,KAC1B,EAAY,GAAQ,EAAY,IAAW,IACjD,GAAI,EAAW,CACb,IAAI,EAAa,GACjB,GAAI,MAAM,QAAQ,EAAU,CAAE,CAC5B,IAAM,EAAgB,EACnB,MAAM,EAAG,KAAK,IAAI,EAAU,GAAK,EAAG,EAAE,CAAC,CACvC,QAAQ,SAAU,IAAI,CACnB,EAAkB,EAAU,IAAM,EAExC,EAAa,CACX;GACA,EAAO,QAAQ,MAAO,IAAI,CAC1B,EACA,IAAI,OAAO,EAAgB,CAC5B,CAAC,KAAK,GAAG,CAEZ,MAAO,CAAC,IAAK,EAAQ,EAAM,EAAW,CAAC,KAAK,GAAG,CAEjD,MAAO,IAAI,IAAS,KACpB,CACD,KAAK;EAAK"}
1
+ {"version":3,"file":"code-frames.mjs","names":["startLoc: Location","endLoc: Location"],"sources":["../../../../../json/src/utils/code-frames.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\ninterface Location {\n column: number;\n line: number;\n}\n\ninterface NodeLocation {\n end?: Location;\n start?: Location;\n}\n\n// Adapted from https://raw.githubusercontent.com/babel/babel/4108524/packages/babel-code-frame/src/index.js\n\n/**\n * RegExp to test for newlines in terminal.\n */\nconst NEWLINE = /\\r\\n|[\\n\\r\\u2028\\u2029]/;\n\n/**\n * Extract what lines should be marked and highlighted.\n */\nfunction getMarkerLines(\n loc: NodeLocation,\n source: string[],\n opts: { linesAbove?: number; linesBelow?: number } = {}\n): {\n start: number;\n end: number;\n markerLines: Record<number, boolean | [number, number]>;\n} {\n const startLoc: Location = {\n column: 0,\n line: -1,\n ...loc.start\n };\n const endLoc: Location = {\n ...startLoc,\n ...loc.end\n };\n const { linesAbove = 2, linesBelow = 3 } = opts || {};\n const startLine = startLoc.line;\n const startColumn = startLoc.column;\n const endLine = endLoc.line;\n const endColumn = endLoc.column;\n\n let start = Math.max(startLine - (linesAbove + 1), 0);\n let end = Math.min(source.length, endLine + linesBelow);\n\n if (startLine === -1) {\n start = 0;\n }\n\n if (endLine === -1) {\n end = source.length;\n }\n\n const lineDiff = endLine - startLine;\n const markerLines = {} as Record<number, boolean | [number, number]>;\n\n if (lineDiff) {\n for (let i = 0; i <= lineDiff; i++) {\n const lineNumber = i + startLine;\n\n if (!startColumn) {\n markerLines[lineNumber] = true;\n } else if (i === 0) {\n const sourceLength = source[lineNumber - 1]?.length ?? 0;\n\n markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];\n } else if (i === lineDiff) {\n markerLines[lineNumber] = [0, endColumn];\n } else {\n const sourceLength = source[lineNumber - i]?.length ?? 0;\n\n markerLines[lineNumber] = [0, sourceLength];\n }\n }\n } else if (startColumn === endColumn) {\n markerLines[startLine] = startColumn ? [startColumn, 0] : true;\n } else {\n markerLines[startLine] = [startColumn, endColumn - startColumn];\n }\n\n return {\n start,\n end,\n markerLines\n };\n}\n\nexport function codeFrameColumns(\n rawLines: string,\n loc: NodeLocation,\n opts: {\n linesAbove?: number;\n linesBelow?: number;\n highlight?: (rawLines: string) => string;\n } = {}\n): string {\n const lines = rawLines.split(NEWLINE);\n const { start, end, markerLines } = getMarkerLines(loc, lines, opts);\n\n const numberMaxWidth = String(end).length;\n const highlightedLines = opts.highlight ? opts.highlight(rawLines) : rawLines;\n\n const frame = highlightedLines\n .split(NEWLINE)\n .slice(start, end)\n .map((line, index) => {\n const number = start + 1 + index;\n const paddedNumber = ` ${number}`.slice(-numberMaxWidth);\n const gutter = ` ${paddedNumber} | `;\n const hasMarker = Boolean(markerLines[number] ?? false);\n if (hasMarker) {\n let markerLine = \"\";\n if (Array.isArray(hasMarker)) {\n const markerSpacing = line\n .slice(0, Math.max(hasMarker[0] - 1, 0))\n .replace(/[^\\t]/g, \" \");\n const numberOfMarkers = hasMarker[1] || 1;\n\n markerLine = [\n \"\\n \",\n gutter.replace(/\\d/g, \" \"),\n markerSpacing,\n \"^\".repeat(numberOfMarkers)\n ].join(\"\");\n }\n return [\">\", gutter, line, markerLine].join(\"\");\n }\n return ` ${gutter}${line}`;\n })\n .join(\"\\n\");\n\n return frame;\n}\n"],"mappings":";;;;AAiCA,MAAM,UAAU;;;;AAKhB,SAAS,eACP,KACA,QACA,OAAqD,EAAE,EAKvD;CACA,MAAMA,WAAqB;EACzB,QAAQ;EACR,MAAM;EACN,GAAG,IAAI;EACR;CACD,MAAMC,SAAmB;EACvB,GAAG;EACH,GAAG,IAAI;EACR;CACD,MAAM,EAAE,aAAa,GAAG,aAAa,MAAM,QAAQ,EAAE;CACrD,MAAM,YAAY,SAAS;CAC3B,MAAM,cAAc,SAAS;CAC7B,MAAM,UAAU,OAAO;CACvB,MAAM,YAAY,OAAO;CAEzB,IAAI,QAAQ,KAAK,IAAI,aAAa,aAAa,IAAI,EAAE;CACrD,IAAI,MAAM,KAAK,IAAI,OAAO,QAAQ,UAAU,WAAW;AAEvD,KAAI,cAAc,GAChB,SAAQ;AAGV,KAAI,YAAY,GACd,OAAM,OAAO;CAGf,MAAM,WAAW,UAAU;CAC3B,MAAM,cAAc,EAAE;AAEtB,KAAI,SACF,MAAK,IAAI,IAAI,GAAG,KAAK,UAAU,KAAK;EAClC,MAAM,aAAa,IAAI;AAEvB,MAAI,CAAC,YACH,aAAY,cAAc;WACjB,MAAM,EAGf,aAAY,cAAc,CAAC,cAFN,OAAO,aAAa,IAAI,UAAU,KAEA,cAAc,EAAE;WAC9D,MAAM,SACf,aAAY,cAAc,CAAC,GAAG,UAAU;MAIxC,aAAY,cAAc,CAAC,GAFN,OAAO,aAAa,IAAI,UAAU,EAEZ;;UAGtC,gBAAgB,UACzB,aAAY,aAAa,cAAc,CAAC,aAAa,EAAE,GAAG;KAE1D,aAAY,aAAa,CAAC,aAAa,YAAY,YAAY;AAGjE,QAAO;EACL;EACA;EACA;EACD;;AAGH,SAAgB,iBACd,UACA,KACA,OAII,EAAE,EACE;CAER,MAAM,EAAE,OAAO,KAAK,gBAAgB,eAAe,KADrC,SAAS,MAAM,QAAQ,EAC0B,KAAK;CAEpE,MAAM,iBAAiB,OAAO,IAAI,CAAC;AAgCnC,SA/ByB,KAAK,YAAY,KAAK,UAAU,SAAS,GAAG,UAGlE,MAAM,QAAQ,CACd,MAAM,OAAO,IAAI,CACjB,KAAK,MAAM,UAAU;EACpB,MAAM,SAAS,QAAQ,IAAI;EAE3B,MAAM,SAAS,IADM,IAAI,SAAS,MAAM,CAAC,eAAe,CACxB;EAChC,MAAM,YAAY,QAAQ,YAAY,WAAW,MAAM;AACvD,MAAI,WAAW;GACb,IAAI,aAAa;AACjB,OAAI,MAAM,QAAQ,UAAU,EAAE;IAC5B,MAAM,gBAAgB,KACnB,MAAM,GAAG,KAAK,IAAI,UAAU,KAAK,GAAG,EAAE,CAAC,CACvC,QAAQ,UAAU,IAAI;IACzB,MAAM,kBAAkB,UAAU,MAAM;AAExC,iBAAa;KACX;KACA,OAAO,QAAQ,OAAO,IAAI;KAC1B;KACA,IAAI,OAAO,gBAAgB;KAC5B,CAAC,KAAK,GAAG;;AAEZ,UAAO;IAAC;IAAK;IAAQ;IAAM;IAAW,CAAC,KAAK,GAAG;;AAEjD,SAAO,IAAI,SAAS;GACpB,CACD,KAAK,KAAK"}