@bamboocss/node 1.60.1 → 1.60.3
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/dist/index.cjs +169 -87
- package/dist/index.d.cts +7 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.mjs +169 -87
- package/dist/native/darwin-arm64.node +0 -0
- package/dist/native/darwin-x64.node +0 -0
- package/dist/native/linux-arm64-gnu.node +0 -0
- package/dist/native/linux-arm64-musl.node +0 -0
- package/dist/native/linux-x64-gnu.node +0 -0
- package/dist/native/linux-x64-musl.node +0 -0
- package/dist/native/win32-arm64-msvc.node +0 -0
- package/dist/native/win32-x64-msvc.node +0 -0
- package/package.json +12 -12
package/dist/index.cjs
CHANGED
|
@@ -1196,13 +1196,42 @@ const prepareAstroTemplate = (source) => {
|
|
|
1196
1196
|
};
|
|
1197
1197
|
//#endregion
|
|
1198
1198
|
//#region src/native-extractor.ts
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1199
|
+
/**
|
|
1200
|
+
* The binaries the release workflow builds into `dist/native`, by platform and architecture and,
|
|
1201
|
+
* on Linux, the C library Node runs on. `__tests__/native-binaries.test.ts` holds the workflow to
|
|
1202
|
+
* building and shipping every one.
|
|
1203
|
+
*/
|
|
1204
|
+
const NATIVE_BINARIES = {
|
|
1205
|
+
"darwin-arm64": "darwin-arm64.node",
|
|
1206
|
+
"darwin-x64": "darwin-x64.node",
|
|
1207
|
+
"linux-arm64-gnu": "linux-arm64-gnu.node",
|
|
1208
|
+
"linux-arm64-musl": "linux-arm64-musl.node",
|
|
1209
|
+
"linux-x64-gnu": "linux-x64-gnu.node",
|
|
1210
|
+
"linux-x64-musl": "linux-x64-musl.node",
|
|
1211
|
+
"win32-arm64": "win32-arm64-msvc.node",
|
|
1212
|
+
"win32-x64": "win32-x64-msvc.node"
|
|
1205
1213
|
};
|
|
1214
|
+
let musl;
|
|
1215
|
+
/**
|
|
1216
|
+
* Whether Node runs on musl, as on Alpine. A gnu binary fails there on x64, naming glibc's dynamic
|
|
1217
|
+
* loader, and loads on arm64 only because musl's does not check the glibc versions it asks for.
|
|
1218
|
+
*
|
|
1219
|
+
* Alpine's `ldd` is musl's own loader and glibc's is a script naming glibc, so reading it answers
|
|
1220
|
+
* without starting anything. Without one, as in a distroless image, the report Node writes names
|
|
1221
|
+
* the glibc it runs on, and has none to name under musl.
|
|
1222
|
+
*/
|
|
1223
|
+
const isMusl = () => {
|
|
1224
|
+
if (musl !== void 0) return musl;
|
|
1225
|
+
try {
|
|
1226
|
+
musl = (0, node_fs.readFileSync)("/usr/bin/ldd", "utf8").includes("musl");
|
|
1227
|
+
} catch {
|
|
1228
|
+
const report = process.report?.getReport();
|
|
1229
|
+
musl = report?.header !== void 0 && !report.header.glibcVersionRuntime;
|
|
1230
|
+
}
|
|
1231
|
+
return musl;
|
|
1232
|
+
};
|
|
1233
|
+
/** This machine's binary in `dist/native`, or undefined where the release builds none. */
|
|
1234
|
+
const nativeBinaryName = () => NATIVE_BINARIES[process.platform === "linux" ? `linux-${process.arch}-${isMusl() ? "musl" : "gnu"}` : `${process.platform}-${process.arch}`];
|
|
1206
1235
|
/** Load the required Rust extractor from the workspace or the published prebuild directory. */
|
|
1207
1236
|
const loadNativeExtractor = () => {
|
|
1208
1237
|
const nativeRequire = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
@@ -1416,6 +1445,13 @@ const EMITTED = [
|
|
|
1416
1445
|
".js",
|
|
1417
1446
|
".jsx"
|
|
1418
1447
|
]],
|
|
1448
|
+
[".jsx", [
|
|
1449
|
+
".tsx",
|
|
1450
|
+
".ts",
|
|
1451
|
+
".d.ts",
|
|
1452
|
+
".jsx",
|
|
1453
|
+
".js"
|
|
1454
|
+
]],
|
|
1419
1455
|
[".mjs", [
|
|
1420
1456
|
".mts",
|
|
1421
1457
|
".d.mts",
|
|
@@ -3400,89 +3436,125 @@ const slashes = (path) => path.replaceAll("\\", "/");
|
|
|
3400
3436
|
* ends in one already — and spelled as every path here is, with `/`.
|
|
3401
3437
|
*/
|
|
3402
3438
|
const entryPath = (directory, name) => slashes(directory.endsWith("/") ? directory + name : `${directory}/${name}`);
|
|
3403
|
-
|
|
3439
|
+
/** Where a folder really is, or as spelled if the system cannot say. */
|
|
3440
|
+
const realOf = (directory) => {
|
|
3441
|
+
try {
|
|
3442
|
+
return slashes(node_fs.realpathSync.native(directory));
|
|
3443
|
+
} catch {
|
|
3444
|
+
return directory;
|
|
3445
|
+
}
|
|
3446
|
+
};
|
|
3447
|
+
/** `entries` as `readdirSync` hands them over, named alone unless asked for their types. */
|
|
3448
|
+
const answer = (entries, options) => options?.withFileTypes ? entries : entries.map((entry) => entry.name);
|
|
3404
3449
|
/**
|
|
3405
|
-
* One walk
|
|
3450
|
+
* One walk of the source glob, which enters each real folder once.
|
|
3406
3451
|
*
|
|
3407
3452
|
* The glob follows symbolic links — how a workspace package or a folder linked into `src` is read
|
|
3408
|
-
* at all — and
|
|
3409
|
-
*
|
|
3410
|
-
*
|
|
3411
|
-
*
|
|
3412
|
-
*
|
|
3413
|
-
*
|
|
3414
|
-
*
|
|
3453
|
+
* at all — and it followed every path through them. A link back into a folder the walk was inside
|
|
3454
|
+
* took it round again, until the system would resolve no deeper a chain of links; and in a pnpm
|
|
3455
|
+
* workspace, where each package's `node_modules` links its siblings, an include reaching each
|
|
3456
|
+
* package's `src` through `../**` went through every sequence of them: 13,699 paths to 7 files, and
|
|
3457
|
+
* 109,600 and a minute for 8. Extraction read each real file once, so what came of the walk was its
|
|
3458
|
+
* time, and a watch on every path.
|
|
3459
|
+
*
|
|
3460
|
+
* So each real folder is entered once. The plain ones first: the walk reads no link, and sets aside
|
|
3461
|
+
* each one it would enter, so a file it can reach directly is found where it really is. Then each
|
|
3462
|
+
* link set aside, in order of its path and round by round as links within them turn up: one leading
|
|
3463
|
+
* to a folder entered already is read as empty, as `find -L` reads a loop, and one leading anywhere
|
|
3464
|
+
* else is walked, through the folders above it and nothing else of them. A link to a file is a file,
|
|
3465
|
+
* and found as before.
|
|
3466
|
+
*
|
|
3467
|
+
* What that gives up is a second spelling of one folder: two links in one walk to a folder outside
|
|
3468
|
+
* it find it by the first. Patterns walked apart, `src/**` and `vendor/**`, still find it by each.
|
|
3415
3469
|
*
|
|
3416
|
-
*
|
|
3417
|
-
*
|
|
3418
|
-
* folders above it are stat'd once each — mostly, just the one the walk began at — and a real path
|
|
3419
|
-
* is resolved only where two of those match, to tell apart inodes too large to be told apart.
|
|
3470
|
+
* `linked` is where the walk began, and each folder and file it reached through a link, as it spelled
|
|
3471
|
+
* them: where a path it found may really be elsewhere.
|
|
3420
3472
|
*/
|
|
3421
|
-
const
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
const links = /* @__PURE__ */ new Map();
|
|
3425
|
-
const identityOf = (directory) => {
|
|
3426
|
-
const walked = directories.get(directory);
|
|
3427
|
-
if (walked.identity === void 0) try {
|
|
3428
|
-
walked.identity = walked.link && links.get(directory) || identify((0, node_fs.statSync)(directory));
|
|
3429
|
-
} catch {
|
|
3430
|
-
walked.identity = directory;
|
|
3431
|
-
}
|
|
3432
|
-
return walked.identity;
|
|
3433
|
-
};
|
|
3434
|
-
const realDirectory = (directory) => {
|
|
3435
|
-
const walked = directories.get(directory);
|
|
3436
|
-
if (walked.real === void 0) try {
|
|
3437
|
-
walked.real = slashes(node_fs.realpathSync.native(directory));
|
|
3438
|
-
} catch {
|
|
3439
|
-
walked.real = directory;
|
|
3440
|
-
}
|
|
3441
|
-
return walked.real;
|
|
3442
|
-
};
|
|
3443
|
-
const readdir = ((path, options) => {
|
|
3444
|
-
const directory = slashes(String(path));
|
|
3445
|
-
const cut = directory.lastIndexOf("/");
|
|
3446
|
-
const above = directory.slice(0, cut);
|
|
3447
|
-
const parent = directories.has(above) ? above : directories.has(directory.slice(0, cut + 1)) ? directory.slice(0, cut + 1) : void 0;
|
|
3448
|
-
const link = links.has(directory);
|
|
3449
|
-
directories.set(directory, {
|
|
3450
|
-
link,
|
|
3451
|
-
parent
|
|
3452
|
-
});
|
|
3453
|
-
if (link) for (let ancestor = parent; ancestor !== void 0; ancestor = directories.get(ancestor).parent) {
|
|
3454
|
-
if (identityOf(ancestor) !== identityOf(directory)) continue;
|
|
3455
|
-
if (realDirectory(ancestor) !== realDirectory(directory)) continue;
|
|
3456
|
-
_bamboocss_logger.logger.debug("glob", `${directory} leads back into ${ancestor}, which is read already`);
|
|
3457
|
-
directories.get(directory).cut = true;
|
|
3458
|
-
return [];
|
|
3459
|
-
}
|
|
3460
|
-
const entries = (0, node_fs.readdirSync)(path, { withFileTypes: true });
|
|
3461
|
-
for (const entry of entries) if (entry.isSymbolicLink()) links.set(entryPath(String(path), entry.name), void 0);
|
|
3462
|
-
return options?.withFileTypes ? entries : entries.map((entry) => entry.name);
|
|
3463
|
-
});
|
|
3473
|
+
const globEachFolderOnce = (patterns, cwd) => {
|
|
3474
|
+
/** Every entry listed that is a symbolic link, by its path. */
|
|
3475
|
+
const links = /* @__PURE__ */ new Set();
|
|
3464
3476
|
/** Every entry listed as a link that is one to a file. */
|
|
3465
3477
|
const fileLinks = /* @__PURE__ */ new Set();
|
|
3478
|
+
/** Every real folder entered. */
|
|
3479
|
+
const entered = /* @__PURE__ */ new Set();
|
|
3480
|
+
/** Links to folders the walk would have entered, to look at once the folders before them are read. */
|
|
3481
|
+
let aside = [];
|
|
3482
|
+
const linked = [];
|
|
3483
|
+
const list = (directory) => {
|
|
3484
|
+
const entries = (0, node_fs.readdirSync)(directory, { withFileTypes: true });
|
|
3485
|
+
for (const entry of entries) if (entry.isSymbolicLink()) links.add(entryPath(directory, entry.name));
|
|
3486
|
+
return entries;
|
|
3487
|
+
};
|
|
3466
3488
|
const stat = ((path, options) => {
|
|
3467
3489
|
const stats = (0, node_fs.statSync)(path, options);
|
|
3468
3490
|
const key = slashes(String(path));
|
|
3469
|
-
if (stats && links.has(key))
|
|
3470
|
-
links.set(key, identify(stats));
|
|
3471
|
-
if (stats.isFile()) fileLinks.add(key);
|
|
3472
|
-
}
|
|
3491
|
+
if (stats && links.has(key) && stats.isFile()) fileLinks.add(key);
|
|
3473
3492
|
return stats;
|
|
3474
3493
|
});
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3494
|
+
let root;
|
|
3495
|
+
let rootReal = "";
|
|
3496
|
+
const plain = ((path, options) => {
|
|
3497
|
+
const directory = slashes(String(path));
|
|
3498
|
+
if (root === void 0) {
|
|
3499
|
+
root = directory;
|
|
3500
|
+
rootReal = realOf(directory);
|
|
3501
|
+
linked.push(directory);
|
|
3502
|
+
} else if (links.has(directory)) {
|
|
3503
|
+
aside.push(directory);
|
|
3504
|
+
return [];
|
|
3505
|
+
}
|
|
3506
|
+
entered.add(rootReal + directory.slice(root.length));
|
|
3507
|
+
return answer(list(directory), options);
|
|
3508
|
+
});
|
|
3509
|
+
const found = [fast_glob.default.sync(patterns, {
|
|
3510
|
+
absolute: true,
|
|
3511
|
+
cwd,
|
|
3482
3512
|
fs: {
|
|
3483
|
-
readdirSync:
|
|
3513
|
+
readdirSync: plain,
|
|
3484
3514
|
statSync: stat
|
|
3485
3515
|
}
|
|
3516
|
+
})];
|
|
3517
|
+
while (aside.length) {
|
|
3518
|
+
const round = [...new Set(aside)].sort();
|
|
3519
|
+
aside = [];
|
|
3520
|
+
for (const link of round) {
|
|
3521
|
+
const real = realOf(link);
|
|
3522
|
+
if (entered.has(real)) {
|
|
3523
|
+
_bamboocss_logger.logger.debug("glob", `${link} leads to ${real}, which is read already`);
|
|
3524
|
+
continue;
|
|
3525
|
+
}
|
|
3526
|
+
const inside = `${link}/`;
|
|
3527
|
+
const through = ((path, options) => {
|
|
3528
|
+
const directory = slashes(String(path));
|
|
3529
|
+
if (directory === link || directory.startsWith(inside)) {
|
|
3530
|
+
if (directory !== link && links.has(directory)) {
|
|
3531
|
+
aside.push(directory);
|
|
3532
|
+
return [];
|
|
3533
|
+
}
|
|
3534
|
+
const folder = real + directory.slice(link.length);
|
|
3535
|
+
if (entered.has(folder)) return [];
|
|
3536
|
+
entered.add(folder);
|
|
3537
|
+
if (directory === link) linked.push(link);
|
|
3538
|
+
return answer(list(directory), options);
|
|
3539
|
+
}
|
|
3540
|
+
const above = directory.endsWith("/") ? directory : `${directory}/`;
|
|
3541
|
+
if (!link.startsWith(above)) return [];
|
|
3542
|
+
const next = link.slice(above.length).split("/", 1)[0];
|
|
3543
|
+
return answer((0, node_fs.readdirSync)(directory, { withFileTypes: true }).filter((entry) => entry.name === next), options);
|
|
3544
|
+
});
|
|
3545
|
+
found.push(fast_glob.default.sync(patterns, {
|
|
3546
|
+
absolute: true,
|
|
3547
|
+
cwd,
|
|
3548
|
+
fs: {
|
|
3549
|
+
readdirSync: through,
|
|
3550
|
+
statSync: stat
|
|
3551
|
+
}
|
|
3552
|
+
}));
|
|
3553
|
+
}
|
|
3554
|
+
}
|
|
3555
|
+
return {
|
|
3556
|
+
found: found.length === 1 ? found[0] : found.flat(),
|
|
3557
|
+
linked: [...linked, ...fileLinks]
|
|
3486
3558
|
};
|
|
3487
3559
|
};
|
|
3488
3560
|
/**
|
|
@@ -3531,14 +3603,9 @@ const nodeRuntime = {
|
|
|
3531
3603
|
})) {
|
|
3532
3604
|
const negatives = task.negative.map((pattern) => `!${pattern}`);
|
|
3533
3605
|
for (const patterns of byOwnBase(task, cwd)) {
|
|
3534
|
-
const walk =
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
cwd,
|
|
3538
|
-
fs: walk.fs
|
|
3539
|
-
});
|
|
3540
|
-
walks.push(found);
|
|
3541
|
-
opts.linked?.push(...walk.linked(), ...task.dynamic ? [] : found);
|
|
3606
|
+
const walk = globEachFolderOnce([...patterns, ...negatives], cwd);
|
|
3607
|
+
walks.push(walk.found);
|
|
3608
|
+
opts.linked?.push(...walk.linked, ...task.dynamic ? [] : walk.found);
|
|
3542
3609
|
}
|
|
3543
3610
|
}
|
|
3544
3611
|
const files = sortSources(walks.length === 1 ? walks[0] : walks.flat());
|
|
@@ -3603,8 +3670,9 @@ const slashed = (path) => path.replaceAll("\\", "/");
|
|
|
3603
3670
|
* The files, each real one once: under the first of the paths the glob reached it by.
|
|
3604
3671
|
*
|
|
3605
3672
|
* Two links in `include` to one folder — `src/shared` and `vendor/shared`, a package linked twice —
|
|
3606
|
-
* and the inventory holds each of its files under both, as
|
|
3607
|
-
* which is how the watcher and a bundler naming a module have to find it.
|
|
3673
|
+
* and the inventory holds each of its files under both, as two patterns walked apart each find it,
|
|
3674
|
+
* which is how the watcher and a bundler naming a module have to find it. One walk enters a folder
|
|
3675
|
+
* once, so a single pattern finds it by one path. Extracted, each was
|
|
3608
3676
|
* read twice for the same styles. The first of them in the inventory's order is the one kept: an
|
|
3609
3677
|
* atom sits at the rank of the earliest file that wrote it, which is that one, so the stylesheet's
|
|
3610
3678
|
* order is as it was.
|
|
@@ -3758,6 +3826,20 @@ var OutputEngine = class {
|
|
|
3758
3826
|
}));
|
|
3759
3827
|
};
|
|
3760
3828
|
/**
|
|
3829
|
+
* Write one file outside an artifact — `cssgen -o`, the stylesheet `bamboo --watch` rebuilds —
|
|
3830
|
+
* unless it holds exactly that already. They wrote it whatever it held, so every rebuild touched
|
|
3831
|
+
* the stylesheet a dev server or a bundler watches, and each of them did its work over for it.
|
|
3832
|
+
* Whether it was written is the answer.
|
|
3833
|
+
*/
|
|
3834
|
+
writeFile = async (absPath, code) => {
|
|
3835
|
+
if (this.isUnchanged(absPath, code)) {
|
|
3836
|
+
_bamboocss_logger.logger.debug("write:unchanged", absPath);
|
|
3837
|
+
return false;
|
|
3838
|
+
}
|
|
3839
|
+
await this.fs.writeFile(absPath, code);
|
|
3840
|
+
return true;
|
|
3841
|
+
};
|
|
3842
|
+
/**
|
|
3761
3843
|
* Whether the file on disk already holds exactly what codegen would write.
|
|
3762
3844
|
*
|
|
3763
3845
|
* Not for the write itself, which is cheap — 54 artifacts and 1.4 MB measure ~6ms, against
|
|
@@ -6220,7 +6302,7 @@ const cssgen = async (ctx, options) => {
|
|
|
6220
6302
|
if (outfile) {
|
|
6221
6303
|
const css = ctx.getCss(sheet);
|
|
6222
6304
|
_bamboocss_logger.logger.info("css", ctx.runtime.path.resolve(outfile));
|
|
6223
|
-
await ctx.
|
|
6305
|
+
await ctx.output.writeFile(outfile, css);
|
|
6224
6306
|
} else await ctx.writeCss(sheet);
|
|
6225
6307
|
done();
|
|
6226
6308
|
} else {
|
|
@@ -6234,7 +6316,7 @@ const cssgen = async (ctx, options) => {
|
|
|
6234
6316
|
else if (outfile) {
|
|
6235
6317
|
const css = ctx.getCss(sheet);
|
|
6236
6318
|
_bamboocss_logger.logger.info("css", ctx.runtime.path.resolve(outfile));
|
|
6237
|
-
await ctx.
|
|
6319
|
+
await ctx.output.writeFile(outfile, css);
|
|
6238
6320
|
} else await ctx.writeCss(sheet);
|
|
6239
6321
|
done();
|
|
6240
6322
|
}
|
|
@@ -6596,7 +6678,7 @@ async function generate(config, configPath, options = {}) {
|
|
|
6596
6678
|
sourceScanCache
|
|
6597
6679
|
});
|
|
6598
6680
|
const css = ctx.getCss(sheet);
|
|
6599
|
-
await ctx.
|
|
6681
|
+
await ctx.output.writeFile(outfile, css);
|
|
6600
6682
|
done();
|
|
6601
6683
|
};
|
|
6602
6684
|
ctx.watchFiles(async (event, file) => {
|
package/dist/index.d.cts
CHANGED
|
@@ -490,6 +490,13 @@ declare class OutputEngine {
|
|
|
490
490
|
stale: string[];
|
|
491
491
|
};
|
|
492
492
|
write: (output: Artifact | undefined) => Promise<PromiseSettledResult<void>[]> | undefined;
|
|
493
|
+
/**
|
|
494
|
+
* Write one file outside an artifact — `cssgen -o`, the stylesheet `bamboo --watch` rebuilds —
|
|
495
|
+
* unless it holds exactly that already. They wrote it whatever it held, so every rebuild touched
|
|
496
|
+
* the stylesheet a dev server or a bundler watches, and each of them did its work over for it.
|
|
497
|
+
* Whether it was written is the answer.
|
|
498
|
+
*/
|
|
499
|
+
writeFile: (absPath: string, code: string) => Promise<boolean>;
|
|
493
500
|
/**
|
|
494
501
|
* Whether the file on disk already holds exactly what codegen would write.
|
|
495
502
|
*
|
package/dist/index.d.mts
CHANGED
|
@@ -490,6 +490,13 @@ declare class OutputEngine {
|
|
|
490
490
|
stale: string[];
|
|
491
491
|
};
|
|
492
492
|
write: (output: Artifact | undefined) => Promise<PromiseSettledResult<void>[]> | undefined;
|
|
493
|
+
/**
|
|
494
|
+
* Write one file outside an artifact — `cssgen -o`, the stylesheet `bamboo --watch` rebuilds —
|
|
495
|
+
* unless it holds exactly that already. They wrote it whatever it held, so every rebuild touched
|
|
496
|
+
* the stylesheet a dev server or a bundler watches, and each of them did its work over for it.
|
|
497
|
+
* Whether it was written is the answer.
|
|
498
|
+
*/
|
|
499
|
+
writeFile: (absPath: string, code: string) => Promise<boolean>;
|
|
493
500
|
/**
|
|
494
501
|
* Whether the file on disk already holds exactly what codegen would write.
|
|
495
502
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -1184,13 +1184,42 @@ const prepareAstroTemplate = (source) => {
|
|
|
1184
1184
|
};
|
|
1185
1185
|
//#endregion
|
|
1186
1186
|
//#region src/native-extractor.ts
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1187
|
+
/**
|
|
1188
|
+
* The binaries the release workflow builds into `dist/native`, by platform and architecture and,
|
|
1189
|
+
* on Linux, the C library Node runs on. `__tests__/native-binaries.test.ts` holds the workflow to
|
|
1190
|
+
* building and shipping every one.
|
|
1191
|
+
*/
|
|
1192
|
+
const NATIVE_BINARIES = {
|
|
1193
|
+
"darwin-arm64": "darwin-arm64.node",
|
|
1194
|
+
"darwin-x64": "darwin-x64.node",
|
|
1195
|
+
"linux-arm64-gnu": "linux-arm64-gnu.node",
|
|
1196
|
+
"linux-arm64-musl": "linux-arm64-musl.node",
|
|
1197
|
+
"linux-x64-gnu": "linux-x64-gnu.node",
|
|
1198
|
+
"linux-x64-musl": "linux-x64-musl.node",
|
|
1199
|
+
"win32-arm64": "win32-arm64-msvc.node",
|
|
1200
|
+
"win32-x64": "win32-x64-msvc.node"
|
|
1193
1201
|
};
|
|
1202
|
+
let musl;
|
|
1203
|
+
/**
|
|
1204
|
+
* Whether Node runs on musl, as on Alpine. A gnu binary fails there on x64, naming glibc's dynamic
|
|
1205
|
+
* loader, and loads on arm64 only because musl's does not check the glibc versions it asks for.
|
|
1206
|
+
*
|
|
1207
|
+
* Alpine's `ldd` is musl's own loader and glibc's is a script naming glibc, so reading it answers
|
|
1208
|
+
* without starting anything. Without one, as in a distroless image, the report Node writes names
|
|
1209
|
+
* the glibc it runs on, and has none to name under musl.
|
|
1210
|
+
*/
|
|
1211
|
+
const isMusl = () => {
|
|
1212
|
+
if (musl !== void 0) return musl;
|
|
1213
|
+
try {
|
|
1214
|
+
musl = readFileSync("/usr/bin/ldd", "utf8").includes("musl");
|
|
1215
|
+
} catch {
|
|
1216
|
+
const report = process.report?.getReport();
|
|
1217
|
+
musl = report?.header !== void 0 && !report.header.glibcVersionRuntime;
|
|
1218
|
+
}
|
|
1219
|
+
return musl;
|
|
1220
|
+
};
|
|
1221
|
+
/** This machine's binary in `dist/native`, or undefined where the release builds none. */
|
|
1222
|
+
const nativeBinaryName = () => NATIVE_BINARIES[process.platform === "linux" ? `linux-${process.arch}-${isMusl() ? "musl" : "gnu"}` : `${process.platform}-${process.arch}`];
|
|
1194
1223
|
/** Load the required Rust extractor from the workspace or the published prebuild directory. */
|
|
1195
1224
|
const loadNativeExtractor = () => {
|
|
1196
1225
|
const nativeRequire = createRequire(import.meta.url);
|
|
@@ -1404,6 +1433,13 @@ const EMITTED = [
|
|
|
1404
1433
|
".js",
|
|
1405
1434
|
".jsx"
|
|
1406
1435
|
]],
|
|
1436
|
+
[".jsx", [
|
|
1437
|
+
".tsx",
|
|
1438
|
+
".ts",
|
|
1439
|
+
".d.ts",
|
|
1440
|
+
".jsx",
|
|
1441
|
+
".js"
|
|
1442
|
+
]],
|
|
1407
1443
|
[".mjs", [
|
|
1408
1444
|
".mts",
|
|
1409
1445
|
".d.mts",
|
|
@@ -3388,89 +3424,125 @@ const slashes = (path) => path.replaceAll("\\", "/");
|
|
|
3388
3424
|
* ends in one already — and spelled as every path here is, with `/`.
|
|
3389
3425
|
*/
|
|
3390
3426
|
const entryPath = (directory, name) => slashes(directory.endsWith("/") ? directory + name : `${directory}/${name}`);
|
|
3391
|
-
|
|
3427
|
+
/** Where a folder really is, or as spelled if the system cannot say. */
|
|
3428
|
+
const realOf = (directory) => {
|
|
3429
|
+
try {
|
|
3430
|
+
return slashes(realpathSync.native(directory));
|
|
3431
|
+
} catch {
|
|
3432
|
+
return directory;
|
|
3433
|
+
}
|
|
3434
|
+
};
|
|
3435
|
+
/** `entries` as `readdirSync` hands them over, named alone unless asked for their types. */
|
|
3436
|
+
const answer = (entries, options) => options?.withFileTypes ? entries : entries.map((entry) => entry.name);
|
|
3392
3437
|
/**
|
|
3393
|
-
* One walk
|
|
3438
|
+
* One walk of the source glob, which enters each real folder once.
|
|
3394
3439
|
*
|
|
3395
3440
|
* The glob follows symbolic links — how a workspace package or a folder linked into `src` is read
|
|
3396
|
-
* at all — and
|
|
3397
|
-
*
|
|
3398
|
-
*
|
|
3399
|
-
*
|
|
3400
|
-
*
|
|
3401
|
-
*
|
|
3402
|
-
*
|
|
3441
|
+
* at all — and it followed every path through them. A link back into a folder the walk was inside
|
|
3442
|
+
* took it round again, until the system would resolve no deeper a chain of links; and in a pnpm
|
|
3443
|
+
* workspace, where each package's `node_modules` links its siblings, an include reaching each
|
|
3444
|
+
* package's `src` through `../**` went through every sequence of them: 13,699 paths to 7 files, and
|
|
3445
|
+
* 109,600 and a minute for 8. Extraction read each real file once, so what came of the walk was its
|
|
3446
|
+
* time, and a watch on every path.
|
|
3447
|
+
*
|
|
3448
|
+
* So each real folder is entered once. The plain ones first: the walk reads no link, and sets aside
|
|
3449
|
+
* each one it would enter, so a file it can reach directly is found where it really is. Then each
|
|
3450
|
+
* link set aside, in order of its path and round by round as links within them turn up: one leading
|
|
3451
|
+
* to a folder entered already is read as empty, as `find -L` reads a loop, and one leading anywhere
|
|
3452
|
+
* else is walked, through the folders above it and nothing else of them. A link to a file is a file,
|
|
3453
|
+
* and found as before.
|
|
3454
|
+
*
|
|
3455
|
+
* What that gives up is a second spelling of one folder: two links in one walk to a folder outside
|
|
3456
|
+
* it find it by the first. Patterns walked apart, `src/**` and `vendor/**`, still find it by each.
|
|
3403
3457
|
*
|
|
3404
|
-
*
|
|
3405
|
-
*
|
|
3406
|
-
* folders above it are stat'd once each — mostly, just the one the walk began at — and a real path
|
|
3407
|
-
* is resolved only where two of those match, to tell apart inodes too large to be told apart.
|
|
3458
|
+
* `linked` is where the walk began, and each folder and file it reached through a link, as it spelled
|
|
3459
|
+
* them: where a path it found may really be elsewhere.
|
|
3408
3460
|
*/
|
|
3409
|
-
const
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
const links = /* @__PURE__ */ new Map();
|
|
3413
|
-
const identityOf = (directory) => {
|
|
3414
|
-
const walked = directories.get(directory);
|
|
3415
|
-
if (walked.identity === void 0) try {
|
|
3416
|
-
walked.identity = walked.link && links.get(directory) || identify(statSync(directory));
|
|
3417
|
-
} catch {
|
|
3418
|
-
walked.identity = directory;
|
|
3419
|
-
}
|
|
3420
|
-
return walked.identity;
|
|
3421
|
-
};
|
|
3422
|
-
const realDirectory = (directory) => {
|
|
3423
|
-
const walked = directories.get(directory);
|
|
3424
|
-
if (walked.real === void 0) try {
|
|
3425
|
-
walked.real = slashes(realpathSync.native(directory));
|
|
3426
|
-
} catch {
|
|
3427
|
-
walked.real = directory;
|
|
3428
|
-
}
|
|
3429
|
-
return walked.real;
|
|
3430
|
-
};
|
|
3431
|
-
const readdir = ((path, options) => {
|
|
3432
|
-
const directory = slashes(String(path));
|
|
3433
|
-
const cut = directory.lastIndexOf("/");
|
|
3434
|
-
const above = directory.slice(0, cut);
|
|
3435
|
-
const parent = directories.has(above) ? above : directories.has(directory.slice(0, cut + 1)) ? directory.slice(0, cut + 1) : void 0;
|
|
3436
|
-
const link = links.has(directory);
|
|
3437
|
-
directories.set(directory, {
|
|
3438
|
-
link,
|
|
3439
|
-
parent
|
|
3440
|
-
});
|
|
3441
|
-
if (link) for (let ancestor = parent; ancestor !== void 0; ancestor = directories.get(ancestor).parent) {
|
|
3442
|
-
if (identityOf(ancestor) !== identityOf(directory)) continue;
|
|
3443
|
-
if (realDirectory(ancestor) !== realDirectory(directory)) continue;
|
|
3444
|
-
logger.debug("glob", `${directory} leads back into ${ancestor}, which is read already`);
|
|
3445
|
-
directories.get(directory).cut = true;
|
|
3446
|
-
return [];
|
|
3447
|
-
}
|
|
3448
|
-
const entries = readdirSync(path, { withFileTypes: true });
|
|
3449
|
-
for (const entry of entries) if (entry.isSymbolicLink()) links.set(entryPath(String(path), entry.name), void 0);
|
|
3450
|
-
return options?.withFileTypes ? entries : entries.map((entry) => entry.name);
|
|
3451
|
-
});
|
|
3461
|
+
const globEachFolderOnce = (patterns, cwd) => {
|
|
3462
|
+
/** Every entry listed that is a symbolic link, by its path. */
|
|
3463
|
+
const links = /* @__PURE__ */ new Set();
|
|
3452
3464
|
/** Every entry listed as a link that is one to a file. */
|
|
3453
3465
|
const fileLinks = /* @__PURE__ */ new Set();
|
|
3466
|
+
/** Every real folder entered. */
|
|
3467
|
+
const entered = /* @__PURE__ */ new Set();
|
|
3468
|
+
/** Links to folders the walk would have entered, to look at once the folders before them are read. */
|
|
3469
|
+
let aside = [];
|
|
3470
|
+
const linked = [];
|
|
3471
|
+
const list = (directory) => {
|
|
3472
|
+
const entries = readdirSync(directory, { withFileTypes: true });
|
|
3473
|
+
for (const entry of entries) if (entry.isSymbolicLink()) links.add(entryPath(directory, entry.name));
|
|
3474
|
+
return entries;
|
|
3475
|
+
};
|
|
3454
3476
|
const stat = ((path, options) => {
|
|
3455
3477
|
const stats = statSync(path, options);
|
|
3456
3478
|
const key = slashes(String(path));
|
|
3457
|
-
if (stats && links.has(key))
|
|
3458
|
-
links.set(key, identify(stats));
|
|
3459
|
-
if (stats.isFile()) fileLinks.add(key);
|
|
3460
|
-
}
|
|
3479
|
+
if (stats && links.has(key) && stats.isFile()) fileLinks.add(key);
|
|
3461
3480
|
return stats;
|
|
3462
3481
|
});
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3482
|
+
let root;
|
|
3483
|
+
let rootReal = "";
|
|
3484
|
+
const plain = ((path, options) => {
|
|
3485
|
+
const directory = slashes(String(path));
|
|
3486
|
+
if (root === void 0) {
|
|
3487
|
+
root = directory;
|
|
3488
|
+
rootReal = realOf(directory);
|
|
3489
|
+
linked.push(directory);
|
|
3490
|
+
} else if (links.has(directory)) {
|
|
3491
|
+
aside.push(directory);
|
|
3492
|
+
return [];
|
|
3493
|
+
}
|
|
3494
|
+
entered.add(rootReal + directory.slice(root.length));
|
|
3495
|
+
return answer(list(directory), options);
|
|
3496
|
+
});
|
|
3497
|
+
const found = [glob.sync(patterns, {
|
|
3498
|
+
absolute: true,
|
|
3499
|
+
cwd,
|
|
3470
3500
|
fs: {
|
|
3471
|
-
readdirSync:
|
|
3501
|
+
readdirSync: plain,
|
|
3472
3502
|
statSync: stat
|
|
3473
3503
|
}
|
|
3504
|
+
})];
|
|
3505
|
+
while (aside.length) {
|
|
3506
|
+
const round = [...new Set(aside)].sort();
|
|
3507
|
+
aside = [];
|
|
3508
|
+
for (const link of round) {
|
|
3509
|
+
const real = realOf(link);
|
|
3510
|
+
if (entered.has(real)) {
|
|
3511
|
+
logger.debug("glob", `${link} leads to ${real}, which is read already`);
|
|
3512
|
+
continue;
|
|
3513
|
+
}
|
|
3514
|
+
const inside = `${link}/`;
|
|
3515
|
+
const through = ((path, options) => {
|
|
3516
|
+
const directory = slashes(String(path));
|
|
3517
|
+
if (directory === link || directory.startsWith(inside)) {
|
|
3518
|
+
if (directory !== link && links.has(directory)) {
|
|
3519
|
+
aside.push(directory);
|
|
3520
|
+
return [];
|
|
3521
|
+
}
|
|
3522
|
+
const folder = real + directory.slice(link.length);
|
|
3523
|
+
if (entered.has(folder)) return [];
|
|
3524
|
+
entered.add(folder);
|
|
3525
|
+
if (directory === link) linked.push(link);
|
|
3526
|
+
return answer(list(directory), options);
|
|
3527
|
+
}
|
|
3528
|
+
const above = directory.endsWith("/") ? directory : `${directory}/`;
|
|
3529
|
+
if (!link.startsWith(above)) return [];
|
|
3530
|
+
const next = link.slice(above.length).split("/", 1)[0];
|
|
3531
|
+
return answer(readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.name === next), options);
|
|
3532
|
+
});
|
|
3533
|
+
found.push(glob.sync(patterns, {
|
|
3534
|
+
absolute: true,
|
|
3535
|
+
cwd,
|
|
3536
|
+
fs: {
|
|
3537
|
+
readdirSync: through,
|
|
3538
|
+
statSync: stat
|
|
3539
|
+
}
|
|
3540
|
+
}));
|
|
3541
|
+
}
|
|
3542
|
+
}
|
|
3543
|
+
return {
|
|
3544
|
+
found: found.length === 1 ? found[0] : found.flat(),
|
|
3545
|
+
linked: [...linked, ...fileLinks]
|
|
3474
3546
|
};
|
|
3475
3547
|
};
|
|
3476
3548
|
/**
|
|
@@ -3519,14 +3591,9 @@ const nodeRuntime = {
|
|
|
3519
3591
|
})) {
|
|
3520
3592
|
const negatives = task.negative.map((pattern) => `!${pattern}`);
|
|
3521
3593
|
for (const patterns of byOwnBase(task, cwd)) {
|
|
3522
|
-
const walk =
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
cwd,
|
|
3526
|
-
fs: walk.fs
|
|
3527
|
-
});
|
|
3528
|
-
walks.push(found);
|
|
3529
|
-
opts.linked?.push(...walk.linked(), ...task.dynamic ? [] : found);
|
|
3594
|
+
const walk = globEachFolderOnce([...patterns, ...negatives], cwd);
|
|
3595
|
+
walks.push(walk.found);
|
|
3596
|
+
opts.linked?.push(...walk.linked, ...task.dynamic ? [] : walk.found);
|
|
3530
3597
|
}
|
|
3531
3598
|
}
|
|
3532
3599
|
const files = sortSources(walks.length === 1 ? walks[0] : walks.flat());
|
|
@@ -3591,8 +3658,9 @@ const slashed = (path) => path.replaceAll("\\", "/");
|
|
|
3591
3658
|
* The files, each real one once: under the first of the paths the glob reached it by.
|
|
3592
3659
|
*
|
|
3593
3660
|
* Two links in `include` to one folder — `src/shared` and `vendor/shared`, a package linked twice —
|
|
3594
|
-
* and the inventory holds each of its files under both, as
|
|
3595
|
-
* which is how the watcher and a bundler naming a module have to find it.
|
|
3661
|
+
* and the inventory holds each of its files under both, as two patterns walked apart each find it,
|
|
3662
|
+
* which is how the watcher and a bundler naming a module have to find it. One walk enters a folder
|
|
3663
|
+
* once, so a single pattern finds it by one path. Extracted, each was
|
|
3596
3664
|
* read twice for the same styles. The first of them in the inventory's order is the one kept: an
|
|
3597
3665
|
* atom sits at the rank of the earliest file that wrote it, which is that one, so the stylesheet's
|
|
3598
3666
|
* order is as it was.
|
|
@@ -3746,6 +3814,20 @@ var OutputEngine = class {
|
|
|
3746
3814
|
}));
|
|
3747
3815
|
};
|
|
3748
3816
|
/**
|
|
3817
|
+
* Write one file outside an artifact — `cssgen -o`, the stylesheet `bamboo --watch` rebuilds —
|
|
3818
|
+
* unless it holds exactly that already. They wrote it whatever it held, so every rebuild touched
|
|
3819
|
+
* the stylesheet a dev server or a bundler watches, and each of them did its work over for it.
|
|
3820
|
+
* Whether it was written is the answer.
|
|
3821
|
+
*/
|
|
3822
|
+
writeFile = async (absPath, code) => {
|
|
3823
|
+
if (this.isUnchanged(absPath, code)) {
|
|
3824
|
+
logger.debug("write:unchanged", absPath);
|
|
3825
|
+
return false;
|
|
3826
|
+
}
|
|
3827
|
+
await this.fs.writeFile(absPath, code);
|
|
3828
|
+
return true;
|
|
3829
|
+
};
|
|
3830
|
+
/**
|
|
3749
3831
|
* Whether the file on disk already holds exactly what codegen would write.
|
|
3750
3832
|
*
|
|
3751
3833
|
* Not for the write itself, which is cheap — 54 artifacts and 1.4 MB measure ~6ms, against
|
|
@@ -6208,7 +6290,7 @@ const cssgen = async (ctx, options) => {
|
|
|
6208
6290
|
if (outfile) {
|
|
6209
6291
|
const css = ctx.getCss(sheet);
|
|
6210
6292
|
logger.info("css", ctx.runtime.path.resolve(outfile));
|
|
6211
|
-
await ctx.
|
|
6293
|
+
await ctx.output.writeFile(outfile, css);
|
|
6212
6294
|
} else await ctx.writeCss(sheet);
|
|
6213
6295
|
done();
|
|
6214
6296
|
} else {
|
|
@@ -6222,7 +6304,7 @@ const cssgen = async (ctx, options) => {
|
|
|
6222
6304
|
else if (outfile) {
|
|
6223
6305
|
const css = ctx.getCss(sheet);
|
|
6224
6306
|
logger.info("css", ctx.runtime.path.resolve(outfile));
|
|
6225
|
-
await ctx.
|
|
6307
|
+
await ctx.output.writeFile(outfile, css);
|
|
6226
6308
|
} else await ctx.writeCss(sheet);
|
|
6227
6309
|
done();
|
|
6228
6310
|
}
|
|
@@ -6584,7 +6666,7 @@ async function generate(config, configPath, options = {}) {
|
|
|
6584
6666
|
sourceScanCache
|
|
6585
6667
|
});
|
|
6586
6668
|
const css = ctx.getCss(sheet);
|
|
6587
|
-
await ctx.
|
|
6669
|
+
await ctx.output.writeFile(outfile, css);
|
|
6588
6670
|
done();
|
|
6589
6671
|
};
|
|
6590
6672
|
ctx.watchFiles(async (event, file) => {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamboocss/node",
|
|
3
|
-
"version": "1.60.
|
|
3
|
+
"version": "1.60.3",
|
|
4
4
|
"description": "The core css bamboo library",
|
|
5
5
|
"homepage": "https://bamboocss.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -60,16 +60,16 @@
|
|
|
60
60
|
"pkg-types": "2.3.0",
|
|
61
61
|
"pluralize": "8.0.0",
|
|
62
62
|
"ts-pattern": "5.9.0",
|
|
63
|
-
"@bamboocss/config": "1.60.
|
|
64
|
-
"@bamboocss/core": "1.60.
|
|
65
|
-
"@bamboocss/generator": "1.60.
|
|
66
|
-
"@bamboocss/logger": "1.60.
|
|
67
|
-
"@bamboocss/plugin-svelte": "1.60.
|
|
68
|
-
"@bamboocss/plugin-vue": "1.60.
|
|
69
|
-
"@bamboocss/reporter": "1.60.
|
|
70
|
-
"@bamboocss/shared": "1.60.
|
|
71
|
-
"@bamboocss/token-dictionary": "1.60.
|
|
72
|
-
"@bamboocss/types": "1.60.
|
|
63
|
+
"@bamboocss/config": "1.60.3",
|
|
64
|
+
"@bamboocss/core": "1.60.3",
|
|
65
|
+
"@bamboocss/generator": "1.60.3",
|
|
66
|
+
"@bamboocss/logger": "1.60.3",
|
|
67
|
+
"@bamboocss/plugin-svelte": "1.60.3",
|
|
68
|
+
"@bamboocss/plugin-vue": "1.60.3",
|
|
69
|
+
"@bamboocss/reporter": "1.60.3",
|
|
70
|
+
"@bamboocss/shared": "1.60.3",
|
|
71
|
+
"@bamboocss/token-dictionary": "1.60.3",
|
|
72
|
+
"@bamboocss/types": "1.60.3"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@astrojs/compiler": "3.0.1",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@types/fs-extra": "11.0.4",
|
|
78
78
|
"@types/picomatch": "4.0.2",
|
|
79
79
|
"boxen": "8.0.1",
|
|
80
|
-
"@bamboocss/native-extractor": "1.60.
|
|
80
|
+
"@bamboocss/native-extractor": "1.60.3"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"@astrojs/compiler": ">=2",
|