bun-workspaces 1.0.1-alpha → 1.0.2

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 (238) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +189 -70
  3. package/bin/cli.js +1 -2
  4. package/package.json +27 -30
  5. package/src/cli/commands/commandHandlerUtils.d.ts +50 -0
  6. package/src/cli/commands/commandHandlerUtils.mjs +91 -0
  7. package/src/cli/commands/commands.d.ts +10 -0
  8. package/src/cli/commands/commands.mjs +23 -0
  9. package/src/cli/commands/commandsConfig.d.ts +351 -0
  10. package/src/cli/commands/commandsConfig.mjs +183 -0
  11. package/src/cli/commands/handleSimpleCommands.d.ts +15 -0
  12. package/src/cli/commands/handleSimpleCommands.mjs +174 -0
  13. package/src/cli/commands/index.d.ts +3 -0
  14. package/src/cli/commands/index.mjs +3 -0
  15. package/src/cli/commands/runScript/handleRunScript.d.ts +3 -0
  16. package/src/cli/commands/runScript/handleRunScript.mjs +250 -0
  17. package/src/cli/commands/runScript/index.d.ts +2 -0
  18. package/src/cli/commands/runScript/index.mjs +2 -0
  19. package/src/cli/commands/runScript/output/index.d.ts +1 -0
  20. package/src/cli/commands/runScript/output/index.mjs +1 -0
  21. package/src/cli/commands/runScript/output/outputStyle.d.ts +8 -0
  22. package/src/cli/commands/runScript/output/outputStyle.mjs +17 -0
  23. package/src/cli/commands/runScript/output/renderGroupedOutput.d.ts +74 -0
  24. package/src/cli/commands/runScript/output/renderGroupedOutput.mjs +331 -0
  25. package/src/cli/commands/runScript/output/renderPlainOutput.d.ts +24 -0
  26. package/src/cli/commands/runScript/output/renderPlainOutput.mjs +44 -0
  27. package/src/cli/commands/runScript/output/sanitizeChunk.d.ts +4 -0
  28. package/src/cli/commands/runScript/output/sanitizeChunk.mjs +101 -0
  29. package/src/cli/createCli.d.ts +25 -0
  30. package/src/cli/createCli.mjs +157 -0
  31. package/src/cli/fatalErrorLogger.d.ts +1 -0
  32. package/src/cli/fatalErrorLogger.mjs +7 -0
  33. package/src/cli/globalOptions/globalOptions.d.ts +42 -0
  34. package/src/cli/globalOptions/globalOptions.mjs +113 -0
  35. package/src/cli/globalOptions/globalOptionsConfig.d.ts +43 -0
  36. package/src/cli/globalOptions/globalOptionsConfig.mjs +34 -0
  37. package/src/cli/globalOptions/index.d.ts +2 -0
  38. package/src/cli/globalOptions/index.mjs +2 -0
  39. package/src/cli/index.d.ts +3 -0
  40. package/src/cli/index.mjs +3 -0
  41. package/src/cli/middleware.d.ts +83 -0
  42. package/src/cli/middleware.mjs +39 -0
  43. package/src/config/index.d.ts +3 -0
  44. package/src/config/index.mjs +3 -0
  45. package/src/config/rootConfig/errors.d.ts +1 -0
  46. package/src/config/rootConfig/errors.mjs +6 -0
  47. package/src/config/rootConfig/index.d.ts +5 -0
  48. package/src/config/rootConfig/index.mjs +5 -0
  49. package/src/config/rootConfig/loadRootConfig.d.ts +3 -0
  50. package/src/config/rootConfig/loadRootConfig.mjs +22 -0
  51. package/src/config/rootConfig/rootConfig.d.ts +17 -0
  52. package/src/config/rootConfig/rootConfig.mjs +43 -0
  53. package/src/config/rootConfig/rootConfigLocation.d.ts +2 -0
  54. package/src/config/rootConfig/rootConfigLocation.mjs +5 -0
  55. package/src/config/rootConfig/rootConfigSchema.d.ts +21 -0
  56. package/src/config/rootConfig/rootConfigSchema.mjs +24 -0
  57. package/src/config/userEnvVars/index.d.ts +1 -0
  58. package/src/config/userEnvVars/index.mjs +1 -0
  59. package/src/config/userEnvVars/userEnvVars.d.ts +13 -0
  60. package/src/config/userEnvVars/userEnvVars.mjs +10 -0
  61. package/src/config/util/ajvTypes.d.ts +10 -0
  62. package/src/config/util/ajvTypes.mjs +2 -0
  63. package/src/config/util/configLocation.d.ts +12 -0
  64. package/src/config/util/configLocation.mjs +11 -0
  65. package/src/config/util/index.d.ts +4 -0
  66. package/src/config/util/index.mjs +3 -0
  67. package/src/config/util/loadConfig.d.ts +16 -0
  68. package/src/config/util/loadConfig.mjs +118 -0
  69. package/src/config/util/validateConfig.d.ts +8 -0
  70. package/src/config/util/validateConfig.mjs +17 -0
  71. package/src/config/workspaceConfig/errors.d.ts +1 -0
  72. package/src/config/workspaceConfig/errors.mjs +6 -0
  73. package/src/config/workspaceConfig/index.d.ts +5 -0
  74. package/src/config/workspaceConfig/index.mjs +5 -0
  75. package/src/config/workspaceConfig/loadWorkspaceConfig.d.ts +3 -0
  76. package/src/config/workspaceConfig/loadWorkspaceConfig.mjs +25 -0
  77. package/src/config/workspaceConfig/workspaceConfig.d.ts +22 -0
  78. package/src/config/workspaceConfig/workspaceConfig.mjs +31 -0
  79. package/src/config/workspaceConfig/workspaceConfigLocation.d.ts +2 -0
  80. package/src/config/workspaceConfig/workspaceConfigLocation.mjs +5 -0
  81. package/src/config/workspaceConfig/workspaceConfigSchema.d.ts +25 -0
  82. package/src/config/workspaceConfig/workspaceConfigSchema.mjs +28 -0
  83. package/src/doctor/doctor.d.ts +35 -0
  84. package/src/doctor/doctor.mjs +52 -0
  85. package/src/doctor/index.d.ts +1 -0
  86. package/src/doctor/index.mjs +1 -0
  87. package/src/index.d.ts +37 -0
  88. package/src/index.mjs +16 -0
  89. package/src/internal/bun/bunLock.d.ts +20 -0
  90. package/src/internal/bun/bunLock.mjs +70 -0
  91. package/src/internal/bun/bunVersion.d.ts +21 -0
  92. package/src/internal/bun/bunVersion.mjs +43 -0
  93. package/src/internal/bun/index.d.ts +2 -0
  94. package/src/internal/bun/index.mjs +2 -0
  95. package/src/internal/core/error/error.d.ts +13 -0
  96. package/src/internal/{error.ts → core/error/error.mjs} +16 -18
  97. package/src/internal/core/error/index.d.ts +1 -0
  98. package/src/internal/core/error/index.mjs +1 -0
  99. package/src/internal/core/index.d.ts +4 -0
  100. package/src/internal/core/index.mjs +4 -0
  101. package/src/internal/core/json/index.d.ts +2 -0
  102. package/src/internal/core/json/index.mjs +2 -0
  103. package/src/internal/core/json/json.d.ts +49 -0
  104. package/src/internal/core/json/json.mjs +12 -0
  105. package/src/internal/core/json/jsonc.d.ts +9 -0
  106. package/src/internal/core/json/jsonc.mjs +117 -0
  107. package/src/internal/core/language/array/index.d.ts +1 -0
  108. package/src/internal/core/language/array/index.mjs +1 -0
  109. package/src/internal/core/language/array/optionalArray.d.ts +15 -0
  110. package/src/internal/core/language/array/optionalArray.mjs +8 -0
  111. package/src/internal/core/language/asyncIterable/asyncIterableQueue.d.ts +16 -0
  112. package/src/internal/core/language/asyncIterable/asyncIterableQueue.mjs +81 -0
  113. package/src/internal/core/language/asyncIterable/index.d.ts +2 -0
  114. package/src/internal/core/language/asyncIterable/index.mjs +2 -0
  115. package/src/internal/core/language/asyncIterable/mergeAsyncIterables.d.ts +5 -0
  116. package/src/internal/core/language/asyncIterable/mergeAsyncIterables.mjs +27 -0
  117. package/src/internal/core/language/events/typedEventTarget.d.ts +50 -0
  118. package/src/internal/core/language/events/typedEventTarget.mjs +14 -0
  119. package/src/internal/core/language/index.d.ts +5 -0
  120. package/src/internal/core/language/index.mjs +5 -0
  121. package/src/internal/core/language/regex/index.d.ts +1 -0
  122. package/src/internal/core/language/regex/index.mjs +1 -0
  123. package/src/internal/core/language/regex/regex.d.ts +3 -0
  124. package/src/internal/core/language/regex/regex.mjs +10 -0
  125. package/src/internal/core/language/string/id.d.ts +1 -0
  126. package/src/internal/core/language/string/id.mjs +10 -0
  127. package/src/internal/core/language/string/index.d.ts +1 -0
  128. package/src/internal/core/language/string/index.mjs +1 -0
  129. package/src/internal/core/language/string/utf/eastAsianWidth.d.ts +16 -0
  130. package/src/internal/core/language/string/utf/eastAsianWidth.mjs +326 -0
  131. package/src/internal/core/language/string/utf/visibleLength.d.ts +5 -0
  132. package/src/internal/core/language/string/utf/visibleLength.mjs +29 -0
  133. package/src/internal/core/language/types/index.d.ts +2 -0
  134. package/src/internal/core/language/types/index.mjs +1 -0
  135. package/src/internal/core/language/types/typeof.d.ts +102 -0
  136. package/src/internal/core/language/types/typeof.mjs +123 -0
  137. package/src/internal/core/language/types/types.d.ts +14 -0
  138. package/src/internal/core/language/types/types.mjs +2 -0
  139. package/src/internal/core/runtime/env.d.ts +6 -0
  140. package/src/internal/core/runtime/env.mjs +36 -0
  141. package/src/internal/core/runtime/index.d.ts +5 -0
  142. package/src/internal/core/runtime/index.mjs +5 -0
  143. package/src/internal/core/runtime/onExit.d.ts +4 -0
  144. package/src/internal/core/runtime/onExit.mjs +54 -0
  145. package/src/internal/core/runtime/os.d.ts +4 -0
  146. package/src/internal/core/runtime/os.mjs +7 -0
  147. package/src/internal/core/runtime/tempFile.d.ts +20 -0
  148. package/src/internal/core/runtime/tempFile.mjs +87 -0
  149. package/src/internal/core/runtime/terminal.d.ts +1 -0
  150. package/src/internal/core/runtime/terminal.mjs +4 -0
  151. package/src/internal/generated/ajv/validateRootConfig.mjs +1 -0
  152. package/src/internal/generated/ajv/validateWorkspaceConfig.mjs +1 -0
  153. package/src/internal/logger/index.d.ts +1 -0
  154. package/src/internal/logger/index.mjs +1 -0
  155. package/src/internal/logger/logger.d.ts +45 -0
  156. package/src/internal/logger/logger.mjs +133 -0
  157. package/src/internal/version.d.ts +1 -0
  158. package/src/internal/version.mjs +6 -0
  159. package/src/project/errors.d.ts +5 -0
  160. package/src/project/errors.mjs +10 -0
  161. package/src/project/implementations/fileSystemProject.d.ts +148 -0
  162. package/src/project/implementations/fileSystemProject.mjs +455 -0
  163. package/src/project/implementations/memoryProject.d.ts +41 -0
  164. package/src/project/implementations/memoryProject.mjs +148 -0
  165. package/src/project/implementations/projectBase.d.ts +35 -0
  166. package/src/project/implementations/projectBase.mjs +197 -0
  167. package/src/project/index.d.ts +5 -0
  168. package/src/project/index.mjs +4 -0
  169. package/src/project/project.d.ts +75 -0
  170. package/src/project/project.mjs +6 -0
  171. package/src/runScript/index.d.ts +7 -0
  172. package/src/runScript/index.mjs +7 -0
  173. package/src/runScript/output/index.d.ts +3 -0
  174. package/src/runScript/output/index.mjs +2 -0
  175. package/src/runScript/output/multiProcessOutput.d.ts +14 -0
  176. package/src/runScript/output/multiProcessOutput.mjs +21 -0
  177. package/src/runScript/output/outputStream.d.ts +1 -0
  178. package/src/runScript/output/outputStream.mjs +1 -0
  179. package/src/runScript/output/processOutput.d.ts +33 -0
  180. package/src/runScript/output/processOutput.mjs +124 -0
  181. package/src/runScript/parallel.d.ts +15 -0
  182. package/src/runScript/parallel.mjs +56 -0
  183. package/src/runScript/recursion.d.ts +4 -0
  184. package/src/runScript/recursion.mjs +17 -0
  185. package/src/runScript/runScript.d.ts +45 -0
  186. package/src/runScript/runScript.mjs +89 -0
  187. package/src/runScript/runScripts.d.ts +65 -0
  188. package/src/runScript/runScripts.mjs +263 -0
  189. package/src/runScript/scriptCommand.d.ts +33 -0
  190. package/src/runScript/scriptCommand.mjs +19 -0
  191. package/src/runScript/scriptExecution.d.ts +9 -0
  192. package/src/runScript/scriptExecution.mjs +50 -0
  193. package/src/runScript/scriptRuntimeMetadata.d.ts +73 -0
  194. package/src/runScript/scriptRuntimeMetadata.mjs +61 -0
  195. package/src/runScript/scriptShellOption.d.ts +8 -0
  196. package/src/runScript/scriptShellOption.mjs +39 -0
  197. package/src/runScript/subprocesses.d.ts +11 -0
  198. package/src/runScript/subprocesses.mjs +34 -0
  199. package/src/workspaces/dependencyGraph/cycles.d.ts +9 -0
  200. package/src/workspaces/dependencyGraph/cycles.mjs +91 -0
  201. package/src/workspaces/dependencyGraph/index.d.ts +2 -0
  202. package/src/workspaces/dependencyGraph/index.mjs +2 -0
  203. package/src/workspaces/dependencyGraph/resolveDependencies.d.ts +18 -0
  204. package/src/workspaces/dependencyGraph/resolveDependencies.mjs +52 -0
  205. package/src/workspaces/errors.d.ts +13 -0
  206. package/src/workspaces/errors.mjs +18 -0
  207. package/src/workspaces/findWorkspaces.d.ts +24 -0
  208. package/src/workspaces/findWorkspaces.mjs +217 -0
  209. package/src/workspaces/index.d.ts +4 -0
  210. package/src/workspaces/index.mjs +3 -0
  211. package/src/workspaces/packageJson.d.ts +31 -0
  212. package/src/workspaces/packageJson.mjs +188 -0
  213. package/src/workspaces/{workspace.ts → workspace.d.ts} +11 -6
  214. package/src/workspaces/workspace.mjs +2 -0
  215. package/src/workspaces/workspacePattern.d.ts +21 -0
  216. package/src/workspaces/workspacePattern.mjs +104 -0
  217. package/bun.lock +0 -576
  218. package/src/cli/cli.ts +0 -87
  219. package/src/cli/globalOptions.ts +0 -122
  220. package/src/cli/index.ts +0 -1
  221. package/src/cli/projectCommands.ts +0 -396
  222. package/src/config/bunWorkspacesConfig.ts +0 -62
  223. package/src/config/configFile.ts +0 -33
  224. package/src/config/index.ts +0 -7
  225. package/src/index.ts +0 -3
  226. package/src/internal/bunVersion.ts +0 -26
  227. package/src/internal/env.ts +0 -25
  228. package/src/internal/logger.ts +0 -145
  229. package/src/internal/regex.ts +0 -5
  230. package/src/project/errors.ts +0 -6
  231. package/src/project/index.ts +0 -6
  232. package/src/project/project.ts +0 -155
  233. package/src/project/scriptCommand.ts +0 -40
  234. package/src/workspaces/errors.ts +0 -14
  235. package/src/workspaces/findWorkspaces.ts +0 -137
  236. package/src/workspaces/index.ts +0 -7
  237. package/src/workspaces/packageJson.ts +0 -166
  238. package/tsconfig.json +0 -28
