@bamboocss/node 1.60.2 → 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 +134 -81
- package/dist/index.d.cts +7 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.mjs +134 -81
- 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
|
@@ -1445,6 +1445,13 @@ const EMITTED = [
|
|
|
1445
1445
|
".js",
|
|
1446
1446
|
".jsx"
|
|
1447
1447
|
]],
|
|
1448
|
+
[".jsx", [
|
|
1449
|
+
".tsx",
|
|
1450
|
+
".ts",
|
|
1451
|
+
".d.ts",
|
|
1452
|
+
".jsx",
|
|
1453
|
+
".js"
|
|
1454
|
+
]],
|
|
1448
1455
|
[".mjs", [
|
|
1449
1456
|
".mts",
|
|
1450
1457
|
".d.mts",
|
|
@@ -3429,89 +3436,125 @@ const slashes = (path) => path.replaceAll("\\", "/");
|
|
|
3429
3436
|
* ends in one already — and spelled as every path here is, with `/`.
|
|
3430
3437
|
*/
|
|
3431
3438
|
const entryPath = (directory, name) => slashes(directory.endsWith("/") ? directory + name : `${directory}/${name}`);
|
|
3432
|
-
|
|
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);
|
|
3433
3449
|
/**
|
|
3434
|
-
* One walk
|
|
3450
|
+
* One walk of the source glob, which enters each real folder once.
|
|
3435
3451
|
*
|
|
3436
3452
|
* The glob follows symbolic links — how a workspace package or a folder linked into `src` is read
|
|
3437
|
-
* at all — and
|
|
3438
|
-
*
|
|
3439
|
-
*
|
|
3440
|
-
*
|
|
3441
|
-
*
|
|
3442
|
-
*
|
|
3443
|
-
*
|
|
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.
|
|
3444
3466
|
*
|
|
3445
|
-
*
|
|
3446
|
-
* it
|
|
3447
|
-
*
|
|
3448
|
-
* is
|
|
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.
|
|
3469
|
+
*
|
|
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.
|
|
3449
3472
|
*/
|
|
3450
|
-
const
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
const links = /* @__PURE__ */ new Map();
|
|
3454
|
-
const identityOf = (directory) => {
|
|
3455
|
-
const walked = directories.get(directory);
|
|
3456
|
-
if (walked.identity === void 0) try {
|
|
3457
|
-
walked.identity = walked.link && links.get(directory) || identify((0, node_fs.statSync)(directory));
|
|
3458
|
-
} catch {
|
|
3459
|
-
walked.identity = directory;
|
|
3460
|
-
}
|
|
3461
|
-
return walked.identity;
|
|
3462
|
-
};
|
|
3463
|
-
const realDirectory = (directory) => {
|
|
3464
|
-
const walked = directories.get(directory);
|
|
3465
|
-
if (walked.real === void 0) try {
|
|
3466
|
-
walked.real = slashes(node_fs.realpathSync.native(directory));
|
|
3467
|
-
} catch {
|
|
3468
|
-
walked.real = directory;
|
|
3469
|
-
}
|
|
3470
|
-
return walked.real;
|
|
3471
|
-
};
|
|
3472
|
-
const readdir = ((path, options) => {
|
|
3473
|
-
const directory = slashes(String(path));
|
|
3474
|
-
const cut = directory.lastIndexOf("/");
|
|
3475
|
-
const above = directory.slice(0, cut);
|
|
3476
|
-
const parent = directories.has(above) ? above : directories.has(directory.slice(0, cut + 1)) ? directory.slice(0, cut + 1) : void 0;
|
|
3477
|
-
const link = links.has(directory);
|
|
3478
|
-
directories.set(directory, {
|
|
3479
|
-
link,
|
|
3480
|
-
parent
|
|
3481
|
-
});
|
|
3482
|
-
if (link) for (let ancestor = parent; ancestor !== void 0; ancestor = directories.get(ancestor).parent) {
|
|
3483
|
-
if (identityOf(ancestor) !== identityOf(directory)) continue;
|
|
3484
|
-
if (realDirectory(ancestor) !== realDirectory(directory)) continue;
|
|
3485
|
-
_bamboocss_logger.logger.debug("glob", `${directory} leads back into ${ancestor}, which is read already`);
|
|
3486
|
-
directories.get(directory).cut = true;
|
|
3487
|
-
return [];
|
|
3488
|
-
}
|
|
3489
|
-
const entries = (0, node_fs.readdirSync)(path, { withFileTypes: true });
|
|
3490
|
-
for (const entry of entries) if (entry.isSymbolicLink()) links.set(entryPath(String(path), entry.name), void 0);
|
|
3491
|
-
return options?.withFileTypes ? entries : entries.map((entry) => entry.name);
|
|
3492
|
-
});
|
|
3473
|
+
const globEachFolderOnce = (patterns, cwd) => {
|
|
3474
|
+
/** Every entry listed that is a symbolic link, by its path. */
|
|
3475
|
+
const links = /* @__PURE__ */ new Set();
|
|
3493
3476
|
/** Every entry listed as a link that is one to a file. */
|
|
3494
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
|
+
};
|
|
3495
3488
|
const stat = ((path, options) => {
|
|
3496
3489
|
const stats = (0, node_fs.statSync)(path, options);
|
|
3497
3490
|
const key = slashes(String(path));
|
|
3498
|
-
if (stats && links.has(key))
|
|
3499
|
-
links.set(key, identify(stats));
|
|
3500
|
-
if (stats.isFile()) fileLinks.add(key);
|
|
3501
|
-
}
|
|
3491
|
+
if (stats && links.has(key) && stats.isFile()) fileLinks.add(key);
|
|
3502
3492
|
return stats;
|
|
3503
3493
|
});
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
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,
|
|
3511
3512
|
fs: {
|
|
3512
|
-
readdirSync:
|
|
3513
|
+
readdirSync: plain,
|
|
3513
3514
|
statSync: stat
|
|
3514
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]
|
|
3515
3558
|
};
|
|
3516
3559
|
};
|
|
3517
3560
|
/**
|
|
@@ -3560,14 +3603,9 @@ const nodeRuntime = {
|
|
|
3560
3603
|
})) {
|
|
3561
3604
|
const negatives = task.negative.map((pattern) => `!${pattern}`);
|
|
3562
3605
|
for (const patterns of byOwnBase(task, cwd)) {
|
|
3563
|
-
const walk =
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
cwd,
|
|
3567
|
-
fs: walk.fs
|
|
3568
|
-
});
|
|
3569
|
-
walks.push(found);
|
|
3570
|
-
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);
|
|
3571
3609
|
}
|
|
3572
3610
|
}
|
|
3573
3611
|
const files = sortSources(walks.length === 1 ? walks[0] : walks.flat());
|
|
@@ -3632,8 +3670,9 @@ const slashed = (path) => path.replaceAll("\\", "/");
|
|
|
3632
3670
|
* The files, each real one once: under the first of the paths the glob reached it by.
|
|
3633
3671
|
*
|
|
3634
3672
|
* Two links in `include` to one folder — `src/shared` and `vendor/shared`, a package linked twice —
|
|
3635
|
-
* and the inventory holds each of its files under both, as
|
|
3636
|
-
* 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
|
|
3637
3676
|
* read twice for the same styles. The first of them in the inventory's order is the one kept: an
|
|
3638
3677
|
* atom sits at the rank of the earliest file that wrote it, which is that one, so the stylesheet's
|
|
3639
3678
|
* order is as it was.
|
|
@@ -3787,6 +3826,20 @@ var OutputEngine = class {
|
|
|
3787
3826
|
}));
|
|
3788
3827
|
};
|
|
3789
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
|
+
/**
|
|
3790
3843
|
* Whether the file on disk already holds exactly what codegen would write.
|
|
3791
3844
|
*
|
|
3792
3845
|
* Not for the write itself, which is cheap — 54 artifacts and 1.4 MB measure ~6ms, against
|
|
@@ -6249,7 +6302,7 @@ const cssgen = async (ctx, options) => {
|
|
|
6249
6302
|
if (outfile) {
|
|
6250
6303
|
const css = ctx.getCss(sheet);
|
|
6251
6304
|
_bamboocss_logger.logger.info("css", ctx.runtime.path.resolve(outfile));
|
|
6252
|
-
await ctx.
|
|
6305
|
+
await ctx.output.writeFile(outfile, css);
|
|
6253
6306
|
} else await ctx.writeCss(sheet);
|
|
6254
6307
|
done();
|
|
6255
6308
|
} else {
|
|
@@ -6263,7 +6316,7 @@ const cssgen = async (ctx, options) => {
|
|
|
6263
6316
|
else if (outfile) {
|
|
6264
6317
|
const css = ctx.getCss(sheet);
|
|
6265
6318
|
_bamboocss_logger.logger.info("css", ctx.runtime.path.resolve(outfile));
|
|
6266
|
-
await ctx.
|
|
6319
|
+
await ctx.output.writeFile(outfile, css);
|
|
6267
6320
|
} else await ctx.writeCss(sheet);
|
|
6268
6321
|
done();
|
|
6269
6322
|
}
|
|
@@ -6625,7 +6678,7 @@ async function generate(config, configPath, options = {}) {
|
|
|
6625
6678
|
sourceScanCache
|
|
6626
6679
|
});
|
|
6627
6680
|
const css = ctx.getCss(sheet);
|
|
6628
|
-
await ctx.
|
|
6681
|
+
await ctx.output.writeFile(outfile, css);
|
|
6629
6682
|
done();
|
|
6630
6683
|
};
|
|
6631
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
|
@@ -1433,6 +1433,13 @@ const EMITTED = [
|
|
|
1433
1433
|
".js",
|
|
1434
1434
|
".jsx"
|
|
1435
1435
|
]],
|
|
1436
|
+
[".jsx", [
|
|
1437
|
+
".tsx",
|
|
1438
|
+
".ts",
|
|
1439
|
+
".d.ts",
|
|
1440
|
+
".jsx",
|
|
1441
|
+
".js"
|
|
1442
|
+
]],
|
|
1436
1443
|
[".mjs", [
|
|
1437
1444
|
".mts",
|
|
1438
1445
|
".d.mts",
|
|
@@ -3417,89 +3424,125 @@ const slashes = (path) => path.replaceAll("\\", "/");
|
|
|
3417
3424
|
* ends in one already — and spelled as every path here is, with `/`.
|
|
3418
3425
|
*/
|
|
3419
3426
|
const entryPath = (directory, name) => slashes(directory.endsWith("/") ? directory + name : `${directory}/${name}`);
|
|
3420
|
-
|
|
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);
|
|
3421
3437
|
/**
|
|
3422
|
-
* One walk
|
|
3438
|
+
* One walk of the source glob, which enters each real folder once.
|
|
3423
3439
|
*
|
|
3424
3440
|
* The glob follows symbolic links — how a workspace package or a folder linked into `src` is read
|
|
3425
|
-
* at all — and
|
|
3426
|
-
*
|
|
3427
|
-
*
|
|
3428
|
-
*
|
|
3429
|
-
*
|
|
3430
|
-
*
|
|
3431
|
-
*
|
|
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.
|
|
3432
3454
|
*
|
|
3433
|
-
*
|
|
3434
|
-
* it
|
|
3435
|
-
*
|
|
3436
|
-
* is
|
|
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.
|
|
3457
|
+
*
|
|
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.
|
|
3437
3460
|
*/
|
|
3438
|
-
const
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
const links = /* @__PURE__ */ new Map();
|
|
3442
|
-
const identityOf = (directory) => {
|
|
3443
|
-
const walked = directories.get(directory);
|
|
3444
|
-
if (walked.identity === void 0) try {
|
|
3445
|
-
walked.identity = walked.link && links.get(directory) || identify(statSync(directory));
|
|
3446
|
-
} catch {
|
|
3447
|
-
walked.identity = directory;
|
|
3448
|
-
}
|
|
3449
|
-
return walked.identity;
|
|
3450
|
-
};
|
|
3451
|
-
const realDirectory = (directory) => {
|
|
3452
|
-
const walked = directories.get(directory);
|
|
3453
|
-
if (walked.real === void 0) try {
|
|
3454
|
-
walked.real = slashes(realpathSync.native(directory));
|
|
3455
|
-
} catch {
|
|
3456
|
-
walked.real = directory;
|
|
3457
|
-
}
|
|
3458
|
-
return walked.real;
|
|
3459
|
-
};
|
|
3460
|
-
const readdir = ((path, options) => {
|
|
3461
|
-
const directory = slashes(String(path));
|
|
3462
|
-
const cut = directory.lastIndexOf("/");
|
|
3463
|
-
const above = directory.slice(0, cut);
|
|
3464
|
-
const parent = directories.has(above) ? above : directories.has(directory.slice(0, cut + 1)) ? directory.slice(0, cut + 1) : void 0;
|
|
3465
|
-
const link = links.has(directory);
|
|
3466
|
-
directories.set(directory, {
|
|
3467
|
-
link,
|
|
3468
|
-
parent
|
|
3469
|
-
});
|
|
3470
|
-
if (link) for (let ancestor = parent; ancestor !== void 0; ancestor = directories.get(ancestor).parent) {
|
|
3471
|
-
if (identityOf(ancestor) !== identityOf(directory)) continue;
|
|
3472
|
-
if (realDirectory(ancestor) !== realDirectory(directory)) continue;
|
|
3473
|
-
logger.debug("glob", `${directory} leads back into ${ancestor}, which is read already`);
|
|
3474
|
-
directories.get(directory).cut = true;
|
|
3475
|
-
return [];
|
|
3476
|
-
}
|
|
3477
|
-
const entries = readdirSync(path, { withFileTypes: true });
|
|
3478
|
-
for (const entry of entries) if (entry.isSymbolicLink()) links.set(entryPath(String(path), entry.name), void 0);
|
|
3479
|
-
return options?.withFileTypes ? entries : entries.map((entry) => entry.name);
|
|
3480
|
-
});
|
|
3461
|
+
const globEachFolderOnce = (patterns, cwd) => {
|
|
3462
|
+
/** Every entry listed that is a symbolic link, by its path. */
|
|
3463
|
+
const links = /* @__PURE__ */ new Set();
|
|
3481
3464
|
/** Every entry listed as a link that is one to a file. */
|
|
3482
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
|
+
};
|
|
3483
3476
|
const stat = ((path, options) => {
|
|
3484
3477
|
const stats = statSync(path, options);
|
|
3485
3478
|
const key = slashes(String(path));
|
|
3486
|
-
if (stats && links.has(key))
|
|
3487
|
-
links.set(key, identify(stats));
|
|
3488
|
-
if (stats.isFile()) fileLinks.add(key);
|
|
3489
|
-
}
|
|
3479
|
+
if (stats && links.has(key) && stats.isFile()) fileLinks.add(key);
|
|
3490
3480
|
return stats;
|
|
3491
3481
|
});
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
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,
|
|
3499
3500
|
fs: {
|
|
3500
|
-
readdirSync:
|
|
3501
|
+
readdirSync: plain,
|
|
3501
3502
|
statSync: stat
|
|
3502
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]
|
|
3503
3546
|
};
|
|
3504
3547
|
};
|
|
3505
3548
|
/**
|
|
@@ -3548,14 +3591,9 @@ const nodeRuntime = {
|
|
|
3548
3591
|
})) {
|
|
3549
3592
|
const negatives = task.negative.map((pattern) => `!${pattern}`);
|
|
3550
3593
|
for (const patterns of byOwnBase(task, cwd)) {
|
|
3551
|
-
const walk =
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
cwd,
|
|
3555
|
-
fs: walk.fs
|
|
3556
|
-
});
|
|
3557
|
-
walks.push(found);
|
|
3558
|
-
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);
|
|
3559
3597
|
}
|
|
3560
3598
|
}
|
|
3561
3599
|
const files = sortSources(walks.length === 1 ? walks[0] : walks.flat());
|
|
@@ -3620,8 +3658,9 @@ const slashed = (path) => path.replaceAll("\\", "/");
|
|
|
3620
3658
|
* The files, each real one once: under the first of the paths the glob reached it by.
|
|
3621
3659
|
*
|
|
3622
3660
|
* Two links in `include` to one folder — `src/shared` and `vendor/shared`, a package linked twice —
|
|
3623
|
-
* and the inventory holds each of its files under both, as
|
|
3624
|
-
* 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
|
|
3625
3664
|
* read twice for the same styles. The first of them in the inventory's order is the one kept: an
|
|
3626
3665
|
* atom sits at the rank of the earliest file that wrote it, which is that one, so the stylesheet's
|
|
3627
3666
|
* order is as it was.
|
|
@@ -3775,6 +3814,20 @@ var OutputEngine = class {
|
|
|
3775
3814
|
}));
|
|
3776
3815
|
};
|
|
3777
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
|
+
/**
|
|
3778
3831
|
* Whether the file on disk already holds exactly what codegen would write.
|
|
3779
3832
|
*
|
|
3780
3833
|
* Not for the write itself, which is cheap — 54 artifacts and 1.4 MB measure ~6ms, against
|
|
@@ -6237,7 +6290,7 @@ const cssgen = async (ctx, options) => {
|
|
|
6237
6290
|
if (outfile) {
|
|
6238
6291
|
const css = ctx.getCss(sheet);
|
|
6239
6292
|
logger.info("css", ctx.runtime.path.resolve(outfile));
|
|
6240
|
-
await ctx.
|
|
6293
|
+
await ctx.output.writeFile(outfile, css);
|
|
6241
6294
|
} else await ctx.writeCss(sheet);
|
|
6242
6295
|
done();
|
|
6243
6296
|
} else {
|
|
@@ -6251,7 +6304,7 @@ const cssgen = async (ctx, options) => {
|
|
|
6251
6304
|
else if (outfile) {
|
|
6252
6305
|
const css = ctx.getCss(sheet);
|
|
6253
6306
|
logger.info("css", ctx.runtime.path.resolve(outfile));
|
|
6254
|
-
await ctx.
|
|
6307
|
+
await ctx.output.writeFile(outfile, css);
|
|
6255
6308
|
} else await ctx.writeCss(sheet);
|
|
6256
6309
|
done();
|
|
6257
6310
|
}
|
|
@@ -6613,7 +6666,7 @@ async function generate(config, configPath, options = {}) {
|
|
|
6613
6666
|
sourceScanCache
|
|
6614
6667
|
});
|
|
6615
6668
|
const css = ctx.getCss(sheet);
|
|
6616
|
-
await ctx.
|
|
6669
|
+
await ctx.output.writeFile(outfile, css);
|
|
6617
6670
|
done();
|
|
6618
6671
|
};
|
|
6619
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",
|