@drincs/pixi-vn 1.8.11 → 1.8.13
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/{ContainerMemory-BjcfYRU7.d.cts → ContainerMemory-D2HtgX7w.d.cts} +1 -1
- package/dist/{ContainerMemory-BjcfYRU7.d.ts → ContainerMemory-D2HtgX7w.d.ts} +1 -1
- package/dist/{HistoryChoiceMenuOption-CEmjDDJH.d.cts → HistoryChoiceMenuOption-BMsYentw.d.cts} +1 -1
- package/dist/{HistoryChoiceMenuOption-CN7NkcxU.d.ts → HistoryChoiceMenuOption-DQ-pnuPU.d.ts} +1 -1
- package/dist/{HistoryGameState-3ztYdv84.d.cts → HistoryGameState-C28NcKKl.d.cts} +1 -1
- package/dist/{HistoryGameState-D4t2fY9x.d.ts → HistoryGameState-CmjUtlkV.d.ts} +1 -1
- package/dist/{HistoryStep-DtOryKAZ.d.cts → HistoryStep-G9dUn0Lf.d.cts} +36 -4
- package/dist/{HistoryStep-DtOryKAZ.d.ts → HistoryStep-G9dUn0Lf.d.ts} +36 -4
- package/dist/{OpenedLabel-t6PvSzaL.d.cts → OpenedLabel-BxfL31aQ.d.cts} +1 -1
- package/dist/{OpenedLabel-DJby8qPc.d.ts → OpenedLabel-DLfFuZgk.d.ts} +1 -1
- package/dist/{SoundManagerInterface-TgOPqm2L.d.cts → SoundManagerInterface-Dd0b88_N.d.cts} +2 -2
- package/dist/{SoundManagerInterface-TgOPqm2L.d.ts → SoundManagerInterface-Dd0b88_N.d.ts} +2 -2
- package/dist/canvas.d.cts +2 -2
- package/dist/canvas.d.ts +2 -2
- package/dist/characters.cjs +1 -1
- package/dist/characters.d.cts +47 -5
- package/dist/characters.d.ts +47 -5
- package/dist/characters.mjs +1 -1
- package/dist/history.d.cts +3 -3
- package/dist/history.d.ts +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.mjs +1 -1
- package/dist/narration.cjs +1 -1
- package/dist/narration.d.cts +15 -10
- package/dist/narration.d.ts +15 -10
- package/dist/narration.mjs +2 -2
- package/dist/sound.d.cts +2 -2
- package/dist/sound.d.ts +2 -2
- package/dist/vite-listener.cjs +1 -1
- package/dist/vite-listener.d.cts +1 -1
- package/dist/vite-listener.d.ts +1 -1
- package/dist/vite-listener.mjs +1 -1
- package/dist/vite.cjs +2 -1
- package/dist/vite.d.cts +47 -2
- package/dist/vite.d.ts +47 -2
- package/dist/vite.mjs +2 -1
- package/package.json +1 -1
package/dist/vite.d.cts
CHANGED
|
@@ -45,6 +45,24 @@ interface VitePluginPixivnOptions {
|
|
|
45
45
|
* @example "./src/*.label.ts"
|
|
46
46
|
*/
|
|
47
47
|
labels?: string | string[];
|
|
48
|
+
/**
|
|
49
|
+
* Path to the auto-generated TypeScript declaration file that augments
|
|
50
|
+
* `PixivnCharacterIds` (in `@drincs/pixi-vn/characters`) and `PixivnLabelIds`
|
|
51
|
+
* (in `@drincs/pixi-vn/narration`) with all currently known IDs.
|
|
52
|
+
*
|
|
53
|
+
* When provided, the plugin generates (or overwrites) this file:
|
|
54
|
+
* - after all content modules have been loaded at startup,
|
|
55
|
+
* - after every hot-reload of a watched content file,
|
|
56
|
+
* - whenever `api.setExternalLabels` or `api.clearExternalLabels` is called.
|
|
57
|
+
*
|
|
58
|
+
* The generated file is **excluded from HMR** so that updating it never
|
|
59
|
+
* triggers a full-page reload.
|
|
60
|
+
*
|
|
61
|
+
* The path may be absolute or relative to Vite `root`.
|
|
62
|
+
*
|
|
63
|
+
* @example "./src/pixi-vn.gen.d.ts"
|
|
64
|
+
*/
|
|
65
|
+
typeFilePath?: string;
|
|
48
66
|
}
|
|
49
67
|
/**
|
|
50
68
|
* Creates a Vite plugin for Pixi'VN integration.
|
|
@@ -57,6 +75,26 @@ interface VitePluginPixivnOptions {
|
|
|
57
75
|
* singletons before downstream plugins (such as `vitePluginInk`) run — including during
|
|
58
76
|
* `vite build`.
|
|
59
77
|
*
|
|
78
|
+
* **Auto-generated type file**
|
|
79
|
+
*
|
|
80
|
+
* When {@link VitePluginPixivnOptions.typeFilePath} is provided, the plugin writes a
|
|
81
|
+
* TypeScript declaration file that augments `PixivnCharacterIds` in `@drincs/pixi-vn/characters`
|
|
82
|
+
* and `PixivnLabelIds` in `@drincs/pixi-vn/narration` with all currently known IDs.
|
|
83
|
+
* This narrows `CharacterIdType` and `LabelIdType` from `string` to unions of known literals,
|
|
84
|
+
* giving compile-time safety for character lookups, `narration.call`, `narration.jump`, etc.
|
|
85
|
+
*
|
|
86
|
+
* The file is regenerated whenever the character or label set changes (content reload or
|
|
87
|
+
* external-label updates). It is **excluded from HMR** so regenerating it never triggers a page reload.
|
|
88
|
+
*
|
|
89
|
+
* **External label providers**
|
|
90
|
+
*
|
|
91
|
+
* Other Vite plugins can inject label IDs via the plugin API without needing to register
|
|
92
|
+
* them through SSR-loaded modules:
|
|
93
|
+
* - `api.setExternalLabels(providerId, labels)` — registers (or replaces) the label list for
|
|
94
|
+
* the given provider and regenerates the type file.
|
|
95
|
+
* - `api.clearExternalLabels(providerId)` — removes all labels for the given provider and
|
|
96
|
+
* regenerates the type file.
|
|
97
|
+
*
|
|
60
98
|
* **Dev-server HTTP endpoints**
|
|
61
99
|
*
|
|
62
100
|
* - `GET /__pixi-vn/characters` — retrieve registered characters
|
|
@@ -70,7 +108,11 @@ interface VitePluginPixivnOptions {
|
|
|
70
108
|
*
|
|
71
109
|
* **Plugin API** (consumed by `vitePluginInk`):
|
|
72
110
|
* - `api.contentLoaded` — `Promise<void>` that resolves once all content modules have finished
|
|
73
|
-
* loading.
|
|
111
|
+
* loading. Await this before generating JSON files.
|
|
112
|
+
* - `api.characters` — the list of registered characters (populated after `contentLoaded`).
|
|
113
|
+
* - `api.onReload(cb)` — register a callback that fires after every hot-content-reload.
|
|
114
|
+
* - `api.setExternalLabels(providerId, labels)` — add/replace labels from an external provider.
|
|
115
|
+
* - `api.clearExternalLabels(providerId)` — remove labels previously set for a provider.
|
|
74
116
|
*
|
|
75
117
|
* @example
|
|
76
118
|
* ```ts
|
|
@@ -80,7 +122,10 @@ interface VitePluginPixivnOptions {
|
|
|
80
122
|
*
|
|
81
123
|
* export default defineConfig({
|
|
82
124
|
* plugins: [
|
|
83
|
-
* vitePluginPixivn({
|
|
125
|
+
* vitePluginPixivn({
|
|
126
|
+
* content: "./src/content/index.ts",
|
|
127
|
+
* typeFilePath: "./src/pixi-vn.gen.d.ts",
|
|
128
|
+
* }),
|
|
84
129
|
* ],
|
|
85
130
|
* });
|
|
86
131
|
* ```
|
package/dist/vite.d.ts
CHANGED
|
@@ -45,6 +45,24 @@ interface VitePluginPixivnOptions {
|
|
|
45
45
|
* @example "./src/*.label.ts"
|
|
46
46
|
*/
|
|
47
47
|
labels?: string | string[];
|
|
48
|
+
/**
|
|
49
|
+
* Path to the auto-generated TypeScript declaration file that augments
|
|
50
|
+
* `PixivnCharacterIds` (in `@drincs/pixi-vn/characters`) and `PixivnLabelIds`
|
|
51
|
+
* (in `@drincs/pixi-vn/narration`) with all currently known IDs.
|
|
52
|
+
*
|
|
53
|
+
* When provided, the plugin generates (or overwrites) this file:
|
|
54
|
+
* - after all content modules have been loaded at startup,
|
|
55
|
+
* - after every hot-reload of a watched content file,
|
|
56
|
+
* - whenever `api.setExternalLabels` or `api.clearExternalLabels` is called.
|
|
57
|
+
*
|
|
58
|
+
* The generated file is **excluded from HMR** so that updating it never
|
|
59
|
+
* triggers a full-page reload.
|
|
60
|
+
*
|
|
61
|
+
* The path may be absolute or relative to Vite `root`.
|
|
62
|
+
*
|
|
63
|
+
* @example "./src/pixi-vn.gen.d.ts"
|
|
64
|
+
*/
|
|
65
|
+
typeFilePath?: string;
|
|
48
66
|
}
|
|
49
67
|
/**
|
|
50
68
|
* Creates a Vite plugin for Pixi'VN integration.
|
|
@@ -57,6 +75,26 @@ interface VitePluginPixivnOptions {
|
|
|
57
75
|
* singletons before downstream plugins (such as `vitePluginInk`) run — including during
|
|
58
76
|
* `vite build`.
|
|
59
77
|
*
|
|
78
|
+
* **Auto-generated type file**
|
|
79
|
+
*
|
|
80
|
+
* When {@link VitePluginPixivnOptions.typeFilePath} is provided, the plugin writes a
|
|
81
|
+
* TypeScript declaration file that augments `PixivnCharacterIds` in `@drincs/pixi-vn/characters`
|
|
82
|
+
* and `PixivnLabelIds` in `@drincs/pixi-vn/narration` with all currently known IDs.
|
|
83
|
+
* This narrows `CharacterIdType` and `LabelIdType` from `string` to unions of known literals,
|
|
84
|
+
* giving compile-time safety for character lookups, `narration.call`, `narration.jump`, etc.
|
|
85
|
+
*
|
|
86
|
+
* The file is regenerated whenever the character or label set changes (content reload or
|
|
87
|
+
* external-label updates). It is **excluded from HMR** so regenerating it never triggers a page reload.
|
|
88
|
+
*
|
|
89
|
+
* **External label providers**
|
|
90
|
+
*
|
|
91
|
+
* Other Vite plugins can inject label IDs via the plugin API without needing to register
|
|
92
|
+
* them through SSR-loaded modules:
|
|
93
|
+
* - `api.setExternalLabels(providerId, labels)` — registers (or replaces) the label list for
|
|
94
|
+
* the given provider and regenerates the type file.
|
|
95
|
+
* - `api.clearExternalLabels(providerId)` — removes all labels for the given provider and
|
|
96
|
+
* regenerates the type file.
|
|
97
|
+
*
|
|
60
98
|
* **Dev-server HTTP endpoints**
|
|
61
99
|
*
|
|
62
100
|
* - `GET /__pixi-vn/characters` — retrieve registered characters
|
|
@@ -70,7 +108,11 @@ interface VitePluginPixivnOptions {
|
|
|
70
108
|
*
|
|
71
109
|
* **Plugin API** (consumed by `vitePluginInk`):
|
|
72
110
|
* - `api.contentLoaded` — `Promise<void>` that resolves once all content modules have finished
|
|
73
|
-
* loading.
|
|
111
|
+
* loading. Await this before generating JSON files.
|
|
112
|
+
* - `api.characters` — the list of registered characters (populated after `contentLoaded`).
|
|
113
|
+
* - `api.onReload(cb)` — register a callback that fires after every hot-content-reload.
|
|
114
|
+
* - `api.setExternalLabels(providerId, labels)` — add/replace labels from an external provider.
|
|
115
|
+
* - `api.clearExternalLabels(providerId)` — remove labels previously set for a provider.
|
|
74
116
|
*
|
|
75
117
|
* @example
|
|
76
118
|
* ```ts
|
|
@@ -80,7 +122,10 @@ interface VitePluginPixivnOptions {
|
|
|
80
122
|
*
|
|
81
123
|
* export default defineConfig({
|
|
82
124
|
* plugins: [
|
|
83
|
-
* vitePluginPixivn({
|
|
125
|
+
* vitePluginPixivn({
|
|
126
|
+
* content: "./src/content/index.ts",
|
|
127
|
+
* typeFilePath: "./src/pixi-vn.gen.d.ts",
|
|
128
|
+
* }),
|
|
84
129
|
* ],
|
|
85
130
|
* });
|
|
86
131
|
* ```
|
package/dist/vite.mjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
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
|
|
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 {mkdirSync,writeFileSync,readFileSync}from'fs';import {isAbsolute,resolve,dirname}from'path';import {glob}from'tinyglobby';var F=a((ee,P)=>{var h=process||{},V=h.argv||[],f=h.env||{},G=!(f.NO_COLOR||V.includes("--no-color"))&&(!!f.FORCE_COLOR||V.includes("--color")||h.platform==="win32"||(h.stdout||{}).isTTY&&f.TERM!=="dumb"||!!f.CI),j=(i,e,c=i)=>d=>{let o=""+d,a=o.indexOf(e,i.length);return ~a?i+H(o,e,c,a)+e:i+o+e},H=(i,e,c,d)=>{let o="",a=0;do o+=i.substring(a,d)+c,a=d+e.length,d=i.indexOf(e,a);while(~d);return o+i.substring(a)},N=(i=G)=>{let e=i?j:()=>String;return {isColorSupported:i,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};P.exports=N();P.exports.createColors=N;});var _=c(F(),1);var C=_.default.cyan("(pixi-vn)");function A(i){return i?Array.isArray(i)?i:[i]:[]}function Z(i){let e=[],c=[];for(let d of i)try{let o=readFileSync(d,"utf-8"),a=/newLabel\(\s*["']([^"']+)["']/g,m;for(;(m=a.exec(o))!==null;)c.push(m[1]);let b=/new\s+\w*[Cc]haracter\(\s*["']([^"']+)["']/g;for(;(m=b.exec(o))!==null;)e.push(m[1]);}catch{}return {charIds:e,labelIds:c}}function q(i){let e,c,d$1=new Promise(t=>{c=t;}),o=[...A(i?.content),...A(i?.characters),...A(i?.labels)],a=[],m=[],b$1=new Set,E=[],p=new Map;function R(){if(!i?.typeFilePath||!e)return null;let t=i.typeFilePath;return isAbsolute(t)?t:resolve(e.root,t)}function M(){let t=[...m,...Array.from(p.values()).flat()];return Array.from(new Set(t))}function k(t,n,s){mkdirSync(dirname(t),{recursive:true});let r=["// @ts-nocheck","/* eslint-disable */","// noinspection JSUnusedGlobalSymbols","// This file is auto-generated by @drincs/pixi-vn vite plugin. Do not edit manually."];if(n.length>0){r.push('declare module "@drincs/pixi-vn/characters" {'),r.push(" interface PixivnCharacterIds {");for(let l of n)r.push(` ${JSON.stringify(l)}: never;`);r.push(" }"),r.push("}");}if(s.length>0){r.push('declare module "@drincs/pixi-vn/narration" {'),r.push(" interface PixivnLabelIds {");for(let l of s)r.push(` ${JSON.stringify(l)}: never;`);r.push(" }"),r.push("}");}r.push("export {};"),r.push(""),writeFileSync(t,r.join(`
|
|
2
|
+
`),"utf-8");}function u(){let t=R();if(t)try{k(t,a.map(n=>n.id),M());}catch(n){e?.logger.error(`${C} Failed to write type file "${t}".`,{error:n instanceof Error?n:new Error(String(n)),timestamp:true});}}async function O(t,n=[]){try{a=(await t("@drincs/pixi-vn/characters")).RegisteredCharacters?.values()??[];}catch{a=[];}try{m=(await t("@drincs/pixi-vn/narration")).RegisteredLabels?.keys()??[];}catch{m=[];}if(n.length>0){let{charIds:r,labelIds:l}=Z(n),y=new Set(a.map(g=>g.id)),$=new Set(m);for(let g of r)y.has(g)||a.push({id:g});for(let g of l)$.has(g)||m.push(g);}let s=a.map(r=>r.id).join(", ")||"none";e?.logger.info(`${C} ${_.default.dim(`${a.length} character(s): [${s}], ${m.length} label(s)`)}`,{timestamp:true});}async function L(t,n){try{await t("@drincs/pixi-vn/characters");}catch{}try{await t("@drincs/pixi-vn/narration");}catch{}let s=await glob(o,{cwd:n,absolute:true,onlyFiles:true}),r=[];for(let l of s){b$1.add(l);try{await t(l);}catch{r.push(l);}}await O(t,r),u(),c();}async function D(t){for(let r of b$1)for(let l of t.moduleGraph.getModulesByFile(r)??[])t.moduleGraph.invalidateModule(l);try{(await t.ssrLoadModule("@drincs/pixi-vn/characters")).RegisteredCharacters?.clear?.();}catch{}try{(await t.ssrLoadModule("@drincs/pixi-vn/narration")).RegisteredLabels?.clear?.();}catch{}let n=await glob(o,{cwd:e.root,absolute:true,onlyFiles:true}),s=[];for(let r of n){b$1.add(r);try{await t.ssrLoadModule(r);}catch{s.push(r);}}await O(r=>t.ssrLoadModule(r),s),u();for(let r of E)r();}let B={characters:null,labels:null,manifest:null,canvasOptions:null};function x(t,n){return (s,r)=>{if(r.setHeader("Content-Type","application/json"),s.method==="GET"){let l=B[t];if(l===null){r.statusCode=404,r.end(JSON.stringify({error:`${n} not initialized`}));return}r.statusCode=200,r.end(JSON.stringify(l));return}if(s.method==="POST"){let l="";s.on("data",y=>{l+=y.toString();}),s.on("end",()=>{try{B[t]=JSON.parse(l),r.statusCode=201,r.end(JSON.stringify({message:`${n} updated successfully`}));}catch{r.statusCode=400,r.end(JSON.stringify({error:`Invalid JSON format for ${n}`}));}});}}}return {name:"vite-plugin-pixi-vn",enforce:"pre",api:{contentLoaded:d$1,get characters(){return a},onReload(t){E.push(t);},setExternalLabels(t,n){p.set(t,n),u();},clearExternalLabels(t){p.delete(t),u();}},config(t,n){if(n.command==="serve"&&o.length>0)return {ssr:{noExternal:["@drincs/pixi-vn"]}}},configResolved(t){e=t,o.length===0&&c();},async buildStart(){if(e?.command!=="build"||o.length===0)return;let{createServer:t}=await import('vite'),n=await t({root:e.root,configFile:false,server:{middlewareMode:true},appType:"custom",logLevel:"silent",optimizeDeps:{noDiscovery:true},ssr:{noExternal:["@drincs/pixi-vn"]}});try{await L(s=>n.ssrLoadModule(s),e.root);}catch{c();}finally{await n.close();}},configureServer(t){o.length>0&&L(n=>t.ssrLoadModule(n),e.root).catch(()=>{c();}),t.middlewares.use(a$1,x("characters","Characters")),t.middlewares.use(b,x("labels","Labels")),t.middlewares.use(c$1,x("manifest","Manifest")),t.middlewares.use(d,x("canvasOptions","Canvas options"));},hotUpdate({file:t,server:n}){let s=R();if(s&&t===s)return [];if(o.length>0&&b$1.has(t))return D(n).catch(r=>{e?.logger.error(`${C} Failed to reload content.`,{error:r instanceof Error?r:new Error(String(r)),timestamp:true});}),[]}}}export{q as vitePluginPixivn};
|