@master/css-binding 0.0.0-site.1793659883.g69c9aebcf628

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.
Files changed (66) hide show
  1. package/artifacts/mastercss.node +0 -0
  2. package/artifacts/mcss +0 -0
  3. package/dist/binding-options.d.ts +14 -0
  4. package/dist/binding-options.js +15 -0
  5. package/dist/binding.d.ts +12 -0
  6. package/dist/binding.js +23 -0
  7. package/dist/browser.d.ts +3 -0
  8. package/dist/browser.js +3 -0
  9. package/dist/compiler-binding-adapter.js +55 -0
  10. package/dist/compiler-binding-browser.d.ts +6 -0
  11. package/dist/compiler-binding-browser.js +24 -0
  12. package/dist/compiler-binding-contract.d.ts +45 -0
  13. package/dist/compiler-binding-node.d.ts +5 -0
  14. package/dist/compiler-binding-node.js +20 -0
  15. package/dist/compiler-binding-wasm.js +58 -0
  16. package/dist/compiler-binding.d.ts +6 -0
  17. package/dist/compiler-binding.js +42 -0
  18. package/dist/compiler.js +52 -0
  19. package/dist/engine-binding-adapter.js +61 -0
  20. package/dist/engine-binding-browser.d.ts +8 -0
  21. package/dist/engine-binding-browser.js +35 -0
  22. package/dist/engine-binding-js.js +81 -0
  23. package/dist/engine-binding-node.d.ts +9 -0
  24. package/dist/engine-binding-node.js +38 -0
  25. package/dist/engine-binding-wasm.js +64 -0
  26. package/dist/engine-binding.d.ts +40 -0
  27. package/dist/engine-binding.js +57 -0
  28. package/dist/engine-contract.d.ts +14 -0
  29. package/dist/engine-js/src/animation.js +154 -0
  30. package/dist/engine-js/src/apply.js +207 -0
  31. package/dist/engine-js/src/class-syntax.js +333 -0
  32. package/dist/engine-js/src/condition.js +440 -0
  33. package/dist/engine-js/src/css-syntax.js +247 -0
  34. package/dist/engine-js/src/generate.js +288 -0
  35. package/dist/engine-js/src/mixin.js +328 -0
  36. package/dist/engine-js/src/native-properties.js +5 -0
  37. package/dist/engine-js/src/order.js +97 -0
  38. package/dist/engine-js/src/program-model.js +19 -0
  39. package/dist/engine-js/src/program.js +434 -0
  40. package/dist/engine-js/src/selector.js +195 -0
  41. package/dist/engine-js/src/session.js +540 -0
  42. package/dist/engine-js/src/state.js +62 -0
  43. package/dist/engine-js/src/text.js +51 -0
  44. package/dist/engine-js/src/utility.js +236 -0
  45. package/dist/engine-js/src/value.js +254 -0
  46. package/dist/engine.js +86 -0
  47. package/dist/errors.js +10 -0
  48. package/dist/index.d.ts +4 -0
  49. package/dist/index.js +3 -0
  50. package/dist/native-loader.js +134 -0
  51. package/dist/normalize-error.js +63 -0
  52. package/dist/protocol.d.ts +1119 -0
  53. package/dist/protocol.js +14 -0
  54. package/dist/tooling-binding-adapter.js +23 -0
  55. package/dist/tooling-binding-browser.d.ts +5 -0
  56. package/dist/tooling-binding-browser.js +15 -0
  57. package/dist/tooling-binding-contract.d.ts +92 -0
  58. package/dist/tooling-binding-native.js +46 -0
  59. package/dist/tooling-binding-node.d.ts +4 -0
  60. package/dist/tooling-binding-node.js +11 -0
  61. package/dist/tooling-binding-wasm.js +127 -0
  62. package/dist/tooling-binding.d.ts +5 -0
  63. package/dist/tooling-binding.js +21 -0
  64. package/dist/tooling.js +144 -0
  65. package/dist/version.js +3 -0
  66. package/package.json +78 -0