@@ -0,0 +1,13 @@
1
+ export declare class BunWorkspacesError extends Error {
2
+ name: string;
3
+ }
4
+ export type DefinedErrors<ErrorName extends string> = {
5
+ [name in ErrorName]: typeof BunWorkspacesError;
6
+ };
7
+ export declare function defineErrors<ErrorName extends string>(
8
+ parentError: typeof BunWorkspacesError,
9
+ ...errorNames: ErrorName[]
10
+ ): DefinedErrors<ErrorName>;
11
+ export declare function defineErrors<ErrorName extends string>(
12
+ ...errorNames: ErrorName[]
13
+ ): DefinedErrors<ErrorName>;
@@ -1,38 +1,36 @@
1
- export class BunWorkspacesError extends Error {
1
+ // CONCATENATED MODULE: ./src/internal/core/error/error.ts
2
+ class BunWorkspacesError extends Error {
2
3
  name = "BunWorkspacesError";
3
4
  }
4
-
5
- export type DefinedErrors<ErrorName extends string> = {
6
- [name in ErrorName]: typeof BunWorkspacesError;
7
- };
8
-
9
- export const defineErrors = <ErrorName extends string>(
10
- ...errors: ErrorName[]
11
- ): DefinedErrors<ErrorName> =>
12
- errors.reduce((acc, error) => {
13
- acc[error] = class extends BunWorkspacesError {
14
- constructor(message?: string) {
5
+ function defineErrors(...[parentError, ...errorNames]) {
6
+ let Parent = BunWorkspacesError;
7
+ if (typeof parentError === "function") {
8
+ Parent = parentError;
9
+ } else {
10
+ errorNames.unshift(parentError);
11
+ }
12
+ return errorNames.reduce((acc, error) => {
13
+ acc[error] = class extends Parent {
14
+ constructor(message) {
15
15
  super(message);
16
16
  this.name = error;
17
17
  }
18
18
  name = error;
19
19
  };
20
-
21
20
  Object.defineProperty(acc[error].prototype.constructor, "name", {
22
21
  value: error,
23
22
  });
24
-
25
23
  Object.defineProperty(acc[error].constructor, "name", {
26
24
  value: error,
27
25
  });
28
-
29
26
  Object.defineProperty(acc[error].prototype, "name", {
30
27
  value: error,
31
28
  });
32
-
33
29
  Object.defineProperty(acc[error], "name", {
34
30
  value: error,
35
31
  });
36
-
37
32
  return acc;
38
- }, {} as DefinedErrors<ErrorName>);
33
+ }, {});
34
+ }
35
+
36
+ export { BunWorkspacesError, defineErrors };
@@ -0,0 +1 @@
1
+ export * from "./error";
@@ -0,0 +1 @@
1
+ export * from "./error.mjs"; // CONCATENATED MODULE: ./src/internal/core/error/index.ts
@@ -0,0 +1,4 @@
1
+ export * from "./language";
2
+ export * from "./error";
3
+ export * from "./json";
4
+ export * from "./runtime";
@@ -0,0 +1,4 @@
1
+ export * from "./language/index.mjs";
2
+ export * from "./error/index.mjs";
3
+ export * from "./json/index.mjs";
4
+ export * from "./runtime/index.mjs"; // CONCATENATED MODULE: ./src/internal/core/index.ts
@@ -0,0 +1,2 @@
1
+ export * from "./json";
2
+ export * from "./jsonc";
@@ -0,0 +1,2 @@
1
+ export * from "./json.mjs";
2
+ export * from "./jsonc.mjs"; // CONCATENATED MODULE: ./src/internal/core/json/index.ts
@@ -0,0 +1,49 @@
1
+ type JSONPrimitiveMap = {
2
+ string: string;
3
+ number: number;
4
+ boolean: boolean;
5
+ null: null;
6
+ };
7
+ export type JSONPrimitiveName = keyof JSONPrimitiveMap;
8
+ export type JSONPrimitiveToName<P extends JSONPrimitive> = {
9
+ [key in keyof JSONPrimitiveMap]: P extends JSONPrimitiveMap[key]
10
+ ? key
11
+ : never;
12
+ }[keyof JSONPrimitiveMap];
13
+ export type NameToJSONPrimitive<Name extends JSONPrimitiveName> =
14
+ JSONPrimitiveMap[Name];
15
+ export type JSONPrimitive<N extends JSONPrimitiveName = JSONPrimitiveName> =
16
+ NameToJSONPrimitive<N>;
17
+ export interface JSONObject {
18
+ [key: string]: JSONData;
19
+ }
20
+ export type JSONItem = JSONPrimitive | JSONObject;
21
+ export type JSONArrayItem =
22
+ | JSONItem
23
+ | JSONItem[]
24
+ | JSONItem[][]
25
+ | JSONItem[][][]
26
+ | JSONItem[][][][]
27
+ | JSONItem[][][][][]
28
+ | JSONItem[][][][][][]
29
+ | JSONItem[][][][][][][]
30
+ | JSONItem[][][][][][][][]
31
+ | JSONItem[][][][][][][][][]
32
+ | JSONItem[][][][][][][][][][]
33
+ | JSONItem[][][][][][][][][][][];
34
+ export type JSONArray<Item extends JSONArrayItem = JSONArrayItem> = Item[];
35
+ export type JSONArrayToItem<A extends JSONArray> = A extends (infer Item)[]
36
+ ? Item
37
+ : never;
38
+ export type JSONData = JSONPrimitive | JSONObject | JSONArray;
39
+ export declare const isJSONPrimitive: (
40
+ value: unknown,
41
+ ) => value is JSONPrimitive;
42
+ export declare const isJSONArray: <T extends JSONArray = JSONArray>(
43
+ value: unknown,
44
+ ) => value is T;
45
+ export declare const isJSONObject: <T extends JSONObject = JSONObject>(
46
+ value: unknown,
47
+ ) => value is T;
48
+ export declare const isJSON: (value: unknown) => value is JSONData;
49
+ export {};
@@ -0,0 +1,12 @@
1
+ import { isTypeof } from "../language/index.mjs"; // CONCATENATED MODULE: external "../language/index.mjs"
2
+ // CONCATENATED MODULE: ./src/internal/core/json/json.ts
3
+
4
+ const isJSONPrimitive = (value) =>
5
+ isTypeof(value, "string", "number", "boolean") || value === null;
6
+ const isJSONArray = (value) => Array.isArray(value) && value.every(isJSON);
7
+ const isJSONObject = (value) =>
8
+ typeof value === "object" && value !== null && value?.constructor === Object;
9
+ const isJSON = (value) =>
10
+ isJSONPrimitive(value) || isJSONArray(value) || isJSONObject(value);
11
+
12
+ export { isJSON, isJSONArray, isJSONObject, isJSONPrimitive };
@@ -0,0 +1,9 @@
1
+ export declare const convertJSONCToJSON: (
2
+ jsonString: string,
3
+ {
4
+ whitespace,
5
+ }?: {
6
+ whitespace?: boolean | undefined;
7
+ },
8
+ ) => string;
9
+ export declare const parseJSONC: (jsonString: string) => any;
@@ -0,0 +1,117 @@
1
+ // CONCATENATED MODULE: ./src/internal/core/json/jsonc.ts
2
+ // Code based on package strip-json-comments
3
+ const stripWithoutWhitespace = () => "";
4
+ // Replace all characters except ASCII spaces, tabs and line endings with regular spaces to ensure valid JSON output.
5
+ const stripWithWhitespace = (string, start, end) =>
6
+ string.slice(start, end).replace(/[^ \t\r\n]/g, " ");
7
+ const isEscaped = (jsonString, quotePosition) => {
8
+ let index = quotePosition - 1;
9
+ let backslashCount = 0;
10
+ while (jsonString[index] === "\\") {
11
+ index -= 1;
12
+ backslashCount += 1;
13
+ }
14
+ return Boolean(backslashCount % 2);
15
+ };
16
+ const convertJSONCToJSON = (jsonString, { whitespace = true } = {}) => {
17
+ if (typeof jsonString !== "string") {
18
+ throw new TypeError(
19
+ `Expected argument \`jsonString\` to be a \`string\`, got \`${typeof jsonString}\``,
20
+ );
21
+ }
22
+ const strip = whitespace ? stripWithWhitespace : stripWithoutWhitespace;
23
+ let isInsideString = false;
24
+ let inComment = null;
25
+ let offset = 0;
26
+ let buffer = "";
27
+ let result = "";
28
+ let commaIndex = -1;
29
+ for (let index = 0; index < jsonString.length; index++) {
30
+ const currentCharacter = jsonString[index];
31
+ const nextCharacter = jsonString[index + 1];
32
+ if (!inComment && currentCharacter === '"') {
33
+ // Enter or exit string
34
+ const escaped = isEscaped(jsonString, index);
35
+ if (!escaped) {
36
+ isInsideString = !isInsideString;
37
+ }
38
+ }
39
+ if (isInsideString) {
40
+ continue;
41
+ }
42
+ if (!inComment && currentCharacter + nextCharacter === "//") {
43
+ // Enter single-line comment
44
+ buffer += jsonString.slice(offset, index);
45
+ offset = index;
46
+ inComment = "single";
47
+ index++;
48
+ } else if (
49
+ inComment === "single" &&
50
+ currentCharacter + nextCharacter === "\r\n"
51
+ ) {
52
+ // Exit single-line comment via \r\n
53
+ index++;
54
+ inComment = null;
55
+ buffer += strip(jsonString, offset, index);
56
+ offset = index;
57
+ continue;
58
+ } else if (inComment === "single" && currentCharacter === "\n") {
59
+ // Exit single-line comment via \n
60
+ inComment = null;
61
+ buffer += strip(jsonString, offset, index);
62
+ offset = index;
63
+ } else if (!inComment && currentCharacter + nextCharacter === "/*") {
64
+ // Enter multiline comment
65
+ buffer += jsonString.slice(offset, index);
66
+ offset = index;
67
+ inComment = "multi";
68
+ index++;
69
+ continue;
70
+ } else if (
71
+ inComment === "multi" &&
72
+ currentCharacter + nextCharacter === "*/"
73
+ ) {
74
+ // Exit multiline comment
75
+ index++;
76
+ inComment = null;
77
+ buffer += strip(jsonString, offset, index + 1);
78
+ offset = index + 1;
79
+ continue;
80
+ } else if (!inComment) {
81
+ if (commaIndex !== -1) {
82
+ if (currentCharacter === "}" || currentCharacter === "]") {
83
+ // Strip trailing comma
84
+ buffer += jsonString.slice(offset, index);
85
+ result += strip(buffer, 0, 1) + buffer.slice(1);
86
+ buffer = "";
87
+ offset = index;
88
+ commaIndex = -1;
89
+ } else if (
90
+ currentCharacter !== " " &&
91
+ currentCharacter !== "\t" &&
92
+ currentCharacter !== "\r" &&
93
+ currentCharacter !== "\n"
94
+ ) {
95
+ // Hit non-whitespace following a comma; comma is not trailing
96
+ buffer += jsonString.slice(offset, index);
97
+ offset = index;
98
+ commaIndex = -1;
99
+ }
100
+ } else if (currentCharacter === ",") {
101
+ // Flush buffer prior to this point, and save new comma index
102
+ result += buffer + jsonString.slice(offset, index);
103
+ buffer = "";
104
+ offset = index;
105
+ commaIndex = index;
106
+ }
107
+ }
108
+ }
109
+ const remaining =
110
+ inComment === "single"
111
+ ? strip(jsonString, offset)
112
+ : jsonString.slice(offset);
113
+ return result + buffer + remaining;
114
+ };
115
+ const parseJSONC = (jsonString) => JSON.parse(convertJSONCToJSON(jsonString));
116
+
117
+ export { convertJSONCToJSON, parseJSONC };
@@ -0,0 +1 @@
1
+ export * from "./optionalArray";
@@ -0,0 +1 @@
1
+ export * from "./optionalArray.mjs"; // CONCATENATED MODULE: ./src/internal/core/language/array/index.ts
@@ -0,0 +1,15 @@
1
+ /**
2
+ * A value that may be its type T or an array of T.
3
+ */
4
+ export type OptionalArray<
5
+ T = unknown,
6
+ IncludeReadonly extends boolean = false,
7
+ > = IncludeReadonly extends true ? T | T[] | readonly T[] : T | T[];
8
+ export type ResolvedOptionalArray<T extends OptionalArray> =
9
+ T extends (infer Item)[] ? Item[] : T[];
10
+ export type ResolvedOptionalArrayItem<T extends OptionalArray> =
11
+ T extends (infer Item)[] ? Item : T;
12
+ /** Resolve `OptionalArray<T>` to `T[]` */
13
+ export declare const resolveOptionalArray: <T extends OptionalArray>(
14
+ value: T,
15
+ ) => ResolvedOptionalArray<T>;
@@ -0,0 +1,8 @@
1
+ // CONCATENATED MODULE: ./src/internal/core/language/array/optionalArray.ts
2
+ /**
3
+ * A value that may be its type T or an array of T.
4
+ */ /** Resolve `OptionalArray<T>` to `T[]` */ const resolveOptionalArray = (
5
+ value,
6
+ ) => (value === undefined ? [] : Array.isArray(value) ? value : [value]);
7
+
8
+ export { resolveOptionalArray };
@@ -0,0 +1,16 @@
1
+ import type { SimpleAsyncIterable } from "../types";
2
+ export type AsyncQueueItem<T> =
3
+ | {
4
+ type: "value";
5
+ value: T;
6
+ }
7
+ | {
8
+ type: "done";
9
+ };
10
+ export declare const createAsyncIterableQueue: <
11
+ T,
12
+ >() => SimpleAsyncIterable<T> & {
13
+ push: (value: T) => void;
14
+ close: () => void;
15
+ closed: Promise<void>;
16
+ };
@@ -0,0 +1,81 @@
1
+ // CONCATENATED MODULE: ./src/internal/core/language/asyncIterable/asyncIterableQueue.ts
2
+ const createAsyncIterableQueue = () => {
3
+ let resolveClose = () => {
4
+ void 0;
5
+ };
6
+ const closePromise = new Promise((resolve) => {
7
+ resolveClose = resolve;
8
+ });
9
+ let pendingResolveIdle = null;
10
+ const items = [];
11
+ let isDone = false;
12
+ const push = (value) => {
13
+ if (isDone) return;
14
+ if (pendingResolveIdle) {
15
+ const resolveIdle = pendingResolveIdle;
16
+ pendingResolveIdle = null;
17
+ resolveIdle({
18
+ value,
19
+ done: false,
20
+ });
21
+ } else {
22
+ items.push({
23
+ type: "value",
24
+ value,
25
+ });
26
+ }
27
+ };
28
+ const close = () => {
29
+ if (isDone) return;
30
+ isDone = true;
31
+ if (pendingResolveIdle) {
32
+ const resolveIdle = pendingResolveIdle;
33
+ pendingResolveIdle = null;
34
+ resolveIdle({
35
+ value: undefined,
36
+ done: true,
37
+ });
38
+ } else {
39
+ items.push({
40
+ type: "done",
41
+ });
42
+ }
43
+ resolveClose();
44
+ };
45
+ const asyncIterator = {
46
+ next: () => {
47
+ if (items.length > 0) {
48
+ const item = items.shift();
49
+ if (item.type === "done") {
50
+ isDone = true;
51
+ return Promise.resolve({
52
+ value: undefined,
53
+ done: true,
54
+ });
55
+ }
56
+ return Promise.resolve({
57
+ value: item.value,
58
+ done: false,
59
+ });
60
+ }
61
+ if (isDone) {
62
+ return Promise.resolve({
63
+ value: undefined,
64
+ done: true,
65
+ });
66
+ }
67
+ return new Promise((resolve) => {
68
+ pendingResolveIdle = resolve;
69
+ });
70
+ },
71
+ };
72
+ const iterator = {
73
+ [Symbol.asyncIterator]: () => asyncIterator,
74
+ push,
75
+ close,
76
+ closed: closePromise,
77
+ };
78
+ return iterator;
79
+ };
80
+
81
+ export { createAsyncIterableQueue };
@@ -0,0 +1,2 @@
1
+ export * from "./asyncIterableQueue";
2
+ export * from "./mergeAsyncIterables";
@@ -0,0 +1,2 @@
1
+ export * from "./asyncIterableQueue.mjs";
2
+ export * from "./mergeAsyncIterables.mjs"; // CONCATENATED MODULE: ./src/internal/core/language/asyncIterable/index.ts
@@ -0,0 +1,5 @@
1
+ import type { SimpleAsyncIterable } from "../types";
2
+ /** Run multiple async iterables in parallel and yield the results in the order they are completed. */
3
+ export declare const mergeAsyncIterables: <T>(
4
+ iterables: SimpleAsyncIterable<T>[],
5
+ ) => SimpleAsyncIterable<T>;
@@ -0,0 +1,27 @@
1
+ // CONCATENATED MODULE: ./src/internal/core/language/asyncIterable/mergeAsyncIterables.ts
2
+ /** Run multiple async iterables in parallel and yield the results in the order they are completed. */ const mergeAsyncIterables =
3
+ (iterables) => ({
4
+ async *[Symbol.asyncIterator]() {
5
+ const iterators = iterables.map((it) => it[Symbol.asyncIterator]());
6
+ const callNext = (index) =>
7
+ iterators[index].next().then((result) => ({
8
+ index,
9
+ result,
10
+ }));
11
+ const nextCalls = iterators.map((_, i) => callNext(i));
12
+ let activeCount = iterators.length;
13
+ while (activeCount > 0) {
14
+ const { index, result } = await Promise.race(nextCalls);
15
+ if (result.done) {
16
+ activeCount--;
17
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
18
+ nextCalls[index] = new Promise(() => {});
19
+ continue;
20
+ }
21
+ nextCalls[index] = callNext(index);
22
+ yield result.value;
23
+ }
24
+ },
25
+ });
26
+
27
+ export { mergeAsyncIterables };
@@ -0,0 +1,50 @@
1
+ export type TypedEvent<
2
+ TypeName extends string = string,
3
+ ExtraProperties extends object = object,
4
+ > = Event & {
5
+ type: TypeName;
6
+ } & ExtraProperties;
7
+ export declare const TypedEvent: {
8
+ prototype: TypedEvent;
9
+ new <TypeName extends string = string>(
10
+ type: TypeName,
11
+ options?: EventInit,
12
+ ): TypedEvent<TypeName>;
13
+ };
14
+ type ExtraProperties<E> =
15
+ E extends TypedEvent<string, infer ExtraProperties>
16
+ ? Omit<ExtraProperties, "type">
17
+ : undefined;
18
+ export declare const createTypedEventFactory: <
19
+ E extends TypedEvent = TypedEvent,
20
+ >(
21
+ type: E["type"],
22
+ ) => (properties: ExtraProperties<E>, options?: EventInit) => E;
23
+ export type EventConfig = {
24
+ [key: string]: TypedEvent;
25
+ };
26
+ type EventFromName<
27
+ E extends keyof Config,
28
+ Config extends EventConfig,
29
+ > = Config[E];
30
+ export interface TypedEventTarget<Config extends EventConfig = EventConfig> {
31
+ addEventListener<EventName extends keyof Config>(
32
+ event: EventName,
33
+ listener: (event: EventFromName<EventName, Config>) => unknown,
34
+ ): void;
35
+ removeEventListener<EventName extends keyof Config>(
36
+ event: EventName,
37
+ listener: (event: EventFromName<EventName, Config>) => unknown,
38
+ ): void;
39
+ dispatchEvent<EventName extends keyof Config>(
40
+ event: EventFromName<EventName, Config>,
41
+ ): boolean;
42
+ }
43
+ /**
44
+ * An EventTarget with typing for specific events.
45
+ */
46
+ export declare const TypedEventTarget: {
47
+ prototype: TypedEventTarget;
48
+ new <Config extends EventConfig = EventConfig>(): TypedEventTarget<Config>;
49
+ };
50
+ export {};
@@ -0,0 +1,14 @@
1
+ // CONCATENATED MODULE: ./src/internal/core/language/events/typedEventTarget.ts
2
+ const TypedEvent = Event;
3
+ const createTypedEventFactory = (type) => (properties, options) => {
4
+ const event = new TypedEvent(type, options);
5
+ for (const key in properties) {
6
+ event[key] = properties[key];
7
+ }
8
+ return event;
9
+ };
10
+ /**
11
+ * An EventTarget with typing for specific events.
12
+ */ const TypedEventTarget = EventTarget;
13
+
14
+ export { TypedEvent, TypedEventTarget, createTypedEventFactory };
@@ -0,0 +1,5 @@
1
+ export * from "./asyncIterable";
2
+ export * from "./array";
3
+ export * from "./types";
4
+ export * from "./regex";
5
+ export * from "./string";
@@ -0,0 +1,5 @@
1
+ export * from "./asyncIterable/index.mjs";
2
+ export * from "./array/index.mjs";
3
+ export * from "./types/index.mjs";
4
+ export * from "./regex/index.mjs";
5
+ export * from "./string/index.mjs"; // CONCATENATED MODULE: ./src/internal/core/language/index.ts
@@ -0,0 +1 @@
1
+ export * from "./regex";
@@ -0,0 +1 @@
1
+ export * from "./regex.mjs"; // CONCATENATED MODULE: ./src/internal/core/language/regex/index.ts
@@ -0,0 +1,3 @@
1
+ export declare const createRawPattern: (pattern: string) => string;
2
+ export declare const createWildcardRegex: (pattern: string) => RegExp;
3
+ export declare const sanitizeAnsi: (text: string) => string;
@@ -0,0 +1,10 @@
1
+ // CONCATENATED MODULE: ./src/internal/core/language/regex/regex.ts
2
+ const createRawPattern = (pattern) =>
3
+ pattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4
+ const createWildcardRegex = (pattern) =>
5
+ new RegExp(`^${pattern.split("*").map(createRawPattern).join(".*")}$`);
6
+ const sanitizeAnsi = (
7
+ text, // eslint-disable-next-line no-control-regex
8
+ ) => text.replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "");
9
+
10
+ export { createRawPattern, createWildcardRegex, sanitizeAnsi };
@@ -0,0 +1 @@
1
+ export declare const createShortId: (bytes?: number) => string;
@@ -0,0 +1,10 @@
1
+ // CONCATENATED MODULE: ./src/internal/core/language/string/id.ts
2
+ const createShortId = (bytes = 12) => {
3
+ const buf = new Uint8Array(bytes);
4
+ crypto.getRandomValues(buf);
5
+ return Buffer.from(buf)
6
+ .toString("base64url")
7
+ .slice(0, Math.ceil((bytes * 4) / 3));
8
+ };
9
+
10
+ export { createShortId };
@@ -0,0 +1 @@
1
+ export * from "./id";
@@ -0,0 +1 @@
1
+ export * from "./id.mjs"; // CONCATENATED MODULE: ./src/internal/core/language/string/index.ts
@@ -0,0 +1,16 @@
1
+ /** A port of the package eastasianwidth */
2
+ export declare const eaw: {
3
+ /**
4
+ * F: Full width
5
+ * H: Half width
6
+ * W: Wide
7
+ * Na: Narrow
8
+ * A: Ambiguous
9
+ * N: Neutral
10
+ */
11
+ eastAsianWidth: (character: string) => "F" | "H" | "W" | "Na" | "A" | "N";
12
+ characterLength: (character: string) => 1 | 2;
13
+ stringToArray: (s: string) => [] | RegExpMatchArray;
14
+ length: (string: string) => number;
15
+ slice: (text: string, start: number, end: number) => string;
16
+ };