@gjsify/cli 0.64.50 → 0.64.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.gjs.mjs CHANGED
@@ -146,7 +146,7 @@ fi
146
146
  `)}`:``;n.fail(N(`Missing required argument: %s`,`Missing required arguments: %s`,Object.keys(C).length,Object.keys(C).join(`, `)+S))}},F.unknownArguments=function unknownArguments(S,C,I,H,W=!0){let q=t.getInternalMethods().getCommandInstance().getCommands(),Y=[],X=t.getInternalMethods().getContext();if(Object.keys(S).forEach(n=>{!Bp.includes(n)&&!Object.prototype.hasOwnProperty.call(I,n)&&!Object.prototype.hasOwnProperty.call(t.getInternalMethods().getParseContext(),n)&&!F.isValidAndSomeAliasIsNotNew(n,C)&&Y.push(n)}),W&&(X.commands.length>0||q.length>0||H)&&S._.slice(X.commands.length).forEach(t=>{q.includes(``+t)||Y.push(``+t)}),W){let n=t.getDemandedCommands()._?.max||0,C=X.commands.length+n;C<S._.length&&S._.slice(C).forEach(t=>{t=String(t),!X.commands.includes(t)&&!Y.includes(t)&&Y.push(t)})}Y.length&&n.fail(N(`Unknown argument: %s`,`Unknown arguments: %s`,Y.length,Y.map(t=>t.trim()?t:`"${t}"`).join(`, `)))},F.unknownCommands=function unknownCommands(S){let C=t.getInternalMethods().getCommandInstance().getCommands(),F=[],I=t.getInternalMethods().getContext();return(I.commands.length>0||C.length>0)&&S._.slice(I.commands.length).forEach(t=>{C.includes(``+t)||F.push(``+t)}),F.length>0?(n.fail(N(`Unknown command: %s`,`Unknown commands: %s`,F.length,F.join(`, `))),!0):!1},F.isValidAndSomeAliasIsNotNew=function isValidAndSomeAliasIsNotNew(n,S){if(!Object.prototype.hasOwnProperty.call(S,n))return!1;let C=t.parsed.newAliases;return[n,...S[n]].some(t=>!Object.prototype.hasOwnProperty.call(C,t)||!C[n])},F.limitedChoices=function limitedChoices(S){let N=t.getOptions(),F={};if(!Object.keys(N.choices).length)return;Object.keys(S).forEach(t=>{Bp.indexOf(t)===-1&&Object.prototype.hasOwnProperty.call(N.choices,t)&&[].concat(S[t]).forEach(n=>{N.choices[t].indexOf(n)===-1&&n!==void 0&&(F[t]=(F[t]||[]).concat(n))})});let I=Object.keys(F);if(!I.length)return;let H=C(`Invalid values:`);I.forEach(t=>{H+=`\n ${C(`Argument: %s, Given: %s, Choices: %s`,t,n.stringifiedValues(F[t]),n.stringifiedValues(N.choices[t]))}`}),n.fail(H)};let I={};F.implies=function implies(n,C){argsert(`<string|object> [array|number|string]`,[n,C],arguments.length),typeof n==`object`?Object.keys(n).forEach(t=>{F.implies(t,n[t])}):(t.global(n),I[n]||(I[n]=[]),Array.isArray(C)?C.forEach(t=>F.implies(n,t)):(assertNotStrictEqual(C,void 0,S),I[n].push(C)))},F.getImplied=function getImplied(){return I};function keyExists(t,n){let S=Number(n);return n=isNaN(S)?n:S,typeof n==`number`?n=t._.length>=n:n.match(/^--no-.+/)?(n=n.match(/^--no-(.+)/)[1],n=!Object.prototype.hasOwnProperty.call(t,n)):n=Object.prototype.hasOwnProperty.call(t,n),n}F.implications=function implications(t){let S=[];if(Object.keys(I).forEach(n=>{let C=n;(I[n]||[]).forEach(n=>{let N=C,F=n;N=keyExists(t,N),n=keyExists(t,n),N&&!n&&S.push(` ${C} -> ${F}`)})}),S.length){let t=`${C(`Implications failed:`)}\n`;S.forEach(n=>{t+=n}),n.fail(t)}};let H={};F.conflicts=function conflicts(n,S){argsert(`<string|object> [array|string]`,[n,S],arguments.length),typeof n==`object`?Object.keys(n).forEach(t=>{F.conflicts(t,n[t])}):(t.global(n),H[n]||(H[n]=[]),Array.isArray(S)?S.forEach(t=>F.conflicts(n,t)):H[n].push(S))},F.getConflicting=()=>H,F.conflicting=function conflictingFn(N){Object.keys(N).forEach(t=>{H[t]&&H[t].forEach(S=>{S&&N[t]!==void 0&&N[S]!==void 0&&n.fail(C(`Arguments %s and %s are mutually exclusive`,t,S))})}),t.getInternalMethods().getParserConfiguration()[`strip-dashed`]&&Object.keys(H).forEach(t=>{H[t].forEach(F=>{F&&N[S.Parser.camelCase(t)]!==void 0&&N[S.Parser.camelCase(F)]!==void 0&&n.fail(C(`Arguments %s and %s are mutually exclusive`,t,F))})})},F.recommendCommands=function recommendCommands(t,S){S=S.sort((t,n)=>n.length-t.length);let N=null,F=1/0;for(let n=0,C;(C=S[n])!==void 0;n++){let n=levenshtein(t,C);n<=3&&n<F&&(F=n,N=C)}N&&n.fail(C(`Did you mean %s?`,N))},F.reset=function reset(t){return I=objFilter(I,n=>!t[n]),H=objFilter(H,n=>!t[n]),F};let W=[];return F.freeze=function freeze(){W.push({implied:I,conflicting:H})},F.unfreeze=function unfreeze(){let t=W.pop();assertNotStrictEqual(t,void 0,S),{implied:I,conflicting:H}=t},F}var Bp,Vp=__esmMin(()=>{Dp(),Cp(),zp(),Mp(),Bp=[`$0`,`--`,`_`]});function YargsFactory(t){return(n=[],S=t.process.cwd(),C)=>{let N=new YargsInstance(n,S,C,t);return Object.defineProperty(N,"argv",{get:()=>N.parse(),enumerable:!0}),N.help(),N.version(),N}}function isYargsInstance(t){return!!t&&typeof t.getInternalMethods==`function`}var __classPrivateFieldSet,__classPrivateFieldGet,Hp,Up,Wp,Gp,Kp,qp,Jp,Yp,Xp,Zp,Qp,$p,em,tm,nm,im,am,om,sm,cm,lm,um,dm,fm,pm,mm,hm,gm,_m,vm,ym,bm,xm,Sm,Cm,wm,Tm,Em,Dm,Om,km,Am,jm,Mm,Nm,Pm,Fm,Im,Lm,Rm,zm,Bm,Vm,Hm,Um,Wm,Gm,Km,qm,Jm,Ym,Xm,Zm,Qm,$m,eh,th,nh,rh,ih,ah,oh,YargsInstance,sh=__esmMin(()=>{_e(),jp(),Cp(),Vl(),Pp(),Dp(),Rp(),Vp(),Mp(),Wl(),Op(),wp(),kp(),Np(),__classPrivateFieldSet=function(t,n,S,C,N){if(C===`m`)throw TypeError(`Private method is not writable`);if(C===`a`&&!N)throw TypeError(`Private accessor was defined without a setter`);if(typeof n==`function`?t!==n||!N:!n.has(t))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return C===`a`?N.call(t,S):N?N.value=S:n.set(t,S),S},__classPrivateFieldGet=function(t,n,S,C){if(S===`a`&&!C)throw TypeError(`Private accessor was defined without a getter`);if(typeof n==`function`?t!==n||!C:!n.has(t))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return S===`m`?C:S===`a`?C.call(t):C?C.value:n.get(t)},wm=Symbol(`copyDoubleDash`),Tm=Symbol(`copyDoubleDash`),Em=Symbol(`deleteFromParserHintObject`),Dm=Symbol(`emitWarning`),Om=Symbol(`freeze`),km=Symbol(`getDollarZero`),Am=Symbol(`getParserConfiguration`),jm=Symbol(`getUsageConfiguration`),Mm=Symbol(`guessLocale`),Nm=Symbol(`guessVersion`),Pm=Symbol(`parsePositionalNumbers`),Fm=Symbol(`pkgUp`),Im=Symbol(`populateParserHintArray`),Lm=Symbol(`populateParserHintSingleValueDictionary`),Rm=Symbol(`populateParserHintArrayDictionary`),zm=Symbol(`populateParserHintDictionary`),Bm=Symbol(`sanitizeKey`),Vm=Symbol(`setKey`),Hm=Symbol(`unfreeze`),Um=Symbol(`validateAsync`),Wm=Symbol(`getCommandInstance`),Gm=Symbol(`getContext`),Km=Symbol(`getHasOutput`),qm=Symbol(`getLoggerInstance`),Jm=Symbol(`getParseContext`),Ym=Symbol(`getUsageInstance`),Xm=Symbol(`getValidationInstance`),Zm=Symbol(`hasParseCallback`),Qm=Symbol(`isGlobalContext`),$m=Symbol(`postProcess`),eh=Symbol(`rebase`),th=Symbol(`reset`),nh=Symbol(`runYargsParserAndExecuteCommands`),rh=Symbol(`runValidation`),ih=Symbol(`setHasOutput`),ah=Symbol(`kTrackManuallySetKeys`),oh=`en_US`,YargsInstance=class{constructor(t=[],n,S,C){this.customScriptName=!1,this.parsed=!1,Hp.set(this,void 0),Up.set(this,void 0),Wp.set(this,{commands:[],fullCommands:[]}),Gp.set(this,null),Kp.set(this,null),qp.set(this,`show-hidden`),Jp.set(this,null),Yp.set(this,!0),Xp.set(this,{}),Zp.set(this,!0),Qp.set(this,[]),$p.set(this,void 0),em.set(this,{}),tm.set(this,!1),nm.set(this,null),im.set(this,!0),am.set(this,void 0),om.set(this,``),sm.set(this,void 0),cm.set(this,void 0),lm.set(this,{}),um.set(this,null),dm.set(this,null),fm.set(this,{}),pm.set(this,{}),mm.set(this,void 0),hm.set(this,!1),gm.set(this,void 0),_m.set(this,!1),vm.set(this,!1),ym.set(this,!1),bm.set(this,void 0),xm.set(this,{}),Sm.set(this,null),Cm.set(this,void 0),__classPrivateFieldSet(this,gm,C,`f`),__classPrivateFieldSet(this,mm,t,`f`),__classPrivateFieldSet(this,Up,n,`f`),__classPrivateFieldSet(this,cm,S,`f`),__classPrivateFieldSet(this,$p,new GlobalMiddleware(this),`f`),this.$0=this[km](),this[th](),__classPrivateFieldSet(this,Hp,__classPrivateFieldGet(this,Hp,`f`),`f`),__classPrivateFieldSet(this,bm,__classPrivateFieldGet(this,bm,`f`),`f`),__classPrivateFieldSet(this,Cm,__classPrivateFieldGet(this,Cm,`f`),`f`),__classPrivateFieldSet(this,sm,__classPrivateFieldGet(this,sm,`f`),`f`),__classPrivateFieldGet(this,sm,`f`).showHiddenOpt=__classPrivateFieldGet(this,qp,`f`),__classPrivateFieldSet(this,am,this[Tm](),`f`),__classPrivateFieldGet(this,gm,`f`).y18n.setLocale(oh)}addHelpOpt(t,n){return argsert(`[string|boolean] [string]`,[t,n],arguments.length),__classPrivateFieldGet(this,nm,`f`)&&(this[Em](__classPrivateFieldGet(this,nm,`f`)),__classPrivateFieldSet(this,nm,null,`f`)),t===!1&&n===void 0?this:(__classPrivateFieldSet(this,nm,typeof t==`string`?t:`help`,`f`),this.boolean(__classPrivateFieldGet(this,nm,`f`)),this.describe(__classPrivateFieldGet(this,nm,`f`),n||__classPrivateFieldGet(this,bm,`f`).deferY18nLookup(`Show help`)),this)}help(t,n){return this.addHelpOpt(t,n)}addShowHiddenOpt(t,n){if(argsert(`[string|boolean] [string]`,[t,n],arguments.length),t===!1&&n===void 0)return this;let S=typeof t==`string`?t:__classPrivateFieldGet(this,qp,`f`);return this.boolean(S),this.describe(S,n||__classPrivateFieldGet(this,bm,`f`).deferY18nLookup(`Show hidden options`)),__classPrivateFieldGet(this,sm,`f`).showHiddenOpt=S,this}showHidden(t,n){return this.addShowHiddenOpt(t,n)}alias(t,n){return argsert(`<object|string|array> [string|array]`,[t,n],arguments.length),this[Rm](this.alias.bind(this),`alias`,t,n),this}array(t){return argsert(`<array|string>`,[t],arguments.length),this[Im](`array`,t),this[ah](t),this}boolean(t){return argsert(`<array|string>`,[t],arguments.length),this[Im](`boolean`,t),this[ah](t),this}check(t,n){return argsert(`<function> [boolean]`,[t,n],arguments.length),this.middleware((n,S)=>maybeAsyncResult(()=>t(n,S.getOptions()),S=>(S?(typeof S==`string`||S instanceof Error)&&__classPrivateFieldGet(this,bm,`f`).fail(S.toString(),S):__classPrivateFieldGet(this,bm,`f`).fail(__classPrivateFieldGet(this,gm,`f`).y18n.__(`Argument check failed: %s`,t.toString())),n),t=>(__classPrivateFieldGet(this,bm,`f`).fail(t.message?t.message:t.toString(),t),n)),!1,n),this}choices(t,n){return argsert(`<object|string|array> [string|array]`,[t,n],arguments.length),this[Rm](this.choices.bind(this),`choices`,t,n),this}coerce(t,n){if(argsert(`<object|string|array> [function]`,[t,n],arguments.length),Array.isArray(t)){if(!n)throw new Bl(`coerce callback must be provided`);for(let S of t)this.coerce(S,n);return this}else if(typeof t==`object`){for(let n of Object.keys(t))this.coerce(n,t[n]);return this}if(!n)throw new Bl(`coerce callback must be provided`);let S=t;return __classPrivateFieldGet(this,sm,`f`).key[S]=!0,__classPrivateFieldGet(this,$p,`f`).addCoerceMiddleware((t,C)=>{let N=C.getAliases()[S]??[],F=[S,...N].filter(n=>Object.prototype.hasOwnProperty.call(t,n));return F.length===0?t:maybeAsyncResult(()=>n(t[F[0]]),n=>(F.forEach(S=>{t[S]=n}),t),t=>{throw new Bl(t.message)})},S),this}conflicts(t,n){return argsert(`<string|object> [string|array]`,[t,n],arguments.length),__classPrivateFieldGet(this,Cm,`f`).conflicts(t,n),this}config(t=`config`,n,S){return argsert(`[object|string] [string|function] [function]`,[t,n,S],arguments.length),typeof t==`object`&&!Array.isArray(t)?(t=applyExtends(t,__classPrivateFieldGet(this,Up,`f`),this[Am]()[`deep-merge-config`]||!1,__classPrivateFieldGet(this,gm,`f`)),__classPrivateFieldGet(this,sm,`f`).configObjects=(__classPrivateFieldGet(this,sm,`f`).configObjects||[]).concat(t),this):(typeof n==`function`&&(S=n,n=void 0),this.describe(t,n||__classPrivateFieldGet(this,bm,`f`).deferY18nLookup(`Path to JSON config file`)),(Array.isArray(t)?t:[t]).forEach(t=>{__classPrivateFieldGet(this,sm,`f`).config[t]=S||!0}),this)}completion(t,n,S){return argsert(`[string] [string|boolean|function] [function]`,[t,n,S],arguments.length),typeof n==`function`&&(S=n,n=void 0),__classPrivateFieldSet(this,Kp,t||__classPrivateFieldGet(this,Kp,`f`)||`completion`,`f`),!n&&n!==!1&&(n=`generate completion script`),this.command(__classPrivateFieldGet(this,Kp,`f`),n),S&&__classPrivateFieldGet(this,Gp,`f`).registerFunction(S),this}command(t,n,S,C,N,F){return argsert(`<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]`,[t,n,S,C,N,F],arguments.length),__classPrivateFieldGet(this,Hp,`f`).addHandler(t,n,S,C,N,F),this}commands(t,n,S,C,N,F){return this.command(t,n,S,C,N,F)}commandDir(t,n){argsert(`<string> [object]`,[t,n],arguments.length);let S=__classPrivateFieldGet(this,cm,`f`)||__classPrivateFieldGet(this,gm,`f`).require;return __classPrivateFieldGet(this,Hp,`f`).addDirectory(t,S,__classPrivateFieldGet(this,gm,`f`).getCallerFile(),n),this}count(t){return argsert(`<array|string>`,[t],arguments.length),this[Im](`count`,t),this[ah](t),this}default(t,n,S){return argsert(`<object|string|array> [*] [string]`,[t,n,S],arguments.length),S&&(assertSingleKey(t,__classPrivateFieldGet(this,gm,`f`)),__classPrivateFieldGet(this,sm,`f`).defaultDescription[t]=S),typeof n==`function`&&(assertSingleKey(t,__classPrivateFieldGet(this,gm,`f`)),__classPrivateFieldGet(this,sm,`f`).defaultDescription[t]||(__classPrivateFieldGet(this,sm,`f`).defaultDescription[t]=__classPrivateFieldGet(this,bm,`f`).functionDescription(n)),n=n.call()),this[Lm](this.default.bind(this),`default`,t,n),this}defaults(t,n,S){return this.default(t,n,S)}demandCommand(t=1,n,S,C){return argsert(`[number] [number|string] [string|null|undefined] [string|null|undefined]`,[t,n,S,C],arguments.length),typeof n!=`number`&&(S=n,n=1/0),this.global(`_`,!1),__classPrivateFieldGet(this,sm,`f`).demandedCommands._={min:t,max:n,minMsg:S,maxMsg:C},this}demand(t,n,S){return Array.isArray(n)?(n.forEach(t=>{assertNotStrictEqual(S,!0,__classPrivateFieldGet(this,gm,`f`)),this.demandOption(t,S)}),n=1/0):typeof n!=`number`&&(S=n,n=1/0),typeof t==`number`?(assertNotStrictEqual(S,!0,__classPrivateFieldGet(this,gm,`f`)),this.demandCommand(t,n,S,S)):Array.isArray(t)?t.forEach(t=>{assertNotStrictEqual(S,!0,__classPrivateFieldGet(this,gm,`f`)),this.demandOption(t,S)}):typeof S==`string`?this.demandOption(t,S):(S===!0||S===void 0)&&this.demandOption(t),this}demandOption(t,n){return argsert(`<object|string|array> [string]`,[t,n],arguments.length),this[Lm](this.demandOption.bind(this),`demandedOptions`,t,n),this}deprecateOption(t,n){return argsert(`<string> [string|boolean]`,[t,n],arguments.length),__classPrivateFieldGet(this,sm,`f`).deprecatedOptions[t]=n,this}describe(t,n){return argsert(`<object|string|array> [string]`,[t,n],arguments.length),this[Vm](t,!0),__classPrivateFieldGet(this,bm,`f`).describe(t,n),this}detectLocale(t){return argsert(`<boolean>`,[t],arguments.length),__classPrivateFieldSet(this,Yp,t,`f`),this}env(t){return argsert(`[string|boolean]`,[t],arguments.length),t===!1?delete __classPrivateFieldGet(this,sm,`f`).envPrefix:__classPrivateFieldGet(this,sm,`f`).envPrefix=t||``,this}epilogue(t){return argsert(`<string>`,[t],arguments.length),__classPrivateFieldGet(this,bm,`f`).epilog(t),this}epilog(t){return this.epilogue(t)}example(t,n){return argsert(`<string|array> [string]`,[t,n],arguments.length),Array.isArray(t)?t.forEach(t=>this.example(...t)):__classPrivateFieldGet(this,bm,`f`).example(t,n),this}exit(t,n){__classPrivateFieldSet(this,tm,!0,`f`),__classPrivateFieldSet(this,Jp,n,`f`),__classPrivateFieldGet(this,Zp,`f`)&&__classPrivateFieldGet(this,gm,`f`).process.exit(t)}exitProcess(t=!0){return argsert(`[boolean]`,[t],arguments.length),__classPrivateFieldSet(this,Zp,t,`f`),this}fail(t){if(argsert(`<function|boolean>`,[t],arguments.length),typeof t==`boolean`&&t!==!1)throw new Bl(`Invalid first argument. Expected function or boolean 'false'`);return __classPrivateFieldGet(this,bm,`f`).failFn(t),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(t,n){return argsert(`<array> [function]`,[t,n],arguments.length),n?__classPrivateFieldGet(this,Gp,`f`).getCompletion(t,n):new Promise((n,S)=>{__classPrivateFieldGet(this,Gp,`f`).getCompletion(t,(t,C)=>{t?S(t):n(C)})})}getDemandedOptions(){return argsert([],0),__classPrivateFieldGet(this,sm,`f`).demandedOptions}getDemandedCommands(){return argsert([],0),__classPrivateFieldGet(this,sm,`f`).demandedCommands}getDeprecatedOptions(){return argsert([],0),__classPrivateFieldGet(this,sm,`f`).deprecatedOptions}getDetectLocale(){return __classPrivateFieldGet(this,Yp,`f`)}getExitProcess(){return __classPrivateFieldGet(this,Zp,`f`)}getGroups(){return Object.assign({},__classPrivateFieldGet(this,em,`f`),__classPrivateFieldGet(this,pm,`f`))}getHelp(){if(__classPrivateFieldSet(this,tm,!0,`f`),!__classPrivateFieldGet(this,bm,`f`).hasCachedHelpMessage()){if(!this.parsed){let t=this[nh](__classPrivateFieldGet(this,mm,`f`),void 0,void 0,0,!0);if(isPromise(t))return t.then(()=>__classPrivateFieldGet(this,bm,`f`).help())}let t=__classPrivateFieldGet(this,Hp,`f`).runDefaultBuilderOn(this);if(isPromise(t))return t.then(()=>__classPrivateFieldGet(this,bm,`f`).help())}return Promise.resolve(__classPrivateFieldGet(this,bm,`f`).help())}getOptions(){return __classPrivateFieldGet(this,sm,`f`)}getStrict(){return __classPrivateFieldGet(this,_m,`f`)}getStrictCommands(){return __classPrivateFieldGet(this,vm,`f`)}getStrictOptions(){return __classPrivateFieldGet(this,ym,`f`)}global(t,n){return argsert(`<string|array> [boolean]`,[t,n],arguments.length),t=[].concat(t),n===!1?t.forEach(t=>{__classPrivateFieldGet(this,sm,`f`).local.includes(t)||__classPrivateFieldGet(this,sm,`f`).local.push(t)}):__classPrivateFieldGet(this,sm,`f`).local=__classPrivateFieldGet(this,sm,`f`).local.filter(n=>t.indexOf(n)===-1),this}group(t,n){argsert(`<string|array> <string>`,[t,n],arguments.length);let S=__classPrivateFieldGet(this,pm,`f`)[n]||__classPrivateFieldGet(this,em,`f`)[n];__classPrivateFieldGet(this,pm,`f`)[n]&&delete __classPrivateFieldGet(this,pm,`f`)[n];let C={};return __classPrivateFieldGet(this,em,`f`)[n]=(S||[]).concat(t).filter(t=>C[t]?!1:C[t]=!0),this}hide(t){return argsert(`<string>`,[t],arguments.length),__classPrivateFieldGet(this,sm,`f`).hiddenOptions.push(t),this}implies(t,n){return argsert(`<string|object> [number|string|array]`,[t,n],arguments.length),__classPrivateFieldGet(this,Cm,`f`).implies(t,n),this}locale(t){return argsert(`[string]`,[t],arguments.length),t===void 0?(this[Mm](),__classPrivateFieldGet(this,gm,`f`).y18n.getLocale()):(__classPrivateFieldSet(this,Yp,!1,`f`),__classPrivateFieldGet(this,gm,`f`).y18n.setLocale(t),this)}middleware(t,n,S){return __classPrivateFieldGet(this,$p,`f`).addMiddleware(t,!!n,S)}nargs(t,n){return argsert(`<string|object|array> [number]`,[t,n],arguments.length),this[Lm](this.nargs.bind(this),`narg`,t,n),this}normalize(t){return argsert(`<array|string>`,[t],arguments.length),this[Im](`normalize`,t),this}number(t){return argsert(`<array|string>`,[t],arguments.length),this[Im](`number`,t),this[ah](t),this}option(t,n){if(argsert(`<string|object> [object]`,[t,n],arguments.length),typeof t==`object`)Object.keys(t).forEach(n=>{this.options(n,t[n])});else{typeof n!=`object`&&(n={}),this[ah](t),__classPrivateFieldGet(this,Sm,`f`)&&(t===`version`||n?.alias===`version`)&&this[Dm]([`"version" is a reserved word.`,`Please do one of the following:`,'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)",`- Use a different option key`,`https://yargs.js.org/docs/#api-reference-version`].join(`
147
147
  `),void 0,`versionWarning`),__classPrivateFieldGet(this,sm,`f`).key[t]=!0,n.alias&&this.alias(t,n.alias);let S=n.deprecate||n.deprecated;S&&this.deprecateOption(t,S);let C=n.demand||n.required||n.require;C&&this.demand(t,C),n.demandOption&&this.demandOption(t,typeof n.demandOption==`string`?n.demandOption:void 0),n.conflicts&&this.conflicts(t,n.conflicts),`default`in n&&this.default(t,n.default),n.implies!==void 0&&this.implies(t,n.implies),n.nargs!==void 0&&this.nargs(t,n.nargs),n.config&&this.config(t,n.configParser),n.normalize&&this.normalize(t),n.choices&&this.choices(t,n.choices),n.coerce&&this.coerce(t,n.coerce),n.group&&this.group(t,n.group),(n.boolean||n.type===`boolean`)&&(this.boolean(t),n.alias&&this.boolean(n.alias)),(n.array||n.type===`array`)&&(this.array(t),n.alias&&this.array(n.alias)),(n.number||n.type===`number`)&&(this.number(t),n.alias&&this.number(n.alias)),(n.string||n.type===`string`)&&(this.string(t),n.alias&&this.string(n.alias)),(n.count||n.type===`count`)&&this.count(t),typeof n.global==`boolean`&&this.global(t,n.global),n.defaultDescription&&(__classPrivateFieldGet(this,sm,`f`).defaultDescription[t]=n.defaultDescription),n.skipValidation&&this.skipValidation(t);let N=n.describe||n.description||n.desc,F=__classPrivateFieldGet(this,bm,`f`).getDescriptions();(!Object.prototype.hasOwnProperty.call(F,t)||typeof N==`string`)&&this.describe(t,N),n.hidden&&this.hide(t),n.requiresArg&&this.requiresArg(t)}return this}options(t,n){return this.option(t,n)}parse(t,n,S){argsert(`[string|array] [function|boolean|object] [function]`,[t,n,S],arguments.length),this[Om](),t===void 0&&(t=__classPrivateFieldGet(this,mm,`f`)),typeof n==`object`&&(__classPrivateFieldSet(this,dm,n,`f`),n=S),typeof n==`function`&&(__classPrivateFieldSet(this,um,n,`f`),n=!1),n||__classPrivateFieldSet(this,mm,t,`f`),__classPrivateFieldGet(this,um,`f`)&&__classPrivateFieldSet(this,Zp,!1,`f`);let C=this[nh](t,!!n),N=this.parsed;return __classPrivateFieldGet(this,Gp,`f`).setParsed(this.parsed),isPromise(C)?C.then(t=>(__classPrivateFieldGet(this,um,`f`)&&__classPrivateFieldGet(this,um,`f`).call(this,__classPrivateFieldGet(this,Jp,`f`),t,__classPrivateFieldGet(this,om,`f`)),t)).catch(t=>{throw __classPrivateFieldGet(this,um,`f`)&&__classPrivateFieldGet(this,um,`f`)(t,this.parsed.argv,__classPrivateFieldGet(this,om,`f`)),t}).finally(()=>{this[Hm](),this.parsed=N}):(__classPrivateFieldGet(this,um,`f`)&&__classPrivateFieldGet(this,um,`f`).call(this,__classPrivateFieldGet(this,Jp,`f`),C,__classPrivateFieldGet(this,om,`f`)),this[Hm](),this.parsed=N,C)}parseAsync(t,n,S){let C=this.parse(t,n,S);return isPromise(C)?C:Promise.resolve(C)}parseSync(t,n,S){let C=this.parse(t,n,S);if(isPromise(C))throw new Bl(`.parseSync() must not be used with asynchronous builders, handlers, or middleware`);return C}parserConfiguration(t){return argsert(`<object>`,[t],arguments.length),__classPrivateFieldSet(this,lm,t,`f`),this}pkgConf(t,n){argsert(`<string> [string]`,[t,n],arguments.length);let S=null,C=this[Fm](n||__classPrivateFieldGet(this,Up,`f`));return C[t]&&typeof C[t]==`object`&&(S=applyExtends(C[t],n||__classPrivateFieldGet(this,Up,`f`),this[Am]()[`deep-merge-config`]||!1,__classPrivateFieldGet(this,gm,`f`)),__classPrivateFieldGet(this,sm,`f`).configObjects=(__classPrivateFieldGet(this,sm,`f`).configObjects||[]).concat(S)),this}positional(t,n){argsert(`<string> <object>`,[t,n],arguments.length);let S=[`default`,`defaultDescription`,`implies`,`normalize`,`choices`,`conflicts`,`coerce`,`type`,`describe`,`desc`,`description`,`alias`];n=objFilter(n,(t,n)=>t===`type`&&![`string`,`number`,`boolean`].includes(n)?!1:S.includes(t));let C=__classPrivateFieldGet(this,Wp,`f`).fullCommands[__classPrivateFieldGet(this,Wp,`f`).fullCommands.length-1],N=C?__classPrivateFieldGet(this,Hp,`f`).cmdToParseOptions(C):{array:[],alias:{},default:{},demand:{}};return objectKeys(N).forEach(S=>{let C=N[S];Array.isArray(C)?C.indexOf(t)!==-1&&(n[S]=!0):C[t]&&!(S in n)&&(n[S]=C[t])}),this.group(t,__classPrivateFieldGet(this,bm,`f`).getPositionalGroupName()),this.option(t,n)}recommendCommands(t=!0){return argsert(`[boolean]`,[t],arguments.length),__classPrivateFieldSet(this,hm,t,`f`),this}required(t,n,S){return this.demand(t,n,S)}require(t,n,S){return this.demand(t,n,S)}requiresArg(t){return argsert(`<array|string|object> [number]`,[t],arguments.length),typeof t==`string`&&__classPrivateFieldGet(this,sm,`f`).narg[t]||this[Lm](this.requiresArg.bind(this),`narg`,t,NaN),this}showCompletionScript(t,n){return argsert(`[string] [string]`,[t,n],arguments.length),t||=this.$0,__classPrivateFieldGet(this,am,`f`).log(__classPrivateFieldGet(this,Gp,`f`).generateCompletionScript(t,n||__classPrivateFieldGet(this,Kp,`f`)||`completion`)),this}showHelp(t){if(argsert(`[string|function]`,[t],arguments.length),__classPrivateFieldSet(this,tm,!0,`f`),!__classPrivateFieldGet(this,bm,`f`).hasCachedHelpMessage()){if(!this.parsed){let n=this[nh](__classPrivateFieldGet(this,mm,`f`),void 0,void 0,0,!0);if(isPromise(n))return n.then(()=>{__classPrivateFieldGet(this,bm,`f`).showHelp(t)}),this}let n=__classPrivateFieldGet(this,Hp,`f`).runDefaultBuilderOn(this);if(isPromise(n))return n.then(()=>{__classPrivateFieldGet(this,bm,`f`).showHelp(t)}),this}return __classPrivateFieldGet(this,bm,`f`).showHelp(t),this}scriptName(t){return this.customScriptName=!0,this.$0=t,this}showHelpOnFail(t,n){return argsert(`[boolean|string] [string]`,[t,n],arguments.length),__classPrivateFieldGet(this,bm,`f`).showHelpOnFail(t,n),this}showVersion(t){return argsert(`[string|function]`,[t],arguments.length),__classPrivateFieldGet(this,bm,`f`).showVersion(t),this}skipValidation(t){return argsert(`<array|string>`,[t],arguments.length),this[Im](`skipValidation`,t),this}strict(t){return argsert(`[boolean]`,[t],arguments.length),__classPrivateFieldSet(this,_m,t!==!1,`f`),this}strictCommands(t){return argsert(`[boolean]`,[t],arguments.length),__classPrivateFieldSet(this,vm,t!==!1,`f`),this}strictOptions(t){return argsert(`[boolean]`,[t],arguments.length),__classPrivateFieldSet(this,ym,t!==!1,`f`),this}string(t){return argsert(`<array|string>`,[t],arguments.length),this[Im](`string`,t),this[ah](t),this}terminalWidth(){return argsert([],0),__classPrivateFieldGet(this,gm,`f`).process.stdColumns}updateLocale(t){return this.updateStrings(t)}updateStrings(t){return argsert(`<object>`,[t],arguments.length),__classPrivateFieldSet(this,Yp,!1,`f`),__classPrivateFieldGet(this,gm,`f`).y18n.updateLocale(t),this}usage(t,n,S,C){if(argsert(`<string|null|undefined> [string|boolean] [function|object] [function]`,[t,n,S,C],arguments.length),n!==void 0){if(assertNotStrictEqual(t,null,__classPrivateFieldGet(this,gm,`f`)),(t||``).match(/^\$0( |$)/))return this.command(t,n,S,C);throw new Bl(`.usage() description must start with $0 if being used as alias for .command()`)}else return __classPrivateFieldGet(this,bm,`f`).usage(t),this}usageConfiguration(t){return argsert(`<object>`,[t],arguments.length),__classPrivateFieldSet(this,xm,t,`f`),this}version(t,n,S){let C=`version`;if(argsert(`[boolean|string] [string] [string]`,[t,n,S],arguments.length),__classPrivateFieldGet(this,Sm,`f`)&&(this[Em](__classPrivateFieldGet(this,Sm,`f`)),__classPrivateFieldGet(this,bm,`f`).version(void 0),__classPrivateFieldSet(this,Sm,null,`f`)),arguments.length===0)S=this[Nm](),t=C;else if(arguments.length===1){if(t===!1)return this;S=t,t=C}else arguments.length===2&&(S=n,n=void 0);return __classPrivateFieldSet(this,Sm,typeof t==`string`?t:C,`f`),n||=__classPrivateFieldGet(this,bm,`f`).deferY18nLookup(`Show version number`),__classPrivateFieldGet(this,bm,`f`).version(S||void 0),this.boolean(__classPrivateFieldGet(this,Sm,`f`)),this.describe(__classPrivateFieldGet(this,Sm,`f`),n),this}wrap(t){return argsert(`<number|null|undefined>`,[t],arguments.length),__classPrivateFieldGet(this,bm,`f`).wrap(t),this}[(Hp=new WeakMap,Up=new WeakMap,Wp=new WeakMap,Gp=new WeakMap,Kp=new WeakMap,qp=new WeakMap,Jp=new WeakMap,Yp=new WeakMap,Xp=new WeakMap,Zp=new WeakMap,Qp=new WeakMap,$p=new WeakMap,em=new WeakMap,tm=new WeakMap,nm=new WeakMap,im=new WeakMap,am=new WeakMap,om=new WeakMap,sm=new WeakMap,cm=new WeakMap,lm=new WeakMap,um=new WeakMap,dm=new WeakMap,fm=new WeakMap,pm=new WeakMap,mm=new WeakMap,hm=new WeakMap,gm=new WeakMap,_m=new WeakMap,vm=new WeakMap,ym=new WeakMap,bm=new WeakMap,xm=new WeakMap,Sm=new WeakMap,Cm=new WeakMap,wm)](t){if(!t._||!t[`--`])return t;t._.push.apply(t._,t[`--`]);try{delete t[`--`]}catch{}return t}[Tm](){return{log:(...t)=>{this[Zm]()||ge.log(...t),__classPrivateFieldSet(this,tm,!0,`f`),__classPrivateFieldGet(this,om,`f`).length&&__classPrivateFieldSet(this,om,__classPrivateFieldGet(this,om,`f`)+`
148
148
  `,`f`),__classPrivateFieldSet(this,om,__classPrivateFieldGet(this,om,`f`)+t.join(` `),`f`)},error:(...t)=>{this[Zm]()||ge.error(...t),__classPrivateFieldSet(this,tm,!0,`f`),__classPrivateFieldGet(this,om,`f`).length&&__classPrivateFieldSet(this,om,__classPrivateFieldGet(this,om,`f`)+`
149
- `,`f`),__classPrivateFieldSet(this,om,__classPrivateFieldGet(this,om,`f`)+t.join(` `),`f`)}}}[Em](t){objectKeys(__classPrivateFieldGet(this,sm,`f`)).forEach(n=>{if((t=>t===`configObjects`)(n))return;let S=__classPrivateFieldGet(this,sm,`f`)[n];Array.isArray(S)?S.includes(t)&&S.splice(S.indexOf(t),1):typeof S==`object`&&delete S[t]}),delete __classPrivateFieldGet(this,bm,`f`).getDescriptions()[t]}[Dm](t,n,S){__classPrivateFieldGet(this,Xp,`f`)[S]||(__classPrivateFieldGet(this,gm,`f`).process.emitWarning(t,n),__classPrivateFieldGet(this,Xp,`f`)[S]=!0)}[Om](){__classPrivateFieldGet(this,Qp,`f`).push({options:__classPrivateFieldGet(this,sm,`f`),configObjects:__classPrivateFieldGet(this,sm,`f`).configObjects.slice(0),exitProcess:__classPrivateFieldGet(this,Zp,`f`),groups:__classPrivateFieldGet(this,em,`f`),strict:__classPrivateFieldGet(this,_m,`f`),strictCommands:__classPrivateFieldGet(this,vm,`f`),strictOptions:__classPrivateFieldGet(this,ym,`f`),completionCommand:__classPrivateFieldGet(this,Kp,`f`),output:__classPrivateFieldGet(this,om,`f`),exitError:__classPrivateFieldGet(this,Jp,`f`),hasOutput:__classPrivateFieldGet(this,tm,`f`),parsed:this.parsed,parseFn:__classPrivateFieldGet(this,um,`f`),parseContext:__classPrivateFieldGet(this,dm,`f`)}),__classPrivateFieldGet(this,bm,`f`).freeze(),__classPrivateFieldGet(this,Cm,`f`).freeze(),__classPrivateFieldGet(this,Hp,`f`).freeze(),__classPrivateFieldGet(this,$p,`f`).freeze()}[km](){let t=``,n;return n=/\b(node|iojs|electron)(\.exe)?$/.test(__classPrivateFieldGet(this,gm,`f`).process.argv()[0])?__classPrivateFieldGet(this,gm,`f`).process.argv().slice(1,2):__classPrivateFieldGet(this,gm,`f`).process.argv().slice(0,1),t=n.map(t=>{let n=this[eh](__classPrivateFieldGet(this,Up,`f`),t);return t.match(/^(\/|([a-zA-Z]:)?\\)/)&&n.length<t.length?n:t}).join(` `).trim(),__classPrivateFieldGet(this,gm,`f`).getEnv(`_`)&&__classPrivateFieldGet(this,gm,`f`).getProcessArgvBin()===__classPrivateFieldGet(this,gm,`f`).getEnv(`_`)&&(t=__classPrivateFieldGet(this,gm,`f`).getEnv(`_`).replace(`${__classPrivateFieldGet(this,gm,`f`).path.dirname(__classPrivateFieldGet(this,gm,`f`).process.execPath())}/`,``)),t}[Am](){return __classPrivateFieldGet(this,lm,`f`)}[jm](){return __classPrivateFieldGet(this,xm,`f`)}[Mm](){if(!__classPrivateFieldGet(this,Yp,`f`))return;let t=__classPrivateFieldGet(this,gm,`f`).getEnv(`LC_ALL`)||__classPrivateFieldGet(this,gm,`f`).getEnv(`LC_MESSAGES`)||__classPrivateFieldGet(this,gm,`f`).getEnv(`LANG`)||__classPrivateFieldGet(this,gm,`f`).getEnv(`LANGUAGE`)||`en_US`;this.locale(t.replace(/[.:].*/,``))}[Nm](){return this[Fm]().version||`unknown`}[Pm](t){let n=t[`--`]?t[`--`]:t._;for(let t=0,S;(S=n[t])!==void 0;t++)__classPrivateFieldGet(this,gm,`f`).Parser.looksLikeNumber(S)&&Number.isSafeInteger(Math.floor(parseFloat(`${S}`)))&&(n[t]=Number(S));return t}[Fm](t){let n=t||`*`;if(__classPrivateFieldGet(this,fm,`f`)[n])return __classPrivateFieldGet(this,fm,`f`)[n];let S={};try{let n=t||__classPrivateFieldGet(this,gm,`f`).mainFilename;__classPrivateFieldGet(this,gm,`f`).path.extname(n)&&(n=__classPrivateFieldGet(this,gm,`f`).path.dirname(n));let C=__classPrivateFieldGet(this,gm,`f`).findUp(n,(t,n)=>{if(n.includes(`package.json`))return`package.json`});assertNotStrictEqual(C,void 0,__classPrivateFieldGet(this,gm,`f`)),S=JSON.parse(__classPrivateFieldGet(this,gm,`f`).readFileSync(C,`utf8`))}catch{}return __classPrivateFieldGet(this,fm,`f`)[n]=S||{},__classPrivateFieldGet(this,fm,`f`)[n]}[Im](t,n){n=[].concat(n),n.forEach(n=>{n=this[Bm](n),__classPrivateFieldGet(this,sm,`f`)[t].push(n)})}[Lm](t,n,S,C){this[zm](t,n,S,C,(t,n,S)=>{__classPrivateFieldGet(this,sm,`f`)[t][n]=S})}[Rm](t,n,S,C){this[zm](t,n,S,C,(t,n,S)=>{__classPrivateFieldGet(this,sm,`f`)[t][n]=(__classPrivateFieldGet(this,sm,`f`)[t][n]||[]).concat(S)})}[zm](t,n,S,C,N){if(Array.isArray(S))S.forEach(n=>{t(n,C)});else if((t=>typeof t==`object`)(S))for(let n of objectKeys(S))t(n,S[n]);else N(n,this[Bm](S),C)}[Bm](t){return t===`__proto__`?`___proto___`:t}[Vm](t,n){return this[Lm](this[Vm].bind(this),`key`,t,n),this}[Hm](){var t,n,S,C,N,F,I,H,W,q,Y,X;let Z=__classPrivateFieldGet(this,Qp,`f`).pop();assertNotStrictEqual(Z,void 0,__classPrivateFieldGet(this,gm,`f`));let te;t=this,n=this,S=this,C=this,N=this,F=this,I=this,H=this,W=this,q=this,Y=this,X=this,{options:{set value(n){__classPrivateFieldSet(t,sm,n,`f`)}}.value,configObjects:te,exitProcess:{set value(t){__classPrivateFieldSet(n,Zp,t,`f`)}}.value,groups:{set value(t){__classPrivateFieldSet(S,em,t,`f`)}}.value,output:{set value(t){__classPrivateFieldSet(C,om,t,`f`)}}.value,exitError:{set value(t){__classPrivateFieldSet(N,Jp,t,`f`)}}.value,hasOutput:{set value(t){__classPrivateFieldSet(F,tm,t,`f`)}}.value,parsed:this.parsed,strict:{set value(t){__classPrivateFieldSet(I,_m,t,`f`)}}.value,strictCommands:{set value(t){__classPrivateFieldSet(H,vm,t,`f`)}}.value,strictOptions:{set value(t){__classPrivateFieldSet(W,ym,t,`f`)}}.value,completionCommand:{set value(t){__classPrivateFieldSet(q,Kp,t,`f`)}}.value,parseFn:{set value(t){__classPrivateFieldSet(Y,um,t,`f`)}}.value,parseContext:{set value(t){__classPrivateFieldSet(X,dm,t,`f`)}}.value}=Z,__classPrivateFieldGet(this,sm,`f`).configObjects=te,__classPrivateFieldGet(this,bm,`f`).unfreeze(),__classPrivateFieldGet(this,Cm,`f`).unfreeze(),__classPrivateFieldGet(this,Hp,`f`).unfreeze(),__classPrivateFieldGet(this,$p,`f`).unfreeze()}[Um](t,n){return maybeAsyncResult(n,n=>(t(n),n))}getInternalMethods(){return{getCommandInstance:this[Wm].bind(this),getContext:this[Gm].bind(this),getHasOutput:this[Km].bind(this),getLoggerInstance:this[qm].bind(this),getParseContext:this[Jm].bind(this),getParserConfiguration:this[Am].bind(this),getUsageConfiguration:this[jm].bind(this),getUsageInstance:this[Ym].bind(this),getValidationInstance:this[Xm].bind(this),hasParseCallback:this[Zm].bind(this),isGlobalContext:this[Qm].bind(this),postProcess:this[$m].bind(this),reset:this[th].bind(this),runValidation:this[rh].bind(this),runYargsParserAndExecuteCommands:this[nh].bind(this),setHasOutput:this[ih].bind(this)}}[Wm](){return __classPrivateFieldGet(this,Hp,`f`)}[Gm](){return __classPrivateFieldGet(this,Wp,`f`)}[Km](){return __classPrivateFieldGet(this,tm,`f`)}[qm](){return __classPrivateFieldGet(this,am,`f`)}[Jm](){return __classPrivateFieldGet(this,dm,`f`)||{}}[Ym](){return __classPrivateFieldGet(this,bm,`f`)}[Xm](){return __classPrivateFieldGet(this,Cm,`f`)}[Zm](){return!!__classPrivateFieldGet(this,um,`f`)}[Qm](){return __classPrivateFieldGet(this,im,`f`)}[$m](t,n,S,C){return S||isPromise(t)?t:(n||(t=this[wm](t)),(this[Am]()[`parse-positional-numbers`]||this[Am]()[`parse-positional-numbers`]===void 0)&&(t=this[Pm](t)),C&&(t=applyMiddleware(t,this,__classPrivateFieldGet(this,$p,`f`).getMiddleware(),!1)),t)}[th](t={}){__classPrivateFieldSet(this,sm,__classPrivateFieldGet(this,sm,`f`)||{},`f`);let n={};n.local=__classPrivateFieldGet(this,sm,`f`).local||[],n.configObjects=__classPrivateFieldGet(this,sm,`f`).configObjects||[];let S={};return n.local.forEach(n=>{S[n]=!0,(t[n]||[]).forEach(t=>{S[t]=!0})}),Object.assign(__classPrivateFieldGet(this,pm,`f`),Object.keys(__classPrivateFieldGet(this,em,`f`)).reduce((t,n)=>{let C=__classPrivateFieldGet(this,em,`f`)[n].filter(t=>!(t in S));return C.length>0&&(t[n]=C),t},{})),__classPrivateFieldSet(this,em,{},`f`),[`array`,`boolean`,`string`,`skipValidation`,`count`,`normalize`,`number`,`hiddenOptions`].forEach(t=>{n[t]=(__classPrivateFieldGet(this,sm,`f`)[t]||[]).filter(t=>!S[t])}),[`narg`,`key`,`alias`,`default`,`defaultDescription`,`config`,`choices`,`demandedOptions`,`demandedCommands`,`deprecatedOptions`].forEach(t=>{n[t]=objFilter(__classPrivateFieldGet(this,sm,`f`)[t],t=>!S[t])}),n.envPrefix=__classPrivateFieldGet(this,sm,`f`).envPrefix,__classPrivateFieldSet(this,sm,n,`f`),__classPrivateFieldSet(this,bm,__classPrivateFieldGet(this,bm,`f`)?__classPrivateFieldGet(this,bm,`f`).reset(S):usage(this,__classPrivateFieldGet(this,gm,`f`)),`f`),__classPrivateFieldSet(this,Cm,__classPrivateFieldGet(this,Cm,`f`)?__classPrivateFieldGet(this,Cm,`f`).reset(S):validation(this,__classPrivateFieldGet(this,bm,`f`),__classPrivateFieldGet(this,gm,`f`)),`f`),__classPrivateFieldSet(this,Hp,__classPrivateFieldGet(this,Hp,`f`)?__classPrivateFieldGet(this,Hp,`f`).reset():command(__classPrivateFieldGet(this,bm,`f`),__classPrivateFieldGet(this,Cm,`f`),__classPrivateFieldGet(this,$p,`f`),__classPrivateFieldGet(this,gm,`f`)),`f`),__classPrivateFieldGet(this,Gp,`f`)||__classPrivateFieldSet(this,Gp,completion(this,__classPrivateFieldGet(this,bm,`f`),__classPrivateFieldGet(this,Hp,`f`),__classPrivateFieldGet(this,gm,`f`)),`f`),__classPrivateFieldGet(this,$p,`f`).reset(),__classPrivateFieldSet(this,Kp,null,`f`),__classPrivateFieldSet(this,om,``,`f`),__classPrivateFieldSet(this,Jp,null,`f`),__classPrivateFieldSet(this,tm,!1,`f`),this.parsed=!1,this}[eh](t,n){return __classPrivateFieldGet(this,gm,`f`).path.relative(t,n)}[nh](t,n,S,C=0,N=!1){let F=!!S||N;t||=__classPrivateFieldGet(this,mm,`f`),__classPrivateFieldGet(this,sm,`f`).__=__classPrivateFieldGet(this,gm,`f`).y18n.__,__classPrivateFieldGet(this,sm,`f`).configuration=this[Am]();let I=!!__classPrivateFieldGet(this,sm,`f`).configuration[`populate--`],H=Object.assign({},__classPrivateFieldGet(this,sm,`f`).configuration,{"populate--":!0}),W=__classPrivateFieldGet(this,gm,`f`).Parser.detailed(t,Object.assign({},__classPrivateFieldGet(this,sm,`f`),{configuration:{"parse-positional-numbers":!1,...H}})),q=Object.assign(W.argv,__classPrivateFieldGet(this,dm,`f`)),Y,X=W.aliases,Z=!1,te=!1;Object.keys(q).forEach(t=>{t===__classPrivateFieldGet(this,nm,`f`)&&q[t]?Z=!0:t===__classPrivateFieldGet(this,Sm,`f`)&&q[t]&&(te=!0)}),q.$0=this.$0,this.parsed=W,C===0&&__classPrivateFieldGet(this,bm,`f`).clearCachedHelpMessage();try{if(this[Mm](),n)return this[$m](q,I,!!S,!1);__classPrivateFieldGet(this,nm,`f`)&&[__classPrivateFieldGet(this,nm,`f`)].concat(X[__classPrivateFieldGet(this,nm,`f`)]||[]).filter(t=>t.length>1).includes(``+q._[q._.length-1])&&(q._.pop(),Z=!0),__classPrivateFieldSet(this,im,!1,`f`);let H=__classPrivateFieldGet(this,Hp,`f`).getCommands(),ne=__classPrivateFieldGet(this,Gp,`f`)?.completionKey?[__classPrivateFieldGet(this,Gp,`f`)?.completionKey,...this.getAliases()[__classPrivateFieldGet(this,Gp,`f`)?.completionKey]??[]].some(t=>Object.prototype.hasOwnProperty.call(q,t)):!1,re=Z||ne||N;if(q._.length){if(H.length){let t;for(let n=C||0,F;q._[n]!==void 0;n++)if(F=String(q._[n]),H.includes(F)&&F!==__classPrivateFieldGet(this,Kp,`f`)){let t=__classPrivateFieldGet(this,Hp,`f`).runCommand(F,this,W,n+1,N,Z||te||N);return this[$m](t,I,!!S,!1)}else if(!t&&F!==__classPrivateFieldGet(this,Kp,`f`)){t=F;break}!__classPrivateFieldGet(this,Hp,`f`).hasDefaultCommand()&&__classPrivateFieldGet(this,hm,`f`)&&t&&!re&&__classPrivateFieldGet(this,Cm,`f`).recommendCommands(t,H)}__classPrivateFieldGet(this,Kp,`f`)&&q._.includes(__classPrivateFieldGet(this,Kp,`f`))&&!ne&&(__classPrivateFieldGet(this,Zp,`f`)&&setBlocking(!0),this.showCompletionScript(),this.exit(0))}if(__classPrivateFieldGet(this,Hp,`f`).hasDefaultCommand()&&!re){let t=__classPrivateFieldGet(this,Hp,`f`).runCommand(null,this,W,0,N,Z||te||N);return this[$m](t,I,!!S,!1)}if(ne){__classPrivateFieldGet(this,Zp,`f`)&&setBlocking(!0),t=[].concat(t);let n=t.slice(t.indexOf(`--${__classPrivateFieldGet(this,Gp,`f`).completionKey}`)+1);return __classPrivateFieldGet(this,Gp,`f`).getCompletion(n,(t,n)=>{if(t)throw new Bl(t.message);(n||[]).forEach(t=>{__classPrivateFieldGet(this,am,`f`).log(t)}),this.exit(0)}),this[$m](q,!I,!!S,!1)}if(__classPrivateFieldGet(this,tm,`f`)||(Z?(__classPrivateFieldGet(this,Zp,`f`)&&setBlocking(!0),F=!0,this.showHelp(t=>{__classPrivateFieldGet(this,am,`f`).log(t),this.exit(0)})):te&&(__classPrivateFieldGet(this,Zp,`f`)&&setBlocking(!0),F=!0,__classPrivateFieldGet(this,bm,`f`).showVersion(`log`),this.exit(0))),!F&&__classPrivateFieldGet(this,sm,`f`).skipValidation.length>0&&(F=Object.keys(q).some(t=>__classPrivateFieldGet(this,sm,`f`).skipValidation.indexOf(t)>=0&&q[t]===!0)),!F){if(W.error)throw new Bl(W.error.message);if(!ne){let t=this[rh](X,{},W.error);S||(Y=applyMiddleware(q,this,__classPrivateFieldGet(this,$p,`f`).getMiddleware(),!0)),Y=this[Um](t,Y??q),isPromise(Y)&&!S&&(Y=Y.then(()=>applyMiddleware(q,this,__classPrivateFieldGet(this,$p,`f`).getMiddleware(),!1)))}}}catch(t){if(t instanceof Bl)__classPrivateFieldGet(this,bm,`f`).fail(t.message,t);else throw t}return this[$m](Y??q,I,!!S,!0)}[rh](t,n,S,C){let N={...this.getDemandedOptions()};return F=>{if(S)throw new Bl(S.message);__classPrivateFieldGet(this,Cm,`f`).nonOptionCount(F),__classPrivateFieldGet(this,Cm,`f`).requiredArguments(F,N);let I=!1;__classPrivateFieldGet(this,vm,`f`)&&(I=__classPrivateFieldGet(this,Cm,`f`).unknownCommands(F)),__classPrivateFieldGet(this,_m,`f`)&&!I?__classPrivateFieldGet(this,Cm,`f`).unknownArguments(F,t,n,!!C):__classPrivateFieldGet(this,ym,`f`)&&__classPrivateFieldGet(this,Cm,`f`).unknownArguments(F,t,{},!1,!1),__classPrivateFieldGet(this,Cm,`f`).limitedChoices(F),__classPrivateFieldGet(this,Cm,`f`).implications(F),__classPrivateFieldGet(this,Cm,`f`).conflicting(F)}}[ih](){__classPrivateFieldSet(this,tm,!0,`f`)}[ah](t){if(typeof t==`string`)__classPrivateFieldGet(this,sm,`f`).key[t]=!0;else for(let n of t)__classPrivateFieldGet(this,sm,`f`).key[n]=!0}}}),ch,lh=__esmMin(()=>{Sp(),sh(),ch=YargsFactory(xp)});function classifyCliFailure(t,n){return typeof t==`string`&&t.length>0?{kind:`usage`,message:t}:{kind:`runtime`}}var uh=__esmMin(()=>{});function buildHeaders(t,n){let S={"user-agent":`gjsify-install/0.64.50`,"accept-encoding":n.acceptEncoding??`identity`};if(n.npmrc){let C=resolveAuthForUrl(t,n.npmrc);C&&(S.authorization=C)}if(n.headers)for(let[t,C]of Object.entries(n.headers))S[t.toLowerCase()]=C;return S}function resolveAuthForUrl(t,n){let S=pathPrefixes(new URL(t));for(let t of S){let S=n.authTokens[t];if(S)return`Bearer ${S}`;let C=n.basicAuth[t];if(C)return`Basic ${btoa(`${C.username}:${C.password}`)}`}return null}function pathPrefixes(t){let n=t.pathname.split(`/`).filter(Boolean),S=[];for(let C=n.length;C>=0;C--){let N=n.slice(0,C).join(`/`);S.push(N?`//${t.host}/${N}`:`//${t.host}`)}return S}var dh=__esmMin(()=>{}),PackageNotFoundError,IntegrityError,RegistryTimeoutError,RegistryUnreachableError,fh=__esmMin(()=>{PackageNotFoundError=class extends Error{name;url;constructor(t,n){super(`Package not found in registry: ${t} (${n})`),this.name=t,this.url=n,this.name=`PackageNotFoundError`}},IntegrityError=class extends Error{url;integrity;constructor(t,n){super(`Tarball integrity mismatch for ${t} (expected ${n})`),this.url=t,this.integrity=n,this.name=`IntegrityError`}},RegistryTimeoutError=class extends Error{url;timeoutMs;attempts;constructor(t,n,S){let C=Math.round(n/100)/10,N=Math.round(n*S/100)/10;super(`@gjsify/npm-registry: GET ${t} timed out after ${C}s × ${S} attempt(s) (total ~${N}s). This usually means the registry CDN is slow or unreachable.`),this.url=t,this.timeoutMs=n,this.attempts=S,this.name=`RegistryTimeoutError`}},RegistryUnreachableError=class extends Error{url;attempts;elapsedMs;constructor(t,n,S,C){let N=Math.round(S/100)/10,F=C instanceof Error?C.message:String(C);super(`@gjsify/npm-registry: GET ${t} failed after ${n} attempt(s) over ~${N}s: ${F}. This usually means the registry or the network dropped out.`),this.url=t,this.attempts=n,this.elapsedMs=S,this.name=`RegistryUnreachableError`,this.cause=C}}});function registryFor(t,n){if(n&&t.startsWith(`@`)){let S=t.slice(0,t.indexOf(`/`)),C=n.scopes[S];if(C)return ensureTrailingSlash$1(C)}return n?.registry?ensureTrailingSlash$1(n.registry):ph}function parseNpmrc(t){let n={registry:ph,scopes:{},authTokens:{},basicAuth:{}},S=t.split(/\r?\n/),C={};for(let t of S){let S=t.replace(/^\s+|\s+$/g,``);if(!S||S.startsWith(`#`)||S.startsWith(`;`))continue;let N=S.indexOf(`=`);if(N<0)continue;let F=S.slice(0,N).trim(),I=expandEnv(stripQuotes(S.slice(N+1).trim()));if(F===`registry`){n.registry=ensureTrailingSlash$1(I);continue}let H=F.match(/^(@[^:]+):registry$/);if(H){n.scopes[H[1]]=ensureTrailingSlash$1(I);continue}let W=F.match(/^\/\/(.+):_authToken$/);if(W){n.authTokens[normalizeAuthHost(W[1])]=I;continue}let q=F.match(/^\/\/(.+):username$/);if(q){(C[normalizeAuthHost(q[1])]??={}).user=I;continue}let Y=F.match(/^\/\/(.+):_password$/);if(Y){let t=base64Decode$1(I);(C[normalizeAuthHost(Y[1])]??={}).pass=t;continue}}for(let[t,S]of Object.entries(C))S.user&&S.pass!==void 0&&(n.basicAuth[t]={username:S.user,password:S.pass});return n}function normalizeAuthHost(t){return`//${t.replace(/\/+$/,``)}`}function ensureTrailingSlash$1(t){return t.endsWith(`/`)?t:t+`/`}function stripQuotes(t){return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1):t}function expandEnv(t){return t.replace(/\$\{([A-Z0-9_]+)\}/gi,(t,n)=>globalThis.process?.env?.[n]??``)}function base64Decode$1(t){return atob(t)}var ph,mh=__esmMin(()=>{ph=`https://registry.npmjs.org/`,__name$1(ensureTrailingSlash$1,`ensureTrailingSlash`),__name$1(base64Decode$1,`base64Decode`)});async function fetchWithRetry(t,n,S){let C=S.fetch??globalThis.fetch;if(!C)throw Error(`@gjsify/npm-registry: globalThis.fetch is missing`);let N=Math.max(0,S.retries??5),F=Math.max(0,S.retryDelayMs??1e3),I=Math.max(0,S.timeoutMs??3e4),H=S.retryNotFound??!1,W=Date.now(),q=0,Y,X=0;for(;;){if(n.signal?.aborted)throw signalAbortError(n.signal);let Z=I>0?new AbortController:null,te=Z===null?null:setTimeout(()=>Z.abort(Error(`@gjsify/npm-registry: per-request timeout ${I}ms`)),I),ne=composeSignals(n.signal,Z?.signal);try{let F=await C(t,{...n,signal:ne}),I=isRetryableStatus(F.status)||H&&F.status===404;if(F.ok||!I||q>=N)return S.read?await S.read(F):F;try{await F.arrayBuffer()}catch{}Y=Error(`HTTP ${F.status} ${F.statusText}`)}catch(S){let C=Z!==null&&Z.signal.aborted,F=n.signal?.aborted===!0;if(C&&!F){if(X++,q>=N)throw new RegistryTimeoutError(t,I,X);Y=S}else if(F)throw signalAbortError(n.signal);else{if(!isRetryableError(S))throw S;if(q>=N)throw new RegistryUnreachableError(t,q+1,Date.now()-W,S);Y=S}}finally{te!==null&&clearTimeout(te)}let re=Math.min(F*2**q,8e3);S.onRetry?.({attempt:q+1,error:Y,delayMs:re}),await delay$1(re,n.signal),q++}}function composeSignals(t,n){return t?n?AbortSignal.any([t,n]):t:n}function isRetryableStatus(t){return t===408||t===425||t===429||t===500||t===502||t===503||t===504||t===521||t===522||t===524||t===525}function isRetryableError(t){if(t&&typeof t==`object`&&`name`in t&&t.name===`AbortError`)return!1;if(t instanceof TypeError)return!0;if(t&&typeof t==`object`&&`name`in t){let n=t.name;if(n===`FetchError`)return!0;if(n===`AbortError`)return!1}let n=t?.cause;if(n&&typeof n==`object`&&`code`in n){let t=n.code;if(typeof t==`string`)return t===`ECONNRESET`||t===`ECONNREFUSED`||t===`ENETUNREACH`||t===`ENOTFOUND`||t===`ETIMEDOUT`||t===`EAI_AGAIN`||t===`UND_ERR_SOCKET`||t===`UND_ERR_CONNECT_TIMEOUT`}return!1}function delay$1(t,n){return t<=0?Promise.resolve():new Promise((S,C)=>{let N=setTimeout(()=>{n?.removeEventListener?.(`abort`,onAbort),S()},t),onAbort=()=>{clearTimeout(N),C(signalAbortError(n))};if(n?.aborted){clearTimeout(N),C(signalAbortError(n));return}n?.addEventListener?.(`abort`,onAbort,{once:!0})})}function signalAbortError(t){let n=t&&`reason`in t?t.reason:void 0;if(n instanceof Error)return n;let S=Error(`Aborted`);return S.name=`AbortError`,S}var hh=__esmMin(()=>{fh(),__name$1(delay$1,`delay`)});async function verifyIntegrity(t,n){let S=n.trim().split(/\s+/);for(let n of S){let S=n.indexOf(`-`);if(S<0)continue;let C=n.slice(0,S).toLowerCase(),N=n.slice(S+1),F=globalThis.crypto?.subtle;if(!F)throw Error(`@gjsify/npm-registry: globalThis.crypto.subtle is missing`);let I=subriToWebCryptoAlgo(C);if(!I)continue;let H=await F.digest(I,dataAsArrayBuffer(t));if(bytesToBase64(new Uint8Array(H))===N)return!0}return!1}function subriToWebCryptoAlgo(t){switch(t){case`sha1`:return`SHA-1`;case`sha256`:return`SHA-256`;case`sha384`:return`SHA-384`;case`sha512`:return`SHA-512`;default:return null}}function dataAsArrayBuffer(t){if(t.byteOffset===0&&t.byteLength===t.buffer.byteLength)return t.buffer;let n=new Uint8Array(t.byteLength);return n.set(t),n.buffer}function bytesToBase64(t){let n=``;for(let S=0;S<t.length;S++)n+=String.fromCharCode(t[S]);return btoa(n)}var gh=__esmMin(()=>{});function assertPackument(t,n){if(!n||typeof n!=`object`)throw TypeError(`registry: ${t} packument is not an object`);let S=n;if(typeof S.name!=`string`)throw TypeError(`registry: ${t} packument missing string name`);if(!S.versions||typeof S.versions!=`object`)throw TypeError(`registry: ${t} packument missing versions map`)}function packumentUrl(t,n){let S=ensureTrailingSlash$1(n);if(t.startsWith(`@`)){let n=t.indexOf(`/`);if(n<0)throw TypeError(`Invalid scoped package name: ${t}`);let C=t.slice(0,n),N=t.slice(n+1);return`${S}${encodeURIComponent(C)}/${encodeURIComponent(N)}`}return`${S}${encodeURIComponent(t)}`}async function fetchPackumentConditional(t,n={}){let S=packumentUrl(t,n.registry??registryFor(t,n.npmrc)),C=buildHeaders(S,{...n,acceptEncoding:`gzip`});C.accept??=n.fullMetadata?`application/json`:`application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*`,n.ifNoneMatch&&(C[`if-none-match`]=n.ifNoneMatch);let N=await fetchWithRetry(S,{headers:C,signal:n.signal},{fetch:n.fetch,retries:n.retries,retryDelayMs:n.retryDelayMs,timeoutMs:n.timeoutMs,onRetry:n.onRetry,read:async n=>{if(n.status===304){try{await n.arrayBuffer()}catch{}return{status:`not-modified`}}if(!n.ok)throw n.status===404||n.status===406?new PackageNotFoundError(t,S):Error(`registry GET ${S} -> ${n.status} ${n.statusText}`);return{status:`fresh`,body:await decodeJsonBody(n),etag:n.headers.get(`etag`)??void 0}}});if(N.status===`not-modified`)return{status:`not-modified`,etag:n.ifNoneMatch};let F=N.body;return assertPackument(t,F),{status:`fresh`,packument:F,etag:N.etag}}async function decodeJsonBody(t){return t.json()}async function fetchPackument(t,n={}){let S=await fetchPackumentConditional(t,n);if(!S.packument)throw Error(`registry: ${t} returned 304 Not Modified to an unconditional request`);return S.packument}var vh=__esmMin(()=>{dh(),fh(),mh(),hh()});async function fetchTarball(t,n={}){let S=buildHeaders(t,{...n,acceptEncoding:`identity`});S.accept??=`application/octet-stream`;let C=await fetchWithRetry(t,{headers:S,signal:n.signal},{fetch:n.fetch,retries:n.retries,retryDelayMs:n.retryDelayMs,timeoutMs:n.timeoutMs,onRetry:n.onRetry,retryNotFound:n.retryNotFound??!0,read:async n=>{if(!n.ok)throw Error(`tarball GET ${t} -> ${n.status} ${n.statusText}`);return new Uint8Array(await n.arrayBuffer())}});if(n.integrity&&!await verifyIntegrity(C,n.integrity))throw new IntegrityError(t,n.integrity);return C}var yh=__esmMin(()=>{dh(),fh(),hh(),gh()});async function whoami(t,n){let S=`${ensureTrailingSlash$1(t)}-/whoami`,C=buildHeaders(S,{npmrc:n});C.accept=`application/json`;let N=globalThis.fetch;if(!N)throw Error(`@gjsify/npm-registry: globalThis.fetch is missing`);let F=await N(S,{method:`GET`,headers:C});if(!F.ok)throw Error(`whoami GET ${S} -> ${F.status} ${F.statusText}`);let I=await F.json();if(I&&typeof I==`object`&&`username`in I){let t=I.username;if(typeof t==`string`&&t.length>0)return{username:t}}return{}}var bh=__esmMin(()=>{dh(),mh()}),xh=__esmMin(()=>{dh(),fh(),mh(),gh(),vh(),yh(),bh()});function escapePackageName(t){return t.replace(`/`,`%2f`)}function buildPublishHeaders(t,n){let S=buildHeaders(t,{npmrc:n.npmrc});return S[`content-type`]=`application/json`,S[`npm-command`]=`publish`,S[`npm-auth-type`]=n.otp?`legacy`:`web`,S[`user-agent`]=n.userAgent??defaultUserAgent(),n.otp&&(S[`npm-otp`]=n.otp),n.authorization&&(S.authorization=n.authorization),S}function cliVersion(){return Sh===void 0&&(Sh=`0.64.50`),Sh}function cliPackageDir(){let t=globalThis.process?.env?.GJSIFY_CLI_PACKAGE_JSON,n;try{n=Hn(t||fileURLToPath(import.meta.url))}catch{return null}for(let t=0;t<12;t++){try{if(JSON.parse(readFileSync(`${n}/package.json`,`utf8`)).name===`@gjsify/cli`)return n}catch{}let t=Hn(n);if(t===n)break;n=t}return null}function defaultUserAgent(){let t=globalThis.process,n=t?.arch??`x64`,S=t?.platform??`linux`;return`gjsify-publish/${cliVersion()} (${S} ${n})`}var Sh,Ch=__esmMin(()=>{af(),Xn(),cr(),xh()}),wh,Th=__esmMin(()=>{wh=`gjsify`});function parseDeclaredChannel(t,n){if(!(t===void 0||t===``)){if(Eh.includes(t))return t;throw Error(`${n}: "${String(t)}" is not a distribution channel. Known: ${Eh.join(`, `)}.`)}}function channelAllowsDonations(t){return t!==void 0&&Dh[t]===`external-link`}var Eh,Dh,Oh,kh=__esmMin(()=>{Eh=[`flathub`,`web`,`microsoft-store`,`apple-app-store`],Dh={flathub:`external-link`,web:`external-link`,"microsoft-store":`none`,"apple-app-store":`store-purchase`},Oh=`GJSIFY_CHANNEL`});function parseDeclaredPricing(t,n){if(!(t===void 0||t===``)){if(Ah.includes(t))return t;throw Error(`${n}: "${String(t)}" is not a pricing tier. Known: ${Ah.join(`, `)}.`)}}var Ah,jh,Mh=__esmMin(()=>{Ah=[`free`,`paid`],jh=`GJSIFY_PRICING`}),Nh=__commonJSMin(((t,n)=>{let S=(Xn(),__toCommonJS(Pn)),C=(eu(),__toCommonJS(Xl)),N=(af(),__toCommonJS(nf)),resolveFrom=(t,n,F)=>{if(typeof t!=`string`)throw TypeError(`Expected \`fromDir\` to be of type \`string\`, got \`${typeof t}\``);if(typeof n!=`string`)throw TypeError(`Expected \`moduleId\` to be of type \`string\`, got \`${typeof n}\``);try{t=N.realpathSync(t)}catch(n){if(n.code===`ENOENT`)t=S.resolve(t);else if(F)return null;else throw n}let I=S.join(t,`noop.js`),resolveFileName=()=>C._resolveFilename(n,{id:I,filename:I,paths:C._nodeModulePaths(t)});if(F)try{return resolveFileName()}catch{return null}return resolveFileName()};n.exports=(t,n)=>resolveFrom(t,n),n.exports.silent=(t,n)=>resolveFrom(t,n,!0)})),Ph=__commonJSMin(((t,n)=>{let callsites=()=>{let t=Error.prepareStackTrace;Error.prepareStackTrace=(t,n)=>n;let n=Error().stack.slice(1);return Error.prepareStackTrace=t,n};n.exports=callsites,n.exports.default=callsites})),Fh=__commonJSMin(((t,n)=>{let S=Ph();n.exports=t=>{let n=S();if(!t)return n[2].getFileName();let C=!1;n.shift();for(let S of n){let n=S.getFileName();if(typeof n==`string`){if(n===t){C=!0;continue}if(n!==`module.js`&&C&&n!==t)return n}}}})),Ih=__commonJSMin(((t,n)=>{var{__gjsifyModuleDir:S,__gjsifyModuleFile:C}=(iu(),__toCommonJS(tu)),N=S(`import-fresh/index.js`),F=C(`import-fresh/index.js`);let I=(Xn(),__toCommonJS(Pn)),H=Nh(),W=Fh();n.exports=t=>{if(typeof t!=`string`)throw TypeError(`Expected a string`);let n=W(F),S=n?I.dirname(n):N,C=H(S,t),q=Y.cache[C];if(q&&q.parent){let t=q.parent.children.length;for(;t--;)q.parent.children[t].id===C&&q.parent.children.splice(t,1)}delete Y.cache[C];let X=Y.cache[n];return X===void 0||X.require===void 0?Y(C):X.require(C)}})),Lh=__commonJSMin(((t,n)=>{n.exports=function isArrayish(t){return t?t instanceof Array||Array.isArray(t)||t.length>=0&&t.splice instanceof Function:!1}})),Rh=__commonJSMin(((t,n)=>{var S=(Uu(),__toCommonJS(zu)),C=Lh(),N=function errorEx(t,n){(!t||t.constructor!==String)&&(n=t||{},t=Error.name);var N=function ErrorEXError(S){if(!this)return new ErrorEXError(S);S=S instanceof Error?S.message:S||this.message,Error.call(this,S),Error.captureStackTrace(this,N),this.name=t,Object.defineProperty(this,"message",{configurable:!0,enumerable:!1,get:function(){var t=S.split(/\r?\n/g);for(var N in n)if(n.hasOwnProperty(N)){var F=n[N];`message`in F&&(t=F.message(this[N],t)||t,C(t)||(t=[t]))}return t.join(`
149
+ `,`f`),__classPrivateFieldSet(this,om,__classPrivateFieldGet(this,om,`f`)+t.join(` `),`f`)}}}[Em](t){objectKeys(__classPrivateFieldGet(this,sm,`f`)).forEach(n=>{if((t=>t===`configObjects`)(n))return;let S=__classPrivateFieldGet(this,sm,`f`)[n];Array.isArray(S)?S.includes(t)&&S.splice(S.indexOf(t),1):typeof S==`object`&&delete S[t]}),delete __classPrivateFieldGet(this,bm,`f`).getDescriptions()[t]}[Dm](t,n,S){__classPrivateFieldGet(this,Xp,`f`)[S]||(__classPrivateFieldGet(this,gm,`f`).process.emitWarning(t,n),__classPrivateFieldGet(this,Xp,`f`)[S]=!0)}[Om](){__classPrivateFieldGet(this,Qp,`f`).push({options:__classPrivateFieldGet(this,sm,`f`),configObjects:__classPrivateFieldGet(this,sm,`f`).configObjects.slice(0),exitProcess:__classPrivateFieldGet(this,Zp,`f`),groups:__classPrivateFieldGet(this,em,`f`),strict:__classPrivateFieldGet(this,_m,`f`),strictCommands:__classPrivateFieldGet(this,vm,`f`),strictOptions:__classPrivateFieldGet(this,ym,`f`),completionCommand:__classPrivateFieldGet(this,Kp,`f`),output:__classPrivateFieldGet(this,om,`f`),exitError:__classPrivateFieldGet(this,Jp,`f`),hasOutput:__classPrivateFieldGet(this,tm,`f`),parsed:this.parsed,parseFn:__classPrivateFieldGet(this,um,`f`),parseContext:__classPrivateFieldGet(this,dm,`f`)}),__classPrivateFieldGet(this,bm,`f`).freeze(),__classPrivateFieldGet(this,Cm,`f`).freeze(),__classPrivateFieldGet(this,Hp,`f`).freeze(),__classPrivateFieldGet(this,$p,`f`).freeze()}[km](){let t=``,n;return n=/\b(node|iojs|electron)(\.exe)?$/.test(__classPrivateFieldGet(this,gm,`f`).process.argv()[0])?__classPrivateFieldGet(this,gm,`f`).process.argv().slice(1,2):__classPrivateFieldGet(this,gm,`f`).process.argv().slice(0,1),t=n.map(t=>{let n=this[eh](__classPrivateFieldGet(this,Up,`f`),t);return t.match(/^(\/|([a-zA-Z]:)?\\)/)&&n.length<t.length?n:t}).join(` `).trim(),__classPrivateFieldGet(this,gm,`f`).getEnv(`_`)&&__classPrivateFieldGet(this,gm,`f`).getProcessArgvBin()===__classPrivateFieldGet(this,gm,`f`).getEnv(`_`)&&(t=__classPrivateFieldGet(this,gm,`f`).getEnv(`_`).replace(`${__classPrivateFieldGet(this,gm,`f`).path.dirname(__classPrivateFieldGet(this,gm,`f`).process.execPath())}/`,``)),t}[Am](){return __classPrivateFieldGet(this,lm,`f`)}[jm](){return __classPrivateFieldGet(this,xm,`f`)}[Mm](){if(!__classPrivateFieldGet(this,Yp,`f`))return;let t=__classPrivateFieldGet(this,gm,`f`).getEnv(`LC_ALL`)||__classPrivateFieldGet(this,gm,`f`).getEnv(`LC_MESSAGES`)||__classPrivateFieldGet(this,gm,`f`).getEnv(`LANG`)||__classPrivateFieldGet(this,gm,`f`).getEnv(`LANGUAGE`)||`en_US`;this.locale(t.replace(/[.:].*/,``))}[Nm](){return this[Fm]().version||`unknown`}[Pm](t){let n=t[`--`]?t[`--`]:t._;for(let t=0,S;(S=n[t])!==void 0;t++)__classPrivateFieldGet(this,gm,`f`).Parser.looksLikeNumber(S)&&Number.isSafeInteger(Math.floor(parseFloat(`${S}`)))&&(n[t]=Number(S));return t}[Fm](t){let n=t||`*`;if(__classPrivateFieldGet(this,fm,`f`)[n])return __classPrivateFieldGet(this,fm,`f`)[n];let S={};try{let n=t||__classPrivateFieldGet(this,gm,`f`).mainFilename;__classPrivateFieldGet(this,gm,`f`).path.extname(n)&&(n=__classPrivateFieldGet(this,gm,`f`).path.dirname(n));let C=__classPrivateFieldGet(this,gm,`f`).findUp(n,(t,n)=>{if(n.includes(`package.json`))return`package.json`});assertNotStrictEqual(C,void 0,__classPrivateFieldGet(this,gm,`f`)),S=JSON.parse(__classPrivateFieldGet(this,gm,`f`).readFileSync(C,`utf8`))}catch{}return __classPrivateFieldGet(this,fm,`f`)[n]=S||{},__classPrivateFieldGet(this,fm,`f`)[n]}[Im](t,n){n=[].concat(n),n.forEach(n=>{n=this[Bm](n),__classPrivateFieldGet(this,sm,`f`)[t].push(n)})}[Lm](t,n,S,C){this[zm](t,n,S,C,(t,n,S)=>{__classPrivateFieldGet(this,sm,`f`)[t][n]=S})}[Rm](t,n,S,C){this[zm](t,n,S,C,(t,n,S)=>{__classPrivateFieldGet(this,sm,`f`)[t][n]=(__classPrivateFieldGet(this,sm,`f`)[t][n]||[]).concat(S)})}[zm](t,n,S,C,N){if(Array.isArray(S))S.forEach(n=>{t(n,C)});else if((t=>typeof t==`object`)(S))for(let n of objectKeys(S))t(n,S[n]);else N(n,this[Bm](S),C)}[Bm](t){return t===`__proto__`?`___proto___`:t}[Vm](t,n){return this[Lm](this[Vm].bind(this),`key`,t,n),this}[Hm](){var t,n,S,C,N,F,I,H,W,q,Y,X;let Z=__classPrivateFieldGet(this,Qp,`f`).pop();assertNotStrictEqual(Z,void 0,__classPrivateFieldGet(this,gm,`f`));let te;t=this,n=this,S=this,C=this,N=this,F=this,I=this,H=this,W=this,q=this,Y=this,X=this,{options:{set value(n){__classPrivateFieldSet(t,sm,n,`f`)}}.value,configObjects:te,exitProcess:{set value(t){__classPrivateFieldSet(n,Zp,t,`f`)}}.value,groups:{set value(t){__classPrivateFieldSet(S,em,t,`f`)}}.value,output:{set value(t){__classPrivateFieldSet(C,om,t,`f`)}}.value,exitError:{set value(t){__classPrivateFieldSet(N,Jp,t,`f`)}}.value,hasOutput:{set value(t){__classPrivateFieldSet(F,tm,t,`f`)}}.value,parsed:this.parsed,strict:{set value(t){__classPrivateFieldSet(I,_m,t,`f`)}}.value,strictCommands:{set value(t){__classPrivateFieldSet(H,vm,t,`f`)}}.value,strictOptions:{set value(t){__classPrivateFieldSet(W,ym,t,`f`)}}.value,completionCommand:{set value(t){__classPrivateFieldSet(q,Kp,t,`f`)}}.value,parseFn:{set value(t){__classPrivateFieldSet(Y,um,t,`f`)}}.value,parseContext:{set value(t){__classPrivateFieldSet(X,dm,t,`f`)}}.value}=Z,__classPrivateFieldGet(this,sm,`f`).configObjects=te,__classPrivateFieldGet(this,bm,`f`).unfreeze(),__classPrivateFieldGet(this,Cm,`f`).unfreeze(),__classPrivateFieldGet(this,Hp,`f`).unfreeze(),__classPrivateFieldGet(this,$p,`f`).unfreeze()}[Um](t,n){return maybeAsyncResult(n,n=>(t(n),n))}getInternalMethods(){return{getCommandInstance:this[Wm].bind(this),getContext:this[Gm].bind(this),getHasOutput:this[Km].bind(this),getLoggerInstance:this[qm].bind(this),getParseContext:this[Jm].bind(this),getParserConfiguration:this[Am].bind(this),getUsageConfiguration:this[jm].bind(this),getUsageInstance:this[Ym].bind(this),getValidationInstance:this[Xm].bind(this),hasParseCallback:this[Zm].bind(this),isGlobalContext:this[Qm].bind(this),postProcess:this[$m].bind(this),reset:this[th].bind(this),runValidation:this[rh].bind(this),runYargsParserAndExecuteCommands:this[nh].bind(this),setHasOutput:this[ih].bind(this)}}[Wm](){return __classPrivateFieldGet(this,Hp,`f`)}[Gm](){return __classPrivateFieldGet(this,Wp,`f`)}[Km](){return __classPrivateFieldGet(this,tm,`f`)}[qm](){return __classPrivateFieldGet(this,am,`f`)}[Jm](){return __classPrivateFieldGet(this,dm,`f`)||{}}[Ym](){return __classPrivateFieldGet(this,bm,`f`)}[Xm](){return __classPrivateFieldGet(this,Cm,`f`)}[Zm](){return!!__classPrivateFieldGet(this,um,`f`)}[Qm](){return __classPrivateFieldGet(this,im,`f`)}[$m](t,n,S,C){return S||isPromise(t)?t:(n||(t=this[wm](t)),(this[Am]()[`parse-positional-numbers`]||this[Am]()[`parse-positional-numbers`]===void 0)&&(t=this[Pm](t)),C&&(t=applyMiddleware(t,this,__classPrivateFieldGet(this,$p,`f`).getMiddleware(),!1)),t)}[th](t={}){__classPrivateFieldSet(this,sm,__classPrivateFieldGet(this,sm,`f`)||{},`f`);let n={};n.local=__classPrivateFieldGet(this,sm,`f`).local||[],n.configObjects=__classPrivateFieldGet(this,sm,`f`).configObjects||[];let S={};return n.local.forEach(n=>{S[n]=!0,(t[n]||[]).forEach(t=>{S[t]=!0})}),Object.assign(__classPrivateFieldGet(this,pm,`f`),Object.keys(__classPrivateFieldGet(this,em,`f`)).reduce((t,n)=>{let C=__classPrivateFieldGet(this,em,`f`)[n].filter(t=>!(t in S));return C.length>0&&(t[n]=C),t},{})),__classPrivateFieldSet(this,em,{},`f`),[`array`,`boolean`,`string`,`skipValidation`,`count`,`normalize`,`number`,`hiddenOptions`].forEach(t=>{n[t]=(__classPrivateFieldGet(this,sm,`f`)[t]||[]).filter(t=>!S[t])}),[`narg`,`key`,`alias`,`default`,`defaultDescription`,`config`,`choices`,`demandedOptions`,`demandedCommands`,`deprecatedOptions`].forEach(t=>{n[t]=objFilter(__classPrivateFieldGet(this,sm,`f`)[t],t=>!S[t])}),n.envPrefix=__classPrivateFieldGet(this,sm,`f`).envPrefix,__classPrivateFieldSet(this,sm,n,`f`),__classPrivateFieldSet(this,bm,__classPrivateFieldGet(this,bm,`f`)?__classPrivateFieldGet(this,bm,`f`).reset(S):usage(this,__classPrivateFieldGet(this,gm,`f`)),`f`),__classPrivateFieldSet(this,Cm,__classPrivateFieldGet(this,Cm,`f`)?__classPrivateFieldGet(this,Cm,`f`).reset(S):validation(this,__classPrivateFieldGet(this,bm,`f`),__classPrivateFieldGet(this,gm,`f`)),`f`),__classPrivateFieldSet(this,Hp,__classPrivateFieldGet(this,Hp,`f`)?__classPrivateFieldGet(this,Hp,`f`).reset():command(__classPrivateFieldGet(this,bm,`f`),__classPrivateFieldGet(this,Cm,`f`),__classPrivateFieldGet(this,$p,`f`),__classPrivateFieldGet(this,gm,`f`)),`f`),__classPrivateFieldGet(this,Gp,`f`)||__classPrivateFieldSet(this,Gp,completion(this,__classPrivateFieldGet(this,bm,`f`),__classPrivateFieldGet(this,Hp,`f`),__classPrivateFieldGet(this,gm,`f`)),`f`),__classPrivateFieldGet(this,$p,`f`).reset(),__classPrivateFieldSet(this,Kp,null,`f`),__classPrivateFieldSet(this,om,``,`f`),__classPrivateFieldSet(this,Jp,null,`f`),__classPrivateFieldSet(this,tm,!1,`f`),this.parsed=!1,this}[eh](t,n){return __classPrivateFieldGet(this,gm,`f`).path.relative(t,n)}[nh](t,n,S,C=0,N=!1){let F=!!S||N;t||=__classPrivateFieldGet(this,mm,`f`),__classPrivateFieldGet(this,sm,`f`).__=__classPrivateFieldGet(this,gm,`f`).y18n.__,__classPrivateFieldGet(this,sm,`f`).configuration=this[Am]();let I=!!__classPrivateFieldGet(this,sm,`f`).configuration[`populate--`],H=Object.assign({},__classPrivateFieldGet(this,sm,`f`).configuration,{"populate--":!0}),W=__classPrivateFieldGet(this,gm,`f`).Parser.detailed(t,Object.assign({},__classPrivateFieldGet(this,sm,`f`),{configuration:{"parse-positional-numbers":!1,...H}})),q=Object.assign(W.argv,__classPrivateFieldGet(this,dm,`f`)),Y,X=W.aliases,Z=!1,te=!1;Object.keys(q).forEach(t=>{t===__classPrivateFieldGet(this,nm,`f`)&&q[t]?Z=!0:t===__classPrivateFieldGet(this,Sm,`f`)&&q[t]&&(te=!0)}),q.$0=this.$0,this.parsed=W,C===0&&__classPrivateFieldGet(this,bm,`f`).clearCachedHelpMessage();try{if(this[Mm](),n)return this[$m](q,I,!!S,!1);__classPrivateFieldGet(this,nm,`f`)&&[__classPrivateFieldGet(this,nm,`f`)].concat(X[__classPrivateFieldGet(this,nm,`f`)]||[]).filter(t=>t.length>1).includes(``+q._[q._.length-1])&&(q._.pop(),Z=!0),__classPrivateFieldSet(this,im,!1,`f`);let H=__classPrivateFieldGet(this,Hp,`f`).getCommands(),ne=__classPrivateFieldGet(this,Gp,`f`)?.completionKey?[__classPrivateFieldGet(this,Gp,`f`)?.completionKey,...this.getAliases()[__classPrivateFieldGet(this,Gp,`f`)?.completionKey]??[]].some(t=>Object.prototype.hasOwnProperty.call(q,t)):!1,re=Z||ne||N;if(q._.length){if(H.length){let t;for(let n=C||0,F;q._[n]!==void 0;n++)if(F=String(q._[n]),H.includes(F)&&F!==__classPrivateFieldGet(this,Kp,`f`)){let t=__classPrivateFieldGet(this,Hp,`f`).runCommand(F,this,W,n+1,N,Z||te||N);return this[$m](t,I,!!S,!1)}else if(!t&&F!==__classPrivateFieldGet(this,Kp,`f`)){t=F;break}!__classPrivateFieldGet(this,Hp,`f`).hasDefaultCommand()&&__classPrivateFieldGet(this,hm,`f`)&&t&&!re&&__classPrivateFieldGet(this,Cm,`f`).recommendCommands(t,H)}__classPrivateFieldGet(this,Kp,`f`)&&q._.includes(__classPrivateFieldGet(this,Kp,`f`))&&!ne&&(__classPrivateFieldGet(this,Zp,`f`)&&setBlocking(!0),this.showCompletionScript(),this.exit(0))}if(__classPrivateFieldGet(this,Hp,`f`).hasDefaultCommand()&&!re){let t=__classPrivateFieldGet(this,Hp,`f`).runCommand(null,this,W,0,N,Z||te||N);return this[$m](t,I,!!S,!1)}if(ne){__classPrivateFieldGet(this,Zp,`f`)&&setBlocking(!0),t=[].concat(t);let n=t.slice(t.indexOf(`--${__classPrivateFieldGet(this,Gp,`f`).completionKey}`)+1);return __classPrivateFieldGet(this,Gp,`f`).getCompletion(n,(t,n)=>{if(t)throw new Bl(t.message);(n||[]).forEach(t=>{__classPrivateFieldGet(this,am,`f`).log(t)}),this.exit(0)}),this[$m](q,!I,!!S,!1)}if(__classPrivateFieldGet(this,tm,`f`)||(Z?(__classPrivateFieldGet(this,Zp,`f`)&&setBlocking(!0),F=!0,this.showHelp(t=>{__classPrivateFieldGet(this,am,`f`).log(t),this.exit(0)})):te&&(__classPrivateFieldGet(this,Zp,`f`)&&setBlocking(!0),F=!0,__classPrivateFieldGet(this,bm,`f`).showVersion(`log`),this.exit(0))),!F&&__classPrivateFieldGet(this,sm,`f`).skipValidation.length>0&&(F=Object.keys(q).some(t=>__classPrivateFieldGet(this,sm,`f`).skipValidation.indexOf(t)>=0&&q[t]===!0)),!F){if(W.error)throw new Bl(W.error.message);if(!ne){let t=this[rh](X,{},W.error);S||(Y=applyMiddleware(q,this,__classPrivateFieldGet(this,$p,`f`).getMiddleware(),!0)),Y=this[Um](t,Y??q),isPromise(Y)&&!S&&(Y=Y.then(()=>applyMiddleware(q,this,__classPrivateFieldGet(this,$p,`f`).getMiddleware(),!1)))}}}catch(t){if(t instanceof Bl)__classPrivateFieldGet(this,bm,`f`).fail(t.message,t);else throw t}return this[$m](Y??q,I,!!S,!0)}[rh](t,n,S,C){let N={...this.getDemandedOptions()};return F=>{if(S)throw new Bl(S.message);__classPrivateFieldGet(this,Cm,`f`).nonOptionCount(F),__classPrivateFieldGet(this,Cm,`f`).requiredArguments(F,N);let I=!1;__classPrivateFieldGet(this,vm,`f`)&&(I=__classPrivateFieldGet(this,Cm,`f`).unknownCommands(F)),__classPrivateFieldGet(this,_m,`f`)&&!I?__classPrivateFieldGet(this,Cm,`f`).unknownArguments(F,t,n,!!C):__classPrivateFieldGet(this,ym,`f`)&&__classPrivateFieldGet(this,Cm,`f`).unknownArguments(F,t,{},!1,!1),__classPrivateFieldGet(this,Cm,`f`).limitedChoices(F),__classPrivateFieldGet(this,Cm,`f`).implications(F),__classPrivateFieldGet(this,Cm,`f`).conflicting(F)}}[ih](){__classPrivateFieldSet(this,tm,!0,`f`)}[ah](t){if(typeof t==`string`)__classPrivateFieldGet(this,sm,`f`).key[t]=!0;else for(let n of t)__classPrivateFieldGet(this,sm,`f`).key[n]=!0}}}),ch,lh=__esmMin(()=>{Sp(),sh(),ch=YargsFactory(xp)});function classifyCliFailure(t,n){return typeof t==`string`&&t.length>0?{kind:`usage`,message:t}:{kind:`runtime`}}var uh=__esmMin(()=>{});function buildHeaders(t,n){let S={"user-agent":`gjsify-install/0.64.51`,"accept-encoding":n.acceptEncoding??`identity`};if(n.npmrc){let C=resolveAuthForUrl(t,n.npmrc);C&&(S.authorization=C)}if(n.headers)for(let[t,C]of Object.entries(n.headers))S[t.toLowerCase()]=C;return S}function resolveAuthForUrl(t,n){let S=pathPrefixes(new URL(t));for(let t of S){let S=n.authTokens[t];if(S)return`Bearer ${S}`;let C=n.basicAuth[t];if(C)return`Basic ${btoa(`${C.username}:${C.password}`)}`}return null}function pathPrefixes(t){let n=t.pathname.split(`/`).filter(Boolean),S=[];for(let C=n.length;C>=0;C--){let N=n.slice(0,C).join(`/`);S.push(N?`//${t.host}/${N}`:`//${t.host}`)}return S}var dh=__esmMin(()=>{}),PackageNotFoundError,IntegrityError,RegistryTimeoutError,RegistryUnreachableError,fh=__esmMin(()=>{PackageNotFoundError=class extends Error{name;url;constructor(t,n){super(`Package not found in registry: ${t} (${n})`),this.name=t,this.url=n,this.name=`PackageNotFoundError`}},IntegrityError=class extends Error{url;integrity;constructor(t,n){super(`Tarball integrity mismatch for ${t} (expected ${n})`),this.url=t,this.integrity=n,this.name=`IntegrityError`}},RegistryTimeoutError=class extends Error{url;timeoutMs;attempts;constructor(t,n,S){let C=Math.round(n/100)/10,N=Math.round(n*S/100)/10;super(`@gjsify/npm-registry: GET ${t} timed out after ${C}s × ${S} attempt(s) (total ~${N}s). This usually means the registry CDN is slow or unreachable.`),this.url=t,this.timeoutMs=n,this.attempts=S,this.name=`RegistryTimeoutError`}},RegistryUnreachableError=class extends Error{url;attempts;elapsedMs;constructor(t,n,S,C){let N=Math.round(S/100)/10,F=C instanceof Error?C.message:String(C);super(`@gjsify/npm-registry: GET ${t} failed after ${n} attempt(s) over ~${N}s: ${F}. This usually means the registry or the network dropped out.`),this.url=t,this.attempts=n,this.elapsedMs=S,this.name=`RegistryUnreachableError`,this.cause=C}}});function registryFor(t,n){if(n&&t.startsWith(`@`)){let S=t.slice(0,t.indexOf(`/`)),C=n.scopes[S];if(C)return ensureTrailingSlash$1(C)}return n?.registry?ensureTrailingSlash$1(n.registry):ph}function parseNpmrc(t){let n={registry:ph,scopes:{},authTokens:{},basicAuth:{}},S=t.split(/\r?\n/),C={};for(let t of S){let S=t.replace(/^\s+|\s+$/g,``);if(!S||S.startsWith(`#`)||S.startsWith(`;`))continue;let N=S.indexOf(`=`);if(N<0)continue;let F=S.slice(0,N).trim(),I=expandEnv(stripQuotes(S.slice(N+1).trim()));if(F===`registry`){n.registry=ensureTrailingSlash$1(I);continue}let H=F.match(/^(@[^:]+):registry$/);if(H){n.scopes[H[1]]=ensureTrailingSlash$1(I);continue}let W=F.match(/^\/\/(.+):_authToken$/);if(W){n.authTokens[normalizeAuthHost(W[1])]=I;continue}let q=F.match(/^\/\/(.+):username$/);if(q){(C[normalizeAuthHost(q[1])]??={}).user=I;continue}let Y=F.match(/^\/\/(.+):_password$/);if(Y){let t=base64Decode$1(I);(C[normalizeAuthHost(Y[1])]??={}).pass=t;continue}}for(let[t,S]of Object.entries(C))S.user&&S.pass!==void 0&&(n.basicAuth[t]={username:S.user,password:S.pass});return n}function normalizeAuthHost(t){return`//${t.replace(/\/+$/,``)}`}function ensureTrailingSlash$1(t){return t.endsWith(`/`)?t:t+`/`}function stripQuotes(t){return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1):t}function expandEnv(t){return t.replace(/\$\{([A-Z0-9_]+)\}/gi,(t,n)=>globalThis.process?.env?.[n]??``)}function base64Decode$1(t){return atob(t)}var ph,mh=__esmMin(()=>{ph=`https://registry.npmjs.org/`,__name$1(ensureTrailingSlash$1,`ensureTrailingSlash`),__name$1(base64Decode$1,`base64Decode`)});async function fetchWithRetry(t,n,S){let C=S.fetch??globalThis.fetch;if(!C)throw Error(`@gjsify/npm-registry: globalThis.fetch is missing`);let N=Math.max(0,S.retries??5),F=Math.max(0,S.retryDelayMs??1e3),I=Math.max(0,S.timeoutMs??3e4),H=S.retryNotFound??!1,W=Date.now(),q=0,Y,X=0;for(;;){if(n.signal?.aborted)throw signalAbortError(n.signal);let Z=I>0?new AbortController:null,te=Z===null?null:setTimeout(()=>Z.abort(Error(`@gjsify/npm-registry: per-request timeout ${I}ms`)),I),ne=composeSignals(n.signal,Z?.signal);try{let F=await C(t,{...n,signal:ne}),I=isRetryableStatus(F.status)||H&&F.status===404;if(F.ok||!I||q>=N)return S.read?await S.read(F):F;try{await F.arrayBuffer()}catch{}Y=Error(`HTTP ${F.status} ${F.statusText}`)}catch(S){let C=Z!==null&&Z.signal.aborted,F=n.signal?.aborted===!0;if(C&&!F){if(X++,q>=N)throw new RegistryTimeoutError(t,I,X);Y=S}else if(F)throw signalAbortError(n.signal);else{if(!isRetryableError(S))throw S;if(q>=N)throw new RegistryUnreachableError(t,q+1,Date.now()-W,S);Y=S}}finally{te!==null&&clearTimeout(te)}let re=Math.min(F*2**q,8e3);S.onRetry?.({attempt:q+1,error:Y,delayMs:re}),await delay$1(re,n.signal),q++}}function composeSignals(t,n){return t?n?AbortSignal.any([t,n]):t:n}function isRetryableStatus(t){return t===408||t===425||t===429||t===500||t===502||t===503||t===504||t===521||t===522||t===524||t===525}function isRetryableError(t){if(t&&typeof t==`object`&&`name`in t&&t.name===`AbortError`)return!1;if(t instanceof TypeError)return!0;if(t&&typeof t==`object`&&`name`in t){let n=t.name;if(n===`FetchError`)return!0;if(n===`AbortError`)return!1}let n=t?.cause;if(n&&typeof n==`object`&&`code`in n){let t=n.code;if(typeof t==`string`)return t===`ECONNRESET`||t===`ECONNREFUSED`||t===`ENETUNREACH`||t===`ENOTFOUND`||t===`ETIMEDOUT`||t===`EAI_AGAIN`||t===`UND_ERR_SOCKET`||t===`UND_ERR_CONNECT_TIMEOUT`}return!1}function delay$1(t,n){return t<=0?Promise.resolve():new Promise((S,C)=>{let N=setTimeout(()=>{n?.removeEventListener?.(`abort`,onAbort),S()},t),onAbort=()=>{clearTimeout(N),C(signalAbortError(n))};if(n?.aborted){clearTimeout(N),C(signalAbortError(n));return}n?.addEventListener?.(`abort`,onAbort,{once:!0})})}function signalAbortError(t){let n=t&&`reason`in t?t.reason:void 0;if(n instanceof Error)return n;let S=Error(`Aborted`);return S.name=`AbortError`,S}var hh=__esmMin(()=>{fh(),__name$1(delay$1,`delay`)});async function verifyIntegrity(t,n){let S=n.trim().split(/\s+/);for(let n of S){let S=n.indexOf(`-`);if(S<0)continue;let C=n.slice(0,S).toLowerCase(),N=n.slice(S+1),F=globalThis.crypto?.subtle;if(!F)throw Error(`@gjsify/npm-registry: globalThis.crypto.subtle is missing`);let I=subriToWebCryptoAlgo(C);if(!I)continue;let H=await F.digest(I,dataAsArrayBuffer(t));if(bytesToBase64(new Uint8Array(H))===N)return!0}return!1}function subriToWebCryptoAlgo(t){switch(t){case`sha1`:return`SHA-1`;case`sha256`:return`SHA-256`;case`sha384`:return`SHA-384`;case`sha512`:return`SHA-512`;default:return null}}function dataAsArrayBuffer(t){if(t.byteOffset===0&&t.byteLength===t.buffer.byteLength)return t.buffer;let n=new Uint8Array(t.byteLength);return n.set(t),n.buffer}function bytesToBase64(t){let n=``;for(let S=0;S<t.length;S++)n+=String.fromCharCode(t[S]);return btoa(n)}var gh=__esmMin(()=>{});function assertPackument(t,n){if(!n||typeof n!=`object`)throw TypeError(`registry: ${t} packument is not an object`);let S=n;if(typeof S.name!=`string`)throw TypeError(`registry: ${t} packument missing string name`);if(!S.versions||typeof S.versions!=`object`)throw TypeError(`registry: ${t} packument missing versions map`)}function packumentUrl(t,n){let S=ensureTrailingSlash$1(n);if(t.startsWith(`@`)){let n=t.indexOf(`/`);if(n<0)throw TypeError(`Invalid scoped package name: ${t}`);let C=t.slice(0,n),N=t.slice(n+1);return`${S}${encodeURIComponent(C)}/${encodeURIComponent(N)}`}return`${S}${encodeURIComponent(t)}`}async function fetchPackumentConditional(t,n={}){let S=packumentUrl(t,n.registry??registryFor(t,n.npmrc)),C=buildHeaders(S,{...n,acceptEncoding:`gzip`});C.accept??=n.fullMetadata?`application/json`:`application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*`,n.ifNoneMatch&&(C[`if-none-match`]=n.ifNoneMatch);let N=await fetchWithRetry(S,{headers:C,signal:n.signal},{fetch:n.fetch,retries:n.retries,retryDelayMs:n.retryDelayMs,timeoutMs:n.timeoutMs,onRetry:n.onRetry,read:async n=>{if(n.status===304){try{await n.arrayBuffer()}catch{}return{status:`not-modified`}}if(!n.ok)throw n.status===404||n.status===406?new PackageNotFoundError(t,S):Error(`registry GET ${S} -> ${n.status} ${n.statusText}`);return{status:`fresh`,body:await decodeJsonBody(n),etag:n.headers.get(`etag`)??void 0}}});if(N.status===`not-modified`)return{status:`not-modified`,etag:n.ifNoneMatch};let F=N.body;return assertPackument(t,F),{status:`fresh`,packument:F,etag:N.etag}}async function decodeJsonBody(t){return t.json()}async function fetchPackument(t,n={}){let S=await fetchPackumentConditional(t,n);if(!S.packument)throw Error(`registry: ${t} returned 304 Not Modified to an unconditional request`);return S.packument}var vh=__esmMin(()=>{dh(),fh(),mh(),hh()});async function fetchTarball(t,n={}){let S=buildHeaders(t,{...n,acceptEncoding:`identity`});S.accept??=`application/octet-stream`;let C=await fetchWithRetry(t,{headers:S,signal:n.signal},{fetch:n.fetch,retries:n.retries,retryDelayMs:n.retryDelayMs,timeoutMs:n.timeoutMs,onRetry:n.onRetry,retryNotFound:n.retryNotFound??!0,read:async n=>{if(!n.ok)throw Error(`tarball GET ${t} -> ${n.status} ${n.statusText}`);return new Uint8Array(await n.arrayBuffer())}});if(n.integrity&&!await verifyIntegrity(C,n.integrity))throw new IntegrityError(t,n.integrity);return C}var yh=__esmMin(()=>{dh(),fh(),hh(),gh()});async function whoami(t,n){let S=`${ensureTrailingSlash$1(t)}-/whoami`,C=buildHeaders(S,{npmrc:n});C.accept=`application/json`;let N=globalThis.fetch;if(!N)throw Error(`@gjsify/npm-registry: globalThis.fetch is missing`);let F=await N(S,{method:`GET`,headers:C});if(!F.ok)throw Error(`whoami GET ${S} -> ${F.status} ${F.statusText}`);let I=await F.json();if(I&&typeof I==`object`&&`username`in I){let t=I.username;if(typeof t==`string`&&t.length>0)return{username:t}}return{}}var bh=__esmMin(()=>{dh(),mh()}),xh=__esmMin(()=>{dh(),fh(),mh(),gh(),vh(),yh(),bh()});function escapePackageName(t){return t.replace(`/`,`%2f`)}function buildPublishHeaders(t,n){let S=buildHeaders(t,{npmrc:n.npmrc});return S[`content-type`]=`application/json`,S[`npm-command`]=`publish`,S[`npm-auth-type`]=n.otp?`legacy`:`web`,S[`user-agent`]=n.userAgent??defaultUserAgent(),n.otp&&(S[`npm-otp`]=n.otp),n.authorization&&(S.authorization=n.authorization),S}function cliVersion(){return Sh===void 0&&(Sh=`0.64.51`),Sh}function cliPackageDir(){let t=globalThis.process?.env?.GJSIFY_CLI_PACKAGE_JSON,n;try{n=Hn(t||fileURLToPath(import.meta.url))}catch{return null}for(let t=0;t<12;t++){try{if(JSON.parse(readFileSync(`${n}/package.json`,`utf8`)).name===`@gjsify/cli`)return n}catch{}let t=Hn(n);if(t===n)break;n=t}return null}function defaultUserAgent(){let t=globalThis.process,n=t?.arch??`x64`,S=t?.platform??`linux`;return`gjsify-publish/${cliVersion()} (${S} ${n})`}var Sh,Ch=__esmMin(()=>{af(),Xn(),cr(),xh()}),wh,Th=__esmMin(()=>{wh=`gjsify`});function parseDeclaredChannel(t,n){if(!(t===void 0||t===``)){if(Eh.includes(t))return t;throw Error(`${n}: "${String(t)}" is not a distribution channel. Known: ${Eh.join(`, `)}.`)}}function channelAllowsDonations(t){return t!==void 0&&Dh[t]===`external-link`}var Eh,Dh,Oh,kh=__esmMin(()=>{Eh=[`flathub`,`web`,`microsoft-store`,`apple-app-store`],Dh={flathub:`external-link`,web:`external-link`,"microsoft-store":`none`,"apple-app-store":`store-purchase`},Oh=`GJSIFY_CHANNEL`});function parseDeclaredPricing(t,n){if(!(t===void 0||t===``)){if(Ah.includes(t))return t;throw Error(`${n}: "${String(t)}" is not a pricing tier. Known: ${Ah.join(`, `)}.`)}}var Ah,jh,Mh=__esmMin(()=>{Ah=[`free`,`paid`],jh=`GJSIFY_PRICING`}),Nh=__commonJSMin(((t,n)=>{let S=(Xn(),__toCommonJS(Pn)),C=(eu(),__toCommonJS(Xl)),N=(af(),__toCommonJS(nf)),resolveFrom=(t,n,F)=>{if(typeof t!=`string`)throw TypeError(`Expected \`fromDir\` to be of type \`string\`, got \`${typeof t}\``);if(typeof n!=`string`)throw TypeError(`Expected \`moduleId\` to be of type \`string\`, got \`${typeof n}\``);try{t=N.realpathSync(t)}catch(n){if(n.code===`ENOENT`)t=S.resolve(t);else if(F)return null;else throw n}let I=S.join(t,`noop.js`),resolveFileName=()=>C._resolveFilename(n,{id:I,filename:I,paths:C._nodeModulePaths(t)});if(F)try{return resolveFileName()}catch{return null}return resolveFileName()};n.exports=(t,n)=>resolveFrom(t,n),n.exports.silent=(t,n)=>resolveFrom(t,n,!0)})),Ph=__commonJSMin(((t,n)=>{let callsites=()=>{let t=Error.prepareStackTrace;Error.prepareStackTrace=(t,n)=>n;let n=Error().stack.slice(1);return Error.prepareStackTrace=t,n};n.exports=callsites,n.exports.default=callsites})),Fh=__commonJSMin(((t,n)=>{let S=Ph();n.exports=t=>{let n=S();if(!t)return n[2].getFileName();let C=!1;n.shift();for(let S of n){let n=S.getFileName();if(typeof n==`string`){if(n===t){C=!0;continue}if(n!==`module.js`&&C&&n!==t)return n}}}})),Ih=__commonJSMin(((t,n)=>{var{__gjsifyModuleDir:S,__gjsifyModuleFile:C}=(iu(),__toCommonJS(tu)),N=S(`import-fresh/index.js`),F=C(`import-fresh/index.js`);let I=(Xn(),__toCommonJS(Pn)),H=Nh(),W=Fh();n.exports=t=>{if(typeof t!=`string`)throw TypeError(`Expected a string`);let n=W(F),S=n?I.dirname(n):N,C=H(S,t),q=Y.cache[C];if(q&&q.parent){let t=q.parent.children.length;for(;t--;)q.parent.children[t].id===C&&q.parent.children.splice(t,1)}delete Y.cache[C];let X=Y.cache[n];return X===void 0||X.require===void 0?Y(C):X.require(C)}})),Lh=__commonJSMin(((t,n)=>{n.exports=function isArrayish(t){return t?t instanceof Array||Array.isArray(t)||t.length>=0&&t.splice instanceof Function:!1}})),Rh=__commonJSMin(((t,n)=>{var S=(Uu(),__toCommonJS(zu)),C=Lh(),N=function errorEx(t,n){(!t||t.constructor!==String)&&(n=t||{},t=Error.name);var N=function ErrorEXError(S){if(!this)return new ErrorEXError(S);S=S instanceof Error?S.message:S||this.message,Error.call(this,S),Error.captureStackTrace(this,N),this.name=t,Object.defineProperty(this,"message",{configurable:!0,enumerable:!1,get:function(){var t=S.split(/\r?\n/g);for(var N in n)if(n.hasOwnProperty(N)){var F=n[N];`message`in F&&(t=F.message(this[N],t)||t,C(t)||(t=[t]))}return t.join(`
150
150
  `)},set:function(t){S=t}});var F=null,I=Object.getOwnPropertyDescriptor(this,`stack`),H=I.get,W=I.value;delete I.value,delete I.writable,I.set=function(t){F=t},I.get=function(){var t=(F||(H?H.call(this):W)).split(/\r?\n+/g);F||(t[0]=this.name+`: `+this.message);var S=1;for(var C in n)if(n.hasOwnProperty(C)){var N=n[C];if(`line`in N){var I=N.line(this[C]);I&&t.splice(S++,0,` `+I)}`stack`in N&&N.stack(this[C],t)}return t.join(`
151
151
  `)},Object.defineProperty(this,"stack",I)};return Object.setPrototypeOf?(Object.setPrototypeOf(N.prototype,Error.prototype),Object.setPrototypeOf(N,Error)):S.inherits(N,Error),N};N.append=function(t,n){return{message:function(S,C){return S||=n,S&&(C[0]+=` `+t.replace(`%s`,S.toString())),C}}},N.line=function(t,n){return{line:function(S){return S||=n,S?t.replace(`%s`,S.toString()):null}}},n.exports=N})),zh=__commonJSMin(((t,n)=>{let hexify=t=>{let n=t.charCodeAt(0).toString(16).toUpperCase();return`0x`+(n.length%2?`0`:``)+n},parseError=(t,n,S)=>{if(!n)return{message:t.message+` while parsing empty string`,position:0};let C=t.message.match(/^Unexpected token (.) .*position\s+(\d+)/i),N=C?+C[2]:t.message.match(/^Unexpected end of JSON.*/i)?n.length-1:null,F=C?t.message.replace(/^Unexpected token ./,`Unexpected token ${JSON.stringify(C[1])} (${hexify(C[1])})`):t.message;if(N!=null){let t=N<=S?0:N-S,C=N+S>=n.length?n.length:N+S,I=(t===0?``:`...`)+n.slice(t,C)+(C===n.length?``:`...`);return{message:F+` while parsing ${n===I?``:`near `}${JSON.stringify(I)}`,position:N}}else return{message:F+` while parsing '${n.slice(0,S*2)}'`,position:0}};var JSONParseError=class extends SyntaxError{constructor(t,n,S,C){S||=20;let N=parseError(t,n,S);super(N.message),Object.assign(this,N),this.code=`EJSONPARSE`,this.systemError=t,Error.captureStackTrace(this,C||this.constructor)}get name(){return this.constructor.name}set name(t){}get[Symbol.toStringTag](){return this.constructor.name}};let S=Symbol.for(`indent`),C=Symbol.for(`newline`),N=/^\s*[{\[]((?:\r?\n)+)([\s\t]*)/,F=/^(?:\{\}|\[\])((?:\r?\n)+)?$/,parseJson=(t,n,I)=>{let H=stripBOM(t);I||=20;try{let[,t=`
152
152
  `,I=` `]=H.match(F)||H.match(N)||[,``,``],W=JSON.parse(H,n);return W&&typeof W==`object`&&(W[C]=t,W[S]=I),W}catch(n){if(typeof t!=`string`&&!Buffer.isBuffer(t)){let S=Array.isArray(t)&&t.length===0;throw Object.assign(TypeError(`Cannot parse ${S?`an empty array`:String(t)}`),{code:`EJSONPARSE`,systemError:n})}throw new JSONParseError(n,H,I,parseJson)}},stripBOM=t=>String(t).replace(/^\uFEFF/,``);n.exports=parseJson,parseJson.JSONParseError=JSONParseError,parseJson.noExceptions=(t,n)=>{try{return JSON.parse(stripBOM(t),n)}catch{}}})),Bh=__commonJSMin((t=>{t.__esModule=!0,t.LinesAndColumns=void 0;var n=`
@@ -1182,13 +1182,13 @@ A misplaced catalogue installs and then shows nothing, which reads exactly like
1182
1182
  TRUNCATED, so the artifact would carry a version that is not the one it was built from. Set \`gjsify.ship.version\`.`);return`${S}.${C}.${N}`}function msiIdentifier(t,n,S=``){let C=createHash(`sha1`).update(new TextEncoder().encode(n)).digest(`hex`).slice(0,12),N=n.replace(/[^A-Za-z0-9_.]/g,`_`),F=72-t.length-2-C.length-S.length;return`${t}_${N.length>F?N.slice(N.length-F):N}_${C}${S}`}function assertNameIsAddressable(t,n){if(t===`.`||t===`..`||t.length===0||PW.test(t))throw Error(`gjsify ship: the payload holds "${n}", and Windows Installer cannot address the path segment "${t}". A \`FileName\` or \`DefaultDir\` cell reserves < > : " / \\ | ? * and ; (its own list separator), and
1183
1183
  \`.\` and \`..\` are not names. The \`.msi\` would build and install the file somewhere else, or not at all.`);if(t.length>255)throw Error(`gjsify ship: the payload holds "${n}", whose segment "${t.slice(0,40)}…" is ${t.length} characters. Windows Installer's \`FileName\` column is 255.`)}function directoryTree(t){let n={path:``,name:``,children:new Map,files:[]};for(let S of[...t].sort((t,n)=>t.path<n.path?-1:+(t.path>n.path))){let t=S.path.split(`/`),C=t.pop();if(C===void 0)throw Error(`gjsify ship: the payload holds an empty path.`);let N=n;for(let n of t){assertNameIsAddressable(n,S.path);let t=N.children.get(n)??{path:N.path===``?n:`${N.path}/${n}`,name:n,children:new Map,files:[]};N.children.set(n,t),N=t}assertNameIsAddressable(C,S.path),N.files.push(S)}return n}function renderWxs(t){let{settings:n,programDirName:S,archLabel:C}=t,N=C!==`x86`,F=C===`arm64`?500:200,I=msiProductVersion(n.version),H=n.maintainer.replace(/\s*<[^>]*>\s*$/,``).trim()||n.maintainer,W=windowsGuiLauncherPath(n),q=new Map,claim=(t,n)=>{let S=q.get(t);if(S!==void 0)throw Error(`gjsify ship: the MSI identifier "${t}" would be shared by ${S} and ${n}. Two rows cannot carry one id — one would silently replace the other.`);return q.set(t,n),t},Y=claim(msiIdentifier(`i`,W,`.exe`),`the launcher icon`),X=[],Z=[],te=!1,ne,emitDir=(t,S)=>{for(let C of t.files){let t=claim(msiIdentifier(`c`,C.path),C.path),F=claim(msiIdentifier(`f`,C.path),C.path);Z.push(t);let I=msiComponentGuid(n,C.path),H=xmlEscape(On.basename(C.path));X.push(`${S}<Component Id="${t}" Guid="${I}" Win64="${N?`yes`:`no`}">`),C.path===W?(te=!0,ne=C.source,X.push(`${S} <File Id="${F}" Name="${H}" Source="${xmlEscape(C.source)}" KeyPath="yes">`),X.push(`${S} <Shortcut Id="${claim(`s_startmenu`,`the Start-Menu shortcut`)}" Directory="ProgramMenuFolder" Name="${xmlEscape(n.name)}" WorkingDirectory="INSTALLDIR" Description="${xmlEscape(n.summary)}" Icon="${Y}" IconIndex="0" Advertise="yes" />`),X.push(`${S} </File>`)):X.push(`${S} <File Id="${F}" Name="${H}" Source="${xmlEscape(C.source)}" KeyPath="yes" />`),X.push(`${S}</Component>`)}for(let n of[...t.children.values()].sort((t,n)=>t.name<n.name?-1:1)){let t=claim(msiIdentifier(`d`,n.path),`the directory ${n.path}`);X.push(`${S}<Directory Id="${t}" Name="${xmlEscape(n.name)}">`),emitDir(n,`${S} `),X.push(`${S}</Directory>`)}};if(emitDir(directoryTree(t.files),` `),Z.length===0)throw Error("gjsify ship: the windows payload is empty, so there is nothing for an `.msi` to install.");if(!te||ne===void 0)throw Error(`gjsify ship: the windows payload carries no "${W}" at the root of the program directory, so the installer would have nothing to point a Start-Menu shortcut at — an application a user installs and
1184
1184
  cannot start. \`windows-dir\` puts the launcher there; a payload without one is a stage assembled for another layout.`);let re=n.homepage===void 0?[]:[` <Property Id="ARPURLINFOABOUT" Value="${xmlEscape(n.homepage)}" />`];return[`<?xml version="1.0" encoding="utf-8"?>`,"<!-- Generated by `gjsify ship` (ADR 0024 stage 5). Do not edit; edit utils/ship/msi.ts. -->",`<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">`,` <Product Id="${msiProductCode(n,C)}" Name="${xmlEscape(n.name)}" Language="1033" Version="${I}" Manufacturer="${xmlEscape(H)}" UpgradeCode="${msiUpgradeCode(n)}">`,` <Package InstallerVersion="${F}" Compressed="yes" InstallScope="perMachine" Manufacturer="${xmlEscape(H)}" Description="${xmlEscape(n.summary)}" />`,` <MajorUpgrade DowngradeErrorMessage="A newer version of ${xmlEscape(n.name)} is already installed." />`,` <Media Id="1" Cabinet="app.cab" EmbedCab="yes" />`,` <Icon Id="${Y}" SourceFile="${xmlEscape(ne)}" />`,` <Property Id="ARPPRODUCTICON" Value="${Y}" />`,...re,` <Directory Id="TARGETDIR" Name="SourceDir">`,` <Directory Id="ProgramFiles64Folder">`,` <Directory Id="INSTALLDIR" Name="${xmlEscape(S)}">`,...X,` <Component Id="AddToPathComponent" Guid="${msiComponentGuid(n,`:path`)}" Win64="${N?`yes`:`no`}">`,` <CreateFolder />`,` <Environment Id="GjsifyPath" Name="PATH" Action="set" Part="last" System="yes" Permanent="no" Value="[INSTALLDIR]" />`,` </Component>`,` </Directory>`,` </Directory>`,` <Directory Id="ProgramMenuFolder" />`,` </Directory>`,` <Feature Id="Main" Title="${xmlEscape(n.name)}" Level="1">`,...Z.map(t=>` <ComponentRef Id="${t}" />`),` </Feature>`,` <Feature Id="AddToPath" Title="Add ${xmlEscape(n.name)} to PATH" Level="2">`,` <ComponentRef Id="AddToPathComponent" />`,` <Condition Level="1">ADDTOPATH=1</Condition>`,` </Feature>`,` </Product>`,`</Wix>`,``].join(`
1185
- `)}function msiBackendFor(t){if(t===`linux`)return`wixl`;if(t===`win32`)return`wix3`;throw Error(`gjsify ship: no MSI compiler is wired for ${t}. \`wixl\` (msitools) is used on linux and WiX v3 on win32; assembly is not host-bound, so \`gjsify ship windows --stage\` here and \`gjsify ship --from-stage <dir> --target msi\` there is the way across.`)}async function buildMsi(t){let n=msiBackendFor(t.host??process.platform);mkdirSync(t.workDir,{recursive:!0});let S=zn(t.workDir,`${t.settings.binaryName}.wxs`);if(writeFileSync(S,renderWxs(t)),n===`wixl`)return await run(`wixl`,[`-a`,t.archLabel,`-o`,t.target,S],t),S;let C=zn(t.workDir,`obj`);return rmSync(C,{recursive:!0,force:!0,maxRetries:5}),mkdirSync(C,{recursive:!0}),await run(`candle.exe`,[`-nologo`,`-arch`,t.archLabel,`-out`,`${C}\\`,S],t),await run(`light.exe`,[`-nologo`,`-out`,t.target,zn(C,`${t.settings.binaryName}.wixobj`)],t),S}async function run(t,n,S){S.verbose&&ge.log(`[gjsify ship] ${t} ${n.join(` `)}`);let C=await spawnToCompletion(t,[...n],{completion:`return`,cwd:S.workDir,stdio:`inherit`,notFound:()=>Error(`gjsify ship: ${t} not found. It is the MSI compiler for this host — Fedora: \`sudo dnf install msitools\`, Debian/Ubuntu: \`sudo apt install msitools\`, Windows: WiX Toolset v3.14 with its \`bin\` directory on PATH.`)});if(C.code!==0)throw Error(`gjsify ship: ${t} failed with ${describeExit(C)}.`)}var NW,PW,FW,IW=__esmMin(()=>{_e(),gl(),af(),Xn(),hv(),rU(),bU(),NW=`7b3a1f6e-0c4d-4a2b-9e51-3d8c6f2a0b14`,PW=/[<>:"/\\|?*;]/,FW=`root`});function tarballTopDir(t,n){return`${t.binaryName}-${t.version}-linux-${n}`}function assertTarballHygiene(t,n){let S=[];for(let C of t){let t=C.path.split(`/`),N=t[t.length-1];N===`.env`||N.startsWith(`.env.`)?S.push(`${C.path} (environment file)`):t.includes(`.git`)?S.push(`${C.path} (version-control data)`):N.endsWith(`.log`)?S.push(`${C.path} (log file)`):t.includes(`node_modules`)&&n.app!==`node`&&S.push(`${C.path} (node_modules in a non-Node payload)`)}if(S.length!==0)throw Error(`gjsify ship: refusing to pack a tarball that would contain ${S.slice(0,5).join(`, `)}${S.length>5?` and ${S.length-5} more`:``}.`)}async function buildLinuxTarball(t){assertTarballHygiene(t.payload,t.settings);let n=tarballTopDir(t.settings,t.archLabel),S=new Set([`${n}/`]);for(let C of t.payload){let t=On.dirname(C.path),N=t===`.`?[]:t.split(`/`),F=n;for(let t of N)F=`${F}/${t}`,S.add(`${F}/`)}return gzipDeterministic(createTarball([...[...S].sort().map(n=>({name:n,mode:493,mtime:t.mtime,directory:!0})),...t.payload.map(S=>({name:`${n}/${S.path}`,body:S.data,mode:S.mode,mtime:t.mtime}))]))}var LW=__esmMin(()=>{Xn(),rz(),pH()});function getCrcTable(){if(WW!==null)return WW;let t=new Uint32Array(256);for(let n=0;n<256;n++){let S=n;for(let t=0;t<8;t++)S=S&1?3988292384^S>>>1:S>>>1;t[n]=S>>>0}return WW=t,t}function crc32(t){let n=getCrcTable(),S=4294967295;for(let C=0;C<t.length;C++)S=n[(S^t[C])&255]^S>>>8;return(S^4294967295)>>>0}function dosDateTime(t){let n=new Date(Math.max(t,315532800)*1e3);return{date:(n.getUTCFullYear()-1980&127)<<9|n.getUTCMonth()+1<<5|n.getUTCDate(),time:n.getUTCHours()<<11|n.getUTCMinutes()<<5|Math.floor(n.getUTCSeconds()/2)}}function buildZip(t,n){let S=[...t].sort((t,n)=>t.path<n.path?-1:+(t.path>n.path)),{date:C,time:N}=dosDateTime(n),F=new TextEncoder;if(S.length>65535)throw Error(`gjsify ship: this archive would hold ${S.length} entries and a non-ZIP64 central directory records the count in 16 bits, so it would silently wrap. Nothing here writes ZIP64 yet; the payload has to shrink, or this writer has to grow the ZIP64 records.`);let I=new Writer,H=new Writer,W=0;for(let t of S){let n=F.encode(t.path),S=crc32(t.data),q=t.data.byteLength,Y=I.offset;if(Y>4294967295||q>4294967295)throw Error(`gjsify ship: ${t.path} would push this archive past 4 GiB, which a non-ZIP64 header records in 32 bits and therefore truncates. Nothing here writes ZIP64 yet.`);I.u32(RW),I.u16(UW),I.u16(2048),I.u16(VW),I.u16(N),I.u16(C),I.u32(S),I.u32(q),I.u32(q),I.u16(n.byteLength),I.u16(0),I.bytes(n),I.bytes(t.data),H.u32(zW),H.u16(HW),H.u16(UW),H.u16(2048),H.u16(VW),H.u16(N),H.u16(C),H.u32(S),H.u32(q),H.u32(q),H.u16(n.byteLength),H.u16(0),H.u16(0),H.u16(0),H.u16(0),H.u32(((32768|t.mode&4095)>>>0)*65536),H.u32(Y),H.bytes(n),W+=1}let q=H.finish(),Y=new Writer;Y.bytes(I.finish());let X=Y.offset;return Y.bytes(q),Y.u32(BW),Y.u16(0),Y.u16(0),Y.u16(W),Y.u16(W),Y.u32(q.byteLength),Y.u32(X),Y.u16(0),Y.finish()}function zipEntriesFromPayload(t,n=``){let S=n===``?``:`${n}/`;return t.map(t=>({path:`${S}${t.path}`,mode:t.mode,data:t.data}))}var RW,zW,BW,VW,HW,UW,WW,Writer,GW=__esmMin(()=>{RW=67324752,zW=33639248,BW=101010256,VW=0,HW=788,UW=20,WW=null,Writer=class{parts=[];length=0;get offset(){return this.length}u16(t){this.push(new Uint8Array([t&255,t>>>8&255]))}u32(t){this.push(new Uint8Array([t&255,t>>>8&255,t>>>16&255,t>>>24&255]))}bytes(t){this.push(t)}push(t){this.parts.push(t),this.length+=t.byteLength}finish(){let t=new Uint8Array(this.length),n=0;for(let S of this.parts)t.set(S,n),n+=S.byteLength;return t}}});function entryEvidence(t){let n=new Set,S=new Set;return walkModuleAst(t,t=>{let C=importedSpecifier(t);C!==null&&(C.startsWith(`gi://`)||KW.has(C)?n.add(C):C.startsWith(`node:`)&&t.type!==`ImportExpression`&&S.add(C))}),{gi:[...n].sort(),node:[...S].sort()}}function assertEntryRunsUnder(t){let n=entryEvidence(t.source),S=t.interpreter===`node`?n.gi:n.node;if(S.length===0)return;let C=t.interpreter===`node`?`gjs`:`node`,N=t.interpreter===`gjs`?`GJS's loader refuses it: ImportError, "Unsupported URI scheme for importing: node"`:S.some(t=>t.startsWith(`gi://`))?`node's ESM loader refuses it: ERR_UNSUPPORTED_ESM_URL_SCHEME, "Only URLs with a scheme in: file, data, and node are supported by the default ESM loader"`:`node's ESM loader refuses it: ERR_MODULE_NOT_FOUND — a GJS built-in is not a package`,F=S.slice(0,3).join(`, `),I=S.length>3?`, and ${S.length-3} more`:``;throw Error(`gjsify ship: this target execs \`${t.interpreter}\` (\`${t.appKey}\`), and the entry it would ship — ${t.entry} (\`${t.bundleKey}\`) — imports ${F}${I}.\n ${N}, before a line of application code runs.\n The artifact would be built, reported as built, and fail at launch on every machine.
1186
- Either ship this target the \`--app ${t.interpreter}\` build of the app — \`gjsify.ship.bundle.${t.layoutOs}\` selects the entry per target, the way \`gjsify.ship.app.${t.layoutOs}\` selects the runtime —\n or set \`gjsify.ship.app.${t.layoutOs}\` to "${C}" if this bundle is the one that should ship.`)}var KW,qW=__esmMin(()=>{lP(),KW=new Set([`system`,`gettext`])});function releaseRecordPath(t){return`${t}${JW}`}function recordedSignature(t,n){return t===void 0?{kind:`none`}:t===n?{kind:`adhoc`}:{kind:`identity`,identity:t}}function buildReleaseRecord(t){let n=readFileSync(t.file);return{schema:1,artifact:Un(t.file),sha256:createHash(`sha256`).update(n).digest(`hex`),size:n.length,format:t.format,os:t.os,arch:t.arch,signature:t.signature,notarized:t.notarized,stapled:t.stapled,nestedBundles:t.nestedBundles,generator:t.generator}}function writeReleaseRecord(t){let n=releaseRecordPath(t.file);return writeFileSync(n,`${JSON.stringify(buildReleaseRecord(t),null,4)}\n`),n}var JW,YW=__esmMin(()=>{gl(),af(),Xn(),JW=`.gjsify-release.json`});function base64Encode(t){let n=``,S=32768;for(let C=0;C<t.length;C+=S)n+=String.fromCharCode(...t.subarray(C,C+S));return btoa(n)}function base64Decode(t){let n=atob(t),S=new Uint8Array(n.length);for(let t=0;t<n.length;t++)S[t]=n.charCodeAt(t);return S}var XW=__esmMin(()=>{});function toPackSettings(t){return{binaryName:t.binaryName,appId:t.appId,name:t.name,version:t.version,release:t.release,maintainer:t.maintainer,summary:t.summary,description:t.description,license:t.license,...t.homepage===void 0?{}:{homepage:t.homepage},section:t.section,group:t.group,extraDepends:t.extraDepends,typelibPackages:t.typelibPackages,app:t.app,minGjsVersion:t.minGjsVersion,minNodeVersion:t.minNodeVersion,flatpak:t.flatpak,executables:t.executables.map(({name:t,gui:n})=>({name:t,gui:n})),nestedBundles:t.nestedBundles.map(({name:t,entitlements:n})=>({name:t,entitlements:n})),helperExecutables:t.helperExecutables.map(({name:t,entitlements:n})=>({name:t,entitlements:n})),...t.hasMainExecutable===!0?{hasMainExecutable:!0}:{}}}function stageManifestPath(t){return zn(t,ZW)}function formatTarget(t){return`${t.os}-${t.arch}`}function writeStageManifest(t){let n={};for(let S of t.formats)n[S.id]=(t.overlay.get(S.id)??[]).map(t=>{if(t.source.kind===`text`)return{path:t.path,mode:t.mode,text:t.source.text};if(t.source.kind===`bytes`)return{path:t.path,mode:t.mode,base64:base64Encode(t.source.data)};throw Error(`gjsify ship: internal error — the ${S.id} overlay entry ${t.path} is a file reference, and a stage manifest may only carry rendered bytes. Render it in \`planOverlay\` instead.`)});let S={schema:6,tool:{name:`@gjsify/cli`,version:cliVersion()},target:{os:t.settings.layoutOs,arch:t.settings.arch},formats:t.formats.map(t=>t.id),mtime:t.mtime,namespaces:[...t.namespaces],optionalNamespaces:[...t.optionalNamespaces??[]],settings:toPackSettings(t.settings),staged:t.staged.map(n=>({path:n.path,mode:n.mode,bytes:statSync(zn(t.stageDir,n.path.split(`/`).join(qn))).size})),overlay:n};return writeFileSync(stageManifestPath(t.stageDir),`${JSON.stringify(S,null,2)}\n`),S}function readStageManifest(t){let n=stageManifestPath(t);if(!existsSync(n))throw Error(`gjsify ship: ${t} has no ${ZW}, so it is not a stage this command can pack. A stage is produced by \`gjsify ship --stage\`, which writes that file at the stage root beside the payload. If you pointed --from-stage at a project's \`ship/\` directory, point it at \`ship/stage/\` instead.`);let S;try{S=JSON.parse(readFileSync(n,`utf-8`))}catch(t){throw Error(`gjsify ship: ${n} is not readable JSON (${t.message}). Re-run the \`--stage\` phase; a truncated manifest means the stage transfer was truncated too.`)}if(typeof S!=`object`||!S||Array.isArray(S))throw Error(`gjsify ship: ${n} is not a JSON object. Re-run the \`--stage\` phase.`);let C=S,N=C.schema;if(typeof N!=`number`||!Number.isInteger(N))throw Error(`gjsify ship: ${n} has no integer \`schema\` field, so it was not written by \`gjsify ship --stage\`. Re-run the \`--stage\` phase.`);if(N>6)throw Error(`gjsify ship: ${n} declares schema ${N} and this gjsify understands 6. The stage was assembled by a newer gjsify: upgrade this one (\`gjsify self-update\`), or re-run the \`--stage\` phase with this version. A manifest from the future is refused rather than partially read, because an unknown field could be the one that decides a file's mode.`);if(N<6)throw Error(`gjsify ship: ${n} declares schema ${N} and this gjsify understands 6. Re-run the \`--stage\` phase with this gjsify. A stage is a short-lived intermediate between two jobs of one run, not an archive, so no migration is kept for it.`);let at=t=>`${n} → ${t}`,F=record(C.tool,at(`tool`)),I=record(C.target,at(`target`)),H={schema:N,tool:{name:expectString(F.name,at(`tool.name`)),version:expectString(F.version,at(`tool.version`))},target:{os:expectLayoutOs(expectString(I.os,at(`target.os`)),at(`target.os`)),arch:expectString(I.arch,at(`target.arch`))},formats:expectArray(C.formats,at(`formats`)).map((t,n)=>{let S=expectString(t,at(`formats[${n}]`));if(!AW.includes(S))throw Error(`gjsify ship: ${at(`formats[${n}]`)} is "${S}", which this gjsify does not know. Known formats: ${AW.join(`, `)}.`);return S}),mtime:expectInteger(C.mtime,at(`mtime`)),namespaces:expectArray(C.namespaces,at(`namespaces`)).map((t,n)=>expectString(t,at(`namespaces[${n}]`))),...C.optionalNamespaces===void 0?{}:{optionalNamespaces:expectArray(C.optionalNamespaces,at(`optionalNamespaces`)).map((t,n)=>expectString(t,at(`optionalNamespaces[${n}]`)))},settings:readPackSettings(record(C.settings,at(`settings`)),at(`settings`)),staged:expectArray(C.staged,at(`staged`)).map((t,n)=>{let S=record(t,at(`staged[${n}]`));return{path:expectString(S.path,at(`staged[${n}].path`)),mode:expectInteger(S.mode,at(`staged[${n}].mode`)),bytes:expectInteger(S.bytes,at(`staged[${n}].bytes`))}}),overlay:{}};if(H.staged.length===0)throw Error(`gjsify ship: ${at(`staged`)} is empty, so this stage describes no payload. A stage always carries at least the launcher its plan named. Re-run the \`--stage\` phase; a stage that lost its plan cannot be packed into anything but an empty package.`);let W=record(C.overlay,at(`overlay`));for(let t of H.formats)H.overlay[t]=expectArray(W[t],at(`overlay.${t}`)).map((n,S)=>{let C=record(n,at(`overlay.${t}[${S}]`)),N=at(`overlay.${t}[${S}]`);if(C.text===void 0==(C.base64===void 0))throw Error(`gjsify ship: ${N} must carry exactly one of \`text\` and \`base64\`. An overlay entry is either rendered text or rendered bytes; an entry with neither would pack an empty file at a path the format requires content at.`);return{path:expectString(C.path,at(`overlay.${t}[${S}].path`)),mode:expectInteger(C.mode,at(`overlay.${t}[${S}].mode`)),...C.text===void 0?{base64:expectString(C.base64,at(`overlay.${t}[${S}].base64`))}:{text:expectString(C.text,at(`overlay.${t}[${S}].text`))}}});return H}function expectLayoutOs(t,n){try{return layoutForOs(t).os}catch{let S=tU.map(t=>eU[t].os).join(`, `);throw Error(`gjsify ship: ${n} is "${t}", which is not a layout this gjsify can pack. It carries the \`process.platform\` spelling and only that — ${S}, so \`win32\` and never \`windows\`. A stage holds exactly one OS's layout and every path in it has that OS's shape, so there is nothing to pack here. Re-run the \`--stage\` phase.`)}}function overlayFiles(t,n){return(t.overlay[n]??[]).map(t=>({path:t.path,mode:t.mode,source:t.base64===void 0?{kind:`text`,text:t.text??``}:{kind:`bytes`,data:base64Decode(t.base64)}}))}function assertExpectedTarget(t,n){if(n===void 0)return;let S=formatTarget(t.target);if(n!==S)throw Error(`gjsify ship: --expect-target ${n} but this stage was assembled for ${S}. The stage records the target its \`--arch\` resolved to at stage time, so this is a stage from another matrix leg: download the artifact belonging to ${n}, or drop --expect-target if packing this one is what you meant.`)}function assertFormatsStaged(t,n){let S=n.filter(n=>!t.formats.includes(n.id)).map(t=>t.id);if(S.length!==0)throw Error(`gjsify ship: this stage was assembled for ${t.formats.length===0?`no format at all`:t.formats.join(`, `)}, and --target names ${S.join(`, `)}. Phase one renders each format's overlay — rpm wants the licence at \`share/licenses/<pkg>/LICENSE\`, deb wants a machine-readable copyright at \`share/doc/<pkg>/copyright\` — so a format the stage never saw would pack without it, and Debian Policy § 12.5 makes that a broken package. Re-run \`gjsify ship --stage --target ${[...t.formats,...S].join(`,`)}\` on the assembling host.`)}function resolveStageMtime(t,n=process.env){let S=n.SOURCE_DATE_EPOCH;return S===void 0||Number(S)===t.mtime?{mtime:t.mtime,warnings:[]}:{mtime:t.mtime,warnings:[`SOURCE_DATE_EPOCH is ${S} here and this stage was stamped ${t.mtime}. The stage's stamp wins, because changing it would make this artifact differ from the same stage packed on the assembling host. Set the same value in both jobs, or set it in neither.`]}}function warnOnToolSkew(t){let n=cliVersion();return t.tool.version===n?[]:[`this stage was assembled by ${t.tool.name} ${t.tool.version} and is being packed by ${n}. Both phases run the same packer, so a version difference can change the artifact's bytes. Pin both jobs to one gjsify version.`]}function readPackSettings(t,n){let field=t=>`${n}.${t}`,S=record(t.extraDepends,field(`extraDepends`)),C=record(t.typelibPackages,field(`typelibPackages`));return{binaryName:expectString(t.binaryName,field(`binaryName`)),appId:expectString(t.appId,field(`appId`)),name:expectString(t.name,field(`name`)),version:expectString(t.version,field(`version`)),release:expectString(t.release,field(`release`)),maintainer:expectString(t.maintainer,field(`maintainer`)),summary:expectString(t.summary,field(`summary`)),description:expectArray(t.description,field(`description`)).map((t,n)=>expectString(t,field(`description[${n}]`))),license:expectString(t.license,field(`license`)),...t.homepage===void 0?{}:{homepage:expectString(t.homepage,field(`homepage`))},section:expectString(t.section,field(`section`)),group:expectString(t.group,field(`group`)),extraDepends:{deb:expectArray(S.deb??[],field(`extraDepends.deb`)).map((t,n)=>expectString(t,field(`extraDepends.deb[${n}]`))),rpm:expectArray(S.rpm??[],field(`extraDepends.rpm`)).map((t,n)=>expectString(t,field(`extraDepends.rpm[${n}]`)))},typelibPackages:Object.fromEntries(Object.entries(C).map(([t,n])=>{let S=record(n,field(`typelibPackages.${t}`));return[t,{deb:expectString(S.deb,field(`typelibPackages.${t}.deb`)),rpm:expectString(S.rpm,field(`typelibPackages.${t}.rpm`))}]})),app:expectApp(t.app,field(`app`)),minGjsVersion:expectString(t.minGjsVersion,field(`minGjsVersion`)),minNodeVersion:expectString(t.minNodeVersion,field(`minNodeVersion`)),flatpak:readFlatpakSettings(record(t.flatpak,field(`flatpak`)),field(`flatpak`)),executables:expectArray(t.executables??[],field(`executables`)).map((t,n)=>{let S=record(t,field(`executables[${n}]`));if(typeof S.gui!=`boolean`)throw Error(`gjsify ship: ${field(`executables[${n}].gui`)} must be a boolean.`);return{name:expectString(S.name,field(`executables[${n}].name`)),gui:S.gui}}),nestedBundles:expectArray(t.nestedBundles??[],field(`nestedBundles`)).map((t,n)=>{let S=record(t,field(`nestedBundles[${n}]`));return{name:expectString(S.name,field(`nestedBundles[${n}].name`)),entitlements:expectArray(S.entitlements,field(`nestedBundles[${n}].entitlements`)).map((t,S)=>expectString(t,field(`nestedBundles[${n}].entitlements[${S}]`)))}}),helperExecutables:expectArray(t.helperExecutables??[],field(`helperExecutables`)).map((t,n)=>{let S=record(t,field(`helperExecutables[${n}]`));return{name:expectString(S.name,field(`helperExecutables[${n}].name`)),entitlements:expectArray(S.entitlements,field(`helperExecutables[${n}].entitlements`)).map((t,S)=>expectString(t,field(`helperExecutables[${n}].entitlements[${S}]`)))}}),...t.hasMainExecutable===void 0?{}:(()=>{if(typeof t.hasMainExecutable!=`boolean`)throw Error(`gjsify ship: ${field(`hasMainExecutable`)} must be a boolean.`);return t.hasMainExecutable?{hasMainExecutable:!0}:{}})()}}function readFlatpakSettings(t,n){let field=t=>`${n}.${t}`,strings=(t,n)=>expectArray(t,field(n)).map((t,S)=>expectString(t,field(`${n}[${S}]`)));return{runtime:expectString(t.runtime,field(`runtime`)),runtimeVersion:expectString(t.runtimeVersion,field(`runtimeVersion`)),sdk:expectString(t.sdk,field(`sdk`)),branch:expectString(t.branch,field(`branch`)),sdkExtensions:strings(t.sdkExtensions,`sdkExtensions`),appendPath:strings(t.appendPath,`appendPath`),finishArgs:strings(t.finishArgs,`finishArgs`),cleanup:strings(t.cleanup,`cleanup`)}}function record(t,n){if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`gjsify ship: ${n} must be an object. Re-run the \`--stage\` phase.`);return t}function expectArray(t,n){if(!Array.isArray(t))throw Error(`gjsify ship: ${n} must be an array. Re-run the \`--stage\` phase.`);return t}function expectApp(t,n){if(t===`gjs`||t===`node`)return t;throw Error(`gjsify ship: ${n} must be "gjs" or "node", got ${JSON.stringify(t)}.`)}function expectString(t,n){if(typeof t!=`string`)throw Error(`gjsify ship: ${n} must be a string. Re-run the \`--stage\` phase.`);return t}function expectInteger(t,n){if(typeof t!=`number`||!Number.isInteger(t)||t<0)throw Error(`gjsify ship: ${n} must be a non-negative integer. Re-run the \`--stage\` phase. (Modes are decimal here — JSON has no octal literal, so 0o755 is written 493.)`);return t}var ZW,QW=__esmMin(()=>{af(),Xn(),XW(),Ch(),MW(),rU(),ZW=`.gjsify-ship-stage.json`});function writeStage(t,n){for(let t of n)if(t.path===`.gjsify-ship-stage.json`)throw Error(`gjsify ship: a payload file may not be called \`${ZW}\` — that name belongs to the stage manifest, which sits at the stage root beside the payload and carries what the packing host needs (ADR 0024 § A2). Rename the \`gjsify.ship.extraFiles\` destination.`);rmSync(t,{recursive:!0,force:!0,maxRetries:5}),mkdirSync(t,{recursive:!0});for(let S of n){let n=zn(t,S.path.split(`/`).join(qn));mkdirSync(Hn(n),{recursive:!0});let C;switch(S.source.kind){case`text`:C=new TextEncoder().encode(S.source.text);break;case`file`:C=new Uint8Array(readFileSync(S.source.path));break;case`bytes`:C=S.source.data;break;default:{let t=S.source;throw Error(`gjsify ship: no writer for the "${JSON.stringify(t)}" source kind.`)}}writeFileSync(n,C),chmodSync(n,S.mode)}}function readStage(t,n){let S=new Map(n.map(t=>[t.path,t])),C=new Map;for(let n of t)for(let t of listFilesRecursive(n)){if(t===`.gjsify-ship-stage.json`)continue;let N=S.get(t);if(N===void 0)throw Error(`gjsify ship: ${zn(n,t.split(`/`).join(qn))} is in the stage and not in its manifest, so nothing knows what mode to give it. Every payload file takes its mode from the plan, never from the filesystem, so a file that arrived some other way would be packed 0644 — unrunnable if it is a program. Remove it, or add it through \`gjsify.ship.extraFiles\` and re-run the \`--stage\` phase.`);let F=new Uint8Array(readFileSync(zn(n,t.split(`/`).join(qn))));if(N.bytes!==void 0&&N.bytes!==F.byteLength)throw Error(`gjsify ship: ${t} is ${F.byteLength} bytes in the stage and ${N.bytes} in its manifest. The stage arrived truncated or was edited after it was assembled. Re-upload it, or re-run the \`--stage\` phase.`);C.set(t,{path:t,mode:N.mode,data:F})}let N=n.filter(t=>!C.has(t.path)).map(t=>t.path);if(N.length>0)throw Error(`gjsify ship: the stage manifest lists ${N.length} file(s) the stage does not contain: ${N.slice(0,5).join(`, `)}${N.length>5?`, …`:``}. A payload has to be complete before it is packed — both formats would pack the rest without complaint and install a package that cannot start. Re-run the \`--stage\` phase, and check that whatever moved the stage between hosts copied every file (an artifact upload that drops empty files or dotfiles is the usual cause).`);return[...C.values()].sort((t,n)=>t.path<n.path?-1:+(t.path>n.path))}function writePayload(t,n,S){let C=S===``?``:`${S}/`;rmSync(t,{recursive:!0,force:!0,maxRetries:5}),mkdirSync(t,{recursive:!0});for(let N of n){if(!N.path.startsWith(C))throw Error(`gjsify ship: ${N.path} is outside ${S||`the artifact`}, which this artifact IS — so there is nowhere inside it for the file to go. A payload file that escaped the bundle would ship beside it, unsigned and unfound.`);let n=zn(t,N.path.slice(C.length).split(`/`).join(qn));mkdirSync(Hn(n),{recursive:!0}),writeFileSync(n,N.data),chmodSync(n,N.mode)}}function directorySize(t){let n=0;for(let S of listFilesRecursive(t))n+=statSync(zn(t,S.split(`/`).join(qn))).size;return n}var $W=__esmMin(()=>{af(),Xn(),IU(),QW()});function asciiCodesignIdentifier(t){let n=Un(t);if([...n].every(t=>(t.codePointAt(0)??0)<128))return;let S=n.normalize(`NFD`).replace(/\p{M}+/gu,``).replace(/[^A-Za-z0-9.-]+/g,`-`).replace(/^-+|-+$/g,``);return/[A-Za-z0-9]/.test(S)?S:`x-${[...new TextEncoder().encode(n)].map(t=>t.toString(16).padStart(2,`0`)).join(``)}`}function resolveSignPlan(t){let n=eG[t.layoutOs];if(n===void 0){if(t.flag!==void 0)throw Error(`gjsify ship: --sign has nothing to sign in the ${t.layoutOs} layout. A .deb and an .rpm carry no per-file signature — the artifact is signed as a whole by the repository that serves it (\`debsigs\`, \`rpmsign\`), with that repository's key and not with a build-time identity. Drop --sign, or assemble the darwin or windows layout.`);return{kind:`unsupported`}}let S=t.config?.[t.layoutOs]?.identity,[C,N]=t.flag===void 0?[S,`config`]:[t.flag,`flag`];return C===void 0||C===``?{kind:`skip`,message:`${C===``?`an empty identity was ${N===`flag`?`passed to --sign`:`set in \`${n.configKey}\``}`:`no identity was given`} — skipping ${n.tool}. An unsigned artifact is the default path and a legitimate deliverable (ADR 0024 § A13). Pass \`--sign <identity>\` or set \`${n.configKey}\` to sign; \`--sign -\` signs ad-hoc and needs no developer identity.`}:{kind:`sign`,identity:C,signer:n,source:N}}function assertHostCanSign(t){let n=process.platform;if(!t.signOn.includes(n))throw Error(`gjsify ship: signing the ${t.layoutOs} layout needs ${t.tool}, which runs on ${t.signOn.join(`, `)} and this host is ${n}. Assembly is not host-bound — \`gjsify ship <os> --stage\` here, then \`gjsify ship --from-stage <dir> --sign <identity>\` on a host that has both the tool and the identity (ADR 0024 § A1, § A14).`);if(!isOnPath(t.tool))throw Error(`gjsify ship: --sign was given and \`${t.tool}\` is not on PATH, so nothing can make the signature — ${t.installHint}. Dropping --sign produces an unsigned artifact, which is a legitimate output (ADR 0024 § A13); silently producing one while --sign was asked for is not.`)}function partitionSignedFileSet(t){let n=new Set(t.planned),S=new Set(t.arrived),C=[...S].filter(t=>!n.has(t)).sort(),N=t.sealPrefixes??[],underAnyPrefix=t=>N.some(n=>t.startsWith(n));return{sealed:N.length===0?[]:C.filter(underAnyPrefix),unexpected:N.length===0?C:C.filter(t=>!underAnyPrefix(t)),removed:[...n].filter(t=>!S.has(t)).sort()}}async function signPayload(t){let{payload:n,signer:S,workDir:C}=t,N=t.nestedBundles??[],F=t.helperExecutables??[];if((N.length>0||F.length>0)&&!S.sealsBundle)throw Error(`gjsify ship: this payload declares a nested bundle or helper executable, and the ${S.layoutOs} signer has no bundle to embed one in — \`signtool\` signs loose images, never a bundle tree. Nested bundles and helper executables are a darwin-only feature.`);writePayload(C,n,``);let I=t.identity===`-`,H=new Map,entitlementsFileFor=(n,S)=>{if(S.length===0)return;let C=H.get(n);if(C!==void 0)return C;let N=n===``?t.entitlementsPath:`${t.entitlementsPath}.${n}.plist`;return mkdirSync(Hn(N),{recursive:!0}),writeFileSync(N,renderEntitlements(S)),H.set(n,N),N},run=async(n,N,F,H)=>{let W=S.args({identity:t.identity,file:n,adhoc:I,seal:F,...H?{entitlements:H}:{}});t.verbose&&t.log(`${S.tool} ${W.join(` `)}`);let q=await spawnToCompletion(S.tool,W,{completion:`return`,cwd:C,stdio:`inherit`,notFound:()=>Error(`gjsify ship: \`${S.tool}\` is not on PATH — ${S.installHint}.`)});if(q.code!==0)throw Error(`gjsify ship: ${S.tool} failed on ${N} with ${describeExit(q)}. Nothing is packed from a payload whose signature failed: an artifact that is half signed installs and is refused at first launch, which is worse than not shipping.`)},W=entitlementsFileFor(``,S.entitlements(I)),q=N.map(t=>`${t.path}/`),Y=new Set(F.map(t=>t.path)),underSubordinate=t=>q.some(n=>t.startsWith(n)),X=[],Z=0;for(let t of N){let N=entitlementsFileFor(t.path,t.entitlements),F=n.filter(n=>n.path.startsWith(`${t.path}/`)&&classifyBinary(n.data)===S.signs);for(let t of F)await run(zn(C,t.path.split(`/`).join(qn)),t.path,!1,N);Z+=F.length,await run(zn(C,t.path.split(`/`).join(qn)),`${t.path} (nested bundle seal)`,!0,N),X.push(S.sealAddPrefix(t.path))}for(let t of F){let n=entitlementsFileFor(t.path,t.entitlements);await run(zn(C,t.path.split(`/`).join(qn)),t.path,!1,n)}let te=n.filter(t=>classifyBinary(t.data)===S.signs&&!underSubordinate(t.path)&&!Y.has(t.path));if(te.length===0&&!S.sealsBundle)return t.log(`nothing in this payload is a ${S.signs===`macho`?`Mach-O`:`PE`} image, so ${S.tool} signed 0 file(s). The artifact carries no signature.`),[...n];for(let t of te)await run(zn(C,t.path.split(`/`).join(qn)),t.path,!1,W);let ne;if(S.sealsBundle){if(t.bundleRoot===``)throw Error(`gjsify ship: the ${S.layoutOs} signer seals a bundle and this layout has no root to seal. \`Layout.root\` is what names the artifact directory; a signer that sealed the whole stage would sign the payload of every other format beside it.`);ne=S.sealAddPrefix(t.bundleRoot),await run(zn(C,t.bundleRoot.split(`/`).join(qn)),`${t.bundleRoot} (bundle seal)`,!0,W)}let re=[...ne===void 0?[]:[ne],...X],ie=partitionSignedFileSet({arrived:listFilesRecursive(C),planned:n.map(t=>t.path),sealPrefixes:re});if(ie.unexpected.length>0||ie.removed.length>0)throw Error(`gjsify ship: ${S.tool} changed the payload's file set — ${ie.unexpected.length} added (${ie.unexpected.slice(0,3).join(`, `)||`—`}), ${ie.removed.length} removed (${ie.removed.slice(0,3).join(`, `)||`—`}). Signing is a mutation of the files that are already in the payload (ADR 0024 § A4), plus exactly each seal's own directory${re.length===0?``:` (${re.map(t=>`\`${t}\``).join(`, `)})`}.`);let ae=ie.sealed;t.log(`${S.tool} signed ${te.length+Z+F.length} of ${n.length} payload file(s) as ${I?"ad-hoc (`-`)":`\`${t.identity}\``}${ne===void 0?``:` and sealed ${t.bundleRoot} (${ae.length} seal file(s))`}${N.length===0?``:`, nested: ${N.map(t=>t.path).join(`, `)}`} — ${S.gap}.`);let read=t=>new Uint8Array(readFileSync(zn(C,t.split(`/`).join(qn))));return[...n.map(t=>({path:t.path,mode:t.mode,data:read(t.path)})),...ae.map(t=>({path:t,mode:420,data:read(t)}))].sort((t,n)=>t.path<n.path?-1:+(t.path>n.path))}function resolveNotaryPlan(t){let n=tG[t.layoutOs];if(n===void 0){if(t.flag!==void 0)throw Error(`gjsify ship: --notarize has no meaning in the ${t.layoutOs} layout. Notarisation is Apple's pre-clearance of a signed artifact and nothing else asks for it — Windows SmartScreen accrues reputation per file hash instead (ADR 0024 § A5).`);return{kind:`unsupported`}}if(t.flag===void 0||t.flag===``)return{kind:`skip`,message:`no notarisation credential was given — skipping ${n.tool} notarytool. Pass \`--notarize <keychain-profile>\`, naming a profile a prior \`notarytool store-credentials\` put in this host's keychain.`};if(t.sign.kind!==`sign`)throw Error("gjsify ship: --notarize was given without an identity to sign with. Notarisation is a check ON a signature, so submitting an unsigned artifact has nothing to clear. Pass `--sign <identity>` as well, or drop --notarize.");return{kind:`notarize`,credential:t.flag,notary:n}}async function notarizeArtifact(t){let{notary:n,credential:S}=t.plan,C=process.platform;if(!n.notarizeOn.includes(C))throw Error(`gjsify ship: notarising the ${n.layoutOs} layout needs ${n.tool}, which runs on ${n.notarizeOn.join(`, `)} and this host is ${C}.`);let N=n.args(S,t.artifact);t.verbose&&t.log(`${n.tool} ${N.join(` `)}`);let F=await spawnToCompletion(n.tool,N,{completion:`return`,stdio:`inherit`,notFound:()=>Error(`gjsify ship: \`${n.tool}\` is not on PATH — ${n.installHint}.`)});if(F.code!==0)throw Error(`gjsify ship: ${n.tool} notarytool failed with ${describeExit(F)}.`);t.log(`${n.tool} notarytool accepted ${t.artifact}.`)}async function stapleArtifact(t){let n=[`stapler`,`staple`,t.artifact];t.verbose&&t.log(`${t.notary.tool} ${n.join(` `)}`);let S=await spawnToCompletion(t.notary.tool,n,{completion:`return`,stdio:`inherit`,notFound:()=>Error(`gjsify ship: \`${t.notary.tool}\` is not on PATH — ${t.notary.installHint}.`)});if(S.code!==0)throw Error(`gjsify ship: ${t.notary.tool} stapler failed with ${describeExit(S)}. The artifact is notarised and NOT stapled, which means every launch asks Gatekeeper to check online — and fails closed on a machine with no network. Re-run the finish phase; \`stapler\` requires internet access and the ticket may not have propagated yet.`);t.log(`${t.notary.tool} stapler attached the ticket to ${t.artifact}.`)}var eG,tG,nG=__esmMin(()=>{af(),Xn(),cL(),hv(),IU(),vU(),ZH(),$W(),eG={darwin:{layoutOs:`darwin`,tool:`codesign`,signOn:[`darwin`],installHint:"install the Xcode Command Line Tools (`xcode-select --install`) on a macOS host",signs:`macho`,args:({identity:t,file:n,entitlements:S,adhoc:C,seal:N})=>{let F=N?void 0:asciiCodesignIdentifier(n);return[`--force`,`--sign`,t,`--options`,`runtime`,...S===void 0?[]:[`--entitlements`,S],...C?[]:[`--timestamp`],...F===void 0?[]:[`--identifier`,F],n]},entitlements:t=>[`com.apple.security.cs.allow-jit`,`com.apple.security.cs.allow-unsigned-executable-memory`,`com.apple.security.cs.disable-executable-page-protection`,`com.apple.security.cs.allow-dyld-environment-variables`,...t?[`com.apple.security.cs.disable-library-validation`]:[]],sealsBundle:!0,sealAddPrefix:t=>`${t}/Contents/_CodeSignature/`,configKey:`gjsify.ship.sign.darwin.identity`,gap:"the images are signed and the bundle is sealed, and the seal survives both the `.zip` and the `.dmg` round trip; § A16 stands measured in ONE direction only — library validation refuses an ad-hoc-signed dylib, so the ad-hoc identity grants `disable-library-validation` while a named one does not; a named Developer ID was signed and notarised on 2026-10-30 for an ASCII-named app, and a non-ASCII image name verifies only with the explicit ASCII `--identifier` this signer now passes"},win32:{layoutOs:`win32`,tool:`signtool`,signOn:[`win32`],installHint:"install the Windows SDK (signtool.exe ships in its `bin/<version>/x64` directory)",signs:`pe`,args:({identity:t,file:n})=>[`sign`,`/n`,t,`/fd`,`sha256`,n],entitlements:()=>[],sealsBundle:!1,sealAddPrefix:()=>``,configKey:`gjsify.ship.sign.win32.identity`,gap:`no timestamp countersignature is requested, so the signature expires with the certificate (UNVERIFIED: no run in this repository has ever invoked signtool)`}},tG={darwin:{layoutOs:`darwin`,tool:`xcrun`,notarizeOn:[`darwin`],installHint:"install the Xcode Command Line Tools (`xcode-select --install`) on a macOS host",args:(t,n)=>[`notarytool`,`submit`,`--keychain-profile`,t,`--wait`,n]}}});function stagedFontDir(t,n){return`${t}/${On.basename(mH.fonts)}/${n}`}function shellQuote(t){return`'${t.replace(/'/g,`'\\''`)}'`}function cmdQuote(t){let n=/["%!\r\n]/.exec(t);if(n!==null)throw Error(`gjsify ship: \`gjsify.ship.execArgs\` contains ${JSON.stringify(t)}, and cmd.exe has no way to pass ${JSON.stringify(n[0])} through a Windows launcher literally — \`%\` expands at parse time and \`"\` ends the quoted run. Move the value into the app (it can read it from its own config) or drop the character.`);return`"${t}"`}function renderLauncher(t,n,S,C={}){switch(S.name){case`linux`:return renderPrefixLauncher(t,n,S);case`darwin`:return renderAppBundleLauncher(t,n,S,C);case`windows`:return renderWindowsLauncher(t,n,S,C);default:{let t=S.name;throw Error(`gjsify ship: no launcher is wired for the "${String(t)}" layout.`)}}}function renderPrefixLauncher(t,n,S){let C=S.dirs(t),N=[`#!/bin/sh`,"# Generated by `gjsify ship` — do not edit.",`set -e`,`self=$(readlink -f "$0")`,`prefix=$(dirname "$(dirname "$self")")`,`XDG_DATA_DIRS="$prefix/${C.data}:\${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"`,`export XDG_DATA_DIRS`];if(t.typelibFiles.length>0){let t=`"$prefix"/${C.native}`;for(let n of[`GI_TYPELIB_PATH`,`LD_LIBRARY_PATH`])N.push(`${n}=${t}\${${n}:+:$${n}}`,`export ${n}`)}else if(Object.values(t.formatFiles).some(t=>t.typelibFiles.length>0)){let t=`"$prefix"/${C.native}`;N.push(`if [ -d ${t} ]; then`);for(let n of[`GI_TYPELIB_PATH`,`LD_LIBRARY_PATH`])N.push(` ${n}=${t}\${${n}:+:$${n}}`,` export ${n}`);N.push(`fi`)}return t.localeFiles.length>0&&N.push(`GJSIFY_LOCALE_DIR="$prefix"/${C.data}/locale`,`export GJSIFY_LOCALE_DIR`),t.fontFiles.length>0&&N.push(`GJSIFY_FONT_DIR="$prefix"/${stagedFontDir(C.data,t.appId)}`,`export GJSIFY_FONT_DIR`),N.push(`exec ${execLine(S,`"$prefix"/${C.bundle}/${n}`,t)} "$@"`,``),N.join(`
1185
+ `)}function msiBackendFor(t){if(t===`linux`)return`wixl`;if(t===`win32`)return`wix3`;throw Error(`gjsify ship: no MSI compiler is wired for ${t}. \`wixl\` (msitools) is used on linux and WiX v3 on win32; assembly is not host-bound, so \`gjsify ship windows --stage\` here and \`gjsify ship --from-stage <dir> --target msi\` there is the way across.`)}async function buildMsi(t){let n=msiBackendFor(t.host??process.platform);mkdirSync(t.workDir,{recursive:!0});let S=zn(t.workDir,`${t.settings.binaryName}.wxs`);if(writeFileSync(S,renderWxs(t)),n===`wixl`)return await run(`wixl`,[`-a`,t.archLabel,`-o`,t.target,S],t),S;let C=zn(t.workDir,`obj`);return rmSync(C,{recursive:!0,force:!0,maxRetries:5}),mkdirSync(C,{recursive:!0}),await run(`candle.exe`,[`-nologo`,`-arch`,t.archLabel,`-out`,`${C}\\`,S],t),await run(`light.exe`,[`-nologo`,`-out`,t.target,zn(C,`${t.settings.binaryName}.wixobj`)],t),S}async function run(t,n,S){S.verbose&&ge.log(`[gjsify ship] ${t} ${n.join(` `)}`);let C=await spawnToCompletion(t,[...n],{completion:`return`,cwd:S.workDir,stdio:`inherit`,notFound:()=>Error(`gjsify ship: ${t} not found. It is the MSI compiler for this host — Fedora: \`sudo dnf install msitools\`, Debian/Ubuntu: \`sudo apt install msitools\`, Windows: WiX Toolset v3.14 with its \`bin\` directory on PATH.`)});if(C.code!==0)throw Error(`gjsify ship: ${t} failed with ${describeExit(C)}.`)}var NW,PW,FW,IW=__esmMin(()=>{_e(),gl(),af(),Xn(),hv(),rU(),bU(),NW=`7b3a1f6e-0c4d-4a2b-9e51-3d8c6f2a0b14`,PW=/[<>:"/\\|?*;]/,FW=`root`});function tarballTopDir(t,n){return`${t.binaryName}-${t.version}-linux-${n}`}function inDeclaredClosure(t,n){return n.some(n=>t.startsWith(`${n}/`)?!t.slice(n.length+1).split(`/`).includes(`node_modules`):!1)}function assertTarballHygiene(t,n){let S=[];for(let C of t){let t=C.path.split(`/`),N=t[t.length-1];N===`.env`||N.startsWith(`.env.`)?S.push(`${C.path} (environment file)`):t.includes(`.git`)?S.push(`${C.path} (version-control data)`):N.endsWith(`.log`)?S.push(`${C.path} (log file)`):t.includes(`node_modules`)&&n.app!==`node`&&!inDeclaredClosure(C.path,n.nodeModulesDirs??[])&&S.push(`${C.path} (node_modules in a non-Node payload)`)}if(S.length!==0)throw Error(`gjsify ship: refusing to pack a tarball that would contain ${S.slice(0,5).join(`, `)}${S.length>5?` and ${S.length-5} more`:``}.`)}async function buildLinuxTarball(t){assertTarballHygiene(t.payload,t.settings);let n=tarballTopDir(t.settings,t.archLabel),S=new Set([`${n}/`]);for(let C of t.payload){let t=On.dirname(C.path),N=t===`.`?[]:t.split(`/`),F=n;for(let t of N)F=`${F}/${t}`,S.add(`${F}/`)}return gzipDeterministic(createTarball([...[...S].sort().map(n=>({name:n,mode:493,mtime:t.mtime,directory:!0})),...t.payload.map(S=>({name:`${n}/${S.path}`,body:S.data,mode:S.mode,mtime:t.mtime}))]))}var LW=__esmMin(()=>{Xn(),rz(),pH()});function getCrcTable(){if(WW!==null)return WW;let t=new Uint32Array(256);for(let n=0;n<256;n++){let S=n;for(let t=0;t<8;t++)S=S&1?3988292384^S>>>1:S>>>1;t[n]=S>>>0}return WW=t,t}function crc32(t){let n=getCrcTable(),S=4294967295;for(let C=0;C<t.length;C++)S=n[(S^t[C])&255]^S>>>8;return(S^4294967295)>>>0}function dosDateTime(t){let n=new Date(Math.max(t,315532800)*1e3);return{date:(n.getUTCFullYear()-1980&127)<<9|n.getUTCMonth()+1<<5|n.getUTCDate(),time:n.getUTCHours()<<11|n.getUTCMinutes()<<5|Math.floor(n.getUTCSeconds()/2)}}function buildZip(t,n){let S=[...t].sort((t,n)=>t.path<n.path?-1:+(t.path>n.path)),{date:C,time:N}=dosDateTime(n),F=new TextEncoder;if(S.length>65535)throw Error(`gjsify ship: this archive would hold ${S.length} entries and a non-ZIP64 central directory records the count in 16 bits, so it would silently wrap. Nothing here writes ZIP64 yet; the payload has to shrink, or this writer has to grow the ZIP64 records.`);let I=new Writer,H=new Writer,W=0;for(let t of S){let n=F.encode(t.path),S=crc32(t.data),q=t.data.byteLength,Y=I.offset;if(Y>4294967295||q>4294967295)throw Error(`gjsify ship: ${t.path} would push this archive past 4 GiB, which a non-ZIP64 header records in 32 bits and therefore truncates. Nothing here writes ZIP64 yet.`);I.u32(RW),I.u16(UW),I.u16(2048),I.u16(VW),I.u16(N),I.u16(C),I.u32(S),I.u32(q),I.u32(q),I.u16(n.byteLength),I.u16(0),I.bytes(n),I.bytes(t.data),H.u32(zW),H.u16(HW),H.u16(UW),H.u16(2048),H.u16(VW),H.u16(N),H.u16(C),H.u32(S),H.u32(q),H.u32(q),H.u16(n.byteLength),H.u16(0),H.u16(0),H.u16(0),H.u16(0),H.u32(((32768|t.mode&4095)>>>0)*65536),H.u32(Y),H.bytes(n),W+=1}let q=H.finish(),Y=new Writer;Y.bytes(I.finish());let X=Y.offset;return Y.bytes(q),Y.u32(BW),Y.u16(0),Y.u16(0),Y.u16(W),Y.u16(W),Y.u32(q.byteLength),Y.u32(X),Y.u16(0),Y.finish()}function zipEntriesFromPayload(t,n=``){let S=n===``?``:`${n}/`;return t.map(t=>({path:`${S}${t.path}`,mode:t.mode,data:t.data}))}var RW,zW,BW,VW,HW,UW,WW,Writer,GW=__esmMin(()=>{RW=67324752,zW=33639248,BW=101010256,VW=0,HW=788,UW=20,WW=null,Writer=class{parts=[];length=0;get offset(){return this.length}u16(t){this.push(new Uint8Array([t&255,t>>>8&255]))}u32(t){this.push(new Uint8Array([t&255,t>>>8&255,t>>>16&255,t>>>24&255]))}bytes(t){this.push(t)}push(t){this.parts.push(t),this.length+=t.byteLength}finish(){let t=new Uint8Array(this.length),n=0;for(let S of this.parts)t.set(S,n),n+=S.byteLength;return t}}});function entryEvidence(t){let n=new Set,S=new Set;return walkModuleAst(t,t=>{let C=importedSpecifier(t);C!==null&&(C.startsWith(`gi://`)||KW.has(C)?n.add(C):C.startsWith(`node:`)&&t.type!==`ImportExpression`&&S.add(C))}),{gi:[...n].sort(),node:[...S].sort()}}function assertEntryRunsUnder(t){let n=entryEvidence(t.source),S=t.interpreter===`node`?n.gi:n.node;if(S.length===0)return;let C=t.interpreter===`node`?`gjs`:`node`,N=t.interpreter===`gjs`?`GJS's loader refuses it: ImportError, "Unsupported URI scheme for importing: node"`:S.some(t=>t.startsWith(`gi://`))?`node's ESM loader refuses it: ERR_UNSUPPORTED_ESM_URL_SCHEME, "Only URLs with a scheme in: file, data, and node are supported by the default ESM loader"`:`node's ESM loader refuses it: ERR_MODULE_NOT_FOUND — a GJS built-in is not a package`,F=S.slice(0,3).join(`, `),I=S.length>3?`, and ${S.length-3} more`:``;throw Error(`gjsify ship: this target execs \`${t.interpreter}\` (\`${t.appKey}\`), and the entry it would ship — ${t.entry} (\`${t.bundleKey}\`) — imports ${F}${I}.\n ${N}, before a line of application code runs.\n The artifact would be built, reported as built, and fail at launch on every machine.
1186
+ Either ship this target the \`--app ${t.interpreter}\` build of the app — \`gjsify.ship.bundle.${t.layoutOs}\` selects the entry per target, the way \`gjsify.ship.app.${t.layoutOs}\` selects the runtime —\n or set \`gjsify.ship.app.${t.layoutOs}\` to "${C}" if this bundle is the one that should ship.`)}var KW,qW=__esmMin(()=>{lP(),KW=new Set([`system`,`gettext`])});function releaseRecordPath(t){return`${t}${JW}`}function recordedSignature(t,n){return t===void 0?{kind:`none`}:t===n?{kind:`adhoc`}:{kind:`identity`,identity:t}}function buildReleaseRecord(t){let n=readFileSync(t.file);return{schema:1,artifact:Un(t.file),sha256:createHash(`sha256`).update(n).digest(`hex`),size:n.length,format:t.format,os:t.os,arch:t.arch,signature:t.signature,notarized:t.notarized,stapled:t.stapled,nestedBundles:t.nestedBundles,generator:t.generator}}function writeReleaseRecord(t){let n=releaseRecordPath(t.file);return writeFileSync(n,`${JSON.stringify(buildReleaseRecord(t),null,4)}\n`),n}var JW,YW=__esmMin(()=>{gl(),af(),Xn(),JW=`.gjsify-release.json`});function base64Encode(t){let n=``,S=32768;for(let C=0;C<t.length;C+=S)n+=String.fromCharCode(...t.subarray(C,C+S));return btoa(n)}function base64Decode(t){let n=atob(t),S=new Uint8Array(n.length);for(let t=0;t<n.length;t++)S[t]=n.charCodeAt(t);return S}var XW=__esmMin(()=>{});function toPackSettings(t){return{binaryName:t.binaryName,appId:t.appId,name:t.name,version:t.version,release:t.release,maintainer:t.maintainer,summary:t.summary,description:t.description,license:t.license,...t.homepage===void 0?{}:{homepage:t.homepage},section:t.section,group:t.group,extraDepends:t.extraDepends,typelibPackages:t.typelibPackages,app:t.app,minGjsVersion:t.minGjsVersion,minNodeVersion:t.minNodeVersion,...t.nodeModulesDirs===void 0||t.nodeModulesDirs.length===0?{}:{nodeModulesDirs:t.nodeModulesDirs},flatpak:t.flatpak,executables:t.executables.map(({name:t,gui:n})=>({name:t,gui:n})),nestedBundles:t.nestedBundles.map(({name:t,entitlements:n})=>({name:t,entitlements:n})),helperExecutables:t.helperExecutables.map(({name:t,entitlements:n})=>({name:t,entitlements:n})),...t.hasMainExecutable===!0?{hasMainExecutable:!0}:{}}}function stageManifestPath(t){return zn(t,ZW)}function formatTarget(t){return`${t.os}-${t.arch}`}function writeStageManifest(t){let n={};for(let S of t.formats)n[S.id]=(t.overlay.get(S.id)??[]).map(t=>{if(t.source.kind===`text`)return{path:t.path,mode:t.mode,text:t.source.text};if(t.source.kind===`bytes`)return{path:t.path,mode:t.mode,base64:base64Encode(t.source.data)};throw Error(`gjsify ship: internal error — the ${S.id} overlay entry ${t.path} is a file reference, and a stage manifest may only carry rendered bytes. Render it in \`planOverlay\` instead.`)});let S={schema:6,tool:{name:`@gjsify/cli`,version:cliVersion()},target:{os:t.settings.layoutOs,arch:t.settings.arch},formats:t.formats.map(t=>t.id),mtime:t.mtime,namespaces:[...t.namespaces],optionalNamespaces:[...t.optionalNamespaces??[]],settings:toPackSettings(t.settings),staged:t.staged.map(n=>({path:n.path,mode:n.mode,bytes:statSync(zn(t.stageDir,n.path.split(`/`).join(qn))).size})),overlay:n};return writeFileSync(stageManifestPath(t.stageDir),`${JSON.stringify(S,null,2)}\n`),S}function readStageManifest(t){let n=stageManifestPath(t);if(!existsSync(n))throw Error(`gjsify ship: ${t} has no ${ZW}, so it is not a stage this command can pack. A stage is produced by \`gjsify ship --stage\`, which writes that file at the stage root beside the payload. If you pointed --from-stage at a project's \`ship/\` directory, point it at \`ship/stage/\` instead.`);let S;try{S=JSON.parse(readFileSync(n,`utf-8`))}catch(t){throw Error(`gjsify ship: ${n} is not readable JSON (${t.message}). Re-run the \`--stage\` phase; a truncated manifest means the stage transfer was truncated too.`)}if(typeof S!=`object`||!S||Array.isArray(S))throw Error(`gjsify ship: ${n} is not a JSON object. Re-run the \`--stage\` phase.`);let C=S,N=C.schema;if(typeof N!=`number`||!Number.isInteger(N))throw Error(`gjsify ship: ${n} has no integer \`schema\` field, so it was not written by \`gjsify ship --stage\`. Re-run the \`--stage\` phase.`);if(N>6)throw Error(`gjsify ship: ${n} declares schema ${N} and this gjsify understands 6. The stage was assembled by a newer gjsify: upgrade this one (\`gjsify self-update\`), or re-run the \`--stage\` phase with this version. A manifest from the future is refused rather than partially read, because an unknown field could be the one that decides a file's mode.`);if(N<6)throw Error(`gjsify ship: ${n} declares schema ${N} and this gjsify understands 6. Re-run the \`--stage\` phase with this gjsify. A stage is a short-lived intermediate between two jobs of one run, not an archive, so no migration is kept for it.`);let at=t=>`${n} → ${t}`,F=record(C.tool,at(`tool`)),I=record(C.target,at(`target`)),H={schema:N,tool:{name:expectString(F.name,at(`tool.name`)),version:expectString(F.version,at(`tool.version`))},target:{os:expectLayoutOs(expectString(I.os,at(`target.os`)),at(`target.os`)),arch:expectString(I.arch,at(`target.arch`))},formats:expectArray(C.formats,at(`formats`)).map((t,n)=>{let S=expectString(t,at(`formats[${n}]`));if(!AW.includes(S))throw Error(`gjsify ship: ${at(`formats[${n}]`)} is "${S}", which this gjsify does not know. Known formats: ${AW.join(`, `)}.`);return S}),mtime:expectInteger(C.mtime,at(`mtime`)),namespaces:expectArray(C.namespaces,at(`namespaces`)).map((t,n)=>expectString(t,at(`namespaces[${n}]`))),...C.optionalNamespaces===void 0?{}:{optionalNamespaces:expectArray(C.optionalNamespaces,at(`optionalNamespaces`)).map((t,n)=>expectString(t,at(`optionalNamespaces[${n}]`)))},settings:readPackSettings(record(C.settings,at(`settings`)),at(`settings`)),staged:expectArray(C.staged,at(`staged`)).map((t,n)=>{let S=record(t,at(`staged[${n}]`));return{path:expectString(S.path,at(`staged[${n}].path`)),mode:expectInteger(S.mode,at(`staged[${n}].mode`)),bytes:expectInteger(S.bytes,at(`staged[${n}].bytes`))}}),overlay:{}};if(H.staged.length===0)throw Error(`gjsify ship: ${at(`staged`)} is empty, so this stage describes no payload. A stage always carries at least the launcher its plan named. Re-run the \`--stage\` phase; a stage that lost its plan cannot be packed into anything but an empty package.`);let W=record(C.overlay,at(`overlay`));for(let t of H.formats)H.overlay[t]=expectArray(W[t],at(`overlay.${t}`)).map((n,S)=>{let C=record(n,at(`overlay.${t}[${S}]`)),N=at(`overlay.${t}[${S}]`);if(C.text===void 0==(C.base64===void 0))throw Error(`gjsify ship: ${N} must carry exactly one of \`text\` and \`base64\`. An overlay entry is either rendered text or rendered bytes; an entry with neither would pack an empty file at a path the format requires content at.`);return{path:expectString(C.path,at(`overlay.${t}[${S}].path`)),mode:expectInteger(C.mode,at(`overlay.${t}[${S}].mode`)),...C.text===void 0?{base64:expectString(C.base64,at(`overlay.${t}[${S}].base64`))}:{text:expectString(C.text,at(`overlay.${t}[${S}].text`))}}});return H}function expectLayoutOs(t,n){try{return layoutForOs(t).os}catch{let S=tU.map(t=>eU[t].os).join(`, `);throw Error(`gjsify ship: ${n} is "${t}", which is not a layout this gjsify can pack. It carries the \`process.platform\` spelling and only that — ${S}, so \`win32\` and never \`windows\`. A stage holds exactly one OS's layout and every path in it has that OS's shape, so there is nothing to pack here. Re-run the \`--stage\` phase.`)}}function overlayFiles(t,n){return(t.overlay[n]??[]).map(t=>({path:t.path,mode:t.mode,source:t.base64===void 0?{kind:`text`,text:t.text??``}:{kind:`bytes`,data:base64Decode(t.base64)}}))}function assertExpectedTarget(t,n){if(n===void 0)return;let S=formatTarget(t.target);if(n!==S)throw Error(`gjsify ship: --expect-target ${n} but this stage was assembled for ${S}. The stage records the target its \`--arch\` resolved to at stage time, so this is a stage from another matrix leg: download the artifact belonging to ${n}, or drop --expect-target if packing this one is what you meant.`)}function assertFormatsStaged(t,n){let S=n.filter(n=>!t.formats.includes(n.id)).map(t=>t.id);if(S.length!==0)throw Error(`gjsify ship: this stage was assembled for ${t.formats.length===0?`no format at all`:t.formats.join(`, `)}, and --target names ${S.join(`, `)}. Phase one renders each format's overlay — rpm wants the licence at \`share/licenses/<pkg>/LICENSE\`, deb wants a machine-readable copyright at \`share/doc/<pkg>/copyright\` — so a format the stage never saw would pack without it, and Debian Policy § 12.5 makes that a broken package. Re-run \`gjsify ship --stage --target ${[...t.formats,...S].join(`,`)}\` on the assembling host.`)}function resolveStageMtime(t,n=process.env){let S=n.SOURCE_DATE_EPOCH;return S===void 0||Number(S)===t.mtime?{mtime:t.mtime,warnings:[]}:{mtime:t.mtime,warnings:[`SOURCE_DATE_EPOCH is ${S} here and this stage was stamped ${t.mtime}. The stage's stamp wins, because changing it would make this artifact differ from the same stage packed on the assembling host. Set the same value in both jobs, or set it in neither.`]}}function warnOnToolSkew(t){let n=cliVersion();return t.tool.version===n?[]:[`this stage was assembled by ${t.tool.name} ${t.tool.version} and is being packed by ${n}. Both phases run the same packer, so a version difference can change the artifact's bytes. Pin both jobs to one gjsify version.`]}function readPackSettings(t,n){let field=t=>`${n}.${t}`,S=record(t.extraDepends,field(`extraDepends`)),C=record(t.typelibPackages,field(`typelibPackages`));return{binaryName:expectString(t.binaryName,field(`binaryName`)),appId:expectString(t.appId,field(`appId`)),name:expectString(t.name,field(`name`)),version:expectString(t.version,field(`version`)),release:expectString(t.release,field(`release`)),maintainer:expectString(t.maintainer,field(`maintainer`)),summary:expectString(t.summary,field(`summary`)),description:expectArray(t.description,field(`description`)).map((t,n)=>expectString(t,field(`description[${n}]`))),license:expectString(t.license,field(`license`)),...t.homepage===void 0?{}:{homepage:expectString(t.homepage,field(`homepage`))},section:expectString(t.section,field(`section`)),group:expectString(t.group,field(`group`)),extraDepends:{deb:expectArray(S.deb??[],field(`extraDepends.deb`)).map((t,n)=>expectString(t,field(`extraDepends.deb[${n}]`))),rpm:expectArray(S.rpm??[],field(`extraDepends.rpm`)).map((t,n)=>expectString(t,field(`extraDepends.rpm[${n}]`)))},typelibPackages:Object.fromEntries(Object.entries(C).map(([t,n])=>{let S=record(n,field(`typelibPackages.${t}`));return[t,{deb:expectString(S.deb,field(`typelibPackages.${t}.deb`)),rpm:expectString(S.rpm,field(`typelibPackages.${t}.rpm`))}]})),app:expectApp(t.app,field(`app`)),minGjsVersion:expectString(t.minGjsVersion,field(`minGjsVersion`)),minNodeVersion:expectString(t.minNodeVersion,field(`minNodeVersion`)),flatpak:readFlatpakSettings(record(t.flatpak,field(`flatpak`)),field(`flatpak`)),...t.nodeModulesDirs===void 0?{}:{nodeModulesDirs:expectArray(t.nodeModulesDirs,field(`nodeModulesDirs`)).map((t,n)=>expectString(t,field(`nodeModulesDirs[${n}]`)))},executables:expectArray(t.executables??[],field(`executables`)).map((t,n)=>{let S=record(t,field(`executables[${n}]`));if(typeof S.gui!=`boolean`)throw Error(`gjsify ship: ${field(`executables[${n}].gui`)} must be a boolean.`);return{name:expectString(S.name,field(`executables[${n}].name`)),gui:S.gui}}),nestedBundles:expectArray(t.nestedBundles??[],field(`nestedBundles`)).map((t,n)=>{let S=record(t,field(`nestedBundles[${n}]`));return{name:expectString(S.name,field(`nestedBundles[${n}].name`)),entitlements:expectArray(S.entitlements,field(`nestedBundles[${n}].entitlements`)).map((t,S)=>expectString(t,field(`nestedBundles[${n}].entitlements[${S}]`)))}}),helperExecutables:expectArray(t.helperExecutables??[],field(`helperExecutables`)).map((t,n)=>{let S=record(t,field(`helperExecutables[${n}]`));return{name:expectString(S.name,field(`helperExecutables[${n}].name`)),entitlements:expectArray(S.entitlements,field(`helperExecutables[${n}].entitlements`)).map((t,S)=>expectString(t,field(`helperExecutables[${n}].entitlements[${S}]`)))}}),...t.hasMainExecutable===void 0?{}:(()=>{if(typeof t.hasMainExecutable!=`boolean`)throw Error(`gjsify ship: ${field(`hasMainExecutable`)} must be a boolean.`);return t.hasMainExecutable?{hasMainExecutable:!0}:{}})()}}function readFlatpakSettings(t,n){let field=t=>`${n}.${t}`,strings=(t,n)=>expectArray(t,field(n)).map((t,S)=>expectString(t,field(`${n}[${S}]`)));return{runtime:expectString(t.runtime,field(`runtime`)),runtimeVersion:expectString(t.runtimeVersion,field(`runtimeVersion`)),sdk:expectString(t.sdk,field(`sdk`)),branch:expectString(t.branch,field(`branch`)),sdkExtensions:strings(t.sdkExtensions,`sdkExtensions`),appendPath:strings(t.appendPath,`appendPath`),finishArgs:strings(t.finishArgs,`finishArgs`),cleanup:strings(t.cleanup,`cleanup`)}}function record(t,n){if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`gjsify ship: ${n} must be an object. Re-run the \`--stage\` phase.`);return t}function expectArray(t,n){if(!Array.isArray(t))throw Error(`gjsify ship: ${n} must be an array. Re-run the \`--stage\` phase.`);return t}function expectApp(t,n){if(t===`gjs`||t===`node`)return t;throw Error(`gjsify ship: ${n} must be "gjs" or "node", got ${JSON.stringify(t)}.`)}function expectString(t,n){if(typeof t!=`string`)throw Error(`gjsify ship: ${n} must be a string. Re-run the \`--stage\` phase.`);return t}function expectInteger(t,n){if(typeof t!=`number`||!Number.isInteger(t)||t<0)throw Error(`gjsify ship: ${n} must be a non-negative integer. Re-run the \`--stage\` phase. (Modes are decimal here — JSON has no octal literal, so 0o755 is written 493.)`);return t}var ZW,QW=__esmMin(()=>{af(),Xn(),XW(),Ch(),MW(),rU(),ZW=`.gjsify-ship-stage.json`});function writeStage(t,n){for(let t of n)if(t.path===`.gjsify-ship-stage.json`)throw Error(`gjsify ship: a payload file may not be called \`${ZW}\` — that name belongs to the stage manifest, which sits at the stage root beside the payload and carries what the packing host needs (ADR 0024 § A2). Rename the \`gjsify.ship.extraFiles\` destination.`);rmSync(t,{recursive:!0,force:!0,maxRetries:5}),mkdirSync(t,{recursive:!0});for(let S of n){let n=zn(t,S.path.split(`/`).join(qn));mkdirSync(Hn(n),{recursive:!0});let C;switch(S.source.kind){case`text`:C=new TextEncoder().encode(S.source.text);break;case`file`:C=new Uint8Array(readFileSync(S.source.path));break;case`bytes`:C=S.source.data;break;default:{let t=S.source;throw Error(`gjsify ship: no writer for the "${JSON.stringify(t)}" source kind.`)}}writeFileSync(n,C),chmodSync(n,S.mode)}}function readStage(t,n){let S=new Map(n.map(t=>[t.path,t])),C=new Map;for(let n of t)for(let t of listFilesRecursive(n)){if(t===`.gjsify-ship-stage.json`)continue;let N=S.get(t);if(N===void 0)throw Error(`gjsify ship: ${zn(n,t.split(`/`).join(qn))} is in the stage and not in its manifest, so nothing knows what mode to give it. Every payload file takes its mode from the plan, never from the filesystem, so a file that arrived some other way would be packed 0644 — unrunnable if it is a program. Remove it, or add it through \`gjsify.ship.extraFiles\` and re-run the \`--stage\` phase.`);let F=new Uint8Array(readFileSync(zn(n,t.split(`/`).join(qn))));if(N.bytes!==void 0&&N.bytes!==F.byteLength)throw Error(`gjsify ship: ${t} is ${F.byteLength} bytes in the stage and ${N.bytes} in its manifest. The stage arrived truncated or was edited after it was assembled. Re-upload it, or re-run the \`--stage\` phase.`);C.set(t,{path:t,mode:N.mode,data:F})}let N=n.filter(t=>!C.has(t.path)).map(t=>t.path);if(N.length>0)throw Error(`gjsify ship: the stage manifest lists ${N.length} file(s) the stage does not contain: ${N.slice(0,5).join(`, `)}${N.length>5?`, …`:``}. A payload has to be complete before it is packed — both formats would pack the rest without complaint and install a package that cannot start. Re-run the \`--stage\` phase, and check that whatever moved the stage between hosts copied every file (an artifact upload that drops empty files or dotfiles is the usual cause).`);return[...C.values()].sort((t,n)=>t.path<n.path?-1:+(t.path>n.path))}function writePayload(t,n,S){let C=S===``?``:`${S}/`;rmSync(t,{recursive:!0,force:!0,maxRetries:5}),mkdirSync(t,{recursive:!0});for(let N of n){if(!N.path.startsWith(C))throw Error(`gjsify ship: ${N.path} is outside ${S||`the artifact`}, which this artifact IS — so there is nowhere inside it for the file to go. A payload file that escaped the bundle would ship beside it, unsigned and unfound.`);let n=zn(t,N.path.slice(C.length).split(`/`).join(qn));mkdirSync(Hn(n),{recursive:!0}),writeFileSync(n,N.data),chmodSync(n,N.mode)}}function directorySize(t){let n=0;for(let S of listFilesRecursive(t))n+=statSync(zn(t,S.split(`/`).join(qn))).size;return n}var $W=__esmMin(()=>{af(),Xn(),IU(),QW()});function asciiCodesignIdentifier(t){let n=Un(t);if([...n].every(t=>(t.codePointAt(0)??0)<128))return;let S=n.normalize(`NFD`).replace(/\p{M}+/gu,``).replace(/[^A-Za-z0-9.-]+/g,`-`).replace(/^-+|-+$/g,``);return/[A-Za-z0-9]/.test(S)?S:`x-${[...new TextEncoder().encode(n)].map(t=>t.toString(16).padStart(2,`0`)).join(``)}`}function resolveSignPlan(t){let n=eG[t.layoutOs];if(n===void 0){if(t.flag!==void 0)throw Error(`gjsify ship: --sign has nothing to sign in the ${t.layoutOs} layout. A .deb and an .rpm carry no per-file signature — the artifact is signed as a whole by the repository that serves it (\`debsigs\`, \`rpmsign\`), with that repository's key and not with a build-time identity. Drop --sign, or assemble the darwin or windows layout.`);return{kind:`unsupported`}}let S=t.config?.[t.layoutOs]?.identity,[C,N]=t.flag===void 0?[S,`config`]:[t.flag,`flag`];return C===void 0||C===``?{kind:`skip`,message:`${C===``?`an empty identity was ${N===`flag`?`passed to --sign`:`set in \`${n.configKey}\``}`:`no identity was given`} — skipping ${n.tool}. An unsigned artifact is the default path and a legitimate deliverable (ADR 0024 § A13). Pass \`--sign <identity>\` or set \`${n.configKey}\` to sign; \`--sign -\` signs ad-hoc and needs no developer identity.`}:{kind:`sign`,identity:C,signer:n,source:N}}function assertHostCanSign(t){let n=process.platform;if(!t.signOn.includes(n))throw Error(`gjsify ship: signing the ${t.layoutOs} layout needs ${t.tool}, which runs on ${t.signOn.join(`, `)} and this host is ${n}. Assembly is not host-bound — \`gjsify ship <os> --stage\` here, then \`gjsify ship --from-stage <dir> --sign <identity>\` on a host that has both the tool and the identity (ADR 0024 § A1, § A14).`);if(!isOnPath(t.tool))throw Error(`gjsify ship: --sign was given and \`${t.tool}\` is not on PATH, so nothing can make the signature — ${t.installHint}. Dropping --sign produces an unsigned artifact, which is a legitimate output (ADR 0024 § A13); silently producing one while --sign was asked for is not.`)}function partitionSignedFileSet(t){let n=new Set(t.planned),S=new Set(t.arrived),C=[...S].filter(t=>!n.has(t)).sort(),N=t.sealPrefixes??[],underAnyPrefix=t=>N.some(n=>t.startsWith(n));return{sealed:N.length===0?[]:C.filter(underAnyPrefix),unexpected:N.length===0?C:C.filter(t=>!underAnyPrefix(t)),removed:[...n].filter(t=>!S.has(t)).sort()}}async function signPayload(t){let{payload:n,signer:S,workDir:C}=t,N=t.nestedBundles??[],F=t.helperExecutables??[];if((N.length>0||F.length>0)&&!S.sealsBundle)throw Error(`gjsify ship: this payload declares a nested bundle or helper executable, and the ${S.layoutOs} signer has no bundle to embed one in — \`signtool\` signs loose images, never a bundle tree. Nested bundles and helper executables are a darwin-only feature.`);writePayload(C,n,``);let I=t.identity===`-`,H=new Map,entitlementsFileFor=(n,S)=>{if(S.length===0)return;let C=H.get(n);if(C!==void 0)return C;let N=n===``?t.entitlementsPath:`${t.entitlementsPath}.${n}.plist`;return mkdirSync(Hn(N),{recursive:!0}),writeFileSync(N,renderEntitlements(S)),H.set(n,N),N},run=async(n,N,F,H)=>{let W=S.args({identity:t.identity,file:n,adhoc:I,seal:F,...H?{entitlements:H}:{}});t.verbose&&t.log(`${S.tool} ${W.join(` `)}`);let q=await spawnToCompletion(S.tool,W,{completion:`return`,cwd:C,stdio:`inherit`,notFound:()=>Error(`gjsify ship: \`${S.tool}\` is not on PATH — ${S.installHint}.`)});if(q.code!==0)throw Error(`gjsify ship: ${S.tool} failed on ${N} with ${describeExit(q)}. Nothing is packed from a payload whose signature failed: an artifact that is half signed installs and is refused at first launch, which is worse than not shipping.`)},W=entitlementsFileFor(``,S.entitlements(I)),q=N.map(t=>`${t.path}/`),Y=new Set(F.map(t=>t.path)),underSubordinate=t=>q.some(n=>t.startsWith(n)),X=[],Z=0;for(let t of N){let N=entitlementsFileFor(t.path,t.entitlements),F=n.filter(n=>n.path.startsWith(`${t.path}/`)&&classifyBinary(n.data)===S.signs);for(let t of F)await run(zn(C,t.path.split(`/`).join(qn)),t.path,!1,N);Z+=F.length,await run(zn(C,t.path.split(`/`).join(qn)),`${t.path} (nested bundle seal)`,!0,N),X.push(S.sealAddPrefix(t.path))}for(let t of F){let n=entitlementsFileFor(t.path,t.entitlements);await run(zn(C,t.path.split(`/`).join(qn)),t.path,!1,n)}let te=n.filter(t=>classifyBinary(t.data)===S.signs&&!underSubordinate(t.path)&&!Y.has(t.path));if(te.length===0&&!S.sealsBundle)return t.log(`nothing in this payload is a ${S.signs===`macho`?`Mach-O`:`PE`} image, so ${S.tool} signed 0 file(s). The artifact carries no signature.`),[...n];for(let t of te)await run(zn(C,t.path.split(`/`).join(qn)),t.path,!1,W);let ne;if(S.sealsBundle){if(t.bundleRoot===``)throw Error(`gjsify ship: the ${S.layoutOs} signer seals a bundle and this layout has no root to seal. \`Layout.root\` is what names the artifact directory; a signer that sealed the whole stage would sign the payload of every other format beside it.`);ne=S.sealAddPrefix(t.bundleRoot),await run(zn(C,t.bundleRoot.split(`/`).join(qn)),`${t.bundleRoot} (bundle seal)`,!0,W)}let re=[...ne===void 0?[]:[ne],...X],ie=partitionSignedFileSet({arrived:listFilesRecursive(C),planned:n.map(t=>t.path),sealPrefixes:re});if(ie.unexpected.length>0||ie.removed.length>0)throw Error(`gjsify ship: ${S.tool} changed the payload's file set — ${ie.unexpected.length} added (${ie.unexpected.slice(0,3).join(`, `)||`—`}), ${ie.removed.length} removed (${ie.removed.slice(0,3).join(`, `)||`—`}). Signing is a mutation of the files that are already in the payload (ADR 0024 § A4), plus exactly each seal's own directory${re.length===0?``:` (${re.map(t=>`\`${t}\``).join(`, `)})`}.`);let ae=ie.sealed;t.log(`${S.tool} signed ${te.length+Z+F.length} of ${n.length} payload file(s) as ${I?"ad-hoc (`-`)":`\`${t.identity}\``}${ne===void 0?``:` and sealed ${t.bundleRoot} (${ae.length} seal file(s))`}${N.length===0?``:`, nested: ${N.map(t=>t.path).join(`, `)}`} — ${S.gap}.`);let read=t=>new Uint8Array(readFileSync(zn(C,t.split(`/`).join(qn))));return[...n.map(t=>({path:t.path,mode:t.mode,data:read(t.path)})),...ae.map(t=>({path:t,mode:420,data:read(t)}))].sort((t,n)=>t.path<n.path?-1:+(t.path>n.path))}function resolveNotaryPlan(t){let n=tG[t.layoutOs];if(n===void 0){if(t.flag!==void 0)throw Error(`gjsify ship: --notarize has no meaning in the ${t.layoutOs} layout. Notarisation is Apple's pre-clearance of a signed artifact and nothing else asks for it — Windows SmartScreen accrues reputation per file hash instead (ADR 0024 § A5).`);return{kind:`unsupported`}}if(t.flag===void 0||t.flag===``)return{kind:`skip`,message:`no notarisation credential was given — skipping ${n.tool} notarytool. Pass \`--notarize <keychain-profile>\`, naming a profile a prior \`notarytool store-credentials\` put in this host's keychain.`};if(t.sign.kind!==`sign`)throw Error("gjsify ship: --notarize was given without an identity to sign with. Notarisation is a check ON a signature, so submitting an unsigned artifact has nothing to clear. Pass `--sign <identity>` as well, or drop --notarize.");return{kind:`notarize`,credential:t.flag,notary:n}}async function notarizeArtifact(t){let{notary:n,credential:S}=t.plan,C=process.platform;if(!n.notarizeOn.includes(C))throw Error(`gjsify ship: notarising the ${n.layoutOs} layout needs ${n.tool}, which runs on ${n.notarizeOn.join(`, `)} and this host is ${C}.`);let N=n.args(S,t.artifact);t.verbose&&t.log(`${n.tool} ${N.join(` `)}`);let F=await spawnToCompletion(n.tool,N,{completion:`return`,stdio:`inherit`,notFound:()=>Error(`gjsify ship: \`${n.tool}\` is not on PATH — ${n.installHint}.`)});if(F.code!==0)throw Error(`gjsify ship: ${n.tool} notarytool failed with ${describeExit(F)}.`);t.log(`${n.tool} notarytool accepted ${t.artifact}.`)}async function stapleArtifact(t){let n=[`stapler`,`staple`,t.artifact];t.verbose&&t.log(`${t.notary.tool} ${n.join(` `)}`);let S=await spawnToCompletion(t.notary.tool,n,{completion:`return`,stdio:`inherit`,notFound:()=>Error(`gjsify ship: \`${t.notary.tool}\` is not on PATH — ${t.notary.installHint}.`)});if(S.code!==0)throw Error(`gjsify ship: ${t.notary.tool} stapler failed with ${describeExit(S)}. The artifact is notarised and NOT stapled, which means every launch asks Gatekeeper to check online — and fails closed on a machine with no network. Re-run the finish phase; \`stapler\` requires internet access and the ticket may not have propagated yet.`);t.log(`${t.notary.tool} stapler attached the ticket to ${t.artifact}.`)}var eG,tG,nG=__esmMin(()=>{af(),Xn(),cL(),hv(),IU(),vU(),ZH(),$W(),eG={darwin:{layoutOs:`darwin`,tool:`codesign`,signOn:[`darwin`],installHint:"install the Xcode Command Line Tools (`xcode-select --install`) on a macOS host",signs:`macho`,args:({identity:t,file:n,entitlements:S,adhoc:C,seal:N})=>{let F=N?void 0:asciiCodesignIdentifier(n);return[`--force`,`--sign`,t,`--options`,`runtime`,...S===void 0?[]:[`--entitlements`,S],...C?[]:[`--timestamp`],...F===void 0?[]:[`--identifier`,F],n]},entitlements:t=>[`com.apple.security.cs.allow-jit`,`com.apple.security.cs.allow-unsigned-executable-memory`,`com.apple.security.cs.disable-executable-page-protection`,`com.apple.security.cs.allow-dyld-environment-variables`,...t?[`com.apple.security.cs.disable-library-validation`]:[]],sealsBundle:!0,sealAddPrefix:t=>`${t}/Contents/_CodeSignature/`,configKey:`gjsify.ship.sign.darwin.identity`,gap:"the images are signed and the bundle is sealed, and the seal survives both the `.zip` and the `.dmg` round trip; § A16 stands measured in ONE direction only — library validation refuses an ad-hoc-signed dylib, so the ad-hoc identity grants `disable-library-validation` while a named one does not; a named Developer ID was signed and notarised on 2026-10-30 for an ASCII-named app, and a non-ASCII image name verifies only with the explicit ASCII `--identifier` this signer now passes"},win32:{layoutOs:`win32`,tool:`signtool`,signOn:[`win32`],installHint:"install the Windows SDK (signtool.exe ships in its `bin/<version>/x64` directory)",signs:`pe`,args:({identity:t,file:n})=>[`sign`,`/n`,t,`/fd`,`sha256`,n],entitlements:()=>[],sealsBundle:!1,sealAddPrefix:()=>``,configKey:`gjsify.ship.sign.win32.identity`,gap:`no timestamp countersignature is requested, so the signature expires with the certificate (UNVERIFIED: no run in this repository has ever invoked signtool)`}},tG={darwin:{layoutOs:`darwin`,tool:`xcrun`,notarizeOn:[`darwin`],installHint:"install the Xcode Command Line Tools (`xcode-select --install`) on a macOS host",args:(t,n)=>[`notarytool`,`submit`,`--keychain-profile`,t,`--wait`,n]}}});function stagedFontDir(t,n){return`${t}/${On.basename(mH.fonts)}/${n}`}function shellQuote(t){return`'${t.replace(/'/g,`'\\''`)}'`}function cmdQuote(t){let n=/["%!\r\n]/.exec(t);if(n!==null)throw Error(`gjsify ship: \`gjsify.ship.execArgs\` contains ${JSON.stringify(t)}, and cmd.exe has no way to pass ${JSON.stringify(n[0])} through a Windows launcher literally — \`%\` expands at parse time and \`"\` ends the quoted run. Move the value into the app (it can read it from its own config) or drop the character.`);return`"${t}"`}function renderLauncher(t,n,S,C={}){switch(S.name){case`linux`:return renderPrefixLauncher(t,n,S);case`darwin`:return renderAppBundleLauncher(t,n,S,C);case`windows`:return renderWindowsLauncher(t,n,S,C);default:{let t=S.name;throw Error(`gjsify ship: no launcher is wired for the "${String(t)}" layout.`)}}}function renderPrefixLauncher(t,n,S){let C=S.dirs(t),N=[`#!/bin/sh`,"# Generated by `gjsify ship` — do not edit.",`set -e`,`self=$(readlink -f "$0")`,`prefix=$(dirname "$(dirname "$self")")`,`XDG_DATA_DIRS="$prefix/${C.data}:\${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"`,`export XDG_DATA_DIRS`];if(t.typelibFiles.length>0){let t=`"$prefix"/${C.native}`;for(let n of[`GI_TYPELIB_PATH`,`LD_LIBRARY_PATH`])N.push(`${n}=${t}\${${n}:+:$${n}}`,`export ${n}`)}else if(Object.values(t.formatFiles).some(t=>t.typelibFiles.length>0)){let t=`"$prefix"/${C.native}`;N.push(`if [ -d ${t} ]; then`);for(let n of[`GI_TYPELIB_PATH`,`LD_LIBRARY_PATH`])N.push(` ${n}=${t}\${${n}:+:$${n}}`,` export ${n}`);N.push(`fi`)}return t.localeFiles.length>0&&N.push(`GJSIFY_LOCALE_DIR="$prefix"/${C.data}/locale`,`export GJSIFY_LOCALE_DIR`),t.fontFiles.length>0&&N.push(`GJSIFY_FONT_DIR="$prefix"/${stagedFontDir(C.data,t.appId)}`,`export GJSIFY_FONT_DIR`),N.push(`exec ${execLine(S,`"$prefix"/${C.bundle}/${n}`,t)} "$@"`,``),N.join(`
1187
1187
  `)}function renderAppBundleLauncher(t,n,S,C){let N=`${S.root(t)}/Contents`,F=S.dirs(t),under=t=>On.relative(N,t),beside=t=>On.relative(F.launcher,t),I=[`#!/bin/sh`,"# Generated by `gjsify ship` — do not edit.",`set -e`,`here=$(cd -- "$(dirname -- "$0")" && pwd)`,`contents=$(dirname -- "$here")`,`XDG_DATA_DIRS="$contents/${under(F.data)}"\${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}`,`export XDG_DATA_DIRS`];C.gtkRuntimeDir!==void 0&&I.push(`GJSIFY_GTK_RUNTIME="$contents/${under(C.gtkRuntimeDir)}"`,`export GJSIFY_GTK_RUNTIME`),C.nodeGiAddon!==void 0&&I.push(`NODE_GI_NATIVE="$contents/${under(C.nodeGiAddon)}"`,`export NODE_GI_NATIVE`),t.typelibFiles.length>0&&(I.push(`GI_TYPELIB_PATH="$contents/${under(F.native)}"\${GI_TYPELIB_PATH:+:$GI_TYPELIB_PATH}`,`export GI_TYPELIB_PATH`),I.push(`GJSIFY_GI_LIBRARY_PATH="$contents/${under(F.native)}"\${GJSIFY_GI_LIBRARY_PATH:+:$GJSIFY_GI_LIBRARY_PATH}`,`export GJSIFY_GI_LIBRARY_PATH`)),t.localeFiles.length>0&&I.push(`GJSIFY_LOCALE_DIR="$contents/${under(F.data)}/locale"`,`export GJSIFY_LOCALE_DIR`),t.fontFiles.length>0&&I.push(`GJSIFY_FONT_DIR="$contents/${stagedFontDir(under(F.data),t.appId)}"`,`export GJSIFY_FONT_DIR`);let H=C.interpreter===void 0?void 0:`"$here/${beside(C.interpreter)}"`;return I.push(`exec ${execLine(S,`"$contents/${under(F.bundle)}/${n}"`,t,H)} "$@"`,``),I.join(`
1188
1188
  `)}function renderWindowsLauncher(t,n,S,C){let N=S.dirs(t),at=t=>`%HERE%${windowsPath(t)}`,F=[`@echo off`,`rem Generated by "gjsify ship" - do not edit.`,`setlocal`,`set "HERE=%~dp0"`,prependVar(`XDG_DATA_DIRS`,at(N.data))];C.gtkRuntimeDir!==void 0&&F.push(`set "GJSIFY_GTK_RUNTIME=${at(C.gtkRuntimeDir)}"`),C.nodeGiAddon!==void 0&&F.push(`set "NODE_GI_NATIVE=${at(C.nodeGiAddon)}"`),t.typelibFiles.length>0&&F.push(prependVar(`GI_TYPELIB_PATH`,at(N.native)),prependVar(`PATH`,at(N.native))),t.localeFiles.length>0&&F.push(`set "GJSIFY_LOCALE_DIR=${at(N.data)}\\locale"`),t.fontFiles.length>0&&F.push(`set "GJSIFY_FONT_DIR=${at(stagedFontDir(N.data,t.appId))}"`);let I=C.interpreter===void 0?void 0:`"${at(C.interpreter)}"`;return F.push(`${execLine(S,`"${at(N.bundle)}\\${windowsPath(n)}"`,t,I)} %*`,``),F.join(`\r
1189
1189
  `)}function prependVar(t,n){return`if defined ${t} (set "${t}=${n};%${t}%") else (set "${t}=${n}")`}function windowsPath(t){return t.split(`/`).filter(t=>t.length>0).join(`\\`)}function execLine(t,n,S,C){let N=t.name===`windows`?cmdQuote:shellQuote,F=S.execArgs.map(N).join(` `),I=C??(S.app===`node`?`node`:`gjs`);return`${S.app===`node`?I:`${I} -m`} ${n}${F?` ${F}`:``}`}var rG=__esmMin(()=>{Xn(),hH()});function createCpioArchive(t){let n=[],S=0;t.forEach((t,C)=>{let N=t.linkTarget===void 0?t.data??new Uint8Array:encodeUtf8(t.linkTarget),F=encodeUtf8(`${t.name}\0`),I=buildHeader({ino:t.ino??C+1,mode:t.mode,nlink:t.nlink??1,mtime:t.mtime??0,filesize:N.byteLength,namesize:F.byteLength});S=push(n,I,S),S=push(n,F,S),S=padTo4(n,S),S=push(n,N,S),S=padTo4(n,S)});let C=encodeUtf8(`TRAILER!!!\0`);return S=push(n,buildHeader({ino:0,mode:0,nlink:1,mtime:0,filesize:0,namesize:C.byteLength}),S),S=push(n,C,S),padTo4(n,S),concatBytes(n)}function buildHeader(t){let n=iG+hex8(t.ino)+hex8(t.mode)+hex8(0)+hex8(0)+hex8(t.nlink)+hex8(t.mtime)+hex8(t.filesize)+hex8(0)+hex8(0)+hex8(0)+hex8(0)+hex8(t.namesize)+hex8(0);if(n.length!==aG)throw Error(`gjsify ship: internal error — cpio header is ${n.length} bytes, expected ${aG}.`);return encodeUtf8(n)}function hex8(t){if(t<0||!Number.isInteger(t))throw Error(`gjsify ship: cpio header field must be a non-negative integer, got ${t}.`);let n=t.toString(16).toUpperCase();if(n.length>8)throw Error(`gjsify ship: cpio header field ${t} does not fit in 8 hex digits.`);return n.padStart(8,`0`)}function push(t,n,S){return n.byteLength>0&&t.push(n),S+n.byteLength}function padTo4(t,n){let S=n%4;if(S===0)return n;let C=4-S;return t.push(new Uint8Array(C)),n+C}var iG,aG,oG,sG,cG=__esmMin(()=>{eH(),iG=`070701`,aG=110,oG=32768,sG=16384});function buildRpmHeader(t,n){let S=[...t].sort((t,n)=>t.tag-n.tag),C=[],N=[],F=0;for(let t of S){if(t.tag<100)throw Error(`gjsify ship: rpm tag ${t.tag} is below 100 and would be rejected by hdrchkTag.`);let{data:n,count:S}=encodeValue(t.type,t.value,t.tag),I=fG[t.type],H=(I-F%I)%I;H>0&&(N.push(new Uint8Array(H)),F+=H),C.push({tag:t.tag,type:t.type,offset:F,count:S}),N.push(n),F+=n.byteLength}let I=F,H=C.length+1;N.push(indexEntry(n,7,-(uG*H),dG)),F+=uG;let W=new Uint8Array(lG.byteLength+8+H*uG+F),q=new DataView(W.buffer);W.set(lG,0),q.setUint32(8,H),q.setUint32(12,F);let Y=16;W.set(indexEntry(n,7,I,dG),Y),Y+=uG;for(let t of C)W.set(indexEntry(t.tag,t.type,t.offset,t.count),Y),Y+=uG;for(let t of N)W.set(t,Y),Y+=t.byteLength;return W}function indexEntry(t,n,S,C){let N=new Uint8Array(uG),F=new DataView(N.buffer);return F.setInt32(0,t),F.setInt32(4,n),F.setInt32(8,S),F.setInt32(12,C),N}function encodeValue(t,n,S){let C=new TextEncoder;switch(t){case 6:if(typeof n!=`string`)throw typeMismatch(S,`a string`);return{data:C.encode(`${n}\0`),count:1};case 8:case 9:{let t=typeof n==`string`?[n]:n;if(!Array.isArray(t))throw typeMismatch(S,`a string array`);if(t.length===0)throw Error(`gjsify ship: rpm tag ${S} has an empty array; omit it instead.`);return{data:C.encode(t.map(t=>`${t}\0`).join(``)),count:t.length}}case 7:if(!(n instanceof Uint8Array))throw typeMismatch(S,`binary data`);return{data:n,count:n.byteLength};case 3:case 4:{let C=typeof n==`number`?[n]:n;if(!Array.isArray(C))throw typeMismatch(S,`a number array`);if(C.length===0)throw Error(`gjsify ship: rpm tag ${S} has an empty array; omit it instead.`);let N=t===3?2:4,F=new Uint8Array(C.length*N),I=new DataView(F.buffer);return C.forEach((n,S)=>{t===3?I.setUint16(S*N,n&65535):I.setUint32(S*N,n>>>0)}),{data:F,count:C.length}}}}function typeMismatch(t,n){return Error(`gjsify ship: internal error — rpm tag ${t} expects ${n}.`)}function buildRpmLead(t){let n=new Uint8Array(96),S=new DataView(n.buffer);n.set([237,171,238,219],0),n[4]=3,n[5]=0,S.setInt16(6,0),S.setInt16(8,0);let C=new TextEncoder().encode(t).slice(0,65);return n.set(C,10),S.setInt16(76,0),S.setInt16(78,5),n}function padToEight(t){let n=(8-t.byteLength%8)%8;if(n===0)return t;let S=new Uint8Array(t.byteLength+n);return S.set(t,0),S}var lG,uG,dG,fG,pG=__esmMin(()=>{lG=Uint8Array.from([142,173,232,1,0,0,0,0]),uG=16,dG=16,fG={3:2,4:4,6:1,7:1,8:1,9:1}});async function buildRpm(t){let{settings:n,mtime:S}=t,C=collectFiles(t,`/${t.prefix.replace(/^\/+|\/+$/g,``)}`),N=createCpioArchive(C.map((t,n)=>({name:`.${t.path}`,mode:t.mode,data:t.data,mtime:S,ino:n+1}))),F=await gzipDeterministic(N),I=buildRpmHeader(mainHeaderEntries(t,C,N,F),63),H=concatBytes([I,F]),W=padToEight(buildRpmHeader([{tag:hG.SHA1HEADER,type:6,value:hashHex(`sha1`,I)},{tag:hG.SHA256HEADER,type:6,value:hashHex(`sha256`,I)},{tag:hG.SIZE,type:4,value:[H.byteLength]},{tag:hG.MD5,type:7,value:hashBytes(`md5`,H)},{tag:hG.PAYLOADSIZE,type:4,value:[N.byteLength]}],62));return concatBytes([buildRpmLead(`${n.binaryName}-${n.version}-${n.release}`),W,H])}function collectFiles(t,n){let S=t.payload.map(t=>{if(t.data.byteLength>4294967295)throw Error(`gjsify ship: ${t.path} is larger than 4 GiB, which needs rpm's LONGFILESIZES tag. That is not implemented — split the payload.`);return{path:`${n}/${t.path}`,mode:oG|t.mode&4095,data:t.data,isDirectory:!1}}),C=new Set;for(let t of S){let n=t.path.split(`/`).slice(1);n.pop();let S=``;for(let t of n)S=`${S}/${t}`,yG.has(S)||C.add(S)}for(let t of C)S.push({path:t,mode:sG|493,data:new Uint8Array,isDirectory:!0});return S.sort((t,n)=>t.path<n.path?-1:+(t.path>n.path))}function mainHeaderEntries(t,n,S,C){let{settings:N}=t,F=`${N.version}-${N.release}`,I=[],H=[],W=[];for(let t of n){let n=t.path.lastIndexOf(`/`),S=`${t.path.slice(0,n)}/`,C=I.indexOf(S);C===-1&&(C=I.push(S)-1),H.push(C),W.push(t.path.slice(n+1))}let q=renderRpmScriptlets(readPayloadFacts(t.payload),t.prefix),Y=buildRequires(t.depends,q,readShebangInterpreters(t.payload)),X=buildRecommends(t.recommends??[]),Z=[{tag:mG.HEADERI18NTABLE,type:8,value:[`C`]},{tag:mG.NAME,type:6,value:N.binaryName},{tag:mG.VERSION,type:6,value:N.version},{tag:mG.RELEASE,type:6,value:N.release},{tag:mG.SUMMARY,type:9,value:[N.summary]},{tag:mG.DESCRIPTION,type:9,value:[N.description.join(`
1190
1190
 
1191
- `)]},{tag:mG.BUILDTIME,type:4,value:[t.mtime]},{tag:mG.BUILDHOST,type:6,value:`localhost`},{tag:mG.SIZE,type:4,value:[n.reduce((t,n)=>t+n.data.byteLength,0)]},{tag:mG.LICENSE,type:6,value:N.license},{tag:mG.GROUP,type:9,value:[N.group]},{tag:mG.OS,type:6,value:`linux`},{tag:mG.ARCH,type:6,value:t.archLabel},{tag:mG.SOURCERPM,type:6,value:`${N.binaryName}-${F}.src.rpm`},{tag:mG.RPMVERSION,type:6,value:`4.20.0`},{tag:mG.ENCODING,type:6,value:`utf-8`},{tag:mG.FILESIZES,type:4,value:n.map(t=>t.data.byteLength)},{tag:mG.FILEMODES,type:3,value:n.map(t=>t.mode)},{tag:mG.FILERDEVS,type:3,value:n.map(()=>0)},{tag:mG.FILEMTIMES,type:4,value:n.map(()=>t.mtime)},{tag:mG.FILEDIGESTS,type:8,value:n.map(t=>t.isDirectory?``:hashHex(`sha256`,t.data))},{tag:mG.FILELINKTOS,type:8,value:n.map(()=>``)},{tag:mG.FILEFLAGS,type:4,value:n.map(()=>0)},{tag:mG.FILEUSERNAME,type:8,value:n.map(()=>`root`)},{tag:mG.FILEGROUPNAME,type:8,value:n.map(()=>`root`)},{tag:mG.FILEVERIFYFLAGS,type:4,value:n.map(()=>4294967295)},{tag:mG.FILEDEVICES,type:4,value:n.map(()=>1)},{tag:mG.FILEINODES,type:4,value:n.map((t,n)=>n+1)},{tag:mG.FILELANGS,type:8,value:n.map(()=>``)},{tag:mG.FILEDIGESTALGO,type:4,value:[_G]},{tag:mG.DIRINDEXES,type:4,value:H},{tag:mG.BASENAMES,type:8,value:W},{tag:mG.DIRNAMES,type:8,value:I},{tag:mG.PROVIDENAME,type:8,value:[N.binaryName]},{tag:mG.PROVIDEFLAGS,type:4,value:[gG.EQUAL]},{tag:mG.PROVIDEVERSION,type:8,value:[F]},{tag:mG.REQUIRENAME,type:8,value:Y.names},{tag:mG.REQUIREFLAGS,type:4,value:Y.flags},{tag:mG.REQUIREVERSION,type:8,value:Y.versions},...X.names.length>0?[{tag:mG.RECOMMENDNAME,type:8,value:X.names},{tag:mG.RECOMMENDFLAGS,type:4,value:X.flags},{tag:mG.RECOMMENDVERSION,type:8,value:X.versions}]:[],{tag:mG.PAYLOADFORMAT,type:6,value:`cpio`},{tag:mG.PAYLOADCOMPRESSOR,type:6,value:`gzip`},{tag:mG.PAYLOADFLAGS,type:6,value:`9`},{tag:mG.PAYLOADDIGEST,type:8,value:[hashHex(`sha256`,C)]},{tag:mG.PAYLOADDIGESTALGO,type:4,value:[_G]},{tag:mG.PAYLOADDIGESTALT,type:8,value:[hashHex(`sha256`,S)]}];return assertParallelFileArrays(Z,n.length),N.homepage&&Z.push({tag:mG.URL,type:6,value:N.homepage}),q.post!==void 0&&(Z.push({tag:mG.POSTIN,type:6,value:q.post}),Z.push({tag:mG.POSTINPROG,type:6,value:`/bin/sh`})),q.postun!==void 0&&(Z.push({tag:mG.POSTUN,type:6,value:q.postun}),Z.push({tag:mG.POSTUNPROG,type:6,value:`/bin/sh`})),Z}function assertParallelFileArrays(t,n){let S=new Set([mG.FILESIZES,mG.FILEMODES,mG.FILERDEVS,mG.FILEMTIMES,mG.FILEDIGESTS,mG.FILELINKTOS,mG.FILEFLAGS,mG.FILEUSERNAME,mG.FILEGROUPNAME,mG.FILEVERIFYFLAGS,mG.FILEDEVICES,mG.FILEINODES,mG.FILELANGS,mG.DIRINDEXES,mG.BASENAMES]);for(let C of t){if(!S.has(C.tag))continue;let t=Array.isArray(C.value)?C.value.length:1;if(t!==n)throw Error(`gjsify ship: internal error — rpm tag ${C.tag} has ${t} values for ${n} files.`)}}function buildRequires(t,n,S){let C=[],N=[],F=[];for(let n of t){let t=parseDepend(n);C.push(t.name),N.push(senseFor(t.relation)),F.push(t.version??``)}n.post!==void 0&&(C.push(`/bin/sh`),N.push(gG.INTERP|gG.SCRIPT_POST),F.push(``)),n.postun!==void 0&&(C.push(`/bin/sh`),N.push(gG.INTERP|gG.SCRIPT_POSTUN),F.push(``));for(let t of S)C.push(t),N.push(gG.FIND_REQUIRES),F.push(``);for(let[t,n]of vG)C.push(t),N.push(gG.RPMLIB|gG.LESS|gG.EQUAL),F.push(n);return{names:C,flags:N,versions:F}}function buildRecommends(t){let n=[],S=[],C=[];for(let N of t){let t=parseDepend(N);n.push(t.name),S.push(senseFor(t.relation)),C.push(t.version??``)}return{names:n,flags:S,versions:C}}function senseFor(t){switch(t){case`>=`:return gG.GREATER|gG.EQUAL;case`>`:return gG.GREATER;case`<=`:return gG.LESS|gG.EQUAL;case`<`:return gG.LESS;case`=`:return gG.EQUAL;default:return 0}}function hashHex(t,n){return createHash(t).update(n).digest(`hex`)}function hashBytes(t,n){return new Uint8Array(createHash(t).update(n).digest())}var mG,hG,gG,_G,vG,yG,bG=__esmMin(()=>{gl(),eH(),cG(),fH(),vU(),pG(),pH(),gH(),hH(),mG={HEADERI18NTABLE:100,NAME:1e3,VERSION:1001,RELEASE:1002,SUMMARY:1004,DESCRIPTION:1005,BUILDTIME:1006,BUILDHOST:1007,SIZE:1009,LICENSE:1014,GROUP:1016,URL:1020,OS:1021,ARCH:1022,POSTIN:1024,POSTUN:1026,FILESIZES:1028,FILEMODES:1030,FILERDEVS:1033,FILEMTIMES:1034,FILEDIGESTS:1035,FILELINKTOS:1036,FILEFLAGS:1037,FILEUSERNAME:1039,FILEGROUPNAME:1040,SOURCERPM:1044,FILEVERIFYFLAGS:1045,PROVIDENAME:1047,REQUIREFLAGS:1048,REQUIRENAME:1049,REQUIREVERSION:1050,RECOMMENDNAME:5046,RECOMMENDVERSION:5047,RECOMMENDFLAGS:5048,RPMVERSION:1064,POSTINPROG:1086,POSTUNPROG:1088,FILEDEVICES:1095,FILEINODES:1096,FILELANGS:1097,PROVIDEFLAGS:1112,PROVIDEVERSION:1113,DIRINDEXES:1116,BASENAMES:1117,DIRNAMES:1118,PAYLOADFORMAT:1124,PAYLOADCOMPRESSOR:1125,PAYLOADFLAGS:1126,FILEDIGESTALGO:5011,ENCODING:5062,PAYLOADDIGEST:5092,PAYLOADDIGESTALGO:5093,PAYLOADDIGESTALT:5097},hG={SIZE:1e3,MD5:1004,PAYLOADSIZE:1007,SHA1HEADER:269,SHA256HEADER:273},gG={LESS:2,GREATER:4,EQUAL:8,INTERP:256,SCRIPT_POST:1024,SCRIPT_POSTUN:4096,FIND_REQUIRES:16384,RPMLIB:1<<24},_G=8,vG=[[`rpmlib(CompressedFileNames)`,`3.0.4-1`],[`rpmlib(FileDigests)`,`4.6.0-1`],[`rpmlib(PayloadFilesHavePrefix)`,`4.0-1`]],yG=new Set([`/usr`,`/usr/bin`,`/usr/lib`,`/usr/lib64`,`/usr/libexec`,`/usr/sbin`,`/usr/share`,`/usr/${mH.applications}`,`/usr/share/doc`,`/usr/share/icons`,`/usr/share/licenses`,`/usr/share/man`,`/usr/${mH.metainfo}`,`/usr/share/glib-2.0`,`/usr/${mH.schemas}`,`/usr/${mH.fonts}`,`/etc`,`/opt`,`/var`])});async function assemble(t){let n=process.cwd(),S=t.os===void 0?hostLayout():resolveLayout(t.os),C=await new Config().forCommand(n),N=C.ship??{},F=C.flatpak??{},I=resolveShipApp({project:C.app,perTarget:N.app,layoutOs:S.os}),H=I.app;I.overridden&&ge.log(`${xG} runtime for ${S.name}: ${H} — \`${I.key}\` overrides \`gjsify.app${C.app===void 0?``:`: "${C.app}"`}\`.`);let W=readPackageJson$2(zn(n,`package.json`))??{},q,Y=[];if(t.target!==void 0)q=resolveFormats(t.target,S);else if(N.targets!==void 0){let t=configuredFormats(N.targets,S);q=t.formats,t.dropped.length>0&&ge.log(`${xG} \`gjsify.ship.targets\` names ${t.dropped.join(`, `)}, which wrap another layout — not built for ${S.name}. Pass --target to ask for one explicitly.`)}else{let t=defaultFormatIds(S.os).map(t=>kW[t]);q=t.filter(t=>t.interpreters.includes(H)),Y=t.filter(t=>!t.interpreters.includes(H)),Y.length>0&&ge.log(`${xG} ${Y.map(t=>t.id).join(`, `)} wrap the ${S.name} layout but cannot run \`${H}\`, which \`${I.key}\` resolves to — ${Y[0]?.interpreterGap??``}. Set \`gjsify.ship.app.${S.os}\` to "${Y[0]?.interpreters.join(`" / "`)}" to ship this OS on that runtime; it leaves every other target on \`gjsify.app\`. Assembling the layout only; pass --target to be told the same thing as an error.`)}q.some(t=>t.id===`flatpak`)&&assertNoDroppedFlatpakModules(F),t.stage||assertPackable(q,S,t.os===void 0?`host`:`positional`,Y);let X=resolveSignPlan({flag:t.sign,config:N.sign,layoutOs:S.os}),Z=resolveNotaryPlan({flag:t.notarize,layoutOs:S.os,sign:X});if(t.stage&&assertNothingToSignYet(t),t.stage||(announceSigning(X,Z),X.kind===`sign`&&assertHostCanSign(X.signer)),t.stage||assertKindCanPack(q,resolveShipKind(N,F)),!t.stage)for(let t of q)assertCanPack(t);let te=parseDeclaredChannel(t.channel,`--channel`)??parseDeclaredChannel(N.channel,`gjsify.ship.channel`)??(q.some(t=>t.id===`flatpak`)?`flathub`:void 0),ne=parseDeclaredPricing(t.pricing,`--pricing`)??parseDeclaredPricing(N.pricing,`gjsify.ship.pricing`)??`free`;t[`skip-build`]||await runProjectBuild(n,te,ne);let re=resolveShipBundle({pkg:W,ship:N,layoutOs:S.os});re.overridden&&ge.log(`${xG} entry for ${S.name}: ${re.declared} — \`${re.key}\` overrides \`gjsify.main\`.`);let ie=discoverPayload({projectDir:n,pkg:W,ship:N,flatpakIcon:F.icon,declaredBundle:re.declared,layoutOs:S.os,foreignBundles:re.foreign}),{settings:ae,metadata:oe,warnings:Q}=resolveShipSettings({projectDir:n,pkg:W,ship:N,flatpak:F,cli:{outDir:t.out,arch:t.arch,layoutOs:S.os},discovered:ie,app:H});for(let t of Q)ge.warn(`${xG} ${t}`);for(let t of q)assertFormatCanRunInterpreter(t,ae.app);let se=readFileSync(ae.bundlePath,`utf-8`);assertEntryRunsUnder({interpreter:ae.app,source:se,entry:Bn(n,ae.bundlePath)||ae.bundlePath,appKey:I.key,bundleKey:re.key,layoutOs:S.os});let ce=buildTimestamp(ae.bundlePath),le={appId:ae.appId,name:ae.name,command:ae.binaryName,kind:ae.kind,metadata:oe,desktopExecArgs:ae.desktopExecArgs,channel:te,configKey:`gjsify.ship`,copyrightYear:new Date(ce*1e3).getUTCFullYear()};for(let t of validateAppMetadata(le))ge.warn(`${xG} ${t.field} is not set — ${t.hint}`);ae.licenseFile!==void 0&&Hn(ae.licenseFile)!==n&&ge.log(`${xG} licence text from ${Bn(n,ae.licenseFile)} (this package carries none of its own)`);let ue=localizeMetadata({metainfo:ae.kind===`app`?renderMetainfoApp$1(le):renderMetainfoCli$1(le),desktopEntry:ae.kind===`app`?renderDesktopEntry(le):void 0},ae.localeFiles),de=await resolveCarriedRuntime(S,ae,n);carryNodeModules(de,S,ae,n,N.nodeModules,N.nodeModulesExclude);let fe=stageSubordinates({layout:S,identity:ae,nestedBundles:ae.nestedBundles,helperExecutables:ae.helperExecutables,mainExecutable:ae.mainExecutableSource}),pe={bundleFiles:ie.bundleFiles,launcher:renderLauncher(ae,Un(ae.bundlePath),S,de.launcher),executableLaunchers:Object.fromEntries(ae.executables.map(t=>[t.name,renderLauncher(ae,t.entry,S,de.launcher)])),metainfo:ue.metainfo,desktopEntry:ue.desktopEntry,licenseText:ae.licenseFile===void 0?void 0:readFileSync(ae.licenseFile,`utf-8`),changelogText:ae.changelogFile===void 0?void 0:readFileSync(ae.changelogFile,`utf-8`),mtime:ce},me=In(n,ae.outDir),he=zn(me,`stage`),_e=[...planStage(ae,pe),...S.os===`linux`?[]:await compileSchemasForStage({schemaFiles:ae.schemaFiles,workDir:zn(me,`schemas`)})],ve=ae.kind===`app`&&S.icon!==void 0&&(S.icon.required||ae.iconFiles.length>0)?await resolveAppIcon({iconFiles:ae.iconFiles,appId:ae.appId,sizes:S.icon.sizes,target:S.icon.writes}):void 0;ve!==void 0&&ge.log(`${xG} icon: ${iconSizes(ve).join(`/`)} px, ${ve.source}`);let ye=placeStage(S,{...ae,icon:ve,categories:oe.categories},_e,[...de.files,...fe.files]);if(writeStage(he,ye),ge.log(`${xG} staged ${ye.length} file(s) for ${S.name} in ${Bn(n,he)}/`),t.verbose)for(let t of ye)ge.log(`${xG} ${t.path}`);if(assertPayloadMatchesArch(readStage([he],ye),ae.arch,{exempt:payloadArchExemptions(S.os,ae)}),S.os!==`linux`){let t=linuxInstallDependent(_e);if(t.length>0){ge.warn(`${xG} the ${S.name} layout carries ${t.length} file(s) whose Linux correctness comes from a package install step it has no equivalent for:`);let n={aborts:`ABORTS: `,unknown:`UNCLASSIFIED: `,inert:``};for(let{path:S,verdict:C,why:N}of t)ge.warn(`${xG} ${n[C]??``}${S} — ${N}`)}for(let t of de.found)ge.log(`${xG} carries its own ${t}`);for(let t of de.missing)ge.warn(`${xG} ${t}`);de.launcher.interpreter===void 0&&S.runtimeGap!==void 0&&ge.warn(`${xG} ${S.runtimeGap}`),S.fontGap!==void 0&&_e.some(t=>isUnder(t.path,mH.fonts))&&ge.warn(`${xG} ${S.fontGap}`),S.arches!==null&&!S.arches.only.includes(ae.arch)&&ge.warn(`${xG} this stage is labelled ${ae.arch} and the ${S.name} layout has no runtime for it — ${S.arches.why}. Nothing can pack this stage; \`--arch ${S.arches.only.join(`|`)}\` is what produces an artifact.`)}let be=scanGiRequirements(se),xe=be.namespaces,Se=be.optional;if(t.verbose){let t=xe.filter(t=>!Se.includes(t));ge.log(`${xG} gi namespaces: ${xe.join(`, `)||`(none)`}`),Se.length>0&&(ge.log(`${xG} gi optional namespaces: ${Se.join(`, `)}`),ge.log(`${xG} gi required namespaces: ${t.join(`, `)||`(none)`}`))}let Ce=new Map;for(let t of q)Ce.set(t.id,(await planOverlay(ae,t,pe)).map(t=>({...t,path:place(S,ae,t.path)})));let we=readPayloadFacts(_e);for(let t of q){if(t.depends===null)continue;let n=deriveDepends(t.depends,{namespaces:xe,optionalNamespaces:Se,hasIcons:we.hasIcons,hasSchemas:we.hasSchemas,interpreter:ae.app,extra:ae.extraDepends[t.depends],typelibPackages:ae.typelibPackages,bundledTypelibs:we.bundledTypelibs,minGjsVersion:ae.minGjsVersion,minNodeVersion:ae.minNodeVersion});for(let S of n.unmappedOptional)ge.warn(`${xG} gi://${S} is imported optionally, but no ${t.depends} package is known to ship its typelib, so no Recommends entry names it. The package builds and runs without it. Add the row if the namespace should be recommended: \`gjsify.ship.typelibPackages.${S} = { "${t.depends}": "…" }\`.`);let S=ae.app===`node`?warnAboutNodeFloor(t.depends,ae.minNodeVersion):warnAboutGjsFloor(t.depends,ae.minGjsVersion);for(let t of S)ge.warn(`${xG} ${t}`)}let Te=writeStageManifest({stageDir:he,settings:ae,formats:q,mtime:ce,namespaces:xe,optionalNamespaces:Se,staged:ye,overlay:Ce});if(t.stage){let t=Y.length>0?`(none — ${Y.map(t=>t.id).join(` and `)} need \`gjsify.ship.app.${S.os}: "node"\`)`:formatIdsFor(S.os).length===0?`(none — no format wraps the ${S.name} layout)`:`(none asked for)`,n=Te.formats.join(`, `)||t;ge.log(`${xG} stage manifest: ${formatTarget(Te.target)}, formats ${n}`);return}let Ee=[];for(let n of q)Ee.push(await packOne({format:n,settings:ae,arch:ae.arch,staged:ye,overlay:Ce.get(n.id)??[],stageDir:he,outRoot:me,namespaces:xe,optionalNamespaces:Se,mtime:ce,sign:X,notarize:Z,verbose:t.verbose}));printArtifacts(n,Ee)}function assertNothingToSignYet(t){let n=t.sign===void 0?t.notarize===void 0?void 0:`--notarize`:`--sign`;if(n!==void 0)throw Error(`gjsify ship: ${n} belongs to the finish phase, and --stage produces no artifact to sign — it writes the tree a packing host reads back. Assemble here, then run \`gjsify ship --from-stage <dir> --sign <identity>\` on the host that holds the identity (ADR 0024 § A2, § A14).`)}function announceSigning(t,n){t.kind===`skip`&&ge.warn(`${xG} ${t.message}`),n.kind===`skip`&&t.kind===`sign`&&ge.warn(`${xG} ${n.message}`)}async function resolveCarriedRuntime(t,n,S){let C={files:[],launcher:{},found:[],missing:[]};if(t.os===`linux`||n.app!==`node`)return C;let N=`${t.os}-${n.arch}`;if(!isGtkRuntimeTarget(N))return C;let F=await acquireGtkRuntime({target:N,version:cliVersion(),discovery:{cwd:S},ensure:async S=>(await ensurePkgDir(parseSpec(S),{verbose:!1,cacheMaxAge:CG,frozen:!1,platform:{os:t.os,cpu:n.arch}})).pkgDir,log:t=>ge.log(`${xG} ${t}`)});return stageAppRuntime({layout:t,identity:n,target:N,cwd:S,interpreter:isNodeRuntimeTarget(N)?resolveNodeRuntime(N,{cwd:S}):null,...F.kind===`fetched`?{fetchedGtkRuntimeDir:F.dir}:{},...F.kind===`failed`?{gtkFetchFailure:F.reason}:{}})}function carryNodeModules(t,n,S,C,N,F){if(N===void 0||N.length===0)return;let I=resolveNodeModulesClosure(N,C,{target:{os:n.os,cpu:S.arch},exclude:F});t.files.push(...stageNodeModules(I,n.dirs(S).bundle)),t.found.push(`node_modules: ${I.packages.length} package(s) for ${N.join(`, `)}`),I.skippedPrebuilds!==void 0&&I.skippedPrebuilds.length>0&&ge.log(`${xG} node_modules: left out, prebuilds for another platform than ${n.os}-${S.arch}: `+I.skippedPrebuilds.join(`, `)),I.excluded.length>0&&ge.log(`${xG} node_modules: left out by gjsify.ship.nodeModulesExclude: ${I.excluded.join(`, `)}`),I.skippedForTarget.length>0&&ge.log(`${xG} node_modules: left out, installed but built for another platform than ${n.os}-${S.arch}: `+I.skippedForTarget.join(`, `)),I.skippedOptional.length>0&&ge.log(`${xG} node_modules: ${I.skippedOptional.length} optional dependenc(ies) not installed, so not carried (other platforms' builds): ${I.skippedOptional.join(`, `)}`)}async function finishFromStage(t,n){if(t.stage)throw Error("gjsify ship: --stage and --from-stage are the two halves of one split and cannot run together. `--stage` assembles a payload and stops; `--from-stage <dir>` packs one that is already assembled. Run them as two commands, on the host each belongs on (ADR 0024 § A2).");if(t[`skip-build`])throw Error(`gjsify ship: --from-stage never runs a build — the payload it packs was built and staged by an earlier run — so --skip-build has nothing to skip. Drop it.`);if(t.arch!==void 0)throw Error("gjsify ship: --arch is decided when the stage is assembled, not when it is packed: the launcher, the payload and the recorded target were all fixed then. Pass --arch to `gjsify ship --stage`, and use `--expect-target <os>-<arch>` here to assert which leg you are packing.");if(t.os!==void 0)throw Error(`gjsify ship: the layout is decided when the stage is assembled, so "${t.os}" has nothing to change here — the staged tree already IS one OS's layout. Use \`--expect-target <os>-<arch>\` to assert which one you are packing.`);let S=process.cwd(),C=In(S,n),N=readStageManifest(C);assertExpectedTarget(N,t[`expect-target`]);let F=layoutForOs(N.target.os);t.target===void 0&&assertPackable(N.formats.map(t=>kW[t]),F,`stage`,defaultFormatIds(F.os).map(t=>kW[t]).filter(t=>!t.interpreters.includes(N.settings.app)));let I=resolveFormats(t.target??N.formats,F);assertFormatsStaged(N,I);for(let t of I)assertCanPack(t);let H=resolveSignPlan({flag:t.sign,layoutOs:F.os}),W=resolveNotaryPlan({flag:t.notarize,layoutOs:F.os,sign:H});announceSigning(H,W),H.kind===`sign`&&assertHostCanSign(H.signer);for(let t of warnOnToolSkew(N))ge.warn(`${xG} ${t}`);let{mtime:q,warnings:Y}=resolveStageMtime(N);for(let t of Y)ge.warn(`${xG} ${t}`);if(ge.log(`${xG} packing ${N.settings.binaryName} ${N.settings.version}-${N.settings.release} for ${formatTarget(N.target)} from ${Bn(S,C)||`.`}/`),t.verbose){for(let t of N.staged)ge.log(`${xG} ${t.path}`);ge.log(`${xG} gi namespaces: ${N.namespaces.join(`, `)||`(none)`}`),(N.optionalNamespaces??[]).length>0&&ge.log(`${xG} gi optional namespaces: ${N.optionalNamespaces?.join(`, `)}`)}let X=t.out===void 0?Hn(C):In(S,t.out),Z=[];for(let n of I){if(assertFormatCanRunInterpreter(n,N.settings.app),n.depends!==null){let t=N.settings.app===`node`?warnAboutNodeFloor(n.depends,N.settings.minNodeVersion):warnAboutGjsFloor(n.depends,N.settings.minGjsVersion);for(let n of t)ge.warn(`${xG} ${n}`)}Z.push(await packOne({format:n,settings:N.settings,arch:N.target.arch,staged:N.staged,overlay:overlayFiles(N,n.id),stageDir:C,outRoot:X,namespaces:N.namespaces,optionalNamespaces:N.optionalNamespaces??[],mtime:q,sign:H,notarize:W,verbose:t.verbose}))}printArtifacts(S,Z)}async function packOne(t){let{format:n,settings:S,stageDir:C,outRoot:N,mtime:F}=t;assertOverlayIsLicensed(n.id,S.binaryName,t.overlay);let I=zn(N,`overlay`,n.id);writeStage(I,t.overlay);let H=readStage([C,I],[...t.staged,...t.overlay]),W=readPayloadFacts(H),q=n.depends===null?{requires:[],recommends:[],unmappedOptional:[]}:deriveDepends(n.depends,{namespaces:t.namespaces,optionalNamespaces:t.optionalNamespaces,hasIcons:W.hasIcons,hasSchemas:W.hasSchemas,interpreter:S.app,extra:S.extraDepends[n.depends],typelibPackages:S.typelibPackages,bundledTypelibs:W.bundledTypelibs,minGjsVersion:S.minGjsVersion,minNodeVersion:S.minNodeVersion}),Y=q.requires,X=q.recommends;assertPayloadMatchesArch(H,t.arch,{exempt:payloadArchExemptions(n.layoutOs,S)});let Z=layoutForOs(n.layoutOs);assertLauncherMatchesInterpreter(H,Z,S,S.app),assertLayoutSupportsArch(Z,t.arch);let te=signedSubordinatesFor(Z,S,S),ne=t.sign.kind===`sign`?await signPayload({payload:H,identity:t.sign.identity,signer:t.sign.signer,workDir:zn(N,`signed`,n.id),bundleRoot:Z.root(S),entitlementsPath:zn(N,`signed`,`${n.id}.entitlements.plist`),nestedBundles:te.nestedBundles,helperExecutables:te.helperExecutables,verbose:t.verbose,log:t=>ge.log(`${xG} ${t}`)}):H,re=n.archName(t.arch,isArchIndependent(ne)),ie={settings:S,payload:ne,prefix:n.prefix,depends:Y,recommends:X,archLabel:re,mtime:F},ae=zn(N,`out`);mkdirSync(ae,{recursive:!0});let oe=zn(ae,n.fileName(S,re));switch(n.id){case`deb`:writeFileSync(oe,await buildDeb(ie));break;case`rpm`:writeFileSync(oe,await buildRpm(ie));break;case`flatpak`:await buildFlatpakBundle({settings:S,stageDir:C,overlayDir:I,stageManifestFile:ZW,workDir:zn(N,`flatpak`),target:oe,archLabel:re,verbose:t.verbose});break;case`appimage`:{let n=appImageHostRequirements({app:S.app,minGjsVersion:S.minGjsVersion,minNodeVersion:S.minNodeVersion,namespaces:t.namespaces,optionalNamespaces:t.optionalNamespaces,bundledTypelibs:W.bundledTypelibs}),C=appDirFor(N),I=appDirPayload(S,ne,n,await compileSchemasForPayload({payload:ne,workDir:zn(N,`appimage-schemas`)}));writePayload(C,I,``),stampAppDirTimes(C,I,F),ge.log(`${xG} the AppImage takes these from the host: ${n.join(`, `)}`);let H=findPinnedRuntime(re);ge.log(`${xG} ${appImageRuntimeNotice(re,H)}`),await buildAppImage({appDir:C,target:oe,archLabel:re,runtimeFile:H,workDir:Hn(C),verbose:t.verbose});break}case`linux-tar`:case`linux-tar-flatpak`:{let t=n.id===`linux-tar-flatpak`?await compileSchemasForPayload({payload:ne,workDir:zn(N,`tar-schemas`)}):void 0;writeFileSync(oe,await buildLinuxTarball({settings:S,payload:t===void 0?ne:[...ne,t],archLabel:re,mtime:F}));break}case`macos-app`:case`windows-dir`:writePayload(oe,ne,Z.root(S));break;case`macos-app-dmg`:{let n=dmgVolumeDir(N);if(writePayload(n,ne,``),t.notarize.kind===`notarize`){let C=t.notarize,N=zn(n,`${S.name}.app`),I=zn(Hn(n),`bundle-notarize.zip`);await stapleBundleBeforeImage({writeArchive:()=>writeFileSync(I,buildZip(zipEntriesFromPayload(ne),F)),notarize:()=>notarizeArtifact({plan:C,artifact:I,verbose:t.verbose,log:t=>ge.log(`${xG} ${t}`)}),staple:()=>stapleArtifact({notary:C.notary,artifact:N,verbose:t.verbose,log:t=>ge.log(`${xG} ${t}`)})})}addApplicationsLink(n),await buildDmgImage({volumeName:dmgVolumeName(S),sourceDir:n,target:oe,workDir:Hn(n),verbose:t.verbose}),t.sign.kind===`sign`&&await signDmgImage({identity:t.sign.identity,file:oe,adhoc:t.sign.identity===`-`,workDir:Hn(n),verbose:t.verbose});break}case`macos-app-zip`:writeFileSync(oe,buildZip(zipEntriesFromPayload(ne),F));break;case`windows-dir-zip`:writeFileSync(oe,buildZip(zipEntriesFromPayload(ne,windowsProgramDirName(S)),F));break;case`msi`:{let n=zn(N,`msi`);writePayload(zn(n,FW),ne,Z.root(S)),await buildMsi({settings:S,files:ne.map(t=>({path:t.path,source:`${FW}/${t.path}`})),programDirName:windowsProgramDirName(S),archLabel:re,workDir:n,target:oe,verbose:t.verbose});break}default:{let t=n.id;throw Error(`gjsify ship: no packer is wired for format "${String(t)}".`)}}let Q=n.artifactKind===`directory`?directorySize(oe):statSync(oe).size,se=!1,ce=!1;if(t.notarize.kind===`notarize`&&(n.artifactKind===`directory`?ge.warn(`${xG} ${n.id} is a directory, and notarytool submits an archive or an installer — not notarised. The container format beside it is what carries the ticket.`):(await notarizeArtifact({plan:t.notarize,artifact:oe,verbose:t.verbose,log:t=>ge.log(`${xG} ${t}`)}),se=!0,canCarryTicket(n.id)?(await stapleArtifact({notary:t.notarize.notary,artifact:oe,verbose:t.verbose,log:t=>ge.log(`${xG} ${t}`)}),ce=!0):ge.warn(`${xG} ${n.id} is notarised and NOT stapled: \`stapler\` takes a UDIF image, a signed flat package or a code-signed bundle, and an archive is none of them. Apple's remedy is to staple each item that went INTO the archive and re-create it — for this artifact that is the \`.app\`, which \`--target macos-app\` writes beside it.`))),n.artifactKind===`file`){let S=writeReleaseRecord({file:oe,format:n.id,os:n.layoutOs,arch:isArchIndependent(ne)?`noarch`:t.arch,signature:recordedSignature(t.sign.kind===`sign`?t.sign.identity:void 0,`-`),notarized:se,stapled:ce,nestedBundles:recordedNestedBundles(ne,te.nestedBundles),generator:`@gjsify/cli ${cliVersion()}`});t.verbose&&ge.log(`${xG} release record: ${S}`)}return{format:n.id,path:oe,size:Q}}function printArtifacts(t,n){for(let S of n)ge.log(`${xG} ${S.format}: ${Bn(t,S.path)} (${S.size} bytes)`)}function assertCanPack(t){assertHostCanFinish(t),assertToolsInstalled(t)}function assertPackable(t,n,S,C=[]){if(t.length>0)return;if(C.length>0)throw Error(`gjsify ship: ${C.map(t=>t.id).join(` and `)} wrap the ${n.name} layout, and neither can run this project — ${C[0]?.interpreterGap??``}.\n Set \`gjsify.ship.app.${n.os}\` to "${C[0]?.interpreters.join(`" / "`)}" — it overrides \`gjsify.app\` for THIS target and\n leaves every other one alone, which is what lets one project be GJS on Linux and Node here.
1191
+ `)]},{tag:mG.BUILDTIME,type:4,value:[t.mtime]},{tag:mG.BUILDHOST,type:6,value:`localhost`},{tag:mG.SIZE,type:4,value:[n.reduce((t,n)=>t+n.data.byteLength,0)]},{tag:mG.LICENSE,type:6,value:N.license},{tag:mG.GROUP,type:9,value:[N.group]},{tag:mG.OS,type:6,value:`linux`},{tag:mG.ARCH,type:6,value:t.archLabel},{tag:mG.SOURCERPM,type:6,value:`${N.binaryName}-${F}.src.rpm`},{tag:mG.RPMVERSION,type:6,value:`4.20.0`},{tag:mG.ENCODING,type:6,value:`utf-8`},{tag:mG.FILESIZES,type:4,value:n.map(t=>t.data.byteLength)},{tag:mG.FILEMODES,type:3,value:n.map(t=>t.mode)},{tag:mG.FILERDEVS,type:3,value:n.map(()=>0)},{tag:mG.FILEMTIMES,type:4,value:n.map(()=>t.mtime)},{tag:mG.FILEDIGESTS,type:8,value:n.map(t=>t.isDirectory?``:hashHex(`sha256`,t.data))},{tag:mG.FILELINKTOS,type:8,value:n.map(()=>``)},{tag:mG.FILEFLAGS,type:4,value:n.map(()=>0)},{tag:mG.FILEUSERNAME,type:8,value:n.map(()=>`root`)},{tag:mG.FILEGROUPNAME,type:8,value:n.map(()=>`root`)},{tag:mG.FILEVERIFYFLAGS,type:4,value:n.map(()=>4294967295)},{tag:mG.FILEDEVICES,type:4,value:n.map(()=>1)},{tag:mG.FILEINODES,type:4,value:n.map((t,n)=>n+1)},{tag:mG.FILELANGS,type:8,value:n.map(()=>``)},{tag:mG.FILEDIGESTALGO,type:4,value:[_G]},{tag:mG.DIRINDEXES,type:4,value:H},{tag:mG.BASENAMES,type:8,value:W},{tag:mG.DIRNAMES,type:8,value:I},{tag:mG.PROVIDENAME,type:8,value:[N.binaryName]},{tag:mG.PROVIDEFLAGS,type:4,value:[gG.EQUAL]},{tag:mG.PROVIDEVERSION,type:8,value:[F]},{tag:mG.REQUIRENAME,type:8,value:Y.names},{tag:mG.REQUIREFLAGS,type:4,value:Y.flags},{tag:mG.REQUIREVERSION,type:8,value:Y.versions},...X.names.length>0?[{tag:mG.RECOMMENDNAME,type:8,value:X.names},{tag:mG.RECOMMENDFLAGS,type:4,value:X.flags},{tag:mG.RECOMMENDVERSION,type:8,value:X.versions}]:[],{tag:mG.PAYLOADFORMAT,type:6,value:`cpio`},{tag:mG.PAYLOADCOMPRESSOR,type:6,value:`gzip`},{tag:mG.PAYLOADFLAGS,type:6,value:`9`},{tag:mG.PAYLOADDIGEST,type:8,value:[hashHex(`sha256`,C)]},{tag:mG.PAYLOADDIGESTALGO,type:4,value:[_G]},{tag:mG.PAYLOADDIGESTALT,type:8,value:[hashHex(`sha256`,S)]}];return assertParallelFileArrays(Z,n.length),N.homepage&&Z.push({tag:mG.URL,type:6,value:N.homepage}),q.post!==void 0&&(Z.push({tag:mG.POSTIN,type:6,value:q.post}),Z.push({tag:mG.POSTINPROG,type:6,value:`/bin/sh`})),q.postun!==void 0&&(Z.push({tag:mG.POSTUN,type:6,value:q.postun}),Z.push({tag:mG.POSTUNPROG,type:6,value:`/bin/sh`})),Z}function assertParallelFileArrays(t,n){let S=new Set([mG.FILESIZES,mG.FILEMODES,mG.FILERDEVS,mG.FILEMTIMES,mG.FILEDIGESTS,mG.FILELINKTOS,mG.FILEFLAGS,mG.FILEUSERNAME,mG.FILEGROUPNAME,mG.FILEVERIFYFLAGS,mG.FILEDEVICES,mG.FILEINODES,mG.FILELANGS,mG.DIRINDEXES,mG.BASENAMES]);for(let C of t){if(!S.has(C.tag))continue;let t=Array.isArray(C.value)?C.value.length:1;if(t!==n)throw Error(`gjsify ship: internal error — rpm tag ${C.tag} has ${t} values for ${n} files.`)}}function buildRequires(t,n,S){let C=[],N=[],F=[];for(let n of t){let t=parseDepend(n);C.push(t.name),N.push(senseFor(t.relation)),F.push(t.version??``)}n.post!==void 0&&(C.push(`/bin/sh`),N.push(gG.INTERP|gG.SCRIPT_POST),F.push(``)),n.postun!==void 0&&(C.push(`/bin/sh`),N.push(gG.INTERP|gG.SCRIPT_POSTUN),F.push(``));for(let t of S)C.push(t),N.push(gG.FIND_REQUIRES),F.push(``);for(let[t,n]of vG)C.push(t),N.push(gG.RPMLIB|gG.LESS|gG.EQUAL),F.push(n);return{names:C,flags:N,versions:F}}function buildRecommends(t){let n=[],S=[],C=[];for(let N of t){let t=parseDepend(N);n.push(t.name),S.push(senseFor(t.relation)),C.push(t.version??``)}return{names:n,flags:S,versions:C}}function senseFor(t){switch(t){case`>=`:return gG.GREATER|gG.EQUAL;case`>`:return gG.GREATER;case`<=`:return gG.LESS|gG.EQUAL;case`<`:return gG.LESS;case`=`:return gG.EQUAL;default:return 0}}function hashHex(t,n){return createHash(t).update(n).digest(`hex`)}function hashBytes(t,n){return new Uint8Array(createHash(t).update(n).digest())}var mG,hG,gG,_G,vG,yG,bG=__esmMin(()=>{gl(),eH(),cG(),fH(),vU(),pG(),pH(),gH(),hH(),mG={HEADERI18NTABLE:100,NAME:1e3,VERSION:1001,RELEASE:1002,SUMMARY:1004,DESCRIPTION:1005,BUILDTIME:1006,BUILDHOST:1007,SIZE:1009,LICENSE:1014,GROUP:1016,URL:1020,OS:1021,ARCH:1022,POSTIN:1024,POSTUN:1026,FILESIZES:1028,FILEMODES:1030,FILERDEVS:1033,FILEMTIMES:1034,FILEDIGESTS:1035,FILELINKTOS:1036,FILEFLAGS:1037,FILEUSERNAME:1039,FILEGROUPNAME:1040,SOURCERPM:1044,FILEVERIFYFLAGS:1045,PROVIDENAME:1047,REQUIREFLAGS:1048,REQUIRENAME:1049,REQUIREVERSION:1050,RECOMMENDNAME:5046,RECOMMENDVERSION:5047,RECOMMENDFLAGS:5048,RPMVERSION:1064,POSTINPROG:1086,POSTUNPROG:1088,FILEDEVICES:1095,FILEINODES:1096,FILELANGS:1097,PROVIDEFLAGS:1112,PROVIDEVERSION:1113,DIRINDEXES:1116,BASENAMES:1117,DIRNAMES:1118,PAYLOADFORMAT:1124,PAYLOADCOMPRESSOR:1125,PAYLOADFLAGS:1126,FILEDIGESTALGO:5011,ENCODING:5062,PAYLOADDIGEST:5092,PAYLOADDIGESTALGO:5093,PAYLOADDIGESTALT:5097},hG={SIZE:1e3,MD5:1004,PAYLOADSIZE:1007,SHA1HEADER:269,SHA256HEADER:273},gG={LESS:2,GREATER:4,EQUAL:8,INTERP:256,SCRIPT_POST:1024,SCRIPT_POSTUN:4096,FIND_REQUIRES:16384,RPMLIB:1<<24},_G=8,vG=[[`rpmlib(CompressedFileNames)`,`3.0.4-1`],[`rpmlib(FileDigests)`,`4.6.0-1`],[`rpmlib(PayloadFilesHavePrefix)`,`4.0-1`]],yG=new Set([`/usr`,`/usr/bin`,`/usr/lib`,`/usr/lib64`,`/usr/libexec`,`/usr/sbin`,`/usr/share`,`/usr/${mH.applications}`,`/usr/share/doc`,`/usr/share/icons`,`/usr/share/licenses`,`/usr/share/man`,`/usr/${mH.metainfo}`,`/usr/share/glib-2.0`,`/usr/${mH.schemas}`,`/usr/${mH.fonts}`,`/etc`,`/opt`,`/var`])});async function assemble(t){let n=process.cwd(),S=t.os===void 0?hostLayout():resolveLayout(t.os),C=await new Config().forCommand(n),N=C.ship??{},F=C.flatpak??{},I=resolveShipApp({project:C.app,perTarget:N.app,layoutOs:S.os}),H=I.app;I.overridden&&ge.log(`${xG} runtime for ${S.name}: ${H} — \`${I.key}\` overrides \`gjsify.app${C.app===void 0?``:`: "${C.app}"`}\`.`);let W=readPackageJson$2(zn(n,`package.json`))??{},q,Y=[];if(t.target!==void 0)q=resolveFormats(t.target,S);else if(N.targets!==void 0){let t=configuredFormats(N.targets,S);q=t.formats,t.dropped.length>0&&ge.log(`${xG} \`gjsify.ship.targets\` names ${t.dropped.join(`, `)}, which wrap another layout — not built for ${S.name}. Pass --target to ask for one explicitly.`)}else{let t=defaultFormatIds(S.os).map(t=>kW[t]);q=t.filter(t=>t.interpreters.includes(H)),Y=t.filter(t=>!t.interpreters.includes(H)),Y.length>0&&ge.log(`${xG} ${Y.map(t=>t.id).join(`, `)} wrap the ${S.name} layout but cannot run \`${H}\`, which \`${I.key}\` resolves to — ${Y[0]?.interpreterGap??``}. Set \`gjsify.ship.app.${S.os}\` to "${Y[0]?.interpreters.join(`" / "`)}" to ship this OS on that runtime; it leaves every other target on \`gjsify.app\`. Assembling the layout only; pass --target to be told the same thing as an error.`)}q.some(t=>t.id===`flatpak`)&&assertNoDroppedFlatpakModules(F),t.stage||assertPackable(q,S,t.os===void 0?`host`:`positional`,Y);let X=resolveSignPlan({flag:t.sign,config:N.sign,layoutOs:S.os}),Z=resolveNotaryPlan({flag:t.notarize,layoutOs:S.os,sign:X});if(t.stage&&assertNothingToSignYet(t),t.stage||(announceSigning(X,Z),X.kind===`sign`&&assertHostCanSign(X.signer)),t.stage||assertKindCanPack(q,resolveShipKind(N,F)),!t.stage)for(let t of q)assertCanPack(t);let te=parseDeclaredChannel(t.channel,`--channel`)??parseDeclaredChannel(N.channel,`gjsify.ship.channel`)??(q.some(t=>t.id===`flatpak`)?`flathub`:void 0),ne=parseDeclaredPricing(t.pricing,`--pricing`)??parseDeclaredPricing(N.pricing,`gjsify.ship.pricing`)??`free`;t[`skip-build`]||await runProjectBuild(n,te,ne);let re=resolveShipBundle({pkg:W,ship:N,layoutOs:S.os});re.overridden&&ge.log(`${xG} entry for ${S.name}: ${re.declared} — \`${re.key}\` overrides \`gjsify.main\`.`);let ie=discoverPayload({projectDir:n,pkg:W,ship:N,flatpakIcon:F.icon,declaredBundle:re.declared,layoutOs:S.os,foreignBundles:re.foreign}),{settings:ae,metadata:oe,warnings:Q}=resolveShipSettings({projectDir:n,pkg:W,ship:N,flatpak:F,cli:{outDir:t.out,arch:t.arch,layoutOs:S.os},discovered:ie,app:H});for(let t of Q)ge.warn(`${xG} ${t}`);for(let t of q)assertFormatCanRunInterpreter(t,ae.app);let se=readFileSync(ae.bundlePath,`utf-8`);assertEntryRunsUnder({interpreter:ae.app,source:se,entry:Bn(n,ae.bundlePath)||ae.bundlePath,appKey:I.key,bundleKey:re.key,layoutOs:S.os});let ce=buildTimestamp(ae.bundlePath),le={appId:ae.appId,name:ae.name,command:ae.binaryName,kind:ae.kind,metadata:oe,desktopExecArgs:ae.desktopExecArgs,channel:te,configKey:`gjsify.ship`,copyrightYear:new Date(ce*1e3).getUTCFullYear()};for(let t of validateAppMetadata(le))ge.warn(`${xG} ${t.field} is not set — ${t.hint}`);ae.licenseFile!==void 0&&Hn(ae.licenseFile)!==n&&ge.log(`${xG} licence text from ${Bn(n,ae.licenseFile)} (this package carries none of its own)`);let ue=localizeMetadata({metainfo:ae.kind===`app`?renderMetainfoApp$1(le):renderMetainfoCli$1(le),desktopEntry:ae.kind===`app`?renderDesktopEntry(le):void 0},ae.localeFiles),de=await resolveCarriedRuntime(S,ae,n),fe=carryNodeModules(de,S,ae,n,N.nodeModules,N.nodeModulesExclude);fe.length>0&&(ae.nodeModulesDirs=fe);let pe=stageSubordinates({layout:S,identity:ae,nestedBundles:ae.nestedBundles,helperExecutables:ae.helperExecutables,mainExecutable:ae.mainExecutableSource}),me={bundleFiles:ie.bundleFiles,launcher:renderLauncher(ae,Un(ae.bundlePath),S,de.launcher),executableLaunchers:Object.fromEntries(ae.executables.map(t=>[t.name,renderLauncher(ae,t.entry,S,de.launcher)])),metainfo:ue.metainfo,desktopEntry:ue.desktopEntry,licenseText:ae.licenseFile===void 0?void 0:readFileSync(ae.licenseFile,`utf-8`),changelogText:ae.changelogFile===void 0?void 0:readFileSync(ae.changelogFile,`utf-8`),mtime:ce},he=In(n,ae.outDir),_e=zn(he,`stage`),ve=[...planStage(ae,me),...S.os===`linux`?[]:await compileSchemasForStage({schemaFiles:ae.schemaFiles,workDir:zn(he,`schemas`)})],ye=ae.kind===`app`&&S.icon!==void 0&&(S.icon.required||ae.iconFiles.length>0)?await resolveAppIcon({iconFiles:ae.iconFiles,appId:ae.appId,sizes:S.icon.sizes,target:S.icon.writes}):void 0;ye!==void 0&&ge.log(`${xG} icon: ${iconSizes(ye).join(`/`)} px, ${ye.source}`);let be=placeStage(S,{...ae,icon:ye,categories:oe.categories},ve,[...de.files,...pe.files]);if(writeStage(_e,be),ge.log(`${xG} staged ${be.length} file(s) for ${S.name} in ${Bn(n,_e)}/`),t.verbose)for(let t of be)ge.log(`${xG} ${t.path}`);if(assertPayloadMatchesArch(readStage([_e],be),ae.arch,{exempt:payloadArchExemptions(S.os,ae)}),S.os!==`linux`){let t=linuxInstallDependent(ve);if(t.length>0){ge.warn(`${xG} the ${S.name} layout carries ${t.length} file(s) whose Linux correctness comes from a package install step it has no equivalent for:`);let n={aborts:`ABORTS: `,unknown:`UNCLASSIFIED: `,inert:``};for(let{path:S,verdict:C,why:N}of t)ge.warn(`${xG} ${n[C]??``}${S} — ${N}`)}for(let t of de.found)ge.log(`${xG} carries its own ${t}`);for(let t of de.missing)ge.warn(`${xG} ${t}`);de.launcher.interpreter===void 0&&S.runtimeGap!==void 0&&ge.warn(`${xG} ${S.runtimeGap}`),S.fontGap!==void 0&&ve.some(t=>isUnder(t.path,mH.fonts))&&ge.warn(`${xG} ${S.fontGap}`),S.arches!==null&&!S.arches.only.includes(ae.arch)&&ge.warn(`${xG} this stage is labelled ${ae.arch} and the ${S.name} layout has no runtime for it — ${S.arches.why}. Nothing can pack this stage; \`--arch ${S.arches.only.join(`|`)}\` is what produces an artifact.`)}let xe=scanGiRequirements(se),Se=xe.namespaces,Ce=xe.optional;if(t.verbose){let t=Se.filter(t=>!Ce.includes(t));ge.log(`${xG} gi namespaces: ${Se.join(`, `)||`(none)`}`),Ce.length>0&&(ge.log(`${xG} gi optional namespaces: ${Ce.join(`, `)}`),ge.log(`${xG} gi required namespaces: ${t.join(`, `)||`(none)`}`))}let we=new Map;for(let t of q)we.set(t.id,(await planOverlay(ae,t,me)).map(t=>({...t,path:place(S,ae,t.path)})));let Te=readPayloadFacts(ve);for(let t of q){if(t.depends===null)continue;let n=deriveDepends(t.depends,{namespaces:Se,optionalNamespaces:Ce,hasIcons:Te.hasIcons,hasSchemas:Te.hasSchemas,interpreter:ae.app,extra:ae.extraDepends[t.depends],typelibPackages:ae.typelibPackages,bundledTypelibs:Te.bundledTypelibs,minGjsVersion:ae.minGjsVersion,minNodeVersion:ae.minNodeVersion});for(let S of n.unmappedOptional)ge.warn(`${xG} gi://${S} is imported optionally, but no ${t.depends} package is known to ship its typelib, so no Recommends entry names it. The package builds and runs without it. Add the row if the namespace should be recommended: \`gjsify.ship.typelibPackages.${S} = { "${t.depends}": "…" }\`.`);let S=ae.app===`node`?warnAboutNodeFloor(t.depends,ae.minNodeVersion):warnAboutGjsFloor(t.depends,ae.minGjsVersion);for(let t of S)ge.warn(`${xG} ${t}`)}let Ee=writeStageManifest({stageDir:_e,settings:ae,formats:q,mtime:ce,namespaces:Se,optionalNamespaces:Ce,staged:be,overlay:we});if(t.stage){let t=Y.length>0?`(none — ${Y.map(t=>t.id).join(` and `)} need \`gjsify.ship.app.${S.os}: "node"\`)`:formatIdsFor(S.os).length===0?`(none — no format wraps the ${S.name} layout)`:`(none asked for)`,n=Ee.formats.join(`, `)||t;ge.log(`${xG} stage manifest: ${formatTarget(Ee.target)}, formats ${n}`);return}let De=[];for(let n of q)De.push(await packOne({format:n,settings:ae,arch:ae.arch,staged:be,overlay:we.get(n.id)??[],stageDir:_e,outRoot:he,namespaces:Se,optionalNamespaces:Ce,mtime:ce,sign:X,notarize:Z,verbose:t.verbose}));printArtifacts(n,De)}function assertNothingToSignYet(t){let n=t.sign===void 0?t.notarize===void 0?void 0:`--notarize`:`--sign`;if(n!==void 0)throw Error(`gjsify ship: ${n} belongs to the finish phase, and --stage produces no artifact to sign — it writes the tree a packing host reads back. Assemble here, then run \`gjsify ship --from-stage <dir> --sign <identity>\` on the host that holds the identity (ADR 0024 § A2, § A14).`)}function announceSigning(t,n){t.kind===`skip`&&ge.warn(`${xG} ${t.message}`),n.kind===`skip`&&t.kind===`sign`&&ge.warn(`${xG} ${n.message}`)}async function resolveCarriedRuntime(t,n,S){let C={files:[],launcher:{},found:[],missing:[]};if(t.os===`linux`||n.app!==`node`)return C;let N=`${t.os}-${n.arch}`;if(!isGtkRuntimeTarget(N))return C;let F=await acquireGtkRuntime({target:N,version:cliVersion(),discovery:{cwd:S},ensure:async S=>(await ensurePkgDir(parseSpec(S),{verbose:!1,cacheMaxAge:CG,frozen:!1,platform:{os:t.os,cpu:n.arch}})).pkgDir,log:t=>ge.log(`${xG} ${t}`)});return stageAppRuntime({layout:t,identity:n,target:N,cwd:S,interpreter:isNodeRuntimeTarget(N)?resolveNodeRuntime(N,{cwd:S}):null,...F.kind===`fetched`?{fetchedGtkRuntimeDir:F.dir}:{},...F.kind===`failed`?{gtkFetchFailure:F.reason}:{}})}function carryNodeModules(t,n,S,C,N,F){if(N===void 0||N.length===0)return[];let I=resolveNodeModulesClosure(N,C,{target:{os:n.os,cpu:S.arch},exclude:F}),H=n.dirs(S).bundle;return t.files.push(...stageNodeModules(I,H)),t.found.push(`node_modules: ${I.packages.length} package(s) for ${N.join(`, `)}`),I.skippedPrebuilds!==void 0&&I.skippedPrebuilds.length>0&&ge.log(`${xG} node_modules: left out, prebuilds for another platform than ${n.os}-${S.arch}: `+I.skippedPrebuilds.join(`, `)),I.excluded.length>0&&ge.log(`${xG} node_modules: left out by gjsify.ship.nodeModulesExclude: ${I.excluded.join(`, `)}`),I.skippedForTarget.length>0&&ge.log(`${xG} node_modules: left out, installed but built for another platform than ${n.os}-${S.arch}: `+I.skippedForTarget.join(`, `)),I.skippedOptional.length>0&&ge.log(`${xG} node_modules: ${I.skippedOptional.length} optional dependenc(ies) not installed, so not carried (other platforms' builds): ${I.skippedOptional.join(`, `)}`),I.packages.map(t=>On.join(H,`node_modules`,t.dest))}async function finishFromStage(t,n){if(t.stage)throw Error("gjsify ship: --stage and --from-stage are the two halves of one split and cannot run together. `--stage` assembles a payload and stops; `--from-stage <dir>` packs one that is already assembled. Run them as two commands, on the host each belongs on (ADR 0024 § A2).");if(t[`skip-build`])throw Error(`gjsify ship: --from-stage never runs a build — the payload it packs was built and staged by an earlier run — so --skip-build has nothing to skip. Drop it.`);if(t.arch!==void 0)throw Error("gjsify ship: --arch is decided when the stage is assembled, not when it is packed: the launcher, the payload and the recorded target were all fixed then. Pass --arch to `gjsify ship --stage`, and use `--expect-target <os>-<arch>` here to assert which leg you are packing.");if(t.os!==void 0)throw Error(`gjsify ship: the layout is decided when the stage is assembled, so "${t.os}" has nothing to change here — the staged tree already IS one OS's layout. Use \`--expect-target <os>-<arch>\` to assert which one you are packing.`);let S=process.cwd(),C=In(S,n),N=readStageManifest(C);assertExpectedTarget(N,t[`expect-target`]);let F=layoutForOs(N.target.os);t.target===void 0&&assertPackable(N.formats.map(t=>kW[t]),F,`stage`,defaultFormatIds(F.os).map(t=>kW[t]).filter(t=>!t.interpreters.includes(N.settings.app)));let I=resolveFormats(t.target??N.formats,F);assertFormatsStaged(N,I);for(let t of I)assertCanPack(t);let H=resolveSignPlan({flag:t.sign,layoutOs:F.os}),W=resolveNotaryPlan({flag:t.notarize,layoutOs:F.os,sign:H});announceSigning(H,W),H.kind===`sign`&&assertHostCanSign(H.signer);for(let t of warnOnToolSkew(N))ge.warn(`${xG} ${t}`);let{mtime:q,warnings:Y}=resolveStageMtime(N);for(let t of Y)ge.warn(`${xG} ${t}`);if(ge.log(`${xG} packing ${N.settings.binaryName} ${N.settings.version}-${N.settings.release} for ${formatTarget(N.target)} from ${Bn(S,C)||`.`}/`),t.verbose){for(let t of N.staged)ge.log(`${xG} ${t.path}`);ge.log(`${xG} gi namespaces: ${N.namespaces.join(`, `)||`(none)`}`),(N.optionalNamespaces??[]).length>0&&ge.log(`${xG} gi optional namespaces: ${N.optionalNamespaces?.join(`, `)}`)}let X=t.out===void 0?Hn(C):In(S,t.out),Z=[];for(let n of I){if(assertFormatCanRunInterpreter(n,N.settings.app),n.depends!==null){let t=N.settings.app===`node`?warnAboutNodeFloor(n.depends,N.settings.minNodeVersion):warnAboutGjsFloor(n.depends,N.settings.minGjsVersion);for(let n of t)ge.warn(`${xG} ${n}`)}Z.push(await packOne({format:n,settings:N.settings,arch:N.target.arch,staged:N.staged,overlay:overlayFiles(N,n.id),stageDir:C,outRoot:X,namespaces:N.namespaces,optionalNamespaces:N.optionalNamespaces??[],mtime:q,sign:H,notarize:W,verbose:t.verbose}))}printArtifacts(S,Z)}async function packOne(t){let{format:n,settings:S,stageDir:C,outRoot:N,mtime:F}=t;assertOverlayIsLicensed(n.id,S.binaryName,t.overlay);let I=zn(N,`overlay`,n.id);writeStage(I,t.overlay);let H=readStage([C,I],[...t.staged,...t.overlay]),W=readPayloadFacts(H),q=n.depends===null?{requires:[],recommends:[],unmappedOptional:[]}:deriveDepends(n.depends,{namespaces:t.namespaces,optionalNamespaces:t.optionalNamespaces,hasIcons:W.hasIcons,hasSchemas:W.hasSchemas,interpreter:S.app,extra:S.extraDepends[n.depends],typelibPackages:S.typelibPackages,bundledTypelibs:W.bundledTypelibs,minGjsVersion:S.minGjsVersion,minNodeVersion:S.minNodeVersion}),Y=q.requires,X=q.recommends;assertPayloadMatchesArch(H,t.arch,{exempt:payloadArchExemptions(n.layoutOs,S)});let Z=layoutForOs(n.layoutOs);assertLauncherMatchesInterpreter(H,Z,S,S.app),assertLayoutSupportsArch(Z,t.arch);let te=signedSubordinatesFor(Z,S,S),ne=t.sign.kind===`sign`?await signPayload({payload:H,identity:t.sign.identity,signer:t.sign.signer,workDir:zn(N,`signed`,n.id),bundleRoot:Z.root(S),entitlementsPath:zn(N,`signed`,`${n.id}.entitlements.plist`),nestedBundles:te.nestedBundles,helperExecutables:te.helperExecutables,verbose:t.verbose,log:t=>ge.log(`${xG} ${t}`)}):H,re=n.archName(t.arch,isArchIndependent(ne)),ie={settings:S,payload:ne,prefix:n.prefix,depends:Y,recommends:X,archLabel:re,mtime:F},ae=zn(N,`out`);mkdirSync(ae,{recursive:!0});let oe=zn(ae,n.fileName(S,re));switch(n.id){case`deb`:writeFileSync(oe,await buildDeb(ie));break;case`rpm`:writeFileSync(oe,await buildRpm(ie));break;case`flatpak`:await buildFlatpakBundle({settings:S,stageDir:C,overlayDir:I,stageManifestFile:ZW,workDir:zn(N,`flatpak`),target:oe,archLabel:re,verbose:t.verbose});break;case`appimage`:{let n=appImageHostRequirements({app:S.app,minGjsVersion:S.minGjsVersion,minNodeVersion:S.minNodeVersion,namespaces:t.namespaces,optionalNamespaces:t.optionalNamespaces,bundledTypelibs:W.bundledTypelibs}),C=appDirFor(N),I=appDirPayload(S,ne,n,await compileSchemasForPayload({payload:ne,workDir:zn(N,`appimage-schemas`)}));writePayload(C,I,``),stampAppDirTimes(C,I,F),ge.log(`${xG} the AppImage takes these from the host: ${n.join(`, `)}`);let H=findPinnedRuntime(re);ge.log(`${xG} ${appImageRuntimeNotice(re,H)}`),await buildAppImage({appDir:C,target:oe,archLabel:re,runtimeFile:H,workDir:Hn(C),verbose:t.verbose});break}case`linux-tar`:case`linux-tar-flatpak`:{let t=n.id===`linux-tar-flatpak`?await compileSchemasForPayload({payload:ne,workDir:zn(N,`tar-schemas`)}):void 0;writeFileSync(oe,await buildLinuxTarball({settings:S,payload:t===void 0?ne:[...ne,t],archLabel:re,mtime:F}));break}case`macos-app`:case`windows-dir`:writePayload(oe,ne,Z.root(S));break;case`macos-app-dmg`:{let n=dmgVolumeDir(N);if(writePayload(n,ne,``),t.notarize.kind===`notarize`){let C=t.notarize,N=zn(n,`${S.name}.app`),I=zn(Hn(n),`bundle-notarize.zip`);await stapleBundleBeforeImage({writeArchive:()=>writeFileSync(I,buildZip(zipEntriesFromPayload(ne),F)),notarize:()=>notarizeArtifact({plan:C,artifact:I,verbose:t.verbose,log:t=>ge.log(`${xG} ${t}`)}),staple:()=>stapleArtifact({notary:C.notary,artifact:N,verbose:t.verbose,log:t=>ge.log(`${xG} ${t}`)})})}addApplicationsLink(n),await buildDmgImage({volumeName:dmgVolumeName(S),sourceDir:n,target:oe,workDir:Hn(n),verbose:t.verbose}),t.sign.kind===`sign`&&await signDmgImage({identity:t.sign.identity,file:oe,adhoc:t.sign.identity===`-`,workDir:Hn(n),verbose:t.verbose});break}case`macos-app-zip`:writeFileSync(oe,buildZip(zipEntriesFromPayload(ne),F));break;case`windows-dir-zip`:writeFileSync(oe,buildZip(zipEntriesFromPayload(ne,windowsProgramDirName(S)),F));break;case`msi`:{let n=zn(N,`msi`);writePayload(zn(n,FW),ne,Z.root(S)),await buildMsi({settings:S,files:ne.map(t=>({path:t.path,source:`${FW}/${t.path}`})),programDirName:windowsProgramDirName(S),archLabel:re,workDir:n,target:oe,verbose:t.verbose});break}default:{let t=n.id;throw Error(`gjsify ship: no packer is wired for format "${String(t)}".`)}}let Q=n.artifactKind===`directory`?directorySize(oe):statSync(oe).size,se=!1,ce=!1;if(t.notarize.kind===`notarize`&&(n.artifactKind===`directory`?ge.warn(`${xG} ${n.id} is a directory, and notarytool submits an archive or an installer — not notarised. The container format beside it is what carries the ticket.`):(await notarizeArtifact({plan:t.notarize,artifact:oe,verbose:t.verbose,log:t=>ge.log(`${xG} ${t}`)}),se=!0,canCarryTicket(n.id)?(await stapleArtifact({notary:t.notarize.notary,artifact:oe,verbose:t.verbose,log:t=>ge.log(`${xG} ${t}`)}),ce=!0):ge.warn(`${xG} ${n.id} is notarised and NOT stapled: \`stapler\` takes a UDIF image, a signed flat package or a code-signed bundle, and an archive is none of them. Apple's remedy is to staple each item that went INTO the archive and re-create it — for this artifact that is the \`.app\`, which \`--target macos-app\` writes beside it.`))),n.artifactKind===`file`){let S=writeReleaseRecord({file:oe,format:n.id,os:n.layoutOs,arch:isArchIndependent(ne)?`noarch`:t.arch,signature:recordedSignature(t.sign.kind===`sign`?t.sign.identity:void 0,`-`),notarized:se,stapled:ce,nestedBundles:recordedNestedBundles(ne,te.nestedBundles),generator:`@gjsify/cli ${cliVersion()}`});t.verbose&&ge.log(`${xG} release record: ${S}`)}return{format:n.id,path:oe,size:Q}}function printArtifacts(t,n){for(let S of n)ge.log(`${xG} ${S.format}: ${Bn(t,S.path)} (${S.size} bytes)`)}function assertCanPack(t){assertHostCanFinish(t),assertToolsInstalled(t)}function assertPackable(t,n,S,C=[]){if(t.length>0)return;if(C.length>0)throw Error(`gjsify ship: ${C.map(t=>t.id).join(` and `)} wrap the ${n.name} layout, and neither can run this project — ${C[0]?.interpreterGap??``}.\n Set \`gjsify.ship.app.${n.os}\` to "${C[0]?.interpreters.join(`" / "`)}" — it overrides \`gjsify.app\` for THIS target and\n leaves every other one alone, which is what lets one project be GJS on Linux and Node here.
1192
1192
  \`gjsify ship ${n.name} --stage\` assembles the tree either way.`);let N=formatIdsFor(n.os).sort();if(N.length>0){let t=S===`stage`?`${n.name} --stage --target`:`${n.name} --target`;throw Error(`gjsify ship: this run records no formats for the ${n.name} layout, so there is nothing to pack — and it is not that none exist: ${N.join(`, `)} wrap it.\n An empty list means none were SELECTED. \`gjsify.ship.targets\` is filtered to the layout being assembled,
1193
1193
  so a configured list naming only another OS's formats leaves this one empty and says so at stage time.
1194
1194
  Name one where the payload is assembled: \`gjsify ship ${t} ${N[0]}\`.`)}let F=defaultFormatIds(`linux`).join(`,`),I={host:`This host is ${process.platform}, so \`gjsify ship\` assembled the ${n.name} layout. Assembly is not host-bound (ADR 0024 § A1), so the Linux packages are still one word away: \`gjsify ship linux\` builds ${F} from right here.`,positional:`\`gjsify ship ${n.name} --stage\` assembles the payload and stops, which is the whole of what this command does for that OS today.`,stage:`This stage carries the ${n.name} layout and nothing here can wrap it — a stage is a build intermediate, not an artifact. Keep it for the milestone that packs it, or re-assemble with \`gjsify ship linux --stage\` if a Linux package is what you wanted.`}[S];throw Error(`gjsify ship: no format wraps the ${n.name} layout, so there is nothing to pack. ${I} Every layout this gjsify knows has one (ADR 0024 stages 2-5), so this is a layout added without a \`FORMATS\` row.`)}function assertFormatCanRunInterpreter(t,n){if(!t.interpreters.includes(n))throw Error(`gjsify ship: this ${t.layoutOs} target runs \`${n}\`, and the ${t.id} runtime cannot run it — it provides ${t.interpreters.join(`, `)}.\n ${t.interpreterGap}.\n Build the formats that wrap this layout and can run it, or set \`gjsify.ship.app.${t.layoutOs}: "${t.interpreters.join(`" / "`)}"\` (which overrides \`gjsify.app\` for this target alone).`)}async function runProjectBuild(t,n,S){if(typeof readPackageJson$2(zn(t,`package.json`))?.scripts?.build!=`string`)throw Error("gjsify ship: this project has no `build` script to run. Add one, or pass --skip-build to package what is already built.");ge.log(`${xG} running the project's build script`);let C=S===void 0&&n===void 0?void 0:{...process.env};C!==void 0&&(n!==void 0&&(C[Oh]=n),S!==void 0&&(C[jh]=S));let N=await spawnToCompletion(`gjsify`,[`run`,`build`],{completion:`return`,cwd:t,stdio:`inherit`,env:C,notFound:()=>Error("gjsify ship: `gjsify` is not on PATH, so the project build cannot be run. Build the project yourself and pass --skip-build.")});if(N.code!==0)throw Error(`gjsify ship: the project's build script failed with ${describeExit(N)}.`)}var xG,SG,CG,wG=__esmMin(()=>{_e(),kh(),Mh(),af(),Xn(),mR(),CB(),pV(),HI(),_B(),Ch(),hv(),yU(),fH(),XU(),ZU(),$U(),eW(),IU(),lW(),mW(),uV(),hW(),xH(),gW(),MW(),rU(),RU(),hH(),cU(),IW(),LW(),GW(),qW(),lP(),vU(),UU(),YW(),nG(),rG(),bG(),jU(),QW(),$W(),xG=`[gjsify ship]`,SG={command:`ship [os]`,description:`Build installable artifacts (${AW.join(`, `)}) from the current project.`,builder:t=>t.positional(`os`,{type:`string`,description:`Operating system whose LAYOUT to assemble (${tU.join(`|`)}, ADR 0024 § A2). Default: this host. Assembly is not host-bound, so any of them can be staged anywhere.`}).option(`target`,{type:`string`,array:!0,description:`Formats to build, comma-separated or repeated. Default: every format wrapping the target OS's layout that needs no extra tooling — on linux, ${defaultFormatIds(`linux`).join(`,`)}. Also available for linux, and opt-in because it needs tooling this CLI does not carry: ${formatIdsFor(`linux`).filter(t=>!defaultFormatIds(`linux`).includes(t)).join(`, `)}.`}).option(`out`,{type:`string`,normalize:!0,description:"Output root, relative to the project. Default: `gjsify.ship.outDir`, else `ship`."}).option(`stage`,{type:`boolean`,default:!1,description:`Produce the staged payload and stop, without packing anything.`}).option(`from-stage`,{type:`string`,normalize:!0,description:"Pack a staged payload written by an earlier `--stage` run. Needs no project: the stage carries its own closure."}).option(`expect-target`,{type:`string`,description:"With --from-stage: refuse unless the stage was assembled for this `<os>-<arch>`, e.g. `linux-arm64`."}).option(`channel`,{type:`string`,choices:[...Eh],description:"Distribution channel (ADR 0113). Overrides gjsify.ship.channel; `--target flatpak` implies flathub. Passed to the project build, and gates the metainfo donation URL."}).option(`pricing`,{type:`string`,choices:[...Ah],description:`Pricing tier (ADR 0139): 'free' or 'paid'. Overrides gjsify.ship.pricing; passed to the project build. Default 'free'.`}).option(`skip-build`,{type:`boolean`,default:!1,description:"Package what is already built instead of running the project's `build` script."}).option(`arch`,{type:`string`,description:"Target architecture in `process.arch` spelling. Default: this host."}).option(`sign`,{type:`string`,requiresArg:!0,description:"Sign the payload with this identity, e.g. a Developer ID name or SHA-1 fingerprint. `-` signs ad-hoc and needs no developer identity. Default: `gjsify.ship.sign.<darwin|win32>.identity`; absent means unsigned, which is a legitimate output."}).option(`notarize`,{type:`string`,requiresArg:!0,description:"Submit the signed artifact to Apple with this `notarytool` keychain profile. Needs --sign; darwin only."}).option(`verbose`,{type:`boolean`,default:!1,description:`Print each staged file, the GI namespaces the bundle imports, and every tool a host-bound packer invokes.`}),handler:async t=>{if(t[`from-stage`]!==void 0)return await finishFromStage(t,t[`from-stage`]);await assemble(t)}},CG=1440*7});function parseGithubRepo(t){let n=t.trim().replace(/^git\+/,``),S=/^([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)$/.exec(n),C=/^(?:https?|ssh|git):\/\/(?:[^@/]+@)?github\.com[/:]([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?\/?$/.exec(n)??S;return C===null?void 0:`${C[1]}/${C[2].replace(/\.git$/,``)}`}function releaseDateOf(t){return new Date(t*1e3).toISOString().slice(0,10)}function readFlatparkSources(t){let n=[];if(existsSync(t.dir))for(let S of readdirSync(t.dir).sort()){if(!S.endsWith(`.gjsify-release.json`))continue;let C=JSON.parse(readFileSync(zn(t.dir,S),`utf-8`));C.format===`linux-tar-flatpak`&&C.os===`linux`&&n.push(C)}if(n.length===0)throw Error(`gjsify flatpark: no release record for \`${EG}\` in ${t.dir}. The URL, sha256 and size come from \`<artifact>${JW}\`, which \`gjsify ship --target ${EG}\` writes beside the archive. Run that first, or point --release-dir at the directory that holds the record.`);let S=`${t.tagPrefix}${t.version}`,C=n.map(n=>{let C=DG[n.arch===`noarch`?t.stageArch??n.arch:n.arch];if(C===void 0)throw Error(`gjsify flatpark: ${n.artifact} is built for \`${n.arch}\`, which has no Flatpak arch (known: ${Object.keys(DG).join(`, `)}).`);return{arch:C,artifact:n.artifact,url:`https://github.com/${t.repo}/releases/download/${S}/${n.artifact}`,sha256:n.sha256,size:n.size}}),N=new Set;for(let n of C){if(N.has(n.arch))throw Error(`gjsify flatpark: two release records for ${n.arch} in ${t.dir}; keep one.`);N.add(n.arch)}return C.sort((t,n)=>t.arch.localeCompare(n.arch))}function renderApplyExtra(t){return`#!/bin/sh
@@ -25,7 +25,7 @@
25
25
  import { CHANNELS, CHANNEL_ENV, parseDeclaredChannel } from '../utils/channel.js';
26
26
  import { PRICINGS, PRICING_ENV, parseDeclaredPricing } from '../utils/pricing.js';
27
27
  import { mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
28
- import { basename, dirname, join, relative, resolve } from 'node:path';
28
+ import { basename, dirname, join, posix, relative, resolve } from 'node:path';
29
29
  import { Config } from '../config.js';
30
30
  import { ensurePkgDir } from './dlx.js';
31
31
  import { renderDesktopEntry, renderMetainfoApp, renderMetainfoCli, validateAppMetadata, } from '../utils/app-metadata.js';
@@ -431,7 +431,9 @@ async function assemble(args) {
431
431
  // carrying a second copy inside the payload would be a private interpreter no
432
432
  // distribution update ever patches.
433
433
  const runtime = await resolveCarriedRuntime(layout, settings, projectDir);
434
- carryNodeModules(runtime, layout, settings, projectDir, ship.nodeModules, ship.nodeModulesExclude);
434
+ const nodeModulesDirs = carryNodeModules(runtime, layout, settings, projectDir, ship.nodeModules, ship.nodeModulesExclude);
435
+ if (nodeModulesDirs.length > 0)
436
+ settings.nodeModulesDirs = nodeModulesDirs;
435
437
  // The nested bundles and helper executables ADR 0026 § 6 needed by hand —
436
438
  // staged like the runtime above (tree-preserving, stage-relative, through
437
439
  // `placeStage`'s `carried` seam), and never through `gjsify.ship.bundledTypelibs`'s
@@ -858,12 +860,13 @@ async function resolveCarriedRuntime(layout, settings, projectDir) {
858
860
  */
859
861
  function carryNodeModules(runtime, layout, settings, projectDir, declared, exclude) {
860
862
  if (declared === undefined || declared.length === 0)
861
- return;
863
+ return [];
862
864
  const closure = resolveNodeModulesClosure(declared, projectDir, {
863
865
  target: { os: layout.os, cpu: settings.arch },
864
866
  exclude,
865
867
  });
866
- runtime.files.push(...stageNodeModules(closure, layout.dirs(settings).bundle));
868
+ const bundleDir = layout.dirs(settings).bundle;
869
+ runtime.files.push(...stageNodeModules(closure, bundleDir));
867
870
  runtime.found.push(`node_modules: ${closure.packages.length} package(s) for ${declared.join(', ')}`);
868
871
  if (closure.skippedPrebuilds !== undefined && closure.skippedPrebuilds.length > 0) {
869
872
  console.log(`${LOG} node_modules: left out, prebuilds for another platform than ${layout.os}-${settings.arch}: ` +
@@ -880,6 +883,7 @@ function carryNodeModules(runtime, layout, settings, projectDir, declared, exclu
880
883
  console.log(`${LOG} node_modules: ${closure.skippedOptional.length} optional dependenc(ies) not installed, ` +
881
884
  `so not carried (other platforms' builds): ${closure.skippedOptional.join(', ')}`);
882
885
  }
886
+ return closure.packages.map((pkg) => posix.join(bundleDir, 'node_modules', pkg.dest));
883
887
  }
884
888
  /** How long a fetched runtime stays in the dlx cache — the same week `gjsify showcase` uses. */
885
889
  const DLX_CACHE_MAX_AGE_MIN = 60 * 24 * 7;
@@ -139,6 +139,9 @@ export function toPackSettings(settings) {
139
139
  app: settings.app,
140
140
  minGjsVersion: settings.minGjsVersion,
141
141
  minNodeVersion: settings.minNodeVersion,
142
+ ...(settings.nodeModulesDirs === undefined || settings.nodeModulesDirs.length === 0
143
+ ? {}
144
+ : { nodeModulesDirs: settings.nodeModulesDirs }),
142
145
  flatpak: settings.flatpak,
143
146
  executables: settings.executables.map(({ name, gui }) => ({ name, gui })),
144
147
  nestedBundles: settings.nestedBundles.map(({ name, entitlements }) => ({ name, entitlements })),
@@ -504,6 +507,12 @@ function readPackSettings(data, at) {
504
507
  minGjsVersion: expectString(data.minGjsVersion, field('minGjsVersion')),
505
508
  minNodeVersion: expectString(data.minNodeVersion, field('minNodeVersion')),
506
509
  flatpak: readFlatpakSettings(record(data.flatpak, field('flatpak')), field('flatpak')),
510
+ // OPTIONAL on read: a stage written before the tarball learned the declared closure has none.
511
+ ...(data.nodeModulesDirs === undefined
512
+ ? {}
513
+ : {
514
+ nodeModulesDirs: expectArray(data.nodeModulesDirs, field('nodeModulesDirs')).map((entry, index) => expectString(entry, field(`nodeModulesDirs[${index}]`))),
515
+ }),
507
516
  // OPTIONAL on read and NOT a schema bump: a stage written before
508
517
  // `gjsify.ship.executables` is a one-executable stage, `[]` is exactly
509
518
  // right for it, and an older reader meeting a newer stage refuses the
@@ -8,8 +8,10 @@ export declare function tarballTopDir(settings: PackSettings, archLabel: string)
8
8
  * The payload is the staged closure, so these are guards against a stage that
9
9
  * grew something nobody meant to publish — a `.env`, a `.git`, a log — rather
10
10
  * than checks a normal build trips. `node_modules` is legitimate exactly when
11
- * the app runs on Node and the stage copied its closure; for `--app gjs` there
12
- * is no reason for one to exist.
11
+ * the app runs on Node and the stage copied its closure, or the path belongs to
12
+ * the declared `gjsify.ship.nodeModules` closure ({@link PackSettings.nodeModulesDirs}),
13
+ * which a GJS app ships for its Node-API addons. Anything else under `node_modules`
14
+ * in a non-Node payload is a stray.
13
15
  */
14
16
  export declare function assertTarballHygiene(payload: readonly PayloadEntry[], settings: PackSettings): void;
15
17
  /**
@@ -10,14 +10,31 @@ import { gzipDeterministic } from './gzip.js';
10
10
  export function tarballTopDir(settings, archLabel) {
11
11
  return `${settings.binaryName}-${settings.version}-linux-${archLabel}`;
12
12
  }
13
+ /**
14
+ * Whether `path` lies inside one declared package directory. The `/` after the directory keeps
15
+ * `@mtcute/wasm-evil` out of `@mtcute/wasm`; a further `node_modules` below it must itself be a
16
+ * declared directory, so a stray nested tree is not waved through by its parent.
17
+ */
18
+ function inDeclaredClosure(path, dirs) {
19
+ return dirs.some((dir) => {
20
+ if (!path.startsWith(`${dir}/`))
21
+ return false;
22
+ return !path
23
+ .slice(dir.length + 1)
24
+ .split('/')
25
+ .includes('node_modules');
26
+ });
27
+ }
13
28
  /**
14
29
  * Refuse a payload that carries what a release archive must never hold.
15
30
  *
16
31
  * The payload is the staged closure, so these are guards against a stage that
17
32
  * grew something nobody meant to publish — a `.env`, a `.git`, a log — rather
18
33
  * than checks a normal build trips. `node_modules` is legitimate exactly when
19
- * the app runs on Node and the stage copied its closure; for `--app gjs` there
20
- * is no reason for one to exist.
34
+ * the app runs on Node and the stage copied its closure, or the path belongs to
35
+ * the declared `gjsify.ship.nodeModules` closure ({@link PackSettings.nodeModulesDirs}),
36
+ * which a GJS app ships for its Node-API addons. Anything else under `node_modules`
37
+ * in a non-Node payload is a stray.
21
38
  */
22
39
  export function assertTarballHygiene(payload, settings) {
23
40
  const problems = [];
@@ -30,7 +47,9 @@ export function assertTarballHygiene(payload, settings) {
30
47
  problems.push(`${entry.path} (version-control data)`);
31
48
  else if (base.endsWith('.log'))
32
49
  problems.push(`${entry.path} (log file)`);
33
- else if (segments.includes('node_modules') && settings.app !== 'node')
50
+ else if (segments.includes('node_modules') &&
51
+ settings.app !== 'node' &&
52
+ !inDeclaredClosure(entry.path, settings.nodeModulesDirs ?? []))
34
53
  problems.push(`${entry.path} (node_modules in a non-Node payload)`);
35
54
  }
36
55
  if (problems.length === 0)
@@ -424,6 +424,12 @@ export interface PackSettings {
424
424
  app: 'gjs' | 'node';
425
425
  /** Minimum GJS the emitted dependency asks for. Used only for `app: 'gjs'`. */
426
426
  minGjsVersion: string;
427
+ /**
428
+ * Stage-relative directories of the `gjsify.ship.nodeModules` closure the stage carries
429
+ * (`lib/<app>/node_modules/@scope/pkg`), recorded so a packer on another host can tell the
430
+ * declared `node_modules` from a stray one. Absent when nothing is declared.
431
+ */
432
+ nodeModulesDirs?: string[];
427
433
  /** Minimum Node major. Used only for `app: 'node'`. */
428
434
  minNodeVersion: string;
429
435
  /** The Flatpak manifest's non-payload half, fully defaulted at stage time. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/cli",
3
- "version": "0.64.50",
3
+ "version": "0.64.51",
4
4
  "description": "CLI for Gjsify",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -142,22 +142,22 @@
142
142
  "cli"
143
143
  ],
144
144
  "dependencies": {
145
- "@gjsify/blueprint": "0.64.50",
146
- "@gjsify/buffer": "0.64.50",
147
- "@gjsify/create-app": "0.64.50",
148
- "@gjsify/node-globals": "0.64.50",
149
- "@gjsify/node-polyfills": "0.64.50",
150
- "@gjsify/npm-registry": "0.64.50",
151
- "@gjsify/resolve-npm": "0.64.50",
152
- "@gjsify/rolldown-plugin-gjsify": "0.64.50",
153
- "@gjsify/vite-plugin-blueprint": "0.64.50",
154
- "@gjsify/rolldown-plugin-pnp": "0.64.50",
155
- "@gjsify/semver": "0.64.50",
156
- "@gjsify/tar": "0.64.50",
157
- "@gjsify/tsc": "0.64.50",
158
- "@gjsify/utils": "0.64.50",
159
- "@gjsify/web-polyfills": "0.64.50",
160
- "@gjsify/workspace": "0.64.50",
145
+ "@gjsify/blueprint": "0.64.51",
146
+ "@gjsify/buffer": "0.64.51",
147
+ "@gjsify/create-app": "0.64.51",
148
+ "@gjsify/node-globals": "0.64.51",
149
+ "@gjsify/node-polyfills": "0.64.51",
150
+ "@gjsify/npm-registry": "0.64.51",
151
+ "@gjsify/resolve-npm": "0.64.51",
152
+ "@gjsify/rolldown-plugin-gjsify": "0.64.51",
153
+ "@gjsify/vite-plugin-blueprint": "0.64.51",
154
+ "@gjsify/rolldown-plugin-pnp": "0.64.51",
155
+ "@gjsify/semver": "0.64.51",
156
+ "@gjsify/tar": "0.64.51",
157
+ "@gjsify/tsc": "0.64.51",
158
+ "@gjsify/utils": "0.64.51",
159
+ "@gjsify/web-polyfills": "0.64.51",
160
+ "@gjsify/workspace": "0.64.51",
161
161
  "acorn": "^8.17.0",
162
162
  "cosmiconfig": "^9.0.2",
163
163
  "get-tsconfig": "^4.14.0",
@@ -166,13 +166,13 @@
166
166
  "yargs": "^18.0.0"
167
167
  },
168
168
  "devDependencies": {
169
- "@gjsify/unit": "0.64.50",
169
+ "@gjsify/unit": "0.64.51",
170
170
  "@types/yargs": "^17.0.35",
171
171
  "typescript": "^6.0.3"
172
172
  },
173
173
  "peerDependencies": {
174
- "@gjsify/oxfmt-native": "0.64.50",
175
- "@gjsify/rolldown-native": "0.64.50"
174
+ "@gjsify/oxfmt-native": "0.64.51",
175
+ "@gjsify/rolldown-native": "0.64.51"
176
176
  },
177
177
  "peerDependenciesMeta": {
178
178
  "@gjsify/oxfmt-native": {