@lunora/vite 1.0.0-alpha.200 → 1.0.0-alpha.202
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
|
@@ -252,17 +252,18 @@ type GeneratedClassModule = (typeof GENERATED_CLASS_MODULES)[number];
|
|
|
252
252
|
* Build the source of the virtual class-A worker entry. Pure (no fs / no Vite),
|
|
253
253
|
* so the emitted composition is unit-testable in isolation.
|
|
254
254
|
*
|
|
255
|
-
* The emitted module imports the framework SSR handler
|
|
256
|
-
* generated
|
|
257
|
-
*
|
|
258
|
-
*
|
|
255
|
+
* The emitted module imports the framework SSR handler and the project's
|
|
256
|
+
* generated `defineApp()` builder, and mounts the handler as the app's
|
|
257
|
+
* `httpRouter` — reserved `/_lunora/*` paths route to Lunora, everything else
|
|
258
|
+
* falls through to the framework SSR handler. `.build()` yields the whole
|
|
259
|
+
* module worker (`fetch` / `scheduled` / `queue` / `email`) plus `ShardDO`. The
|
|
259
260
|
* `generatedImportBase` MUST be an absolute filesystem path to the `_generated`
|
|
260
261
|
* directory. Virtual modules have no real filesystem path, so relative specifiers
|
|
261
262
|
* like `./lunora/_generated/functions` cannot be resolved by Vite/rolldown from a
|
|
262
263
|
* virtual module id. Absolute paths are resolved correctly in all environments
|
|
263
264
|
* (Vite 8 + rolldown 1.x confirmed).
|
|
264
265
|
*/
|
|
265
|
-
declare const buildWorkerEntrySource: (framework: DetectedFramework, generatedImportBase: string, classModules?: ReadonlyArray<GeneratedClassModule>,
|
|
266
|
+
declare const buildWorkerEntrySource: (framework: DetectedFramework, generatedImportBase: string, classModules?: ReadonlyArray<GeneratedClassModule>, allowUnauthenticatedShardAccess?: boolean, shard?: LunoraShardConfig) => string;
|
|
266
267
|
/**
|
|
267
268
|
* Vite plugin that auto-composes a detected class-A meta-framework's SSR
|
|
268
269
|
* handler with Lunora into one Cloudflare Worker (PLAN4 §2.4 / §3 class-A row).
|
package/dist/index.d.ts
CHANGED
|
@@ -252,17 +252,18 @@ type GeneratedClassModule = (typeof GENERATED_CLASS_MODULES)[number];
|
|
|
252
252
|
* Build the source of the virtual class-A worker entry. Pure (no fs / no Vite),
|
|
253
253
|
* so the emitted composition is unit-testable in isolation.
|
|
254
254
|
*
|
|
255
|
-
* The emitted module imports the framework SSR handler
|
|
256
|
-
* generated
|
|
257
|
-
*
|
|
258
|
-
*
|
|
255
|
+
* The emitted module imports the framework SSR handler and the project's
|
|
256
|
+
* generated `defineApp()` builder, and mounts the handler as the app's
|
|
257
|
+
* `httpRouter` — reserved `/_lunora/*` paths route to Lunora, everything else
|
|
258
|
+
* falls through to the framework SSR handler. `.build()` yields the whole
|
|
259
|
+
* module worker (`fetch` / `scheduled` / `queue` / `email`) plus `ShardDO`. The
|
|
259
260
|
* `generatedImportBase` MUST be an absolute filesystem path to the `_generated`
|
|
260
261
|
* directory. Virtual modules have no real filesystem path, so relative specifiers
|
|
261
262
|
* like `./lunora/_generated/functions` cannot be resolved by Vite/rolldown from a
|
|
262
263
|
* virtual module id. Absolute paths are resolved correctly in all environments
|
|
263
264
|
* (Vite 8 + rolldown 1.x confirmed).
|
|
264
265
|
*/
|
|
265
|
-
declare const buildWorkerEntrySource: (framework: DetectedFramework, generatedImportBase: string, classModules?: ReadonlyArray<GeneratedClassModule>,
|
|
266
|
+
declare const buildWorkerEntrySource: (framework: DetectedFramework, generatedImportBase: string, classModules?: ReadonlyArray<GeneratedClassModule>, allowUnauthenticatedShardAccess?: boolean, shard?: LunoraShardConfig) => string;
|
|
266
267
|
/**
|
|
267
268
|
* Vite plugin that auto-composes a detected class-A meta-framework's SSR
|
|
268
269
|
* handler with Lunora into one Cloudflare Worker (PLAN4 §2.4 / §3 class-A row).
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{createRequire as i}from"node:module";import{cloudflare as l}from"@cloudflare/vite-plugin";import{detectAgentRules as s,claimAgentRulesHint as u,AGENT_RULES_HINT as c,detectFramework as f,resolveTargetOrThrow as d,isRunnableTarget as m,runnableTargetIds as p}from"@lunora/config";import{detectFramework as ar}from"@lunora/config";import g from"@visulima/vite-overlay";import{l as a}from"./packem_shared/log-DE48L4Oz.mjs";import{r as S,c as v}from"./packem_shared/codegen-plugin-dg384k5b.mjs";import w from"./packem_shared/containerLogsPlugin-CWkqSCL3.mjs";import R from"./packem_shared/devStatePlugin-CcFV-eBl.mjs";import h from"./packem_shared/devVariablesPlugin-DY_bJXsX.mjs";import{frameworkComposePlugin as k}from"./packem_shared/CLASS_A_WIRING-
|
|
1
|
+
import{createRequire as i}from"node:module";import{cloudflare as l}from"@cloudflare/vite-plugin";import{detectAgentRules as s,claimAgentRulesHint as u,AGENT_RULES_HINT as c,detectFramework as f,resolveTargetOrThrow as d,isRunnableTarget as m,runnableTargetIds as p}from"@lunora/config";import{detectFramework as ar}from"@lunora/config";import g from"@visulima/vite-overlay";import{l as a}from"./packem_shared/log-DE48L4Oz.mjs";import{r as S,c as v}from"./packem_shared/codegen-plugin-dg384k5b.mjs";import w from"./packem_shared/containerLogsPlugin-CWkqSCL3.mjs";import R from"./packem_shared/devStatePlugin-CcFV-eBl.mjs";import h from"./packem_shared/devVariablesPlugin-DY_bJXsX.mjs";import{frameworkComposePlugin as k}from"./packem_shared/CLASS_A_WIRING-DhnXqptk.mjs";import{CLASS_A_WIRING as lr,GENERATED_CLASS_MODULES as sr,LUNORA_WORKER_VIRTUAL_ID as ur,buildWorkerEntrySource as cr,isAutoComposable as fr}from"./packem_shared/CLASS_A_WIRING-DhnXqptk.mjs";import P from"./packem_shared/logStreamPlugin-DtOu5VX8.mjs";import{proxyCheckPlugin as A}from"./packem_shared/checkLunoraProxy-C9M8c5eS.mjs";import{checkLunoraProxy as mr}from"./packem_shared/checkLunoraProxy-C9M8c5eS.mjs";import{remoteBindingsPlugin as E}from"./packem_shared/planViteRemoteBindings-E3GdC6pY.mjs";import{planViteRemoteBindings as gr,withRemoteBindings as Sr}from"./packem_shared/planViteRemoteBindings-E3GdC6pY.mjs";import{lunoraSolutionFinders as T}from"./packem_shared/lunoraSolutionFinder--J0x2mAM.mjs";import{lunoraSolutionFinder as wr}from"./packem_shared/lunoraSolutionFinder--J0x2mAM.mjs";import{studioPlugin as _}from"./packem_shared/STUDIO_PATH-UztnV2ca.mjs";import{STUDIO_PATH as hr,buildStudioUrl as kr}from"./packem_shared/STUDIO_PATH-UztnV2ca.mjs";import{withWorkerStartupHint as x}from"./packem_shared/WORKER_STARTUP_HINT-COlRTY32.mjs";import{WORKER_STARTUP_HINT as Ar,augmentWorkerStartupError as Er,isWorkerEntryEvalError as Tr}from"./packem_shared/WORKER_STARTUP_HINT-COlRTY32.mjs";import{wranglerValidatorPlugin as O}from"./packem_shared/wranglerValidatorPlugin-BdKLAEoq.mjs";import{default as xr}from"./packem_shared/LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs";import{reconcileWranglerCrons as br}from"@lunora/config/cloudflare";const b=o=>({apply:"serve",configureServer(r){return()=>{s(o.projectRoot).installed||!u()||r.config.logger.warn(`
|
|
2
2
|
${a(c)}
|
|
3
3
|
`)}},name:"lunora:agent-rules-hint"}),y=o=>({async config(r,t){t.isPreview!==!0&&await S(o,{info:e=>{console.info(e)},warn:e=>{console.warn(e)}})},enforce:"pre",name:"lunora:bindings-provision"}),L=()=>({}),W={astro:"Astro",none:"standalone (SPA / SSR-less)",nuxt:"Nuxt","react-router":"React Router","solid-start":"SolidStart",sveltekit:"SvelteKit","tanstack-start":"TanStack Start","tanstack-start-solid":"TanStack Start (Solid)",vinext:"Next.js on Vite (vinext)"},D=o=>{const r=W[o.framework];return o.framework==="none"?a("no meta-framework detected — running standalone."):o.class==="B"?a(`detected ${r} — composition is handled by the framework adapter.`):a(`detected ${r} — composing the Lunora worker into one Cloudflare Worker.`)},C=(o,r)=>{let t=!1;const e=()=>{r.framework??=f(o.projectRoot)};return{config(){e()},configResolved(){e()},configureServer(){e(),!t&&r.framework!==void 0&&(t=!0,console.info(D(r.framework)))},name:"lunora:framework-detect"}},N=o=>{if(o===!1)return!1;const r=o===!0||o===void 0?{}:o;return{...r,forwardedConsoleMethods:r.forwardedConsoleMethods??["error","warn"],solutionFinders:[...T,...r.solutionFinders??[]]}},U=(o,r)=>{const t=d(o,r);if(!m(t)){const e=p();throw new Error(`target "${t}" has no command-line toolchain, so the Lunora Vite plugin cannot build or serve it — it can only generate for it (\`lunora codegen --target ${t}\`). Buildable targets: ${e.join(", ")}`)}return t},I=o=>{const r=o??{},t=r.schemaDir??"lunora";let e;r.cloudflare===!1?e=!1:r.cloudflare===!0||r.cloudflare===void 0?e={}:e=r.cloudflare;const n=r.projectRoot??process.cwd();return{allowUnauthenticatedShardAccess:r.allowUnauthenticatedShardAccess??!1,apiSpec:r.apiSpec??"openapi",cloudflare:e,studio:r.studio??!0,generatedDir:`${t}/_generated`,overlay:N(r.overlay),projectRoot:n,schemaDir:t,shard:r.shard??{},target:U(n,r.target),validateWrangler:r.validateWrangler??!0}},er=o=>{const r=I(o),t=L(),e=[C(r,t),k(r,t),h(r),y(r),v(r),P(),R(r),b(r),A()];r.studio&&e.push(_(r)),r.validateWrangler&&e.push(O(r)),r.overlay!==!1&&e.push(g(r.overlay)),e.push(w(r));const n=r.cloudflare===!1?void 0:{...r.cloudflare};return e.push(E(n,{projectRoot:r.projectRoot})),n!==void 0&&e.push(...x(l(n))),e},or=i(import.meta.url)("../package.json").version;export{lr as CLASS_A_WIRING,sr as GENERATED_CLASS_MODULES,xr as LUNORA_API_UPDATED_EVENT,ur as LUNORA_WORKER_VIRTUAL_ID,hr as STUDIO_PATH,or as VERSION,Ar as WORKER_STARTUP_HINT,Er as augmentWorkerStartupError,kr as buildStudioUrl,cr as buildWorkerEntrySource,mr as checkLunoraProxy,v as codegenPlugin,w as containerLogsPlugin,ar as detectFramework,R as devStatePlugin,h as devVariablesPlugin,k as frameworkComposePlugin,fr as isAutoComposable,Tr as isWorkerEntryEvalError,P as logStreamPlugin,er as lunora,wr as lunoraSolutionFinder,T as lunoraSolutionFinders,gr as planViteRemoteBindings,A as proxyCheckPlugin,br as reconcileWranglerCrons,E as remoteBindingsPlugin,N as resolveOverlayOption,_ as studioPlugin,Sr as withRemoteBindings,x as withWorkerStartupHint,O as wranglerValidatorPlugin};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import{existsSync as h}from"node:fs";import{resolve as v,join as R}from"node:path";import{LunoraError as w}from"@lunora/errors";const m="virtual:lunora/worker",A="\0",d=`${A}${m}`,k=`// @lunora/vite — the composed worker entry is worker-only and unavailable in the client environment.
|
|
2
|
+
export default {};
|
|
3
|
+
`,S=/\/$/,u={"react-router":{handler:'{ fetch: (request) => createRequestHandler(() => import("virtual:react-router/server-build"), import.meta.env.MODE)(request) }',imports:'import { createRequestHandler } from "react-router";'},"solid-start":{handler:"ssrModule.default",imports:'import * as ssrModule from "@solidjs/start/server-handler";'},"tanstack-start":{handler:"ssrModule.default",imports:'import * as ssrModule from "@tanstack/react-start/server-entry";'},"tanstack-start-solid":{handler:"ssrModule.default",imports:'import * as ssrModule from "@tanstack/solid-start/server-entry";'},vinext:{handler:"ssrModule.default",imports:'import * as ssrModule from "vinext/server/fetch-handler";'}},c=r=>{const e=r.framework;return e?.class==="A"&&u[e.framework]!==void 0},E=["agents","containers","workflows"],$=(r,e,a=[],o=!1,n={})=>{const s=u[r];if(s===void 0)throw new w("INTERNAL",`[lunora] no class-A worker wiring for framework "${r}"`);const l=e.replaceAll("\\","/"),p=a.map(t=>`
|
|
4
|
+
export * from "${l}/${t}";
|
|
5
|
+
`).join(""),f=Object.entries(n).filter(([,t])=>t!==void 0).toSorted(([t],[i])=>t.localeCompare(i)).map(([t,i])=>`
|
|
6
|
+
.${t}(${JSON.stringify(i)})`).join("");return`// Generated by @lunora/vite — class-A worker composition (PLAN4 M2).
|
|
7
|
+
// Do not edit: emitted from the detected framework (${r}). Point your
|
|
8
|
+
// wrangler \`main\` here (or re-export it) instead of hand-wiring createWorker.
|
|
9
|
+
${s.imports}
|
|
10
|
+
import { defineApp } from "${l}/app";
|
|
11
|
+
|
|
12
|
+
const app = defineApp()
|
|
13
|
+
.shard((env) => env.SHARD)
|
|
14
|
+
.httpRouter(${s.handler})${f}${o?`
|
|
15
|
+
.extend(() => ({ allowUnauthenticatedShardAccess: true }))`:""}
|
|
16
|
+
.build();
|
|
17
|
+
|
|
18
|
+
export const ShardDO = app.ShardDO;
|
|
19
|
+
${p}
|
|
20
|
+
export default app;
|
|
21
|
+
`},O=(r,e)=>{const a=v(r.projectRoot,r.generatedDir.replace(S,""));return{load(o){if(o===d&&c(e)&&e.framework!==void 0){if(this.environment.name==="client")return k;const n=E.filter(s=>h(R(a,`${s}.ts`)));return $(e.framework.framework,a,n,r.allowUnauthenticatedShardAccess,r.shard)}},name:"lunora:framework-compose",resolveId(o){if(o===m&&c(e))return d}}};export{u as CLASS_A_WIRING,E as GENERATED_CLASS_MODULES,m as LUNORA_WORKER_VIRTUAL_ID,d as RESOLVED_LUNORA_WORKER_ID,$ as buildWorkerEntrySource,O as frameworkComposePlugin,c as isAutoComposable};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/vite",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.202",
|
|
4
4
|
"description": "The Lunora Vite plugin: codegen, type sync, wrangler validation, and an error overlay over @cloudflare/vite-plugin",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@cloudflare/vite-plugin": "1.51.2",
|
|
49
|
-
"@lunora/codegen": "1.0.0-alpha.
|
|
50
|
-
"@lunora/config": "1.0.0-alpha.
|
|
51
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
49
|
+
"@lunora/codegen": "1.0.0-alpha.165",
|
|
50
|
+
"@lunora/config": "1.0.0-alpha.202",
|
|
51
|
+
"@lunora/errors": "1.0.0-alpha.35",
|
|
52
52
|
"@visulima/vite-overlay": "2.0.12"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import{existsSync as w}from"node:fs";import{resolve as A,join as k}from"node:path";import{projectUsesUmbrella as S}from"@lunora/config";import{LunoraError as O}from"@lunora/errors";const u="virtual:lunora/worker",E="\0",m=`${E}${u}`,L=`// @lunora/vite — the composed worker entry is worker-only and unavailable in the client environment.
|
|
2
|
-
export default {};
|
|
3
|
-
`,_=/\/$/,p={"react-router":{handler:'{ fetch: (request) => createRequestHandler(() => import("virtual:react-router/server-build"), import.meta.env.MODE)(request) }',imports:'import { createRequestHandler } from "react-router";'},"solid-start":{handler:"ssrModule.default",imports:'import * as ssrModule from "@solidjs/start/server-handler";'},"tanstack-start":{handler:"ssrModule.default",imports:'import * as ssrModule from "@tanstack/react-start/server-entry";'},"tanstack-start-solid":{handler:"ssrModule.default",imports:'import * as ssrModule from "@tanstack/solid-start/server-entry";'},vinext:{handler:"ssrModule.default",imports:'import * as ssrModule from "vinext/server/fetch-handler";'}},d=r=>{const e=r.framework;return e?.class==="A"&&p[e.framework]!==void 0},$=["agents","containers","workflows"],N=(r,e,s=[],a=!1,t=!1,i={})=>{const o=p[r];if(o===void 0)throw new O("INTERNAL",`[lunora] no class-A worker wiring for framework "${r}"`);const n=e.replaceAll("\\","/"),f=a?"lunorash/runtime":"@lunora/runtime",h=s.map(l=>`
|
|
4
|
-
export * from "${n}/${l}";
|
|
5
|
-
`).join(""),c=JSON.stringify(Object.fromEntries(Object.entries(i).toSorted(([l],[v])=>l.localeCompare(v)))),R=c==="{}"?"":c;return`// Generated by @lunora/vite — class-A worker composition (PLAN4 M2).
|
|
6
|
-
// Do not edit: emitted from the detected framework (${r}). Point your
|
|
7
|
-
// wrangler \`main\` here (or re-export it) instead of hand-wiring createWorker.
|
|
8
|
-
import { composeWorker } from "${f}";
|
|
9
|
-
${o.imports}
|
|
10
|
-
import { LUNORA_FUNCTIONS } from "${n}/functions";
|
|
11
|
-
import { openApiSpec } from "${n}/openapi";
|
|
12
|
-
import { createShardDO } from "${n}/shard";
|
|
13
|
-
|
|
14
|
-
export const ShardDO = createShardDO(${R});
|
|
15
|
-
${h}
|
|
16
|
-
|
|
17
|
-
let worker;
|
|
18
|
-
|
|
19
|
-
export default {
|
|
20
|
-
async fetch(request, env, context) {
|
|
21
|
-
worker ??= composeWorker({${t?`
|
|
22
|
-
allowUnauthenticatedShardAccess: true,`:""}
|
|
23
|
-
functions: LUNORA_FUNCTIONS,
|
|
24
|
-
httpRouter: ${o.handler},
|
|
25
|
-
openApiSpec,
|
|
26
|
-
routes: {},
|
|
27
|
-
shardDO: env.SHARD,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
return worker.fetch(request, env, context);
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
`},g=(r,e)=>{const s=A(r.projectRoot,r.generatedDir.replace(_,"")),a=S(r.projectRoot);return{load(t){if(t===m&&d(e)&&e.framework!==void 0){if(this.environment.name==="client")return L;const i=$.filter(o=>w(k(s,`${o}.ts`)));return N(e.framework.framework,s,i,a,r.allowUnauthenticatedShardAccess,r.shard)}},name:"lunora:framework-compose",resolveId(t){if(t===u&&d(e))return m}}};export{p as CLASS_A_WIRING,$ as GENERATED_CLASS_MODULES,u as LUNORA_WORKER_VIRTUAL_ID,m as RESOLVED_LUNORA_WORKER_ID,N as buildWorkerEntrySource,g as frameworkComposePlugin,d as isAutoComposable};
|