@novely/core 0.37.0-beta.0 → 0.37.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 +8 -2
- package/dist/index.global.js +33 -17
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +33 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -198,6 +198,12 @@ type Renderer = {
|
|
|
198
198
|
getContext: (context: string) => Context;
|
|
199
199
|
removeContext: (context: string) => void;
|
|
200
200
|
};
|
|
201
|
+
type RendererInitPreviewReturn = {
|
|
202
|
+
/**
|
|
203
|
+
* Assets that was used in game preview
|
|
204
|
+
*/
|
|
205
|
+
assets: string[];
|
|
206
|
+
};
|
|
201
207
|
type RendererInit<$Language extends Lang, $Characters extends Record<string, Character<$Language>>> = {
|
|
202
208
|
characters: $Characters;
|
|
203
209
|
characterAssetSizes: CharacterAssetSizes<$Characters>;
|
|
@@ -224,7 +230,7 @@ type RendererInit<$Language extends Lang, $Characters extends Record<string, Cha
|
|
|
224
230
|
* There is different context, and the main one which is used for game
|
|
225
231
|
*/
|
|
226
232
|
mainContextKey: string;
|
|
227
|
-
preview: (save: Save<State>, name: string) => Promise<
|
|
233
|
+
preview: (save: Save<State>, name: string) => Promise<RendererInitPreviewReturn>;
|
|
228
234
|
removeContext: (name: string) => void;
|
|
229
235
|
getStateFunction: (context: string) => StateFunction<State>;
|
|
230
236
|
clearCustomAction: (ctx: Context, customAction: CustomHandler) => void;
|
|
@@ -889,4 +895,4 @@ declare const novely: <$Language extends string, $Characters extends Record<stri
|
|
|
889
895
|
*/
|
|
890
896
|
declare const extendAction: <Part0 extends Record<string, (...args: any[]) => ValidAction>, Part1 extends Record<string, (...args: any[]) => ValidAction>>(base: Part0, extension: Part1) => Readonly<Assign<Part0, Part1>>;
|
|
891
897
|
|
|
892
|
-
export { type ActionInputOnInputMeta, type ActionInputSetup, type ActionInputSetupCleanup, type ActionProxy, type AllowedContent, type AudioHandle, type BackgroundImage, type BaseTranslationStrings, type Character, type CharacterHandle, 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 Save, type Stack, type StackHolder, type State, type StateFunction, type Storage, type StorageData, type StorageMeta, type Stored, type Story, type TextContent, type Thenable, type TranslationActions, type TypeEssentials, type TypewriterSpeed, type ValidAction, extendAction, localStorageStorage, novely };
|
|
898
|
+
export { type ActionInputOnInputMeta, type ActionInputSetup, type ActionInputSetupCleanup, type ActionProxy, type AllowedContent, type AudioHandle, type BackgroundImage, type BaseTranslationStrings, type Character, type CharacterHandle, 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 Storage, type StorageData, type StorageMeta, type Stored, type Story, type TextContent, type Thenable, type TranslationActions, type TypeEssentials, type TypewriterSpeed, type ValidAction, extendAction, localStorageStorage, novely };
|
package/dist/index.global.js
CHANGED
|
@@ -212,6 +212,7 @@ var Novely = (() => {
|
|
|
212
212
|
var STACK_MAP = /* @__PURE__ */ new Map();
|
|
213
213
|
var CUSTOM_ACTION_MAP = /* @__PURE__ */ new Map();
|
|
214
214
|
var PRELOADED_ASSETS = /* @__PURE__ */ new Set();
|
|
215
|
+
var RESOURCE_TYPE_CACHE = /* @__PURE__ */ new Map();
|
|
215
216
|
|
|
216
217
|
// ../../node_modules/.pnpm/esm-env@1.0.0/node_modules/esm-env/prod-ssr.js
|
|
217
218
|
var DEV = false;
|
|
@@ -663,24 +664,31 @@ var Novely = (() => {
|
|
|
663
664
|
}
|
|
664
665
|
};
|
|
665
666
|
var getResourseType = async (request, url) => {
|
|
667
|
+
if (RESOURCE_TYPE_CACHE.has(url)) {
|
|
668
|
+
return RESOURCE_TYPE_CACHE.get(url);
|
|
669
|
+
}
|
|
670
|
+
const encache = (value) => {
|
|
671
|
+
RESOURCE_TYPE_CACHE.set(url, value);
|
|
672
|
+
return value;
|
|
673
|
+
};
|
|
666
674
|
if (!isCSSImage(url)) {
|
|
667
|
-
return "other";
|
|
675
|
+
return encache("other");
|
|
668
676
|
}
|
|
669
677
|
const extension = getUrlFileExtension(url);
|
|
670
678
|
if (HOWLER_SUPPORTED_FILE_FORMATS.has(extension)) {
|
|
671
|
-
return "audio";
|
|
679
|
+
return encache("audio");
|
|
672
680
|
}
|
|
673
681
|
if (SUPPORTED_IMAGE_FILE_FORMATS.has(extension)) {
|
|
674
|
-
return "image";
|
|
682
|
+
return encache("image");
|
|
675
683
|
}
|
|
676
684
|
const contentType = await fetchContentType(request, url);
|
|
677
685
|
if (contentType.includes("audio")) {
|
|
678
|
-
return "audio";
|
|
686
|
+
return encache("audio");
|
|
679
687
|
}
|
|
680
688
|
if (contentType.includes("image")) {
|
|
681
|
-
return "image";
|
|
689
|
+
return encache("image");
|
|
682
690
|
}
|
|
683
|
-
return "other";
|
|
691
|
+
return encache("other");
|
|
684
692
|
};
|
|
685
693
|
var capitalize = (str2) => {
|
|
686
694
|
return str2[0].toUpperCase() + str2.slice(1);
|
|
@@ -1215,38 +1223,38 @@ var Novely = (() => {
|
|
|
1215
1223
|
const script = (part) => {
|
|
1216
1224
|
return limitScript(() => scriptBase(part));
|
|
1217
1225
|
};
|
|
1218
|
-
const
|
|
1226
|
+
const assetPreloadingCheck = (action2, props, doAction = assetsToPreloadAdd) => {
|
|
1219
1227
|
if (action2 === "showBackground") {
|
|
1220
1228
|
if (isImageAsset(props[0])) {
|
|
1221
|
-
|
|
1229
|
+
doAction(props[0]);
|
|
1222
1230
|
}
|
|
1223
1231
|
if (props[0] && typeof props[0] === "object") {
|
|
1224
1232
|
for (const value of Object.values(props[0])) {
|
|
1225
1233
|
if (!isImageAsset(value))
|
|
1226
1234
|
continue;
|
|
1227
|
-
|
|
1235
|
+
doAction(value);
|
|
1228
1236
|
}
|
|
1229
1237
|
}
|
|
1230
1238
|
return;
|
|
1231
1239
|
}
|
|
1232
1240
|
if (isAudioAction(action2) && isString(props[0])) {
|
|
1233
|
-
|
|
1241
|
+
doAction(props[0]);
|
|
1234
1242
|
return;
|
|
1235
1243
|
}
|
|
1236
1244
|
if (action2 === "showCharacter" && isString(props[0]) && isString(props[1])) {
|
|
1237
1245
|
const images = characters[props[0]].emotions[props[1]];
|
|
1238
1246
|
if (Array.isArray(images)) {
|
|
1239
1247
|
for (const asset of images) {
|
|
1240
|
-
|
|
1248
|
+
doAction(asset);
|
|
1241
1249
|
}
|
|
1242
1250
|
} else {
|
|
1243
|
-
|
|
1251
|
+
doAction(images);
|
|
1244
1252
|
}
|
|
1245
1253
|
return;
|
|
1246
1254
|
}
|
|
1247
1255
|
if (action2 === "custom" && props[0].assets && props[0].assets.length > 0) {
|
|
1248
1256
|
for (const asset of props[0].assets) {
|
|
1249
|
-
|
|
1257
|
+
doAction(asset);
|
|
1250
1258
|
}
|
|
1251
1259
|
}
|
|
1252
1260
|
};
|
|
@@ -1257,7 +1265,7 @@ var Novely = (() => {
|
|
|
1257
1265
|
}
|
|
1258
1266
|
return (...props) => {
|
|
1259
1267
|
if (preloadAssets === "blocking") {
|
|
1260
|
-
|
|
1268
|
+
assetPreloadingCheck(action2, props);
|
|
1261
1269
|
}
|
|
1262
1270
|
return [action2, ...props];
|
|
1263
1271
|
};
|
|
@@ -1508,8 +1516,11 @@ var Novely = (() => {
|
|
|
1508
1516
|
return translation[lang].internal[key];
|
|
1509
1517
|
};
|
|
1510
1518
|
const preview = async (save2, name) => {
|
|
1511
|
-
if (isEmpty(story))
|
|
1512
|
-
return
|
|
1519
|
+
if (isEmpty(story)) {
|
|
1520
|
+
return Promise.resolve({
|
|
1521
|
+
assets: []
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1513
1524
|
const [path, data2] = save2;
|
|
1514
1525
|
const { queue } = getActionsFromPath(story, path, true);
|
|
1515
1526
|
const ctx = renderer.getContext(name);
|
|
@@ -1519,6 +1530,7 @@ var Novely = (() => {
|
|
|
1519
1530
|
skip: EMPTY_SET
|
|
1520
1531
|
});
|
|
1521
1532
|
useStack(ctx).push(klona(save2));
|
|
1533
|
+
const assets = [];
|
|
1522
1534
|
await processor.run(([action2, ...props]) => {
|
|
1523
1535
|
if (isAudioAction(action2))
|
|
1524
1536
|
return;
|
|
@@ -1526,11 +1538,15 @@ var Novely = (() => {
|
|
|
1526
1538
|
return;
|
|
1527
1539
|
if (action2 === "end")
|
|
1528
1540
|
return;
|
|
1541
|
+
assetPreloadingCheck(action2, props, assets.push.bind(assets));
|
|
1529
1542
|
return match(action2, props, {
|
|
1530
1543
|
ctx,
|
|
1531
1544
|
data: data2
|
|
1532
1545
|
});
|
|
1533
1546
|
});
|
|
1547
|
+
return {
|
|
1548
|
+
assets
|
|
1549
|
+
};
|
|
1534
1550
|
};
|
|
1535
1551
|
const removeContext = (name) => {
|
|
1536
1552
|
STACK_MAP.delete(name);
|
|
@@ -1627,7 +1643,7 @@ var Novely = (() => {
|
|
|
1627
1643
|
refer
|
|
1628
1644
|
});
|
|
1629
1645
|
for (const [action3, ...props2] of collection) {
|
|
1630
|
-
|
|
1646
|
+
assetPreloadingCheck(action3, props2);
|
|
1631
1647
|
}
|
|
1632
1648
|
const { preloadAudioBlocking, preloadImageBlocking } = renderer.misc;
|
|
1633
1649
|
ASSETS_TO_PRELOAD.forEach(async (asset) => {
|