@visual-check/storybook 0.0.0-stage → 0.1.0

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 (64) hide show
  1. package/LICENSE +21 -0
  2. package/THIRD-PARTY-NOTICES.md +51 -0
  3. package/dist/angular-port/combinations.d.ts +89 -0
  4. package/dist/angular-port/combinations.d.ts.map +1 -0
  5. package/dist/angular-port/combinations.js +97 -0
  6. package/dist/angular-port/combinations.js.map +1 -0
  7. package/dist/angular.d.ts +4 -0
  8. package/dist/angular.d.ts.map +1 -0
  9. package/dist/angular.js +4 -0
  10. package/dist/angular.js.map +1 -0
  11. package/dist/dom-port/combinations.d.ts +59 -0
  12. package/dist/dom-port/combinations.d.ts.map +1 -0
  13. package/dist/dom-port/combinations.js +137 -0
  14. package/dist/dom-port/combinations.js.map +1 -0
  15. package/dist/forced-state/force-states.d.ts +68 -0
  16. package/dist/forced-state/force-states.d.ts.map +1 -0
  17. package/dist/forced-state/force-states.js +388 -0
  18. package/dist/forced-state/force-states.js.map +1 -0
  19. package/dist/forced-state/forced-states.d.ts +27 -0
  20. package/dist/forced-state/forced-states.d.ts.map +1 -0
  21. package/dist/forced-state/forced-states.js +41 -0
  22. package/dist/forced-state/forced-states.js.map +1 -0
  23. package/dist/forced-state/prototype-hooks.d.ts +28 -0
  24. package/dist/forced-state/prototype-hooks.d.ts.map +1 -0
  25. package/dist/forced-state/prototype-hooks.js +49 -0
  26. package/dist/forced-state/prototype-hooks.js.map +1 -0
  27. package/dist/forced-state/style-sheet-rewrite.d.ts +29 -0
  28. package/dist/forced-state/style-sheet-rewrite.d.ts.map +1 -0
  29. package/dist/forced-state/style-sheet-rewrite.js +148 -0
  30. package/dist/forced-state/style-sheet-rewrite.js.map +1 -0
  31. package/dist/forced-state/twin-selectors.d.ts +21 -0
  32. package/dist/forced-state/twin-selectors.d.ts.map +1 -0
  33. package/dist/forced-state/twin-selectors.js +316 -0
  34. package/dist/forced-state/twin-selectors.js.map +1 -0
  35. package/dist/grid-story/grid-layout.d.ts +156 -0
  36. package/dist/grid-story/grid-layout.d.ts.map +1 -0
  37. package/dist/grid-story/grid-layout.js +163 -0
  38. package/dist/grid-story/grid-layout.js.map +1 -0
  39. package/dist/index.d.ts +8 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +6 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/per-story-options/define-visual-check.d.ts +237 -0
  44. package/dist/per-story-options/define-visual-check.d.ts.map +1 -0
  45. package/dist/per-story-options/define-visual-check.js +60 -0
  46. package/dist/per-story-options/define-visual-check.js.map +1 -0
  47. package/dist/react-port/combinations.d.ts +27 -0
  48. package/dist/react-port/combinations.d.ts.map +1 -0
  49. package/dist/react-port/combinations.js +45 -0
  50. package/dist/react-port/combinations.js.map +1 -0
  51. package/dist/react.d.ts +4 -0
  52. package/dist/react.d.ts.map +1 -0
  53. package/dist/react.js +4 -0
  54. package/dist/react.js.map +1 -0
  55. package/dist/vue-port/combinations.d.ts +35 -0
  56. package/dist/vue-port/combinations.d.ts.map +1 -0
  57. package/dist/vue-port/combinations.js +75 -0
  58. package/dist/vue-port/combinations.js.map +1 -0
  59. package/dist/vue.d.ts +4 -0
  60. package/dist/vue.d.ts.map +1 -0
  61. package/dist/vue.js +4 -0
  62. package/dist/vue.js.map +1 -0
  63. package/package.json +78 -3
  64. package/README.md +0 -3
