@jskit-ai/assistant-voice 0.1.1 → 0.1.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/examples/conversation/package.json +8 -8
- package/package.json +1 -1
- package/examples/conversation/dist/assets/error-DOwCrGXH.js +0 -1
- package/examples/conversation/dist/assets/index-Bq1DwQwF.js +0 -90
- package/examples/conversation/dist/assets/index-Bw7_l3Cu.css +0 -1
- package/examples/conversation/dist/assets/placement-CUwf_TAl.js +0 -1
- package/examples/conversation/dist/assets/placementTopology-CUwf_TAl.js +0 -1
- package/examples/conversation/dist/index.html +0 -3
- package/examples/conversation/node_modules/.vite/deps/@jskit-ai_kernel_client_moduleBootstrap.js +0 -824
- package/examples/conversation/node_modules/.vite/deps/@jskit-ai_kernel_client_moduleBootstrap.js.map +0 -1
- package/examples/conversation/node_modules/.vite/deps/@mdi_js.js +0 -7450
- package/examples/conversation/node_modules/.vite/deps/@mdi_js.js.map +0 -1
- package/examples/conversation/node_modules/.vite/deps/@tanstack_vue-query.js +0 -3965
- package/examples/conversation/node_modules/.vite/deps/@tanstack_vue-query.js.map +0 -1
- package/examples/conversation/node_modules/.vite/deps/VTooltip-Nwckus73.js +0 -2311
- package/examples/conversation/node_modules/.vite/deps/VTooltip-Nwckus73.js.map +0 -1
- package/examples/conversation/node_modules/.vite/deps/_metadata.json +0 -110
- package/examples/conversation/node_modules/.vite/deps/defineComponent-Bx_4rnHZ.js +0 -710
- package/examples/conversation/node_modules/.vite/deps/defineComponent-Bx_4rnHZ.js.map +0 -1
- package/examples/conversation/node_modules/.vite/deps/dist-CUIjXXPV.js +0 -3878
- package/examples/conversation/node_modules/.vite/deps/dist-CUIjXXPV.js.map +0 -1
- package/examples/conversation/node_modules/.vite/deps/hotkey-parsing-B5h5TiMG.js +0 -1214
- package/examples/conversation/node_modules/.vite/deps/hotkey-parsing-B5h5TiMG.js.map +0 -1
- package/examples/conversation/node_modules/.vite/deps/icons-DPtxVIU0.js +0 -98
- package/examples/conversation/node_modules/.vite/deps/icons-DPtxVIU0.js.map +0 -1
- package/examples/conversation/node_modules/.vite/deps/json-rest-schema.js +0 -2071
- package/examples/conversation/node_modules/.vite/deps/json-rest-schema.js.map +0 -1
- package/examples/conversation/node_modules/.vite/deps/package.json +0 -3
- package/examples/conversation/node_modules/.vite/deps/pinia.js +0 -1453
- package/examples/conversation/node_modules/.vite/deps/pinia.js.map +0 -1
- package/examples/conversation/node_modules/.vite/deps/socket__io-client.js +0 -3899
- package/examples/conversation/node_modules/.vite/deps/socket__io-client.js.map +0 -1
- package/examples/conversation/node_modules/.vite/deps/theme-BSn2V8xv.js +0 -1301
- package/examples/conversation/node_modules/.vite/deps/theme-BSn2V8xv.js.map +0 -1
- package/examples/conversation/node_modules/.vite/deps/vue-router.js +0 -2989
- package/examples/conversation/node_modules/.vite/deps/vue-router.js.map +0 -1
- package/examples/conversation/node_modules/.vite/deps/vue.js +0 -2
- package/examples/conversation/node_modules/.vite/deps/vue.runtime.esm-bundler-DWdvffrK.js +0 -8890
- package/examples/conversation/node_modules/.vite/deps/vue.runtime.esm-bundler-DWdvffrK.js.map +0 -1
- package/examples/conversation/node_modules/.vite/deps/vuetify.js +0 -413
- package/examples/conversation/node_modules/.vite/deps/vuetify.js.map +0 -1
- package/examples/conversation/node_modules/.vite/deps/vuetify_components.js +0 -25370
- package/examples/conversation/node_modules/.vite/deps/vuetify_components.js.map +0 -1
- package/examples/conversation/node_modules/.vite/deps/vuetify_directives.js +0 -132
- package/examples/conversation/node_modules/.vite/deps/vuetify_directives.js.map +0 -1
- package/examples/conversation/node_modules/.vite/deps/vuetify_iconsets_mdi-svg.js +0 -70
- package/examples/conversation/node_modules/.vite/deps/vuetify_iconsets_mdi-svg.js.map +0 -1
package/examples/conversation/node_modules/.vite/deps/@jskit-ai_kernel_client_moduleBootstrap.js
DELETED
|
@@ -1,824 +0,0 @@
|
|
|
1
|
-
Object.freeze([
|
|
2
|
-
"none",
|
|
3
|
-
"pending",
|
|
4
|
-
"committed",
|
|
5
|
-
"rolledBack",
|
|
6
|
-
"unknown"
|
|
7
|
-
]);
|
|
8
|
-
function isRecord(value) {
|
|
9
|
-
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
10
|
-
}
|
|
11
|
-
Object.freeze(["bundled", "dev_server"]);
|
|
12
|
-
Object.freeze(["capacitor"]);
|
|
13
|
-
Object.freeze({
|
|
14
|
-
callbackPath: "/auth/login",
|
|
15
|
-
customScheme: "",
|
|
16
|
-
appLinkDomains: Object.freeze([])
|
|
17
|
-
});
|
|
18
|
-
Object.freeze({
|
|
19
|
-
packageName: "",
|
|
20
|
-
minSdk: 26,
|
|
21
|
-
targetSdk: 35,
|
|
22
|
-
versionCode: 1,
|
|
23
|
-
versionName: "1.0.0"
|
|
24
|
-
});
|
|
25
|
-
//#endregion
|
|
26
|
-
//#region ../../../kernel/shared/capabilities/defineProvider.js
|
|
27
|
-
var ARCHITECTURE_ID_PATTERN = /^[a-z][a-z0-9_.-]*$/u;
|
|
28
|
-
var LOCAL_NAME_PATTERN = /^[A-Za-z_$][A-Za-z0-9_$]*$/u;
|
|
29
|
-
function normalizeArchitectureId(value, label) {
|
|
30
|
-
const normalized = String(value || "").trim().toLowerCase();
|
|
31
|
-
if (!ARCHITECTURE_ID_PATTERN.test(normalized)) throw new TypeError(`${label} must match ${ARCHITECTURE_ID_PATTERN.toString()}.`);
|
|
32
|
-
return normalized;
|
|
33
|
-
}
|
|
34
|
-
function normalizeCapabilityMap(value, label) {
|
|
35
|
-
if (value == null) return Object.freeze({});
|
|
36
|
-
if (!isRecord(value)) throw new TypeError(`${label} must be an object mapping local names to capability ids.`);
|
|
37
|
-
const normalized = {};
|
|
38
|
-
const seenCapabilityIds = /* @__PURE__ */ new Set();
|
|
39
|
-
for (const [rawLocalName, rawCapabilityId] of Object.entries(value)) {
|
|
40
|
-
const localName = String(rawLocalName || "").trim();
|
|
41
|
-
if (!LOCAL_NAME_PATTERN.test(localName)) throw new TypeError(`${label} local name "${localName}" must be a JavaScript identifier.`);
|
|
42
|
-
const capabilityId = normalizeArchitectureId(rawCapabilityId, `${label}.${localName}`);
|
|
43
|
-
if (seenCapabilityIds.has(capabilityId)) throw new TypeError(`${label} declares capability "${capabilityId}" more than once.`);
|
|
44
|
-
seenCapabilityIds.add(capabilityId);
|
|
45
|
-
normalized[localName] = capabilityId;
|
|
46
|
-
}
|
|
47
|
-
return Object.freeze(normalized);
|
|
48
|
-
}
|
|
49
|
-
function assertDistinctLocalNames(maps) {
|
|
50
|
-
const owners = /* @__PURE__ */ new Map();
|
|
51
|
-
for (const [kind, entries] of Object.entries(maps)) for (const localName of Object.keys(entries)) {
|
|
52
|
-
if (owners.has(localName)) throw new TypeError(`Provider local name "${localName}" is declared by both ${owners.get(localName)} and ${kind}.`);
|
|
53
|
-
owners.set(localName, kind);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function normalizeLifecycleMethod(value, label) {
|
|
57
|
-
if (value == null) return null;
|
|
58
|
-
if (typeof value !== "function") throw new TypeError(`${label} must be a function when provided.`);
|
|
59
|
-
return value;
|
|
60
|
-
}
|
|
61
|
-
function defineProvider({ id, requires = {}, optional = {}, provides = {}, setup, boot = null, shutdown = null } = {}) {
|
|
62
|
-
const providerId = normalizeArchitectureId(id, "Provider id");
|
|
63
|
-
const normalizedRequires = normalizeCapabilityMap(requires, `${providerId}.requires`);
|
|
64
|
-
const normalizedOptional = normalizeCapabilityMap(optional, `${providerId}.optional`);
|
|
65
|
-
const normalizedProvides = normalizeCapabilityMap(provides, `${providerId}.provides`);
|
|
66
|
-
assertDistinctLocalNames({
|
|
67
|
-
requires: normalizedRequires,
|
|
68
|
-
optional: normalizedOptional,
|
|
69
|
-
provides: normalizedProvides
|
|
70
|
-
});
|
|
71
|
-
const setupMethod = normalizeLifecycleMethod(setup, `${providerId}.setup`);
|
|
72
|
-
if (!setupMethod) throw new TypeError(`${providerId}.setup is required.`);
|
|
73
|
-
return Object.freeze({
|
|
74
|
-
id: providerId,
|
|
75
|
-
requires: normalizedRequires,
|
|
76
|
-
optional: normalizedOptional,
|
|
77
|
-
provides: normalizedProvides,
|
|
78
|
-
setup: setupMethod,
|
|
79
|
-
boot: normalizeLifecycleMethod(boot, `${providerId}.boot`),
|
|
80
|
-
shutdown: normalizeLifecycleMethod(shutdown, `${providerId}.shutdown`)
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
//#endregion
|
|
84
|
-
//#region ../../../kernel/shared/capabilities/runtime.js
|
|
85
|
-
function normalizeProviderDefinition(value) {
|
|
86
|
-
if (!isRecord(value)) throw new TypeError("Capability runtime providers must be provider definitions.");
|
|
87
|
-
return defineProvider(value);
|
|
88
|
-
}
|
|
89
|
-
function normalizeInputCapabilities(value) {
|
|
90
|
-
if (value == null) return /* @__PURE__ */ new Map();
|
|
91
|
-
if (!isRecord(value)) throw new TypeError("Capability runtime inputs must be an object keyed by capability id.");
|
|
92
|
-
return new Map(Object.entries(value).map(([id, capability]) => [normalizeArchitectureId(id, "Runtime input capability id"), capability]));
|
|
93
|
-
}
|
|
94
|
-
function providerCapabilityIds(provider, field) {
|
|
95
|
-
return Object.values(provider[field] || {});
|
|
96
|
-
}
|
|
97
|
-
function buildProviderOrder(providers, inputCapabilities) {
|
|
98
|
-
const normalizedProviders = providers.map(normalizeProviderDefinition);
|
|
99
|
-
const providersById = /* @__PURE__ */ new Map();
|
|
100
|
-
const providerByCapability = /* @__PURE__ */ new Map();
|
|
101
|
-
for (const provider of normalizedProviders) {
|
|
102
|
-
if (providersById.has(provider.id)) throw new Error(`Provider "${provider.id}" is duplicated.`);
|
|
103
|
-
providersById.set(provider.id, provider);
|
|
104
|
-
for (const capabilityId of providerCapabilityIds(provider, "provides")) {
|
|
105
|
-
if (inputCapabilities.has(capabilityId)) throw new Error(`Capability "${capabilityId}" is supplied both as a runtime input and by ${provider.id}.`);
|
|
106
|
-
if (providerByCapability.has(capabilityId)) throw new Error(`Capability "${capabilityId}" is provided by both ${providerByCapability.get(capabilityId).id} and ${provider.id}.`);
|
|
107
|
-
providerByCapability.set(capabilityId, provider);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
for (const provider of normalizedProviders) for (const capabilityId of providerCapabilityIds(provider, "requires")) {
|
|
111
|
-
if (!inputCapabilities.has(capabilityId) && !providerByCapability.has(capabilityId)) throw new Error(`Provider "${provider.id}" requires missing capability "${capabilityId}".`);
|
|
112
|
-
if (providerByCapability.get(capabilityId)?.id === provider.id) throw new Error(`Provider "${provider.id}" cannot require capability "${capabilityId}" that it provides.`);
|
|
113
|
-
}
|
|
114
|
-
const visited = /* @__PURE__ */ new Set();
|
|
115
|
-
const visiting = /* @__PURE__ */ new Set();
|
|
116
|
-
const ordered = [];
|
|
117
|
-
function visit(provider, lineage = []) {
|
|
118
|
-
if (visited.has(provider.id)) return;
|
|
119
|
-
if (visiting.has(provider.id)) throw new Error(`Provider capability cycle detected: ${[...lineage, provider.id].join(" -> ")}.`);
|
|
120
|
-
visiting.add(provider.id);
|
|
121
|
-
const dependencyProviders = [...providerCapabilityIds(provider, "requires"), ...providerCapabilityIds(provider, "optional")].map((capabilityId) => providerByCapability.get(capabilityId) || null).filter(Boolean).sort((left, right) => left.id.localeCompare(right.id));
|
|
122
|
-
for (const dependencyProvider of dependencyProviders) visit(dependencyProvider, [...lineage, provider.id]);
|
|
123
|
-
visiting.delete(provider.id);
|
|
124
|
-
visited.add(provider.id);
|
|
125
|
-
ordered.push(provider);
|
|
126
|
-
}
|
|
127
|
-
for (const provider of [...normalizedProviders].sort((left, right) => left.id.localeCompare(right.id))) visit(provider);
|
|
128
|
-
return Object.freeze(ordered);
|
|
129
|
-
}
|
|
130
|
-
function resolveProviderDependencies(provider, capabilities) {
|
|
131
|
-
const dependencies = {};
|
|
132
|
-
for (const [localName, capabilityId] of Object.entries(provider.requires)) {
|
|
133
|
-
if (!capabilities.has(capabilityId)) throw new Error(`Provider "${provider.id}" requires unavailable capability "${capabilityId}".`);
|
|
134
|
-
dependencies[localName] = capabilities.get(capabilityId);
|
|
135
|
-
}
|
|
136
|
-
for (const [localName, capabilityId] of Object.entries(provider.optional)) dependencies[localName] = capabilities.has(capabilityId) ? capabilities.get(capabilityId) : null;
|
|
137
|
-
return Object.freeze(dependencies);
|
|
138
|
-
}
|
|
139
|
-
function normalizeProviderOutputs(provider, value) {
|
|
140
|
-
const expectedNames = Object.keys(provider.provides);
|
|
141
|
-
if (expectedNames.length === 0) {
|
|
142
|
-
if (value != null && (!isRecord(value) || Object.keys(value).length > 0)) throw new Error(`Provider "${provider.id}" declares no capabilities but setup() returned outputs.`);
|
|
143
|
-
return Object.freeze({});
|
|
144
|
-
}
|
|
145
|
-
if (!isRecord(value)) throw new Error(`Provider "${provider.id}" setup() must return its declared capability outputs.`);
|
|
146
|
-
const actualNames = Object.keys(value).sort();
|
|
147
|
-
const sortedExpectedNames = [...expectedNames].sort();
|
|
148
|
-
if (actualNames.length !== sortedExpectedNames.length || actualNames.some((name, index) => name !== sortedExpectedNames[index])) throw new Error(`Provider "${provider.id}" setup() outputs must be exactly: ${sortedExpectedNames.join(", ") || "<none>"}.`);
|
|
149
|
-
return Object.freeze({ ...value });
|
|
150
|
-
}
|
|
151
|
-
function createCapabilityRuntime({ providers = [], inputs = {}, profile = "" } = {}) {
|
|
152
|
-
const capabilities = normalizeInputCapabilities(inputs);
|
|
153
|
-
const providerOrder = buildProviderOrder(Array.isArray(providers) ? providers : [], capabilities);
|
|
154
|
-
const providerStates = /* @__PURE__ */ new Map();
|
|
155
|
-
const normalizedProfile = String(profile || "").trim();
|
|
156
|
-
let lifecycleState = "created";
|
|
157
|
-
async function stopInitializedProviders() {
|
|
158
|
-
const stopped = [];
|
|
159
|
-
let firstError = null;
|
|
160
|
-
for (const provider of [...providerOrder].reverse()) {
|
|
161
|
-
if (!providerStates.has(provider.id)) continue;
|
|
162
|
-
if (provider.shutdown) {
|
|
163
|
-
const state = providerStates.get(provider.id);
|
|
164
|
-
try {
|
|
165
|
-
await provider.shutdown(state.dependencies, Object.freeze({
|
|
166
|
-
outputs: state.outputs,
|
|
167
|
-
profile: normalizedProfile
|
|
168
|
-
}));
|
|
169
|
-
} catch (error) {
|
|
170
|
-
firstError ||= error;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
stopped.push(provider.id);
|
|
174
|
-
}
|
|
175
|
-
if (firstError) throw firstError;
|
|
176
|
-
return Object.freeze(stopped);
|
|
177
|
-
}
|
|
178
|
-
async function start() {
|
|
179
|
-
if (lifecycleState !== "created") throw new Error(`Capability runtime cannot start from state "${lifecycleState}".`);
|
|
180
|
-
lifecycleState = "starting";
|
|
181
|
-
try {
|
|
182
|
-
for (const provider of providerOrder) {
|
|
183
|
-
const dependencies = resolveProviderDependencies(provider, capabilities);
|
|
184
|
-
const outputs = normalizeProviderOutputs(provider, await provider.setup(dependencies, Object.freeze({ profile: normalizedProfile })));
|
|
185
|
-
for (const [localName, capabilityId] of Object.entries(provider.provides)) capabilities.set(capabilityId, outputs[localName]);
|
|
186
|
-
providerStates.set(provider.id, Object.freeze({
|
|
187
|
-
dependencies,
|
|
188
|
-
outputs
|
|
189
|
-
}));
|
|
190
|
-
}
|
|
191
|
-
for (const provider of providerOrder) if (provider.boot) {
|
|
192
|
-
const state = providerStates.get(provider.id);
|
|
193
|
-
await provider.boot(state.dependencies, Object.freeze({
|
|
194
|
-
outputs: state.outputs,
|
|
195
|
-
profile: normalizedProfile
|
|
196
|
-
}));
|
|
197
|
-
}
|
|
198
|
-
lifecycleState = "started";
|
|
199
|
-
return api;
|
|
200
|
-
} catch (error) {
|
|
201
|
-
lifecycleState = "failed";
|
|
202
|
-
try {
|
|
203
|
-
await stopInitializedProviders();
|
|
204
|
-
} catch (shutdownError) {
|
|
205
|
-
throw new AggregateError([error, shutdownError], "Capability runtime startup failed and cleanup also failed.", { cause: error });
|
|
206
|
-
}
|
|
207
|
-
throw error;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
async function shutdown() {
|
|
211
|
-
if (lifecycleState === "stopped") return Object.freeze([]);
|
|
212
|
-
if (lifecycleState !== "started") throw new Error(`Capability runtime cannot shut down from state "${lifecycleState}".`);
|
|
213
|
-
lifecycleState = "stopping";
|
|
214
|
-
try {
|
|
215
|
-
return await stopInitializedProviders();
|
|
216
|
-
} finally {
|
|
217
|
-
lifecycleState = "stopped";
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
function diagnostics() {
|
|
221
|
-
return Object.freeze({
|
|
222
|
-
profile: normalizedProfile,
|
|
223
|
-
lifecycleState,
|
|
224
|
-
providerOrder: Object.freeze(providerOrder.map((provider) => provider.id)),
|
|
225
|
-
capabilityIds: Object.freeze([...capabilities.keys()].sort())
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
const api = Object.freeze({
|
|
229
|
-
start,
|
|
230
|
-
shutdown,
|
|
231
|
-
diagnostics
|
|
232
|
-
});
|
|
233
|
-
return api;
|
|
234
|
-
}
|
|
235
|
-
//#endregion
|
|
236
|
-
//#region ../../../kernel/shared/surface/registry.js
|
|
237
|
-
function normalizeSurfaceId(value) {
|
|
238
|
-
return String(value || "").trim().toLowerCase();
|
|
239
|
-
}
|
|
240
|
-
//#endregion
|
|
241
|
-
//#region ../../../kernel/shared/surface/runtime.js
|
|
242
|
-
function normalizeRoutePath(pathLike = "") {
|
|
243
|
-
const rawPath = String(pathLike || "").trim();
|
|
244
|
-
if (!rawPath || rawPath === "/") return "/";
|
|
245
|
-
const compacted = (rawPath.startsWith("/") ? rawPath : `/${rawPath}`).replace(/\/{2,}/g, "/");
|
|
246
|
-
if (compacted === "/") return "/";
|
|
247
|
-
return compacted.replace(/\/+$/, "") || "/";
|
|
248
|
-
}
|
|
249
|
-
function resolveAbsoluteRoutePath(parentAbsolutePath = "/", routePath = "") {
|
|
250
|
-
const normalizedParentPath = normalizeRoutePath(parentAbsolutePath);
|
|
251
|
-
const rawRoutePath = String(routePath || "").trim();
|
|
252
|
-
if (!rawRoutePath) return normalizedParentPath;
|
|
253
|
-
if (rawRoutePath.startsWith("/")) return normalizeRoutePath(rawRoutePath);
|
|
254
|
-
if (normalizedParentPath === "/") return normalizeRoutePath(`/${rawRoutePath}`);
|
|
255
|
-
return normalizeRoutePath(`${normalizedParentPath}/${rawRoutePath}`);
|
|
256
|
-
}
|
|
257
|
-
function readRouteJskitMeta(route) {
|
|
258
|
-
if (!isRecord(route) || !isRecord(route.meta) || !isRecord(route.meta.jskit)) return {};
|
|
259
|
-
return route.meta.jskit;
|
|
260
|
-
}
|
|
261
|
-
function resolveRouteExplicitSurface(route) {
|
|
262
|
-
const metaSurface = readRouteJskitMeta(route).surface;
|
|
263
|
-
return normalizeSurfaceId(route?.surface || metaSurface);
|
|
264
|
-
}
|
|
265
|
-
function resolveOwnRouteScope(route) {
|
|
266
|
-
const metaScope = readRouteJskitMeta(route).scope;
|
|
267
|
-
const normalizedScope = String(route?.scope || metaScope || "").trim().toLowerCase();
|
|
268
|
-
if (!normalizedScope) return "";
|
|
269
|
-
return normalizedScope === "global" ? "global" : "surface";
|
|
270
|
-
}
|
|
271
|
-
function resolveRouteSurface(route, inheritedSurfaceId = "", { surfaceRuntime, absolutePath = "/" } = {}) {
|
|
272
|
-
const explicitSurface = resolveRouteExplicitSurface(route);
|
|
273
|
-
if (explicitSurface) return explicitSurface;
|
|
274
|
-
const normalizedInheritedSurface = normalizeSurfaceId(inheritedSurfaceId);
|
|
275
|
-
if (normalizedInheritedSurface) return normalizedInheritedSurface;
|
|
276
|
-
const routePath = String(route?.path || "").trim();
|
|
277
|
-
if (routePath && routePath.startsWith("/")) return surfaceRuntime.resolveSurfaceFromPathname(routePath);
|
|
278
|
-
if (absolutePath) return surfaceRuntime.resolveSurfaceFromPathname(absolutePath);
|
|
279
|
-
return surfaceRuntime.DEFAULT_SURFACE_ID;
|
|
280
|
-
}
|
|
281
|
-
function normalizeRoutesBySurfaceBoundaries(routeList = [], { surfaceRuntime } = {}) {
|
|
282
|
-
const normalizedRoutes = Array.isArray(routeList) ? routeList : [];
|
|
283
|
-
const hoistedRoutes = [];
|
|
284
|
-
function cloneRouteWithChildren(route, children) {
|
|
285
|
-
const nextRoute = { ...route };
|
|
286
|
-
if (children.length > 0) nextRoute.children = children;
|
|
287
|
-
else if (Object.prototype.hasOwnProperty.call(nextRoute, "children")) delete nextRoute.children;
|
|
288
|
-
return nextRoute;
|
|
289
|
-
}
|
|
290
|
-
function cloneRouteAsHoisted(route, absolutePath, children) {
|
|
291
|
-
const nextRoute = cloneRouteWithChildren(route, children);
|
|
292
|
-
nextRoute.path = absolutePath;
|
|
293
|
-
return nextRoute;
|
|
294
|
-
}
|
|
295
|
-
function visitRoute(route, parentSurfaceId = "", parentAbsolutePath = "/") {
|
|
296
|
-
if (!isRecord(route)) return null;
|
|
297
|
-
const absolutePath = resolveAbsoluteRoutePath(parentAbsolutePath, route.path);
|
|
298
|
-
const explicitSurface = resolveRouteExplicitSurface(route);
|
|
299
|
-
const normalizedParentSurfaceId = normalizeSurfaceId(parentSurfaceId);
|
|
300
|
-
const resolvedSurface = resolveRouteSurface(route, normalizedParentSurfaceId, {
|
|
301
|
-
surfaceRuntime,
|
|
302
|
-
absolutePath
|
|
303
|
-
});
|
|
304
|
-
const surfaceBoundary = Boolean(explicitSurface) && Boolean(normalizedParentSurfaceId) && explicitSurface !== normalizedParentSurfaceId;
|
|
305
|
-
const children = Array.isArray(route.children) ? route.children : [];
|
|
306
|
-
const filteredChildren = [];
|
|
307
|
-
for (const child of children) {
|
|
308
|
-
const normalizedChild = visitRoute(child, resolvedSurface, absolutePath);
|
|
309
|
-
if (normalizedChild) filteredChildren.push(normalizedChild);
|
|
310
|
-
}
|
|
311
|
-
const routeWithChildren = children.length !== filteredChildren.length || filteredChildren.some((child, index) => child !== children[index]) ? cloneRouteWithChildren(route, filteredChildren) : route;
|
|
312
|
-
if (!surfaceBoundary) return routeWithChildren;
|
|
313
|
-
hoistedRoutes.push(cloneRouteAsHoisted(routeWithChildren, absolutePath, filteredChildren));
|
|
314
|
-
return null;
|
|
315
|
-
}
|
|
316
|
-
const keptRoutes = [];
|
|
317
|
-
for (const route of normalizedRoutes) {
|
|
318
|
-
const normalizedRoute = visitRoute(route, "", "/");
|
|
319
|
-
if (normalizedRoute) keptRoutes.push(normalizedRoute);
|
|
320
|
-
}
|
|
321
|
-
return [...keptRoutes, ...hoistedRoutes];
|
|
322
|
-
}
|
|
323
|
-
function filterRoutesBySurface(routeList, { surfaceRuntime, surfaceMode } = {}) {
|
|
324
|
-
if (!surfaceRuntime || typeof surfaceRuntime !== "object") throw new Error("filterRoutesBySurface requires surfaceRuntime.");
|
|
325
|
-
if (typeof surfaceRuntime.normalizeSurfaceMode !== "function") throw new Error("filterRoutesBySurface requires surfaceRuntime.normalizeSurfaceMode().");
|
|
326
|
-
if (typeof surfaceRuntime.resolveSurfaceFromPathname !== "function") throw new Error("filterRoutesBySurface requires surfaceRuntime.resolveSurfaceFromPathname().");
|
|
327
|
-
if (typeof surfaceRuntime.listEnabledSurfaceIds !== "function") throw new Error("filterRoutesBySurface requires surfaceRuntime.listEnabledSurfaceIds().");
|
|
328
|
-
const normalizedRoutes = normalizeRoutesBySurfaceBoundaries(routeList, { surfaceRuntime });
|
|
329
|
-
const allMode = String(surfaceRuntime.SURFACE_MODE_ALL || "all").trim().toLowerCase() || "all";
|
|
330
|
-
const normalizedMode = surfaceRuntime.normalizeSurfaceMode(surfaceMode);
|
|
331
|
-
const enabledSurfaces = new Set(surfaceRuntime.listEnabledSurfaceIds());
|
|
332
|
-
function filterRouteNode(route, inheritedSurfaceId = "") {
|
|
333
|
-
if (!isRecord(route)) return null;
|
|
334
|
-
const resolvedSurface = resolveRouteSurface(route, inheritedSurfaceId, {
|
|
335
|
-
surfaceRuntime,
|
|
336
|
-
absolutePath: String(route.path || "/")
|
|
337
|
-
});
|
|
338
|
-
const isGlobalScope = resolveOwnRouteScope(route) === "global";
|
|
339
|
-
const isEnabledSurfaceRoute = enabledSurfaces.has(resolvedSurface);
|
|
340
|
-
const ownIncluded = isGlobalScope || isEnabledSurfaceRoute && (normalizedMode === allMode || resolvedSurface === normalizedMode);
|
|
341
|
-
const children = Array.isArray(route.children) ? route.children : [];
|
|
342
|
-
const filteredChildren = children.map((child) => filterRouteNode(child, resolvedSurface)).filter(Boolean);
|
|
343
|
-
if (!ownIncluded && filteredChildren.length < 1) return null;
|
|
344
|
-
if (children.length < 1) return route;
|
|
345
|
-
return {
|
|
346
|
-
...route,
|
|
347
|
-
children: filteredChildren
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
return normalizedRoutes.map((route) => filterRouteNode(route)).filter(Boolean);
|
|
351
|
-
}
|
|
352
|
-
//#endregion
|
|
353
|
-
//#region ../../../kernel/client/componentRegistry.js
|
|
354
|
-
function normalizeComponentId(value) {
|
|
355
|
-
const id = String(value || "").trim();
|
|
356
|
-
if (!id) throw new TypeError("Client component id is required.");
|
|
357
|
-
return id;
|
|
358
|
-
}
|
|
359
|
-
function createClientComponentRegistry() {
|
|
360
|
-
const components = /* @__PURE__ */ new Map();
|
|
361
|
-
function register(id, component) {
|
|
362
|
-
const componentId = normalizeComponentId(id);
|
|
363
|
-
if (component == null) throw new TypeError(`Client component "${componentId}" is required.`);
|
|
364
|
-
if (components.has(componentId)) throw new Error(`Client component "${componentId}" is duplicated.`);
|
|
365
|
-
components.set(componentId, component);
|
|
366
|
-
return api;
|
|
367
|
-
}
|
|
368
|
-
function has(id) {
|
|
369
|
-
return components.has(normalizeComponentId(id));
|
|
370
|
-
}
|
|
371
|
-
function get(id) {
|
|
372
|
-
const componentId = normalizeComponentId(id);
|
|
373
|
-
if (!components.has(componentId)) throw new Error(`Client component "${componentId}" is not registered.`);
|
|
374
|
-
return components.get(componentId);
|
|
375
|
-
}
|
|
376
|
-
function ids() {
|
|
377
|
-
return Object.freeze([...components.keys()].sort());
|
|
378
|
-
}
|
|
379
|
-
const api = Object.freeze({
|
|
380
|
-
register,
|
|
381
|
-
has,
|
|
382
|
-
get,
|
|
383
|
-
ids
|
|
384
|
-
});
|
|
385
|
-
return api;
|
|
386
|
-
}
|
|
387
|
-
//#endregion
|
|
388
|
-
//#region ../../../kernel/client/packageMetadataSections.js
|
|
389
|
-
function normalizePackageMetadataUiRoutes(value) {
|
|
390
|
-
const routeEntries = Array.isArray(value) ? value : [];
|
|
391
|
-
const normalizedRoutes = [];
|
|
392
|
-
for (const routeEntry of routeEntries) {
|
|
393
|
-
if (!isRecord(routeEntry)) continue;
|
|
394
|
-
try {
|
|
395
|
-
normalizedRoutes.push(Object.freeze(JSON.parse(JSON.stringify(routeEntry))));
|
|
396
|
-
} catch {}
|
|
397
|
-
}
|
|
398
|
-
return Object.freeze(normalizedRoutes);
|
|
399
|
-
}
|
|
400
|
-
function normalizePackageMetadataClientProviders(value) {
|
|
401
|
-
const entries = Array.isArray(value) ? value : [];
|
|
402
|
-
const providers = [];
|
|
403
|
-
for (const entry of entries) {
|
|
404
|
-
if (!isRecord(entry)) continue;
|
|
405
|
-
const exportName = String(entry.export || "").trim();
|
|
406
|
-
if (!exportName) continue;
|
|
407
|
-
providers.push(Object.freeze({
|
|
408
|
-
export: exportName,
|
|
409
|
-
entrypoint: String(entry.entrypoint || "").trim()
|
|
410
|
-
}));
|
|
411
|
-
}
|
|
412
|
-
return Object.freeze(providers);
|
|
413
|
-
}
|
|
414
|
-
//#endregion
|
|
415
|
-
//#region ../../../kernel/client/logging.js
|
|
416
|
-
function createStructuredLogger(logger = console) {
|
|
417
|
-
if (isRecord(logger)) return Object.freeze({
|
|
418
|
-
info: typeof logger.info === "function" ? logger.info.bind(logger) : console.info.bind(console),
|
|
419
|
-
warn: typeof logger.warn === "function" ? logger.warn.bind(logger) : console.warn.bind(console),
|
|
420
|
-
error: typeof logger.error === "function" ? logger.error.bind(logger) : console.error.bind(console),
|
|
421
|
-
debug: typeof logger.debug === "function" ? logger.debug.bind(logger) : () => {}
|
|
422
|
-
});
|
|
423
|
-
return Object.freeze({
|
|
424
|
-
info: console.info.bind(console),
|
|
425
|
-
warn: console.warn.bind(console),
|
|
426
|
-
error: console.error.bind(console),
|
|
427
|
-
debug: () => {}
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
function summarizeRouterRoutes(router) {
|
|
431
|
-
if (!router || typeof router.getRoutes !== "function") return Object.freeze([]);
|
|
432
|
-
return Object.freeze(router.getRoutes().map((route) => Object.freeze({
|
|
433
|
-
name: String(route?.name || "").trim(),
|
|
434
|
-
path: String(route?.path || "").trim(),
|
|
435
|
-
metaScope: String(route?.meta?.jskit?.scope || "").trim(),
|
|
436
|
-
metaSurface: String(route?.meta?.jskit?.surface || "").trim()
|
|
437
|
-
})));
|
|
438
|
-
}
|
|
439
|
-
//#endregion
|
|
440
|
-
//#region ../../../kernel/client/moduleBootstrap.js
|
|
441
|
-
function normalizePackageId(value) {
|
|
442
|
-
return String(value || "").trim();
|
|
443
|
-
}
|
|
444
|
-
function toRouteSnapshot(route) {
|
|
445
|
-
const metaJskit = isRecord(route?.meta?.jskit) ? route.meta.jskit : {};
|
|
446
|
-
return Object.freeze({
|
|
447
|
-
id: String(route?.id || "").trim(),
|
|
448
|
-
name: String(route?.name || "").trim(),
|
|
449
|
-
path: String(route?.path || "").trim(),
|
|
450
|
-
scope: String(route?.scope || "").trim(),
|
|
451
|
-
surface: String(route?.surface || "").trim(),
|
|
452
|
-
metaScope: String(metaJskit.scope || "").trim(),
|
|
453
|
-
metaSurface: String(metaJskit.surface || "").trim()
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
function isRouteComponent(value) {
|
|
457
|
-
if (typeof value === "function") return true;
|
|
458
|
-
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
459
|
-
}
|
|
460
|
-
function normalizeRoute(route, { packageId, index }) {
|
|
461
|
-
if (!isRecord(route)) throw new TypeError(`Client route #${index} from ${packageId} must be an object.`);
|
|
462
|
-
const id = String(route.id || "").trim();
|
|
463
|
-
const path = String(route.path || "").trim();
|
|
464
|
-
if (!id) throw new Error(`Client route #${index} from ${packageId} requires id.`);
|
|
465
|
-
if (!path || !path.startsWith("/") || path.startsWith("//")) throw new Error(`Client route "${id}" from ${packageId} must use an absolute path.`);
|
|
466
|
-
if (!isRouteComponent(route.component)) throw new Error(`Client route "${id}" from ${packageId} requires component.`);
|
|
467
|
-
const scope = String(route.scope || "surface").trim().toLowerCase();
|
|
468
|
-
if (scope !== "global" && scope !== "surface") throw new Error(`Client route "${id}" from ${packageId} has invalid scope "${scope}".`);
|
|
469
|
-
const surface = String(route.surface || "").trim().toLowerCase();
|
|
470
|
-
const baseMeta = isRecord(route.meta) ? route.meta : {};
|
|
471
|
-
const baseMetaJskit = isRecord(baseMeta.jskit) ? baseMeta.jskit : {};
|
|
472
|
-
return Object.freeze({
|
|
473
|
-
...route,
|
|
474
|
-
id,
|
|
475
|
-
path,
|
|
476
|
-
scope,
|
|
477
|
-
...surface ? { surface } : {},
|
|
478
|
-
meta: {
|
|
479
|
-
...baseMeta,
|
|
480
|
-
jskit: {
|
|
481
|
-
...baseMetaJskit,
|
|
482
|
-
packageId,
|
|
483
|
-
routeId: id,
|
|
484
|
-
scope,
|
|
485
|
-
...surface ? { surface } : {}
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
});
|
|
489
|
-
}
|
|
490
|
-
function normalizeRouteList(routes, { packageId }) {
|
|
491
|
-
return Object.freeze((Array.isArray(routes) ? routes : []).map((route, index) => normalizeRoute(route, {
|
|
492
|
-
packageId,
|
|
493
|
-
index: index + 1
|
|
494
|
-
})));
|
|
495
|
-
}
|
|
496
|
-
function toVueRouteRecord(route) {
|
|
497
|
-
const nextMeta = isRecord(route.meta) ? { ...route.meta } : void 0;
|
|
498
|
-
const routeRecord = {
|
|
499
|
-
path: route.path,
|
|
500
|
-
component: route.component,
|
|
501
|
-
...route.name ? { name: route.name } : {},
|
|
502
|
-
...route.props !== void 0 ? { props: route.props } : {},
|
|
503
|
-
...route.redirect !== void 0 ? { redirect: route.redirect } : {},
|
|
504
|
-
...route.children !== void 0 ? { children: route.children } : {},
|
|
505
|
-
...nextMeta ? { meta: nextMeta } : {}
|
|
506
|
-
};
|
|
507
|
-
return Object.freeze(routeRecord);
|
|
508
|
-
}
|
|
509
|
-
function registerClientModuleRoutes({ packageId, routes = [], router, surfaceRuntime, surfaceMode, seenRoutePaths, seenRouteNames, logger = null, source = "module", packageMetadataRouteDeclarations = null } = {}) {
|
|
510
|
-
const normalizedPackageId = normalizePackageId(packageId);
|
|
511
|
-
if (!normalizedPackageId) throw new TypeError("registerClientModuleRoutes requires packageId.");
|
|
512
|
-
if (!router || typeof router.addRoute !== "function") throw new TypeError("registerClientModuleRoutes requires router.addRoute().");
|
|
513
|
-
if (!surfaceRuntime || typeof surfaceRuntime !== "object") throw new TypeError("registerClientModuleRoutes requires surfaceRuntime.");
|
|
514
|
-
const normalizedRoutes = normalizeRouteList(routes, { packageId: normalizedPackageId });
|
|
515
|
-
assertRoutesDeclaredInPackageMetadata({
|
|
516
|
-
packageId: normalizedPackageId,
|
|
517
|
-
source,
|
|
518
|
-
normalizedRoutes,
|
|
519
|
-
packageMetadataRouteDeclarations
|
|
520
|
-
});
|
|
521
|
-
const activeRoutes = filterRoutesBySurface(normalizedRoutes, {
|
|
522
|
-
surfaceRuntime,
|
|
523
|
-
surfaceMode
|
|
524
|
-
});
|
|
525
|
-
const log = createStructuredLogger(logger);
|
|
526
|
-
log.debug({
|
|
527
|
-
packageId: normalizedPackageId,
|
|
528
|
-
source,
|
|
529
|
-
surfaceMode: String(surfaceMode || "").trim(),
|
|
530
|
-
declaredRoutes: normalizedRoutes.map(toRouteSnapshot),
|
|
531
|
-
activeRoutes: activeRoutes.map(toRouteSnapshot)
|
|
532
|
-
}, "Client route registration analysis.");
|
|
533
|
-
const declaredPaths = normalizedRoutes.map((route) => route.path);
|
|
534
|
-
const activePaths = activeRoutes.map((route) => route.path);
|
|
535
|
-
let registeredCount = 0;
|
|
536
|
-
for (const route of activeRoutes) {
|
|
537
|
-
const normalizedPath = String(route.path || "").trim();
|
|
538
|
-
if (seenRoutePaths.has(normalizedPath)) throw new Error(`Client route path "${normalizedPath}" is duplicated (package ${normalizedPackageId}).`);
|
|
539
|
-
const normalizedName = String(route.name || "").trim();
|
|
540
|
-
if (normalizedName) {
|
|
541
|
-
if (seenRouteNames.has(normalizedName)) throw new Error(`Client route name "${normalizedName}" is duplicated (package ${normalizedPackageId}).`);
|
|
542
|
-
seenRouteNames.add(normalizedName);
|
|
543
|
-
}
|
|
544
|
-
seenRoutePaths.add(normalizedPath);
|
|
545
|
-
router.addRoute(toVueRouteRecord(route));
|
|
546
|
-
log.debug({
|
|
547
|
-
packageId: normalizedPackageId,
|
|
548
|
-
source,
|
|
549
|
-
route: toRouteSnapshot(route)
|
|
550
|
-
}, "Added client route to router.");
|
|
551
|
-
registeredCount += 1;
|
|
552
|
-
}
|
|
553
|
-
return Object.freeze({
|
|
554
|
-
packageId: normalizedPackageId,
|
|
555
|
-
source,
|
|
556
|
-
declaredCount: normalizedRoutes.length,
|
|
557
|
-
registeredCount,
|
|
558
|
-
declaredPaths: Object.freeze(declaredPaths),
|
|
559
|
-
activePaths: Object.freeze(activePaths)
|
|
560
|
-
});
|
|
561
|
-
}
|
|
562
|
-
function resolvePackageMetadataProviders(moduleNamespace, packageId, packageMetadataClientProviders = []) {
|
|
563
|
-
const providers = [];
|
|
564
|
-
const seenProviderIds = /* @__PURE__ */ new Set();
|
|
565
|
-
for (const providerDeclaration of packageMetadataClientProviders) {
|
|
566
|
-
const exportName = String(providerDeclaration?.export || "").trim();
|
|
567
|
-
if (!exportName) continue;
|
|
568
|
-
const providerValue = moduleNamespace?.[exportName];
|
|
569
|
-
let provider = null;
|
|
570
|
-
try {
|
|
571
|
-
provider = defineProvider(providerValue);
|
|
572
|
-
} catch (error) {
|
|
573
|
-
throw new TypeError(`Client module ${packageId} packageMetadata provider export "${exportName}" must be a capability provider: ${error.message}`, { cause: error });
|
|
574
|
-
}
|
|
575
|
-
const providerId = provider.id;
|
|
576
|
-
if (seenProviderIds.has(providerId)) continue;
|
|
577
|
-
seenProviderIds.add(providerId);
|
|
578
|
-
providers.push(provider);
|
|
579
|
-
}
|
|
580
|
-
return providers;
|
|
581
|
-
}
|
|
582
|
-
function resolveModuleProviders(moduleNamespace, packageId, packageMetadataClientProviders = []) {
|
|
583
|
-
if (!isRecord(moduleNamespace)) return [];
|
|
584
|
-
return resolvePackageMetadataProviders(moduleNamespace, packageId, packageMetadataClientProviders);
|
|
585
|
-
}
|
|
586
|
-
function buildPackageMetadataRouteDeclarationIndex({ packageId, packageMetadataUiRoutes = [] } = {}) {
|
|
587
|
-
const normalizedPackageId = normalizePackageId(packageId);
|
|
588
|
-
const packageMetadataRoutes = normalizePackageMetadataUiRoutes(packageMetadataUiRoutes);
|
|
589
|
-
const byId = /* @__PURE__ */ new Map();
|
|
590
|
-
for (const packageMetadataRoute of packageMetadataRoutes) {
|
|
591
|
-
const routeId = String(packageMetadataRoute.id || "").trim();
|
|
592
|
-
const routePath = String(packageMetadataRoute.path || "").trim();
|
|
593
|
-
const routeScope = String(packageMetadataRoute.scope || "surface").trim().toLowerCase();
|
|
594
|
-
if (!routeId || !routePath) continue;
|
|
595
|
-
if (byId.has(routeId)) {
|
|
596
|
-
const existingRoute = byId.get(routeId);
|
|
597
|
-
if (existingRoute.path !== routePath || existingRoute.scope !== routeScope) throw new Error(`PackageMetadata ui routes for ${normalizedPackageId} define duplicate id "${routeId}" with conflicting declarations.`);
|
|
598
|
-
continue;
|
|
599
|
-
}
|
|
600
|
-
byId.set(routeId, Object.freeze({
|
|
601
|
-
id: routeId,
|
|
602
|
-
path: routePath,
|
|
603
|
-
scope: routeScope
|
|
604
|
-
}));
|
|
605
|
-
}
|
|
606
|
-
return Object.freeze({ byId });
|
|
607
|
-
}
|
|
608
|
-
function assertRoutesDeclaredInPackageMetadata({ packageId, source, normalizedRoutes = [], packageMetadataRouteDeclarations = null } = {}) {
|
|
609
|
-
if (String(source || "").trim() !== "clientRoutes") return;
|
|
610
|
-
const byId = packageMetadataRouteDeclarations?.byId instanceof Map ? packageMetadataRouteDeclarations.byId : /* @__PURE__ */ new Map();
|
|
611
|
-
const normalizedPackageId = normalizePackageId(packageId);
|
|
612
|
-
for (const route of normalizedRoutes) {
|
|
613
|
-
const routeId = String(route?.id || "").trim();
|
|
614
|
-
const routePath = String(route?.path || "").trim();
|
|
615
|
-
if (String(route?.scope || "surface").trim().toLowerCase() !== "global") continue;
|
|
616
|
-
const declaredRoute = byId.get(routeId);
|
|
617
|
-
if (!declaredRoute) throw new Error(`Global client route "${routeId}" from ${normalizedPackageId} (${source}) must be declared in metadata.ui.routes (id "${routeId}", path "${routePath}") with scope:"global" and autoRegister:false.`);
|
|
618
|
-
if (String(declaredRoute.path || "").trim() !== routePath) throw new Error(`Global client route "${routeId}" from ${normalizedPackageId} (${source}) path "${routePath}" does not match packageMetadata metadata.ui.routes path "${declaredRoute.path}".`);
|
|
619
|
-
if (String(declaredRoute.scope || "").trim().toLowerCase() !== "global") throw new Error(`Global client route "${routeId}" from ${normalizedPackageId} (${source}) must be declared with scope:"global" in metadata.ui.routes.`);
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
function resolvePackageMetadataClientRoutes({ packageId, packageMetadataUiRoutes = [], routeComponents = {}, logger = null } = {}) {
|
|
623
|
-
const normalizedPackageId = normalizePackageId(packageId);
|
|
624
|
-
const packageMetadataRoutes = normalizePackageMetadataUiRoutes(packageMetadataUiRoutes);
|
|
625
|
-
if (packageMetadataRoutes.length < 1) return Object.freeze([]);
|
|
626
|
-
if (!isRecord(routeComponents)) throw new TypeError(`Client module ${normalizedPackageId} declares packageMetadata ui routes but does not export a routeComponents map.`);
|
|
627
|
-
const log = createStructuredLogger(logger);
|
|
628
|
-
const routes = [];
|
|
629
|
-
const skippedRoutes = [];
|
|
630
|
-
for (const packageMetadataRoute of packageMetadataRoutes) {
|
|
631
|
-
const routeId = String(packageMetadataRoute.id || "").trim();
|
|
632
|
-
const routePath = String(packageMetadataRoute.path || "").trim();
|
|
633
|
-
if (!(packageMetadataRoute.autoRegister !== false)) {
|
|
634
|
-
skippedRoutes.push(Object.freeze({
|
|
635
|
-
id: routeId,
|
|
636
|
-
path: routePath,
|
|
637
|
-
reason: "autoRegister=false"
|
|
638
|
-
}));
|
|
639
|
-
continue;
|
|
640
|
-
}
|
|
641
|
-
if (!routeId || !routePath) throw new Error(`PackageMetadata ui route from ${normalizedPackageId} requires id and path when autoRegister is enabled.`);
|
|
642
|
-
const componentKey = String(packageMetadataRoute.componentKey || "").trim();
|
|
643
|
-
if (!componentKey) throw new Error(`PackageMetadata ui route "${routeId}" from ${normalizedPackageId} requires componentKey when autoRegister is enabled.`);
|
|
644
|
-
const routeComponent = routeComponents[componentKey];
|
|
645
|
-
if (!isRouteComponent(routeComponent)) throw new Error(`PackageMetadata ui route "${routeId}" from ${normalizedPackageId} references unknown routeComponents key "${componentKey}".`);
|
|
646
|
-
const scope = String(packageMetadataRoute.scope || "surface").trim().toLowerCase();
|
|
647
|
-
const surface = String(packageMetadataRoute.surface || "").trim().toLowerCase();
|
|
648
|
-
const guard = isRecord(packageMetadataRoute.guard) ? { ...packageMetadataRoute.guard } : {};
|
|
649
|
-
const baseMeta = isRecord(packageMetadataRoute.meta) ? { ...packageMetadataRoute.meta } : {};
|
|
650
|
-
const baseMetaJskit = isRecord(baseMeta.jskit) ? { ...baseMeta.jskit } : {};
|
|
651
|
-
routes.push(Object.freeze({
|
|
652
|
-
id: routeId,
|
|
653
|
-
path: routePath,
|
|
654
|
-
scope,
|
|
655
|
-
...surface ? { surface } : {},
|
|
656
|
-
...String(packageMetadataRoute.name || "").trim() ? { name: String(packageMetadataRoute.name || "").trim() } : {},
|
|
657
|
-
component: routeComponent,
|
|
658
|
-
meta: {
|
|
659
|
-
...baseMeta,
|
|
660
|
-
...Object.keys(guard).length > 0 ? { guard } : {},
|
|
661
|
-
jskit: {
|
|
662
|
-
...baseMetaJskit,
|
|
663
|
-
packageId: normalizedPackageId,
|
|
664
|
-
routeId,
|
|
665
|
-
scope,
|
|
666
|
-
componentKey,
|
|
667
|
-
source: "packageMetadata.ui.routes",
|
|
668
|
-
...surface ? { surface } : {}
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
}));
|
|
672
|
-
}
|
|
673
|
-
log.debug({
|
|
674
|
-
packageId: normalizedPackageId,
|
|
675
|
-
packageMetadataRouteCount: packageMetadataRoutes.length,
|
|
676
|
-
autoRegisterRouteCount: routes.length,
|
|
677
|
-
skippedRoutes
|
|
678
|
-
}, "Processed packageMetadata ui routes.");
|
|
679
|
-
return Object.freeze(routes);
|
|
680
|
-
}
|
|
681
|
-
function normalizeClientModuleEntries(clientModules) {
|
|
682
|
-
if (!Array.isArray(clientModules)) return [];
|
|
683
|
-
return clientModules.map((entry) => {
|
|
684
|
-
const packageId = normalizePackageId(entry?.packageId);
|
|
685
|
-
const moduleNamespace = isRecord(entry?.module) ? entry.module : null;
|
|
686
|
-
if (!packageId || !moduleNamespace) return null;
|
|
687
|
-
return Object.freeze({
|
|
688
|
-
packageId,
|
|
689
|
-
module: moduleNamespace,
|
|
690
|
-
packageMetadataUiRoutes: normalizePackageMetadataUiRoutes(entry?.packageMetadataUiRoutes),
|
|
691
|
-
packageMetadataClientProviders: normalizePackageMetadataClientProviders(entry?.packageMetadataClientProviders)
|
|
692
|
-
});
|
|
693
|
-
}).filter(Boolean).sort((left, right) => left.packageId.localeCompare(right.packageId));
|
|
694
|
-
}
|
|
695
|
-
function createClientRuntime({ profile = "client", providers = [], app, pinia = null, queryClient = null, router, env, logger, surfaceRuntime, surfaceMode } = {}) {
|
|
696
|
-
const components = createClientComponentRegistry();
|
|
697
|
-
const runtime = createCapabilityRuntime({
|
|
698
|
-
profile,
|
|
699
|
-
providers,
|
|
700
|
-
inputs: {
|
|
701
|
-
"client.vue": app || null,
|
|
702
|
-
"client.router": router || null,
|
|
703
|
-
"client.pinia": pinia,
|
|
704
|
-
"client.query": queryClient,
|
|
705
|
-
"client.env": Object.freeze({ ...isRecord(env) ? env : {} }),
|
|
706
|
-
"client.surface": surfaceRuntime || null,
|
|
707
|
-
"client.surface-mode": String(surfaceMode || "").trim(),
|
|
708
|
-
"client.logger": logger,
|
|
709
|
-
"client.components": components
|
|
710
|
-
}
|
|
711
|
-
});
|
|
712
|
-
return Object.freeze({
|
|
713
|
-
runtime,
|
|
714
|
-
components
|
|
715
|
-
});
|
|
716
|
-
}
|
|
717
|
-
async function bootClientModules({ clientModules = [], app, pinia = null, queryClient = null, router, surfaceRuntime, surfaceMode, env, logger = console } = {}) {
|
|
718
|
-
if (!router || typeof router.addRoute !== "function") throw new TypeError("bootClientModules requires router.addRoute().");
|
|
719
|
-
if (!surfaceRuntime || typeof surfaceRuntime.normalizeSurfaceMode !== "function") throw new TypeError("bootClientModules requires surfaceRuntime.normalizeSurfaceMode().");
|
|
720
|
-
const log = createStructuredLogger(logger);
|
|
721
|
-
const moduleEntries = normalizeClientModuleEntries(clientModules);
|
|
722
|
-
const providers = [];
|
|
723
|
-
const seenProviderIds = /* @__PURE__ */ new Set();
|
|
724
|
-
log.debug({
|
|
725
|
-
surfaceMode: String(surfaceMode || "").trim(),
|
|
726
|
-
normalizedSurfaceMode: String(surfaceRuntime.normalizeSurfaceMode(surfaceMode) || "").trim(),
|
|
727
|
-
moduleCount: moduleEntries.length,
|
|
728
|
-
modules: moduleEntries.map((entry) => entry.packageId)
|
|
729
|
-
}, "Starting JSKIT client module bootstrap.");
|
|
730
|
-
for (const entry of moduleEntries) {
|
|
731
|
-
const moduleProviders = resolveModuleProviders(entry.module, entry.packageId, entry.packageMetadataClientProviders);
|
|
732
|
-
log.debug({
|
|
733
|
-
packageId: entry.packageId,
|
|
734
|
-
providerExports: moduleProviders.map((provider) => provider.id),
|
|
735
|
-
hasClientRoutes: Array.isArray(entry.module.clientRoutes) && entry.module.clientRoutes.length > 0
|
|
736
|
-
}, "Discovered client module capabilities.");
|
|
737
|
-
for (const provider of moduleProviders) {
|
|
738
|
-
const providerId = provider.id;
|
|
739
|
-
if (seenProviderIds.has(providerId)) throw new Error(`Client provider id "${providerId}" is duplicated.`);
|
|
740
|
-
seenProviderIds.add(providerId);
|
|
741
|
-
providers.push(provider);
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
const clientRuntime = createClientRuntime({
|
|
745
|
-
profile: String(surfaceRuntime.normalizeSurfaceMode(surfaceMode) || "client"),
|
|
746
|
-
providers,
|
|
747
|
-
app,
|
|
748
|
-
pinia,
|
|
749
|
-
queryClient,
|
|
750
|
-
router,
|
|
751
|
-
env,
|
|
752
|
-
logger: log,
|
|
753
|
-
surfaceRuntime,
|
|
754
|
-
surfaceMode
|
|
755
|
-
});
|
|
756
|
-
await clientRuntime.runtime.start();
|
|
757
|
-
const seenRoutePaths = /* @__PURE__ */ new Set();
|
|
758
|
-
const seenRouteNames = /* @__PURE__ */ new Set();
|
|
759
|
-
const routeResults = [];
|
|
760
|
-
const registerRoutesForEntry = (routeList, packageId, source = "module", packageMetadataRouteDeclarations = null) => {
|
|
761
|
-
if (!routeList || routeList.length === 0) return null;
|
|
762
|
-
const result = registerClientModuleRoutes({
|
|
763
|
-
packageId,
|
|
764
|
-
routes: routeList,
|
|
765
|
-
router,
|
|
766
|
-
surfaceRuntime,
|
|
767
|
-
surfaceMode,
|
|
768
|
-
seenRoutePaths,
|
|
769
|
-
seenRouteNames,
|
|
770
|
-
logger: log,
|
|
771
|
-
source,
|
|
772
|
-
packageMetadataRouteDeclarations
|
|
773
|
-
});
|
|
774
|
-
log.debug({
|
|
775
|
-
packageId,
|
|
776
|
-
source,
|
|
777
|
-
declaredPaths: result.declaredPaths,
|
|
778
|
-
activePaths: result.activePaths,
|
|
779
|
-
registeredCount: result.registeredCount
|
|
780
|
-
}, "Registered client module routes.");
|
|
781
|
-
log.debug({
|
|
782
|
-
packageId,
|
|
783
|
-
source,
|
|
784
|
-
routerRoutes: summarizeRouterRoutes(router)
|
|
785
|
-
}, "Router route table after client route registration.");
|
|
786
|
-
routeResults.push(result);
|
|
787
|
-
return result;
|
|
788
|
-
};
|
|
789
|
-
for (const entry of moduleEntries) {
|
|
790
|
-
const packageMetadataRouteDeclarations = buildPackageMetadataRouteDeclarationIndex({
|
|
791
|
-
packageId: entry.packageId,
|
|
792
|
-
packageMetadataUiRoutes: entry.packageMetadataUiRoutes
|
|
793
|
-
});
|
|
794
|
-
registerRoutesForEntry(resolvePackageMetadataClientRoutes({
|
|
795
|
-
packageId: entry.packageId,
|
|
796
|
-
packageMetadataUiRoutes: entry.packageMetadataUiRoutes,
|
|
797
|
-
routeComponents: entry.module.routeComponents,
|
|
798
|
-
logger: log
|
|
799
|
-
}), entry.packageId, "packageMetadata.ui.routes", packageMetadataRouteDeclarations);
|
|
800
|
-
registerRoutesForEntry(Array.isArray(entry.module.clientRoutes) ? entry.module.clientRoutes : [], entry.packageId, "clientRoutes", packageMetadataRouteDeclarations);
|
|
801
|
-
}
|
|
802
|
-
const registeredRouteCount = routeResults.reduce((sum, result) => sum + result.registeredCount, 0);
|
|
803
|
-
if (moduleEntries.length > 0) {
|
|
804
|
-
log.debug({
|
|
805
|
-
modules: moduleEntries.map((entry) => entry.packageId),
|
|
806
|
-
providerCount: providers.length,
|
|
807
|
-
routeCount: registeredRouteCount
|
|
808
|
-
}, "Booted JSKIT client modules.");
|
|
809
|
-
log.debug({
|
|
810
|
-
routerRoutes: summarizeRouterRoutes(router),
|
|
811
|
-
currentPath: typeof window !== "undefined" ? String(window.location?.pathname || "") : ""
|
|
812
|
-
}, "JSKIT client bootstrap final route table.");
|
|
813
|
-
}
|
|
814
|
-
return Object.freeze({
|
|
815
|
-
runtime: clientRuntime.runtime,
|
|
816
|
-
components: clientRuntime.components,
|
|
817
|
-
modules: Object.freeze(moduleEntries.map((entry) => entry.packageId)),
|
|
818
|
-
providerCount: providers.length,
|
|
819
|
-
routeResults: Object.freeze(routeResults),
|
|
820
|
-
routeCount: registeredRouteCount
|
|
821
|
-
});
|
|
822
|
-
}
|
|
823
|
-
//#endregion
|
|
824
|
-
export { bootClientModules };
|