@bolt-foundry/gambit 0.5.3-dev.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/bin/gambit.cjs +214 -0
  3. package/esm/_dnt.polyfills.d.ts +82 -6
  4. package/esm/_dnt.polyfills.d.ts.map +1 -1
  5. package/esm/_dnt.polyfills.js +127 -1
  6. package/esm/deps/jsr.io/@std/path/1.1.4/constants.d.ts +1 -1
  7. package/esm/deps/jsr.io/@std/path/1.1.4/posix/constants.d.ts.map +1 -1
  8. package/esm/deps/jsr.io/@std/path/1.1.4/windows/constants.d.ts.map +1 -1
  9. package/{simulator-ui → esm/gambit/simulator-ui/dist}/bundle.js +253 -120
  10. package/{simulator-ui → esm/gambit/simulator-ui/dist}/bundle.js.map +4 -4
  11. package/esm/mod.d.ts +53 -0
  12. package/esm/mod.d.ts.map +1 -0
  13. package/esm/mod.js +22 -0
  14. package/esm/packages/gambit-core/mod.d.ts.map +1 -0
  15. package/esm/packages/gambit-core/src/definitions.d.ts.map +1 -0
  16. package/esm/packages/gambit-core/src/openai_compat.d.ts.map +1 -0
  17. package/esm/packages/gambit-core/src/providers/openrouter.d.ts.map +1 -0
  18. package/esm/{gambit-core → packages/gambit-core}/src/providers/openrouter.js +1 -1
  19. package/esm/packages/gambit-core/src/render.d.ts.map +1 -0
  20. package/esm/packages/gambit-core/src/schema.d.ts.map +1 -0
  21. package/esm/src/durable_streams.d.ts.map +1 -0
  22. package/esm/{gambit/src → src}/server.d.ts +4 -1
  23. package/esm/src/server.d.ts.map +1 -0
  24. package/esm/{gambit/src → src}/server.js +26 -12
  25. package/esm/src/test_bot.d.ts.map +1 -0
  26. package/esm/src/trace.d.ts.map +1 -0
  27. package/esm/{gambit/src → src}/trace.js +2 -2
  28. package/package.json +10 -6
  29. package/script/_dnt.polyfills.d.ts +82 -6
  30. package/script/_dnt.polyfills.d.ts.map +1 -1
  31. package/script/_dnt.polyfills.js +128 -0
  32. package/script/deps/jsr.io/@std/internal/1.0.12/_os.js +17 -7
  33. package/script/deps/jsr.io/@std/path/1.1.4/constants.d.ts +1 -1
  34. package/script/deps/jsr.io/@std/path/1.1.4/posix/constants.d.ts.map +1 -1
  35. package/script/deps/jsr.io/@std/path/1.1.4/posix/resolve.js +17 -7
  36. package/script/deps/jsr.io/@std/path/1.1.4/windows/constants.d.ts.map +1 -1
  37. package/script/deps/jsr.io/@std/path/1.1.4/windows/resolve.js +17 -7
  38. package/script/gambit/simulator-ui/dist/.gitkeep +1 -0
  39. package/script/gambit/simulator-ui/dist/bundle.js +22957 -0
  40. package/script/gambit/simulator-ui/dist/bundle.js.map +7 -0
  41. package/script/mod.d.ts +53 -0
  42. package/script/mod.d.ts.map +1 -0
  43. package/script/mod.js +33 -0
  44. package/script/packages/gambit-core/mod.d.ts.map +1 -0
  45. package/script/packages/gambit-core/src/definitions.d.ts.map +1 -0
  46. package/script/packages/gambit-core/src/openai_compat.d.ts.map +1 -0
  47. package/script/packages/gambit-core/src/providers/openrouter.d.ts.map +1 -0
  48. package/script/{gambit-core → packages/gambit-core}/src/providers/openrouter.js +18 -8
  49. package/script/packages/gambit-core/src/render.d.ts.map +1 -0
  50. package/script/packages/gambit-core/src/schema.d.ts.map +1 -0
  51. package/script/src/durable_streams.d.ts.map +1 -0
  52. package/script/{gambit/src → src}/server.d.ts +4 -1
  53. package/script/src/server.d.ts.map +1 -0
  54. package/script/{gambit/src → src}/server.js +43 -19
  55. package/script/src/test_bot.d.ts.map +1 -0
  56. package/script/src/trace.d.ts.map +1 -0
  57. package/script/{gambit/src → src}/trace.js +19 -9
  58. package/esm/gambit/mod.d.ts +0 -10
  59. package/esm/gambit/mod.d.ts.map +0 -1
  60. package/esm/gambit/mod.js +0 -9
  61. package/esm/gambit/src/durable_streams.d.ts.map +0 -1
  62. package/esm/gambit/src/server.d.ts.map +0 -1
  63. package/esm/gambit/src/test_bot.d.ts.map +0 -1
  64. package/esm/gambit/src/trace.d.ts.map +0 -1
  65. package/esm/gambit-core/mod.d.ts.map +0 -1
  66. package/esm/gambit-core/src/definitions.d.ts.map +0 -1
  67. package/esm/gambit-core/src/openai_compat.d.ts.map +0 -1
  68. package/esm/gambit-core/src/providers/openrouter.d.ts.map +0 -1
  69. package/esm/gambit-core/src/render.d.ts.map +0 -1
  70. package/esm/gambit-core/src/schema.d.ts.map +0 -1
  71. package/script/gambit/mod.d.ts +0 -10
  72. package/script/gambit/mod.d.ts.map +0 -1
  73. package/script/gambit/mod.js +0 -27
  74. package/script/gambit/src/durable_streams.d.ts.map +0 -1
  75. package/script/gambit/src/server.d.ts.map +0 -1
  76. package/script/gambit/src/test_bot.d.ts.map +0 -1
  77. package/script/gambit/src/trace.d.ts.map +0 -1
  78. package/script/gambit-core/mod.d.ts.map +0 -1
  79. package/script/gambit-core/src/definitions.d.ts.map +0 -1
  80. package/script/gambit-core/src/openai_compat.d.ts.map +0 -1
  81. package/script/gambit-core/src/providers/openrouter.d.ts.map +0 -1
  82. package/script/gambit-core/src/render.d.ts.map +0 -1
  83. package/script/gambit-core/src/schema.d.ts.map +0 -1
  84. /package/{simulator-ui → esm/gambit/simulator-ui/dist}/.gitkeep +0 -0
  85. /package/esm/{gambit-core → packages/gambit-core}/mod.d.ts +0 -0
  86. /package/esm/{gambit-core → packages/gambit-core}/mod.js +0 -0
  87. /package/esm/{gambit-core → packages/gambit-core}/src/definitions.d.ts +0 -0
  88. /package/esm/{gambit-core → packages/gambit-core}/src/definitions.js +0 -0
  89. /package/esm/{gambit-core → packages/gambit-core}/src/openai_compat.d.ts +0 -0
  90. /package/esm/{gambit-core → packages/gambit-core}/src/openai_compat.js +0 -0
  91. /package/esm/{gambit-core → packages/gambit-core}/src/providers/openrouter.d.ts +0 -0
  92. /package/esm/{gambit-core → packages/gambit-core}/src/render.d.ts +0 -0
  93. /package/esm/{gambit-core → packages/gambit-core}/src/render.js +0 -0
  94. /package/esm/{gambit-core → packages/gambit-core}/src/schema.d.ts +0 -0
  95. /package/esm/{gambit-core → packages/gambit-core}/src/schema.js +0 -0
  96. /package/esm/{gambit/src → src}/durable_streams.d.ts +0 -0
  97. /package/esm/{gambit/src → src}/durable_streams.js +0 -0
  98. /package/esm/{gambit/src → src}/test_bot.d.ts +0 -0
  99. /package/esm/{gambit/src → src}/test_bot.js +0 -0
  100. /package/esm/{gambit/src → src}/trace.d.ts +0 -0
  101. /package/script/{gambit-core → packages/gambit-core}/mod.d.ts +0 -0
  102. /package/script/{gambit-core → packages/gambit-core}/mod.js +0 -0
  103. /package/script/{gambit-core → packages/gambit-core}/src/definitions.d.ts +0 -0
  104. /package/script/{gambit-core → packages/gambit-core}/src/definitions.js +0 -0
  105. /package/script/{gambit-core → packages/gambit-core}/src/openai_compat.d.ts +0 -0
  106. /package/script/{gambit-core → packages/gambit-core}/src/openai_compat.js +0 -0
  107. /package/script/{gambit-core → packages/gambit-core}/src/providers/openrouter.d.ts +0 -0
  108. /package/script/{gambit-core → packages/gambit-core}/src/render.d.ts +0 -0
  109. /package/script/{gambit-core → packages/gambit-core}/src/render.js +0 -0
  110. /package/script/{gambit-core → packages/gambit-core}/src/schema.d.ts +0 -0
  111. /package/script/{gambit-core → packages/gambit-core}/src/schema.js +0 -0
  112. /package/script/{gambit/src → src}/durable_streams.d.ts +0 -0
  113. /package/script/{gambit/src → src}/durable_streams.js +0 -0
  114. /package/script/{gambit/src → src}/test_bot.d.ts +0 -0
  115. /package/script/{gambit/src → src}/test_bot.js +0 -0
  116. /package/script/{gambit/src → src}/trace.d.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -5,10 +5,30 @@ since = "b0ddcc2ba4e861e0879dc92cc713e8cde30d230f"