@@ -0,0 +1,388 @@
1
+ import { checkedStatesOf, forcedStateClassOf, forcedStates } from './forced-states.js';
2
+ import { hookMethod, hookSetter, runEffect } from './prototype-hooks.js';
3
+ import { styleSheetRewriterOf } from './style-sheet-rewrite.js';
4
+ /**
5
+ * What the observer watches in the document and each shadow root.
6
+ */
7
+ const observedChanges = {
8
+ childList: true,
9
+ subtree: true,
10
+ characterData: true,
11
+ attributes: true,
12
+ attributeFilter: ['class'],
13
+ };
14
+ /**
15
+ * Every state's class, which shadow hosts take from their ancestors.
16
+ */
17
+ const stateClasses = forcedStates.map(forcedStateClassOf);
18
+ /**
19
+ * The rewriter of this realm's page, made on the first `forceStates`.
20
+ */
21
+ let realmRewriter;
22
+ /**
23
+ * The rewriter of one page. Creating it touches nothing in the page.
24
+ */
25
+ export function pageRewriterOf(page) {
26
+ const state = {
27
+ page,
28
+ rewriter: styleSheetRewriterOf((message) => page.console.warn(message)),
29
+ counts: new Map(),
30
+ states: new Set(),
31
+ hooked: false,
32
+ closedRoots: new Set(),
33
+ observer: undefined,
34
+ roots: new Set(),
35
+ hostClasses: new Map(),
36
+ onLoad: (event) => rewriteLoaded(state, event),
37
+ };
38
+ return { force: (states) => force(state, states) };
39
+ }
40
+ /**
41
+ * Forces states on this page, the way a grid's state columns do. Every stylesheet rule that uses one of the states gets a
42
+ * twin selector, at the same specificity, that matches under the state's class: `visual-check-hover`, `visual-check-active`,
43
+ * `visual-check-focus`, `visual-check-focus-visible` or `visual-check-focus-within`. Put the class on any ancestor of what
44
+ * should show the state. It reaches `<style>` and `<link>` sheets, adopted sheets and shadow roots' sheets, and keeps
45
+ * rewriting styles added or changed later, CSS-in-JS rules included, until the returned function is called. That makes
46
+ * it fit a story's `beforeEach`. Rewritten rules stay rewritten, and without the classes nothing in the page changes. The
47
+ * browser's default styles, states inside `:not()` and cross-origin stylesheets without CORS, which log a warning,
48
+ * aren't forced. A sheet pushed onto `adoptedStyleSheets`, rather than assigned, is rewritten on the next change to the
49
+ * DOM, so one pushed with no change after it may be missed. Without a DOM, it does nothing. Adapted from Storybook's
50
+ * pseudo-states addon (MIT).
51
+ *
52
+ * @throws When a state isn't one visual-check forces, or is listed twice.
53
+ * @public
54
+ */
55
+ export function forceStates(states) {
56
+ const checked = checkedStatesOf(states, 'forceStates');
57
+ if (typeof globalThis.document === 'undefined' || checked.length === 0) {
58
+ return () => undefined;
59
+ }
60
+ realmRewriter ??= pageRewriterOf(globalThis);
61
+ return realmRewriter.force(new Set(checked));
62
+ }
63
+ /**
64
+ * Counts the request in, starting or growing the rewrite when it adds states, and gives its idempotent stop.
65
+ */
66
+ function force(state, states) {
67
+ const grows = [...states].some((forced) => !state.states.has(forced));
68
+ let stopped = false;
69
+ count(state, states, 1);
70
+ if (grows) {
71
+ start(state);
72
+ }
73
+ return () => {
74
+ if (!stopped) {
75
+ stopped = true;
76
+ stop(state, states);
77
+ }
78
+ };
79
+ }
80
+ /**
81
+ * Counts the request out, and deactivates once no state is left.
82
+ */
83
+ function stop(state, states) {
84
+ count(state, states, -1);
85
+ if (state.states.size === 0) {
86
+ deactivate(state);
87
+ }
88
+ }
89
+ /**
90
+ * Adds `change` to each state's count, and recomputes the union.
91
+ */
92
+ function count(state, states, change) {
93
+ for (const forced of states) {
94
+ state.counts.set(forced, (state.counts.get(forced) ?? 0) + change);
95
+ }
96
+ state.states = new Set(forcedStates.filter((forced) => (state.counts.get(forced) ?? 0) > 0));
97
+ }
98
+ /**
99
+ * Activates the rewriter on the first request, then does a full pass.
100
+ */
101
+ function start(state) {
102
+ if (!isActive(state)) {
103
+ installHooks(state);
104
+ state.observer = new state.page.MutationObserver((records) => rewriteMutated(state, records));
105
+ watch(state, state.page.document);
106
+ addClosedRoots(state);
107
+ }
108
+ rewriteAll(state);
109
+ }
110
+ /**
111
+ * Whether there is a request.
112
+ */
113
+ function isActive(state) {
114
+ return state.observer !== undefined;
115
+ }
116
+ /**
117
+ * Registers the closed roots attached while inactive that are still alive, and forgets the dead ones.
118
+ */
119
+ function addClosedRoots(state) {
120
+ for (const reference of state.closedRoots) {
121
+ const root = reference.deref();
122
+ if (root === undefined) {
123
+ state.closedRoots.delete(reference);
124
+ }
125
+ else {
126
+ state.roots.add(root);
127
+ watch(state, root);
128
+ }
129
+ }
130
+ }
131
+ /**
132
+ * Stops watching and takes the classes off hosts. Twins stay, inert without the classes, and hooks stay, inert.
133
+ */
134
+ function deactivate(state) {
135
+ state.observer?.disconnect();
136
+ state.observer = undefined;
137
+ for (const root of [state.page.document, ...state.roots]) {
138
+ root.removeEventListener('load', state.onLoad, true);
139
+ }
140
+ for (const [host, classes] of state.hostClasses) {
141
+ host.classList.remove(...classes);
142
+ }
143
+ state.hostClasses.clear();
144
+ state.roots.clear();
145
+ }
146
+ /**
147
+ * Observes the root and listens for its `load`s.
148
+ */
149
+ function watch(state, root) {
150
+ state.observer?.observe(root, observedChanges);
151
+ root.addEventListener('load', state.onLoad, true);
152
+ }
153
+ /**
154
+ * Rewrites the document, every open shadow root and every root already known, with those nested in them, then tags the
155
+ * hosts.
156
+ */
157
+ function rewriteAll(state) {
158
+ const known = [...state.roots].flatMap((root) => [root, ...shadowRootsIn(root.querySelectorAll('*'))]);
159
+ rewriteRoot(state, state.page.document);
160
+ for (const root of [...shadowRootsIn(state.page.document.querySelectorAll('*')), ...known]) {
161
+ addRoot(state, root);
162
+ }
163
+ tagHosts(state);
164
+ }
165
+ /**
166
+ * Rewrites each root that changed once, the shadow roots added with new elements, and every known root's adopted
167
+ * sheets, which a push onto `adoptedStyleSheets` changes without the setter, then tags the hosts.
168
+ */
169
+ function rewriteMutated(state, records) {
170
+ const changed = new Set(records.map((record) => record.target.getRootNode()));
171
+ const added = new Set(records.flatMap((record) => elementsIn(state.page, record.addedNodes)));
172
+ for (const root of changed) {
173
+ if (isStyleRoot(state.page, root)) {
174
+ rewriteRoot(state, root);
175
+ }
176
+ }
177
+ for (const root of shadowRootsIn(added)) {
178
+ addRoot(state, root);
179
+ }
180
+ for (const root of [state.page.document, ...state.roots]) {
181
+ rewriteSheets(state, root, root.adoptedStyleSheets ?? []);
182
+ }
183
+ tagHosts(state);
184
+ }
185
+ /**
186
+ * Rewrites the sheet of a `<link>` or `<style>` that loaded, or whose `@import`s did.
187
+ */
188
+ function rewriteLoaded(state, event) {
189
+ const target = event.target;
190
+ const sheet = target.sheet;
191
+ if (sheet === null || sheet === undefined) {
192
+ return;
193
+ }
194
+ state.rewriter.forgetSheet(sheet);
195
+ state.rewriter.rewriteSheet(sheet, scopeOf(state.page, target.getRootNode()), state.states);
196
+ }
197
+ /**
198
+ * The elements among the nodes, and every element below them.
199
+ */
200
+ function elementsIn(page, nodes) {
201
+ return Array.from(nodes).flatMap((node) => node instanceof page.Element ? [node, ...Array.from(node.querySelectorAll('*'))] : []);
202
+ }
203
+ /**
204
+ * The open shadow roots of the elements, and those nested in them.
205
+ */
206
+ function shadowRootsIn(elements) {
207
+ return [...elements].flatMap((element) => element.shadowRoot === null ? [] : [element.shadowRoot, ...shadowRootsIn(element.shadowRoot.querySelectorAll('*'))]);
208
+ }
209
+ /**
210
+ * Registers a shadow root, watching it the first time, and rewrites its sheets.
211
+ */
212
+ function addRoot(state, root) {
213
+ if (!state.roots.has(root)) {
214
+ state.roots.add(root);
215
+ watch(state, root);
216
+ }
217
+ rewriteRoot(state, root);
218
+ }
219
+ /**
220
+ * Rewrites a root's `<style>`, `<link>` and adopted sheets in its scope.
221
+ */
222
+ function rewriteRoot(state, root) {
223
+ rewriteSheets(state, root, [...Array.from(root.styleSheets), ...(root.adoptedStyleSheets ?? [])]);
224
+ }
225
+ /**
226
+ * Rewrites the sheets in the root's scope.
227
+ */
228
+ function rewriteSheets(state, root, sheets) {
229
+ const scope = scopeOf(state.page, root);
230
+ for (const sheet of sheets) {
231
+ state.rewriter.rewriteSheet(sheet, scope, state.states);
232
+ }
233
+ }
234
+ /**
235
+ * Whether a node is where stylesheets apply: a document or a shadow root.
236
+ */
237
+ function isStyleRoot(page, node) {
238
+ return node instanceof page.Document || node instanceof page.ShadowRoot;
239
+ }
240
+ /**
241
+ * The scope of the sheets in a root.
242
+ */
243
+ function scopeOf(page, root) {
244
+ return root instanceof page.ShadowRoot ? 'shadow-root' : 'document';
245
+ }
246
+ /**
247
+ * Gives each connected host the state classes of its composed ancestors, and takes off those it no longer gets. A
248
+ * disconnected host's root is kept: a custom element often attaches a closed root before it's inserted.
249
+ */
250
+ function tagHosts(state) {
251
+ for (const root of state.roots) {
252
+ tagHost(state, root.host);
253
+ }
254
+ }
255
+ /**
256
+ * Gives a connected host the state classes of its composed ancestors, and takes off those it no longer gets.
257
+ */
258
+ function tagHost(state, host) {
259
+ if (host.isConnected) {
260
+ setHostClasses(state, host, inheritedClassesOf(state, host));
261
+ }
262
+ }
263
+ /**
264
+ * The state classes of the element's composed ancestors, through shadow hosts, leaving out those this rewriter added.
265
+ */
266
+ function inheritedClassesOf(state, element) {
267
+ const classes = new Set();
268
+ for (let node = composedParentOf(state.page, element); node !== null; node = composedParentOf(state.page, node)) {
269
+ for (const className of ownStateClassesOf(state, node)) {
270
+ classes.add(className);
271
+ }
272
+ }
273
+ return classes;
274
+ }
275
+ /**
276
+ * The node's parent, or its host when the parent is a shadow root.
277
+ */
278
+ function composedParentOf(page, node) {
279
+ const parent = node.parentNode;
280
+ return parent instanceof page.ShadowRoot ? parent.host : parent;
281
+ }
282
+ /**
283
+ * The state classes an element has that this rewriter didn't add.
284
+ */
285
+ function ownStateClassesOf(state, node) {
286
+ if (!(node instanceof state.page.Element)) {
287
+ return [];
288
+ }
289
+ const added = state.hostClasses.get(node);
290
+ return stateClasses.filter((className) => node.classList.contains(className) && !added?.has(className));
291
+ }
292
+ /**
293
+ * Adds the wanted classes the host lacks, and removes those this rewriter added that are no longer wanted.
294
+ */
295
+ function setHostClasses(state, host, wanted) {
296
+ const added = state.hostClasses.get(host) ?? new Set();
297
+ for (const className of wanted) {
298
+ if (!host.classList.contains(className)) {
299
+ host.classList.add(className);
300
+ added.add(className);
301
+ }
302
+ }
303
+ for (const className of [...added].filter((name) => !wanted.has(name))) {
304
+ host.classList.remove(className);
305
+ added.delete(className);
306
+ }
307
+ if (added.size > 0) {
308
+ state.hostClasses.set(host, added);
309
+ }
310
+ else {
311
+ state.hostClasses.delete(host);
312
+ }
313
+ }
314
+ /**
315
+ * Hooks the prototypes once, chaining with any earlier hook: `attachShadow`, the `adoptedStyleSheets` setters,
316
+ * `insertRule`, `replaceSync` and `replace`.
317
+ */
318
+ function installHooks(state) {
319
+ if (state.hooked) {
320
+ return;
321
+ }
322
+ const { page } = state;
323
+ const context = { isActive: () => isActive(state), warn: (message) => page.console.warn(message) };
324
+ state.hooked = true;
325
+ hookMethod(page.Element.prototype, 'attachShadow', { ...context, isActive: () => true }, (host, root) => attached(state, host, root));
326
+ hookSetter(page.Document.prototype, 'adoptedStyleSheets', context, (root) => adoptRoot(state, root));
327
+ hookSetter(page.ShadowRoot.prototype, 'adoptedStyleSheets', context, (root) => adoptRoot(state, root));
328
+ hookMethod(page.CSSStyleSheet.prototype, 'insertRule', context, (sheet, index) => rewriteInserted(state, sheet, sheet.cssRules[index]));
329
+ hookMethod(page.CSSGroupingRule?.prototype, 'insertRule', context, (rule, index) => rewriteInserted(state, rule.parentStyleSheet, rule.cssRules[index]));
330
+ hookMethod(page.CSSStyleSheet.prototype, 'replaceSync', context, (sheet) => rewriteReplaced(state, sheet));
331
+ hookMethod(page.CSSStyleSheet.prototype, 'replace', context, (sheet, replaced) => {
332
+ replaced.then(() => runEffect(context, 'replace', () => rewriteReplaced(state, sheet)), () => undefined);
333
+ });
334
+ }
335
+ /**
336
+ * Records a closed root, active or not, and while active registers any new root and tags its host.
337
+ */
338
+ function attached(state, host, root) {
339
+ if (host.shadowRoot !== root) {
340
+ state.closedRoots.add(new WeakRef(root));
341
+ }
342
+ if (isActive(state)) {
343
+ adoptRoot(state, root);
344
+ }
345
+ }
346
+ /**
347
+ * Rewrites a root a hook saw, registering it when it's a shadow root, and tags its host.
348
+ */
349
+ function adoptRoot(state, root) {
350
+ if (root instanceof state.page.ShadowRoot) {
351
+ addRoot(state, root);
352
+ tagHost(state, root.host);
353
+ }
354
+ else {
355
+ rewriteRoot(state, root);
356
+ }
357
+ }
358
+ /**
359
+ * Rewrites an inserted rule in each scope its sheet applies in. A sheet with none, constructed and not yet adopted, is
360
+ * left for when it is.
361
+ */
362
+ function rewriteInserted(state, sheet, rule) {
363
+ if (sheet === null || rule === undefined) {
364
+ return;
365
+ }
366
+ for (const scope of scopesOf(state, sheet)) {
367
+ state.rewriter.rewriteRule(rule, scope, state.states);
368
+ }
369
+ }
370
+ /**
371
+ * Walks a sheet whose rules were replaced again, in each scope it applies in.
372
+ */
373
+ function rewriteReplaced(state, sheet) {
374
+ state.rewriter.forgetSheet(sheet);
375
+ for (const scope of scopesOf(state, sheet)) {
376
+ state.rewriter.rewriteSheet(sheet, scope, state.states);
377
+ }
378
+ }
379
+ /**
380
+ * The scopes a sheet applies in: its owner's root's, or those it was rewritten in.
381
+ */
382
+ function scopesOf(state, sheet) {
383
+ if (sheet.ownerNode !== null) {
384
+ return [scopeOf(state.page, sheet.ownerNode.getRootNode())];
385
+ }
386
+ return [...state.rewriter.scopesOf(sheet)];
387
+ }
388
+ //# sourceMappingURL=force-states.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"force-states.js","sourceRoot":"","sources":["../../src/forced-state/force-states.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAoB,kBAAkB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACxG,OAAO,EAAoB,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAC1F,OAAO,EAA2B,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAsGxF;;GAEG;AACH,MAAM,eAAe,GAAyB;IAC5C,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IAAI;IACb,aAAa,EAAE,IAAI;IACnB,UAAU,EAAE,IAAI;IAChB,eAAe,EAAE,CAAC,OAAO,CAAC;CAC3B,CAAA;AAED;;GAEG;AACH,MAAM,YAAY,GAAG,YAAY,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;AAEzD;;GAEG;AACH,IAAI,aAAuC,CAAA;AAE3C;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,IAAiB;IAC9C,MAAM,KAAK,GAAc;QACvB,IAAI;QACJ,QAAQ,EAAE,oBAAoB,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvE,MAAM,EAAE,IAAI,GAAG,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,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IACzD,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,QAAQ,CAAC,KAAgB,EAAE,KAAoB;IACtD,IAAI,KAAK,CAAC,SAAS,KAAK,IAAI,EAAE,CAAC;QAC7B,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC,CAAA;IAC7D,CAAC;IAED,OAAO,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA;AAC5C,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * An interaction state visual-check can force on what's inside an element carrying its class.
3
+ *
4
+ * @public
5
+ */
6
+ export type ForcedState = 'hover' | 'active' | 'focus-visible' | 'focus-within' | 'focus';
7
+ /**
8
+ * Every state visual-check forces, in the order the docs list them. Also the order of the classes in a host twin.
9
+ *
10
+ * @public
11
+ */
12
+ export declare const forcedStates: readonly ForcedState[];
13
+ /**
14
+ * The class that forces a state on what's inside it: `visual-check-<state>`.
15
+ *
16
+ * @public
17
+ */
18
+ export declare function forcedStateClassOf(state: ForcedState): string;
19
+ /**
20
+ * The states a story listed, checked: each must be one visual-check forces, and none may repeat.
21
+ *
22
+ * @throws `visual-check: ${owner} can't force "${state}". The states it forces are hover, active, focus-visible, focus-within and focus.`
23
+ * @throws `visual-check: ${owner} lists "${state}" twice.`
24
+ * @public
25
+ */
26
+ export declare function checkedStatesOf(states: readonly unknown[], owner: string): ForcedState[];
27
+ //# sourceMappingURL=forced-states.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forced-states.d.ts","sourceRoot":"","sources":["../../src/forced-state/forced-states.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,eAAe,GAAG,cAAc,GAAG,OAAO,CAAA;AAEzF;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,SAAS,WAAW,EAAkE,CAAA;AAEjH;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAE7D;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE,CAkBxF"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Every state visual-check forces, in the order the docs list them. Also the order of the classes in a host twin.
3
+ *
4
+ * @public
5
+ */
6
+ export const forcedStates = ['hover', 'active', 'focus-visible', 'focus-within', 'focus'];
7
+ /**
8
+ * The class that forces a state on what's inside it: `visual-check-<state>`.
9
+ *
10
+ * @public
11
+ */
12
+ export function forcedStateClassOf(state) {
13
+ return `visual-check-${state}`;
14
+ }
15
+ /**
16
+ * The states a story listed, checked: each must be one visual-check forces, and none may repeat.
17
+ *
18
+ * @throws `visual-check: ${owner} can't force "${state}". The states it forces are hover, active, focus-visible, focus-within and focus.`
19
+ * @throws `visual-check: ${owner} lists "${state}" twice.`
20
+ * @public
21
+ */
22
+ export function checkedStatesOf(states, owner) {
23
+ const checked = [];
24
+ for (const state of states) {
25
+ if (!isForcedState(state)) {
26
+ throw new Error(`visual-check: ${owner} can't force "${String(state)}". The states it forces are hover, active, focus-visible, focus-within and focus.`);
27
+ }
28
+ if (checked.includes(state)) {
29
+ throw new Error(`visual-check: ${owner} lists "${state}" twice.`);
30
+ }
31
+ checked.push(state);
32
+ }
33
+ return checked;
34
+ }
35
+ /**
36
+ * Whether a value is a state visual-check forces.
37
+ */
38
+ function isForcedState(value) {
39
+ return forcedStates.includes(value);
40
+ }
41
+ //# sourceMappingURL=forced-states.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forced-states.js","sourceRoot":"","sources":["../../src/forced-state/forced-states.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAA2B,CAAC,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,cAAc,EAAE,OAAO,CAAC,CAAA;AAEjH;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAkB;IACnD,OAAO,gBAAgB,KAAK,EAAE,CAAA;AAChC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,MAA0B,EAAE,KAAa;IACvE,MAAM,OAAO,GAAkB,EAAE,CAAA;IAEjC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CACb,iBAAiB,KAAK,iBAAiB,MAAM,CAAC,KAAK,CAAC,mFAAmF,CACxI,CAAA;QACH,CAAC;QAED,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,iBAAiB,KAAK,WAAW,KAAK,UAAU,CAAC,CAAA;QACnE,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACrB,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,YAAY,CAAC,QAAQ,CAAC,KAAoB,CAAC,CAAA;AACpD,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * When a hook's effect runs, and where its failures go.
3
+ */
4
+ export interface HookContext {
5
+ /**
6
+ * Whether the effect should run: while there is a request.
7
+ */
8
+ isActive: () => boolean;
9
+ /**
10
+ * Reports an effect that threw, so the page's call never fails for it.
11
+ */
12
+ warn: (message: string) => void;
13
+ }
14
+ /**
15
+ * Wraps a prototype's method so it calls the earlier one with the same `this` and arguments, then, while active, runs
16
+ * the effect on its result, and returns the result. A missing prototype or method is skipped.
17
+ */
18
+ export declare function hookMethod<Target, Result>(prototype: Target | undefined, name: string, context: HookContext, effect: (target: Target, result: Result) => void): void;
19
+ /**
20
+ * Wraps a prototype's accessor so its setter calls the earlier one, then, while active, runs the effect. A missing
21
+ * descriptor or setter is skipped.
22
+ */
23
+ export declare function hookSetter<Target>(prototype: Target, name: string, context: HookContext, effect: (target: Target) => void): void;
24
+ /**
25
+ * Runs the effect while active, reporting what it throws instead of throwing.
26
+ */
27
+ export declare function runEffect(context: HookContext, name: string, effect: () => void): void;
28
+ //# sourceMappingURL=prototype-hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prototype-hooks.d.ts","sourceRoot":"","sources":["../../src/forced-state/prototype-hooks.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,QAAQ,EAAE,MAAM,OAAO,CAAA;IACvB;;OAEG;IACH,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CAChC;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EACvC,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,GAC/C,IAAI,CAeN;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAC/B,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAC/B,IAAI,CAeN;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,GAAG,IAAI,CAUtF"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Wraps a prototype's method so it calls the earlier one with the same `this` and arguments, then, while active, runs
3
+ * the effect on its result, and returns the result. A missing prototype or method is skipped.
4
+ */
5
+ export function hookMethod(prototype, name, context, effect) {
6
+ const methods = prototype;
7
+ const previous = methods?.[name];
8
+ if (methods === undefined || typeof previous !== 'function') {
9
+ return;
10
+ }
11
+ methods[name] = function hooked(...args) {
12
+ const result = previous.apply(this, args);
13
+ runEffect(context, name, () => effect(this, result));
14
+ return result;
15
+ };
16
+ }
17
+ /**
18
+ * Wraps a prototype's accessor so its setter calls the earlier one, then, while active, runs the effect. A missing
19
+ * descriptor or setter is skipped.
20
+ */
21
+ export function hookSetter(prototype, name, context, effect) {
22
+ const descriptor = Object.getOwnPropertyDescriptor(prototype, name);
23
+ const previous = descriptor?.set;
24
+ if (descriptor === undefined || previous === undefined) {
25
+ return;
26
+ }
27
+ Object.defineProperty(prototype, name, {
28
+ ...descriptor,
29
+ set(value) {
30
+ previous.call(this, value);
31
+ runEffect(context, name, () => effect(this));
32
+ },
33
+ });
34
+ }
35
+ /**
36
+ * Runs the effect while active, reporting what it throws instead of throwing.
37
+ */
38
+ export function runEffect(context, name, effect) {
39
+ if (!context.isActive()) {
40
+ return;
41
+ }
42
+ try {
43
+ effect();
44
+ }
45
+ catch (error) {
46
+ context.warn(`visual-check: couldn't force states after ${name}: ${String(error)}`);
47
+ }
48
+ }
49
+ //# sourceMappingURL=prototype-hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prototype-hooks.js","sourceRoot":"","sources":["../../src/forced-state/prototype-hooks.ts"],"names":[],"mappings":"AAcA;;;GAGG;AACH,MAAM,UAAU,UAAU,CACxB,SAA6B,EAC7B,IAAY,EACZ,OAAoB,EACpB,MAAgD;IAEhD,MAAM,OAAO,GAAG,SAAgD,CAAA;IAChE,MAAM,QAAQ,GAAG,OAAO,EAAE,CAAC,IAAI,CAAC,CAAA;IAEhC,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;QAC5D,OAAM;IACR,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,GAA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@@ -0,0 +1,29 @@
1
+ import type { ForcedState } from './forced-states.js';
2
+ import { type SheetScope } from './twin-selectors.js';
3
+ /**
4
+ * What rewrites stylesheets for forced states, and remembers which rules and sheets it did, for which scope and states.
5
+ */
6
+ export interface StyleSheetRewriter {
7
+ /**
8
+ * Rewrites every style rule of the sheet, in grouping rules, nested rules and imported sheets too, unless already
9
+ * done for these states in this scope.
10
+ */
11
+ rewriteSheet(sheet: CSSStyleSheet, scope: SheetScope, states: ReadonlySet<ForcedState>): void;
12
+ /**
13
+ * Rewrites one rule and the rules in it, as after `insertRule`.
14
+ */
15
+ rewriteRule(rule: CSSRule, scope: SheetScope, states: ReadonlySet<ForcedState>): void;
16
+ /**
17
+ * Forgets the sheet was done, so the next `rewriteSheet` walks it again, as after `replaceSync` or a `<link>`'s load.
18
+ */
19
+ forgetSheet(sheet: CSSStyleSheet): void;
20
+ /**
21
+ * The scopes the sheet has been rewritten in so far: how an `insertRule` into a constructed sheet finds its scope.
22
+ */
23
+ scopesOf(sheet: CSSStyleSheet): ReadonlySet<SheetScope>;
24
+ }
25
+ /**
26
+ * A rewriter that reports through `warn`.
27
+ */
28
+ export declare function styleSheetRewriterOf(warn: (message: string) => void): StyleSheetRewriter;
29
+ //# sourceMappingURL=style-sheet-rewrite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style-sheet-rewrite.d.ts","sourceRoot":"","sources":["../../src/forced-state/style-sheet-rewrite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,KAAK,UAAU,EAAyB,MAAM,qBAAqB,CAAA;AAE5E;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,YAAY,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,CAAC,WAAW,CAAC,GAAG,IAAI,CAAA;IAC7F;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,CAAC,WAAW,CAAC,GAAG,IAAI,CAAA;IACrF;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAA;IACvC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,WAAW,CAAC,UAAU,CAAC,CAAA;CACxD;AAwDD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GAAG,kBAAkB,CAiBxF"}