@lunora/rspack 1.0.0-alpha.77 → 1.0.0-alpha.79

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/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { R as ResolvedLunoraRspackOptions, L as LunoraRspackOptions } from "./packem_shared/types.d-DVVPoWKu.mjs";
1
+ import { R as ResolvedLunoraRspackOptions, L as LunoraRspackOptions } from "./packem_shared/types.d-DCaFxXeH.mjs";
2
2
  import '@lunora/codegen';
3
3
  /**
4
4
  * The slice of the Rspack compiler this plugin touches, projected structurally.
@@ -104,8 +104,13 @@ declare class LunoraRspackPlugin {
104
104
  * this pass writes. Spawned first, wrangler dies on an unresolvable import
105
105
  * before the first compilation ever generates it. The first compilation then
106
106
  * finds the fingerprint unchanged and skips its own pass.
107
+ *
108
+ * Returns the target that pass generated for, so the Worker started next is the
109
+ * one its output matches. Reading `target` again after this resolves would leave
110
+ * a window in which an edit to `lunora.config.*` starts a Worker against output
111
+ * for the other target.
107
112
  */
108
- generateForDev(): Promise<void>;
113
+ generateForDev(): Promise<string>;
109
114
  /** Rspack's plugin entry point. */
110
115
  apply(compiler: CompilerLike): void;
111
116
  }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { R as ResolvedLunoraRspackOptions, L as LunoraRspackOptions } from "./packem_shared/types.d-DVVPoWKu.js";
1
+ import { R as ResolvedLunoraRspackOptions, L as LunoraRspackOptions } from "./packem_shared/types.d-DCaFxXeH.js";
2
2
  import '@lunora/codegen';
3
3
  /**
4
4
  * The slice of the Rspack compiler this plugin touches, projected structurally.
@@ -104,8 +104,13 @@ declare class LunoraRspackPlugin {
104
104
  * this pass writes. Spawned first, wrangler dies on an unresolvable import
105
105
  * before the first compilation ever generates it. The first compilation then
106
106
  * finds the fingerprint unchanged and skips its own pass.
107
+ *
108
+ * Returns the target that pass generated for, so the Worker started next is the
109
+ * one its output matches. Reading `target` again after this resolves would leave
110
+ * a window in which an edit to `lunora.config.*` starts a Worker against output
111
+ * for the other target.
107
112
  */
108
- generateForDev(): Promise<void>;
113
+ generateForDev(): Promise<string>;
109
114
  /** Rspack's plugin entry point. */
110
115
  apply(compiler: CompilerLike): void;
