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

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.
@@ -11,7 +11,7 @@ export class LayerBgChange extends ModuleCore {
11
11
  const realId = await this.getBgId(id, layer);
12
12
  if (!realId)
13
13
  return;
14
- const clonedArgs = await this.emitClone(args);
14
+ const clonedArgs = structuredClone(args);
15
15
  const src = await this.emitOne(this.EVENTS.LAYER_BG.SRC_GET, { name, layer, args: clonedArgs });
16
16
  const changeArgs = { src, isAllSrcRendered: Boolean(clonedArgs.overlays), name, args: clonedArgs };
17
17
  await this.emit(this.EVENTS.LAYER_BG.STATE_UPDATE, { id: realId, name, args: clonedArgs });
@@ -6,7 +6,7 @@ export class LayerBgShow extends ModuleCore {
6
6
  this.on(this.EVENTS.LAYER_BG.SHOW, this.onBgShow);
7
7
  };
8
8
  onBgShow = async ({ name, layer, transition, duration, args = {}, hideOldBgsOnShow = true } = {}) => {
9
- const clonedArgs = await this.emitClone(args);
9
+ const clonedArgs = structuredClone(args);
10
10
  const shouldHideOldImages = hideOldBgsOnShow || clonedArgs.hideOldBgsOnShow;
11
11
  const id = clonedArgs.id || crypto.randomUUID();
12
12
  const oldChildsId = shouldHideOldImages
@@ -7,7 +7,7 @@ export class LayerBgStaff extends ModuleCore {
7
7
  this.on(this.EVENTS.LAYER_BG.SRC_GET, this.onBgGetSrc);
8
8
  };
9
9
  onBgGetSrc = async ({ name = "", args = {} } = {}) => {
10
- const clonedArgs = await this.emitClone(args);
10
+ const clonedArgs = structuredClone(args);
11
11
  const injections = (await this.emitReals(this.EVENTS.LAYER_BG.ARGS_INJECT, { args: clonedArgs }));
12
12
  const { overlays } = applyArgsInjections(clonedArgs, injections);
13
13
  return overlays ? this.getBgSrcOverlays(name, overlays) : this.getBgSrcOne(name);
@@ -24,8 +24,8 @@ export class LayerBgState extends ModuleCore {
24
24
  this.state.bgs = this.state.bgs.filter((e) => e.id !== id);
25
25
  };
26
26
  onStateSet = async (payload) => {
27
- const clonedStateOld = await this.emitClone(this.state);
28
- const clonedStateNew = await this.emitClone(this.getStateSlice(payload));
27
+ const clonedStateOld = structuredClone(this.state);
28
+ const clonedStateNew = structuredClone(this.getStateSlice(payload));
29
29
  await this.preloadState(clonedStateNew);
30
30
  const oldBgsByLayer = clonedStateOld.bgs.reduce(this.getBgsByLayerFromState, {});
31
31
  const newBgsByLayer = clonedStateNew.bgs.reduce(this.getBgsByLayerFromState, {});
@@ -60,10 +60,10 @@ export class LayerBgState extends ModuleCore {
60
60
  this.shared.viewForceAnimationSources.rm(`${this.name}.clear`);
61
61
  };
62
62
  preloadState = (state) => Promise.all(state.bgs.map(this.emitBgSrcGet));
63
- cloneBgAndChangeWithNewId = async (bg, id) => this.emitEventWithBg({ ...(await this.emitClone(bg)), id }, this.emitBgChange);
64
- cloneBgAndChange = async (bg) => this.emitEventWithBg(await this.emitClone(bg), this.emitBgChange);
65
- cloneBgAndHide = async (bg) => this.emitEventWithBg(await this.emitClone(bg), this.emitBgHide);
66
- cloneBgAndShow = async (bg) => this.emitEventWithBg(await this.emitClone(bg), this.emitBgShow);
63
+ cloneBgAndChangeWithNewId = async (bg, id) => this.emitEventWithBg({ ...structuredClone(bg), id }, this.emitBgChange);
64
+ cloneBgAndChange = async (bg) => this.emitEventWithBg(structuredClone(bg), this.emitBgChange);
65
+ cloneBgAndHide = async (bg) => this.emitEventWithBg(structuredClone(bg), this.emitBgHide);
66
+ cloneBgAndShow = async (bg) => this.emitEventWithBg(structuredClone(bg), this.emitBgShow);
67
67
  emitEventWithBg = (bg, cb) => cb(bg);
68
68
  emitBgSrcGet = (bg) => this.emit(this.EVENTS.LAYER_BG.SRC_GET, bg);
69
69
  emitBgChange = (bg) => this.emit(this.EVENTS.LAYER_BG.CHANGE, bg);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.canvas.child.bg",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,7 +19,7 @@ export class LayerBgChange extends ModuleCore<BgPluginEvents, BgPluginConstants,
19
19
 
20
20
  if (!realId) return;
21
21
 
22
- const clonedArgs = await this.emitClone<BgArgs>(args);
22
+ const clonedArgs = structuredClone(args);
23
23
 
24
24
  const src = await this.emitOne(this.EVENTS.LAYER_BG.SRC_GET, { name, layer, args: clonedArgs });
25
25
 
@@ -14,7 +14,7 @@ export class LayerBgShow extends ModuleCore<BgPluginEvents, BgPluginConstants, B
14
14
  };
15
15
 
16
16
  onBgShow = async ({ name, layer, transition, duration, args = {}, hideOldBgsOnShow = true }: BgShowPayload = {}) => {
17
- const clonedArgs = await this.emitClone<BgArgs>(args);
17
+ const clonedArgs = structuredClone(args);
18
18
 
19
19
  const shouldHideOldImages = hideOldBgsOnShow || clonedArgs.hideOldBgsOnShow;
20
20
 
@@ -15,7 +15,7 @@ export class LayerBgStaff extends ModuleCore<BgPluginEvents, BgPluginConstants,
15
15
  };
16
16
 
17
17
  onBgGetSrc = async ({ name = "", args = {} }: BgSrcGetPayload = {}) => {
18
- const clonedArgs = await this.emitClone<BgArgs>(args);
18
+ const clonedArgs = structuredClone(args);
19
19
  const injections = (await this.emitReals(this.EVENTS.LAYER_BG.ARGS_INJECT, { args: clonedArgs })) as BgArgsInject[];
20
20
  const { overlays } = applyArgsInjections(clonedArgs, injections);
21
21
 
@@ -37,8 +37,8 @@ export class LayerBgState extends ModuleCore<BgPluginEvents, BgPluginConstants,
37
37
  };
38
38
 
39
39
  onStateSet = async (payload: ModuleGlobalStateRegistry) => {
40
- const clonedStateOld = await this.emitClone<BgState>(this.state);
41
- const clonedStateNew = await this.emitClone<BgState>(this.getStateSlice(payload));
40
+ const clonedStateOld = structuredClone(this.state);
41
+ const clonedStateNew = structuredClone(this.getStateSlice(payload));
42
42
 
43
43
  await this.preloadState(clonedStateNew);
44
44
 
@@ -87,13 +87,13 @@ export class LayerBgState extends ModuleCore<BgPluginEvents, BgPluginConstants,
87
87
 
88
88
  preloadState = (state: BgState) => Promise.all(state.bgs.map(this.emitBgSrcGet));
89
89
 
90
- cloneBgAndChangeWithNewId = async (bg: BgRecord, id: string) => this.emitEventWithBg({ ...(await this.emitClone<BgRecord>(bg)), id }, this.emitBgChange);
90
+ cloneBgAndChangeWithNewId = async (bg: BgRecord, id: string) => this.emitEventWithBg({ ...structuredClone(bg), id }, this.emitBgChange);
91
91
 
92
- cloneBgAndChange = async (bg: BgRecord) => this.emitEventWithBg(await this.emitClone<BgRecord>(bg), this.emitBgChange);
92
+ cloneBgAndChange = async (bg: BgRecord) => this.emitEventWithBg(structuredClone(bg), this.emitBgChange);
93
93
 
94
- cloneBgAndHide = async (bg: BgRecord) => this.emitEventWithBg(await this.emitClone<BgRecord>(bg), this.emitBgHide);
94
+ cloneBgAndHide = async (bg: BgRecord) => this.emitEventWithBg(structuredClone(bg), this.emitBgHide);
95
95
 
96
- cloneBgAndShow = async (bg: BgRecord) => this.emitEventWithBg(await this.emitClone<BgRecord>(bg), this.emitBgShow);
96
+ cloneBgAndShow = async (bg: BgRecord) => this.emitEventWithBg(structuredClone(bg), this.emitBgShow);
97
97
 
98
98
  emitEventWithBg = (bg: BgRecord, cb: (bg: BgRecord) => unknown) => cb(bg);
99
99