@powerhousedao/host-core 6.2.3-dev.86 → 6.2.3-dev.87
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/{compound-NxCal3db.d.mts → compound-7I7qUIiG.d.mts} +220 -2
- package/dist/compound-7I7qUIiG.d.mts.map +1 -0
- package/dist/{compound-GhJAA2dK.mjs → compound-BZb3tR_c.mjs} +93 -7
- package/dist/compound-BZb3tR_c.mjs.map +1 -0
- package/dist/{env-substitution-CN_oSVVY.mjs → env-substitution-BbFg9lIW.mjs} +93 -7
- package/dist/env-substitution-BbFg9lIW.mjs.map +1 -0
- package/dist/{host-schemas-DtKFmLd0.d.mts → host-schemas-CwNCJflE.d.mts} +220 -2
- package/dist/host-schemas-CwNCJflE.d.mts.map +1 -0
- package/dist/index.d.mts +90 -75
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +91 -20
- package/dist/index.mjs.map +1 -1
- package/dist/{plugins-C1Rjl-zt.d.mts → plugins-DZPDoyBt.d.mts} +2 -2
- package/dist/{plugins-C1Rjl-zt.d.mts.map → plugins-DZPDoyBt.d.mts.map} +1 -1
- package/dist/plugins.d.mts +1 -1
- package/dist/projection.d.mts +82 -66
- package/dist/projection.d.mts.map +1 -1
- package/dist/projection.mjs +55 -20
- package/dist/projection.mjs.map +1 -1
- package/dist/runners/compound.d.mts +23 -1
- package/dist/runners/compound.d.mts.map +1 -1
- package/dist/runners/compound.mjs +1 -1
- package/dist/schema.d.mts +3 -3
- package/dist/schema.mjs +2 -2
- package/package.json +3 -3
- package/dist/compound-GhJAA2dK.mjs.map +0 -1
- package/dist/compound-NxCal3db.d.mts.map +0 -1
- package/dist/env-substitution-CN_oSVVY.mjs.map +0 -1
- package/dist/host-schemas-DtKFmLd0.d.mts.map +0 -1
package/dist/projection.d.mts
CHANGED
|
@@ -1,10 +1,72 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as RunnerKind, et as OutputPath, h as ReactorConfig, l as HostDefinition, lt as TokenKey, m as ReactorBackendKind, n as ChildWrapper, p as ReactorBackend, x as ReactorStorageConfig, y as ReactorProtocol } from "./host-schemas-CwNCJflE.mjs";
|
|
2
2
|
import { t as BuiltinEnv } from "./env-substitution-C_fVirPh.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { PHConnectDefaultDrive, PHConnectRuntimeConfig } from "@powerhousedao/shared/clis";
|
|
5
|
+
//#region src/backend-projection.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Phase 4 (track R): project named host backends onto reactor-monitor's
|
|
8
|
+
* `ReactorDescriptor` shape — the input `provision()` takes. Pure and
|
|
9
|
+
* dependency-free; a type-assignability test pins the output to the real
|
|
10
|
+
* `ReactorDescriptor` so an upstream field rename fails this package's tests
|
|
11
|
+
* instead of silently drifting (D2.b: aligned locally, upstreaming not
|
|
12
|
+
* blocked on).
|
|
13
|
+
*/
|
|
14
|
+
/** The browser-provisionable storage union — reactor-monitor's
|
|
15
|
+
* `ReactorStorageConfig` shape. `postgres` is the SERVER extension (D2.b): a
|
|
16
|
+
* switchboard backend's storage, never a provisioned browser reactor's. */
|
|
17
|
+
type ProjectedStorage = {
|
|
18
|
+
kind: "idb";
|
|
19
|
+
} | {
|
|
20
|
+
kind: "memory";
|
|
21
|
+
} | {
|
|
22
|
+
kind: "path";
|
|
23
|
+
dataDir: string;
|
|
24
|
+
};
|
|
25
|
+
interface ProjectedDescriptor {
|
|
26
|
+
kind: "in-process" | "worker" | "remote";
|
|
27
|
+
name: string;
|
|
28
|
+
storage?: ProjectedStorage;
|
|
29
|
+
packages?: {
|
|
30
|
+
cdnUrl?: string;
|
|
31
|
+
specs?: string[];
|
|
32
|
+
dynamic?: boolean;
|
|
33
|
+
};
|
|
34
|
+
featureFlags?: {
|
|
35
|
+
documentDecisions?: boolean;
|
|
36
|
+
authEnforcement?: boolean;
|
|
37
|
+
authGroups?: boolean;
|
|
38
|
+
authConditions?: boolean;
|
|
39
|
+
};
|
|
40
|
+
remote?: {
|
|
41
|
+
url: string;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** One backend → one descriptor. The protocol's featureFlags ride every
|
|
45
|
+
* descriptor (they are fleet consensus, not per-backend). A remote backend
|
|
46
|
+
* must carry remote.url — provision() requires it. */
|
|
47
|
+
export declare function backendToDescriptor(name: string, backend: ReactorBackend, protocol?: ReactorProtocol): ProjectedDescriptor;
|
|
48
|
+
/** All named backends, in placement-primary-first order (the order a
|
|
49
|
+
* createReactorClients step would provision them). */
|
|
50
|
+
export declare function backendsToDescriptors(reactor: ReactorConfig | undefined): ProjectedDescriptor[];
|
|
51
|
+
/**
|
|
52
|
+
* Structural multi-reactor (phase 4): true when the block names BOTH a local
|
|
53
|
+
* backend (in-process/worker — the tab's own reactor) and a remote one. This
|
|
54
|
+
* is the shape Connect's routing client serves; a lone remote backend is an
|
|
55
|
+
* attach-only host (assistant/agent shape), not a routed tab.
|
|
56
|
+
*/
|
|
57
|
+
export declare function isStructuralMultiReactor(reactor: ReactorConfig | undefined): boolean;
|
|
58
|
+
/** The remote backends' drive addresses, placement order. */
|
|
59
|
+
export declare function remoteBackendUrls(reactor: ReactorConfig | undefined): string[];
|
|
60
|
+
/** A switchboard as Connect's served config names it, with its connection settings. */
|
|
61
|
+
type ServedRemoteBackend = {
|
|
62
|
+
name: string;
|
|
63
|
+
url: string;
|
|
64
|
+
} & Omit<NonNullable<ReactorBackend["remote"]>, "url">;
|
|
65
|
+
//#endregion
|
|
5
66
|
//#region src/reactor-config.d.ts
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
67
|
+
/** A switchboard host's own store. Prefers placement.primary, else
|
|
68
|
+
* "main"/"local", else the first. Connect refuses placement.primary: its
|
|
69
|
+
* reactor is {@link browserBackend}. */
|
|
8
70
|
export declare function primaryBackend(reactor: ReactorConfig | undefined): ReactorBackend | undefined;
|
|
9
71
|
/** The env vars a protocol block maps onto, with their string values. Only
|
|
10
72
|
* keys the block actually sets appear. */
|
|
@@ -34,6 +96,10 @@ export declare function reactorBlockToSwitchboardConfig(reactor: ReactorConfig |
|
|
|
34
96
|
/** The four reactor-client shapes a Connect host can select (mirrors the
|
|
35
97
|
* shared PHReactorClientMode; kept local to avoid an import cycle). */
|
|
36
98
|
type ReactorClientMode = "in-process" | "worker" | "remote" | "router";
|
|
99
|
+
/** Connect's browser reactor: its first in-process or worker backend. */
|
|
100
|
+
export declare function browserBackend(reactor: ReactorConfig | undefined): (ReactorBackend & {
|
|
101
|
+
name: string;
|
|
102
|
+
}) | undefined;
|
|
37
103
|
/**
|
|
38
104
|
* Which reactor client the backend topology asks for:
|
|
39
105
|
* - local (in-process/worker) AND remote backends -> `router`
|
|
@@ -44,6 +110,13 @@ type ReactorClientMode = "in-process" | "worker" | "remote" | "router";
|
|
|
44
110
|
* legacy reactorWorker/multiReactor behaviour untouched.
|
|
45
111
|
*/
|
|
46
112
|
export declare function reactorClientMode(reactor: ReactorConfig | undefined): ReactorClientMode | undefined;
|
|
113
|
+
/** The router settings Connect serves: only the keys the host sets. */
|
|
114
|
+
interface ConnectRouterSettings {
|
|
115
|
+
/** A remote backend's host key; absent, the browser reactor (or the only switchboard). */
|
|
116
|
+
newDrives?: string;
|
|
117
|
+
probeTimeoutMs?: number;
|
|
118
|
+
provisionalRouteMs?: number;
|
|
119
|
+
}
|
|
47
120
|
interface ConnectReactorProjection {
|
|
48
121
|
/** Patch merged into the connect runtime config (connect.*). */
|
|
49
122
|
connect: {
|
|
@@ -51,10 +124,8 @@ interface ConnectReactorProjection {
|
|
|
51
124
|
instance?: {
|
|
52
125
|
reactorWorker?: boolean;
|
|
53
126
|
reactorClient?: ReactorClientMode;
|
|
54
|
-
remoteBackends?:
|
|
55
|
-
|
|
56
|
-
url: string;
|
|
57
|
-
}[];
|
|
127
|
+
remoteBackends?: ServedRemoteBackend[];
|
|
128
|
+
router?: ConnectRouterSettings;
|
|
58
129
|
};
|
|
59
130
|
app?: {
|
|
60
131
|
workflowsEnabled?: boolean;
|
|
@@ -63,8 +134,9 @@ interface ConnectReactorProjection {
|
|
|
63
134
|
}
|
|
64
135
|
/** Project the reactor block onto the Connect runtime config: protocol →
|
|
65
136
|
* connect.reactor (same shape), backend topology → instance.reactorWorker
|
|
66
|
-
* (
|
|
67
|
-
*
|
|
137
|
+
* (the browser reactor's kind), instance.reactorClient, and with a
|
|
138
|
+
* switchboard instance.remoteBackends and instance.router, workflows →
|
|
139
|
+
* app.workflowsEnabled. */
|
|
68
140
|
export declare function projectReactorToConnect(reactor: ReactorConfig | undefined): ConnectReactorProjection;
|
|
69
141
|
/** Each pre-set env var that CONTRADICTS the host's protocol block, as a
|
|
70
142
|
* message naming the var, the host value and the env value. An env var that
|
|
@@ -79,62 +151,6 @@ export declare function protocolConflicts(protocol: ReactorProtocol | undefined,
|
|
|
79
151
|
*/
|
|
80
152
|
export declare function assertProtocolConsistency(protocol: ReactorProtocol | undefined, env: Record<string, string | undefined>, hostFile?: string): void;
|
|
81
153
|
//#endregion
|
|
82
|
-
//#region src/backend-projection.d.ts
|
|
83
|
-
/**
|
|
84
|
-
* Phase 4 (track R): project named host backends onto reactor-monitor's
|
|
85
|
-
* `ReactorDescriptor` shape — the input `provision()` takes. Pure and
|
|
86
|
-
* dependency-free; a type-assignability test pins the output to the real
|
|
87
|
-
* `ReactorDescriptor` so an upstream field rename fails this package's tests
|
|
88
|
-
* instead of silently drifting (D2.b: aligned locally, upstreaming not
|
|
89
|
-
* blocked on).
|
|
90
|
-
*/
|
|
91
|
-
/** The browser-provisionable storage union — reactor-monitor's
|
|
92
|
-
* `ReactorStorageConfig` shape. `postgres` is the SERVER extension (D2.b): a
|
|
93
|
-
* switchboard backend's storage, never a provisioned browser reactor's. */
|
|
94
|
-
type ProjectedStorage = {
|
|
95
|
-
kind: "idb";
|
|
96
|
-
} | {
|
|
97
|
-
kind: "memory";
|
|
98
|
-
} | {
|
|
99
|
-
kind: "path";
|
|
100
|
-
dataDir: string;
|
|
101
|
-
};
|
|
102
|
-
interface ProjectedDescriptor {
|
|
103
|
-
kind: "in-process" | "worker" | "remote";
|
|
104
|
-
name: string;
|
|
105
|
-
storage?: ProjectedStorage;
|
|
106
|
-
packages?: {
|
|
107
|
-
cdnUrl?: string;
|
|
108
|
-
specs?: string[];
|
|
109
|
-
dynamic?: boolean;
|
|
110
|
-
};
|
|
111
|
-
featureFlags?: {
|
|
112
|
-
documentDecisions?: boolean;
|
|
113
|
-
authEnforcement?: boolean;
|
|
114
|
-
authGroups?: boolean;
|
|
115
|
-
authConditions?: boolean;
|
|
116
|
-
};
|
|
117
|
-
remote?: {
|
|
118
|
-
url: string;
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
/** One backend → one descriptor. The protocol's featureFlags ride every
|
|
122
|
-
* descriptor (they are fleet consensus, not per-backend). A remote backend
|
|
123
|
-
* must carry remote.url — provision() requires it. */
|
|
124
|
-
export declare function backendToDescriptor(name: string, backend: ReactorBackend, protocol?: ReactorProtocol): ProjectedDescriptor;
|
|
125
|
-
/** All named backends, in placement-primary-first order (the order a
|
|
126
|
-
* createReactorClients step would provision them). */
|
|
127
|
-
export declare function backendsToDescriptors(reactor: ReactorConfig | undefined): ProjectedDescriptor[];
|
|
128
|
-
/**
|
|
129
|
-
* Structural multi-reactor (phase 4): true when the block names BOTH a local
|
|
130
|
-
* backend (in-process/worker — the tab's own reactor) and a remote one. This
|
|
131
|
-
* is the shape Connect's routing client serves; a lone remote backend is an
|
|
132
|
-
* attach-only host (assistant/agent shape), not a routed tab.
|
|
133
|
-
*/
|
|
134
|
-
export declare function isStructuralMultiReactor(reactor: ReactorConfig | undefined): boolean;
|
|
135
|
-
/** The remote backends' drive addresses, placement order. */
|
|
136
|
-
export declare function remoteBackendUrls(reactor: ReactorConfig | undefined): string[];
|
|
137
|
-
//#endregion
|
|
138
154
|
//#region src/child-wrapper.d.ts
|
|
139
155
|
/** A member's host.js with its wrapper applied, tokens unresolved. */
|
|
140
156
|
type MemberDraft = Record<string, unknown> & {
|
|
@@ -619,6 +635,6 @@ interface MemberInput extends Omit<ExpectHostInput, "members" | "plan"> {
|
|
|
619
635
|
*/
|
|
620
636
|
export declare function expectHost(input: ExpectHostInput): HostExpectation;
|
|
621
637
|
//#endregion
|
|
622
|
-
export type { CompoundPlan, ConnectReactorProjection, ConsumedOutput, ContributedDriveInput, DeclaredIssue, DeferredResolution, DeferredToken, DriveProjectionInput, ExpectHostInput, ExpectedBackend, ExpectedDrive, HostExpectation, MemberDraft, MemberExpectation, MemberInput, OutputLookup, OutputRef, OutputSource, OutputsSchemaLookup, PlanEdge, PlanMember, ProjectedDescriptor, ProjectedStorage, ReactorClientMode, RemovedForm, ResolveOptions, ResolveSources, RunRecord, RunRecordMember, SelfMembers, SwitchboardReactorLayer, TokenPosition, TokenSite };
|
|
638
|
+
export type { CompoundPlan, ConnectReactorProjection, ConnectRouterSettings, ConsumedOutput, ContributedDriveInput, DeclaredIssue, DeferredResolution, DeferredToken, DriveProjectionInput, ExpectHostInput, ExpectedBackend, ExpectedDrive, HostExpectation, MemberDraft, MemberExpectation, MemberInput, OutputLookup, OutputRef, OutputSource, OutputsSchemaLookup, PlanEdge, PlanMember, ProjectedDescriptor, ProjectedStorage, ReactorClientMode, RemovedForm, ResolveOptions, ResolveSources, RunRecord, RunRecordMember, SelfMembers, SwitchboardReactorLayer, TokenPosition, TokenSite };
|
|
623
639
|
export {};
|
|
624
640
|
//# sourceMappingURL=projection.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projection.d.mts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"projection.d.mts","names":[],"sources":["../src/backend-projection.ts","../src/reactor-config.ts","../src/child-wrapper.ts","../src/connect-projection.ts","../src/run-record-schema.ts","../src/resolve/declared.ts","../src/resolve/plan.ts","../src/resolve/resolve.ts","../src/resolve/removed-forms.ts","../src/resolve/sources.ts","../src/resolve/walk.ts","../src/expect-host.ts"],"mappings":";;;;;;;;;;;;;;;;KAmBY;EACN;;EAC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;EAEN;;EAEA,OAAO;;UAGQ;;;EAGf,MAAM;EACN,KAAK;;EAEL,OAAO;EACP,UAAU;;;EAGV,iBAAiB;;;wBAcH,WAAW;;;;;wBAmBX,kBAAkB,iBAAiB;;wBA+DnC,cAAc;;;wBAuDd,aAAa,GAAG,OAAO,IAAI;;;wBAe3B,cAAc,GAAG,OAAO,IAAI;;;;;;;;;;;;;;UCvL3B;EACf;EACA,MAAM;EACN,UAAU;;EAEV;;;;;EAKA;;;;;;UAOe;EACf;EACA;;EAEA;;EAEA;EACA;EACA;;;UAIe;;EAEf;EACA;EACA;EACA,MAAM;;UAGS;EACf;EACA,MAAM;;;EAGN;;EAEA,aAAa;;EAEb;EACA,WAAW;;EAEX;EACA,SAAS;;EAET;EACA,UAAU;;EAEV;;EAEA;;EAEA,UAAU,eAAe;;UAGV,0BAA0B,KACzC;;EAIA;;EAEA;;;;UAKe;EACf,aAAa;EACb;;UAGe;EACf,MAAM;;;EAGN,UAAU;;EAEV,WAAW;;EAEX,uBAAuB;;EAEvB,mBAAmB;;EAEnB,OAAO;;UAGQ,oBAAoB,KAAK;EACxC;EACA;;;;;;;;wBAgKc,WAAW,OAAO,kBAAkB"}
|
package/dist/projection.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as runnerKindSchema, F as TOKEN_ESCAPE_KEY, J as tokenKeyOf, Y as tokenSchema, n as substituteBuiltinEnv, t as isBuiltinEnvName, v as hostNameSchema } from "./env-substitution-BbFg9lIW.mjs";
|
|
2
2
|
import "@powerhousedao/shared/host-tokens";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region src/backend-projection.ts
|
|
@@ -61,15 +61,23 @@ function remoteBackendUrls(reactor) {
|
|
|
61
61
|
return backendsToDescriptors(reactor).filter((d) => d.kind === "remote").map((d) => d.remote?.url).filter((u) => typeof u === "string");
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
|
-
* The remote backends by host key, placement order
|
|
65
|
-
*
|
|
66
|
-
* in remoteBackendUrls.
|
|
64
|
+
* The remote backends by host key, placement order, each with the
|
|
65
|
+
* connection settings it sets. A url that is not a string yet (an output
|
|
66
|
+
* token, unresolved when a host builds) is skipped, as in remoteBackendUrls.
|
|
67
67
|
*/
|
|
68
68
|
function remoteBackends(reactor) {
|
|
69
|
-
return backendsToDescriptors(reactor).flatMap((d) =>
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
return backendsToDescriptors(reactor).flatMap((d) => {
|
|
70
|
+
const remote = reactor?.backends?.[d.name]?.remote;
|
|
71
|
+
if (d.kind !== "remote" || typeof d.remote?.url !== "string" || !remote) return [];
|
|
72
|
+
const { requestTimeoutMs, breaker, realtime } = remote;
|
|
73
|
+
return [{
|
|
74
|
+
name: d.name,
|
|
75
|
+
url: d.remote.url,
|
|
76
|
+
...requestTimeoutMs !== void 0 ? { requestTimeoutMs } : {},
|
|
77
|
+
...breaker !== void 0 ? { breaker } : {},
|
|
78
|
+
...realtime !== void 0 ? { realtime } : {}
|
|
79
|
+
}];
|
|
80
|
+
});
|
|
73
81
|
}
|
|
74
82
|
//#endregion
|
|
75
83
|
//#region src/reactor-config.ts
|
|
@@ -81,8 +89,9 @@ function remoteBackends(reactor) {
|
|
|
81
89
|
* single-sourced `reactor.protocol` — both projections read the same block, so
|
|
82
90
|
* client and server cannot diverge, and a contradicting pre-set env fails boot.
|
|
83
91
|
*/
|
|
84
|
-
/**
|
|
85
|
-
*
|
|
92
|
+
/** A switchboard host's own store. Prefers placement.primary, else
|
|
93
|
+
* "main"/"local", else the first. Connect refuses placement.primary: its
|
|
94
|
+
* reactor is {@link browserBackend}. */
|
|
86
95
|
function primaryBackend(reactor) {
|
|
87
96
|
const backends = reactor?.backends;
|
|
88
97
|
if (!backends) return void 0;
|
|
@@ -127,6 +136,14 @@ function reactorBlockToSwitchboardConfig(reactor) {
|
|
|
127
136
|
return layer;
|
|
128
137
|
}
|
|
129
138
|
const LOCAL_BACKEND_KINDS = /* @__PURE__ */ new Set(["in-process", "worker"]);
|
|
139
|
+
/** Connect's browser reactor: its first in-process or worker backend. */
|
|
140
|
+
function browserBackend(reactor) {
|
|
141
|
+
const entry = Object.entries(reactor?.backends ?? {}).find(([, backend]) => LOCAL_BACKEND_KINDS.has(backend.kind));
|
|
142
|
+
return entry ? {
|
|
143
|
+
...entry[1],
|
|
144
|
+
name: entry[0]
|
|
145
|
+
} : void 0;
|
|
146
|
+
}
|
|
130
147
|
/**
|
|
131
148
|
* Which reactor client the backend topology asks for:
|
|
132
149
|
* - local (in-process/worker) AND remote backends -> `router`
|
|
@@ -145,22 +162,40 @@ function reactorClientMode(reactor) {
|
|
|
145
162
|
const hasRemote = kinds.some((k) => k === "remote");
|
|
146
163
|
if (hasLocal && hasRemote) return "router";
|
|
147
164
|
if (hasRemote) return "remote";
|
|
148
|
-
return
|
|
165
|
+
return browserBackend(reactor)?.kind === "worker" ? "worker" : "in-process";
|
|
166
|
+
}
|
|
167
|
+
/** Served only when `newDrives` names a served remote backend: a local one
|
|
168
|
+
* is the default, and Connect refuses one it has no address for. */
|
|
169
|
+
function connectRouterSettings(reactor, served) {
|
|
170
|
+
const newDrives = reactor?.placement?.newDrives;
|
|
171
|
+
const { probeTimeoutMs, provisionalRouteMs } = reactor?.router ?? {};
|
|
172
|
+
const router = {
|
|
173
|
+
...newDrives !== void 0 && served.some((remote) => remote.name === newDrives) ? { newDrives } : {},
|
|
174
|
+
...probeTimeoutMs !== void 0 ? { probeTimeoutMs } : {},
|
|
175
|
+
...provisionalRouteMs !== void 0 ? { provisionalRouteMs } : {}
|
|
176
|
+
};
|
|
177
|
+
return Object.keys(router).length > 0 ? router : void 0;
|
|
149
178
|
}
|
|
150
179
|
/** Project the reactor block onto the Connect runtime config: protocol →
|
|
151
180
|
* connect.reactor (same shape), backend topology → instance.reactorWorker
|
|
152
|
-
* (
|
|
153
|
-
*
|
|
181
|
+
* (the browser reactor's kind), instance.reactorClient, and with a
|
|
182
|
+
* switchboard instance.remoteBackends and instance.router, workflows →
|
|
183
|
+
* app.workflowsEnabled. */
|
|
154
184
|
function projectReactorToConnect(reactor) {
|
|
155
185
|
const connect = {};
|
|
156
186
|
if (reactor?.protocol) connect.reactor = reactor.protocol;
|
|
157
|
-
const backend = primaryBackend(reactor);
|
|
158
187
|
const mode = reactorClientMode(reactor);
|
|
159
|
-
if (
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
188
|
+
if (mode !== void 0) {
|
|
189
|
+
const routed = mode === "router" || mode === "remote";
|
|
190
|
+
const served = routed ? remoteBackends(reactor) : [];
|
|
191
|
+
const router = routed ? connectRouterSettings(reactor, served) : void 0;
|
|
192
|
+
connect.instance = {
|
|
193
|
+
reactorWorker: browserBackend(reactor)?.kind === "worker",
|
|
194
|
+
reactorClient: mode,
|
|
195
|
+
...routed ? { remoteBackends: served } : {},
|
|
196
|
+
...router ? { router } : {}
|
|
197
|
+
};
|
|
198
|
+
}
|
|
164
199
|
if (reactor?.workflows !== void 0) connect.app = { workflowsEnabled: reactor.workflows };
|
|
165
200
|
return { connect };
|
|
166
201
|
}
|
|
@@ -1570,6 +1605,6 @@ function expectHost(input) {
|
|
|
1570
1605
|
return expectation;
|
|
1571
1606
|
}
|
|
1572
1607
|
//#endregion
|
|
1573
|
-
export { PlanError, TokenResolutionError, applyChildWrapper, assertProtocolConsistency, backendToDescriptor, backendsToDescriptors, checkOutputPaths, checkTokenSites, collectTokenSites, compoundOutputSource, describeMapElements, describeToken, envSitesOf, expectHost, findRemovedForms, formatPath, isStructuralMultiReactor, memberForRef, mergeDefaultDrives, outputRefsOf, outputSitesOf, planCompound, primaryBackend, projectDrivesIntoConnect, projectReactorToConnect, protocolConflicts, protocolEnv, reactorBlockToSwitchboardConfig, reactorClientMode, rebaseDriveUrl, refKey, remoteBackendUrls, renderTokens, resolveHostOutputs, runRecordMemberSchema, runRecordSchema, schemaAtPath, unwrapEscapes };
|
|
1608
|
+
export { PlanError, TokenResolutionError, applyChildWrapper, assertProtocolConsistency, backendToDescriptor, backendsToDescriptors, browserBackend, checkOutputPaths, checkTokenSites, collectTokenSites, compoundOutputSource, describeMapElements, describeToken, envSitesOf, expectHost, findRemovedForms, formatPath, isStructuralMultiReactor, memberForRef, mergeDefaultDrives, outputRefsOf, outputSitesOf, planCompound, primaryBackend, projectDrivesIntoConnect, projectReactorToConnect, protocolConflicts, protocolEnv, reactorBlockToSwitchboardConfig, reactorClientMode, rebaseDriveUrl, refKey, remoteBackendUrls, renderTokens, resolveHostOutputs, runRecordMemberSchema, runRecordSchema, schemaAtPath, unwrapEscapes };
|
|
1574
1609
|
|
|
1575
1610
|
//# sourceMappingURL=projection.mjs.map
|