@modular-vue/journeys 1.0.0

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/provider.ts","../src/use-journey-state.ts","../src/instance-hooks.ts","../src/mount-adapter.ts","../src/outlet.ts","../src/journey-host.ts","../src/use-journey-sync.ts","../src/module-tab.ts","../src/use-wait-for-exit.ts","../src/plugin.ts"],"mappings":";;;;;;;;;AAiBA;;;;;;;;UAAiB,oBAAA;EASgC;EAAA,SAPtC,OAAA,EAAS,gBAAA;EAeP;;;;AAA6C;AAsB1D;EAtBa,SARF,YAAA,IAAgB,KAAA,EAAO,eAAe;AAAA;;;;;;cAQpC,UAAA,EAAY,YAAY,CAAC,oBAAA;;;;;;;;;;;;;;;;;;;;;cAsBzB,eAAA,gBAAe,eAAA,eAAA,gBAAA;;UAIG,QAAA,CAAS,gBAAA;;;;UAEF,QAAA,CAAS,iBAAA;;;;;;;UAFhB,QAAA,CAAS,gBAAA;;;;UAEF,QAAA,CAAS,iBAAA;;;;;;;iBAmB/B,iBAAA,IAAqB,oBAAoB;;;;;;;AAhEzD;;;;;;;;;iBCEgB,eAAA,SACd,UAAA,EAAY,gBAAA,CAAiB,YAAA,WAC5B,WAAA,CAAY,MAAA;ADKkC;AAQjD;;;;AAA0D;AAsB1D;;AA9BiD,iBCQjC,kBAAA,CACd,UAAA,EAAY,gBAAA,CAAiB,YAAA,WAC5B,UAAA,CAAW,iBAAA;;;;;;;;;;;iBAeE,yBAAA,SACd,cAAA,EAAgB,gBAAA,CAAiB,YAAA,WAChC,WAAA,CAAY,MAAA;;;;;;;;;;;;iBAgBC,4BAAA,CACd,cAAA,EAAgB,gBAAA,CAAiB,YAAA,WAChC,UAAA,CAAW,iBAAA;;;;;;;ADtDd;;;;;;;;;;AASiD;AAQjD;;;;AAA0D;iBEY1C,mBAAA,CACd,OAAA,EAAS,gBAAA,SACT,UA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SAAA;IAAA,SACA,UAAA,IAAc,GAAA;EAAA;AAAA;;;;;;KASf,qBAAA,kBAAuC,kBAAA,KACjD,QAAA,EAAU,qBAAA,EACV,GAAA,EAAK,wBAAA;EAAA,SAA6C,SAAA;AAAA,MAC/C,QAAA;AAAA,UAEY,qBAAA,kBACE,kBAAA,GAAqB,qBAAA;;;;;WAM7B,KAAA;;;;;;;;WAQA,YAAA,GAAe,iBAAA;;;;;ATnB1B;;;;AAAyD;WS6B9C,YAAA,GAAe,qBAAA,CAAsB,QAAA;AAAA;;AR3FhD;;;;;;;;;;;;;;;;AAEqB;AAarB;;iBQmGgB,cAAA,kBAAgC,kBAAA,GAAqB,qBAAA,EACnE,OAAA,GAAS,qBAAA,CAAsB,QAAA,IAC9B,cAAA,aAA2B,uBAAA,EAAyB,gBAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,690 @@
1
+ import { Suspense as e, computed as t, defineComponent as n, h as r, inject as i, onErrorCaptured as a, onMounted as o, onUnmounted as s, provide as c, ref as l, shallowRef as u, toRaw as d, toValue as f, watch as p, watchEffect as m } from "vue";
2
+ import { ModuleErrorBoundary as h, ModuleExitProvider as g, resolveEntryComponent as _, useModuleExit as v } from "@modular-vue/vue";
3
+ import { JourneyHydrationError as y, JourneyValidationError as b, JourneyValidationError as x, UnknownJourneyError as S, createJourneyRuntime as ee, createJourneyRuntime as te, createJourneySync as ne, createJourneySync as re, createMemoryJourneySyncPort as ie, createMemoryPersistence as ae, createWebStoragePersistence as oe, defaultStepPath as se, defaultStepPath as ce, defineJourney as le, defineJourneyHandle as ue, defineJourneyPersistence as de, defineTransition as fe, getInternals as pe, invoke as me, isAnnotatedTransition as he, isAnnotatedTransition as C, isTerminalSentinel as ge, journeyStepPath as w, resolveJourneySyncAction as T, selectModule as E, selectModuleOrDefault as D, validateJourneyContracts as O, validateJourneyContracts as k, validateJourneyDefinition as A, validateJourneyDefinition as j, validateJourneyGraph as M } from "@modular-frontend/journeys-engine";
4
+ import { SemverParseError as N, compareVersions as P, isDevEnv as F, isJourneySystemAbort as I, satisfies as L } from "@modular-frontend/core";
5
+ //#region src/provider.ts
6
+ var R = Symbol("modular-vue.journey"), z = n({
7
+ name: "JourneyProvider",
8
+ props: {
9
+ runtime: {
10
+ type: Object,
11
+ required: !0
12
+ },
13
+ onModuleExit: {
14
+ type: Function,
15
+ default: void 0
16
+ }
17
+ },
18
+ setup(e, { slots: t }) {
19
+ return c(R, {
20
+ runtime: e.runtime,
21
+ get onModuleExit() {
22
+ return e.onModuleExit;
23
+ }
24
+ }), () => r(g, { onExit: e.onModuleExit }, () => t.default?.());
25
+ }
26
+ });
27
+ function B() {
28
+ return i(R, null);
29
+ }
30
+ //#endregion
31
+ //#region src/instance-hooks.ts
32
+ var _e = 64, V = Object.freeze([]);
33
+ function H(e, t) {
34
+ let n = u(null), r = () => {
35
+ let n = f(t);
36
+ return !e || !n ? null : e.getInstance(n);
37
+ };
38
+ return m((i) => {
39
+ let a = f(t);
40
+ if (!e || !a) {
41
+ n.value = null;
42
+ return;
43
+ }
44
+ n.value = e.getInstance(a), i(e.subscribe(a, () => {
45
+ n.value = r();
46
+ }));
47
+ }), n;
48
+ }
49
+ function U(e, t, n) {
50
+ let r = u(V), i = null, a = (e) => {
51
+ let t = e.join(">");
52
+ i !== t && (i = t, r.value = e.length === 0 ? V : e);
53
+ };
54
+ return m((r) => {
55
+ let i = f(t), o = f(n);
56
+ if (!e || !i) {
57
+ a(V);
58
+ return;
59
+ }
60
+ let s = /* @__PURE__ */ new Map(), c = !1, l = () => {
61
+ if (c) return;
62
+ let t = /* @__PURE__ */ new Set(), n = [], r = i, u = 0;
63
+ for (; r && u < _e && !t.has(r);) {
64
+ t.add(r), n.push(r), s.has(r) || s.set(r, e.subscribe(r, l));
65
+ let i = e.getInstance(r);
66
+ r = o && i ? i.activeChildId : null, u += 1;
67
+ }
68
+ for (let [e, n] of s) t.has(e) || (n(), s.delete(e));
69
+ a(n);
70
+ };
71
+ l(), r(() => {
72
+ c = !0;
73
+ for (let e of s.values()) e();
74
+ s.clear();
75
+ });
76
+ }), r;
77
+ }
78
+ function W(e, n, r) {
79
+ let i = U(e, n, r);
80
+ return t(() => i.value[i.value.length - 1] ?? f(n));
81
+ }
82
+ //#endregion
83
+ //#region src/use-journey-state.ts
84
+ function ve(e) {
85
+ let n = G(e);
86
+ return t(() => n.value ? n.value.state : null);
87
+ }
88
+ function G(e) {
89
+ return H(B()?.runtime ?? null, e);
90
+ }
91
+ function ye(e) {
92
+ let n = K(e);
93
+ return t(() => n.value ? n.value.state : null);
94
+ }
95
+ function K(e) {
96
+ let t = B()?.runtime ?? null;
97
+ return H(t, W(t, e, !0));
98
+ }
99
+ var q = n({
100
+ name: "JourneyOutlet",
101
+ props: {
102
+ runtime: {
103
+ type: Object,
104
+ default: void 0
105
+ },
106
+ instanceId: {
107
+ type: String,
108
+ required: !0
109
+ },
110
+ modules: {
111
+ type: Object,
112
+ default: void 0
113
+ },
114
+ loadingFallback: {
115
+ type: null,
116
+ default: void 0
117
+ },
118
+ onFinished: {
119
+ type: Function,
120
+ default: void 0
121
+ },
122
+ onStepError: {
123
+ type: Function,
124
+ default: void 0
125
+ },
126
+ leafOnly: {
127
+ type: Boolean,
128
+ default: !0
129
+ },
130
+ retryLimit: {
131
+ type: Number,
132
+ default: 2
133
+ },
134
+ notFoundComponent: {
135
+ type: Object,
136
+ default: void 0
137
+ },
138
+ errorComponent: {
139
+ type: Object,
140
+ default: void 0
141
+ },
142
+ preload: {
143
+ type: [Boolean, String],
144
+ default: "precise"
145
+ }
146
+ },
147
+ setup(n) {
148
+ let a = i(R, null), c = d(n.runtime ?? a?.runtime ?? void 0) ?? null;
149
+ if (!c) throw Error("[@modular-vue/journeys] <JourneyOutlet> needs a runtime. Either pass `runtime` or mount a <JourneyProvider>.");
150
+ let u = pe(c), f = () => d(n.modules ?? u.__moduleMap), m = H(c, () => n.instanceId), h = W(c, () => n.instanceId, () => n.leafOnly), g = H(c, h), v = t(() => h.value === n.instanceId ? m.value : g.value), y = l(0);
151
+ s(() => {
152
+ let e = n.instanceId;
153
+ queueMicrotask(() => {
154
+ let t = u.__getRecord(e);
155
+ t && (t.status !== "active" && t.status !== "loading" || t.listeners.size > 0 || c.end(e, { reason: "unmounted" }, { force: !0 }));
156
+ });
157
+ });
158
+ let b = /* @__PURE__ */ new Set();
159
+ return p(m, (e) => {
160
+ e && (e.status !== "completed" && e.status !== "aborted" || b.has(e.id) || (b.add(e.id), n.onFinished?.({
161
+ status: e.status,
162
+ payload: e.terminalPayload,
163
+ instanceId: e.id,
164
+ journeyId: e.journeyId
165
+ })));
166
+ }, { immediate: !0 }), o(() => {
167
+ p(() => {
168
+ let e = v.value;
169
+ return [
170
+ n.preload,
171
+ e?.status === "active",
172
+ e?.step?.moduleId,
173
+ e?.step?.entry,
174
+ e?.journeyId
175
+ ];
176
+ }, ([e, t, n, r, i], a, o) => {
177
+ if (e === !1 || !t || !n || !r || !i) return;
178
+ let s = u.__getRegistered(i);
179
+ if (!s) return;
180
+ let c = e === "aggressive" ? "aggressive" : "precise", l = be(s.definition, f(), n, r, c);
181
+ if (l.length === 0) return;
182
+ let d = !1, p = () => {
183
+ if (!d) for (let e of l) try {
184
+ _(e).preload().catch(() => {});
185
+ } catch {}
186
+ }, m = globalThis.requestIdleCallback, h = globalThis.cancelIdleCallback, g, v;
187
+ typeof m == "function" ? g = m(p, { timeout: 2e3 }) : v = setTimeout(p, 0), o(() => {
188
+ d = !0, g !== void 0 && typeof h == "function" && h(g), v !== void 0 && clearTimeout(v);
189
+ });
190
+ }, { immediate: !0 });
191
+ }), () => {
192
+ let t = v.value;
193
+ if (!t) return null;
194
+ if (t.status === "loading") {
195
+ let e = n.loadingFallback;
196
+ return (typeof e == "function" ? e() : e) ?? null;
197
+ }
198
+ if (t.status === "completed" || t.status === "aborted") return null;
199
+ let i = t.step;
200
+ if (!i) return null;
201
+ let a = f()[i.moduleId], o = a?.entryPoints?.[i.entry];
202
+ if (!a || !o) return r(n.notFoundComponent ?? Se, {
203
+ moduleId: i.moduleId,
204
+ entry: i.entry
205
+ });
206
+ if (!xe(o)) return r(n.errorComponent ?? J, {
207
+ moduleId: i.moduleId,
208
+ error: /* @__PURE__ */ Error(`[@modular-vue/journeys] Entry "${i.moduleId}.${i.entry}" declares mountKinds=${JSON.stringify(o.mountKinds)} which does not include "journey". Journey steps cannot mount composition-only entries — either widen the entry's mountKinds, or pick a different module-entry in the transition.`)
209
+ });
210
+ let s = u.__getRecord(t.id), l = u.__getRegistered(t.journeyId);
211
+ if (!s || !l) return null;
212
+ let { exit: d, goBack: p, goForward: m } = u.__bindStepCallbacks(s, l), h = (e) => {
213
+ u.__fireComponentError(t.id, e, i);
214
+ let r = n.onStepError?.(e, { step: i }) ?? "abort";
215
+ if (r === "retry" && (u.__consumeRetry(t.id, n.retryLimit) || (r = "abort")), r === "abort") {
216
+ c.end(t.id, {
217
+ reason: "component-error",
218
+ error: e
219
+ });
220
+ return;
221
+ }
222
+ r === "retry" && (y.value += 1);
223
+ }, { Component: g } = _(o), b = `${s.stepToken}:${y.value}`, x = o.fallback, S = n.loadingFallback;
224
+ return r(Ce, {
225
+ key: b,
226
+ moduleId: i.moduleId,
227
+ onError: h,
228
+ errorComponent: n.errorComponent
229
+ }, () => r(e, null, {
230
+ default: () => r(g, {
231
+ input: i.input,
232
+ exit: d,
233
+ goBack: p,
234
+ goForward: m
235
+ }),
236
+ fallback: () => {
237
+ let e = x ?? S;
238
+ return (typeof e == "function" ? e() : e) ?? null;
239
+ }
240
+ }));
241
+ };
242
+ }
243
+ });
244
+ function be(e, t, n, r, i) {
245
+ let a = /* @__PURE__ */ new Set(), o = [], s = e.transitions;
246
+ if (!s) return o;
247
+ let c = (e, i) => {
248
+ if (!e || !i || e === n && i === r) return;
249
+ let s = `${e} ${i}`;
250
+ if (a.has(s)) return;
251
+ a.add(s);
252
+ let c = t[e]?.entryPoints?.[i];
253
+ c && o.push(c);
254
+ };
255
+ if (i === "precise") {
256
+ let e = s[n]?.[r];
257
+ if (!e) return o;
258
+ for (let t of Object.values(e)) if (C(t)) for (let e of t.targets) typeof e != "string" && c(e.module, e.entry);
259
+ return o;
260
+ }
261
+ for (let [e, t] of Object.entries(s)) if (t) {
262
+ for (let [n, r] of Object.entries(t)) if (c(e, n), r) {
263
+ for (let e of Object.values(r)) if (C(e)) for (let t of e.targets) typeof t != "string" && c(t.module, t.entry);
264
+ }
265
+ }
266
+ return o;
267
+ }
268
+ function xe(e) {
269
+ return Array.isArray(e.mountKinds) ? e.mountKinds.includes("journey") : !0;
270
+ }
271
+ var Se = n({
272
+ name: "JourneyOutletNotFound",
273
+ props: {
274
+ moduleId: {
275
+ type: String,
276
+ required: !0
277
+ },
278
+ entry: {
279
+ type: String,
280
+ required: !0
281
+ }
282
+ },
283
+ setup(e) {
284
+ return () => r("div", { style: {
285
+ padding: "1rem",
286
+ color: "#c53030"
287
+ } }, `Journey outlet: no entry "${e.moduleId}.${e.entry}" on the registered modules.`);
288
+ }
289
+ }), J = n({
290
+ name: "JourneyOutletError",
291
+ props: {
292
+ moduleId: {
293
+ type: String,
294
+ required: !0
295
+ },
296
+ error: {
297
+ type: null,
298
+ default: void 0
299
+ }
300
+ },
301
+ setup(e) {
302
+ return () => {
303
+ let t = e.error, n = t instanceof Error ? t.message : String(t);
304
+ return r("div", {
305
+ style: {
306
+ padding: "1rem",
307
+ border: "1px solid #e53e3e",
308
+ borderRadius: "0.5rem",
309
+ margin: "1rem"
310
+ },
311
+ role: "alert",
312
+ "data-journey-step-error": e.moduleId
313
+ }, [r("h3", { style: {
314
+ color: "#e53e3e",
315
+ margin: "0 0 0.5rem 0"
316
+ } }, `Module "${e.moduleId}" encountered an error`), r("pre", { style: {
317
+ fontSize: "0.875rem",
318
+ color: "#718096",
319
+ whiteSpace: "pre-wrap"
320
+ } }, n)]);
321
+ };
322
+ }
323
+ }), Ce = n({
324
+ name: "JourneyStepErrorBoundary",
325
+ props: {
326
+ moduleId: {
327
+ type: String,
328
+ required: !0
329
+ },
330
+ onError: {
331
+ type: Function,
332
+ required: !0
333
+ },
334
+ errorComponent: {
335
+ type: Object,
336
+ default: void 0
337
+ }
338
+ },
339
+ setup(e, { slots: t }) {
340
+ let n = l(null);
341
+ return a((t) => (n.value = t, e.onError(t), !1)), () => n.value == null ? t.default?.() : r(e.errorComponent ?? J, {
342
+ moduleId: e.moduleId,
343
+ error: n.value
344
+ });
345
+ }
346
+ });
347
+ function we(e, t) {
348
+ return U(e, t, !0);
349
+ }
350
+ //#endregion
351
+ //#region src/mount-adapter.ts
352
+ function Y(e) {
353
+ return {
354
+ start(t, n) {
355
+ return e.start(t, n);
356
+ },
357
+ end(t) {
358
+ e.end(t, { reason: "adapter-end" });
359
+ },
360
+ Outlet: n({
361
+ name: "JourneyMountAdapterOutlet",
362
+ props: {
363
+ instanceId: {
364
+ type: String,
365
+ required: !0
366
+ },
367
+ loadingFallback: {
368
+ type: null,
369
+ default: void 0
370
+ }
371
+ },
372
+ setup(t) {
373
+ return () => r(q, {
374
+ runtime: e,
375
+ instanceId: t.instanceId,
376
+ loadingFallback: t.loadingFallback
377
+ });
378
+ }
379
+ })
380
+ };
381
+ }
382
+ //#endregion
383
+ //#region src/journey-host.ts
384
+ var X = /* @__PURE__ */ new WeakMap();
385
+ function Z(e) {
386
+ let t = X.get(e);
387
+ return t || (t = /* @__PURE__ */ new Map(), X.set(e, t)), t;
388
+ }
389
+ function Q(e, n, r = {}) {
390
+ let i = B(), a = d(r.runtime ?? i?.runtime ?? void 0) ?? null;
391
+ if (!a) throw Error("[@modular-vue/journeys] useJourneyHost needs a runtime. Either pass `runtime` or mount a <JourneyProvider>.");
392
+ let c = u(null), l = Symbol("journey-host");
393
+ o(() => {
394
+ let t = a.start(e.id, n);
395
+ c.value = t;
396
+ let r = Z(a), i = r.get(t);
397
+ i || (i = /* @__PURE__ */ new Set(), r.set(t, i)), i.add(l);
398
+ }), s(() => {
399
+ let e = c.value;
400
+ if (!e) return;
401
+ c.value = null;
402
+ let t = Z(a);
403
+ queueMicrotask(() => {
404
+ let n = t.get(e);
405
+ n && (n.delete(l), !(n.size > 0) && (t.delete(e), a.end(e, { reason: "unmounted" }, { force: !0 }), a.forget(e)));
406
+ });
407
+ });
408
+ let f = H(a, c);
409
+ return {
410
+ instanceId: c,
411
+ instance: f,
412
+ runtime: a,
413
+ stepIndex: t(() => f.value ? f.value.history.length : 0)
414
+ };
415
+ }
416
+ function Te(e) {
417
+ return e.loadingFallback ?? e["loading-fallback"];
418
+ }
419
+ var Ee = n({
420
+ name: "JourneyHost",
421
+ inheritAttrs: !1,
422
+ props: {
423
+ handle: {
424
+ type: Object,
425
+ required: !0
426
+ },
427
+ input: {
428
+ type: null,
429
+ default: void 0
430
+ },
431
+ runtime: {
432
+ type: Object,
433
+ default: void 0
434
+ }
435
+ },
436
+ setup(e, { slots: t, attrs: n }) {
437
+ let { instanceId: i, instance: a, runtime: o, stepIndex: s } = Q(e.handle, e.input, { runtime: e.runtime });
438
+ return () => {
439
+ let e = i.value, c = a.value;
440
+ if (!e || !c) {
441
+ let e = Te(n);
442
+ return e ? typeof e == "function" ? e() : e : null;
443
+ }
444
+ let l = r(q, {
445
+ ...n,
446
+ runtime: o,
447
+ instanceId: e
448
+ }), u = t.default;
449
+ return u ? u({
450
+ instanceId: e,
451
+ instance: c,
452
+ stepIndex: s.value,
453
+ outlet: l
454
+ }) : l;
455
+ };
456
+ }
457
+ });
458
+ //#endregion
459
+ //#region src/use-journey-sync.ts
460
+ function De(e, t, n = {}) {
461
+ let r = B(), i = d(f(n).runtime ?? r?.runtime ?? void 0) ?? null, a = {
462
+ port: f(t),
463
+ options: f(n)
464
+ };
465
+ m(() => {
466
+ a.port = f(t), a.options = f(n);
467
+ });
468
+ let o = {
469
+ read: () => a.port.read(),
470
+ push: (e) => a.port.push(e),
471
+ replace: (e) => a.port.replace(e),
472
+ get go() {
473
+ return a.port.go ? (e) => a.port.go?.(e) : void 0;
474
+ },
475
+ subscribe: (e) => a.port.subscribe(e)
476
+ };
477
+ p(() => f(e), (e, t, n) => {
478
+ if (!i || !e) return;
479
+ let r = a.options.stepToPath ?? ce, s = re(i, e, o, {
480
+ stepToPath: r,
481
+ onUnresolved: (e) => a.options.onUnresolved?.(e),
482
+ onBlocked: (e) => a.options.onBlocked?.(e)
483
+ });
484
+ n(() => s.stop());
485
+ }, { immediate: !0 });
486
+ }
487
+ //#endregion
488
+ //#region src/module-tab.ts
489
+ function Oe(e, t) {
490
+ let n = e.entryPoints, r = n ? Object.keys(n) : [], i = t, a = null;
491
+ return t === void 0 ? r.length === 1 ? i = r[0] : r.length > 1 && (a = `Module "${e.id}" exposes multiple entries (${r.join(", ")}); pass the \`entry\` prop to disambiguate.`) : n && !Object.prototype.hasOwnProperty.call(n, t) ? a = `Module "${e.id}" has no entry "${t}". Registered: ${r.join(", ") || "(none)"}.` : n || (i = void 0, a = `Module "${e.id}" has no entry points; \`entry="${t}"\` cannot be resolved.`), {
492
+ resolvedName: i,
493
+ missingEntryNotice: a
494
+ };
495
+ }
496
+ function $(e) {
497
+ return r("div", { style: {
498
+ padding: "1rem",
499
+ color: "#c53030"
500
+ } }, e);
501
+ }
502
+ var ke = n({
503
+ name: "ModuleTab",
504
+ inheritAttrs: !1,
505
+ props: {
506
+ module: {
507
+ type: Object,
508
+ required: !0
509
+ },
510
+ entry: {
511
+ type: String,
512
+ default: void 0
513
+ },
514
+ tabId: {
515
+ type: String,
516
+ default: void 0
517
+ },
518
+ onExit: {
519
+ type: Function,
520
+ default: void 0
521
+ }
522
+ },
523
+ setup(n, { attrs: i }) {
524
+ let a = () => d(n.module), o = t(() => Oe(a(), n.entry)), s = v(() => n.module.id, () => o.value.resolvedName ?? "", {
525
+ tabId: () => n.tabId,
526
+ localOnExit: () => n.onExit
527
+ });
528
+ return () => {
529
+ let t = a(), { resolvedName: c, missingEntryNotice: l } = o.value, u = c ? t.entryPoints?.[c] : void 0, d;
530
+ if (l) d = $(l);
531
+ else if (u) {
532
+ let n = "input" in i, a = i.input;
533
+ if (a === void 0 && !n) d = $(`Module "${t.id}" entry "${c ?? ""}" was rendered without an \`input\` prop. Pass \`input={undefined}\` explicitly if the entry accepts no input.`);
534
+ else {
535
+ let { Component: t } = _(u), n = u.fallback;
536
+ d = r(e, null, {
537
+ default: () => r(t, {
538
+ input: a,
539
+ exit: s
540
+ }),
541
+ fallback: () => typeof n == "function" ? n() : n ?? null
542
+ });
543
+ }
544
+ } else if (t.component) {
545
+ let e = t.component, a = i.input;
546
+ d = r(e, {
547
+ input: a,
548
+ tabId: n.tabId
549
+ });
550
+ } else d = $(`Module "${t.id}" has no entry points and no component.`);
551
+ return r(h, { moduleId: t.id }, () => d);
552
+ };
553
+ }
554
+ });
555
+ //#endregion
556
+ //#region src/use-wait-for-exit.ts
557
+ function Ae(e, t) {
558
+ let n = {
559
+ exit: void 0,
560
+ subscribe: void 0,
561
+ pollCheck: void 0,
562
+ timeoutFire: void 0
563
+ };
564
+ m(() => {
565
+ let r = f(t);
566
+ n.exit = f(e), n.subscribe = r.subscribe, n.pollCheck = r.poll?.check, n.timeoutFire = r.timeout?.fire;
567
+ });
568
+ let r = (e) => {
569
+ let r = f(t), i = r.subscribe != null, a = r.poll != null, o = r.timeout != null, s = r.poll?.intervalMs, c = r.timeout?.ms, l = !1, u = [], d = (e) => {
570
+ try {
571
+ e();
572
+ } catch (e) {
573
+ F() && console.warn("[useWaitForExit] channel teardown threw:", e);
574
+ }
575
+ }, p = () => {
576
+ let e = u.splice(0);
577
+ for (let t of e) d(t);
578
+ }, m = ((e, ...t) => {
579
+ l || (l = !0, p(), n.exit?.(e, ...t));
580
+ }), h = (e) => {
581
+ l ? d(e) : u.push(e);
582
+ };
583
+ if (i) {
584
+ let e = n.subscribe?.(m);
585
+ typeof e == "function" && h(e);
586
+ }
587
+ if (!l && a && s !== void 0 && s > 0) {
588
+ let e = setInterval(() => {
589
+ if (!l) try {
590
+ let e = n.pollCheck?.(m);
591
+ e && typeof e.then == "function" && Promise.resolve(e).catch(() => {});
592
+ } catch {}
593
+ }, s);
594
+ h(() => clearInterval(e));
595
+ }
596
+ if (!l && o && c !== void 0 && c > 0) {
597
+ let e = setTimeout(() => {
598
+ if (l) return;
599
+ let e = n.timeoutFire;
600
+ typeof e == "string" ? m(e) : typeof e == "function" && e(m);
601
+ }, c);
602
+ h(() => clearTimeout(e));
603
+ }
604
+ e(() => {
605
+ l = !0, p();
606
+ });
607
+ };
608
+ p(() => {
609
+ let e = f(t), n = e.timeout && typeof e.timeout.fire == "string" ? e.timeout.fire : void 0;
610
+ return [
611
+ e.subscribe != null,
612
+ e.poll != null,
613
+ e.timeout != null,
614
+ e.poll?.intervalMs,
615
+ e.timeout?.ms,
616
+ n
617
+ ].join("|");
618
+ }, (e, t, n) => {
619
+ r(n);
620
+ }, { immediate: !0 });
621
+ }
622
+ //#endregion
623
+ //#region src/plugin.ts
624
+ function je(e = {}) {
625
+ let t = [];
626
+ return {
627
+ name: "journeys",
628
+ extend() {
629
+ return { registerJourney(e, n) {
630
+ let r = e, i = j(r);
631
+ if (i.length > 0) throw new x(i);
632
+ t.push({
633
+ definition: r,
634
+ options: n
635
+ });
636
+ } };
637
+ },
638
+ validate({ modules: e }) {
639
+ t.length > 0 && k(t, e);
640
+ },
641
+ onResolve({ moduleDescriptors: n, debug: r }) {
642
+ return te(t, {
643
+ modules: n,
644
+ debug: e.debug ?? r
645
+ });
646
+ },
647
+ contributeNavigation() {
648
+ let n = [];
649
+ for (let r of t) {
650
+ let t = r.options?.nav;
651
+ if (!t) continue;
652
+ let i = {
653
+ label: t.label,
654
+ to: "",
655
+ ...t.icon === void 0 ? {} : { icon: t.icon },
656
+ ...t.group === void 0 ? {} : { group: t.group },
657
+ ...t.order === void 0 ? {} : { order: t.order },
658
+ ...t.hidden === void 0 ? {} : { hidden: t.hidden },
659
+ ...t.meta === void 0 ? {} : { meta: t.meta },
660
+ action: {
661
+ kind: "journey-start",
662
+ journeyId: r.definition.id,
663
+ ...t.buildInput ? { buildInput: t.buildInput } : {}
664
+ }
665
+ };
666
+ e.buildNavItem ? n.push(e.buildNavItem(i, {
667
+ ...t,
668
+ journeyId: r.definition.id
669
+ })) : n.push(i);
670
+ }
671
+ return n;
672
+ },
673
+ providers({ runtime: t }) {
674
+ let i = e.onModuleExit;
675
+ return [n({
676
+ name: "JourneysPluginProvider",
677
+ setup(e, { slots: n }) {
678
+ return () => r(z, {
679
+ runtime: t,
680
+ onModuleExit: i
681
+ }, () => n.default?.());
682
+ }
683
+ })];
684
+ }
685
+ };
686
+ }
687
+ //#endregion
688
+ export { Ee as JourneyHost, y as JourneyHydrationError, q as JourneyOutlet, z as JourneyProvider, b as JourneyValidationError, ke as ModuleTab, N as SemverParseError, S as UnknownJourneyError, P as compareVersions, Y as createJourneyMountAdapter, ee as createJourneyRuntime, ne as createJourneySync, ie as createMemoryJourneySyncPort, ae as createMemoryPersistence, oe as createWebStoragePersistence, se as defaultStepPath, le as defineJourney, ue as defineJourneyHandle, de as defineJourneyPersistence, fe as defineTransition, me as invoke, he as isAnnotatedTransition, I as isJourneySystemAbort, ge as isTerminalSentinel, R as journeyKey, w as journeyStepPath, je as journeysPlugin, T as resolveJourneySyncAction, L as satisfies, E as selectModule, D as selectModuleOrDefault, K as useActiveLeafJourneyInstance, ye as useActiveLeafJourneyState, U as useCallChain, H as useInstanceSnapshot, we as useJourneyCallStack, B as useJourneyContext, Q as useJourneyHost, G as useJourneyInstance, ve as useJourneyState, De as useJourneySync, W as useLeafId, Ae as useWaitForExit, O as validateJourneyContracts, A as validateJourneyDefinition, M as validateJourneyGraph };
689
+
690
+ //# sourceMappingURL=index.js.map