@noego/wood 0.5.1 → 0.6.1
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/README.md +31 -0
- package/dist/client/index.cjs +30 -11
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +33 -1
- package/dist/client/index.d.ts +33 -1
- package/dist/client/index.js +28 -11
- package/dist/client/index.js.map +1 -1
- package/dist/codegen/preload_generator.cjs +44 -5
- package/dist/codegen/preload_generator.cjs.map +1 -1
- package/dist/codegen/preload_generator.js +44 -5
- package/dist/codegen/preload_generator.js.map +1 -1
- package/dist/codegen/renderer_app_generator.cjs +2 -9
- package/dist/codegen/renderer_app_generator.cjs.map +1 -1
- package/dist/codegen/renderer_app_generator.js +2 -9
- package/dist/codegen/renderer_app_generator.js.map +1 -1
- package/dist/controller/cleanup.cjs +39 -0
- package/dist/controller/cleanup.cjs.map +1 -0
- package/dist/controller/cleanup.d.cts +4 -0
- package/dist/controller/cleanup.d.ts +4 -0
- package/dist/controller/cleanup.js +15 -0
- package/dist/controller/cleanup.js.map +1 -0
- package/dist/controller/controller_lifecycle.cjs +26 -2
- package/dist/controller/controller_lifecycle.cjs.map +1 -1
- package/dist/controller/controller_lifecycle.d.cts +3 -1
- package/dist/controller/controller_lifecycle.d.ts +3 -1
- package/dist/controller/controller_lifecycle.js +24 -1
- package/dist/controller/controller_lifecycle.js.map +1 -1
- package/dist/frontend/frontend_lifecycle.cjs +5 -7
- package/dist/frontend/frontend_lifecycle.cjs.map +1 -1
- package/dist/frontend/frontend_lifecycle.d.cts +1 -14
- package/dist/frontend/frontend_lifecycle.d.ts +1 -14
- package/dist/frontend/frontend_lifecycle.js +5 -7
- package/dist/frontend/frontend_lifecycle.js.map +1 -1
- package/dist/frontend/frontend_surface.cjs +130 -104
- package/dist/frontend/frontend_surface.cjs.map +1 -1
- package/dist/frontend/frontend_surface.js +131 -105
- package/dist/frontend/frontend_surface.js.map +1 -1
- package/dist/frontend/work_registry.cjs +29 -4
- package/dist/frontend/work_registry.cjs.map +1 -1
- package/dist/frontend/work_registry.d.cts +2 -0
- package/dist/frontend/work_registry.d.ts +2 -0
- package/dist/frontend/work_registry.js +29 -4
- package/dist/frontend/work_registry.js.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/ipc/index.cjs +6 -2
- package/dist/ipc/index.cjs.map +1 -1
- package/dist/ipc/index.d.cts +9 -0
- package/dist/ipc/index.d.ts +9 -0
- package/dist/ipc/index.js +6 -2
- package/dist/ipc/index.js.map +1 -1
- package/dist/main/index.cjs +81 -82
- package/dist/main/index.cjs.map +1 -1
- package/dist/main/index.d.cts +13 -4
- package/dist/main/index.d.ts +13 -4
- package/dist/main/index.js +89 -87
- package/dist/main/index.js.map +1 -1
- package/dist/main/shutdown_coordinator.cjs +153 -0
- package/dist/main/shutdown_coordinator.cjs.map +1 -0
- package/dist/main/shutdown_coordinator.d.cts +81 -0
- package/dist/main/shutdown_coordinator.d.ts +81 -0
- package/dist/main/shutdown_coordinator.js +127 -0
- package/dist/main/shutdown_coordinator.js.map +1 -0
- package/dist/main/startup_failure_handler.cjs +67 -0
- package/dist/main/startup_failure_handler.cjs.map +1 -0
- package/dist/main/startup_failure_handler.d.cts +16 -0
- package/dist/main/startup_failure_handler.d.ts +16 -0
- package/dist/main/startup_failure_handler.js +43 -0
- package/dist/main/startup_failure_handler.js.map +1 -0
- package/dist/router/index.d.cts +3 -0
- package/dist/router/index.d.ts +3 -0
- package/dist/router/wood_router.cjs +204 -123
- package/dist/router/wood_router.cjs.map +1 -1
- package/dist/router/wood_router.d.cts +20 -0
- package/dist/router/wood_router.d.ts +20 -0
- package/dist/router/wood_router.js +206 -125
- package/dist/router/wood_router.js.map +1 -1
- package/dist/runtime/index.cjs +13 -0
- package/dist/runtime/index.cjs.map +1 -1
- package/dist/runtime/index.d.cts +8 -4
- package/dist/runtime/index.d.ts +8 -4
- package/dist/runtime/index.js +8 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/renderer_config_extension.cjs +1 -2
- package/dist/runtime/renderer_config_extension.cjs.map +1 -1
- package/dist/runtime/renderer_config_extension.d.cts +1 -1
- package/dist/runtime/renderer_config_extension.d.ts +1 -1
- package/dist/runtime/renderer_config_extension.js +1 -2
- package/dist/runtime/renderer_config_extension.js.map +1 -1
- package/dist/runtime/renderer_log_dispatcher.cjs +2 -0
- package/dist/runtime/renderer_log_dispatcher.cjs.map +1 -1
- package/dist/runtime/renderer_log_dispatcher.d.cts +1 -1
- package/dist/runtime/renderer_log_dispatcher.d.ts +1 -1
- package/dist/runtime/renderer_log_dispatcher.js +1 -0
- package/dist/runtime/renderer_log_dispatcher.js.map +1 -1
- package/dist/runtime/runtime.cjs +107 -57
- package/dist/runtime/runtime.cjs.map +1 -1
- package/dist/runtime/runtime.d.cts +12 -0
- package/dist/runtime/runtime.d.ts +12 -0
- package/dist/runtime/runtime.js +110 -59
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/runtime_module.cjs +58 -0
- package/dist/runtime/runtime_module.cjs.map +1 -0
- package/dist/runtime/runtime_module.d.cts +22 -0
- package/dist/runtime/runtime_module.d.ts +22 -0
- package/dist/runtime/runtime_module.js +30 -0
- package/dist/runtime/runtime_module.js.map +1 -0
- package/dist/testing/create_controller_harness.d.cts +3 -0
- package/dist/testing/create_controller_harness.d.ts +3 -0
- package/dist/testing/create_router_bridge.d.cts +3 -0
- package/dist/testing/create_router_bridge.d.ts +3 -0
- package/dist/testing/create_test_router.d.cts +3 -0
- package/dist/testing/create_test_router.d.ts +3 -0
- package/dist/testing/index.cjs +3 -0
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +6 -1
- package/dist/testing/index.d.ts +6 -1
- package/dist/testing/index.js +2 -0
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/registration_only_root.cjs +168 -0
- package/dist/testing/registration_only_root.cjs.map +1 -0
- package/dist/testing/registration_only_root.d.cts +46 -0
- package/dist/testing/registration_only_root.d.ts +46 -0
- package/dist/testing/registration_only_root.js +141 -0
- package/dist/testing/registration_only_root.js.map +1 -0
- package/dist/testing/test_wood_config.cjs +382 -70
- package/dist/testing/test_wood_config.cjs.map +1 -1
- package/dist/testing/test_wood_config.d.cts +25 -1
- package/dist/testing/test_wood_config.d.ts +25 -1
- package/dist/testing/test_wood_config.js +388 -71
- package/dist/testing/test_wood_config.js.map +1 -1
- package/dist/testing/wood_dom_animation.cjs +213 -0
- package/dist/testing/wood_dom_animation.cjs.map +1 -0
- package/dist/testing/wood_dom_animation.d.cts +89 -0
- package/dist/testing/wood_dom_animation.d.ts +89 -0
- package/dist/testing/wood_dom_animation.js +185 -0
- package/dist/testing/wood_dom_animation.js.map +1 -0
- package/dist/testing/wood_env_renderer.cjs +81 -32
- package/dist/testing/wood_env_renderer.cjs.map +1 -1
- package/dist/testing/wood_env_renderer.d.cts +32 -1
- package/dist/testing/wood_env_renderer.d.ts +32 -1
- package/dist/testing/wood_env_renderer.js +84 -32
- package/dist/testing/wood_env_renderer.js.map +1 -1
- package/dist/transport/in_process_router_transport.d.cts +3 -0
- package/dist/transport/in_process_router_transport.d.ts +3 -0
- package/dist/transport/index.d.cts +3 -0
- package/dist/transport/index.d.ts +3 -0
- package/package.json +7 -6
- package/src/components/NavigationShell.svelte +12 -7
- package/src/controller/cleanup.ts +8 -0
- package/src/controller/controller_lifecycle.ts +24 -0
|
@@ -24,6 +24,7 @@ __export(frontend_surface_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(frontend_surface_exports);
|
|
25
25
|
var import_ioc = require("@noego/ioc");
|
|
26
26
|
var import_layout_preservation = require("../navigation/layout_preservation.js");
|
|
27
|
+
var import_cleanup = require("../controller/cleanup.js");
|
|
27
28
|
var import_controller_lifecycle = require("../controller/controller_lifecycle.js");
|
|
28
29
|
var import_page_catalog = require("./page_catalog.js");
|
|
29
30
|
var import_work_registry = require("./work_registry.js");
|
|
@@ -34,26 +35,6 @@ function registerControllerUnlessBound(scope, ControllerClass) {
|
|
|
34
35
|
if (typeof registrable.isRegistered === "function" && registrable.isRegistered(ControllerClass)) return;
|
|
35
36
|
if (typeof scope.registerClass === "function") scope.registerClass(ControllerClass);
|
|
36
37
|
}
|
|
37
|
-
function guardControllerLifecycleOnce(instance) {
|
|
38
|
-
if (!instance || typeof instance !== "object") return;
|
|
39
|
-
const target = instance;
|
|
40
|
-
for (const hook of ["dispose", "destroy"]) {
|
|
41
|
-
const original = target[hook];
|
|
42
|
-
if (typeof original !== "function") continue;
|
|
43
|
-
if (Object.prototype.hasOwnProperty.call(target, hook)) continue;
|
|
44
|
-
let called = false;
|
|
45
|
-
Object.defineProperty(target, hook, {
|
|
46
|
-
configurable: true,
|
|
47
|
-
writable: true,
|
|
48
|
-
enumerable: false,
|
|
49
|
-
value: function guarded(...args) {
|
|
50
|
-
if (called) return void 0;
|
|
51
|
-
called = true;
|
|
52
|
-
return original.apply(this, args);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
38
|
function createFrontendSurface(options) {
|
|
58
39
|
const { catalog, rendererRoot, registry, navigation } = options;
|
|
59
40
|
const flushHooks = options.flushHooks ?? [];
|
|
@@ -61,6 +42,16 @@ function createFrontendSurface(options) {
|
|
|
61
42
|
let active = null;
|
|
62
43
|
let transitioning = false;
|
|
63
44
|
let disposed = false;
|
|
45
|
+
let navigationQueue = Promise.resolve();
|
|
46
|
+
let closing;
|
|
47
|
+
const retainedPageScopes = /* @__PURE__ */ new Map();
|
|
48
|
+
const locallyOwnedControllers = /* @__PURE__ */ new WeakSet();
|
|
49
|
+
const markController = (instance, token) => {
|
|
50
|
+
const root = rendererRoot;
|
|
51
|
+
if (!root.isRegistered?.(token) && instance && typeof instance === "object") locallyOwnedControllers.add(instance);
|
|
52
|
+
(0, import_controller_lifecycle.guardControllerLifecycleOnce)(instance);
|
|
53
|
+
};
|
|
54
|
+
const disposeLocalController = (instance) => instance && typeof instance === "object" && locallyOwnedControllers.has(instance) ? (0, import_controller_lifecycle.disposeControllerLifecycle)(instance) : Promise.resolve();
|
|
64
55
|
const currentOwner = () => active ? `page ${active.identity}` : "application";
|
|
65
56
|
async function constructPage(view, params, query, preserved = []) {
|
|
66
57
|
const identity = (0, import_page_catalog.pageIdentity)(view);
|
|
@@ -72,91 +63,111 @@ function createFrontendSurface(options) {
|
|
|
72
63
|
const ControllerClass = await options.resolveController(view.controller, view);
|
|
73
64
|
const scope = rendererRoot.extend();
|
|
74
65
|
const lifecycle = new import_frontend_lifecycle.FrontendLifecycleOwner(registry, `page ${identity}`);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
66
|
+
const rollback = [
|
|
67
|
+
() => import_ioc.ExecutionContext.run(scope, () => scope.dispose?.()),
|
|
68
|
+
() => lifecycle.dispose()
|
|
69
|
+
];
|
|
70
|
+
try {
|
|
71
|
+
scope.registerFunction?.(import_frontend_lifecycle.FrontendLifecycleOwner, () => lifecycle, { loadAs: import_ioc.LoadAs.Scoped });
|
|
72
|
+
await import_ioc.ExecutionContext.run(scope, () => options.configurePageScope?.(scope, view, { kind: "page", controller: view.controller }));
|
|
73
|
+
registerControllerUnlessBound(scope, ControllerClass);
|
|
74
|
+
const layouts = [...preserved];
|
|
75
|
+
for (let index = preserved.length; index < view.layouts.length; index += 1) {
|
|
76
|
+
const layoutIdentity = view.layoutControllers?.[index];
|
|
77
|
+
if (!layoutIdentity) continue;
|
|
78
|
+
const preserve = view.layoutPreserve?.[index] === true;
|
|
79
|
+
const LayoutClass = await options.resolveController(layoutIdentity, view);
|
|
80
|
+
const ownScope = preserve ? rendererRoot.extend() : null;
|
|
81
|
+
const ownLifecycle = ownScope ? new import_frontend_lifecycle.FrontendLifecycleOwner(registry, `layout ${layoutIdentity}`) : null;
|
|
82
|
+
const layoutScope = ownScope ?? scope;
|
|
83
|
+
if (ownScope) {
|
|
84
|
+
rollback.push(() => import_ioc.ExecutionContext.run(ownScope, () => ownScope.dispose?.()));
|
|
85
|
+
rollback.push(() => ownLifecycle.dispose());
|
|
86
|
+
ownScope.registerFunction?.(import_frontend_lifecycle.FrontendLifecycleOwner, () => ownLifecycle, { loadAs: import_ioc.LoadAs.Scoped });
|
|
87
|
+
await import_ioc.ExecutionContext.run(ownScope, () => options.configurePageScope?.(ownScope, view, {
|
|
88
|
+
kind: "layout",
|
|
89
|
+
layoutIndex: index,
|
|
90
|
+
controller: layoutIdentity
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
registerControllerUnlessBound(layoutScope, LayoutClass);
|
|
94
|
+
const instance = await import_ioc.ExecutionContext.run(
|
|
95
|
+
layoutScope,
|
|
96
|
+
() => layoutScope.get(LayoutClass)
|
|
97
|
+
);
|
|
98
|
+
markController(instance, LayoutClass);
|
|
99
|
+
rollback.push(() => import_ioc.ExecutionContext.run(layoutScope, () => disposeLocalController(instance)));
|
|
100
|
+
layouts.push({
|
|
101
|
+
index,
|
|
102
|
+
path: view.layouts[index],
|
|
103
|
+
controller: layoutIdentity,
|
|
104
|
+
preserve,
|
|
105
|
+
instance,
|
|
106
|
+
scope: layoutScope,
|
|
107
|
+
ownScope,
|
|
108
|
+
ownLifecycle
|
|
96
109
|
});
|
|
97
110
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
() => layoutScope.get(LayoutClass)
|
|
111
|
+
const controller = await import_ioc.ExecutionContext.run(
|
|
112
|
+
scope,
|
|
113
|
+
() => scope.get(ControllerClass)
|
|
102
114
|
);
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
115
|
+
markController(controller, ControllerClass);
|
|
116
|
+
rollback.push(() => import_ioc.ExecutionContext.run(scope, () => disposeLocalController(controller)));
|
|
117
|
+
if (typeof controller.initialize === "function") {
|
|
118
|
+
await registry.track(
|
|
119
|
+
Promise.resolve(
|
|
120
|
+
import_ioc.ExecutionContext.run(
|
|
121
|
+
scope,
|
|
122
|
+
() => controller.initialize({ params, query })
|
|
123
|
+
)
|
|
124
|
+
).then(() => void 0),
|
|
125
|
+
{ label: `initialize ${identity}`, kind: "initialize", owner: `page ${identity}` }
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
const handle = (0, import_frontend_page.createFrontendPage)({
|
|
129
|
+
identity,
|
|
130
|
+
controller,
|
|
131
|
+
scope,
|
|
132
|
+
layouts,
|
|
133
|
+
onClose: async () => {
|
|
134
|
+
await disposePage(identity);
|
|
135
|
+
}
|
|
113
136
|
});
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if (typeof controller.initialize === "function") {
|
|
121
|
-
await registry.track(
|
|
122
|
-
Promise.resolve(
|
|
123
|
-
import_ioc.ExecutionContext.run(
|
|
124
|
-
scope,
|
|
125
|
-
() => controller.initialize({ params, query })
|
|
126
|
-
)
|
|
127
|
-
).then(() => void 0),
|
|
128
|
-
{ label: `initialize ${identity}`, kind: "initialize", owner: `page ${identity}` }
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
const handle = (0, import_frontend_page.createFrontendPage)({
|
|
132
|
-
identity,
|
|
133
|
-
controller,
|
|
134
|
-
scope,
|
|
135
|
-
layouts,
|
|
136
|
-
onClose: async () => {
|
|
137
|
-
await disposePage(identity);
|
|
137
|
+
return { identity, view, scope, lifecycle, handle, controller, layouts };
|
|
138
|
+
} catch (error) {
|
|
139
|
+
try {
|
|
140
|
+
await (0, import_cleanup.cleanupAll)(rollback.reverse(), "Wood page rollback failed");
|
|
141
|
+
} catch (cleanupError) {
|
|
142
|
+
throw Object.assign(new Error("Wood page construction and cleanup failed"), { cause: error, errors: [error, cleanupError] });
|
|
138
143
|
}
|
|
139
|
-
|
|
140
|
-
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
141
146
|
}
|
|
142
147
|
async function endPage(page, preservedDepth = 0) {
|
|
143
148
|
page.handle.invalidate();
|
|
144
|
-
|
|
149
|
+
const steps = [
|
|
150
|
+
() => import_ioc.ExecutionContext.run(page.scope, () => disposeLocalController(page.controller))
|
|
151
|
+
];
|
|
145
152
|
for (const layout of page.layouts) {
|
|
146
153
|
if (layout.index < preservedDepth) continue;
|
|
147
|
-
|
|
154
|
+
steps.push(() => import_ioc.ExecutionContext.run(layout.scope, () => disposeLocalController(layout.instance)));
|
|
155
|
+
steps.push(() => layout.ownLifecycle?.dispose());
|
|
156
|
+
if (layout.ownScope) steps.push(() => import_ioc.ExecutionContext.run(layout.ownScope, () => layout.ownScope.dispose?.()));
|
|
148
157
|
}
|
|
149
|
-
|
|
150
|
-
if (
|
|
151
|
-
|
|
158
|
+
const carriesPageScope = page.layouts.some((layout) => layout.index < preservedDepth && layout.scope === page.scope);
|
|
159
|
+
if (carriesPageScope) retainedPageScopes.set(page.scope, page.lifecycle);
|
|
160
|
+
else {
|
|
161
|
+
steps.push(() => page.lifecycle.dispose());
|
|
162
|
+
steps.push(() => import_ioc.ExecutionContext.run(page.scope, () => page.scope.dispose?.()));
|
|
152
163
|
}
|
|
153
|
-
for (const
|
|
154
|
-
if (layout.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
164
|
+
for (const [scope, lifecycle] of retainedPageScopes) {
|
|
165
|
+
if (active?.layouts.some((layout) => layout.scope === scope)) continue;
|
|
166
|
+
retainedPageScopes.delete(scope);
|
|
167
|
+
steps.push(() => lifecycle.dispose());
|
|
168
|
+
steps.push(() => import_ioc.ExecutionContext.run(scope, () => scope.dispose?.()));
|
|
159
169
|
}
|
|
170
|
+
await (0, import_cleanup.cleanupAll)(steps, "Wood page cleanup failed");
|
|
160
171
|
}
|
|
161
172
|
async function disposePage(identity) {
|
|
162
173
|
if (!active || active.identity !== identity) return;
|
|
@@ -165,6 +176,7 @@ function createFrontendSurface(options) {
|
|
|
165
176
|
await endPage(ended);
|
|
166
177
|
}
|
|
167
178
|
async function transitionTo(entry) {
|
|
179
|
+
if (disposed) return;
|
|
168
180
|
const view = catalog.resolve(entry.page);
|
|
169
181
|
const previous = active;
|
|
170
182
|
const depth = previous ? (0, import_layout_preservation.computePreservedLayoutDepth)(
|
|
@@ -174,16 +186,23 @@ function createFrontendSurface(options) {
|
|
|
174
186
|
) : 0;
|
|
175
187
|
const carried = previous ? previous.layouts.filter((layout) => layout.index < depth) : [];
|
|
176
188
|
const next = await constructPage(view, entry.params, entry.query, carried);
|
|
189
|
+
if (disposed) {
|
|
190
|
+
await endPage(next, depth);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
177
193
|
active = next;
|
|
178
194
|
if (previous) {
|
|
179
195
|
await endPage(previous, depth);
|
|
180
196
|
}
|
|
181
197
|
}
|
|
182
|
-
navigation.subscribe((entry) => {
|
|
198
|
+
const unsubscribe = navigation.subscribe((entry) => {
|
|
183
199
|
if (!entry || transitioning || disposed) return;
|
|
184
200
|
if (active && entry.page === active.identity) return;
|
|
185
201
|
if (!active) return;
|
|
186
|
-
|
|
202
|
+
const transition = navigationQueue.then(() => transitionTo(entry));
|
|
203
|
+
navigationQueue = transition.catch(() => {
|
|
204
|
+
});
|
|
205
|
+
registry.track(transition, {
|
|
187
206
|
label: `navigate ${active.identity} -> ${entry.page}`,
|
|
188
207
|
kind: "navigation",
|
|
189
208
|
owner: currentOwner()
|
|
@@ -192,6 +211,7 @@ function createFrontendSurface(options) {
|
|
|
192
211
|
return {
|
|
193
212
|
navigation,
|
|
194
213
|
async open(openOptions) {
|
|
214
|
+
if (disposed || transitioning) throw new import_page_catalog.PageCatalogError("Wood frontend is closed or opening a page");
|
|
195
215
|
if (!openOptions || typeof openOptions.page !== "string" || !openOptions.page.length) {
|
|
196
216
|
throw new import_page_catalog.PageCatalogError("frontend.open() requires an explicit { page } identity");
|
|
197
217
|
}
|
|
@@ -206,7 +226,12 @@ function createFrontendSurface(options) {
|
|
|
206
226
|
transitioning = true;
|
|
207
227
|
try {
|
|
208
228
|
navigation.replace((0, import_page_catalog.pageIdentity)(view), params, query);
|
|
209
|
-
|
|
229
|
+
const opened = await constructPage(view, params, query);
|
|
230
|
+
if (disposed) {
|
|
231
|
+
await endPage(opened);
|
|
232
|
+
throw new import_page_catalog.PageCatalogError("Wood frontend was disposed during page construction");
|
|
233
|
+
}
|
|
234
|
+
active = opened;
|
|
210
235
|
} finally {
|
|
211
236
|
transitioning = false;
|
|
212
237
|
}
|
|
@@ -216,7 +241,7 @@ function createFrontendSurface(options) {
|
|
|
216
241
|
return active ? active.handle.page : null;
|
|
217
242
|
},
|
|
218
243
|
async act(action) {
|
|
219
|
-
|
|
244
|
+
void registry.track(
|
|
220
245
|
Promise.resolve().then(() => action()).then(() => void 0),
|
|
221
246
|
{ label: "act()", kind: "tracked", owner: currentOwner() }
|
|
222
247
|
).catch(() => {
|
|
@@ -229,15 +254,16 @@ function createFrontendSurface(options) {
|
|
|
229
254
|
get errors() {
|
|
230
255
|
return registry.errors();
|
|
231
256
|
},
|
|
232
|
-
|
|
233
|
-
if (
|
|
257
|
+
dispose() {
|
|
258
|
+
if (closing) return closing;
|
|
234
259
|
disposed = true;
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
260
|
+
unsubscribe();
|
|
261
|
+
const ended = active;
|
|
262
|
+
active = null;
|
|
263
|
+
return closing = (0, import_cleanup.cleanupAll)([
|
|
264
|
+
() => ended ? endPage(ended) : void 0,
|
|
265
|
+
() => application.dispose()
|
|
266
|
+
], "Wood frontend cleanup failed");
|
|
241
267
|
}
|
|
242
268
|
};
|
|
243
269
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/frontend/frontend_surface.ts"],"sourcesContent":["/**\n * The Node frontend application surface (spec 18 §12–13, 18A D-FAS-01/02).\n *\n * frontend.open({ page, params, query }) — explicit initial page\n * frontend.current() — production navigation result\n * frontend.act(fn) / frontend.settle() — owned-work fixed-point drains\n * frontend.errors — observed owned-work failures\n *\n * Runtime honesty (D-FAS-02): this is the plain-Node tier. It proves\n * explicit PageController behavior, $state/$derived reachable through it,\n * backend calls, events, and navigation identity/lifecycle. It does not\n * create a Svelte component/root context and therefore proves no $effect,\n * mount/unmount, or DOM behavior — those belong to the happy-dom tier.\n *\n * Isolation: every environment owns its own Navigation instance, renderer\n * root, transport, and work registry. Nothing here writes globalThis and\n * nothing calls the production client getters — two environments run\n * concurrently without cross-talk. A controller that calls the module-level\n * `go()`/`getNavigation()` free functions bypasses its environment; this\n * tier requires constructor-injected `Navigation`.\n */\nimport { ExecutionContext, LoadAs } from '@noego/ioc';\nimport { Navigation, type NavigationEntry } from '../navigation/index.js';\nimport { computePreservedLayoutDepth } from '../navigation/layout_preservation.js';\nimport { disposeControllerLifecycle } from '../controller/controller_lifecycle.js';\nimport type { ViewDef } from '../types/index.cjs';\nimport { PageCatalog, PageCatalogError, pageIdentity } from './page_catalog.js';\nimport { WorkRegistry, FrontendWorkError, type WorkFailure } from './work_registry.js';\nimport { FrontendLifecycleOwner, type FrontendLifecycle } from './frontend_lifecycle.js';\nimport { createFrontendPage, type FrontendPage, type FrontendPageHandle, type MountedLayout } from './frontend_page.js';\n\nexport interface FrontendOpenOptions {\n /** Required production page identity (`window.page`, or unambiguous leaf). */\n page: string;\n params?: Record<string, string>;\n query?: Record<string, string>;\n}\n\nexport interface FrontendApplicationSurface {\n open(options: FrontendOpenOptions): Promise<FrontendPage>;\n current(): FrontendPage | null;\n act(action: () => unknown | Promise<unknown>): Promise<void>;\n settle(): Promise<void>;\n readonly errors: readonly WorkFailure[];\n /** The environment-local production Navigation instance. */\n readonly navigation: Navigation;\n /** Internal: dispose the active page and application lifecycles. */\n dispose(): Promise<void>;\n}\n\ninterface ScopeLike {\n extend(): ScopeLike;\n get(token: unknown): Promise<unknown>;\n registerClass?(target: unknown, options?: unknown): void;\n registerFunction?(token: unknown, factory: () => unknown, options?: unknown): void;\n registerValue?(token: unknown, value: unknown): void;\n dispose?(): Promise<void>;\n}\n\n/**\n * A mounted layout controller and the scope that owns it. A layout declared\n * `preserve: true` owns a DEDICATED scope that survives page transitions\n * (production parity: `createControllerSet`); every other layout shares the\n * page scope and dies with the page.\n */\ninterface ActiveLayout extends MountedLayout {\n index: number;\n /** Non-null only for a preserved layout that owns its scope. */\n ownScope: ScopeLike | null;\n /**\n * A preserved layout outlives the page that built it, so it cannot borrow\n * that page's lifecycle owner — it owns one, disposed when the layout is\n * finally dropped.\n */\n ownLifecycle: FrontendLifecycleOwner | null;\n}\n\ninterface ActivePage {\n identity: string;\n view: ViewDef;\n scope: ScopeLike;\n lifecycle: FrontendLifecycleOwner;\n handle: FrontendPageHandle;\n controller: unknown;\n layouts: ActiveLayout[];\n}\n\nexport interface PageScopeContext {\n kind: 'page' | 'layout';\n /** Layout index within the view's layout stack (layout scopes only). */\n layoutIndex?: number;\n /** Controller identity bound to this scope. */\n controller: string;\n}\n\nexport interface CreateFrontendSurfaceOptions {\n /** The selected renderer aperture. */\n catalog: PageCatalog;\n /** Fresh renderer root for this environment (separate from the main root). */\n rendererRoot: ScopeLike;\n registry: WorkRegistry;\n /** Environment-local Navigation (also registered on the renderer root). */\n navigation: Navigation;\n /** Resolve a production controller identity to its class. */\n resolveController: (identity: string, view: ViewDef) => Promise<new (...args: never[]) => unknown>;\n /** Per-pass reactive flush hooks from the active runtime adapter (Node: none). */\n flushHooks?: ReadonlyArray<() => void | Promise<void>>;\n /**\n * Register per-scope services on a newly created scope (bridge client,\n * etc.). Called for the page scope, and once for each PRESERVED layout\n * that owns a dedicated scope — `context.kind` says which, so a caller\n * that tracks \"the page scope\" does not mistake a layout scope for it.\n */\n configurePageScope?: (\n scope: ScopeLike,\n view: ViewDef,\n context: PageScopeContext,\n ) => void | Promise<void>;\n}\n\n/**\n * Plain (undecorated) controller classes are registered on their scope so\n * they resolve — unless the hierarchy already decided how the token resolves\n * (a renderer-root substitution of the controller class), which keeps\n * winning inside the page scope.\n */\nfunction registerControllerUnlessBound(scope: ScopeLike, ControllerClass: unknown): void {\n const registrable = scope as { isRegistered?(token: unknown): boolean };\n if (typeof registrable.isRegistered === 'function' && registrable.isRegistered(ControllerClass)) return;\n if (typeof scope.registerClass === 'function') scope.registerClass(ControllerClass);\n}\n\n/**\n * Make a controller's production teardown hook run at most once.\n *\n * Two owners legitimately end a controller: this surface (production\n * parity — the renderer's NavigationShell calls the hook explicitly, and\n * for a Transient controller that is the ONLY call) and IoC scope\n * disposal (which calls `dispose()`/`destroy()` on the scoped instances it\n * owns). Shadowing the hook with a once-guard means a controller sees the\n * same single teardown whichever way it was registered.\n */\nfunction guardControllerLifecycleOnce(instance: unknown): void {\n if (!instance || typeof instance !== 'object') return;\n const target = instance as Record<string, unknown>;\n for (const hook of ['dispose', 'destroy'] as const) {\n const original = target[hook];\n if (typeof original !== 'function') continue;\n if (Object.prototype.hasOwnProperty.call(target, hook)) continue;\n let called = false;\n Object.defineProperty(target, hook, {\n configurable: true,\n writable: true,\n enumerable: false,\n value: function guarded(this: unknown, ...args: unknown[]) {\n if (called) return undefined;\n called = true;\n return (original as (...rest: unknown[]) => unknown).apply(this, args);\n },\n });\n }\n}\n\nexport function createFrontendSurface(options: CreateFrontendSurfaceOptions): FrontendApplicationSurface {\n const { catalog, rendererRoot, registry, navigation } = options;\n const flushHooks = options.flushHooks ?? [];\n const application = new FrontendLifecycleOwner(registry, 'application');\n\n let active: ActivePage | null = null;\n let transitioning = false;\n let disposed = false;\n\n const currentOwner = (): string => (active ? `page ${active.identity}` : 'application');\n\n async function constructPage(\n view: ViewDef,\n params: Record<string, string>,\n query: Record<string, string>,\n preserved: ActiveLayout[] = [],\n ): Promise<ActivePage> {\n const identity = pageIdentity(view);\n if (!view.controller) {\n throw new PageCatalogError(\n `page \"${identity}\" declares no controller in its view definition; ` +\n 'the Node application slice drives public PageController input and needs one.',\n );\n }\n\n const ControllerClass = await options.resolveController(view.controller, view);\n const scope = rendererRoot.extend();\n const lifecycle = new FrontendLifecycleOwner(registry, `page ${identity}`);\n\n // The page lifecycle is injectable so controllers can register\n // deliberately detached finite work (D-FAS-01 §2.2). Scoped, not\n // Singleton: the lifecycle belongs to this page scope alone — a\n // Singleton would store at the hierarchy root and leak the first\n // page's lifecycle into every later page.\n scope.registerFunction?.(FrontendLifecycleOwner, () => lifecycle, { loadAs: LoadAs.Scoped });\n await options.configurePageScope?.(scope, view, {\n kind: 'page',\n controller: view.controller,\n });\n registerControllerUnlessBound(scope, ControllerClass);\n\n // Layout controllers mount BEFORE the view controller (production\n // ordering in `createControllerSet`): a page controller may legitimately\n // read state a layout controller published during construction.\n const layouts: ActiveLayout[] = [...preserved];\n for (let index = preserved.length; index < view.layouts.length; index += 1) {\n const layoutIdentity = view.layoutControllers?.[index];\n if (!layoutIdentity) continue;\n const preserve = view.layoutPreserve?.[index] === true;\n const LayoutClass = await options.resolveController(layoutIdentity, view);\n const ownScope = preserve ? rendererRoot.extend() : null;\n const ownLifecycle = ownScope\n ? new FrontendLifecycleOwner(registry, `layout ${layoutIdentity}`)\n : null;\n const layoutScope = ownScope ?? scope;\n if (ownScope) {\n ownScope.registerFunction?.(FrontendLifecycleOwner, () => ownLifecycle!, { loadAs: LoadAs.Scoped });\n await options.configurePageScope?.(ownScope, view, {\n kind: 'layout',\n layoutIndex: index,\n controller: layoutIdentity,\n });\n }\n registerControllerUnlessBound(layoutScope, LayoutClass);\n const instance = (await ExecutionContext.run(layoutScope as never, () =>\n layoutScope.get(LayoutClass),\n )) as Record<string, unknown>;\n guardControllerLifecycleOnce(instance);\n layouts.push({\n index,\n path: view.layouts[index],\n controller: layoutIdentity,\n preserve,\n instance,\n scope: layoutScope,\n ownScope,\n ownLifecycle,\n });\n }\n\n const controller = (await ExecutionContext.run(scope as never, () =>\n scope.get(ControllerClass),\n )) as Record<string, unknown>;\n\n guardControllerLifecycleOnce(controller);\n\n if (typeof controller.initialize === 'function') {\n await registry.track(\n Promise.resolve(\n ExecutionContext.run(scope as never, () =>\n (controller.initialize as (load: unknown) => unknown)({ params, query }),\n ),\n ).then(() => undefined),\n { label: `initialize ${identity}`, kind: 'initialize', owner: `page ${identity}` },\n );\n }\n\n const handle = createFrontendPage({\n identity,\n controller,\n scope,\n layouts,\n onClose: async () => {\n await disposePage(identity);\n },\n });\n\n return { identity, view, scope, lifecycle, handle, controller, layouts };\n }\n\n /**\n * End a page: the page lifecycle owner first (abort signal, owned\n * resources), then the IoC scopes — scope disposal is what runs each\n * controller's production `dispose()`/`destroy()` hook, so nothing here\n * calls those directly. Layouts in the preserved prefix keep running:\n * they belong to the next page now.\n */\n async function endPage(page: ActivePage, preservedDepth = 0): Promise<void> {\n page.handle.invalidate();\n // Production teardown order (NavigationShell.disposeControllerSet): the\n // page controller's hook, then each ending layout's, then the lifecycle\n // owner and the IoC scopes. The hooks are once-guarded, so the scope\n // disposal below does not run them a second time.\n await disposeControllerLifecycle(page.controller);\n for (const layout of page.layouts) {\n if (layout.index < preservedDepth) continue;\n await disposeControllerLifecycle(layout.instance);\n }\n await page.lifecycle.dispose();\n // Page scope first, then dropped preserved layouts — production's\n // disposeControllerSet order (view controller, then layouts).\n if (typeof page.scope.dispose === 'function') {\n await page.scope.dispose();\n }\n for (const layout of page.layouts) {\n if (layout.index < preservedDepth) continue;\n await layout.ownLifecycle?.dispose();\n if (layout.ownScope && typeof layout.ownScope.dispose === 'function') {\n await layout.ownScope.dispose();\n }\n }\n }\n\n async function disposePage(identity: string): Promise<void> {\n if (!active || active.identity !== identity) return;\n const ended = active;\n active = null;\n await endPage(ended);\n }\n\n async function transitionTo(entry: NavigationEntry): Promise<void> {\n // Resolve the destination through the selected aperture — navigation\n // outside it fails without widening the environment.\n const view = catalog.resolve(entry.page);\n const previous = active;\n // Preserved layouts carry over as live instances — the transition never\n // reconstructs them (production `preserve: true` semantics).\n // Same preservation rule the renderer's NavigationShell applies.\n const depth = previous\n ? computePreservedLayoutDepth(\n { layoutPaths: previous.view.layouts, layoutControllers: previous.view.layoutControllers, layoutPreserve: previous.view.layoutPreserve },\n { layoutPaths: view.layouts, layoutControllers: view.layoutControllers, layoutPreserve: view.layoutPreserve },\n entry.options ?? {},\n )\n : 0;\n const carried = previous ? previous.layouts.filter((layout) => layout.index < depth) : [];\n const next = await constructPage(view, entry.params, entry.query, carried);\n active = next;\n if (previous) {\n await endPage(previous, depth);\n }\n }\n\n // Production navigation drives page transitions: a controller calling its\n // injected Navigation.go()/replace() inside the aperture triggers one\n // tracked finite navigation transition (18A D-FAS-01 §2.2).\n navigation.subscribe((entry) => {\n if (!entry || transitioning || disposed) return;\n if (active && entry.page === active.identity) return;\n if (!active) return; // initial open() seeds navigation itself\n registry.track(transitionTo(entry), {\n label: `navigate ${active.identity} -> ${entry.page}`,\n kind: 'navigation',\n owner: currentOwner(),\n });\n });\n\n return {\n navigation,\n\n async open(openOptions: FrontendOpenOptions): Promise<FrontendPage> {\n if (!openOptions || typeof openOptions.page !== 'string' || !openOptions.page.length) {\n throw new PageCatalogError('frontend.open() requires an explicit { page } identity');\n }\n if (active) {\n throw new PageCatalogError(\n `frontend.open() is test bootstrap; page \"${active.identity}\" is already open. ` +\n 'Drive production navigation for subsequent route changes, or close() the page first.',\n );\n }\n const view = catalog.resolve(openOptions.page);\n const params = openOptions.params ?? {};\n const query = openOptions.query ?? {};\n\n transitioning = true;\n try {\n // Seed production navigation state BEFORE construction: controllers\n // and their services legitimately read the current route (params,\n // query) during construction/initialize, exactly as in production\n // where the route exists before the page loads.\n navigation.replace(pageIdentity(view), params, query);\n active = await constructPage(view, params, query);\n } finally {\n transitioning = false;\n }\n return active.handle.page;\n },\n\n current(): FrontendPage | null {\n return active ? active.handle.page : null;\n },\n\n async act(action: () => unknown | Promise<unknown>): Promise<void> {\n await registry.track(\n Promise.resolve().then(() => action()).then(() => undefined),\n { label: 'act()', kind: 'tracked', owner: currentOwner() },\n ).catch(() => {\n // The failure is recorded by the registry; drain reports it with\n // its owner rather than losing the aggregate view.\n });\n await registry.drain(flushHooks);\n },\n\n async settle(): Promise<void> {\n await registry.drain(flushHooks);\n },\n\n get errors(): readonly WorkFailure[] {\n return registry.errors();\n },\n\n async dispose(): Promise<void> {\n if (disposed) return;\n disposed = true;\n if (active) {\n const ended = active;\n active = null;\n // Environment teardown ends everything, preserved layouts included.\n await endPage(ended);\n }\n await application.dispose();\n },\n };\n}\n\nexport type { FrontendLifecycle };\nexport { FrontendWorkError };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBA,iBAAyC;AAEzC,iCAA4C;AAC5C,kCAA2C;AAE3C,0BAA4D;AAC5D,2BAAkE;AAClE,gCAA+D;AAC/D,2BAAmG;AAiGnG,SAAS,8BAA8B,OAAkB,iBAAgC;AACvF,QAAM,cAAc;AACpB,MAAI,OAAO,YAAY,iBAAiB,cAAc,YAAY,aAAa,eAAe,EAAG;AACjG,MAAI,OAAO,MAAM,kBAAkB,WAAY,OAAM,cAAc,eAAe;AACpF;AAYA,SAAS,6BAA6B,UAAyB;AAC7D,MAAI,CAAC,YAAY,OAAO,aAAa,SAAU;AAC/C,QAAM,SAAS;AACf,aAAW,QAAQ,CAAC,WAAW,SAAS,GAAY;AAClD,UAAM,WAAW,OAAO,IAAI;AAC5B,QAAI,OAAO,aAAa,WAAY;AACpC,QAAI,OAAO,UAAU,eAAe,KAAK,QAAQ,IAAI,EAAG;AACxD,QAAI,SAAS;AACb,WAAO,eAAe,QAAQ,MAAM;AAAA,MAClC,cAAc;AAAA,MACd,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,OAAO,SAAS,WAA0B,MAAiB;AACzD,YAAI,OAAQ,QAAO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AAM;AAAA,MAGd,CAAC;AACD,YAAM,SAAS,MAAM,UAAU;AAAA,IACjC;AAAA,IAEA,MAAM,SAAwB;AAC5B,YAAM,SAAS,MAAM,UAAU;AAAA,IACjC;AAAA,IAEA,IAAI,SAAiC;AACnC,aAAO,SAAS,OAAO;AAAA,IACzB;AAAA,IAEA,MAAM,UAAyB;AAC7B,UAAI,SAAU;AACd,iBAAW;AACX,UAAI,QAAQ;AACV,cAAM,QAAQ;AACd,iBAAS;AAET,cAAM,QAAQ,KAAK;AAAA,MACrB;AACA,YAAM,YAAY,QAAQ;AAAA,IAC5B;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/frontend/frontend_surface.ts"],"sourcesContent":["/**\n * The Node frontend application surface (spec 18 §12–13, 18A D-FAS-01/02).\n *\n * frontend.open({ page, params, query }) — explicit initial page\n * frontend.current() — production navigation result\n * frontend.act(fn) / frontend.settle() — owned-work fixed-point drains\n * frontend.errors — observed owned-work failures\n *\n * Runtime honesty (D-FAS-02): this is the plain-Node tier. It proves\n * explicit PageController behavior, $state/$derived reachable through it,\n * backend calls, events, and navigation identity/lifecycle. It does not\n * create a Svelte component/root context and therefore proves no $effect,\n * mount/unmount, or DOM behavior — those belong to the happy-dom tier.\n *\n * Isolation: every environment owns its own Navigation instance, renderer\n * root, transport, and work registry. Nothing here writes globalThis and\n * nothing calls the production client getters — two environments run\n * concurrently without cross-talk. A controller that calls the module-level\n * `go()`/`getNavigation()` free functions bypasses its environment; this\n * tier requires constructor-injected `Navigation`.\n */\nimport { ExecutionContext, LoadAs } from '@noego/ioc';\nimport { Navigation, type NavigationEntry } from '../navigation/index.js';\nimport { computePreservedLayoutDepth } from '../navigation/layout_preservation.js';\nimport { cleanupAll } from '../controller/cleanup.js';\nimport { disposeControllerLifecycle, guardControllerLifecycleOnce } from '../controller/controller_lifecycle.js';\nimport type { ViewDef } from '../types/index.cjs';\nimport { PageCatalog, PageCatalogError, pageIdentity } from './page_catalog.js';\nimport { WorkRegistry, FrontendWorkError, type WorkFailure } from './work_registry.js';\nimport { FrontendLifecycleOwner, type FrontendLifecycle } from './frontend_lifecycle.js';\nimport { createFrontendPage, type FrontendPage, type FrontendPageHandle, type MountedLayout } from './frontend_page.js';\n\nexport interface FrontendOpenOptions {\n /** Required production page identity (`window.page`, or unambiguous leaf). */\n page: string;\n params?: Record<string, string>;\n query?: Record<string, string>;\n}\n\nexport interface FrontendApplicationSurface {\n open(options: FrontendOpenOptions): Promise<FrontendPage>;\n current(): FrontendPage | null;\n act(action: () => unknown | Promise<unknown>): Promise<void>;\n settle(): Promise<void>;\n readonly errors: readonly WorkFailure[];\n /** The environment-local production Navigation instance. */\n readonly navigation: Navigation;\n /** Internal: dispose the active page and application lifecycles. */\n dispose(): Promise<void>;\n}\n\ninterface ScopeLike {\n extend(): ScopeLike;\n get(token: unknown): Promise<unknown>;\n registerClass?(target: unknown, options?: unknown): void;\n registerFunction?(token: unknown, factory: () => unknown, options?: unknown): void;\n registerValue?(token: unknown, value: unknown): void;\n dispose?(): Promise<void>;\n}\n\n/**\n * A mounted layout controller and the scope that owns it. A layout declared\n * `preserve: true` owns a DEDICATED scope that survives page transitions\n * (production parity: `createControllerSet`); every other layout shares the\n * page scope and dies with the page.\n */\ninterface ActiveLayout extends MountedLayout {\n index: number;\n /** Non-null only for a preserved layout that owns its scope. */\n ownScope: ScopeLike | null;\n /**\n * A preserved layout outlives the page that built it, so it cannot borrow\n * that page's lifecycle owner — it owns one, disposed when the layout is\n * finally dropped.\n */\n ownLifecycle: FrontendLifecycleOwner | null;\n}\n\ninterface ActivePage {\n identity: string;\n view: ViewDef;\n scope: ScopeLike;\n lifecycle: FrontendLifecycleOwner;\n handle: FrontendPageHandle;\n controller: unknown;\n layouts: ActiveLayout[];\n}\n\nexport interface PageScopeContext {\n kind: 'page' | 'layout';\n /** Layout index within the view's layout stack (layout scopes only). */\n layoutIndex?: number;\n /** Controller identity bound to this scope. */\n controller: string;\n}\n\nexport interface CreateFrontendSurfaceOptions {\n /** The selected renderer aperture. */\n catalog: PageCatalog;\n /** Fresh renderer root for this environment (separate from the main root). */\n rendererRoot: ScopeLike;\n registry: WorkRegistry;\n /** Environment-local Navigation (also registered on the renderer root). */\n navigation: Navigation;\n /** Resolve a production controller identity to its class. */\n resolveController: (identity: string, view: ViewDef) => Promise<new (...args: never[]) => unknown>;\n /** Per-pass reactive flush hooks from the active runtime adapter (Node: none). */\n flushHooks?: ReadonlyArray<() => void | Promise<void>>;\n /**\n * Register per-scope services on a newly created scope (bridge client,\n * etc.). Called for the page scope, and once for each PRESERVED layout\n * that owns a dedicated scope — `context.kind` says which, so a caller\n * that tracks \"the page scope\" does not mistake a layout scope for it.\n */\n configurePageScope?: (\n scope: ScopeLike,\n view: ViewDef,\n context: PageScopeContext,\n ) => void | Promise<void>;\n}\n\n/**\n * Plain (undecorated) controller classes are registered on their scope so\n * they resolve — unless the hierarchy already decided how the token resolves\n * (a renderer-root substitution of the controller class), which keeps\n * winning inside the page scope.\n */\nfunction registerControllerUnlessBound(scope: ScopeLike, ControllerClass: unknown): void {\n const registrable = scope as { isRegistered?(token: unknown): boolean };\n if (typeof registrable.isRegistered === 'function' && registrable.isRegistered(ControllerClass)) return;\n if (typeof scope.registerClass === 'function') scope.registerClass(ControllerClass);\n}\n\nexport function createFrontendSurface(options: CreateFrontendSurfaceOptions): FrontendApplicationSurface {\n const { catalog, rendererRoot, registry, navigation } = options;\n const flushHooks = options.flushHooks ?? [];\n const application = new FrontendLifecycleOwner(registry, 'application');\n\n let active: ActivePage | null = null;\n let transitioning = false;\n let disposed = false;\n let navigationQueue: Promise<void> = Promise.resolve();\n let closing: Promise<void> | undefined;\n const retainedPageScopes = new Map<ScopeLike, FrontendLifecycleOwner>();\n const locallyOwnedControllers = new WeakSet<object>();\n const markController = (instance: unknown, token: unknown) => {\n const root = rendererRoot as ScopeLike & { isRegistered?(token: unknown): boolean };\n if (!root.isRegistered?.(token) && instance && typeof instance === 'object') locallyOwnedControllers.add(instance);\n guardControllerLifecycleOnce(instance);\n };\n const disposeLocalController = (instance: unknown) => instance && typeof instance === 'object' && locallyOwnedControllers.has(instance)\n ? disposeControllerLifecycle(instance) : Promise.resolve();\n\n const currentOwner = (): string => (active ? `page ${active.identity}` : 'application');\n\n async function constructPage(\n view: ViewDef,\n params: Record<string, string>,\n query: Record<string, string>,\n preserved: ActiveLayout[] = [],\n ): Promise<ActivePage> {\n const identity = pageIdentity(view);\n if (!view.controller) {\n throw new PageCatalogError(\n `page \"${identity}\" declares no controller in its view definition; ` +\n 'the Node application slice drives public PageController input and needs one.',\n );\n }\n\n const ControllerClass = await options.resolveController(view.controller, view);\n const scope = rendererRoot.extend();\n const lifecycle = new FrontendLifecycleOwner(registry, `page ${identity}`);\n\n const rollback: Array<() => unknown | Promise<unknown>> = [\n () => ExecutionContext.run(scope as never, () => scope.dispose?.()),\n () => lifecycle.dispose(),\n ];\n try {\n // The page lifecycle is injectable so controllers can register\n // deliberately detached finite work (D-FAS-01 §2.2). Scoped, not\n // Singleton: the lifecycle belongs to this page scope alone — a\n // Singleton would store at the hierarchy root and leak the first\n // page's lifecycle into every later page.\n scope.registerFunction?.(FrontendLifecycleOwner, () => lifecycle, { loadAs: LoadAs.Scoped });\n await ExecutionContext.run(scope as never, () => options.configurePageScope?.(scope, view, { kind: 'page', controller: view.controller! }));\n registerControllerUnlessBound(scope, ControllerClass);\n\n // Layout controllers mount BEFORE the view controller (production\n // ordering in `createControllerSet`): a page controller may legitimately\n // read state a layout controller published during construction.\n const layouts: ActiveLayout[] = [...preserved];\n for (let index = preserved.length; index < view.layouts.length; index += 1) {\n const layoutIdentity = view.layoutControllers?.[index];\n if (!layoutIdentity) continue;\n const preserve = view.layoutPreserve?.[index] === true;\n const LayoutClass = await options.resolveController(layoutIdentity, view);\n const ownScope = preserve ? rendererRoot.extend() : null;\n const ownLifecycle = ownScope\n ? new FrontendLifecycleOwner(registry, `layout ${layoutIdentity}`)\n : null;\n const layoutScope = ownScope ?? scope;\n if (ownScope) {\n rollback.push(() => ExecutionContext.run(ownScope as never, () => ownScope.dispose?.()));\n rollback.push(() => ownLifecycle!.dispose());\n ownScope.registerFunction?.(FrontendLifecycleOwner, () => ownLifecycle!, { loadAs: LoadAs.Scoped });\n await ExecutionContext.run(ownScope as never, () => options.configurePageScope?.(ownScope, view, {\n kind: 'layout',\n layoutIndex: index,\n controller: layoutIdentity,\n }));\n }\n registerControllerUnlessBound(layoutScope, LayoutClass);\n const instance = (await ExecutionContext.run(layoutScope as never, () =>\n layoutScope.get(LayoutClass),\n )) as Record<string, unknown>;\n markController(instance, LayoutClass);\n rollback.push(() => ExecutionContext.run(layoutScope as never, () => disposeLocalController(instance)));\n layouts.push({\n index,\n path: view.layouts[index],\n controller: layoutIdentity,\n preserve,\n instance,\n scope: layoutScope,\n ownScope,\n ownLifecycle,\n });\n }\n\n const controller = (await ExecutionContext.run(scope as never, () =>\n scope.get(ControllerClass),\n )) as Record<string, unknown>;\n\n markController(controller, ControllerClass);\n rollback.push(() => ExecutionContext.run(scope as never, () => disposeLocalController(controller)));\n\n if (typeof controller.initialize === 'function') {\n await registry.track(\n Promise.resolve(\n ExecutionContext.run(scope as never, () =>\n (controller.initialize as (load: unknown) => unknown)({ params, query }),\n ),\n ).then(() => undefined),\n { label: `initialize ${identity}`, kind: 'initialize', owner: `page ${identity}` },\n );\n }\n\n const handle = createFrontendPage({\n identity,\n controller,\n scope,\n layouts,\n onClose: async () => {\n await disposePage(identity);\n },\n });\n\n return { identity, view, scope, lifecycle, handle, controller, layouts };\n } catch (error) {\n try { await cleanupAll(rollback.reverse(), 'Wood page rollback failed'); }\n catch (cleanupError) { throw Object.assign(new Error('Wood page construction and cleanup failed'), { cause: error, errors: [error, cleanupError] }); }\n throw error;\n }\n }\n\n /**\n * End a page: the page lifecycle owner first (abort signal, owned\n * resources), then the IoC scopes — scope disposal is what runs each\n * controller's production `dispose()`/`destroy()` hook, so nothing here\n * calls those directly. Layouts in the preserved prefix keep running:\n * they belong to the next page now.\n */\n async function endPage(page: ActivePage, preservedDepth = 0): Promise<void> {\n page.handle.invalidate();\n // Production teardown order (NavigationShell.disposeControllerSet): the\n // page controller's hook, then each ending layout's, then the lifecycle\n // owner and the IoC scopes. The hooks are once-guarded, so the scope\n // disposal below does not run them a second time.\n const steps: Array<() => unknown | Promise<unknown>> = [\n () => ExecutionContext.run(page.scope as never, () => disposeLocalController(page.controller)),\n ];\n for (const layout of page.layouts) {\n if (layout.index < preservedDepth) continue;\n steps.push(() => ExecutionContext.run(layout.scope as never, () => disposeLocalController(layout.instance)));\n steps.push(() => layout.ownLifecycle?.dispose());\n if (layout.ownScope) steps.push(() => ExecutionContext.run(layout.ownScope as never, () => layout.ownScope!.dispose?.()));\n }\n const carriesPageScope = page.layouts.some(layout => layout.index < preservedDepth && layout.scope === page.scope);\n if (carriesPageScope) retainedPageScopes.set(page.scope, page.lifecycle);\n else {\n steps.push(() => page.lifecycle.dispose());\n steps.push(() => ExecutionContext.run(page.scope as never, () => page.scope.dispose?.()));\n }\n for (const [scope, lifecycle] of retainedPageScopes) {\n if (active?.layouts.some(layout => layout.scope === scope)) continue;\n retainedPageScopes.delete(scope);\n steps.push(() => lifecycle.dispose());\n steps.push(() => ExecutionContext.run(scope as never, () => scope.dispose?.()));\n }\n await cleanupAll(steps, 'Wood page cleanup failed');\n }\n\n async function disposePage(identity: string): Promise<void> {\n if (!active || active.identity !== identity) return;\n const ended = active;\n active = null;\n await endPage(ended);\n }\n\n async function transitionTo(entry: NavigationEntry): Promise<void> {\n if (disposed) return;\n // Resolve the destination through the selected aperture — navigation\n // outside it fails without widening the environment.\n const view = catalog.resolve(entry.page);\n const previous = active;\n // Preserved layouts carry over as live instances — the transition never\n // reconstructs them (production `preserve: true` semantics).\n // Same preservation rule the renderer's NavigationShell applies.\n const depth = previous\n ? computePreservedLayoutDepth(\n { layoutPaths: previous.view.layouts, layoutControllers: previous.view.layoutControllers, layoutPreserve: previous.view.layoutPreserve },\n { layoutPaths: view.layouts, layoutControllers: view.layoutControllers, layoutPreserve: view.layoutPreserve },\n entry.options ?? {},\n )\n : 0;\n const carried = previous ? previous.layouts.filter((layout) => layout.index < depth) : [];\n const next = await constructPage(view, entry.params, entry.query, carried);\n if (disposed) {\n await endPage(next, depth);\n return;\n }\n active = next;\n if (previous) {\n await endPage(previous, depth);\n }\n }\n\n // Production navigation drives page transitions: a controller calling its\n // injected Navigation.go()/replace() inside the aperture triggers one\n // tracked finite navigation transition (18A D-FAS-01 §2.2).\n const unsubscribe = navigation.subscribe((entry) => {\n if (!entry || transitioning || disposed) return;\n if (active && entry.page === active.identity) return;\n if (!active) return; // initial open() seeds navigation itself\n const transition = navigationQueue.then(() => transitionTo(entry));\n navigationQueue = transition.catch(() => {});\n registry.track(transition, {\n label: `navigate ${active.identity} -> ${entry.page}`,\n kind: 'navigation',\n owner: currentOwner(),\n });\n });\n\n return {\n navigation,\n\n async open(openOptions: FrontendOpenOptions): Promise<FrontendPage> {\n if (disposed || transitioning) throw new PageCatalogError('Wood frontend is closed or opening a page');\n if (!openOptions || typeof openOptions.page !== 'string' || !openOptions.page.length) {\n throw new PageCatalogError('frontend.open() requires an explicit { page } identity');\n }\n if (active) {\n throw new PageCatalogError(\n `frontend.open() is test bootstrap; page \"${active.identity}\" is already open. ` +\n 'Drive production navigation for subsequent route changes, or close() the page first.',\n );\n }\n const view = catalog.resolve(openOptions.page);\n const params = openOptions.params ?? {};\n const query = openOptions.query ?? {};\n\n transitioning = true;\n try {\n // Seed production navigation state BEFORE construction: controllers\n // and their services legitimately read the current route (params,\n // query) during construction/initialize, exactly as in production\n // where the route exists before the page loads.\n navigation.replace(pageIdentity(view), params, query);\n const opened = await constructPage(view, params, query);\n if (disposed) { await endPage(opened); throw new PageCatalogError('Wood frontend was disposed during page construction'); }\n active = opened;\n } finally {\n transitioning = false;\n }\n return active.handle.page;\n },\n\n current(): FrontendPage | null {\n return active ? active.handle.page : null;\n },\n\n async act(action: () => unknown | Promise<unknown>): Promise<void> {\n void registry.track(\n Promise.resolve().then(() => action()).then(() => undefined),\n { label: 'act()', kind: 'tracked', owner: currentOwner() },\n ).catch(() => {\n // The failure is recorded by the registry; drain reports it with\n // its owner rather than losing the aggregate view.\n });\n await registry.drain(flushHooks);\n },\n\n async settle(): Promise<void> {\n await registry.drain(flushHooks);\n },\n\n get errors(): readonly WorkFailure[] {\n return registry.errors();\n },\n\n dispose(): Promise<void> {\n if (closing) return closing;\n disposed = true;\n unsubscribe();\n const ended = active;\n active = null;\n return closing = cleanupAll([\n () => ended ? endPage(ended) : undefined,\n () => application.dispose(),\n ], 'Wood frontend cleanup failed');\n },\n };\n}\n\nexport type { FrontendLifecycle };\nexport { FrontendWorkError };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBA,iBAAyC;AAEzC,iCAA4C;AAC5C,qBAA2B;AAC3B,kCAAyE;AAEzE,0BAA4D;AAC5D,2BAAkE;AAClE,gCAA+D;AAC/D,2BAAmG;AAiGnG,SAAS,8BAA8B,OAAkB,iBAAgC;AACvF,QAAM,cAAc;AACpB,MAAI,OAAO,YAAY,iBAAiB,cAAc,YAAY,aAAa,eAAe,EAAG;AACjG,MAAI,OAAO,MAAM,kBAAkB,WAAY,OAAM,cAAc,eAAe;AACpF;AAEO,SAAS,sBAAsB,SAAmE;AACvG,QAAM,EAAE,SAAS,cAAc,UAAU,WAAW,IAAI;AACxD,QAAM,aAAa,QAAQ,cAAc,CAAC;AAC1C,QAAM,cAAc,IAAI,iDAAuB,UAAU,aAAa;AAEtE,MAAI,SAA4B;AAChC,MAAI,gBAAgB;AACpB,MAAI,WAAW;AACf,MAAI,kBAAiC,QAAQ,QAAQ;AACrD,MAAI;AACJ,QAAM,qBAAqB,oBAAI,IAAuC;AACtE,QAAM,0BAA0B,oBAAI,QAAgB;AACpD,QAAM,iBAAiB,CAAC,UAAmB,UAAmB;AAC5D,UAAM,OAAO;AACb,QAAI,CAAC,KAAK,eAAe,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