@flighthq/displayobject 0.1.0 → 0.2.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.
@@ -1,8 +1,12 @@
1
- import type { ClipRegion, DisplayObject, DisplayObjectDataFactory, DisplayObjectRuntime, DisplayObjectRuntimeFactory, Kind, MethodsOf, NodeAny, PartialNode } from '@flighthq/types';
1
+ import type { Adjustment, ClipRegion, ColorTransform, DisplayObject, DisplayObjectDataFactory, DisplayObjectRuntime, DisplayObjectRuntimeFactory, Kind, MethodsOf, NodeAny, PartialNode } from '@flighthq/types';
2
+ export declare function addDisplayObjectColorAdjustment(source: DisplayObject, adjustment: Adjustment): void;
2
3
  export declare function createDisplayObject(obj?: Readonly<PartialNode<DisplayObject>>): DisplayObject;
3
4
  export declare function createDisplayObjectGeneric<R extends DisplayObjectRuntime>(kind: Kind, obj?: Readonly<PartialNode<DisplayObject>>, createData?: DisplayObjectDataFactory, createDisplayObjectRuntimeFactory?: DisplayObjectRuntimeFactory<R>): DisplayObject;
4
5
  export declare function createDisplayObjectRuntime(methods?: Readonly<Partial<MethodsOf<DisplayObjectRuntime>>>): DisplayObjectRuntime;
6
+ export declare function getDisplayObjectColorAdjustments(source: Readonly<DisplayObject>): readonly Adjustment[] | null;
5
7
  export declare function getDisplayObjectRuntime(source: Readonly<DisplayObject>): Readonly<DisplayObjectRuntime>;
6
8
  export declare function isDisplayObject(node: NodeAny): node is DisplayObject;
7
9
  export declare function setDisplayObjectClip(source: DisplayObject, value: ClipRegion | null): void;
10
+ export declare function setDisplayObjectColorAdjustments(source: DisplayObject, value: readonly Adjustment[] | null): void;
11
+ export declare function setDisplayObjectColorTransform(source: DisplayObject, colorTransform: Readonly<ColorTransform> | null): void;
8
12
  //# sourceMappingURL=displayObject.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"displayObject.d.ts","sourceRoot":"","sources":["../src/displayObject.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,UA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mentsColorTransform, } from '@flighthq/adjustments';
2
+ import { createColorTransform } from '@flighthq/materials';
1
3
  import { createNode, createNodeRuntime, getNodeRuntime, initAppearanceTrait, initBoundsRectangleRuntimeTrait, initBoundsRectangleTrait, initClipTrait, initMaterialTrait, initTransform2DRuntimeTrait, initTransform2DTrait, invalidateNodeAppearance, } from '@flighthq/node';
2
4
  import { DisplayObjectKind, DisplayObjectTraitsKey } from '@flighthq/types';
5
+ // Appends one pointwise color adjustment to this object's stack (creating the stack if absent), re-fuses
6
+ // the resolved cache, and invalidates appearance so the render walk hands the fold the new value.
7
+ // Allocates a new array — the stack is a plain `readonly Adjustment[]`, never mutated in place.
8
+ export function addDisplayObjectColorAdjustment(source, adjustment) {
9
+ const runtime = getNodeRuntime(source);
10
+ const current = runtime.colorAdjustments;
11
+ runtime.colorAdjustments = current === null ? [adjustment] : [...current, adjustment];
12
+ resolveDisplayObjectColorAdjustments(runtime);
13
+ invalidateNodeAppearance(source);
14
+ }
3
15
  export function createDisplayObject(obj) {
4
16
  return createDisplayObjectGeneric(DisplayObjectKind, obj);
5
17
  }
@@ -19,6 +31,11 @@ export function createDisplayObjectRuntime(methods) {
19
31
  initBoundsRectangleRuntimeTrait(out, methods);
20
32
  return out;
21
33
  }
34
+ // Returns this object's pointwise color-adjustment stack (the source of truth on the node runtime), or
35
+ // null when it carries none.
36
+ export function getDisplayObjectColorAdjustments(source) {
37
+ return getNodeRuntime(source).colorAdjustments;
38
+ }
22
39
  export function getDisplayObjectRuntime(source) {
23
40
  return getNodeRuntime(source);
24
41
  }
@@ -29,4 +46,42 @@ export function setDisplayObjectClip(source, value) {
29
46
  source.clip = value;
30
47
  invalidateNodeAppearance(source);
31
48
  }
