@lunora/vite 1.0.0-alpha.19 → 1.0.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/dist/index.d.mts +41 -1
- package/dist/index.d.ts +41 -1
- package/dist/index.mjs +17 -11
- package/dist/packem_shared/lunoraSolutionFinder-BKEAiUJP.mjs +17 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -80,6 +80,21 @@ lunora({
|
|
|
80
80
|
|
|
81
81
|
`lunora()` returns a flat `Plugin[]`; Vite flattens nested plugin arrays, so `plugins: [lunora()]` works without spreading.
|
|
82
82
|
|
|
83
|
+
### Error overlay
|
|
84
|
+
|
|
85
|
+
The overlay surfaces dev-time failures in the browser. Lunora ships **solution finders** that turn the common ones — missing/invalid `defineSchema`, reserved or duplicate table names, a bad `.jurisdiction(...)`, a non-literal `unique`, a binding that isn't re-exported by your worker entry, and runtime unique-constraint / optimistic-concurrency conflicts — into an actionable fix hint right in the overlay.
|
|
86
|
+
|
|
87
|
+
`overlay` also accepts an options object forwarded to [`@visulima/vite-overlay`](https://www.npmjs.com/package/@visulima/vite-overlay), so you can add your own finders alongside Lunora's:
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
lunora({
|
|
91
|
+
overlay: {
|
|
92
|
+
// your finders run alongside Lunora's; either side can win per error via `priority`
|
|
93
|
+
solutionFinders: [myCustomFinder],
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
```
|
|
97
|
+
|
|
83
98
|
> This README covers the basics. For the full API, options, and guides, see the **[documentation](https://lunora.sh/docs/packages/vite)**.
|
|
84
99
|
|
|
85
100
|
## Related
|
package/dist/index.d.mts
CHANGED
|
@@ -305,6 +305,35 @@ declare const withRemoteBindings: (options: CloudflarePluginOptions, isServe: ()
|
|
|
305
305
|
* the build/close path). Idempotent cleanup means firing on both is safe.
|
|
306
306
|
*/
|
|
307
307
|
declare const remoteBindingsCleanupPlugin: (cleanup: () => void) => Plugin;
|
|
308
|
+
/**
|
|
309
|
+
* A `@visulima/vite-overlay` solution finder. Derived from the overlay's own
|
|
310
|
+
* options type so the shape can't drift from the installed package. The overlay
|
|
311
|
+
* runs every finder it's given (custom finders first, then its built-ins),
|
|
312
|
+
* sorted by `priority` descending, and shows the first non-`undefined` result.
|
|
313
|
+
*
|
|
314
|
+
* Note: this type (and {@link Solution}) is re-exported from `@lunora/vite` and
|
|
315
|
+
* intentionally tracks the installed `@visulima/vite-overlay` — if a future
|
|
316
|
+
* overlay release changes the finder contract, that surfaces here as a compile
|
|
317
|
+
* error rather than a silent drift.
|
|
318
|
+
*/
|
|
319
|
+
type SolutionFinder = NonNullable<OverlayPluginOptions["solutionFinders"]>[number];
|
|
320
|
+
/** What a finder may return: a Markdown-rendered `{ header?, body }`, or `undefined` to defer. */
|
|
321
|
+
type Solution = NonNullable<Awaited<ReturnType<SolutionFinder["handle"]>>>;
|
|
322
|
+
/**
|
|
323
|
+
* Lunora's solution finder for the dev error overlay. A single finder that
|
|
324
|
+
* delegates to `@lunora/codegen`'s shared rule table (the same table the
|
|
325
|
+
* standalone `lunora dev` CLI prints to the terminal) and returns the first
|
|
326
|
+
* match — so one `priority` slot covers every Lunora rule and the overlay's
|
|
327
|
+
* built-in finders still run for anything we don't recognize (we return
|
|
328
|
+
* `undefined`).
|
|
329
|
+
*
|
|
330
|
+
* Priority is high so a Lunora-specific hint wins over the overlay's generic
|
|
331
|
+
* finder for the same error; a user's own finder can still outrank it with a
|
|
332
|
+
* higher `priority`.
|
|
333
|
+
*/
|
|
334
|
+
declare const lunoraSolutionFinder: SolutionFinder;
|
|
335
|
+
/** The finders Lunora injects into the overlay by default. */
|
|
336
|
+
declare const lunoraSolutionFinders: ReadonlyArray<SolutionFinder>;
|
|
308
337
|
/** Dev-server path the studio SPA is served from. */
|
|
309
338
|
declare const STUDIO_PATH = "/__lunora";
|
|
310
339
|
/** Static asset routes the studio document references. */
|
|
@@ -382,6 +411,17 @@ declare const withWorkerStartupHint: (plugins: ReadonlyArray<Plugin>) => Plugin[
|
|
|
382
411
|
*/
|
|
383
412
|
declare const wranglerValidatorPlugin: (options: ResolvedLunoraPluginOptions) => Plugin;
|
|
384
413
|
/**
|
|
414
|
+
* Resolve the `overlay` toggle into the overlay plugin's options — or `false` to
|
|
415
|
+
* skip it. Lunora's solution finders are **prepended** so they run before the
|
|
416
|
+
* overlay's built-ins; a user's own finders are appended and can still win per
|
|
417
|
+
* error via a strictly higher `priority` (equal priority keeps Lunora first,
|
|
418
|
+
* since the overlay sorts stably). Lunora also forwards both `error` AND `warn`
|
|
419
|
+
* console calls by default (the overlay's own default is `["error"]` only) so
|
|
420
|
+
* Lunora's branded `warn` advisories surface in the browser too — the user can
|
|
421
|
+
* override `forwardedConsoleMethods`.
|
|
422
|
+
*/
|
|
423
|
+
declare const resolveOverlayOption: (overlay: LunoraPluginOptions["overlay"]) => false | OverlayPluginOptions;
|
|
424
|
+
/**
|
|
385
425
|
* Lunora Vite plugin. Returns a flat array of Vite plugins that:
|
|
386
426
|
*
|
|
387
427
|
* 1. Run `@lunora/codegen` on startup + on schema file changes.
|
|
@@ -395,4 +435,4 @@ declare const wranglerValidatorPlugin: (options: ResolvedLunoraPluginOptions) =>
|
|
|
395
435
|
*/
|
|
396
436
|
declare const lunora: (options?: LunoraPluginOptions) => LunoraPlugins;
|
|
397
437
|
declare const VERSION = "0.0.0";
|
|
398
|
-
export { CLASS_A_WIRING, type ClassAWiring, type CloudflarePluginOptions, DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR, LUNORA_WORKER_VIRTUAL_ID, type LunoraPluginOptions, type LunoraPlugins, type OverlayPluginOptions, type PlanViteRemoteOptions, type ReconcileResult, type ResolvedLunoraPluginOptions, STUDIO_PATH, VERSION, type ViteRemotePlan, WORKER_STARTUP_HINT, augmentWorkerStartupError, buildStudioUrl, buildWorkerEntrySource, codegenPlugin, containerLogsPlugin, createCommandProbe, devVariablesPlugin, frameworkComposePlugin, isAutoComposable, isWorkerEntryEvalError, logStreamPlugin, lunora, planViteRemoteBindings, reconcileWranglerCrons, remoteBindingsCleanupPlugin, studioPlugin, withDevWorkerEnv, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
|
|
438
|
+
export { CLASS_A_WIRING, type ClassAWiring, type CloudflarePluginOptions, DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR, LUNORA_WORKER_VIRTUAL_ID, type LunoraPluginOptions, type LunoraPlugins, type OverlayPluginOptions, type PlanViteRemoteOptions, type ReconcileResult, type ResolvedLunoraPluginOptions, STUDIO_PATH, type Solution, type SolutionFinder, VERSION, type ViteRemotePlan, WORKER_STARTUP_HINT, augmentWorkerStartupError, buildStudioUrl, buildWorkerEntrySource, codegenPlugin, containerLogsPlugin, createCommandProbe, devVariablesPlugin, frameworkComposePlugin, isAutoComposable, isWorkerEntryEvalError, logStreamPlugin, lunora, lunoraSolutionFinder, lunoraSolutionFinders, planViteRemoteBindings, reconcileWranglerCrons, remoteBindingsCleanupPlugin, resolveOverlayOption, studioPlugin, withDevWorkerEnv, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
|
package/dist/index.d.ts
CHANGED
|
@@ -305,6 +305,35 @@ declare const withRemoteBindings: (options: CloudflarePluginOptions, isServe: ()
|
|
|
305
305
|
* the build/close path). Idempotent cleanup means firing on both is safe.
|
|
306
306
|
*/
|
|
307
307
|
declare const remoteBindingsCleanupPlugin: (cleanup: () => void) => Plugin;
|
|
308
|
+
/**
|
|
309
|
+
* A `@visulima/vite-overlay` solution finder. Derived from the overlay's own
|
|
310
|
+
* options type so the shape can't drift from the installed package. The overlay
|
|
311
|
+
* runs every finder it's given (custom finders first, then its built-ins),
|
|
312
|
+
* sorted by `priority` descending, and shows the first non-`undefined` result.
|
|
313
|
+
*
|
|
314
|
+
* Note: this type (and {@link Solution}) is re-exported from `@lunora/vite` and
|
|
315
|
+
* intentionally tracks the installed `@visulima/vite-overlay` — if a future
|
|
316
|
+
* overlay release changes the finder contract, that surfaces here as a compile
|
|
317
|
+
* error rather than a silent drift.
|
|
318
|
+
*/
|
|
319
|
+
type SolutionFinder = NonNullable<OverlayPluginOptions["solutionFinders"]>[number];
|
|
320
|
+
/** What a finder may return: a Markdown-rendered `{ header?, body }`, or `undefined` to defer. */
|
|
321
|
+
type Solution = NonNullable<Awaited<ReturnType<SolutionFinder["handle"]>>>;
|
|
322
|
+
/**
|
|
323
|
+
* Lunora's solution finder for the dev error overlay. A single finder that
|
|
324
|
+
* delegates to `@lunora/codegen`'s shared rule table (the same table the
|
|
325
|
+
* standalone `lunora dev` CLI prints to the terminal) and returns the first
|
|
326
|
+
* match — so one `priority` slot covers every Lunora rule and the overlay's
|
|
327
|
+
* built-in finders still run for anything we don't recognize (we return
|
|
328
|
+
* `undefined`).
|
|
329
|
+
*
|
|
330
|
+
* Priority is high so a Lunora-specific hint wins over the overlay's generic
|
|
331
|
+
* finder for the same error; a user's own finder can still outrank it with a
|
|
332
|
+
* higher `priority`.
|
|
333
|
+
*/
|
|
334
|
+
declare const lunoraSolutionFinder: SolutionFinder;
|
|
335
|
+
/** The finders Lunora injects into the overlay by default. */
|
|
336
|
+
declare const lunoraSolutionFinders: ReadonlyArray<SolutionFinder>;
|
|
308
337
|
/** Dev-server path the studio SPA is served from. */
|
|
309
338
|
declare const STUDIO_PATH = "/__lunora";
|
|
310
339
|
/** Static asset routes the studio document references. */
|
|
@@ -382,6 +411,17 @@ declare const withWorkerStartupHint: (plugins: ReadonlyArray<Plugin>) => Plugin[
|
|
|
382
411
|
*/
|
|
383
412
|
declare const wranglerValidatorPlugin: (options: ResolvedLunoraPluginOptions) => Plugin;
|
|
384
413
|
/**
|
|
414
|
+
* Resolve the `overlay` toggle into the overlay plugin's options — or `false` to
|
|
415
|
+
* skip it. Lunora's solution finders are **prepended** so they run before the
|
|
416
|
+
* overlay's built-ins; a user's own finders are appended and can still win per
|
|
417
|
+
* error via a strictly higher `priority` (equal priority keeps Lunora first,
|
|
418
|
+
* since the overlay sorts stably). Lunora also forwards both `error` AND `warn`
|
|
419
|
+
* console calls by default (the overlay's own default is `["error"]` only) so
|
|
420
|
+
* Lunora's branded `warn` advisories surface in the browser too — the user can
|
|
421
|
+
* override `forwardedConsoleMethods`.
|
|
422
|
+
*/
|
|
423
|
+
declare const resolveOverlayOption: (overlay: LunoraPluginOptions["overlay"]) => false | OverlayPluginOptions;
|
|
424
|
+
/**
|
|
385
425
|
* Lunora Vite plugin. Returns a flat array of Vite plugins that:
|
|
386
426
|
*
|
|
387
427
|
* 1. Run `@lunora/codegen` on startup + on schema file changes.
|
|
@@ -395,4 +435,4 @@ declare const wranglerValidatorPlugin: (options: ResolvedLunoraPluginOptions) =>
|
|
|
395
435
|
*/
|
|
396
436
|
declare const lunora: (options?: LunoraPluginOptions) => LunoraPlugins;
|
|
397
437
|
declare const VERSION = "0.0.0";
|
|
398
|
-
export { CLASS_A_WIRING, type ClassAWiring, type CloudflarePluginOptions, DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR, LUNORA_WORKER_VIRTUAL_ID, type LunoraPluginOptions, type LunoraPlugins, type OverlayPluginOptions, type PlanViteRemoteOptions, type ReconcileResult, type ResolvedLunoraPluginOptions, STUDIO_PATH, VERSION, type ViteRemotePlan, WORKER_STARTUP_HINT, augmentWorkerStartupError, buildStudioUrl, buildWorkerEntrySource, codegenPlugin, containerLogsPlugin, createCommandProbe, devVariablesPlugin, frameworkComposePlugin, isAutoComposable, isWorkerEntryEvalError, logStreamPlugin, lunora, planViteRemoteBindings, reconcileWranglerCrons, remoteBindingsCleanupPlugin, studioPlugin, withDevWorkerEnv, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
|
|
438
|
+
export { CLASS_A_WIRING, type ClassAWiring, type CloudflarePluginOptions, DEV_WORKER_ENV_VALUE, DEV_WORKER_ENV_VAR, LUNORA_WORKER_VIRTUAL_ID, type LunoraPluginOptions, type LunoraPlugins, type OverlayPluginOptions, type PlanViteRemoteOptions, type ReconcileResult, type ResolvedLunoraPluginOptions, STUDIO_PATH, type Solution, type SolutionFinder, VERSION, type ViteRemotePlan, WORKER_STARTUP_HINT, augmentWorkerStartupError, buildStudioUrl, buildWorkerEntrySource, codegenPlugin, containerLogsPlugin, createCommandProbe, devVariablesPlugin, frameworkComposePlugin, isAutoComposable, isWorkerEntryEvalError, logStreamPlugin, lunora, lunoraSolutionFinder, lunoraSolutionFinders, planViteRemoteBindings, reconcileWranglerCrons, remoteBindingsCleanupPlugin, resolveOverlayOption, studioPlugin, withDevWorkerEnv, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
|
package/dist/index.mjs
CHANGED
|
@@ -12,6 +12,8 @@ import { frameworkComposePlugin } from './packem_shared/CLASS_A_WIRING-DpX_WcOK.
|
|
|
12
12
|
export { CLASS_A_WIRING, LUNORA_WORKER_VIRTUAL_ID, buildWorkerEntrySource, isAutoComposable } from './packem_shared/CLASS_A_WIRING-DpX_WcOK.mjs';
|
|
13
13
|
import logStreamPlugin from './packem_shared/logStreamPlugin-CqvZ17kd.mjs';
|
|
14
14
|
import { planViteRemoteBindings, remoteBindingsCleanupPlugin, withRemoteBindings } from './packem_shared/planViteRemoteBindings-QN5ncUS1.mjs';
|
|
15
|
+
import { lunoraSolutionFinders } from './packem_shared/lunoraSolutionFinder-BKEAiUJP.mjs';
|
|
16
|
+
export { lunoraSolutionFinder } from './packem_shared/lunoraSolutionFinder-BKEAiUJP.mjs';
|
|
15
17
|
import { studioPlugin } from './packem_shared/STUDIO_PATH-5ppCdBHa.mjs';
|
|
16
18
|
export { STUDIO_PATH, buildStudioUrl } from './packem_shared/STUDIO_PATH-5ppCdBHa.mjs';
|
|
17
19
|
import { withWorkerStartupHint } from './packem_shared/WORKER_STARTUP_HINT-DhsXUW8k.mjs';
|
|
@@ -82,6 +84,19 @@ const frameworkDetectPlugin = (options, context) => {
|
|
|
82
84
|
};
|
|
83
85
|
};
|
|
84
86
|
|
|
87
|
+
const resolveOverlayOption = (overlay) => {
|
|
88
|
+
if (overlay === false) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
const userOverlay = overlay === true || overlay === void 0 ? {} : overlay;
|
|
92
|
+
return {
|
|
93
|
+
...userOverlay,
|
|
94
|
+
// After the spread + nullish-coalesce so an explicit `undefined` from the
|
|
95
|
+
// user doesn't erase Lunora's default (the spread would otherwise win).
|
|
96
|
+
forwardedConsoleMethods: userOverlay.forwardedConsoleMethods ?? ["error", "warn"],
|
|
97
|
+
solutionFinders: [...lunoraSolutionFinders, ...userOverlay.solutionFinders ?? []]
|
|
98
|
+
};
|
|
99
|
+
};
|
|
85
100
|
const resolveOptions = (options) => {
|
|
86
101
|
const input = options ?? {};
|
|
87
102
|
const schemaDirectory = input.schemaDir ?? "lunora";
|
|
@@ -93,21 +108,12 @@ const resolveOptions = (options) => {
|
|
|
93
108
|
} else {
|
|
94
109
|
cloudflareOption = input.cloudflare;
|
|
95
110
|
}
|
|
96
|
-
const overlayDefaults = { forwardedConsoleMethods: ["error", "warn"] };
|
|
97
|
-
let overlayOption;
|
|
98
|
-
if (input.overlay === false) {
|
|
99
|
-
overlayOption = false;
|
|
100
|
-
} else if (input.overlay === true || input.overlay === void 0) {
|
|
101
|
-
overlayOption = { ...overlayDefaults };
|
|
102
|
-
} else {
|
|
103
|
-
overlayOption = { ...overlayDefaults, ...input.overlay };
|
|
104
|
-
}
|
|
105
111
|
return {
|
|
106
112
|
apiSpec: input.apiSpec ?? "openapi",
|
|
107
113
|
cloudflare: cloudflareOption,
|
|
108
114
|
studio: input.studio ?? true,
|
|
109
115
|
generatedDir: input.generatedDir ?? `${schemaDirectory}/_generated`,
|
|
110
|
-
overlay:
|
|
116
|
+
overlay: resolveOverlayOption(input.overlay),
|
|
111
117
|
projectRoot: input.projectRoot ?? process.cwd(),
|
|
112
118
|
schemaDir: schemaDirectory,
|
|
113
119
|
validateWrangler: input.validateWrangler ?? true
|
|
@@ -154,4 +160,4 @@ const lunora = (options) => {
|
|
|
154
160
|
};
|
|
155
161
|
const VERSION = "0.0.0";
|
|
156
162
|
|
|
157
|
-
export { VERSION, codegenPlugin, containerLogsPlugin, createCommandProbe, devVariablesPlugin, frameworkComposePlugin, logStreamPlugin, lunora, planViteRemoteBindings, remoteBindingsCleanupPlugin, studioPlugin, withDevWorkerEnv, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
|
|
163
|
+
export { VERSION, codegenPlugin, containerLogsPlugin, createCommandProbe, devVariablesPlugin, frameworkComposePlugin, logStreamPlugin, lunora, lunoraSolutionFinders, planViteRemoteBindings, remoteBindingsCleanupPlugin, resolveOverlayOption, studioPlugin, withDevWorkerEnv, withRemoteBindings, withWorkerStartupHint, wranglerValidatorPlugin };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { findLunoraSolution } from '@lunora/codegen';
|
|
2
|
+
|
|
3
|
+
const lunoraSolutionFinder = {
|
|
4
|
+
// Synchronous body wrapped in `Promise.resolve` rather than `async`: the
|
|
5
|
+
// overlay's `handle` contract is promise-returning, but `require-await` is on
|
|
6
|
+
// for src and there's nothing to await here.
|
|
7
|
+
handle: (error) => {
|
|
8
|
+
const message = typeof error.message === "string" ? error.message : "";
|
|
9
|
+
const solution = findLunoraSolution(message);
|
|
10
|
+
return Promise.resolve(solution ? { body: solution.body, header: solution.header } : void 0);
|
|
11
|
+
},
|
|
12
|
+
name: "lunora",
|
|
13
|
+
priority: 100
|
|
14
|
+
};
|
|
15
|
+
const lunoraSolutionFinders = [lunoraSolutionFinder];
|
|
16
|
+
|
|
17
|
+
export { lunoraSolutionFinder, lunoraSolutionFinders };
|
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.20",
|
|
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.42.0",
|
|
49
|
-
"@lunora/codegen": "1.0.0-alpha.
|
|
50
|
-
"@lunora/config": "1.0.0-alpha.
|
|
49
|
+
"@lunora/codegen": "1.0.0-alpha.13",
|
|
50
|
+
"@lunora/config": "1.0.0-alpha.20",
|
|
51
51
|
"@visulima/vite-overlay": "2.0.0-alpha.35",
|
|
52
52
|
"jsonc-parser": "^3.3.1",
|
|
53
53
|
"ts-morph": "^28.0.0"
|