@hozo/engine 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +8 -4
  3. package/dist/authored-gap.d.ts +11 -0
  4. package/dist/authored-gap.d.ts.map +1 -0
  5. package/dist/authored-gap.js +45 -0
  6. package/dist/authored-gap.js.map +1 -0
  7. package/dist/class-resolver.d.ts +41 -3
  8. package/dist/class-resolver.d.ts.map +1 -1
  9. package/dist/class-resolver.js +160 -23
  10. package/dist/class-resolver.js.map +1 -1
  11. package/dist/class-transition.d.ts +32 -0
  12. package/dist/class-transition.d.ts.map +1 -0
  13. package/dist/class-transition.js +48 -0
  14. package/dist/class-transition.js.map +1 -0
  15. package/dist/color-transition.d.ts +2 -0
  16. package/dist/color-transition.d.ts.map +1 -1
  17. package/dist/color-transition.js +4 -0
  18. package/dist/color-transition.js.map +1 -1
  19. package/dist/cx.d.ts +4 -0
  20. package/dist/cx.d.ts.map +1 -0
  21. package/dist/cx.js +17 -0
  22. package/dist/cx.js.map +1 -0
  23. package/dist/dom-style.d.ts +1 -0
  24. package/dist/dom-style.d.ts.map +1 -1
  25. package/dist/dom-style.js +4 -0
  26. package/dist/dom-style.js.map +1 -1
  27. package/dist/gap-styles.d.ts +3 -0
  28. package/dist/gap-styles.d.ts.map +1 -0
  29. package/dist/gap-styles.js +7 -0
  30. package/dist/gap-styles.js.map +1 -0
  31. package/dist/generated/animated.d.ts +3 -0
  32. package/dist/generated/animated.d.ts.map +1 -0
  33. package/dist/generated/animated.js +7 -0
  34. package/dist/generated/animated.js.map +1 -0
  35. package/dist/generated/class-resolver.d.ts +1 -1
  36. package/dist/generated/class-resolver.d.ts.map +1 -1
  37. package/dist/generated/class-resolver.js +1 -1
  38. package/dist/generated/class-resolver.js.map +1 -1
  39. package/dist/generated/gap-styles.d.ts +3 -0
  40. package/dist/generated/gap-styles.d.ts.map +1 -0
  41. package/dist/generated/gap-styles.js +4 -0
  42. package/dist/generated/gap-styles.js.map +1 -0
  43. package/dist/generated/safe-area.d.ts +1 -1
  44. package/dist/generated/safe-area.d.ts.map +1 -1
  45. package/dist/generated/safe-area.js +1 -1
  46. package/dist/generated/safe-area.js.map +1 -1
  47. package/dist/generated/spread-styles.d.ts +2 -0
  48. package/dist/generated/spread-styles.d.ts.map +1 -0
  49. package/dist/generated/spread-styles.js +3 -0
  50. package/dist/generated/spread-styles.js.map +1 -0
  51. package/dist/generated/text-inheritance-protocol.d.ts +3 -0
  52. package/dist/generated/text-inheritance-protocol.d.ts.map +1 -0
  53. package/dist/generated/text-inheritance-protocol.js +3 -0
  54. package/dist/generated/text-inheritance-protocol.js.map +1 -0
  55. package/dist/generated/text-size-context.d.ts +2 -0
  56. package/dist/generated/text-size-context.d.ts.map +1 -0
  57. package/dist/generated/text-size-context.js +3 -0
  58. package/dist/generated/text-size-context.js.map +1 -0
  59. package/dist/hooks.native.js +1 -1
  60. package/dist/index.d.ts +6 -3
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +6 -3
  63. package/dist/index.js.map +1 -1
  64. package/dist/presence-context.d.ts +15 -0
  65. package/dist/presence-context.d.ts.map +1 -0
  66. package/dist/presence-context.js +11 -0
  67. package/dist/presence-context.js.map +1 -0
  68. package/dist/project.d.ts +8 -0
  69. package/dist/project.d.ts.map +1 -1
  70. package/dist/project.js +7 -0
  71. package/dist/project.js.map +1 -1
  72. package/dist/project.native.d.ts +1 -1
  73. package/dist/project.native.d.ts.map +1 -1
  74. package/dist/project.native.js +1 -1
  75. package/dist/project.native.js.map +1 -1
  76. package/dist/responder.d.ts +34 -0
  77. package/dist/responder.d.ts.map +1 -1
  78. package/dist/responder.js +52 -0
  79. package/dist/responder.js.map +1 -1
  80. package/dist/runtime-transition.native.d.ts +37 -0
  81. package/dist/runtime-transition.native.d.ts.map +1 -0
  82. package/dist/runtime-transition.native.js +252 -0
  83. package/dist/runtime-transition.native.js.map +1 -0
  84. package/dist/safe-area.native.d.ts +12 -0
  85. package/dist/safe-area.native.d.ts.map +1 -1
  86. package/dist/safe-area.native.js +44 -21
  87. package/dist/safe-area.native.js.map +1 -1
  88. package/dist/spread-styles.d.ts +14 -0
  89. package/dist/spread-styles.d.ts.map +1 -0
  90. package/dist/spread-styles.js +56 -0
  91. package/dist/spread-styles.js.map +1 -0
  92. package/dist/text-inheritance.d.ts +35 -0
  93. package/dist/text-inheritance.d.ts.map +1 -0
  94. package/dist/text-inheritance.js +48 -0
  95. package/dist/text-inheritance.js.map +1 -0
  96. package/dist/text-style.d.ts +8 -0
  97. package/dist/text-style.d.ts.map +1 -0
  98. package/dist/text-style.js +34 -0
  99. package/dist/text-style.js.map +1 -0
  100. package/package.json +22 -2
  101. package/src/authored-gap.ts +41 -0
  102. package/src/class-resolver.ts +213 -7
  103. package/src/class-transition.ts +71 -0
  104. package/src/color-transition.ts +5 -0
  105. package/src/cx.ts +18 -0
  106. package/src/dom-style.ts +3 -0
  107. package/src/gap-styles.ts +11 -0
  108. package/src/generated/animated.ts +15 -0
  109. package/src/generated/class-resolver.ts +7 -1
  110. package/src/generated/gap-styles.ts +3 -0
  111. package/src/generated/safe-area.ts +5 -1
  112. package/src/generated/spread-styles.ts +2 -0
  113. package/src/generated/text-inheritance-protocol.ts +9 -0
  114. package/src/generated/text-size-context.ts +2 -0
  115. package/src/hooks.native.ts +1 -1
  116. package/src/index.ts +17 -2
  117. package/src/presence-context.ts +27 -0
  118. package/src/project.native.ts +1 -1
  119. package/src/project.ts +9 -0
  120. package/src/responder.ts +52 -0
  121. package/src/runtime-transition.native.tsx +324 -0
  122. package/src/safe-area.native.ts +59 -24
  123. package/src/spread-styles.ts +74 -0
  124. package/src/text-inheritance.ts +75 -0
  125. package/src/text-style.ts +35 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @hozo/engine
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1462](https://github.com/iray-tno/hozo/pull/1462) [`add3e7b`](https://github.com/iray-tno/hozo/commit/add3e7b2c5a152c770eabee7d09d723e925958e1) Thanks [@iray-tno](https://github.com/iray-tno)! - `HozoAnimated` and `PresenceContext` move from `@hozo/primitives` to `@hozo/engine` (`@hozo/engine/generated/animated`), so `@hozo/patterns` can run them. `@hozo/primitives/generated/animated` is gone; compiled output imports them through `@hozo/core/generated/animated` as before.
8
+
9
+ - [#1597](https://github.com/iray-tno/hozo/pull/1597) [`b3df5b7`](https://github.com/iray-tno/hozo/commit/b3df5b73a8ec104fe407d89472e4339411de311d) Thanks [@iray-tno](https://github.com/iray-tno)! - React Native 0.87 is now the lowest supported version (`react-native: >=0.87`), and `@hozo/media`'s Expo peers move to SDK 58 (`expo-video`, `expo-audio` and `expo-asset` `>=58 <59`). Native gradients go under `backgroundImage` again: the `experimental_backgroundImage` spelling existed only for React Native 0.86, which read nothing else.
10
+
11
+ - [#1462](https://github.com/iray-tno/hozo/pull/1462) [`c9a3b4d`](https://github.com/iray-tno/hozo/commit/c9a3b4d61541024c66165c91a4b7e2a75c9a203c) Thanks [@iray-tno](https://github.com/iray-tno)! - The Native candidate module now emits a `hozoClassTransitions` table for transition utilities (`transition-*`, `duration-*`, `delay-*`, `ease-*`, also under `motion-reduce:` / `motion-safe:`) instead of reporting them as Web-only, and `@hozo/engine` adds `createClassTransitions` to read a runtime class string into a `HozoAnimated` transition spec.
12
+
13
+ ### Patch Changes
14
+
15
+ - [#1473](https://github.com/iray-tno/hozo/pull/1473) [`fac2f53`](https://github.com/iray-tno/hozo/commit/fac2f53a7636c7373cf22c4d49fcf5a137bb08ec) Thanks [@iray-tno](https://github.com/iray-tno)! - An interrupted `HozoAnimated` transition now starts from where its numbers had got to (opacity, and the position and size keys its spec names), rather than jumping to the previous target first. A panel closed halfway through opening shrinks from its current height.
16
+
17
+ - [#1348](https://github.com/iray-tno/hozo/pull/1348) [`b59995e`](https://github.com/iray-tno/hozo/commit/b59995e108e4cc9b6d093c2487cebece0d02a707) Thanks [@iray-tno](https://github.com/iray-tno)! - The Native `Menu` sheet clears the home indicator and the Android gesture handle: it adds the bottom inset an app's `<SafeAreaProvider>` reports below its own padding, and nothing in an app without one. `@hozo/engine` gains `useHozoProvidedSafeArea()` for that, which reads zeros instead of throwing when the provider or `react-native-safe-area-context` is missing, and the missing-package warning for a safe-area class now fires when such a class first renders rather than whenever the Native entry loads.
18
+
19
+ - [#1056](https://github.com/iray-tno/hozo/pull/1056) [`c1ca21a`](https://github.com/iray-tno/hozo/commit/c1ca21afee0e3f4dd92110570f3ff3775b01c4cf) Thanks [@iray-tno](https://github.com/iray-tno)! - On Native, a `style` a caller passes through a component's `{...rest}` no longer replaces the styles compiled from its classes: the two compose, classes first and the caller's style after, as the owner itself composes them. Elements whose spreads cannot carry `style` compile as before.
20
+
21
+ - [#1155](https://github.com/iray-tno/hozo/pull/1155) [`416d627`](https://github.com/iray-tno/hozo/commit/416d627e8afc6a3f321c95dbe1f74b630d173d7b) Thanks [@iray-tno](https://github.com/iray-tno)! - On the Web, a spread onto a compiled `View`, `Text` or `Image` keeps the props that need the element.
22
+
23
+ - **`onLayout`** is called on mount and when the layout changes, as it is uncompiled. It is not called again on a re-render.
24
+ - **The responder props** (`onStartShouldSetResponder`, `onResponderGrant`, `onResponderMove`, …) claim and release the pointer on a `View`.
25
+ - **An `Image` whose `src` fails to load falls back to `defaultSource`.**
26
+
27
+ Before this, these reached the DOM raw and did nothing. The spread's translation now adds a callback ref when the spread carries one of them. `@hozo/engine` exports `createSpreadResponder` for it: the responder without a hook.
28
+
3
29
  ## 0.3.0
4
30
 
5
31
  ### Patch Changes
package/README.md CHANGED
@@ -31,7 +31,7 @@ negated known sibling predicates such as `not-first:`/`not-last:`, and negated
31
31
  supported environment queries such as `not-motion-reduce:` reuse the positive
32
32
  predicate, including when stacked with other supported conditions. Prop predicates
33
33
  need the same readable driver as their positive form; `not-disabled:` without a
34
- `disabled` prop or an unreadable ARIA state is still a diagnostic, not a false value
34
+ readable disabled fact or an unreadable ARIA state is still a diagnostic, not a false value
35
35
  to invert. `not-enabled:` follows the existing `enabled:` contract: without a
36
36
  `disabled` prop, enabled is known true and its negation does not apply. Unknown
37
37
  sibling positions and unsupported environment queries remain diagnostics too.
@@ -44,8 +44,12 @@ negated focus-visible alone enables the same pointer/keyboard modality inference
44
44
  as its positive form. Text in that interaction context uses the owner's state,
45
45
  not an independent text focus target, just as positive focus variants do. No new
46
46
  store or subscription is added. Other elements without a readable focus driver
47
- remain diagnostics. `not-hover:` and other unsupported selector negations remain
48
- unwired.
47
+ remain diagnostics. Dynamic class maps also carry negated ARIA predicates as
48
+ compiler-owned `!aria-…` keys, prepared once by the resolver from the underlying
49
+ owner facts. Missing facts remain unassessed, including under negation; no new
50
+ owner-state fields or subscriptions are needed. Both ordinary and ordered maps
51
+ use this same matcher. Non-ARIA dynamic selector negations such as `not-hover:`
52
+ remain unwired; their static lowering is a separate capability.
49
53
 
50
54
  **Interaction state infrastructure.** The canonical `HozoPressable` in `@hozo/primitives` tracks
51
55
  pressed, hovered, focused and focus-visible state using the shared helpers owned here. Focus-visible
@@ -107,6 +111,6 @@ rendering boundaries and their layout solvers are owned by `@hozo/primitives`.
107
111
 
108
112
  ---
109
113
 
110
- Part of [Hozo](https://iray-tno.github.io/hozo/), a Rust-powered universal UI compiler and accessibility-first layer for React Native. Most applications install [`@hozo/core`](https://www.npmjs.com/package/@hozo/core) and one build integration; see [Getting started](https://github.com/iray-tno/hozo#getting-started). Source and issues: [github.com/iray-tno/hozo](https://github.com/iray-tno/hozo).
114
+ Part of [Hozo](https://iray-tno.github.io/hozo/), a universal UI framework for React Native, compiled by Rust, with native semantics on every platform, first-class accessibility, and diagnostics for humans and AI agents alike. Most applications install [`@hozo/core`](https://www.npmjs.com/package/@hozo/core) and one build integration; see [Getting started](https://iray-tno.github.io/hozo/docs/getting-started/). Source and issues: [github.com/iray-tno/hozo](https://github.com/iray-tno/hozo).
111
115
 
112
116
  <!-- /generated: package-footer -->
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Project a flattened author's StyleProp, not a mixture with compiled styles.
3
+ * Yoga prefers an axis gutter to `gap` regardless of object key/array order.
4
+ * CSS needs the effective longhands instead, or a later shorthand erases the
5
+ * axis. The caller owns this flat object; authored objects are never mutated.
6
+ * Keep CSS-only strings untouched rather than pretending RN accepts them.
7
+ */
8
+ export declare function projectAuthoredGap(style: Record<string, unknown>): void;
9
+ /** Generated Native code calls this before mixing an author with class axes. */
10
+ export declare function hozoAuthoredStyle<T>(input: T): T;
11
+ //# sourceMappingURL=authored-gap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authored-gap.d.ts","sourceRoot":"","sources":["../src/authored-gap.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAcvE;AAED,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAgBhD"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Project a flattened author's StyleProp, not a mixture with compiled styles.
3
+ * Yoga prefers an axis gutter to `gap` regardless of object key/array order.
4
+ * CSS needs the effective longhands instead, or a later shorthand erases the
5
+ * axis. The caller owns this flat object; authored objects are never mutated.
6
+ * Keep CSS-only strings untouched rather than pretending RN accepts them.
7
+ */
8
+ export function projectAuthoredGap(style) {
9
+ const gap = style.gap;
10
+ if (gap === undefined)
11
+ return;
12
+ if (!(typeof gap === 'number' && Number.isFinite(gap) && gap >= 0) &&
13
+ !(typeof gap === 'string' && /^(?:\d+(?:\.\d+)?|\.\d+)%$/.test(gap)))
14
+ return;
15
+ if (!Object.hasOwn(style, 'gap'))
16
+ return;
17
+ const row = style.rowGap ?? gap;
18
+ const column = style.columnGap ?? gap;
19
+ delete style.gap;
20
+ style.rowGap = row;
21
+ style.columnGap = column;
22
+ }
23
+ /** Generated Native code calls this before mixing an author with class axes. */
24
+ export function hozoAuthoredStyle(input) {
25
+ if (!input || typeof input !== 'object')
26
+ return input;
27
+ if (!Array.isArray(input) && (!('gap' in input) || !Object.hasOwn(input, 'gap')))
28
+ return input;
29
+ // Flatten only the author's contribution. Reading it once also avoids a
30
+ // pre-scan that would evaluate style accessors again during composition.
31
+ const flat = {};
32
+ function visit(value) {
33
+ if (Array.isArray(value)) {
34
+ for (const item of value)
35
+ visit(item);
36
+ }
37
+ else if (value && typeof value === 'object') {
38
+ Object.assign(flat, value);
39
+ }
40
+ }
41
+ visit(input);
42
+ projectAuthoredGap(flat);
43
+ return flat;
44
+ }
45
+ //# sourceMappingURL=authored-gap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authored-gap.js","sourceRoot":"","sources":["../src/authored-gap.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAA8B;IAC/D,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAA;IACrB,IAAI,GAAG,KAAK,SAAS;QAAE,OAAM;IAC7B,IACE,CAAC,CAAC,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;QAC9D,CAAC,CAAC,OAAO,GAAG,KAAK,QAAQ,IAAI,4BAA4B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEpE,OAAM;IACR,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC;QAAE,OAAM;IACxC,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,IAAI,GAAG,CAAA;IAC/B,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,IAAI,GAAG,CAAA;IACrC,OAAO,KAAK,CAAC,GAAG,CAAA;IAChB,KAAK,CAAC,MAAM,GAAG,GAAG,CAAA;IAClB,KAAK,CAAC,SAAS,GAAG,MAAM,CAAA;AAC1B,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,iBAAiB,CAAI,KAAQ;IAC3C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IACrD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAAE,OAAO,KAAK,CAAA;IAC9F,wEAAwE;IACxE,yEAAyE;IACzE,MAAM,IAAI,GAA4B,EAAE,CAAA;IACxC,SAAS,KAAK,CAAC,KAAc;QAC3B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,KAAK,MAAM,IAAI,IAAI,KAAK;gBAAE,KAAK,CAAC,IAAI,CAAC,CAAA;QACvC,CAAC;aAAM,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9C,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;QAC5B,CAAC;IACH,CAAC;IACD,KAAK,CAAC,KAAK,CAAC,CAAA;IACZ,kBAAkB,CAAC,IAAI,CAAC,CAAA;IACxB,OAAO,IAAS,CAAA;AAClB,CAAC"}
@@ -1,19 +1,35 @@
1
1
  /** A React Native style object, as the compiler emits it. */
2
2
  export type StyleObject = Record<string, unknown>;
3
+ /**
4
+ * Compiler-owned text-size fallbacks are not explicit line heights. CSS's
5
+ * --tw-leading register survives a later font-size rule; RN has one numeric
6
+ * slot. The map marks actual generated objects, never class names or private
7
+ * style keys. Only maps containing these fallbacks install this composition.
8
+ */
9
+ export declare function hozoTextMetricStyles(styles: StyleObject[], defaults: ReadonlyMap<StyleObject, StyleObject>): StyleObject[];
3
10
  /**
4
11
  * The state an element is in when its runtime classes are resolved: what
5
12
  * its pressable reports (`pressed`, `hovered`, `focused`, `focusVisible`)
6
13
  * and what its props say: `disabled`, and `aria-checked`, `aria-selected` and
7
14
  * the rest under their attribute names, so `aria-pressed` cannot be read as
8
- * the pointer's `pressed`.
15
+ * the pointer's `pressed`. Plain data-presence conditions use `data-foo`
16
+ * booleans supplied by the actual owner: true means the attribute is present,
17
+ * false means absent, and a missing key is unassessed (and diagnosed).
18
+ * Simple equality predicates use `data-foo=value` booleans, with case-sensitive
19
+ * safe token values normalized at build time. Presence cannot satisfy equality.
20
+ * These are normalized facts, not raw HTML attribute values or selectors.
9
21
  */
10
22
  export type ClassState = Readonly<Record<string, unknown>>;
11
23
  /**
12
24
  * A class that applies only in a state: the state keys that all have to
13
25
  * hold, and the style it applies then. `active:opacity-80` is
14
26
  * `[['pressed'], { opacity: 0.8 }]`.
27
+ * Generated Tailwind owner states may append a cached cascade rank; legacy
28
+ * two-entry groups and mixed/unranked conditional domains keep their order.
29
+ * `!aria-…` is compiler-owned negative-predicate data. It still requires the
30
+ * underlying owner fact; an absent fact is not a measured false value.
15
31
  */
16
- export type StateGroup = readonly [readonly string[], StyleObject];
32
+ export type StateGroup = readonly [readonly string[], StyleObject, number?];
17
33
  /**
18
34
  * Resolves whitespace-separated class names to React Native style objects.
19
35
  *
@@ -26,6 +42,20 @@ export type StateGroup = readonly [readonly string[], StyleObject];
26
42
  * when its state holds, after the unconditional ones.
27
43
  */
28
44
  export type ClassResolver = (value: unknown, state?: ClassState) => StyleObject[];
45
+ /** @internal Generated-data ABI, not a utility parser or a public cascade API. */
46
+ export interface ClassResolverPlan {
47
+ schema: 1;
48
+ styles: Record<string, StyleObject>;
49
+ unsupported?: Record<string, string>;
50
+ states?: Record<string, readonly StateGroup[]>;
51
+ ambient?: ClassState;
52
+ compose?: (styles: StyleObject[]) => StyleObject[];
53
+ /** Ordinals from one complete compiler namespace. Missing means barrier. */
54
+ ordering: {
55
+ schema: 1;
56
+ ranks: Readonly<Record<string, readonly number[]>>;
57
+ };
58
+ }
29
59
  /**
30
60
  * Builds a resolver over one project's candidate map.
31
61
  *
@@ -44,6 +74,14 @@ export type ClassResolver = (value: unknown, state?: ClassState) => StyleObject[
44
74
  * state (#886). Those need no tracking here: the pressable that renders
45
75
  * the element already tracks it and hands it in, so this stays a function
46
76
  * of the class string and that state.
77
+ *
78
+ * `ambient` holds facts that cannot change while the app runs, so no
79
+ * element has to supply them: `rtl` and `ltr`, because React Native needs
80
+ * a reload for a direction change to take effect. A class conditioned on
81
+ * them alone is decided once, when its string is first resolved, and then
82
+ * cached like an unconditional one -- after the unconditional ones, which is
83
+ * where Tailwind puts a variant too.
47
84
  */
48
- export declare function createClassResolver(styles: Record<string, StyleObject>, unsupported?: Record<string, string>, compose?: (styles: StyleObject[]) => StyleObject[], states?: Record<string, readonly StateGroup[]>): ClassResolver;
85
+ export declare function createClassResolver(plan: ClassResolverPlan): ClassResolver;
86
+ export declare function createClassResolver(styles: Record<string, StyleObject>, unsupported?: Record<string, string>, compose?: (styles: StyleObject[]) => StyleObject[], states?: Record<string, readonly StateGroup[]>, ambient?: ClassState): ClassResolver;
49
87
  //# sourceMappingURL=class-resolver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"class-resolver.d.ts","sourceRoot":"","sources":["../src/class-resolver.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEjD;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;AAE1D;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,CAAC,SAAS,MAAM,EAAE,EAAE,WAAW,CAAC,CAAA;AAElE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,UAAU,KAAK,WAAW,EAAE,CAAA;AAYjF;;;;;;;;;;;;;;;;;;GA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EAAE,CAAC,CAAA;IAC9C,OAAO,CAAC,EAAE,UAAU,CAAA;IACpB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,CAAA;IAClD,4EAA4E;IAC5E,QAAQ,EAAE;QAAE,MAAM,EAAE,CAAC,CAAC;QAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAAA;KAAE,CAAA;CAC5E;AAsBD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,aAAa,CAAA;AAC3E,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACnC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,EAClD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,CAAC,EAC9C,OAAO,CAAC,EAAE,UAAU,GACnB,aAAa,CAAA"}
@@ -1,23 +1,37 @@
1
1
  /**
2
- * Builds a resolver over one project's candidate map.
3
- *
4
- * Called by the generated candidate module rather than by application
5
- * code: `styles`, `unsupported` and `states` are build output, and binding
6
- * them here keeps the generated file to data plus one call.
7
- *
8
- * `unsupported` maps a class the compiler *recognized but can't express*
9
- * as a plain style object -- a utility under a breakpoint or `dark:`, or
10
- * one that's Web-only -- to the reason. Those are reported when they're
11
- * actually used rather than at build time, because a class appearing in
12
- * the project's candidate scan doesn't mean any dynamic expression ever
13
- * produces it.
14
- *
15
- * `states` holds the classes whose only condition is the element's own
16
- * state (#886). Those need no tracking here: the pressable that renders
17
- * the element already tracks it and hands it in, so this stays a function
18
- * of the class string and that state.
2
+ * Compiler-owned text-size fallbacks are not explicit line heights. CSS's
3
+ * --tw-leading register survives a later font-size rule; RN has one numeric
4
+ * slot. The map marks actual generated objects, never class names or private
5
+ * style keys. Only maps containing these fallbacks install this composition.
19
6
  */
20
- export function createClassResolver(styles, unsupported = {}, compose, states = {}) {
7
+ export function hozoTextMetricStyles(styles, defaults) {
8
+ if (!styles.some((style) => defaults.has(style)) ||
9
+ !styles.some((style) => Object.hasOwn(style, 'lineHeight') && !defaults.has(style)))
10
+ return styles;
11
+ // Default-free objects are built once by the generated factory. A state
12
+ // update selects them; it never clones a style object or inspects ranks.
13
+ return styles.map((style) => defaults.get(style) ?? style);
14
+ }
15
+ export function createClassResolver(stylesOrPlan, unsupported = {}, compose, states = {}, ambient = {}) {
16
+ let styles;
17
+ let ranks;
18
+ if (typeof stylesOrPlan.schema === 'number') {
19
+ const plan = stylesOrPlan;
20
+ if (plan.schema !== 1 ||
21
+ plan.ordering?.schema !== 1 ||
22
+ !plan.ordering.ranks ||
23
+ typeof plan.ordering.ranks !== 'object')
24
+ throw new Error('Unsupported Hozo class plan schema');
25
+ styles = plan.styles;
26
+ unsupported = plan.unsupported ?? {};
27
+ compose = plan.compose;
28
+ states = plan.states ?? {};
29
+ ambient = plan.ambient ?? {};
30
+ ranks = plan.ordering.ranks;
31
+ }
32
+ else
33
+ styles = stylesOrPlan;
34
+ const isAmbient = (key) => Object.hasOwn(ambient, key);
21
35
  // Class strings repeat constantly across renders and list items, and the
22
36
  // result is immutable, so each distinct string is resolved once.
23
37
  const cache = new Map();
@@ -31,10 +45,63 @@ export function createClassResolver(styles, unsupported = {}, compose, states =
31
45
  // eslint-disable-next-line no-console
32
46
  console.warn(`[hozo] ${reason}`);
33
47
  };
48
+ // Absent is not false. A focused field must not silently claim that it
49
+ // measured hover/press, or that a spread supplied a disabled driver.
50
+ const supplied = (keys, name, facts) => {
51
+ if (!keys.every((key) => Object.hasOwn(facts, key))) {
52
+ if (!warned.has(name)) {
53
+ const missing = keys.filter((key) => !Object.hasOwn(facts, key));
54
+ warn(name, `\`${name}\` needs state (${missing.join(', ')}) this element does not supply.`);
55
+ }
56
+ return false;
57
+ }
58
+ return true;
59
+ };
60
+ const positive = (keys, name, facts) => supplied(keys, name, facts) && keys.every((key) => Boolean(facts[key]));
61
+ // Prepare only negative maps' exceptional groups once, not during state
62
+ // updates or for every authored class lookup. Positive-only maps retain
63
+ // their existing boolean matcher and allocate no predicate side table.
64
+ let negative;
65
+ for (const groups of Object.values(states))
66
+ for (const [keys] of groups)
67
+ if (keys.some((key) => key.startsWith('!aria-')))
68
+ (negative ??= new Map()).set(keys, {
69
+ keys: keys.map((key) => (key.startsWith('!aria-') ? key.slice(1) : key)),
70
+ expected: keys.map((key) => !key.startsWith('!aria-')),
71
+ });
72
+ const negativePredicates = negative;
73
+ const matches = negativePredicates
74
+ ? (keys, name, facts) => {
75
+ const predicate = negativePredicates.get(keys);
76
+ return predicate
77
+ ? supplied(predicate.keys, name, facts) &&
78
+ predicate.keys.every((key, index) => Boolean(facts[key]) === predicate.expected[index])
79
+ : positive(keys, name, facts);
80
+ }
81
+ : positive;
34
82
  function resolve(value) {
35
83
  const base = [];
36
84
  const groups = [];
85
+ const groupClasses = [];
37
86
  const stateClasses = [];
87
+ const decided = [];
88
+ // Build transient ranked entries only for the generated-plan ABI. A
89
+ // single unassessed object makes this whole string use the old path.
90
+ let ranked = ranks ? [] : undefined;
91
+ const take = ranks
92
+ ? (name, index, style, keys) => {
93
+ if (!ranked)
94
+ return;
95
+ const rank = ranks[name]?.[index];
96
+ if (rank === undefined) {
97
+ ranked = undefined;
98
+ return;
99
+ }
100
+ if (!Number.isSafeInteger(rank) || rank < 0)
101
+ throw new Error('Invalid Hozo class plan rank');
102
+ ranked.push({ rank, entry: { name, style, keys } });
103
+ }
104
+ : undefined;
38
105
  for (const name of value.split(/\s+/)) {
39
106
  if (name === '') {
40
107
  continue;
@@ -42,12 +109,26 @@ export function createClassResolver(styles, unsupported = {}, compose, states =
42
109
  const style = styles[name];
43
110
  if (style) {
44
111
  base.push(style);
112
+ take?.(name, 0, style, []);
45
113
  continue;
46
114
  }
47
115
  const conditional = states[name];
48
116
  if (conditional) {
49
- groups.push(...conditional);
50
- stateClasses.push(name);
117
+ let needsState = false;
118
+ for (let index = 0; index < conditional.length; index++) {
119
+ const group = conditional[index];
120
+ take?.(name, index, group[1], group[0]);
121
+ if ((negativePredicates?.get(group[0])?.keys ?? group[0]).every(isAmbient)) {
122
+ if (matches(group[0], name, ambient))
123
+ decided.push(group[1]);
124
+ continue;
125
+ }
126
+ groups.push(group);
127
+ groupClasses.push(name);
128
+ needsState = true;
129
+ }
130
+ if (needsState)
131
+ stateClasses.push(name);
51
132
  continue;
52
133
  }
53
134
  // An unknown class isn't necessarily a Hozo problem -- it may be an
@@ -57,7 +138,45 @@ export function createClassResolver(styles, unsupported = {}, compose, states =
57
138
  if (reason)
58
139
  warn(name, reason);
59
140
  }
60
- return { base: compose ? compose(base) : base, raw: base, groups, stateClasses };
141
+ if (ranked) {
142
+ // Stable ties keep input order. Strip rank objects before caching, so
143
+ // neither cache hits nor state-only changes can read/sort priorities.
144
+ ranked.sort((a, b) => a.rank - b.rank);
145
+ const ordered = [];
146
+ for (const { entry } of ranked) {
147
+ if ((negativePredicates?.get(entry.keys)?.keys ?? entry.keys).every(isAmbient)) {
148
+ if (matches(entry.keys, entry.name, ambient))
149
+ ordered.push({ ...entry, keys: [] });
150
+ }
151
+ else
152
+ ordered.push(entry);
153
+ }
154
+ const raw = ordered.filter((entry) => !entry.keys.length).map((entry) => entry.style);
155
+ return {
156
+ base: compose ? compose(raw) : raw,
157
+ raw,
158
+ groups,
159
+ groupClasses,
160
+ stateClasses,
161
+ ordered,
162
+ };
163
+ }
164
+ // Build-time Tailwind owner-state rank, sorted once per cached class string,
165
+ // never on every state update. Mixed/unranked domains are left alone; ties
166
+ // retain authored/caller order. Keep warning provenance beside each group.
167
+ if (groups.length > 1 && groups.every((group) => group[2] !== undefined)) {
168
+ if (groups.some((group, index) => index > 0 && groups[index - 1][2] > group[2])) {
169
+ const sorted = groups
170
+ .map((group, index) => ({ group, name: groupClasses[index] }))
171
+ .sort((a, b) => a.group[2] - b.group[2]);
172
+ for (const [index, entry] of sorted.entries()) {
173
+ groups[index] = entry.group;
174
+ groupClasses[index] = entry.name;
175
+ }
176
+ }
177
+ }
178
+ base.push(...decided);
179
+ return { base: compose ? compose(base) : base, raw: base, groups, groupClasses, stateClasses };
61
180
  }
62
181
  return function hozoClasses(value, state) {
63
182
  // Falsy is the normal case, not an error: `cond && 'p-4'` yields
@@ -75,12 +194,30 @@ export function createClassResolver(styles, unsupported = {}, compose, states =
75
194
  if (state === undefined) {
76
195
  for (const name of resolved.stateClasses) {
77
196
  warn(name, `\`${name}\` applies in a state, and this element hands its classes no state to ` +
78
- 'resolve it against. Put it on a Pressable, Button or Link, or write it as a static ' +
197
+ 'resolve it against. Put it on an owner that supplies this state, or write it as a static ' +
79
198
  'className so it compiles to a real style variant.');
80
199
  }
81
200
  return resolved.base;
82
201
  }
83
- const active = resolved.groups.filter(([keys]) => keys.every((key) => Boolean(state[key])));
202
+ // A group can name an ambient fact beside the element's own, as
203
+ // `rtl:hover:` does; the element supplies only its part.
204
+ const facts = { ...ambient, ...state };
205
+ if (resolved.ordered) {
206
+ const all = [];
207
+ let active = false;
208
+ for (const entry of resolved.ordered) {
209
+ if (!entry.keys.length)
210
+ all.push(entry.style);
211
+ else if (matches(entry.keys, entry.name, facts)) {
212
+ all.push(entry.style);
213
+ active = true;
214
+ }
215
+ }
216
+ if (!active)
217
+ return resolved.base;
218
+ return compose ? compose(all) : all;
219
+ }
220
+ const active = resolved.groups.filter(([keys], index) => matches(keys, resolved.groupClasses[index], facts));
84
221
  if (active.length === 0)
85
222
  return resolved.base;
86
223
  const all = [...resolved.raw, ...active.map(([, style]) => style)];
@@ -1 +1 @@
1
- {"version":3,"file":"class-resolver.js","sourceRoot":"","sources":["../src/class-resolver.ts"],"names":[],"mappings":"AA0CA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU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AE,KAAK,EAAE,EAAE,CACtD,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAE,EAAE,KAAK,CAAC,CACpD,CAAA;QACD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,QAAQ,CAAC,IAAI,CAAA;QAC7C,MAAM,GAAG,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;QAClE,uEAAuE;QACvE,sEAAsE;QACtE,4CAA4C;QAC5C,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;IACrC,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,32 @@
1
+ /** `HozoAnimated`'s spec, as `@hozo/primitives` defines it. */
2
+ export interface ClassTransitionSpec {
3
+ duration: number;
4
+ delay?: number;
5
+ easing: 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out';
6
+ properties?: readonly string[];
7
+ }
8
+ /** @internal Generated-data ABI: one transition utility's condition and part. */
9
+ export type ClassTransitionTable = Readonly<Record<string, readonly [condition: 'motion-reduce' | 'motion-safe' | null, Partial<ClassTransitionSpec>]>>;
10
+ /**
11
+ * Reads the transition a class string asks for, or `undefined` when it asks
12
+ * for none.
13
+ *
14
+ * `reduceMotion` decides the `motion-reduce:` and `motion-safe:` parts, as
15
+ * the media query does on the Web; the caller reads it, so this stays a pure
16
+ * function of its arguments.
17
+ */
18
+ export type ClassTransition = (value: unknown, environment: {
19
+ reduceMotion: boolean;
20
+ }) => ClassTransitionSpec | undefined;
21
+ /**
22
+ * Builds the reader over one project's transition table.
23
+ *
24
+ * Later classes win, field by field, as later declarations do in a
25
+ * stylesheet. A string with no `transition*` utility asks for no
26
+ * transition, whatever its duration says: on the Web `transition-property`
27
+ * is what turns one on. Its defaults are Tailwind's: 150ms and
28
+ * `ease-in-out`'s curve, which `transition-*` utilities normally set
29
+ * themselves.
30
+ */
31
+ export declare function createClassTransitions(table: ClassTransitionTable): ClassTransition;
32
+ //# sourceMappingURL=class-transition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class-transition.d.ts","sourceRoot":"","sources":["../src/class-transition.ts"],"names":[],"mappings":"AAUA,+DAA+D;AAC/D,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,aAAa,CAAA;IACzD,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAC/B;AAED,iFAAiF;AACjF,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CACzC,MAAM,CACJ,MAAM,EACN,SAAS,CAAC,SAAS,EAAE,eAAe,GAAG,aAAa,GAAG,IAAI,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAC3F,CACF,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,GAAG,CAC5B,KAAK,EAAE,OAAO,EACd,WAAW,EAAE;IAAE,YAAY,EAAE,OAAO,CAAA;CAAE,KACnC,mBAAmB,GAAG,SAAS,CAAA;AAEpC;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,oBAAoB,GAAG,eAAe,CAqBnF"}
@@ -0,0 +1,48 @@
1
+ // What a runtime-resolved class string says about transitions.
2
+ //
3
+ // A transition utility draws nothing on React Native, so the class resolver
4
+ // has nothing to return for one, and it used to be reported as Web-only and
5
+ // dropped. A component that resolves its look at run time -- a pattern's
6
+ // indicator, say -- then had no way to animate on Native what its classes
7
+ // animate on the Web (#1450). The candidate module now emits each transition
8
+ // utility's part of a spec, and this reads a class string into one spec for
9
+ // `HozoAnimated` to run.
10
+ /**
11
+ * Builds the reader over one project's transition table.
12
+ *
13
+ * Later classes win, field by field, as later declarations do in a
14
+ * stylesheet. A string with no `transition*` utility asks for no
15
+ * transition, whatever its duration says: on the Web `transition-property`
16
+ * is what turns one on. Its defaults are Tailwind's: 150ms and
17
+ * `ease-in-out`'s curve, which `transition-*` utilities normally set
18
+ * themselves.
19
+ */
20
+ export function createClassTransitions(table) {
21
+ return (value, { reduceMotion }) => {
22
+ if (typeof value !== 'string' || value === '')
23
+ return undefined;
24
+ let spec;
25
+ for (const name of value.split(/\s+/)) {
26
+ const entry = table[name];
27
+ if (!entry)
28
+ continue;
29
+ const [condition, part] = entry;
30
+ if (condition === 'motion-reduce' && !reduceMotion)
31
+ continue;
32
+ if (condition === 'motion-safe' && reduceMotion)
33
+ continue;
34
+ spec = { ...spec, ...part };
35
+ }
36
+ if (!spec?.properties || spec.properties.length === 0)
37
+ return undefined;
38
+ if (spec.properties.length === 1 && spec.properties[0] === 'none')
39
+ return undefined;
40
+ return {
41
+ duration: spec.duration ?? 150,
42
+ delay: spec.delay,
43
+ easing: spec.easing ?? 'ease-in-out',
44
+ properties: spec.properties,
45
+ };
46
+ };
47
+ }
48
+ //# sourceMappingURL=class-transition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class-transition.js","sourceRoot":"","sources":["../src/class-transition.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,EAAE;AACF,4EAA4E;AAC5E,4EAA4E;AAC5E,yEAAyE;AACzE,0EAA0E;AAC1E,6EAA6E;AAC7E,4EAA4E;AAC5E,yBAAyB;AA+BzB;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAA2B;IAChE,OAAO,CAAC,KAAK,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE;QACjC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE;YAAE,OAAO,SAAS,CAAA;QAC/D,IAAI,IAA8C,CAAA;QAClD,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YACtC,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,CAAA;YACzB,IAAI,CAAC,KAAK;gBAAE,SAAQ;YACpB,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,KAAK,CAAA;YAC/B,IAAI,SAAS,KAAK,eAAe,IAAI,CAAC,YAAY;gBAAE,SAAQ;YAC5D,IAAI,SAAS,KAAK,aAAa,IAAI,YAAY;gBAAE,SAAQ;YACzD,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,EAAE,CAAA;QAC7B,CAAC;QACD,IAAI,CAAC,IAAI,EAAE,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,SAAS,CAAA;QACvE,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,MAAM;YAAE,OAAO,SAAS,CAAA;QACnF,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,GAAG;YAC9B,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,aAAa;YACpC,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,CAAA;IACH,CAAC,CAAA;AACH,CAAC"}
@@ -1,3 +1,5 @@
1
+ /** @internal Whether interrupted blending can read this colour without a snap fallback. */
2
+ export declare function canBlendColor(color: string): boolean;
1
3
  /** The visible colour at `progress`, used when an interrupted transition restarts. */
2
4
  export declare function blendColor(from: string, to: string, progress: number): string;
3
5
  //# sourceMappingURL=color-transition.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"color-transition.d.ts","sourceRoot":"","sources":["../src/color-transition.ts"],"names":[],"mappings":"AAqBA,sFAAsF;AACtF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAUpE"}
1
+ {"version":3,"file":"color-transition.d.ts","sourceRoot":"","sources":["../src/color-transition.ts"],"names":[],"mappings":"AAqBA,2FAA2F;AAC3F,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,WAE1C;AAED,sFAAsF;AACtF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAUpE"}
@@ -21,6 +21,10 @@ function rgba(color) {
21
21
  alpha,
22
22
  ];
23
23
  }
24
+ /** @internal Whether interrupted blending can read this colour without a snap fallback. */
25
+ export function canBlendColor(color) {
26
+ return rgba(color) !== null;
27
+ }
24
28
  /** The visible colour at `progress`, used when an interrupted transition restarts. */
25
29
  export function blendColor(from, to, progress) {
26
30
  const a = rgba(from);
@@ -1 +1 @@
1
- {"version":3,"file":"color-transition.js","sourceRoot":"","sources":["../src/color-transition.ts"],"names":[],"mappings":"AAAA,SAAS,IAAI,CAAC,KAAa;IACzB,IAAI,KAAK,KAAK,aAAa;QAAE,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAChD,uEAAuE;IACvE,MAAM,OAAO,GAAG,4CAA4C,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACxE,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAqC,CAAA;QACjF,OAAO,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAA;IAC1D,CAAC;IACD,MAAM,KAAK,GAAG,2CAA2C,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACrE,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAA;IACvB,IAAI,GAAG,GAAG,KAAK,CAAC,CAAC,CAAE,CAAA;IACnB,IAAI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E,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAA;AAC3F,CAAC"}
package/dist/cx.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export type CxValue = string | false | null | undefined;
2
+ /** Joins the truthy class strings with a space, as `clsx` does for strings. */
3
+ export declare function cx(...classes: CxValue[]): string;
4
+ //# sourceMappingURL=cx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cx.d.ts","sourceRoot":"","sources":["../src/cx.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,CAAA;AAEvD,+EAA+E;AAC/E,wBAAgB,EAAE,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAOhD"}