@vnejs/plugins.canvas.child.bg 0.2.6 → 0.2.7

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.
@@ -5,6 +5,6 @@ export declare class LayerBgChange extends ModuleCore<BgPluginEvents, BgPluginCo
5
5
  name: string;
6
6
  subscribe: () => void;
7
7
  onBgChange: ({ id, name, layer, duration, args }?: BgChangePayload) => Promise<import("@vnejs/shared").EmitResults<"vne:interact:push_pop"> | undefined>;
8
- getBgId: (id: string | undefined, layer: string) => Promise<string>;
9
8
  emitChildChange: (layer: string, childId: string, duration: number, props: Record<string, unknown>) => Promise<import("@vnejs/shared").EmitResults<"vne:layer:child_change">> | undefined;
9
+ getBgId: (id: string | undefined, layer: string) => Promise<string>;
10
10
  }
@@ -26,11 +26,11 @@ export class LayerBgChange extends ModuleCore {
26
26
  handler: () => Promise.race([this.emitChildChange(layer, realId, durationMs, { ...changeArgs, transition: durationMs }), skipPromise]),
27
27
  });
28
28
  };
29
+ emitChildChange = (layer, childId, duration, props) => this.emit(this.EVENTS.LAYER.CHILD_CHANGE, { layer, childId, duration, props });
29
30
  getBgId = async (id, layer) => {
30
31
  if (id)
31
32
  return id;
32
33
  const oldChilds = (await this.emitOne(this.EVENTS.LAYER_BG.STATE_GET, { layer }));
33
34
  return oldChilds.length === 1 ? oldChilds[0].id : "";
34
35
  };
35
- emitChildChange = (layer, childId, duration, props) => this.emit(this.EVENTS.LAYER.CHILD_CHANGE, { layer, childId, duration, props });
36
36
  }
@@ -6,6 +6,6 @@ export declare class LayerBgHide extends ModuleCore<BgPluginEvents, BgPluginCons
6
6
  name: string;
7
7
  subscribe: () => void;
8
8
  onBgHide: ({ layer, transition, duration }?: BgHidePayload) => Promise<void>;
9
- getTransitionProps: (transition: string, duration: number) => TransitionProps;
10
9
  emitStateRm: (id: string) => Promise<import("@vnejs/shared").EmitResults<"vne:layer_bg:state_rm">> | undefined;
10
+ getTransitionProps: (transition: string, duration: number) => TransitionProps;
11
11
  }
@@ -20,9 +20,9 @@ export class LayerBgHide extends ModuleCore {
20
20
  await Promise.all(oldChildsId.map((childId) => this.emitStateRm(childId)));
21
21
  await this.emit(this.EVENTS.LAYER.CHILDS_RM, { layer, childsIds: oldChildsId });
22
22
  };
23
+ emitStateRm = (id) => this.emit(this.EVENTS.LAYER_BG.STATE_RM, { id });
23
24
  getTransitionProps = (transition, duration) => {
24
25
  const transitions = this.PARAMS.LAYER_BG.TRANSITIONS_HIDE;
25
26
  return transitions[transition] ? transitions[transition](duration) : transitions.opacity(duration);
26
27
  };
27
- emitStateRm = (id) => this.emit(this.EVENTS.LAYER_BG.STATE_RM, { id });
28
28
  }
@@ -6,6 +6,6 @@ export declare class LayerBgShow extends ModuleCore<BgPluginEvents, BgPluginCons
6
6
  name: string;
7
7
  subscribe: () => void;
8
8
  onBgShow: ({ name, layer, transition, duration, args, hideOldBgsOnShow }?: BgShowPayload) => Promise<[...(import("@vnejs/shared").EmitResults<"vne:layer_bg:state_rm"> | undefined)[], import("@vnejs/shared").EmitResults<"vne:layer:childs_rm"> | undefined] | undefined>;
9
- getTransitionProps: (transition: string, duration: number) => TransitionProps;
10
9
  emitStateRm: (id: string) => Promise<import("@vnejs/shared").EmitResults<"vne:layer_bg:state_rm">> | undefined;
10
+ getTransitionProps: (transition: string, duration: number) => TransitionProps;
11
11
  }
