elit 3.6.6 → 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/dist/build.cjs +421 -331
- package/dist/build.d.ts +1 -19
- 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 +22439 -21563
- package/dist/cli.d.ts +19 -37
- package/dist/cli.mjs +24113 -23252
- package/dist/config.cjs +357 -350
- package/dist/config.d.ts +17 -245
- 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 -62
- 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 -1523
- package/dist/desktop-auto-render.d.ts +4 -12
- package/dist/desktop-auto-render.js +1695 -1518
- package/dist/desktop-auto-render.mjs +1696 -1519
- 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 -591
- package/dist/dom.d.ts +2 -17
- package/dist/dom.js +714 -588
- package/dist/dom.mjs +716 -590
- package/dist/el.cjs +62 -52
- package/dist/el.d.ts +5 -12
- 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 -7691
- package/dist/index.d.ts +6 -3
- package/dist/index.js +7486 -7677
- package/dist/index.mjs +7497 -7687
- 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 -8870
- package/dist/native.d.ts +7 -10
- package/dist/native.js +8682 -8936
- package/dist/native.mjs +8615 -8869
- 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 -34
- package/dist/render-context.js +11 -2
- package/dist/render-context.mjs +11 -2
- package/dist/router.cjs +787 -646
- package/dist/router.d.ts +8 -14
- package/dist/router.js +786 -645
- package/dist/router.mjs +786 -645
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.js +1 -1
- package/dist/runtime.mjs +1 -1
- package/dist/server.cjs +3254 -2684
- package/dist/server.d.ts +47 -5
- package/dist/server.js +3427 -2859
- package/dist/server.mjs +3397 -2829
- package/dist/smtp-server.cjs +16 -3
- package/dist/smtp-server.d.ts +12 -26
- package/dist/smtp-server.js +18 -5
- package/dist/smtp-server.mjs +16 -3
- package/dist/state-DvEkDehk.d.ts +195 -0
- package/dist/state.cjs +768 -659
- package/dist/state.d.ts +11 -71
- package/dist/state.js +760 -651
- package/dist/state.mjs +767 -658
- 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 +50 -237
- package/dist/universal.cjs +1 -1
- package/dist/universal.d.ts +1 -7
- 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 +8 -1
- package/vendor/epaint-0.31.1/src/image.rs +418 -0
- package/dist/server-uMQvZAll.d.ts +0 -458
package/dist/config.cjs
CHANGED
|
@@ -30,10 +30,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
));
|
|
31
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
32
|
|
|
33
|
-
// src/runtime.ts
|
|
33
|
+
// src/shares/runtime.ts
|
|
34
34
|
var runtime, isNode, isBun, isDeno;
|
|
35
35
|
var init_runtime = __esm({
|
|
36
|
-
"src/runtime.ts"() {
|
|
36
|
+
"src/shares/runtime.ts"() {
|
|
37
37
|
"use strict";
|
|
38
38
|
runtime = (() => {
|
|
39
39
|
if (typeof Deno !== "undefined") return "deno";
|
|
@@ -46,37 +46,20 @@ var init_runtime = __esm({
|
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
-
// src/fs.ts
|
|
50
|
-
var
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
mkdir: () => mkdir,
|
|
61
|
-
mkdirSync: () => mkdirSync,
|
|
62
|
-
promises: () => promises,
|
|
63
|
-
readFile: () => readFile,
|
|
64
|
-
readFileSync: () => readFileSync,
|
|
65
|
-
readdir: () => readdir,
|
|
66
|
-
readdirSync: () => readdirSync,
|
|
67
|
-
realpath: () => realpath,
|
|
68
|
-
realpathSync: () => realpathSync,
|
|
69
|
-
rename: () => rename,
|
|
70
|
-
renameSync: () => renameSync,
|
|
71
|
-
rmdir: () => rmdir,
|
|
72
|
-
rmdirSync: () => rmdirSync,
|
|
73
|
-
stat: () => stat,
|
|
74
|
-
statSync: () => statSync,
|
|
75
|
-
unlink: () => unlink,
|
|
76
|
-
unlinkSync: () => unlinkSync,
|
|
77
|
-
writeFile: () => writeFile,
|
|
78
|
-
writeFileSync: () => writeFileSync
|
|
49
|
+
// src/server/fs/node-modules.ts
|
|
50
|
+
var fs, fsPromises;
|
|
51
|
+
var init_node_modules = __esm({
|
|
52
|
+
"src/server/fs/node-modules.ts"() {
|
|
53
|
+
"use strict";
|
|
54
|
+
init_runtime();
|
|
55
|
+
if (isNode || isBun) {
|
|
56
|
+
fs = require("fs");
|
|
57
|
+
fsPromises = require("fs/promises");
|
|
58
|
+
}
|
|
59
|
+
}
|
|
79
60
|
});
|
|
61
|
+
|
|
62
|
+
// src/server/fs/utils.ts
|
|
80
63
|
function parseOptions(options, defaultValue) {
|
|
81
64
|
return typeof options === "string" ? { encoding: options } : options || defaultValue;
|
|
82
65
|
}
|
|
@@ -95,6 +78,18 @@ function dataToUint8Array(data) {
|
|
|
95
78
|
}
|
|
96
79
|
return data;
|
|
97
80
|
}
|
|
81
|
+
function createDirentFromDenoEntry(entry) {
|
|
82
|
+
return {
|
|
83
|
+
name: entry.name,
|
|
84
|
+
isFile: () => entry.isFile,
|
|
85
|
+
isDirectory: () => entry.isDirectory,
|
|
86
|
+
isBlockDevice: () => false,
|
|
87
|
+
isCharacterDevice: () => false,
|
|
88
|
+
isSymbolicLink: () => entry.isSymlink || false,
|
|
89
|
+
isFIFO: () => false,
|
|
90
|
+
isSocket: () => false
|
|
91
|
+
};
|
|
92
|
+
}
|
|
98
93
|
function processDenoEntries(iterator, withFileTypes) {
|
|
99
94
|
const entries = [];
|
|
100
95
|
for (const entry of iterator) {
|
|
@@ -117,6 +112,42 @@ async function processDenoEntriesAsync(iterator, withFileTypes) {
|
|
|
117
112
|
}
|
|
118
113
|
return entries;
|
|
119
114
|
}
|
|
115
|
+
function createStatsFromDenoFileInfo(info) {
|
|
116
|
+
return {
|
|
117
|
+
isFile: () => info.isFile,
|
|
118
|
+
isDirectory: () => info.isDirectory,
|
|
119
|
+
isBlockDevice: () => false,
|
|
120
|
+
isCharacterDevice: () => false,
|
|
121
|
+
isSymbolicLink: () => info.isSymlink || false,
|
|
122
|
+
isFIFO: () => false,
|
|
123
|
+
isSocket: () => false,
|
|
124
|
+
dev: info.dev || 0,
|
|
125
|
+
ino: info.ino || 0,
|
|
126
|
+
mode: info.mode || 0,
|
|
127
|
+
nlink: info.nlink || 1,
|
|
128
|
+
uid: info.uid || 0,
|
|
129
|
+
gid: info.gid || 0,
|
|
130
|
+
rdev: 0,
|
|
131
|
+
size: info.size,
|
|
132
|
+
blksize: info.blksize || 4096,
|
|
133
|
+
blocks: info.blocks || Math.ceil(info.size / 512),
|
|
134
|
+
atimeMs: info.atime?.getTime() || Date.now(),
|
|
135
|
+
mtimeMs: info.mtime?.getTime() || Date.now(),
|
|
136
|
+
ctimeMs: info.birthtime?.getTime() || Date.now(),
|
|
137
|
+
birthtimeMs: info.birthtime?.getTime() || Date.now(),
|
|
138
|
+
atime: info.atime || /* @__PURE__ */ new Date(),
|
|
139
|
+
mtime: info.mtime || /* @__PURE__ */ new Date(),
|
|
140
|
+
ctime: info.birthtime || /* @__PURE__ */ new Date(),
|
|
141
|
+
birthtime: info.birthtime || /* @__PURE__ */ new Date()
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
var init_utils = __esm({
|
|
145
|
+
"src/server/fs/utils.ts"() {
|
|
146
|
+
"use strict";
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// src/server/fs/file-ops.ts
|
|
120
151
|
async function readFile(path, options) {
|
|
121
152
|
const opts = parseOptions(options, {});
|
|
122
153
|
if (isNode || isBun) {
|
|
@@ -157,28 +188,27 @@ async function appendFile(path, data, options) {
|
|
|
157
188
|
const opts = parseOptions(options, {});
|
|
158
189
|
if (isNode) {
|
|
159
190
|
return fsPromises.appendFile(path, data, opts);
|
|
191
|
+
}
|
|
192
|
+
if (await exists(path)) {
|
|
193
|
+
const existing = await readFile(path);
|
|
194
|
+
const combined = Buffer.isBuffer(existing) ? Buffer.concat([existing, Buffer.isBuffer(data) ? data : Buffer.from(data)]) : existing + (Buffer.isBuffer(data) ? data.toString() : data);
|
|
195
|
+
await writeFile(path, combined, opts);
|
|
160
196
|
} else {
|
|
161
|
-
|
|
162
|
-
const existing = await readFile(path);
|
|
163
|
-
const combined = Buffer.isBuffer(existing) ? Buffer.concat([existing, Buffer.isBuffer(data) ? data : Buffer.from(data)]) : existing + (Buffer.isBuffer(data) ? data.toString() : data);
|
|
164
|
-
await writeFile(path, combined, opts);
|
|
165
|
-
} else {
|
|
166
|
-
await writeFile(path, data, opts);
|
|
167
|
-
}
|
|
197
|
+
await writeFile(path, data, opts);
|
|
168
198
|
}
|
|
169
199
|
}
|
|
170
200
|
function appendFileSync(path, data, options) {
|
|
171
201
|
const opts = parseOptions(options, {});
|
|
172
202
|
if (isNode) {
|
|
173
203
|
fs.appendFileSync(path, data, opts);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (existsSync(path)) {
|
|
207
|
+
const existing = readFileSync(path);
|
|
208
|
+
const combined = Buffer.isBuffer(existing) ? Buffer.concat([existing, Buffer.isBuffer(data) ? data : Buffer.from(data)]) : existing + (Buffer.isBuffer(data) ? data.toString() : data);
|
|
209
|
+
writeFileSync(path, combined, opts);
|
|
174
210
|
} else {
|
|
175
|
-
|
|
176
|
-
const existing = readFileSync(path);
|
|
177
|
-
const combined = Buffer.isBuffer(existing) ? Buffer.concat([existing, Buffer.isBuffer(data) ? data : Buffer.from(data)]) : existing + (Buffer.isBuffer(data) ? data.toString() : data);
|
|
178
|
-
writeFileSync(path, combined, opts);
|
|
179
|
-
} else {
|
|
180
|
-
writeFileSync(path, data, opts);
|
|
181
|
-
}
|
|
211
|
+
writeFileSync(path, data, opts);
|
|
182
212
|
}
|
|
183
213
|
}
|
|
184
214
|
async function exists(path) {
|
|
@@ -215,6 +245,16 @@ function statSync(path) {
|
|
|
215
245
|
}
|
|
216
246
|
throw new Error("Unsupported runtime");
|
|
217
247
|
}
|
|
248
|
+
var init_file_ops = __esm({
|
|
249
|
+
"src/server/fs/file-ops.ts"() {
|
|
250
|
+
"use strict";
|
|
251
|
+
init_runtime();
|
|
252
|
+
init_node_modules();
|
|
253
|
+
init_utils();
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
// src/server/fs/directory-ops.ts
|
|
218
258
|
async function mkdir(path, options) {
|
|
219
259
|
const opts = typeof options === "number" ? { mode: options } : options || {};
|
|
220
260
|
if (isNode || isBun) {
|
|
@@ -277,6 +317,16 @@ function rmdirSync(path, options) {
|
|
|
277
317
|
Deno.removeSync(path, { recursive: options?.recursive });
|
|
278
318
|
}
|
|
279
319
|
}
|
|
320
|
+
var init_directory_ops = __esm({
|
|
321
|
+
"src/server/fs/directory-ops.ts"() {
|
|
322
|
+
"use strict";
|
|
323
|
+
init_runtime();
|
|
324
|
+
init_node_modules();
|
|
325
|
+
init_utils();
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
// src/server/fs/path-ops.ts
|
|
280
330
|
async function rename(oldPath, newPath) {
|
|
281
331
|
if (isNode || isBun) {
|
|
282
332
|
return fsPromises.rename(oldPath, newPath);
|
|
@@ -321,59 +371,59 @@ function realpathSync(path, options) {
|
|
|
321
371
|
}
|
|
322
372
|
return path;
|
|
323
373
|
}
|
|
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
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
};
|
|
364
|
-
}
|
|
374
|
+
var init_path_ops = __esm({
|
|
375
|
+
"src/server/fs/path-ops.ts"() {
|
|
376
|
+
"use strict";
|
|
377
|
+
init_runtime();
|
|
378
|
+
init_node_modules();
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
// src/server/fs/index.ts
|
|
383
|
+
var fs_exports = {};
|
|
384
|
+
__export(fs_exports, {
|
|
385
|
+
appendFile: () => appendFile,
|
|
386
|
+
appendFileSync: () => appendFileSync,
|
|
387
|
+
copyFile: () => copyFile,
|
|
388
|
+
copyFileSync: () => copyFileSync,
|
|
389
|
+
default: () => fs_default,
|
|
390
|
+
exists: () => exists,
|
|
391
|
+
existsSync: () => existsSync,
|
|
392
|
+
getRuntime: () => getRuntime,
|
|
393
|
+
mkdir: () => mkdir,
|
|
394
|
+
mkdirSync: () => mkdirSync,
|
|
395
|
+
promises: () => promises,
|
|
396
|
+
readFile: () => readFile,
|
|
397
|
+
readFileSync: () => readFileSync,
|
|
398
|
+
readdir: () => readdir,
|
|
399
|
+
readdirSync: () => readdirSync,
|
|
400
|
+
realpath: () => realpath,
|
|
401
|
+
realpathSync: () => realpathSync,
|
|
402
|
+
rename: () => rename,
|
|
403
|
+
renameSync: () => renameSync,
|
|
404
|
+
rmdir: () => rmdir,
|
|
405
|
+
rmdirSync: () => rmdirSync,
|
|
406
|
+
stat: () => stat,
|
|
407
|
+
statSync: () => statSync,
|
|
408
|
+
unlink: () => unlink,
|
|
409
|
+
unlinkSync: () => unlinkSync,
|
|
410
|
+
writeFile: () => writeFile,
|
|
411
|
+
writeFileSync: () => writeFileSync
|
|
412
|
+
});
|
|
365
413
|
function getRuntime() {
|
|
366
414
|
return runtime;
|
|
367
415
|
}
|
|
368
|
-
var
|
|
416
|
+
var promises, fs_default;
|
|
369
417
|
var init_fs = __esm({
|
|
370
|
-
"src/fs.ts"() {
|
|
418
|
+
"src/server/fs/index.ts"() {
|
|
371
419
|
"use strict";
|
|
372
420
|
init_runtime();
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
421
|
+
init_file_ops();
|
|
422
|
+
init_directory_ops();
|
|
423
|
+
init_path_ops();
|
|
424
|
+
init_file_ops();
|
|
425
|
+
init_directory_ops();
|
|
426
|
+
init_path_ops();
|
|
377
427
|
promises = {
|
|
378
428
|
readFile,
|
|
379
429
|
writeFile,
|
|
@@ -418,57 +468,59 @@ var init_fs = __esm({
|
|
|
418
468
|
}
|
|
419
469
|
});
|
|
420
470
|
|
|
421
|
-
// src/
|
|
422
|
-
var
|
|
423
|
-
__export(
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
getRuntime: () => getRuntime2,
|
|
431
|
-
isAbsolute: () => isAbsolute,
|
|
432
|
-
join: () => join,
|
|
433
|
-
normalize: () => normalize,
|
|
434
|
-
parse: () => parse,
|
|
435
|
-
posix: () => posix,
|
|
436
|
-
relative: () => relative,
|
|
437
|
-
resolve: () => resolve,
|
|
438
|
-
sep: () => sep,
|
|
439
|
-
toNamespacedPath: () => toNamespacedPath,
|
|
440
|
-
win32: () => win32
|
|
471
|
+
// src/shares/config/index.ts
|
|
472
|
+
var config_exports = {};
|
|
473
|
+
__export(config_exports, {
|
|
474
|
+
ELIT_CONFIG_FILES: () => ELIT_CONFIG_FILES,
|
|
475
|
+
defineConfig: () => defineConfig,
|
|
476
|
+
loadConfig: () => loadConfig,
|
|
477
|
+
loadEnv: () => loadEnv,
|
|
478
|
+
mergeConfig: () => mergeConfig,
|
|
479
|
+
resolveConfigPath: () => resolveConfigPath
|
|
441
480
|
});
|
|
481
|
+
module.exports = __toCommonJS(config_exports);
|
|
482
|
+
|
|
483
|
+
// src/shares/config/constants.ts
|
|
484
|
+
var ELIT_CONFIG_FILES = [
|
|
485
|
+
"elit.config.ts",
|
|
486
|
+
"elit.config.mts",
|
|
487
|
+
"elit.config.js",
|
|
488
|
+
"elit.config.mjs",
|
|
489
|
+
"elit.config.cjs",
|
|
490
|
+
"elit.config.json"
|
|
491
|
+
];
|
|
492
|
+
|
|
493
|
+
// src/shares/config/env.ts
|
|
494
|
+
init_fs();
|
|
495
|
+
|
|
496
|
+
// src/server/path/platform.ts
|
|
497
|
+
init_runtime();
|
|
442
498
|
function getSeparator(isWin) {
|
|
443
499
|
return isWin ? "\\" : "/";
|
|
444
500
|
}
|
|
445
501
|
function getCwd() {
|
|
446
502
|
if (isNode || isBun) {
|
|
447
503
|
return process.cwd();
|
|
448
|
-
}
|
|
504
|
+
}
|
|
505
|
+
if (isDeno) {
|
|
449
506
|
return Deno.cwd();
|
|
450
507
|
}
|
|
451
508
|
return "/";
|
|
452
509
|
}
|
|
510
|
+
var isWindows = (() => {
|
|
511
|
+
if (isNode) {
|
|
512
|
+
return process.platform === "win32";
|
|
513
|
+
}
|
|
514
|
+
if (isDeno) {
|
|
515
|
+
return Deno.build.os === "windows";
|
|
516
|
+
}
|
|
517
|
+
return typeof process !== "undefined" && process.platform === "win32";
|
|
518
|
+
})();
|
|
519
|
+
|
|
520
|
+
// src/server/path/operations.ts
|
|
453
521
|
function findLastSeparator(path) {
|
|
454
522
|
return Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
|
|
455
523
|
}
|
|
456
|
-
function createPathOps(isWin) {
|
|
457
|
-
return {
|
|
458
|
-
sep: getSeparator(isWin),
|
|
459
|
-
delimiter: isWin ? ";" : ":",
|
|
460
|
-
normalize: (path) => normalizePath(path, isWin),
|
|
461
|
-
join: (...paths) => joinPaths(paths, isWin),
|
|
462
|
-
resolve: (...paths) => resolvePaths(paths, isWin),
|
|
463
|
-
isAbsolute: (path) => isWin ? isAbsoluteWin(path) : isAbsolutePosix(path),
|
|
464
|
-
relative: (from, to) => relativePath(from, to, isWin),
|
|
465
|
-
dirname: (path) => getDirname(path, isWin),
|
|
466
|
-
basename: (path, ext) => getBasename(path, ext, isWin),
|
|
467
|
-
extname: (path) => getExtname(path),
|
|
468
|
-
parse: (path) => parsePath(path, isWin),
|
|
469
|
-
format: (pathObject) => formatPath(pathObject, isWin)
|
|
470
|
-
};
|
|
471
|
-
}
|
|
472
524
|
function isAbsolutePosix(path) {
|
|
473
525
|
return path.length > 0 && path[0] === "/";
|
|
474
526
|
}
|
|
@@ -492,15 +544,15 @@ function isAbsoluteWin(path) {
|
|
|
492
544
|
function normalizePath(path, isWin) {
|
|
493
545
|
if (path.length === 0) return ".";
|
|
494
546
|
const separator = getSeparator(isWin);
|
|
495
|
-
const
|
|
547
|
+
const isAbsolute = isWin ? isAbsoluteWin(path) : isAbsolutePosix(path);
|
|
496
548
|
const trailingSeparator = path[path.length - 1] === separator || isWin && path[path.length - 1] === "/";
|
|
497
|
-
|
|
549
|
+
const normalized = path.replace(isWin ? /[\/\\]+/g : /\/+/g, separator);
|
|
498
550
|
const parts = normalized.split(separator);
|
|
499
551
|
const result = [];
|
|
500
|
-
for (let
|
|
501
|
-
const part = parts[
|
|
552
|
+
for (let index = 0; index < parts.length; index++) {
|
|
553
|
+
const part = parts[index];
|
|
502
554
|
if (part === "" || part === ".") {
|
|
503
|
-
if (
|
|
555
|
+
if (index === 0 && isAbsolute) result.push("");
|
|
504
556
|
continue;
|
|
505
557
|
}
|
|
506
558
|
if (part === "..") {
|
|
@@ -508,28 +560,28 @@ function normalizePath(path, isWin) {
|
|
|
508
560
|
if (!(result.length === 1 && result[0] === "")) {
|
|
509
561
|
result.pop();
|
|
510
562
|
}
|
|
511
|
-
} else if (!
|
|
563
|
+
} else if (!isAbsolute) {
|
|
512
564
|
result.push("..");
|
|
513
565
|
}
|
|
514
566
|
} else {
|
|
515
567
|
result.push(part);
|
|
516
568
|
}
|
|
517
569
|
}
|
|
518
|
-
let
|
|
519
|
-
if (
|
|
520
|
-
return
|
|
570
|
+
let finalPath = result.join(separator);
|
|
571
|
+
if (finalPath.length === 0) {
|
|
572
|
+
return isAbsolute ? separator : ".";
|
|
521
573
|
}
|
|
522
|
-
if (trailingSeparator &&
|
|
523
|
-
|
|
574
|
+
if (trailingSeparator && finalPath[finalPath.length - 1] !== separator) {
|
|
575
|
+
finalPath += separator;
|
|
524
576
|
}
|
|
525
|
-
return
|
|
577
|
+
return finalPath;
|
|
526
578
|
}
|
|
527
579
|
function joinPaths(paths, isWin) {
|
|
528
580
|
if (paths.length === 0) return ".";
|
|
529
581
|
const separator = getSeparator(isWin);
|
|
530
582
|
let joined = "";
|
|
531
|
-
for (let
|
|
532
|
-
const path = paths[
|
|
583
|
+
for (let index = 0; index < paths.length; index++) {
|
|
584
|
+
const path = paths[index];
|
|
533
585
|
if (path && path.length > 0) {
|
|
534
586
|
if (joined.length === 0) {
|
|
535
587
|
joined = path;
|
|
@@ -544,43 +596,43 @@ function joinPaths(paths, isWin) {
|
|
|
544
596
|
function resolvePaths(paths, isWin) {
|
|
545
597
|
const separator = getSeparator(isWin);
|
|
546
598
|
let resolved = "";
|
|
547
|
-
let
|
|
548
|
-
for (let
|
|
549
|
-
const path = paths[
|
|
599
|
+
let absolute = false;
|
|
600
|
+
for (let index = paths.length - 1; index >= 0 && !absolute; index--) {
|
|
601
|
+
const path = paths[index];
|
|
550
602
|
if (path && path.length > 0) {
|
|
551
603
|
resolved = path + (resolved.length > 0 ? separator + resolved : "");
|
|
552
|
-
|
|
604
|
+
absolute = isWin ? isAbsoluteWin(resolved) : isAbsolutePosix(resolved);
|
|
553
605
|
}
|
|
554
606
|
}
|
|
555
|
-
if (!
|
|
607
|
+
if (!absolute) {
|
|
556
608
|
const cwd = getCwd();
|
|
557
609
|
resolved = cwd + (resolved.length > 0 ? separator + resolved : "");
|
|
558
610
|
}
|
|
559
611
|
return normalizePath(resolved, isWin);
|
|
560
612
|
}
|
|
561
613
|
function relativePath(from, to, isWin) {
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
if (
|
|
614
|
+
const resolvedFrom = resolvePaths([from], isWin);
|
|
615
|
+
const resolvedTo = resolvePaths([to], isWin);
|
|
616
|
+
if (resolvedFrom === resolvedTo) return "";
|
|
565
617
|
const separator = getSeparator(isWin);
|
|
566
|
-
const fromParts =
|
|
567
|
-
const toParts =
|
|
568
|
-
let commonLength = 0;
|
|
618
|
+
const fromParts = resolvedFrom.split(separator).filter((part) => part.length > 0);
|
|
619
|
+
const toParts = resolvedTo.split(separator).filter((part) => part.length > 0);
|
|
569
620
|
const minLength = Math.min(fromParts.length, toParts.length);
|
|
570
|
-
|
|
571
|
-
|
|
621
|
+
let commonLength = 0;
|
|
622
|
+
for (let index = 0; index < minLength; index++) {
|
|
623
|
+
if (fromParts[index] === toParts[index]) {
|
|
572
624
|
commonLength++;
|
|
573
625
|
} else {
|
|
574
626
|
break;
|
|
575
627
|
}
|
|
576
628
|
}
|
|
577
|
-
const upCount = fromParts.length - commonLength;
|
|
578
629
|
const result = [];
|
|
579
|
-
|
|
630
|
+
const upCount = fromParts.length - commonLength;
|
|
631
|
+
for (let index = 0; index < upCount; index++) {
|
|
580
632
|
result.push("..");
|
|
581
633
|
}
|
|
582
|
-
for (let
|
|
583
|
-
result.push(toParts[
|
|
634
|
+
for (let index = commonLength; index < toParts.length; index++) {
|
|
635
|
+
result.push(toParts[index]);
|
|
584
636
|
}
|
|
585
637
|
return result.join(separator) || ".";
|
|
586
638
|
}
|
|
@@ -588,15 +640,15 @@ function getDirname(path, isWin) {
|
|
|
588
640
|
if (path.length === 0) return ".";
|
|
589
641
|
const separator = getSeparator(isWin);
|
|
590
642
|
const normalized = normalizePath(path, isWin);
|
|
591
|
-
const
|
|
592
|
-
if (
|
|
593
|
-
if (
|
|
594
|
-
return normalized.slice(0,
|
|
643
|
+
const lastSeparatorIndex = normalized.lastIndexOf(separator);
|
|
644
|
+
if (lastSeparatorIndex === -1) return ".";
|
|
645
|
+
if (lastSeparatorIndex === 0) return separator;
|
|
646
|
+
return normalized.slice(0, lastSeparatorIndex);
|
|
595
647
|
}
|
|
596
648
|
function getBasename(path, ext, isWin) {
|
|
597
649
|
if (path.length === 0) return "";
|
|
598
|
-
const
|
|
599
|
-
let base =
|
|
650
|
+
const lastSeparatorIndex = isWin ? findLastSeparator(path) : path.lastIndexOf("/");
|
|
651
|
+
let base = lastSeparatorIndex === -1 ? path : path.slice(lastSeparatorIndex + 1);
|
|
600
652
|
if (ext && base.endsWith(ext)) {
|
|
601
653
|
base = base.slice(0, base.length - ext.length);
|
|
602
654
|
}
|
|
@@ -604,8 +656,8 @@ function getBasename(path, ext, isWin) {
|
|
|
604
656
|
}
|
|
605
657
|
function getExtname(path) {
|
|
606
658
|
const lastDotIndex = path.lastIndexOf(".");
|
|
607
|
-
const
|
|
608
|
-
if (lastDotIndex === -1 || lastDotIndex <
|
|
659
|
+
const lastSeparatorIndex = findLastSeparator(path);
|
|
660
|
+
if (lastDotIndex === -1 || lastDotIndex < lastSeparatorIndex || lastDotIndex === path.length - 1) {
|
|
609
661
|
return "";
|
|
610
662
|
}
|
|
611
663
|
return path.slice(lastDotIndex);
|
|
@@ -621,10 +673,8 @@ function parsePath(path, isWin) {
|
|
|
621
673
|
} else if (path[0] === "\\" || path[0] === "/") {
|
|
622
674
|
root = "\\";
|
|
623
675
|
}
|
|
624
|
-
} else {
|
|
625
|
-
|
|
626
|
-
root = "/";
|
|
627
|
-
}
|
|
676
|
+
} else if (path[0] === "/") {
|
|
677
|
+
root = "/";
|
|
628
678
|
}
|
|
629
679
|
const dir = getDirname(path, isWin);
|
|
630
680
|
const base = getBasename(path, void 0, isWin);
|
|
@@ -640,108 +690,113 @@ function formatPath(pathObject, isWin) {
|
|
|
640
690
|
if (dir === pathObject.root) return dir + base;
|
|
641
691
|
return dir + separator + base;
|
|
642
692
|
}
|
|
643
|
-
function
|
|
644
|
-
return
|
|
693
|
+
function createPathOps(isWin) {
|
|
694
|
+
return {
|
|
695
|
+
sep: getSeparator(isWin),
|
|
696
|
+
delimiter: isWin ? ";" : ":",
|
|
697
|
+
normalize: (path) => normalizePath(path, isWin),
|
|
698
|
+
join: (...paths) => joinPaths(paths, isWin),
|
|
699
|
+
resolve: (...paths) => resolvePaths(paths, isWin),
|
|
700
|
+
isAbsolute: (path) => isWin ? isAbsoluteWin(path) : isAbsolutePosix(path),
|
|
701
|
+
relative: (from, to) => relativePath(from, to, isWin),
|
|
702
|
+
dirname: (path) => getDirname(path, isWin),
|
|
703
|
+
basename: (path, ext) => getBasename(path, ext, isWin),
|
|
704
|
+
extname: (path) => getExtname(path),
|
|
705
|
+
parse: (path) => parsePath(path, isWin),
|
|
706
|
+
format: (pathObject) => formatPath(pathObject, isWin)
|
|
707
|
+
};
|
|
645
708
|
}
|
|
709
|
+
|
|
710
|
+
// src/server/path/runtime.ts
|
|
711
|
+
init_runtime();
|
|
712
|
+
|
|
713
|
+
// src/server/path/index.ts
|
|
714
|
+
var posix = createPathOps(false);
|
|
715
|
+
var win32 = createPathOps(true);
|
|
646
716
|
function join(...paths) {
|
|
647
717
|
return joinPaths(paths, isWindows);
|
|
648
718
|
}
|
|
649
719
|
function resolve(...paths) {
|
|
650
720
|
return resolvePaths(paths, isWindows);
|
|
651
721
|
}
|
|
652
|
-
function isAbsolute(path) {
|
|
653
|
-
return isWindows ? win32.isAbsolute(path) : posix.isAbsolute(path);
|
|
654
|
-
}
|
|
655
722
|
function relative(from, to) {
|
|
656
723
|
return relativePath(from, to, isWindows);
|
|
657
724
|
}
|
|
658
725
|
function dirname(path) {
|
|
659
726
|
return getDirname(path, isWindows);
|
|
660
727
|
}
|
|
661
|
-
|
|
662
|
-
|
|
728
|
+
|
|
729
|
+
// src/shares/config/utils.ts
|
|
730
|
+
init_fs();
|
|
731
|
+
function readFileAsString(filePath) {
|
|
732
|
+
const contentBuffer = readFileSync(filePath, "utf-8");
|
|
733
|
+
return typeof contentBuffer === "string" ? contentBuffer : contentBuffer.toString("utf-8");
|
|
663
734
|
}
|
|
664
|
-
function
|
|
665
|
-
|
|
735
|
+
function removeQuotes(value) {
|
|
736
|
+
const trimmed = value.trim();
|
|
737
|
+
if (trimmed.startsWith('"') && trimmed.endsWith('"') || trimmed.startsWith("'") && trimmed.endsWith("'")) {
|
|
738
|
+
return trimmed.slice(1, -1);
|
|
739
|
+
}
|
|
740
|
+
return trimmed;
|
|
666
741
|
}
|
|
667
|
-
function
|
|
668
|
-
|
|
742
|
+
function normalizeRelativeImportPath(fromDirectory, targetPath) {
|
|
743
|
+
const relativePath2 = relative(fromDirectory, targetPath).replace(/\\/g, "/");
|
|
744
|
+
return relativePath2.startsWith(".") ? relativePath2 : `./${relativePath2}`;
|
|
669
745
|
}
|
|
670
|
-
function
|
|
671
|
-
|
|
746
|
+
async function importConfigModule(configPath) {
|
|
747
|
+
const { pathToFileURL } = await import("url");
|
|
748
|
+
const configModule = await import(pathToFileURL(configPath).href);
|
|
749
|
+
return configModule.default || configModule;
|
|
672
750
|
}
|
|
673
|
-
function
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
if (resolved[1] === "\\" && resolved[2] !== "?") {
|
|
679
|
-
return "\\\\?\\UNC\\" + resolved.slice(2);
|
|
680
|
-
}
|
|
681
|
-
} else if (resolved[1] === ":" && resolved[2] === "\\") {
|
|
682
|
-
return "\\\\?\\" + resolved;
|
|
683
|
-
}
|
|
751
|
+
async function safeCleanup(filePath) {
|
|
752
|
+
try {
|
|
753
|
+
const { unlinkSync: unlinkSync2 } = await Promise.resolve().then(() => (init_fs(), fs_exports));
|
|
754
|
+
unlinkSync2(filePath);
|
|
755
|
+
} catch {
|
|
684
756
|
}
|
|
685
|
-
return path;
|
|
686
757
|
}
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
758
|
+
|
|
759
|
+
// src/shares/config/env.ts
|
|
760
|
+
function loadEnv(mode = "development", cwd = process.cwd()) {
|
|
761
|
+
const env = { MODE: mode };
|
|
762
|
+
const envFiles = [
|
|
763
|
+
`.env.${mode}.local`,
|
|
764
|
+
`.env.${mode}`,
|
|
765
|
+
".env.local",
|
|
766
|
+
".env"
|
|
767
|
+
];
|
|
768
|
+
for (const file of envFiles) {
|
|
769
|
+
const filePath = resolve(cwd, file);
|
|
770
|
+
if (existsSync(filePath)) {
|
|
771
|
+
const content = readFileAsString(filePath);
|
|
772
|
+
const lines = content.split("\n");
|
|
773
|
+
for (const line of lines) {
|
|
774
|
+
const trimmed = line.trim();
|
|
775
|
+
if (!trimmed || trimmed.startsWith("#")) {
|
|
776
|
+
continue;
|
|
777
|
+
}
|
|
778
|
+
const match = trimmed.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/);
|
|
779
|
+
if (match) {
|
|
780
|
+
const [, key, value] = match;
|
|
781
|
+
const cleanValue = removeQuotes(value);
|
|
782
|
+
if (!(key in env)) {
|
|
783
|
+
env[key] = cleanValue;
|
|
784
|
+
}
|
|
785
|
+
}
|
|
700
786
|
}
|
|
701
|
-
|
|
702
|
-
})();
|
|
703
|
-
sep = isWindows ? "\\" : "/";
|
|
704
|
-
delimiter = isWindows ? ";" : ":";
|
|
705
|
-
posix = createPathOps(false);
|
|
706
|
-
win32 = createPathOps(true);
|
|
707
|
-
path_default = {
|
|
708
|
-
sep,
|
|
709
|
-
delimiter,
|
|
710
|
-
normalize,
|
|
711
|
-
join,
|
|
712
|
-
resolve,
|
|
713
|
-
isAbsolute,
|
|
714
|
-
relative,
|
|
715
|
-
dirname,
|
|
716
|
-
basename,
|
|
717
|
-
extname,
|
|
718
|
-
parse,
|
|
719
|
-
format,
|
|
720
|
-
toNamespacedPath,
|
|
721
|
-
posix,
|
|
722
|
-
win32,
|
|
723
|
-
getRuntime: getRuntime2
|
|
724
|
-
};
|
|
787
|
+
}
|
|
725
788
|
}
|
|
726
|
-
|
|
789
|
+
return env;
|
|
790
|
+
}
|
|
727
791
|
|
|
728
|
-
// src/config.ts
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
defineConfig: () => defineConfig,
|
|
733
|
-
loadConfig: () => loadConfig,
|
|
734
|
-
loadEnv: () => loadEnv,
|
|
735
|
-
mergeConfig: () => mergeConfig,
|
|
736
|
-
resolveConfigPath: () => resolveConfigPath
|
|
737
|
-
});
|
|
738
|
-
module.exports = __toCommonJS(config_exports);
|
|
792
|
+
// src/shares/config/loader.ts
|
|
793
|
+
init_fs();
|
|
794
|
+
|
|
795
|
+
// src/shares/workspace-package/roots.ts
|
|
739
796
|
init_fs();
|
|
740
|
-
init_path();
|
|
741
797
|
|
|
742
|
-
// src/workspace-package.ts
|
|
798
|
+
// src/shares/workspace-package/package-json.ts
|
|
743
799
|
init_fs();
|
|
744
|
-
init_path();
|
|
745
800
|
function readPackageJson(filePath) {
|
|
746
801
|
try {
|
|
747
802
|
const packageJsonBuffer = readFileSync(filePath, "utf-8");
|
|
@@ -751,13 +806,14 @@ function readPackageJson(filePath) {
|
|
|
751
806
|
return void 0;
|
|
752
807
|
}
|
|
753
808
|
}
|
|
754
|
-
|
|
809
|
+
|
|
810
|
+
// src/shares/workspace-package/roots.ts
|
|
811
|
+
function findPackageDirectory(startDir, resolveMatch) {
|
|
755
812
|
let currentDir = resolve(startDir);
|
|
756
813
|
while (true) {
|
|
757
|
-
const
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
return currentDir;
|
|
814
|
+
const match = resolveMatch(currentDir);
|
|
815
|
+
if (match) {
|
|
816
|
+
return match;
|
|
761
817
|
}
|
|
762
818
|
const parentDir = dirname(currentDir);
|
|
763
819
|
if (parentDir === currentDir) {
|
|
@@ -766,20 +822,24 @@ function findWorkspacePackageRoot(startDir, packageName) {
|
|
|
766
822
|
currentDir = parentDir;
|
|
767
823
|
}
|
|
768
824
|
}
|
|
825
|
+
function findWorkspacePackageRoot(startDir, packageName) {
|
|
826
|
+
return findPackageDirectory(startDir, (currentDir) => {
|
|
827
|
+
const packageJsonPath = join(currentDir, "package.json");
|
|
828
|
+
const packageJson = existsSync(packageJsonPath) ? readPackageJson(packageJsonPath) : void 0;
|
|
829
|
+
return packageJson?.name === packageName ? currentDir : void 0;
|
|
830
|
+
});
|
|
831
|
+
}
|
|
769
832
|
function findInstalledPackageRoot(startDir, packageName) {
|
|
770
|
-
|
|
771
|
-
while (true) {
|
|
833
|
+
return findPackageDirectory(startDir, (currentDir) => {
|
|
772
834
|
const candidate = join(currentDir, "node_modules", ...packageName.split("/"));
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
}
|
|
776
|
-
const parentDir = dirname(currentDir);
|
|
777
|
-
if (parentDir === currentDir) {
|
|
778
|
-
return void 0;
|
|
779
|
-
}
|
|
780
|
-
currentDir = parentDir;
|
|
781
|
-
}
|
|
835
|
+
return existsSync(candidate) ? candidate : void 0;
|
|
836
|
+
});
|
|
782
837
|
}
|
|
838
|
+
|
|
839
|
+
// src/shares/workspace-package/resolve.ts
|
|
840
|
+
init_fs();
|
|
841
|
+
|
|
842
|
+
// src/shares/workspace-package/candidates.ts
|
|
783
843
|
function getWorkspacePackageImportCandidates(packageRoot, specifier, options = {}) {
|
|
784
844
|
const subpath = specifier === "elit" ? "index" : specifier.slice("elit/".length);
|
|
785
845
|
const builtCandidates = options.preferredBuiltFormat === "cjs" ? [
|
|
@@ -797,14 +857,24 @@ function getWorkspacePackageImportCandidates(packageRoot, specifier, options = {
|
|
|
797
857
|
];
|
|
798
858
|
return options.preferBuilt ? [...builtCandidates, ...sourceCandidates] : [...sourceCandidates, ...builtCandidates];
|
|
799
859
|
}
|
|
860
|
+
|
|
861
|
+
// src/shares/workspace-package/resolve.ts
|
|
862
|
+
function isWorkspacePackageSpecifier(specifier) {
|
|
863
|
+
return specifier === "elit" || specifier.startsWith("elit/");
|
|
864
|
+
}
|
|
800
865
|
function resolveWorkspacePackageImport(specifier, startDir, options = {}) {
|
|
801
|
-
if (
|
|
866
|
+
if (!isWorkspacePackageSpecifier(specifier)) {
|
|
802
867
|
return void 0;
|
|
803
868
|
}
|
|
804
|
-
const packageRoots =
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
869
|
+
const packageRoots = /* @__PURE__ */ new Set();
|
|
870
|
+
const workspacePackageRoot = findWorkspacePackageRoot(startDir, "elit");
|
|
871
|
+
const installedPackageRoot = findInstalledPackageRoot(startDir, "elit");
|
|
872
|
+
if (workspacePackageRoot) {
|
|
873
|
+
packageRoots.add(workspacePackageRoot);
|
|
874
|
+
}
|
|
875
|
+
if (installedPackageRoot) {
|
|
876
|
+
packageRoots.add(installedPackageRoot);
|
|
877
|
+
}
|
|
808
878
|
for (const packageRoot of packageRoots) {
|
|
809
879
|
for (const candidate of getWorkspacePackageImportCandidates(packageRoot, specifier, options)) {
|
|
810
880
|
if (existsSync(candidate)) {
|
|
@@ -815,45 +885,7 @@ function resolveWorkspacePackageImport(specifier, startDir, options = {}) {
|
|
|
815
885
|
return void 0;
|
|
816
886
|
}
|
|
817
887
|
|
|
818
|
-
// src/config.ts
|
|
819
|
-
function readFileAsString(filePath) {
|
|
820
|
-
const contentBuffer = readFileSync(filePath, "utf-8");
|
|
821
|
-
return typeof contentBuffer === "string" ? contentBuffer : contentBuffer.toString("utf-8");
|
|
822
|
-
}
|
|
823
|
-
function removeQuotes(value) {
|
|
824
|
-
const trimmed = value.trim();
|
|
825
|
-
if (trimmed.startsWith('"') && trimmed.endsWith('"') || trimmed.startsWith("'") && trimmed.endsWith("'")) {
|
|
826
|
-
return trimmed.slice(1, -1);
|
|
827
|
-
}
|
|
828
|
-
return trimmed;
|
|
829
|
-
}
|
|
830
|
-
function normalizeRelativeImportPath(fromDirectory, targetPath) {
|
|
831
|
-
const relativePath2 = relative(fromDirectory, targetPath).replace(/\\/g, "/");
|
|
832
|
-
return relativePath2.startsWith(".") ? relativePath2 : `./${relativePath2}`;
|
|
833
|
-
}
|
|
834
|
-
async function importConfigModule(configPath) {
|
|
835
|
-
const { pathToFileURL } = await import("url");
|
|
836
|
-
const configModule = await import(pathToFileURL(configPath).href);
|
|
837
|
-
return configModule.default || configModule;
|
|
838
|
-
}
|
|
839
|
-
async function safeCleanup(filePath) {
|
|
840
|
-
try {
|
|
841
|
-
const { unlinkSync: unlinkSync2 } = await Promise.resolve().then(() => (init_fs(), fs_exports));
|
|
842
|
-
unlinkSync2(filePath);
|
|
843
|
-
} catch {
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
function defineConfig(config) {
|
|
847
|
-
return config;
|
|
848
|
-
}
|
|
849
|
-
var ELIT_CONFIG_FILES = [
|
|
850
|
-
"elit.config.ts",
|
|
851
|
-
"elit.config.mts",
|
|
852
|
-
"elit.config.js",
|
|
853
|
-
"elit.config.mjs",
|
|
854
|
-
"elit.config.cjs",
|
|
855
|
-
"elit.config.json"
|
|
856
|
-
];
|
|
888
|
+
// src/shares/config/loader.ts
|
|
857
889
|
function resolveConfigPath(cwd = process.cwd()) {
|
|
858
890
|
for (const configFile of ELIT_CONFIG_FILES) {
|
|
859
891
|
const configPath = resolve(cwd, configFile);
|
|
@@ -863,35 +895,6 @@ function resolveConfigPath(cwd = process.cwd()) {
|
|
|
863
895
|
}
|
|
864
896
|
return null;
|
|
865
897
|
}
|
|
866
|
-
function loadEnv(mode = "development", cwd = process.cwd()) {
|
|
867
|
-
const env = { MODE: mode };
|
|
868
|
-
const envFiles = [
|
|
869
|
-
`.env.${mode}.local`,
|
|
870
|
-
`.env.${mode}`,
|
|
871
|
-
`.env.local`,
|
|
872
|
-
`.env`
|
|
873
|
-
];
|
|
874
|
-
for (const file of envFiles) {
|
|
875
|
-
const filePath = resolve(cwd, file);
|
|
876
|
-
if (existsSync(filePath)) {
|
|
877
|
-
const content = readFileAsString(filePath);
|
|
878
|
-
const lines = content.split("\n");
|
|
879
|
-
for (const line of lines) {
|
|
880
|
-
const trimmed = line.trim();
|
|
881
|
-
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
882
|
-
const match = trimmed.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/);
|
|
883
|
-
if (match) {
|
|
884
|
-
const [, key, value] = match;
|
|
885
|
-
const cleanValue = removeQuotes(value);
|
|
886
|
-
if (!(key in env)) {
|
|
887
|
-
env[key] = cleanValue;
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
return env;
|
|
894
|
-
}
|
|
895
898
|
async function loadConfig(cwd = process.cwd()) {
|
|
896
899
|
const configPath = resolveConfigPath(cwd);
|
|
897
900
|
if (configPath) {
|
|
@@ -910,16 +913,16 @@ async function loadConfigFile(configPath) {
|
|
|
910
913
|
if (ext === "json") {
|
|
911
914
|
const content = readFileAsString(configPath);
|
|
912
915
|
return JSON.parse(content);
|
|
913
|
-
}
|
|
916
|
+
}
|
|
917
|
+
if (ext === "ts" || ext === "mts") {
|
|
914
918
|
try {
|
|
915
919
|
const { build } = await import("esbuild");
|
|
916
|
-
const
|
|
917
|
-
const
|
|
918
|
-
const tempFile = join2(configDir, `.elit-config-${Date.now()}.mjs`);
|
|
920
|
+
const configDir = dirname(configPath);
|
|
921
|
+
const tempFile = join(configDir, `.elit-config-${Date.now()}.mjs`);
|
|
919
922
|
const externalAllPlugin = {
|
|
920
923
|
name: "external-all",
|
|
921
|
-
setup(
|
|
922
|
-
|
|
924
|
+
setup(buildContext) {
|
|
925
|
+
buildContext.onResolve({ filter: /.*/ }, (args) => {
|
|
923
926
|
const workspacePackageImport = resolveWorkspacePackageImport(args.path, args.resolveDir || configDir, {
|
|
924
927
|
preferBuilt: true,
|
|
925
928
|
preferredBuiltFormat: "esm"
|
|
@@ -959,7 +962,6 @@ async function loadConfigFile(configPath) {
|
|
|
959
962
|
write: true,
|
|
960
963
|
target: "es2020",
|
|
961
964
|
plugins: [externalAllPlugin],
|
|
962
|
-
// External Node.js built-ins and runtime-specific packages
|
|
963
965
|
external: [
|
|
964
966
|
"node:*",
|
|
965
967
|
"fs",
|
|
@@ -974,7 +976,6 @@ async function loadConfigFile(configPath) {
|
|
|
974
976
|
"deno",
|
|
975
977
|
"deno:*"
|
|
976
978
|
],
|
|
977
|
-
// Use the config directory as the working directory for resolution
|
|
978
979
|
absWorkingDir: configDir
|
|
979
980
|
});
|
|
980
981
|
const config = await importConfigModule(tempFile);
|
|
@@ -985,10 +986,11 @@ async function loadConfigFile(configPath) {
|
|
|
985
986
|
console.error("You can use a .js, .mjs, or .json config file instead.");
|
|
986
987
|
throw error;
|
|
987
988
|
}
|
|
988
|
-
} else {
|
|
989
|
-
return await importConfigModule(configPath);
|
|
990
989
|
}
|
|
990
|
+
return await importConfigModule(configPath);
|
|
991
991
|
}
|
|
992
|
+
|
|
993
|
+
// src/shares/config/merge.ts
|
|
992
994
|
function mergeConfig(config, cliArgs) {
|
|
993
995
|
if (!config) {
|
|
994
996
|
return cliArgs;
|
|
@@ -996,10 +998,15 @@ function mergeConfig(config, cliArgs) {
|
|
|
996
998
|
return {
|
|
997
999
|
...config,
|
|
998
1000
|
...Object.fromEntries(
|
|
999
|
-
Object.entries(cliArgs).filter(([_,
|
|
1001
|
+
Object.entries(cliArgs).filter(([_, value]) => value !== void 0)
|
|
1000
1002
|
)
|
|
1001
1003
|
};
|
|
1002
1004
|
}
|
|
1005
|
+
|
|
1006
|
+
// src/shares/config/types.ts
|
|
1007
|
+
function defineConfig(config) {
|
|
1008
|
+
return config;
|
|
1009
|
+
}
|
|
1003
1010
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1004
1011
|
0 && (module.exports = {
|
|
1005
1012
|
ELIT_CONFIG_FILES,
|