@vnejs/plugins.canvas.child.bg 0.2.5 → 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.
- package/dist/modules/change.d.ts +1 -1
- package/dist/modules/change.js +2 -2
- package/dist/modules/hide.d.ts +1 -1
- package/dist/modules/hide.js +1 -1
- package/dist/modules/show.d.ts +1 -1
- package/dist/modules/show.js +2 -2
- package/dist/modules/staff.js +1 -1
- package/dist/modules/state.d.ts +5 -5
- package/dist/modules/state.js +11 -11
- package/package.json +1 -1
- package/src/modules/change.ts +4 -4
- package/src/modules/hide.ts +2 -2
- package/src/modules/show.ts +3 -3
- package/src/modules/staff.ts +1 -3
- package/src/modules/state.ts +13 -20
package/dist/modules/change.d.ts
CHANGED
|
@@ -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
|
}
|
package/dist/modules/change.js
CHANGED
|
@@ -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 =
|
|
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 });
|
|
@@ -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
|
}
|
package/dist/modules/hide.d.ts
CHANGED
|
@@ -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
|
}
|
package/dist/modules/hide.js
CHANGED
|
@@ -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
|
}
|
package/dist/modules/show.d.ts
CHANGED
|
@@ -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
|
}
|
package/dist/modules/show.js
CHANGED
|
@@ -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 =
|
|
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
|
|
@@ -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
|
}
|
package/dist/modules/staff.js
CHANGED
|
@@ -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 =
|
|
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);
|
package/dist/modules/state.d.ts
CHANGED
|
@@ -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
|
}
|
package/dist/modules/state.js
CHANGED
|
@@ -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 =
|
|
28
|
-
const clonedStateNew =
|
|
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, {});
|
|
@@ -54,26 +54,26 @@ 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));
|
|
60
65
|
this.shared.viewForceAnimationSources.rm(`${this.name}.clear`);
|
|
61
66
|
};
|
|
62
67
|
preloadState = (state) => Promise.all(state.bgs.map(this.emitBgSrcGet));
|
|
63
|
-
cloneBgAndChangeWithNewId = async (bg, id) => this.emitEventWithBg({ ...(
|
|
64
|
-
cloneBgAndChange = async (bg) => this.emitEventWithBg(
|
|
65
|
-
cloneBgAndHide = async (bg) => this.emitEventWithBg(
|
|
66
|
-
cloneBgAndShow = async (bg) => this.emitEventWithBg(
|
|
68
|
+
cloneBgAndChangeWithNewId = async (bg, id) => this.emitEventWithBg({ ...structuredClone(bg), id }, this.emitBgChange);
|
|
69
|
+
cloneBgAndChange = async (bg) => this.emitEventWithBg(structuredClone(bg), this.emitBgChange);
|
|
70
|
+
cloneBgAndHide = async (bg) => this.emitEventWithBg(structuredClone(bg), this.emitBgHide);
|
|
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
package/src/modules/change.ts
CHANGED
|
@@ -19,7 +19,7 @@ export class LayerBgChange extends ModuleCore<BgPluginEvents, BgPluginConstants,
|
|
|
19
19
|
|
|
20
20
|
if (!realId) return;
|
|
21
21
|
|
|
22
|
-
const clonedArgs =
|
|
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
|
|
|
@@ -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
|
}
|
package/src/modules/hide.ts
CHANGED
|
@@ -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
|
}
|
package/src/modules/show.ts
CHANGED
|
@@ -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 =
|
|
17
|
+
const clonedArgs = structuredClone(args);
|
|
18
18
|
|
|
19
19
|
const shouldHideOldImages = hideOldBgsOnShow || clonedArgs.hideOldBgsOnShow;
|
|
20
20
|
|
|
@@ -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
|
}
|
package/src/modules/staff.ts
CHANGED
|
@@ -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 =
|
|
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
|
|
|
@@ -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}`;
|
package/src/modules/state.ts
CHANGED
|
@@ -37,8 +37,8 @@ export class LayerBgState extends ModuleCore<BgPluginEvents, BgPluginConstants,
|
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
onStateSet = async (payload: ModuleGlobalStateRegistry) => {
|
|
40
|
-
const clonedStateOld =
|
|
41
|
-
const clonedStateNew =
|
|
40
|
+
const clonedStateOld = structuredClone(this.state);
|
|
41
|
+
const clonedStateNew = structuredClone(this.getStateSlice(payload));
|
|
42
42
|
|
|
43
43
|
await this.preloadState(clonedStateNew);
|
|
44
44
|
|
|
@@ -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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
cloneBgAndHide = async (bg: BgRecord) => this.emitEventWithBg(await this.emitClone<BgRecord>(bg), this.emitBgHide);
|
|
95
|
-
|
|
96
|
-
cloneBgAndShow = async (bg: BgRecord) => this.emitEventWithBg(await this.emitClone<BgRecord>(bg), this.emitBgShow);
|
|
97
|
-
|
|
95
|
+
cloneBgAndChangeWithNewId = async (bg: BgRecord, id: string) => this.emitEventWithBg({ ...structuredClone(bg), id }, this.emitBgChange);
|
|
96
|
+
cloneBgAndChange = async (bg: BgRecord) => this.emitEventWithBg(structuredClone(bg), this.emitBgChange);
|
|
97
|
+
cloneBgAndHide = async (bg: BgRecord) => this.emitEventWithBg(structuredClone(bg), this.emitBgHide);
|
|
98
|
+
cloneBgAndShow = async (bg: BgRecord) => this.emitEventWithBg(structuredClone(bg), this.emitBgShow);
|
|
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
|
}
|