@@ -33,9 +33,9 @@ export class LayerBgShow extends ModuleCore {
33
33
  this.emit(this.EVENTS.LAYER.CHILDS_RM, { layer, childsIds: oldChildsId }),
34
34
  ]);
35
35
  };
36
+ emitStateRm = (id) => this.emit(this.EVENTS.LAYER_BG.STATE_RM, { id });
36
37
  getTransitionProps = (transition, duration) => {
37
38
  const transitions = this.PARAMS.LAYER_BG.TRANSITIONS_SHOW;
38
39
  return transitions[transition] ? transitions[transition](duration) : transitions.opacity(duration);
39
40
  };
40
- emitStateRm = (id) => this.emit(this.EVENTS.LAYER_BG.STATE_RM, { id });
41
41
  }
@@ -13,6 +13,11 @@ export declare class LayerBgState extends ModuleCore<BgPluginEvents, BgPluginCon
13
13
  onStateClear: () => Promise<void>;
14
14
  onStatePreload: ({ [this.name]: state }: Record<string, BgState>) => Promise<(import("@vnejs/shared").EmitResults<"vne:layer_bg:src_get"> | undefined)[]>;
15
15
  onMemoryCleared: () => Promise<void>;
16
+ getDefaultState: () => BgState;
17
+ emitBgSrcGet: (bg: BgRecord) => Promise<import("@vnejs/shared").EmitResults<"vne:layer_bg:src_get">> | undefined;
18
+ emitBgChange: (bg: BgRecord) => Promise<import("@vnejs/shared").EmitResults<"vne:layer_bg:change">> | undefined;
19
+ emitBgHide: (bg: BgRecord) => Promise<import("@vnejs/shared").EmitResults<"vne:layer_bg:hide">> | undefined;
20
+ emitBgShow: (bg: BgRecord) => Promise<import("@vnejs/shared").EmitResults<"vne:layer_bg:show">> | undefined;
16
21
  clearState: () => Promise<void>;
17
22
  preloadState: (state: BgState) => Promise<(import("@vnejs/shared").EmitResults<"vne:layer_bg:src_get"> | undefined)[]>;
18
23
  cloneBgAndChangeWithNewId: (bg: BgRecord, id: string) => Promise<unknown>;
@@ -20,10 +25,5 @@ export declare class LayerBgState extends ModuleCore<BgPluginEvents, BgPluginCon
20
25
  cloneBgAndHide: (bg: BgRecord) => Promise<unknown>;
21
26
  cloneBgAndShow: (bg: BgRecord) => Promise<unknown>;
22
27
  emitEventWithBg: (bg: BgRecord, cb: (bg: BgRecord) => unknown) => unknown;
23
- emitBgSrcGet: (bg: BgRecord) => Promise<import("@vnejs/shared").EmitResults<"vne:layer_bg:src_get">> | undefined;
24
- emitBgChange: (bg: BgRecord) => Promise<import("@vnejs/shared").EmitResults<"vne:layer_bg:change">> | undefined;
25
- emitBgHide: (bg: BgRecord) => Promise<import("@vnejs/shared").EmitResults<"vne:layer_bg:hide">> | undefined;
26
- emitBgShow: (bg: BgRecord) => Promise<import("@vnejs/shared").EmitResults<"vne:layer_bg:show">> | undefined;
27
28
  getBgsByLayerFromState: (acc: Record<string, BgRecord[]>, img: BgRecord) => Record<string, BgRecord[]>;
28
- getDefaultState: () => BgState;
29
29
  }
@@ -54,6 +54,11 @@ export class LayerBgState extends ModuleCore {
54
54
  await Promise.all(this.state.bgs.map(this.cloneBgAndChange));
55
55
  this.shared.viewForceAnimationSources.rm(`${this.name}.memory`);
56
56
  };
