@stryke/fs 0.33.69 → 0.33.71

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 (196) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +1 -1
  3. package/dist/buffer.cjs +5 -4
  4. package/dist/buffer.d.cts.map +1 -1
  5. package/dist/buffer.d.mts.map +1 -1
  6. package/dist/buffer.mjs +1 -1
  7. package/dist/chmod-x.cjs +2 -1
  8. package/dist/chmod-x.d.cts.map +1 -1
  9. package/dist/chmod-x.d.mts.map +1 -1
  10. package/dist/chmod-x.mjs.map +1 -1
  11. package/dist/command-exists.cjs +3 -2
  12. package/dist/command-exists.d.cts.map +1 -1
  13. package/dist/command-exists.d.mts.map +1 -1
  14. package/dist/command-exists.mjs +1 -1
  15. package/dist/command-exists.mjs.map +1 -1
  16. package/dist/compress.cjs +7 -7
  17. package/dist/compress.d.cts.map +1 -1
  18. package/dist/compress.d.mts.map +1 -1
  19. package/dist/compress.mjs +5 -6
  20. package/dist/compress.mjs.map +1 -1
  21. package/dist/constants.d.cts.map +1 -1
  22. package/dist/constants.d.mts.map +1 -1
  23. package/dist/copy-file.cjs +16 -15
  24. package/dist/copy-file.d.cts +0 -1
  25. package/dist/copy-file.d.cts.map +1 -1
  26. package/dist/copy-file.d.mts +0 -1
  27. package/dist/copy-file.d.mts.map +1 -1
  28. package/dist/copy-file.mjs +6 -6
  29. package/dist/exists.cjs +2 -1
  30. package/dist/exists.d.cts.map +1 -1
  31. package/dist/exists.d.mts.map +1 -1
  32. package/dist/get-parent-path.cjs +14 -13
  33. package/dist/get-parent-path.d.cts.map +1 -1
  34. package/dist/get-parent-path.d.mts.map +1 -1
  35. package/dist/get-parent-path.mjs +6 -6
  36. package/dist/get-parent-path.mjs.map +1 -1
  37. package/dist/get-workspace-root.cjs +14 -13
  38. package/dist/get-workspace-root.d.cts.map +1 -1
  39. package/dist/get-workspace-root.d.mts.map +1 -1
  40. package/dist/get-workspace-root.mjs +3 -3
  41. package/dist/get-workspace-root.mjs.map +1 -1
  42. package/dist/helpers.cjs +2 -1
  43. package/dist/helpers.d.cts.map +1 -1
  44. package/dist/helpers.d.mts.map +1 -1
  45. package/dist/helpers.mjs.map +1 -1
  46. package/dist/index.cjs +1 -0
  47. package/dist/install.cjs +6 -5
  48. package/dist/install.d.cts +0 -2
  49. package/dist/install.d.cts.map +1 -1
  50. package/dist/install.d.mts +0 -3
  51. package/dist/install.d.mts.map +1 -1
  52. package/dist/install.mjs +1 -1
  53. package/dist/is-file.cjs +7 -6
  54. package/dist/is-file.d.cts.map +1 -1
  55. package/dist/is-file.d.mts.map +1 -1
  56. package/dist/is-file.mjs +1 -1
  57. package/dist/json/src/storm-json.cjs +3 -3
  58. package/dist/json/src/storm-json.mjs +1 -1
  59. package/dist/json/src/storm-json.mjs.map +1 -1
  60. package/dist/json/src/types.d.cts +0 -1
  61. package/dist/json/src/types.d.cts.map +1 -1
  62. package/dist/json/src/types.d.mts +0 -1
  63. package/dist/json/src/types.d.mts.map +1 -1
  64. package/dist/json/src/utils/code-frames.mjs.map +1 -1
  65. package/dist/json/src/utils/parse-error.cjs +1 -1
  66. package/dist/json/src/utils/stringify.mjs.map +1 -1
  67. package/dist/json/src/utils/strip-comments.cjs +4 -5
  68. package/dist/json/src/utils/strip-comments.mjs +4 -6
  69. package/dist/json/src/utils/strip-comments.mjs.map +1 -1
  70. package/dist/json.cjs +6 -4
  71. package/dist/json.d.cts +0 -1
  72. package/dist/json.d.cts.map +1 -1
  73. package/dist/json.d.mts +0 -1
  74. package/dist/json.d.mts.map +1 -1
  75. package/dist/json.mjs +2 -2
  76. package/dist/list-files.cjs +6 -5
  77. package/dist/list-files.d.cts.map +1 -1
  78. package/dist/list-files.d.mts.map +1 -1
  79. package/dist/list-files.mjs +1 -1
  80. package/dist/list-files.mjs.map +1 -1
  81. package/dist/package-fns.cjs +12 -11
  82. package/dist/package-fns.d.cts +0 -1
  83. package/dist/package-fns.d.cts.map +1 -1
  84. package/dist/package-fns.d.mts +0 -1
  85. package/dist/package-fns.d.mts.map +1 -1
  86. package/dist/package-fns.mjs +4 -4
  87. package/dist/read-file.cjs +2 -1
  88. package/dist/read-file.d.cts.map +1 -1
  89. package/dist/read-file.d.mts.map +1 -1
  90. package/dist/registry.cjs +4 -3
  91. package/dist/registry.d.cts.map +1 -1
  92. package/dist/registry.d.mts.map +1 -1
  93. package/dist/registry.mjs.map +1 -1
  94. package/dist/remove-file.cjs +2 -1
  95. package/dist/remove-file.d.cts.map +1 -1
  96. package/dist/remove-file.d.mts.map +1 -1
  97. package/dist/resolve.cjs +38 -37
  98. package/dist/resolve.d.cts.map +1 -1
  99. package/dist/resolve.d.mts.map +1 -1
  100. package/dist/resolve.mjs +18 -18
  101. package/dist/resolve.mjs.map +1 -1
  102. package/dist/semver-fns.cjs +5 -4
  103. package/dist/semver-fns.d.cts.map +1 -1
  104. package/dist/semver-fns.d.mts.map +1 -1
  105. package/dist/semver-fns.mjs +1 -1
  106. package/dist/semver-fns.mjs.map +1 -1
  107. package/dist/toml.cjs +3 -2
  108. package/dist/toml.d.cts +3 -4
  109. package/dist/toml.d.cts.map +1 -1
  110. package/dist/toml.d.mts +3 -4
  111. package/dist/toml.d.mts.map +1 -1
  112. package/dist/tsconfig.cjs +13 -12
  113. package/dist/tsconfig.d.cts +0 -1
  114. package/dist/tsconfig.d.cts.map +1 -1
  115. package/dist/tsconfig.d.mts +0 -1
  116. package/dist/tsconfig.d.mts.map +1 -1
  117. package/dist/tsconfig.mjs +5 -5
  118. package/dist/type-checks/src/index.cjs +3 -3
  119. package/dist/type-checks/src/index.mjs +3 -3
  120. package/dist/type-checks/src/is-buffer.cjs +2 -2
  121. package/dist/type-checks/src/is-buffer.mjs +1 -1
  122. package/dist/type-checks/src/is-buffer.mjs.map +1 -1
  123. package/dist/type-checks/src/is-set-string.cjs +1 -1
  124. package/dist/type-checks/src/is-set-string.mjs +1 -1
  125. package/dist/types/src/file.d.cts +0 -1
  126. package/dist/types/src/file.d.cts.map +1 -1
  127. package/dist/types/src/file.d.mts +0 -1
  128. package/dist/types/src/file.d.mts.map +1 -1
  129. package/dist/types/src/package-json.d.cts.map +1 -1
  130. package/dist/types/src/package-json.d.mts.map +1 -1
  131. package/dist/types/src/package-manager.d.cts.map +1 -1
  132. package/dist/types/src/package-manager.d.mts.map +1 -1
  133. package/dist/types/src/tsconfig.d.cts.map +1 -1
  134. package/dist/types/src/tsconfig.d.mts.map +1 -1
  135. package/dist/write-file.cjs +6 -5
  136. package/dist/write-file.d.cts.map +1 -1
  137. package/dist/write-file.d.mts.map +1 -1
  138. package/dist/write-file.mjs +2 -2
  139. package/dist/yaml.cjs +2 -1
  140. package/dist/yaml.d.cts.map +1 -1
  141. package/dist/yaml.d.mts.map +1 -1
  142. package/package.json +140 -59
  143. package/dist/convert/src/array-buffer-to-string.cjs +0 -19
  144. package/dist/convert/src/array-buffer-to-string.mjs +0 -19
  145. package/dist/convert/src/array-buffer-to-string.mjs.map +0 -1
  146. package/dist/convert/src/to-array.cjs +0 -15
  147. package/dist/convert/src/to-array.mjs +0 -15
  148. package/dist/convert/src/to-array.mjs.map +0 -1
  149. package/dist/convert/src/uint8-array-to-string.cjs +0 -15
  150. package/dist/convert/src/uint8-array-to-string.mjs +0 -16
  151. package/dist/convert/src/uint8-array-to-string.mjs.map +0 -1
  152. package/dist/helpers/src/get-unique.cjs +0 -14
  153. package/dist/helpers/src/get-unique.mjs +0 -14
  154. package/dist/helpers/src/get-unique.mjs.map +0 -1
  155. package/dist/path/src/append.cjs +0 -57
  156. package/dist/path/src/append.mjs +0 -57
  157. package/dist/path/src/append.mjs.map +0 -1
  158. package/dist/path/src/correct-path.cjs +0 -138
  159. package/dist/path/src/correct-path.mjs +0 -135
  160. package/dist/path/src/correct-path.mjs.map +0 -1
  161. package/dist/path/src/cwd.cjs +0 -17
  162. package/dist/path/src/cwd.mjs +0 -17
  163. package/dist/path/src/cwd.mjs.map +0 -1
  164. package/dist/path/src/file-path-fns.cjs +0 -178
  165. package/dist/path/src/file-path-fns.mjs +0 -171
  166. package/dist/path/src/file-path-fns.mjs.map +0 -1
  167. package/dist/path/src/is-parent-path.cjs +0 -32
  168. package/dist/path/src/is-parent-path.mjs +0 -33
  169. package/dist/path/src/is-parent-path.mjs.map +0 -1
  170. package/dist/path/src/is-root-dir.cjs +0 -14
  171. package/dist/path/src/is-root-dir.mjs +0 -14
  172. package/dist/path/src/is-root-dir.mjs.map +0 -1
  173. package/dist/path/src/is-type.cjs +0 -68
  174. package/dist/path/src/is-type.mjs +0 -67
  175. package/dist/path/src/is-type.mjs.map +0 -1
  176. package/dist/path/src/join-paths.cjs +0 -122
  177. package/dist/path/src/join-paths.mjs +0 -123
  178. package/dist/path/src/join-paths.mjs.map +0 -1
  179. package/dist/path/src/regex.cjs +0 -20
  180. package/dist/path/src/regex.mjs +0 -13
  181. package/dist/path/src/regex.mjs.map +0 -1
  182. package/dist/path/src/replace.cjs +0 -24
  183. package/dist/path/src/replace.mjs +0 -25
  184. package/dist/path/src/replace.mjs.map +0 -1
  185. package/dist/path/src/resolve-parent-path.cjs +0 -18
  186. package/dist/path/src/resolve-parent-path.mjs +0 -19
  187. package/dist/path/src/resolve-parent-path.mjs.map +0 -1
  188. package/dist/path/src/slash.cjs +0 -15
  189. package/dist/path/src/slash.mjs +0 -15
  190. package/dist/path/src/slash.mjs.map +0 -1
  191. package/dist/string-format/src/package.cjs +0 -92
  192. package/dist/string-format/src/package.mjs +0 -92
  193. package/dist/string-format/src/package.mjs.map +0 -1
  194. package/dist/types/src/base.cjs +0 -6
  195. package/dist/types/src/base.mjs +0 -6
  196. package/dist/types/src/base.mjs.map +0 -1
