env-runner 0.2.1 → 0.2.3

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.
@@ -1,6 +1,6 @@
1
1
  import { RuntimeDep } from "../../_chunks/common-runtime-deps.mjs";
2
2
  /** Metadata passed alongside each delivered message (`MessageMetadata`). */
3
- interface VercelQueueMessageMetadata {
3
+ export interface VercelQueueMessageMetadata {
4
4
  messageId: string;
5
5
  deliveryCount: number;
6
6
  createdAt: Date;
@@ -11,21 +11,17 @@ interface VercelQueueMessageMetadata {
11
11
  region: string;
12
12
  }
13
13
  /** Instruction returned by a retry handler when the message handler throws. */
14
- type VercelQueueRetryDirective = {
14
+ export type VercelQueueRetryDirective = {
15
15
  afterSeconds: number;
16
16
  } | {
17
17
  acknowledge: true;
18
18
  };
19
19
  /** Function invoked with each delivered message (`MessageHandler`). */
20
- type VercelQueueMessageHandler<T = unknown> = (message: T, metadata: VercelQueueMessageMetadata) => Promise<void> | void;
20
+ export type VercelQueueMessageHandler<T = unknown> = (message: T, metadata: VercelQueueMessageMetadata) => Promise<void> | void;
21
21
  /** Called when the message handler throws (`RetryHandler`). */
22
- type VercelQueueRetryHandler = (error: unknown, metadata: VercelQueueMessageMetadata) => VercelQueueRetryDirective | void | undefined;
23
- /**
24
- * The `@vercel/queue` package, as imported by the consumer
25
- * (`import * as queue from "@vercel/queue"`). Structurally typed so the real
26
- * module namespace is assignable without env-runner depending on the package.
27
- */
28
- interface VercelQueueSdk {
22
+ export type VercelQueueRetryHandler = (error: unknown, metadata: VercelQueueMessageMetadata) => VercelQueueRetryDirective | void | undefined;
23
+ /** `@vercel/queue` namespace, structurally typed to avoid depending on the package. */
24
+ export interface VercelQueueSdk {
29
25
  QueueClient: new (options?: any) => any;
30
26
  registerDevConsumer?: (options: {
31
27
  topic: string;
@@ -37,22 +33,10 @@ interface VercelQueueSdk {
37
33
  }) => () => void;
38
34
  [key: string]: unknown;
39
35
  }
40
- interface VercelQueueDevConsumer {
36
+ export interface VercelQueueDevConsumer {
41
37
  /**
42
- * The `@vercel/queue` package: the imported module, or a specifier for it.
43
- *
44
- * ```ts
45
- * import * as sdk from "@vercel/queue";
46
- * await registerVercelQueueConsumer({ sdk, topic: "orders", handler });
47
- *
48
- * // or, equivalently
49
- * await registerVercelQueueConsumer({ sdk: "@vercel/queue", topic, handler });
50
- * ```
51
- *
52
- * Passing it explicitly is preferred (`@vercel/queue` is not a dependency of
53
- * `env-runner`). Bare specifiers resolve from the current working directory.
54
- * When omitted, `@vercel/queue` is imported optionally and registration
55
- * becomes a no-op if the package isn't installed.
38
+ * The `@vercel/queue` package (`import * as sdk from "@vercel/queue"`) or a
39
+ * specifier resolved from cwd. Omitted: imported optionally.
56
40
  */
57
41
  sdk?: RuntimeDep<VercelQueueSdk>;
58
42
  /** Topic name. Wildcard patterns (e.g. `"user-*"`) are supported. */
@@ -60,40 +44,19 @@ interface VercelQueueDevConsumer {
60
44
  /** Function invoked with each delivered message. */
61
45
  handler: VercelQueueMessageHandler;
62
46
  /**
63
- * Logical consumer identifier. Re-registering with the same group on the same
64
- * topic replaces the previous handler (HMR-safe). Use distinct groups to fan
65
- * a topic out to multiple coexisting handlers.
66
- *
47
+ * Same group + topic replaces the handler; distinct groups coexist.
67
48
  * @default "env-runner-vercel-dev"
68
49
  */
69
50
  consumerGroup?: string;
70
- /**
71
- * Lock duration for in-flight messages. Forwarded to the SDK's
72
- * `coreHandleCallback`.
73
- */
51
+ /** Lock duration for in-flight messages (SDK `coreHandleCallback`). */
74
52
  visibilityTimeoutSeconds?: number;
75
- /**
76
- * Convenience: rescheduled re-delivery delay applied when the handler throws.
77
- * Equivalent to `retry: () => ({ afterSeconds })`. Ignored if `retry` is set.
78
- */
53
+ /** Re-delivery delay when the handler throws; shorthand for `retry` (which wins). */
79
54
  retryAfterSeconds?: number;
80
- /**
81
- * Full retry handler. Receives the thrown error and message metadata; return
82
- * `{ afterSeconds }` to reschedule, `{ acknowledge: true }` to drop, or
83
- * `undefined` to let the error propagate.
84
- */
55
+ /** Return `{ afterSeconds }` to reschedule, `{ acknowledge: true }` to drop, or `undefined` to rethrow. */
85
56
  retry?: VercelQueueRetryHandler;
86
57
  }
87
58
  /**
88
- * Bind a handler to a topic. Resolves to an unregister function.
89
- *
90
- * A shared `QueueClient` is constructed from `sdk` on first use and reused for
91
- * later registrations with the same SDK. Re-registering with the same topic
92
- * replaces the handler (HMR-safe; the SDK keys consumers by `consumerGroup`,
93
- * so calling unregister on a replaced registration is a no-op).
94
- *
95
- * If no SDK is available, or it does not expose `registerDevConsumer`,
96
- * resolves to a no-op unregister and logs a one-time warning.
59
+ * Bind a handler to a topic; resolves to an unregister function (a no-op once
60
+ * replaced). Without a usable SDK, warns once and no-ops.
97
61
  */
98
- declare function registerVercelQueueConsumer(consumer: VercelQueueDevConsumer): Promise<() => void>;
99
- export { VercelQueueDevConsumer, VercelQueueMessageHandler, VercelQueueMessageMetadata, VercelQueueRetryDirective, VercelQueueRetryHandler, VercelQueueSdk, registerVercelQueueConsumer };
62
+ export declare function registerVercelQueueConsumer(consumer: VercelQueueDevConsumer): Promise<() => void>;
package/dist/vite.d.mts CHANGED
@@ -1,29 +1,18 @@
1
1
  import { RunnerRPCHooks } from "./_chunks/types.mjs";
2
2
  /** Vite HotChannel-compatible interface (avoids hard dependency on vite types). */
3
- interface ViteHotChannel {
3
+ export interface ViteHotChannel {
4
4
  send: (data: any) => void;
5
5
  on: (event: string, handler: (...args: any[]) => void) => void;
6
6
  off: (event: string, handler: (...args: any[]) => void) => void;
7
7
  }
8
8
  /** Vite ModuleRunner transport-compatible interface. */
9
- interface ViteTransport {
9
+ export interface ViteTransport {
10
10
  connect: (handlers: {
11
11
  onMessage: (payload: any) => void;
12
12
  }) => void;
13
13
  send: (payload: any) => void;
14
14
  }
15
- /**
16
- * Create a Vite `HotChannel` from an env-runner's RPC hooks.
17
- *
18
- * Use on the **host side** to bridge env-runner IPC → Vite's DevEnvironment transport.
19
- * Messages are namespaced by `envName` so multiple Vite environments can share one runner.
20
- */
21
- declare function createViteHotChannel(hooks: RunnerRPCHooks, envName: string): ViteHotChannel;
22
- /**
23
- * Create a Vite `ModuleRunner` transport from worker-side IPC primitives.
24
- *
25
- * Use on the **worker side** to bridge worker IPC → Vite's `ModuleRunner` transport.
26
- * Filters messages by `envName` so multiple Vite environments can share one IPC channel.
27
- */
28
- declare function createViteTransport(sendMessage: (data: any) => void, onMessage: (listener: (value: any) => void) => void, envName: string): ViteTransport;
29
- export { ViteHotChannel, ViteTransport, createViteHotChannel, createViteTransport };
15
+ /** Host-side Vite `HotChannel`, namespaced by `envName` so environments can share a runner. */
16
+ export declare function createViteHotChannel(hooks: RunnerRPCHooks, envName: string): ViteHotChannel;
17
+ /** Worker-side Vite `ModuleRunner` transport, filtered by `envName` to share one IPC channel. */
18
+ export declare function createViteTransport(sendMessage: (data: any) => void, onMessage: (listener: (value: any) => void) => void, envName: string): ViteTransport;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "env-runner",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Generic environment runner for JavaScript runtimes.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,25 +38,25 @@
38
38
  "crossws": "^0.4.12",
39
39
  "exsolve": "^1.1.1",
40
40
  "httpxy": "^0.5.5",
41
- "srvx": "^1.0.0"
41
+ "srvx": "^1.0.5"
42
42
  },
43
43
  "devDependencies": {
44
- "@netlify/runtime": "^5.0.2",
45
- "@types/node": "^26.4.0",
44
+ "@netlify/runtime": "^5.0.3",
45
+ "@types/node": "^26.5.1",
46
46
  "@vercel/queue": "^0.5.1",
47
- "@vitest/coverage-v8": "^4.1.11",
47
+ "@vitest/coverage-v8": "^5.0.0",
48
48
  "automd": "^0.4.3",
49
49
  "changelogen": "^0.6.2",
50
50
  "cjs-module-lexer": "^2.2.1",
51
51
  "env-runner-fixture": "link:",
52
- "es-module-lexer": "^2.3.2",
52
+ "es-module-lexer": "^3.0.2",
53
53
  "miniflare": "^4.20260730.0",
54
- "obuild": "^0.4.38",
55
- "oxfmt": "^0.65.0",
56
- "oxlint": "^1.80.0",
54
+ "obuild": "^0.4.39",
55
+ "oxfmt": ">=0.67.0",
56
+ "oxlint": "^1.82.0",
57
57
  "typescript": "^7.0.2",
58
- "vitest": "^4.1.11",
59
- "wrangler": "^4.127.1"
58
+ "vitest": "^5.0.0",
59
+ "wrangler": "^4.131.0"
60
60
  },
61
61
  "scripts": {
62
62
  "build": "obuild",