111
116
  }
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{createRequire as r}from"node:module";import{r as e}from"./packem_shared/options-DDIOylz7.mjs";import{LunoraRspackPlugin as t}from"./packem_shared/LunoraRspackPlugin-D2MOKumS.mjs";const s=o=>new t(e(o)),i=r(import.meta.url)("../package.json").version;export{t as LunoraRspackPlugin,i as VERSION,s as lunoraRspack};
1
+ import{createRequire as r}from"node:module";import{L as e,r as a}from"./packem_shared/plugin-BcI1b7ej.mjs";const t=o=>new e(a(o)),p=r(import.meta.url)("../package.json").version;export{e as LunoraRspackPlugin,p as VERSION,t as lunoraRspack};
@@ -0,0 +1 @@
1
+ import{L as r,P as s}from"./plugin-BcI1b7ej.mjs";export{r as LunoraRspackPlugin,s as PLUGIN_NAME};
@@ -0,0 +1,4 @@
1
+ import{createHash as j}from"node:crypto";import{existsSync as m,readFileSync as w}from"node:fs";import{join as v,resolve as a}from"node:path";import{createCodegenProject as y,refreshCodegenProject as E,runCodegen as S,findTsconfig as l,PROJECT_CONFIG_FILENAMES as d,projectConfigCandidatePaths as g,fingerprintSchemaSources as P}from"@lunora/codegen";import{resolveTargetOrThrow as D,isRunnableTarget as C,runnableTargetIds as F,resolveLazyFunctions as T,LUNORA_TAG as b,reportCodegenFindings as L,blockingFindingsMessage as k,isCodegenDisabled as I,CODEGEN_ENV as u,lunoraLine as c,runPostCodegenHook as A,ensureDevVariables as N,createConfirm as _,fillDevSecrets as O,ensureDevWorkerEnv as $,detectAgentRules as W,claimAgentRulesHint as x,AGENT_RULES_HINT as G}from"@lunora/config";import{wranglerCodegenInputs as M,reconcileWranglerExtras as z,WRANGLER_FILES as H,warnCloudflareCliConfigOnce as U,findWranglerFile as B,reconcileBindingsSafely as V,assertWranglerSatisfiesSchema as J}from"@lunora/config/cloudflare";const R=(e,t)=>{const r=D(e,t);if(!C(r))throw new Error(`target "${r}" has no command-line toolchain, so the Lunora Rspack plugin cannot build for it — it can only generate for it (\`lunora codegen --target ${r}\`). Buildable targets: ${F().join(", ")}`);return r},st=e=>{const t=e??{},r=t.projectRoot??process.cwd();return{apiSpec:t.apiSpec??"openapi",explicitTarget:t.target,lazyFunctions:T(t.lazyFunctions),projectRoot:r,schemaDir:t.schemaDir??"lunora",target:R(r,t.target),validateWrangler:t.validateWrangler??!0}},X=(e,t,r)=>{const i=v(e.projectRoot,e.schemaDir,"schema.ts");if(!m(i)){t.warn(`${b} no schema found at ${i} — run \`lunora init\` or create it, then rebuild.`);return}const s=S({apiSpec:e.apiSpec,lazyFunctions:e.lazyFunctions,lunoraDirectory:e.schemaDir,project:r,projectRoot:e.projectRoot,target:e.target,...M(e.projectRoot)});return z(e.projectRoot,s.cronTriggers,t),L(s,t),k(s)},q=e=>{let t;return{drop:()=>{t=void 0},get:()=>(t===void 0?t=y(e):E(t,e),t)}},p="LunoraRspackPlugin",K=2,h=e=>{try{return w(e,"utf8")}catch{return""}},n={error:e=>{console.error(e)},info:e=>{console.info(e)},warn:e=>{console.warn(e)}},f=async e=>{const t=r=>{n.info(c(r))};await N({confirm:_("[lunora] "),cwd:e.projectRoot,info:t}),O({cwd:e.projectRoot,info:t}),$(e.projectRoot,t),!W(e.projectRoot).installed&&x()&&n.warn(`
2
+ ${c(G)}
3
+ `)};class it{#t;#c;#e;#h;#o;#s=!1;#l=!1;#n;#d;#i=[];#r;#a;constructor(t){this.#t=t,this.#e=a(t.projectRoot,t.schemaDir),this.#h=I(process.env[u]),this.#o=q(this.#e)}async prepareDevSession(){this.#u(),!this.#s&&(this.#s=!0,await f(this.#t))}async generateForDev(){return await this.#g(!0),this.#c??this.#t.target}apply(t){t.hooks.beforeCompile.tapPromise(p,async()=>{await this.#g(t.watchMode===!0)}),t.hooks.afterCompile.tapPromise(p,r=>{r.contextDependencies.add(this.#e);const i=l(this.#e);i!==void 0&&r.fileDependencies.add(i);const s=[...H.map(o=>a(this.#t.projectRoot,o)),...d.map(o=>a(this.#t.projectRoot,o)),...g(this.#e)];for(const o of new Set(s))m(o)?r.fileDependencies.add(o):r.missingDependencies.add(o);for(const o of this.#i)r.errors.push(o);return Promise.resolve()})}async#g(t){this.#a??=this.#f(t).finally(()=>{this.#a=void 0}),await this.#a}#u(){this.#l||(this.#l=U(this.#t.projectRoot,t=>{n.warn(c(t))}))}async#f(t){if(this.#u(),t&&this.#h){this.#s||(this.#s=!0,n.info(c(`codegen disabled via ${u} — skipping generation and the wrangler checks.`)));return}const r=this.#w();r!==this.#d&&(this.#o.drop(),this.#d=r,this.#n=void 0);const i=this.#R(r);if(!this.#m(i)){this.#i=[];try{!this.#s&&t&&await f(this.#t),this.#s=!0,await this.#j(t),this.#i.length===0?(this.#n=i,this.#r=void 0):this.#p(i)}catch(s){this.#o.drop(),this.#n=void 0,this.#i.push(s instanceof Error?s:new Error(String(s))),this.#p(i),n.error(s instanceof Error?s.message:String(s))}}}#m(t){return t===this.#n?!0:this.#r!==void 0&&this.#r.fingerprint===t&&this.#r.attempts>=K}#p(t){this.#r=this.#r?.fingerprint===t?{attempts:this.#r.attempts+1,fingerprint:t}:{attempts:1,fingerprint:t}}#R(t){const r=B(this.#t.projectRoot);return[P(this.#e),t,r===void 0?"":h(r)].map(s=>j("sha256").update(s).digest("hex")).join("")}async#j(t){this.#t={...this.#t,target:R(this.#t.projectRoot,this.#t.explicitTarget)},await V(this.#t,n),this.#t.validateWrangler&&J(this.#t,n.warn,"Update your wrangler.jsonc and rebuild.");const r=X(this.#t,n,this.#o.get());this.#c=this.#t.target;const i=await A({cwd:this.#t.projectRoot,logger:n});i.error!==void 0&&this.#i.push(new Error(i.error)),!t&&r!==void 0&&this.#i.push(new Error(r))}#w(){const t=l(this.#e),i=[...new Set([...g(this.#e),...d.map(s=>a(this.#t.projectRoot,s))])].map(s=>`${s}
4
+ ${h(s)}`);return[t===void 0?"":h(t),...i].join("\0")}}export{it as L,p as P,st as r};
@@ -38,6 +38,8 @@ interface LunoraRspackOptions {
38
38
  /** Resolved options after merging defaults. */
39
39
  interface ResolvedLunoraRspackOptions {
40
40
  apiSpec: NonNullable<CodegenOptions["apiSpec"]>;
41
+ /** The target the caller passed, if any. Kept so a `lunora.config.*` edit can re-resolve `target` in watch mode. */
42
+ explicitTarget: string | undefined;
41
43
  lazyFunctions: boolean;
42
44
  projectRoot: string;
43
45
  schemaDir: string;
@@ -38,6 +38,8 @@ interface LunoraRspackOptions {
38
38
  /** Resolved options after merging defaults. */
39
39
  interface ResolvedLunoraRspackOptions {
40
40
  apiSpec: NonNullable<CodegenOptions["apiSpec"]>;
41
+ /** The target the caller passed, if any. Kept so a `lunora.config.*` edit can re-resolve `target` in watch mode. */
42
+ explicitTarget: string | undefined;
41
43
  lazyFunctions: boolean;
42
44
  projectRoot: string;
43
45
  schemaDir: string;
@@ -1,5 +1,5 @@
1
1
  import { IncomingMessage, ServerResponse } from 'node:http';
2
- import { L as LunoraRspackOptions } from "./packem_shared/types.d-DVVPoWKu.mjs";
2
+ import { L as LunoraRspackOptions } from "./packem_shared/types.d-DCaFxXeH.mjs";
3
3
  import '@lunora/codegen';
4
4
  /** Path prefix the Lunora Worker serves — RPC, the WebSocket, and the studio. */
5
5
  declare const LUNORA_PATH = "/_lunora";
package/dist/rsbuild.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { IncomingMessage, ServerResponse } from 'node:http';
2
- import { L as LunoraRspackOptions } from "./packem_shared/types.d-DVVPoWKu.js";
2
+ import { L as LunoraRspackOptions } from "./packem_shared/types.d-DCaFxXeH.js";
3
3
  import '@lunora/codegen';
4
4
  /** Path prefix the Lunora Worker serves — RPC, the WebSocket, and the studio. */
5
5
  declare const LUNORA_PATH = "/_lunora";
package/dist/rsbuild.mjs CHANGED
@@ -1 +1 @@
1
- import{formatLunoraEvent as m,lunoraLine as c,acceptsConnection as h,startDevProcess as y,targetRunsOwnDevServer as S,startCelldDevSession as R}from"@lunora/config";import{createStudioMiddleware as k,isNonLoopbackHost as A,studioMountPath as D}from"@lunora/config/studio-host";import{r as b}from"./packem_shared/options-DDIOylz7.mjs";import{LunoraRspackPlugin as L}from"./packem_shared/LunoraRspackPlugin-D2MOKumS.mjs";import{existsSync as P,mkdirSync as E}from"node:fs";import{resolve as g,dirname as W}from"node:path";import{findWranglerFile as j,readWranglerJsonc as x}from"@lunora/config/cloudflare";const O=8787,_=3e4,u=(r,e,t)=>{let o;for(const[n,a]of r.entries())a.startsWith(`${e}=`)?o=a.slice(e.length+1):(a===e||a===t)&&n+1<r.length&&(o=r[n+1]);return o},f=(r,e=[])=>{const t=u(e,"--config","-c"),o=t===void 0?j(r):g(r,t);if(o===void 0||!P(o))return;const{parsed:n}=x(o);return n===void 0?void 0:{config:n,env:u(e,"--env","-e"),path:o}},$=(r,e,t)=>{if(e!==void 0)return e;const o=f(r,t)?.config.dev?.port;return typeof o=="number"?o:O},T=(r,e)=>{const t=f(r,e);if(t===void 0)return;const n=((t.env===void 0?void 0:t.config.env?.[t.env]?.assets)??t.config.assets)?.directory;typeof n=="string"&&E(g(W(t.path),n),{recursive:!0})},p=r=>{const e=m(r);if(e===void 0){r.trim()!==""&&console.log(r);return}const t=c(e.text);e.level==="error"?console.error(t):e.level==="warn"?console.warn(t):console.info(t)},C=async r=>{if(await h(r.port))throw new Error(`could not start the worker: port ${String(r.port)} is already in use. Stop whatever is serving there (another \`rsbuild dev\` or \`lunora dev\`?), or set \`workerPort\`.`);T(r.projectRoot,r.wranglerArgs);const e=process.platform==="win32",t=await y({args:["dev","--port",String(r.port),"--var","WORKER_ENV:development",...r.wranglerArgs??[]],command:e?"wrangler.cmd":"wrangler",cwd:r.projectRoot,label:"wrangler dev",notFound:"could not start the worker: `wrangler` was not found on PATH. Add it to the project (`npm install -D wrangler`), or pass `worker: false` to run the worker yourself.",onLine:p,port:r.port,readyTimeoutMs:_,shell:e});return{port:r.port,stop:t.stop}},v="/_lunora",F="lunora:rsbuild",M=(r,e)=>{const t=`http://127.0.0.1:${String(e)}`;return Array.isArray(r)?[...r,{changeOrigin:!0,pathFilter:v,target:t,ws:!0}]:{[v]:{changeOrigin:!0,target:t,ws:!0},...r}},N=(r,e)=>{r.onBeforeStartDevServer(({server:t})=>{const{base:o,host:n}=r.getRsbuildConfig().server??{};t.middlewares.use(k({apiSpec:e.apiSpec,lazyFunctions:e.lazyFunctions,base:o,isNonLoopbackBind:A(n),projectRoot:e.projectRoot,schemaDirectory:e.schemaDir}))}),r.onAfterStartDevServer(({port:t})=>{console.info(c(`studio on http://localhost:${String(t)}${D(r.getRsbuildConfig().server?.base)}`))})},G=r=>{const e=b(r),t=$(e.projectRoot,r?.workerPort,r?.wranglerArgs),o=new L(e);return{name:F,setup:n=>{if(n.modifyRspackConfig(s=>({...s,plugins:[...Array.isArray(s.plugins)?s.plugins:[],o]})),n.modifyRsbuildConfig(s=>({...s,server:{...s.server,proxy:M(s.server?.proxy,t)}})),r?.studio!==!1&&N(n,e),r?.worker===!1)return;let a,l;n.onBeforeStartDevServer(async()=>{if(await o.prepareDevSession(),await o.generateForDev(),console.info(c(`starting the worker on http://127.0.0.1:${String(t)} …`)),S(e.target)){const s=await R({log:(i,{tag:d})=>{p(d==="celld"?i:`[${d}] ${i}`)},port:t,projectRoot:e.projectRoot});l=s;const w=i=>{console.error(c(`the worker on celld exited (code ${String(i)}) — restart \`rsbuild dev\` to bring it back`))};s.exited.then(w).catch(()=>{});return}a=await C({port:t,projectRoot:e.projectRoot,wranglerArgs:r?.wranglerArgs})}),n.onCloseDevServer(async()=>{await a?.stop(),await l?.stop(),a=void 0,l=void 0})}}};export{v as LUNORA_PATH,F as RSBUILD_PLUGIN_NAME,G as lunoraRsbuild,M as withLunoraProxy};
1
+ import{formatLunoraEvent as h,lunoraLine as c,acceptsConnection as y,startDevProcess as S,targetRunsOwnDevServer as R,startCelldDevSession as k}from"@lunora/config";import{createStudioMiddleware as A,isNonLoopbackHost as D,studioMountPath as b}from"@lunora/config/studio-host";import{r as L,L as P}from"./packem_shared/plugin-BcI1b7ej.mjs";import{existsSync as E,mkdirSync as W}from"node:fs";import{resolve as f,dirname as j}from"node:path";import{findWranglerFile as x,readWranglerJsonc as O}from"@lunora/config/cloudflare";const _=8787,$=3e4,v=(r,e,t)=>{let o;for(const[n,a]of r.entries())a.startsWith(`${e}=`)?o=a.slice(e.length+1):(a===e||a===t)&&n+1<r.length&&(o=r[n+1]);return o},p=(r,e=[])=>{const t=v(e,"--config","-c"),o=t===void 0?x(r):f(r,t);if(o===void 0||!E(o))return;const{parsed:n}=O(o);return n===void 0?void 0:{config:n,env:v(e,"--env","-e"),path:o}},T=(r,e,t)=>{if(e!==void 0)return e;const o=p(r,t)?.config.dev?.port;return typeof o=="number"?o:_},C=(r,e)=>{const t=p(r,e);if(t===void 0)return;const n=((t.env===void 0?void 0:t.config.env?.[t.env]?.assets)??t.config.assets)?.directory;typeof n=="string"&&W(f(j(t.path),n),{recursive:!0})},w=r=>{const e=h(r);if(e===void 0){r.trim()!==""&&console.log(r);return}const t=c(e.text);e.level==="error"?console.error(t):e.level==="warn"?console.warn(t):console.info(t)},F=async r=>{if(await y(r.port))throw new Error(`could not start the worker: port ${String(r.port)} is already in use. Stop whatever is serving there (another \`rsbuild dev\` or \`lunora dev\`?), or set \`workerPort\`.`);C(r.projectRoot,r.wranglerArgs);const e=process.platform==="win32",t=await S({args:["dev","--port",String(r.port),"--var","WORKER_ENV:development",...r.wranglerArgs??[]],command:e?"wrangler.cmd":"wrangler",cwd:r.projectRoot,label:"wrangler dev",notFound:"could not start the worker: `wrangler` was not found on PATH. Add it to the project (`npm install -D wrangler`), or pass `worker: false` to run the worker yourself.",onLine:w,port:r.port,readyTimeoutMs:$,shell:e});return{port:r.port,stop:t.stop}},g="/_lunora",M="lunora:rsbuild",N=(r,e)=>{const t=`http://127.0.0.1:${String(e)}`;return Array.isArray(r)?[...r,{changeOrigin:!0,pathFilter:g,target:t,ws:!0}]:{[g]:{changeOrigin:!0,target:t,ws:!0},...r}},U=(r,e)=>{r.onBeforeStartDevServer(({server:t})=>{const{base:o,host:n}=r.getRsbuildConfig().server??{};t.middlewares.use(A({apiSpec:e.apiSpec,lazyFunctions:e.lazyFunctions,base:o,isNonLoopbackBind:D(n),projectRoot:e.projectRoot,schemaDirectory:e.schemaDir}))}),r.onAfterStartDevServer(({port:t})=>{console.info(c(`studio on http://localhost:${String(t)}${b(r.getRsbuildConfig().server?.base)}`))})},G=r=>{const e=L(r),t=T(e.projectRoot,r?.workerPort,r?.wranglerArgs),o=new P(e);return{name:M,setup:n=>{if(n.modifyRspackConfig(s=>({...s,plugins:[...Array.isArray(s.plugins)?s.plugins:[],o]})),n.modifyRsbuildConfig(s=>({...s,server:{...s.server,proxy:N(s.server?.proxy,t)}})),r?.studio!==!1&&U(n,e),r?.worker===!1)return;let a,l;n.onBeforeStartDevServer(async()=>{await o.prepareDevSession();const s=await o.generateForDev();if(console.info(c(`starting the worker on http://127.0.0.1:${String(t)} …`)),R(s)){const d=await k({log:(i,{tag:u})=>{w(u==="celld"?i:`[${u}] ${i}`)},port:t,projectRoot:e.projectRoot});l=d;const m=i=>{console.error(c(`the worker on celld exited (code ${String(i)}) — restart \`rsbuild dev\` to bring it back`))};d.exited.then(m).catch(()=>{});return}a=await F({port:t,projectRoot:e.projectRoot,wranglerArgs:r?.wranglerArgs})}),n.onCloseDevServer(async()=>{await a?.stop(),await l?.stop(),a=void 0,l=void 0})}}};export{g as LUNORA_PATH,M as RSBUILD_PLUGIN_NAME,G as lunoraRsbuild,N as withLunoraProxy};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/rspack",
3
- "version": "1.0.0-alpha.77",
3
+ "version": "1.0.0-alpha.79",
4
4
  "description": "The Lunora Rspack plugin: codegen, binding provisioning, and wrangler validation for Rspack projects",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -51,8 +51,8 @@
