@vnejs/compatibility.scenario.choose-with-scenario.qte 0.2.4 → 0.2.5
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/index.d.ts +2 -2
- package/dist/index.js +8 -8
- package/package.json +1 -1
- package/src/index.ts +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -11,9 +11,9 @@ declare module "@vnejs/contracts.scenario.choose" {
|
|
|
11
11
|
export declare class CompatibilityScenarioChooseWithScenarioQte extends ModuleCore<PluginEvents, PluginConstants, PluginSettings, PluginParams> {
|
|
12
12
|
name: string;
|
|
13
13
|
pendingResolve: ((success: boolean) => void) | null;
|
|
14
|
-
init: () => Promise<import("@vnejs/shared").EmitResults<"vne:choose:option_replace_reg">> | undefined;
|
|
15
14
|
subscribe: () => void;
|
|
16
|
-
|
|
15
|
+
init: () => Promise<import("@vnejs/shared").EmitResults<"vne:choose:option_replace_reg">> | undefined;
|
|
17
16
|
onOptionReplace: ChooseOptionReplaceHandler;
|
|
17
|
+
onQteResult: ({ success }?: QteResultPayload) => void;
|
|
18
18
|
resolveFailIndex: (index: number, options: ChooseOption[]) => number;
|
|
19
19
|
}
|
package/dist/index.js
CHANGED
|
@@ -8,17 +8,10 @@ const LOGS_ACTIONS = {
|
|
|
8
8
|
export class CompatibilityScenarioChooseWithScenarioQte extends ModuleCore {
|
|
9
9
|
name = "compatibility.scenario.choose-with-scenario.qte";
|
|
10
10
|
pendingResolve = null;
|
|
11
|
-
init = () => this.emit(this.EVENTS.CHOOSE.OPTION_REPLACE_REG, { handler: this.onOptionReplace });
|
|
12
11
|
subscribe = () => {
|
|
13
12
|
this.on(this.EVENTS.QTE.RESULT, this.onQteResult);
|
|
14
13
|
};
|
|
15
|
-
|
|
16
|
-
if (!this.pendingResolve)
|
|
17
|
-
return;
|
|
18
|
-
const resolve = this.pendingResolve;
|
|
19
|
-
this.pendingResolve = null;
|
|
20
|
-
resolve(!!success);
|
|
21
|
-
};
|
|
14
|
+
init = () => this.emit(this.EVENTS.CHOOSE.OPTION_REPLACE_REG, { handler: this.onOptionReplace });
|
|
22
15
|
onOptionReplace = async ({ index = 0, options = [] } = {}) => {
|
|
23
16
|
const option = options[index];
|
|
24
17
|
const qteId = option?.qte;
|
|
@@ -37,6 +30,13 @@ export class CompatibilityScenarioChooseWithScenarioQte extends ModuleCore {
|
|
|
37
30
|
return index;
|
|
38
31
|
return this.resolveFailIndex(index, options);
|
|
39
32
|
};
|
|
33
|
+
onQteResult = ({ success = false } = {}) => {
|
|
34
|
+
if (!this.pendingResolve)
|
|
35
|
+
return;
|
|
36
|
+
const resolve = this.pendingResolve;
|
|
37
|
+
this.pendingResolve = null;
|
|
38
|
+
resolve(!!success);
|
|
39
|
+
};
|
|
40
40
|
resolveFailIndex = (index, options) => {
|
|
41
41
|
const fallbackIndex = options.findIndex((option) => option.keywords?.includes(this.CONST.QTE.LINE_KEYWORDS.QTE_FALLBACK));
|
|
42
42
|
if (fallbackIndex < 0) {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -23,19 +23,11 @@ export class CompatibilityScenarioChooseWithScenarioQte extends ModuleCore<Plugi
|
|
|
23
23
|
|
|
24
24
|
pendingResolve: ((success: boolean) => void) | null = null;
|
|
25
25
|
|
|
26
|
-
init = () => this.emit(this.EVENTS.CHOOSE.OPTION_REPLACE_REG, { handler: this.onOptionReplace } satisfies ChooseOptionReplaceRegPayload);
|
|
27
|
-
|
|
28
26
|
subscribe = () => {
|
|
29
27
|
this.on(this.EVENTS.QTE.RESULT, this.onQteResult);
|
|
30
28
|
};
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
if (!this.pendingResolve) return;
|
|
34
|
-
|
|
35
|
-
const resolve = this.pendingResolve;
|
|
36
|
-
this.pendingResolve = null;
|
|
37
|
-
resolve(!!success);
|
|
38
|
-
};
|
|
30
|
+
init = () => this.emit(this.EVENTS.CHOOSE.OPTION_REPLACE_REG, { handler: this.onOptionReplace } satisfies ChooseOptionReplaceRegPayload);
|
|
39
31
|
|
|
40
32
|
onOptionReplace: ChooseOptionReplaceHandler = async ({ index = 0, options = [] }: ChooseOptionReplacePayload = {}) => {
|
|
41
33
|
const option = options[index];
|
|
@@ -60,6 +52,14 @@ export class CompatibilityScenarioChooseWithScenarioQte extends ModuleCore<Plugi
|
|
|
60
52
|
return this.resolveFailIndex(index, options);
|
|
61
53
|
};
|
|
62
54
|
|
|
55
|
+
onQteResult = ({ success = false }: QteResultPayload = {}) => {
|
|
56
|
+
if (!this.pendingResolve) return;
|
|
57
|
+
|
|
58
|
+
const resolve = this.pendingResolve;
|
|
59
|
+
this.pendingResolve = null;
|
|
60
|
+
resolve(!!success);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
63
|
resolveFailIndex = (index: number, options: ChooseOption[]) => {
|
|
64
64
|
const fallbackIndex = options.findIndex((option) => option.keywords?.includes(this.CONST.QTE.LINE_KEYWORDS.QTE_FALLBACK));
|
|
65
65
|
|