@veryfront/ext-content-mdx 0.1.1119 → 0.1.1122

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 (188) hide show
  1. package/esm/_dnt.polyfills.d.ts +6 -0
  2. package/esm/_dnt.polyfills.d.ts.map +1 -1
  3. package/esm/deno.js +1 -1
  4. package/esm/src/config/defaults.d.ts +39 -0
  5. package/esm/src/config/defaults.d.ts.map +1 -0
  6. package/esm/src/config/defaults.js +65 -0
  7. package/esm/src/errors/error-registry/agent.d.ts +18 -0
  8. package/esm/src/errors/error-registry/agent.d.ts.map +1 -0
  9. package/esm/src/errors/error-registry/agent.js +60 -0
  10. package/esm/src/errors/error-registry/boundary.d.ts +16 -0
  11. package/esm/src/errors/error-registry/boundary.d.ts.map +1 -0
  12. package/esm/src/errors/error-registry/boundary.js +52 -0
  13. package/esm/src/errors/error-registry/build.d.ts +20 -0
  14. package/esm/src/errors/error-registry/build.d.ts.map +1 -0
  15. package/esm/src/errors/error-registry/build.js +68 -0
  16. package/esm/src/errors/error-registry/config.d.ts +31 -0
  17. package/esm/src/errors/error-registry/config.d.ts.map +1 -0
  18. package/esm/src/errors/error-registry/config.js +97 -0
  19. package/esm/src/errors/error-registry/deploy.d.ts +12 -0
  20. package/esm/src/errors/error-registry/deploy.d.ts.map +1 -0
  21. package/esm/src/errors/error-registry/deploy.js +36 -0
  22. package/esm/src/errors/error-registry/dev.d.ts +14 -0
  23. package/esm/src/errors/error-registry/dev.d.ts.map +1 -0
  24. package/esm/src/errors/error-registry/dev.js +44 -0
  25. package/esm/src/errors/error-registry/general.d.ts +29 -0
  26. package/esm/src/errors/error-registry/general.d.ts.map +1 -0
  27. package/esm/src/errors/error-registry/general.js +92 -0
  28. package/esm/src/errors/error-registry/module.d.ts +16 -0
  29. package/esm/src/errors/error-registry/module.d.ts.map +1 -0
  30. package/esm/src/errors/error-registry/module.js +52 -0
  31. package/esm/src/errors/error-registry/route.d.ts +16 -0
  32. package/esm/src/errors/error-registry/route.d.ts.map +1 -0
  33. package/esm/src/errors/error-registry/route.js +52 -0
  34. package/esm/src/errors/error-registry/runtime.d.ts +27 -0
  35. package/esm/src/errors/error-registry/runtime.d.ts.map +1 -0
  36. package/esm/src/errors/error-registry/runtime.js +87 -0
  37. package/esm/src/errors/error-registry/server.d.ts +39 -0
  38. package/esm/src/errors/error-registry/server.d.ts.map +1 -0
  39. package/esm/src/errors/error-registry/server.js +129 -0
  40. package/esm/src/errors/error-registry-helpers.d.ts +6 -0
  41. package/esm/src/errors/error-registry-helpers.d.ts.map +1 -0
  42. package/esm/src/errors/error-registry-helpers.js +9 -0
  43. package/esm/src/errors/error-registry.d.ts +120 -0
  44. package/esm/src/errors/error-registry.d.ts.map +1 -0
  45. package/esm/src/errors/error-registry.js +60 -0
  46. package/esm/src/errors/types.d.ts +84 -0
  47. package/esm/src/errors/types.d.ts.map +1 -0
  48. package/esm/src/errors/types.js +69 -0
  49. package/esm/src/errors/veryfront-error.d.ts +149 -0
  50. package/esm/src/errors/veryfront-error.d.ts.map +1 -0
  51. package/esm/src/errors/veryfront-error.js +61 -0
  52. package/esm/src/modules/react-loader/ssr-module-loader/concurrency/semaphore.d.ts +13 -0
  53. package/esm/src/modules/react-loader/ssr-module-loader/concurrency/semaphore.d.ts.map +1 -0
  54. package/esm/src/modules/react-loader/ssr-module-loader/concurrency/semaphore.js +55 -0
  55. package/esm/src/observability/tracing/api-shim.d.ts +191 -0
  56. package/esm/src/observability/tracing/api-shim.d.ts.map +1 -0
  57. package/esm/src/observability/tracing/api-shim.js +281 -0
  58. package/esm/src/observability/tracing/otlp-setup.d.ts +63 -0
  59. package/esm/src/observability/tracing/otlp-setup.d.ts.map +1 -0
  60. package/esm/src/observability/tracing/otlp-setup.js +219 -0
  61. package/esm/src/observability/tracing/telemetry-env.d.ts +3 -0
  62. package/esm/src/observability/tracing/telemetry-env.d.ts.map +1 -0
  63. package/esm/src/observability/tracing/telemetry-env.js +10 -0
  64. package/esm/src/platform/adapters/base.d.ts +209 -0
  65. package/esm/src/platform/adapters/base.d.ts.map +1 -0
  66. package/esm/src/platform/adapters/base.js +15 -0
  67. package/esm/src/platform/compat/constants.d.ts +13 -0
  68. package/esm/src/platform/compat/constants.d.ts.map +1 -0
  69. package/esm/src/platform/compat/constants.js +12 -0
  70. package/esm/src/platform/compat/dynamic-import.d.ts +11 -0
  71. package/esm/src/platform/compat/dynamic-import.d.ts.map +1 -0
  72. package/esm/src/platform/compat/dynamic-import.js +10 -0
  73. package/esm/src/platform/compat/fs.d.ts +76 -0
  74. package/esm/src/platform/compat/fs.d.ts.map +1 -0
  75. package/esm/src/platform/compat/fs.js +336 -0
  76. package/esm/src/platform/compat/process/command.d.ts +33 -0
  77. package/esm/src/platform/compat/process/command.d.ts.map +1 -0
  78. package/esm/src/platform/compat/process/command.js +206 -0
  79. package/esm/src/platform/compat/process.d.ts +5 -0
  80. package/esm/src/platform/compat/process.d.ts.map +1 -0
  81. package/esm/src/platform/compat/process.js +4 -0
  82. package/esm/src/transforms/import-rewriter/url-builder.d.ts +70 -0
  83. package/esm/src/transforms/import-rewriter/url-builder.d.ts.map +1 -0
  84. package/esm/src/transforms/import-rewriter/url-builder.js +152 -0
  85. package/esm/src/transforms/mdx/compiler/import-rewriter.d.ts.map +1 -1
  86. package/esm/src/transforms/mdx/compiler/import-rewriter.js +2 -1
  87. package/esm/src/utils/base64url.d.ts +7 -0
  88. package/esm/src/utils/base64url.d.ts.map +1 -0
  89. package/esm/src/utils/base64url.js +39 -0
  90. package/esm/src/utils/bundle-manifest.d.ts +63 -0
  91. package/esm/src/utils/bundle-manifest.d.ts.map +1 -0
  92. package/esm/src/utils/bundle-manifest.js +96 -0
  93. package/esm/src/utils/constants/buffers.d.ts +24 -0
  94. package/esm/src/utils/constants/buffers.d.ts.map +1 -0
  95. package/esm/src/utils/constants/buffers.js +23 -0
  96. package/esm/src/utils/constants/build.d.ts +8 -0
  97. package/esm/src/utils/constants/build.d.ts.map +1 -0
  98. package/esm/src/utils/constants/build.js +7 -0
  99. package/esm/src/utils/constants/cache.d.ts +74 -0
  100. package/esm/src/utils/constants/cache.d.ts.map +1 -0
  101. package/esm/src/utils/constants/cache.js +133 -0
  102. package/esm/src/utils/constants/cdn.d.ts +29 -0
  103. package/esm/src/utils/constants/cdn.d.ts.map +1 -0
  104. package/esm/src/utils/constants/cdn.js +58 -0
  105. package/esm/src/utils/constants/crypto.d.ts +10 -0
  106. package/esm/src/utils/constants/crypto.d.ts.map +1 -0
  107. package/esm/src/utils/constants/crypto.js +9 -0
  108. package/esm/src/utils/constants/env.d.ts +16 -0
  109. package/esm/src/utils/constants/env.d.ts.map +1 -0
  110. package/esm/src/utils/constants/env.js +20 -0
  111. package/esm/src/utils/constants/hash.d.ts +5 -0
  112. package/esm/src/utils/constants/hash.d.ts.map +1 -0
  113. package/esm/src/utils/constants/hash.js +4 -0
  114. package/esm/src/utils/constants/hmr.d.ts +24 -0
  115. package/esm/src/utils/constants/hmr.d.ts.map +1 -0
  116. package/esm/src/utils/constants/hmr.js +26 -0
  117. package/esm/src/utils/constants/html.d.ts +13 -0
  118. package/esm/src/utils/constants/html.d.ts.map +1 -0
  119. package/esm/src/utils/constants/html.js +12 -0
  120. package/esm/src/utils/constants/http.d.ts +77 -0
  121. package/esm/src/utils/constants/http.d.ts.map +1 -0
  122. package/esm/src/utils/constants/http.js +76 -0
  123. package/esm/src/utils/constants/index.d.ts +23 -0
  124. package/esm/src/utils/constants/index.d.ts.map +1 -0
  125. package/esm/src/utils/constants/index.js +22 -0
  126. package/esm/src/utils/constants/limits.d.ts +27 -0
  127. package/esm/src/utils/constants/limits.d.ts.map +1 -0
  128. package/esm/src/utils/constants/limits.js +26 -0
  129. package/esm/src/utils/constants/metrics.d.ts +10 -0
  130. package/esm/src/utils/constants/metrics.d.ts.map +1 -0
  131. package/esm/src/utils/constants/metrics.js +34 -0
  132. package/esm/src/utils/constants/network.d.ts +23 -0
  133. package/esm/src/utils/constants/network.d.ts.map +1 -0
  134. package/esm/src/utils/constants/network.js +27 -0
  135. package/esm/src/utils/constants/priorities.d.ts +31 -0
  136. package/esm/src/utils/constants/priorities.d.ts.map +1 -0
  137. package/esm/src/utils/constants/priorities.js +30 -0
  138. package/esm/src/utils/constants/retry.d.ts +14 -0
  139. package/esm/src/utils/constants/retry.d.ts.map +1 -0
  140. package/esm/src/utils/constants/retry.js +13 -0
  141. package/esm/src/utils/constants/server.d.ts +107 -0
  142. package/esm/src/utils/constants/server.d.ts.map +1 -0
  143. package/esm/src/utils/constants/server.js +120 -0
  144. package/esm/src/utils/feature-flags.d.ts +7 -0
  145. package/esm/src/utils/feature-flags.d.ts.map +1 -0
  146. package/esm/src/utils/feature-flags.js +8 -0
  147. package/esm/src/utils/hash-utils.d.ts +22 -0
  148. package/esm/src/utils/hash-utils.d.ts.map +1 -0
  149. package/esm/src/utils/hash-utils.js +48 -0
  150. package/esm/src/utils/import-lockfile.d.ts +52 -0
  151. package/esm/src/utils/import-lockfile.d.ts.map +1 -0
  152. package/esm/src/utils/import-lockfile.js +187 -0
  153. package/esm/src/utils/index.d.ts +30 -0
  154. package/esm/src/utils/index.d.ts.map +1 -0
  155. package/esm/src/utils/index.js +29 -0
  156. package/esm/src/utils/logger/components.d.ts +73 -0
  157. package/esm/src/utils/logger/components.d.ts.map +1 -0
  158. package/esm/src/utils/logger/components.js +81 -0
  159. package/esm/src/utils/logger/index.d.ts +10 -0
  160. package/esm/src/utils/logger/index.d.ts.map +1 -0
  161. package/esm/src/utils/logger/index.js +9 -0
  162. package/esm/src/utils/logger/request-context.d.ts +27 -0
  163. package/esm/src/utils/logger/request-context.d.ts.map +1 -0
  164. package/esm/src/utils/logger/request-context.js +28 -0
  165. package/esm/src/utils/memoize.d.ts +19 -0
  166. package/esm/src/utils/memoize.d.ts.map +1 -0
  167. package/esm/src/utils/memoize.js +72 -0
  168. package/esm/src/utils/parallel.d.ts +21 -0
  169. package/esm/src/utils/parallel.d.ts.map +1 -0
  170. package/esm/src/utils/parallel.js +51 -0
  171. package/esm/src/utils/path-utils.d.ts +34 -0
  172. package/esm/src/utils/path-utils.d.ts.map +1 -0
  173. package/esm/src/utils/path-utils.js +138 -0
  174. package/esm/src/utils/perf-timer.d.ts +11 -0
  175. package/esm/src/utils/perf-timer.d.ts.map +1 -0
  176. package/esm/src/utils/perf-timer.js +114 -0
  177. package/esm/src/utils/platform.d.ts +9 -0
  178. package/esm/src/utils/platform.d.ts.map +1 -0
  179. package/esm/src/utils/platform.js +11 -0
  180. package/esm/src/utils/runtime-guards.d.ts +29 -0
  181. package/esm/src/utils/runtime-guards.d.ts.map +1 -0
  182. package/esm/src/utils/runtime-guards.js +23 -0
  183. package/esm/src/utils/sleep.d.ts +2 -0
  184. package/esm/src/utils/sleep.d.ts.map +1 -0
  185. package/esm/src/utils/sleep.js +19 -0
  186. package/esm/src/utils/version-constant.d.ts +1 -1
  187. package/esm/src/utils/version-constant.js +1 -1
  188. package/package.json +2 -2