51
51
  "access": "public"
52
52
  },
53
53
  "dependencies": {
54
- "@lunora/codegen": "1.0.0-alpha.331",
55
- "@lunora/config": "1.0.0-alpha.381"
54
+ "@lunora/codegen": "1.0.0-alpha.334",
55
+ "@lunora/config": "1.0.0-alpha.383"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "@lunora/studio": ">=1.0.0-alpha.50 <2.0.0-0",
@@ -1,3 +0,0 @@
1
- import{createHash as p}from"node:crypto";import{existsSync as g,readFileSync as m}from"node:fs";import{join as v,resolve as c}from"node:path";import{createCodegenProject as w,refreshCodegenProject as R,runCodegen as j,findTsconfig as h,fingerprintSchemaSources as y}from"@lunora/codegen";import{LUNORA_TAG as E,reportCodegenFindings as D,blockingFindingsMessage as S,isCodegenDisabled as C,CODEGEN_ENV as d,lunoraLine as n,runPostCodegenHook as P,ensureDevVariables as F,createConfirm as k,fillDevSecrets as b,ensureDevWorkerEnv as L,detectAgentRules as A,claimAgentRulesHint as N,AGENT_RULES_HINT as T}from"@lunora/config";import{wranglerCodegenInputs as _,reconcileWranglerExtras as I,WRANGLER_FILES as W,warnCloudflareCliConfigOnce as x,findWranglerFile as G,reconcileBindingsSafely as M,assertWranglerSatisfiesSchema as H}from"@lunora/config/cloudflare";const O=(t,e,r)=>{const i=v(t.projectRoot,t.schemaDir,"schema.ts");if(!g(i)){e.warn(`${E} no schema found at ${i} — run \`lunora init\` or create it, then rebuild.`);return}const s=j({apiSpec:t.apiSpec,lazyFunctions:t.lazyFunctions,lunoraDirectory:t.schemaDir,project:r,projectRoot:t.projectRoot,target:t.target,..._(t.projectRoot)});return I(t.projectRoot,s.cronTriggers,e),D(s,e),S(s)},U=t=>{let e;return{drop:()=>{e=void 0},get:()=>(e===void 0?e=w(t):R(e,t),e)}},f="LunoraRspackPlugin",$=2,l=t=>{try{return m(t,"utf8")}catch{return""}},o={error:t=>{console.error(t)},info:t=>{console.info(t)},warn:t=>{console.warn(t)}},u=async t=>{const e=r=>{o.info(n(r))};await F({confirm:k("[lunora] "),cwd:t.projectRoot,info:e}),b({cwd:t.projectRoot,info:e}),L(t.projectRoot,e),!A(t.projectRoot).installed&&N()&&o.warn(`
2
- ${n(T)}
3
- `)};class K{#e;#r;#c;#o;#s=!1;#h=!1;#n;#d;#i=[];#t;#a;constructor(e){this.#e=e,this.#r=c(e.projectRoot,e.schemaDir),this.#c=C(process.env[d]),this.#o=U(this.#r)}async prepareDevSession(){this.#l(),!this.#s&&(this.#s=!0,await u(this.#e))}async generateForDev(){await this.#f(!0)}apply(e){e.hooks.beforeCompile.tapPromise(f,async()=>{await this.#f(e.watchMode===!0)}),e.hooks.afterCompile.tapPromise(f,r=>{r.contextDependencies.add(this.#r);const i=h(this.#r);i!==void 0&&r.fileDependencies.add(i);for(const s of W){const a=c(this.#e.projectRoot,s);g(a)?r.fileDependencies.add(a):r.missingDependencies.add(a)}for(const s of this.#i)r.errors.push(s);return Promise.resolve()})}async#f(e){this.#a??=this.#g(e).finally(()=>{this.#a=void 0}),await this.#a}#l(){this.#h||(this.#h=x(this.#e.projectRoot,e=>{o.warn(n(e))}))}async#g(e){if(this.#l(),e&&this.#c){this.#s||(this.#s=!0,o.info(n(`codegen disabled via ${d} — skipping generation and the wrangler checks.`)));return}const r=this.#w();r!==this.#d&&(this.#o.drop(),this.#d=r,this.#n=void 0);const i=this.#m(r);if(!this.#p(i)){this.#i=[];try{!this.#s&&e&&await u(this.#e),this.#s=!0,await this.#v(e),this.#i.length===0?(this.#n=i,this.#t=void 0):this.#u(i)}catch(s){this.#o.drop(),this.#n=void 0,this.#i.push(s instanceof Error?s:new Error(String(s))),this.#u(i),o.error(s instanceof Error?s.message:String(s))}}}#p(e){return e===this.#n?!0:this.#t!==void 0&&this.#t.fingerprint===e&&this.#t.attempts>=$}#u(e){this.#t=this.#t?.fingerprint===e?{attempts:this.#t.attempts+1,fingerprint:e}:{attempts:1,fingerprint:e}}#m(e){const r=G(this.#e.projectRoot);return[y(this.#r),e,r===void 0?"":l(r)].map(s=>p("sha256").update(s).digest("hex")).join("")}async#v(e){await M(this.#e,o),this.#e.validateWrangler&&H(this.#e,o.warn,"Update your wrangler.jsonc and rebuild.");const r=O(this.#e,o,this.#o.get()),i=await P({cwd:this.#e.projectRoot,logger:o});i.error!==void 0&&this.#i.push(new Error(i.error)),!e&&r!==void 0&&this.#i.push(new Error(r))}#w(){const e=h(this.#r);return e===void 0?"":l(e)}}export{K as LunoraRspackPlugin,f as PLUGIN_NAME};
@@ -1 +0,0 @@
1
- import{resolveLazyFunctions as o,resolveTargetOrThrow as n,isRunnableTarget as a,runnableTargetIds as i}from"@lunora/config";const s=(t,r)=>{const e=n(t,r);if(!a(e))throw new Error(`target "${e}" has no command-line toolchain, so the Lunora Rspack plugin cannot build for it — it can only generate for it (\`lunora codegen --target ${e}\`). Buildable targets: ${i().join(", ")}`);return e},l=t=>{const r=t??{},e=r.projectRoot??process.cwd();return{apiSpec:r.apiSpec??"openapi",lazyFunctions:o(r.lazyFunctions),projectRoot:e,schemaDir:r.schemaDir??"lunora",target:s(e,r.target),validateWrangler:r.validateWrangler??!0}};export{l as r};