@vnejs/plugins.canvas.child.bg 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.
@@ -22,9 +22,7 @@ export class LayerBgHide extends ModuleCore {
22
22
  };
23
23
  getTransitionProps = (transition, duration) => {
24
24
  const transitions = this.PARAMS.LAYER_BG.TRANSITIONS_HIDE;
25
- return transitions[transition]
26
- ? transitions[transition](duration)
27
- : transitions.opacity(duration);
25
+ return transitions[transition] ? transitions[transition](duration) : transitions.opacity(duration);
28
26
  };
29
27
  emitStateRm = (id) => this.emit(this.EVENTS.LAYER_BG.STATE_RM, { id });
30
28
  }
@@ -8,7 +8,7 @@ export class LayerBgShow extends ModuleCore {
8
8
  onBgShow = async ({ name, layer, transition, duration, args = {}, hideOldBgsOnShow = true } = {}) => {
9
9
  const clonedArgs = await this.emitClone(args);
10
10
  const shouldHideOldImages = hideOldBgsOnShow || clonedArgs.hideOldBgsOnShow;
11
- const id = clonedArgs.id || (await this.emitOne(this.EVENTS.VENDORS.UID));
11
+ const id = clonedArgs.id || crypto.randomUUID();
12
12
  const oldChildsId = shouldHideOldImages
13
13
  ? (await this.emitOne(this.EVENTS.LAYER_BG.STATE_GET, { layer })).map((item) => item.id)
14
14
  : [];
@@ -28,13 +28,14 @@ export class LayerBgShow extends ModuleCore {
28
28
  await this.emit(this.EVENTS.INTERACT.POP, { key });
29
29
  }
30
30
  if (shouldHideOldImages)
31
- return Promise.all([...oldChildsId.map((childId) => this.emitStateRm(childId)), this.emit(this.EVENTS.LAYER.CHILDS_RM, { layer, childsIds: oldChildsId })]);
31
+ return Promise.all([
32
+ ...oldChildsId.map((childId) => this.emitStateRm(childId)),
33
+ this.emit(this.EVENTS.LAYER.CHILDS_RM, { layer, childsIds: oldChildsId }),
34
+ ]);
32
35
  };
33
36
  getTransitionProps = (transition, duration) => {
34
37
  const transitions = this.PARAMS.LAYER_BG.TRANSITIONS_SHOW;
35
- return transitions[transition]
36
- ? transitions[transition](duration)
37
- : transitions.opacity(duration);
38
+ return transitions[transition] ? transitions[transition](duration) : transitions.opacity(duration);
38
39
  };
39
40
  emitStateRm = (id) => this.emit(this.EVENTS.LAYER_BG.STATE_RM, { id });
40
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.canvas.child.bg",
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",
@@ -33,9 +33,7 @@ export class LayerBgHide extends ModuleCore<BgPluginEvents, BgPluginConstants, B
33
33
  getTransitionProps = (transition: string, duration: number): TransitionProps => {
34
34
  const transitions = this.PARAMS.LAYER_BG.TRANSITIONS_HIDE;
35
35
 
36
- return transitions[transition as keyof typeof transitions]
37
- ? transitions[transition as keyof typeof transitions](duration)
38
- : transitions.opacity(duration);
36
+ return transitions[transition as keyof typeof transitions] ? transitions[transition as keyof typeof transitions](duration) : transitions.opacity(duration);
39
37
  };
40
38
 
41
39
  emitStateRm = (id: string) => this.emit(this.EVENTS.LAYER_BG.STATE_RM, { id });
@@ -16,7 +16,7 @@ export class LayerBgShow extends ModuleCore<BgPluginEvents, BgPluginConstants, B
16
16
 
17
17
  const shouldHideOldImages = hideOldBgsOnShow || clonedArgs.hideOldBgsOnShow;
18
18
 
19
- const id = clonedArgs.id || (await this.emitOne(this.EVENTS.VENDORS.UID));
19
+ const id = clonedArgs.id || crypto.randomUUID();
20
20
  const oldChildsId = shouldHideOldImages
21
21
  ? ((await this.emitOne(this.EVENTS.LAYER_BG.STATE_GET, { layer })) as BgStateIdPayload[]).map((item) => item.id!)
22
22
  : [];
@@ -40,15 +40,16 @@ export class LayerBgShow extends ModuleCore<BgPluginEvents, BgPluginConstants, B
40
40
  }
41
41
 
42
42
  if (shouldHideOldImages)
43
- return Promise.all([...oldChildsId.map((childId) => this.emitStateRm(childId)), this.emit(this.EVENTS.LAYER.CHILDS_RM, { layer, childsIds: oldChildsId })]);
43
+ return Promise.all([
44
+ ...oldChildsId.map((childId) => this.emitStateRm(childId)),
45
+ this.emit(this.EVENTS.LAYER.CHILDS_RM, { layer, childsIds: oldChildsId }),
46
+ ]);
44
47
  };
45
48
 
46
49
  getTransitionProps = (transition: string, duration: number): TransitionProps => {
47
50
  const transitions = this.PARAMS.LAYER_BG.TRANSITIONS_SHOW;
48
51
 
49
- return transitions[transition as keyof typeof transitions]
50
- ? transitions[transition as keyof typeof transitions](duration)
51
- : transitions.opacity(duration);
52
+ return transitions[transition as keyof typeof transitions] ? transitions[transition as keyof typeof transitions](duration) : transitions.opacity(duration);
52
53
  };
53
54
 
54
55
  emitStateRm = (id: string) => this.emit(this.EVENTS.LAYER_BG.STATE_RM, { id });
@@ -87,8 +87,7 @@ 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) =>
91
- this.emitEventWithBg({ ...(await this.emitClone<BgRecord>(bg)), id }, this.emitBgChange);
90
+ cloneBgAndChangeWithNewId = async (bg: BgRecord, id: string) => this.emitEventWithBg({ ...(await this.emitClone<BgRecord>(bg)), id }, this.emitBgChange);
92
91
 
93
92
  cloneBgAndChange = async (bg: BgRecord) => this.emitEventWithBg(await this.emitClone<BgRecord>(bg), this.emitBgChange);
94
93
 
@@ -8,14 +8,7 @@ import {
8
8
  } from "@vnejs/contracts.canvas.layer";
9
9
  import { CONSTANTS, PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.canvas.child.bg";
10
10
  import { SourcesSet } from "@vnejs/sources-set";
11
- import {
12
- createTestModule as baseCreateTestModule,
13
- registerCoreVne,
14
- registerVnePlugin,
15
- stubEvent,
16
- stubSilentEvent,
17
- stubVendorEvents,
18
- } from "@vnejs/test-utils";
11
+ import { createTestModule as baseCreateTestModule, registerCoreVne, registerVnePlugin, stubEvent, stubSilentEvent, stubVendorEvents } from "@vnejs/test-utils";
19
12
 
20
13
  export const registerBgPluginVne = () => {
21
14
  registerCoreVne();
package/tsconfig.json CHANGED
@@ -4,12 +4,6 @@
4
4
  "rootDir": "src",
5
5
  "outDir": "dist"
6
6
  },
7
- "include": [
8
- "src/**/*.ts"
9
- ],
10
- "exclude": [
11
- "dist",
12
- "node_modules",
13
- "src/tests"
14
- ]
7
+ "include": ["src/**/*.ts"],
8
+ "exclude": ["dist", "node_modules", "src/tests"]
15
9
  }