@craft-ts/style 0.7.0-beta.15

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 (73) hide show
  1. package/package.json +41 -0
  2. package/src/index.d.ts +18 -0
  3. package/src/index.d.ts.map +1 -0
  4. package/src/index.js +18 -0
  5. package/src/index.js.map +1 -0
  6. package/src/lib/axes/define.d.ts +115 -0
  7. package/src/lib/axes/define.d.ts.map +1 -0
  8. package/src/lib/axes/define.js +81 -0
  9. package/src/lib/axes/define.js.map +1 -0
  10. package/src/lib/axes/index.d.ts +4 -0
  11. package/src/lib/axes/index.d.ts.map +1 -0
  12. package/src/lib/axes/index.js +4 -0
  13. package/src/lib/axes/index.js.map +1 -0
  14. package/src/lib/axes/standard.d.ts +85 -0
  15. package/src/lib/axes/standard.d.ts.map +1 -0
  16. package/src/lib/axes/standard.js +109 -0
  17. package/src/lib/axes/standard.js.map +1 -0
  18. package/src/lib/axes/types.d.ts +67 -0
  19. package/src/lib/axes/types.d.ts.map +1 -0
  20. package/src/lib/axes/types.js +21 -0
  21. package/src/lib/axes/types.js.map +1 -0
  22. package/src/lib/css-vars.d.ts +100 -0
  23. package/src/lib/css-vars.d.ts.map +1 -0
  24. package/src/lib/css-vars.js +96 -0
  25. package/src/lib/css-vars.js.map +1 -0
  26. package/src/lib/kinds.d.ts +84 -0
  27. package/src/lib/kinds.d.ts.map +1 -0
  28. package/src/lib/kinds.js +44 -0
  29. package/src/lib/kinds.js.map +1 -0
  30. package/src/lib/obligations.d.ts +99 -0
  31. package/src/lib/obligations.d.ts.map +1 -0
  32. package/src/lib/obligations.js +69 -0
  33. package/src/lib/obligations.js.map +1 -0
  34. package/src/lib/props/factory.d.ts +61 -0
  35. package/src/lib/props/factory.d.ts.map +1 -0
  36. package/src/lib/props/factory.js +35 -0
  37. package/src/lib/props/factory.js.map +1 -0
  38. package/src/lib/props/generated.d.ts +974 -0
  39. package/src/lib/props/generated.d.ts.map +1 -0
  40. package/src/lib/props/generated.js +2478 -0
  41. package/src/lib/props/generated.js.map +1 -0
  42. package/src/lib/props/index.d.ts +37 -0
  43. package/src/lib/props/index.d.ts.map +1 -0
  44. package/src/lib/props/index.js +27 -0
  45. package/src/lib/props/index.js.map +1 -0
  46. package/src/lib/styles.d.ts +201 -0
  47. package/src/lib/styles.d.ts.map +1 -0
  48. package/src/lib/styles.js +247 -0
  49. package/src/lib/styles.js.map +1 -0
  50. package/src/lib/tokens/index.d.ts +4 -0
  51. package/src/lib/tokens/index.d.ts.map +1 -0
  52. package/src/lib/tokens/index.js +4 -0
  53. package/src/lib/tokens/index.js.map +1 -0
  54. package/src/lib/tokens/palette.d.ts +97 -0
  55. package/src/lib/tokens/palette.d.ts.map +1 -0
  56. package/src/lib/tokens/palette.js +61 -0
  57. package/src/lib/tokens/palette.js.map +1 -0
  58. package/src/lib/tokens/scales.d.ts +47 -0
  59. package/src/lib/tokens/scales.d.ts.map +1 -0
  60. package/src/lib/tokens/scales.js +51 -0
  61. package/src/lib/tokens/scales.js.map +1 -0
  62. package/src/lib/tokens/units.d.ts +114 -0
  63. package/src/lib/tokens/units.d.ts.map +1 -0
  64. package/src/lib/tokens/units.js +54 -0
  65. package/src/lib/tokens/units.js.map +1 -0
  66. package/src/plugin/emit.d.ts +64 -0
  67. package/src/plugin/emit.d.ts.map +1 -0
  68. package/src/plugin/emit.js +134 -0
  69. package/src/plugin/emit.js.map +1 -0
  70. package/src/plugin/vite.d.ts +66 -0
  71. package/src/plugin/vite.d.ts.map +1 -0
  72. package/src/plugin/vite.js +150 -0
  73. package/src/plugin/vite.js.map +1 -0
