@jrtilak-recall/plugin-creator 0.0.1 → 0.0.2-alpha.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/CHANGELOG.md +18 -0
- package/README.md +11 -3
- package/dist/cli.js +15 -0
- package/package.json +30 -25
- package/dist/build-plugin.js +0 -131
- package/src/scripts/build-plugin.ts +0 -89
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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.
|
package/README.md
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
# @recall/plugin-creator
|
|
1
|
+
# @jrtilak-recall/plugin-creator
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
CLI tools for building Recall plugins.
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
|
-
bunx @jrtilak-recall/plugin-creator build
|
|
6
|
+
bunx @jrtilak-recall/plugin-creator build
|
|
7
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.
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
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(`
|
|
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(`
|
|
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();
|
package/package.json
CHANGED
|
@@ -1,27 +1,32 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
2
|
+
"name": "@jrtilak-recall/plugin-creator",
|
|
3
|
+
"version": "0.0.2-alpha.0",
|
|
4
|
+
"description": "CLI tools for building Recall plugins.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": "./dist/cli.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"CHANGELOG.md",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "rm -rf ./dist && bun build ./src/cli.ts --outdir ./dist --minify --target bun --external @jrtilak-recall/plugin-schema --external zod",
|
|
14
|
+
"prepack": "bun run build",
|
|
15
|
+
"test": "bun test"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/bun": "latest"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@jrtilak-recall/plugin-schema": "0.0.3-alpha.0",
|
|
22
|
+
"cac": "^7.0.0",
|
|
23
|
+
"fflate": "^0.8.3",
|
|
24
|
+
"zod": "^4.4.3"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"typescript": "^5"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
}
|
|
27
32
|
}
|