49
+ // Sets (or clears with null) this object's pointwise color-adjustment stack — the generic replacement for
50
+ // the removed color-transform trait. A color transform is one member: `createColorTransformAdjustment`.
51
+ // Re-fuses the resolved cache once here (not per frame) and invalidates appearance so the render walk
52
+ // hands the fold the affine ColorTransform the stack resolves to. Null is the untinted default.
53
+ export function setDisplayObjectColorAdjustments(source, value) {
54
+ const runtime = getNodeRuntime(source);
55
+ runtime.colorAdjustments = value;
56
+ resolveDisplayObjectColorAdjustments(runtime);
57
+ invalidateNodeAppearance(source);
58
+ }
59
+ // Convenience for the common single-tint path (the color-transform an agent looks for): sets this object's
60
+ // adjustment stack to one `ColorTransformAdjustment`, or clears it with null. Thin wrapper over
61
+ // `setDisplayObjectColorAdjustments` — a color transform is just one adjustment in the generic stack.
62
+ export function setDisplayObjectColorTransform(source, colorTransform) {
63
+ setDisplayObjectColorAdjustments(source, colorTransform === null ? null : [createColorTransformAdjustment(colorTransform)]);
64
+ }
65
+ // Fuses the runtime's color-adjustment stack once into its cached affine `resolvedColorTransform`, setting
66
+ // `colorAdjustmentsChannelMixing` when the fused stack has off-diagonal channel-mixing terms the 8-float
67
+ // fold cannot represent yet (the render walk reports that through the shakeable guard). Called by the
68
+ // accessors on change — the render walk only reads the cache, so no fuse math weighs on the base render
69
+ // path. The cached ColorTransform is reused in place across re-fuses to avoid per-set allocation churn.
70
+ function resolveDisplayObjectColorAdjustments(runtime) {
71
+ const adjustments = runtime.colorAdjustments;
72
+ if (adjustments === null || adjustments.length === 0) {
73
+ runtime.resolvedColorTransform = null;
74
+ runtime.colorAdjustmentsChannelMixing = false;
75
+ return;
76
+ }
77
+ const out = runtime.resolvedColorTransform ?? createColorTransform();
78
+ const status = resolveColorAdjustmentsColorTransform(adjustments, out);
79
+ if (status === COLOR_ADJUSTMENT_NONE) {
80
+ runtime.resolvedColorTransform = null;
81
+ runtime.colorAdjustmentsChannelMixing = false;
82
+ return;
83
+ }
84
+ runtime.resolvedColorTransform = out;
85
+ runtime.colorAdjustmentsChannelMixing = status === COLOR_ADJUSTMENT_CHANNEL_MIXING;
86
+ }
32
87
  //# sourceMappingURL=displayObject.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"displayObject.js","sourceRoot":"","sources":["../src/displayObject.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,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AO;IACT,CAAC;IACD,OAAO,CAAC,sBAAsB,GAAG,GAAG,CAAC;IACrC,OAAO,CAAC,6BAA6B,GAAG,MAAM,KAAK,+BAA+B,CAAC;AACrF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,11 @@
1
1
  {
2
2
  "name": "@flighthq/displayobject",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/flighthq/flight.git",
7
+ "directory": "packages/displayobject"
8
+ },
4
9
  "type": "module",
5
10
  "main": "dist/index.js",
6
11
  "types": "dist/index.d.ts",
@@ -27,10 +32,12 @@
27
32
  "clean:dist": "tsx ../../scripts/clean-package-dist.ts"
28
33
  },
29
34
  "dependencies": {
30
- "@flighthq/geometry": "0.1.0",
31
- "@flighthq/node": "0.1.0",
32
- "@flighthq/signals": "0.1.0",
33
- "@flighthq/types": "0.1.0"
35
+ "@flighthq/adjustments": "0.2.0",
36
+ "@flighthq/geometry": "0.2.0",
37
+ "@flighthq/materials": "0.2.0",
38
+ "@flighthq/node": "0.2.0",
39
+ "@flighthq/signals": "0.2.0",
40
+ "@flighthq/types": "0.2.0"
34
41
  },