@@ -0,0 +1,97 @@
1
+ /**
2
+ * The palette.
3
+ *
4
+ * A token carries **both** of its values and its role. `palette.surface.raised`
5
+ * is a value, not a string, and dark mode is not a second file to keep in sync
6
+ * by hand — the emitter reads the `dark` side off the same token.
7
+ *
8
+ * The role is what later makes `defineAxis(..., { writes: onlyVarsOfKind(color) })`
9
+ * meaningful, and what lets the graph answer "which surfaces does this token
10
+ * paint?" without parsing CSS.
11
+ */
12
+ import type { ColorValue } from './units.ts';
13
+ export interface PaletteEntry {
14
+ readonly light: string;
15
+ readonly dark: string;
16
+ }
17
+ export type PaletteSpec = Readonly<Record<string, Readonly<Record<string, PaletteEntry>>>>;
18
+ export type Palette<Spec extends PaletteSpec> = {
19
+ readonly [Group in keyof Spec]: {
20
+ readonly [Token in keyof Spec[Group]]: ColorValue;
21
+ };
22
+ };
23
+ export declare function definePalette<const Spec extends PaletteSpec>(spec: Spec): Palette<Spec>;
24
+ /**
25
+ * The dark side of a token, as a value.
26
+ *
27
+ * A token carries both of its values; this is how a sheet reaches the other
28
+ * one. Written once, at the theme level — `when(scheme.dark, [set(theme.ink,
29
+ * darkOf(palette.text.strong))])` — rather than at every use site, which is
30
+ * what keeps dark mode from becoming a second design system to maintain.
31
+ *
32
+ * The role travels with it: the dark side of a surface is still a surface.
33
+ */
34
+ export declare const darkOf: (token: ColorValue) => ColorValue;
35
+ export declare const palette: Palette<{
36
+ readonly surface: {
37
+ readonly page: {
38
+ readonly light: "#ffffff";
39
+ readonly dark: "#0b0d11";
40
+ };
41
+ readonly raised: {
42
+ readonly light: "#f6f7f9";
43
+ readonly dark: "#151922";
44
+ };
45
+ readonly sunken: {
46
+ readonly light: "#eceef2";
47
+ readonly dark: "#0f131a";
48
+ };
49
+ };
50
+ readonly text: {
51
+ readonly strong: {
52
+ readonly light: "#111318";
53
+ readonly dark: "#f2f4f8";
54
+ };
55
+ readonly muted: {
56
+ readonly light: "#5b6472";
57
+ readonly dark: "#98a2b3";
58
+ };
59
+ readonly inverted: {
60
+ readonly light: "#ffffff";
61
+ readonly dark: "#0b0d11";
62
+ };
63
+ };
64
+ readonly border: {
65
+ readonly subtle: {
66
+ readonly light: "#e3e6ea";
67
+ readonly dark: "#232936";
68
+ };
69
+ readonly strong: {
70
+ readonly light: "#c3c9d2";
71
+ readonly dark: "#39414f";
72
+ };
73
+ };
74
+ readonly accent: {
75
+ readonly info: {
76
+ readonly light: "#1b5fa1";
77
+ readonly dark: "#6fb2f0";
78
+ };
79
+ readonly success: {
80
+ readonly light: "#0f7b4f";
81
+ readonly dark: "#3ddc97";
82
+ };
83
+ readonly warning: {
84
+ readonly light: "#8a5a00";
85
+ readonly dark: "#f5b544";
86
+ };
87
+ readonly danger: {
88
+ readonly light: "#a11b1b";
89
+ readonly dark: "#ff6b6b";
90
+ };
91
+ readonly neutral: {
92
+ readonly light: "#4a5568";
93
+ readonly dark: "#a6b0c0";
94
+ };
95
+ };
96
+ }>;
97
+ //# sourceMappingURL=palette.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../../../../../../libs/style/src/lib/tokens/palette.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAa,UAAU,EAAE,MAAM,YAAY,CAAC;AAExD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAKD,MAAM,MAAM,WAAW,GAAG,QAAQ,CAChC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,CACvD,CAAC;AAEF,MAAM,MAAM,OAAO,CAAC,IAAI,SAAS,WAAW,IAAI;IAC9C,QAAQ,EAAE,KAAK,IAAI,MAAM,IAAI,GAAG;QAC9B,QAAQ,EAAE,KAAK,IAAI,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,UAAU;KAClD;CACF,CAAC;AAcF,wBAAgB,aAAa,CAAC,KAAK,CAAC,IAAI,SAAS,WAAW,EAC1D,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,IAAI,CAAC,CAYf;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM,GAAI,OAAO,UAAU,KAAG,UAMzB,CAAC;AAEnB,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsBlB,CAAC"}
@@ -0,0 +1,61 @@
1
+ const swatch = (light, dark, role) => ({ css: light, dark, role, unproven: '' });
2
+ /**
3
+ * Roles are derived from the group name rather than repeated on every entry:
4
+ * a token in `surface` paints a surface. A group the map does not know gets
5
+ * `'none'`, which is honest — it says the role is unknown instead of guessing.
6
+ */
7
+ const ROLE_OF_GROUP = {
8
+ surface: 'surface',
9
+ text: 'text',
10
+ border: 'border',
11
+ accent: 'accent',
12
+ };
13
+ export function definePalette(spec) {
14
+ return Object.fromEntries(Object.entries(spec).map(([group, tokens]) => [
15
+ group,
16
+ Object.fromEntries(Object.entries(tokens).map(([name, pair]) => [
17
+ name,
18
+ swatch(pair.light, pair.dark, ROLE_OF_GROUP[group] ?? 'none'),
19
+ ])),
20
+ ]));
21
+ }
22
+ /**
23
+ * The dark side of a token, as a value.
24
+ *
25
+ * A token carries both of its values; this is how a sheet reaches the other
26
+ * one. Written once, at the theme level — `when(scheme.dark, [set(theme.ink,
27
+ * darkOf(palette.text.strong))])` — rather than at every use site, which is
28
+ * what keeps dark mode from becoming a second design system to maintain.
29
+ *
30
+ * The role travels with it: the dark side of a surface is still a surface.
31
+ */
32
+ export const darkOf = (token) => ({
33
+ css: token.dark,
34
+ dark: token.dark,
35
+ role: token.role,
36
+ unproven: token.unproven,
37
+ });
38
+ export const palette = definePalette({
39
+ surface: {
40
+ page: { light: '#ffffff', dark: '#0b0d11' },
41
+ raised: { light: '#f6f7f9', dark: '#151922' },
42
+ sunken: { light: '#eceef2', dark: '#0f131a' },
43
+ },
44
+ text: {
45
+ strong: { light: '#111318', dark: '#f2f4f8' },
46
+ muted: { light: '#5b6472', dark: '#98a2b3' },
47
+ inverted: { light: '#ffffff', dark: '#0b0d11' },
48
+ },
49
+ border: {
50
+ subtle: { light: '#e3e6ea', dark: '#232936' },
51
+ strong: { light: '#c3c9d2', dark: '#39414f' },
52
+ },
53
+ accent: {
54
+ info: { light: '#1b5fa1', dark: '#6fb2f0' },
55
+ success: { light: '#0f7b4f', dark: '#3ddc97' },
56
+ warning: { light: '#8a5a00', dark: '#f5b544' },
57
+ danger: { light: '#a11b1b', dark: '#ff6b6b' },
58
+ neutral: { light: '#4a5568', dark: '#a6b0c0' },
59
+ },
60
+ });
61
+ //# sourceMappingURL=palette.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"palette.js","sourceRoot":"","sources":["../../../../../../libs/style/src/lib/tokens/palette.ts"],"names":[],"mappings":"AAkBA,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,IAAY,EAAE,IAAe,EAAc,EAAE,CAC1E,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAe,CAAC;AAY3D;;;;GAIG;AACH,MAAM,aAAa,GAAwC;IACzD,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;CACjB,CAAC;AAEF,MAAM,UAAU,aAAa,CAC3B,IAAU;IAEV,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC;QAC5C,KAAK;QACL,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;YAC3C,IAAI;YACJ,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC;SAC9D,CAAC,CACH;KACF,CAAC,CACc,CAAC;AACrB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,MAAM,GA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E,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;KAC/C;CACF,CAAC,CAAC","sourcesContent":["/**\n * The palette.\n *\n * A token carries **both** of its values and its role. `palette.surface.raised`\n * is a value, not a string, and dark mode is not a second file to keep in sync\n * by hand — the emitter reads the `dark` side off the same token.\n *\n * The role is what later makes `defineAxis(..., { writes: onlyVarsOfKind(color) })`\n * meaningful, and what lets the graph answer \"which surfaces does this token\n * paint?\" without parsing CSS.\n */\nimport type { ColorRole, ColorValue } from './units.ts';\n\nexport interface PaletteEntry {\n readonly light: string;\n readonly dark: string;\n}\n\nconst swatch = (light: string, dark: string, role: ColorRole): ColorValue =>\n ({ css: light, dark, role, unproven: '' }) as ColorValue;\n\nexport type PaletteSpec = Readonly<\n Record<string, Readonly<Record<string, PaletteEntry>>>\n>;\n\nexport type Palette<Spec extends PaletteSpec> = {\n readonly [Group in keyof Spec]: {\n readonly [Token in keyof Spec[Group]]: ColorValue;\n };\n};\n\n/**\n * Roles are derived from the group name rather than repeated on every entry:\n * a token in `surface` paints a surface. A group the map does not know gets\n * `'none'`, which is honest — it says the role is unknown instead of guessing.\n */\nconst ROLE_OF_GROUP: Readonly<Record<string, ColorRole>> = {\n surface: 'surface',\n text: 'text',\n border: 'border',\n accent: 'accent',\n};\n\nexport function definePalette<const Spec extends PaletteSpec>(\n spec: Spec,\n): Palette<Spec> {\n return Object.fromEntries(\n Object.entries(spec).map(([group, tokens]) => [\n group,\n Object.fromEntries(\n Object.entries(tokens).map(([name, pair]) => [\n name,\n swatch(pair.light, pair.dark, ROLE_OF_GROUP[group] ?? 'none'),\n ]),\n ),\n ]),\n ) as Palette<Spec>;\n}\n\n/**\n * The dark side of a token, as a value.\n *\n * A token carries both of its values; this is how a sheet reaches the other\n * one. Written once, at the theme level — `when(scheme.dark, [set(theme.ink,\n * darkOf(palette.text.strong))])` — rather than at every use site, which is\n * what keeps dark mode from becoming a second design system to maintain.\n *\n * The role travels with it: the dark side of a surface is still a surface.\n */\nexport const darkOf = (token: ColorValue): ColorValue =>\n ({\n css: token.dark,\n dark: token.dark,\n role: token.role,\n unproven: token.unproven,\n }) as ColorValue;\n\nexport const palette = definePalette({\n surface: {\n page: { light: '#ffffff', dark: '#0b0d11' },\n raised: { light: '#f6f7f9', dark: '#151922' },\n sunken: { light: '#eceef2', dark: '#0f131a' },\n },\n text: {\n strong: { light: '#111318', dark: '#f2f4f8' },\n muted: { light: '#5b6472', dark: '#98a2b3' },\n inverted: { light: '#ffffff', dark: '#0b0d11' },\n },\n border: {\n subtle: { light: '#e3e6ea', dark: '#232936' },\n strong: { light: '#c3c9d2', dark: '#39414f' },\n },\n accent: {\n info: { light: '#1b5fa1', dark: '#6fb2f0' },\n success: { light: '#0f7b4f', dark: '#3ddc97' },\n warning: { light: '#8a5a00', dark: '#f5b544' },\n danger: { light: '#a11b1b', dark: '#ff6b6b' },\n neutral: { light: '#4a5568', dark: '#a6b0c0' },\n },\n});\n"]}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The closed scales.
3
+ *
4
+ * `space(4.5)` does not compile: the step is a union of literals, not a
5
+ * `number`. When a step is missing, it is added here — that is the whole point
6
+ * of a scale, and the reason `unsafeLength` exists as the marked alternative
7
+ * rather than an arbitrary-value syntax.
8
+ */
9
+ import { type LengthValue } from './units.ts';
10
+ export type SpaceStep = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16 | 20 | 24;
11
+ export declare const space: (step: SpaceStep) => LengthValue;
12
+ export declare const radii: {
13
+ readonly none: LengthValue;
14
+ readonly sm: LengthValue;
15
+ readonly md: LengthValue;
16
+ readonly lg: LengthValue;
17
+ readonly xl: LengthValue;
18
+ readonly full: LengthValue;
19
+ };
20
+ /**
21
+ * Named `lineWidth` rather than `borderWidth`: the generated table already
22
+ * exports a `borderWidth` **helper**, and one name for two concepts in the same
23
+ * import is the collision this package spends its effort avoiding.
24
+ */
25
+ export declare const lineWidth: {
26
+ readonly hairline: LengthValue;
27
+ readonly thick: LengthValue;
28
+ };
29
+ /**
30
+ * A type scale entry **is** a length, and carries its line height alongside.
31
+ *
32
+ * Being a length is what lets it flow into the generated `font-size` helper
33
+ * without a conversion; carrying the line height is what lets `font(text.sm)`
34
+ * emit both declarations, which is the only shape in which the pair cannot
35
+ * drift apart.
36
+ */
37
+ export interface FontSizeToken extends LengthValue {
38
+ readonly lineHeight: string;
39
+ }
40
+ export declare const text: {
41
+ readonly xs: FontSizeToken;
42
+ readonly sm: FontSizeToken;
43
+ readonly base: FontSizeToken;
44
+ readonly lg: FontSizeToken;
45
+ readonly xl: FontSizeToken;
46
+ };
47
+ //# sourceMappingURL=scales.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scales.d.ts","sourceRoot":"","sources":["../../../../../../libs/style/src/lib/tokens/scales.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzD,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAkB/E,eAAO,MAAM,KAAK,GAAI,MAAM,SAAS,KAAG,WACJ,CAAC;AAErC,eAAO,MAAM,KAAK;;;;;;;CAOR,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,SAAS;;;CAGZ,CAAC;AAEX;;;;;;;GAOG;AACH,MAAM,WAAW,aAAc,SAAQ,WAAW;IAChD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAKD,eAAO,MAAM,IAAI;;;;;;CAMP,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The closed scales.
3
+ *
4
+ * `space(4.5)` does not compile: the step is a union of literals, not a
5
+ * `number`. When a step is missing, it is added here — that is the whole point
6
+ * of a scale, and the reason `unsafeLength` exists as the marked alternative
7
+ * rather than an arbitrary-value syntax.
8
+ */
9
+ import { rawLength } from "./units.js";
10
+ const SPACE_REM = {
11
+ 0: 0,
12
+ 1: 0.25,
13
+ 2: 0.5,
14
+ 3: 0.75,
15
+ 4: 1,
16
+ 5: 1.25,
17
+ 6: 1.5,
18
+ 8: 2,
19
+ 10: 2.5,
20
+ 12: 3,
21
+ 16: 4,
22
+ 20: 5,
23
+ 24: 6,
24
+ };
25
+ export const space = (step) => rawLength(`${SPACE_REM[step]}rem`);
26
+ export const radii = {
27
+ none: rawLength('0'),
28
+ sm: rawLength('0.25rem'),
29
+ md: rawLength('0.375rem'),
30
+ lg: rawLength('0.5rem'),
31
+ xl: rawLength('0.75rem'),
32
+ full: rawLength('9999px'),
33
+ };
34
+ /**
35
+ * Named `lineWidth` rather than `borderWidth`: the generated table already
36
+ * exports a `borderWidth` **helper**, and one name for two concepts in the same
37
+ * import is the collision this package spends its effort avoiding.
38
+ */
39
+ export const lineWidth = {
40
+ hairline: rawLength('1px'),
41
+ thick: rawLength('2px'),
42
+ };
43
+ const size = (css, lineHeight) => ({ ...rawLength(css), lineHeight });
44
+ export const text = {
45
+ xs: size('0.75rem', '1rem'),
46
+ sm: size('0.875rem', '1.25rem'),
47
+ base: size('1rem', '1.5rem'),
48
+ lg: size('1.125rem', '1.75rem'),
49
+ xl: size('1.375rem', '1.875rem'),
50
+ };
51
+ //# sourceMappingURL=scales.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scales.js","sourceRoot":"","sources":["../../../../../../libs/style/src/lib/tokens/scales.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,SAAS,EAAoB,MAAM,YAAY,CAAC;AAIzD,MAAM,SAAS,GAAwC;IACrD,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,IAAI;I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* The closed scales.\n *\n * `space(4.5)` does not compile: the step is a union of literals, not a\n * `number`. When a step is missing, it is added here — that is the whole point\n * of a scale, and the reason `unsafeLength` exists as the marked alternative\n * rather than an arbitrary-value syntax.\n */\nimport { rawLength, type LengthValue } from './units.ts';\n\nexport type SpaceStep = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16 | 20 | 24;\n\nconst SPACE_REM: Readonly<Record<SpaceStep, number>> = {\n 0: 0,\n 1: 0.25,\n 2: 0.5,\n 3: 0.75,\n 4: 1,\n 5: 1.25,\n 6: 1.5,\n 8: 2,\n 10: 2.5,\n 12: 3,\n 16: 4,\n 20: 5,\n 24: 6,\n};\n\nexport const space = (step: SpaceStep): LengthValue =>\n rawLength(`${SPACE_REM[step]}rem`);\n\nexport const radii = {\n none: rawLength('0'),\n sm: rawLength('0.25rem'),\n md: rawLength('0.375rem'),\n lg: rawLength('0.5rem'),\n xl: rawLength('0.75rem'),\n full: rawLength('9999px'),\n} as const;\n\n/**\n * Named `lineWidth` rather than `borderWidth`: the generated table already\n * exports a `borderWidth` **helper**, and one name for two concepts in the same\n * import is the collision this package spends its effort avoiding.\n */\nexport const lineWidth = {\n hairline: rawLength('1px'),\n thick: rawLength('2px'),\n} as const;\n\n/**\n * A type scale entry **is** a length, and carries its line height alongside.\n *\n * Being a length is what lets it flow into the generated `font-size` helper\n * without a conversion; carrying the line height is what lets `font(text.sm)`\n * emit both declarations, which is the only shape in which the pair cannot\n * drift apart.\n */\nexport interface FontSizeToken extends LengthValue {\n readonly lineHeight: string;\n}\n\nconst size = (css: string, lineHeight: string): FontSizeToken =>\n ({ ...rawLength(css), lineHeight }) as FontSizeToken;\n\nexport const text = {\n xs: size('0.75rem', '1rem'),\n sm: size('0.875rem', '1.25rem'),\n base: size('1rem', '1.5rem'),\n lg: size('1.125rem', '1.75rem'),\n xl: size('1.375rem', '1.875rem'),\n} as const;\n"]}
@@ -0,0 +1,114 @@
1
+ /**
2
+ * The branded value types every helper in the design system speaks.
3
+ *
4
+ * Each value is a **nominal object** — `{ readonly [LENGTH]: true }` with
5
+ * `LENGTH` a `unique symbol` — never a `string & { __length?: true }`. An
6
+ * optional phantom on a primitive base brands nothing: `'blabla'` stays
7
+ * assignable and the whole guarantee collapses in silence, with every test
8
+ * still green. That failure mode is the most expensive one this package can
9
+ * have, which is why the shape is an object and why `tokens.spec.ts` measures
10
+ * the brand itself rather than a handful of hand-picked cases.
11
+ *
12
+ * The assignability lattice is carried by the brands, not by a separate table:
13
+ * an integer *is* a number (it carries both brands), a length *is* a
14
+ * length-percentage (the target is a union). See `kinds.ts`.
15
+ */
16
+ declare const LENGTH: unique symbol;
17
+ declare const PERCENT: unique symbol;
18
+ declare const NUMBER: unique symbol;
19
+ declare const INTEGER: unique symbol;
20
+ declare const ANGLE: unique symbol;
21
+ declare const TIME: unique symbol;
22
+ declare const COLOR: unique symbol;
23
+ declare const IDENT: unique symbol;
24
+ declare const CSS_STRING: unique symbol;
25
+ declare const URL_VALUE: unique symbol;
26
+ /** Shared by every value: the CSS text, and the debt it carries. */
27
+ export interface StyleValue {
28
+ readonly css: string;
29
+ /**
30
+ * Non-empty when the value could not be proven — see `unsafeLength`. It
31
+ * travels with the declaration all the way to the graph, which is what makes
32
+ * the debt countable instead of invisible.
33
+ */
34
+ readonly unproven: string;
35
+ }
36
+ export interface LengthValue extends StyleValue {
37
+ readonly [LENGTH]: true;
38
+ }
39
+ export interface PercentValue extends StyleValue {
40
+ readonly [PERCENT]: true;
41
+ }
42
+ export interface NumberValue extends StyleValue {
43
+ readonly [NUMBER]: true;
44
+ }
45
+ /** An integer carries the number brand too: `<integer>` is a `<number>`. */
46
+ export interface IntegerValue extends NumberValue {
47
+ readonly [INTEGER]: true;
48
+ }
49
+ export interface AngleValue extends StyleValue {
50
+ readonly [ANGLE]: true;
51
+ }
52
+ export interface TimeValue extends StyleValue {
53
+ readonly [TIME]: true;
54
+ }
55
+ export type ColorRole = 'surface' | 'text' | 'border' | 'accent' | 'none';
56
+ export interface ColorValue extends StyleValue {
57
+ readonly [COLOR]: true;
58
+ /** The dark counterpart. A palette token carries both of its values. */
59
+ readonly dark: string;
60
+ readonly role: ColorRole;
61
+ }
62
+ /** `<custom-ident>` — a name, never a free string. */
63
+ export interface IdentValue extends StyleValue {
64
+ readonly [IDENT]: true;
65
+ }
66
+ /** `<string>` — quoted at construction, so it cannot break out of the rule. */
67
+ export interface CssStringValue extends StyleValue {
68
+ readonly [CSS_STRING]: true;
69
+ }
70
+ /** `<url>` — wrapped at construction for the same reason. */
71
+ export interface UrlValue extends StyleValue {
72
+ readonly [URL_VALUE]: true;
73
+ }
74
+ /** `<length-percentage>`, spelled as the union the grammar actually means. */
75
+ export type LengthPercentageValue = LengthValue | PercentValue;
76
+ export declare const rawLength: (css: string, unproven?: string) => LengthValue;
77
+ /**
78
+ * Raw units live under a namespace rather than at the top level for a dull but
79
+ * real reason: `px` is already taken by `padding-inline` on the property side.
80
+ * Two short names for two different concepts in the same import is a guaranteed
81
+ * collision — better settled here, once.
82
+ */
83
+ export declare const unit: {
84
+ readonly rem: (amount: number) => LengthValue;
85
+ readonly px: (amount: number) => LengthValue;
86
+ readonly em: (amount: number) => LengthValue;
87
+ readonly ch: (amount: number) => LengthValue;
88
+ readonly vw: (amount: number) => LengthValue;
89
+ readonly vh: (amount: number) => LengthValue;
90
+ readonly pct: (amount: number) => PercentValue;
91
+ readonly deg: (amount: number) => AngleValue;
92
+ readonly ms: (amount: number) => TimeValue;
93
+ readonly s: (amount: number) => TimeValue;
94
+ };
95
+ export declare const num: (amount: number) => NumberValue;
96
+ export declare const int: (amount: number) => IntegerValue;
97
+ /**
98
+ * The three types the generator cannot close, each behind its own constructor
99
+ * so that no generated signature ever has to accept a bare `string`.
100
+ */
101
+ export declare const ident: (name: string) => IdentValue;
102
+ export declare const cssString: (text: string) => CssStringValue;
103
+ export declare const url: (href: string) => UrlValue;
104
+ /**
105
+ * The only way out of the scales, and it leaves a trace.
106
+ *
107
+ * Without this door a blocked agent bypasses the design system entirely; with
108
+ * it unmarked, the bypass is silent. `unproven` bubbles up to the graph, so the
109
+ * debt is countable. There is no `[17px]` arbitrary-value syntax: if a value is
110
+ * missing from a scale, it is added to the scale.
111
+ */
112
+ export declare const unsafeLength: <Reason extends string>(css: string, reason: Reason) => LengthValue;
113
+ export {};
114
+ //# sourceMappingURL=units.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"units.d.ts","sourceRoot":"","sources":["../../../../../../libs/style/src/lib/tokens/units.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,CAAC,MAAM,MAAM,EAAE,OAAO,MAAM,CAAC;AACpC,OAAO,CAAC,MAAM,OAAO,EAAE,OAAO,MAAM,CAAC;AACrC,OAAO,CAAC,MAAM,MAAM,EAAE,OAAO,MAAM,CAAC;AACpC,OAAO,CAAC,MAAM,OAAO,EAAE,OAAO,MAAM,CAAC;AACrC,OAAO,CAAC,MAAM,KAAK,EAAE,OAAO,MAAM,CAAC;AACnC,OAAO,CAAC,MAAM,IAAI,EAAE,OAAO,MAAM,CAAC;AAClC,OAAO,CAAC,MAAM,KAAK,EAAE,OAAO,MAAM,CAAC;AACnC,OAAO,CAAC,MAAM,KAAK,EAAE,OAAO,MAAM,CAAC;AACnC,OAAO,CAAC,MAAM,UAAU,EAAE,OAAO,MAAM,CAAC;AACxC,OAAO,CAAC,MAAM,SAAS,EAAE,OAAO,MAAM,CAAC;AAEvC,oEAAoE;AACpE,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,WAAY,SAAQ,UAAU;IAC7C,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC9C,QAAQ,CAAC,CAAC,OAAO,CAAC,EA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KG;AACH,eAAO,MAAM,IAAI;2BACD,MAAM,KAAG,WAAW;0BACrB,MAAM,KAAG,WAAW;0BACpB,MAAM,KAAG,WAAW;0BACpB,MAAM,KAAG,WAAW;0BACpB,MAAM,KAAG,WAAW;0BACpB,MAAM,KAAG,WAAW;2BACnB,MAAM,KAAG,YAAY;2BACrB,MAAM,KAAG,UAAU;0BACpB,MAAM,KAAG,SAAS;yBACnB,MAAM,KAAG,SAAS;CACtB,CAAC;AAEX,eAAO,MAAM,GAAG,GAAI,QAAQ,MAAM,KAAG,WACD,CAAC;AAErC,eAAO,MAAM,GAAG,GAAI,QAAQ,MAAM,KAAG,YACY,CAAC;AAElD;;;GAGG;AACH,eAAO,MAAM,KAAK,GAAI,MAAM,MAAM,KAAG,UACmB,CAAC;AAEzD,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,KAAG,cACI,CAAC;AAE9C,eAAO,MAAM,GAAG,GAAI,MAAM,MAAM,KAAG,QACc,CAAC;AAElD;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,SAAS,MAAM,EAChD,KAAK,MAAM,EACX,QAAQ,MAAM,KACb,WAAqC,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * The branded value types every helper in the design system speaks.
3
+ *
4
+ * Each value is a **nominal object** — `{ readonly [LENGTH]: true }` with
5
+ * `LENGTH` a `unique symbol` — never a `string & { __length?: true }`. An
6
+ * optional phantom on a primitive base brands nothing: `'blabla'` stays
7
+ * assignable and the whole guarantee collapses in silence, with every test
8
+ * still green. That failure mode is the most expensive one this package can
9
+ * have, which is why the shape is an object and why `tokens.spec.ts` measures
10
+ * the brand itself rather than a handful of hand-picked cases.
11
+ *
12
+ * The assignability lattice is carried by the brands, not by a separate table:
13
+ * an integer *is* a number (it carries both brands), a length *is* a
14
+ * length-percentage (the target is a union). See `kinds.ts`.
15
+ */
16
+ const value = (css, unproven = '') => ({ css, unproven });
17
+ export const rawLength = (css, unproven = '') => value(css, unproven);
18
+ /**
19
+ * Raw units live under a namespace rather than at the top level for a dull but
20
+ * real reason: `px` is already taken by `padding-inline` on the property side.
21
+ * Two short names for two different concepts in the same import is a guaranteed
22
+ * collision — better settled here, once.
23
+ */
24
+ export const unit = {
25
+ rem: (amount) => rawLength(`${amount}rem`),
26
+ px: (amount) => rawLength(`${amount}px`),
27
+ em: (amount) => rawLength(`${amount}em`),
28
+ ch: (amount) => rawLength(`${amount}ch`),
29
+ vw: (amount) => rawLength(`${amount}vw`),
30
+ vh: (amount) => rawLength(`${amount}vh`),
31
+ pct: (amount) => value(`${amount}%`),
32
+ deg: (amount) => value(`${amount}deg`),
33
+ ms: (amount) => value(`${amount}ms`),
34
+ s: (amount) => value(`${amount}s`),
35
+ };
36
+ export const num = (amount) => value(String(amount));
37
+ export const int = (amount) => value(String(Math.trunc(amount)));
38
+ /**
39
+ * The three types the generator cannot close, each behind its own constructor
40
+ * so that no generated signature ever has to accept a bare `string`.
41
+ */
42
+ export const ident = (name) => value(name.replace(/[^A-Za-z0-9_-]/g, ''));
43
+ export const cssString = (text) => value(JSON.stringify(text));
44
+ export const url = (href) => value(`url(${JSON.stringify(href)})`);
45
+ /**
46
+ * The only way out of the scales, and it leaves a trace.
47
+ *
48
+ * Without this door a blocked agent bypasses the design system entirely; with
49
+ * it unmarked, the bypass is silent. `unproven` bubbles up to the graph, so the
50
+ * debt is countable. There is no `[17px]` arbitrary-value syntax: if a value is
51
+ * missing from a scale, it is added to the scale.
52
+ */
53
+ export const unsafeLength = (css, reason) => rawLength(css, reason);
54
+ //# sourceMappingURL=units.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"units.js","sourceRoot":"","sources":["../../../../../../libs/style/src/lib/tokens/units.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA4EH,MAAM,KAAK,GAAG,CAAQ,GAAW,EAAE,QAAQ,GAAG,EAAE,EAAS,EAAE,CACzD,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAU,CAA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ClD,KAAK,CAAe,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAElD;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,IAAY,EAAc,EAAE,CAChD,KAAK,CAAa,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC,CAAC;AAEzD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAY,EAAkB,EAAE,CACxD,KAAK,CAAiB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;AAE9C,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,IAAY,EAAY,EAAE,CAC5C,KAAK,CAAW,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,GAAW,EACX,MAAc,EACD,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC","sourcesContent":["/**\n * The branded value types every helper in the design system speaks.\n *\n * Each value is a **nominal object** — `{ readonly [LENGTH]: true }` with\n * `LENGTH` a `unique symbol` — never a `string & { __length?: true }`. An\n * optional phantom on a primitive base brands nothing: `'blabla'` stays\n * assignable and the whole guarantee collapses in silence, with every test\n * still green. That failure mode is the most expensive one this package can\n * have, which is why the shape is an object and why `tokens.spec.ts` measures\n * the brand itself rather than a handful of hand-picked cases.\n *\n * The assignability lattice is carried by the brands, not by a separate table:\n * an integer *is* a number (it carries both brands), a length *is* a\n * length-percentage (the target is a union). See `kinds.ts`.\n */\n\ndeclare const LENGTH: unique symbol;\ndeclare const PERCENT: unique symbol;\ndeclare const NUMBER: unique symbol;\ndeclare const INTEGER: unique symbol;\ndeclare const ANGLE: unique symbol;\ndeclare const TIME: unique symbol;\ndeclare const COLOR: unique symbol;\ndeclare const IDENT: unique symbol;\ndeclare const CSS_STRING: unique symbol;\ndeclare const URL_VALUE: unique symbol;\n\n/** Shared by every value: the CSS text, and the debt it carries. */\nexport interface StyleValue {\n readonly css: string;\n /**\n * Non-empty when the value could not be proven — see `unsafeLength`. It\n * travels with the declaration all the way to the graph, which is what makes\n * the debt countable instead of invisible.\n */\n readonly unproven: string;\n}\n\nexport interface LengthValue extends StyleValue {\n readonly [LENGTH]: true;\n}\n\nexport interface PercentValue extends StyleValue {\n readonly [PERCENT]: true;\n}\n\nexport interface NumberValue extends StyleValue {\n readonly [NUMBER]: true;\n}\n\n/** An integer carries the number brand too: `<integer>` is a `<number>`. */\nexport interface IntegerValue extends NumberValue {\n readonly [INTEGER]: true;\n}\n\nexport interface AngleValue extends StyleValue {\n readonly [ANGLE]: true;\n}\n\nexport interface TimeValue extends StyleValue {\n readonly [TIME]: true;\n}\n\nexport type ColorRole = 'surface' | 'text' | 'border' | 'accent' | 'none';\n\nexport interface ColorValue extends StyleValue {\n readonly [COLOR]: true;\n /** The dark counterpart. A palette token carries both of its values. */\n readonly dark: string;\n readonly role: ColorRole;\n}\n\n/** `<custom-ident>` — a name, never a free string. */\nexport interface IdentValue extends StyleValue {\n readonly [IDENT]: true;\n}\n\n/** `<string>` — quoted at construction, so it cannot break out of the rule. */\nexport interface CssStringValue extends StyleValue {\n readonly [CSS_STRING]: true;\n}\n\n/** `<url>` — wrapped at construction for the same reason. */\nexport interface UrlValue extends StyleValue {\n readonly [URL_VALUE]: true;\n}\n\n/** `<length-percentage>`, spelled as the union the grammar actually means. */\nexport type LengthPercentageValue = LengthValue | PercentValue;\n\nconst value = <Brand>(css: string, unproven = ''): Brand =>\n ({ css, unproven }) as Brand;\n\nexport const rawLength = (css: string, unproven = ''): LengthValue =>\n value<LengthValue>(css, unproven);\n\n/**\n * Raw units live under a namespace rather than at the top level for a dull but\n * real reason: `px` is already taken by `padding-inline` on the property side.\n * Two short names for two different concepts in the same import is a guaranteed\n * collision — better settled here, once.\n */\nexport const unit = {\n rem: (amount: number): LengthValue => rawLength(`${amount}rem`),\n px: (amount: number): LengthValue => rawLength(`${amount}px`),\n em: (amount: number): LengthValue => rawLength(`${amount}em`),\n ch: (amount: number): LengthValue => rawLength(`${amount}ch`),\n vw: (amount: number): LengthValue => rawLength(`${amount}vw`),\n vh: (amount: number): LengthValue => rawLength(`${amount}vh`),\n pct: (amount: number): PercentValue => value<PercentValue>(`${amount}%`),\n deg: (amount: number): AngleValue => value<AngleValue>(`${amount}deg`),\n ms: (amount: number): TimeValue => value<TimeValue>(`${amount}ms`),\n s: (amount: number): TimeValue => value<TimeValue>(`${amount}s`),\n} as const;\n\nexport const num = (amount: number): NumberValue =>\n value<NumberValue>(String(amount));\n\nexport const int = (amount: number): IntegerValue =>\n value<IntegerValue>(String(Math.trunc(amount)));\n\n/**\n * The three types the generator cannot close, each behind its own constructor\n * so that no generated signature ever has to accept a bare `string`.\n */\nexport const ident = (name: string): IdentValue =>\n value<IdentValue>(name.replace(/[^A-Za-z0-9_-]/g, ''));\n\nexport const cssString = (text: string): CssStringValue =>\n value<CssStringValue>(JSON.stringify(text));\n\nexport const url = (href: string): UrlValue =>\n value<UrlValue>(`url(${JSON.stringify(href)})`);\n\n/**\n * The only way out of the scales, and it leaves a trace.\n *\n * Without this door a blocked agent bypasses the design system entirely; with\n * it unmarked, the bypass is silent. `unproven` bubbles up to the graph, so the\n * debt is countable. There is no `[17px]` arbitrary-value syntax: if a value is\n * missing from a scale, it is added to the scale.\n */\nexport const unsafeLength = <Reason extends string>(\n css: string,\n reason: Reason,\n): LengthValue => rawLength(css, reason);\n"]}
@@ -0,0 +1,64 @@
1
+ import type { AtomicRule, RegisteredClass } from '../lib/styles.ts';
2
+ import type { CssVarDeclaration } from '../lib/css-vars.ts';
3
+ /** The layer order is fixed here so that no import order can change it. */
4
+ export declare const LAYERS: readonly ["reset", "tokens", "components", "variants", "overrides"];
5
+ /**
6
+ * Properties the vocabulary owns.
7
+ *
8
+ * The generated table, plus the ones only an obligation can write. `overflow`
9
+ * is in the second set and not the first on purpose: it is reachable through
10
+ * `provides(scrollPort.block)` and through nothing else.
11
+ */
12
+ export declare const knownProperties: () => ReadonlySet<string>;
13
+ export declare class UnknownCssError extends Error {
14
+ readonly property: string;
15
+ readonly source: string;
16
+ constructor(property: string, source: string);
17
+ }
18
+ /**
19
+ * The last net under the escape hatches.
20
+ *
21
+ * A keyword or property that slipped past the types would otherwise become CSS
22
+ * the browser silently drops — the exact failure the package exists to prevent,
23
+ * arriving at the last possible moment.
24
+ */
25
+ export declare function validateAtoms(atoms: readonly AtomicRule[], source?: string): void;
26
+ /**
27
+ * The stylesheet.
28
+ *
29
+ * Unconditional atoms land in `components`, conditional ones in `variants`, so
30
+ * a variant always wins over the base without anyone counting selector
31
+ * specificity. Ordering is by class name rather than by registration order:
32
+ * the output must not depend on which module the bundler happened to load
33
+ * first, or two identical builds would produce two different files.
34
+ */
35
+ export declare function renderCss(atoms: readonly AtomicRule[], vars: readonly CssVarDeclaration[]): string;
36
+ export interface StyleDump {
37
+ readonly classes: readonly {
38
+ readonly key: string;
39
+ readonly className: string;
40
+ readonly axes: Readonly<Record<string, readonly string[]>>;
41
+ readonly atoms: readonly string[];
42
+ readonly unproven: readonly string[];
43
+ readonly requires: readonly string[];
44
+ readonly provides: readonly string[];
45
+ readonly violates: readonly string[];
46
+ }[];
47
+ readonly atoms: readonly {
48
+ readonly className: string;
49
+ readonly property: string;
50
+ readonly value: string;
51
+ readonly conditions: readonly string[];
52
+ readonly unproven: string;
53
+ }[];
54
+ readonly vars: readonly CssVarDeclaration[];
55
+ }
56
+ /**
57
+ * What the dependency graph consumes.
58
+ *
59
+ * Emitted by the plugin rather than re-derived by an AST pass: there is one
60
+ * graph and two producers, and a second, approximate evaluation of the DSL
61
+ * would disagree with this one sooner or later.
62
+ */
63
+ export declare function styleDump(classes: readonly RegisteredClass[], atoms: readonly AtomicRule[], vars: readonly CssVarDeclaration[]): StyleDump;
64
+ //# sourceMappingURL=emit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit.d.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