@drincs/pixi-vn 1.6.4 → 1.7.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/README.md +47 -53
- package/dist/canvas.cjs +2 -2
- package/dist/canvas.d.cts +56 -51
- package/dist/canvas.d.ts +56 -51
- package/dist/canvas.mjs +2 -2
- package/dist/characters.cjs +1 -1
- package/dist/characters.mjs +1 -1
- package/dist/chunk-4KCAZKAJ.mjs +1 -0
- package/dist/{chunk-D45QSSXG.mjs → chunk-HNGW4ITF.mjs} +1 -1
- package/dist/{chunk-L4IHQ3VT.mjs → chunk-X4NBVTSJ.mjs} +1 -1
- package/dist/{chunk-ZW3MIPMS.mjs → chunk-YDNEIPJP.mjs} +1 -1
- package/dist/history.cjs +1 -1
- package/dist/history.mjs +1 -1
- package/dist/index.cjs +2 -9
- package/dist/index.d.cts +73 -4
- package/dist/index.d.ts +73 -4
- package/dist/index.mjs +2 -9
- package/dist/motion.cjs +1 -1
- package/dist/motion.d.cts +3 -1
- package/dist/motion.d.ts +3 -1
- package/dist/motion.mjs +1 -1
- package/dist/narration.cjs +2 -2
- package/dist/narration.mjs +2 -2
- package/dist/pixi/browser.js +183 -171
- package/dist/sound.cjs +1 -1
- package/dist/sound.d.cts +74 -14
- package/dist/sound.d.ts +74 -14
- package/dist/sound.mjs +1 -1
- package/dist/storage.cjs +1 -1
- package/dist/storage.d.cts +63 -12
- package/dist/storage.d.ts +63 -12
- package/dist/storage.mjs +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.d.cts +10 -1
- package/dist/vite.d.ts +10 -1
- package/dist/vite.mjs +1 -1
- package/package.json +12 -7
- package/dist/chunk-EWW7VYPM.mjs +0 -1
- /package/dist/{chunk-XSN6P5JL.mjs → chunk-JMOSOAGB.mjs} +0 -0
package/dist/storage.d.cts
CHANGED
|
@@ -4,6 +4,24 @@ export { S as StorageObjectType } from './StorageElementType-DkJ394kq.cjs';
|
|
|
4
4
|
export { S as StoredClassModel } from './StoredClassModel-LtyakzOw.cjs';
|
|
5
5
|
import { C as CachedMap } from './CachedMap-DZLvJAnA.cjs';
|
|
6
6
|
|
|
7
|
+
interface StorageExternalStoreHandler {
|
|
8
|
+
/**
|
|
9
|
+
* Triggered when {@link StorageManagerStatic.setVariable} is called.
|
|
10
|
+
* The key is provided without any storage prefix.
|
|
11
|
+
*/
|
|
12
|
+
onSetVariable?: (key: string, value: StorageElementType) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Triggered when a temp variable is removed by {@link StorageManagerStatic.clearOldTempVariables}.
|
|
15
|
+
* The key is provided without any storage prefix.
|
|
16
|
+
*/
|
|
17
|
+
onClearOldTempVariable?: (key: string) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Triggered when {@link StorageManagerStatic.removeVariable} is called.
|
|
20
|
+
* The key is provided without any storage prefix.
|
|
21
|
+
*/
|
|
22
|
+
onRemoveVariable?: (key: string) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
7
25
|
interface StorageGameStateItem<T = StorageElementType> {
|
|
8
26
|
key: string;
|
|
9
27
|
value: T;
|
|
@@ -103,6 +121,39 @@ interface StorageManagerInterface {
|
|
|
103
121
|
* @returns The value of the flag
|
|
104
122
|
*/
|
|
105
123
|
getFlag(key: string): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Configure the handler used to mirror game storage changes into an external reactive store.
|
|
126
|
+
* Call this at any time to start/stop mirroring.
|
|
127
|
+
* @param value The handler to set. If undefined, the handler will be removed.
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* import { Store } from '@tanstack/store'
|
|
131
|
+
*
|
|
132
|
+
* // Create a TanStack store that mirrors the game storage variables
|
|
133
|
+
* const gameStore = new Store<Record<string, unknown>>({})
|
|
134
|
+
*
|
|
135
|
+
* storage.setStorageHandler({
|
|
136
|
+
* onSetVariable: (key, value) => {
|
|
137
|
+
* gameStore.setState((state) => ({ ...state, [key]: value }))
|
|
138
|
+
* },
|
|
139
|
+
* onRemoveVariable: (key) => {
|
|
140
|
+
* gameStore.setState((state) => {
|
|
141
|
+
* const next = { ...state }
|
|
142
|
+
* delete next[key]
|
|
143
|
+
* return next
|
|
144
|
+
* })
|
|
145
|
+
* },
|
|
146
|
+
* onClearOldTempVariable: (key) => {
|
|
147
|
+
* gameStore.setState((state) => {
|
|
148
|
+
* const next = { ...state }
|
|
149
|
+
* delete next[key]
|
|
150
|
+
* return next
|
|
151
|
+
* })
|
|
152
|
+
* },
|
|
153
|
+
* })
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
setStorageHandler(value?: StorageExternalStoreHandler): void;
|
|
106
157
|
/**
|
|
107
158
|
* Clear the storage and the oidsUsed
|
|
108
159
|
* @returns
|
|
@@ -120,19 +171,19 @@ interface StorageManagerInterface {
|
|
|
120
171
|
restore(data: StorageGameState): void;
|
|
121
172
|
}
|
|
122
173
|
|
|
123
|
-
declare
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
174
|
+
declare namespace StorageManagerStatic {
|
|
175
|
+
const storage: CachedMap<string, any>;
|
|
176
|
+
const defaultStorage: CachedMap<string, any>;
|
|
177
|
+
const tempStorageDeadlines: Map<string, number>;
|
|
178
|
+
function clearOldTempVariables(openedLabelsNumber: number): void;
|
|
179
|
+
function setExternalStoreHandler(handler?: StorageExternalStoreHandler): void;
|
|
180
|
+
function setVariable(prefix: string, key: string, value: StorageElementType): void;
|
|
181
|
+
function getVariable<T = StorageElementType>(prefix: string, key: string): T | undefined;
|
|
182
|
+
function removeVariable(prefix: string, key: string): void;
|
|
183
|
+
function setFlag(key: string, value: boolean): void;
|
|
184
|
+
function getFlag(key: string): boolean;
|
|
134
185
|
}
|
|
135
186
|
|
|
136
187
|
declare const storage: StorageManagerInterface;
|
|
137
188
|
|
|
138
|
-
export { StorageElementType, type StorageGameState, type StorageManagerInterface, StorageManagerStatic, storage };
|
|
189
|
+
export { StorageElementType, type StorageExternalStoreHandler, type StorageGameState, type StorageManagerInterface, StorageManagerStatic, storage };
|
package/dist/storage.d.ts
CHANGED
|
@@ -4,6 +4,24 @@ export { S as StorageObjectType } from './StorageElementType-DkJ394kq.js';
|
|
|
4
4
|
export { S as StoredClassModel } from './StoredClassModel-a4pvgJXD.js';
|
|
5
5
|
import { C as CachedMap } from './CachedMap-DZLvJAnA.js';
|
|
6
6
|
|
|
7
|
+
interface StorageExternalStoreHandler {
|
|
8
|
+
/**
|
|
9
|
+
* Triggered when {@link StorageManagerStatic.setVariable} is called.
|
|
10
|
+
* The key is provided without any storage prefix.
|
|
11
|
+
*/
|
|
12
|
+
onSetVariable?: (key: string, value: StorageElementType) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Triggered when a temp variable is removed by {@link StorageManagerStatic.clearOldTempVariables}.
|
|
15
|
+
* The key is provided without any storage prefix.
|
|
16
|
+
*/
|
|
17
|
+
onClearOldTempVariable?: (key: string) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Triggered when {@link StorageManagerStatic.removeVariable} is called.
|
|
20
|
+
* The key is provided without any storage prefix.
|
|
21
|
+
*/
|
|
22
|
+
onRemoveVariable?: (key: string) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
7
25
|
interface StorageGameStateItem<T = StorageElementType> {
|
|
8
26
|
key: string;
|
|
9
27
|
value: T;
|
|
@@ -103,6 +121,39 @@ interface StorageManagerInterface {
|
|
|
103
121
|
* @returns The value of the flag
|
|
104
122
|
*/
|
|
105
123
|
getFlag(key: string): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Configure the handler used to mirror game storage changes into an external reactive store.
|
|
126
|
+
* Call this at any time to start/stop mirroring.
|
|
127
|
+
* @param value The handler to set. If undefined, the handler will be removed.
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* import { Store } from '@tanstack/store'
|
|
131
|
+
*
|
|
132
|
+
* // Create a TanStack store that mirrors the game storage variables
|
|
133
|
+
* const gameStore = new Store<Record<string, unknown>>({})
|
|
134
|
+
*
|
|
135
|
+
* storage.setStorageHandler({
|
|
136
|
+
* onSetVariable: (key, value) => {
|
|
137
|
+
* gameStore.setState((state) => ({ ...state, [key]: value }))
|
|
138
|
+
* },
|
|
139
|
+
* onRemoveVariable: (key) => {
|
|
140
|
+
* gameStore.setState((state) => {
|
|
141
|
+
* const next = { ...state }
|
|
142
|
+
* delete next[key]
|
|
143
|
+
* return next
|
|
144
|
+
* })
|
|
145
|
+
* },
|
|
146
|
+
* onClearOldTempVariable: (key) => {
|
|
147
|
+
* gameStore.setState((state) => {
|
|
148
|
+
* const next = { ...state }
|
|
149
|
+
* delete next[key]
|
|
150
|
+
* return next
|
|
151
|
+
* })
|
|
152
|
+
* },
|
|
153
|
+
* })
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
setStorageHandler(value?: StorageExternalStoreHandler): void;
|
|
106
157
|
/**
|
|
107
158
|
* Clear the storage and the oidsUsed
|
|
108
159
|
* @returns
|
|
@@ -120,19 +171,19 @@ interface StorageManagerInterface {
|
|
|
120
171
|
restore(data: StorageGameState): void;
|
|
121
172
|
}
|
|
122
173
|
|
|
123
|
-
declare
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
174
|
+
declare namespace StorageManagerStatic {
|
|
175
|
+
const storage: CachedMap<string, any>;
|
|
176
|
+
const defaultStorage: CachedMap<string, any>;
|
|
177
|
+
const tempStorageDeadlines: Map<string, number>;
|
|
178
|
+
function clearOldTempVariables(openedLabelsNumber: number): void;
|
|
179
|
+
function setExternalStoreHandler(handler?: StorageExternalStoreHandler): void;
|
|
180
|
+
function setVariable(prefix: string, key: string, value: StorageElementType): void;
|
|
181
|
+
function getVariable<T = StorageElementType>(prefix: string, key: string): T | undefined;
|
|
182
|
+
function removeVariable(prefix: string, key: string): void;
|
|
183
|
+
function setFlag(key: string, value: boolean): void;
|
|
184
|
+
function getFlag(key: string): boolean;
|
|
134
185
|
}
|
|
135
186
|
|
|
136
187
|
declare const storage: StorageManagerInterface;
|
|
137
188
|
|
|
138
|
-
export { StorageElementType, type StorageGameState, type StorageManagerInterface, StorageManagerStatic, storage };
|
|
189
|
+
export { StorageElementType, type StorageExternalStoreHandler, type StorageGameState, type StorageManagerInterface, StorageManagerStatic, storage };
|
package/dist/storage.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as StorageManagerStatic,b as StoredClassModel,c as storage}from'./chunk-
|
|
1
|
+
export{a as StorageManagerStatic,b as StoredClassModel,c as storage}from'./chunk-4KCAZKAJ.mjs';import'./chunk-YDNEIPJP.mjs';import'./chunk-IWAXXFXE.mjs';import'./chunk-HNGW4ITF.mjs';
|
package/dist/vite.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var s=null,o=null,d=null,
|
|
1
|
+
'use strict';var s=null,o=null,d=null,r=null;function l(){return {name:"vite-plugin-pixi-vn",apply:"serve",configureServer(a){a.middlewares.use("/pixi-vn/characters",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!s){t.statusCode=404,t.end(JSON.stringify({error:"Characters not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(s));}if(i.method==="POST"){let e="";i.on("data",n=>e+=n),i.on("end",()=>{try{s=JSON.parse(e),t.statusCode=201,t.end(JSON.stringify({message:"Characters updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}}),a.middlewares.use("/pixi-vn/labels",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!o){t.statusCode=404,t.end(JSON.stringify({error:"Labels not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(o));}if(i.method==="POST"){let e="";i.on("data",n=>e+=n),i.on("end",()=>{try{o=JSON.parse(e),t.statusCode=201,t.end(JSON.stringify({message:"Labels updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}}),a.middlewares.use("/pixi-vn/assets/manifest",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!d){t.statusCode=404,t.end(JSON.stringify({error:"Manifest not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(d));}if(i.method==="POST"){let e="";i.on("data",n=>e+=n),i.on("end",()=>{try{d=JSON.parse(e),t.statusCode=201,t.end(JSON.stringify({message:"Manifest updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}}),a.middlewares.use("/pixi-vn/canvas/options",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!r){t.statusCode=404,t.end(JSON.stringify({error:"Options not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(r));}if(i.method==="POST"){let e="";i.on("data",n=>e+=n),i.on("end",()=>{try{r=JSON.parse(e),t.statusCode=201,t.end(JSON.stringify({message:"Options updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}});}}}exports.vitePluginPixivn=l;
|
package/dist/vite.d.cts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
2
|
|
|
3
|
+
type Plugin = {
|
|
4
|
+
name: string;
|
|
5
|
+
apply: "serve";
|
|
6
|
+
configureServer: (server: {
|
|
7
|
+
middlewares: {
|
|
8
|
+
use: (path: string, handler: (req: IncomingMessage, res: ServerResponse) => void) => void;
|
|
9
|
+
};
|
|
10
|
+
}) => void;
|
|
11
|
+
};
|
|
3
12
|
/**
|
|
4
13
|
* Vite plugin to handle pixi-vn related endpoints.
|
|
5
14
|
* This plugin only runs in development mode (serve).
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
2
|
|
|
3
|
+
type Plugin = {
|
|
4
|
+
name: string;
|
|
5
|
+
apply: "serve";
|
|
6
|
+
configureServer: (server: {
|
|
7
|
+
middlewares: {
|
|
8
|
+
use: (path: string, handler: (req: IncomingMessage, res: ServerResponse) => void) => void;
|
|
9
|
+
};
|
|
10
|
+
}) => void;
|
|
11
|
+
};
|
|
3
12
|
/**
|
|
4
13
|
* Vite plugin to handle pixi-vn related endpoints.
|
|
5
14
|
* This plugin only runs in development mode (serve).
|
package/dist/vite.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import'./chunk-TTRUPDAB.mjs';var s=null,o=null,d=null,
|
|
1
|
+
import'./chunk-TTRUPDAB.mjs';var s=null,o=null,d=null,r=null;function l(){return {name:"vite-plugin-pixi-vn",apply:"serve",configureServer(a){a.middlewares.use("/pixi-vn/characters",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!s){t.statusCode=404,t.end(JSON.stringify({error:"Characters not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(s));}if(i.method==="POST"){let e="";i.on("data",n=>e+=n),i.on("end",()=>{try{s=JSON.parse(e),t.statusCode=201,t.end(JSON.stringify({message:"Characters updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}}),a.middlewares.use("/pixi-vn/labels",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!o){t.statusCode=404,t.end(JSON.stringify({error:"Labels not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(o));}if(i.method==="POST"){let e="";i.on("data",n=>e+=n),i.on("end",()=>{try{o=JSON.parse(e),t.statusCode=201,t.end(JSON.stringify({message:"Labels updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}}),a.middlewares.use("/pixi-vn/assets/manifest",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!d){t.statusCode=404,t.end(JSON.stringify({error:"Manifest not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(d));}if(i.method==="POST"){let e="";i.on("data",n=>e+=n),i.on("end",()=>{try{d=JSON.parse(e),t.statusCode=201,t.end(JSON.stringify({message:"Manifest updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}}),a.middlewares.use("/pixi-vn/canvas/options",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!r){t.statusCode=404,t.end(JSON.stringify({error:"Options not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(r));}if(i.method==="POST"){let e="";i.on("data",n=>e+=n),i.on("end",()=>{try{r=JSON.parse(e),t.statusCode=201,t.end(JSON.stringify({message:"Options updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}});}}}export{l as vitePluginPixivn};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drincs/pixi-vn",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Pixi'VN is a npm package that provides various features for creating visual novels.",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
"scripts": {
|
|
13
13
|
"dev": "tsup --watch",
|
|
14
14
|
"build": "tsup --config tsup.config.ts",
|
|
15
|
+
"lint": "biome lint",
|
|
16
|
+
"check": "biome check",
|
|
17
|
+
"format": "biome format --write",
|
|
15
18
|
"test": "vitest"
|
|
16
19
|
},
|
|
17
20
|
"exports": {
|
|
@@ -140,7 +143,7 @@
|
|
|
140
143
|
"@pixi/devtools": "^2.0.1",
|
|
141
144
|
"@pixi/sound": "^6.0.1",
|
|
142
145
|
"motion": "^12.38.0",
|
|
143
|
-
"pixi.js": "^8.
|
|
146
|
+
"pixi.js": "^8.18.1"
|
|
144
147
|
},
|
|
145
148
|
"peerDependencies": {
|
|
146
149
|
"@pixi/devtools": "^2.0.0",
|
|
@@ -149,20 +152,22 @@
|
|
|
149
152
|
"pixi.js": "^8.17.0"
|
|
150
153
|
},
|
|
151
154
|
"devDependencies": {
|
|
155
|
+
"@biomejs/biome": "^2.4.12",
|
|
152
156
|
"@types/crypto-js": "^4.2.2",
|
|
153
157
|
"@types/mime-db": "^1.43.6",
|
|
154
158
|
"crypto-js": "^4.2.0",
|
|
155
|
-
"jsdom": "^29.0.
|
|
159
|
+
"jsdom": "^29.0.2",
|
|
156
160
|
"keyv": "^5.6.0",
|
|
157
|
-
"lru-cache": "
|
|
161
|
+
"lru-cache": "11.2.7",
|
|
158
162
|
"microdiff": "^1.5.0",
|
|
159
163
|
"mime-db": "^1.54.0",
|
|
160
164
|
"ts-node": "^10.9.2",
|
|
165
|
+
"tsconfig-paths": "^4.2.0",
|
|
161
166
|
"tsup": "^8.5.1",
|
|
162
167
|
"typescript": "^5.9.3",
|
|
163
|
-
"vite": "^
|
|
164
|
-
"vite-tsconfig-paths": "^6.
|
|
165
|
-
"vitest": "^4.
|
|
168
|
+
"vite": "^8.0.9",
|
|
169
|
+
"vite-tsconfig-paths": "^6.1.1",
|
|
170
|
+
"vitest": "^4.1.5"
|
|
166
171
|
},
|
|
167
172
|
"keywords": [
|
|
168
173
|
"2d",
|
package/dist/chunk-EWW7VYPM.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-ZW3MIPMS.mjs';import {k,m,j,l,n}from'./chunk-IWAXXFXE.mjs';import {d,k as k$1,j as j$1}from'./chunk-D45QSSXG.mjs';import {GameUnifier}from'@drincs/pixi-vn/core';var s=class s{constructor(){}static clearOldTempVariables(t){s.tempStorageDeadlines.forEach((e,r)=>{e>t&&(s.removeVariable(k,r),s.tempStorageDeadlines.delete(r));});}static setVariable(t,e,r){r==null?s.storage.delete(`${t}:${e}`):s.storage.set(`${t}:${e}`,r);}static getVariable(t,e){let r=s.storage.get(`${t}:${e}`);return k$1(r)}static removeVariable(t,e){s.storage.delete(`${t}:${e}`);}static setFlag(t,e){let r=s.storage.get(m)||[];if(e)r.includes(t)||r.push(t);else {let g=r.indexOf(t);g>-1&&r.splice(g,1);}s.storage.set(m,r);}static getFlag(t){return (s.storage.get(m)||[]).includes(t)}};d(s,"storage",new a$1({cacheSize:50})),d(s,"default",new a$1({cacheSize:10})),d(s,"tempStorageDeadlines",new Map);var a=s;var p=class{get base(){return a.storage.map}get cache(){return a.storage.cache}get tempStorageDeadlines(){return a.tempStorageDeadlines}set default(t){Object.entries(t).forEach(([e,r])=>{a.default.map.set(e,r);});}set(t,e){return a.setVariable(j,t,e)}get(t){let e=a.getVariable(k,t);return e===void 0&&(e=a.getVariable(j,t)),e===void 0&&(e=k$1(a.default.get(t))),e}remove(t){return this.removeTempVariable(t),a.removeVariable(j,t)}setTempVariable(t,e){if(e==null){this.removeTempVariable(t);return}else a.setVariable(k,t,e),this.tempStorageDeadlines.has(t)||this.tempStorageDeadlines.set(t,GameUnifier.openedLabels);}removeTempVariable(t){a.removeVariable(k,t),this.tempStorageDeadlines.has(t)&&this.tempStorageDeadlines.delete(t);}setFlag(t,e){return a.setFlag(t,e)}getFlag(t){return a.getFlag(t)}clear(){this.base.clear(),this.cache.clear(),this.tempStorageDeadlines.clear();}export(){let t=[];[...this.base.keys()].forEach(r=>{t.push({key:r,value:this.base.get(r)});});let e=[];return [...a.tempStorageDeadlines.keys()].forEach(r=>{e.push({key:r,value:this.tempStorageDeadlines.get(r)});}),k$1({main:t,tempDeadlines:e})}restore(t){this.clear();try{t?(t.base?.forEach(e=>{switch(e.key){case "___current_dialogue_memory___":a.setVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY,e.value);break;case "___last_dialogue_added_in_step_memory___":a.setVariable(l,n.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,e.value);break;case "___current_menu_options_memory___":a.setVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY,e.value);break;case "___last_menu_options_added_in_step_memory___":a.setVariable(l,n.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,e.value);break;case "_input_value_":a.setVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY,e.value);break;case "___last_input_added_in_step_memory___":a.setVariable(l,n.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,e.value);break;case "___current_input_info_memory___":a.setVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY,e.value);break;case "___opened_labels_counter___":a.setVariable(l,n.OPENED_LABELS_COUNTER_KEY,e.value);break;case "___all_choices_made___":a.setVariable(l,n.ALL_CHOICES_MADE_KEY,e.value);break;case "___current_step_times_counter___":a.setVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY,e.value);break;case "___last_step_glued___":a.setVariable(l,n.LAST_STEP_GLUED,e.value);break;default:a.setVariable(j,e.key,e.value);}}),t.temp?.forEach(e=>{a.setVariable(k,e.key,e.value);}),t.flags?.forEach(e=>{a.setFlag(e,!0);}),t.main?.forEach(e=>{this.base.set(e.key,e.value);}),t.tempDeadlines?.forEach(e=>{this.tempStorageDeadlines.set(e.key,e.value);})):j$1.warn("No storage data found");}catch(e){j$1.error("Error importing data",e);}}};var E=class{constructor(t,e){d(this,"id");d(this,"categoryId");this.categoryId=t,this.id=e,this.migrateOldStorage();}migrateOldStorage(t=this.categoryId){let e=a.getVariable(j,t);e&&(Object.entries(e).forEach(([r,g])=>{typeof g=="object"&&g!==null&&Object.entries(g).forEach(([f,b])=>{a.setVariable(this.categoryId,`${r}:${f}`,b);});}),a.removeVariable(j,t));}setStorageProperty(t,e){a.setVariable(this.categoryId,`${this.id}:${t}`,e);}getStorageProperty(t,e=this.id){return a.getVariable(this.categoryId,`${e}:${t}`)}};var L=new p;export{a,E as b,L as c};
|
|
File without changes
|