57
+ getDefaultState = () => ({ bgs: [] });
58
+ emitBgSrcGet = (bg) => this.emit(this.EVENTS.LAYER_BG.SRC_GET, bg);
59
+ emitBgChange = (bg) => this.emit(this.EVENTS.LAYER_BG.CHANGE, bg);
60
+ emitBgHide = (bg) => this.emit(this.EVENTS.LAYER_BG.HIDE, bg);
61
+ emitBgShow = (bg) => this.emit(this.EVENTS.LAYER_BG.SHOW, bg);
57
62
  clearState = async () => {
58
63
  this.shared.viewForceAnimationSources.add(`${this.name}.clear`);
59
64
  await Promise.all(this.state.bgs.map(this.cloneBgAndHide));
@@ -65,15 +70,10 @@ export class LayerBgState extends ModuleCore {
65
70
  cloneBgAndHide = async (bg) => this.emitEventWithBg(structuredClone(bg), this.emitBgHide);
66
71
  cloneBgAndShow = async (bg) => this.emitEventWithBg(structuredClone(bg), this.emitBgShow);
67
72
  emitEventWithBg = (bg, cb) => cb(bg);
68
- emitBgSrcGet = (bg) => this.emit(this.EVENTS.LAYER_BG.SRC_GET, bg);
69
- emitBgChange = (bg) => this.emit(this.EVENTS.LAYER_BG.CHANGE, bg);
70
- emitBgHide = (bg) => this.emit(this.EVENTS.LAYER_BG.HIDE, bg);
71
- emitBgShow = (bg) => this.emit(this.EVENTS.LAYER_BG.SHOW, bg);
72
73
  getBgsByLayerFromState = (acc, img) => {
73
74
  if (!acc[img.layer])
74
75
  acc[img.layer] = [];
75
76
  acc[img.layer].push(img);
76
77
  return acc;
77
78
  };
78
- getDefaultState = () => ({ bgs: [] });
79
79
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.canvas.child.bg",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -41,6 +41,9 @@ export class LayerBgChange extends ModuleCore<BgPluginEvents, BgPluginConstants,
41
41
  });
42
42
  };
43
43
 
44
+ emitChildChange = (layer: string, childId: string, duration: number, props: Record<string, unknown>) =>
45
+ this.emit(this.EVENTS.LAYER.CHILD_CHANGE, { layer, childId, duration, props });
46
+
44
47
  getBgId = async (id: string | undefined, layer: string) => {
45
48
  if (id) return id;
46
49
 
@@ -48,7 +51,4 @@ export class LayerBgChange extends ModuleCore<BgPluginEvents, BgPluginConstants,
48
51
 
49
52
  return oldChilds.length === 1 ? oldChilds[0].id : "";
50
53
  };
51
-
52
- emitChildChange = (layer: string, childId: string, duration: number, props: Record<string, unknown>) =>
53
- this.emit(this.EVENTS.LAYER.CHILD_CHANGE, { layer, childId, duration, props });
54
54
  }
@@ -32,11 +32,11 @@ export class LayerBgHide extends ModuleCore<BgPluginEvents, BgPluginConstants, B
32
32
  await this.emit(this.EVENTS.LAYER.CHILDS_RM, { layer, childsIds: oldChildsId });
33
33
  };
34
34
 
35
+ emitStateRm = (id: string) => this.emit(this.EVENTS.LAYER_BG.STATE_RM, { id });
36
+
35
37
  getTransitionProps = (transition: string, duration: number): TransitionProps => {
36
38
  const transitions = this.PARAMS.LAYER_BG.TRANSITIONS_HIDE;
37
39
 
38
40
  return transitions[transition as keyof typeof transitions] ? transitions[transition as keyof typeof transitions](duration) : transitions.opacity(duration);
39
41
  };
40
-
41
- emitStateRm = (id: string) => this.emit(this.EVENTS.LAYER_BG.STATE_RM, { id });
42
42
  }
@@ -48,11 +48,11 @@ export class LayerBgShow extends ModuleCore<BgPluginEvents, BgPluginConstants, B
48
48
  ]);
49
49
  };
50
50
 
51
+ emitStateRm = (id: string) => this.emit(this.EVENTS.LAYER_BG.STATE_RM, { id });
52
+
51
53
  getTransitionProps = (transition: string, duration: number): TransitionProps => {
52
54
  const transitions = this.PARAMS.LAYER_BG.TRANSITIONS_SHOW;
53
55
 
54
56
  return transitions[transition as keyof typeof transitions] ? transitions[transition as keyof typeof transitions](duration) : transitions.opacity(duration);
55
57
  };
