@vnejs/plugins.canvas.child.fill 0.2.1 → 0.2.3

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,9 +1,9 @@
1
1
  import { ModuleCore } from "@vnejs/module.core";
2
2
  import type { FillPluginConstants, FillPluginEvents, FillPluginParams, FillPluginSettings } from "../types.js";
3
- import type { FillChangePayload } from "../utils/fill.js";
3
+ import type { FillChangePayload } from "@vnejs/contracts.canvas.child.fill";
4
4
  export declare class LayerFillChange extends ModuleCore<FillPluginEvents, FillPluginConstants, FillPluginSettings, FillPluginParams> {
5
5
  name: string;
6
6
  subscribe: () => void;
7
- onChange: ({ id, layer, color, duration }?: FillChangePayload) => Promise<unknown[] | undefined>;
8
- emitChildChange: (layer: string, childId: string, duration: number, props: Record<string, unknown>) => Promise<unknown[]> | undefined;
7
+ onChange: ({ id, layer, color, duration }?: FillChangePayload) => Promise<import("@vnejs/shared").EmitResults<"vne:interact:push_pop"> | undefined>;
8
+ emitChildChange: (layer: string, childId: string, duration: number, props: Record<string, unknown>) => Promise<import("@vnejs/shared").EmitResults<"vne:layer:child_change">> | undefined;
9
9
  }
@@ -1,10 +1,9 @@
1
1
  import { ModuleCore } from "@vnejs/module.core";
2
- import type { FillTransitionProps } from "@vnejs/contracts.canvas.child.fill";
2
+ import type { FillHidePayload, FillTransitionProps } from "@vnejs/contracts.canvas.child.fill";
3
3
  import type { FillPluginConstants, FillPluginEvents, FillPluginParams, FillPluginSettings } from "../types.js";
4
- import type { FillHidePayload } from "../utils/fill.js";
5
4
  export declare class LayerFillHide extends ModuleCore<FillPluginEvents, FillPluginConstants, FillPluginSettings, FillPluginParams> {
6
5
  name: string;
7
6
  subscribe: () => void;
8
- onHide: ({ id, layer, duration }?: FillHidePayload) => Promise<unknown[] | undefined>;
7
+ onHide: ({ id, layer, duration }?: FillHidePayload) => Promise<import("@vnejs/shared").EmitResults<"vne:layer:child_rm"> | undefined>;
9
8
  getTransitionProps: (duration: number) => FillTransitionProps;
10
9
  }
@@ -1,10 +1,9 @@
1
1
  import { ModuleCore } from "@vnejs/module.core";
2
- import type { FillTransitionProps } from "@vnejs/contracts.canvas.child.fill";
2
+ import type { FillShowPayload, FillTransitionProps } from "@vnejs/contracts.canvas.child.fill";
3
3
  import type { FillPluginConstants, FillPluginEvents, FillPluginParams, FillPluginSettings } from "../types.js";
4
- import type { FillShowPayload } from "../utils/fill.js";
5
4
  export declare class LayerFillShow extends ModuleCore<FillPluginEvents, FillPluginConstants, FillPluginSettings, FillPluginParams> {
6
5
  name: string;
7
6
  subscribe: () => void;
8
- onShow: ({ id, layer, color, duration }?: FillShowPayload) => Promise<unknown[] | undefined>;
7
+ onShow: ({ id, layer, color, duration }?: FillShowPayload) => Promise<import("@vnejs/shared").EmitResults<"vne:layer:child_add"> | undefined>;
9
8
  getTransitionProps: (duration: number) => FillTransitionProps;
10
9
  }
@@ -1,6 +1,6 @@
1
1
  import { ModuleCore, type ModuleGlobalStateRegistry } from "@vnejs/module.core";
2
2
  import type { FillPluginConstants, FillPluginEvents, FillPluginParams, FillPluginSettings } from "../types.js";