@@ -0,0 +1,195 @@
1
+ import { isAsciiCase, isAsciiWhitespace, trim } from "./text.js";
2
+ import { tokenize } from "./css-syntax.js";
3
+ import { nativeContent, splitTopLevel } from "./class-syntax.js";
4
+ // ../engine-js/src/selector.ts
5
+ /** Top-level selector list branches, each trimmed. */
6
+ function splitSelectorList(source) {
7
+ const tokens = tokenize(source);
8
+ const branches = [];
9
+ let cursor = 0;
10
+ for (let index = 0; index < tokens.length; index++) {
11
+ const token = tokens[index];
12
+ if (token.close >= 0) index = token.close;
13
+ else if (token.kind === 8 && token.value === ",") {
14
+ branches.push(trim(source.slice(cursor, token.start)));
15
+ cursor = token.end;
16
+ }
17
+ }
18
+ branches.push(trim(source.slice(cursor)));
19
+ return branches;
20
+ }
21
+ /** Replaces each nesting `&` outside attribute selectors; undefined when there is none. */
22
+ function replaceNestingSelector(source, parent) {
23
+ const replacement = splitSelectorList(parent).length > 1 ? `:is(${parent})` : parent;
24
+ let result = "";
25
+ let cursor = 0;
26
+ let attributes = 0;
27
+ for (const token of tokenize(source)) {
28
+ if (token.kind !== 8) continue;
29
+ if (token.value === "[") attributes++;
30
+ else if (token.value === "]") attributes && attributes--;
31
+ else if (token.value === "&" && !attributes) {
32
+ result += source.slice(cursor, token.start) + replacement;
33
+ cursor = token.end;
34
+ }
35
+ }
36
+ return cursor ? result + source.slice(cursor) : void 0;
37
+ }
38
+ /** Rejects definite token structure errors, without a browser capability allowlist. */
39
+ function validSelectorStructure(source) {
40
+ if (nativeContent(source) === void 0 || splitSelectorList(source).includes("")) return false;
41
+ const tokens = tokenize(source);
42
+ for (let index = 0; index < tokens.length; index++) {
43
+ const token = tokens[index];
44
+ if (token.kind !== 8) continue;
45
+ if (token.value === "[") {
46
+ if (token.close < 0) return false;
47
+ index = token.close;
48
+ } else if (token.value === "." || token.value === "#") {
49
+ if (tokens[index + 1]?.kind !== 0) return false;
50
+ } else if ("<;{}@".includes(token.value)) return false;
51
+ else if (token.value === ":") {
52
+ const previous = tokens[index - 1];
53
+ const element = previous?.kind === 8 && previous.value === ":" && previous.end === token.start;
54
+ const next = tokens[index + 1];
55
+ if (!(next !== void 0 && next.start === token.end && (next.kind === 0 || next.kind === 3 || next.kind === 8 && next.value === ":" && !element))) return false;
56
+ }
57
+ }
58
+ return true;
59
+ }
60
+ const SELECTOR_LIST_FUNCTIONS = [
61
+ "is",
62
+ "where",
63
+ "not",
64
+ "has",
65
+ "host",
66
+ "host-context",
67
+ "slotted"
68
+ ];
69
+ const NTH_FUNCTIONS = ["nth-child", "nth-last-child"];
70
+ /** Turns descendant `_` into spaces, except inside attributes, strings, escapes and non-selector arguments. */
71
+ function replaceSelectorUnderscores(source) {
72
+ const tokens = tokenize(source);
73
+ const protectedRanges = /* @__PURE__ */ new Map();
74
+ const protect = (start, end) => protectedRanges.has(start) || protectedRanges.set(start, end);
75
+ for (let index = 0; index < tokens.length; index++) {
76
+ const token = tokens[index];
77
+ if (token.kind === 8 && token.value === "[" && token.close >= 0) {
78
+ protect(token.start, tokens[token.close].end);
79
+ index = token.close;
80
+ continue;
81
+ }
82
+ if (token.kind === 3 && token.close >= 0 && !SELECTOR_LIST_FUNCTIONS.some((name) => isAsciiCase(token.value, name))) {
83
+ const closeStart = tokens[token.close].start;
84
+ let start = closeStart;
85
+ if (NTH_FUNCTIONS.some((name) => isAsciiCase(token.value, name))) {
86
+ const of = tokens.slice(index + 1, token.close).find((item) => item.kind === 0 && isAsciiCase(item.value, "of"));
87
+ if (of) start = of.start;
88
+ }
89
+ if (start > token.end) protect(token.end, start);
90
+ if (start === closeStart) {
91
+ index = token.close;
92
+ continue;
93
+ }
94
+ }
95
+ if (token.kind === 1) protect(token.start, token.end);
96
+ }
97
+ let output = "";
98
+ let cursor = 0;
99
+ while (cursor < source.length) {
100
+ const end = protectedRanges.get(cursor);
101
+ if (end !== void 0) {
102
+ output += source.slice(cursor, end);
103
+ cursor = end;
104
+ continue;
105
+ }
106
+ if (source.startsWith("/*", cursor)) {
107
+ const close = source.indexOf("*/", cursor + 2);
108
+ const commentEnd = close < 0 ? source.length : close + 2;
109
+ output += source.slice(cursor, commentEnd);
110
+ cursor = commentEnd;
111
+ continue;
112
+ }
113
+ const unit = source.charCodeAt(cursor);
114
+ if (unit === 92) {
115
+ const start = cursor++;
116
+ let digits = 0;
117
+ while (digits < 6 && /[0-9a-fA-F]/.test(source[cursor] ?? "")) {
118
+ digits++;
119
+ cursor++;
120
+ }
121
+ if (!digits) cursor += cursor < source.length ? String.fromCodePoint(source.codePointAt(cursor)).length : 0;
122
+ else if (isAsciiWhitespace(source.charCodeAt(cursor))) cursor++;
123
+ output += source.slice(start, cursor);
124
+ continue;
125
+ }
126
+ output += unit === 95 && isDescendantUnderscore(source, tokens, cursor) ? " " : source[cursor];
127
+ cursor++;
128
+ }
129
+ return output;
130
+ }
131
+ function isDescendantUnderscore(source, tokens, cursor) {
132
+ if (source[cursor - 1] === "_" || source[cursor + 1] === "_") return false;
133
+ let before;
134
+ for (let index = tokens.length - 1; index >= 0; index--) if (tokens[index].start < cursor) {
135
+ before = source[Math.min(tokens[index].end, cursor) - 1];
136
+ break;
137
+ }
138
+ if (before !== void 0 && "(,.:#>+~|".includes(before)) return false;
139
+ const next = tokens.find((token) => token.end > cursor + 1);
140
+ if (!next) return false;
141
+ const after = source[Math.max(next.start, cursor + 1)];
142
+ return after !== void 0 && !")+,>~|".includes(after);
143
+ }
144
+ /** The template of a selector suffix, `&` before each top-level branch. */
145
+ function selectorTokenToTemplate(selectorToken) {
146
+ return splitTopLevel(replaceSelectorUnderscores(selectorToken), ",").map((group) => `&${group}`).join(",");
147
+ }
148
+ const STATE_PRIORITIES = {
149
+ hover: 1,
150
+ focus: 2,
151
+ "focus-visible": 2,
152
+ active: 3,
153
+ disabled: 4
154
+ };
155
+ const statePriority = (name) => Object.hasOwn(STATE_PRIORITIES, name) ? STATE_PRIORITIES[name] : 0;
156
+ const isIdentifierCharacter = (unit) => unit >= 48 && unit <= 57 || unit >= 65 && unit <= 90 || unit >= 97 && unit <= 122 || unit === 45 || unit === 95;
157
+ /** Interaction states in a selector, so hover precedes focus, active and disabled. */
158
+ function selectorPriority(selector) {
159
+ if (selector === void 0) return 0;
160
+ let total = 0;
161
+ let quote = "";
162
+ let index = 0;
163
+ while (index < selector.length) {
164
+ const character = selector[index];
165
+ if (quote) {
166
+ index++;
167
+ if (character === "\\") {
168
+ if (index < selector.length) index++;
169
+ } else if (character === quote) quote = "";
170
+ continue;
171
+ }
172
+ if (character === "\"" || character === "'") {
173
+ quote = character;
174
+ index++;
175
+ continue;
176
+ }
177
+ if (character === "[") {
178
+ const close = selector.indexOf("]", index + 1);
179
+ if (close >= 0) {
180
+ total += statePriority(trim(selector.slice(index + 1, close)));
181
+ index = close + 1;
182
+ continue;
183
+ }
184
+ }
185
+ if (isIdentifierCharacter(selector.charCodeAt(index))) {
186
+ const start = index++;
187
+ while (isIdentifierCharacter(selector.charCodeAt(index))) index++;
188
+ total += statePriority(selector.slice(start, index));
189
+ continue;
190
+ }
191
+ index++;
192
+ }
193
+ return total;
194
+ }
195
+ export { replaceNestingSelector, selectorPriority, selectorTokenToTemplate, splitSelectorList, validSelectorStructure };