5
5
 
6
6
  # Changelog
7
7
 
8
- ## Unreleased (v0.6.0)
8
+ ## Unreleased (v0.6.1)
9
9
 
10
10
  - TBD
11
11
 
12
+ ## v0.6.0
13
+
14
+ ### Release and packaging
15
+
16
+ - Add an npm CLI wrapper that downloads prebuilt Gambit binaries with checksum
17
+ verification.
18
+ - Normalize release binary asset names and checksum generation for predictable
19
+ npm downloads.
20
+ - Fix the npm build to resolve gambit-core in the mirror layout and derive
21
+ import-map targets from the detected path.
22
+ - Add `@deno/dnt` to the Gambit package and refresh release/npm docs.
23
+
24
+ ## v0.5.5
25
+
26
+ ### Release and packaging
27
+
28
+ - Publish a minimal `@bolt-foundry/gambit` npm package alongside gambit-core
29
+ (runtime-only; no CLI/bin yet).
30
+ - Document DNT/npm status and release notes for the npm publish flow.
31
+
12
32
  ## v0.5.0
13
33
 
14
34
  ### Runtime and API
package/bin/gambit.cjs ADDED
@@ -0,0 +1,214 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const os = require("os");
7
+ const https = require("https");
8
+ const http = require("http");
9
+ const crypto = require("crypto");
10
+ const { spawnSync } = require("child_process");
11
+
12
+ const MAX_REDIRECTS = 5;
13
+
14
+ const readJson = (filePath) => {
15
+ const raw = fs.readFileSync(filePath, "utf8");
16
+ return JSON.parse(raw);
17
+ };
18
+
19
+ const getPackageVersion = () => {
20
+ const pkgPath = path.join(__dirname, "..", "package.json");
21
+ const pkg = readJson(pkgPath);
22
+ if (!pkg.version) {
23
+ throw new Error(`Missing version in ${pkgPath}`);
24
+ }
25
+ return pkg.version;
26
+ };
27
+
28
+ const getPlatformAsset = () => {
29
+ const { platform, arch } = process;
30
+ if (platform === "darwin" && arch === "arm64") {
31
+ return "gambit-darwin-arm64";
32
+ }
33
+ if (platform === "darwin" && arch === "x64") {
34
+ return "gambit-darwin-x64";
35
+ }
36
+ if (platform === "linux" && arch === "x64") {
37
+ return "gambit-linux-x64";
38
+ }
39
+ if (platform === "linux" && arch === "arm64") {
40
+ return "gambit-linux-arm64";
41
+ }
42
+ return "";
43
+ };
44
+
45
+ const getCacheDir = (version) => {
46
+ const cacheRoot = process.env.XDG_CACHE_HOME ||
47
+ (process.env.HOME ? path.join(process.env.HOME, ".cache") : os.tmpdir());
48
+ return path.join(cacheRoot, "bolt-foundry", "gambit", version);
49
+ };
50
+
51
+ const request = (url, redirectCount = 0) =>
52
+ new Promise((resolve, reject) => {
53
+ const client = url.startsWith("https:") ? https : http;
54
+ const req = client.get(url, (res) => {
55
+ const status = res.statusCode || 0;
56
+ if (
57
+ status >= 300 && status < 400 && res.headers.location &&
58
+ redirectCount < MAX_REDIRECTS
59
+ ) {
60
+ const nextUrl = new URL(res.headers.location, url).toString();
61
+ res.resume();
62
+ resolve(request(nextUrl, redirectCount + 1));
63
+ return;
64
+ }
65
+ if (status !== 200) {
66
+ res.resume();
67
+ reject(new Error(`HTTP ${status} for ${url}`));
68
+ return;
69
+ }
70
+ resolve(res);
71
+ });
72
+ req.on("error", reject);
73
+ });
74
+
75
+ const downloadFile = async (url, dest) => {
76
+ const tmpDest = `${dest}.tmp-${process.pid}`;
77
+ await fs.promises.mkdir(path.dirname(dest), { recursive: true });
78
+ const res = await request(url);
79
+ await new Promise((resolve, reject) => {
80
+ const file = fs.createWriteStream(tmpDest, { mode: 0o755 });
81
+ res.pipe(file);
82
+ res.on("error", (err) => {
83
+ file.close(() => reject(err));
84
+ });
85
+ file.on("finish", () => file.close(resolve));
86
+ file.on("error", reject);
87
+ });
88
+ await fs.promises.rename(tmpDest, dest);
89
+ };
90
+
91
+ const fetchText = async (url) => {
92
+ const res = await request(url);
93
+ const chunks = [];
94
+ for await (const chunk of res) {
95
+ chunks.push(chunk);
96
+ }
97
+ return Buffer.concat(chunks).toString("utf8");
98
+ };
99
+
100
+ const sha256File = (filePath) =>
101
+ new Promise((resolve, reject) => {
102
+ const hash = crypto.createHash("sha256");
103
+ const stream = fs.createReadStream(filePath);
104
+ stream.on("data", (chunk) => hash.update(chunk));
105
+ stream.on("error", reject);
106
+ stream.on("end", () => resolve(hash.digest("hex")));
107
+ });
108
+
109
+ const allowUnverified = process.env.GAMBIT_ALLOW_UNVERIFIED === "1";
110
+
111
+ const verifyChecksum = async (checksumUrl, assetName, filePath) => {
112
+ let text;
113
+ try {
114
+ text = await fetchText(checksumUrl);
115
+ } catch (err) {
116
+ if (allowUnverified) {
117
+ console.warn(`Warning: unable to fetch checksums: ${err.message}`);
118
+ return;
119
+ }
120
+ throw new Error(`Unable to fetch checksums: ${err.message}`);
121
+ }
122
+ const lines = text.split("\n").map((line) => line.trim()).filter(Boolean);
123
+ const match = lines
124
+ .map((line) => line.match(/^([a-f0-9]{64})\s+(.+)$/i))
125
+ .find((result) => result && path.posix.basename(result[2]) === assetName);
126
+ if (!match) {
127
+ if (allowUnverified) {
128
+ console.warn(`Warning: checksum for ${assetName} not found.`);
129
+ return;
130
+ }
131
+ throw new Error(`Checksum for ${assetName} not found.`);
132
+ }
133
+ const expected = match[1].toLowerCase();
134
+ const actual = (await sha256File(filePath)).toLowerCase();
135
+ if (expected !== actual) {
136
+ throw new Error(`Checksum mismatch for ${assetName}`);
137
+ }
138
+ };
139
+
140
+ const main = async () => {
141
+ const version = getPackageVersion();
142
+ const assetName = process.env.GAMBIT_BINARY_NAME || getPlatformAsset();
143
+ if (!assetName) {
144
+ console.error(
145
+ `Unsupported platform ${process.platform}/${process.arch}.`,
146
+ );
147
+ process.exit(1);
148
+ }
149
+
150
+ const baseUrl = process.env.GAMBIT_BINARY_BASE_URL ||
151
+ `https://github.com/bolt-foundry/gambit/releases/download/v${version}`;
152
+ const binaryUrl = process.env.GAMBIT_BINARY_URL || `${baseUrl}/${assetName}`;
153
+ const checksumUrl = process.env.GAMBIT_BINARY_CHECKSUM_URL ||
154
+ `${baseUrl}/SHA256SUMS`;
155
+
156
+ const cacheDir = getCacheDir(version);
157
+ const binPath = path.join(cacheDir, assetName);
158
+ const ensureBinary = async () => {
159
+ if (fs.existsSync(binPath)) {
160
+ try {
161
+ await verifyChecksum(checksumUrl, assetName, binPath);
162
+ return;
163
+ } catch (err) {
164
+ console.warn(
165
+ `Cached binary failed checksum; deleting and re-downloading.`,
166
+ );
167
+ try {
168
+ await fs.promises.unlink(binPath);
169
+ } catch {
170
+ // ignore
171
+ }
172
+ }
173
+ }
174
+ console.log(`Downloading ${binaryUrl}...`);
175
+ await downloadFile(binaryUrl, binPath);
176
+ try {
177
+ await verifyChecksum(checksumUrl, assetName, binPath);
178
+ } catch (err) {
179
+ try {
180
+ await fs.promises.unlink(binPath);
181
+ } catch {
182
+ // ignore
183
+ }
184
+ throw err;
185
+ }
186
+ };
187
+
188
+ try {
189
+ await ensureBinary();
190
+ } catch (err) {
191
+ console.error(`Checksum verification failed: ${err.message}`);
192
+ process.exit(1);
193
+ }
194
+
195
+ try {
196
+ await fs.promises.chmod(binPath, 0o755);
197
+ } catch {
198
+ // ignore
199
+ }
200
+
201
+ const result = spawnSync(binPath, process.argv.slice(2), {
202
+ stdio: "inherit",
203
+ });
204
+ if (result.error) {
205
+ console.error(`Failed to launch gambit: ${result.error.message}`);
206
+ process.exit(1);
207
+ }
208
+ process.exit(result.status ?? 1);
209
+ };
210
+
211
+ main().catch((err) => {
212
+ console.error(err.stack || err.message || String(err));
213
+ process.exit(1);
214
+ });
@@ -1,5 +1,49 @@
1
+ /**
2
+ * Based on [import-meta-ponyfill](https://github.com/gaubee/import-meta-ponyfill),
3
+ * but instead of using npm to install additional dependencies,
4
+ * this approach manually consolidates cjs/mjs/d.ts into a single file.
5
+ *
6
+ * Note that this code might be imported multiple times
7
+ * (for example, both dnt.test.polyfills.ts and dnt.polyfills.ts contain this code;
8
+ * or Node.js might dynamically clear the cache and then force a require).
9
+ * Therefore, it's important to avoid redundant writes to global objects.
10
+ * Additionally, consider that commonjs is used alongside esm,
11
+ * so the two ponyfill functions are stored independently in two separate global objects.
12
+ */
13
+ import { createRequire } from "node:module";
14
+ import { type URL } from "node:url";
1
15
  declare global {
2
16
  interface ImportMeta {
17
+ /** A string representation of the fully qualified module URL. When the
18
+ * module is loaded locally, the value will be a file URL (e.g.
19
+ * `file:///path/module.ts`).
20
+ *
21
+ * You can also parse the string as a URL to determine more information about
22
+ * how the current module was loaded. For example to determine if a module was
23
+ * local or not:
24
+ *
25
+ * ```ts
26
+ * const url = new URL(import.meta.url);
27
+ * if (url.protocol === "file:") {
28
+ * console.log("this module was loaded locally");
29
+ * }
30
+ * ```
31
+ */
32
+ url: string;
33
+ /**
34
+ * A function that returns resolved specifier as if it would be imported
35
+ * using `import(specifier)`.
36
+ *
37
+ * ```ts
38
+ * console.log(import.meta.resolve("./foo.js"));
39
+ * // file:///dev/foo.js
40
+ * ```
41
+ *
42
+ * @param specifier The module specifier to resolve relative to `parent`.
43
+ * @param parent The absolute parent module URL to resolve from.
44
+ * @returns The absolute (`file:`) URL string for the resolved module.
45
+ */
46
+ resolve(specifier: string, parent?: string | URL | undefined): string;
3
47
  /** A flag that indicates if the current module is the main module that was
4
48
  * called when starting the program under Deno.
5
49
  *
@@ -10,16 +54,48 @@ declare global {
10
54
  * ```
11
55
  */
12
56
  main: boolean;
13
- /** A function that returns resolved specifier as if it would be imported
14
- * using `import(specifier)`.
57
+ /** The absolute path of the current module.
15
58
  *
16
- * ```ts
17
- * console.log(import.meta.resolve("./foo.js"));
18
- * // file:///dev/foo.js
59
+ * This property is only provided for local modules (ie. using `file://` URLs).
60
+ *
61
+ * Example:
62
+ * ```
63
+ * // Unix
64
+ * console.log(import.meta.filename); // /home/alice/my_module.ts
65
+ *
66
+ * // Windows
67
+ * console.log(import.meta.filename); // C:\alice\my_module.ts
19
68
  * ```
20
69
  */
21
- resolve(specifier: string): string;
70
+ filename: string;
71
+ /** The absolute path of the directory containing the current module.
72
+ *
73
+ * This property is only provided for local modules (ie. using `file://` URLs).
74
+ *
75
+ * * Example:
76
+ * ```
77
+ * // Unix
78
+ * console.log(import.meta.dirname); // /home/alice
79
+ *
80
+ * // Windows
81
+ * console.log(import.meta.dirname); // C:\alice
82
+ * ```
83
+ */
84
+ dirname: string;
22
85
  }
23
86
  }