@@ -1,9 +1,10 @@
1
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
- const require_cwd = require('./path/src/cwd.cjs');
3
- const require_file_path_fns = require('./path/src/file-path-fns.cjs');
4
- const require_is_root_dir = require('./path/src/is-root-dir.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
5
3
  const require_get_parent_path = require('./get-parent-path.cjs');
6
- let __storm_software_config_tools = require("@storm-software/config-tools");
4
+ let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
5
+ let _stryke_path_cwd = require("@stryke/path/cwd");
6
+ let _storm_software_config_tools = require("@storm-software/config-tools");
7
+ let _stryke_path_is_root_dir = require("@stryke/path/is-root-dir");
7
8
 
8
9
  //#region src/get-workspace-root.ts
9
10
  const WORKSPACE_ROOT_CONTENT = [
@@ -79,14 +80,14 @@ const PROJECT_ROOT_CONTENT = [
79
80
  * @param dir - A directory to start the search from
80
81
  * @returns The workspace root path
81
82
  */
82
- function getWorkspaceRoot(dir = require_cwd.cwd()) {
83
+ function getWorkspaceRoot(dir = (0, _stryke_path_cwd.cwd)()) {
83
84
  if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) return process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH;
84
- const root = (0, __storm_software_config_tools.findWorkspaceRootSafe)(dir);
85
+ const root = (0, _storm_software_config_tools.findWorkspaceRootSafe)(dir);
85
86
  if (root) return root;
86
87
  let result = require_get_parent_path.getParentPath(WORKSPACE_ROOT_CONTENT, dir);
87
88
  if (result) return result;
88
89
  result = dir;
89
- while (result && !require_is_root_dir.isSystemRoot(result)) {
90
+ while (result && !(0, _stryke_path_is_root_dir.isSystemRoot)(result)) {
90
91
  result = require_get_parent_path.getParentPath("storm-workspace.json", result, {
91
92
  skipCwd: true,
92
93
  includeNameInResults: false
@@ -101,7 +102,7 @@ function getWorkspaceRoot(dir = require_cwd.cwd()) {
101
102
  * @param dir - A directory to check
102
103
  * @returns True if the directory is the workspace root, false otherwise
103
104
  */
104
- function isWorkspaceRoot(dir = require_cwd.cwd()) {
105
+ function isWorkspaceRoot(dir = (0, _stryke_path_cwd.cwd)()) {
105
106
  const workspaceRoot = getWorkspaceRoot(dir);
106
107
  if (workspaceRoot) return workspaceRoot === dir;
107
108
  return false;
@@ -112,7 +113,7 @@ function isWorkspaceRoot(dir = require_cwd.cwd()) {
112
113
  * @param dir - A directory to start the search from
113
114
  * @returns The project root path
114
115
  */
115
- function getProjectRoot(dir = require_cwd.cwd()) {
116
+ function getProjectRoot(dir = (0, _stryke_path_cwd.cwd)()) {
116
117
  const result = require_get_parent_path.getParentPath(PROJECT_ROOT_CONTENT, dir);
117
118
  if (result) return result;
118
119
  return dir;
@@ -123,7 +124,7 @@ function getProjectRoot(dir = require_cwd.cwd()) {
123
124
  * @param dir - A directory to check
124
125
  * @returns True if the directory is the project root, false otherwise
125
126
  */
126
- function isProjectRoot(dir = require_cwd.cwd()) {
127
+ function isProjectRoot(dir = (0, _stryke_path_cwd.cwd)()) {
127
128
  const projectRoot = getProjectRoot(dir);
128
129
  if (projectRoot) return projectRoot === dir;
129
130
  return false;
@@ -135,7 +136,7 @@ function isProjectRoot(dir = require_cwd.cwd()) {
135
136
  * @returns The file path relative to the workspace root
136
137
  */
137
138
  function relativeToWorkspaceRoot(filePath) {
138
- return require_file_path_fns.relativePath(filePath, getWorkspaceRoot());
139
+ return (0, _stryke_path_file_path_fns.relativePath)(filePath, getWorkspaceRoot());
139
140
  }
140
141
  /**
141
142
  * Find the file path relative to the project root path.
@@ -144,7 +145,7 @@ function relativeToWorkspaceRoot(filePath) {
144
145
  * @returns The file path relative to the project root
145
146
  */
146
147
  function relativeToProjectRoot(filePath) {
147
- return require_file_path_fns.relativePath(filePath, getProjectRoot());
148
+ return (0, _stryke_path_file_path_fns.relativePath)(filePath, getProjectRoot());
148
149
  }
149
150
 
150
151
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"get-workspace-root.d.cts","names":[],"sources":["../src/get-workspace-root.ts"],"sourcesContent":[],"mappings":";cAwBa;AAAA,cAwDA,oBAFH,EAAA,MAAA,EAAA;AAEV;AAmBA;AAoCA;AAeA;AAgBA;AAeA;AAUgB,iBA5FA,gBAAA,CA4FqB,GAAA,CAAA,EAAA,MAAA,CAAA,EAAA,MAAA;;;;;;;iBAxDrB,eAAA;;;;;;;iBAeA,cAAA;;;;;;;iBAgBA,aAAA;;;;;;;iBAeA,uBAAA;;;;;;;iBAUA,qBAAA"}
1
+ {"version":3,"file":"get-workspace-root.d.cts","names":[],"sources":["../src/get-workspace-root.ts"],"mappings":";cAwBa,sBAAA;AAAA,cAwDA,oBAAA;;;;;AAAb;;iBAmBgB,gBAAA,CAAiB,GAAA;;;AAAjC;;;;iBAoCgB,eAAA,CAAgB,GAAA;AAAhC;;;;;AAeA;AAfA,iBAegB,cAAA,CAAe,GAAA;;;;AAgB/B;;;iBAAgB,aAAA,CAAc,GAAA;;AAe9B;;;;;iBAAgB,uBAAA,CAAwB,QAAA;;;;;;;iBAUxB,qBAAA,CAAsB,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-workspace-root.d.mts","names":[],"sources":["../src/get-workspace-root.ts"],"sourcesContent":[],"mappings":";cAwBa;AAAA,cAwDA,oBAFH,EAAA,MAAA,EAAA;AAEV;AAmBA;AAoCA;AAeA;AAgBA;AAeA;AAUgB,iBA5FA,gBAAA,CA4FqB,GAAA,CAAA,EAAA,MAAA,CAAA,EAAA,MAAA;;;;;;;iBAxDrB,eAAA;;;;;;;iBAeA,cAAA;;;;;;;iBAgBA,aAAA;;;;;;;iBAeA,uBAAA;;;;;;;iBAUA,qBAAA"}
1
+ {"version":3,"file":"get-workspace-root.d.mts","names":[],"sources":["../src/get-workspace-root.ts"],"mappings":";cAwBa,sBAAA;AAAA,cAwDA,oBAAA;;;;;AAAb;;iBAmBgB,gBAAA,CAAiB,GAAA;;;AAAjC;;;;iBAoCgB,eAAA,CAAgB,GAAA;AAAhC;;;;;AAeA;AAfA,iBAegB,cAAA,CAAe,GAAA;;;;AAgB/B;;;iBAAgB,aAAA,CAAc,GAAA;;AAe9B;;;;;iBAAgB,uBAAA,CAAwB,QAAA;;;;;;;iBAUxB,qBAAA,CAAsB,QAAA"}
@@ -1,8 +1,8 @@
1
- import { cwd } from "./path/src/cwd.mjs";
2
- import { relativePath } from "./path/src/file-path-fns.mjs";
3
- import { isSystemRoot } from "./path/src/is-root-dir.mjs";
4
1
  import { getParentPath } from "./get-parent-path.mjs";
2
+ import { relativePath } from "@stryke/path/file-path-fns";
3
+ import { cwd } from "@stryke/path/cwd";
5
4
  import { findWorkspaceRootSafe } from "@storm-software/config-tools";
5
+ import { isSystemRoot } from "@stryke/path/is-root-dir";
6
6
 
7
7
  //#region src/get-workspace-root.ts
8
8
  const WORKSPACE_ROOT_CONTENT = [
@@ -1 +1 @@
1
- {"version":3,"file":"get-workspace-root.mjs","names":["WORKSPACE_ROOT_CONTENT: string[]","PROJECT_ROOT_CONTENT: string[]"],"sources":["../src/get-workspace-root.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 { findWorkspaceRootSafe } from \"@storm-software/config-tools\";\nimport { cwd } from \"@stryke/path/cwd\";\nimport { relativePath } from \"@stryke/path/file-path-fns\";\nimport { isSystemRoot } from \"@stryke/path/is-root-dir\";\nimport { getParentPath } from \"./get-parent-path\";\n\nexport const WORKSPACE_ROOT_CONTENT: string[] = [\n \".all-contributorsrc\",\n \".commitlintrc\",\n \".github\",\n \".git\",\n \".husky\",\n \".huskyrc\",\n \".lintstagedrc\",\n \".log4brains.yml\",\n \".npmrc\",\n \".nx\",\n \".storm-workspace.js\",\n \".storm-workspace.json\",\n \".storm-workspace.ts\",\n \".storm-workspace.yaml\",\n \".storm-workspace.yml\",\n \".vscode\",\n \".whitesource\",\n \"bun.lock\",\n \"bun.lockb\",\n \"lefthook.yaml\",\n \"lefthook.yml\",\n \"lerna.json\",\n \"npm-lock.json\",\n \"npm-lock.yaml\",\n \"npm-lock.yml\",\n \"npm-workspace.json\",\n \"npm-workspace.yaml\",\n \"npm-workspace.yml\",\n \"nx.json\",\n \"package-lock.json\",\n \"patches\",\n \"pnpm-lock.json\",\n \"pnpm-lock.yaml\",\n \"pnpm-lock.yml\",\n \"pnpm-workspace.json\",\n \"pnpm-workspace.yaml\",\n \"pnpm-workspace.yml\",\n \"socket.yaml\",\n \"storm-workspace.js\",\n \"storm-workspace.json\",\n \"storm-workspace.ts\",\n \"storm-workspace.yaml\",\n \"storm-workspace.yml\",\n \"syncpack.config.js\",\n \"syncpack.json\",\n \"turbo.json\",\n \"yarn-lock.json\",\n \"yarn-lock.yaml\",\n \"yarn-lock.yml\",\n \"yarn-workspace.json\",\n \"yarn-workspace.yaml\",\n \"yarn-workspace.yml\",\n \"yarn.lock\"\n] as const;\n\nexport const PROJECT_ROOT_CONTENT: string[] = [\n \".powerlines\",\n \".storm\",\n \"package.json\",\n \"powerlines.json\",\n \"powerlines.yaml\",\n \"powerlines.yml\",\n \"powerlines.toml\",\n \"powerlines.config.js\",\n \"powerlines.config.ts\",\n \"project.json\"\n] as const;\n\n/**\n * Get the workspace root path\n *\n * @param dir - A directory to start the search from\n * @returns The workspace root path\n */\nexport function getWorkspaceRoot(dir = cwd()) {\n if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {\n return (process.env.STORM_WORKSPACE_ROOT ||\n process.env.NX_WORKSPACE_ROOT_PATH)!;\n }\n\n const root = findWorkspaceRootSafe(dir);\n if (root) {\n return root;\n }\n\n let result = getParentPath(WORKSPACE_ROOT_CONTENT, dir);\n if (result) {\n return result;\n }\n\n result = dir;\n while (result && !isSystemRoot(result)) {\n result = getParentPath(\"storm-workspace.json\", result, {\n skipCwd: true,\n includeNameInResults: false\n });\n if (result) {\n return result;\n }\n }\n\n return dir;\n}\n\n/**\n * Check if the given directory is the workspace root\n *\n * @param dir - A directory to check\n * @returns True if the directory is the workspace root, false otherwise\n */\nexport function isWorkspaceRoot(dir = cwd()): boolean {\n const workspaceRoot = getWorkspaceRoot(dir);\n if (workspaceRoot) {\n return workspaceRoot === dir;\n }\n\n return false;\n}\n\n/**\n * Get the project root path\n *\n * @param dir - A directory to start the search from\n * @returns The project root path\n */\nexport function getProjectRoot(dir = cwd()) {\n const result = getParentPath(PROJECT_ROOT_CONTENT, dir);\n\n if (result) {\n return result;\n }\n\n return dir;\n}\n\n/**\n * Check if the given directory is the project root\n *\n * @param dir - A directory to check\n * @returns True if the directory is the project root, false otherwise\n */\nexport function isProjectRoot(dir = cwd()): boolean {\n const projectRoot = getProjectRoot(dir);\n if (projectRoot) {\n return projectRoot === dir;\n }\n\n return false;\n}\n\n/**\n * Find the file path relative to the workspace root path.\n *\n * @param filePath - The file path to process\n * @returns The file path relative to the workspace root\n */\nexport function relativeToWorkspaceRoot(filePath: string) {\n return relativePath(filePath, getWorkspaceRoot());\n}\n\n/**\n * Find the file path relative to the project root path.\n *\n * @param filePath - The file path to process\n * @returns The file path relative to the project root\n */\nexport function relativeToProjectRoot(filePath: string) {\n return relativePath(filePath, getProjectRoot());\n}\n"],"mappings":";;;;;;;AAwBA,MAAaA,yBAAmC;CAC9C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAaC,uBAAiC;CAC5C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;AAQD,SAAgB,iBAAiB,MAAM,KAAK,EAAE;AAC5C,KAAI,QAAQ,IAAI,wBAAwB,QAAQ,IAAI,uBAClD,QAAQ,QAAQ,IAAI,wBAClB,QAAQ,IAAI;CAGhB,MAAM,OAAO,sBAAsB,IAAI;AACvC,KAAI,KACF,QAAO;CAGT,IAAI,SAAS,cAAc,wBAAwB,IAAI;AACvD,KAAI,OACF,QAAO;AAGT,UAAS;AACT,QAAO,UAAU,CAAC,aAAa,OAAO,EAAE;AACtC,WAAS,cAAc,wBAAwB,QAAQ;GACrD,SAAS;GACT,sBAAsB;GACvB,CAAC;AACF,MAAI,OACF,QAAO;;AAIX,QAAO;;;;;;;;AAST,SAAgB,gBAAgB,MAAM,KAAK,EAAW;CACpD,MAAM,gBAAgB,iBAAiB,IAAI;AAC3C,KAAI,cACF,QAAO,kBAAkB;AAG3B,QAAO;;;;;;;;AAST,SAAgB,eAAe,MAAM,KAAK,EAAE;CAC1C,MAAM,SAAS,cAAc,sBAAsB,IAAI;AAEvD,KAAI,OACF,QAAO;AAGT,QAAO;;;;;;;;AAST,SAAgB,cAAc,MAAM,KAAK,EAAW;CAClD,MAAM,cAAc,eAAe,IAAI;AACvC,KAAI,YACF,QAAO,gBAAgB;AAGzB,QAAO;;;;;;;;AAST,SAAgB,wBAAwB,UAAkB;AACxD,QAAO,aAAa,UAAU,kBAAkB,CAAC;;;;;;;;AASnD,SAAgB,sBAAsB,UAAkB;AACtD,QAAO,aAAa,UAAU,gBAAgB,CAAC"}
1
+ {"version":3,"file":"get-workspace-root.mjs","names":[],"sources":["../src/get-workspace-root.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 { findWorkspaceRootSafe } from \"@storm-software/config-tools\";\nimport { cwd } from \"@stryke/path/cwd\";\nimport { relativePath } from \"@stryke/path/file-path-fns\";\nimport { isSystemRoot } from \"@stryke/path/is-root-dir\";\nimport { getParentPath } from \"./get-parent-path\";\n\nexport const WORKSPACE_ROOT_CONTENT: string[] = [\n \".all-contributorsrc\",\n \".commitlintrc\",\n \".github\",\n \".git\",\n \".husky\",\n \".huskyrc\",\n \".lintstagedrc\",\n \".log4brains.yml\",\n \".npmrc\",\n \".nx\",\n \".storm-workspace.js\",\n \".storm-workspace.json\",\n \".storm-workspace.ts\",\n \".storm-workspace.yaml\",\n \".storm-workspace.yml\",\n \".vscode\",\n \".whitesource\",\n \"bun.lock\",\n \"bun.lockb\",\n \"lefthook.yaml\",\n \"lefthook.yml\",\n \"lerna.json\",\n \"npm-lock.json\",\n \"npm-lock.yaml\",\n \"npm-lock.yml\",\n \"npm-workspace.json\",\n \"npm-workspace.yaml\",\n \"npm-workspace.yml\",\n \"nx.json\",\n \"package-lock.json\",\n \"patches\",\n \"pnpm-lock.json\",\n \"pnpm-lock.yaml\",\n \"pnpm-lock.yml\",\n \"pnpm-workspace.json\",\n \"pnpm-workspace.yaml\",\n \"pnpm-workspace.yml\",\n \"socket.yaml\",\n \"storm-workspace.js\",\n \"storm-workspace.json\",\n \"storm-workspace.ts\",\n \"storm-workspace.yaml\",\n \"storm-workspace.yml\",\n \"syncpack.config.js\",\n \"syncpack.json\",\n \"turbo.json\",\n \"yarn-lock.json\",\n \"yarn-lock.yaml\",\n \"yarn-lock.yml\",\n \"yarn-workspace.json\",\n \"yarn-workspace.yaml\",\n \"yarn-workspace.yml\",\n \"yarn.lock\"\n] as const;\n\nexport const PROJECT_ROOT_CONTENT: string[] = [\n \".powerlines\",\n \".storm\",\n \"package.json\",\n \"powerlines.json\",\n \"powerlines.yaml\",\n \"powerlines.yml\",\n \"powerlines.toml\",\n \"powerlines.config.js\",\n \"powerlines.config.ts\",\n \"project.json\"\n] as const;\n\n/**\n * Get the workspace root path\n *\n * @param dir - A directory to start the search from\n * @returns The workspace root path\n */\nexport function getWorkspaceRoot(dir = cwd()) {\n if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {\n return (process.env.STORM_WORKSPACE_ROOT ||\n process.env.NX_WORKSPACE_ROOT_PATH)!;\n }\n\n const root = findWorkspaceRootSafe(dir);\n if (root) {\n return root;\n }\n\n let result = getParentPath(WORKSPACE_ROOT_CONTENT, dir);\n if (result) {\n return result;\n }\n\n result = dir;\n while (result && !isSystemRoot(result)) {\n result = getParentPath(\"storm-workspace.json\", result, {\n skipCwd: true,\n includeNameInResults: false\n });\n if (result) {\n return result;\n }\n }\n\n return dir;\n}\n\n/**\n * Check if the given directory is the workspace root\n *\n * @param dir - A directory to check\n * @returns True if the directory is the workspace root, false otherwise\n */\nexport function isWorkspaceRoot(dir = cwd()): boolean {\n const workspaceRoot = getWorkspaceRoot(dir);\n if (workspaceRoot) {\n return workspaceRoot === dir;\n }\n\n return false;\n}\n\n/**\n * Get the project root path\n *\n * @param dir - A directory to start the search from\n * @returns The project root path\n */\nexport function getProjectRoot(dir = cwd()) {\n const result = getParentPath(PROJECT_ROOT_CONTENT, dir);\n\n if (result) {\n return result;\n }\n\n return dir;\n}\n\n/**\n * Check if the given directory is the project root\n *\n * @param dir - A directory to check\n * @returns True if the directory is the project root, false otherwise\n */\nexport function isProjectRoot(dir = cwd()): boolean {\n const projectRoot = getProjectRoot(dir);\n if (projectRoot) {\n return projectRoot === dir;\n }\n\n return false;\n}\n\n/**\n * Find the file path relative to the workspace root path.\n *\n * @param filePath - The file path to process\n * @returns The file path relative to the workspace root\n */\nexport function relativeToWorkspaceRoot(filePath: string) {\n return relativePath(filePath, getWorkspaceRoot());\n}\n\n/**\n * Find the file path relative to the project root path.\n *\n * @param filePath - The file path to process\n * @returns The file path relative to the project root\n */\nexport function relativeToProjectRoot(filePath: string) {\n return relativePath(filePath, getProjectRoot());\n}\n"],"mappings":";;;;;;;AAwBA,MAAa,yBAAmC;CAC9C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,uBAAiC;CAC5C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;AAQD,SAAgB,iBAAiB,MAAM,KAAK,EAAE;AAC5C,KAAI,QAAQ,IAAI,wBAAwB,QAAQ,IAAI,uBAClD,QAAQ,QAAQ,IAAI,wBAClB,QAAQ,IAAI;CAGhB,MAAM,OAAO,sBAAsB,IAAI;AACvC,KAAI,KACF,QAAO;CAGT,IAAI,SAAS,cAAc,wBAAwB,IAAI;AACvD,KAAI,OACF,QAAO;AAGT,UAAS;AACT,QAAO,UAAU,CAAC,aAAa,OAAO,EAAE;AACtC,WAAS,cAAc,wBAAwB,QAAQ;GACrD,SAAS;GACT,sBAAsB;GACvB,CAAC;AACF,MAAI,OACF,QAAO;;AAIX,QAAO;;;;;;;;AAST,SAAgB,gBAAgB,MAAM,KAAK,EAAW;CACpD,MAAM,gBAAgB,iBAAiB,IAAI;AAC3C,KAAI,cACF,QAAO,kBAAkB;AAG3B,QAAO;;;;;;;;AAST,SAAgB,eAAe,MAAM,KAAK,EAAE;CAC1C,MAAM,SAAS,cAAc,sBAAsB,IAAI;AAEvD,KAAI,OACF,QAAO;AAGT,QAAO;;;;;;;;AAST,SAAgB,cAAc,MAAM,KAAK,EAAW;CAClD,MAAM,cAAc,eAAe,IAAI;AACvC,KAAI,YACF,QAAO,gBAAgB;AAGzB,QAAO;;;;;;;;AAST,SAAgB,wBAAwB,UAAkB;AACxD,QAAO,aAAa,UAAU,kBAAkB,CAAC;;;;;;;;AASnD,SAAgB,sBAAsB,UAAkB;AACtD,QAAO,aAAa,UAAU,gBAAgB,CAAC"}
package/dist/helpers.cjs CHANGED
@@ -1,4 +1,5 @@
1
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
3
  const require_exists = require('./exists.cjs');
3
4
  let node_fs = require("node:fs");
4
5
  let node_fs_promises = require("node:fs/promises");
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.cts","names":[],"sources":["../src/helpers.ts"],"sourcesContent":[],"mappings":";;AA6BA;AAcA;AAcA;AAcA;AAgBA;AA4BsB,iBAtFN,mBAAA,CAyFa,IAAA,EAAA,MAAA,CAAA,EAAA,MAAA,GAAA,SAAA;;;;;;;iBA3EP,eAAA,gBAA4B;;;;;;;iBAclC,mBAAA;;;;;;;iBAcM,eAAA,gBAA4B;;;;;;;;;iBAgB5B,kBAAA,kEAGO;;;;;;;;;iBAyBP,sBAAA,kEAGO"}
1
+ {"version":3,"file":"helpers.d.cts","names":[],"sources":["../src/helpers.ts"],"mappings":";;AA6BA;;;;;iBAAgB,mBAAA,CAAoB,IAAA;;;;;AA4BpC;;iBAdsB,eAAA,CAAgB,IAAA,WAAY,OAAA;;;AA4BlD;;;;iBAdgB,mBAAA,CAAoB,IAAA;AA8BpC;;;;;;AAAA,iBAhBsB,eAAA,CAAgB,IAAA,WAAY,OAAA;;;;AA4ClD;;;;;iBA5BsB,kBAAA,CACpB,WAAA,UACA,IAAA,UACA,mBAAA,WAA2B,OAAA;;;;;;;;;iBAyBP,sBAAA,CACpB,WAAA,UACA,IAAA,UACA,mBAAA,WAA2B,OAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.mts","names":[],"sources":["../src/helpers.ts"],"sourcesContent":[],"mappings":";;AA6BA;AAcA;AAcA;AAcA;AAgBA;AA4BsB,iBAtFN,mBAAA,CAyFa,IAAA,EAAA,MAAA,CAAA,EAAA,MAAA,GAAA,SAAA;;;;;;;iBA3EP,eAAA,gBAA4B;;;;;;;iBAclC,mBAAA;;;;;;;iBAcM,eAAA,gBAA4B;;;;;;;;;iBAgB5B,kBAAA,kEAGO;;;;;;;;;iBAyBP,sBAAA,kEAGO"}
1
+ {"version":3,"file":"helpers.d.mts","names":[],"sources":["../src/helpers.ts"],"mappings":";;AA6BA;;;;;iBAAgB,mBAAA,CAAoB,IAAA;;;;;AA4BpC;;iBAdsB,eAAA,CAAgB,IAAA,WAAY,OAAA;;;AA4BlD;;;;iBAdgB,mBAAA,CAAoB,IAAA;AA8BpC;;;;;;AAAA,iBAhBsB,eAAA,CAAgB,IAAA,WAAY,OAAA;;;;AA4ClD;;;;;iBA5BsB,kBAAA,CACpB,WAAA,UACA,IAAA,UACA,mBAAA,WAA2B,OAAA;;;;;;;;;iBAyBP,sBAAA,CACpB,WAAA,UACA,IAAA,UACA,mBAAA,WAA2B,OAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.mjs","names":["existsSync"],"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\nimport { parseTar, parseTarGzip } from \"nanotar\";\nimport { createWriteStream, mkdirSync, rmSync } from \"node:fs\";\nimport { mkdir, readFile, rm } from \"node:fs/promises\";\nimport { exists, existsSync } from \"./exists\";\n\n/**\n * Create a directory if it does not exist.\n *\n * @param path - The directory path to check\n * @returns An indicator specifying if the directory exists\n */\nexport function createDirectorySync(path: string) {\n if (existsSync(path)) {\n return;\n }\n\n return mkdirSync(path, { recursive: true });\n}\n\n/**\n * Create a directory if it does not exist.\n *\n * @param path - The directory path to check\n * @returns An indicator specifying if the directory exists\n */\nexport async function createDirectory(path: string) {\n if (await exists(path)) {\n return;\n }\n\n return mkdir(path, { recursive: true });\n}\n\n/**\n * Remove a directory if it exists.\n *\n * @param path - The directory path to check\n * @returns An indicator specifying if the directory exists\n */\nexport function removeDirectorySync(path: string) {\n if (!existsSync(path)) {\n return;\n }\n\n return rmSync(path, { recursive: true });\n}\n\n/**\n * Remove a directory if it exists.\n *\n * @param path - The directory path to check\n * @returns An indicator specifying if the directory exists\n */\nexport async function removeDirectory(path: string) {\n if (!existsSync(path)) {\n return;\n }\n\n return rm(path, { recursive: true });\n}\n\n/**\n * Extracts a file from a given tarball to the specified destination.\n *\n * @param tarballPath - The path to the tarball from where the file should be extracted.\n * @param file - The path to the file inside the tarball.\n * @param destinationFilePath - The destination file path.\n * @returns True if the file was extracted successfully, false otherwise.\n */\nexport async function extractFileFromTar(\n tarballPath: string,\n file: string,\n destinationFilePath: string\n) {\n const result = parseTar(await readFile(tarballPath));\n\n const entry = result.find(e => e.name === file);\n if (!entry?.data) {\n return;\n }\n\n if (!(await exists(destinationFilePath))) {\n await mkdir(destinationFilePath, { recursive: true });\n }\n\n const stream = createWriteStream(destinationFilePath);\n stream.write(entry.data);\n}\n\n/**\n * Extracts a file from a given TarGzip to the specified destination.\n *\n * @param tarballPath - The path to the tarball from where the file should be extracted.\n * @param file - The path to the file inside the tarball.\n * @param destinationFilePath - The destination file path.\n * @returns True if the file was extracted successfully, false otherwise.\n */\nexport async function extractFileFromTarGzip(\n tarballPath: string,\n file: string,\n destinationFilePath: string\n) {\n const result = await parseTarGzip(await readFile(tarballPath));\n\n const entry = result.find(e => e.name === file);\n if (!entry?.data) {\n return;\n }\n\n if (!(await exists(destinationFilePath))) {\n await mkdir(destinationFilePath, { recursive: true });\n }\n\n const stream = createWriteStream(destinationFilePath);\n stream.write(entry.data);\n}\n"],"mappings":";;;;;;;;;;;;AA6BA,SAAgB,oBAAoB,MAAc;AAChD,KAAIA,aAAW,KAAK,CAClB;AAGF,QAAO,UAAU,MAAM,EAAE,WAAW,MAAM,CAAC;;;;;;;;AAS7C,eAAsB,gBAAgB,MAAc;AAClD,KAAI,MAAM,OAAO,KAAK,CACpB;AAGF,QAAO,MAAM,MAAM,EAAE,WAAW,MAAM,CAAC;;;;;;;;AASzC,SAAgB,oBAAoB,MAAc;AAChD,KAAI,CAACA,aAAW,KAAK,CACnB;AAGF,QAAO,OAAO,MAAM,EAAE,WAAW,MAAM,CAAC;;;;;;;;AAS1C,eAAsB,gBAAgB,MAAc;AAClD,KAAI,CAACA,aAAW,KAAK,CACnB;AAGF,QAAO,GAAG,MAAM,EAAE,WAAW,MAAM,CAAC;;;;;;;;;;AAWtC,eAAsB,mBACpB,aACA,MACA,qBACA;CAGA,MAAM,QAFS,SAAS,MAAM,SAAS,YAAY,CAAC,CAE/B,MAAK,MAAK,EAAE,SAAS,KAAK;AAC/C,KAAI,CAAC,OAAO,KACV;AAGF,KAAI,CAAE,MAAM,OAAO,oBAAoB,CACrC,OAAM,MAAM,qBAAqB,EAAE,WAAW,MAAM,CAAC;AAIvD,CADe,kBAAkB,oBAAoB,CAC9C,MAAM,MAAM,KAAK;;;;;;;;;;AAW1B,eAAsB,uBACpB,aACA,MACA,qBACA;CAGA,MAAM,SAFS,MAAM,aAAa,MAAM,SAAS,YAAY,CAAC,EAEzC,MAAK,MAAK,EAAE,SAAS,KAAK;AAC/C,KAAI,CAAC,OAAO,KACV;AAGF,KAAI,CAAE,MAAM,OAAO,oBAAoB,CACrC,OAAM,MAAM,qBAAqB,EAAE,WAAW,MAAM,CAAC;AAIvD,CADe,kBAAkB,oBAAoB,CAC9C,MAAM,MAAM,KAAK"}
1
+ {"version":3,"file":"helpers.mjs","names":["existsSync"],"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\nimport { parseTar, parseTarGzip } from \"nanotar\";\nimport { createWriteStream, mkdirSync, rmSync } from \"node:fs\";\nimport { mkdir, readFile, rm } from \"node:fs/promises\";\nimport { exists, existsSync } from \"./exists\";\n\n/**\n * Create a directory if it does not exist.\n *\n * @param path - The directory path to check\n * @returns An indicator specifying if the directory exists\n */\nexport function createDirectorySync(path: string) {\n if (existsSync(path)) {\n return;\n }\n\n return mkdirSync(path, { recursive: true });\n}\n\n/**\n * Create a directory if it does not exist.\n *\n * @param path - The directory path to check\n * @returns An indicator specifying if the directory exists\n */\nexport async function createDirectory(path: string) {\n if (await exists(path)) {\n return;\n }\n\n return mkdir(path, { recursive: true });\n}\n\n/**\n * Remove a directory if it exists.\n *\n * @param path - The directory path to check\n * @returns An indicator specifying if the directory exists\n */\nexport function removeDirectorySync(path: string) {\n if (!existsSync(path)) {\n return;\n }\n\n return rmSync(path, { recursive: true });\n}\n\n/**\n * Remove a directory if it exists.\n *\n * @param path - The directory path to check\n * @returns An indicator specifying if the directory exists\n */\nexport async function removeDirectory(path: string) {\n if (!existsSync(path)) {\n return;\n }\n\n return rm(path, { recursive: true });\n}\n\n/**\n * Extracts a file from a given tarball to the specified destination.\n *\n * @param tarballPath - The path to the tarball from where the file should be extracted.\n * @param file - The path to the file inside the tarball.\n * @param destinationFilePath - The destination file path.\n * @returns True if the file was extracted successfully, false otherwise.\n */\nexport async function extractFileFromTar(\n tarballPath: string,\n file: string,\n destinationFilePath: string\n) {\n const result = parseTar(await readFile(tarballPath));\n\n const entry = result.find(e => e.name === file);\n if (!entry?.data) {\n return;\n }\n\n if (!(await exists(destinationFilePath))) {\n await mkdir(destinationFilePath, { recursive: true });\n }\n\n const stream = createWriteStream(destinationFilePath);\n stream.write(entry.data);\n}\n\n/**\n * Extracts a file from a given TarGzip to the specified destination.\n *\n * @param tarballPath - The path to the tarball from where the file should be extracted.\n * @param file - The path to the file inside the tarball.\n * @param destinationFilePath - The destination file path.\n * @returns True if the file was extracted successfully, false otherwise.\n */\nexport async function extractFileFromTarGzip(\n tarballPath: string,\n file: string,\n destinationFilePath: string\n) {\n const result = await parseTarGzip(await readFile(tarballPath));\n\n const entry = result.find(e => e.name === file);\n if (!entry?.data) {\n return;\n }\n\n if (!(await exists(destinationFilePath))) {\n await mkdir(destinationFilePath, { recursive: true });\n }\n\n const stream = createWriteStream(destinationFilePath);\n stream.write(entry.data);\n}\n"],"mappings":";;;;;;;;;;;;AA6BA,SAAgB,oBAAoB,MAAc;AAChD,KAAIA,aAAW,KAAK,CAClB;AAGF,QAAO,UAAU,MAAM,EAAE,WAAW,MAAM,CAAC;;;;;;;;AAS7C,eAAsB,gBAAgB,MAAc;AAClD,KAAI,MAAM,OAAO,KAAK,CACpB;AAGF,QAAO,MAAM,MAAM,EAAE,WAAW,MAAM,CAAC;;;;;;;;AASzC,SAAgB,oBAAoB,MAAc;AAChD,KAAI,CAACA,aAAW,KAAK,CACnB;AAGF,QAAO,OAAO,MAAM,EAAE,WAAW,MAAM,CAAC;;;;;;;;AAS1C,eAAsB,gBAAgB,MAAc;AAClD,KAAI,CAACA,aAAW,KAAK,CACnB;AAGF,QAAO,GAAG,MAAM,EAAE,WAAW,MAAM,CAAC;;;;;;;;;;AAWtC,eAAsB,mBACpB,aACA,MACA,qBACA;CAGA,MAAM,QAFS,SAAS,MAAM,SAAS,YAAY,CAE/B,CAAC,MAAK,MAAK,EAAE,SAAS,KAAK;AAC/C,KAAI,CAAC,OAAO,KACV;AAGF,KAAI,CAAE,MAAM,OAAO,oBAAoB,CACrC,OAAM,MAAM,qBAAqB,EAAE,WAAW,MAAM,CAAC;AAIvD,CADe,kBAAkB,oBAC3B,CAAC,MAAM,MAAM,KAAK;;;;;;;;;;AAW1B,eAAsB,uBACpB,aACA,MACA,qBACA;CAGA,MAAM,SAAQ,MAFO,aAAa,MAAM,SAAS,YAAY,CAAC,EAEzC,MAAK,MAAK,EAAE,SAAS,KAAK;AAC/C,KAAI,CAAC,OAAO,KACV;AAGF,KAAI,CAAE,MAAM,OAAO,oBAAoB,CACrC,OAAM,MAAM,qBAAqB,EAAE,WAAW,MAAM,CAAC;AAIvD,CADe,kBAAkB,oBAC3B,CAAC,MAAM,MAAM,KAAK"}
package/dist/index.cjs CHANGED
@@ -1,3 +1,4 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1
2
  const require_exists = require('./exists.cjs');
2
3
  const require_helpers = require('./helpers.cjs');
3
4
  const require_buffer = require('./buffer.cjs');
package/dist/install.cjs CHANGED
@@ -1,7 +1,8 @@
1
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
- const require_cwd = require('./path/src/cwd.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
3
  const require_resolve = require('./resolve.cjs');
4
- let __antfu_install_pkg = require("@antfu/install-pkg");
4
+ let _stryke_path_cwd = require("@stryke/path/cwd");
5
+ let _antfu_install_pkg = require("@antfu/install-pkg");
5
6
  require("tinyexec");
6
7
 
7
8
  //#region src/install.ts
@@ -13,7 +14,7 @@ require("tinyexec");
13
14
  * @returns The result of the command or an exception
14
15
  */
15
16
  async function install(nameOrNames, options) {
16
- return (0, __antfu_install_pkg.installPackage)(nameOrNames, options);
17
+ return (0, _antfu_install_pkg.installPackage)(nameOrNames, options);
17
18
  }
18
19
  /**
19
20
  * Check if a package exists and install it if it does not
@@ -22,7 +23,7 @@ async function install(nameOrNames, options) {
22
23
  * @param options - The options to use when installing the package
23
24
  */
24
25
  const packageExists = async (name, options) => {
25
- const resolvePath = await require_resolve.resolve(options?.cwd || require_cwd.cwd());
26
+ const resolvePath = await require_resolve.resolve(options?.cwd || (0, _stryke_path_cwd.cwd)());
26
27
  try {
27
28
  await require_resolve.resolve(name, { paths: [resolvePath] });
28
29
  } catch {
@@ -1,7 +1,5 @@
1
1
  import { InstallPackageOptions, installPackage } from "@antfu/install-pkg";
2
-
3
2
  //#region src/install.d.ts
4
-
5
3
  /**
6
4
  * Install a specific package
7
5
  *
@@ -1 +1 @@
1
- {"version":3,"file":"install.d.cts","names":[],"sources":["../src/install.ts"],"sourcesContent":[],"mappings":";;;;AA8BA;;;;;;AAWsB,iBAXA,OAAA,CAWO,IAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EATjB,qBASiB,CAAA,EAR1B,OAQ0B,CARlB,UAQkB,CAAA,OARA,cAQA,CAAA,CAAA;;;;;;AAyB7B;iBAzBsB,OAAA,4BAEV,wBACT,QAAQ,kBAAkB;;;;;;;cAsBhB,wCAED,0BAAqB"}
1
+ {"version":3,"file":"install.d.cts","names":[],"sources":["../src/install.ts"],"mappings":";;;AA8BA;;;;;iBAAsB,OAAA,CACpB,IAAA,UACA,OAAA,GAAU,qBAAA,GACT,OAAA,CAAQ,UAAA,QAAkB,cAAA;;;;;;;iBAQP,OAAA,CACpB,KAAA,YACA,OAAA,GAAU,qBAAA,GACT,OAAA,CAAQ,UAAA,QAAkB,cAAA;;;;;AAH7B;;cAyBa,aAAA,GACX,IAAA,UACA,OAAA,GAAU,qBAAA,KAAqB,OAAA"}
@@ -1,8 +1,5 @@
1
1
  import { InstallPackageOptions, installPackage } from "@antfu/install-pkg";
2
- import "tinyexec";
3
-
4
2
  //#region src/install.d.ts
5
-
6
3
  /**
7
4
  * Install a specific package
8
5
  *
@@ -1 +1 @@
1
- {"version":3,"file":"install.d.mts","names":[],"sources":["../src/install.ts"],"sourcesContent":[],"mappings":";;;;;;AA8BA;;;;;AAGU,iBAHY,OAAA,CAGZ,IAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EADE,qBACF,CAAA,EAAP,OAAO,CAAC,UAAD,CAAA,OAAmB,cAAnB,CAAA,CAAA;AAQV;;;;;;AAyBa,iBAzBS,OAAA,CA2BV,KAAA,EAAA,MAAA,EAAA,EAAA,OAAqB,CAAA,EAzBrB,qBAyBqB,CAAA,EAxB9B,OAwB8B,CAxBtB,UAwBsB,CAAA,OAxBJ,cAwBI,CAAA,CAAA;;;;;;;cAFpB,wCAED,0BAAqB"}
1
+ {"version":3,"file":"install.d.mts","names":[],"sources":["../src/install.ts"],"mappings":";;;AA8BA;;;;;iBAAsB,OAAA,CACpB,IAAA,UACA,OAAA,GAAU,qBAAA,GACT,OAAA,CAAQ,UAAA,QAAkB,cAAA;;;;;;;iBAQP,OAAA,CACpB,KAAA,YACA,OAAA,GAAU,qBAAA,GACT,OAAA,CAAQ,UAAA,QAAkB,cAAA;;;;;AAH7B;;cAyBa,aAAA,GACX,IAAA,UACA,OAAA,GAAU,qBAAA,KAAqB,OAAA"}
package/dist/install.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { cwd } from "./path/src/cwd.mjs";
2
1
  import { resolve } from "./resolve.mjs";
2
+ import { cwd } from "@stryke/path/cwd";
3
3
  import { installPackage } from "@antfu/install-pkg";
4
4
  import "tinyexec";
5
5
 
package/dist/is-file.cjs CHANGED
@@ -1,6 +1,7 @@
1
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
- const require_join_paths = require('./path/src/join-paths.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
3
  let node_fs = require("node:fs");
4
+ let _stryke_path_join_paths = require("@stryke/path/join-paths");
4
5
 
5
6
  //#region src/is-file.ts
6
7
  /**
@@ -11,7 +12,7 @@ let node_fs = require("node:fs");
11
12
  * @returns An indicator specifying if the path is a file
12
13
  */
13
14
  function isFile(path, additionalPath) {
14
- return Boolean((0, node_fs.statSync)(additionalPath ? require_join_paths.joinPaths(additionalPath, path) : path, { throwIfNoEntry: false })?.isFile());
15
+ return Boolean((0, node_fs.statSync)(additionalPath ? (0, _stryke_path_join_paths.joinPaths)(additionalPath, path) : path, { throwIfNoEntry: false })?.isFile());
15
16
  }
16
17
  /**
17
18
  * Check if the given path is a directory.
@@ -21,7 +22,7 @@ function isFile(path, additionalPath) {
21
22
  * @returns An indicator specifying if the path is a directory
22
23
  */
23
24
  function isDirectory(path, additionalPath) {
24
- return Boolean((0, node_fs.statSync)(additionalPath ? require_join_paths.joinPaths(additionalPath, path) : path, { throwIfNoEntry: false })?.isDirectory());
25
+ return Boolean((0, node_fs.statSync)(additionalPath ? (0, _stryke_path_join_paths.joinPaths)(additionalPath, path) : path, { throwIfNoEntry: false })?.isDirectory());
25
26
  }
26
27
  /**
27
28
  * Check if the given path is a file . Does not dereference symbolic links.
@@ -31,7 +32,7 @@ function isDirectory(path, additionalPath) {
31
32
  * @returns An indicator specifying if the path is a file
32
33
  */
33
34
  const isFileSymlink = (path, additionalPath) => {
34
- return Boolean((0, node_fs.lstatSync)(additionalPath ? require_join_paths.joinPaths(additionalPath, path) : path, { throwIfNoEntry: false })?.isFile());
35
+ return Boolean((0, node_fs.lstatSync)(additionalPath ? (0, _stryke_path_join_paths.joinPaths)(additionalPath, path) : path, { throwIfNoEntry: false })?.isFile());
35
36
  };
36
37
  /**
37
38
  * Check if the given path is a directory. Does not dereference symbolic links.
@@ -41,7 +42,7 @@ const isFileSymlink = (path, additionalPath) => {
41
42
  * @returns An indicator specifying if the path is a directory
42
43
  */
43
44
  const isDirectorySymlink = (path, additionalPath) => {
44
- return Boolean((0, node_fs.lstatSync)(additionalPath ? require_join_paths.joinPaths(additionalPath, path) : path, { throwIfNoEntry: false })?.isDirectory());
45
+ return Boolean((0, node_fs.lstatSync)(additionalPath ? (0, _stryke_path_join_paths.joinPaths)(additionalPath, path) : path, { throwIfNoEntry: false })?.isDirectory());
45
46
  };
46
47
 
47
48
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"is-file.d.cts","names":[],"sources":["../src/is-file.ts"],"sourcesContent":[],"mappings":";;AA4BA;AAeA;AAeA;AAkBA;;;iBAhDgB,MAAA;;;;;;;;iBAeA,WAAA;;;;;;;;cAeH;;;;;;;;cAkBA"}
1
+ {"version":3,"file":"is-file.d.cts","names":[],"sources":["../src/is-file.ts"],"mappings":";;AA4BA;;;;;AAeA;iBAfgB,MAAA,CAAO,IAAA,UAAc,cAAA;;;;AA8BrC;;;;iBAfgB,WAAA,CAAY,IAAA,UAAc,cAAA;AAiC1C;;;;;;;AAAA,cAlBa,aAAA,GACX,IAAA,UACA,cAAA;;;;;;;;cAgBW,kBAAA,GACX,IAAA,UACA,cAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"is-file.d.mts","names":[],"sources":["../src/is-file.ts"],"sourcesContent":[],"mappings":";;AA4BA;AAeA;AAeA;AAkBA;;;iBAhDgB,MAAA;;;;;;;;iBAeA,WAAA;;;;;;;;cAeH;;;;;;;;cAkBA"}
1
+ {"version":3,"file":"is-file.d.mts","names":[],"sources":["../src/is-file.ts"],"mappings":";;AA4BA;;;;;AAeA;iBAfgB,MAAA,CAAO,IAAA,UAAc,cAAA;;;;AA8BrC;;;;iBAfgB,WAAA,CAAY,IAAA,UAAc,cAAA;AAiC1C;;;;;;;AAAA,cAlBa,aAAA,GACX,IAAA,UACA,cAAA;;;;;;;;cAgBW,kBAAA,GACX,IAAA,UACA,cAAA"}
package/dist/is-file.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { joinPaths } from "./path/src/join-paths.mjs";
2
1
  import { lstatSync, statSync } from "node:fs";
2
+ import { joinPaths } from "@stryke/path/join-paths";
3
3
 
4
4
  //#region src/is-file.ts
5
5
  /**
@@ -1,13 +1,13 @@
1
- const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
- const require_is_string = require('../../type-checks/src/is-string.cjs');
1
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
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
4
  const require_parse = require('./utils/parse.cjs');
5
5
  const require_parse_error = require('./utils/parse-error.cjs');
6
6
  const require_stringify = require('./utils/stringify.cjs');
7
7
  let node_buffer = require("node:buffer");
8
8
  let jsonc_parser = require("jsonc-parser");
9
9
  let superjson = require("superjson");
10
- superjson = require_rolldown_runtime.__toESM(superjson);
10
+ superjson = require_runtime.__toESM(superjson, 1);
11
11
 
12
12
  //#region ../json/src/storm-json.ts
13
13
  /**
@@ -1,5 +1,5 @@
1
- import { isString } from "../../type-checks/src/is-string.mjs";
2
1
  import { isObject } from "../../type-checks/src/is-object.mjs";
2
+ import { isString } from "../../type-checks/src/is-string.mjs";
3
3
  import { parse as parse$1 } from "./utils/parse.mjs";
4
4
  import { formatParseError } from "./utils/parse-error.mjs";
5
5
  import { stringify } from "./utils/stringify.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"storm-json.mjs","names":["#instance","parseValue","errors: ParseError[]","stringifyValue"],"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>(\n value: string,\n options: JsonParseOptions = {}\n ): TData {\n try {\n if (options.expectComments === false) {\n return parseValue<TData>(value);\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(value, errors, opts) as TData;\n\n if (errors.length > 0 && errors[0]) {\n throw new Error(formatParseError(value, errors[0]));\n }\n\n return result;\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 * 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,MACrB,OACA,UAA4B,EAAE,EACvB;AACP,MAAI;AACF,OAAI,QAAQ,mBAAmB,MAC7B,QAAOC,QAAkB,MAAM;UAE3B;EAIR,MAAMC,SAAuB,EAAE;EAK/B,MAAM,SAAS,MAAM,OAAO,QAJf;GACX,oBAAoB;GACpB,GAAG;GACJ,CACwC;AAEzC,MAAI,OAAO,SAAS,KAAK,OAAO,GAC9B,OAAM,IAAI,MAAM,iBAAiB,OAAO,OAAO,GAAG,CAAC;AAGrD,SAAO;;;;;;;;;;CAWT,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,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
+ {"version":3,"file":"storm-json.mjs","names":["#instance","parseValue","stringifyValue"],"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 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// eslint-disable-next-line unicorn/prefer-node-protocol\nimport { Buffer } from \"buffer\";\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>(\n value: string,\n options: JsonParseOptions = {}\n ): TData {\n try {\n if (options.expectComments === false) {\n return parseValue<TData>(value);\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(value, errors, opts) as TData;\n\n if (errors.length > 0 && errors[0]) {\n throw new Error(formatParseError(value, errors[0]));\n }\n\n return result;\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 * 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":";;;;;;;;;;;;;;;;AA4CA,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,MACrB,OACA,UAA4B,EAAE,EACvB;AACP,MAAI;AACF,OAAI,QAAQ,mBAAmB,MAC7B,QAAOC,QAAkB,MAAM;UAE3B;EAIR,MAAM,SAAuB,EAAE;EAK/B,MAAM,SAAS,MAAM,OAAO,QAAQ;GAHlC,oBAAoB;GACpB,GAAG;GAEmC,CAAC;AAEzC,MAAI,OAAO,SAAS,KAAK,OAAO,GAC9B,OAAM,IAAI,MAAM,iBAAiB,OAAO,OAAO,GAAG,CAAC;AAGrD,SAAO;;;;;;;;;;CAWT,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,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,7 +1,6 @@
1
1
  import { ParseOptions } from "jsonc-parser";
2
2
 
3
3
  //#region ../json/src/types.d.ts
4
-
5
4
  interface JsonParseOptions extends ParseOptions {
6
5
  /**
7
6
  * Expect JSON with javascript-style
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","names":[],"sources":["../../../../json/src/types.ts"],"sourcesContent":[],"mappings":";;;;UAsEiB,gBAAA,SAAyB;;;;;;;;;;;;;;;;;;UAqBzB,oBAAA"}
1
+ {"version":3,"file":"types.d.cts","names":[],"sources":["../../../../json/src/types.ts"],"mappings":";;;UAsEiB,gBAAA,SAAyB,YAAA;;;;;;EAMxC,cAAA;;;;;;EAOA,gBAAA;;;;EAKA,kBAAA;AAAA;AAAA,UAGe,oBAAA;;;;;;EAMf,MAAA;AAAA"}
@@ -1,7 +1,6 @@
1
1
  import { ParseOptions } from "jsonc-parser";
2
2
 
3
3
  //#region ../json/src/types.d.ts
4
-
5
4
  interface JsonParseOptions extends ParseOptions {
6
5
  /**
7
6
  * Expect JSON with javascript-style
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../../../../json/src/types.ts"],"sourcesContent":[],"mappings":";;;;UAsEiB,gBAAA,SAAyB;;;;;;;;;;;;;;;;;;UAqBzB,oBAAA"}
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../../../../json/src/types.ts"],"mappings":";;;UAsEiB,gBAAA,SAAyB,YAAA;;;;;;EAMxC,cAAA;;;;;;EAOA,gBAAA;;;;EAKA,kBAAA;AAAA;AAAA,UAGe,oBAAA;;;;;;EAMf,MAAA;AAAA"}
@@ -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,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"}
1
+ {"version":3,"file":"code-frames.mjs","names":[],"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,MAAM,WAAqB;EACzB,QAAQ;EACR,MAAM;EACN,GAAG,IAAI;EACR;CACD,MAAM,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,QACgC,EAAE,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,eACV,CAAC;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,KAEI"}
@@ -1,4 +1,4 @@
1
- const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
1
+ const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
2
2
  const require_code_frames = require('./code-frames.cjs');
3
3
  let jsonc_parser = require("jsonc-parser");
4
4
  let lines_and_columns = require("lines-and-columns");
@@ -1 +1 @@
1
- {"version":3,"file":"stringify.mjs","names":[],"sources":["../../../../../json/src/utils/stringify.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\n\nexport const invalidKeyChars = [\n \"@\",\n \"/\",\n \"#\",\n \"$\",\n \" \",\n \":\",\n \";\",\n \",\",\n \".\",\n \"!\",\n \"?\",\n \"&\",\n \"=\",\n \"+\",\n \"-\",\n \"*\",\n \"%\",\n \"^\",\n \"~\",\n \"|\",\n \"\\\\\",\n '\"',\n \"'\",\n \"`\",\n \"{\",\n \"}\",\n \"[\",\n \"]\",\n \"(\",\n \")\",\n \"<\",\n \">\"\n] as const;\n\n/**\n * Stringify a value to a JSON-like string.\n *\n * @param value - The value to stringify\n * @param spacing - The spacing to use for the stringification\n * @returns The stringified value\n */\nexport const stringify = (\n value: unknown,\n spacing: string | number = 2\n): string => {\n const space = isNumber(spacing) ? \" \".repeat(spacing) : spacing;\n\n switch (value) {\n case null: {\n return \"null\";\n }\n case undefined: {\n return '\"undefined\"';\n }\n case true: {\n return \"true\";\n }\n case false: {\n return \"false\";\n }\n case Number.POSITIVE_INFINITY: {\n return \"infinity\";\n }\n case Number.NEGATIVE_INFINITY: {\n return \"-infinity\";\n }\n }\n\n if (Array.isArray(value)) {\n return `[${space}${value.map(v => stringify(v, space)).join(`,${space}`)}${space}]`;\n }\n if (value instanceof Uint8Array) {\n return value.toString();\n }\n\n // eslint-disable-next-line ts/switch-exhaustiveness-check\n switch (typeof value) {\n case \"number\": {\n return `${value}`;\n }\n case \"string\": {\n return JSON.stringify(value);\n }\n case \"object\": {\n const keys = Object.keys(value as object).filter(\n key => !isUndefined((value as any)[key])\n );\n\n return `{${space}${keys\n .map(\n key => `\"${key}\": ${space}${stringify((value as any)[key], space)}`\n )\n .join(`,${space}`)}${space}}`;\n }\n default:\n return \"null\";\n }\n};\n"],"mappings":";;;;;;;;;;;AA+DA,MAAa,aACX,OACA,UAA2B,MAChB;CACX,MAAM,QAAQ,SAAS,QAAQ,GAAG,IAAI,OAAO,QAAQ,GAAG;AAExD,SAAQ,OAAR;EACE,KAAK,KACH,QAAO;EAET,KAAK,OACH,QAAO;EAET,KAAK,KACH,QAAO;EAET,KAAK,MACH,QAAO;EAET,KAAK,OAAO,kBACV,QAAO;EAET,KAAK,OAAO,kBACV,QAAO;;AAIX,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,IAAI,QAAQ,MAAM,KAAI,MAAK,UAAU,GAAG,MAAM,CAAC,CAAC,KAAK,IAAI,QAAQ,GAAG,MAAM;AAEnF,KAAI,iBAAiB,WACnB,QAAO,MAAM,UAAU;AAIzB,SAAQ,OAAO,OAAf;EACE,KAAK,SACH,QAAO,GAAG;EAEZ,KAAK,SACH,QAAO,KAAK,UAAU,MAAM;EAE9B,KAAK,SAKH,QAAO,IAAI,QAJE,OAAO,KAAK,MAAgB,CAAC,QACxC,QAAO,CAAC,YAAa,MAAc,KAAK,CACzC,CAGE,KACC,QAAO,IAAI,IAAI,KAAK,QAAQ,UAAW,MAAc,MAAM,MAAM,GAClE,CACA,KAAK,IAAI,QAAQ,GAAG,MAAM;EAE/B,QACE,QAAO"}
1
+ {"version":3,"file":"stringify.mjs","names":[],"sources":["../../../../../json/src/utils/stringify.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\n\nexport const invalidKeyChars = [\n \"@\",\n \"/\",\n \"#\",\n \"$\",\n \" \",\n \":\",\n \";\",\n \",\",\n \".\",\n \"!\",\n \"?\",\n \"&\",\n \"=\",\n \"+\",\n \"-\",\n \"*\",\n \"%\",\n \"^\",\n \"~\",\n \"|\",\n \"\\\\\",\n '\"',\n \"'\",\n \"`\",\n \"{\",\n \"}\",\n \"[\",\n \"]\",\n \"(\",\n \")\",\n \"<\",\n \">\"\n] as const;\n\n/**\n * Stringify a value to a JSON-like string.\n *\n * @param value - The value to stringify\n * @param spacing - The spacing to use for the stringification\n * @returns The stringified value\n */\nexport const stringify = (\n value: unknown,\n spacing: string | number = 2\n): string => {\n const space = isNumber(spacing) ? \" \".repeat(spacing) : spacing;\n\n switch (value) {\n case null: {\n return \"null\";\n }\n case undefined: {\n return '\"undefined\"';\n }\n case true: {\n return \"true\";\n }\n case false: {\n return \"false\";\n }\n case Number.POSITIVE_INFINITY: {\n return \"infinity\";\n }\n case Number.NEGATIVE_INFINITY: {\n return \"-infinity\";\n }\n }\n\n if (Array.isArray(value)) {\n return `[${space}${value.map(v => stringify(v, space)).join(`,${space}`)}${space}]`;\n }\n if (value instanceof Uint8Array) {\n return value.toString();\n }\n\n // eslint-disable-next-line ts/switch-exhaustiveness-check\n switch (typeof value) {\n case \"number\": {\n return `${value}`;\n }\n case \"string\": {\n return JSON.stringify(value);\n }\n case \"object\": {\n const keys = Object.keys(value as object).filter(\n key => !isUndefined((value as any)[key])\n );\n\n return `{${space}${keys\n .map(\n key => `\"${key}\": ${space}${stringify((value as any)[key], space)}`\n )\n .join(`,${space}`)}${space}}`;\n }\n default:\n return \"null\";\n }\n};\n"],"mappings":";;;;;;;;;;;AA+DA,MAAa,aACX,OACA,UAA2B,MAChB;CACX,MAAM,QAAQ,SAAS,QAAQ,GAAG,IAAI,OAAO,QAAQ,GAAG;AAExD,SAAQ,OAAR;EACE,KAAK,KACH,QAAO;EAET,KAAK,OACH,QAAO;EAET,KAAK,KACH,QAAO;EAET,KAAK,MACH,QAAO;EAET,KAAK,OAAO,kBACV,QAAO;EAET,KAAK,OAAO,kBACV,QAAO;;AAIX,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,IAAI,QAAQ,MAAM,KAAI,MAAK,UAAU,GAAG,MAAM,CAAC,CAAC,KAAK,IAAI,QAAQ,GAAG,MAAM;AAEnF,KAAI,iBAAiB,WACnB,QAAO,MAAM,UAAU;AAIzB,SAAQ,OAAO,OAAf;EACE,KAAK,SACH,QAAO,GAAG;EAEZ,KAAK,SACH,QAAO,KAAK,UAAU,MAAM;EAE9B,KAAK,SAKH,QAAO,IAAI,QAJE,OAAO,KAAK,MAAgB,CAAC,QACxC,QAAO,CAAC,YAAa,MAAc,KAAK,CAGnB,CACpB,KACC,QAAO,IAAI,IAAI,KAAK,QAAQ,UAAW,MAAc,MAAM,MAAM,GAClE,CACA,KAAK,IAAI,QAAQ,GAAG,MAAM;EAE/B,QACE,QAAO"}
@@ -1,4 +1,3 @@
1
- const require_base = require('../../../types/src/base.cjs');
2
1
 
3
2
  //#region ../json/src/utils/strip-comments.ts
4
3
  const singleComment = Symbol("singleComment");
@@ -34,12 +33,12 @@ function stripComments(value, { whitespace = true, trailingCommas = false } = {}
34
33
  if (!isEscaped(value, index)) isInsideString = !isInsideString;
35
34
  }
36
35
  if (isInsideString) continue;
37
- if (!isInsideComment && currentCharacter + (nextCharacter ?? require_base.EMPTY_STRING) === "//") {
36
+ if (!isInsideComment && currentCharacter + (nextCharacter ?? "") === "//") {
38
37
  buffer += value.slice(offset, index);
39
38
  offset = index;
40
39
  isInsideComment = singleComment;
41
40
  index++;
42
- } else if (isInsideComment === singleComment && currentCharacter + (nextCharacter ?? require_base.EMPTY_STRING) === "\r\n") {
41
+ } else if (isInsideComment === singleComment && currentCharacter + (nextCharacter ?? "") === "\r\n") {
43
42
  index++;
44
43
  isInsideComment = false;
45
44
  buffer += strip(value, offset, index);
@@ -48,12 +47,12 @@ function stripComments(value, { whitespace = true, trailingCommas = false } = {}
48
47
  isInsideComment = false;
49
48
  buffer += strip(value, offset, index);
50
49
  offset = index;
51
- } else if (!isInsideComment && currentCharacter + (nextCharacter ?? require_base.EMPTY_STRING) === "/*") {
50
+ } else if (!isInsideComment && currentCharacter + (nextCharacter ?? "") === "/*") {
52
51
  buffer += value.slice(offset, index);
53
52
  offset = index;
54
53
  isInsideComment = multiComment;
55
54
  index++;
56
- } else if (isInsideComment === multiComment && currentCharacter + (nextCharacter ?? require_base.EMPTY_STRING) === "*/") {
55
+ } else if (isInsideComment === multiComment && currentCharacter + (nextCharacter ?? "") === "*/") {
57
56
  index++;
58
57
  isInsideComment = false;
59
58
  buffer += strip(value, offset, index + 1);
@@ -1,5 +1,3 @@
1
- import { EMPTY_STRING } from "../../../types/src/base.mjs";
2
-
3
1
  //#region ../json/src/utils/strip-comments.ts
4
2
  const singleComment = Symbol("singleComment");
5
3
  const multiComment = Symbol("multiComment");
@@ -34,12 +32,12 @@ function stripComments(value, { whitespace = true, trailingCommas = false } = {}
34
32
  if (!isEscaped(value, index)) isInsideString = !isInsideString;
35
33
  }
36
34
  if (isInsideString) continue;
37
- if (!isInsideComment && currentCharacter + (nextCharacter ?? EMPTY_STRING) === "//") {
35
+ if (!isInsideComment && currentCharacter + (nextCharacter ?? "") === "//") {
38
36
  buffer += value.slice(offset, index);
39
37
  offset = index;
40
38
  isInsideComment = singleComment;
41
39
  index++;
42
- } else if (isInsideComment === singleComment && currentCharacter + (nextCharacter ?? EMPTY_STRING) === "\r\n") {
40
+ } else if (isInsideComment === singleComment && currentCharacter + (nextCharacter ?? "") === "\r\n") {
43
41
  index++;
44
42
  isInsideComment = false;
45
43
  buffer += strip(value, offset, index);
@@ -48,12 +46,12 @@ function stripComments(value, { whitespace = true, trailingCommas = false } = {}
48
46
  isInsideComment = false;
49
47
  buffer += strip(value, offset, index);
50
48
  offset = index;
51
- } else if (!isInsideComment && currentCharacter + (nextCharacter ?? EMPTY_STRING) === "/*") {
49
+ } else if (!isInsideComment && currentCharacter + (nextCharacter ?? "") === "/*") {
52
50
  buffer += value.slice(offset, index);
53
51
  offset = index;
54
52
  isInsideComment = multiComment;
55
53
  index++;
56
- } else if (isInsideComment === multiComment && currentCharacter + (nextCharacter ?? EMPTY_STRING) === "*/") {
54
+ } else if (isInsideComment === multiComment && currentCharacter + (nextCharacter ?? "") === "*/") {
57
55
  index++;
58
56
  isInsideComment = false;
59
57
  buffer += strip(value, offset, index + 1);
@@ -1 +1 @@
1
- {"version":3,"file":"strip-comments.mjs","names":["isInsideString: boolean | symbol","isInsideComment: boolean | symbol"],"sources":["../../../../../json/src/utils/strip-comments.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { EMPTY_STRING } from \"@stryke/types/base\";\n\nconst singleComment = Symbol(\"singleComment\");\nconst multiComment = Symbol(\"multiComment\");\n\nfunction stripWithoutWhitespace() {\n return \"\";\n}\nfunction stripWithWhitespace(value: string, start?: number, end?: number) {\n return value.slice(start, end).replace(/\\S/g, \" \");\n}\n\nfunction isEscaped(value: string, quotePosition: number) {\n let index = quotePosition - 1;\n let backslashCount = 0;\n while (value[index] === \"\\\\\") {\n index -= 1;\n backslashCount += 1;\n }\n\n return Boolean(backslashCount % 2);\n}\n\nexport function stripComments(\n value: string,\n { whitespace = true, trailingCommas = false } = {}\n) {\n if (typeof value !== \"string\") {\n throw new TypeError(\n `Expected argument \\`jsonString\\` to be a \\`string\\`, got \\`${typeof value}\\``\n );\n }\n\n const strip = whitespace ? stripWithWhitespace : stripWithoutWhitespace;\n let isInsideString: boolean | symbol = false;\n let isInsideComment: boolean | symbol = false;\n let offset = 0;\n let buffer = \"\";\n let result = \"\";\n let commaIndex = -1;\n for (let index = 0; index < value.length; index++) {\n const currentCharacter = value[index];\n const nextCharacter = value[index + 1];\n if (!isInsideComment && currentCharacter === '\"') {\n const escaped = isEscaped(value, index);\n if (!escaped) {\n isInsideString = !isInsideString;\n }\n }\n if (isInsideString) {\n continue;\n }\n if (\n !isInsideComment &&\n currentCharacter + (nextCharacter ?? EMPTY_STRING) === \"//\"\n ) {\n buffer += value.slice(offset, index);\n offset = index;\n isInsideComment = singleComment;\n index++;\n } else if (\n isInsideComment === singleComment &&\n currentCharacter + (nextCharacter ?? EMPTY_STRING) === \"\\r\\n\"\n ) {\n index++;\n isInsideComment = false;\n buffer += strip(value, offset, index);\n offset = index;\n } else if (isInsideComment === singleComment && currentCharacter === \"\\n\") {\n isInsideComment = false;\n buffer += strip(value, offset, index);\n offset = index;\n } else if (\n !isInsideComment &&\n currentCharacter + (nextCharacter ?? EMPTY_STRING) === \"/*\"\n ) {\n buffer += value.slice(offset, index);\n offset = index;\n isInsideComment = multiComment;\n index++;\n } else if (\n isInsideComment === multiComment &&\n currentCharacter + (nextCharacter ?? EMPTY_STRING) === \"*/\"\n ) {\n index++;\n isInsideComment = false;\n buffer += strip(value, offset, index + 1);\n offset = index + 1;\n } else if (trailingCommas && !isInsideComment) {\n if (commaIndex !== -1) {\n if (currentCharacter === \"}\" || currentCharacter === \"]\") {\n buffer += value.slice(offset, index);\n result += strip(buffer, 0, 1) + buffer.slice(1);\n buffer = \"\";\n offset = index;\n commaIndex = -1;\n } else if (\n currentCharacter !== \" \" &&\n currentCharacter !== \"\t\" &&\n currentCharacter !== \"\\r\" &&\n currentCharacter !== \"\\n\"\n ) {\n buffer += value.slice(offset, index);\n offset = index;\n commaIndex = -1;\n }\n } else if (currentCharacter === \",\") {\n result += buffer + value.slice(offset, index);\n buffer = \"\";\n offset = index;\n commaIndex = index;\n }\n }\n }\n\n return (\n result +\n buffer +\n (isInsideComment ? strip(value.slice(offset)) : value.slice(offset))\n );\n}\n"],"mappings":";;;AAoBA,MAAM,gBAAgB,OAAO,gBAAgB;AAC7C,MAAM,eAAe,OAAO,eAAe;AAE3C,SAAS,yBAAyB;AAChC,QAAO;;AAET,SAAS,oBAAoB,OAAe,OAAgB,KAAc;AACxE,QAAO,MAAM,MAAM,OAAO,IAAI,CAAC,QAAQ,OAAO,IAAI;;AAGpD,SAAS,UAAU,OAAe,eAAuB;CACvD,IAAI,QAAQ,gBAAgB;CAC5B,IAAI,iBAAiB;AACrB,QAAO,MAAM,WAAW,MAAM;AAC5B,WAAS;AACT,oBAAkB;;AAGpB,QAAO,QAAQ,iBAAiB,EAAE;;AAGpC,SAAgB,cACd,OACA,EAAE,aAAa,MAAM,iBAAiB,UAAU,EAAE,EAClD;AACA,KAAI,OAAO,UAAU,SACnB,OAAM,IAAI,UACR,8DAA8D,OAAO,MAAM,IAC5E;CAGH,MAAM,QAAQ,aAAa,sBAAsB;CACjD,IAAIA,iBAAmC;CACvC,IAAIC,kBAAoC;CACxC,IAAI,SAAS;CACb,IAAI,SAAS;CACb,IAAI,SAAS;CACb,IAAI,aAAa;AACjB,MAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;EACjD,MAAM,mBAAmB,MAAM;EAC/B,MAAM,gBAAgB,MAAM,QAAQ;AACpC,MAAI,CAAC,mBAAmB,qBAAqB,MAE3C;OAAI,CADY,UAAU,OAAO,MAAM,CAErC,kBAAiB,CAAC;;AAGtB,MAAI,eACF;AAEF,MACE,CAAC,mBACD,oBAAoB,iBAAiB,kBAAkB,MACvD;AACA,aAAU,MAAM,MAAM,QAAQ,MAAM;AACpC,YAAS;AACT,qBAAkB;AAClB;aAEA,oBAAoB,iBACpB,oBAAoB,iBAAiB,kBAAkB,QACvD;AACA;AACA,qBAAkB;AAClB,aAAU,MAAM,OAAO,QAAQ,MAAM;AACrC,YAAS;aACA,oBAAoB,iBAAiB,qBAAqB,MAAM;AACzE,qBAAkB;AAClB,aAAU,MAAM,OAAO,QAAQ,MAAM;AACrC,YAAS;aAET,CAAC,mBACD,oBAAoB,iBAAiB,kBAAkB,MACvD;AACA,aAAU,MAAM,MAAM,QAAQ,MAAM;AACpC,YAAS;AACT,qBAAkB;AAClB;aAEA,oBAAoB,gBACpB,oBAAoB,iBAAiB,kBAAkB,MACvD;AACA;AACA,qBAAkB;AAClB,aAAU,MAAM,OAAO,QAAQ,QAAQ,EAAE;AACzC,YAAS,QAAQ;aACR,kBAAkB,CAAC,iBAC5B;OAAI,eAAe,IACjB;QAAI,qBAAqB,OAAO,qBAAqB,KAAK;AACxD,eAAU,MAAM,MAAM,QAAQ,MAAM;AACpC,eAAU,MAAM,QAAQ,GAAG,EAAE,GAAG,OAAO,MAAM,EAAE;AAC/C,cAAS;AACT,cAAS;AACT,kBAAa;eAEb,qBAAqB,OACrB,qBAAqB,OACrB,qBAAqB,QACrB,qBAAqB,MACrB;AACA,eAAU,MAAM,MAAM,QAAQ,MAAM;AACpC,cAAS;AACT,kBAAa;;cAEN,qBAAqB,KAAK;AACnC,cAAU,SAAS,MAAM,MAAM,QAAQ,MAAM;AAC7C,aAAS;AACT,aAAS;AACT,iBAAa;;;;AAKnB,QACE,SACA,UACC,kBAAkB,MAAM,MAAM,MAAM,OAAO,CAAC,GAAG,MAAM,MAAM,OAAO"}
1
+ {"version":3,"file":"strip-comments.mjs","names":[],"sources":["../../../../../json/src/utils/strip-comments.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { EMPTY_STRING } from \"@stryke/types/base\";\n\nconst singleComment = Symbol(\"singleComment\");\nconst multiComment = Symbol(\"multiComment\");\n\nfunction stripWithoutWhitespace() {\n return \"\";\n}\nfunction stripWithWhitespace(value: string, start?: number, end?: number) {\n return value.slice(start, end).replace(/\\S/g, \" \");\n}\n\nfunction isEscaped(value: string, quotePosition: number) {\n let index = quotePosition - 1;\n let backslashCount = 0;\n while (value[index] === \"\\\\\") {\n index -= 1;\n backslashCount += 1;\n }\n\n return Boolean(backslashCount % 2);\n}\n\nexport function stripComments(\n value: string,\n { whitespace = true, trailingCommas = false } = {}\n) {\n if (typeof value !== \"string\") {\n throw new TypeError(\n `Expected argument \\`jsonString\\` to be a \\`string\\`, got \\`${typeof value}\\``\n );\n }\n\n const strip = whitespace ? stripWithWhitespace : stripWithoutWhitespace;\n let isInsideString: boolean | symbol = false;\n let isInsideComment: boolean | symbol = false;\n let offset = 0;\n let buffer = \"\";\n let result = \"\";\n let commaIndex = -1;\n for (let index = 0; index < value.length; index++) {\n const currentCharacter = value[index];\n const nextCharacter = value[index + 1];\n if (!isInsideComment && currentCharacter === '\"') {\n const escaped = isEscaped(value, index);\n if (!escaped) {\n isInsideString = !isInsideString;\n }\n }\n if (isInsideString) {\n continue;\n }\n if (\n !isInsideComment &&\n currentCharacter + (nextCharacter ?? EMPTY_STRING) === \"//\"\n ) {\n buffer += value.slice(offset, index);\n offset = index;\n isInsideComment = singleComment;\n index++;\n } else if (\n isInsideComment === singleComment &&\n currentCharacter + (nextCharacter ?? EMPTY_STRING) === \"\\r\\n\"\n ) {\n index++;\n isInsideComment = false;\n buffer += strip(value, offset, index);\n offset = index;\n } else if (isInsideComment === singleComment && currentCharacter === \"\\n\") {\n isInsideComment = false;\n buffer += strip(value, offset, index);\n offset = index;\n } else if (\n !isInsideComment &&\n currentCharacter + (nextCharacter ?? EMPTY_STRING) === \"/*\"\n ) {\n buffer += value.slice(offset, index);\n offset = index;\n isInsideComment = multiComment;\n index++;\n } else if (\n isInsideComment === multiComment &&\n currentCharacter + (nextCharacter ?? EMPTY_STRING) === \"*/\"\n ) {\n index++;\n isInsideComment = false;\n buffer += strip(value, offset, index + 1);\n offset = index + 1;\n } else if (trailingCommas && !isInsideComment) {\n if (commaIndex !== -1) {\n if (currentCharacter === \"}\" || currentCharacter === \"]\") {\n buffer += value.slice(offset, index);\n result += strip(buffer, 0, 1) + buffer.slice(1);\n buffer = \"\";\n offset = index;\n commaIndex = -1;\n } else if (\n currentCharacter !== \" \" &&\n currentCharacter !== \"\t\" &&\n currentCharacter !== \"\\r\" &&\n currentCharacter !== \"\\n\"\n ) {\n buffer += value.slice(offset, index);\n offset = index;\n commaIndex = -1;\n }\n } else if (currentCharacter === \",\") {\n result += buffer + value.slice(offset, index);\n buffer = \"\";\n offset = index;\n commaIndex = index;\n }\n }\n }\n\n return (\n result +\n buffer +\n (isInsideComment ? strip(value.slice(offset)) : value.slice(offset))\n );\n}\n"],"mappings":";AAoBA,MAAM,gBAAgB,OAAO,gBAAgB;AAC7C,MAAM,eAAe,OAAO,eAAe;AAE3C,SAAS,yBAAyB;AAChC,QAAO;;AAET,SAAS,oBAAoB,OAAe,OAAgB,KAAc;AACxE,QAAO,MAAM,MAAM,OAAO,IAAI,CAAC,QAAQ,OAAO,IAAI;;AAGpD,SAAS,UAAU,OAAe,eAAuB;CACvD,IAAI,QAAQ,gBAAgB;CAC5B,IAAI,iBAAiB;AACrB,QAAO,MAAM,WAAW,MAAM;AAC5B,WAAS;AACT,oBAAkB;;AAGpB,QAAO,QAAQ,iBAAiB,EAAE;;AAGpC,SAAgB,cACd,OACA,EAAE,aAAa,MAAM,iBAAiB,UAAU,EAAE,EAClD;AACA,KAAI,OAAO,UAAU,SACnB,OAAM,IAAI,UACR,8DAA8D,OAAO,MAAM,IAC5E;CAGH,MAAM,QAAQ,aAAa,sBAAsB;CACjD,IAAI,iBAAmC;CACvC,IAAI,kBAAoC;CACxC,IAAI,SAAS;CACb,IAAI,SAAS;CACb,IAAI,SAAS;CACb,IAAI,aAAa;AACjB,MAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;EACjD,MAAM,mBAAmB,MAAM;EAC/B,MAAM,gBAAgB,MAAM,QAAQ;AACpC,MAAI,CAAC,mBAAmB,qBAAqB,MAE3C;OAAI,CADY,UAAU,OAAO,MACrB,CACV,kBAAiB,CAAC;;AAGtB,MAAI,eACF;AAEF,MACE,CAAC,mBACD,oBAAoB,yBAAmC,MACvD;AACA,aAAU,MAAM,MAAM,QAAQ,MAAM;AACpC,YAAS;AACT,qBAAkB;AAClB;aAEA,oBAAoB,iBACpB,oBAAoB,yBAAmC,QACvD;AACA;AACA,qBAAkB;AAClB,aAAU,MAAM,OAAO,QAAQ,MAAM;AACrC,YAAS;aACA,oBAAoB,iBAAiB,qBAAqB,MAAM;AACzE,qBAAkB;AAClB,aAAU,MAAM,OAAO,QAAQ,MAAM;AACrC,YAAS;aAET,CAAC,mBACD,oBAAoB,yBAAmC,MACvD;AACA,aAAU,MAAM,MAAM,QAAQ,MAAM;AACpC,YAAS;AACT,qBAAkB;AAClB;aAEA,oBAAoB,gBACpB,oBAAoB,yBAAmC,MACvD;AACA;AACA,qBAAkB;AAClB,aAAU,MAAM,OAAO,QAAQ,QAAQ,EAAE;AACzC,YAAS,QAAQ;aACR,kBAAkB,CAAC,iBAC5B;OAAI,eAAe,IACjB;QAAI,qBAAqB,OAAO,qBAAqB,KAAK;AACxD,eAAU,MAAM,MAAM,QAAQ,MAAM;AACpC,eAAU,MAAM,QAAQ,GAAG,EAAE,GAAG,OAAO,MAAM,EAAE;AAC/C,cAAS;AACT,cAAS;AACT,kBAAa;eAEb,qBAAqB,OACrB,qBAAqB,OACrB,qBAAqB,QACrB,qBAAqB,MACrB;AACA,eAAU,MAAM,MAAM,QAAQ,MAAM;AACpC,cAAS;AACT,kBAAa;;cAEN,qBAAqB,KAAK;AACnC,cAAU,SAAS,MAAM,MAAM,QAAQ,MAAM;AAC7C,aAAS;AACT,aAAS;AACT,iBAAa;;;;AAKnB,QACE,SACA,UACC,kBAAkB,MAAM,MAAM,MAAM,OAAO,CAAC,GAAG,MAAM,MAAM,OAAO"}