@gjsify/cli 0.64.6 → 0.64.8
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 +11 -11
- package/lib/commands/ship.js +12 -2
- package/lib/commands/showcase.js +1 -1
- package/lib/utils/ship/app-runtime.d.ts +1 -1
- package/lib/utils/ship/app-runtime.js +1 -1
- package/lib/utils/ship/entry-interpreter.js +5 -1
- package/lib/utils/ship/formats.js +11 -15
- package/lib/utils/ship/layout.js +30 -29
- package/lib/utils/ship/msi.js +20 -3
- package/lib/utils/ship/node-runtime.d.ts +1 -1
- package/lib/utils/ship/node-runtime.js +1 -1
- package/lib/utils/ship/payload.d.ts +3 -1
- package/lib/utils/ship/payload.js +11 -1
- package/lib/utils/ship/pe-launcher.js +11 -1
- package/package.json +20 -20
package/dist/cli.gjs.mjs
CHANGED
|
@@ -145,7 +145,7 @@ fi
|
|
|
145
145
|
`)}`:``;n.fail(N(`Missing required argument: %s`,`Missing required arguments: %s`,Object.keys(C).length,Object.keys(C).join(`, `)+S))}},F.unknownArguments=function unknownArguments(S,C,I,H,W=!0){let q=t.getInternalMethods().getCommandInstance().getCommands(),Y=[],X=t.getInternalMethods().getContext();if(Object.keys(S).forEach(n=>{!Sp.includes(n)&&!Object.prototype.hasOwnProperty.call(I,n)&&!Object.prototype.hasOwnProperty.call(t.getInternalMethods().getParseContext(),n)&&!F.isValidAndSomeAliasIsNotNew(n,C)&&Y.push(n)}),W&&(X.commands.length>0||q.length>0||H)&&S._.slice(X.commands.length).forEach(t=>{q.includes(``+t)||Y.push(``+t)}),W){let n=t.getDemandedCommands()._?.max||0,C=X.commands.length+n;C<S._.length&&S._.slice(C).forEach(t=>{t=String(t),!X.commands.includes(t)&&!Y.includes(t)&&Y.push(t)})}Y.length&&n.fail(N(`Unknown argument: %s`,`Unknown arguments: %s`,Y.length,Y.map(t=>t.trim()?t:`"${t}"`).join(`, `)))},F.unknownCommands=function unknownCommands(S){let C=t.getInternalMethods().getCommandInstance().getCommands(),F=[],I=t.getInternalMethods().getContext();return(I.commands.length>0||C.length>0)&&S._.slice(I.commands.length).forEach(t=>{C.includes(``+t)||F.push(``+t)}),F.length>0?(n.fail(N(`Unknown command: %s`,`Unknown commands: %s`,F.length,F.join(`, `))),!0):!1},F.isValidAndSomeAliasIsNotNew=function isValidAndSomeAliasIsNotNew(n,S){if(!Object.prototype.hasOwnProperty.call(S,n))return!1;let C=t.parsed.newAliases;return[n,...S[n]].some(t=>!Object.prototype.hasOwnProperty.call(C,t)||!C[n])},F.limitedChoices=function limitedChoices(S){let N=t.getOptions(),F={};if(!Object.keys(N.choices).length)return;Object.keys(S).forEach(t=>{Sp.indexOf(t)===-1&&Object.prototype.hasOwnProperty.call(N.choices,t)&&[].concat(S[t]).forEach(n=>{N.choices[t].indexOf(n)===-1&&n!==void 0&&(F[t]=(F[t]||[]).concat(n))})});let I=Object.keys(F);if(!I.length)return;let H=C(`Invalid values:`);I.forEach(t=>{H+=`\n ${C(`Argument: %s, Given: %s, Choices: %s`,t,n.stringifiedValues(F[t]),n.stringifiedValues(N.choices[t]))}`}),n.fail(H)};let I={};F.implies=function implies(n,C){argsert(`<string|object> [array|number|string]`,[n,C],arguments.length),typeof n==`object`?Object.keys(n).forEach(t=>{F.implies(t,n[t])}):(t.global(n),I[n]||(I[n]=[]),Array.isArray(C)?C.forEach(t=>F.implies(n,t)):(assertNotStrictEqual(C,void 0,S),I[n].push(C)))},F.getImplied=function getImplied(){return I};function keyExists(t,n){let S=Number(n);return n=isNaN(S)?n:S,typeof n==`number`?n=t._.length>=n:n.match(/^--no-.+/)?(n=n.match(/^--no-(.+)/)[1],n=!Object.prototype.hasOwnProperty.call(t,n)):n=Object.prototype.hasOwnProperty.call(t,n),n}F.implications=function implications(t){let S=[];if(Object.keys(I).forEach(n=>{let C=n;(I[n]||[]).forEach(n=>{let N=C,F=n;N=keyExists(t,N),n=keyExists(t,n),N&&!n&&S.push(` ${C} -> ${F}`)})}),S.length){let t=`${C(`Implications failed:`)}\n`;S.forEach(n=>{t+=n}),n.fail(t)}};let H={};F.conflicts=function conflicts(n,S){argsert(`<string|object> [array|string]`,[n,S],arguments.length),typeof n==`object`?Object.keys(n).forEach(t=>{F.conflicts(t,n[t])}):(t.global(n),H[n]||(H[n]=[]),Array.isArray(S)?S.forEach(t=>F.conflicts(n,t)):H[n].push(S))},F.getConflicting=()=>H,F.conflicting=function conflictingFn(N){Object.keys(N).forEach(t=>{H[t]&&H[t].forEach(S=>{S&&N[t]!==void 0&&N[S]!==void 0&&n.fail(C(`Arguments %s and %s are mutually exclusive`,t,S))})}),t.getInternalMethods().getParserConfiguration()[`strip-dashed`]&&Object.keys(H).forEach(t=>{H[t].forEach(F=>{F&&N[S.Parser.camelCase(t)]!==void 0&&N[S.Parser.camelCase(F)]!==void 0&&n.fail(C(`Arguments %s and %s are mutually exclusive`,t,F))})})},F.recommendCommands=function recommendCommands(t,S){S=S.sort((t,n)=>n.length-t.length);let N=null,F=1/0;for(let n=0,C;(C=S[n])!==void 0;n++){let n=levenshtein(t,C);n<=3&&n<F&&(F=n,N=C)}N&&n.fail(C(`Did you mean %s?`,N))},F.reset=function reset(t){return I=objFilter(I,n=>!t[n]),H=objFilter(H,n=>!t[n]),F};let W=[];return F.freeze=function freeze(){W.push({implied:I,conflicting:H})},F.unfreeze=function unfreeze(){let t=W.pop();assertNotStrictEqual(t,void 0,S),{implied:I,conflicting:H}=t},F}var Sp,Cp=__esmMin(()=>{sp(),rp(),xp(),pp(),Sp=[`$0`,`--`,`_`]});function YargsFactory(t){return(n=[],S=t.process.cwd(),C)=>{let N=new YargsInstance(n,S,C,t);return Object.defineProperty(N,"argv",{get:()=>N.parse(),enumerable:!0}),N.help(),N.version(),N}}function isYargsInstance(t){return!!t&&typeof t.getInternalMethods==`function`}var __classPrivateFieldSet,__classPrivateFieldGet,wp,Tp,Ep,Dp,Op,kp,Ap,jp,Mp,Np,Pp,Fp,Ip,Lp,Rp,zp,Bp,Vp,Hp,Up,Wp,Gp,Kp,qp,Jp,Yp,Xp,Zp,Qp,$p,em,tm,nm,im,am,om,sm,cm,lm,um,dm,fm,pm,mm,hm,gm,_m,vm,ym,bm,xm,Sm,Cm,wm,Tm,Em,Dm,Om,km,Am,jm,Mm,Nm,Pm,Fm,Im,Lm,Rm,zm,Bm,Vm,Hm,YargsInstance,Um=__esmMin(()=>{_e(),fp(),rp(),Tl(),hp(),sp(),bp(),Cp(),pp(),Ol(),lp(),ip(),up(),mp(),__classPrivateFieldSet=function(t,n,S,C,N){if(C===`m`)throw TypeError(`Private method is not writable`);if(C===`a`&&!N)throw TypeError(`Private accessor was defined without a setter`);if(typeof n==`function`?t!==n||!N:!n.has(t))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return C===`a`?N.call(t,S):N?N.value=S:n.set(t,S),S},__classPrivateFieldGet=function(t,n,S,C){if(S===`a`&&!C)throw TypeError(`Private accessor was defined without a getter`);if(typeof n==`function`?t!==n||!C:!n.has(t))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return S===`m`?C:S===`a`?C.call(t):C?C.value:n.get(t)},om=Symbol(`copyDoubleDash`),sm=Symbol(`copyDoubleDash`),cm=Symbol(`deleteFromParserHintObject`),lm=Symbol(`emitWarning`),um=Symbol(`freeze`),dm=Symbol(`getDollarZero`),fm=Symbol(`getParserConfiguration`),pm=Symbol(`getUsageConfiguration`),mm=Symbol(`guessLocale`),hm=Symbol(`guessVersion`),gm=Symbol(`parsePositionalNumbers`),_m=Symbol(`pkgUp`),vm=Symbol(`populateParserHintArray`),ym=Symbol(`populateParserHintSingleValueDictionary`),bm=Symbol(`populateParserHintArrayDictionary`),xm=Symbol(`populateParserHintDictionary`),Sm=Symbol(`sanitizeKey`),Cm=Symbol(`setKey`),wm=Symbol(`unfreeze`),Tm=Symbol(`validateAsync`),Em=Symbol(`getCommandInstance`),Dm=Symbol(`getContext`),Om=Symbol(`getHasOutput`),km=Symbol(`getLoggerInstance`),Am=Symbol(`getParseContext`),jm=Symbol(`getUsageInstance`),Mm=Symbol(`getValidationInstance`),Nm=Symbol(`hasParseCallback`),Pm=Symbol(`isGlobalContext`),Fm=Symbol(`postProcess`),Im=Symbol(`rebase`),Lm=Symbol(`reset`),Rm=Symbol(`runYargsParserAndExecuteCommands`),zm=Symbol(`runValidation`),Bm=Symbol(`setHasOutput`),Vm=Symbol(`kTrackManuallySetKeys`),Hm=`en_US`,YargsInstance=class{constructor(t=[],n,S,C){this.customScriptName=!1,this.parsed=!1,wp.set(this,void 0),Tp.set(this,void 0),Ep.set(this,{commands:[],fullCommands:[]}),Dp.set(this,null),Op.set(this,null),kp.set(this,`show-hidden`),Ap.set(this,null),jp.set(this,!0),Mp.set(this,{}),Np.set(this,!0),Pp.set(this,[]),Fp.set(this,void 0),Ip.set(this,{}),Lp.set(this,!1),Rp.set(this,null),zp.set(this,!0),Bp.set(this,void 0),Vp.set(this,``),Hp.set(this,void 0),Up.set(this,void 0),Wp.set(this,{}),Gp.set(this,null),Kp.set(this,null),qp.set(this,{}),Jp.set(this,{}),Yp.set(this,void 0),Xp.set(this,!1),Zp.set(this,void 0),Qp.set(this,!1),$p.set(this,!1),em.set(this,!1),tm.set(this,void 0),nm.set(this,{}),im.set(this,null),am.set(this,void 0),__classPrivateFieldSet(this,Zp,C,`f`),__classPrivateFieldSet(this,Yp,t,`f`),__classPrivateFieldSet(this,Tp,n,`f`),__classPrivateFieldSet(this,Up,S,`f`),__classPrivateFieldSet(this,Fp,new GlobalMiddleware(this),`f`),this.$0=this[dm](),this[Lm](),__classPrivateFieldSet(this,wp,__classPrivateFieldGet(this,wp,`f`),`f`),__classPrivateFieldSet(this,tm,__classPrivateFieldGet(this,tm,`f`),`f`),__classPrivateFieldSet(this,am,__classPrivateFieldGet(this,am,`f`),`f`),__classPrivateFieldSet(this,Hp,__classPrivateFieldGet(this,Hp,`f`),`f`),__classPrivateFieldGet(this,Hp,`f`).showHiddenOpt=__classPrivateFieldGet(this,kp,`f`),__classPrivateFieldSet(this,Bp,this[sm](),`f`),__classPrivateFieldGet(this,Zp,`f`).y18n.setLocale(Hm)}addHelpOpt(t,n){return argsert(`[string|boolean] [string]`,[t,n],arguments.length),__classPrivateFieldGet(this,Rp,`f`)&&(this[cm](__classPrivateFieldGet(this,Rp,`f`)),__classPrivateFieldSet(this,Rp,null,`f`)),t===!1&&n===void 0?this:(__classPrivateFieldSet(this,Rp,typeof t==`string`?t:`help`,`f`),this.boolean(__classPrivateFieldGet(this,Rp,`f`)),this.describe(__classPrivateFieldGet(this,Rp,`f`),n||__classPrivateFieldGet(this,tm,`f`).deferY18nLookup(`Show help`)),this)}help(t,n){return this.addHelpOpt(t,n)}addShowHiddenOpt(t,n){if(argsert(`[string|boolean] [string]`,[t,n],arguments.length),t===!1&&n===void 0)return this;let S=typeof t==`string`?t:__classPrivateFieldGet(this,kp,`f`);return this.boolean(S),this.describe(S,n||__classPrivateFieldGet(this,tm,`f`).deferY18nLookup(`Show hidden options`)),__classPrivateFieldGet(this,Hp,`f`).showHiddenOpt=S,this}showHidden(t,n){return this.addShowHiddenOpt(t,n)}alias(t,n){return argsert(`<object|string|array> [string|array]`,[t,n],arguments.length),this[bm](this.alias.bind(this),`alias`,t,n),this}array(t){return argsert(`<array|string>`,[t],arguments.length),this[vm](`array`,t),this[Vm](t),this}boolean(t){return argsert(`<array|string>`,[t],arguments.length),this[vm](`boolean`,t),this[Vm](t),this}check(t,n){return argsert(`<function> [boolean]`,[t,n],arguments.length),this.middleware((n,S)=>maybeAsyncResult(()=>t(n,S.getOptions()),S=>(S?(typeof S==`string`||S instanceof Error)&&__classPrivateFieldGet(this,tm,`f`).fail(S.toString(),S):__classPrivateFieldGet(this,tm,`f`).fail(__classPrivateFieldGet(this,Zp,`f`).y18n.__(`Argument check failed: %s`,t.toString())),n),t=>(__classPrivateFieldGet(this,tm,`f`).fail(t.message?t.message:t.toString(),t),n)),!1,n),this}choices(t,n){return argsert(`<object|string|array> [string|array]`,[t,n],arguments.length),this[bm](this.choices.bind(this),`choices`,t,n),this}coerce(t,n){if(argsert(`<object|string|array> [function]`,[t,n],arguments.length),Array.isArray(t)){if(!n)throw new wl(`coerce callback must be provided`);for(let S of t)this.coerce(S,n);return this}else if(typeof t==`object`){for(let n of Object.keys(t))this.coerce(n,t[n]);return this}if(!n)throw new wl(`coerce callback must be provided`);let S=t;return __classPrivateFieldGet(this,Hp,`f`).key[S]=!0,__classPrivateFieldGet(this,Fp,`f`).addCoerceMiddleware((t,C)=>{let N=C.getAliases()[S]??[],F=[S,...N].filter(n=>Object.prototype.hasOwnProperty.call(t,n));return F.length===0?t:maybeAsyncResult(()=>n(t[F[0]]),n=>(F.forEach(S=>{t[S]=n}),t),t=>{throw new wl(t.message)})},S),this}conflicts(t,n){return argsert(`<string|object> [string|array]`,[t,n],arguments.length),__classPrivateFieldGet(this,am,`f`).conflicts(t,n),this}config(t=`config`,n,S){return argsert(`[object|string] [string|function] [function]`,[t,n,S],arguments.length),typeof t==`object`&&!Array.isArray(t)?(t=applyExtends(t,__classPrivateFieldGet(this,Tp,`f`),this[fm]()[`deep-merge-config`]||!1,__classPrivateFieldGet(this,Zp,`f`)),__classPrivateFieldGet(this,Hp,`f`).configObjects=(__classPrivateFieldGet(this,Hp,`f`).configObjects||[]).concat(t),this):(typeof n==`function`&&(S=n,n=void 0),this.describe(t,n||__classPrivateFieldGet(this,tm,`f`).deferY18nLookup(`Path to JSON config file`)),(Array.isArray(t)?t:[t]).forEach(t=>{__classPrivateFieldGet(this,Hp,`f`).config[t]=S||!0}),this)}completion(t,n,S){return argsert(`[string] [string|boolean|function] [function]`,[t,n,S],arguments.length),typeof n==`function`&&(S=n,n=void 0),__classPrivateFieldSet(this,Op,t||__classPrivateFieldGet(this,Op,`f`)||`completion`,`f`),!n&&n!==!1&&(n=`generate completion script`),this.command(__classPrivateFieldGet(this,Op,`f`),n),S&&__classPrivateFieldGet(this,Dp,`f`).registerFunction(S),this}command(t,n,S,C,N,F){return argsert(`<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]`,[t,n,S,C,N,F],arguments.length),__classPrivateFieldGet(this,wp,`f`).addHandler(t,n,S,C,N,F),this}commands(t,n,S,C,N,F){return this.command(t,n,S,C,N,F)}commandDir(t,n){argsert(`<string> [object]`,[t,n],arguments.length);let S=__classPrivateFieldGet(this,Up,`f`)||__classPrivateFieldGet(this,Zp,`f`).require;return __classPrivateFieldGet(this,wp,`f`).addDirectory(t,S,__classPrivateFieldGet(this,Zp,`f`).getCallerFile(),n),this}count(t){return argsert(`<array|string>`,[t],arguments.length),this[vm](`count`,t),this[Vm](t),this}default(t,n,S){return argsert(`<object|string|array> [*] [string]`,[t,n,S],arguments.length),S&&(assertSingleKey(t,__classPrivateFieldGet(this,Zp,`f`)),__classPrivateFieldGet(this,Hp,`f`).defaultDescription[t]=S),typeof n==`function`&&(assertSingleKey(t,__classPrivateFieldGet(this,Zp,`f`)),__classPrivateFieldGet(this,Hp,`f`).defaultDescription[t]||(__classPrivateFieldGet(this,Hp,`f`).defaultDescription[t]=__classPrivateFieldGet(this,tm,`f`).functionDescription(n)),n=n.call()),this[ym](this.default.bind(this),`default`,t,n),this}defaults(t,n,S){return this.default(t,n,S)}demandCommand(t=1,n,S,C){return argsert(`[number] [number|string] [string|null|undefined] [string|null|undefined]`,[t,n,S,C],arguments.length),typeof n!=`number`&&(S=n,n=1/0),this.global(`_`,!1),__classPrivateFieldGet(this,Hp,`f`).demandedCommands._={min:t,max:n,minMsg:S,maxMsg:C},this}demand(t,n,S){return Array.isArray(n)?(n.forEach(t=>{assertNotStrictEqual(S,!0,__classPrivateFieldGet(this,Zp,`f`)),this.demandOption(t,S)}),n=1/0):typeof n!=`number`&&(S=n,n=1/0),typeof t==`number`?(assertNotStrictEqual(S,!0,__classPrivateFieldGet(this,Zp,`f`)),this.demandCommand(t,n,S,S)):Array.isArray(t)?t.forEach(t=>{assertNotStrictEqual(S,!0,__classPrivateFieldGet(this,Zp,`f`)),this.demandOption(t,S)}):typeof S==`string`?this.demandOption(t,S):(S===!0||S===void 0)&&this.demandOption(t),this}demandOption(t,n){return argsert(`<object|string|array> [string]`,[t,n],arguments.length),this[ym](this.demandOption.bind(this),`demandedOptions`,t,n),this}deprecateOption(t,n){return argsert(`<string> [string|boolean]`,[t,n],arguments.length),__classPrivateFieldGet(this,Hp,`f`).deprecatedOptions[t]=n,this}describe(t,n){return argsert(`<object|string|array> [string]`,[t,n],arguments.length),this[Cm](t,!0),__classPrivateFieldGet(this,tm,`f`).describe(t,n),this}detectLocale(t){return argsert(`<boolean>`,[t],arguments.length),__classPrivateFieldSet(this,jp,t,`f`),this}env(t){return argsert(`[string|boolean]`,[t],arguments.length),t===!1?delete __classPrivateFieldGet(this,Hp,`f`).envPrefix:__classPrivateFieldGet(this,Hp,`f`).envPrefix=t||``,this}epilogue(t){return argsert(`<string>`,[t],arguments.length),__classPrivateFieldGet(this,tm,`f`).epilog(t),this}epilog(t){return this.epilogue(t)}example(t,n){return argsert(`<string|array> [string]`,[t,n],arguments.length),Array.isArray(t)?t.forEach(t=>this.example(...t)):__classPrivateFieldGet(this,tm,`f`).example(t,n),this}exit(t,n){__classPrivateFieldSet(this,Lp,!0,`f`),__classPrivateFieldSet(this,Ap,n,`f`),__classPrivateFieldGet(this,Np,`f`)&&__classPrivateFieldGet(this,Zp,`f`).process.exit(t)}exitProcess(t=!0){return argsert(`[boolean]`,[t],arguments.length),__classPrivateFieldSet(this,Np,t,`f`),this}fail(t){if(argsert(`<function|boolean>`,[t],arguments.length),typeof t==`boolean`&&t!==!1)throw new wl(`Invalid first argument. Expected function or boolean 'false'`);return __classPrivateFieldGet(this,tm,`f`).failFn(t),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(t,n){return argsert(`<array> [function]`,[t,n],arguments.length),n?__classPrivateFieldGet(this,Dp,`f`).getCompletion(t,n):new Promise((n,S)=>{__classPrivateFieldGet(this,Dp,`f`).getCompletion(t,(t,C)=>{t?S(t):n(C)})})}getDemandedOptions(){return argsert([],0),__classPrivateFieldGet(this,Hp,`f`).demandedOptions}getDemandedCommands(){return argsert([],0),__classPrivateFieldGet(this,Hp,`f`).demandedCommands}getDeprecatedOptions(){return argsert([],0),__classPrivateFieldGet(this,Hp,`f`).deprecatedOptions}getDetectLocale(){return __classPrivateFieldGet(this,jp,`f`)}getExitProcess(){return __classPrivateFieldGet(this,Np,`f`)}getGroups(){return Object.assign({},__classPrivateFieldGet(this,Ip,`f`),__classPrivateFieldGet(this,Jp,`f`))}getHelp(){if(__classPrivateFieldSet(this,Lp,!0,`f`),!__classPrivateFieldGet(this,tm,`f`).hasCachedHelpMessage()){if(!this.parsed){let t=this[Rm](__classPrivateFieldGet(this,Yp,`f`),void 0,void 0,0,!0);if(isPromise(t))return t.then(()=>__classPrivateFieldGet(this,tm,`f`).help())}let t=__classPrivateFieldGet(this,wp,`f`).runDefaultBuilderOn(this);if(isPromise(t))return t.then(()=>__classPrivateFieldGet(this,tm,`f`).help())}return Promise.resolve(__classPrivateFieldGet(this,tm,`f`).help())}getOptions(){return __classPrivateFieldGet(this,Hp,`f`)}getStrict(){return __classPrivateFieldGet(this,Qp,`f`)}getStrictCommands(){return __classPrivateFieldGet(this,$p,`f`)}getStrictOptions(){return __classPrivateFieldGet(this,em,`f`)}global(t,n){return argsert(`<string|array> [boolean]`,[t,n],arguments.length),t=[].concat(t),n===!1?t.forEach(t=>{__classPrivateFieldGet(this,Hp,`f`).local.includes(t)||__classPrivateFieldGet(this,Hp,`f`).local.push(t)}):__classPrivateFieldGet(this,Hp,`f`).local=__classPrivateFieldGet(this,Hp,`f`).local.filter(n=>t.indexOf(n)===-1),this}group(t,n){argsert(`<string|array> <string>`,[t,n],arguments.length);let S=__classPrivateFieldGet(this,Jp,`f`)[n]||__classPrivateFieldGet(this,Ip,`f`)[n];__classPrivateFieldGet(this,Jp,`f`)[n]&&delete __classPrivateFieldGet(this,Jp,`f`)[n];let C={};return __classPrivateFieldGet(this,Ip,`f`)[n]=(S||[]).concat(t).filter(t=>C[t]?!1:C[t]=!0),this}hide(t){return argsert(`<string>`,[t],arguments.length),__classPrivateFieldGet(this,Hp,`f`).hiddenOptions.push(t),this}implies(t,n){return argsert(`<string|object> [number|string|array]`,[t,n],arguments.length),__classPrivateFieldGet(this,am,`f`).implies(t,n),this}locale(t){return argsert(`[string]`,[t],arguments.length),t===void 0?(this[mm](),__classPrivateFieldGet(this,Zp,`f`).y18n.getLocale()):(__classPrivateFieldSet(this,jp,!1,`f`),__classPrivateFieldGet(this,Zp,`f`).y18n.setLocale(t),this)}middleware(t,n,S){return __classPrivateFieldGet(this,Fp,`f`).addMiddleware(t,!!n,S)}nargs(t,n){return argsert(`<string|object|array> [number]`,[t,n],arguments.length),this[ym](this.nargs.bind(this),`narg`,t,n),this}normalize(t){return argsert(`<array|string>`,[t],arguments.length),this[vm](`normalize`,t),this}number(t){return argsert(`<array|string>`,[t],arguments.length),this[vm](`number`,t),this[Vm](t),this}option(t,n){if(argsert(`<string|object> [object]`,[t,n],arguments.length),typeof t==`object`)Object.keys(t).forEach(n=>{this.options(n,t[n])});else{typeof n!=`object`&&(n={}),this[Vm](t),__classPrivateFieldGet(this,im,`f`)&&(t===`version`||n?.alias===`version`)&&this[lm]([`"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(`
|
|
146
146
|
`),void 0,`versionWarning`),__classPrivateFieldGet(this,Hp,`f`).key[t]=!0,n.alias&&this.alias(t,n.alias);let S=n.deprecate||n.deprecated;S&&this.deprecateOption(t,S);let C=n.demand||n.required||n.require;C&&this.demand(t,C),n.demandOption&&this.demandOption(t,typeof n.demandOption==`string`?n.demandOption:void 0),n.conflicts&&this.conflicts(t,n.conflicts),`default`in n&&this.default(t,n.default),n.implies!==void 0&&this.implies(t,n.implies),n.nargs!==void 0&&this.nargs(t,n.nargs),n.config&&this.config(t,n.configParser),n.normalize&&this.normalize(t),n.choices&&this.choices(t,n.choices),n.coerce&&this.coerce(t,n.coerce),n.group&&this.group(t,n.group),(n.boolean||n.type===`boolean`)&&(this.boolean(t),n.alias&&this.boolean(n.alias)),(n.array||n.type===`array`)&&(this.array(t),n.alias&&this.array(n.alias)),(n.number||n.type===`number`)&&(this.number(t),n.alias&&this.number(n.alias)),(n.string||n.type===`string`)&&(this.string(t),n.alias&&this.string(n.alias)),(n.count||n.type===`count`)&&this.count(t),typeof n.global==`boolean`&&this.global(t,n.global),n.defaultDescription&&(__classPrivateFieldGet(this,Hp,`f`).defaultDescription[t]=n.defaultDescription),n.skipValidation&&this.skipValidation(t);let N=n.describe||n.description||n.desc,F=__classPrivateFieldGet(this,tm,`f`).getDescriptions();(!Object.prototype.hasOwnProperty.call(F,t)||typeof N==`string`)&&this.describe(t,N),n.hidden&&this.hide(t),n.requiresArg&&this.requiresArg(t)}return this}options(t,n){return this.option(t,n)}parse(t,n,S){argsert(`[string|array] [function|boolean|object] [function]`,[t,n,S],arguments.length),this[um](),t===void 0&&(t=__classPrivateFieldGet(this,Yp,`f`)),typeof n==`object`&&(__classPrivateFieldSet(this,Kp,n,`f`),n=S),typeof n==`function`&&(__classPrivateFieldSet(this,Gp,n,`f`),n=!1),n||__classPrivateFieldSet(this,Yp,t,`f`),__classPrivateFieldGet(this,Gp,`f`)&&__classPrivateFieldSet(this,Np,!1,`f`);let C=this[Rm](t,!!n),N=this.parsed;return __classPrivateFieldGet(this,Dp,`f`).setParsed(this.parsed),isPromise(C)?C.then(t=>(__classPrivateFieldGet(this,Gp,`f`)&&__classPrivateFieldGet(this,Gp,`f`).call(this,__classPrivateFieldGet(this,Ap,`f`),t,__classPrivateFieldGet(this,Vp,`f`)),t)).catch(t=>{throw __classPrivateFieldGet(this,Gp,`f`)&&__classPrivateFieldGet(this,Gp,`f`)(t,this.parsed.argv,__classPrivateFieldGet(this,Vp,`f`)),t}).finally(()=>{this[wm](),this.parsed=N}):(__classPrivateFieldGet(this,Gp,`f`)&&__classPrivateFieldGet(this,Gp,`f`).call(this,__classPrivateFieldGet(this,Ap,`f`),C,__classPrivateFieldGet(this,Vp,`f`)),this[wm](),this.parsed=N,C)}parseAsync(t,n,S){let C=this.parse(t,n,S);return isPromise(C)?C:Promise.resolve(C)}parseSync(t,n,S){let C=this.parse(t,n,S);if(isPromise(C))throw new wl(`.parseSync() must not be used with asynchronous builders, handlers, or middleware`);return C}parserConfiguration(t){return argsert(`<object>`,[t],arguments.length),__classPrivateFieldSet(this,Wp,t,`f`),this}pkgConf(t,n){argsert(`<string> [string]`,[t,n],arguments.length);let S=null,C=this[_m](n||__classPrivateFieldGet(this,Tp,`f`));return C[t]&&typeof C[t]==`object`&&(S=applyExtends(C[t],n||__classPrivateFieldGet(this,Tp,`f`),this[fm]()[`deep-merge-config`]||!1,__classPrivateFieldGet(this,Zp,`f`)),__classPrivateFieldGet(this,Hp,`f`).configObjects=(__classPrivateFieldGet(this,Hp,`f`).configObjects||[]).concat(S)),this}positional(t,n){argsert(`<string> <object>`,[t,n],arguments.length);let S=[`default`,`defaultDescription`,`implies`,`normalize`,`choices`,`conflicts`,`coerce`,`type`,`describe`,`desc`,`description`,`alias`];n=objFilter(n,(t,n)=>t===`type`&&![`string`,`number`,`boolean`].includes(n)?!1:S.includes(t));let C=__classPrivateFieldGet(this,Ep,`f`).fullCommands[__classPrivateFieldGet(this,Ep,`f`).fullCommands.length-1],N=C?__classPrivateFieldGet(this,wp,`f`).cmdToParseOptions(C):{array:[],alias:{},default:{},demand:{}};return objectKeys(N).forEach(S=>{let C=N[S];Array.isArray(C)?C.indexOf(t)!==-1&&(n[S]=!0):C[t]&&!(S in n)&&(n[S]=C[t])}),this.group(t,__classPrivateFieldGet(this,tm,`f`).getPositionalGroupName()),this.option(t,n)}recommendCommands(t=!0){return argsert(`[boolean]`,[t],arguments.length),__classPrivateFieldSet(this,Xp,t,`f`),this}required(t,n,S){return this.demand(t,n,S)}require(t,n,S){return this.demand(t,n,S)}requiresArg(t){return argsert(`<array|string|object> [number]`,[t],arguments.length),typeof t==`string`&&__classPrivateFieldGet(this,Hp,`f`).narg[t]||this[ym](this.requiresArg.bind(this),`narg`,t,NaN),this}showCompletionScript(t,n){return argsert(`[string] [string]`,[t,n],arguments.length),t||=this.$0,__classPrivateFieldGet(this,Bp,`f`).log(__classPrivateFieldGet(this,Dp,`f`).generateCompletionScript(t,n||__classPrivateFieldGet(this,Op,`f`)||`completion`)),this}showHelp(t){if(argsert(`[string|function]`,[t],arguments.length),__classPrivateFieldSet(this,Lp,!0,`f`),!__classPrivateFieldGet(this,tm,`f`).hasCachedHelpMessage()){if(!this.parsed){let n=this[Rm](__classPrivateFieldGet(this,Yp,`f`),void 0,void 0,0,!0);if(isPromise(n))return n.then(()=>{__classPrivateFieldGet(this,tm,`f`).showHelp(t)}),this}let n=__classPrivateFieldGet(this,wp,`f`).runDefaultBuilderOn(this);if(isPromise(n))return n.then(()=>{__classPrivateFieldGet(this,tm,`f`).showHelp(t)}),this}return __classPrivateFieldGet(this,tm,`f`).showHelp(t),this}scriptName(t){return this.customScriptName=!0,this.$0=t,this}showHelpOnFail(t,n){return argsert(`[boolean|string] [string]`,[t,n],arguments.length),__classPrivateFieldGet(this,tm,`f`).showHelpOnFail(t,n),this}showVersion(t){return argsert(`[string|function]`,[t],arguments.length),__classPrivateFieldGet(this,tm,`f`).showVersion(t),this}skipValidation(t){return argsert(`<array|string>`,[t],arguments.length),this[vm](`skipValidation`,t),this}strict(t){return argsert(`[boolean]`,[t],arguments.length),__classPrivateFieldSet(this,Qp,t!==!1,`f`),this}strictCommands(t){return argsert(`[boolean]`,[t],arguments.length),__classPrivateFieldSet(this,$p,t!==!1,`f`),this}strictOptions(t){return argsert(`[boolean]`,[t],arguments.length),__classPrivateFieldSet(this,em,t!==!1,`f`),this}string(t){return argsert(`<array|string>`,[t],arguments.length),this[vm](`string`,t),this[Vm](t),this}terminalWidth(){return argsert([],0),__classPrivateFieldGet(this,Zp,`f`).process.stdColumns}updateLocale(t){return this.updateStrings(t)}updateStrings(t){return argsert(`<object>`,[t],arguments.length),__classPrivateFieldSet(this,jp,!1,`f`),__classPrivateFieldGet(this,Zp,`f`).y18n.updateLocale(t),this}usage(t,n,S,C){if(argsert(`<string|null|undefined> [string|boolean] [function|object] [function]`,[t,n,S,C],arguments.length),n!==void 0){if(assertNotStrictEqual(t,null,__classPrivateFieldGet(this,Zp,`f`)),(t||``).match(/^\$0( |$)/))return this.command(t,n,S,C);throw new wl(`.usage() description must start with $0 if being used as alias for .command()`)}else return __classPrivateFieldGet(this,tm,`f`).usage(t),this}usageConfiguration(t){return argsert(`<object>`,[t],arguments.length),__classPrivateFieldSet(this,nm,t,`f`),this}version(t,n,S){let C=`version`;if(argsert(`[boolean|string] [string] [string]`,[t,n,S],arguments.length),__classPrivateFieldGet(this,im,`f`)&&(this[cm](__classPrivateFieldGet(this,im,`f`)),__classPrivateFieldGet(this,tm,`f`).version(void 0),__classPrivateFieldSet(this,im,null,`f`)),arguments.length===0)S=this[hm](),t=C;else if(arguments.length===1){if(t===!1)return this;S=t,t=C}else arguments.length===2&&(S=n,n=void 0);return __classPrivateFieldSet(this,im,typeof t==`string`?t:C,`f`),n||=__classPrivateFieldGet(this,tm,`f`).deferY18nLookup(`Show version number`),__classPrivateFieldGet(this,tm,`f`).version(S||void 0),this.boolean(__classPrivateFieldGet(this,im,`f`)),this.describe(__classPrivateFieldGet(this,im,`f`),n),this}wrap(t){return argsert(`<number|null|undefined>`,[t],arguments.length),__classPrivateFieldGet(this,tm,`f`).wrap(t),this}[(wp=new WeakMap,Tp=new WeakMap,Ep=new WeakMap,Dp=new WeakMap,Op=new WeakMap,kp=new WeakMap,Ap=new WeakMap,jp=new WeakMap,Mp=new WeakMap,Np=new WeakMap,Pp=new WeakMap,Fp=new WeakMap,Ip=new WeakMap,Lp=new WeakMap,Rp=new WeakMap,zp=new WeakMap,Bp=new WeakMap,Vp=new WeakMap,Hp=new WeakMap,Up=new WeakMap,Wp=new WeakMap,Gp=new WeakMap,Kp=new WeakMap,qp=new WeakMap,Jp=new WeakMap,Yp=new WeakMap,Xp=new WeakMap,Zp=new WeakMap,Qp=new WeakMap,$p=new WeakMap,em=new WeakMap,tm=new WeakMap,nm=new WeakMap,im=new WeakMap,am=new WeakMap,om)](t){if(!t._||!t[`--`])return t;t._.push.apply(t._,t[`--`]);try{delete t[`--`]}catch{}return t}[sm](){return{log:(...t)=>{this[Nm]()||ge.log(...t),__classPrivateFieldSet(this,Lp,!0,`f`),__classPrivateFieldGet(this,Vp,`f`).length&&__classPrivateFieldSet(this,Vp,__classPrivateFieldGet(this,Vp,`f`)+`
|
|
147
147
|
`,`f`),__classPrivateFieldSet(this,Vp,__classPrivateFieldGet(this,Vp,`f`)+t.join(` `),`f`)},error:(...t)=>{this[Nm]()||ge.error(...t),__classPrivateFieldSet(this,Lp,!0,`f`),__classPrivateFieldGet(this,Vp,`f`).length&&__classPrivateFieldSet(this,Vp,__classPrivateFieldGet(this,Vp,`f`)+`
|
|
148
|
-
`,`f`),__classPrivateFieldSet(this,Vp,__classPrivateFieldGet(this,Vp,`f`)+t.join(` `),`f`)}}}[cm](t){objectKeys(__classPrivateFieldGet(this,Hp,`f`)).forEach(n=>{if((t=>t===`configObjects`)(n))return;let S=__classPrivateFieldGet(this,Hp,`f`)[n];Array.isArray(S)?S.includes(t)&&S.splice(S.indexOf(t),1):typeof S==`object`&&delete S[t]}),delete __classPrivateFieldGet(this,tm,`f`).getDescriptions()[t]}[lm](t,n,S){__classPrivateFieldGet(this,Mp,`f`)[S]||(__classPrivateFieldGet(this,Zp,`f`).process.emitWarning(t,n),__classPrivateFieldGet(this,Mp,`f`)[S]=!0)}[um](){__classPrivateFieldGet(this,Pp,`f`).push({options:__classPrivateFieldGet(this,Hp,`f`),configObjects:__classPrivateFieldGet(this,Hp,`f`).configObjects.slice(0),exitProcess:__classPrivateFieldGet(this,Np,`f`),groups:__classPrivateFieldGet(this,Ip,`f`),strict:__classPrivateFieldGet(this,Qp,`f`),strictCommands:__classPrivateFieldGet(this,$p,`f`),strictOptions:__classPrivateFieldGet(this,em,`f`),completionCommand:__classPrivateFieldGet(this,Op,`f`),output:__classPrivateFieldGet(this,Vp,`f`),exitError:__classPrivateFieldGet(this,Ap,`f`),hasOutput:__classPrivateFieldGet(this,Lp,`f`),parsed:this.parsed,parseFn:__classPrivateFieldGet(this,Gp,`f`),parseContext:__classPrivateFieldGet(this,Kp,`f`)}),__classPrivateFieldGet(this,tm,`f`).freeze(),__classPrivateFieldGet(this,am,`f`).freeze(),__classPrivateFieldGet(this,wp,`f`).freeze(),__classPrivateFieldGet(this,Fp,`f`).freeze()}[dm](){let t=``,n;return n=/\b(node|iojs|electron)(\.exe)?$/.test(__classPrivateFieldGet(this,Zp,`f`).process.argv()[0])?__classPrivateFieldGet(this,Zp,`f`).process.argv().slice(1,2):__classPrivateFieldGet(this,Zp,`f`).process.argv().slice(0,1),t=n.map(t=>{let n=this[Im](__classPrivateFieldGet(this,Tp,`f`),t);return t.match(/^(\/|([a-zA-Z]:)?\\)/)&&n.length<t.length?n:t}).join(` `).trim(),__classPrivateFieldGet(this,Zp,`f`).getEnv(`_`)&&__classPrivateFieldGet(this,Zp,`f`).getProcessArgvBin()===__classPrivateFieldGet(this,Zp,`f`).getEnv(`_`)&&(t=__classPrivateFieldGet(this,Zp,`f`).getEnv(`_`).replace(`${__classPrivateFieldGet(this,Zp,`f`).path.dirname(__classPrivateFieldGet(this,Zp,`f`).process.execPath())}/`,``)),t}[fm](){return __classPrivateFieldGet(this,Wp,`f`)}[pm](){return __classPrivateFieldGet(this,nm,`f`)}[mm](){if(!__classPrivateFieldGet(this,jp,`f`))return;let t=__classPrivateFieldGet(this,Zp,`f`).getEnv(`LC_ALL`)||__classPrivateFieldGet(this,Zp,`f`).getEnv(`LC_MESSAGES`)||__classPrivateFieldGet(this,Zp,`f`).getEnv(`LANG`)||__classPrivateFieldGet(this,Zp,`f`).getEnv(`LANGUAGE`)||`en_US`;this.locale(t.replace(/[.:].*/,``))}[hm](){return this[_m]().version||`unknown`}[gm](t){let n=t[`--`]?t[`--`]:t._;for(let t=0,S;(S=n[t])!==void 0;t++)__classPrivateFieldGet(this,Zp,`f`).Parser.looksLikeNumber(S)&&Number.isSafeInteger(Math.floor(parseFloat(`${S}`)))&&(n[t]=Number(S));return t}[_m](t){let n=t||`*`;if(__classPrivateFieldGet(this,qp,`f`)[n])return __classPrivateFieldGet(this,qp,`f`)[n];let S={};try{let n=t||__classPrivateFieldGet(this,Zp,`f`).mainFilename;__classPrivateFieldGet(this,Zp,`f`).path.extname(n)&&(n=__classPrivateFieldGet(this,Zp,`f`).path.dirname(n));let C=__classPrivateFieldGet(this,Zp,`f`).findUp(n,(t,n)=>{if(n.includes(`package.json`))return`package.json`});assertNotStrictEqual(C,void 0,__classPrivateFieldGet(this,Zp,`f`)),S=JSON.parse(__classPrivateFieldGet(this,Zp,`f`).readFileSync(C,`utf8`))}catch{}return __classPrivateFieldGet(this,qp,`f`)[n]=S||{},__classPrivateFieldGet(this,qp,`f`)[n]}[vm](t,n){n=[].concat(n),n.forEach(n=>{n=this[Sm](n),__classPrivateFieldGet(this,Hp,`f`)[t].push(n)})}[ym](t,n,S,C){this[xm](t,n,S,C,(t,n,S)=>{__classPrivateFieldGet(this,Hp,`f`)[t][n]=S})}[bm](t,n,S,C){this[xm](t,n,S,C,(t,n,S)=>{__classPrivateFieldGet(this,Hp,`f`)[t][n]=(__classPrivateFieldGet(this,Hp,`f`)[t][n]||[]).concat(S)})}[xm](t,n,S,C,N){if(Array.isArray(S))S.forEach(n=>{t(n,C)});else if((t=>typeof t==`object`)(S))for(let n of objectKeys(S))t(n,S[n]);else N(n,this[Sm](S),C)}[Sm](t){return t===`__proto__`?`___proto___`:t}[Cm](t,n){return this[ym](this[Cm].bind(this),`key`,t,n),this}[wm](){var t,n,S,C,N,F,I,H,W,q,Y,X;let Z=__classPrivateFieldGet(this,Pp,`f`).pop();assertNotStrictEqual(Z,void 0,__classPrivateFieldGet(this,Zp,`f`));let te;t=this,n=this,S=this,C=this,N=this,F=this,I=this,H=this,W=this,q=this,Y=this,X=this,{options:{set value(n){__classPrivateFieldSet(t,Hp,n,`f`)}}.value,configObjects:te,exitProcess:{set value(t){__classPrivateFieldSet(n,Np,t,`f`)}}.value,groups:{set value(t){__classPrivateFieldSet(S,Ip,t,`f`)}}.value,output:{set value(t){__classPrivateFieldSet(C,Vp,t,`f`)}}.value,exitError:{set value(t){__classPrivateFieldSet(N,Ap,t,`f`)}}.value,hasOutput:{set value(t){__classPrivateFieldSet(F,Lp,t,`f`)}}.value,parsed:this.parsed,strict:{set value(t){__classPrivateFieldSet(I,Qp,t,`f`)}}.value,strictCommands:{set value(t){__classPrivateFieldSet(H,$p,t,`f`)}}.value,strictOptions:{set value(t){__classPrivateFieldSet(W,em,t,`f`)}}.value,completionCommand:{set value(t){__classPrivateFieldSet(q,Op,t,`f`)}}.value,parseFn:{set value(t){__classPrivateFieldSet(Y,Gp,t,`f`)}}.value,parseContext:{set value(t){__classPrivateFieldSet(X,Kp,t,`f`)}}.value}=Z,__classPrivateFieldGet(this,Hp,`f`).configObjects=te,__classPrivateFieldGet(this,tm,`f`).unfreeze(),__classPrivateFieldGet(this,am,`f`).unfreeze(),__classPrivateFieldGet(this,wp,`f`).unfreeze(),__classPrivateFieldGet(this,Fp,`f`).unfreeze()}[Tm](t,n){return maybeAsyncResult(n,n=>(t(n),n))}getInternalMethods(){return{getCommandInstance:this[Em].bind(this),getContext:this[Dm].bind(this),getHasOutput:this[Om].bind(this),getLoggerInstance:this[km].bind(this),getParseContext:this[Am].bind(this),getParserConfiguration:this[fm].bind(this),getUsageConfiguration:this[pm].bind(this),getUsageInstance:this[jm].bind(this),getValidationInstance:this[Mm].bind(this),hasParseCallback:this[Nm].bind(this),isGlobalContext:this[Pm].bind(this),postProcess:this[Fm].bind(this),reset:this[Lm].bind(this),runValidation:this[zm].bind(this),runYargsParserAndExecuteCommands:this[Rm].bind(this),setHasOutput:this[Bm].bind(this)}}[Em](){return __classPrivateFieldGet(this,wp,`f`)}[Dm](){return __classPrivateFieldGet(this,Ep,`f`)}[Om](){return __classPrivateFieldGet(this,Lp,`f`)}[km](){return __classPrivateFieldGet(this,Bp,`f`)}[Am](){return __classPrivateFieldGet(this,Kp,`f`)||{}}[jm](){return __classPrivateFieldGet(this,tm,`f`)}[Mm](){return __classPrivateFieldGet(this,am,`f`)}[Nm](){return!!__classPrivateFieldGet(this,Gp,`f`)}[Pm](){return __classPrivateFieldGet(this,zp,`f`)}[Fm](t,n,S,C){return S||isPromise(t)?t:(n||(t=this[om](t)),(this[fm]()[`parse-positional-numbers`]||this[fm]()[`parse-positional-numbers`]===void 0)&&(t=this[gm](t)),C&&(t=applyMiddleware(t,this,__classPrivateFieldGet(this,Fp,`f`).getMiddleware(),!1)),t)}[Lm](t={}){__classPrivateFieldSet(this,Hp,__classPrivateFieldGet(this,Hp,`f`)||{},`f`);let n={};n.local=__classPrivateFieldGet(this,Hp,`f`).local||[],n.configObjects=__classPrivateFieldGet(this,Hp,`f`).configObjects||[];let S={};return n.local.forEach(n=>{S[n]=!0,(t[n]||[]).forEach(t=>{S[t]=!0})}),Object.assign(__classPrivateFieldGet(this,Jp,`f`),Object.keys(__classPrivateFieldGet(this,Ip,`f`)).reduce((t,n)=>{let C=__classPrivateFieldGet(this,Ip,`f`)[n].filter(t=>!(t in S));return C.length>0&&(t[n]=C),t},{})),__classPrivateFieldSet(this,Ip,{},`f`),[`array`,`boolean`,`string`,`skipValidation`,`count`,`normalize`,`number`,`hiddenOptions`].forEach(t=>{n[t]=(__classPrivateFieldGet(this,Hp,`f`)[t]||[]).filter(t=>!S[t])}),[`narg`,`key`,`alias`,`default`,`defaultDescription`,`config`,`choices`,`demandedOptions`,`demandedCommands`,`deprecatedOptions`].forEach(t=>{n[t]=objFilter(__classPrivateFieldGet(this,Hp,`f`)[t],t=>!S[t])}),n.envPrefix=__classPrivateFieldGet(this,Hp,`f`).envPrefix,__classPrivateFieldSet(this,Hp,n,`f`),__classPrivateFieldSet(this,tm,__classPrivateFieldGet(this,tm,`f`)?__classPrivateFieldGet(this,tm,`f`).reset(S):usage(this,__classPrivateFieldGet(this,Zp,`f`)),`f`),__classPrivateFieldSet(this,am,__classPrivateFieldGet(this,am,`f`)?__classPrivateFieldGet(this,am,`f`).reset(S):validation(this,__classPrivateFieldGet(this,tm,`f`),__classPrivateFieldGet(this,Zp,`f`)),`f`),__classPrivateFieldSet(this,wp,__classPrivateFieldGet(this,wp,`f`)?__classPrivateFieldGet(this,wp,`f`).reset():command(__classPrivateFieldGet(this,tm,`f`),__classPrivateFieldGet(this,am,`f`),__classPrivateFieldGet(this,Fp,`f`),__classPrivateFieldGet(this,Zp,`f`)),`f`),__classPrivateFieldGet(this,Dp,`f`)||__classPrivateFieldSet(this,Dp,completion(this,__classPrivateFieldGet(this,tm,`f`),__classPrivateFieldGet(this,wp,`f`),__classPrivateFieldGet(this,Zp,`f`)),`f`),__classPrivateFieldGet(this,Fp,`f`).reset(),__classPrivateFieldSet(this,Op,null,`f`),__classPrivateFieldSet(this,Vp,``,`f`),__classPrivateFieldSet(this,Ap,null,`f`),__classPrivateFieldSet(this,Lp,!1,`f`),this.parsed=!1,this}[Im](t,n){return __classPrivateFieldGet(this,Zp,`f`).path.relative(t,n)}[Rm](t,n,S,C=0,N=!1){let F=!!S||N;t||=__classPrivateFieldGet(this,Yp,`f`),__classPrivateFieldGet(this,Hp,`f`).__=__classPrivateFieldGet(this,Zp,`f`).y18n.__,__classPrivateFieldGet(this,Hp,`f`).configuration=this[fm]();let I=!!__classPrivateFieldGet(this,Hp,`f`).configuration[`populate--`],H=Object.assign({},__classPrivateFieldGet(this,Hp,`f`).configuration,{"populate--":!0}),W=__classPrivateFieldGet(this,Zp,`f`).Parser.detailed(t,Object.assign({},__classPrivateFieldGet(this,Hp,`f`),{configuration:{"parse-positional-numbers":!1,...H}})),q=Object.assign(W.argv,__classPrivateFieldGet(this,Kp,`f`)),Y,X=W.aliases,Z=!1,te=!1;Object.keys(q).forEach(t=>{t===__classPrivateFieldGet(this,Rp,`f`)&&q[t]?Z=!0:t===__classPrivateFieldGet(this,im,`f`)&&q[t]&&(te=!0)}),q.$0=this.$0,this.parsed=W,C===0&&__classPrivateFieldGet(this,tm,`f`).clearCachedHelpMessage();try{if(this[mm](),n)return this[Fm](q,I,!!S,!1);__classPrivateFieldGet(this,Rp,`f`)&&[__classPrivateFieldGet(this,Rp,`f`)].concat(X[__classPrivateFieldGet(this,Rp,`f`)]||[]).filter(t=>t.length>1).includes(``+q._[q._.length-1])&&(q._.pop(),Z=!0),__classPrivateFieldSet(this,zp,!1,`f`);let H=__classPrivateFieldGet(this,wp,`f`).getCommands(),ne=__classPrivateFieldGet(this,Dp,`f`)?.completionKey?[__classPrivateFieldGet(this,Dp,`f`)?.completionKey,...this.getAliases()[__classPrivateFieldGet(this,Dp,`f`)?.completionKey]??[]].some(t=>Object.prototype.hasOwnProperty.call(q,t)):!1,re=Z||ne||N;if(q._.length){if(H.length){let t;for(let n=C||0,F;q._[n]!==void 0;n++)if(F=String(q._[n]),H.includes(F)&&F!==__classPrivateFieldGet(this,Op,`f`)){let t=__classPrivateFieldGet(this,wp,`f`).runCommand(F,this,W,n+1,N,Z||te||N);return this[Fm](t,I,!!S,!1)}else if(!t&&F!==__classPrivateFieldGet(this,Op,`f`)){t=F;break}!__classPrivateFieldGet(this,wp,`f`).hasDefaultCommand()&&__classPrivateFieldGet(this,Xp,`f`)&&t&&!re&&__classPrivateFieldGet(this,am,`f`).recommendCommands(t,H)}__classPrivateFieldGet(this,Op,`f`)&&q._.includes(__classPrivateFieldGet(this,Op,`f`))&&!ne&&(__classPrivateFieldGet(this,Np,`f`)&&setBlocking(!0),this.showCompletionScript(),this.exit(0))}if(__classPrivateFieldGet(this,wp,`f`).hasDefaultCommand()&&!re){let t=__classPrivateFieldGet(this,wp,`f`).runCommand(null,this,W,0,N,Z||te||N);return this[Fm](t,I,!!S,!1)}if(ne){__classPrivateFieldGet(this,Np,`f`)&&setBlocking(!0),t=[].concat(t);let n=t.slice(t.indexOf(`--${__classPrivateFieldGet(this,Dp,`f`).completionKey}`)+1);return __classPrivateFieldGet(this,Dp,`f`).getCompletion(n,(t,n)=>{if(t)throw new wl(t.message);(n||[]).forEach(t=>{__classPrivateFieldGet(this,Bp,`f`).log(t)}),this.exit(0)}),this[Fm](q,!I,!!S,!1)}if(__classPrivateFieldGet(this,Lp,`f`)||(Z?(__classPrivateFieldGet(this,Np,`f`)&&setBlocking(!0),F=!0,this.showHelp(t=>{__classPrivateFieldGet(this,Bp,`f`).log(t),this.exit(0)})):te&&(__classPrivateFieldGet(this,Np,`f`)&&setBlocking(!0),F=!0,__classPrivateFieldGet(this,tm,`f`).showVersion(`log`),this.exit(0))),!F&&__classPrivateFieldGet(this,Hp,`f`).skipValidation.length>0&&(F=Object.keys(q).some(t=>__classPrivateFieldGet(this,Hp,`f`).skipValidation.indexOf(t)>=0&&q[t]===!0)),!F){if(W.error)throw new wl(W.error.message);if(!ne){let t=this[zm](X,{},W.error);S||(Y=applyMiddleware(q,this,__classPrivateFieldGet(this,Fp,`f`).getMiddleware(),!0)),Y=this[Tm](t,Y??q),isPromise(Y)&&!S&&(Y=Y.then(()=>applyMiddleware(q,this,__classPrivateFieldGet(this,Fp,`f`).getMiddleware(),!1)))}}}catch(t){if(t instanceof wl)__classPrivateFieldGet(this,tm,`f`).fail(t.message,t);else throw t}return this[Fm](Y??q,I,!!S,!0)}[zm](t,n,S,C){let N={...this.getDemandedOptions()};return F=>{if(S)throw new wl(S.message);__classPrivateFieldGet(this,am,`f`).nonOptionCount(F),__classPrivateFieldGet(this,am,`f`).requiredArguments(F,N);let I=!1;__classPrivateFieldGet(this,$p,`f`)&&(I=__classPrivateFieldGet(this,am,`f`).unknownCommands(F)),__classPrivateFieldGet(this,Qp,`f`)&&!I?__classPrivateFieldGet(this,am,`f`).unknownArguments(F,t,n,!!C):__classPrivateFieldGet(this,em,`f`)&&__classPrivateFieldGet(this,am,`f`).unknownArguments(F,t,{},!1,!1),__classPrivateFieldGet(this,am,`f`).limitedChoices(F),__classPrivateFieldGet(this,am,`f`).implications(F),__classPrivateFieldGet(this,am,`f`).conflicting(F)}}[Bm](){__classPrivateFieldSet(this,Lp,!0,`f`)}[Vm](t){if(typeof t==`string`)__classPrivateFieldGet(this,Hp,`f`).key[t]=!0;else for(let n of t)__classPrivateFieldGet(this,Hp,`f`).key[n]=!0}}}),Wm,Gm=__esmMin(()=>{np(),Um(),Wm=YargsFactory(tp)});function classifyCliFailure(t,n){return typeof t==`string`&&t.length>0?{kind:`usage`,message:t}:{kind:`runtime`}}var Km=__esmMin(()=>{});function buildHeaders(t,n){let S={"user-agent":`gjsify-install/0.64.6`,"accept-encoding":n.acceptEncoding??`identity`};if(n.npmrc){let C=resolveAuthForUrl(t,n.npmrc);C&&(S.authorization=C)}if(n.headers)for(let[t,C]of Object.entries(n.headers))S[t.toLowerCase()]=C;return S}function resolveAuthForUrl(t,n){let S=pathPrefixes(new URL(t));for(let t of S){let S=n.authTokens[t];if(S)return`Bearer ${S}`;let C=n.basicAuth[t];if(C)return`Basic ${btoa(`${C.username}:${C.password}`)}`}return null}function pathPrefixes(t){let n=t.pathname.split(`/`).filter(Boolean),S=[];for(let C=n.length;C>=0;C--){let N=n.slice(0,C).join(`/`);S.push(N?`//${t.host}/${N}`:`//${t.host}`)}return S}var qm=__esmMin(()=>{}),PackageNotFoundError,IntegrityError,RegistryTimeoutError,RegistryUnreachableError,Jm=__esmMin(()=>{PackageNotFoundError=class extends Error{name;url;constructor(t,n){super(`Package not found in registry: ${t} (${n})`),this.name=t,this.url=n,this.name=`PackageNotFoundError`}},IntegrityError=class extends Error{url;integrity;constructor(t,n){super(`Tarball integrity mismatch for ${t} (expected ${n})`),this.url=t,this.integrity=n,this.name=`IntegrityError`}},RegistryTimeoutError=class extends Error{url;timeoutMs;attempts;constructor(t,n,S){let C=Math.round(n/100)/10,N=Math.round(n*S/100)/10;super(`@gjsify/npm-registry: GET ${t} timed out after ${C}s × ${S} attempt(s) (total ~${N}s). This usually means the registry CDN is slow or unreachable.`),this.url=t,this.timeoutMs=n,this.attempts=S,this.name=`RegistryTimeoutError`}},RegistryUnreachableError=class extends Error{url;attempts;elapsedMs;constructor(t,n,S,C){let N=Math.round(S/100)/10,F=C instanceof Error?C.message:String(C);super(`@gjsify/npm-registry: GET ${t} failed after ${n} attempt(s) over ~${N}s: ${F}. This usually means the registry or the network dropped out.`),this.url=t,this.attempts=n,this.elapsedMs=S,this.name=`RegistryUnreachableError`,this.cause=C}}});function registryFor(t,n){if(n&&t.startsWith(`@`)){let S=t.slice(0,t.indexOf(`/`)),C=n.scopes[S];if(C)return ensureTrailingSlash$1(C)}return n?.registry?ensureTrailingSlash$1(n.registry):Ym}function parseNpmrc(t){let n={registry:Ym,scopes:{},authTokens:{},basicAuth:{}},S=t.split(/\r?\n/),C={};for(let t of S){let S=t.replace(/^\s+|\s+$/g,``);if(!S||S.startsWith(`#`)||S.startsWith(`;`))continue;let N=S.indexOf(`=`);if(N<0)continue;let F=S.slice(0,N).trim(),I=expandEnv(stripQuotes(S.slice(N+1).trim()));if(F===`registry`){n.registry=ensureTrailingSlash$1(I);continue}let H=F.match(/^(@[^:]+):registry$/);if(H){n.scopes[H[1]]=ensureTrailingSlash$1(I);continue}let W=F.match(/^\/\/(.+):_authToken$/);if(W){n.authTokens[normalizeAuthHost(W[1])]=I;continue}let q=F.match(/^\/\/(.+):username$/);if(q){(C[normalizeAuthHost(q[1])]??={}).user=I;continue}let Y=F.match(/^\/\/(.+):_password$/);if(Y){let t=base64Decode$1(I);(C[normalizeAuthHost(Y[1])]??={}).pass=t;continue}}for(let[t,S]of Object.entries(C))S.user&&S.pass!==void 0&&(n.basicAuth[t]={username:S.user,password:S.pass});return n}function normalizeAuthHost(t){return`//${t.replace(/\/+$/,``)}`}function ensureTrailingSlash$1(t){return t.endsWith(`/`)?t:t+`/`}function stripQuotes(t){return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1):t}function expandEnv(t){return t.replace(/\$\{([A-Z0-9_]+)\}/gi,(t,n)=>globalThis.process?.env?.[n]??``)}function base64Decode$1(t){return atob(t)}var Ym,Xm=__esmMin(()=>{Ym=`https://registry.npmjs.org/`,__name$1(ensureTrailingSlash$1,`ensureTrailingSlash`),__name$1(base64Decode$1,`base64Decode`)});async function fetchWithRetry(t,n,S){let C=S.fetch??globalThis.fetch;if(!C)throw Error(`@gjsify/npm-registry: globalThis.fetch is missing`);let N=Math.max(0,S.retries??5),F=Math.max(0,S.retryDelayMs??1e3),I=Math.max(0,S.timeoutMs??3e4),H=S.retryNotFound??!1,W=Date.now(),q=0,Y,X=0;for(;;){if(n.signal?.aborted)throw signalAbortError(n.signal);let Z=I>0?new AbortController:null,te=Z===null?null:setTimeout(()=>Z.abort(Error(`@gjsify/npm-registry: per-request timeout ${I}ms`)),I),ne=composeSignals(n.signal,Z?.signal);try{let F=await C(t,{...n,signal:ne}),I=isRetryableStatus(F.status)||H&&F.status===404;if(F.ok||!I||q>=N)return S.read?await S.read(F):F;try{await F.arrayBuffer()}catch{}Y=Error(`HTTP ${F.status} ${F.statusText}`)}catch(S){let C=Z!==null&&Z.signal.aborted,F=n.signal?.aborted===!0;if(C&&!F){if(X++,q>=N)throw new RegistryTimeoutError(t,I,X);Y=S}else if(F)throw signalAbortError(n.signal);else{if(!isRetryableError(S))throw S;if(q>=N)throw new RegistryUnreachableError(t,q+1,Date.now()-W,S);Y=S}}finally{te!==null&&clearTimeout(te)}let re=Math.min(F*2**q,8e3);S.onRetry?.({attempt:q+1,error:Y,delayMs:re}),await delay$1(re,n.signal),q++}}function composeSignals(t,n){return t?n?AbortSignal.any([t,n]):t:n}function isRetryableStatus(t){return t===408||t===425||t===429||t===500||t===502||t===503||t===504||t===521||t===522||t===524||t===525}function isRetryableError(t){if(t&&typeof t==`object`&&`name`in t&&t.name===`AbortError`)return!1;if(t instanceof TypeError)return!0;if(t&&typeof t==`object`&&`name`in t){let n=t.name;if(n===`FetchError`)return!0;if(n===`AbortError`)return!1}let n=t?.cause;if(n&&typeof n==`object`&&`code`in n){let t=n.code;if(typeof t==`string`)return t===`ECONNRESET`||t===`ECONNREFUSED`||t===`ENETUNREACH`||t===`ENOTFOUND`||t===`ETIMEDOUT`||t===`EAI_AGAIN`||t===`UND_ERR_SOCKET`||t===`UND_ERR_CONNECT_TIMEOUT`}return!1}function delay$1(t,n){return t<=0?Promise.resolve():new Promise((S,C)=>{let N=setTimeout(()=>{n?.removeEventListener?.(`abort`,onAbort),S()},t),onAbort=()=>{clearTimeout(N),C(signalAbortError(n))};if(n?.aborted){clearTimeout(N),C(signalAbortError(n));return}n?.addEventListener?.(`abort`,onAbort,{once:!0})})}function signalAbortError(t){let n=t&&`reason`in t?t.reason:void 0;if(n instanceof Error)return n;let S=Error(`Aborted`);return S.name=`AbortError`,S}var Zm=__esmMin(()=>{Jm(),__name$1(delay$1,`delay`)});async function verifyIntegrity(t,n){let S=n.trim().split(/\s+/);for(let n of S){let S=n.indexOf(`-`);if(S<0)continue;let C=n.slice(0,S).toLowerCase(),N=n.slice(S+1),F=globalThis.crypto?.subtle;if(!F)throw Error(`@gjsify/npm-registry: globalThis.crypto.subtle is missing`);let I=subriToWebCryptoAlgo(C);if(!I)continue;let H=await F.digest(I,dataAsArrayBuffer(t));if(bytesToBase64(new Uint8Array(H))===N)return!0}return!1}function subriToWebCryptoAlgo(t){switch(t){case`sha1`:return`SHA-1`;case`sha256`:return`SHA-256`;case`sha384`:return`SHA-384`;case`sha512`:return`SHA-512`;default:return null}}function dataAsArrayBuffer(t){if(t.byteOffset===0&&t.byteLength===t.buffer.byteLength)return t.buffer;let n=new Uint8Array(t.byteLength);return n.set(t),n.buffer}function bytesToBase64(t){let n=``;for(let S=0;S<t.length;S++)n+=String.fromCharCode(t[S]);return btoa(n)}var Qm=__esmMin(()=>{});function assertPackument(t,n){if(!n||typeof n!=`object`)throw TypeError(`registry: ${t} packument is not an object`);let S=n;if(typeof S.name!=`string`)throw TypeError(`registry: ${t} packument missing string name`);if(!S.versions||typeof S.versions!=`object`)throw TypeError(`registry: ${t} packument missing versions map`)}function packumentUrl(t,n){let S=ensureTrailingSlash$1(n);if(t.startsWith(`@`)){let n=t.indexOf(`/`);if(n<0)throw TypeError(`Invalid scoped package name: ${t}`);let C=t.slice(0,n),N=t.slice(n+1);return`${S}${encodeURIComponent(C)}/${encodeURIComponent(N)}`}return`${S}${encodeURIComponent(t)}`}async function fetchPackumentConditional(t,n={}){let S=packumentUrl(t,n.registry??registryFor(t,n.npmrc)),C=buildHeaders(S,{...n,acceptEncoding:`gzip`});C.accept??=n.fullMetadata?`application/json`:`application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*`,n.ifNoneMatch&&(C[`if-none-match`]=n.ifNoneMatch);let N=await fetchWithRetry(S,{headers:C,signal:n.signal},{fetch:n.fetch,retries:n.retries,retryDelayMs:n.retryDelayMs,timeoutMs:n.timeoutMs,onRetry:n.onRetry,read:async n=>{if(n.status===304){try{await n.arrayBuffer()}catch{}return{status:`not-modified`}}if(!n.ok)throw n.status===404||n.status===406?new PackageNotFoundError(t,S):Error(`registry GET ${S} -> ${n.status} ${n.statusText}`);return{status:`fresh`,body:await decodeJsonBody(n),etag:n.headers.get(`etag`)??void 0}}});if(N.status===`not-modified`)return{status:`not-modified`,etag:n.ifNoneMatch};let F=N.body;return assertPackument(t,F),{status:`fresh`,packument:F,etag:N.etag}}async function decodeJsonBody(t){return t.json()}async function fetchPackument(t,n={}){let S=await fetchPackumentConditional(t,n);if(!S.packument)throw Error(`registry: ${t} returned 304 Not Modified to an unconditional request`);return S.packument}var $m=__esmMin(()=>{qm(),Jm(),Xm(),Zm()});async function fetchTarball(t,n={}){let S=buildHeaders(t,{...n,acceptEncoding:`identity`});S.accept??=`application/octet-stream`;let C=await fetchWithRetry(t,{headers:S,signal:n.signal},{fetch:n.fetch,retries:n.retries,retryDelayMs:n.retryDelayMs,timeoutMs:n.timeoutMs,onRetry:n.onRetry,retryNotFound:n.retryNotFound??!0,read:async n=>{if(!n.ok)throw Error(`tarball GET ${t} -> ${n.status} ${n.statusText}`);return new Uint8Array(await n.arrayBuffer())}});if(n.integrity&&!await verifyIntegrity(C,n.integrity))throw new IntegrityError(t,n.integrity);return C}var eh=__esmMin(()=>{qm(),Jm(),Zm(),Qm()});async function whoami(t,n){let S=`${ensureTrailingSlash$1(t)}-/whoami`,C=buildHeaders(S,{npmrc:n});C.accept=`application/json`;let N=globalThis.fetch;if(!N)throw Error(`@gjsify/npm-registry: globalThis.fetch is missing`);let F=await N(S,{method:`GET`,headers:C});if(!F.ok)throw Error(`whoami GET ${S} -> ${F.status} ${F.statusText}`);let I=await F.json();if(I&&typeof I==`object`&&`username`in I){let t=I.username;if(typeof t==`string`&&t.length>0)return{username:t}}return{}}var th=__esmMin(()=>{qm(),Xm()}),nh=__esmMin(()=>{qm(),Jm(),Xm(),Qm(),$m(),eh(),th()});function escapePackageName(t){return t.replace(`/`,`%2f`)}function buildPublishHeaders(t,n){let S=buildHeaders(t,{npmrc:n.npmrc});return S[`content-type`]=`application/json`,S[`npm-command`]=`publish`,S[`npm-auth-type`]=n.otp?`legacy`:`web`,S[`user-agent`]=n.userAgent??defaultUserAgent(),n.otp&&(S[`npm-otp`]=n.otp),n.authorization&&(S.authorization=n.authorization),S}function cliVersion(){return rh===void 0&&(rh=`0.64.6`),rh}function cliPackageDir(){let t=globalThis.process?.env?.GJSIFY_CLI_PACKAGE_JSON,n;try{n=On(t||fileURLToPath(import.meta.url))}catch{return null}for(let t=0;t<12;t++){try{if(JSON.parse(readFileSync(`${n}/package.json`,`utf8`)).name===`@gjsify/cli`)return n}catch{}let t=On(n);if(t===n)break;n=t}return null}function defaultUserAgent(){let t=globalThis.process,n=t?.arch??`x64`,S=t?.platform??`linux`;return`gjsify-publish/${cliVersion()} (${S} ${n})`}var rh,ih=__esmMin(()=>{Bd(),In(),qn(),nh()}),ah,oh=__esmMin(()=>{ah=`gjsify`});function parseDeclaredChannel(t,n){if(!(t===void 0||t===``)){if(sh.includes(t))return t;throw Error(`${n}: "${String(t)}" is not a distribution channel. Known: ${sh.join(`, `)}.`)}}function channelAllowsDonations(t){return t!==void 0&&ch[t]===!0}var sh,ch,lh,uh=__esmMin(()=>{sh=[`flathub`,`web`,`microsoft-store`,`apple-app-store`],ch={flathub:!0,web:!0,"microsoft-store":!1,"apple-app-store":!1},lh=`GJSIFY_CHANNEL`}),dh=__commonJSMin(((t,n)=>{let S=(In(),__toCommonJS(xn)),C=(Rl(),__toCommonJS(Pl)),N=(Bd(),__toCommonJS(Rd)),resolveFrom=(t,n,F)=>{if(typeof t!=`string`)throw TypeError(`Expected \`fromDir\` to be of type \`string\`, got \`${typeof t}\``);if(typeof n!=`string`)throw TypeError(`Expected \`moduleId\` to be of type \`string\`, got \`${typeof n}\``);try{t=N.realpathSync(t)}catch(n){if(n.code===`ENOENT`)t=S.resolve(t);else if(F)return null;else throw n}let I=S.join(t,`noop.js`),resolveFileName=()=>C._resolveFilename(n,{id:I,filename:I,paths:C._nodeModulePaths(t)});if(F)try{return resolveFileName()}catch{return null}return resolveFileName()};n.exports=(t,n)=>resolveFrom(t,n),n.exports.silent=(t,n)=>resolveFrom(t,n,!0)})),fh=__commonJSMin(((t,n)=>{let callsites=()=>{let t=Error.prepareStackTrace;Error.prepareStackTrace=(t,n)=>n;let n=Error().stack.slice(1);return Error.prepareStackTrace=t,n};n.exports=callsites,n.exports.default=callsites})),ph=__commonJSMin(((t,n)=>{let S=fh();n.exports=t=>{let n=S();if(!t)return n[2].getFileName();let C=!1;n.shift();for(let S of n){let n=S.getFileName();if(typeof n==`string`){if(n===t){C=!0;continue}if(n!==`module.js`&&C&&n!==t)return n}}}})),mh=__commonJSMin(((t,n)=>{var{__gjsifyModuleDir:S,__gjsifyModuleFile:C}=(Hl(),__toCommonJS(zl)),N=S(`import-fresh/index.js`),F=C(`import-fresh/index.js`);let I=(In(),__toCommonJS(xn)),H=dh(),W=ph();n.exports=t=>{if(typeof t!=`string`)throw TypeError(`Expected a string`);let n=W(F),S=n?I.dirname(n):N,C=H(S,t),q=Y.cache[C];if(q&&q.parent){let t=q.parent.children.length;for(;t--;)q.parent.children[t].id===C&&q.parent.children.splice(t,1)}delete Y.cache[C];let X=Y.cache[n];return X===void 0||X.require===void 0?Y(C):X.require(C)}})),hh=__commonJSMin(((t,n)=>{n.exports=function isArrayish(t){return t?t instanceof Array||Array.isArray(t)||t.length>=0&&t.splice instanceof Function:!1}})),gh=__commonJSMin(((t,n)=>{var S=(Du(),__toCommonJS(Cu)),C=hh(),N=function errorEx(t,n){(!t||t.constructor!==String)&&(n=t||{},t=Error.name);var N=function ErrorEXError(S){if(!this)return new ErrorEXError(S);S=S instanceof Error?S.message:S||this.message,Error.call(this,S),Error.captureStackTrace(this,N),this.name=t,Object.defineProperty(this,"message",{configurable:!0,enumerable:!1,get:function(){var t=S.split(/\r?\n/g);for(var N in n)if(n.hasOwnProperty(N)){var F=n[N];`message`in F&&(t=F.message(this[N],t)||t,C(t)||(t=[t]))}return t.join(`
|
|
148
|
+
`,`f`),__classPrivateFieldSet(this,Vp,__classPrivateFieldGet(this,Vp,`f`)+t.join(` `),`f`)}}}[cm](t){objectKeys(__classPrivateFieldGet(this,Hp,`f`)).forEach(n=>{if((t=>t===`configObjects`)(n))return;let S=__classPrivateFieldGet(this,Hp,`f`)[n];Array.isArray(S)?S.includes(t)&&S.splice(S.indexOf(t),1):typeof S==`object`&&delete S[t]}),delete __classPrivateFieldGet(this,tm,`f`).getDescriptions()[t]}[lm](t,n,S){__classPrivateFieldGet(this,Mp,`f`)[S]||(__classPrivateFieldGet(this,Zp,`f`).process.emitWarning(t,n),__classPrivateFieldGet(this,Mp,`f`)[S]=!0)}[um](){__classPrivateFieldGet(this,Pp,`f`).push({options:__classPrivateFieldGet(this,Hp,`f`),configObjects:__classPrivateFieldGet(this,Hp,`f`).configObjects.slice(0),exitProcess:__classPrivateFieldGet(this,Np,`f`),groups:__classPrivateFieldGet(this,Ip,`f`),strict:__classPrivateFieldGet(this,Qp,`f`),strictCommands:__classPrivateFieldGet(this,$p,`f`),strictOptions:__classPrivateFieldGet(this,em,`f`),completionCommand:__classPrivateFieldGet(this,Op,`f`),output:__classPrivateFieldGet(this,Vp,`f`),exitError:__classPrivateFieldGet(this,Ap,`f`),hasOutput:__classPrivateFieldGet(this,Lp,`f`),parsed:this.parsed,parseFn:__classPrivateFieldGet(this,Gp,`f`),parseContext:__classPrivateFieldGet(this,Kp,`f`)}),__classPrivateFieldGet(this,tm,`f`).freeze(),__classPrivateFieldGet(this,am,`f`).freeze(),__classPrivateFieldGet(this,wp,`f`).freeze(),__classPrivateFieldGet(this,Fp,`f`).freeze()}[dm](){let t=``,n;return n=/\b(node|iojs|electron)(\.exe)?$/.test(__classPrivateFieldGet(this,Zp,`f`).process.argv()[0])?__classPrivateFieldGet(this,Zp,`f`).process.argv().slice(1,2):__classPrivateFieldGet(this,Zp,`f`).process.argv().slice(0,1),t=n.map(t=>{let n=this[Im](__classPrivateFieldGet(this,Tp,`f`),t);return t.match(/^(\/|([a-zA-Z]:)?\\)/)&&n.length<t.length?n:t}).join(` `).trim(),__classPrivateFieldGet(this,Zp,`f`).getEnv(`_`)&&__classPrivateFieldGet(this,Zp,`f`).getProcessArgvBin()===__classPrivateFieldGet(this,Zp,`f`).getEnv(`_`)&&(t=__classPrivateFieldGet(this,Zp,`f`).getEnv(`_`).replace(`${__classPrivateFieldGet(this,Zp,`f`).path.dirname(__classPrivateFieldGet(this,Zp,`f`).process.execPath())}/`,``)),t}[fm](){return __classPrivateFieldGet(this,Wp,`f`)}[pm](){return __classPrivateFieldGet(this,nm,`f`)}[mm](){if(!__classPrivateFieldGet(this,jp,`f`))return;let t=__classPrivateFieldGet(this,Zp,`f`).getEnv(`LC_ALL`)||__classPrivateFieldGet(this,Zp,`f`).getEnv(`LC_MESSAGES`)||__classPrivateFieldGet(this,Zp,`f`).getEnv(`LANG`)||__classPrivateFieldGet(this,Zp,`f`).getEnv(`LANGUAGE`)||`en_US`;this.locale(t.replace(/[.:].*/,``))}[hm](){return this[_m]().version||`unknown`}[gm](t){let n=t[`--`]?t[`--`]:t._;for(let t=0,S;(S=n[t])!==void 0;t++)__classPrivateFieldGet(this,Zp,`f`).Parser.looksLikeNumber(S)&&Number.isSafeInteger(Math.floor(parseFloat(`${S}`)))&&(n[t]=Number(S));return t}[_m](t){let n=t||`*`;if(__classPrivateFieldGet(this,qp,`f`)[n])return __classPrivateFieldGet(this,qp,`f`)[n];let S={};try{let n=t||__classPrivateFieldGet(this,Zp,`f`).mainFilename;__classPrivateFieldGet(this,Zp,`f`).path.extname(n)&&(n=__classPrivateFieldGet(this,Zp,`f`).path.dirname(n));let C=__classPrivateFieldGet(this,Zp,`f`).findUp(n,(t,n)=>{if(n.includes(`package.json`))return`package.json`});assertNotStrictEqual(C,void 0,__classPrivateFieldGet(this,Zp,`f`)),S=JSON.parse(__classPrivateFieldGet(this,Zp,`f`).readFileSync(C,`utf8`))}catch{}return __classPrivateFieldGet(this,qp,`f`)[n]=S||{},__classPrivateFieldGet(this,qp,`f`)[n]}[vm](t,n){n=[].concat(n),n.forEach(n=>{n=this[Sm](n),__classPrivateFieldGet(this,Hp,`f`)[t].push(n)})}[ym](t,n,S,C){this[xm](t,n,S,C,(t,n,S)=>{__classPrivateFieldGet(this,Hp,`f`)[t][n]=S})}[bm](t,n,S,C){this[xm](t,n,S,C,(t,n,S)=>{__classPrivateFieldGet(this,Hp,`f`)[t][n]=(__classPrivateFieldGet(this,Hp,`f`)[t][n]||[]).concat(S)})}[xm](t,n,S,C,N){if(Array.isArray(S))S.forEach(n=>{t(n,C)});else if((t=>typeof t==`object`)(S))for(let n of objectKeys(S))t(n,S[n]);else N(n,this[Sm](S),C)}[Sm](t){return t===`__proto__`?`___proto___`:t}[Cm](t,n){return this[ym](this[Cm].bind(this),`key`,t,n),this}[wm](){var t,n,S,C,N,F,I,H,W,q,Y,X;let Z=__classPrivateFieldGet(this,Pp,`f`).pop();assertNotStrictEqual(Z,void 0,__classPrivateFieldGet(this,Zp,`f`));let te;t=this,n=this,S=this,C=this,N=this,F=this,I=this,H=this,W=this,q=this,Y=this,X=this,{options:{set value(n){__classPrivateFieldSet(t,Hp,n,`f`)}}.value,configObjects:te,exitProcess:{set value(t){__classPrivateFieldSet(n,Np,t,`f`)}}.value,groups:{set value(t){__classPrivateFieldSet(S,Ip,t,`f`)}}.value,output:{set value(t){__classPrivateFieldSet(C,Vp,t,`f`)}}.value,exitError:{set value(t){__classPrivateFieldSet(N,Ap,t,`f`)}}.value,hasOutput:{set value(t){__classPrivateFieldSet(F,Lp,t,`f`)}}.value,parsed:this.parsed,strict:{set value(t){__classPrivateFieldSet(I,Qp,t,`f`)}}.value,strictCommands:{set value(t){__classPrivateFieldSet(H,$p,t,`f`)}}.value,strictOptions:{set value(t){__classPrivateFieldSet(W,em,t,`f`)}}.value,completionCommand:{set value(t){__classPrivateFieldSet(q,Op,t,`f`)}}.value,parseFn:{set value(t){__classPrivateFieldSet(Y,Gp,t,`f`)}}.value,parseContext:{set value(t){__classPrivateFieldSet(X,Kp,t,`f`)}}.value}=Z,__classPrivateFieldGet(this,Hp,`f`).configObjects=te,__classPrivateFieldGet(this,tm,`f`).unfreeze(),__classPrivateFieldGet(this,am,`f`).unfreeze(),__classPrivateFieldGet(this,wp,`f`).unfreeze(),__classPrivateFieldGet(this,Fp,`f`).unfreeze()}[Tm](t,n){return maybeAsyncResult(n,n=>(t(n),n))}getInternalMethods(){return{getCommandInstance:this[Em].bind(this),getContext:this[Dm].bind(this),getHasOutput:this[Om].bind(this),getLoggerInstance:this[km].bind(this),getParseContext:this[Am].bind(this),getParserConfiguration:this[fm].bind(this),getUsageConfiguration:this[pm].bind(this),getUsageInstance:this[jm].bind(this),getValidationInstance:this[Mm].bind(this),hasParseCallback:this[Nm].bind(this),isGlobalContext:this[Pm].bind(this),postProcess:this[Fm].bind(this),reset:this[Lm].bind(this),runValidation:this[zm].bind(this),runYargsParserAndExecuteCommands:this[Rm].bind(this),setHasOutput:this[Bm].bind(this)}}[Em](){return __classPrivateFieldGet(this,wp,`f`)}[Dm](){return __classPrivateFieldGet(this,Ep,`f`)}[Om](){return __classPrivateFieldGet(this,Lp,`f`)}[km](){return __classPrivateFieldGet(this,Bp,`f`)}[Am](){return __classPrivateFieldGet(this,Kp,`f`)||{}}[jm](){return __classPrivateFieldGet(this,tm,`f`)}[Mm](){return __classPrivateFieldGet(this,am,`f`)}[Nm](){return!!__classPrivateFieldGet(this,Gp,`f`)}[Pm](){return __classPrivateFieldGet(this,zp,`f`)}[Fm](t,n,S,C){return S||isPromise(t)?t:(n||(t=this[om](t)),(this[fm]()[`parse-positional-numbers`]||this[fm]()[`parse-positional-numbers`]===void 0)&&(t=this[gm](t)),C&&(t=applyMiddleware(t,this,__classPrivateFieldGet(this,Fp,`f`).getMiddleware(),!1)),t)}[Lm](t={}){__classPrivateFieldSet(this,Hp,__classPrivateFieldGet(this,Hp,`f`)||{},`f`);let n={};n.local=__classPrivateFieldGet(this,Hp,`f`).local||[],n.configObjects=__classPrivateFieldGet(this,Hp,`f`).configObjects||[];let S={};return n.local.forEach(n=>{S[n]=!0,(t[n]||[]).forEach(t=>{S[t]=!0})}),Object.assign(__classPrivateFieldGet(this,Jp,`f`),Object.keys(__classPrivateFieldGet(this,Ip,`f`)).reduce((t,n)=>{let C=__classPrivateFieldGet(this,Ip,`f`)[n].filter(t=>!(t in S));return C.length>0&&(t[n]=C),t},{})),__classPrivateFieldSet(this,Ip,{},`f`),[`array`,`boolean`,`string`,`skipValidation`,`count`,`normalize`,`number`,`hiddenOptions`].forEach(t=>{n[t]=(__classPrivateFieldGet(this,Hp,`f`)[t]||[]).filter(t=>!S[t])}),[`narg`,`key`,`alias`,`default`,`defaultDescription`,`config`,`choices`,`demandedOptions`,`demandedCommands`,`deprecatedOptions`].forEach(t=>{n[t]=objFilter(__classPrivateFieldGet(this,Hp,`f`)[t],t=>!S[t])}),n.envPrefix=__classPrivateFieldGet(this,Hp,`f`).envPrefix,__classPrivateFieldSet(this,Hp,n,`f`),__classPrivateFieldSet(this,tm,__classPrivateFieldGet(this,tm,`f`)?__classPrivateFieldGet(this,tm,`f`).reset(S):usage(this,__classPrivateFieldGet(this,Zp,`f`)),`f`),__classPrivateFieldSet(this,am,__classPrivateFieldGet(this,am,`f`)?__classPrivateFieldGet(this,am,`f`).reset(S):validation(this,__classPrivateFieldGet(this,tm,`f`),__classPrivateFieldGet(this,Zp,`f`)),`f`),__classPrivateFieldSet(this,wp,__classPrivateFieldGet(this,wp,`f`)?__classPrivateFieldGet(this,wp,`f`).reset():command(__classPrivateFieldGet(this,tm,`f`),__classPrivateFieldGet(this,am,`f`),__classPrivateFieldGet(this,Fp,`f`),__classPrivateFieldGet(this,Zp,`f`)),`f`),__classPrivateFieldGet(this,Dp,`f`)||__classPrivateFieldSet(this,Dp,completion(this,__classPrivateFieldGet(this,tm,`f`),__classPrivateFieldGet(this,wp,`f`),__classPrivateFieldGet(this,Zp,`f`)),`f`),__classPrivateFieldGet(this,Fp,`f`).reset(),__classPrivateFieldSet(this,Op,null,`f`),__classPrivateFieldSet(this,Vp,``,`f`),__classPrivateFieldSet(this,Ap,null,`f`),__classPrivateFieldSet(this,Lp,!1,`f`),this.parsed=!1,this}[Im](t,n){return __classPrivateFieldGet(this,Zp,`f`).path.relative(t,n)}[Rm](t,n,S,C=0,N=!1){let F=!!S||N;t||=__classPrivateFieldGet(this,Yp,`f`),__classPrivateFieldGet(this,Hp,`f`).__=__classPrivateFieldGet(this,Zp,`f`).y18n.__,__classPrivateFieldGet(this,Hp,`f`).configuration=this[fm]();let I=!!__classPrivateFieldGet(this,Hp,`f`).configuration[`populate--`],H=Object.assign({},__classPrivateFieldGet(this,Hp,`f`).configuration,{"populate--":!0}),W=__classPrivateFieldGet(this,Zp,`f`).Parser.detailed(t,Object.assign({},__classPrivateFieldGet(this,Hp,`f`),{configuration:{"parse-positional-numbers":!1,...H}})),q=Object.assign(W.argv,__classPrivateFieldGet(this,Kp,`f`)),Y,X=W.aliases,Z=!1,te=!1;Object.keys(q).forEach(t=>{t===__classPrivateFieldGet(this,Rp,`f`)&&q[t]?Z=!0:t===__classPrivateFieldGet(this,im,`f`)&&q[t]&&(te=!0)}),q.$0=this.$0,this.parsed=W,C===0&&__classPrivateFieldGet(this,tm,`f`).clearCachedHelpMessage();try{if(this[mm](),n)return this[Fm](q,I,!!S,!1);__classPrivateFieldGet(this,Rp,`f`)&&[__classPrivateFieldGet(this,Rp,`f`)].concat(X[__classPrivateFieldGet(this,Rp,`f`)]||[]).filter(t=>t.length>1).includes(``+q._[q._.length-1])&&(q._.pop(),Z=!0),__classPrivateFieldSet(this,zp,!1,`f`);let H=__classPrivateFieldGet(this,wp,`f`).getCommands(),ne=__classPrivateFieldGet(this,Dp,`f`)?.completionKey?[__classPrivateFieldGet(this,Dp,`f`)?.completionKey,...this.getAliases()[__classPrivateFieldGet(this,Dp,`f`)?.completionKey]??[]].some(t=>Object.prototype.hasOwnProperty.call(q,t)):!1,re=Z||ne||N;if(q._.length){if(H.length){let t;for(let n=C||0,F;q._[n]!==void 0;n++)if(F=String(q._[n]),H.includes(F)&&F!==__classPrivateFieldGet(this,Op,`f`)){let t=__classPrivateFieldGet(this,wp,`f`).runCommand(F,this,W,n+1,N,Z||te||N);return this[Fm](t,I,!!S,!1)}else if(!t&&F!==__classPrivateFieldGet(this,Op,`f`)){t=F;break}!__classPrivateFieldGet(this,wp,`f`).hasDefaultCommand()&&__classPrivateFieldGet(this,Xp,`f`)&&t&&!re&&__classPrivateFieldGet(this,am,`f`).recommendCommands(t,H)}__classPrivateFieldGet(this,Op,`f`)&&q._.includes(__classPrivateFieldGet(this,Op,`f`))&&!ne&&(__classPrivateFieldGet(this,Np,`f`)&&setBlocking(!0),this.showCompletionScript(),this.exit(0))}if(__classPrivateFieldGet(this,wp,`f`).hasDefaultCommand()&&!re){let t=__classPrivateFieldGet(this,wp,`f`).runCommand(null,this,W,0,N,Z||te||N);return this[Fm](t,I,!!S,!1)}if(ne){__classPrivateFieldGet(this,Np,`f`)&&setBlocking(!0),t=[].concat(t);let n=t.slice(t.indexOf(`--${__classPrivateFieldGet(this,Dp,`f`).completionKey}`)+1);return __classPrivateFieldGet(this,Dp,`f`).getCompletion(n,(t,n)=>{if(t)throw new wl(t.message);(n||[]).forEach(t=>{__classPrivateFieldGet(this,Bp,`f`).log(t)}),this.exit(0)}),this[Fm](q,!I,!!S,!1)}if(__classPrivateFieldGet(this,Lp,`f`)||(Z?(__classPrivateFieldGet(this,Np,`f`)&&setBlocking(!0),F=!0,this.showHelp(t=>{__classPrivateFieldGet(this,Bp,`f`).log(t),this.exit(0)})):te&&(__classPrivateFieldGet(this,Np,`f`)&&setBlocking(!0),F=!0,__classPrivateFieldGet(this,tm,`f`).showVersion(`log`),this.exit(0))),!F&&__classPrivateFieldGet(this,Hp,`f`).skipValidation.length>0&&(F=Object.keys(q).some(t=>__classPrivateFieldGet(this,Hp,`f`).skipValidation.indexOf(t)>=0&&q[t]===!0)),!F){if(W.error)throw new wl(W.error.message);if(!ne){let t=this[zm](X,{},W.error);S||(Y=applyMiddleware(q,this,__classPrivateFieldGet(this,Fp,`f`).getMiddleware(),!0)),Y=this[Tm](t,Y??q),isPromise(Y)&&!S&&(Y=Y.then(()=>applyMiddleware(q,this,__classPrivateFieldGet(this,Fp,`f`).getMiddleware(),!1)))}}}catch(t){if(t instanceof wl)__classPrivateFieldGet(this,tm,`f`).fail(t.message,t);else throw t}return this[Fm](Y??q,I,!!S,!0)}[zm](t,n,S,C){let N={...this.getDemandedOptions()};return F=>{if(S)throw new wl(S.message);__classPrivateFieldGet(this,am,`f`).nonOptionCount(F),__classPrivateFieldGet(this,am,`f`).requiredArguments(F,N);let I=!1;__classPrivateFieldGet(this,$p,`f`)&&(I=__classPrivateFieldGet(this,am,`f`).unknownCommands(F)),__classPrivateFieldGet(this,Qp,`f`)&&!I?__classPrivateFieldGet(this,am,`f`).unknownArguments(F,t,n,!!C):__classPrivateFieldGet(this,em,`f`)&&__classPrivateFieldGet(this,am,`f`).unknownArguments(F,t,{},!1,!1),__classPrivateFieldGet(this,am,`f`).limitedChoices(F),__classPrivateFieldGet(this,am,`f`).implications(F),__classPrivateFieldGet(this,am,`f`).conflicting(F)}}[Bm](){__classPrivateFieldSet(this,Lp,!0,`f`)}[Vm](t){if(typeof t==`string`)__classPrivateFieldGet(this,Hp,`f`).key[t]=!0;else for(let n of t)__classPrivateFieldGet(this,Hp,`f`).key[n]=!0}}}),Wm,Gm=__esmMin(()=>{np(),Um(),Wm=YargsFactory(tp)});function classifyCliFailure(t,n){return typeof t==`string`&&t.length>0?{kind:`usage`,message:t}:{kind:`runtime`}}var Km=__esmMin(()=>{});function buildHeaders(t,n){let S={"user-agent":`gjsify-install/0.64.8`,"accept-encoding":n.acceptEncoding??`identity`};if(n.npmrc){let C=resolveAuthForUrl(t,n.npmrc);C&&(S.authorization=C)}if(n.headers)for(let[t,C]of Object.entries(n.headers))S[t.toLowerCase()]=C;return S}function resolveAuthForUrl(t,n){let S=pathPrefixes(new URL(t));for(let t of S){let S=n.authTokens[t];if(S)return`Bearer ${S}`;let C=n.basicAuth[t];if(C)return`Basic ${btoa(`${C.username}:${C.password}`)}`}return null}function pathPrefixes(t){let n=t.pathname.split(`/`).filter(Boolean),S=[];for(let C=n.length;C>=0;C--){let N=n.slice(0,C).join(`/`);S.push(N?`//${t.host}/${N}`:`//${t.host}`)}return S}var qm=__esmMin(()=>{}),PackageNotFoundError,IntegrityError,RegistryTimeoutError,RegistryUnreachableError,Jm=__esmMin(()=>{PackageNotFoundError=class extends Error{name;url;constructor(t,n){super(`Package not found in registry: ${t} (${n})`),this.name=t,this.url=n,this.name=`PackageNotFoundError`}},IntegrityError=class extends Error{url;integrity;constructor(t,n){super(`Tarball integrity mismatch for ${t} (expected ${n})`),this.url=t,this.integrity=n,this.name=`IntegrityError`}},RegistryTimeoutError=class extends Error{url;timeoutMs;attempts;constructor(t,n,S){let C=Math.round(n/100)/10,N=Math.round(n*S/100)/10;super(`@gjsify/npm-registry: GET ${t} timed out after ${C}s × ${S} attempt(s) (total ~${N}s). This usually means the registry CDN is slow or unreachable.`),this.url=t,this.timeoutMs=n,this.attempts=S,this.name=`RegistryTimeoutError`}},RegistryUnreachableError=class extends Error{url;attempts;elapsedMs;constructor(t,n,S,C){let N=Math.round(S/100)/10,F=C instanceof Error?C.message:String(C);super(`@gjsify/npm-registry: GET ${t} failed after ${n} attempt(s) over ~${N}s: ${F}. This usually means the registry or the network dropped out.`),this.url=t,this.attempts=n,this.elapsedMs=S,this.name=`RegistryUnreachableError`,this.cause=C}}});function registryFor(t,n){if(n&&t.startsWith(`@`)){let S=t.slice(0,t.indexOf(`/`)),C=n.scopes[S];if(C)return ensureTrailingSlash$1(C)}return n?.registry?ensureTrailingSlash$1(n.registry):Ym}function parseNpmrc(t){let n={registry:Ym,scopes:{},authTokens:{},basicAuth:{}},S=t.split(/\r?\n/),C={};for(let t of S){let S=t.replace(/^\s+|\s+$/g,``);if(!S||S.startsWith(`#`)||S.startsWith(`;`))continue;let N=S.indexOf(`=`);if(N<0)continue;let F=S.slice(0,N).trim(),I=expandEnv(stripQuotes(S.slice(N+1).trim()));if(F===`registry`){n.registry=ensureTrailingSlash$1(I);continue}let H=F.match(/^(@[^:]+):registry$/);if(H){n.scopes[H[1]]=ensureTrailingSlash$1(I);continue}let W=F.match(/^\/\/(.+):_authToken$/);if(W){n.authTokens[normalizeAuthHost(W[1])]=I;continue}let q=F.match(/^\/\/(.+):username$/);if(q){(C[normalizeAuthHost(q[1])]??={}).user=I;continue}let Y=F.match(/^\/\/(.+):_password$/);if(Y){let t=base64Decode$1(I);(C[normalizeAuthHost(Y[1])]??={}).pass=t;continue}}for(let[t,S]of Object.entries(C))S.user&&S.pass!==void 0&&(n.basicAuth[t]={username:S.user,password:S.pass});return n}function normalizeAuthHost(t){return`//${t.replace(/\/+$/,``)}`}function ensureTrailingSlash$1(t){return t.endsWith(`/`)?t:t+`/`}function stripQuotes(t){return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1):t}function expandEnv(t){return t.replace(/\$\{([A-Z0-9_]+)\}/gi,(t,n)=>globalThis.process?.env?.[n]??``)}function base64Decode$1(t){return atob(t)}var Ym,Xm=__esmMin(()=>{Ym=`https://registry.npmjs.org/`,__name$1(ensureTrailingSlash$1,`ensureTrailingSlash`),__name$1(base64Decode$1,`base64Decode`)});async function fetchWithRetry(t,n,S){let C=S.fetch??globalThis.fetch;if(!C)throw Error(`@gjsify/npm-registry: globalThis.fetch is missing`);let N=Math.max(0,S.retries??5),F=Math.max(0,S.retryDelayMs??1e3),I=Math.max(0,S.timeoutMs??3e4),H=S.retryNotFound??!1,W=Date.now(),q=0,Y,X=0;for(;;){if(n.signal?.aborted)throw signalAbortError(n.signal);let Z=I>0?new AbortController:null,te=Z===null?null:setTimeout(()=>Z.abort(Error(`@gjsify/npm-registry: per-request timeout ${I}ms`)),I),ne=composeSignals(n.signal,Z?.signal);try{let F=await C(t,{...n,signal:ne}),I=isRetryableStatus(F.status)||H&&F.status===404;if(F.ok||!I||q>=N)return S.read?await S.read(F):F;try{await F.arrayBuffer()}catch{}Y=Error(`HTTP ${F.status} ${F.statusText}`)}catch(S){let C=Z!==null&&Z.signal.aborted,F=n.signal?.aborted===!0;if(C&&!F){if(X++,q>=N)throw new RegistryTimeoutError(t,I,X);Y=S}else if(F)throw signalAbortError(n.signal);else{if(!isRetryableError(S))throw S;if(q>=N)throw new RegistryUnreachableError(t,q+1,Date.now()-W,S);Y=S}}finally{te!==null&&clearTimeout(te)}let re=Math.min(F*2**q,8e3);S.onRetry?.({attempt:q+1,error:Y,delayMs:re}),await delay$1(re,n.signal),q++}}function composeSignals(t,n){return t?n?AbortSignal.any([t,n]):t:n}function isRetryableStatus(t){return t===408||t===425||t===429||t===500||t===502||t===503||t===504||t===521||t===522||t===524||t===525}function isRetryableError(t){if(t&&typeof t==`object`&&`name`in t&&t.name===`AbortError`)return!1;if(t instanceof TypeError)return!0;if(t&&typeof t==`object`&&`name`in t){let n=t.name;if(n===`FetchError`)return!0;if(n===`AbortError`)return!1}let n=t?.cause;if(n&&typeof n==`object`&&`code`in n){let t=n.code;if(typeof t==`string`)return t===`ECONNRESET`||t===`ECONNREFUSED`||t===`ENETUNREACH`||t===`ENOTFOUND`||t===`ETIMEDOUT`||t===`EAI_AGAIN`||t===`UND_ERR_SOCKET`||t===`UND_ERR_CONNECT_TIMEOUT`}return!1}function delay$1(t,n){return t<=0?Promise.resolve():new Promise((S,C)=>{let N=setTimeout(()=>{n?.removeEventListener?.(`abort`,onAbort),S()},t),onAbort=()=>{clearTimeout(N),C(signalAbortError(n))};if(n?.aborted){clearTimeout(N),C(signalAbortError(n));return}n?.addEventListener?.(`abort`,onAbort,{once:!0})})}function signalAbortError(t){let n=t&&`reason`in t?t.reason:void 0;if(n instanceof Error)return n;let S=Error(`Aborted`);return S.name=`AbortError`,S}var Zm=__esmMin(()=>{Jm(),__name$1(delay$1,`delay`)});async function verifyIntegrity(t,n){let S=n.trim().split(/\s+/);for(let n of S){let S=n.indexOf(`-`);if(S<0)continue;let C=n.slice(0,S).toLowerCase(),N=n.slice(S+1),F=globalThis.crypto?.subtle;if(!F)throw Error(`@gjsify/npm-registry: globalThis.crypto.subtle is missing`);let I=subriToWebCryptoAlgo(C);if(!I)continue;let H=await F.digest(I,dataAsArrayBuffer(t));if(bytesToBase64(new Uint8Array(H))===N)return!0}return!1}function subriToWebCryptoAlgo(t){switch(t){case`sha1`:return`SHA-1`;case`sha256`:return`SHA-256`;case`sha384`:return`SHA-384`;case`sha512`:return`SHA-512`;default:return null}}function dataAsArrayBuffer(t){if(t.byteOffset===0&&t.byteLength===t.buffer.byteLength)return t.buffer;let n=new Uint8Array(t.byteLength);return n.set(t),n.buffer}function bytesToBase64(t){let n=``;for(let S=0;S<t.length;S++)n+=String.fromCharCode(t[S]);return btoa(n)}var Qm=__esmMin(()=>{});function assertPackument(t,n){if(!n||typeof n!=`object`)throw TypeError(`registry: ${t} packument is not an object`);let S=n;if(typeof S.name!=`string`)throw TypeError(`registry: ${t} packument missing string name`);if(!S.versions||typeof S.versions!=`object`)throw TypeError(`registry: ${t} packument missing versions map`)}function packumentUrl(t,n){let S=ensureTrailingSlash$1(n);if(t.startsWith(`@`)){let n=t.indexOf(`/`);if(n<0)throw TypeError(`Invalid scoped package name: ${t}`);let C=t.slice(0,n),N=t.slice(n+1);return`${S}${encodeURIComponent(C)}/${encodeURIComponent(N)}`}return`${S}${encodeURIComponent(t)}`}async function fetchPackumentConditional(t,n={}){let S=packumentUrl(t,n.registry??registryFor(t,n.npmrc)),C=buildHeaders(S,{...n,acceptEncoding:`gzip`});C.accept??=n.fullMetadata?`application/json`:`application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*`,n.ifNoneMatch&&(C[`if-none-match`]=n.ifNoneMatch);let N=await fetchWithRetry(S,{headers:C,signal:n.signal},{fetch:n.fetch,retries:n.retries,retryDelayMs:n.retryDelayMs,timeoutMs:n.timeoutMs,onRetry:n.onRetry,read:async n=>{if(n.status===304){try{await n.arrayBuffer()}catch{}return{status:`not-modified`}}if(!n.ok)throw n.status===404||n.status===406?new PackageNotFoundError(t,S):Error(`registry GET ${S} -> ${n.status} ${n.statusText}`);return{status:`fresh`,body:await decodeJsonBody(n),etag:n.headers.get(`etag`)??void 0}}});if(N.status===`not-modified`)return{status:`not-modified`,etag:n.ifNoneMatch};let F=N.body;return assertPackument(t,F),{status:`fresh`,packument:F,etag:N.etag}}async function decodeJsonBody(t){return t.json()}async function fetchPackument(t,n={}){let S=await fetchPackumentConditional(t,n);if(!S.packument)throw Error(`registry: ${t} returned 304 Not Modified to an unconditional request`);return S.packument}var $m=__esmMin(()=>{qm(),Jm(),Xm(),Zm()});async function fetchTarball(t,n={}){let S=buildHeaders(t,{...n,acceptEncoding:`identity`});S.accept??=`application/octet-stream`;let C=await fetchWithRetry(t,{headers:S,signal:n.signal},{fetch:n.fetch,retries:n.retries,retryDelayMs:n.retryDelayMs,timeoutMs:n.timeoutMs,onRetry:n.onRetry,retryNotFound:n.retryNotFound??!0,read:async n=>{if(!n.ok)throw Error(`tarball GET ${t} -> ${n.status} ${n.statusText}`);return new Uint8Array(await n.arrayBuffer())}});if(n.integrity&&!await verifyIntegrity(C,n.integrity))throw new IntegrityError(t,n.integrity);return C}var eh=__esmMin(()=>{qm(),Jm(),Zm(),Qm()});async function whoami(t,n){let S=`${ensureTrailingSlash$1(t)}-/whoami`,C=buildHeaders(S,{npmrc:n});C.accept=`application/json`;let N=globalThis.fetch;if(!N)throw Error(`@gjsify/npm-registry: globalThis.fetch is missing`);let F=await N(S,{method:`GET`,headers:C});if(!F.ok)throw Error(`whoami GET ${S} -> ${F.status} ${F.statusText}`);let I=await F.json();if(I&&typeof I==`object`&&`username`in I){let t=I.username;if(typeof t==`string`&&t.length>0)return{username:t}}return{}}var th=__esmMin(()=>{qm(),Xm()}),nh=__esmMin(()=>{qm(),Jm(),Xm(),Qm(),$m(),eh(),th()});function escapePackageName(t){return t.replace(`/`,`%2f`)}function buildPublishHeaders(t,n){let S=buildHeaders(t,{npmrc:n.npmrc});return S[`content-type`]=`application/json`,S[`npm-command`]=`publish`,S[`npm-auth-type`]=n.otp?`legacy`:`web`,S[`user-agent`]=n.userAgent??defaultUserAgent(),n.otp&&(S[`npm-otp`]=n.otp),n.authorization&&(S.authorization=n.authorization),S}function cliVersion(){return rh===void 0&&(rh=`0.64.8`),rh}function cliPackageDir(){let t=globalThis.process?.env?.GJSIFY_CLI_PACKAGE_JSON,n;try{n=On(t||fileURLToPath(import.meta.url))}catch{return null}for(let t=0;t<12;t++){try{if(JSON.parse(readFileSync(`${n}/package.json`,`utf8`)).name===`@gjsify/cli`)return n}catch{}let t=On(n);if(t===n)break;n=t}return null}function defaultUserAgent(){let t=globalThis.process,n=t?.arch??`x64`,S=t?.platform??`linux`;return`gjsify-publish/${cliVersion()} (${S} ${n})`}var rh,ih=__esmMin(()=>{Bd(),In(),qn(),nh()}),ah,oh=__esmMin(()=>{ah=`gjsify`});function parseDeclaredChannel(t,n){if(!(t===void 0||t===``)){if(sh.includes(t))return t;throw Error(`${n}: "${String(t)}" is not a distribution channel. Known: ${sh.join(`, `)}.`)}}function channelAllowsDonations(t){return t!==void 0&&ch[t]===!0}var sh,ch,lh,uh=__esmMin(()=>{sh=[`flathub`,`web`,`microsoft-store`,`apple-app-store`],ch={flathub:!0,web:!0,"microsoft-store":!1,"apple-app-store":!1},lh=`GJSIFY_CHANNEL`}),dh=__commonJSMin(((t,n)=>{let S=(In(),__toCommonJS(xn)),C=(Rl(),__toCommonJS(Pl)),N=(Bd(),__toCommonJS(Rd)),resolveFrom=(t,n,F)=>{if(typeof t!=`string`)throw TypeError(`Expected \`fromDir\` to be of type \`string\`, got \`${typeof t}\``);if(typeof n!=`string`)throw TypeError(`Expected \`moduleId\` to be of type \`string\`, got \`${typeof n}\``);try{t=N.realpathSync(t)}catch(n){if(n.code===`ENOENT`)t=S.resolve(t);else if(F)return null;else throw n}let I=S.join(t,`noop.js`),resolveFileName=()=>C._resolveFilename(n,{id:I,filename:I,paths:C._nodeModulePaths(t)});if(F)try{return resolveFileName()}catch{return null}return resolveFileName()};n.exports=(t,n)=>resolveFrom(t,n),n.exports.silent=(t,n)=>resolveFrom(t,n,!0)})),fh=__commonJSMin(((t,n)=>{let callsites=()=>{let t=Error.prepareStackTrace;Error.prepareStackTrace=(t,n)=>n;let n=Error().stack.slice(1);return Error.prepareStackTrace=t,n};n.exports=callsites,n.exports.default=callsites})),ph=__commonJSMin(((t,n)=>{let S=fh();n.exports=t=>{let n=S();if(!t)return n[2].getFileName();let C=!1;n.shift();for(let S of n){let n=S.getFileName();if(typeof n==`string`){if(n===t){C=!0;continue}if(n!==`module.js`&&C&&n!==t)return n}}}})),mh=__commonJSMin(((t,n)=>{var{__gjsifyModuleDir:S,__gjsifyModuleFile:C}=(Hl(),__toCommonJS(zl)),N=S(`import-fresh/index.js`),F=C(`import-fresh/index.js`);let I=(In(),__toCommonJS(xn)),H=dh(),W=ph();n.exports=t=>{if(typeof t!=`string`)throw TypeError(`Expected a string`);let n=W(F),S=n?I.dirname(n):N,C=H(S,t),q=Y.cache[C];if(q&&q.parent){let t=q.parent.children.length;for(;t--;)q.parent.children[t].id===C&&q.parent.children.splice(t,1)}delete Y.cache[C];let X=Y.cache[n];return X===void 0||X.require===void 0?Y(C):X.require(C)}})),hh=__commonJSMin(((t,n)=>{n.exports=function isArrayish(t){return t?t instanceof Array||Array.isArray(t)||t.length>=0&&t.splice instanceof Function:!1}})),gh=__commonJSMin(((t,n)=>{var S=(Du(),__toCommonJS(Cu)),C=hh(),N=function errorEx(t,n){(!t||t.constructor!==String)&&(n=t||{},t=Error.name);var N=function ErrorEXError(S){if(!this)return new ErrorEXError(S);S=S instanceof Error?S.message:S||this.message,Error.call(this,S),Error.captureStackTrace(this,N),this.name=t,Object.defineProperty(this,"message",{configurable:!0,enumerable:!1,get:function(){var t=S.split(/\r?\n/g);for(var N in n)if(n.hasOwnProperty(N)){var F=n[N];`message`in F&&(t=F.message(this[N],t)||t,C(t)||(t=[t]))}return t.join(`
|
|
149
149
|
`)},set:function(t){S=t}});var F=null,I=Object.getOwnPropertyDescriptor(this,`stack`),H=I.get,W=I.value;delete I.value,delete I.writable,I.set=function(t){F=t},I.get=function(){var t=(F||(H?H.call(this):W)).split(/\r?\n+/g);F||(t[0]=this.name+`: `+this.message);var S=1;for(var C in n)if(n.hasOwnProperty(C)){var N=n[C];if(`line`in N){var I=N.line(this[C]);I&&t.splice(S++,0,` `+I)}`stack`in N&&N.stack(this[C],t)}return t.join(`
|
|
150
150
|
`)},Object.defineProperty(this,"stack",I)};return Object.setPrototypeOf?(Object.setPrototypeOf(N.prototype,Error.prototype),Object.setPrototypeOf(N,Error)):S.inherits(N,Error),N};N.append=function(t,n){return{message:function(S,C){return S||=n,S&&(C[0]+=` `+t.replace(`%s`,S.toString())),C}}},N.line=function(t,n){return{line:function(S){return S||=n,S?t.replace(`%s`,S.toString()):null}}},n.exports=N})),vh=__commonJSMin(((t,n)=>{let hexify=t=>{let n=t.charCodeAt(0).toString(16).toUpperCase();return`0x`+(n.length%2?`0`:``)+n},parseError=(t,n,S)=>{if(!n)return{message:t.message+` while parsing empty string`,position:0};let C=t.message.match(/^Unexpected token (.) .*position\s+(\d+)/i),N=C?+C[2]:t.message.match(/^Unexpected end of JSON.*/i)?n.length-1:null,F=C?t.message.replace(/^Unexpected token ./,`Unexpected token ${JSON.stringify(C[1])} (${hexify(C[1])})`):t.message;if(N!=null){let t=N<=S?0:N-S,C=N+S>=n.length?n.length:N+S,I=(t===0?``:`...`)+n.slice(t,C)+(C===n.length?``:`...`);return{message:F+` while parsing ${n===I?``:`near `}${JSON.stringify(I)}`,position:N}}else return{message:F+` while parsing '${n.slice(0,S*2)}'`,position:0}};var JSONParseError=class extends SyntaxError{constructor(t,n,S,C){S||=20;let N=parseError(t,n,S);super(N.message),Object.assign(this,N),this.code=`EJSONPARSE`,this.systemError=t,Error.captureStackTrace(this,C||this.constructor)}get name(){return this.constructor.name}set name(t){}get[Symbol.toStringTag](){return this.constructor.name}};let S=Symbol.for(`indent`),C=Symbol.for(`newline`),N=/^\s*[{\[]((?:\r?\n)+)([\s\t]*)/,F=/^(?:\{\}|\[\])((?:\r?\n)+)?$/,parseJson=(t,n,I)=>{let H=stripBOM(t);I||=20;try{let[,t=`
|
|
151
151
|
`,I=` `]=H.match(F)||H.match(N)||[,``,``],W=JSON.parse(H,n);return W&&typeof W==`object`&&(W[C]=t,W[S]=I),W}catch(n){if(typeof t!=`string`&&!Buffer.isBuffer(t)){let S=Array.isArray(t)&&t.length===0;throw Object.assign(TypeError(`Cannot parse ${S?`an empty array`:String(t)}`),{code:`EJSONPARSE`,systemError:n})}throw new JSONParseError(n,H,I,parseJson)}},stripBOM=t=>String(t).replace(/^\uFEFF/,``);n.exports=parseJson,parseJson.JSONParseError=JSONParseError,parseJson.noExceptions=(t,n)=>{try{return JSON.parse(stripBOM(t),n)}catch{}}})),yh=__commonJSMin((t=>{t.__esModule=!0,t.LinesAndColumns=void 0;var n=`
|
|
@@ -943,7 +943,7 @@ No install command available for your package manager. Install manually.`),proce
|
|
|
943
943
|
`);for(let t of n){if(t.link!==void 0){let n;try{n=hashFileStream(t.abs)}catch{n=`link:${t.link}`}S.update(`${t.rel} ${n}\n`);continue}try{S.update(`${t.rel} ${hashFileStream(t.abs)}\n`)}catch{S.update(`${t.rel} unreadable\n`)}}return S.digest(`hex`)}function walkFiles(t,n,S){let C;try{C=readdirSync(t)}catch{return}C.sort();for(let N of C){if(N===`node_modules`)continue;let C=$(t,N),F=n===``?N:`${n}/${N}`,I;try{I=lstatSync(C)}catch{continue}if(I.isSymbolicLink())try{S.push({rel:F,abs:C,link:readlinkSync(C)})}catch{}else I.isDirectory()?walkFiles(C,F,S):I.isFile()&&S.push({rel:F,abs:C})}}function hashOutputDirs(t,n){let S=createHash(`sha256`);S.update(`gjsify-build-cache-outputs/v4
|
|
944
944
|
`);for(let C of[...n].sort()){let n=$(t,C);if(!existsSync(n)){S.update(`${C} absent\n`);continue}let N=[];walkFiles(n,C,N);for(let t of N){if(t.link!==void 0){S.update(`${t.rel} link:${t.link}\n`);continue}try{S.update(`${t.rel} ${hashFileStream(t.abs)}\n`)}catch{S.update(`${t.rel} unreadable\n`)}}}return S.digest(`hex`)}function outputUnits(t){let n=[];for(let S of TR){let C=$(t,S);if(!existsSync(C))continue;let N;try{N=readdirSync(C).filter(t=>t!==`node_modules`&&!isBuildInfo(t))}catch{continue}let F=N.every(t=>{try{return lstatSync($(C,t)).isDirectory()}catch{return!1}});if(N.length===0||!F){n.push(S);continue}for(let t of[...N].sort())n.push(`${S}/${t}`)}return n}function signatureOf(t,n){let S=[];walkFiles($(t,n),n,S);let C=createHash(`sha256`);for(let t of S){let n=`link`;if(t.link===void 0)try{let S=lstatSync(t.abs);n=`${S.size}:${S.mtimeMs}`}catch{n=`gone`}C.update(`${t.rel} ${n}\n`)}return C.digest(`hex`)}function snapshotOutputDirs(t){let n={};for(let t of TR)n[t]=null;for(let S of outputUnits(t))n[S]=signatureOf(t,S);return n}function modifiedOutputDirs(t,n){let S=[];for(let C of outputUnits(t))signatureOf(t,C)!==(n[C]??null)&&S.push(C);return S.sort()}function composeCacheKey(t){let n=createHash(`sha256`);n.update(`gjsify-build-cache/v4
|
|
945
945
|
`),n.update(`script:${t.script}\n`);for(let S of t.args??[])n.update(`arg:${S}\n`);for(let S of Object.keys(t.toolchain).sort())n.update(`tool:${S}@${t.toolchain[S]}\n`);n.update(`self:${t.ownHash}\n`);let S=t.depHashes instanceof Map?t.depHashes:new Map(Object.entries(t.depHashes));for(let t of[...S.keys()].sort())n.update(`dep:${t} ${S.get(t)}\n`);return n.digest(`hex`).slice(0,32)}function resolveToolchainVersions(t){let n={};for(let S of ER){let C=`none`;try{let n=readFileSync($(t,`node_modules`,...S.split(`/`),`package.json`),`utf-8`),N=JSON.parse(n);typeof N.version==`string`&&(C=N.version)}catch{}S===`@gjsify/cli`&&C===`none`&&(C=readOwnCliVersion()??`none`),n[S]=C}return n}function readOwnCliVersion(){try{let t=On(fileURLToPath(import.meta.url));for(let n=0;n<4;n++){let n=$(t,`package.json`);if(existsSync(n)){let t=JSON.parse(readFileSync(n,`utf-8`));if(t.name===`@gjsify/cli`&&typeof t.version==`string`)return t.version}t=On(t)}}catch{}return null}function copyDirRecursive(t,n){mkdirSync(n,{recursive:!0});for(let S of readdirSync(t).sort()){let C=$(t,S),N=$(n,S),F=lstatSync(C);if(F.isSymbolicLink())replicateLinkSync(C,N);else if(F.isDirectory())copyDirRecursive(C,N);else if(F.isFile()){copyFileSync(C,N);try{chmodSync(N,F.mode&511)}catch{}}}}function buildCacheEntryDir(t,n,S){return $(t,sanitizePackageDirName(n),S)}function readCacheEntry(t,n,S){let C=$(DR(t,n,S),`manifest.json`);try{let N=JSON.parse(readFileSync(C,`utf-8`));if(N.version!==1||N.layout!==`v4`||N.package!==n||N.key!==S||!Array.isArray(N.dirs))return null;for(let C of N.dirs)if(!existsSync($(DR(t,n,S),`outputs`,C)))return null;return N}catch{return null}}function storeCacheEntry(t,n,S,C,N){let F=DR(t,n.name,S),I=`${F}.tmp-${process.pid}`;try{rmSync(I,{recursive:!0,force:!0}),mkdirSync($(I,`outputs`),{recursive:!0});for(let t of N)copyDirRecursive($(n.location,t),$(I,`outputs`,t));let H=new Date().toISOString(),W={version:1,layout:`v4`,package:n.name,script:C,key:S,dirs:[...N],outputsHash:hashOutputDirs(n.location,N),createdAt:H,usedAt:H};return writeFileSync($(I,`manifest.json`),JSON.stringify(W,null,2)),rmSync(F,{recursive:!0,force:!0}),renameSync(I,F),pruneCacheEntries(t,n.name),W}catch{try{rmSync(I,{recursive:!0,force:!0})}catch{}return null}}function restoreCacheEntry(t,n,S){let C=DR(t,n.name,S.key);try{if(S.dirs.length>0&&hashOutputDirs(n.location,S.dirs)===S.outputsHash)return touchManifestUsed(C,S),`up-to-date`;for(let t of S.dirs){let S=$(n.location,t);rmSync(S,{recursive:!0,force:!0}),copyDirRecursive($(C,`outputs`,t),S)}return touchManifestUsed(C,S),S.dirs.length>0?`restored`:`up-to-date`}catch{return null}}function touchManifestUsed(t,n){try{n.usedAt=new Date().toISOString(),writeFileSync($(t,`manifest.json`),JSON.stringify(n,null,2))}catch{}}function pruneCacheEntries(t,n,S=2){let C=$(t,sanitizePackageDirName(n)),N;try{N=readdirSync(C)}catch{return}let F=[];for(let t of N){if(t.includes(`.tmp-`)){try{rmSync($(C,t),{recursive:!0,force:!0})}catch{}continue}let n=``;try{let S=JSON.parse(readFileSync($(C,t,`manifest.json`),`utf-8`));n=S.usedAt??S.createdAt??``}catch{}F.push({name:t,stamp:n})}if(!(F.length<=S)){F.sort((t,n)=>t.stamp<n.stamp?1:t.stamp>n.stamp?-1:0);for(let t of F.slice(S))try{rmSync($(C,t.name),{recursive:!0,force:!0})}catch{}}}function buildCacheOptedOut(t){return t.manifest.gjsify?.buildCache===!1}var TR,ER,isBuildInfo,DR,BuildCacheRunner,OR=__esmMin(()=>{_e(),el(),Bd(),In(),qn(),eF(),VL(),TI(),TR=CI,ER=[`@gjsify/cli`,`@gjsify/tsc`,`rolldown`,`typescript`],isBuildInfo=t=>t.endsWith(`.tsbuildinfo`),DR=buildCacheEntryDir,BuildCacheRunner=class{options;cacheRoot;graph;toolchain;ownHashes=new Map;closures=new Map;keys=new Map;log;constructor(t){this.options=t,this.cacheRoot=buildCacheRoot(t.root),this.graph=buildDependencyGraph(t.workspaces,{includeDev:!0,includePeer:!0,includeOptional:!0}),this.toolchain=resolveToolchainVersions(t.root),this.log=t.log??(t=>ge.error(t));for(let n of t.targets??[])if(this.graph.byName.has(n)){this.ownHashOf(n);for(let t of this.closureOf(n))this.ownHashOf(t)}}ownHashOf(t){let n=this.ownHashes.get(t);if(n===void 0){let S=this.graph.byName.get(t);n=S?hashPackageInputs(S.location):`unknown-workspace`,this.ownHashes.set(t,n)}return n}closureOf(t){let n=this.closures.get(t);if(n===void 0){let S=new Set,C=[...this.graph.edges.get(t)??[]];for(;C.length>0;){let n=C.shift();if(!(n===t||S.has(n))){S.add(n);for(let N of this.graph.edges.get(n)??[])!S.has(N)&&N!==t&&C.push(N)}}n=[...S].sort(),this.closures.set(t,n)}return n}keyFor(t){let n=this.keys.get(t.name);if(n===void 0){let S=new Map;for(let n of this.closureOf(t.name))S.set(n,this.ownHashOf(n));n=composeCacheKey({script:this.options.script,args:this.options.args,toolchain:this.toolchain,ownHash:this.ownHashOf(t.name),depHashes:S}),this.keys.set(t.name,n)}return n}tryRestore(t){try{if(buildCacheOptedOut(t))return this.log(`[gjsify build-cache] ${t.name}: opted out (gjsify.buildCache=false) — running uncached`),!1;let n=this.keyFor(t),S=readCacheEntry(this.cacheRoot,t.name,n);if(!S||S.script!==this.options.script)return this.log(`[gjsify build-cache] ${t.name}: miss ${n} — running "${this.options.script}"`),!1;let C=restoreCacheEntry(this.cacheRoot,t,S);if(C===null)return this.log(`[gjsify build-cache] ${t.name}: entry ${n} unrestorable — running "${this.options.script}"`),!1;let N=S.dirs.length>0?S.dirs.join(`, `):`no output dirs`;return this.log(`[gjsify build-cache] ${t.name}: hit ${n} — ${C===`restored`?`restored ${N}`:`${N} up to date`} (skipped "${this.options.script}")`),!0}catch(n){return this.log(`[gjsify build-cache] ${t.name}: cache error (${n.message}) — running uncached`),!1}}snapshotOutputs(t){try{return snapshotOutputDirs(t.location)}catch{return{}}}storeAfterSuccess(t,n){try{if(buildCacheOptedOut(t))return;let S=this.keyFor(t),C=modifiedOutputDirs(t.location,n);if(storeCacheEntry(this.cacheRoot,t,S,this.options.script,C)){let n=C.length>0?C.join(`, `):`no output dirs modified`;this.log(`[gjsify build-cache] ${t.name}: stored ${S} (${n})`)}}catch(n){this.log(`[gjsify build-cache] ${t.name}: store failed (${n.message}) — continuing`)}}}});function editDistance(t,n){if(t===n)return 0;if(t.length===0)return n.length;if(n.length===0)return t.length;let S=Array.from({length:n.length+1},(t,n)=>n),C=Array.from({length:n.length+1},()=>0);for(let N=1;N<=t.length;N++){C[0]=N;for(let F=1;F<=n.length;F++){let I=t[N-1]===n[F-1]?0:1;C[F]=Math.min(S[F]+1,C[F-1]+1,S[F-1]+I)}[S,C]=[C,S]}return S[n.length]}function suggestClosest(t,n){if(n.length===0)return;let S=t.toLowerCase(),C=Math.max(2,Math.floor(t.length/3)),N,F=1/0;for(let t of n){let n=editDistance(S,t.toLowerCase());n<F&&(F=n,N=t)}return N!==void 0&&F<=C?N:void 0}var kR=__esmMin(()=>{});function reportUnlinked(t,n){for(let S of t)n.has(S.from)&&ge.error(`gjsify workspace: "${S.from}" depends on "${S.to}": ${S.spec}, which the local workspace (${S.to}@${S.version}) does not satisfy — NOT built as a dependency. npm and yarn take that one from the registry; \`gjsify install\` links the local one anyway, so if it is the local one you mean, make the range admit ${S.version}.`)}async function runOne$1(t,n,S,C,N,F){if(F&&F.tryRestore(t))return;let I=F?.snapshotOutputs(t),H=C===`gjsify`?[`run`,n,...S]:[`run`,n,...S.length>0?[`--`,...S]:[]];N&&ge.error(`[${t.name}] $ ${C} ${H.join(` `)}`);let{code:W}=await spawnToCompletion(C,H,{completion:`exit`,cwd:t.location,color:!0});if(W!==0)throw Error(`${C} ${H.join(` `)} exited with code ${W}`);F&&I&&F.storeAfterSuccess(t,I)}function detectPackageManager(){if(isGjs()||usingSelfShim())return`gjsify`;let t=process.env.npm_config_user_agent??``;return t.startsWith(`yarn/`)?`yarn`:t.startsWith(`gjsify/`)?`gjsify`:`npm`}var AR,jR=__esmMin(()=>{_e(),U_(),eF(),nF(),OR(),p_(),hR(),kR(),AR={command:`workspace <name> <script> [args..]`,description:"Run a workspace script. Both `workspace <name> <script>` and the yarn spelling `workspace <name> run <script>` work.",builder:t=>t.positional(`name`,{description:"Workspace name (matches package.json `name` field).",type:`string`,demandOption:!0}).positional(`script`,{description:`Script name to run inside that workspace.`,type:`string`,demandOption:!0}).positional(`args`,{description:`Extra arguments forwarded to the script.`,type:`string`,array:!0}).option(`with-dependencies`,{description:"Pre-build the target workspace's transitive workspace dependencies in topological order before running the script in the target. Deps that don't declare the script are skipped (--if-present behaviour). Replaces manual `gjsify workspace A build && gjsify workspace B build && …` chains.",type:`boolean`,alias:[`d`,`t`,`topological`],default:!1}).option(`include-dev`,{description:"When --with-dependencies is set, also walk devDependencies (production deps only by default — matches `gjsify foreach -t`).",type:`boolean`,default:!1}).option(`continue-on-error`,{description:`When --with-dependencies is set, keep running remaining deps after one fails (default: stop on first failure).`,type:`boolean`,default:!1}).option(`verbose`,{description:`Echo every spawned command before running it.`,type:`boolean`,alias:`v`,default:!1}).option(`cached`,{description:`Content-hash build cache (ADR 0006): skip the script for a workspace whose inputs (src/**, package.json, tsconfig*.json, transitive workspace deps, toolchain versions) are unchanged and restore its stored outputs instead; on miss run it and store the output dirs it modified. Also applies to the deps run via --with-dependencies. Default from GJSIFY_BUILD_CACHE=1.`,type:`boolean`}),handler:async t=>{let n=findWorkspaceRoot(process.cwd())??process.cwd(),S=discoverWorkspaces(n),C=S.find(n=>n.name===t.name);if(!C){let C=suggestClosest(t.name,S.map(t=>t.name)),N=C?` — did you mean "${C}"?`:``;return ge.error(`gjsify workspace: no workspace named "${t.name}"${N} (discovered ${S.length} workspace(s) under ${n})`),process.exit(1)}let N=detectPackageManager(),F=t.verbose===!0,I=t[`with-dependencies`]===!0,H=t[`continue-on-error`]===!0,W=t.script,q=t.args??[];W===`run`&&q.length>0&&([W,...q]=q);let Y=C.manifest.scripts??{};if(typeof Y[W]!=`string`){let n=suggestClosest(W,Object.keys(Y));return ge.error(`gjsify workspace: workspace "${t.name}" has no script "${W}"`+(n?` — did you mean "${n}"?`:``)),process.exit(1)}let X;if(I){let n=t[`include-dev`]===!0,N=buildDependencyGraph(S,{includeDev:n}),F=affectedClosure(N,[C.name]),I=S.filter(t=>F.has(t.name));reportUnlinked(N.unlinked,F),X=topologicalSort(buildDependencyGraph(I,{includeDev:n})),X.length===1&&ge.error(`gjsify workspace: --with-dependencies found no workspace dependencies of "${C.name}" — running "${W}" in it alone.`)}else X=[C];let Z=t.cached??buildCacheEnabledByEnv()?new BuildCacheRunner({root:n,workspaces:S,script:W,args:q,targets:X.map(t=>t.name)}):void 0,te=[];for(let t of X){if(typeof(t.manifest.scripts??{})[W]!=`string`){F&&ge.error(`[${t.name}] (no "${W}" script — skipping)`);continue}try{await runOne$1(t,W,q,N,F,Z)}catch(n){let S=n instanceof Error?n:Error(String(n));if(ge.error(`[${t.name}] ${S.message}`),!H)return process.exit(1);te.push({workspace:t.name,error:S})}}return te.length>0?(ge.error(`gjsify workspace: ${te.length} workspace(s) failed: ${te.map(t=>t.workspace).join(`, `)}`),process.exit(1)):process.exit(0)}},__name$1(runOne$1,`runOne`)});async function runCheck(t,n){let S=[],C=detectPackageManager();if(C===`gjsify`&&readPackageJson$2($(t.location,`package.json`))?.scripts?.check===void 0)return 0;let N=C===`gjsify`?[`run`,`check`]:[`run`,`check`,`--if-present`];try{let{code:F}=await spawnToCompletion(C,N,{completion:`exit`,cwd:t.location,stdio:n===null?`inherit`:`pipe`,onSpawn:t=>{let C=!process.stdout.isTTY;if(n!==null&&t.stdout&&t.stderr){let N=`[${n}] `;S.push(prefixLines(t.stdout,process.stdout,N,C)),S.push(prefixLines(t.stderr,process.stderr,N,C))}}});for(let t of S)t();return F??1}catch{for(let t of S)t();return 1}}var MR,NR=__esmMin(()=>{_e(),wR(),U_(),tF(),In(),zg(),eF(),nF(),jR(),MR={command:`check`,description:"Run `npm run check` (TypeScript type-check) across the current workspace. In a workspace root: walks every package with a `check` script (excludes @girs/*; honours --include/--exclude). In a single package: runs the local `check` script directly. Symmetric peer of `gjsify format` / `lint` / `fix`. (Legacy system-dep `gjsify check` is now `gjsify system-check` — see #254.)",builder:t=>t.option(`include`,{description:`Only run in workspaces matching these glob patterns (repeatable).`,type:`string`,array:!0}).option(`exclude`,{description:`Skip workspaces matching these glob patterns (repeatable). Always excludes @girs/*.`,type:`string`,array:!0}).option(`parallel`,{description:`Run workspace checks in parallel (default). Use --no-parallel to run them sequentially with full per-workspace output.`,type:`boolean`,alias:`p`,default:!0}).option(`jobs`,{description:`Max parallel workers (when --parallel). Default: os.cpus().length.`,type:`number`,alias:`j`}).option(`verbose`,{description:`Log the per-workspace command before spawning.`,type:`boolean`,default:!1}),handler:async t=>{let n=process.cwd(),S=findWorkspaceRoot(n);if(S&&n!==S&&readPackageJson$2($(n,`package.json`))?.scripts?.check){t.verbose&&ge.log(`[check] cwd=${n} → npm run check`);let{code:S}=await spawnToCompletion(detectPackageManager(),[`run`,`check`],{cwd:n,completion:`exit`});return process.exit(S??1)}if(!S)return ge.error("gjsify check: no workspace root found from cwd. Run inside a workspace (or a package within one) with `npm run check` defined."),process.exit(1);let C=discoverWorkspaces(S),N=[`@girs/*`,...t.exclude??[]],F=filterWorkspaces(C,{include:t.include,exclude:N}).filter(t=>t.manifest.scripts?.check!==void 0);if(F.length===0)return ge.error("gjsify check: no workspaces with a `check` script found."),process.exit(1);if(t.verbose&&ge.log(`[check] root=${S} workspaces=${F.length} parallel=${t.parallel?`yes`:`no`}`),!t.parallel){let n=0,S=0;for(let C of F){t.verbose&&ge.log(`[check] → ${C.name}`);let N=await runCheck(C,null);N!==0&&(S++,n===0&&(n=N))}return n!==0&&ge.error(`gjsify check: failures in ${S} workspace(s)`),process.exit(n)}let I=t.jobs??Math.max(1,cpus().length),H=[],W=0,q=[];for(let t=0;t<I;t++)q.push((async()=>{for(;;){let t=W++;if(t>=F.length)return;let n=F[t],S=await runCheck(n,n.name);S!==0&&H.push({name:n.name,code:S})}})());if(await Promise.all(q),H.length>0){ge.error(`\ngjsify check: ${H.length} of ${F.length} workspace(s) failed:`);for(let t of H)ge.error(` ✗ ${t.name} (exit ${t.code})`);return process.exit(1)}t.verbose&&ge.log(`\ngjsify check: ${F.length} workspace(s) green.`),process.exit(0)}}});function manifestPath(){let t=process.env.GJSIFY_SHOWCASES_MANIFEST;if(t)return t;let n=On(fileURLToPath(import.meta.url)),S=[$(n,`..`,`..`,`showcases.json`),$(n,`..`,`showcases.json`)];return S.find(t=>existsSync(t))??S[0]}function discoverShowcases(){let t=manifestPath();if(!existsSync(t))return[];let n;try{n=JSON.parse(readFileSync(t,`utf-8`))}catch{return[]}if(!Array.isArray(n.showcases))return[];let S=n.showcases.map(t=>({name:t.name,packageName:t.package,category:t.category,description:t.description??``}));return S.sort((t,n)=>t.category.localeCompare(n.category)||t.name.localeCompare(n.name)),S}function findShowcase(t){return discoverShowcases().find(n=>n.name===t)}var PR=__esmMin(()=>{Bd(),In(),qn()});function parseSpec(t){if(!t)throw Error(`dlx: empty package spec`);if(t.startsWith(`./`)||t.startsWith(`../`)||Tn(t)||existsSync(t))return{kind:`local`,path:Cn(t)};let n=t,S,C=t.lastIndexOf(`@`);if(C>0&&(n=t.slice(0,C),S=t.slice(C+1)),!FR.test(n))throw Error(`dlx: invalid package name "${n}"`);return{kind:`registry`,name:n,version:S,spec:t}}var FR,IR=__esmMin(()=>{Bd(),In(),FR=/^(?:@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/});function resolveGjsEntry(t,n){let S=$(t,`package.json`);if(!existsSync(S))throw Error(`dlx: no package.json found at ${t}`);let C=JSON.parse(readFileSync(S,`utf-8`)),N=C.gjsify?.bin,F=C.gjsify?.main,I=C.main,H,W=null,q=!1;if(n!==null){if(!N||!N[n]){let S=N?Object.keys(N).join(`, `):`(none)`;throw Error(`dlx: package "${C.name??t}" has no GJS bin named "${n}" — known: ${S}`)}H=N[n],W=n}else if(N&&Object.keys(N).length===1){let t=Object.keys(N)[0];H=N[t],W=t}else F?H=F:I&&(H=I,q=!0);if(N&&Object.keys(N).length>1&&n===null){let n=Object.keys(N).join(`, `);throw Error(`dlx: package "${C.name??t}" defines multiple GJS bins — pass one of: ${n}`)}if(!H)throw Error(`dlx: package "${C.name??t}" has no GJS entry — set \`gjsify.main\` (or \`gjsify.bin\`) in its package.json`);let Y=Cn(t,H);if(!existsSync(Y))throw Error(`dlx: GJS entry not found: ${Y}`);return{bundlePath:Y,binName:W,fromFallback:q}}function resolveNodeEntry(t){let n=$(t,`package.json`);if(!existsSync(n))throw Error(`no package.json found at ${t}`);let S=JSON.parse(readFileSync(n,`utf-8`)),C=S.gjsify?.example?.node;if(C){let n=Cn(t,C);if(!existsSync(n))throw Error(`declared node entry not found: ${n} (gjsify.example.node)`);return n}let N=S.gjsify?.main??(S.gjsify?.bin?Object.values(S.gjsify.bin)[0]:void 0)??S.main;if(!N)throw Error(`package "${S.name??t}" has no entry to derive a node bundle from — set \`gjsify.example.node\` to its \`--app node\` bundle path.`);let F=N.replace(/\.gjs\.(js|mjs|cjs)$/,``).replace(/\.(js|mjs|cjs)$/,``),I=[`${F}.node.mjs`,`${F}.node.js`,`${F}.node.cjs`];for(let n of I){let S=Cn(t,n);if(existsSync(S))return S}throw Error(`package "${S.name??t}" has no \`--app node\` bundle — looked for ${I.join(`, `)}.\n Build one (e.g. \`gjsify build src/app.ts --app node --outfile dist/app.node.mjs\`) or set \`gjsify.example.node\` to its path.`)}var LR=__esmMin(()=>{Bd(),In()});function lexCompare(t,n){return t<n?-1:+(t>n)}function createCacheKey(t){let n=[...t.packages].sort(lexCompare),S=Object.entries(t.registries??{}).sort(([t],[n])=>lexCompare(t,n)),C=JSON.stringify([n,S]);return createHash(`sha256`).update(C).digest(`hex`)}function dlxCacheRoot(){let t=process.env.XDG_CACHE_HOME,n=$(t&&t.length>0?t:$(homedir(),`.cache`),`gjsify`,`dlx`);return mkdirSync(n,{recursive:!0}),n}function cacheDirFor(t){let n=$(dlxCacheRoot(),t);return mkdirSync(n,{recursive:!0}),n}function makePrepareDir(t){let n=$(t,`${Date.now().toString(16)}-${process.pid.toString(16)}`);return mkdirSync(n,{recursive:!0}),n}function getValidCachedPkg(t,n=zR){let S=$(t,`pkg`),C;try{C=lstatSync(S)}catch(t){if(t.code===`ENOENT`)return;throw t}if(!C.isSymbolicLink())return;let N;try{N=realpathSync(S)}catch{return}return Date.now()-C.mtime.getTime()<=n*RR?N:void 0}function symlinkSwap(t,n,S={}){let C=S.junctions??dirLinksAreJunctions(),N=$(t,`pkg`),F=$(t,`pkg.tmp-${Date.now().toString(16)}-${process.pid.toString(16)}`);linkDirSync(F,n);try{C&&rmSync(N,{force:!0,recursive:!1,maxRetries:10,retryDelay:100}),renameSync(F,N)}catch(t){let S=t.code;if(S===`EBUSY`||S===`EPERM`||S===`EEXIST`||S===`EACCES`){rmSync(F,{force:!0});try{return realpathSync(N)}catch{return realpathSync(n)}}throw t}return realpathSync(N)}function resolveInstalledPkgDir(t,n){return Cn(t,`node_modules`,n)}var RR,zR,BR=__esmMin(()=>{el(),Bd(),zg(),In(),VL(),RR=6e4,zR=1440*7});async function ensurePkgDir(t,n){if(t.kind===`local`)return{pkgDir:t.path,cachedPkgName:null};let S=[t.spec,...n.extraSpecs??[]],C=cacheDirFor(createCacheKey({packages:S})),N=n.cacheMaxAge>0?getValidCachedPkg(C,n.cacheMaxAge):void 0;if(N)return{pkgDir:resolveInstalledPkgDir(N,t.name),cachedPkgName:t.name};let F=makePrepareDir(C),I=makeProgressReporter({enabled:!n.verbose});return await installPackages({prefix:F,specs:S,verbose:n.verbose,registry:n.registry,lockfile:!0,frozen:n.frozen,progress:I}),{pkgDir:resolveInstalledPkgDir(symlinkSwap(C,F),t.name),cachedPkgName:t.name}}function splitBinAndArgs(t,n,S){if(!n)return{binName:null,extraArgs:S};let C=$(t,`package.json`);if(existsSync(C))try{let t=JSON.parse(readFileSync(C,`utf-8`)).gjsify?.bin;if(t&&Object.prototype.hasOwnProperty.call(t,n))return{binName:n,extraArgs:S}}catch{}return{binName:null,extraArgs:[n,...S]}}var VR,HR=__esmMin(()=>{_e(),rL(),IR(),LR(),BI(),BR(),sR(),Bd(),In(),VR={command:`dlx <spec> [binOrArg] [extraArgs..]`,description:`Run the GJS bundle of an npm-published package without installing it locally.`,builder:t=>t.parserConfiguration({"populate--":!0,"parse-positional-numbers":!1}).positional(`spec`,{description:"Package spec (`name`, `name@version`, `@scope/name@spec`, or local path).",type:`string`,demandOption:!0}).positional(`binOrArg`,{description:"Optional bin name when the package defines `gjsify.bin` with multiple entries; otherwise treated as the first argument forwarded to the bundle. To pass a flag here (e.g. `--help`) use the `--` separator: `gjsify dlx <pkg> -- --help`.",type:`string`}).positional(`extraArgs`,{description:"Extra args forwarded to `gjs -m <bundle>`. Use `--` before flags to bypass gjsify-level parsing (`gjsify dlx <pkg> -- --help --verbose`).",type:`string`,array:!0}).option(`cache-max-age`,{description:`Cache TTL in minutes. Defaults to 7 days. Use 0 to bypass cache.`,type:`number`,default:1440*7}).option(`reinstall`,{description:`Bypass the cache for this run (alias for --cache-max-age=0).`,type:`boolean`,default:!1}).option(`frozen`,{description:`Use the project-local gjsify-lock.json verbatim — fail if missing or stale (no resolver pass).`,type:`boolean`,default:!1}).option(`verbose`,{description:`Verbose logging (passes --loglevel verbose to npm).`,type:`boolean`,default:!1}).option(`registry`,{description:`Registry URL override.`,type:`string`}),handler:async t=>{let n=parseSpec(t.spec),S=t.reinstall?0:t[`cache-max-age`],{pkgDir:C,cachedPkgName:N}=await ensurePkgDir(n,{verbose:t.verbose,registry:t.registry,cacheMaxAge:S,frozen:t.frozen}),F=[...t.extraArgs??[],...doubleDashArgs(t)],{binName:I,extraArgs:H}=splitBinAndArgs(C,t.binOrArg,F),W=resolveGjsEntry(C,I);W.fromFallback&&ge.warn(`[gjsify dlx] package "${N??n.kind}" declares no \`gjsify.main\` — falling back to package.json#main. Add \`gjsify.main\` to silence.`),await runGjsBundle(W.bundlePath,H,{completion:`exit`,exitOnSuccess:!0})}}});async function loadNpmrc(t){let n=[],S=$(t,`.npmrc`);existsSync(S)&&n.push(readFileSync(S,`utf-8`));let C=process.env.NPM_CONFIG_USERCONFIG;if(C&&existsSync(C))n.push(readFileSync(C,`utf-8`));else{let t=$(homedir(),`.npmrc`);existsSync(t)&&n.push(readFileSync(t,`utf-8`))}return parseNpmrc(n.join(`
|
|
946
|
-
`).replace(/\$\{([A-Z_][A-Z0-9_]*)\}/gi,(t,n)=>process.env[n]??``))}function hasAnyAuthToken(t){return Object.keys(t.authTokens).length>0}function hasAnyCredential(t){return hasAnyAuthToken(t)||Object.keys(t.basicAuth).length>0}var UR=__esmMin(()=>{Bd(),zg(),In(),nh()});function readCliVersion(){let t=cliVersion();return t===`unknown`?void 0:t}function runningAs(t){return t?`[gjsify ${t}] `:``}async function resolveShowcaseDir(t,n,S=[]){let C=resolveLocalShowcaseDir(t);if(C)return C;let{pkgDir:N}=await ensurePkgDir(parseSpec(n?`${t.packageName}@${n}`:t.packageName),{verbose:!1,cacheMaxAge:1440*7,frozen:!1,extraSpecs:S});return N}function resolveLocalShowcaseDir(t){try{let n=createRequire(import.meta.url).resolve(`${t.packageName}/package.json`);if(existsSync(n))return On(n)}catch{}return null}function gtkRuntimeSpecs(t){let n=`${process.platform}-${process.arch}`;if(![`win32-x64`,`darwin-arm64`,`darwin-x64`].includes(n))return[];let S=`@gjsify/gtk-runtime-${n}`;return[t?`${S}@${t}`:S]}async function preflightDeclaredRuntimes(t,n){try{return declaredRuntimesFromPackument(await fetchPackument(t.packageName,{npmrc:await loadNpmrc(process.cwd()),fullMetadata:!0}),n)}catch{return}}function declaredRuntimesFromPackument(t,n){let S=n??t[`dist-tags`]?.latest,C=S?t.versions?.[S]:void 0;if(C)return readDeclaredRuntimes(C)}async function runShowcaseOnRuntime(t,n,S){if(resolveLocalShowcaseDir(t)===null){let C=await preflightDeclaredRuntimes(t,S);if(C!==void 0){let S=checkRuntimeSupported(n,C,t.name);if(!S.ok)return ge.error(S.message),process.exit(1)}}let C;try{C=await resolveShowcaseDir(t,S,[S?`@gjsify/node-gi@${S}`:`@gjsify/node-gi`,...gtkRuntimeSpecs(S)])}catch(n){return ge.error(`Could not resolve showcase "${t.name}": ${n.message}`),process.exit(1)}let N={};try{N=JSON.parse(readFileSync(`${C}/package.json`,`utf-8`))}catch{}let F=checkRuntimeSupported(n,readDeclaredRuntimes(N),t.name);if(!F.ok)return ge.error(F.message),process.exit(1);let I;try{I=resolveNodeEntry(C)}catch(C){let F=typeof N.name==`string`?`${N.name}@${S??`?`}`:t.packageName;return ge.error(`Cannot run showcase "${t.name}" on ${n}: ${C.message}\n\n ${F} declares --runtime ${n} but ships no \`--app node\` bundle, so that\n version of the showcase cannot run there. You are running gjsify ${S??`(unknown)`},\n and \`showcase\` pins the showcase to the CLI's own version.\n\n ${WR}\n\n Or run it on GJS, which every showcase ships: gjsify showcase ${t.name} --runtime gjs`),process.exit(1)}ge.log(`Running showcase: ${t.name} ${runningAs(S)}on ${n} (${I})\n`);try{await runRuntimeBundle(n,I,[],{completion:`exit`,exitOnSuccess:!0})}catch(t){return ge.error(`${t.message}\n\n The showcase and the \`@gjsify/node-gi\` bridge it needs are both installed by THIS CLI\n (gjsify ${S??`(unknown)`}) into its own cache, so a missing bridge points at the CLI\n rather than at anything in your project.\n\n ${WR}`),process.exit(1)}}var WR,GR,KR=__esmMin(()=>{_e(),PR(),bF(),Rl(),In(),Bd(),HR(),nh(),UR(),IR(),ih(),LR(),aL(),K_(),WR=`A package runner reuses a CACHED copy of an unpinned bin. Force the current one:
|
|
946
|
+
`).replace(/\$\{([A-Z_][A-Z0-9_]*)\}/gi,(t,n)=>process.env[n]??``))}function hasAnyAuthToken(t){return Object.keys(t.authTokens).length>0}function hasAnyCredential(t){return hasAnyAuthToken(t)||Object.keys(t.basicAuth).length>0}var UR=__esmMin(()=>{Bd(),zg(),In(),nh()});function readCliVersion(){let t=cliVersion();return t===`unknown`?void 0:t}function runningAs(t){return t?`[gjsify ${t}] `:``}async function resolveShowcaseDir(t,n,S=[]){let C=resolveLocalShowcaseDir(t);if(C)return C;let{pkgDir:N}=await ensurePkgDir(parseSpec(n?`${t.packageName}@${n}`:t.packageName),{verbose:!1,cacheMaxAge:1440*7,frozen:!1,extraSpecs:S});return N}function resolveLocalShowcaseDir(t){try{let n=createRequire(import.meta.url).resolve(`${t.packageName}/package.json`);if(existsSync(n))return On(n)}catch{}return null}function gtkRuntimeSpecs(t){let n=`${process.platform}-${process.arch}`;if(![`win32-x64`,`win32-arm64`,`darwin-arm64`,`darwin-x64`].includes(n))return[];let S=`@gjsify/gtk-runtime-${n}`;return[t?`${S}@${t}`:S]}async function preflightDeclaredRuntimes(t,n){try{return declaredRuntimesFromPackument(await fetchPackument(t.packageName,{npmrc:await loadNpmrc(process.cwd()),fullMetadata:!0}),n)}catch{return}}function declaredRuntimesFromPackument(t,n){let S=n??t[`dist-tags`]?.latest,C=S?t.versions?.[S]:void 0;if(C)return readDeclaredRuntimes(C)}async function runShowcaseOnRuntime(t,n,S){if(resolveLocalShowcaseDir(t)===null){let C=await preflightDeclaredRuntimes(t,S);if(C!==void 0){let S=checkRuntimeSupported(n,C,t.name);if(!S.ok)return ge.error(S.message),process.exit(1)}}let C;try{C=await resolveShowcaseDir(t,S,[S?`@gjsify/node-gi@${S}`:`@gjsify/node-gi`,...gtkRuntimeSpecs(S)])}catch(n){return ge.error(`Could not resolve showcase "${t.name}": ${n.message}`),process.exit(1)}let N={};try{N=JSON.parse(readFileSync(`${C}/package.json`,`utf-8`))}catch{}let F=checkRuntimeSupported(n,readDeclaredRuntimes(N),t.name);if(!F.ok)return ge.error(F.message),process.exit(1);let I;try{I=resolveNodeEntry(C)}catch(C){let F=typeof N.name==`string`?`${N.name}@${S??`?`}`:t.packageName;return ge.error(`Cannot run showcase "${t.name}" on ${n}: ${C.message}\n\n ${F} declares --runtime ${n} but ships no \`--app node\` bundle, so that\n version of the showcase cannot run there. You are running gjsify ${S??`(unknown)`},\n and \`showcase\` pins the showcase to the CLI's own version.\n\n ${WR}\n\n Or run it on GJS, which every showcase ships: gjsify showcase ${t.name} --runtime gjs`),process.exit(1)}ge.log(`Running showcase: ${t.name} ${runningAs(S)}on ${n} (${I})\n`);try{await runRuntimeBundle(n,I,[],{completion:`exit`,exitOnSuccess:!0})}catch(t){return ge.error(`${t.message}\n\n The showcase and the \`@gjsify/node-gi\` bridge it needs are both installed by THIS CLI\n (gjsify ${S??`(unknown)`}) into its own cache, so a missing bridge points at the CLI\n rather than at anything in your project.\n\n ${WR}`),process.exit(1)}}var WR,GR,KR=__esmMin(()=>{_e(),PR(),bF(),Rl(),In(),Bd(),HR(),nh(),UR(),IR(),ih(),LR(),aL(),K_(),WR=`A package runner reuses a CACHED copy of an unpinned bin. Force the current one:
|
|
947
947
|
npx @gjsify/cli@latest showcase <name>
|
|
948
948
|
bunx @gjsify/cli@latest showcase <name>
|
|
949
949
|
deno run -A --reload --min-dep-age 0 npm:@gjsify/cli@latest showcase <name>`,GR={command:`showcase [name]`,description:`List or run curated gjsify showcase applications.`,builder:t=>t.positional(`name`,{description:`Showcase name to run (omit to list all)`,type:`string`}).option(`json`,{description:`Output as JSON`,type:`boolean`,default:!1}).option(`list`,{description:`List available showcases`,type:`boolean`,default:!1}).option(`runtime`,{type:`string`,choices:W_,defaultDescription:`gjs when gjs is installed, else the host runtime`,description:"Runtime to run the showcase on: gjs | node | bun | deno (default: gjs when installed, else the host runtime). node/bun/deno run its `--app node` bundle."}),handler:async t=>{if(!t.name||t.list){let n=discoverShowcases();if(t.json){ge.log(JSON.stringify(n,null,2));return}if(n.length===0){ge.log("No showcases found. The CLI ships a curated list in `showcases.json`; if it is missing the CLI install is incomplete.");return}let S=new Map;for(let t of n){let n=S.get(t.category)??[];n.push(t),S.set(t.category,n)}ge.log(`Available gjsify showcases:
|
|
@@ -1125,14 +1125,14 @@ $`,64,`ascii`),le.writeUInt32LE(UB,60),le.write(`PE\0\0`,UB,`ascii`),le.writeUIn
|
|
|
1125
1125
|
`)}function renderPkgInfo(){return`${lV}${uV}`}function renderEntitlements(t){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>`,t.map(t=>`\t<key>${xmlText(t)}</key>\n\t<true/>`).join(`
|
|
1126
1126
|
`),`</dict>`,`</plist>`,``].join(`
|
|
1127
1127
|
`)}var oV,sV,cV,lV,uV,dV=__esmMin(()=>{oV=`Contents/Info.plist`,sV=`Contents/PkgInfo`,cV=`Contents/Resources`,lV=`APPL`,uV=`????`});function darwinFontsPath(t,n){let S=`${kB.fonts}/${t.appId}`,C=n.find(t=>t.path.startsWith(`${S}/`));if(C===void 0)return;let N=mV.darwin.dirs(t);return hn.relative(N.other,hn.dirname(place(mV.darwin,t,C.path)))}function appBundleDir(t){if(fV.test(t.name))throw Error(`gjsify ship: the macOS layout would put this app in "${t.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`${t.name}.app`}function assertUsableAsHelperName(t){if(t===``||t===`.`||t===`..`||fV.test(t)||t.includes(`\0`))throw Error(`gjsify ship: the macOS layout would name the carried interpreter "${t}" under \`Contents/Helpers\`, and that is not usable as a file name — empty, ".", ".." and anything containing "/", ":", "\\" or a NUL byte are refused. Set \`gjsify.ship.name\` to the display name you want.`);return t}function iconFor(t,n){if(t.kind===`app`){if(t.icon===void 0){if(mV[n].icon?.required!==!0)return;throw Error(`gjsify ship: the ${n} layout writes the application's icon and was given none. A \`kind: "app"\` stage is rendered its icon by \`resolveAppIcon\` before the layout runs; reaching this row without one is a caller that skipped that step.`)}return t.icon}}function launcherPath(t,n){return hn.join(t.dirs(n).launcher,`${n.binaryName}${t.launcherExt}`)}function windowsGuiLauncherPath(t){let n=mV.windows;if(n.launcherExt.length!==4)throw Error(`gjsify ship: the windows launcher extension is "${n.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 hn.join(n.dirs(t).launcher,`${t.binaryName}.exe`)}function windowsLaunchLogLeaf(t){return`${t.binaryName}.launch.log`}function layoutForOs(t){let n=gV.get(t);if(n===void 0)throw Error(`"${t}" is not a \`process.platform\` token this gjsify has a layout for. Known: ${hV.map(t=>mV[t].os).join(`, `)} — the \`\${process.platform}-\${process.arch}\` spelling, so \`win32\` and never \`windows\`.`);return n}function resolveLayout(t){let n=t.trim().toLowerCase();if(Object.hasOwn(mV,n))return mV[n];let S=gV.get(n);if(S!==void 0)return S;throw Error(`gjsify ship: "${t}" is not an operating system this command has a layout for. Known: ${hV.join(`, `)} (\`win32\` is accepted for \`windows\`, because that is the spelling \`--expect-target <os>-<arch>\` uses).`)}function hostLayout(t=process.platform){let n=gV.get(t);if(n===void 0)throw Error(`gjsify ship: this host is ${t}, which has no layout. Name the one you want — \`gjsify ship <${hV.join(`|`)}> --stage\` — assembly is not host-bound (ADR 0024 § A1).`);return n}function assertLayoutSupportsArch(t,n){let S=t.arches;if(!(S===null||S.only.includes(n)))throw Error(`gjsify ship: the ${t.name} layout is not assemblable for \`--arch ${n}\` — ${S.only.length===1?`the only architecture it has`:`the architectures it has`} ${S.only.length===1?`is`:`are`} ${S.only.join(`, `)}.\n ${S.why}.\n \`--arch\` names the architecture the PAYLOAD was built for and cross-compiles nothing, so there is no
|
|
1128
|
-
flag that makes this work — the artifact would carry a runtime that does not exist.`)}function place(t,n,S){let C=t.dirs(n);if(S===`bin/${n.binaryName}`)return launcherPath(t,n);let N=`lib/${n.binaryName}/`,F=`${N}gi/`;return S.startsWith(F)?hn.join(C.native,S.slice(F.length)):S.startsWith(N)?hn.join(C.bundle,S.slice(N.length)):S.startsWith(`bin/`)?hn.join(C.launcher,S.slice(4)):S.startsWith(`share/`)?hn.join(C.data,S.slice(6)):hn.join(C.other,S)}function placeStage(t,n,S,C=[]){let N=new Map,F=[],claim=(n,S,C)=>{let I=N.get(n);if(I!==void 0)throw Error(`gjsify ship: in the ${t.name} layout both ${I} and ${S} install as ${n}. Two payload files cannot share one destination — one would silently replace the other. Rename the \`gjsify.ship.extraFiles\` destination that collides.`);N.set(n,S),F.push({...C,path:n})};for(let C of S)claim(place(t,n,C.path),C.path,C);for(let C of t.metadata(n,S))claim(C.path,`the ${t.name} layout's own metadata`,C);for(let n of C)claim(n.path,`the runtime staged into the ${t.name} artifact`,n);return F.sort((t,n)=>t.path<n.path?-1:+(t.path>n.path))}var fV,pV,mV,hV,gV,_V=__esmMin(()=>{In(),zB(),VB(),aV(),dV(),AB(),fV=/[/:\\]/,pV=[64,128,256],mV={linux:{name:`linux`,os:`linux`,shippedRuntime:`gjs`,launcherExt:``,root:()=>``,dirs:t=>({launcher:`bin`,bundle:`lib/${t.binaryName}`,native:`lib/${t.binaryName}/gi`,data:`share`,other:``,helpers:``}),icon:{sizes:pV,writes:"the hicolor theme's raster icons (`share/icons/hicolor/<n>x<n>/apps/<appId>.png`)",required:!1},metadata:(t,n)=>{let S=iconFor(t,`linux`);if(S===void 0)return[];let C=new Set(n.map(t=>t.path)),N=[];for(let n of[...S.png.keys()].sort((t,n)=>t-n)){let F=`${kB.icons}/${n}x${n}/apps/${t.appId}.png`,I=S.png.get(n);I===void 0||C.has(F)||N.push({path:place(mV.linux,t,F),mode:420,source:{kind:`bytes`,data:I}})}return N},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 and the route that matters whenever Pango on macOS resolves CoreText by default — which it does on a Homebrew GTK, because that one is not built against fontconfig. A `.app` carrying the bundled GTK runtime reads the same faces through fontconfig instead: `@gjsify/node-gi`'s loader selects it with `PANGOCAIRO_BACKEND=fc` (ADR 0038 § Amendment 3), and `initFonts()` from `@gjsify/gtk-host/fonts` registers them as it does on Windows. Either way no branch is needed in your app: a CoreText map answers G_IO_ERROR_NOT_SUPPORTED and the call reports that as declined. Confirm in the shipped bundle with `PangoCairo.FontMap.get_default().list_families()`, and `PANGOCAIRO_BACKEND=bogus` to print which backends it was built with.",launcherExt:``,root:appBundleDir,dirs:t=>{let n=appBundleDir(t);return{launcher:`${n}/Contents/MacOS`,bundle:`${n}/Contents/Resources/lib`,native:`${n}/Contents/Resources/native`,data:`${n}/Contents/Resources/share`,other:`${n}/Contents/Resources`,helpers:`${n}/Contents/Helpers`}},icon:{sizes:RB,writes:"the macOS bundle icon (`Contents/Resources/<binaryName>.icns`)",required:!0},metadata:(t,n)=>{let S=iconFor(t,`darwin`),C=S===void 0?void 0:`${t.binaryName}.icns`;return[{path:`${appBundleDir(t)}/${oV}`,mode:420,source:{kind:`text`,text:renderInfoPlist(t,darwinFontsPath(t,n),C)}},{path:`${appBundleDir(t)}/${sV}`,mode:420,source:{kind:`text`,text:renderPkgInfo()}},...S===void 0||C===void 0?[]:[{path:`${appBundleDir(t)}/${cV}/${C}`,mode:420,source:{kind:`bytes`,data:buildIcns(S)}}]]},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 resolves pangowin32, whose font map is populated from DirectWrite and never from fontconfig or from GDI, unless something selects otherwise — which the bundled GTK runtime does (`PANGOCAIRO_BACKEND=fc`, ADR 0038 § Amendment 3), and an app may. MEASURED on the DirectWrite map, 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:``,helpers:``}),icon:{sizes:BB,writes:"the Windows launcher icon (`.rsrc` of `<binaryName>.exe`)",required:!0},metadata:t=>{let n=iconFor(t,`windows`);return
|
|
1128
|
+
flag that makes this work — the artifact would carry a runtime that does not exist.`)}function place(t,n,S){let C=t.dirs(n);if(S===`bin/${n.binaryName}`)return launcherPath(t,n);let N=`lib/${n.binaryName}/`,F=`${N}gi/`;return S.startsWith(F)?hn.join(C.native,S.slice(F.length)):S.startsWith(N)?hn.join(C.bundle,S.slice(N.length)):S.startsWith(`bin/`)?hn.join(C.launcher,S.slice(4)):S.startsWith(`share/`)?hn.join(C.data,S.slice(6)):hn.join(C.other,S)}function placeStage(t,n,S,C=[]){let N=new Map,F=[],claim=(n,S,C)=>{let I=N.get(n);if(I!==void 0)throw Error(`gjsify ship: in the ${t.name} layout both ${I} and ${S} install as ${n}. Two payload files cannot share one destination — one would silently replace the other. Rename the \`gjsify.ship.extraFiles\` destination that collides.`);N.set(n,S),F.push({...C,path:n})};for(let C of S)claim(place(t,n,C.path),C.path,C);for(let C of t.metadata(n,S))claim(C.path,`the ${t.name} layout's own metadata`,C);for(let n of C)claim(n.path,`the runtime staged into the ${t.name} artifact`,n);return F.sort((t,n)=>t.path<n.path?-1:+(t.path>n.path))}var fV,pV,mV,hV,gV,_V=__esmMin(()=>{In(),zB(),VB(),aV(),dV(),AB(),fV=/[/:\\]/,pV=[64,128,256],mV={linux:{name:`linux`,os:`linux`,shippedRuntime:`gjs`,launcherExt:``,root:()=>``,dirs:t=>({launcher:`bin`,bundle:`lib/${t.binaryName}`,native:`lib/${t.binaryName}/gi`,data:`share`,other:``,helpers:``}),icon:{sizes:pV,writes:"the hicolor theme's raster icons (`share/icons/hicolor/<n>x<n>/apps/<appId>.png`)",required:!1},metadata:(t,n)=>{let S=iconFor(t,`linux`);if(S===void 0)return[];let C=new Set(n.map(t=>t.path)),N=[];for(let n of[...S.png.keys()].sort((t,n)=>t-n)){let F=`${kB.icons}/${n}x${n}/apps/${t.appId}.png`,I=S.png.get(n);I===void 0||C.has(F)||N.push({path:place(mV.linux,t,F),mode:420,source:{kind:`bytes`,data:I}})}return N},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 and the route that matters whenever Pango on macOS resolves CoreText by default — which it does on a Homebrew GTK, because that one is not built against fontconfig. A `.app` carrying the bundled GTK runtime reads the same faces through fontconfig instead: `@gjsify/node-gi`'s loader selects it with `PANGOCAIRO_BACKEND=fc` (ADR 0038 § Amendment 3), and `initFonts()` from `@gjsify/gtk-host/fonts` registers them as it does on Windows. Either way no branch is needed in your app: a CoreText map answers G_IO_ERROR_NOT_SUPPORTED and the call reports that as declined. Confirm in the shipped bundle with `PangoCairo.FontMap.get_default().list_families()`, and `PANGOCAIRO_BACKEND=bogus` to print which backends it was built with.",launcherExt:``,root:appBundleDir,dirs:t=>{let n=appBundleDir(t);return{launcher:`${n}/Contents/MacOS`,bundle:`${n}/Contents/Resources/lib`,native:`${n}/Contents/Resources/native`,data:`${n}/Contents/Resources/share`,other:`${n}/Contents/Resources`,helpers:`${n}/Contents/Helpers`}},icon:{sizes:RB,writes:"the macOS bundle icon (`Contents/Resources/<binaryName>.icns`)",required:!0},metadata:(t,n)=>{let S=iconFor(t,`darwin`),C=S===void 0?void 0:`${t.binaryName}.icns`;return[{path:`${appBundleDir(t)}/${oV}`,mode:420,source:{kind:`text`,text:renderInfoPlist(t,darwinFontsPath(t,n),C)}},{path:`${appBundleDir(t)}/${sV}`,mode:420,source:{kind:`text`,text:renderPkgInfo()}},...S===void 0||C===void 0?[]:[{path:`${appBundleDir(t)}/${cV}/${C}`,mode:420,source:{kind:`bytes`,data:buildIcns(S)}}]]},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 resolves pangowin32, whose font map is populated from DirectWrite and never from fontconfig or from GDI, unless something selects otherwise — which the bundled GTK runtime does (`PANGOCAIRO_BACKEND=fc`, ADR 0038 § Amendment 3), and an app may. MEASURED on the DirectWrite map, 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:``,helpers:``}),icon:{sizes:BB,writes:"the Windows launcher icon (`.rsrc` of `<binaryName>.exe`)",required:!0},metadata:t=>{let n=iconFor(t,`windows`);return[{path:windowsGuiLauncherPath(t),mode:493,source:{kind:`bytes`,data:buildGuiLauncher({logLeaf:windowsLaunchLogLeaf(t),...n===void 0?{}:{icon:iconResources(n)}})}}]},arches:{only:[`x64`,`arm64`],why:"win32 runs on x64 natively and on arm64 via the MSVC closure ADR 0089 builds — both have a `@gjsify/gtk-runtime-win32-*` and `@gjsify/node-runtime-win32-*` to stage"}}},hV=Object.keys(mV),gV=new Map(hV.map(t=>[mV[t].os,mV[t]]))});async function compileSchemasForStage(t){if(t.schemaFiles.length===0)return[];rmSync(t.workDir,{recursive:!0,force:!0,maxRetries:5}),mkdirSync(t.workDir,{recursive:!0});for(let n of t.schemaFiles)copyFileSync(n,$(t.workDir,kn(n)));return await runSchemaCompiler(t.workDir),[{path:xV,mode:420,source:{kind:`file`,path:$(t.workDir,`gschemas.compiled`)}}]}async function compileSchemasForPayload(t){let n=t.payload.filter(t=>isSchemaSource(t.path));if(n.length!==0){rmSync(t.workDir,{recursive:!0,force:!0,maxRetries:5}),mkdirSync(t.workDir,{recursive:!0});for(let S of n)writeFileSync($(t.workDir,hn.basename(S.path)),S.data);return await runSchemaCompiler(t.workDir),{path:xV,mode:420,data:readFileSync($(t.workDir,`gschemas.compiled`))}}}function isSchemaSource(t){return t.startsWith(`${kB.schemas}/`)&&t.endsWith(`.gschema.xml`)}async function runSchemaCompiler(t){try{await vV(yV,[`--strict`,`--targetdir=${t}`,t])}catch(t){let n=t;throw n.code===`ENOENT`?Error(`gjsify ship: this artifact has no install step, so \`${yV}\` has to run HERE to turn the payload's schemas into \`${xV}\` — and it is not on PATH. Install it (${bV}). 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: \`${yV} --strict\` refused this project's schemas.\n${(n.stderr??``).trimEnd()}\n \`--strict\` is deliberate: without it a malformed schema is SKIPPED at exit 0 and a cache
|
|
1129
1129
|
is written without it, so the app still aborts on the schema that was dropped. Fix the
|
|
1130
1130
|
file it names, or drop it from \`gjsify.ship.schemas\`.`)}}var vV,yV,bV,xV,SV=__esmMin(()=>{I_(),In(),Bd(),Du(),AB(),vV=promisify(execFile),yV=`glib-compile-schemas`,bV="Fedora: `sudo dnf install glib2`, Debian/Ubuntu: `sudo apt install libglib2.0-bin`",xV=`${kB.schemas}/gschemas.compiled`});function buildTimestamp(t,n=process.env){let S=n.SOURCE_DATE_EPOCH;if(S!==void 0){let t=Number(S);if(!Number.isInteger(t)||t<0)throw Error(`gjsify ship: SOURCE_DATE_EPOCH must be a non-negative integer, got "${S}".`);return t}return Math.floor(statSync(t).mtimeMs/1e3)}function readPayloadFacts(t){let n=t.map(t=>t.path);return{hasDesktopEntry:n.some(t=>isUnder(t,kB.applications)&&t.endsWith(`.desktop`)),hasIcons:n.some(t=>isUnder(t,kB.icons)),hasSchemas:n.some(t=>isUnder(t,kB.schemas)&&t.endsWith(`.gschema.xml`)),hasMimeTypes:n.some(t=>isUnder(t,kB.mime)&&t.endsWith(`.xml`)),bundledTypelibs:n.filter(t=>t.endsWith(`.typelib`))}}function readLauncherInterpreters(t,n,S){let C=t.find(t=>t.path===launcherPath(n,S));if(C===void 0)return[];let N=new TextDecoder().decode(C.data),F=n.name===`windows`?`cmd`:`sh`,I=[];for(let t of F===`cmd`?batchCommands(N):shellExecLines(N)){let n=interpreterOf(t,F);n!==null&&I.push(n)}return[...new Set(I)]}function shellExecLines(t){return[...`\n${t}`.matchAll(/\n[ \t]*exec\s+([^\n]*)/g)].map(t=>t[1].trim())}function cmdTokens(t){let n=[],S=0;for(;S<t.length;){if(/\s/.test(t[S])){S+=1;continue}let C=S,N=!1;for(;S<t.length&&(N||!/\s/.test(t[S]));)t[S]===`"`&&(N=!N),S+=1;n.push({text:t.slice(C,S),end:S})}return n}function splitBatchBlock(t){let n=0,S=!1;for(let C=0;C<t.length;C++){let N=t[C];if(N===`"`)S=!S;else if(!S&&N===`(`)n+=1;else if(!S&&N===`)`&&(--n,n===0))return[t.slice(1,C).trim(),t.slice(C+1).trim()]}return null}function batchPrefix(t){if(t.startsWith(`(`)){let n=splitBatchBlock(t);return n===null?null:[n[0],n[1]]}let n=cmdTokens(t),word=t=>(n[t]?.text??``).toLowerCase(),after=S=>[t.slice(n[S]?.end??t.length).trim()];if(word(0)===`else`)return after(0);if(word(0)===`for`){let t=n.findIndex(t=>t.text.toLowerCase()===`do`);return t===-1?null:after(t)}if(word(0)!==`if`)return;let S=1;for(;word(S)===`not`||word(S)===`/i`;)S+=1;return wV.has(word(S))?after(S+1):word(S).includes(`==`)?after(S):TV.has(word(S+1))?after(S+2):null}function batchCommands(t){let n=[],S=t.split(/\r?\n/).map(t=>t.trim().replace(/^@+/,``).trim());for(let t=0;t<EV&&S.length>0;t++){let t=S.shift();if(t===``||t===`)`||t.startsWith(`::`))continue;let C=(cmdTokens(t)[0]?.text??``).toLowerCase();if(CV.has(C))continue;let N=batchPrefix(t);N===void 0?n.push(t):N!==null&&S.unshift(...N)}return n}function interpreterOf(t,n){if(n===`cmd`)return cmdProgramOf(t);let S=t.split(/\s+/).filter(t=>t.length>0);for(let t=0;t<2&&S.length>0;t++){let t=basenameOf(S[0]);if(t!==`env`)return t===``?null:t;S=S.slice(1).filter(t=>!t.startsWith(`-`)&&!/^[A-Za-z_][A-Za-z0-9_]*=/.test(t))}return null}function cmdProgramOf(t){let n=/^"([^"]*)"/.exec(t),S=((n===null?t.split(/\s+/)[0]??``:n[1]).replace(/^%[^%\s]*%/,``).split(/[/\\]/).pop()??``).replace(/\.exe$/i,``);return S===``?null:S}function basenameOf(t){let n=unquote(t).split(/[/\\]/);return n[n.length-1]??``}function unquote(t){let n=t[0];return(n===`"`||n===`'`)&&t.length>1&&t[t.length-1]===n?t.slice(1,-1):t}function assertLauncherMatchesInterpreter(t,n,S,C){let N=readLauncherInterpreters(t,n,S);if(N.length===0||N.includes(C))return;let F=C===`gjs`?`node`:`gjs`;if(N.includes(F))throw Error(`gjsify ship: the launcher ${launcherPath(n,S)} execs \`${F}\`, but this package would declare a dependency on \`${C}\`.\n An installed package that depends on one interpreter and runs another installs cleanly and fails
|
|
1131
1131
|
at first launch, on the user's machine.
|
|
1132
1132
|
Either set \`gjsify.ship.app.${n.os}\` to "${F}" in the project this was staged from — it overrides
|
|
1133
1133
|
\`gjsify.app\` for that target alone — or fix the launcher: if it comes from \`gjsify.ship.extraFiles\`,
|
|
1134
1134
|
that override is what decides which interpreter runs and it must match the declaration.`)}function linuxInstallDependent(t){let n=[],S={hasCompiledSchemas:t.some(t=>t.path===xV)};for(let C of t){if(!isUnder(C.path,`share`)||OV.some(t=>C.path===t||isUnder(C.path,t)))continue;let t=DV.find(([t])=>isUnder(C.path,t));if(t===void 0){n.push({path:C.path,verdict:`unknown`,why:`nothing here classifies this directory — it may need an install step no non-Linux layout runs, or it may be inert; say which before shipping it`});continue}let[N,F]=t[1](S);n.push({path:C.path,verdict:N,why:F})}let C={aborts:0,unknown:1,inert:2};return n.sort((t,n)=>C[t.verdict]-C[n.verdict]||(t.path<n.path?-1:1))}function readShebangInterpreters(t){let n=new Set;for(let S of t){if(!(S.mode&73))continue;let t=readShebang(S.data);t!==null&&n.add(t)}return[...n].sort()}function readShebang(t){if(t[0]!==35||t[1]!==33)return null;let n=(new TextDecoder().decode(t.subarray(2,Math.min(t.byteLength,256))).split(`
|
|
1135
|
-
`)[0]??``).trim().split(/\s+/)[0]??``;return n.startsWith(`/`)?n:null}function isArchIndependent(t){return!t.some(t=>isNativeBinary(t.data))}function readBinaryArch(t){if(t.byteLength<20)return null;let n=(t[0]<<24|t[1]<<16|t[2]<<8|t[3])>>>0;if(n===2135247942){let n=t[5]===1?t[18]|t[19]<<8:t[18]<<8|t[19];return kV[n]??null}if(n===4277009102||n===4277009103)return AV[(t[4]<<24|t[5]<<16|t[6]<<8|t[7])>>>0]??null;if(n===3472551422||n===3489328638)return AV[(t[7]<<24|t[6]<<16|t[5]<<8|t[4])>>>0]??null;if(t[0]===77&&t[1]===90&&t.byteLength>=64){let n=(t[60]|t[61]<<8|t[62]<<16|t[63]<<24)>>>0;return n+6>t.byteLength||(t[n]|t[n+1]<<8|t[n+2]<<16)>>>0!=17744||t[n+3]!==0?null:jV[t[n+4]|t[n+5]<<8]??null}return null}function assertPayloadMatchesArch(t,n){for(let
|
|
1135
|
+
`)[0]??``).trim().split(/\s+/)[0]??``;return n.startsWith(`/`)?n:null}function isArchIndependent(t){return!t.some(t=>isNativeBinary(t.data))}function readBinaryArch(t){if(t.byteLength<20)return null;let n=(t[0]<<24|t[1]<<16|t[2]<<8|t[3])>>>0;if(n===2135247942){let n=t[5]===1?t[18]|t[19]<<8:t[18]<<8|t[19];return kV[n]??null}if(n===4277009102||n===4277009103)return AV[(t[4]<<24|t[5]<<16|t[6]<<8|t[7])>>>0]??null;if(n===3472551422||n===3489328638)return AV[(t[7]<<24|t[6]<<16|t[5]<<8|t[4])>>>0]??null;if(t[0]===77&&t[1]===90&&t.byteLength>=64){let n=(t[60]|t[61]<<8|t[62]<<16|t[63]<<24)>>>0;return n+6>t.byteLength||(t[n]|t[n+1]<<8|t[n+2]<<16)>>>0!=17744||t[n+3]!==0?null:jV[t[n+4]|t[n+5]<<8]??null}return null}function assertPayloadMatchesArch(t,n,S={}){for(let C of t){let t=readBinaryArch(C.data);if(!(t===null||t===n)&&!S.exempt?.has(C.path))throw Error(`gjsify ship: the payload is ${t}, but the package would be labelled ${n} — ${C.path} is built for ${t}.\n \`--arch\` names the architecture the PAYLOAD was built for; it does not cross-compile anything.
|
|
1136
1136
|
A package labelled ${n} installs on ${n} and then fails to load. Build the payload for ${n}\n (its own prebuild), or assemble the stage without \`--arch\` and label the payload you actually have.`)}}function classifyBinary(t){if(t.byteLength<4)return null;switch((t[0]<<24|t[1]<<16|t[2]<<8|t[3])>>>0){case 2135247942:return`elf`;case 4277009102:case 4277009103:case 3472551422:case 3489328638:case 3405691582:return`macho`;default:return t[0]===77&&t[1]===90?`pe`:null}}function isNativeBinary(t){return classifyBinary(t)!==null}var CV,wV,TV,EV,DV,OV,kV,AV,jV,MV=__esmMin(()=>{Bd(),_V(),SV(),AB(),CV=new Set([`rem`,`set`,`setlocal`,`endlocal`,`echo`,`goto`,`exit`,`title`,`pause`,`shift`,`cd`,`chdir`,`pushd`,`popd`,`color`,`cls`,`verify`,`prompt`]),wV=new Set([`exist`,`defined`,`errorlevel`]),TV=new Set([`equ`,`neq`,`lss`,`leq`,`gtr`,`geq`]),EV=32,DV=[[kB.schemas,({hasCompiledSchemas:t})=>t?[`inert`,"the schema SOURCE; `gschemas.compiled` is staged beside it and that is what GSettings reads, so this file is carried and never opened"]:[`aborts`,"needs `glib-compile-schemas`, and the launcher points XDG_DATA_DIRS here — GSettings ABORTS on a schema directory with no `gschemas.compiled`"]],[kB.mime,()=>[`inert`,"needs `update-mime-database`; detection runs off the compiled cache"]],[kB.icons,()=>[`inert`,"needs `gtk-update-icon-cache`; neither OS reads the hicolor theme"]],[kB.applications,()=>[`inert`,`a freedesktop desktop entry; neither OS reads one`]],[kB.metainfo,()=>[`inert`,`an AppStream component; neither OS reads one`]]],OV=[kB.locale,kB.fonts,xV],kV={3:`ia32`,21:`ppc64`,22:`s390x`,40:`arm`,62:`x64`,183:`arm64`,243:`riscv64`},AV={7:`ia32`,12:`arm`,16777223:`x64`,16777228:`arm64`},jV={332:`ia32`,34404:`x64`,43620:`arm64`}});async function buildDeb(t){let{payload:n,mtime:S}=t,C=t.prefix.replace(/^\/+/,``),N=n.map(t=>({...t,tarPath:`./${hn.join(C,t.path)}`})),F=ancestorDirectories(N.map(t=>t.tarPath)),I=await gzipDeterministic(createTarball([...F.map(t=>({name:t,mode:493,mtime:S,directory:!0})),...N.map(t=>({name:t.tarPath,body:t.data,mode:t.mode,mtime:S}))])),H=renderControl(t,N.reduce((t,n)=>t+Math.ceil(n.data.byteLength/1024),0)+F.length),W=N.map(t=>`${createHash(`md5`).update(t.data).digest(`hex`)} ${t.tarPath.slice(2)}\n`).join(``),q=[{name:`./`,mode:493,mtime:S,directory:!0},{name:`./control`,body:H,mode:420,mtime:S},{name:`./md5sums`,body:W,mode:420,mtime:S}],Y=renderDebScripts(readPayloadFacts(n),t.prefix);for(let[t,n]of Object.entries(Y))q.push({name:`./${t}`,body:n,mode:493,mtime:S});let X=await gzipDeterministic(createTarball(q));return createArArchive([{name:`debian-binary`,data:new TextEncoder().encode(`2.0
|
|
1137
1137
|
`),mtime:S},{name:`control.tar.gz`,data:X,mtime:S},{name:`data.tar.gz`,data:I,mtime:S}])}function singleLine(t){return t.replace(/[\r\n]+/g,` `).trim()}function ancestorDirectories(t){let n=new Set([`./`]);for(let S of t){let t=S.replace(/^\.\//,``).split(`/`);t.pop();let C=`.`;for(let S of t)C=`${C}/${S}`,n.add(`${C}/`)}return[...n].sort()}function renderControl(t,n){let{settings:S}=t,C=[[`Package`,S.binaryName],[`Version`,`${S.version}-${S.release}`],[`Architecture`,t.archLabel],[`Maintainer`,S.maintainer],[`Installed-Size`,String(n)]];t.depends.length>0&&C.push([`Depends`,t.depends.map(formatDebDepend).join(`, `)]),t.recommends!==void 0&&t.recommends.length>0&&C.push([`Recommends`,t.recommends.map(formatDebDepend).join(`, `)]),C.push([`Section`,S.section],[`Priority`,`optional`]),S.homepage&&C.push([`Homepage`,S.homepage]);let N=C.map(([t,n])=>`${t}: ${singleLine(n)}`);return N.push(`Description: ${singleLine(S.summary)}`),S.description.filter(t=>t!==S.summary).forEach((t,n)=>{n>0&&N.push(` .`),N.push(` ${t}`)}),`${N.join(`
|
|
1138
1138
|
`)}\n`}var NV=__esmMin(()=>{el(),In(),SL(),vB(),DB(),OB(),jB(),MV()});function xmlEscape(t){return t.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}var PV=__esmMin(()=>{});function validateMimeTypes(t){let n=new Set;for(let S of t){if(!FV.test(S.type))throw Error(`gjsify ship: \`gjsify.ship.mimeTypes\` has an invalid type "${S.type}". Expected \`<media>/<subtype>\`, e.g. \`application/x-bauplan\` — update-mime-database ignores a malformed name, so the type would install and never resolve.`);if(n.has(S.type))throw Error(`gjsify ship: \`gjsify.ship.mimeTypes\` defines ${S.type} twice. Which comment and glob set win would depend on document order.`);if(n.add(S.type),S.comment.trim()===``)throw Error(`gjsify ship: ${S.type} has an empty \`comment\`. A file manager then shows the user the raw type string instead of a name.`);for(let t of S.globs??[])if(!t.includes(`*`)&&!t.includes(`?`)&&!t.includes(`[`))throw Error(`gjsify ship: ${S.type} has the glob "${t}", which matches only a file named exactly that. A suffix pattern is written \`*.${t.replace(/^\.+/,``)}\`.`);if((S.globs??[]).length===0&&S.subClassOf===void 0)throw Error(`gjsify ship: ${S.type} declares neither \`globs\` nor \`subClassOf\`, so nothing can ever match it. The type would be registered and then never assigned to a file.`)}}function renderMimePackage(t){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
@@ -1143,28 +1143,28 @@ ${t.map(t=>{let n=[` <mime-type type="${xmlEscape(t.type)}">`,` <comment>${x
|
|
|
1143
1143
|
</mime-info>
|
|
1144
1144
|
`}var FV,IV=__esmMin(()=>{PV(),FV=/^[a-z0-9][a-z0-9!#$&^_.+-]*\/[a-z0-9][a-z0-9!#$&^_.+-]*$/});function normaliseVersion(t){let n=[],S=t.trim();S.startsWith(`v`)&&(S=S.slice(1));let C=S.indexOf(`+`);C!==-1&&(n.push(`gjsify ship: dropped the build metadata "${S.slice(C)}" from version ${t} — neither dpkg nor rpm has a field for it. Set \`gjsify.ship.version\` to pin an exact package version.`),S=S.slice(0,C));let N=S.indexOf(`-`);if(N!==-1){let t=S.slice(N+1).replace(/-/g,`.`);S=`${S.slice(0,N)}~${t}`}if(!LV.test(S))throw Error(`gjsify ship: "${t}" is not a usable package version (normalised to "${S}"). It must start with a digit and contain only letters, digits, \`.\`, \`+\` and \`~\`. Set \`gjsify.ship.version\` in package.json to override it.`);return{version:S,warnings:n}}function assertRelease(t){if(!RV.test(t))throw Error(`gjsify ship: "${t}" is not a usable package release. It must start with a letter or digit and contain only letters, digits, \`.\`, \`+\` and \`~\`. Set \`gjsify.ship.release\` in package.json.`);return t}var LV,RV,zV=__esmMin(()=>{LV=/^\d[A-Za-z0-9.+~]*$/,RV=/^[A-Za-z0-9][A-Za-z0-9.+~]*$/});function resolveShipApp(t){let n=t.perTarget??{};for(let t of Object.keys(n))if(!Object.hasOwn(BV,t))throw Error(`gjsify ship: \`gjsify.ship.app.${t}\` is not an OS this command assembles for. Known: ${Object.keys(BV).join(`, `)} — the \`process.platform\` spelling, not the \`gjsify ship <os>\` positional's. A runtime under a key nothing reads leaves that target on \`gjsify.app\` with nothing to say so.`);let S=n[t.layoutOs],C=S!==void 0,N=C?`gjsify.ship.app.${t.layoutOs}`:`gjsify.app`,F=C?S:t.project;if(F!==void 0&&F!==`gjs`&&F!==`node`)throw Error(`gjsify ship: \`${N}\` is "${F}", and only \`gjs\` and \`node\` can be packaged. A browser bundle has no process to launch, and a NativeScript app ships as an APK/IPA through a different pipeline. ADR 0024 § 4 has the runtime-per-OS table.`);return{app:F===`node`?`node`:`gjs`,key:N,overridden:C}}function resolveShipKind(t,n){return t.kind??n.kind??`app`}function resolveShipSettings(t){let n=[],{pkg:S,ship:C,flatpak:N,discovered:F}=t,I={...N,...definedOnly(C)},H=C.mimeTypes??[];if(H.length>0){validateMimeTypes(H);let t=new Set([...I.provides?.mimetypes??[],...H.map(t=>t.type)]);I.provides={...I.provides,mimetypes:[...t]}}let W=C.binaryName??deriveBinaryName(S.name),q=C.appId??N.appId??reverseDnsOrThrow(S.name,W),Y=I.name??titleCase(W),X=resolveShipKind(C,N),Z=t.app,te=C.version??S.version;if(!te)throw Error("gjsify ship: no version — set `version` in package.json or `gjsify.ship.version`.");let ne=normaliseVersion(te);n.push(...ne.warnings);let re=I.license?.project??S.license;if(!re)throw Error('gjsify ship: no licence — set `license` in package.json (an SPDX id, e.g. "MIT") or `gjsify.ship.license.project`. Both deb and rpm carry it as a required field.');I.license={...I.license,project:re};let ie=C.maintainer??formatAuthor(S.author)??formatDeveloper(I);if(!ie)throw Error('gjsify ship: no maintainer — set `author` in package.json ("Name <you@example.com>"), `gjsify.ship.maintainer`, or `gjsify.ship.developer`. dpkg refuses a package without one.');let ae=I.summary??S.description??Y,oe=descriptionParagraphs(I.description)??[ae],Q=sectionsFor(I.categories);X===`app`&&F.iconFiles.length===0&&n.push("gjsify ship: no icon found — the installed app will show a placeholder in menus on Linux, the Flatpak will carry no catalogue icon for an app store to show, and the darwin and windows layouts refuse to stage without one. Point `gjsify.ship.icon` at an SVG (or a directory of sized PNGs).");let se=resolveShipFlatpakSettings({ship:C,flatpak:N,kind:X});return n.push(...se.warnings),{settings:{projectDir:t.projectDir,appId:q,name:Y,binaryName:W,version:ne.version,release:assertRelease(C.release??`1`),maintainer:ie,summary:ae,description:oe,license:re,licenseFile:F.licenseFile,changelogFile:F.changelogFile,homepage:I.homepageUrl??S.homepage,section:C.section??Q.section,group:C.group??Q.group,kind:X,mimeTypes:H,extraDepends:{deb:C.depends?.deb??[],rpm:C.depends?.rpm??[]},typelibPackages:C.typelibPackages??{},bundlePath:F.bundlePath,bundleDir:F.bundleDir,iconFiles:F.iconFiles,schemaFiles:F.schemaFiles,typelibFiles:F.typelibFiles,formatFiles:F.formatFiles,localeFiles:F.localeFiles,fontFiles:F.fontFiles,extraFiles:C.extraFiles??{},execArgs:C.execArgs??[],outDir:t.cli.outDir??C.outDir??`ship`,arch:t.cli.arch??process.arch,app:Z,layoutOs:t.cli.layoutOs,minGjsVersion:C.minGjsVersion??`1.86`,minNodeVersion:C.minNodeVersion??`24`,flatpak:se.settings},metadata:I,warnings:n}}function resolveShipBundle(t){let n=t.ship.bundle,S=typeof n==`object`&&n?n:{};for(let t of Object.keys(S))if(!Object.hasOwn(BV,t))throw Error(`gjsify ship: \`gjsify.ship.bundle.${t}\` is not an OS this command assembles for. Known: ${Object.keys(BV).join(`, `)} — the \`process.platform\` spelling, not the \`gjsify ship <os>\` positional's. An entry under a key nothing reads leaves that target on \`gjsify.main\` with nothing to say so.`);let C=typeof n==`string`?n:void 0,N=t.pkg.gjsify?.main??t.pkg.main,entryFor=t=>S[t]??C??N,F=S[t.layoutOs],I=entryFor(t.layoutOs),H=F===void 0?C===void 0?t.pkg.gjsify?.main===void 0?`main`:`gjsify.main`:`gjsify.ship.bundle`:`gjsify.ship.bundle.${t.layoutOs}`,W=[...new Set(Object.keys(BV).filter(n=>n!==t.layoutOs).map(entryFor).filter(t=>t!==void 0&&t!==I))];return{declared:I,key:H,overridden:F!==void 0,foreign:W}}function deriveBinaryName(t){if(!t)throw Error("gjsify ship: no package name — set `name` in package.json or `gjsify.ship.binaryName`.");let n=(t.includes(`/`)?t.split(`/`).pop():t).toLowerCase().replace(/[^a-z\d+.-]+/g,`-`).replace(/^-+|-+$/g,``);if(!/^[a-z\d][a-z\d+.-]+$/.test(n))throw Error(`gjsify ship: cannot derive a package name from "${t}" (got "${n}"). Set \`gjsify.ship.binaryName\` to something matching \`[a-z0-9][a-z0-9+.-]+\`.`);return n}function reverseDnsOrThrow(t,n){if(t&&/^[A-Za-z][\w-]*(\.[A-Za-z][\w-]*){2,}$/.test(t))return t;throw Error(`gjsify ship: no application id. Set \`gjsify.ship.appId\` (or \`gjsify.flatpak.appId\`) to a reverse-DNS id such as "io.github.you.${titleCase(n).replace(/\s+/g,``)}". It names the desktop entry, the AppStream component and the installed icon, so it cannot be guessed.`)}function definedOnly(t){return Object.fromEntries(Object.entries(t).filter(([,t])=>t!==void 0))}function titleCase(t){return t.split(/[-_.]+/).filter(t=>t.length>0).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(` `)}function sectionsFor(t){for(let[n,S]of VV)if(t?.includes(n))return S;return{section:`misc`,group:`Applications/System`}}function formatAuthor(t){if(typeof t==`string`)return t.replace(/\s*\([^)]*\)\s*$/,``).trim()||void 0;if(t?.name)return t.email?`${t.name} <${t.email}>`:t.name}function formatDeveloper(t){let n=t.developer;if(n?.name)return n.email?`${n.name} <${n.email}>`:n.name}function descriptionParagraphs(t){if(t===void 0)return;if(typeof t==`string`){let n=t.trim().split(/\n\n+/).map(t=>t.trim().replace(/\s+/g,` `)).filter(t=>t.length>0);return n.length>0?n:void 0}let n=[];for(let S of t)if(typeof S==`string`){let t=S.trim().replace(/\s+/g,` `);t&&n.push(t)}else if(`p`in S)n.push(S.p.trim().replace(/\s+/g,` `));else for(let t of S.ul)n.push(`* ${(typeof t==`string`?t:t.item).trim().replace(/\s+/g,` `)}`);return n.length>0?n:void 0}var BV,VV,HV,UV,WV=__esmMin(()=>{IV(),In(),DB(),kz(),zV(),BV={linux:!0,darwin:!0,win32:!0},VV=[[`Development`,{section:`devel`,group:`Development/Tools`}],[`Education`,{section:`education`,group:`Applications/Education`}],[`Game`,{section:`games`,group:`Amusements/Games`}],[`Graphics`,{section:`graphics`,group:`Applications/Multimedia`}],[`AudioVideo`,{section:`sound`,group:`Applications/Multimedia`}],[`Network`,{section:`net`,group:`Applications/Internet`}],[`Office`,{section:`text`,group:`Applications/Productivity`}],[`Science`,{section:`science`,group:`Applications/Engineering`}],[`System`,{section:`admin`,group:`Applications/System`}],[`Utility`,{section:`utils`,group:`Applications/System`}]],HV=[`LICENSE`,`LICENSE.md`,`LICENSE.txt`,`COPYING`,`COPYING.md`],UV=[`CHANGELOG.md`,`CHANGELOG`,`CHANGELOG.txt`,`NEWS.md`,`NEWS`]});function discoverPayload(t){let{projectDir:n,ship:S}=t,C=resolveBundle(t),N=Cn(C,`..`),F=discoverLocales(n,S.localeDir);return{bundlePath:C,bundleDir:N,bundleFiles:withoutForeignEntries(withoutLocaleTree(listFilesRecursive(N),N,n,S.localeDir),N,n,t.foreignBundles??[],C),iconFiles:discoverIcons(n,S.icon??t.flatpakIcon),schemaFiles:discoverSchemas(n,S.schemas),typelibFiles:discoverTypelibs(n,resolveBundledTypelibs(S.bundledTypelibs,t.layoutOs)),formatFiles:discoverFormatFiles(n,S,t.layoutOs),localeFiles:F,fontFiles:discoverFonts(n,S.fonts),licenseFile:discoverLicense(n,S.licenseFile),changelogFile:discoverChangelog(n,S.changelogFile)}}function discoverFormatFiles(t,n,S){let C={};if(S!==void 0&&S!==`linux`)return C;for(let[S,N]of Object.entries(n.formats??{})){if(S!==`deb`&&S!==`rpm`)throw Error(`gjsify ship: \`gjsify.ship.formats.${S}\` is not a format that carries its own files. Known: deb, rpm.`);C[S]={typelibFiles:discoverTypelibs(t,N?.bundledTypelibs),extraFiles:Object.fromEntries(Object.entries(N?.extraFiles??{}).map(([n,S])=>[n,Cn(t,S)]))}}return C}function resolveBundledTypelibs(t,n){if(t===void 0||Array.isArray(t))return t??[];let S=[`linux`,`darwin`,`win32`];for(let n of Object.keys(t))if(!S.includes(n))throw Error(`gjsify ship: \`gjsify.ship.bundledTypelibs.${n}\` is not an OS this command assembles for. Known: ${S.join(`, `)} — the \`process.platform\` spelling, not the \`gjsify ship <os>\` positional's.`);if(n===void 0)throw Error("gjsify ship: `gjsify.ship.bundledTypelibs` is a per-OS table but no layout OS was given.");return t[n]??[]}function discoverTypelibs(t,n){let S=[];for(let C of n??[]){let n=Cn(t,C);if(!existsSync(n))throw Error(`gjsify ship: \`gjsify.ship.bundledTypelibs\` names ${C}, which does not exist. A missing directory here means the package would install without the typelib it promises.`);for(let t of listFilesRecursive(n))(/\.(typelib|dylib|dll)$/i.test(t)||/\.so(\.\d+)*$/.test(t))&&S.push($(n,t))}return S}function withoutLocaleTree(t,n,S,C){if(C===void 0)return t;let N=En(n,Cn(S,C));if(N===``||N.startsWith(`..`)||Tn(N))return t;let F=`${N.split(Nn).join(hn.sep)}${hn.sep}`;return t.filter(t=>!`${t}${hn.sep}`.startsWith(F))}function discoverLocales(t,n){if(n===void 0)return[];let S=Cn(t,n);if(!existsSync(S))throw Error(`gjsify ship: \`gjsify.ship.localeDir\` names ${n}, which does not exist. Compile the catalogues first (msgfmt, or @gjsify/vite-plugin-gettext) — a missing directory here means the package would install without the translations it promises.`);let C=[],N=[];for(let t of listFilesRecursive(S)){if(t.endsWith(`.po`)||t.endsWith(`.pot`)){N.push(`${t} (a .po source; bindtextdomain reads .mo only)`);continue}if(!t.endsWith(`.mo`))continue;let n=t.split(hn.sep);if(n.length!==3||n[1]!==`LC_MESSAGES`){N.push(`${t} (expected <lang>/LC_MESSAGES/<domain>.mo)`);continue}C.push({rel:n.join(`/`),abs:$(S,t)})}if(N.length>0)throw Error(`gjsify ship: \`gjsify.ship.localeDir\` (${n}) holds files no catalogue lookup will find:\n`+N.map(t=>` ${t}`).join(`
|
|
1145
1145
|
`)+`
|
|
1146
|
-
A misplaced catalogue installs and then shows nothing, which reads exactly like having no translation at all. Lay them out as <lang>/LC_MESSAGES/<domain>.mo.`);if(C.length===0)throw Error(`gjsify ship: \`gjsify.ship.localeDir\` (${n}) contains no \`.mo\` catalogue. Declaring a locale directory that ships nothing is a promise the package does not keep.`);return C}function withoutForeignEntries(t,n,S,C,N){if(C.length===0)return t;let F=new Set;for(let t of C){let C=Tn(t)?t:Cn(S,t);if(C===N)continue;let I=En(n,C);I===``||I.startsWith(`..`)||Tn(I)||F.add(I.split(Nn).join(hn.sep))}return t.filter(t=>!F.has(t))}function resolveBundle(t){let n=t.declaredBundle;if(n===void 0)throw Error("gjsify ship: no bundle to ship. Set `gjsify.main` (or `main`) in package.json to the built bundle, or `gjsify.ship.bundle` to override it.");let S=Tn(n)?n:Cn(t.projectDir,n);if(!existsSync(S))throw Error(`gjsify ship: the bundle ${n} does not exist. Build it first (\`gjsify run build\`), or drop \`--skip-build\`.`);return S}function discoverIcons(t,n){if(n!==void 0){let S=Cn(t,n);if(!existsSync(S))throw Error(`gjsify ship: the configured icon path ${n} does not exist.`);return statSync(S).isDirectory()?listIcons(S):[S]}for(let n of[`data/icons`,`data/icons/hicolor`]){let S=$(t,n);if(existsSync(S)&&statSync(S).isDirectory()){let t=listIcons(S);if(t.length>0)return t}}return[]}function listIcons(t){return listFilesRecursive(t).filter(t=>GV.some(n=>t.toLowerCase().endsWith(n))).map(n=>$(t,n.split(`/`).join(Nn))).sort()}function discoverFonts(t,n){let S=n??`data/fonts`,C=n===void 0?$(t,`data`,`fonts`):Cn(t,n);if(!existsSync(C)){if(n===void 0)return[];throw Error(`gjsify ship: the configured font path ${n} does not exist.`)}if(!statSync(C).isDirectory()){if(assertNotWebFont(C,S),!KV.some(t=>C.toLowerCase().endsWith(t)))throw Error(`gjsify ship: \`gjsify.ship.fonts\` names ${n}, which is not a font face fontconfig will open (${KV.join(`, `)}). A file it cannot read installs and is never found, and Pango substitutes a fallback family rather than reporting anything.`);return[C]}let N=[];for(let t of listFilesRecursive(C))assertNotWebFont(t,S),KV.some(n=>t.toLowerCase().endsWith(n))&&N.push($(C,t.split(`/`).join(Nn)));if(N.length===0&&n!==void 0)throw Error(`gjsify ship: \`gjsify.ship.fonts\` (${n}) holds no font face (${KV.join(`, `)}). Declaring fonts that ship nothing is a promise the package does not keep — and its symptom is a substituted family, not an error.`);return N.sort()}function assertNotWebFont(t,n){let S=t.toLowerCase(),C=qV.find(t=>S.endsWith(t));if(C!==void 0)throw Error(`gjsify ship: \`gjsify.ship.fonts\` (${n}) carries ${t}, and \`${C}\` is a web-font wrapper whose support is a FreeType BUILD option — brotli for woff2, zlib for woff. Whether it opens is therefore a property of the FreeType the SHIPPED artifact loads (inside \`@gjsify/gtk-runtime-<target>\` for a \`.app\` or a Windows program directory), not of the machine that packaged it. Ship the desktop face instead (${KV.join(`, `)}); a font that fails to open is not an error, it is Pango quietly substituting a different typeface.`)}function discoverSchemas(t,n){let S=n===void 0?[$(t,`data`)]:[Cn(t,n)];for(let t of S){if(!existsSync(t)){if(n!==void 0)throw Error(`gjsify ship: the configured schema path ${n} does not exist.`);continue}if(!statSync(t).isDirectory())return[t];let S=listFilesRecursive(t).filter(t=>t.endsWith(`.gschema.xml`)).map(n=>$(t,n.split(`/`).join(Nn))).sort();if(S.length>0)return S}return[]}function discoverLicense(t,n){if(n!==void 0){let S=Cn(t,n);if(!existsSync(S))throw Error(`gjsify ship: the configured licence file ${n} does not exist.`);return S}for(let n of licenseSearchDirs(t))for(let t of HV){let S=$(n,t);if(existsSync(S))return S}}function discoverChangelog(t,n){if(n!==void 0){let S=Cn(t,n);if(!existsSync(S))throw Error(`gjsify ship: the configured changelog file ${n} does not exist.`);return S}for(let n of licenseSearchDirs(t))for(let t of UV){let S=$(n,t);if(existsSync(S))return S}}function licenseSearchDirs(t){let n=[];for(let S=t;;){if(n.push(S),isProjectRoot(S))return n;let C=On(S);if(C===S)return[t];S=C}}function isProjectRoot(t){if(existsSync($(t,`.git`)))return!0;let n=$(t,`package.json`);if(!existsSync(n))return!1;try{return JSON.parse(readFileSync(n,`utf-8`)).workspaces!==void 0}catch{return!1}}function listFilesRecursive(t){let n=[],walk=S=>{for(let C of readdirSync(S,{withFileTypes:!0}).sort((t,n)=>t.name<n.name?-1:1)){let N=$(S,C.name);if(C.isDirectory())walk(N);else if(C.isSymbolicLink())throw Error(`gjsify ship: ${N} is a symlink. The payload has to be self-contained — replace it with the file it points at, or exclude it from the bundle directory.`);else C.isFile()&&n.push(hn.join(...En(t,N).split(Nn)))}};return walk(t),n.sort()}var GV,KV,qV,JV=__esmMin(()=>{Bd(),In(),WV(),GV=[`.svg`,`.png`],KV=[`.ttf`,`.otf`,`.ttc`,`.otc`],qV=[`.woff`,`.woff2`,`.eot`]});function isNodeRuntimeTarget(t){return YV.includes(t)}function nodeRuntimePackageName(t){return`@gjsify/node-runtime-${t}`}function nodeRuntimeBinaryName(t){return t.startsWith(`win32-`)?`node.exe`:`node`}function resolveNodeRuntime(t,n={}){let S=n.env??process.env,C=nodeRuntimeBinaryName(t),N=S.GJSIFY_NODE_RUNTIME;if(N){let t=complete(`GJSIFY_NODE_RUNTIME`,N,C);if(t)return t}let F=nodeRuntimePackageName(t),I=resolveInstalledPackage(F,{cwd:n.cwd,bundleUrl:import.meta.url});return I===null?null:complete(F,$(On(I),`bin`),C)}function complete(t,n,S){let C=$(n,S),N=$(n,`LICENSE`);return!existsSync(C)||!existsSync(N)?null:{source:t,binDir:n,nodePath:C,licensePath:N}}var YV,XV=__esmMin(()=>{Bd(),In(),iF(),YV=[`darwin-arm64`,`darwin-x64`,`win32-x64`]});function rfc822(t){let n=new Date(t*1e3),pad=t=>String(t).padStart(2,`0`);return`${ZV[n.getUTCDay()]}, ${pad(n.getUTCDate())} ${QV[n.getUTCMonth()]} ${n.getUTCFullYear()} ${pad(n.getUTCHours())}:${pad(n.getUTCMinutes())}:${pad(n.getUTCSeconds())} +0000`}function changelogEntriesFor(t,n){let S=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),C=RegExp(`^##+[ \\t]+\\[?${S}\\]?[^\\n]*$`,`m`).exec(n);if(C===null)return[];let N=n.slice(C.index+C[0].length),F=/^##[ \t]+\[?\d/m.exec(N),I=F===null?N:N.slice(0,F.index),H=[];for(let t of I.split(`
|
|
1146
|
+
A misplaced catalogue installs and then shows nothing, which reads exactly like having no translation at all. Lay them out as <lang>/LC_MESSAGES/<domain>.mo.`);if(C.length===0)throw Error(`gjsify ship: \`gjsify.ship.localeDir\` (${n}) contains no \`.mo\` catalogue. Declaring a locale directory that ships nothing is a promise the package does not keep.`);return C}function withoutForeignEntries(t,n,S,C,N){if(C.length===0)return t;let F=new Set;for(let t of C){let C=Tn(t)?t:Cn(S,t);if(C===N)continue;let I=En(n,C);I===``||I.startsWith(`..`)||Tn(I)||F.add(I.split(Nn).join(hn.sep))}return t.filter(t=>!F.has(t))}function resolveBundle(t){let n=t.declaredBundle;if(n===void 0)throw Error("gjsify ship: no bundle to ship. Set `gjsify.main` (or `main`) in package.json to the built bundle, or `gjsify.ship.bundle` to override it.");let S=Tn(n)?n:Cn(t.projectDir,n);if(!existsSync(S))throw Error(`gjsify ship: the bundle ${n} does not exist. Build it first (\`gjsify run build\`), or drop \`--skip-build\`.`);return S}function discoverIcons(t,n){if(n!==void 0){let S=Cn(t,n);if(!existsSync(S))throw Error(`gjsify ship: the configured icon path ${n} does not exist.`);return statSync(S).isDirectory()?listIcons(S):[S]}for(let n of[`data/icons`,`data/icons/hicolor`]){let S=$(t,n);if(existsSync(S)&&statSync(S).isDirectory()){let t=listIcons(S);if(t.length>0)return t}}return[]}function listIcons(t){return listFilesRecursive(t).filter(t=>GV.some(n=>t.toLowerCase().endsWith(n))).map(n=>$(t,n.split(`/`).join(Nn))).sort()}function discoverFonts(t,n){let S=n??`data/fonts`,C=n===void 0?$(t,`data`,`fonts`):Cn(t,n);if(!existsSync(C)){if(n===void 0)return[];throw Error(`gjsify ship: the configured font path ${n} does not exist.`)}if(!statSync(C).isDirectory()){if(assertNotWebFont(C,S),!KV.some(t=>C.toLowerCase().endsWith(t)))throw Error(`gjsify ship: \`gjsify.ship.fonts\` names ${n}, which is not a font face fontconfig will open (${KV.join(`, `)}). A file it cannot read installs and is never found, and Pango substitutes a fallback family rather than reporting anything.`);return[C]}let N=[];for(let t of listFilesRecursive(C))assertNotWebFont(t,S),KV.some(n=>t.toLowerCase().endsWith(n))&&N.push($(C,t.split(`/`).join(Nn)));if(N.length===0&&n!==void 0)throw Error(`gjsify ship: \`gjsify.ship.fonts\` (${n}) holds no font face (${KV.join(`, `)}). Declaring fonts that ship nothing is a promise the package does not keep — and its symptom is a substituted family, not an error.`);return N.sort()}function assertNotWebFont(t,n){let S=t.toLowerCase(),C=qV.find(t=>S.endsWith(t));if(C!==void 0)throw Error(`gjsify ship: \`gjsify.ship.fonts\` (${n}) carries ${t}, and \`${C}\` is a web-font wrapper whose support is a FreeType BUILD option — brotli for woff2, zlib for woff. Whether it opens is therefore a property of the FreeType the SHIPPED artifact loads (inside \`@gjsify/gtk-runtime-<target>\` for a \`.app\` or a Windows program directory), not of the machine that packaged it. Ship the desktop face instead (${KV.join(`, `)}); a font that fails to open is not an error, it is Pango quietly substituting a different typeface.`)}function discoverSchemas(t,n){let S=n===void 0?[$(t,`data`)]:[Cn(t,n)];for(let t of S){if(!existsSync(t)){if(n!==void 0)throw Error(`gjsify ship: the configured schema path ${n} does not exist.`);continue}if(!statSync(t).isDirectory())return[t];let S=listFilesRecursive(t).filter(t=>t.endsWith(`.gschema.xml`)).map(n=>$(t,n.split(`/`).join(Nn))).sort();if(S.length>0)return S}return[]}function discoverLicense(t,n){if(n!==void 0){let S=Cn(t,n);if(!existsSync(S))throw Error(`gjsify ship: the configured licence file ${n} does not exist.`);return S}for(let n of licenseSearchDirs(t))for(let t of HV){let S=$(n,t);if(existsSync(S))return S}}function discoverChangelog(t,n){if(n!==void 0){let S=Cn(t,n);if(!existsSync(S))throw Error(`gjsify ship: the configured changelog file ${n} does not exist.`);return S}for(let n of licenseSearchDirs(t))for(let t of UV){let S=$(n,t);if(existsSync(S))return S}}function licenseSearchDirs(t){let n=[];for(let S=t;;){if(n.push(S),isProjectRoot(S))return n;let C=On(S);if(C===S)return[t];S=C}}function isProjectRoot(t){if(existsSync($(t,`.git`)))return!0;let n=$(t,`package.json`);if(!existsSync(n))return!1;try{return JSON.parse(readFileSync(n,`utf-8`)).workspaces!==void 0}catch{return!1}}function listFilesRecursive(t){let n=[],walk=S=>{for(let C of readdirSync(S,{withFileTypes:!0}).sort((t,n)=>t.name<n.name?-1:1)){let N=$(S,C.name);if(C.isDirectory())walk(N);else if(C.isSymbolicLink())throw Error(`gjsify ship: ${N} is a symlink. The payload has to be self-contained — replace it with the file it points at, or exclude it from the bundle directory.`);else C.isFile()&&n.push(hn.join(...En(t,N).split(Nn)))}};return walk(t),n.sort()}var GV,KV,qV,JV=__esmMin(()=>{Bd(),In(),WV(),GV=[`.svg`,`.png`],KV=[`.ttf`,`.otf`,`.ttc`,`.otc`],qV=[`.woff`,`.woff2`,`.eot`]});function isNodeRuntimeTarget(t){return YV.includes(t)}function nodeRuntimePackageName(t){return`@gjsify/node-runtime-${t}`}function nodeRuntimeBinaryName(t){return t.startsWith(`win32-`)?`node.exe`:`node`}function resolveNodeRuntime(t,n={}){let S=n.env??process.env,C=nodeRuntimeBinaryName(t),N=S.GJSIFY_NODE_RUNTIME;if(N){let t=complete(`GJSIFY_NODE_RUNTIME`,N,C);if(t)return t}let F=nodeRuntimePackageName(t),I=resolveInstalledPackage(F,{cwd:n.cwd,bundleUrl:import.meta.url});return I===null?null:complete(F,$(On(I),`bin`),C)}function complete(t,n,S){let C=$(n,S),N=$(n,`LICENSE`);return!existsSync(C)||!existsSync(N)?null:{source:t,binDir:n,nodePath:C,licensePath:N}}var YV,XV=__esmMin(()=>{Bd(),In(),iF(),YV=[`darwin-arm64`,`darwin-x64`,`win32-x64`,`win32-arm64`]});function rfc822(t){let n=new Date(t*1e3),pad=t=>String(t).padStart(2,`0`);return`${ZV[n.getUTCDay()]}, ${pad(n.getUTCDate())} ${QV[n.getUTCMonth()]} ${n.getUTCFullYear()} ${pad(n.getUTCHours())}:${pad(n.getUTCMinutes())}:${pad(n.getUTCSeconds())} +0000`}function changelogEntriesFor(t,n){let S=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),C=RegExp(`^##+[ \\t]+\\[?${S}\\]?[^\\n]*$`,`m`).exec(n);if(C===null)return[];let N=n.slice(C.index+C[0].length),F=/^##[ \t]+\[?\d/m.exec(N),I=F===null?N:N.slice(0,F.index),H=[];for(let t of I.split(`
|
|
1147
1147
|
`)){let n=/^[*-][ \t]+(.*\S)\s*$/.exec(t);n!==null&&H.push(n[1].replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\*\*([^*]+)\*\*/g,`$1`).replace(/\s+/g,` `).trim())}return H}function wrapEntry(t){let n=[],S=` *`;for(let C of t.split(/\s+/))C!==``&&(S.length+1+C.length>$V&&S!==` *`&&S!==` `&&(n.push(S),S=` `),S+=` ${C}`);return n.push(S),n}function renderDebianChangelog(t,n,S){let C=n===void 0?[]:changelogEntriesFor(t.version,n),N=t.homepage?`Release ${t.version}. See ${t.homepage} for the upstream changes.`:`Release ${t.version}.`,F=(C.length>0?C:[N]).flatMap(wrapEntry);return[`${t.binaryName} (${t.version}-${t.release}) unstable; urgency=medium`,``,...F,``,` -- ${t.maintainer} ${rfc822(S)}`,``].join(`
|
|
1148
1148
|
`)}var ZV,QV,$V,eH=__esmMin(()=>{ZV=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],QV=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],$V=80});function planStage(t,n){let S=[],C=`lib/${t.binaryName}`;S.push({path:`bin/${t.binaryName}`,mode:493,source:{kind:`text`,text:n.launcher}});for(let N of n.bundleFiles)S.push({path:hn.join(C,N),mode:isExecutableAsset(N)?493:420,source:{kind:`file`,path:hn.join(t.bundleDir,N)}});if(S.push({path:`${kB.metainfo}/${t.appId}.metainfo.xml`,mode:420,source:{kind:`text`,text:n.metainfo}}),t.kind===`app`){if(n.desktopEntry===void 0)throw Error('gjsify ship: internal error — a desktop entry is required for `kind: "app"`.');S.push({path:`${kB.applications}/${t.appId}.desktop`,mode:420,source:{kind:`text`,text:n.desktopEntry}});for(let n of planIcons(t))S.push(n)}for(let n of t.schemaFiles){let C=kn(n);if(!C.startsWith(t.appId))throw Error(`gjsify ship: the GSettings schema ${C} must be named \`${t.appId}[.…].gschema.xml\`. Every installed schema shares one system directory, so the app id is what keeps it unique.`);S.push({path:`${kB.schemas}/${C}`,mode:420,source:{kind:`file`,path:n}})}for(let n of t.typelibFiles)S.push({path:hn.join(C,`gi`,kn(n)),mode:493,source:{kind:`file`,path:n}});t.mimeTypes.length>0&&S.push({path:`${kB.mime}/${t.appId}.xml`,mode:420,source:{kind:`text`,text:renderMimePackage(t.mimeTypes)}});for(let n of t.localeFiles)S.push({path:hn.join(kB.locale,n.rel),mode:420,source:{kind:`file`,path:n.abs}});for(let n of planFonts(t))S.push(n);for(let[n,C]of Object.entries(t.extraFiles))S.push({path:assertInsidePrefix(n),mode:420,source:{kind:`file`,path:C}});return normalise(S)}function planFonts(t){let n=[],S=new Map;for(let C of t.fontFiles){let N=`${kB.fonts}/${t.appId}/${kn(C)}`,F=S.get(N);if(F!==void 0)throw Error(`gjsify ship: ${C} and ${F} both install as ${N}. Two faces cannot share one filename — one would silently not ship, and a missing face is a substituted typeface rather than an error. Rename one, or point \`gjsify.ship.fonts\` at a directory holding only the faces you mean to ship.`);S.set(N,C),n.push({path:N,mode:420,source:{kind:`file`,path:C}})}return n}async function planOverlay(t,n,S){if(S.licenseText===void 0)throw Error(`gjsify ship: no licence file found, so the ${n.id} package would ship no ${n.licenseDest(t.binaryName)}. Debian Policy § 12.5 requires it and lintian errors without it, and neither dpkg nor rpm will tell you it is missing. Add a LICENSE file to ${t.projectDir} or to the root of its repository, or point \`gjsify.ship.licenseFile\` at the one this package ships under.`);let C=n.licenseKind===`debian-copyright`?renderDebianCopyright(t,S.licenseText):S.licenseText,N=[{path:n.licenseDest(t.binaryName),mode:420,source:{kind:`text`,text:C}}];if(n.changelogDest!==void 0){let C=renderDebianChangelog(t,S.changelogText,S.mtime);N.push({path:n.changelogDest(t.binaryName),mode:420,source:{kind:`bytes`,data:await gzipDeterministic(new TextEncoder().encode(C),9)}})}let F=t.formatFiles[n.id];for(let n of F?.typelibFiles??[])N.push({path:hn.join(`lib`,t.binaryName,`gi`,kn(n)),mode:493,source:{kind:`bytes`,data:new Uint8Array(await readFile$1(n))}});for(let[t,n]of Object.entries(F?.extraFiles??{}))N.push({path:assertInsidePrefix(t),mode:t.endsWith(`.so`)?493:420,source:{kind:`bytes`,data:new Uint8Array(await readFile$1(n))}});return N}function assertOverlayIsLicensed(t,n,S){if(!(S.length>0))throw Error(`gjsify ship: this stage carries no ${t} licence overlay, so the package would ship no licence file for ${n} — Debian Policy § 12.5 requires one and lintian errors without it. The fix is on the assembling host, not this one: give that project a LICENSE (or set \`gjsify.ship.licenseFile\`) and re-run the \`--stage\` phase.`)}function renderDebianCopyright(t,n){let S=n.trimEnd().split(`
|
|
1149
1149
|
`).map(t=>t.trim()===``?` .`:` ${t}`).join(`
|
|
1150
1150
|
`);return[`Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/`,`Upstream-Name: ${t.name}`,...t.homepage?[`Source: ${t.homepage}`]:[],``,`Files: *`,`Copyright: ${t.maintainer}`,`License: ${t.license}`,S,``].join(`
|
|
1151
|
-
`)}function planIcons(t){let n=[],S=new Map;for(let C of t.iconFiles){let N=An(C),F=iconThemeDir(C),I=isSymbolicIcon(C)?`${t.appId}-symbolic`:t.appId,H=`${kB.icons}/${F}/apps/${I}${N}`,W=S.get(H);if(W!==void 0)throw Error(`gjsify ship: ${C} and ${W} both install as ${H}. 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.`);S.set(H,C),n.push({path:H,mode:420,source:{kind:`file`,path:C}})}return n}function assertInsidePrefix(t){let n=hn.normalize(t);if(hn.isAbsolute(n)||n===`..`||n.startsWith(`../`))throw Error(`gjsify ship: \`gjsify.ship.extraFiles\` destination "${t}" escapes the install prefix. Destinations are relative to the prefix, e.g. \`share/applications/extra.desktop\`.`);return n}function isExecutableAsset(t){return/\.(so|node|dylib)(\.\d+)*$/.test(t)}function normalise(t){let n=new Map;for(let S of t)n.set(S.path,S);return[...n.values()].sort((t,n)=>t.path<n.path?-1:+(t.path>n.path))}var tH=__esmMin(()=>{eH(),OB(),IB(),IV(),AB(),Cd(),In()});function isGtkRuntimeTarget(t){return nH.includes(t)}function gtkRuntimePackageName(t){return`@gjsify/gtk-runtime-${t}`}function resolveGtkRuntime(t,n={}){let S=n.env??process.env,C=t.startsWith(`win32-`)?`bin`:`lib`,N=[],F=S.GJSIFY_GTK_RUNTIME;F&&N.push({source:`GJSIFY_GTK_RUNTIME`,dir:F});let I=resolveNodeGiRoot(n);I!==null&&(N.push({source:`${iH}/prebuilds/${t}`,dir:$(I,`prebuilds`,t,`gtk`)}),N.push({source:`${iH} sibling`,dir:$(I,`..`,`gtk-runtime-${t}`,`gtk`)}));let H=gtkRuntimePackageName(t),W=resolveStagedPackage(H,n);W!==null&&N.push({source:H,dir:$(On(W),`gtk`)}),n.fetchedGtkRuntimeDir!==void 0&&N.push({source:`${H} (fetched for this ship run)`,dir:$(n.fetchedGtkRuntimeDir,`gtk`)});for(let t of N){let n=$(t.dir,C),S=$(t.dir,`girepository-1.0`);if(!(!existsSync(n)||!existsSync(S)))return{source:t.source,dir:t.dir,libDir:n,typelibDir:S}}return null}function resolveNodeGiAddon(t,n={}){let S=resolveNodeGiRoot(n);if(S===null)return null;let C=$(S,`prebuilds`,t,rH);return existsSync(C)?{source:iH,addonPath:C}:null}function resolveNodeGiRoot(t){let n=resolveStagedPackage(iH,t);return n===null?null:On(n)}function resolveStagedPackage(t,n){let S={bundleUrl:import.meta.url};return n.cwd!==void 0&&(S.cwd=n.cwd),n.resolve!==void 0&&(S.resolve=n.resolve),resolveInstalledPackage(t,S)}function resolveNodeGiPackage(t={}){let n=resolveNodeGiRoot(t);if(n===null)return null;let S=[`package.json`];for(let t of readdirSync(n,{withFileTypes:!0}).sort((t,n)=>t.name<n.name?-1:1))t.isFile()&&t.name.endsWith(`.js`)&&S.push(t.name);let C=$(n,`overrides`);if(existsSync(C))for(let t of listFilesRecursive(C))S.push(hn.join(`overrides`,t));return S.length>1?{source:iH,root:n,files:S.sort()}:null}function appRuntimePaths(t,n,S){let C=t.dirs(n),N=hn.join(C.native,`node-gi`),F=hn.join(N,`prebuilds`,S);return{nodeGiRoot:N,nodeGiPackageDir:hn.join(C.bundle,`node_modules`,iH),prebuildDir:F,gtkDir:hn.join(F,`gtk`),addonPath:hn.join(F,rH),interpreterPath:C.helpers===``?hn.join(C.launcher,nodeRuntimeBinaryName(S)):hn.join(C.helpers,assertUsableAsHelperName(n.name)),interpreterLicensePath:hn.join(C.data,`licenses`,`node`,`LICENSE`)}}function stageAppRuntime(t){let n=appRuntimePaths(t.layout,t.identity,t.target),S=[],C={},N=[],F=[];t.interpreter===null?F.push(`no bundled interpreter — install \`@gjsify/node-runtime-${t.target}\` (or point \`GJSIFY_NODE_RUNTIME\` at a \`bin/\` directory holding \`node\` and its \`LICENSE\`)`):(S.push({path:n.interpreterPath,mode:493,source:{kind:`file`,path:t.interpreter.nodePath}}),S.push({path:n.interpreterLicensePath,mode:420,source:{kind:`file`,path:t.interpreter.licensePath}}),C.interpreter=n.interpreterPath,N.push(`interpreter from ${t.interpreter.source}`));let I=resolveGtkRuntime(t.target,discoveryOptions(t));if(I!==null){for(let t of listFilesRecursive(I.dir)){let C=$(I.dir,t.split(`/`).join(Nn));S.push({path:hn.join(n.gtkDir,t),mode:stagedMode(t,C),source:{kind:`file`,path:C}})}C.gtkRuntimeDir=n.gtkDir,N.push(`GTK closure from ${I.source}`)}else{let n=t.target.startsWith(`win32-`)?`bin`:`lib`,S=t.gtkFetchFailure===void 0?``:` — fetching it failed: ${t.gtkFetchFailure}`;F.push(`no GTK closure${S} — point \`GJSIFY_GTK_RUNTIME\` at a bundle directory holding \`${n}/\` and \`girepository-1.0/\`, or install \`${gtkRuntimePackageName(t.target)}\` where the build can reach it`)}let H=resolveNodeGiPackage(discoveryOptions(t));if(H!==null){for(let t of H.files)S.push({path:hn.join(n.nodeGiPackageDir,t),mode:420,source:{kind:`file`,path:$(H.root,t.split(`/`).join(Nn))}});N.push(`node-gi runtime (${H.files.length} file(s)) from ${H.source}`)}else F.push(`no node-gi JavaScript — install \`${iH}\`; a \`--app node\` bundle keeps \`@gjsify/node-gi/*\` external, so the staged bundle would \`require\` a package the artifact does not carry`);let W=resolveNodeGiAddon(t.target,discoveryOptions(t));return W===null?F.push(`no node-gi addon — install \`${iH}\`, whose \`prebuilds/${t.target}/${rH}\` is the binary built against that closure`):(S.push({path:n.addonPath,mode:493,source:{kind:`file`,path:W.addonPath}}),C.nodeGiAddon=n.addonPath,N.push(`node-gi addon from ${W.source}`)),{files:S,launcher:C,found:N,missing:F}}function discoveryOptions(t){let n={};return t.cwd!==void 0&&(n.cwd=t.cwd),t.env!==void 0&&(n.env=t.env),t.resolve!==void 0&&(n.resolve=t.resolve),t.fetchedGtkRuntimeDir!==void 0&&(n.fetchedGtkRuntimeDir=t.fetchedGtkRuntimeDir),n}function stagedMode(t,n){if(isExecutableAsset(t)||t.startsWith(`libexec/`)||t.startsWith(`bin/`))return 493;try{if(statSync(n).mode&73)return 493}catch{}return 420}var nH,rH,iH,aH=__esmMin(()=>{Bd(),In(),JV(),_V(),XV(),tH(),iF(),nH=[`darwin-arm64`,`darwin-x64`,`win32-x64`],rH=`node_gi.node`,iH=`@gjsify/node-gi`});async function acquireGtkRuntime(t){let n=t.discovery??{};if(resolveGtkRuntime(t.target,n)!==null)return{kind:`present`};let S=gtkRuntimePackageName(t.target),C=`${S}@${t.version}`;t.log?.(`${S} is not installed here, and is not meant to be — fetching ${C} into the cache (about 100 MB, once)`);let N;try{N=await t.ensure(C)}catch(t){return{kind:`failed`,reason:t instanceof Error?t.message:String(t)}}return resolveGtkRuntime(t.target,{...n,fetchedGtkRuntimeDir:N})===null?{kind:`failed`,reason:`${C} was fetched to ${N} but holds no complete gtk/ closure`}:{kind:`fetched`,dir:N}}var oH=__esmMin(()=>{aH()});function appDirFor(t){return $(t,`appimage`,dH)}function appImageHostRequirements(t){let n=interpreterFloor(t),S=new Set(t.optionalNamespaces??[]);return[`${t.app} (>= ${n})`,...hostProvidedNamespaces(t.namespaces,t.bundledTypelibs).map(t=>S.has(t)?`the ${t} typelib (optional)`:`the ${t} typelib`)]}function interpreterFloor(t){return t.app===`node`?t.minNodeVersion??`24`:t.minGjsVersion??`1.86`}function renderAppRun(t,n){let S=mV.linux.dirs(t).launcher,C=interpreterFloor(t),[N=`0`,F=`0`]=C.split(`.`);return[`#!/bin/sh`,"# Generated by `gjsify ship` — do not edit.",`set -e`,`here=$(dirname "$(readlink -f "$0")")`,`if ! command -v ${t.app} >/dev/null 2>&1; then`,` echo "${shellSafe(t.name)} needs ${t.app}, and this system has none." >&2`,` echo "This AppImage carries the application, not its runtime. It needs:" >&2`,...n.map(t=>` echo " - ${shellSafe(t)}" >&2`),` exit 127`,`fi`,`found=$(${t.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 ${N} ] || { [ "$major" -eq ${N} ] && [ "$minor" -lt ${F} ]; }; then`,` echo "${shellSafe(t.name)} needs ${t.app} ${C} or newer, and this system has $major.$minor." >&2`,` echo "This AppImage carries the application, not its runtime. It needs:" >&2`,...n.map(t=>` echo " - ${shellSafe(t)}" >&2`),` exit 126`,` fi`,`fi`,`exec "$here/usr/${S}/${t.binaryName}" "$@"`,``].join(`
|
|
1151
|
+
`)}function planIcons(t){let n=[],S=new Map;for(let C of t.iconFiles){let N=An(C),F=iconThemeDir(C),I=isSymbolicIcon(C)?`${t.appId}-symbolic`:t.appId,H=`${kB.icons}/${F}/apps/${I}${N}`,W=S.get(H);if(W!==void 0)throw Error(`gjsify ship: ${C} and ${W} both install as ${H}. 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.`);S.set(H,C),n.push({path:H,mode:420,source:{kind:`file`,path:C}})}return n}function assertInsidePrefix(t){let n=hn.normalize(t);if(hn.isAbsolute(n)||n===`..`||n.startsWith(`../`))throw Error(`gjsify ship: \`gjsify.ship.extraFiles\` destination "${t}" escapes the install prefix. Destinations are relative to the prefix, e.g. \`share/applications/extra.desktop\`.`);return n}function isExecutableAsset(t){return/\.(so|node|dylib)(\.\d+)*$/.test(t)}function normalise(t){let n=new Map;for(let S of t)n.set(S.path,S);return[...n.values()].sort((t,n)=>t.path<n.path?-1:+(t.path>n.path))}var tH=__esmMin(()=>{eH(),OB(),IB(),IV(),AB(),Cd(),In()});function isGtkRuntimeTarget(t){return nH.includes(t)}function gtkRuntimePackageName(t){return`@gjsify/gtk-runtime-${t}`}function resolveGtkRuntime(t,n={}){let S=n.env??process.env,C=t.startsWith(`win32-`)?`bin`:`lib`,N=[],F=S.GJSIFY_GTK_RUNTIME;F&&N.push({source:`GJSIFY_GTK_RUNTIME`,dir:F});let I=resolveNodeGiRoot(n);I!==null&&(N.push({source:`${iH}/prebuilds/${t}`,dir:$(I,`prebuilds`,t,`gtk`)}),N.push({source:`${iH} sibling`,dir:$(I,`..`,`gtk-runtime-${t}`,`gtk`)}));let H=gtkRuntimePackageName(t),W=resolveStagedPackage(H,n);W!==null&&N.push({source:H,dir:$(On(W),`gtk`)}),n.fetchedGtkRuntimeDir!==void 0&&N.push({source:`${H} (fetched for this ship run)`,dir:$(n.fetchedGtkRuntimeDir,`gtk`)});for(let t of N){let n=$(t.dir,C),S=$(t.dir,`girepository-1.0`);if(!(!existsSync(n)||!existsSync(S)))return{source:t.source,dir:t.dir,libDir:n,typelibDir:S}}return null}function resolveNodeGiAddon(t,n={}){let S=resolveNodeGiRoot(n);if(S===null)return null;let C=$(S,`prebuilds`,t,rH);return existsSync(C)?{source:iH,addonPath:C}:null}function resolveNodeGiRoot(t){let n=resolveStagedPackage(iH,t);return n===null?null:On(n)}function resolveStagedPackage(t,n){let S={bundleUrl:import.meta.url};return n.cwd!==void 0&&(S.cwd=n.cwd),n.resolve!==void 0&&(S.resolve=n.resolve),resolveInstalledPackage(t,S)}function resolveNodeGiPackage(t={}){let n=resolveNodeGiRoot(t);if(n===null)return null;let S=[`package.json`];for(let t of readdirSync(n,{withFileTypes:!0}).sort((t,n)=>t.name<n.name?-1:1))t.isFile()&&t.name.endsWith(`.js`)&&S.push(t.name);let C=$(n,`overrides`);if(existsSync(C))for(let t of listFilesRecursive(C))S.push(hn.join(`overrides`,t));return S.length>1?{source:iH,root:n,files:S.sort()}:null}function appRuntimePaths(t,n,S){let C=t.dirs(n),N=hn.join(C.native,`node-gi`),F=hn.join(N,`prebuilds`,S);return{nodeGiRoot:N,nodeGiPackageDir:hn.join(C.bundle,`node_modules`,iH),prebuildDir:F,gtkDir:hn.join(F,`gtk`),addonPath:hn.join(F,rH),interpreterPath:C.helpers===``?hn.join(C.launcher,nodeRuntimeBinaryName(S)):hn.join(C.helpers,assertUsableAsHelperName(n.name)),interpreterLicensePath:hn.join(C.data,`licenses`,`node`,`LICENSE`)}}function stageAppRuntime(t){let n=appRuntimePaths(t.layout,t.identity,t.target),S=[],C={},N=[],F=[];t.interpreter===null?F.push(`no bundled interpreter — install \`@gjsify/node-runtime-${t.target}\` (or point \`GJSIFY_NODE_RUNTIME\` at a \`bin/\` directory holding \`node\` and its \`LICENSE\`)`):(S.push({path:n.interpreterPath,mode:493,source:{kind:`file`,path:t.interpreter.nodePath}}),S.push({path:n.interpreterLicensePath,mode:420,source:{kind:`file`,path:t.interpreter.licensePath}}),C.interpreter=n.interpreterPath,N.push(`interpreter from ${t.interpreter.source}`));let I=resolveGtkRuntime(t.target,discoveryOptions(t));if(I!==null){for(let t of listFilesRecursive(I.dir)){let C=$(I.dir,t.split(`/`).join(Nn));S.push({path:hn.join(n.gtkDir,t),mode:stagedMode(t,C),source:{kind:`file`,path:C}})}C.gtkRuntimeDir=n.gtkDir,N.push(`GTK closure from ${I.source}`)}else{let n=t.target.startsWith(`win32-`)?`bin`:`lib`,S=t.gtkFetchFailure===void 0?``:` — fetching it failed: ${t.gtkFetchFailure}`;F.push(`no GTK closure${S} — point \`GJSIFY_GTK_RUNTIME\` at a bundle directory holding \`${n}/\` and \`girepository-1.0/\`, or install \`${gtkRuntimePackageName(t.target)}\` where the build can reach it`)}let H=resolveNodeGiPackage(discoveryOptions(t));if(H!==null){for(let t of H.files)S.push({path:hn.join(n.nodeGiPackageDir,t),mode:420,source:{kind:`file`,path:$(H.root,t.split(`/`).join(Nn))}});N.push(`node-gi runtime (${H.files.length} file(s)) from ${H.source}`)}else F.push(`no node-gi JavaScript — install \`${iH}\`; a \`--app node\` bundle keeps \`@gjsify/node-gi/*\` external, so the staged bundle would \`require\` a package the artifact does not carry`);let W=resolveNodeGiAddon(t.target,discoveryOptions(t));return W===null?F.push(`no node-gi addon — install \`${iH}\`, whose \`prebuilds/${t.target}/${rH}\` is the binary built against that closure`):(S.push({path:n.addonPath,mode:493,source:{kind:`file`,path:W.addonPath}}),C.nodeGiAddon=n.addonPath,N.push(`node-gi addon from ${W.source}`)),{files:S,launcher:C,found:N,missing:F}}function discoveryOptions(t){let n={};return t.cwd!==void 0&&(n.cwd=t.cwd),t.env!==void 0&&(n.env=t.env),t.resolve!==void 0&&(n.resolve=t.resolve),t.fetchedGtkRuntimeDir!==void 0&&(n.fetchedGtkRuntimeDir=t.fetchedGtkRuntimeDir),n}function stagedMode(t,n){if(isExecutableAsset(t)||t.startsWith(`libexec/`)||t.startsWith(`bin/`))return 493;try{if(statSync(n).mode&73)return 493}catch{}return 420}var nH,rH,iH,aH=__esmMin(()=>{Bd(),In(),JV(),_V(),XV(),tH(),iF(),nH=[`darwin-arm64`,`darwin-x64`,`win32-x64`,`win32-arm64`],rH=`node_gi.node`,iH=`@gjsify/node-gi`});async function acquireGtkRuntime(t){let n=t.discovery??{};if(resolveGtkRuntime(t.target,n)!==null)return{kind:`present`};let S=gtkRuntimePackageName(t.target),C=`${S}@${t.version}`;t.log?.(`${S} is not installed here, and is not meant to be — fetching ${C} into the cache (about 100 MB, once)`);let N;try{N=await t.ensure(C)}catch(t){return{kind:`failed`,reason:t instanceof Error?t.message:String(t)}}return resolveGtkRuntime(t.target,{...n,fetchedGtkRuntimeDir:N})===null?{kind:`failed`,reason:`${C} was fetched to ${N} but holds no complete gtk/ closure`}:{kind:`fetched`,dir:N}}var oH=__esmMin(()=>{aH()});function appDirFor(t){return $(t,`appimage`,dH)}function appImageHostRequirements(t){let n=interpreterFloor(t),S=new Set(t.optionalNamespaces??[]);return[`${t.app} (>= ${n})`,...hostProvidedNamespaces(t.namespaces,t.bundledTypelibs).map(t=>S.has(t)?`the ${t} typelib (optional)`:`the ${t} typelib`)]}function interpreterFloor(t){return t.app===`node`?t.minNodeVersion??`24`:t.minGjsVersion??`1.86`}function renderAppRun(t,n){let S=mV.linux.dirs(t).launcher,C=interpreterFloor(t),[N=`0`,F=`0`]=C.split(`.`);return[`#!/bin/sh`,"# Generated by `gjsify ship` — do not edit.",`set -e`,`here=$(dirname "$(readlink -f "$0")")`,`if ! command -v ${t.app} >/dev/null 2>&1; then`,` echo "${shellSafe(t.name)} needs ${t.app}, and this system has none." >&2`,` echo "This AppImage carries the application, not its runtime. It needs:" >&2`,...n.map(t=>` echo " - ${shellSafe(t)}" >&2`),` exit 127`,`fi`,`found=$(${t.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 ${N} ] || { [ "$major" -eq ${N} ] && [ "$minor" -lt ${F} ]; }; then`,` echo "${shellSafe(t.name)} needs ${t.app} ${C} or newer, and this system has $major.$minor." >&2`,` echo "This AppImage carries the application, not its runtime. It needs:" >&2`,...n.map(t=>` echo " - ${shellSafe(t)}" >&2`),` exit 126`,` fi`,`fi`,`exec "$here/usr/${S}/${t.binaryName}" "$@"`,``].join(`
|
|
1152
1152
|
`)}function shellSafe(t){return t.replace(/(["$`\\])/g,`\\$1`)}function findPinnedRuntime(t,n=process.env,S=existsSync){let C=n.GJSIFY_APPIMAGE_RUNTIME_DIR||`/usr/local/share/gjsify/appimage-runtime`,N=hn.join(C,`runtime-${t}`);return S(N)?N:void 0}function appImageRuntimeNotice(t,n){return n===void 0?`NO pinned AppImage runtime for ${t}: appimagetool will fetch runtime-${t} 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 ${uH}/runtime-${t} (or point ${lH} at a directory holding it).`:`the AppImage runtime is pinned: ${n} — this pack needs no network`}function selectAppDirIcon(t,n){let S;for(let C of t){let t=rootIconRank(C.path,n);t!==void 0&&(S===void 0||t>S.rank)&&(S={entry:C,rank:t})}return S?.entry}function rootIconRank(t,n){if(mH.find(S=>t.endsWith(`${n}${S}`))===void 0||!t.startsWith(`${kB.icons}/`)||t.includes(`/symbolic/`))return;if(t.includes(`/scalable/`))return 2**53-1;let S=/\/(\d+)x\1\//.exec(t);return S===null?1:Number(S[1])}function assertAppImageIsPackable(t,n,S){let C=`${kB.applications}/${n.appId}.desktop`;if(!t.some(t=>t.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(t,n.appId)===void 0)throw Error(`gjsify ship: an AppImage needs an icon called ${n.appId} beside its desktop entry, and this payload stages none under ${kB.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(S===void 0&&t.some(t=>isSchemaSource(t.path)))throw Error(`gjsify ship: this payload stages GSettings schema sources under ${kB.schemas}/ and no ${xV} 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 ${xV}; \`compileSchemasForPayload\` produces it from this payload.`)}function appDirPayload(t,n,S,C){assertAppImageIsPackable(n,t,C);let N=selectAppDirIcon(n,t.appId),F=`${kB.applications}/${t.appId}.desktop`,I=n.find(t=>t.path===F);return[...[...n,...C===void 0?[]:[C]].map(t=>({...t,path:`usr/${t.path}`})),{path:fH,mode:493,data:encodeUtf8(renderAppRun(t,S))},{path:`${t.appId}.desktop`,mode:420,data:I.data},{path:N.path.slice(N.path.lastIndexOf(`/`)+1),mode:420,data:N.data},{path:pH,mode:420,data:N.data}]}function appImageToolArgs(t){return[`--no-appstream`,`--comp`,`zstd`,...t.runtimeFile===void 0?[]:[`--runtime-file`,t.runtimeFile],t.appDir,t.target]}function appImageToolEnv(t){return{ARCH:t,[cH]:`1`}}function appImageToolFailureMessage(t,n){let S=n===void 0?`the AppImage RUNTIME could not be downloaded — ${sH} 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 ${n} 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: ${sH} failed with ${t}. Four causes, measured in this order: ${S}\`file\` is not installed — ${sH} 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 ${cH}=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(t){let n=appImageToolArgs(t),S=appImageToolEnv(t.archLabel);t.verbose&&ge.log(`[gjsify ship] ${Object.entries(S).map(([t,n])=>`${t}=${n}`).join(` `)} ${sH} ${n.join(` `)}`);let C=await spawnToCompletion(sH,n,{completion:`return`,cwd:t.workDir,stdio:`inherit`,env:{...process.env,...S},notFound:()=>Error(`gjsify ship: ${sH} 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 \`${sH}\`. \`gjsify ship linux --stage\` needs none of this — the payload is assembled by this CLI and only the container needs the tool.`)});if(C.code!==0)throw Error(appImageToolFailureMessage(describeExit(C),t.runtimeFile));if(!existsSync(t.target))throw Error(`gjsify ship: ${sH} exited 0 and wrote no file at ${t.target}. An exit code is not an artifact — re-run with \`--verbose\` to see what it was told.`)}function appDirPaths(t){let n=new Set;for(let S of t){let t=S.path.split(`/`);for(let S=1;S<t.length;S++)n.add(t.slice(0,S).join(`/`))}return[...[...n].sort(),...t.map(t=>t.path)]}function stampAppDirTimes(t,n,S){for(let C of appDirPaths(n))utimesSync($(t,C.split(`/`).join(Nn)),S,S);utimesSync(t,S,S)}var sH,cH,lH,uH,dH,fH,pH,mH,hH=__esmMin(()=>{_e(),Bd(),In(),U_(),hB(),DB(),_V(),SV(),AB(),sH=`appimagetool`,cH=`APPIMAGE_EXTRACT_AND_RUN`,lH=`GJSIFY_APPIMAGE_RUNTIME_DIR`,uH=`/usr/local/share/gjsify/appimage-runtime`,dH=`AppDir`,fH=`AppRun`,pH=`.DirIcon`,mH=[`.png`,`.svg`]});function dmgVolumeName(t){let n=t.name;if(n.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(_H.test(n))throw Error(`gjsify ship: the macOS image would mount a volume called "${n}", 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 n}function hdiutilCreateArgs(t){return[`create`,`-format`,`UDZO`,`-fs`,`HFS+J`,`-volname`,t.volumeName,`-srcfolder`,t.sourceDir,`-ov`,`-quiet`,t.target]}async function buildDmgImage(t){let n=hdiutilCreateArgs(t);t.verbose&&ge.log(`[gjsify ship] ${gH} ${n.join(` `)}`);let S=await spawnToCompletion(gH,n,{completion:`return`,cwd:t.workDir,stdio:`inherit`,notFound:()=>Error(`gjsify ship: ${gH} 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(S.code!==0)throw Error(`gjsify ship: ${gH} failed with ${describeExit(S)}.`)}function dmgVolumeDir(t){return $(t,`dmg`,`volume`)}var gH,_H,vH=__esmMin(()=>{_e(),In(),U_(),gH=`hdiutil`,_H=/[/:]/});function renderShipFlatpakManifest(t){let{settings:n,stageDir:S,overlayDir:C}=t,N=n.flatpak,F={id:n.appId,runtime:N.runtime,"runtime-version":N.runtimeVersion,sdk:N.sdk,branch:N.branch,command:n.binaryName,"finish-args":N.finishArgs};return N.sdkExtensions.length>0&&(F[`sdk-extensions`]=N.sdkExtensions),N.appendPath.length>0&&(F[`build-options`]={"append-path":N.appendPath.join(`:`)}),N.cleanup.length>0&&(F.cleanup=N.cleanup),F.modules=[{name:n.binaryName,buildsystem:`simple`,"build-commands":[`mkdir -p /app`,`cp -a stage/. /app/`,`cp -a overlay/. /app/`],sources:[{type:`dir`,path:S,dest:`stage`,skip:[t.stageManifestFile]},{type:`dir`,path:C,dest:`overlay`}]}],F}async function buildFlatpakBundle(t){let{settings:n,workDir:S,archLabel:C}=t,N=$(S,`${n.appId}.json`),F=$(S,`build`),I=$(S,`repo`),H=$(S,`state`);mkdirSync(S,{recursive:!0}),rmSync(I,{recursive:!0,force:!0,maxRetries:5}),writeFileSync(N,`${JSON.stringify(renderShipFlatpakManifest(t),null,2)}\n`),await run$1(`flatpak-builder`,[`--force-clean`,`--disable-rofiles-fuse`,`--delete-build-dirs`,`--state-dir=${H}`,`--arch=${C}`,`--repo=${I}`,F,N],t,"flatpak-builder not found. Install it (Fedora: `sudo dnf install flatpak-builder`)."),await run$1(`flatpak`,[`build-bundle`,`--arch=${C}`,I,t.target,n.appId,n.flatpak.branch],t,`flatpak not found. Install it via your distro: see https://flathub.org/setup.`)}async function run$1(t,n,S,C){S.verbose&&ge.log(`[gjsify ship] ${t} ${n.join(` `)}`);let N=await spawnToCompletion(t,n,{completion:`return`,cwd:S.workDir,stdio:`inherit`,notFound:()=>Error(`gjsify ship: ${C}`)});if(N.code!==0)throw Error(`gjsify ship: ${t} failed with ${describeExit(N)}.`)}var yH=__esmMin(()=>{_e(),Bd(),In(),U_(),__name$1(run$1,`run`)});function localeOf(t){return t.split(`/`)[0]??``}function fold(t,n,S,C,N){let F=$(N,`source${S}`);return writeFileSync(F,n),readFileSync(mergeCatalogues({mode:t,template:F,extension:S,catalogues:C,workDir:N}),`utf-8`)}function localizeMetadata(t,n){if(n.length===0)return t;let S=mkdtempSync($(tmpdir(),`gjsify-ship-l10n-`));try{let C=[...n].sort((t,n)=>t.rel<n.rel?-1:+(t.rel>n.rel)),N=new Map;for(let[t,n]of C.entries()){let C=$(S,`${t}.po`);execFileSync(`msgunfmt`,[n.abs,`--output-file`,C],{stdio:`pipe`});let F=localeOf(n.rel);N.set(F,[...N.get(F)??[],C])}let F=[...N].map(([t,n])=>({locale:t,po:n.length===1?n[0]:msgcat(n,$(S,`${t}.merged.po`))}));return{metainfo:fold(`--xml`,t.metainfo,`.metainfo.xml`,F,S),desktopEntry:t.desktopEntry===void 0?void 0:fold(`--desktop`,t.desktopEntry,`.desktop`,F,S)}}catch(t){throw Error(describeFailure(t,n.length))}finally{rmSync(S,{recursive:!0,force:!0})}}function msgcat(t,n){return execFileSync(`msgcat`,[`--use-first`,`--output-file`,n,...t],{stdio:`pipe`}),n}function describeFailure(t,n){let S=t;return S?.code===`ENOENT`?`gjsify ship: \`msgfmt\`/\`msgunfmt\`/\`msgcat\` are not on PATH, but the package stages ${n} 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.${S?.stderr===void 0?``:`\n${String(S.stderr).trim()}`}`}var bH=__esmMin(()=>{I_(),Bd(),zg(),In(),mz()});function lookupArch(t,n,S){let C=t[n];if(!C)throw Error(`gjsify ship: no ${S} architecture is known for \`process.arch\` "${n}". Known: ${Object.keys(t).join(`, `)}.`);return C}function debArch(t,n){return n?`all`:lookupArch(xH,t,`Debian`)}function rpmArch(t,n){return n?`noarch`:lookupArch(SH,t,`RPM`)}function flatpakArch(t,n){return lookupArch(CH,t,`Flatpak`)}function appImageArch(t,n){return lookupArch(wH,t,`AppImage`)}function macosArch(t,n){return lookupArch(TH,t,`macOS`)}function windowsArch(t,n){return lookupArch(EH,t,`Windows`)}function windowsNameIsUnusable(t){return DH.test(t)||OH.test(t)||/[. ]$/.test(t)?!0:[...t].some(t=>(t.codePointAt(0)??0)<32)}function windowsProgramDirName(t){let n=t.name;if(n.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(n))throw Error(`gjsify ship: the windows layout would put this app in a directory called "${n}", 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.
|
|
1153
1153
|
The artifact would assemble here and be unextractable — or extract under a different name than
|
|
1154
|
-
the launcher resolves against. Set \`gjsify.ship.name\` to the display name you want on disk.`);return n}function requiredToolsOn(t,n){return Array.isArray(t)?t:t[n]??[]}function defaultFormatIds(t){return NH.filter(n=>MH[n].layoutOs===t&&MH[n].host.finishOn===`any`)}function formatIdsFor(t){return NH.filter(n=>MH[n].layoutOs===t)}function assertHostCanFinish(t,n=process.platform){let{finishOn:S}=t.host;if(!(S===`any`||S.includes(n)))throw Error(`gjsify ship: a ${t.id} artifact is packed on ${S.join(` or `)} and this host is ${n} (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 ${S.join(`/`)} runner, and finish with \`gjsify ship --from-stage <dir> --target ${t.id}\`.`)}function assertToolsInstalled(t,n=isOnPath,S=process.platform){let C=requiredToolsOn(t.host.requiredTools,S),N=C.filter(t=>!n(t));if(N.length===0)return;let F=t.host.installHint;throw Error(`gjsify ship: packing a ${t.id} on ${S} needs ${C.join(` and `)}, and ${N.join(`, `)} ${N.length>1?`are`:`is`} not on PATH. ${F===void 0?`Install it`:`Install it (${F})`}, or drop this target — the other formats need no tools at all. \`gjsify ship --stage\` also works without ${N.join(`/`)}: the payload is assembled by this CLI and only the container needs them.`)}function parseFormatNames(t,n){let S=t.flatMap(t=>t.split(`,`)).map(t=>t.trim()).filter(t=>t.length>0),C=S.filter(t=>!Object.hasOwn(MH,t));if(C.length>0)throw Error(`gjsify ship: unknown target${C.length>1?`s`:``} ${C.join(`, `)} in ${n}. Known targets: ${NH.join(`, `)}.`);let N=[...new Set(S)].sort();if(N.length===0)throw Error(`gjsify ship: ${n} named no format. Known targets: ${NH.join(`, `)}.`);return N}function resolveFormats(t,n){let S=parseFormatNames(t,`--target`),C=S.filter(t=>MH[t].layoutOs!==n.os);if(C.length>0){let t=formatIdsFor(n.os),S=[...new Set(C.map(t=>MH[t].layoutOs))];throw Error(`gjsify ship: ${C.join(`, `)} ${C.length>1?`wrap`:`wraps`} the ${S.join(`/`)} layout and this run assembles the ${n.name} one. `+(t.length===0?`No format wraps the ${n.name} layout — \`gjsify ship ${n.name} --stage\` assembles it and stops.`:`Formats for this layout: ${t.join(`, `)}.`)+` To build ${C.join(`, `)}, name the layout each wraps: ${S.map(t=>`\`gjsify ship ${PH[t]??t} --target ${C.filter(n=>MH[n].layoutOs===t).join(`,`)}\``).join(`, `)}.`)}return S.map(t=>MH[t])}function configuredFormats(t,n){let S=parseFormatNames(t,"`gjsify.ship.targets`");return{formats:S.filter(t=>MH[t].layoutOs===n.os).map(t=>MH[t]),dropped:S.filter(t=>MH[t].layoutOs!==n.os)}}function assertKindCanPack(t,n){if(n===`app`)return;let S=t.filter(t=>t.requiresDesktopEntry);if(S.length!==0)throw Error(`gjsify ship: ${S.map(t=>t.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(t){switch(t){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(t)}".`)}}var xH,SH,CH,wH,TH,EH,DH,OH,kH,AH,jH,SHARE_LICENSE_DEST,WRITTEN_HERE,MH,NH,PH,FH=__esmMin(()=>{bF(),hH(),vH(),_V(),SV(),xH={x64:`amd64`,arm64:`arm64`,ia32:`i386`,arm:`armhf`,riscv64:`riscv64`,ppc64:`ppc64el`,s390x:`s390x`},SH={x64:`x86_64`,arm64:`aarch64`,ia32:`i686`,arm:`armv7hl`,riscv64:`riscv64`,ppc64:`ppc64le`,s390x:`s390x`},CH={x64:`x86_64`,arm64:`aarch64`,ia32:`i386`,arm:`arm`},wH={x64:`x86_64`,arm64:`aarch64`,ia32:`i686`,arm:`armhf`},TH={x64:`x86_64`,arm64:`arm64`},EH={x64:`x64`},DH=/[<>:"/\\|?*]/,OH=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|$)/i,kH=`a distro package declares its interpreter as a dependency instead of carrying one, and every distribution ships both`,AH='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',jH="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=t=>`share/licenses/${t}/LICENSE`,WRITTEN_HERE=t=>({finishOn:`any`,requiredTools:[],oracle:{readWith:t,readOn:[`linux`],selfReading:!1}}),MH={deb:{id:`deb`,layoutOs:`linux`,prefix:`/usr`,host:WRITTEN_HERE([`ar`,`tar`,`dpkg-deb`,`lintian`]),depends:`deb`,interpreters:[`gjs`,`node`],interpreterGap:kH,licenseDest:t=>`share/doc/${t}/copyright`,licenseKind:`debian-copyright`,changelogDest:t=>`share/doc/${t}/changelog.Debian.gz`,archName:debArch,fileName:(t,n)=>`${t.binaryName}_${t.version}-${t.release}_${n}.deb`,artifactKind:`file`},rpm:{id:`rpm`,layoutOs:`linux`,prefix:`/usr`,host:WRITTEN_HERE([`rpm`,`rpm2cpio`,`cpio`]),depends:`rpm`,interpreters:[`gjs`,`node`],interpreterGap:kH,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:rpmArch,fileName:(t,n)=>`${t.binaryName}-${t.version}-${t.release}.${n}.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:(t,n)=>`${t.appId}-${t.version}-${t.release}.${n}.flatpak`,artifactKind:`file`},appimage:{id:`appimage`,layoutOs:`linux`,prefix:`/usr`,host:{finishOn:[`linux`],requiredTools:[sH,yV],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: ${bV}`,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:(t,n)=>`${t.binaryName}-${t.version}-${t.release}.${n}.AppImage`,artifactKind:`file`,requiresDesktopEntry:!0},"macos-app":{id:`macos-app`,layoutOs:`darwin`,prefix:``,host:{finishOn:`any`,requiredTools:[yV],installHint:bV,oracle:{readWith:[`python3`],readOn:[`linux`,`darwin`],selfReading:!1}},depends:null,interpreters:[`node`],interpreterGap:AH,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:macosArch,fileName:t=>`${t.name}.app`,artifactKind:`directory`},"macos-app-zip":{id:`macos-app-zip`,layoutOs:`darwin`,prefix:``,host:{finishOn:`any`,requiredTools:[yV],installHint:bV,oracle:{readWith:[`zipinfo`],readOn:[`linux`,`darwin`],selfReading:!1}},depends:null,interpreters:[`node`],interpreterGap:AH,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:macosArch,fileName:(t,n)=>`${t.binaryName}-${t.version}-${t.release}.macos.${n}.zip`,artifactKind:`file`},"macos-app-dmg":{id:`macos-app-dmg`,layoutOs:`darwin`,prefix:``,host:{finishOn:[`darwin`],requiredTools:[gH],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:AH,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:macosArch,fileName:(t,n)=>`${t.binaryName}-${t.version}-${t.release}.${n}.dmg`,artifactKind:`file`},"windows-dir":{id:`windows-dir`,layoutOs:`win32`,prefix:``,host:{finishOn:`any`,requiredTools:[yV],installHint:bV,oracle:{readWith:[`cmd`,`python3`],readOn:[`linux`,`win32`],selfReading:!1}},depends:null,interpreters:[`node`],interpreterGap:jH,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:windowsArch,fileName:t=>windowsProgramDirName(t),artifactKind:`directory`},"windows-dir-zip":{id:`windows-dir-zip`,layoutOs:`win32`,prefix:``,host:{finishOn:`any`,requiredTools:[yV],installHint:bV,oracle:{readWith:[`zipinfo`],readOn:[`linux`,`darwin`],selfReading:!1}},depends:null,interpreters:[`node`],interpreterGap:jH,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:windowsArch,fileName:(t,n)=>`${t.binaryName}-${t.version}-${t.release}.windows.${n}.zip`,artifactKind:`file`},msi:{id:`msi`,layoutOs:`win32`,prefix:``,host:{finishOn:[`linux`,`win32`],requiredTools:{linux:[yV,`wixl`],win32:[yV,`candle.exe`,`light.exe`]},installHint:`${bV}; 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:jH,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:windowsArch,fileName:(t,n)=>`${t.binaryName}-${t.version}-${t.release}.${n}.msi`,artifactKind:`file`}},NH=Object.keys(MH),PH=Object.fromEntries(hV.map(t=>[mV[t].os,t]))});function uuid5(t,n){let S=t.replace(/-/g,``),C=new Uint8Array(16);for(let t=0;t<16;t+=1)C[t]=Number.parseInt(S.slice(t*2,t*2+2),16);let N=createHash(`sha1`).update(C).update(new TextEncoder().encode(n)).digest(),F=Uint8Array.from(N.subarray(0,16));F[6]=(F[6]??0)&15|80,F[8]=(F[8]??0)&63|128;let I=[...F].map(t=>t.toString(16).padStart(2,`0`)).join(``);return[I.slice(0,8),I.slice(8,12),I.slice(12,16),I.slice(16,20),I.slice(20)].join(`-`)}function msiUpgradeCode(t){return uuid5(IH,`upgrade\n${t.appId}`).toUpperCase()}function msiProductCode(t,n){let S=`product\n${t.appId}\n${t.version}\n${t.release}\n${n}`;return uuid5(IH,S).toUpperCase()}function msiComponentGuid(t,n){return uuid5(IH,`component\n${t.appId}\n${n}`).toUpperCase()}function msiProductVersion(t){let n=/^(\d+)\.(\d+)(?:\.(\d+))?$/.exec(t);if(n===null)throw Error(`gjsify ship: "${t}" 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.
|
|
1154
|
+
the launcher resolves against. Set \`gjsify.ship.name\` to the display name you want on disk.`);return n}function requiredToolsOn(t,n){return Array.isArray(t)?t:t[n]??[]}function defaultFormatIds(t){return NH.filter(n=>MH[n].layoutOs===t&&MH[n].host.finishOn===`any`)}function formatIdsFor(t){return NH.filter(n=>MH[n].layoutOs===t)}function assertHostCanFinish(t,n=process.platform){let{finishOn:S}=t.host;if(!(S===`any`||S.includes(n)))throw Error(`gjsify ship: a ${t.id} artifact is packed on ${S.join(` or `)} and this host is ${n} (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 ${S.join(`/`)} runner, and finish with \`gjsify ship --from-stage <dir> --target ${t.id}\`.`)}function assertToolsInstalled(t,n=isOnPath,S=process.platform){let C=requiredToolsOn(t.host.requiredTools,S),N=C.filter(t=>!n(t));if(N.length===0)return;let F=t.host.installHint;throw Error(`gjsify ship: packing a ${t.id} on ${S} needs ${C.join(` and `)}, and ${N.join(`, `)} ${N.length>1?`are`:`is`} not on PATH. ${F===void 0?`Install it`:`Install it (${F})`}, or drop this target — the other formats need no tools at all. \`gjsify ship --stage\` also works without ${N.join(`/`)}: the payload is assembled by this CLI and only the container needs them.`)}function parseFormatNames(t,n){let S=t.flatMap(t=>t.split(`,`)).map(t=>t.trim()).filter(t=>t.length>0),C=S.filter(t=>!Object.hasOwn(MH,t));if(C.length>0)throw Error(`gjsify ship: unknown target${C.length>1?`s`:``} ${C.join(`, `)} in ${n}. Known targets: ${NH.join(`, `)}.`);let N=[...new Set(S)].sort();if(N.length===0)throw Error(`gjsify ship: ${n} named no format. Known targets: ${NH.join(`, `)}.`);return N}function resolveFormats(t,n){let S=parseFormatNames(t,`--target`),C=S.filter(t=>MH[t].layoutOs!==n.os);if(C.length>0){let t=formatIdsFor(n.os),S=[...new Set(C.map(t=>MH[t].layoutOs))];throw Error(`gjsify ship: ${C.join(`, `)} ${C.length>1?`wrap`:`wraps`} the ${S.join(`/`)} layout and this run assembles the ${n.name} one. `+(t.length===0?`No format wraps the ${n.name} layout — \`gjsify ship ${n.name} --stage\` assembles it and stops.`:`Formats for this layout: ${t.join(`, `)}.`)+` To build ${C.join(`, `)}, name the layout each wraps: ${S.map(t=>`\`gjsify ship ${PH[t]??t} --target ${C.filter(n=>MH[n].layoutOs===t).join(`,`)}\``).join(`, `)}.`)}return S.map(t=>MH[t])}function configuredFormats(t,n){let S=parseFormatNames(t,"`gjsify.ship.targets`");return{formats:S.filter(t=>MH[t].layoutOs===n.os).map(t=>MH[t]),dropped:S.filter(t=>MH[t].layoutOs!==n.os)}}function assertKindCanPack(t,n){if(n===`app`)return;let S=t.filter(t=>t.requiresDesktopEntry);if(S.length!==0)throw Error(`gjsify ship: ${S.map(t=>t.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(t){switch(t){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(t)}".`)}}var xH,SH,CH,wH,TH,EH,DH,OH,kH,AH,jH,SHARE_LICENSE_DEST,WRITTEN_HERE,MH,NH,PH,FH=__esmMin(()=>{bF(),hH(),vH(),_V(),SV(),xH={x64:`amd64`,arm64:`arm64`,ia32:`i386`,arm:`armhf`,riscv64:`riscv64`,ppc64:`ppc64el`,s390x:`s390x`},SH={x64:`x86_64`,arm64:`aarch64`,ia32:`i686`,arm:`armv7hl`,riscv64:`riscv64`,ppc64:`ppc64le`,s390x:`s390x`},CH={x64:`x86_64`,arm64:`aarch64`,ia32:`i386`,arm:`arm`},wH={x64:`x86_64`,arm64:`aarch64`,ia32:`i686`,arm:`armhf`},TH={x64:`x86_64`,arm64:`arm64`},EH={x64:`x64`,arm64:`arm64`},DH=/[<>:"/\\|?*]/,OH=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|$)/i,kH=`a distro package declares its interpreter as a dependency instead of carrying one, and every distribution ships both`,AH='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',jH="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=t=>`share/licenses/${t}/LICENSE`,WRITTEN_HERE=t=>({finishOn:`any`,requiredTools:[],oracle:{readWith:t,readOn:[`linux`],selfReading:!1}}),MH={deb:{id:`deb`,layoutOs:`linux`,prefix:`/usr`,host:WRITTEN_HERE([`ar`,`tar`,`dpkg-deb`,`lintian`]),depends:`deb`,interpreters:[`gjs`,`node`],interpreterGap:kH,licenseDest:t=>`share/doc/${t}/copyright`,licenseKind:`debian-copyright`,changelogDest:t=>`share/doc/${t}/changelog.Debian.gz`,archName:debArch,fileName:(t,n)=>`${t.binaryName}_${t.version}-${t.release}_${n}.deb`,artifactKind:`file`},rpm:{id:`rpm`,layoutOs:`linux`,prefix:`/usr`,host:WRITTEN_HERE([`rpm`,`rpm2cpio`,`cpio`]),depends:`rpm`,interpreters:[`gjs`,`node`],interpreterGap:kH,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:rpmArch,fileName:(t,n)=>`${t.binaryName}-${t.version}-${t.release}.${n}.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:(t,n)=>`${t.appId}-${t.version}-${t.release}.${n}.flatpak`,artifactKind:`file`},appimage:{id:`appimage`,layoutOs:`linux`,prefix:`/usr`,host:{finishOn:[`linux`],requiredTools:[sH,yV],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: ${bV}`,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:(t,n)=>`${t.binaryName}-${t.version}-${t.release}.${n}.AppImage`,artifactKind:`file`,requiresDesktopEntry:!0},"macos-app":{id:`macos-app`,layoutOs:`darwin`,prefix:``,host:{finishOn:`any`,requiredTools:[yV],installHint:bV,oracle:{readWith:[`python3`],readOn:[`linux`,`darwin`],selfReading:!1}},depends:null,interpreters:[`node`],interpreterGap:AH,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:macosArch,fileName:t=>`${t.name}.app`,artifactKind:`directory`},"macos-app-zip":{id:`macos-app-zip`,layoutOs:`darwin`,prefix:``,host:{finishOn:`any`,requiredTools:[yV],installHint:bV,oracle:{readWith:[`zipinfo`],readOn:[`linux`,`darwin`],selfReading:!1}},depends:null,interpreters:[`node`],interpreterGap:AH,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:macosArch,fileName:(t,n)=>`${t.binaryName}-${t.version}-${t.release}.macos.${n}.zip`,artifactKind:`file`},"macos-app-dmg":{id:`macos-app-dmg`,layoutOs:`darwin`,prefix:``,host:{finishOn:[`darwin`],requiredTools:[gH],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:AH,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:macosArch,fileName:(t,n)=>`${t.binaryName}-${t.version}-${t.release}.${n}.dmg`,artifactKind:`file`},"windows-dir":{id:`windows-dir`,layoutOs:`win32`,prefix:``,host:{finishOn:`any`,requiredTools:[yV],installHint:bV,oracle:{readWith:[`cmd`,`python3`],readOn:[`linux`,`win32`],selfReading:!1}},depends:null,interpreters:[`node`],interpreterGap:jH,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:windowsArch,fileName:t=>windowsProgramDirName(t),artifactKind:`directory`},"windows-dir-zip":{id:`windows-dir-zip`,layoutOs:`win32`,prefix:``,host:{finishOn:`any`,requiredTools:[yV],installHint:bV,oracle:{readWith:[`zipinfo`],readOn:[`linux`,`darwin`],selfReading:!1}},depends:null,interpreters:[`node`],interpreterGap:jH,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:windowsArch,fileName:(t,n)=>`${t.binaryName}-${t.version}-${t.release}.windows.${n}.zip`,artifactKind:`file`},msi:{id:`msi`,layoutOs:`win32`,prefix:``,host:{finishOn:[`linux`,`win32`],requiredTools:{linux:[yV,`wixl`],win32:[yV,`candle.exe`,`light.exe`]},installHint:`${bV}; 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:jH,licenseDest:SHARE_LICENSE_DEST,licenseKind:`plain`,archName:windowsArch,fileName:(t,n)=>`${t.binaryName}-${t.version}-${t.release}.${n}.msi`,artifactKind:`file`}},NH=Object.keys(MH),PH=Object.fromEntries(hV.map(t=>[mV[t].os,t]))});function uuid5(t,n){let S=t.replace(/-/g,``),C=new Uint8Array(16);for(let t=0;t<16;t+=1)C[t]=Number.parseInt(S.slice(t*2,t*2+2),16);let N=createHash(`sha1`).update(C).update(new TextEncoder().encode(n)).digest(),F=Uint8Array.from(N.subarray(0,16));F[6]=(F[6]??0)&15|80,F[8]=(F[8]??0)&63|128;let I=[...F].map(t=>t.toString(16).padStart(2,`0`)).join(``);return[I.slice(0,8),I.slice(8,12),I.slice(12,16),I.slice(16,20),I.slice(20)].join(`-`)}function msiUpgradeCode(t){return uuid5(IH,`upgrade\n${t.appId}`).toUpperCase()}function msiProductCode(t,n){let S=`product\n${t.appId}\n${t.version}\n${t.release}\n${n}`;return uuid5(IH,S).toUpperCase()}function msiComponentGuid(t,n){return uuid5(IH,`component\n${t.appId}\n${n}`).toUpperCase()}function msiProductVersion(t){let n=/^(\d+)\.(\d+)(?:\.(\d+))?$/.exec(t);if(n===null)throw Error(`gjsify ship: "${t}" 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.
|
|
1155
1155
|
Dropping the suffix is not an option this command will take silently: \`1.2.0~rc.1\` and \`1.2.0\` would
|
|
1156
1156
|
become the same version, \`MajorUpgrade\` could not tell them apart, and installing one over the other
|
|
1157
1157
|
would leave both on the machine. Set \`gjsify.ship.version\` to a plain \`x.y.z\`, or drop \`msi\` from the targets.`);let[S,C,N]=[Number(n[1]),Number(n[2]),Number(n[3]??`0`)];if(S>255||C>255||N>65535)throw Error(`gjsify ship: version "${t}" 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
|
|
1158
1158
|
TRUNCATED, so the artifact would carry a version that is not the one it was built from. Set \`gjsify.ship.version\`.`);return`${S}.${C}.${N}`}function msiIdentifier(t,n,S=``){let C=createHash(`sha1`).update(new TextEncoder().encode(n)).digest(`hex`).slice(0,12),N=n.replace(/[^A-Za-z0-9_.]/g,`_`),F=72-t.length-2-C.length-S.length;return`${t}_${N.length>F?N.slice(N.length-F):N}_${C}${S}`}function assertNameIsAddressable(t,n){if(t===`.`||t===`..`||t.length===0||LH.test(t))throw Error(`gjsify ship: the payload holds "${n}", and Windows Installer cannot address the path segment "${t}". A \`FileName\` or \`DefaultDir\` cell reserves < > : " / \\ | ? * and ; (its own list separator), and
|
|
1159
|
-
\`.\` and \`..\` are not names. The \`.msi\` would build and install the file somewhere else, or not at all.`);if(t.length>255)throw Error(`gjsify ship: the payload holds "${n}", whose segment "${t.slice(0,40)}…" is ${t.length} characters. Windows Installer's \`FileName\` column is 255.`)}function directoryTree(t){let n={path:``,name:``,children:new Map,files:[]};for(let S of[...t].sort((t,n)=>t.path<n.path?-1:+(t.path>n.path))){let t=S.path.split(`/`),C=t.pop();if(C===void 0)throw Error(`gjsify ship: the payload holds an empty path.`);let N=n;for(let n of t){assertNameIsAddressable(n,S.path);let t=N.children.get(n)??{path:N.path===``?n:`${N.path}/${n}`,name:n,children:new Map,files:[]};N.children.set(n,t),N=t}assertNameIsAddressable(C,S.path),N.files.push(S)}return n}function renderWxs(t){let{settings:n,programDirName:S,archLabel:C}=t,N=msiProductVersion(n.version),
|
|
1160
|
-
cannot start. \`windows-dir\` puts the launcher there; a payload without one is a stage assembled for another layout.`);let
|
|
1161
|
-
`)}function msiBackendFor(t){if(t===`linux`)return`wixl`;if(t===`win32`)return`wix3`;throw Error(`gjsify ship: no MSI compiler is wired for ${t}. \`wixl\` (msitools) is used on linux and WiX v3 on win32; assembly is not host-bound, so \`gjsify ship windows --stage\` here and \`gjsify ship --from-stage <dir> --target msi\` there is the way across.`)}async function buildMsi(t){let n=msiBackendFor(t.host??process.platform);mkdirSync(t.workDir,{recursive:!0});let S=$(t.workDir,`${t.settings.binaryName}.wxs`);if(writeFileSync(S,renderWxs(t)),n===`wixl`)return await run(`wixl`,[`-a`,t.archLabel,`-o`,t.target,S],t),S;let C=$(t.workDir,`obj`);return rmSync(C,{recursive:!0,force:!0,maxRetries:5}),mkdirSync(C,{recursive:!0}),await run(`candle.exe`,[`-nologo`,`-arch`,t.archLabel,`-out`,`${C}\\`,S],t),await run(`light.exe`,[`-nologo`,`-out`,t.target,$(C,`${t.settings.binaryName}.wixobj`)],t),S}async function run(t,n,S){S.verbose&&ge.log(`[gjsify ship] ${t} ${n.join(` `)}`);let C=await spawnToCompletion(t,[...n],{completion:`return`,cwd:S.workDir,stdio:`inherit`,notFound:()=>Error(`gjsify ship: ${t} not found. It is the MSI compiler for this host — Fedora: \`sudo dnf install msitools\`, Debian/Ubuntu: \`sudo apt install msitools\`, Windows: WiX Toolset v3.14 with its \`bin\` directory on PATH.`)});if(C.code!==0)throw Error(`gjsify ship: ${t} failed with ${describeExit(C)}.`)}var IH,LH,RH,zH=__esmMin(()=>{_e(),el(),Bd(),In(),U_(),_V(),PV(),IH=`7b3a1f6e-0c4d-4a2b-9e51-3d8c6f2a0b14`,LH=/[<>:"/\\|?*;]/,RH=`root`});function getCrcTable(){if(KH!==null)return KH;let t=new Uint32Array(256);for(let n=0;n<256;n++){let S=n;for(let t=0;t<8;t++)S=S&1?3988292384^S>>>1:S>>>1;t[n]=S>>>0}return KH=t,t}function crc32(t){let n=getCrcTable(),S=4294967295;for(let C=0;C<t.length;C++)S=n[(S^t[C])&255]^S>>>8;return(S^4294967295)>>>0}function dosDateTime(t){let n=new Date(Math.max(t,315532800)*1e3);return{date:(n.getUTCFullYear()-1980&127)<<9|n.getUTCMonth()+1<<5|n.getUTCDate(),time:n.getUTCHours()<<11|n.getUTCMinutes()<<5|Math.floor(n.getUTCSeconds()/2)}}function buildZip(t,n){let S=[...t].sort((t,n)=>t.path<n.path?-1:+(t.path>n.path)),{date:C,time:N}=dosDateTime(n),F=new TextEncoder;if(S.length>65535)throw Error(`gjsify ship: this archive would hold ${S.length} entries and a non-ZIP64 central directory records the count in 16 bits, so it would silently wrap. Nothing here writes ZIP64 yet; the payload has to shrink, or this writer has to grow the ZIP64 records.`);let I=new Writer,H=new Writer,W=0;for(let t of S){let n=F.encode(t.path),S=crc32(t.data),q=t.data.byteLength,Y=I.offset;if(Y>4294967295||q>4294967295)throw Error(`gjsify ship: ${t.path} would push this archive past 4 GiB, which a non-ZIP64 header records in 32 bits and therefore truncates. Nothing here writes ZIP64 yet.`);I.u32(BH),I.u16(GH),I.u16(2048),I.u16(UH),I.u16(N),I.u16(C),I.u32(S),I.u32(q),I.u32(q),I.u16(n.byteLength),I.u16(0),I.bytes(n),I.bytes(t.data),H.u32(VH),H.u16(WH),H.u16(GH),H.u16(2048),H.u16(UH),H.u16(N),H.u16(C),H.u32(S),H.u32(q),H.u32(q),H.u16(n.byteLength),H.u16(0),H.u16(0),H.u16(0),H.u16(0),H.u32(((32768|t.mode&4095)>>>0)*65536),H.u32(Y),H.bytes(n),W+=1}let q=H.finish(),Y=new Writer;Y.bytes(I.finish());let X=Y.offset;return Y.bytes(q),Y.u32(HH),Y.u16(0),Y.u16(0),Y.u16(W),Y.u16(W),Y.u32(q.byteLength),Y.u32(X),Y.u16(0),Y.finish()}function zipEntriesFromPayload(t,n=``){let S=n===``?``:`${n}/`;return t.map(t=>({path:`${S}${t.path}`,mode:t.mode,data:t.data}))}var BH,VH,HH,UH,WH,GH,KH,Writer,qH=__esmMin(()=>{BH=67324752,VH=33639248,HH=101010256,UH=0,WH=788,GH=20,KH=null,Writer=class{parts=[];length=0;get offset(){return this.length}u16(t){this.push(new Uint8Array([t&255,t>>>8&255]))}u32(t){this.push(new Uint8Array([t&255,t>>>8&255,t>>>16&255,t>>>24&255]))}bytes(t){this.push(t)}push(t){this.parts.push(t),this.length+=t.byteLength}finish(){let t=new Uint8Array(this.length),n=0;for(let S of this.parts)t.set(S,n),n+=S.byteLength;return t}}});function entryEvidence(t){let n=new Set,S=new Set;return walkModuleAst(t,t=>{let C=importedSpecifier(t);C!==null&&(C.startsWith(`gi://`)||JH.has(C)?n.add(C):C.startsWith(`node:`)&&S.add(C))}),{gi:[...n].sort(),node:[...S].sort()}}function assertEntryRunsUnder(t){let n=entryEvidence(t.source),S=t.interpreter===`node`?n.gi:n.node;if(S.length===0)return;let C=t.interpreter===`node`?`gjs`:`node`,N=t.interpreter===`gjs`?`GJS's loader refuses it: ImportError, "Unsupported URI scheme for importing: node"`:S.some(t=>t.startsWith(`gi://`))?`node's ESM loader refuses it: ERR_UNSUPPORTED_ESM_URL_SCHEME, "Only URLs with a scheme in: file, data, and node are supported by the default ESM loader"`:`node's ESM loader refuses it: ERR_MODULE_NOT_FOUND — a GJS built-in is not a package`,F=S.slice(0,3).join(`, `),I=S.length>3?`, and ${S.length-3} more`:``;throw Error(`gjsify ship: this target execs \`${t.interpreter}\` (\`${t.appKey}\`), and the entry it would ship — ${t.entry} (\`${t.bundleKey}\`) — imports ${F}${I}.\n ${N}, before a line of application code runs.\n The artifact would be built, reported as built, and fail at launch on every machine.
|
|
1159
|
+
\`.\` and \`..\` are not names. The \`.msi\` would build and install the file somewhere else, or not at all.`);if(t.length>255)throw Error(`gjsify ship: the payload holds "${n}", whose segment "${t.slice(0,40)}…" is ${t.length} characters. Windows Installer's \`FileName\` column is 255.`)}function directoryTree(t){let n={path:``,name:``,children:new Map,files:[]};for(let S of[...t].sort((t,n)=>t.path<n.path?-1:+(t.path>n.path))){let t=S.path.split(`/`),C=t.pop();if(C===void 0)throw Error(`gjsify ship: the payload holds an empty path.`);let N=n;for(let n of t){assertNameIsAddressable(n,S.path);let t=N.children.get(n)??{path:N.path===``?n:`${N.path}/${n}`,name:n,children:new Map,files:[]};N.children.set(n,t),N=t}assertNameIsAddressable(C,S.path),N.files.push(S)}return n}function renderWxs(t){let{settings:n,programDirName:S,archLabel:C}=t,N=C!==`x86`,F=msiProductVersion(n.version),I=n.maintainer.replace(/\s*<[^>]*>\s*$/,``).trim()||n.maintainer,H=windowsGuiLauncherPath(n),W=new Map,claim=(t,n)=>{let S=W.get(t);if(S!==void 0)throw Error(`gjsify ship: the MSI identifier "${t}" would be shared by ${S} and ${n}. Two rows cannot carry one id — one would silently replace the other.`);return W.set(t,n),t},q=claim(msiIdentifier(`i`,H,`.exe`),`the launcher icon`),Y=[],X=[],Z=!1,te,emitDir=(t,S)=>{for(let C of t.files){let t=claim(msiIdentifier(`c`,C.path),C.path),F=claim(msiIdentifier(`f`,C.path),C.path);X.push(t);let I=msiComponentGuid(n,C.path),W=xmlEscape(hn.basename(C.path));Y.push(`${S}<Component Id="${t}" Guid="${I}" Win64="${N?`yes`:`no`}">`),C.path===H?(Z=!0,te=C.source,Y.push(`${S} <File Id="${F}" Name="${W}" Source="${xmlEscape(C.source)}" KeyPath="yes">`),Y.push(`${S} <Shortcut Id="${claim(`s_startmenu`,`the Start-Menu shortcut`)}" Directory="ProgramMenuFolder" Name="${xmlEscape(n.name)}" WorkingDirectory="INSTALLDIR" Description="${xmlEscape(n.summary)}" Icon="${q}" IconIndex="0" Advertise="yes" />`),Y.push(`${S} </File>`)):Y.push(`${S} <File Id="${F}" Name="${W}" Source="${xmlEscape(C.source)}" KeyPath="yes" />`),Y.push(`${S}</Component>`)}for(let n of[...t.children.values()].sort((t,n)=>t.name<n.name?-1:1)){let t=claim(msiIdentifier(`d`,n.path),`the directory ${n.path}`);Y.push(`${S}<Directory Id="${t}" Name="${xmlEscape(n.name)}">`),emitDir(n,`${S} `),Y.push(`${S}</Directory>`)}};if(emitDir(directoryTree(t.files),` `),X.length===0)throw Error("gjsify ship: the windows payload is empty, so there is nothing for an `.msi` to install.");if(!Z||te===void 0)throw Error(`gjsify ship: the windows payload carries no "${H}" at the root of the program directory, so the installer would have nothing to point a Start-Menu shortcut at — an application a user installs and
|
|
1160
|
+
cannot start. \`windows-dir\` puts the launcher there; a payload without one is a stage assembled for another layout.`);let ne=n.homepage===void 0?[]:[` <Property Id="ARPURLINFOABOUT" Value="${xmlEscape(n.homepage)}" />`];return[`<?xml version="1.0" encoding="utf-8"?>`,"<!-- Generated by `gjsify ship` (ADR 0024 stage 5). Do not edit; edit utils/ship/msi.ts. -->",`<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">`,` <Product Id="${msiProductCode(n,C)}" Name="${xmlEscape(n.name)}" Language="1033" Version="${F}" Manufacturer="${xmlEscape(I)}" UpgradeCode="${msiUpgradeCode(n)}">`,` <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Manufacturer="${xmlEscape(I)}" Description="${xmlEscape(n.summary)}" />`,` <MajorUpgrade DowngradeErrorMessage="A newer version of ${xmlEscape(n.name)} is already installed." />`,` <Media Id="1" Cabinet="app.cab" EmbedCab="yes" />`,` <Icon Id="${q}" SourceFile="${xmlEscape(te)}" />`,` <Property Id="ARPPRODUCTICON" Value="${q}" />`,...ne,` <Directory Id="TARGETDIR" Name="SourceDir">`,` <Directory Id="ProgramFiles64Folder">`,` <Directory Id="INSTALLDIR" Name="${xmlEscape(S)}">`,...Y,` </Directory>`,` </Directory>`,` <Directory Id="ProgramMenuFolder" />`,` </Directory>`,` <Feature Id="Main" Title="${xmlEscape(n.name)}" Level="1">`,...X.map(t=>` <ComponentRef Id="${t}" />`),` </Feature>`,` </Product>`,`</Wix>`,``].join(`
|
|
1161
|
+
`)}function msiBackendFor(t){if(t===`linux`)return`wixl`;if(t===`win32`)return`wix3`;throw Error(`gjsify ship: no MSI compiler is wired for ${t}. \`wixl\` (msitools) is used on linux and WiX v3 on win32; assembly is not host-bound, so \`gjsify ship windows --stage\` here and \`gjsify ship --from-stage <dir> --target msi\` there is the way across.`)}async function buildMsi(t){let n=msiBackendFor(t.host??process.platform);mkdirSync(t.workDir,{recursive:!0});let S=$(t.workDir,`${t.settings.binaryName}.wxs`);if(writeFileSync(S,renderWxs(t)),n===`wixl`)return await run(`wixl`,[`-a`,t.archLabel,`-o`,t.target,S],t),S;let C=$(t.workDir,`obj`);return rmSync(C,{recursive:!0,force:!0,maxRetries:5}),mkdirSync(C,{recursive:!0}),await run(`candle.exe`,[`-nologo`,`-arch`,t.archLabel,`-out`,`${C}\\`,S],t),await run(`light.exe`,[`-nologo`,`-out`,t.target,$(C,`${t.settings.binaryName}.wixobj`)],t),S}async function run(t,n,S){S.verbose&&ge.log(`[gjsify ship] ${t} ${n.join(` `)}`);let C=await spawnToCompletion(t,[...n],{completion:`return`,cwd:S.workDir,stdio:`inherit`,notFound:()=>Error(`gjsify ship: ${t} not found. It is the MSI compiler for this host — Fedora: \`sudo dnf install msitools\`, Debian/Ubuntu: \`sudo apt install msitools\`, Windows: WiX Toolset v3.14 with its \`bin\` directory on PATH.`)});if(C.code!==0)throw Error(`gjsify ship: ${t} failed with ${describeExit(C)}.`)}var IH,LH,RH,zH=__esmMin(()=>{_e(),el(),Bd(),In(),U_(),_V(),PV(),IH=`7b3a1f6e-0c4d-4a2b-9e51-3d8c6f2a0b14`,LH=/[<>:"/\\|?*;]/,RH=`root`});function getCrcTable(){if(KH!==null)return KH;let t=new Uint32Array(256);for(let n=0;n<256;n++){let S=n;for(let t=0;t<8;t++)S=S&1?3988292384^S>>>1:S>>>1;t[n]=S>>>0}return KH=t,t}function crc32(t){let n=getCrcTable(),S=4294967295;for(let C=0;C<t.length;C++)S=n[(S^t[C])&255]^S>>>8;return(S^4294967295)>>>0}function dosDateTime(t){let n=new Date(Math.max(t,315532800)*1e3);return{date:(n.getUTCFullYear()-1980&127)<<9|n.getUTCMonth()+1<<5|n.getUTCDate(),time:n.getUTCHours()<<11|n.getUTCMinutes()<<5|Math.floor(n.getUTCSeconds()/2)}}function buildZip(t,n){let S=[...t].sort((t,n)=>t.path<n.path?-1:+(t.path>n.path)),{date:C,time:N}=dosDateTime(n),F=new TextEncoder;if(S.length>65535)throw Error(`gjsify ship: this archive would hold ${S.length} entries and a non-ZIP64 central directory records the count in 16 bits, so it would silently wrap. Nothing here writes ZIP64 yet; the payload has to shrink, or this writer has to grow the ZIP64 records.`);let I=new Writer,H=new Writer,W=0;for(let t of S){let n=F.encode(t.path),S=crc32(t.data),q=t.data.byteLength,Y=I.offset;if(Y>4294967295||q>4294967295)throw Error(`gjsify ship: ${t.path} would push this archive past 4 GiB, which a non-ZIP64 header records in 32 bits and therefore truncates. Nothing here writes ZIP64 yet.`);I.u32(BH),I.u16(GH),I.u16(2048),I.u16(UH),I.u16(N),I.u16(C),I.u32(S),I.u32(q),I.u32(q),I.u16(n.byteLength),I.u16(0),I.bytes(n),I.bytes(t.data),H.u32(VH),H.u16(WH),H.u16(GH),H.u16(2048),H.u16(UH),H.u16(N),H.u16(C),H.u32(S),H.u32(q),H.u32(q),H.u16(n.byteLength),H.u16(0),H.u16(0),H.u16(0),H.u16(0),H.u32(((32768|t.mode&4095)>>>0)*65536),H.u32(Y),H.bytes(n),W+=1}let q=H.finish(),Y=new Writer;Y.bytes(I.finish());let X=Y.offset;return Y.bytes(q),Y.u32(HH),Y.u16(0),Y.u16(0),Y.u16(W),Y.u16(W),Y.u32(q.byteLength),Y.u32(X),Y.u16(0),Y.finish()}function zipEntriesFromPayload(t,n=``){let S=n===``?``:`${n}/`;return t.map(t=>({path:`${S}${t.path}`,mode:t.mode,data:t.data}))}var BH,VH,HH,UH,WH,GH,KH,Writer,qH=__esmMin(()=>{BH=67324752,VH=33639248,HH=101010256,UH=0,WH=788,GH=20,KH=null,Writer=class{parts=[];length=0;get offset(){return this.length}u16(t){this.push(new Uint8Array([t&255,t>>>8&255]))}u32(t){this.push(new Uint8Array([t&255,t>>>8&255,t>>>16&255,t>>>24&255]))}bytes(t){this.push(t)}push(t){this.parts.push(t),this.length+=t.byteLength}finish(){let t=new Uint8Array(this.length),n=0;for(let S of this.parts)t.set(S,n),n+=S.byteLength;return t}}});function entryEvidence(t){let n=new Set,S=new Set;return walkModuleAst(t,t=>{let C=importedSpecifier(t);C!==null&&(C.startsWith(`gi://`)||JH.has(C)?n.add(C):C.startsWith(`node:`)&&t.type!==`ImportExpression`&&S.add(C))}),{gi:[...n].sort(),node:[...S].sort()}}function assertEntryRunsUnder(t){let n=entryEvidence(t.source),S=t.interpreter===`node`?n.gi:n.node;if(S.length===0)return;let C=t.interpreter===`node`?`gjs`:`node`,N=t.interpreter===`gjs`?`GJS's loader refuses it: ImportError, "Unsupported URI scheme for importing: node"`:S.some(t=>t.startsWith(`gi://`))?`node's ESM loader refuses it: ERR_UNSUPPORTED_ESM_URL_SCHEME, "Only URLs with a scheme in: file, data, and node are supported by the default ESM loader"`:`node's ESM loader refuses it: ERR_MODULE_NOT_FOUND — a GJS built-in is not a package`,F=S.slice(0,3).join(`, `),I=S.length>3?`, and ${S.length-3} more`:``;throw Error(`gjsify ship: this target execs \`${t.interpreter}\` (\`${t.appKey}\`), and the entry it would ship — ${t.entry} (\`${t.bundleKey}\`) — imports ${F}${I}.\n ${N}, before a line of application code runs.\n The artifact would be built, reported as built, and fail at launch on every machine.
|
|
1162
1162
|
Either ship this target the \`--app ${t.interpreter}\` build of the app — \`gjsify.ship.bundle.${t.layoutOs}\` selects the entry per target, the way \`gjsify.ship.app.${t.layoutOs}\` selects the runtime —\n or set \`gjsify.ship.app.${t.layoutOs}\` to "${C}" if this bundle is the one that should ship.`)}var JH,YH=__esmMin(()=>{pI(),JH=new Set([`system`,`gettext`])});function base64Encode(t){let n=``,S=32768;for(let C=0;C<t.length;C+=S)n+=String.fromCharCode(...t.subarray(C,C+S));return btoa(n)}function base64Decode(t){let n=atob(t),S=new Uint8Array(n.length);for(let t=0;t<n.length;t++)S[t]=n.charCodeAt(t);return S}var XH=__esmMin(()=>{});function toPackSettings(t){return{binaryName:t.binaryName,appId:t.appId,name:t.name,version:t.version,release:t.release,maintainer:t.maintainer,summary:t.summary,description:t.description,license:t.license,...t.homepage===void 0?{}:{homepage:t.homepage},section:t.section,group:t.group,extraDepends:t.extraDepends,typelibPackages:t.typelibPackages,app:t.app,minGjsVersion:t.minGjsVersion,minNodeVersion:t.minNodeVersion,flatpak:t.flatpak}}function stageManifestPath(t){return $(t,ZH)}function formatTarget(t){return`${t.os}-${t.arch}`}function writeStageManifest(t){let n={};for(let S of t.formats)n[S.id]=(t.overlay.get(S.id)??[]).map(t=>{if(t.source.kind===`text`)return{path:t.path,mode:t.mode,text:t.source.text};if(t.source.kind===`bytes`)return{path:t.path,mode:t.mode,base64:base64Encode(t.source.data)};throw Error(`gjsify ship: internal error — the ${S.id} overlay entry ${t.path} is a file reference, and a stage manifest may only carry rendered bytes. Render it in \`planOverlay\` instead.`)});let S={schema:6,tool:{name:`@gjsify/cli`,version:cliVersion()},target:{os:t.settings.layoutOs,arch:t.settings.arch},formats:t.formats.map(t=>t.id),mtime:t.mtime,namespaces:[...t.namespaces],optionalNamespaces:[...t.optionalNamespaces??[]],settings:toPackSettings(t.settings),staged:t.staged.map(n=>({path:n.path,mode:n.mode,bytes:statSync($(t.stageDir,n.path.split(`/`).join(Nn))).size})),overlay:n};return writeFileSync(stageManifestPath(t.stageDir),`${JSON.stringify(S,null,2)}\n`),S}function readStageManifest(t){let n=stageManifestPath(t);if(!existsSync(n))throw Error(`gjsify ship: ${t} has no ${ZH}, so it is not a stage this command can pack. A stage is produced by \`gjsify ship --stage\`, which writes that file at the stage root beside the payload. If you pointed --from-stage at a project's \`ship/\` directory, point it at \`ship/stage/\` instead.`);let S;try{S=JSON.parse(readFileSync(n,`utf-8`))}catch(t){throw Error(`gjsify ship: ${n} is not readable JSON (${t.message}). Re-run the \`--stage\` phase; a truncated manifest means the stage transfer was truncated too.`)}if(typeof S!=`object`||!S||Array.isArray(S))throw Error(`gjsify ship: ${n} is not a JSON object. Re-run the \`--stage\` phase.`);let C=S,N=C.schema;if(typeof N!=`number`||!Number.isInteger(N))throw Error(`gjsify ship: ${n} has no integer \`schema\` field, so it was not written by \`gjsify ship --stage\`. Re-run the \`--stage\` phase.`);if(N>6)throw Error(`gjsify ship: ${n} declares schema ${N} and this gjsify understands 6. The stage was assembled by a newer gjsify: upgrade this one (\`gjsify self-update\`), or re-run the \`--stage\` phase with this version. A manifest from the future is refused rather than partially read, because an unknown field could be the one that decides a file's mode.`);if(N<6)throw Error(`gjsify ship: ${n} declares schema ${N} and this gjsify understands 6. Re-run the \`--stage\` phase with this gjsify. A stage is a short-lived intermediate between two jobs of one run, not an archive, so no migration is kept for it.`);let at=t=>`${n} → ${t}`,F=record(C.tool,at(`tool`)),I=record(C.target,at(`target`)),H={schema:N,tool:{name:expectString(F.name,at(`tool.name`)),version:expectString(F.version,at(`tool.version`))},target:{os:expectLayoutOs(expectString(I.os,at(`target.os`)),at(`target.os`)),arch:expectString(I.arch,at(`target.arch`))},formats:expectArray(C.formats,at(`formats`)).map((t,n)=>{let S=expectString(t,at(`formats[${n}]`));if(!NH.includes(S))throw Error(`gjsify ship: ${at(`formats[${n}]`)} is "${S}", which this gjsify does not know. Known formats: ${NH.join(`, `)}.`);return S}),mtime:expectInteger(C.mtime,at(`mtime`)),namespaces:expectArray(C.namespaces,at(`namespaces`)).map((t,n)=>expectString(t,at(`namespaces[${n}]`))),...C.optionalNamespaces===void 0?{}:{optionalNamespaces:expectArray(C.optionalNamespaces,at(`optionalNamespaces`)).map((t,n)=>expectString(t,at(`optionalNamespaces[${n}]`)))},settings:readPackSettings(record(C.settings,at(`settings`)),at(`settings`)),staged:expectArray(C.staged,at(`staged`)).map((t,n)=>{let S=record(t,at(`staged[${n}]`));return{path:expectString(S.path,at(`staged[${n}].path`)),mode:expectInteger(S.mode,at(`staged[${n}].mode`)),bytes:expectInteger(S.bytes,at(`staged[${n}].bytes`))}}),overlay:{}};if(H.staged.length===0)throw Error(`gjsify ship: ${at(`staged`)} is empty, so this stage describes no payload. A stage always carries at least the launcher its plan named. Re-run the \`--stage\` phase; a stage that lost its plan cannot be packed into anything but an empty package.`);let W=record(C.overlay,at(`overlay`));for(let t of H.formats)H.overlay[t]=expectArray(W[t],at(`overlay.${t}`)).map((n,S)=>{let C=record(n,at(`overlay.${t}[${S}]`)),N=at(`overlay.${t}[${S}]`);if(C.text===void 0==(C.base64===void 0))throw Error(`gjsify ship: ${N} must carry exactly one of \`text\` and \`base64\`. An overlay entry is either rendered text or rendered bytes; an entry with neither would pack an empty file at a path the format requires content at.`);return{path:expectString(C.path,at(`overlay.${t}[${S}].path`)),mode:expectInteger(C.mode,at(`overlay.${t}[${S}].mode`)),...C.text===void 0?{base64:expectString(C.base64,at(`overlay.${t}[${S}].base64`))}:{text:expectString(C.text,at(`overlay.${t}[${S}].text`))}}});return H}function expectLayoutOs(t,n){try{return layoutForOs(t).os}catch{let S=hV.map(t=>mV[t].os).join(`, `);throw Error(`gjsify ship: ${n} is "${t}", which is not a layout this gjsify can pack. It carries the \`process.platform\` spelling and only that — ${S}, so \`win32\` and never \`windows\`. A stage holds exactly one OS's layout and every path in it has that OS's shape, so there is nothing to pack here. Re-run the \`--stage\` phase.`)}}function overlayFiles(t,n){return(t.overlay[n]??[]).map(t=>({path:t.path,mode:t.mode,source:t.base64===void 0?{kind:`text`,text:t.text??``}:{kind:`bytes`,data:base64Decode(t.base64)}}))}function assertExpectedTarget(t,n){if(n===void 0)return;let S=formatTarget(t.target);if(n!==S)throw Error(`gjsify ship: --expect-target ${n} but this stage was assembled for ${S}. The stage records the target its \`--arch\` resolved to at stage time, so this is a stage from another matrix leg: download the artifact belonging to ${n}, or drop --expect-target if packing this one is what you meant.`)}function assertFormatsStaged(t,n){let S=n.filter(n=>!t.formats.includes(n.id)).map(t=>t.id);if(S.length!==0)throw Error(`gjsify ship: this stage was assembled for ${t.formats.length===0?`no format at all`:t.formats.join(`, `)}, and --target names ${S.join(`, `)}. Phase one renders each format's overlay — rpm wants the licence at \`share/licenses/<pkg>/LICENSE\`, deb wants a machine-readable copyright at \`share/doc/<pkg>/copyright\` — so a format the stage never saw would pack without it, and Debian Policy § 12.5 makes that a broken package. Re-run \`gjsify ship --stage --target ${[...t.formats,...S].join(`,`)}\` on the assembling host.`)}function resolveStageMtime(t,n=process.env){let S=n.SOURCE_DATE_EPOCH;return S===void 0||Number(S)===t.mtime?{mtime:t.mtime,warnings:[]}:{mtime:t.mtime,warnings:[`SOURCE_DATE_EPOCH is ${S} here and this stage was stamped ${t.mtime}. The stage's stamp wins, because changing it would make this artifact differ from the same stage packed on the assembling host. Set the same value in both jobs, or set it in neither.`]}}function warnOnToolSkew(t){let n=cliVersion();return t.tool.version===n?[]:[`this stage was assembled by ${t.tool.name} ${t.tool.version} and is being packed by ${n}. Both phases run the same packer, so a version difference can change the artifact's bytes. Pin both jobs to one gjsify version.`]}function readPackSettings(t,n){let field=t=>`${n}.${t}`,S=record(t.extraDepends,field(`extraDepends`)),C=record(t.typelibPackages,field(`typelibPackages`));return{binaryName:expectString(t.binaryName,field(`binaryName`)),appId:expectString(t.appId,field(`appId`)),name:expectString(t.name,field(`name`)),version:expectString(t.version,field(`version`)),release:expectString(t.release,field(`release`)),maintainer:expectString(t.maintainer,field(`maintainer`)),summary:expectString(t.summary,field(`summary`)),description:expectArray(t.description,field(`description`)).map((t,n)=>expectString(t,field(`description[${n}]`))),license:expectString(t.license,field(`license`)),...t.homepage===void 0?{}:{homepage:expectString(t.homepage,field(`homepage`))},section:expectString(t.section,field(`section`)),group:expectString(t.group,field(`group`)),extraDepends:{deb:expectArray(S.deb??[],field(`extraDepends.deb`)).map((t,n)=>expectString(t,field(`extraDepends.deb[${n}]`))),rpm:expectArray(S.rpm??[],field(`extraDepends.rpm`)).map((t,n)=>expectString(t,field(`extraDepends.rpm[${n}]`)))},typelibPackages:Object.fromEntries(Object.entries(C).map(([t,n])=>{let S=record(n,field(`typelibPackages.${t}`));return[t,{deb:expectString(S.deb,field(`typelibPackages.${t}.deb`)),rpm:expectString(S.rpm,field(`typelibPackages.${t}.rpm`))}]})),app:expectApp(t.app,field(`app`)),minGjsVersion:expectString(t.minGjsVersion,field(`minGjsVersion`)),minNodeVersion:expectString(t.minNodeVersion,field(`minNodeVersion`)),flatpak:readFlatpakSettings(record(t.flatpak,field(`flatpak`)),field(`flatpak`))}}function readFlatpakSettings(t,n){let field=t=>`${n}.${t}`,strings=(t,n)=>expectArray(t,field(n)).map((t,S)=>expectString(t,field(`${n}[${S}]`)));return{runtime:expectString(t.runtime,field(`runtime`)),runtimeVersion:expectString(t.runtimeVersion,field(`runtimeVersion`)),sdk:expectString(t.sdk,field(`sdk`)),branch:expectString(t.branch,field(`branch`)),sdkExtensions:strings(t.sdkExtensions,`sdkExtensions`),appendPath:strings(t.appendPath,`appendPath`),finishArgs:strings(t.finishArgs,`finishArgs`),cleanup:strings(t.cleanup,`cleanup`)}}function record(t,n){if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`gjsify ship: ${n} must be an object. Re-run the \`--stage\` phase.`);return t}function expectArray(t,n){if(!Array.isArray(t))throw Error(`gjsify ship: ${n} must be an array. Re-run the \`--stage\` phase.`);return t}function expectApp(t,n){if(t===`gjs`||t===`node`)return t;throw Error(`gjsify ship: ${n} must be "gjs" or "node", got ${JSON.stringify(t)}.`)}function expectString(t,n){if(typeof t!=`string`)throw Error(`gjsify ship: ${n} must be a string. Re-run the \`--stage\` phase.`);return t}function expectInteger(t,n){if(typeof t!=`number`||!Number.isInteger(t)||t<0)throw Error(`gjsify ship: ${n} must be a non-negative integer. Re-run the \`--stage\` phase. (Modes are decimal here — JSON has no octal literal, so 0o755 is written 493.)`);return t}var ZH,QH=__esmMin(()=>{Bd(),In(),XH(),ih(),FH(),_V(),ZH=`.gjsify-ship-stage.json`});function writeStage(t,n){for(let t of n)if(t.path===`.gjsify-ship-stage.json`)throw Error(`gjsify ship: a payload file may not be called \`${ZH}\` — that name belongs to the stage manifest, which sits at the stage root beside the payload and carries what the packing host needs (ADR 0024 § A2). Rename the \`gjsify.ship.extraFiles\` destination.`);rmSync(t,{recursive:!0,force:!0,maxRetries:5}),mkdirSync(t,{recursive:!0});for(let S of n){let n=$(t,S.path.split(`/`).join(Nn));mkdirSync(On(n),{recursive:!0});let C;switch(S.source.kind){case`text`:C=new TextEncoder().encode(S.source.text);break;case`file`:C=new Uint8Array(readFileSync(S.source.path));break;case`bytes`:C=S.source.data;break;default:{let t=S.source;throw Error(`gjsify ship: no writer for the "${JSON.stringify(t)}" source kind.`)}}writeFileSync(n,C),chmodSync(n,S.mode)}}function readStage(t,n){let S=new Map(n.map(t=>[t.path,t])),C=new Map;for(let n of t)for(let t of listFilesRecursive(n)){if(t===`.gjsify-ship-stage.json`)continue;let N=S.get(t);if(N===void 0)throw Error(`gjsify ship: ${$(n,t.split(`/`).join(Nn))} is in the stage and not in its manifest, so nothing knows what mode to give it. Every payload file takes its mode from the plan, never from the filesystem, so a file that arrived some other way would be packed 0644 — unrunnable if it is a program. Remove it, or add it through \`gjsify.ship.extraFiles\` and re-run the \`--stage\` phase.`);let F=new Uint8Array(readFileSync($(n,t.split(`/`).join(Nn))));if(N.bytes!==void 0&&N.bytes!==F.byteLength)throw Error(`gjsify ship: ${t} is ${F.byteLength} bytes in the stage and ${N.bytes} in its manifest. The stage arrived truncated or was edited after it was assembled. Re-upload it, or re-run the \`--stage\` phase.`);C.set(t,{path:t,mode:N.mode,data:F})}let N=n.filter(t=>!C.has(t.path)).map(t=>t.path);if(N.length>0)throw Error(`gjsify ship: the stage manifest lists ${N.length} file(s) the stage does not contain: ${N.slice(0,5).join(`, `)}${N.length>5?`, …`:``}. A payload has to be complete before it is packed — both formats would pack the rest without complaint and install a package that cannot start. Re-run the \`--stage\` phase, and check that whatever moved the stage between hosts copied every file (an artifact upload that drops empty files or dotfiles is the usual cause).`);return[...C.values()].sort((t,n)=>t.path<n.path?-1:+(t.path>n.path))}function writePayload(t,n,S){let C=S===``?``:`${S}/`;rmSync(t,{recursive:!0,force:!0,maxRetries:5}),mkdirSync(t,{recursive:!0});for(let N of n){if(!N.path.startsWith(C))throw Error(`gjsify ship: ${N.path} is outside ${S||`the artifact`}, which this artifact IS — so there is nowhere inside it for the file to go. A payload file that escaped the bundle would ship beside it, unsigned and unfound.`);let n=$(t,N.path.slice(C.length).split(`/`).join(Nn));mkdirSync(On(n),{recursive:!0}),writeFileSync(n,N.data),chmodSync(n,N.mode)}}function directorySize(t){let n=0;for(let S of listFilesRecursive(t))n+=statSync($(t,S.split(`/`).join(Nn))).size;return n}var $H=__esmMin(()=>{Bd(),In(),JV(),QH()});function resolveSignPlan(t){let n=eU[t.layoutOs];if(n===void 0){if(t.flag!==void 0)throw Error(`gjsify ship: --sign has nothing to sign in the ${t.layoutOs} layout. A .deb and an .rpm carry no per-file signature — the artifact is signed as a whole by the repository that serves it (\`debsigs\`, \`rpmsign\`), with that repository's key and not with a build-time identity. Drop --sign, or assemble the darwin or windows layout.`);return{kind:`unsupported`}}let S=t.config?.[t.layoutOs]?.identity,[C,N]=t.flag===void 0?[S,`config`]:[t.flag,`flag`];return C===void 0||C===``?{kind:`skip`,message:`${C===``?`an empty identity was ${N===`flag`?`passed to --sign`:`set in \`${n.configKey}\``}`:`no identity was given`} — skipping ${n.tool}. An unsigned artifact is the default path and a legitimate deliverable (ADR 0024 § A13). Pass \`--sign <identity>\` or set \`${n.configKey}\` to sign; \`--sign -\` signs ad-hoc and needs no developer identity.`}:{kind:`sign`,identity:C,signer:n,source:N}}function assertHostCanSign(t){let n=process.platform;if(!t.signOn.includes(n))throw Error(`gjsify ship: signing the ${t.layoutOs} layout needs ${t.tool}, which runs on ${t.signOn.join(`, `)} and this host is ${n}. Assembly is not host-bound — \`gjsify ship <os> --stage\` here, then \`gjsify ship --from-stage <dir> --sign <identity>\` on a host that has both the tool and the identity (ADR 0024 § A1, § A14).`);if(!isOnPath(t.tool))throw Error(`gjsify ship: --sign was given and \`${t.tool}\` is not on PATH, so nothing can make the signature — ${t.installHint}. Dropping --sign produces an unsigned artifact, which is a legitimate output (ADR 0024 § A13); silently producing one while --sign was asked for is not.`)}function partitionSignedFileSet(t){let n=new Set(t.planned),S=new Set(t.arrived),C=[...S].filter(t=>!n.has(t)).sort(),N=t.sealPrefix;return{sealed:N===void 0?[]:C.filter(t=>t.startsWith(N)),unexpected:N===void 0?C:C.filter(t=>!t.startsWith(N)),removed:[...n].filter(t=>!S.has(t)).sort()}}async function signPayload(t){let{payload:n,signer:S,workDir:C}=t;writePayload(C,n,``);let N=t.identity===`-`,F,I=S.entitlements(N);I.length>0&&(mkdirSync(On(t.entitlementsPath),{recursive:!0}),writeFileSync(t.entitlementsPath,renderEntitlements(I)),F=t.entitlementsPath);let run=async(n,I)=>{let H=S.args({identity:t.identity,file:n,adhoc:N,...F?{entitlements:F}:{}});t.verbose&&t.log(`${S.tool} ${H.join(` `)}`);let W=await spawnToCompletion(S.tool,H,{completion:`return`,cwd:C,stdio:`inherit`,notFound:()=>Error(`gjsify ship: \`${S.tool}\` is not on PATH — ${S.installHint}.`)});if(W.code!==0)throw Error(`gjsify ship: ${S.tool} failed on ${I} with ${describeExit(W)}. Nothing is packed from a payload whose signature failed: an artifact that is half signed installs and is refused at first launch, which is worse than not shipping.`)},H=n.filter(t=>classifyBinary(t.data)===S.signs);if(H.length===0&&!S.sealsBundle)return t.log(`nothing in this payload is a ${S.signs===`macho`?`Mach-O`:`PE`} image, so ${S.tool} signed 0 file(s). The artifact carries no signature.`),[...n];for(let t of H)await run($(C,t.path.split(`/`).join(Nn)),t.path);let W;if(S.sealsBundle){if(t.bundleRoot===``)throw Error(`gjsify ship: the ${S.layoutOs} signer seals a bundle and this layout has no root to seal. \`Layout.root\` is what names the artifact directory; a signer that sealed the whole stage would sign the payload of every other format beside it.`);W=S.sealAddPrefix(t.bundleRoot),await run($(C,t.bundleRoot.split(`/`).join(Nn)),`${t.bundleRoot} (bundle seal)`)}let q=partitionSignedFileSet({arrived:listFilesRecursive(C),planned:n.map(t=>t.path),...W===void 0?{}:{sealPrefix:W}});if(q.unexpected.length>0||q.removed.length>0)throw Error(`gjsify ship: ${S.tool} changed the payload's file set — ${q.unexpected.length} added (${q.unexpected.slice(0,3).join(`, `)||`—`}), ${q.removed.length} removed (${q.removed.slice(0,3).join(`, `)||`—`}). Signing is a mutation of the files that are already in the payload (ADR 0024 § A4), plus exactly the seal's own directory${W===void 0?``:` (\`${W}\`)`}.`);let Y=q.sealed;t.log(`${S.tool} signed ${H.length} of ${n.length} payload file(s) as ${N?"ad-hoc (`-`)":`\`${t.identity}\``}${W===void 0?``:` and sealed ${t.bundleRoot} (${Y.length} seal file(s))`} — ${S.gap}.`);let read=t=>new Uint8Array(readFileSync($(C,t.split(`/`).join(Nn))));return[...n.map(t=>({path:t.path,mode:t.mode,data:read(t.path)})),...Y.map(t=>({path:t,mode:420,data:read(t)}))].sort((t,n)=>t.path<n.path?-1:+(t.path>n.path))}function resolveNotaryPlan(t){let n=tU[t.layoutOs];if(n===void 0){if(t.flag!==void 0)throw Error(`gjsify ship: --notarize has no meaning in the ${t.layoutOs} layout. Notarisation is Apple's pre-clearance of a signed artifact and nothing else asks for it — Windows SmartScreen accrues reputation per file hash instead (ADR 0024 § A5).`);return{kind:`unsupported`}}if(t.flag===void 0||t.flag===``)return{kind:`skip`,message:`no notarisation credential was given — skipping ${n.tool} notarytool. Pass \`--notarize <keychain-profile>\`, naming a profile a prior \`notarytool store-credentials\` put in this host's keychain.`};if(t.sign.kind!==`sign`)throw Error("gjsify ship: --notarize was given without an identity to sign with. Notarisation is a check ON a signature, so submitting an unsigned artifact has nothing to clear. Pass `--sign <identity>` as well, or drop --notarize.");return{kind:`notarize`,credential:t.flag,notary:n}}async function notarizeArtifact(t){let{notary:n,credential:S}=t.plan,C=process.platform;if(!n.notarizeOn.includes(C))throw Error(`gjsify ship: notarising the ${n.layoutOs} layout needs ${n.tool}, which runs on ${n.notarizeOn.join(`, `)} and this host is ${C}.`);let N=n.args(S,t.artifact);t.verbose&&t.log(`${n.tool} ${N.join(` `)}`);let F=await spawnToCompletion(n.tool,N,{completion:`return`,stdio:`inherit`,notFound:()=>Error(`gjsify ship: \`${n.tool}\` is not on PATH — ${n.installHint}.`)});if(F.code!==0)throw Error(`gjsify ship: ${n.tool} notarytool failed with ${describeExit(F)}.`);t.log(`${n.tool} notarytool accepted ${t.artifact}.`)}async function stapleArtifact(t){let n=[`stapler`,`staple`,t.artifact];t.verbose&&t.log(`${t.notary.tool} ${n.join(` `)}`);let S=await spawnToCompletion(t.notary.tool,n,{completion:`return`,stdio:`inherit`,notFound:()=>Error(`gjsify ship: \`${t.notary.tool}\` is not on PATH — ${t.notary.installHint}.`)});if(S.code!==0)throw Error(`gjsify ship: ${t.notary.tool} stapler failed with ${describeExit(S)}. The artifact is notarised and NOT stapled, which means every launch asks Gatekeeper to check online — and fails closed on a machine with no network. Re-run the finish phase; \`stapler\` requires internet access and the ticket may not have propagated yet.`);t.log(`${t.notary.tool} stapler attached the ticket to ${t.artifact}.`)}var eU,tU,nU=__esmMin(()=>{Bd(),In(),bF(),U_(),JV(),MV(),dV(),$H(),eU={darwin:{layoutOs:`darwin`,tool:`codesign`,signOn:[`darwin`],installHint:"install the Xcode Command Line Tools (`xcode-select --install`) on a macOS host",signs:`macho`,args:({identity:t,file:n,entitlements:S,adhoc:C})=>[`--force`,`--sign`,t,`--options`,`runtime`,...S===void 0?[]:[`--entitlements`,S],...C?[]:[`--timestamp`],n],entitlements:t=>[`com.apple.security.cs.allow-jit`,`com.apple.security.cs.allow-unsigned-executable-memory`,`com.apple.security.cs.disable-executable-page-protection`,`com.apple.security.cs.allow-dyld-environment-variables`,...t?[`com.apple.security.cs.disable-library-validation`]:[]],sealsBundle:!0,sealAddPrefix:t=>`${t}/Contents/_CodeSignature/`,configKey:`gjsify.ship.sign.darwin.identity`,gap:"the images are signed and the bundle is sealed, and the seal survives both the `.zip` and the `.dmg` round trip; § A16 stands measured in ONE direction only — library validation refuses an ad-hoc-signed dylib, so the ad-hoc identity grants `disable-library-validation` while a named one does not, and no run in this repository has ever held the named one"},win32:{layoutOs:`win32`,tool:`signtool`,signOn:[`win32`],installHint:"install the Windows SDK (signtool.exe ships in its `bin/<version>/x64` directory)",signs:`pe`,args:({identity:t,file:n})=>[`sign`,`/n`,t,`/fd`,`sha256`,n],entitlements:()=>[],sealsBundle:!1,sealAddPrefix:()=>``,configKey:`gjsify.ship.sign.win32.identity`,gap:`no timestamp countersignature is requested, so the signature expires with the certificate (UNVERIFIED: no run in this repository has ever invoked signtool)`}},tU={darwin:{layoutOs:`darwin`,tool:`xcrun`,notarizeOn:[`darwin`],installHint:"install the Xcode Command Line Tools (`xcode-select --install`) on a macOS host",args:(t,n)=>[`notarytool`,`submit`,`--keychain-profile`,t,`--wait`,n]}}});function stagedFontDir(t,n){return`${t}/${hn.basename(kB.fonts)}/${n}`}function shellQuote(t){return`'${t.replace(/'/g,`'\\''`)}'`}function cmdQuote(t){let n=/["%!\r\n]/.exec(t);if(n!==null)throw Error(`gjsify ship: \`gjsify.ship.execArgs\` contains ${JSON.stringify(t)}, and cmd.exe has no way to pass ${JSON.stringify(n[0])} through a Windows launcher literally — \`%\` expands at parse time and \`"\` ends the quoted run. Move the value into the app (it can read it from its own config) or drop the character.`);return`"${t}"`}function renderLauncher(t,n,S,C={}){switch(S.name){case`linux`:return renderPrefixLauncher(t,n,S);case`darwin`:return renderAppBundleLauncher(t,n,S,C);case`windows`:return renderWindowsLauncher(t,n,S,C);default:{let t=S.name;throw Error(`gjsify ship: no launcher is wired for the "${String(t)}" layout.`)}}}function renderPrefixLauncher(t,n,S){let C=S.dirs(t),N=[`#!/bin/sh`,"# Generated by `gjsify ship` — do not edit.",`set -e`,`self=$(readlink -f "$0")`,`prefix=$(dirname "$(dirname "$self")")`,`XDG_DATA_DIRS="$prefix/${C.data}:\${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"`,`export XDG_DATA_DIRS`];if(t.typelibFiles.length>0){let t=`"$prefix"/${C.native}`;for(let n of[`GI_TYPELIB_PATH`,`LD_LIBRARY_PATH`])N.push(`${n}=${t}\${${n}:+:$${n}}`,`export ${n}`)}else if(Object.values(t.formatFiles).some(t=>t.typelibFiles.length>0)){let t=`"$prefix"/${C.native}`;N.push(`if [ -d ${t} ]; then`);for(let n of[`GI_TYPELIB_PATH`,`LD_LIBRARY_PATH`])N.push(` ${n}=${t}\${${n}:+:$${n}}`,` export ${n}`);N.push(`fi`)}return t.localeFiles.length>0&&N.push(`GJSIFY_LOCALE_DIR="$prefix"/${C.data}/locale`,`export GJSIFY_LOCALE_DIR`),t.fontFiles.length>0&&N.push(`GJSIFY_FONT_DIR="$prefix"/${stagedFontDir(C.data,t.appId)}`,`export GJSIFY_FONT_DIR`),N.push(`exec ${execLine(S,`"$prefix"/${C.bundle}/${n}`,t)} "$@"`,``),N.join(`
|
|
1163
1163
|
`)}function renderAppBundleLauncher(t,n,S,C){let N=`${S.root(t)}/Contents`,F=S.dirs(t),under=t=>hn.relative(N,t),beside=t=>hn.relative(F.launcher,t),I=[`#!/bin/sh`,"# Generated by `gjsify ship` — do not edit.",`set -e`,`here=$(cd -- "$(dirname -- "$0")" && pwd)`,`contents=$(dirname -- "$here")`,`XDG_DATA_DIRS="$contents/${under(F.data)}"\${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}`,`export XDG_DATA_DIRS`];C.gtkRuntimeDir!==void 0&&I.push(`GJSIFY_GTK_RUNTIME="$contents/${under(C.gtkRuntimeDir)}"`,`export GJSIFY_GTK_RUNTIME`),C.nodeGiAddon!==void 0&&I.push(`NODE_GI_NATIVE="$contents/${under(C.nodeGiAddon)}"`,`export NODE_GI_NATIVE`),t.typelibFiles.length>0&&(I.push(`GI_TYPELIB_PATH="$contents/${under(F.native)}"\${GI_TYPELIB_PATH:+:$GI_TYPELIB_PATH}`,`export GI_TYPELIB_PATH`),I.push(`GJSIFY_GI_LIBRARY_PATH="$contents/${under(F.native)}"\${GJSIFY_GI_LIBRARY_PATH:+:$GJSIFY_GI_LIBRARY_PATH}`,`export GJSIFY_GI_LIBRARY_PATH`)),t.localeFiles.length>0&&I.push(`GJSIFY_LOCALE_DIR="$contents/${under(F.data)}/locale"`,`export GJSIFY_LOCALE_DIR`),t.fontFiles.length>0&&I.push(`GJSIFY_FONT_DIR="$contents/${stagedFontDir(under(F.data),t.appId)}"`,`export GJSIFY_FONT_DIR`);let H=C.interpreter===void 0?void 0:`"$here/${beside(C.interpreter)}"`;return I.push(`exec ${execLine(S,`"$contents/${under(F.bundle)}/${n}"`,t,H)} "$@"`,``),I.join(`
|
|
1164
1164
|
`)}function renderWindowsLauncher(t,n,S,C){let N=S.dirs(t),at=t=>`%HERE%${windowsPath(t)}`,F=[`@echo off`,`rem Generated by "gjsify ship" - do not edit.`,`setlocal`,`set "HERE=%~dp0"`,prependVar(`XDG_DATA_DIRS`,at(N.data))];C.gtkRuntimeDir!==void 0&&F.push(`set "GJSIFY_GTK_RUNTIME=${at(C.gtkRuntimeDir)}"`),C.nodeGiAddon!==void 0&&F.push(`set "NODE_GI_NATIVE=${at(C.nodeGiAddon)}"`),t.typelibFiles.length>0&&F.push(prependVar(`GI_TYPELIB_PATH`,at(N.native)),prependVar(`PATH`,at(N.native))),t.localeFiles.length>0&&F.push(`set "GJSIFY_LOCALE_DIR=${at(N.data)}\\locale"`),t.fontFiles.length>0&&F.push(`set "GJSIFY_FONT_DIR=${at(stagedFontDir(N.data,t.appId))}"`);let I=C.interpreter===void 0?void 0:`"${at(C.interpreter)}"`;return F.push(`${execLine(S,`"${at(N.bundle)}\\${windowsPath(n)}"`,t,I)} %*`,``),F.join(`\r
|
|
1165
1165
|
`)}function prependVar(t,n){return`if defined ${t} (set "${t}=${n};%${t}%") else (set "${t}=${n}")`}function windowsPath(t){return t.split(`/`).filter(t=>t.length>0).join(`\\`)}function execLine(t,n,S,C){let N=t.name===`windows`?cmdQuote:shellQuote,F=S.execArgs.map(N).join(` `),I=C??(S.app===`node`?`node`:`gjs`);return`${S.app===`node`?I:`${I} -m`} ${n}${F?` ${F}`:``}`}var rU=__esmMin(()=>{In(),AB()});function createCpioArchive(t){let n=[],S=0;t.forEach((t,C)=>{let N=t.linkTarget===void 0?t.data??new Uint8Array:encodeUtf8(t.linkTarget),F=encodeUtf8(`${t.name}\0`),I=buildHeader({ino:t.ino??C+1,mode:t.mode,nlink:t.nlink??1,mtime:t.mtime??0,filesize:N.byteLength,namesize:F.byteLength});S=push(n,I,S),S=push(n,F,S),S=padTo4(n,S),S=push(n,N,S),S=padTo4(n,S)});let C=encodeUtf8(`TRAILER!!!\0`);return S=push(n,buildHeader({ino:0,mode:0,nlink:1,mtime:0,filesize:0,namesize:C.byteLength}),S),S=push(n,C,S),padTo4(n,S),concatBytes(n)}function buildHeader(t){let n=iU+hex8(t.ino)+hex8(t.mode)+hex8(0)+hex8(0)+hex8(t.nlink)+hex8(t.mtime)+hex8(t.filesize)+hex8(0)+hex8(0)+hex8(0)+hex8(0)+hex8(t.namesize)+hex8(0);if(n.length!==aU)throw Error(`gjsify ship: internal error — cpio header is ${n.length} bytes, expected ${aU}.`);return encodeUtf8(n)}function hex8(t){if(t<0||!Number.isInteger(t))throw Error(`gjsify ship: cpio header field must be a non-negative integer, got ${t}.`);let n=t.toString(16).toUpperCase();if(n.length>8)throw Error(`gjsify ship: cpio header field ${t} does not fit in 8 hex digits.`);return n.padStart(8,`0`)}function push(t,n,S){return n.byteLength>0&&t.push(n),S+n.byteLength}function padTo4(t,n){let S=n%4;if(S===0)return n;let C=4-S;return t.push(new Uint8Array(C)),n+C}var iU,aU,oU,sU,cU=__esmMin(()=>{hB(),iU=`070701`,aU=110,oU=32768,sU=16384});function buildRpmHeader(t,n){let S=[...t].sort((t,n)=>t.tag-n.tag),C=[],N=[],F=0;for(let t of S){if(t.tag<100)throw Error(`gjsify ship: rpm tag ${t.tag} is below 100 and would be rejected by hdrchkTag.`);let{data:n,count:S}=encodeValue(t.type,t.value,t.tag),I=fU[t.type],H=(I-F%I)%I;H>0&&(N.push(new Uint8Array(H)),F+=H),C.push({tag:t.tag,type:t.type,offset:F,count:S}),N.push(n),F+=n.byteLength}let I=F,H=C.length+1;N.push(indexEntry(n,7,-(uU*H),dU)),F+=uU;let W=new Uint8Array(lU.byteLength+8+H*uU+F),q=new DataView(W.buffer);W.set(lU,0),q.setUint32(8,H),q.setUint32(12,F);let Y=16;W.set(indexEntry(n,7,I,dU),Y),Y+=uU;for(let t of C)W.set(indexEntry(t.tag,t.type,t.offset,t.count),Y),Y+=uU;for(let t of N)W.set(t,Y),Y+=t.byteLength;return W}function indexEntry(t,n,S,C){let N=new Uint8Array(uU),F=new DataView(N.buffer);return F.setInt32(0,t),F.setInt32(4,n),F.setInt32(8,S),F.setInt32(12,C),N}function encodeValue(t,n,S){let C=new TextEncoder;switch(t){case 6:if(typeof n!=`string`)throw typeMismatch(S,`a string`);return{data:C.encode(`${n}\0`),count:1};case 8:case 9:{let t=typeof n==`string`?[n]:n;if(!Array.isArray(t))throw typeMismatch(S,`a string array`);if(t.length===0)throw Error(`gjsify ship: rpm tag ${S} has an empty array; omit it instead.`);return{data:C.encode(t.map(t=>`${t}\0`).join(``)),count:t.length}}case 7:if(!(n instanceof Uint8Array))throw typeMismatch(S,`binary data`);return{data:n,count:n.byteLength};case 3:case 4:{let C=typeof n==`number`?[n]:n;if(!Array.isArray(C))throw typeMismatch(S,`a number array`);if(C.length===0)throw Error(`gjsify ship: rpm tag ${S} has an empty array; omit it instead.`);let N=t===3?2:4,F=new Uint8Array(C.length*N),I=new DataView(F.buffer);return C.forEach((n,S)=>{t===3?I.setUint16(S*N,n&65535):I.setUint32(S*N,n>>>0)}),{data:F,count:C.length}}}}function typeMismatch(t,n){return Error(`gjsify ship: internal error — rpm tag ${t} expects ${n}.`)}function buildRpmLead(t){let n=new Uint8Array(96),S=new DataView(n.buffer);n.set([237,171,238,219],0),n[4]=3,n[5]=0,S.setInt16(6,0),S.setInt16(8,0);let C=new TextEncoder().encode(t).slice(0,65);return n.set(C,10),S.setInt16(76,0),S.setInt16(78,5),n}function padToEight(t){let n=(8-t.byteLength%8)%8;if(n===0)return t;let S=new Uint8Array(t.byteLength+n);return S.set(t,0),S}var lU,uU,dU,fU,pU=__esmMin(()=>{lU=Uint8Array.from([142,173,232,1,0,0,0,0]),uU=16,dU=16,fU={3:2,4:4,6:1,7:1,8:1,9:1}});async function buildRpm(t){let{settings:n,mtime:S}=t,C=collectFiles(t,`/${t.prefix.replace(/^\/+|\/+$/g,``)}`),N=createCpioArchive(C.map((t,n)=>({name:`.${t.path}`,mode:t.mode,data:t.data,mtime:S,ino:n+1}))),F=await gzipDeterministic(N),I=buildRpmHeader(mainHeaderEntries(t,C,N,F),63),H=concatBytes([I,F]),W=padToEight(buildRpmHeader([{tag:hU.SHA1HEADER,type:6,value:hashHex(`sha1`,I)},{tag:hU.SHA256HEADER,type:6,value:hashHex(`sha256`,I)},{tag:hU.SIZE,type:4,value:[H.byteLength]},{tag:hU.MD5,type:7,value:hashBytes(`md5`,H)},{tag:hU.PAYLOADSIZE,type:4,value:[N.byteLength]}],62));return concatBytes([buildRpmLead(`${n.binaryName}-${n.version}-${n.release}`),W,H])}function collectFiles(t,n){let S=t.payload.map(t=>{if(t.data.byteLength>4294967295)throw Error(`gjsify ship: ${t.path} is larger than 4 GiB, which needs rpm's LONGFILESIZES tag. That is not implemented — split the payload.`);return{path:`${n}/${t.path}`,mode:oU|t.mode&4095,data:t.data,isDirectory:!1}}),C=new Set;for(let t of S){let n=t.path.split(`/`).slice(1);n.pop();let S=``;for(let t of n)S=`${S}/${t}`,yU.has(S)||C.add(S)}for(let t of C)S.push({path:t,mode:sU|493,data:new Uint8Array,isDirectory:!0});return S.sort((t,n)=>t.path<n.path?-1:+(t.path>n.path))}function mainHeaderEntries(t,n,S,C){let{settings:N}=t,F=`${N.version}-${N.release}`,I=[],H=[],W=[];for(let t of n){let n=t.path.lastIndexOf(`/`),S=`${t.path.slice(0,n)}/`,C=I.indexOf(S);C===-1&&(C=I.push(S)-1),H.push(C),W.push(t.path.slice(n+1))}let q=renderRpmScriptlets(readPayloadFacts(t.payload),t.prefix),Y=buildRequires(t.depends,q,readShebangInterpreters(t.payload)),X=buildRecommends(t.recommends??[]),Z=[{tag:mU.HEADERI18NTABLE,type:8,value:[`C`]},{tag:mU.NAME,type:6,value:N.binaryName},{tag:mU.VERSION,type:6,value:N.version},{tag:mU.RELEASE,type:6,value:N.release},{tag:mU.SUMMARY,type:9,value:[N.summary]},{tag:mU.DESCRIPTION,type:9,value:[N.description.join(`
|
|
1166
1166
|
|
|
1167
|
-
`)]},{tag:mU.BUILDTIME,type:4,value:[t.mtime]},{tag:mU.BUILDHOST,type:6,value:`localhost`},{tag:mU.SIZE,type:4,value:[n.reduce((t,n)=>t+n.data.byteLength,0)]},{tag:mU.LICENSE,type:6,value:N.license},{tag:mU.GROUP,type:9,value:[N.group]},{tag:mU.OS,type:6,value:`linux`},{tag:mU.ARCH,type:6,value:t.archLabel},{tag:mU.SOURCERPM,type:6,value:`${N.binaryName}-${F}.src.rpm`},{tag:mU.RPMVERSION,type:6,value:`4.20.0`},{tag:mU.ENCODING,type:6,value:`utf-8`},{tag:mU.FILESIZES,type:4,value:n.map(t=>t.data.byteLength)},{tag:mU.FILEMODES,type:3,value:n.map(t=>t.mode)},{tag:mU.FILERDEVS,type:3,value:n.map(()=>0)},{tag:mU.FILEMTIMES,type:4,value:n.map(()=>t.mtime)},{tag:mU.FILEDIGESTS,type:8,value:n.map(t=>t.isDirectory?``:hashHex(`sha256`,t.data))},{tag:mU.FILELINKTOS,type:8,value:n.map(()=>``)},{tag:mU.FILEFLAGS,type:4,value:n.map(()=>0)},{tag:mU.FILEUSERNAME,type:8,value:n.map(()=>`root`)},{tag:mU.FILEGROUPNAME,type:8,value:n.map(()=>`root`)},{tag:mU.FILEVERIFYFLAGS,type:4,value:n.map(()=>4294967295)},{tag:mU.FILEDEVICES,type:4,value:n.map(()=>1)},{tag:mU.FILEINODES,type:4,value:n.map((t,n)=>n+1)},{tag:mU.FILELANGS,type:8,value:n.map(()=>``)},{tag:mU.FILEDIGESTALGO,type:4,value:[_U]},{tag:mU.DIRINDEXES,type:4,value:H},{tag:mU.BASENAMES,type:8,value:W},{tag:mU.DIRNAMES,type:8,value:I},{tag:mU.PROVIDENAME,type:8,value:[N.binaryName]},{tag:mU.PROVIDEFLAGS,type:4,value:[gU.EQUAL]},{tag:mU.PROVIDEVERSION,type:8,value:[F]},{tag:mU.REQUIRENAME,type:8,value:Y.names},{tag:mU.REQUIREFLAGS,type:4,value:Y.flags},{tag:mU.REQUIREVERSION,type:8,value:Y.versions},...X.names.length>0?[{tag:mU.RECOMMENDNAME,type:8,value:X.names},{tag:mU.RECOMMENDFLAGS,type:4,value:X.flags},{tag:mU.RECOMMENDVERSION,type:8,value:X.versions}]:[],{tag:mU.PAYLOADFORMAT,type:6,value:`cpio`},{tag:mU.PAYLOADCOMPRESSOR,type:6,value:`gzip`},{tag:mU.PAYLOADFLAGS,type:6,value:`9`},{tag:mU.PAYLOADDIGEST,type:8,value:[hashHex(`sha256`,C)]},{tag:mU.PAYLOADDIGESTALGO,type:4,value:[_U]},{tag:mU.PAYLOADDIGESTALT,type:8,value:[hashHex(`sha256`,S)]}];return assertParallelFileArrays(Z,n.length),N.homepage&&Z.push({tag:mU.URL,type:6,value:N.homepage}),q.post!==void 0&&(Z.push({tag:mU.POSTIN,type:6,value:q.post}),Z.push({tag:mU.POSTINPROG,type:6,value:`/bin/sh`})),q.postun!==void 0&&(Z.push({tag:mU.POSTUN,type:6,value:q.postun}),Z.push({tag:mU.POSTUNPROG,type:6,value:`/bin/sh`})),Z}function assertParallelFileArrays(t,n){let S=new Set([mU.FILESIZES,mU.FILEMODES,mU.FILERDEVS,mU.FILEMTIMES,mU.FILEDIGESTS,mU.FILELINKTOS,mU.FILEFLAGS,mU.FILEUSERNAME,mU.FILEGROUPNAME,mU.FILEVERIFYFLAGS,mU.FILEDEVICES,mU.FILEINODES,mU.FILELANGS,mU.DIRINDEXES,mU.BASENAMES]);for(let C of t){if(!S.has(C.tag))continue;let t=Array.isArray(C.value)?C.value.length:1;if(t!==n)throw Error(`gjsify ship: internal error — rpm tag ${C.tag} has ${t} values for ${n} files.`)}}function buildRequires(t,n,S){let C=[],N=[],F=[];for(let n of t){let t=parseDepend(n);C.push(t.name),N.push(senseFor(t.relation)),F.push(t.version??``)}n.post!==void 0&&(C.push(`/bin/sh`),N.push(gU.INTERP|gU.SCRIPT_POST),F.push(``)),n.postun!==void 0&&(C.push(`/bin/sh`),N.push(gU.INTERP|gU.SCRIPT_POSTUN),F.push(``));for(let t of S)C.push(t),N.push(gU.FIND_REQUIRES),F.push(``);for(let[t,n]of vU)C.push(t),N.push(gU.RPMLIB|gU.LESS|gU.EQUAL),F.push(n);return{names:C,flags:N,versions:F}}function buildRecommends(t){let n=[],S=[],C=[];for(let N of t){let t=parseDepend(N);n.push(t.name),S.push(senseFor(t.relation)),C.push(t.version??``)}return{names:n,flags:S,versions:C}}function senseFor(t){switch(t){case`>=`:return gU.GREATER|gU.EQUAL;case`>`:return gU.GREATER;case`<=`:return gU.LESS|gU.EQUAL;case`<`:return gU.LESS;case`=`:return gU.EQUAL;default:return 0}}function hashHex(t,n){return createHash(t).update(n).digest(`hex`)}function hashBytes(t,n){return new Uint8Array(createHash(t).update(n).digest())}var mU,hU,gU,_U,vU,yU,bU=__esmMin(()=>{el(),hB(),cU(),DB(),MV(),pU(),OB(),jB(),AB(),mU={HEADERI18NTABLE:100,NAME:1e3,VERSION:1001,RELEASE:1002,SUMMARY:1004,DESCRIPTION:1005,BUILDTIME:1006,BUILDHOST:1007,SIZE:1009,LICENSE:1014,GROUP:1016,URL:1020,OS:1021,ARCH:1022,POSTIN:1024,POSTUN:1026,FILESIZES:1028,FILEMODES:1030,FILERDEVS:1033,FILEMTIMES:1034,FILEDIGESTS:1035,FILELINKTOS:1036,FILEFLAGS:1037,FILEUSERNAME:1039,FILEGROUPNAME:1040,SOURCERPM:1044,FILEVERIFYFLAGS:1045,PROVIDENAME:1047,REQUIREFLAGS:1048,REQUIRENAME:1049,REQUIREVERSION:1050,RECOMMENDNAME:5046,RECOMMENDVERSION:5047,RECOMMENDFLAGS:5048,RPMVERSION:1064,POSTINPROG:1086,POSTUNPROG:1088,FILEDEVICES:1095,FILEINODES:1096,FILELANGS:1097,PROVIDEFLAGS:1112,PROVIDEVERSION:1113,DIRINDEXES:1116,BASENAMES:1117,DIRNAMES:1118,PAYLOADFORMAT:1124,PAYLOADCOMPRESSOR:1125,PAYLOADFLAGS:1126,FILEDIGESTALGO:5011,ENCODING:5062,PAYLOADDIGEST:5092,PAYLOADDIGESTALGO:5093,PAYLOADDIGESTALT:5097},hU={SIZE:1e3,MD5:1004,PAYLOADSIZE:1007,SHA1HEADER:269,SHA256HEADER:273},gU={LESS:2,GREATER:4,EQUAL:8,INTERP:256,SCRIPT_POST:1024,SCRIPT_POSTUN:4096,FIND_REQUIRES:16384,RPMLIB:1<<24},_U=8,vU=[[`rpmlib(CompressedFileNames)`,`3.0.4-1`],[`rpmlib(FileDigests)`,`4.6.0-1`],[`rpmlib(PayloadFilesHavePrefix)`,`4.0-1`]],yU=new Set([`/usr`,`/usr/bin`,`/usr/lib`,`/usr/lib64`,`/usr/libexec`,`/usr/sbin`,`/usr/share`,`/usr/${kB.applications}`,`/usr/share/doc`,`/usr/share/icons`,`/usr/share/licenses`,`/usr/share/man`,`/usr/${kB.metainfo}`,`/usr/share/glib-2.0`,`/usr/${kB.schemas}`,`/usr/${kB.fonts}`,`/etc`,`/opt`,`/var`])});async function assemble(t){let n=process.cwd(),S=t.os===void 0?hostLayout():resolveLayout(t.os),C=await new Config().forCommand(n),N=C.ship??{},F=C.flatpak??{},I=resolveShipApp({project:C.app,perTarget:N.app,layoutOs:S.os}),H=I.app;I.overridden&&ge.log(`${xU} runtime for ${S.name}: ${H} — \`${I.key}\` overrides \`gjsify.app${C.app===void 0?``:`: "${C.app}"`}\`.`);let W=readPackageJson$2($(n,`package.json`))??{},q,Y=[];if(t.target!==void 0)q=resolveFormats(t.target,S);else if(N.targets!==void 0){let t=configuredFormats(N.targets,S);q=t.formats,t.dropped.length>0&&ge.log(`${xU} \`gjsify.ship.targets\` names ${t.dropped.join(`, `)}, which wrap another layout — not built for ${S.name}. Pass --target to ask for one explicitly.`)}else{let t=defaultFormatIds(S.os).map(t=>MH[t]);q=t.filter(t=>t.interpreters.includes(H)),Y=t.filter(t=>!t.interpreters.includes(H)),Y.length>0&&ge.log(`${xU} ${Y.map(t=>t.id).join(`, `)} wrap the ${S.name} layout but cannot run \`${H}\`, which \`${I.key}\` resolves to — ${Y[0]?.interpreterGap??``}. Set \`gjsify.ship.app.${S.os}\` to "${Y[0]?.interpreters.join(`" / "`)}" to ship this OS on that runtime; it leaves every other target on \`gjsify.app\`. Assembling the layout only; pass --target to be told the same thing as an error.`)}q.some(t=>t.id===`flatpak`)&&assertNoDroppedFlatpakModules(F),t.stage||assertPackable(q,S,t.os===void 0?`host`:`positional`,Y);let X=resolveSignPlan({flag:t.sign,config:N.sign,layoutOs:S.os}),Z=resolveNotaryPlan({flag:t.notarize,layoutOs:S.os,sign:X});if(t.stage&&assertNothingToSignYet(t),t.stage||(announceSigning(X,Z),X.kind===`sign`&&assertHostCanSign(X.signer)),t.stage||assertKindCanPack(q,resolveShipKind(N,F)),!t.stage)for(let t of q)assertCanPack(t);let te=parseDeclaredChannel(t.channel,`--channel`)??parseDeclaredChannel(N.channel,`gjsify.ship.channel`)??(q.some(t=>t.id===`flatpak`)?`flathub`:void 0);t[`skip-build`]||await runProjectBuild(n,te);let ne=resolveShipBundle({pkg:W,ship:N,layoutOs:S.os});ne.overridden&&ge.log(`${xU} entry for ${S.name}: ${ne.declared} — \`${ne.key}\` overrides \`gjsify.main\`.`);let re=discoverPayload({projectDir:n,pkg:W,ship:N,flatpakIcon:F.icon,declaredBundle:ne.declared,layoutOs:S.os,foreignBundles:ne.foreign}),{settings:ie,metadata:ae,warnings:oe}=resolveShipSettings({projectDir:n,pkg:W,ship:N,flatpak:F,cli:{outDir:t.out,arch:t.arch,layoutOs:S.os},discovered:re,app:H});for(let t of oe)ge.warn(`${xU} ${t}`);for(let t of q)assertFormatCanRunInterpreter(t,ie.app);let Q=readFileSync(ie.bundlePath,`utf-8`);assertEntryRunsUnder({interpreter:ie.app,source:Q,entry:En(n,ie.bundlePath)||ie.bundlePath,appKey:I.key,bundleKey:ne.key,layoutOs:S.os});let se=buildTimestamp(ie.bundlePath),ce={appId:ie.appId,name:ie.name,command:ie.binaryName,kind:ie.kind,metadata:ae,channel:te,configKey:`gjsify.ship`,copyrightYear:new Date(se*1e3).getUTCFullYear()};for(let t of validateAppMetadata(ce))ge.warn(`${xU} ${t.field} is not set — ${t.hint}`);ie.licenseFile!==void 0&&On(ie.licenseFile)!==n&&ge.log(`${xU} licence text from ${En(n,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=await resolveCarriedRuntime(S,ie,n),de={bundleFiles:re.bundleFiles,launcher:renderLauncher(ie,kn(ie.bundlePath),S,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:se},fe=Cn(n,ie.outDir),pe=$(fe,`stage`),me=[...planStage(ie,de),...S.os===`linux`?[]:await compileSchemasForStage({schemaFiles:ie.schemaFiles,workDir:$(fe,`schemas`)})],he=ie.kind===`app`&&S.icon!==void 0&&(S.icon.required||ie.iconFiles.length>0)?await resolveAppIcon({iconFiles:ie.iconFiles,appId:ie.appId,sizes:S.icon.sizes,target:S.icon.writes}):void 0;he!==void 0&&ge.log(`${xU} icon: ${iconSizes(he).join(`/`)} px, ${he.source}`);let _e=placeStage(S,{...ie,icon:he},me,ue.files);if(writeStage(pe,_e),ge.log(`${xU} staged ${_e.length} file(s) for ${S.name} in ${En(n,pe)}/`),t.verbose)for(let t of _e)ge.log(`${xU} ${t.path}`);if(assertPayloadMatchesArch(readStage([pe],_e),ie.arch),S.os!==`linux`){let t=linuxInstallDependent(me);if(t.length>0){ge.warn(`${xU} the ${S.name} layout carries ${t.length} file(s) whose Linux correctness comes from a package install step it has no equivalent for:`);let n={aborts:`ABORTS: `,unknown:`UNCLASSIFIED: `,inert:``};for(let{path:S,verdict:C,why:N}of t)ge.warn(`${xU} ${n[C]??``}${S} — ${N}`)}for(let t of ue.found)ge.log(`${xU} carries its own ${t}`);for(let t of ue.missing)ge.warn(`${xU} ${t}`);ue.launcher.interpreter===void 0&&S.runtimeGap!==void 0&&ge.warn(`${xU} ${S.runtimeGap}`),S.fontGap!==void 0&&me.some(t=>isUnder(t.path,kB.fonts))&&ge.warn(`${xU} ${S.fontGap}`),S.arches!==null&&!S.arches.only.includes(ie.arch)&&ge.warn(`${xU} this stage is labelled ${ie.arch} and the ${S.name} layout has no runtime for it — ${S.arches.why}. Nothing can pack this stage; \`--arch ${S.arches.only.join(`|`)}\` is what produces an artifact.`)}let ve=scanGiRequirements(Q),ye=ve.namespaces,be=ve.optional;if(t.verbose){let t=ye.filter(t=>!be.includes(t));ge.log(`${xU} gi namespaces: ${ye.join(`, `)||`(none)`}`),be.length>0&&(ge.log(`${xU} gi optional namespaces: ${be.join(`, `)}`),ge.log(`${xU} gi required namespaces: ${t.join(`, `)||`(none)`}`))}let xe=new Map;for(let t of q)xe.set(t.id,(await planOverlay(ie,t,de)).map(t=>({...t,path:place(S,ie,t.path)})));let Se=readPayloadFacts(me);for(let t of q){if(t.depends===null)continue;let n=deriveDepends(t.depends,{namespaces:ye,optionalNamespaces:be,hasIcons:Se.hasIcons,hasSchemas:Se.hasSchemas,interpreter:ie.app,extra:ie.extraDepends[t.depends],typelibPackages:ie.typelibPackages,bundledTypelibs:Se.bundledTypelibs,minGjsVersion:ie.minGjsVersion,minNodeVersion:ie.minNodeVersion});for(let S of n.unmappedOptional)ge.warn(`${xU} gi://${S} is imported optionally, but no ${t.depends} package is known to ship its typelib, so no Recommends entry names it. The package builds and runs without it. Add the row if the namespace should be recommended: \`gjsify.ship.typelibPackages.${S} = { "${t.depends}": "…" }\`.`);let S=ie.app===`node`?warnAboutNodeFloor(t.depends,ie.minNodeVersion):warnAboutGjsFloor(t.depends,ie.minGjsVersion);for(let t of S)ge.warn(`${xU} ${t}`)}let Ce=writeStageManifest({stageDir:pe,settings:ie,formats:q,mtime:se,namespaces:ye,optionalNamespaces:be,staged:_e,overlay:xe});if(t.stage){let t=Y.length>0?`(none — ${Y.map(t=>t.id).join(` and `)} need \`gjsify.ship.app.${S.os}: "node"\`)`:formatIdsFor(S.os).length===0?`(none — no format wraps the ${S.name} layout)`:`(none asked for)`,n=Ce.formats.join(`, `)||t;ge.log(`${xU} stage manifest: ${formatTarget(Ce.target)}, formats ${n}`);return}let we=[];for(let n of q)we.push(await packOne({format:n,settings:ie,arch:ie.arch,staged:_e,overlay:xe.get(n.id)??[],stageDir:pe,outRoot:fe,namespaces:ye,optionalNamespaces:be,mtime:se,sign:X,notarize:Z,verbose:t.verbose}));printArtifacts(n,we)}function assertNothingToSignYet(t){let n=t.sign===void 0?t.notarize===void 0?void 0:`--notarize`:`--sign`;if(n!==void 0)throw Error(`gjsify ship: ${n} belongs to the finish phase, and --stage produces no artifact to sign — it writes the tree a packing host reads back. Assemble here, then run \`gjsify ship --from-stage <dir> --sign <identity>\` on the host that holds the identity (ADR 0024 § A2, § A14).`)}function announceSigning(t,n){t.kind===`skip`&&ge.warn(`${xU} ${t.message}`),n.kind===`skip`&&t.kind===`sign`&&ge.warn(`${xU} ${n.message}`)}async function resolveCarriedRuntime(t,n,S){let C={files:[],launcher:{},found:[],missing:[]};if(t.os===`linux`||n.app!==`node`)return C;let N=`${t.os}-${n.arch}`;if(!isGtkRuntimeTarget(N))return C;let F=await acquireGtkRuntime({target:N,version:cliVersion(),discovery:{cwd:S},ensure:async t=>(await ensurePkgDir(parseSpec(t),{verbose:!1,cacheMaxAge:CU,frozen:!1})).pkgDir,log:t=>ge.log(`${xU} ${t}`)});return stageAppRuntime({layout:t,identity:n,target:N,cwd:S,interpreter:isNodeRuntimeTarget(N)?resolveNodeRuntime(N,{cwd:S}):null,...F.kind===`fetched`?{fetchedGtkRuntimeDir:F.dir}:{},...F.kind===`failed`?{gtkFetchFailure:F.reason}:{}})}async function finishFromStage(t,n){if(t.stage)throw Error("gjsify ship: --stage and --from-stage are the two halves of one split and cannot run together. `--stage` assembles a payload and stops; `--from-stage <dir>` packs one that is already assembled. Run them as two commands, on the host each belongs on (ADR 0024 § A2).");if(t[`skip-build`])throw Error(`gjsify ship: --from-stage never runs a build — the payload it packs was built and staged by an earlier run — so --skip-build has nothing to skip. Drop it.`);if(t.arch!==void 0)throw Error("gjsify ship: --arch is decided when the stage is assembled, not when it is packed: the launcher, the payload and the recorded target were all fixed then. Pass --arch to `gjsify ship --stage`, and use `--expect-target <os>-<arch>` here to assert which leg you are packing.");if(t.os!==void 0)throw Error(`gjsify ship: the layout is decided when the stage is assembled, so "${t.os}" has nothing to change here — the staged tree already IS one OS's layout. Use \`--expect-target <os>-<arch>\` to assert which one you are packing.`);let S=process.cwd(),C=Cn(S,n),N=readStageManifest(C);assertExpectedTarget(N,t[`expect-target`]);let F=layoutForOs(N.target.os);t.target===void 0&&assertPackable(N.formats.map(t=>MH[t]),F,`stage`,defaultFormatIds(F.os).map(t=>MH[t]).filter(t=>!t.interpreters.includes(N.settings.app)));let I=resolveFormats(t.target??N.formats,F);assertFormatsStaged(N,I);for(let t of I)assertCanPack(t);let H=resolveSignPlan({flag:t.sign,layoutOs:F.os}),W=resolveNotaryPlan({flag:t.notarize,layoutOs:F.os,sign:H});announceSigning(H,W),H.kind===`sign`&&assertHostCanSign(H.signer);for(let t of warnOnToolSkew(N))ge.warn(`${xU} ${t}`);let{mtime:q,warnings:Y}=resolveStageMtime(N);for(let t of Y)ge.warn(`${xU} ${t}`);if(ge.log(`${xU} packing ${N.settings.binaryName} ${N.settings.version}-${N.settings.release} for ${formatTarget(N.target)} from ${En(S,C)||`.`}/`),t.verbose){for(let t of N.staged)ge.log(`${xU} ${t.path}`);ge.log(`${xU} gi namespaces: ${N.namespaces.join(`, `)||`(none)`}`),(N.optionalNamespaces??[]).length>0&&ge.log(`${xU} gi optional namespaces: ${N.optionalNamespaces?.join(`, `)}`)}let X=t.out===void 0?On(C):Cn(S,t.out),Z=[];for(let n of I){if(assertFormatCanRunInterpreter(n,N.settings.app),n.depends!==null){let t=N.settings.app===`node`?warnAboutNodeFloor(n.depends,N.settings.minNodeVersion):warnAboutGjsFloor(n.depends,N.settings.minGjsVersion);for(let n of t)ge.warn(`${xU} ${n}`)}Z.push(await packOne({format:n,settings:N.settings,arch:N.target.arch,staged:N.staged,overlay:overlayFiles(N,n.id),stageDir:C,outRoot:X,namespaces:N.namespaces,optionalNamespaces:N.optionalNamespaces??[],mtime:q,sign:H,notarize:W,verbose:t.verbose}))}printArtifacts(S,Z)}async function packOne(t){let{format:n,settings:S,stageDir:C,outRoot:N,mtime:F}=t;assertOverlayIsLicensed(n.id,S.binaryName,t.overlay);let I=$(N,`overlay`,n.id);writeStage(I,t.overlay);let H=readStage([C,I],[...t.staged,...t.overlay]),W=readPayloadFacts(H),q=n.depends===null?{requires:[],recommends:[],unmappedOptional:[]}:deriveDepends(n.depends,{namespaces:t.namespaces,optionalNamespaces:t.optionalNamespaces,hasIcons:W.hasIcons,hasSchemas:W.hasSchemas,interpreter:S.app,extra:S.extraDepends[n.depends],typelibPackages:S.typelibPackages,bundledTypelibs:W.bundledTypelibs,minGjsVersion:S.minGjsVersion,minNodeVersion:S.minNodeVersion}),Y=q.requires,X=q.recommends;assertPayloadMatchesArch(H,t.arch);let Z=layoutForOs(n.layoutOs);assertLauncherMatchesInterpreter(H,Z,S,S.app),assertLayoutSupportsArch(Z,t.arch);let te=t.sign.kind===`sign`?await signPayload({payload:H,identity:t.sign.identity,signer:t.sign.signer,workDir:$(N,`signed`,n.id),bundleRoot:Z.root(S),entitlementsPath:$(N,`signed`,`${n.id}.entitlements.plist`),verbose:t.verbose,log:t=>ge.log(`${xU} ${t}`)}):H,ne=n.archName(t.arch,isArchIndependent(te)),re={settings:S,payload:te,prefix:n.prefix,depends:Y,recommends:X,archLabel:ne,mtime:F},ie=$(N,`out`);mkdirSync(ie,{recursive:!0});let ae=$(ie,n.fileName(S,ne));switch(n.id){case`deb`:writeFileSync(ae,await buildDeb(re));break;case`rpm`:writeFileSync(ae,await buildRpm(re));break;case`flatpak`:await buildFlatpakBundle({settings:S,stageDir:C,overlayDir:I,stageManifestFile:ZH,workDir:$(N,`flatpak`),target:ae,archLabel:ne,verbose:t.verbose});break;case`appimage`:{let n=appImageHostRequirements({app:S.app,minGjsVersion:S.minGjsVersion,minNodeVersion:S.minNodeVersion,namespaces:t.namespaces,optionalNamespaces:t.optionalNamespaces,bundledTypelibs:W.bundledTypelibs}),C=appDirFor(N),I=appDirPayload(S,te,n,await compileSchemasForPayload({payload:te,workDir:$(N,`appimage-schemas`)}));writePayload(C,I,``),stampAppDirTimes(C,I,F),ge.log(`${xU} the AppImage takes these from the host: ${n.join(`, `)}`);let H=findPinnedRuntime(ne);ge.log(`${xU} ${appImageRuntimeNotice(ne,H)}`),await buildAppImage({appDir:C,target:ae,archLabel:ne,runtimeFile:H,workDir:On(C),verbose:t.verbose});break}case`macos-app`:case`windows-dir`:writePayload(ae,te,Z.root(S));break;case`macos-app-dmg`:{let n=dmgVolumeDir(N);writePayload(n,te,``),await buildDmgImage({volumeName:dmgVolumeName(S),sourceDir:n,target:ae,workDir:On(n),verbose:t.verbose});break}case`macos-app-zip`:writeFileSync(ae,buildZip(zipEntriesFromPayload(te),F));break;case`windows-dir-zip`:writeFileSync(ae,buildZip(zipEntriesFromPayload(te,windowsProgramDirName(S)),F));break;case`msi`:{let n=$(N,`msi`);writePayload($(n,RH),te,Z.root(S)),await buildMsi({settings:S,files:te.map(t=>({path:t.path,source:`${RH}/${t.path}`})),programDirName:windowsProgramDirName(S),archLabel:ne,workDir:n,target:ae,verbose:t.verbose});break}default:{let t=n.id;throw Error(`gjsify ship: no packer is wired for format "${String(t)}".`)}}let oe=n.artifactKind===`directory`?directorySize(ae):statSync(ae).size;return t.notarize.kind===`notarize`&&(n.artifactKind===`directory`?ge.warn(`${xU} ${n.id} is a directory, and notarytool submits an archive or an installer — not notarised. The container format beside it is what carries the ticket.`):(await notarizeArtifact({plan:t.notarize,artifact:ae,verbose:t.verbose,log:t=>ge.log(`${xU} ${t}`)}),canCarryTicket(n.id)?await stapleArtifact({notary:t.notarize.notary,artifact:ae,verbose:t.verbose,log:t=>ge.log(`${xU} ${t}`)}):ge.warn(`${xU} ${n.id} is notarised and NOT stapled: \`stapler\` takes a UDIF image, a signed flat package or a code-signed bundle, and an archive is none of them. Apple's remedy is to staple each item that went INTO the archive and re-create it — for this artifact that is the \`.app\`, which \`--target macos-app\` writes beside it.`))),{format:n.id,path:ae,size:oe}}function printArtifacts(t,n){for(let S of n)ge.log(`${xU} ${S.format}: ${En(t,S.path)} (${S.size} bytes)`)}function assertCanPack(t){assertHostCanFinish(t),assertToolsInstalled(t)}function assertPackable(t,n,S,C=[]){if(t.length>0)return;if(C.length>0)throw Error(`gjsify ship: ${C.map(t=>t.id).join(` and `)} wrap the ${n.name} layout, and neither can run this project — ${C[0]?.interpreterGap??``}.\n Set \`gjsify.ship.app.${n.os}\` to "${C[0]?.interpreters.join(`" / "`)}" — it overrides \`gjsify.app\` for THIS target and\n leaves every other one alone, which is what lets one project be GJS on Linux and Node here.
|
|
1167
|
+
`)]},{tag:mU.BUILDTIME,type:4,value:[t.mtime]},{tag:mU.BUILDHOST,type:6,value:`localhost`},{tag:mU.SIZE,type:4,value:[n.reduce((t,n)=>t+n.data.byteLength,0)]},{tag:mU.LICENSE,type:6,value:N.license},{tag:mU.GROUP,type:9,value:[N.group]},{tag:mU.OS,type:6,value:`linux`},{tag:mU.ARCH,type:6,value:t.archLabel},{tag:mU.SOURCERPM,type:6,value:`${N.binaryName}-${F}.src.rpm`},{tag:mU.RPMVERSION,type:6,value:`4.20.0`},{tag:mU.ENCODING,type:6,value:`utf-8`},{tag:mU.FILESIZES,type:4,value:n.map(t=>t.data.byteLength)},{tag:mU.FILEMODES,type:3,value:n.map(t=>t.mode)},{tag:mU.FILERDEVS,type:3,value:n.map(()=>0)},{tag:mU.FILEMTIMES,type:4,value:n.map(()=>t.mtime)},{tag:mU.FILEDIGESTS,type:8,value:n.map(t=>t.isDirectory?``:hashHex(`sha256`,t.data))},{tag:mU.FILELINKTOS,type:8,value:n.map(()=>``)},{tag:mU.FILEFLAGS,type:4,value:n.map(()=>0)},{tag:mU.FILEUSERNAME,type:8,value:n.map(()=>`root`)},{tag:mU.FILEGROUPNAME,type:8,value:n.map(()=>`root`)},{tag:mU.FILEVERIFYFLAGS,type:4,value:n.map(()=>4294967295)},{tag:mU.FILEDEVICES,type:4,value:n.map(()=>1)},{tag:mU.FILEINODES,type:4,value:n.map((t,n)=>n+1)},{tag:mU.FILELANGS,type:8,value:n.map(()=>``)},{tag:mU.FILEDIGESTALGO,type:4,value:[_U]},{tag:mU.DIRINDEXES,type:4,value:H},{tag:mU.BASENAMES,type:8,value:W},{tag:mU.DIRNAMES,type:8,value:I},{tag:mU.PROVIDENAME,type:8,value:[N.binaryName]},{tag:mU.PROVIDEFLAGS,type:4,value:[gU.EQUAL]},{tag:mU.PROVIDEVERSION,type:8,value:[F]},{tag:mU.REQUIRENAME,type:8,value:Y.names},{tag:mU.REQUIREFLAGS,type:4,value:Y.flags},{tag:mU.REQUIREVERSION,type:8,value:Y.versions},...X.names.length>0?[{tag:mU.RECOMMENDNAME,type:8,value:X.names},{tag:mU.RECOMMENDFLAGS,type:4,value:X.flags},{tag:mU.RECOMMENDVERSION,type:8,value:X.versions}]:[],{tag:mU.PAYLOADFORMAT,type:6,value:`cpio`},{tag:mU.PAYLOADCOMPRESSOR,type:6,value:`gzip`},{tag:mU.PAYLOADFLAGS,type:6,value:`9`},{tag:mU.PAYLOADDIGEST,type:8,value:[hashHex(`sha256`,C)]},{tag:mU.PAYLOADDIGESTALGO,type:4,value:[_U]},{tag:mU.PAYLOADDIGESTALT,type:8,value:[hashHex(`sha256`,S)]}];return assertParallelFileArrays(Z,n.length),N.homepage&&Z.push({tag:mU.URL,type:6,value:N.homepage}),q.post!==void 0&&(Z.push({tag:mU.POSTIN,type:6,value:q.post}),Z.push({tag:mU.POSTINPROG,type:6,value:`/bin/sh`})),q.postun!==void 0&&(Z.push({tag:mU.POSTUN,type:6,value:q.postun}),Z.push({tag:mU.POSTUNPROG,type:6,value:`/bin/sh`})),Z}function assertParallelFileArrays(t,n){let S=new Set([mU.FILESIZES,mU.FILEMODES,mU.FILERDEVS,mU.FILEMTIMES,mU.FILEDIGESTS,mU.FILELINKTOS,mU.FILEFLAGS,mU.FILEUSERNAME,mU.FILEGROUPNAME,mU.FILEVERIFYFLAGS,mU.FILEDEVICES,mU.FILEINODES,mU.FILELANGS,mU.DIRINDEXES,mU.BASENAMES]);for(let C of t){if(!S.has(C.tag))continue;let t=Array.isArray(C.value)?C.value.length:1;if(t!==n)throw Error(`gjsify ship: internal error — rpm tag ${C.tag} has ${t} values for ${n} files.`)}}function buildRequires(t,n,S){let C=[],N=[],F=[];for(let n of t){let t=parseDepend(n);C.push(t.name),N.push(senseFor(t.relation)),F.push(t.version??``)}n.post!==void 0&&(C.push(`/bin/sh`),N.push(gU.INTERP|gU.SCRIPT_POST),F.push(``)),n.postun!==void 0&&(C.push(`/bin/sh`),N.push(gU.INTERP|gU.SCRIPT_POSTUN),F.push(``));for(let t of S)C.push(t),N.push(gU.FIND_REQUIRES),F.push(``);for(let[t,n]of vU)C.push(t),N.push(gU.RPMLIB|gU.LESS|gU.EQUAL),F.push(n);return{names:C,flags:N,versions:F}}function buildRecommends(t){let n=[],S=[],C=[];for(let N of t){let t=parseDepend(N);n.push(t.name),S.push(senseFor(t.relation)),C.push(t.version??``)}return{names:n,flags:S,versions:C}}function senseFor(t){switch(t){case`>=`:return gU.GREATER|gU.EQUAL;case`>`:return gU.GREATER;case`<=`:return gU.LESS|gU.EQUAL;case`<`:return gU.LESS;case`=`:return gU.EQUAL;default:return 0}}function hashHex(t,n){return createHash(t).update(n).digest(`hex`)}function hashBytes(t,n){return new Uint8Array(createHash(t).update(n).digest())}var mU,hU,gU,_U,vU,yU,bU=__esmMin(()=>{el(),hB(),cU(),DB(),MV(),pU(),OB(),jB(),AB(),mU={HEADERI18NTABLE:100,NAME:1e3,VERSION:1001,RELEASE:1002,SUMMARY:1004,DESCRIPTION:1005,BUILDTIME:1006,BUILDHOST:1007,SIZE:1009,LICENSE:1014,GROUP:1016,URL:1020,OS:1021,ARCH:1022,POSTIN:1024,POSTUN:1026,FILESIZES:1028,FILEMODES:1030,FILERDEVS:1033,FILEMTIMES:1034,FILEDIGESTS:1035,FILELINKTOS:1036,FILEFLAGS:1037,FILEUSERNAME:1039,FILEGROUPNAME:1040,SOURCERPM:1044,FILEVERIFYFLAGS:1045,PROVIDENAME:1047,REQUIREFLAGS:1048,REQUIRENAME:1049,REQUIREVERSION:1050,RECOMMENDNAME:5046,RECOMMENDVERSION:5047,RECOMMENDFLAGS:5048,RPMVERSION:1064,POSTINPROG:1086,POSTUNPROG:1088,FILEDEVICES:1095,FILEINODES:1096,FILELANGS:1097,PROVIDEFLAGS:1112,PROVIDEVERSION:1113,DIRINDEXES:1116,BASENAMES:1117,DIRNAMES:1118,PAYLOADFORMAT:1124,PAYLOADCOMPRESSOR:1125,PAYLOADFLAGS:1126,FILEDIGESTALGO:5011,ENCODING:5062,PAYLOADDIGEST:5092,PAYLOADDIGESTALGO:5093,PAYLOADDIGESTALT:5097},hU={SIZE:1e3,MD5:1004,PAYLOADSIZE:1007,SHA1HEADER:269,SHA256HEADER:273},gU={LESS:2,GREATER:4,EQUAL:8,INTERP:256,SCRIPT_POST:1024,SCRIPT_POSTUN:4096,FIND_REQUIRES:16384,RPMLIB:1<<24},_U=8,vU=[[`rpmlib(CompressedFileNames)`,`3.0.4-1`],[`rpmlib(FileDigests)`,`4.6.0-1`],[`rpmlib(PayloadFilesHavePrefix)`,`4.0-1`]],yU=new Set([`/usr`,`/usr/bin`,`/usr/lib`,`/usr/lib64`,`/usr/libexec`,`/usr/sbin`,`/usr/share`,`/usr/${kB.applications}`,`/usr/share/doc`,`/usr/share/icons`,`/usr/share/licenses`,`/usr/share/man`,`/usr/${kB.metainfo}`,`/usr/share/glib-2.0`,`/usr/${kB.schemas}`,`/usr/${kB.fonts}`,`/etc`,`/opt`,`/var`])});async function assemble(t){let n=process.cwd(),S=t.os===void 0?hostLayout():resolveLayout(t.os),C=await new Config().forCommand(n),N=C.ship??{},F=C.flatpak??{},I=resolveShipApp({project:C.app,perTarget:N.app,layoutOs:S.os}),H=I.app;I.overridden&&ge.log(`${xU} runtime for ${S.name}: ${H} — \`${I.key}\` overrides \`gjsify.app${C.app===void 0?``:`: "${C.app}"`}\`.`);let W=readPackageJson$2($(n,`package.json`))??{},q,Y=[];if(t.target!==void 0)q=resolveFormats(t.target,S);else if(N.targets!==void 0){let t=configuredFormats(N.targets,S);q=t.formats,t.dropped.length>0&&ge.log(`${xU} \`gjsify.ship.targets\` names ${t.dropped.join(`, `)}, which wrap another layout — not built for ${S.name}. Pass --target to ask for one explicitly.`)}else{let t=defaultFormatIds(S.os).map(t=>MH[t]);q=t.filter(t=>t.interpreters.includes(H)),Y=t.filter(t=>!t.interpreters.includes(H)),Y.length>0&&ge.log(`${xU} ${Y.map(t=>t.id).join(`, `)} wrap the ${S.name} layout but cannot run \`${H}\`, which \`${I.key}\` resolves to — ${Y[0]?.interpreterGap??``}. Set \`gjsify.ship.app.${S.os}\` to "${Y[0]?.interpreters.join(`" / "`)}" to ship this OS on that runtime; it leaves every other target on \`gjsify.app\`. Assembling the layout only; pass --target to be told the same thing as an error.`)}q.some(t=>t.id===`flatpak`)&&assertNoDroppedFlatpakModules(F),t.stage||assertPackable(q,S,t.os===void 0?`host`:`positional`,Y);let X=resolveSignPlan({flag:t.sign,config:N.sign,layoutOs:S.os}),Z=resolveNotaryPlan({flag:t.notarize,layoutOs:S.os,sign:X});if(t.stage&&assertNothingToSignYet(t),t.stage||(announceSigning(X,Z),X.kind===`sign`&&assertHostCanSign(X.signer)),t.stage||assertKindCanPack(q,resolveShipKind(N,F)),!t.stage)for(let t of q)assertCanPack(t);let te=parseDeclaredChannel(t.channel,`--channel`)??parseDeclaredChannel(N.channel,`gjsify.ship.channel`)??(q.some(t=>t.id===`flatpak`)?`flathub`:void 0);t[`skip-build`]||await runProjectBuild(n,te);let ne=resolveShipBundle({pkg:W,ship:N,layoutOs:S.os});ne.overridden&&ge.log(`${xU} entry for ${S.name}: ${ne.declared} — \`${ne.key}\` overrides \`gjsify.main\`.`);let re=discoverPayload({projectDir:n,pkg:W,ship:N,flatpakIcon:F.icon,declaredBundle:ne.declared,layoutOs:S.os,foreignBundles:ne.foreign}),{settings:ie,metadata:ae,warnings:oe}=resolveShipSettings({projectDir:n,pkg:W,ship:N,flatpak:F,cli:{outDir:t.out,arch:t.arch,layoutOs:S.os},discovered:re,app:H});for(let t of oe)ge.warn(`${xU} ${t}`);for(let t of q)assertFormatCanRunInterpreter(t,ie.app);let Q=readFileSync(ie.bundlePath,`utf-8`);assertEntryRunsUnder({interpreter:ie.app,source:Q,entry:En(n,ie.bundlePath)||ie.bundlePath,appKey:I.key,bundleKey:ne.key,layoutOs:S.os});let se=buildTimestamp(ie.bundlePath),ce={appId:ie.appId,name:ie.name,command:ie.binaryName,kind:ie.kind,metadata:ae,channel:te,configKey:`gjsify.ship`,copyrightYear:new Date(se*1e3).getUTCFullYear()};for(let t of validateAppMetadata(ce))ge.warn(`${xU} ${t.field} is not set — ${t.hint}`);ie.licenseFile!==void 0&&On(ie.licenseFile)!==n&&ge.log(`${xU} licence text from ${En(n,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=await resolveCarriedRuntime(S,ie,n),de={bundleFiles:re.bundleFiles,launcher:renderLauncher(ie,kn(ie.bundlePath),S,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:se},fe=Cn(n,ie.outDir),pe=$(fe,`stage`),me=[...planStage(ie,de),...S.os===`linux`?[]:await compileSchemasForStage({schemaFiles:ie.schemaFiles,workDir:$(fe,`schemas`)})],he=ie.kind===`app`&&S.icon!==void 0&&(S.icon.required||ie.iconFiles.length>0)?await resolveAppIcon({iconFiles:ie.iconFiles,appId:ie.appId,sizes:S.icon.sizes,target:S.icon.writes}):void 0;he!==void 0&&ge.log(`${xU} icon: ${iconSizes(he).join(`/`)} px, ${he.source}`);let _e=placeStage(S,{...ie,icon:he},me,ue.files);if(writeStage(pe,_e),ge.log(`${xU} staged ${_e.length} file(s) for ${S.name} in ${En(n,pe)}/`),t.verbose)for(let t of _e)ge.log(`${xU} ${t.path}`);if(assertPayloadMatchesArch(readStage([pe],_e),ie.arch,{exempt:S===mV.windows?new Set([windowsGuiLauncherPath(ie)]):void 0}),S.os!==`linux`){let t=linuxInstallDependent(me);if(t.length>0){ge.warn(`${xU} the ${S.name} layout carries ${t.length} file(s) whose Linux correctness comes from a package install step it has no equivalent for:`);let n={aborts:`ABORTS: `,unknown:`UNCLASSIFIED: `,inert:``};for(let{path:S,verdict:C,why:N}of t)ge.warn(`${xU} ${n[C]??``}${S} — ${N}`)}for(let t of ue.found)ge.log(`${xU} carries its own ${t}`);for(let t of ue.missing)ge.warn(`${xU} ${t}`);ue.launcher.interpreter===void 0&&S.runtimeGap!==void 0&&ge.warn(`${xU} ${S.runtimeGap}`),S.fontGap!==void 0&&me.some(t=>isUnder(t.path,kB.fonts))&&ge.warn(`${xU} ${S.fontGap}`),S.arches!==null&&!S.arches.only.includes(ie.arch)&&ge.warn(`${xU} this stage is labelled ${ie.arch} and the ${S.name} layout has no runtime for it — ${S.arches.why}. Nothing can pack this stage; \`--arch ${S.arches.only.join(`|`)}\` is what produces an artifact.`)}let ve=scanGiRequirements(Q),ye=ve.namespaces,be=ve.optional;if(t.verbose){let t=ye.filter(t=>!be.includes(t));ge.log(`${xU} gi namespaces: ${ye.join(`, `)||`(none)`}`),be.length>0&&(ge.log(`${xU} gi optional namespaces: ${be.join(`, `)}`),ge.log(`${xU} gi required namespaces: ${t.join(`, `)||`(none)`}`))}let xe=new Map;for(let t of q)xe.set(t.id,(await planOverlay(ie,t,de)).map(t=>({...t,path:place(S,ie,t.path)})));let Se=readPayloadFacts(me);for(let t of q){if(t.depends===null)continue;let n=deriveDepends(t.depends,{namespaces:ye,optionalNamespaces:be,hasIcons:Se.hasIcons,hasSchemas:Se.hasSchemas,interpreter:ie.app,extra:ie.extraDepends[t.depends],typelibPackages:ie.typelibPackages,bundledTypelibs:Se.bundledTypelibs,minGjsVersion:ie.minGjsVersion,minNodeVersion:ie.minNodeVersion});for(let S of n.unmappedOptional)ge.warn(`${xU} gi://${S} is imported optionally, but no ${t.depends} package is known to ship its typelib, so no Recommends entry names it. The package builds and runs without it. Add the row if the namespace should be recommended: \`gjsify.ship.typelibPackages.${S} = { "${t.depends}": "…" }\`.`);let S=ie.app===`node`?warnAboutNodeFloor(t.depends,ie.minNodeVersion):warnAboutGjsFloor(t.depends,ie.minGjsVersion);for(let t of S)ge.warn(`${xU} ${t}`)}let Ce=writeStageManifest({stageDir:pe,settings:ie,formats:q,mtime:se,namespaces:ye,optionalNamespaces:be,staged:_e,overlay:xe});if(t.stage){let t=Y.length>0?`(none — ${Y.map(t=>t.id).join(` and `)} need \`gjsify.ship.app.${S.os}: "node"\`)`:formatIdsFor(S.os).length===0?`(none — no format wraps the ${S.name} layout)`:`(none asked for)`,n=Ce.formats.join(`, `)||t;ge.log(`${xU} stage manifest: ${formatTarget(Ce.target)}, formats ${n}`);return}let we=[];for(let n of q)we.push(await packOne({format:n,settings:ie,arch:ie.arch,staged:_e,overlay:xe.get(n.id)??[],stageDir:pe,outRoot:fe,namespaces:ye,optionalNamespaces:be,mtime:se,sign:X,notarize:Z,verbose:t.verbose}));printArtifacts(n,we)}function assertNothingToSignYet(t){let n=t.sign===void 0?t.notarize===void 0?void 0:`--notarize`:`--sign`;if(n!==void 0)throw Error(`gjsify ship: ${n} belongs to the finish phase, and --stage produces no artifact to sign — it writes the tree a packing host reads back. Assemble here, then run \`gjsify ship --from-stage <dir> --sign <identity>\` on the host that holds the identity (ADR 0024 § A2, § A14).`)}function announceSigning(t,n){t.kind===`skip`&&ge.warn(`${xU} ${t.message}`),n.kind===`skip`&&t.kind===`sign`&&ge.warn(`${xU} ${n.message}`)}async function resolveCarriedRuntime(t,n,S){let C={files:[],launcher:{},found:[],missing:[]};if(t.os===`linux`||n.app!==`node`)return C;let N=`${t.os}-${n.arch}`;if(!isGtkRuntimeTarget(N))return C;let F=await acquireGtkRuntime({target:N,version:cliVersion(),discovery:{cwd:S},ensure:async t=>(await ensurePkgDir(parseSpec(t),{verbose:!1,cacheMaxAge:CU,frozen:!1})).pkgDir,log:t=>ge.log(`${xU} ${t}`)});return stageAppRuntime({layout:t,identity:n,target:N,cwd:S,interpreter:isNodeRuntimeTarget(N)?resolveNodeRuntime(N,{cwd:S}):null,...F.kind===`fetched`?{fetchedGtkRuntimeDir:F.dir}:{},...F.kind===`failed`?{gtkFetchFailure:F.reason}:{}})}async function finishFromStage(t,n){if(t.stage)throw Error("gjsify ship: --stage and --from-stage are the two halves of one split and cannot run together. `--stage` assembles a payload and stops; `--from-stage <dir>` packs one that is already assembled. Run them as two commands, on the host each belongs on (ADR 0024 § A2).");if(t[`skip-build`])throw Error(`gjsify ship: --from-stage never runs a build — the payload it packs was built and staged by an earlier run — so --skip-build has nothing to skip. Drop it.`);if(t.arch!==void 0)throw Error("gjsify ship: --arch is decided when the stage is assembled, not when it is packed: the launcher, the payload and the recorded target were all fixed then. Pass --arch to `gjsify ship --stage`, and use `--expect-target <os>-<arch>` here to assert which leg you are packing.");if(t.os!==void 0)throw Error(`gjsify ship: the layout is decided when the stage is assembled, so "${t.os}" has nothing to change here — the staged tree already IS one OS's layout. Use \`--expect-target <os>-<arch>\` to assert which one you are packing.`);let S=process.cwd(),C=Cn(S,n),N=readStageManifest(C);assertExpectedTarget(N,t[`expect-target`]);let F=layoutForOs(N.target.os);t.target===void 0&&assertPackable(N.formats.map(t=>MH[t]),F,`stage`,defaultFormatIds(F.os).map(t=>MH[t]).filter(t=>!t.interpreters.includes(N.settings.app)));let I=resolveFormats(t.target??N.formats,F);assertFormatsStaged(N,I);for(let t of I)assertCanPack(t);let H=resolveSignPlan({flag:t.sign,layoutOs:F.os}),W=resolveNotaryPlan({flag:t.notarize,layoutOs:F.os,sign:H});announceSigning(H,W),H.kind===`sign`&&assertHostCanSign(H.signer);for(let t of warnOnToolSkew(N))ge.warn(`${xU} ${t}`);let{mtime:q,warnings:Y}=resolveStageMtime(N);for(let t of Y)ge.warn(`${xU} ${t}`);if(ge.log(`${xU} packing ${N.settings.binaryName} ${N.settings.version}-${N.settings.release} for ${formatTarget(N.target)} from ${En(S,C)||`.`}/`),t.verbose){for(let t of N.staged)ge.log(`${xU} ${t.path}`);ge.log(`${xU} gi namespaces: ${N.namespaces.join(`, `)||`(none)`}`),(N.optionalNamespaces??[]).length>0&&ge.log(`${xU} gi optional namespaces: ${N.optionalNamespaces?.join(`, `)}`)}let X=t.out===void 0?On(C):Cn(S,t.out),Z=[];for(let n of I){if(assertFormatCanRunInterpreter(n,N.settings.app),n.depends!==null){let t=N.settings.app===`node`?warnAboutNodeFloor(n.depends,N.settings.minNodeVersion):warnAboutGjsFloor(n.depends,N.settings.minGjsVersion);for(let n of t)ge.warn(`${xU} ${n}`)}Z.push(await packOne({format:n,settings:N.settings,arch:N.target.arch,staged:N.staged,overlay:overlayFiles(N,n.id),stageDir:C,outRoot:X,namespaces:N.namespaces,optionalNamespaces:N.optionalNamespaces??[],mtime:q,sign:H,notarize:W,verbose:t.verbose}))}printArtifacts(S,Z)}async function packOne(t){let{format:n,settings:S,stageDir:C,outRoot:N,mtime:F}=t;assertOverlayIsLicensed(n.id,S.binaryName,t.overlay);let I=$(N,`overlay`,n.id);writeStage(I,t.overlay);let H=readStage([C,I],[...t.staged,...t.overlay]),W=readPayloadFacts(H),q=n.depends===null?{requires:[],recommends:[],unmappedOptional:[]}:deriveDepends(n.depends,{namespaces:t.namespaces,optionalNamespaces:t.optionalNamespaces,hasIcons:W.hasIcons,hasSchemas:W.hasSchemas,interpreter:S.app,extra:S.extraDepends[n.depends],typelibPackages:S.typelibPackages,bundledTypelibs:W.bundledTypelibs,minGjsVersion:S.minGjsVersion,minNodeVersion:S.minNodeVersion}),Y=q.requires,X=q.recommends;assertPayloadMatchesArch(H,t.arch);let Z=layoutForOs(n.layoutOs);assertLauncherMatchesInterpreter(H,Z,S,S.app),assertLayoutSupportsArch(Z,t.arch);let te=t.sign.kind===`sign`?await signPayload({payload:H,identity:t.sign.identity,signer:t.sign.signer,workDir:$(N,`signed`,n.id),bundleRoot:Z.root(S),entitlementsPath:$(N,`signed`,`${n.id}.entitlements.plist`),verbose:t.verbose,log:t=>ge.log(`${xU} ${t}`)}):H,ne=n.archName(t.arch,isArchIndependent(te)),re={settings:S,payload:te,prefix:n.prefix,depends:Y,recommends:X,archLabel:ne,mtime:F},ie=$(N,`out`);mkdirSync(ie,{recursive:!0});let ae=$(ie,n.fileName(S,ne));switch(n.id){case`deb`:writeFileSync(ae,await buildDeb(re));break;case`rpm`:writeFileSync(ae,await buildRpm(re));break;case`flatpak`:await buildFlatpakBundle({settings:S,stageDir:C,overlayDir:I,stageManifestFile:ZH,workDir:$(N,`flatpak`),target:ae,archLabel:ne,verbose:t.verbose});break;case`appimage`:{let n=appImageHostRequirements({app:S.app,minGjsVersion:S.minGjsVersion,minNodeVersion:S.minNodeVersion,namespaces:t.namespaces,optionalNamespaces:t.optionalNamespaces,bundledTypelibs:W.bundledTypelibs}),C=appDirFor(N),I=appDirPayload(S,te,n,await compileSchemasForPayload({payload:te,workDir:$(N,`appimage-schemas`)}));writePayload(C,I,``),stampAppDirTimes(C,I,F),ge.log(`${xU} the AppImage takes these from the host: ${n.join(`, `)}`);let H=findPinnedRuntime(ne);ge.log(`${xU} ${appImageRuntimeNotice(ne,H)}`),await buildAppImage({appDir:C,target:ae,archLabel:ne,runtimeFile:H,workDir:On(C),verbose:t.verbose});break}case`macos-app`:case`windows-dir`:writePayload(ae,te,Z.root(S));break;case`macos-app-dmg`:{let n=dmgVolumeDir(N);writePayload(n,te,``),await buildDmgImage({volumeName:dmgVolumeName(S),sourceDir:n,target:ae,workDir:On(n),verbose:t.verbose});break}case`macos-app-zip`:writeFileSync(ae,buildZip(zipEntriesFromPayload(te),F));break;case`windows-dir-zip`:writeFileSync(ae,buildZip(zipEntriesFromPayload(te,windowsProgramDirName(S)),F));break;case`msi`:{let n=$(N,`msi`);writePayload($(n,RH),te,Z.root(S)),await buildMsi({settings:S,files:te.map(t=>({path:t.path,source:`${RH}/${t.path}`})),programDirName:windowsProgramDirName(S),archLabel:ne,workDir:n,target:ae,verbose:t.verbose});break}default:{let t=n.id;throw Error(`gjsify ship: no packer is wired for format "${String(t)}".`)}}let oe=n.artifactKind===`directory`?directorySize(ae):statSync(ae).size;return t.notarize.kind===`notarize`&&(n.artifactKind===`directory`?ge.warn(`${xU} ${n.id} is a directory, and notarytool submits an archive or an installer — not notarised. The container format beside it is what carries the ticket.`):(await notarizeArtifact({plan:t.notarize,artifact:ae,verbose:t.verbose,log:t=>ge.log(`${xU} ${t}`)}),canCarryTicket(n.id)?await stapleArtifact({notary:t.notarize.notary,artifact:ae,verbose:t.verbose,log:t=>ge.log(`${xU} ${t}`)}):ge.warn(`${xU} ${n.id} is notarised and NOT stapled: \`stapler\` takes a UDIF image, a signed flat package or a code-signed bundle, and an archive is none of them. Apple's remedy is to staple each item that went INTO the archive and re-create it — for this artifact that is the \`.app\`, which \`--target macos-app\` writes beside it.`))),{format:n.id,path:ae,size:oe}}function printArtifacts(t,n){for(let S of n)ge.log(`${xU} ${S.format}: ${En(t,S.path)} (${S.size} bytes)`)}function assertCanPack(t){assertHostCanFinish(t),assertToolsInstalled(t)}function assertPackable(t,n,S,C=[]){if(t.length>0)return;if(C.length>0)throw Error(`gjsify ship: ${C.map(t=>t.id).join(` and `)} wrap the ${n.name} layout, and neither can run this project — ${C[0]?.interpreterGap??``}.\n Set \`gjsify.ship.app.${n.os}\` to "${C[0]?.interpreters.join(`" / "`)}" — it overrides \`gjsify.app\` for THIS target and\n leaves every other one alone, which is what lets one project be GJS on Linux and Node here.
|
|
1168
1168
|
\`gjsify ship ${n.name} --stage\` assembles the tree either way.`);let N=formatIdsFor(n.os).sort();if(N.length>0){let t=S===`stage`?`${n.name} --stage --target`:`${n.name} --target`;throw Error(`gjsify ship: this run records no formats for the ${n.name} layout, so there is nothing to pack — and it is not that none exist: ${N.join(`, `)} wrap it.\n An empty list means none were SELECTED. \`gjsify.ship.targets\` is filtered to the layout being assembled,
|
|
1169
1169
|
so a configured list naming only another OS's formats leaves this one empty and says so at stage time.
|
|
1170
1170
|
Name one where the payload is assembled: \`gjsify ship ${t} ${N[0]}\`.`)}let F=defaultFormatIds(`linux`).join(`,`),I={host:`This host is ${process.platform}, so \`gjsify ship\` assembled the ${n.name} layout. Assembly is not host-bound (ADR 0024 § A1), so the Linux packages are still one word away: \`gjsify ship linux\` builds ${F} from right here.`,positional:`\`gjsify ship ${n.name} --stage\` assembles the payload and stops, which is the whole of what this command does for that OS today.`,stage:`This stage carries the ${n.name} layout and nothing here can wrap it — a stage is a build intermediate, not an artifact. Keep it for the milestone that packs it, or re-assemble with \`gjsify ship linux --stage\` if a Linux package is what you wanted.`}[S];throw Error(`gjsify ship: no format wraps the ${n.name} layout, so there is nothing to pack. ${I} Every layout this gjsify knows has one (ADR 0024 stages 2-5), so this is a layout added without a \`FORMATS\` row.`)}function assertFormatCanRunInterpreter(t,n){if(!t.interpreters.includes(n))throw Error(`gjsify ship: this ${t.layoutOs} target runs \`${n}\`, and the ${t.id} runtime cannot run it — it provides ${t.interpreters.join(`, `)}.\n ${t.interpreterGap}.\n Build the formats that wrap this layout and can run it, or set \`gjsify.ship.app.${t.layoutOs}: "${t.interpreters.join(`" / "`)}"\` (which overrides \`gjsify.app\` for this target alone).`)}async function runProjectBuild(t,n){if(typeof readPackageJson$2($(t,`package.json`))?.scripts?.build!=`string`)throw Error("gjsify ship: this project has no `build` script to run. Add one, or pass --skip-build to package what is already built.");ge.log(`${xU} running the project's build script`);let S=await spawnToCompletion(`gjsify`,[`run`,`build`],{completion:`return`,cwd:t,stdio:`inherit`,env:n===void 0?void 0:{...process.env,[lh]:n},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 xU,SU,CU,wU=__esmMin(()=>{_e(),uh(),Bd(),In(),MI(),HR(),jz(),tF(),IR(),ih(),U_(),NV(),DB(),aH(),oH(),JV(),hH(),vH(),kz(),yH(),IB(),bH(),FH(),_V(),XV(),AB(),SV(),zH(),qH(),YH(),gI(),MV(),tH(),nU(),rU(),bU(),WV(),QH(),$H(),xU=`[gjsify ship]`,SU={command:`ship [os]`,description:`Build installable artifacts (${NH.join(`, `)}) from the current project.`,builder:t=>t.positional(`os`,{type:`string`,description:`Operating system whose LAYOUT to assemble (${hV.join(`|`)}, ADR 0024 § A2). Default: this host. Assembly is not host-bound, so any of them can be staged anywhere.`}).option(`target`,{type:`string`,array:!0,description:`Formats to build, comma-separated or repeated. Default: every format wrapping the target OS's layout that needs no extra tooling — on linux, ${defaultFormatIds(`linux`).join(`,`)}. Also available for linux, and opt-in because it needs tooling this CLI does not carry: ${formatIdsFor(`linux`).filter(t=>!defaultFormatIds(`linux`).includes(t)).join(`, `)}.`}).option(`out`,{type:`string`,normalize:!0,description:"Output root, relative to the project. Default: `gjsify.ship.outDir`, else `ship`."}).option(`stage`,{type:`boolean`,default:!1,description:`Produce the staged payload and stop, without packing anything.`}).option(`from-stage`,{type:`string`,normalize:!0,description:"Pack a staged payload written by an earlier `--stage` run. Needs no project: the stage carries its own closure."}).option(`expect-target`,{type:`string`,description:"With --from-stage: refuse unless the stage was assembled for this `<os>-<arch>`, e.g. `linux-arm64`."}).option(`channel`,{type:`string`,choices:[...sh],description:"Distribution channel (ADR 0113). Overrides gjsify.ship.channel; `--target flatpak` implies flathub. Passed to the project build, and gates the metainfo donation URL."}).option(`skip-build`,{type:`boolean`,default:!1,description:"Package what is already built instead of running the project's `build` script."}).option(`arch`,{type:`string`,description:"Target architecture in `process.arch` spelling. Default: this host."}).option(`sign`,{type:`string`,requiresArg:!0,description:"Sign the payload with this identity, e.g. a Developer ID name or SHA-1 fingerprint. `-` signs ad-hoc and needs no developer identity. Default: `gjsify.ship.sign.<darwin|win32>.identity`; absent means unsigned, which is a legitimate output."}).option(`notarize`,{type:`string`,requiresArg:!0,description:"Submit the signed artifact to Apple with this `notarytool` keychain profile. Needs --sign; darwin only."}).option(`verbose`,{type:`boolean`,default:!1,description:`Print each staged file, the GI namespaces the bundle imports, and every tool a host-bound packer invokes.`}),handler:async t=>{if(t[`from-stage`]!==void 0)return await finishFromStage(t,t[`from-stage`]);await assemble(t)}},CU=1440*7});function forceExit(t){if(process.exitCode=t,!gjsExit(t))return process.exit(t)}var TU=__esmMin(()=>{p_()});function workspaceLinkTarget(t,n){return EU===`junction`?Cn(n):En(On(t),n)}function applyPlatformConfigFromFlags(t){for(let[n,S]of[[`os`,`npm_config_os`],[`cpu`,`npm_config_cpu`],[`libc`,`npm_config_libc`]]){let C=t[n];if(typeof C!=`string`)continue;let N=C.trim();N!==``&&(process.env[S]=N)}t.force&&(process.env.npm_config_force=`true`)}function isAbortedFromOverallTimeout(t){if(!t||typeof t!=`object`)return!1;let n=t.name;if(n===`AbortError`)return!0;let S=t.message;return!!(typeof S==`string`&&S.includes(`install-overall-timeout`)||n===`RegistryTimeoutError`)}function readCliVersionFrom(t){try{if(!existsSync(t))return null;let n=JSON.parse(readFileSync(t,`utf-8`));if(n.name===kU&&typeof n.version==`string`)return n.version}catch{}return null}function readRunningCliVersion(){try{let t=On(Cn(fileURLToPath(import.meta.url)));for(let n=0;n<8&&t!==On(t);n++){let n=readCliVersionFrom($(t,`package.json`));if(n)return n;t=On(t)}}catch{}return null}function readWorkspaceCliVersion(t){let n=readPackageJson$1($(t,`package.json`)),S=!1;for(let t of[`dependencies`,`devDependencies`,`optionalDependencies`]){let C=n?.[t]?.[kU];typeof C==`string`&&(S=!0);let N=typeof C==`string`?/^[\^~=v]*(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)$/.exec(C.trim()):null;if(N)return N[1]}if(!S){let n=readCliVersionFrom($(t,`node_modules`,kU,`package.json`));if(n)return n}return readCliVersionFrom($(t,`packages`,`infra`,`cli`,`package.json`))}function warnOnCliVersionSkew(t){if(process.env.GJSIFY_NO_VERSION_SKEW_WARNING===`1`)return;let n=readRunningCliVersion(),S=readWorkspaceCliVersion(t);!n||!S||n===S||ge.warn(`gjsify install: version skew — you are running @gjsify/cli v${n}, but this workspace pins v${S}.\n A mismatched CLI can stall the install (lock discarded → full re-resolve) or silently produce a wrong build.\n Align them: run \`gjsify self-update\` (global CLI) or use the workspace-local \`node_modules/.bin/gjsify\`.\n Suppress this with GJSIFY_NO_VERSION_SKEW_WARNING=1.`)}function isWorkspaceRoot(t){let n=readPackageJson$1($(t,`package.json`));return n?n.workspaces!==void 0:!1}function optionalDependencyNames(t){let n=new Set,S=new Set;for(let C of t){let t=new Set(Object.keys(C.optionalDependencies??{}));for(let S of t)n.add(S);for(let n of[`dependencies`,`devDependencies`])for(let N of Object.keys(C[n]??{}))t.has(N)||S.add(N)}for(let t of S)n.delete(t);return n}function depKindFromArgs(t){return t[`save-dev`]?`devDependencies`:t[`save-peer`]?`peerDependencies`:t[`save-optional`]?`optionalDependencies`:`dependencies`}function activateDevLinks(t,n){let S=prepareDevLinks(devLinkRoot(t));if(!S)return null;let C=applyDevLinks(S.links);if(!n)return S;ge.log(`gjsify install: development link ACTIVE (${S.overridePath}) — ${S.links.length} package(s) come from ${S.checkout}, linked rather than fetched (${C.length} (re)written, ${S.links.length-C.length} already current):`);let N=S.links.map(t=>t.name),F=N.slice(0,12);return ge.log(` ${F.join(`, `)}${N.length>F.length?`, +${N.length-F.length} more`:``}`),ge.log(" `gjsify unlink` restores the registry copies; `gjsify install --immutable` refuses while it exists."),S}function reportRewiredDevLinks(t){if(!t)return;let n=applyDevLinks(t.links);n.length!==0&&ge.log(`gjsify install: re-applied ${n.length} development link(s) the install had replaced: ${n.map(t=>t.name).join(`, `)}`)}async function projectInstallNative(t,n){let S=process.cwd(),C=$(S,`package.json`),N=[`.pnp.cjs`,`.pnp.loader.mjs`].filter(t=>existsSync($(S,t)));if(N.length>0)throw Error(`gjsify install uses the node_modules linker and cannot run in a Yarn PnP project (found ${N.join(`, `)} in ${S}).\n\n• If this project uses \`gjsify install\` to manage dependencies, these PnP files are stale residue from an earlier \`yarn install\` — remove them and re-run:\n rm -f .pnp.cjs .pnp.loader.mjs && rm -rf .yarn/cache .yarn/unplugged\n gjsify install\n\n• If instead you want Yarn to manage dependencies, set \`nodeLinker: node-modules\` in .yarnrc.yml and run \`yarn install\` (not \`gjsify install\`).`);if(!t.packages||t.packages.length===0){let C=isWorkspaceRoot(S)?S:findWorkspaceRoot(S);if(C){C!==S&&ge.log(`gjsify install: resolved workspace root ${C} (from ${S}); installing the workspace.`),await workspaceInstall(C,t,n);return}}let F,I=readPackageJson$1(C),H=I?projectSpecsFromPackageJson(I):[];if(t.packages&&t.packages.length>0){let n=new Set(t.packages.map(t=>parseSpec$2(t).name));F=[...H.filter(t=>!n.has(parseSpec$2(t).name)),...t.packages]}else{if(!I)throw Error(`gjsify install: no package.json in ${S}`);if(F=H,F.length===0){ge.log(`gjsify install: no dependencies declared in package.json — nothing to do.`);return}}mkdirSync(S,{recursive:!0});let W=makeProgressReporter({enabled:!t.verbose&&!t.quiet&&t.progress!==!1}),q=await acquireInstallLock(S,{signal:n});try{let N=activateDevLinks(S,!0),H=await installPackages({prefix:S,specs:F,verbose:t.verbose,lockfile:!t.immutable,frozen:t.immutable,refreshLockfile:t[`refresh-lockfile`],signal:n,progress:W,optionalSpecs:new Set([...optionalDependencyNames(I?[I]:[]),...t[`save-optional`]?(t.packages??[]).map(t=>parseSpec$2(t).name):[]]),linkedNames:N?.names});if(reportRewiredDevLinks(N),t.packages&&t.packages.length>0&&I){let n=depKindFromArgs(t);for(let S of t.packages){let{name:t,range:C}=parseSpec$2(S),N=H.installed.find(n=>n.name===t);addDependencyEntry(I,t,C??(N?defaultRangeFromVersion(N.version):`latest`),n)}writePackageJson(C,I),t.immutable||syncLockfileRequested(S,projectSpecsFromPackageJson(I))}}finally{q.release()}}function syncLockfileRequested(t,n){let S=$(t,`gjsify-lock.json`);if(existsSync(S))try{let t=JSON.parse(readFileSync(S,`utf-8`)),C=[...n].sort(),N=[...t.requested??[]].sort();if(C.length===N.length&&C.every((t,n)=>t===N[n]))return;t.requested=n,atomicWriteStrict(S,JSON.stringify(t,null,2)+`
|