@novely/core 0.33.0-beta.1 → 0.33.0-beta.2
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 +5 -0
- package/dist/index.global.js +36 -32
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +38 -32
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -95,6 +95,11 @@ type Context = {
|
|
|
95
95
|
}, resolve: () => void) => void;
|
|
96
96
|
custom: (fn: CustomHandler<Lang, State>, push: () => void) => Thenable<void>;
|
|
97
97
|
clearCustom: (fn: CustomHandler<Lang, State>) => void;
|
|
98
|
+
/**
|
|
99
|
+
* Clears all mentioned actions except for preserved one
|
|
100
|
+
* @param preserve Action to preserve
|
|
101
|
+
*/
|
|
102
|
+
clearAction: (preserve: 'dialog' | 'choice' | 'input' | 'text') => void;
|
|
98
103
|
text: (str: string, resolve: () => void) => void;
|
|
99
104
|
vibrate: (pattern: VibratePattern) => void;
|
|
100
105
|
audio: {
|
package/dist/index.global.js
CHANGED
|
@@ -215,6 +215,34 @@ var Novely = (() => {
|
|
|
215
215
|
// ../../node_modules/.pnpm/esm-env@1.0.0/node_modules/esm-env/prod-ssr.js
|
|
216
216
|
var DEV = false;
|
|
217
217
|
|
|
218
|
+
// ../../node_modules/.pnpm/klona@2.0.6/node_modules/klona/json/index.mjs
|
|
219
|
+
function klona(val) {
|
|
220
|
+
var k, out, tmp;
|
|
221
|
+
if (Array.isArray(val)) {
|
|
222
|
+
out = Array(k = val.length);
|
|
223
|
+
while (k--)
|
|
224
|
+
out[k] = (tmp = val[k]) && typeof tmp === "object" ? klona(tmp) : tmp;
|
|
225
|
+
return out;
|
|
226
|
+
}
|
|
227
|
+
if (Object.prototype.toString.call(val) === "[object Object]") {
|
|
228
|
+
out = {};
|
|
229
|
+
for (k in val) {
|
|
230
|
+
if (k === "__proto__") {
|
|
231
|
+
Object.defineProperty(out, k, {
|
|
232
|
+
value: klona(val[k]),
|
|
233
|
+
configurable: true,
|
|
234
|
+
enumerable: true,
|
|
235
|
+
writable: true
|
|
236
|
+
});
|
|
237
|
+
} else {
|
|
238
|
+
out[k] = (tmp = val[k]) && typeof tmp === "object" ? klona(tmp) : tmp;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return out;
|
|
242
|
+
}
|
|
243
|
+
return val;
|
|
244
|
+
}
|
|
245
|
+
|
|
218
246
|
// src/utils.ts
|
|
219
247
|
var matchAction = ({ getContext, push, forward }, values) => {
|
|
220
248
|
return (action, props, { ctx, data }) => {
|
|
@@ -686,7 +714,7 @@ var Novely = (() => {
|
|
|
686
714
|
if (isExitImpossible(path)) {
|
|
687
715
|
const referred = refer(path);
|
|
688
716
|
if (isAction(referred) && isSkippedDuringRestore(referred[0])) {
|
|
689
|
-
onExitImpossible();
|
|
717
|
+
onExitImpossible?.();
|
|
690
718
|
}
|
|
691
719
|
wasExitImpossible = true;
|
|
692
720
|
return {
|
|
@@ -858,34 +886,6 @@ var Novely = (() => {
|
|
|
858
886
|
}
|
|
859
887
|
};
|
|
860
888
|
|
|
861
|
-
// ../../node_modules/.pnpm/klona@2.0.6/node_modules/klona/json/index.mjs
|
|
862
|
-
function klona(val) {
|
|
863
|
-
var k, out, tmp;
|
|
864
|
-
if (Array.isArray(val)) {
|
|
865
|
-
out = Array(k = val.length);
|
|
866
|
-
while (k--)
|
|
867
|
-
out[k] = (tmp = val[k]) && typeof tmp === "object" ? klona(tmp) : tmp;
|
|
868
|
-
return out;
|
|
869
|
-
}
|
|
870
|
-
if (Object.prototype.toString.call(val) === "[object Object]") {
|
|
871
|
-
out = {};
|
|
872
|
-
for (k in val) {
|
|
873
|
-
if (k === "__proto__") {
|
|
874
|
-
Object.defineProperty(out, k, {
|
|
875
|
-
value: klona(val[k]),
|
|
876
|
-
configurable: true,
|
|
877
|
-
enumerable: true,
|
|
878
|
-
writable: true
|
|
879
|
-
});
|
|
880
|
-
} else {
|
|
881
|
-
out[k] = (tmp = val[k]) && typeof tmp === "object" ? klona(tmp) : tmp;
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
return out;
|
|
885
|
-
}
|
|
886
|
-
return val;
|
|
887
|
-
}
|
|
888
|
-
|
|
889
889
|
// src/translation.ts
|
|
890
890
|
var RGX = /{{(.*?)}}/g;
|
|
891
891
|
var split = (input, delimeters) => {
|
|
@@ -1407,7 +1407,7 @@ var Novely = (() => {
|
|
|
1407
1407
|
const path = stack.value[0];
|
|
1408
1408
|
nextPath(path);
|
|
1409
1409
|
};
|
|
1410
|
-
const
|
|
1410
|
+
const matchActionOptions = {
|
|
1411
1411
|
getContext: renderer.getContext,
|
|
1412
1412
|
push(ctx) {
|
|
1413
1413
|
if (ctx.meta.restoring)
|
|
@@ -1418,12 +1418,12 @@ var Novely = (() => {
|
|
|
1418
1418
|
forward(ctx) {
|
|
1419
1419
|
if (!ctx.meta.preview)
|
|
1420
1420
|
enmemory(ctx);
|
|
1421
|
-
|
|
1421
|
+
matchActionOptions.push(ctx);
|
|
1422
1422
|
if (!ctx.meta.preview)
|
|
1423
1423
|
interactivity(true);
|
|
1424
1424
|
}
|
|
1425
1425
|
};
|
|
1426
|
-
const match = matchAction(
|
|
1426
|
+
const match = matchAction(matchActionOptions, {
|
|
1427
1427
|
wait({ ctx, push }, [time]) {
|
|
1428
1428
|
if (ctx.meta.restoring)
|
|
1429
1429
|
return;
|
|
@@ -1505,6 +1505,7 @@ var Novely = (() => {
|
|
|
1505
1505
|
}
|
|
1506
1506
|
return c || "";
|
|
1507
1507
|
})();
|
|
1508
|
+
ctx.clearAction("dialog");
|
|
1508
1509
|
ctx.dialog(
|
|
1509
1510
|
templateReplace(content, data2),
|
|
1510
1511
|
templateReplace(name, data2),
|
|
@@ -1555,6 +1556,7 @@ var Novely = (() => {
|
|
|
1555
1556
|
if (DEV && transformedChoices.length === 0) {
|
|
1556
1557
|
throw new Error(`Running choice without variants to choose from, look at how to use Choice action properly [https://novely.pages.dev/guide/actions/choice#usage]`);
|
|
1557
1558
|
}
|
|
1559
|
+
ctx.clearAction("choice");
|
|
1558
1560
|
ctx.choices(templateReplace(question, data2), transformedChoices, (selected) => {
|
|
1559
1561
|
if (!ctx.meta.preview) {
|
|
1560
1562
|
enmemory(ctx);
|
|
@@ -1618,6 +1620,7 @@ var Novely = (() => {
|
|
|
1618
1620
|
exit(true, false);
|
|
1619
1621
|
},
|
|
1620
1622
|
input({ ctx, data: data2, forward }, [question, onInput, setup]) {
|
|
1623
|
+
ctx.clearAction("input");
|
|
1621
1624
|
ctx.input(
|
|
1622
1625
|
templateReplace(question, data2),
|
|
1623
1626
|
onInput,
|
|
@@ -1661,6 +1664,7 @@ var Novely = (() => {
|
|
|
1661
1664
|
if (DEV && string.length === 0) {
|
|
1662
1665
|
throw new Error(`Action Text was called with empty string or array`);
|
|
1663
1666
|
}
|
|
1667
|
+
ctx.clearAction("text");
|
|
1664
1668
|
ctx.text(string, forward);
|
|
1665
1669
|
},
|
|
1666
1670
|
exit({ ctx, data: data2 }) {
|