3
- import type { FillRecord, FillState, FillStateIdPayload } from "../utils/fill.js";
3
+ import type { FillRecord, FillState, FillStateIdPayload } from "@vnejs/contracts.canvas.child.fill";
4
4
  export declare class LayerFillState extends ModuleCore<FillPluginEvents, FillPluginConstants, FillPluginSettings, FillPluginParams, FillState> {
5
5
  name: string;
6
6
  subscribe: () => void;
@@ -14,9 +14,9 @@ export declare class LayerFillState extends ModuleCore<FillPluginEvents, FillPlu
14
14
  cloneFillAndChange: (fill: FillRecord) => Promise<unknown>;
15
15
  cloneFillAndHide: (fill: FillRecord) => Promise<unknown>;
16
16
  cloneFillAndShow: (fill: FillRecord) => Promise<unknown>;
17
- emitFillChange: (fill: FillRecord) => Promise<unknown[]> | undefined;
18
- emitFillHide: (fill: FillRecord) => Promise<unknown[]> | undefined;
19
- emitFillShow: (fill: FillRecord) => Promise<unknown[]> | undefined;
17
+ emitFillChange: (fill: FillRecord) => Promise<import("@vnejs/shared").EmitResults<"vne:layer_fill:change">> | undefined;
18
+ emitFillHide: (fill: FillRecord) => Promise<import("@vnejs/shared").EmitResults<"vne:layer_fill:hide">> | undefined;
19
+ emitFillShow: (fill: FillRecord) => Promise<import("@vnejs/shared").EmitResults<"vne:layer_fill:show">> | undefined;
20
20
  emitEventWithFill: (fill: FillRecord, cb: (fill: FillRecord) => unknown) => unknown;
21
21
  getFillsByLayerFromState: (acc: Record<string, FillRecord[]>, fill: FillRecord) => Record<string, FillRecord[]>;
22
22
  getDefaultState: () => FillState;
@@ -20,7 +20,7 @@ export class LayerFillState extends ModuleCore {
20
20
  };
21
21
  onFillStateGet = ({ id } = {}) => this.state.fills.find((item) => item.id === id);
22
22
  onStateSet = async (payload) => {
23
- const clonedState = await this.emitClone(this.getStateSlice(payload));
23
+ const clonedState = structuredClone(this.getStateSlice(payload));
24
24
  const oldFillsByLayer = this.state.fills.reduce(this.getFillsByLayerFromState, {});
25
25
  const newFillsByLayer = clonedState.fills.reduce(this.getFillsByLayerFromState, {});
26
26
  const [promises, uniqLayers, oldLayers, newLayers] = [
@@ -51,9 +51,9 @@ export class LayerFillState extends ModuleCore {
51
51
  await Promise.all(this.state.fills.map(this.cloneFillAndHide));
52
52
  this.shared.viewForceAnimationSources.rm(`${this.name}.clear`);
53
53
  };
54
- cloneFillAndChange = async (fill) => this.emitEventWithFill(await this.emitClone(fill), this.emitFillChange);
55
- cloneFillAndHide = async (fill) => this.emitEventWithFill(await this.emitClone(fill), this.emitFillHide);
56
- cloneFillAndShow = async (fill) => this.emitEventWithFill(await this.emitClone(fill), this.emitFillShow);
54
+ cloneFillAndChange = async (fill) => this.emitEventWithFill(structuredClone(fill), this.emitFillChange);
55
+ cloneFillAndHide = async (fill) => this.emitEventWithFill(structuredClone(fill), this.emitFillHide);
56
+ cloneFillAndShow = async (fill) => this.emitEventWithFill(structuredClone(fill), this.emitFillShow);
57
57
  emitFillChange = (fill) => this.emit(this.EVENTS.LAYER_FILL.CHANGE, { ...fill, duration: 0 });
58
58
  emitFillHide = (fill) => this.emit(this.EVENTS.LAYER_FILL.HIDE, fill);
59
59
  emitFillShow = (fill) => this.emit(this.EVENTS.LAYER_FILL.SHOW, fill);
@@ -1,33 +1,4 @@
1
- export type FillRecord = {
2
- id: string;
3
- layer?: string;
4
- color?: string;
5
- };
6
- export type FillState = {
7
- fills: FillRecord[];
8
- };
9
- export type FillShowPayload = {
10
- id?: string;
11
- layer?: string;
12
- color?: string;
13
- duration?: number;
14
- };
15
- export type FillHidePayload = {
16
- id?: string;
17
- layer?: string;
18
- duration?: number;
19
- };
20
- export type FillChangePayload = {
21
- id?: string;
22
- layer?: string;
23
- color?: string;
24
- duration?: number;
25
- };
26
- export type FillStateIdPayload = {
27
- id?: string;
28
- layer?: string;
29
- color?: string;
30
- };
1
+ import type { FillRecord } from "@vnejs/contracts.canvas.child.fill";
31
2
  export type LayerFillChild = {
32
3
  type: string;
33
4
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.canvas.child.fill",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -2,7 +2,7 @@ import { createPromiseResolve } from "@vnejs/helpers";
2
2
  import { ModuleCore } from "@vnejs/module.core";
3
3
 
4
4
  import type { FillPluginConstants, FillPluginEvents, FillPluginParams, FillPluginSettings } from "../types.js";
5
- import type { FillChangePayload, FillRecord } from "../utils/fill.js";
5
+ import type { FillChangePayload, FillRecord } from "@vnejs/contracts.canvas.child.fill";
6
6
 
7
7
  export class LayerFillChange extends ModuleCore<FillPluginEvents, FillPluginConstants, FillPluginSettings, FillPluginParams> {
8
8
  name = "layer.fill.change";
@@ -1,9 +1,8 @@
1
1
  import { createPromiseResolve } from "@vnejs/helpers";
2
2
  import { ModuleCore } from "@vnejs/module.core";
3
- import type { FillTransitionProps } from "@vnejs/contracts.canvas.child.fill";
3
+ import type { FillHidePayload, FillTransitionProps } from "@vnejs/contracts.canvas.child.fill";
4
4
 
5
5
  import type { FillPluginConstants, FillPluginEvents, FillPluginParams, FillPluginSettings } from "../types.js";
6
- import type { FillHidePayload } from "../utils/fill.js";
7
6
 
8
7
  export class LayerFillHide extends ModuleCore<FillPluginEvents, FillPluginConstants, FillPluginSettings, FillPluginParams> {
9
8
  name = "layer.fill.hide";
@@ -1,9 +1,8 @@
1
1
  import { createPromiseResolve } from "@vnejs/helpers";
2
2
  import { ModuleCore } from "@vnejs/module.core";
3
- import type { FillTransitionProps } from "@vnejs/contracts.canvas.child.fill";
3
+ import type { FillRecord, FillShowPayload, FillTransitionProps } from "@vnejs/contracts.canvas.child.fill";
4
4
 
5
5
  import type { FillPluginConstants, FillPluginEvents, FillPluginParams, FillPluginSettings } from "../types.js";
6
- import type { FillRecord, FillShowPayload } from "../utils/fill.js";
7
6
  import { assertIdNotExists, buildChild } from "../utils/fill.js";
8
7
 
9
8
  export class LayerFillShow extends ModuleCore<FillPluginEvents, FillPluginConstants, FillPluginSettings, FillPluginParams> {
@@ -1,7 +1,7 @@
1
1
  import { ModuleCore, type ModuleGlobalStateRegistry } from "@vnejs/module.core";
2
2
 
3
3
  import type { FillPluginConstants, FillPluginEvents, FillPluginParams, FillPluginSettings } from "../types.js";
4
- import type { FillRecord, FillState, FillStateIdPayload } from "../utils/fill.js";
4
+ import type { FillRecord, FillState, FillStateIdPayload } from "@vnejs/contracts.canvas.child.fill";
5
5
 
6
6
  export class LayerFillState extends ModuleCore<FillPluginEvents, FillPluginConstants, FillPluginSettings, FillPluginParams, FillState> {
7
7
  name = "layer.fill.state";
@@ -31,7 +31,7 @@ export class LayerFillState extends ModuleCore<FillPluginEvents, FillPluginConst
31
31
  onFillStateGet = ({ id }: FillStateIdPayload = {}) => this.state.fills.find((item) => item.id === id);
32
32
 
33
33
  onStateSet = async (payload: ModuleGlobalStateRegistry) => {
34
- const clonedState = await this.emitClone<FillState>(this.getStateSlice(payload));
34
+ const clonedState = structuredClone(this.getStateSlice(payload));
35
35
 
36
36
  const oldFillsByLayer = this.state.fills.reduce(this.getFillsByLayerFromState, {} as Record<string, FillRecord[]>);
37
37
  const newFillsByLayer = clonedState.fills.reduce(this.getFillsByLayerFromState, {} as Record<string, FillRecord[]>);
@@ -71,11 +71,11 @@ export class LayerFillState extends ModuleCore<FillPluginEvents, FillPluginConst
71
71
  this.shared.viewForceAnimationSources.rm(`${this.name}.clear`);
72
72
  };
73
73
 
74
- cloneFillAndChange = async (fill: FillRecord) => this.emitEventWithFill(await this.emitClone<FillRecord>(fill), this.emitFillChange);
74
+ cloneFillAndChange = async (fill: FillRecord) => this.emitEventWithFill(structuredClone(fill), this.emitFillChange);
75
75
 
76
- cloneFillAndHide = async (fill: FillRecord) => this.emitEventWithFill(await this.emitClone<FillRecord>(fill), this.emitFillHide);
76
+ cloneFillAndHide = async (fill: FillRecord) => this.emitEventWithFill(structuredClone(fill), this.emitFillHide);
77
77
 
78
- cloneFillAndShow = async (fill: FillRecord) => this.emitEventWithFill(await this.emitClone<FillRecord>(fill), this.emitFillShow);
78
+ cloneFillAndShow = async (fill: FillRecord) => this.emitEventWithFill(structuredClone(fill), this.emitFillShow);
79
79
 
80
80
  emitFillChange = (fill: FillRecord) => this.emit(this.EVENTS.LAYER_FILL.CHANGE, { ...fill, duration: 0 });
81
81
  emitFillHide = (fill: FillRecord) => this.emit(this.EVENTS.LAYER_FILL.HIDE, fill);
package/src/utils/fill.ts CHANGED
@@ -1,38 +1,4 @@
1
- export type FillRecord = {
2
- id: string;
3
- layer?: string;
4
- color?: string;
5
- };
6
-
7
- export type FillState = {
8
- fills: FillRecord[];
9
- };
10
-
11
- export type FillShowPayload = {
12
- id?: string;
13
- layer?: string;
14
- color?: string;
15
- duration?: number;
16
- };
17
-
18
- export type FillHidePayload = {
19
- id?: string;
20
- layer?: string;
21
- duration?: number;
22
- };
23
-
24
- export type FillChangePayload = {
25
- id?: string;
26
- layer?: string;
27
- color?: string;
28
- duration?: number;
29
- };
30
-
31
- export type FillStateIdPayload = {
32
- id?: string;
33
- layer?: string;
34
- color?: string;
35
- };
1
+ import type { FillRecord } from "@vnejs/contracts.canvas.child.fill";
36
2
 
37
3
  export type LayerFillChild = {
38
4
  type: string;