@drincs/pixi-vn 1.8.0 → 1.8.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.
Files changed (49) hide show
  1. package/README.md +3 -47
  2. package/dist/{HistoryChoiceMenuOption-BP9Tsbyd.d.ts → HistoryChoiceMenuOption-CS41KG13.d.ts} +2 -2
  3. package/dist/{HistoryChoiceMenuOption-DSSNUXEq.d.cts → HistoryChoiceMenuOption-DdwePsOm.d.cts} +2 -2
  4. package/dist/{StorageElementType-DkJ394kq.d.cts → StorageElementType-C7ETezlL.d.cts} +1 -1
  5. package/dist/{StorageElementType-DkJ394kq.d.ts → StorageElementType-C7ETezlL.d.ts} +1 -1
  6. package/dist/{StoredClassModel-a4pvgJXD.d.ts → StoredClassModel-C9mQxPg-.d.cts} +9 -6
  7. package/dist/{StoredClassModel-LtyakzOw.d.cts → StoredClassModel-upXPNQTp.d.ts} +9 -6
  8. package/dist/canvas.cjs +1 -1
  9. package/dist/canvas.mjs +2 -2
  10. package/dist/characters.cjs +1 -1
  11. package/dist/characters.d.cts +54 -50
  12. package/dist/characters.d.ts +54 -50
  13. package/dist/characters.mjs +1 -1
  14. package/dist/chunk-3BBZHKU4.mjs +1 -0
  15. package/dist/chunk-K7JIC2F2.mjs +1 -0
  16. package/dist/chunk-V34PMA2H.mjs +1 -0
  17. package/dist/{chunk-3SLELYPF.mjs → chunk-YCWXA3OR.mjs} +1 -1
  18. package/dist/{chunk-6HI66YQL.mjs → chunk-Z4GZCINS.mjs} +1 -1
  19. package/dist/history.cjs +1 -1
  20. package/dist/history.d.cts +2 -2
  21. package/dist/history.d.ts +2 -2
  22. package/dist/history.mjs +1 -1
  23. package/dist/index.cjs +2 -2
  24. package/dist/index.d.cts +21 -6
  25. package/dist/index.d.ts +21 -6
  26. package/dist/index.mjs +2 -2
  27. package/dist/narration.cjs +1 -1
  28. package/dist/narration.d.cts +3 -3
  29. package/dist/narration.d.ts +3 -3
  30. package/dist/narration.mjs +1 -1
  31. package/dist/sound.cjs +1 -1
  32. package/dist/sound.d.cts +6 -2
  33. package/dist/sound.d.ts +6 -2
  34. package/dist/sound.mjs +1 -1
  35. package/dist/storage.cjs +1 -1
  36. package/dist/storage.d.cts +12 -8
  37. package/dist/storage.d.ts +12 -8
  38. package/dist/storage.mjs +1 -1
  39. package/dist/vite-listener.cjs +1 -1
  40. package/dist/vite-listener.d.cts +31 -5
  41. package/dist/vite-listener.d.ts +31 -5
  42. package/dist/vite-listener.mjs +1 -1
  43. package/dist/vite.cjs +1 -1
  44. package/dist/vite.d.cts +89 -21
  45. package/dist/vite.d.ts +89 -21
  46. package/dist/vite.mjs +1 -1
  47. package/package.json +14 -6
  48. package/dist/chunk-TTRUPDAB.mjs +0 -1
  49. package/dist/chunk-XYO5SLSM.mjs +0 -1
package/dist/storage.d.ts CHANGED
@@ -1,22 +1,22 @@
1
1
  import { LRUCache } from 'lru-cache';
2
- import { a as StorageElementType } from './StorageElementType-DkJ394kq.js';
3
- export { S as StorageObjectType } from './StorageElementType-DkJ394kq.js';
4
- export { S as StoredClassModel } from './StoredClassModel-a4pvgJXD.js';
2
+ import { S as StorageElementType } from './StorageElementType-C7ETezlL.js';
3
+ export { a as StorageObjectType } from './StorageElementType-C7ETezlL.js';
4
+ export { S as StoredClassModel } from './StoredClassModel-upXPNQTp.js';
5
5
  import { C as CachedMap } from './CachedMap-DZLvJAnA.js';
6
6
 