87
+ type NodeRequest = ReturnType<typeof createRequire>;
88
+ type NodeModule = NonNullable<NodeRequest["main"]>;
89
+ interface ImportMetaPonyfillCommonjs {
90
+ (require: NodeRequest, module: NodeModule): ImportMeta;
91
+ }
92
+ interface ImportMetaPonyfillEsmodule {
93
+ (importMeta: ImportMeta): ImportMeta;
94
+ }
95
+ interface ImportMetaPonyfill extends ImportMetaPonyfillCommonjs, ImportMetaPonyfillEsmodule {
96
+ }
97
+ export declare let import_meta_ponyfill_commonjs: ImportMetaPonyfillCommonjs;
98
+ export declare let import_meta_ponyfill_esmodule: ImportMetaPonyfillEsmodule;
99
+ export declare let import_meta_ponyfill: ImportMetaPonyfill;
24
100
  export {};
25
101
  //# sourceMappingURL=_dnt.polyfills.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"_dnt.polyfills.d.ts","sourceRoot":"","sources":["../src/_dnt.polyfills.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,UAAU;QAClB;;;;;;;;WAQG;QACH,IAAI,EAAE,OAAO,CAAC;QAEd;;;;;;;WAOG;QAEH,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;KACpC;CACF;AAED,OAAO,EAAE,CAAA"}