56
-
57
- emitStateRm = (id: string) => this.emit(this.EVENTS.LAYER_BG.STATE_RM, { id });
58
58
  }
@@ -27,9 +27,7 @@ export class LayerBgStaff extends ModuleCore<BgPluginEvents, BgPluginConstants,
27
27
 
28
28
  return (await Promise.all([this.getBgMedia(`${name}/index`), ...overlaysPromises])).map(mediaToSrcs);
29
29
  };
30
-
31
30
  getBgSrcOne = async (name: string) => (await this.getBgMedia(name)).src;
32
-
33
31
  getBgMedia = (name: string) => {
34
32
  const [type, quality, mediaType] = [this.CONST.MEDIA.TYPES.IMAGE, this.shared.settings[this.SETTINGS.LAYER.QUALITY]!, "canvas"];
35
33
  const mediaName = `${this.CONST.LAYER_BG.LAYER_CHILD_TYPE}/${name}`;
@@ -79,35 +79,28 @@ export class LayerBgState extends ModuleCore<BgPluginEvents, BgPluginConstants,
79
79
  this.shared.viewForceAnimationSources.rm(`${this.name}.memory`);
80
80
  };
81
81
 
82
+ getDefaultState = (): BgState => ({ bgs: [] });
83
+
84
+ emitBgSrcGet = (bg: BgRecord) => this.emit(this.EVENTS.LAYER_BG.SRC_GET, bg);
85
+ emitBgChange = (bg: BgRecord) => this.emit(this.EVENTS.LAYER_BG.CHANGE, bg);
86
+ emitBgHide = (bg: BgRecord) => this.emit(this.EVENTS.LAYER_BG.HIDE, bg);
87
+ emitBgShow = (bg: BgRecord) => this.emit(this.EVENTS.LAYER_BG.SHOW, bg);
88
+
82
89
  clearState = async () => {
83
90
  this.shared.viewForceAnimationSources.add(`${this.name}.clear`);
84
91
  await Promise.all(this.state.bgs.map(this.cloneBgAndHide));
85
92
  this.shared.viewForceAnimationSources.rm(`${this.name}.clear`);
86
93
  };
87
-
88
94
  preloadState = (state: BgState) => Promise.all(state.bgs.map(this.emitBgSrcGet));
89
-
90
95
  cloneBgAndChangeWithNewId = async (bg: BgRecord, id: string) => this.emitEventWithBg({ ...structuredClone(bg), id }, this.emitBgChange);
91
-
92
96
  cloneBgAndChange = async (bg: BgRecord) => this.emitEventWithBg(structuredClone(bg), this.emitBgChange);
93
-
94
97
  cloneBgAndHide = async (bg: BgRecord) => this.emitEventWithBg(structuredClone(bg), this.emitBgHide);
95
-
96
98
  cloneBgAndShow = async (bg: BgRecord) => this.emitEventWithBg(structuredClone(bg), this.emitBgShow);
97
-
98
99
  emitEventWithBg = (bg: BgRecord, cb: (bg: BgRecord) => unknown) => cb(bg);
99
-
100
- emitBgSrcGet = (bg: BgRecord) => this.emit(this.EVENTS.LAYER_BG.SRC_GET, bg);
101
- emitBgChange = (bg: BgRecord) => this.emit(this.EVENTS.LAYER_BG.CHANGE, bg);
102
- emitBgHide = (bg: BgRecord) => this.emit(this.EVENTS.LAYER_BG.HIDE, bg);
103
- emitBgShow = (bg: BgRecord) => this.emit(this.EVENTS.LAYER_BG.SHOW, bg);
104
-
105
100
  getBgsByLayerFromState = (acc: Record<string, BgRecord[]>, img: BgRecord) => {
106
101
  if (!acc[img.layer!]) acc[img.layer!] = [];
107
102
  acc[img.layer!].push(img);
108
103
 
109
104
  return acc;
110
105
  };
111
-
112
- getDefaultState = (): BgState => ({ bgs: [] });
113
106
  }