7
7
  interface StorageExternalStoreHandler {
8
8
  /**
9
- * Triggered when {@link StorageManagerStatic.setVariable} is called.
9
+ * Triggered when {@link StorageRegistry.setVariable} is called.
10
10
  * The key is provided without any storage prefix.
11
11
  */
12
12
  onSetVariable?: (key: string, value: StorageElementType) => void;
13
13
  /**
14
- * Triggered when a temp variable is removed by {@link StorageManagerStatic.clearOldTempVariables}.
14
+ * Triggered when a temp variable is removed by {@link StorageRegistry.clearOldTempVariables}.
15
15
  * The key is provided without any storage prefix.
16
16
  */
17
17
  onClearOldTempVariable?: (key: string) => void;
18
18
  /**
19
- * Triggered when {@link StorageManagerStatic.removeVariable} is called.
19
+ * Triggered when {@link StorageRegistry.removeVariable} is called.
20
20
  * The key is provided without any storage prefix.
21
21
  */
22
22
  onRemoveVariable?: (key: string) => void;
@@ -171,7 +171,11 @@ interface StorageManagerInterface {
171
171
  restore(data: StorageGameState): void;
172
172
  }
173
173
 
174
- declare namespace StorageManagerStatic {
174
+ /**
175
+ * StorageRegistry is a singleton namespace that holds global state for the storage system.
176
+ * **DO NOT** import this module directly; use `storage`.
177
+ */
178
+ declare namespace StorageRegistry {
175
179
  const storage: CachedMap<string, any>;
176
180
  const defaultStorage: CachedMap<string, any>;
177
181
  const tempStorageDeadlines: Map<string, number>;
@@ -186,4 +190,4 @@ declare namespace StorageManagerStatic {
186
190
 
187
191
  declare const storage: StorageManagerInterface;
188
192
 
189
- export { StorageElementType, type StorageExternalStoreHandler, type StorageGameState, type StorageManagerInterface, StorageManagerStatic, storage };
193
+ export { StorageElementType, type StorageExternalStoreHandler, type StorageGameState, type StorageManagerInterface, StorageRegistry, storage };
package/dist/storage.mjs CHANGED
@@ -1 +1 @@
1
- export{a as StorageManagerStatic,b as StoredClassModel,c as storage}from'./chunk-XYO5SLSM.mjs';import'./chunk-IWAXXFXE.mjs';import'./chunk-6HI66YQL.mjs';
1
+ export{a as StorageRegistry,b as StoredClassModel,c as storage}from'./chunk-V34PMA2H.mjs';import'./chunk-IWAXXFXE.mjs';import'./chunk-Z4GZCINS.mjs';
@@ -1 +1 @@
1
- 'use strict';var canvas=require('@drincs/pixi-vn/canvas'),characters=require('@drincs/pixi-vn/characters'),narration=require('@drincs/pixi-vn/narration'),o=require('@drincs/pixi-vn/pixi.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var o__default=/*#__PURE__*/_interopDefault(o);function h(){try{return new Function('return typeof import !== "undefined" && typeof import.meta !== "undefined" && import.meta.env?.DEV === true')()}catch{return false}}function l(){if(h()){try{let e=characters.RegisteredCharacters.values();fetch("/pixi-vn/characters",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch{}try{let e=narration.RegisteredLabels.keys();fetch("/pixi-vn/labels",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch{}try{let e=o__default.default.Assets.resolver._assetMap,r=o__default.default.Assets.resolver._bundles,s={bundles:[]};Object.entries(r).forEach(([a,p])=>{let t=[];p.forEach(n=>{if(e[n]){let c=e[n];t=[...t,...c];}}),s.bundles.push({name:a,assets:t});}),fetch("/pixi-vn/assets/manifest",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});}catch{}try{let e={height:canvas.canvas.app.screen.height,width:canvas.canvas.app.screen.width};fetch("/pixi-vn/canvas/options",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch{}}}exports.setupPixivnViteData=l;
1
+ 'use strict';var canvas=require('@drincs/pixi-vn/canvas'),characters=require('@drincs/pixi-vn/characters'),narration=require('@drincs/pixi-vn/narration'),l=require('@drincs/pixi-vn/pixi.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var l__default=/*#__PURE__*/_interopDefault(l);var i="/__pixi-vn/characters",a="/__pixi-vn/labels",c="/__pixi-vn/assets/manifest",p="/__pixi-vn/canvas-options";async function e(t,s,r="data"){try{await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});}catch(n){console.warn(`Failed to send ${r} to ${t}:`,n);}}function d(){let t=l__default.default.Assets.resolver._assetMap,s=l__default.default.Assets.resolver._bundles;return {bundles:Object.entries(s).map(([r,n])=>({name:r,assets:n.flatMap(I=>t[I]??[])}))}}function _(){return typeof window>"u"||typeof document>"u"?false:!!document.querySelector('script[src^="/@vite/client"]')}async function m(){if(_()){try{let t=characters.RegisteredCharacters.values();await e(i,t,"characters");}catch(t){console.warn("Error collecting characters:",t);}try{let t=narration.RegisteredLabels.keys();await e(a,t,"labels");}catch(t){console.warn("Error collecting labels:",t);}try{let t=d();await e(c,t,"assets manifest");}catch(t){console.warn("Error collecting assets manifest:",t);}if(canvas.canvas.isInitialized)try{let t={height:canvas.canvas.app.screen.height,width:canvas.canvas.app.screen.width};await e(p,t,"canvas options");}catch(t){console.warn("Error collecting canvas options:",t);}}}exports.isViteDevelopmentMode=_;exports.setupPixivnViteData=m;
@@ -1,8 +1,34 @@
1
1
  /**
2
- * Function that setup the pixivn vite data.
3
- * This function should be called in the client side, after the RegisteredCharacters and RegisteredLabels are populated.
4
- * **Note:** This function only runs in development mode and does nothing in production.
2
+ * Checks if the current runtime is Vite development mode.
3
+ * Detects Vite dev client script injected in development.
4
+ * Assumes default Vite client path starts with `/@vite/client`.
5
+ *
6
+ * @returns {boolean}
7
+ * @public
5
8
  */
6
- declare function setupPixivnViteData(): void;
9
+ declare function isViteDevelopmentMode(): boolean;
10
+ /**
11
+ * Initializes Pixi VN development tools by syncing game state with the Vite dev server.
12
+ * Sends registered characters, labels, assets manifest, and canvas options.
13
+ *
14
+ * **Note:** This function only operates in Vite development mode and is a no-op in production.
15
+ *
16
+ * **Call this function:** After RegisteredCharacters and RegisteredLabels are populated,
17
+ * typically in your client-side initialization code.
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * // In your main game initialization file
22
+ * import { setupPixivnViteData } from '@drincs/pixi-vn/vite-listener';
23
+ *
24
+ * await Promise.all([import("@/content")]);
25
+ * // After game setup
26
+ * await setupPixivnViteData();
27
+ * ```
28
+ *
29
+ * @returns {Promise<void>}
30
+ * @public
31
+ */
32
+ declare function setupPixivnViteData(): Promise<void>;
7
33
 
8
- export { setupPixivnViteData };
34
+ export { isViteDevelopmentMode, setupPixivnViteData };
@@ -1,8 +1,34 @@
1
1
  /**
2
- * Function that setup the pixivn vite data.
3
- * This function should be called in the client side, after the RegisteredCharacters and RegisteredLabels are populated.
4
- * **Note:** This function only runs in development mode and does nothing in production.
2
+ * Checks if the current runtime is Vite development mode.
3
+ * Detects Vite dev client script injected in development.
4
+ * Assumes default Vite client path starts with `/@vite/client`.
5
+ *
6
+ * @returns {boolean}
7
+ * @public
5
8
  */
6
- declare function setupPixivnViteData(): void;
9
+ declare function isViteDevelopmentMode(): boolean;
10
+ /**
11
+ * Initializes Pixi VN development tools by syncing game state with the Vite dev server.
12
+ * Sends registered characters, labels, assets manifest, and canvas options.
13
+ *
14
+ * **Note:** This function only operates in Vite development mode and is a no-op in production.
15
+ *
16
+ * **Call this function:** After RegisteredCharacters and RegisteredLabels are populated,
17
+ * typically in your client-side initialization code.
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * // In your main game initialization file
22
+ * import { setupPixivnViteData } from '@drincs/pixi-vn/vite-listener';
23
+ *
24
+ * await Promise.all([import("@/content")]);
25
+ * // After game setup
26
+ * await setupPixivnViteData();
27
+ * ```
28
+ *
29
+ * @returns {Promise<void>}
30
+ * @public
31
+ */
32
+ declare function setupPixivnViteData(): Promise<void>;
7
33
 
8
- export { setupPixivnViteData };
34
+ export { isViteDevelopmentMode, setupPixivnViteData };
@@ -1 +1 @@
1
- import'./chunk-TTRUPDAB.mjs';import {canvas}from'@drincs/pixi-vn/canvas';import {RegisteredCharacters}from'@drincs/pixi-vn/characters';import {RegisteredLabels}from'@drincs/pixi-vn/narration';import o from'@drincs/pixi-vn/pixi.js';function h(){try{return new Function('return typeof import !== "undefined" && typeof import.meta !== "undefined" && import.meta.env?.DEV === true')()}catch{return false}}function l(){if(h()){try{let e=RegisteredCharacters.values();fetch("/pixi-vn/characters",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch{}try{let e=RegisteredLabels.keys();fetch("/pixi-vn/labels",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch{}try{let e=o.Assets.resolver._assetMap,r=o.Assets.resolver._bundles,s={bundles:[]};Object.entries(r).forEach(([a,p])=>{let t=[];p.forEach(n=>{if(e[n]){let c=e[n];t=[...t,...c];}}),s.bundles.push({name:a,assets:t});}),fetch("/pixi-vn/assets/manifest",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});}catch{}try{let e={height:canvas.app.screen.height,width:canvas.app.screen.width};fetch("/pixi-vn/canvas/options",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch{}}}export{l as setupPixivnViteData};
1
+ import {a,b,c,d}from'./chunk-3BBZHKU4.mjs';import'./chunk-K7JIC2F2.mjs';import {canvas}from'@drincs/pixi-vn/canvas';import {RegisteredCharacters}from'@drincs/pixi-vn/characters';import {RegisteredLabels}from'@drincs/pixi-vn/narration';import p from'@drincs/pixi-vn/pixi.js';async function t(e,s,r="data"){try{await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});}catch(o){console.warn(`Failed to send ${r} to ${e}:`,o);}}function A(){let e=p.Assets.resolver._assetMap,s=p.Assets.resolver._bundles;return {bundles:Object.entries(s).map(([r,o])=>({name:r,assets:o.flatMap(d=>e[d]??[])}))}}function f(){return typeof window>"u"||typeof document>"u"?false:!!document.querySelector('script[src^="/@vite/client"]')}async function h(){if(f()){try{let e=RegisteredCharacters.values();await t(a,e,"characters");}catch(e){console.warn("Error collecting characters:",e);}try{let e=RegisteredLabels.keys();await t(b,e,"labels");}catch(e){console.warn("Error collecting labels:",e);}try{let e=A();await t(c,e,"assets manifest");}catch(e){console.warn("Error collecting assets manifest:",e);}if(canvas.isInitialized)try{let e={height:canvas.app.screen.height,width:canvas.app.screen.width};await t(d,e,"canvas options");}catch(e){console.warn("Error collecting canvas options:",e);}}}export{f as isViteDevelopmentMode,h as setupPixivnViteData};
package/dist/vite.cjs CHANGED
@@ -1 +1 @@
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;
1
+ 'use strict';var fs=require('fs'),tinyglobby=require('tinyglobby');var D=Object.create;var V=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var G=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var J=(e,t,s,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of X(t))!$.call(e,i)&&i!==s&&V(e,i,{get:()=>t[i],enumerable:!(c=F(t,i))||c.enumerable});return e};var H=(e,t,s)=>(s=e!=null?D(k(e)):{},J(V(s,"default",{value:e,enumerable:true}),e));var N=G((q,S)=>{var f=process||{},O=f.argv||[],u=f.env||{},j=!(u.NO_COLOR||O.includes("--no-color"))&&(!!u.FORCE_COLOR||O.includes("--color")||f.platform==="win32"||(f.stdout||{}).isTTY&&u.TERM!=="dumb"||!!u.CI),z=(e,t,s=e)=>c=>{let i=""+c,a=i.indexOf(t,e.length);return ~a?e+Y(i,t,s,a)+t:e+i+t},Y=(e,t,s,c)=>{let i="",a=0;do i+=e.substring(a,c)+s,a=c+t.length,c=e.indexOf(t,a);while(~c);return i+e.substring(a)},R=(e=j)=>{let t=e?z:()=>String;return {isColorSupported:e,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};S.exports=R();S.exports.createColors=R;});var p="/__pixi-vn/characters",I="/__pixi-vn/labels",v="/__pixi-vn/assets/manifest",_="/__pixi-vn/canvas-options";var y=H(N());var L=y.default.cyan("(pixi-vn)");function P(e){return e?Array.isArray(e)?e:[e]:[]}function W(e){let t=[],s=[];for(let c of e)try{let i=fs.readFileSync(c,"utf-8"),a=/newLabel\(\s*["']([^"']+)["']/g,d;for(;(d=a.exec(i))!==null;)s.push(d[1]);let g=/new\s+\w*[Cc]haracter\(\s*["']([^"']+)["']/g;for(;(d=g.exec(i))!==null;)t.push(d[1]);}catch{}return {charIds:t,labelIds:s}}function K(e){let t,s,c=new Promise(r=>{s=r;}),i=[...P(e?.content),...P(e?.characters),...P(e?.labels)],a=[],d=[],g=new Set,C=[];async function A(r,o=[]){try{a=(await r("@drincs/pixi-vn")).RegisteredCharacters?.values()??[];}catch{a=[];}try{d=(await r("@drincs/pixi-vn")).RegisteredLabels?.keys()??[];}catch{d=[];}if(o.length>0){let{charIds:n,labelIds:m}=W(o),h=new Set(a.map(b=>b.id)),M=new Set(d);for(let b of n)h.has(b)||a.push({id:b});for(let b of m)M.has(b)||d.push(b);}let l=a.map(n=>n.id).join(", ")||"none";t?.logger.info(`${L} ${y.default.dim(`${a.length} character(s): [${l}], ${d.length} label(s)`)}`,{timestamp:true});}async function w(r,o){let l=await tinyglobby.glob(i,{cwd:o,absolute:true,onlyFiles:true}),n=[];for(let m of l){g.add(m);try{await r(m);}catch{n.push(m);}}await A(r,n),s();}async function T(r){for(let n of g)for(let m of r.moduleGraph.getModulesByFile(n)??[])r.moduleGraph.invalidateModule(m);try{(await r.ssrLoadModule("@drincs/pixi-vn/characters")).registeredCharacters?.clear?.();}catch{}let o=await tinyglobby.glob(i,{cwd:t.root,absolute:true,onlyFiles:true}),l=[];for(let n of o){g.add(n);try{await r.ssrLoadModule(n);}catch{l.push(n);}}await A(n=>r.ssrLoadModule(n),l);for(let n of C)n();}let E={characters:null,labels:null,manifest:null,canvasOptions:null};function x(r,o){return (l,n)=>{if(n.setHeader("Content-Type","application/json"),l.method==="GET"){let m=E[r];if(m===null){n.statusCode=404,n.end(JSON.stringify({error:`${o} not initialized`}));return}n.statusCode=200,n.end(JSON.stringify(m));return}if(l.method==="POST"){let m="";l.on("data",h=>{m+=h.toString();}),l.on("end",()=>{try{E[r]=JSON.parse(m),n.statusCode=201,n.end(JSON.stringify({message:`${o} updated successfully`}));}catch{n.statusCode=400,n.end(JSON.stringify({error:`Invalid JSON format for ${o}`}));}});}}}return {name:"vite-plugin-pixi-vn",enforce:"pre",api:{contentLoaded:c,get characters(){return a},onReload(r){C.push(r);}},configResolved(r){t=r,i.length===0&&s();},async buildStart(){if(t?.command!=="build"||i.length===0)return;let{createServer:r}=await import('vite'),o=await r({root:t.root,configFile:false,server:{middlewareMode:true},appType:"custom",logLevel:"silent",optimizeDeps:{noDiscovery:true}});try{await w(l=>o.ssrLoadModule(l),t.root);}catch{s();}finally{await o.close();}},configureServer(r){i.length>0&&w(o=>r.ssrLoadModule(o),t.root).catch(()=>{s();}),r.middlewares.use(p,x("characters","Characters")),r.middlewares.use(I,x("labels","Labels")),r.middlewares.use(v,x("manifest","Manifest")),r.middlewares.use(_,x("canvasOptions","Canvas options"));},hotUpdate({file:r,server:o}){if(i.length>0&&g.has(r))return T(o).catch(l=>{t?.logger.error(`${L} Failed to reload content.`,{error:l instanceof Error?l:new Error(String(l)),timestamp:true});}),[]}}}exports.PIXIVN_DEV_API_ASSETS_MANIFEST=v;exports.PIXIVN_DEV_API_CANVAS_OPTIONS=_;exports.PIXIVN_DEV_API_CHARACTERS=p;exports.PIXIVN_DEV_API_LABELS=I;exports.vitePluginPixivn=K;
package/dist/vite.d.cts CHANGED
@@ -1,25 +1,93 @@
1
- import { IncomingMessage, ServerResponse } from 'node:http';
1
+ import { Plugin } from 'vite';
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
+ /** @const {string} API endpoint for characters data - GET to retrieve, POST to update */
4
+ declare const PIXIVN_DEV_API_CHARACTERS = "/__pixi-vn/characters";
5
+ /** @const {string} API endpoint for narration labels - GET to retrieve, POST to update */
6
+ declare const PIXIVN_DEV_API_LABELS = "/__pixi-vn/labels";
7
+ /** @const {string} API endpoint for assets manifest - GET to retrieve, POST to update */
8
+ declare const PIXIVN_DEV_API_ASSETS_MANIFEST = "/__pixi-vn/assets/manifest";
9
+ /** @const {string} API endpoint for canvas options - GET to retrieve, POST to update */
10
+ declare const PIXIVN_DEV_API_CANVAS_OPTIONS = "/__pixi-vn/canvas-options";
11
+
12
+ /**
13
+ * Options for {@link vitePluginPixivn}.
14
+ */
15
+ interface VitePluginPixivnOptions {
16
+ /**
17
+ * Glob / path of module(s) that set up all game content as side effects:
18
+ * characters, labels, hashtag-command handlers, text-replace handlers, etc.
19
+ *
20
+ * The plugin loads these files server-side (via Vite SSR) at startup so that
21
+ * every downstream plugin that depends on the registered data — most notably
22
+ * `vitePluginInk` for JSON compilation — has the full registry available
23
+ * before it runs. This also works during `vite build`.
24
+ *
25
+ * Pointing to a barrel file that re-exports everything is the simplest option.
26
+ * All patterns are resolved relative to Vite `root`.
27
+ *
28
+ * @example "./src/content/index.ts"
29
+ * @example "./src/content/*.ts"
30
+ */
31
+ content?: string | string[];
32
+ /**
33
+ * Glob / path of module(s) whose side effects register characters via
34
+ * `RegisteredCharacters.add(...)`.
35
+ *
36
+ * Use when characters are defined separately from other content.
37
+ *
38
+ * @example "./src/characters.ts"
39
+ */
40
+ characters?: string | string[];
41
+ /**
42
+ * Glob / path of module(s) whose side effects register narration labels via
43
+ * `RegisteredLabels.register(...)`.
44
+ *
45
+ * @example "./src/*.label.ts"
46
+ */
47
+ labels?: string | string[];
48
+ }
12
49
  /**
13
- * Vite plugin to handle pixi-vn related endpoints.
14
- * This plugin only runs in development mode (serve).
15
- * Endpoints:
16
- * - GET /pixi-vn/characters -> list of registered characters
17
- * - POST /pixi-vn/characters -> update the list of registered characters
18
- * - GET /pixi-vn/labels -> list of registered labels
19
- * - POST /pixi-vn/labels -> update the list of registered labels
20
- * - GET /pixi-vn/assets/manifest -> assets manifest
21
- * - POST /pixi-vn/assets/manifest -> update assets manifest
50
+ * Creates a Vite plugin for Pixi'VN integration.
51
+ *
52
+ * **Static content loading**
53
+ *
54
+ * When {@link VitePluginPixivnOptions.content}, {@link VitePluginPixivnOptions.characters}, or
55
+ * {@link VitePluginPixivnOptions.labels} are provided, the matched files are executed server-side
56
+ * via Vite SSR at startup, populating `RegisteredCharacters`, `RegisteredLabels`, and any other
57
+ * singletons before downstream plugins (such as `vitePluginInk`) run — including during
58
+ * `vite build`.
59
+ *
60
+ * **Dev-server HTTP endpoints**
61
+ *
62
+ * - `GET /__pixi-vn/characters` — retrieve registered characters
63
+ * - `POST /__pixi-vn/characters` — *(deprecated)* update from client; use the `characters` option instead
64
+ * - `GET /__pixi-vn/labels` — retrieve narration labels
65
+ * - `POST /__pixi-vn/labels` — *(deprecated)* update from client; use the `labels` / `content` option instead
66
+ * - `GET /__pixi-vn/assets/manifest` — retrieve PIXI assets manifest
67
+ * - `POST /__pixi-vn/assets/manifest` — update assets manifest from client
68
+ * - `GET /__pixi-vn/canvas-options` — retrieve canvas rendering options
69
+ * - `POST /__pixi-vn/canvas-options` — update canvas options from client
70
+ *
71
+ * **Plugin API** (consumed by `vitePluginInk`):
72
+ * - `api.contentLoaded` — `Promise<void>` that resolves once all content modules have finished
73
+ * loading. Await this before generating JSON files.
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * // vite.config.ts
78
+ * import { defineConfig } from "vite";
79
+ * import { vitePluginPixivn } from "@drincs/pixi-vn/vite";
80
+ *
81
+ * export default defineConfig({
82
+ * plugins: [
83
+ * vitePluginPixivn({ content: "./src/content/index.ts" }),
84
+ * ],
85
+ * });
86
+ * ```
87
+ *
88
+ * @param options - Optional plugin configuration.
89
+ * @returns A Vite plugin.
22
90
  */
23
- declare function vitePluginPixivn(): Plugin;
91
+ declare function vitePluginPixivn(options?: VitePluginPixivnOptions): Plugin;
24
92
 
25
- export { vitePluginPixivn };
93
+ export { PIXIVN_DEV_API_ASSETS_MANIFEST, PIXIVN_DEV_API_CANVAS_OPTIONS, PIXIVN_DEV_API_CHARACTERS, PIXIVN_DEV_API_LABELS, type VitePluginPixivnOptions, vitePluginPixivn };
package/dist/vite.d.ts CHANGED
@@ -1,25 +1,93 @@
1
- import { IncomingMessage, ServerResponse } from 'node:http';
1
+ import { Plugin } from 'vite';
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
+ /** @const {string} API endpoint for characters data - GET to retrieve, POST to update */
4
+ declare const PIXIVN_DEV_API_CHARACTERS = "/__pixi-vn/characters";
5
+ /** @const {string} API endpoint for narration labels - GET to retrieve, POST to update */
6
+ declare const PIXIVN_DEV_API_LABELS = "/__pixi-vn/labels";
7
+ /** @const {string} API endpoint for assets manifest - GET to retrieve, POST to update */
8
+ declare const PIXIVN_DEV_API_ASSETS_MANIFEST = "/__pixi-vn/assets/manifest";
9
+ /** @const {string} API endpoint for canvas options - GET to retrieve, POST to update */
10
+ declare const PIXIVN_DEV_API_CANVAS_OPTIONS = "/__pixi-vn/canvas-options";
11
+
12
+ /**
13
+ * Options for {@link vitePluginPixivn}.
14
+ */
15
+ interface VitePluginPixivnOptions {
16
+ /**
17
+ * Glob / path of module(s) that set up all game content as side effects:
18
+ * characters, labels, hashtag-command handlers, text-replace handlers, etc.
19
+ *
20
+ * The plugin loads these files server-side (via Vite SSR) at startup so that
21
+ * every downstream plugin that depends on the registered data — most notably
22
+ * `vitePluginInk` for JSON compilation — has the full registry available
23
+ * before it runs. This also works during `vite build`.
24
+ *
25
+ * Pointing to a barrel file that re-exports everything is the simplest option.
26
+ * All patterns are resolved relative to Vite `root`.
27
+ *
28
+ * @example "./src/content/index.ts"
29
+ * @example "./src/content/*.ts"
30
+ */
31
+ content?: string | string[];
32
+ /**
33
+ * Glob / path of module(s) whose side effects register characters via
34
+ * `RegisteredCharacters.add(...)`.
35
+ *
36
+ * Use when characters are defined separately from other content.
37
+ *
38
+ * @example "./src/characters.ts"
39
+ */
40
+ characters?: string | string[];
41
+ /**
42
+ * Glob / path of module(s) whose side effects register narration labels via
43
+ * `RegisteredLabels.register(...)`.
44
+ *
45
+ * @example "./src/*.label.ts"
46
+ */
47
+ labels?: string | string[];
48
+ }
12
49
  /**
13
- * Vite plugin to handle pixi-vn related endpoints.
14
- * This plugin only runs in development mode (serve).
15
- * Endpoints:
16
- * - GET /pixi-vn/characters -> list of registered characters
17
- * - POST /pixi-vn/characters -> update the list of registered characters
18
- * - GET /pixi-vn/labels -> list of registered labels
19
- * - POST /pixi-vn/labels -> update the list of registered labels
20
- * - GET /pixi-vn/assets/manifest -> assets manifest
21
- * - POST /pixi-vn/assets/manifest -> update assets manifest
50
+ * Creates a Vite plugin for Pixi'VN integration.
51
+ *
52
+ * **Static content loading**
53
+ *
54
+ * When {@link VitePluginPixivnOptions.content}, {@link VitePluginPixivnOptions.characters}, or
55
+ * {@link VitePluginPixivnOptions.labels} are provided, the matched files are executed server-side
56
+ * via Vite SSR at startup, populating `RegisteredCharacters`, `RegisteredLabels`, and any other
57
+ * singletons before downstream plugins (such as `vitePluginInk`) run — including during
58
+ * `vite build`.
59
+ *
60
+ * **Dev-server HTTP endpoints**
61
+ *
62
+ * - `GET /__pixi-vn/characters` — retrieve registered characters
63
+ * - `POST /__pixi-vn/characters` — *(deprecated)* update from client; use the `characters` option instead
64
+ * - `GET /__pixi-vn/labels` — retrieve narration labels
65
+ * - `POST /__pixi-vn/labels` — *(deprecated)* update from client; use the `labels` / `content` option instead
66
+ * - `GET /__pixi-vn/assets/manifest` — retrieve PIXI assets manifest
67
+ * - `POST /__pixi-vn/assets/manifest` — update assets manifest from client
68
+ * - `GET /__pixi-vn/canvas-options` — retrieve canvas rendering options
69
+ * - `POST /__pixi-vn/canvas-options` — update canvas options from client
70
+ *
71
+ * **Plugin API** (consumed by `vitePluginInk`):
72
+ * - `api.contentLoaded` — `Promise<void>` that resolves once all content modules have finished
73
+ * loading. Await this before generating JSON files.
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * // vite.config.ts
78
+ * import { defineConfig } from "vite";
79
+ * import { vitePluginPixivn } from "@drincs/pixi-vn/vite";
80
+ *
81
+ * export default defineConfig({
82
+ * plugins: [
83
+ * vitePluginPixivn({ content: "./src/content/index.ts" }),
84
+ * ],
85
+ * });
86
+ * ```
87
+ *
88
+ * @param options - Optional plugin configuration.
89
+ * @returns A Vite plugin.
22
90
  */
23
- declare function vitePluginPixivn(): Plugin;
91
+ declare function vitePluginPixivn(options?: VitePluginPixivnOptions): Plugin;
24
92
 
25
- export { vitePluginPixivn };
93
+ export { PIXIVN_DEV_API_ASSETS_MANIFEST, PIXIVN_DEV_API_CANVAS_OPTIONS, PIXIVN_DEV_API_CHARACTERS, PIXIVN_DEV_API_LABELS, type VitePluginPixivnOptions, vitePluginPixivn };
package/dist/vite.mjs CHANGED
@@ -1 +1 @@
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};
1
+ import {a as a$1,b,c as c$1,d}from'./chunk-3BBZHKU4.mjs';export{c as PIXIVN_DEV_API_ASSETS_MANIFEST,d as PIXIVN_DEV_API_CANVAS_OPTIONS,a as PIXIVN_DEV_API_CHARACTERS,b as PIXIVN_DEV_API_LABELS}from'./chunk-3BBZHKU4.mjs';import {a,c}from'./chunk-K7JIC2F2.mjs';import {readFileSync}from'fs';import {glob}from'tinyglobby';var E=a((H,C)=>{var f=process||{},R=f.argv||[],u=f.env||{},D=!(u.NO_COLOR||R.includes("--no-color"))&&(!!u.FORCE_COLOR||R.includes("--color")||f.platform==="win32"||(f.stdout||{}).isTTY&&u.TERM!=="dumb"||!!u.CI),k=(n,t,c=n)=>m=>{let o=""+m,i=o.indexOf(t,n.length);return ~i?n+X(o,t,c,i)+t:n+o+t},X=(n,t,c,m)=>{let o="",i=0;do o+=n.substring(i,m)+c,i=m+t.length,m=n.indexOf(t,i);while(~m);return o+n.substring(i)},B=(n=D)=>{let t=n?k:()=>String;return {isColorSupported:n,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};C.exports=B();C.exports.createColors=B;});var w=c(E(),1);var L=w.default.cyan("(pixi-vn)");function S(n){return n?Array.isArray(n)?n:[n]:[]}function G(n){let t=[],c=[];for(let m of n)try{let o=readFileSync(m,"utf-8"),i=/newLabel\(\s*["']([^"']+)["']/g,d;for(;(d=i.exec(o))!==null;)c.push(d[1]);let g=/new\s+\w*[Cc]haracter\(\s*["']([^"']+)["']/g;for(;(d=g.exec(o))!==null;)t.push(d[1]);}catch{}return {charIds:t,labelIds:c}}function J(n){let t,c,m=new Promise(e=>{c=e;}),o=[...S(n?.content),...S(n?.characters),...S(n?.labels)],i=[],d$1=[],g=new Set,P=[];async function A(e,s=[]){try{i=(await e("@drincs/pixi-vn")).RegisteredCharacters?.values()??[];}catch{i=[];}try{d$1=(await e("@drincs/pixi-vn")).RegisteredLabels?.keys()??[];}catch{d$1=[];}if(s.length>0){let{charIds:r,labelIds:l}=G(s),h=new Set(i.map(b=>b.id)),M=new Set(d$1);for(let b of r)h.has(b)||i.push({id:b});for(let b of l)M.has(b)||d$1.push(b);}let a=i.map(r=>r.id).join(", ")||"none";t?.logger.info(`${L} ${w.default.dim(`${i.length} character(s): [${a}], ${d$1.length} label(s)`)}`,{timestamp:true});}async function _(e,s){let a=await glob(o,{cwd:s,absolute:true,onlyFiles:true}),r=[];for(let l of a){g.add(l);try{await e(l);}catch{r.push(l);}}await A(e,r),c();}async function N(e){for(let r of g)for(let l of e.moduleGraph.getModulesByFile(r)??[])e.moduleGraph.invalidateModule(l);try{(await e.ssrLoadModule("@drincs/pixi-vn/characters")).registeredCharacters?.clear?.();}catch{}let s=await glob(o,{cwd:t.root,absolute:true,onlyFiles:true}),a=[];for(let r of s){g.add(r);try{await e.ssrLoadModule(r);}catch{a.push(r);}}await A(r=>e.ssrLoadModule(r),a);for(let r of P)r();}let O={characters:null,labels:null,manifest:null,canvasOptions:null};function x(e,s){return (a,r)=>{if(r.setHeader("Content-Type","application/json"),a.method==="GET"){let l=O[e];if(l===null){r.statusCode=404,r.end(JSON.stringify({error:`${s} not initialized`}));return}r.statusCode=200,r.end(JSON.stringify(l));return}if(a.method==="POST"){let l="";a.on("data",h=>{l+=h.toString();}),a.on("end",()=>{try{O[e]=JSON.parse(l),r.statusCode=201,r.end(JSON.stringify({message:`${s} updated successfully`}));}catch{r.statusCode=400,r.end(JSON.stringify({error:`Invalid JSON format for ${s}`}));}});}}}return {name:"vite-plugin-pixi-vn",enforce:"pre",api:{contentLoaded:m,get characters(){return i},onReload(e){P.push(e);}},configResolved(e){t=e,o.length===0&&c();},async buildStart(){if(t?.command!=="build"||o.length===0)return;let{createServer:e}=await import('vite'),s=await e({root:t.root,configFile:false,server:{middlewareMode:true},appType:"custom",logLevel:"silent",optimizeDeps:{noDiscovery:true}});try{await _(a=>s.ssrLoadModule(a),t.root);}catch{c();}finally{await s.close();}},configureServer(e){o.length>0&&_(s=>e.ssrLoadModule(s),t.root).catch(()=>{c();}),e.middlewares.use(a$1,x("characters","Characters")),e.middlewares.use(b,x("labels","Labels")),e.middlewares.use(c$1,x("manifest","Manifest")),e.middlewares.use(d,x("canvasOptions","Canvas options"));},hotUpdate({file:e,server:s}){if(o.length>0&&g.has(e))return N(s).catch(a=>{t?.logger.error(`${L} Failed to reload content.`,{error:a instanceof Error?a:new Error(String(a)),timestamp:true});}),[]}}}export{J as vitePluginPixivn};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drincs/pixi-vn",
3
- "version": "1.8.0",
3
+ "version": "1.8.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",
@@ -141,16 +141,23 @@
141
141
  "homepage": "https://pixi-vn.web.app/",
142
142
  "funding": "https://github.com/DRincs-Productions/pixi-vn?sponsor=1",
143
143
  "dependencies": {
144
- "@pixi/devtools": "^2.0.1",
145
- "motion": "^12.38.0",
146
- "pixi.js": "^8.18.1",
147
- "tone": "^15.1.22"
144
+ "@pixi/devtools": ">=2.0.0",
145
+ "motion": ">=12.38.0",
146
+ "pixi.js": ">=8.17.0",
147
+ "tinyglobby": "^0.2.16",
148
+ "tone": ">=15.1.0"
148
149
  },
149
150
  "peerDependencies": {
150
151
  "@pixi/devtools": ">=2.0.0",
151
152
  "motion": ">=12.38.0",
152
153
  "pixi.js": ">=8.17.0",
153
- "tone": ">=15.1.0"
154
+ "tone": ">=15.1.0",
155
+ "vite": ">=5.0.0"
156
+ },
157
+ "peerDependenciesMeta": {
158
+ "vite": {
159
+ "optional": true
160
+ }
154
161
  },
155
162
  "devDependencies": {
156
163
  "@biomejs/biome": "^2.4.12",
@@ -162,6 +169,7 @@
162
169
  "lru-cache": "11.2.7",
163
170
  "microdiff": "^1.5.0",
164
171
  "mime-db": "^1.54.0",
172
+ "picocolors": "^1.1.1",
165
173
  "ts-node": "^10.9.2",
166
174
  "tsconfig-paths": "^4.2.0",
167
175
  "tsup": "^8.5.1",
@@ -1 +0,0 @@
1
- var f=Object.defineProperty;var g=a=>{throw TypeError(a)};var i=(a,b,c)=>b in a?f(a,b,{enumerable:true,configurable:true,writable:true,value:c}):a[b]=c;var l=(a,b)=>{for(var c in b)f(a,c,{get:b[c],enumerable:true});};var m=(a,b,c)=>i(a,typeof b!="symbol"?b+"":b,c),e=(a,b,c)=>b.has(a)||g("Cannot "+c);var j=(a,b,c)=>(e(a,b,"read from private field"),c?c.call(a):b.get(a)),n=(a,b,c)=>b.has(a)?g("Cannot add the same private member more than once"):b instanceof WeakSet?b.add(a):b.set(a,c),k=(a,b,c,d)=>(e(a,b,"write to private field"),d?d.call(a,c):b.set(a,c),c),o=(a,b,c)=>(e(a,b,"access private method"),c);var p=(a,b,c,d)=>({set _(h){k(a,b,h,c);},get _(){return j(a,b,d)}});export{l as a,m as b,j as c,n as d,k as e,o as f,p as g};
@@ -1 +0,0 @@
1
- import {k as k$1,m,j,l,n}from'./chunk-IWAXXFXE.mjs';import {e,g,f as f$1,d}from'./chunk-6HI66YQL.mjs';import {GameUnifier}from'@drincs/pixi-vn/core';var T;(s=>{s.storage=new e({cacheSize:50}),s.defaultStorage=new e({cacheSize:10}),s.tempStorageDeadlines=new Map;let n;function c(a){s.tempStorageDeadlines.forEach((l,o)=>{l>a&&(s.storage.delete(`${k$1}:${o}`),n?.onClearOldTempVariable?.(o),s.tempStorageDeadlines.delete(o));});}s.clearOldTempVariables=c;function h(a){n=a;}s.setExternalStoreHandler=h;function V(a,l,o){o==null?s.storage.delete(`${a}:${l}`):s.storage.set(`${a}:${l}`,o),n?.onSetVariable?.(l,o);}s.setVariable=V;function O(a,l){let o=s.storage.get(`${a}:${l}`);return g(o)}s.getVariable=O;function M(a,l){s.storage.delete(`${a}:${l}`),n?.onRemoveVariable?.(l);}s.removeVariable=M;function D(a,l){let o=s.storage.get(m)||[];if(l)o.includes(a)||o.push(a);else {let x=o.indexOf(a);x>-1&&o.splice(x,1);}s.storage.set(m,o);}s.setFlag=D;function R(a){return (s.storage.get(m)||[]).includes(a)}s.getFlag=R;})(T||(T={}));var r=T;var S=class{get base(){return r.storage.map}get cache(){return r.storage.cache}get tempStorageDeadlines(){return r.tempStorageDeadlines}set default(t){Object.entries(t).forEach(([e,n])=>{r.defaultStorage.map.set(e,n);});}set(t,e){return r.setVariable(j,t,e)}get(t){let e=r.getVariable(k$1,t);return e===void 0&&(e=r.getVariable(j,t)),e===void 0&&(e=g(r.defaultStorage.get(t))),e}remove(t){return this.removeTempVariable(t),r.removeVariable(j,t)}setTempVariable(t,e){if(e==null){this.removeTempVariable(t);return}else r.setVariable(k$1,t,e),this.tempStorageDeadlines.has(t)||this.tempStorageDeadlines.set(t,GameUnifier.openedLabels);}removeTempVariable(t){r.removeVariable(k$1,t),this.tempStorageDeadlines.has(t)&&this.tempStorageDeadlines.delete(t);}setFlag(t,e){return r.setFlag(t,e)}getFlag(t){return r.getFlag(t)}setStorageHandler(t){r.setExternalStoreHandler(t);}clear(){this.base.clear(),this.cache.clear(),this.tempStorageDeadlines.clear();}export(){let t=[];[...this.base.keys()].forEach(n=>{t.push({key:n,value:this.base.get(n)});});let e=[];return [...r.tempStorageDeadlines.keys()].forEach(n=>{e.push({key:n,value:this.tempStorageDeadlines.get(n)});}),g({main:t,tempDeadlines:e})}restore(t){this.clear();try{t?(t.base?.forEach(e=>{switch(e.key){case "___current_dialogue_memory___":r.setVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY,e.value);break;case "___last_dialogue_added_in_step_memory___":r.setVariable(l,n.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,e.value);break;case "___current_menu_options_memory___":r.setVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY,e.value);break;case "___last_menu_options_added_in_step_memory___":r.setVariable(l,n.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,e.value);break;case "_input_value_":r.setVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY,e.value);break;case "___last_input_added_in_step_memory___":r.setVariable(l,n.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,e.value);break;case "___current_input_info_memory___":r.setVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY,e.value);break;case "___opened_labels_counter___":r.setVariable(l,n.OPENED_LABELS_COUNTER_KEY,e.value);break;case "___all_choices_made___":r.setVariable(l,n.ALL_CHOICES_MADE_KEY,e.value);break;case "___current_step_times_counter___":r.setVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY,e.value);break;case "___last_step_glued___":r.setVariable(l,n.LAST_STEP_GLUED,e.value);break;default:r.setVariable(j,e.key,e.value);}}),t.temp?.forEach(e=>{r.setVariable(k$1,e.key,e.value);}),t.flags?.forEach(e=>{r.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);})):f$1.warn("No storage data found");}catch(e){f$1.error("Error importing data",e);}}};var f=class{constructor(t,e){d(this,"id");d(this,"categoryId");this.categoryId=t,this.id=e,this.migrateOldStorage();}migrateOldStorage(t=this.categoryId){let e=r.getVariable(j,t);e&&(Object.entries(e).forEach(([n,c])=>{typeof c=="object"&&c!==null&&Object.entries(c).forEach(([h,V])=>{r.setVariable(this.categoryId,`${n}:${h}`,V);});}),r.removeVariable(j,t));}setStorageProperty(t,e){r.setVariable(this.categoryId,`${this.id}:${t}`,e);}getStorageProperty(t,e=this.id){return r.getVariable(this.categoryId,`${e}:${t}`)}};var k=new S;export{r as a,f as b,k as c};