@novely/core 0.33.0-beta.1 → 0.33.0
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 +43 -33
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +45 -33
- 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 that should not be cleared
|
|
101
|
+
*/
|
|
102
|
+
clearBlockingActions: (preserve: 'dialog' | 'choice' | 'input' | 'text' | undefined) => 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) => {
|
|
@@ -1274,8 +1274,11 @@ var Novely = (() => {
|
|
|
1274
1274
|
data: latest[1]
|
|
1275
1275
|
});
|
|
1276
1276
|
});
|
|
1277
|
-
|
|
1277
|
+
if (!context.meta.goingBack) {
|
|
1278
|
+
context.meta.restoring = false;
|
|
1279
|
+
}
|
|
1278
1280
|
render(context);
|
|
1281
|
+
context.meta.restoring = context.meta.goingBack = false;
|
|
1279
1282
|
};
|
|
1280
1283
|
const refer = createReferFunction(story);
|
|
1281
1284
|
const exit = (force = false, saving = true) => {
|
|
@@ -1407,7 +1410,7 @@ var Novely = (() => {
|
|
|
1407
1410
|
const path = stack.value[0];
|
|
1408
1411
|
nextPath(path);
|
|
1409
1412
|
};
|
|
1410
|
-
const
|
|
1413
|
+
const matchActionOptions = {
|
|
1411
1414
|
getContext: renderer.getContext,
|
|
1412
1415
|
push(ctx) {
|
|
1413
1416
|
if (ctx.meta.restoring)
|
|
@@ -1418,12 +1421,12 @@ var Novely = (() => {
|
|
|
1418
1421
|
forward(ctx) {
|
|
1419
1422
|
if (!ctx.meta.preview)
|
|
1420
1423
|
enmemory(ctx);
|
|
1421
|
-
|
|
1424
|
+
matchActionOptions.push(ctx);
|
|
1422
1425
|
if (!ctx.meta.preview)
|
|
1423
1426
|
interactivity(true);
|
|
1424
1427
|
}
|
|
1425
1428
|
};
|
|
1426
|
-
const match = matchAction(
|
|
1429
|
+
const match = matchAction(matchActionOptions, {
|
|
1427
1430
|
wait({ ctx, push }, [time]) {
|
|
1428
1431
|
if (ctx.meta.restoring)
|
|
1429
1432
|
return;
|
|
@@ -1505,6 +1508,7 @@ var Novely = (() => {
|
|
|
1505
1508
|
}
|
|
1506
1509
|
return c || "";
|
|
1507
1510
|
})();
|
|
1511
|
+
ctx.clearBlockingActions("dialog");
|
|
1508
1512
|
ctx.dialog(
|
|
1509
1513
|
templateReplace(content, data2),
|
|
1510
1514
|
templateReplace(name, data2),
|
|
@@ -1555,6 +1559,7 @@ var Novely = (() => {
|
|
|
1555
1559
|
if (DEV && transformedChoices.length === 0) {
|
|
1556
1560
|
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
1561
|
}
|
|
1562
|
+
ctx.clearBlockingActions("choice");
|
|
1558
1563
|
ctx.choices(templateReplace(question, data2), transformedChoices, (selected) => {
|
|
1559
1564
|
if (!ctx.meta.preview) {
|
|
1560
1565
|
enmemory(ctx);
|
|
@@ -1618,6 +1623,7 @@ var Novely = (() => {
|
|
|
1618
1623
|
exit(true, false);
|
|
1619
1624
|
},
|
|
1620
1625
|
input({ ctx, data: data2, forward }, [question, onInput, setup]) {
|
|
1626
|
+
ctx.clearBlockingActions("input");
|
|
1621
1627
|
ctx.input(
|
|
1622
1628
|
templateReplace(question, data2),
|
|
1623
1629
|
onInput,
|
|
@@ -1626,6 +1632,9 @@ var Novely = (() => {
|
|
|
1626
1632
|
);
|
|
1627
1633
|
},
|
|
1628
1634
|
custom({ ctx, push }, [handler]) {
|
|
1635
|
+
if (handler.requireUserAction) {
|
|
1636
|
+
ctx.clearBlockingActions(void 0);
|
|
1637
|
+
}
|
|
1629
1638
|
const result = ctx.custom(handler, () => {
|
|
1630
1639
|
if (ctx.meta.restoring)
|
|
1631
1640
|
return;
|
|
@@ -1661,6 +1670,7 @@ var Novely = (() => {
|
|
|
1661
1670
|
if (DEV && string.length === 0) {
|
|
1662
1671
|
throw new Error(`Action Text was called with empty string or array`);
|
|
1663
1672
|
}
|
|
1673
|
+
ctx.clearBlockingActions("text");
|
|
1664
1674
|
ctx.text(string, forward);
|
|
1665
1675
|
},
|
|
1666
1676
|
exit({ ctx, data: data2 }) {
|