@fluentic/style 0.1.0-beta.17 → 0.1.0-beta.19
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/CHANGELOG.md +18 -0
- package/atomic/utils/types.ts +4 -2
- package/compiler/compiler/cache_identity.ts +115 -0
- package/compiler/compiler/compiler.ts +21 -1
- package/compiler/compiler/persistent_cache.ts +310 -0
- package/compiler/compiler/types.ts +12 -0
- package/compiler/extract/collector.ts +2 -2
- package/compiler/transform/evaluator/metadata_cache.ts +124 -0
- package/compiler/transform/evaluator/tracer.ts +71 -63
- package/compiler/transform/extract/plugin.ts +2 -0
- package/compiler/utils/check_diagnostics.ts +18 -0
- package/compiler/utils/file_resolver.ts +24 -0
- package/dist/{combine-BpOQWCtM.js → combine-B5AnX0Gb.js} +2 -2
- package/dist/{combine-BpOQWCtM.js.map → combine-B5AnX0Gb.js.map} +1 -1
- package/dist/compiler/index.mjs +1 -1
- package/dist/{compiler-Cat8TmMk.mjs → compiler-Dpd41bCS.mjs} +552 -41
- package/dist/compiler-Dpd41bCS.mjs.map +1 -0
- package/dist/{config-B70LIQhi.js → config-VS1lyh3Z.js} +2 -2
- package/dist/{config-B70LIQhi.js.map → config-VS1lyh3Z.js.map} +1 -1
- package/dist/{css-C7tcD3IO.js → css-CMuUcsWb.js} +99 -21
- package/dist/css-CMuUcsWb.js.map +1 -0
- package/dist/{css-Cdxkur4h.js → css-ivddFxoH.js} +6 -6
- package/dist/{css-Cdxkur4h.js.map → css-ivddFxoH.js.map} +1 -1
- package/dist/{css-BkNqUfLD.js → css-tUcQKLko.js} +5 -5
- package/dist/{css-BkNqUfLD.js.map → css-tUcQKLko.js.map} +1 -1
- package/dist/css.js +1 -1
- package/dist/{css_extra-BC1Z_hDy.js → css_extra-FjU7uCIO.js} +2 -2
- package/dist/{css_extra-BC1Z_hDy.js.map → css_extra-FjU7uCIO.js.map} +1 -1
- package/dist/dev/rsc.js +5 -5
- package/dist/{dev-BoEgFs_x.js → dev-CZUGQ_Ps.js} +3 -3
- package/dist/{dev-BoEgFs_x.js.map → dev-CZUGQ_Ps.js.map} +1 -1
- package/dist/dev.js +1 -1
- package/dist/{elementMarker-nYeJnJPQ.js → elementMarker-BCL0sycL.js} +99 -21
- package/dist/elementMarker-BCL0sycL.js.map +1 -0
- package/dist/entry/dev/adapter/preact.js +1 -1
- package/dist/entry/dev/adapter/react.js +1 -1
- package/dist/entry/dev/adapter/solid.js +1 -1
- package/dist/entry/dev/css.js +1 -1
- package/dist/entry/dev/jsx-dev-runtime.js +1 -1
- package/dist/entry/dev/jsx-runtime.js +1 -1
- package/dist/entry/dev.js +5 -5
- package/dist/entry/prod/css.js +2 -2
- package/dist/entry/prod.js +2 -2
- package/dist/entry/rsc-dev/adapter/preact.js +1 -1
- package/dist/entry/rsc-dev/adapter/react.js +1 -1
- package/dist/entry/rsc-dev/adapter/solid.js +1 -1
- package/dist/entry/rsc-dev/css.js +3 -3
- package/dist/entry/rsc-dev/dev.js +4 -4
- package/dist/entry/rsc-dev/jsx-dev-runtime.js +3 -3
- package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
- package/dist/entry/rsc-dev.js +6 -6
- package/dist/entry/rsc-dev.js.map +1 -1
- package/dist/entry/rsc-prod/css.js +2 -2
- package/dist/entry/rsc-prod.js +2 -2
- package/dist/{env-BcNl1tsJ.js → env-CljhzScj.js} +2 -2
- package/dist/{env-BcNl1tsJ.js.map → env-CljhzScj.js.map} +1 -1
- package/dist/{getClassName-B3azD1TO.js → getClassName-DKk03IJU.js} +3 -3
- package/dist/{getClassName-B3azD1TO.js.map → getClassName-DKk03IJU.js.map} +1 -1
- package/dist/{getClassName-CkTq92nR.js → getClassName-a1SH7I2q.js} +3 -3
- package/dist/{getClassName-CkTq92nR.js.map → getClassName-a1SH7I2q.js.map} +1 -1
- package/dist/{globalSheet-CdgVpvCb.js → globalSheet-CjX0Df0w.js} +3 -3
- package/dist/globalSheet-CjX0Df0w.js.map +1 -0
- package/dist/index.js +4 -4
- package/dist/jsx/jsx-dev-runtime.js +1 -1
- package/dist/jsx/jsx-dev-runtime.server.js +1 -1
- package/dist/jsx/jsx-runtime.js +1 -1
- package/dist/jsx/jsx-runtime.server.js +1 -1
- package/dist/{jsx-DA1LD8nU.js → jsx-Gs5YwesA.js} +3 -3
- package/dist/{jsx-DA1LD8nU.js.map → jsx-Gs5YwesA.js.map} +1 -1
- package/dist/{jsx_runtime-pt7DOZOE.js → jsx_runtime-D3Dc1XfC.js} +3 -3
- package/dist/{jsx_runtime-pt7DOZOE.js.map → jsx_runtime-D3Dc1XfC.js.map} +1 -1
- package/dist/{loader-Cvz2pKYV.mjs → loader-CR_NH6ub.mjs} +3 -3
- package/dist/{loader-Cvz2pKYV.mjs.map → loader-CR_NH6ub.mjs.map} +1 -1
- package/dist/{misc-BKaSZF14.mjs → misc-D5AjOWP-.mjs} +3 -3
- package/dist/misc-D5AjOWP-.mjs.map +1 -0
- package/dist/plugin/farm/index.mjs +4 -4
- package/dist/plugin/farm/index.mjs.map +1 -1
- package/dist/plugin/nextjs/index.mjs +5 -5
- package/dist/plugin/nextjs/index.mjs.map +1 -1
- package/dist/plugin/nextjs/loader.mjs +4 -4
- package/dist/plugin/parcel/index.cjs +1 -1
- package/dist/plugin/parcel/index.mjs +2 -2
- package/dist/plugin/parcel/optimizer.cjs +1 -1
- package/dist/plugin/parcel/optimizer.mjs +2 -2
- package/dist/plugin/parcel/resolver.cjs +1 -1
- package/dist/plugin/parcel/resolver.mjs +2 -2
- package/dist/plugin/parcel/runtime.cjs +1 -1
- package/dist/plugin/parcel/runtime.mjs +1 -1
- package/dist/plugin/parcel/transformer.cjs +1 -1
- package/dist/plugin/parcel/transformer.mjs +2 -2
- package/dist/plugin/rspack/index.mjs +2 -2
- package/dist/plugin/vite/index.mjs +6 -6
- package/dist/plugin/vite/index.mjs.map +1 -1
- package/dist/plugin/webpack/index.mjs +2 -2
- package/dist/plugin/webpack/loader.mjs +2 -2
- package/dist/{registry-Bbxm5X90.mjs → registry-CdSHrX-o.mjs} +2 -2
- package/dist/{registry-Bbxm5X90.mjs.map → registry-CdSHrX-o.mjs.map} +1 -1
- package/dist/{resolveClassNameRuntime-B6vKNL5y.js → resolveClassNameRuntime-BBI9nYtq.js} +2 -2
- package/dist/{resolveClassNameRuntime-B6vKNL5y.js.map → resolveClassNameRuntime-BBI9nYtq.js.map} +1 -1
- package/dist/server.js +7 -7
- package/dist/{shared-L-63tURh.cjs → shared-CcB1KDFI.cjs} +557 -47
- package/dist/shared-CcB1KDFI.cjs.map +1 -0
- package/dist/{shared-BVciI9ew.mjs → shared-CobOEWzt.mjs} +5 -5
- package/dist/shared-CobOEWzt.mjs.map +1 -0
- package/dist/sheet-AV0Sl7e2.js +1 -0
- package/dist/sheet-Bf09AL2O.js +7 -0
- package/dist/{sheet-D_grHnaJ.js.map → sheet-Bf09AL2O.js.map} +1 -1
- package/dist/{sheet-C6ymGhKV.js → sheet-CcwxBK3r.js} +2 -2
- package/dist/{sheet-C6ymGhKV.js.map → sheet-CcwxBK3r.js.map} +1 -1
- package/dist/{sidecar-B7Q2P71F.mjs → sidecar-CHDVQqN_.mjs} +3 -3
- package/dist/{sidecar-B7Q2P71F.mjs.map → sidecar-CHDVQqN_.mjs.map} +1 -1
- package/dist/{style-CRs-vfY1.js → style-DY3v7k9y.js} +3 -3
- package/dist/style-DY3v7k9y.js.map +1 -0
- package/dist/{styleStore-D1IEmq1v.js → styleStore-BpkbvtBI.js} +99 -21
- package/dist/styleStore-BpkbvtBI.js.map +1 -0
- package/dist/{styleStore-HI4V2puu.js → styleStore-DWEAtd8z.js} +3 -3
- package/dist/{styleStore-HI4V2puu.js.map → styleStore-DWEAtd8z.js.map} +1 -1
- package/dist/{trace-DdFJPELS.js → trace-BxvaCfGx.js} +2 -2
- package/dist/{trace-DdFJPELS.js.map → trace-BxvaCfGx.js.map} +1 -1
- package/dist/{trace-uHVvnYiw.js → trace-Db5et6nx.js} +2 -2
- package/dist/{trace-uHVvnYiw.js.map → trace-Db5et6nx.js.map} +1 -1
- package/dist/transform-BZ4jPwy3.js.map +1 -1
- package/dist/types/atomic/utils/types.d.ts +3 -2
- package/dist/types/builder/utils.d.ts +1 -1
- package/dist/types/compiler/compiler/cache_identity.d.ts +4 -0
- package/dist/types/compiler/compiler/compiler.d.ts +12 -0
- package/dist/types/compiler/compiler/persistent_cache.d.ts +14 -0
- package/dist/types/compiler/compiler/types.d.ts +11 -0
- package/dist/types/compiler/extract/collector.d.ts +1 -1
- package/dist/types/compiler/transform/evaluator/metadata_cache.d.ts +13 -0
- package/dist/types/compiler/transform/evaluator/tracer.d.ts +6 -0
- package/dist/types/compiler/utils/check_diagnostics.d.ts +7 -0
- package/dist/types/compiler/utils/file_resolver.d.ts +4 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/plugin/bundler/vite/state.d.ts +24 -0
- package/dist/types/plugin/utils/compiler.d.ts +12 -1
- package/dist/types/style/tokens.d.ts +1 -1
- package/dist/types/style/transform.d.ts +4 -3
- package/dist/{utils-CB70kIh6.js → utils-B3O2b3Ly.js} +3 -3
- package/dist/{utils-CB70kIh6.js.map → utils-B3O2b3Ly.js.map} +1 -1
- package/dist/{utils-sG7IWYP6.js → utils-BeJmRz7x.js} +99 -21
- package/dist/utils-BeJmRz7x.js.map +1 -0
- package/dist/{utils-D2QdzQkX.mjs → utils-CICsXGqS.mjs} +5 -5
- package/dist/utils-CICsXGqS.mjs.map +1 -0
- package/dist/{utils-D3KR1ht8.mjs → utils-XfsnoteV.mjs} +3 -3
- package/dist/{utils-D3KR1ht8.mjs.map → utils-XfsnoteV.mjs.map} +1 -1
- package/dist/{webpack-DRegoWgj.mjs → webpack-BAflvDbq.mjs} +6 -6
- package/dist/webpack-BAflvDbq.mjs.map +1 -0
- package/index.ts +1 -0
- package/package.json +2 -2
- package/plugin/bundler/farm/plugin.ts +1 -1
- package/plugin/bundler/parcel/shared.ts +1 -1
- package/plugin/bundler/vite/state.ts +5 -6
- package/plugin/bundler/webpack/plugin.ts +1 -1
- package/plugin/nextjs/plugin.ts +1 -1
- package/plugin/nextjs/utils.ts +1 -1
- package/plugin/utils/compiler.ts +1 -2
- package/sheet/dev/dev_layer.ts +55 -11
- package/sheet/dev/dev_sort.ts +16 -9
- package/sheet/ordered.ts +43 -6
- package/style/tokens.ts +2 -1
- package/style/transform.ts +4 -3
- package/dist/compiler-Cat8TmMk.mjs.map +0 -1
- package/dist/css-C7tcD3IO.js.map +0 -1
- package/dist/elementMarker-nYeJnJPQ.js.map +0 -1
- package/dist/globalSheet-CdgVpvCb.js.map +0 -1
- package/dist/misc-BKaSZF14.mjs.map +0 -1
- package/dist/shared-BVciI9ew.mjs.map +0 -1
- package/dist/shared-L-63tURh.cjs.map +0 -1
- package/dist/sheet-Biw_rI4_.js +0 -1
- package/dist/sheet-D_grHnaJ.js +0 -7
- package/dist/style-CRs-vfY1.js.map +0 -1
- package/dist/styleStore-D1IEmq1v.js.map +0 -1
- package/dist/utils-D2QdzQkX.mjs.map +0 -1
- package/dist/utils-sG7IWYP6.js.map +0 -1
- package/dist/webpack-DRegoWgj.mjs.map +0 -1
|
@@ -32,6 +32,10 @@ let picomatch = require("picomatch");
|
|
|
32
32
|
picomatch = __toESM(picomatch, 1);
|
|
33
33
|
let css_what = require("css-what");
|
|
34
34
|
let oxc_resolver = require("oxc-resolver");
|
|
35
|
+
let node_module = require("node:module");
|
|
36
|
+
let node_url = require("node:url");
|
|
37
|
+
let node_util = require("node:util");
|
|
38
|
+
let node_v8 = require("node:v8");
|
|
35
39
|
require("@parcel/plugin");
|
|
36
40
|
let node_http = require("node:http");
|
|
37
41
|
//#region utils/symbol.ts
|
|
@@ -224,8 +228,8 @@ function createCssCollector() {
|
|
|
224
228
|
add(item) {
|
|
225
229
|
items.push(item);
|
|
226
230
|
},
|
|
227
|
-
addMany(
|
|
228
|
-
items.push(...
|
|
231
|
+
addMany(rules) {
|
|
232
|
+
items.push(...rules);
|
|
229
233
|
},
|
|
230
234
|
getItems() {
|
|
231
235
|
return items;
|
|
@@ -478,10 +482,10 @@ function createFileCssCache(args) {
|
|
|
478
482
|
};
|
|
479
483
|
}
|
|
480
484
|
function createFileCssContentHash(code) {
|
|
481
|
-
return hash(code);
|
|
485
|
+
return hash$1(code);
|
|
482
486
|
}
|
|
483
487
|
function createFileCssConfigHash(config) {
|
|
484
|
-
return hash(JSON.stringify(config ?? null));
|
|
488
|
+
return hash$1(JSON.stringify(config ?? null));
|
|
485
489
|
}
|
|
486
490
|
function readRecords(filesDir, args) {
|
|
487
491
|
let entries;
|
|
@@ -503,9 +507,9 @@ function readRecords(filesDir, args) {
|
|
|
503
507
|
return records;
|
|
504
508
|
}
|
|
505
509
|
function hashFilePath(filePath) {
|
|
506
|
-
return hash(normalizePath(node_path.default.resolve(filePath)));
|
|
510
|
+
return hash$1(normalizePath(node_path.default.resolve(filePath)));
|
|
507
511
|
}
|
|
508
|
-
function hash(text) {
|
|
512
|
+
function hash$1(text) {
|
|
509
513
|
return (0, node_crypto.createHash)("sha256").update(text).digest("hex");
|
|
510
514
|
}
|
|
511
515
|
//#endregion
|
|
@@ -772,7 +776,7 @@ const DEV_CONFIG_DEFAULT = {
|
|
|
772
776
|
sourcemapLocationMode: "style",
|
|
773
777
|
isElementClassNameEnabled: true
|
|
774
778
|
};
|
|
775
|
-
globalData("config.dev.isDev", () => ({ isDev: false }));
|
|
779
|
+
const IS_DEV = globalData("config.dev.isDev", () => ({ isDev: false }));
|
|
776
780
|
const DEV_CONFIG = globalData("config.dev", () => ({ ...DEV_CONFIG_DEFAULT }));
|
|
777
781
|
globalData("config.dev.plugin", () => ({ config: null }));
|
|
778
782
|
globalData("config.dev.base", () => ({ config: null }));
|
|
@@ -6104,6 +6108,20 @@ function transformDebug(internal, args, deps) {
|
|
|
6104
6108
|
//#endregion
|
|
6105
6109
|
//#region compiler/utils/file_resolver.ts
|
|
6106
6110
|
const contentCache = /* @__PURE__ */ new Map();
|
|
6111
|
+
let resolutionObserver = null;
|
|
6112
|
+
/** Synchronous extraction only; restore the previous observer even when extraction throws. */
|
|
6113
|
+
function observeFileResolutions(observer, run) {
|
|
6114
|
+
const previous = resolutionObserver;
|
|
6115
|
+
resolutionObserver = (source, fromFile, result) => {
|
|
6116
|
+
previous?.(source, fromFile, result);
|
|
6117
|
+
observer(source, fromFile, result);
|
|
6118
|
+
};
|
|
6119
|
+
try {
|
|
6120
|
+
return run();
|
|
6121
|
+
} finally {
|
|
6122
|
+
resolutionObserver = previous;
|
|
6123
|
+
}
|
|
6124
|
+
}
|
|
6107
6125
|
const resolver = new oxc_resolver.ResolverFactory({
|
|
6108
6126
|
conditionNames: [
|
|
6109
6127
|
"import",
|
|
@@ -6128,6 +6146,11 @@ function clearResolverCache() {
|
|
|
6128
6146
|
resolver.clearCache();
|
|
6129
6147
|
}
|
|
6130
6148
|
function resolveFile(source, fromFile) {
|
|
6149
|
+
const result = readResolvedFile(source, fromFile);
|
|
6150
|
+
resolutionObserver?.(source, fromFile, result);
|
|
6151
|
+
return result;
|
|
6152
|
+
}
|
|
6153
|
+
function readResolvedFile(source, fromFile) {
|
|
6131
6154
|
const filePath = resolveFilePath(source, fromFile);
|
|
6132
6155
|
if (!filePath) return null;
|
|
6133
6156
|
let stat;
|
|
@@ -7689,15 +7712,221 @@ var LazyBindings = class LazyBindings extends Map {
|
|
|
7689
7712
|
}
|
|
7690
7713
|
};
|
|
7691
7714
|
//#endregion
|
|
7715
|
+
//#region compiler/compiler/cache_identity.ts
|
|
7716
|
+
let identity;
|
|
7717
|
+
/** Fingerprint actual compiler and dependency bytes, including locally patched packages.
|
|
7718
|
+
* Computed once per process: replacing loaded compiler code requires restarting Node.
|
|
7719
|
+
*/
|
|
7720
|
+
function getCompilerCacheIdentity() {
|
|
7721
|
+
if (identity !== void 0) return identity;
|
|
7722
|
+
try {
|
|
7723
|
+
const filename = typeof __filename === "string" ? __filename : (0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
|
|
7724
|
+
const root = findPackageRoot(filename, "@fluentic/style");
|
|
7725
|
+
const hash = (0, node_crypto.createHash)("sha256");
|
|
7726
|
+
hash.update(JSON.stringify([
|
|
7727
|
+
process.versions,
|
|
7728
|
+
process.platform,
|
|
7729
|
+
process.arch,
|
|
7730
|
+
process.execArgv,
|
|
7731
|
+
process.env.NODE_OPTIONS,
|
|
7732
|
+
process.env.NODE_ENV,
|
|
7733
|
+
process.env.BABEL_ENV
|
|
7734
|
+
]));
|
|
7735
|
+
const visited = /* @__PURE__ */ new Set();
|
|
7736
|
+
const hashTree = (directory, source = false) => {
|
|
7737
|
+
for (const item of node_fs.readdirSync(directory, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
7738
|
+
if (item.name === "node_modules" || item.name === ".git") continue;
|
|
7739
|
+
const file = node_path.default.join(directory, item.name);
|
|
7740
|
+
if (item.isDirectory()) hashTree(file, source);
|
|
7741
|
+
else if (item.isFile()) {
|
|
7742
|
+
if (!(source ? /\.(?:[cm]?[jt]sx?|json|node|wasm)$/ : /\.(?:[cm]?js|json|node|wasm)$/).test(item.name)) continue;
|
|
7743
|
+
hash.update(file).update("\0").update(node_fs.readFileSync(file)).update("\0");
|
|
7744
|
+
} else throw new Error("Unsupported package entry");
|
|
7745
|
+
}
|
|
7746
|
+
};
|
|
7747
|
+
const visit = (directory) => {
|
|
7748
|
+
directory = node_fs.realpathSync(directory);
|
|
7749
|
+
if (visited.has(directory)) return;
|
|
7750
|
+
visited.add(directory);
|
|
7751
|
+
hashTree(directory);
|
|
7752
|
+
const manifest = JSON.parse(node_fs.readFileSync(node_path.default.join(directory, "package.json"), "utf8"));
|
|
7753
|
+
const require = (0, node_module.createRequire)(node_path.default.join(directory, "package.json"));
|
|
7754
|
+
const optional = manifest.optionalDependencies ?? {};
|
|
7755
|
+
for (const name of Object.keys({
|
|
7756
|
+
...manifest.dependencies,
|
|
7757
|
+
...optional
|
|
7758
|
+
}).sort()) {
|
|
7759
|
+
let dependency;
|
|
7760
|
+
try {
|
|
7761
|
+
dependency = resolvePackageRoot(require, name);
|
|
7762
|
+
} catch (error) {
|
|
7763
|
+
if (name in optional) {
|
|
7764
|
+
hash.update("absent:" + name);
|
|
7765
|
+
continue;
|
|
7766
|
+
}
|
|
7767
|
+
throw error;
|
|
7768
|
+
}
|
|
7769
|
+
visit(dependency);
|
|
7770
|
+
}
|
|
7771
|
+
};
|
|
7772
|
+
const manifest = JSON.parse(node_fs.readFileSync(node_path.default.join(root, "package.json"), "utf8"));
|
|
7773
|
+
hash.update(node_fs.readFileSync(node_path.default.join(root, "package.json")));
|
|
7774
|
+
if (filename.startsWith(node_path.default.join(root, "dist") + node_path.default.sep)) hashTree(node_path.default.join(root, "dist"));
|
|
7775
|
+
else for (const item of manifest.files) {
|
|
7776
|
+
if (item === "dist") continue;
|
|
7777
|
+
const file = node_path.default.join(root, item);
|
|
7778
|
+
if (!node_fs.existsSync(file)) continue;
|
|
7779
|
+
if (node_fs.statSync(file).isDirectory()) hashTree(file, true);
|
|
7780
|
+
else if (/\.[cm]?[jt]sx?$/.test(item)) hash.update(item).update(node_fs.readFileSync(file));
|
|
7781
|
+
}
|
|
7782
|
+
const require = (0, node_module.createRequire)(node_path.default.join(root, "package.json"));
|
|
7783
|
+
for (const name of [
|
|
7784
|
+
"@babel/core",
|
|
7785
|
+
"@jridgewell/trace-mapping",
|
|
7786
|
+
"css-what",
|
|
7787
|
+
"oxc-resolver",
|
|
7788
|
+
"picomatch"
|
|
7789
|
+
]) visit(resolvePackageRoot(require, name));
|
|
7790
|
+
identity = hash.digest("hex");
|
|
7791
|
+
} catch {
|
|
7792
|
+
identity = null;
|
|
7793
|
+
}
|
|
7794
|
+
return identity;
|
|
7795
|
+
}
|
|
7796
|
+
function resolvePackageRoot(require, name) {
|
|
7797
|
+
for (const directory of require.resolve.paths(name) ?? []) {
|
|
7798
|
+
const root = node_path.default.join(directory, name);
|
|
7799
|
+
if (node_fs.existsSync(node_path.default.join(root, "package.json"))) return node_fs.realpathSync(root);
|
|
7800
|
+
}
|
|
7801
|
+
try {
|
|
7802
|
+
return node_path.default.dirname(require.resolve(name + "/package.json"));
|
|
7803
|
+
} catch {
|
|
7804
|
+
return findPackageRoot(require.resolve(name), name);
|
|
7805
|
+
}
|
|
7806
|
+
}
|
|
7807
|
+
function findPackageRoot(filename, name) {
|
|
7808
|
+
let directory = node_path.default.dirname(filename);
|
|
7809
|
+
while (true) {
|
|
7810
|
+
const manifest = node_path.default.join(directory, "package.json");
|
|
7811
|
+
if (node_fs.existsSync(manifest) && JSON.parse(node_fs.readFileSync(manifest, "utf8")).name === name) return directory;
|
|
7812
|
+
const parent = node_path.default.dirname(directory);
|
|
7813
|
+
if (parent === directory) throw new Error("Package root not found");
|
|
7814
|
+
directory = parent;
|
|
7815
|
+
}
|
|
7816
|
+
}
|
|
7817
|
+
//#endregion
|
|
7818
|
+
//#region compiler/transform/evaluator/metadata_cache.ts
|
|
7819
|
+
const defaultParser = _babel_core.parseSync;
|
|
7820
|
+
const MAX_MEMORY_BYTES = 32 * 1024 * 1024;
|
|
7821
|
+
/** Immutable syntax only. Every consumer gets fresh nodes before annotations/evaluation. */
|
|
7822
|
+
function createTraceMetadataCache(internal) {
|
|
7823
|
+
const memory = /* @__PURE__ */ new Map();
|
|
7824
|
+
let memoryBytes = 0;
|
|
7825
|
+
let memoryVersion = internal.options.cache?.version;
|
|
7826
|
+
const stats = {
|
|
7827
|
+
parses: 0,
|
|
7828
|
+
memoryHits: 0,
|
|
7829
|
+
diskHits: 0,
|
|
7830
|
+
writes: 0
|
|
7831
|
+
};
|
|
7832
|
+
const remember = (filePath, contentHash, json) => {
|
|
7833
|
+
const previous = memory.get(filePath);
|
|
7834
|
+
if (previous) memoryBytes -= previous.json.length * 2;
|
|
7835
|
+
memory.delete(filePath);
|
|
7836
|
+
if (json.length * 2 > MAX_MEMORY_BYTES) return;
|
|
7837
|
+
while (memoryBytes + json.length * 2 > MAX_MEMORY_BYTES) {
|
|
7838
|
+
const oldest = memory.keys().next().value;
|
|
7839
|
+
memoryBytes -= memory.get(oldest).json.length * 2;
|
|
7840
|
+
memory.delete(oldest);
|
|
7841
|
+
}
|
|
7842
|
+
memory.set(filePath, {
|
|
7843
|
+
contentHash,
|
|
7844
|
+
json
|
|
7845
|
+
});
|
|
7846
|
+
memoryBytes += json.length * 2;
|
|
7847
|
+
};
|
|
7848
|
+
const parse = (babel, filePath, content) => {
|
|
7849
|
+
if (!Object.is(memoryVersion, internal.options.cache?.version)) {
|
|
7850
|
+
memory.clear();
|
|
7851
|
+
memoryBytes = 0;
|
|
7852
|
+
memoryVersion = internal.options.cache?.version;
|
|
7853
|
+
}
|
|
7854
|
+
const supportedParser = babel.parseSync === defaultParser;
|
|
7855
|
+
const contentHash = hash(content);
|
|
7856
|
+
const cached = supportedParser ? memory.get(filePath) : void 0;
|
|
7857
|
+
if (cached?.contentHash === contentHash) {
|
|
7858
|
+
stats.memoryHits++;
|
|
7859
|
+
memory.delete(filePath);
|
|
7860
|
+
memory.set(filePath, cached);
|
|
7861
|
+
return JSON.parse(cached.json);
|
|
7862
|
+
}
|
|
7863
|
+
const identity = supportedParser && internal.options.cache?.persistent !== false ? getCompilerCacheIdentity() : null;
|
|
7864
|
+
const filename = identity ? node_path.default.join(internal.cacheDir, "trace-metadata-v1", identity, hash(JSON.stringify(internal.options.cache?.version ?? null)), hash(filePath) + ".json") : null;
|
|
7865
|
+
if (filename) try {
|
|
7866
|
+
const record = JSON.parse(node_fs.readFileSync(filename, "utf8"));
|
|
7867
|
+
if (record.version === 1 && record.filePath === filePath && record.contentHash === contentHash && record.ast?.type === "File" && record.ast.program?.type === "Program" && Array.isArray(record.ast.program.body)) {
|
|
7868
|
+
const json = JSON.stringify(record.ast);
|
|
7869
|
+
if (record.checksum === hash(json)) {
|
|
7870
|
+
remember(filePath, contentHash, json);
|
|
7871
|
+
stats.diskHits++;
|
|
7872
|
+
return record.ast;
|
|
7873
|
+
}
|
|
7874
|
+
}
|
|
7875
|
+
} catch {}
|
|
7876
|
+
let ast;
|
|
7877
|
+
try {
|
|
7878
|
+
stats.parses++;
|
|
7879
|
+
ast = babel.parseSync(content, {
|
|
7880
|
+
...babelTransformOptions(),
|
|
7881
|
+
filename: filePath
|
|
7882
|
+
});
|
|
7883
|
+
} catch {
|
|
7884
|
+
return null;
|
|
7885
|
+
}
|
|
7886
|
+
if (!ast || !supportedParser) return ast;
|
|
7887
|
+
let temporary;
|
|
7888
|
+
try {
|
|
7889
|
+
const json = JSON.stringify(ast, (_key, value) => {
|
|
7890
|
+
if (typeof value === "number" && (!Number.isFinite(value) || Object.is(value, -0)) || typeof value === "bigint" || typeof value === "function" || typeof value === "symbol") throw new Error("Non-JSON syntax data");
|
|
7891
|
+
return value;
|
|
7892
|
+
});
|
|
7893
|
+
remember(filePath, contentHash, json);
|
|
7894
|
+
if (filename) {
|
|
7895
|
+
const record = {
|
|
7896
|
+
version: 1,
|
|
7897
|
+
filePath,
|
|
7898
|
+
contentHash,
|
|
7899
|
+
checksum: hash(json),
|
|
7900
|
+
ast
|
|
7901
|
+
};
|
|
7902
|
+
node_fs.mkdirSync(node_path.default.dirname(filename), { recursive: true });
|
|
7903
|
+
temporary = filename + "." + (0, node_crypto.randomUUID)() + ".tmp";
|
|
7904
|
+
node_fs.writeFileSync(temporary, JSON.stringify(record), "utf8");
|
|
7905
|
+
node_fs.renameSync(temporary, filename);
|
|
7906
|
+
stats.writes++;
|
|
7907
|
+
}
|
|
7908
|
+
} catch {} finally {
|
|
7909
|
+
if (temporary) try {
|
|
7910
|
+
node_fs.unlinkSync(temporary);
|
|
7911
|
+
} catch {}
|
|
7912
|
+
}
|
|
7913
|
+
return ast;
|
|
7914
|
+
};
|
|
7915
|
+
return {
|
|
7916
|
+
parse,
|
|
7917
|
+
getStats: () => ({ ...stats })
|
|
7918
|
+
};
|
|
7919
|
+
}
|
|
7920
|
+
function hash(content) {
|
|
7921
|
+
return (0, node_crypto.createHash)("sha256").update(content).digest("hex");
|
|
7922
|
+
}
|
|
7923
|
+
//#endregion
|
|
7692
7924
|
//#region compiler/transform/evaluator/tracer.ts
|
|
7693
|
-
const CACHE_TYPE = "transform-trace-
|
|
7925
|
+
const CACHE_TYPE = "transform-trace-links-v2";
|
|
7694
7926
|
function createTracer(internal) {
|
|
7695
7927
|
const active = /* @__PURE__ */ new Set();
|
|
7696
|
-
const
|
|
7697
|
-
const
|
|
7698
|
-
if (!dependencyHashes.has(filePath)) dependencyHashes.set(filePath, hashFileContent(filePath));
|
|
7699
|
-
return dependencyHashes.get(filePath) ?? null;
|
|
7700
|
-
};
|
|
7928
|
+
const cyclic = /* @__PURE__ */ new Set();
|
|
7929
|
+
const metadata = createTraceMetadataCache(internal);
|
|
7701
7930
|
const resolveImport = (babel, source, fromFile) => {
|
|
7702
7931
|
return traceModuleResult(babel, source, fromFile)?.bindings ?? null;
|
|
7703
7932
|
};
|
|
@@ -7710,27 +7939,43 @@ function createTracer(internal) {
|
|
|
7710
7939
|
contentHash,
|
|
7711
7940
|
cacheType: CACHE_TYPE
|
|
7712
7941
|
});
|
|
7713
|
-
if (cached?.bindings instanceof Map && areDependenciesFresh(cached.dependencies ?? []
|
|
7942
|
+
if (cached?.bindings instanceof Map && areDependenciesFresh(cached.dependencies ?? [])) return {
|
|
7943
|
+
source,
|
|
7944
|
+
fromFile,
|
|
7714
7945
|
filePath: resolved.filePath,
|
|
7715
7946
|
contentHash,
|
|
7716
7947
|
bindings: cached.bindings,
|
|
7717
7948
|
dependencies: cached.dependencies ?? []
|
|
7718
7949
|
};
|
|
7719
|
-
if (active.has(resolved.filePath))
|
|
7950
|
+
if (active.has(resolved.filePath)) {
|
|
7951
|
+
for (const file of active) cyclic.add(file);
|
|
7952
|
+
return null;
|
|
7953
|
+
}
|
|
7720
7954
|
active.add(resolved.filePath);
|
|
7721
7955
|
try {
|
|
7722
7956
|
const dependencies = /* @__PURE__ */ new Map();
|
|
7723
7957
|
const dependencyList = [];
|
|
7958
|
+
const onTrack = () => {
|
|
7959
|
+
dependencyList.splice(0, dependencyList.length, ...dependencies.values());
|
|
7960
|
+
};
|
|
7724
7961
|
const resolveDependency = (source, fromFile) => {
|
|
7962
|
+
const dependency = resolveFile(source, fromFile);
|
|
7963
|
+
addTraceDependency(dependencies, {
|
|
7964
|
+
source,
|
|
7965
|
+
fromFile,
|
|
7966
|
+
filePath: dependency?.filePath ?? null,
|
|
7967
|
+
contentHash: dependency ? hashContent(dependency.content) : null
|
|
7968
|
+
});
|
|
7969
|
+
onTrack();
|
|
7725
7970
|
const traced = traceModuleResult(babel, source, fromFile);
|
|
7726
7971
|
if (!traced) return null;
|
|
7727
|
-
return createTrackedBindings(traced, dependencies, () =>
|
|
7728
|
-
dependencyList.splice(0, dependencyList.length, ...dependencies.values());
|
|
7729
|
-
});
|
|
7972
|
+
return createTrackedBindings(traced, dependencies, onTrack, () => traceModuleResult(babel, source, fromFile));
|
|
7730
7973
|
};
|
|
7731
|
-
const
|
|
7974
|
+
const ast = metadata.parse(babel, resolved.filePath, resolved.content);
|
|
7975
|
+
if (!ast) return null;
|
|
7976
|
+
const bindings = extractModuleBindings(internal.projectDir, resolved.filePath, ast, babel, resolveDependency, internal.options);
|
|
7732
7977
|
if (!bindings) return null;
|
|
7733
|
-
internal.cache.setItem({
|
|
7978
|
+
if (!cyclic.has(resolved.filePath)) internal.cache.setItem({
|
|
7734
7979
|
filePath: resolved.filePath,
|
|
7735
7980
|
contentHash,
|
|
7736
7981
|
cacheType: CACHE_TYPE,
|
|
@@ -7741,6 +7986,8 @@ function createTracer(internal) {
|
|
|
7741
7986
|
}
|
|
7742
7987
|
});
|
|
7743
7988
|
return {
|
|
7989
|
+
source,
|
|
7990
|
+
fromFile,
|
|
7744
7991
|
filePath: resolved.filePath,
|
|
7745
7992
|
contentHash,
|
|
7746
7993
|
bindings,
|
|
@@ -7756,22 +8003,14 @@ function createTracer(internal) {
|
|
|
7756
8003
|
return {
|
|
7757
8004
|
resolveImport,
|
|
7758
8005
|
traceModule,
|
|
8006
|
+
getMetadataCacheStats: metadata.getStats,
|
|
7759
8007
|
beginCompilation() {
|
|
7760
|
-
|
|
8008
|
+
clearResolverCache();
|
|
8009
|
+
cyclic.clear();
|
|
7761
8010
|
}
|
|
7762
8011
|
};
|
|
7763
8012
|
}
|
|
7764
|
-
function
|
|
7765
|
-
let ast = null;
|
|
7766
|
-
try {
|
|
7767
|
-
ast = babel.parseSync(content, {
|
|
7768
|
-
...babelTransformOptions(),
|
|
7769
|
-
filename: filePath
|
|
7770
|
-
});
|
|
7771
|
-
} catch {
|
|
7772
|
-
return null;
|
|
7773
|
-
}
|
|
7774
|
-
if (!ast) return null;
|
|
8013
|
+
function extractModuleBindings(projectDir, filePath, ast, babel, resolveImport, options) {
|
|
7775
8014
|
const imports = /* @__PURE__ */ new Map();
|
|
7776
8015
|
const rawBindings = /* @__PURE__ */ new Map();
|
|
7777
8016
|
const bindings = new LazyBindings();
|
|
@@ -8040,12 +8279,12 @@ function createSlotRef(fileId, loc) {
|
|
|
8040
8279
|
};
|
|
8041
8280
|
}
|
|
8042
8281
|
function hashContent(content) {
|
|
8043
|
-
return node_crypto.createHash("sha256").update(content).digest("hex")
|
|
8282
|
+
return node_crypto.createHash("sha256").update(content).digest("hex");
|
|
8044
8283
|
}
|
|
8045
8284
|
function addTraceDependency(dependencies, dependency) {
|
|
8046
|
-
dependencies.set(dependency.
|
|
8285
|
+
dependencies.set(JSON.stringify([dependency.source, dependency.fromFile]), dependency);
|
|
8047
8286
|
}
|
|
8048
|
-
function createTrackedBindings(traced, dependencies, onTrack) {
|
|
8287
|
+
function createTrackedBindings(traced, dependencies, onTrack, refresh) {
|
|
8049
8288
|
const track = () => {
|
|
8050
8289
|
addTraceDependency(dependencies, traced);
|
|
8051
8290
|
traced.dependencies.forEach((dependency) => addTraceDependency(dependencies, dependency));
|
|
@@ -8053,24 +8292,39 @@ function createTrackedBindings(traced, dependencies, onTrack) {
|
|
|
8053
8292
|
};
|
|
8054
8293
|
const bindings = new LazyBindings();
|
|
8055
8294
|
for (const key of traced.bindings.keys()) bindings.setLazy(key, () => {
|
|
8056
|
-
const
|
|
8295
|
+
const current = refresh();
|
|
8296
|
+
if (!current) return evalFail(`Cannot resolve export: ${key}`);
|
|
8297
|
+
traced = current;
|
|
8298
|
+
const value = traced.bindings.get(key) ?? evalFail(`Cannot resolve export: ${key}`);
|
|
8057
8299
|
track();
|
|
8058
8300
|
return value;
|
|
8059
8301
|
});
|
|
8060
8302
|
track();
|
|
8061
8303
|
return bindings;
|
|
8062
8304
|
}
|
|
8063
|
-
function areDependenciesFresh(dependencies
|
|
8064
|
-
for (const dependency of dependencies)
|
|
8305
|
+
function areDependenciesFresh(dependencies) {
|
|
8306
|
+
for (const dependency of dependencies) {
|
|
8307
|
+
const current = resolveFile(dependency.source, dependency.fromFile);
|
|
8308
|
+
if ((current?.filePath ?? null) !== dependency.filePath || (current ? hashContent(current.content) : null) !== dependency.contentHash) return false;
|
|
8309
|
+
}
|
|
8065
8310
|
return true;
|
|
8066
8311
|
}
|
|
8067
|
-
|
|
8312
|
+
//#endregion
|
|
8313
|
+
//#region compiler/utils/check_diagnostics.ts
|
|
8314
|
+
let observer;
|
|
8315
|
+
/** Extraction is synchronous; restore the previous observer for nested compilations. */
|
|
8316
|
+
function observeCheckDiagnostics(onDiagnostic, run) {
|
|
8317
|
+
const previous = observer;
|
|
8318
|
+
observer = onDiagnostic;
|
|
8068
8319
|
try {
|
|
8069
|
-
return
|
|
8070
|
-
}
|
|
8071
|
-
|
|
8320
|
+
return run();
|
|
8321
|
+
} finally {
|
|
8322
|
+
observer = previous;
|
|
8072
8323
|
}
|
|
8073
8324
|
}
|
|
8325
|
+
function recordCheckDiagnostic(diagnostic) {
|
|
8326
|
+
observer?.(diagnostic);
|
|
8327
|
+
}
|
|
8074
8328
|
//#endregion
|
|
8075
8329
|
//#region compiler/utils/imports.ts
|
|
8076
8330
|
function getStyleRuntimeImportPath(mode) {
|
|
@@ -8699,6 +8953,10 @@ function createExtractPlugin(args) {
|
|
|
8699
8953
|
}
|
|
8700
8954
|
if (!result) return;
|
|
8701
8955
|
checkCompiledImportantUsage(result, options.check?.important, (level, message) => {
|
|
8956
|
+
recordCheckDiagnostic({
|
|
8957
|
+
level,
|
|
8958
|
+
message
|
|
8959
|
+
});
|
|
8702
8960
|
if (level === "error") throw path.buildCodeFrameError(message);
|
|
8703
8961
|
console.warn("[fluentic-style] " + message);
|
|
8704
8962
|
});
|
|
@@ -9041,11 +9299,248 @@ function createPlugin(rewriteSource) {
|
|
|
9041
9299
|
});
|
|
9042
9300
|
}
|
|
9043
9301
|
//#endregion
|
|
9302
|
+
//#region compiler/compiler/persistent_cache.ts
|
|
9303
|
+
function createPersistentTransformCache(internal) {
|
|
9304
|
+
const stats = {
|
|
9305
|
+
hits: 0,
|
|
9306
|
+
misses: 0,
|
|
9307
|
+
bypasses: 0,
|
|
9308
|
+
writes: 0
|
|
9309
|
+
};
|
|
9310
|
+
const directory = node_path.default.join(internal.cacheDir, "extract-v1");
|
|
9311
|
+
let previousContext = null;
|
|
9312
|
+
const contextFor = () => {
|
|
9313
|
+
if (internal.options.cache?.persistent === false || DEV_CONFIG.isDev) return null;
|
|
9314
|
+
try {
|
|
9315
|
+
const identity = getCompilerCacheIdentity();
|
|
9316
|
+
if (!identity) return null;
|
|
9317
|
+
const options = internal.options;
|
|
9318
|
+
assertDataProperties(options);
|
|
9319
|
+
if (Object.getPrototypeOf(options) !== Object.prototype && Object.getPrototypeOf(options) !== null) throw new Error("Non-plain compiler options");
|
|
9320
|
+
if (options.importSources) assertPlainArray(options.importSources);
|
|
9321
|
+
const importSources = options.importSources?.map((entry) => {
|
|
9322
|
+
assertDataProperties(entry);
|
|
9323
|
+
if (Object.getPrototypeOf(entry) !== Object.prototype && Object.getPrototypeOf(entry) !== null) throw new Error("Non-plain import source");
|
|
9324
|
+
if (entry.styleFn && node_util.types.isProxy(entry.styleFn)) throw new Error("Proxy style function");
|
|
9325
|
+
if (!entry.meta && entry.styleFn) {
|
|
9326
|
+
const metadata = Object.getOwnPropertyDescriptor(entry.styleFn, symbol("style.fn:meta"));
|
|
9327
|
+
if (!metadata || !("value" in metadata)) throw new Error("Dynamic style metadata");
|
|
9328
|
+
}
|
|
9329
|
+
return {
|
|
9330
|
+
...entry,
|
|
9331
|
+
styleFn: void 0,
|
|
9332
|
+
meta: entry.meta ?? (entry.styleFn ? getStyleFnMeta(entry.styleFn) : null)
|
|
9333
|
+
};
|
|
9334
|
+
});
|
|
9335
|
+
return digest(encode({
|
|
9336
|
+
schema: 1,
|
|
9337
|
+
identity,
|
|
9338
|
+
cwd: process.cwd(),
|
|
9339
|
+
projectDir: internal.projectDir,
|
|
9340
|
+
runtimeMode: internal.runtimeMode,
|
|
9341
|
+
options: {
|
|
9342
|
+
...options,
|
|
9343
|
+
importSources
|
|
9344
|
+
},
|
|
9345
|
+
globals: {
|
|
9346
|
+
CSS_CONFIG,
|
|
9347
|
+
CSS_EXTRA_CONFIG,
|
|
9348
|
+
DEBUG_CONFIG,
|
|
9349
|
+
DEV_CONFIG,
|
|
9350
|
+
IS_DEV,
|
|
9351
|
+
RUNTIME_CONFIG,
|
|
9352
|
+
CHECK_CONFIG,
|
|
9353
|
+
DEFAULT_CONFIG,
|
|
9354
|
+
PrioritySelectors
|
|
9355
|
+
}
|
|
9356
|
+
}, options.cache?.dynamicConfig !== false));
|
|
9357
|
+
} catch {
|
|
9358
|
+
return null;
|
|
9359
|
+
}
|
|
9360
|
+
};
|
|
9361
|
+
const run = (args, compile) => {
|
|
9362
|
+
const context = contextFor();
|
|
9363
|
+
let key = null;
|
|
9364
|
+
try {
|
|
9365
|
+
if (context) key = digest(encode({
|
|
9366
|
+
context,
|
|
9367
|
+
args
|
|
9368
|
+
}));
|
|
9369
|
+
} catch {}
|
|
9370
|
+
if (!key) {
|
|
9371
|
+
stats.bypasses++;
|
|
9372
|
+
previousContext = null;
|
|
9373
|
+
internal.cache.clear();
|
|
9374
|
+
clearResolverCache();
|
|
9375
|
+
return {
|
|
9376
|
+
result: compile(),
|
|
9377
|
+
hit: false
|
|
9378
|
+
};
|
|
9379
|
+
}
|
|
9380
|
+
const filename = node_path.default.join(directory, getCompilerCacheIdentity(), digest(encode(internal.options.cache?.version)), digest(args.filePath) + ".bin");
|
|
9381
|
+
clearResolverCache();
|
|
9382
|
+
let hit;
|
|
9383
|
+
try {
|
|
9384
|
+
const buffer = node_fs.readFileSync(filename);
|
|
9385
|
+
const body = buffer.subarray(65);
|
|
9386
|
+
if (buffer.subarray(0, 64).toString() === digest(body)) {
|
|
9387
|
+
const record = (0, node_v8.deserialize)(body);
|
|
9388
|
+
if (record.key === key && Array.isArray(record.dependencies) && validRecord(record) && record.dependencies.every(isFresh)) hit = record;
|
|
9389
|
+
}
|
|
9390
|
+
} catch {}
|
|
9391
|
+
if (hit) {
|
|
9392
|
+
stats.hits++;
|
|
9393
|
+
for (const diagnostic of hit.diagnostics) if (diagnostic.level === "warn") console.warn("[fluentic-style] " + diagnostic.message);
|
|
9394
|
+
if (hit.error) {
|
|
9395
|
+
const error = new Error(hit.error.message);
|
|
9396
|
+
error.name = hit.error.name;
|
|
9397
|
+
error.stack = hit.error.stack;
|
|
9398
|
+
throw error;
|
|
9399
|
+
}
|
|
9400
|
+
return {
|
|
9401
|
+
result: hit.result,
|
|
9402
|
+
hit: true
|
|
9403
|
+
};
|
|
9404
|
+
}
|
|
9405
|
+
stats.misses++;
|
|
9406
|
+
clearResolverCache();
|
|
9407
|
+
if (context !== previousContext) internal.cache.clear();
|
|
9408
|
+
previousContext = context;
|
|
9409
|
+
const dependencies = /* @__PURE__ */ new Map();
|
|
9410
|
+
const diagnostics = [];
|
|
9411
|
+
let result = null;
|
|
9412
|
+
let failure = null;
|
|
9413
|
+
try {
|
|
9414
|
+
result = observeCheckDiagnostics((diagnostic) => diagnostics.push(diagnostic), () => observeFileResolutions((source, fromFile, resolved) => {
|
|
9415
|
+
dependencies.set(JSON.stringify([source, fromFile]), {
|
|
9416
|
+
source,
|
|
9417
|
+
fromFile,
|
|
9418
|
+
filePath: resolved?.filePath ?? null,
|
|
9419
|
+
hash: resolved ? digest(resolved.content) : null
|
|
9420
|
+
});
|
|
9421
|
+
}, compile));
|
|
9422
|
+
} catch (error) {
|
|
9423
|
+
if (!(error instanceof Error) || diagnostics[diagnostics.length - 1]?.level !== "error") throw error;
|
|
9424
|
+
failure = error;
|
|
9425
|
+
}
|
|
9426
|
+
const cachedError = failure ? {
|
|
9427
|
+
name: failure.name,
|
|
9428
|
+
message: failure.message,
|
|
9429
|
+
stack: failure.stack
|
|
9430
|
+
} : null;
|
|
9431
|
+
if (result || failure) {
|
|
9432
|
+
let temporary;
|
|
9433
|
+
try {
|
|
9434
|
+
encode(result);
|
|
9435
|
+
const records = [...dependencies.values()];
|
|
9436
|
+
clearResolverCache();
|
|
9437
|
+
if (!records.every(isFresh) || contextFor() !== context) throw new Error("Cache snapshot changed");
|
|
9438
|
+
const body = (0, node_v8.serialize)({
|
|
9439
|
+
key,
|
|
9440
|
+
dependencies: records,
|
|
9441
|
+
result,
|
|
9442
|
+
diagnostics,
|
|
9443
|
+
error: cachedError
|
|
9444
|
+
});
|
|
9445
|
+
node_fs.mkdirSync(node_path.default.dirname(filename), { recursive: true });
|
|
9446
|
+
temporary = filename + "." + (0, node_crypto.randomUUID)() + ".tmp";
|
|
9447
|
+
node_fs.writeFileSync(temporary, Buffer.concat([Buffer.from(digest(body) + "\n"), body]));
|
|
9448
|
+
node_fs.renameSync(temporary, filename);
|
|
9449
|
+
stats.writes++;
|
|
9450
|
+
} catch {} finally {
|
|
9451
|
+
if (temporary) try {
|
|
9452
|
+
node_fs.unlinkSync(temporary);
|
|
9453
|
+
} catch {}
|
|
9454
|
+
}
|
|
9455
|
+
}
|
|
9456
|
+
if (failure) throw failure;
|
|
9457
|
+
return {
|
|
9458
|
+
result,
|
|
9459
|
+
hit: false
|
|
9460
|
+
};
|
|
9461
|
+
};
|
|
9462
|
+
return {
|
|
9463
|
+
run,
|
|
9464
|
+
getStats: () => ({ ...stats })
|
|
9465
|
+
};
|
|
9466
|
+
}
|
|
9467
|
+
function isFresh(dependency) {
|
|
9468
|
+
if (typeof dependency.source !== "string" || typeof dependency.fromFile !== "string") return false;
|
|
9469
|
+
const resolved = resolveFile(dependency.source, dependency.fromFile);
|
|
9470
|
+
return (resolved?.filePath ?? null) === dependency.filePath && (resolved ? digest(resolved.content) : null) === dependency.hash;
|
|
9471
|
+
}
|
|
9472
|
+
function validRecord(record) {
|
|
9473
|
+
if (!Array.isArray(record.diagnostics) || !record.diagnostics.every((item) => item && (item.level === "warn" || item.level === "error") && typeof item.message === "string")) return false;
|
|
9474
|
+
if (record.error) return record.result === null && record.diagnostics[record.diagnostics.length - 1]?.level === "error" && typeof record.error.name === "string" && typeof record.error.message === "string" && (record.error.stack === void 0 || typeof record.error.stack === "string");
|
|
9475
|
+
return record.error === null && record.diagnostics.every((item) => item.level === "warn") && validResult(record.result);
|
|
9476
|
+
}
|
|
9477
|
+
function validResult(result) {
|
|
9478
|
+
return !!result && typeof result.code === "string" && (result.sourcemap === null || typeof result.sourcemap === "string") && Array.isArray(result.rules) && result.rules.every((rule) => typeof rule.css === "string" && typeof rule.dedupe === "string" && typeof rule.className === "string" && Array.isArray(rule.priority));
|
|
9479
|
+
}
|
|
9480
|
+
function digest(value) {
|
|
9481
|
+
return (0, node_crypto.createHash)("sha256").update(value).digest("hex");
|
|
9482
|
+
}
|
|
9483
|
+
function assertDataProperties(value) {
|
|
9484
|
+
if (node_util.types.isProxy(value)) throw new Error("Proxy configuration");
|
|
9485
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
9486
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
9487
|
+
if (typeof key === "symbol" || !("value" in descriptor) || !descriptor.enumerable && !(Array.isArray(value) && key === "length") && !(value instanceof RegExp && key === "lastIndex")) throw new Error("Dynamic configuration");
|
|
9488
|
+
}
|
|
9489
|
+
}
|
|
9490
|
+
function assertPlainArray(value) {
|
|
9491
|
+
assertDataProperties(value);
|
|
9492
|
+
if (Object.getPrototypeOf(value) !== Array.prototype || Object.keys(value).some((key) => !/^(0|[1-9][0-9]*)$/.test(key))) throw new Error("Non-plain array");
|
|
9493
|
+
}
|
|
9494
|
+
/** Tagged, order-preserving encoding: property order can affect generated CSS. */
|
|
9495
|
+
function encode(value, dynamicConfig = false) {
|
|
9496
|
+
return JSON.stringify(encodeValue(value, /* @__PURE__ */ new Set(), dynamicConfig));
|
|
9497
|
+
}
|
|
9498
|
+
function encodeValue(value, seen = /* @__PURE__ */ new Set(), dynamicConfig = false) {
|
|
9499
|
+
if (typeof value === "function" && dynamicConfig) {
|
|
9500
|
+
if (node_util.types.isProxy(value)) throw new Error("Proxy callback");
|
|
9501
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
9502
|
+
if (typeof key !== "string" || ![
|
|
9503
|
+
"length",
|
|
9504
|
+
"name",
|
|
9505
|
+
"prototype",
|
|
9506
|
+
"arguments",
|
|
9507
|
+
"caller"
|
|
9508
|
+
].includes(key)) throw new Error("Callback with custom properties");
|
|
9509
|
+
if (!("value" in Object.getOwnPropertyDescriptor(value, key))) throw new Error("Callback accessor");
|
|
9510
|
+
}
|
|
9511
|
+
const source = Function.prototype.toString.call(value);
|
|
9512
|
+
if (source.includes("[native code]")) throw new Error("Opaque callback");
|
|
9513
|
+
return ["function", source];
|
|
9514
|
+
}
|
|
9515
|
+
if (value === void 0) return ["undefined"];
|
|
9516
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return value;
|
|
9517
|
+
if (typeof value === "number" && Number.isFinite(value)) return ["number", Object.is(value, -0) ? "-0" : value];
|
|
9518
|
+
if (typeof value !== "object" || value === null || seen.has(value)) throw new Error("Unsupported cache input");
|
|
9519
|
+
assertDataProperties(value);
|
|
9520
|
+
if (value instanceof RegExp) {
|
|
9521
|
+
if (value.global || value.sticky || Object.getPrototypeOf(value) !== RegExp.prototype || Object.keys(value).length) throw new Error("Dynamic pattern");
|
|
9522
|
+
return [
|
|
9523
|
+
"regexp",
|
|
9524
|
+
value.source,
|
|
9525
|
+
value.flags
|
|
9526
|
+
];
|
|
9527
|
+
}
|
|
9528
|
+
if (Array.isArray(value)) assertPlainArray(value);
|
|
9529
|
+
if (!Array.isArray(value) && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) throw new Error("Non-plain cache input");
|
|
9530
|
+
seen.add(value);
|
|
9531
|
+
try {
|
|
9532
|
+
return [Array.isArray(value) ? ["array", value.length] : "object", Object.keys(value).map((key) => [key, encodeValue(value[key], seen, dynamicConfig)])];
|
|
9533
|
+
} finally {
|
|
9534
|
+
seen.delete(value);
|
|
9535
|
+
}
|
|
9536
|
+
}
|
|
9537
|
+
//#endregion
|
|
9044
9538
|
//#region compiler/compiler/compiler.ts
|
|
9045
9539
|
function createCompiler(args, options) {
|
|
9046
9540
|
const internal = createCompilerInternal(args, options);
|
|
9047
9541
|
const tracer = createTracer(internal);
|
|
9048
9542
|
const collector = createCssCollector();
|
|
9543
|
+
const persistentCache = createPersistentTransformCache(internal);
|
|
9049
9544
|
const compileDebug = (args) => {
|
|
9050
9545
|
tracer.beginCompilation();
|
|
9051
9546
|
return rewriteTransformResult(transformDebug(internal, args, { tracer }), internal.runtimeMode, args.code);
|
|
@@ -9072,6 +9567,17 @@ function createCompiler(args, options) {
|
|
|
9072
9567
|
};
|
|
9073
9568
|
};
|
|
9074
9569
|
const compileExtract = (args) => {
|
|
9570
|
+
const startIndex = collector.getItems().length;
|
|
9571
|
+
try {
|
|
9572
|
+
const cached = persistentCache.run(args, () => compileExtractUncached(args));
|
|
9573
|
+
if (cached.hit && cached.result) collector.addMany(cached.result.rules);
|
|
9574
|
+
return cached.result;
|
|
9575
|
+
} catch (error) {
|
|
9576
|
+
collector.getItems().splice(startIndex);
|
|
9577
|
+
throw error;
|
|
9578
|
+
}
|
|
9579
|
+
};
|
|
9580
|
+
const compileExtractUncached = (args) => {
|
|
9075
9581
|
tracer.beginCompilation();
|
|
9076
9582
|
const startIndex = collector.getItems().length;
|
|
9077
9583
|
const result = transformExtract(internal, args, {
|
|
@@ -9099,11 +9605,14 @@ function createCompiler(args, options) {
|
|
|
9099
9605
|
compileDebugRSC,
|
|
9100
9606
|
compileExtract,
|
|
9101
9607
|
getExtractedCss,
|
|
9102
|
-
invalidateFile
|
|
9608
|
+
invalidateFile,
|
|
9609
|
+
getPersistentCacheStats: persistentCache.getStats,
|
|
9610
|
+
getTraceMetadataCacheStats: tracer.getMetadataCacheStats
|
|
9103
9611
|
};
|
|
9104
9612
|
}
|
|
9105
9613
|
function createCompilerInternal(args, options) {
|
|
9106
|
-
const { projectDir,
|
|
9614
|
+
const { projectDir, runtimeMode } = args;
|
|
9615
|
+
const cacheDir = options.cache?.location === void 0 ? args.cacheDir : node_path.default.resolve(projectDir, options.cache.location);
|
|
9107
9616
|
return {
|
|
9108
9617
|
projectDir,
|
|
9109
9618
|
cacheDir,
|
|
@@ -9183,6 +9692,7 @@ const CssPropPresets = {
|
|
|
9183
9692
|
//#endregion
|
|
9184
9693
|
//#region plugin/utils/constants.ts
|
|
9185
9694
|
const PLUGIN_NAME = "fluentic-style";
|
|
9695
|
+
const PLUGIN_CACHE_DIR = "node_modules/.cache/fluentic-style";
|
|
9186
9696
|
const EXTRACTED_CSS_MARKER = ".__fluentic_style_css_marker__{--fluentic-style:0}";
|
|
9187
9697
|
//#endregion
|
|
9188
9698
|
//#region plugin/utils/filter.ts
|
|
@@ -9244,7 +9754,7 @@ function escapeRegExp(value) {
|
|
|
9244
9754
|
//#endregion
|
|
9245
9755
|
//#region plugin/utils/compiler.ts
|
|
9246
9756
|
function getPluginCacheDir(projectDir, cacheDir) {
|
|
9247
|
-
return cacheDir
|
|
9757
|
+
return cacheDir === void 0 ? node_path.default.join(projectDir, PLUGIN_CACHE_DIR) : node_path.default.resolve(projectDir, cacheDir);
|
|
9248
9758
|
}
|
|
9249
9759
|
function createPluginCompiler(args) {
|
|
9250
9760
|
const dev = args.dev;
|
|
@@ -9640,7 +10150,7 @@ let stateKey = "";
|
|
|
9640
10150
|
function getParcelState(options, pluginOptions = {}) {
|
|
9641
10151
|
const projectDir = options.projectRoot ?? process.cwd();
|
|
9642
10152
|
const dev = options.mode !== "production";
|
|
9643
|
-
const cacheDir = getPluginCacheDir(projectDir, pluginOptions.
|
|
10153
|
+
const cacheDir = getPluginCacheDir(projectDir, pluginOptions.cache?.location);
|
|
9644
10154
|
const key = JSON.stringify({
|
|
9645
10155
|
projectDir,
|
|
9646
10156
|
dev,
|
|
@@ -9888,4 +10398,4 @@ Object.defineProperty(exports, "writeParcelVirtualRuntimeFile", {
|
|
|
9888
10398
|
}
|
|
9889
10399
|
});
|
|
9890
10400
|
|
|
9891
|
-
//# sourceMappingURL=shared-
|
|
10401
|
+
//# sourceMappingURL=shared-CcB1KDFI.cjs.map
|