@gjsify/cli 0.51.0 → 0.51.1

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
@@ -119,7 +119,7 @@ fi
119
119
  `)}`:``;S.fail(F(`Missing required argument: %s`,`Missing required arguments: %s`,Object.keys(N).length,Object.keys(N).join(`, `)+C))}},I.unknownArguments=function unknownArguments(C,N,H,W,q=!0){let Y=n.getInternalMethods().getCommandInstance().getCommands(),X=[],Z=n.getInternalMethods().getContext();if(Object.keys(C).forEach(S=>{!bd.includes(S)&&!Object.prototype.hasOwnProperty.call(H,S)&&!Object.prototype.hasOwnProperty.call(n.getInternalMethods().getParseContext(),S)&&!I.isValidAndSomeAliasIsNotNew(S,N)&&X.push(S)}),q&&(Z.commands.length>0||Y.length>0||W)&&C._.slice(Z.commands.length).forEach(n=>{Y.includes(``+n)||X.push(``+n)}),q){let S=n.getDemandedCommands()._?.max||0,N=Z.commands.length+S;N<C._.length&&C._.slice(N).forEach(n=>{n=String(n),!Z.commands.includes(n)&&!X.includes(n)&&X.push(n)})}X.length&&S.fail(F(`Unknown argument: %s`,`Unknown arguments: %s`,X.length,X.map(n=>n.trim()?n:`"${n}"`).join(`, `)))},I.unknownCommands=function unknownCommands(C){let N=n.getInternalMethods().getCommandInstance().getCommands(),I=[],H=n.getInternalMethods().getContext();return(H.commands.length>0||N.length>0)&&C._.slice(H.commands.length).forEach(n=>{N.includes(``+n)||I.push(``+n)}),I.length>0?(S.fail(F(`Unknown command: %s`,`Unknown commands: %s`,I.length,I.join(`, `))),!0):!1},I.isValidAndSomeAliasIsNotNew=function isValidAndSomeAliasIsNotNew(S,C){if(!Object.prototype.hasOwnProperty.call(C,S))return!1;let N=n.parsed.newAliases;return[S,...C[S]].some(n=>!Object.prototype.hasOwnProperty.call(N,n)||!N[S])},I.limitedChoices=function limitedChoices(C){let F=n.getOptions(),I={};if(!Object.keys(F.choices).length)return;Object.keys(C).forEach(n=>{bd.indexOf(n)===-1&&Object.prototype.hasOwnProperty.call(F.choices,n)&&[].concat(C[n]).forEach(S=>{F.choices[n].indexOf(S)===-1&&S!==void 0&&(I[n]=(I[n]||[]).concat(S))})});let H=Object.keys(I);if(!H.length)return;let W=N(`Invalid values:`);H.forEach(n=>{W+=`\n ${N(`Argument: %s, Given: %s, Choices: %s`,n,S.stringifiedValues(I[n]),S.stringifiedValues(F.choices[n]))}`}),S.fail(W)};let H={};I.implies=function implies(S,N){argsert(`<string|object> [array|number|string]`,[S,N],arguments.length),typeof S==`object`?Object.keys(S).forEach(n=>{I.implies(n,S[n])}):(n.global(S),H[S]||(H[S]=[]),Array.isArray(N)?N.forEach(n=>I.implies(S,n)):(assertNotStrictEqual(N,void 0,C),H[S].push(N)))},I.getImplied=function getImplied(){return H};function keyExists(n,S){let C=Number(S);return S=isNaN(C)?S:C,typeof S==`number`?S=n._.length>=S:S.match(/^--no-.+/)?(S=S.match(/^--no-(.+)/)[1],S=!Object.prototype.hasOwnProperty.call(n,S)):S=Object.prototype.hasOwnProperty.call(n,S),S}I.implications=function implications(n){let C=[];if(Object.keys(H).forEach(S=>{let N=S;(H[S]||[]).forEach(S=>{let F=N,I=S;F=keyExists(n,F),S=keyExists(n,S),F&&!S&&C.push(` ${N} -> ${I}`)})}),C.length){let n=`${N(`Implications failed:`)}\n`;C.forEach(S=>{n+=S}),S.fail(n)}};let W={};I.conflicts=function conflicts(S,C){argsert(`<string|object> [array|string]`,[S,C],arguments.length),typeof S==`object`?Object.keys(S).forEach(n=>{I.conflicts(n,S[n])}):(n.global(S),W[S]||(W[S]=[]),Array.isArray(C)?C.forEach(n=>I.conflicts(S,n)):W[S].push(C))},I.getConflicting=()=>W,I.conflicting=function conflictingFn(F){Object.keys(F).forEach(n=>{W[n]&&W[n].forEach(C=>{C&&F[n]!==void 0&&F[C]!==void 0&&S.fail(N(`Arguments %s and %s are mutually exclusive`,n,C))})}),n.getInternalMethods().getParserConfiguration()[`strip-dashed`]&&Object.keys(W).forEach(n=>{W[n].forEach(I=>{I&&F[C.Parser.camelCase(n)]!==void 0&&F[C.Parser.camelCase(I)]!==void 0&&S.fail(N(`Arguments %s and %s are mutually exclusive`,n,I))})})},I.recommendCommands=function recommendCommands(n,C){C=C.sort((n,S)=>S.length-n.length);let F=null,I=1/0;for(let S=0,N;(N=C[S])!==void 0;S++){let S=levenshtein(n,N);S<=3&&S<I&&(I=S,F=N)}F&&S.fail(N(`Did you mean %s?`,F))},I.reset=function reset(n){return H=objFilter(H,S=>!n[S]),W=objFilter(W,S=>!n[S]),I};let q=[];return I.freeze=function freeze(){q.push({implied:H,conflicting:W})},I.unfreeze=function unfreeze(){let n=q.pop();assertNotStrictEqual(n,void 0,C),{implied:H,conflicting:W}=n},I}var bd,xd=__esmMin(()=>{sd(),rd(),yd(),fd(),bd=[`$0`,`--`,`_`]});function YargsFactory(n){return(S=[],C=n.process.cwd(),N)=>{let F=new YargsInstance(S,C,N,n);return Object.defineProperty(F,"argv",{get:()=>F.parse(),enumerable:!0}),F.help(),F.version(),F}}function isYargsInstance(n){return!!n&&typeof n.getInternalMethods==`function`}var __classPrivateFieldSet,__classPrivateFieldGet,Sd,Cd,wd,Td,Ed,Dd,Od,kd,Ad,jd,Md,Nd,Pd,Fd,Id,Ld,Rd,zd,Bd,Vd,Hd,Ud,Wd,Gd,Kd,qd,Jd,Yd,Xd,Zd,Qd,$d,ef,tf,nf,rf,af,of,sf,cf,lf,uf,df,ff,pf,mf,hf,gf,_f,vf,yf,bf,xf,Sf,Cf,wf,Tf,Ef,Df,Of,kf,Af,jf,Mf,Nf,Pf,Ff,If,Lf,Rf,zf,Bf,YargsInstance,Vf=__esmMin(()=>{ye(),dd(),rd(),rs(),md(),sd(),vd(),xd(),fd(),os(),cd(),id(),ld(),pd(),__classPrivateFieldSet=function(n,S,C,N,F){if(N===`m`)throw TypeError(`Private method is not writable`);if(N===`a`&&!F)throw TypeError(`Private accessor was defined without a setter`);if(typeof S==`function`?n!==S||!F:!S.has(n))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return N===`a`?F.call(n,C):F?F.value=C:S.set(n,C),C},__classPrivateFieldGet=function(n,S,C,N){if(C===`a`&&!N)throw TypeError(`Private accessor was defined without a getter`);if(typeof S==`function`?n!==S||!N:!S.has(n))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return C===`m`?N:C===`a`?N.call(n):N?N.value:S.get(n)},rf=Symbol(`copyDoubleDash`),af=Symbol(`copyDoubleDash`),of=Symbol(`deleteFromParserHintObject`),sf=Symbol(`emitWarning`),cf=Symbol(`freeze`),lf=Symbol(`getDollarZero`),uf=Symbol(`getParserConfiguration`),df=Symbol(`getUsageConfiguration`),ff=Symbol(`guessLocale`),pf=Symbol(`guessVersion`),mf=Symbol(`parsePositionalNumbers`),hf=Symbol(`pkgUp`),gf=Symbol(`populateParserHintArray`),_f=Symbol(`populateParserHintSingleValueDictionary`),vf=Symbol(`populateParserHintArrayDictionary`),yf=Symbol(`populateParserHintDictionary`),bf=Symbol(`sanitizeKey`),xf=Symbol(`setKey`),Sf=Symbol(`unfreeze`),Cf=Symbol(`validateAsync`),wf=Symbol(`getCommandInstance`),Tf=Symbol(`getContext`),Ef=Symbol(`getHasOutput`),Df=Symbol(`getLoggerInstance`),Of=Symbol(`getParseContext`),kf=Symbol(`getUsageInstance`),Af=Symbol(`getValidationInstance`),jf=Symbol(`hasParseCallback`),Mf=Symbol(`isGlobalContext`),Nf=Symbol(`postProcess`),Pf=Symbol(`rebase`),Ff=Symbol(`reset`),If=Symbol(`runYargsParserAndExecuteCommands`),Lf=Symbol(`runValidation`),Rf=Symbol(`setHasOutput`),zf=Symbol(`kTrackManuallySetKeys`),Bf=`en_US`,YargsInstance=class{constructor(n=[],S,C,N){this.customScriptName=!1,this.parsed=!1,Sd.set(this,void 0),Cd.set(this,void 0),wd.set(this,{commands:[],fullCommands:[]}),Td.set(this,null),Ed.set(this,null),Dd.set(this,`show-hidden`),Od.set(this,null),kd.set(this,!0),Ad.set(this,{}),jd.set(this,!0),Md.set(this,[]),Nd.set(this,void 0),Pd.set(this,{}),Fd.set(this,!1),Id.set(this,null),Ld.set(this,!0),Rd.set(this,void 0),zd.set(this,``),Bd.set(this,void 0),Vd.set(this,void 0),Hd.set(this,{}),Ud.set(this,null),Wd.set(this,null),Gd.set(this,{}),Kd.set(this,{}),qd.set(this,void 0),Jd.set(this,!1),Yd.set(this,void 0),Xd.set(this,!1),Zd.set(this,!1),Qd.set(this,!1),$d.set(this,void 0),ef.set(this,{}),tf.set(this,null),nf.set(this,void 0),__classPrivateFieldSet(this,Yd,N,`f`),__classPrivateFieldSet(this,qd,n,`f`),__classPrivateFieldSet(this,Cd,S,`f`),__classPrivateFieldSet(this,Vd,C,`f`),__classPrivateFieldSet(this,Nd,new GlobalMiddleware(this),`f`),this.$0=this[lf](),this[Ff](),__classPrivateFieldSet(this,Sd,__classPrivateFieldGet(this,Sd,`f`),`f`),__classPrivateFieldSet(this,$d,__classPrivateFieldGet(this,$d,`f`),`f`),__classPrivateFieldSet(this,nf,__classPrivateFieldGet(this,nf,`f`),`f`),__classPrivateFieldSet(this,Bd,__classPrivateFieldGet(this,Bd,`f`),`f`),__classPrivateFieldGet(this,Bd,`f`).showHiddenOpt=__classPrivateFieldGet(this,Dd,`f`),__classPrivateFieldSet(this,Rd,this[af](),`f`),__classPrivateFieldGet(this,Yd,`f`).y18n.setLocale(Bf)}addHelpOpt(n,S){return argsert(`[string|boolean] [string]`,[n,S],arguments.length),__classPrivateFieldGet(this,Id,`f`)&&(this[of](__classPrivateFieldGet(this,Id,`f`)),__classPrivateFieldSet(this,Id,null,`f`)),n===!1&&S===void 0?this:(__classPrivateFieldSet(this,Id,typeof n==`string`?n:`help`,`f`),this.boolean(__classPrivateFieldGet(this,Id,`f`)),this.describe(__classPrivateFieldGet(this,Id,`f`),S||__classPrivateFieldGet(this,$d,`f`).deferY18nLookup(`Show help`)),this)}help(n,S){return this.addHelpOpt(n,S)}addShowHiddenOpt(n,S){if(argsert(`[string|boolean] [string]`,[n,S],arguments.length),n===!1&&S===void 0)return this;let C=typeof n==`string`?n:__classPrivateFieldGet(this,Dd,`f`);return this.boolean(C),this.describe(C,S||__classPrivateFieldGet(this,$d,`f`).deferY18nLookup(`Show hidden options`)),__classPrivateFieldGet(this,Bd,`f`).showHiddenOpt=C,this}showHidden(n,S){return this.addShowHiddenOpt(n,S)}alias(n,S){return argsert(`<object|string|array> [string|array]`,[n,S],arguments.length),this[vf](this.alias.bind(this),`alias`,n,S),this}array(n){return argsert(`<array|string>`,[n],arguments.length),this[gf](`array`,n),this[zf](n),this}boolean(n){return argsert(`<array|string>`,[n],arguments.length),this[gf](`boolean`,n),this[zf](n),this}check(n,S){return argsert(`<function> [boolean]`,[n,S],arguments.length),this.middleware((S,C)=>maybeAsyncResult(()=>n(S,C.getOptions()),C=>(C?(typeof C==`string`||C instanceof Error)&&__classPrivateFieldGet(this,$d,`f`).fail(C.toString(),C):__classPrivateFieldGet(this,$d,`f`).fail(__classPrivateFieldGet(this,Yd,`f`).y18n.__(`Argument check failed: %s`,n.toString())),S),n=>(__classPrivateFieldGet(this,$d,`f`).fail(n.message?n.message:n.toString(),n),S)),!1,S),this}choices(n,S){return argsert(`<object|string|array> [string|array]`,[n,S],arguments.length),this[vf](this.choices.bind(this),`choices`,n,S),this}coerce(n,S){if(argsert(`<object|string|array> [function]`,[n,S],arguments.length),Array.isArray(n)){if(!S)throw new ns(`coerce callback must be provided`);for(let C of n)this.coerce(C,S);return this}else if(typeof n==`object`){for(let S of Object.keys(n))this.coerce(S,n[S]);return this}if(!S)throw new ns(`coerce callback must be provided`);let C=n;return __classPrivateFieldGet(this,Bd,`f`).key[C]=!0,__classPrivateFieldGet(this,Nd,`f`).addCoerceMiddleware((n,N)=>{let F=N.getAliases()[C]??[],I=[C,...F].filter(S=>Object.prototype.hasOwnProperty.call(n,S));return I.length===0?n:maybeAsyncResult(()=>S(n[I[0]]),S=>(I.forEach(C=>{n[C]=S}),n),n=>{throw new ns(n.message)})},C),this}conflicts(n,S){return argsert(`<string|object> [string|array]`,[n,S],arguments.length),__classPrivateFieldGet(this,nf,`f`).conflicts(n,S),this}config(n=`config`,S,C){return argsert(`[object|string] [string|function] [function]`,[n,S,C],arguments.length),typeof n==`object`&&!Array.isArray(n)?(n=applyExtends(n,__classPrivateFieldGet(this,Cd,`f`),this[uf]()[`deep-merge-config`]||!1,__classPrivateFieldGet(this,Yd,`f`)),__classPrivateFieldGet(this,Bd,`f`).configObjects=(__classPrivateFieldGet(this,Bd,`f`).configObjects||[]).concat(n),this):(typeof S==`function`&&(C=S,S=void 0),this.describe(n,S||__classPrivateFieldGet(this,$d,`f`).deferY18nLookup(`Path to JSON config file`)),(Array.isArray(n)?n:[n]).forEach(n=>{__classPrivateFieldGet(this,Bd,`f`).config[n]=C||!0}),this)}completion(n,S,C){return argsert(`[string] [string|boolean|function] [function]`,[n,S,C],arguments.length),typeof S==`function`&&(C=S,S=void 0),__classPrivateFieldSet(this,Ed,n||__classPrivateFieldGet(this,Ed,`f`)||`completion`,`f`),!S&&S!==!1&&(S=`generate completion script`),this.command(__classPrivateFieldGet(this,Ed,`f`),S),C&&__classPrivateFieldGet(this,Td,`f`).registerFunction(C),this}command(n,S,C,N,F,I){return argsert(`<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]`,[n,S,C,N,F,I],arguments.length),__classPrivateFieldGet(this,Sd,`f`).addHandler(n,S,C,N,F,I),this}commands(n,S,C,N,F,I){return this.command(n,S,C,N,F,I)}commandDir(n,S){argsert(`<string> [object]`,[n,S],arguments.length);let C=__classPrivateFieldGet(this,Vd,`f`)||__classPrivateFieldGet(this,Yd,`f`).require;return __classPrivateFieldGet(this,Sd,`f`).addDirectory(n,C,__classPrivateFieldGet(this,Yd,`f`).getCallerFile(),S),this}count(n){return argsert(`<array|string>`,[n],arguments.length),this[gf](`count`,n),this[zf](n),this}default(n,S,C){return argsert(`<object|string|array> [*] [string]`,[n,S,C],arguments.length),C&&(assertSingleKey(n,__classPrivateFieldGet(this,Yd,`f`)),__classPrivateFieldGet(this,Bd,`f`).defaultDescription[n]=C),typeof S==`function`&&(assertSingleKey(n,__classPrivateFieldGet(this,Yd,`f`)),__classPrivateFieldGet(this,Bd,`f`).defaultDescription[n]||(__classPrivateFieldGet(this,Bd,`f`).defaultDescription[n]=__classPrivateFieldGet(this,$d,`f`).functionDescription(S)),S=S.call()),this[_f](this.default.bind(this),`default`,n,S),this}defaults(n,S,C){return this.default(n,S,C)}demandCommand(n=1,S,C,N){return argsert(`[number] [number|string] [string|null|undefined] [string|null|undefined]`,[n,S,C,N],arguments.length),typeof S!=`number`&&(C=S,S=1/0),this.global(`_`,!1),__classPrivateFieldGet(this,Bd,`f`).demandedCommands._={min:n,max:S,minMsg:C,maxMsg:N},this}demand(n,S,C){return Array.isArray(S)?(S.forEach(n=>{assertNotStrictEqual(C,!0,__classPrivateFieldGet(this,Yd,`f`)),this.demandOption(n,C)}),S=1/0):typeof S!=`number`&&(C=S,S=1/0),typeof n==`number`?(assertNotStrictEqual(C,!0,__classPrivateFieldGet(this,Yd,`f`)),this.demandCommand(n,S,C,C)):Array.isArray(n)?n.forEach(n=>{assertNotStrictEqual(C,!0,__classPrivateFieldGet(this,Yd,`f`)),this.demandOption(n,C)}):typeof C==`string`?this.demandOption(n,C):(C===!0||C===void 0)&&this.demandOption(n),this}demandOption(n,S){return argsert(`<object|string|array> [string]`,[n,S],arguments.length),this[_f](this.demandOption.bind(this),`demandedOptions`,n,S),this}deprecateOption(n,S){return argsert(`<string> [string|boolean]`,[n,S],arguments.length),__classPrivateFieldGet(this,Bd,`f`).deprecatedOptions[n]=S,this}describe(n,S){return argsert(`<object|string|array> [string]`,[n,S],arguments.length),this[xf](n,!0),__classPrivateFieldGet(this,$d,`f`).describe(n,S),this}detectLocale(n){return argsert(`<boolean>`,[n],arguments.length),__classPrivateFieldSet(this,kd,n,`f`),this}env(n){return argsert(`[string|boolean]`,[n],arguments.length),n===!1?delete __classPrivateFieldGet(this,Bd,`f`).envPrefix:__classPrivateFieldGet(this,Bd,`f`).envPrefix=n||``,this}epilogue(n){return argsert(`<string>`,[n],arguments.length),__classPrivateFieldGet(this,$d,`f`).epilog(n),this}epilog(n){return this.epilogue(n)}example(n,S){return argsert(`<string|array> [string]`,[n,S],arguments.length),Array.isArray(n)?n.forEach(n=>this.example(...n)):__classPrivateFieldGet(this,$d,`f`).example(n,S),this}exit(n,S){__classPrivateFieldSet(this,Fd,!0,`f`),__classPrivateFieldSet(this,Od,S,`f`),__classPrivateFieldGet(this,jd,`f`)&&__classPrivateFieldGet(this,Yd,`f`).process.exit(n)}exitProcess(n=!0){return argsert(`[boolean]`,[n],arguments.length),__classPrivateFieldSet(this,jd,n,`f`),this}fail(n){if(argsert(`<function|boolean>`,[n],arguments.length),typeof n==`boolean`&&n!==!1)throw new ns(`Invalid first argument. Expected function or boolean 'false'`);return __classPrivateFieldGet(this,$d,`f`).failFn(n),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(n,S){return argsert(`<array> [function]`,[n,S],arguments.length),S?__classPrivateFieldGet(this,Td,`f`).getCompletion(n,S):new Promise((S,C)=>{__classPrivateFieldGet(this,Td,`f`).getCompletion(n,(n,N)=>{n?C(n):S(N)})})}getDemandedOptions(){return argsert([],0),__classPrivateFieldGet(this,Bd,`f`).demandedOptions}getDemandedCommands(){return argsert([],0),__classPrivateFieldGet(this,Bd,`f`).demandedCommands}getDeprecatedOptions(){return argsert([],0),__classPrivateFieldGet(this,Bd,`f`).deprecatedOptions}getDetectLocale(){return __classPrivateFieldGet(this,kd,`f`)}getExitProcess(){return __classPrivateFieldGet(this,jd,`f`)}getGroups(){return Object.assign({},__classPrivateFieldGet(this,Pd,`f`),__classPrivateFieldGet(this,Kd,`f`))}getHelp(){if(__classPrivateFieldSet(this,Fd,!0,`f`),!__classPrivateFieldGet(this,$d,`f`).hasCachedHelpMessage()){if(!this.parsed){let n=this[If](__classPrivateFieldGet(this,qd,`f`),void 0,void 0,0,!0);if(isPromise(n))return n.then(()=>__classPrivateFieldGet(this,$d,`f`).help())}let n=__classPrivateFieldGet(this,Sd,`f`).runDefaultBuilderOn(this);if(isPromise(n))return n.then(()=>__classPrivateFieldGet(this,$d,`f`).help())}return Promise.resolve(__classPrivateFieldGet(this,$d,`f`).help())}getOptions(){return __classPrivateFieldGet(this,Bd,`f`)}getStrict(){return __classPrivateFieldGet(this,Xd,`f`)}getStrictCommands(){return __classPrivateFieldGet(this,Zd,`f`)}getStrictOptions(){return __classPrivateFieldGet(this,Qd,`f`)}global(n,S){return argsert(`<string|array> [boolean]`,[n,S],arguments.length),n=[].concat(n),S===!1?n.forEach(n=>{__classPrivateFieldGet(this,Bd,`f`).local.includes(n)||__classPrivateFieldGet(this,Bd,`f`).local.push(n)}):__classPrivateFieldGet(this,Bd,`f`).local=__classPrivateFieldGet(this,Bd,`f`).local.filter(S=>n.indexOf(S)===-1),this}group(n,S){argsert(`<string|array> <string>`,[n,S],arguments.length);let C=__classPrivateFieldGet(this,Kd,`f`)[S]||__classPrivateFieldGet(this,Pd,`f`)[S];__classPrivateFieldGet(this,Kd,`f`)[S]&&delete __classPrivateFieldGet(this,Kd,`f`)[S];let N={};return __classPrivateFieldGet(this,Pd,`f`)[S]=(C||[]).concat(n).filter(n=>N[n]?!1:N[n]=!0),this}hide(n){return argsert(`<string>`,[n],arguments.length),__classPrivateFieldGet(this,Bd,`f`).hiddenOptions.push(n),this}implies(n,S){return argsert(`<string|object> [number|string|array]`,[n,S],arguments.length),__classPrivateFieldGet(this,nf,`f`).implies(n,S),this}locale(n){return argsert(`[string]`,[n],arguments.length),n===void 0?(this[ff](),__classPrivateFieldGet(this,Yd,`f`).y18n.getLocale()):(__classPrivateFieldSet(this,kd,!1,`f`),__classPrivateFieldGet(this,Yd,`f`).y18n.setLocale(n),this)}middleware(n,S,C){return __classPrivateFieldGet(this,Nd,`f`).addMiddleware(n,!!S,C)}nargs(n,S){return argsert(`<string|object|array> [number]`,[n,S],arguments.length),this[_f](this.nargs.bind(this),`narg`,n,S),this}normalize(n){return argsert(`<array|string>`,[n],arguments.length),this[gf](`normalize`,n),this}number(n){return argsert(`<array|string>`,[n],arguments.length),this[gf](`number`,n),this[zf](n),this}option(n,S){if(argsert(`<string|object> [object]`,[n,S],arguments.length),typeof n==`object`)Object.keys(n).forEach(S=>{this.options(S,n[S])});else{typeof S!=`object`&&(S={}),this[zf](n),__classPrivateFieldGet(this,tf,`f`)&&(n===`version`||S?.alias===`version`)&&this[sf]([`"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(`
120
120
  `),void 0,`versionWarning`),__classPrivateFieldGet(this,Bd,`f`).key[n]=!0,S.alias&&this.alias(n,S.alias);let C=S.deprecate||S.deprecated;C&&this.deprecateOption(n,C);let N=S.demand||S.required||S.require;N&&this.demand(n,N),S.demandOption&&this.demandOption(n,typeof S.demandOption==`string`?S.demandOption:void 0),S.conflicts&&this.conflicts(n,S.conflicts),`default`in S&&this.default(n,S.default),S.implies!==void 0&&this.implies(n,S.implies),S.nargs!==void 0&&this.nargs(n,S.nargs),S.config&&this.config(n,S.configParser),S.normalize&&this.normalize(n),S.choices&&this.choices(n,S.choices),S.coerce&&this.coerce(n,S.coerce),S.group&&this.group(n,S.group),(S.boolean||S.type===`boolean`)&&(this.boolean(n),S.alias&&this.boolean(S.alias)),(S.array||S.type===`array`)&&(this.array(n),S.alias&&this.array(S.alias)),(S.number||S.type===`number`)&&(this.number(n),S.alias&&this.number(S.alias)),(S.string||S.type===`string`)&&(this.string(n),S.alias&&this.string(S.alias)),(S.count||S.type===`count`)&&this.count(n),typeof S.global==`boolean`&&this.global(n,S.global),S.defaultDescription&&(__classPrivateFieldGet(this,Bd,`f`).defaultDescription[n]=S.defaultDescription),S.skipValidation&&this.skipValidation(n);let F=S.describe||S.description||S.desc,I=__classPrivateFieldGet(this,$d,`f`).getDescriptions();(!Object.prototype.hasOwnProperty.call(I,n)||typeof F==`string`)&&this.describe(n,F),S.hidden&&this.hide(n),S.requiresArg&&this.requiresArg(n)}return this}options(n,S){return this.option(n,S)}parse(n,S,C){argsert(`[string|array] [function|boolean|object] [function]`,[n,S,C],arguments.length),this[cf](),n===void 0&&(n=__classPrivateFieldGet(this,qd,`f`)),typeof S==`object`&&(__classPrivateFieldSet(this,Wd,S,`f`),S=C),typeof S==`function`&&(__classPrivateFieldSet(this,Ud,S,`f`),S=!1),S||__classPrivateFieldSet(this,qd,n,`f`),__classPrivateFieldGet(this,Ud,`f`)&&__classPrivateFieldSet(this,jd,!1,`f`);let N=this[If](n,!!S),F=this.parsed;return __classPrivateFieldGet(this,Td,`f`).setParsed(this.parsed),isPromise(N)?N.then(n=>(__classPrivateFieldGet(this,Ud,`f`)&&__classPrivateFieldGet(this,Ud,`f`).call(this,__classPrivateFieldGet(this,Od,`f`),n,__classPrivateFieldGet(this,zd,`f`)),n)).catch(n=>{throw __classPrivateFieldGet(this,Ud,`f`)&&__classPrivateFieldGet(this,Ud,`f`)(n,this.parsed.argv,__classPrivateFieldGet(this,zd,`f`)),n}).finally(()=>{this[Sf](),this.parsed=F}):(__classPrivateFieldGet(this,Ud,`f`)&&__classPrivateFieldGet(this,Ud,`f`).call(this,__classPrivateFieldGet(this,Od,`f`),N,__classPrivateFieldGet(this,zd,`f`)),this[Sf](),this.parsed=F,N)}parseAsync(n,S,C){let N=this.parse(n,S,C);return isPromise(N)?N:Promise.resolve(N)}parseSync(n,S,C){let N=this.parse(n,S,C);if(isPromise(N))throw new ns(`.parseSync() must not be used with asynchronous builders, handlers, or middleware`);return N}parserConfiguration(n){return argsert(`<object>`,[n],arguments.length),__classPrivateFieldSet(this,Hd,n,`f`),this}pkgConf(n,S){argsert(`<string> [string]`,[n,S],arguments.length);let C=null,N=this[hf](S||__classPrivateFieldGet(this,Cd,`f`));return N[n]&&typeof N[n]==`object`&&(C=applyExtends(N[n],S||__classPrivateFieldGet(this,Cd,`f`),this[uf]()[`deep-merge-config`]||!1,__classPrivateFieldGet(this,Yd,`f`)),__classPrivateFieldGet(this,Bd,`f`).configObjects=(__classPrivateFieldGet(this,Bd,`f`).configObjects||[]).concat(C)),this}positional(n,S){argsert(`<string> <object>`,[n,S],arguments.length);let C=[`default`,`defaultDescription`,`implies`,`normalize`,`choices`,`conflicts`,`coerce`,`type`,`describe`,`desc`,`description`,`alias`];S=objFilter(S,(n,S)=>n===`type`&&![`string`,`number`,`boolean`].includes(S)?!1:C.includes(n));let N=__classPrivateFieldGet(this,wd,`f`).fullCommands[__classPrivateFieldGet(this,wd,`f`).fullCommands.length-1],F=N?__classPrivateFieldGet(this,Sd,`f`).cmdToParseOptions(N):{array:[],alias:{},default:{},demand:{}};return objectKeys(F).forEach(C=>{let N=F[C];Array.isArray(N)?N.indexOf(n)!==-1&&(S[C]=!0):N[n]&&!(C in S)&&(S[C]=N[n])}),this.group(n,__classPrivateFieldGet(this,$d,`f`).getPositionalGroupName()),this.option(n,S)}recommendCommands(n=!0){return argsert(`[boolean]`,[n],arguments.length),__classPrivateFieldSet(this,Jd,n,`f`),this}required(n,S,C){return this.demand(n,S,C)}require(n,S,C){return this.demand(n,S,C)}requiresArg(n){return argsert(`<array|string|object> [number]`,[n],arguments.length),typeof n==`string`&&__classPrivateFieldGet(this,Bd,`f`).narg[n]||this[_f](this.requiresArg.bind(this),`narg`,n,NaN),this}showCompletionScript(n,S){return argsert(`[string] [string]`,[n,S],arguments.length),n||=this.$0,__classPrivateFieldGet(this,Rd,`f`).log(__classPrivateFieldGet(this,Td,`f`).generateCompletionScript(n,S||__classPrivateFieldGet(this,Ed,`f`)||`completion`)),this}showHelp(n){if(argsert(`[string|function]`,[n],arguments.length),__classPrivateFieldSet(this,Fd,!0,`f`),!__classPrivateFieldGet(this,$d,`f`).hasCachedHelpMessage()){if(!this.parsed){let S=this[If](__classPrivateFieldGet(this,qd,`f`),void 0,void 0,0,!0);if(isPromise(S))return S.then(()=>{__classPrivateFieldGet(this,$d,`f`).showHelp(n)}),this}let S=__classPrivateFieldGet(this,Sd,`f`).runDefaultBuilderOn(this);if(isPromise(S))return S.then(()=>{__classPrivateFieldGet(this,$d,`f`).showHelp(n)}),this}return __classPrivateFieldGet(this,$d,`f`).showHelp(n),this}scriptName(n){return this.customScriptName=!0,this.$0=n,this}showHelpOnFail(n,S){return argsert(`[boolean|string] [string]`,[n,S],arguments.length),__classPrivateFieldGet(this,$d,`f`).showHelpOnFail(n,S),this}showVersion(n){return argsert(`[string|function]`,[n],arguments.length),__classPrivateFieldGet(this,$d,`f`).showVersion(n),this}skipValidation(n){return argsert(`<array|string>`,[n],arguments.length),this[gf](`skipValidation`,n),this}strict(n){return argsert(`[boolean]`,[n],arguments.length),__classPrivateFieldSet(this,Xd,n!==!1,`f`),this}strictCommands(n){return argsert(`[boolean]`,[n],arguments.length),__classPrivateFieldSet(this,Zd,n!==!1,`f`),this}strictOptions(n){return argsert(`[boolean]`,[n],arguments.length),__classPrivateFieldSet(this,Qd,n!==!1,`f`),this}string(n){return argsert(`<array|string>`,[n],arguments.length),this[gf](`string`,n),this[zf](n),this}terminalWidth(){return argsert([],0),__classPrivateFieldGet(this,Yd,`f`).process.stdColumns}updateLocale(n){return this.updateStrings(n)}updateStrings(n){return argsert(`<object>`,[n],arguments.length),__classPrivateFieldSet(this,kd,!1,`f`),__classPrivateFieldGet(this,Yd,`f`).y18n.updateLocale(n),this}usage(n,S,C,N){if(argsert(`<string|null|undefined> [string|boolean] [function|object] [function]`,[n,S,C,N],arguments.length),S!==void 0){if(assertNotStrictEqual(n,null,__classPrivateFieldGet(this,Yd,`f`)),(n||``).match(/^\$0( |$)/))return this.command(n,S,C,N);throw new ns(`.usage() description must start with $0 if being used as alias for .command()`)}else return __classPrivateFieldGet(this,$d,`f`).usage(n),this}usageConfiguration(n){return argsert(`<object>`,[n],arguments.length),__classPrivateFieldSet(this,ef,n,`f`),this}version(n,S,C){let N=`version`;if(argsert(`[boolean|string] [string] [string]`,[n,S,C],arguments.length),__classPrivateFieldGet(this,tf,`f`)&&(this[of](__classPrivateFieldGet(this,tf,`f`)),__classPrivateFieldGet(this,$d,`f`).version(void 0),__classPrivateFieldSet(this,tf,null,`f`)),arguments.length===0)C=this[pf](),n=N;else if(arguments.length===1){if(n===!1)return this;C=n,n=N}else arguments.length===2&&(C=S,S=void 0);return __classPrivateFieldSet(this,tf,typeof n==`string`?n:N,`f`),S||=__classPrivateFieldGet(this,$d,`f`).deferY18nLookup(`Show version number`),__classPrivateFieldGet(this,$d,`f`).version(C||void 0),this.boolean(__classPrivateFieldGet(this,tf,`f`)),this.describe(__classPrivateFieldGet(this,tf,`f`),S),this}wrap(n){return argsert(`<number|null|undefined>`,[n],arguments.length),__classPrivateFieldGet(this,$d,`f`).wrap(n),this}[(Sd=new WeakMap,Cd=new WeakMap,wd=new WeakMap,Td=new WeakMap,Ed=new WeakMap,Dd=new WeakMap,Od=new WeakMap,kd=new WeakMap,Ad=new WeakMap,jd=new WeakMap,Md=new WeakMap,Nd=new WeakMap,Pd=new WeakMap,Fd=new WeakMap,Id=new WeakMap,Ld=new WeakMap,Rd=new WeakMap,zd=new WeakMap,Bd=new WeakMap,Vd=new WeakMap,Hd=new WeakMap,Ud=new WeakMap,Wd=new WeakMap,Gd=new WeakMap,Kd=new WeakMap,qd=new WeakMap,Jd=new WeakMap,Yd=new WeakMap,Xd=new WeakMap,Zd=new WeakMap,Qd=new WeakMap,$d=new WeakMap,ef=new WeakMap,tf=new WeakMap,nf=new WeakMap,rf)](n){if(!n._||!n[`--`])return n;n._.push.apply(n._,n[`--`]);try{delete n[`--`]}catch{}return n}[af](){return{log:(...n)=>{this[jf]()||ve.log(...n),__classPrivateFieldSet(this,Fd,!0,`f`),__classPrivateFieldGet(this,zd,`f`).length&&__classPrivateFieldSet(this,zd,__classPrivateFieldGet(this,zd,`f`)+`
121
121
  `,`f`),__classPrivateFieldSet(this,zd,__classPrivateFieldGet(this,zd,`f`)+n.join(` `),`f`)},error:(...n)=>{this[jf]()||ve.error(...n),__classPrivateFieldSet(this,Fd,!0,`f`),__classPrivateFieldGet(this,zd,`f`).length&&__classPrivateFieldSet(this,zd,__classPrivateFieldGet(this,zd,`f`)+`
122
- `,`f`),__classPrivateFieldSet(this,zd,__classPrivateFieldGet(this,zd,`f`)+n.join(` `),`f`)}}}[of](n){objectKeys(__classPrivateFieldGet(this,Bd,`f`)).forEach(S=>{if((n=>n===`configObjects`)(S))return;let C=__classPrivateFieldGet(this,Bd,`f`)[S];Array.isArray(C)?C.includes(n)&&C.splice(C.indexOf(n),1):typeof C==`object`&&delete C[n]}),delete __classPrivateFieldGet(this,$d,`f`).getDescriptions()[n]}[sf](n,S,C){__classPrivateFieldGet(this,Ad,`f`)[C]||(__classPrivateFieldGet(this,Yd,`f`).process.emitWarning(n,S),__classPrivateFieldGet(this,Ad,`f`)[C]=!0)}[cf](){__classPrivateFieldGet(this,Md,`f`).push({options:__classPrivateFieldGet(this,Bd,`f`),configObjects:__classPrivateFieldGet(this,Bd,`f`).configObjects.slice(0),exitProcess:__classPrivateFieldGet(this,jd,`f`),groups:__classPrivateFieldGet(this,Pd,`f`),strict:__classPrivateFieldGet(this,Xd,`f`),strictCommands:__classPrivateFieldGet(this,Zd,`f`),strictOptions:__classPrivateFieldGet(this,Qd,`f`),completionCommand:__classPrivateFieldGet(this,Ed,`f`),output:__classPrivateFieldGet(this,zd,`f`),exitError:__classPrivateFieldGet(this,Od,`f`),hasOutput:__classPrivateFieldGet(this,Fd,`f`),parsed:this.parsed,parseFn:__classPrivateFieldGet(this,Ud,`f`),parseContext:__classPrivateFieldGet(this,Wd,`f`)}),__classPrivateFieldGet(this,$d,`f`).freeze(),__classPrivateFieldGet(this,nf,`f`).freeze(),__classPrivateFieldGet(this,Sd,`f`).freeze(),__classPrivateFieldGet(this,Nd,`f`).freeze()}[lf](){let n=``,S;return S=/\b(node|iojs|electron)(\.exe)?$/.test(__classPrivateFieldGet(this,Yd,`f`).process.argv()[0])?__classPrivateFieldGet(this,Yd,`f`).process.argv().slice(1,2):__classPrivateFieldGet(this,Yd,`f`).process.argv().slice(0,1),n=S.map(n=>{let S=this[Pf](__classPrivateFieldGet(this,Cd,`f`),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&S.length<n.length?S:n}).join(` `).trim(),__classPrivateFieldGet(this,Yd,`f`).getEnv(`_`)&&__classPrivateFieldGet(this,Yd,`f`).getProcessArgvBin()===__classPrivateFieldGet(this,Yd,`f`).getEnv(`_`)&&(n=__classPrivateFieldGet(this,Yd,`f`).getEnv(`_`).replace(`${__classPrivateFieldGet(this,Yd,`f`).path.dirname(__classPrivateFieldGet(this,Yd,`f`).process.execPath())}/`,``)),n}[uf](){return __classPrivateFieldGet(this,Hd,`f`)}[df](){return __classPrivateFieldGet(this,ef,`f`)}[ff](){if(!__classPrivateFieldGet(this,kd,`f`))return;let n=__classPrivateFieldGet(this,Yd,`f`).getEnv(`LC_ALL`)||__classPrivateFieldGet(this,Yd,`f`).getEnv(`LC_MESSAGES`)||__classPrivateFieldGet(this,Yd,`f`).getEnv(`LANG`)||__classPrivateFieldGet(this,Yd,`f`).getEnv(`LANGUAGE`)||`en_US`;this.locale(n.replace(/[.:].*/,``))}[pf](){return this[hf]().version||`unknown`}[mf](n){let S=n[`--`]?n[`--`]:n._;for(let n=0,C;(C=S[n])!==void 0;n++)__classPrivateFieldGet(this,Yd,`f`).Parser.looksLikeNumber(C)&&Number.isSafeInteger(Math.floor(parseFloat(`${C}`)))&&(S[n]=Number(C));return n}[hf](n){let S=n||`*`;if(__classPrivateFieldGet(this,Gd,`f`)[S])return __classPrivateFieldGet(this,Gd,`f`)[S];let C={};try{let S=n||__classPrivateFieldGet(this,Yd,`f`).mainFilename;__classPrivateFieldGet(this,Yd,`f`).path.extname(S)&&(S=__classPrivateFieldGet(this,Yd,`f`).path.dirname(S));let N=__classPrivateFieldGet(this,Yd,`f`).findUp(S,(n,S)=>{if(S.includes(`package.json`))return`package.json`});assertNotStrictEqual(N,void 0,__classPrivateFieldGet(this,Yd,`f`)),C=JSON.parse(__classPrivateFieldGet(this,Yd,`f`).readFileSync(N,`utf8`))}catch{}return __classPrivateFieldGet(this,Gd,`f`)[S]=C||{},__classPrivateFieldGet(this,Gd,`f`)[S]}[gf](n,S){S=[].concat(S),S.forEach(S=>{S=this[bf](S),__classPrivateFieldGet(this,Bd,`f`)[n].push(S)})}[_f](n,S,C,N){this[yf](n,S,C,N,(n,S,C)=>{__classPrivateFieldGet(this,Bd,`f`)[n][S]=C})}[vf](n,S,C,N){this[yf](n,S,C,N,(n,S,C)=>{__classPrivateFieldGet(this,Bd,`f`)[n][S]=(__classPrivateFieldGet(this,Bd,`f`)[n][S]||[]).concat(C)})}[yf](n,S,C,N,F){if(Array.isArray(C))C.forEach(S=>{n(S,N)});else if((n=>typeof n==`object`)(C))for(let S of objectKeys(C))n(S,C[S]);else F(S,this[bf](C),N)}[bf](n){return n===`__proto__`?`___proto___`:n}[xf](n,S){return this[_f](this[xf].bind(this),`key`,n,S),this}[Sf](){var n,S,C,N,F,I,H,W,q,Y,X,Z;let te=__classPrivateFieldGet(this,Md,`f`).pop();assertNotStrictEqual(te,void 0,__classPrivateFieldGet(this,Yd,`f`));let ne;n=this,S=this,C=this,N=this,F=this,I=this,H=this,W=this,q=this,Y=this,X=this,Z=this,{options:{set value(S){__classPrivateFieldSet(n,Bd,S,`f`)}}.value,configObjects:ne,exitProcess:{set value(n){__classPrivateFieldSet(S,jd,n,`f`)}}.value,groups:{set value(n){__classPrivateFieldSet(C,Pd,n,`f`)}}.value,output:{set value(n){__classPrivateFieldSet(N,zd,n,`f`)}}.value,exitError:{set value(n){__classPrivateFieldSet(F,Od,n,`f`)}}.value,hasOutput:{set value(n){__classPrivateFieldSet(I,Fd,n,`f`)}}.value,parsed:this.parsed,strict:{set value(n){__classPrivateFieldSet(H,Xd,n,`f`)}}.value,strictCommands:{set value(n){__classPrivateFieldSet(W,Zd,n,`f`)}}.value,strictOptions:{set value(n){__classPrivateFieldSet(q,Qd,n,`f`)}}.value,completionCommand:{set value(n){__classPrivateFieldSet(Y,Ed,n,`f`)}}.value,parseFn:{set value(n){__classPrivateFieldSet(X,Ud,n,`f`)}}.value,parseContext:{set value(n){__classPrivateFieldSet(Z,Wd,n,`f`)}}.value}=te,__classPrivateFieldGet(this,Bd,`f`).configObjects=ne,__classPrivateFieldGet(this,$d,`f`).unfreeze(),__classPrivateFieldGet(this,nf,`f`).unfreeze(),__classPrivateFieldGet(this,Sd,`f`).unfreeze(),__classPrivateFieldGet(this,Nd,`f`).unfreeze()}[Cf](n,S){return maybeAsyncResult(S,S=>(n(S),S))}getInternalMethods(){return{getCommandInstance:this[wf].bind(this),getContext:this[Tf].bind(this),getHasOutput:this[Ef].bind(this),getLoggerInstance:this[Df].bind(this),getParseContext:this[Of].bind(this),getParserConfiguration:this[uf].bind(this),getUsageConfiguration:this[df].bind(this),getUsageInstance:this[kf].bind(this),getValidationInstance:this[Af].bind(this),hasParseCallback:this[jf].bind(this),isGlobalContext:this[Mf].bind(this),postProcess:this[Nf].bind(this),reset:this[Ff].bind(this),runValidation:this[Lf].bind(this),runYargsParserAndExecuteCommands:this[If].bind(this),setHasOutput:this[Rf].bind(this)}}[wf](){return __classPrivateFieldGet(this,Sd,`f`)}[Tf](){return __classPrivateFieldGet(this,wd,`f`)}[Ef](){return __classPrivateFieldGet(this,Fd,`f`)}[Df](){return __classPrivateFieldGet(this,Rd,`f`)}[Of](){return __classPrivateFieldGet(this,Wd,`f`)||{}}[kf](){return __classPrivateFieldGet(this,$d,`f`)}[Af](){return __classPrivateFieldGet(this,nf,`f`)}[jf](){return!!__classPrivateFieldGet(this,Ud,`f`)}[Mf](){return __classPrivateFieldGet(this,Ld,`f`)}[Nf](n,S,C,N){return C||isPromise(n)?n:(S||(n=this[rf](n)),(this[uf]()[`parse-positional-numbers`]||this[uf]()[`parse-positional-numbers`]===void 0)&&(n=this[mf](n)),N&&(n=applyMiddleware(n,this,__classPrivateFieldGet(this,Nd,`f`).getMiddleware(),!1)),n)}[Ff](n={}){__classPrivateFieldSet(this,Bd,__classPrivateFieldGet(this,Bd,`f`)||{},`f`);let S={};S.local=__classPrivateFieldGet(this,Bd,`f`).local||[],S.configObjects=__classPrivateFieldGet(this,Bd,`f`).configObjects||[];let C={};return S.local.forEach(S=>{C[S]=!0,(n[S]||[]).forEach(n=>{C[n]=!0})}),Object.assign(__classPrivateFieldGet(this,Kd,`f`),Object.keys(__classPrivateFieldGet(this,Pd,`f`)).reduce((n,S)=>{let N=__classPrivateFieldGet(this,Pd,`f`)[S].filter(n=>!(n in C));return N.length>0&&(n[S]=N),n},{})),__classPrivateFieldSet(this,Pd,{},`f`),[`array`,`boolean`,`string`,`skipValidation`,`count`,`normalize`,`number`,`hiddenOptions`].forEach(n=>{S[n]=(__classPrivateFieldGet(this,Bd,`f`)[n]||[]).filter(n=>!C[n])}),[`narg`,`key`,`alias`,`default`,`defaultDescription`,`config`,`choices`,`demandedOptions`,`demandedCommands`,`deprecatedOptions`].forEach(n=>{S[n]=objFilter(__classPrivateFieldGet(this,Bd,`f`)[n],n=>!C[n])}),S.envPrefix=__classPrivateFieldGet(this,Bd,`f`).envPrefix,__classPrivateFieldSet(this,Bd,S,`f`),__classPrivateFieldSet(this,$d,__classPrivateFieldGet(this,$d,`f`)?__classPrivateFieldGet(this,$d,`f`).reset(C):usage(this,__classPrivateFieldGet(this,Yd,`f`)),`f`),__classPrivateFieldSet(this,nf,__classPrivateFieldGet(this,nf,`f`)?__classPrivateFieldGet(this,nf,`f`).reset(C):validation(this,__classPrivateFieldGet(this,$d,`f`),__classPrivateFieldGet(this,Yd,`f`)),`f`),__classPrivateFieldSet(this,Sd,__classPrivateFieldGet(this,Sd,`f`)?__classPrivateFieldGet(this,Sd,`f`).reset():command(__classPrivateFieldGet(this,$d,`f`),__classPrivateFieldGet(this,nf,`f`),__classPrivateFieldGet(this,Nd,`f`),__classPrivateFieldGet(this,Yd,`f`)),`f`),__classPrivateFieldGet(this,Td,`f`)||__classPrivateFieldSet(this,Td,completion(this,__classPrivateFieldGet(this,$d,`f`),__classPrivateFieldGet(this,Sd,`f`),__classPrivateFieldGet(this,Yd,`f`)),`f`),__classPrivateFieldGet(this,Nd,`f`).reset(),__classPrivateFieldSet(this,Ed,null,`f`),__classPrivateFieldSet(this,zd,``,`f`),__classPrivateFieldSet(this,Od,null,`f`),__classPrivateFieldSet(this,Fd,!1,`f`),this.parsed=!1,this}[Pf](n,S){return __classPrivateFieldGet(this,Yd,`f`).path.relative(n,S)}[If](n,S,C,N=0,F=!1){let I=!!C||F;n||=__classPrivateFieldGet(this,qd,`f`),__classPrivateFieldGet(this,Bd,`f`).__=__classPrivateFieldGet(this,Yd,`f`).y18n.__,__classPrivateFieldGet(this,Bd,`f`).configuration=this[uf]();let H=!!__classPrivateFieldGet(this,Bd,`f`).configuration[`populate--`],W=Object.assign({},__classPrivateFieldGet(this,Bd,`f`).configuration,{"populate--":!0}),q=__classPrivateFieldGet(this,Yd,`f`).Parser.detailed(n,Object.assign({},__classPrivateFieldGet(this,Bd,`f`),{configuration:{"parse-positional-numbers":!1,...W}})),Y=Object.assign(q.argv,__classPrivateFieldGet(this,Wd,`f`)),X,Z=q.aliases,te=!1,ne=!1;Object.keys(Y).forEach(n=>{n===__classPrivateFieldGet(this,Id,`f`)&&Y[n]?te=!0:n===__classPrivateFieldGet(this,tf,`f`)&&Y[n]&&(ne=!0)}),Y.$0=this.$0,this.parsed=q,N===0&&__classPrivateFieldGet(this,$d,`f`).clearCachedHelpMessage();try{if(this[ff](),S)return this[Nf](Y,H,!!C,!1);__classPrivateFieldGet(this,Id,`f`)&&[__classPrivateFieldGet(this,Id,`f`)].concat(Z[__classPrivateFieldGet(this,Id,`f`)]||[]).filter(n=>n.length>1).includes(``+Y._[Y._.length-1])&&(Y._.pop(),te=!0),__classPrivateFieldSet(this,Ld,!1,`f`);let W=__classPrivateFieldGet(this,Sd,`f`).getCommands(),re=__classPrivateFieldGet(this,Td,`f`)?.completionKey?[__classPrivateFieldGet(this,Td,`f`)?.completionKey,...this.getAliases()[__classPrivateFieldGet(this,Td,`f`)?.completionKey]??[]].some(n=>Object.prototype.hasOwnProperty.call(Y,n)):!1,ie=te||re||F;if(Y._.length){if(W.length){let n;for(let S=N||0,I;Y._[S]!==void 0;S++)if(I=String(Y._[S]),W.includes(I)&&I!==__classPrivateFieldGet(this,Ed,`f`)){let n=__classPrivateFieldGet(this,Sd,`f`).runCommand(I,this,q,S+1,F,te||ne||F);return this[Nf](n,H,!!C,!1)}else if(!n&&I!==__classPrivateFieldGet(this,Ed,`f`)){n=I;break}!__classPrivateFieldGet(this,Sd,`f`).hasDefaultCommand()&&__classPrivateFieldGet(this,Jd,`f`)&&n&&!ie&&__classPrivateFieldGet(this,nf,`f`).recommendCommands(n,W)}__classPrivateFieldGet(this,Ed,`f`)&&Y._.includes(__classPrivateFieldGet(this,Ed,`f`))&&!re&&(__classPrivateFieldGet(this,jd,`f`)&&setBlocking(!0),this.showCompletionScript(),this.exit(0))}if(__classPrivateFieldGet(this,Sd,`f`).hasDefaultCommand()&&!ie){let n=__classPrivateFieldGet(this,Sd,`f`).runCommand(null,this,q,0,F,te||ne||F);return this[Nf](n,H,!!C,!1)}if(re){__classPrivateFieldGet(this,jd,`f`)&&setBlocking(!0),n=[].concat(n);let S=n.slice(n.indexOf(`--${__classPrivateFieldGet(this,Td,`f`).completionKey}`)+1);return __classPrivateFieldGet(this,Td,`f`).getCompletion(S,(n,S)=>{if(n)throw new ns(n.message);(S||[]).forEach(n=>{__classPrivateFieldGet(this,Rd,`f`).log(n)}),this.exit(0)}),this[Nf](Y,!H,!!C,!1)}if(__classPrivateFieldGet(this,Fd,`f`)||(te?(__classPrivateFieldGet(this,jd,`f`)&&setBlocking(!0),I=!0,this.showHelp(n=>{__classPrivateFieldGet(this,Rd,`f`).log(n),this.exit(0)})):ne&&(__classPrivateFieldGet(this,jd,`f`)&&setBlocking(!0),I=!0,__classPrivateFieldGet(this,$d,`f`).showVersion(`log`),this.exit(0))),!I&&__classPrivateFieldGet(this,Bd,`f`).skipValidation.length>0&&(I=Object.keys(Y).some(n=>__classPrivateFieldGet(this,Bd,`f`).skipValidation.indexOf(n)>=0&&Y[n]===!0)),!I){if(q.error)throw new ns(q.error.message);if(!re){let n=this[Lf](Z,{},q.error);C||(X=applyMiddleware(Y,this,__classPrivateFieldGet(this,Nd,`f`).getMiddleware(),!0)),X=this[Cf](n,X??Y),isPromise(X)&&!C&&(X=X.then(()=>applyMiddleware(Y,this,__classPrivateFieldGet(this,Nd,`f`).getMiddleware(),!1)))}}}catch(n){if(n instanceof ns)__classPrivateFieldGet(this,$d,`f`).fail(n.message,n);else throw n}return this[Nf](X??Y,H,!!C,!0)}[Lf](n,S,C,N){let F={...this.getDemandedOptions()};return I=>{if(C)throw new ns(C.message);__classPrivateFieldGet(this,nf,`f`).nonOptionCount(I),__classPrivateFieldGet(this,nf,`f`).requiredArguments(I,F);let H=!1;__classPrivateFieldGet(this,Zd,`f`)&&(H=__classPrivateFieldGet(this,nf,`f`).unknownCommands(I)),__classPrivateFieldGet(this,Xd,`f`)&&!H?__classPrivateFieldGet(this,nf,`f`).unknownArguments(I,n,S,!!N):__classPrivateFieldGet(this,Qd,`f`)&&__classPrivateFieldGet(this,nf,`f`).unknownArguments(I,n,{},!1,!1),__classPrivateFieldGet(this,nf,`f`).limitedChoices(I),__classPrivateFieldGet(this,nf,`f`).implications(I),__classPrivateFieldGet(this,nf,`f`).conflicting(I)}}[Rf](){__classPrivateFieldSet(this,Fd,!0,`f`)}[zf](n){if(typeof n==`string`)__classPrivateFieldGet(this,Bd,`f`).key[n]=!0;else for(let S of n)__classPrivateFieldGet(this,Bd,`f`).key[S]=!0}}}),Hf,Uf=__esmMin(()=>{nd(),Vf(),Hf=YargsFactory(td)});function classifyCliFailure(n,S){return typeof n==`string`&&n.length>0?{kind:`usage`,message:n}:{kind:`runtime`}}var Wf=__esmMin(()=>{});function buildHeaders(n,S){let C={"user-agent":`gjsify-install/0.51.0`,"accept-encoding":S.acceptEncoding??`identity`};if(S.npmrc){let N=resolveAuthForUrl(n,S.npmrc);N&&(C.authorization=N)}if(S.headers)for(let[n,N]of Object.entries(S.headers))C[n.toLowerCase()]=N;return C}function resolveAuthForUrl(n,S){let C=pathPrefixes(new URL(n));for(let n of C){let C=S.authTokens[n];if(C)return`Bearer ${C}`;let N=S.basicAuth[n];if(N)return`Basic ${btoa(`${N.username}:${N.password}`)}`}return null}function pathPrefixes(n){let S=n.pathname.split(`/`).filter(Boolean),C=[];for(let N=S.length;N>=0;N--){let F=S.slice(0,N).join(`/`);C.push(F?`//${n.host}/${F}`:`//${n.host}`)}return C}var Gf=__esmMin(()=>{}),PackageNotFoundError,IntegrityError,RegistryTimeoutError,RegistryUnreachableError,Kf=__esmMin(()=>{PackageNotFoundError=class extends Error{name;url;constructor(n,S){super(`Package not found in registry: ${n} (${S})`),this.name=n,this.url=S,this.name=`PackageNotFoundError`}},IntegrityError=class extends Error{url;integrity;constructor(n,S){super(`Tarball integrity mismatch for ${n} (expected ${S})`),this.url=n,this.integrity=S,this.name=`IntegrityError`}},RegistryTimeoutError=class extends Error{url;timeoutMs;attempts;constructor(n,S,C){let N=Math.round(S/100)/10,F=Math.round(S*C/100)/10;super(`@gjsify/npm-registry: GET ${n} timed out after ${N}s × ${C} attempt(s) (total ~${F}s). This usually means the registry CDN is slow or unreachable.`),this.url=n,this.timeoutMs=S,this.attempts=C,this.name=`RegistryTimeoutError`}},RegistryUnreachableError=class extends Error{url;attempts;elapsedMs;constructor(n,S,C,N){let F=Math.round(C/100)/10,I=N instanceof Error?N.message:String(N);super(`@gjsify/npm-registry: GET ${n} failed after ${S} attempt(s) over ~${F}s: ${I}. This usually means the registry or the network dropped out.`),this.url=n,this.attempts=S,this.elapsedMs=C,this.name=`RegistryUnreachableError`,this.cause=N}}});function registryFor(n,S){if(S&&n.startsWith(`@`)){let C=n.slice(0,n.indexOf(`/`)),N=S.scopes[C];if(N)return ensureTrailingSlash$1(N)}return S?.registry?ensureTrailingSlash$1(S.registry):qf}function parseNpmrc(n){let S={registry:qf,scopes:{},authTokens:{},basicAuth:{}},C=n.split(/\r?\n/),N={};for(let n of C){let C=n.replace(/^\s+|\s+$/g,``);if(!C||C.startsWith(`#`)||C.startsWith(`;`))continue;let F=C.indexOf(`=`);if(F<0)continue;let I=C.slice(0,F).trim(),H=expandEnv(stripQuotes(C.slice(F+1).trim()));if(I===`registry`){S.registry=ensureTrailingSlash$1(H);continue}let W=I.match(/^(@[^:]+):registry$/);if(W){S.scopes[W[1]]=ensureTrailingSlash$1(H);continue}let q=I.match(/^\/\/(.+):_authToken$/);if(q){S.authTokens[normalizeAuthHost(q[1])]=H;continue}let Y=I.match(/^\/\/(.+):username$/);if(Y){(N[normalizeAuthHost(Y[1])]??={}).user=H;continue}let X=I.match(/^\/\/(.+):_password$/);if(X){let n=base64Decode$1(H);(N[normalizeAuthHost(X[1])]??={}).pass=n;continue}}for(let[n,C]of Object.entries(N))C.user&&C.pass!==void 0&&(S.basicAuth[n]={username:C.user,password:C.pass});return S}function normalizeAuthHost(n){return`//${n.replace(/\/+$/,``)}`}function ensureTrailingSlash$1(n){return n.endsWith(`/`)?n:n+`/`}function stripQuotes(n){return n.startsWith(`"`)&&n.endsWith(`"`)||n.startsWith(`'`)&&n.endsWith(`'`)?n.slice(1,-1):n}function expandEnv(n){return n.replace(/\$\{([A-Z0-9_]+)\}/gi,(n,S)=>globalThis.process?.env?.[S]??``)}function base64Decode$1(n){return atob(n)}var qf,Jf=__esmMin(()=>{qf=`https://registry.npmjs.org/`,__name$1(ensureTrailingSlash$1,`ensureTrailingSlash`),__name$1(base64Decode$1,`base64Decode`)});async function fetchWithRetry(n,S,C){let N=C.fetch??globalThis.fetch;if(!N)throw Error(`@gjsify/npm-registry: globalThis.fetch is missing`);let F=Math.max(0,C.retries??5),I=Math.max(0,C.retryDelayMs??1e3),H=Math.max(0,C.timeoutMs??3e4),W=C.retryNotFound??!1,q=Date.now(),Y=0,X,Z=0;for(;;){if(S.signal?.aborted)throw signalAbortError(S.signal);let te=H>0?new AbortController:null,ne=te===null?null:setTimeout(()=>te.abort(Error(`@gjsify/npm-registry: per-request timeout ${H}ms`)),H),re=composeSignals(S.signal,te?.signal);try{let I=await N(n,{...S,signal:re}),H=isRetryableStatus(I.status)||W&&I.status===404;if(I.ok||!H||Y>=F)return C.read?await C.read(I):I;try{await I.arrayBuffer()}catch{}X=Error(`HTTP ${I.status} ${I.statusText}`)}catch(C){let N=te!==null&&te.signal.aborted,I=S.signal?.aborted===!0;if(N&&!I){if(Z++,Y>=F)throw new RegistryTimeoutError(n,H,Z);X=C}else if(I)throw signalAbortError(S.signal);else{if(!isRetryableError(C))throw C;if(Y>=F)throw new RegistryUnreachableError(n,Y+1,Date.now()-q,C);X=C}}finally{ne!==null&&clearTimeout(ne)}let ie=Math.min(I*2**Y,8e3);C.onRetry?.({attempt:Y+1,error:X,delayMs:ie}),await delay$1(ie,S.signal),Y++}}function composeSignals(n,S){return n?S?AbortSignal.any([n,S]):n:S}function isRetryableStatus(n){return n===408||n===425||n===429||n===500||n===502||n===503||n===504||n===521||n===522||n===524||n===525}function isRetryableError(n){if(n&&typeof n==`object`&&`name`in n&&n.name===`AbortError`)return!1;if(n instanceof TypeError)return!0;if(n&&typeof n==`object`&&`name`in n){let S=n.name;if(S===`FetchError`)return!0;if(S===`AbortError`)return!1}let S=n?.cause;if(S&&typeof S==`object`&&`code`in S){let n=S.code;if(typeof n==`string`)return n===`ECONNRESET`||n===`ECONNREFUSED`||n===`ENETUNREACH`||n===`ENOTFOUND`||n===`ETIMEDOUT`||n===`EAI_AGAIN`||n===`UND_ERR_SOCKET`||n===`UND_ERR_CONNECT_TIMEOUT`}return!1}function delay$1(n,S){return n<=0?Promise.resolve():new Promise((C,N)=>{let F=setTimeout(()=>{S?.removeEventListener?.(`abort`,onAbort),C()},n),onAbort=()=>{clearTimeout(F),N(signalAbortError(S))};if(S?.aborted){clearTimeout(F),N(signalAbortError(S));return}S?.addEventListener?.(`abort`,onAbort,{once:!0})})}function signalAbortError(n){let S=n&&`reason`in n?n.reason:void 0;if(S instanceof Error)return S;let C=Error(`Aborted`);return C.name=`AbortError`,C}var Yf=__esmMin(()=>{Kf(),__name$1(delay$1,`delay`)});async function verifyIntegrity(n,S){let C=S.trim().split(/\s+/);for(let S of C){let C=S.indexOf(`-`);if(C<0)continue;let N=S.slice(0,C).toLowerCase(),F=S.slice(C+1),I=globalThis.crypto?.subtle;if(!I)throw Error(`@gjsify/npm-registry: globalThis.crypto.subtle is missing`);let H=subriToWebCryptoAlgo(N);if(!H)continue;let W=await I.digest(H,dataAsArrayBuffer(n));if(bytesToBase64(new Uint8Array(W))===F)return!0}return!1}function subriToWebCryptoAlgo(n){switch(n){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(n){if(n.byteOffset===0&&n.byteLength===n.buffer.byteLength)return n.buffer;let S=new Uint8Array(n.byteLength);return S.set(n),S.buffer}function bytesToBase64(n){let S=``;for(let C=0;C<n.length;C++)S+=String.fromCharCode(n[C]);return btoa(S)}var Xf=__esmMin(()=>{});function assertPackument(n,S){if(!S||typeof S!=`object`)throw TypeError(`registry: ${n} packument is not an object`);let C=S;if(typeof C.name!=`string`)throw TypeError(`registry: ${n} packument missing string name`);if(!C.versions||typeof C.versions!=`object`)throw TypeError(`registry: ${n} packument missing versions map`)}function packumentUrl(n,S){let C=ensureTrailingSlash$1(S);if(n.startsWith(`@`)){let S=n.indexOf(`/`);if(S<0)throw TypeError(`Invalid scoped package name: ${n}`);let N=n.slice(0,S),F=n.slice(S+1);return`${C}${encodeURIComponent(N)}/${encodeURIComponent(F)}`}return`${C}${encodeURIComponent(n)}`}async function fetchPackumentConditional(n,S={}){let C=packumentUrl(n,S.registry??registryFor(n,S.npmrc)),N=buildHeaders(C,{...S,acceptEncoding:`gzip`});N.accept??=S.fullMetadata?`application/json`:`application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*`,S.ifNoneMatch&&(N[`if-none-match`]=S.ifNoneMatch);let F=await fetchWithRetry(C,{headers:N,signal:S.signal},{fetch:S.fetch,retries:S.retries,retryDelayMs:S.retryDelayMs,timeoutMs:S.timeoutMs,onRetry:S.onRetry,read:async S=>{if(S.status===304){try{await S.arrayBuffer()}catch{}return{status:`not-modified`}}if(!S.ok)throw S.status===404||S.status===406?new PackageNotFoundError(n,C):Error(`registry GET ${C} -> ${S.status} ${S.statusText}`);return{status:`fresh`,body:await decodeJsonBody(S),etag:S.headers.get(`etag`)??void 0}}});if(F.status===`not-modified`)return{status:`not-modified`,etag:S.ifNoneMatch};let I=F.body;return assertPackument(n,I),{status:`fresh`,packument:I,etag:F.etag}}async function decodeJsonBody(n){return n.json()}async function fetchPackument(n,S={}){let C=await fetchPackumentConditional(n,S);if(!C.packument)throw Error(`registry: ${n} returned 304 Not Modified to an unconditional request`);return C.packument}var Zf=__esmMin(()=>{Gf(),Kf(),Jf(),Yf()});async function fetchTarball(n,S={}){let C=buildHeaders(n,{...S,acceptEncoding:`identity`});C.accept??=`application/octet-stream`;let N=await fetchWithRetry(n,{headers:C,signal:S.signal},{fetch:S.fetch,retries:S.retries,retryDelayMs:S.retryDelayMs,timeoutMs:S.timeoutMs,onRetry:S.onRetry,retryNotFound:S.retryNotFound??!0,read:async S=>{if(!S.ok)throw Error(`tarball GET ${n} -> ${S.status} ${S.statusText}`);return new Uint8Array(await S.arrayBuffer())}});if(S.integrity&&!await verifyIntegrity(N,S.integrity))throw new IntegrityError(n,S.integrity);return N}var Qf=__esmMin(()=>{Gf(),Kf(),Yf(),Xf()});async function whoami(n,S){let C=`${ensureTrailingSlash$1(n)}-/whoami`,N=buildHeaders(C,{npmrc:S});N.accept=`application/json`;let F=globalThis.fetch;if(!F)throw Error(`@gjsify/npm-registry: globalThis.fetch is missing`);let I=await F(C,{method:`GET`,headers:N});if(!I.ok)throw Error(`whoami GET ${C} -> ${I.status} ${I.statusText}`);let H=await I.json();if(H&&typeof H==`object`&&`username`in H){let n=H.username;if(typeof n==`string`&&n.length>0)return{username:n}}return{}}var $f=__esmMin(()=>{Gf(),Jf()}),ep=__esmMin(()=>{Gf(),Jf(),Zf(),Qf(),$f()});function escapePackageName(n){return n.replace(`/`,`%2f`)}function buildPublishHeaders(n,S){let C=buildHeaders(n,{npmrc:S.npmrc});return C[`content-type`]=`application/json`,C[`npm-command`]=`publish`,C[`npm-auth-type`]=S.otp?`legacy`:`web`,C[`user-agent`]=S.userAgent??defaultUserAgent(),S.otp&&(C[`npm-otp`]=S.otp),S.authorization&&(C.authorization=S.authorization),C}function cliVersion(){return tp===void 0&&(tp=`0.51.0`),tp}function cliPackageDir(){let n=globalThis.process?.env?.GJSIFY_CLI_PACKAGE_JSON,S;try{S=Ps(n||fileURLToPath(import.meta.url))}catch{return null}for(let n=0;n<12;n++){try{if(JSON.parse(readFileSync(`${S}/package.json`,`utf8`)).name===`@gjsify/cli`)return S}catch{}let n=Ps(S);if(n===S)break;S=n}return null}function defaultUserAgent(){let n=globalThis.process,S=n?.arch??`x64`,C=n?.platform??`linux`;return`gjsify-publish/${cliVersion()} (${C} ${S})`}var tp,np=__esmMin(()=>{Vl(),Hs(),gn(),ep()}),rp,ip=__esmMin(()=>{rp=`gjsify`}),ap=__commonJSMin(((n,S)=>{let C=(Hs(),__toCommonJS(Es)),N=(gs(),__toCommonJS(fs)),F=(Vl(),__toCommonJS(Rl)),resolveFrom=(n,S,I)=>{if(typeof n!=`string`)throw TypeError(`Expected \`fromDir\` to be of type \`string\`, got \`${typeof n}\``);if(typeof S!=`string`)throw TypeError(`Expected \`moduleId\` to be of type \`string\`, got \`${typeof S}\``);try{n=F.realpathSync(n)}catch(S){if(S.code===`ENOENT`)n=C.resolve(n);else if(I)return null;else throw S}let H=C.join(n,`noop.js`),resolveFileName=()=>N._resolveFilename(S,{id:H,filename:H,paths:N._nodeModulePaths(n)});if(I)try{return resolveFileName()}catch{return null}return resolveFileName()};S.exports=(n,S)=>resolveFrom(n,S),S.exports.silent=(n,S)=>resolveFrom(n,S,!0)})),op=__commonJSMin(((n,S)=>{let callsites=()=>{let n=Error.prepareStackTrace;Error.prepareStackTrace=(n,S)=>S;let S=Error().stack.slice(1);return Error.prepareStackTrace=n,S};S.exports=callsites,S.exports.default=callsites})),sp=__commonJSMin(((n,S)=>{let C=op();S.exports=n=>{let S=C();if(!n)return S[2].getFileName();let N=!1;S.shift();for(let C of S){let S=C.getFileName();if(typeof S==`string`){if(S===n){N=!0;continue}if(S!==`module.js`&&N&&S!==n)return S}}}})),lp=__commonJSMin(((n,S)=>{var{__gjsifyModuleDir:C,__gjsifyModuleFile:N}=(Ks(),__toCommonJS(Us)),F=C(`import-fresh/index.js`),I=N(`import-fresh/index.js`);let H=(Hs(),__toCommonJS(Es)),W=ap(),q=sp();S.exports=n=>{if(typeof n!=`string`)throw TypeError(`Expected a string`);let S=q(I),C=S?H.dirname(S):F,N=W(C,n),Y=X.cache[N];if(Y&&Y.parent){let n=Y.parent.children.length;for(;n--;)Y.parent.children[n].id===N&&Y.parent.children.splice(n,1)}delete X.cache[N];let Z=X.cache[S];return Z===void 0||Z.require===void 0?X(N):Z.require(N)}})),up=__commonJSMin(((n,S)=>{S.exports=function isArrayish(n){return n?n instanceof Array||Array.isArray(n)||n.length>=0&&n.splice instanceof Function:!1}})),dp=__commonJSMin(((n,S)=>{var C=(Ac(),__toCommonJS(Ec)),N=up(),F=function errorEx(n,S){(!n||n.constructor!==String)&&(S=n||{},n=Error.name);var F=function ErrorEXError(C){if(!this)return new ErrorEXError(C);C=C instanceof Error?C.message:C||this.message,Error.call(this,C),Error.captureStackTrace(this,F),this.name=n,Object.defineProperty(this,"message",{configurable:!0,enumerable:!1,get:function(){var n=C.split(/\r?\n/g);for(var F in S)if(S.hasOwnProperty(F)){var I=S[F];`message`in I&&(n=I.message(this[F],n)||n,N(n)||(n=[n]))}return n.join(`
122
+ `,`f`),__classPrivateFieldSet(this,zd,__classPrivateFieldGet(this,zd,`f`)+n.join(` `),`f`)}}}[of](n){objectKeys(__classPrivateFieldGet(this,Bd,`f`)).forEach(S=>{if((n=>n===`configObjects`)(S))return;let C=__classPrivateFieldGet(this,Bd,`f`)[S];Array.isArray(C)?C.includes(n)&&C.splice(C.indexOf(n),1):typeof C==`object`&&delete C[n]}),delete __classPrivateFieldGet(this,$d,`f`).getDescriptions()[n]}[sf](n,S,C){__classPrivateFieldGet(this,Ad,`f`)[C]||(__classPrivateFieldGet(this,Yd,`f`).process.emitWarning(n,S),__classPrivateFieldGet(this,Ad,`f`)[C]=!0)}[cf](){__classPrivateFieldGet(this,Md,`f`).push({options:__classPrivateFieldGet(this,Bd,`f`),configObjects:__classPrivateFieldGet(this,Bd,`f`).configObjects.slice(0),exitProcess:__classPrivateFieldGet(this,jd,`f`),groups:__classPrivateFieldGet(this,Pd,`f`),strict:__classPrivateFieldGet(this,Xd,`f`),strictCommands:__classPrivateFieldGet(this,Zd,`f`),strictOptions:__classPrivateFieldGet(this,Qd,`f`),completionCommand:__classPrivateFieldGet(this,Ed,`f`),output:__classPrivateFieldGet(this,zd,`f`),exitError:__classPrivateFieldGet(this,Od,`f`),hasOutput:__classPrivateFieldGet(this,Fd,`f`),parsed:this.parsed,parseFn:__classPrivateFieldGet(this,Ud,`f`),parseContext:__classPrivateFieldGet(this,Wd,`f`)}),__classPrivateFieldGet(this,$d,`f`).freeze(),__classPrivateFieldGet(this,nf,`f`).freeze(),__classPrivateFieldGet(this,Sd,`f`).freeze(),__classPrivateFieldGet(this,Nd,`f`).freeze()}[lf](){let n=``,S;return S=/\b(node|iojs|electron)(\.exe)?$/.test(__classPrivateFieldGet(this,Yd,`f`).process.argv()[0])?__classPrivateFieldGet(this,Yd,`f`).process.argv().slice(1,2):__classPrivateFieldGet(this,Yd,`f`).process.argv().slice(0,1),n=S.map(n=>{let S=this[Pf](__classPrivateFieldGet(this,Cd,`f`),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&S.length<n.length?S:n}).join(` `).trim(),__classPrivateFieldGet(this,Yd,`f`).getEnv(`_`)&&__classPrivateFieldGet(this,Yd,`f`).getProcessArgvBin()===__classPrivateFieldGet(this,Yd,`f`).getEnv(`_`)&&(n=__classPrivateFieldGet(this,Yd,`f`).getEnv(`_`).replace(`${__classPrivateFieldGet(this,Yd,`f`).path.dirname(__classPrivateFieldGet(this,Yd,`f`).process.execPath())}/`,``)),n}[uf](){return __classPrivateFieldGet(this,Hd,`f`)}[df](){return __classPrivateFieldGet(this,ef,`f`)}[ff](){if(!__classPrivateFieldGet(this,kd,`f`))return;let n=__classPrivateFieldGet(this,Yd,`f`).getEnv(`LC_ALL`)||__classPrivateFieldGet(this,Yd,`f`).getEnv(`LC_MESSAGES`)||__classPrivateFieldGet(this,Yd,`f`).getEnv(`LANG`)||__classPrivateFieldGet(this,Yd,`f`).getEnv(`LANGUAGE`)||`en_US`;this.locale(n.replace(/[.:].*/,``))}[pf](){return this[hf]().version||`unknown`}[mf](n){let S=n[`--`]?n[`--`]:n._;for(let n=0,C;(C=S[n])!==void 0;n++)__classPrivateFieldGet(this,Yd,`f`).Parser.looksLikeNumber(C)&&Number.isSafeInteger(Math.floor(parseFloat(`${C}`)))&&(S[n]=Number(C));return n}[hf](n){let S=n||`*`;if(__classPrivateFieldGet(this,Gd,`f`)[S])return __classPrivateFieldGet(this,Gd,`f`)[S];let C={};try{let S=n||__classPrivateFieldGet(this,Yd,`f`).mainFilename;__classPrivateFieldGet(this,Yd,`f`).path.extname(S)&&(S=__classPrivateFieldGet(this,Yd,`f`).path.dirname(S));let N=__classPrivateFieldGet(this,Yd,`f`).findUp(S,(n,S)=>{if(S.includes(`package.json`))return`package.json`});assertNotStrictEqual(N,void 0,__classPrivateFieldGet(this,Yd,`f`)),C=JSON.parse(__classPrivateFieldGet(this,Yd,`f`).readFileSync(N,`utf8`))}catch{}return __classPrivateFieldGet(this,Gd,`f`)[S]=C||{},__classPrivateFieldGet(this,Gd,`f`)[S]}[gf](n,S){S=[].concat(S),S.forEach(S=>{S=this[bf](S),__classPrivateFieldGet(this,Bd,`f`)[n].push(S)})}[_f](n,S,C,N){this[yf](n,S,C,N,(n,S,C)=>{__classPrivateFieldGet(this,Bd,`f`)[n][S]=C})}[vf](n,S,C,N){this[yf](n,S,C,N,(n,S,C)=>{__classPrivateFieldGet(this,Bd,`f`)[n][S]=(__classPrivateFieldGet(this,Bd,`f`)[n][S]||[]).concat(C)})}[yf](n,S,C,N,F){if(Array.isArray(C))C.forEach(S=>{n(S,N)});else if((n=>typeof n==`object`)(C))for(let S of objectKeys(C))n(S,C[S]);else F(S,this[bf](C),N)}[bf](n){return n===`__proto__`?`___proto___`:n}[xf](n,S){return this[_f](this[xf].bind(this),`key`,n,S),this}[Sf](){var n,S,C,N,F,I,H,W,q,Y,X,Z;let te=__classPrivateFieldGet(this,Md,`f`).pop();assertNotStrictEqual(te,void 0,__classPrivateFieldGet(this,Yd,`f`));let ne;n=this,S=this,C=this,N=this,F=this,I=this,H=this,W=this,q=this,Y=this,X=this,Z=this,{options:{set value(S){__classPrivateFieldSet(n,Bd,S,`f`)}}.value,configObjects:ne,exitProcess:{set value(n){__classPrivateFieldSet(S,jd,n,`f`)}}.value,groups:{set value(n){__classPrivateFieldSet(C,Pd,n,`f`)}}.value,output:{set value(n){__classPrivateFieldSet(N,zd,n,`f`)}}.value,exitError:{set value(n){__classPrivateFieldSet(F,Od,n,`f`)}}.value,hasOutput:{set value(n){__classPrivateFieldSet(I,Fd,n,`f`)}}.value,parsed:this.parsed,strict:{set value(n){__classPrivateFieldSet(H,Xd,n,`f`)}}.value,strictCommands:{set value(n){__classPrivateFieldSet(W,Zd,n,`f`)}}.value,strictOptions:{set value(n){__classPrivateFieldSet(q,Qd,n,`f`)}}.value,completionCommand:{set value(n){__classPrivateFieldSet(Y,Ed,n,`f`)}}.value,parseFn:{set value(n){__classPrivateFieldSet(X,Ud,n,`f`)}}.value,parseContext:{set value(n){__classPrivateFieldSet(Z,Wd,n,`f`)}}.value}=te,__classPrivateFieldGet(this,Bd,`f`).configObjects=ne,__classPrivateFieldGet(this,$d,`f`).unfreeze(),__classPrivateFieldGet(this,nf,`f`).unfreeze(),__classPrivateFieldGet(this,Sd,`f`).unfreeze(),__classPrivateFieldGet(this,Nd,`f`).unfreeze()}[Cf](n,S){return maybeAsyncResult(S,S=>(n(S),S))}getInternalMethods(){return{getCommandInstance:this[wf].bind(this),getContext:this[Tf].bind(this),getHasOutput:this[Ef].bind(this),getLoggerInstance:this[Df].bind(this),getParseContext:this[Of].bind(this),getParserConfiguration:this[uf].bind(this),getUsageConfiguration:this[df].bind(this),getUsageInstance:this[kf].bind(this),getValidationInstance:this[Af].bind(this),hasParseCallback:this[jf].bind(this),isGlobalContext:this[Mf].bind(this),postProcess:this[Nf].bind(this),reset:this[Ff].bind(this),runValidation:this[Lf].bind(this),runYargsParserAndExecuteCommands:this[If].bind(this),setHasOutput:this[Rf].bind(this)}}[wf](){return __classPrivateFieldGet(this,Sd,`f`)}[Tf](){return __classPrivateFieldGet(this,wd,`f`)}[Ef](){return __classPrivateFieldGet(this,Fd,`f`)}[Df](){return __classPrivateFieldGet(this,Rd,`f`)}[Of](){return __classPrivateFieldGet(this,Wd,`f`)||{}}[kf](){return __classPrivateFieldGet(this,$d,`f`)}[Af](){return __classPrivateFieldGet(this,nf,`f`)}[jf](){return!!__classPrivateFieldGet(this,Ud,`f`)}[Mf](){return __classPrivateFieldGet(this,Ld,`f`)}[Nf](n,S,C,N){return C||isPromise(n)?n:(S||(n=this[rf](n)),(this[uf]()[`parse-positional-numbers`]||this[uf]()[`parse-positional-numbers`]===void 0)&&(n=this[mf](n)),N&&(n=applyMiddleware(n,this,__classPrivateFieldGet(this,Nd,`f`).getMiddleware(),!1)),n)}[Ff](n={}){__classPrivateFieldSet(this,Bd,__classPrivateFieldGet(this,Bd,`f`)||{},`f`);let S={};S.local=__classPrivateFieldGet(this,Bd,`f`).local||[],S.configObjects=__classPrivateFieldGet(this,Bd,`f`).configObjects||[];let C={};return S.local.forEach(S=>{C[S]=!0,(n[S]||[]).forEach(n=>{C[n]=!0})}),Object.assign(__classPrivateFieldGet(this,Kd,`f`),Object.keys(__classPrivateFieldGet(this,Pd,`f`)).reduce((n,S)=>{let N=__classPrivateFieldGet(this,Pd,`f`)[S].filter(n=>!(n in C));return N.length>0&&(n[S]=N),n},{})),__classPrivateFieldSet(this,Pd,{},`f`),[`array`,`boolean`,`string`,`skipValidation`,`count`,`normalize`,`number`,`hiddenOptions`].forEach(n=>{S[n]=(__classPrivateFieldGet(this,Bd,`f`)[n]||[]).filter(n=>!C[n])}),[`narg`,`key`,`alias`,`default`,`defaultDescription`,`config`,`choices`,`demandedOptions`,`demandedCommands`,`deprecatedOptions`].forEach(n=>{S[n]=objFilter(__classPrivateFieldGet(this,Bd,`f`)[n],n=>!C[n])}),S.envPrefix=__classPrivateFieldGet(this,Bd,`f`).envPrefix,__classPrivateFieldSet(this,Bd,S,`f`),__classPrivateFieldSet(this,$d,__classPrivateFieldGet(this,$d,`f`)?__classPrivateFieldGet(this,$d,`f`).reset(C):usage(this,__classPrivateFieldGet(this,Yd,`f`)),`f`),__classPrivateFieldSet(this,nf,__classPrivateFieldGet(this,nf,`f`)?__classPrivateFieldGet(this,nf,`f`).reset(C):validation(this,__classPrivateFieldGet(this,$d,`f`),__classPrivateFieldGet(this,Yd,`f`)),`f`),__classPrivateFieldSet(this,Sd,__classPrivateFieldGet(this,Sd,`f`)?__classPrivateFieldGet(this,Sd,`f`).reset():command(__classPrivateFieldGet(this,$d,`f`),__classPrivateFieldGet(this,nf,`f`),__classPrivateFieldGet(this,Nd,`f`),__classPrivateFieldGet(this,Yd,`f`)),`f`),__classPrivateFieldGet(this,Td,`f`)||__classPrivateFieldSet(this,Td,completion(this,__classPrivateFieldGet(this,$d,`f`),__classPrivateFieldGet(this,Sd,`f`),__classPrivateFieldGet(this,Yd,`f`)),`f`),__classPrivateFieldGet(this,Nd,`f`).reset(),__classPrivateFieldSet(this,Ed,null,`f`),__classPrivateFieldSet(this,zd,``,`f`),__classPrivateFieldSet(this,Od,null,`f`),__classPrivateFieldSet(this,Fd,!1,`f`),this.parsed=!1,this}[Pf](n,S){return __classPrivateFieldGet(this,Yd,`f`).path.relative(n,S)}[If](n,S,C,N=0,F=!1){let I=!!C||F;n||=__classPrivateFieldGet(this,qd,`f`),__classPrivateFieldGet(this,Bd,`f`).__=__classPrivateFieldGet(this,Yd,`f`).y18n.__,__classPrivateFieldGet(this,Bd,`f`).configuration=this[uf]();let H=!!__classPrivateFieldGet(this,Bd,`f`).configuration[`populate--`],W=Object.assign({},__classPrivateFieldGet(this,Bd,`f`).configuration,{"populate--":!0}),q=__classPrivateFieldGet(this,Yd,`f`).Parser.detailed(n,Object.assign({},__classPrivateFieldGet(this,Bd,`f`),{configuration:{"parse-positional-numbers":!1,...W}})),Y=Object.assign(q.argv,__classPrivateFieldGet(this,Wd,`f`)),X,Z=q.aliases,te=!1,ne=!1;Object.keys(Y).forEach(n=>{n===__classPrivateFieldGet(this,Id,`f`)&&Y[n]?te=!0:n===__classPrivateFieldGet(this,tf,`f`)&&Y[n]&&(ne=!0)}),Y.$0=this.$0,this.parsed=q,N===0&&__classPrivateFieldGet(this,$d,`f`).clearCachedHelpMessage();try{if(this[ff](),S)return this[Nf](Y,H,!!C,!1);__classPrivateFieldGet(this,Id,`f`)&&[__classPrivateFieldGet(this,Id,`f`)].concat(Z[__classPrivateFieldGet(this,Id,`f`)]||[]).filter(n=>n.length>1).includes(``+Y._[Y._.length-1])&&(Y._.pop(),te=!0),__classPrivateFieldSet(this,Ld,!1,`f`);let W=__classPrivateFieldGet(this,Sd,`f`).getCommands(),re=__classPrivateFieldGet(this,Td,`f`)?.completionKey?[__classPrivateFieldGet(this,Td,`f`)?.completionKey,...this.getAliases()[__classPrivateFieldGet(this,Td,`f`)?.completionKey]??[]].some(n=>Object.prototype.hasOwnProperty.call(Y,n)):!1,ie=te||re||F;if(Y._.length){if(W.length){let n;for(let S=N||0,I;Y._[S]!==void 0;S++)if(I=String(Y._[S]),W.includes(I)&&I!==__classPrivateFieldGet(this,Ed,`f`)){let n=__classPrivateFieldGet(this,Sd,`f`).runCommand(I,this,q,S+1,F,te||ne||F);return this[Nf](n,H,!!C,!1)}else if(!n&&I!==__classPrivateFieldGet(this,Ed,`f`)){n=I;break}!__classPrivateFieldGet(this,Sd,`f`).hasDefaultCommand()&&__classPrivateFieldGet(this,Jd,`f`)&&n&&!ie&&__classPrivateFieldGet(this,nf,`f`).recommendCommands(n,W)}__classPrivateFieldGet(this,Ed,`f`)&&Y._.includes(__classPrivateFieldGet(this,Ed,`f`))&&!re&&(__classPrivateFieldGet(this,jd,`f`)&&setBlocking(!0),this.showCompletionScript(),this.exit(0))}if(__classPrivateFieldGet(this,Sd,`f`).hasDefaultCommand()&&!ie){let n=__classPrivateFieldGet(this,Sd,`f`).runCommand(null,this,q,0,F,te||ne||F);return this[Nf](n,H,!!C,!1)}if(re){__classPrivateFieldGet(this,jd,`f`)&&setBlocking(!0),n=[].concat(n);let S=n.slice(n.indexOf(`--${__classPrivateFieldGet(this,Td,`f`).completionKey}`)+1);return __classPrivateFieldGet(this,Td,`f`).getCompletion(S,(n,S)=>{if(n)throw new ns(n.message);(S||[]).forEach(n=>{__classPrivateFieldGet(this,Rd,`f`).log(n)}),this.exit(0)}),this[Nf](Y,!H,!!C,!1)}if(__classPrivateFieldGet(this,Fd,`f`)||(te?(__classPrivateFieldGet(this,jd,`f`)&&setBlocking(!0),I=!0,this.showHelp(n=>{__classPrivateFieldGet(this,Rd,`f`).log(n),this.exit(0)})):ne&&(__classPrivateFieldGet(this,jd,`f`)&&setBlocking(!0),I=!0,__classPrivateFieldGet(this,$d,`f`).showVersion(`log`),this.exit(0))),!I&&__classPrivateFieldGet(this,Bd,`f`).skipValidation.length>0&&(I=Object.keys(Y).some(n=>__classPrivateFieldGet(this,Bd,`f`).skipValidation.indexOf(n)>=0&&Y[n]===!0)),!I){if(q.error)throw new ns(q.error.message);if(!re){let n=this[Lf](Z,{},q.error);C||(X=applyMiddleware(Y,this,__classPrivateFieldGet(this,Nd,`f`).getMiddleware(),!0)),X=this[Cf](n,X??Y),isPromise(X)&&!C&&(X=X.then(()=>applyMiddleware(Y,this,__classPrivateFieldGet(this,Nd,`f`).getMiddleware(),!1)))}}}catch(n){if(n instanceof ns)__classPrivateFieldGet(this,$d,`f`).fail(n.message,n);else throw n}return this[Nf](X??Y,H,!!C,!0)}[Lf](n,S,C,N){let F={...this.getDemandedOptions()};return I=>{if(C)throw new ns(C.message);__classPrivateFieldGet(this,nf,`f`).nonOptionCount(I),__classPrivateFieldGet(this,nf,`f`).requiredArguments(I,F);let H=!1;__classPrivateFieldGet(this,Zd,`f`)&&(H=__classPrivateFieldGet(this,nf,`f`).unknownCommands(I)),__classPrivateFieldGet(this,Xd,`f`)&&!H?__classPrivateFieldGet(this,nf,`f`).unknownArguments(I,n,S,!!N):__classPrivateFieldGet(this,Qd,`f`)&&__classPrivateFieldGet(this,nf,`f`).unknownArguments(I,n,{},!1,!1),__classPrivateFieldGet(this,nf,`f`).limitedChoices(I),__classPrivateFieldGet(this,nf,`f`).implications(I),__classPrivateFieldGet(this,nf,`f`).conflicting(I)}}[Rf](){__classPrivateFieldSet(this,Fd,!0,`f`)}[zf](n){if(typeof n==`string`)__classPrivateFieldGet(this,Bd,`f`).key[n]=!0;else for(let S of n)__classPrivateFieldGet(this,Bd,`f`).key[S]=!0}}}),Hf,Uf=__esmMin(()=>{nd(),Vf(),Hf=YargsFactory(td)});function classifyCliFailure(n,S){return typeof n==`string`&&n.length>0?{kind:`usage`,message:n}:{kind:`runtime`}}var Wf=__esmMin(()=>{});function buildHeaders(n,S){let C={"user-agent":`gjsify-install/0.51.1`,"accept-encoding":S.acceptEncoding??`identity`};if(S.npmrc){let N=resolveAuthForUrl(n,S.npmrc);N&&(C.authorization=N)}if(S.headers)for(let[n,N]of Object.entries(S.headers))C[n.toLowerCase()]=N;return C}function resolveAuthForUrl(n,S){let C=pathPrefixes(new URL(n));for(let n of C){let C=S.authTokens[n];if(C)return`Bearer ${C}`;let N=S.basicAuth[n];if(N)return`Basic ${btoa(`${N.username}:${N.password}`)}`}return null}function pathPrefixes(n){let S=n.pathname.split(`/`).filter(Boolean),C=[];for(let N=S.length;N>=0;N--){let F=S.slice(0,N).join(`/`);C.push(F?`//${n.host}/${F}`:`//${n.host}`)}return C}var Gf=__esmMin(()=>{}),PackageNotFoundError,IntegrityError,RegistryTimeoutError,RegistryUnreachableError,Kf=__esmMin(()=>{PackageNotFoundError=class extends Error{name;url;constructor(n,S){super(`Package not found in registry: ${n} (${S})`),this.name=n,this.url=S,this.name=`PackageNotFoundError`}},IntegrityError=class extends Error{url;integrity;constructor(n,S){super(`Tarball integrity mismatch for ${n} (expected ${S})`),this.url=n,this.integrity=S,this.name=`IntegrityError`}},RegistryTimeoutError=class extends Error{url;timeoutMs;attempts;constructor(n,S,C){let N=Math.round(S/100)/10,F=Math.round(S*C/100)/10;super(`@gjsify/npm-registry: GET ${n} timed out after ${N}s × ${C} attempt(s) (total ~${F}s). This usually means the registry CDN is slow or unreachable.`),this.url=n,this.timeoutMs=S,this.attempts=C,this.name=`RegistryTimeoutError`}},RegistryUnreachableError=class extends Error{url;attempts;elapsedMs;constructor(n,S,C,N){let F=Math.round(C/100)/10,I=N instanceof Error?N.message:String(N);super(`@gjsify/npm-registry: GET ${n} failed after ${S} attempt(s) over ~${F}s: ${I}. This usually means the registry or the network dropped out.`),this.url=n,this.attempts=S,this.elapsedMs=C,this.name=`RegistryUnreachableError`,this.cause=N}}});function registryFor(n,S){if(S&&n.startsWith(`@`)){let C=n.slice(0,n.indexOf(`/`)),N=S.scopes[C];if(N)return ensureTrailingSlash$1(N)}return S?.registry?ensureTrailingSlash$1(S.registry):qf}function parseNpmrc(n){let S={registry:qf,scopes:{},authTokens:{},basicAuth:{}},C=n.split(/\r?\n/),N={};for(let n of C){let C=n.replace(/^\s+|\s+$/g,``);if(!C||C.startsWith(`#`)||C.startsWith(`;`))continue;let F=C.indexOf(`=`);if(F<0)continue;let I=C.slice(0,F).trim(),H=expandEnv(stripQuotes(C.slice(F+1).trim()));if(I===`registry`){S.registry=ensureTrailingSlash$1(H);continue}let W=I.match(/^(@[^:]+):registry$/);if(W){S.scopes[W[1]]=ensureTrailingSlash$1(H);continue}let q=I.match(/^\/\/(.+):_authToken$/);if(q){S.authTokens[normalizeAuthHost(q[1])]=H;continue}let Y=I.match(/^\/\/(.+):username$/);if(Y){(N[normalizeAuthHost(Y[1])]??={}).user=H;continue}let X=I.match(/^\/\/(.+):_password$/);if(X){let n=base64Decode$1(H);(N[normalizeAuthHost(X[1])]??={}).pass=n;continue}}for(let[n,C]of Object.entries(N))C.user&&C.pass!==void 0&&(S.basicAuth[n]={username:C.user,password:C.pass});return S}function normalizeAuthHost(n){return`//${n.replace(/\/+$/,``)}`}function ensureTrailingSlash$1(n){return n.endsWith(`/`)?n:n+`/`}function stripQuotes(n){return n.startsWith(`"`)&&n.endsWith(`"`)||n.startsWith(`'`)&&n.endsWith(`'`)?n.slice(1,-1):n}function expandEnv(n){return n.replace(/\$\{([A-Z0-9_]+)\}/gi,(n,S)=>globalThis.process?.env?.[S]??``)}function base64Decode$1(n){return atob(n)}var qf,Jf=__esmMin(()=>{qf=`https://registry.npmjs.org/`,__name$1(ensureTrailingSlash$1,`ensureTrailingSlash`),__name$1(base64Decode$1,`base64Decode`)});async function fetchWithRetry(n,S,C){let N=C.fetch??globalThis.fetch;if(!N)throw Error(`@gjsify/npm-registry: globalThis.fetch is missing`);let F=Math.max(0,C.retries??5),I=Math.max(0,C.retryDelayMs??1e3),H=Math.max(0,C.timeoutMs??3e4),W=C.retryNotFound??!1,q=Date.now(),Y=0,X,Z=0;for(;;){if(S.signal?.aborted)throw signalAbortError(S.signal);let te=H>0?new AbortController:null,ne=te===null?null:setTimeout(()=>te.abort(Error(`@gjsify/npm-registry: per-request timeout ${H}ms`)),H),re=composeSignals(S.signal,te?.signal);try{let I=await N(n,{...S,signal:re}),H=isRetryableStatus(I.status)||W&&I.status===404;if(I.ok||!H||Y>=F)return C.read?await C.read(I):I;try{await I.arrayBuffer()}catch{}X=Error(`HTTP ${I.status} ${I.statusText}`)}catch(C){let N=te!==null&&te.signal.aborted,I=S.signal?.aborted===!0;if(N&&!I){if(Z++,Y>=F)throw new RegistryTimeoutError(n,H,Z);X=C}else if(I)throw signalAbortError(S.signal);else{if(!isRetryableError(C))throw C;if(Y>=F)throw new RegistryUnreachableError(n,Y+1,Date.now()-q,C);X=C}}finally{ne!==null&&clearTimeout(ne)}let ie=Math.min(I*2**Y,8e3);C.onRetry?.({attempt:Y+1,error:X,delayMs:ie}),await delay$1(ie,S.signal),Y++}}function composeSignals(n,S){return n?S?AbortSignal.any([n,S]):n:S}function isRetryableStatus(n){return n===408||n===425||n===429||n===500||n===502||n===503||n===504||n===521||n===522||n===524||n===525}function isRetryableError(n){if(n&&typeof n==`object`&&`name`in n&&n.name===`AbortError`)return!1;if(n instanceof TypeError)return!0;if(n&&typeof n==`object`&&`name`in n){let S=n.name;if(S===`FetchError`)return!0;if(S===`AbortError`)return!1}let S=n?.cause;if(S&&typeof S==`object`&&`code`in S){let n=S.code;if(typeof n==`string`)return n===`ECONNRESET`||n===`ECONNREFUSED`||n===`ENETUNREACH`||n===`ENOTFOUND`||n===`ETIMEDOUT`||n===`EAI_AGAIN`||n===`UND_ERR_SOCKET`||n===`UND_ERR_CONNECT_TIMEOUT`}return!1}function delay$1(n,S){return n<=0?Promise.resolve():new Promise((C,N)=>{let F=setTimeout(()=>{S?.removeEventListener?.(`abort`,onAbort),C()},n),onAbort=()=>{clearTimeout(F),N(signalAbortError(S))};if(S?.aborted){clearTimeout(F),N(signalAbortError(S));return}S?.addEventListener?.(`abort`,onAbort,{once:!0})})}function signalAbortError(n){let S=n&&`reason`in n?n.reason:void 0;if(S instanceof Error)return S;let C=Error(`Aborted`);return C.name=`AbortError`,C}var Yf=__esmMin(()=>{Kf(),__name$1(delay$1,`delay`)});async function verifyIntegrity(n,S){let C=S.trim().split(/\s+/);for(let S of C){let C=S.indexOf(`-`);if(C<0)continue;let N=S.slice(0,C).toLowerCase(),F=S.slice(C+1),I=globalThis.crypto?.subtle;if(!I)throw Error(`@gjsify/npm-registry: globalThis.crypto.subtle is missing`);let H=subriToWebCryptoAlgo(N);if(!H)continue;let W=await I.digest(H,dataAsArrayBuffer(n));if(bytesToBase64(new Uint8Array(W))===F)return!0}return!1}function subriToWebCryptoAlgo(n){switch(n){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(n){if(n.byteOffset===0&&n.byteLength===n.buffer.byteLength)return n.buffer;let S=new Uint8Array(n.byteLength);return S.set(n),S.buffer}function bytesToBase64(n){let S=``;for(let C=0;C<n.length;C++)S+=String.fromCharCode(n[C]);return btoa(S)}var Xf=__esmMin(()=>{});function assertPackument(n,S){if(!S||typeof S!=`object`)throw TypeError(`registry: ${n} packument is not an object`);let C=S;if(typeof C.name!=`string`)throw TypeError(`registry: ${n} packument missing string name`);if(!C.versions||typeof C.versions!=`object`)throw TypeError(`registry: ${n} packument missing versions map`)}function packumentUrl(n,S){let C=ensureTrailingSlash$1(S);if(n.startsWith(`@`)){let S=n.indexOf(`/`);if(S<0)throw TypeError(`Invalid scoped package name: ${n}`);let N=n.slice(0,S),F=n.slice(S+1);return`${C}${encodeURIComponent(N)}/${encodeURIComponent(F)}`}return`${C}${encodeURIComponent(n)}`}async function fetchPackumentConditional(n,S={}){let C=packumentUrl(n,S.registry??registryFor(n,S.npmrc)),N=buildHeaders(C,{...S,acceptEncoding:`gzip`});N.accept??=S.fullMetadata?`application/json`:`application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*`,S.ifNoneMatch&&(N[`if-none-match`]=S.ifNoneMatch);let F=await fetchWithRetry(C,{headers:N,signal:S.signal},{fetch:S.fetch,retries:S.retries,retryDelayMs:S.retryDelayMs,timeoutMs:S.timeoutMs,onRetry:S.onRetry,read:async S=>{if(S.status===304){try{await S.arrayBuffer()}catch{}return{status:`not-modified`}}if(!S.ok)throw S.status===404||S.status===406?new PackageNotFoundError(n,C):Error(`registry GET ${C} -> ${S.status} ${S.statusText}`);return{status:`fresh`,body:await decodeJsonBody(S),etag:S.headers.get(`etag`)??void 0}}});if(F.status===`not-modified`)return{status:`not-modified`,etag:S.ifNoneMatch};let I=F.body;return assertPackument(n,I),{status:`fresh`,packument:I,etag:F.etag}}async function decodeJsonBody(n){return n.json()}async function fetchPackument(n,S={}){let C=await fetchPackumentConditional(n,S);if(!C.packument)throw Error(`registry: ${n} returned 304 Not Modified to an unconditional request`);return C.packument}var Zf=__esmMin(()=>{Gf(),Kf(),Jf(),Yf()});async function fetchTarball(n,S={}){let C=buildHeaders(n,{...S,acceptEncoding:`identity`});C.accept??=`application/octet-stream`;let N=await fetchWithRetry(n,{headers:C,signal:S.signal},{fetch:S.fetch,retries:S.retries,retryDelayMs:S.retryDelayMs,timeoutMs:S.timeoutMs,onRetry:S.onRetry,retryNotFound:S.retryNotFound??!0,read:async S=>{if(!S.ok)throw Error(`tarball GET ${n} -> ${S.status} ${S.statusText}`);return new Uint8Array(await S.arrayBuffer())}});if(S.integrity&&!await verifyIntegrity(N,S.integrity))throw new IntegrityError(n,S.integrity);return N}var Qf=__esmMin(()=>{Gf(),Kf(),Yf(),Xf()});async function whoami(n,S){let C=`${ensureTrailingSlash$1(n)}-/whoami`,N=buildHeaders(C,{npmrc:S});N.accept=`application/json`;let F=globalThis.fetch;if(!F)throw Error(`@gjsify/npm-registry: globalThis.fetch is missing`);let I=await F(C,{method:`GET`,headers:N});if(!I.ok)throw Error(`whoami GET ${C} -> ${I.status} ${I.statusText}`);let H=await I.json();if(H&&typeof H==`object`&&`username`in H){let n=H.username;if(typeof n==`string`&&n.length>0)return{username:n}}return{}}var $f=__esmMin(()=>{Gf(),Jf()}),ep=__esmMin(()=>{Gf(),Jf(),Zf(),Qf(),$f()});function escapePackageName(n){return n.replace(`/`,`%2f`)}function buildPublishHeaders(n,S){let C=buildHeaders(n,{npmrc:S.npmrc});return C[`content-type`]=`application/json`,C[`npm-command`]=`publish`,C[`npm-auth-type`]=S.otp?`legacy`:`web`,C[`user-agent`]=S.userAgent??defaultUserAgent(),S.otp&&(C[`npm-otp`]=S.otp),S.authorization&&(C.authorization=S.authorization),C}function cliVersion(){return tp===void 0&&(tp=`0.51.1`),tp}function cliPackageDir(){let n=globalThis.process?.env?.GJSIFY_CLI_PACKAGE_JSON,S;try{S=Ps(n||fileURLToPath(import.meta.url))}catch{return null}for(let n=0;n<12;n++){try{if(JSON.parse(readFileSync(`${S}/package.json`,`utf8`)).name===`@gjsify/cli`)return S}catch{}let n=Ps(S);if(n===S)break;S=n}return null}function defaultUserAgent(){let n=globalThis.process,S=n?.arch??`x64`,C=n?.platform??`linux`;return`gjsify-publish/${cliVersion()} (${C} ${S})`}var tp,np=__esmMin(()=>{Vl(),Hs(),gn(),ep()}),rp,ip=__esmMin(()=>{rp=`gjsify`}),ap=__commonJSMin(((n,S)=>{let C=(Hs(),__toCommonJS(Es)),N=(gs(),__toCommonJS(fs)),F=(Vl(),__toCommonJS(Rl)),resolveFrom=(n,S,I)=>{if(typeof n!=`string`)throw TypeError(`Expected \`fromDir\` to be of type \`string\`, got \`${typeof n}\``);if(typeof S!=`string`)throw TypeError(`Expected \`moduleId\` to be of type \`string\`, got \`${typeof S}\``);try{n=F.realpathSync(n)}catch(S){if(S.code===`ENOENT`)n=C.resolve(n);else if(I)return null;else throw S}let H=C.join(n,`noop.js`),resolveFileName=()=>N._resolveFilename(S,{id:H,filename:H,paths:N._nodeModulePaths(n)});if(I)try{return resolveFileName()}catch{return null}return resolveFileName()};S.exports=(n,S)=>resolveFrom(n,S),S.exports.silent=(n,S)=>resolveFrom(n,S,!0)})),op=__commonJSMin(((n,S)=>{let callsites=()=>{let n=Error.prepareStackTrace;Error.prepareStackTrace=(n,S)=>S;let S=Error().stack.slice(1);return Error.prepareStackTrace=n,S};S.exports=callsites,S.exports.default=callsites})),sp=__commonJSMin(((n,S)=>{let C=op();S.exports=n=>{let S=C();if(!n)return S[2].getFileName();let N=!1;S.shift();for(let C of S){let S=C.getFileName();if(typeof S==`string`){if(S===n){N=!0;continue}if(S!==`module.js`&&N&&S!==n)return S}}}})),lp=__commonJSMin(((n,S)=>{var{__gjsifyModuleDir:C,__gjsifyModuleFile:N}=(Ks(),__toCommonJS(Us)),F=C(`import-fresh/index.js`),I=N(`import-fresh/index.js`);let H=(Hs(),__toCommonJS(Es)),W=ap(),q=sp();S.exports=n=>{if(typeof n!=`string`)throw TypeError(`Expected a string`);let S=q(I),C=S?H.dirname(S):F,N=W(C,n),Y=X.cache[N];if(Y&&Y.parent){let n=Y.parent.children.length;for(;n--;)Y.parent.children[n].id===N&&Y.parent.children.splice(n,1)}delete X.cache[N];let Z=X.cache[S];return Z===void 0||Z.require===void 0?X(N):Z.require(N)}})),up=__commonJSMin(((n,S)=>{S.exports=function isArrayish(n){return n?n instanceof Array||Array.isArray(n)||n.length>=0&&n.splice instanceof Function:!1}})),dp=__commonJSMin(((n,S)=>{var C=(Ac(),__toCommonJS(Ec)),N=up(),F=function errorEx(n,S){(!n||n.constructor!==String)&&(S=n||{},n=Error.name);var F=function ErrorEXError(C){if(!this)return new ErrorEXError(C);C=C instanceof Error?C.message:C||this.message,Error.call(this,C),Error.captureStackTrace(this,F),this.name=n,Object.defineProperty(this,"message",{configurable:!0,enumerable:!1,get:function(){var n=C.split(/\r?\n/g);for(var F in S)if(S.hasOwnProperty(F)){var I=S[F];`message`in I&&(n=I.message(this[F],n)||n,N(n)||(n=[n]))}return n.join(`
123
123
  `)},set:function(n){C=n}});var I=null,H=Object.getOwnPropertyDescriptor(this,`stack`),W=H.get,q=H.value;delete H.value,delete H.writable,H.set=function(n){I=n},H.get=function(){var n=(I||(W?W.call(this):q)).split(/\r?\n+/g);I||(n[0]=this.name+`: `+this.message);var C=1;for(var N in S)if(S.hasOwnProperty(N)){var F=S[N];if(`line`in F){var H=F.line(this[N]);H&&n.splice(C++,0,` `+H)}`stack`in F&&F.stack(this[N],n)}return n.join(`
124
124
  `)},Object.defineProperty(this,"stack",H)};return Object.setPrototypeOf?(Object.setPrototypeOf(F.prototype,Error.prototype),Object.setPrototypeOf(F,Error)):C.inherits(F,Error),F};F.append=function(n,S){return{message:function(C,N){return C||=S,C&&(N[0]+=` `+n.replace(`%s`,C.toString())),N}}},F.line=function(n,S){return{line:function(C){return C||=S,C?n.replace(`%s`,C.toString()):null}}},S.exports=F})),fp=__commonJSMin(((n,S)=>{let hexify=n=>{let S=n.charCodeAt(0).toString(16).toUpperCase();return`0x`+(S.length%2?`0`:``)+S},parseError=(n,S,C)=>{if(!S)return{message:n.message+` while parsing empty string`,position:0};let N=n.message.match(/^Unexpected token (.) .*position\s+(\d+)/i),F=N?+N[2]:n.message.match(/^Unexpected end of JSON.*/i)?S.length-1:null,I=N?n.message.replace(/^Unexpected token ./,`Unexpected token ${JSON.stringify(N[1])} (${hexify(N[1])})`):n.message;if(F!=null){let n=F<=C?0:F-C,N=F+C>=S.length?S.length:F+C,H=(n===0?``:`...`)+S.slice(n,N)+(N===S.length?``:`...`);return{message:I+` while parsing ${S===H?``:`near `}${JSON.stringify(H)}`,position:F}}else return{message:I+` while parsing '${S.slice(0,C*2)}'`,position:0}};var JSONParseError=class extends SyntaxError{constructor(n,S,C,N){C||=20;let F=parseError(n,S,C);super(F.message),Object.assign(this,F),this.code=`EJSONPARSE`,this.systemError=n,Error.captureStackTrace(this,N||this.constructor)}get name(){return this.constructor.name}set name(n){}get[Symbol.toStringTag](){return this.constructor.name}};let C=Symbol.for(`indent`),N=Symbol.for(`newline`),F=/^\s*[{\[]((?:\r?\n)+)([\s\t]*)/,I=/^(?:\{\}|\[\])((?:\r?\n)+)?$/,parseJson=(n,S,H)=>{let W=stripBOM(n);H||=20;try{let[,n=`
125
125
  `,H=` `]=W.match(I)||W.match(F)||[,``,``],q=JSON.parse(W,S);return q&&typeof q==`object`&&(q[N]=n,q[C]=H),q}catch(S){if(typeof n!=`string`&&!Buffer.isBuffer(n)){let C=Array.isArray(n)&&n.length===0;throw Object.assign(TypeError(`Cannot parse ${C?`an empty array`:String(n)}`),{code:`EJSONPARSE`,systemError:S})}throw new JSONParseError(S,W,H,parseJson)}},stripBOM=n=>String(n).replace(/^\uFEFF/,``);S.exports=parseJson,parseJson.JSONParseError=JSONParseError,parseJson.noExceptions=(n,S)=>{try{return JSON.parse(stripBOM(n),S)}catch{}}})),pp=__commonJSMin((n=>{n.__esModule=!0,n.LinesAndColumns=void 0;var S=`
@@ -1071,9 +1071,9 @@ $`,64,`ascii`),ae.writeUInt32LE(JL,60),ae.write(`PE\0\0`,JL,`ascii`),ae.writeUIn
1071
1071
  `)}function renderPkgInfo(){return`${fR}${pR}`}function renderEntitlements(n){return[`<?xml version="1.0" encoding="UTF-8"?>`,`<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">`,`<plist version="1.0">`,`<dict>`,n.map(n=>`\t<key>${xmlText(n)}</key>\n\t<true/>`).join(`
1072
1072
  `),`</dict>`,`</plist>`,``].join(`
1073
1073
  `)}var uR,dR,fR,pR,mR=__esmMin(()=>{uR=`Contents/Info.plist`,dR=`Contents/PkgInfo`,fR=`APPL`,pR=`????`});function darwinFontsPath(n,S){let C=`${WL.fonts}/${n.appId}`,N=S.find(n=>n.path.startsWith(`${C}/`));if(N===void 0)return;let F=gR.darwin.dirs(n);return xs.relative(F.other,xs.dirname(place(gR.darwin,n,N.path)))}function appBundleDir(n){if(hR.test(n.name))throw Error(`gjsify ship: the macOS layout would put this app in "${n.name}.app", and a bundle directory may contain no "/", "\\" or ":" — HFS+ and the Finder swap the first two, so the bundle would not be the one its own metadata names. Set \`gjsify.ship.name\` to the display name you want on disk.`);return`${n.name}.app`}function launcherPath(n,S){return xs.join(n.dirs(S).launcher,`${S.binaryName}${n.launcherExt}`)}function windowsGuiLauncherPath(n){let S=gR.windows;if(S.launcherExt.length!==4)throw Error(`gjsify ship: the windows launcher extension is "${S.launcherExt}" and the GUI stub can only reach a four-character one — it rewrites the last three characters of its own filename rather than searching for a path (\`utils/ship/pe-launcher.ts\`).`);return xs.join(S.dirs(n).launcher,`${n.binaryName}.exe`)}function windowsLaunchLogLeaf(n){return`${n.binaryName}.launch.log`}function layoutForOs(n){let S=vR.get(n);if(S===void 0)throw Error(`"${n}" is not a \`process.platform\` token this gjsify has a layout for. Known: ${_R.map(n=>gR[n].os).join(`, `)} — the \`\${process.platform}-\${process.arch}\` spelling, so \`win32\` and never \`windows\`.`);return S}function resolveLayout(n){let S=n.trim().toLowerCase();if(Object.hasOwn(gR,S))return gR[S];let C=vR.get(S);if(C!==void 0)return C;throw Error(`gjsify ship: "${n}" is not an operating system this command has a layout for. Known: ${_R.join(`, `)} (\`win32\` is accepted for \`windows\`, because that is the spelling \`--expect-target <os>-<arch>\` uses).`)}function hostLayout(n=process.platform){let S=vR.get(n);if(S===void 0)throw Error(`gjsify ship: this host is ${n}, which has no layout. Name the one you want — \`gjsify ship <${_R.join(`|`)}> --stage\` — assembly is not host-bound (ADR 0024 § A1).`);return S}function assertLayoutSupportsArch(n,S){let C=n.arches;if(!(C===null||C.only.includes(S)))throw Error(`gjsify ship: the ${n.name} layout is not assemblable for \`--arch ${S}\` — ${C.only.length===1?`the only architecture it has`:`the architectures it has`} ${C.only.length===1?`is`:`are`} ${C.only.join(`, `)}.\n ${C.why}.\n \`--arch\` names the architecture the PAYLOAD was built for and cross-compiles nothing, so there is no
1074
- flag that makes this work — the artifact would carry a runtime that does not exist.`)}function place(n,S,C){let N=n.dirs(S);if(C===`bin/${S.binaryName}`)return launcherPath(n,S);let F=`lib/${S.binaryName}/`,I=`${F}gi/`;return C.startsWith(I)?xs.join(N.native,C.slice(I.length)):C.startsWith(F)?xs.join(N.bundle,C.slice(F.length)):C.startsWith(`bin/`)?xs.join(N.launcher,C.slice(4)):C.startsWith(`share/`)?xs.join(N.data,C.slice(6)):xs.join(N.other,C)}function placeStage(n,S,C,N=[]){let F=new Map,I=[],claim=(S,C,N)=>{let H=F.get(S);if(H!==void 0)throw Error(`gjsify ship: in the ${n.name} layout both ${H} and ${C} install as ${S}. Two payload files cannot share one destination — one would silently replace the other. Rename the \`gjsify.ship.extraFiles\` destination that collides.`);F.set(S,C),I.push({...N,path:S})};for(let N of C)claim(place(n,S,N.path),N.path,N);for(let N of n.metadata(S,C))claim(N.path,`the ${n.name} layout's own metadata`,N);for(let S of N)claim(S.path,`the runtime staged into the ${n.name} artifact`,S);return I.sort((n,S)=>n.path<S.path?-1:+(n.path>S.path))}var hR,gR,_R,vR,yR=__esmMin(()=>{Hs(),lR(),mR(),GL(),hR=/[/:\\]/,gR={linux:{name:`linux`,os:`linux`,shippedRuntime:`gjs`,launcherExt:``,root:()=>``,dirs:n=>({launcher:`bin`,bundle:`lib/${n.binaryName}`,native:`lib/${n.binaryName}/gi`,data:`share`,other:``}),metadata:()=>[],arches:null},darwin:{name:`darwin`,os:`darwin`,shippedRuntime:`node`,runtimeGap:'the staged launcher execs an interpreter off `PATH`, which a downloaded `.app` cannot assume — macOS ships no Node, and there is no RELOCATABLE GJS (`build-gtk-runtime-darwin.mjs`: "GJS ships no relocation"), so ADR 0024 § 4 derives Node here. A self-contained bundle needs `@gjsify/node-runtime-darwin-<arch>` and a `--app node` payload (#1354 M0), or `@gjsify/gjs-runtime-darwin-<arch>` (ADR 0024 stage 7).',fontGap:"the faces are staged in `share/fonts/<appId>` and `Info.plist` carries `ATSApplicationFontsPath` at it, which is macOS's own per-app activation — NOT the XDG_DATA_DIRS path, because Pango on macOS is CoreText-backed and GTK is not built against fontconfig there. That the activation reaches Pango's CoreText font map is UNVERIFIED: no leg in this repository runs a `.app`. Confirm with `PangoCairo.FontMap.get_default().list_families()` in the shipped bundle, and `PANGOCAIRO_BACKEND=bogus` to print which backend it was built with. An app that calls `initFonts()` from `@gjsify/gtk-host/fonts` for the Windows row needs no branch around it: the CoreText map answers G_IO_ERROR_NOT_SUPPORTED and that call deliberately does nothing here.",launcherExt:``,root:appBundleDir,dirs:n=>{let S=appBundleDir(n);return{launcher:`${S}/Contents/MacOS`,bundle:`${S}/Contents/Resources/lib`,native:`${S}/Contents/Frameworks`,data:`${S}/Contents/Resources/share`,other:`${S}/Contents/Resources`}},metadata:(n,S)=>[{path:`${appBundleDir(n)}/${uR}`,mode:420,source:{kind:`text`,text:renderInfoPlist(n,darwinFontsPath(n,S))}},{path:`${appBundleDir(n)}/${dR}`,mode:420,source:{kind:`text`,text:renderPkgInfo()}}],arches:{only:[`x64`,`arm64`],why:"macOS runs on x86_64 and Apple silicon and nothing else, so those are the two `@gjsify/gtk-runtime-darwin-*` and `@gjsify/node-runtime-darwin-*` targets that exist"}},windows:{name:`windows`,os:`win32`,shippedRuntime:`node`,runtimeGap:"the staged launcher execs an interpreter off `PATH`, which a downloaded program directory cannot assume — Windows ships neither, and there is NO GJS host on Windows at all (ADR 0024 § 4), so § 4 derives Node here. A self-contained directory needs `@gjsify/node-runtime-win32-x64` and a `--app node` payload (#1354 M3).",fontGap:"the faces are staged in `share/fonts/<appId>` and the launcher exports GJSIFY_FONT_DIR at it, but WINDOWS HAS NO DECLARATIVE FONT ACTIVATION and nothing here reaches a bundled face on its own: GTK4 uses pangowin32, whose font map is populated from DirectWrite and never from fontconfig or from GDI. MEASURED on Windows 11 / GTK 4.22.4 rather than inferred (ADR 0038 W1-W5): a FONTCONFIG_FILE naming the staged directory moves the default font map by nothing even when it is the ONLY configuration present — that map does not read fontconfig, and exposes no config_changed or set_config with which to make it — while add_font_file on the same map a Gtk.Label renders through does register the family. So register them at startup, with one call from the GTK host layer: `import { initFonts } from '@gjsify/gtk-host/fonts'`, then `initFonts()` before the first window — it reads GJSIFY_FONT_DIR itself, registers every face it holds, and no-ops on the operating systems that already activated them. Without it the app renders in a substituted family with no error.",launcherExt:`.cmd`,root:()=>``,dirs:()=>({launcher:``,bundle:`app`,native:`lib`,data:`share`,other:``}),metadata:n=>n.arch===`x64`?[{path:windowsGuiLauncherPath(n),mode:493,source:{kind:`bytes`,data:buildGuiLauncher({logLeaf:windowsLaunchLogLeaf(n)})}}]:[],arches:{only:[`x64`],why:'gvsbuild publishes no arm64 GTK (it hardcodes `self.platform = "x64"`), so there is nothing to build `@gjsify/gtk-runtime-win32-arm64` out of and no GTK for a Windows/ARM artifact to load — the blocker is upstream and is tracked in gjsify/gjsify#1117'}}},_R=Object.keys(gR),vR=new Map(_R.map(n=>[gR[n].os,gR[n]]))});async function compileSchemasForStage(n){if(n.schemaFiles.length===0)return[];rmSync(n.workDir,{recursive:!0,force:!0,maxRetries:5}),mkdirSync(n.workDir,{recursive:!0});for(let S of n.schemaFiles)copyFileSync(S,js(n.workDir,Fs(S)));try{await bR(xR,[`--strict`,`--targetdir=${n.workDir}`,n.workDir])}catch(n){let S=n;throw S.code===`ENOENT`?Error(`gjsify ship: this layout has no install step, so \`${xR}\` has to run HERE to turn the payload's schemas into \`${CR}\` — and it is not on PATH. Install it (${SR}). Without the compiled cache the launcher points XDG_DATA_DIRS at a schema directory GSettings aborts on, so the bundle would build and then die at its first \`Gio.Settings.new()\`.`):Error(`gjsify ship: \`${xR} --strict\` refused this project's schemas.\n${(S.stderr??``).trimEnd()}\n \`--strict\` is deliberate: without it a malformed schema is SKIPPED at exit 0 and a cache
1074
+ flag that makes this work — the artifact would carry a runtime that does not exist.`)}function place(n,S,C){let N=n.dirs(S);if(C===`bin/${S.binaryName}`)return launcherPath(n,S);let F=`lib/${S.binaryName}/`,I=`${F}gi/`;return C.startsWith(I)?xs.join(N.native,C.slice(I.length)):C.startsWith(F)?xs.join(N.bundle,C.slice(F.length)):C.startsWith(`bin/`)?xs.join(N.launcher,C.slice(4)):C.startsWith(`share/`)?xs.join(N.data,C.slice(6)):xs.join(N.other,C)}function placeStage(n,S,C,N=[]){let F=new Map,I=[],claim=(S,C,N)=>{let H=F.get(S);if(H!==void 0)throw Error(`gjsify ship: in the ${n.name} layout both ${H} and ${C} install as ${S}. Two payload files cannot share one destination — one would silently replace the other. Rename the \`gjsify.ship.extraFiles\` destination that collides.`);F.set(S,C),I.push({...N,path:S})};for(let N of C)claim(place(n,S,N.path),N.path,N);for(let N of n.metadata(S,C))claim(N.path,`the ${n.name} layout's own metadata`,N);for(let S of N)claim(S.path,`the runtime staged into the ${n.name} artifact`,S);return I.sort((n,S)=>n.path<S.path?-1:+(n.path>S.path))}var hR,gR,_R,vR,yR=__esmMin(()=>{Hs(),lR(),mR(),GL(),hR=/[/:\\]/,gR={linux:{name:`linux`,os:`linux`,shippedRuntime:`gjs`,launcherExt:``,root:()=>``,dirs:n=>({launcher:`bin`,bundle:`lib/${n.binaryName}`,native:`lib/${n.binaryName}/gi`,data:`share`,other:``}),metadata:()=>[],arches:null},darwin:{name:`darwin`,os:`darwin`,shippedRuntime:`node`,runtimeGap:'the staged launcher execs an interpreter off `PATH`, which a downloaded `.app` cannot assume — macOS ships no Node, and there is no RELOCATABLE GJS (`build-gtk-runtime-darwin.mjs`: "GJS ships no relocation"), so ADR 0024 § 4 derives Node here. A self-contained bundle needs `@gjsify/node-runtime-darwin-<arch>` and a `--app node` payload (#1354 M0), or `@gjsify/gjs-runtime-darwin-<arch>` (ADR 0024 stage 7).',fontGap:"the faces are staged in `share/fonts/<appId>` and `Info.plist` carries `ATSApplicationFontsPath` at it, which is macOS's own per-app activation — NOT the XDG_DATA_DIRS path, because Pango on macOS is CoreText-backed and GTK is not built against fontconfig there. That the activation reaches Pango's CoreText font map is UNVERIFIED: no leg in this repository runs a `.app`. Confirm with `PangoCairo.FontMap.get_default().list_families()` in the shipped bundle, and `PANGOCAIRO_BACKEND=bogus` to print which backend it was built with. An app that calls `initFonts()` from `@gjsify/gtk-host/fonts` for the Windows row needs no branch around it: the CoreText map answers G_IO_ERROR_NOT_SUPPORTED and that call deliberately does nothing here.",launcherExt:``,root:appBundleDir,dirs:n=>{let S=appBundleDir(n);return{launcher:`${S}/Contents/MacOS`,bundle:`${S}/Contents/Resources/lib`,native:`${S}/Contents/Frameworks`,data:`${S}/Contents/Resources/share`,other:`${S}/Contents/Resources`}},metadata:(n,S)=>[{path:`${appBundleDir(n)}/${uR}`,mode:420,source:{kind:`text`,text:renderInfoPlist(n,darwinFontsPath(n,S))}},{path:`${appBundleDir(n)}/${dR}`,mode:420,source:{kind:`text`,text:renderPkgInfo()}}],arches:{only:[`x64`,`arm64`],why:"macOS runs on x86_64 and Apple silicon and nothing else, so those are the two `@gjsify/gtk-runtime-darwin-*` and `@gjsify/node-runtime-darwin-*` targets that exist"}},windows:{name:`windows`,os:`win32`,shippedRuntime:`node`,runtimeGap:"the staged launcher execs an interpreter off `PATH`, which a downloaded program directory cannot assume — Windows ships neither, and there is NO GJS host on Windows at all (ADR 0024 § 4), so § 4 derives Node here. A self-contained directory needs `@gjsify/node-runtime-win32-x64` and a `--app node` payload (#1354 M3).",fontGap:"the faces are staged in `share/fonts/<appId>` and the launcher exports GJSIFY_FONT_DIR at it, but WINDOWS HAS NO DECLARATIVE FONT ACTIVATION and nothing here reaches a bundled face on its own: GTK4 uses pangowin32, whose font map is populated from DirectWrite and never from fontconfig or from GDI. MEASURED on Windows 11 / GTK 4.22.4 rather than inferred (ADR 0038 W1-W5): a FONTCONFIG_FILE naming the staged directory moves the default font map by nothing even when it is the ONLY configuration present — that map does not read fontconfig, and exposes no config_changed or set_config with which to make it — while add_font_file on the same map a Gtk.Label renders through does register the family. So register them at startup, with one call from the GTK host layer: `import { initFonts } from '@gjsify/gtk-host/fonts'`, then `initFonts()` before the first window — it reads GJSIFY_FONT_DIR itself, registers every face it holds, and no-ops on the operating systems that already activated them. Without it the app renders in a substituted family with no error.",launcherExt:`.cmd`,root:()=>``,dirs:()=>({launcher:``,bundle:`app`,native:`lib`,data:`share`,other:``}),metadata:n=>n.arch===`x64`?[{path:windowsGuiLauncherPath(n),mode:493,source:{kind:`bytes`,data:buildGuiLauncher({logLeaf:windowsLaunchLogLeaf(n)})}}]:[],arches:{only:[`x64`],why:'gvsbuild publishes no arm64 GTK (it hardcodes `self.platform = "x64"`), so there is nothing to build `@gjsify/gtk-runtime-win32-arm64` out of and no GTK for a Windows/ARM artifact to load — the blocker is upstream and is tracked in gjsify/gjsify#1117'}}},_R=Object.keys(gR),vR=new Map(_R.map(n=>[gR[n].os,gR[n]]))});async function compileSchemasForStage(n){if(n.schemaFiles.length===0)return[];rmSync(n.workDir,{recursive:!0,force:!0,maxRetries:5}),mkdirSync(n.workDir,{recursive:!0});for(let S of n.schemaFiles)copyFileSync(S,js(n.workDir,Fs(S)));return await runSchemaCompiler(n.workDir),[{path:CR,mode:420,source:{kind:`file`,path:js(n.workDir,`gschemas.compiled`)}}]}async function compileSchemasForPayload(n){let S=n.payload.filter(n=>isSchemaSource(n.path));if(S.length!==0){rmSync(n.workDir,{recursive:!0,force:!0,maxRetries:5}),mkdirSync(n.workDir,{recursive:!0});for(let C of S)writeFileSync(js(n.workDir,xs.basename(C.path)),C.data);return await runSchemaCompiler(n.workDir),{path:CR,mode:420,data:readFileSync(js(n.workDir,`gschemas.compiled`))}}}function isSchemaSource(n){return n.startsWith(`${WL.schemas}/`)&&n.endsWith(`.gschema.xml`)}async function runSchemaCompiler(n){try{await bR(xR,[`--strict`,`--targetdir=${n}`,n])}catch(n){let S=n;throw S.code===`ENOENT`?Error(`gjsify ship: this artifact has no install step, so \`${xR}\` has to run HERE to turn the payload's schemas into \`${CR}\` — and it is not on PATH. Install it (${SR}). Without the compiled cache the launcher points XDG_DATA_DIRS at a schema directory GSettings aborts on, so the bundle would build and then die at its first \`Gio.Settings.new()\`.`):Error(`gjsify ship: \`${xR} --strict\` refused this project's schemas.\n${(S.stderr??``).trimEnd()}\n \`--strict\` is deliberate: without it a malformed schema is SKIPPED at exit 0 and a cache
1075
1075
  is written without it, so the app still aborts on the schema that was dropped. Fix the
1076
- file it names, or drop it from \`gjsify.ship.schemas\`.`)}return[{path:CR,mode:420,source:{kind:`file`,path:js(n.workDir,`gschemas.compiled`)}}]}var bR,xR,SR,CR,wR=__esmMin(()=>{Dh(),Hs(),Vl(),Ac(),GL(),bR=promisify(execFile),xR=`glib-compile-schemas`,SR="Fedora: `sudo dnf install glib2`, Debian/Ubuntu: `sudo apt install libglib2.0-bin`",CR=`${WL.schemas}/gschemas.compiled`});function buildTimestamp(n,S=process.env){let C=S.SOURCE_DATE_EPOCH;if(C!==void 0){let n=Number(C);if(!Number.isInteger(n)||n<0)throw Error(`gjsify ship: SOURCE_DATE_EPOCH must be a non-negative integer, got "${C}".`);return n}return Math.floor(statSync(n).mtimeMs/1e3)}function readPayloadFacts(n){let S=n.map(n=>n.path);return{hasDesktopEntry:S.some(n=>isUnder(n,WL.applications)&&n.endsWith(`.desktop`)),hasIcons:S.some(n=>isUnder(n,WL.icons)),hasSchemas:S.some(n=>isUnder(n,WL.schemas)&&n.endsWith(`.gschema.xml`)),hasMimeTypes:S.some(n=>isUnder(n,WL.mime)&&n.endsWith(`.xml`)),bundledTypelibs:S.filter(n=>n.endsWith(`.typelib`))}}function readLauncherInterpreters(n,S,C){let N=n.find(n=>n.path===launcherPath(S,C));if(N===void 0)return[];let F=new TextDecoder().decode(N.data),I=S.name===`windows`?`cmd`:`sh`,H=[];for(let n of I===`cmd`?batchCommands(F):shellExecLines(F)){let S=interpreterOf(n,I);S!==null&&H.push(S)}return[...new Set(H)]}function shellExecLines(n){return[...`\n${n}`.matchAll(/\n[ \t]*exec\s+([^\n]*)/g)].map(n=>n[1].trim())}function cmdTokens(n){let S=[],C=0;for(;C<n.length;){if(/\s/.test(n[C])){C+=1;continue}let N=C,F=!1;for(;C<n.length&&(F||!/\s/.test(n[C]));)n[C]===`"`&&(F=!F),C+=1;S.push({text:n.slice(N,C),end:C})}return S}function splitBatchBlock(n){let S=0,C=!1;for(let N=0;N<n.length;N++){let F=n[N];if(F===`"`)C=!C;else if(!C&&F===`(`)S+=1;else if(!C&&F===`)`&&(--S,S===0))return[n.slice(1,N).trim(),n.slice(N+1).trim()]}return null}function batchPrefix(n){if(n.startsWith(`(`)){let S=splitBatchBlock(n);return S===null?null:[S[0],S[1]]}let S=cmdTokens(n),word=n=>(S[n]?.text??``).toLowerCase(),after=C=>[n.slice(S[C]?.end??n.length).trim()];if(word(0)===`else`)return after(0);if(word(0)===`for`){let n=S.findIndex(n=>n.text.toLowerCase()===`do`);return n===-1?null:after(n)}if(word(0)!==`if`)return;let C=1;for(;word(C)===`not`||word(C)===`/i`;)C+=1;return ER.has(word(C))?after(C+1):word(C).includes(`==`)?after(C):DR.has(word(C+1))?after(C+2):null}function batchCommands(n){let S=[],C=n.split(/\r?\n/).map(n=>n.trim().replace(/^@+/,``).trim());for(let n=0;n<OR&&C.length>0;n++){let n=C.shift();if(n===``||n===`)`||n.startsWith(`::`))continue;let N=(cmdTokens(n)[0]?.text??``).toLowerCase();if(TR.has(N))continue;let F=batchPrefix(n);F===void 0?S.push(n):F!==null&&C.unshift(...F)}return S}function interpreterOf(n,S){if(S===`cmd`)return cmdProgramOf(n);let C=n.split(/\s+/).filter(n=>n.length>0);for(let n=0;n<2&&C.length>0;n++){let n=basenameOf(C[0]);if(n!==`env`)return n===``?null:n;C=C.slice(1).filter(n=>!n.startsWith(`-`)&&!/^[A-Za-z_][A-Za-z0-9_]*=/.test(n))}return null}function cmdProgramOf(n){let S=/^"([^"]*)"/.exec(n),C=((S===null?n.split(/\s+/)[0]??``:S[1]).replace(/^%[^%\s]*%/,``).split(/[/\\]/).pop()??``).replace(/\.exe$/i,``);return C===``?null:C}function basenameOf(n){let S=unquote(n).split(/[/\\]/);return S[S.length-1]??``}function unquote(n){let S=n[0];return(S===`"`||S===`'`)&&n.length>1&&n[n.length-1]===S?n.slice(1,-1):n}function assertLauncherMatchesInterpreter(n,S,C,N){let F=readLauncherInterpreters(n,S,C);if(F.length===0||F.includes(N))return;let I=N===`gjs`?`node`:`gjs`;if(F.includes(I))throw Error(`gjsify ship: the launcher ${launcherPath(S,C)} execs \`${I}\`, but this package would declare a dependency on \`${N}\`.\n An installed package that depends on one interpreter and runs another installs cleanly and fails
1076
+ file it names, or drop it from \`gjsify.ship.schemas\`.`)}}var bR,xR,SR,CR,wR=__esmMin(()=>{Dh(),Hs(),Vl(),Ac(),GL(),bR=promisify(execFile),xR=`glib-compile-schemas`,SR="Fedora: `sudo dnf install glib2`, Debian/Ubuntu: `sudo apt install libglib2.0-bin`",CR=`${WL.schemas}/gschemas.compiled`});function buildTimestamp(n,S=process.env){let C=S.SOURCE_DATE_EPOCH;if(C!==void 0){let n=Number(C);if(!Number.isInteger(n)||n<0)throw Error(`gjsify ship: SOURCE_DATE_EPOCH must be a non-negative integer, got "${C}".`);return n}return Math.floor(statSync(n).mtimeMs/1e3)}function readPayloadFacts(n){let S=n.map(n=>n.path);return{hasDesktopEntry:S.some(n=>isUnder(n,WL.applications)&&n.endsWith(`.desktop`)),hasIcons:S.some(n=>isUnder(n,WL.icons)),hasSchemas:S.some(n=>isUnder(n,WL.schemas)&&n.endsWith(`.gschema.xml`)),hasMimeTypes:S.some(n=>isUnder(n,WL.mime)&&n.endsWith(`.xml`)),bundledTypelibs:S.filter(n=>n.endsWith(`.typelib`))}}function readLauncherInterpreters(n,S,C){let N=n.find(n=>n.path===launcherPath(S,C));if(N===void 0)return[];let F=new TextDecoder().decode(N.data),I=S.name===`windows`?`cmd`:`sh`,H=[];for(let n of I===`cmd`?batchCommands(F):shellExecLines(F)){let S=interpreterOf(n,I);S!==null&&H.push(S)}return[...new Set(H)]}function shellExecLines(n){return[...`\n${n}`.matchAll(/\n[ \t]*exec\s+([^\n]*)/g)].map(n=>n[1].trim())}function cmdTokens(n){let S=[],C=0;for(;C<n.length;){if(/\s/.test(n[C])){C+=1;continue}let N=C,F=!1;for(;C<n.length&&(F||!/\s/.test(n[C]));)n[C]===`"`&&(F=!F),C+=1;S.push({text:n.slice(N,C),end:C})}return S}function splitBatchBlock(n){let S=0,C=!1;for(let N=0;N<n.length;N++){let F=n[N];if(F===`"`)C=!C;else if(!C&&F===`(`)S+=1;else if(!C&&F===`)`&&(--S,S===0))return[n.slice(1,N).trim(),n.slice(N+1).trim()]}return null}function batchPrefix(n){if(n.startsWith(`(`)){let S=splitBatchBlock(n);return S===null?null:[S[0],S[1]]}let S=cmdTokens(n),word=n=>(S[n]?.text??``).toLowerCase(),after=C=>[n.slice(S[C]?.end??n.length).trim()];if(word(0)===`else`)return after(0);if(word(0)===`for`){let n=S.findIndex(n=>n.text.toLowerCase()===`do`);return n===-1?null:after(n)}if(word(0)!==`if`)return;let C=1;for(;word(C)===`not`||word(C)===`/i`;)C+=1;return ER.has(word(C))?after(C+1):word(C).includes(`==`)?after(C):DR.has(word(C+1))?after(C+2):null}function batchCommands(n){let S=[],C=n.split(/\r?\n/).map(n=>n.trim().replace(/^@+/,``).trim());for(let n=0;n<OR&&C.length>0;n++){let n=C.shift();if(n===``||n===`)`||n.startsWith(`::`))continue;let N=(cmdTokens(n)[0]?.text??``).toLowerCase();if(TR.has(N))continue;let F=batchPrefix(n);F===void 0?S.push(n):F!==null&&C.unshift(...F)}return S}function interpreterOf(n,S){if(S===`cmd`)return cmdProgramOf(n);let C=n.split(/\s+/).filter(n=>n.length>0);for(let n=0;n<2&&C.length>0;n++){let n=basenameOf(C[0]);if(n!==`env`)return n===``?null:n;C=C.slice(1).filter(n=>!n.startsWith(`-`)&&!/^[A-Za-z_][A-Za-z0-9_]*=/.test(n))}return null}function cmdProgramOf(n){let S=/^"([^"]*)"/.exec(n),C=((S===null?n.split(/\s+/)[0]??``:S[1]).replace(/^%[^%\s]*%/,``).split(/[/\\]/).pop()??``).replace(/\.exe$/i,``);return C===``?null:C}function basenameOf(n){let S=unquote(n).split(/[/\\]/);return S[S.length-1]??``}function unquote(n){let S=n[0];return(S===`"`||S===`'`)&&n.length>1&&n[n.length-1]===S?n.slice(1,-1):n}function assertLauncherMatchesInterpreter(n,S,C,N){let F=readLauncherInterpreters(n,S,C);if(F.length===0||F.includes(N))return;let I=N===`gjs`?`node`:`gjs`;if(F.includes(I))throw Error(`gjsify ship: the launcher ${launcherPath(S,C)} execs \`${I}\`, but this package would declare a dependency on \`${N}\`.\n An installed package that depends on one interpreter and runs another installs cleanly and fails
1077
1077
  at first launch, on the user's machine.
1078
1078
  Either set \`gjsify.ship.app.${S.os}\` to "${I}" in the project this was staged from — it overrides
1079
1079
  \`gjsify.app\` for that target alone — or fix the launcher: if it comes from \`gjsify.ship.extraFiles\`,
@@ -1095,9 +1095,9 @@ A misplaced catalogue installs and then shows nothing, which reads exactly like
1095
1095
  `).map(n=>n.trim()===``?` .`:` ${n}`).join(`
1096
1096
  `);return[`Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/`,`Upstream-Name: ${n.name}`,...n.homepage?[`Source: ${n.homepage}`]:[],``,`Files: *`,`Copyright: ${n.maintainer}`,`License: ${n.license}`,C,``].join(`
1097
1097
  `)}function planIcons(n){let S=[],C=new Map;for(let N of n.iconFiles){let F=Is(N),I=iconThemeDir(N),H=isSymbolicIcon(N)?`${n.appId}-symbolic`:n.appId,W=`${WL.icons}/${I}/apps/${H}${F}`,q=C.get(W);if(q!==void 0)throw Error(`gjsify ship: ${N} and ${q} both install as ${W}. An icon is keyed on its context and its size: \`symbolic\` is read from a \`symbolic/\` path component or a \`-symbolic\` filename, the size from the path (\`.../128x128/...\`) or the filename (\`icon-128.png\`). Give them distinguishable sizes, or point \`gjsify.ship.icon\` at a single file.`);C.set(W,N),S.push({path:W,mode:420,source:{kind:`file`,path:N}})}return S}function isSymbolicIcon(n){return Is(n).toLowerCase()===`.svg`?/(?:^|[\\/])symbolic[\\/]/.test(n)?!0:Fs(n,Is(n)).endsWith(`-symbolic`):!1}function iconThemeDir(n){if(isSymbolicIcon(n))return`symbolic`;if(Is(n).toLowerCase()===`.svg`)return`scalable`;let S=/(?:^|[\\/])(\d{1,4})x\1(?:[\\/]|$)/.exec(n);if(S)return`${S[1]}x${S[1]}`;let C=Fs(n,Is(n)).split(/[-_.]/);for(let n=C.length-1;n>=0;n--){let S=C[n];if(S!==void 0&&/^\d{1,4}$/.test(S))return`${S}x${S}`}throw Error(`gjsify ship: cannot tell what size ${n} is. Put it in a \`<size>x<size>/\` directory, end its name with the size (\`icon-128.png\`), or ship an SVG.`)}function assertInsidePrefix(n){let S=xs.normalize(n);if(xs.isAbsolute(S)||S===`..`||S.startsWith(`../`))throw Error(`gjsify ship: \`gjsify.ship.extraFiles\` destination "${n}" escapes the install prefix. Destinations are relative to the prefix, e.g. \`share/applications/extra.desktop\`.`);return S}function isExecutableAsset(n){return/\.(so|node|dylib)(\.\d+)*$/.test(n)}function normalise(n){let S=new Map;for(let C of n)S.set(C.path,C);return[...S.values()].sort((n,S)=>n.path<S.path?-1:+(n.path>S.path))}var rz=__esmMin(()=>{nz(),UL(),RR(),GL(),Hs()});function isGtkRuntimeTarget(n){return iz.includes(n)}function gtkRuntimePackageName(n){return`@gjsify/gtk-runtime-${n}`}function resolveGtkRuntime(n,S={}){let C=S.env??process.env,N=n.startsWith(`win32-`)?`bin`:`lib`,F=[],I=C.GJSIFY_GTK_RUNTIME;I&&F.push({source:`GJSIFY_GTK_RUNTIME`,dir:I});let H=resolveNodeGiRoot(S);H!==null&&(F.push({source:`${oz}/prebuilds/${n}`,dir:js(H,`prebuilds`,n,`gtk`)}),F.push({source:`${oz} sibling`,dir:js(H,`..`,`gtk-runtime-${n}`,`gtk`)}));let W=gtkRuntimePackageName(n),q=resolveStagedPackage(W,S);q!==null&&F.push({source:W,dir:js(Ps(q),`gtk`)});for(let n of F){let S=js(n.dir,N),C=js(n.dir,`girepository-1.0`);if(!(!existsSync(S)||!existsSync(C)))return{source:n.source,dir:n.dir,libDir:S,typelibDir:C}}return null}function resolveNodeGiAddon(n,S={}){let C=resolveNodeGiRoot(S);if(C===null)return null;let N=js(C,`prebuilds`,n,az);return existsSync(N)?{source:oz,addonPath:N}:null}function resolveNodeGiRoot(n){let S=resolveStagedPackage(oz,n);return S===null?null:Ps(S)}function resolveStagedPackage(n,S){let C={bundleUrl:import.meta.url};return S.cwd!==void 0&&(C.cwd=S.cwd),S.resolve!==void 0&&(C.resolve=S.resolve),resolveInstalledPackage(n,C)}function resolveNodeGiPackage(n={}){let S=resolveNodeGiRoot(n);if(S===null)return null;let C=[`package.json`];for(let n of readdirSync(S,{withFileTypes:!0}).sort((n,S)=>n.name<S.name?-1:1))n.isFile()&&n.name.endsWith(`.js`)&&C.push(n.name);let N=js(S,`overrides`);if(existsSync(N))for(let n of listFilesRecursive(N))C.push(xs.join(`overrides`,n));return C.length>1?{source:oz,root:S,files:C.sort()}:null}function appRuntimePaths(n,S,C){let N=n.dirs(S),F=xs.join(N.native,`node-gi`),I=xs.join(F,`prebuilds`,C);return{nodeGiRoot:F,nodeGiPackageDir:xs.join(N.bundle,`node_modules`,oz),prebuildDir:I,gtkDir:xs.join(I,`gtk`),addonPath:xs.join(I,az),interpreterPath:xs.join(N.launcher,nodeRuntimeBinaryName(C)),interpreterLicensePath:xs.join(N.data,`licenses`,`node`,`LICENSE`)}}function stageAppRuntime(n){let S=appRuntimePaths(n.layout,n.identity,n.target),C=[],N={},F=[],I=[];n.interpreter===null?I.push(`no bundled interpreter — install \`@gjsify/node-runtime-${n.target}\` (or point \`GJSIFY_NODE_RUNTIME\` at a \`bin/\` directory holding \`node\` and its \`LICENSE\`)`):(C.push({path:S.interpreterPath,mode:493,source:{kind:`file`,path:n.interpreter.nodePath}}),C.push({path:S.interpreterLicensePath,mode:420,source:{kind:`file`,path:n.interpreter.licensePath}}),N.interpreter=S.interpreterPath,F.push(`interpreter from ${n.interpreter.source}`));let H=resolveGtkRuntime(n.target,discoveryOptions(n));if(H!==null){for(let n of listFilesRecursive(H.dir)){let N=js(H.dir,n.split(`/`).join(zs));C.push({path:xs.join(S.gtkDir,n),mode:stagedMode(n,N),source:{kind:`file`,path:N}})}N.gtkRuntimeDir=S.gtkDir,F.push(`GTK closure from ${H.source}`)}else{let S=n.target.startsWith(`win32-`)?`bin`:`lib`;I.push(`no GTK closure — install \`${gtkRuntimePackageName(n.target)}\` (or point \`GJSIFY_GTK_RUNTIME\` at a bundle directory holding \`${S}/\` and \`girepository-1.0/\`)`)}let W=resolveNodeGiPackage(discoveryOptions(n));if(W!==null){for(let n of W.files)C.push({path:xs.join(S.nodeGiPackageDir,n),mode:420,source:{kind:`file`,path:js(W.root,n.split(`/`).join(zs))}});F.push(`node-gi runtime (${W.files.length} file(s)) from ${W.source}`)}else I.push(`no node-gi JavaScript — install \`${oz}\`; a \`--app node\` bundle keeps \`@gjsify/node-gi/*\` external, so the staged bundle would \`require\` a package the artifact does not carry`);let q=resolveNodeGiAddon(n.target,discoveryOptions(n));return q===null?I.push(`no node-gi addon — install \`${oz}\`, whose \`prebuilds/${n.target}/${az}\` is the binary built against that closure`):(C.push({path:S.addonPath,mode:493,source:{kind:`file`,path:q.addonPath}}),N.nodeGiAddon=S.addonPath,F.push(`node-gi addon from ${q.source}`)),{files:C,launcher:N,found:F,missing:I}}function discoveryOptions(n){let S={};return n.cwd!==void 0&&(S.cwd=n.cwd),n.env!==void 0&&(S.env=n.env),n.resolve!==void 0&&(S.resolve=n.resolve),S}function stagedMode(n,S){if(isExecutableAsset(n)||n.startsWith(`libexec/`)||n.startsWith(`bin/`))return 493;try{if(statSync(S).mode&73)return 493}catch{}return 420}var iz,az,oz,sz=__esmMin(()=>{Vl(),Hs(),XR(),QR(),rz(),iN(),iz=[`darwin-arm64`,`darwin-x64`,`win32-x64`],az=`node_gi.node`,oz=`@gjsify/node-gi`});function appDirFor(n){return js(n,`appimage`,fz)}function appImageHostRequirements(n){let S=interpreterFloor(n);return[`${n.app} (>= ${S})`,...hostProvidedNamespaces(n.namespaces,n.bundledTypelibs).map(n=>`the ${n} typelib`)]}function interpreterFloor(n){return n.app===`node`?n.minNodeVersion??`24`:n.minGjsVersion??`1.86`}function renderAppRun(n,S){let C=gR.linux.dirs(n).launcher,N=interpreterFloor(n),[F=`0`,I=`0`]=N.split(`.`);return[`#!/bin/sh`,"# Generated by `gjsify ship` — do not edit.",`set -e`,`here=$(dirname "$(readlink -f "$0")")`,`if ! command -v ${n.app} >/dev/null 2>&1; then`,` echo "${shellSafe(n.name)} needs ${n.app}, and this system has none." >&2`,` echo "This AppImage carries the application, not its runtime. It needs:" >&2`,...S.map(n=>` echo " - ${shellSafe(n)}" >&2`),` exit 127`,`fi`,`found=$(${n.app} --version 2>/dev/null | sed -n 's/[^0-9]*\\([0-9][0-9]*\\)\\.\\([0-9][0-9]*\\).*/\\1 \\2/p' | head -n 1 || true)`,"major=${found% *}","minor=${found#* }",`if [ -n "$major" ]; then`,` if [ "$major" -lt ${F} ] || { [ "$major" -eq ${F} ] && [ "$minor" -lt ${I} ]; }; then`,` echo "${shellSafe(n.name)} needs ${n.app} ${N} or newer, and this system has $major.$minor." >&2`,` echo "This AppImage carries the application, not its runtime. It needs:" >&2`,...S.map(n=>` echo " - ${shellSafe(n)}" >&2`),` exit 126`,` fi`,`fi`,`exec "$here/usr/${C}/${n.binaryName}" "$@"`,``].join(`
1098
- `)}function shellSafe(n){return n.replace(/(["$`\\])/g,`\\$1`)}function findPinnedRuntime(n,S=process.env,C=existsSync){let N=S.GJSIFY_APPIMAGE_RUNTIME_DIR||`/usr/local/share/gjsify/appimage-runtime`,F=xs.join(N,`runtime-${n}`);return C(F)?F:void 0}function appImageRuntimeNotice(n,S){return S===void 0?`NO pinned AppImage runtime for ${n}: appimagetool will fetch runtime-${n} from type2-runtime's rolling \`continuous\` tag, so this pack NEEDS A NETWORK and the ~940 KB of runtime it embeds carries no digest from this tree. Pin one at ${dz}/runtime-${n} (or point ${uz} at a directory holding it).`:`the AppImage runtime is pinned: ${S} — this pack needs no network`}function selectAppDirIcon(n,S){let C;for(let N of n){let n=rootIconRank(N.path,S);n!==void 0&&(C===void 0||n>C.rank)&&(C={entry:N,rank:n})}return C?.entry}function rootIconRank(n,S){if(hz.find(C=>n.endsWith(`${S}${C}`))===void 0||!n.startsWith(`${WL.icons}/`)||n.includes(`/symbolic/`))return;if(n.includes(`/scalable/`))return 2**53-1;let C=/\/(\d+)x\1\//.exec(n);return C===null?1:Number(C[1])}function assertAppImageIsPackable(n,S){let C=`${WL.applications}/${S.appId}.desktop`;if(!n.some(n=>n.path===C))throw Error(`gjsify ship: an AppImage needs a desktop entry and this payload has no ${C}. appimagetool refuses an AppDir without one, and the AppImage runtime has nothing to tell a desktop about the application it just mounted. A \`kind: "cli"\` project stages no entry by design — set \`gjsify.ship.kind\` to "app" if this is a GUI application, or ship it as a \`.deb\`, an \`.rpm\` or a Flatpak, none of which need one.`);if(selectAppDirIcon(n,S.appId)===void 0)throw Error(`gjsify ship: an AppImage needs an icon called ${S.appId} beside its desktop entry, and this payload stages none under ${WL.icons}/. The entry's \`Icon=\` names the app id, so a file keeping its own basename is an icon nothing looks up — point \`gjsify.ship.icon\` at a PNG or an SVG and it is renamed into the theme for you.`)}function appDirPayload(n,S,C){assertAppImageIsPackable(S,n);let N=selectAppDirIcon(S,n.appId),F=`${WL.applications}/${n.appId}.desktop`,I=S.find(n=>n.path===F);return[...S.map(n=>({...n,path:`usr/${n.path}`})),{path:pz,mode:493,data:encodeUtf8(renderAppRun(n,C))},{path:`${n.appId}.desktop`,mode:420,data:I.data},{path:N.path.slice(N.path.lastIndexOf(`/`)+1),mode:420,data:N.data},{path:mz,mode:420,data:N.data}]}function appImageToolArgs(n){return[`--no-appstream`,`--comp`,`zstd`,...n.runtimeFile===void 0?[]:[`--runtime-file`,n.runtimeFile],n.appDir,n.target]}function appImageToolEnv(n){return{ARCH:n,[lz]:`1`}}function appImageToolFailureMessage(n,S){let C=S===void 0?`the AppImage RUNTIME could not be downloaded — ${cz} fetches it from github.com/AppImage/type2-runtime when no runtime is pinned, so this pack needs a network and an offline host fails here having written nothing; or `:`the pinned runtime at ${S} is not an AppImage runtime — it is passed through to \`--runtime-file\` unread, so a truncated or wrong-architecture file fails here; or `;return`gjsify ship: ${cz} failed with ${n}. Four causes, measured in this order: ${C}\`file\` is not installed — ${cz} requires file(1) and says so, even though this pack already tells it the architecture; or FUSE is unavailable and the tool on PATH is a wrapper that dropped ${lz}=1, which this pack sets so the extract path is taken instead of a mount; or the work directory is full — the AppDir is copied into a squashfs image beside it.`}async function buildAppImage(n){let S=appImageToolArgs(n),C=appImageToolEnv(n.archLabel);n.verbose&&ve.log(`[gjsify ship] ${Object.entries(C).map(([n,S])=>`${n}=${S}`).join(` `)} ${cz} ${S.join(` `)}`);let N=await spawnToCompletion(cz,S,{completion:`return`,cwd:n.workDir,stdio:`inherit`,env:{...process.env,...C},notFound:()=>Error(`gjsify ship: ${cz} is not on PATH. Unlike flatpak-builder and msitools it is not packaged by Fedora or Debian: take the release from https://github.com/AppImage/appimagetool/releases, \`chmod +x\` it and put it on PATH as \`${cz}\`. \`gjsify ship linux --stage\` needs none of this — the payload is assembled by this CLI and only the container needs the tool.`)});if(N.code!==0)throw Error(appImageToolFailureMessage(describeExit(N),n.runtimeFile));if(!existsSync(n.target))throw Error(`gjsify ship: ${cz} exited 0 and wrote no file at ${n.target}. An exit code is not an artifact — re-run with \`--verbose\` to see what it was told.`)}function appDirPaths(n){let S=new Set;for(let C of n){let n=C.path.split(`/`);for(let C=1;C<n.length;C++)S.add(n.slice(0,C).join(`/`))}return[...[...S].sort(),...n.map(n=>n.path)]}function stampAppDirTimes(n,S,C){for(let N of appDirPaths(S))utimesSync(js(n,N.split(`/`).join(zs)),C,C);utimesSync(n,C,C)}var cz,lz,uz,dz,fz,pz,mz,hz,gz=__esmMin(()=>{ye(),Vl(),Hs(),jP(),AL(),HL(),yR(),GL(),cz=`appimagetool`,lz=`APPIMAGE_EXTRACT_AND_RUN`,uz=`GJSIFY_APPIMAGE_RUNTIME_DIR`,dz=`/usr/local/share/gjsify/appimage-runtime`,fz=`AppDir`,pz=`AppRun`,mz=`.DirIcon`,hz=[`.png`,`.svg`]});function dmgVolumeName(n){let S=n.name;if(S.trim()===``)throw Error("gjsify ship: the macOS image has no name to call its volume — `gjsify.ship.name` (or the package name it is derived from) is empty. `hdiutil` would accept that and mount the image as `untitled`, which is the name every nameless disk image on the machine has.");if(vz.test(S))throw Error(`gjsify ship: the macOS image would mount a volume called "${S}", and HFS+ cannot hold it: the Finder shows a stored ":" as a "/" and a stored "/" as a ":", so the volume would not be the one this project named. Set \`gjsify.ship.name\` to the display name you want.`);return S}function hdiutilCreateArgs(n){return[`create`,`-format`,`UDZO`,`-fs`,`HFS+J`,`-volname`,n.volumeName,`-srcfolder`,n.sourceDir,`-ov`,`-quiet`,n.target]}async function buildDmgImage(n){let S=hdiutilCreateArgs(n);n.verbose&&ve.log(`[gjsify ship] ${_z} ${S.join(` `)}`);let C=await spawnToCompletion(_z,S,{completion:`return`,cwd:n.workDir,stdio:`inherit`,notFound:()=>Error(`gjsify ship: ${_z} is not on PATH. It ships with macOS and cannot be installed anywhere else, so this is either a broken macOS installation or a host that is not macOS at all. A \`.dmg\` is packed on darwin (ADR 0024 § A1); from anywhere else the route is \`gjsify ship darwin --stage\` here and \`gjsify ship --from-stage <dir> --target macos-app-dmg\` there.`)});if(C.code!==0)throw Error(`gjsify ship: ${_z} failed with ${describeExit(C)}.`)}function dmgVolumeDir(n){return js(n,`dmg`,`volume`)}var _z,vz,yz=__esmMin(()=>{ye(),Hs(),jP(),_z=`hdiutil`,vz=/[/:]/});function renderShipFlatpakManifest(n){let{settings:S,stageDir:C,overlayDir:N}=n,F=S.flatpak,I={id:S.appId,runtime:F.runtime,"runtime-version":F.runtimeVersion,sdk:F.sdk,branch:F.branch,command:S.binaryName,"finish-args":F.finishArgs};return F.sdkExtensions.length>0&&(I[`sdk-extensions`]=F.sdkExtensions),F.appendPath.length>0&&(I[`build-options`]={"append-path":F.appendPath.join(`:`)}),F.cleanup.length>0&&(I.cleanup=F.cleanup),I.modules=[{name:S.binaryName,buildsystem:`simple`,"build-commands":[`mkdir -p /app`,`cp -a stage/. /app/`,`cp -a overlay/. /app/`],sources:[{type:`dir`,path:C,dest:`stage`,skip:[n.stageManifestFile]},{type:`dir`,path:N,dest:`overlay`}]}],I}async function buildFlatpakBundle(n){let{settings:S,workDir:C,archLabel:N}=n,F=js(C,`${S.appId}.json`),I=js(C,`build`),H=js(C,`repo`),W=js(C,`state`);mkdirSync(C,{recursive:!0}),rmSync(H,{recursive:!0,force:!0,maxRetries:5}),writeFileSync(F,`${JSON.stringify(renderShipFlatpakManifest(n),null,2)}\n`),await run$1(`flatpak-builder`,[`--force-clean`,`--disable-rofiles-fuse`,`--delete-build-dirs`,`--state-dir=${W}`,`--arch=${N}`,`--repo=${H}`,I,F],n,"flatpak-builder not found. Install it (Fedora: `sudo dnf install flatpak-builder`)."),await run$1(`flatpak`,[`build-bundle`,`--arch=${N}`,H,n.target,S.appId,S.flatpak.branch],n,`flatpak not found. Install it via your distro: see https://flathub.org/setup.`)}async function run$1(n,S,C,N){C.verbose&&ve.log(`[gjsify ship] ${n} ${S.join(` `)}`);let F=await spawnToCompletion(n,S,{completion:`return`,cwd:C.workDir,stdio:`inherit`,notFound:()=>Error(`gjsify ship: ${N}`)});if(F.code!==0)throw Error(`gjsify ship: ${n} failed with ${describeExit(F)}.`)}var bz=__esmMin(()=>{ye(),Vl(),Hs(),jP(),__name$1(run$1,`run`)});function localeOf(n){return n.split(`/`)[0]??``}function fold(n,S,C,N,F){let I=js(F,`source${C}`);return writeFileSync(I,S),readFileSync(mergeCatalogues({mode:n,template:I,extension:C,catalogues:N,workDir:F}),`utf-8`)}function localizeMetadata(n,S){if(S.length===0)return n;let C=mkdtempSync(js(tmpdir(),`gjsify-ship-l10n-`));try{let N=[...S].sort((n,S)=>n.rel<S.rel?-1:+(n.rel>S.rel)),F=new Map;for(let[n,S]of N.entries()){let N=js(C,`${n}.po`);execFileSync(`msgunfmt`,[S.abs,`--output-file`,N],{stdio:`pipe`});let I=localeOf(S.rel);F.set(I,[...F.get(I)??[],N])}let I=[...F].map(([n,S])=>({locale:n,po:S.length===1?S[0]:msgcat(S,js(C,`${n}.merged.po`))}));return{metainfo:fold(`--xml`,n.metainfo,`.metainfo.xml`,I,C),desktopEntry:n.desktopEntry===void 0?void 0:fold(`--desktop`,n.desktopEntry,`.desktop`,I,C)}}catch(n){throw Error(describeFailure(n,S.length))}finally{rmSync(C,{recursive:!0,force:!0})}}function msgcat(n,S){return execFileSync(`msgcat`,[`--use-first`,`--output-file`,S,...n],{stdio:`pipe`}),S}function describeFailure(n,S){let C=n;return C?.code===`ENOENT`?`gjsify ship: \`msgfmt\`/\`msgunfmt\`/\`msgcat\` are not on PATH, but the package stages ${S} gettext catalogue(s). Install them (package: gettext) — shipping the metadata untranslated would install an English app menu entry for a translated app, which nothing downstream can detect.`:`gjsify ship: could not fold the gettext catalogues into the freedesktop metadata.${C?.stderr===void 0?``:`\n${String(C.stderr).trim()}`}`}var xz=__esmMin(()=>{Dh(),Vl(),Dm(),Hs(),BI()});function lookupArch(n,S,C){let N=n[S];if(!N)throw Error(`gjsify ship: no ${C} architecture is known for \`process.arch\` "${S}". Known: ${Object.keys(n).join(`, `)}.`);return N}function debArch(n,S){return S?`all`:lookupArch(Sz,n,`Debian`)}function rpmArch(n,S){return S?`noarch`:lookupArch(Cz,n,`RPM`)}function flatpakArch(n,S){return lookupArch(wz,n,`Flatpak`)}function appImageArch(n,S){return lookupArch(Tz,n,`AppImage`)}function macosArch(n,S){return lookupArch(Ez,n,`macOS`)}function windowsArch(n,S){return lookupArch(Dz,n,`Windows`)}function windowsNameIsUnusable(n){return Oz.test(n)||kz.test(n)||/[. ]$/.test(n)?!0:[...n].some(n=>(n.codePointAt(0)??0)<32)}function windowsProgramDirName(n){let S=n.name;if(S.trim()===``)throw Error("gjsify ship: the windows layout has no name to call the program directory — `gjsify.ship.name` (or the package name it is derived from) is empty. The artifact IS a directory and its zip expands into one, so an empty name would unpack `app\\`, `share\\` and the launcher loose into whatever folder the user was in.");if(windowsNameIsUnusable(S))throw Error(`gjsify ship: the windows layout would put this app in a directory called "${S}", and Windows cannot hold it: it reserves < > : " / \\ | ? * and the control characters, reserves CON, PRN, AUX, NUL, COM1-9 and LPT1-9 as device names at every path, and silently strips a trailing dot or space.
1098
+ `)}function shellSafe(n){return n.replace(/(["$`\\])/g,`\\$1`)}function findPinnedRuntime(n,S=process.env,C=existsSync){let N=S.GJSIFY_APPIMAGE_RUNTIME_DIR||`/usr/local/share/gjsify/appimage-runtime`,F=xs.join(N,`runtime-${n}`);return C(F)?F:void 0}function appImageRuntimeNotice(n,S){return S===void 0?`NO pinned AppImage runtime for ${n}: appimagetool will fetch runtime-${n} from type2-runtime's rolling \`continuous\` tag, so this pack NEEDS A NETWORK and the ~940 KB of runtime it embeds carries no digest from this tree. Pin one at ${dz}/runtime-${n} (or point ${uz} at a directory holding it).`:`the AppImage runtime is pinned: ${S} — this pack needs no network`}function selectAppDirIcon(n,S){let C;for(let N of n){let n=rootIconRank(N.path,S);n!==void 0&&(C===void 0||n>C.rank)&&(C={entry:N,rank:n})}return C?.entry}function rootIconRank(n,S){if(hz.find(C=>n.endsWith(`${S}${C}`))===void 0||!n.startsWith(`${WL.icons}/`)||n.includes(`/symbolic/`))return;if(n.includes(`/scalable/`))return 2**53-1;let C=/\/(\d+)x\1\//.exec(n);return C===null?1:Number(C[1])}function assertAppImageIsPackable(n,S,C){let N=`${WL.applications}/${S.appId}.desktop`;if(!n.some(n=>n.path===N))throw Error(`gjsify ship: an AppImage needs a desktop entry and this payload has no ${N}. appimagetool refuses an AppDir without one, and the AppImage runtime has nothing to tell a desktop about the application it just mounted. A \`kind: "cli"\` project stages no entry by design — set \`gjsify.ship.kind\` to "app" if this is a GUI application, or ship it as a \`.deb\`, an \`.rpm\` or a Flatpak, none of which need one.`);if(selectAppDirIcon(n,S.appId)===void 0)throw Error(`gjsify ship: an AppImage needs an icon called ${S.appId} beside its desktop entry, and this payload stages none under ${WL.icons}/. The entry's \`Icon=\` names the app id, so a file keeping its own basename is an icon nothing looks up — point \`gjsify.ship.icon\` at a PNG or an SVG and it is renamed into the theme for you.`);if(C===void 0&&n.some(n=>isSchemaSource(n.path)))throw Error(`gjsify ship: this payload stages GSettings schema sources under ${WL.schemas}/ and no ${CR} was compiled for it. An AppImage has NO INSTALL STEP — that is the whole point of the format — so the \`.deb\`/\`.rpm\` postinst that compiles the system schema directory never runs, and GSettings aborts on a directory holding only sources. The AppDir must carry ${CR}; \`compileSchemasForPayload\` produces it from this payload.`)}function appDirPayload(n,S,C,N){assertAppImageIsPackable(S,n,N);let F=selectAppDirIcon(S,n.appId),I=`${WL.applications}/${n.appId}.desktop`,H=S.find(n=>n.path===I);return[...[...S,...N===void 0?[]:[N]].map(n=>({...n,path:`usr/${n.path}`})),{path:pz,mode:493,data:encodeUtf8(renderAppRun(n,C))},{path:`${n.appId}.desktop`,mode:420,data:H.data},{path:F.path.slice(F.path.lastIndexOf(`/`)+1),mode:420,data:F.data},{path:mz,mode:420,data:F.data}]}function appImageToolArgs(n){return[`--no-appstream`,`--comp`,`zstd`,...n.runtimeFile===void 0?[]:[`--runtime-file`,n.runtimeFile],n.appDir,n.target]}function appImageToolEnv(n){return{ARCH:n,[lz]:`1`}}function appImageToolFailureMessage(n,S){let C=S===void 0?`the AppImage RUNTIME could not be downloaded — ${cz} fetches it from github.com/AppImage/type2-runtime when no runtime is pinned, so this pack needs a network and an offline host fails here having written nothing; or `:`the pinned runtime at ${S} is not an AppImage runtime — it is passed through to \`--runtime-file\` unread, so a truncated or wrong-architecture file fails here; or `;return`gjsify ship: ${cz} failed with ${n}. Four causes, measured in this order: ${C}\`file\` is not installed — ${cz} requires file(1) and says so, even though this pack already tells it the architecture; or FUSE is unavailable and the tool on PATH is a wrapper that dropped ${lz}=1, which this pack sets so the extract path is taken instead of a mount; or the work directory is full — the AppDir is copied into a squashfs image beside it.`}async function buildAppImage(n){let S=appImageToolArgs(n),C=appImageToolEnv(n.archLabel);n.verbose&&ve.log(`[gjsify ship] ${Object.entries(C).map(([n,S])=>`${n}=${S}`).join(` `)} ${cz} ${S.join(` `)}`);let N=await spawnToCompletion(cz,S,{completion:`return`,cwd:n.workDir,stdio:`inherit`,env:{...process.env,...C},notFound:()=>Error(`gjsify ship: ${cz} is not on PATH. Unlike flatpak-builder and msitools it is not packaged by Fedora or Debian: take the release from https://github.com/AppImage/appimagetool/releases, \`chmod +x\` it and put it on PATH as \`${cz}\`. \`gjsify ship linux --stage\` needs none of this — the payload is assembled by this CLI and only the container needs the tool.`)});if(N.code!==0)throw Error(appImageToolFailureMessage(describeExit(N),n.runtimeFile));if(!existsSync(n.target))throw Error(`gjsify ship: ${cz} exited 0 and wrote no file at ${n.target}. An exit code is not an artifact — re-run with \`--verbose\` to see what it was told.`)}function appDirPaths(n){let S=new Set;for(let C of n){let n=C.path.split(`/`);for(let C=1;C<n.length;C++)S.add(n.slice(0,C).join(`/`))}return[...[...S].sort(),...n.map(n=>n.path)]}function stampAppDirTimes(n,S,C){for(let N of appDirPaths(S))utimesSync(js(n,N.split(`/`).join(zs)),C,C);utimesSync(n,C,C)}var cz,lz,uz,dz,fz,pz,mz,hz,gz=__esmMin(()=>{ye(),Vl(),Hs(),jP(),AL(),HL(),yR(),wR(),GL(),cz=`appimagetool`,lz=`APPIMAGE_EXTRACT_AND_RUN`,uz=`GJSIFY_APPIMAGE_RUNTIME_DIR`,dz=`/usr/local/share/gjsify/appimage-runtime`,fz=`AppDir`,pz=`AppRun`,mz=`.DirIcon`,hz=[`.png`,`.svg`]});function dmgVolumeName(n){let S=n.name;if(S.trim()===``)throw Error("gjsify ship: the macOS image has no name to call its volume — `gjsify.ship.name` (or the package name it is derived from) is empty. `hdiutil` would accept that and mount the image as `untitled`, which is the name every nameless disk image on the machine has.");if(vz.test(S))throw Error(`gjsify ship: the macOS image would mount a volume called "${S}", and HFS+ cannot hold it: the Finder shows a stored ":" as a "/" and a stored "/" as a ":", so the volume would not be the one this project named. Set \`gjsify.ship.name\` to the display name you want.`);return S}function hdiutilCreateArgs(n){return[`create`,`-format`,`UDZO`,`-fs`,`HFS+J`,`-volname`,n.volumeName,`-srcfolder`,n.sourceDir,`-ov`,`-quiet`,n.target]}async function buildDmgImage(n){let S=hdiutilCreateArgs(n);n.verbose&&ve.log(`[gjsify ship] ${_z} ${S.join(` `)}`);let C=await spawnToCompletion(_z,S,{completion:`return`,cwd:n.workDir,stdio:`inherit`,notFound:()=>Error(`gjsify ship: ${_z} is not on PATH. It ships with macOS and cannot be installed anywhere else, so this is either a broken macOS installation or a host that is not macOS at all. A \`.dmg\` is packed on darwin (ADR 0024 § A1); from anywhere else the route is \`gjsify ship darwin --stage\` here and \`gjsify ship --from-stage <dir> --target macos-app-dmg\` there.`)});if(C.code!==0)throw Error(`gjsify ship: ${_z} failed with ${describeExit(C)}.`)}function dmgVolumeDir(n){return js(n,`dmg`,`volume`)}var _z,vz,yz=__esmMin(()=>{ye(),Hs(),jP(),_z=`hdiutil`,vz=/[/:]/});function renderShipFlatpakManifest(n){let{settings:S,stageDir:C,overlayDir:N}=n,F=S.flatpak,I={id:S.appId,runtime:F.runtime,"runtime-version":F.runtimeVersion,sdk:F.sdk,branch:F.branch,command:S.binaryName,"finish-args":F.finishArgs};return F.sdkExtensions.length>0&&(I[`sdk-extensions`]=F.sdkExtensions),F.appendPath.length>0&&(I[`build-options`]={"append-path":F.appendPath.join(`:`)}),F.cleanup.length>0&&(I.cleanup=F.cleanup),I.modules=[{name:S.binaryName,buildsystem:`simple`,"build-commands":[`mkdir -p /app`,`cp -a stage/. /app/`,`cp -a overlay/. /app/`],sources:[{type:`dir`,path:C,dest:`stage`,skip:[n.stageManifestFile]},{type:`dir`,path:N,dest:`overlay`}]}],I}async function buildFlatpakBundle(n){let{settings:S,workDir:C,archLabel:N}=n,F=js(C,`${S.appId}.json`),I=js(C,`build`),H=js(C,`repo`),W=js(C,`state`);mkdirSync(C,{recursive:!0}),rmSync(H,{recursive:!0,force:!0,maxRetries:5}),writeFileSync(F,`${JSON.stringify(renderShipFlatpakManifest(n),null,2)}\n`),await run$1(`flatpak-builder`,[`--force-clean`,`--disable-rofiles-fuse`,`--delete-build-dirs`,`--state-dir=${W}`,`--arch=${N}`,`--repo=${H}`,I,F],n,"flatpak-builder not found. Install it (Fedora: `sudo dnf install flatpak-builder`)."),await run$1(`flatpak`,[`build-bundle`,`--arch=${N}`,H,n.target,S.appId,S.flatpak.branch],n,`flatpak not found. Install it via your distro: see https://flathub.org/setup.`)}async function run$1(n,S,C,N){C.verbose&&ve.log(`[gjsify ship] ${n} ${S.join(` `)}`);let F=await spawnToCompletion(n,S,{completion:`return`,cwd:C.workDir,stdio:`inherit`,notFound:()=>Error(`gjsify ship: ${N}`)});if(F.code!==0)throw Error(`gjsify ship: ${n} failed with ${describeExit(F)}.`)}var bz=__esmMin(()=>{ye(),Vl(),Hs(),jP(),__name$1(run$1,`run`)});function localeOf(n){return n.split(`/`)[0]??``}function fold(n,S,C,N,F){let I=js(F,`source${C}`);return writeFileSync(I,S),readFileSync(mergeCatalogues({mode:n,template:I,extension:C,catalogues:N,workDir:F}),`utf-8`)}function localizeMetadata(n,S){if(S.length===0)return n;let C=mkdtempSync(js(tmpdir(),`gjsify-ship-l10n-`));try{let N=[...S].sort((n,S)=>n.rel<S.rel?-1:+(n.rel>S.rel)),F=new Map;for(let[n,S]of N.entries()){let N=js(C,`${n}.po`);execFileSync(`msgunfmt`,[S.abs,`--output-file`,N],{stdio:`pipe`});let I=localeOf(S.rel);F.set(I,[...F.get(I)??[],N])}let I=[...F].map(([n,S])=>({locale:n,po:S.length===1?S[0]:msgcat(S,js(C,`${n}.merged.po`))}));return{metainfo:fold(`--xml`,n.metainfo,`.metainfo.xml`,I,C),desktopEntry:n.desktopEntry===void 0?void 0:fold(`--desktop`,n.desktopEntry,`.desktop`,I,C)}}catch(n){throw Error(describeFailure(n,S.length))}finally{rmSync(C,{recursive:!0,force:!0})}}function msgcat(n,S){return execFileSync(`msgcat`,[`--use-first`,`--output-file`,S,...n],{stdio:`pipe`}),S}function describeFailure(n,S){let C=n;return C?.code===`ENOENT`?`gjsify ship: \`msgfmt\`/\`msgunfmt\`/\`msgcat\` are not on PATH, but the package stages ${S} gettext catalogue(s). Install them (package: gettext) — shipping the metadata untranslated would install an English app menu entry for a translated app, which nothing downstream can detect.`:`gjsify ship: could not fold the gettext catalogues into the freedesktop metadata.${C?.stderr===void 0?``:`\n${String(C.stderr).trim()}`}`}var xz=__esmMin(()=>{Dh(),Vl(),Dm(),Hs(),BI()});function lookupArch(n,S,C){let N=n[S];if(!N)throw Error(`gjsify ship: no ${C} architecture is known for \`process.arch\` "${S}". Known: ${Object.keys(n).join(`, `)}.`);return N}function debArch(n,S){return S?`all`:lookupArch(Sz,n,`Debian`)}function rpmArch(n,S){return S?`noarch`:lookupArch(Cz,n,`RPM`)}function flatpakArch(n,S){return lookupArch(wz,n,`Flatpak`)}function appImageArch(n,S){return lookupArch(Tz,n,`AppImage`)}function macosArch(n,S){return lookupArch(Ez,n,`macOS`)}function windowsArch(n,S){return lookupArch(Dz,n,`Windows`)}function windowsNameIsUnusable(n){return Oz.test(n)||kz.test(n)||/[. ]$/.test(n)?!0:[...n].some(n=>(n.codePointAt(0)??0)<32)}function windowsProgramDirName(n){let S=n.name;if(S.trim()===``)throw Error("gjsify ship: the windows layout has no name to call the program directory — `gjsify.ship.name` (or the package name it is derived from) is empty. The artifact IS a directory and its zip expands into one, so an empty name would unpack `app\\`, `share\\` and the launcher loose into whatever folder the user was in.");if(windowsNameIsUnusable(S))throw Error(`gjsify ship: the windows layout would put this app in a directory called "${S}", and Windows cannot hold it: it reserves < > : " / \\ | ? * and the control characters, reserves CON, PRN, AUX, NUL, COM1-9 and LPT1-9 as device names at every path, and silently strips a trailing dot or space.
1099
1099
  The artifact would assemble here and be unextractable — or extract under a different name than
1100
- the launcher resolves against. Set \`gjsify.ship.name\` to the display name you want on disk.`);return S}function requiredToolsOn(n,S){return Array.isArray(n)?n:n[S]??[]}function defaultFormatIds(n){return Pz.filter(S=>Nz[S].layoutOs===n&&Nz[S].host.finishOn===`any`)}function formatIdsFor(n){return Pz.filter(S=>Nz[S].layoutOs===n)}function assertHostCanFinish(n,S=process.platform){let{finishOn:C}=n.host;if(!(C===`any`||C.includes(S)))throw Error(`gjsify ship: a ${n.id} artifact is packed on ${C.join(` or `)} and this host is ${S} (ADR 0024 § A1: a container is produced where its format's tool lives). Assembly is not host-bound, so the way across is the two-phase split: run \`gjsify ship --stage\` here, move \`ship/stage/\` to a ${C.join(`/`)} runner, and finish with \`gjsify ship --from-stage <dir> --target ${n.id}\`.`)}function assertToolsInstalled(n,S=isOnPath,C=process.platform){let N=requiredToolsOn(n.host.requiredTools,C),F=N.filter(n=>!S(n));if(F.length===0)return;let I=n.host.installHint;throw Error(`gjsify ship: packing a ${n.id} on ${C} needs ${N.join(` and `)}, and ${F.join(`, `)} ${F.length>1?`are`:`is`} not on PATH. ${I===void 0?`Install it`:`Install it (${I})`}, or drop this target — the other formats need no tools at all. \`gjsify ship --stage\` also works without ${F.join(`/`)}: the payload is assembled by this CLI and only the container needs them.`)}function parseFormatNames(n,S){let C=n.flatMap(n=>n.split(`,`)).map(n=>n.trim()).filter(n=>n.length>0),N=C.filter(n=>!Object.hasOwn(Nz,n));if(N.length>0)throw Error(`gjsify ship: unknown target${N.length>1?`s`:``} ${N.join(`, `)} in ${S}. Known targets: ${Pz.join(`, `)}.`);let F=[...new Set(C)].sort();if(F.length===0)throw Error(`gjsify ship: ${S} named no format. Known targets: ${Pz.join(`, `)}.`);return F}function resolveFormats(n,S){let C=parseFormatNames(n,`--target`),N=C.filter(n=>Nz[n].layoutOs!==S.os);if(N.length>0){let n=formatIdsFor(S.os),C=[...new Set(N.map(n=>Nz[n].layoutOs))];throw Error(`gjsify ship: ${N.join(`, `)} ${N.length>1?`wrap`:`wraps`} the ${C.join(`/`)} layout and this run assembles the ${S.name} one. `+(n.length===0?`No format wraps the ${S.name} layout — \`gjsify ship ${S.name} --stage\` assembles it and stops.`:`Formats for this layout: ${n.join(`, `)}.`)+` To build ${N.join(`, `)}, name the layout each wraps: ${C.map(n=>`\`gjsify ship ${Fz[n]??n} --target ${N.filter(S=>Nz[S].layoutOs===n).join(`,`)}\``).join(`, `)}.`)}return C.map(n=>Nz[n])}function configuredFormats(n,S){let C=parseFormatNames(n,"`gjsify.ship.targets`");return{formats:C.filter(n=>Nz[n].layoutOs===S.os).map(n=>Nz[n]),dropped:C.filter(n=>Nz[n].layoutOs!==S.os)}}function assertKindCanPack(n,S){if(S===`app`)return;let C=n.filter(n=>n.requiresDesktopEntry);if(C.length!==0)throw Error(`gjsify ship: ${C.map(n=>n.id).join(`, `)} cannot package a \`kind: "cli"\` project — the container needs a desktop entry at its root and a CLI stages none by design. Set \`gjsify.ship.kind\` to "app" if this is a GUI application, or ship it as a \`.deb\`, an \`.rpm\` or a Flatpak, none of which need one.`)}function canCarryTicket(n){switch(n){case`macos-app`:case`macos-app-dmg`:return!0;case`macos-app-zip`:case`deb`:case`rpm`:case`flatpak`:case`appimage`:case`windows-dir`:case`windows-dir-zip`:case`msi`:return!1;default:throw Error(`gjsify ship: no ticket answer for format "${String(n)}".`)}}var Sz,Cz,wz,Tz,Ez,Dz,Oz,kz,Az,jz,Mz,SHARE_LICENSE_DEST,WRITTEN_HERE,Nz,Pz,Fz,Iz=__esmMin(()=>{bN(),gz(),yz(),yR(),wR(),Sz={x64:`amd64`,arm64:`arm64`,ia32:`i386`,arm:`armhf`,riscv64:`riscv64`,ppc64:`ppc64el`,s390x:`s390x`},Cz={x64:`x86_64`,arm64:`aarch64`,ia32:`i686`,arm:`armv7hl`,riscv64:`riscv64`,ppc64:`ppc64le`,s390x:`s390x`},wz={x64:`x86_64`,arm64:`aarch64`,ia32:`i386`,arm:`arm`},Tz={x64:`x86_64`,arm64:`aarch64`,ia32:`i686`,arm:`armhf`},Ez={x64:`x86_64`,arm64:`arm64`},Dz={x64:`x64`},Oz=/[<>:"/\\|?*]/,kz=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|$)/i,Az=`a distro package declares its interpreter as a dependency instead of carrying one, and every distribution ships both`,jz='a `.app` a stranger downloads has to CARRY its interpreter, and there is no relocatable GJS to put in one — `packages/node-gi/scripts/build-gtk-runtime-darwin.mjs` records "GJS ships no relocation", which is why ADR 0024 § 4 derives Node on macOS and stage 7 is what would change it',Mz="there is no GJS host on Windows at all (ADR 0024 § 4) — not a system one to depend on and not a relocatable one to carry — so a `--app gjs` payload cannot be shipped this way. That is why § 4 derives Node here, and why `@gjsify/node-runtime-win32-x64` exists",SHARE_LICENSE_DEST=n=>`share/licenses/${n}/LICENSE`,WRITTEN_HERE=n=>({finishOn:`any`,requiredTools:[],oracle:{readWith:n,readOn:[`linux`],selfReading:!1}}),Nz={deb:{id:`deb`,layoutOs:`linux`,prefix:`/usr`,host:WRITTEN_HERE([`ar`,`tar`,`dpkg-deb`,`lintian`]),depends:`deb`,interpreters:[`gjs`,`node`],interpreterGap:Az,licenseDest:n=>`share/doc/${n}/copyright`,licenseKind:`debian-copyright`,changelogDest:n=>`share/doc/${n}/changelog.Debian.gz`,archName:debArch,fileName:(n,S)=>`${n.binaryName}_${n.version}-${n.release}_${S}.deb`,artifactKind:`file`},rpm:{id:`rpm`,layoutOs:`linux`,prefix:`/usr`,host:WRITTEN_HERE([`rpm`,`rpm2cpio`,`cpio`]),depends:`rpm`,interpreters:[`gjs`,`node`],interpreterGap:Az,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:rpmArch,fileName:(n,S)=>`${n.binaryName}-${n.version}-${n.release}.${S}.rpm`,artifactKind:`file`},flatpak:{id:`flatpak`,layoutOs:`linux`,prefix:`/app`,host:{finishOn:[`linux`],requiredTools:[`flatpak-builder`,`flatpak`],installHint:"Fedora: `sudo dnf install flatpak flatpak-builder`, Debian/Ubuntu: `sudo apt install flatpak flatpak-builder`",oracle:{readWith:[`flatpak`,`ostree`],readOn:[`linux`],selfReading:!1}},depends:null,interpreters:[`gjs`],interpreterGap:"a Flatpak runs against `org.gnome.Platform`, which ships `gjs` and no `node`. Node exists only as `org.freedesktop.Sdk.Extension.node2x`, and that extension puts node on the BUILD path, not in the runtime — so the artifact would install and then fail at `exec node`",licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:flatpakArch,fileName:(n,S)=>`${n.appId}-${n.version}-${n.release}.${S}.flatpak`,artifactKind:`file`},appimage:{id:`appimage`,layoutOs:`linux`,prefix:`/usr`,host:{finishOn:[`linux`],requiredTools:[cz],installHint:"no distribution packages it — take the release from https://github.com/AppImage/appimagetool/releases, `chmod +x` it and put it on PATH as `appimagetool`; or assemble here with `gjsify ship linux --stage` and pack where it is",oracle:{readWith:[`python3`,`unsquashfs`],readOn:[`linux`],selfReading:!1}},depends:null,interpreters:[`gjs`,`node`],interpreterGap:"an AppImage carries the application and takes its interpreter from the host, exactly as a distro package does — but with no dependency field to declare it in, so the requirement is printed at pack time and checked by `AppRun` at launch instead",licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:appImageArch,fileName:(n,S)=>`${n.binaryName}-${n.version}-${n.release}.${S}.AppImage`,artifactKind:`file`,requiresDesktopEntry:!0},"macos-app":{id:`macos-app`,layoutOs:`darwin`,prefix:``,host:{finishOn:`any`,requiredTools:[xR],installHint:SR,oracle:{readWith:[`python3`],readOn:[`linux`,`darwin`],selfReading:!1}},depends:null,interpreters:[`node`],interpreterGap:jz,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:macosArch,fileName:n=>`${n.name}.app`,artifactKind:`directory`},"macos-app-zip":{id:`macos-app-zip`,layoutOs:`darwin`,prefix:``,host:{finishOn:`any`,requiredTools:[xR],installHint:SR,oracle:{readWith:[`zipinfo`],readOn:[`linux`,`darwin`],selfReading:!1}},depends:null,interpreters:[`node`],interpreterGap:jz,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:macosArch,fileName:(n,S)=>`${n.binaryName}-${n.version}-${n.release}.macos.${S}.zip`,artifactKind:`file`},"macos-app-dmg":{id:`macos-app-dmg`,layoutOs:`darwin`,prefix:``,host:{finishOn:[`darwin`],requiredTools:[_z],installHint:"`hdiutil` is part of macOS and cannot be installed elsewhere — on a Mac it is /usr/bin/hdiutil, so an absent one means a broken installation rather than a missing package",oracle:{readWith:[`7z`,`dmg2img`,`fsck.hfsplus`],readOn:[`linux`],selfReading:!1}},depends:null,interpreters:[`node`],interpreterGap:jz,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:macosArch,fileName:(n,S)=>`${n.binaryName}-${n.version}-${n.release}.${S}.dmg`,artifactKind:`file`},"windows-dir":{id:`windows-dir`,layoutOs:`win32`,prefix:``,host:{finishOn:`any`,requiredTools:[xR],installHint:SR,oracle:{readWith:[`cmd`,`python3`],readOn:[`linux`,`win32`],selfReading:!1}},depends:null,interpreters:[`node`],interpreterGap:Mz,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:windowsArch,fileName:n=>windowsProgramDirName(n),artifactKind:`directory`},"windows-dir-zip":{id:`windows-dir-zip`,layoutOs:`win32`,prefix:``,host:{finishOn:`any`,requiredTools:[xR],installHint:SR,oracle:{readWith:[`zipinfo`],readOn:[`linux`,`darwin`],selfReading:!1}},depends:null,interpreters:[`node`],interpreterGap:Mz,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:windowsArch,fileName:(n,S)=>`${n.binaryName}-${n.version}-${n.release}.windows.${S}.zip`,artifactKind:`file`},msi:{id:`msi`,layoutOs:`win32`,prefix:``,host:{finishOn:[`linux`,`win32`],requiredTools:{linux:[xR,`wixl`],win32:[xR,`candle.exe`,`light.exe`]},installHint:`${SR}; the MSI compiler is Fedora: \`sudo dnf install msitools\`, Debian/Ubuntu: \`sudo apt install msitools\`, Windows: WiX Toolset v3.14 (https://github.com/wixtoolset/wix3/releases) with its \`bin\` directory on PATH`,oracle:{readWith:[`msiexec`,`msiinfo`],readOn:[`win32`,`linux`],selfReading:!1}},depends:null,interpreters:[`node`],interpreterGap:Mz,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:windowsArch,fileName:(n,S)=>`${n.binaryName}-${n.version}-${n.release}.${S}.msi`,artifactKind:`file`}},Pz=Object.keys(Nz),Fz=Object.fromEntries(_R.map(n=>[gR[n].os,n]))});function uuid5(n,S){let C=n.replace(/-/g,``),N=new Uint8Array(16);for(let n=0;n<16;n+=1)N[n]=Number.parseInt(C.slice(n*2,n*2+2),16);let F=createHash(`sha1`).update(N).update(new TextEncoder().encode(S)).digest(),I=Uint8Array.from(F.subarray(0,16));I[6]=(I[6]??0)&15|80,I[8]=(I[8]??0)&63|128;let H=[...I].map(n=>n.toString(16).padStart(2,`0`)).join(``);return[H.slice(0,8),H.slice(8,12),H.slice(12,16),H.slice(16,20),H.slice(20)].join(`-`)}function msiUpgradeCode(n){return uuid5(Lz,`upgrade\n${n.appId}`).toUpperCase()}function msiProductCode(n,S){let C=`product\n${n.appId}\n${n.version}\n${n.release}\n${S}`;return uuid5(Lz,C).toUpperCase()}function msiComponentGuid(n,S){return uuid5(Lz,`component\n${n.appId}\n${S}`).toUpperCase()}function msiProductVersion(n){let S=/^(\d+)\.(\d+)(?:\.(\d+))?$/.exec(n);if(S===null)throw Error(`gjsify ship: "${n}" is not a version an \`.msi\` can carry. Windows Installer's \`ProductVersion\` is \`major.minor.build\` and nothing else — no prerelease suffix, no build metadata.
1100
+ the launcher resolves against. Set \`gjsify.ship.name\` to the display name you want on disk.`);return S}function requiredToolsOn(n,S){return Array.isArray(n)?n:n[S]??[]}function defaultFormatIds(n){return Pz.filter(S=>Nz[S].layoutOs===n&&Nz[S].host.finishOn===`any`)}function formatIdsFor(n){return Pz.filter(S=>Nz[S].layoutOs===n)}function assertHostCanFinish(n,S=process.platform){let{finishOn:C}=n.host;if(!(C===`any`||C.includes(S)))throw Error(`gjsify ship: a ${n.id} artifact is packed on ${C.join(` or `)} and this host is ${S} (ADR 0024 § A1: a container is produced where its format's tool lives). Assembly is not host-bound, so the way across is the two-phase split: run \`gjsify ship --stage\` here, move \`ship/stage/\` to a ${C.join(`/`)} runner, and finish with \`gjsify ship --from-stage <dir> --target ${n.id}\`.`)}function assertToolsInstalled(n,S=isOnPath,C=process.platform){let N=requiredToolsOn(n.host.requiredTools,C),F=N.filter(n=>!S(n));if(F.length===0)return;let I=n.host.installHint;throw Error(`gjsify ship: packing a ${n.id} on ${C} needs ${N.join(` and `)}, and ${F.join(`, `)} ${F.length>1?`are`:`is`} not on PATH. ${I===void 0?`Install it`:`Install it (${I})`}, or drop this target — the other formats need no tools at all. \`gjsify ship --stage\` also works without ${F.join(`/`)}: the payload is assembled by this CLI and only the container needs them.`)}function parseFormatNames(n,S){let C=n.flatMap(n=>n.split(`,`)).map(n=>n.trim()).filter(n=>n.length>0),N=C.filter(n=>!Object.hasOwn(Nz,n));if(N.length>0)throw Error(`gjsify ship: unknown target${N.length>1?`s`:``} ${N.join(`, `)} in ${S}. Known targets: ${Pz.join(`, `)}.`);let F=[...new Set(C)].sort();if(F.length===0)throw Error(`gjsify ship: ${S} named no format. Known targets: ${Pz.join(`, `)}.`);return F}function resolveFormats(n,S){let C=parseFormatNames(n,`--target`),N=C.filter(n=>Nz[n].layoutOs!==S.os);if(N.length>0){let n=formatIdsFor(S.os),C=[...new Set(N.map(n=>Nz[n].layoutOs))];throw Error(`gjsify ship: ${N.join(`, `)} ${N.length>1?`wrap`:`wraps`} the ${C.join(`/`)} layout and this run assembles the ${S.name} one. `+(n.length===0?`No format wraps the ${S.name} layout — \`gjsify ship ${S.name} --stage\` assembles it and stops.`:`Formats for this layout: ${n.join(`, `)}.`)+` To build ${N.join(`, `)}, name the layout each wraps: ${C.map(n=>`\`gjsify ship ${Fz[n]??n} --target ${N.filter(S=>Nz[S].layoutOs===n).join(`,`)}\``).join(`, `)}.`)}return C.map(n=>Nz[n])}function configuredFormats(n,S){let C=parseFormatNames(n,"`gjsify.ship.targets`");return{formats:C.filter(n=>Nz[n].layoutOs===S.os).map(n=>Nz[n]),dropped:C.filter(n=>Nz[n].layoutOs!==S.os)}}function assertKindCanPack(n,S){if(S===`app`)return;let C=n.filter(n=>n.requiresDesktopEntry);if(C.length!==0)throw Error(`gjsify ship: ${C.map(n=>n.id).join(`, `)} cannot package a \`kind: "cli"\` project — the container needs a desktop entry at its root and a CLI stages none by design. Set \`gjsify.ship.kind\` to "app" if this is a GUI application, or ship it as a \`.deb\`, an \`.rpm\` or a Flatpak, none of which need one.`)}function canCarryTicket(n){switch(n){case`macos-app`:case`macos-app-dmg`:return!0;case`macos-app-zip`:case`deb`:case`rpm`:case`flatpak`:case`appimage`:case`windows-dir`:case`windows-dir-zip`:case`msi`:return!1;default:throw Error(`gjsify ship: no ticket answer for format "${String(n)}".`)}}var Sz,Cz,wz,Tz,Ez,Dz,Oz,kz,Az,jz,Mz,SHARE_LICENSE_DEST,WRITTEN_HERE,Nz,Pz,Fz,Iz=__esmMin(()=>{bN(),gz(),yz(),yR(),wR(),Sz={x64:`amd64`,arm64:`arm64`,ia32:`i386`,arm:`armhf`,riscv64:`riscv64`,ppc64:`ppc64el`,s390x:`s390x`},Cz={x64:`x86_64`,arm64:`aarch64`,ia32:`i686`,arm:`armv7hl`,riscv64:`riscv64`,ppc64:`ppc64le`,s390x:`s390x`},wz={x64:`x86_64`,arm64:`aarch64`,ia32:`i386`,arm:`arm`},Tz={x64:`x86_64`,arm64:`aarch64`,ia32:`i686`,arm:`armhf`},Ez={x64:`x86_64`,arm64:`arm64`},Dz={x64:`x64`},Oz=/[<>:"/\\|?*]/,kz=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|$)/i,Az=`a distro package declares its interpreter as a dependency instead of carrying one, and every distribution ships both`,jz='a `.app` a stranger downloads has to CARRY its interpreter, and there is no relocatable GJS to put in one — `packages/node-gi/scripts/build-gtk-runtime-darwin.mjs` records "GJS ships no relocation", which is why ADR 0024 § 4 derives Node on macOS and stage 7 is what would change it',Mz="there is no GJS host on Windows at all (ADR 0024 § 4) — not a system one to depend on and not a relocatable one to carry — so a `--app gjs` payload cannot be shipped this way. That is why § 4 derives Node here, and why `@gjsify/node-runtime-win32-x64` exists",SHARE_LICENSE_DEST=n=>`share/licenses/${n}/LICENSE`,WRITTEN_HERE=n=>({finishOn:`any`,requiredTools:[],oracle:{readWith:n,readOn:[`linux`],selfReading:!1}}),Nz={deb:{id:`deb`,layoutOs:`linux`,prefix:`/usr`,host:WRITTEN_HERE([`ar`,`tar`,`dpkg-deb`,`lintian`]),depends:`deb`,interpreters:[`gjs`,`node`],interpreterGap:Az,licenseDest:n=>`share/doc/${n}/copyright`,licenseKind:`debian-copyright`,changelogDest:n=>`share/doc/${n}/changelog.Debian.gz`,archName:debArch,fileName:(n,S)=>`${n.binaryName}_${n.version}-${n.release}_${S}.deb`,artifactKind:`file`},rpm:{id:`rpm`,layoutOs:`linux`,prefix:`/usr`,host:WRITTEN_HERE([`rpm`,`rpm2cpio`,`cpio`]),depends:`rpm`,interpreters:[`gjs`,`node`],interpreterGap:Az,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:rpmArch,fileName:(n,S)=>`${n.binaryName}-${n.version}-${n.release}.${S}.rpm`,artifactKind:`file`},flatpak:{id:`flatpak`,layoutOs:`linux`,prefix:`/app`,host:{finishOn:[`linux`],requiredTools:[`flatpak-builder`,`flatpak`],installHint:"Fedora: `sudo dnf install flatpak flatpak-builder`, Debian/Ubuntu: `sudo apt install flatpak flatpak-builder`",oracle:{readWith:[`flatpak`,`ostree`],readOn:[`linux`],selfReading:!1}},depends:null,interpreters:[`gjs`],interpreterGap:"a Flatpak runs against `org.gnome.Platform`, which ships `gjs` and no `node`. Node exists only as `org.freedesktop.Sdk.Extension.node2x`, and that extension puts node on the BUILD path, not in the runtime — so the artifact would install and then fail at `exec node`",licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:flatpakArch,fileName:(n,S)=>`${n.appId}-${n.version}-${n.release}.${S}.flatpak`,artifactKind:`file`},appimage:{id:`appimage`,layoutOs:`linux`,prefix:`/usr`,host:{finishOn:[`linux`],requiredTools:[cz,xR],installHint:`no distribution packages appimagetool — take the release from https://github.com/AppImage/appimagetool/releases, \`chmod +x\` it and put it on PATH as \`appimagetool\`; or assemble here with \`gjsify ship linux --stage\` and pack where it is. The schema compiler is packaged: ${SR}`,oracle:{readWith:[`python3`,`unsquashfs`],readOn:[`linux`],selfReading:!1}},depends:null,interpreters:[`gjs`,`node`],interpreterGap:"an AppImage carries the application and takes its interpreter from the host, exactly as a distro package does — but with no dependency field to declare it in, so the requirement is printed at pack time and checked by `AppRun` at launch instead",licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:appImageArch,fileName:(n,S)=>`${n.binaryName}-${n.version}-${n.release}.${S}.AppImage`,artifactKind:`file`,requiresDesktopEntry:!0},"macos-app":{id:`macos-app`,layoutOs:`darwin`,prefix:``,host:{finishOn:`any`,requiredTools:[xR],installHint:SR,oracle:{readWith:[`python3`],readOn:[`linux`,`darwin`],selfReading:!1}},depends:null,interpreters:[`node`],interpreterGap:jz,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:macosArch,fileName:n=>`${n.name}.app`,artifactKind:`directory`},"macos-app-zip":{id:`macos-app-zip`,layoutOs:`darwin`,prefix:``,host:{finishOn:`any`,requiredTools:[xR],installHint:SR,oracle:{readWith:[`zipinfo`],readOn:[`linux`,`darwin`],selfReading:!1}},depends:null,interpreters:[`node`],interpreterGap:jz,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:macosArch,fileName:(n,S)=>`${n.binaryName}-${n.version}-${n.release}.macos.${S}.zip`,artifactKind:`file`},"macos-app-dmg":{id:`macos-app-dmg`,layoutOs:`darwin`,prefix:``,host:{finishOn:[`darwin`],requiredTools:[_z],installHint:"`hdiutil` is part of macOS and cannot be installed elsewhere — on a Mac it is /usr/bin/hdiutil, so an absent one means a broken installation rather than a missing package",oracle:{readWith:[`7z`,`dmg2img`,`fsck.hfsplus`],readOn:[`linux`],selfReading:!1}},depends:null,interpreters:[`node`],interpreterGap:jz,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:macosArch,fileName:(n,S)=>`${n.binaryName}-${n.version}-${n.release}.${S}.dmg`,artifactKind:`file`},"windows-dir":{id:`windows-dir`,layoutOs:`win32`,prefix:``,host:{finishOn:`any`,requiredTools:[xR],installHint:SR,oracle:{readWith:[`cmd`,`python3`],readOn:[`linux`,`win32`],selfReading:!1}},depends:null,interpreters:[`node`],interpreterGap:Mz,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:windowsArch,fileName:n=>windowsProgramDirName(n),artifactKind:`directory`},"windows-dir-zip":{id:`windows-dir-zip`,layoutOs:`win32`,prefix:``,host:{finishOn:`any`,requiredTools:[xR],installHint:SR,oracle:{readWith:[`zipinfo`],readOn:[`linux`,`darwin`],selfReading:!1}},depends:null,interpreters:[`node`],interpreterGap:Mz,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:windowsArch,fileName:(n,S)=>`${n.binaryName}-${n.version}-${n.release}.windows.${S}.zip`,artifactKind:`file`},msi:{id:`msi`,layoutOs:`win32`,prefix:``,host:{finishOn:[`linux`,`win32`],requiredTools:{linux:[xR,`wixl`],win32:[xR,`candle.exe`,`light.exe`]},installHint:`${SR}; the MSI compiler is Fedora: \`sudo dnf install msitools\`, Debian/Ubuntu: \`sudo apt install msitools\`, Windows: WiX Toolset v3.14 (https://github.com/wixtoolset/wix3/releases) with its \`bin\` directory on PATH`,oracle:{readWith:[`msiexec`,`msiinfo`],readOn:[`win32`,`linux`],selfReading:!1}},depends:null,interpreters:[`node`],interpreterGap:Mz,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:windowsArch,fileName:(n,S)=>`${n.binaryName}-${n.version}-${n.release}.${S}.msi`,artifactKind:`file`}},Pz=Object.keys(Nz),Fz=Object.fromEntries(_R.map(n=>[gR[n].os,n]))});function uuid5(n,S){let C=n.replace(/-/g,``),N=new Uint8Array(16);for(let n=0;n<16;n+=1)N[n]=Number.parseInt(C.slice(n*2,n*2+2),16);let F=createHash(`sha1`).update(N).update(new TextEncoder().encode(S)).digest(),I=Uint8Array.from(F.subarray(0,16));I[6]=(I[6]??0)&15|80,I[8]=(I[8]??0)&63|128;let H=[...I].map(n=>n.toString(16).padStart(2,`0`)).join(``);return[H.slice(0,8),H.slice(8,12),H.slice(12,16),H.slice(16,20),H.slice(20)].join(`-`)}function msiUpgradeCode(n){return uuid5(Lz,`upgrade\n${n.appId}`).toUpperCase()}function msiProductCode(n,S){let C=`product\n${n.appId}\n${n.version}\n${n.release}\n${S}`;return uuid5(Lz,C).toUpperCase()}function msiComponentGuid(n,S){return uuid5(Lz,`component\n${n.appId}\n${S}`).toUpperCase()}function msiProductVersion(n){let S=/^(\d+)\.(\d+)(?:\.(\d+))?$/.exec(n);if(S===null)throw Error(`gjsify ship: "${n}" is not a version an \`.msi\` can carry. Windows Installer's \`ProductVersion\` is \`major.minor.build\` and nothing else — no prerelease suffix, no build metadata.
1101
1101
  Dropping the suffix is not an option this command will take silently: \`1.2.0~rc.1\` and \`1.2.0\` would
1102
1102
  become the same version, \`MajorUpgrade\` could not tell them apart, and installing one over the other
1103
1103
  would leave both on the machine. Set \`gjsify.ship.version\` to a plain \`x.y.z\`, or drop \`msi\` from the targets.`);let[C,N,F]=[Number(S[1]),Number(S[2]),Number(S[3]??`0`)];if(C>255||N>255||F>65535)throw Error(`gjsify ship: version "${n}" is outside what Windows Installer compares — \`major\` and \`minor\` are at most 255 and \`build\` at most 65535. A field over the limit is not rejected by the installer, it is
@@ -1110,7 +1110,7 @@ A misplaced catalogue installs and then shows nothing, which reads exactly like
1110
1110
  `)}function renderWindowsLauncher(n,S,C,N){let F=C.dirs(n),at=n=>`%HERE%${windowsPath(n)}`,I=[`@echo off`,`rem Generated by "gjsify ship" - do not edit.`,`setlocal`,`set "HERE=%~dp0"`,prependVar(`XDG_DATA_DIRS`,at(F.data))];N.gtkRuntimeDir!==void 0&&I.push(`set "GJSIFY_GTK_RUNTIME=${at(N.gtkRuntimeDir)}"`),N.nodeGiAddon!==void 0&&I.push(`set "NODE_GI_NATIVE=${at(N.nodeGiAddon)}"`),n.typelibFiles.length>0&&I.push(prependVar(`GI_TYPELIB_PATH`,at(F.native)),prependVar(`PATH`,at(F.native))),n.localeFiles.length>0&&I.push(`set "GJSIFY_LOCALE_DIR=${at(F.data)}\\locale"`),n.fontFiles.length>0&&I.push(`set "GJSIFY_FONT_DIR=${at(stagedFontDir(F.data,n.appId))}"`);let H=N.interpreter===void 0?void 0:`"${at(N.interpreter)}"`;return I.push(`${execLine(C,`"${at(F.bundle)}\\${windowsPath(S)}"`,n,H)} %*`,``),I.join(`\r
1111
1111
  `)}function prependVar(n,S){return`if defined ${n} (set "${n}=${S};%${n}%") else (set "${n}=${S}")`}function windowsPath(n){return n.split(`/`).filter(n=>n.length>0).join(`\\`)}function execLine(n,S,C,N){let F=n.name===`windows`?cmdQuote:shellQuote,I=C.execArgs.map(F).join(` `),H=N??(C.app===`node`?`node`:`gjs`);return`${C.app===`node`?H:`${H} -m`} ${S}${I?` ${I}`:``}`}var cB=__esmMin(()=>{Hs(),GL()});function createCpioArchive(n){let S=[],C=0;n.forEach((n,N)=>{let F=n.linkTarget===void 0?n.data??new Uint8Array:encodeUtf8(n.linkTarget),I=encodeUtf8(`${n.name}\0`),H=buildHeader({ino:n.ino??N+1,mode:n.mode,nlink:n.nlink??1,mtime:n.mtime??0,filesize:F.byteLength,namesize:I.byteLength});C=push(S,H,C),C=push(S,I,C),C=padTo4(S,C),C=push(S,F,C),C=padTo4(S,C)});let N=encodeUtf8(`TRAILER!!!\0`);return C=push(S,buildHeader({ino:0,mode:0,nlink:1,mtime:0,filesize:0,namesize:N.byteLength}),C),C=push(S,N,C),padTo4(S,C),concatBytes(S)}function buildHeader(n){let S=lB+hex8(n.ino)+hex8(n.mode)+hex8(0)+hex8(0)+hex8(n.nlink)+hex8(n.mtime)+hex8(n.filesize)+hex8(0)+hex8(0)+hex8(0)+hex8(0)+hex8(n.namesize)+hex8(0);if(S.length!==uB)throw Error(`gjsify ship: internal error — cpio header is ${S.length} bytes, expected ${uB}.`);return encodeUtf8(S)}function hex8(n){if(n<0||!Number.isInteger(n))throw Error(`gjsify ship: cpio header field must be a non-negative integer, got ${n}.`);let S=n.toString(16).toUpperCase();if(S.length>8)throw Error(`gjsify ship: cpio header field ${n} does not fit in 8 hex digits.`);return S.padStart(8,`0`)}function push(n,S,C){return S.byteLength>0&&n.push(S),C+S.byteLength}function padTo4(n,S){let C=S%4;if(C===0)return S;let N=4-C;return n.push(new Uint8Array(N)),S+N}var lB,uB,dB,fB,pB=__esmMin(()=>{AL(),lB=`070701`,uB=110,dB=32768,fB=16384});function buildRpmHeader(n,S){let C=[...n].sort((n,S)=>n.tag-S.tag),N=[],F=[],I=0;for(let n of C){if(n.tag<100)throw Error(`gjsify ship: rpm tag ${n.tag} is below 100 and would be rejected by hdrchkTag.`);let{data:S,count:C}=encodeValue(n.type,n.value,n.tag),H=_B[n.type],W=(H-I%H)%H;W>0&&(F.push(new Uint8Array(W)),I+=W),N.push({tag:n.tag,type:n.type,offset:I,count:C}),F.push(S),I+=S.byteLength}let H=I,W=N.length+1;F.push(indexEntry(S,7,-(hB*W),gB)),I+=hB;let q=new Uint8Array(mB.byteLength+8+W*hB+I),Y=new DataView(q.buffer);q.set(mB,0),Y.setUint32(8,W),Y.setUint32(12,I);let X=16;q.set(indexEntry(S,7,H,gB),X),X+=hB;for(let n of N)q.set(indexEntry(n.tag,n.type,n.offset,n.count),X),X+=hB;for(let n of F)q.set(n,X),X+=n.byteLength;return q}function indexEntry(n,S,C,N){let F=new Uint8Array(hB),I=new DataView(F.buffer);return I.setInt32(0,n),I.setInt32(4,S),I.setInt32(8,C),I.setInt32(12,N),F}function encodeValue(n,S,C){let N=new TextEncoder;switch(n){case 6:if(typeof S!=`string`)throw typeMismatch(C,`a string`);return{data:N.encode(`${S}\0`),count:1};case 8:case 9:{let n=typeof S==`string`?[S]:S;if(!Array.isArray(n))throw typeMismatch(C,`a string array`);if(n.length===0)throw Error(`gjsify ship: rpm tag ${C} has an empty array; omit it instead.`);return{data:N.encode(n.map(n=>`${n}\0`).join(``)),count:n.length}}case 7:if(!(S instanceof Uint8Array))throw typeMismatch(C,`binary data`);return{data:S,count:S.byteLength};case 3:case 4:{let N=typeof S==`number`?[S]:S;if(!Array.isArray(N))throw typeMismatch(C,`a number array`);if(N.length===0)throw Error(`gjsify ship: rpm tag ${C} has an empty array; omit it instead.`);let F=n===3?2:4,I=new Uint8Array(N.length*F),H=new DataView(I.buffer);return N.forEach((S,C)=>{n===3?H.setUint16(C*F,S&65535):H.setUint32(C*F,S>>>0)}),{data:I,count:N.length}}}}function typeMismatch(n,S){return Error(`gjsify ship: internal error — rpm tag ${n} expects ${S}.`)}function buildRpmLead(n){let S=new Uint8Array(96),C=new DataView(S.buffer);S.set([237,171,238,219],0),S[4]=3,S[5]=0,C.setInt16(6,0),C.setInt16(8,0);let N=new TextEncoder().encode(n).slice(0,65);return S.set(N,10),C.setInt16(76,0),C.setInt16(78,5),S}function padToEight(n){let S=(8-n.byteLength%8)%8;if(S===0)return n;let C=new Uint8Array(n.byteLength+S);return C.set(n,0),C}var mB,hB,gB,_B,vB=__esmMin(()=>{mB=Uint8Array.from([142,173,232,1,0,0,0,0]),hB=16,gB=16,_B={3:2,4:4,6:1,7:1,8:1,9:1}});async function buildRpm(n){let{settings:S,mtime:C}=n,N=collectFiles(n,`/${n.prefix.replace(/^\/+|\/+$/g,``)}`),F=createCpioArchive(N.map((n,S)=>({name:`.${n.path}`,mode:n.mode,data:n.data,mtime:C,ino:S+1}))),I=await gzipDeterministic(F),H=buildRpmHeader(mainHeaderEntries(n,N,F,I),63),W=concatBytes([H,I]),q=padToEight(buildRpmHeader([{tag:bB.SHA1HEADER,type:6,value:hashHex(`sha1`,H)},{tag:bB.SHA256HEADER,type:6,value:hashHex(`sha256`,H)},{tag:bB.SIZE,type:4,value:[W.byteLength]},{tag:bB.MD5,type:7,value:hashBytes(`md5`,W)},{tag:bB.PAYLOADSIZE,type:4,value:[F.byteLength]}],62));return concatBytes([buildRpmLead(`${S.binaryName}-${S.version}-${S.release}`),q,W])}function collectFiles(n,S){let C=n.payload.map(n=>{if(n.data.byteLength>4294967295)throw Error(`gjsify ship: ${n.path} is larger than 4 GiB, which needs rpm's LONGFILESIZES tag. That is not implemented — split the payload.`);return{path:`${S}/${n.path}`,mode:dB|n.mode&4095,data:n.data,isDirectory:!1}}),N=new Set;for(let n of C){let S=n.path.split(`/`).slice(1);S.pop();let C=``;for(let n of S)C=`${C}/${n}`,wB.has(C)||N.add(C)}for(let n of N)C.push({path:n,mode:fB|493,data:new Uint8Array,isDirectory:!0});return C.sort((n,S)=>n.path<S.path?-1:+(n.path>S.path))}function mainHeaderEntries(n,S,C,N){let{settings:F}=n,I=`${F.version}-${F.release}`,H=[],W=[],q=[];for(let n of S){let S=n.path.lastIndexOf(`/`),C=`${n.path.slice(0,S)}/`,N=H.indexOf(C);N===-1&&(N=H.push(C)-1),W.push(N),q.push(n.path.slice(S+1))}let Y=renderRpmScriptlets(readPayloadFacts(n.payload),n.prefix),X=buildRequires(n.depends,Y,readShebangInterpreters(n.payload)),Z=[{tag:yB.HEADERI18NTABLE,type:8,value:[`C`]},{tag:yB.NAME,type:6,value:F.binaryName},{tag:yB.VERSION,type:6,value:F.version},{tag:yB.RELEASE,type:6,value:F.release},{tag:yB.SUMMARY,type:9,value:[F.summary]},{tag:yB.DESCRIPTION,type:9,value:[F.description.join(`
1112
1112
 
1113
- `)]},{tag:yB.BUILDTIME,type:4,value:[n.mtime]},{tag:yB.BUILDHOST,type:6,value:`localhost`},{tag:yB.SIZE,type:4,value:[S.reduce((n,S)=>n+S.data.byteLength,0)]},{tag:yB.LICENSE,type:6,value:F.license},{tag:yB.GROUP,type:9,value:[F.group]},{tag:yB.OS,type:6,value:`linux`},{tag:yB.ARCH,type:6,value:n.archLabel},{tag:yB.SOURCERPM,type:6,value:`${F.binaryName}-${I}.src.rpm`},{tag:yB.RPMVERSION,type:6,value:`4.20.0`},{tag:yB.ENCODING,type:6,value:`utf-8`},{tag:yB.FILESIZES,type:4,value:S.map(n=>n.data.byteLength)},{tag:yB.FILEMODES,type:3,value:S.map(n=>n.mode)},{tag:yB.FILERDEVS,type:3,value:S.map(()=>0)},{tag:yB.FILEMTIMES,type:4,value:S.map(()=>n.mtime)},{tag:yB.FILEDIGESTS,type:8,value:S.map(n=>n.isDirectory?``:hashHex(`sha256`,n.data))},{tag:yB.FILELINKTOS,type:8,value:S.map(()=>``)},{tag:yB.FILEFLAGS,type:4,value:S.map(()=>0)},{tag:yB.FILEUSERNAME,type:8,value:S.map(()=>`root`)},{tag:yB.FILEGROUPNAME,type:8,value:S.map(()=>`root`)},{tag:yB.FILEVERIFYFLAGS,type:4,value:S.map(()=>4294967295)},{tag:yB.FILEDEVICES,type:4,value:S.map(()=>1)},{tag:yB.FILEINODES,type:4,value:S.map((n,S)=>S+1)},{tag:yB.FILELANGS,type:8,value:S.map(()=>``)},{tag:yB.FILEDIGESTALGO,type:4,value:[SB]},{tag:yB.DIRINDEXES,type:4,value:W},{tag:yB.BASENAMES,type:8,value:q},{tag:yB.DIRNAMES,type:8,value:H},{tag:yB.PROVIDENAME,type:8,value:[F.binaryName]},{tag:yB.PROVIDEFLAGS,type:4,value:[xB.EQUAL]},{tag:yB.PROVIDEVERSION,type:8,value:[I]},{tag:yB.REQUIRENAME,type:8,value:X.names},{tag:yB.REQUIREFLAGS,type:4,value:X.flags},{tag:yB.REQUIREVERSION,type:8,value:X.versions},{tag:yB.PAYLOADFORMAT,type:6,value:`cpio`},{tag:yB.PAYLOADCOMPRESSOR,type:6,value:`gzip`},{tag:yB.PAYLOADFLAGS,type:6,value:`9`},{tag:yB.PAYLOADDIGEST,type:8,value:[hashHex(`sha256`,N)]},{tag:yB.PAYLOADDIGESTALGO,type:4,value:[SB]},{tag:yB.PAYLOADDIGESTALT,type:8,value:[hashHex(`sha256`,C)]}];return assertParallelFileArrays(Z,S.length),F.homepage&&Z.push({tag:yB.URL,type:6,value:F.homepage}),Y.post!==void 0&&(Z.push({tag:yB.POSTIN,type:6,value:Y.post}),Z.push({tag:yB.POSTINPROG,type:6,value:`/bin/sh`})),Y.postun!==void 0&&(Z.push({tag:yB.POSTUN,type:6,value:Y.postun}),Z.push({tag:yB.POSTUNPROG,type:6,value:`/bin/sh`})),Z}function assertParallelFileArrays(n,S){let C=new Set([yB.FILESIZES,yB.FILEMODES,yB.FILERDEVS,yB.FILEMTIMES,yB.FILEDIGESTS,yB.FILELINKTOS,yB.FILEFLAGS,yB.FILEUSERNAME,yB.FILEGROUPNAME,yB.FILEVERIFYFLAGS,yB.FILEDEVICES,yB.FILEINODES,yB.FILELANGS,yB.DIRINDEXES,yB.BASENAMES]);for(let N of n){if(!C.has(N.tag))continue;let n=Array.isArray(N.value)?N.value.length:1;if(n!==S)throw Error(`gjsify ship: internal error — rpm tag ${N.tag} has ${n} values for ${S} files.`)}}function buildRequires(n,S,C){let N=[],F=[],I=[];for(let S of n){let n=parseDepend(S);N.push(n.name),F.push(senseFor(n.relation)),I.push(n.version??``)}S.post!==void 0&&(N.push(`/bin/sh`),F.push(xB.INTERP|xB.SCRIPT_POST),I.push(``)),S.postun!==void 0&&(N.push(`/bin/sh`),F.push(xB.INTERP|xB.SCRIPT_POSTUN),I.push(``));for(let n of C)N.push(n),F.push(xB.FIND_REQUIRES),I.push(``);for(let[n,S]of CB)N.push(n),F.push(xB.RPMLIB|xB.LESS|xB.EQUAL),I.push(S);return{names:N,flags:F,versions:I}}function senseFor(n){switch(n){case`>=`:return xB.GREATER|xB.EQUAL;case`>`:return xB.GREATER;case`<=`:return xB.LESS|xB.EQUAL;case`<`:return xB.LESS;case`=`:return xB.EQUAL;default:return 0}}function hashHex(n,S){return createHash(n).update(S).digest(`hex`)}function hashBytes(n,S){return new Uint8Array(createHash(n).update(S).digest())}var yB,bB,xB,SB,CB,wB,TB=__esmMin(()=>{No(),AL(),pB(),HL(),PR(),vB(),UL(),KL(),GL(),yB={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,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},bB={SIZE:1e3,MD5:1004,PAYLOADSIZE:1007,SHA1HEADER:269,SHA256HEADER:273},xB={LESS:2,GREATER:4,EQUAL:8,INTERP:256,SCRIPT_POST:1024,SCRIPT_POSTUN:4096,FIND_REQUIRES:16384,RPMLIB:1<<24},SB=8,CB=[[`rpmlib(CompressedFileNames)`,`3.0.4-1`],[`rpmlib(FileDigests)`,`4.6.0-1`],[`rpmlib(PayloadFilesHavePrefix)`,`4.0-1`]],wB=new Set([`/usr`,`/usr/bin`,`/usr/lib`,`/usr/lib64`,`/usr/libexec`,`/usr/sbin`,`/usr/share`,`/usr/${WL.applications}`,`/usr/share/doc`,`/usr/share/icons`,`/usr/share/licenses`,`/usr/share/man`,`/usr/${WL.metainfo}`,`/usr/share/glib-2.0`,`/usr/${WL.schemas}`,`/usr/${WL.fonts}`,`/etc`,`/opt`,`/var`])});async function assemble(n){let S=process.cwd(),C=n.os===void 0?hostLayout():resolveLayout(n.os),N=await new Config().forCommand(S),F=N.ship??{},I=N.flatpak??{},H=resolveShipApp({project:N.app,perTarget:F.app,layoutOs:C.os}),W=H.app;H.overridden&&ve.log(`${EB} runtime for ${C.name}: ${W} — \`${H.key}\` overrides \`gjsify.app${N.app===void 0?``:`: "${N.app}"`}\`.`);let q=readPackageJson$2(js(S,`package.json`))??{},Y,X=[];if(n.target!==void 0)Y=resolveFormats(n.target,C);else if(F.targets!==void 0){let n=configuredFormats(F.targets,C);Y=n.formats,n.dropped.length>0&&ve.log(`${EB} \`gjsify.ship.targets\` names ${n.dropped.join(`, `)}, which wrap another layout — not built for ${C.name}. Pass --target to ask for one explicitly.`)}else{let n=defaultFormatIds(C.os).map(n=>Nz[n]);Y=n.filter(n=>n.interpreters.includes(W)),X=n.filter(n=>!n.interpreters.includes(W)),X.length>0&&ve.log(`${EB} ${X.map(n=>n.id).join(`, `)} wrap the ${C.name} layout but cannot run \`${W}\`, which \`${H.key}\` resolves to — ${X[0]?.interpreterGap??``}. Set \`gjsify.ship.app.${C.os}\` to "${X[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.`)}n.stage||assertPackable(Y,C,n.os===void 0?`host`:`positional`,X);let Z=resolveSignPlan({flag:n.sign,config:F.sign,layoutOs:C.os}),te=resolveNotaryPlan({flag:n.notarize,layoutOs:C.os,sign:Z});if(n.stage&&assertNothingToSignYet(n),n.stage||(announceSigning(Z,te),Z.kind===`sign`&&assertHostCanSign(Z.signer)),n.stage||assertKindCanPack(Y,resolveShipKind(F,I)),!n.stage)for(let n of Y)assertCanPack(n);n[`skip-build`]||await runProjectBuild(S);let ne=resolveShipBundle({pkg:q,ship:F,layoutOs:C.os});ne.overridden&&ve.log(`${EB} entry for ${C.name}: ${ne.declared} — \`${ne.key}\` overrides \`gjsify.main\`.`);let re=discoverPayload({projectDir:S,pkg:q,ship:F,flatpakIcon:I.icon,declaredBundle:ne.declared,foreignBundles:ne.foreign}),{settings:ie,metadata:ae,warnings:oe}=resolveShipSettings({projectDir:S,pkg:q,ship:F,flatpak:I,cli:{outDir:n.out,arch:n.arch,layoutOs:C.os},discovered:re,app:W});for(let n of oe)ve.warn(`${EB} ${n}`);for(let n of Y)assertFormatCanRunInterpreter(n,ie.app);let se=readFileSync(ie.bundlePath,`utf-8`);assertEntryRunsUnder({interpreter:ie.app,source:se,entry:Ms(S,ie.bundlePath)||ie.bundlePath,appKey:H.key,bundleKey:ne.key,layoutOs:C.os});let Q=buildTimestamp(ie.bundlePath),ce={appId:ie.appId,name:ie.name,command:ie.binaryName,kind:ie.kind,metadata:ae,configKey:`gjsify.ship`,copyrightYear:new Date(Q*1e3).getUTCFullYear()};for(let n of validateAppMetadata(ce))ve.warn(`${EB} ${n.field} is not set — ${n.hint}`);ie.licenseFile!==void 0&&Ps(ie.licenseFile)!==S&&ve.log(`${EB} licence text from ${Ms(S,ie.licenseFile)} (this package carries none of its own)`);let le=localizeMetadata({metainfo:ie.kind===`app`?renderMetainfoApp$1(ce):renderMetainfoCli$1(ce),desktopEntry:ie.kind===`app`?renderDesktopEntry(ce):void 0},ie.localeFiles),ue=resolveCarriedRuntime(C,ie,S),de={bundleFiles:re.bundleFiles,launcher:renderLauncher(ie,Fs(ie.bundlePath),C,ue.launcher),metainfo:le.metainfo,desktopEntry:le.desktopEntry,licenseText:ie.licenseFile===void 0?void 0:readFileSync(ie.licenseFile,`utf-8`),changelogText:ie.changelogFile===void 0?void 0:readFileSync(ie.changelogFile,`utf-8`),mtime:Q},fe=Os(S,ie.outDir),pe=js(fe,`stage`),me=[...planStage(ie,de),...C.os===`linux`?[]:await compileSchemasForStage({schemaFiles:ie.schemaFiles,workDir:js(fe,`schemas`)})],he=placeStage(C,ie,me,ue.files);if(writeStage(pe,he),ve.log(`${EB} staged ${he.length} file(s) for ${C.name} in ${Ms(S,pe)}/`),n.verbose)for(let n of he)ve.log(`${EB} ${n.path}`);if(assertPayloadMatchesArch(readStage([pe],he),ie.arch),C.os!==`linux`){let n=linuxInstallDependent(me);if(n.length>0){ve.warn(`${EB} the ${C.name} layout carries ${n.length} file(s) whose Linux correctness comes from a package install step it has no equivalent for:`);let S={aborts:`ABORTS: `,unknown:`UNCLASSIFIED: `,inert:``};for(let{path:C,verdict:N,why:F}of n)ve.warn(`${EB} ${S[N]??``}${C} — ${F}`)}for(let n of ue.found)ve.log(`${EB} carries its own ${n}`);for(let n of ue.missing)ve.warn(`${EB} ${n}`);ue.launcher.interpreter===void 0&&C.runtimeGap!==void 0&&ve.warn(`${EB} ${C.runtimeGap}`),C.fontGap!==void 0&&me.some(n=>isUnder(n.path,WL.fonts))&&ve.warn(`${EB} ${C.fontGap}`),C.arches!==null&&!C.arches.only.includes(ie.arch)&&ve.warn(`${EB} this stage is labelled ${ie.arch} and the ${C.name} layout has no runtime for it — ${C.arches.why}. Nothing can pack this stage; \`--arch ${C.arches.only.join(`|`)}\` is what produces an artifact.`)}let ge=scanGiNamespaces(se);n.verbose&&ve.log(`${EB} gi namespaces: ${ge.join(`, `)||`(none)`}`);let _e=new Map;for(let n of Y)_e.set(n.id,(await planOverlay(ie,n,de)).map(n=>({...n,path:place(C,ie,n.path)})));let ye=readPayloadFacts(me);for(let n of Y){if(n.depends===null)continue;deriveDepends(n.depends,{namespaces:ge,hasIcons:ye.hasIcons,hasSchemas:ye.hasSchemas,interpreter:ie.app,extra:ie.extraDepends[n.depends],typelibPackages:ie.typelibPackages,bundledTypelibs:ye.bundledTypelibs,minGjsVersion:ie.minGjsVersion,minNodeVersion:ie.minNodeVersion});let S=ie.app===`node`?warnAboutNodeFloor(n.depends,ie.minNodeVersion):warnAboutGjsFloor(n.depends,ie.minGjsVersion);for(let n of S)ve.warn(`${EB} ${n}`)}let be=writeStageManifest({stageDir:pe,settings:ie,formats:Y,mtime:Q,namespaces:ge,staged:he,overlay:_e});if(n.stage){let n=X.length>0?`(none — ${X.map(n=>n.id).join(` and `)} need \`gjsify.ship.app.${C.os}: "node"\`)`:formatIdsFor(C.os).length===0?`(none — no format wraps the ${C.name} layout)`:`(none asked for)`,S=be.formats.join(`, `)||n;ve.log(`${EB} stage manifest: ${formatTarget(be.target)}, formats ${S}`);return}let xe=[];for(let S of Y)xe.push(await packOne({format:S,settings:ie,arch:ie.arch,staged:he,overlay:_e.get(S.id)??[],stageDir:pe,outRoot:fe,namespaces:ge,mtime:Q,sign:Z,notarize:te,verbose:n.verbose}));printArtifacts(S,xe)}function assertNothingToSignYet(n){let S=n.sign===void 0?n.notarize===void 0?void 0:`--notarize`:`--sign`;if(S!==void 0)throw Error(`gjsify ship: ${S} 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(n,S){n.kind===`skip`&&ve.warn(`${EB} ${n.message}`),S.kind===`skip`&&n.kind===`sign`&&ve.warn(`${EB} ${S.message}`)}function resolveCarriedRuntime(n,S,C){let N={files:[],launcher:{},found:[],missing:[]};if(n.os===`linux`||S.app!==`node`)return N;let F=`${n.os}-${S.arch}`;return isGtkRuntimeTarget(F)?stageAppRuntime({layout:n,identity:S,target:F,cwd:C,interpreter:isNodeRuntimeTarget(F)?resolveNodeRuntime(F,{cwd:C}):null}):N}async function finishFromStage(n,S){if(n.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(n[`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(n.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(n.os!==void 0)throw Error(`gjsify ship: the layout is decided when the stage is assembled, so "${n.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 C=process.cwd(),N=Os(C,S),F=readStageManifest(N);assertExpectedTarget(F,n[`expect-target`]);let I=layoutForOs(F.target.os);n.target===void 0&&assertPackable(F.formats.map(n=>Nz[n]),I,`stage`,defaultFormatIds(I.os).map(n=>Nz[n]).filter(n=>!n.interpreters.includes(F.settings.app)));let H=resolveFormats(n.target??F.formats,I);assertFormatsStaged(F,H);for(let n of H)assertCanPack(n);let W=resolveSignPlan({flag:n.sign,layoutOs:I.os}),q=resolveNotaryPlan({flag:n.notarize,layoutOs:I.os,sign:W});announceSigning(W,q),W.kind===`sign`&&assertHostCanSign(W.signer);for(let n of warnOnToolSkew(F))ve.warn(`${EB} ${n}`);let{mtime:Y,warnings:X}=resolveStageMtime(F);for(let n of X)ve.warn(`${EB} ${n}`);if(ve.log(`${EB} packing ${F.settings.binaryName} ${F.settings.version}-${F.settings.release} for ${formatTarget(F.target)} from ${Ms(C,N)||`.`}/`),n.verbose){for(let n of F.staged)ve.log(`${EB} ${n.path}`);ve.log(`${EB} gi namespaces: ${F.namespaces.join(`, `)||`(none)`}`)}let Z=n.out===void 0?Ps(N):Os(C,n.out),te=[];for(let S of H){if(assertFormatCanRunInterpreter(S,F.settings.app),S.depends!==null){let n=F.settings.app===`node`?warnAboutNodeFloor(S.depends,F.settings.minNodeVersion):warnAboutGjsFloor(S.depends,F.settings.minGjsVersion);for(let S of n)ve.warn(`${EB} ${S}`)}te.push(await packOne({format:S,settings:F.settings,arch:F.target.arch,staged:F.staged,overlay:overlayFiles(F,S.id),stageDir:N,outRoot:Z,namespaces:F.namespaces,mtime:Y,sign:W,notarize:q,verbose:n.verbose}))}printArtifacts(C,te)}async function packOne(n){let{format:S,settings:C,stageDir:N,outRoot:F,mtime:I}=n;assertOverlayIsLicensed(S.id,C.binaryName,n.overlay);let H=js(F,`overlay`,S.id);writeStage(H,n.overlay);let W=readStage([N,H],[...n.staged,...n.overlay]),q=readPayloadFacts(W),Y=S.depends===null?[]:deriveDepends(S.depends,{namespaces:n.namespaces,hasIcons:q.hasIcons,hasSchemas:q.hasSchemas,interpreter:C.app,extra:C.extraDepends[S.depends],typelibPackages:C.typelibPackages,bundledTypelibs:q.bundledTypelibs,minGjsVersion:C.minGjsVersion,minNodeVersion:C.minNodeVersion});assertPayloadMatchesArch(W,n.arch);let X=layoutForOs(S.layoutOs);assertLauncherMatchesInterpreter(W,X,C,C.app),assertLayoutSupportsArch(X,n.arch);let Z=n.sign.kind===`sign`?await signPayload({payload:W,identity:n.sign.identity,signer:n.sign.signer,workDir:js(F,`signed`,S.id),bundleRoot:X.root(C),entitlementsPath:js(F,`signed`,`${S.id}.entitlements.plist`),verbose:n.verbose,log:n=>ve.log(`${EB} ${n}`)}):W,te=S.archName(n.arch,isArchIndependent(Z)),ne={settings:C,payload:Z,prefix:S.prefix,depends:Y,archLabel:te,mtime:I},re=js(F,`out`);mkdirSync(re,{recursive:!0});let ie=js(re,S.fileName(C,te));switch(S.id){case`deb`:writeFileSync(ie,await buildDeb(ne));break;case`rpm`:writeFileSync(ie,await buildRpm(ne));break;case`flatpak`:await buildFlatpakBundle({settings:C,stageDir:N,overlayDir:H,stageManifestFile:nB,workDir:js(F,`flatpak`),target:ie,archLabel:te,verbose:n.verbose});break;case`appimage`:{let S=appImageHostRequirements({app:C.app,minGjsVersion:C.minGjsVersion,minNodeVersion:C.minNodeVersion,namespaces:n.namespaces,bundledTypelibs:q.bundledTypelibs}),N=appDirFor(F),H=appDirPayload(C,Z,S);writePayload(N,H,``),stampAppDirTimes(N,H,I),ve.log(`${EB} the AppImage takes these from the host: ${S.join(`, `)}`);let W=findPinnedRuntime(te);ve.log(`${EB} ${appImageRuntimeNotice(te,W)}`),await buildAppImage({appDir:N,target:ie,archLabel:te,runtimeFile:W,workDir:Ps(N),verbose:n.verbose});break}case`macos-app`:case`windows-dir`:writePayload(ie,Z,X.root(C));break;case`macos-app-dmg`:{let S=dmgVolumeDir(F);writePayload(S,Z,``),await buildDmgImage({volumeName:dmgVolumeName(C),sourceDir:S,target:ie,workDir:Ps(S),verbose:n.verbose});break}case`macos-app-zip`:writeFileSync(ie,buildZip(zipEntriesFromPayload(Z),I));break;case`windows-dir-zip`:writeFileSync(ie,buildZip(zipEntriesFromPayload(Z,windowsProgramDirName(C)),I));break;case`msi`:{let S=js(F,`msi`);writePayload(js(S,zz),Z,X.root(C)),await buildMsi({settings:C,files:Z.map(n=>({path:n.path,source:`${zz}/${n.path}`})),programDirName:windowsProgramDirName(C),archLabel:te,workDir:S,target:ie,verbose:n.verbose});break}default:{let n=S.id;throw Error(`gjsify ship: no packer is wired for format "${String(n)}".`)}}let ae=S.artifactKind===`directory`?directorySize(ie):statSync(ie).size;return n.notarize.kind===`notarize`&&(S.artifactKind===`directory`?ve.warn(`${EB} ${S.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:n.notarize,artifact:ie,verbose:n.verbose,log:n=>ve.log(`${EB} ${n}`)}),canCarryTicket(S.id)?await stapleArtifact({notary:n.notarize.notary,artifact:ie,verbose:n.verbose,log:n=>ve.log(`${EB} ${n}`)}):ve.warn(`${EB} ${S.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.`))),{format:S.id,path:ie,size:ae}}function printArtifacts(n,S){for(let C of S)ve.log(`${EB} ${C.format}: ${Ms(n,C.path)} (${C.size} bytes)`)}function assertCanPack(n){assertHostCanFinish(n),assertToolsInstalled(n)}function assertPackable(n,S,C,N=[]){if(n.length>0)return;if(N.length>0)throw Error(`gjsify ship: ${N.map(n=>n.id).join(` and `)} wrap the ${S.name} layout, and neither can run this project — ${N[0]?.interpreterGap??``}.\n Set \`gjsify.ship.app.${S.os}\` to "${N[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.
1113
+ `)]},{tag:yB.BUILDTIME,type:4,value:[n.mtime]},{tag:yB.BUILDHOST,type:6,value:`localhost`},{tag:yB.SIZE,type:4,value:[S.reduce((n,S)=>n+S.data.byteLength,0)]},{tag:yB.LICENSE,type:6,value:F.license},{tag:yB.GROUP,type:9,value:[F.group]},{tag:yB.OS,type:6,value:`linux`},{tag:yB.ARCH,type:6,value:n.archLabel},{tag:yB.SOURCERPM,type:6,value:`${F.binaryName}-${I}.src.rpm`},{tag:yB.RPMVERSION,type:6,value:`4.20.0`},{tag:yB.ENCODING,type:6,value:`utf-8`},{tag:yB.FILESIZES,type:4,value:S.map(n=>n.data.byteLength)},{tag:yB.FILEMODES,type:3,value:S.map(n=>n.mode)},{tag:yB.FILERDEVS,type:3,value:S.map(()=>0)},{tag:yB.FILEMTIMES,type:4,value:S.map(()=>n.mtime)},{tag:yB.FILEDIGESTS,type:8,value:S.map(n=>n.isDirectory?``:hashHex(`sha256`,n.data))},{tag:yB.FILELINKTOS,type:8,value:S.map(()=>``)},{tag:yB.FILEFLAGS,type:4,value:S.map(()=>0)},{tag:yB.FILEUSERNAME,type:8,value:S.map(()=>`root`)},{tag:yB.FILEGROUPNAME,type:8,value:S.map(()=>`root`)},{tag:yB.FILEVERIFYFLAGS,type:4,value:S.map(()=>4294967295)},{tag:yB.FILEDEVICES,type:4,value:S.map(()=>1)},{tag:yB.FILEINODES,type:4,value:S.map((n,S)=>S+1)},{tag:yB.FILELANGS,type:8,value:S.map(()=>``)},{tag:yB.FILEDIGESTALGO,type:4,value:[SB]},{tag:yB.DIRINDEXES,type:4,value:W},{tag:yB.BASENAMES,type:8,value:q},{tag:yB.DIRNAMES,type:8,value:H},{tag:yB.PROVIDENAME,type:8,value:[F.binaryName]},{tag:yB.PROVIDEFLAGS,type:4,value:[xB.EQUAL]},{tag:yB.PROVIDEVERSION,type:8,value:[I]},{tag:yB.REQUIRENAME,type:8,value:X.names},{tag:yB.REQUIREFLAGS,type:4,value:X.flags},{tag:yB.REQUIREVERSION,type:8,value:X.versions},{tag:yB.PAYLOADFORMAT,type:6,value:`cpio`},{tag:yB.PAYLOADCOMPRESSOR,type:6,value:`gzip`},{tag:yB.PAYLOADFLAGS,type:6,value:`9`},{tag:yB.PAYLOADDIGEST,type:8,value:[hashHex(`sha256`,N)]},{tag:yB.PAYLOADDIGESTALGO,type:4,value:[SB]},{tag:yB.PAYLOADDIGESTALT,type:8,value:[hashHex(`sha256`,C)]}];return assertParallelFileArrays(Z,S.length),F.homepage&&Z.push({tag:yB.URL,type:6,value:F.homepage}),Y.post!==void 0&&(Z.push({tag:yB.POSTIN,type:6,value:Y.post}),Z.push({tag:yB.POSTINPROG,type:6,value:`/bin/sh`})),Y.postun!==void 0&&(Z.push({tag:yB.POSTUN,type:6,value:Y.postun}),Z.push({tag:yB.POSTUNPROG,type:6,value:`/bin/sh`})),Z}function assertParallelFileArrays(n,S){let C=new Set([yB.FILESIZES,yB.FILEMODES,yB.FILERDEVS,yB.FILEMTIMES,yB.FILEDIGESTS,yB.FILELINKTOS,yB.FILEFLAGS,yB.FILEUSERNAME,yB.FILEGROUPNAME,yB.FILEVERIFYFLAGS,yB.FILEDEVICES,yB.FILEINODES,yB.FILELANGS,yB.DIRINDEXES,yB.BASENAMES]);for(let N of n){if(!C.has(N.tag))continue;let n=Array.isArray(N.value)?N.value.length:1;if(n!==S)throw Error(`gjsify ship: internal error — rpm tag ${N.tag} has ${n} values for ${S} files.`)}}function buildRequires(n,S,C){let N=[],F=[],I=[];for(let S of n){let n=parseDepend(S);N.push(n.name),F.push(senseFor(n.relation)),I.push(n.version??``)}S.post!==void 0&&(N.push(`/bin/sh`),F.push(xB.INTERP|xB.SCRIPT_POST),I.push(``)),S.postun!==void 0&&(N.push(`/bin/sh`),F.push(xB.INTERP|xB.SCRIPT_POSTUN),I.push(``));for(let n of C)N.push(n),F.push(xB.FIND_REQUIRES),I.push(``);for(let[n,S]of CB)N.push(n),F.push(xB.RPMLIB|xB.LESS|xB.EQUAL),I.push(S);return{names:N,flags:F,versions:I}}function senseFor(n){switch(n){case`>=`:return xB.GREATER|xB.EQUAL;case`>`:return xB.GREATER;case`<=`:return xB.LESS|xB.EQUAL;case`<`:return xB.LESS;case`=`:return xB.EQUAL;default:return 0}}function hashHex(n,S){return createHash(n).update(S).digest(`hex`)}function hashBytes(n,S){return new Uint8Array(createHash(n).update(S).digest())}var yB,bB,xB,SB,CB,wB,TB=__esmMin(()=>{No(),AL(),pB(),HL(),PR(),vB(),UL(),KL(),GL(),yB={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,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},bB={SIZE:1e3,MD5:1004,PAYLOADSIZE:1007,SHA1HEADER:269,SHA256HEADER:273},xB={LESS:2,GREATER:4,EQUAL:8,INTERP:256,SCRIPT_POST:1024,SCRIPT_POSTUN:4096,FIND_REQUIRES:16384,RPMLIB:1<<24},SB=8,CB=[[`rpmlib(CompressedFileNames)`,`3.0.4-1`],[`rpmlib(FileDigests)`,`4.6.0-1`],[`rpmlib(PayloadFilesHavePrefix)`,`4.0-1`]],wB=new Set([`/usr`,`/usr/bin`,`/usr/lib`,`/usr/lib64`,`/usr/libexec`,`/usr/sbin`,`/usr/share`,`/usr/${WL.applications}`,`/usr/share/doc`,`/usr/share/icons`,`/usr/share/licenses`,`/usr/share/man`,`/usr/${WL.metainfo}`,`/usr/share/glib-2.0`,`/usr/${WL.schemas}`,`/usr/${WL.fonts}`,`/etc`,`/opt`,`/var`])});async function assemble(n){let S=process.cwd(),C=n.os===void 0?hostLayout():resolveLayout(n.os),N=await new Config().forCommand(S),F=N.ship??{},I=N.flatpak??{},H=resolveShipApp({project:N.app,perTarget:F.app,layoutOs:C.os}),W=H.app;H.overridden&&ve.log(`${EB} runtime for ${C.name}: ${W} — \`${H.key}\` overrides \`gjsify.app${N.app===void 0?``:`: "${N.app}"`}\`.`);let q=readPackageJson$2(js(S,`package.json`))??{},Y,X=[];if(n.target!==void 0)Y=resolveFormats(n.target,C);else if(F.targets!==void 0){let n=configuredFormats(F.targets,C);Y=n.formats,n.dropped.length>0&&ve.log(`${EB} \`gjsify.ship.targets\` names ${n.dropped.join(`, `)}, which wrap another layout — not built for ${C.name}. Pass --target to ask for one explicitly.`)}else{let n=defaultFormatIds(C.os).map(n=>Nz[n]);Y=n.filter(n=>n.interpreters.includes(W)),X=n.filter(n=>!n.interpreters.includes(W)),X.length>0&&ve.log(`${EB} ${X.map(n=>n.id).join(`, `)} wrap the ${C.name} layout but cannot run \`${W}\`, which \`${H.key}\` resolves to — ${X[0]?.interpreterGap??``}. Set \`gjsify.ship.app.${C.os}\` to "${X[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.`)}n.stage||assertPackable(Y,C,n.os===void 0?`host`:`positional`,X);let Z=resolveSignPlan({flag:n.sign,config:F.sign,layoutOs:C.os}),te=resolveNotaryPlan({flag:n.notarize,layoutOs:C.os,sign:Z});if(n.stage&&assertNothingToSignYet(n),n.stage||(announceSigning(Z,te),Z.kind===`sign`&&assertHostCanSign(Z.signer)),n.stage||assertKindCanPack(Y,resolveShipKind(F,I)),!n.stage)for(let n of Y)assertCanPack(n);n[`skip-build`]||await runProjectBuild(S);let ne=resolveShipBundle({pkg:q,ship:F,layoutOs:C.os});ne.overridden&&ve.log(`${EB} entry for ${C.name}: ${ne.declared} — \`${ne.key}\` overrides \`gjsify.main\`.`);let re=discoverPayload({projectDir:S,pkg:q,ship:F,flatpakIcon:I.icon,declaredBundle:ne.declared,foreignBundles:ne.foreign}),{settings:ie,metadata:ae,warnings:oe}=resolveShipSettings({projectDir:S,pkg:q,ship:F,flatpak:I,cli:{outDir:n.out,arch:n.arch,layoutOs:C.os},discovered:re,app:W});for(let n of oe)ve.warn(`${EB} ${n}`);for(let n of Y)assertFormatCanRunInterpreter(n,ie.app);let se=readFileSync(ie.bundlePath,`utf-8`);assertEntryRunsUnder({interpreter:ie.app,source:se,entry:Ms(S,ie.bundlePath)||ie.bundlePath,appKey:H.key,bundleKey:ne.key,layoutOs:C.os});let Q=buildTimestamp(ie.bundlePath),ce={appId:ie.appId,name:ie.name,command:ie.binaryName,kind:ie.kind,metadata:ae,configKey:`gjsify.ship`,copyrightYear:new Date(Q*1e3).getUTCFullYear()};for(let n of validateAppMetadata(ce))ve.warn(`${EB} ${n.field} is not set — ${n.hint}`);ie.licenseFile!==void 0&&Ps(ie.licenseFile)!==S&&ve.log(`${EB} licence text from ${Ms(S,ie.licenseFile)} (this package carries none of its own)`);let le=localizeMetadata({metainfo:ie.kind===`app`?renderMetainfoApp$1(ce):renderMetainfoCli$1(ce),desktopEntry:ie.kind===`app`?renderDesktopEntry(ce):void 0},ie.localeFiles),ue=resolveCarriedRuntime(C,ie,S),de={bundleFiles:re.bundleFiles,launcher:renderLauncher(ie,Fs(ie.bundlePath),C,ue.launcher),metainfo:le.metainfo,desktopEntry:le.desktopEntry,licenseText:ie.licenseFile===void 0?void 0:readFileSync(ie.licenseFile,`utf-8`),changelogText:ie.changelogFile===void 0?void 0:readFileSync(ie.changelogFile,`utf-8`),mtime:Q},fe=Os(S,ie.outDir),pe=js(fe,`stage`),me=[...planStage(ie,de),...C.os===`linux`?[]:await compileSchemasForStage({schemaFiles:ie.schemaFiles,workDir:js(fe,`schemas`)})],he=placeStage(C,ie,me,ue.files);if(writeStage(pe,he),ve.log(`${EB} staged ${he.length} file(s) for ${C.name} in ${Ms(S,pe)}/`),n.verbose)for(let n of he)ve.log(`${EB} ${n.path}`);if(assertPayloadMatchesArch(readStage([pe],he),ie.arch),C.os!==`linux`){let n=linuxInstallDependent(me);if(n.length>0){ve.warn(`${EB} the ${C.name} layout carries ${n.length} file(s) whose Linux correctness comes from a package install step it has no equivalent for:`);let S={aborts:`ABORTS: `,unknown:`UNCLASSIFIED: `,inert:``};for(let{path:C,verdict:N,why:F}of n)ve.warn(`${EB} ${S[N]??``}${C} — ${F}`)}for(let n of ue.found)ve.log(`${EB} carries its own ${n}`);for(let n of ue.missing)ve.warn(`${EB} ${n}`);ue.launcher.interpreter===void 0&&C.runtimeGap!==void 0&&ve.warn(`${EB} ${C.runtimeGap}`),C.fontGap!==void 0&&me.some(n=>isUnder(n.path,WL.fonts))&&ve.warn(`${EB} ${C.fontGap}`),C.arches!==null&&!C.arches.only.includes(ie.arch)&&ve.warn(`${EB} this stage is labelled ${ie.arch} and the ${C.name} layout has no runtime for it — ${C.arches.why}. Nothing can pack this stage; \`--arch ${C.arches.only.join(`|`)}\` is what produces an artifact.`)}let ge=scanGiNamespaces(se);n.verbose&&ve.log(`${EB} gi namespaces: ${ge.join(`, `)||`(none)`}`);let _e=new Map;for(let n of Y)_e.set(n.id,(await planOverlay(ie,n,de)).map(n=>({...n,path:place(C,ie,n.path)})));let ye=readPayloadFacts(me);for(let n of Y){if(n.depends===null)continue;deriveDepends(n.depends,{namespaces:ge,hasIcons:ye.hasIcons,hasSchemas:ye.hasSchemas,interpreter:ie.app,extra:ie.extraDepends[n.depends],typelibPackages:ie.typelibPackages,bundledTypelibs:ye.bundledTypelibs,minGjsVersion:ie.minGjsVersion,minNodeVersion:ie.minNodeVersion});let S=ie.app===`node`?warnAboutNodeFloor(n.depends,ie.minNodeVersion):warnAboutGjsFloor(n.depends,ie.minGjsVersion);for(let n of S)ve.warn(`${EB} ${n}`)}let be=writeStageManifest({stageDir:pe,settings:ie,formats:Y,mtime:Q,namespaces:ge,staged:he,overlay:_e});if(n.stage){let n=X.length>0?`(none — ${X.map(n=>n.id).join(` and `)} need \`gjsify.ship.app.${C.os}: "node"\`)`:formatIdsFor(C.os).length===0?`(none — no format wraps the ${C.name} layout)`:`(none asked for)`,S=be.formats.join(`, `)||n;ve.log(`${EB} stage manifest: ${formatTarget(be.target)}, formats ${S}`);return}let xe=[];for(let S of Y)xe.push(await packOne({format:S,settings:ie,arch:ie.arch,staged:he,overlay:_e.get(S.id)??[],stageDir:pe,outRoot:fe,namespaces:ge,mtime:Q,sign:Z,notarize:te,verbose:n.verbose}));printArtifacts(S,xe)}function assertNothingToSignYet(n){let S=n.sign===void 0?n.notarize===void 0?void 0:`--notarize`:`--sign`;if(S!==void 0)throw Error(`gjsify ship: ${S} 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(n,S){n.kind===`skip`&&ve.warn(`${EB} ${n.message}`),S.kind===`skip`&&n.kind===`sign`&&ve.warn(`${EB} ${S.message}`)}function resolveCarriedRuntime(n,S,C){let N={files:[],launcher:{},found:[],missing:[]};if(n.os===`linux`||S.app!==`node`)return N;let F=`${n.os}-${S.arch}`;return isGtkRuntimeTarget(F)?stageAppRuntime({layout:n,identity:S,target:F,cwd:C,interpreter:isNodeRuntimeTarget(F)?resolveNodeRuntime(F,{cwd:C}):null}):N}async function finishFromStage(n,S){if(n.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(n[`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(n.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(n.os!==void 0)throw Error(`gjsify ship: the layout is decided when the stage is assembled, so "${n.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 C=process.cwd(),N=Os(C,S),F=readStageManifest(N);assertExpectedTarget(F,n[`expect-target`]);let I=layoutForOs(F.target.os);n.target===void 0&&assertPackable(F.formats.map(n=>Nz[n]),I,`stage`,defaultFormatIds(I.os).map(n=>Nz[n]).filter(n=>!n.interpreters.includes(F.settings.app)));let H=resolveFormats(n.target??F.formats,I);assertFormatsStaged(F,H);for(let n of H)assertCanPack(n);let W=resolveSignPlan({flag:n.sign,layoutOs:I.os}),q=resolveNotaryPlan({flag:n.notarize,layoutOs:I.os,sign:W});announceSigning(W,q),W.kind===`sign`&&assertHostCanSign(W.signer);for(let n of warnOnToolSkew(F))ve.warn(`${EB} ${n}`);let{mtime:Y,warnings:X}=resolveStageMtime(F);for(let n of X)ve.warn(`${EB} ${n}`);if(ve.log(`${EB} packing ${F.settings.binaryName} ${F.settings.version}-${F.settings.release} for ${formatTarget(F.target)} from ${Ms(C,N)||`.`}/`),n.verbose){for(let n of F.staged)ve.log(`${EB} ${n.path}`);ve.log(`${EB} gi namespaces: ${F.namespaces.join(`, `)||`(none)`}`)}let Z=n.out===void 0?Ps(N):Os(C,n.out),te=[];for(let S of H){if(assertFormatCanRunInterpreter(S,F.settings.app),S.depends!==null){let n=F.settings.app===`node`?warnAboutNodeFloor(S.depends,F.settings.minNodeVersion):warnAboutGjsFloor(S.depends,F.settings.minGjsVersion);for(let S of n)ve.warn(`${EB} ${S}`)}te.push(await packOne({format:S,settings:F.settings,arch:F.target.arch,staged:F.staged,overlay:overlayFiles(F,S.id),stageDir:N,outRoot:Z,namespaces:F.namespaces,mtime:Y,sign:W,notarize:q,verbose:n.verbose}))}printArtifacts(C,te)}async function packOne(n){let{format:S,settings:C,stageDir:N,outRoot:F,mtime:I}=n;assertOverlayIsLicensed(S.id,C.binaryName,n.overlay);let H=js(F,`overlay`,S.id);writeStage(H,n.overlay);let W=readStage([N,H],[...n.staged,...n.overlay]),q=readPayloadFacts(W),Y=S.depends===null?[]:deriveDepends(S.depends,{namespaces:n.namespaces,hasIcons:q.hasIcons,hasSchemas:q.hasSchemas,interpreter:C.app,extra:C.extraDepends[S.depends],typelibPackages:C.typelibPackages,bundledTypelibs:q.bundledTypelibs,minGjsVersion:C.minGjsVersion,minNodeVersion:C.minNodeVersion});assertPayloadMatchesArch(W,n.arch);let X=layoutForOs(S.layoutOs);assertLauncherMatchesInterpreter(W,X,C,C.app),assertLayoutSupportsArch(X,n.arch);let Z=n.sign.kind===`sign`?await signPayload({payload:W,identity:n.sign.identity,signer:n.sign.signer,workDir:js(F,`signed`,S.id),bundleRoot:X.root(C),entitlementsPath:js(F,`signed`,`${S.id}.entitlements.plist`),verbose:n.verbose,log:n=>ve.log(`${EB} ${n}`)}):W,te=S.archName(n.arch,isArchIndependent(Z)),ne={settings:C,payload:Z,prefix:S.prefix,depends:Y,archLabel:te,mtime:I},re=js(F,`out`);mkdirSync(re,{recursive:!0});let ie=js(re,S.fileName(C,te));switch(S.id){case`deb`:writeFileSync(ie,await buildDeb(ne));break;case`rpm`:writeFileSync(ie,await buildRpm(ne));break;case`flatpak`:await buildFlatpakBundle({settings:C,stageDir:N,overlayDir:H,stageManifestFile:nB,workDir:js(F,`flatpak`),target:ie,archLabel:te,verbose:n.verbose});break;case`appimage`:{let S=appImageHostRequirements({app:C.app,minGjsVersion:C.minGjsVersion,minNodeVersion:C.minNodeVersion,namespaces:n.namespaces,bundledTypelibs:q.bundledTypelibs}),N=appDirFor(F),H=appDirPayload(C,Z,S,await compileSchemasForPayload({payload:Z,workDir:js(F,`appimage-schemas`)}));writePayload(N,H,``),stampAppDirTimes(N,H,I),ve.log(`${EB} the AppImage takes these from the host: ${S.join(`, `)}`);let W=findPinnedRuntime(te);ve.log(`${EB} ${appImageRuntimeNotice(te,W)}`),await buildAppImage({appDir:N,target:ie,archLabel:te,runtimeFile:W,workDir:Ps(N),verbose:n.verbose});break}case`macos-app`:case`windows-dir`:writePayload(ie,Z,X.root(C));break;case`macos-app-dmg`:{let S=dmgVolumeDir(F);writePayload(S,Z,``),await buildDmgImage({volumeName:dmgVolumeName(C),sourceDir:S,target:ie,workDir:Ps(S),verbose:n.verbose});break}case`macos-app-zip`:writeFileSync(ie,buildZip(zipEntriesFromPayload(Z),I));break;case`windows-dir-zip`:writeFileSync(ie,buildZip(zipEntriesFromPayload(Z,windowsProgramDirName(C)),I));break;case`msi`:{let S=js(F,`msi`);writePayload(js(S,zz),Z,X.root(C)),await buildMsi({settings:C,files:Z.map(n=>({path:n.path,source:`${zz}/${n.path}`})),programDirName:windowsProgramDirName(C),archLabel:te,workDir:S,target:ie,verbose:n.verbose});break}default:{let n=S.id;throw Error(`gjsify ship: no packer is wired for format "${String(n)}".`)}}let ae=S.artifactKind===`directory`?directorySize(ie):statSync(ie).size;return n.notarize.kind===`notarize`&&(S.artifactKind===`directory`?ve.warn(`${EB} ${S.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:n.notarize,artifact:ie,verbose:n.verbose,log:n=>ve.log(`${EB} ${n}`)}),canCarryTicket(S.id)?await stapleArtifact({notary:n.notarize.notary,artifact:ie,verbose:n.verbose,log:n=>ve.log(`${EB} ${n}`)}):ve.warn(`${EB} ${S.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.`))),{format:S.id,path:ie,size:ae}}function printArtifacts(n,S){for(let C of S)ve.log(`${EB} ${C.format}: ${Ms(n,C.path)} (${C.size} bytes)`)}function assertCanPack(n){assertHostCanFinish(n),assertToolsInstalled(n)}function assertPackable(n,S,C,N=[]){if(n.length>0)return;if(N.length>0)throw Error(`gjsify ship: ${N.map(n=>n.id).join(` and `)} wrap the ${S.name} layout, and neither can run this project — ${N[0]?.interpreterGap??``}.\n Set \`gjsify.ship.app.${S.os}\` to "${N[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.
1114
1114
  \`gjsify ship ${S.name} --stage\` assembles the tree either way.`);let F=formatIdsFor(S.os).sort();if(F.length>0){let n=C===`stage`?`${S.name} --stage --target`:`${S.name} --target`;throw Error(`gjsify ship: this run records no formats for the ${S.name} layout, so there is nothing to pack — and it is not that none exist: ${F.join(`, `)} wrap it.\n An empty list means none were SELECTED. \`gjsify.ship.targets\` is filtered to the layout being assembled,
1115
1115
  so a configured list naming only another OS's formats leaves this one empty and says so at stage time.
1116
1116
  Name one where the payload is assembled: \`gjsify ship ${n} ${F[0]}\`.`)}let I=defaultFormatIds(`linux`).join(`,`),H={host:`This host is ${process.platform}, so \`gjsify ship\` assembled the ${S.name} layout. Assembly is not host-bound (ADR 0024 § A1), so the Linux packages are still one word away: \`gjsify ship linux\` builds ${I} from right here.`,positional:`\`gjsify ship ${S.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 ${S.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.`}[C];throw Error(`gjsify ship: no format wraps the ${S.name} layout, so there is nothing to pack. ${H} Every layout this gjsify knows has one (ADR 0024 stages 2-5), so this is a layout added without a \`FORMATS\` row.`)}function assertFormatCanRunInterpreter(n,S){if(!n.interpreters.includes(S))throw Error(`gjsify ship: this ${n.layoutOs} target runs \`${S}\`, and the ${n.id} runtime cannot run it — it provides ${n.interpreters.join(`, `)}.\n ${n.interpreterGap}.\n Build the formats that wrap this layout and can run it, or set \`gjsify.ship.app.${n.layoutOs}: "${n.interpreters.join(`" / "`)}"\` (which overrides \`gjsify.app\` for this target alone).`)}async function runProjectBuild(n){if(typeof readPackageJson$2(js(n,`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.");ve.log(`${EB} running the project's build script`);let S=await spawnToCompletion(`gjsify`,[`run`,`build`],{completion:`return`,cwd:n,stdio:`inherit`,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(S.code!==0)throw Error(`gjsify ship: the project's build script failed with ${describeExit(S)}.`)}var EB,DB,OB=__esmMin(()=>{ye(),Vl(),Hs(),_P(),nL(),tN(),jP(),FR(),HL(),sz(),XR(),gz(),yz(),bz(),xz(),Iz(),yR(),QR(),GL(),wR(),Bz(),Jz(),Zz(),eB(),PR(),rz(),sB(),cB(),TB(),KR(),rB(),iB(),EB=`[gjsify ship]`,DB={command:`ship [os]`,description:`Build installable artifacts (${Pz.join(`, `)}) from the current project.`,builder:n=>n.positional(`os`,{type:`string`,description:`Operating system whose LAYOUT to assemble (${_R.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(n=>!defaultFormatIds(`linux`).includes(n)).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(`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 n=>{if(n[`from-stage`]!==void 0)return await finishFromStage(n,n[`from-stage`]);await assemble(n)}}});function forceExit(n){if(process.exitCode=n,!gjsExit(n))return process.exit(n)}var kB=__esmMin(()=>{th()});function isReservedEntry(n){return n.startsWith(`.`)}function readManifest(n){try{let S=JSON.parse(readFileSync(js(n,`package.json`),`utf8`)),C={os:S.os,cpu:S.cpu,libc:S.libc};return{name:typeof S.name==`string`?S.name:void 0,version:typeof S.version==`string`?S.version:void 0,platform:declaresPlatform(C)?C:void 0}}catch{return null}}function collect(n,S){let C;try{C=readdirSync(n,{withFileTypes:!0})}catch{return}for(let N of C){if(isReservedEntry(N.name))continue;let C=js(n,N.name);if(N.name.startsWith(`@`)){let n;try{n=readdirSync(C,{withFileTypes:!0})}catch{continue}for(let N of n)isReservedEntry(N.name)||addPackage(js(C,N.name),S);continue}addPackage(C,S)}}function addPackage(n,S){let C=!1;try{C=lstatSync(n).isSymbolicLink()}catch{return}let N=readManifest(n);S.push({name:N?.name??n,version:N?.version??`0.0.0`,dir:n,linked:C,platform:N?.platform}),C||collect(js(n,`node_modules`),S)}function scanPrefix(n){let S=[];return collect(js(n,`node_modules`),S),S}function planPlatformPrune(n,S){let C=[];for(let N of n){if(N.linked||!N.platform)continue;let n=checkPlatform(N.platform,S);n.ok||C.push({pkg:N,bytes:0,verdict:n})}return C}function dirBytes(n){let S=0,C=[n];for(;C.length>0;){let n=C.pop(),N;try{N=readdirSync(n,{withFileTypes:!0})}catch{continue}for(let F of N){let N=js(n,F.name);if(F.isDirectory())C.push(N);else if(F.isFile())try{S+=statSync(N).size}catch{}}}return S}function planPrune(n){let S=scanPrefix(n.prefix),C=planPlatformPrune(S,n.target);for(let n of C)n.bytes=dirBytes(n.pkg.dir);return{prefix:n.prefix,target:n.target,scanned:S.length,entries:C,bytes:C.reduce((n,S)=>n+S.bytes,0)}}function executePrune(n,S={}){let C=[],N=[],F=[],I=S.remove??(n=>rmSync(n,{recursive:!0,force:!0,maxRetries:10}));if(!S.dryRun){for(let S of n.entries)try{I(S.pkg.dir),C.push(S)}catch(n){N.push({entry:S,error:n.message})}F.push(...pruneDeadBinLinks(n.prefix))}return{plan:n,removed:C,failed:N,bytes:C.reduce((n,S)=>n+S.bytes,0),binLinks:F}}function pruneDeadBinLinks(n){let S=js(n,`node_modules`,`.bin`),C=[],N;try{N=readdirSync(S,{withFileTypes:!0})}catch{return C}for(let n of N){let N=js(S,n.name);try{if(!lstatSync(N).isSymbolicLink()||existsSync(N))continue;unlinkSync(N),C.push(n.name)}catch{}}return C}function humanBytes(n){if(n<1024)return`${n} B`;let S=[`KB`,`MB`,`GB`],C=n/1024,N=0;for(;C>=1024&&N<S.length-1;)C/=1024,N+=1;return`${C.toFixed(1)} ${S[N]}`}function formatPruneReport(n,S){let{plan:C}=n,N=[`${C.prefix} · target ${describePlatformTarget(C.target)} · scanned ${C.scanned} package(s)`];if(C.entries.length===0)return N.push(`nothing to prune — no installed package declares a platform this target cannot use.`),N.join(`
@@ -40,7 +40,7 @@ import { assertHostCanFinish, assertKindCanPack, assertToolsInstalled, canCarryT
40
40
  import { assertLayoutSupportsArch, hostLayout, layoutForOs, place, placeStage, resolveLayout, LAYOUT_NAMES, } from '../utils/ship/layout.js';
41
41
  import { isNodeRuntimeTarget, resolveNodeRuntime } from '../utils/ship/node-runtime.js';
42
42
  import { isUnder, SHARE } from '../utils/ship/share-dirs.js';
43
- import { compileSchemasForStage } from '../utils/ship/schemas.js';
43
+ import { compileSchemasForPayload, compileSchemasForStage } from '../utils/ship/schemas.js';
44
44
  import { buildMsi, MSI_PAYLOAD_DIR } from '../utils/ship/msi.js';
45
45
  import { buildZip, zipEntriesFromPayload } from '../utils/ship/zip.js';
46
46
  import { assertEntryRunsUnder } from '../utils/ship/entry-interpreter.js';
@@ -416,7 +416,14 @@ async function assemble(args) {
416
416
  // `.deb`/`.rpm` postinst compiles the SYSTEM directory at install time
417
417
  // (`utils/ship/scripts.ts`), where our schemas merge with every other
418
418
  // package's — shipping a prebuilt cache there would be a file the install step
419
- // overwrites. So the compile is conditional on the layout and nothing else.
419
+ // overwrites, and one `rpm -e` takes away with it.
420
+ //
421
+ // WHICH IS WHY THIS CONDITION IS ABOUT THE STAGE AND NOT ABOUT INSTALL STEPS,
422
+ // a distinction that used to be invisible because the two agreed. They stopped
423
+ // agreeing when the AppImage landed: it takes the Linux layout and has no
424
+ // install step at all. It does not get its cache from here — a Linux stage
425
+ // serves three formats and only one of them wants one — it compiles its own
426
+ // into the AppDir, on its own pack path (`packOne`, `case 'appimage'`).
420
427
  const planned = [
421
428
  ...planStage(settings, stageInputs),
422
429
  ...(layout.os === 'linux'
@@ -988,7 +995,24 @@ async function packOne(input) {
988
995
  bundledTypelibs: facts.bundledTypelibs,
989
996
  });
990
997
  const appDir = appDirFor(outRoot);
991
- const tree = appDirPayload(settings, payload, hostRequirements);
998
+ // THE ONE FILE THIS FORMAT ADDS TO THE PAYLOAD, and the reason it is
999
+ // added HERE and not where every other layout's is (the stage, above).
1000
+ // An AppImage has no install step; the Linux layout it inherits assumes
1001
+ // one, because until this format existed every Linux artifact had a
1002
+ // `postinst`. The compile cannot move up into the stage: the Linux stage
1003
+ // is shared with the `.deb` and the `.rpm`, whose `share/glib-2.0/schemas`
1004
+ // is `/usr/share/glib-2.0/schemas` — the SYSTEM directory — and a cache
1005
+ // staged there is this app's 700 bytes installed over every other
1006
+ // package's schemas, then taken away with `rpm -e`.
1007
+ //
1008
+ // FROM THE PAYLOAD, like the host requirements two lines up and for the
1009
+ // same reason: `--from-stage` has the schema BYTES and not the project
1010
+ // directory they were read from.
1011
+ const schemaCache = await compileSchemasForPayload({
1012
+ payload,
1013
+ workDir: join(outRoot, 'appimage-schemas'),
1014
+ });
1015
+ const tree = appDirPayload(settings, payload, hostRequirements, schemaCache);
992
1016
  // ONE `writePayload` FOR THE WHOLE AppDir, prefix and root files
993
1017
  // together, because that call WIPES: two of them would leave the
994
1018
  // previous run's `<appId>.desktop` and icon at a root the second call
@@ -117,6 +117,17 @@ export declare function interpreterFloor(input: {
117
117
  * drifts is the one nothing tests: `tests/e2e/ship-layout` compares the staged
118
118
  * trees, not this script.
119
119
  *
120
+ * THAT CLAIM WAS RE-MEASURED AGAINST THE ARTIFACT and it holds — which is worth
121
+ * writing down, because when Learn6502 0.8.0's AppImage died on `GSettings schema
122
+ * … not found` this script was the obvious suspect and adding
123
+ * `GSETTINGS_SCHEMA_DIR` here was the obvious fix. It would have changed nothing.
124
+ * Measured on the real 0.8.0 image, by compiling `gschemas.compiled` into the
125
+ * extracted AppDir and touching NO environment variable anywhere: the application
126
+ * started. The launcher's `XDG_DATA_DIRS` was already pointing GSettings at the
127
+ * right directory; the directory had no cache in it. An extra export would have
128
+ * been a second name for a path that was already correct, and it would have
129
+ * "fixed" the bug by sitting next to the change that did.
130
+ *
120
131
  * WHAT IT DOES ADD is the refusal ADR 0024 § 9 asks for. An AppImage whose
121
132
  * interpreter is missing exits with the loader's own message — `gjs: not found`
122
133
  * from a shell, or nothing at all when a desktop launches it — and the user
@@ -205,10 +216,19 @@ export declare function selectAppDirIcon(payload: readonly PayloadEntry[], appId
205
216
  * those two are separate from each other (ADR 0024 § A3): three failures, three
206
217
  * different fixes — a different machine, a package, or a line in package.json.
207
218
  */
208
- export declare function assertAppImageIsPackable(payload: readonly PayloadEntry[], settings: PackSettings): void;
219
+ export declare function assertAppImageIsPackable(payload: readonly PayloadEntry[], settings: PackSettings, schemaCache?: PayloadEntry): void;
209
220
  /**
210
- * The whole AppDir as one payload: the prefix under `usr/`, plus the three files
211
- * at its root.
221
+ * The whole AppDir as one payload: the prefix under `usr/`, plus the compiled
222
+ * schema cache, plus the three files at its root.
223
+ *
224
+ * THE SCHEMA CACHE IS AN ARGUMENT AND NOT A COMPILE, so this function stays pure
225
+ * and so the one impure step in the AppDir has exactly one home (`packOne`). It
226
+ * is prefix-relative on the way in — `share/glib-2.0/schemas/gschemas.compiled`,
227
+ * the same shape every other entry has — and gets the `usr/` prefix from the same
228
+ * map below, because a second spelling of that prefix is the thing this packer
229
+ * spent a comment explaining it must not have. `undefined` is legal and means the
230
+ * payload has no schemas at all; a payload that HAS them and no cache is refused
231
+ * by {@link assertAppImageIsPackable}, not silently packed.
212
232
  *
213
233
  * PURE, AND ONE LIST RATHER THAN A WRITER, which is the shape `msi.ts` and
214
234
  * `dmg.ts` already have — `packOne` owns the single `writePayload` call for every
@@ -226,7 +246,7 @@ export declare function assertAppImageIsPackable(payload: readonly PayloadEntry[
226
246
  * its schemas one directory too high — at exit 0, until the first
227
247
  * `Gio.Settings.new()`.
228
248
  */
229
- export declare function appDirPayload(settings: PackSettings, payload: readonly PayloadEntry[], hostRequirements: readonly string[]): PayloadEntry[];
249
+ export declare function appDirPayload(settings: PackSettings, payload: readonly PayloadEntry[], hostRequirements: readonly string[], schemaCache?: PayloadEntry): PayloadEntry[];
230
250
  /**
231
251
  * The argument vector, as data.
232
252
  *
@@ -99,6 +99,7 @@ import { describeExit, spawnToCompletion } from '../spawn.js';
99
99
  import { encodeUtf8 } from './bytes.js';
100
100
  import { DEFAULT_GJS_FLOOR, DEFAULT_NODE_FLOOR, hostProvidedNamespaces } from './depends.js';
101
101
  import { LAYOUTS } from './layout.js';
102
+ import { isSchemaSource, SCHEMA_CACHE } from './schemas.js';
102
103
  import { SHARE } from './share-dirs.js';
103
104
  /** The tool this packer execs. One spelling, read by this module AND by the format row. */
104
105
  export const APPIMAGE_TOOL = 'appimagetool';
@@ -234,6 +235,17 @@ export function interpreterFloor(input) {
234
235
  * drifts is the one nothing tests: `tests/e2e/ship-layout` compares the staged
235
236
  * trees, not this script.
236
237
  *
238
+ * THAT CLAIM WAS RE-MEASURED AGAINST THE ARTIFACT and it holds — which is worth
239
+ * writing down, because when Learn6502 0.8.0's AppImage died on `GSettings schema
240
+ * … not found` this script was the obvious suspect and adding
241
+ * `GSETTINGS_SCHEMA_DIR` here was the obvious fix. It would have changed nothing.
242
+ * Measured on the real 0.8.0 image, by compiling `gschemas.compiled` into the
243
+ * extracted AppDir and touching NO environment variable anywhere: the application
244
+ * started. The launcher's `XDG_DATA_DIRS` was already pointing GSettings at the
245
+ * right directory; the directory had no cache in it. An extra export would have
246
+ * been a second name for a path that was already correct, and it would have
247
+ * "fixed" the bug by sitting next to the change that did.
248
+ *
237
249
  * WHAT IT DOES ADD is the refusal ADR 0024 § 9 asks for. An AppImage whose
238
250
  * interpreter is missing exits with the loader's own message — `gjs: not found`
239
251
  * from a shell, or nothing at all when a desktop launches it — and the user
@@ -435,7 +447,7 @@ function rootIconRank(path, appId) {
435
447
  * those two are separate from each other (ADR 0024 § A3): three failures, three
436
448
  * different fixes — a different machine, a package, or a line in package.json.
437
449
  */
438
- export function assertAppImageIsPackable(payload, settings) {
450
+ export function assertAppImageIsPackable(payload, settings, schemaCache) {
439
451
  const desktopEntry = `${SHARE.applications}/${settings.appId}.desktop`;
440
452
  if (!payload.some((entry) => entry.path === desktopEntry)) {
441
453
  throw new Error(`gjsify ship: an AppImage needs a desktop entry and this payload has no ${desktopEntry}. ` +
@@ -450,10 +462,40 @@ export function assertAppImageIsPackable(payload, settings) {
450
462
  'file keeping its own basename is an icon nothing looks up — point `gjsify.ship.icon` at a PNG ' +
451
463
  'or an SVG and it is renamed into the theme for you.');
452
464
  }
465
+ // THE THIRD REFUSAL, and the only one whose failure is invisible until a user
466
+ // double-clicks the file. The two above are decided by `package.json` and
467
+ // appimagetool would have caught both eventually; this one is decided by the
468
+ // PACK PATH and nothing catches it — the image builds, the oracle reads it
469
+ // back, every listing agrees, and the app dies at its first
470
+ // `Gio.Settings.new()` because `share/glib-2.0/schemas` holds a source with no
471
+ // compiled cache beside it. That is exactly what Learn6502 0.8.0 shipped.
472
+ //
473
+ // A GUARD ON THE PURE FUNCTION rather than a step in `packOne`, because this
474
+ // is the INVARIANT and not the procedure: whoever assembles an AppDir from a
475
+ // payload carrying schema sources owes it a cache, and an assembler that
476
+ // forgets must not be able to produce a tree. It is also what keeps the e2e
477
+ // honest — the suite calls this function to build its own AppDir, so it
478
+ // inherits the refusal instead of quietly modelling the defect.
479
+ if (schemaCache === undefined && payload.some((entry) => isSchemaSource(entry.path))) {
480
+ throw new Error(`gjsify ship: this payload stages GSettings schema sources under ${SHARE.schemas}/ and no ` +
481
+ `${SCHEMA_CACHE} was compiled for it. An AppImage has NO INSTALL STEP — that is the whole ` +
482
+ 'point of the format — so the `.deb`/`.rpm` postinst that compiles the system schema ' +
483
+ 'directory never runs, and GSettings aborts on a directory holding only sources. The AppDir ' +
484
+ `must carry ${SCHEMA_CACHE}; \`compileSchemasForPayload\` produces it from this payload.`);
485
+ }
453
486
  }
454
487
  /**
455
- * The whole AppDir as one payload: the prefix under `usr/`, plus the three files
456
- * at its root.
488
+ * The whole AppDir as one payload: the prefix under `usr/`, plus the compiled
489
+ * schema cache, plus the three files at its root.
490
+ *
491
+ * THE SCHEMA CACHE IS AN ARGUMENT AND NOT A COMPILE, so this function stays pure
492
+ * and so the one impure step in the AppDir has exactly one home (`packOne`). It
493
+ * is prefix-relative on the way in — `share/glib-2.0/schemas/gschemas.compiled`,
494
+ * the same shape every other entry has — and gets the `usr/` prefix from the same
495
+ * map below, because a second spelling of that prefix is the thing this packer
496
+ * spent a comment explaining it must not have. `undefined` is legal and means the
497
+ * payload has no schemas at all; a payload that HAS them and no cache is refused
498
+ * by {@link assertAppImageIsPackable}, not silently packed.
457
499
  *
458
500
  * PURE, AND ONE LIST RATHER THAN A WRITER, which is the shape `msi.ts` and
459
501
  * `dmg.ts` already have — `packOne` owns the single `writePayload` call for every
@@ -471,15 +513,18 @@ export function assertAppImageIsPackable(payload, settings) {
471
513
  * its schemas one directory too high — at exit 0, until the first
472
514
  * `Gio.Settings.new()`.
473
515
  */
474
- export function appDirPayload(settings, payload, hostRequirements) {
475
- assertAppImageIsPackable(payload, settings);
516
+ export function appDirPayload(settings, payload, hostRequirements, schemaCache) {
517
+ assertAppImageIsPackable(payload, settings, schemaCache);
476
518
  // Non-null by construction: the assertion above refuses a payload with
477
519
  // neither, and both reads are the SAME selection it made.
478
520
  const icon = selectAppDirIcon(payload, settings.appId);
479
521
  const desktopPath = `${SHARE.applications}/${settings.appId}.desktop`;
480
522
  const desktop = payload.find((entry) => entry.path === desktopPath);
481
523
  return [
482
- ...payload.map((entry) => ({ ...entry, path: `${APPDIR_PREFIX_DIR}/${entry.path}` })),
524
+ ...[...payload, ...(schemaCache === undefined ? [] : [schemaCache])].map((entry) => ({
525
+ ...entry,
526
+ path: `${APPDIR_PREFIX_DIR}/${entry.path}`,
527
+ })),
483
528
  { path: APPRUN_NAME, mode: 0o755, data: encodeUtf8(renderAppRun(settings, hostRequirements)) },
484
529
  // THE SAME BYTES, TWICE, and that is the AppImage specification rather
485
530
  // than a duplication to lift: the entry under `usr/share/applications` is
@@ -396,23 +396,56 @@ export const FORMATS = {
396
396
  // is: the container is an ELF runtime for Linux with a Linux filesystem
397
397
  // behind it, so the format is bound the way the application is.
398
398
  finishOn: ['linux'],
399
- // The SCHEMA COMPILER IS ABSENT here, unlike the two windows rows and
400
- // for the `.dmg`'s reason inverted: this layout HAS an install step in
401
- // every other format, and inside an AppImage it does not — there is no
402
- // `postinst` to run `glib-compile-schemas` in a read-only squashfs. But
403
- // `compileSchemasForStage` has already run at ASSEMBLY time and
404
- // `gschemas.compiled` is in the payload, so declaring the compiler on
405
- // the PACK path would refuse a `--from-stage` pack that works.
406
- requiredTools: [APPIMAGE_TOOL],
399
+ // THE SCHEMA COMPILER IS DECLARED HERE, and this row is the one place
400
+ // in the table where it sits on a PACK path. It used to be absent, on
401
+ // an argument that read well and was false: "this layout has an install
402
+ // step in every other format, and `compileSchemasForStage` has already
403
+ // run at assembly time, so declaring the compiler here would refuse a
404
+ // `--from-stage` pack that works." The second clause never held.
405
+ // `compileSchemasForStage` is skipped for `layout.os === 'linux'` —
406
+ // deliberately, because the Linux stage is SHARED with the `.deb` and
407
+ // the `.rpm`, whose `share/glib-2.0/schemas` is the SYSTEM directory
408
+ // that a postinst compiles and that our cache must never be installed
409
+ // over. So no Linux stage carries `gschemas.compiled`, a `--from-stage`
410
+ // AppImage pack has to produce it, and this row needs the tool.
411
+ //
412
+ // MEASURED, not reasoned: Learn6502 0.8.0's first CI-built AppImage
413
+ // shipped `eu.jumplink.Learn6502.gschema.xml` with nothing beside it
414
+ // and died at `Gio.Settings.new()` on the first line it ran.
415
+ //
416
+ // AND ONLY THIS ONE OF THE FOUR, which is the question the fix had to
417
+ // answer next and which is measured rather than argued.
418
+ // `cacheRefreshCommands` (`scripts.ts`) names four install-time steps,
419
+ // and an AppImage runs none of them. Three DEGRADE and one ABORTS:
420
+ //
421
+ // * `glib-compile-schemas` — ABORTS. GSettings refuses a schema
422
+ // directory holding a source with no cache; there is no fallback.
423
+ // * `gtk-update-icon-cache` — does not. Measured against the rebuilt
424
+ // 0.8.0 image on GTK 4 / glib 2.88.3: with `XDG_DATA_DIRS` pointing
425
+ // at the mounted `usr/share` and no `icon-theme.cache` anywhere,
426
+ // `Gtk.IconTheme.has_icon('eu.jumplink.Learn6502')` is `true` — and
427
+ // `false` for a name that is not there, so the probe discriminates.
428
+ // GTK scans the directory; the cache is a lookup optimisation.
429
+ // * `update-desktop-database`, `update-mime-database` — about a
430
+ // SYSTEM database an install writes into. An AppImage is not
431
+ // installed, so there is nothing for them to update: what a desktop
432
+ // reads is the entry at the AppDir root, via the runtime's own
433
+ // integration.
434
+ //
435
+ // `share/locale` needs no step on any layout — the launcher exports
436
+ // `GJSIFY_LOCALE_DIR` and gettext reads the `.mo` directly.
437
+ requiredTools: [APPIMAGE_TOOL, SCHEMA_COMPILER],
407
438
  // A URL AND NOT A PACKAGE NAME, and it is the first hint in this table
408
439
  // that has to be. `flatpak-builder` and `msitools` are in Fedora and in
409
440
  // Debian; `appimagetool` is in neither, so pointing at a distro would
410
441
  // send the reader to an `E: Unable to locate package`. The `--stage`
411
442
  // half is repeated here because it is the answer for a CI image that is
412
- // not going to grow a hand-installed binary.
413
- installHint: 'no distribution packages it — take the release from ' +
443
+ // not going to grow a hand-installed binary. The compiler IS packaged,
444
+ // so its half of the hint is the ordinary one.
445
+ installHint: 'no distribution packages appimagetool — take the release from ' +
414
446
  'https://github.com/AppImage/appimagetool/releases, `chmod +x` it and put it on PATH as ' +
415
- '`appimagetool`; or assemble here with `gjsify ship linux --stage` and pack where it is',
447
+ '`appimagetool`; or assemble here with `gjsify ship linux --stage` and pack where it is. ' +
448
+ `The schema compiler is packaged: ${SCHEMA_COMPILER_HINT}`,
416
449
  oracle: {
417
450
  // TWO READERS, NEITHER OF THEM appimagetool AND NEITHER OF THEM THE
418
451
  // ARTIFACT'S OWN RUNTIME — which is what `--appimage-offset` and
@@ -59,3 +59,49 @@ export interface CompileSchemasInput {
59
59
  * anyone claims otherwise.
60
60
  */
61
61
  export declare function compileSchemasForStage(input: CompileSchemasInput): Promise<StagedFile[]>;
62
+ /**
63
+ * The same compile, driven from a PAYLOAD instead of from the project's files.
64
+ *
65
+ * WHY A SECOND ENTRY POINT AND NOT A SECOND CALLER OF THE FIRST. The AppImage is
66
+ * the one format whose LAYOUT has an install step and whose ARTIFACT does not
67
+ * (`formats.ts`, the `appimage` row), so the compile cannot move to the place
68
+ * {@link compileSchemasForStage} runs: the Linux stage is SHARED with the `.deb`
69
+ * and the `.rpm`, whose `share/glib-2.0/schemas` is the SYSTEM directory. A cache
70
+ * staged there is our 700 bytes installed over every other package's schemas —
71
+ * regenerated by the postinst on dpkg, and REMOVED from the system on `rpm -e`.
72
+ * So the cache is produced on the AppImage's own pack path, into the AppDir, and
73
+ * nowhere else.
74
+ *
75
+ * FROM THE PAYLOAD AND NOT FROM `settings.schemaFiles`, which is the input that
76
+ * makes `--from-stage` work: a stage that crossed from another host carries the
77
+ * `.gschema.xml` bytes and not the project directory they came from. The same
78
+ * argument `packOne`'s header already makes for every other container here.
79
+ *
80
+ * `undefined` RATHER THAN AN EMPTY LIST when the payload has no schema, because
81
+ * the caller has to tell "nothing to compile" from "a cache is expected" — see
82
+ * `assertAppImageIsPackable`, which refuses the second case.
83
+ */
84
+ export declare function compileSchemasForPayload(input: {
85
+ payload: readonly {
86
+ path: string;
87
+ data: Uint8Array;
88
+ }[];
89
+ workDir: string;
90
+ }): Promise<{
91
+ path: string;
92
+ mode: number;
93
+ data: Uint8Array;
94
+ } | undefined>;
95
+ /**
96
+ * Whether a prefix-relative payload path is a GSettings schema SOURCE.
97
+ *
98
+ * Exported because two modules ask it of the same payload and a second spelling
99
+ * would let them disagree: this module decides what to compile, and
100
+ * `assertAppImageIsPackable` decides whether a compiled cache was owed.
101
+ *
102
+ * The extension is `glib-compile-schemas`'s own — it reads `*.gschema.xml` from
103
+ * the directory it is given and ignores everything else — so a payload that
104
+ * staged `foo.xml` under `share/glib-2.0/schemas` is a file GSettings never reads
105
+ * and this correctly says nothing about it.
106
+ */
107
+ export declare function isSchemaSource(path: string): boolean;
@@ -10,6 +10,19 @@
10
10
  // installs and does not start, which is the class this whole command exists
11
11
  // against.
12
12
  //
13
+ // AND THE PREDICATE IS THE ARTIFACT, NOT THE LAYOUT — which is what the first
14
+ // version of this module got wrong and what the AppImage measured. The condition
15
+ // was written as `layout.os === 'linux' ? [] : compile` (`commands/ship.ts`), and
16
+ // it stood for a year because on Linux every format DID have an install step.
17
+ // An AppImage has none — that is the entire point of the format — so it inherited
18
+ // the Linux layout, inherited the skip, and shipped an artifact that died on
19
+ // `Gio.Settings.new()` at its first line. Learn6502 0.8.0's AppImage, measured:
20
+ //
21
+ // JS ERROR: Error: GSettings schema eu.jumplink.Learn6502 not found
22
+ //
23
+ // A layout is not a claim about install steps. {@link compileSchemasForPayload}
24
+ // is what the format that has none calls for itself.
25
+ //
13
26
  // AT STAGE TIME, not at pack time, and that is the decision worth stating.
14
27
  // A stage is a deliverable in its own right — it is what crosses to the host
15
28
  // that finishes a `.dmg` or an `.msi` — and the warning `gjsify ship` prints
@@ -25,8 +38,8 @@
25
38
  // declare it: they wrap a tree that is already assembled, so a `--from-stage`
26
39
  // pack of one needs no GLib at all (the `macos-app-dmg` row says so).
27
40
  import { execFile } from 'node:child_process';
28
- import { basename, join } from 'node:path';
29
- import { copyFileSync, mkdirSync, rmSync } from 'node:fs';
41
+ import { basename, join, posix } from 'node:path';
42
+ import { copyFileSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
30
43
  import { promisify } from 'node:util';
31
44
  import { SHARE } from './share-dirs.js';
32
45
  const execFileAsync = promisify(execFile);
@@ -90,13 +103,88 @@ export async function compileSchemasForStage(input) {
90
103
  mkdirSync(input.workDir, { recursive: true });
91
104
  for (const schema of input.schemaFiles)
92
105
  copyFileSync(schema, join(input.workDir, basename(schema)));
106
+ await runSchemaCompiler(input.workDir);
107
+ return [
108
+ {
109
+ path: SCHEMA_CACHE,
110
+ mode: 0o644,
111
+ source: { kind: 'file', path: join(input.workDir, 'gschemas.compiled') },
112
+ },
113
+ ];
114
+ }
115
+ /**
116
+ * The same compile, driven from a PAYLOAD instead of from the project's files.
117
+ *
118
+ * WHY A SECOND ENTRY POINT AND NOT A SECOND CALLER OF THE FIRST. The AppImage is
119
+ * the one format whose LAYOUT has an install step and whose ARTIFACT does not
120
+ * (`formats.ts`, the `appimage` row), so the compile cannot move to the place
121
+ * {@link compileSchemasForStage} runs: the Linux stage is SHARED with the `.deb`
122
+ * and the `.rpm`, whose `share/glib-2.0/schemas` is the SYSTEM directory. A cache
123
+ * staged there is our 700 bytes installed over every other package's schemas —
124
+ * regenerated by the postinst on dpkg, and REMOVED from the system on `rpm -e`.
125
+ * So the cache is produced on the AppImage's own pack path, into the AppDir, and
126
+ * nowhere else.
127
+ *
128
+ * FROM THE PAYLOAD AND NOT FROM `settings.schemaFiles`, which is the input that
129
+ * makes `--from-stage` work: a stage that crossed from another host carries the
130
+ * `.gschema.xml` bytes and not the project directory they came from. The same
131
+ * argument `packOne`'s header already makes for every other container here.
132
+ *
133
+ * `undefined` RATHER THAN AN EMPTY LIST when the payload has no schema, because
134
+ * the caller has to tell "nothing to compile" from "a cache is expected" — see
135
+ * `assertAppImageIsPackable`, which refuses the second case.
136
+ */
137
+ export async function compileSchemasForPayload(input) {
138
+ const sources = input.payload.filter((entry) => isSchemaSource(entry.path));
139
+ if (sources.length === 0)
140
+ return undefined;
141
+ rmSync(input.workDir, { recursive: true, force: true, maxRetries: 5 });
142
+ mkdirSync(input.workDir, { recursive: true });
143
+ for (const source of sources) {
144
+ // `posix.basename` AND NOT `basename`, which the function above correctly
145
+ // uses one screen up. The two take different kinds of string: that one is
146
+ // handed a path read off THIS filesystem, where the host is the authority;
147
+ // this one is handed a `PayloadEntry.path`, which is POSIX-separated by its
148
+ // own type contract and built with `posix.join`. On win32 the host-aware
149
+ // `basename` also separates on `\`, so a Linux schema whose filename
150
+ // legitimately contains a backslash would be silently truncated while
151
+ // assembling a payload that is not the host's.
152
+ writeFileSync(join(input.workDir, posix.basename(source.path)), source.data);
153
+ }
154
+ await runSchemaCompiler(input.workDir);
155
+ return { path: SCHEMA_CACHE, mode: 0o644, data: readFileSync(join(input.workDir, 'gschemas.compiled')) };
156
+ }
157
+ /**
158
+ * Whether a prefix-relative payload path is a GSettings schema SOURCE.
159
+ *
160
+ * Exported because two modules ask it of the same payload and a second spelling
161
+ * would let them disagree: this module decides what to compile, and
162
+ * `assertAppImageIsPackable` decides whether a compiled cache was owed.
163
+ *
164
+ * The extension is `glib-compile-schemas`'s own — it reads `*.gschema.xml` from
165
+ * the directory it is given and ignores everything else — so a payload that
166
+ * staged `foo.xml` under `share/glib-2.0/schemas` is a file GSettings never reads
167
+ * and this correctly says nothing about it.
168
+ */
169
+ export function isSchemaSource(path) {
170
+ return path.startsWith(`${SHARE.schemas}/`) && path.endsWith('.gschema.xml');
171
+ }
172
+ /**
173
+ * `glib-compile-schemas --strict` over a directory, with the two failures named.
174
+ *
175
+ * Split out when the AppImage needed the same compile from different bytes. The
176
+ * MESSAGES are the reason it is one function rather than two copies: they are the
177
+ * whole value of this module over a bare `execFile`, and an ENOENT that named the
178
+ * package on one path and not the other is the drift this shape cannot have.
179
+ */
180
+ async function runSchemaCompiler(workDir) {
93
181
  try {
94
- await execFileAsync(SCHEMA_COMPILER, ['--strict', `--targetdir=${input.workDir}`, input.workDir]);
182
+ await execFileAsync(SCHEMA_COMPILER, ['--strict', `--targetdir=${workDir}`, workDir]);
95
183
  }
96
184
  catch (error) {
97
185
  const failure = error;
98
186
  if (failure.code === 'ENOENT') {
99
- throw new Error(`gjsify ship: this layout has no install step, so \`${SCHEMA_COMPILER}\` has to run HERE to ` +
187
+ throw new Error(`gjsify ship: this artifact has no install step, so \`${SCHEMA_COMPILER}\` has to run HERE to ` +
100
188
  `turn the payload's schemas into \`${SCHEMA_CACHE}\` — and it is not on PATH. ` +
101
189
  `Install it (${SCHEMA_COMPILER_HINT}). Without the compiled cache the launcher points ` +
102
190
  'XDG_DATA_DIRS at a schema directory GSettings aborts on, so the bundle would build and ' +
@@ -108,11 +196,4 @@ export async function compileSchemasForStage(input) {
108
196
  'cache\n is written without it, so the app still aborts on the schema that was dropped. ' +
109
197
  'Fix the\n file it names, or drop it from `gjsify.ship.schemas`.');
110
198
  }
111
- return [
112
- {
113
- path: SCHEMA_CACHE,
114
- mode: 0o644,
115
- source: { kind: 'file', path: join(input.workDir, 'gschemas.compiled') },
116
- },
117
- ];
118
199
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/cli",
3
- "version": "0.51.0",
3
+ "version": "0.51.1",
4
4
  "description": "CLI for Gjsify",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -142,21 +142,21 @@
142
142
  "cli"
143
143
  ],
144
144
  "dependencies": {
145
- "@gjsify/buffer": "^0.51.0",
146
- "@gjsify/create-app": "^0.51.0",
147
- "@gjsify/node-globals": "^0.51.0",
148
- "@gjsify/node-polyfills": "^0.51.0",
149
- "@gjsify/npm-registry": "^0.51.0",
150
- "@gjsify/resolve-npm": "^0.51.0",
151
- "@gjsify/rolldown-plugin-gjsify": "^0.51.0",
152
- "@gjsify/vite-plugin-blueprint": "^0.51.0",
153
- "@gjsify/rolldown-plugin-pnp": "^0.51.0",
154
- "@gjsify/semver": "^0.51.0",
155
- "@gjsify/tar": "^0.51.0",
156
- "@gjsify/tsc": "^0.51.0",
157
- "@gjsify/utils": "^0.51.0",
158
- "@gjsify/web-polyfills": "^0.51.0",
159
- "@gjsify/workspace": "^0.51.0",
145
+ "@gjsify/buffer": "^0.51.1",
146
+ "@gjsify/create-app": "^0.51.1",
147
+ "@gjsify/node-globals": "^0.51.1",
148
+ "@gjsify/node-polyfills": "^0.51.1",
149
+ "@gjsify/npm-registry": "^0.51.1",
150
+ "@gjsify/resolve-npm": "^0.51.1",
151
+ "@gjsify/rolldown-plugin-gjsify": "^0.51.1",
152
+ "@gjsify/vite-plugin-blueprint": "^0.51.1",
153
+ "@gjsify/rolldown-plugin-pnp": "^0.51.1",
154
+ "@gjsify/semver": "^0.51.1",
155
+ "@gjsify/tar": "^0.51.1",
156
+ "@gjsify/tsc": "^0.51.1",
157
+ "@gjsify/utils": "^0.51.1",
158
+ "@gjsify/web-polyfills": "^0.51.1",
159
+ "@gjsify/workspace": "^0.51.1",
160
160
  "acorn": "^8.17.0",
161
161
  "cosmiconfig": "^9.0.2",
162
162
  "get-tsconfig": "^4.14.0",
@@ -165,13 +165,13 @@
165
165
  "yargs": "^18.0.0"
166
166
  },
167
167
  "devDependencies": {
168
- "@gjsify/unit": "^0.51.0",
168
+ "@gjsify/unit": "^0.51.1",
169
169
  "@types/yargs": "^17.0.35",
170
170
  "typescript": "^6.0.3"
171
171
  },
172
172
  "peerDependencies": {
173
- "@gjsify/oxfmt-native": "^0.51.0",
174
- "@gjsify/rolldown-native": "^0.51.0"
173
+ "@gjsify/oxfmt-native": "^0.51.1",
174
+ "@gjsify/rolldown-native": "^0.51.1"
175
175
  },
176
176
  "peerDependenciesMeta": {
177
177
  "@gjsify/oxfmt-native": {