elit 3.6.5 → 3.6.7
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.
- package/Cargo.lock +1 -1
- package/Cargo.toml +1 -1
- package/README.md +6 -0
- package/dist/build.cjs +421 -331
- package/dist/build.d.ts +1 -16
- package/dist/build.js +420 -330
- package/dist/build.mjs +420 -330
- package/dist/chokidar.cjs +219 -182
- package/dist/chokidar.d.ts +25 -10
- package/dist/chokidar.js +217 -182
- package/dist/chokidar.mjs +218 -183
- package/dist/cli.cjs +21608 -20241
- package/dist/cli.d.ts +19 -37
- package/dist/cli.mjs +21262 -19910
- package/dist/config.cjs +357 -350
- package/dist/config.d.ts +19 -240
- package/dist/config.js +520 -515
- package/dist/config.mjs +346 -341
- package/dist/contracts-BeW9k0yZ.d.ts +54 -0
- package/dist/contracts-D7KIS-TK.d.ts +36 -0
- package/dist/coverage.cjs +448 -485
- package/dist/coverage.d.ts +13 -59
- package/dist/coverage.js +447 -484
- package/dist/coverage.mjs +447 -484
- package/dist/database.cjs +819 -828
- package/dist/database.d.ts +8 -24
- package/dist/database.js +818 -829
- package/dist/database.mjs +818 -829
- package/dist/desktop-auto-render.cjs +1700 -1522
- package/dist/desktop-auto-render.d.ts +4 -9
- package/dist/desktop-auto-render.js +1695 -1517
- package/dist/desktop-auto-render.mjs +1696 -1518
- package/dist/desktop.cjs +3 -1
- package/dist/desktop.d.ts +4 -1
- package/dist/desktop.js +1 -1
- package/dist/desktop.mjs +1 -1
- package/dist/dev-build.cjs +830 -0
- package/dist/dev-build.d.ts +53 -0
- package/dist/dev-build.js +3318 -0
- package/dist/dev-build.mjs +797 -0
- package/dist/dom.cjs +717 -590
- package/dist/dom.d.ts +2 -15
- package/dist/dom.js +714 -587
- package/dist/dom.mjs +716 -589
- package/dist/el.cjs +62 -52
- package/dist/el.d.ts +5 -10
- package/dist/el.js +60 -52
- package/dist/el.mjs +60 -52
- package/dist/fs.cjs +72 -63
- package/dist/fs.d.ts +22 -19
- package/dist/fs.js +71 -62
- package/dist/fs.mjs +71 -62
- package/dist/hmr.cjs +40 -14
- package/dist/hmr.d.ts +11 -23
- package/dist/hmr.js +38 -14
- package/dist/hmr.mjs +38 -14
- package/dist/http.cjs +251 -99
- package/dist/http.d.ts +38 -104
- package/dist/http.js +249 -99
- package/dist/http.mjs +249 -99
- package/dist/https.cjs +524 -228
- package/dist/https.d.ts +44 -36
- package/dist/https.js +520 -226
- package/dist/https.mjs +522 -228
- package/dist/index.cjs +7502 -7690
- package/dist/index.d.ts +8 -3
- package/dist/index.js +7486 -7676
- package/dist/index.mjs +7497 -7686
- package/dist/mime-types.cjs +10 -4
- package/dist/mime-types.d.ts +8 -11
- package/dist/mime-types.js +9 -3
- package/dist/mime-types.mjs +9 -3
- package/dist/native.cjs +8616 -8869
- package/dist/native.d.ts +7 -8
- package/dist/native.js +8682 -8935
- package/dist/native.mjs +8615 -8868
- package/dist/path.cjs +83 -77
- package/dist/path.d.ts +29 -29
- package/dist/path.js +82 -76
- package/dist/path.mjs +82 -76
- package/dist/pm.cjs +3300 -0
- package/dist/pm.d.ts +256 -0
- package/dist/pm.js +5638 -0
- package/dist/pm.mjs +3196 -0
- package/dist/preview-build.cjs +712 -0
- package/dist/preview-build.d.ts +59 -0
- package/dist/preview-build.js +3194 -0
- package/dist/preview-build.mjs +676 -0
- package/dist/render-context.cjs +13 -2
- package/dist/render-context.d.ts +9 -31
- package/dist/render-context.js +11 -2
- package/dist/render-context.mjs +11 -2
- package/dist/router.cjs +787 -645
- package/dist/router.d.ts +8 -12
- package/dist/router.js +786 -644
- package/dist/router.mjs +786 -644
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.js +1 -1
- package/dist/runtime.mjs +1 -1
- package/dist/server.cjs +3315 -2603
- package/dist/server.d.ts +49 -4
- package/dist/server.js +7611 -2834
- package/dist/server.mjs +3317 -2607
- package/dist/smtp-server.cjs +128 -0
- package/dist/smtp-server.d.ts +27 -0
- package/dist/smtp-server.js +4199 -0
- package/dist/smtp-server.mjs +100 -0
- package/dist/state-DvEkDehk.d.ts +195 -0
- package/dist/state.cjs +768 -658
- package/dist/state.d.ts +11 -69
- package/dist/state.js +760 -650
- package/dist/state.mjs +767 -657
- package/dist/style.cjs +1011 -968
- package/dist/style.d.ts +13 -127
- package/dist/style.js +1009 -970
- package/dist/style.mjs +1011 -971
- package/dist/test-reporter.cjs +332 -316
- package/dist/test-reporter.d.ts +28 -33
- package/dist/test-reporter.js +328 -312
- package/dist/test-reporter.mjs +328 -312
- package/dist/test-runtime.cjs +927 -968
- package/dist/test-runtime.d.ts +24 -99
- package/dist/test-runtime.js +922 -965
- package/dist/test-runtime.mjs +922 -965
- package/dist/test.cjs +4428 -4273
- package/dist/test.d.ts +2 -8
- package/dist/test.js +4307 -4154
- package/dist/test.mjs +4419 -4267
- package/dist/types-BONVzPtp.d.ts +59 -0
- package/dist/types-BR4wMiVx.d.ts +32 -0
- package/dist/types-C4gKykuG.d.ts +23 -0
- package/dist/types-CIhpN1-K.d.ts +64 -0
- package/dist/types-Ckj8md_j.d.ts +84 -0
- package/dist/types-CpjQTAkX.d.ts +24 -0
- package/dist/types-D0LjrYjS.d.ts +14 -0
- package/dist/types-DAisuVr5.d.ts +75 -0
- package/dist/types-tJn88E1N.d.ts +242 -0
- package/dist/types.d.ts +71 -226
- package/dist/universal.cjs +1 -1
- package/dist/universal.d.ts +1 -5
- package/dist/universal.js +1 -1
- package/dist/universal.mjs +1 -1
- package/dist/websocket-XfyK23zD.d.ts +119 -0
- package/dist/ws.cjs +129 -108
- package/dist/ws.d.ts +21 -131
- package/dist/ws.js +128 -109
- package/dist/ws.mjs +128 -109
- package/dist/wss.cjs +757 -479
- package/dist/wss.d.ts +31 -28
- package/dist/wss.js +755 -479
- package/dist/wss.mjs +758 -482
- package/package.json +16 -1
- package/vendor/epaint-0.31.1/src/image.rs +418 -0
- package/dist/server-CcBFc2F5.d.ts +0 -449
package/dist/config.mjs
CHANGED
|
@@ -15,10 +15,10 @@ var __export = (target, all) => {
|
|
|
15
15
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
// src/runtime.ts
|
|
18
|
+
// src/shares/runtime.ts
|
|
19
19
|
var runtime, isNode, isBun, isDeno;
|
|
20
20
|
var init_runtime = __esm({
|
|
21
|
-
"src/runtime.ts"() {
|
|
21
|
+
"src/shares/runtime.ts"() {
|
|
22
22
|
"use strict";
|
|
23
23
|
runtime = (() => {
|
|
24
24
|
if (typeof Deno !== "undefined") return "deno";
|
|
@@ -31,37 +31,20 @@ var init_runtime = __esm({
|
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
// src/fs.ts
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
mkdir: () => mkdir,
|
|
46
|
-
mkdirSync: () => mkdirSync,
|
|
47
|
-
promises: () => promises,
|
|
48
|
-
readFile: () => readFile,
|
|
49
|
-
readFileSync: () => readFileSync,
|
|
50
|
-
readdir: () => readdir,
|
|
51
|
-
readdirSync: () => readdirSync,
|
|
52
|
-
realpath: () => realpath,
|
|
53
|
-
realpathSync: () => realpathSync,
|
|
54
|
-
rename: () => rename,
|
|
55
|
-
renameSync: () => renameSync,
|
|
56
|
-
rmdir: () => rmdir,
|
|
57
|
-
rmdirSync: () => rmdirSync,
|
|
58
|
-
stat: () => stat,
|
|
59
|
-
statSync: () => statSync,
|
|
60
|
-
unlink: () => unlink,
|
|
61
|
-
unlinkSync: () => unlinkSync,
|
|
62
|
-
writeFile: () => writeFile,
|
|
63
|
-
writeFileSync: () => writeFileSync
|
|
34
|
+
// src/server/fs/node-modules.ts
|
|
35
|
+
var fs, fsPromises;
|
|
36
|
+
var init_node_modules = __esm({
|
|
37
|
+
"src/server/fs/node-modules.ts"() {
|
|
38
|
+
"use strict";
|
|
39
|
+
init_runtime();
|
|
40
|
+
if (isNode || isBun) {
|
|
41
|
+
fs = __require("fs");
|
|
42
|
+
fsPromises = __require("fs/promises");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
64
45
|
});
|
|
46
|
+
|
|
47
|
+
// src/server/fs/utils.ts
|
|
65
48
|
function parseOptions(options, defaultValue) {
|
|
66
49
|
return typeof options === "string" ? { encoding: options } : options || defaultValue;
|
|
67
50
|
}
|
|
@@ -80,6 +63,18 @@ function dataToUint8Array(data) {
|
|
|
80
63
|
}
|
|
81
64
|
return data;
|
|
82
65
|
}
|
|
66
|
+
function createDirentFromDenoEntry(entry) {
|
|
67
|
+
return {
|
|
68
|
+
name: entry.name,
|
|
69
|
+
isFile: () => entry.isFile,
|
|
70
|
+
isDirectory: () => entry.isDirectory,
|
|
71
|
+
isBlockDevice: () => false,
|
|
72
|
+
isCharacterDevice: () => false,
|
|
73
|
+
isSymbolicLink: () => entry.isSymlink || false,
|
|
74
|
+
isFIFO: () => false,
|
|
75
|
+
isSocket: () => false
|
|
76
|
+
};
|
|
77
|
+
}
|
|
83
78
|
function processDenoEntries(iterator, withFileTypes) {
|
|
84
79
|
const entries = [];
|
|
85
80
|
for (const entry of iterator) {
|
|
@@ -102,6 +97,42 @@ async function processDenoEntriesAsync(iterator, withFileTypes) {
|
|
|
102
97
|
}
|
|
103
98
|
return entries;
|
|
104
99
|
}
|
|
100
|
+
function createStatsFromDenoFileInfo(info) {
|
|
101
|
+
return {
|
|
102
|
+
isFile: () => info.isFile,
|
|
103
|
+
isDirectory: () => info.isDirectory,
|
|
104
|
+
isBlockDevice: () => false,
|
|
105
|
+
isCharacterDevice: () => false,
|
|
106
|
+
isSymbolicLink: () => info.isSymlink || false,
|
|
107
|
+
isFIFO: () => false,
|
|
108
|
+
isSocket: () => false,
|
|
109
|
+
dev: info.dev || 0,
|
|
110
|
+
ino: info.ino || 0,
|
|
111
|
+
mode: info.mode || 0,
|
|
112
|
+
nlink: info.nlink || 1,
|
|
113
|
+
uid: info.uid || 0,
|
|
114
|
+
gid: info.gid || 0,
|
|
115
|
+
rdev: 0,
|
|
116
|
+
size: info.size,
|
|
117
|
+
blksize: info.blksize || 4096,
|
|
118
|
+
blocks: info.blocks || Math.ceil(info.size / 512),
|
|
119
|
+
atimeMs: info.atime?.getTime() || Date.now(),
|
|
120
|
+
mtimeMs: info.mtime?.getTime() || Date.now(),
|
|
121
|
+
ctimeMs: info.birthtime?.getTime() || Date.now(),
|
|
122
|
+
birthtimeMs: info.birthtime?.getTime() || Date.now(),
|
|
123
|
+
atime: info.atime || /* @__PURE__ */ new Date(),
|
|
124
|
+
mtime: info.mtime || /* @__PURE__ */ new Date(),
|
|
125
|
+
ctime: info.birthtime || /* @__PURE__ */ new Date(),
|
|
126
|
+
birthtime: info.birthtime || /* @__PURE__ */ new Date()
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
var init_utils = __esm({
|
|
130
|
+
"src/server/fs/utils.ts"() {
|
|
131
|
+
"use strict";
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// src/server/fs/file-ops.ts
|
|
105
136
|
async function readFile(path, options) {
|
|
106
137
|
const opts = parseOptions(options, {});
|
|
107
138
|
if (isNode || isBun) {
|
|
@@ -142,28 +173,27 @@ async function appendFile(path, data, options) {
|
|
|
142
173
|
const opts = parseOptions(options, {});
|
|
143
174
|
if (isNode) {
|
|
144
175
|
return fsPromises.appendFile(path, data, opts);
|
|
176
|
+
}
|
|
177
|
+
if (await exists(path)) {
|
|
178
|
+
const existing = await readFile(path);
|
|
179
|
+
const combined = Buffer.isBuffer(existing) ? Buffer.concat([existing, Buffer.isBuffer(data) ? data : Buffer.from(data)]) : existing + (Buffer.isBuffer(data) ? data.toString() : data);
|
|
180
|
+
await writeFile(path, combined, opts);
|
|
145
181
|
} else {
|
|
146
|
-
|
|
147
|
-
const existing = await readFile(path);
|
|
148
|
-
const combined = Buffer.isBuffer(existing) ? Buffer.concat([existing, Buffer.isBuffer(data) ? data : Buffer.from(data)]) : existing + (Buffer.isBuffer(data) ? data.toString() : data);
|
|
149
|
-
await writeFile(path, combined, opts);
|
|
150
|
-
} else {
|
|
151
|
-
await writeFile(path, data, opts);
|
|
152
|
-
}
|
|
182
|
+
await writeFile(path, data, opts);
|
|
153
183
|
}
|
|
154
184
|
}
|
|
155
185
|
function appendFileSync(path, data, options) {
|
|
156
186
|
const opts = parseOptions(options, {});
|
|
157
187
|
if (isNode) {
|
|
158
188
|
fs.appendFileSync(path, data, opts);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (existsSync(path)) {
|
|
192
|
+
const existing = readFileSync(path);
|
|
193
|
+
const combined = Buffer.isBuffer(existing) ? Buffer.concat([existing, Buffer.isBuffer(data) ? data : Buffer.from(data)]) : existing + (Buffer.isBuffer(data) ? data.toString() : data);
|
|
194
|
+
writeFileSync(path, combined, opts);
|
|
159
195
|
} else {
|
|
160
|
-
|
|
161
|
-
const existing = readFileSync(path);
|
|
162
|
-
const combined = Buffer.isBuffer(existing) ? Buffer.concat([existing, Buffer.isBuffer(data) ? data : Buffer.from(data)]) : existing + (Buffer.isBuffer(data) ? data.toString() : data);
|
|
163
|
-
writeFileSync(path, combined, opts);
|
|
164
|
-
} else {
|
|
165
|
-
writeFileSync(path, data, opts);
|
|
166
|
-
}
|
|
196
|
+
writeFileSync(path, data, opts);
|
|
167
197
|
}
|
|
168
198
|
}
|
|
169
199
|
async function exists(path) {
|
|
@@ -200,6 +230,16 @@ function statSync(path) {
|
|
|
200
230
|
}
|
|
201
231
|
throw new Error("Unsupported runtime");
|
|
202
232
|
}
|
|
233
|
+
var init_file_ops = __esm({
|
|
234
|
+
"src/server/fs/file-ops.ts"() {
|
|
235
|
+
"use strict";
|
|
236
|
+
init_runtime();
|
|
237
|
+
init_node_modules();
|
|
238
|
+
init_utils();
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
// src/server/fs/directory-ops.ts
|
|
203
243
|
async function mkdir(path, options) {
|
|
204
244
|
const opts = typeof options === "number" ? { mode: options } : options || {};
|
|
205
245
|
if (isNode || isBun) {
|
|
@@ -262,6 +302,16 @@ function rmdirSync(path, options) {
|
|
|
262
302
|
Deno.removeSync(path, { recursive: options?.recursive });
|
|
263
303
|
}
|
|
264
304
|
}
|
|
305
|
+
var init_directory_ops = __esm({
|
|
306
|
+
"src/server/fs/directory-ops.ts"() {
|
|
307
|
+
"use strict";
|
|
308
|
+
init_runtime();
|
|
309
|
+
init_node_modules();
|
|
310
|
+
init_utils();
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
// src/server/fs/path-ops.ts
|
|
265
315
|
async function rename(oldPath, newPath) {
|
|
266
316
|
if (isNode || isBun) {
|
|
267
317
|
return fsPromises.rename(oldPath, newPath);
|
|
@@ -306,59 +356,59 @@ function realpathSync(path, options) {
|
|
|
306
356
|
}
|
|
307
357
|
return path;
|
|
308
358
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
};
|
|
349
|
-
}
|
|
359
|
+
var init_path_ops = __esm({
|
|
360
|
+
"src/server/fs/path-ops.ts"() {
|
|
361
|
+
"use strict";
|
|
362
|
+
init_runtime();
|
|
363
|
+
init_node_modules();
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
// src/server/fs/index.ts
|
|
368
|
+
var fs_exports = {};
|
|
369
|
+
__export(fs_exports, {
|
|
370
|
+
appendFile: () => appendFile,
|
|
371
|
+
appendFileSync: () => appendFileSync,
|
|
372
|
+
copyFile: () => copyFile,
|
|
373
|
+
copyFileSync: () => copyFileSync,
|
|
374
|
+
default: () => fs_default,
|
|
375
|
+
exists: () => exists,
|
|
376
|
+
existsSync: () => existsSync,
|
|
377
|
+
getRuntime: () => getRuntime,
|
|
378
|
+
mkdir: () => mkdir,
|
|
379
|
+
mkdirSync: () => mkdirSync,
|
|
380
|
+
promises: () => promises,
|
|
381
|
+
readFile: () => readFile,
|
|
382
|
+
readFileSync: () => readFileSync,
|
|
383
|
+
readdir: () => readdir,
|
|
384
|
+
readdirSync: () => readdirSync,
|
|
385
|
+
realpath: () => realpath,
|
|
386
|
+
realpathSync: () => realpathSync,
|
|
387
|
+
rename: () => rename,
|
|
388
|
+
renameSync: () => renameSync,
|
|
389
|
+
rmdir: () => rmdir,
|
|
390
|
+
rmdirSync: () => rmdirSync,
|
|
391
|
+
stat: () => stat,
|
|
392
|
+
statSync: () => statSync,
|
|
393
|
+
unlink: () => unlink,
|
|
394
|
+
unlinkSync: () => unlinkSync,
|
|
395
|
+
writeFile: () => writeFile,
|
|
396
|
+
writeFileSync: () => writeFileSync
|
|
397
|
+
});
|
|
350
398
|
function getRuntime() {
|
|
351
399
|
return runtime;
|
|
352
400
|
}
|
|
353
|
-
var
|
|
401
|
+
var promises, fs_default;
|
|
354
402
|
var init_fs = __esm({
|
|
355
|
-
"src/fs.ts"() {
|
|
403
|
+
"src/server/fs/index.ts"() {
|
|
356
404
|
"use strict";
|
|
357
405
|
init_runtime();
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
406
|
+
init_file_ops();
|
|
407
|
+
init_directory_ops();
|
|
408
|
+
init_path_ops();
|
|
409
|
+
init_file_ops();
|
|
410
|
+
init_directory_ops();
|
|
411
|
+
init_path_ops();
|
|
362
412
|
promises = {
|
|
363
413
|
readFile,
|
|
364
414
|
writeFile,
|
|
@@ -403,57 +453,47 @@ var init_fs = __esm({
|
|
|
403
453
|
}
|
|
404
454
|
});
|
|
405
455
|
|
|
406
|
-
// src/
|
|
407
|
-
var
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
relative: () => relative,
|
|
422
|
-
resolve: () => resolve,
|
|
423
|
-
sep: () => sep,
|
|
424
|
-
toNamespacedPath: () => toNamespacedPath,
|
|
425
|
-
win32: () => win32
|
|
426
|
-
});
|
|
456
|
+
// src/shares/config/constants.ts
|
|
457
|
+
var ELIT_CONFIG_FILES = [
|
|
458
|
+
"elit.config.ts",
|
|
459
|
+
"elit.config.mts",
|
|
460
|
+
"elit.config.js",
|
|
461
|
+
"elit.config.mjs",
|
|
462
|
+
"elit.config.cjs",
|
|
463
|
+
"elit.config.json"
|
|
464
|
+
];
|
|
465
|
+
|
|
466
|
+
// src/shares/config/env.ts
|
|
467
|
+
init_fs();
|
|
468
|
+
|
|
469
|
+
// src/server/path/platform.ts
|
|
470
|
+
init_runtime();
|
|
427
471
|
function getSeparator(isWin) {
|
|
428
472
|
return isWin ? "\\" : "/";
|
|
429
473
|
}
|
|
430
474
|
function getCwd() {
|
|
431
475
|
if (isNode || isBun) {
|
|
432
476
|
return process.cwd();
|
|
433
|
-
}
|
|
477
|
+
}
|
|
478
|
+
if (isDeno) {
|
|
434
479
|
return Deno.cwd();
|
|
435
480
|
}
|
|
436
481
|
return "/";
|
|
437
482
|
}
|
|
483
|
+
var isWindows = (() => {
|
|
484
|
+
if (isNode) {
|
|
485
|
+
return process.platform === "win32";
|
|
486
|
+
}
|
|
487
|
+
if (isDeno) {
|
|
488
|
+
return Deno.build.os === "windows";
|
|
489
|
+
}
|
|
490
|
+
return typeof process !== "undefined" && process.platform === "win32";
|
|
491
|
+
})();
|
|
492
|
+
|
|
493
|
+
// src/server/path/operations.ts
|
|
438
494
|
function findLastSeparator(path) {
|
|
439
495
|
return Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
|
|
440
496
|
}
|
|
441
|
-
function createPathOps(isWin) {
|
|
442
|
-
return {
|
|
443
|
-
sep: getSeparator(isWin),
|
|
444
|
-
delimiter: isWin ? ";" : ":",
|
|
445
|
-
normalize: (path) => normalizePath(path, isWin),
|
|
446
|
-
join: (...paths) => joinPaths(paths, isWin),
|
|
447
|
-
resolve: (...paths) => resolvePaths(paths, isWin),
|
|
448
|
-
isAbsolute: (path) => isWin ? isAbsoluteWin(path) : isAbsolutePosix(path),
|
|
449
|
-
relative: (from, to) => relativePath(from, to, isWin),
|
|
450
|
-
dirname: (path) => getDirname(path, isWin),
|
|
451
|
-
basename: (path, ext) => getBasename(path, ext, isWin),
|
|
452
|
-
extname: (path) => getExtname(path),
|
|
453
|
-
parse: (path) => parsePath(path, isWin),
|
|
454
|
-
format: (pathObject) => formatPath(pathObject, isWin)
|
|
455
|
-
};
|
|
456
|
-
}
|
|
457
497
|
function isAbsolutePosix(path) {
|
|
458
498
|
return path.length > 0 && path[0] === "/";
|
|
459
499
|
}
|
|
@@ -477,15 +517,15 @@ function isAbsoluteWin(path) {
|
|
|
477
517
|
function normalizePath(path, isWin) {
|
|
478
518
|
if (path.length === 0) return ".";
|
|
479
519
|
const separator = getSeparator(isWin);
|
|
480
|
-
const
|
|
520
|
+
const isAbsolute = isWin ? isAbsoluteWin(path) : isAbsolutePosix(path);
|
|
481
521
|
const trailingSeparator = path[path.length - 1] === separator || isWin && path[path.length - 1] === "/";
|
|
482
|
-
|
|
522
|
+
const normalized = path.replace(isWin ? /[\/\\]+/g : /\/+/g, separator);
|
|
483
523
|
const parts = normalized.split(separator);
|
|
484
524
|
const result = [];
|
|
485
|
-
for (let
|
|
486
|
-
const part = parts[
|
|
525
|
+
for (let index = 0; index < parts.length; index++) {
|
|
526
|
+
const part = parts[index];
|
|
487
527
|
if (part === "" || part === ".") {
|
|
488
|
-
if (
|
|
528
|
+
if (index === 0 && isAbsolute) result.push("");
|
|
489
529
|
continue;
|
|
490
530
|
}
|
|
491
531
|
if (part === "..") {
|
|
@@ -493,28 +533,28 @@ function normalizePath(path, isWin) {
|
|
|
493
533
|
if (!(result.length === 1 && result[0] === "")) {
|
|
494
534
|
result.pop();
|
|
495
535
|
}
|
|
496
|
-
} else if (!
|
|
536
|
+
} else if (!isAbsolute) {
|
|
497
537
|
result.push("..");
|
|
498
538
|
}
|
|
499
539
|
} else {
|
|
500
540
|
result.push(part);
|
|
501
541
|
}
|
|
502
542
|
}
|
|
503
|
-
let
|
|
504
|
-
if (
|
|
505
|
-
return
|
|
543
|
+
let finalPath = result.join(separator);
|
|
544
|
+
if (finalPath.length === 0) {
|
|
545
|
+
return isAbsolute ? separator : ".";
|
|
506
546
|
}
|
|
507
|
-
if (trailingSeparator &&
|
|
508
|
-
|
|
547
|
+
if (trailingSeparator && finalPath[finalPath.length - 1] !== separator) {
|
|
548
|
+
finalPath += separator;
|
|
509
549
|
}
|
|
510
|
-
return
|
|
550
|
+
return finalPath;
|
|
511
551
|
}
|
|
512
552
|
function joinPaths(paths, isWin) {
|
|
513
553
|
if (paths.length === 0) return ".";
|
|
514
554
|
const separator = getSeparator(isWin);
|
|
515
555
|
let joined = "";
|
|
516
|
-
for (let
|
|
517
|
-
const path = paths[
|
|
556
|
+
for (let index = 0; index < paths.length; index++) {
|
|
557
|
+
const path = paths[index];
|
|
518
558
|
if (path && path.length > 0) {
|
|
519
559
|
if (joined.length === 0) {
|
|
520
560
|
joined = path;
|
|
@@ -529,43 +569,43 @@ function joinPaths(paths, isWin) {
|
|
|
529
569
|
function resolvePaths(paths, isWin) {
|
|
530
570
|
const separator = getSeparator(isWin);
|
|
531
571
|
let resolved = "";
|
|
532
|
-
let
|
|
533
|
-
for (let
|
|
534
|
-
const path = paths[
|
|
572
|
+
let absolute = false;
|
|
573
|
+
for (let index = paths.length - 1; index >= 0 && !absolute; index--) {
|
|
574
|
+
const path = paths[index];
|
|
535
575
|
if (path && path.length > 0) {
|
|
536
576
|
resolved = path + (resolved.length > 0 ? separator + resolved : "");
|
|
537
|
-
|
|
577
|
+
absolute = isWin ? isAbsoluteWin(resolved) : isAbsolutePosix(resolved);
|
|
538
578
|
}
|
|
539
579
|
}
|
|
540
|
-
if (!
|
|
580
|
+
if (!absolute) {
|
|
541
581
|
const cwd = getCwd();
|
|
542
582
|
resolved = cwd + (resolved.length > 0 ? separator + resolved : "");
|
|
543
583
|
}
|
|
544
584
|
return normalizePath(resolved, isWin);
|
|
545
585
|
}
|
|
546
586
|
function relativePath(from, to, isWin) {
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
if (
|
|
587
|
+
const resolvedFrom = resolvePaths([from], isWin);
|
|
588
|
+
const resolvedTo = resolvePaths([to], isWin);
|
|
589
|
+
if (resolvedFrom === resolvedTo) return "";
|
|
550
590
|
const separator = getSeparator(isWin);
|
|
551
|
-
const fromParts =
|
|
552
|
-
const toParts =
|
|
553
|
-
let commonLength = 0;
|
|
591
|
+
const fromParts = resolvedFrom.split(separator).filter((part) => part.length > 0);
|
|
592
|
+
const toParts = resolvedTo.split(separator).filter((part) => part.length > 0);
|
|
554
593
|
const minLength = Math.min(fromParts.length, toParts.length);
|
|
555
|
-
|
|
556
|
-
|
|
594
|
+
let commonLength = 0;
|
|
595
|
+
for (let index = 0; index < minLength; index++) {
|
|
596
|
+
if (fromParts[index] === toParts[index]) {
|
|
557
597
|
commonLength++;
|
|
558
598
|
} else {
|
|
559
599
|
break;
|
|
560
600
|
}
|
|
561
601
|
}
|
|
562
|
-
const upCount = fromParts.length - commonLength;
|
|
563
602
|
const result = [];
|
|
564
|
-
|
|
603
|
+
const upCount = fromParts.length - commonLength;
|
|
604
|
+
for (let index = 0; index < upCount; index++) {
|
|
565
605
|
result.push("..");
|
|
566
606
|
}
|
|
567
|
-
for (let
|
|
568
|
-
result.push(toParts[
|
|
607
|
+
for (let index = commonLength; index < toParts.length; index++) {
|
|
608
|
+
result.push(toParts[index]);
|
|
569
609
|
}
|
|
570
610
|
return result.join(separator) || ".";
|
|
571
611
|
}
|
|
@@ -573,15 +613,15 @@ function getDirname(path, isWin) {
|
|
|
573
613
|
if (path.length === 0) return ".";
|
|
574
614
|
const separator = getSeparator(isWin);
|
|
575
615
|
const normalized = normalizePath(path, isWin);
|
|
576
|
-
const
|
|
577
|
-
if (
|
|
578
|
-
if (
|
|
579
|
-
return normalized.slice(0,
|
|
616
|
+
const lastSeparatorIndex = normalized.lastIndexOf(separator);
|
|
617
|
+
if (lastSeparatorIndex === -1) return ".";
|
|
618
|
+
if (lastSeparatorIndex === 0) return separator;
|
|
619
|
+
return normalized.slice(0, lastSeparatorIndex);
|
|
580
620
|
}
|
|
581
621
|
function getBasename(path, ext, isWin) {
|
|
582
622
|
if (path.length === 0) return "";
|
|
583
|
-
const
|
|
584
|
-
let base =
|
|
623
|
+
const lastSeparatorIndex = isWin ? findLastSeparator(path) : path.lastIndexOf("/");
|
|
624
|
+
let base = lastSeparatorIndex === -1 ? path : path.slice(lastSeparatorIndex + 1);
|
|
585
625
|
if (ext && base.endsWith(ext)) {
|
|
586
626
|
base = base.slice(0, base.length - ext.length);
|
|
587
627
|
}
|
|
@@ -589,8 +629,8 @@ function getBasename(path, ext, isWin) {
|
|
|
589
629
|
}
|
|
590
630
|
function getExtname(path) {
|
|
591
631
|
const lastDotIndex = path.lastIndexOf(".");
|
|
592
|
-
const
|
|
593
|
-
if (lastDotIndex === -1 || lastDotIndex <
|
|
632
|
+
const lastSeparatorIndex = findLastSeparator(path);
|
|
633
|
+
if (lastDotIndex === -1 || lastDotIndex < lastSeparatorIndex || lastDotIndex === path.length - 1) {
|
|
594
634
|
return "";
|
|
595
635
|
}
|
|
596
636
|
return path.slice(lastDotIndex);
|
|
@@ -606,10 +646,8 @@ function parsePath(path, isWin) {
|
|
|
606
646
|
} else if (path[0] === "\\" || path[0] === "/") {
|
|
607
647
|
root = "\\";
|
|
608
648
|
}
|
|
609
|
-
} else {
|
|
610
|
-
|
|
611
|
-
root = "/";
|
|
612
|
-
}
|
|
649
|
+
} else if (path[0] === "/") {
|
|
650
|
+
root = "/";
|
|
613
651
|
}
|
|
614
652
|
const dir = getDirname(path, isWin);
|
|
615
653
|
const base = getBasename(path, void 0, isWin);
|
|
@@ -625,98 +663,113 @@ function formatPath(pathObject, isWin) {
|
|
|
625
663
|
if (dir === pathObject.root) return dir + base;
|
|
626
664
|
return dir + separator + base;
|
|
627
665
|
}
|
|
628
|
-
function
|
|
629
|
-
return
|
|
666
|
+
function createPathOps(isWin) {
|
|
667
|
+
return {
|
|
668
|
+
sep: getSeparator(isWin),
|
|
669
|
+
delimiter: isWin ? ";" : ":",
|
|
670
|
+
normalize: (path) => normalizePath(path, isWin),
|
|
671
|
+
join: (...paths) => joinPaths(paths, isWin),
|
|
672
|
+
resolve: (...paths) => resolvePaths(paths, isWin),
|
|
673
|
+
isAbsolute: (path) => isWin ? isAbsoluteWin(path) : isAbsolutePosix(path),
|
|
674
|
+
relative: (from, to) => relativePath(from, to, isWin),
|
|
675
|
+
dirname: (path) => getDirname(path, isWin),
|
|
676
|
+
basename: (path, ext) => getBasename(path, ext, isWin),
|
|
677
|
+
extname: (path) => getExtname(path),
|
|
678
|
+
parse: (path) => parsePath(path, isWin),
|
|
679
|
+
format: (pathObject) => formatPath(pathObject, isWin)
|
|
680
|
+
};
|
|
630
681
|
}
|
|
682
|
+
|
|
683
|
+
// src/server/path/runtime.ts
|
|
684
|
+
init_runtime();
|
|
685
|
+
|
|
686
|
+
// src/server/path/index.ts
|
|
687
|
+
var posix = createPathOps(false);
|
|
688
|
+
var win32 = createPathOps(true);
|
|
631
689
|
function join(...paths) {
|
|
632
690
|
return joinPaths(paths, isWindows);
|
|
633
691
|
}
|
|
634
692
|
function resolve(...paths) {
|
|
635
693
|
return resolvePaths(paths, isWindows);
|
|
636
694
|
}
|
|
637
|
-
function isAbsolute(path) {
|
|
638
|
-
return isWindows ? win32.isAbsolute(path) : posix.isAbsolute(path);
|
|
639
|
-
}
|
|
640
695
|
function relative(from, to) {
|
|
641
696
|
return relativePath(from, to, isWindows);
|
|
642
697
|
}
|
|
643
698
|
function dirname(path) {
|
|
644
699
|
return getDirname(path, isWindows);
|
|
645
700
|
}
|
|
646
|
-
|
|
647
|
-
|
|
701
|
+
|
|
702
|
+
// src/shares/config/utils.ts
|
|
703
|
+
init_fs();
|
|
704
|
+
function readFileAsString(filePath) {
|
|
705
|
+
const contentBuffer = readFileSync(filePath, "utf-8");
|
|
706
|
+
return typeof contentBuffer === "string" ? contentBuffer : contentBuffer.toString("utf-8");
|
|
648
707
|
}
|
|
649
|
-
function
|
|
650
|
-
|
|
708
|
+
function removeQuotes(value) {
|
|
709
|
+
const trimmed = value.trim();
|
|
710
|
+
if (trimmed.startsWith('"') && trimmed.endsWith('"') || trimmed.startsWith("'") && trimmed.endsWith("'")) {
|
|
711
|
+
return trimmed.slice(1, -1);
|
|
712
|
+
}
|
|
713
|
+
return trimmed;
|
|
651
714
|
}
|
|
652
|
-
function
|
|
653
|
-
|
|
715
|
+
function normalizeRelativeImportPath(fromDirectory, targetPath) {
|
|
716
|
+
const relativePath2 = relative(fromDirectory, targetPath).replace(/\\/g, "/");
|
|
717
|
+
return relativePath2.startsWith(".") ? relativePath2 : `./${relativePath2}`;
|
|
654
718
|
}
|
|
655
|
-
function
|
|
656
|
-
|
|
719
|
+
async function importConfigModule(configPath) {
|
|
720
|
+
const { pathToFileURL } = await import("url");
|
|
721
|
+
const configModule = await import(pathToFileURL(configPath).href);
|
|
722
|
+
return configModule.default || configModule;
|
|
657
723
|
}
|
|
658
|
-
function
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
if (resolved[1] === "\\" && resolved[2] !== "?") {
|
|
664
|
-
return "\\\\?\\UNC\\" + resolved.slice(2);
|
|
665
|
-
}
|
|
666
|
-
} else if (resolved[1] === ":" && resolved[2] === "\\") {
|
|
667
|
-
return "\\\\?\\" + resolved;
|
|
668
|
-
}
|
|
724
|
+
async function safeCleanup(filePath) {
|
|
725
|
+
try {
|
|
726
|
+
const { unlinkSync: unlinkSync2 } = await Promise.resolve().then(() => (init_fs(), fs_exports));
|
|
727
|
+
unlinkSync2(filePath);
|
|
728
|
+
} catch {
|
|
669
729
|
}
|
|
670
|
-
return path;
|
|
671
|
-
}
|
|
672
|
-
function getRuntime2() {
|
|
673
|
-
return runtime;
|
|
674
730
|
}
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
731
|
+
|
|
732
|
+
// src/shares/config/env.ts
|
|
733
|
+
function loadEnv(mode = "development", cwd = process.cwd()) {
|
|
734
|
+
const env = { MODE: mode };
|
|
735
|
+
const envFiles = [
|
|
736
|
+
`.env.${mode}.local`,
|
|
737
|
+
`.env.${mode}`,
|
|
738
|
+
".env.local",
|
|
739
|
+
".env"
|
|
740
|
+
];
|
|
741
|
+
for (const file of envFiles) {
|
|
742
|
+
const filePath = resolve(cwd, file);
|
|
743
|
+
if (existsSync(filePath)) {
|
|
744
|
+
const content = readFileAsString(filePath);
|
|
745
|
+
const lines = content.split("\n");
|
|
746
|
+
for (const line of lines) {
|
|
747
|
+
const trimmed = line.trim();
|
|
748
|
+
if (!trimmed || trimmed.startsWith("#")) {
|
|
749
|
+
continue;
|
|
750
|
+
}
|
|
751
|
+
const match = trimmed.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/);
|
|
752
|
+
if (match) {
|
|
753
|
+
const [, key, value] = match;
|
|
754
|
+
const cleanValue = removeQuotes(value);
|
|
755
|
+
if (!(key in env)) {
|
|
756
|
+
env[key] = cleanValue;
|
|
757
|
+
}
|
|
758
|
+
}
|
|
685
759
|
}
|
|
686
|
-
|
|
687
|
-
})();
|
|
688
|
-
sep = isWindows ? "\\" : "/";
|
|
689
|
-
delimiter = isWindows ? ";" : ":";
|
|
690
|
-
posix = createPathOps(false);
|
|
691
|
-
win32 = createPathOps(true);
|
|
692
|
-
path_default = {
|
|
693
|
-
sep,
|
|
694
|
-
delimiter,
|
|
695
|
-
normalize,
|
|
696
|
-
join,
|
|
697
|
-
resolve,
|
|
698
|
-
isAbsolute,
|
|
699
|
-
relative,
|
|
700
|
-
dirname,
|
|
701
|
-
basename,
|
|
702
|
-
extname,
|
|
703
|
-
parse,
|
|
704
|
-
format,
|
|
705
|
-
toNamespacedPath,
|
|
706
|
-
posix,
|
|
707
|
-
win32,
|
|
708
|
-
getRuntime: getRuntime2
|
|
709
|
-
};
|
|
760
|
+
}
|
|
710
761
|
}
|
|
711
|
-
|
|
762
|
+
return env;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
// src/shares/config/loader.ts
|
|
766
|
+
init_fs();
|
|
712
767
|
|
|
713
|
-
// src/
|
|
768
|
+
// src/shares/workspace-package/roots.ts
|
|
714
769
|
init_fs();
|
|
715
|
-
init_path();
|
|
716
770
|
|
|
717
|
-
// src/workspace-package.ts
|
|
771
|
+
// src/shares/workspace-package/package-json.ts
|
|
718
772
|
init_fs();
|
|
719
|
-
init_path();
|
|
720
773
|
function readPackageJson(filePath) {
|
|
721
774
|
try {
|
|
722
775
|
const packageJsonBuffer = readFileSync(filePath, "utf-8");
|
|
@@ -726,13 +779,14 @@ function readPackageJson(filePath) {
|
|
|
726
779
|
return void 0;
|
|
727
780
|
}
|
|
728
781
|
}
|
|
729
|
-
|
|
782
|
+
|
|
783
|
+
// src/shares/workspace-package/roots.ts
|
|
784
|
+
function findPackageDirectory(startDir, resolveMatch) {
|
|
730
785
|
let currentDir = resolve(startDir);
|
|
731
786
|
while (true) {
|
|
732
|
-
const
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
return currentDir;
|
|
787
|
+
const match = resolveMatch(currentDir);
|
|
788
|
+
if (match) {
|
|
789
|
+
return match;
|
|
736
790
|
}
|
|
737
791
|
const parentDir = dirname(currentDir);
|
|
738
792
|
if (parentDir === currentDir) {
|
|
@@ -741,20 +795,24 @@ function findWorkspacePackageRoot(startDir, packageName) {
|
|
|
741
795
|
currentDir = parentDir;
|
|
742
796
|
}
|
|
743
797
|
}
|
|
798
|
+
function findWorkspacePackageRoot(startDir, packageName) {
|
|
799
|
+
return findPackageDirectory(startDir, (currentDir) => {
|
|
800
|
+
const packageJsonPath = join(currentDir, "package.json");
|
|
801
|
+
const packageJson = existsSync(packageJsonPath) ? readPackageJson(packageJsonPath) : void 0;
|
|
802
|
+
return packageJson?.name === packageName ? currentDir : void 0;
|
|
803
|
+
});
|
|
804
|
+
}
|
|
744
805
|
function findInstalledPackageRoot(startDir, packageName) {
|
|
745
|
-
|
|
746
|
-
while (true) {
|
|
806
|
+
return findPackageDirectory(startDir, (currentDir) => {
|
|
747
807
|
const candidate = join(currentDir, "node_modules", ...packageName.split("/"));
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
}
|
|
751
|
-
const parentDir = dirname(currentDir);
|
|
752
|
-
if (parentDir === currentDir) {
|
|
753
|
-
return void 0;
|
|
754
|
-
}
|
|
755
|
-
currentDir = parentDir;
|
|
756
|
-
}
|
|
808
|
+
return existsSync(candidate) ? candidate : void 0;
|
|
809
|
+
});
|
|
757
810
|
}
|
|
811
|
+
|
|
812
|
+
// src/shares/workspace-package/resolve.ts
|
|
813
|
+
init_fs();
|
|
814
|
+
|
|
815
|
+
// src/shares/workspace-package/candidates.ts
|
|
758
816
|
function getWorkspacePackageImportCandidates(packageRoot, specifier, options = {}) {
|
|
759
817
|
const subpath = specifier === "elit" ? "index" : specifier.slice("elit/".length);
|
|
760
818
|
const builtCandidates = options.preferredBuiltFormat === "cjs" ? [
|
|
@@ -772,14 +830,24 @@ function getWorkspacePackageImportCandidates(packageRoot, specifier, options = {
|
|
|
772
830
|
];
|
|
773
831
|
return options.preferBuilt ? [...builtCandidates, ...sourceCandidates] : [...sourceCandidates, ...builtCandidates];
|
|
774
832
|
}
|
|
833
|
+
|
|
834
|
+
// src/shares/workspace-package/resolve.ts
|
|
835
|
+
function isWorkspacePackageSpecifier(specifier) {
|
|
836
|
+
return specifier === "elit" || specifier.startsWith("elit/");
|
|
837
|
+
}
|
|
775
838
|
function resolveWorkspacePackageImport(specifier, startDir, options = {}) {
|
|
776
|
-
if (
|
|
839
|
+
if (!isWorkspacePackageSpecifier(specifier)) {
|
|
777
840
|
return void 0;
|
|
778
841
|
}
|
|
779
|
-
const packageRoots =
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
842
|
+
const packageRoots = /* @__PURE__ */ new Set();
|
|
843
|
+
const workspacePackageRoot = findWorkspacePackageRoot(startDir, "elit");
|
|
844
|
+
const installedPackageRoot = findInstalledPackageRoot(startDir, "elit");
|
|
845
|
+
if (workspacePackageRoot) {
|
|
846
|
+
packageRoots.add(workspacePackageRoot);
|
|
847
|
+
}
|
|
848
|
+
if (installedPackageRoot) {
|
|
849
|
+
packageRoots.add(installedPackageRoot);
|
|
850
|
+
}
|
|
783
851
|
for (const packageRoot of packageRoots) {
|
|
784
852
|
for (const candidate of getWorkspacePackageImportCandidates(packageRoot, specifier, options)) {
|
|
785
853
|
if (existsSync(candidate)) {
|
|
@@ -790,45 +858,7 @@ function resolveWorkspacePackageImport(specifier, startDir, options = {}) {
|
|
|
790
858
|
return void 0;
|
|
791
859
|
}
|
|
792
860
|
|
|
793
|
-
// src/config.ts
|
|
794
|
-
function readFileAsString(filePath) {
|
|
795
|
-
const contentBuffer = readFileSync(filePath, "utf-8");
|
|
796
|
-
return typeof contentBuffer === "string" ? contentBuffer : contentBuffer.toString("utf-8");
|
|
797
|
-
}
|
|
798
|
-
function removeQuotes(value) {
|
|
799
|
-
const trimmed = value.trim();
|
|
800
|
-
if (trimmed.startsWith('"') && trimmed.endsWith('"') || trimmed.startsWith("'") && trimmed.endsWith("'")) {
|
|
801
|
-
return trimmed.slice(1, -1);
|
|
802
|
-
}
|
|
803
|
-
return trimmed;
|
|
804
|
-
}
|
|
805
|
-
function normalizeRelativeImportPath(fromDirectory, targetPath) {
|
|
806
|
-
const relativePath2 = relative(fromDirectory, targetPath).replace(/\\/g, "/");
|
|
807
|
-
return relativePath2.startsWith(".") ? relativePath2 : `./${relativePath2}`;
|
|
808
|
-
}
|
|
809
|
-
async function importConfigModule(configPath) {
|
|
810
|
-
const { pathToFileURL } = await import("url");
|
|
811
|
-
const configModule = await import(pathToFileURL(configPath).href);
|
|
812
|
-
return configModule.default || configModule;
|
|
813
|
-
}
|
|
814
|
-
async function safeCleanup(filePath) {
|
|
815
|
-
try {
|
|
816
|
-
const { unlinkSync: unlinkSync2 } = await Promise.resolve().then(() => (init_fs(), fs_exports));
|
|
817
|
-
unlinkSync2(filePath);
|
|
818
|
-
} catch {
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
function defineConfig(config) {
|
|
822
|
-
return config;
|
|
823
|
-
}
|
|
824
|
-
var ELIT_CONFIG_FILES = [
|
|
825
|
-
"elit.config.ts",
|
|
826
|
-
"elit.config.mts",
|
|
827
|
-
"elit.config.js",
|
|
828
|
-
"elit.config.mjs",
|
|
829
|
-
"elit.config.cjs",
|
|
830
|
-
"elit.config.json"
|
|
831
|
-
];
|
|
861
|
+
// src/shares/config/loader.ts
|
|
832
862
|
function resolveConfigPath(cwd = process.cwd()) {
|
|
833
863
|
for (const configFile of ELIT_CONFIG_FILES) {
|
|
834
864
|
const configPath = resolve(cwd, configFile);
|
|
@@ -838,35 +868,6 @@ function resolveConfigPath(cwd = process.cwd()) {
|
|
|
838
868
|
}
|
|
839
869
|
return null;
|
|
840
870
|
}
|
|
841
|
-
function loadEnv(mode = "development", cwd = process.cwd()) {
|
|
842
|
-
const env = { MODE: mode };
|
|
843
|
-
const envFiles = [
|
|
844
|
-
`.env.${mode}.local`,
|
|
845
|
-
`.env.${mode}`,
|
|
846
|
-
`.env.local`,
|
|
847
|
-
`.env`
|
|
848
|
-
];
|
|
849
|
-
for (const file of envFiles) {
|
|
850
|
-
const filePath = resolve(cwd, file);
|
|
851
|
-
if (existsSync(filePath)) {
|
|
852
|
-
const content = readFileAsString(filePath);
|
|
853
|
-
const lines = content.split("\n");
|
|
854
|
-
for (const line of lines) {
|
|
855
|
-
const trimmed = line.trim();
|
|
856
|
-
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
857
|
-
const match = trimmed.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/);
|
|
858
|
-
if (match) {
|
|
859
|
-
const [, key, value] = match;
|
|
860
|
-
const cleanValue = removeQuotes(value);
|
|
861
|
-
if (!(key in env)) {
|
|
862
|
-
env[key] = cleanValue;
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
return env;
|
|
869
|
-
}
|
|
870
871
|
async function loadConfig(cwd = process.cwd()) {
|
|
871
872
|
const configPath = resolveConfigPath(cwd);
|
|
872
873
|
if (configPath) {
|
|
@@ -885,16 +886,16 @@ async function loadConfigFile(configPath) {
|
|
|
885
886
|
if (ext === "json") {
|
|
886
887
|
const content = readFileAsString(configPath);
|
|
887
888
|
return JSON.parse(content);
|
|
888
|
-
}
|
|
889
|
+
}
|
|
890
|
+
if (ext === "ts" || ext === "mts") {
|
|
889
891
|
try {
|
|
890
892
|
const { build } = await import("esbuild");
|
|
891
|
-
const
|
|
892
|
-
const
|
|
893
|
-
const tempFile = join2(configDir, `.elit-config-${Date.now()}.mjs`);
|
|
893
|
+
const configDir = dirname(configPath);
|
|
894
|
+
const tempFile = join(configDir, `.elit-config-${Date.now()}.mjs`);
|
|
894
895
|
const externalAllPlugin = {
|
|
895
896
|
name: "external-all",
|
|
896
|
-
setup(
|
|
897
|
-
|
|
897
|
+
setup(buildContext) {
|
|
898
|
+
buildContext.onResolve({ filter: /.*/ }, (args) => {
|
|
898
899
|
const workspacePackageImport = resolveWorkspacePackageImport(args.path, args.resolveDir || configDir, {
|
|
899
900
|
preferBuilt: true,
|
|
900
901
|
preferredBuiltFormat: "esm"
|
|
@@ -934,7 +935,6 @@ async function loadConfigFile(configPath) {
|
|
|
934
935
|
write: true,
|
|
935
936
|
target: "es2020",
|
|
936
937
|
plugins: [externalAllPlugin],
|
|
937
|
-
// External Node.js built-ins and runtime-specific packages
|
|
938
938
|
external: [
|
|
939
939
|
"node:*",
|
|
940
940
|
"fs",
|
|
@@ -949,7 +949,6 @@ async function loadConfigFile(configPath) {
|
|
|
949
949
|
"deno",
|
|
950
950
|
"deno:*"
|
|
951
951
|
],
|
|
952
|
-
// Use the config directory as the working directory for resolution
|
|
953
952
|
absWorkingDir: configDir
|
|
954
953
|
});
|
|
955
954
|
const config = await importConfigModule(tempFile);
|
|
@@ -960,10 +959,11 @@ async function loadConfigFile(configPath) {
|
|
|
960
959
|
console.error("You can use a .js, .mjs, or .json config file instead.");
|
|
961
960
|
throw error;
|
|
962
961
|
}
|
|
963
|
-
} else {
|
|
964
|
-
return await importConfigModule(configPath);
|
|
965
962
|
}
|
|
963
|
+
return await importConfigModule(configPath);
|
|
966
964
|
}
|
|
965
|
+
|
|
966
|
+
// src/shares/config/merge.ts
|
|
967
967
|
function mergeConfig(config, cliArgs) {
|
|
968
968
|
if (!config) {
|
|
969
969
|
return cliArgs;
|
|
@@ -971,10 +971,15 @@ function mergeConfig(config, cliArgs) {
|
|
|
971
971
|
return {
|
|
972
972
|
...config,
|
|
973
973
|
...Object.fromEntries(
|
|
974
|
-
Object.entries(cliArgs).filter(([_,
|
|
974
|
+
Object.entries(cliArgs).filter(([_, value]) => value !== void 0)
|
|
975
975
|
)
|
|
976
976
|
};
|
|
977
977
|
}
|
|
978
|
+
|
|
979
|
+
// src/shares/config/types.ts
|
|
980
|
+
function defineConfig(config) {
|
|
981
|
+
return config;
|
|
982
|
+
}
|
|
978
983
|
export {
|
|
979
984
|
ELIT_CONFIG_FILES,
|
|
980
985
|
defineConfig,
|