@@ -0,0 +1,336 @@
1
+ import * as dntShim from "../../../_dnt.shims.js";
2
+ import { createError, toError } from "../../errors/veryfront-error.js";
3
+ import { isBun, isDeno, isNode } from "./runtime.js";
4
+ /**
5
+ * Typed accessor for the Deno global.
6
+ *
7
+ * This is pure typing only — it reads no environment variables and performs no
8
+ * side effects, so this module stays importable without `--allow-env`. It
9
+ * exists to retire the `@ts-ignore` comments that were previously required to
10
+ * access `Deno.*` APIs from runtime-agnostic compat code.
11
+ */
12
+ function denoGlobal() {
13
+ return dntShim.dntGlobalThis.Deno;
14
+ }
15
+ class NodeFileSystem {
16
+ fs;
17
+ os;
18
+ path;
19
+ initialized = false;
20
+ async ensureInitialized() {
21
+ if (this.initialized)
22
+ return;
23
+ if (!isNode && !isBun) {
24
+ throw toError(createError({
25
+ type: "not_supported",
26
+ message: "Node.js fs modules not available",
27
+ feature: "Node.js",
28
+ }));
29
+ }
30
+ const [fsModule, osModule, pathModule] = await Promise.all([
31
+ import("node:fs/promises"),
32
+ import("node:os"),
33
+ import("node:path"),
34
+ ]);
35
+ this.fs = fsModule;
36
+ this.os = osModule;
37
+ this.path = pathModule;
38
+ this.initialized = true;
39
+ }
40
+ getFs() {
41
+ if (!this.fs)
42
+ throw new Error("NodeFileSystem not initialized");
43
+ return this.fs;
44
+ }
45
+ getOs() {
46
+ if (!this.os)
47
+ throw new Error("NodeFileSystem not initialized");
48
+ return this.os;
49
+ }
50
+ getPath() {
51
+ if (!this.path)
52
+ throw new Error("NodeFileSystem not initialized");
53
+ return this.path;
54
+ }
55
+ async readTextFile(path) {
56
+ await this.ensureInitialized();
57
+ return this.getFs().readFile(path, { encoding: "utf8" });
58
+ }
59
+ async readFile(path) {
60
+ await this.ensureInitialized();
61
+ return this.getFs().readFile(path);
62
+ }
63
+ async writeTextFile(path, data) {
64
+ await this.ensureInitialized();
65
+ await this.getFs().writeFile(path, data, { encoding: "utf8" });
66
+ }
67
+ async writeFile(path, data) {
68
+ await this.ensureInitialized();
69
+ await this.getFs().writeFile(path, data);
70
+ }
71
+ async exists(path) {
72
+ await this.ensureInitialized();
73
+ try {
74
+ await this.getFs().access(path);
75
+ return true;
76
+ }
77
+ catch (error) {
78
+ if (error?.code === "ENOENT")
79
+ return false;
80
+ throw error;
81
+ }
82
+ }
83
+ async stat(path) {
84
+ await this.ensureInitialized();
85
+ const stat = await this.getFs().stat(path);
86
+ return {
87
+ isFile: stat.isFile(),
88
+ isDirectory: stat.isDirectory(),
89
+ isSymlink: stat.isSymbolicLink(),
90
+ size: stat.size,
91
+ mtime: stat.mtime,
92
+ };
93
+ }
94
+ async lstat(path) {
95
+ await this.ensureInitialized();
96
+ const stat = await this.getFs().lstat(path);
97
+ return {
98
+ isFile: stat.isFile(),
99
+ isDirectory: stat.isDirectory(),
100
+ isSymlink: stat.isSymbolicLink(),
101
+ size: stat.size,
102
+ mtime: stat.mtime,
103
+ };
104
+ }
105
+ async mkdir(path, options) {
106
+ await this.ensureInitialized();
107
+ await this.getFs().mkdir(path, { recursive: options?.recursive ?? false });
108
+ }
109
+ async *readDir(path) {
110
+ await this.ensureInitialized();
111
+ const entries = await this.getFs().readdir(path, { withFileTypes: true });
112
+ for (const entry of entries) {
113
+ yield {
114
+ name: entry.name,
115
+ isFile: entry.isFile(),
116
+ isDirectory: entry.isDirectory(),
117
+ isSymlink: entry.isSymbolicLink(),
118
+ };
119
+ }
120
+ }
121
+ async remove(path, options) {
122
+ await this.ensureInitialized();
123
+ const recursive = options?.recursive ?? false;
124
+ await this.getFs().rm(path, { recursive, force: recursive });
125
+ }
126
+ async makeTempDir(options) {
127
+ await this.ensureInitialized();
128
+ const tempDir = this.getPath().join(this.getOs().tmpdir(), `${options?.prefix ?? "tmp-"}${dntShim.crypto.randomUUID().slice(0, 8)}`);
129
+ await this.getFs().mkdir(tempDir, { recursive: true });
130
+ return tempDir;
131
+ }
132
+ async chmod(path, mode) {
133
+ await this.ensureInitialized();
134
+ try {
135
+ await this.getFs().chmod(path, mode);
136
+ }
137
+ catch {
138
+ // Ignore errors on Windows where chmod is not fully supported.
139
+ // Intentionally not logged: this low-level compat module must stay
140
+ // importable without `--allow-env` (the logger reads env at import).
141
+ }
142
+ }
143
+ }
144
+ class DenoFileSystem {
145
+ readTextFile(path) {
146
+ return denoGlobal().readTextFile(path);
147
+ }
148
+ readFile(path) {
149
+ return denoGlobal().readFile(path);
150
+ }
151
+ async writeTextFile(path, data) {
152
+ await denoGlobal().writeTextFile(path, data);
153
+ }
154
+ async writeFile(path, data) {
155
+ await denoGlobal().writeFile(path, data);
156
+ }
157
+ async exists(path) {
158
+ try {
159
+ await denoGlobal().stat(path);
160
+ return true;
161
+ }
162
+ catch (error) {
163
+ if (error instanceof denoGlobal().errors.NotFound)
164
+ return false;
165
+ throw error;
166
+ }
167
+ }
168
+ async stat(path) {
169
+ const stat = await denoGlobal().stat(path);
170
+ return {
171
+ isFile: stat.isFile,
172
+ isDirectory: stat.isDirectory,
173
+ isSymlink: stat.isSymlink,
174
+ size: stat.size,
175
+ mtime: stat.mtime,
176
+ };
177
+ }
178
+ async lstat(path) {
179
+ const stat = await denoGlobal().lstat(path);
180
+ return {
181
+ isFile: stat.isFile,
182
+ isDirectory: stat.isDirectory,
183
+ isSymlink: stat.isSymlink,
184
+ size: stat.size,
185
+ mtime: stat.mtime,
186
+ };
187
+ }
188
+ async mkdir(path, options) {
189
+ await denoGlobal().mkdir(path, { recursive: options?.recursive ?? false });
190
+ }
191
+ async *readDir(path) {
192
+ for await (const entry of denoGlobal().readDir(path)) {
193
+ yield {
194
+ name: entry.name,
195
+ isFile: entry.isFile,
196
+ isDirectory: entry.isDirectory,
197
+ isSymlink: entry.isSymlink,
198
+ };
199
+ }
200
+ }
201
+ async remove(path, options) {
202
+ await denoGlobal().remove(path, { recursive: options?.recursive ?? false });
203
+ }
204
+ makeTempDir(options) {
205
+ return denoGlobal().makeTempDir({ prefix: options?.prefix });
206
+ }
207
+ async chmod(path, mode) {
208
+ try {
209
+ await denoGlobal().chmod(path, mode);
210
+ }
211
+ catch (_) {
212
+ /* expected: chmod is not fully supported on Windows */
213
+ }
214
+ }
215
+ }
216
+ /** Create file system. */
217
+ export function createFileSystem() {
218
+ return isDeno ? new DenoFileSystem() : new NodeFileSystem();
219
+ }
220
+ let _fs = null;
221
+ function getFs() {
222
+ _fs ??= createFileSystem();
223
+ return _fs;
224
+ }
225
+ /** Read a file as text. */
226
+ export function readTextFile(path) {
227
+ return getFs().readTextFile(path);
228
+ }
229
+ /** Read a file as bytes. */
230
+ export function readFile(path) {
231
+ return getFs().readFile(path);
232
+ }
233
+ /** Write text to a file. */
234
+ export function writeTextFile(path, data) {
235
+ return getFs().writeTextFile(path, data);
236
+ }
237
+ /** Write bytes to a file. */
238
+ export function writeFile(path, data) {
239
+ return getFs().writeFile(path, data);
240
+ }
241
+ /** Check whether a path exists. */
242
+ export function exists(path) {
243
+ return getFs().exists(path);
244
+ }
245
+ /** Read file metadata. */
246
+ export function stat(path) {
247
+ return getFs().stat(path);
248
+ }
249
+ /** Read file metadata without following a terminal symbolic link. */
250
+ export async function lstat(path) {
251
+ if (isDeno) {
252
+ const info = await denoGlobal().lstat(path);
253
+ return {
254
+ isFile: info.isFile,
255
+ isDirectory: info.isDirectory,
256
+ isSymlink: info.isSymlink,
257
+ size: info.size,
258
+ mtime: info.mtime,
259
+ };
260
+ }
261
+ const fs = await import("node:fs/promises");
262
+ const info = await fs.lstat(path);
263
+ return {
264
+ isFile: info.isFile(),
265
+ isDirectory: info.isDirectory(),
266
+ isSymlink: info.isSymbolicLink(),
267
+ size: info.size,
268
+ mtime: info.mtime,
269
+ };
270
+ }
271
+ /** Create a directory. */
272
+ export function mkdir(path, options) {
273
+ return getFs().mkdir(path, options);
274
+ }
275
+ /** Remove a file or directory. */
276
+ export function remove(path, options) {
277
+ return getFs().remove(path, options);
278
+ }
279
+ /** Read directory entries. */
280
+ export function readDir(path) {
281
+ return getFs().readDir(path);
282
+ }
283
+ /** Create temp dir. */
284
+ export function makeTempDir(options) {
285
+ return getFs().makeTempDir(options);
286
+ }
287
+ /** Change file permissions. */
288
+ export function chmod(path, mode) {
289
+ return getFs().chmod(path, mode);
290
+ }
291
+ export async function symlink(target, path) {
292
+ if (isDeno) {
293
+ await denoGlobal().symlink(target, path);
294
+ return;
295
+ }
296
+ const fs = await import("node:fs/promises");
297
+ await fs.symlink(target, path);
298
+ }
299
+ /**
300
+ * Resolve a path to its canonical absolute form, following symlinks.
301
+ * Throws if the path does not exist. Useful for containment checks where a
302
+ * symlink could otherwise escape an intended directory.
303
+ */
304
+ export async function realPath(path) {
305
+ if (isDeno) {
306
+ return await denoGlobal().realPath(path);
307
+ }
308
+ const fs = await import("node:fs/promises");
309
+ return await fs.realpath(path);
310
+ }
311
+ /** Error shape for is not found. */
312
+ export function isNotFoundError(error, seen = new Set()) {
313
+ if (seen.has(error))
314
+ return false;
315
+ seen.add(error);
316
+ const NotFound = dntShim.dntGlobalThis.Deno?.errors?.NotFound;
317
+ if (isDeno && NotFound && error instanceof NotFound)
318
+ return true;
319
+ if (error?.code === "ENOENT")
320
+ return true;
321
+ if (error instanceof Error && error.name === "VeryfrontError" &&
322
+ error.slug === "file-not-found") {
323
+ return true;
324
+ }
325
+ if (error instanceof Error && "cause" in error) {
326
+ return isNotFoundError(error.cause, seen);
327
+ }
328
+ return false;
329
+ }
330
+ /** Error shape for is already exists. */
331
+ export function isAlreadyExistsError(error) {
332
+ const AlreadyExists = dntShim.dntGlobalThis.Deno?.errors?.AlreadyExists;
333
+ if (isDeno && AlreadyExists && error instanceof AlreadyExists)
334
+ return true;
335
+ return error?.code === "EEXIST";
336
+ }
@@ -0,0 +1,33 @@
1
+ export interface CommandResult {
2
+ success: boolean;
3
+ code: number;
4
+ stdout?: string;
5
+ stderr?: string;
6
+ }
7
+ export interface CommandOptions {
8
+ args?: string[];
9
+ cwd?: string;
10
+ env?: Record<string, string>;
11
+ /** Start from an empty environment before applying `env`. */
12
+ clearEnv?: boolean;
13
+ /** Capture stdout/stderr to return in result */
14
+ capture?: boolean;
15
+ /** Inherit stdio from parent process (shows output in terminal) */
16
+ inherit?: boolean;
17
+ /** Use shell to run the command (needed for .cmd files on Windows) */
18
+ shell?: boolean;
19
+ /** Kill the command if it exceeds this duration (milliseconds) */
20
+ timeoutMs?: number;
21
+ }
22
+ /**
23
+ * Run a command and return the result.
24
+ * Works across Deno, Node.js, and Bun.
25
+ *
26
+ * @param cmd - Command to run
27
+ * @param options - Command options
28
+ * @param options.capture - Capture stdout/stderr to return in result
29
+ * @param options.inherit - Inherit stdio from parent (shows output in terminal)
30
+ * @param options.shell - Use shell to run command (needed for .cmd on Windows)
31
+ */
32
+ export declare function runCommand(cmd: string, options?: CommandOptions): Promise<CommandResult>;
33
+ //# sourceMappingURL=command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../../src/src/platform/compat/process/command.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gDAAgD;IAChD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mEAAmE;IACnE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,sEAAsE;IACtE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA6ED;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAC9B,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,aAAa,CAAC,CAoMxB"}
@@ -0,0 +1,206 @@
1
+ import * as dntShim from "../../../../_dnt.shims.js";
2
+ import { dynamicImport } from "../dynamic-import.js";
3
+ import { getDenoRuntime, isBun as IS_BUN, isDeno as IS_DENO } from "../runtime.js";
4
+ import { isWindowsPlatform, runtimeProcess } from "./runtime-process.js";
5
+ const COMMAND_TIMEOUT_EXIT_CODE = 124;
6
+ const FORCE_KILL_GRACE_MS = 250;
7
+ function createTimeoutResult(timeoutMs, stdout, stderr) {
8
+ return {
9
+ success: false,
10
+ code: COMMAND_TIMEOUT_EXIT_CODE,
11
+ stdout,
12
+ stderr: `${stderr ?? ""}\nCommand timed out after ${timeoutMs}ms`.trim(),
13
+ };
14
+ }
15
+ function createProcessTimeout(timeoutMs, terminate, forceTerminate) {
16
+ let timedOut = false;
17
+ let timeoutId;
18
+ let forceKillId;
19
+ if (timeoutMs && timeoutMs > 0) {
20
+ timeoutId = dntShim.setTimeout(() => {
21
+ timedOut = true;
22
+ try {
23
+ terminate();
24
+ }
25
+ catch (_) {
26
+ /* expected: best-effort terminate may fail if process already exited */
27
+ }
28
+ forceKillId = dntShim.setTimeout(() => {
29
+ try {
30
+ forceTerminate();
31
+ }
32
+ catch (_) {
33
+ /* expected: best-effort force terminate may fail if process already exited */
34
+ }
35
+ }, FORCE_KILL_GRACE_MS);
36
+ }, timeoutMs);
37
+ }
38
+ return {
39
+ hasTimedOut: () => timedOut,
40
+ clear: () => {
41
+ if (timeoutId)
42
+ clearTimeout(timeoutId);
43
+ if (forceKillId)
44
+ clearTimeout(forceKillId);
45
+ },
46
+ };
47
+ }
48
+ async function readStreamToString(stream) {
49
+ const reader = stream.getReader();
50
+ const chunks = [];
51
+ while (true) {
52
+ const { done, value } = await reader.read();
53
+ if (done)
54
+ break;
55
+ if (value)
56
+ chunks.push(value);
57
+ }
58
+ const total = chunks.reduce((acc, c) => acc + c.length, 0);
59
+ const merged = new Uint8Array(total);
60
+ let offset = 0;
61
+ for (const chunk of chunks) {
62
+ merged.set(chunk, offset);
63
+ offset += chunk.length;
64
+ }
65
+ return new TextDecoder().decode(merged);
66
+ }
67
+ /**
68
+ * Run a command and return the result.
69
+ * Works across Deno, Node.js, and Bun.
70
+ *
71
+ * @param cmd - Command to run
72
+ * @param options - Command options
73
+ * @param options.capture - Capture stdout/stderr to return in result
74
+ * @param options.inherit - Inherit stdio from parent (shows output in terminal)
75
+ * @param options.shell - Use shell to run command (needed for .cmd on Windows)
76
+ */
77
+ export async function runCommand(cmd, options = {}) {
78
+ const { args = [], cwd: cmdCwd, env: cmdEnv, clearEnv = false, capture = false, inherit = false, shell = false, timeoutMs, } = options;
79
+ const effectiveTimeoutMs = timeoutMs && timeoutMs > 0 ? Math.floor(timeoutMs) : undefined;
80
+ // Determine stdio mode: inherit > capture > null
81
+ const stdioMode = inherit ? "inherit" : capture ? "piped" : "null";
82
+ const deno = IS_DENO ? getDenoRuntime() : undefined;
83
+ if (deno) {
84
+ const command = new deno.Command(cmd, {
85
+ args,
86
+ cwd: cmdCwd,
87
+ env: cmdEnv,
88
+ clearEnv,
89
+ stdin: inherit ? "inherit" : "null",
90
+ stdout: stdioMode,
91
+ stderr: stdioMode,
92
+ });
93
+ const child = command.spawn();
94
+ const timeout = createProcessTimeout(effectiveTimeoutMs, () => child.kill("SIGTERM"), () => child.kill("SIGKILL"));
95
+ try {
96
+ const [status, stdout, stderr] = await Promise.all([
97
+ child.status,
98
+ capture && child.stdout ? readStreamToString(child.stdout) : Promise.resolve(undefined),
99
+ capture && child.stderr ? readStreamToString(child.stderr) : Promise.resolve(undefined),
100
+ ]);
101
+ if (timeout.hasTimedOut()) {
102
+ return createTimeoutResult(effectiveTimeoutMs ?? 0, stdout, stderr);
103
+ }
104
+ return {
105
+ success: status.success,
106
+ code: status.code,
107
+ stdout,
108
+ stderr,
109
+ };
110
+ }
111
+ finally {
112
+ timeout.clear();
113
+ }
114
+ }
115
+ if (IS_BUN) {
116
+ const bunGlobal = dntShim.dntGlobalThis;
117
+ const bunStdio = inherit ? "inherit" : capture ? "pipe" : "ignore";
118
+ const isWindows = isWindowsPlatform();
119
+ const bunCmd = shell
120
+ ? args.length === 0
121
+ ? isWindows ? ["cmd", "/c", cmd] : ["sh", "-c", cmd]
122
+ : isWindows
123
+ ? ["cmd", "/c", cmd, ...args]
124
+ : ["sh", "-c", 'exec "$@"', "sh", cmd, ...args]
125
+ : [cmd, ...args];
126
+ const proc = bunGlobal.Bun.spawn({
127
+ cmd: bunCmd,
128
+ cwd: cmdCwd,
129
+ env: clearEnv ? cmdEnv ?? {} : cmdEnv,
130
+ stdout: bunStdio,
131
+ stderr: bunStdio,
132
+ });
133
+ const timeout = createProcessTimeout(effectiveTimeoutMs, () => proc.kill?.("SIGTERM"), () => proc.kill?.("SIGKILL"));
134
+ try {
135
+ const [code, stdout, stderr] = await Promise.all([
136
+ proc.exited,
137
+ capture && proc.stdout ? readStreamToString(proc.stdout) : Promise.resolve(undefined),
138
+ capture && proc.stderr ? readStreamToString(proc.stderr) : Promise.resolve(undefined),
139
+ ]);
140
+ if (timeout.hasTimedOut()) {
141
+ return createTimeoutResult(effectiveTimeoutMs ?? 0, stdout, stderr);
142
+ }
143
+ return { success: code === 0, code, stdout, stderr };
144
+ }
145
+ finally {
146
+ timeout.clear();
147
+ }
148
+ }
149
+ if (!runtimeProcess)
150
+ return { success: false, code: 1 };
151
+ const process = runtimeProcess;
152
+ const { spawn } = await dynamicImport("node:child_process");
153
+ const nodeStdio = inherit
154
+ ? ["inherit", "inherit", "inherit"]
155
+ : capture
156
+ ? ["ignore", "pipe", "pipe"]
157
+ : ["ignore", "ignore", "ignore"];
158
+ return await new Promise((resolve) => {
159
+ const child = spawn(cmd, args, {
160
+ cwd: cmdCwd,
161
+ env: clearEnv ? cmdEnv ?? {} : cmdEnv ? { ...process.env, ...cmdEnv } : undefined,
162
+ stdio: nodeStdio,
163
+ shell,
164
+ });
165
+ let stdout = "";
166
+ let stderr = "";
167
+ const decoder = new TextDecoder();
168
+ const timeout = createProcessTimeout(effectiveTimeoutMs, () => child.kill("SIGTERM"), () => child.kill("SIGKILL"));
169
+ if (capture) {
170
+ child.stdout?.on("data", (data) => {
171
+ stdout += decoder.decode(data);
172
+ });
173
+ child.stderr?.on("data", (data) => {
174
+ stderr += decoder.decode(data);
175
+ });
176
+ }
177
+ child.on("close", (code) => {
178
+ timeout.clear();
179
+ if (timeout.hasTimedOut()) {
180
+ resolve(createTimeoutResult(effectiveTimeoutMs ?? 0, capture ? stdout : undefined, capture ? stderr : undefined));
181
+ return;
182
+ }
183
+ resolve({
184
+ success: code === 0,
185
+ code: code ?? 1,
186
+ stdout: capture ? stdout : undefined,
187
+ stderr: capture ? stderr : undefined,
188
+ });
189
+ });
190
+ child.on("error", (spawnError) => {
191
+ timeout.clear();
192
+ // Include the spawn error message so callers can distinguish ENOENT
193
+ // ("command not found"), EACCES ("permission denied"), etc.
194
+ resolve({
195
+ success: false,
196
+ code: 1,
197
+ stdout: capture ? stdout : undefined,
198
+ stderr: capture
199
+ ? (stderr
200
+ ? `${stderr}\nSpawn error: ${spawnError.message}`
201
+ : `Spawn error: ${spawnError.message}`)
202
+ : undefined,
203
+ });
204
+ });
205
+ });
206
+ }
@@ -0,0 +1,5 @@
1
+ export { deleteEnv, env, type EnvBooleanOptions, getEnv, getEnvBoolean, getEnvNumber, getEnvOverlayStorage, getEnvString, getHostEnv, setEnv, } from "./process/env.js";
2
+ export { chdir, cwd, execPath, exit, getArgs, getOsType, getRuntimeVersion, getStdout, getTerminalSize, isInteractive, isStdoutTTY, memoryUsage, onGlobalError, onSignal, pid, promptSync, readStdinByteSync, unrefTimer, uptime, writeStdout, writeStdoutAsync, } from "./process/lifecycle.js";
3
+ export { testHasRuntimeProcess } from "./process/runtime-process.js";
4
+ export { type CommandOptions, type CommandResult, runCommand } from "./process/command.js";
5
+ //# sourceMappingURL=process.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../../../src/src/platform/compat/process.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,GAAG,EACH,KAAK,iBAAiB,EACtB,MAAM,EACN,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,YAAY,EACZ,UAAU,EACV,MAAM,GACP,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,KAAK,EACL,GAAG,EACH,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,SAAS,EACT,iBAAiB,EACjB,SAAS,EACT,eAAe,EACf,aAAa,EACb,WAAW,EACX,WAAW,EACX,aAAa,EACb,QAAQ,EACR,GAAG,EACH,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,MAAM,EACN,WAAW,EACX,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { deleteEnv, env, getEnv, getEnvBoolean, getEnvNumber, getEnvOverlayStorage, getEnvString, getHostEnv, setEnv, } from "./process/env.js";
2
+ export { chdir, cwd, execPath, exit, getArgs, getOsType, getRuntimeVersion, getStdout, getTerminalSize, isInteractive, isStdoutTTY, memoryUsage, onGlobalError, onSignal, pid, promptSync, readStdinByteSync, unrefTimer, uptime, writeStdout, writeStdoutAsync, } from "./process/lifecycle.js";
3
+ export { testHasRuntimeProcess } from "./process/runtime-process.js";
4
+ export { runCommand } from "./process/command.js";
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Canonical URL builders for import rewriting.
3
+ *
4
+ * Single source of truth for all URL generation.
5
+ * Ensures consistent URLs across SSR and browser for hydration parity.
6
+ */
7
+ /**
8
+ * Default React version - used when not specified.
9
+ *
10
+ * MUST match the React version the build bundles (see `react/deno.json`),
11
+ * because veryfront's framework React re-export is generated against that
12
+ * version and references its named exports. A drift guard in
13
+ * `src/utils/constants/cdn.test.ts` enforces this.
14
+ */
15
+ export declare const DEFAULT_REACT_VERSION = "19.2.4";
16
+ /** Tailwind CSS version */
17
+ export declare const TAILWIND_VERSION = "4.1.8";
18
+ /** csstype version - must match deno.json for type consistency */
19
+ export declare const CSSTYPE_VERSION = "3.2.3";
20
+ type EsmShOptions = {
21
+ external?: string[];
22
+ target?: string;
23
+ deps?: Record<string, string>;
24
+ };
25
+ /**
26
+ * Build esm.sh URL with proper configuration.
27
+ *
28
+ * @param pkg - Package name (e.g., "react", "lodash")
29
+ * @param version - Package version (optional)
30
+ * @param subpath - Subpath (e.g., "/jsx-runtime")
31
+ * @param options - URL options
32
+ */
33
+ export declare function buildEsmShUrl(pkg: string, version?: string, subpath?: string, options?: EsmShOptions): string;
34
+ /**
35
+ * Build React esm.sh URL.
36
+ * Uses deps=csstype for type consistency.
37
+ */
38
+ export declare function buildReactUrl(pkg: "react" | "react-dom", version: string, subpath?: string, external?: boolean): string;
39
+ /**
40
+ * Get complete React import map for a specific version.
41
+ */
42
+ export declare function getReactImportMap(version: string): Record<string, string>;
43
+ /**
44
+ * Build module server URL for a path.
45
+ */
46
+ export declare function buildModuleServerUrl(baseUrl: string, path: string): string;
47
+ /**
48
+ * Build cross-project import URL.
49
+ */
50
+ export declare function buildCrossProjectUrl(projectSlug: string, version: string | null, path: string): string;
51
+ /**
52
+ * Build veryfront framework module URL.
53
+ */
54
+ export declare function buildVeryfrontModuleUrl(path: string): string;
55
+ /**
56
+ * Normalize file extension for JavaScript output.
57
+ */
58
+ export declare function normalizeExtension(path: string, options?: {
59
+ removeExtension?: boolean;
60
+ }): string;
61
+ /**
62
+ * Check if a URL is an esm.sh URL.
63
+ */
64
+ export declare function isEsmShUrl(url: string): boolean;
65
+ /**
66
+ * Add deps query param to esm.sh URL if not already present.
67
+ */
68
+ export declare function addEsmShDeps(url: string, reactVersion: string): string;
69
+ export {};
70
+ //# sourceMappingURL=url-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-builder.d.ts","sourceRoot":"","sources":["../../../../src/src/transforms/import-rewriter/url-builder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAE9C,2BAA2B;AAC3B,eAAO,MAAM,gBAAgB,UAAU,CAAC;AAExC,kEAAkE;AAClE,eAAO,MAAM,eAAe,UAAU,CAAC;AAEvC,KAAK,YAAY,GAAG;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,YAAY,GACrB,MAAM,CAqBR;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,OAAO,GAAG,WAAW,EAC1B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,EAChB,QAAQ,UAAQ,GACf,MAAM,CAKR;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAWzE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAI1E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,IAAI,EAAE,MAAM,GACX,MAAM,CAIR;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG5D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CAGhG;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE/C;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAgDtE"}