@incajs/cli 0.0.28 → 0.0.30

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/cli.js CHANGED
@@ -1,33 +1,41 @@
1
- import{t as e}from"./chunks/rolldown-runtime-DT7IzrpZ.js";import{c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./chunks/dist-B-B_PlmU.js";import{i as c,n as l,r as u,t as d}from"./chunks/defaults-DfHXv1fN.js";import{createRequire as f}from"node:module";import p,{constants as m,existsSync as h,lstatSync as g,readFileSync as _,realpathSync as v,statSync as y,watch as b}from"node:fs";import x,{resolve as S}from"node:path";import*as C from"node:util";import{parseArgs as w,styleText as T}from"node:util";import{access as ee,chmod as E,cp as D,link as O,mkdir as k,readFile as A,readdir as j,rename as M,rm as N,stat as P,writeFile as F}from"node:fs/promises";import{fileURLToPath as te,pathToFileURL as I}from"node:url";import{homedir as L}from"node:os";import ne from"@vitejs/plugin-vue";import{DevEnvironment as R,build as re,buildErrorMessage as ie,createServer as ae}from"vite";import{spawn as oe,spawnSync as se}from"node:child_process";import{once as ce}from"node:events";import le from"node:readline";import{setTimeout as ue}from"node:timers/promises";import{createHash as de,randomBytes as fe,randomUUID as pe}from"node:crypto";import{brotliDecompressSync as me}from"node:zlib";const he=/\d/,ge=[`-`,`_`,`/`,`.`];function _e(e=``){if(!he.test(e))return e!==e.toLowerCase()}function ve(e,t){let n=t??ge,r=[];if(!e||typeof e!=`string`)return r;let i=``,a,o;for(let t of e){let e=n.includes(t);if(e===!0){r.push(i),i=``,a=void 0;continue}let s=_e(t);if(o===!1){if(a===!1&&s===!0){r.push(i),i=t,a=s;continue}if(a===!0&&s===!1&&i.length>1){let e=i.at(-1);r.push(i.slice(0,Math.max(0,i.length-1))),i=e+t,a=s;continue}}i+=t,a=s,o=e}return r.push(i),r}function ye(e){return e?e[0].toUpperCase()+e.slice(1):``}function be(e){return e?e[0].toLowerCase()+e.slice(1):``}function xe(e,t){return e?(Array.isArray(e)?e:ve(e)).map(e=>ye(t?.normalize?e.toLowerCase():e)).join(``):``}function Se(e,t){return be(xe(e||``,t))}function Ce(e,t){return e?(Array.isArray(e)?e:ve(e)).map(e=>e.toLowerCase()).join(t??`-`):``}function we(e){return Ce(e||``,`_`)}function z(e){return Array.isArray(e)?e:e===void 0?[]:[e]}function Te(e,t=``){let n=[];for(let t of e)for(let[e,r]of t.entries())n[e]=Math.max(n[e]||0,r.length);return e.map(e=>e.map((e,r)=>t+e[r===0?`padStart`:`padEnd`](n[r])).join(` `)).join(`
2
- `)}function B(e){return typeof e==`function`?e():e}var V=class extends Error{code;constructor(e,t){super(e),this.name=`CLIError`,this.code=t}};function Ee(e=[],t={}){let n=new Set(t.boolean||[]),r=new Set(t.string||[]),i=t.alias||{},a=t.default||{},o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map;for(let[e,t]of Object.entries(i)){let n=t;for(let t of n)o.set(e,t),s.has(t)||s.set(t,[]),s.get(t).push(e),o.set(t,e),s.has(e)||s.set(e,[]),s.get(e).push(t)}let c={};function l(e){if(n.has(e))return`boolean`;let t=s.get(e)||[];for(let e of t)if(n.has(e))return`boolean`;return`string`}function u(e){if(r.has(e))return!0;let t=s.get(e)||[];for(let e of t)if(r.has(e))return!0;return!1}let d=/* @__PURE__ */ new Set([...n,...r,...Object.keys(i),...Object.values(i).flat(),...Object.keys(a)]);for(let e of d)c[e]||(c[e]={type:l(e),default:a[e]});for(let[e,t]of o.entries())e.length===1&&c[t]&&!c[t].short&&(c[t].short=e);let f=[],p={};for(let t=0;t<e.length;t++){let n=e[t];if(n===`--`){f.push(...e.slice(t));break}if(n.startsWith(`--no-`)){let e=n.slice(5);p[e]=!0}else f.push(n)}let m;try{m=w({args:f,options:Object.keys(c).length>0?c:void 0,allowPositionals:!0,strict:!1})}catch{m={values:{},positionals:f}}let h={_:[]};h._=m.positionals;for(let[e,t]of Object.entries(m.values)){let n=t;l(e)===`boolean`&&typeof t==`string`?n=t!==`false`:u(e)&&typeof t==`boolean`&&(n=``),h[e]=n}for(let[e]of Object.entries(p)){h[e]=!1;let t=o.get(e);t&&(h[t]=!1);let n=s.get(e);if(n)for(let e of n)h[e]=!1}for(let[e,t]of o.entries())h[e]!==void 0&&h[t]===void 0&&(h[t]=h[e]),h[t]!==void 0&&h[e]===void 0&&(h[e]=h[t]),h[e]!==h[t]&&a[t]===h[t]&&(h[t]=h[e]);return h}const De=/* @__PURE__ */ (()=>{let e=globalThis.process?.env??{};return e.NO_COLOR===`1`||e.TERM===`dumb`||e.TEST||e.CI})(),Oe=(e,t=39)=>n=>De?n:`\u001B[${e}m${n}\u001B[${t}m`,ke=/* @__PURE__ */ Oe(1,22),H=/* @__PURE__ */ Oe(36),U=/* @__PURE__ */ Oe(90),W=/* @__PURE__ */ Oe(4,24);function Ae(e,t){let n={boolean:[],string:[],alias:{},default:{}},r=je(t);for(let e of r){if(e.type===`positional`)continue;e.type===`string`||e.type===`enum`?n.string.push(e.name):e.type===`boolean`&&n.boolean.push(e.name),e.default!==void 0&&(n.default[e.name]=e.default),e.alias&&(n.alias[e.name]=e.alias);let t=Se(e.name),r=Ce(e.name);if(t!==e.name||r!==e.name){let i=z(n.alias[e.name]||[]);t!==e.name&&!i.includes(t)&&i.push(t),r!==e.name&&!i.includes(r)&&i.push(r),i.length>0&&(n.alias[e.name]=i)}}let i=Ee(e,n),[...a]=i._,o=new Proxy(i,{get(e,t){return e[t]??e[Se(t)]??e[Ce(t)]}});for(let[,e]of r.entries())if(e.type===`positional`){let t=a.shift();if(t!==void 0)o[e.name]=t;else if(e.default===void 0&&e.required!==!1)throw new V(`Missing required positional argument: ${e.name.toUpperCase()}`,`EARG`);else o[e.name]=e.default}else if(e.type===`enum`){let t=o[e.name],n=e.options||[];if(t!==void 0&&n.length>0&&!n.includes(t))throw new V(`Invalid value for argument: ${H(`--${e.name}`)} (${H(t)}). Expected one of: ${n.map(e=>H(e)).join(`, `)}.`,`EARG`)}else if(e.required&&o[e.name]===void 0)throw new V(`Missing required argument: --${e.name}`,`EARG`);return o}function je(e){let t=[];for(let[n,r]of Object.entries(e||{}))t.push({...r,name:n,alias:z(r.alias)});return t}async function Me(e){return Promise.all(e.map(e=>B(e)))}function G(e){return e}async function Ne(e,t){let n=await B(e.args||{}),r=Ae(t.rawArgs,n),i={rawArgs:t.rawArgs,args:r,data:t.data,cmd:e},a=await Me(e.plugins??[]),o,s;try{for(let e of a)await e.setup?.(i);typeof e.setup==`function`&&await e.setup(i);let r=await B(e.subCommands);if(r&&Object.keys(r).length>0){let i=Ie(t.rawArgs,n),a=t.rawArgs[i];if(a){let e=await Fe(r,a);if(!e)throw new V(`Unknown command ${H(a)}`,`E_UNKNOWN_COMMAND`);await Ne(e,{rawArgs:t.rawArgs.slice(i+1)})}else{let n=await B(e.default);if(n){if(e.run)throw new V(`Cannot specify both 'run' and 'default' on the same command.`,`E_DEFAULT_CONFLICT`);let i=await Fe(r,n);if(!i)throw new V(`Default sub command ${H(n)} not found in subCommands.`,`E_UNKNOWN_COMMAND`);await Ne(i,{rawArgs:t.rawArgs})}else if(!e.run)throw new V(`No command specified.`,`E_NO_COMMAND`)}}typeof e.run==`function`&&(o=await e.run(i))}catch(e){s=e}let c=[];if(typeof e.cleanup==`function`)try{await e.cleanup(i)}catch(e){c.push(e)}for(let e of[...a].reverse())try{await e.cleanup?.(i)}catch(e){c.push(e)}if(s)throw s;if(c.length===1)throw c[0];if(c.length>1)throw Error(`Multiple cleanup errors`,{cause:c});return{result:o}}async function Pe(e,t,n){let r=await B(e.subCommands);if(r&&Object.keys(r).length>0){let n=Ie(t,await B(e.args||{})),i=t[n],a=await Fe(r,i);if(a)return Pe(a,t.slice(n+1),e)}return[e,n]}async function Fe(e,t){if(t in e)return B(e[t]);for(let n of Object.values(e)){let e=await B(n),r=await B(e?.meta);if(r?.alias&&z(r.alias).includes(t))return e}}function Ie(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r===`--`)return-1;if(r.startsWith(`-`))!r.includes(`=`)&&Le(r,t)&&n++;else return n}return-1}function Le(e,t){let n=e.replace(/^-{1,2}/,``),r=Se(n);for(let[e,i]of Object.entries(t))if((i.type===`string`||i.type===`enum`)&&(r===Se(e)||(Array.isArray(i.alias)?i.alias:i.alias?[i.alias]:[]).includes(n)))return!0;return!1}async function Re(e,t){try{console.log(await Be(e,t)+`
3
- `)}catch(e){console.error(e)}}const ze=/^no[-A-Z]/;async function Be(e,t){let n=await B(e.meta||{}),r=je(await B(e.args||{})),i=await B(t?.meta||{}),a=`${i.name?`${i.name} `:``}`+(n.name||process.argv[1]),o=[],s=[],c=[],l=[];for(let e of r)if(e.type===`positional`){let t=e.name.toUpperCase(),n=e.required!==!1&&e.default===void 0;s.push([H(t+Ve(e)),He(e,n)]),l.push(n?`<${t}>`:`[${t}]`)}else{let t=e.required===!0&&e.default===void 0,n=[...(e.alias||[]).map(e=>`-${e}`),`--${e.name}`].join(`, `)+Ve(e);if(o.push([H(n),He(e,t)]),e.type===`boolean`&&(e.default===!0||e.negativeDescription)&&!ze.test(e.name)){let n=[...(e.alias||[]).map(e=>`--no-${e}`),`--no-${e.name}`].join(`, `);o.push([H(n),[e.negativeDescription,t?U(`(Required)`):``].filter(Boolean).join(` `)])}t&&l.push(`--${e.name}`+Ve(e))}if(e.subCommands){let t=[],n=await B(e.subCommands);for(let[e,r]of Object.entries(n)){let n=await B((await B(r))?.meta);if(n?.hidden)continue;let i=z(n?.alias),a=[e,...i].join(`, `);c.push([H(a),n?.description||``]),t.push(e,...i)}l.push(t.join(`|`))}let u=[],d=n.version||i.version;u.push(U(`${n.description} (${a+(d?` v${d}`:``)})`),``);let f=o.length>0||s.length>0;return u.push(`${W(ke(`USAGE`))} ${H(`${a}${f?` [OPTIONS]`:``} ${l.join(` `)}`)}`,``),s.length>0&&(u.push(W(ke(`ARGUMENTS`)),``),u.push(Te(s,` `)),u.push(``)),o.length>0&&(u.push(W(ke(`OPTIONS`)),``),u.push(Te(o,` `)),u.push(``)),c.length>0&&(u.push(W(ke(`COMMANDS`)),``),u.push(Te(c,` `)),u.push(``,`Use ${H(`${a} <command> --help`)} for more information about a command.`)),u.filter(e=>typeof e==`string`).join(`
4
- `)}function Ve(e){let t=e.valueHint?`=<${e.valueHint}>`:``,n=t||`=<${we(e.name)}>`;return!e.type||e.type===`positional`||e.type===`boolean`?t:e.type===`enum`&&e.options?.length?`=<${e.options.join(`|`)}>`:n}function He(e,t){let n=t?U(`(Required)`):``,r=e.default===void 0?``:U(`(Default: ${e.default})`);return[e.description,n,r].filter(Boolean).join(` `)}async function Ue(e,t={}){let n=t.rawArgs||process.argv.slice(2),r=t.showUsage||Re;try{let t=await We(e);if(t.help.length>0&&n.some(e=>t.help.includes(e)))await r(...await Pe(e,n)),process.exit(0);else if(n.length===1&&t.version.includes(n[0])){let t=typeof e.meta==`function`?await e.meta():await e.meta;if(!t?.version)throw new V(`No version specified`,`E_NO_VERSION`);console.log(t.version)}else await Ne(e,{rawArgs:n})}catch(t){t instanceof V?(await r(...await Pe(e,n)),console.error(t.message)):console.error(t,`
5
- `),process.exit(1)}}async function We(e){let t=await B(e.args||{}),n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set;for(let[e,i]of Object.entries(t)){n.add(e);for(let e of z(i.alias))r.add(e)}return{help:Ge(`help`,`h`,n,r),version:Ge(`version`,`v`,n,r)}}function Ge(e,t,n,r){return n.has(e)||r.has(e)?[]:n.has(t)||r.has(t)?[`--${e}`]:[`--${e}`,`-${t}`]}var Ke=`0.0.28`,qe=`Commands to develop, bundle, and package Incarnative.js apps.`;function Je(e,t,n){let r=typeof e==`object`&&e?e:{},i=x.relative(n,t).split(x.sep).join(`/`);return{...r,root:i===``?`.`:i}}function Ye(e){return e&&e.constructor&&typeof e.constructor.isBuffer==`function`&&e.constructor.isBuffer(e)}function Xe(e){return e}function Ze(e,t){t||={};let n=t.delimiter||`.`,r=t.maxDepth,i=t.transformKey||Xe,a={};function o(e,s,c){c||=1,Object.keys(e).forEach(function(l){let u=e[l],d=t.safe&&Array.isArray(u),f=Object.prototype.toString.call(u),p=Ye(u),m=f===`[object Object]`||f===`[object Array]`,h=s?s+n+i(l):i(l);if(!d&&!p&&m&&Object.keys(u).length&&(!t.maxDepth||c<r))return o(u,h,c+1);a[h]=u})}return o(e),a}function Qe(e,t){t||={};let n=t.delimiter||`.`,r=t.overwrite||!1,i=t.transformKey||Xe,a={};if(Ye(e)||Object.prototype.toString.call(e)!==`[object Object]`)return e;function o(e){let n=Number(e);return isNaN(n)||e.indexOf(`.`)!==-1||t.object?e:n}function s(e,t,r){return Object.keys(r).reduce(function(t,i){return t[e+n+i]=r[i],t},t)}function c(e){let t=Object.prototype.toString.call(e),n=t===`[object Array]`,r=t===`[object Object]`;if(!e)return!0;if(n)return!e.length;if(r)return!Object.keys(e).length}return e=Object.keys(e).reduce(function(n,r){let i=Object.prototype.toString.call(e[r]);return i!==`[object Object]`&&i!==`[object Array]`||c(e[r])?(n[r]=e[r],n):s(r,n,Ze(e[r],t))},{}),Object.keys(e).forEach(function(s){let c=s.split(n).map(i),l=o(c.shift()),u=o(c[0]),d=a;for(;u!==void 0;){if(l===`__proto__`)return;let e=Object.prototype.toString.call(d[l]),n=e===`[object Object]`||e===`[object Array]`;if(!r&&!n&&d[l]!==void 0)return;(r&&!n||!r&&d[l]==null)&&(d[l]=typeof u==`number`&&!t.object?[]:{}),d=d[l],c.length>0&&(l=o(c.shift()),u=o(c[0]))}d[l]=Qe(e[s],t)}),a}const $e=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,et=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,tt=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function nt(e,t){if(e===`__proto__`||e===`constructor`&&t&&typeof t==`object`&&`prototype`in t)rt(e);else return t}function rt(e){console.warn(`[destr] Dropping "${e}" key to prevent prototype pollution.`)}function it(e,t={}){if(typeof e!=`string`)return e;if(e[0]===`"`&&e[e.length-1]===`"`&&e.indexOf(`\\`)===-1)return e.slice(1,-1);let n=e.trim();if(n.length<=9)switch(n.toLowerCase()){case`true`:return!0;case`false`:return!1;case`undefined`:return;case`null`:return null;case`nan`:return NaN;case`infinity`:return 1/0;case`-infinity`:return-1/0}if(!tt.test(e)){if(t.strict)throw SyntaxError(`[destr] Invalid JSON`);return e}try{if($e.test(e)||et.test(e)){if(t.strict)throw Error(`[destr] Possible prototype pollution`);return JSON.parse(e,nt)}return JSON.parse(e)}catch(n){if(t.strict)throw n;return e}}function at(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)===`[object Module]`:!0}function ot(e,t,n=`.`,r){if(!at(t))return ot(e,{},n,r);let i={...t};for(let t of Object.keys(e)){if(t===`__proto__`||t===`constructor`)continue;let a=e[t];a!=null&&(r&&r(i,t,a,n)||(i[t]=Array.isArray(a)&&Array.isArray(i[t])?[...a,...i[t]]:at(a)&&at(i[t])?ot(a,i[t],(n?`${n}.`:``)+t.toString(),r):a))}return i}function st(e){return(...t)=>t.reduce((t,n)=>ot(t,n,``,e),{})}const ct=st(),lt=/^\s*([^\s=]+)\s*=\s*(.*)?\s*$/,ut=/\n|\r|\r\n/,dt={name:`.conf`,dir:process.cwd(),flat:!1};function ft(e){return typeof e==`string`&&(e={name:e}),{...dt,...e}}function pt(e,t={}){let n={},r=e.split(ut);for(let e of r){let t=e.match(lt);if(!t)continue;let r=t[1];if(!r||r===`__proto__`||r===`constructor`)continue;let i=it((t[2]||``).trim());if(r.endsWith(`[]`)){let e=r.slice(0,Math.max(0,r.length-2));n[e]=(n[e]||[]).concat(i)}else n[r]=i}return t.flat?n:Qe(n,{overwrite:!0})}function mt(e,t){return h(e)?pt(_(e,`utf8`),t):{}}function ht(e){return e=ft(e),mt(S(e.dir,e.name),e)}function gt(){return process.env.XDG_CONFIG_HOME||S(L(),`.config`)}function _t(e){return e=ft(e),e.dir=gt(),ht(e)}async function vt(e){let t=e.env??process.env,n=await yt({cwd:e.cwd,fileName:e.fileName??`.env`,env:t,interpolate:e.interpolate??!0,expandFileReferences:e.expandFileReferences??!1,parse:e.parse}),r=Dt(t);for(let e in n)e.startsWith(`_`)||(t[e]===void 0||r.has(e))&&(t[e]=n[e]);return n}async function yt(e){let n=Object.create(null),r=t(e.cwd||`.`),i=e.fileName||`.env`,a=typeof i==`string`?[i]:i,o=Dt(e.env||{});Object.assign(n,e.env);for(let i of a){let a=t(r,i);if(!y(a,{throwIfNoEntry:!1})?.isFile())continue;let s=await xt(a,e.parse);for(let e in s)e in n&&!o.has(e)||(n[e]=s[e],o.add(e))}if(e.expandFileReferences){for(let e in n)if(e.endsWith(`_FILE`)){let t=e.slice(0,-5);if(n[t]===void 0){let r=n[e];r&&y(r,{throwIfNoEntry:!1})?.isFile()&&(n[t]=_(r,`utf8`).trim(),o.add(t))}}}return e.interpolate&&St(n),n}let bt=C.parseEnv;async function xt(e,t){let n=_(e,`utf8`);if(t)return t(n);if(!bt)try{let e=await import(`dotenv`);bt=t=>e.parse(t)}catch{throw Error("Failed to parse .env file: `node:util.parseEnv` is not available and `dotenv` package is not installed. Please upgrade your runtime, install `dotenv` as a dependency or provide a custom `parse` option.")}return bt(n)}function St(e,t={},n=e=>e){function r(n){return t[n]===void 0?e[n]:t[n]}function i(e,t=[]){if(typeof e!=`string`)return e;let a=``,o=0;for(;o<e.length;){let n=e[o];if(n===`\\`&&e[o+1]===`$`){a+=`$`,o+=2;continue}let s=n===`$`?Tt(e,o):void 0;if(!s){a+=n,o++;continue}if(t.includes(s.key)){if(s.defaultValue!==void 0){a+=i(s.defaultValue,t),o=s.end;continue}return console.warn(`Please avoid recursive environment variables ( loop: ${t.join(` > `)} > ${s.key} )`),``}let c=i(r(s.key),[...t,s.key]);s.defaultValue!==void 0&&(c===void 0||s.operator===`:-`&&c===``)&&(c=i(s.defaultValue,t)),a+=c===void 0?e.slice(o,s.end):c,o=s.end}return n(a)}for(let t in e)e[t]=i(r(t))}const Ct=/\w+/y,wt=/[\w:]+/y;function Tt(e,t){let n=t+1,r=e[n]===`{`;r&&n++;let i=r?wt:Ct;i.lastIndex=n;let a=i.exec(e);if(!a)return;let o=a[0];if(n=i.lastIndex,!r)return{key:o,end:n};if(e[n]===`}`)return{key:o,end:n+1};if(e[n]===`-`){let t=`-`;o.endsWith(`:`)&&(o=o.slice(0,-1),t=`:-`);let r=o?Et(e,n+1):void 0;return r?{key:o,operator:t,defaultValue:r.value,end:r.end}:void 0}return{key:o,end:n}}function Et(e,t){let n=``,r=1;for(let i=t;i<e.length;i++){let t=e[i];if(t===`\\`&&i+1<e.length){let r=e[i+1];n+=r===`{`||r===`}`?r:t+r,i++}else if(t===`$`&&e[i+1]===`{`)r++,n+="${",i++;else{if(t===`{`&&r++,t===`}`&&(r--,r===0))return{value:n,end:i+1};n+=t}}}function Dt(e){let t=globalThis.__c12_dotenv_vars__||=/* @__PURE__ */ new Map;return t.has(e)||t.set(e,/* @__PURE__ */ new Set),t.get(e)}const Ot=e=>e?.replace(/\\/g,`/`);let kt=0;const At={".json":()=>JSON.parse,".yaml":()=>import(`./chunks/yaml-DtBxpt6z.js`).then(e=>e.parseYAML),".yml":()=>import(`./chunks/yaml-DtBxpt6z.js`).then(e=>e.parseYAML),".jsonc":()=>import(`./chunks/jsonc-DJWoCi14.js`).then(e=>e.n).then(e=>t=>e.parseJSONC(t,{allowTrailingComma:!0})),".json5":()=>import(`./chunks/json5-BcF68iGq.js`).then(e=>e.parseJSON5),".toml":()=>import(`./chunks/toml-n3nLqi2g.js`).then(e=>e.parseTOML)},jt=Object.freeze([`.js`,`.ts`,`.mjs`,`.cjs`,`.mts`,`.cts`,`.json`,`.jsonc`,`.json5`,`.yaml`,`.yml`,`.toml`]);async function Mt(e){e.cwd=t(process.cwd(),e.cwd||`.`),e.name=e.name||`config`,e.envName=e.envName??process.env.NODE_ENV,e.configFile=e.configFile??(e.name===`config`?`config`:`${e.name}.config`),e.rcFile=e.rcFile??`.${e.name}rc`,e.extend!==!1&&(e.extend={extendKey:`extends`,...e.extend});let n=e.merger||ct,r={config:{},cwd:e.cwd,configFile:t(e.cwd,e.configFile),layers:[],_configFile:void 0},i={overrides:e.overrides,main:void 0,rc:void 0,packageJson:void 0,defaultConfig:e.defaultConfig};e.dotenv&&await vt({cwd:e.cwd,...e.dotenv===!0?{}:e.dotenv});let a=await It(`.`,e);if(a.configFile&&(i.main=a.config,r.configFile=a.configFile,r._configFile=a._configFile),a.meta&&(r.meta=a.meta),e.rcFile){let t=[];if(t.push(ht({name:e.rcFile,dir:e.cwd})),e.globalRc){let{findWorkspaceDir:n}=await import(`./chunks/dist-BTWvruNB.js`),r=await n(e.cwd).catch(()=>{});r&&t.push(ht({name:e.rcFile,dir:r})),t.push(_t({name:e.rcFile})),t.push(ht({name:e.rcFile,dir:L()}))}i.rc=n({},...t)}if(e.packageJson){let t=(Array.isArray(e.packageJson)?e.packageJson:[typeof e.packageJson==`string`?e.packageJson:e.name]).filter(e=>e&&typeof e==`string`),{readPackageJSON:r}=await import(`./chunks/dist-BTWvruNB.js`),a=await r(e.cwd).catch(()=>{});i.packageJson=n({},...t.map(e=>a?.[e]))}let o={};for(let e in i){let t=i[e];o[e]=await(typeof t==`function`?t({configs:o,rawConfigs:i}):t)}if(Array.isArray(o.main)?r.config=o.main:(r.config=n(o.overrides,o.main,o.rc,o.packageJson,o.defaultConfig),e.extend&&(await Nt(r.config,e),r.layers=r.config._layers,delete r.config._layers,r.config=n(r.config,...r.layers.map(e=>e.config)))),r.layers=[...[o.overrides&&{config:o.overrides,configFile:void 0,cwd:void 0},{config:o.main,configFile:e.configFile,cwd:e.cwd},o.rc&&{config:o.rc,configFile:e.rcFile},o.packageJson&&{config:o.packageJson,configFile:`package.json`}].filter(e=>e&&e.config),...r.layers],e.defaults&&(r.config=n(r.config,e.defaults)),e.omit$Keys)for(let e in r.config)e.startsWith(`$`)&&delete r.config[e];if(e.configFileRequired&&!r._configFile)throw Error(`Required config (${r.configFile}) cannot be resolved.`);return e.schema!=null&&(r.config=await Lt(r.config,e.schema)),r}async function Nt(e,t){if(e._layers=e._layers||[],!t.extend)return;let n=t.extend.extendKey;typeof n==`string`&&(n=[n]);let r=[];for(let t of n)r.push(...(Array.isArray(e[t])?e[t]:[e[t]]).filter(Boolean)),delete e[t];for(let n of r){let r=n,i={};if(n.source&&(i=n.options||{},n=n.source),Array.isArray(n)&&(i=n[1]||{},n=n[0]),typeof n!=`string`){console.warn(`Cannot extend config from \`${JSON.stringify(r)}\` in ${t.cwd}`);continue}let a=await It(n,t,i);a.config?(await Nt(a.config,{...t,cwd:a.cwd}),e._layers.push(a),a.config._layers&&(e._layers.push(...a.config._layers),delete a.config._layers)):console.warn(`Cannot extend config from \`${n}\` in ${t.cwd}`)}}const Pt=[`gh:`,`github:`,`gitlab:`,`bitbucket:`,`https://`,`http://`],Ft=/^(@[\da-z~-][\d._a-z~-]*\/)?[\da-z~-][\d._a-z~-]*($|\/.*)/;async function It(e,o,s={}){if(o.resolve){let t=await o.resolve(e,o);if(t)return t}let c=o.merger||ct,l=Object.keys(s.giget?.providers||{}).map(e=>`${e}:`),u=l.length>0?[.../* @__PURE__ */ new Set([...l,...Pt])]:Pt;if(o.giget!==!1&&u.some(t=>e.startsWith(t))){let{downloadTemplate:n}=await import(`giget`).catch(t=>{throw Error(`Extending config from \`${e}\` requires \`giget\` peer dependency to be installed.\n\nInstall it with: \`npx nypm i giget\``,{cause:t})}),{digest:c}=await import(`./chunks/ohash-DUMW2FP0.js`).then(e=>e.dist_exports),l=e.replace(/\W+/g,`_`).split(`_`).splice(0,3).join(`_`)+`_`+c(e).slice(0,10).replace(/[-_]/g,``),u,d=t(o.cwd,`node_modules`),f=a(o.cwd);u=r(f)===`.c12`?i(f,l):h(d)?i(d,`.c12`,l):process.env.XDG_CACHE_HOME?t(process.env.XDG_CACHE_HOME,`c12`,l):t(L(),`.cache/c12`,l);let p=s.install?ct(s.install===!0?{}:s.install,{ignoreWorkspace:!0}):!1;h(u)&&!p&&await N(u,{recursive:!0}),e=(await n(e,{dir:u,install:p,force:!!p,auth:s.auth,...o.giget,...s.giget})).dir}Ft.test(e)&&(e=Rt(e,o)||e);let d=n(e),f=zt(t(o.cwd,e))??(!d||d===r(e)),p=t(o.cwd,f?e:a(e));f&&(e=o.configFile);let m={config:void 0,configFile:void 0,cwd:p,source:e,sourceOptions:s};if(m.configFile=Rt(t(p,e),o)||Rt(t(p,`.config`,e.replace(/\.config$/,``)),o)||Rt(t(p,`.config`,e),o)||e,!h(m.configFile))return m;m._configFile=m.configFile;let g=n(m.configFile)||``;if(g in At)m.config=(await At[g]())(await A(m.configFile,`utf8`));else{let e=o.resolveModule||(e=>e.default||e);if(o.import)m.config=e(await o.import(m.configFile));else{let t=I(m.configFile);t.search=`_${++kt}`,m.config=await import(t.href).then(e,async t=>{let{createJiti:n}=await import(`jiti`).catch(()=>{throw Error(`Failed to load config file \`${m.configFile}\`: ${t?.message}. Hint install \`jiti\` for compatibility.`,{cause:t})}),r=n(i(o.cwd||`.`,o.configFile||`/`),{interopDefault:!0,moduleCache:!1,extensions:[...jt],...o.jitiOptions});return o.import=e=>r.import(e),e(await o.import(m.configFile))})}}typeof m.config==`function`&&(m.config=await m.config(o.context)),m.config&&typeof m.config==`object`&&!Array.isArray(m.config)&&!Object.isExtensible(m.config)&&(m.config={...m.config});let _=(Array.isArray(o.envName)?o.envName:[o.envName]).filter(Boolean).reverse().flatMap(e=>[m.config.$env?.[e],m.config[`$`+e]]).filter(e=>e&&Object.keys(e).length>0);return _.length>0&&(m.config=(o.envMerger||c)({},..._,m.config)),m.meta=ct(m.sourceOptions.meta,m.config.$meta),delete m.config.$meta,m.sourceOptions.overrides&&(m.config=c(m.sourceOptions.overrides,m.config)),m.configFile=Ot(m.configFile),m.source=Ot(m.source),m}async function Lt(e,t){if(typeof t?.[`~standard`]?.validate!=`function`)throw TypeError("Invalid `schema` option: expected a Standard Schema (https://standardschema.dev).");let n=await t[`~standard`].validate(e);if(n.issues){let e=n.issues.map(e=>{let t=e.path?.map(e=>String(typeof e==`object`?e.key:e)).join(`.`);return` - ${t?`${t}: `:``}${e.message}`});throw Error(`Config validation failed (${t[`~standard`].vendor}):\n${e.join(`
6
- `)}`,{cause:n.issues})}return n.value}function Rt(e,t){let n=s(e,{try:!0,from:I(i(t.cwd||`.`,t.configFile||`/`)),suffixes:[``,`/index`],extensions:jt,cache:!1});return n?o(n):void 0}function zt(e){try{return y(e).isDirectory()}catch{return null}}var K=class extends Error{code;path;name=`IncaError`;constructor(e,t,n){super(t),this.code=e,this.path=n}},Bt=class extends Error{code;hostStack;constructor(e,t,n=null){super(e),this.code=t,this.hostStack=n,this.name=`HostError`}};const Vt={name:`inca`,packageJson:`inca`,rcFile:!1,globalRc:!1,giget:!1,extend:!1},Ht=[`.js`,`.ts`,`.mjs`,`.cjs`,`.mts`,`.cts`],Ut=/[/\\:*?"<>|\0]/;function Wt(e){return e===e.trim()&&e!==``&&e!==`.`&&e!==`..`&&!Ut.test(e)}function Gt(e){if(!(typeof e==`string`&&Wt(e)))throw new K(`ERR_INCA_PRODUCT_NAME_INVALID`,`${JSON.stringify(e)} can't name a directory. set a "productName" in inca.config.ts with no leading or trailing space, and none of \`/\\:*?"<>|\``)}const Kt=process.platform===`darwin`||process.platform===`win32`;function qt(e,t){let n=e=>Kt?e.toLowerCase():e,r=x.relative(n(e),n(t));return r===``||r!==`..`&&!r.startsWith(`..${x.sep}`)&&!x.isAbsolute(r)}function Jt(e){let t=x.resolve(e),n=t;for(let e;!g(n,{throwIfNoEntry:!1})&&(e=x.dirname(n))!==n;)n=e;return x.join(v.native(n),x.relative(n,t))}function Yt(e,t,n){let r=x.resolve(e,t),i;try{let t=Jt(r);i=[e,x.join(e,`src`),x.join(e,`node_modules`),...n?[n]:[]].some(e=>qt(t,Jt(e)))}catch{i=!0}if(i)throw new K(`ERR_INCA_OUT_DIR_INVALID`,`"outDir" resolves to ${r}, which holds the app's own files. Set it to a directory the build can own, such as "dist"`)}function Xt(e,t,n){let r=x.resolve(e,t??d.outDir);return Yt(e,r,n),r}function Zt(e,t){try{return JSON.parse(e)}catch(e){throw new K(`ERR_INCA_PACKAGE_JSON_INVALID`,`${t} holds malformed JSON: ${e.message}`,t)}}async function Qt(e){let t=f(import.meta.url).cache;for(let n of Ht)delete t[x.join(e,`inca.config`+n)];let{config:n,layers:r}=await Mt({cwd:e,...Vt}),i=r?.find(e=>e.configFile===`package.json`);return{config:n,usedPackageJsonKey:Object.keys(i?.config??{}).length>0}}async function $t(e){let{config:t}=await Qt(e),n=t.entry?x.resolve(e,t.entry):void 0;return{entry:n,outDir:Xt(e,t.outDir,n),sourcemap:t.sourcemap??d.sourcemap}}function en(e){return e.dev?.stackPaths??d.dev.stackPaths}async function tn(e){let t=x.join(e,`package.json`),n;try{n=await A(t,`utf8`)}catch{throw new K(`ERR_INCA_PACKAGE_JSON_NOT_FOUND`,`no package.json found at ${t}`)}let r=Zt(n,t),{config:i,usedPackageJsonKey:a}=await Qt(e),o=i.productName??u(r.name);if(!o)throw new K(`ERR_INCA_PRODUCT_NAME_MISSING`,`${t} needs a "name", or "productName" in inca.config.ts`);Gt(o);let s=i.version??r.version??d.version,c=i.identifier??l(o),f;if(i.icon&&(f=x.resolve(e,i.icon),!h(f)))throw new K(`ERR_INCA_ICON_NOT_FOUND`,`"icon" points to ${f}, which doesn't exist`,f);let p=i.entry?x.resolve(e,i.entry):void 0,m=Xt(e,i.outDir,p);return{productName:o,identifier:c,identifierIsDefault:i.identifier===void 0,version:s,icon:f,window:i.window,dev:{stackPaths:en(i)},entry:p,outDir:m,sourcemap:i.sourcemap??d.sourcemap,usedPackageJsonKey:a}}function nn(e,{dev:t=!1}={}){return{name:e.productName,identifier:e.identifier,window:e.window,...t&&{dev:{stackPaths:e.dev.stackPaths}}}}async function rn(e,{dev:t=!1}={}){let{config:n}=await Qt(e),r=x.join(e,`package.json`),i=await A(r,`utf8`).catch(()=>void 0),a=i===void 0?{}:Zt(i,r),o=n.productName??u(a.name);return o&&Gt(o),{name:o,identifier:n.identifier??(o?l(o):void 0),window:n.window,...t&&{dev:{stackPaths:en(n)}}}}function an(e){var t=[...arguments].slice(1),n=Array.from(typeof e==`string`?[e]:e);n[n.length-1]=n[n.length-1].replace(/\r?\n([\t ]*)$/,``);var r=n.reduce(function(e,t){var n=t.match(/\n([\t ]+|(?!\s).)/g);return n?e.concat(n.map(function(e){return e.match(/[\t ]/g)?.length??0})):e},[]);if(r.length){var i=RegExp(`
1
+ import{t as e}from"./chunks/rolldown-runtime-DT7IzrpZ.js";import{c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./chunks/dist-B-B_PlmU.js";import{i as c,n as l,r as u,t as d}from"./chunks/defaults-DfHXv1fN.js";import{createRequire as f}from"node:module";import p,{constants as m,existsSync as h,lstatSync as g,readFileSync as _,realpathSync as v,statSync as y,watch as ee}from"node:fs";import b,{resolve as x}from"node:path";import*as S from"node:util";import{parseArgs as C,styleText as w}from"node:util";import{access as T,chmod as E,cp as D,link as O,mkdir as k,readFile as A,readdir as j,rename as te,rm as M,stat as N,writeFile as P}from"node:fs/promises";import{fileURLToPath as ne,pathToFileURL as F}from"node:url";import{homedir as I}from"node:os";import re from"@vitejs/plugin-vue";import{DevEnvironment as ie,build as L,buildErrorMessage as ae,createServer as oe,isCSSRequest as se}from"vite";import{spawn as ce,spawnSync as le}from"node:child_process";import{once as ue}from"node:events";import de from"node:readline";import{setTimeout as fe}from"node:timers/promises";import{createHash as pe,randomBytes as me,randomUUID as he}from"node:crypto";import{brotliDecompressSync as ge}from"node:zlib";const _e=/\d/,ve=[`-`,`_`,`/`,`.`];function ye(e=``){if(!_e.test(e))return e!==e.toLowerCase()}function be(e,t){let n=t??ve,r=[];if(!e||typeof e!=`string`)return r;let i=``,a,o;for(let t of e){let e=n.includes(t);if(e===!0){r.push(i),i=``,a=void 0;continue}let s=ye(t);if(o===!1){if(a===!1&&s===!0){r.push(i),i=t,a=s;continue}if(a===!0&&s===!1&&i.length>1){let e=i.at(-1);r.push(i.slice(0,Math.max(0,i.length-1))),i=e+t,a=s;continue}}i+=t,a=s,o=e}return r.push(i),r}function xe(e){return e?e[0].toUpperCase()+e.slice(1):``}function Se(e){return e?e[0].toLowerCase()+e.slice(1):``}function Ce(e,t){return e?(Array.isArray(e)?e:be(e)).map(e=>xe(t?.normalize?e.toLowerCase():e)).join(``):``}function R(e,t){return Se(Ce(e||``,t))}function we(e,t){return e?(Array.isArray(e)?e:be(e)).map(e=>e.toLowerCase()).join(t??`-`):``}function Te(e){return we(e||``,`_`)}function z(e){return Array.isArray(e)?e:e===void 0?[]:[e]}function Ee(e,t=``){let n=[];for(let t of e)for(let[e,r]of t.entries())n[e]=Math.max(n[e]||0,r.length);return e.map(e=>e.map((e,r)=>t+e[r===0?`padStart`:`padEnd`](n[r])).join(` `)).join(`
2
+ `)}function B(e){return typeof e==`function`?e():e}var V=class extends Error{code;constructor(e,t){super(e),this.name=`CLIError`,this.code=t}};function De(e=[],t={}){let n=new Set(t.boolean||[]),r=new Set(t.string||[]),i=t.alias||{},a=t.default||{},o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map;for(let[e,t]of Object.entries(i)){let n=t;for(let t of n)o.set(e,t),s.has(t)||s.set(t,[]),s.get(t).push(e),o.set(t,e),s.has(e)||s.set(e,[]),s.get(e).push(t)}let c={};function l(e){if(n.has(e))return`boolean`;let t=s.get(e)||[];for(let e of t)if(n.has(e))return`boolean`;return`string`}function u(e){if(r.has(e))return!0;let t=s.get(e)||[];for(let e of t)if(r.has(e))return!0;return!1}let d=/* @__PURE__ */ new Set([...n,...r,...Object.keys(i),...Object.values(i).flat(),...Object.keys(a)]);for(let e of d)c[e]||(c[e]={type:l(e),default:a[e]});for(let[e,t]of o.entries())e.length===1&&c[t]&&!c[t].short&&(c[t].short=e);let f=[],p={};for(let t=0;t<e.length;t++){let n=e[t];if(n===`--`){f.push(...e.slice(t));break}if(n.startsWith(`--no-`)){let e=n.slice(5);p[e]=!0}else f.push(n)}let m;try{m=C({args:f,options:Object.keys(c).length>0?c:void 0,allowPositionals:!0,strict:!1})}catch{m={values:{},positionals:f}}let h={_:[]};h._=m.positionals;for(let[e,t]of Object.entries(m.values)){let n=t;l(e)===`boolean`&&typeof t==`string`?n=t!==`false`:u(e)&&typeof t==`boolean`&&(n=``),h[e]=n}for(let[e]of Object.entries(p)){h[e]=!1;let t=o.get(e);t&&(h[t]=!1);let n=s.get(e);if(n)for(let e of n)h[e]=!1}for(let[e,t]of o.entries())h[e]!==void 0&&h[t]===void 0&&(h[t]=h[e]),h[t]!==void 0&&h[e]===void 0&&(h[e]=h[t]),h[e]!==h[t]&&a[t]===h[t]&&(h[t]=h[e]);return h}const Oe=/* @__PURE__ */ (()=>{let e=globalThis.process?.env??{};return e.NO_COLOR===`1`||e.TERM===`dumb`||e.TEST||e.CI})(),ke=(e,t=39)=>n=>Oe?n:`\u001B[${e}m${n}\u001B[${t}m`,Ae=/* @__PURE__ */ ke(1,22),H=/* @__PURE__ */ ke(36),je=/* @__PURE__ */ ke(90),Me=/* @__PURE__ */ ke(4,24);function Ne(e,t){let n={boolean:[],string:[],alias:{},default:{}},r=Pe(t);for(let e of r){if(e.type===`positional`)continue;e.type===`string`||e.type===`enum`?n.string.push(e.name):e.type===`boolean`&&n.boolean.push(e.name),e.default!==void 0&&(n.default[e.name]=e.default),e.alias&&(n.alias[e.name]=e.alias);let t=R(e.name),r=we(e.name);if(t!==e.name||r!==e.name){let i=z(n.alias[e.name]||[]);t!==e.name&&!i.includes(t)&&i.push(t),r!==e.name&&!i.includes(r)&&i.push(r),i.length>0&&(n.alias[e.name]=i)}}let i=De(e,n),[...a]=i._,o=new Proxy(i,{get(e,t){return e[t]??e[R(t)]??e[we(t)]}});for(let[,e]of r.entries())if(e.type===`positional`){let t=a.shift();if(t!==void 0)o[e.name]=t;else if(e.default===void 0&&e.required!==!1)throw new V(`Missing required positional argument: ${e.name.toUpperCase()}`,`EARG`);else o[e.name]=e.default}else if(e.type===`enum`){let t=o[e.name],n=e.options||[];if(t!==void 0&&n.length>0&&!n.includes(t))throw new V(`Invalid value for argument: ${H(`--${e.name}`)} (${H(t)}). Expected one of: ${n.map(e=>H(e)).join(`, `)}.`,`EARG`)}else if(e.required&&o[e.name]===void 0)throw new V(`Missing required argument: --${e.name}`,`EARG`);return o}function Pe(e){let t=[];for(let[n,r]of Object.entries(e||{}))t.push({...r,name:n,alias:z(r.alias)});return t}async function Fe(e){return Promise.all(e.map(e=>B(e)))}function U(e){return e}async function Ie(e,t){let n=await B(e.args||{}),r=Ne(t.rawArgs,n),i={rawArgs:t.rawArgs,args:r,data:t.data,cmd:e},a=await Fe(e.plugins??[]),o,s;try{for(let e of a)await e.setup?.(i);typeof e.setup==`function`&&await e.setup(i);let r=await B(e.subCommands);if(r&&Object.keys(r).length>0){let i=ze(t.rawArgs,n),a=t.rawArgs[i];if(a){let e=await Re(r,a);if(!e)throw new V(`Unknown command ${H(a)}`,`E_UNKNOWN_COMMAND`);await Ie(e,{rawArgs:t.rawArgs.slice(i+1)})}else{let n=await B(e.default);if(n){if(e.run)throw new V(`Cannot specify both 'run' and 'default' on the same command.`,`E_DEFAULT_CONFLICT`);let i=await Re(r,n);if(!i)throw new V(`Default sub command ${H(n)} not found in subCommands.`,`E_UNKNOWN_COMMAND`);await Ie(i,{rawArgs:t.rawArgs})}else if(!e.run)throw new V(`No command specified.`,`E_NO_COMMAND`)}}typeof e.run==`function`&&(o=await e.run(i))}catch(e){s=e}let c=[];if(typeof e.cleanup==`function`)try{await e.cleanup(i)}catch(e){c.push(e)}for(let e of[...a].reverse())try{await e.cleanup?.(i)}catch(e){c.push(e)}if(s)throw s;if(c.length===1)throw c[0];if(c.length>1)throw Error(`Multiple cleanup errors`,{cause:c});return{result:o}}async function Le(e,t,n){let r=await B(e.subCommands);if(r&&Object.keys(r).length>0){let n=ze(t,await B(e.args||{})),i=t[n],a=await Re(r,i);if(a)return Le(a,t.slice(n+1),e)}return[e,n]}async function Re(e,t){if(t in e)return B(e[t]);for(let n of Object.values(e)){let e=await B(n),r=await B(e?.meta);if(r?.alias&&z(r.alias).includes(t))return e}}function ze(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r===`--`)return-1;if(r.startsWith(`-`))!r.includes(`=`)&&Be(r,t)&&n++;else return n}return-1}function Be(e,t){let n=e.replace(/^-{1,2}/,``),r=R(n);for(let[e,i]of Object.entries(t))if((i.type===`string`||i.type===`enum`)&&(r===R(e)||(Array.isArray(i.alias)?i.alias:i.alias?[i.alias]:[]).includes(n)))return!0;return!1}async function Ve(e,t){try{console.log(await Ue(e,t)+`
3
+ `)}catch(e){console.error(e)}}const He=/^no[-A-Z]/;async function Ue(e,t){let n=await B(e.meta||{}),r=Pe(await B(e.args||{})),i=await B(t?.meta||{}),a=`${i.name?`${i.name} `:``}`+(n.name||process.argv[1]),o=[],s=[],c=[],l=[];for(let e of r)if(e.type===`positional`){let t=e.name.toUpperCase(),n=e.required!==!1&&e.default===void 0;s.push([H(t+We(e)),Ge(e,n)]),l.push(n?`<${t}>`:`[${t}]`)}else{let t=e.required===!0&&e.default===void 0,n=[...(e.alias||[]).map(e=>`-${e}`),`--${e.name}`].join(`, `)+We(e);if(o.push([H(n),Ge(e,t)]),e.type===`boolean`&&(e.default===!0||e.negativeDescription)&&!He.test(e.name)){let n=[...(e.alias||[]).map(e=>`--no-${e}`),`--no-${e.name}`].join(`, `);o.push([H(n),[e.negativeDescription,t?je(`(Required)`):``].filter(Boolean).join(` `)])}t&&l.push(`--${e.name}`+We(e))}if(e.subCommands){let t=[],n=await B(e.subCommands);for(let[e,r]of Object.entries(n)){let n=await B((await B(r))?.meta);if(n?.hidden)continue;let i=z(n?.alias),a=[e,...i].join(`, `);c.push([H(a),n?.description||``]),t.push(e,...i)}l.push(t.join(`|`))}let u=[],d=n.version||i.version;u.push(je(`${n.description} (${a+(d?` v${d}`:``)})`),``);let f=o.length>0||s.length>0;return u.push(`${Me(Ae(`USAGE`))} ${H(`${a}${f?` [OPTIONS]`:``} ${l.join(` `)}`)}`,``),s.length>0&&(u.push(Me(Ae(`ARGUMENTS`)),``),u.push(Ee(s,` `)),u.push(``)),o.length>0&&(u.push(Me(Ae(`OPTIONS`)),``),u.push(Ee(o,` `)),u.push(``)),c.length>0&&(u.push(Me(Ae(`COMMANDS`)),``),u.push(Ee(c,` `)),u.push(``,`Use ${H(`${a} <command> --help`)} for more information about a command.`)),u.filter(e=>typeof e==`string`).join(`
4
+ `)}function We(e){let t=e.valueHint?`=<${e.valueHint}>`:``,n=t||`=<${Te(e.name)}>`;return!e.type||e.type===`positional`||e.type===`boolean`?t:e.type===`enum`&&e.options?.length?`=<${e.options.join(`|`)}>`:n}function Ge(e,t){let n=t?je(`(Required)`):``,r=e.default===void 0?``:je(`(Default: ${e.default})`);return[e.description,n,r].filter(Boolean).join(` `)}async function Ke(e,t={}){let n=t.rawArgs||process.argv.slice(2),r=t.showUsage||Ve;try{let t=await qe(e);if(t.help.length>0&&n.some(e=>t.help.includes(e)))await r(...await Le(e,n)),process.exit(0);else if(n.length===1&&t.version.includes(n[0])){let t=typeof e.meta==`function`?await e.meta():await e.meta;if(!t?.version)throw new V(`No version specified`,`E_NO_VERSION`);console.log(t.version)}else await Ie(e,{rawArgs:n})}catch(t){t instanceof V?(await r(...await Le(e,n)),console.error(t.message)):console.error(t,`
5
+ `),process.exit(1)}}async function qe(e){let t=await B(e.args||{}),n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set;for(let[e,i]of Object.entries(t)){n.add(e);for(let e of z(i.alias))r.add(e)}return{help:Je(`help`,`h`,n,r),version:Je(`version`,`v`,n,r)}}function Je(e,t,n,r){return n.has(e)||r.has(e)?[]:n.has(t)||r.has(t)?[`--${e}`]:[`--${e}`,`-${t}`]}var Ye=`0.0.30`,Xe=`Commands to develop, bundle, and package Incarnative.js apps.`;function Ze(e,t,n){let r=typeof e==`object`&&e?e:{},i=b.relative(n,t).split(b.sep).join(`/`);return{...r,root:i===``?`.`:i}}function Qe(e){return e&&e.constructor&&typeof e.constructor.isBuffer==`function`&&e.constructor.isBuffer(e)}function $e(e){return e}function et(e,t){t||={};let n=t.delimiter||`.`,r=t.maxDepth,i=t.transformKey||$e,a={};function o(e,s,c){c||=1,Object.keys(e).forEach(function(l){let u=e[l],d=t.safe&&Array.isArray(u),f=Object.prototype.toString.call(u),p=Qe(u),m=f===`[object Object]`||f===`[object Array]`,h=s?s+n+i(l):i(l);if(!d&&!p&&m&&Object.keys(u).length&&(!t.maxDepth||c<r))return o(u,h,c+1);a[h]=u})}return o(e),a}function tt(e,t){t||={};let n=t.delimiter||`.`,r=t.overwrite||!1,i=t.transformKey||$e,a={};if(Qe(e)||Object.prototype.toString.call(e)!==`[object Object]`)return e;function o(e){let n=Number(e);return isNaN(n)||e.indexOf(`.`)!==-1||t.object?e:n}function s(e,t,r){return Object.keys(r).reduce(function(t,i){return t[e+n+i]=r[i],t},t)}function c(e){let t=Object.prototype.toString.call(e),n=t===`[object Array]`,r=t===`[object Object]`;if(!e)return!0;if(n)return!e.length;if(r)return!Object.keys(e).length}return e=Object.keys(e).reduce(function(n,r){let i=Object.prototype.toString.call(e[r]);return i!==`[object Object]`&&i!==`[object Array]`||c(e[r])?(n[r]=e[r],n):s(r,n,et(e[r],t))},{}),Object.keys(e).forEach(function(s){let c=s.split(n).map(i),l=o(c.shift()),u=o(c[0]),d=a;for(;u!==void 0;){if(l===`__proto__`)return;let e=Object.prototype.toString.call(d[l]),n=e===`[object Object]`||e===`[object Array]`;if(!r&&!n&&d[l]!==void 0)return;(r&&!n||!r&&d[l]==null)&&(d[l]=typeof u==`number`&&!t.object?[]:{}),d=d[l],c.length>0&&(l=o(c.shift()),u=o(c[0]))}d[l]=tt(e[s],t)}),a}const nt=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,rt=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,it=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function at(e,t){if(e===`__proto__`||e===`constructor`&&t&&typeof t==`object`&&`prototype`in t)ot(e);else return t}function ot(e){console.warn(`[destr] Dropping "${e}" key to prevent prototype pollution.`)}function st(e,t={}){if(typeof e!=`string`)return e;if(e[0]===`"`&&e[e.length-1]===`"`&&e.indexOf(`\\`)===-1)return e.slice(1,-1);let n=e.trim();if(n.length<=9)switch(n.toLowerCase()){case`true`:return!0;case`false`:return!1;case`undefined`:return;case`null`:return null;case`nan`:return NaN;case`infinity`:return 1/0;case`-infinity`:return-1/0}if(!it.test(e)){if(t.strict)throw SyntaxError(`[destr] Invalid JSON`);return e}try{if(nt.test(e)||rt.test(e)){if(t.strict)throw Error(`[destr] Possible prototype pollution`);return JSON.parse(e,at)}return JSON.parse(e)}catch(n){if(t.strict)throw n;return e}}function ct(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)===`[object Module]`:!0}function lt(e,t,n=`.`,r){if(!ct(t))return lt(e,{},n,r);let i={...t};for(let t of Object.keys(e)){if(t===`__proto__`||t===`constructor`)continue;let a=e[t];a!=null&&(r&&r(i,t,a,n)||(i[t]=Array.isArray(a)&&Array.isArray(i[t])?[...a,...i[t]]:ct(a)&&ct(i[t])?lt(a,i[t],(n?`${n}.`:``)+t.toString(),r):a))}return i}function ut(e){return(...t)=>t.reduce((t,n)=>lt(t,n,``,e),{})}const dt=ut(),ft=/^\s*([^\s=]+)\s*=\s*(.*)?\s*$/,pt=/\n|\r|\r\n/,mt={name:`.conf`,dir:process.cwd(),flat:!1};function ht(e){return typeof e==`string`&&(e={name:e}),{...mt,...e}}function gt(e,t={}){let n={},r=e.split(pt);for(let e of r){let t=e.match(ft);if(!t)continue;let r=t[1];if(!r||r===`__proto__`||r===`constructor`)continue;let i=st((t[2]||``).trim());if(r.endsWith(`[]`)){let e=r.slice(0,Math.max(0,r.length-2));n[e]=(n[e]||[]).concat(i)}else n[r]=i}return t.flat?n:tt(n,{overwrite:!0})}function _t(e,t){return h(e)?gt(_(e,`utf8`),t):{}}function vt(e){return e=ht(e),_t(x(e.dir,e.name),e)}function yt(){return process.env.XDG_CONFIG_HOME||x(I(),`.config`)}function bt(e){return e=ht(e),e.dir=yt(),vt(e)}async function xt(e){let t=e.env??process.env,n=await St({cwd:e.cwd,fileName:e.fileName??`.env`,env:t,interpolate:e.interpolate??!0,expandFileReferences:e.expandFileReferences??!1,parse:e.parse}),r=At(t);for(let e in n)e.startsWith(`_`)||(t[e]===void 0||r.has(e))&&(t[e]=n[e]);return n}async function St(e){let n=Object.create(null),r=t(e.cwd||`.`),i=e.fileName||`.env`,a=typeof i==`string`?[i]:i,o=At(e.env||{});Object.assign(n,e.env);for(let i of a){let a=t(r,i);if(!y(a,{throwIfNoEntry:!1})?.isFile())continue;let s=await wt(a,e.parse);for(let e in s)e in n&&!o.has(e)||(n[e]=s[e],o.add(e))}if(e.expandFileReferences){for(let e in n)if(e.endsWith(`_FILE`)){let t=e.slice(0,-5);if(n[t]===void 0){let r=n[e];r&&y(r,{throwIfNoEntry:!1})?.isFile()&&(n[t]=_(r,`utf8`).trim(),o.add(t))}}}return e.interpolate&&Tt(n),n}let Ct=S.parseEnv;async function wt(e,t){let n=_(e,`utf8`);if(t)return t(n);if(!Ct)try{let e=await import(`dotenv`);Ct=t=>e.parse(t)}catch{throw Error("Failed to parse .env file: `node:util.parseEnv` is not available and `dotenv` package is not installed. Please upgrade your runtime, install `dotenv` as a dependency or provide a custom `parse` option.")}return Ct(n)}function Tt(e,t={},n=e=>e){function r(n){return t[n]===void 0?e[n]:t[n]}function i(e,t=[]){if(typeof e!=`string`)return e;let a=``,o=0;for(;o<e.length;){let n=e[o];if(n===`\\`&&e[o+1]===`$`){a+=`$`,o+=2;continue}let s=n===`$`?Ot(e,o):void 0;if(!s){a+=n,o++;continue}if(t.includes(s.key)){if(s.defaultValue!==void 0){a+=i(s.defaultValue,t),o=s.end;continue}return console.warn(`Please avoid recursive environment variables ( loop: ${t.join(` > `)} > ${s.key} )`),``}let c=i(r(s.key),[...t,s.key]);s.defaultValue!==void 0&&(c===void 0||s.operator===`:-`&&c===``)&&(c=i(s.defaultValue,t)),a+=c===void 0?e.slice(o,s.end):c,o=s.end}return n(a)}for(let t in e)e[t]=i(r(t))}const Et=/\w+/y,Dt=/[\w:]+/y;function Ot(e,t){let n=t+1,r=e[n]===`{`;r&&n++;let i=r?Dt:Et;i.lastIndex=n;let a=i.exec(e);if(!a)return;let o=a[0];if(n=i.lastIndex,!r)return{key:o,end:n};if(e[n]===`}`)return{key:o,end:n+1};if(e[n]===`-`){let t=`-`;o.endsWith(`:`)&&(o=o.slice(0,-1),t=`:-`);let r=o?kt(e,n+1):void 0;return r?{key:o,operator:t,defaultValue:r.value,end:r.end}:void 0}return{key:o,end:n}}function kt(e,t){let n=``,r=1;for(let i=t;i<e.length;i++){let t=e[i];if(t===`\\`&&i+1<e.length){let r=e[i+1];n+=r===`{`||r===`}`?r:t+r,i++}else if(t===`$`&&e[i+1]===`{`)r++,n+="${",i++;else{if(t===`{`&&r++,t===`}`&&(r--,r===0))return{value:n,end:i+1};n+=t}}}function At(e){let t=globalThis.__c12_dotenv_vars__||=/* @__PURE__ */ new Map;return t.has(e)||t.set(e,/* @__PURE__ */ new Set),t.get(e)}const jt=e=>e?.replace(/\\/g,`/`);let Mt=0;const Nt={".json":()=>JSON.parse,".yaml":()=>import(`./chunks/yaml-DtBxpt6z.js`).then(e=>e.parseYAML),".yml":()=>import(`./chunks/yaml-DtBxpt6z.js`).then(e=>e.parseYAML),".jsonc":()=>import(`./chunks/jsonc-DJWoCi14.js`).then(e=>e.n).then(e=>t=>e.parseJSONC(t,{allowTrailingComma:!0})),".json5":()=>import(`./chunks/json5-BcF68iGq.js`).then(e=>e.parseJSON5),".toml":()=>import(`./chunks/toml-n3nLqi2g.js`).then(e=>e.parseTOML)},Pt=Object.freeze([`.js`,`.ts`,`.mjs`,`.cjs`,`.mts`,`.cts`,`.json`,`.jsonc`,`.json5`,`.yaml`,`.yml`,`.toml`]);async function Ft(e){e.cwd=t(process.cwd(),e.cwd||`.`),e.name=e.name||`config`,e.envName=e.envName??process.env.NODE_ENV,e.configFile=e.configFile??(e.name===`config`?`config`:`${e.name}.config`),e.rcFile=e.rcFile??`.${e.name}rc`,e.extend!==!1&&(e.extend={extendKey:`extends`,...e.extend});let n=e.merger||dt,r={config:{},cwd:e.cwd,configFile:t(e.cwd,e.configFile),layers:[],_configFile:void 0},i={overrides:e.overrides,main:void 0,rc:void 0,packageJson:void 0,defaultConfig:e.defaultConfig};e.dotenv&&await xt({cwd:e.cwd,...e.dotenv===!0?{}:e.dotenv});let a=await zt(`.`,e);if(a.configFile&&(i.main=a.config,r.configFile=a.configFile,r._configFile=a._configFile),a.meta&&(r.meta=a.meta),e.rcFile){let t=[];if(t.push(vt({name:e.rcFile,dir:e.cwd})),e.globalRc){let{findWorkspaceDir:n}=await import(`./chunks/dist-BTWvruNB.js`),r=await n(e.cwd).catch(()=>{});r&&t.push(vt({name:e.rcFile,dir:r})),t.push(bt({name:e.rcFile})),t.push(vt({name:e.rcFile,dir:I()}))}i.rc=n({},...t)}if(e.packageJson){let t=(Array.isArray(e.packageJson)?e.packageJson:[typeof e.packageJson==`string`?e.packageJson:e.name]).filter(e=>e&&typeof e==`string`),{readPackageJSON:r}=await import(`./chunks/dist-BTWvruNB.js`),a=await r(e.cwd).catch(()=>{});i.packageJson=n({},...t.map(e=>a?.[e]))}let o={};for(let e in i){let t=i[e];o[e]=await(typeof t==`function`?t({configs:o,rawConfigs:i}):t)}if(Array.isArray(o.main)?r.config=o.main:(r.config=n(o.overrides,o.main,o.rc,o.packageJson,o.defaultConfig),e.extend&&(await It(r.config,e),r.layers=r.config._layers,delete r.config._layers,r.config=n(r.config,...r.layers.map(e=>e.config)))),r.layers=[...[o.overrides&&{config:o.overrides,configFile:void 0,cwd:void 0},{config:o.main,configFile:e.configFile,cwd:e.cwd},o.rc&&{config:o.rc,configFile:e.rcFile},o.packageJson&&{config:o.packageJson,configFile:`package.json`}].filter(e=>e&&e.config),...r.layers],e.defaults&&(r.config=n(r.config,e.defaults)),e.omit$Keys)for(let e in r.config)e.startsWith(`$`)&&delete r.config[e];if(e.configFileRequired&&!r._configFile)throw Error(`Required config (${r.configFile}) cannot be resolved.`);return e.schema!=null&&(r.config=await Bt(r.config,e.schema)),r}async function It(e,t){if(e._layers=e._layers||[],!t.extend)return;let n=t.extend.extendKey;typeof n==`string`&&(n=[n]);let r=[];for(let t of n)r.push(...(Array.isArray(e[t])?e[t]:[e[t]]).filter(Boolean)),delete e[t];for(let n of r){let r=n,i={};if(n.source&&(i=n.options||{},n=n.source),Array.isArray(n)&&(i=n[1]||{},n=n[0]),typeof n!=`string`){console.warn(`Cannot extend config from \`${JSON.stringify(r)}\` in ${t.cwd}`);continue}let a=await zt(n,t,i);a.config?(await It(a.config,{...t,cwd:a.cwd}),e._layers.push(a),a.config._layers&&(e._layers.push(...a.config._layers),delete a.config._layers)):console.warn(`Cannot extend config from \`${n}\` in ${t.cwd}`)}}const Lt=[`gh:`,`github:`,`gitlab:`,`bitbucket:`,`https://`,`http://`],Rt=/^(@[\da-z~-][\d._a-z~-]*\/)?[\da-z~-][\d._a-z~-]*($|\/.*)/;async function zt(e,o,s={}){if(o.resolve){let t=await o.resolve(e,o);if(t)return t}let c=o.merger||dt,l=Object.keys(s.giget?.providers||{}).map(e=>`${e}:`),u=l.length>0?[.../* @__PURE__ */ new Set([...l,...Lt])]:Lt;if(o.giget!==!1&&u.some(t=>e.startsWith(t))){let{downloadTemplate:n}=await import(`giget`).catch(t=>{throw Error(`Extending config from \`${e}\` requires \`giget\` peer dependency to be installed.\n\nInstall it with: \`npx nypm i giget\``,{cause:t})}),{digest:c}=await import(`./chunks/ohash-DUMW2FP0.js`).then(e=>e.dist_exports),l=e.replace(/\W+/g,`_`).split(`_`).splice(0,3).join(`_`)+`_`+c(e).slice(0,10).replace(/[-_]/g,``),u,d=t(o.cwd,`node_modules`),f=a(o.cwd);u=r(f)===`.c12`?i(f,l):h(d)?i(d,`.c12`,l):process.env.XDG_CACHE_HOME?t(process.env.XDG_CACHE_HOME,`c12`,l):t(I(),`.cache/c12`,l);let p=s.install?dt(s.install===!0?{}:s.install,{ignoreWorkspace:!0}):!1;h(u)&&!p&&await M(u,{recursive:!0}),e=(await n(e,{dir:u,install:p,force:!!p,auth:s.auth,...o.giget,...s.giget})).dir}Rt.test(e)&&(e=Vt(e,o)||e);let d=n(e),f=Ht(t(o.cwd,e))??(!d||d===r(e)),p=t(o.cwd,f?e:a(e));f&&(e=o.configFile);let m={config:void 0,configFile:void 0,cwd:p,source:e,sourceOptions:s};if(m.configFile=Vt(t(p,e),o)||Vt(t(p,`.config`,e.replace(/\.config$/,``)),o)||Vt(t(p,`.config`,e),o)||e,!h(m.configFile))return m;m._configFile=m.configFile;let g=n(m.configFile)||``;if(g in Nt)m.config=(await Nt[g]())(await A(m.configFile,`utf8`));else{let e=o.resolveModule||(e=>e.default||e);if(o.import)m.config=e(await o.import(m.configFile));else{let t=F(m.configFile);t.search=`_${++Mt}`,m.config=await import(t.href).then(e,async t=>{let{createJiti:n}=await import(`jiti`).catch(()=>{throw Error(`Failed to load config file \`${m.configFile}\`: ${t?.message}. Hint install \`jiti\` for compatibility.`,{cause:t})}),r=n(i(o.cwd||`.`,o.configFile||`/`),{interopDefault:!0,moduleCache:!1,extensions:[...Pt],...o.jitiOptions});return o.import=e=>r.import(e),e(await o.import(m.configFile))})}}typeof m.config==`function`&&(m.config=await m.config(o.context)),m.config&&typeof m.config==`object`&&!Array.isArray(m.config)&&!Object.isExtensible(m.config)&&(m.config={...m.config});let _=(Array.isArray(o.envName)?o.envName:[o.envName]).filter(Boolean).reverse().flatMap(e=>[m.config.$env?.[e],m.config[`$`+e]]).filter(e=>e&&Object.keys(e).length>0);return _.length>0&&(m.config=(o.envMerger||c)({},..._,m.config)),m.meta=dt(m.sourceOptions.meta,m.config.$meta),delete m.config.$meta,m.sourceOptions.overrides&&(m.config=c(m.sourceOptions.overrides,m.config)),m.configFile=jt(m.configFile),m.source=jt(m.source),m}async function Bt(e,t){if(typeof t?.[`~standard`]?.validate!=`function`)throw TypeError("Invalid `schema` option: expected a Standard Schema (https://standardschema.dev).");let n=await t[`~standard`].validate(e);if(n.issues){let e=n.issues.map(e=>{let t=e.path?.map(e=>String(typeof e==`object`?e.key:e)).join(`.`);return` - ${t?`${t}: `:``}${e.message}`});throw Error(`Config validation failed (${t[`~standard`].vendor}):\n${e.join(`
6
+ `)}`,{cause:n.issues})}return n.value}function Vt(e,t){let n=s(e,{try:!0,from:F(i(t.cwd||`.`,t.configFile||`/`)),suffixes:[``,`/index`],extensions:Pt,cache:!1});return n?o(n):void 0}function Ht(e){try{return y(e).isDirectory()}catch{return null}}var W=class extends Error{code;path;name=`IncaError`;constructor(e,t,n){super(t),this.code=e,this.path=n}},Ut=class extends Error{code;hostStack;constructor(e,t,n=null){super(e),this.code=t,this.hostStack=n,this.name=`HostError`}};const Wt={name:`inca`,packageJson:`inca`,rcFile:!1,globalRc:!1,giget:!1,extend:!1},Gt=[`.js`,`.ts`,`.mjs`,`.cjs`,`.mts`,`.cts`],Kt=/[/\\:*?"<>|\0]/;function qt(e){return e===e.trim()&&e!==``&&e!==`.`&&e!==`..`&&!Kt.test(e)}function Jt(e){if(!(typeof e==`string`&&qt(e)))throw new W(`ERR_INCA_PRODUCT_NAME_INVALID`,`${JSON.stringify(e)} can't name a directory. set a "productName" in inca.config.ts with no leading or trailing space, and none of \`/\\:*?"<>|\``)}const Yt=process.platform===`darwin`||process.platform===`win32`;function Xt(e,t){let n=e=>Yt?e.toLowerCase():e,r=b.relative(n(e),n(t));return r===``||r!==`..`&&!r.startsWith(`..${b.sep}`)&&!b.isAbsolute(r)}function Zt(e){let t=b.resolve(e),n=t;for(let e;!g(n,{throwIfNoEntry:!1})&&(e=b.dirname(n))!==n;)n=e;return b.join(v.native(n),b.relative(n,t))}function Qt(e,t,n){let r=b.resolve(e,t),i;try{let t=Zt(r);i=[e,b.join(e,`src`),b.join(e,`node_modules`),...n?[n]:[]].some(e=>Xt(t,Zt(e)))}catch{i=!0}if(i)throw new W(`ERR_INCA_OUT_DIR_INVALID`,`"outDir" resolves to ${r}, which holds the app's own files. Set it to a directory the build can own, such as "dist"`)}function $t(e,t,n){let r=b.resolve(e,t??d.outDir);return Qt(e,r,n),r}function en(e,t){try{return JSON.parse(e)}catch(e){throw new W(`ERR_INCA_PACKAGE_JSON_INVALID`,`${t} holds malformed JSON: ${e.message}`,t)}}async function tn(e){let t=f(import.meta.url).cache;for(let n of Gt)delete t[b.join(e,`inca.config`+n)];let{config:n,layers:r}=await Ft({cwd:e,...Wt}),i=r?.find(e=>e.configFile===`package.json`);return{config:n,usedPackageJsonKey:Object.keys(i?.config??{}).length>0}}async function nn(e){let{config:t}=await tn(e),n=t.entry?b.resolve(e,t.entry):void 0;return{entry:n,outDir:$t(e,t.outDir,n),sourcemap:t.sourcemap??d.sourcemap}}function rn(e){return e.dev?.stackPaths??d.dev.stackPaths}async function an(e){let t=b.join(e,`package.json`),n;try{n=await A(t,`utf8`)}catch{throw new W(`ERR_INCA_PACKAGE_JSON_NOT_FOUND`,`no package.json found at ${t}`)}let r=en(n,t),{config:i,usedPackageJsonKey:a}=await tn(e),o=i.productName??u(r.name);if(!o)throw new W(`ERR_INCA_PRODUCT_NAME_MISSING`,`${t} needs a "name", or "productName" in inca.config.ts`);Jt(o);let s=i.version??r.version??d.version,c=i.identifier??l(o),f;if(i.icon&&(f=b.resolve(e,i.icon),!h(f)))throw new W(`ERR_INCA_ICON_NOT_FOUND`,`"icon" points to ${f}, which doesn't exist`,f);let p=i.entry?b.resolve(e,i.entry):void 0,m=$t(e,i.outDir,p);return{productName:o,identifier:c,identifierIsDefault:i.identifier===void 0,version:s,icon:f,window:i.window,dev:{stackPaths:rn(i)},entry:p,outDir:m,sourcemap:i.sourcemap??d.sourcemap,usedPackageJsonKey:a}}function on(e,{dev:t=!1}={}){return{name:e.productName,identifier:e.identifier,window:e.window,...t&&{dev:{stackPaths:e.dev.stackPaths}}}}async function sn(e,{dev:t=!1}={}){let{config:n}=await tn(e),r=b.join(e,`package.json`),i=await A(r,`utf8`).catch(()=>void 0),a=i===void 0?{}:en(i,r),o=n.productName??u(a.name);return o&&Jt(o),{name:o,identifier:n.identifier??(o?l(o):void 0),window:n.window,...t&&{dev:{stackPaths:rn(n)}}}}function G(e){var t=[...arguments].slice(1),n=Array.from(typeof e==`string`?[e]:e);n[n.length-1]=n[n.length-1].replace(/\r?\n([\t ]*)$/,``);var r=n.reduce(function(e,t){var n=t.match(/\n([\t ]+|(?!\s).)/g);return n?e.concat(n.map(function(e){return e.match(/[\t ]/g)?.length??0})):e},[]);if(r.length){var i=RegExp(`
7
7
  [ ]{${Math.min.apply(Math,r)}}`,`g`);n=n.map(function(e){return e.replace(i,`
8
8
  `)})}n[0]=n[0].replace(/^\r?\n/,``);var a=n[0];return t.forEach(function(e,t){var r=a.match(/(?:^|\n)( *)$/),i=r?r[1]:``,o=e;typeof e==`string`&&e.includes(`
9
9
  `)&&(o=String(e).split(`
10
10
  `).map(function(e,t){return t===0?e:`${i}${e}`}).join(`
11
- `)),a+=o+n[t+1]}),a}const on=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`numeric`,second:`numeric`}),q={timestamp:!0};function sn(e,t,n){let r=T([`bold`,n],`[inca]`,{stream:e});return t.timestamp?`${T(`dim`,on.format(/* @__PURE__ */ new Date),{stream:e})} ${r}`:r}function J(e,t,n={}){e.write(`${sn(e,n,`cyan`)} ${t}\n`)}function cn(e,t,n={}){e.write(`${sn(e,n,`yellow`)} ${t}\n`)}function ln(e){let t=e.code;return typeof t==`string`?t:null}function un(e){return/\bERR_INCA_[A-Z0-9_]+/.exec(e)?.[0]??null}function dn(e){let t=e.stack;if(!t)return null;for(let n of[`${e.name}: ${e.message}`,e.message])if(t.startsWith(n))return t.slice(n.length).replace(/^\r?\n/,``)||null;return t}function fn(e){let t=/^(?:\w*Error: )?(ERR_INCA_[A-Z0-9_]+): /.exec(e);return t?{message:e.slice(t[0].length),stack:null,code:t[1]}:{message:e.replace(/^\w*Error: /,``),stack:null,code:null}}function Y(e){return e instanceof Bt?{message:e.message,stack:e.hostStack,code:ln(e)}:e instanceof Error?{message:e.message,stack:dn(e),code:ln(e)??un(e.message)}:{message:String(e),stack:null,code:null}}function pn(e,t){return e.split(`
12
- `).map(e=>/^\s*at\b/.test(e)?T(`dim`,e,{stream:t}):e).join(`
13
- `)}function X(e,t,n,r={}){n.stack&&e.write(`${pn(n.stack,e)}\n`);let i=n.code?` (${T(`bold`,n.code,{stream:e})})`:``;e.write(`${sn(e,r,`red`)} ${t}${i}: ${n.message}\n`)}var mn=/* @__PURE__ */ e({IncaError:()=>K,bundlerFault:()=>fn,withAppRoot:()=>Je});function hn(e,t,n){return{outDir:e,entryFile:x.join(e,t.entryFile),files:t.files,changed:n}}async function gn(e,t=``){let n;try{n=await j(e)}catch{return[]}return(await Promise.all(n.map(async n=>{let r=await P(x.join(e,n)).catch(()=>void 0);return r?r.isDirectory()?gn(x.join(e,n),`${t}${n}/`):[t+n]:[]}))).flat()}function _n(e,t){let n=``;return{name:`inca:capture-output`,configResolved(e){n=e.build.copyPublicDir?e.publicDir:``},async writeBundle(r,i){let a=[.../* @__PURE__ */ new Set([...Object.keys(i),...await gn(n)])],o=Object.values(i).find(e=>e.type===`chunk`&&e.isEntry);if(!o){let t=`ERR_INCA_BUILD_NO_ENTRY_CHUNK`;throw new e.IncaError(t,`${t}: build produced no entry chunk`)}t({entryFile:o.fileName,files:a})}}}const vn=`inca.json`;function yn(e){let t=JSON.stringify(e,void 0,2);return{name:`inca:emit-config`,generateBundle(){t!==void 0&&this.emitFile({type:`asset`,fileName:vn,source:`${t}\n`})}}}function bn(e,t){let n=`ERR_INCA_PEER_NOT_FOUND`;return new e.IncaError(n,`${n}: ${t} can't be resolved. add it to the app's dependencies`)}async function xn(e,t){let n=f(I(`${e}/`)).resolve.paths(t)??[];for(let e of n)try{return await A(x.join(e,t,`package.json`),`utf8`)}catch(e){let{code:t}=e;if(t!==`ENOENT`&&t!==`ENOTDIR`)throw e}}async function Sn(e,t,[n,r]){let i=await xn(t,n);if(i===void 0)throw bn(e,n);return JSON.parse(i).incajs?.frontends?.[r]?.peers??[]}function Cn(e,t){let n=process.cwd(),r;return{name:`inca:require-peers`,enforce:`pre`,configResolved(e){n=e.root},async resolveId(i,a,o){if(r??=await Sn(e,n,t),!r.includes(i))return null;let s=await this.resolve(i,a,{...o,skipSelf:!0});if(s&&!s.id.startsWith(`__vite-optional-peer-dep:`))return null;throw bn(e,i)}}}const wn=/\.(?:css|pcss|postcss|sass|scss|less|styl|stylus)(?:\?|$)/,Tn=[{code:`ERR_INCA_UNSUPPORTED_STYLESHEET`,name:`a stylesheet import`,matches:e=>wn.test(e),hint:`the build does not convert a stylesheet yet. use a :style binding instead`}];function En(e,t=[]){return{name:`inca:reject-unsupported`,enforce:`pre`,transform(n,r){let i=[...t,...Tn].find(e=>e.matches(r));if(!i)return null;let a=x.relative(process.cwd(),r.split(`?`)[0]??r);throw new e.IncaError(i.code,`${i.code}: ${a} uses ${i.name}, unsupported for now: ${i.hint}`)}}}function Dn(e,t,n){return[...n.plugins(),Cn(e,t),En(e,n.unsupported)]}function On(e,t,n=!1){let r=/* @__PURE__ */ new WeakSet,i=/* @__PURE__ */ new Set,a={hasWarned:!1,info(t){n||e.write(`${t}\n`)},warn(e){a.hasWarned=!0,t.write(`${e}\n`)},warnOnce(e){i.has(e)||(i.add(e),a.warn(e))},error(e,n){a.hasWarned=!0,n?.error&&r.add(n.error),e.includes(`Build failed with `)||e.includes(`Pre-transform error`)||t.write(`${e.replace(/\n\s+at .*/g,``)}\n`)},clearScreen(){},hasErrorLogged(e){return r.has(e)}};return a}function kn({core:e,frontend:t,integration:n,entry:r,root:i=x.dirname(r),envDir:a,publicDir:o,outDir:s,mode:c,sourcemap:l=!1,watch:u,onOutput:d,stdout:f,stderr:p,quiet:m,runtimeConfig:h}){let g=c===`development`||l;return{configFile:!1,root:i,envDir:a,publicDir:o,mode:c,clearScreen:!1,logLevel:m?`silent`:`info`,customLogger:On(f,p),define:{"process.env.NODE_ENV":JSON.stringify(c)},plugins:[...Dn(e,t,n),yn(h),_n(e,d)],build:{lib:{entry:r,formats:[`es`],fileName:()=>`bundle.js`},outDir:s,emptyOutDir:c===`production`,minify:c===`production`,sourcemap:g,watch:u?{buildDelay:30}:void 0,rolldownOptions:{output:{chunkFileNames:`chunks/[name]-[hash].js`,assetFileNames:`assets/[name]-[hash][extname]`,sourcemapExcludeSources:g}}}}}async function An(e,t,n,{entry:r,root:i,envDir:a,publicDir:o,outDir:s,sourcemap:c,runtimeConfig:l,stdout:u=process.stdout,stderr:d=process.stderr,quiet:f=!1}){let p;if(await re(kn({core:e,frontend:t,integration:n,entry:r,root:i,envDir:a,publicDir:o,outDir:s,runtimeConfig:l,mode:`production`,sourcemap:c,watch:!1,stdout:u,stderr:d,quiet:f,onOutput:e=>{p=hn(s,e)}})),!p)throw new e.IncaError(`ERR_INCA_BUILD_NO_OUTPUT`,`build produced no output`);return p}function jn(e,t){let n=ie(t,[],!1),r=[t.stack,n].filter(e=>e).join(`
14
- `);return{...e.bundlerFault(t.message),stack:r||null}}function Mn(e){return x.join(e,`node_modules/.inca/hmr`)}function Nn(){let e=x.dirname(te(import.meta.url));for(;!h(x.join(e,`package.json`));){let t=x.dirname(e);if(t===e)throw Error(`could not locate @incajs/cli's own package.json`);e=t}return x.join(e,`dist/vite-runtime.js`)}function Pn(e,t){let n=x.relative(e,t).split(x.sep).join(`/`);return n.startsWith(`.`)?n:`./${n}`}const Fn=/^[A-Za-z_$][\w$]*$/;function In(e){let t={};for(let[n,r]of Object.entries(e??{}))if(Fn.test(n))try{t[n]=JSON.parse(typeof r==`string`?r:JSON.stringify(r))}catch{}return t}async function Ln(e,t,n,r){let i=Mn(e),a=x.join(i,`entry.js`),o=Pn(i,r??Nn()),s=t.split(x.sep).join(`/`);return await F(a,an`
11
+ `)),a+=o+n[t+1]}),a}const cn=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`numeric`,second:`numeric`}),K={timestamp:!0};function ln(e,t,n){let r=w([`bold`,n],`[inca]`,{stream:e});return t.timestamp?`${w(`dim`,cn.format(/* @__PURE__ */ new Date),{stream:e})} ${r}`:r}function q(e,t,n={}){e.write(`${ln(e,n,`cyan`)} ${t}\n`)}function un(e,t,n={}){e.write(`${ln(e,n,`yellow`)} ${t}\n`)}function dn(e){let t=e.code;return typeof t==`string`?t:null}function fn(e){return/\bERR_INCA_[A-Z0-9_]+/.exec(e)?.[0]??null}function pn(e){let t=e.stack;if(!t)return null;for(let n of[`${e.name}: ${e.message}`,e.message])if(t.startsWith(n))return t.slice(n.length).replace(/^\r?\n/,``)||null;return t}function mn(e){let t=/^(?:\w*Error: )?(ERR_INCA_[A-Z0-9_]+): /.exec(e);return t?{message:e.slice(t[0].length),stack:null,code:t[1]}:{message:e.replace(/^\w*Error: /,``),stack:null,code:null}}function J(e){return e instanceof Ut?{message:e.message,stack:e.hostStack,code:dn(e)}:e instanceof Error?{message:e.message,stack:pn(e),code:dn(e)??fn(e.message)}:{message:String(e),stack:null,code:null}}function hn(e,t){return e.split(`
12
+ `).map(e=>/^\s*at\b/.test(e)?w(`dim`,e,{stream:t}):e).join(`
13
+ `)}function Y(e,t,n,r={}){n.stack&&e.write(`${hn(n.stack,e)}\n`);let i=n.code?` (${w(`bold`,n.code,{stream:e})})`:``;e.write(`${ln(e,r,`red`)} ${t}${i}: ${n.message}\n`)}var gn=/* @__PURE__ */ e({IncaError:()=>W,bundlerFault:()=>mn,withAppRoot:()=>Ze});function _n(e,t,n){return{outDir:e,entryFile:b.join(e,t.entryFile),files:t.files,changed:n}}async function vn(e,t=``){let n;try{n=await j(e)}catch{return[]}return(await Promise.all(n.map(async n=>{let r=await N(b.join(e,n)).catch(()=>void 0);return r?r.isDirectory()?vn(b.join(e,n),`${t}${n}/`):[t+n]:[]}))).flat()}function yn(e,t){let n=``;return{name:`inca:capture-output`,configResolved(e){n=e.build.copyPublicDir?e.publicDir:``},async writeBundle(r,i){let a=[.../* @__PURE__ */ new Set([...Object.keys(i),...await vn(n)])],o=Object.values(i).find(e=>e.type===`chunk`&&e.isEntry);if(!o){let t=`ERR_INCA_BUILD_NO_ENTRY_CHUNK`;throw new e.IncaError(t,`${t}: build produced no entry chunk`)}t({entryFile:o.fileName,files:a})}}}const bn=`inca.json`;function xn(e){let t=JSON.stringify(e,void 0,2);return{name:`inca:emit-config`,generateBundle(){t!==void 0&&this.emitFile({type:`asset`,fileName:bn,source:`${t}\n`})}}}function Sn(e,t){let n=`ERR_INCA_PEER_NOT_FOUND`;return new e.IncaError(n,`${n}: ${t} can't be resolved. add it to the app's dependencies`)}async function Cn(e,t){let n=f(F(`${e}/`)).resolve.paths(t)??[];for(let e of n)try{return await A(b.join(e,t,`package.json`),`utf8`)}catch(e){let{code:t}=e;if(t!==`ENOENT`&&t!==`ENOTDIR`)throw e}}async function wn(e,t,[n,r]){let i=await Cn(t,n);if(i===void 0)throw Sn(e,n);return JSON.parse(i).incajs?.frontends?.[r]?.peers??[]}function Tn(e,t){let n=process.cwd(),r;return{name:`inca:require-peers`,enforce:`pre`,configResolved(e){n=e.root},async resolveId(i,a,o){if(r??=await wn(e,n,t),!r.includes(i))return null;let s=await this.resolve(i,a,{...o,skipSelf:!0});if(s&&!s.id.startsWith(`__vite-optional-peer-dep:`))return null;throw Sn(e,i)}}}const En=/[?&](?:inline|url|raw|direct|transform-only|worker|sharedworker)(?:[&=]|$)/;function Dn(e,t){let[n=e,...r]=e.split(`?`),i=b.relative(t,n),a=(!i.startsWith(`..${b.sep}`)&&!b.isAbsolute(i)?i:n).split(b.sep).join(`/`);return r.length>0?`${a}?${r.join(`?`)}`:a}function On(e,t){let n=/* @__PURE__ */ new Map;return[{name:`inca:style-collect`,apply:`build`,transform(e,t){return!se(t)||En.test(t)?null:(n.set(t,e),{code:``,map:null})}},{name:`inca:style-apply`,apply:`build`,enforce:`post`,transform(r,i){let a=n.get(i);return a===void 0?null:{code:G`
14
+ ${r}
15
+ import { updateStyle } from ${JSON.stringify(e)};
16
+ updateStyle(${JSON.stringify(Dn(i,t))}, ${JSON.stringify(a)});
17
+ `+`
18
+ `,map:null,moduleSideEffects:`no-treeshake`}}}]}const kn=[];function An(e,t=[]){return{name:`inca:reject-unsupported`,enforce:`pre`,transform(n,r){let i=[...t,...kn].find(e=>e.matches(r));if(!i)return null;let a=b.relative(process.cwd(),r.split(`?`)[0]??r);throw new e.IncaError(i.code,`${i.code}: ${a} uses ${i.name}, unsupported for now: ${i.hint}`)}}}function jn(e,t,n,r){return[...n.plugins(),...On(n.styleModule,r),Tn(e,t),An(e,n.unsupported)]}function Mn(e,t,n=!1){let r=/* @__PURE__ */ new WeakSet,i=/* @__PURE__ */ new Set,a={hasWarned:!1,info(t){n||e.write(`${t}\n`)},warn(e){a.hasWarned=!0,t.write(`${e}\n`)},warnOnce(e){i.has(e)||(i.add(e),a.warn(e))},error(e,n){a.hasWarned=!0,n?.error&&r.add(n.error),e.includes(`Build failed with `)||e.includes(`Pre-transform error`)||t.write(`${e.replace(/\n\s+at .*/g,``)}\n`)},clearScreen(){},hasErrorLogged(e){return r.has(e)}};return a}function Nn({core:e,frontend:t,integration:n,entry:r,root:i=b.dirname(r),envDir:a,publicDir:o,outDir:s,mode:c,sourcemap:l=!1,watch:u,onOutput:d,stdout:f,stderr:p,quiet:m,runtimeConfig:h}){let g=c===`development`||l;return{configFile:!1,root:i,envDir:a,publicDir:o,mode:c,clearScreen:!1,logLevel:m?`silent`:`info`,customLogger:Mn(f,p),define:{"process.env.NODE_ENV":JSON.stringify(c)},plugins:[...jn(e,t,n,i),xn(h),yn(e,d)],build:{lib:{entry:r,cssFileName:`inca-style`,formats:[`es`],fileName:()=>`bundle.js`},outDir:s,emptyOutDir:c===`production`,minify:c===`production`,sourcemap:g,watch:u?{buildDelay:30}:void 0,rolldownOptions:{output:{chunkFileNames:`chunks/[name]-[hash].js`,assetFileNames:`assets/[name]-[hash][extname]`,sourcemapExcludeSources:g}}}}}async function Pn(e,t,n,{entry:r,root:i,envDir:a,publicDir:o,outDir:s,sourcemap:c,runtimeConfig:l,stdout:u=process.stdout,stderr:d=process.stderr,quiet:f=!1}){let p;if(await L(Nn({core:e,frontend:t,integration:n,entry:r,root:i,envDir:a,publicDir:o,outDir:s,runtimeConfig:l,mode:`production`,sourcemap:c,watch:!1,stdout:u,stderr:d,quiet:f,onOutput:e=>{p=_n(s,e)}})),!p)throw new e.IncaError(`ERR_INCA_BUILD_NO_OUTPUT`,`build produced no output`);return p}function Fn(e,t){let n=ae(t,[],!1),r=[t.stack,n].filter(e=>e).join(`
19
+ `);return{...e.bundlerFault(t.message),stack:r||null}}function X(e){return b.join(e,`node_modules/.inca/hmr`)}function In(){let e=b.dirname(ne(import.meta.url));for(;!h(b.join(e,`package.json`));){let t=b.dirname(e);if(t===e)throw Error(`could not locate @incajs/cli's own package.json`);e=t}return b.join(e,`dist/vite-runtime.js`)}function Ln(e,t){let n=b.relative(e,t).split(b.sep).join(`/`);return n.startsWith(`.`)?n:`./${n}`}const Rn=/^[A-Za-z_$][\w$]*$/;function zn(e){let t={};for(let[n,r]of Object.entries(e??{}))if(Rn.test(n))try{t[n]=JSON.parse(typeof r==`string`?r:JSON.stringify(r))}catch{}return t}async function Bn(e,t,n,r){let i=X(e),a=b.join(i,`entry.js`),o=Ln(i,r??In()),s=t.split(b.sep).join(`/`);return await P(a,G`
15
20
  import { start } from ${JSON.stringify(o)};
16
21
  await start(${JSON.stringify(s)}, ${JSON.stringify(n)});
17
- `),a}function Rn(e){if(e.type===`error`)return e.err;if(e.type===`custom`&&e.event===`vite:invoke`)return e.data?.data?.error}function zn(e){if(e.type!==`custom`||e.event!==`vite:invoke`)return!1;let t=e.data;return t.name===`fetchModule`&&!t.data?.error}function Bn(e,t,n,r,i){let a=/* @__PURE__ */ new Map,o={send:s};function s(a){if(a.type===`full-reload`){let e=i.current;i.current=void 0,t(e);return}let o=Rn(a);o?(n(o),i.current=void 0):zn(a)&&i.current&&(r({file:i.current.file,took:Date.now()-i.current.at}),i.current=void 0),e(a)}return{channel:{send:s,on(e,t){let n=a.get(e);n||a.set(e,n=/* @__PURE__ */ new Set),n.add(t)},off(e,t){a.get(e)?.delete(t)}},dispatch(e){let t=e;if(t?.type===`custom`&&typeof t.event==`string`)for(let e of a.get(t.event)??[])e(t.data,o)}}}function Vn(){let e=`\0inca:vite-client-shim`;return{name:`inca:shim-vite-client`,enforce:`pre`,resolveId(t){return t===`/@vite/client`||t.endsWith(`/dist/client/client.mjs`)?e:null},load(t){return t===e?`export function createHotContext() { return undefined; }`:null}}}function Hn(e){return{name:`inca:file-changed`,hotUpdate(t){e.current={file:t.file,at:Date.now()},this.environment.hot.send({type:`custom`,event:`file-changed`,data:{file:t.file}})}}}async function Un(e,t,n,{entry:r,root:i=x.dirname(r),envDir:a,publicDir:o,cwd:s,runtimeConfig:c,runtimePath:l,stdout:u=process.stdout,stderr:d=process.stderr,quiet:f=!1,notify:p,reload:m,onError:h,onUpdate:g=()=>{}}){await k(Mn(s),{recursive:!0});let _=e.withAppRoot(c,s,Mn(s));await F(x.join(Mn(s),vn),`${JSON.stringify(_,void 0,2)}\n`);let v={current:void 0},{channel:y,dispatch:b}=Bn(p,m,t=>h(jn(e,t)),g,v),S=await ae({configFile:!1,root:i,envDir:a,publicDir:o,mode:`development`,clearScreen:!1,logLevel:f?`silent`:`info`,customLogger:On(u,d,f),define:{"process.env.NODE_ENV":JSON.stringify(`development`)},server:{middlewareMode:!0,ws:!1,watch:{awaitWriteFinish:{stabilityThreshold:20,pollInterval:10}}},optimizeDeps:{noDiscovery:!0},environments:{client:{consumer:`client`,dev:{moduleRunnerTransform:!0,createEnvironment:(e,t)=>new R(e,t,{hot:!0,transport:y})}}},plugins:[...Dn(e,t,n),Vn(),Hn(v)]}),C;try{C=await Ln(s,r,In(S.environments.client.config.define),l)}catch(e){throw await S.close(),e}return{entryFile:C,dispatch:b,close:()=>S.close()}}async function Wn(e,t,n,{onBuild:r,onError:i,stdout:a=process.stdout,stderr:o=process.stderr,quiet:s=!1,...c}){let{outDir:l}=c,u,d=await re(kn({core:e,frontend:t,integration:n,...c,watch:!0,stdout:a,stderr:o,quiet:s,onOutput:e=>{r(hn(l,e,u)),u=void 0}}));return d.on(`change`,e=>{u??={file:e,at:Date.now()}}),d.on(`event`,t=>{if(t.code!==`ERROR`)return;u=void 0;let{errors:n}=t.error;i(e.bundlerFault(n?.[0]?.message??t.error.message))}),{close:()=>d.close()}}function Gn(e,t,n){return{watch:r=>Wn(e,t,n,r),build:r=>An(e,t,n,r),hmr:r=>Un(e,t,n,r)}}const Kn={id:[`incajs`,`vue`],appFile:`App.vue`,entryCode:e=>an`
22
+ `),a}function Vn(e){if(e.type===`error`)return e.err;if(e.type===`custom`&&e.event===`vite:invoke`)return e.data?.data?.error}function Hn(e){if(e.type!==`custom`||e.event!==`vite:invoke`)return!1;let t=e.data;return t.name===`fetchModule`&&!t.data?.error}function Un(e,t,n,r,i){let a=/* @__PURE__ */ new Map,o={send:s};function s(a){if(a.type===`full-reload`){let e=i.current;i.current=void 0,t(e);return}let o=Vn(a);o?(n(o),i.current=void 0):Hn(a)&&i.current&&(r({file:i.current.file,took:Date.now()-i.current.at}),i.current=void 0),e(a)}return{channel:{send:s,on(e,t){let n=a.get(e);n||a.set(e,n=/* @__PURE__ */ new Set),n.add(t)},off(e,t){a.get(e)?.delete(t)}},dispatch(e){let t=e;if(t?.type===`custom`&&typeof t.event==`string`)for(let e of a.get(t.event)??[])e(t.data,o)}}}function Wn(e){let t=`\0inca:vite-client-shim`;return{name:`inca:shim-vite-client`,enforce:`pre`,resolveId(e){return e===`/@vite/client`||e.endsWith(`/dist/client/client.mjs`)?t:null},load(n){return n===t?G`
23
+ export function createHotContext() { return undefined; }
24
+ export { updateStyle, removeStyle } from ${JSON.stringify(e)};
25
+ `:null}}}function Gn(e){return{name:`inca:file-changed`,hotUpdate(t){e.current={file:t.file,at:Date.now()},this.environment.hot.send({type:`custom`,event:`file-changed`,data:{file:t.file}})}}}async function Kn(e,t,n,{entry:r,root:i=b.dirname(r),envDir:a,publicDir:o,cwd:s,runtimeConfig:c,runtimePath:l,stdout:u=process.stdout,stderr:d=process.stderr,quiet:f=!1,notify:p,reload:m,onError:h,onUpdate:g=()=>{}}){await k(X(s),{recursive:!0});let _=e.withAppRoot(c,s,X(s));await P(b.join(X(s),bn),`${JSON.stringify(_,void 0,2)}\n`);let v={current:void 0},{channel:y,dispatch:ee}=Un(p,m,t=>h(Fn(e,t)),g,v),x=await oe({configFile:!1,root:i,envDir:a,publicDir:o,mode:`development`,clearScreen:!1,logLevel:f?`silent`:`info`,customLogger:Mn(u,d,f),define:{"process.env.NODE_ENV":JSON.stringify(`development`)},server:{middlewareMode:!0,ws:!1,watch:{awaitWriteFinish:{stabilityThreshold:20,pollInterval:10}}},optimizeDeps:{noDiscovery:!0},environments:{client:{consumer:`client`,dev:{moduleRunnerTransform:!0,createEnvironment:(e,t)=>new ie(e,t,{hot:!0,transport:y})}}},plugins:[...jn(e,t,n,i),Wn(n.styleModule),Gn(v)]}),S;try{S=await Bn(s,r,zn(x.environments.client.config.define),l)}catch(e){throw await x.close(),e}return{entryFile:S,dispatch:ee,close:()=>x.close()}}async function qn(e,t,n,{onBuild:r,onError:i,stdout:a=process.stdout,stderr:o=process.stderr,quiet:s=!1,...c}){let{outDir:l}=c,u,d=await L(Nn({core:e,frontend:t,integration:n,...c,watch:!0,stdout:a,stderr:o,quiet:s,onOutput:e=>{r(_n(l,e,u)),u=void 0}}));return d.on(`change`,e=>{u??={file:e,at:Date.now()}}),d.on(`event`,t=>{if(t.code!==`ERROR`)return;u=void 0;let{errors:n}=t.error;i(e.bundlerFault(n?.[0]?.message??t.error.message))}),{close:()=>d.close()}}function Jn(e,t,n){return{watch:r=>qn(e,t,n,r),build:r=>Pn(e,t,n,r),hmr:r=>Kn(e,t,n,r)}}const Yn={id:[`incajs`,`vue`],appFile:`App.vue`,entryCode:e=>G`
18
26
  import { createIncaApp } from "incajs/vue";
19
27
  import App from ${e};
20
28
  createIncaApp(App).mount();
21
- `};function qn(e){return{plugins:()=>[ne({template:{compilerOptions:{runtimeModuleName:e,hoistStatic:!1}}})],unsupported:[{code:`ERR_INCA_UNSUPPORTED_STYLE`,name:`a <style> block`,matches:e=>e.includes(`vue&type=style`),hint:`the build does not convert a stylesheet yet. use a :style binding instead`}]}}const Jn=Gn(mn,Kn.id,qn(`incajs/vue/runtime`)),Yn=[`main.mts`,`main.ts`,`main.js`];function Xn(e){return x.join(e,`node_modules/.inca/entry.mts`)}function Zn(e,t){return t===Xn(e)?x.join(e,`src`):x.dirname(t)}function Qn(e,t){return Yn.map(t=>x.join(e,`src`,t)).find(e=>h(e))||(h(x.join(e,`src`,t.appFile))?Xn(e):void 0)}async function $n(e,t){let n=x.join(e,`src`,t.appFile),r=Qn(e,t);if(r===Xn(e))return er(n,e,t);if(r)return r;throw new K(`ERR_INCA_ENTRY_NOT_FOUND`,`no app entry found. check that ${x.join(e,`src/main.ts`)} or ${n} exists`)}async function er(e,t,n){let r=Xn(t);await k(x.dirname(r),{recursive:!0});let i=JSON.stringify(e.split(x.sep).join(`/`));return await F(r,n.entryCode(i)),r}async function tr(e={}){let t=e.cwd??process.cwd(),n=e.config??await $t(t),r=x.resolve(t,n.outDir),i=e.bundler??Jn,a=e.frontend??Kn,o=e.entry??n.entry??await $n(t,a);Yt(t,r,o);let s=e.runtimeConfig??await rn(t);return i.build({entry:o,root:Zn(t,o),envDir:t,publicDir:x.join(t,`public`),outDir:r,sourcemap:e.sourcemap??n.sourcemap,runtimeConfig:Je(s,t,r),stdout:e.stdout,stderr:e.stderr})}const nr=`bin/inca-host.br`,rr=/^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$/,ir=[`darwin`,`linux`],ar=[`arm64`,`x64`];function or(e=process.platform,t=process.arch){let n=ir.find(t=>t===e),r=ar.find(e=>e===t);if(!n||!r)return;let i=`${n}-${r}`;return{key:i,name:`@incajs/host-${i}`}}function sr(e){try{return x.dirname(f(import.meta.url).resolve(`${e}/package.json`))}catch{return}}function Z(e,t){return new K(`ERR_INCA_HOST_PACKAGE_CORRUPT`,`the host package ${e} is damaged: ${t}. reinstall it`)}async function cr(e,t){let n;try{n=JSON.parse(await A(x.join(t,`package.json`),`utf8`))}catch(t){throw Z(e,`package.json can't be read (${t.message})`)}let r=n?.incajs?.host;if(r===void 0)return;let i=r?.sha256;if(typeof i!=`string`||!/^[0-9a-f]{64}$/.test(i))throw Z(e,`verification failed`);let a=n?.version;if(typeof a!=`string`||!rr.test(a))throw Z(e,`invalid version`);return{name:e,dir:t,version:a,sha256:i}}const lr=`INCA_CACHE_DIR`,ur=`inca-host`;function dr(e){return de(`sha256`).update(e).digest(`hex`)}function fr(e,t,n){let r=e.XDG_CACHE_HOME;if(t!==`darwin`&&r&&x.isAbsolute(r))return{dir:x.join(r,`incajs`,`host`)};if(n)return{dir:t===`darwin`?x.join(n,`Library`,`Caches`,`incajs`,`host`):x.join(n,`.cache`,`incajs`,`host`)}}function pr(e,t,n,r){let i=[],a=e[lr];a&&i.push({dir:x.resolve(a)});let o=fr(e,t,n);return o&&i.push(o),i.push({dir:x.join(r,`node_modules/.inca/host`),mustExist:x.join(r,`node_modules`)}),i.filter((e,t)=>i.findIndex(t=>t.dir===e.dir)===t)}async function mr(e,t){try{return dr(await A(e))===t&&(await ee(e,m.X_OK),!0)}catch{return!1}}async function hr(e){let t;try{t=me(await A(x.join(e.dir,nr)))}catch(t){throw Z(e.name,`${nr} can't be unpacked (${t.message})`)}if(dr(t)!==e.sha256)throw Z(e.name,`verification failed`);return t}async function gr(e,t){let n=`${e}.tmp-${process.pid}-${fe(4).toString(`hex`)}`;try{await k(x.dirname(e),{recursive:!0,mode:448}),await F(n,t),await E(n,493),await ee(n,m.X_OK),await M(n,e)}catch(e){throw await N(n,{force:!0}),e}}async function _r(e,t,n){let r=RegExp(`^${t}@${rr.source.slice(1)}`);try{let t=(await j(e,{withFileTypes:!0})).filter(e=>e.isDirectory()&&r.test(e.name)&&e.name!==n).map(t=>x.join(e,t.name)),i=(await Promise.all(t.map(async e=>({dir:e,modified:(await P(e)).mtimeMs})))).sort((e,t)=>t.modified-e.modified).slice(2);for(let{dir:e}of i)await N(e,{recursive:!0,force:!0})}catch{}}async function vr(e){try{return(await P(e)).isDirectory()}catch{return!1}}async function yr(e,t,n,r){let i=`${t}@${e.version}`;for(let t of n){let n=x.join(t.dir,i,ur);if(await mr(n,e.sha256))return n}let a;for(let o of n){if(o.mustExist&&!await vr(o.mustExist))continue;a??=await hr(e);let n=x.join(o.dir,i,ur);try{await gr(n,a)}catch{continue}return J(r,`unpacked the host binary into ${x.dirname(n)}`),await _r(o.dir,t,i),n}throw new K(`ERR_INCA_HOST_UNPACK_FAILED`,`failed to unpack the host binary because no usable directory was found to unpack into. set ${lr} to a writable directory that allows running programs`)}async function br(){let e=or();if(!e)return{state:`unsupported`};let t=sr(e.name);if(!t)return{state:`notInstalled`,target:e};try{let n=await cr(e.name,t);return n?{state:`installed`,target:e,pkg:n}:{state:`noBinary`,target:e}}catch(t){return{state:`corrupt`,target:e,error:t}}}const xr=`INCA_HOST_BIN`;function Sr(){try{return L()}catch{return}}async function Q(e=process.cwd(),t=process.stderr){let n=process.env[xr];if(n)return n;let r=await br();if(r.state===`installed`){let n=pr(process.env,process.platform,Sr(),e);return yr(r.pkg,r.target.key,n,t)}throw r.state===`corrupt`?r.error:new K(`ERR_INCA_HOST_BIN_UNRESOLVED`,`no host binary found because ${r.state===`unsupported`?`no host package is published for ${process.platform}/${process.arch}`:r.state===`noBinary`?`${r.target.name} is installed but carries no host binary`:`${r.target.name} isn't installed`}. set ${xr} to the path of a host binary to use your own`)}async function $(e){if(!(await P(e).catch(()=>void 0))?.isFile())throw new K(`ERR_INCA_HOST_BIN_NOT_FOUND`,`no host binary at ${e}. check that it was built`)}const Cr=[`NOTICE`,`LICENSE-MIT`,`LICENSE-APACHE`];async function wr(e){if(e!==void 0||process.env.INCA_HOST_BIN)return[];let t=await br();return t.state===`installed`?(await Promise.all(Cr.map(async e=>{let n=x.join(t.pkg.dir,e);return(await P(n).catch(()=>void 0))?.isFile()?n:void 0}))).filter(e=>e!==void 0):[]}function Tr(e){return typeof e==`object`&&!!e&&e.jsonrpc===`2.0`}const Er=e=>{process.stderr.write(e.endsWith(`
22
- `)?e:`${e}\n`)};var Dr=class{#e;#t;#n=1;#r=/* @__PURE__ */ new Map;#i=!1;constructor(e){this.#e=e}async start(){let{hostBin:e}=this.#e;if(await $(e),this.#e.signal?.aborted)return;let t=oe(e,[`--dev`,this.#e.entryFile],{stdio:[`pipe`,`pipe`,`pipe`],env:this.#e.env});this.#t=t;let n=this.#e.onStderr??Er;t.stderr.setEncoding(`utf8`),t.stderr.on(`data`,e=>n(e)),t.stdin.on(`error`,e=>{e.code!==`EPIPE`&&n(`host stdin: ${e.message}\n`)}),le.createInterface({input:t.stdout}).on(`line`,e=>{this.#a(e,n)}),t.on(`exit`,(e,t)=>{let n=/* @__PURE__ */ Error(`the host exited (code=${String(e)}, signal=${String(t)}) before answering`);for(let{reject:e}of this.#r.values())e(n);this.#r.clear(),this.#i||this.#e.onExit?.(e,t)});let r=!1;t.on(`error`,e=>{r&&n(`host: ${e.message}\n`)}),await ce(t,`spawn`),r=!0}#a(e,t){let n;try{n=JSON.parse(e)}catch{t(`[stray stdout] ${e}`);return}if(!Tr(n)){t(`[stray stdout] ${e}`);return}if(`method`in n){this.#o(n.method,n.params,t);return}if(n.id===null){if(!(`error`in n))return;let{code:e,message:r,data:i}=n.error;e===-32e3?this.#e.onAppError?.({message:r,stack:i?.stack??null}):e!==-32603&&t(`[host error ${String(e)}] ${r}\n`);return}let r=this.#r.get(n.id);r&&(this.#r.delete(n.id),`error`in n?r.reject(new Bt(n.error.message,n.error.code,n.error.data?.stack??null)):r.resolve(n.result))}#o(e,t,n){switch(e){case`ready`:{let{protocol:e}=t;if(e!==0){n(`the host speaks protocol ${String(e)}, this package was built for 0. stopping it`),this.#t&&this.#s(this.#t);return}this.#e.onReady?.();return}case`appError`:this.#e.onAppError?.(t);return;default:{let r=this.#e.integrations?.[e];r?r(t):n(`[unhandled notification] ${e}`)}}}async#s(e){let t=ce(e,`exit`);e.kill(),await t}async call(e,t,n){let r=this.#t;if(!r)throw Error(`HostClient.start() has not been called`);let i=this.#n++,a=JSON.stringify({jsonrpc:`2.0`,id:i,method:e,params:t});return new Promise((t,o)=>{let s=n===void 0?void 0:setTimeout(()=>{this.#r.delete(i),o(/* @__PURE__ */ Error(`${e} timed out after ${String(n)}ms`))},n);this.#r.set(i,{resolve:e=>{clearTimeout(s),t(e)},reject:e=>{clearTimeout(s),o(e)}}),r.stdin.write(`${a}\n`,e=>{e&&(clearTimeout(s),this.#r.delete(i),o(e))})})}notify(e,t){let n=this.#t;if(!n)throw Error(`HostClient.start() has not been called`);n.stdin.write(`${JSON.stringify({jsonrpc:`2.0`,method:e,params:t})}\n`)}async stop(e=2e3){let t=this.#t;if(!t||t.exitCode!==null||t.signalCode!==null)return;this.#i=!0;let n=ce(t,`exit`);this.call(`shutdown`).catch(()=>{}),await Promise.race([n.then(()=>`exited`),ue(e,void 0,{ref:!1}).then(()=>`timeout`)])===`timeout`&&(t.kill(),await n)}};function Or(e){return x.join(e,`node_modules/.inca/dev.pid`)}function kr(e){try{return process.kill(e,0),!0}catch(e){return e.code===`EPERM`}}const Ar=pe();function jr(e){return new K(`ERR_INCA_DEV_RUNNING`,`inca dev is already running for this app (pid ${String(e)})`)}async function Mr(e){let t=Or(e),n=`${String(process.pid)}:${Ar}`,r=`${t}.${pe()}`;await k(x.dirname(t),{recursive:!0}),await F(r,n);let i=process.pid;try{for(let e=0;e<5;e++){try{return await O(r,t),Nr(t,n)}catch(e){if(e.code!==`EEXIST`)throw e}let e=await A(t,`utf8`).catch(()=>``),a=Number.parseInt(e,10);if(a===process.pid){if(e===n)throw jr(a)}else if(Number.isSafeInteger(a)&&a>0&&kr(a))throw jr(a);i=Number.isSafeInteger(a)&&a>0?a:i,await N(t,{force:!0})}throw jr(i)}finally{await N(r,{force:!0})}}function Nr(e,t){let n=!1;return async()=>{n||(n=!0,await A(e,`utf8`).catch(()=>``)===t&&await N(e,{force:!0}))}}function Pr(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`)}function Fr(e){return typeof e==`boolean`?e?`<true/>`:`<false/>`:`<string>${Pr(e)}</string>`}function Ir(e){return an`
29
+ `};function Xn(e){return{plugins:()=>[re({template:{compilerOptions:{runtimeModuleName:e,hoistStatic:!1}}})],unsupported:[],styleModule:`incajs/style`}}const Zn=Jn(gn,Yn.id,Xn(`incajs/vue/runtime`)),Qn=[`main.mts`,`main.ts`,`main.js`];function $n(e){return b.join(e,`node_modules/.inca/entry.mts`)}function er(e,t){return t===$n(e)?b.join(e,`src`):b.dirname(t)}function tr(e,t){return Qn.map(t=>b.join(e,`src`,t)).find(e=>h(e))||(h(b.join(e,`src`,t.appFile))?$n(e):void 0)}async function nr(e,t){let n=b.join(e,`src`,t.appFile),r=tr(e,t);if(r===$n(e))return rr(n,e,t);if(r)return r;throw new W(`ERR_INCA_ENTRY_NOT_FOUND`,`no app entry found. check that ${b.join(e,`src/main.ts`)} or ${n} exists`)}async function rr(e,t,n){let r=$n(t);await k(b.dirname(r),{recursive:!0});let i=JSON.stringify(e.split(b.sep).join(`/`));return await P(r,n.entryCode(i)),r}async function ir(e={}){let t=e.cwd??process.cwd(),n=e.config??await nn(t),r=b.resolve(t,n.outDir),i=e.bundler??Zn,a=e.frontend??Yn,o=e.entry??n.entry??await nr(t,a);Qt(t,r,o);let s=e.runtimeConfig??await sn(t);return i.build({entry:o,root:er(t,o),envDir:t,publicDir:b.join(t,`public`),outDir:r,sourcemap:e.sourcemap??n.sourcemap,runtimeConfig:Ze(s,t,r),stdout:e.stdout,stderr:e.stderr})}const ar=`bin/inca-host.br`,or=/^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$/,sr=[`darwin`,`linux`],cr=[`arm64`,`x64`];function lr(e=process.platform,t=process.arch){let n=sr.find(t=>t===e),r=cr.find(e=>e===t);if(!n||!r)return;let i=`${n}-${r}`;return{key:i,name:`@incajs/host-${i}`}}function ur(e){try{return b.dirname(f(import.meta.url).resolve(`${e}/package.json`))}catch{return}}function Z(e,t){return new W(`ERR_INCA_HOST_PACKAGE_CORRUPT`,`the host package ${e} is damaged: ${t}. reinstall it`)}async function dr(e,t){let n;try{n=JSON.parse(await A(b.join(t,`package.json`),`utf8`))}catch(t){throw Z(e,`package.json can't be read (${t.message})`)}let r=n?.incajs?.host;if(r===void 0)return;let i=r?.sha256;if(typeof i!=`string`||!/^[0-9a-f]{64}$/.test(i))throw Z(e,`verification failed`);let a=n?.version;if(typeof a!=`string`||!or.test(a))throw Z(e,`invalid version`);return{name:e,dir:t,version:a,sha256:i}}const fr=`INCA_CACHE_DIR`,pr=`inca-host`;function mr(e){return pe(`sha256`).update(e).digest(`hex`)}function hr(e,t,n){let r=e.XDG_CACHE_HOME;if(t!==`darwin`&&r&&b.isAbsolute(r))return{dir:b.join(r,`incajs`,`host`)};if(n)return{dir:t===`darwin`?b.join(n,`Library`,`Caches`,`incajs`,`host`):b.join(n,`.cache`,`incajs`,`host`)}}function gr(e,t,n,r){let i=[],a=e[fr];a&&i.push({dir:b.resolve(a)});let o=hr(e,t,n);return o&&i.push(o),i.push({dir:b.join(r,`node_modules/.inca/host`),mustExist:b.join(r,`node_modules`)}),i.filter((e,t)=>i.findIndex(t=>t.dir===e.dir)===t)}async function _r(e,t){try{return mr(await A(e))===t&&(await T(e,m.X_OK),!0)}catch{return!1}}async function vr(e){let t;try{t=ge(await A(b.join(e.dir,ar)))}catch(t){throw Z(e.name,`${ar} can't be unpacked (${t.message})`)}if(mr(t)!==e.sha256)throw Z(e.name,`verification failed`);return t}async function yr(e,t){let n=`${e}.tmp-${process.pid}-${me(4).toString(`hex`)}`;try{await k(b.dirname(e),{recursive:!0,mode:448}),await P(n,t),await E(n,493),await T(n,m.X_OK),await te(n,e)}catch(e){throw await M(n,{force:!0}),e}}async function br(e,t,n){let r=RegExp(`^${t}@${or.source.slice(1)}`);try{let t=(await j(e,{withFileTypes:!0})).filter(e=>e.isDirectory()&&r.test(e.name)&&e.name!==n).map(t=>b.join(e,t.name)),i=(await Promise.all(t.map(async e=>({dir:e,modified:(await N(e)).mtimeMs})))).sort((e,t)=>t.modified-e.modified).slice(2);for(let{dir:e}of i)await M(e,{recursive:!0,force:!0})}catch{}}async function xr(e){try{return(await N(e)).isDirectory()}catch{return!1}}async function Sr(e,t,n,r,i){let a=`${t}@${e.version}`;for(let t of n){let n=b.join(t.dir,a,pr);if(await _r(n,e.sha256))return n}let o;for(let s of n){if(s.mustExist&&!await xr(s.mustExist))continue;o??=await vr(e);let n=b.join(s.dir,a,pr);try{await yr(n,o)}catch{continue}return i?.aborted||q(r,`unpacked the host binary into ${b.dirname(n)}`),await br(s.dir,t,a),n}throw new W(`ERR_INCA_HOST_UNPACK_FAILED`,`failed to unpack the host binary because no usable directory was found to unpack into. set ${fr} to a writable directory that allows running programs`)}async function Cr(){let e=lr();if(!e)return{state:`unsupported`};let t=ur(e.name);if(!t)return{state:`notInstalled`,target:e};try{let n=await dr(e.name,t);return n?{state:`installed`,target:e,pkg:n}:{state:`noBinary`,target:e}}catch(t){return{state:`corrupt`,target:e,error:t}}}const wr=`INCA_HOST_BIN`;function Tr(){try{return I()}catch{return}}async function Q(e=process.cwd(),t=process.stderr,n){let r=process.env[wr];if(r)return r;let i=await Cr();if(i.state===`installed`){let r=gr(process.env,process.platform,Tr(),e);return Sr(i.pkg,i.target.key,r,t,n)}throw i.state===`corrupt`?i.error:new W(`ERR_INCA_HOST_BIN_UNRESOLVED`,`no host binary found because ${i.state===`unsupported`?`no host package is published for ${process.platform}/${process.arch}`:i.state===`noBinary`?`${i.target.name} is installed but carries no host binary`:`${i.target.name} isn't installed`}. set ${wr} to the path of a host binary to use your own`)}async function $(e){if(!(await N(e).catch(()=>void 0))?.isFile())throw new W(`ERR_INCA_HOST_BIN_NOT_FOUND`,`no host binary at ${e}. check that it was built`)}const Er=[`NOTICE`,`LICENSE-MIT`,`LICENSE-APACHE`];async function Dr(e){if(e!==void 0||process.env.INCA_HOST_BIN)return[];let t=await Cr();return t.state===`installed`?(await Promise.all(Er.map(async e=>{let n=b.join(t.pkg.dir,e);return(await N(n).catch(()=>void 0))?.isFile()?n:void 0}))).filter(e=>e!==void 0):[]}function Or(e){return typeof e==`object`&&!!e&&e.jsonrpc===`2.0`}const kr=e=>{process.stderr.write(e.endsWith(`
30
+ `)?e:`${e}\n`)};var Ar=class{#e;#t;#n=1;#r=/* @__PURE__ */ new Map;#i=!1;constructor(e){this.#e=e}async start(){let{hostBin:e}=this.#e;if(await $(e),this.#e.signal?.aborted)return;let t=ce(e,[`--dev`,this.#e.entryFile],{stdio:[`pipe`,`pipe`,`pipe`],env:this.#e.env});this.#t=t;let n=this.#e.onStderr??kr;t.stderr.setEncoding(`utf8`),t.stderr.on(`data`,e=>n(e)),t.stdin.on(`error`,e=>{e.code!==`EPIPE`&&n(`host stdin: ${e.message}\n`)}),de.createInterface({input:t.stdout}).on(`line`,e=>{this.#a(e,n)}),t.on(`exit`,(e,t)=>{let n=/* @__PURE__ */ Error(`the host exited (code=${String(e)}, signal=${String(t)}) before answering`);for(let{reject:e}of this.#r.values())e(n);this.#r.clear(),this.#i||this.#e.onExit?.(e,t)});let r=!1;t.on(`error`,e=>{r&&n(`host: ${e.message}\n`)}),await ue(t,`spawn`),r=!0}#a(e,t){let n;try{n=JSON.parse(e)}catch{t(`[stray stdout] ${e}`);return}if(!Or(n)){t(`[stray stdout] ${e}`);return}if(`method`in n){this.#o(n.method,n.params,t);return}if(n.id===null){if(!(`error`in n))return;let{code:e,message:r,data:i}=n.error;e===-32e3?this.#e.onAppError?.({message:r,stack:i?.stack??null}):e!==-32603&&t(`[host error ${String(e)}] ${r}\n`);return}let r=this.#r.get(n.id);r&&(this.#r.delete(n.id),`error`in n?r.reject(new Ut(n.error.message,n.error.code,n.error.data?.stack??null)):r.resolve(n.result))}#o(e,t,n){switch(e){case`ready`:{let{protocol:e}=t;if(e!==0){n(`the host speaks protocol ${String(e)}, this package was built for 0. stopping it`),this.#t&&this.#s(this.#t);return}this.#e.onReady?.();return}case`appError`:this.#e.onAppError?.(t);return;default:{let r=this.#e.integrations?.[e];r?r(t):n(`[unhandled notification] ${e}`)}}}async#s(e){let t=ue(e,`exit`);e.kill(),await t}async call(e,t,n){let r=this.#t;if(!r)throw Error(`HostClient.start() has not been called`);let i=this.#n++,a=JSON.stringify({jsonrpc:`2.0`,id:i,method:e,params:t});return new Promise((t,o)=>{let s=n===void 0?void 0:setTimeout(()=>{this.#r.delete(i),o(/* @__PURE__ */ Error(`${e} timed out after ${String(n)}ms`))},n);this.#r.set(i,{resolve:e=>{clearTimeout(s),t(e)},reject:e=>{clearTimeout(s),o(e)}}),r.stdin.write(`${a}\n`,e=>{e&&(clearTimeout(s),this.#r.delete(i),o(e))})})}notify(e,t){let n=this.#t;if(!n)throw Error(`HostClient.start() has not been called`);n.stdin.write(`${JSON.stringify({jsonrpc:`2.0`,method:e,params:t})}\n`)}async stop(e=2e3){let t=this.#t;if(!t||t.exitCode!==null||t.signalCode!==null)return;this.#i=!0;let n=ue(t,`exit`);this.call(`shutdown`).catch(()=>{}),await Promise.race([n.then(()=>`exited`),fe(e,void 0,{ref:!1}).then(()=>`timeout`)])===`timeout`&&(t.kill(),await n)}};function jr(e){return b.join(e,`node_modules/.inca/dev.pid`)}function Mr(e){try{return process.kill(e,0),!0}catch(e){return e.code===`EPERM`}}const Nr=he();function Pr(e){return new W(`ERR_INCA_DEV_RUNNING`,`inca dev is already running for this app (pid ${String(e)})`)}async function Fr(e){let t=jr(e),n=`${String(process.pid)}:${Nr}`,r=`${t}.${he()}`;await k(b.dirname(t),{recursive:!0}),await P(r,n);let i=process.pid;try{for(let e=0;e<5;e++){try{return await O(r,t),Ir(t,n)}catch(e){if(e.code!==`EEXIST`)throw e}let e=await A(t,`utf8`).catch(()=>``),a=Number.parseInt(e,10);if(a===process.pid){if(e===n)throw Pr(a)}else if(Number.isSafeInteger(a)&&a>0&&Mr(a))throw Pr(a);i=Number.isSafeInteger(a)&&a>0?a:i,await M(t,{force:!0})}throw Pr(i)}finally{await M(r,{force:!0})}}function Ir(e,t){let n=!1;return async()=>{n||(n=!0,await A(e,`utf8`).catch(()=>``)===t&&await M(e,{force:!0}))}}function Lr(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`)}function Rr(e){return typeof e==`boolean`?e?`<true/>`:`<false/>`:`<string>${Lr(e)}</string>`}function zr(e){return G`
23
31
  <?xml version="1.0" encoding="UTF-8"?>
24
32
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
25
33
  <plist version="1.0">
26
34
  <dict>
27
- ${Object.entries(e).map(([e,t])=>`\t<key>${Pr(e)}</key>\n\t${Fr(t)}`).join(`
35
+ ${Object.entries(e).map(([e,t])=>`\t<key>${Lr(e)}</key>\n\t${Rr(t)}`).join(`
28
36
  `)}
29
37
  </dict>
30
38
  </plist>
31
- `}async function Lr(e){let{appPath:t,metadata:n,hostBin:r}=e;await N(t,{recursive:!0,force:!0});let i=x.join(t,`Contents`),a=x.join(i,`MacOS`),o=x.join(i,`Resources`);await k(a,{recursive:!0}),await k(o,{recursive:!0});let s=x.join(a,n.productName);e.link?await O(r,s).catch(()=>D(r,s)):await D(r,s),await E(s,493);let c={CFBundleName:n.productName,CFBundleDisplayName:n.productName,CFBundleExecutable:n.productName,CFBundleIdentifier:n.identifier,CFBundleVersion:n.version,CFBundleShortVersionString:n.version,CFBundlePackageType:`APPL`,CFBundleInfoDictionaryVersion:`6.0`,NSHighResolutionCapable:!0};if(n.icon){let e=x.basename(n.icon);await D(n.icon,x.join(o,e)),c.CFBundleIconFile=e}return await F(x.join(i,`Info.plist`),Ir(c)),await F(x.join(i,`PkgInfo`),`APPL????`),{appPath:t,executablePath:s,resourcesDir:o}}const Rr={productName:`a string`,identifier:`a string`,window:`an object`,dev:`an object`,"window.width":`a number`,"window.height":`a number`,"window.title":`a string`,"window.resizable":`true or false`,"window.minWidth":`a number`,"window.minHeight":`a number`,"dev.stackPaths":`a string`};function zr(e){return typeof e==`number`?`a number`:typeof e==`string`?`a string`:typeof e==`boolean`?`true or false`:`an object`}function Br(e,t,n){let r=`failed to read ${t}: `,i=e.split(`
32
- `)[0]??``;if(!i.startsWith(r))return;let a=i.slice(r.length),o=a.indexOf(`]: `),s;try{s=JSON.parse(a.slice(0,o+1))}catch{return}if(!Array.isArray(s))return;let[c,...l]=s,u=[c===`name`?`productName`:c,...l].join(`.`),d=Rr[u];if(!d)return;let f=s.reduce((e,t)=>e?.[t],n),p=zr(f)===d?`the host can't use it`:`it must be ${d}`;return new K(`ERR_INCA_CONFIG_INVALID`,`${u} in inca.config.ts is ${JSON.stringify(f)}. ${p}`)}function Vr(e,t,n,r){let i=se(e,[`--print-config`,t],{encoding:`utf8`});if(i.error)throw i.error;if(i.status!==0){let e=Br(i.stderr,n,r);if(e)throw e}return i}function Hr(e,t){let n=x.join(x.dirname(t),`inca.json`),r={};try{r=JSON.parse(_(n,`utf8`))}catch{}let i=Vr(e,t,n,r);if(i.status===null)throw new K(`ERR_INCA_HOST_EXITED_EARLY`,`the host exited with signal ${String(i.signal)} before it read the config`);if(i.status!==0)throw new K(`ERR_INCA_CONFIG_INVALID`,`the host can't read ${n}. it reported "${i.stderr.split(`
33
- `)[0]??``}"`)}async function Ur(e,t){let n;try{n=await Q(process.cwd(),t),await $(n)}catch(e){if(e instanceof K&&(e.code===`ERR_INCA_HOST_BIN_UNRESOLVED`||e.code===`ERR_INCA_HOST_BIN_NOT_FOUND`)){cn(t,`no host binary found, so the config was not checked`);return}if(e instanceof K&&e.code===`ERR_INCA_HOST_UNPACK_FAILED`){cn(t,`failed to unpack the host binary, so the config was not checked`);return}throw e}Hr(n,e)}async function Wr(e={}){let t=e.cwd??process.cwd(),n=e.hostBin??await Q(t,e.stderr);await $(n);let r=await rn(t,{dev:!0}),i=x.join(t,`node_modules/.inca/config`),a=x.join(i,`bundle.js`),o=x.join(i,`inca.json`);await k(i,{recursive:!0}),await F(a,``),await F(o,JSON.stringify(Je(r,t,i),void 0,2));let s=Vr(n,a,o,r);return(e.stdout??process.stdout).write(s.stdout),(e.stderr??process.stderr).write(s.stderr),s.status??1}const Gr=/^(?:inca\.config\.[a-z0-9]+|package\.json)$/;function Kr(e,t){let n=t.debounceMs??100,r=[...Yn,t.appFile],i=/* @__PURE__ */ new Set,a,o=!1,s=()=>{},c=new Promise(e=>{s=e}),l=()=>{o||(clearTimeout(a),a=setTimeout(s,n),a.unref())},u=(e,t)=>{let n=e;for(let e;!h(n)&&(e=x.dirname(n))!==n;)n=e;let r=n===e?void 0:x.relative(n,e).split(x.sep)[0],a=b(n);a.on(`change`,(e,n)=>{let i=n===null?null:String(n);(i===null||(r===void 0?t(i):i===r))&&l()}),a.on(`error`,()=>{a.close(),i.delete(a),l()}),i.add(a)},d=()=>{o=!0,clearTimeout(a);for(let e of i)e.close();i.clear()};try{u(e,e=>e===`src`||Gr.test(e)),u(x.join(e,`src`),e=>r.includes(e))}catch(e){throw d(),e}return{edited:c,add(e){if(o)return;let t=x.resolve(e);u(x.dirname(t),e=>e===x.basename(t))},close:d}}function qr(e,t){return new Promise(n=>{let r=()=>n(!1);t.addEventListener(`abort`,r,{once:!0}),e.then(()=>{t.removeEventListener(`abort`,r),n(!0)})})}async function Jr(e){let{cwd:t,signal:n,stdout:r,stderr:i,appFile:a,debounceMs:o}=e,s=!1;for(;;){let c=Kr(t,{appFile:a,debounceMs:o});try{return await e.attempt(c)}catch(e){let t=e instanceof K?e.path:void 0;if(t)try{c.add(t)}catch(t){throw X(i,`build failed`,Y(e),q),t}if(!n.aborted&&!s&&t&&h(t)){s=!0;continue}if(s=!1,X(i,`build failed`,Y(e),q),n.aborted||(J(r,`waiting for a change to retry`,q),!await qr(c.edited,n)))return;J(r,`retrying`,q)}finally{c.close()}}}const Yr=[`ERR_INCA_PACKAGE_JSON_NOT_FOUND`,`ERR_INCA_PRODUCT_NAME_MISSING`];async function Xr(e,t){try{return await tn(e)}catch(e){if(!(e instanceof K)||!Yr.includes(e.code))throw e;J(t,`running unnamed. ${e.message}`,q);return}}async function Zr(e,t,n,r){if(process.platform===`darwin`&&t)try{return(await Lr({appPath:x.join(e,`node_modules/.inca`,`${t.productName}.app`),metadata:t,hostBin:n,link:!0})).executablePath}catch(e){J(r,`running unbundled. ${Y(e).message}`,q);return}}function Qr(e){return x.join(e,`node_modules/.inca/dev`)}async function $r(e,t){let n=new Set(t),r;try{r=await j(e,{recursive:!0,withFileTypes:!0})}catch{return}await Promise.all(r.filter(e=>e.isFile()).map(t=>x.relative(e,x.join(t.parentPath,t.name))).filter(e=>!n.has(e)).map(t=>N(x.join(e,t),{force:!0})))}function ei(e){let{NO_COLOR:t,FORCE_COLOR:n}=process.env;if(!(!e.isTTY||t||n))return{...process.env,FORCE_COLOR:`1`}}async function ti(e){let t=e.cwd??process.cwd(),n=await Mr(t),r=()=>{},i=!1,a=new Promise(e=>{r=()=>{i=!0,e()}});e.signal.aborted?r():e.signal.addEventListener(`abort`,()=>r(),{once:!0});let o,s;try{let n=e.stdout??process.stdout,c=e.stderr??process.stderr,l=e.hostBin??await Q(t,c);await $(l);let u=e.bundler??Jn,d=e.frontend??Kn,f=e.experimentalHmr?u.hmr?.bind(u):void 0;if(e.experimentalHmr&&!f)throw new K(`ERR_INCA_HMR_UNSUPPORTED`,`--experimental-hmr was set, but the configured bundler has no HMR support`);let p=await Jr({cwd:t,signal:e.signal,stdout:n,stderr:c,appFile:d.appFile,async attempt(){let r=await $t(t),i=e.entry===void 0&&r.entry===void 0,a=e.entry??r.entry??await $n(t,d),o=await Xr(t,n);return{entry:a,automaticEntry:i,metadata:o,runtimeConfig:o?nn(o,{dev:!0}):await rn(t,{dev:!0})}}});if(!p)return;let{entry:m,automaticEntry:h,metadata:g,runtimeConfig:_}=p,v=Qr(t),y=await Zr(t,g,l,n)??l,b,S,C=!1,w=!1,ee=!1,E,D=Promise.resolve(),O,k=0,A=!1,j;async function M(){try{return await b?.call(`reload`,void 0,1e4),!0}catch(e){return X(c,`reload failed`,Y(e),q),!1}}function N(e){if(!e)return;let r=T(`dim`,x.relative(t,e.file),{stream:n}),i=Date.now()-e.at;J(n,`${T(`green`,`reload`)} ${r} (${i}ms)`,q)}async function P(t,a){if(i)return;try{Hr(y,t)}catch(e){e instanceof K&&e.code===`ERR_INCA_CONFIG_INVALID`?(S=e,r()):X(c,`failed to start the host`,Y(e),q);return}let o=new Dr({entryFile:t,hostBin:y,signal:e.signal,env:ei(c),onStderr:e=>c.write(e),onReady:()=>{C=!0,J(n,`ready`,q),w&&(w=!1,M())},onAppError:e=>X(c,`app error`,e,q),onExit:(e,t)=>{ee=!C,E={code:e,signal:t},J(n,`host exited. stopping`,q),r()},integrations:a});try{await o.start()}catch(e){X(c,`failed to start the host`,Y(e),q);return}b=o}async function F(e){await $r(e.outDir,e.files),b?C?await M()&&N(e.changed):w=!0:await P(e.entryFile)}async function te(e){let a=++k,o=()=>a===k&&!i,s=e=>(...t)=>{o()&&e(...t)},l;if(f){let i=await f({entry:e,root:Zn(t,e),envDir:t,publicDir:x.join(t,`public`),cwd:t,runtimeConfig:_,stdout:n,stderr:c,notify:s(e=>b?.notify(`vite`,e)),reload:s(e=>{C?M().then(t=>{t&&N(e)}):w=!0}),onError:s(e=>X(c,`build failed`,e,q)),onUpdate:s(({file:e,took:r})=>{if(!C)return;let i=T(`dim`,x.relative(t,e),{stream:n});J(n,`${T(`green`,`update`)} ${i} (${r}ms)`,q)})});j=e=>i.dispatch(e),l={close:()=>(j=void 0,i.close())},b?C?await M():w=!0:(await P(i.entryFile,{vite:e=>j?.(e)}),b||r())}else l=await u.watch({entry:e,root:Zn(t,e),envDir:t,publicDir:x.join(t,`public`),outDir:v,runtimeConfig:Je(_,t,v),mode:`development`,stdout:n,stderr:c,onBuild:e=>{D=D.then(()=>o()?F(e):void 0)},onError:s(e=>{X(c,`build failed`,e,q)})});return{entry:e,async close(){k++,await l.close()}}}async function I(){let e=O;O=void 0,await e?.close()}async function L(){if(i)return;let e=Qn(t,d);if(e===void 0||e!==O?.entry)try{e===void 0&&await I();let n=await $n(t,d);if(A=!1,await I(),i)return;O=await te(n)}catch(t){A||X(c,`build failed`,Y(t),q),A=e===void 0}}async function ne(e){let n=e;for(;await Promise.race([a.then(()=>!1),n.edited.then(()=>!0)]);)n.close(),n=o=Kr(t,{appFile:d.appFile}),D=D.then(L),await D}let R=m;if(h){o=Kr(t,{appFile:d.appFile});try{R=await $n(t,d)}catch(e){R=void 0,A=!0,X(c,`build failed`,Y(e),q)}}R!==void 0&&(O=await te(R)),o&&(s=ne(o).then(()=>void 0,e=>(r(),{error:e}))),await a;let re=await s;if(await O?.close(),await D,await b?.stop(),re)throw re.error;if(S)throw S;if(ee)throw new K(`ERR_INCA_HOST_EXITED_EARLY`,`the host exited before it was ready`);if(E&&E.code!==0&&E.signal!==`SIGINT`&&E.signal!==`SIGTERM`){let{code:e,signal:t}=E;throw new K(`ERR_INCA_HOST_CRASHED`,`the host exited with ${t?`signal ${t}`:`code ${e}`}`)}}finally{r(),await s,o?.close(),await n()}}async function ni(){let e=await br();switch(e.state){case`unsupported`:return`unavailable (unsupported platform)`;case`notInstalled`:return`${e.target.name} (not installed)`;case`noBinary`:return`${e.target.name} (no binary)`;case`corrupt`:return`${e.target.name} (corrupt)`;case`installed`:return`${e.target.name}@${e.pkg.version}`}}async function ri(e,t){let n=await Q(e,t);return await $(n),n}async function ii(e){try{return await e()}catch(e){if(!(e instanceof K))throw e;return`unavailable (${e.code.replace(/^ERR_INCA_HOST_/,``).toLowerCase().replaceAll(`_`,` `)})`}}async function ai(e=process.stdout,t=process.cwd(),n=process.stderr){let r=[[`Incarnative.js:`,Ke],[`host package:`,await ii(ni)],[`host binary:`,await ii(()=>ri(t,n))]],i=Math.max(...r.map(([e])=>e.length))+1;e.write(r.map(([e,t])=>`${e.padEnd(i)}${t}\n`).join(``))}function oi(){if(process.platform===`darwin`)return`macos`;if(process.platform===`linux`)return`linux`;throw new K(`ERR_INCA_PLATFORM_UNSUPPORTED`,`inca package doesn't support ${process.platform} yet`)}async function si(e,t){await Promise.all(e.files.map(async n=>{let r=x.join(t,n);await k(x.dirname(r),{recursive:!0}),await D(x.join(e.outDir,n),r)}))}function ci(e,t){let n=e.files.map(e=>e.split(`/`)[0]??e).find(e=>e.toLowerCase()===t.toLowerCase());if(n!==void 0)throw new K(`ERR_INCA_PRODUCT_NAME_INVALID`,`the packaged app's directory "${t}" collides with "${n}" in the build output. Set a different "productName" in inca.config.ts`)}function li(e,t){let n=t.map(e=>x.basename(e).toLowerCase()),r=e.files.map(e=>e.split(`/`)[0]??e).find(e=>n.includes(e.toLowerCase()));if(r!==void 0)throw new K(`ERR_INCA_PUBLIC_FILE_RESERVED`,`"${r}" collides with a file the packaged app reserves. rename the file in public/`)}async function ui(e,t){await Promise.all(e.map(e=>D(e,x.join(t,x.basename(e)))))}async function di({metadata:e,output:t,hostBin:n,licenseFiles:r}){let{appPath:i,resourcesDir:a}=await Lr({appPath:x.join(t.outDir,`${e.productName}.app`),metadata:e,hostBin:n});return await si(t,a),await ui(r,a),i}async function fi({metadata:e,output:t,hostBin:n,licenseFiles:r}){let i=c(e.productName);ci(t,i);let a=x.join(t.outDir,i);await N(a,{recursive:!0,force:!0}),await k(a,{recursive:!0});let o=x.join(a,i);return await D(n,o),await E(o,493),await si(t,a),await ui(r,a),a}async function pi(e={}){let t=e.cwd??process.cwd(),n=e.stdout??process.stdout,r=e.target??oi(),i=await tn(t);i.usedPackageJsonKey&&J(n,`the "inca" key in package.json is deprecated. move these settings to inca.config.ts`),i.identifierIsDefault&&J(n,`no "identifier" set in inca.config.ts. using generated identifier ${i.identifier}`);let a=await tr({cwd:t,entry:e.entry,config:i,sourcemap:e.sourcemap,runtimeConfig:nn(i),bundler:e.bundler,frontend:e.frontend,stdout:n,stderr:e.stderr}),o=e.hostBin??await Q(t,e.stderr);await $(o),Hr(o,a.entryFile);let s=await wr(e.hostBin);li(a,s);let c={metadata:i,output:a,hostBin:o,licenseFiles:s};return{appPath:r===`macos`?await di(c):await fi(c)}}function mi(e){return x.relative(process.cwd(),e)}const hi={type:`boolean`,description:`Write a source map`,negativeDescription:`Skip the source map`};function gi(){for(let e of[0,1,2])try{p.closeSync(e)}catch{}}const _i=G({meta:{name:`build`,description:`Bundle the app into dist`},args:{sourcemap:hi},async run({args:e}){try{let t=await tr({sourcemap:e.sourcemap});await Ur(t.entryFile,process.stderr),J(process.stdout,`built ${mi(t.entryFile)}`)}catch(e){X(process.stderr,`build failed`,Y(e)),process.exitCode=1}}}),vi=G({meta:{name:`package`,description:`Package the app as an application bundle`},args:{sourcemap:hi},async run({args:e}){try{let{appPath:t}=await pi({sourcemap:e.sourcemap});J(process.stdout,`packaged ${mi(t)}`)}catch(e){X(process.stderr,`package failed`,Y(e)),process.exitCode=1}}}),yi=G({meta:{name:`config`,description:`Print the settings the host applies to the app`},async run(){try{process.exitCode=await Wr()}catch(e){X(process.stderr,`config failed`,Y(e)),process.exitCode=1}}}),bi=G({meta:{name:`info`,description:`Print the versions and the host binary in use`},async run(){try{await ai()}catch(e){X(process.stderr,`info failed`,Y(e)),process.exitCode=1}}}),xi=G({meta:{name:`dev`,description:`Run the app in a development window`},args:{"experimental-hmr":{type:`boolean`,description:`Apply edits without a reload (or set INCA_EXPERIMENTAL_HMR)`}},async run({args:e}){`sourcemap`in e&&cn(process.stderr,`dev ignores --sourcemap and --no-sourcemap`,{timestamp:!0});let t=new AbortController,n=()=>{t.signal.aborted||(J(process.stderr,`shutting down`,{timestamp:!0}),t.abort())};process.on(`SIGINT`,n),process.on(`SIGTERM`,n);let r=e[`experimental-hmr`]===!0||![``,`0`,`false`].includes(process.env.INCA_EXPERIMENTAL_HMR??``);r&&J(process.stdout,`experimental HMR active`,{timestamp:!0});try{await ti({signal:t.signal,experimentalHmr:r}),t.signal.aborted&&gi()}catch(e){X(process.stderr,`dev failed`,Y(e),{timestamp:!0}),process.exitCode=1}}}),Si=G({meta:{name:`inca`,version:Ke,description:qe},subCommands:{dev:xi,build:_i,package:vi,config:yi,info:bi}});async function Ci(e=process.argv){await Ue(Si,{rawArgs:e.slice(2)})}export{Ci as run};
39
+ `}async function Br(e){let{appPath:t,metadata:n,hostBin:r}=e;await M(t,{recursive:!0,force:!0});let i=b.join(t,`Contents`),a=b.join(i,`MacOS`),o=b.join(i,`Resources`);await k(a,{recursive:!0}),await k(o,{recursive:!0});let s=b.join(a,n.productName);e.link?await O(r,s).catch(()=>D(r,s)):await D(r,s),await E(s,493);let c={CFBundleName:n.productName,CFBundleDisplayName:n.productName,CFBundleExecutable:n.productName,CFBundleIdentifier:n.identifier,CFBundleVersion:n.version,CFBundleShortVersionString:n.version,CFBundlePackageType:`APPL`,CFBundleInfoDictionaryVersion:`6.0`,NSHighResolutionCapable:!0};if(n.icon){let e=b.basename(n.icon);await D(n.icon,b.join(o,e)),c.CFBundleIconFile=e}return await P(b.join(i,`Info.plist`),zr(c)),await P(b.join(i,`PkgInfo`),`APPL????`),{appPath:t,executablePath:s,resourcesDir:o}}const Vr={productName:`a string`,identifier:`a string`,window:`an object`,dev:`an object`,"window.width":`a number`,"window.height":`a number`,"window.title":`a string`,"window.resizable":`true or false`,"window.minWidth":`a number`,"window.minHeight":`a number`,"dev.stackPaths":`a string`};function Hr(e){return typeof e==`number`?`a number`:typeof e==`string`?`a string`:typeof e==`boolean`?`true or false`:`an object`}function Ur(e,t,n){let r=`failed to read ${t}: `,i=e.split(`
40
+ `)[0]??``;if(!i.startsWith(r))return;let a=i.slice(r.length),o=a.indexOf(`]: `),s;try{s=JSON.parse(a.slice(0,o+1))}catch{return}if(!Array.isArray(s))return;let[c,...l]=s,u=[c===`name`?`productName`:c,...l].join(`.`),d=Vr[u];if(!d)return;let f=s.reduce((e,t)=>e?.[t],n),p=Hr(f)===d?`the host can't use it`:`it must be ${d}`;return new W(`ERR_INCA_CONFIG_INVALID`,`${u} in inca.config.ts is ${JSON.stringify(f)}. ${p}`)}function Wr(e,t,n,r){let i=le(e,[`--print-config`,t],{encoding:`utf8`});if(i.error)throw i.error;if(i.status!==0){let e=Ur(i.stderr,n,r);if(e)throw e}return i}function Gr(e,t){let n=b.join(b.dirname(t),`inca.json`),r={};try{r=JSON.parse(_(n,`utf8`))}catch{}let i=Wr(e,t,n,r);if(i.status===null)throw new W(`ERR_INCA_HOST_EXITED_EARLY`,`the host exited with signal ${String(i.signal)} before it read the config`);if(i.status!==0)throw new W(`ERR_INCA_CONFIG_INVALID`,`the host can't read ${n}. it reported "${i.stderr.split(`
41
+ `)[0]??``}"`)}async function Kr(e,t){let n;try{n=await Q(process.cwd(),t),await $(n)}catch(e){if(e instanceof W&&(e.code===`ERR_INCA_HOST_BIN_UNRESOLVED`||e.code===`ERR_INCA_HOST_BIN_NOT_FOUND`)){un(t,`no host binary found, so the config was not checked`);return}if(e instanceof W&&e.code===`ERR_INCA_HOST_UNPACK_FAILED`){un(t,`failed to unpack the host binary, so the config was not checked`);return}throw e}Gr(n,e)}async function qr(e={}){let t=e.cwd??process.cwd(),n=e.hostBin??await Q(t,e.stderr);await $(n);let r=await sn(t,{dev:!0}),i=b.join(t,`node_modules/.inca/config`),a=b.join(i,`bundle.js`),o=b.join(i,`inca.json`);await k(i,{recursive:!0}),await P(a,``),await P(o,JSON.stringify(Ze(r,t,i),void 0,2));let s=Wr(n,a,o,r);return(e.stdout??process.stdout).write(s.stdout),(e.stderr??process.stderr).write(s.stderr),s.status??1}const Jr=/^(?:inca\.config\.[a-z0-9]+|package\.json)$/;function Yr(e,t){let n=t.debounceMs??100,r=[...Qn,t.appFile],i=/* @__PURE__ */ new Set,a,o=!1,s=()=>{},c=new Promise(e=>{s=e}),l=()=>{o||(clearTimeout(a),a=setTimeout(s,n),a.unref())},u=(e,t)=>{let n=e;for(let e;!h(n)&&(e=b.dirname(n))!==n;)n=e;let r=n===e?void 0:b.relative(n,e).split(b.sep)[0],a=ee(n);a.on(`change`,(e,n)=>{let i=n===null?null:String(n);(i===null||(r===void 0?t(i):i===r))&&l()}),a.on(`error`,()=>{a.close(),i.delete(a),l()}),i.add(a)},d=()=>{o=!0,clearTimeout(a);for(let e of i)e.close();i.clear()};try{u(e,e=>e===`src`||Jr.test(e)),u(b.join(e,`src`),e=>r.includes(e))}catch(e){throw d(),e}return{edited:c,add(e){if(o)return;let t=b.resolve(e);u(b.dirname(t),e=>e===b.basename(t))},close:d}}function Xr(e,t){return new Promise(n=>{let r=()=>n(!1);t.addEventListener(`abort`,r,{once:!0}),e.then(()=>{t.removeEventListener(`abort`,r),n(!0)})})}async function Zr(e){let{cwd:t,signal:n,stdout:r,stderr:i,appFile:a,debounceMs:o}=e,s=!1;for(;;){let c=Yr(t,{appFile:a,debounceMs:o});try{return await e.attempt(c)}catch(e){let t=e instanceof W?e.path:void 0;if(t)try{c.add(t)}catch(t){if(n.aborted)return;throw Y(i,`build failed`,J(e),K),t}if(!n.aborted&&!s&&t&&h(t)){s=!0;continue}if(s=!1,n.aborted||(Y(i,`build failed`,J(e),K),q(r,`waiting for a change to retry`,K),!await Xr(c.edited,n)))return;q(r,`retrying`,K)}finally{c.close()}}}const Qr=[`ERR_INCA_PACKAGE_JSON_NOT_FOUND`,`ERR_INCA_PRODUCT_NAME_MISSING`];async function $r(e,t,n){try{return await an(e)}catch(e){if(!(e instanceof W)||!Qr.includes(e.code))throw e;n.aborted||q(t,`running unnamed. ${e.message}`,K);return}}async function ei(e,t,n,r,i){if(process.platform===`darwin`&&t)try{return(await Br({appPath:b.join(e,`node_modules/.inca`,`${t.productName}.app`),metadata:t,hostBin:n,link:!0})).executablePath}catch(e){i.aborted||q(r,`running unbundled. ${J(e).message}`,K);return}}function ti(e){return b.join(e,`node_modules/.inca/dev`)}async function ni(e,t){let n=new Set(t),r;try{r=await j(e,{recursive:!0,withFileTypes:!0})}catch{return}await Promise.all(r.filter(e=>e.isFile()).map(t=>b.relative(e,b.join(t.parentPath,t.name))).filter(e=>!n.has(e)).map(t=>M(b.join(e,t),{force:!0})))}function ri(e){let{NO_COLOR:t,FORCE_COLOR:n}=process.env;if(!(!e.isTTY||t||n))return{...process.env,FORCE_COLOR:`1`}}async function ii(e){let t=e.cwd??process.cwd(),n=await Fr(t),r=()=>{},i=!1,a=new Promise(e=>{r=()=>{i=!0,e()}});e.signal.aborted?r():e.signal.addEventListener(`abort`,()=>r(),{once:!0});let o,s,c=!1;try{if(i)return;let n=e.stdout??process.stdout,l=e.stderr??process.stderr,u=e.hostBin??await Q(t,l,e.signal);if(i||(await $(u),i))return;let d=e.bundler??Zn,f=e.frontend??Yn,p=e.experimentalHmr?d.hmr?.bind(d):void 0;if(e.experimentalHmr&&!p)throw new W(`ERR_INCA_HMR_UNSUPPORTED`,`--experimental-hmr was set, but the configured bundler has no HMR support`);let m=await Zr({cwd:t,signal:e.signal,stdout:n,stderr:l,appFile:f.appFile,async attempt(){let r=await nn(t);if(i)return;let a=e.entry===void 0&&r.entry===void 0,o=e.entry??r.entry??await nr(t,f);if(i)return;let s=await $r(t,n,e.signal);if(i)return;let c=s?on(s,{dev:!0}):await sn(t,{dev:!0});if(!i)return{entry:o,automaticEntry:a,metadata:s,runtimeConfig:c}}});if(!m)return;let{entry:h,automaticEntry:g,metadata:_,runtimeConfig:v}=m,y=ti(t),ee=await ei(t,_,u,n,e.signal)??u;if(i)return;let x,S,C=!1,T=!1,E=!1,D,O=Promise.resolve(),k,A=0,j=!1,te;async function M(){if(i)return!1;try{return await Promise.race([Promise.resolve(x?.call(`reload`,void 0,1e4)).then(()=>!0),a.then(()=>!1)])}catch(e){return Y(l,`reload failed`,J(e),K),!1}}function N(e){if(!e)return;let r=w(`dim`,b.relative(t,e.file),{stream:n}),i=Date.now()-e.at;q(n,`${w(`green`,`reload`)} ${r} (${i}ms)`,K)}async function P(t,a){if(i)return;try{Gr(ee,t)}catch(e){e instanceof W&&e.code===`ERR_INCA_CONFIG_INVALID`?(S=e,r()):Y(l,`failed to start the host`,J(e),K);return}let o=new Ar({entryFile:t,hostBin:ee,signal:e.signal,env:ri(l),onStderr:e=>l.write(e),onReady:()=>{C=!0,q(n,`ready`,K),T&&(T=!1,M())},onAppError:e=>Y(l,`app error`,e,K),onExit:(e,t)=>{E=!C,D={code:e,signal:t},q(n,`host exited. stopping`,K),r()},integrations:a});try{await o.start()}catch(e){i||Y(l,`failed to start the host`,J(e),K);return}x=o}async function ne(e){await ni(e.outDir,e.files),x?C?await M()&&N(e.changed):T=!0:await P(e.entryFile)}async function F(e){let a=++A,o=()=>a===A&&!i,s=e=>(...t)=>{o()&&e(...t)},c;if(p){let i=await p({entry:e,root:er(t,e),envDir:t,publicDir:b.join(t,`public`),cwd:t,runtimeConfig:v,stdout:n,stderr:l,notify:s(e=>x?.notify(`vite`,e)),reload:s(e=>{C?M().then(t=>{t&&N(e)}):T=!0}),onError:s(e=>Y(l,`build failed`,e,K)),onUpdate:s(({file:e,took:r})=>{if(!C)return;let i=w(`dim`,b.relative(t,e),{stream:n});q(n,`${w(`green`,`update`)} ${i} (${r}ms)`,K)})});te=e=>i.dispatch(e),c={close:()=>(te=void 0,i.close())},x?C?await M():T=!0:(await P(i.entryFile,{vite:e=>te?.(e)}),x||r())}else c=await d.watch({entry:e,root:er(t,e),envDir:t,publicDir:b.join(t,`public`),outDir:y,runtimeConfig:Ze(v,t,y),mode:`development`,stdout:n,stderr:l,onBuild:e=>{O=O.then(()=>o()?ne(e):void 0)},onError:s(e=>{Y(l,`build failed`,e,K)})});return{entry:e,async close(){A++,await c.close()}}}async function I(){let e=k;k=void 0,await e?.close()}async function re(){if(i)return;let e=tr(t,f);if(e===void 0||e!==k?.entry)try{if(e===void 0&&await I(),i)return;let n=await nr(t,f);if(j=!1,await I(),i)return;k=await F(n)}catch(t){!j&&!i&&Y(l,`build failed`,J(t),K),j=e===void 0}}async function ie(e){let n=e;for(;await Promise.race([a.then(()=>!1),n.edited.then(()=>!0)]);)n.close(),n=o=Yr(t,{appFile:f.appFile}),O=O.then(re),await O}let L=h;if(g){o=Yr(t,{appFile:f.appFile});try{L=await nr(t,f)}catch(e){L=void 0,j=!0,i||Y(l,`build failed`,J(e),K)}}L!==void 0&&!i&&(k=await F(L)),o&&(s=ie(o).then(()=>void 0,e=>(r(),{error:e}))),c=!0,await a;let ae=await s;if(await k?.close(),await O,await x?.stop(),ae)throw ae.error;if(S)throw S;if(E)throw new W(`ERR_INCA_HOST_EXITED_EARLY`,`the host exited before it was ready`);if(D&&D.code!==0&&D.signal!==`SIGINT`&&D.signal!==`SIGTERM`){let{code:e,signal:t}=D;throw new W(`ERR_INCA_HOST_CRASHED`,`the host exited with ${t?`signal ${t}`:`code ${e}`}`)}}catch(t){if(c||!e.signal.aborted)throw t}finally{r(),await s,o?.close(),await n()}}async function ai(){let e=await Cr();switch(e.state){case`unsupported`:return`unavailable (unsupported platform)`;case`notInstalled`:return`${e.target.name} (not installed)`;case`noBinary`:return`${e.target.name} (no binary)`;case`corrupt`:return`${e.target.name} (corrupt)`;case`installed`:return`${e.target.name}@${e.pkg.version}`}}async function oi(e,t){let n=await Q(e,t);return await $(n),n}async function si(e){try{return await e()}catch(e){if(!(e instanceof W))throw e;return`unavailable (${e.code.replace(/^ERR_INCA_HOST_/,``).toLowerCase().replaceAll(`_`,` `)})`}}async function ci(e=process.stdout,t=process.cwd(),n=process.stderr){let r=[[`Incarnative.js:`,Ye],[`host package:`,await si(ai)],[`host binary:`,await si(()=>oi(t,n))]],i=Math.max(...r.map(([e])=>e.length))+1;e.write(r.map(([e,t])=>`${e.padEnd(i)}${t}\n`).join(``))}function li(){if(process.platform===`darwin`)return`macos`;if(process.platform===`linux`)return`linux`;throw new W(`ERR_INCA_PLATFORM_UNSUPPORTED`,`inca package doesn't support ${process.platform} yet`)}async function ui(e,t){await Promise.all(e.files.map(async n=>{let r=b.join(t,n);await k(b.dirname(r),{recursive:!0}),await D(b.join(e.outDir,n),r)}))}function di(e,t){let n=e.files.map(e=>e.split(`/`)[0]??e).find(e=>e.toLowerCase()===t.toLowerCase());if(n!==void 0)throw new W(`ERR_INCA_PRODUCT_NAME_INVALID`,`the packaged app's directory "${t}" collides with "${n}" in the build output. Set a different "productName" in inca.config.ts`)}function fi(e,t){let n=t.map(e=>b.basename(e).toLowerCase()),r=e.files.map(e=>e.split(`/`)[0]??e).find(e=>n.includes(e.toLowerCase()));if(r!==void 0)throw new W(`ERR_INCA_PUBLIC_FILE_RESERVED`,`"${r}" collides with a file the packaged app reserves. rename the file in public/`)}async function pi(e,t){await Promise.all(e.map(e=>D(e,b.join(t,b.basename(e)))))}async function mi({metadata:e,output:t,hostBin:n,licenseFiles:r}){let{appPath:i,resourcesDir:a}=await Br({appPath:b.join(t.outDir,`${e.productName}.app`),metadata:e,hostBin:n});return await ui(t,a),await pi(r,a),i}async function hi({metadata:e,output:t,hostBin:n,licenseFiles:r}){let i=c(e.productName);di(t,i);let a=b.join(t.outDir,i);await M(a,{recursive:!0,force:!0}),await k(a,{recursive:!0});let o=b.join(a,i);return await D(n,o),await E(o,493),await ui(t,a),await pi(r,a),a}async function gi(e={}){let t=e.cwd??process.cwd(),n=e.stdout??process.stdout,r=e.target??li(),i=await an(t);i.usedPackageJsonKey&&q(n,`the "inca" key in package.json is deprecated. move these settings to inca.config.ts`),i.identifierIsDefault&&q(n,`no "identifier" set in inca.config.ts. using generated identifier ${i.identifier}`);let a=await ir({cwd:t,entry:e.entry,config:i,sourcemap:e.sourcemap,runtimeConfig:on(i),bundler:e.bundler,frontend:e.frontend,stdout:n,stderr:e.stderr}),o=e.hostBin??await Q(t,e.stderr);await $(o),Gr(o,a.entryFile);let s=await Dr(e.hostBin);fi(a,s);let c={metadata:i,output:a,hostBin:o,licenseFiles:s};return{appPath:r===`macos`?await mi(c):await hi(c)}}function _i(e){return b.relative(process.cwd(),e)}const vi={type:`boolean`,description:`Write a source map`,negativeDescription:`Skip the source map`};function yi(){for(let e of[0,1,2])try{p.closeSync(e)}catch{}}const bi=U({meta:{name:`build`,description:`Bundle the app into dist`},args:{sourcemap:vi},async run({args:e}){try{let t=await ir({sourcemap:e.sourcemap});await Kr(t.entryFile,process.stderr),q(process.stdout,`built ${_i(t.entryFile)}`)}catch(e){Y(process.stderr,`build failed`,J(e)),process.exitCode=1}}}),xi=U({meta:{name:`package`,description:`Package the app as an application bundle`},args:{sourcemap:vi},async run({args:e}){try{let{appPath:t}=await gi({sourcemap:e.sourcemap});q(process.stdout,`packaged ${_i(t)}`)}catch(e){Y(process.stderr,`package failed`,J(e)),process.exitCode=1}}}),Si=U({meta:{name:`config`,description:`Print the settings the host applies to the app`},async run(){try{process.exitCode=await qr()}catch(e){Y(process.stderr,`config failed`,J(e)),process.exitCode=1}}}),Ci=U({meta:{name:`info`,description:`Print the versions and the host binary in use`},async run(){try{await ci()}catch(e){Y(process.stderr,`info failed`,J(e)),process.exitCode=1}}}),wi=U({meta:{name:`dev`,description:`Run the app in a development window`},args:{"experimental-hmr":{type:`boolean`,description:`Apply edits without a reload (or set INCA_EXPERIMENTAL_HMR)`}},async run({args:e}){`sourcemap`in e&&un(process.stderr,`dev ignores --sourcemap and --no-sourcemap`,{timestamp:!0});let t=new AbortController,n=()=>{t.signal.aborted||(q(process.stderr,`shutting down`,{timestamp:!0}),t.abort())};process.on(`SIGINT`,n),process.on(`SIGTERM`,n);let r=e[`experimental-hmr`]===!0||![``,`0`,`false`].includes(process.env.INCA_EXPERIMENTAL_HMR??``);r&&q(process.stdout,`experimental HMR active`,{timestamp:!0});try{await ii({signal:t.signal,experimentalHmr:r}),t.signal.aborted&&yi()}catch(e){Y(process.stderr,`dev failed`,J(e),{timestamp:!0}),process.exitCode=1}}}),Ti=U({meta:{name:`inca`,version:Ye,description:Xe},subCommands:{dev:wi,build:bi,package:xi,config:Si,info:Ci}});async function Ei(e=process.argv){await Ke(Ti,{rawArgs:e.slice(2)})}export{Ei as run};
@@ -1,4 +1,4 @@
1
- globalThis.URL===void 0&&(globalThis.URL=class{href;constructor(e){this.href=e}});let e=`sourceMa`;e+=`ppingURL`;const t=typeof process<`u`&&process.platform===`win32`;function n(e){return e.startsWith(`/@id/`)?e.slice(5).replace(`__x00__`,`\0`):e}const r=/\\/g;function i(e){return e.replace(r,`/`)}const a=/[?#].*$/;function o(e){return e.replace(a,``)}function s(e){return!e||typeof e!=`object`&&typeof e!=`function`}const c=async function(){}.constructor;let l;function u(){if(l===void 0){let e=`/*code*/`,t=new c(`a`,`b`,e).toString();l=t.slice(0,t.indexOf(e)).split(`
1
+ let e=`sourceMa`;e+=`ppingURL`;const t=typeof process<`u`&&process.platform===`win32`;function n(e){return e.startsWith(`/@id/`)?e.slice(5).replace(`__x00__`,`\0`):e}const r=/\\/g;function i(e){return e.replace(r,`/`)}const a=/[?#].*$/;function o(e){return e.replace(a,``)}function s(e){return!e||typeof e!=`object`&&typeof e!=`function`}const c=async function(){}.constructor;let l;function u(){if(l===void 0){let e=`/*code*/`,t=new c(`a`,`b`,e).toString();l=t.slice(0,t.indexOf(e)).split(`
2
2
  `).length-1}return l}function ee(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}const d=/(?:%[0-9a-f]{2})+/gi,f=/^\s+$/;function p(e){return e.replace(d,e=>{let t;try{t=decodeURIComponent(e)}catch{return e}return f.test(t)?t:e})}var m=44,h=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,g=/* @__PURE__ */ new Uint8Array(64),_=/* @__PURE__ */ new Uint8Array(128);for(let e=0;e<h.length;e++){let t=h.charCodeAt(e);g[e]=t,_[t]=e}function v(e){let t=0,n=0,r=0;do r=_[e.next()],t|=(r&31)<<n,n+=5;while(r&32);return t}function y(e){return e&1?-2147483648|-(e>>>1):e>>>1}function b(e,t){return e.pos>=t?!1:e.peek()!==m}var te=class{constructor(e){this.pos=0,this.buffer=e}next(){return this.buffer.charCodeAt(this.pos++)}peek(){return this.buffer.charCodeAt(this.pos)}indexOf(e){let{buffer:t,pos:n}=this,r=t.indexOf(e,n);return r===-1?t.length:r}};function ne(e){let{length:t}=e,n=new te(e),r=[],i=0,a=0,o=0,s=0,c=0;do{let e=n.indexOf(`;`),t=[],l=!0,u=0;for(i=0;n.pos<e;){let r;i+=y(v(n)),i<u&&(l=!1),u=i,b(n,e)?(a+=y(v(n)),o+=y(v(n)),s+=y(v(n)),b(n,e)?(c+=y(v(n)),r=[i,a,o,s,c]):r=[i,a,o,s]):r=[i],t.push(r),n.pos++}l||re(t),r.push(t),n.pos=e+1}while(n.pos<=t);return r}function re(e){e.sort(ie)}function ie(e,t){return e[0]-t[0]}var x=0,ae=1,oe=2,se=3,ce=4,S=!1;function le(e,t,n,r){for(;n<=r;){let i=n+(r-n>>1),a=e[i][x]-t;if(a===0)return S=!0,i;a<0?n=i+1:r=i-1}return S=!1,n-1}function ue(e,t,n){for(let r=n+1;r<e.length&&e[r][x]===t;n=r++);return n}function de(e,t,n){for(let r=n-1;r>=0&&e[r][x]===t;n=r--);return n}function fe(e,t,n,r){let{lastKey:i,lastNeedle:a,lastIndex:o}=n,s=0,c=e.length-1;if(r===i){if(t===a)return S=o!==-1&&e[o][x]===t,o;t>=a?s=o===-1?0:o:c=o}return n.lastKey=r,n.lastNeedle=t,n.lastIndex=le(e,t,s,c)}var pe="`line` must be greater than 0 (lines start at line 1)",me="`column` must be greater than or equal to 0 (columns start at column 0)";function C(e){return e}function he(e){var t;return(t=C(e))._decoded||(t._decoded=ne(C(e)._encoded))}function ge(e,t){let{line:n,column:r,bias:i}=t;if(n--,n<0)throw Error(pe);if(r<0)throw Error(me);let a=he(e);if(n>=a.length)return w(null,null,null,null);let o=a[n],s=_e(o,C(e)._decodedMemo,n,r,i||1);if(s===-1)return w(null,null,null,null);let c=o[s];if(c.length===1)return w(null,null,null,null);let{names:l,resolvedSources:u}=e;return w(u[c[ae]],c[oe]+1,c[se],c.length===5?l[c[ce]]:null)}function w(e,t,n,r){return{source:e,line:t,column:n,name:r}}function _e(e,t,n,r,i){let a=fe(e,r,t,n);return S?a=(i===-1?ue:de)(e,r,a):i===-1&&a++,a===-1||a===e.length?-1:a}const ve=/^[A-Za-z]:\//;function T(e=``){return e&&e.replace(/\\/g,`/`).replace(ve,e=>e.toUpperCase())}const ye=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,be=/^[A-Za-z]:$/;function xe(){return typeof process<`u`&&typeof process.cwd==`function`?process.cwd().replace(/\\/g,`/`):`/`}const Se=function(...e){e=e.map(e=>T(e));let t=``,n=!1;for(let r=e.length-1;r>=-1&&!n;r--){let i=r>=0?e[r]:xe();i&&i.length!==0&&(t=`${i}/${t}`,n=E(i))}return t=Ce(t,!n),n&&!E(t)?`/${t}`:t.length>0?t:`.`};function Ce(e,t){let n=``,r=0,i=-1,a=0,o=null;for(let s=0;s<=e.length;++s){if(s<e.length)o=e[s];else if(o===`/`)break;else o=`/`;if(o===`/`){if(i!==s-1&&a!==1){if(a===2){if(n.length<2||r!==2||n[n.length-1]!==`.`||n[n.length-2]!==`.`){if(n.length>2){let e=n.lastIndexOf(`/`);e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}if(n.length>0){n=``,r=0,i=s,a=0;continue}}t&&(n+=n.length>0?`/..`:`..`,r=2)}else n.length>0?n+=`/${e.slice(i+1,s)}`:n=e.slice(i+1,s),r=s-i-1}i=s,a=0}else o===`.`&&a!==-1?++a:a=-1}return n}const E=function(e){return ye.test(e)},we=function(e){let t=T(e).replace(/\/$/,``).split(`/`).slice(0,-1);return t.length===1&&be.test(t[0])&&(t[0]+=`/`),t.join(`/`)||(E(e)?`/`:`.`)},Te=new TextDecoder,D=(()=>{let e=typeof Buffer==`function`?Buffer:void 0;return e&&typeof e.from==`function`?t=>e.from(t,`base64`).toString(`utf-8`):e=>Te.decode(Uint8Array.from(atob(e),e=>e.charCodeAt(0)))})(),Ee=/%/g,De=/\\/g,Oe=/\n/g,ke=/\r/g,Ae=/\t/g,je=/\?/g,Me=/#/g;function Ne(e){return e.includes(`%`)&&(e=e.replace(Ee,`%25`)),!t&&e.includes(`\\`)&&(e=e.replace(De,`%5C`)),e.includes(`
3
3
  `)&&(e=e.replace(Oe,`%0A`)),e.includes(`\r`)&&(e=e.replace(ke,`%0D`)),e.includes(` `)&&(e=e.replace(Ae,`%09`)),e}const O=we,k=Se;function A(e){let n=k(e),r=e.charCodeAt(e.length-1);return(r===47||t&&r===92)&&n.at(-1)!==`/`&&(n+=`/`),n=Ne(n),n.includes(`?`)&&(n=n.replace(je,`%3F`)),n.includes(`#`)&&(n=n.replace(Me,`%23`)),new URL(`file://${n}`).href}function j(e){return e.replace(/\//g,`\\`)}var M=class{map;_encoded;_decoded;_decodedMemo;url;file;version;names=[];resolvedSources;constructor(e,t){this.map=e;let{mappings:n,names:r,sources:i}=e;this.version=e.version,this.names=r||[],this._encoded=n||``,this._decodedMemo=Pe(),this.url=t,this.file=t;let a=O(t);this.resolvedSources=(i||[]).map(e=>k(a,e||``))}};function Pe(){return{lastKey:-1,lastNeedle:-1,lastIndex:-1}}function Fe(e,t){let n=ge(e,t);return n.column==null?null:n}const Ie=RegExp(`//# ${e}=data:application/json;base64,(.+)`);var Le=class{id;url;importers=/* @__PURE__ */ new Set;imports=/* @__PURE__ */ new Set;evaluated=!1;meta;promise;exports;file;map;constructor(e,t){this.id=e,this.url=t,this.file=o(e)}},Re=class{idToModuleMap=/* @__PURE__ */ new Map;fileToModulesMap=/* @__PURE__ */ new Map;urlToIdModuleMap=/* @__PURE__ */ new Map;getModuleById(e){return this.idToModuleMap.get(e)}getModulesByFile(e){return this.fileToModulesMap.get(e)}getModuleByUrl(e){return this.urlToIdModuleMap.get(n(e))}ensureModule(e,t){if(e=Be(e),this.idToModuleMap.has(e)){let n=this.idToModuleMap.get(e);return this.urlToIdModuleMap.set(t,n),n}let n=new Le(e,t);this.idToModuleMap.set(e,n),this.urlToIdModuleMap.set(t,n);let r=this.fileToModulesMap.get(n.file)||/* @__PURE__ */ new Set;return r.add(n),this.fileToModulesMap.set(n.file,r),n}invalidateModule(e){e.evaluated=!1,e.meta=void 0,e.map=void 0,e.promise=void 0,e.exports=void 0,e.imports.clear()}getModuleSourceMapById(t){let n=this.getModuleById(t);if(!n)return null;if(n.map)return n.map;if(!n.meta||!(`code`in n.meta))return null;let r=`//# ${e}=data:application/json;base64,`,i=n.meta.code.lastIndexOf(r);if(i===-1)return null;let a=Ie.exec(n.meta.code.slice(i))?.[1];return a?(n.map=new M(JSON.parse(D(a)),n.file),n.map):null}clear(){this.idToModuleMap.clear(),this.fileToModulesMap.clear(),this.urlToIdModuleMap.clear()}};const ze=/* @__PURE__ */ new Set([`node:sea`,`node:sqlite`,`node:test`,`node:test/reporters`]);function Be(e){return ze.has(e)?e:i(e).replace(/^\/@fs\//,t?``:`/`).replace(/^node:/,``).replace(/^\/+/,`/`).replace(/^file:\/+/,t?``:`/`)}function Ve(e){let t=new Set(e.filter(e=>typeof e==`string`)),n=e.filter(e=>typeof e!=`string`);return e=>t.has(e)||n.some(t=>t.test(e))}var He=class{hmrClient;ownerPath;newListeners;constructor(e,t){this.hmrClient=e,this.ownerPath=t,e.dataMap.has(t)||e.dataMap.set(t,{});let n=e.hotModulesMap.get(t);n&&(n.callbacks=[]);let r=e.ctxToListenersMap.get(t);if(r)for(let[t,n]of r){let r=e.customListenersMap.get(t);r&&e.customListenersMap.set(t,r.filter(e=>!n.includes(e)))}this.newListeners=/* @__PURE__ */ new Map,e.ctxToListenersMap.set(t,this.newListeners)}get data(){return this.hmrClient.dataMap.get(this.ownerPath)}accept(e,t){if(typeof e==`function`||!e)this.acceptDeps([this.ownerPath],([t])=>e?.(t));else if(typeof e==`string`)this.acceptDeps([e],([e])=>t?.(e));else if(Array.isArray(e))this.acceptDeps(e,t);else throw Error(`invalid hot.accept() usage.`)}acceptExports(e,t){this.acceptDeps([this.ownerPath],([e])=>t?.(e),typeof e==`string`?[e]:e)}dispose(e){this.hmrClient.disposeMap.set(this.ownerPath,e)}prune(e){this.hmrClient.pruneMap.set(this.ownerPath,e)}decline(){}invalidate(e){let t=this.hmrClient.currentFirstInvalidatedBy??this.ownerPath;this.hmrClient.notifyListeners(`vite:invalidate`,{path:this.ownerPath,message:e,firstInvalidatedBy:t}),this.send(`vite:invalidate`,{path:this.ownerPath,message:e,firstInvalidatedBy:t}),this.hmrClient.logger.debug(`invalidate ${this.ownerPath}${e?`: ${e}`:``}`)}on(e,t){let n=n=>{let r=n.get(e)||[];r.push(t),n.set(e,r)};n(this.hmrClient.customListenersMap),n(this.newListeners)}off(e,t){let n=n=>{let r=n.get(e);if(r===void 0)return;let i=r.filter(e=>e!==t);i.length===0?n.delete(e):n.set(e,i)};n(this.hmrClient.customListenersMap),n(this.newListeners)}send(e,t){this.hmrClient.send({type:`custom`,event:e,data:t})}acceptDeps(e,t=()=>{},n){let r=this.hmrClient.hotModulesMap.get(this.ownerPath)||{id:this.ownerPath,callbacks:[]};r.callbacks.push({deps:e,fn:t,exports:n}),this.hmrClient.hotModulesMap.set(this.ownerPath,r)}},Ue=class{logger;transport;importUpdatedModule;hotModulesMap=/* @__PURE__ */ new Map;disposeMap=/* @__PURE__ */ new Map;pruneMap=/* @__PURE__ */ new Map;dataMap=/* @__PURE__ */ new Map;customListenersMap=/* @__PURE__ */ new Map;ctxToListenersMap=/* @__PURE__ */ new Map;currentFirstInvalidatedBy;constructor(e,t,n){this.logger=e,this.transport=t,this.importUpdatedModule=n}async notifyListeners(e,t){let n=this.customListenersMap.get(e);n&&await Promise.allSettled(n.map(e=>e(t)))}send(e){this.transport.send(e).catch(e=>{this.logger.error(e)})}clear(){this.hotModulesMap.clear(),this.disposeMap.clear(),this.pruneMap.clear(),this.dataMap.clear(),this.customListenersMap.clear(),this.ctxToListenersMap.clear()}async prunePaths(e){try{await Promise.all(e.map(e=>{let t=this.disposeMap.get(e);if(t)return t(this.dataMap.get(e))})),await Promise.all(e.map(e=>{let t=this.pruneMap.get(e);if(t)return t(this.dataMap.get(e))}))}finally{e.forEach(e=>this.dataMap.delete(e))}}warnFailedUpdate(e,t){e instanceof Error&&e.message.includes(`fetch`)||this.logger.error(e),this.logger.error(`Failed to reload ${t}. This could be due to syntax errors or importing non-existent modules. (see errors above)`)}updateQueue=[];pendingUpdateQueue=!1;async queueUpdate(e){if(this.updateQueue.push(this.fetchUpdate(e)),!this.pendingUpdateQueue){this.pendingUpdateQueue=!0,await Promise.resolve(),this.pendingUpdateQueue=!1;let e=[...this.updateQueue];this.updateQueue=[],(await Promise.all(e)).forEach(e=>e&&e())}}async fetchUpdate(e){let{path:t,acceptedPath:n,firstInvalidatedBy:r}=e,i=this.hotModulesMap.get(t);if(!i)return;let a,o=t===n,s=i.callbacks.filter(({deps:e})=>e.includes(n));if(o||s.length>0){let t=this.disposeMap.get(n);t&&await t(this.dataMap.get(n));try{a=await this.importUpdatedModule(e)}catch(e){this.warnFailedUpdate(e,n)}}return()=>{try{this.currentFirstInvalidatedBy=r;for(let{deps:e,fn:t}of s)t(e.map(e=>e===n?a:void 0));let e=o?t:`${n} via ${t}`;this.logger.debug(`hot updated: ${e}`)}finally{this.currentFirstInvalidatedBy=void 0}}}};let We=(e=21)=>{let t=``,n=e|0;for(;n-->0;)t+=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`[Math.random()*64|0];return t};function N(e){let t=Error(e.message||`Unknown invoke error`);return Object.assign(t,e,{runnerError:/* @__PURE__ */ Error(`RunnerError`)}),t}const Ge=e=>{if(e.invoke)return{...e,async invoke(t,n){let r=await e.invoke({type:`custom`,event:`vite:invoke`,data:{id:`send`,name:t,data:n}});if(`error`in r)throw N(r.error);return r.result}};if(!e.send||!e.connect)throw Error(`transport must implement send and connect when invoke is not implemented`);let t=/* @__PURE__ */ new Map;return{...e,connect({onMessage:n,onDisconnection:r}){return e.connect({onMessage(e){if(e.type===`custom`&&e.event===`vite:invoke`){let n=e.data;if(n.id.startsWith(`response:`)){let e=n.id.slice(9),r=t.get(e);if(!r)return;r.timeoutId&&clearTimeout(r.timeoutId),t.delete(e);let{error:i,result:a}=n.data;i?r.reject(i):r.resolve(a);return}}n(e)},onDisconnection:r})},disconnect(){return t.forEach(e=>{e.reject(/* @__PURE__ */ Error(`transport was disconnected, cannot call ${JSON.stringify(e.name)}`))}),t.clear(),e.disconnect?.()},send(t){return e.send(t)},async invoke(n,r){let i=We(),a={type:`custom`,event:`vite:invoke`,data:{name:n,id:`send:${i}`,data:r}},o=e.send(a),{promise:s,resolve:c,reject:l}=ee(),u=e.timeout??6e4,d;u>0&&(d=setTimeout(()=>{t.delete(i),l(/* @__PURE__ */ Error(`transport invoke timed out after ${u}ms (data: ${JSON.stringify(a)})`))},u),d?.unref?.()),t.set(i,{resolve:c,reject:l,name:n,timeoutId:d}),o&&o.catch(e=>{clearTimeout(d),t.delete(i),l(e)});try{return await s}catch(e){throw N(e)}}}},Ke=e=>{let t=Ge(e),n=!t.connect,r;return{...e,...t.connect?{async connect(e){if(n)return;if(r){await r;return}let i=t.connect({onMessage:e??(()=>{}),onDisconnection(){n=!1}});i&&(r=i,await r,r=void 0),n=!0}}:{},...t.disconnect?{async disconnect(){n&&(r&&await r,n=!1,await t.disconnect())}}:{},async send(e){if(t.send){if(!n){if(r)await r;else throw new P(`send was called before connect`)}await t.send(e)}},async invoke(e,i){if(!n){if(r)await r;else throw new P(`invoke was called before connect`)}return t.invoke(e,i)}}};var P=class extends Error{constructor(e){super(e),this.name=`SendBeforeConnectError`}};function qe(e,t,n,r){if(!r?.isDynamicImport&&r?.importedNames?.length){let i=r.importedNames.filter(t=>!(t in e));if(i.length){let e=i.at(-1);throw SyntaxError(n===`module`?`[vite] The requested module '${t}' does not provide an export named '${e}'`:`\
4
4
  [vite] Named export '${e}' not found. The requested module '${t}' is a CommonJS module, which may not support all module.exports as named exports.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@incajs/cli",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
4
4
  "description": "Commands to develop, bundle, and package Incarnative.js apps.",
5
5
  "keywords": [
6
6
  "bundler",
@@ -32,9 +32,7 @@
32
32
  "LICENSE-APACHE"
33
33
  ],
34
34
  "type": "module",
35
- "sideEffects": [
36
- "src/vite/runtime/globals.mts"
37
- ],
35
+ "sideEffects": false,
38
36
  "main": "./dist/index.js",
39
37
  "types": "./dist/index.d.ts",
40
38
  "exports": {
@@ -63,10 +61,10 @@
63
61
  }
64
62
  },
65
63
  "optionalDependencies": {
66
- "@incajs/host-darwin-arm64": "0.0.28",
67
- "@incajs/host-darwin-x64": "0.0.28",
68
- "@incajs/host-linux-arm64": "0.0.28",
69
- "@incajs/host-linux-x64": "0.0.28"
64
+ "@incajs/host-darwin-arm64": "0.0.30",
65
+ "@incajs/host-darwin-x64": "0.0.30",
66
+ "@incajs/host-linux-arm64": "0.0.30",
67
+ "@incajs/host-linux-x64": "0.0.30"
70
68
  },
71
69
  "engines": {
72
70
  "node": ">=22.18"