@novely/core 0.33.3 → 0.34.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 +37 -3
- package/dist/index.global.js +25 -12
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +25 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -532,13 +532,46 @@ type CustomHandlerFunctionParameters<L extends string, S extends State> = {
|
|
|
532
532
|
lang: L;
|
|
533
533
|
};
|
|
534
534
|
type CustomHandlerFunction<L extends string, S extends State> = (parameters: CustomHandlerFunctionParameters<L, S>) => Thenable<void>;
|
|
535
|
-
type
|
|
535
|
+
type CustomHandlerCalling = {
|
|
536
|
+
/**
|
|
537
|
+
* Call only the last custom action of this type or not. Does not affect other custom actions
|
|
538
|
+
* @example
|
|
539
|
+
* ```ts
|
|
540
|
+
* ['custom', customSomething1]
|
|
541
|
+
* ['custom', customSomething1]
|
|
542
|
+
* ['custom', customSomething1] <-- Run only that
|
|
543
|
+
* ```
|
|
544
|
+
*/
|
|
536
545
|
callOnlyLatest?: boolean;
|
|
546
|
+
/**
|
|
547
|
+
* Manually check should be skipped or not during restore
|
|
548
|
+
* @param getNext Function which will return next actions in queue
|
|
549
|
+
*/
|
|
550
|
+
skipOnRestore?: (getNext: () => Exclude<ValidAction, ValidAction[]>[]) => boolean;
|
|
551
|
+
};
|
|
552
|
+
type CustomHandlerInfo = CustomHandlerCalling & {
|
|
553
|
+
/**
|
|
554
|
+
* When true interacting with it will be saved in history
|
|
555
|
+
*/
|
|
537
556
|
requireUserAction?: boolean;
|
|
557
|
+
/**
|
|
558
|
+
* When player is going back we clear every custom action. But we can ignore clearing that.
|
|
559
|
+
*/
|
|
538
560
|
skipClearOnGoingBack?: boolean;
|
|
561
|
+
/**
|
|
562
|
+
* Id by which we will determine what action is which
|
|
563
|
+
*
|
|
564
|
+
* It IS recommended to pass this property as it will speed up that check and make it more reliable
|
|
565
|
+
*/
|
|
539
566
|
id?: string | symbol;
|
|
567
|
+
/**
|
|
568
|
+
* Key by which we will save the data in the `get` function provided to custom action.
|
|
569
|
+
*
|
|
570
|
+
* It can be a name of action or more specific thing. In example for custom `showCharacter` it may be `show-character-${character}
|
|
571
|
+
*/
|
|
540
572
|
key: string;
|
|
541
573
|
};
|
|
574
|
+
type CustomHandler<L extends string = string, S extends State = State> = CustomHandlerFunction<L, S> & CustomHandlerInfo;
|
|
542
575
|
interface ActionInputOnInputMeta<L extends string, S extends State> {
|
|
543
576
|
/**
|
|
544
577
|
* Input Element itself
|
|
@@ -594,7 +627,8 @@ type ChoiceCheckFunctionProps<L extends string, S extends State> = {
|
|
|
594
627
|
type ChoiceCheckFunction<L extends string, S extends State> = (props: ChoiceCheckFunctionProps<L, S>) => boolean;
|
|
595
628
|
type ConditionCheckFunction<S extends State, R extends string | true | false> = (state: S) => R;
|
|
596
629
|
type FunctionAction<L extends string, S extends State> = (props: FunctionActionProps<L, S>) => Thenable<void>;
|
|
597
|
-
type
|
|
630
|
+
type ActionInputSetupCleanup = () => void;
|
|
631
|
+
type ActionInputSetup = (input: HTMLInputElement) => ActionInputSetupCleanup | void;
|
|
598
632
|
type BackgroundImage = Partial<Record<'portrait' | 'landscape' | 'all', string>> & Record<string, string>;
|
|
599
633
|
type VoiceAction<L extends Lang> = (params: string | Partial<Record<L, string>>) => ValidAction;
|
|
600
634
|
type ActionProxy<Characters extends Record<string, Character>, Languages extends Lang, S extends State> = {
|
|
@@ -765,4 +799,4 @@ declare const novely: <$Language extends string, $Characters extends Record<stri
|
|
|
765
799
|
*/
|
|
766
800
|
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>>;
|
|
767
801
|
|
|
768
|
-
export { type ActionInputOnInputMeta, type ActionInputSetup, type ActionProxy, type AllowedContent, type AudioHandle, type BackgroundImage, type BaseTranslationStrings, type Character, type CharacterHandle, type ConditionParams, type Context, type CoreData, type CustomHandler, type CustomHandlerFunctionGetFn, type CustomHandlerFunctionParameters, type CustomHandlerGetResult, type CustomHandlerGetResultDataFunction, type Data, type DeepPartial, type DefaultActionProxy, EN, type Emotions, 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 };
|
|
802
|
+
export { type ActionInputOnInputMeta, type ActionInputSetup, type ActionInputSetupCleanup, type ActionProxy, type AllowedContent, type AudioHandle, type BackgroundImage, type BaseTranslationStrings, type Character, type CharacterHandle, type ConditionParams, type Context, type CoreData, type CustomHandler, type CustomHandlerFunctionGetFn, type CustomHandlerFunctionParameters, type CustomHandlerGetResult, type CustomHandlerGetResultDataFunction, type Data, type DeepPartial, type DefaultActionProxy, EN, type Emotions, 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 };
|
package/dist/index.global.js
CHANGED
|
@@ -496,18 +496,31 @@ var Novely = (() => {
|
|
|
496
496
|
}
|
|
497
497
|
keep.add(action);
|
|
498
498
|
if (action === "function" || action === "custom") {
|
|
499
|
-
if (action === "custom"
|
|
500
|
-
const
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
499
|
+
if (action === "custom") {
|
|
500
|
+
const fn = params[0];
|
|
501
|
+
if ("callOnlyLatest" in fn && fn.callOnlyLatest) {
|
|
502
|
+
const notLatest = next(i).some(([, func]) => {
|
|
503
|
+
if (!isFunction(func))
|
|
504
|
+
return false;
|
|
505
|
+
const c0 = func;
|
|
506
|
+
const c1 = fn;
|
|
507
|
+
const isIdenticalID = Boolean(c0.id && c1.id && c0.id === c1.id);
|
|
508
|
+
const isIdenticalByReference = c0 === c1;
|
|
509
|
+
return isIdenticalID || isIdenticalByReference || str(c0) === str(c1);
|
|
510
|
+
});
|
|
511
|
+
if (notLatest)
|
|
512
|
+
continue;
|
|
513
|
+
} else if ("skipOnRestore" in fn && fn.skipOnRestore) {
|
|
514
|
+
let getNext = () => {
|
|
515
|
+
const nextActions = next(i);
|
|
516
|
+
getNext = () => {
|
|
517
|
+
return nextActions;
|
|
518
|
+
};
|
|
519
|
+
return nextActions;
|
|
520
|
+
};
|
|
521
|
+
if (fn.skipOnRestore(getNext))
|
|
522
|
+
continue;
|
|
523
|
+
}
|
|
511
524
|
}
|
|
512
525
|
processedQueue.push(item);
|
|
513
526
|
} else if (action === "showCharacter" || action === "playSound" || action === "playMusic" || action === "voice") {
|