@novely/core 0.40.2 → 0.40.3
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 +12 -8
- package/dist/index.global.js +55 -29
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +55 -29
- package/dist/index.js.map +1 -1
- package/license +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
type LocalStorageStorageSettings = {
|
|
2
2
|
key: string;
|
|
3
|
-
}
|
|
4
|
-
|
|
3
|
+
};
|
|
4
|
+
type NovelyStorage = {
|
|
5
5
|
get: () => Promise<StorageData>;
|
|
6
6
|
set: (data: StorageData) => Promise<void>;
|
|
7
|
-
}
|
|
8
|
-
declare const localStorageStorage: (options: LocalStorageStorageSettings) =>
|
|
7
|
+
};
|
|
8
|
+
declare const localStorageStorage: (options: LocalStorageStorageSettings) => NovelyStorage;
|
|
9
9
|
|
|
10
10
|
type PluralType = Intl.LDMLPluralRule;
|
|
11
11
|
type Pluralization = Partial<Record<PluralType, string>>;
|
|
@@ -406,7 +406,7 @@ interface NovelyInit<$Language extends Lang, $Characters extends Record<string,
|
|
|
406
406
|
* An object that provides access to the game's storage system.
|
|
407
407
|
* @default localStorage // at key `novely-game-storage`
|
|
408
408
|
*/
|
|
409
|
-
storage?:
|
|
409
|
+
storage?: NovelyStorage;
|
|
410
410
|
/**
|
|
411
411
|
* Delay loading data until Promise is resolved
|
|
412
412
|
*/
|
|
@@ -858,7 +858,7 @@ declare const novely: <$Language extends string, $Characters extends Record<stri
|
|
|
858
858
|
*/
|
|
859
859
|
typeEssentials: TypeEssentials<$Language, $State, $Data, $Characters>;
|
|
860
860
|
/**
|
|
861
|
-
* Replaces content inside {{braces}}
|
|
861
|
+
* Replaces content inside {{braces}} using global data
|
|
862
862
|
* @example
|
|
863
863
|
* ```ts
|
|
864
864
|
* data({ name: 'Alexei' })
|
|
@@ -870,6 +870,10 @@ declare const novely: <$Language extends string, $Characters extends Record<stri
|
|
|
870
870
|
* ```
|
|
871
871
|
*/
|
|
872
872
|
templateReplace(content: TextContent<$Language, $Data>): string;
|
|
873
|
+
/**
|
|
874
|
+
* Same as `templateReplace` but uses state and requires explicitly providing it
|
|
875
|
+
*/
|
|
876
|
+
templateReplaceState(content: TextContent<$Language, $State>, state: State): string;
|
|
873
877
|
/**
|
|
874
878
|
* Cancel data loading, hide UI, ignore page change events
|
|
875
879
|
* Data updates still will work in case Novely already was loaded
|
|
@@ -944,4 +948,4 @@ declare const extendAction: <Part0 extends Record<string, (...args: any[]) => Va
|
|
|
944
948
|
*/
|
|
945
949
|
declare const asset: (...variants: string[]) => NovelyAsset;
|
|
946
950
|
|
|
947
|
-
export { type ActionInputOnInputMeta, type ActionInputSetup, type ActionInputSetupCleanup, type ActionProxy, type AllowedContent, type AudioHandle, type BackgroundImage, type BaseTranslationStrings, type Character, type CharacterAssetSizes, type CharacterHandle, type CharactersData, type ChoiceParams, type ConditionParams, type Context, type CoreData, type CustomActionHandle, type CustomHandler, type CustomHandlerFunctionGetFn, type CustomHandlerFunctionParameters, type CustomHandlerGetResult, type CustomHandlerGetResultDataFunction, type Data, type DeepPartial, type DefaultActionProxy, EN, type Emotions, type FunctionParams, type FunctionableValue, type GetActionParameters, type InputHandler, JP, KK, type Lang, type NovelyInit, type NovelyScreen, type Path, type PluralType, type Pluralization, RU, type Renderer, type RendererInit, type RendererInitPreviewReturn, type Save, type Stack, type StackHolder, type State, type StateFunction, type
|
|
951
|
+
export { type ActionInputOnInputMeta, type ActionInputSetup, type ActionInputSetupCleanup, type ActionProxy, type AllowedContent, type AudioHandle, type BackgroundImage, type BaseTranslationStrings, type Character, type CharacterAssetSizes, type CharacterHandle, type CharactersData, type ChoiceParams, type ConditionParams, type Context, type CoreData, type CustomActionHandle, type CustomHandler, type CustomHandlerFunctionGetFn, type CustomHandlerFunctionParameters, type CustomHandlerGetResult, type CustomHandlerGetResultDataFunction, type Data, type DeepPartial, type DefaultActionProxy, EN, type Emotions, type FunctionParams, type FunctionableValue, type GetActionParameters, type InputHandler, JP, KK, type Lang, type NovelyInit, type NovelyScreen, type NovelyStorage, type Path, type PluralType, type Pluralization, RU, type Renderer, type RendererInit, type RendererInitPreviewReturn, type Save, type Stack, type StackHolder, type State, type StateFunction, type StorageData, type StorageMeta, type Stored, type Story, type TextContent, type Thenable, type TranslationActions, type TypeEssentials, type TypewriterSpeed, type ValidAction, asset, extendAction, localStorageStorage, novely };
|
package/dist/index.global.js
CHANGED
|
@@ -87,31 +87,51 @@ var Novely = (() => {
|
|
|
87
87
|
// ../../node_modules/.pnpm/esm-env@1.0.0/node_modules/esm-env/prod-ssr.js
|
|
88
88
|
var DEV = false;
|
|
89
89
|
|
|
90
|
-
// ../../node_modules/.pnpm/klona@2.0.6/node_modules/klona/
|
|
91
|
-
function
|
|
92
|
-
|
|
93
|
-
if (
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
90
|
+
// ../../node_modules/.pnpm/klona@2.0.6/node_modules/klona/full/index.mjs
|
|
91
|
+
function set(obj, key, val) {
|
|
92
|
+
if (typeof val.value === "object") val.value = klona(val.value);
|
|
93
|
+
if (!val.enumerable || val.get || val.set || !val.configurable || !val.writable || key === "__proto__") {
|
|
94
|
+
Object.defineProperty(obj, key, val);
|
|
95
|
+
} else obj[key] = val.value;
|
|
96
|
+
}
|
|
97
|
+
function klona(x) {
|
|
98
|
+
if (typeof x !== "object") return x;
|
|
99
|
+
var i = 0, k, list, tmp, str2 = Object.prototype.toString.call(x);
|
|
100
|
+
if (str2 === "[object Object]") {
|
|
101
|
+
tmp = Object.create(x.__proto__ || null);
|
|
102
|
+
} else if (str2 === "[object Array]") {
|
|
103
|
+
tmp = Array(x.length);
|
|
104
|
+
} else if (str2 === "[object Set]") {
|
|
105
|
+
tmp = /* @__PURE__ */ new Set();
|
|
106
|
+
x.forEach(function(val) {
|
|
107
|
+
tmp.add(klona(val));
|
|
108
|
+
});
|
|
109
|
+
} else if (str2 === "[object Map]") {
|
|
110
|
+
tmp = /* @__PURE__ */ new Map();
|
|
111
|
+
x.forEach(function(val, key) {
|
|
112
|
+
tmp.set(klona(key), klona(val));
|
|
113
|
+
});
|
|
114
|
+
} else if (str2 === "[object Date]") {
|
|
115
|
+
tmp = /* @__PURE__ */ new Date(+x);
|
|
116
|
+
} else if (str2 === "[object RegExp]") {
|
|
117
|
+
tmp = new RegExp(x.source, x.flags);
|
|
118
|
+
} else if (str2 === "[object DataView]") {
|
|
119
|
+
tmp = new x.constructor(klona(x.buffer));
|
|
120
|
+
} else if (str2 === "[object ArrayBuffer]") {
|
|
121
|
+
tmp = x.slice(0);
|
|
122
|
+
} else if (str2.slice(-6) === "Array]") {
|
|
123
|
+
tmp = new x.constructor(x);
|
|
97
124
|
}
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
enumerable: true,
|
|
106
|
-
writable: true
|
|
107
|
-
});
|
|
108
|
-
} else {
|
|
109
|
-
out[k] = (tmp = val[k]) && typeof tmp === "object" ? klona(tmp) : tmp;
|
|
110
|
-
}
|
|
125
|
+
if (tmp) {
|
|
126
|
+
for (list = Object.getOwnPropertySymbols(x); i < list.length; i++) {
|
|
127
|
+
set(tmp, list[i], Object.getOwnPropertyDescriptor(x, list[i]));
|
|
128
|
+
}
|
|
129
|
+
for (i = 0, list = Object.getOwnPropertyNames(x); i < list.length; i++) {
|
|
130
|
+
if (Object.hasOwnProperty.call(tmp, k = list[i]) && tmp[k] === x[k]) continue;
|
|
131
|
+
set(tmp, k, Object.getOwnPropertyDescriptor(x, k));
|
|
111
132
|
}
|
|
112
|
-
return out;
|
|
113
133
|
}
|
|
114
|
-
return
|
|
134
|
+
return tmp || x;
|
|
115
135
|
}
|
|
116
136
|
|
|
117
137
|
// ../../node_modules/.pnpm/es-toolkit@1.16.0/node_modules/es-toolkit/dist/function/once.mjs
|
|
@@ -630,8 +650,8 @@ var Novely = (() => {
|
|
|
630
650
|
};
|
|
631
651
|
return useStack;
|
|
632
652
|
};
|
|
633
|
-
var mapSet = (
|
|
634
|
-
return [...
|
|
653
|
+
var mapSet = (set2, fn) => {
|
|
654
|
+
return [...set2].map(fn);
|
|
635
655
|
};
|
|
636
656
|
var isImageAsset = (asset2) => {
|
|
637
657
|
return isString(asset2) && isCSSImage(asset2);
|
|
@@ -939,13 +959,13 @@ var Novely = (() => {
|
|
|
939
959
|
const update = (fn) => {
|
|
940
960
|
push(current = fn(current));
|
|
941
961
|
};
|
|
942
|
-
const
|
|
962
|
+
const set2 = (val) => {
|
|
943
963
|
update(() => val);
|
|
944
964
|
};
|
|
945
965
|
const get = () => {
|
|
946
966
|
return current;
|
|
947
967
|
};
|
|
948
|
-
return { subscribe, update, set, get };
|
|
968
|
+
return { subscribe, update, set: set2, get };
|
|
949
969
|
};
|
|
950
970
|
|
|
951
971
|
// src/translation.ts
|
|
@@ -1537,7 +1557,7 @@ var Novely = (() => {
|
|
|
1537
1557
|
renderer.ui.showScreen("game");
|
|
1538
1558
|
render(context);
|
|
1539
1559
|
};
|
|
1540
|
-
const
|
|
1560
|
+
const set2 = (save2, ctx) => {
|
|
1541
1561
|
const stack = useStack(ctx || MAIN_CONTEXT_KEY);
|
|
1542
1562
|
stack.value = save2;
|
|
1543
1563
|
return restore(save2);
|
|
@@ -1735,7 +1755,7 @@ var Novely = (() => {
|
|
|
1735
1755
|
mainContextKey: MAIN_CONTEXT_KEY,
|
|
1736
1756
|
characters: getCharactersData(characters),
|
|
1737
1757
|
characterAssetSizes,
|
|
1738
|
-
set,
|
|
1758
|
+
set: set2,
|
|
1739
1759
|
restore,
|
|
1740
1760
|
save,
|
|
1741
1761
|
newGame,
|
|
@@ -2244,7 +2264,7 @@ var Novely = (() => {
|
|
|
2244
2264
|
*/
|
|
2245
2265
|
typeEssentials,
|
|
2246
2266
|
/**
|
|
2247
|
-
* Replaces content inside {{braces}}
|
|
2267
|
+
* Replaces content inside {{braces}} using global data
|
|
2248
2268
|
* @example
|
|
2249
2269
|
* ```ts
|
|
2250
2270
|
* data({ name: 'Alexei' })
|
|
@@ -2258,6 +2278,12 @@ var Novely = (() => {
|
|
|
2258
2278
|
templateReplace(content) {
|
|
2259
2279
|
return templateReplace(content);
|
|
2260
2280
|
},
|
|
2281
|
+
/**
|
|
2282
|
+
* Same as `templateReplace` but uses state and requires explicitly providing it
|
|
2283
|
+
*/
|
|
2284
|
+
templateReplaceState(content, state) {
|
|
2285
|
+
return templateReplace(content, state);
|
|
2286
|
+
},
|
|
2261
2287
|
/**
|
|
2262
2288
|
* Cancel data loading, hide UI, ignore page change events
|
|
2263
2289
|
* Data updates still will work in case Novely already was loaded
|