1
+ {"version":3,"file":"_dnt.polyfills.d.ts","sourceRoot":"","sources":["../src/_dnt.polyfills.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAgC,KAAK,GAAG,EAAE,MAAM,UAAU,CAAC;AAGlE,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,UAAU;QAClB;;;;;;;;;;;;;;WAcG;QACH,GAAG,EAAE,MAAM,CAAC;QACZ;;;;;;;;;;;;WAYG;QACH,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS,GAAG,MAAM,CAAC;QACtE;;;;;;;;WAQG;QACH,IAAI,EAAE,OAAO,CAAC;QAEd;;;;;;;;;;;;WAYG;QACH,QAAQ,EAAE,MAAM,CAAC;QAEjB;;;;;;;;;;;;WAYG;QACH,OAAO,EAAE,MAAM,CAAC;KACjB;CACF;AAED,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACpD,KAAK,UAAU,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;AACnD,UAAU,0BAA0B;IAClC,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC;CACxD;AACD,UAAU,0BAA0B;IAClC,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC;CACtC;AACD,UAAU,kBACR,SAAQ,0BAA0B,EAAE,0BAA0B;CAC/D;AAiBD,eAAO,IAAI,6BAA6B,EA2BnC,0BAA0B,CAAC;AAMhC,eAAO,IAAI,6BAA6B,EA4DnC,0BAA0B,CAAC;AAMhC,eAAO,IAAI,oBAAoB,EAoB1B,kBAAkB,CAAC"}
@@ -1 +1,127 @@
1
- export {};
1
+ /**
2
+ * Based on [import-meta-ponyfill](https://github.com/gaubee/import-meta-ponyfill),
3
+ * but instead of using npm to install additional dependencies,
4
+ * this approach manually consolidates cjs/mjs/d.ts into a single file.
5
+ *
6
+ * Note that this code might be imported multiple times
7
+ * (for example, both dnt.test.polyfills.ts and dnt.polyfills.ts contain this code;
8
+ * or Node.js might dynamically clear the cache and then force a require).
9
+ * Therefore, it's important to avoid redundant writes to global objects.
10
+ * Additionally, consider that commonjs is used alongside esm,
11
+ * so the two ponyfill functions are stored independently in two separate global objects.
12
+ */
13
+ //@ts-ignore
14
+ import { createRequire } from "node:module";
15
+ //@ts-ignore
16
+ import { fileURLToPath, pathToFileURL } from "node:url";
17
+ //@ts-ignore
18
+ import { dirname } from "node:path";
19
+ const defineGlobalPonyfill = (symbolFor, fn) => {
20
+ if (!Reflect.has(globalThis, Symbol.for(symbolFor))) {
21
+ Object.defineProperty(globalThis, Symbol.for(symbolFor), {
22
+ configurable: true,
23
+ get() {
24
+ return fn;
25
+ },
26
+ });
27
+ }
28
+ };
29
+ export let import_meta_ponyfill_commonjs = (Reflect.get(globalThis, Symbol.for("import-meta-ponyfill-commonjs")) ??
30
+ (() => {
31
+ const moduleImportMetaWM = new WeakMap();
32
+ return (require, module) => {
33
+ let importMetaCache = moduleImportMetaWM.get(module);
34
+ if (importMetaCache == null) {
35
+ const importMeta = Object.assign(Object.create(null), {
36
+ url: pathToFileURL(module.filename).href,
37
+ main: require.main == module,
38
+ resolve: (specifier, parentURL = importMeta.url) => {
39
+ return pathToFileURL((importMeta.url === parentURL
40
+ ? require
41
+ : createRequire(parentURL))
42
+ .resolve(specifier)).href;
43
+ },
44
+ filename: module.filename,
45
+ dirname: module.path,
46
+ });
47
+ moduleImportMetaWM.set(module, importMeta);
48
+ importMetaCache = importMeta;
49
+ }
50
+ return importMetaCache;
51
+ };
52
+ })());
53
+ defineGlobalPonyfill("import-meta-ponyfill-commonjs", import_meta_ponyfill_commonjs);
54
+ export let import_meta_ponyfill_esmodule = (Reflect.get(globalThis, Symbol.for("import-meta-ponyfill-esmodule")) ??
55
+ ((importMeta) => {
56
+ const resolveFunStr = String(importMeta.resolve);
57
+ const shimWs = new WeakSet();
58
+ //@ts-ignore
59
+ const mainUrl = ("file:///" + process.argv[1].replace(/\\/g, "/"))
60
+ .replace(/\/{3,}/, "///");
61
+ const commonShim = (importMeta) => {
62
+ if (typeof importMeta.main !== "boolean") {
63
+ importMeta.main = importMeta.url === mainUrl;
64
+ }
65
+ if (typeof importMeta.filename !== "string") {
66
+ importMeta.filename = fileURLToPath(importMeta.url);
67
+ importMeta.dirname = dirname(importMeta.filename);
68
+ }
69
+ };
70
+ if (
71
+ // v16.2.0+, v14.18.0+: Add support for WHATWG URL object to parentURL parameter.
72
+ resolveFunStr === "undefined" ||
73
+ // v20.0.0+, v18.19.0+"" This API now returns a string synchronously instead of a Promise.
74
+ resolveFunStr.startsWith("async")
75
+ // enable by --experimental-import-meta-resolve flag
76
+ ) {
77
+ import_meta_ponyfill_esmodule = (importMeta) => {
78
+ if (!shimWs.has(importMeta)) {
79
+ shimWs.add(importMeta);
80
+ const importMetaUrlRequire = {
81
+ url: importMeta.url,
82
+ require: createRequire(importMeta.url),
83
+ };
84
+ importMeta.resolve = function resolve(specifier, parentURL = importMeta.url) {
85
+ return pathToFileURL((importMetaUrlRequire.url === parentURL
86
+ ? importMetaUrlRequire.require
87
+ : createRequire(parentURL)).resolve(specifier)).href;
88
+ };
89
+ commonShim(importMeta);
90
+ }
91
+ return importMeta;
92
+ };
93
+ }
94
+ else {
95
+ /// native support
96
+ import_meta_ponyfill_esmodule = (importMeta) => {
97
+ if (!shimWs.has(importMeta)) {
98
+ shimWs.add(importMeta);
99
+ commonShim(importMeta);
100
+ }
101
+ return importMeta;
102
+ };
103
+ }
104
+ return import_meta_ponyfill_esmodule(importMeta);
105
+ }));
106
+ defineGlobalPonyfill("import-meta-ponyfill-esmodule", import_meta_ponyfill_esmodule);
107
+ export let import_meta_ponyfill = ((...args) => {
108
+ const _MODULE = (() => {
109
+ if (typeof require === "function" && typeof module === "object") {
110
+ return "commonjs";
111
+ }
112
+ else {
113
+ // eval("typeof import.meta");
114
+ return "esmodule";
115
+ }
116
+ })();
117
+ if (_MODULE === "commonjs") {
118
+ //@ts-ignore
119
+ import_meta_ponyfill = (r, m) => import_meta_ponyfill_commonjs(r, m);
120
+ }
121
+ else {
122
+ //@ts-ignore
123
+ import_meta_ponyfill = (im) => import_meta_ponyfill_esmodule(im);
124
+ }
125
+ //@ts-ignore
126
+ return import_meta_ponyfill(...args);
127
+ });
@@ -7,7 +7,7 @@ export declare const DELIMITER: ";" | ":";
7
7
  * The character used to separate components of a file path.
8
8
  * On Windows, this is `\`. On all other platforms, this is `/`.
9
9
  */
10
- export declare const SEPARATOR: "\\" | "/";
10
+ export declare const SEPARATOR: "/" | "\\";
11
11
  /**
12
12
  * A regular expression that matches one or more path separators.
13
13
  */
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@std/path/1.1.4/posix/constants.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,SAAS,KAAe,CAAC;AACtC;;GAEG;AACH,eAAO,MAAM,SAAS,KAAe,CAAC;AACtC;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAAQ,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@std/path/1.1.4/posix/constants.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,SAAS,EAAG,GAAY,CAAC;AACtC;;GAEG;AACH,eAAO,MAAM,SAAS,EAAG,GAAY,CAAC;AACtC;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAAQ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@std/path/1.1.4/windows/constants.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,SAAS,KAAe,CAAC;AACtC;;GAEG;AACH,eAAO,MAAM,SAAS,MAAgB,CAAC;AACvC;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAAW,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@std/path/1.1.4/windows/constants.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,SAAS,EAAG,GAAY,CAAC;AACtC;;GAEG;AACH,eAAO,MAAM,SAAS,EAAG,IAAa,CAAC;AACvC;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAAW,CAAC"}