35
42
  "devDependencies": {
36
43
  "@flighthq/entity": "*",
@@ -1,5 +1,6 @@
1
1
  import { getEntityRuntime } from '@flighthq/entity';
2
2
  import { createRectangle } from '@flighthq/geometry';
3
+ import { getNodeLocalBoundsRevision, getNodeLocalContentRevision, getNodeLocalTransformRevision } from '@flighthq/node';
3
4
  import type { Bitmap, BitmapRuntime, ImageResource, Node } from '@flighthq/types';
4
5
  import { BitmapKind } from '@flighthq/types';
5
6
 
@@ -1,4 +1,5 @@
1
1
  import { getEntityRuntime } from '@flighthq/entity';
2
+ import { createColorTransform } from '@flighthq/materials';
2
3
  import type {
3
4
  BoundsNode,
4
5
  DisplayObject,
@@ -10,18 +11,47 @@ import type {
10
11
  import { BlendMode, DisplayObjectKind, DisplayObjectTraitsKey } from '@flighthq/types';
11
12
 
12
13
  import {
14
+ addDisplayObjectColorAdjustment,
13
15
  createDisplayObject,
14
16
  createDisplayObjectGeneric,
15
17
  createDisplayObjectRuntime,
18
+ getDisplayObjectColorAdjustments,
16
19
  getDisplayObjectRuntime,
17
20
  isDisplayObject,
18
21
  setDisplayObjectClip,
22
+ setDisplayObjectColorAdjustments,
23
+ setDisplayObjectColorTransform,
19
24
  } from './displayObject';
20
25
 
21
26
  function getRuntime_(obj: DisplayObject): DisplayObjectRuntime {
22
27
  return getEntityRuntime(obj) as DisplayObjectRuntime;
23
28
  }
24
29
 
30
+ describe('addDisplayObjectColorAdjustment', () => {
31
+ let obj: DisplayObject;
32
+ beforeEach(() => {
33
+ obj = createDisplayObject();
34
+ });
35
+
36
+ it('appends to a fresh (null) stack and invalidates appearance', () => {
37
+ const idBefore = getRuntime_(obj).appearanceId;
38
+ const adjustment = { kind: 'ColorTransformAdjustment' } as never;
39
+ addDisplayObjectColorAdjustment(obj, adjustment);
40
+ expect(getDisplayObjectColorAdjustments(obj)).toEqual([adjustment]);
41
+ expect(getRuntime_(obj).appearanceId).not.toBe(idBefore);
42
+ });
43
+
44
+ it('appends to an existing stack without mutating the previous array', () => {
45
+ const a = { kind: 'A' } as never;
46
+ const b = { kind: 'B' } as never;
47
+ addDisplayObjectColorAdjustment(obj, a);
48
+ const first = getDisplayObjectColorAdjustments(obj);
49
+ addDisplayObjectColorAdjustment(obj, b);
50
+ expect(getDisplayObjectColorAdjustments(obj)).toEqual([a, b]);
51
+ expect(first).toEqual([a]); // the earlier array was not mutated
52
+ });
53
+ });
54
+
25
55
  describe('createDisplayObject', () => {
26
56
  let displayObject: DisplayObject;
27
57
 
@@ -113,6 +143,12 @@ describe('createDisplayObjectRuntime', () => {
113
143
  });
114
144
  });
115
145
 
146
+ describe('getDisplayObjectColorAdjustments', () => {
147
+ it('defaults to null on a fresh node', () => {
148
+ expect(getDisplayObjectColorAdjustments(createDisplayObject())).toBeNull();
149
+ });
150
+ });
151
+
116
152
  describe('getDisplayObjectRuntime', () => {
117
153
  it('returns the runtime for a DisplayObject', () => {
118
154
  const obj = createDisplayObject();
@@ -161,6 +197,44 @@ describe('setDisplayObjectClip', () => {
161
197
  });
162
198
  });
163
199
 
200
+ describe('setDisplayObjectColorAdjustments', () => {
201
+ let obj: DisplayObject;
202
+ beforeEach(() => {
203
+ obj = createDisplayObject();
204
+ });
205
+
206
+ it('sets the stack and invalidates appearance', () => {
207
+ const idBefore = getRuntime_(obj).appearanceId;
208
+ const stack = [{ kind: 'ColorTransformAdjustment' }] as never;
209
+ setDisplayObjectColorAdjustments(obj, stack);
210
+ expect(getDisplayObjectColorAdjustments(obj)).toBe(stack);
211
+ expect(getRuntime_(obj).appearanceId).not.toBe(idBefore);
212
+ });
213
+
214
+ it('accepts null', () => {
215
+ setDisplayObjectColorAdjustments(obj, [{ kind: 'ColorTransformAdjustment' }] as never);
216
+ setDisplayObjectColorAdjustments(obj, null);
217
+ expect(getDisplayObjectColorAdjustments(obj)).toBeNull();
218
+ });
219
+ });
220
+
221
+ describe('setDisplayObjectColorTransform', () => {
222
+ it('wraps a color transform as one ColorTransformAdjustment on the stack', () => {
223
+ const obj = createDisplayObject();
224
+ setDisplayObjectColorTransform(obj, createColorTransform({ redMultiplier: 0.5 }));
225
+ const stack = getDisplayObjectColorAdjustments(obj);
226
+ expect(stack?.length).toBe(1);
227
+ expect(stack?.[0].kind).toBe('ColorTransformAdjustment');
228
+ });
229
+
230
+ it('clears with null', () => {
231
+ const obj = createDisplayObject();
232
+ setDisplayObjectColorTransform(obj, createColorTransform({ redMultiplier: 0.5 }));
233
+ setDisplayObjectColorTransform(obj, null);
234
+ expect(getDisplayObjectColorAdjustments(obj)).toBeNull();
235
+ });
236
+ });
237
+
164
238
  interface DisplayObjectTest extends DisplayObject {}
165
239
 
166
240
  interface DisplayObjectTestData extends DisplayObjectData {
package/src/video.test.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { getNodeLocalBoundsRevision, getNodeLocalContentRevision, getNodeLocalTransformRevision } from '@flighthq/node';
1
2
  import type { Video } from '@flighthq/types';
2
3
  import { VideoKind } from '@flighthq/types';
3
4