foldkit-mixins 0.3.0 → 0.5.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.
- package/README.md +459 -10
- package/dist/app.d.mts +46 -0
- package/dist/app.d.mts.map +1 -0
- package/dist/app.mjs +45 -0
- package/dist/app.mjs.map +1 -0
- package/dist/core-Bxj0UQDF.mjs +53 -0
- package/dist/core-Bxj0UQDF.mjs.map +1 -0
- package/dist/core-CUw_n1Nd.d.mts +40 -0
- package/dist/core-CUw_n1Nd.d.mts.map +1 -0
- package/dist/defaults.d.mts +31 -0
- package/dist/defaults.d.mts.map +1 -0
- package/dist/defaults.mjs +75 -0
- package/dist/defaults.mjs.map +1 -0
- package/dist/foundations.d.mts +30 -0
- package/dist/foundations.d.mts.map +1 -0
- package/dist/foundations.mjs +71 -0
- package/dist/foundations.mjs.map +1 -0
- package/dist/index.d.mts +137 -536
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +261 -1017
- package/dist/index.mjs.map +1 -1
- package/dist/layers-B31M0tDi.mjs +193 -0
- package/dist/layers-B31M0tDi.mjs.map +1 -0
- package/dist/layers.d.mts +47 -0
- package/dist/layers.d.mts.map +1 -0
- package/dist/layers.mjs +2 -0
- package/dist/layout.d.mts +114 -0
- package/dist/layout.d.mts.map +1 -0
- package/dist/layout.mjs +154 -0
- package/dist/layout.mjs.map +1 -0
- package/dist/oklch-BxvCD0oi.d.mts +135 -0
- package/dist/oklch-BxvCD0oi.d.mts.map +1 -0
- package/dist/prose.d.mts +30 -0
- package/dist/prose.d.mts.map +1 -0
- package/dist/prose.mjs +61 -0
- package/dist/prose.mjs.map +1 -0
- package/dist/root-C1u12YMD.mjs +37 -0
- package/dist/root-C1u12YMD.mjs.map +1 -0
- package/dist/root-xyWS6geK.d.mts +25 -0
- package/dist/root-xyWS6geK.d.mts.map +1 -0
- package/dist/slotItem-D6_m6IqP.d.mts +18 -0
- package/dist/slotItem-D6_m6IqP.d.mts.map +1 -0
- package/dist/slotMark-Rdsjb7XI.mjs +135 -0
- package/dist/slotMark-Rdsjb7XI.mjs.map +1 -0
- package/dist/slotView-BtIF2pHo.d.mts +476 -0
- package/dist/slotView-BtIF2pHo.d.mts.map +1 -0
- package/dist/style-CKjLee4e.mjs +1266 -0
- package/dist/style-CKjLee4e.mjs.map +1 -0
- package/dist/style-CtCqaL0l.d.mts +182 -0
- package/dist/style-CtCqaL0l.d.mts.map +1 -0
- package/dist/styleValue-BavTe9MZ.d.mts +72 -0
- package/dist/styleValue-BavTe9MZ.d.mts.map +1 -0
- package/dist/styleValue-_G9jwb17.mjs +248 -0
- package/dist/styleValue-_G9jwb17.mjs.map +1 -0
- package/dist/testing.d.mts +30 -0
- package/dist/testing.d.mts.map +1 -0
- package/dist/testing.mjs +167 -0
- package/dist/testing.mjs.map +1 -0
- package/dist/theme.d.mts +193 -0
- package/dist/theme.d.mts.map +1 -0
- package/dist/theme.mjs +146 -0
- package/dist/theme.mjs.map +1 -0
- package/dist/tokens-BR_qxDR7.d.mts +91 -0
- package/dist/tokens-BR_qxDR7.d.mts.map +1 -0
- package/dist/tokens-DteBJVN-.mjs +117 -0
- package/dist/tokens-DteBJVN-.mjs.map +1 -0
- package/dist/utilities.d.mts +73 -0
- package/dist/utilities.d.mts.map +1 -0
- package/dist/utilities.mjs +90 -0
- package/dist/utilities.mjs.map +1 -0
- package/package.json +59 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root-C1u12YMD.mjs","names":[],"sources":["../src/theme/root.ts"],"sourcesContent":["/**\n * A theme's tokens as `:root` custom properties, for the page stylesheet.\n * Unlayered: the page decides which layer with `Layers.in`.\n */\nimport { global, type StyleValue } from '../styleValue.js'\nimport { VAR_PREFIX, type ThemeTokens } from './core.js'\n\nexport interface RootOptions {\n /** Tokens present in this theme are left out, so a scale shipped in another layer goes out once. */\n readonly omit?: ThemeTokens\n /** Default `'light dark'`, so `lightDark` tokens resolve. */\n readonly colorScheme?: 'light dark' | 'light' | 'dark'\n}\n\n/**\n * Every token as `--fk-group-name:value`, in authored order. `omit` is\n * matched token by token, not group by group: two themes can both carry a\n * `knob` group (the scales' density beside a palette's hues) and only the\n * names `omit` has are skipped.\n */\nconst declarations = (theme: ThemeTokens, omit?: ThemeTokens): ReadonlyArray<string> =>\n Object.entries(theme).flatMap(([group, names]) =>\n Object.entries(names).flatMap(([name, value]) =>\n omit !== undefined && Object.hasOwn(omit[group] ?? {}, name)\n ? []\n : [`${VAR_PREFIX}-${group}-${name}:${value}`],\n ),\n )\n\nexport const root = (theme: ThemeTokens, options?: RootOptions): StyleValue =>\n global(\n `:root{${[...declarations(theme, options?.omit), `color-scheme:${options?.colorScheme ?? 'light dark'}`].join(';')}}`,\n )\n\n/** Some of a theme's tokens, by the theme's own group and token names. */\nexport type Overrides<T extends ThemeTokens> = {\n readonly [G in keyof T]?: { readonly [N in keyof T[G]]?: string }\n}\n\n/**\n * Token overrides under `selector`: a named theme the Model selects with a\n * root attribute (`:root[data-theme=\"ocean\"]`), a scheme the user chose\n * (`:root[data-color-scheme=\"dark\"]`), or a subtree (`.marketing`). Which\n * one is active is the Model's fact; this only says what it means.\n *\n * `theme` is the theme being overridden and is read only for its type, so a\n * group or token it lacks is a type error rather than a variable nothing reads.\n */\nexport const scoped = <T extends ThemeTokens>(\n _theme: T,\n selector: string,\n overrides: Overrides<T>,\n): StyleValue => {\n const tokens: Record<string, Record<string, string>> = {}\n for (const [group, names] of Object.entries(overrides)) {\n const defined: Record<string, string> = {}\n for (const [name, value] of Object.entries(names ?? {})) {\n if (typeof value === 'string') defined[name] = value\n }\n tokens[group] = defined\n }\n return global(`${selector}{${declarations(tokens).join(';')}}`)\n}\n"],"mappings":";;;;;;;;;;;;;AAoBA,MAAM,gBAAgB,OAAoB,SACxC,OAAO,QAAQ,KAAK,CAAC,CAAC,SAAS,CAAC,OAAO,WACrC,OAAO,QAAQ,KAAK,CAAC,CAAC,SAAS,CAAC,MAAM,WACpC,SAAS,KAAA,KAAa,OAAO,OAAO,KAAK,UAAU,CAAC,GAAG,IAAI,IACvD,CAAC,IACD,CAAC,GAAG,WAAW,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,CAChD,CACF;AAEF,MAAa,QAAQ,OAAoB,YACvC,OACE,SAAS,CAAC,GAAG,aAAa,OAAO,SAAS,IAAI,GAAG,gBAAgB,SAAS,eAAe,cAAc,CAAC,CAAC,KAAK,GAAG,EAAE,EACrH;;;;;;;;;;AAgBF,MAAa,UACX,QACA,UACA,cACe;CACf,MAAM,SAAiD,CAAC;CACxD,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,SAAS,GAAG;EACtD,MAAM,UAAkC,CAAC;EACzC,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,SAAS,CAAC,CAAC,GACpD,IAAI,OAAO,UAAU,UAAU,QAAQ,QAAQ;EAEjD,OAAO,SAAS;CAClB;CACA,OAAO,OAAO,GAAG,SAAS,GAAG,aAAa,MAAM,CAAC,CAAC,KAAK,GAAG,EAAE,EAAE;AAChE"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { o as StyleValue } from "./styleValue-BavTe9MZ.mjs";
|
|
2
|
+
import { r as ThemeTokens } from "./core-CUw_n1Nd.mjs";
|
|
3
|
+
//#region src/theme/root.d.ts
|
|
4
|
+
interface RootOptions {
|
|
5
|
+
/** Tokens present in this theme are left out, so a scale shipped in another layer goes out once. */
|
|
6
|
+
readonly omit?: ThemeTokens;
|
|
7
|
+
/** Default `'light dark'`, so `lightDark` tokens resolve. */
|
|
8
|
+
readonly colorScheme?: 'light dark' | 'light' | 'dark';
|
|
9
|
+
}
|
|
10
|
+
declare const root: (theme: ThemeTokens, options?: RootOptions) => StyleValue;
|
|
11
|
+
/** Some of a theme's tokens, by the theme's own group and token names. */
|
|
12
|
+
type Overrides<T extends ThemeTokens> = { readonly [G in keyof T]?: { readonly [N in keyof T[G]]?: string; }; };
|
|
13
|
+
/**
|
|
14
|
+
* Token overrides under `selector`: a named theme the Model selects with a
|
|
15
|
+
* root attribute (`:root[data-theme="ocean"]`), a scheme the user chose
|
|
16
|
+
* (`:root[data-color-scheme="dark"]`), or a subtree (`.marketing`). Which
|
|
17
|
+
* one is active is the Model's fact; this only says what it means.
|
|
18
|
+
*
|
|
19
|
+
* `theme` is the theme being overridden and is read only for its type, so a
|
|
20
|
+
* group or token it lacks is a type error rather than a variable nothing reads.
|
|
21
|
+
*/
|
|
22
|
+
declare const scoped: <T extends ThemeTokens>(_theme: T, selector: string, overrides: Overrides<T>) => StyleValue;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { scoped as i, RootOptions as n, root as r, Overrides as t };
|
|
25
|
+
//# sourceMappingURL=root-xyWS6geK.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root-xyWS6geK.d.mts","names":[],"sources":["../src/theme/root.ts"],"mappings":";;;UAOiB;;WAEN,OAAO;;WAEP;;cAkBE,OAAQ,OAAO,aAAa,UAAU,gBAAc;;KAMrD,UAAU,UAAU,2BACpB,WAAW,iBAAiB,WAAW,EAAE;;;;;;;;;;cAYxC,SAAU,UAAU,aAC/B,QAAQ,GACR,kBACA,WAAW,UAAU,OACpB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/slotItem.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Which repetition of a slot is being resolved, when a view renders one slot
|
|
4
|
+
* once per item (rows, tabs, options). The view passes it as the second
|
|
5
|
+
* argument of `slots.x.attrs(base, item)`; a Behavior reads it to write
|
|
6
|
+
* per-item attributes such as `tabindex`, `aria-posinset`, or an id, and a
|
|
7
|
+
* `Style.perItem` piece reads it for appearance.
|
|
8
|
+
*/
|
|
9
|
+
interface SlotItem {
|
|
10
|
+
readonly index: number;
|
|
11
|
+
/** The item's stable identity, when it has one: a row id, an option value. */
|
|
12
|
+
readonly id?: string;
|
|
13
|
+
/** How many items the slot renders, when the view knows. */
|
|
14
|
+
readonly count?: number;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { SlotItem as t };
|
|
18
|
+
//# sourceMappingURL=slotItem-D6_m6IqP.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slotItem-D6_m6IqP.d.mts","names":[],"sources":["../src/slotItem.ts"],"mappings":";;;;;;;;UAOiB;WACN;;WAEA;;WAEA"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { r as standard } from "./layers-B31M0tDi.mjs";
|
|
2
|
+
//#region src/inject.ts
|
|
3
|
+
/**
|
|
4
|
+
* Styles that arrive with what uses them. Compiling a Style registers each
|
|
5
|
+
* class it produces with that class's CSS; the name is a hash of the CSS, so
|
|
6
|
+
* the registry is the same on the server and in the browser, and holds no DOM.
|
|
7
|
+
*
|
|
8
|
+
* When a Slot draws a class in a browser, the CSS is queued, and one microtask
|
|
9
|
+
* later (after the patch, before the browser paints) appended to a single
|
|
10
|
+
* `<style data-foldkit-styles>` element, unless a stylesheet on the page
|
|
11
|
+
* already carries the class: a static sheet and injection never repeat each
|
|
12
|
+
* other.
|
|
13
|
+
*
|
|
14
|
+
* The registry holds every class compiled in the process and never lets one
|
|
15
|
+
* go, which is bounded by the code when Styles are defined once, as they are
|
|
16
|
+
* meant to be. A Style compiled during a render from data (a width from the
|
|
17
|
+
* Model) would register a class per value; such a value belongs in an inline
|
|
18
|
+
* custom property read by a rule instead.
|
|
19
|
+
*/
|
|
20
|
+
const registry = /* @__PURE__ */ new Map();
|
|
21
|
+
/** Records the CSS a compiled class stands for. Called by the compiler. */
|
|
22
|
+
const register = (className, css) => {
|
|
23
|
+
if (!registry.has(className)) registry.set(className, css);
|
|
24
|
+
};
|
|
25
|
+
/** A compiled class in CSS text: `.style-` and its hash. */
|
|
26
|
+
const COMPILED_CLASS = /\.(style-[0-9a-z]+)/g;
|
|
27
|
+
/** An `@layer` order statement, as opposed to a layer block. */
|
|
28
|
+
const LAYER_STATEMENT = /@layer [^{};]+;/g;
|
|
29
|
+
/** The standard layer order, as one `@layer` statement. */
|
|
30
|
+
const layerOrder = () => standard.declare.globalCss?.join("") ?? "";
|
|
31
|
+
/**
|
|
32
|
+
* The CSS for every compiled class that `html` carries, after the standard
|
|
33
|
+
* layer order: what a server puts in a page's head, so it is styled before
|
|
34
|
+
* any script runs. The browser's injection then finds these classes present
|
|
35
|
+
* and adds nothing twice.
|
|
36
|
+
*/
|
|
37
|
+
const usedIn = (html) => {
|
|
38
|
+
const found = /* @__PURE__ */ new Set();
|
|
39
|
+
for (const [className] of html.matchAll(/style-[0-9a-z]+/g)) if (registry.has(className)) found.add(className);
|
|
40
|
+
return [layerOrder(), ...[...found].map((className) => registry.get(className) ?? "")].join("");
|
|
41
|
+
};
|
|
42
|
+
let page;
|
|
43
|
+
let pending = [];
|
|
44
|
+
let scheduled = false;
|
|
45
|
+
/**
|
|
46
|
+
* The page as injection knows it, counted afresh when a sheet it counted or its
|
|
47
|
+
* own element has been removed (by a test's cleanup, or an application
|
|
48
|
+
* replacing the head).
|
|
49
|
+
*/
|
|
50
|
+
const current = () => {
|
|
51
|
+
if (page !== void 0 && (page.element === void 0 || page.element.isConnected) && page.counted.every((sheet) => sheet.isConnected)) return page;
|
|
52
|
+
const present = /* @__PURE__ */ new Set();
|
|
53
|
+
let ordered = false;
|
|
54
|
+
const counted = Array.from(document.querySelectorAll("style"));
|
|
55
|
+
for (const sheet of counted) {
|
|
56
|
+
const text = sheet.textContent ?? "";
|
|
57
|
+
for (const [, className] of text.matchAll(COMPILED_CLASS)) if (className !== void 0) present.add(className);
|
|
58
|
+
if (text.match(LAYER_STATEMENT) !== null) ordered = true;
|
|
59
|
+
}
|
|
60
|
+
page = {
|
|
61
|
+
present,
|
|
62
|
+
globals: /* @__PURE__ */ new Set(),
|
|
63
|
+
handled: /* @__PURE__ */ new WeakSet(),
|
|
64
|
+
ordered,
|
|
65
|
+
counted,
|
|
66
|
+
element: void 0
|
|
67
|
+
};
|
|
68
|
+
return page;
|
|
69
|
+
};
|
|
70
|
+
const flush = () => {
|
|
71
|
+
scheduled = false;
|
|
72
|
+
if (pending.length === 0) return;
|
|
73
|
+
const into = current();
|
|
74
|
+
if (into.element === void 0) {
|
|
75
|
+
const element = document.createElement("style");
|
|
76
|
+
element.setAttribute("data-foldkit-styles", "");
|
|
77
|
+
element.textContent = into.ordered ? "" : layerOrder();
|
|
78
|
+
document.head.appendChild(element);
|
|
79
|
+
into.element = element;
|
|
80
|
+
}
|
|
81
|
+
into.element.appendChild(document.createTextNode(pending.join("")));
|
|
82
|
+
pending = [];
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Queues the CSS of each registered class a contribution draws that the page
|
|
86
|
+
* does not carry yet, and its global CSS (keyframes, a theme root) once.
|
|
87
|
+
* Outside a browser it does nothing: a server extracts what it rendered instead.
|
|
88
|
+
*/
|
|
89
|
+
const ensure = (contribution) => {
|
|
90
|
+
if (typeof document === "undefined") return;
|
|
91
|
+
const into = current();
|
|
92
|
+
if (into.handled.has(contribution)) return;
|
|
93
|
+
for (const className of contribution.classes ?? []) {
|
|
94
|
+
if (into.present.has(className)) continue;
|
|
95
|
+
const css = registry.get(className);
|
|
96
|
+
if (css === void 0) continue;
|
|
97
|
+
into.present.add(className);
|
|
98
|
+
pending.push(css);
|
|
99
|
+
}
|
|
100
|
+
const globalCss = contribution.globalCss;
|
|
101
|
+
if (globalCss !== void 0 && globalCss !== "" && !into.globals.has(globalCss)) {
|
|
102
|
+
into.globals.add(globalCss);
|
|
103
|
+
pending.push(globalCss.replace(LAYER_STATEMENT, ""));
|
|
104
|
+
}
|
|
105
|
+
if (Object.isFrozen(contribution)) into.handled.add(contribution);
|
|
106
|
+
if (pending.length > 0 && !scheduled) {
|
|
107
|
+
scheduled = true;
|
|
108
|
+
queueMicrotask(flush);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/slotMark.ts
|
|
113
|
+
/**
|
|
114
|
+
* Marking the elements Slots draw with the Slot's name, for
|
|
115
|
+
* `foldkit-mixins/testing`'s `Inert.draw`. Internal: the package index does not
|
|
116
|
+
* export it, and a view drawn for real is never marked.
|
|
117
|
+
*/
|
|
118
|
+
/** The data attribute a marked element carries: `data-fk-slot="row"`. */
|
|
119
|
+
const SLOT_MARK = "fk-slot";
|
|
120
|
+
let marking = false;
|
|
121
|
+
/** Whether Slots mark what they draw: only while `drawMarked` runs. */
|
|
122
|
+
const isMarking = () => marking;
|
|
123
|
+
/** Draws with every Slot, however deeply nested its view, marking its element. */
|
|
124
|
+
const drawMarked = (draw) => {
|
|
125
|
+
marking = true;
|
|
126
|
+
try {
|
|
127
|
+
return draw();
|
|
128
|
+
} finally {
|
|
129
|
+
marking = false;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
//#endregion
|
|
133
|
+
export { register as a, ensure as i, drawMarked as n, usedIn as o, isMarking as r, SLOT_MARK as t };
|
|
134
|
+
|
|
135
|
+
//# sourceMappingURL=slotMark-Rdsjb7XI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slotMark-Rdsjb7XI.mjs","names":[],"sources":["../src/inject.ts","../src/slotMark.ts"],"sourcesContent":["/**\n * Styles that arrive with what uses them. Compiling a Style registers each\n * class it produces with that class's CSS; the name is a hash of the CSS, so\n * the registry is the same on the server and in the browser, and holds no DOM.\n *\n * When a Slot draws a class in a browser, the CSS is queued, and one microtask\n * later (after the patch, before the browser paints) appended to a single\n * `<style data-foldkit-styles>` element, unless a stylesheet on the page\n * already carries the class: a static sheet and injection never repeat each\n * other.\n *\n * The registry holds every class compiled in the process and never lets one\n * go, which is bounded by the code when Styles are defined once, as they are\n * meant to be. A Style compiled during a render from data (a width from the\n * Model) would register a class per value; such a value belongs in an inline\n * custom property read by a rule instead.\n */\nimport { standard } from './layers.js'\n\nconst registry = new Map<string, string>()\n\n/** Records the CSS a compiled class stands for. Called by the compiler. */\nexport const register = (className: string, css: string): void => {\n if (!registry.has(className)) registry.set(className, css)\n}\n\n/** A compiled class in CSS text: `.style-` and its hash. */\nconst COMPILED_CLASS = /\\.(style-[0-9a-z]+)/g\n\n/** An `@layer` order statement, as opposed to a layer block. */\nconst LAYER_STATEMENT = /@layer [^{};]+;/g\n\n/** The standard layer order, as one `@layer` statement. */\nconst layerOrder = (): string => standard.declare.globalCss?.join('') ?? ''\n\n/**\n * The CSS for every compiled class that `html` carries, after the standard\n * layer order: what a server puts in a page's head, so it is styled before\n * any script runs. The browser's injection then finds these classes present\n * and adds nothing twice.\n */\nexport const usedIn = (html: string): string => {\n const found = new Set<string>()\n for (const [className] of html.matchAll(/style-[0-9a-z]+/g)) {\n if (registry.has(className)) found.add(className)\n }\n return [layerOrder(), ...[...found].map(className => registry.get(className) ?? '')].join('')\n}\n\n/** What the page carries: counted from its sheets once, then kept as CSS is queued. */\ninterface Page {\n readonly present: Set<string>\n readonly globals: Set<string>\n /** Contributions already handled whole: a Style's are the same object every render. */\n readonly handled: WeakSet<object>\n /** Whether a sheet on the page declares a layer order, so this one need not. */\n readonly ordered: boolean\n /** The sheets counted, so a removed one means counting again. */\n readonly counted: ReadonlyArray<HTMLStyleElement>\n element: HTMLStyleElement | undefined\n}\n\nlet page: Page | undefined\nlet pending: Array<string> = []\nlet scheduled = false\n\n/**\n * The page as injection knows it, counted afresh when a sheet it counted or its\n * own element has been removed (by a test's cleanup, or an application\n * replacing the head).\n */\nconst current = (): Page => {\n if (\n page !== undefined &&\n (page.element === undefined || page.element.isConnected) &&\n page.counted.every(sheet => sheet.isConnected)\n )\n return page\n const present = new Set<string>()\n let ordered = false\n const counted = Array.from(document.querySelectorAll('style'))\n for (const sheet of counted) {\n const text = sheet.textContent ?? ''\n for (const [, className] of text.matchAll(COMPILED_CLASS))\n if (className !== undefined) present.add(className)\n if (text.match(LAYER_STATEMENT) !== null) ordered = true\n }\n page = {\n present,\n globals: new Set(),\n handled: new WeakSet(),\n ordered,\n counted,\n element: undefined,\n }\n return page\n}\n\nconst flush = (): void => {\n scheduled = false\n if (pending.length === 0) return\n const into = current()\n if (into.element === undefined) {\n const element = document.createElement('style')\n element.setAttribute('data-foldkit-styles', '')\n // Without an order on the page, the standard one first, so rules inserted\n // in any order still cascade by layer; an application's own order is left alone.\n element.textContent = into.ordered ? '' : layerOrder()\n document.head.appendChild(element)\n into.element = element\n }\n into.element.appendChild(document.createTextNode(pending.join('')))\n pending = []\n}\n\n/**\n * Queues the CSS of each registered class a contribution draws that the page\n * does not carry yet, and its global CSS (keyframes, a theme root) once.\n * Outside a browser it does nothing: a server extracts what it rendered instead.\n */\nexport const ensure = (contribution: {\n readonly classes?: ReadonlyArray<string>\n readonly globalCss?: string\n}): void => {\n if (typeof document === 'undefined') return\n const into = current()\n if (into.handled.has(contribution)) return\n for (const className of contribution.classes ?? []) {\n if (into.present.has(className)) continue\n const css = registry.get(className)\n if (css === undefined) continue\n into.present.add(className)\n pending.push(css)\n }\n const globalCss = contribution.globalCss\n // A layer order is the page's to declare, so a Style's own is not repeated.\n if (globalCss !== undefined && globalCss !== '' && !into.globals.has(globalCss)) {\n into.globals.add(globalCss)\n pending.push(globalCss.replace(LAYER_STATEMENT, ''))\n }\n // Frozen, a contribution cannot draw other classes next time it is drawn.\n if (Object.isFrozen(contribution)) into.handled.add(contribution)\n if (pending.length > 0 && !scheduled) {\n scheduled = true\n queueMicrotask(flush)\n }\n}\n","/**\n * Marking the elements Slots draw with the Slot's name, for\n * `foldkit-mixins/testing`'s `Inert.draw`. Internal: the package index does not\n * export it, and a view drawn for real is never marked.\n */\n\n/** The data attribute a marked element carries: `data-fk-slot=\"row\"`. */\nexport const SLOT_MARK = 'fk-slot'\n\nlet marking = false\n\n/** Whether Slots mark what they draw: only while `drawMarked` runs. */\nexport const isMarking = (): boolean => marking\n\n/** Draws with every Slot, however deeply nested its view, marking its element. */\nexport const drawMarked = <A>(draw: () => A): A => {\n marking = true\n try {\n return draw()\n } finally {\n marking = false\n }\n}\n"],"mappings":";;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