@drincs/pixi-vn 0.3.5 → 0.3.6

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Pixi'VN - Pixi Visual Novel Engine
1
+ # Pixi'VN - PixiJS Visual Novel Engine
2
2
 
3
3
  Pixi'VN is a npm package that provides various features for creating visual novels.
4
4
 
@@ -9,6 +9,14 @@ Pixi'VN is based on [Pixi.js](https://pixijs.com/), a modern 2D rendering engine
9
9
  In addition to managing the Pixi.js "Canvas", Pixi'VN offers the possibility of adding an HTML Element with the same dimensions as the "Canvas" to add interactions with the user.
10
10
  This allows the use of systems such as React, Vue, Angular, etc. to create much more complex interfaces with excellent performance.
11
11
 
12
+ ## Why Pixi'VN?
13
+
14
+ The reason why Pixi'VN was born is that current systems for creating a visual novel are based on dated systems and have many shortcomings.
15
+
16
+ ## Pivi'VN Templates
17
+
18
+ * [Pixi’VN template (React + Vite + MUI joy)](https://github.com/DRincs-Productions/pixi-vn-react-template)
19
+
12
20
  ## Get Started
13
21
 
14
22
  ### Installation
@@ -87,7 +95,3 @@ body {
87
95
  ## Wiki
88
96
 
89
97
  For more information, visit the [Wiki](https://pixivn.readthedocs.io/)
90
-
91
- ## Why Pixi'VN?
92
-
93
- The reason why Pixi'VN was born is that current systems for creating a visual novel are based on dated systems and have many shortcomings.
package/dist/index.d.mts CHANGED
@@ -273,11 +273,11 @@ declare class ChoiceMenuOptionLabel {
273
273
  */
274
274
  constructor(text: string, label: typeof Label, type?: LabelRunModeEnum);
275
275
  }
276
- interface IStoratedChoiceMenuOptionLabel {
276
+ type IStoratedChoiceMenuOptionLabel = {
277
277
  text: string;
278
278
  label: LabelIdType;
279
279
  type: LabelRunModeEnum;
280
- }
280
+ };
281
281
 
282
282
  /**
283
283
  * Munu is a type that contains a list of Label that a player can choose from.
@@ -295,10 +295,12 @@ declare function Pause(duration: number): PauseType;
295
295
  type RepeatType = "Repeat";
296
296
  declare const Repeat: RepeatType;
297
297
 
298
+ type StorageElementPrimaryType = string | number | boolean | undefined | null | StorageElementPrimaryType[];
299
+ type StorageElementInternalType = StorageElementPrimaryType | Record<string | number | symbol, StorageElementPrimaryType> | StorageElementInternalType[];
298
300
  /**
299
301
  * StorageElementType are all the types that can be stored in the storage
300
302
  */
301
- type StorageElementType = string | number | boolean | object | undefined | null;
303
+ type StorageElementType = StorageElementInternalType | Record<string | number | symbol, StorageElementInternalType>;
302
304
 
303
305
  /**
304
306
  * Base class for all dialogue models.
@@ -682,16 +684,33 @@ declare class TickerBase<TArgs extends TickerArgsType> implements ITicker<TArgs>
682
684
  fn(_t: Ticker, _args: TArgs, _tags: string | string[]): void;
683
685
  }
684
686
 
687
+ type TickerFadeAlphaProps = {
688
+ /**
689
+ * The speed of the fade
690
+ */
691
+ speed: number;
692
+ /**
693
+ * The type of the fade
694
+ * @default "hide"
695
+ */
696
+ type?: "hide" | "show";
697
+ /**
698
+ * The limit of the fade
699
+ * @default type === "hide" ? 0 : 1
700
+ */
701
+ limit?: number;
702
+ /**
703
+ * The tag to remove after the fade is done
704
+ */
705
+ tagToRemoveAfter?: string[] | string;
706
+ /**
707
+ * If true, the fade only starts if the canvas element have a texture
708
+ */
709
+ startOnlyIfHaveTexture?: boolean;
710
+ };
711
+
685
712
  /**
686
713
  * A ticker that fades the alpha of the canvas element of the canvas.
687
- * @param args The arguments that are passed to the ticker
688
- * - speed: The speed of the fade
689
- * - type: The type of the fade, default is "hide"
690
- * - limit: The limit of the fade, default is 0 for hide and 1 for show
691
- * - tagToRemoveAfter?: The tag to remove after the fade is done
692
- * - startOnlyIfHaveTexture?: If true, the fade only starts if the canvas element have a texture
693
- * @param duration The duration of the ticker
694
- * @param priority The priority of the ticker
695
714
  * @example
696
715
  * ```typescript
697
716
  * let bunny = addImage("bunny1", "https://pixijs.com/assets/eggHead.png")
@@ -705,13 +724,7 @@ declare class TickerBase<TArgs extends TickerArgsType> implements ITicker<TArgs>
705
724
  * GameWindowManager.addTicker("bunny", ticker)
706
725
  * ```
707
726
  */
708
- declare class TickerFadeAlpha extends TickerBase<{
709
- speed: number;
710
- type?: "hide" | "show";
711
- limit?: number;
712
- tagToRemoveAfter?: string[] | string;
713
- startOnlyIfHaveTexture?: boolean;
714
- }> {
727
+ declare class TickerFadeAlpha extends TickerBase<TickerFadeAlphaProps> {
715
728
  /**
716
729
  * The method that will be called every frame to fade the alpha of the canvas element of the canvas.
717
730
  * @param delta The delta time
@@ -728,114 +741,16 @@ declare class TickerFadeAlpha extends TickerBase<{
728
741
  }
729
742
 
730
743
  type TickerProgrationType = ITickerProgrationLinear | ITickerProgrationExponential;
731
- interface ITickerProgrationLinear {
744
+ type ITickerProgrationLinear = {
732
745
  amt: number;
733
746
  limit?: number;
734
747
  type: "linear";
735
- }
736
- interface ITickerProgrationExponential {
748
+ };
749
+ type ITickerProgrationExponential = {
737
750
  percentage: number;
738
751
  limit?: number;
739
752
  type: "exponential";
740
- }
741
-
742
- /**
743
- * A ticker that rotates the canvas element of the canvas.
744
- * @param args The arguments that are passed to the ticker
745
- * - speed: The speed of the rotation, default is 0.1
746
- * - clockwise: The direction of the rotation, default is true
747
- * - speedProgression: The progression of the speed
748
- * - startOnlyIfHaveTexture?: If true, the rotation only starts if the canvas element have a texture
749
- * @param duration The duration of the ticker
750
- * @param priority The priority of the ticker
751
- * @example
752
- * ```typescript
753
- * let alien = addImage("alien", 'https://pixijs.com/assets/eggHead.png')
754
- * GameWindowManager.addCanvasElement("alien", alien);
755
- * const ticker = new TickerRotate({
756
- * speed: 0.1,
757
- * clockwise: true,
758
- * }),
759
- * GameWindowManager.addTicker("alien", ticker)
760
- */
761
- declare class TickerRotate extends TickerBase<{
762
- speed?: number;
763
- clockwise?: boolean;
764
- speedProgression?: TickerProgrationType;
765
- startOnlyIfHaveTexture?: boolean;
766
- }> {
767
- /**
768
- * The method that will be called every frame to rotate the canvas element of the canvas.
769
- * @param delta The delta time
770
- * @param args The arguments that are passed to the ticker
771
- * @param tags The tags of the canvas element that are connected to this ticker
772
- */
773
- fn(t: Ticker, args: {
774
- speed?: number;
775
- clockwise?: boolean;
776
- speedProgression?: TickerProgrationType;
777
- startOnlyIfHaveTexture?: boolean;
778
- }, tags: string[]): void;
779
- }
780
-
781
- type CanvasElementTagType = string;
782
-
783
- /**
784
- * Is a decorator that register a canvas element in the game.
785
- * @param name Name of the canvas element, by default it will use the class name. If the name is already registered, it will show a warning
786
- * @returns
787
- */
788
- declare function canvasElementDecorator(name?: CanvasElementTagType): (target: typeof CanvasBase<any>) => void;
789
-
790
- /**
791
- * Is a function that saves the character. If the character already exists, it will be overwritten.
792
- * @param character is the character to save
793
- * @returns
794
- * @example
795
- * ```typescript
796
- * export const liam = new CharacterBaseModel('liam', { name: 'Liam'});
797
- * export const alice = new CharacterBaseModel('alice', { name: 'Alice'});
798
- * saveCharacter([liam, alice]);
799
- * ```
800
- */
801
- declare function saveCharacter<T extends CharacterBaseModel = CharacterBaseModel>(character: T | T[]): void;
802
- /**
803
- * is a function that returns the character by the id
804
- * @param id is the id of the character
805
- * @returns the character
806
- * @example
807
- * ```typescript
808
- * const liam = getCharacterById('liam');
809
- * ```
810
- */
811
- declare function getCharacterById<T extends CharacterBaseModel>(id: string): T | undefined;
812
- /**
813
- * is a function that returns all characters
814
- * @returns all characters
815
- * @example
816
- * ```typescript
817
- * const allCharacters = getAllCharacters();
818
- * ```
819
- */
820
- declare function getAllCharacters<T extends CharacterBaseModel>(): T[];
821
-
822
- /**
823
- * Is a decorator that register a event in the game.
824
- * Is a required decorator for use the event in the game.
825
- * Thanks to this decoration the game has the possibility of updating the events to the latest modification and saving the game.
826
- * @param name is th identifier of the event, by default is the name of the class
827
- * @returns
828
- */
829
- declare function eventDecorator(name?: EventIdType): (target: typeof CanvasEvent<any>) => void;
830
-
831
- /**
832
- * Is a decorator that register a label in the game.
833
- * Is a required decorator for use the label in the game.
834
- * Thanks to this decoration the game has the possibility of updating the labels to the latest modification and saving the game.
835
- * @param name is th identifier of the label, by default is the name of the class
836
- * @returns
837
- */
838
- declare function labelDecorator(name?: LabelIdType): (target: typeof Label) => void;
753
+ };
839
754
 
840
755
  /**
841
756
  * is a string that represents a ticker id.
@@ -843,15 +758,6 @@ declare function labelDecorator(name?: LabelIdType): (target: typeof Label) => v
843
758
  */
844
759
  type TickerIdType = string;
845
760
 
846
- /**
847
- * Is a decorator that register a ticker in the game.
848
- * Is a required decorator for use the ticker in the game.
849
- * Thanks to this decoration the game has the possibility of updating the tickers to the latest modification and saving the game.
850
- * @param name is th identifier of the label, by default is the name of the class
851
- * @returns
852
- */
853
- declare function tickerDecorator(name?: TickerIdType): (target: typeof TickerBase<any>) => void;
854
-
855
761
  /**
856
762
  * IClassWithArgsHistory is a class that contains the name of a class and the arguments that were used to create it.
857
763
  */
@@ -1007,6 +913,122 @@ interface ITickersSteps {
1007
913
  steps: (ITickersStep<any> | RepeatType | PauseType)[];
1008
914
  }
1009
915
 
916
+ type TickerRotateProps = {
917
+ /**
918
+ * The speed of the rotation
919
+ * @default 0.1
920
+ */
921
+ speed?: number;
922
+ /**
923
+ * The direction of the rotation
924
+ * @default true
925
+ */
926
+ clockwise?: boolean;
927
+ /**
928
+ * The progression of the speed
929
+ */
930
+ speedProgression?: TickerProgrationType;
931
+ /**
932
+ * If true, the rotation only starts if the canvas element have a texture
933
+ */
934
+ startOnlyIfHaveTexture?: boolean;
935
+ };
936
+
937
+ /**
938
+ * A ticker that rotates the canvas element of the canvas.
939
+ * @example
940
+ * ```typescript
941
+ * let alien = addImage("alien", 'https://pixijs.com/assets/eggHead.png')
942
+ * GameWindowManager.addCanvasElement("alien", alien);
943
+ * const ticker = new TickerRotate({
944
+ * speed: 0.1,
945
+ * clockwise: true,
946
+ * }),
947
+ * GameWindowManager.addTicker("alien", ticker)
948
+ */
949
+ declare class TickerRotate extends TickerBase<TickerRotateProps> {
950
+ /**
951
+ * The method that will be called every frame to rotate the canvas element of the canvas.
952
+ * @param delta The delta time
953
+ * @param args The arguments that are passed to the ticker
954
+ * @param tags The tags of the canvas element that are connected to this ticker
955
+ */
956
+ fn(t: Ticker, args: {
957
+ speed?: number;
958
+ clockwise?: boolean;
959
+ speedProgression?: TickerProgrationType;
960
+ startOnlyIfHaveTexture?: boolean;
961
+ }, tags: string[]): void;
962
+ }
963
+
964
+ type CanvasElementTagType = string;
965
+
966
+ /**
967
+ * Is a decorator that register a canvas element in the game.
968
+ * @param name Name of the canvas element, by default it will use the class name. If the name is already registered, it will show a warning
969
+ * @returns
970
+ */
971
+ declare function canvasElementDecorator(name?: CanvasElementTagType): (target: typeof CanvasBase<any>) => void;
972
+
973
+ /**
974
+ * Is a function that saves the character. If the character already exists, it will be overwritten.
975
+ * @param character is the character to save
976
+ * @returns
977
+ * @example
978
+ * ```typescript
979
+ * export const liam = new CharacterBaseModel('liam', { name: 'Liam'});
980
+ * export const alice = new CharacterBaseModel('alice', { name: 'Alice'});
981
+ * saveCharacter([liam, alice]);
982
+ * ```
983
+ */
984
+ declare function saveCharacter<T extends CharacterBaseModel = CharacterBaseModel>(character: T | T[]): void;
985
+ /**
986
+ * is a function that returns the character by the id
987
+ * @param id is the id of the character
988
+ * @returns the character
989
+ * @example
990
+ * ```typescript
991
+ * const liam = getCharacterById('liam');
992
+ * ```
993
+ */
994
+ declare function getCharacterById<T extends CharacterBaseModel>(id: string): T | undefined;
995
+ /**
996
+ * is a function that returns all characters
997
+ * @returns all characters
998
+ * @example
999
+ * ```typescript
1000
+ * const allCharacters = getAllCharacters();
1001
+ * ```
1002
+ */
1003
+ declare function getAllCharacters<T extends CharacterBaseModel>(): T[];
1004
+
1005
+ /**
1006
+ * Is a decorator that register a event in the game.
1007
+ * Is a required decorator for use the event in the game.
1008
+ * Thanks to this decoration the game has the possibility of updating the events to the latest modification and saving the game.
1009
+ * @param name is th identifier of the event, by default is the name of the class
1010
+ * @returns
1011
+ */
1012
+ declare function eventDecorator(name?: EventIdType): (target: typeof CanvasEvent<any>) => void;
1013
+
1014
+ /**
1015
+ * Is a decorator that register a label in the game.
1016
+ * Is a required decorator for use the label in the game.
1017
+ * Thanks to this decoration the game has the possibility of updating the labels to the latest modification and saving the game.
1018
+ * @param name is th identifier of the label, by default is the name of the class
1019
+ * @returns
1020
+ */
1021
+ declare function labelDecorator(name?: LabelIdType): (target: typeof Label) => void;
1022
+
1023
+ /**
1024
+ * Is a decorator that register a ticker in the game.
1025
+ * Is a required decorator for use the ticker in the game.
1026
+ * Thanks to this decoration the game has the possibility of updating the tickers to the latest modification and saving the game.
1027
+ * @param name is th identifier of the label, by default is the name of the class
1028
+ * @returns
1029
+ */
1030
+ declare function tickerDecorator(name?: TickerIdType): (target: typeof TickerBase<any>) => void;
1031
+
1010
1032
  /**
1011
1033
  * Set the dialogue to be shown in the game
1012
1034
  * @param text Text of the dialogue
@@ -1657,4 +1679,4 @@ declare class GameWindowManager {
1657
1679
  static import(data: object): void;
1658
1680
  }
1659
1681
 
1660
- export { CanvasBase, CanvasContainer, CanvasEvent, type CanvasEventNamesType, CanvasImage, CanvasSprite, CanvasText, CharacterBaseModel, type CharacterBaseModelProps, ChoiceMenuOptionLabel, type ChoiceMenuOptionsType, DialogueBaseModel, type ExportedCanvas, type ExportedStep, type ExportedStorage, GameStepManager, GameStorageManager, GameWindowManager, type ICanvasBaseMemory, type ICanvasContainerMemory, type ICanvasImageMemory, type ICanvasSpriteBaseMemory, type ICanvasSpriteMemory, type ICanvasTextMemory as ICanvasTextTextMemory, type IClassWithArgsHistory, type IClassWithArgsHistoryForExport, type IDialogueHistory, type IHistoryStep, type IHistoryStepData, type IOpenedLabel, type ISaveData, type ITextureMemory, type ITicker, type ITickersSteps, Label, LabelRunModeEnum, Pause, type PauseType, PauseValueType, Repeat, type RepeatType, type StepLabelResultType, type StepLabelType, type StorageElementType, StoredClassModel, TickerBase, TickerFadeAlpha, type TickerProgrationType, TickerRotate, addImage, canvasElementDecorator, clearAllGameDatas, clearChoiceMenuOptions, clearDialogue, eventDecorator, getAllCharacters, getCharacterById, getChoiceMenuOptions, getDialogue, getDialogueHistory, getFlag, getSaveData, getSaveJson, getTexture, labelDecorator, loadSaveData, loadSaveJson, removeCanvasElement, saveCharacter, setChoiceMenuOptions, setDialogue, setFlag, showCanvasImages, showImageWithDissolveTransition, tickerDecorator };
1682
+ export { CanvasBase, CanvasContainer, CanvasEvent, type CanvasEventNamesType, CanvasImage, CanvasSprite, CanvasText, CharacterBaseModel, type CharacterBaseModelProps, ChoiceMenuOptionLabel, type ChoiceMenuOptionsType, DialogueBaseModel, type ExportedCanvas, type ExportedStep, type ExportedStorage, GameStepManager, GameStorageManager, GameWindowManager, type ICanvasBaseMemory, type ICanvasContainerMemory, type ICanvasImageMemory, type ICanvasSpriteBaseMemory, type ICanvasSpriteMemory, type ICanvasTextMemory as ICanvasTextTextMemory, type IClassWithArgsHistory, type IClassWithArgsHistoryForExport, type IDialogueHistory, type IHistoryStep, type IHistoryStepData, type IOpenedLabel, type ISaveData, type ITextureMemory, type ITicker, type ITickersSteps, Label, LabelRunModeEnum, Pause, type PauseType, PauseValueType, Repeat, type RepeatType, type StepLabelResultType, type StepLabelType, type StorageElementType, StoredClassModel, TickerBase, TickerFadeAlpha, type TickerFadeAlphaProps, type TickerProgrationType, TickerRotate, type TickerRotateProps, addImage, canvasElementDecorator, clearAllGameDatas, clearChoiceMenuOptions, clearDialogue, eventDecorator, getAllCharacters, getCharacterById, getChoiceMenuOptions, getDialogue, getDialogueHistory, getFlag, getSaveData, getSaveJson, getTexture, labelDecorator, loadSaveData, loadSaveJson, removeCanvasElement, saveCharacter, setChoiceMenuOptions, setDialogue, setFlag, showCanvasImages, showImageWithDissolveTransition, tickerDecorator };