@incajs/cli 0.0.25 → 0.0.26

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/LICENSE-APACHE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/LICENSE-MIT ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 tom96da
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/cli.js CHANGED
@@ -1,33 +1,33 @@
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 ee,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 ne,writeFile as N}from"node:fs/promises";import{fileURLToPath as re,pathToFileURL as ie}from"node:url";import{homedir as P}from"node:os";import{DevEnvironment as F,build as I,buildErrorMessage as ae,createServer as oe}from"vite";import se from"@vitejs/plugin-vue";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 we(e,t){return Se(Ce(e||``,t))}function Te(e,t){return e?(Array.isArray(e)?e:be(e)).map(e=>e.toLowerCase()).join(t??`-`):``}function Ee(e){return Te(e||``,`_`)}function L(e){return Array.isArray(e)?e:e===void 0?[]:[e]}function De(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 R(e){return typeof e==`function`?e():e}var z=class extends Error{code;constructor(e,t){super(e),this.name=`CLIError`,this.code=t}};function Oe(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=ee({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 ke=/* @__PURE__ */ (()=>{let e=globalThis.process?.env??{};return e.NO_COLOR===`1`||e.TERM===`dumb`||e.TEST||e.CI})(),Ae=(e,t=39)=>n=>ke?n:`\u001B[${e}m${n}\u001B[${t}m`,je=/* @__PURE__ */ Ae(1,22),B=/* @__PURE__ */ Ae(36),Me=/* @__PURE__ */ Ae(90),V=/* @__PURE__ */ Ae(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=we(e.name),r=Te(e.name);if(t!==e.name||r!==e.name){let i=L(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=Oe(e,n),[...a]=i._,o=new Proxy(i,{get(e,t){return e[t]??e[we(t)]??e[Te(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 z(`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 z(`Invalid value for argument: ${B(`--${e.name}`)} (${B(t)}). Expected one of: ${n.map(e=>B(e)).join(`, `)}.`,`EARG`)}else if(e.required&&o[e.name]===void 0)throw new z(`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:L(r.alias)});return t}async function Fe(e){return Promise.all(e.map(e=>R(e)))}function H(e){return e}async function Ie(e,t){let n=await R(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 R(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 z(`Unknown command ${B(a)}`,`E_UNKNOWN_COMMAND`);await Ie(e,{rawArgs:t.rawArgs.slice(i+1)})}else{let n=await R(e.default);if(n){if(e.run)throw new z(`Cannot specify both 'run' and 'default' on the same command.`,`E_DEFAULT_CONFLICT`);let i=await Re(r,n);if(!i)throw new z(`Default sub command ${B(n)} not found in subCommands.`,`E_UNKNOWN_COMMAND`);await Ie(i,{rawArgs:t.rawArgs})}else if(!e.run)throw new z(`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 R(e.subCommands);if(r&&Object.keys(r).length>0){let n=ze(t,await R(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 R(e[t]);for(let n of Object.values(e)){let e=await R(n),r=await R(e?.meta);if(r?.alias&&L(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=we(n);for(let[e,i]of Object.entries(t))if((i.type===`string`||i.type===`enum`)&&(r===we(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 R(e.meta||{}),r=Pe(await R(e.args||{})),i=await R(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([B(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([B(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([B(n),[e.negativeDescription,t?Me(`(Required)`):``].filter(Boolean).join(` `)])}t&&l.push(`--${e.name}`+We(e))}if(e.subCommands){let t=[],n=await R(e.subCommands);for(let[e,r]of Object.entries(n)){let n=await R((await R(r))?.meta);if(n?.hidden)continue;let i=L(n?.alias),a=[e,...i].join(`, `);c.push([B(a),n?.description||``]),t.push(e,...i)}l.push(t.join(`|`))}let u=[],d=n.version||i.version;u.push(Me(`${n.description} (${a+(d?` v${d}`:``)})`),``);let f=o.length>0||s.length>0;return u.push(`${V(je(`USAGE`))} ${B(`${a}${f?` [OPTIONS]`:``} ${l.join(` `)}`)}`,``),s.length>0&&(u.push(V(je(`ARGUMENTS`)),``),u.push(De(s,` `)),u.push(``)),o.length>0&&(u.push(V(je(`OPTIONS`)),``),u.push(De(o,` `)),u.push(``)),c.length>0&&(u.push(V(je(`COMMANDS`)),``),u.push(De(c,` `)),u.push(``,`Use ${B(`${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||`=<${Ee(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?Me(`(Required)`):``,r=e.default===void 0?``:Me(`(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 z(`No version specified`,`E_NO_VERSION`);console.log(t.version)}else await Ie(e,{rawArgs:n})}catch(t){t instanceof z?(await r(...await Le(e,n)),console.error(t.message)):console.error(t,`
5
- `),process.exit(1)}}async function qe(e){let t=await R(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 L(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.25`,Xe=`Commands to develop, bundle, and package Incarnative.js apps.`;function U(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 Ze(e){return e&&e.constructor&&typeof e.constructor.isBuffer==`function`&&e.constructor.isBuffer(e)}function Qe(e){return e}function $e(e,t){t||={};let n=t.delimiter||`.`,r=t.maxDepth,i=t.transformKey||Qe,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=Ze(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 et(e,t){t||={};let n=t.delimiter||`.`,r=t.overwrite||!1,i=t.transformKey||Qe,a={};if(Ze(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,$e(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]=et(e[s],t)}),a}const tt=/"(?:_|\\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*:/,nt=/"(?: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*:/,rt=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function it(e,t){if(e===`__proto__`||e===`constructor`&&t&&typeof t==`object`&&`prototype`in t)at(e);else return t}function at(e){console.warn(`[destr] Dropping "${e}" key to prevent prototype pollution.`)}function ot(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(!rt.test(e)){if(t.strict)throw SyntaxError(`[destr] Invalid JSON`);return e}try{if(tt.test(e)||nt.test(e)){if(t.strict)throw Error(`[destr] Possible prototype pollution`);return JSON.parse(e,it)}return JSON.parse(e)}catch(n){if(t.strict)throw n;return e}}function st(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 ct(e,t,n=`.`,r){if(!st(t))return ct(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]]:st(a)&&st(i[t])?ct(a,i[t],(n?`${n}.`:``)+t.toString(),r):a))}return i}function lt(e){return(...t)=>t.reduce((t,n)=>ct(t,n,``,e),{})}const W=lt(),ut=/^\s*([^\s=]+)\s*=\s*(.*)?\s*$/,dt=/\n|\r|\r\n/,ft={name:`.conf`,dir:process.cwd(),flat:!1};function pt(e){return typeof e==`string`&&(e={name:e}),{...ft,...e}}function mt(e,t={}){let n={},r=e.split(dt);for(let e of r){let t=e.match(ut);if(!t)continue;let r=t[1];if(!r||r===`__proto__`||r===`constructor`)continue;let i=ot((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:et(n,{overwrite:!0})}function ht(e,t){return h(e)?mt(_(e,`utf8`),t):{}}function gt(e){return e=pt(e),ht(S(e.dir,e.name),e)}function _t(){return process.env.XDG_CONFIG_HOME||S(P(),`.config`)}function vt(e){return e=pt(e),e.dir=_t(),gt(e)}async function yt(e){let t=e.env??process.env,n=await bt({cwd:e.cwd,fileName:e.fileName??`.env`,env:t,interpolate:e.interpolate??!0,expandFileReferences:e.expandFileReferences??!1,parse:e.parse}),r=Ot(t);for(let e in n)e.startsWith(`_`)||(t[e]===void 0||r.has(e))&&(t[e]=n[e]);return n}async function bt(e){let n=Object.create(null),r=t(e.cwd||`.`),i=e.fileName||`.env`,a=typeof i==`string`?[i]:i,o=Ot(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 St(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&&Ct(n),n}let xt=C.parseEnv;async function St(e,t){let n=_(e,`utf8`);if(t)return t(n);if(!xt)try{let e=await import(`dotenv`);xt=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 xt(n)}function Ct(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===`$`?Et(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 wt=/\w+/y,Tt=/[\w:]+/y;function Et(e,t){let n=t+1,r=e[n]===`{`;r&&n++;let i=r?Tt:wt;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?Dt(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 Dt(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 Ot(e){let t=globalThis.__c12_dotenv_vars__||=/* @__PURE__ */ new Map;return t.has(e)||t.set(e,/* @__PURE__ */ new Set),t.get(e)}const kt=e=>e?.replace(/\\/g,`/`);let At=0;const jt={".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)},Mt=Object.freeze([`.js`,`.ts`,`.mjs`,`.cjs`,`.mts`,`.cts`,`.json`,`.jsonc`,`.json5`,`.yaml`,`.yml`,`.toml`]);async function Nt(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||W,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 yt({cwd:e.cwd,...e.dotenv===!0?{}:e.dotenv});let a=await Lt(`.`,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(gt({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(gt({name:e.rcFile,dir:r})),t.push(vt({name:e.rcFile})),t.push(gt({name:e.rcFile,dir:P()}))}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 Pt(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 Rt(r.config,e.schema)),r}async function Pt(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 Lt(n,t,i);a.config?(await Pt(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 Ft=[`gh:`,`github:`,`gitlab:`,`bitbucket:`,`https://`,`http://`],It=/^(@[\da-z~-][\d._a-z~-]*\/)?[\da-z~-][\d._a-z~-]*($|\/.*)/;async function Lt(e,o,s={}){if(o.resolve){let t=await o.resolve(e,o);if(t)return t}let c=o.merger||W,l=Object.keys(s.giget?.providers||{}).map(e=>`${e}:`),u=l.length>0?[.../* @__PURE__ */ new Set([...l,...Ft])]:Ft;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(P(),`.cache/c12`,l);let p=s.install?W(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}It.test(e)&&(e=zt(e,o)||e);let d=n(e),f=Bt(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=zt(t(p,e),o)||zt(t(p,`.config`,e.replace(/\.config$/,``)),o)||zt(t(p,`.config`,e),o)||e,!h(m.configFile))return m;m._configFile=m.configFile;let g=n(m.configFile)||``;if(g in jt)m.config=(await jt[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=ie(m.configFile);t.search=`_${++At}`,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:[...Mt],...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=W(m.sourceOptions.meta,m.config.$meta),delete m.config.$meta,m.sourceOptions.overrides&&(m.config=c(m.sourceOptions.overrides,m.config)),m.configFile=kt(m.configFile),m.source=kt(m.source),m}async function Rt(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 zt(e,t){let n=s(e,{try:!0,from:ie(i(t.cwd||`.`,t.configFile||`/`)),suffixes:[``,`/index`],extensions:Mt,cache:!1});return n?o(n):void 0}function Bt(e){try{return y(e).isDirectory()}catch{return null}}var G=class extends Error{code;path;name=`IncaError`;constructor(e,t,n){super(t),this.code=e,this.path=n}},Vt=class extends Error{code;hostStack;constructor(e,t,n=null){super(e),this.code=t,this.hostStack=n,this.name=`HostError`}};const Ht={name:`inca`,packageJson:`inca`,rcFile:!1,globalRc:!1,giget:!1,extend:!1},Ut=[`.js`,`.ts`,`.mjs`,`.cjs`,`.mts`,`.cts`],Wt=/[/\\:*?"<>|\0]/;function Gt(e){return e===e.trim()&&e!==``&&e!==`.`&&e!==`..`&&!Wt.test(e)}function Kt(e){if(!(typeof e==`string`&&Gt(e)))throw new G(`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 qt=process.platform===`darwin`||process.platform===`win32`;function Jt(e,t){let n=e=>qt?e.toLowerCase():e,r=x.relative(n(e),n(t));return r===``||r!==`..`&&!r.startsWith(`..${x.sep}`)&&!x.isAbsolute(r)}function Yt(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 Xt(e,t,n){let r=x.resolve(e,t),i;try{let t=Yt(r);i=[e,x.join(e,`src`),x.join(e,`node_modules`),...n?[n]:[]].some(e=>Jt(t,Yt(e)))}catch{i=!0}if(i)throw new G(`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 Zt(e,t,n){let r=x.resolve(e,t??d.outDir);return Xt(e,r,n),r}function Qt(e,t){try{return JSON.parse(e)}catch(e){throw new G(`ERR_INCA_PACKAGE_JSON_INVALID`,`${t} holds malformed JSON: ${e.message}`,t)}}async function $t(e){let t=f(import.meta.url).cache;for(let n of Ut)delete t[x.join(e,`inca.config`+n)];let{config:n,layers:r}=await Nt({cwd:e,...Ht}),i=r?.find(e=>e.configFile===`package.json`);return{config:n,usedPackageJsonKey:Object.keys(i?.config??{}).length>0}}async function en(e){let{config:t}=await $t(e),n=t.entry?x.resolve(e,t.entry):void 0;return{entry:n,outDir:Zt(e,t.outDir,n),sourcemap:t.sourcemap??d.sourcemap}}function tn(e){return e.dev?.stackPaths??d.dev.stackPaths}async function nn(e){let t=x.join(e,`package.json`),n;try{n=await A(t,`utf8`)}catch{throw new G(`ERR_INCA_PACKAGE_JSON_NOT_FOUND`,`no package.json found at ${t}`)}let r=Qt(n,t),{config:i,usedPackageJsonKey:a}=await $t(e),o=i.productName??u(r.name);if(!o)throw new G(`ERR_INCA_PRODUCT_NAME_MISSING`,`${t} needs a "name", or "productName" in inca.config.ts`);Kt(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 G(`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=Zt(e,i.outDir,p);return{productName:o,identifier:c,identifierIsDefault:i.identifier===void 0,version:s,icon:f,window:i.window,dev:{stackPaths:tn(i)},entry:p,outDir:m,sourcemap:i.sourcemap??d.sourcemap,usedPackageJsonKey:a}}function rn(e,{dev:t=!1}={}){return{name:e.productName,identifier:e.identifier,window:e.window,...t&&{dev:{stackPaths:e.dev.stackPaths}}}}async function an(e,{dev:t=!1}={}){let{config:n}=await $t(e),r=x.join(e,`package.json`),i=await A(r,`utf8`).catch(()=>void 0),a=i===void 0?{}:Qt(i,r),o=n.productName??u(a.name);return o&&Kt(o),{name:o,identifier:n.identifier??(o?l(o):void 0),window:n.window,...t&&{dev:{stackPaths:tn(n)}}}}const on=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`numeric`,second:`numeric`}),K={timestamp:!0};function sn(e,t,n){let r=w([`bold`,n],`[inca]`,{stream:e});return t.timestamp?`${w(`dim`,on.format(/* @__PURE__ */ new Date),{stream:e})} ${r}`:r}function q(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 J(e){return e instanceof Vt?{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(`
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 ee,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 re}from"node:url";import{homedir as F}from"node:os";import{DevEnvironment as I,build as L,buildErrorMessage as ie,createServer as ae}from"vite";import oe from"@vitejs/plugin-vue";import{spawn as se,spawnSync as ce}from"node:child_process";import{once as le}from"node:events";import ue from"node:readline";import{setTimeout as de}from"node:timers/promises";import{createHash as fe,randomBytes as pe,randomUUID as me}from"node:crypto";import{brotliDecompressSync as he}from"node:zlib";const ge=/\d/,_e=[`-`,`_`,`/`,`.`];function ve(e=``){if(!ge.test(e))return e!==e.toLowerCase()}function ye(e,t){let n=t??_e,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=ve(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 be(e){return e?e[0].toUpperCase()+e.slice(1):``}function xe(e){return e?e[0].toLowerCase()+e.slice(1):``}function Se(e,t){return e?(Array.isArray(e)?e:ye(e)).map(e=>be(t?.normalize?e.toLowerCase():e)).join(``):``}function R(e,t){return xe(Se(e||``,t))}function Ce(e,t){return e?(Array.isArray(e)?e:ye(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=ee({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})(),H=(e,t=39)=>n=>De?n:`\u001B[${e}m${n}\u001B[${t}m`,U=/* @__PURE__ */ H(1,22),W=/* @__PURE__ */ H(36),Oe=/* @__PURE__ */ H(90),ke=/* @__PURE__ */ H(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=R(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[R(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: ${W(`--${e.name}`)} (${W(t)}). Expected one of: ${n.map(e=>W(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 ${W(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 ${W(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=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 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([W(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([W(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([W(n),[e.negativeDescription,t?Oe(`(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([W(a),n?.description||``]),t.push(e,...i)}l.push(t.join(`|`))}let u=[],d=n.version||i.version;u.push(Oe(`${n.description} (${a+(d?` v${d}`:``)})`),``);let f=o.length>0||s.length>0;return u.push(`${ke(U(`USAGE`))} ${W(`${a}${f?` [OPTIONS]`:``} ${l.join(` `)}`)}`,``),s.length>0&&(u.push(ke(U(`ARGUMENTS`)),``),u.push(Te(s,` `)),u.push(``)),o.length>0&&(u.push(ke(U(`OPTIONS`)),``),u.push(Te(o,` `)),u.push(``)),c.length>0&&(u.push(ke(U(`COMMANDS`)),``),u.push(Te(c,` `)),u.push(``,`Use ${W(`${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?Oe(`(Required)`):``,r=e.default===void 0?``:Oe(`(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.26`,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(F(),`.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:F()}))}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(F(),`.cache/c12`,l);let p=s.install?ct(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}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=re(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:re(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)}}}}const an=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`numeric`,second:`numeric`}),q={timestamp:!0};function on(e,t,n){let r=w([`bold`,n],`[inca]`,{stream:e});return t.timestamp?`${w(`dim`,an.format(/* @__PURE__ */ new Date),{stream:e})} ${r}`:r}function J(e,t,n={}){e.write(`${on(e,n,`cyan`)} ${t}\n`)}function sn(e,t,n={}){e.write(`${on(e,n,`yellow`)} ${t}\n`)}function cn(e){let t=e.code;return typeof t==`string`?t:null}function ln(e){return/\bERR_INCA_[A-Z0-9_]+/.exec(e)?.[0]??null}function un(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 dn(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:cn(e)}:e instanceof Error?{message:e.message,stack:un(e),code:cn(e)??ln(e.message)}:{message:String(e),stack:null,code:null}}function fn(e,t){return e.split(`
7
7
  `).map(e=>/^\s*at\b/.test(e)?w(`dim`,e,{stream:t}):e).join(`
8
- `)}function Y(e,t,n,r={}){n.stack&&e.write(`${pn(n.stack,e)}\n`);let i=n.code?` (${w(`bold`,n.code,{stream:e})})`:``;e.write(`${sn(e,r,`red`)} ${t}${i}: ${n.message}\n`)}var mn=/* @__PURE__ */ e({IncaError:()=>G,bundlerFault:()=>fn,withAppRoot:()=>U});function hn(e,t,n){return{outDir:e,entryFile:x.join(e,t.entryFile),files:t.files,changed:n}}function gn(e,t){return{name:`inca:capture-output`,writeBundle(n,r){let i=Object.keys(r),a=Object.values(r).find(e=>e.type===`chunk`&&e.isEntry);if(!a){let t=`ERR_INCA_BUILD_NO_ENTRY_CHUNK`;throw new e.IncaError(t,`${t}: build produced no entry chunk`)}t({entryFile:a.fileName,files:i})}}}const _n=`inca.json`;function vn(e){let t=JSON.stringify(e,void 0,2);return{name:`inca:emit-config`,generateBundle(){t!==void 0&&this.emitFile({type:`asset`,fileName:_n,source:`${t}\n`})}}}function yn(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 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(ie(`${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_STYLE`,name:`a <style> block`,matches:e=>e.includes(`vue&type=style`),hint:`the renderer applies no stylesheet. use a :style binding instead`},{code:`ERR_INCA_UNSUPPORTED_STYLESHEET`,name:`a stylesheet import`,matches:e=>wn.test(e),hint:`the renderer applies no stylesheet. use a :style binding instead`}];function En(e,t=Tn){return{name:`inca:reject-unsupported`,enforce:`pre`,transform(n,r){let i=t.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({core:e,frontend:t,frontendOptions: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:yn(f,p),define:{"process.env.NODE_ENV":JSON.stringify(c)},plugins:[se({template:{compilerOptions:{...n,hoistStatic:!1}}}),Cn(e,t),En(e),vn(h),gn(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 On(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 I(Dn({core:e,frontend:t,frontendOptions: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 kn(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(`
8
+ `)}function X(e,t,n,r={}){n.stack&&e.write(`${fn(n.stack,e)}\n`);let i=n.code?` (${w(`bold`,n.code,{stream:e})})`:``;e.write(`${on(e,r,`red`)} ${t}${i}: ${n.message}\n`)}var pn=/* @__PURE__ */ e({IncaError:()=>K,bundlerFault:()=>dn,withAppRoot:()=>Je});function mn(e,t,n){return{outDir:e,entryFile:x.join(e,t.entryFile),files:t.files,changed:n}}async function hn(e,t=``){let n;try{n=await j(e)}catch{return[]}return(await Promise.all(n.map(async n=>{let r=await N(x.join(e,n)).catch(()=>void 0);return r?r.isDirectory()?hn(x.join(e,n),`${t}${n}/`):[t+n]:[]}))).flat()}function gn(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 hn(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 _n=`inca.json`;function vn(e){let t=JSON.stringify(e,void 0,2);return{name:`inca:emit-config`,generateBundle(){t!==void 0&&this.emitFile({type:`asset`,fileName:_n,source:`${t}\n`})}}}function yn(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 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(re(`${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_STYLE`,name:`a <style> block`,matches:e=>e.includes(`vue&type=style`),hint:`the renderer applies no stylesheet. use a :style binding instead`},{code:`ERR_INCA_UNSUPPORTED_STYLESHEET`,name:`a stylesheet import`,matches:e=>wn.test(e),hint:`the renderer applies no stylesheet. use a :style binding instead`}];function En(e,t=Tn){return{name:`inca:reject-unsupported`,enforce:`pre`,transform(n,r){let i=t.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({core:e,frontend:t,frontendOptions: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:yn(f,p),define:{"process.env.NODE_ENV":JSON.stringify(c)},plugins:[oe({template:{compilerOptions:{...n,hoistStatic:!1}}}),Cn(e,t),En(e),vn(h),gn(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 On(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(Dn({core:e,frontend:t,frontendOptions: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=mn(s,e)}})),!p)throw new e.IncaError(`ERR_INCA_BUILD_NO_OUTPUT`,`build produced no output`);return p}function kn(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(`
9
9
  [ ]{${Math.min.apply(Math,r)}}`,`g`);n=n.map(function(e){return e.replace(i,`
10
10
  `)})}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(`
11
11
  `)&&(o=String(e).split(`
12
12
  `).map(function(e,t){return t===0?e:`${i}${e}`}).join(`
13
- `)),a+=o+n[t+1]}),a}function An(e,t){let n=ae(t,[],!1),r=[t.stack,n].filter(e=>e).join(`
14
- `);return{...e.bundlerFault(t.message),stack:r||null}}function X(e){return x.join(e,`node_modules/.inca/hmr`)}function jn(){let e=x.dirname(re(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 Mn(e,t){let n=x.relative(e,t).split(x.sep).join(`/`);return n.startsWith(`.`)?n:`./${n}`}const Nn=/^[A-Za-z_$][\w$]*$/;function Pn(e){let t={};for(let[n,r]of Object.entries(e??{}))if(Nn.test(n))try{t[n]=JSON.parse(typeof r==`string`?r:JSON.stringify(r))}catch{}return t}async function Fn(e,t,n,r){let i=X(e),a=x.join(i,`entry.js`),o=Mn(i,r??jn()),s=t.split(x.sep).join(`/`);return await N(a,kn`
13
+ `)),a+=o+n[t+1]}),a}function An(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 jn(e){return x.join(e,`node_modules/.inca/hmr`)}function Mn(){let e=x.dirname(ne(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 Nn(e,t){let n=x.relative(e,t).split(x.sep).join(`/`);return n.startsWith(`.`)?n:`./${n}`}const Pn=/^[A-Za-z_$][\w$]*$/;function Fn(e){let t={};for(let[n,r]of Object.entries(e??{}))if(Pn.test(n))try{t[n]=JSON.parse(typeof r==`string`?r:JSON.stringify(r))}catch{}return t}async function In(e,t,n,r){let i=jn(e),a=x.join(i,`entry.js`),o=Nn(i,r??Mn()),s=t.split(x.sep).join(`/`);return await P(a,kn`
15
15
  import { start } from ${JSON.stringify(o)};
16
16
  await start(${JSON.stringify(s)}, ${JSON.stringify(n)});
17
- `),a}function In(e){if(e.type===`error`)return e.err;if(e.type===`custom`&&e.event===`vite:invoke`)return e.data?.data?.error}function Ln(e){if(e.type!==`custom`||e.event!==`vite:invoke`)return!1;let t=e.data;return t.name===`fetchModule`&&!t.data?.error}function Rn(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=In(a);o?(n(o),i.current=void 0):Ln(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 zn(){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 Bn(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 Vn(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(X(s),{recursive:!0});let _=e.withAppRoot(c,s,X(s));await N(x.join(X(s),_n),`${JSON.stringify(_,void 0,2)}\n`);let v={current:void 0},{channel:y,dispatch:b}=Rn(p,m,t=>h(An(e,t)),g,v),S=await oe({configFile:!1,root:i,envDir:a,publicDir:o,mode:`development`,clearScreen:!1,logLevel:f?`silent`:`info`,customLogger:yn(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 F(e,t,{hot:!0,transport:y})}}},plugins:[se({template:{compilerOptions:{...n,hoistStatic:!1}}}),Cn(e,t),En(e),zn(),Bn(v)]}),C;try{C=await Fn(s,r,Pn(S.environments.client.config.define),l)}catch(e){throw await S.close(),e}return{entryFile:C,dispatch:b,close:()=>S.close()}}async function Hn(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 I(Dn({core:e,frontend:t,frontendOptions: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 Un(e,t,n){return{watch:r=>Hn(e,t,n,r),build:r=>On(e,t,n,r),hmr:r=>Vn(e,t,n,r)}}const Wn=Un(mn,[`incajs`,`vue`],{runtimeModuleName:`incajs/vue/runtime`}),Gn=[`main.mts`,`main.ts`,`main.js`];function Kn(e){return x.join(e,`node_modules/.inca/entry.mts`)}function qn(e,t){return t===Kn(e)?x.join(e,`src`):x.dirname(t)}function Jn(e){return Gn.map(t=>x.join(e,`src`,t)).find(e=>h(e))||(h(x.join(e,`src/App.vue`))?Kn(e):void 0)}async function Yn(e){let t=x.join(e,`src/App.vue`),n=Jn(e);if(n===Kn(e))return Xn(t,e);if(n)return n;throw new G(`ERR_INCA_ENTRY_NOT_FOUND`,`no app entry found. check that ${x.join(e,`src/main.ts`)} or ${t} exists`)}async function Xn(e,t){let n=Kn(t);await k(x.dirname(n),{recursive:!0});let r=JSON.stringify(e.split(x.sep).join(`/`));return await N(n,kn`
17
+ `),a}function Ln(e){if(e.type===`error`)return e.err;if(e.type===`custom`&&e.event===`vite:invoke`)return e.data?.data?.error}function Rn(e){if(e.type!==`custom`||e.event!==`vite:invoke`)return!1;let t=e.data;return t.name===`fetchModule`&&!t.data?.error}function zn(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=Ln(a);o?(n(o),i.current=void 0):Rn(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 Bn(){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 Vn(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 Hn(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(jn(s),{recursive:!0});let _=e.withAppRoot(c,s,jn(s));await P(x.join(jn(s),_n),`${JSON.stringify(_,void 0,2)}\n`);let v={current:void 0},{channel:y,dispatch:b}=zn(p,m,t=>h(An(e,t)),g,v),S=await ae({configFile:!1,root:i,envDir:a,publicDir:o,mode:`development`,clearScreen:!1,logLevel:f?`silent`:`info`,customLogger:yn(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 I(e,t,{hot:!0,transport:y})}}},plugins:[oe({template:{compilerOptions:{...n,hoistStatic:!1}}}),Cn(e,t),En(e),Bn(),Vn(v)]}),C;try{C=await In(s,r,Fn(S.environments.client.config.define),l)}catch(e){throw await S.close(),e}return{entryFile:C,dispatch:b,close:()=>S.close()}}async function Un(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(Dn({core:e,frontend:t,frontendOptions:n,...c,watch:!0,stdout:a,stderr:o,quiet:s,onOutput:e=>{r(mn(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 Wn(e,t,n){return{watch:r=>Un(e,t,n,r),build:r=>On(e,t,n,r),hmr:r=>Hn(e,t,n,r)}}const Gn=Wn(pn,[`incajs`,`vue`],{runtimeModuleName:`incajs/vue/runtime`}),Kn=[`main.mts`,`main.ts`,`main.js`];function qn(e){return x.join(e,`node_modules/.inca/entry.mts`)}function Jn(e,t){return t===qn(e)?x.join(e,`src`):x.dirname(t)}function Yn(e){return Kn.map(t=>x.join(e,`src`,t)).find(e=>h(e))||(h(x.join(e,`src/App.vue`))?qn(e):void 0)}async function Xn(e){let t=x.join(e,`src/App.vue`),n=Yn(e);if(n===qn(e))return Zn(t,e);if(n)return n;throw new K(`ERR_INCA_ENTRY_NOT_FOUND`,`no app entry found. check that ${x.join(e,`src/main.ts`)} or ${t} exists`)}async function Zn(e,t){let n=qn(t);await k(x.dirname(n),{recursive:!0});let r=JSON.stringify(e.split(x.sep).join(`/`));return await P(n,kn`
18
18
  import { createIncaApp } from "incajs/vue";
19
19
  import App from ${r};
20
20
  createIncaApp(App).mount();
21
- `),n}async function Zn(e={}){let t=e.cwd??process.cwd(),n=e.config??await en(t),r=x.resolve(t,n.outDir),i=e.bundler??Wn,a=e.entry??n.entry??await Yn(t);Xt(t,r,a);let o=e.runtimeConfig??await an(t);return i.build({entry:a,root:qn(t,a),envDir:t,publicDir:x.join(t,`public`),outDir:r,sourcemap:e.sourcemap??n.sourcemap,runtimeConfig:U(o,t,r),stdout:e.stdout,stderr:e.stderr})}const Qn=`bin/inca-host.br`,$n=/^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$/,er=[`darwin`,`linux`],tr=[`arm64`,`x64`];function nr(e=process.platform,t=process.arch){let n=er.find(t=>t===e),r=tr.find(e=>e===t);if(!n||!r)return;let i=`${n}-${r}`;return{key:i,name:`@incajs/host-${i}`}}function rr(e){try{return x.dirname(f(import.meta.url).resolve(`${e}/package.json`))}catch{return}}function Z(e,t){return new G(`ERR_INCA_HOST_PACKAGE_CORRUPT`,`the host package ${e} is damaged: ${t}. reinstall it`)}async function ir(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`||!$n.test(a))throw Z(e,`invalid version`);return{name:e,dir:t,version:a,sha256:i}}const ar=`INCA_CACHE_DIR`,or=`inca-host`;function sr(e){return pe(`sha256`).update(e).digest(`hex`)}function cr(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 lr(e,t,n,r){let i=[],a=e[ar];a&&i.push({dir:x.resolve(a)});let o=cr(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 ur(e,t){try{return sr(await A(e))===t&&(await T(e,m.X_OK),!0)}catch{return!1}}async function dr(e){let t;try{t=ge(await A(x.join(e.dir,Qn)))}catch(t){throw Z(e.name,`${Qn} can't be unpacked (${t.message})`)}if(sr(t)!==e.sha256)throw Z(e.name,`verification failed`);return t}async function fr(e,t){let n=`${e}.tmp-${process.pid}-${me(4).toString(`hex`)}`;try{await k(x.dirname(e),{recursive:!0,mode:448}),await N(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 pr(e,t,n){let r=RegExp(`^${t}@${$n.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 ne(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 mr(e){try{return(await ne(e)).isDirectory()}catch{return!1}}async function hr(e,t,n,r){let i=`${t}@${e.version}`;for(let t of n){let n=x.join(t.dir,i,or);if(await ur(n,e.sha256))return n}let a;for(let o of n){if(o.mustExist&&!await mr(o.mustExist))continue;a??=await dr(e);let n=x.join(o.dir,i,or);try{await fr(n,a)}catch{continue}return q(r,`unpacked the host binary into ${x.dirname(n)}`),await pr(o.dir,t,i),n}throw new G(`ERR_INCA_HOST_UNPACK_FAILED`,`failed to unpack the host binary because no usable directory was found to unpack into. set ${ar} to a writable directory that allows running programs`)}async function gr(){let e=nr();if(!e)return{state:`unsupported`};let t=rr(e.name);if(!t)return{state:`notInstalled`,target:e};try{let n=await ir(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 _r=`INCA_HOST_BIN`;function vr(){try{return P()}catch{return}}async function Q(e=process.cwd(),t=process.stderr){let n=process.env[_r];if(n)return n;let r=await gr();if(r.state===`installed`){let n=lr(process.env,process.platform,vr(),e);return hr(r.pkg,r.target.key,n,t)}throw r.state===`corrupt`?r.error:new G(`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 ${_r} to the path of a host binary to use your own`)}async function $(e){if(!(await ne(e).catch(()=>void 0))?.isFile())throw new G(`ERR_INCA_HOST_BIN_NOT_FOUND`,`no host binary at ${e}. check that it was built`)}function yr(e){return typeof e==`object`&&!!e&&e.jsonrpc===`2.0`}const br=e=>{process.stderr.write(e.endsWith(`
22
- `)?e:`${e}\n`)};var xr=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??br;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(!yr(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 Vt(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 Sr(e){return x.join(e,`node_modules/.inca/dev.pid`)}function Cr(e){try{return process.kill(e,0),!0}catch(e){return e.code===`EPERM`}}const wr=he();function Tr(e){return new G(`ERR_INCA_DEV_RUNNING`,`inca dev is already running for this app (pid ${String(e)})`)}async function Er(e){let t=Sr(e),n=`${String(process.pid)}:${wr}`,r=`${t}.${he()}`;await k(x.dirname(t),{recursive:!0}),await N(r,n);let i=process.pid;try{for(let e=0;e<5;e++){try{return await O(r,t),Dr(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 Tr(a)}else if(Number.isSafeInteger(a)&&a>0&&Cr(a))throw Tr(a);i=Number.isSafeInteger(a)&&a>0?a:i,await M(t,{force:!0})}throw Tr(i)}finally{await M(r,{force:!0})}}function Dr(e,t){let n=!1;return async()=>{n||(n=!0,await A(e,`utf8`).catch(()=>``)===t&&await M(e,{force:!0}))}}function Or(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`)}function kr(e){return typeof e==`boolean`?e?`<true/>`:`<false/>`:`<string>${Or(e)}</string>`}function Ar(e){return kn`
21
+ `),n}async function Qn(e={}){let t=e.cwd??process.cwd(),n=e.config??await $t(t),r=x.resolve(t,n.outDir),i=e.bundler??Gn,a=e.entry??n.entry??await Xn(t);Yt(t,r,a);let o=e.runtimeConfig??await rn(t);return i.build({entry:a,root:Jn(t,a),envDir:t,publicDir:x.join(t,`public`),outDir:r,sourcemap:e.sourcemap??n.sourcemap,runtimeConfig:Je(o,t,r),stdout:e.stdout,stderr:e.stderr})}const $n=`bin/inca-host.br`,er=/^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$/,tr=[`darwin`,`linux`],nr=[`arm64`,`x64`];function rr(e=process.platform,t=process.arch){let n=tr.find(t=>t===e),r=nr.find(e=>e===t);if(!n||!r)return;let i=`${n}-${r}`;return{key:i,name:`@incajs/host-${i}`}}function ir(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 ar(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`||!er.test(a))throw Z(e,`invalid version`);return{name:e,dir:t,version:a,sha256:i}}const or=`INCA_CACHE_DIR`,sr=`inca-host`;function cr(e){return fe(`sha256`).update(e).digest(`hex`)}function lr(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 ur(e,t,n,r){let i=[],a=e[or];a&&i.push({dir:x.resolve(a)});let o=lr(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 dr(e,t){try{return cr(await A(e))===t&&(await T(e,m.X_OK),!0)}catch{return!1}}async function fr(e){let t;try{t=he(await A(x.join(e.dir,$n)))}catch(t){throw Z(e.name,`${$n} can't be unpacked (${t.message})`)}if(cr(t)!==e.sha256)throw Z(e.name,`verification failed`);return t}async function pr(e,t){let n=`${e}.tmp-${process.pid}-${pe(4).toString(`hex`)}`;try{await k(x.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 mr(e,t,n){let r=RegExp(`^${t}@${er.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 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 hr(e){try{return(await N(e)).isDirectory()}catch{return!1}}async function gr(e,t,n,r){let i=`${t}@${e.version}`;for(let t of n){let n=x.join(t.dir,i,sr);if(await dr(n,e.sha256))return n}let a;for(let o of n){if(o.mustExist&&!await hr(o.mustExist))continue;a??=await fr(e);let n=x.join(o.dir,i,sr);try{await pr(n,a)}catch{continue}return J(r,`unpacked the host binary into ${x.dirname(n)}`),await mr(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 ${or} to a writable directory that allows running programs`)}async function _r(){let e=rr();if(!e)return{state:`unsupported`};let t=ir(e.name);if(!t)return{state:`notInstalled`,target:e};try{let n=await ar(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 vr=`INCA_HOST_BIN`;function yr(){try{return F()}catch{return}}async function Q(e=process.cwd(),t=process.stderr){let n=process.env[vr];if(n)return n;let r=await _r();if(r.state===`installed`){let n=ur(process.env,process.platform,yr(),e);return gr(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 ${vr} to the path of a host binary to use your own`)}async function $(e){if(!(await N(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 br=[`NOTICE`,`LICENSE-MIT`,`LICENSE-APACHE`];async function xr(e){if(e!==void 0||process.env.INCA_HOST_BIN)return[];let t=await _r();return t.state===`installed`?(await Promise.all(br.map(async e=>{let n=x.join(t.pkg.dir,e);return(await N(n).catch(()=>void 0))?.isFile()?n:void 0}))).filter(e=>e!==void 0):[]}function Sr(e){return typeof e==`object`&&!!e&&e.jsonrpc===`2.0`}const Cr=e=>{process.stderr.write(e.endsWith(`
22
+ `)?e:`${e}\n`)};var wr=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=se(e,[`--dev`,this.#e.entryFile],{stdio:[`pipe`,`pipe`,`pipe`],env:this.#e.env});this.#t=t;let n=this.#e.onStderr??Cr;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`)}),ue.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 le(t,`spawn`),r=!0}#a(e,t){let n;try{n=JSON.parse(e)}catch{t(`[stray stdout] ${e}`);return}if(!Sr(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=le(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=le(t,`exit`);this.call(`shutdown`).catch(()=>{}),await Promise.race([n.then(()=>`exited`),de(e,void 0,{ref:!1}).then(()=>`timeout`)])===`timeout`&&(t.kill(),await n)}};function Tr(e){return x.join(e,`node_modules/.inca/dev.pid`)}function Er(e){try{return process.kill(e,0),!0}catch(e){return e.code===`EPERM`}}const Dr=me();function Or(e){return new K(`ERR_INCA_DEV_RUNNING`,`inca dev is already running for this app (pid ${String(e)})`)}async function kr(e){let t=Tr(e),n=`${String(process.pid)}:${Dr}`,r=`${t}.${me()}`;await k(x.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),Ar(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 Or(a)}else if(Number.isSafeInteger(a)&&a>0&&Er(a))throw Or(a);i=Number.isSafeInteger(a)&&a>0?a:i,await M(t,{force:!0})}throw Or(i)}finally{await M(r,{force:!0})}}function Ar(e,t){let n=!1;return async()=>{n||(n=!0,await A(e,`utf8`).catch(()=>``)===t&&await M(e,{force:!0}))}}function jr(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`)}function Mr(e){return typeof e==`boolean`?e?`<true/>`:`<false/>`:`<string>${jr(e)}</string>`}function Nr(e){return kn`
23
23
  <?xml version="1.0" encoding="UTF-8"?>
24
24
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
25
25
  <plist version="1.0">
26
26
  <dict>
27
- ${Object.entries(e).map(([e,t])=>`\t<key>${Or(e)}</key>\n\t${kr(t)}`).join(`
27
+ ${Object.entries(e).map(([e,t])=>`\t<key>${jr(e)}</key>\n\t${Mr(t)}`).join(`
28
28
  `)}
29
29
  </dict>
30
30
  </plist>
31
- `}async function jr(e){let{appPath:t,metadata:n,hostBin:r}=e;await M(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 N(x.join(i,`Info.plist`),Ar(c)),await N(x.join(i,`PkgInfo`),`APPL????`),{appPath:t,executablePath:s,resourcesDir:o}}const Mr={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 Nr(e){return typeof e==`number`?`a number`:typeof e==`string`?`a string`:typeof e==`boolean`?`true or false`:`an object`}function Pr(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=Mr[u];if(!d)return;let f=s.reduce((e,t)=>e?.[t],n),p=Nr(f)===d?`the host can't use it`:`it must be ${d}`;return new G(`ERR_INCA_CONFIG_INVALID`,`${u} in inca.config.ts is ${JSON.stringify(f)}. ${p}`)}function Fr(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=Pr(i.stderr,n,r);if(e)throw e}return i}function Ir(e,t){let n=x.join(x.dirname(t),`inca.json`),r={};try{r=JSON.parse(_(n,`utf8`))}catch{}let i=Fr(e,t,n,r);if(i.status===null)throw new G(`ERR_INCA_HOST_EXITED_EARLY`,`the host exited with signal ${String(i.signal)} before it read the config`);if(i.status!==0)throw new G(`ERR_INCA_CONFIG_INVALID`,`the host can't read ${n}. it reported "${i.stderr.split(`
33
- `)[0]??``}"`)}async function Lr(e,t){let n;try{n=await Q(process.cwd(),t),await $(n)}catch(e){if(e instanceof G&&(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 G&&e.code===`ERR_INCA_HOST_UNPACK_FAILED`){cn(t,`failed to unpack the host binary, so the config was not checked`);return}throw e}Ir(n,e)}async function Rr(e={}){let t=e.cwd??process.cwd(),n=e.hostBin??await Q(t,e.stderr);await $(n);let r=await an(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 N(a,``),await N(o,JSON.stringify(U(r,t,i),void 0,2));let s=Fr(n,a,o,r);return(e.stdout??process.stdout).write(s.stdout),(e.stderr??process.stderr).write(s.stderr),s.status??1}const zr=/^(?:inca\.config\.[a-z0-9]+|package\.json)$/,Br=[...Gn,`App.vue`];function Vr(e,t={}){let n=t.debounceMs??100,r=/* @__PURE__ */ new Set,i,a=!1,o=()=>{},s=new Promise(e=>{o=e}),c=()=>{a||(clearTimeout(i),i=setTimeout(o,n),i.unref())},l=(e,t)=>{let n=e;for(let e;!h(n)&&(e=x.dirname(n))!==n;)n=e;let i=n===e?void 0:x.relative(n,e).split(x.sep)[0],a=b(n);a.on(`change`,(e,n)=>{let r=n===null?null:String(n);(r===null||(i===void 0?t(r):r===i))&&c()}),a.on(`error`,()=>{a.close(),r.delete(a),c()}),r.add(a)},u=()=>{a=!0,clearTimeout(i);for(let e of r)e.close();r.clear()};try{l(e,e=>e===`src`||zr.test(e)),l(x.join(e,`src`),e=>Br.includes(e))}catch(e){throw u(),e}return{edited:s,add(e){if(a)return;let t=x.resolve(e);l(x.dirname(t),e=>e===x.basename(t))},close:u}}function Hr(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 Ur(e){let{cwd:t,signal:n,stdout:r,stderr:i,debounceMs:a}=e,o=!1;for(;;){let s=Vr(t,{debounceMs:a});try{return await e.attempt(s)}catch(e){let t=e instanceof G?e.path:void 0;if(t)try{s.add(t)}catch(t){throw Y(i,`build failed`,J(e),K),t}if(!n.aborted&&!o&&t&&h(t)){o=!0;continue}if(o=!1,Y(i,`build failed`,J(e),K),n.aborted||(q(r,`waiting for a change to retry`,K),!await Hr(s.edited,n)))return;q(r,`retrying`,K)}finally{s.close()}}}const Wr=[`ERR_INCA_PACKAGE_JSON_NOT_FOUND`,`ERR_INCA_PRODUCT_NAME_MISSING`];async function Gr(e,t){try{return await nn(e)}catch(e){if(!(e instanceof G)||!Wr.includes(e.code))throw e;q(t,`running unnamed. ${e.message}`,K);return}}async function Kr(e,t,n,r){if(process.platform===`darwin`&&t)try{return(await jr({appPath:x.join(e,`node_modules/.inca`,`${t.productName}.app`),metadata:t,hostBin:n,link:!0})).executablePath}catch(e){q(r,`running unbundled. ${J(e).message}`,K);return}}async function qr(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=>M(x.join(e,t),{force:!0})))}function Jr(e){let{NO_COLOR:t,FORCE_COLOR:n}=process.env;if(!(!e.isTTY||t||n))return{...process.env,FORCE_COLOR:`1`}}async function Yr(e){let t=e.cwd??process.cwd(),n=await Er(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??Wn,d=e.experimentalHmr?u.hmr?.bind(u):void 0;if(e.experimentalHmr&&!d)throw new G(`ERR_INCA_HMR_UNSUPPORTED`,`--experimental-hmr was set, but the configured bundler has no HMR support`);let f=await Ur({cwd:t,signal:e.signal,stdout:n,stderr:c,async attempt(){let r=await en(t),i=x.resolve(t,r.outDir),a=e.entry===void 0&&r.entry===void 0,o=e.entry??r.entry??await Yn(t);Xt(t,i,o);let s=await Gr(t,n);return{outDir:i,entry:o,automaticEntry:a,metadata:s,runtimeConfig:s?rn(s,{dev:!0}):await an(t,{dev:!0})}}});if(!f)return;let{outDir:p,entry:m,automaticEntry:h,metadata:g,runtimeConfig:_}=f,v=await Kr(t,g,l,n)??l,y,b,S=!1,C=!1,ee=!1,T,E=Promise.resolve(),D,O=0,k=!1,A;async function j(){try{return await y?.call(`reload`,void 0,1e4),!0}catch(e){return Y(c,`reload failed`,J(e),K),!1}}function te(e){if(!e)return;let r=w(`dim`,x.relative(t,e.file),{stream:n}),i=Date.now()-e.at;q(n,`${w(`green`,`reload`)} ${r} (${i}ms)`,K)}async function M(t,a){if(i)return;try{Ir(v,t)}catch(e){e instanceof G&&e.code===`ERR_INCA_CONFIG_INVALID`?(b=e,r()):Y(c,`failed to start the host`,J(e),K);return}let o=new xr({entryFile:t,hostBin:v,signal:e.signal,env:Jr(c),onStderr:e=>c.write(e),onReady:()=>{S=!0,q(n,`ready`,K),C&&(C=!1,j())},onAppError:e=>Y(c,`app error`,e,K),onExit:(e,t)=>{ee=!S,T={code:e,signal:t},q(n,`host exited. stopping`,K),r()},integrations:a});try{await o.start()}catch(e){Y(c,`failed to start the host`,J(e),K);return}y=o}async function ne(e){await qr(e.outDir,e.files),y?S?await j()&&te(e.changed):C=!0:await M(e.entryFile)}async function N(e){Xt(t,p,e);let a=++O,o=()=>a===O&&!i,s=e=>(...t)=>{o()&&e(...t)},l;if(d){let i=await d({entry:e,root:qn(t,e),envDir:t,publicDir:x.join(t,`public`),cwd:t,runtimeConfig:_,stdout:n,stderr:c,notify:s(e=>y?.notify(`vite`,e)),reload:s(e=>{S?j().then(t=>{t&&te(e)}):C=!0}),onError:s(e=>Y(c,`build failed`,e,K)),onUpdate:s(({file:e,took:r})=>{if(!S)return;let i=w(`dim`,x.relative(t,e),{stream:n});q(n,`${w(`green`,`update`)} ${i} (${r}ms)`,K)})});A=e=>i.dispatch(e),l={close:()=>(A=void 0,i.close())},y?S?await j():C=!0:(await M(i.entryFile,{vite:e=>A?.(e)}),y||r())}else l=await u.watch({entry:e,root:qn(t,e),envDir:t,publicDir:x.join(t,`public`),outDir:p,runtimeConfig:U(_,t,p),mode:`development`,stdout:n,stderr:c,onBuild:e=>{E=E.then(()=>o()?ne(e):void 0)},onError:s(e=>{Y(c,`build failed`,e,K)})});return{entry:e,async close(){O++,await l.close()}}}async function re(){let e=D;D=void 0,await e?.close()}async function ie(){if(i)return;let e=Jn(t);if(e===void 0||e!==D?.entry)try{e===void 0&&await re();let n=await Yn(t);if(k=!1,await re(),i)return;D=await N(n)}catch(t){k||Y(c,`build failed`,J(t),K),k=e===void 0}}async function P(e){let n=e;for(;await Promise.race([a.then(()=>!1),n.edited.then(()=>!0)]);)n.close(),n=o=Vr(t),E=E.then(ie),await E}let F=m;if(h){o=Vr(t);try{F=await Yn(t)}catch(e){F=void 0,k=!0,Y(c,`build failed`,J(e),K)}}F!==void 0&&(D=await N(F)),o&&(s=P(o).then(()=>void 0,e=>(r(),{error:e}))),await a;let I=await s;if(await D?.close(),await E,await y?.stop(),I)throw I.error;if(b)throw b;if(ee)throw new G(`ERR_INCA_HOST_EXITED_EARLY`,`the host exited before it was ready`);if(T&&T.code!==0&&T.signal!==`SIGINT`&&T.signal!==`SIGTERM`){let{code:e,signal:t}=T;throw new G(`ERR_INCA_HOST_CRASHED`,`the host exited with ${t?`signal ${t}`:`code ${e}`}`)}}finally{r(),await s,o?.close(),await n()}}async function Xr(){let e=await gr();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 Zr(e,t){let n=await Q(e,t);return await $(n),n}async function Qr(e){try{return await e()}catch(e){if(!(e instanceof G))throw e;return`unavailable (${e.code.replace(/^ERR_INCA_HOST_/,``).toLowerCase().replaceAll(`_`,` `)})`}}async function $r(e=process.stdout,t=process.cwd(),n=process.stderr){let r=[[`Incarnative.js:`,Ye],[`host package:`,await Qr(Xr)],[`host binary:`,await Qr(()=>Zr(t,n))]],i=Math.max(...r.map(([e])=>e.length))+1;e.write(r.map(([e,t])=>`${e.padEnd(i)}${t}\n`).join(``))}function ei(){if(process.platform===`darwin`)return`macos`;if(process.platform===`linux`)return`linux`;throw new G(`ERR_INCA_PLATFORM_UNSUPPORTED`,`inca package doesn't support ${process.platform} yet`)}async function ti(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 ni(e,t){let n=e.files.map(e=>e.split(`/`)[0]??e).find(e=>e.toLowerCase()===t.toLowerCase());if(n!==void 0)throw new G(`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`)}async function ri({metadata:e,output:t,hostBin:n}){let{appPath:r,resourcesDir:i}=await jr({appPath:x.join(t.outDir,`${e.productName}.app`),metadata:e,hostBin:n});return await ti(t,i),r}async function ii({metadata:e,output:t,hostBin:n}){let r=c(e.productName);ni(t,r);let i=x.join(t.outDir,r);await M(i,{recursive:!0,force:!0}),await k(i,{recursive:!0});let a=x.join(i,r);return await D(n,a),await E(a,493),await ti(t,i),i}async function ai(e={}){let t=e.cwd??process.cwd(),n=e.stdout??process.stdout,r=e.target??ei(),i=await nn(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 Zn({cwd:t,entry:e.entry,config:i,sourcemap:e.sourcemap,runtimeConfig:rn(i),bundler:e.bundler,stdout:n,stderr:e.stderr}),o=e.hostBin??await Q(t,e.stderr);await $(o),Ir(o,a.entryFile);let s={metadata:i,output:a,hostBin:o};return{appPath:r===`macos`?await ri(s):await ii(s)}}function oi(e){return x.relative(process.cwd(),e)}const si={type:`boolean`,description:`Write a source map`,negativeDescription:`Skip the source map`};function ci(){for(let e of[0,1,2])try{p.closeSync(e)}catch{}}const li=H({meta:{name:`build`,description:`Bundle the app into dist`},args:{sourcemap:si},async run({args:e}){try{let t=await Zn({sourcemap:e.sourcemap});await Lr(t.entryFile,process.stderr),q(process.stdout,`built ${oi(t.entryFile)}`)}catch(e){Y(process.stderr,`build failed`,J(e)),process.exitCode=1}}}),ui=H({meta:{name:`package`,description:`Package the app as an application bundle`},args:{sourcemap:si},async run({args:e}){try{let{appPath:t}=await ai({sourcemap:e.sourcemap});q(process.stdout,`packaged ${oi(t)}`)}catch(e){Y(process.stderr,`package failed`,J(e)),process.exitCode=1}}}),di=H({meta:{name:`config`,description:`Print the settings the host applies to the app`},async run(){try{process.exitCode=await Rr()}catch(e){Y(process.stderr,`config failed`,J(e)),process.exitCode=1}}}),fi=H({meta:{name:`info`,description:`Print the versions and the host binary in use`},async run(){try{await $r()}catch(e){Y(process.stderr,`info failed`,J(e)),process.exitCode=1}}}),pi=H({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||(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 Yr({signal:t.signal,experimentalHmr:r}),t.signal.aborted&&ci()}catch(e){Y(process.stderr,`dev failed`,J(e),{timestamp:!0}),process.exitCode=1}}}),mi=H({meta:{name:`inca`,version:Ye,description:Xe},subCommands:{dev:pi,build:li,package:ui,config:di,info:fi}});async function hi(e=process.argv){await Ke(mi,{rawArgs:e.slice(2)})}export{hi as run};
31
+ `}async function Pr(e){let{appPath:t,metadata:n,hostBin:r}=e;await M(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 P(x.join(i,`Info.plist`),Nr(c)),await P(x.join(i,`PkgInfo`),`APPL????`),{appPath:t,executablePath:s,resourcesDir:o}}const Fr={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 Ir(e){return typeof e==`number`?`a number`:typeof e==`string`?`a string`:typeof e==`boolean`?`true or false`:`an object`}function Lr(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=Fr[u];if(!d)return;let f=s.reduce((e,t)=>e?.[t],n),p=Ir(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 Rr(e,t,n,r){let i=ce(e,[`--print-config`,t],{encoding:`utf8`});if(i.error)throw i.error;if(i.status!==0){let e=Lr(i.stderr,n,r);if(e)throw e}return i}function zr(e,t){let n=x.join(x.dirname(t),`inca.json`),r={};try{r=JSON.parse(_(n,`utf8`))}catch{}let i=Rr(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 Br(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`)){sn(t,`no host binary found, so the config was not checked`);return}if(e instanceof K&&e.code===`ERR_INCA_HOST_UNPACK_FAILED`){sn(t,`failed to unpack the host binary, so the config was not checked`);return}throw e}zr(n,e)}async function Vr(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 P(a,``),await P(o,JSON.stringify(Je(r,t,i),void 0,2));let s=Rr(n,a,o,r);return(e.stdout??process.stdout).write(s.stdout),(e.stderr??process.stderr).write(s.stderr),s.status??1}const Hr=/^(?:inca\.config\.[a-z0-9]+|package\.json)$/,Ur=[...Kn,`App.vue`];function Wr(e,t={}){let n=t.debounceMs??100,r=/* @__PURE__ */ new Set,i,a=!1,o=()=>{},s=new Promise(e=>{o=e}),c=()=>{a||(clearTimeout(i),i=setTimeout(o,n),i.unref())},l=(e,t)=>{let n=e;for(let e;!h(n)&&(e=x.dirname(n))!==n;)n=e;let i=n===e?void 0:x.relative(n,e).split(x.sep)[0],a=b(n);a.on(`change`,(e,n)=>{let r=n===null?null:String(n);(r===null||(i===void 0?t(r):r===i))&&c()}),a.on(`error`,()=>{a.close(),r.delete(a),c()}),r.add(a)},u=()=>{a=!0,clearTimeout(i);for(let e of r)e.close();r.clear()};try{l(e,e=>e===`src`||Hr.test(e)),l(x.join(e,`src`),e=>Ur.includes(e))}catch(e){throw u(),e}return{edited:s,add(e){if(a)return;let t=x.resolve(e);l(x.dirname(t),e=>e===x.basename(t))},close:u}}function Gr(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 Kr(e){let{cwd:t,signal:n,stdout:r,stderr:i,debounceMs:a}=e,o=!1;for(;;){let s=Wr(t,{debounceMs:a});try{return await e.attempt(s)}catch(e){let t=e instanceof K?e.path:void 0;if(t)try{s.add(t)}catch(t){throw X(i,`build failed`,Y(e),q),t}if(!n.aborted&&!o&&t&&h(t)){o=!0;continue}if(o=!1,X(i,`build failed`,Y(e),q),n.aborted||(J(r,`waiting for a change to retry`,q),!await Gr(s.edited,n)))return;J(r,`retrying`,q)}finally{s.close()}}}const qr=[`ERR_INCA_PACKAGE_JSON_NOT_FOUND`,`ERR_INCA_PRODUCT_NAME_MISSING`];async function Jr(e,t){try{return await tn(e)}catch(e){if(!(e instanceof K)||!qr.includes(e.code))throw e;J(t,`running unnamed. ${e.message}`,q);return}}async function Yr(e,t,n,r){if(process.platform===`darwin`&&t)try{return(await Pr({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 Xr(e){return x.join(e,`node_modules/.inca/dev`)}async function Zr(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=>M(x.join(e,t),{force:!0})))}function Qr(e){let{NO_COLOR:t,FORCE_COLOR:n}=process.env;if(!(!e.isTTY||t||n))return{...process.env,FORCE_COLOR:`1`}}async function $r(e){let t=e.cwd??process.cwd(),n=await kr(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??Gn,d=e.experimentalHmr?u.hmr?.bind(u):void 0;if(e.experimentalHmr&&!d)throw new K(`ERR_INCA_HMR_UNSUPPORTED`,`--experimental-hmr was set, but the configured bundler has no HMR support`);let f=await Kr({cwd:t,signal:e.signal,stdout:n,stderr:c,async attempt(){let r=await $t(t),i=e.entry===void 0&&r.entry===void 0,a=e.entry??r.entry??await Xn(t),o=await Jr(t,n);return{entry:a,automaticEntry:i,metadata:o,runtimeConfig:o?nn(o,{dev:!0}):await rn(t,{dev:!0})}}});if(!f)return;let{entry:p,automaticEntry:m,metadata:h,runtimeConfig:g}=f,_=Xr(t),v=await Yr(t,h,l,n)??l,y,b,S=!1,C=!1,ee=!1,T,E=Promise.resolve(),D,O=0,k=!1,A;async function j(){try{return await y?.call(`reload`,void 0,1e4),!0}catch(e){return X(c,`reload failed`,Y(e),q),!1}}function te(e){if(!e)return;let r=w(`dim`,x.relative(t,e.file),{stream:n}),i=Date.now()-e.at;J(n,`${w(`green`,`reload`)} ${r} (${i}ms)`,q)}async function M(t,a){if(i)return;try{zr(v,t)}catch(e){e instanceof K&&e.code===`ERR_INCA_CONFIG_INVALID`?(b=e,r()):X(c,`failed to start the host`,Y(e),q);return}let o=new wr({entryFile:t,hostBin:v,signal:e.signal,env:Qr(c),onStderr:e=>c.write(e),onReady:()=>{S=!0,J(n,`ready`,q),C&&(C=!1,j())},onAppError:e=>X(c,`app error`,e,q),onExit:(e,t)=>{ee=!S,T={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}y=o}async function N(e){await Zr(e.outDir,e.files),y?S?await j()&&te(e.changed):C=!0:await M(e.entryFile)}async function P(e){let a=++O,o=()=>a===O&&!i,s=e=>(...t)=>{o()&&e(...t)},l;if(d){let i=await d({entry:e,root:Jn(t,e),envDir:t,publicDir:x.join(t,`public`),cwd:t,runtimeConfig:g,stdout:n,stderr:c,notify:s(e=>y?.notify(`vite`,e)),reload:s(e=>{S?j().then(t=>{t&&te(e)}):C=!0}),onError:s(e=>X(c,`build failed`,e,q)),onUpdate:s(({file:e,took:r})=>{if(!S)return;let i=w(`dim`,x.relative(t,e),{stream:n});J(n,`${w(`green`,`update`)} ${i} (${r}ms)`,q)})});A=e=>i.dispatch(e),l={close:()=>(A=void 0,i.close())},y?S?await j():C=!0:(await M(i.entryFile,{vite:e=>A?.(e)}),y||r())}else l=await u.watch({entry:e,root:Jn(t,e),envDir:t,publicDir:x.join(t,`public`),outDir:_,runtimeConfig:Je(g,t,_),mode:`development`,stdout:n,stderr:c,onBuild:e=>{E=E.then(()=>o()?N(e):void 0)},onError:s(e=>{X(c,`build failed`,e,q)})});return{entry:e,async close(){O++,await l.close()}}}async function ne(){let e=D;D=void 0,await e?.close()}async function re(){if(i)return;let e=Yn(t);if(e===void 0||e!==D?.entry)try{e===void 0&&await ne();let n=await Xn(t);if(k=!1,await ne(),i)return;D=await P(n)}catch(t){k||X(c,`build failed`,Y(t),q),k=e===void 0}}async function F(e){let n=e;for(;await Promise.race([a.then(()=>!1),n.edited.then(()=>!0)]);)n.close(),n=o=Wr(t),E=E.then(re),await E}let I=p;if(m){o=Wr(t);try{I=await Xn(t)}catch(e){I=void 0,k=!0,X(c,`build failed`,Y(e),q)}}I!==void 0&&(D=await P(I)),o&&(s=F(o).then(()=>void 0,e=>(r(),{error:e}))),await a;let L=await s;if(await D?.close(),await E,await y?.stop(),L)throw L.error;if(b)throw b;if(ee)throw new K(`ERR_INCA_HOST_EXITED_EARLY`,`the host exited before it was ready`);if(T&&T.code!==0&&T.signal!==`SIGINT`&&T.signal!==`SIGTERM`){let{code:e,signal:t}=T;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 ei(){let e=await _r();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 ti(e,t){let n=await Q(e,t);return await $(n),n}async function ni(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 ri(e=process.stdout,t=process.cwd(),n=process.stderr){let r=[[`Incarnative.js:`,Ke],[`host package:`,await ni(ei)],[`host binary:`,await ni(()=>ti(t,n))]],i=Math.max(...r.map(([e])=>e.length))+1;e.write(r.map(([e,t])=>`${e.padEnd(i)}${t}\n`).join(``))}function ii(){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 ai(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 oi(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 si(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 ci(e,t){await Promise.all(e.map(e=>D(e,x.join(t,x.basename(e)))))}async function li({metadata:e,output:t,hostBin:n,licenseFiles:r}){let{appPath:i,resourcesDir:a}=await Pr({appPath:x.join(t.outDir,`${e.productName}.app`),metadata:e,hostBin:n});return await ai(t,a),await ci(r,a),i}async function ui({metadata:e,output:t,hostBin:n,licenseFiles:r}){let i=c(e.productName);oi(t,i);let a=x.join(t.outDir,i);await M(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 ai(t,a),await ci(r,a),a}async function di(e={}){let t=e.cwd??process.cwd(),n=e.stdout??process.stdout,r=e.target??ii(),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 Qn({cwd:t,entry:e.entry,config:i,sourcemap:e.sourcemap,runtimeConfig:nn(i),bundler:e.bundler,stdout:n,stderr:e.stderr}),o=e.hostBin??await Q(t,e.stderr);await $(o),zr(o,a.entryFile);let s=await xr(e.hostBin);si(a,s);let c={metadata:i,output:a,hostBin:o,licenseFiles:s};return{appPath:r===`macos`?await li(c):await ui(c)}}function fi(e){return x.relative(process.cwd(),e)}const pi={type:`boolean`,description:`Write a source map`,negativeDescription:`Skip the source map`};function mi(){for(let e of[0,1,2])try{p.closeSync(e)}catch{}}const hi=G({meta:{name:`build`,description:`Bundle the app into dist`},args:{sourcemap:pi},async run({args:e}){try{let t=await Qn({sourcemap:e.sourcemap});await Br(t.entryFile,process.stderr),J(process.stdout,`built ${fi(t.entryFile)}`)}catch(e){X(process.stderr,`build failed`,Y(e)),process.exitCode=1}}}),gi=G({meta:{name:`package`,description:`Package the app as an application bundle`},args:{sourcemap:pi},async run({args:e}){try{let{appPath:t}=await di({sourcemap:e.sourcemap});J(process.stdout,`packaged ${fi(t)}`)}catch(e){X(process.stderr,`package failed`,Y(e)),process.exitCode=1}}}),_i=G({meta:{name:`config`,description:`Print the settings the host applies to the app`},async run(){try{process.exitCode=await Vr()}catch(e){X(process.stderr,`config failed`,Y(e)),process.exitCode=1}}}),vi=G({meta:{name:`info`,description:`Print the versions and the host binary in use`},async run(){try{await ri()}catch(e){X(process.stderr,`info failed`,Y(e)),process.exitCode=1}}}),yi=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&&sn(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 $r({signal:t.signal,experimentalHmr:r}),t.signal.aborted&&mi()}catch(e){X(process.stderr,`dev failed`,Y(e),{timestamp:!0}),process.exitCode=1}}}),bi=G({meta:{name:`inca`,version:Ke,description:qe},subCommands:{dev:yi,build:hi,package:gi,config:_i,info:vi}});async function xi(e=process.argv){await Ue(bi,{rawArgs:e.slice(2)})}export{xi as run};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@incajs/cli",
3
- "version": "0.0.25",
3
+ "version": "0.0.26",
4
4
  "description": "Commands to develop, bundle, and package Incarnative.js apps.",
5
5
  "keywords": [
6
6
  "bundler",
@@ -27,7 +27,9 @@
27
27
  },
28
28
  "files": [
29
29
  "dist",
30
- "bin"
30
+ "bin",
31
+ "LICENSE-MIT",
32
+ "LICENSE-APACHE"
31
33
  ],
32
34
  "type": "module",
33
35
  "sideEffects": [
@@ -61,10 +63,10 @@
61
63
  }
62
64
  },
63
65
  "optionalDependencies": {
64
- "@incajs/host-darwin-arm64": "0.0.25",
65
- "@incajs/host-darwin-x64": "0.0.25",
66
- "@incajs/host-linux-arm64": "0.0.25",
67
- "@incajs/host-linux-x64": "0.0.25"
66
+ "@incajs/host-darwin-arm64": "0.0.26",
67
+ "@incajs/host-darwin-x64": "0.0.26",
68
+ "@incajs/host-linux-arm64": "0.0.26",
69
+ "@incajs/host-linux-x64": "0.0.26"
68
70
  },
69
71
  "engines": {
70
72
  "node": ">=22.18"
package/LICENSE DELETED
@@ -1,5 +0,0 @@
1
- Dual-licensed under MIT OR Apache-2.0.
2
-
3
- See:
4
- - https://github.com/tom96da/incajs/blob/main/LICENSE-MIT
5
- - https://github.com/tom96da/incajs/blob/main/LICENSE-APACHE