@ng-native/fabric 0.7.0 → 0.9.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/dist/fabric.d.ts CHANGED
@@ -16,5 +16,5 @@ import type { FabricUIManager } from './engine.ts';
16
16
  * Exported because the facade test iterates it: there was a second copy of this list in that file,
17
17
  * which is how the two managed to be wrong in the same way at the same time.
18
18
  */
19
- export declare const FABRIC_METHODS: readonly ["createNode", "cloneNodeWithNewChildren", "cloneNodeWithNewProps", "cloneNodeWithNewChildrenAndProps", "appendChild", "createChildSet", "appendChildToSet", "completeRoot", "registerEventHandler", "setIsJSResponder", "dispatchCommand", "measureInWindow"];
19
+ export declare const FABRIC_METHODS: readonly ["createNode", "cloneNodeWithNewChildren", "cloneNodeWithNewProps", "cloneNodeWithNewChildrenAndProps", "appendChild", "configureNextLayoutAnimation", "createChildSet", "appendChildToSet", "completeRoot", "registerEventHandler", "setIsJSResponder", "dispatchCommand", "measureInWindow"];
20
20
  export declare function getFabricUIManager(): FabricUIManager;
package/dist/fabric.js CHANGED
@@ -16,6 +16,7 @@ export const FABRIC_METHODS = [
16
16
  'cloneNodeWithNewProps',
17
17
  'cloneNodeWithNewChildrenAndProps',
18
18
  'appendChild',
19
+ 'configureNextLayoutAnimation',
19
20
  'createChildSet',
20
21
  'appendChildToSet',
21
22
  'completeRoot',
@@ -1 +1 @@
1
- {"version":3,"file":"fabric.js","sourceRoot":"","sources":["../src/fabric.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,YAAY;IACZ,0BAA0B;IAC1B,uBAAuB;IACvB,kCAAkC;IAClC,aAAa;IACb,gBAAgB;IAChB,kBAAkB;IAClB,cAAc;IACd,sBAAsB;IACtB,kBAAkB;IAClB,iBAAiB;IACjB,iBAAiB;CACoC,CAAC;AAexD,MAAM,UAAU,kBAAkB;IAChC,MAAM,GAAG,GAAI,UAAkE;SAC5E,qBAAqB,CAAC;IAEzB,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CACb,gFAAgF;YAC9E,sDAAsD,CACzD,CAAC;IACJ,CAAC;IAED,gGAAgG;IAChG,4FAA4F;IAC5F,MAAM,MAAM,GAAqE,EAAE,CAAC;IACpF,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE,CAAC;QAClC,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;QACxB,IAAI,OAAO,KAAK,KAAK,UAAU;YAAE,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,MAAoC,CAAC;AAC9C,CAAC","sourcesContent":["/**\n * `global.nativeFabricUIManager` is a lazy caching proxy: every property access mints a\n * fresh host function. Read each method exactly once into a plain object (this is what\n * RN's own `FabricUIManager.js` does with its CACHED_PROPERTIES list).\n */\nimport type { FabricUIManager } from './engine.ts';\n\n/**\n * Every method of `FabricUIManager`, and nothing else.\n *\n * A name missing here is `undefined` on device and nowhere else, because the fake the suite runs\n * against implements the interface directly - so every test passes and every device fails. That\n * is not hypothetical: `measureInWindow` was added to the interface and to the engine and left out\n * here, and the anchored overlays it was built for could never have worked.\n *\n * `AllMethodsListed` below is what makes that impossible now rather than merely tested for.\n * Exported because the facade test iterates it: there was a second copy of this list in that file,\n * which is how the two managed to be wrong in the same way at the same time.\n */\nexport const FABRIC_METHODS = [\n 'createNode',\n 'cloneNodeWithNewChildren',\n 'cloneNodeWithNewProps',\n 'cloneNodeWithNewChildrenAndProps',\n 'appendChild',\n 'createChildSet',\n 'appendChildToSet',\n 'completeRoot',\n 'registerEventHandler',\n 'setIsJSResponder',\n 'dispatchCommand',\n 'measureInWindow',\n] as const satisfies readonly (keyof FabricUIManager)[];\n\n/**\n * A method the interface declares and the list above forgets.\n *\n * `satisfies` already checks that every name in the list is a real method. This is the other\n * direction, which is the one that bites: it resolves to `never` when the list is complete, and to\n * the missing name when it is not - so forgetting one is a compile error naming it rather than a\n * silent no-op on every phone.\n */\ntype AssertNever<T extends never> = T;\ntype AllMethodsListed = AssertNever<\n Exclude<keyof FabricUIManager, (typeof FABRIC_METHODS)[number]>\n>;\n\nexport function getFabricUIManager(): FabricUIManager {\n const raw = (globalThis as { nativeFabricUIManager?: Record<string, unknown> })\n .nativeFabricUIManager;\n\n if (!raw) {\n throw new Error(\n 'nativeFabricUIManager is not available. The New Architecture must be enabled, ' +\n 'and mount() must run inside an AppRegistry runnable.',\n );\n }\n\n // Typed with the check above, which is `never` when the list is complete and so adds nothing; a\n // check nothing refers to is an unused local to a consumer compiling with `noUnusedLocals`.\n const facade: Record<string, unknown> & { [name in AllMethodsListed]?: never } = {};\n for (const name of FABRIC_METHODS) {\n const value = raw[name];\n if (typeof value === 'function') facade[name] = value.bind(raw);\n }\n return facade as unknown as FabricUIManager;\n}\n"]}
1
+ {"version":3,"file":"fabric.js","sourceRoot":"","sources":["../src/fabric.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,YAAY;IACZ,0BAA0B;IAC1B,uBAAuB;IACvB,kCAAkC;IAClC,aAAa;IACb,8BAA8B;IAC9B,gBAAgB;IAChB,kBAAkB;IAClB,cAAc;IACd,sBAAsB;IACtB,kBAAkB;IAClB,iBAAiB;IACjB,iBAAiB;CACoC,CAAC;AAexD,MAAM,UAAU,kBAAkB;IAChC,MAAM,GAAG,GAAI,UAAkE;SAC5E,qBAAqB,CAAC;IAEzB,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CACb,gFAAgF;YAC9E,sDAAsD,CACzD,CAAC;IACJ,CAAC;IAED,gGAAgG;IAChG,4FAA4F;IAC5F,MAAM,MAAM,GAAqE,EAAE,CAAC;IACpF,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE,CAAC;QAClC,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;QACxB,IAAI,OAAO,KAAK,KAAK,UAAU;YAAE,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,MAAoC,CAAC;AAC9C,CAAC","sourcesContent":["/**\n * `global.nativeFabricUIManager` is a lazy caching proxy: every property access mints a\n * fresh host function. Read each method exactly once into a plain object (this is what\n * RN's own `FabricUIManager.js` does with its CACHED_PROPERTIES list).\n */\nimport type { FabricUIManager } from './engine.ts';\n\n/**\n * Every method of `FabricUIManager`, and nothing else.\n *\n * A name missing here is `undefined` on device and nowhere else, because the fake the suite runs\n * against implements the interface directly - so every test passes and every device fails. That\n * is not hypothetical: `measureInWindow` was added to the interface and to the engine and left out\n * here, and the anchored overlays it was built for could never have worked.\n *\n * `AllMethodsListed` below is what makes that impossible now rather than merely tested for.\n * Exported because the facade test iterates it: there was a second copy of this list in that file,\n * which is how the two managed to be wrong in the same way at the same time.\n */\nexport const FABRIC_METHODS = [\n 'createNode',\n 'cloneNodeWithNewChildren',\n 'cloneNodeWithNewProps',\n 'cloneNodeWithNewChildrenAndProps',\n 'appendChild',\n 'configureNextLayoutAnimation',\n 'createChildSet',\n 'appendChildToSet',\n 'completeRoot',\n 'registerEventHandler',\n 'setIsJSResponder',\n 'dispatchCommand',\n 'measureInWindow',\n] as const satisfies readonly (keyof FabricUIManager)[];\n\n/**\n * A method the interface declares and the list above forgets.\n *\n * `satisfies` already checks that every name in the list is a real method. This is the other\n * direction, which is the one that bites: it resolves to `never` when the list is complete, and to\n * the missing name when it is not - so forgetting one is a compile error naming it rather than a\n * silent no-op on every phone.\n */\ntype AssertNever<T extends never> = T;\ntype AllMethodsListed = AssertNever<\n Exclude<keyof FabricUIManager, (typeof FABRIC_METHODS)[number]>\n>;\n\nexport function getFabricUIManager(): FabricUIManager {\n const raw = (globalThis as { nativeFabricUIManager?: Record<string, unknown> })\n .nativeFabricUIManager;\n\n if (!raw) {\n throw new Error(\n 'nativeFabricUIManager is not available. The New Architecture must be enabled, ' +\n 'and mount() must run inside an AppRegistry runnable.',\n );\n }\n\n // Typed with the check above, which is `never` when the list is complete and so adds nothing; a\n // check nothing refers to is an unused local to a consumer compiling with `noUnusedLocals`.\n const facade: Record<string, unknown> & { [name in AllMethodsListed]?: never } = {};\n for (const name of FABRIC_METHODS) {\n const value = raw[name];\n if (typeof value === 'function') facade[name] = value.bind(raw);\n }\n return facade as unknown as FabricUIManager;\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -21,3 +21,4 @@ export { HostEngine, type HostNode, type Settling } from './host.ts';
21
21
  export { getFabricUIManager } from './fabric.ts';
22
22
  export { pinnedRange, type DrivenProperty, type EventFeed, type NativeAnimated, type ScrollAxis, type ScrollDrive, type ScrollRange, type StaticTransform, } from './native-drive.ts';
23
23
  export { bezier, interpolate, redirect, sample, settled, step, tracksOf, tween, type AnimationSpec, type Keyframe, type RunningAnimation, type Transition, type TransitionSpec, } from './transition.ts';
24
+ export { backgroundLayers, type BackgroundLayers } from './background-layers.ts';
package/dist/index.js CHANGED
@@ -21,4 +21,5 @@ export { HostEngine } from "./host.js";
21
21
  export { getFabricUIManager } from "./fabric.js";
22
22
  export { pinnedRange, } from "./native-drive.js";
23
23
  export { bezier, interpolate, redirect, sample, settled, step, tracksOf, tween, } from "./transition.js";
24
+ export { backgroundLayers } from "./background-layers.js";
24
25
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACL,aAAa,EACb,OAAO,EACP,YAAY,GAiBb,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,aAAa,EACb,MAAM,EACN,cAAc,EACd,SAAS,EACT,cAAc,EACd,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,0BAA0B,EAC1B,gBAAgB,EAGhB,UAAU,GAeX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,uBAAuB,EAAsB,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAE,UAAU,EAAgC,MAAM,WAAW,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EACL,WAAW,GAQZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,MAAM,EACN,WAAW,EACX,QAAQ,EACR,MAAM,EACN,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,KAAK,GAMN,MAAM,iBAAiB,CAAC","sourcesContent":["/**\n * The engine's public surface.\n *\n * Nothing here imports Angular, and nothing here may start to: the engine stays\n * framework-agnostic (see docs/ARCHITECTURE.md), which is what keeps the commit logic testable without Angular in\n * the loop and a second adapter possible later.\n *\n * The CSS runtime lives here rather than in a package of its own because the cascade is driven\n * from the commit walk - the resolver runs per node, per tick - and because it is as\n * framework-agnostic as the rest of the engine. The build-time half of CSS is a different\n * animal and lives in `@ng-native/metro`.\n */\nexport {\n StyleResolver,\n matches,\n styleSheetOf,\n type AttributeTest,\n type Combinator,\n type Compound,\n type Conditions,\n type DeferredDeclaration,\n type GradientTemplate,\n type HslChannel,\n type MediaCondition,\n type NthTest,\n type RuleIndex,\n type StyleCache,\n type StyleRule,\n type StyleSheet,\n type StyleTarget,\n type TokenKind,\n type TokenValue,\n} from './css.ts';\nexport { ELEMENT_STYLES, ELEMENT_STYLES_CSS } from './element-styles.ts';\nexport { EngineIntersectionObserver, installDeferTriggers } from './defer-triggers.ts';\nexport { faceName } from './font-faces.ts';\nexport { firstFamily } from './inline-token.ts';\nexport {\n DIRECT_EVENTS,\n Engine,\n SyntheticEvent,\n claimHost,\n keepNativeView,\n declareNativeProps,\n fontsLoading,\n fontsRegistered,\n fontsSettled,\n markComponentHost,\n nativePlatform,\n onFontsRegistered,\n onFontsSettled,\n registerHoist,\n registerPlatformComponents,\n registerViewName,\n type PlatformViewName,\n type ViewNameOptions,\n viewNameOf,\n type EngineNode,\n type EngineOptions,\n type EngineStats,\n type FabricNode,\n type FabricNodeSet,\n type FabricUIManager,\n type HoistOptions,\n type NativeSyntheticEvent,\n type NodeKind,\n type ResponderEvent,\n type ResponderHandlers,\n type TouchPayload,\n type ViewNameNode,\n type WindowFrame,\n} from './engine.ts';\nexport { reportUnboundFormsInput, type NamedHostNode } from './forms-inputs.ts';\nexport { HostEngine, type HostNode, type Settling } from './host.ts';\nexport { getFabricUIManager } from './fabric.ts';\nexport {\n pinnedRange,\n type DrivenProperty,\n type EventFeed,\n type NativeAnimated,\n type ScrollAxis,\n type ScrollDrive,\n type ScrollRange,\n type StaticTransform,\n} from './native-drive.ts';\nexport {\n bezier,\n interpolate,\n redirect,\n sample,\n settled,\n step,\n tracksOf,\n tween,\n type AnimationSpec,\n type Keyframe,\n type RunningAnimation,\n type Transition,\n type TransitionSpec,\n} from './transition.ts';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACL,aAAa,EACb,OAAO,EACP,YAAY,GAiBb,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,aAAa,EACb,MAAM,EACN,cAAc,EACd,SAAS,EACT,cAAc,EACd,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,0BAA0B,EAC1B,gBAAgB,EAGhB,UAAU,GAeX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,uBAAuB,EAAsB,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAE,UAAU,EAAgC,MAAM,WAAW,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EACL,WAAW,GAQZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,MAAM,EACN,WAAW,EACX,QAAQ,EACR,MAAM,EACN,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,KAAK,GAMN,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAyB,MAAM,wBAAwB,CAAC","sourcesContent":["/**\n * The engine's public surface.\n *\n * Nothing here imports Angular, and nothing here may start to: the engine stays\n * framework-agnostic (see docs/ARCHITECTURE.md), which is what keeps the commit logic testable without Angular in\n * the loop and a second adapter possible later.\n *\n * The CSS runtime lives here rather than in a package of its own because the cascade is driven\n * from the commit walk - the resolver runs per node, per tick - and because it is as\n * framework-agnostic as the rest of the engine. The build-time half of CSS is a different\n * animal and lives in `@ng-native/metro`.\n */\nexport {\n StyleResolver,\n matches,\n styleSheetOf,\n type AttributeTest,\n type Combinator,\n type Compound,\n type Conditions,\n type DeferredDeclaration,\n type GradientTemplate,\n type HslChannel,\n type MediaCondition,\n type NthTest,\n type RuleIndex,\n type StyleCache,\n type StyleRule,\n type StyleSheet,\n type StyleTarget,\n type TokenKind,\n type TokenValue,\n} from './css.ts';\nexport { ELEMENT_STYLES, ELEMENT_STYLES_CSS } from './element-styles.ts';\nexport { EngineIntersectionObserver, installDeferTriggers } from './defer-triggers.ts';\nexport { faceName } from './font-faces.ts';\nexport { firstFamily } from './inline-token.ts';\nexport {\n DIRECT_EVENTS,\n Engine,\n SyntheticEvent,\n claimHost,\n keepNativeView,\n declareNativeProps,\n fontsLoading,\n fontsRegistered,\n fontsSettled,\n markComponentHost,\n nativePlatform,\n onFontsRegistered,\n onFontsSettled,\n registerHoist,\n registerPlatformComponents,\n registerViewName,\n type PlatformViewName,\n type ViewNameOptions,\n viewNameOf,\n type EngineNode,\n type EngineOptions,\n type EngineStats,\n type FabricNode,\n type FabricNodeSet,\n type FabricUIManager,\n type HoistOptions,\n type NativeSyntheticEvent,\n type NodeKind,\n type ResponderEvent,\n type ResponderHandlers,\n type TouchPayload,\n type ViewNameNode,\n type WindowFrame,\n} from './engine.ts';\nexport { reportUnboundFormsInput, type NamedHostNode } from './forms-inputs.ts';\nexport { HostEngine, type HostNode, type Settling } from './host.ts';\nexport { getFabricUIManager } from './fabric.ts';\nexport {\n pinnedRange,\n type DrivenProperty,\n type EventFeed,\n type NativeAnimated,\n type ScrollAxis,\n type ScrollDrive,\n type ScrollRange,\n type StaticTransform,\n} from './native-drive.ts';\nexport {\n bezier,\n interpolate,\n redirect,\n sample,\n settled,\n step,\n tracksOf,\n tween,\n type AnimationSpec,\n type Keyframe,\n type RunningAnimation,\n type Transition,\n type TransitionSpec,\n} from './transition.ts';\nexport { backgroundLayers, type BackgroundLayers } from './background-layers.ts';\n"]}
@@ -216,6 +216,15 @@ export class NativeScrollDriver {
216
216
  const style = {};
217
217
  if (channels.opacity)
218
218
  style['opacity'] = interpolation(channels.opacity);
219
+ for (const [property, parts] of Object.entries(channels.colors ?? {})) {
220
+ const [r, g, b, a] = parts.map(interpolation);
221
+ const colour = this.native.generateNewNodeTag();
222
+ API.createAnimatedNode(colour, { type: 'color', r, g, b, a });
223
+ for (const part of [r, g, b, a])
224
+ API.connectAnimatedNodes(part, colour);
225
+ style[property] = colour;
226
+ made.push(colour);
227
+ }
219
228
  if (channels.transform.length) {
220
229
  const transforms = channels.transform.map((channel) => 'range' in channel
221
230
  ? { type: 'animated', property: channel.property, nodeTag: interpolation(channel.range) }
@@ -1 +1 @@
1
- {"version":3,"file":"native-drive.js","sourceRoot":"","sources":["../src/native-drive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA0FH,MAAM,OAAO,kBAAkB;IACZ,MAAM,CAAiB;IACxC,6DAA6D;IAC5C,OAAO,GAAG,IAAI,GAAG,EAA+B,CAAC;IACjD,OAAO,GAAG,IAAI,GAAG,EAAiB,CAAC;IAEpD,YAAY,MAAsB;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,KAAK,CACH,IAAY,EACZ,MAAc,EACd,IAAe,EACf,QAAwB,EACxB,KAAkB,EAClB,OAAmC,EACnC,KAAsC,EACtC,QAAuB,IAAI;QAE3B,MAAM,KAAK,GAAU,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAClF,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAC1B,MAAM,OAAO,GAAG,GAAY,EAAE;YAC5B,IAAI,KAAK,CAAC,OAAO;gBAAE,OAAO,IAAI,CAAC;YAC/B,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;YAC5B,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;YAChC,IAAI,OAAO,KAAK,IAAI,IAAI,SAAS,KAAK,IAAI;gBAAE,OAAO,KAAK,CAAC;YACzD,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;YACxB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;YACzD,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK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G,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAC3D,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,UAAU,CAAC,IAAgB;IACzC,OAAO,EAAE,MAAM,EAAE,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,CAAC,eAAe,EAAE,IAAI,CAAC,EAAE,CAAC;AACjE,CAAC;AAED,SAAS,SAAS,CAAC,CAAc,EAAE,CAAc;IAC/C,OAAO,CACL,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM;QACjC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjD,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CACpD,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa,EAAE,KAAK,GAAG,QAAQ;IACzD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,KAAK,EAAE,CAAC;QAC9C,yFAAyF;QACzF,OAAO,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;IAC3D,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC;AAC/D,CAAC","sourcesContent":["/**\n * A view moved by a scroll view's offset on the native side, with no JavaScript in between.\n *\n * A sticky header moved by a transform set from each scroll event lags the scroll: the event\n * reaches JavaScript, the transform is committed, and by the time Fabric mounts it the content has\n * moved on, so on a fast fling the header shudders and comes away from the edge it is pinned to.\n * React Native's own sticky headers do not, because `ScrollViewStickyHeader` maps the offset onto\n * an animated value on the native side and interpolates the header's translate from it there.\n * This is that mapping, for the engine's nodes: the scroll view's offset along one axis feeds a\n * value, the value an interpolation, the interpolation a translate, and native applies it on every\n * frame the scroll view moves.\n *\n * It goes through React Native's own `NativeAnimatedHelper`, whose node tags every other animated\n * value in the app also comes from, so none of them can collide.\n */\n\n/** The part of React Native's `NativeAnimatedHelper` default export this uses. */\nexport interface NativeAnimated {\n generateNewNodeTag(): number;\n generateNewAnimationId?(): number;\n readonly API: {\n /** Run a value through `config` on the native side, and say when it has ended. */\n startAnimatingNode?(\n animationId: number,\n nodeTag: number,\n config: object,\n end: (result: { finished: boolean }) => void,\n ): void;\n stopAnimation?(animationId: number): void;\n createAnimatedNode(tag: number, config: object): void;\n connectAnimatedNodes(parentTag: number, childTag: number): void;\n disconnectAnimatedNodes(parentTag: number, childTag: number): void;\n connectAnimatedNodeToView(nodeTag: number, viewTag: number): void;\n disconnectAnimatedNodeFromView(nodeTag: number, viewTag: number): void;\n dropAnimatedNode(tag: number): void;\n addAnimatedEventToView(\n viewTag: number,\n eventName: string,\n mapping: { nativeEventPath: string[]; animatedValueTag: number },\n ): void;\n removeAnimatedEventFromView(viewTag: number, eventName: string, nodeTag: number): void;\n setAnimatedNodeValue(nodeTag: number, value: number): void;\n flushQueue?(): void;\n };\n}\n\nimport type { DrivenChannels } from './scroll-animation.ts';\n\nexport type ScrollAxis = 'x' | 'y';\n\n/** A native event that feeds a value: the events carrying it, and the path to it in each. */\nexport interface EventFeed {\n readonly events: readonly string[];\n readonly path: readonly string[];\n}\n\n/** What a driven view moves along. */\nexport type DrivenProperty = 'translateX' | 'translateY';\n\n/** Where a driven view sits for each scroll offset, as an interpolation clamped at both ends. */\nexport interface ScrollRange {\n readonly input: readonly number[];\n readonly output: readonly number[];\n}\n\n/** A transform native keeps beside the driven translate, such as an inverted list's flip. */\nexport type StaticTransform = Readonly<Record<string, number>>;\n\n/**\n * A view moved by a scroll. `update` moves it by a new range; `shift` adds an amount to where the\n * range puts it, for a drive made with one; `stop` lets it go.\n */\nexport interface ScrollDrive {\n update(range: ScrollRange): void;\n shift(amount: number): void;\n stop(): void;\n}\n\ninterface Offset {\n readonly value: number;\n readonly viewTag: number;\n readonly feed: EventFeed;\n users: number;\n}\n\ninterface Nodes {\n interpolation: number;\n /** The shift JavaScript sets, and the sum of it and the interpolation, for a shifted drive. */\n shift: number | null;\n sum: number | null;\n transform: number;\n style: number;\n props: number;\n}\n\ninterface Drive {\n viewTag: number | null;\n range: ScrollRange;\n /** The amount added to the range's translate, or null for a drive without one. */\n shift: number | null;\n nodes: Nodes | null;\n stopped: boolean;\n}\n\nexport class NativeScrollDriver {\n private readonly native: NativeAnimated;\n /** One value per source view and feed, by the feed's key. */\n private readonly offsets = new Map<object, Map<string, Offset>>();\n private readonly pending = new Set<() => boolean>();\n\n constructor(native: NativeAnimated) {\n this.native = native;\n }\n\n /**\n * Move a view by a scroll. `tagOf` answers a node's view tag once it has been committed, and\n * null before, which is why the connection may wait for a commit: `connect` is tried again by\n * `afterCommit` until both views exist.\n */\n drive(\n view: object,\n source: object,\n feed: EventFeed,\n property: DrivenProperty,\n range: ScrollRange,\n statics: readonly StaticTransform[],\n tagOf: (node: object) => number | null,\n shift: number | null = null,\n ): ScrollDrive {\n const drive: Drive = { viewTag: null, range, shift, nodes: null, stopped: false };\n const key = feedKey(feed);\n const connect = (): boolean => {\n if (drive.stopped) return true;\n const viewTag = tagOf(view);\n const sourceTag = tagOf(source);\n if (viewTag === null || sourceTag === null) return false;\n drive.viewTag = viewTag;\n const offset = this.offset(source, sourceTag, feed, key);\n drive.nodes = this.build(offset.value, viewTag, property, drive, statics);\n this.flush();\n return true;\n };\n if (!connect()) this.pending.add(connect);\n return {\n update: (next) => {\n if (drive.stopped || sameRange(drive.range, next)) return;\n drive.range = next;\n if (!drive.nodes || drive.viewTag === null) return;\n this.tearDown(drive.nodes, drive.viewTag);\n const offset = this.offsets.get(source)!.get(key)!;\n drive.nodes = this.build(offset.value, drive.viewTag, property, drive, statics);\n this.flush();\n },\n shift: (amount) => {\n if (drive.stopped || drive.shift === null || drive.shift === amount) return;\n drive.shift = amount;\n if (drive.nodes?.shift == null) return;\n this.native.API.setAnimatedNodeValue(drive.nodes.shift, amount);\n this.flush();\n },\n stop: () => {\n if (drive.stopped) return;\n drive.stopped = true;\n this.pending.delete(connect);\n if (!drive.nodes || drive.viewTag === null) return;\n this.tearDown(drive.nodes, drive.viewTag);\n this.release(source, key);\n this.flush();\n },\n };\n }\n\n /**\n * Play a view's opacity and transform by a scroll: each channel an interpolation from the\n * offset, as `scroll-animation.ts` lays a `@keyframes` animation along it. `update` rebuilds\n * the channels, when the scroll view says how far it scrolls; `stop` lets the view go.\n */\n animate(\n view: object,\n source: object,\n feed: EventFeed,\n channels: DrivenChannels,\n tagOf: (node: object) => number | null,\n ): { update(channels: DrivenChannels): void; stop(): void } {\n const state = {\n channels,\n viewTag: null as number | null,\n nodes: null as number[] | null,\n stopped: false,\n };\n const key = feedKey(feed);\n const connect = (): boolean => {\n if (state.stopped) return true;\n const viewTag = tagOf(view);\n const sourceTag = tagOf(source);\n if (viewTag === null || sourceTag === null) return false;\n state.viewTag = viewTag;\n const offset = this.offset(source, sourceTag, feed, key);\n state.nodes = this.buildChannels(offset.value, viewTag, state.channels);\n this.flush();\n return true;\n };\n if (!connect()) this.pending.add(connect);\n return {\n update: (next) => {\n if (state.stopped) return;\n state.channels = next;\n if (!state.nodes || state.viewTag === null) return;\n this.dropChannels(state.nodes, state.viewTag);\n const offset = this.offsets.get(source)!.get(key)!;\n state.nodes = this.buildChannels(offset.value, state.viewTag, next);\n this.flush();\n },\n stop: () => {\n if (state.stopped) return;\n state.stopped = true;\n this.pending.delete(connect);\n if (!state.nodes || state.viewTag === null) return;\n this.dropChannels(state.nodes, state.viewTag);\n this.release(source, key);\n this.flush();\n },\n };\n }\n\n /**\n * Play a view's opacity and transform by the clock: each channel an interpolation from a value\n * native runs from nothing to `timing.toValue`, over the frames it is given, as many times as\n * asked. Nothing runs in JavaScript while it plays. `ended` is told when native reaches the end\n * of the last iteration; `stop` lets the view go, and stops an animation still playing.\n *\n * Null where the native module cannot start an animation, and the caller plays it itself.\n */\n play(\n view: object,\n channels: DrivenChannels,\n timing: { frames: readonly number[]; toValue: number; iterations: number },\n tagOf: (node: object) => number | null,\n ended: () => void,\n ): { stop(): void } | null {\n const { API } = this.native;\n const start = API.startAnimatingNode;\n if (!start || !API.stopAnimation || !this.native.generateNewAnimationId) return null;\n const state = {\n viewTag: null as number | null,\n nodes: null as number[] | null,\n value: 0,\n id: 0,\n over: false,\n };\n const connect = (): boolean => {\n if (state.over) return true;\n const viewTag = tagOf(view);\n if (viewTag === null) return false;\n state.viewTag = viewTag;\n state.value = this.native.generateNewNodeTag();\n API.createAnimatedNode(state.value, { type: 'value', value: 0, offset: 0 });\n state.nodes = this.buildChannels(state.value, viewTag, channels);\n state.id = this.native.generateNewAnimationId!();\n const config = { type: 'frames', frames: [...timing.frames], toValue: timing.toValue };\n start(state.id, state.value, { ...config, iterations: timing.iterations }, (result) => {\n // Stopped rather than finished is the caller's own doing, and it knows.\n if (!result.finished || state.over) return;\n state.id = 0;\n // Written once more, to the view as it is now. A view is mounted when the task that\n // made it is over, and an animation no longer than that task is over before there is a\n // view to move: the view is then mounted at the frame the animation started from.\n API.setAnimatedNodeValue(state.value, timing.toValue);\n this.flush();\n ended();\n });\n this.flush();\n return true;\n };\n if (!connect()) this.pending.add(connect);\n return {\n stop: () => {\n if (state.over) return;\n state.over = true;\n this.pending.delete(connect);\n if (!state.nodes || state.viewTag === null) return;\n if (state.id) API.stopAnimation!(state.id);\n this.dropChannels(state.nodes, state.viewTag);\n API.dropAnimatedNode(state.value);\n this.flush();\n },\n };\n }\n\n /** The nodes for a set of channels, connected to the view; the props node first. */\n private buildChannels(value: number, viewTag: number, channels: DrivenChannels): number[] {\n const { API } = this.native;\n const made: number[] = [];\n const interpolation = (range: ScrollRange): number => {\n const tag = this.native.generateNewNodeTag();\n API.createAnimatedNode(tag, {\n type: 'interpolation',\n inputRange: [...range.input],\n outputRange: [...range.output],\n extrapolateLeft: 'clamp',\n extrapolateRight: 'clamp',\n });\n API.connectAnimatedNodes(value, tag);\n made.push(tag);\n return tag;\n };\n const style: Record<string, number> = {};\n if (channels.opacity) style['opacity'] = interpolation(channels.opacity);\n if (channels.transform.length) {\n const transforms = channels.transform.map((channel) =>\n 'range' in channel\n ? { type: 'animated', property: channel.property, nodeTag: interpolation(channel.range) }\n : { type: 'static', property: channel.property, value: channel.value },\n );\n const transform = this.native.generateNewNodeTag();\n API.createAnimatedNode(transform, { type: 'transform', transforms });\n for (const entry of transforms) {\n if (entry.type === 'animated') API.connectAnimatedNodes(entry.nodeTag!, transform);\n }\n style['transform'] = transform;\n made.push(transform);\n }\n const styleTag = this.native.generateNewNodeTag();\n API.createAnimatedNode(styleTag, { type: 'style', style });\n for (const tag of Object.values(style)) API.connectAnimatedNodes(tag, styleTag);\n const props = this.native.generateNewNodeTag();\n API.createAnimatedNode(props, { type: 'props', props: { style: styleTag } });\n API.connectAnimatedNodes(styleTag, props);\n API.connectAnimatedNodeToView(props, viewTag);\n return [props, styleTag, ...made.reverse()];\n }\n\n private dropChannels(nodes: readonly number[], viewTag: number): void {\n const { API } = this.native;\n API.disconnectAnimatedNodeFromView(nodes[0]!, viewTag);\n for (const tag of nodes) API.dropAnimatedNode(tag);\n }\n\n /** Connects every drive still waiting for its views, now that a commit may have made them. */\n afterCommit(): void {\n for (const connect of [...this.pending]) if (connect()) this.pending.delete(connect);\n }\n\n /** One value per source view and feed, fed by its events, shared by every view it drives. */\n private offset(source: object, viewTag: number, feed: EventFeed, key: string): Offset {\n let feeds = this.offsets.get(source);\n if (!feeds) this.offsets.set(source, (feeds = new Map()));\n let offset = feeds.get(key);\n if (!offset) {\n const value = this.native.generateNewNodeTag();\n this.native.API.createAnimatedNode(value, { type: 'value', value: 0, offset: 0 });\n for (const event of feed.events) {\n this.native.API.addAnimatedEventToView(viewTag, event, {\n nativeEventPath: [...feed.path],\n animatedValueTag: value,\n });\n }\n offset = { value, viewTag, feed, users: 0 };\n feeds.set(key, offset);\n }\n offset.users++;\n return offset;\n }\n\n private release(source: object, key: string): void {\n const feeds = this.offsets.get(source);\n const offset = feeds?.get(key);\n if (!feeds || !offset || --offset.users > 0) return;\n feeds.delete(key);\n if (feeds.size === 0) this.offsets.delete(source);\n for (const event of offset.feed.events) {\n this.native.API.removeAnimatedEventFromView(offset.viewTag, event, offset.value);\n }\n this.native.API.dropAnimatedNode(offset.value);\n }\n\n private build(\n value: number,\n viewTag: number,\n property: DrivenProperty,\n drive: Drive,\n statics: readonly StaticTransform[],\n ): Nodes {\n const { API } = this.native;\n const range = drive.range;\n const interpolation = this.native.generateNewNodeTag();\n API.createAnimatedNode(interpolation, {\n type: 'interpolation',\n inputRange: [...range.input],\n outputRange: [...range.output],\n extrapolateLeft: 'clamp',\n extrapolateRight: 'clamp',\n });\n let shift: number | null = null;\n let sum: number | null = null;\n if (drive.shift !== null) {\n shift = this.native.generateNewNodeTag();\n API.createAnimatedNode(shift, { type: 'value', value: drive.shift, offset: 0 });\n sum = this.native.generateNewNodeTag();\n API.createAnimatedNode(sum, { type: 'addition', input: [interpolation, shift] });\n }\n const transform = this.native.generateNewNodeTag();\n API.createAnimatedNode(transform, {\n type: 'transform',\n transforms: [\n {\n type: 'animated',\n property,\n nodeTag: sum ?? interpolation,\n },\n ...statics.flatMap((entry) =>\n Object.entries(entry).map(([property, amount]) => ({\n type: 'static',\n property,\n value: amount,\n })),\n ),\n ],\n });\n // A style node between, as `Animated` builds it: RN's props node on iOS reads its values from\n // a style node and ignores a transform node connected to it directly.\n const style = this.native.generateNewNodeTag();\n API.createAnimatedNode(style, { type: 'style', style: { transform } });\n const props = this.native.generateNewNodeTag();\n API.createAnimatedNode(props, { type: 'props', props: { style } });\n API.connectAnimatedNodes(value, interpolation);\n if (shift !== null && sum !== null) {\n API.connectAnimatedNodes(interpolation, sum);\n API.connectAnimatedNodes(shift, sum);\n API.connectAnimatedNodes(sum, transform);\n } else {\n API.connectAnimatedNodes(interpolation, transform);\n }\n API.connectAnimatedNodes(transform, style);\n API.connectAnimatedNodes(style, props);\n API.connectAnimatedNodeToView(props, viewTag);\n return { interpolation, shift, sum, transform, style, props };\n }\n\n private tearDown(nodes: Nodes, viewTag: number): void {\n const { API } = this.native;\n API.disconnectAnimatedNodeFromView(nodes.props, viewTag);\n API.dropAnimatedNode(nodes.props);\n API.dropAnimatedNode(nodes.style);\n API.dropAnimatedNode(nodes.transform);\n if (nodes.sum !== null) API.dropAnimatedNode(nodes.sum);\n if (nodes.shift !== null) API.dropAnimatedNode(nodes.shift);\n API.dropAnimatedNode(nodes.interpolation);\n }\n\n private flush(): void {\n this.native.API.flushQueue?.();\n }\n}\n\nfunction feedKey(feed: EventFeed): string {\n return `${feed.events.join(',')}:${feed.path.join('.')}`;\n}\n\n/** A scroll view's offset along an axis, as `onScroll` carries it. */\nexport function scrollFeed(axis: ScrollAxis): EventFeed {\n return { events: ['onScroll'], path: ['contentOffset', axis] };\n}\n\nfunction sameRange(a: ScrollRange, b: ScrollRange): boolean {\n return (\n a.input.length === b.input.length &&\n a.input.every((value, i) => value === b.input[i]) &&\n a.output.every((value, i) => value === b.output[i])\n );\n}\n\n/**\n * The translate a pinned view needs at each scroll offset: none until the offset reaches where\n * the view starts, then the offset past that, until `until`, where the next pinned view pushes it\n * off and it stays. `start` and `until` are in the scroll view's own coordinates.\n */\nexport function pinnedRange(start: number, until = Infinity): ScrollRange {\n if (!Number.isFinite(until) || until <= start) {\n // A large finite end, since native interpolation takes numbers and extends nothing here.\n return { input: [start, start + 1e7], output: [0, 1e7] };\n }\n return { input: [start, until], output: [0, until - start] };\n}\n"]}
1
+ {"version":3,"file":"native-drive.js","sour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ACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa,EAAE,KAAK,GAAG,QAAQ;IACzD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,KAAK,EAAE,CAAC;QAC9C,yFAAyF;QACzF,OAAO,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;IAC3D,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC;AAC/D,CAAC","sourcesContent":["/**\n * A view moved by a scroll view's offset on the native side, with no JavaScript in between.\n *\n * A sticky header moved by a transform set from each scroll event lags the scroll: the event\n * reaches JavaScript, the transform is committed, and by the time Fabric mounts it the content has\n * moved on, so on a fast fling the header shudders and comes away from the edge it is pinned to.\n * React Native's own sticky headers do not, because `ScrollViewStickyHeader` maps the offset onto\n * an animated value on the native side and interpolates the header's translate from it there.\n * This is that mapping, for the engine's nodes: the scroll view's offset along one axis feeds a\n * value, the value an interpolation, the interpolation a translate, and native applies it on every\n * frame the scroll view moves.\n *\n * It goes through React Native's own `NativeAnimatedHelper`, whose node tags every other animated\n * value in the app also comes from, so none of them can collide.\n */\n\n/** The part of React Native's `NativeAnimatedHelper` default export this uses. */\nexport interface NativeAnimated {\n generateNewNodeTag(): number;\n generateNewAnimationId?(): number;\n readonly API: {\n /** Run a value through `config` on the native side, and say when it has ended. */\n startAnimatingNode?(\n animationId: number,\n nodeTag: number,\n config: object,\n end: (result: { finished: boolean }) => void,\n ): void;\n stopAnimation?(animationId: number): void;\n createAnimatedNode(tag: number, config: object): void;\n connectAnimatedNodes(parentTag: number, childTag: number): void;\n disconnectAnimatedNodes(parentTag: number, childTag: number): void;\n connectAnimatedNodeToView(nodeTag: number, viewTag: number): void;\n disconnectAnimatedNodeFromView(nodeTag: number, viewTag: number): void;\n dropAnimatedNode(tag: number): void;\n addAnimatedEventToView(\n viewTag: number,\n eventName: string,\n mapping: { nativeEventPath: string[]; animatedValueTag: number },\n ): void;\n removeAnimatedEventFromView(viewTag: number, eventName: string, nodeTag: number): void;\n setAnimatedNodeValue(nodeTag: number, value: number): void;\n flushQueue?(): void;\n };\n}\n\nimport type { DrivenChannels } from './scroll-animation.ts';\n\nexport type ScrollAxis = 'x' | 'y';\n\n/** A native event that feeds a value: the events carrying it, and the path to it in each. */\nexport interface EventFeed {\n readonly events: readonly string[];\n readonly path: readonly string[];\n}\n\n/** What a driven view moves along. */\nexport type DrivenProperty = 'translateX' | 'translateY';\n\n/** Where a driven view sits for each scroll offset, as an interpolation clamped at both ends. */\nexport interface ScrollRange {\n readonly input: readonly number[];\n readonly output: readonly number[];\n}\n\n/** A transform native keeps beside the driven translate, such as an inverted list's flip. */\nexport type StaticTransform = Readonly<Record<string, number>>;\n\n/**\n * A view moved by a scroll. `update` moves it by a new range; `shift` adds an amount to where the\n * range puts it, for a drive made with one; `stop` lets it go.\n */\nexport interface ScrollDrive {\n update(range: ScrollRange): void;\n shift(amount: number): void;\n stop(): void;\n}\n\ninterface Offset {\n readonly value: number;\n readonly viewTag: number;\n readonly feed: EventFeed;\n users: number;\n}\n\ninterface Nodes {\n interpolation: number;\n /** The shift JavaScript sets, and the sum of it and the interpolation, for a shifted drive. */\n shift: number | null;\n sum: number | null;\n transform: number;\n style: number;\n props: number;\n}\n\ninterface Drive {\n viewTag: number | null;\n range: ScrollRange;\n /** The amount added to the range's translate, or null for a drive without one. */\n shift: number | null;\n nodes: Nodes | null;\n stopped: boolean;\n}\n\nexport class NativeScrollDriver {\n private readonly native: NativeAnimated;\n /** One value per source view and feed, by the feed's key. */\n private readonly offsets = new Map<object, Map<string, Offset>>();\n private readonly pending = new Set<() => boolean>();\n\n constructor(native: NativeAnimated) {\n this.native = native;\n }\n\n /**\n * Move a view by a scroll. `tagOf` answers a node's view tag once it has been committed, and\n * null before, which is why the connection may wait for a commit: `connect` is tried again by\n * `afterCommit` until both views exist.\n */\n drive(\n view: object,\n source: object,\n feed: EventFeed,\n property: DrivenProperty,\n range: ScrollRange,\n statics: readonly StaticTransform[],\n tagOf: (node: object) => number | null,\n shift: number | null = null,\n ): ScrollDrive {\n const drive: Drive = { viewTag: null, range, shift, nodes: null, stopped: false };\n const key = feedKey(feed);\n const connect = (): boolean => {\n if (drive.stopped) return true;\n const viewTag = tagOf(view);\n const sourceTag = tagOf(source);\n if (viewTag === null || sourceTag === null) return false;\n drive.viewTag = viewTag;\n const offset = this.offset(source, sourceTag, feed, key);\n drive.nodes = this.build(offset.value, viewTag, property, drive, statics);\n this.flush();\n return true;\n };\n if (!connect()) this.pending.add(connect);\n return {\n update: (next) => {\n if (drive.stopped || sameRange(drive.range, next)) return;\n drive.range = next;\n if (!drive.nodes || drive.viewTag === null) return;\n this.tearDown(drive.nodes, drive.viewTag);\n const offset = this.offsets.get(source)!.get(key)!;\n drive.nodes = this.build(offset.value, drive.viewTag, property, drive, statics);\n this.flush();\n },\n shift: (amount) => {\n if (drive.stopped || drive.shift === null || drive.shift === amount) return;\n drive.shift = amount;\n if (drive.nodes?.shift == null) return;\n this.native.API.setAnimatedNodeValue(drive.nodes.shift, amount);\n this.flush();\n },\n stop: () => {\n if (drive.stopped) return;\n drive.stopped = true;\n this.pending.delete(connect);\n if (!drive.nodes || drive.viewTag === null) return;\n this.tearDown(drive.nodes, drive.viewTag);\n this.release(source, key);\n this.flush();\n },\n };\n }\n\n /**\n * Play a view's opacity and transform by a scroll: each channel an interpolation from the\n * offset, as `scroll-animation.ts` lays a `@keyframes` animation along it. `update` rebuilds\n * the channels, when the scroll view says how far it scrolls; `stop` lets the view go.\n */\n animate(\n view: object,\n source: object,\n feed: EventFeed,\n channels: DrivenChannels,\n tagOf: (node: object) => number | null,\n ): { update(channels: DrivenChannels): void; stop(): void } {\n const state = {\n channels,\n viewTag: null as number | null,\n nodes: null as number[] | null,\n stopped: false,\n };\n const key = feedKey(feed);\n const connect = (): boolean => {\n if (state.stopped) return true;\n const viewTag = tagOf(view);\n const sourceTag = tagOf(source);\n if (viewTag === null || sourceTag === null) return false;\n state.viewTag = viewTag;\n const offset = this.offset(source, sourceTag, feed, key);\n state.nodes = this.buildChannels(offset.value, viewTag, state.channels);\n this.flush();\n return true;\n };\n if (!connect()) this.pending.add(connect);\n return {\n update: (next) => {\n if (state.stopped) return;\n state.channels = next;\n if (!state.nodes || state.viewTag === null) return;\n this.dropChannels(state.nodes, state.viewTag);\n const offset = this.offsets.get(source)!.get(key)!;\n state.nodes = this.buildChannels(offset.value, state.viewTag, next);\n this.flush();\n },\n stop: () => {\n if (state.stopped) return;\n state.stopped = true;\n this.pending.delete(connect);\n if (!state.nodes || state.viewTag === null) return;\n this.dropChannels(state.nodes, state.viewTag);\n this.release(source, key);\n this.flush();\n },\n };\n }\n\n /**\n * Play a view's opacity and transform by the clock: each channel an interpolation from a value\n * native runs from nothing to `timing.toValue`, over the frames it is given, as many times as\n * asked. Nothing runs in JavaScript while it plays. `ended` is told when native reaches the end\n * of the last iteration; `stop` lets the view go, and stops an animation still playing.\n *\n * Null where the native module cannot start an animation, and the caller plays it itself.\n */\n play(\n view: object,\n channels: DrivenChannels,\n timing: { frames: readonly number[]; toValue: number; iterations: number },\n tagOf: (node: object) => number | null,\n ended: () => void,\n ): { stop(): void } | null {\n const { API } = this.native;\n const start = API.startAnimatingNode;\n if (!start || !API.stopAnimation || !this.native.generateNewAnimationId) return null;\n const state = {\n viewTag: null as number | null,\n nodes: null as number[] | null,\n value: 0,\n id: 0,\n over: false,\n };\n const connect = (): boolean => {\n if (state.over) return true;\n const viewTag = tagOf(view);\n if (viewTag === null) return false;\n state.viewTag = viewTag;\n state.value = this.native.generateNewNodeTag();\n API.createAnimatedNode(state.value, { type: 'value', value: 0, offset: 0 });\n state.nodes = this.buildChannels(state.value, viewTag, channels);\n state.id = this.native.generateNewAnimationId!();\n const config = { type: 'frames', frames: [...timing.frames], toValue: timing.toValue };\n start(state.id, state.value, { ...config, iterations: timing.iterations }, (result) => {\n // Stopped rather than finished is the caller's own doing, and it knows.\n if (!result.finished || state.over) return;\n state.id = 0;\n // Written once more, to the view as it is now. A view is mounted when the task that\n // made it is over, and an animation no longer than that task is over before there is a\n // view to move: the view is then mounted at the frame the animation started from.\n API.setAnimatedNodeValue(state.value, timing.toValue);\n this.flush();\n ended();\n });\n this.flush();\n return true;\n };\n if (!connect()) this.pending.add(connect);\n return {\n stop: () => {\n if (state.over) return;\n state.over = true;\n this.pending.delete(connect);\n if (!state.nodes || state.viewTag === null) return;\n if (state.id) API.stopAnimation!(state.id);\n this.dropChannels(state.nodes, state.viewTag);\n API.dropAnimatedNode(state.value);\n this.flush();\n },\n };\n }\n\n /** The nodes for a set of channels, connected to the view; the props node first. */\n private buildChannels(value: number, viewTag: number, channels: DrivenChannels): number[] {\n const { API } = this.native;\n const made: number[] = [];\n const interpolation = (range: ScrollRange): number => {\n const tag = this.native.generateNewNodeTag();\n API.createAnimatedNode(tag, {\n type: 'interpolation',\n inputRange: [...range.input],\n outputRange: [...range.output],\n extrapolateLeft: 'clamp',\n extrapolateRight: 'clamp',\n });\n API.connectAnimatedNodes(value, tag);\n made.push(tag);\n return tag;\n };\n const style: Record<string, number> = {};\n if (channels.opacity) style['opacity'] = interpolation(channels.opacity);\n for (const [property, parts] of Object.entries(channels.colors ?? {})) {\n const [r, g, b, a] = parts.map(interpolation);\n const colour = this.native.generateNewNodeTag();\n API.createAnimatedNode(colour, { type: 'color', r, g, b, a });\n for (const part of [r, g, b, a]) API.connectAnimatedNodes(part!, colour);\n style[property] = colour;\n made.push(colour);\n }\n if (channels.transform.length) {\n const transforms = channels.transform.map((channel) =>\n 'range' in channel\n ? { type: 'animated', property: channel.property, nodeTag: interpolation(channel.range) }\n : { type: 'static', property: channel.property, value: channel.value },\n );\n const transform = this.native.generateNewNodeTag();\n API.createAnimatedNode(transform, { type: 'transform', transforms });\n for (const entry of transforms) {\n if (entry.type === 'animated') API.connectAnimatedNodes(entry.nodeTag!, transform);\n }\n style['transform'] = transform;\n made.push(transform);\n }\n const styleTag = this.native.generateNewNodeTag();\n API.createAnimatedNode(styleTag, { type: 'style', style });\n for (const tag of Object.values(style)) API.connectAnimatedNodes(tag, styleTag);\n const props = this.native.generateNewNodeTag();\n API.createAnimatedNode(props, { type: 'props', props: { style: styleTag } });\n API.connectAnimatedNodes(styleTag, props);\n API.connectAnimatedNodeToView(props, viewTag);\n return [props, styleTag, ...made.reverse()];\n }\n\n private dropChannels(nodes: readonly number[], viewTag: number): void {\n const { API } = this.native;\n API.disconnectAnimatedNodeFromView(nodes[0]!, viewTag);\n for (const tag of nodes) API.dropAnimatedNode(tag);\n }\n\n /** Connects every drive still waiting for its views, now that a commit may have made them. */\n afterCommit(): void {\n for (const connect of [...this.pending]) if (connect()) this.pending.delete(connect);\n }\n\n /** One value per source view and feed, fed by its events, shared by every view it drives. */\n private offset(source: object, viewTag: number, feed: EventFeed, key: string): Offset {\n let feeds = this.offsets.get(source);\n if (!feeds) this.offsets.set(source, (feeds = new Map()));\n let offset = feeds.get(key);\n if (!offset) {\n const value = this.native.generateNewNodeTag();\n this.native.API.createAnimatedNode(value, { type: 'value', value: 0, offset: 0 });\n for (const event of feed.events) {\n this.native.API.addAnimatedEventToView(viewTag, event, {\n nativeEventPath: [...feed.path],\n animatedValueTag: value,\n });\n }\n offset = { value, viewTag, feed, users: 0 };\n feeds.set(key, offset);\n }\n offset.users++;\n return offset;\n }\n\n private release(source: object, key: string): void {\n const feeds = this.offsets.get(source);\n const offset = feeds?.get(key);\n if (!feeds || !offset || --offset.users > 0) return;\n feeds.delete(key);\n if (feeds.size === 0) this.offsets.delete(source);\n for (const event of offset.feed.events) {\n this.native.API.removeAnimatedEventFromView(offset.viewTag, event, offset.value);\n }\n this.native.API.dropAnimatedNode(offset.value);\n }\n\n private build(\n value: number,\n viewTag: number,\n property: DrivenProperty,\n drive: Drive,\n statics: readonly StaticTransform[],\n ): Nodes {\n const { API } = this.native;\n const range = drive.range;\n const interpolation = this.native.generateNewNodeTag();\n API.createAnimatedNode(interpolation, {\n type: 'interpolation',\n inputRange: [...range.input],\n outputRange: [...range.output],\n extrapolateLeft: 'clamp',\n extrapolateRight: 'clamp',\n });\n let shift: number | null = null;\n let sum: number | null = null;\n if (drive.shift !== null) {\n shift = this.native.generateNewNodeTag();\n API.createAnimatedNode(shift, { type: 'value', value: drive.shift, offset: 0 });\n sum = this.native.generateNewNodeTag();\n API.createAnimatedNode(sum, { type: 'addition', input: [interpolation, shift] });\n }\n const transform = this.native.generateNewNodeTag();\n API.createAnimatedNode(transform, {\n type: 'transform',\n transforms: [\n {\n type: 'animated',\n property,\n nodeTag: sum ?? interpolation,\n },\n ...statics.flatMap((entry) =>\n Object.entries(entry).map(([property, amount]) => ({\n type: 'static',\n property,\n value: amount,\n })),\n ),\n ],\n });\n // A style node between, as `Animated` builds it: RN's props node on iOS reads its values from\n // a style node and ignores a transform node connected to it directly.\n const style = this.native.generateNewNodeTag();\n API.createAnimatedNode(style, { type: 'style', style: { transform } });\n const props = this.native.generateNewNodeTag();\n API.createAnimatedNode(props, { type: 'props', props: { style } });\n API.connectAnimatedNodes(value, interpolation);\n if (shift !== null && sum !== null) {\n API.connectAnimatedNodes(interpolation, sum);\n API.connectAnimatedNodes(shift, sum);\n API.connectAnimatedNodes(sum, transform);\n } else {\n API.connectAnimatedNodes(interpolation, transform);\n }\n API.connectAnimatedNodes(transform, style);\n API.connectAnimatedNodes(style, props);\n API.connectAnimatedNodeToView(props, viewTag);\n return { interpolation, shift, sum, transform, style, props };\n }\n\n private tearDown(nodes: Nodes, viewTag: number): void {\n const { API } = this.native;\n API.disconnectAnimatedNodeFromView(nodes.props, viewTag);\n API.dropAnimatedNode(nodes.props);\n API.dropAnimatedNode(nodes.style);\n API.dropAnimatedNode(nodes.transform);\n if (nodes.sum !== null) API.dropAnimatedNode(nodes.sum);\n if (nodes.shift !== null) API.dropAnimatedNode(nodes.shift);\n API.dropAnimatedNode(nodes.interpolation);\n }\n\n private flush(): void {\n this.native.API.flushQueue?.();\n }\n}\n\nfunction feedKey(feed: EventFeed): string {\n return `${feed.events.join(',')}:${feed.path.join('.')}`;\n}\n\n/** A scroll view's offset along an axis, as `onScroll` carries it. */\nexport function scrollFeed(axis: ScrollAxis): EventFeed {\n return { events: ['onScroll'], path: ['contentOffset', axis] };\n}\n\nfunction sameRange(a: ScrollRange, b: ScrollRange): boolean {\n return (\n a.input.length === b.input.length &&\n a.input.every((value, i) => value === b.input[i]) &&\n a.output.every((value, i) => value === b.output[i])\n );\n}\n\n/**\n * The translate a pinned view needs at each scroll offset: none until the offset reaches where\n * the view starts, then the offset past that, until `until`, where the next pinned view pushes it\n * off and it stays. `start` and `until` are in the scroll view's own coordinates.\n */\nexport function pinnedRange(start: number, until = Infinity): ScrollRange {\n if (!Number.isFinite(until) || until <= start) {\n // A large finite end, since native interpolation takes numbers and extends nothing here.\n return { input: [start, start + 1e7], output: [0, 1e7] };\n }\n return { input: [start, until], output: [0, until - start] };\n}\n"]}
@@ -16,9 +16,12 @@ type Track = readonly {
16
16
  /** The channels a scroll-driven animation drives natively, in the order native applies them. */
17
17
  export interface DrivenChannels {
18
18
  readonly opacity?: ScrollRange;
19
+ /** Each colour native eases, as its red, green, blue and alpha: see `colourChannels`. */
20
+ readonly colors?: Readonly<Record<string, ColourRanges>>;
19
21
  /** Every transform entry the view paints: driven by the scroll, or held as it is. */
20
22
  readonly transform: readonly TransformChannel[];
21
23
  }
24
+ export type ColourRanges = readonly [ScrollRange, ScrollRange, ScrollRange, ScrollRange];
22
25
  export type TransformChannel = {
23
26
  readonly property: string;
24
27
  readonly range: ScrollRange;
@@ -36,6 +39,14 @@ export declare function scrollChannels(tracks: ReadonlyMap<string, Track>, spec:
36
39
  channels: DrivenChannels;
37
40
  held: string[];
38
41
  };
42
+ /**
43
+ * The channels for each colour eased by the clock from nothing to one: its red, green, blue and
44
+ * alpha, each a range of its own, which is how native has a colour. Sampled along the way as
45
+ * JavaScript mixes the two, in premultiplied alpha and by the curve: native mixes a channel at
46
+ * a time and in a straight line, which is another colour half way between two of different
47
+ * alpha. Nothing for a track that is not two colours.
48
+ */
49
+ export declare function colourChannels(tracks: ReadonlyMap<string, Track>, spec: AnimationSpec): Record<string, ColourRanges> | null;
39
50
  /**
40
51
  * The channels for an animation played by the clock, along a value native runs from nothing to
41
52
  * `span`: one iteration along 0 to 1, and for `alternate` the way back along 1 to 2, so that
@@ -1,4 +1,4 @@
1
- import { at } from "./transition.js";
1
+ import { at, bezier, interpolate, parseColor, } from "./transition.js";
2
2
  /** What a range with no end, or a percentage of one, stands in for until the scroll view says. */
3
3
  const UNKNOWN_EXTENT = 1e6;
4
4
  /** Points per eased segment: enough that the curve between them reads as the curve. */
@@ -50,6 +50,35 @@ export function scrollChannels(tracks, spec, resting, range) {
50
50
  held,
51
51
  };
52
52
  }
53
+ /** How many stretches a colour's way is cut into: each is straight on native. */
54
+ const COLOUR_STEPS = 16;
55
+ /**
56
+ * The channels for each colour eased by the clock from nothing to one: its red, green, blue and
57
+ * alpha, each a range of its own, which is how native has a colour. Sampled along the way as
58
+ * JavaScript mixes the two, in premultiplied alpha and by the curve: native mixes a channel at
59
+ * a time and in a straight line, which is another colour half way between two of different
60
+ * alpha. Nothing for a track that is not two colours.
61
+ */
62
+ export function colourChannels(tracks, spec) {
63
+ const colors = {};
64
+ for (const [property, track] of tracks) {
65
+ const [from, to] = track;
66
+ if (track.length !== 2 || !parseColor(from.value) || !parseColor(to.value))
67
+ return null;
68
+ const input = [];
69
+ const parts = [[], [], [], []];
70
+ for (let step = 0; step <= COLOUR_STEPS; step++) {
71
+ const along = step / COLOUR_STEPS;
72
+ const mixed = parseColor(interpolate(from.value, to.value, bezier(spec.easing, along)));
73
+ if (!mixed)
74
+ return null;
75
+ input.push(along);
76
+ mixed.forEach((part, at) => parts[at].push(round(part)));
77
+ }
78
+ colors[property] = parts.map((output) => ({ input, output }));
79
+ }
80
+ return colors;
81
+ }
53
82
  /**
54
83
  * The channels for an animation played by the clock, along a value native runs from nothing to
55
84
  * `span`: one iteration along 0 to 1, and for `alternate` the way back along 1 to 2, so that
@@ -1 +1 @@
1
- {"version":3,"file":"scroll-animation.js","sourceRoot":"","sources":["../src/scroll-animation.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,EAAE,EAAuC,MAAM,iBAAiB,CAAC;AAe1E,kGAAkG;AAClG,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B,uFAAuF;AACvF,MAAM,OAAO,GAAG,EAAE,CAAC;AAEnB,uFAAuF;AACvF,MAAM,MAAM,GAAG,CAAC,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,CAAU,CAAC;AAE5E,mEAAmE;AACnE,MAAM,UAAU,OAAO,CAAC,IAAmB,EAAE,MAAqB;IAChE,MAAM,GAAG,GAAG,CAAC,KAAkC,EAAE,SAAiB,EAAU,EAAE;QAC5E,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QAC5C,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,MAAM,IAAI,cAAc,CAAC,CAAC;IAChE,CAAC,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,IAAI,cAAc,CAAC,CAAC,CAAC;AACrF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAkC,EAClC,IAAmB,EACnB,OAA0C,EAC1C,KAAgC;IAEhC,MAAM,KAAK,GAAG,CAAC,KAAY,EAAE,IAAuC,EAAE,IAAY,EAAE,EAAE,CACp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K,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;IAC/C,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,KAAK,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,MAAM;QAAE,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACzF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/**\n * A `@keyframes` animation played by a scroll view's offset: `animation-timeline: scroll()`.\n *\n * Native interpolates linearly between the points it is given and clamps past both ends, which is\n * all a scroll-driven animation needs from it once its keyframes are laid along the offset: each\n * keyframe sits at its share of the range, a segment's timing function is sampled into points\n * along it, and an unfilled end falls back to the resting value just outside the range. What\n * native can animate this way is opacity and the transforms; anything else holds its first frame.\n */\nimport type { ScrollRange } from './native-drive.ts';\nimport { at, type AnimationSpec, type TrackPoint } from './transition.ts';\n\ntype Track = readonly { offset: number; value: unknown }[];\n\n/** The channels a scroll-driven animation drives natively, in the order native applies them. */\nexport interface DrivenChannels {\n readonly opacity?: ScrollRange;\n /** Every transform entry the view paints: driven by the scroll, or held as it is. */\n readonly transform: readonly TransformChannel[];\n}\n\nexport type TransformChannel =\n | { readonly property: string; readonly range: ScrollRange }\n | { readonly property: string; readonly value: number };\n\n/** What a range with no end, or a percentage of one, stands in for until the scroll view says. */\nconst UNKNOWN_EXTENT = 1e6;\n\n/** Points per eased segment: enough that the curve between them reads as the curve. */\nconst SAMPLES = 12;\n\n/** The transform groups in the order CSS applies them, as the engine composes them. */\nconst GROUPS = ['__translate', '__rotate', '__scale', 'transform'] as const;\n\n/** Where the range starts and ends on the scroll view's offset. */\nexport function rangeOf(spec: AnimationSpec, extent: number | null): [number, number] {\n const end = (value: number | string | undefined, otherwise: number): number => {\n if (value === undefined) return otherwise;\n if (typeof value === 'number') return value;\n return (parseFloat(value) / 100) * (extent ?? UNKNOWN_EXTENT);\n };\n return [end(spec.range?.start, 0), end(spec.range?.end, extent ?? UNKNOWN_EXTENT)];\n}\n\n/**\n * The channels for an animation's tracks over a range, and the properties it cannot drive\n * natively, which the caller holds at their first frame.\n */\nexport function scrollChannels(\n tracks: ReadonlyMap<string, Track>,\n spec: AnimationSpec,\n resting: Readonly<Record<string, unknown>>,\n range: readonly [number, number],\n): { channels: DrivenChannels; held: string[] } {\n const along = (track: Track, pick: (value: unknown) => number | null, rest: number) =>\n laid(track, pick, rest, spec, range);\n const held: string[] = [];\n let opacity: ScrollRange | undefined;\n const transform: TransformChannel[] = [];\n for (const [property, track] of tracks) {\n if (property === 'opacity') {\n opacity =\n along(\n track,\n (value) => (typeof value === 'number' ? value : null),\n numberOr(resting['opacity'], 1),\n ) ?? undefined;\n if (!opacity) held.push(property);\n } else if (!(GROUPS as readonly string[]).includes(property)) {\n held.push(property);\n }\n }\n for (const group of GROUPS) {\n const track = tracks.get(group);\n const channels = track ? drivenGroup(track, resting[group], along) : heldGroup(resting[group]);\n if (channels === null) held.push(group);\n else transform.push(...channels);\n }\n const anyDriven = transform.some((channel) => 'range' in channel);\n return {\n channels: { ...(opacity ? { opacity } : {}), transform: anyDriven ? transform : [] },\n held,\n };\n}\n\n/**\n * The channels for an animation played by the clock, along a value native runs from nothing to\n * `span`: one iteration along 0 to 1, and for `alternate` the way back along 1 to 2, so that\n * native repeats there and back as one animation. Both ends are the frames' own: what the\n * element rests at is committed when the animation ends, and not played.\n */\nexport function clockChannels(\n tracks: ReadonlyMap<string, Track>,\n spec: AnimationSpec,\n resting: Readonly<Record<string, unknown>>,\n): { channels: DrivenChannels; held: string[]; span: number } {\n const way = (direction: AnimationSpec['direction'], range: readonly [number, number]) =>\n scrollChannels(tracks, { ...spec, fill: 'both', direction }, resting, range);\n if (spec.direction !== 'alternate' && spec.direction !== 'alternate-reverse') {\n return { ...way(spec.direction, [0, 1]), span: 1 };\n }\n const reversed = spec.direction === 'alternate-reverse';\n const out = way(reversed ? 'reverse' : undefined, [0, 1]);\n const back = way(reversed ? undefined : 'reverse', [1, 2]);\n const join = (a: ScrollRange, b: ScrollRange): ScrollRange => ({\n input: [...a.input, ...b.input.slice(1)],\n output: [...a.output, ...b.output.slice(1)],\n });\n const transform = out.channels.transform.map((channel, i) => {\n const other = back.channels.transform[i];\n return 'range' in channel && other && 'range' in other\n ? { property: channel.property, range: join(channel.range, other.range) }\n : channel;\n });\n const opacity =\n out.channels.opacity && back.channels.opacity\n ? { opacity: join(out.channels.opacity, back.channels.opacity) }\n : {};\n return { channels: { ...opacity, transform }, held: out.held, span: 2 };\n}\n\n/**\n * One transform group's entries, each driven along the scroll; null if their shapes differ. A\n * frame, or the element at rest, with fewer functions than the longest is that list with the\n * rest at their identity, which is how CSS eases a list into a longer one that starts the same.\n */\nfunction drivenGroup(\n track: Track,\n resting: unknown,\n along: (\n track: Track,\n pick: (value: unknown) => number | null,\n rest: number,\n ) => ScrollRange | null,\n): TransformChannel[] | null {\n const shapes = track.map((point) => (Array.isArray(point.value) ? point.value : []));\n if (Array.isArray(resting)) shapes.push(resting);\n const shape = shapes.reduce((longest, entries) =>\n entries.length > longest.length ? entries : longest,\n );\n const keys = shape.map((entry) => Object.keys(entry as object)[0]!);\n const channels: TransformChannel[] = [];\n for (const [index, key] of keys.entries()) {\n const identity = key.startsWith('scale') ? 1 : 0;\n const pick = (value: unknown) => {\n const entries = Array.isArray(value) ? value : null;\n if (!entries?.length) return identity;\n const entry = entries[index] as Record<string, unknown> | undefined;\n // Past the end of a shorter list. Where it differs before its end, an earlier entry says.\n if (!entry) return identity;\n return key in entry ? amount(key, entry[key]) : null;\n };\n const range = along(track, pick, restingAmount(resting, index, key, identity));\n if (!range) return null;\n channels.push({ property: key, range });\n }\n return channels;\n}\n\n/** A transform group no keyframe touches, held as the element has it. */\nfunction heldGroup(resting: unknown): TransformChannel[] | null {\n if (!Array.isArray(resting)) return [];\n const channels: TransformChannel[] = [];\n for (const entry of resting as Record<string, unknown>[]) {\n const [key, value] = Object.entries(entry)[0] ?? [];\n const number = key === undefined ? null : amount(key, value);\n if (key === undefined || number === null) return null;\n channels.push({ property: key, value: number });\n }\n return channels;\n}\n\nfunction restingAmount(resting: unknown, index: number, key: string, identity: number): number {\n const entry = Array.isArray(resting) ? (resting[index] as Record<string, unknown>) : undefined;\n return (entry && key in entry ? amount(key, entry[key]) : null) ?? identity;\n}\n\nconst numberOr = (value: unknown, otherwise: number) =>\n typeof value === 'number' ? value : otherwise;\n\nconst RADIANS: Record<string, number> = {\n deg: Math.PI / 180,\n rad: 1,\n grad: Math.PI / 200,\n turn: 2 * Math.PI,\n};\n\n/** The side of a box each move by a share is a share of. */\nconst SHARED: Readonly<Record<string, 'width' | 'height'>> = {\n translateX: 'width',\n translateY: 'height',\n};\n\nconst isShare = (value: unknown): value is string =>\n typeof value === 'string' && value.endsWith('%');\n\nconst sharesIn = (value: unknown): boolean =>\n Array.isArray(value) &&\n value.some((entry) =>\n Object.entries(entry as object).some(([key, to]) => key in SHARED && isShare(to)),\n );\n\n/** Whether an animation moves a box by a share of its own size, in a frame or at rest. */\nexport function movesByShare(\n tracks: ReadonlyMap<string, Track>,\n resting: Readonly<Record<string, unknown>>,\n): boolean {\n return GROUPS.some(\n (group) =>\n sharesIn(resting[group]) ||\n tracks.get(group)?.some((point) => sharesIn(point.value)) === true,\n );\n}\n\n/** A transform list with each move by a share as the points it is of a box of `size`. */\nfunction inPoints(value: unknown, size: { width: number; height: number }): unknown {\n if (!sharesIn(value)) return value;\n return (value as Record<string, unknown>[]).map((entry) => {\n const [key, to] = Object.entries(entry)[0]!;\n const side = SHARED[key];\n return side && isShare(to) ? { [key]: (size[side] * Number.parseFloat(to)) / 100 } : entry;\n });\n}\n\n/**\n * An animation's tracks and resting style with every move by a share of the box as points, which\n * is what native interpolates: `translateX(200%)` of a box 300 wide is 600.\n */\nexport function sharesAsPoints<T extends Track>(\n tracks: ReadonlyMap<string, T>,\n resting: Readonly<Record<string, unknown>>,\n size: { width: number; height: number },\n): { tracks: Map<string, T>; resting: Record<string, unknown> } {\n const sized = new Map(tracks);\n const rest = { ...resting };\n for (const group of GROUPS) {\n const track = tracks.get(group);\n if (track) {\n sized.set(\n group,\n track.map((point) => ({ ...point, value: inPoints(point.value, size) })) as never,\n );\n }\n if (group in rest) rest[group] = inPoints(rest[group], size);\n }\n return { tracks: sized, resting: rest };\n}\n\n/**\n * A transform entry's amount as native's transform node takes it: points, a factor, or an angle\n * in radians. Null for what it cannot take, a percentage translate.\n */\nfunction amount(key: string, value: unknown): number | null {\n if (typeof value === 'number') return value;\n if (typeof value !== 'string') return null;\n const angle = /^(-?[\\d.]+)(deg|rad|grad|turn)$/.exec(value);\n if (angle && (key.startsWith('rotate') || key.startsWith('skew'))) {\n return Number(angle[1]) * RADIANS[angle[2]!]!;\n }\n return null;\n}\n\n/**\n * One property's frames laid along the scroll: each keyframe at its share of the range, eased\n * segments sampled, and the resting value just past an end the animation does not fill.\n */\nfunction laid(\n track: Track,\n pick: (value: unknown) => number | null,\n rest: number,\n spec: AnimationSpec,\n [start, end]: readonly [number, number],\n): ScrollRange | null {\n const values = track.map((point) => pick(point.value));\n if (values.some((value) => value === null)) return null;\n // Each point keeps its own timing function, which eases the stretch it starts.\n const numeric = track.map((point, i) => ({ ...point, value: values[i]! }));\n const points = sampled(numeric, spec, start, Math.max(end - start, 1e-3));\n const fills = spec.fill;\n const backwards = fills === 'backwards' || fills === 'both';\n const forwards = fills === 'forwards' || fills === 'both';\n if (!backwards) points.unshift([points[0]![0] - 1e-3, rest]);\n if (!forwards) points.push([points.at(-1)![0] + 1e-3, rest]);\n return { input: points.map(([x]) => x), output: points.map(([, y]) => round(y)) };\n}\n\n/** A numeric track's points along the scroll, each eased segment sampled, in offset order. */\nfunction sampled(\n numeric: readonly (TrackPoint & { value: number })[],\n spec: AnimationSpec,\n start: number,\n span: number,\n): [number, number][] {\n const reversed = spec.direction === 'reverse' || spec.direction === 'alternate-reverse';\n const points: [number, number][] = [];\n for (let i = 0; i < numeric.length - 1; i++) {\n const from = numeric[i]!;\n const to = numeric[i + 1]!;\n const steps = isLinear(from.easing ?? spec.easing) ? 1 : SAMPLES;\n for (let s = i === 0 ? 0 : 1; s <= steps; s++) {\n const offset = from.offset + ((to.offset - from.offset) * s) / steps;\n const value = at(numeric, offset, spec.easing) as number;\n points.push([start + (reversed ? 1 - offset : offset) * span, value]);\n }\n }\n if (points.length === 1) points.push([start + span, points[0]![1]]);\n return points.sort((a, b) => a[0] - b[0]);\n}\n\nconst isLinear = (easing: readonly number[]) =>\n easing[0] === 0 && easing[1] === 0 && easing[2] === 1 && easing[3] === 1;\n\nconst round = (value: number) => Math.round(value * 1e6) / 1e6;\n\n/** The values a scroll-driven animation commits: its frame at the offset the view starts at. */\nexport function firstFrame(\n tracks: ReadonlyMap<string, Track>,\n spec: AnimationSpec,\n range: readonly [number, number],\n): Record<string, unknown> {\n const [start, end] = range;\n const reversed = spec.direction === 'reverse' || spec.direction === 'alternate-reverse';\n const before = 0 < start;\n if (before && spec.fill !== 'backwards' && spec.fill !== 'both') return {};\n const through = Math.min(1, Math.max(0, (0 - start) / Math.max(end - start, 1e-3)));\n const local = reversed ? 1 - through : through;\n const values: Record<string, unknown> = {};\n for (const [property, track] of tracks) values[property] = at(track, local, spec.easing);\n return values;\n}\n"]}
1
+ {"version":3,"file":"scroll-animation.js","sourceRoot":"","sources":["../src/scroll-animation.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,EAAE,EACF,MAAM,EACN,WAAW,EACX,UAAU,GAGX,MAAM,iBAAiB,CAAC;AAmBzB,kGAAkG;AAClG,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B,uFAAuF;AACvF,MAAM,OAAO,GAAG,EAAE,CAAC;AAEnB,uFAAuF;AACvF,MAAM,MAAM,GAAG,CAAC,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,CAAU,CAAC;AAE5E,mEAAmE;AACnE,MAAM,UAAU,OAAO,CAAC,I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CAAC,KAAK,CAAC,CAAC;AAE3E,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AAE/D,gGAAgG;AAChG,MAAM,UAAU,UAAU,CACxB,MAAkC,EAClC,IAAmB,EACnB,KAAgC;IAEhC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC;IAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI,IAAI,CAAC,SAAS,KAAK,mBAAmB,CAAC;IACxF,MAAM,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC;IACzB,IAAI,MAAM,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO,EAAE,CAAC;IAC3E,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACpF,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;IAC/C,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,KAAK,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,MAAM;QAAE,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACzF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/**\n * A `@keyframes` animation played by a scroll view's offset: `animation-timeline: scroll()`.\n *\n * Native interpolates linearly between the points it is given and clamps past both ends, which is\n * all a scroll-driven animation needs from it once its keyframes are laid along the offset: each\n * keyframe sits at its share of the range, a segment's timing function is sampled into points\n * along it, and an unfilled end falls back to the resting value just outside the range. What\n * native can animate this way is opacity and the transforms; anything else holds its first frame.\n */\nimport type { ScrollRange } from './native-drive.ts';\nimport {\n at,\n bezier,\n interpolate,\n parseColor,\n type AnimationSpec,\n type TrackPoint,\n} from './transition.ts';\n\ntype Track = readonly { offset: number; value: unknown }[];\n\n/** The channels a scroll-driven animation drives natively, in the order native applies them. */\nexport interface DrivenChannels {\n readonly opacity?: ScrollRange;\n /** Each colour native eases, as its red, green, blue and alpha: see `colourChannels`. */\n readonly colors?: Readonly<Record<string, ColourRanges>>;\n /** Every transform entry the view paints: driven by the scroll, or held as it is. */\n readonly transform: readonly TransformChannel[];\n}\n\nexport type ColourRanges = readonly [ScrollRange, ScrollRange, ScrollRange, ScrollRange];\n\nexport type TransformChannel =\n | { readonly property: string; readonly range: ScrollRange }\n | { readonly property: string; readonly value: number };\n\n/** What a range with no end, or a percentage of one, stands in for until the scroll view says. */\nconst UNKNOWN_EXTENT = 1e6;\n\n/** Points per eased segment: enough that the curve between them reads as the curve. */\nconst SAMPLES = 12;\n\n/** The transform groups in the order CSS applies them, as the engine composes them. */\nconst GROUPS = ['__translate', '__rotate', '__scale', 'transform'] as const;\n\n/** Where the range starts and ends on the scroll view's offset. */\nexport function rangeOf(spec: AnimationSpec, extent: number | null): [number, number] {\n const end = (value: number | string | undefined, otherwise: number): number => {\n if (value === undefined) return otherwise;\n if (typeof value === 'number') return value;\n return (parseFloat(value) / 100) * (extent ?? UNKNOWN_EXTENT);\n };\n return [end(spec.range?.start, 0), end(spec.range?.end, extent ?? UNKNOWN_EXTENT)];\n}\n\n/**\n * The channels for an animation's tracks over a range, and the properties it cannot drive\n * natively, which the caller holds at their first frame.\n */\nexport function scrollChannels(\n tracks: ReadonlyMap<string, Track>,\n spec: AnimationSpec,\n resting: Readonly<Record<string, unknown>>,\n range: readonly [number, number],\n): { channels: DrivenChannels; held: string[] } {\n const along = (track: Track, pick: (value: unknown) => number | null, rest: number) =>\n laid(track, pick, rest, spec, range);\n const held: string[] = [];\n let opacity: ScrollRange | undefined;\n const transform: TransformChannel[] = [];\n for (const [property, track] of tracks) {\n if (property === 'opacity') {\n opacity =\n along(\n track,\n (value) => (typeof value === 'number' ? value : null),\n numberOr(resting['opacity'], 1),\n ) ?? undefined;\n if (!opacity) held.push(property);\n } else if (!(GROUPS as readonly string[]).includes(property)) {\n held.push(property);\n }\n }\n for (const group of GROUPS) {\n const track = tracks.get(group);\n const channels = track ? drivenGroup(track, resting[group], along) : heldGroup(resting[group]);\n if (channels === null) held.push(group);\n else transform.push(...channels);\n }\n const anyDriven = transform.some((channel) => 'range' in channel);\n return {\n channels: { ...(opacity ? { opacity } : {}), transform: anyDriven ? transform : [] },\n held,\n };\n}\n\n/** How many stretches a colour's way is cut into: each is straight on native. */\nconst COLOUR_STEPS = 16;\n\n/**\n * The channels for each colour eased by the clock from nothing to one: its red, green, blue and\n * alpha, each a range of its own, which is how native has a colour. Sampled along the way as\n * JavaScript mixes the two, in premultiplied alpha and by the curve: native mixes a channel at\n * a time and in a straight line, which is another colour half way between two of different\n * alpha. Nothing for a track that is not two colours.\n */\nexport function colourChannels(\n tracks: ReadonlyMap<string, Track>,\n spec: AnimationSpec,\n): Record<string, ColourRanges> | null {\n const colors: Record<string, ColourRanges> = {};\n for (const [property, track] of tracks) {\n const [from, to] = track;\n if (track.length !== 2 || !parseColor(from!.value) || !parseColor(to!.value)) return null;\n const input: number[] = [];\n const parts: number[][] = [[], [], [], []];\n for (let step = 0; step <= COLOUR_STEPS; step++) {\n const along = step / COLOUR_STEPS;\n const mixed = parseColor(interpolate(from!.value, to!.value, bezier(spec.easing, along)));\n if (!mixed) return null;\n input.push(along);\n mixed.forEach((part, at) => parts[at]!.push(round(part)));\n }\n colors[property] = parts.map((output) => ({ input, output })) as unknown as ColourRanges;\n }\n return colors;\n}\n\n/**\n * The channels for an animation played by the clock, along a value native runs from nothing to\n * `span`: one iteration along 0 to 1, and for `alternate` the way back along 1 to 2, so that\n * native repeats there and back as one animation. Both ends are the frames' own: what the\n * element rests at is committed when the animation ends, and not played.\n */\nexport function clockChannels(\n tracks: ReadonlyMap<string, Track>,\n spec: AnimationSpec,\n resting: Readonly<Record<string, unknown>>,\n): { channels: DrivenChannels; held: string[]; span: number } {\n const way = (direction: AnimationSpec['direction'], range: readonly [number, number]) =>\n scrollChannels(tracks, { ...spec, fill: 'both', direction }, resting, range);\n if (spec.direction !== 'alternate' && spec.direction !== 'alternate-reverse') {\n return { ...way(spec.direction, [0, 1]), span: 1 };\n }\n const reversed = spec.direction === 'alternate-reverse';\n const out = way(reversed ? 'reverse' : undefined, [0, 1]);\n const back = way(reversed ? undefined : 'reverse', [1, 2]);\n const join = (a: ScrollRange, b: ScrollRange): ScrollRange => ({\n input: [...a.input, ...b.input.slice(1)],\n output: [...a.output, ...b.output.slice(1)],\n });\n const transform = out.channels.transform.map((channel, i) => {\n const other = back.channels.transform[i];\n return 'range' in channel && other && 'range' in other\n ? { property: channel.property, range: join(channel.range, other.range) }\n : channel;\n });\n const opacity =\n out.channels.opacity && back.channels.opacity\n ? { opacity: join(out.channels.opacity, back.channels.opacity) }\n : {};\n return { channels: { ...opacity, transform }, held: out.held, span: 2 };\n}\n\n/**\n * One transform group's entries, each driven along the scroll; null if their shapes differ. A\n * frame, or the element at rest, with fewer functions than the longest is that list with the\n * rest at their identity, which is how CSS eases a list into a longer one that starts the same.\n */\nfunction drivenGroup(\n track: Track,\n resting: unknown,\n along: (\n track: Track,\n pick: (value: unknown) => number | null,\n rest: number,\n ) => ScrollRange | null,\n): TransformChannel[] | null {\n const shapes = track.map((point) => (Array.isArray(point.value) ? point.value : []));\n if (Array.isArray(resting)) shapes.push(resting);\n const shape = shapes.reduce((longest, entries) =>\n entries.length > longest.length ? entries : longest,\n );\n const keys = shape.map((entry) => Object.keys(entry as object)[0]!);\n const channels: TransformChannel[] = [];\n for (const [index, key] of keys.entries()) {\n const identity = key.startsWith('scale') ? 1 : 0;\n const pick = (value: unknown) => {\n const entries = Array.isArray(value) ? value : null;\n if (!entries?.length) return identity;\n const entry = entries[index] as Record<string, unknown> | undefined;\n // Past the end of a shorter list. Where it differs before its end, an earlier entry says.\n if (!entry) return identity;\n return key in entry ? amount(key, entry[key]) : null;\n };\n const range = along(track, pick, restingAmount(resting, index, key, identity));\n if (!range) return null;\n channels.push({ property: key, range });\n }\n return channels;\n}\n\n/** A transform group no keyframe touches, held as the element has it. */\nfunction heldGroup(resting: unknown): TransformChannel[] | null {\n if (!Array.isArray(resting)) return [];\n const channels: TransformChannel[] = [];\n for (const entry of resting as Record<string, unknown>[]) {\n const [key, value] = Object.entries(entry)[0] ?? [];\n const number = key === undefined ? null : amount(key, value);\n if (key === undefined || number === null) return null;\n channels.push({ property: key, value: number });\n }\n return channels;\n}\n\nfunction restingAmount(resting: unknown, index: number, key: string, identity: number): number {\n const entry = Array.isArray(resting) ? (resting[index] as Record<string, unknown>) : undefined;\n return (entry && key in entry ? amount(key, entry[key]) : null) ?? identity;\n}\n\nconst numberOr = (value: unknown, otherwise: number) =>\n typeof value === 'number' ? value : otherwise;\n\nconst RADIANS: Record<string, number> = {\n deg: Math.PI / 180,\n rad: 1,\n grad: Math.PI / 200,\n turn: 2 * Math.PI,\n};\n\n/** The side of a box each move by a share is a share of. */\nconst SHARED: Readonly<Record<string, 'width' | 'height'>> = {\n translateX: 'width',\n translateY: 'height',\n};\n\nconst isShare = (value: unknown): value is string =>\n typeof value === 'string' && value.endsWith('%');\n\nconst sharesIn = (value: unknown): boolean =>\n Array.isArray(value) &&\n value.some((entry) =>\n Object.entries(entry as object).some(([key, to]) => key in SHARED && isShare(to)),\n );\n\n/** Whether an animation moves a box by a share of its own size, in a frame or at rest. */\nexport function movesByShare(\n tracks: ReadonlyMap<string, Track>,\n resting: Readonly<Record<string, unknown>>,\n): boolean {\n return GROUPS.some(\n (group) =>\n sharesIn(resting[group]) ||\n tracks.get(group)?.some((point) => sharesIn(point.value)) === true,\n );\n}\n\n/** A transform list with each move by a share as the points it is of a box of `size`. */\nfunction inPoints(value: unknown, size: { width: number; height: number }): unknown {\n if (!sharesIn(value)) return value;\n return (value as Record<string, unknown>[]).map((entry) => {\n const [key, to] = Object.entries(entry)[0]!;\n const side = SHARED[key];\n return side && isShare(to) ? { [key]: (size[side] * Number.parseFloat(to)) / 100 } : entry;\n });\n}\n\n/**\n * An animation's tracks and resting style with every move by a share of the box as points, which\n * is what native interpolates: `translateX(200%)` of a box 300 wide is 600.\n */\nexport function sharesAsPoints<T extends Track>(\n tracks: ReadonlyMap<string, T>,\n resting: Readonly<Record<string, unknown>>,\n size: { width: number; height: number },\n): { tracks: Map<string, T>; resting: Record<string, unknown> } {\n const sized = new Map(tracks);\n const rest = { ...resting };\n for (const group of GROUPS) {\n const track = tracks.get(group);\n if (track) {\n sized.set(\n group,\n track.map((point) => ({ ...point, value: inPoints(point.value, size) })) as never,\n );\n }\n if (group in rest) rest[group] = inPoints(rest[group], size);\n }\n return { tracks: sized, resting: rest };\n}\n\n/**\n * A transform entry's amount as native's transform node takes it: points, a factor, or an angle\n * in radians. Null for what it cannot take, a percentage translate.\n */\nfunction amount(key: string, value: unknown): number | null {\n if (typeof value === 'number') return value;\n if (typeof value !== 'string') return null;\n const angle = /^(-?[\\d.]+)(deg|rad|grad|turn)$/.exec(value);\n if (angle && (key.startsWith('rotate') || key.startsWith('skew'))) {\n return Number(angle[1]) * RADIANS[angle[2]!]!;\n }\n return null;\n}\n\n/**\n * One property's frames laid along the scroll: each keyframe at its share of the range, eased\n * segments sampled, and the resting value just past an end the animation does not fill.\n */\nfunction laid(\n track: Track,\n pick: (value: unknown) => number | null,\n rest: number,\n spec: AnimationSpec,\n [start, end]: readonly [number, number],\n): ScrollRange | null {\n const values = track.map((point) => pick(point.value));\n if (values.some((value) => value === null)) return null;\n // Each point keeps its own timing function, which eases the stretch it starts.\n const numeric = track.map((point, i) => ({ ...point, value: values[i]! }));\n const points = sampled(numeric, spec, start, Math.max(end - start, 1e-3));\n const fills = spec.fill;\n const backwards = fills === 'backwards' || fills === 'both';\n const forwards = fills === 'forwards' || fills === 'both';\n if (!backwards) points.unshift([points[0]![0] - 1e-3, rest]);\n if (!forwards) points.push([points.at(-1)![0] + 1e-3, rest]);\n return { input: points.map(([x]) => x), output: points.map(([, y]) => round(y)) };\n}\n\n/** A numeric track's points along the scroll, each eased segment sampled, in offset order. */\nfunction sampled(\n numeric: readonly (TrackPoint & { value: number })[],\n spec: AnimationSpec,\n start: number,\n span: number,\n): [number, number][] {\n const reversed = spec.direction === 'reverse' || spec.direction === 'alternate-reverse';\n const points: [number, number][] = [];\n for (let i = 0; i < numeric.length - 1; i++) {\n const from = numeric[i]!;\n const to = numeric[i + 1]!;\n const steps = isLinear(from.easing ?? spec.easing) ? 1 : SAMPLES;\n for (let s = i === 0 ? 0 : 1; s <= steps; s++) {\n const offset = from.offset + ((to.offset - from.offset) * s) / steps;\n const value = at(numeric, offset, spec.easing) as number;\n points.push([start + (reversed ? 1 - offset : offset) * span, value]);\n }\n }\n if (points.length === 1) points.push([start + span, points[0]![1]]);\n return points.sort((a, b) => a[0] - b[0]);\n}\n\nconst isLinear = (easing: readonly number[]) =>\n easing[0] === 0 && easing[1] === 0 && easing[2] === 1 && easing[3] === 1;\n\nconst round = (value: number) => Math.round(value * 1e6) / 1e6;\n\n/** The values a scroll-driven animation commits: its frame at the offset the view starts at. */\nexport function firstFrame(\n tracks: ReadonlyMap<string, Track>,\n spec: AnimationSpec,\n range: readonly [number, number],\n): Record<string, unknown> {\n const [start, end] = range;\n const reversed = spec.direction === 'reverse' || spec.direction === 'alternate-reverse';\n const before = 0 < start;\n if (before && spec.fill !== 'backwards' && spec.fill !== 'both') return {};\n const through = Math.min(1, Math.max(0, (0 - start) / Math.max(end - start, 1e-3)));\n const local = reversed ? 1 - through : through;\n const values: Record<string, unknown> = {};\n for (const [property, track] of tracks) values[property] = at(track, local, spec.easing);\n return values;\n}\n"]}
@@ -10,6 +10,7 @@
10
10
  * knows a value changed at all. The cost is a commit per frame, which is the same cost a
11
11
  * JavaScript-driven `Animated` value has.
12
12
  */
13
+ import type { DeferredDeclaration } from './css.ts';
13
14
  /** What the CSS compiler emits per transitioning property. Durations are in milliseconds. */
14
15
  export interface TransitionSpec {
15
16
  readonly duration: number;
@@ -17,6 +18,11 @@ export interface TransitionSpec {
17
18
  /** The four control points of the timing curve; a keyword is resolved at build time. */
18
19
  readonly easing: readonly number[];
19
20
  }
21
+ /** Transitions of one element native plays on one clock: what stops it, and which they are. */
22
+ export interface EasedNatively {
23
+ stop(): void;
24
+ readonly keys: readonly string[];
25
+ }
20
26
  export interface Transition {
21
27
  from: unknown;
22
28
  to: unknown;
@@ -26,6 +32,16 @@ export interface Transition {
26
32
  easing: readonly number[];
27
33
  /** What the node paints right now. Also the value a redirected transition starts from. */
28
34
  current: unknown;
35
+ /**
36
+ * The clock native plays it on, with the others started beside it, while it does. Nothing of
37
+ * it runs in JavaScript then, and `current` is where it started from.
38
+ */
39
+ native?: EasedNatively;
40
+ /**
41
+ * Committed where it ends, with native moving the view there by a layout animation: see
42
+ * `layEased` in the engine. `current` is where it started from.
43
+ */
44
+ laid?: true;
29
45
  done: boolean;
30
46
  /**
31
47
  * The value a change back is a reversal to, and the share of the full duration this one takes:
@@ -65,6 +81,12 @@ export declare function interpolate(from: unknown, to: unknown, t: number): unkn
65
81
  export declare function step(state: Map<string, Transition>, key: string, props: Record<string, unknown>, rule: TransitionSpec | undefined, now: number): boolean;
66
82
  /** A property seen for the first time: recorded so the next change has something to aim from. */
67
83
  export declare function settled(value: unknown, rule: TransitionSpec): Transition;
84
+ /**
85
+ * Whether a transition is no longer going where a commit's props say: by the value a property
86
+ * has when nothing sets one, and by what two values are and not which objects, as `step` reads
87
+ * them. What native plays is taken back only for a target that is another.
88
+ */
89
+ export declare function aimsElsewhere(transition: Transition, key: string, props: Record<string, unknown>): boolean;
68
90
  /**
69
91
  * Aim an existing transition at a new value, starting from wherever it had got to.
70
92
  *
@@ -109,6 +131,11 @@ export interface Keyframe {
109
131
  readonly declarations: Record<string, unknown>;
110
132
  /** The `animation-timing-function` written in this keyframe, easing it to the next. */
111
133
  readonly easing?: readonly number[];
134
+ /**
135
+ * The declarations that wait for the element playing the frame, a `var()` it sets: settled by
136
+ * the engine as it plays.
137
+ */
138
+ readonly deferred?: readonly DeferredDeclaration[];
112
139
  }
113
140
  export interface RunningAnimation {
114
141
  spec: AnimationSpec;
@@ -132,6 +159,13 @@ export interface RunningAnimation {
132
159
  native?: {
133
160
  stop(): void;
134
161
  };
162
+ /** The properties left out of what native plays, as a rule declared them `!important`. */
163
+ pinned?: readonly string[];
164
+ /**
165
+ * Set while native moves the view to its last frame by a layout animation, with no frame of it
166
+ * in JavaScript. `values` is then that last frame, which is what the view is committed with.
167
+ */
168
+ laid?: true;
135
169
  }
136
170
  /**
137
171
  * Build one track per property the frames touch.
@@ -479,18 +479,25 @@ function mixColours(a, b, t) {
479
479
  const mix = (i) => Math.round((a[i] * a[3] + (b[i] * b[3] - a[i] * a[3]) * t) / alpha);
480
480
  return `rgba(${mix(0)}, ${mix(1)}, ${mix(2)}, ${Math.round(alpha * 1000) / 1000})`;
481
481
  }
482
- /** `50%` -> `75%`. Both sides have to be percentages; a percentage and a length are not a scale. */
482
+ /**
483
+ * `50%` -> `75%`. Both sides have to be percentages; a percentage and a length are not a scale.
484
+ * Except 0, which is 0% too: a padding nothing sets eases from it to `50%`, as in a browser.
485
+ */
483
486
  const PERCENTAGE = /^(-?[\d.]+)%$/;
484
487
  function interpolatePercentage(from, to, t) {
485
- if (typeof from !== 'string' || typeof to !== 'string')
488
+ const a = percentageOf(from);
489
+ const b = percentageOf(to);
490
+ if (a === null || b === null)
486
491
  return null;
487
- const a = PERCENTAGE.exec(from);
488
- const b = PERCENTAGE.exec(to);
489
- if (!a || !b)
490
- return null;
491
- const value = Number(a[1]) + (Number(b[1]) - Number(a[1])) * t;
492
+ const value = a + (b - a) * t;
492
493
  return `${Math.round(value * 1000) / 1000}%`;
493
494
  }
495
+ function percentageOf(value) {
496
+ if (value === 0)
497
+ return 0;
498
+ const percent = typeof value === 'string' ? PERCENTAGE.exec(value) : null;
499
+ return percent ? Number(percent[1]) : null;
500
+ }
494
501
  /**
495
502
  * Bring one property up to date, and say whether that started a transition.
496
503
  *
@@ -572,6 +579,14 @@ export function settled(value, rule) {
572
579
  shortening: 1,
573
580
  };
574
581
  }
582
+ /**
583
+ * Whether a transition is no longer going where a commit's props say: by the value a property
584
+ * has when nothing sets one, and by what two values are and not which objects, as `step` reads
585
+ * them. What native plays is taken back only for a target that is another.
586
+ */
587
+ export function aimsElsewhere(transition, key, props) {
588
+ return !sameValue(transition.to, props[key] ?? INITIAL[key]);
589
+ }
575
590
  /** Whether two values are the same, a transform list by what is in it rather than by identity. */
576
591
  function sameValue(a, b) {
577
592
  if (Object.is(a, b))
@@ -667,14 +682,22 @@ const isCurrentColour = (value) => value?.__colour?.color === 'currentcolor';
667
682
  * fades out from 1 and back in to it, and a background colour nothing set eases from
668
683
  * `transparent`, as in a browser.
669
684
  *
670
- * Only the properties that appear in an animation and have a meaningful resting value. A length
671
- * defaulting to zero is the same as absent for anything here.
685
+ * A padding, a margin and a corner radius start at 0, so `.open { padding: 20px }` eases in from
686
+ * no padding. Each edge and corner is here under both the physical name and the logical one, as
687
+ * the compiler writes either. A border width is not: one nothing sets is 0 on a native view and
688
+ * `medium`, 3px, in CSS, which a browser eases from. Nor is anything that starts at `auto` or
689
+ * `normal`, which has no number to ease from.
672
690
  */
673
691
  const INITIAL = {
674
692
  opacity: 1,
675
693
  scale: 1,
676
694
  rotate: '0deg',
677
695
  backgroundColor: 'transparent',
696
+ ...Object.fromEntries(['padding', 'margin'].flatMap((box) => ['Top', 'Right', 'Bottom', 'Left', 'Start', 'End'].map((edge) => [`${box}${edge}`, 0]))),
697
+ ...Object.fromEntries([
698
+ ...['Top', 'Bottom'].flatMap((side) => [`${side}Left`, `${side}Right`]),
699
+ ...['Start', 'End'].flatMap((side) => [`${side}Start`, `${side}End`]),
700
+ ].map((corner) => [`border${corner}Radius`, 0])),
678
701
  };
679
702
  /**
680
703
  * The properties to step for an element: the ones it has, and the ones its transition *names*,