stillwind 0.0.0 → 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.
- package/AGENTS_TEMPLATE.md +5 -0
- package/LICENSE +21 -0
- package/README.md +166 -0
- package/TAILWINDCSS-MIT-LICENSE +21 -0
- package/css/builtin-metadata/sw-motion-properties.css +186 -0
- package/css/builtin-metadata/tw-legacy-metadata.css +36 -0
- package/css/builtin-metadata/tw-properties.css +944 -0
- package/css/builtin-metadata/tw-registry-metadata.css +52 -0
- package/css/builtin-metadata/tw-relationship-metadata.css +10 -0
- package/css/builtin-utilities/sw-motion-contexts.css +1043 -0
- package/css/builtin-utilities/tw-backgrounds.css +606 -0
- package/css/builtin-utilities/tw-borders.css +954 -0
- package/css/builtin-utilities/tw-effects.css +1209 -0
- package/css/builtin-utilities/tw-flex-grid.css +749 -0
- package/css/builtin-utilities/tw-interactivity.css +680 -0
- package/css/builtin-utilities/tw-layout.css +943 -0
- package/css/builtin-utilities/tw-masks.css +1268 -0
- package/css/builtin-utilities/tw-motion.css +142 -0
- package/css/builtin-utilities/tw-spacing-sizing.css +621 -0
- package/css/builtin-utilities/tw-svg.css +50 -0
- package/css/builtin-utilities/tw-transforms.css +652 -0
- package/css/builtin-utilities/tw-typography.css +720 -0
- package/css/builtin-variants/sw-conditional.css +5 -0
- package/css/builtin-variants/sw-document.css +13 -0
- package/css/builtin-variants/tw-conditional.css +187 -0
- package/css/builtin-variants/tw-dynamic-selector.css +49 -0
- package/css/builtin-variants/tw-relationship.css +41 -0
- package/css/builtin-variants/tw-state.css +159 -0
- package/css/builtin-variants/tw-structural.css +121 -0
- package/css/builtins.css +111 -0
- package/css/preflight.css +401 -0
- package/css/templates.css +40 -0
- package/css/theme.css +546 -0
- package/css/utilities.css +9 -0
- package/dist/class-object-D24FFYqO.js +6 -0
- package/dist/class-object-D24FFYqO.js.map +1 -0
- package/dist/class-object-D7ZGJOf_.d.ts +9 -0
- package/dist/class-string-CQHnc9GN.d.ts +9 -0
- package/dist/class-string-Db8-oI4q.js +6 -0
- package/dist/class-string-Db8-oI4q.js.map +1 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.js +2 -0
- package/dist/css.d.ts +100 -0
- package/dist/css.js +143 -0
- package/dist/css.js.map +1 -0
- package/dist/cva-BwX07CFw.js +204 -0
- package/dist/cva-BwX07CFw.js.map +1 -0
- package/dist/cva-DSpDNBYi.d.ts +9 -0
- package/dist/development-DttPQc71.d.ts +27 -0
- package/dist/development-J-JCSIm0.js +111 -0
- package/dist/development-J-JCSIm0.js.map +1 -0
- package/dist/frameworks/alpine.d.ts +20 -0
- package/dist/frameworks/alpine.js +18 -0
- package/dist/frameworks/alpine.js.map +1 -0
- package/dist/frameworks/astro.d.ts +3 -0
- package/dist/frameworks/astro.js +1 -0
- package/dist/frameworks/lit.d.ts +21 -0
- package/dist/frameworks/lit.js +38 -0
- package/dist/frameworks/lit.js.map +1 -0
- package/dist/frameworks/preact.d.ts +3 -0
- package/dist/frameworks/preact.js +1 -0
- package/dist/frameworks/qwik.d.ts +3 -0
- package/dist/frameworks/qwik.js +1 -0
- package/dist/frameworks/react.d.ts +10 -0
- package/dist/frameworks/react.js +6 -0
- package/dist/frameworks/react.js.map +1 -0
- package/dist/frameworks/solid.d.ts +3 -0
- package/dist/frameworks/solid.js +1 -0
- package/dist/frameworks/svelte.d.ts +3 -0
- package/dist/frameworks/svelte.js +1 -0
- package/dist/frameworks/vanilla.d.ts +27 -0
- package/dist/frameworks/vanilla.js +3 -0
- package/dist/frameworks/vue.d.ts +3 -0
- package/dist/frameworks/vue.js +1 -0
- package/dist/index-RwVFpxhE.d.ts +815 -0
- package/dist/macro/index.d.ts +2 -0
- package/dist/macro/index.js +1 -0
- package/dist/module-css.d.ts +30 -0
- package/dist/module-css.js +23 -0
- package/dist/module-css.js.map +1 -0
- package/dist/runtime/class-name-object-development.d.ts +10 -0
- package/dist/runtime/class-name-object-development.js +18 -0
- package/dist/runtime/class-name-object-development.js.map +1 -0
- package/dist/runtime/class-name-object.d.ts +16 -0
- package/dist/runtime/class-name-object.js +31 -0
- package/dist/runtime/class-name-object.js.map +1 -0
- package/dist/runtime/class-object-development.d.ts +10 -0
- package/dist/runtime/class-object-development.js +18 -0
- package/dist/runtime/class-object-development.js.map +1 -0
- package/dist/runtime/class-object.d.ts +16 -0
- package/dist/runtime/class-object.js +31 -0
- package/dist/runtime/class-object.js.map +1 -0
- package/dist/runtime/class-string-development.d.ts +10 -0
- package/dist/runtime/class-string-development.js +18 -0
- package/dist/runtime/class-string-development.js.map +1 -0
- package/dist/runtime/class-string.d.ts +16 -0
- package/dist/runtime/class-string.js +31 -0
- package/dist/runtime/class-string.js.map +1 -0
- package/dist/shared-B9IQXU6P.d.ts +32 -0
- package/dist/style-BV4ctkni.js +78 -0
- package/dist/style-BV4ctkni.js.map +1 -0
- package/dist/style-fTQbsVWZ.js +41 -0
- package/dist/style-fTQbsVWZ.js.map +1 -0
- package/docs/agents.md +76 -0
- package/docs/at-rules/apply.md +93 -0
- package/docs/at-rules/custom-variant.md +127 -0
- package/docs/at-rules/index.md +75 -0
- package/docs/at-rules/plugin.md +71 -0
- package/docs/at-rules/registry-directives.md +181 -0
- package/docs/at-rules/slot.md +58 -0
- package/docs/at-rules/stillwind-css-template.md +126 -0
- package/docs/at-rules/stillwind-property.md +133 -0
- package/docs/at-rules/stillwind-registry.md +115 -0
- package/docs/at-rules/stillwind-require-properties.md +91 -0
- package/docs/at-rules/stillwind-slot.md +85 -0
- package/docs/at-rules/stillwind-undef-arbitrary-property.md +75 -0
- package/docs/at-rules/stillwind-undef-utility.md +87 -0
- package/docs/at-rules/stillwind-undef-variant.md +55 -0
- package/docs/at-rules/theme.md +304 -0
- package/docs/at-rules/utility.md +286 -0
- package/docs/at-rules/variant.md +91 -0
- package/docs/concepts/css-ordering.md +245 -0
- package/docs/concepts/how-styles-compile.md +132 -0
- package/docs/configuration.md +298 -0
- package/docs/errors/SW01001.md +51 -0
- package/docs/errors/SW01002.md +52 -0
- package/docs/errors/SW01003.md +69 -0
- package/docs/errors/SW02001.md +23 -0
- package/docs/errors/SW02002.md +51 -0
- package/docs/errors/SW03001.md +71 -0
- package/docs/errors/SW03002.md +79 -0
- package/docs/errors/SW03003.md +36 -0
- package/docs/errors/SW10001.md +34 -0
- package/docs/errors/SW10002.md +36 -0
- package/docs/errors/SW10003.md +30 -0
- package/docs/errors/SW10004.md +39 -0
- package/docs/errors/SW10005.md +35 -0
- package/docs/errors/SW11001.md +37 -0
- package/docs/errors/SW11002.md +65 -0
- package/docs/errors/SW11003.md +20 -0
- package/docs/errors/SW12001.md +43 -0
- package/docs/errors/SW12002.md +42 -0
- package/docs/errors/SW13001.md +35 -0
- package/docs/errors/SW13002.md +33 -0
- package/docs/errors/SW13003.md +18 -0
- package/docs/errors/SW13004.md +45 -0
- package/docs/errors/SW14001.md +44 -0
- package/docs/errors/SW14002.md +47 -0
- package/docs/errors/SW14003.md +38 -0
- package/docs/errors/SW14004.md +48 -0
- package/docs/errors/SW14005.md +51 -0
- package/docs/errors/SW14006.md +19 -0
- package/docs/errors/SW14007.md +35 -0
- package/docs/errors/SW14008.md +41 -0
- package/docs/errors/SW15001.md +18 -0
- package/docs/errors/SW15002.md +19 -0
- package/docs/errors/SW15003.md +16 -0
- package/docs/errors/SW30001.md +21 -0
- package/docs/errors/SW30002.md +18 -0
- package/docs/errors/SW30003.md +17 -0
- package/docs/errors/SW30004.md +18 -0
- package/docs/errors/SW31001.md +20 -0
- package/docs/errors/SW31002.md +17 -0
- package/docs/errors/SW31003.md +18 -0
- package/docs/errors/SW31004.md +20 -0
- package/docs/errors/SW31005.md +18 -0
- package/docs/errors/SW31006.md +17 -0
- package/docs/errors/SW31007.md +18 -0
- package/docs/errors/SW31008.md +16 -0
- package/docs/errors/SW31009.md +18 -0
- package/docs/errors/SW31010.md +16 -0
- package/docs/errors/SW31011.md +17 -0
- package/docs/errors/SW32001.md +18 -0
- package/docs/errors/SW32002.md +45 -0
- package/docs/errors/SW32003.md +43 -0
- package/docs/errors/SW32004.md +17 -0
- package/docs/errors/SW32005.md +40 -0
- package/docs/errors/SW32006.md +18 -0
- package/docs/errors/SW32007.md +20 -0
- package/docs/errors/SW33001.md +17 -0
- package/docs/errors/SW33002.md +17 -0
- package/docs/errors/SW33003.md +17 -0
- package/docs/errors/SW33004.md +17 -0
- package/docs/errors/SW33005.md +20 -0
- package/docs/errors/SW34001.md +18 -0
- package/docs/errors/SW34002.md +17 -0
- package/docs/errors/SW34003.md +18 -0
- package/docs/errors/SW90001.md +17 -0
- package/docs/errors/SW90002.md +18 -0
- package/docs/errors/SW90003.md +17 -0
- package/docs/errors/SW90004.md +17 -0
- package/docs/errors/SW90005.md +16 -0
- package/docs/errors/SW90006.md +17 -0
- package/docs/errors/SW90007.md +17 -0
- package/docs/errors/SW90008.md +17 -0
- package/docs/errors/index.md +125 -0
- package/docs/guides/animations.md +73 -0
- package/docs/guides/design-systems.md +119 -0
- package/docs/guides/element-relationships.md +136 -0
- package/docs/guides/lint-adoption.md +128 -0
- package/docs/guides/migrating-from-css.md +126 -0
- package/docs/guides/migrating-from-tailwind.md +179 -0
- package/docs/guides/recommended-practices.md +338 -0
- package/docs/guides/responsive-styles.md +103 -0
- package/docs/guides/reusable-styles.md +110 -0
- package/docs/guides/style.md +181 -0
- package/docs/guides/tailwind-compatibility.md +126 -0
- package/docs/guides/view-transitions.md +84 -0
- package/docs/guides/web-components.md +216 -0
- package/docs/index.md +136 -0
- package/docs/integrations.md +190 -0
- package/docs/lints/ambiguous-style-base-order.md +50 -0
- package/docs/lints/bypassed-undefinition.md +50 -0
- package/docs/lints/clamped-value.md +44 -0
- package/docs/lints/conflicting-provider-properties.md +47 -0
- package/docs/lints/conflicting-utilities.md +55 -0
- package/docs/lints/document-scoped-selector.md +45 -0
- package/docs/lints/duplicate-definition.md +44 -0
- package/docs/lints/duplicate-utility.md +44 -0
- package/docs/lints/duplicate-view-transition-name.md +45 -0
- package/docs/lints/ignored-definition-condition.md +51 -0
- package/docs/lints/ignored-tailwind-feature.md +62 -0
- package/docs/lints/incompatible-property-value.md +60 -0
- package/docs/lints/incompatible-theme-value.md +46 -0
- package/docs/lints/index.md +140 -0
- package/docs/lints/ineffective-anchor-scope.md +46 -0
- package/docs/lints/interfering-imported-style-base.md +57 -0
- package/docs/lints/invalid-animation-option.md +47 -0
- package/docs/lints/invalid-css-directive.md +43 -0
- package/docs/lints/invalid-css-import.md +43 -0
- package/docs/lints/invalid-css-input.md +45 -0
- package/docs/lints/invalid-cva-config.md +46 -0
- package/docs/lints/invalid-cva-input.md +50 -0
- package/docs/lints/invalid-keyframes-definition.md +47 -0
- package/docs/lints/invalid-keyframes-use.md +47 -0
- package/docs/lints/invalid-keyframes-variant.md +48 -0
- package/docs/lints/invalid-lint-suppression.md +47 -0
- package/docs/lints/invalid-marker-use.md +53 -0
- package/docs/lints/invalid-media-query.md +52 -0
- package/docs/lints/invalid-ref-input.md +49 -0
- package/docs/lints/invalid-rule-group-input.md +58 -0
- package/docs/lints/invalid-runtime-condition.md +67 -0
- package/docs/lints/invalid-style-composition.md +52 -0
- package/docs/lints/invalid-style-input.md +47 -0
- package/docs/lints/invalid-theme-reference.md +52 -0
- package/docs/lints/invalid-utility.md +44 -0
- package/docs/lints/invalid-variant.md +45 -0
- package/docs/lints/invalid-view-transition-definition.md +46 -0
- package/docs/lints/invalid-view-transition-use.md +46 -0
- package/docs/lints/invalid-view-transition-variant.md +51 -0
- package/docs/lints/mismatched-framework-import.md +47 -0
- package/docs/lints/missing-document-target.md +44 -0
- package/docs/lints/missing-ref-attachment.md +44 -0
- package/docs/lints/missing-view-transition-name.md +46 -0
- package/docs/lints/mutating-macro-argument.md +48 -0
- package/docs/lints/no-arbitrary-breakpoints.md +50 -0
- package/docs/lints/no-arbitrary-colors.md +51 -0
- package/docs/lints/no-arbitrary-spacing.md +57 -0
- package/docs/lints/no-class-property.md +58 -0
- package/docs/lints/no-important.md +50 -0
- package/docs/lints/no-restricted-declarations.md +76 -0
- package/docs/lints/no-restricted-length-units.md +73 -0
- package/docs/lints/no-restricted-theme-tokens.md +73 -0
- package/docs/lints/no-restricted-utilities.md +73 -0
- package/docs/lints/prefer-canonical-utilities.md +69 -0
- package/docs/lints/prefer-direct-styling.md +47 -0
- package/docs/lints/prefer-explicit-nesting-selector.md +42 -0
- package/docs/lints/prefer-logical-properties.md +49 -0
- package/docs/lints/prefer-sorted-utilities.md +46 -0
- package/docs/lints/prefer-typed-relationships.md +48 -0
- package/docs/lints/prefer-typed-variables.md +43 -0
- package/docs/lints/prefer-variant-directive.md +59 -0
- package/docs/lints/redundant-variant.md +50 -0
- package/docs/lints/repeated-nesting-selector.md +59 -0
- package/docs/lints/runtime-condition-requires-css-if.md +59 -0
- package/docs/lints/split-view-transition-class.md +47 -0
- package/docs/lints/suspending-macro-argument.md +46 -0
- package/docs/lints/unknown-utility.md +47 -0
- package/docs/lints/unknown-variant.md +42 -0
- package/docs/lints/unsatisfiable-variants.md +42 -0
- package/docs/lints/unused-lint-suppression.md +57 -0
- package/docs/lints/unverified-style-base.md +64 -0
- package/docs/macros/anchor-scope.md +90 -0
- package/docs/macros/css.md +68 -0
- package/docs/macros/cva.md +153 -0
- package/docs/macros/index.md +30 -0
- package/docs/macros/keyframes.md +98 -0
- package/docs/macros/media.md +65 -0
- package/docs/macros/ref/as-anchor.md +70 -0
- package/docs/macros/ref/as-container.md +64 -0
- package/docs/macros/ref/at.md +68 -0
- package/docs/macros/ref/condition.md +86 -0
- package/docs/macros/ref/in.md +81 -0
- package/docs/macros/ref/index.md +115 -0
- package/docs/macros/ref/position-anchor.md +64 -0
- package/docs/macros/style.md +185 -0
- package/docs/macros/view-transition.md +159 -0
- package/docs/utilities.md +35 -0
- package/docs/why.md +144 -0
- package/index.css +7 -0
- package/package.json +135 -8
- package/skills/migrate-to-stillwind/SKILL.md +81 -0
- package/skills/setup-stillwind/SKILL.md +51 -0
- package/skills/stillwind/SKILL.md +54 -0
- package/index.js +0 -1
package/dist/css.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { CssPart } from "./module-css.js";
|
|
2
|
+
/**
|
|
3
|
+
* Creates or reuses constructed sheets in the supplied document's Window.
|
|
4
|
+
*
|
|
5
|
+
* Updating a cached part creates a new sheet. Callers must adopt the returned sheets to apply it.
|
|
6
|
+
*
|
|
7
|
+
* @param parts - Ordered CSS parts. A part reuses the cached sheet for its key only when its CSS
|
|
8
|
+
* matches the cached text.
|
|
9
|
+
* @param document - Target document whose Window provides `CSSStyleSheet` and `replaceSync`.
|
|
10
|
+
* @returns One sheet per input part, in input order, without adopting them into the document.
|
|
11
|
+
* @throws If the document has no Window or constructing or parsing a stylesheet fails.
|
|
12
|
+
*/
|
|
13
|
+
export declare function styleSheets(parts: readonly CssPart[], document: Document): CSSStyleSheet[];
|
|
14
|
+
/**
|
|
15
|
+
* Concatenates CSS bodies in occurrence order and adds their notices once before the result.
|
|
16
|
+
*
|
|
17
|
+
* Repeated occurrences remain, and no separators are added between bodies. When the combined
|
|
18
|
+
* body ends with an inline base64 source map, as development fragments do, the map is shifted
|
|
19
|
+
* by the lines that the notices add.
|
|
20
|
+
*
|
|
21
|
+
* @param parts - CSS parts in the order required by the cascade.
|
|
22
|
+
* @returns The combined stylesheet text, or an empty string when every body is blank.
|
|
23
|
+
* @throws If the inline source map is not valid JSON.
|
|
24
|
+
*/
|
|
25
|
+
export declare function cssText<Part extends Pick<CssPart, "css" | "banners">>(parts: readonly Part[]): string;
|
|
26
|
+
/** Build manifest that maps producer modules to stylesheet occurrences in cascade order. */
|
|
27
|
+
export interface StylesheetManifest {
|
|
28
|
+
/** Manifest format version. The supported shape uses version 1. */
|
|
29
|
+
readonly version: 1;
|
|
30
|
+
/**
|
|
31
|
+
* Build revision identifying the manifest. Link selection and loading do not compare this value.
|
|
32
|
+
*/
|
|
33
|
+
readonly revision: string;
|
|
34
|
+
/**
|
|
35
|
+
* Stylesheet occurrences in cascade order. Each occurrence has a distinct ID even when URLs
|
|
36
|
+
* repeat.
|
|
37
|
+
*/
|
|
38
|
+
readonly parts: readonly {
|
|
39
|
+
/**
|
|
40
|
+
* Unique occurrence identity used by module selections and `data-stillwind-part` attributes.
|
|
41
|
+
*/
|
|
42
|
+
readonly id: string;
|
|
43
|
+
/**
|
|
44
|
+
* Stylesheet URL assigned to a link element. Relative URLs resolve against the target document.
|
|
45
|
+
*/
|
|
46
|
+
readonly href: string;
|
|
47
|
+
}[];
|
|
48
|
+
/**
|
|
49
|
+
* Producer module identities mapped to occurrence IDs from `parts`. An empty list means no CSS.
|
|
50
|
+
*/
|
|
51
|
+
readonly modules: Readonly<Record<string, readonly string[]>>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Selects stylesheet occurrences for producer modules in manifest order.
|
|
55
|
+
*
|
|
56
|
+
* @param manifest - Manifest whose module selections refer to IDs in its ordered parts.
|
|
57
|
+
* @param modules - Producer identities to include. Repeated requests select each occurrence once.
|
|
58
|
+
* @returns Selected parts with their zero-based position in the complete manifest as `order`.
|
|
59
|
+
* @throws If a requested producer has no entry in `manifest.modules`.
|
|
60
|
+
*/
|
|
61
|
+
export declare function stylesheetLinks(manifest: StylesheetManifest, modules: readonly string[]): {
|
|
62
|
+
order: number;
|
|
63
|
+
id: string;
|
|
64
|
+
href: string;
|
|
65
|
+
}[];
|
|
66
|
+
/**
|
|
67
|
+
* Adds selected stylesheet links to the document head and waits for them to load.
|
|
68
|
+
*
|
|
69
|
+
* Existing links are matched by occurrence ID and retained, including their current URL. New links
|
|
70
|
+
* are inserted before the first existing Stillwind link that follows them in manifest order. IDs
|
|
71
|
+
* must identify stable resources across calls. This function does not refresh links by revision or
|
|
72
|
+
* remove unselected links.
|
|
73
|
+
*
|
|
74
|
+
* @param manifest - Manifest containing the requested producers and their ordered stylesheet
|
|
75
|
+
* occurrences.
|
|
76
|
+
* @param modules - Producer identities whose stylesheet occurrences should be loaded.
|
|
77
|
+
* @param document - Target document with a head for inserting links.
|
|
78
|
+
* @returns A promise that resolves when all selected links have loaded or already expose a sheet.
|
|
79
|
+
* @throws If a producer is unknown or a selected stylesheet emits an error event.
|
|
80
|
+
*/
|
|
81
|
+
export declare function loadStyles(manifest: StylesheetManifest, modules: readonly string[], document: Document): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Orders notices as a published stylesheet lists them.
|
|
84
|
+
*
|
|
85
|
+
* @param banners - Complete preserved comments selected by the compiler, in any order and possibly
|
|
86
|
+
* repeated.
|
|
87
|
+
* @returns A new array with the Stillwind and Tailwind notices first, then the other unique notices
|
|
88
|
+
* in lexical order.
|
|
89
|
+
*/
|
|
90
|
+
export declare function cssBanners(banners: readonly string[]): string[];
|
|
91
|
+
/**
|
|
92
|
+
* Formats notices as the prefix of a published stylesheet.
|
|
93
|
+
*
|
|
94
|
+
* @param banners - Complete preserved comments selected by the compiler, in any order and possibly
|
|
95
|
+
* repeated.
|
|
96
|
+
* @returns The notices in the order of {@link cssBanners}, each followed by a newline.
|
|
97
|
+
*/
|
|
98
|
+
export declare function cssBannerPrefix(banners: readonly string[]): string;
|
|
99
|
+
export type { CssPart };
|
|
100
|
+
//# sourceMappingURL=css.d.ts.map
|
package/dist/css.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// src/css.ts
|
|
2
|
+
/**
|
|
3
|
+
* Constructed sheets cached by document and part key. A changed CSS value replaces only that key's
|
|
4
|
+
* cached sheet.
|
|
5
|
+
*/
|
|
6
|
+
const documents = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
/**
|
|
8
|
+
* Creates or reuses constructed sheets in the supplied document's Window.
|
|
9
|
+
*
|
|
10
|
+
* Updating a cached part creates a new sheet. Callers must adopt the returned sheets to apply it.
|
|
11
|
+
*
|
|
12
|
+
* @param parts - Ordered CSS parts. A part reuses the cached sheet for its key only when its CSS
|
|
13
|
+
* matches the cached text.
|
|
14
|
+
* @param document - Target document whose Window provides `CSSStyleSheet` and `replaceSync`.
|
|
15
|
+
* @returns One sheet per input part, in input order, without adopting them into the document.
|
|
16
|
+
* @throws If the document has no Window or constructing or parsing a stylesheet fails.
|
|
17
|
+
*/
|
|
18
|
+
function styleSheets(parts, document) {
|
|
19
|
+
const realm = document.defaultView;
|
|
20
|
+
if (!realm) throw new Error("Stillwind stylesheets require a document with a Window");
|
|
21
|
+
let cache = documents.get(document);
|
|
22
|
+
if (!cache) documents.set(document, cache = /* @__PURE__ */ new Map());
|
|
23
|
+
return parts.map((part) => {
|
|
24
|
+
const css = cssText([part]);
|
|
25
|
+
const previous = cache.get(part.key);
|
|
26
|
+
if (previous?.css === css) return previous.sheet;
|
|
27
|
+
const sheet = new realm.CSSStyleSheet();
|
|
28
|
+
sheet.replaceSync(css);
|
|
29
|
+
cache.set(part.key, {
|
|
30
|
+
css,
|
|
31
|
+
sheet
|
|
32
|
+
});
|
|
33
|
+
return sheet;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Concatenates CSS bodies in occurrence order and adds their notices once before the result.
|
|
38
|
+
*
|
|
39
|
+
* Repeated occurrences remain, and no separators are added between bodies. When the combined
|
|
40
|
+
* body ends with an inline base64 source map, as development fragments do, the map is shifted
|
|
41
|
+
* by the lines that the notices add.
|
|
42
|
+
*
|
|
43
|
+
* @param parts - CSS parts in the order required by the cascade.
|
|
44
|
+
* @returns The combined stylesheet text, or an empty string when every body is blank.
|
|
45
|
+
* @throws If the inline source map is not valid JSON.
|
|
46
|
+
*/
|
|
47
|
+
function cssText(parts) {
|
|
48
|
+
const body = parts.map((part) => part.css).join("");
|
|
49
|
+
if (!body.trim()) return "";
|
|
50
|
+
const prefix = cssBannerPrefix(parts.flatMap((part) => part.banners ?? []));
|
|
51
|
+
const match = prefix && /\n\/\*# sourceMappingURL=data:application\/json;base64,([A-Za-z0-9+/=]+) \*\/$/.exec(body);
|
|
52
|
+
if (!match) return prefix + body;
|
|
53
|
+
const map = JSON.parse(new TextDecoder().decode(Uint8Array.from(atob(match[1]), (char) => char.charCodeAt(0))));
|
|
54
|
+
if (typeof map.mappings === "string") map.mappings = ";".repeat(prefix.match(/\r\n|\r|\n/g)?.length ?? 0) + map.mappings;
|
|
55
|
+
const bytes = new TextEncoder().encode(JSON.stringify(map));
|
|
56
|
+
const encoded = btoa(Array.from(bytes, (byte) => String.fromCharCode(byte)).join(""));
|
|
57
|
+
return prefix + body.slice(0, match.index) + `\n/*# sourceMappingURL=data:application/json;base64,${encoded} */`;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Selects stylesheet occurrences for producer modules in manifest order.
|
|
61
|
+
*
|
|
62
|
+
* @param manifest - Manifest whose module selections refer to IDs in its ordered parts.
|
|
63
|
+
* @param modules - Producer identities to include. Repeated requests select each occurrence once.
|
|
64
|
+
* @returns Selected parts with their zero-based position in the complete manifest as `order`.
|
|
65
|
+
* @throws If a requested producer has no entry in `manifest.modules`.
|
|
66
|
+
*/
|
|
67
|
+
function stylesheetLinks(manifest, modules) {
|
|
68
|
+
const selected = new Set(modules.flatMap((module) => {
|
|
69
|
+
const parts = manifest.modules[module];
|
|
70
|
+
if (!parts) throw new Error(`Unknown Stillwind stylesheet producer: ${module}`);
|
|
71
|
+
return parts;
|
|
72
|
+
}));
|
|
73
|
+
return manifest.parts.flatMap((part, order) => selected.has(part.id) ? [{
|
|
74
|
+
...part,
|
|
75
|
+
order
|
|
76
|
+
}] : []);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Adds selected stylesheet links to the document head and waits for them to load.
|
|
80
|
+
*
|
|
81
|
+
* Existing links are matched by occurrence ID and retained, including their current URL. New links
|
|
82
|
+
* are inserted before the first existing Stillwind link that follows them in manifest order. IDs
|
|
83
|
+
* must identify stable resources across calls. This function does not refresh links by revision or
|
|
84
|
+
* remove unselected links.
|
|
85
|
+
*
|
|
86
|
+
* @param manifest - Manifest containing the requested producers and their ordered stylesheet
|
|
87
|
+
* occurrences.
|
|
88
|
+
* @param modules - Producer identities whose stylesheet occurrences should be loaded.
|
|
89
|
+
* @param document - Target document with a head for inserting links.
|
|
90
|
+
* @returns A promise that resolves when all selected links have loaded or already expose a sheet.
|
|
91
|
+
* @throws If a producer is unknown or a selected stylesheet emits an error event.
|
|
92
|
+
*/
|
|
93
|
+
async function loadStyles(manifest, modules, document) {
|
|
94
|
+
const selected = stylesheetLinks(manifest, modules);
|
|
95
|
+
const order = new Map(manifest.parts.map((part, index) => [part.id, index]));
|
|
96
|
+
await Promise.all(selected.map((part) => {
|
|
97
|
+
const previous = [...document.querySelectorAll("link[data-stillwind-part]")].find((link) => link.dataset.stillwindPart === part.id);
|
|
98
|
+
if (previous?.sheet) return Promise.resolve();
|
|
99
|
+
const link = previous ?? document.createElement("link");
|
|
100
|
+
const loaded = new Promise((resolve, reject) => {
|
|
101
|
+
link.addEventListener("load", () => {
|
|
102
|
+
resolve();
|
|
103
|
+
}, { once: true });
|
|
104
|
+
link.addEventListener("error", () => {
|
|
105
|
+
reject(/* @__PURE__ */ new Error(`Cannot load ${part.href}`));
|
|
106
|
+
}, { once: true });
|
|
107
|
+
});
|
|
108
|
+
if (!previous) {
|
|
109
|
+
link.rel = "stylesheet";
|
|
110
|
+
link.href = part.href;
|
|
111
|
+
link.dataset.stillwindPart = part.id;
|
|
112
|
+
link.dataset.stillwindOrder = String(part.order);
|
|
113
|
+
const next = [...document.querySelectorAll("link[data-stillwind-part]")].find((existing) => (order.get(existing.dataset.stillwindPart) ?? -1) > order.get(part.id));
|
|
114
|
+
document.head.insertBefore(link, next ?? null);
|
|
115
|
+
}
|
|
116
|
+
return loaded;
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Orders notices as a published stylesheet lists them.
|
|
121
|
+
*
|
|
122
|
+
* @param banners - Complete preserved comments selected by the compiler, in any order and possibly
|
|
123
|
+
* repeated.
|
|
124
|
+
* @returns A new array with the Stillwind and Tailwind notices first, then the other unique notices
|
|
125
|
+
* in lexical order.
|
|
126
|
+
*/
|
|
127
|
+
function cssBanners(banners) {
|
|
128
|
+
const priority = (text) => text.startsWith("/*! stillwind v") ? 0 : text.startsWith("/*! tailwindcss v") ? 1 : 2;
|
|
129
|
+
return [...new Set(banners)].sort((a, b) => priority(a) - priority(b) || (a < b ? -1 : a > b ? 1 : 0));
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Formats notices as the prefix of a published stylesheet.
|
|
133
|
+
*
|
|
134
|
+
* @param banners - Complete preserved comments selected by the compiler, in any order and possibly
|
|
135
|
+
* repeated.
|
|
136
|
+
* @returns The notices in the order of {@link cssBanners}, each followed by a newline.
|
|
137
|
+
*/
|
|
138
|
+
function cssBannerPrefix(banners) {
|
|
139
|
+
return cssBanners(banners).map((banner) => banner + "\n").join("");
|
|
140
|
+
}
|
|
141
|
+
export { cssBannerPrefix, cssBanners, cssText, loadStyles, styleSheets, stylesheetLinks };
|
|
142
|
+
|
|
143
|
+
//# sourceMappingURL=css.js.map
|
package/dist/css.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css.js","names":[],"sources":["../src/css.ts"],"sourcesContent":["import type { CssPart } from \"./module-css.ts\";\n\nexport type { CssPart } from \"./module-css.ts\";\n\n/**\n * Constructed sheets cached by document and part key. A changed CSS value replaces only that key's\n * cached sheet.\n */\nconst documents = new WeakMap<\n Document,\n Map<\n string,\n {\n css: string;\n sheet: CSSStyleSheet;\n }\n >\n>();\n\n/**\n * Creates or reuses constructed sheets in the supplied document's Window.\n *\n * Updating a cached part creates a new sheet. Callers must adopt the returned sheets to apply it.\n *\n * @param parts - Ordered CSS parts. A part reuses the cached sheet for its key only when its CSS\n * matches the cached text.\n * @param document - Target document whose Window provides `CSSStyleSheet` and `replaceSync`.\n * @returns One sheet per input part, in input order, without adopting them into the document.\n * @throws If the document has no Window or constructing or parsing a stylesheet fails.\n */\nexport function styleSheets(parts: readonly CssPart[], document: Document): CSSStyleSheet[] {\n const realm = document.defaultView;\n if (!realm) {\n throw new Error(\"Stillwind stylesheets require a document with a Window\");\n }\n let cache = documents.get(document);\n if (!cache) {\n documents.set(document, (cache = new Map()));\n }\n return parts.map((part) => {\n const css = cssText([part]);\n const previous = cache.get(part.key);\n if (previous?.css === css) {\n return previous.sheet;\n }\n const sheet = new realm.CSSStyleSheet();\n sheet.replaceSync(css);\n cache!.set(part.key, {\n css,\n sheet,\n });\n return sheet;\n });\n}\n\n/**\n * Concatenates CSS bodies in occurrence order and adds their notices once before the result.\n *\n * Repeated occurrences remain, and no separators are added between bodies. When the combined\n * body ends with an inline base64 source map, as development fragments do, the map is shifted\n * by the lines that the notices add.\n *\n * @param parts - CSS parts in the order required by the cascade.\n * @returns The combined stylesheet text, or an empty string when every body is blank.\n * @throws If the inline source map is not valid JSON.\n */\nexport function cssText<Part extends Pick<CssPart, \"css\" | \"banners\">>(\n parts: readonly Part[],\n): string {\n const body = parts.map((part) => part.css).join(\"\");\n if (!body.trim()) {\n return \"\";\n }\n const prefix = cssBannerPrefix(parts.flatMap((part) => part.banners ?? []));\n const match =\n prefix &&\n /\\n\\/\\*# sourceMappingURL=data:application\\/json;base64,([A-Za-z0-9+/=]+) \\*\\/$/.exec(body);\n if (!match) {\n return prefix + body;\n }\n const map = JSON.parse(\n new TextDecoder().decode(Uint8Array.from(atob(match[1]), (char) => char.charCodeAt(0))),\n );\n if (typeof map.mappings === \"string\") {\n map.mappings = \";\".repeat(prefix.match(/\\r\\n|\\r|\\n/g)?.length ?? 0) + map.mappings;\n }\n const bytes = new TextEncoder().encode(JSON.stringify(map));\n const encoded = btoa(Array.from(bytes, (byte) => String.fromCharCode(byte)).join(\"\"));\n return (\n prefix +\n body.slice(0, match.index) +\n `\\n/*# sourceMappingURL=data:application/json;base64,${encoded} */`\n );\n}\n\n/** Build manifest that maps producer modules to stylesheet occurrences in cascade order. */\nexport interface StylesheetManifest {\n /** Manifest format version. The supported shape uses version 1. */\n readonly version: 1;\n /**\n * Build revision identifying the manifest. Link selection and loading do not compare this value.\n */\n readonly revision: string;\n /**\n * Stylesheet occurrences in cascade order. Each occurrence has a distinct ID even when URLs\n * repeat.\n */\n readonly parts: readonly {\n /**\n * Unique occurrence identity used by module selections and `data-stillwind-part` attributes.\n */\n readonly id: string;\n /**\n * Stylesheet URL assigned to a link element. Relative URLs resolve against the target document.\n */\n readonly href: string;\n }[];\n /**\n * Producer module identities mapped to occurrence IDs from `parts`. An empty list means no CSS.\n */\n readonly modules: Readonly<Record<string, readonly string[]>>;\n}\n\n/**\n * Selects stylesheet occurrences for producer modules in manifest order.\n *\n * @param manifest - Manifest whose module selections refer to IDs in its ordered parts.\n * @param modules - Producer identities to include. Repeated requests select each occurrence once.\n * @returns Selected parts with their zero-based position in the complete manifest as `order`.\n * @throws If a requested producer has no entry in `manifest.modules`.\n */\nexport function stylesheetLinks(manifest: StylesheetManifest, modules: readonly string[]) {\n const selected = new Set(\n modules.flatMap((module) => {\n const parts = manifest.modules[module];\n if (!parts) {\n throw new Error(`Unknown Stillwind stylesheet producer: ${module}`);\n }\n return parts;\n }),\n );\n return manifest.parts.flatMap((part, order) =>\n selected.has(part.id)\n ? [\n {\n ...part,\n order,\n },\n ]\n : [],\n );\n}\n\n/**\n * Adds selected stylesheet links to the document head and waits for them to load.\n *\n * Existing links are matched by occurrence ID and retained, including their current URL. New links\n * are inserted before the first existing Stillwind link that follows them in manifest order. IDs\n * must identify stable resources across calls. This function does not refresh links by revision or\n * remove unselected links.\n *\n * @param manifest - Manifest containing the requested producers and their ordered stylesheet\n * occurrences.\n * @param modules - Producer identities whose stylesheet occurrences should be loaded.\n * @param document - Target document with a head for inserting links.\n * @returns A promise that resolves when all selected links have loaded or already expose a sheet.\n * @throws If a producer is unknown or a selected stylesheet emits an error event.\n */\nexport async function loadStyles(\n manifest: StylesheetManifest,\n modules: readonly string[],\n document: Document,\n): Promise<void> {\n const selected = stylesheetLinks(manifest, modules);\n const order = new Map(manifest.parts.map((part, index) => [part.id, index]));\n await Promise.all(\n selected.map((part) => {\n const previous = [\n ...document.querySelectorAll<HTMLLinkElement>(\"link[data-stillwind-part]\"),\n ].find((link) => link.dataset.stillwindPart === part.id);\n if (previous?.sheet) {\n return Promise.resolve();\n }\n const link = previous ?? document.createElement(\"link\");\n const loaded = new Promise<void>((resolve, reject) => {\n link.addEventListener(\n \"load\",\n () => {\n resolve();\n },\n {\n once: true,\n },\n );\n link.addEventListener(\n \"error\",\n () => {\n reject(new Error(`Cannot load ${part.href}`));\n },\n {\n once: true,\n },\n );\n });\n if (!previous) {\n link.rel = \"stylesheet\";\n link.href = part.href;\n link.dataset.stillwindPart = part.id;\n link.dataset.stillwindOrder = String(part.order);\n const next = [\n ...document.querySelectorAll<HTMLLinkElement>(\"link[data-stillwind-part]\"),\n ].find(\n (existing) => (order.get(existing.dataset.stillwindPart!) ?? -1) > order.get(part.id)!,\n );\n document.head.insertBefore(link, next ?? null);\n }\n return loaded;\n }),\n );\n}\n\n/**\n * Orders notices as a published stylesheet lists them.\n *\n * @param banners - Complete preserved comments selected by the compiler, in any order and possibly\n * repeated.\n * @returns A new array with the Stillwind and Tailwind notices first, then the other unique notices\n * in lexical order.\n */\nexport function cssBanners(banners: readonly string[]): string[] {\n const priority = (text: string) =>\n text.startsWith(\"/*! stillwind v\") ? 0 : text.startsWith(\"/*! tailwindcss v\") ? 1 : 2;\n return [...new Set(banners)].sort(\n (a, b) => priority(a) - priority(b) || (a < b ? -1 : a > b ? 1 : 0),\n );\n}\n\n/**\n * Formats notices as the prefix of a published stylesheet.\n *\n * @param banners - Complete preserved comments selected by the compiler, in any order and possibly\n * repeated.\n * @returns The notices in the order of {@link cssBanners}, each followed by a newline.\n */\nexport function cssBannerPrefix(banners: readonly string[]): string {\n return cssBanners(banners)\n .map((banner) => banner + \"\\n\")\n .join(\"\");\n}\n"],"mappings":";;;;;AAQA,MAAM,4BAAY,IAAI,QASpB;;;;;;;;;;;;AAaF,SAAgB,YAAY,OAA2B,UAAqC;CAC1F,MAAM,QAAQ,SAAS;CACvB,IAAI,CAAC,OAC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Ac,MAAM,IAAI,SAAS,QAAQ,aAAc,KAAK,MAAM,MAAM,IAAI,KAAK,EAAE,CACtF;GACA,SAAS,KAAK,aAAa,MAAM,QAAQ,IAAI;EAC/C;EACA,OAAO;CACT,CAAC,CACH;AACF;;;;;;;;;AAUA,SAAgB,WAAW,SAAsC;CAC/D,MAAM,YAAY,SAChB,KAAK,WAAW,iBAAiB,IAAI,IAAI,KAAK,WAAW,mBAAmB,IAAI,IAAI;CACtF,OAAO,CAAC,GAAG,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,MAC1B,GAAG,MAAM,SAAS,CAAC,IAAI,SAAS,CAAC,MAAM,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,EACnE;AACF;;;;;;;;AASA,SAAgB,gBAAgB,SAAoC;CAClE,OAAO,WAAW,OAAO,CAAC,CACvB,KAAK,WAAW,SAAS,IAAI,CAAC,CAC9B,KAAK,EAAE;AACZ"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
// src/runtime/fragment.ts
|
|
2
|
+
function isObject(value) {
|
|
3
|
+
return typeof value === "object" && value !== null;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Converts a style payload using the framework's style convention.
|
|
7
|
+
*
|
|
8
|
+
* @param payload - Arbitrary payload. String mode accepts text and objects whose entries become declarations.
|
|
9
|
+
* @param styleFormat - Object mode returns the payload unchanged; string mode serializes object entries in order.
|
|
10
|
+
* @returns The payload, declaration text, or undefined for an unsupported string-mode payload.
|
|
11
|
+
*/
|
|
12
|
+
function serializeStyle(payload, styleFormat) {
|
|
13
|
+
if (styleFormat === "string") {
|
|
14
|
+
if (typeof payload === "string") return payload;
|
|
15
|
+
if (isObject(payload)) return Object.entries(payload).map(([name, value]) => `${name}:${String(value)}`).join(";");
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
return payload;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Materializes class and style fragments without mutating the inputs.
|
|
22
|
+
*
|
|
23
|
+
* @param options - Framework conventions and the keys of the runtime that created the fragments.
|
|
24
|
+
* @param values - Fragments or nested arrays.
|
|
25
|
+
* Nonobjects are ignored. Materialized bases must first be converted with `toFragment`.
|
|
26
|
+
* @returns Props with classes joined in traversal order. The last non-null fragment
|
|
27
|
+
* style supplies inline style, and generated custom properties are combined and applied
|
|
28
|
+
* last. Fragment symbol channels do not appear in the result.
|
|
29
|
+
*/
|
|
30
|
+
function mergeFragments(options, values) {
|
|
31
|
+
const [classProperty, styleFormat, stillwindClassKey, stillwindStyleKey, stillwindCustomPropertiesKey] = options;
|
|
32
|
+
const classes = [];
|
|
33
|
+
const customProperties = {};
|
|
34
|
+
let style;
|
|
35
|
+
let hasStyle = false;
|
|
36
|
+
const collect = (value) => {
|
|
37
|
+
if (!value) return;
|
|
38
|
+
if (Array.isArray(value)) {
|
|
39
|
+
for (const element of value) collect(element);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (!isObject(value)) return;
|
|
43
|
+
if (Object.hasOwn(value, stillwindClassKey) || Object.hasOwn(value, stillwindStyleKey) || Object.hasOwn(value, stillwindCustomPropertiesKey)) {
|
|
44
|
+
const custom = value[stillwindCustomPropertiesKey];
|
|
45
|
+
if (isObject(custom)) Object.assign(customProperties, custom);
|
|
46
|
+
const contribution = value[stillwindClassKey];
|
|
47
|
+
if (typeof contribution === "string" && contribution.length > 0) classes.push(contribution);
|
|
48
|
+
if (Object.hasOwn(value, stillwindStyleKey)) {
|
|
49
|
+
const payload = value[stillwindStyleKey];
|
|
50
|
+
if (payload !== void 0 && payload !== null) {
|
|
51
|
+
style = payload;
|
|
52
|
+
hasStyle = true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
for (const value of values) collect(value);
|
|
58
|
+
const result = {};
|
|
59
|
+
if (classes.length > 0) result[classProperty] = classes.join(" ");
|
|
60
|
+
if (hasStyle) {
|
|
61
|
+
const materialized = serializeStyle(style, styleFormat);
|
|
62
|
+
if (materialized !== void 0) result.style = materialized;
|
|
63
|
+
}
|
|
64
|
+
if (Object.keys(customProperties).length > 0) result.style = styleFormat === "string" ? [serializeStyle(result.style, styleFormat), serializeStyle(customProperties, styleFormat)].filter(Boolean).join(";") : {
|
|
65
|
+
...isObject(result.style) ? result.style : {},
|
|
66
|
+
...customProperties
|
|
67
|
+
};
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Converts a composition base to a fragment that contributes only its class.
|
|
72
|
+
*
|
|
73
|
+
* A base contributes either `class` or `className`, or the class channel of a fragment
|
|
74
|
+
* from this runtime. The receiving output's prop takes precedence unless it is null or
|
|
75
|
+
* undefined. Style payloads and custom properties are ignored.
|
|
76
|
+
*
|
|
77
|
+
* @param options - The receiving framework's prop conventions and fragment keys.
|
|
78
|
+
* @param value - A non-null object containing materialized props or this runtime's
|
|
79
|
+
* fragment channels.
|
|
80
|
+
* @returns A new fragment whose class channel holds the base's class value.
|
|
81
|
+
*/
|
|
82
|
+
function toFragment(options, value) {
|
|
83
|
+
const [classProperty, , stillwindClassKey] = options;
|
|
84
|
+
return { [stillwindClassKey]: Object.hasOwn(value, stillwindClassKey) ? value[stillwindClassKey] : value[classProperty] ?? value[classProperty === "class" ? "className" : "class"] };
|
|
85
|
+
}
|
|
86
|
+
// src/runtime/shared.ts
|
|
87
|
+
/**
|
|
88
|
+
* Converts a dynamic value into text for a generated CSS declaration.
|
|
89
|
+
*
|
|
90
|
+
* @param value - CSS text, a number, a URL, or a boolean. URLs are quoted and CSS-escaped. True
|
|
91
|
+
* becomes a space and false becomes `initial`.
|
|
92
|
+
* @returns CSS value text. Strings and numbers are converted with `String`.
|
|
93
|
+
*/
|
|
94
|
+
function stillwindCssValue(value) {
|
|
95
|
+
if (typeof value === "boolean") return value ? " " : "initial";
|
|
96
|
+
if (value instanceof URL) return `url("${value.href.replace(/["\\\n\r\f]/g, (character) => `\\${character.codePointAt(0).toString(16)} `)}")`;
|
|
97
|
+
return String(value);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Flattens class contributions and joins nonempty values with spaces.
|
|
101
|
+
*
|
|
102
|
+
* @param values - Strings, numbers, bigints, nested arrays, or objects whose truthy values enable
|
|
103
|
+
* their keys. Other values are ignored.
|
|
104
|
+
* @returns Class text in contribution order, without deduplication.
|
|
105
|
+
*/
|
|
106
|
+
function stillwindClsx(...values) {
|
|
107
|
+
return values.flatMap(flatten).filter(Boolean).join(" ");
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Escapes text for use as one CSS identifier.
|
|
111
|
+
*
|
|
112
|
+
* @param value - Unescaped identifier text.
|
|
113
|
+
* @returns `CSS.escape` output when available, otherwise escaped text with NUL replaced by U+FFFD.
|
|
114
|
+
*/
|
|
115
|
+
function stillwindEscapedIdentifier(value) {
|
|
116
|
+
if (typeof CSS !== "undefined" && typeof CSS.escape === "function") return CSS.escape(value);
|
|
117
|
+
const characters = Array.from(value);
|
|
118
|
+
let escaped = "";
|
|
119
|
+
for (const [index, character] of characters.entries()) {
|
|
120
|
+
const code = character.codePointAt(0);
|
|
121
|
+
const isDigit = code >= 48 && code <= 57;
|
|
122
|
+
const isControl = code >= 1 && code <= 31 || code === 127;
|
|
123
|
+
if (code === 0) escaped += "�";
|
|
124
|
+
else if (isControl) escaped += `\\${code.toString(16)} `;
|
|
125
|
+
else if (index === 0 && isDigit) escaped += `\\${code.toString(16)} `;
|
|
126
|
+
else if (index === 0 && character === "-" && characters.length === 1) escaped += "\\-";
|
|
127
|
+
else if (index === 1 && isDigit && characters[0] === "-") escaped += `\\${code.toString(16)} `;
|
|
128
|
+
else if (isDigit || code >= 65 && code <= 90 || code >= 97 && code <= 122 || code === 45 || code === 95 || code >= 128) escaped += character;
|
|
129
|
+
else escaped += `\\${character}`;
|
|
130
|
+
}
|
|
131
|
+
return escaped;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Builds a CSS identifier for one keyed view transition.
|
|
135
|
+
*
|
|
136
|
+
* @param value - Nonempty class token or an object whose `v` property contains that token.
|
|
137
|
+
* @param key - Key appended to the token after a hyphen using `String`.
|
|
138
|
+
* @returns The combined token and key escaped as a CSS identifier.
|
|
139
|
+
*/
|
|
140
|
+
function stillwindViewTransitionName(value, key) {
|
|
141
|
+
return stillwindEscapedIdentifier(`${typeof value === "string" ? value : value.v}-${String(key)}`);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Expands one class contribution into strings without splitting class text.
|
|
145
|
+
*
|
|
146
|
+
* @param value - Class text, a number, a bigint, a nested array, or an object with enabled class
|
|
147
|
+
* keys.
|
|
148
|
+
* @returns Strings in traversal or object-entry order. Unsupported values produce an empty list.
|
|
149
|
+
*/
|
|
150
|
+
function flatten(value) {
|
|
151
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "bigint") return [String(value)];
|
|
152
|
+
if (Array.isArray(value)) return value.flatMap(flatten);
|
|
153
|
+
if (value && typeof value === "object") return Object.entries(value).filter(([, enabled]) => Boolean(enabled)).map(([name]) => name);
|
|
154
|
+
return [];
|
|
155
|
+
}
|
|
156
|
+
// src/runtime/cva.ts
|
|
157
|
+
function optionKey(value) {
|
|
158
|
+
return typeof value === "boolean" ? String(value) : value === 0 ? "0" : value;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Creates a selector over compiler-produced values using the supplied framework channels.
|
|
162
|
+
* Values are captured at creation. Each call returns fresh props without mutating inputs.
|
|
163
|
+
* Undefined selections keep defaults; null suppresses an option. Matching compounds
|
|
164
|
+
* contribute in array order, followed by external class and className inputs.
|
|
165
|
+
*
|
|
166
|
+
* @param options - Framework conventions and the keys used by compiled fragments.
|
|
167
|
+
* @param base - Compiled styles included in every selection.
|
|
168
|
+
* @param config - Immutable compiled option maps, defaults, and compound conditions.
|
|
169
|
+
* @param classes - Concatenates external class inputs. Development calls supply validation.
|
|
170
|
+
* @param merge - Materializes selected fragments. Development calls supply validation.
|
|
171
|
+
* @returns A selector that materializes class and optional style props without private symbols.
|
|
172
|
+
*/
|
|
173
|
+
function createCva(options, base, config = {}, classes = stillwindClsx, merge = mergeFragments) {
|
|
174
|
+
const axes = Object.keys(config.variants ?? {});
|
|
175
|
+
const compounds = (config.compoundVariants ?? []).map((compound) => ({
|
|
176
|
+
conditions: Object.entries(compound).filter(([key]) => key !== "class" && key !== "className"),
|
|
177
|
+
class: compound.class,
|
|
178
|
+
className: compound.className
|
|
179
|
+
}));
|
|
180
|
+
const fragment = (value) => typeof value === "string" ? { [options[2]]: value } : value;
|
|
181
|
+
return (props = {}) => {
|
|
182
|
+
const values = [fragment(base)];
|
|
183
|
+
const variants = config.variants;
|
|
184
|
+
if (variants) {
|
|
185
|
+
for (const axis of axes) {
|
|
186
|
+
const supplied = props[axis];
|
|
187
|
+
if (supplied === null) continue;
|
|
188
|
+
const key = optionKey(supplied) || optionKey(config.defaultVariants?.[axis]);
|
|
189
|
+
const choices = variants[axis];
|
|
190
|
+
if ((typeof key === "string" || typeof key === "number") && Object.hasOwn(choices, key)) values.push(fragment(choices[key]));
|
|
191
|
+
}
|
|
192
|
+
const resolved = {
|
|
193
|
+
...config.defaultVariants,
|
|
194
|
+
...Object.fromEntries(Object.entries(props).filter(([, value]) => value !== void 0))
|
|
195
|
+
};
|
|
196
|
+
for (const compound of compounds) if (compound.conditions.every(([key, expected]) => Array.isArray(expected) ? expected.includes(resolved[key]) : expected === resolved[key])) values.push(fragment(compound.class), fragment(compound.className));
|
|
197
|
+
}
|
|
198
|
+
values.push({ [options[2]]: classes(props.class, props.className) });
|
|
199
|
+
return merge(options, values);
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
export { createCva, isObject, mergeFragments, serializeStyle, stillwindClsx, stillwindCssValue, stillwindEscapedIdentifier, stillwindViewTransitionName, toFragment };
|
|
203
|
+
|
|
204
|
+
//# sourceMappingURL=cva-BwX07CFw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cva-BwX07CFw.js","names":[],"sources":["../src/runtime/fragment.ts","../src/runtime/shared.ts","../src/runtime/cva.ts"],"sourcesContent":["/**\n * Framework conventions and private channels used to materialize fragments.\n * The three keys must be distinct and belong to the runtime that created the fragments.\n */\nexport type FragmentRuntimeOptions = readonly [\n /** Element prop that receives the combined class text. */\n classProperty: \"class\" | \"className\",\n /** Whether style records become objects or semicolon-separated declaration text. */\n styleFormat: \"object\" | \"string\",\n /** Own fragment property containing class text. */\n stillwindClassKey: symbol,\n /** Own fragment property containing the last authored style payload. */\n stillwindStyleKey: symbol,\n /** Own fragment property containing generated custom properties applied last. */\n stillwindCustomPropertiesKey: symbol,\n];\n\nexport function isObject(value: unknown): value is Record<PropertyKey, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\n/**\n * Converts a style payload using the framework's style convention.\n *\n * @param payload - Arbitrary payload. String mode accepts text and objects whose entries become declarations.\n * @param styleFormat - Object mode returns the payload unchanged; string mode serializes object entries in order.\n * @returns The payload, declaration text, or undefined for an unsupported string-mode payload.\n */\nexport function serializeStyle(payload: unknown, styleFormat: \"object\" | \"string\"): unknown {\n if (styleFormat === \"string\") {\n if (typeof payload === \"string\") {\n return payload;\n }\n if (isObject(payload)) {\n return Object.entries(payload)\n .map(([name, value]) => `${name}:${String(value)}`)\n .join(\";\");\n }\n return undefined;\n }\n return payload;\n}\n\n/**\n * Materializes class and style fragments without mutating the inputs.\n *\n * @param options - Framework conventions and the keys of the runtime that created the fragments.\n * @param values - Fragments or nested arrays.\n * Nonobjects are ignored. Materialized bases must first be converted with `toFragment`.\n * @returns Props with classes joined in traversal order. The last non-null fragment\n * style supplies inline style, and generated custom properties are combined and applied\n * last. Fragment symbol channels do not appear in the result.\n */\nexport function mergeFragments(\n options: FragmentRuntimeOptions,\n values: readonly unknown[],\n): Record<string, unknown> {\n const [\n classProperty,\n styleFormat,\n stillwindClassKey,\n stillwindStyleKey,\n stillwindCustomPropertiesKey,\n ] = options;\n const classes: string[] = [];\n const customProperties: Record<string, string> = {};\n let style: unknown;\n let hasStyle = false;\n\n const collect = (value: unknown): void => {\n if (!value) {\n return;\n }\n if (Array.isArray(value)) {\n for (const element of value) {\n collect(element);\n }\n return;\n }\n if (!isObject(value)) {\n return;\n }\n const fragment =\n Object.hasOwn(value, stillwindClassKey) ||\n Object.hasOwn(value, stillwindStyleKey) ||\n Object.hasOwn(value, stillwindCustomPropertiesKey);\n if (fragment) {\n const custom = value[stillwindCustomPropertiesKey];\n if (isObject(custom)) {\n Object.assign(customProperties, custom);\n }\n const contribution = value[stillwindClassKey];\n if (typeof contribution === \"string\" && contribution.length > 0) {\n classes.push(contribution);\n }\n if (Object.hasOwn(value, stillwindStyleKey)) {\n const payload = value[stillwindStyleKey];\n if (payload !== undefined && payload !== null) {\n style = payload;\n hasStyle = true;\n }\n }\n }\n };\n\n for (const value of values) {\n collect(value);\n }\n\n const result: Record<string, unknown> = {};\n if (classes.length > 0) {\n result[classProperty] = classes.join(\" \");\n }\n if (hasStyle) {\n const materialized = serializeStyle(style, styleFormat);\n if (materialized !== undefined) {\n result.style = materialized;\n }\n }\n if (Object.keys(customProperties).length > 0) {\n result.style =\n styleFormat === \"string\"\n ? [serializeStyle(result.style, styleFormat), serializeStyle(customProperties, styleFormat)]\n .filter(Boolean)\n .join(\";\")\n : { ...(isObject(result.style) ? result.style : {}), ...customProperties };\n }\n return result;\n}\n\n/**\n * Converts a composition base to a fragment that contributes only its class.\n *\n * A base contributes either `class` or `className`, or the class channel of a fragment\n * from this runtime. The receiving output's prop takes precedence unless it is null or\n * undefined. Style payloads and custom properties are ignored.\n *\n * @param options - The receiving framework's prop conventions and fragment keys.\n * @param value - A non-null object containing materialized props or this runtime's\n * fragment channels.\n * @returns A new fragment whose class channel holds the base's class value.\n */\nexport function toFragment(\n options: FragmentRuntimeOptions,\n value: Record<PropertyKey, unknown>,\n): Record<PropertyKey, unknown> {\n const [classProperty, , stillwindClassKey] = options;\n return {\n [stillwindClassKey]: Object.hasOwn(value, stillwindClassKey)\n ? value[stillwindClassKey]\n : (value[classProperty] ?? value[classProperty === \"class\" ? \"className\" : \"class\"]),\n };\n}\n","/**\n * Converts a dynamic value into text for a generated CSS declaration.\n *\n * @param value - CSS text, a number, a URL, or a boolean. URLs are quoted and CSS-escaped. True\n * becomes a space and false becomes `initial`.\n * @returns CSS value text. Strings and numbers are converted with `String`.\n */\nexport function stillwindCssValue(value: URL | string | number | boolean): string {\n if (typeof value === \"boolean\") {\n return value ? \" \" : \"initial\";\n }\n if (value instanceof URL) {\n const escaped = value.href.replace(\n /[\"\\\\\\n\\r\\f]/g,\n (character) => `\\\\${character.codePointAt(0)!.toString(16)} `,\n );\n return `url(\"${escaped}\")`;\n }\n return String(value);\n}\n\n/**\n * Flattens class contributions and joins nonempty values with spaces.\n *\n * @param values - Strings, numbers, bigints, nested arrays, or objects whose truthy values enable\n * their keys. Other values are ignored.\n * @returns Class text in contribution order, without deduplication.\n */\nexport function stillwindClsx(...values: readonly unknown[]): string {\n return values.flatMap(flatten).filter(Boolean).join(\" \");\n}\n\n/**\n * Escapes text for use as one CSS identifier.\n *\n * @param value - Unescaped identifier text.\n * @returns `CSS.escape` output when available, otherwise escaped text with NUL replaced by U+FFFD.\n */\nexport function stillwindEscapedIdentifier(value: string): string {\n if (typeof CSS !== \"undefined\" && typeof CSS.escape === \"function\") {\n return CSS.escape(value);\n }\n const characters = Array.from(value);\n let escaped = \"\";\n for (const [index, character] of characters.entries()) {\n const code = character.codePointAt(0)!;\n const isDigit = code >= 48 && code <= 57;\n const isControl = (code >= 1 && code <= 31) || code === 127;\n if (code === 0) {\n escaped += \"\\uFFFD\";\n } else if (isControl) {\n escaped += `\\\\${code.toString(16)} `;\n } else if (index === 0 && isDigit) {\n escaped += `\\\\${code.toString(16)} `;\n } else if (index === 0 && character === \"-\" && characters.length === 1) {\n escaped += \"\\\\-\";\n } else if (index === 1 && isDigit && characters[0] === \"-\") {\n escaped += `\\\\${code.toString(16)} `;\n } else if (\n isDigit ||\n (code >= 65 && code <= 90) ||\n (code >= 97 && code <= 122) ||\n code === 45 ||\n code === 95 ||\n code >= 128\n ) {\n escaped += character;\n } else {\n escaped += `\\\\${character}`;\n }\n }\n return escaped;\n}\n\n/**\n * Builds a CSS identifier for one keyed view transition.\n *\n * @param value - Nonempty class token or an object whose `v` property contains that token.\n * @param key - Key appended to the token after a hyphen using `String`.\n * @returns The combined token and key escaped as a CSS identifier.\n */\nexport function stillwindViewTransitionName(value: unknown, key: string | number): string {\n const token = typeof value === \"string\" ? value : (value as { v: string }).v;\n return stillwindEscapedIdentifier(`${token}-${String(key)}`);\n}\n\n/**\n * Expands one class contribution into strings without splitting class text.\n *\n * @param value - Class text, a number, a bigint, a nested array, or an object with enabled class\n * keys.\n * @returns Strings in traversal or object-entry order. Unsupported values produce an empty list.\n */\nfunction flatten(value: unknown): string[] {\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"bigint\") {\n return [String(value)];\n }\n if (Array.isArray(value)) {\n return value.flatMap(flatten);\n }\n if (value && typeof value === \"object\") {\n return Object.entries(value as Record<string, unknown>)\n .filter(([, enabled]) => Boolean(enabled))\n .map(([name]) => name);\n }\n return [];\n}\n","import { mergeFragments, type FragmentRuntimeOptions } from \"./fragment.ts\";\nimport { stillwindClsx } from \"./shared.ts\";\n\n/** Compiler-produced class text, fragment channels, or nested fragment arrays. */\nexport type CvaValue = string | boolean | null | undefined | object;\n\n/** Compiled configuration whose structure is immutable after factory creation. */\nexport interface CompiledCvaConfig {\n readonly variants?: Readonly<Record<string, Readonly<Record<string, CvaValue>>>>;\n readonly defaultVariants?: Readonly<Record<string, string | number | boolean | null | undefined>>;\n readonly compoundVariants?: readonly Readonly<Record<string, unknown>>[];\n}\n\nfunction optionKey(value: unknown): unknown {\n return typeof value === \"boolean\" ? String(value) : value === 0 ? \"0\" : value;\n}\n\n/**\n * Creates a selector over compiler-produced values using the supplied framework channels.\n * Values are captured at creation. Each call returns fresh props without mutating inputs.\n * Undefined selections keep defaults; null suppresses an option. Matching compounds\n * contribute in array order, followed by external class and className inputs.\n *\n * @param options - Framework conventions and the keys used by compiled fragments.\n * @param base - Compiled styles included in every selection.\n * @param config - Immutable compiled option maps, defaults, and compound conditions.\n * @param classes - Concatenates external class inputs. Development calls supply validation.\n * @param merge - Materializes selected fragments. Development calls supply validation.\n * @returns A selector that materializes class and optional style props without private symbols.\n */\nexport function createCva(\n options: FragmentRuntimeOptions,\n base: CvaValue,\n config: CompiledCvaConfig = {},\n classes: typeof stillwindClsx = stillwindClsx,\n merge: typeof mergeFragments = mergeFragments,\n): (props?: Readonly<Record<string, unknown>>) => Record<string, unknown> {\n const axes = Object.keys(config.variants ?? {});\n const compounds = (config.compoundVariants ?? []).map((compound) => ({\n conditions: Object.entries(compound).filter(([key]) => key !== \"class\" && key !== \"className\"),\n class: compound.class as CvaValue,\n className: compound.className as CvaValue,\n }));\n const fragment = (value: CvaValue): unknown =>\n typeof value === \"string\" ? { [options[2]]: value } : value;\n\n return (props = {}) => {\n const values: unknown[] = [fragment(base)];\n const variants = config.variants;\n if (variants) {\n for (const axis of axes) {\n const supplied = props[axis];\n if (supplied === null) {\n continue;\n }\n const key = optionKey(supplied) || optionKey(config.defaultVariants?.[axis]);\n const choices = variants[axis]!;\n if ((typeof key === \"string\" || typeof key === \"number\") && Object.hasOwn(choices, key)) {\n values.push(fragment(choices[key]));\n }\n }\n const resolved = {\n ...config.defaultVariants,\n ...Object.fromEntries(Object.entries(props).filter(([, value]) => value !== undefined)),\n };\n for (const compound of compounds) {\n if (\n compound.conditions.every(([key, expected]) =>\n Array.isArray(expected) ? expected.includes(resolved[key]) : expected === resolved[key],\n )\n ) {\n values.push(fragment(compound.class), fragment(compound.className));\n }\n }\n }\n values.push({ [options[2]]: classes(props.class, props.className) });\n return merge(options, values);\n };\n}\n"],"mappings":";AAiBA,SAAgB,SAAS,OAAuD;CAC9E,OAAO,OAAO,UAAU,YAAY,UAAU;AAChD;;;;;;;;AASA,SAAgB,eAAe,SAA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, fragment channels, or nested fragment arrays. */
|
|
2
|
+
export type CvaValue = string | boolean | null | undefined | object;
|
|
3
|
+
/** Compiled configuration whose structure is immutable after factory creation. */
|
|
4
|
+
export interface CompiledCvaConfig {
|
|
5
|
+
readonly variants?: Readonly<Record<string, Readonly<Record<string, CvaValue>>>>;
|
|
6
|
+
readonly defaultVariants?: Readonly<Record<string, string | number | boolean | null | undefined>>;
|
|
7
|
+
readonly compoundVariants?: readonly Readonly<Record<string, unknown>>[];
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=cva-DSpDNBYi.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads a compiled ref's class token once.
|
|
3
|
+
*
|
|
4
|
+
* @param value - A ref record whose `.c` property contains a nonempty string.
|
|
5
|
+
* @returns The class token.
|
|
6
|
+
* @throws TypeError if the record or token is missing, or the token is empty or not a string.
|
|
7
|
+
*/
|
|
8
|
+
export declare function stillwindRefClassChecked(value: unknown): string;
|
|
9
|
+
/**
|
|
10
|
+
* Validates external class inputs before concatenating them.
|
|
11
|
+
*
|
|
12
|
+
* @param values - Strings, numbers, bigints, nested arrays, or objects whose truthy entries enable their keys.
|
|
13
|
+
* Booleans, null, and undefined add no text.
|
|
14
|
+
* @returns Class text in contribution order without deduplication.
|
|
15
|
+
* @throws TypeError when an input or nested array contains a function or symbol.
|
|
16
|
+
*/
|
|
17
|
+
export declare function stillwindClsxChecked(...values: readonly unknown[]): string;
|
|
18
|
+
/**
|
|
19
|
+
* Names a keyed view transition after reading its token once.
|
|
20
|
+
*
|
|
21
|
+
* @param value - A nonempty class token or a record whose `.v` contains that token.
|
|
22
|
+
* @param key - A key appended after a hyphen using `String`.
|
|
23
|
+
* @returns The token and key escaped as one CSS identifier.
|
|
24
|
+
* @throws TypeError when the token is missing, empty, or not a string.
|
|
25
|
+
*/
|
|
26
|
+
export declare function stillwindViewTransitionNameChecked(value: unknown, key: string | number): string;
|
|
27
|
+
//# sourceMappingURL=development-DttPQc71.d.ts.map
|