@venizia/ignis-worker 0.4.8-0 → 0.4.8-2
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/esm/applications/common/types.d.ts +5 -1
- package/dist/esm/applications/common/types.js.map +1 -1
- package/dist/esm/envelope/common/types.d.ts +2 -0
- package/dist/esm/envelope/common/types.js.map +1 -1
- package/dist/esm/transport/common/types.d.ts +1 -0
- package/dist/esm/transport/common/types.js.map +1 -1
- package/dist/esm/transport/fetch-bridge.d.ts +2 -1
- package/dist/esm/transport/fetch-bridge.js.map +1 -1
- package/dist/esm/transport/shared/common/types.d.ts +2 -0
- package/dist/esm/transport/shared/common/types.js.map +1 -1
- package/package.json +5 -5
|
@@ -4,7 +4,11 @@ import type { IApplicationConfigs } from '@venizia/ignis-kernel';
|
|
|
4
4
|
* interface on purpose - `@venizia/ignis`'s `IServerApplicationConfigs` is the one with a socket.
|
|
5
5
|
*/
|
|
6
6
|
export interface IWorkerApplicationConfigs extends IApplicationConfigs {
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Bound as `CoreBindings.APPLICATION_PROJECT_ROOT` when `getProjectRoot()` resolves it, and shared with `ModuleUtility`.
|
|
9
|
+
*
|
|
10
|
+
* @default the host's working directory (`process.cwd()`) when one exists, else `''`
|
|
11
|
+
*/
|
|
8
12
|
projectRoot?: string;
|
|
9
13
|
}
|
|
10
14
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/applications/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { IApplicationConfigs } from '@venizia/ignis-kernel';\n\n/**\n * What a Web Worker host configures on top of the kernel's shape. `host`/`port` stay off this\n * interface on purpose - `@venizia/ignis`'s `IServerApplicationConfigs` is the one with a socket.\n */\nexport interface IWorkerApplicationConfigs extends IApplicationConfigs {\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/applications/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { IApplicationConfigs } from '@venizia/ignis-kernel';\n\n/**\n * What a Web Worker host configures on top of the kernel's shape. `host`/`port` stay off this\n * interface on purpose - `@venizia/ignis`'s `IServerApplicationConfigs` is the one with a socket.\n */\nexport interface IWorkerApplicationConfigs extends IApplicationConfigs {\n /**\n * Bound as `CoreBindings.APPLICATION_PROJECT_ROOT` when `getProjectRoot()` resolves it, and shared with `ModuleUtility`.\n *\n * @default the host's working directory (`process.cwd()`) when one exists, else `''`\n */\n projectRoot?: string;\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Headers are carried as tuples: a `Headers` instance is not structured-cloneable. */
|
|
2
2
|
export type TEnvelopeHeaders = Array<[string, string]>;
|
|
3
|
+
/** A request as it crosses between tabs and the worker: the plain, structured-cloneable parts of a `Request`, matched to its response by `id`. */
|
|
3
4
|
export interface IBffRequestEnvelope {
|
|
4
5
|
id: string;
|
|
5
6
|
method: string;
|
|
@@ -8,6 +9,7 @@ export interface IBffRequestEnvelope {
|
|
|
8
9
|
/** Buffered, never a stream - `ReadableStream` does not transfer in Safari. */
|
|
9
10
|
body?: ArrayBuffer;
|
|
10
11
|
}
|
|
12
|
+
/** A response as it crosses between the worker and tabs, matched to its request by `id`. */
|
|
11
13
|
export interface IBffResponseEnvelope {
|
|
12
14
|
id: string;
|
|
13
15
|
status: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/envelope/common/types.ts"],"names":[],"mappings":"","sourcesContent":["/** Headers are carried as tuples: a `Headers` instance is not structured-cloneable. */\nexport type TEnvelopeHeaders = Array<[string, string]>;\n\nexport interface IBffRequestEnvelope {\n id: string;\n method: string;\n url: string;\n headers: TEnvelopeHeaders;\n /** Buffered, never a stream - `ReadableStream` does not transfer in Safari. */\n body?: ArrayBuffer;\n}\n\nexport interface IBffResponseEnvelope {\n id: string;\n status: number;\n statusText?: string;\n headers: TEnvelopeHeaders;\n body?: ArrayBuffer;\n}\n\n/**\n * A custom `Error` subclass loses its name, its own properties and its prototype through structured\n * clone, so an `ApplicationError` cannot cross as itself. It crosses as its normalised shape and is\n * rebuilt with `fromError` on the far side.\n */\nexport interface IBffErrorEnvelope {\n id: string;\n /**\n * Carried explicitly, because `fromError` defaults a missing one to 400. This envelope is only\n * ever produced when something escaped Hono's `onError` - the 500-class failures a UI must not\n * classify as its own bad request.\n */\n statusCode: number;\n error: { text: string; code?: string; args?: unknown };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/envelope/common/types.ts"],"names":[],"mappings":"","sourcesContent":["/** Headers are carried as tuples: a `Headers` instance is not structured-cloneable. */\nexport type TEnvelopeHeaders = Array<[string, string]>;\n\n/** A request as it crosses between tabs and the worker: the plain, structured-cloneable parts of a `Request`, matched to its response by `id`. */\nexport interface IBffRequestEnvelope {\n id: string;\n method: string;\n url: string;\n headers: TEnvelopeHeaders;\n /** Buffered, never a stream - `ReadableStream` does not transfer in Safari. */\n body?: ArrayBuffer;\n}\n\n/** A response as it crosses between the worker and tabs, matched to its request by `id`. */\nexport interface IBffResponseEnvelope {\n id: string;\n status: number;\n statusText?: string;\n headers: TEnvelopeHeaders;\n body?: ArrayBuffer;\n}\n\n/**\n * A custom `Error` subclass loses its name, its own properties and its prototype through structured\n * clone, so an `ApplicationError` cannot cross as itself. It crosses as its normalised shape and is\n * rebuilt with `fromError` on the far side.\n */\nexport interface IBffErrorEnvelope {\n id: string;\n /**\n * Carried explicitly, because `fromError` defaults a missing one to 400. This envelope is only\n * ever produced when something escaped Hono's `onError` - the 500-class failures a UI must not\n * classify as its own bad request.\n */\n statusCode: number;\n error: { text: string; code?: string; args?: unknown };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/transport/common/types.ts"],"names":[],"mappings":"","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/transport/common/types.ts"],"names":[],"mappings":"","sourcesContent":["/** The contract a BFF transport fulfils: turns a `Request` into a `Response`, wherever the server runs. */\nexport interface IBffTransport {\n fetch(opts: { request: Request }): Promise<Response>;\n}\n"]}
|
|
@@ -4,6 +4,7 @@ type TFetch = typeof globalThis.fetch;
|
|
|
4
4
|
interface IFetchCarrier {
|
|
5
5
|
fetch: TFetch;
|
|
6
6
|
}
|
|
7
|
+
/** Options for replacing `fetch` so matching requests go to a BFF transport. */
|
|
7
8
|
export interface IInstallBffFetchOptions {
|
|
8
9
|
/** Anything implementing the transport contract, so an in-process transport works in a test. */
|
|
9
10
|
transport: IBffTransport;
|
|
@@ -18,7 +19,7 @@ export interface IInstallBffFetchOptions {
|
|
|
18
19
|
* Unset, only the path decides, so a call to ANY origin under `basePath` is claimed.
|
|
19
20
|
*/
|
|
20
21
|
origin?: string | Array<string>;
|
|
21
|
-
/**
|
|
22
|
+
/** @default globalThis */
|
|
22
23
|
carrier?: IFetchCarrier;
|
|
23
24
|
}
|
|
24
25
|
/** Routes the page's own `fetch` into a BFF transport. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-bridge.js","sourceRoot":"","sources":["../../../src/transport/fetch-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"fetch-bridge.js","sourceRoot":"","sources":["../../../src/transport/fetch-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AA6BvD,0DAA0D;AAC1D,MAAM,OAAO,cAAc;IACzB;;;OAGG;aACqB,kBAAa,GAAG,MAAM,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;IAEtF;;;;;;;;;;;;;;;;;OAiBG;IACK,MAAM,CAAC,iBAAiB,CAAC,KAAwB;QAC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,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QAChE,CAAC,CAAC;QAEF,wFAAwF;QACxF,iGAAiG;QACjG,gFAAgF;QAChF,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,yBAAyB,CAAC,aAAa,CAAC,CAAC,CAAC;QAClF,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,cAAc,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAE9E,OAAO,CAAC,KAAK,GAAG,OAAiB,CAAC;QAElC,OAAO,GAAG,EAAE;YACV,IAAI,OAAO,CAAC,KAAK,KAAK,OAAO,EAAE,CAAC;gBAC9B,OAAO;YACT,CAAC;YAED,OAAO,CAAC,KAAK,GAAG,aAAa,CAAC;QAChC,CAAC,CAAC;IACJ,CAAC","sourcesContent":["import { getError } from '@venizia/ignis-helpers/core';\nimport type { IBffTransport } from './common/types';\n\ntype TFetch = typeof globalThis.fetch;\n\n/** The carrier whose `fetch` is replaced - `globalThis` in a page, an object a test controls otherwise. */\ninterface IFetchCarrier {\n fetch: TFetch;\n}\n\n/** Options for replacing `fetch` so matching requests go to a BFF transport. */\nexport interface IInstallBffFetchOptions {\n /** Anything implementing the transport contract, so an in-process transport works in a test. */\n transport: IBffTransport;\n /**\n * Path prefixes the BFF owns, matched on a segment boundary: `/api` claims `/api` and `/api/...`,\n * never `/apix`. Everything else is passed to the original `fetch` untouched.\n */\n basePath: string | Array<string>;\n /**\n * The origin, or origins, the BFF answers for - the page's own, or an upstream gateway whose\n * calls the BFF stands in for. A request to any other origin goes to the network whatever its path.\n * Unset, only the path decides, so a call to ANY origin under `basePath` is claimed.\n */\n origin?: string | Array<string>;\n /** @default globalThis */\n carrier?: IFetchCarrier;\n}\n\n/** Routes the page's own `fetch` into a BFF transport. */\nexport class BffFetchBridge {\n /**\n * Marks the patched `fetch` so a second install is refused rather than silently stacking. `Symbol.for`\n * and not a private symbol: two copies of this package in one page must still see each other's mark.\n */\n private static readonly BRIDGE_MARKER = Symbol.for('@venizia/ignis-worker/bff-fetch');\n\n /**\n * Resolves a request's absolute URL WITHOUT constructing a `Request`.\n *\n * This is the whole reason this helper exists rather than one obvious line. `new Request(input)`,\n * where `input` is a `Request` carrying a body, marks that body disturbed - so building one just to\n * read `.url` breaks the very pass-through it is deciding about: the next line hands the same, now\n * unreadable, request to the network.\n *\n * Measured, because the runtimes disagree. Chromium:\n *\n * original.bodyUsed // false\n * new Request(original)\n * original.bodyUsed // true\n * await original.text() // TypeError: body stream already read\n *\n * Bun does NOT disturb it, so the unit tests pass either way and cannot guard this. The browser is\n * where this code runs, so the browser is the behaviour to write for.\n */\n private static resolveRequestUrl(input: RequestInfo | URL): string {\n if (typeof input === 'string') {\n return new URL(input, globalThis.location?.href).href;\n }\n\n if (input instanceof URL) {\n return input.href;\n }\n\n return input.url;\n }\n\n private static toPrefixList(basePath: string | Array<string>): Array<string> {\n // Trailing slashes trimmed once, so the boundary test below is one comparison and one prefix check.\n const prefixes = (Array.isArray(basePath) ? basePath : [basePath])\n .map((prefix) => prefix.replace(/\\/+$/, ''))\n .filter((prefix) => prefix.length > 0);\n\n if (prefixes.length === 0) {\n throw getError({\n message:\n '[installBffFetch] Invalid basePath | At least one non-empty path prefix is required',\n });\n }\n\n return prefixes;\n }\n\n /**\n * Routes the page's own `fetch` into a BFF transport for anything under `basePath`, and leaves every\n * other call on the network untouched.\n *\n * This is the seam that lets an existing HTTP client talk to an in-browser IGNIS application without\n * knowing one exists. A data provider, an SDK or a generated client reaches the network through the\n * global `fetch` and usually accepts no custom fetcher, so answering that `fetch` is the only place\n * an in-browser backend becomes a drop-in swap rather than a fork of the client.\n *\n * Install it BEFORE the application that will use it boots: a request issued while the original\n * `fetch` is still in place leaves the page and 404s against whatever is serving it.\n *\n * @returns The uninstall function. It restores the previous `fetch` only if this bridge is still the\n * installed one - if something patched `fetch` afterwards, restoring would silently discard that.\n */\n static install(opts: IInstallBffFetchOptions): () => void {\n const { transport, basePath } = opts;\n const origins =\n opts.origin === undefined\n ? undefined\n : new Set(\n (Array.isArray(opts.origin) ? opts.origin : [opts.origin]).map(\n (value) => new URL(value).origin,\n ),\n );\n const carrier = opts.carrier ?? (globalThis as unknown as IFetchCarrier);\n\n const prefixes = BffFetchBridge.toPrefixList(basePath);\n const previousFetch = carrier.fetch;\n\n if (Object.getOwnPropertyDescriptor(previousFetch, BffFetchBridge.BRIDGE_MARKER)) {\n throw getError({\n message:\n '[installBffFetch] A BFF fetch bridge is already installed | Uninstall it first, or pass every prefix to a single install',\n });\n }\n\n const networkFetch = previousFetch.bind(carrier) as TFetch;\n\n const bridged = async (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {\n const url = new URL(BffFetchBridge.resolveRequestUrl(input));\n const { pathname } = url;\n const isOwnOrigin = origins === undefined || origins.has(url.origin);\n const isOwnPath = prefixes.some(\n (prefix) => pathname === prefix || pathname.startsWith(`${prefix}/`),\n );\n\n if (!isOwnOrigin || !isOwnPath) {\n return networkFetch(input, init);\n }\n\n // Constructed only now, on the branch that owns the request - so the pass-through above never\n // disturbs a body it is about to hand to the network.\n return transport.fetch({ request: new Request(input, init) });\n };\n\n // Whatever the runtime hung on `fetch` comes along - Bun puts `preconnect` there, and a\n // replacement that dropped it would break any caller reaching for it. Copying the descriptors is\n // also what makes this satisfy `typeof fetch` rather than merely resembling it.\n Object.defineProperties(bridged, Object.getOwnPropertyDescriptors(previousFetch));\n Object.defineProperty(bridged, BffFetchBridge.BRIDGE_MARKER, { value: true });\n\n carrier.fetch = bridged as TFetch;\n\n return () => {\n if (carrier.fetch !== bridged) {\n return;\n }\n\n carrier.fetch = previousFetch;\n };\n }\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { TConstValue } from '@venizia/ignis-helpers/common';
|
|
2
2
|
import type { IBffErrorEnvelope, IBffRequestEnvelope, IBffResponseEnvelope } from '../../../envelope/common/index.js';
|
|
3
3
|
import { type BffRoles, type ChannelMessageKinds } from './constants.js';
|
|
4
|
+
/** One of the `BffRoles` values: `electing`, `leader` or `follower`. */
|
|
4
5
|
export type TBffRole = TConstValue<typeof BffRoles>;
|
|
5
6
|
/**
|
|
6
7
|
* There is deliberately no "a new leader is ready" broadcast. A follower cannot act on one safely:
|
|
@@ -24,6 +25,7 @@ export interface IPendingRequest {
|
|
|
24
25
|
reject: (error: unknown) => void;
|
|
25
26
|
release: () => void;
|
|
26
27
|
}
|
|
28
|
+
/** Options for the transport that shares one worker across tabs through a leader election. */
|
|
27
29
|
export interface ISharedBffTransportOptions {
|
|
28
30
|
/** Builds the Worker. Called ONLY by whichever tab wins the election - the others never start one. */
|
|
29
31
|
createWorker: () => Worker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/transport/shared/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TConstValue } from '@venizia/ignis-helpers/common';\nimport type {\n IBffErrorEnvelope,\n IBffRequestEnvelope,\n IBffResponseEnvelope,\n} from '@/envelope/common';\nimport { type BffRoles, type ChannelMessageKinds } from './constants';\n\nexport type TBffRole = TConstValue<typeof BffRoles>;\n\n/**\n * There is deliberately no \"a new leader is ready\" broadcast. A follower cannot act on one safely:\n * BroadcastChannel does not order messages across senders, so a request posted around the moment of\n * promotion may well be answered by the new leader - and a follower that failed its in-flight\n * requests on hearing the announcement would turn some of those successes into errors. The request\n * timeout is the one honest answer for that window.\n */\nexport type TChannelMessage =\n | { kind: typeof ChannelMessageKinds.REQUEST; envelope: IBffRequestEnvelope }\n | { kind: typeof ChannelMessageKinds.RESPONSE; envelope: IBffResponseEnvelope }\n | { kind: typeof ChannelMessageKinds.ERROR; envelope: IBffErrorEnvelope };\n\nexport interface IPendingRequest {\n resolve: (response: Response) => void;\n reject: (error: unknown) => void;\n release: () => void;\n}\n\nexport interface ISharedBffTransportOptions {\n /** Builds the Worker. Called ONLY by whichever tab wins the election - the others never start one. */\n createWorker: () => Worker;\n /** Distinguishes independent BFFs on one origin. The lock name is derived from it. */\n channelName?: string;\n timeoutMs?: number;\n scope?: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/transport/shared/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TConstValue } from '@venizia/ignis-helpers/common';\nimport type {\n IBffErrorEnvelope,\n IBffRequestEnvelope,\n IBffResponseEnvelope,\n} from '@/envelope/common';\nimport { type BffRoles, type ChannelMessageKinds } from './constants';\n\n/** One of the `BffRoles` values: `electing`, `leader` or `follower`. */\nexport type TBffRole = TConstValue<typeof BffRoles>;\n\n/**\n * There is deliberately no \"a new leader is ready\" broadcast. A follower cannot act on one safely:\n * BroadcastChannel does not order messages across senders, so a request posted around the moment of\n * promotion may well be answered by the new leader - and a follower that failed its in-flight\n * requests on hearing the announcement would turn some of those successes into errors. The request\n * timeout is the one honest answer for that window.\n */\nexport type TChannelMessage =\n | { kind: typeof ChannelMessageKinds.REQUEST; envelope: IBffRequestEnvelope }\n | { kind: typeof ChannelMessageKinds.RESPONSE; envelope: IBffResponseEnvelope }\n | { kind: typeof ChannelMessageKinds.ERROR; envelope: IBffErrorEnvelope };\n\nexport interface IPendingRequest {\n resolve: (response: Response) => void;\n reject: (error: unknown) => void;\n release: () => void;\n}\n\n/** Options for the transport that shares one worker across tabs through a leader election. */\nexport interface ISharedBffTransportOptions {\n /** Builds the Worker. Called ONLY by whichever tab wins the election - the others never start one. */\n createWorker: () => Worker;\n /** Distinguishes independent BFFs on one origin. The lock name is derived from it. */\n channelName?: string;\n timeoutMs?: number;\n scope?: string;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venizia/ignis-worker",
|
|
3
|
-
"version": "0.4.8-
|
|
3
|
+
"version": "0.4.8-2",
|
|
4
4
|
"description": "Browser Web Worker host for the IGNIS framework: the request/response envelope, the transport contract, and WorkerApplication - the layer that listens on `onmessage` instead of a socket, so a RestApplication can serve its controllers with no server anywhere.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"browser",
|
|
@@ -56,14 +56,14 @@
|
|
|
56
56
|
"force-update": "sh ../../scripts/build/force-update.sh"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@venizia/ignis-helpers": "0.4.8-
|
|
60
|
-
"@venizia/ignis-inversion": "0.4.7-
|
|
61
|
-
"@venizia/ignis-kernel": "0.4.8-
|
|
59
|
+
"@venizia/ignis-helpers": "0.4.8-2",
|
|
60
|
+
"@venizia/ignis-inversion": "0.4.7-2",
|
|
61
|
+
"@venizia/ignis-kernel": "0.4.8-2",
|
|
62
62
|
"reflect-metadata": "^0.2.2"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@types/bun": "^1.4.3",
|
|
66
|
-
"@venizia/dev-configs": "0.4.8-
|
|
66
|
+
"@venizia/dev-configs": "0.4.8-2",
|
|
67
67
|
"eslint": "^10.13.0",
|
|
68
68
|
"oxlint": "1.89.0",
|
|
69
69
|
"oxlint-tsgolint": "7.0.2004",
|