@novely/core 0.33.0-beta.0 → 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 +25 -1
- package/dist/index.global.js +46 -32
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +48 -32
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -51,6 +51,36 @@ var PRELOADED_ASSETS = /* @__PURE__ */ new Set();
|
|
|
51
51
|
|
|
52
52
|
// src/utils.ts
|
|
53
53
|
import { DEV } from "esm-env";
|
|
54
|
+
|
|
55
|
+
// ../../node_modules/.pnpm/klona@2.0.6/node_modules/klona/json/index.mjs
|
|
56
|
+
function klona(val) {
|
|
57
|
+
var k, out, tmp;
|
|
58
|
+
if (Array.isArray(val)) {
|
|
59
|
+
out = Array(k = val.length);
|
|
60
|
+
while (k--)
|
|
61
|
+
out[k] = (tmp = val[k]) && typeof tmp === "object" ? klona(tmp) : tmp;
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
if (Object.prototype.toString.call(val) === "[object Object]") {
|
|
65
|
+
out = {};
|
|
66
|
+
for (k in val) {
|
|
67
|
+
if (k === "__proto__") {
|
|
68
|
+
Object.defineProperty(out, k, {
|
|
69
|
+
value: klona(val[k]),
|
|
70
|
+
configurable: true,
|
|
71
|
+
enumerable: true,
|
|
72
|
+
writable: true
|
|
73
|
+
});
|
|
74
|
+
} else {
|
|
75
|
+
out[k] = (tmp = val[k]) && typeof tmp === "object" ? klona(tmp) : tmp;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
return val;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// src/utils.ts
|
|
54
84
|
var matchAction = ({ getContext, push, forward }, values) => {
|
|
55
85
|
return (action, props, { ctx, data }) => {
|
|
56
86
|
const context = typeof ctx === "string" ? getContext(ctx) : ctx;
|
|
@@ -521,7 +551,7 @@ var exitPath = ({ path, refer, onExitImpossible }) => {
|
|
|
521
551
|
if (isExitImpossible(path)) {
|
|
522
552
|
const referred = refer(path);
|
|
523
553
|
if (isAction(referred) && isSkippedDuringRestore(referred[0])) {
|
|
524
|
-
onExitImpossible();
|
|
554
|
+
onExitImpossible?.();
|
|
525
555
|
}
|
|
526
556
|
wasExitImpossible = true;
|
|
527
557
|
return {
|
|
@@ -664,34 +694,6 @@ var deepmerge = (target, source) => {
|
|
|
664
694
|
}
|
|
665
695
|
};
|
|
666
696
|
|
|
667
|
-
// ../../node_modules/.pnpm/klona@2.0.6/node_modules/klona/json/index.mjs
|
|
668
|
-
function klona(val) {
|
|
669
|
-
var k, out, tmp;
|
|
670
|
-
if (Array.isArray(val)) {
|
|
671
|
-
out = Array(k = val.length);
|
|
672
|
-
while (k--)
|
|
673
|
-
out[k] = (tmp = val[k]) && typeof tmp === "object" ? klona(tmp) : tmp;
|
|
674
|
-
return out;
|
|
675
|
-
}
|
|
676
|
-
if (Object.prototype.toString.call(val) === "[object Object]") {
|
|
677
|
-
out = {};
|
|
678
|
-
for (k in val) {
|
|
679
|
-
if (k === "__proto__") {
|
|
680
|
-
Object.defineProperty(out, k, {
|
|
681
|
-
value: klona(val[k]),
|
|
682
|
-
configurable: true,
|
|
683
|
-
enumerable: true,
|
|
684
|
-
writable: true
|
|
685
|
-
});
|
|
686
|
-
} else {
|
|
687
|
-
out[k] = (tmp = val[k]) && typeof tmp === "object" ? klona(tmp) : tmp;
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
return out;
|
|
691
|
-
}
|
|
692
|
-
return val;
|
|
693
|
-
}
|
|
694
|
-
|
|
695
697
|
// src/translation.ts
|
|
696
698
|
var RGX = /{{(.*?)}}/g;
|
|
697
699
|
var split = (input, delimeters) => {
|
|
@@ -1214,7 +1216,7 @@ var novely = ({
|
|
|
1214
1216
|
const path = stack.value[0];
|
|
1215
1217
|
nextPath(path);
|
|
1216
1218
|
};
|
|
1217
|
-
const
|
|
1219
|
+
const matchActionOptions = {
|
|
1218
1220
|
getContext: renderer.getContext,
|
|
1219
1221
|
push(ctx) {
|
|
1220
1222
|
if (ctx.meta.restoring)
|
|
@@ -1225,12 +1227,12 @@ var novely = ({
|
|
|
1225
1227
|
forward(ctx) {
|
|
1226
1228
|
if (!ctx.meta.preview)
|
|
1227
1229
|
enmemory(ctx);
|
|
1228
|
-
|
|
1230
|
+
matchActionOptions.push(ctx);
|
|
1229
1231
|
if (!ctx.meta.preview)
|
|
1230
1232
|
interactivity(true);
|
|
1231
1233
|
}
|
|
1232
1234
|
};
|
|
1233
|
-
const match = matchAction(
|
|
1235
|
+
const match = matchAction(matchActionOptions, {
|
|
1234
1236
|
wait({ ctx, push }, [time]) {
|
|
1235
1237
|
if (ctx.meta.restoring)
|
|
1236
1238
|
return;
|
|
@@ -1312,6 +1314,7 @@ var novely = ({
|
|
|
1312
1314
|
}
|
|
1313
1315
|
return c || "";
|
|
1314
1316
|
})();
|
|
1317
|
+
ctx.clearAction("dialog");
|
|
1315
1318
|
ctx.dialog(
|
|
1316
1319
|
templateReplace(content, data2),
|
|
1317
1320
|
templateReplace(name, data2),
|
|
@@ -1362,6 +1365,7 @@ var novely = ({
|
|
|
1362
1365
|
if (DEV2 && transformedChoices.length === 0) {
|
|
1363
1366
|
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]`);
|
|
1364
1367
|
}
|
|
1368
|
+
ctx.clearAction("choice");
|
|
1365
1369
|
ctx.choices(templateReplace(question, data2), transformedChoices, (selected) => {
|
|
1366
1370
|
if (!ctx.meta.preview) {
|
|
1367
1371
|
enmemory(ctx);
|
|
@@ -1425,6 +1429,7 @@ var novely = ({
|
|
|
1425
1429
|
exit(true, false);
|
|
1426
1430
|
},
|
|
1427
1431
|
input({ ctx, data: data2, forward }, [question, onInput, setup]) {
|
|
1432
|
+
ctx.clearAction("input");
|
|
1428
1433
|
ctx.input(
|
|
1429
1434
|
templateReplace(question, data2),
|
|
1430
1435
|
onInput,
|
|
@@ -1468,6 +1473,7 @@ var novely = ({
|
|
|
1468
1473
|
if (DEV2 && string.length === 0) {
|
|
1469
1474
|
throw new Error(`Action Text was called with empty string or array`);
|
|
1470
1475
|
}
|
|
1476
|
+
ctx.clearAction("text");
|
|
1471
1477
|
ctx.text(string, forward);
|
|
1472
1478
|
},
|
|
1473
1479
|
exit({ ctx, data: data2 }) {
|
|
@@ -1665,6 +1671,15 @@ var novely = ({
|
|
|
1665
1671
|
};
|
|
1666
1672
|
};
|
|
1667
1673
|
|
|
1674
|
+
// src/extend-actions.ts
|
|
1675
|
+
var extendAction = (base, extension) => {
|
|
1676
|
+
return new Proxy({}, {
|
|
1677
|
+
get(_, key, receiver) {
|
|
1678
|
+
return Reflect.get(key in extension ? extension : base, key, receiver);
|
|
1679
|
+
}
|
|
1680
|
+
});
|
|
1681
|
+
};
|
|
1682
|
+
|
|
1668
1683
|
// src/translations.ts
|
|
1669
1684
|
var RU = {
|
|
1670
1685
|
NewGame: "\u041D\u043E\u0432\u0430\u044F \u0438\u0433\u0440\u0430",
|
|
@@ -1815,6 +1830,7 @@ export {
|
|
|
1815
1830
|
JP,
|
|
1816
1831
|
KK,
|
|
1817
1832
|
RU,
|
|
1833
|
+
extendAction,
|
|
1818
1834
|
localStorageStorage,
|
|
1819
1835
|
novely
|
|
1820
1836
|
};
|