@jrtilak-recall/plugin-creator 0.0.2-alpha.0 → 0.1.0

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/README.md CHANGED
@@ -1,15 +1,4 @@
1
1
  # @jrtilak-recall/plugin-creator
2
2
 
3
- CLI tools for building Recall plugins.
4
-
5
- ```sh
6
- bunx @jrtilak-recall/plugin-creator build
7
- ```
8
-
9
- ```sh
10
- bunx @jrtilak-recall/plugin-creator --help
11
- bunx @jrtilak-recall/plugin-creator build --help
12
- bunx @jrtilak-recall/plugin-creator build ./my-plugin --out-dir dist --zip
13
- ```
14
-
15
- See [CHANGELOG.md](./CHANGELOG.md) for release notes.
3
+ - [Documentation](https://docs.recall.jrtilak.dev/core-packages/plugin-creator/)
4
+ - [Changelog](https://docs.recall.jrtilak.dev/changelogs/plugin-creator/)
package/dist/cli.js CHANGED
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- function F$($){return $==null?[]:Array.isArray($)?$:[$]}function VJ($,J,E,H){var B,Y=$[J],V=~H.string.indexOf(J)?E==null||E===!0?"":String(E):typeof E==="boolean"?E:~H.boolean.indexOf(J)?E==="false"?!1:E==="true"||($._.push((B=+E,B*0===0)?B:E),!!E):(B=+E,B*0===0)?B:E;$[J]=Y==null?V:Array.isArray(Y)?Y.concat(V):[Y,V]}function XJ($,J){$=$||[],J=J||{};var E,H,B,Y,V,X={_:[]},Q=0,R=0,K=0,F=$.length;let q=J.alias!==void 0,P=J.unknown!==void 0,O=J.default!==void 0;if(J.alias=J.alias||{},J.string=F$(J.string),J.boolean=F$(J.boolean),q)for(E in J.alias){H=J.alias[E]=F$(J.alias[E]);for(Q=0;Q<H.length;Q++)(J.alias[H[Q]]=H.concat(E)).splice(Q,1)}for(Q=J.boolean.length;Q-- >0;){H=J.alias[J.boolean[Q]]||[];for(R=H.length;R-- >0;)J.boolean.push(H[R])}for(Q=J.string.length;Q-- >0;){H=J.alias[J.string[Q]]||[];for(R=H.length;R-- >0;)J.string.push(H[R])}if(O){for(E in J.default)if(Y=typeof J.default[E],H=J.alias[E]=J.alias[E]||[],J[Y]!==void 0){J[Y].push(E);for(Q=0;Q<H.length;Q++)J[Y].push(H[Q])}}let G=P?Object.keys(J.alias):[];for(Q=0;Q<F;Q++){if(B=$[Q],B==="--"){X._=X._.concat($.slice(++Q));break}for(R=0;R<B.length;R++)if(B.charCodeAt(R)!==45)break;if(R===0)X._.push(B);else if(B.substring(R,R+3)==="no-"){if(Y=B.substring(R+3),P&&!~G.indexOf(Y))return J.unknown(B);X[Y]=!1}else{for(K=R+1;K<B.length;K++)if(B.charCodeAt(K)===61)break;Y=B.substring(R,K),V=B.substring(++K)||Q+1===F||(""+$[Q+1]).charCodeAt(0)===45||$[++Q],H=R===2?[Y]:Y;for(K=0;K<H.length;K++){if(Y=H[K],P&&!~G.indexOf(Y))return J.unknown("-".repeat(R)+Y);VJ(X,Y,K+1<H.length||V,J)}}}if(O){for(E in J.default)if(X[E]===void 0)X[E]=J.default[E]}if(q)for(E in X){H=J.alias[E]||[];while(H.length>0)X[H.shift()]=X[E]}return X}function w$($){return $.replace(/[<[].+/,"").trim()}function QJ($){let J=/<([^>]+)>/g,E=/\[([^\]]+)\]/g,H=[],B=(X)=>{let Q=!1,R=X[1];if(R.startsWith("..."))R=R.slice(3),Q=!0;return{required:X[0].startsWith("<"),value:R,variadic:Q}},Y;while(Y=J.exec($))H.push(B(Y));let V;while(V=E.exec($))H.push(B(V));return H}function KJ($){let J={alias:{},boolean:[]};for(let[E,H]of $.entries()){if(H.names.length>1)J.alias[H.names[0]]=H.names.slice(1);if(H.isBoolean)if(H.negated){if(!$.some((B,Y)=>{return Y!==E&&B.names.some((V)=>H.names.includes(V))&&typeof B.required==="boolean"}))J.boolean.push(H.names[0])}else J.boolean.push(H.names[0])}return J}function x$($){return $.sort((J,E)=>{return J.length>E.length?-1:1})[0]}function g$($,J){return $.length>=J?$:`${$}${" ".repeat(J-$.length)}`}function RJ($){return $.replaceAll(/([a-z])-([a-z])/g,(J,E,H)=>{return E+H.toUpperCase()})}function FJ($,J,E){let H=$;for(let B=0;B<J.length;B++){let Y=J[B];if(B===J.length-1){H[Y]=E;return}if(H[Y]==null){let V=+J[B+1]>-1;H[Y]=V?[]:{}}H=H[Y]}}function WJ($,J){for(let E of Object.keys(J)){let H=J[E];if(H.shouldTransform){if($[E]=[$[E]].flat(),typeof H.transformFunction==="function")$[E]=$[E].map(H.transformFunction)}}}function qJ($){let J=/([^\\/]+)$/.exec($);return J?J[1]:""}function z$($){return $.split(".").map((J,E)=>{return E===0?RJ(J):J}).join(".")}var E$=class extends Error{constructor($){super($);if(this.name="CACError",typeof Error.captureStackTrace!=="function")this.stack=Error($).stack}},LJ=class{rawName;description;name;names;isBoolean;required;config;negated;constructor($,J,E){if(this.rawName=$,this.description=J,this.config=Object.assign({},E),$=$.replaceAll(".*",""),this.negated=!1,this.names=w$($).split(",").map((H)=>{let B=H.trim().replace(/^-{1,2}/,"");if(B.startsWith("no-"))this.negated=!0,B=B.replace(/^no-/,"");return z$(B)}).sort((H,B)=>H.length>B.length?1:-1),this.name=this.names.at(-1),this.negated&&this.config.default==null)this.config.default=!0;if($.includes("<"))this.required=!0;else if($.includes("["))this.required=!1;else this.isBoolean=!0}},W$,H$;if(typeof process<"u"){let $;if(typeof Deno<"u"&&typeof Deno.version?.deno==="string")$="deno";else if(typeof Bun<"u"&&typeof Bun.version==="string")$="bun";else $="node";H$=`${process.platform}-${process.arch} ${$}-${process.version}`,W$=process.argv}else if(typeof navigator>"u")H$="unknown";else H$=`${navigator.platform} ${navigator.userAgent}`;var y$=class{rawName;description;config;cli;options;aliasNames;name;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;constructor($,J,E={},H){this.rawName=$,this.description=J,this.config=E,this.cli=H,this.options=[],this.aliasNames=[],this.name=w$($),this.args=QJ($),this.examples=[]}usage($){return this.usageText=$,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version($,J="-v, --version"){return this.versionNumber=$,this.option(J,"Display version number"),this}example($){return this.examples.push($),this}option($,J,E){let H=new LJ($,J,E);return this.options.push(H),this}alias($){return this.aliasNames.push($),this}action($){return this.commandAction=$,this}isMatched($){return this.name===$||this.aliasNames.includes($)}get isDefaultCommand(){return this.name===""||this.aliasNames.includes("!")}get isGlobalCommand(){return this instanceof k$}hasOption($){return $=$.split(".")[0],this.options.find((J)=>{return J.names.includes($)})}outputHelp(){let{name:$,commands:J}=this.cli,{versionNumber:E,options:H,helpCallback:B}=this.cli.globalCommand,Y=[{body:`${$}${E?`/${E}`:""}`}];if(Y.push({title:"Usage",body:` $ ${$} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&J.length>0){let X=x$(J.map((Q)=>Q.rawName));Y.push({title:"Commands",body:J.map((Q)=>{return` ${g$(Q.rawName,X.length)} ${Q.description}`}).join(`
4
- `)},{title:"For more info, run any command with the `--help` flag",body:J.map((Q)=>` $ ${$}${Q.name===""?"":` ${Q.name}`} --help`).join(`
5
- `)})}let V=this.isGlobalCommand?H:[...this.options,...H||[]];if(!this.isGlobalCommand&&!this.isDefaultCommand)V=V.filter((X)=>X.name!=="version");if(V.length>0){let X=x$(V.map((Q)=>Q.rawName));Y.push({title:"Options",body:V.map((Q)=>{return` ${g$(Q.rawName,X.length)} ${Q.description} ${Q.config.default===void 0?"":`(default: ${Q.config.default})`}`}).join(`
6
- `)})}if(this.examples.length>0)Y.push({title:"Examples",body:this.examples.map((X)=>{if(typeof X==="function")return X($);return X}).join(`
7
- `)});if(B)Y=B(Y)||Y;console.info(Y.map((X)=>{return X.title?`${X.title}:
8
- ${X.body}`:X.body}).join(`
3
+ function R$($){return $==null?[]:Array.isArray($)?$:[$]}function KJ($,J,X,Q){var V,H=$[J],K=~Q.string.indexOf(J)?X==null||X===!0?"":String(X):typeof X==="boolean"?X:~Q.boolean.indexOf(J)?X==="false"?!1:X==="true"||($._.push((V=+X,V*0===0)?V:X),!!X):(V=+X,V*0===0)?V:X;$[J]=H==null?K:Array.isArray(H)?H.concat(K):[H,K]}function YJ($,J){$=$||[],J=J||{};var X,Q,V,H,K,Y={_:[]},W=0,q=0,B=0,R=$.length;let E=J.alias!==void 0,G=J.unknown!==void 0,O=J.default!==void 0;if(J.alias=J.alias||{},J.string=R$(J.string),J.boolean=R$(J.boolean),E)for(X in J.alias){Q=J.alias[X]=R$(J.alias[X]);for(W=0;W<Q.length;W++)(J.alias[Q[W]]=Q.concat(X)).splice(W,1)}for(W=J.boolean.length;W-- >0;){Q=J.alias[J.boolean[W]]||[];for(q=Q.length;q-- >0;)J.boolean.push(Q[q])}for(W=J.string.length;W-- >0;){Q=J.alias[J.string[W]]||[];for(q=Q.length;q-- >0;)J.string.push(Q[q])}if(O){for(X in J.default)if(H=typeof J.default[X],Q=J.alias[X]=J.alias[X]||[],J[H]!==void 0){J[H].push(X);for(W=0;W<Q.length;W++)J[H].push(Q[W])}}let C=G?Object.keys(J.alias):[];for(W=0;W<R;W++){if(V=$[W],V==="--"){Y._=Y._.concat($.slice(++W));break}for(q=0;q<V.length;q++)if(V.charCodeAt(q)!==45)break;if(q===0)Y._.push(V);else if(V.substring(q,q+3)==="no-"){if(H=V.substring(q+3),G&&!~C.indexOf(H))return J.unknown(V);Y[H]=!1}else{for(B=q+1;B<V.length;B++)if(V.charCodeAt(B)===61)break;H=V.substring(q,B),K=V.substring(++B)||W+1===R||(""+$[W+1]).charCodeAt(0)===45||$[++W],Q=q===2?[H]:H;for(B=0;B<Q.length;B++){if(H=Q[B],G&&!~C.indexOf(H))return J.unknown("-".repeat(q)+H);KJ(Y,H,B+1<Q.length||K,J)}}}if(O){for(X in J.default)if(Y[X]===void 0)Y[X]=J.default[X]}if(E)for(X in Y){Q=J.alias[X]||[];while(Q.length>0)Y[Q.shift()]=Y[X]}return Y}function z$($){return $.replace(/[<[].+/,"").trim()}function WJ($){let J=/<([^>]+)>/g,X=/\[([^\]]+)\]/g,Q=[],V=(Y)=>{let W=!1,q=Y[1];if(q.startsWith("..."))q=q.slice(3),W=!0;return{required:Y[0].startsWith("<"),value:q,variadic:W}},H;while(H=J.exec($))Q.push(V(H));let K;while(K=X.exec($))Q.push(V(K));return Q}function qJ($){let J={alias:{},boolean:[]};for(let[X,Q]of $.entries()){if(Q.names.length>1)J.alias[Q.names[0]]=Q.names.slice(1);if(Q.isBoolean)if(Q.negated){if(!$.some((V,H)=>{return H!==X&&V.names.some((K)=>Q.names.includes(K))&&typeof V.required==="boolean"}))J.boolean.push(Q.names[0])}else J.boolean.push(Q.names[0])}return J}function D$($){return $.sort((J,X)=>{return J.length>X.length?-1:1})[0]}function w$($,J){return $.length>=J?$:`${$}${" ".repeat(J-$.length)}`}function BJ($){return $.replaceAll(/([a-z])-([a-z])/g,(J,X,Q)=>{return X+Q.toUpperCase()})}function RJ($,J,X){let Q=$;for(let V=0;V<J.length;V++){let H=J[V];if(V===J.length-1){Q[H]=X;return}if(Q[H]==null){let K=+J[V+1]>-1;Q[H]=K?[]:{}}Q=Q[H]}}function LJ($,J){for(let X of Object.keys(J)){let Q=J[X];if(Q.shouldTransform){if($[X]=[$[X]].flat(),typeof Q.transformFunction==="function")$[X]=$[X].map(Q.transformFunction)}}}function EJ($){let J=/([^\\/]+)$/.exec($);return J?J[1]:""}function g$($){return $.split(".").map((J,X)=>{return X===0?BJ(J):J}).join(".")}var X$=class extends Error{constructor($){super($);if(this.name="CACError",typeof Error.captureStackTrace!=="function")this.stack=Error($).stack}},FJ=class{rawName;description;name;names;isBoolean;required;config;negated;constructor($,J,X){if(this.rawName=$,this.description=J,this.config=Object.assign({},X),$=$.replaceAll(".*",""),this.negated=!1,this.names=z$($).split(",").map((Q)=>{let V=Q.trim().replace(/^-{1,2}/,"");if(V.startsWith("no-"))this.negated=!0,V=V.replace(/^no-/,"");return g$(V)}).sort((Q,V)=>Q.length>V.length?1:-1),this.name=this.names.at(-1),this.negated&&this.config.default==null)this.config.default=!0;if($.includes("<"))this.required=!0;else if($.includes("["))this.required=!1;else this.isBoolean=!0}},L$,Q$;if(typeof process<"u"){let $;if(typeof Deno<"u"&&typeof Deno.version?.deno==="string")$="deno";else if(typeof Bun<"u"&&typeof Bun.version==="string")$="bun";else $="node";Q$=`${process.platform}-${process.arch} ${$}-${process.version}`,L$=process.argv}else if(typeof navigator>"u")Q$="unknown";else Q$=`${navigator.platform} ${navigator.userAgent}`;var y$=class{rawName;description;config;cli;options;aliasNames;name;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;constructor($,J,X={},Q){this.rawName=$,this.description=J,this.config=X,this.cli=Q,this.options=[],this.aliasNames=[],this.name=z$($),this.args=WJ($),this.examples=[]}usage($){return this.usageText=$,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version($,J="-v, --version"){return this.versionNumber=$,this.option(J,"Display version number"),this}example($){return this.examples.push($),this}option($,J,X){let Q=new FJ($,J,X);return this.options.push(Q),this}alias($){return this.aliasNames.push($),this}action($){return this.commandAction=$,this}isMatched($){return this.name===$||this.aliasNames.includes($)}get isDefaultCommand(){return this.name===""||this.aliasNames.includes("!")}get isGlobalCommand(){return this instanceof k$}hasOption($){return $=$.split(".")[0],this.options.find((J)=>{return J.names.includes($)})}outputHelp(){let{name:$,commands:J}=this.cli,{versionNumber:X,options:Q,helpCallback:V}=this.cli.globalCommand,H=[{body:`${$}${X?`/${X}`:""}`}];if(H.push({title:"Usage",body:` $ ${$} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&J.length>0){let Y=D$(J.map((W)=>W.rawName));H.push({title:"Commands",body:J.map((W)=>{return` ${w$(W.rawName,Y.length)} ${W.description}`}).join(`
4
+ `)},{title:"For more info, run any command with the `--help` flag",body:J.map((W)=>` $ ${$}${W.name===""?"":` ${W.name}`} --help`).join(`
5
+ `)})}let K=this.isGlobalCommand?Q:[...this.options,...Q||[]];if(!this.isGlobalCommand&&!this.isDefaultCommand)K=K.filter((Y)=>Y.name!=="version");if(K.length>0){let Y=D$(K.map((W)=>W.rawName));H.push({title:"Options",body:K.map((W)=>{return` ${w$(W.rawName,Y.length)} ${W.description} ${W.config.default===void 0?"":`(default: ${W.config.default})`}`}).join(`
6
+ `)})}if(this.examples.length>0)H.push({title:"Examples",body:this.examples.map((Y)=>{if(typeof Y==="function")return Y($);return Y}).join(`
7
+ `)});if(V)H=V(H)||H;console.info(H.map((Y)=>{return Y.title?`${Y.title}:
8
+ ${Y.body}`:Y.body}).join(`
9
9
 
10
- `))}outputVersion(){let{name:$}=this.cli,{versionNumber:J}=this.cli.globalCommand;if(J)console.info(`${$}/${J} ${H$}`)}checkRequiredArgs(){let $=this.args.filter((J)=>J.required).length;if(this.cli.args.length<$)throw new E$(`missing required args for command \`${this.rawName}\``)}checkUnknownOptions(){let{options:$,globalCommand:J}=this.cli;if(!this.config.allowUnknownOptions){for(let E of Object.keys($))if(E!=="--"&&!this.hasOption(E)&&!J.hasOption(E))throw new E$(`Unknown option \`${E.length>1?`--${E}`:`-${E}`}\``)}}checkOptionValue(){let{options:$,globalCommand:J}=this.cli,E=[...J.options,...this.options];for(let H of E){let B=$[H.name.split(".")[0]];if(H.required){let Y=E.some((V)=>V.negated&&V.names.includes(H.name));if(B===!0||B===!1&&!Y)throw new E$(`option \`${H.rawName}\` value is missing`)}}}checkUnusedArgs(){let $=this.args.some((J)=>J.variadic)?1/0:this.args.length;if($<this.cli.args.length)throw new E$(`Unused args: ${this.cli.args.slice($).map((J)=>`\`${J}\``).join(", ")}`)}},k$=class extends y${constructor($){super("@@global@@","",{},$)}},PJ=class extends EventTarget{name;commands;globalCommand;matchedCommand;matchedCommandName;rawArgs;args;options;showHelpOnExit;showVersionOnExit;constructor($=""){super();this.name=$,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new k$(this),this.globalCommand.usage("<command> [options]")}usage($){return this.globalCommand.usage($),this}command($,J,E){let H=new y$($,J||"",E,this);return H.globalCommand=this.globalCommand,this.commands.push(H),H}option($,J,E){return this.globalCommand.option($,J,E),this}help($){return this.globalCommand.option("-h, --help","Display this message"),this.globalCommand.helpCallback=$,this.showHelpOnExit=!0,this}version($,J="-v, --version"){return this.globalCommand.version($,J),this.showVersionOnExit=!0,this}example($){return this.globalCommand.example($),this}outputHelp(){if(this.matchedCommand)this.matchedCommand.outputHelp();else this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:$,options:J},E,H){if(this.args=$,this.options=J,E)this.matchedCommand=E;if(H)this.matchedCommandName=H;return this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}parse($,{run:J=!0}={}){if(!$){if(!W$)throw Error("No argv provided and runtime process argv is not available.");$=W$}if(this.rawArgs=$,!this.name)this.name=$[1]?qJ($[1]):"cli";let E=!0;for(let B of this.commands){let Y=this.mri($.slice(2),B),V=Y.args[0];if(B.isMatched(V)){E=!1;let X={...Y,args:Y.args.slice(1)};this.setParsedInfo(X,B,V),this.dispatchEvent(new CustomEvent(`command:${V}`,{detail:B}))}}if(E){for(let B of this.commands)if(B.isDefaultCommand){E=!1;let Y=this.mri($.slice(2),B);this.setParsedInfo(Y,B),this.dispatchEvent(new CustomEvent("command:!",{detail:B}))}}if(E){let B=this.mri($.slice(2));this.setParsedInfo(B)}if(this.options.help&&this.showHelpOnExit)this.outputHelp(),J=!1,this.unsetMatchedCommand();if(this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null)this.outputVersion(),J=!1,this.unsetMatchedCommand();let H={args:this.args,options:this.options};if(J)this.runMatchedCommand();if(!this.matchedCommand&&this.args[0])this.dispatchEvent(new CustomEvent("command:*",{detail:this.args[0]}));return H}mri($,J){let E=[...this.globalCommand.options,...J?J.options:[]],H=KJ(E),B=[],Y=$.indexOf("--");if(Y!==-1)B=$.slice(Y+1),$=$.slice(0,Y);let V=XJ($,H);V=Object.keys(V).reduce((F,q)=>{return{...F,[z$(q)]:V[q]}},{_:[]});let X=V._,Q={"--":B},R=J&&J.config.ignoreOptionDefaultValue?J.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,K=Object.create(null);for(let F of E){if(!R&&F.config.default!==void 0)for(let q of F.names)Q[q]=F.config.default;if(Array.isArray(F.config.type)&&K[F.name]===void 0)K[F.name]=Object.create(null),K[F.name].shouldTransform=!0,K[F.name].transformFunction=F.config.type[0]}for(let F of Object.keys(V))if(F!=="_")FJ(Q,F.split("."),V[F]),WJ(Q,K);return{args:X,options:Q}}runMatchedCommand(){let{args:$,options:J,matchedCommand:E}=this;if(!E||!E.commandAction)return;E.checkUnknownOptions(),E.checkOptionValue(),E.checkRequiredArgs(),E.checkUnusedArgs();let H=[];return E.args.forEach((B,Y)=>{if(B.variadic)H.push($.slice(Y));else H.push($[Y])}),H.push(J),E.commandAction.apply(this,H)}},v$=($="")=>new PJ($);import{mkdir as yJ,readdir as kJ,rm as s$}from"fs/promises";import{join as i,relative as $J,resolve as t$}from"path";import{PluginConfigSchema as vJ,ThemeSchema as hJ}from"@jrtilak-recall/plugin-schema";import{createRequire as MJ}from"module";var GJ=MJ("/"),l,OJ,CJ;try{l=GJ("worker_threads"),OJ=l.Worker,CJ=l.isMarkedAsUntransferable}catch($){}var N=Uint8Array,g=Uint16Array,O$=Int32Array,C$=new N([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),T$=new N([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),h$=new N([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),f$=function($,J){var E=new g(31);for(var H=0;H<31;++H)E[H]=J+=1<<$[H-1];var B=new O$(E[30]);for(var H=1;H<30;++H)for(var Y=E[H];Y<E[H+1];++Y)B[Y]=Y-E[H]<<5|H;return{b:E,r:B}},l=f$(C$,2),TJ=l.b,L$=l.r;TJ[28]=258,L$[258]=28;var b$=f$(T$,0),dJ=b$.b,u$=b$.r,P$=new g(32768);for(W=0;W<32768;++W)m=(W&43690)>>1|(W&21845)<<1,m=(m&52428)>>2|(m&13107)<<2,m=(m&61680)>>4|(m&3855)<<4,P$[W]=((m&65280)>>8|(m&255)<<8)>>1;var m,W,$$=function($,J,E){var H=$.length,B=0,Y=new g(J);for(;B<H;++B)if($[B])++Y[$[B]-1];var V=new g(J);for(B=1;B<J;++B)V[B]=V[B-1]+Y[B-1]<<1;var X;if(E){X=new g(1<<J);var Q=15-J;for(B=0;B<H;++B)if($[B]){var R=B<<4|$[B],K=J-$[B],F=V[$[B]-1]++<<K;for(var q=F|(1<<K)-1;F<=q;++F)X[P$[F]>>Q]=R}}else{X=new g(H);for(B=0;B<H;++B)if($[B])X[B]=P$[V[$[B]-1]++]>>15-$[B]}return X},f=new N(288);for(W=0;W<144;++W)f[W]=8;var W;for(W=144;W<256;++W)f[W]=9;var W;for(W=256;W<280;++W)f[W]=7;var W;for(W=280;W<288;++W)f[W]=8;var W,B$=new N(32);for(W=0;W<32;++W)B$[W]=5;var W,ZJ=$$(f,9,0);var jJ=$$(B$,5,0);var e$=function($){return($+7)/8|0},o$=function($,J,E){if(J==null||J<0)J=0;if(E==null||E>$.length)E=$.length;return new N($.subarray(J,E))};var UJ=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Y$=function($,J,E){var H=Error(J||UJ[$]);if(H.code=$,Error.captureStackTrace)Error.captureStackTrace(H,Y$);if(!E)throw H;return H};var p=function($,J,E){E<<=J&7;var H=J/8|0;$[H]|=E,$[H+1]|=E>>8},s=function($,J,E){E<<=J&7;var H=J/8|0;$[H]|=E,$[H+1]|=E>>8,$[H+2]|=E>>16},q$=function($,J){var E=[];for(var H=0;H<$.length;++H)if($[H])E.push({s:H,f:$[H]});var B=E.length,Y=E.slice();if(!B)return{t:l$,l:0};if(B==1){var V=new N(E[0].s+1);return V[E[0].s]=1,{t:V,l:1}}E.sort(function(I,D){return I.f-D.f}),E.push({s:-1,f:25001});var X=E[0],Q=E[1],R=0,K=1,F=2;E[0]={s:-1,f:X.f+Q.f,l:X,r:Q};while(K!=B-1)X=E[E[R].f<E[F].f?R++:F++],Q=E[R!=K&&E[R].f<E[F].f?R++:F++],E[K++]={s:-1,f:X.f+Q.f,l:X,r:Q};var q=Y[0].s;for(var H=1;H<B;++H)if(Y[H].s>q)q=Y[H].s;var P=new g(q+1),O=M$(E[K-1],P,0);if(O>J){var H=0,G=0,S=O-J,v=1<<S;Y.sort(function(D,C){return P[C.s]-P[D.s]||D.f-C.f});for(;H<B;++H){var w=Y[H].s;if(P[w]>J)G+=v-(1<<O-P[w]),P[w]=J;else break}G>>=S;while(G>0){var h=Y[H].s;if(P[h]<J)G-=1<<J-P[h]++-1;else++H}for(;H>=0&&G;--H){var T=Y[H].s;if(P[T]==J)--P[T],++G}O=J}return{t:new N(P),l:O}},M$=function($,J,E){return $.s==-1?Math.max(M$($.l,J,E+1),M$($.r,J,E+1)):J[$.s]=E},_$=function($){var J=$.length;while(J&&!$[--J]);var E=new g(++J),H=0,B=$[0],Y=1,V=function(Q){E[H++]=Q};for(var X=1;X<=J;++X)if($[X]==B&&X!=J)++Y;else{if(!B&&Y>2){for(;Y>138;Y-=138)V(32754);if(Y>2)V(Y>10?Y-11<<5|28690:Y-3<<5|12305),Y=0}else if(Y>3){V(B),--Y;for(;Y>6;Y-=6)V(8304);if(Y>2)V(Y-3<<5|8208),Y=0}while(Y--)V(B);Y=1,B=$[X]}return{c:E.subarray(0,H),n:J}},t=function($,J){var E=0;for(var H=0;H<J.length;++H)E+=$[H]*J[H];return E},c$=function($,J,E){var H=E.length,B=e$(J+2);$[B]=H&255,$[B+1]=H>>8,$[B+2]=$[B]^255,$[B+3]=$[B+1]^255;for(var Y=0;Y<H;++Y)$[B+Y+4]=E[Y];return(B+4+H)*8},r$=function($,J,E,H,B,Y,V,X,Q,R,K){p(J,K++,E),++B[256];var F=q$(B,15),q=F.t,P=F.l,O=q$(Y,15),G=O.t,S=O.l,v=_$(q),w=v.c,h=v.n,T=_$(G),I=T.c,D=T.n,C=new g(19);for(var M=0;M<w.length;++M)++C[w[M]&31];for(var M=0;M<I.length;++M)++C[I[M]&31];var L=q$(C,7),A=L.t,b=L.l,x=19;for(;x>4&&!A[h$[x-1]];--x);var e=R+5<<3,z=t(B,f)+t(Y,B$)+V,y=t(B,q)+t(Y,G)+V+14+3*x+t(C,A)+2*C[16]+3*C[17]+7*C[18];if(Q>=0&&e<=z&&e<=y)return c$(J,K,$.subarray(Q,Q+R));var u,Z,k,n;if(p(J,K,1+(y<z)),K+=2,y<z){u=$$(q,P,0),Z=q,k=$$(G,S,0),n=G;var X$=$$(A,b,0);p(J,K,h-257),p(J,K+5,D-1),p(J,K+10,x-4),K+=14;for(var M=0;M<x;++M)p(J,K+3*M,A[h$[M]]);K+=3*x;var _=[w,I];for(var a=0;a<2;++a){var o=_[a];for(var M=0;M<o.length;++M){var r=o[M]&31;if(p(J,K,X$[r]),K+=A[r],r>15)p(J,K,o[M]>>5&127),K+=o[M]>>12}}}else u=ZJ,Z=f,k=jJ,n=B$;for(var M=0;M<X;++M){var U=H[M];if(U>255){var r=U>>18&31;if(s(J,K,u[r+257]),K+=Z[r+257],r>7)p(J,K,U>>23&31),K+=C$[r];var c=U&31;if(s(J,K,k[c]),K+=n[c],c>3)s(J,K,U>>5&8191),K+=T$[c]}else s(J,K,u[U]),K+=Z[U]}return s(J,K,u[256]),K+Z[256]},NJ=new O$([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),l$=new N(0),SJ=function($,J,E,H,B,Y){var V=Y.z||$.length,X=new N(H+V+5*(1+Math.ceil(V/7000))+B),Q=X.subarray(H,X.length-B),R=Y.l,K=(Y.r||0)&7;if(J){if(K)Q[0]=Y.r>>3;var F=NJ[J-1],q=F>>13,P=F&8191,O=(1<<E)-1,G=Y.p||new g(32768),S=Y.h||new g(O+1),v=Math.ceil(E/3),w=2*v,h=function(R$){return($[R$]^$[R$+1]<<v^$[R$+2]<<w)&O},T=new O$(25000),I=new g(288),D=new g(32),C=0,M=0,L=Y.i||0,A=0,b=Y.w||0,x=0;for(;L+2<V;++L){var e=h(L),z=L&32767,y=S[e];if(G[z]=y,S[e]=z,b<=L){var u=V-L;if((C>7000||A>24576)&&(u>423||!R)){K=r$($,Q,0,T,I,D,M,A,x,L-x,K),A=C=M=0,x=L;for(var Z=0;Z<286;++Z)I[Z]=0;for(var Z=0;Z<30;++Z)D[Z]=0}var k=2,n=0,X$=P,_=z-y&32767;if(u>2&&e==h(L-_)){var a=Math.min(q,u)-1,o=Math.min(32767,L),r=Math.min(258,u);while(_<=o&&--X$&&z!=y){if($[L+k]==$[L+k-_]){var U=0;for(;U<r&&$[L+U]==$[L+U-_];++U);if(U>k){if(k=U,n=_,U>a)break;var c=Math.min(_,U-2),S$=0;for(var Z=0;Z<c;++Z){var Q$=L-_+Z&32767,YJ=G[Q$],I$=Q$-YJ&32767;if(I$>S$)S$=I$,y=Q$}}}z=y,y=G[z],_+=z-y&32767}}if(n){T[A++]=268435456|L$[k]<<18|u$[n];var D$=L$[k]&31,A$=u$[n]&31;M+=C$[D$]+T$[A$],++I[257+D$],++D[A$],b=L+k,++C}else T[A++]=$[L],++I[$[L]]}}for(L=Math.max(L,b);L<V;++L)T[A++]=$[L],++I[$[L]];if(K=r$($,Q,R,T,I,D,M,A,x,L-x,K),!R)Y.r=K&7|Q[K/8|0]<<3,K-=7,Y.h=S,Y.p=G,Y.i=L,Y.w=b}else{for(var L=Y.w||0;L<V+R;L+=65535){var K$=L+65535;if(K$>=V)Q[K/8|0]=R,K$=V;K=c$(Q,K+1,$.subarray(L,K$))}Y.i=V}return o$(X,0,H+e$(K)+B)},IJ=function(){var $=new Int32Array(256);for(var J=0;J<256;++J){var E=J,H=9;while(--H)E=(E&1&&-306674912)^E>>>1;$[J]=E}return $}(),DJ=function(){var $=-1;return{p:function(J){var E=$;for(var H=0;H<J.length;++H)E=IJ[E&255^J[H]]^E>>>8;$=E},d:function(){return~$}}};var AJ=function($,J,E,H,B){if(!B){if(B={l:1},J.dictionary){var Y=J.dictionary.subarray(-32768),V=new N(Y.length+$.length);V.set(Y),V.set($,Y.length),$=V,B.w=Y.length}}return SJ($,J.level==null?6:J.level,J.mem==null?B.l?Math.ceil(Math.max(8,Math.min(13,Math.log($.length)))*1.5):20:12+J.mem,E,H,B)},i$=function($,J){var E={};for(var H in $)E[H]=$[H];for(var H in J)E[H]=J[H];return E};var j=function($,J,E){for(;E;++J)$[J]=E,E>>>=8};function xJ($,J){return AJ($,J||{},0,0)}var d$=function($,J,E,H){for(var B in $){var Y=$[B],V=J+B,X=H;if(Array.isArray(Y))X=i$(H,Y[1]),Y=Y[0];if(ArrayBuffer.isView(Y))E[V]=[Y,X];else E[V+="/"]=[new N(0),X],d$(Y,V,E,H)}},m$=typeof TextEncoder<"u"&&new TextEncoder,gJ=typeof TextDecoder<"u"&&new TextDecoder,wJ=0;try{gJ.decode(l$,{stream:!0}),wJ=1}catch($){}function p$($,J){if(J){var E=new N($.length);for(var H=0;H<$.length;++H)E[H]=$.charCodeAt(H);return E}if(m$)return m$.encode($);var B=$.length,Y=new N($.length+($.length>>1)),V=0,X=function(K){Y[V++]=K};for(var H=0;H<B;++H){if(V+5>Y.length){var Q=new N(V+8+(B-H<<1));Q.set(Y),Y=Q}var R=$.charCodeAt(H);if(R<128||J)X(R);else if(R<2048)X(192|R>>6),X(128|R&63);else if(R>55295&&R<57344)R=65536+(R&1047552)|$.charCodeAt(++H)&1023,X(240|R>>18),X(128|R>>12&63),X(128|R>>6&63),X(128|R&63);else X(224|R>>12),X(128|R>>6&63),X(128|R&63)}return o$(Y,0,V)}var G$=function($){var J=0;if($)for(var E in $){var H=$[E].length;if(H>65535)Y$(9);J+=H+4}return J},n$=function($,J,E,H,B,Y,V,X){var Q=H.length,R=E.extra,K=X&&X.length,F=G$(R);if(j($,J,V!=null?33639248:67324752),J+=4,V!=null)$[J++]=20,$[J++]=E.os;$[J]=20,J+=2,$[J++]=E.flag<<1|(Y<0&&8),$[J++]=B&&8,$[J++]=E.compression&255,$[J++]=E.compression>>8;var q=new Date(E.mtime==null?Date.now():E.mtime),P=q.getFullYear()-1980;if(P<0||P>119)Y$(10);if(j($,J,P<<25|q.getMonth()+1<<21|q.getDate()<<16|q.getHours()<<11|q.getMinutes()<<5|q.getSeconds()>>1),J+=4,Y!=-1)j($,J,E.crc),j($,J+4,Y<0?-Y-2:Y),j($,J+8,E.size);if(j($,J+12,Q),j($,J+14,F),J+=16,V!=null)j($,J,K),j($,J+6,E.attrs),j($,J+10,V),J+=14;if($.set(H,J),J+=Q,F)for(var O in R){var G=R[O],S=G.length;j($,J,+O),j($,J+2,S),$.set(G,J+4),J+=4+S}if(K)$.set(X,J),J+=K;return J},zJ=function($,J,E,H,B){j($,J,101010256),j($,J+8,E),j($,J+10,E),j($,J+12,H),j($,J+16,B)};function a$($,J){if(!J)J={};var E={},H=[];d$($,"",E,J);var B=0,Y=0;for(var V in E){var X=E[V],Q=X[0],R=X[1],K=R.level==0?0:8,F=p$(V),q=F.length,P=R.comment,O=P&&p$(P),G=O&&O.length,S=G$(R.extra);if(q>65535)Y$(11);var v=K?xJ(Q,R):Q,w=v.length,h=DJ();h.p(Q),H.push(i$(R,{size:Q.length,crc:h.d(),c:v,f:F,m:O,u:q!=V.length||O&&P.length!=G,o:B,compression:K})),B+=30+q+S+w,Y+=76+2*(q+S)+(G||0)+w}var T=new N(Y+22),I=B,D=Y-B;for(var C=0;C<H.length;++C){var F=H[C];n$(T,F.o,F,F.f,F.u,F.c.length);var M=30+F.f.length+G$(F.extra);T.set(F.c,F.o+M),n$(T,B,F,F.f,F.u,F.c.length,F.o,F.m),B+=16+M+(F.m?F.m.length:0)}return zJ(T,B,H.length,D,I),T}import{z as JJ}from"zod";async function Z$($,J){try{return await Bun.file($).json()}catch(E){let H=E instanceof Error?E.message:"unknown error";throw Error(`Could not read ${J} at ${$}: ${H}`)}}function j$($){return`${JSON.stringify($,null,2)}
11
- `}var V$={error($){console.error(`[recall-plugin] error: ${$}`)},info($){console.info(`[recall-plugin] ${$}`)},success($){console.info(`[recall-plugin] ok: ${$}`)},warn($){console.warn(`[recall-plugin] warn: ${$}`)}};var U$="theme.json";async function EJ($,J=V$){let E=t$($.rootDir),H=t$(E,$.outDir),B=`${H}.zip`,Y=i(E,"package.json");if(J.info(`Building plugin in ${E}`),$.clean)J.info(`Cleaning ${d(E,H)}`),await s$(H,{recursive:!0,force:!0}),await s$(B,{force:!0});await yJ(H,{recursive:!0});let V=await Z$(Y,"plugin package.json"),X=vJ.safeParse(V);if(!X.success)throw Error(`Invalid plugin manifest:
12
- ${JJ.prettifyError(X.error)}`);let Q=X.data,R=Q.recall.entry,K=i(E,R.file),F=R.runtime==="theme"?await rJ(K,H,J):await uJ(K,E,H,$,J),q={...Q,recall:{...Q.recall,entry:{...R,file:F}}},P=i(H,"manifest.json");if(await Bun.write(P,j$(q)),J.success(`Generated ${d(E,P)}`),$.zip)await mJ(H,B,E,J);J.success("Plugin build complete")}async function uJ($,J,E,H,B){B.info(`Building JavaScript entry ${$}`);let Y=await _J(J);if(Y)B.info(`Using ${d(J,Y)}`);let V=await Bun.build({entrypoints:[$],minify:H.minify,outdir:E,root:J,sourcemap:H.sourcemap?"external":"none",...Y?{tsconfig:Y}:{}});if(!V.success){let R=V.logs.map((K)=>K.message).join(`
10
+ `))}outputVersion(){let{name:$}=this.cli,{versionNumber:J}=this.cli.globalCommand;if(J)console.info(`${$}/${J} ${Q$}`)}checkRequiredArgs(){let $=this.args.filter((J)=>J.required).length;if(this.cli.args.length<$)throw new X$(`missing required args for command \`${this.rawName}\``)}checkUnknownOptions(){let{options:$,globalCommand:J}=this.cli;if(!this.config.allowUnknownOptions){for(let X of Object.keys($))if(X!=="--"&&!this.hasOption(X)&&!J.hasOption(X))throw new X$(`Unknown option \`${X.length>1?`--${X}`:`-${X}`}\``)}}checkOptionValue(){let{options:$,globalCommand:J}=this.cli,X=[...J.options,...this.options];for(let Q of X){let V=$[Q.name.split(".")[0]];if(Q.required){let H=X.some((K)=>K.negated&&K.names.includes(Q.name));if(V===!0||V===!1&&!H)throw new X$(`option \`${Q.rawName}\` value is missing`)}}}checkUnusedArgs(){let $=this.args.some((J)=>J.variadic)?1/0:this.args.length;if($<this.cli.args.length)throw new X$(`Unused args: ${this.cli.args.slice($).map((J)=>`\`${J}\``).join(", ")}`)}},k$=class extends y${constructor($){super("@@global@@","",{},$)}},GJ=class extends EventTarget{name;commands;globalCommand;matchedCommand;matchedCommandName;rawArgs;args;options;showHelpOnExit;showVersionOnExit;constructor($=""){super();this.name=$,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new k$(this),this.globalCommand.usage("<command> [options]")}usage($){return this.globalCommand.usage($),this}command($,J,X){let Q=new y$($,J||"",X,this);return Q.globalCommand=this.globalCommand,this.commands.push(Q),Q}option($,J,X){return this.globalCommand.option($,J,X),this}help($){return this.globalCommand.option("-h, --help","Display this message"),this.globalCommand.helpCallback=$,this.showHelpOnExit=!0,this}version($,J="-v, --version"){return this.globalCommand.version($,J),this.showVersionOnExit=!0,this}example($){return this.globalCommand.example($),this}outputHelp(){if(this.matchedCommand)this.matchedCommand.outputHelp();else this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:$,options:J},X,Q){if(this.args=$,this.options=J,X)this.matchedCommand=X;if(Q)this.matchedCommandName=Q;return this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}parse($,{run:J=!0}={}){if(!$){if(!L$)throw Error("No argv provided and runtime process argv is not available.");$=L$}if(this.rawArgs=$,!this.name)this.name=$[1]?EJ($[1]):"cli";let X=!0;for(let V of this.commands){let H=this.mri($.slice(2),V),K=H.args[0];if(V.isMatched(K)){X=!1;let Y={...H,args:H.args.slice(1)};this.setParsedInfo(Y,V,K),this.dispatchEvent(new CustomEvent(`command:${K}`,{detail:V}))}}if(X){for(let V of this.commands)if(V.isDefaultCommand){X=!1;let H=this.mri($.slice(2),V);this.setParsedInfo(H,V),this.dispatchEvent(new CustomEvent("command:!",{detail:V}))}}if(X){let V=this.mri($.slice(2));this.setParsedInfo(V)}if(this.options.help&&this.showHelpOnExit)this.outputHelp(),J=!1,this.unsetMatchedCommand();if(this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null)this.outputVersion(),J=!1,this.unsetMatchedCommand();let Q={args:this.args,options:this.options};if(J)this.runMatchedCommand();if(!this.matchedCommand&&this.args[0])this.dispatchEvent(new CustomEvent("command:*",{detail:this.args[0]}));return Q}mri($,J){let X=[...this.globalCommand.options,...J?J.options:[]],Q=qJ(X),V=[],H=$.indexOf("--");if(H!==-1)V=$.slice(H+1),$=$.slice(0,H);let K=YJ($,Q);K=Object.keys(K).reduce((R,E)=>{return{...R,[g$(E)]:K[E]}},{_:[]});let Y=K._,W={"--":V},q=J&&J.config.ignoreOptionDefaultValue?J.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,B=Object.create(null);for(let R of X){if(!q&&R.config.default!==void 0)for(let E of R.names)W[E]=R.config.default;if(Array.isArray(R.config.type)&&B[R.name]===void 0)B[R.name]=Object.create(null),B[R.name].shouldTransform=!0,B[R.name].transformFunction=R.config.type[0]}for(let R of Object.keys(K))if(R!=="_")RJ(W,R.split("."),K[R]),LJ(W,B);return{args:Y,options:W}}runMatchedCommand(){let{args:$,options:J,matchedCommand:X}=this;if(!X||!X.commandAction)return;X.checkUnknownOptions(),X.checkOptionValue(),X.checkRequiredArgs(),X.checkUnusedArgs();let Q=[];return X.args.forEach((V,H)=>{if(V.variadic)Q.push($.slice(H));else Q.push($[H])}),Q.push(J),X.commandAction.apply(this,Q)}},v$=($="")=>new GJ($);import{mkdir as yJ,readdir as kJ,rm as s$}from"fs/promises";import{isAbsolute as vJ,join as a,relative as S$,resolve as t$,sep as _J}from"path";import{PluginConfigSchema as hJ,ThemeSchema as uJ}from"@jrtilak-recall/plugin-schema";import{createRequire as MJ}from"module";var CJ=MJ("/"),d,OJ,ZJ;try{d=CJ("worker_threads"),OJ=d.Worker,ZJ=d.isMarkedAsUntransferable}catch($){}var S=Uint8Array,w=Uint16Array,O$=Int32Array,Z$=new S([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),U$=new S([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),_$=new S([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),r$=function($,J){var X=new w(31);for(var Q=0;Q<31;++Q)X[Q]=J+=1<<$[Q-1];var V=new O$(X[30]);for(var Q=1;Q<30;++Q)for(var H=X[Q];H<X[Q+1];++H)V[H]=H-X[Q]<<5|Q;return{b:X,r:V}},d=r$(Z$,2),UJ=d.b,F$=d.r;UJ[28]=258,F$[258]=28;var n$=r$(U$,0),tJ=n$.b,h$=n$.r,G$=new w(32768);for(L=0;L<32768;++L)p=(L&43690)>>1|(L&21845)<<1,p=(p&52428)>>2|(p&13107)<<2,p=(p&61680)>>4|(p&3855)<<4,G$[L]=((p&65280)>>8|(p&255)<<8)>>1;var p,L,J$=function($,J,X){var Q=$.length,V=0,H=new w(J);for(;V<Q;++V)if($[V])++H[$[V]-1];var K=new w(J);for(V=1;V<J;++V)K[V]=K[V-1]+H[V-1]<<1;var Y;if(X){Y=new w(1<<J);var W=15-J;for(V=0;V<Q;++V)if($[V]){var q=V<<4|$[V],B=J-$[V],R=K[$[V]-1]++<<B;for(var E=R|(1<<B)-1;R<=E;++R)Y[G$[R]>>W]=q}}else{Y=new w(Q);for(V=0;V<Q;++V)if($[V])Y[V]=G$[K[$[V]-1]++]>>15-$[V]}return Y},n=new S(288);for(L=0;L<144;++L)n[L]=8;var L;for(L=144;L<256;++L)n[L]=9;var L;for(L=256;L<280;++L)n[L]=7;var L;for(L=280;L<288;++L)n[L]=8;var L,V$=new S(32);for(L=0;L<32;++L)V$[L]=5;var L,TJ=J$(n,9,0);var NJ=J$(V$,5,0);var c$=function($){return($+7)/8|0},l$=function($,J,X){if(J==null||J<0)J=0;if(X==null||X>$.length)X=$.length;return new S($.subarray(J,X))};var jJ=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],H$=function($,J,X){var Q=Error(J||jJ[$]);if(Q.code=$,Error.captureStackTrace)Error.captureStackTrace(Q,H$);if(!X)throw Q;return Q};var b=function($,J,X){X<<=J&7;var Q=J/8|0;$[Q]|=X,$[Q+1]|=X>>8},t=function($,J,X){X<<=J&7;var Q=J/8|0;$[Q]|=X,$[Q+1]|=X>>8,$[Q+2]|=X>>16},E$=function($,J){var X=[];for(var Q=0;Q<$.length;++Q)if($[Q])X.push({s:Q,f:$[Q]});var V=X.length,H=X.slice();if(!V)return{t:e$,l:0};if(V==1){var K=new S(X[0].s+1);return K[X[0].s]=1,{t:K,l:1}}X.sort(function(P,A){return P.f-A.f}),X.push({s:-1,f:25001});var Y=X[0],W=X[1],q=0,B=1,R=2;X[0]={s:-1,f:Y.f+W.f,l:Y,r:W};while(B!=V-1)Y=X[X[q].f<X[R].f?q++:R++],W=X[q!=B&&X[q].f<X[R].f?q++:R++],X[B++]={s:-1,f:Y.f+W.f,l:Y,r:W};var E=H[0].s;for(var Q=1;Q<V;++Q)if(H[Q].s>E)E=H[Q].s;var G=new w(E+1),O=M$(X[B-1],G,0);if(O>J){var Q=0,C=0,I=O-J,v=1<<I;H.sort(function(A,Z){return G[Z.s]-G[A.s]||A.f-Z.f});for(;Q<V;++Q){var z=H[Q].s;if(G[z]>J)C+=v-(1<<O-G[z]),G[z]=J;else break}C>>=I;while(C>0){var _=H[Q].s;if(G[_]<J)C-=1<<J-G[_]++-1;else++Q}for(;Q>=0&&C;--Q){var U=H[Q].s;if(G[U]==J)--G[U],++C}O=J}return{t:new S(G),l:O}},M$=function($,J,X){return $.s==-1?Math.max(M$($.l,J,X+1),M$($.r,J,X+1)):J[$.s]=X},u$=function($){var J=$.length;while(J&&!$[--J]);var X=new w(++J),Q=0,V=$[0],H=1,K=function(W){X[Q++]=W};for(var Y=1;Y<=J;++Y)if($[Y]==V&&Y!=J)++H;else{if(!V&&H>2){for(;H>138;H-=138)K(32754);if(H>2)K(H>10?H-11<<5|28690:H-3<<5|12305),H=0}else if(H>3){K(V),--H;for(;H>6;H-=6)K(8304);if(H>2)K(H-3<<5|8208),H=0}while(H--)K(V);H=1,V=$[Y]}return{c:X.subarray(0,Q),n:J}},$$=function($,J){var X=0;for(var Q=0;Q<J.length;++Q)X+=$[Q]*J[Q];return X},o$=function($,J,X){var Q=X.length,V=c$(J+2);$[V]=Q&255,$[V+1]=Q>>8,$[V+2]=$[V]^255,$[V+3]=$[V+1]^255;for(var H=0;H<Q;++H)$[V+H+4]=X[H];return(V+4+Q)*8},m$=function($,J,X,Q,V,H,K,Y,W,q,B){b(J,B++,X),++V[256];var R=E$(V,15),E=R.t,G=R.l,O=E$(H,15),C=O.t,I=O.l,v=u$(E),z=v.c,_=v.n,U=u$(C),P=U.c,A=U.n,Z=new w(19);for(var M=0;M<z.length;++M)++Z[z[M]&31];for(var M=0;M<P.length;++M)++Z[P[M]&31];var F=E$(Z,7),x=F.t,c=F.l,D=19;for(;D>4&&!x[_$[D-1]];--D);var l=q+5<<3,g=$$(V,n)+$$(H,V$)+K,y=$$(V,E)+$$(H,C)+K+14+3*D+$$(Z,x)+2*Z[16]+3*Z[17]+7*Z[18];if(W>=0&&l<=g&&l<=y)return o$(J,B,$.subarray(W,W+q));var h,T,k,f;if(b(J,B,1+(y<g)),B+=2,y<g){h=J$(E,G,0),T=E,k=J$(C,I,0),f=C;var Y$=J$(x,c,0);b(J,B,_-257),b(J,B+5,A-1),b(J,B+10,D-4),B+=14;for(var M=0;M<D;++M)b(J,B+3*M,x[_$[M]]);B+=3*D;var u=[z,P];for(var s=0;s<2;++s){var o=u[s];for(var M=0;M<o.length;++M){var m=o[M]&31;if(b(J,B,Y$[m]),B+=x[m],m>15)b(J,B,o[M]>>5&127),B+=o[M]>>12}}}else h=TJ,T=n,k=NJ,f=V$;for(var M=0;M<Y;++M){var j=Q[M];if(j>255){var m=j>>18&31;if(t(J,B,h[m+257]),B+=T[m+257],m>7)b(J,B,j>>23&31),B+=Z$[m];var e=j&31;if(t(J,B,k[e]),B+=f[e],e>3)t(J,B,j>>5&8191),B+=U$[e]}else t(J,B,h[j]),B+=T[j]}return t(J,B,h[256]),B+T[256]},SJ=new O$([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),e$=new S(0),IJ=function($,J,X,Q,V,H){var K=H.z||$.length,Y=new S(Q+K+5*(1+Math.ceil(K/7000))+V),W=Y.subarray(Q,Y.length-V),q=H.l,B=(H.r||0)&7;if(J){if(B)W[0]=H.r>>3;var R=SJ[J-1],E=R>>13,G=R&8191,O=(1<<X)-1,C=H.p||new w(32768),I=H.h||new w(O+1),v=Math.ceil(X/3),z=2*v,_=function(B$){return($[B$]^$[B$+1]<<v^$[B$+2]<<z)&O},U=new O$(25000),P=new w(288),A=new w(32),Z=0,M=0,F=H.i||0,x=0,c=H.w||0,D=0;for(;F+2<K;++F){var l=_(F),g=F&32767,y=I[l];if(C[g]=y,I[l]=g,c<=F){var h=K-F;if((Z>7000||x>24576)&&(h>423||!q)){B=m$($,W,0,U,P,A,M,x,D,F-D,B),x=Z=M=0,D=F;for(var T=0;T<286;++T)P[T]=0;for(var T=0;T<30;++T)A[T]=0}var k=2,f=0,Y$=G,u=g-y&32767;if(h>2&&l==_(F-u)){var s=Math.min(E,h)-1,o=Math.min(32767,F),m=Math.min(258,h);while(u<=o&&--Y$&&g!=y){if($[F+k]==$[F+k-u]){var j=0;for(;j<m&&$[F+j]==$[F+j-u];++j);if(j>k){if(k=j,f=u,j>s)break;var e=Math.min(u,j-2),I$=0;for(var T=0;T<e;++T){var W$=F-u+T&32767,HJ=C[W$],P$=W$-HJ&32767;if(P$>I$)I$=P$,y=W$}}}g=y,y=C[g],u+=g-y&32767}}if(f){U[x++]=268435456|F$[k]<<18|h$[f];var A$=F$[k]&31,x$=h$[f]&31;M+=Z$[A$]+U$[x$],++P[257+A$],++A[x$],c=F+k,++Z}else U[x++]=$[F],++P[$[F]]}}for(F=Math.max(F,c);F<K;++F)U[x++]=$[F],++P[$[F]];if(B=m$($,W,q,U,P,A,M,x,D,F-D,B),!q)H.r=B&7|W[B/8|0]<<3,B-=7,H.h=I,H.p=C,H.i=F,H.w=c}else{for(var F=H.w||0;F<K+q;F+=65535){var q$=F+65535;if(q$>=K)W[B/8|0]=q,q$=K;B=o$(W,B+1,$.subarray(F,q$))}H.i=K}return l$(Y,0,Q+c$(B)+V)},PJ=function(){var $=new Int32Array(256);for(var J=0;J<256;++J){var X=J,Q=9;while(--Q)X=(X&1&&-306674912)^X>>>1;$[J]=X}return $}(),AJ=function(){var $=-1;return{p:function(J){var X=$;for(var Q=0;Q<J.length;++Q)X=PJ[X&255^J[Q]]^X>>>8;$=X},d:function(){return~$}}};var xJ=function($,J,X,Q,V){if(!V){if(V={l:1},J.dictionary){var H=J.dictionary.subarray(-32768),K=new S(H.length+$.length);K.set(H),K.set($,H.length),$=K,V.w=H.length}}return IJ($,J.level==null?6:J.level,J.mem==null?V.l?Math.ceil(Math.max(8,Math.min(13,Math.log($.length)))*1.5):20:12+J.mem,X,Q,V)},d$=function($,J){var X={};for(var Q in $)X[Q]=$[Q];for(var Q in J)X[Q]=J[Q];return X};var N=function($,J,X){for(;X;++J)$[J]=X,X>>>=8};function DJ($,J){return xJ($,J||{},0,0)}var a$=function($,J,X,Q){for(var V in $){var H=$[V],K=J+V,Y=Q;if(Array.isArray(H))Y=d$(Q,H[1]),H=H[0];if(ArrayBuffer.isView(H))X[K]=[H,Y];else X[K+="/"]=[new S(0),Y],a$(H,K,X,Q)}},p$=typeof TextEncoder<"u"&&new TextEncoder,wJ=typeof TextDecoder<"u"&&new TextDecoder,zJ=0;try{wJ.decode(e$,{stream:!0}),zJ=1}catch($){}function b$($,J){if(J){var X=new S($.length);for(var Q=0;Q<$.length;++Q)X[Q]=$.charCodeAt(Q);return X}if(p$)return p$.encode($);var V=$.length,H=new S($.length+($.length>>1)),K=0,Y=function(B){H[K++]=B};for(var Q=0;Q<V;++Q){if(K+5>H.length){var W=new S(K+8+(V-Q<<1));W.set(H),H=W}var q=$.charCodeAt(Q);if(q<128||J)Y(q);else if(q<2048)Y(192|q>>6),Y(128|q&63);else if(q>55295&&q<57344)q=65536+(q&1047552)|$.charCodeAt(++Q)&1023,Y(240|q>>18),Y(128|q>>12&63),Y(128|q>>6&63),Y(128|q&63);else Y(224|q>>12),Y(128|q>>6&63),Y(128|q&63)}return l$(H,0,K)}var C$=function($){var J=0;if($)for(var X in $){var Q=$[X].length;if(Q>65535)H$(9);J+=Q+4}return J},f$=function($,J,X,Q,V,H,K,Y){var W=Q.length,q=X.extra,B=Y&&Y.length,R=C$(q);if(N($,J,K!=null?33639248:67324752),J+=4,K!=null)$[J++]=20,$[J++]=X.os;$[J]=20,J+=2,$[J++]=X.flag<<1|(H<0&&8),$[J++]=V&&8,$[J++]=X.compression&255,$[J++]=X.compression>>8;var E=new Date(X.mtime==null?Date.now():X.mtime),G=E.getFullYear()-1980;if(G<0||G>119)H$(10);if(N($,J,G<<25|E.getMonth()+1<<21|E.getDate()<<16|E.getHours()<<11|E.getMinutes()<<5|E.getSeconds()>>1),J+=4,H!=-1)N($,J,X.crc),N($,J+4,H<0?-H-2:H),N($,J+8,X.size);if(N($,J+12,W),N($,J+14,R),J+=16,K!=null)N($,J,B),N($,J+6,X.attrs),N($,J+10,K),J+=14;if($.set(Q,J),J+=W,R)for(var O in q){var C=q[O],I=C.length;N($,J,+O),N($,J+2,I),$.set(C,J+4),J+=4+I}if(B)$.set(Y,J),J+=B;return J},gJ=function($,J,X,Q,V){N($,J,101010256),N($,J+8,X),N($,J+10,X),N($,J+12,Q),N($,J+16,V)};function i$($,J){if(!J)J={};var X={},Q=[];a$($,"",X,J);var V=0,H=0;for(var K in X){var Y=X[K],W=Y[0],q=Y[1],B=q.level==0?0:8,R=b$(K),E=R.length,G=q.comment,O=G&&b$(G),C=O&&O.length,I=C$(q.extra);if(E>65535)H$(11);var v=B?DJ(W,q):W,z=v.length,_=AJ();_.p(W),Q.push(d$(q,{size:W.length,crc:_.d(),c:v,f:R,m:O,u:E!=K.length||O&&G.length!=C,o:V,compression:B})),V+=30+E+I+z,H+=76+2*(E+I)+(C||0)+z}var U=new S(H+22),P=V,A=H-V;for(var Z=0;Z<Q.length;++Z){var R=Q[Z];f$(U,R.o,R,R.f,R.u,R.c.length);var M=30+R.f.length+C$(R.extra);U.set(R.c,R.o+M),f$(U,V,R,R.f,R.u,R.c.length,R.o,R.m),V+=16+M+(R.m?R.m.length:0)}return gJ(U,V,Q.length,A,P),U}import{z as $J}from"zod";async function T$($,J){try{return await Bun.file($).json()}catch(X){let Q=X instanceof Error?X.message:"unknown error";throw Error(`Could not read ${J} at ${$}: ${Q}`)}}function N$($){return`${JSON.stringify($,null,2)}
11
+ `}var K$={error($){console.error(`[recall-plugin] error: ${$}`)},info($){console.info(`[recall-plugin] ${$}`)},success($){console.info(`[recall-plugin] ok: ${$}`)},warn($){console.warn(`[recall-plugin] warn: ${$}`)}};var j$="theme.json";async function JJ($,J=K$){let X=t$($.rootDir),Q=a(X,"package.json");J.info(`Building plugin in ${X}`);let V=await T$(Q,"plugin package.json"),H=hJ.safeParse(V);if(!H.success)throw Error(`Invalid plugin manifest:
12
+ ${$J.prettifyError(H.error)}`);let K=H.data,Y=K.recall.entry,W=a(X,Y.file),q=rJ(X,$.outDir),B=`${q}.zip`;if(q===W||QJ(q,W))throw Error("Output directory must not contain the plugin entry file.");if($.clean)J.info(`Cleaning ${i(X,q)}`),await s$(q,{recursive:!0,force:!0}),await s$(B,{force:!0});await yJ(q,{recursive:!0});let R=Y.runtime==="theme"?await bJ(W,q,J):await mJ(W,X,q,$,J),E={...K,recall:{...K.recall,entry:{...Y,file:R}}},G=a(q,"manifest.json");if(await Bun.write(G,N$(E)),J.success(`Generated ${i(X,G)}`),$.zip)await fJ(q,B,X,J);J.success("Plugin build complete")}async function mJ($,J,X,Q,V){V.info(`Building JavaScript entry ${$}`);let H=await pJ(J);if(H)V.info(`Using ${i(J,H)}`);let K=await Bun.build({entrypoints:[$],minify:Q.minify,outdir:X,root:J,sourcemap:Q.sourcemap?"external":"none",...H?{tsconfig:H}:{}});if(!K.success){let q=K.logs.map((B)=>B.message).join(`
13
13
  `);throw Error(`Failed to build JavaScript entry:
14
- ${R}`)}let X=V.outputs.find((R)=>R.kind==="entry-point");if(!X)throw Error(`Build did not produce an entry point for ${$}`);let Q=$J(E,X.path).replaceAll("\\","/");return B.success(`Generated ${Q}`),Q}async function _J($){let J=i($,"tsconfig.json");return await Bun.file(J).exists()?J:void 0}async function rJ($,J,E){E.info(`Validating theme entry ${$}`);let H=await Z$($,"theme entry file"),B=hJ.safeParse(H);if(!B.success)throw Error(`Invalid theme entry:
15
- ${JJ.prettifyError(B.error)}`);return await Bun.write(i(J,U$),j$(B.data)),E.success(`Generated ${U$}`),U$}async function mJ($,J,E,H){H.info(`Creating ${d(E,J)}`);let B=await HJ($);await Bun.write(J,a$(B)),H.success(`Generated ${d(E,J)}`)}async function HJ($,J=$,E={}){let H=await kJ(J,{withFileTypes:!0});for(let B of H.sort((Y,V)=>Y.name.localeCompare(V.name))){let Y=i(J,B.name);if(B.isDirectory()){await HJ($,Y,E);continue}if(!B.isFile())continue;let V=d($,Y);E[V]=new Uint8Array(await Bun.file(Y).arrayBuffer())}return E}function d($,J){return $J($,J).replaceAll("\\","/")||"."}function pJ($){if($ instanceof Error)return $.message;if(typeof $==="string")return $;return"Unknown error"}async function BJ($){try{await $()}catch(J){V$.error(pJ(J)),process.exit(1)}}var nJ=await Bun.file(new URL("../package.json",import.meta.url)).json(),J$=v$("plugin-creator");J$.command("build [root]","Build a Recall plugin package").option("--out-dir <dir>","Output directory",{default:"dist"}).option("--no-clean","Keep the output directory before building").option("--minify","Minify JavaScript entry output").option("--sourcemap","Emit external sourcemaps").option("--zip","Create a marketplace zip from the output directory").action(($,J)=>{BJ(()=>EJ({clean:J.clean,minify:J.minify??!1,outDir:J.outDir,rootDir:$??".",sourcemap:J.sourcemap??!1,zip:J.zip??!1}))});J$.help();J$.version(nJ.version);var N$=J$.parse();if(N$.args.length===0&&!N$.options.help&&!N$.options.version)J$.outputHelp();
14
+ ${q}`)}let Y=K.outputs.find((q)=>q.kind==="entry-point");if(!Y)throw Error(`Build did not produce an entry point for ${$}`);let W=S$(X,Y.path).replaceAll("\\","/");return V.success(`Generated ${W}`),W}async function pJ($){let J=a($,"tsconfig.json");return await Bun.file(J).exists()?J:void 0}async function bJ($,J,X){X.info(`Validating theme entry ${$}`);let Q=await T$($,"theme entry file"),V=uJ.safeParse(Q);if(!V.success)throw Error(`Invalid theme entry:
15
+ ${$J.prettifyError(V.error)}`);return await Bun.write(a(J,j$),N$(V.data)),X.success(`Generated ${j$}`),j$}async function fJ($,J,X,Q){Q.info(`Creating ${i(X,J)}`);let V=await XJ($);await Bun.write(J,i$(V)),Q.success(`Generated ${i(X,J)}`)}async function XJ($,J=$,X={}){let Q=await kJ(J,{withFileTypes:!0});for(let V of Q.sort((H,K)=>H.name.localeCompare(K.name))){let H=a(J,V.name);if(V.isDirectory()){await XJ($,H,X);continue}if(!V.isFile())continue;let K=i($,H);X[K]=new Uint8Array(await Bun.file(H).arrayBuffer())}return X}function rJ($,J){let X=t$($,J);if(!QJ($,X))throw Error("Output directory must be inside the plugin root.");return X}function QJ($,J){let X=S$($,J);return X!==""&&X!==".."&&!X.startsWith(`..${_J}`)&&!vJ(X)}function i($,J){return S$($,J).replaceAll("\\","/")||"."}function nJ($){if($ instanceof Error)return $.message;if(typeof $==="string")return $;return"Unknown error"}async function VJ($){try{await $()}catch(J){K$.error(nJ(J)),process.exitCode=1}}var cJ=await Bun.file(new URL("../package.json",import.meta.url)).json(),r=v$("plugin-creator");r.command("build [root]","Build a Recall plugin package").option("--out-dir <dir>","Output directory",{default:"dist"}).option("--no-clean","Keep the output directory before building").option("--minify","Minify JavaScript entry output").option("--sourcemap","Emit external sourcemaps").option("--zip","Create a marketplace zip from the output directory").action(($,J)=>JJ({clean:J.clean,minify:J.minify??!1,outDir:J.outDir,rootDir:$??".",sourcemap:J.sourcemap??!1,zip:J.zip??!1}));r.help();r.version(cJ.version);r.addEventListener("command:*",($)=>{let J=$.detail;throw Error(`Unknown command: ${J}`)});await VJ(async()=>{let $=r.parse(process.argv,{run:!1});if($.options.help||$.options.version)return;if(!r.matchedCommand){r.outputHelp();return}await r.runMatchedCommand()});
package/package.json CHANGED
@@ -1,12 +1,28 @@
1
1
  {
2
2
  "name": "@jrtilak-recall/plugin-creator",
3
- "version": "0.0.2-alpha.0",
4
- "description": "CLI tools for building Recall plugins.",
3
+ "version": "0.1.0",
4
+ "description": "Build and package Recall plugins from the command line.",
5
+ "author": "jrtilak <https://jrtilak.dev>",
6
+ "homepage": "https://docs.recall.jrtilak.dev/core-packages/plugin-creator/",
7
+ "keywords": [
8
+ "recall",
9
+ "plugin",
10
+ "cli",
11
+ "build",
12
+ "bun"
13
+ ],
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/jrTilak/recall.git",
17
+ "directory": "packages/plugin-creator"
18
+ },
19
+ "bugs": {
20
+ "url": "https://github.com/jrTilak/recall/issues"
21
+ },
5
22
  "type": "module",
6
23
  "bin": "./dist/cli.js",
7
24
  "files": [
8
25
  "dist",
9
- "CHANGELOG.md",
10
26
  "README.md"
11
27
  ],
12
28
  "scripts": {
@@ -18,13 +34,13 @@
18
34
  "@types/bun": "latest"
19
35
  },
20
36
  "dependencies": {
21
- "@jrtilak-recall/plugin-schema": "0.0.3-alpha.0",
37
+ "@jrtilak-recall/plugin-schema": "0.1.0",
22
38
  "cac": "^7.0.0",
23
39
  "fflate": "^0.8.3",
24
40
  "zod": "^4.4.3"
25
41
  },
26
42
  "peerDependencies": {
27
- "typescript": "^5"
43
+ "typescript": "^6"
28
44
  },
29
45
  "publishConfig": {
30
46
  "access": "public"
package/CHANGELOG.md DELETED
@@ -1,18 +0,0 @@
1
- # @jrtilak-recall/plugin-creator
2
-
3
- ## 0.0.2-alpha.0
4
-
5
- ### Patch Changes
6
-
7
- - Refactor the plugin creator into a proper `plugin-creator` CLI.
8
-
9
- - Add `plugin-creator build` with help, version, output directory, clean, minify,
10
- sourcemap, and marketplace zip flags.
11
- - Build against the new `recall.entry.runtime` and `recall.entry.file` manifest
12
- contract.
13
- - Use the published `@jrtilak-recall/plugin-schema@0.0.3-alpha.0` package
14
- instead of a workspace dependency.
15
- - Resolve JavaScript builds from the plugin project root and use its
16
- `tsconfig.json` when present.
17
- - Add clearer build logs and colocated validation for JavaScript and theme
18
- plugin entries.