boss-css 0.0.1 → 0.0.2
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/README.md +1 -0
- package/dist/_virtual/rolldown_runtime.cjs +43 -0
- package/dist/_virtual/rolldown_runtime.mjs +20 -0
- package/dist/api/browser.cjs +54 -0
- package/dist/api/browser.mjs +48 -0
- package/dist/api/config.cjs +94 -0
- package/dist/api/config.mjs +91 -0
- package/dist/api/css.cjs +304 -0
- package/dist/api/css.mjs +303 -0
- package/dist/api/dictionary.cjs +218 -0
- package/dist/api/dictionary.mjs +215 -0
- package/dist/api/file/dts.cjs +21 -0
- package/dist/api/file/dts.mjs +21 -0
- package/dist/api/file/file.cjs +123 -0
- package/dist/api/file/file.mjs +120 -0
- package/dist/api/file/js.cjs +118 -0
- package/dist/api/file/js.mjs +116 -0
- package/dist/api/names.cjs +52 -0
- package/dist/api/names.mjs +46 -0
- package/dist/api/noopCss.cjs +37 -0
- package/dist/api/noopCss.mjs +36 -0
- package/dist/api/propTree.cjs +54 -0
- package/dist/api/propTree.mjs +48 -0
- package/dist/api/server.cjs +112 -0
- package/dist/api/server.mjs +106 -0
- package/dist/cli/build.cjs +1 -0
- package/dist/cli/build.mjs +3 -0
- package/dist/cli/index.cjs +30 -0
- package/dist/cli/index.mjs +29 -0
- package/dist/cli/tasks/build.cjs +24 -0
- package/dist/cli/tasks/build.mjs +23 -0
- package/dist/cli/tasks/choose.cjs +47 -0
- package/dist/cli/tasks/choose.mjs +46 -0
- package/dist/cli/tasks/compile.cjs +68 -0
- package/dist/cli/tasks/compile.mjs +67 -0
- package/dist/cli/tasks/dev.cjs +51 -0
- package/dist/cli/tasks/dev.mjs +48 -0
- package/dist/cli/tasks/init.cjs +1835 -0
- package/dist/cli/tasks/init.mjs +1831 -0
- package/dist/cli/tasks/watch.cjs +38 -0
- package/dist/cli/tasks/watch.mjs +37 -0
- package/dist/cli/templates/init.cjs +82 -0
- package/dist/cli/templates/init.mjs +78 -0
- package/dist/cli/types.cjs +13 -0
- package/dist/cli/types.mjs +13 -0
- package/dist/cli/utils.cjs +43 -0
- package/dist/cli/utils.mjs +41 -0
- package/dist/compile/classname-strategy.cjs +79 -0
- package/dist/compile/classname-strategy.mjs +77 -0
- package/dist/compile/classname.cjs +366 -0
- package/dist/compile/classname.mjs +360 -0
- package/dist/compile/index.cjs +238 -0
- package/dist/compile/index.mjs +235 -0
- package/dist/compile/jsx.cjs +803 -0
- package/dist/compile/jsx.mjs +800 -0
- package/dist/compile/prepared.cjs +88 -0
- package/dist/compile/prepared.mjs +87 -0
- package/dist/compile/runtime.cjs +33 -0
- package/dist/compile/runtime.mjs +32 -0
- package/dist/compile/transform.cjs +371 -0
- package/dist/compile/transform.mjs +369 -0
- package/dist/cx/index.cjs +93 -0
- package/dist/cx/index.mjs +85 -0
- package/dist/detect-fw/index.cjs +384 -0
- package/dist/detect-fw/index.mjs +379 -0
- package/dist/dev/client.cjs +39 -0
- package/dist/dev/client.mjs +38 -0
- package/dist/dev/plugin/browser.cjs +11 -0
- package/dist/dev/plugin/browser.mjs +9 -0
- package/dist/dev/plugin/server.cjs +86 -0
- package/dist/dev/plugin/server.mjs +78 -0
- package/dist/dev/port.cjs +46 -0
- package/dist/dev/port.mjs +43 -0
- package/dist/dev/runtime.cjs +28 -0
- package/dist/dev/runtime.mjs +29 -0
- package/dist/dev/server.cjs +808 -0
- package/dist/dev/server.mjs +805 -0
- package/dist/dev/shared.cjs +6 -0
- package/dist/dev/shared.mjs +5 -0
- package/dist/eslint-plugin/index.cjs +66 -0
- package/dist/eslint-plugin/index.mjs +66 -0
- package/dist/eslint-plugin/rules/classnames-only.cjs +68 -0
- package/dist/eslint-plugin/rules/classnames-only.mjs +68 -0
- package/dist/eslint-plugin/rules/format-classnames.cjs +137 -0
- package/dist/eslint-plugin/rules/format-classnames.mjs +136 -0
- package/dist/eslint-plugin/rules/no-unknown-classes.cjs +119 -0
- package/dist/eslint-plugin/rules/no-unknown-classes.mjs +119 -0
- package/dist/eslint-plugin/rules/prefer-classnames.cjs +69 -0
- package/dist/eslint-plugin/rules/prefer-classnames.mjs +69 -0
- package/dist/eslint-plugin/rules/prefer-token-values.cjs +197 -0
- package/dist/eslint-plugin/rules/prefer-token-values.mjs +197 -0
- package/dist/eslint-plugin/rules/props-only.cjs +115 -0
- package/dist/eslint-plugin/rules/props-only.mjs +115 -0
- package/dist/eslint-plugin/rules/redundant-cx.cjs +66 -0
- package/dist/eslint-plugin/rules/redundant-cx.mjs +66 -0
- package/dist/eslint-plugin/rules/require-prop-functions.cjs +130 -0
- package/dist/eslint-plugin/rules/require-prop-functions.mjs +130 -0
- package/dist/eslint-plugin/utils/api.cjs +30 -0
- package/dist/eslint-plugin/utils/api.mjs +29 -0
- package/dist/eslint-plugin/utils/ast.cjs +119 -0
- package/dist/eslint-plugin/utils/ast.mjs +112 -0
- package/dist/eslint-plugin/utils/boss-classes.cjs +185 -0
- package/dist/eslint-plugin/utils/boss-classes.mjs +175 -0
- package/dist/eslint-plugin/utils/defaults.cjs +99 -0
- package/dist/eslint-plugin/utils/defaults.mjs +93 -0
- package/dist/eslint-plugin/utils/format.cjs +20 -0
- package/dist/eslint-plugin/utils/format.mjs +19 -0
- package/dist/eslint-plugin/utils/order.cjs +76 -0
- package/dist/eslint-plugin/utils/order.mjs +76 -0
- package/dist/eslint-plugin/utils/property-order.cjs +449 -0
- package/dist/eslint-plugin/utils/property-order.mjs +448 -0
- package/dist/eslint-plugin/utils/static.cjs +36 -0
- package/dist/eslint-plugin/utils/static.mjs +35 -0
- package/dist/fontsource/directory.cjs +39588 -0
- package/dist/fontsource/directory.mjs +39587 -0
- package/dist/fontsource/server.cjs +291 -0
- package/dist/fontsource/server.mjs +282 -0
- package/dist/index.cjs +10 -0
- package/dist/index.mjs +6 -0
- package/dist/log/browser.cjs +28 -0
- package/dist/log/browser.mjs +28 -0
- package/dist/log/server.cjs +32 -0
- package/dist/log/server.mjs +30 -0
- package/dist/merge/index.cjs +590 -0
- package/dist/merge/index.mjs +586 -0
- package/dist/native/browser.cjs +78 -0
- package/dist/native/browser.mjs +77 -0
- package/dist/native/server.cjs +180 -0
- package/dist/native/server.mjs +176 -0
- package/dist/native/styleTypes.cjs +168 -0
- package/dist/native/styleTypes.mjs +164 -0
- package/dist/parser/classname/server.cjs +239 -0
- package/dist/parser/classname/server.mjs +232 -0
- package/dist/parser/jsx/browser.cjs +66 -0
- package/dist/parser/jsx/browser.mjs +63 -0
- package/dist/parser/jsx/extractCode.cjs +99 -0
- package/dist/parser/jsx/extractCode.mjs +98 -0
- package/dist/parser/jsx/extractPrepared.cjs +123 -0
- package/dist/parser/jsx/extractPrepared.mjs +122 -0
- package/dist/parser/jsx/extractProps.cjs +234 -0
- package/dist/parser/jsx/extractProps.mjs +232 -0
- package/dist/parser/jsx/isDOMProp.cjs +17 -0
- package/dist/parser/jsx/isDOMProp.mjs +15 -0
- package/dist/parser/jsx/native.cjs +110 -0
- package/dist/parser/jsx/native.mjs +108 -0
- package/dist/parser/jsx/runtime.cjs +4 -0
- package/dist/parser/jsx/runtime.mjs +3 -0
- package/dist/parser/jsx/server.cjs +278 -0
- package/dist/parser/jsx/server.mjs +268 -0
- package/dist/postcss/index.cjs +16 -0
- package/dist/postcss/index.mjs +16 -0
- package/dist/prop/at/runtime-only.cjs +90 -0
- package/dist/prop/at/runtime-only.mjs +88 -0
- package/dist/prop/at/server.cjs +282 -0
- package/dist/prop/at/server.mjs +268 -0
- package/dist/prop/at/shared.cjs +153 -0
- package/dist/prop/at/shared.mjs +144 -0
- package/dist/prop/bosswind/browser.cjs +18 -0
- package/dist/prop/bosswind/browser.mjs +16 -0
- package/dist/prop/bosswind/runtime-only.cjs +18 -0
- package/dist/prop/bosswind/runtime-only.mjs +16 -0
- package/dist/prop/bosswind/server.cjs +81 -0
- package/dist/prop/bosswind/server.mjs +72 -0
- package/dist/prop/bosswind/shared.cjs +861 -0
- package/dist/prop/bosswind/shared.mjs +855 -0
- package/dist/prop/bosswind/tailwind-theme.cjs +703 -0
- package/dist/prop/bosswind/tailwind-theme.mjs +702 -0
- package/dist/prop/child/runtime-only.cjs +18 -0
- package/dist/prop/child/runtime-only.mjs +15 -0
- package/dist/prop/child/server.cjs +81 -0
- package/dist/prop/child/server.mjs +72 -0
- package/dist/prop/css/getDtsTemplate.cjs +65 -0
- package/dist/prop/css/getDtsTemplate.mjs +63 -0
- package/dist/prop/css/runtime-only.cjs +14 -0
- package/dist/prop/css/runtime-only.mjs +13 -0
- package/dist/prop/css/server.cjs +99 -0
- package/dist/prop/css/server.mjs +90 -0
- package/dist/prop/pseudo/runtime-only.cjs +23 -0
- package/dist/prop/pseudo/runtime-only.mjs +21 -0
- package/dist/prop/pseudo/server.cjs +91 -0
- package/dist/prop/pseudo/server.mjs +82 -0
- package/dist/prop/pseudo/shared.cjs +61 -0
- package/dist/prop/pseudo/shared.mjs +60 -0
- package/dist/reset/server.cjs +34 -0
- package/dist/reset/server.mjs +26 -0
- package/dist/runtime/index.cjs +119 -0
- package/dist/runtime/index.mjs +118 -0
- package/dist/runtime/preact.cjs +4 -0
- package/dist/runtime/preact.mjs +3 -0
- package/dist/runtime/qwik.cjs +21 -0
- package/dist/runtime/qwik.mjs +18 -0
- package/dist/runtime/react.cjs +4 -0
- package/dist/runtime/react.mjs +3 -0
- package/dist/runtime/solid.cjs +15 -0
- package/dist/runtime/solid.mjs +14 -0
- package/dist/runtime/stencil.cjs +25 -0
- package/dist/runtime/stencil.mjs +21 -0
- package/dist/runtime/style.cjs +14 -0
- package/dist/runtime/style.mjs +13 -0
- package/dist/shared/boundaries.cjs +288 -0
- package/dist/shared/boundaries.mjs +285 -0
- package/dist/shared/customCss.cjs +212 -0
- package/dist/shared/customCss.mjs +211 -0
- package/dist/shared/debug.cjs +76 -0
- package/dist/shared/debug.mjs +74 -0
- package/dist/shared/file.cjs +21 -0
- package/dist/shared/file.mjs +19 -0
- package/dist/shared/framework.cjs +10 -0
- package/dist/shared/framework.mjs +9 -0
- package/dist/shared/json.cjs +58 -0
- package/dist/shared/json.mjs +57 -0
- package/dist/shared/types.cjs +11 -0
- package/dist/shared/types.mjs +10 -0
- package/dist/strategy/classic/runtime-only.cjs +190 -0
- package/dist/strategy/classic/runtime-only.mjs +186 -0
- package/dist/strategy/classname-first/runtime-only.cjs +138 -0
- package/dist/strategy/classname-first/runtime-only.mjs +134 -0
- package/dist/strategy/classname-first/server.cjs +139 -0
- package/dist/strategy/classname-first/server.mjs +133 -0
- package/dist/strategy/classname-only/server.cjs +43 -0
- package/dist/strategy/classname-only/server.mjs +35 -0
- package/dist/strategy/inline-first/browser.cjs +61 -0
- package/dist/strategy/inline-first/browser.mjs +58 -0
- package/dist/strategy/inline-first/runtime-only.cjs +159 -0
- package/dist/strategy/inline-first/runtime-only.mjs +155 -0
- package/dist/strategy/inline-first/server.cjs +92 -0
- package/dist/strategy/inline-first/server.mjs +83 -0
- package/dist/strategy/runtime/runtime-only.cjs +24 -0
- package/dist/strategy/runtime/runtime-only.mjs +22 -0
- package/dist/strategy/runtime/server.cjs +72 -0
- package/dist/strategy/runtime/server.mjs +63 -0
- package/dist/strategy/runtime-only/css.cjs +183 -0
- package/dist/strategy/runtime-only/css.mjs +181 -0
- package/dist/tasks/build.cjs +88 -0
- package/dist/tasks/build.mjs +84 -0
- package/dist/tasks/compile.cjs +12 -0
- package/dist/tasks/compile.mjs +12 -0
- package/dist/tasks/postcss.cjs +116 -0
- package/dist/tasks/postcss.mjs +113 -0
- package/dist/tasks/session.cjs +46 -0
- package/dist/tasks/session.mjs +42 -0
- package/dist/tasks/watch.cjs +102 -0
- package/dist/tasks/watch.mjs +99 -0
- package/dist/transform/cache.cjs +24 -0
- package/dist/transform/cache.mjs +21 -0
- package/dist/transform/processFile.cjs +26 -0
- package/dist/transform/processFile.mjs +24 -0
- package/dist/use/token/browser.cjs +65 -0
- package/dist/use/token/browser.mjs +61 -0
- package/dist/use/token/runtime-only.cjs +245 -0
- package/dist/use/token/runtime-only.mjs +239 -0
- package/dist/use/token/server.cjs +325 -0
- package/dist/use/token/server.mjs +313 -0
- package/dist/use/token/vars.cjs +47 -0
- package/dist/use/token/vars.mjs +46 -0
- package/package.json +300 -4
- package/src/api/config.d.ts +1 -0
- package/src/fontsource/types.d.ts +50 -0
- package/src/packages/document-create-element/createElement.browser.js +3 -0
- package/src/packages/document-create-element/createElement.js +7 -0
- package/src/packages/document-create-element/package.json +17 -0
- package/src/packages/is-css-prop/browser.js +13 -0
- package/src/packages/is-css-prop/index.js +13 -0
- package/src/packages/is-css-prop/package-lock.json +52 -0
- package/src/packages/is-css-prop/package.json +17 -0
- package/src/prop/css/csstype.json +4387 -0
- package/src/prop/css/package.json +3 -0
- package/src/reset/reset.css +259 -0
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let node_path = require("node:path");
|
|
3
|
+
node_path = require_rolldown_runtime.__toESM(node_path);
|
|
4
|
+
let fast_glob = require("fast-glob");
|
|
5
|
+
fast_glob = require_rolldown_runtime.__toESM(fast_glob);
|
|
6
|
+
|
|
7
|
+
//#region src/shared/boundaries.ts
|
|
8
|
+
const DEFAULT_CRITICALITY = 2;
|
|
9
|
+
const GLOBAL_SOURCE = "<global>";
|
|
10
|
+
const BOUNDARY_PATTERN = "**/*.boss.css";
|
|
11
|
+
const normalizePath = (filePath) => node_path.default.resolve(filePath);
|
|
12
|
+
const getDepth = (dir) => dir.split(node_path.default.sep).filter(Boolean).length;
|
|
13
|
+
const normalizeCssText = (value) => {
|
|
14
|
+
return value.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\s+/g, " ").replace(/\s*([{}:;,>+~])\s*/g, "$1").replace(/;}/g, "}").trim();
|
|
15
|
+
};
|
|
16
|
+
const findBoundaryFiles = async (rootDir, config = {}) => {
|
|
17
|
+
const ignore = [...config.ignore ?? []];
|
|
18
|
+
ignore.push("**/node_modules/**");
|
|
19
|
+
return (await (0, fast_glob.default)(BOUNDARY_PATTERN, {
|
|
20
|
+
cwd: rootDir,
|
|
21
|
+
absolute: true,
|
|
22
|
+
onlyFiles: true,
|
|
23
|
+
ignore
|
|
24
|
+
})).map(normalizePath).sort((a, b) => a.localeCompare(b));
|
|
25
|
+
};
|
|
26
|
+
const buildBoundaryIndex = (boundaryFiles, stylesheetPath) => {
|
|
27
|
+
const normalizedStylesheet = normalizePath(stylesheetPath);
|
|
28
|
+
const globalNode = {
|
|
29
|
+
id: 0,
|
|
30
|
+
path: normalizedStylesheet,
|
|
31
|
+
dir: node_path.default.dirname(normalizedStylesheet),
|
|
32
|
+
depth: getDepth(node_path.default.dirname(normalizedStylesheet)),
|
|
33
|
+
parentId: null
|
|
34
|
+
};
|
|
35
|
+
const byId = new Map([[globalNode.id, globalNode]]);
|
|
36
|
+
const byPath = new Map([[globalNode.path, globalNode]]);
|
|
37
|
+
const byDir = /* @__PURE__ */ new Map();
|
|
38
|
+
const primaryByDir = /* @__PURE__ */ new Map();
|
|
39
|
+
const nodes = boundaryFiles.map((file, index) => {
|
|
40
|
+
const dir = node_path.default.dirname(file);
|
|
41
|
+
const node = {
|
|
42
|
+
id: index + 1,
|
|
43
|
+
path: file,
|
|
44
|
+
dir,
|
|
45
|
+
depth: getDepth(dir),
|
|
46
|
+
parentId: null
|
|
47
|
+
};
|
|
48
|
+
byId.set(node.id, node);
|
|
49
|
+
byPath.set(node.path, node);
|
|
50
|
+
const list = byDir.get(dir) ?? [];
|
|
51
|
+
list.push(node);
|
|
52
|
+
byDir.set(dir, list);
|
|
53
|
+
return node;
|
|
54
|
+
});
|
|
55
|
+
for (const [dir, list] of byDir.entries()) {
|
|
56
|
+
list.sort((a, b) => a.path.localeCompare(b.path));
|
|
57
|
+
primaryByDir.set(dir, list[0]);
|
|
58
|
+
if (list.length > 1) console.warn(`[boss-css] Multiple .boss.css files found in ${dir}. Using ${node_path.default.basename(list[0].path)} for boundary mapping.`);
|
|
59
|
+
}
|
|
60
|
+
for (const node of nodes) {
|
|
61
|
+
let current = node_path.default.dirname(node.dir);
|
|
62
|
+
while (true) {
|
|
63
|
+
const parent = primaryByDir.get(current);
|
|
64
|
+
if (parent) {
|
|
65
|
+
node.parentId = parent.id;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
const next = node_path.default.dirname(current);
|
|
69
|
+
if (!next || next === current) {
|
|
70
|
+
node.parentId = globalNode.id;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
current = next;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
global: globalNode,
|
|
78
|
+
byId,
|
|
79
|
+
byPath,
|
|
80
|
+
byDir,
|
|
81
|
+
primaryByDir,
|
|
82
|
+
nodes
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
const resolveBoundaryForSource = (source, index) => {
|
|
86
|
+
if (!source || source === GLOBAL_SOURCE) return index.global;
|
|
87
|
+
if (source.startsWith("<") && source.endsWith(">")) return index.global;
|
|
88
|
+
const resolved = normalizePath(source);
|
|
89
|
+
let current = node_path.default.dirname(resolved);
|
|
90
|
+
while (true) {
|
|
91
|
+
const boundary = index.primaryByDir.get(current);
|
|
92
|
+
if (boundary) return boundary;
|
|
93
|
+
const next = node_path.default.dirname(current);
|
|
94
|
+
if (!next || next === current) break;
|
|
95
|
+
current = next;
|
|
96
|
+
}
|
|
97
|
+
return index.global;
|
|
98
|
+
};
|
|
99
|
+
const getAncestorIds = (id, index) => {
|
|
100
|
+
const ids = [];
|
|
101
|
+
let current = index.byId.get(id);
|
|
102
|
+
while (current) {
|
|
103
|
+
ids.push(current.id);
|
|
104
|
+
if (current.parentId == null) break;
|
|
105
|
+
current = index.byId.get(current.parentId);
|
|
106
|
+
}
|
|
107
|
+
return ids;
|
|
108
|
+
};
|
|
109
|
+
const resolveCommonAncestor = (ids, index) => {
|
|
110
|
+
if (!ids.length) return index.global.id;
|
|
111
|
+
const [first, ...rest] = ids.map((id) => getAncestorIds(id, index));
|
|
112
|
+
for (const candidate of first) if (rest.every((list) => list.includes(candidate))) return candidate;
|
|
113
|
+
return index.global.id;
|
|
114
|
+
};
|
|
115
|
+
const ensureBucket = (map, id, factory) => {
|
|
116
|
+
const existing = map.get(id);
|
|
117
|
+
if (existing) return existing;
|
|
118
|
+
const created = factory();
|
|
119
|
+
map.set(id, created);
|
|
120
|
+
return created;
|
|
121
|
+
};
|
|
122
|
+
const assignRulesToBoundaries = (entries, index, criticality) => {
|
|
123
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
124
|
+
for (const entry of entries) {
|
|
125
|
+
const boundaryIds = /* @__PURE__ */ new Set();
|
|
126
|
+
for (const source of entry.sources) boundaryIds.add(resolveBoundaryForSource(source, index).id);
|
|
127
|
+
if (!boundaryIds.size) boundaryIds.add(index.global.id);
|
|
128
|
+
const ids = Array.from(boundaryIds);
|
|
129
|
+
if (ids.length >= criticality) ensureBucket(buckets, resolveCommonAncestor(ids, index), () => /* @__PURE__ */ new Set()).add(entry.rule);
|
|
130
|
+
else for (const id of ids) ensureBucket(buckets, id, () => /* @__PURE__ */ new Set()).add(entry.rule);
|
|
131
|
+
}
|
|
132
|
+
return buckets;
|
|
133
|
+
};
|
|
134
|
+
const assignRootToBoundaries = (entries, index, criticality) => {
|
|
135
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
136
|
+
for (const entry of entries) {
|
|
137
|
+
const boundaryIds = /* @__PURE__ */ new Set();
|
|
138
|
+
for (const source of entry.sources) boundaryIds.add(resolveBoundaryForSource(source, index).id);
|
|
139
|
+
if (!boundaryIds.size) boundaryIds.add(index.global.id);
|
|
140
|
+
const ids = Array.from(boundaryIds);
|
|
141
|
+
if (ids.length >= criticality) ensureBucket(buckets, resolveCommonAncestor(ids, index), () => /* @__PURE__ */ new Set()).add(entry.declaration);
|
|
142
|
+
else for (const id of ids) ensureBucket(buckets, id, () => /* @__PURE__ */ new Set()).add(entry.declaration);
|
|
143
|
+
}
|
|
144
|
+
return buckets;
|
|
145
|
+
};
|
|
146
|
+
const assignCustomToBoundaries = (entries, index, criticality) => {
|
|
147
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
148
|
+
for (const entry of entries) {
|
|
149
|
+
const boundaryIds = /* @__PURE__ */ new Set();
|
|
150
|
+
for (const source of entry.sources) boundaryIds.add(resolveBoundaryForSource(source, index).id);
|
|
151
|
+
if (!boundaryIds.size) boundaryIds.add(index.global.id);
|
|
152
|
+
const ids = Array.from(boundaryIds);
|
|
153
|
+
if (ids.length >= criticality) ensureBucket(buckets, resolveCommonAncestor(ids, index), () => []).push(entry);
|
|
154
|
+
else for (const id of ids) ensureBucket(buckets, id, () => []).push(entry);
|
|
155
|
+
}
|
|
156
|
+
return buckets;
|
|
157
|
+
};
|
|
158
|
+
const buildCssText = (css, options) => {
|
|
159
|
+
const importRules = options.imports?.size ? Array.from(options.imports).join("\n") : "";
|
|
160
|
+
const entries = Array.from(options.rules).map((rule) => {
|
|
161
|
+
const meta = css.ruleMeta.get(rule);
|
|
162
|
+
return {
|
|
163
|
+
rule,
|
|
164
|
+
query: meta?.query ?? null,
|
|
165
|
+
index: meta?.index ?? 0
|
|
166
|
+
};
|
|
167
|
+
});
|
|
168
|
+
const baseRules = entries.filter((entry) => !entry.query).sort((a, b) => a.index - b.index).map((entry) => entry.rule);
|
|
169
|
+
const atRules = entries.filter((entry) => entry.query).sort((a, b) => css.compareAtRuleOrder(a, b)).map((entry) => entry.rule);
|
|
170
|
+
const orderedRules = [...baseRules, ...atRules].join("\n");
|
|
171
|
+
const rootSelector = css.api.selectorScope || ":root";
|
|
172
|
+
const rootRules = options.root.size ? `${rootSelector} {\n ${Array.from(options.root).join("\n ")}\n}\n${orderedRules}` : orderedRules;
|
|
173
|
+
const customRules = options.custom.length ? options.custom.map((entry) => entry.cssText).join("\n") : "";
|
|
174
|
+
if (!importRules && !rootRules && !customRules) return "";
|
|
175
|
+
if (!importRules && !customRules) return rootRules;
|
|
176
|
+
if (!importRules && !rootRules) return customRules;
|
|
177
|
+
if (!customRules) return importRules ? `${importRules}\n${rootRules}` : rootRules;
|
|
178
|
+
if (!rootRules) return importRules ? `${importRules}\n${customRules}` : customRules;
|
|
179
|
+
return `${importRules}\n${rootRules}\n${customRules}`;
|
|
180
|
+
};
|
|
181
|
+
const collectRuleEntries = (css) => {
|
|
182
|
+
const map = /* @__PURE__ */ new Map();
|
|
183
|
+
for (const rule of css) {
|
|
184
|
+
const meta = css.ruleMeta.get(rule);
|
|
185
|
+
const signature = normalizeCssText(rule);
|
|
186
|
+
const sources = css.ruleSources.get(rule) ?? new Set([GLOBAL_SOURCE]);
|
|
187
|
+
const existing = map.get(signature);
|
|
188
|
+
if (!existing) {
|
|
189
|
+
map.set(signature, {
|
|
190
|
+
rule,
|
|
191
|
+
query: meta?.query ?? null,
|
|
192
|
+
index: meta?.index ?? 0,
|
|
193
|
+
sources: new Set(sources)
|
|
194
|
+
});
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
for (const source of sources) existing.sources.add(source);
|
|
198
|
+
if (meta && meta.index < existing.index) {
|
|
199
|
+
existing.rule = rule;
|
|
200
|
+
existing.index = meta.index;
|
|
201
|
+
existing.query = meta.query ?? null;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return map.values();
|
|
205
|
+
};
|
|
206
|
+
const collectRootEntries = (css) => {
|
|
207
|
+
const map = /* @__PURE__ */ new Map();
|
|
208
|
+
const rootSelector = css.api.selectorScope || ":root";
|
|
209
|
+
let order = 0;
|
|
210
|
+
for (const declaration of css.root) {
|
|
211
|
+
const signature = normalizeCssText(`${rootSelector} { ${declaration} }`);
|
|
212
|
+
const sources = css.rootSources.get(declaration) ?? new Set([GLOBAL_SOURCE]);
|
|
213
|
+
const existing = map.get(signature);
|
|
214
|
+
if (!existing) map.set(signature, {
|
|
215
|
+
declaration,
|
|
216
|
+
sources: new Set(sources),
|
|
217
|
+
order
|
|
218
|
+
});
|
|
219
|
+
else for (const source of sources) existing.sources.add(source);
|
|
220
|
+
order += 1;
|
|
221
|
+
}
|
|
222
|
+
return map.values();
|
|
223
|
+
};
|
|
224
|
+
const collectCustomEntries = (css) => {
|
|
225
|
+
const map = /* @__PURE__ */ new Map();
|
|
226
|
+
let order = 0;
|
|
227
|
+
for (const entry of css.customBlocks.values()) {
|
|
228
|
+
const signature = normalizeCssText(entry.cssText);
|
|
229
|
+
const sources = new Set([entry.file || GLOBAL_SOURCE]);
|
|
230
|
+
const existing = map.get(signature);
|
|
231
|
+
if (!existing) map.set(signature, {
|
|
232
|
+
cssText: entry.cssText,
|
|
233
|
+
sources,
|
|
234
|
+
order
|
|
235
|
+
});
|
|
236
|
+
else for (const source of sources) existing.sources.add(source);
|
|
237
|
+
order += 1;
|
|
238
|
+
}
|
|
239
|
+
return map.values();
|
|
240
|
+
};
|
|
241
|
+
const resolveBoundaryOutputs = async (api, options) => {
|
|
242
|
+
const rootDir = options.rootDir ?? process.cwd();
|
|
243
|
+
const boundaryConfig = options.boundaries ?? {};
|
|
244
|
+
const boundaryFiles = await findBoundaryFiles(rootDir, boundaryConfig);
|
|
245
|
+
if (!boundaryFiles.length) return {
|
|
246
|
+
outputs: [{
|
|
247
|
+
path: normalizePath(options.stylesheetPath),
|
|
248
|
+
text: api.css.text
|
|
249
|
+
}],
|
|
250
|
+
boundaryFiles: [],
|
|
251
|
+
hasBoundaries: false
|
|
252
|
+
};
|
|
253
|
+
const index = buildBoundaryIndex(boundaryFiles, options.stylesheetPath);
|
|
254
|
+
const criticality = Math.max(1, boundaryConfig.criticality ?? DEFAULT_CRITICALITY);
|
|
255
|
+
const ruleEntries = collectRuleEntries(api.css);
|
|
256
|
+
const rootEntries = collectRootEntries(api.css);
|
|
257
|
+
const customEntries = collectCustomEntries(api.css);
|
|
258
|
+
const ruleBuckets = assignRulesToBoundaries(ruleEntries, index, criticality);
|
|
259
|
+
const rootBuckets = assignRootToBoundaries(rootEntries, index, criticality);
|
|
260
|
+
const customBuckets = assignCustomToBoundaries(customEntries, index, criticality);
|
|
261
|
+
const outputs = [];
|
|
262
|
+
const boundaryNodes = [index.global, ...index.nodes].sort((a, b) => a.path.localeCompare(b.path));
|
|
263
|
+
for (const boundary of boundaryNodes) {
|
|
264
|
+
const rules = ruleBuckets.get(boundary.id) ?? /* @__PURE__ */ new Set();
|
|
265
|
+
const root = rootBuckets.get(boundary.id) ?? /* @__PURE__ */ new Set();
|
|
266
|
+
const custom = customBuckets.get(boundary.id) ?? [];
|
|
267
|
+
custom.sort((a, b) => a.order - b.order);
|
|
268
|
+
const imports = boundary.id === index.global.id ? api.css.imports : /* @__PURE__ */ new Set();
|
|
269
|
+
const text = buildCssText(api.css, {
|
|
270
|
+
rules,
|
|
271
|
+
root,
|
|
272
|
+
custom,
|
|
273
|
+
imports
|
|
274
|
+
});
|
|
275
|
+
outputs.push({
|
|
276
|
+
path: boundary.path,
|
|
277
|
+
text
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
return {
|
|
281
|
+
outputs,
|
|
282
|
+
boundaryFiles,
|
|
283
|
+
hasBoundaries: true
|
|
284
|
+
};
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
//#endregion
|
|
288
|
+
exports.resolveBoundaryOutputs = resolveBoundaryOutputs;
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fg from "fast-glob";
|
|
3
|
+
|
|
4
|
+
//#region src/shared/boundaries.ts
|
|
5
|
+
const DEFAULT_CRITICALITY = 2;
|
|
6
|
+
const GLOBAL_SOURCE = "<global>";
|
|
7
|
+
const BOUNDARY_PATTERN = "**/*.boss.css";
|
|
8
|
+
const normalizePath = (filePath) => path.resolve(filePath);
|
|
9
|
+
const getDepth = (dir) => dir.split(path.sep).filter(Boolean).length;
|
|
10
|
+
const normalizeCssText = (value) => {
|
|
11
|
+
return value.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\s+/g, " ").replace(/\s*([{}:;,>+~])\s*/g, "$1").replace(/;}/g, "}").trim();
|
|
12
|
+
};
|
|
13
|
+
const findBoundaryFiles = async (rootDir, config = {}) => {
|
|
14
|
+
const ignore = [...config.ignore ?? []];
|
|
15
|
+
ignore.push("**/node_modules/**");
|
|
16
|
+
return (await fg(BOUNDARY_PATTERN, {
|
|
17
|
+
cwd: rootDir,
|
|
18
|
+
absolute: true,
|
|
19
|
+
onlyFiles: true,
|
|
20
|
+
ignore
|
|
21
|
+
})).map(normalizePath).sort((a, b) => a.localeCompare(b));
|
|
22
|
+
};
|
|
23
|
+
const buildBoundaryIndex = (boundaryFiles, stylesheetPath) => {
|
|
24
|
+
const normalizedStylesheet = normalizePath(stylesheetPath);
|
|
25
|
+
const globalNode = {
|
|
26
|
+
id: 0,
|
|
27
|
+
path: normalizedStylesheet,
|
|
28
|
+
dir: path.dirname(normalizedStylesheet),
|
|
29
|
+
depth: getDepth(path.dirname(normalizedStylesheet)),
|
|
30
|
+
parentId: null
|
|
31
|
+
};
|
|
32
|
+
const byId = new Map([[globalNode.id, globalNode]]);
|
|
33
|
+
const byPath = new Map([[globalNode.path, globalNode]]);
|
|
34
|
+
const byDir = /* @__PURE__ */ new Map();
|
|
35
|
+
const primaryByDir = /* @__PURE__ */ new Map();
|
|
36
|
+
const nodes = boundaryFiles.map((file, index) => {
|
|
37
|
+
const dir = path.dirname(file);
|
|
38
|
+
const node = {
|
|
39
|
+
id: index + 1,
|
|
40
|
+
path: file,
|
|
41
|
+
dir,
|
|
42
|
+
depth: getDepth(dir),
|
|
43
|
+
parentId: null
|
|
44
|
+
};
|
|
45
|
+
byId.set(node.id, node);
|
|
46
|
+
byPath.set(node.path, node);
|
|
47
|
+
const list = byDir.get(dir) ?? [];
|
|
48
|
+
list.push(node);
|
|
49
|
+
byDir.set(dir, list);
|
|
50
|
+
return node;
|
|
51
|
+
});
|
|
52
|
+
for (const [dir, list] of byDir.entries()) {
|
|
53
|
+
list.sort((a, b) => a.path.localeCompare(b.path));
|
|
54
|
+
primaryByDir.set(dir, list[0]);
|
|
55
|
+
if (list.length > 1) console.warn(`[boss-css] Multiple .boss.css files found in ${dir}. Using ${path.basename(list[0].path)} for boundary mapping.`);
|
|
56
|
+
}
|
|
57
|
+
for (const node of nodes) {
|
|
58
|
+
let current = path.dirname(node.dir);
|
|
59
|
+
while (true) {
|
|
60
|
+
const parent = primaryByDir.get(current);
|
|
61
|
+
if (parent) {
|
|
62
|
+
node.parentId = parent.id;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
const next = path.dirname(current);
|
|
66
|
+
if (!next || next === current) {
|
|
67
|
+
node.parentId = globalNode.id;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
current = next;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
global: globalNode,
|
|
75
|
+
byId,
|
|
76
|
+
byPath,
|
|
77
|
+
byDir,
|
|
78
|
+
primaryByDir,
|
|
79
|
+
nodes
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
const resolveBoundaryForSource = (source, index) => {
|
|
83
|
+
if (!source || source === GLOBAL_SOURCE) return index.global;
|
|
84
|
+
if (source.startsWith("<") && source.endsWith(">")) return index.global;
|
|
85
|
+
const resolved = normalizePath(source);
|
|
86
|
+
let current = path.dirname(resolved);
|
|
87
|
+
while (true) {
|
|
88
|
+
const boundary = index.primaryByDir.get(current);
|
|
89
|
+
if (boundary) return boundary;
|
|
90
|
+
const next = path.dirname(current);
|
|
91
|
+
if (!next || next === current) break;
|
|
92
|
+
current = next;
|
|
93
|
+
}
|
|
94
|
+
return index.global;
|
|
95
|
+
};
|
|
96
|
+
const getAncestorIds = (id, index) => {
|
|
97
|
+
const ids = [];
|
|
98
|
+
let current = index.byId.get(id);
|
|
99
|
+
while (current) {
|
|
100
|
+
ids.push(current.id);
|
|
101
|
+
if (current.parentId == null) break;
|
|
102
|
+
current = index.byId.get(current.parentId);
|
|
103
|
+
}
|
|
104
|
+
return ids;
|
|
105
|
+
};
|
|
106
|
+
const resolveCommonAncestor = (ids, index) => {
|
|
107
|
+
if (!ids.length) return index.global.id;
|
|
108
|
+
const [first, ...rest] = ids.map((id) => getAncestorIds(id, index));
|
|
109
|
+
for (const candidate of first) if (rest.every((list) => list.includes(candidate))) return candidate;
|
|
110
|
+
return index.global.id;
|
|
111
|
+
};
|
|
112
|
+
const ensureBucket = (map, id, factory) => {
|
|
113
|
+
const existing = map.get(id);
|
|
114
|
+
if (existing) return existing;
|
|
115
|
+
const created = factory();
|
|
116
|
+
map.set(id, created);
|
|
117
|
+
return created;
|
|
118
|
+
};
|
|
119
|
+
const assignRulesToBoundaries = (entries, index, criticality) => {
|
|
120
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
121
|
+
for (const entry of entries) {
|
|
122
|
+
const boundaryIds = /* @__PURE__ */ new Set();
|
|
123
|
+
for (const source of entry.sources) boundaryIds.add(resolveBoundaryForSource(source, index).id);
|
|
124
|
+
if (!boundaryIds.size) boundaryIds.add(index.global.id);
|
|
125
|
+
const ids = Array.from(boundaryIds);
|
|
126
|
+
if (ids.length >= criticality) ensureBucket(buckets, resolveCommonAncestor(ids, index), () => /* @__PURE__ */ new Set()).add(entry.rule);
|
|
127
|
+
else for (const id of ids) ensureBucket(buckets, id, () => /* @__PURE__ */ new Set()).add(entry.rule);
|
|
128
|
+
}
|
|
129
|
+
return buckets;
|
|
130
|
+
};
|
|
131
|
+
const assignRootToBoundaries = (entries, index, criticality) => {
|
|
132
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
133
|
+
for (const entry of entries) {
|
|
134
|
+
const boundaryIds = /* @__PURE__ */ new Set();
|
|
135
|
+
for (const source of entry.sources) boundaryIds.add(resolveBoundaryForSource(source, index).id);
|
|
136
|
+
if (!boundaryIds.size) boundaryIds.add(index.global.id);
|
|
137
|
+
const ids = Array.from(boundaryIds);
|
|
138
|
+
if (ids.length >= criticality) ensureBucket(buckets, resolveCommonAncestor(ids, index), () => /* @__PURE__ */ new Set()).add(entry.declaration);
|
|
139
|
+
else for (const id of ids) ensureBucket(buckets, id, () => /* @__PURE__ */ new Set()).add(entry.declaration);
|
|
140
|
+
}
|
|
141
|
+
return buckets;
|
|
142
|
+
};
|
|
143
|
+
const assignCustomToBoundaries = (entries, index, criticality) => {
|
|
144
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
145
|
+
for (const entry of entries) {
|
|
146
|
+
const boundaryIds = /* @__PURE__ */ new Set();
|
|
147
|
+
for (const source of entry.sources) boundaryIds.add(resolveBoundaryForSource(source, index).id);
|
|
148
|
+
if (!boundaryIds.size) boundaryIds.add(index.global.id);
|
|
149
|
+
const ids = Array.from(boundaryIds);
|
|
150
|
+
if (ids.length >= criticality) ensureBucket(buckets, resolveCommonAncestor(ids, index), () => []).push(entry);
|
|
151
|
+
else for (const id of ids) ensureBucket(buckets, id, () => []).push(entry);
|
|
152
|
+
}
|
|
153
|
+
return buckets;
|
|
154
|
+
};
|
|
155
|
+
const buildCssText = (css, options) => {
|
|
156
|
+
const importRules = options.imports?.size ? Array.from(options.imports).join("\n") : "";
|
|
157
|
+
const entries = Array.from(options.rules).map((rule) => {
|
|
158
|
+
const meta = css.ruleMeta.get(rule);
|
|
159
|
+
return {
|
|
160
|
+
rule,
|
|
161
|
+
query: meta?.query ?? null,
|
|
162
|
+
index: meta?.index ?? 0
|
|
163
|
+
};
|
|
164
|
+
});
|
|
165
|
+
const baseRules = entries.filter((entry) => !entry.query).sort((a, b) => a.index - b.index).map((entry) => entry.rule);
|
|
166
|
+
const atRules = entries.filter((entry) => entry.query).sort((a, b) => css.compareAtRuleOrder(a, b)).map((entry) => entry.rule);
|
|
167
|
+
const orderedRules = [...baseRules, ...atRules].join("\n");
|
|
168
|
+
const rootSelector = css.api.selectorScope || ":root";
|
|
169
|
+
const rootRules = options.root.size ? `${rootSelector} {\n ${Array.from(options.root).join("\n ")}\n}\n${orderedRules}` : orderedRules;
|
|
170
|
+
const customRules = options.custom.length ? options.custom.map((entry) => entry.cssText).join("\n") : "";
|
|
171
|
+
if (!importRules && !rootRules && !customRules) return "";
|
|
172
|
+
if (!importRules && !customRules) return rootRules;
|
|
173
|
+
if (!importRules && !rootRules) return customRules;
|
|
174
|
+
if (!customRules) return importRules ? `${importRules}\n${rootRules}` : rootRules;
|
|
175
|
+
if (!rootRules) return importRules ? `${importRules}\n${customRules}` : customRules;
|
|
176
|
+
return `${importRules}\n${rootRules}\n${customRules}`;
|
|
177
|
+
};
|
|
178
|
+
const collectRuleEntries = (css) => {
|
|
179
|
+
const map = /* @__PURE__ */ new Map();
|
|
180
|
+
for (const rule of css) {
|
|
181
|
+
const meta = css.ruleMeta.get(rule);
|
|
182
|
+
const signature = normalizeCssText(rule);
|
|
183
|
+
const sources = css.ruleSources.get(rule) ?? new Set([GLOBAL_SOURCE]);
|
|
184
|
+
const existing = map.get(signature);
|
|
185
|
+
if (!existing) {
|
|
186
|
+
map.set(signature, {
|
|
187
|
+
rule,
|
|
188
|
+
query: meta?.query ?? null,
|
|
189
|
+
index: meta?.index ?? 0,
|
|
190
|
+
sources: new Set(sources)
|
|
191
|
+
});
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
for (const source of sources) existing.sources.add(source);
|
|
195
|
+
if (meta && meta.index < existing.index) {
|
|
196
|
+
existing.rule = rule;
|
|
197
|
+
existing.index = meta.index;
|
|
198
|
+
existing.query = meta.query ?? null;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return map.values();
|
|
202
|
+
};
|
|
203
|
+
const collectRootEntries = (css) => {
|
|
204
|
+
const map = /* @__PURE__ */ new Map();
|
|
205
|
+
const rootSelector = css.api.selectorScope || ":root";
|
|
206
|
+
let order = 0;
|
|
207
|
+
for (const declaration of css.root) {
|
|
208
|
+
const signature = normalizeCssText(`${rootSelector} { ${declaration} }`);
|
|
209
|
+
const sources = css.rootSources.get(declaration) ?? new Set([GLOBAL_SOURCE]);
|
|
210
|
+
const existing = map.get(signature);
|
|
211
|
+
if (!existing) map.set(signature, {
|
|
212
|
+
declaration,
|
|
213
|
+
sources: new Set(sources),
|
|
214
|
+
order
|
|
215
|
+
});
|
|
216
|
+
else for (const source of sources) existing.sources.add(source);
|
|
217
|
+
order += 1;
|
|
218
|
+
}
|
|
219
|
+
return map.values();
|
|
220
|
+
};
|
|
221
|
+
const collectCustomEntries = (css) => {
|
|
222
|
+
const map = /* @__PURE__ */ new Map();
|
|
223
|
+
let order = 0;
|
|
224
|
+
for (const entry of css.customBlocks.values()) {
|
|
225
|
+
const signature = normalizeCssText(entry.cssText);
|
|
226
|
+
const sources = new Set([entry.file || GLOBAL_SOURCE]);
|
|
227
|
+
const existing = map.get(signature);
|
|
228
|
+
if (!existing) map.set(signature, {
|
|
229
|
+
cssText: entry.cssText,
|
|
230
|
+
sources,
|
|
231
|
+
order
|
|
232
|
+
});
|
|
233
|
+
else for (const source of sources) existing.sources.add(source);
|
|
234
|
+
order += 1;
|
|
235
|
+
}
|
|
236
|
+
return map.values();
|
|
237
|
+
};
|
|
238
|
+
const resolveBoundaryOutputs = async (api, options) => {
|
|
239
|
+
const rootDir = options.rootDir ?? process.cwd();
|
|
240
|
+
const boundaryConfig = options.boundaries ?? {};
|
|
241
|
+
const boundaryFiles = await findBoundaryFiles(rootDir, boundaryConfig);
|
|
242
|
+
if (!boundaryFiles.length) return {
|
|
243
|
+
outputs: [{
|
|
244
|
+
path: normalizePath(options.stylesheetPath),
|
|
245
|
+
text: api.css.text
|
|
246
|
+
}],
|
|
247
|
+
boundaryFiles: [],
|
|
248
|
+
hasBoundaries: false
|
|
249
|
+
};
|
|
250
|
+
const index = buildBoundaryIndex(boundaryFiles, options.stylesheetPath);
|
|
251
|
+
const criticality = Math.max(1, boundaryConfig.criticality ?? DEFAULT_CRITICALITY);
|
|
252
|
+
const ruleEntries = collectRuleEntries(api.css);
|
|
253
|
+
const rootEntries = collectRootEntries(api.css);
|
|
254
|
+
const customEntries = collectCustomEntries(api.css);
|
|
255
|
+
const ruleBuckets = assignRulesToBoundaries(ruleEntries, index, criticality);
|
|
256
|
+
const rootBuckets = assignRootToBoundaries(rootEntries, index, criticality);
|
|
257
|
+
const customBuckets = assignCustomToBoundaries(customEntries, index, criticality);
|
|
258
|
+
const outputs = [];
|
|
259
|
+
const boundaryNodes = [index.global, ...index.nodes].sort((a, b) => a.path.localeCompare(b.path));
|
|
260
|
+
for (const boundary of boundaryNodes) {
|
|
261
|
+
const rules = ruleBuckets.get(boundary.id) ?? /* @__PURE__ */ new Set();
|
|
262
|
+
const root = rootBuckets.get(boundary.id) ?? /* @__PURE__ */ new Set();
|
|
263
|
+
const custom = customBuckets.get(boundary.id) ?? [];
|
|
264
|
+
custom.sort((a, b) => a.order - b.order);
|
|
265
|
+
const imports = boundary.id === index.global.id ? api.css.imports : /* @__PURE__ */ new Set();
|
|
266
|
+
const text = buildCssText(api.css, {
|
|
267
|
+
rules,
|
|
268
|
+
root,
|
|
269
|
+
custom,
|
|
270
|
+
imports
|
|
271
|
+
});
|
|
272
|
+
outputs.push({
|
|
273
|
+
path: boundary.path,
|
|
274
|
+
text
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
return {
|
|
278
|
+
outputs,
|
|
279
|
+
boundaryFiles,
|
|
280
|
+
hasBoundaries: true
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
//#endregion
|
|
285
|
+
export { resolveBoundaryOutputs };
|