@master/css-tooling 0.0.0-site.1793659883.g69c9aebcf628 → 0.0.0-stage
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 +2 -57
- package/package.json +5 -126
- package/dist/browser.d.ts +0 -2
- package/dist/browser.js +0 -1
- package/dist/css-tree-version.d.ts +0 -2
- package/dist/css-tree-version.js +0 -4
- package/dist/css.d.ts +0 -32
- package/dist/css.js +0 -120
- package/dist/immutable.d.ts +0 -2
- package/dist/immutable.js +0 -7
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -1
- package/dist/language/binding-session.d.ts +0 -6
- package/dist/language/binding-session.js +0 -8
- package/dist/language/browser.d.ts +0 -10
- package/dist/language/browser.js +0 -12
- package/dist/language/common.d.ts +0 -12
- package/dist/language/common.js +0 -55
- package/dist/language/contracts.d.ts +0 -197
- package/dist/language/contracts.js +0 -1
- package/dist/language/index.d.ts +0 -29
- package/dist/language/index.js +0 -39
- package/dist/language/master-css.d.ts +0 -13
- package/dist/language/master-css.js +0 -35
- package/dist/language/node.d.ts +0 -21
- package/dist/language/node.js +0 -36
- package/dist/language/semantic/scopes.d.ts +0 -55
- package/dist/language/semantic/scopes.js +0 -73
- package/dist/language/semantic/types.d.ts +0 -11
- package/dist/language/semantic/types.js +0 -1
- package/dist/language/session.d.ts +0 -37
- package/dist/language/session.js +0 -87
- package/dist/language/settings.d.ts +0 -13
- package/dist/language/settings.js +0 -19
- package/dist/language/utils/mdn-css-data.d.ts +0 -5
- package/dist/language/utils/mdn-css-data.js +0 -63
- package/dist/lexer/browser.d.ts +0 -6
- package/dist/lexer/browser.js +0 -11
- package/dist/lexer/contracts.d.ts +0 -41
- package/dist/lexer/contracts.js +0 -1
- package/dist/lexer/index.d.ts +0 -8
- package/dist/lexer/index.js +0 -11
- package/dist/lexer/node.d.ts +0 -7
- package/dist/lexer/node.js +0 -11
- package/dist/lexer/session.d.ts +0 -17
- package/dist/lexer/session.js +0 -25
- package/dist/lint/analysis.d.ts +0 -90
- package/dist/lint/analysis.js +0 -1
- package/dist/lint/binding-session.d.ts +0 -21
- package/dist/lint/binding-session.js +0 -97
- package/dist/lint/constants.d.ts +0 -7
- package/dist/lint/constants.js +0 -18
- package/dist/lint/contracts.d.ts +0 -17
- package/dist/lint/contracts.js +0 -6
- package/dist/lint/diagnostic-format.d.ts +0 -5
- package/dist/lint/diagnostic-format.js +0 -15
- package/dist/lint/diagnostics.d.ts +0 -42
- package/dist/lint/diagnostics.js +0 -1
- package/dist/lint/index.d.ts +0 -21
- package/dist/lint/index.js +0 -30
- package/dist/lint/node.d.ts +0 -6
- package/dist/lint/node.js +0 -11
- package/dist/lint/rule-signatures.d.ts +0 -23
- package/dist/lint/rule-signatures.js +0 -27
- package/dist/lint/source.d.ts +0 -70
- package/dist/lint/source.js +0 -261
- package/dist/math-types.d.ts +0 -11
- package/dist/math-types.js +0 -236
- package/dist/math-validation.d.ts +0 -7
- package/dist/math-validation.js +0 -74
- package/dist/node.d.ts +0 -12
- package/dist/node.js +0 -32
- package/dist/scanner/binding-session.d.ts +0 -29
- package/dist/scanner/binding-session.js +0 -37
- package/dist/scanner/core.d.ts +0 -130
- package/dist/scanner/core.js +0 -480
- package/dist/scanner/index.d.ts +0 -3
- package/dist/scanner/index.js +0 -3
- package/dist/scanner/node.d.ts +0 -5
- package/dist/scanner/node.js +0 -4
- package/dist/scanner/options/index.d.ts +0 -16
- package/dist/scanner/options/index.js +0 -57
- package/dist/scanner/source-policy.d.ts +0 -15
- package/dist/scanner/source-policy.js +0 -131
- package/dist/source/adapters/optional-peer.d.ts +0 -5
- package/dist/source/adapters/optional-peer.js +0 -29
- package/dist/source/adapters/oxc.d.ts +0 -2
- package/dist/source/adapters/oxc.js +0 -6
- package/dist/source/adapters/svelte.d.ts +0 -5
- package/dist/source/adapters/svelte.js +0 -82
- package/dist/source/adapters/types.d.ts +0 -11
- package/dist/source/adapters/types.js +0 -9
- package/dist/source/adapters/vue.d.ts +0 -5
- package/dist/source/adapters/vue.js +0 -50
- package/dist/source/browser.d.ts +0 -7
- package/dist/source/browser.js +0 -11
- package/dist/source/contracts.d.ts +0 -35
- package/dist/source/contracts.js +0 -1
- package/dist/source/index.d.ts +0 -8
- package/dist/source/index.js +0 -11
- package/dist/source/native.d.ts +0 -5
- package/dist/source/native.js +0 -53
- package/dist/source/node.d.ts +0 -7
- package/dist/source/node.js +0 -11
- package/dist/source/session.d.ts +0 -25
- package/dist/source/session.js +0 -37
- package/dist/syntax-validation.d.ts +0 -10
- package/dist/syntax-validation.js +0 -54
- package/dist/tooling-session.d.ts +0 -66
- package/dist/tooling-session.js +0 -188
- package/dist/validator/binding-session.d.ts +0 -17
- package/dist/validator/binding-session.js +0 -29
- package/dist/validator/contracts.d.ts +0 -24
- package/dist/validator/contracts.js +0 -1
- package/dist/validator/index.d.ts +0 -10
- package/dist/validator/index.js +0 -13
- package/dist/validator/node.d.ts +0 -6
- package/dist/validator/node.js +0 -11
- package/dist/validator/types/syntax-error.d.ts +0 -22
- package/dist/validator/types/syntax-error.js +0 -1
- package/dist/value-validation.d.ts +0 -46
- package/dist/value-validation.js +0 -162
package/dist/math-types.js
DELETED
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import { clone, lexer, walk } from "@eslint/css-tree";
|
|
2
|
-
// src/math-types.ts
|
|
3
|
-
const unknown = { kind: "unknown" };
|
|
4
|
-
const invalid = { kind: "invalid" };
|
|
5
|
-
const number = () => ({
|
|
6
|
-
kind: "known",
|
|
7
|
-
powers: {}
|
|
8
|
-
});
|
|
9
|
-
const dimension = (name) => ({
|
|
10
|
-
kind: "known",
|
|
11
|
-
powers: { [name]: 1 }
|
|
12
|
-
});
|
|
13
|
-
const examples = {
|
|
14
|
-
length: "px",
|
|
15
|
-
angle: "deg",
|
|
16
|
-
time: "s",
|
|
17
|
-
frequency: "hz",
|
|
18
|
-
resolution: "dppx",
|
|
19
|
-
flex: "fr"
|
|
20
|
-
};
|
|
21
|
-
const units = new Map(Object.entries(lexer.units).filter(([type]) => type in examples).flatMap(([type, names]) => names.map((unit) => [unit.toLowerCase(), type])));
|
|
22
|
-
const mathFunctions = /* @__PURE__ */ new Set([
|
|
23
|
-
"calc",
|
|
24
|
-
"min",
|
|
25
|
-
"max",
|
|
26
|
-
"clamp",
|
|
27
|
-
"mod",
|
|
28
|
-
"rem",
|
|
29
|
-
"sin",
|
|
30
|
-
"cos",
|
|
31
|
-
"tan",
|
|
32
|
-
"asin",
|
|
33
|
-
"acos",
|
|
34
|
-
"atan",
|
|
35
|
-
"atan2",
|
|
36
|
-
"pow",
|
|
37
|
-
"sqrt",
|
|
38
|
-
"hypot",
|
|
39
|
-
"exp",
|
|
40
|
-
"abs",
|
|
41
|
-
"sign",
|
|
42
|
-
"log",
|
|
43
|
-
"round"
|
|
44
|
-
]);
|
|
45
|
-
function same(a, b) {
|
|
46
|
-
return Object.keys({
|
|
47
|
-
...a.powers,
|
|
48
|
-
...b.powers
|
|
49
|
-
}).every((key) => a.powers[key] === b.powers[key]);
|
|
50
|
-
}
|
|
51
|
-
function combine(a, b, operator, hint) {
|
|
52
|
-
if (a.kind === "invalid" || b.kind === "invalid") return invalid;
|
|
53
|
-
if (a.kind === "unknown" || b.kind === "unknown") return unknown;
|
|
54
|
-
if (operator === "+" || operator === "-") {
|
|
55
|
-
if (same(a, b)) return a;
|
|
56
|
-
if (hint === void 0 && (a.powers.percentage || b.powers.percentage)) return unknown;
|
|
57
|
-
return invalid;
|
|
58
|
-
}
|
|
59
|
-
const powers = { ...a.powers };
|
|
60
|
-
for (const [dimension, exponent] of Object.entries(b.powers)) {
|
|
61
|
-
const key = dimension;
|
|
62
|
-
powers[key] = (powers[key] ?? 0) + exponent * (operator === "/" ? -1 : 1);
|
|
63
|
-
if (powers[key] === 0) delete powers[key];
|
|
64
|
-
}
|
|
65
|
-
return {
|
|
66
|
-
kind: "known",
|
|
67
|
-
powers
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
function expression(nodes, hint) {
|
|
71
|
-
let offset = 0;
|
|
72
|
-
const atom = () => {
|
|
73
|
-
const node = nodes[offset++];
|
|
74
|
-
if (!node) return invalid;
|
|
75
|
-
switch (node.type) {
|
|
76
|
-
case "Number": return number();
|
|
77
|
-
case "Dimension": return units.has(node.unit.toLowerCase()) ? dimension(units.get(node.unit.toLowerCase())) : unknown;
|
|
78
|
-
case "Percentage": return dimension(hint ?? "percentage");
|
|
79
|
-
case "Identifier": return [
|
|
80
|
-
"e",
|
|
81
|
-
"pi",
|
|
82
|
-
"infinity",
|
|
83
|
-
"-infinity",
|
|
84
|
-
"nan"
|
|
85
|
-
].includes(node.name.toLowerCase()) ? number() : unknown;
|
|
86
|
-
case "Parentheses": return expression([...node.children], hint);
|
|
87
|
-
case "Function": return inferFunction(node, hint);
|
|
88
|
-
default: return unknown;
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
const operator = () => {
|
|
92
|
-
const node = nodes[offset];
|
|
93
|
-
return node?.type === "Operator" ? node.value.trim() : "";
|
|
94
|
-
};
|
|
95
|
-
const product = () => {
|
|
96
|
-
let result = atom();
|
|
97
|
-
while (["*", "/"].includes(operator())) {
|
|
98
|
-
const op = operator();
|
|
99
|
-
offset++;
|
|
100
|
-
result = combine(result, atom(), op, hint);
|
|
101
|
-
}
|
|
102
|
-
return result;
|
|
103
|
-
};
|
|
104
|
-
let result = product();
|
|
105
|
-
let knownSum = result.kind === "known" ? result : void 0;
|
|
106
|
-
while (["+", "-"].includes(operator())) {
|
|
107
|
-
const op = operator();
|
|
108
|
-
offset++;
|
|
109
|
-
const right = product();
|
|
110
|
-
if (right.kind === "known") {
|
|
111
|
-
const sum = knownSum ? combine(knownSum, right, op, hint) : right;
|
|
112
|
-
if (sum.kind === "invalid") return invalid;
|
|
113
|
-
knownSum = sum.kind === "known" ? sum : void 0;
|
|
114
|
-
}
|
|
115
|
-
result = combine(result, right, op, hint);
|
|
116
|
-
}
|
|
117
|
-
return offset === nodes.length ? result : unknown;
|
|
118
|
-
}
|
|
119
|
-
function primitive(value) {
|
|
120
|
-
const entries = Object.entries(value.powers);
|
|
121
|
-
return !entries.length ? "number" : entries.length === 1 && entries[0][1] === 1 ? entries[0][0] : void 0;
|
|
122
|
-
}
|
|
123
|
-
function inferFunction(node, hint) {
|
|
124
|
-
const name = node.name.toLowerCase();
|
|
125
|
-
if (!mathFunctions.has(name)) return unknown;
|
|
126
|
-
const args = [[]];
|
|
127
|
-
for (const child of node.children) if (child.type === "Operator" && child.value.trim() === ",") args.push([]);
|
|
128
|
-
else args.at(-1).push(child);
|
|
129
|
-
if (name === "round" && args[0]?.length === 1 && args[0][0].type === "Identifier" && [
|
|
130
|
-
"nearest",
|
|
131
|
-
"up",
|
|
132
|
-
"down",
|
|
133
|
-
"to-zero"
|
|
134
|
-
].includes(args[0][0].name)) args.shift();
|
|
135
|
-
const values = args.map((nodes, index) => name === "clamp" && index !== 1 && nodes.length === 1 && nodes[0].type === "Identifier" && nodes[0].name === "none" ? void 0 : expression(nodes, hint)).filter((value) => value !== void 0);
|
|
136
|
-
if (values.some((value) => value.kind === "invalid")) return invalid;
|
|
137
|
-
const known = values.filter((value) => value.kind === "known");
|
|
138
|
-
const uncertain = known.length !== values.length;
|
|
139
|
-
const accepts = (types) => known.every((value) => {
|
|
140
|
-
const type = primitive(value);
|
|
141
|
-
return type !== void 0 && types.includes(type);
|
|
142
|
-
});
|
|
143
|
-
let result;
|
|
144
|
-
switch (name) {
|
|
145
|
-
case "calc": return values[0] ?? invalid;
|
|
146
|
-
case "sin":
|
|
147
|
-
case "cos":
|
|
148
|
-
case "tan":
|
|
149
|
-
result = accepts(["number", "angle"]) ? number() : invalid;
|
|
150
|
-
break;
|
|
151
|
-
case "asin":
|
|
152
|
-
case "acos":
|
|
153
|
-
case "atan":
|
|
154
|
-
result = accepts(["number"]) ? dimension("angle") : invalid;
|
|
155
|
-
break;
|
|
156
|
-
case "pow":
|
|
157
|
-
case "sqrt":
|
|
158
|
-
case "exp":
|
|
159
|
-
case "log":
|
|
160
|
-
result = accepts(["number"]) ? number() : invalid;
|
|
161
|
-
break;
|
|
162
|
-
case "sign":
|
|
163
|
-
result = known.every((value) => primitive(value) !== void 0) ? number() : invalid;
|
|
164
|
-
break;
|
|
165
|
-
case "abs":
|
|
166
|
-
result = values[0] ?? invalid;
|
|
167
|
-
break;
|
|
168
|
-
default:
|
|
169
|
-
result = known.reduce((result, value) => combine(result, value, "+", hint), known[0] ?? unknown);
|
|
170
|
-
if (name === "round" && values.length === 1 && !accepts(["number"])) result = invalid;
|
|
171
|
-
if (name === "atan2" && result.kind === "known") result = dimension("angle");
|
|
172
|
-
}
|
|
173
|
-
return result.kind === "invalid" ? invalid : uncertain ? unknown : result;
|
|
174
|
-
}
|
|
175
|
-
function representative(type) {
|
|
176
|
-
if (type === "number") return {
|
|
177
|
-
type: "Number",
|
|
178
|
-
value: "1"
|
|
179
|
-
};
|
|
180
|
-
if (type === "percentage") return {
|
|
181
|
-
type: "Percentage",
|
|
182
|
-
value: "1"
|
|
183
|
-
};
|
|
184
|
-
return {
|
|
185
|
-
type: "Dimension",
|
|
186
|
-
value: "1",
|
|
187
|
-
unit: examples[type]
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
/** Substitute only proven result types into a disposable grammar AST. Never
|
|
191
|
-
* evaluate values, ranges, variable substitutions, or mutate emitted CSS.
|
|
192
|
-
* A nested calc may have a compound intermediate type which its parent cancels.
|
|
193
|
-
*/
|
|
194
|
-
function validateMathTypes(ast, matches) {
|
|
195
|
-
const normalized = clone(ast);
|
|
196
|
-
let status = "valid";
|
|
197
|
-
let found = false;
|
|
198
|
-
walk(normalized, (node, item, list) => {
|
|
199
|
-
if (node.type !== "Function" || !mathFunctions.has(node.name.toLowerCase()) || !item || !list) return;
|
|
200
|
-
found = true;
|
|
201
|
-
const original = item.data;
|
|
202
|
-
const accepts = (type) => {
|
|
203
|
-
item.data = representative(type);
|
|
204
|
-
const result = matches(normalized);
|
|
205
|
-
item.data = original;
|
|
206
|
-
return result;
|
|
207
|
-
};
|
|
208
|
-
let hint = null;
|
|
209
|
-
let hasPercentage = false;
|
|
210
|
-
walk(node, (child) => {
|
|
211
|
-
if (child.type === "Percentage") hasPercentage = true;
|
|
212
|
-
});
|
|
213
|
-
if (hasPercentage) {
|
|
214
|
-
const bases = Object.keys(examples).filter((type) => accepts(type));
|
|
215
|
-
hint = accepts("percentage") && bases.length === 1 ? bases[0] : bases.length ? null : void 0;
|
|
216
|
-
}
|
|
217
|
-
const inferred = inferFunction(node, hint);
|
|
218
|
-
if (inferred.kind === "invalid") status = "invalid";
|
|
219
|
-
else if (inferred.kind === "unknown") {
|
|
220
|
-
if (status !== "invalid") status = "unknown";
|
|
221
|
-
} else {
|
|
222
|
-
const type = primitive(inferred);
|
|
223
|
-
if (!type) {
|
|
224
|
-
if (hasPercentage && hint === void 0) {
|
|
225
|
-
if (status !== "invalid") status = "unknown";
|
|
226
|
-
} else status = "invalid";
|
|
227
|
-
} else item.data = representative(type);
|
|
228
|
-
}
|
|
229
|
-
return walk.skip;
|
|
230
|
-
});
|
|
231
|
-
return {
|
|
232
|
-
ast: normalized,
|
|
233
|
-
status: found ? status : void 0
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
export { mathFunctions, validateMathTypes };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { FunctionNode } from "@eslint/css-tree";
|
|
2
|
-
/** Check operator structure and arity, without inferring the result's dimension.
|
|
3
|
-
* CSS Values 4 allows dimensional division. Normalize operands for grammar-only
|
|
4
|
-
* checks rather than applying the lexer's numeric-divisor restriction.
|
|
5
|
-
*/
|
|
6
|
-
declare function mathFunctionStatus(node: FunctionNode): 'valid' | 'invalid' | 'unknown' | undefined;
|
|
7
|
-
export { mathFunctionStatus };
|
package/dist/math-validation.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { mathFunctions } from "./math-types.js";
|
|
2
|
-
import { List, clone, generate, lexer, walk } from "@eslint/css-tree";
|
|
3
|
-
// src/math-validation.ts
|
|
4
|
-
/** Check operator structure and arity, without inferring the result's dimension.
|
|
5
|
-
* CSS Values 4 allows dimensional division. Normalize operands for grammar-only
|
|
6
|
-
* checks rather than applying the lexer's numeric-divisor restriction.
|
|
7
|
-
*/
|
|
8
|
-
function mathFunctionStatus(node) {
|
|
9
|
-
const name = node.name.toLowerCase();
|
|
10
|
-
if (!mathFunctions.has(name)) return;
|
|
11
|
-
const normalized = clone(node);
|
|
12
|
-
let uncertain = false;
|
|
13
|
-
walk(normalized, (child, item, list) => {
|
|
14
|
-
if (child === normalized) return;
|
|
15
|
-
if (child.type === "Function") {
|
|
16
|
-
if (!mathFunctions.has(child.name.toLowerCase())) uncertain = true;
|
|
17
|
-
if (item && list) list.replace(item, list.createItem({
|
|
18
|
-
type: "Number",
|
|
19
|
-
value: "1"
|
|
20
|
-
}));
|
|
21
|
-
return walk.skip;
|
|
22
|
-
}
|
|
23
|
-
if ((child.type === "Dimension" || child.type === "Percentage") && item && list) list.replace(item, list.createItem({
|
|
24
|
-
type: "Number",
|
|
25
|
-
value: "1"
|
|
26
|
-
}));
|
|
27
|
-
});
|
|
28
|
-
if (uncertain) {
|
|
29
|
-
const arguments_ = [[]];
|
|
30
|
-
for (const child of node.children) if (child.type === "Operator" && child.value.trim() === ",") arguments_.push([]);
|
|
31
|
-
else arguments_.at(-1).push(child);
|
|
32
|
-
for (const argument of arguments_) {
|
|
33
|
-
const last = argument.at(-1);
|
|
34
|
-
if (last?.type === "Operator" && [
|
|
35
|
-
"+",
|
|
36
|
-
"-",
|
|
37
|
-
"*",
|
|
38
|
-
"/"
|
|
39
|
-
].includes(last.value.trim())) return "invalid";
|
|
40
|
-
let dependent = false;
|
|
41
|
-
const children = new List().fromArray(argument);
|
|
42
|
-
walk({
|
|
43
|
-
type: "Value",
|
|
44
|
-
children
|
|
45
|
-
}, (child) => {
|
|
46
|
-
if (child.type === "Function") dependent = true;
|
|
47
|
-
});
|
|
48
|
-
if (!dependent && mathFunctionStatus({
|
|
49
|
-
type: "Function",
|
|
50
|
-
name: "calc",
|
|
51
|
-
children
|
|
52
|
-
}) === "invalid") return "invalid";
|
|
53
|
-
}
|
|
54
|
-
return "unknown";
|
|
55
|
-
}
|
|
56
|
-
if (name === "log" || name === "round") {
|
|
57
|
-
const parts = [[]];
|
|
58
|
-
for (const child of normalized.children) if (child.type === "Operator" && child.value.trim() === ",") parts.push([]);
|
|
59
|
-
else parts.at(-1).push(child);
|
|
60
|
-
if (name === "round" && parts[0]?.length === 1 && parts[0][0].type === "Identifier" && [
|
|
61
|
-
"nearest",
|
|
62
|
-
"up",
|
|
63
|
-
"down",
|
|
64
|
-
"to-zero"
|
|
65
|
-
].includes(parts[0][0].name)) parts.shift();
|
|
66
|
-
if (parts.length < 1 || parts.length > 2) return "invalid";
|
|
67
|
-
return parts.some((children) => lexer.matchType("calc-sum", generate({
|
|
68
|
-
type: "Value",
|
|
69
|
-
children: new List().fromArray(children)
|
|
70
|
-
})).error) ? "invalid" : "valid";
|
|
71
|
-
}
|
|
72
|
-
return lexer.matchType(`${name}()`, generate(normalized)).error ? "invalid" : "valid";
|
|
73
|
-
}
|
|
74
|
-
export { mathFunctionStatus };
|
package/dist/node.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { CSS_VALUE_CHECK, cssValueStatus, validateRuleDeclarations } from "./value-validation.js";
|
|
2
|
-
import { CSS_SYNTAX_CHECK, cssSyntaxStatus } from "./syntax-validation.js";
|
|
3
|
-
import { MasterCSSToolingSession } from "./tooling-session.js";
|
|
4
|
-
import { MasterCSSManifest } from "@master/css-schema/manifest";
|
|
5
|
-
declare function createToolingSessionSync(options: {
|
|
6
|
-
readonly manifest: MasterCSSManifest;
|
|
7
|
-
/** Classes the project defines in native CSS; they report no diagnostics while they generate no rules. */
|
|
8
|
-
readonly nativeClassNames?: readonly string[];
|
|
9
|
-
}): MasterCSSToolingSession;
|
|
10
|
-
/** Versions from the artifact that actually executes project semantics. */
|
|
11
|
-
declare function getToolingBindingInfo(): import("@master/css-binding").MasterCSSBindingInfo;
|
|
12
|
-
export { CSS_SYNTAX_CHECK, CSS_VALUE_CHECK, type MasterCSSToolingSession, createToolingSessionSync, cssSyntaxStatus, cssValueStatus, getToolingBindingInfo, validateRuleDeclarations };
|
package/dist/node.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { bindLexerSession } from "./lexer/session.js";
|
|
2
|
-
import { CSS_SYNTAX_CHECK, cssSyntaxStatus } from "./syntax-validation.js";
|
|
3
|
-
import { CSS_VALUE_CHECK, cssValueStatus, validateRuleDeclarations } from "./value-validation.js";
|
|
4
|
-
import { bindLanguageSession } from "./language/session.js";
|
|
5
|
-
import { bindLintSession } from "./lint/binding-session.js";
|
|
6
|
-
import { bindSourceExtractor } from "./source/session.js";
|
|
7
|
-
import { bindValidatorSession } from "./validator/binding-session.js";
|
|
8
|
-
import { bindToolingSessionInternal } from "./tooling-session.js";
|
|
9
|
-
import { createToolingBindingSync } from "@master/css-binding/tooling/node";
|
|
10
|
-
// src/node.ts
|
|
11
|
-
function createToolingSessionSync(options) {
|
|
12
|
-
const tooling = createToolingBindingSync();
|
|
13
|
-
const lexer = tooling.createLexerSession();
|
|
14
|
-
const source = tooling.createSourceSession();
|
|
15
|
-
const validator = tooling.createValidatorSession(options.manifest);
|
|
16
|
-
const language = tooling.createLanguageSession(options.manifest);
|
|
17
|
-
const lint = tooling.createLintSession(options.manifest);
|
|
18
|
-
const lintValidator = tooling.createValidatorSession(options.manifest);
|
|
19
|
-
const lintLanguage = tooling.createLanguageSession(options.manifest);
|
|
20
|
-
return bindToolingSessionInternal({
|
|
21
|
-
lexer: bindLexerSession("native", lexer),
|
|
22
|
-
source: bindSourceExtractor("native", source),
|
|
23
|
-
validator: bindValidatorSession("native", validator, options.nativeClassNames),
|
|
24
|
-
lint: bindLintSession(lint, lintValidator, lintLanguage),
|
|
25
|
-
language: bindLanguageSession("native", language, options.nativeClassNames)
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
/** Versions from the artifact that actually executes project semantics. */
|
|
29
|
-
function getToolingBindingInfo() {
|
|
30
|
-
return createToolingBindingSync().info;
|
|
31
|
-
}
|
|
32
|
-
export { CSS_SYNTAX_CHECK, CSS_VALUE_CHECK, createToolingSessionSync, cssSyntaxStatus, cssValueStatus, getToolingBindingInfo, validateRuleDeclarations };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { MasterCSSBindingLoadOptions, MasterCSSScannerSourceInput, MasterCSSScannerSourceOptions, MasterCSSScannerState, MasterCSSScannerUpdate } from "@master/css-binding/tooling";
|
|
2
|
-
import { MasterCSSManifest } from "@master/css-schema/manifest";
|
|
3
|
-
type BindingScannerUpdate = MasterCSSScannerUpdate;
|
|
4
|
-
type BindingScannerState = MasterCSSScannerState;
|
|
5
|
-
type ScannerSourceOptions = MasterCSSScannerSourceOptions;
|
|
6
|
-
type ScannerSourceInput = MasterCSSScannerSourceInput;
|
|
7
|
-
type BindingScannerBlocklist = string | Readonly<{
|
|
8
|
-
source: string;
|
|
9
|
-
flags: string;
|
|
10
|
-
}>;
|
|
11
|
-
interface BindingScannerSession {
|
|
12
|
-
readonly binding: 'native' | 'wasm';
|
|
13
|
-
extractCandidates(source: string, content: string, options?: ScannerSourceOptions): string[];
|
|
14
|
-
collectCandidates(candidates: string[]): string[];
|
|
15
|
-
filterCandidates(candidates: string[], blocklist: BindingScannerBlocklist[]): string[];
|
|
16
|
-
scanCandidates(source: string, content: string, candidates: string[], blocklist: BindingScannerBlocklist[], options?: ScannerSourceOptions): BindingScannerUpdate;
|
|
17
|
-
removeSource(source: string, options?: ScannerSourceOptions): BindingScannerUpdate;
|
|
18
|
-
reconcileSources(owner: string, inputs: readonly ScannerSourceInput[]): BindingScannerUpdate;
|
|
19
|
-
removeOwner(owner: string): BindingScannerUpdate;
|
|
20
|
-
ensureClasses(classNames: string[]): void;
|
|
21
|
-
registerNativeClasses(owner: string, classNames: string[]): boolean;
|
|
22
|
-
reset(): void;
|
|
23
|
-
state(): BindingScannerState;
|
|
24
|
-
dispose(): void;
|
|
25
|
-
}
|
|
26
|
-
declare function serializeScannerBlocklist(blocklist?: Iterable<string | RegExp>): BindingScannerBlocklist[];
|
|
27
|
-
declare function createNativeScannerSession(manifest: MasterCSSManifest): BindingScannerSession;
|
|
28
|
-
declare function createScannerSession(manifest: MasterCSSManifest, options?: MasterCSSBindingLoadOptions): Promise<BindingScannerSession>;
|
|
29
|
-
export { BindingScannerBlocklist, BindingScannerSession, BindingScannerState, BindingScannerUpdate, ScannerSourceInput, ScannerSourceOptions, createNativeScannerSession, createScannerSession, serializeScannerBlocklist };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { createToolingBindingSync } from "@master/css-binding/tooling/node";
|
|
2
|
-
import { createToolingBinding } from "@master/css-binding/tooling";
|
|
3
|
-
// src/scanner/binding-session.ts
|
|
4
|
-
function serializeScannerBlocklist(blocklist = []) {
|
|
5
|
-
return [...blocklist].map((entry) => typeof entry === "string" ? entry : {
|
|
6
|
-
source: entry.source,
|
|
7
|
-
flags: entry.flags
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
function bindScannerSession(binding, session) {
|
|
11
|
-
return {
|
|
12
|
-
binding,
|
|
13
|
-
extractCandidates: (source, content, options) => [...session.extractCandidates(source, content, options)],
|
|
14
|
-
collectCandidates: (candidates) => [...session.collectCandidates(candidates)],
|
|
15
|
-
filterCandidates: (candidates, blocklist) => [...session.filterCandidates(candidates, blocklist)],
|
|
16
|
-
scanCandidates: (source, content, candidates, blocklist, options) => session.scanCandidates(source, content, candidates, blocklist, options),
|
|
17
|
-
removeSource: (source, options) => session.removeSource(source, options),
|
|
18
|
-
reconcileSources: (owner, inputs) => session.reconcileSources(owner, inputs),
|
|
19
|
-
removeOwner: (owner) => session.removeOwner(owner),
|
|
20
|
-
ensureClasses: (classes) => {
|
|
21
|
-
session.ensureClassRules(classes);
|
|
22
|
-
},
|
|
23
|
-
registerNativeClasses: (owner, classes) => session.registerNativeClassNames(owner, classes),
|
|
24
|
-
reset: () => session.reset(),
|
|
25
|
-
state: () => session.snapshot(),
|
|
26
|
-
dispose: () => session.dispose()
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function createNativeScannerSession(manifest) {
|
|
30
|
-
const tooling = createToolingBindingSync();
|
|
31
|
-
return bindScannerSession(tooling.binding, tooling.createScannerSession(manifest));
|
|
32
|
-
}
|
|
33
|
-
async function createScannerSession(manifest, options = {}) {
|
|
34
|
-
const tooling = await createToolingBinding(options);
|
|
35
|
-
return bindScannerSession(tooling.binding, await tooling.createScannerSession(manifest));
|
|
36
|
-
}
|
|
37
|
-
export { createNativeScannerSession, createScannerSession, serializeScannerBlocklist };
|
package/dist/scanner/core.d.ts
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { ScannerSourceInput, ScannerSourceOptions } from "./binding-session.js";
|
|
2
|
-
import { MasterCSSScannerOptions } from "./options/index.js";
|
|
3
|
-
import { EventEmitter } from "node:events";
|
|
4
|
-
import { MasterCSSManifest } from "@master/css-schema/manifest";
|
|
5
|
-
interface ScannerResetOptions {
|
|
6
|
-
emit?: boolean;
|
|
7
|
-
}
|
|
8
|
-
interface MasterCSSScannerSourceResult {
|
|
9
|
-
readonly changed: boolean;
|
|
10
|
-
readonly sourceChanged: boolean;
|
|
11
|
-
/** All candidates extracted from this input, including previously scanned classes. */
|
|
12
|
-
readonly candidates: readonly string[];
|
|
13
|
-
}
|
|
14
|
-
declare class ScannerCSSView {
|
|
15
|
-
readonly scanner: MasterCSSScanner;
|
|
16
|
-
constructor(scanner: MasterCSSScanner);
|
|
17
|
-
get manifest(): MasterCSSManifest;
|
|
18
|
-
get text(): string;
|
|
19
|
-
get utilitiesLayer(): {
|
|
20
|
-
rules: {
|
|
21
|
-
className: string;
|
|
22
|
-
key: string;
|
|
23
|
-
layer: import("@master/css-schema/manifest").MasterCSSManifestUtilityLayerName;
|
|
24
|
-
type: import("~/packages/schema/src/utility-type").UtilityType;
|
|
25
|
-
sortTier: number;
|
|
26
|
-
priority: import("~/packages/schema/src/hydration-manifest").MasterCSSRulePriority;
|
|
27
|
-
text: string;
|
|
28
|
-
nodes?: readonly import("~/packages/schema/src/hydration-manifest").MasterCSSHydrationRuleNode[];
|
|
29
|
-
selectorText?: string;
|
|
30
|
-
variableNames?: readonly string[];
|
|
31
|
-
keyframeNames?: readonly string[];
|
|
32
|
-
retainAllKeyframes?: boolean;
|
|
33
|
-
name: string;
|
|
34
|
-
}[];
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
declare class ScannerStateSetView {
|
|
38
|
-
private readonly readValues;
|
|
39
|
-
readonly [Symbol.toStringTag] = "ScannerStateSetView";
|
|
40
|
-
constructor(readValues: () => readonly string[]);
|
|
41
|
-
get size(): number;
|
|
42
|
-
has(value: string): boolean;
|
|
43
|
-
entries(): SetIterator<[string, string]>;
|
|
44
|
-
keys(): SetIterator<string>;
|
|
45
|
-
valuesIterator(): SetIterator<string>;
|
|
46
|
-
values(): SetIterator<string>;
|
|
47
|
-
forEach(callbackfn: (value: string, value2: string, set: ScannerStateSetView) => void, thisArg?: unknown): void;
|
|
48
|
-
[Symbol.iterator](): SetIterator<string>;
|
|
49
|
-
}
|
|
50
|
-
declare class MasterCSSScanner extends EventEmitter implements AsyncDisposable {
|
|
51
|
-
customOptions: MasterCSSScannerOptions;
|
|
52
|
-
cwd: string;
|
|
53
|
-
readonly latentClasses: ScannerStateSetView;
|
|
54
|
-
readonly validClasses: ScannerStateSetView;
|
|
55
|
-
readonly invalidClasses: ScannerStateSetView;
|
|
56
|
-
readonly nativeClassNames: ScannerStateSetView;
|
|
57
|
-
readonly usedNativeClasses: ScannerStateSetView;
|
|
58
|
-
/** Current successful source snapshot, including empty and virtual inputs. */
|
|
59
|
-
get sources(): {
|
|
60
|
-
source: string;
|
|
61
|
-
owner: string;
|
|
62
|
-
parentSource: string | null;
|
|
63
|
-
kind: import("@master/css-binding/protocol").MasterCSSSourceExtractorKind;
|
|
64
|
-
extractor: string;
|
|
65
|
-
candidates: string[];
|
|
66
|
-
}[];
|
|
67
|
-
initialized: boolean;
|
|
68
|
-
initializing?: Promise<this>;
|
|
69
|
-
resetDependencies: string[];
|
|
70
|
-
readonly css: ScannerCSSView;
|
|
71
|
-
private bindingSession?;
|
|
72
|
-
private bindingState?;
|
|
73
|
-
private currentManifest;
|
|
74
|
-
private lifecycleGeneration;
|
|
75
|
-
private sourcePolicy?;
|
|
76
|
-
private sourceRevisions;
|
|
77
|
-
private ownerRevisions;
|
|
78
|
-
private ownerSnapshots;
|
|
79
|
-
private sourceParents;
|
|
80
|
-
private committedSources;
|
|
81
|
-
private extractionCache;
|
|
82
|
-
/** Precompiled minimatch patterns for per-module allow/exclude checks. */
|
|
83
|
-
private sourceMatchers?;
|
|
84
|
-
private sourceMatcherOptions?;
|
|
85
|
-
constructor(customOptions: MasterCSSScannerOptions, cwd?: string);
|
|
86
|
-
init(customOptions?: MasterCSSScannerOptions): Promise<this>;
|
|
87
|
-
private initInternal;
|
|
88
|
-
reset(customOptions?: MasterCSSScannerOptions, resetOptions?: ScannerResetOptions): Promise<this>;
|
|
89
|
-
dispose(): Promise<this>;
|
|
90
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
91
|
-
private insertSafelist;
|
|
92
|
-
/**
|
|
93
|
-
* @description Extract source content candidates.
|
|
94
|
-
* @param source
|
|
95
|
-
* @param content
|
|
96
|
-
* @returns Promise<string[]> Latent classes
|
|
97
|
-
*/
|
|
98
|
-
collectCandidates(source: string, content: string, options?: ScannerSourceOptions): Promise<string[]>;
|
|
99
|
-
private extractCandidates;
|
|
100
|
-
scan(source: string, content: string): Promise<boolean>;
|
|
101
|
-
scanSource(source: string, content: string, options?: ScannerSourceOptions): Promise<MasterCSSScannerSourceResult>;
|
|
102
|
-
removeSource(source: string, options?: ScannerSourceOptions): MasterCSSScannerSourceResult;
|
|
103
|
-
private sourceAncestors;
|
|
104
|
-
reconcileSources(owner: string, inputs: readonly ScannerSourceInput[]): Promise<MasterCSSScannerSourceResult>;
|
|
105
|
-
private reconcileOwner;
|
|
106
|
-
removeOwner(owner: string): MasterCSSScannerSourceResult;
|
|
107
|
-
private applyUpdate;
|
|
108
|
-
scanModule(source: string, content: string): Promise<boolean>;
|
|
109
|
-
private resolveSourceAdapter;
|
|
110
|
-
private getSourceMatchers;
|
|
111
|
-
isModuleAllowed(source: string): boolean;
|
|
112
|
-
isSourceAllowed(source: string, options?: {
|
|
113
|
-
explicit?: boolean;
|
|
114
|
-
}): boolean;
|
|
115
|
-
get sourcePolicyDependencies(): string[];
|
|
116
|
-
registerNativeClasses(owner: string, classNames: string[]): boolean;
|
|
117
|
-
private getBindingSession;
|
|
118
|
-
private syncBindingState;
|
|
119
|
-
get state(): import("@master/css-binding/protocol").MasterCSSScannerState;
|
|
120
|
-
/**
|
|
121
|
-
* computed from `options.manifest`
|
|
122
|
-
*/
|
|
123
|
-
get manifest(): MasterCSSManifest;
|
|
124
|
-
readonly slotCSSRule = "#master-css-slot{--slot:0}";
|
|
125
|
-
}
|
|
126
|
-
declare function createScanner(options: MasterCSSScannerOptions, cwd?: string): Promise<MasterCSSScanner>;
|
|
127
|
-
interface MasterCSSScanner {
|
|
128
|
-
options: MasterCSSScannerOptions;
|
|
129
|
-
}
|
|
130
|
-
export { MasterCSSScanner, MasterCSSScannerSourceResult, ScannerCSSView, type ScannerSourceInput, type ScannerSourceOptions, ScannerStateSetView, createScanner };
|