@drincs/pixi-vn 1.8.17 → 1.8.19

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/vite.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var fs=require('fs'),path=require('path'),tinyglobby=require('tinyglobby');var X=Object.create;var L=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var H=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var z=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var U=(n,t,l,m)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of j(t))!K.call(n,s)&&s!==l&&L(n,s,{get:()=>t[s],enumerable:!(m=G(t,s))||m.enumerable});return n};var Y=(n,t,l)=>(l=n!=null?X(H(n)):{},U(L(l,"default",{value:n,enumerable:true}),n));var T=z((ct,_)=>{var h=process||{},B=h.argv||[],p=h.env||{},W=!(p.NO_COLOR||B.includes("--no-color"))&&(!!p.FORCE_COLOR||B.includes("--color")||h.platform==="win32"||(h.stdout||{}).isTTY&&p.TERM!=="dumb"||!!p.CI),Q=(n,t,l=n)=>m=>{let s=""+m,c=s.indexOf(t,n.length);return ~c?n+Z(s,t,l,c)+t:n+s+t},Z=(n,t,l,m)=>{let s="",c=0;do s+=n.substring(c,m)+l,c=m+t.length,m=n.indexOf(t,c);while(~m);return s+n.substring(c)},F=(n=W)=>{let t=n?Q:()=>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")}};_.exports=F();_.exports.createColors=F;});var y="/__pixi-vn/characters",I="/__pixi-vn/labels",S="/__pixi-vn/assets/manifest",P="/__pixi-vn/canvas-options";var C=Y(T());var w=C.default.cyan("(pixi-vn)");function A(n){return n?Array.isArray(n)?n:[n]:[]}function st(n){let t=[],l=[];for(let m of n)try{let s=fs.readFileSync(m,"utf-8"),c=/newLabel\(\s*["']([^"']+)["']/g,d;for(;(d=c.exec(s))!==null;)l.push(d[1]);let u=/new\s+\w*[Cc]haracter\(\s*["']([^"']+)["']/g;for(;(d=u.exec(s))!==null;)t.push(d[1]);}catch{}return {charIds:t,labelIds:l}}function at(n){let t,l,m=new Promise(e=>{l=e;}),s=[...A(n?.content),...A(n?.characters),...A(n?.labels)],c=[],d=[],u=new Set,E=[],v=new Map;function O(){if(!n?.typeFilePath||!t)return null;let e=n.typeFilePath;return path.isAbsolute(e)?e:path.resolve(t.root,e)}function D(){let e=[...d,...Array.from(v.values()).flat()];return Array.from(new Set(e))}function $(e,i,a){fs.mkdirSync(path.dirname(e),{recursive:true});let r=["/* eslint-disable */","// noinspection JSUnusedGlobalSymbols","// This file is auto-generated by @drincs/pixi-vn vite plugin. Do not edit manually."];if(i.length>0){r.push('declare module "@drincs/pixi-vn/characters" {'),r.push(" interface PixivnCharacterIds {");for(let o of i)r.push(` ${JSON.stringify(o)}: never;`);r.push(" }"),r.push("}");}if(a.length>0){r.push('declare module "@drincs/pixi-vn/narration" {'),r.push(" interface PixivnLabelIds {");for(let o of a)r.push(` ${JSON.stringify(o)}: never;`);r.push(" }"),r.push("}");}if(r.push(`export const characterIds = ${JSON.stringify(i)} as const;`),i.length>0){let o=Object.fromEntries(i.map(g=>[g,g]));r.push(`export const characterIdsEnum = ${JSON.stringify(o)} as const;`);}if(r.push(`export const labelIds = ${JSON.stringify(a)} as const;`),a.length>0){let o=Object.fromEntries(a.map(g=>[g,g]));r.push(`export const labelIdsEnum = ${JSON.stringify(o)} as const;`);}r.push(""),fs.writeFileSync(e,r.join(`
2
- `),"utf-8");}function x(){let e=O();if(e)try{$(e,c.map(i=>i.id),D());}catch(i){t?.logger.error(`${w} Failed to write keys file "${e}".`,{error:i instanceof Error?i:new Error(String(i)),timestamp:true});}}async function N(e,i=[]){try{c=(await e("@drincs/pixi-vn/characters")).RegisteredCharacters?.values()??[];}catch{c=[];}try{d=(await e("@drincs/pixi-vn/narration")).RegisteredLabels?.keys()??[];}catch{d=[];}if(i.length>0){let{charIds:r,labelIds:o}=st(i),g=new Set(c.map(b=>b.id)),J=new Set(d);for(let b of r)g.has(b)||c.push({id:b});for(let b of o)J.has(b)||d.push(b);}let a=c.map(r=>r.id).join(", ")||"none";t?.logger.info(`${w} ${C.default.dim(`${c.length} character(s): [${a}], ${d.length} label(s)`)}`,{timestamp:true});}async function R(e,i){try{await e("@drincs/pixi-vn/characters");}catch{}try{await e("@drincs/pixi-vn/narration");}catch{}let a=await tinyglobby.glob(s,{cwd:i,absolute:true,onlyFiles:true}),r=[];for(let o of a){u.add(o);try{await e(o);}catch{r.push(o);}}await N(e,r),x(),l();}async function k(e){for(let r of u)for(let o of e.moduleGraph.getModulesByFile(r)??[])e.moduleGraph.invalidateModule(o);try{(await e.ssrLoadModule("@drincs/pixi-vn/characters")).RegisteredCharacters?.clear?.();}catch{}try{(await e.ssrLoadModule("@drincs/pixi-vn/narration")).RegisteredLabels?.clear?.();}catch{}let i=await tinyglobby.glob(s,{cwd:t.root,absolute:true,onlyFiles:true}),a=[];for(let r of i){u.add(r);try{await e.ssrLoadModule(r);}catch{a.push(r);}}await N(r=>e.ssrLoadModule(r),a),x();for(let r of E)r();}let V={characters:null,labels:null,manifest:null,canvasOptions:null};function f(e,i){return (a,r)=>{if(r.setHeader("Content-Type","application/json"),a.method==="GET"){let o=V[e];if(o===null){r.statusCode=404,r.end(JSON.stringify({error:`${i} not initialized`}));return}r.statusCode=200,r.end(JSON.stringify(o));return}if(a.method==="POST"){let o="";a.on("data",g=>{o+=g.toString();}),a.on("end",()=>{try{V[e]=JSON.parse(o),r.statusCode=201,r.end(JSON.stringify({message:`${i} updated successfully`}));}catch{r.statusCode=400,r.end(JSON.stringify({error:`Invalid JSON format for ${i}`}));}});}}}return {name:"vite-plugin-pixi-vn",enforce:"pre",api:{contentLoaded:m,get characters(){return c},onReload(e){E.push(e);},setExternalLabels(e,i){v.set(e,i),x();},clearExternalLabels(e){v.delete(e),x();}},config(e,i){if(i.command==="serve"&&s.length>0)return {ssr:{noExternal:["@drincs/pixi-vn"]}}},configResolved(e){t=e,s.length===0&&l();},async buildStart(){if(t?.command!=="build"||s.length===0)return;let{createServer:e}=await import('vite'),i=await e({root:t.root,configFile:false,server:{middlewareMode:true},appType:"custom",logLevel:"silent",optimizeDeps:{noDiscovery:true},ssr:{noExternal:["@drincs/pixi-vn"]}});try{await R(a=>i.ssrLoadModule(a),t.root);}catch{l();}finally{await i.close();}},configureServer(e){s.length>0&&R(i=>e.ssrLoadModule(i),t.root).catch(()=>{l();}),e.middlewares.use(y,f("characters","Characters")),e.middlewares.use(I,f("labels","Labels")),e.middlewares.use(S,f("manifest","Manifest")),e.middlewares.use(P,f("canvasOptions","Canvas options"));},hotUpdate({file:e,server:i}){let a=O();if(a&&e===a)return [];if(s.length>0&&u.has(e))return k(i).catch(r=>{t?.logger.error(`${w} Failed to reload content.`,{error:r instanceof Error?r:new Error(String(r)),timestamp:true});}),[]}}}exports.PIXIVN_DEV_API_ASSETS_MANIFEST=S;exports.PIXIVN_DEV_API_CANVAS_OPTIONS=P;exports.PIXIVN_DEV_API_CHARACTERS=y;exports.PIXIVN_DEV_API_LABELS=I;exports.vitePluginPixivn=at;
1
+ 'use strict';var fs=require('fs'),path=require('path'),tinyglobby=require('tinyglobby');var X=Object.create;var L=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var H=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var z=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var U=(n,t,l,m)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of j(t))!K.call(n,s)&&s!==l&&L(n,s,{get:()=>t[s],enumerable:!(m=G(t,s))||m.enumerable});return n};var Y=(n,t,l)=>(l=n!=null?X(H(n)):{},U(L(l,"default",{value:n,enumerable:true}),n));var T=z((ct,_)=>{var h=process||{},B=h.argv||[],p=h.env||{},W=!(p.NO_COLOR||B.includes("--no-color"))&&(!!p.FORCE_COLOR||B.includes("--color")||h.platform==="win32"||(h.stdout||{}).isTTY&&p.TERM!=="dumb"||!!p.CI),Q=(n,t,l=n)=>m=>{let s=""+m,c=s.indexOf(t,n.length);return ~c?n+Z(s,t,l,c)+t:n+s+t},Z=(n,t,l,m)=>{let s="",c=0;do s+=n.substring(c,m)+l,c=m+t.length,m=n.indexOf(t,c);while(~m);return s+n.substring(c)},F=(n=W)=>{let t=n?Q:()=>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")}};_.exports=F();_.exports.createColors=F;});var y="/__pixi-vn/characters",I="/__pixi-vn/labels",S="/__pixi-vn/assets/manifest",P="/__pixi-vn/canvas-options";var C=Y(T());var w=C.default.cyan("(pixi-vn)");function A(n){return n?Array.isArray(n)?n:[n]:[]}function st(n){let t=[],l=[];for(let m of n)try{let s=fs.readFileSync(m,"utf-8"),c=/newLabel\(\s*["']([^"']+)["']/g,d;for(;(d=c.exec(s))!==null;)l.push(d[1]);let u=/new\s+\w*[Cc]haracter\(\s*["']([^"']+)["']/g;for(;(d=u.exec(s))!==null;)t.push(d[1]);}catch{}return {charIds:t,labelIds:l}}function at(n){let t,l,m=new Promise(e=>{l=e;}),s=[...A(n?.content),...A(n?.characters),...A(n?.labels)],c=[],d=[],u=new Set,E=[],v=new Map;function O(){if(!n?.typeFilePath||!t)return null;let e=n.typeFilePath;return path.isAbsolute(e)?e:path.resolve(t.root,e)}function D(){let e=[...d,...Array.from(v.values()).flat()];return Array.from(new Set(e))}function $(e,i,a){fs.mkdirSync(path.dirname(e),{recursive:true});let r=["/* eslint-disable */","// noinspection JSUnusedGlobalSymbols","// This file is auto-generated by @drincs/pixi-vn vite plugin. Do not edit manually."];if(i.length>0){r.push('declare module "@drincs/pixi-vn/characters" {'),r.push(" interface PixivnCharacterIds {");for(let o of i)r.push(` ${JSON.stringify(o)}: never;`);r.push(" }"),r.push("}");}if(a.length>0){r.push('declare module "@drincs/pixi-vn/narration" {'),r.push(" interface PixivnLabelIds {");for(let o of a)r.push(` ${JSON.stringify(o)}: never;`);r.push(" }"),r.push("}");}r.push(`export const characterIds = ${JSON.stringify(i)} as const;`);{let o=Object.fromEntries(i.map(g=>[g,g]));r.push(`export const characterIdsEnum = ${JSON.stringify(o)} as const;`);}r.push(`export const labelIds = ${JSON.stringify(a)} as const;`);{let o=Object.fromEntries(a.map(g=>[g,g]));r.push(`export const labelIdsEnum = ${JSON.stringify(o)} as const;`);}r.push(""),fs.writeFileSync(e,r.join(`
2
+ `),"utf-8");}function x(){let e=O();if(e)try{$(e,c.map(i=>i.id),D());}catch(i){t?.logger.error(`${w} Failed to write keys file "${e}".`,{error:i instanceof Error?i:new Error(String(i)),timestamp:true});}}async function N(e,i=[]){try{c=(await e("@drincs/pixi-vn/characters")).RegisteredCharacters?.values()??[];}catch{c=[];}try{d=(await e("@drincs/pixi-vn/narration")).RegisteredLabels?.keys()??[];}catch{d=[];}if(i.length>0){let{charIds:r,labelIds:o}=st(i),g=new Set(c.map(b=>b.id)),J=new Set(d);for(let b of r)g.has(b)||c.push({id:b});for(let b of o)J.has(b)||d.push(b);}let a=c.map(r=>r.id).join(", ")||"none";t?.logger.info(`${w} ${C.default.dim(`${c.length} character(s): [${a}], ${d.length} label(s)`)}`,{timestamp:true});}async function R(e,i){try{await e("@drincs/pixi-vn/characters");}catch{}try{await e("@drincs/pixi-vn/narration");}catch{}let a=await tinyglobby.glob(s,{cwd:i,absolute:true,onlyFiles:true}),r=[];for(let o of a){u.add(o);try{await e(o);}catch{r.push(o);}}await N(e,r),x(),l();}async function k(e){for(let r of u)for(let o of e.moduleGraph.getModulesByFile(r)??[])e.moduleGraph.invalidateModule(o);try{(await e.ssrLoadModule("@drincs/pixi-vn/characters")).RegisteredCharacters?.clear?.();}catch{}try{(await e.ssrLoadModule("@drincs/pixi-vn/narration")).RegisteredLabels?.clear?.();}catch{}let i=await tinyglobby.glob(s,{cwd:t.root,absolute:true,onlyFiles:true}),a=[];for(let r of i){u.add(r);try{await e.ssrLoadModule(r);}catch{a.push(r);}}await N(r=>e.ssrLoadModule(r),a),x();for(let r of E)r();}let V={characters:null,labels:null,manifest:null,canvasOptions:null};function f(e,i){return (a,r)=>{if(r.setHeader("Content-Type","application/json"),a.method==="GET"){let o=V[e];if(o===null){r.statusCode=404,r.end(JSON.stringify({error:`${i} not initialized`}));return}r.statusCode=200,r.end(JSON.stringify(o));return}if(a.method==="POST"){let o="";a.on("data",g=>{o+=g.toString();}),a.on("end",()=>{try{V[e]=JSON.parse(o),r.statusCode=201,r.end(JSON.stringify({message:`${i} updated successfully`}));}catch{r.statusCode=400,r.end(JSON.stringify({error:`Invalid JSON format for ${i}`}));}});}}}return {name:"vite-plugin-pixi-vn",enforce:"pre",api:{contentLoaded:m,get characters(){return c},onReload(e){E.push(e);},setExternalLabels(e,i){v.set(e,i),x();},clearExternalLabels(e){v.delete(e),x();}},config(e,i){if(i.command==="serve"&&s.length>0)return {ssr:{noExternal:["@drincs/pixi-vn"]}}},configResolved(e){t=e,s.length===0&&l();},async buildStart(){if(t?.command!=="build"||s.length===0)return;let{createServer:e}=await import('vite'),i=await e({root:t.root,configFile:false,resolve:t.resolve,server:{middlewareMode:true},appType:"custom",logLevel:"silent",optimizeDeps:{noDiscovery:true},ssr:{noExternal:["@drincs/pixi-vn"]}});try{await R(a=>i.ssrLoadModule(a),t.root);}catch{l();}finally{await i.close();}},configureServer(e){s.length>0&&R(i=>e.ssrLoadModule(i),t.root).catch(()=>{l();}),e.middlewares.use(y,f("characters","Characters")),e.middlewares.use(I,f("labels","Labels")),e.middlewares.use(S,f("manifest","Manifest")),e.middlewares.use(P,f("canvasOptions","Canvas options"));},hotUpdate({file:e,server:i}){let a=O();if(a&&e===a)return [];if(s.length>0&&u.has(e))return k(i).catch(r=>{t?.logger.error(`${w} Failed to reload content.`,{error:r instanceof Error?r:new Error(String(r)),timestamp:true});}),[]}}}exports.PIXIVN_DEV_API_ASSETS_MANIFEST=S;exports.PIXIVN_DEV_API_CANVAS_OPTIONS=P;exports.PIXIVN_DEV_API_CHARACTERS=y;exports.PIXIVN_DEV_API_LABELS=I;exports.vitePluginPixivn=at;
package/dist/vite.mjs CHANGED
@@ -1,2 +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 {mkdirSync,writeFileSync,readFileSync}from'fs';import {isAbsolute,resolve,dirname}from'path';import {glob}from'tinyglobby';var F=a((tt,P)=>{var p=process||{},B=p.argv||[],h=p.env||{},G=!(h.NO_COLOR||B.includes("--no-color"))&&(!!h.FORCE_COLOR||B.includes("--color")||p.platform==="win32"||(p.stdout||{}).isTTY&&h.TERM!=="dumb"||!!h.CI),j=(i,t,c=i)=>d=>{let l=""+d,o=l.indexOf(t,i.length);return ~o?i+H(l,t,c,o)+t:i+l+t},H=(i,t,c,d)=>{let l="",o=0;do l+=i.substring(o,d)+c,o=d+t.length,d=i.indexOf(t,o);while(~d);return l+i.substring(o)},V=(i=G)=>{let t=i?j:()=>String;return {isColorSupported:i,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")}};P.exports=V();P.exports.createColors=V;});var E=c(F(),1);var C=E.default.cyan("(pixi-vn)");function A(i){return i?Array.isArray(i)?i:[i]:[]}function Z(i){let t=[],c=[];for(let d of i)try{let l=readFileSync(d,"utf-8"),o=/newLabel\(\s*["']([^"']+)["']/g,m;for(;(m=o.exec(l))!==null;)c.push(m[1]);let u=/new\s+\w*[Cc]haracter\(\s*["']([^"']+)["']/g;for(;(m=u.exec(l))!==null;)t.push(m[1]);}catch{}return {charIds:t,labelIds:c}}function q(i){let t,c,d$1=new Promise(e=>{c=e;}),l=[...A(i?.content),...A(i?.characters),...A(i?.labels)],o=[],m=[],u=new Set,O=[],y=new Map;function _(){if(!i?.typeFilePath||!t)return null;let e=i.typeFilePath;return isAbsolute(e)?e:resolve(t.root,e)}function $(){let e=[...m,...Array.from(y.values()).flat()];return Array.from(new Set(e))}function T(e,n,s){mkdirSync(dirname(e),{recursive:true});let r=["/* 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 a of n)r.push(` ${JSON.stringify(a)}: never;`);r.push(" }"),r.push("}");}if(s.length>0){r.push('declare module "@drincs/pixi-vn/narration" {'),r.push(" interface PixivnLabelIds {");for(let a of s)r.push(` ${JSON.stringify(a)}: never;`);r.push(" }"),r.push("}");}if(r.push(`export const characterIds = ${JSON.stringify(n)} as const;`),n.length>0){let a=Object.fromEntries(n.map(g=>[g,g]));r.push(`export const characterIdsEnum = ${JSON.stringify(a)} as const;`);}if(r.push(`export const labelIds = ${JSON.stringify(s)} as const;`),s.length>0){let a=Object.fromEntries(s.map(g=>[g,g]));r.push(`export const labelIdsEnum = ${JSON.stringify(a)} as const;`);}r.push(""),writeFileSync(e,r.join(`
2
- `),"utf-8");}function x(){let e=_();if(e)try{T(e,o.map(n=>n.id),$());}catch(n){t?.logger.error(`${C} Failed to write keys file "${e}".`,{error:n instanceof Error?n:new Error(String(n)),timestamp:true});}}async function R(e,n=[]){try{o=(await e("@drincs/pixi-vn/characters")).RegisteredCharacters?.values()??[];}catch{o=[];}try{m=(await e("@drincs/pixi-vn/narration")).RegisteredLabels?.keys()??[];}catch{m=[];}if(n.length>0){let{charIds:r,labelIds:a}=Z(n),g=new Set(o.map(b=>b.id)),D=new Set(m);for(let b of r)g.has(b)||o.push({id:b});for(let b of a)D.has(b)||m.push(b);}let s=o.map(r=>r.id).join(", ")||"none";t?.logger.info(`${C} ${E.default.dim(`${o.length} character(s): [${s}], ${m.length} label(s)`)}`,{timestamp:true});}async function L(e,n){try{await e("@drincs/pixi-vn/characters");}catch{}try{await e("@drincs/pixi-vn/narration");}catch{}let s=await glob(l,{cwd:n,absolute:true,onlyFiles:true}),r=[];for(let a of s){u.add(a);try{await e(a);}catch{r.push(a);}}await R(e,r),x(),c();}async function k(e){for(let r of u)for(let a of e.moduleGraph.getModulesByFile(r)??[])e.moduleGraph.invalidateModule(a);try{(await e.ssrLoadModule("@drincs/pixi-vn/characters")).RegisteredCharacters?.clear?.();}catch{}try{(await e.ssrLoadModule("@drincs/pixi-vn/narration")).RegisteredLabels?.clear?.();}catch{}let n=await glob(l,{cwd:t.root,absolute:true,onlyFiles:true}),s=[];for(let r of n){u.add(r);try{await e.ssrLoadModule(r);}catch{s.push(r);}}await R(r=>e.ssrLoadModule(r),s),x();for(let r of O)r();}let N={characters:null,labels:null,manifest:null,canvasOptions:null};function f(e,n){return (s,r)=>{if(r.setHeader("Content-Type","application/json"),s.method==="GET"){let a=N[e];if(a===null){r.statusCode=404,r.end(JSON.stringify({error:`${n} not initialized`}));return}r.statusCode=200,r.end(JSON.stringify(a));return}if(s.method==="POST"){let a="";s.on("data",g=>{a+=g.toString();}),s.on("end",()=>{try{N[e]=JSON.parse(a),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 o},onReload(e){O.push(e);},setExternalLabels(e,n){y.set(e,n),x();},clearExternalLabels(e){y.delete(e),x();}},config(e,n){if(n.command==="serve"&&l.length>0)return {ssr:{noExternal:["@drincs/pixi-vn"]}}},configResolved(e){t=e,l.length===0&&c();},async buildStart(){if(t?.command!=="build"||l.length===0)return;let{createServer:e}=await import('vite'),n=await e({root:t.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),t.root);}catch{c();}finally{await n.close();}},configureServer(e){l.length>0&&L(n=>e.ssrLoadModule(n),t.root).catch(()=>{c();}),e.middlewares.use(a$1,f("characters","Characters")),e.middlewares.use(b,f("labels","Labels")),e.middlewares.use(c$1,f("manifest","Manifest")),e.middlewares.use(d,f("canvasOptions","Canvas options"));},hotUpdate({file:e,server:n}){let s=_();if(s&&e===s)return [];if(l.length>0&&u.has(e))return k(n).catch(r=>{t?.logger.error(`${C} Failed to reload content.`,{error:r instanceof Error?r:new Error(String(r)),timestamp:true});}),[]}}}export{q 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 {mkdirSync,writeFileSync,readFileSync}from'fs';import {isAbsolute,resolve,dirname}from'path';import {glob}from'tinyglobby';var F=a((tt,P)=>{var p=process||{},B=p.argv||[],h=p.env||{},G=!(h.NO_COLOR||B.includes("--no-color"))&&(!!h.FORCE_COLOR||B.includes("--color")||p.platform==="win32"||(p.stdout||{}).isTTY&&h.TERM!=="dumb"||!!h.CI),j=(i,t,c=i)=>d=>{let l=""+d,o=l.indexOf(t,i.length);return ~o?i+H(l,t,c,o)+t:i+l+t},H=(i,t,c,d)=>{let l="",o=0;do l+=i.substring(o,d)+c,o=d+t.length,d=i.indexOf(t,o);while(~d);return l+i.substring(o)},V=(i=G)=>{let t=i?j:()=>String;return {isColorSupported:i,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")}};P.exports=V();P.exports.createColors=V;});var E=c(F(),1);var C=E.default.cyan("(pixi-vn)");function A(i){return i?Array.isArray(i)?i:[i]:[]}function Z(i){let t=[],c=[];for(let d of i)try{let l=readFileSync(d,"utf-8"),o=/newLabel\(\s*["']([^"']+)["']/g,m;for(;(m=o.exec(l))!==null;)c.push(m[1]);let u=/new\s+\w*[Cc]haracter\(\s*["']([^"']+)["']/g;for(;(m=u.exec(l))!==null;)t.push(m[1]);}catch{}return {charIds:t,labelIds:c}}function q(i){let t,c,d$1=new Promise(e=>{c=e;}),l=[...A(i?.content),...A(i?.characters),...A(i?.labels)],o=[],m=[],u=new Set,O=[],y=new Map;function _(){if(!i?.typeFilePath||!t)return null;let e=i.typeFilePath;return isAbsolute(e)?e:resolve(t.root,e)}function $(){let e=[...m,...Array.from(y.values()).flat()];return Array.from(new Set(e))}function T(e,n,s){mkdirSync(dirname(e),{recursive:true});let r=["/* 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 a of n)r.push(` ${JSON.stringify(a)}: never;`);r.push(" }"),r.push("}");}if(s.length>0){r.push('declare module "@drincs/pixi-vn/narration" {'),r.push(" interface PixivnLabelIds {");for(let a of s)r.push(` ${JSON.stringify(a)}: never;`);r.push(" }"),r.push("}");}r.push(`export const characterIds = ${JSON.stringify(n)} as const;`);{let a=Object.fromEntries(n.map(g=>[g,g]));r.push(`export const characterIdsEnum = ${JSON.stringify(a)} as const;`);}r.push(`export const labelIds = ${JSON.stringify(s)} as const;`);{let a=Object.fromEntries(s.map(g=>[g,g]));r.push(`export const labelIdsEnum = ${JSON.stringify(a)} as const;`);}r.push(""),writeFileSync(e,r.join(`
2
+ `),"utf-8");}function x(){let e=_();if(e)try{T(e,o.map(n=>n.id),$());}catch(n){t?.logger.error(`${C} Failed to write keys file "${e}".`,{error:n instanceof Error?n:new Error(String(n)),timestamp:true});}}async function R(e,n=[]){try{o=(await e("@drincs/pixi-vn/characters")).RegisteredCharacters?.values()??[];}catch{o=[];}try{m=(await e("@drincs/pixi-vn/narration")).RegisteredLabels?.keys()??[];}catch{m=[];}if(n.length>0){let{charIds:r,labelIds:a}=Z(n),g=new Set(o.map(b=>b.id)),D=new Set(m);for(let b of r)g.has(b)||o.push({id:b});for(let b of a)D.has(b)||m.push(b);}let s=o.map(r=>r.id).join(", ")||"none";t?.logger.info(`${C} ${E.default.dim(`${o.length} character(s): [${s}], ${m.length} label(s)`)}`,{timestamp:true});}async function L(e,n){try{await e("@drincs/pixi-vn/characters");}catch{}try{await e("@drincs/pixi-vn/narration");}catch{}let s=await glob(l,{cwd:n,absolute:true,onlyFiles:true}),r=[];for(let a of s){u.add(a);try{await e(a);}catch{r.push(a);}}await R(e,r),x(),c();}async function k(e){for(let r of u)for(let a of e.moduleGraph.getModulesByFile(r)??[])e.moduleGraph.invalidateModule(a);try{(await e.ssrLoadModule("@drincs/pixi-vn/characters")).RegisteredCharacters?.clear?.();}catch{}try{(await e.ssrLoadModule("@drincs/pixi-vn/narration")).RegisteredLabels?.clear?.();}catch{}let n=await glob(l,{cwd:t.root,absolute:true,onlyFiles:true}),s=[];for(let r of n){u.add(r);try{await e.ssrLoadModule(r);}catch{s.push(r);}}await R(r=>e.ssrLoadModule(r),s),x();for(let r of O)r();}let N={characters:null,labels:null,manifest:null,canvasOptions:null};function f(e,n){return (s,r)=>{if(r.setHeader("Content-Type","application/json"),s.method==="GET"){let a=N[e];if(a===null){r.statusCode=404,r.end(JSON.stringify({error:`${n} not initialized`}));return}r.statusCode=200,r.end(JSON.stringify(a));return}if(s.method==="POST"){let a="";s.on("data",g=>{a+=g.toString();}),s.on("end",()=>{try{N[e]=JSON.parse(a),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 o},onReload(e){O.push(e);},setExternalLabels(e,n){y.set(e,n),x();},clearExternalLabels(e){y.delete(e),x();}},config(e,n){if(n.command==="serve"&&l.length>0)return {ssr:{noExternal:["@drincs/pixi-vn"]}}},configResolved(e){t=e,l.length===0&&c();},async buildStart(){if(t?.command!=="build"||l.length===0)return;let{createServer:e}=await import('vite'),n=await e({root:t.root,configFile:false,resolve:t.resolve,server:{middlewareMode:true},appType:"custom",logLevel:"silent",optimizeDeps:{noDiscovery:true},ssr:{noExternal:["@drincs/pixi-vn"]}});try{await L(s=>n.ssrLoadModule(s),t.root);}catch{c();}finally{await n.close();}},configureServer(e){l.length>0&&L(n=>e.ssrLoadModule(n),t.root).catch(()=>{c();}),e.middlewares.use(a$1,f("characters","Characters")),e.middlewares.use(b,f("labels","Labels")),e.middlewares.use(c$1,f("manifest","Manifest")),e.middlewares.use(d,f("canvasOptions","Canvas options"));},hotUpdate({file:e,server:n}){let s=_();if(s&&e===s)return [];if(l.length>0&&u.has(e))return k(n).catch(r=>{t?.logger.error(`${C} Failed to reload content.`,{error:r instanceof Error?r:new Error(String(r)),timestamp:true});}),[]}}}export{q as vitePluginPixivn};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drincs/pixi-vn",
3
- "version": "1.8.17",
3
+ "version": "1.8.19",
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",