@lunora/vite 1.0.0-alpha.428 → 1.0.0-alpha.429
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 +20 -24
- package/dist/index.d.ts +20 -24
- package/dist/index.mjs +4 -4
- package/dist/packem_shared/buildStudioUrl-Num2hyVU.mjs +1 -0
- package/dist/packem_shared/codegenPlugin-CzkFjxTv.mjs +3 -0
- package/dist/packem_shared/devVariablesPlugin-BZc49ZPO.mjs +1 -0
- package/dist/packem_shared/planViteRemoteBindings-CxfLf0vb.mjs +1 -0
- package/package.json +3 -3
- package/dist/packem_shared/buildStudioUrl-B9K0wAjC.mjs +0 -1
- package/dist/packem_shared/codegenPlugin-2ycHgwJC.mjs +0 -3
- package/dist/packem_shared/devVariablesPlugin-Bm5X49VR.mjs +0 -1
- package/dist/packem_shared/planViteRemoteBindings-DYUUW67d.mjs +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -3,8 +3,8 @@ import errorOverlayPlugin from '@visulima/vite-overlay';
|
|
|
3
3
|
import { Plugin } from 'vite';
|
|
4
4
|
import { DiscoveryCache, FrameworkDetection, DetectedFramework, GeneratedClassModule, readProjectRemotePreference } from '@lunora/config';
|
|
5
5
|
export { type DetectedFramework, type FrameworkClass, type FrameworkDetection, GENERATED_CLASS_MODULES, type GeneratedClassModule, detectFramework } from '@lunora/config';
|
|
6
|
-
import { materializeDevWranglerConfig,
|
|
7
|
-
export { type ReconcileCronsResult as ReconcileResult, reconcileWranglerCrons } from '@lunora/config/cloudflare';
|
|
6
|
+
import { materializeDevWranglerConfig, RemotePlan } from '@lunora/config/cloudflare';
|
|
7
|
+
export { type ReconcileCronsResult as ReconcileResult, type RemotePlan, reconcileWranglerCrons } from '@lunora/config/cloudflare';
|
|
8
8
|
import { AddressInfo } from 'node:net';
|
|
9
9
|
export { STUDIO_PATH } from '@lunora/config/studio-host';
|
|
10
10
|
/** Options forwarded to `@cloudflare/vite-plugin`'s cloudflare plugin. */
|
|
@@ -191,11 +191,24 @@ declare const devStatePlugin: (options: ResolvedLunoraPluginOptions) => Plugin;
|
|
|
191
191
|
*
|
|
192
192
|
* Runs in `configResolved` (awaited by Vite) so it completes before the
|
|
193
193
|
* Cloudflare plugin reads the file. Non-interactive runs decline silently.
|
|
194
|
+
*
|
|
195
|
+
* Last, it checks the env against the project's `defineEnv` contract and warns
|
|
196
|
+
* about missing or invalid keys, which `defineEnv` would otherwise report only
|
|
197
|
+
* as a 500 from the first request that reads one. A `.dev.vars`, `.env` or
|
|
198
|
+
* wrangler.jsonc edit restarts the dev server (`@cloudflare/vite-plugin` and the
|
|
199
|
+
* codegen plugin do that), which re-runs this hook; an `env.ts` edit does not,
|
|
200
|
+
* so the plugin watches that file itself. `configPath` is the wrangler config
|
|
201
|
+
* the Cloudflare plugin runs, when it is not the project's own; `withheld` names
|
|
202
|
+
* the bindings the remote-bindings plugin left out of this session, which the
|
|
203
|
+
* check must not treat as present.
|
|
194
204
|
* Skipped under `vite preview`, which resolves with `command: "serve"` and so
|
|
195
205
|
* runs `apply: "serve"` plugins too — previewing a built app must not prompt to
|
|
196
206
|
* scaffold, or write, a dev secrets file.
|
|
197
207
|
*/
|
|
198
|
-
declare const devVariablesPlugin: (options: ResolvedLunoraPluginOptions
|
|
208
|
+
declare const devVariablesPlugin: (options: ResolvedLunoraPluginOptions, { configPath, withheld }?: {
|
|
209
|
+
configPath?: string;
|
|
210
|
+
withheld?: () => ReadonlyArray<string>;
|
|
211
|
+
}) => Plugin;
|
|
199
212
|
/**
|
|
200
213
|
* Mutable, plugin-shared context. The `lunora()` factory creates one instance
|
|
201
214
|
* and threads it through every Lunora sub-plugin, so detection runs once and
|
|
@@ -337,23 +350,6 @@ declare const checkLunoraProxy: (proxy: Record<string, unknown> | undefined, lab
|
|
|
337
350
|
* origin-rewriting `changeOrigin`). See the module docs.
|
|
338
351
|
*/
|
|
339
352
|
declare const proxyCheckPlugin: () => Plugin;
|
|
340
|
-
/** The decision a {@link planViteRemoteBindings} call returns. */
|
|
341
|
-
interface ViteRemotePlan {
|
|
342
|
-
/** Idempotent disposer for the temp config; always present + safe to call. */
|
|
343
|
-
cleanup: () => void;
|
|
344
|
-
/**
|
|
345
|
-
* Absolute path to the materialized temp wrangler config to hand the
|
|
346
|
-
* cloudflare plugin's `configPath`, or `undefined` when remote mode is off
|
|
347
|
-
* or nothing was materialized (no eligible binding, no wrangler file, …).
|
|
348
|
-
*/
|
|
349
|
-
configPath?: string;
|
|
350
|
-
/** Whether remote mode was requested for this dev session. */
|
|
351
|
-
enabled: boolean;
|
|
352
|
-
/** Why remote mode didn't take effect despite being requested, for logging. */
|
|
353
|
-
reason?: string;
|
|
354
|
-
/** Remote-only bindings (`ai`, `artifacts`) left out for lack of Cloudflare credentials, for the dev warning. */
|
|
355
|
-
withheld: WithheldBinding[];
|
|
356
|
-
}
|
|
357
353
|
/** Inputs to the Vite remote-binding decision — injectable so tests don't touch the env/fs. */
|
|
358
354
|
interface PlanViteRemoteOptions {
|
|
359
355
|
/** Injection seam — defaults to the real materializer. */
|
|
@@ -376,7 +372,7 @@ interface PlanViteRemoteOptions {
|
|
|
376
372
|
* Call this from a `config` hook, never at plugin-factory time — see
|
|
377
373
|
* {@link remoteBindingsPlugin} for the two defects that timing caused.
|
|
378
374
|
*/
|
|
379
|
-
declare const planViteRemoteBindings: (options: PlanViteRemoteOptions) =>
|
|
375
|
+
declare const planViteRemoteBindings: (options: PlanViteRemoteOptions) => RemotePlan;
|
|
380
376
|
/**
|
|
381
377
|
* Wrap the cloudflare-plugin options so the dev worker loads the materialized
|
|
382
378
|
* remote temp config (via `configPath`) when — and only when — remote mode is
|
|
@@ -388,7 +384,7 @@ declare const planViteRemoteBindings: (options: PlanViteRemoteOptions) => ViteRe
|
|
|
388
384
|
* `command` is unknown at plugin-factory time. An eager serve check there would
|
|
389
385
|
* always read `command` as undefined and strip `configPath`.
|
|
390
386
|
*/
|
|
391
|
-
declare const withRemoteBindings: (options: CloudflarePluginOptions, plan:
|
|
387
|
+
declare const withRemoteBindings: (options: CloudflarePluginOptions, plan: RemotePlan) => CloudflarePluginOptions;
|
|
392
388
|
/**
|
|
393
389
|
* A `enforce: "pre"` plugin that materializes the remote temp wrangler config
|
|
394
390
|
* and injects it into the cloudflare plugin's `configPath` — but only on a
|
|
@@ -433,7 +429,7 @@ declare const withRemoteBindings: (options: CloudflarePluginOptions, plan: ViteR
|
|
|
433
429
|
* inject into: the materialized path is printed with what to do with it, rather
|
|
434
430
|
* than leaving `LUNORA_REMOTE` looking like it took effect.
|
|
435
431
|
*/
|
|
436
|
-
declare const remoteBindingsPlugin: (options: CloudflarePluginOptions | undefined, planOptions: PlanViteRemoteOptions) => Plugin;
|
|
432
|
+
declare const remoteBindingsPlugin: (options: CloudflarePluginOptions | undefined, planOptions: PlanViteRemoteOptions, onPlan?: (plan: RemotePlan) => void) => Plugin;
|
|
437
433
|
/**
|
|
438
434
|
* A `@visulima/vite-overlay` solution finder. Derived from the overlay's own
|
|
439
435
|
* options type so the shape can't drift from the installed package. The overlay
|
|
@@ -559,4 +555,4 @@ declare const wranglerValidatorPlugin: (options: ResolvedLunoraPluginOptions, di
|
|
|
559
555
|
declare const resolveOverlayOption: (overlay: LunoraPluginOptions["overlay"]) => false | OverlayPluginOptions;
|
|
560
556
|
declare const lunora: (options?: LunoraPluginOptions) => LunoraPlugins;
|
|
561
557
|
declare const VERSION: string;
|
|
562
|
-
export { CLASS_A_WIRING, type ClassAWiring, type CloudflarePluginOptions, LUNORA_API_UPDATED_EVENT, LUNORA_WORKER_VIRTUAL_ID, type LunoraPluginOptions, type LunoraPlugins, type LunoraShardConfig, type OverlayPluginOptions, type PlanViteRemoteOptions, type ResolvedLunoraPluginOptions, type Solution, type SolutionFinder, VERSION,
|
|
558
|
+
export { CLASS_A_WIRING, type ClassAWiring, type CloudflarePluginOptions, LUNORA_API_UPDATED_EVENT, LUNORA_WORKER_VIRTUAL_ID, type LunoraPluginOptions, type LunoraPlugins, type LunoraShardConfig, type OverlayPluginOptions, type PlanViteRemoteOptions, type ResolvedLunoraPluginOptions, type Solution, type SolutionFinder, VERSION, WORKER_STARTUP_HINT, type WorkerEntryComposition, augmentWorkerStartupError, buildStudioUrl, buildWorkerEntrySource, checkLunoraProxy, codegenPlugin, containerLogsPlugin, devStatePlugin, devVariablesPlugin, frameworkComposePlugin, isAutoComposable, isWorkerEntryEvalError, logStreamPlugin, lunora, lunoraSolutionFinder, lunoraSolutionFinders, planViteRemoteBindings, proxyCheckPlugin, remoteBindingsPlugin, resolveOverlayOption, studioPlugin, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import errorOverlayPlugin from '@visulima/vite-overlay';
|
|
|
3
3
|
import { Plugin } from 'vite';
|
|
4
4
|
import { DiscoveryCache, FrameworkDetection, DetectedFramework, GeneratedClassModule, readProjectRemotePreference } from '@lunora/config';
|
|
5
5
|
export { type DetectedFramework, type FrameworkClass, type FrameworkDetection, GENERATED_CLASS_MODULES, type GeneratedClassModule, detectFramework } from '@lunora/config';
|
|
6
|
-
import { materializeDevWranglerConfig,
|
|
7
|
-
export { type ReconcileCronsResult as ReconcileResult, reconcileWranglerCrons } from '@lunora/config/cloudflare';
|
|
6
|
+
import { materializeDevWranglerConfig, RemotePlan } from '@lunora/config/cloudflare';
|
|
7
|
+
export { type ReconcileCronsResult as ReconcileResult, type RemotePlan, reconcileWranglerCrons } from '@lunora/config/cloudflare';
|
|
8
8
|
import { AddressInfo } from 'node:net';
|
|
9
9
|
export { STUDIO_PATH } from '@lunora/config/studio-host';
|
|
10
10
|
/** Options forwarded to `@cloudflare/vite-plugin`'s cloudflare plugin. */
|
|
@@ -191,11 +191,24 @@ declare const devStatePlugin: (options: ResolvedLunoraPluginOptions) => Plugin;
|
|
|
191
191
|
*
|
|
192
192
|
* Runs in `configResolved` (awaited by Vite) so it completes before the
|
|
193
193
|
* Cloudflare plugin reads the file. Non-interactive runs decline silently.
|
|
194
|
+
*
|
|
195
|
+
* Last, it checks the env against the project's `defineEnv` contract and warns
|
|
196
|
+
* about missing or invalid keys, which `defineEnv` would otherwise report only
|
|
197
|
+
* as a 500 from the first request that reads one. A `.dev.vars`, `.env` or
|
|
198
|
+
* wrangler.jsonc edit restarts the dev server (`@cloudflare/vite-plugin` and the
|
|
199
|
+
* codegen plugin do that), which re-runs this hook; an `env.ts` edit does not,
|
|
200
|
+
* so the plugin watches that file itself. `configPath` is the wrangler config
|
|
201
|
+
* the Cloudflare plugin runs, when it is not the project's own; `withheld` names
|
|
202
|
+
* the bindings the remote-bindings plugin left out of this session, which the
|
|
203
|
+
* check must not treat as present.
|
|
194
204
|
* Skipped under `vite preview`, which resolves with `command: "serve"` and so
|
|
195
205
|
* runs `apply: "serve"` plugins too — previewing a built app must not prompt to
|
|
196
206
|
* scaffold, or write, a dev secrets file.
|
|
197
207
|
*/
|
|
198
|
-
declare const devVariablesPlugin: (options: ResolvedLunoraPluginOptions
|
|
208
|
+
declare const devVariablesPlugin: (options: ResolvedLunoraPluginOptions, { configPath, withheld }?: {
|
|
209
|
+
configPath?: string;
|
|
210
|
+
withheld?: () => ReadonlyArray<string>;
|
|
211
|
+
}) => Plugin;
|
|
199
212
|
/**
|
|
200
213
|
* Mutable, plugin-shared context. The `lunora()` factory creates one instance
|
|
201
214
|
* and threads it through every Lunora sub-plugin, so detection runs once and
|
|
@@ -337,23 +350,6 @@ declare const checkLunoraProxy: (proxy: Record<string, unknown> | undefined, lab
|
|
|
337
350
|
* origin-rewriting `changeOrigin`). See the module docs.
|
|
338
351
|
*/
|
|
339
352
|
declare const proxyCheckPlugin: () => Plugin;
|
|
340
|
-
/** The decision a {@link planViteRemoteBindings} call returns. */
|
|
341
|
-
interface ViteRemotePlan {
|
|
342
|
-
/** Idempotent disposer for the temp config; always present + safe to call. */
|
|
343
|
-
cleanup: () => void;
|
|
344
|
-
/**
|
|
345
|
-
* Absolute path to the materialized temp wrangler config to hand the
|
|
346
|
-
* cloudflare plugin's `configPath`, or `undefined` when remote mode is off
|
|
347
|
-
* or nothing was materialized (no eligible binding, no wrangler file, …).
|
|
348
|
-
*/
|
|
349
|
-
configPath?: string;
|
|
350
|
-
/** Whether remote mode was requested for this dev session. */
|
|
351
|
-
enabled: boolean;
|
|
352
|
-
/** Why remote mode didn't take effect despite being requested, for logging. */
|
|
353
|
-
reason?: string;
|
|
354
|
-
/** Remote-only bindings (`ai`, `artifacts`) left out for lack of Cloudflare credentials, for the dev warning. */
|
|
355
|
-
withheld: WithheldBinding[];
|
|
356
|
-
}
|
|
357
353
|
/** Inputs to the Vite remote-binding decision — injectable so tests don't touch the env/fs. */
|
|
358
354
|
interface PlanViteRemoteOptions {
|
|
359
355
|
/** Injection seam — defaults to the real materializer. */
|
|
@@ -376,7 +372,7 @@ interface PlanViteRemoteOptions {
|
|
|
376
372
|
* Call this from a `config` hook, never at plugin-factory time — see
|
|
377
373
|
* {@link remoteBindingsPlugin} for the two defects that timing caused.
|
|
378
374
|
*/
|
|
379
|
-
declare const planViteRemoteBindings: (options: PlanViteRemoteOptions) =>
|
|
375
|
+
declare const planViteRemoteBindings: (options: PlanViteRemoteOptions) => RemotePlan;
|
|
380
376
|
/**
|
|
381
377
|
* Wrap the cloudflare-plugin options so the dev worker loads the materialized
|
|
382
378
|
* remote temp config (via `configPath`) when — and only when — remote mode is
|
|
@@ -388,7 +384,7 @@ declare const planViteRemoteBindings: (options: PlanViteRemoteOptions) => ViteRe
|
|
|
388
384
|
* `command` is unknown at plugin-factory time. An eager serve check there would
|
|
389
385
|
* always read `command` as undefined and strip `configPath`.
|
|
390
386
|
*/
|
|
391
|
-
declare const withRemoteBindings: (options: CloudflarePluginOptions, plan:
|
|
387
|
+
declare const withRemoteBindings: (options: CloudflarePluginOptions, plan: RemotePlan) => CloudflarePluginOptions;
|
|
392
388
|
/**
|
|
393
389
|
* A `enforce: "pre"` plugin that materializes the remote temp wrangler config
|
|
394
390
|
* and injects it into the cloudflare plugin's `configPath` — but only on a
|
|
@@ -433,7 +429,7 @@ declare const withRemoteBindings: (options: CloudflarePluginOptions, plan: ViteR
|
|
|
433
429
|
* inject into: the materialized path is printed with what to do with it, rather
|
|
434
430
|
* than leaving `LUNORA_REMOTE` looking like it took effect.
|
|
435
431
|
*/
|
|
436
|
-
declare const remoteBindingsPlugin: (options: CloudflarePluginOptions | undefined, planOptions: PlanViteRemoteOptions) => Plugin;
|
|
432
|
+
declare const remoteBindingsPlugin: (options: CloudflarePluginOptions | undefined, planOptions: PlanViteRemoteOptions, onPlan?: (plan: RemotePlan) => void) => Plugin;
|
|
437
433
|
/**
|
|
438
434
|
* A `@visulima/vite-overlay` solution finder. Derived from the overlay's own
|
|
439
435
|
* options type so the shape can't drift from the installed package. The overlay
|
|
@@ -559,4 +555,4 @@ declare const wranglerValidatorPlugin: (options: ResolvedLunoraPluginOptions, di
|
|
|
559
555
|
declare const resolveOverlayOption: (overlay: LunoraPluginOptions["overlay"]) => false | OverlayPluginOptions;
|
|
560
556
|
declare const lunora: (options?: LunoraPluginOptions) => LunoraPlugins;
|
|
561
557
|
declare const VERSION: string;
|
|
562
|
-
export { CLASS_A_WIRING, type ClassAWiring, type CloudflarePluginOptions, LUNORA_API_UPDATED_EVENT, LUNORA_WORKER_VIRTUAL_ID, type LunoraPluginOptions, type LunoraPlugins, type LunoraShardConfig, type OverlayPluginOptions, type PlanViteRemoteOptions, type ResolvedLunoraPluginOptions, type Solution, type SolutionFinder, VERSION,
|
|
558
|
+
export { CLASS_A_WIRING, type ClassAWiring, type CloudflarePluginOptions, LUNORA_API_UPDATED_EVENT, LUNORA_WORKER_VIRTUAL_ID, type LunoraPluginOptions, type LunoraPlugins, type LunoraShardConfig, type OverlayPluginOptions, type PlanViteRemoteOptions, type ResolvedLunoraPluginOptions, type Solution, type SolutionFinder, VERSION, WORKER_STARTUP_HINT, type WorkerEntryComposition, augmentWorkerStartupError, buildStudioUrl, buildWorkerEntrySource, checkLunoraProxy, codegenPlugin, containerLogsPlugin, devStatePlugin, devVariablesPlugin, frameworkComposePlugin, isAutoComposable, isWorkerEntryEvalError, logStreamPlugin, lunora, lunoraSolutionFinder, lunoraSolutionFinders, planViteRemoteBindings, proxyCheckPlugin, remoteBindingsPlugin, resolveOverlayOption, studioPlugin, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as I}from"node:module";import{resolve as
|
|
2
|
-
${
|
|
3
|
-
`)}},name:"lunora:agent-rules-hint"})
|
|
4
|
-
`,"utf8")}}},
|
|
1
|
+
import{createRequire as I}from"node:module";import{resolve as h,sep as L,dirname as M,isAbsolute as U,relative as j}from"node:path";import{cloudflare as H}from"@cloudflare/vite-plugin";import{lunoraLine as A,BUNDLE_META_PATH_ENV as V,canonicalPath as k,DEFAULT_BUNDLE_META_PATH as z,resolveDeployDriver as G,startCelldDevSession as K,formatLunoraEvent as q,detectFramework as J,resolveSchemaDirectory as Q,createDiscoveryCache as Y,targetRunsOwnDevServer as X,resolveLazyFunctions as Z,resolveTargetOrThrow as ee,isRunnableTarget as re,runnableTargetIds as te,assertBuildTargetMatches as oe}from"@lunora/config";import{GENERATED_CLASS_MODULES as Nr,detectFramework as Fr}from"@lunora/config";import ne from"@visulima/vite-overlay";import{detectAgentRules as ie,claimAgentRulesHint as se,lunoraLine as g,AGENT_RULES_HINT as ae}from"@lunora/config/cli";import{reconcileBindingsSafely as le,findWranglerFile as ce,readWranglerJsonc as ue,warnCloudflareCliConfigOnce as de,hasCloudflareCredentials as fe,withheldBindings as pe,describeWithheld as me,startLocalHyperdrive as ge}from"@lunora/config/cloudflare";import{reconcileWranglerCrons as Ir}from"@lunora/config/cloudflare";import{o as ve}from"./packem_shared/build-session-D75JzvIT.mjs";import{mkdirSync as he,writeFileSync as we,statSync as ye,rmSync as Se}from"node:fs";import{r as W,a as $}from"./packem_shared/server-close-DWiO4Vxb.mjs";import Pe from"./packem_shared/codegenPlugin-CzkFjxTv.mjs";import be from"./packem_shared/containerLogsPlugin-CWF3LHN3.mjs";import Ae from"./packem_shared/devStatePlugin-CF4GDvBn.mjs";import Re from"./packem_shared/devVariablesPlugin-BZc49ZPO.mjs";import{frameworkComposePlugin as ke}from"./packem_shared/CLASS_A_WIRING-CDSSmDqw.mjs";import{CLASS_A_WIRING as Ur,LUNORA_WORKER_VIRTUAL_ID as jr,buildWorkerEntrySource as Hr,isAutoComposable as Vr}from"./packem_shared/CLASS_A_WIRING-CDSSmDqw.mjs";import Ee from"./packem_shared/logStreamPlugin-EMXiy6pI.mjs";import{proxyCheckPlugin as De}from"./packem_shared/checkLunoraProxy-BNPgNWtV.mjs";import{checkLunoraProxy as Gr}from"./packem_shared/checkLunoraProxy-BNPgNWtV.mjs";import{remoteBindingsPlugin as _e}from"./packem_shared/planViteRemoteBindings-CxfLf0vb.mjs";import{planViteRemoteBindings as qr,withRemoteBindings as Jr}from"./packem_shared/planViteRemoteBindings-CxfLf0vb.mjs";import{readDevServiceBindings as Te}from"@lunora/codegen";import{lunoraSolutionFinders as Ce}from"./packem_shared/lunoraSolutionFinder--J0x2mAM.mjs";import{lunoraSolutionFinder as Yr}from"./packem_shared/lunoraSolutionFinder--J0x2mAM.mjs";import{studioPlugin as xe}from"./packem_shared/buildStudioUrl-Num2hyVU.mjs";import{buildStudioUrl as Zr}from"./packem_shared/buildStudioUrl-Num2hyVU.mjs";import{withWorkerStartupHint as Oe}from"./packem_shared/WORKER_STARTUP_HINT-COlRTY32.mjs";import{WORKER_STARTUP_HINT as rt,augmentWorkerStartupError as tt,isWorkerEntryEvalError as ot}from"./packem_shared/WORKER_STARTUP_HINT-COlRTY32.mjs";import{wranglerValidatorPlugin as Le}from"./packem_shared/wranglerValidatorPlugin-CPPKubFC.mjs";import{default as it}from"./packem_shared/LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs";import{STUDIO_PATH as at}from"@lunora/config/studio-host";const We=r=>({apply:"serve",configureServer(e){return()=>{ie(r.projectRoot).installed||!se()||e.config.logger.warn(`
|
|
2
|
+
${g(ae)}
|
|
3
|
+
`)}},name:"lunora:agent-rules-hint"}),$e="vite-plugin-cloudflare",N=["assetFileNames","chunkFileNames","entryFileNames"],F=r=>{const{output:e}=r.rolldownOptions??r.rollupOptions;return e===void 0?[]:[e].flat()},Ne=r=>F(r).every(e=>N.every(t=>e[t]===void 0||typeof e[t]=="string"&&e[t].includes("[hash]"))),Fe=r=>[...F(r).flatMap(e=>N.map(t=>e[t]).filter(t=>typeof t=="string")),`${r.assetsDir}/[name]-[hash][extname]`,`${r.assetsDir}/[name]-[hash].js`],Be=(r,e)=>{let t=!1;return{apply:"build",applyToEnvironment:o=>o.name==="client",configResolved(o){t=o.plugins.some(s=>s.name===$e)},name:"lunora:asset-headers",async writeBundle(){if(!t)return;const{config:o}=this.environment,{emitProjectAssetHeaders:s}=await import("@lunora/config/cloudflare");s({hashedDirectory:Ne(o.build)?o.build.assetsDir:void 0,hashedNamePatterns:Fe(o.build),outputDirectory:h(o.root,o.build.outDir),projectRoot:r.projectRoot,publicDirectory:o.publicDir===""?void 0:o.publicDir,requireAssetsDirectory:!1,schemaDir:r.schemaDir,target:r.target,wranglerPath:e},{info:n=>{o.logger.info(A(n))},warn:n=>{o.logger.warn(A(n))}})}}},Ie=(r,e)=>({async config(t,o){if(e?.clear(),o.isPreview===!0)return;const s=async()=>le({...r,cache:e},{info:n=>{console.info(n)},warn:n=>{console.warn(n)}});await(o.command==="build"?ve(r,"provision",s):s())},enforce:"pre",name:"lunora:bindings-provision"}),Me=(r,e=L)=>r.split(e).join("/"),R=(r,e)=>U(e)?Me(j(r,e)):e,y=(r,e,t)=>e.map(o=>({kind:t,path:R(r,o)})),Ue=/[?#]/,E=r=>{try{return ye(r).size}catch{return}},je=(r,e)=>E(r)??E(r.split(Ue)[0]??r)??Buffer.byteLength(e??""),He=r=>{let e;return{apply:"build",applyToEnvironment:t=>t.config.consumer==="server",name:"lunora:bundle-meta",sharedDuringBuild:!0,generateBundle(t,o){const s={},n={};for(const[u,d]of Object.entries(o)){if(d.type!=="chunk")continue;const f={bytes:Buffer.byteLength(d.code),imports:[...y(r,d.imports,"import-statement"),...y(r,d.dynamicImports,"dynamic-import")],inputs:{}};d.facadeModuleId&&(f.entryPoint=R(r,d.facadeModuleId));for(const[m,S]of Object.entries(d.modules)){const v=R(r,m);if(f.inputs[v]={bytesInOutput:Buffer.byteLength(S.code??"")},!s[v]){const p=this.getModuleInfo(m);s[v]={bytes:je(m,p?.code),imports:[...y(r,p?.importedIds??[],"import-statement"),...y(r,p?.dynamicallyImportedIds??[],"dynamic-import")]}}}n[u]=f}const i=process.env[V],a=i===void 0||i===""?void 0:h(r,i),l=`${k(h(r,".lunora"))}${L}`,c=a!==void 0&&k(a).startsWith(l)?a:h(r,z);if(e!==void 0&&e!==this.environment.name){Se(c,{force:!0}),this.warn(`bundle-meta: environment "${this.environment.name}" built a server bundle after "${e}" wrote one; no bundle-meta.json is written, because the app's own graph cannot be told apart from a service's`);return}e=this.environment.name,he(M(c),{recursive:!0}),we(c,`${JSON.stringify({inputs:s,outputs:n},void 0,2)}
|
|
4
|
+
`,"utf8")}}},D="/_lunora",Ve=8787,w=new Map,B=r=>r.command==="serve"&&r.isPreview!==!0,ze=(r,e)=>{let t;return()=>{if(t===void 0)try{G(e).projectConfig?.(r,"dev"),t={runs:!0}}catch(o){t={reason:o instanceof Error?o.message:String(o),runs:!1}}return t}},Ge=r=>{const e=ce(r),t=e===void 0?void 0:ue(e).parsed?.dev?.port;return typeof t=="number"?t:Ve},Ke=(r,e)=>r.map(t=>{const o=t.apply;return{...t,apply:(s,n)=>B(n)&&e()?!1:typeof o=="function"?o(s,n):o===void 0||o===n.command}}),qe=(r,e,{stream:t,tag:o})=>{const s=q(e);s!==void 0?r[s.level](`[lunora] ${s.text}`):t==="stderr"?r.warn(`[${o}] ${e}`):r.info(`[${o}] ${e}`)},Je=(r,e)=>{const t=Ge(r),o=new Map;return{apply:(s,n)=>B(n)&&e(),buildEnd(){$(o,this.environment)},config:s=>{if(s.server?.proxy?.[D]===void 0)return{server:{proxy:{[D]:{changeOrigin:!0,target:`http://127.0.0.1:${String(t)}`,ws:!0}}}}},async configureServer(s){const{logger:n}=s.config;await w.get(r)?.stop(),w.delete(r),n.info(`[lunora] starting the worker on celld at http://127.0.0.1:${String(t)} …`);const i=await K({log:(l,c)=>{qe(n,l,c)},port:t,projectRoot:r});w.set(r,i);const a=l=>{n.error(`[lunora] the worker on celld exited (code ${String(l)}) — restart vite dev to bring it back`)};i.exited.then(a).catch(()=>{}),W(s,o,()=>{w.get(r)===i&&w.delete(r),i.stop().catch(l=>{n.error(`[lunora] stopping celld failed: ${l instanceof Error?l.message:String(l)}`)})})},name:"lunora:celld-dev"}},Qe=r=>({configResolved(e){de(r.projectRoot,t=>{e.logger.warn(A(t))})},name:"lunora:cf-config-warning"}),Ye=()=>({}),Xe={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)"},Ze=r=>{const e=Xe[r.framework];return r.framework==="none"?g("no meta-framework detected — running standalone."):r.class==="B"?g(`detected ${e} — composition is handled by the framework adapter.`):g(`detected ${e} — composing the Lunora worker into one Cloudflare Worker.`)},er=(r,e)=>{let t=!1;const o=()=>{e.framework??=J(r.projectRoot)};return{config(){o()},configResolved(){o()},configureServer(){o(),!t&&e.framework!==void 0&&(t=!0,console.info(Ze(e.framework)))},name:"lunora:framework-detect"}},_=r=>Array.isArray(r)?r:[],P=new WeakSet,rr=(r,e={})=>{let t=!1;const o=r.experimental?.newConfig,s=o!==void 0&&o!==!1,n=e.hasCredentials??(()=>fe({projectRoot:e.projectRoot})),i=(a,l)=>{const c=(u,...d)=>{const f=typeof a=="function"?a(u,...d):a,m=f===void 0?void 0:{...f},S=t?[..._(u.artifacts),..._(m?.artifacts)]:[],v=t?pe({ai:u.ai??m?.ai,artifacts:S},n):[];for(const p of v)Reflect.deleteProperty(u,p.kind),Reflect.deleteProperty(m??{},p.kind),console.warn(g(me(p)));return l?.(v.map(p=>p.binding)),m};return P.add(c),c};return{config(a,l){if(t=l.command==="serve"&&l.isPreview!==!0,s)return;const c=r;P.has(c.config)||(c.config=i(c.config,e.onWithheld)),Array.isArray(c.auxiliaryWorkers)&&(c.auxiliaryWorkers=c.auxiliaryWorkers.map(u=>P.has(u.config)?u:{...u,config:i(u.config)}))},enforce:"pre",name:"lunora:local-ai-binding"}},tr=5e3,or=3e4,T=new Map,C=r=>{const e=T.get(r);if(e!==void 0)return e;const t={databases:[],pending:Promise.resolve(),servers:0,stopping:Promise.resolve()};return T.set(r,t),t},nr=async r=>{const e=r.databases.splice(0);await Promise.allSettled(e.map(async t=>t.stop()))},x=(r,e)=>{const t=setTimeout(()=>{r.pending.then(async()=>{r.servers===0&&(r.stopping=nr(r),await r.stopping)}).catch(()=>{})},e);return t.unref(),t},O=({projectRoot:r,start:e=ge,wranglerConfigPath:t})=>{const o=new Map,s=n=>{const i=C(r);let a=!1;i.servers+=1,clearTimeout(i.stopTimer),n(()=>{a||(a=!0,i.servers-=1,i.servers===0&&(i.stopTimer=x(i,tr)))})};return{async config(n,i){if(i.command!=="serve")return;const a=C(r);clearTimeout(a.stopTimer);const l=a.pending,c=(async()=>{await l,await a.stopping;const u=await e({onWarning:d=>{console.warn(g(d))},projectRoot:r,wranglerConfigPath:t});u!==void 0&&a.databases.push(u),u!==void 0&&u.bindings.length>0&&console.info(g(`Hyperdrive ${u.bindings.join(", ")}: embedded Postgres (PGlite), data in .wrangler/state/lunora-pglite.`))})();a.pending=c.catch(()=>{});try{await c}finally{a.servers===0&&(clearTimeout(a.stopTimer),a.stopTimer=x(a,or))}},buildEnd(){$(o,this.environment)},configureServer(n){s(i=>{W(n,o,i)})},configurePreviewServer(n){s(i=>{n.httpServer.once("close",i)})},enforce:"pre",name:"lunora:local-hyperdrive"}},ir=(r,e)=>({config(t,o){if(o.command!=="serve")return;const{services:s}=Te(e,Q(e)),n=Array.isArray(r.auxiliaryWorkers)?r.auxiliaryWorkers:[],i=new Set(n.map(l=>l.configPath===void 0?"":h(e,l.configPath))),a=[...new Set(s.map(l=>l.wranglerPath))].filter(l=>!i.has(l)).map(l=>({configPath:l}));a.length>0&&(r.auxiliaryWorkers=[...n,...a])},enforce:"pre",name:"lunora:service-workers"}),sr=r=>{if(r===!1)return!1;const e=r===!0||r===void 0?{}:r;return{...e,forwardedConsoleMethods:e.forwardedConsoleMethods??["error","warn"],solutionFinders:[...Ce,...e.solutionFinders??[]]}},ar=(r,e)=>{const t=ee(r,e);if(!re(t)){const o=te();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: ${o.join(", ")}`)}return oe(t,r),t},lr=r=>{const e=r??{};if(e.lazyFunctions!==void 0)throw new Error("lunora(): the `lazyFunctions` option was removed. Set `codegen: { lazyFunctions: true }` in lunora.config (or pass --lazy-functions for one run).");const t=e.schemaDir??"lunora";let o;e.cloudflare===!1?o=!1:e.cloudflare===!0||e.cloudflare===void 0?o={}:o=e.cloudflare;const s=e.projectRoot??process.cwd(),n=ar(s,e.target);return{allowUnauthenticatedShardAccess:e.allowUnauthenticatedShardAccess??!1,apiSpec:e.apiSpec??"openapi",lazyFunctions:Z(),cloudflare:o,studio:e.studio??!0,generatedDir:`${t}/_generated`,overlay:sr(e.overlay),projectRoot:s,schemaDir:t,shard:e.shard??{},target:n,validateWrangler:e.validateWrangler??!0}},b=(r,e)=>{const{configPath:t}=r;return typeof t=="string"&&t!==""?h(e,t):void 0},Or=r=>{const e=lr(r),t=Ye(),o=Y();let s=[],n=[];const i=[er(e,t),ke(e,t),Re(e,{configPath:e.cloudflare===!1?void 0:b(e.cloudflare,e.projectRoot),withheld:()=>[...new Set([...s,...n])]}),Ie(e,o),Pe(e,o),He(e.projectRoot),Be(e,e.cloudflare===!1?void 0:b(e.cloudflare,e.projectRoot)),Ee(),Ae(e),We(e),Qe(e),De()];e.studio&&i.push(xe(e)),e.validateWrangler&&i.push(Le(e,o)),e.overlay!==!1&&i.push(ne(e.overlay)),i.push(be(e,o));const a=e.cloudflare===!1?void 0:{...e.cloudflare};if(i.push(_e(a,{projectRoot:e.projectRoot},l=>{s=l.withheld.map(c=>c.binding)})),a===void 0&&i.push(O({projectRoot:e.projectRoot})),a!==void 0){i.push(ir(a,e.projectRoot));const l=X(e.target),c=ze(e.projectRoot,e.target),u=()=>l&&c().runs;i.push(...Ke([O({projectRoot:e.projectRoot,wranglerConfigPath:b(a,e.projectRoot)}),rr(a,{onWithheld:d=>{n=d},projectRoot:e.projectRoot}),...Oe(H(a))],u)),l&&i.push(Je(e.projectRoot,u),{apply:(d,f)=>f.command==="serve"&&f.isPreview!==!0&&!u(),configureServer(d){d.config.logger.warn(`[lunora] target "${e.target}": vite dev serves the worker in workerd, not on ${e.target} — ${c().reason??"it cannot run this project"}. \`vite build\` then \`lunora deploy\` ships it to ${e.target}.`)},name:"lunora:target-runtime-notice"})}return i},Lr=I(import.meta.url)("../package.json").version;export{Ur as CLASS_A_WIRING,Nr as GENERATED_CLASS_MODULES,it as LUNORA_API_UPDATED_EVENT,jr as LUNORA_WORKER_VIRTUAL_ID,at as STUDIO_PATH,Lr as VERSION,rt as WORKER_STARTUP_HINT,tt as augmentWorkerStartupError,Zr as buildStudioUrl,Hr as buildWorkerEntrySource,Gr as checkLunoraProxy,Pe as codegenPlugin,be as containerLogsPlugin,Fr as detectFramework,Ae as devStatePlugin,Re as devVariablesPlugin,ke as frameworkComposePlugin,Vr as isAutoComposable,ot as isWorkerEntryEvalError,Ee as logStreamPlugin,Or as lunora,Yr as lunoraSolutionFinder,Ce as lunoraSolutionFinders,qr as planViteRemoteBindings,De as proxyCheckPlugin,Ir as reconcileWranglerCrons,_e as remoteBindingsPlugin,sr as resolveOverlayOption,xe as studioPlugin,Jr as withRemoteBindings,Oe as withWorkerStartupHint,Le as wranglerValidatorPlugin};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{formatDevBannerRow as n,targetRunsOwnDevServer as l,devTriggerHints as i}from"@lunora/config";import{STUDIO_PATH as g,studioMountPath as f,isNonLoopbackHost as u,createStudioMiddleware as m}from"@lunora/config/studio-host";import{STUDIO_PATH as D}from"@lunora/config/studio-host";const h=/\/$/,S=e=>{if(e.resolvedLocal!==void 0&&e.resolvedLocal!=="")return`${e.resolvedLocal.replace(h,"")}${g}`;const o=f(e.base);if(e.address===void 0||typeof e.address=="string")return`http://localhost:5173${o}`;const r=e.address.address==="::"||e.address.address==="0.0.0.0"?"localhost":e.address.address;return`http://${r.includes(":")?`[${r}]`:r}:${String(e.address.port)}${o}`},d={arrow:e=>`\x1B[32m${e}\x1B[39m`,label:e=>`\x1B[1m${e}\x1B[22m`},a=9,p=(e,o)=>{const t=e.cloudflare!==!1&&!l(e.target)?`${new URL(o).origin}/cdn-cgi/local/scheduled`:void 0;return i({projectRoot:e.projectRoot,scheduledUrl:t,schemaDirectory:e.schemaDir,studioUrl:o}).map(({label:s,text:c})=>n(s,c,a,d))},$=e=>({apply:"serve",configureServer(o){const r=u(o.config.server?.host);return o.middlewares.use(m({apiSpec:e.apiSpec,lazyFunctions:e.lazyFunctions,base:o.config.base,isNonLoopbackBind:r,logger:o.config.logger,projectRoot:e.projectRoot,schemaDirectory:e.schemaDir})),()=>{const t=()=>{const s=S({address:o.httpServer?.address()??void 0,base:o.config.base,resolvedLocal:o.resolvedUrls?.local[0]});o.config.logger.info(n("Lunora",`\x1B[36m${s}\x1B[39m`,a,d));for(const c of p(e,s))o.config.logger.info(c)};if(typeof o.printUrls=="function"){const s=o.printUrls.bind(o);o.printUrls=()=>{s(),t()}}else o.httpServer?.listening===!0?t():o.httpServer?.once("listening",t)}},name:"lunora:studio"});export{D as STUDIO_PATH,S as buildStudioUrl,$ as studioPlugin};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{existsSync as we}from"node:fs";import{resolve as h,dirname as Se,sep as $,basename as q,join as Q,relative as ye}from"node:path";import{PROJECT_CONFIG_FILENAMES as U,readServiceBindings as Re,readProjectLazyFunctions as Y,projectConfigCandidatePaths as Z,createCodegenProject as ae,runCodegen as ve,findTsconfig as Ee,isTestPath as ke,fingerprintSchemaSources as z,refreshCodegenProject as je,CodegenDiagnosticError as Ce}from"@lunora/codegen";import{LUNORA_TAG as y,isCodegenDisabled as $e,CODEGEN_ENV as ee,createDiscoveryCache as De,writeApiSpecMarker as be,reportCodegenFindings as Te,blockingFindingsMessage as _e,STRICT_ADVISORIES_ENV as Pe,runPostCodegenHook as te}from"@lunora/config";import{pendingBindingChanges as Ne,WRANGLER_FILES as ne,wranglerCodegenInputs as Fe,reconcileWranglerExtras as Ie,reconcileBindingsSafely as Me}from"@lunora/config/cloudflare";import{consumeStudioWrite as Ae}from"@lunora/config/studio-host";import{isRunnableDevEnvironment as Oe}from"vite";import{c as L,m as We,o as xe}from"./build-session-D75JzvIT.mjs";import Be from"./LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs";import{a as Ge,r as Le}from"./server-close-DWiO4Vxb.mjs";const Ue=2e3,Ve=(e,i)=>{const c=setTimeout(e,i);return()=>{clearTimeout(c)}},He=e=>{const i=e.pending??Ne,c=e.schedule??Ve;let o=new Set,f,a=0;const s=async()=>{if(f=void 0,e.isSuppressed())return;const u=a,d=await i({...e.project,cache:e.cache});if(a!==u||e.isSuppressed())return;const R=d.filter(g=>!o.has(g));o=new Set(d),R.length!==0&&e.warn(`${y} ${d.join(", ")} — not in the running worker yet. Restart the dev server to write ${d.length===1?"it":"them"} to the wrangler config.`)},m=()=>{a+=1,e.cache.clear(),f?.(),f=void 0};return{check:s,dispose:()=>{a+=1,f?.(),f=void 0},invalidate:m,noteSave:()=>{m(),f=c(s,Ue)}}},Je=e=>{const i=U.some(c=>h(e.projectRoot,c)===e.file);return e.flipped&&(!i||!e.baselineSettled)},Ke=100,se=300,re=2,Xe=e=>{let i,c=!1,o,f=0;const a=()=>{i&&(clearTimeout(i),i=void 0)},s=(d,R)=>{o&&clearTimeout(o),o=setTimeout(()=>{if(o=void 0,e.fingerprint()!==d){if(f+=1,f>re){e.logger.warn(`${y} \`postcodegen\` keeps rewriting the schema sources — stopping after ${String(re)} reruns. Make the hook idempotent or move it off the schema directory.`);return}e.logger.info(`${y} schema changed while \`postcodegen\` was running — regenerating`),R()}},se)},m=(d,R)=>{e.regenerate(d,g=>{s(g,()=>{m(d,!0)})},R)},u=(d,R)=>{const g=R||i!==void 0&&c;a(),f=0,c=g,i=setTimeout(()=>{i=void 0,m(d,g)},Ke)};return{cancelPending:a,dispose:()=>{a(),o&&(clearTimeout(o),o=void 0)},onSave:d=>{u(d,!0)},onStudioWrite:d=>{u(d,!1)}}},oe=/[/\\]tsconfig\..+\.json$/u,qe=/\.[cm]?[jt]sx?$/u,Qe=/(?:\.[cm]?[jt]sx?|(?:^|[/\\])tsconfig(?:\..+)?\.json)$/u,Ye=e=>{const i=e.map(o=>` • ${o.kind} "${o.exportName}" — class ${o.className} is not exported by your worker entry.`),c=[...new Set(e.map(o=>o.module))].map(o=>` export * from "./lunora/_generated/${o}";`);return[`[lunora] ${String(e.length)} declared ${e.length===1?"binding is":"bindings are"} not exported by your worker entry — \`wrangler deploy\` will fail.`,...i,"","Add to your worker entry:",...c].join(`
|
|
2
|
+
`)},Ze=(e,i,c)=>{if(i.warn(`${y} schema.ts not found at ${e} — codegen skipped`),c!==void 0){const o=`schema.ts not found at ${e} — generated output is now stale`;c.onError(new Error(o),o)}},O=(e,i,c,o)=>{const f=Q(e.projectRoot,e.schemaDir,"schema.ts");if(!we(f))return Ze(f,i,c),{};try{const a=o??ae(Q(e.projectRoot,e.schemaDir)),s=ve({apiSpec:e.apiSpec,lazyFunctions:e.lazyFunctions,lunoraDirectory:e.schemaDir,project:a,projectRoot:e.projectRoot,target:e.target,...Fe(e.projectRoot)});Ie(e.projectRoot,s.cronTriggers,i);let m;try{be(e.projectRoot,e.apiSpec)}catch(u){m=`${y} could not write the API spec marker: ${u instanceof Error?u.message:String(u)}`,i.error(m)}return Te(s,i),{blockingMessage:_e(s,{strictAdvisories:process.env[Pe]!=="0"}),markerFailure:m,outputDirectory:h(s.outputDirectory),project:a}}catch(a){const s=a instanceof Error?a.message:String(a);return i.error(`${y} codegen failed: ${s}`),c?.onError(a,s),{failure:`${y} codegen failed: ${s}`}}},ze=(e,i,c)=>{let o;for(const[f,a]of Object.entries(e.environments)){if(f==="client"){o=a;continue}Oe(a)||a.hot.send({path:"*",triggeredBy:i,type:"full-reload"})}if(o===void 0){e.hot.send({type:"full-reload"});return}if(c){o.hot.send({type:"full-reload"});return}o.hot.send({event:Be,type:"custom"})},F={error:e=>{console.error(e)},info:e=>{console.info(e)},warn:e=>{console.warn(e)}},ce=new WeakMap,ie=async(e,i,c)=>{const o=ce.get(e)??new Map;return ce.set(e,o),o.has(i)||o.set(i,c()),o.get(i)},lt=(e,i)=>{const c=h(e.projectRoot,e.schemaDir),o=e.cloudflare===!1?void 0:e.cloudflare.configPath,f=typeof o=="string"&&o!==""&&!ne.some(n=>h(e.projectRoot,n)===h(e.projectRoot,o)),a=$e(process.env[ee]);let s=h(e.projectRoot,e.generatedDir),m=0,u=!1,d;const R=new Map;let g,I=!1,_=!1,W=!1,V,v,P;const x=new Set,de=n=>{const p=x.has(n)?void 0:P;return x.add(n),v!=="build"&&(P=void 0),p},le=async()=>{u=!0;let n;try{n=await te({cwd:e.projectRoot,logger:F})}finally{u=!1}return n.ran&&(m=Date.now(),i?.clear()),n.error},fe=async()=>{P=await xe(e,"codegen",()=>{const{blockingMessage:n,failure:p,markerFailure:E,outputDirectory:k}=O(e,F);return{blockingMessage:n,failure:p,markerFailure:E,outputDirectory:k}})};return{config(n,p){v=p.command},configResolved(){if(x.clear(),v==="build")return fe();a||(P=O(e,F))},async buildStart(){const n=v!=="build"&&a,p=de(v==="build"?this.environment.name:"")??(n?{}:O(e,F)),{blockingMessage:E,failure:k,markerFailure:M,outputDirectory:j}=p;v==="build"&&We(e),v==="build"&&k!==void 0&&this.error(k),v==="build"&&M!==void 0&&this.error(M),s=j??s;const C=j===void 0?void 0:await ie(p,"postcodegen",le);v==="build"&&C!==void 0&&this.error(C),v==="build"&&E!==void 0&&this.error(E),await ie(p,"reconcile",async()=>Me({...e,cache:i},F,w=>{d?.hot.send({err:{loc:void 0,message:Ye(w),stack:""},type:"error"})})),i?.clear(),d!==void 0&&(g=L(e.projectRoot),I=!0)},configureServer(n){d=n,n.watcher.add(c);const p=Re(e.projectRoot).services.filter(t=>t.rpcEntrypoint!==void 0).map(t=>Se(t.wranglerPath));n.watcher.add(p),g=L(e.projectRoot),I=!1;const E={error:t=>{n.config.logger.error(t)},info:t=>{n.config.logger.info(t)},warn:t=>{n.config.logger.warn(t)}};let k=!1;const M={onError(t,r){k=!0;const l=t instanceof Ce?{column:t.column,file:t.file,line:t.line}:void 0,S=l===void 0?`[lunora] codegen failed: ${r}
|
|
3
|
+
(see terminal for full stack trace and file location)`:`[lunora] codegen failed: ${r}`;d?.hot.send({err:{loc:l,message:S,stack:t instanceof Error?t.stack??"":""},type:"error"})}},j=(t,r)=>t===r||t.startsWith(r+$);let C=!1,w=P?.project;const ue=()=>{for(const t of Object.values(n.environments)){const r=t.moduleGraph;for(const l of r.idToModuleMap.values())l.id&&j(l.id,s)&&r.invalidateModule(l)}},ge=()=>{w===void 0?w=ae(c):je(w,c);const{outputDirectory:t}=O(e,E,M,w);return t===void 0?(w=void 0,!1):(s=t,!0)},N=He({cache:i??De(),isSuppressed:()=>(_&&(W=!0),_||C||f),project:e,warn:E.warn});V=N.noteSave;const he=async(t,r,l)=>{try{if(C||l&&!ge())return;const S=z(c);u=!0;let G;try{G=await te({cwd:e.projectRoot,logger:E})}finally{u=!1}if(G.ran&&(m=Date.now(),r(S)),G.error!==void 0)return;ue(),ze(n,t,k),k=!1,N.noteSave()}catch(S){E.error(`${y} codegen watch: ${S instanceof Error?S.message:String(S)}`)}};let H=Y(c);const A=Xe({fingerprint:()=>z(c),logger:E,regenerate:(t,r,l)=>{he(t,r,l)}}),me=t=>{if(oe.test(t))return w=void 0,!1;if(U.includes(q(t))&&Z(c).includes(t)){w=void 0;const r=Y(c),l=r!==H;return H=r,Je({baselineSettled:I,file:t,flipped:l,projectRoot:e.projectRoot})}return t.endsWith(`${$}tsconfig.json`)&&t===Ee(c)?(w=void 0,!1):!(!j(t,c)||j(t,s)||!t.endsWith(".ts")||ke(ye(c,t).split($).join("/")))},D=t=>{const r=h(t);if(!(!(Qe.test(r)&&!r.includes(`${$}node_modules${$}`)&&p.some(S=>j(r,S)))&&!me(r))){if(u||Date.now()-m<se){A.cancelPending();return}if(Ae(r)){A.onStudioWrite(r);return}N.invalidate(),A.onSave(r)}},J=h(e.projectRoot,"src"),B=(t,r)=>t.startsWith(`${r}${$}`),b=t=>{const r=h(t);if(!qe.test(r)||B(r,s))return;const l=!a&&r.endsWith(".ts");(B(r,J)||!l&&B(r,c))&&N.noteSave()},K=t=>{const r=h(t);(r.endsWith(`${$}tsconfig.json`)||oe.test(r))&&(w=void 0)};a?n.config.logger.info(`${y} codegen watch disabled (${ee}) — _generated/ is written only by an explicit \`lunora codegen\``):(n.watcher.on("add",D),n.watcher.on("change",D),n.watcher.on("unlink",D),n.watcher.on("unlink",K)),n.watcher.add(J),n.watcher.on("add",b),n.watcher.on("change",b),n.watcher.on("unlink",b);const X=new Set([...ne.map(t=>h(e.projectRoot,t)),...U.map(t=>h(e.projectRoot,t)),...Z(c)]);for(const t of X)n.watcher.add(t);const T=t=>{if(!X.has(h(t))||_)return;const r=L(e.projectRoot);if(!I){g=r;return}if(g===void 0){g=r;return}r!==g&&(g=r,_=!0,n.config.logger.info(`${y} ${q(h(t))} changed — restarting dev server`),Promise.resolve(n.restart()).finally(()=>{_=!1,W&&(W=!1,V?.())}).catch(l=>{const S=l instanceof Error?l.message:String(l);n.config.logger.error(`${y} dev server restart failed: ${S} — keeping the running server; re-save your config to retry.`),n.hot.send({err:{loc:void 0,message:`[lunora] dev server restart failed: ${S}`,stack:""},type:"error"})}))};n.watcher.on("add",T),n.watcher.on("change",T),n.watcher.on("unlink",T);const pe=()=>{C||(C=!0,w=void 0,A.dispose(),N.dispose(),a||(n.watcher.off("add",D),n.watcher.off("change",D),n.watcher.off("unlink",D),n.watcher.off("unlink",K)),n.watcher.off("add",b),n.watcher.off("change",b),n.watcher.off("unlink",b),n.watcher.off("add",T),n.watcher.off("change",T),n.watcher.off("unlink",T))};return()=>{Le(n,R,pe)}},buildEnd(){Ge(R,this.environment)},name:"lunora:codegen"}};export{lt as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as h}from"node:fs";import{resolve as l}from"node:path";import{ENV_FILENAME as g,ensureDevVariables as m,createConfirm as w,fillDevSecrets as R,ensureDevWorkerEnv as E,lunoraLine as f,secretSourcesFromBindings as D,inferLunoraBindings as j,checkDevEnv as p,detectFramework as S,describeDevEnvCheck as k}from"@lunora/config";const C=async(e,n,o)=>{try{return D(await j({projectRoot:e,schemaDir:n}))}catch(r){o(`could not read the project's bindings, so every dev secret is generated: ${r instanceof Error?r.message:String(r)}`);return}},y="wrangler.dev.jsonc",b=new Set(["nuxt","sveltekit"]),P=(e,n)=>{const o=l(e.projectRoot,y),r={projectRoot:e.projectRoot,schemaDirectory:e.schemaDir};return b.has(S(e.projectRoot).framework)&&h(o)?{...r,configPath:o,vars:{WORKER_ENV:"development"}}:{...r,configPath:n.configPath,withheld:n.withheld}},u=new Map,_=(e,n,o,r)=>{const a=k(e,n,{wasInvalid:r});return a!==void 0&&o[a.level](f(a.message)),e.kind==="invalid"||e.kind==="unloadable"&&r},V=(e,{configPath:n,withheld:o=()=>[]}={})=>{let r=!1,a=u.get(e.projectRoot)??!1,d=0;const v=async t=>{d+=1;const c=d,i=await p(P(e,{configPath:n,withheld:o()}));c===d&&(a=_(i,e.schemaDir,t,a),u.set(e.projectRoot,a))};return{apply:"serve",config(t,c){r=c.isPreview===!0},async configResolved(){if(r)return;const t=s=>{console.info(f(s))},c=s=>{console.warn(f(s))};if((await m({confirm:w("[lunora] "),cwd:e.projectRoot,info:t,warn:c})).status!=="unreadable"){const s=await C(e.projectRoot,e.schemaDir,t);R({cwd:e.projectRoot,info:t,secretSources:s}),E(e.projectRoot,t)}await v(console)},configureServer(t){if(r)return;const c=l(e.projectRoot,e.schemaDir,g),i=s=>{l(s)===c&&v(t.config.logger)};t.watcher.add(c),t.watcher.on("add",i),t.watcher.on("change",i),t.watcher.on("unlink",i)},enforce:"pre",name:"lunora:dev-vars"}};export{V as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readProjectRemotePreference as m,lunoraLine as o}from"@lunora/config";import{resolveRemoteEnabled as b,materializeDevWranglerConfig as P,toRemotePlan as v,describeWithheld as p}from"@lunora/config/cloudflare";const g=()=>{},R=e=>{const i=e.readPreference??m;if(!b({configPreference:i(e.projectRoot),envValue:e.remoteEnv??process.env.LUNORA_REMOTE}))return{bindings:[],cleanup:g,enabled:!1,withheld:[]};const n=e.materialize??P;return v(n({projectRoot:e.projectRoot,remote:!0}),!0)},j=(e,i)=>!i.enabled||i.configPath===void 0||typeof e.configPath=="string"?e:{...e,configPath:i.configPath},w=e=>{if(!e.enabled||e.configPath===void 0)return;const i=e.bindings.length>0?` (${e.bindings.join(", ")})`:"";console.info(o(`remote bindings${i} are materialized at ${e.configPath} — this project adds @cloudflare/vite-plugin itself (\`cloudflare: false\`), so pass that path as its \`configPath\` to use them.`))},B=(e,i,r)=>{let n={bindings:[],cleanup:g,enabled:!1,withheld:[]},c;const d=()=>{n.cleanup()};return{buildEnd:d,closeBundle:d,config(E,h){if(h.command!=="serve")return;n.cleanup(),n=R(i);const s=f=>{r?.(f?n:{...n,withheld:[]});for(const u of f?n.withheld:[])console.warn(o(p(u)))};if(e===void 0){s(!0),w(n);return}const t=e;c!==void 0&&t.configPath===c&&delete t.configPath;const a=j(e,n),l=a.configPath!==void 0&&t.configPath===void 0;s(l),l?(t.configPath=a.configPath,c=a.configPath,n.bindings.length>0&&console.info(o(`remote bindings: ${n.bindings.join(", ")} → deployed resources`))):n.enabled&&n.configPath===void 0&&n.reason!==void 0&&console.info(o(`remote bindings requested but not applied: ${n.reason}`))},enforce:"pre",name:"lunora:remote-bindings"}};export{R as planViteRemoteBindings,B as remoteBindingsPlugin,j as withRemoteBindings};
|
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.429",
|
|
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,8 +46,8 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@cloudflare/vite-plugin": "1.63.1",
|
|
49
|
-
"@lunora/codegen": "^1.0.0-alpha.
|
|
50
|
-
"@lunora/config": "^1.0.0-alpha.
|
|
49
|
+
"@lunora/codegen": "^1.0.0-alpha.402",
|
|
50
|
+
"@lunora/config": "^1.0.0-alpha.458",
|
|
51
51
|
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
52
52
|
"@visulima/vite-overlay": "2.0.41"
|
|
53
53
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{STUDIO_PATH as d,studioMountPath as a,isNonLoopbackHost as c,createStudioMiddleware as n}from"@lunora/config/studio-host";import{STUDIO_PATH as p}from"@lunora/config/studio-host";const l=/\/$/,i=e=>{if(e.resolvedLocal!==void 0&&e.resolvedLocal!=="")return`${e.resolvedLocal.replace(l,"")}${d}`;const o=a(e.base);if(e.address===void 0||typeof e.address=="string")return`http://localhost:5173${o}`;const s=e.address.address==="::"||e.address.address==="0.0.0.0"?"localhost":e.address.address;return`http://${s.includes(":")?`[${s}]`:s}:${String(e.address.port)}${o}`},f=e=>({apply:"serve",configureServer(o){const s=c(o.config.server?.host);return o.middlewares.use(n({apiSpec:e.apiSpec,lazyFunctions:e.lazyFunctions,base:o.config.base,isNonLoopbackBind:s,logger:o.config.logger,projectRoot:e.projectRoot,schemaDirectory:e.schemaDir})),()=>{const t=()=>{const r=i({address:o.httpServer?.address()??void 0,base:o.config.base,resolvedLocal:o.resolvedUrls?.local[0]});o.config.logger.info(` \x1B[32m➜\x1B[39m \x1B[1mLunora\x1B[22m: \x1B[36m${r}\x1B[39m`)};if(typeof o.printUrls=="function"){const r=o.printUrls.bind(o);o.printUrls=()=>{r(),t()}}else o.httpServer?.listening===!0?t():o.httpServer?.once("listening",t)}},name:"lunora:studio"});export{p as STUDIO_PATH,i as buildStudioUrl,f as studioPlugin};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{existsSync as se}from"node:fs";import{resolve as S,dirname as de,sep as D,basename as G,join as B,relative as le}from"node:path";import{PROJECT_CONFIG_FILENAMES as O,readServiceBindings as fe,readProjectLazyFunctions as U,projectConfigCandidatePaths as V,createCodegenProject as Z,runCodegen as ue,findTsconfig as ge,isTestPath as me,fingerprintSchemaSources as H,refreshCodegenProject as he,CodegenDiagnosticError as pe}from"@lunora/codegen";import{LUNORA_TAG as y,isCodegenDisabled as we,CODEGEN_ENV as J,writeApiSpecMarker as Se,reportCodegenFindings as ye,blockingFindingsMessage as ve,STRICT_ADVISORIES_ENV as Re,runPostCodegenHook as K}from"@lunora/config";import{WRANGLER_FILES as Ee,wranglerCodegenInputs as ke,reconcileWranglerExtras as je,reconcileBindingsSafely as Ce}from"@lunora/config/cloudflare";import{consumeStudioWrite as $e}from"@lunora/config/studio-host";import{isRunnableDevEnvironment as be}from"vite";import{c as I,m as De,o as Pe}from"./build-session-D75JzvIT.mjs";import Te from"./LUNORA_API_UPDATED_EVENT-CO2Rv2re.mjs";import{a as _e,r as Me}from"./server-close-DWiO4Vxb.mjs";const Fe=e=>{const c=O.some(i=>S(e.projectRoot,i)===e.file);return e.flipped&&(!c||!e.baselineSettled)},Ae=100,z=300,X=2,Ne=e=>{let c,i=!1,n,f=0;const a=()=>{c&&(clearTimeout(c),c=void 0)},l=(s,p)=>{n&&clearTimeout(n),n=setTimeout(()=>{if(n=void 0,e.fingerprint()!==s){if(f+=1,f>X){e.logger.warn(`${y} \`postcodegen\` keeps rewriting the schema sources — stopping after ${String(X)} reruns. Make the hook idempotent or move it off the schema directory.`);return}e.logger.info(`${y} schema changed while \`postcodegen\` was running — regenerating`),p()}},z)},h=(s,p)=>{e.regenerate(s,E=>{l(E,()=>{h(s,!0)})},p)},v=(s,p)=>{const E=p||c!==void 0&&i;a(),f=0,i=E,c=setTimeout(()=>{c=void 0,h(s,E)},Ae)};return{cancelPending:a,dispose:()=>{a(),n&&(clearTimeout(n),n=void 0)},onSave:s=>{v(s,!0)},onStudioWrite:s=>{v(s,!1)}}},q=/[/\\]tsconfig\..+\.json$/u,Ie=/(?:\.[cm]?[jt]sx?|(?:^|[/\\])tsconfig(?:\..+)?\.json)$/u,Oe=e=>{const c=e.map(n=>` • ${n.kind} "${n.exportName}" — class ${n.className} is not exported by your worker entry.`),i=[...new Set(e.map(n=>n.module))].map(n=>` export * from "./lunora/_generated/${n}";`);return[`[lunora] ${String(e.length)} declared ${e.length===1?"binding is":"bindings are"} not exported by your worker entry — \`wrangler deploy\` will fail.`,...c,"","Add to your worker entry:",...i].join(`
|
|
2
|
-
`)},We=(e,c,i)=>{if(c.warn(`${y} schema.ts not found at ${e} — codegen skipped`),i!==void 0){const n=`schema.ts not found at ${e} — generated output is now stale`;i.onError(new Error(n),n)}},F=(e,c,i,n)=>{const f=B(e.projectRoot,e.schemaDir,"schema.ts");if(!se(f))return We(f,c,i),{};try{const a=n??Z(B(e.projectRoot,e.schemaDir)),l=ue({apiSpec:e.apiSpec,lazyFunctions:e.lazyFunctions,lunoraDirectory:e.schemaDir,project:a,projectRoot:e.projectRoot,target:e.target,...ke(e.projectRoot)});je(e.projectRoot,l.cronTriggers,c);let h;try{Se(e.projectRoot,e.apiSpec)}catch(v){h=`${y} could not write the API spec marker: ${v instanceof Error?v.message:String(v)}`,c.error(h)}return ye(l,c),{blockingMessage:ve(l,{strictAdvisories:process.env[Re]!=="0"}),markerFailure:h,outputDirectory:S(l.outputDirectory),project:a}}catch(a){const l=a instanceof Error?a.message:String(a);return c.error(`${y} codegen failed: ${l}`),i?.onError(a,l),{failure:`${y} codegen failed: ${l}`}}},xe=(e,c,i)=>{let n;for(const[f,a]of Object.entries(e.environments)){if(f==="client"){n=a;continue}be(a)||a.hot.send({path:"*",triggeredBy:c,type:"full-reload"})}if(n===void 0){e.hot.send({type:"full-reload"});return}if(i){n.hot.send({type:"full-reload"});return}n.hot.send({event:Te,type:"custom"})},T={error:e=>{console.error(e)},info:e=>{console.info(e)},warn:e=>{console.warn(e)}},Q=new WeakMap,Y=async(e,c,i)=>{const n=Q.get(e)??new Map;return Q.set(e,n),n.has(c)||n.set(c,i()),n.get(c)},Qe=(e,c)=>{const i=S(e.projectRoot,e.schemaDir),n=we(process.env[J]);let f=S(e.projectRoot,e.generatedDir),a=0,l=!1,h;const v=new Map;let s,p=!1,E=!1,w,P;const A=new Set,ee=r=>{const u=A.has(r)?void 0:P;return A.add(r),w!=="build"&&(P=void 0),u},te=async()=>{l=!0;let r;try{r=await K({cwd:e.projectRoot,logger:T})}finally{l=!1}return r.ran&&(a=Date.now(),c?.clear()),r.error},re=async()=>{P=await Pe(e,"codegen",()=>{const{blockingMessage:r,failure:u,markerFailure:R,outputDirectory:k}=F(e,T);return{blockingMessage:r,failure:u,markerFailure:R,outputDirectory:k}})};return{config(r,u){w=u.command},configResolved(){if(A.clear(),w==="build")return re();n||(P=F(e,T))},async buildStart(){const r=w!=="build"&&n,u=ee(w==="build"?this.environment.name:"")??(r?{}:F(e,T)),{blockingMessage:R,failure:k,markerFailure:_,outputDirectory:j}=u;w==="build"&&De(e),w==="build"&&k!==void 0&&this.error(k),w==="build"&&_!==void 0&&this.error(_),f=j??f;const C=j===void 0?void 0:await Y(u,"postcodegen",te);w==="build"&&C!==void 0&&this.error(C),w==="build"&&R!==void 0&&this.error(R),await Y(u,"reconcile",async()=>Ce({...e,cache:c},T,g=>{h?.hot.send({err:{loc:void 0,message:Oe(g),stack:""},type:"error"})})),c?.clear(),h!==void 0&&(s=I(e.projectRoot),p=!0)},configureServer(r){h=r,r.watcher.add(i);const u=fe(e.projectRoot).services.filter(t=>t.rpcEntrypoint!==void 0).map(t=>de(t.wranglerPath));r.watcher.add(u),s=I(e.projectRoot),p=!1;const R={error:t=>{r.config.logger.error(t)},info:t=>{r.config.logger.info(t)},warn:t=>{r.config.logger.warn(t)}};let k=!1;const _={onError(t,o){k=!0;const d=t instanceof pe?{column:t.column,file:t.file,line:t.line}:void 0,m=d===void 0?`[lunora] codegen failed: ${o}
|
|
3
|
-
(see terminal for full stack trace and file location)`:`[lunora] codegen failed: ${o}`;h?.hot.send({err:{loc:d,message:m,stack:t instanceof Error?t.stack??"":""},type:"error"})}},j=(t,o)=>t===o||t.startsWith(o+D);let C=!1,g=P?.project;const ne=()=>{for(const t of Object.values(r.environments)){const o=t.moduleGraph;for(const d of o.idToModuleMap.values())d.id&&j(d.id,f)&&o.invalidateModule(d)}},oe=()=>{g===void 0?g=Z(i):he(g,i);const{outputDirectory:t}=F(e,R,_,g);return t===void 0?(g=void 0,!1):(f=t,!0)},ie=async(t,o,d)=>{try{if(C||d&&!oe())return;const m=H(i);l=!0;let N;try{N=await K({cwd:e.projectRoot,logger:R})}finally{l=!1}if(N.ran&&(a=Date.now(),o(m)),N.error!==void 0)return;ne(),xe(r,t,k),k=!1}catch(m){R.error(`${y} codegen watch: ${m instanceof Error?m.message:String(m)}`)}};let W=U(i);const M=Ne({fingerprint:()=>H(i),logger:R,regenerate:(t,o,d)=>{ie(t,o,d)}}),ce=t=>{if(q.test(t))return g=void 0,!1;if(O.includes(G(t))&&V(i).includes(t)){g=void 0;const o=U(i),d=o!==W;return W=o,Fe({baselineSettled:p,file:t,flipped:d,projectRoot:e.projectRoot})}return t.endsWith(`${D}tsconfig.json`)&&t===ge(i)?(g=void 0,!1):!(!j(t,i)||j(t,f)||!t.endsWith(".ts")||me(le(i,t).split(D).join("/")))},$=t=>{const o=S(t);if(!(!(Ie.test(o)&&!o.includes(`${D}node_modules${D}`)&&u.some(m=>j(o,m)))&&!ce(o))){if(l||Date.now()-a<z){M.cancelPending();return}if($e(o)){M.onStudioWrite(o);return}M.onSave(o)}},x=t=>{const o=S(t);(o.endsWith(`${D}tsconfig.json`)||q.test(o))&&(g=void 0)};n?r.config.logger.info(`${y} codegen watch disabled (${J}) — _generated/ is written only by an explicit \`lunora codegen\``):(r.watcher.on("add",$),r.watcher.on("change",$),r.watcher.on("unlink",$),r.watcher.on("unlink",x));const L=new Set([...Ee.map(t=>S(e.projectRoot,t)),...O.map(t=>S(e.projectRoot,t)),...V(i)]);for(const t of L)r.watcher.add(t);const b=t=>{if(!L.has(S(t))||E)return;const o=I(e.projectRoot);if(!p){s=o;return}if(s===void 0){s=o;return}o!==s&&(s=o,E=!0,r.config.logger.info(`${y} ${G(S(t))} changed — restarting dev server`),Promise.resolve(r.restart()).finally(()=>{E=!1}).catch(d=>{const m=d instanceof Error?d.message:String(d);r.config.logger.error(`${y} dev server restart failed: ${m} — keeping the running server; re-save your config to retry.`),r.hot.send({err:{loc:void 0,message:`[lunora] dev server restart failed: ${m}`,stack:""},type:"error"})}))};r.watcher.on("add",b),r.watcher.on("change",b),r.watcher.on("unlink",b);const ae=()=>{C||(C=!0,g=void 0,M.dispose(),r.watcher.off("add",$),r.watcher.off("change",$),r.watcher.off("unlink",$),r.watcher.off("unlink",x),r.watcher.off("add",b),r.watcher.off("change",b),r.watcher.off("unlink",b))};return()=>{Me(r,v,ae)}},buildEnd(){_e(v,this.environment)},name:"lunora:codegen"}};export{Qe as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ensureDevVariables as t,createConfirm as c,fillDevSecrets as i,ensureDevWorkerEnv as a,lunoraLine as u,secretSourcesFromBindings as d,inferLunoraBindings as f}from"@lunora/config";const l=async(e,o,r)=>{try{return d(await f({projectRoot:e,schemaDir:o}))}catch(n){r(`could not read the project's bindings, so every dev secret is generated: ${n instanceof Error?n.message:String(n)}`);return}},g=e=>{let o=!1;return{apply:"serve",config(r,n){o=n.isPreview===!0},async configResolved(){if(o)return;const r=s=>{console.info(u(s))};await t({confirm:c("[lunora] "),cwd:e.projectRoot,info:r});const n=await l(e.projectRoot,e.schemaDir,r);i({cwd:e.projectRoot,info:r,secretSources:n}),a(e.projectRoot,r)},enforce:"pre",name:"lunora:dev-vars"}};export{g as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{readProjectRemotePreference as s,lunoraLine as c}from"@lunora/config";import{resolveRemoteEnabled as g,materializeDevWranglerConfig as h,describeWithheld as u}from"@lunora/config/cloudflare";const l=()=>{},m=e=>{const t=e.readPreference??s;if(!g({configPreference:t(e.projectRoot),envValue:e.remoteEnv??process.env.LUNORA_REMOTE}))return{cleanup:l,enabled:!1,withheld:[]};const i=(e.materialize??h)({projectRoot:e.projectRoot,remote:!0});return{cleanup:i.cleanup,configPath:i.configPath,enabled:!0,reason:i.reason,withheld:i.withheld}},P=(e,t)=>!t.enabled||t.configPath===void 0||typeof e.configPath=="string"?e:{...e,configPath:t.configPath},R=(e,t)=>{let n={cleanup:l,enabled:!1,withheld:[]},o;const i=()=>{n.cleanup()};return{buildEnd:i,closeBundle:i,config(b,d){if(d.command!=="serve")return;n.cleanup(),n=m(t);for(const f of n.withheld)console.warn(c(u(f)));if(e===void 0){n.enabled&&n.configPath!==void 0&&console.info(c(`remote bindings are materialized at ${n.configPath} — this project adds @cloudflare/vite-plugin itself (\`cloudflare: false\`), so pass that path as its \`configPath\` to use them.`));return}const r=e;o!==void 0&&r.configPath===o&&delete r.configPath;const a=P(e,n);a.configPath!==void 0&&r.configPath===void 0?(r.configPath=a.configPath,o=a.configPath):n.enabled&&n.configPath===void 0&&n.reason!==void 0&&console.info(c(`remote bindings requested but not applied: ${n.reason}`))},enforce:"pre",name:"lunora:remote-bindings"}};export{m as planViteRemoteBindings,R as remoteBindingsPlugin,P as withRemoteBindings};
|