@coherent.js/runtime 1.0.0-beta.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/LICENSE +21 -0
- package/README.md +1119 -0
- package/dist/coherent-browser.cjs +304 -0
- package/dist/coherent-browser.cjs.map +7 -0
- package/dist/coherent-browser.js +279 -0
- package/dist/coherent-browser.js.map +7 -0
- package/dist/coherent-edge.cjs +458 -0
- package/dist/coherent-edge.cjs.map +7 -0
- package/dist/coherent-edge.js +430 -0
- package/dist/coherent-edge.js.map +7 -0
- package/dist/coherent-node.cjs +330 -0
- package/dist/coherent-node.cjs.map +7 -0
- package/dist/coherent-node.js +304 -0
- package/dist/coherent-node.js.map +7 -0
- package/dist/coherent-standalone.esm.js +279 -0
- package/dist/coherent-standalone.esm.js.map +7 -0
- package/dist/coherent-standalone.js +2 -0
- package/dist/coherent-standalone.js.map +7 -0
- package/dist/coherent-static.cjs +356 -0
- package/dist/coherent-static.cjs.map +7 -0
- package/dist/coherent-static.js +331 -0
- package/dist/coherent-static.js.map +7 -0
- package/dist/coherent-universal.cjs +3294 -0
- package/dist/coherent-universal.cjs.map +7 -0
- package/dist/coherent-universal.js +3254 -0
- package/dist/coherent-universal.js.map +7 -0
- package/dist/coherent-universal.min.js +2 -0
- package/dist/coherent-universal.min.js.map +7 -0
- package/package.json +92 -0
- package/types/browser.d.ts +2 -0
- package/types/edge.d.ts +2 -0
- package/types/index.d.ts +118 -0
- package/types/static.d.ts +2 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/runtimes/browser.js
|
|
21
|
+
var browser_exports = {};
|
|
22
|
+
__export(browser_exports, {
|
|
23
|
+
BrowserRuntime: () => BrowserRuntime
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(browser_exports);
|
|
26
|
+
var import_core = require("@coherent.js/core");
|
|
27
|
+
var import_client = require("@coherent.js/client");
|
|
28
|
+
var import_web_components = require("@coherent.js/web-components");
|
|
29
|
+
var BrowserRuntime = class _BrowserRuntime {
|
|
30
|
+
constructor(options = {}) {
|
|
31
|
+
this.options = {
|
|
32
|
+
autoHydrate: true,
|
|
33
|
+
enableWebComponents: true,
|
|
34
|
+
enablePerformanceMonitoring: true,
|
|
35
|
+
routingMode: "hash",
|
|
36
|
+
// 'hash', 'history', or 'memory'
|
|
37
|
+
...options
|
|
38
|
+
};
|
|
39
|
+
this.componentRegistry = /* @__PURE__ */ new Map();
|
|
40
|
+
this.routeRegistry = /* @__PURE__ */ new Map();
|
|
41
|
+
this.currentRoute = null;
|
|
42
|
+
this.isInitialized = false;
|
|
43
|
+
this.renderMetrics = [];
|
|
44
|
+
this.startTime = Date.now();
|
|
45
|
+
}
|
|
46
|
+
async initialize() {
|
|
47
|
+
if (this.isInitialized) return;
|
|
48
|
+
if (document.readyState === "loading") {
|
|
49
|
+
await new Promise((resolve) => {
|
|
50
|
+
document.addEventListener("DOMContentLoaded", resolve);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (this.options.enableWebComponents) {
|
|
54
|
+
await this.initializeWebComponents();
|
|
55
|
+
}
|
|
56
|
+
if (this.options.routingMode !== "none") {
|
|
57
|
+
this.initializeRouting();
|
|
58
|
+
}
|
|
59
|
+
if (this.options.autoHydrate) {
|
|
60
|
+
await this.autoHydrate();
|
|
61
|
+
}
|
|
62
|
+
if (this.options.enablePerformanceMonitoring) {
|
|
63
|
+
this.initializePerformanceMonitoring();
|
|
64
|
+
}
|
|
65
|
+
this.isInitialized = true;
|
|
66
|
+
}
|
|
67
|
+
async initializeWebComponents() {
|
|
68
|
+
try {
|
|
69
|
+
await (0, import_web_components.integrateWithWebComponents)(
|
|
70
|
+
Object.fromEntries(this.componentRegistry),
|
|
71
|
+
this.options.webComponents || {}
|
|
72
|
+
);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.warn("Failed to initialize Web Components:", error);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
initializeRouting() {
|
|
78
|
+
const handleRouteChange = () => {
|
|
79
|
+
const newRoute = this.getCurrentRoute();
|
|
80
|
+
if (newRoute !== this.currentRoute) {
|
|
81
|
+
this.handleRouteChange(this.currentRoute, newRoute);
|
|
82
|
+
this.currentRoute = newRoute;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
if (this.options.routingMode === "hash") {
|
|
86
|
+
window.addEventListener("hashchange", handleRouteChange);
|
|
87
|
+
} else if (this.options.routingMode === "history") {
|
|
88
|
+
window.addEventListener("popstate", handleRouteChange);
|
|
89
|
+
}
|
|
90
|
+
this.currentRoute = this.getCurrentRoute();
|
|
91
|
+
handleRouteChange();
|
|
92
|
+
}
|
|
93
|
+
getCurrentRoute() {
|
|
94
|
+
if (this.options.routingMode === "hash") {
|
|
95
|
+
return window.location.hash.slice(1) || "/";
|
|
96
|
+
} else if (this.options.routingMode === "history") {
|
|
97
|
+
return window.location.pathname;
|
|
98
|
+
}
|
|
99
|
+
return "/";
|
|
100
|
+
}
|
|
101
|
+
handleRouteChange(oldRoute, newRoute) {
|
|
102
|
+
const handler = this.routeRegistry.get(newRoute) || this.routeRegistry.get("*");
|
|
103
|
+
if (handler) {
|
|
104
|
+
try {
|
|
105
|
+
handler({ route: newRoute, oldRoute, params: this.parseRouteParams(newRoute) });
|
|
106
|
+
} catch (error) {
|
|
107
|
+
console.error("Route handler error:", error);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
parseRouteParams(route) {
|
|
112
|
+
const params = {};
|
|
113
|
+
const parts = route.split("/").filter(Boolean);
|
|
114
|
+
parts.forEach((part, index) => {
|
|
115
|
+
if (part.startsWith(":")) {
|
|
116
|
+
const key = part.slice(1);
|
|
117
|
+
const value = parts[index];
|
|
118
|
+
if (value && !value.startsWith(":")) {
|
|
119
|
+
params[key] = value;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
return params;
|
|
124
|
+
}
|
|
125
|
+
initializePerformanceMonitoring() {
|
|
126
|
+
if (typeof window === "undefined" || typeof window.PerformanceObserver === "undefined") return;
|
|
127
|
+
const observer = new window.PerformanceObserver((list) => {
|
|
128
|
+
for (const entry of list.getEntries()) {
|
|
129
|
+
if (entry.name.includes("coherent")) {
|
|
130
|
+
this.renderMetrics.push({
|
|
131
|
+
name: entry.name,
|
|
132
|
+
duration: entry.duration,
|
|
133
|
+
startTime: entry.startTime,
|
|
134
|
+
timestamp: Date.now()
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
try {
|
|
140
|
+
observer.observe({ entryTypes: ["measure", "mark"] });
|
|
141
|
+
} catch (error) {
|
|
142
|
+
console.warn("Performance monitoring not available:", error);
|
|
143
|
+
}
|
|
144
|
+
setInterval(() => {
|
|
145
|
+
const cutoff = Date.now() - 3e5;
|
|
146
|
+
this.renderMetrics = this.renderMetrics.filter((m) => m.timestamp > cutoff);
|
|
147
|
+
}, 6e4);
|
|
148
|
+
}
|
|
149
|
+
// Component management
|
|
150
|
+
registerComponent(name, component, options = {}) {
|
|
151
|
+
const hydratableComponent = (0, import_client.makeHydratable)(component, {
|
|
152
|
+
componentName: name,
|
|
153
|
+
...options
|
|
154
|
+
});
|
|
155
|
+
this.componentRegistry.set(name, hydratableComponent);
|
|
156
|
+
if (this.options.enableWebComponents && this.isInitialized) {
|
|
157
|
+
try {
|
|
158
|
+
(0, import_web_components.defineCoherentElement)(name, hydratableComponent, options);
|
|
159
|
+
} catch (error) {
|
|
160
|
+
console.warn(`Failed to register Web Component ${name}:`, error);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return hydratableComponent;
|
|
164
|
+
}
|
|
165
|
+
getComponent(name) {
|
|
166
|
+
return this.componentRegistry.get(name);
|
|
167
|
+
}
|
|
168
|
+
// Routing
|
|
169
|
+
addRoute(path, handler) {
|
|
170
|
+
this.routeRegistry.set(path, handler);
|
|
171
|
+
}
|
|
172
|
+
navigate(path) {
|
|
173
|
+
if (this.options.routingMode === "hash") {
|
|
174
|
+
window.location.hash = path;
|
|
175
|
+
} else if (this.options.routingMode === "history") {
|
|
176
|
+
window.history.pushState({}, "", path);
|
|
177
|
+
this.handleRouteChange(this.currentRoute, path);
|
|
178
|
+
this.currentRoute = path;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// Rendering
|
|
182
|
+
async render(component, props = {}, target = null) {
|
|
183
|
+
const startMark = `coherent-render-start-${Date.now()}`;
|
|
184
|
+
const endMark = `coherent-render-end-${Date.now()}`;
|
|
185
|
+
try {
|
|
186
|
+
performance.mark(startMark);
|
|
187
|
+
const resolvedComponent = typeof component === "string" ? this.getComponent(component) : component;
|
|
188
|
+
if (!resolvedComponent) {
|
|
189
|
+
throw new Error(`Component not found: ${component}`);
|
|
190
|
+
}
|
|
191
|
+
const vdom = resolvedComponent(props);
|
|
192
|
+
const html = (0, import_core.render)(vdom);
|
|
193
|
+
let targetElement = target;
|
|
194
|
+
if (typeof target === "string") {
|
|
195
|
+
targetElement = document.querySelector(target);
|
|
196
|
+
}
|
|
197
|
+
if (!targetElement) {
|
|
198
|
+
targetElement = document.body;
|
|
199
|
+
}
|
|
200
|
+
targetElement.innerHTML = html;
|
|
201
|
+
const instance = await (0, import_client.hydrate)(targetElement.firstElementChild, resolvedComponent, props);
|
|
202
|
+
performance.mark(endMark);
|
|
203
|
+
performance.measure(`coherent-render-${resolvedComponent.name || "anonymous"}`, startMark, endMark);
|
|
204
|
+
return instance;
|
|
205
|
+
} catch (error) {
|
|
206
|
+
performance.mark(endMark);
|
|
207
|
+
console.error("Render error:", error);
|
|
208
|
+
throw error;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// Create a complete app
|
|
212
|
+
async createApp(_options = {}) {
|
|
213
|
+
await this.initialize();
|
|
214
|
+
return {
|
|
215
|
+
// Component management
|
|
216
|
+
component: (name, component, opts) => this.registerComponent(name, component, opts),
|
|
217
|
+
// Routing
|
|
218
|
+
route: (path, handler) => this.addRoute(path, handler),
|
|
219
|
+
navigate: (path) => this.navigate(path),
|
|
220
|
+
// Rendering
|
|
221
|
+
render: (component, props, target) => this.render(component, props, target),
|
|
222
|
+
// State management
|
|
223
|
+
state: import_core.withState,
|
|
224
|
+
memo: import_core.memo,
|
|
225
|
+
// Hydration
|
|
226
|
+
hydrate: (element, component, props) => (0, import_client.hydrate)(element, component, props),
|
|
227
|
+
// Utilities
|
|
228
|
+
getRuntime: () => this,
|
|
229
|
+
getCurrentRoute: () => this.currentRoute,
|
|
230
|
+
getPerformanceMetrics: () => [...this.renderMetrics],
|
|
231
|
+
// Lifecycle
|
|
232
|
+
mount: async (component, target = "#app") => {
|
|
233
|
+
const app = await this.render(component, {}, target);
|
|
234
|
+
return app;
|
|
235
|
+
},
|
|
236
|
+
unmount: (target = "#app") => {
|
|
237
|
+
const element = typeof target === "string" ? document.querySelector(target) : target;
|
|
238
|
+
if (element) {
|
|
239
|
+
element.innerHTML = "";
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
// Auto-hydration
|
|
245
|
+
async autoHydrate() {
|
|
246
|
+
const componentMap = Object.fromEntries(this.componentRegistry);
|
|
247
|
+
await (0, import_client.autoHydrate)(componentMap);
|
|
248
|
+
}
|
|
249
|
+
// Static methods for quick setup
|
|
250
|
+
static async createQuickApp(components = {}, options = {}) {
|
|
251
|
+
const runtime = new _BrowserRuntime(options);
|
|
252
|
+
Object.entries(components).forEach(([name, component]) => {
|
|
253
|
+
runtime.registerComponent(name, component);
|
|
254
|
+
});
|
|
255
|
+
return await runtime.createApp(options);
|
|
256
|
+
}
|
|
257
|
+
static async renderToPage(component, props = {}, target = "#app") {
|
|
258
|
+
const runtime = new _BrowserRuntime({ autoHydrate: false });
|
|
259
|
+
await runtime.initialize();
|
|
260
|
+
return await runtime.render(component, props, target);
|
|
261
|
+
}
|
|
262
|
+
// Performance utilities
|
|
263
|
+
getPerformanceReport() {
|
|
264
|
+
const now = Date.now();
|
|
265
|
+
const uptime = now - this.startTime;
|
|
266
|
+
const recentMetrics = this.renderMetrics.filter((m) => m.timestamp >= now - 6e4);
|
|
267
|
+
const averageRenderTime = recentMetrics.length > 0 ? recentMetrics.reduce((sum, m) => sum + m.duration, 0) / recentMetrics.length : 0;
|
|
268
|
+
return {
|
|
269
|
+
uptime,
|
|
270
|
+
totalRenders: this.renderMetrics.length,
|
|
271
|
+
recentRenders: recentMetrics.length,
|
|
272
|
+
averageRenderTime: Math.round(averageRenderTime * 100) / 100,
|
|
273
|
+
registeredComponents: this.componentRegistry.size,
|
|
274
|
+
registeredRoutes: this.routeRegistry.size,
|
|
275
|
+
currentRoute: this.currentRoute,
|
|
276
|
+
memoryUsage: this.getMemoryUsage()
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
getMemoryUsage() {
|
|
280
|
+
if (typeof performance !== "undefined" && performance.memory) {
|
|
281
|
+
return {
|
|
282
|
+
used: Math.round(performance.memory.usedJSHeapSize / 1024 / 1024),
|
|
283
|
+
total: Math.round(performance.memory.totalJSHeapSize / 1024 / 1024),
|
|
284
|
+
limit: Math.round(performance.memory.jsHeapSizeLimit / 1024 / 1024)
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
// Development utilities
|
|
290
|
+
debug() {
|
|
291
|
+
return {
|
|
292
|
+
runtime: this,
|
|
293
|
+
components: Array.from(this.componentRegistry.keys()),
|
|
294
|
+
routes: Array.from(this.routeRegistry.keys()),
|
|
295
|
+
performance: this.getPerformanceReport(),
|
|
296
|
+
options: this.options
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
301
|
+
0 && (module.exports = {
|
|
302
|
+
BrowserRuntime
|
|
303
|
+
});
|
|
304
|
+
//# sourceMappingURL=coherent-browser.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/runtimes/browser.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Browser Runtime - Full client-side Coherent.js runtime\n * Works in browsers, Electron, and Tauri\n */\n\nimport { render, withState, memo } from '@coherent.js/core';\nimport { hydrate, autoHydrate, makeHydratable } from '@coherent.js/client';\nimport { integrateWithWebComponents, defineCoherentElement } from '@coherent.js/web-components';\n\nexport class BrowserRuntime {\n constructor(options = {}) {\n this.options = {\n autoHydrate: true,\n enableWebComponents: true,\n enablePerformanceMonitoring: true,\n routingMode: 'hash', // 'hash', 'history', or 'memory'\n ...options\n };\n \n this.componentRegistry = new Map();\n this.routeRegistry = new Map();\n this.currentRoute = null;\n this.isInitialized = false;\n \n // Performance tracking\n this.renderMetrics = [];\n this.startTime = Date.now();\n }\n\n async initialize() {\n if (this.isInitialized) return;\n\n // Wait for DOM to be ready\n if (document.readyState === 'loading') {\n await new Promise(resolve => {\n document.addEventListener('DOMContentLoaded', resolve);\n });\n }\n\n // Initialize Web Components integration\n if (this.options.enableWebComponents) {\n await this.initializeWebComponents();\n }\n\n // Initialize routing\n if (this.options.routingMode !== 'none') {\n this.initializeRouting();\n }\n\n // Auto-hydrate existing components\n if (this.options.autoHydrate) {\n await this.autoHydrate();\n }\n\n // Initialize performance monitoring\n if (this.options.enablePerformanceMonitoring) {\n this.initializePerformanceMonitoring();\n }\n\n this.isInitialized = true;\n }\n\n async initializeWebComponents() {\n try {\n await integrateWithWebComponents(\n Object.fromEntries(this.componentRegistry), \n this.options.webComponents || {}\n );\n } catch (error) {\n console.warn('Failed to initialize Web Components:', error);\n }\n }\n\n initializeRouting() {\n const handleRouteChange = () => {\n const newRoute = this.getCurrentRoute();\n if (newRoute !== this.currentRoute) {\n this.handleRouteChange(this.currentRoute, newRoute);\n this.currentRoute = newRoute;\n }\n };\n\n if (this.options.routingMode === 'hash') {\n window.addEventListener('hashchange', handleRouteChange);\n } else if (this.options.routingMode === 'history') {\n window.addEventListener('popstate', handleRouteChange);\n }\n\n // Handle initial route\n this.currentRoute = this.getCurrentRoute();\n handleRouteChange();\n }\n\n getCurrentRoute() {\n if (this.options.routingMode === 'hash') {\n return window.location.hash.slice(1) || '/';\n } else if (this.options.routingMode === 'history') {\n return window.location.pathname;\n }\n return '/';\n }\n\n handleRouteChange(oldRoute, newRoute) {\n const handler = this.routeRegistry.get(newRoute) || this.routeRegistry.get('*');\n \n if (handler) {\n try {\n handler({ route: newRoute, oldRoute, params: this.parseRouteParams(newRoute) });\n } catch (error) {\n console.error('Route handler error:', error);\n }\n }\n }\n\n parseRouteParams(route) {\n // Simple parameter parsing - can be enhanced\n const params = {};\n const parts = route.split('/').filter(Boolean);\n \n parts.forEach((part, index) => {\n if (part.startsWith(':')) {\n const key = part.slice(1);\n const value = parts[index];\n if (value && !value.startsWith(':')) {\n params[key] = value;\n }\n }\n });\n \n return params;\n }\n\n initializePerformanceMonitoring() {\n // Monitor render performance\n if (typeof window === 'undefined' || typeof window.PerformanceObserver === 'undefined') return;\n const observer = new window.PerformanceObserver((list) => {\n for (const entry of list.getEntries()) {\n if (entry.name.includes('coherent')) {\n this.renderMetrics.push({\n name: entry.name,\n duration: entry.duration,\n startTime: entry.startTime,\n timestamp: Date.now()\n });\n }\n }\n });\n\n try {\n observer.observe({ entryTypes: ['measure', 'mark'] });\n } catch (error) {\n console.warn('Performance monitoring not available:', error);\n }\n\n // Clean up old metrics periodically\n setInterval(() => {\n const cutoff = Date.now() - 300000; // 5 minutes\n this.renderMetrics = this.renderMetrics.filter(m => m.timestamp > cutoff);\n }, 60000); // Every minute\n }\n\n // Component management\n registerComponent(name, component, options = {}) {\n // Make component hydratable\n const hydratableComponent = makeHydratable(component, {\n componentName: name,\n ...options\n });\n\n this.componentRegistry.set(name, hydratableComponent);\n\n // Register as Web Component if enabled\n if (this.options.enableWebComponents && this.isInitialized) {\n try {\n defineCoherentElement(name, hydratableComponent, options);\n } catch (error) {\n console.warn(`Failed to register Web Component ${name}:`, error);\n }\n }\n\n return hydratableComponent;\n }\n\n getComponent(name) {\n return this.componentRegistry.get(name);\n }\n\n // Routing\n addRoute(path, handler) {\n this.routeRegistry.set(path, handler);\n }\n\n navigate(path) {\n if (this.options.routingMode === 'hash') {\n window.location.hash = path;\n } else if (this.options.routingMode === 'history') {\n window.history.pushState({}, '', path);\n this.handleRouteChange(this.currentRoute, path);\n this.currentRoute = path;\n }\n }\n\n // Rendering\n async render(component, props = {}, target = null) {\n const startMark = `coherent-render-start-${Date.now()}`;\n const endMark = `coherent-render-end-${Date.now()}`;\n \n try {\n performance.mark(startMark);\n\n // Resolve component\n const resolvedComponent = typeof component === 'string' \n ? this.getComponent(component) \n : component;\n\n if (!resolvedComponent) {\n throw new Error(`Component not found: ${component}`);\n }\n\n // Render component\n const vdom = resolvedComponent(props);\n const html = render(vdom);\n\n // Find or create target element\n let targetElement = target;\n if (typeof target === 'string') {\n targetElement = document.querySelector(target);\n }\n if (!targetElement) {\n targetElement = document.body;\n }\n\n // Update DOM\n targetElement.innerHTML = html;\n\n // Hydrate the rendered component\n const instance = await hydrate(targetElement.firstElementChild, resolvedComponent, props);\n\n performance.mark(endMark);\n performance.measure(`coherent-render-${resolvedComponent.name || 'anonymous'}`, startMark, endMark);\n\n return instance;\n } catch (error) {\n performance.mark(endMark);\n console.error('Render error:', error);\n throw error;\n }\n }\n\n // Create a complete app\n async createApp(_options = {}) {\n await this.initialize();\n \n return {\n // Component management\n component: (name, component, opts) => this.registerComponent(name, component, opts),\n \n // Routing\n route: (path, handler) => this.addRoute(path, handler),\n navigate: (path) => this.navigate(path),\n \n // Rendering\n render: (component, props, target) => this.render(component, props, target),\n \n // State management\n state: withState,\n memo: memo,\n \n // Hydration\n hydrate: (element, component, props) => hydrate(element, component, props),\n \n // Utilities\n getRuntime: () => this,\n getCurrentRoute: () => this.currentRoute,\n getPerformanceMetrics: () => [...this.renderMetrics],\n \n // Lifecycle\n mount: async (component, target = '#app') => {\n const app = await this.render(component, {}, target);\n return app;\n },\n \n unmount: (target = '#app') => {\n const element = typeof target === 'string' ? document.querySelector(target) : target;\n if (element) {\n element.innerHTML = '';\n }\n }\n };\n }\n\n // Auto-hydration\n async autoHydrate() {\n const componentMap = Object.fromEntries(this.componentRegistry);\n await autoHydrate(componentMap);\n }\n\n // Static methods for quick setup\n static async createQuickApp(components = {}, options = {}) {\n const runtime = new BrowserRuntime(options);\n \n // Register all components\n Object.entries(components).forEach(([name, component]) => {\n runtime.registerComponent(name, component);\n });\n \n return await runtime.createApp(options);\n }\n\n static async renderToPage(component, props = {}, target = '#app') {\n const runtime = new BrowserRuntime({ autoHydrate: false });\n await runtime.initialize();\n return await runtime.render(component, props, target);\n }\n\n // Performance utilities\n getPerformanceReport() {\n const now = Date.now();\n const uptime = now - this.startTime;\n const recentMetrics = this.renderMetrics.filter(m => m.timestamp >= now - 60000);\n \n const averageRenderTime = recentMetrics.length > 0\n ? recentMetrics.reduce((sum, m) => sum + m.duration, 0) / recentMetrics.length\n : 0;\n\n return {\n uptime,\n totalRenders: this.renderMetrics.length,\n recentRenders: recentMetrics.length,\n averageRenderTime: Math.round(averageRenderTime * 100) / 100,\n registeredComponents: this.componentRegistry.size,\n registeredRoutes: this.routeRegistry.size,\n currentRoute: this.currentRoute,\n memoryUsage: this.getMemoryUsage()\n };\n }\n\n getMemoryUsage() {\n if (typeof performance !== 'undefined' && performance.memory) {\n return {\n used: Math.round(performance.memory.usedJSHeapSize / 1024 / 1024),\n total: Math.round(performance.memory.totalJSHeapSize / 1024 / 1024),\n limit: Math.round(performance.memory.jsHeapSizeLimit / 1024 / 1024)\n };\n }\n return null;\n }\n\n // Development utilities\n debug() {\n return {\n runtime: this,\n components: Array.from(this.componentRegistry.keys()),\n routes: Array.from(this.routeRegistry.keys()),\n performance: this.getPerformanceReport(),\n options: this.options\n };\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,kBAAwC;AACxC,oBAAqD;AACrD,4BAAkE;AAE3D,IAAM,iBAAN,MAAM,gBAAe;AAAA,EAC1B,YAAY,UAAU,CAAC,GAAG;AACxB,SAAK,UAAU;AAAA,MACb,aAAa;AAAA,MACb,qBAAqB;AAAA,MACrB,6BAA6B;AAAA,MAC7B,aAAa;AAAA;AAAA,MACb,GAAG;AAAA,IACL;AAEA,SAAK,oBAAoB,oBAAI,IAAI;AACjC,SAAK,gBAAgB,oBAAI,IAAI;AAC7B,SAAK,eAAe;AACpB,SAAK,gBAAgB;AAGrB,SAAK,gBAAgB,CAAC;AACtB,SAAK,YAAY,KAAK,IAAI;AAAA,EAC5B;AAAA,EAEA,MAAM,aAAa;AACjB,QAAI,KAAK,cAAe;AAGxB,QAAI,SAAS,eAAe,WAAW;AACrC,YAAM,IAAI,QAAQ,aAAW;AAC3B,iBAAS,iBAAiB,oBAAoB,OAAO;AAAA,MACvD,CAAC;AAAA,IACH;AAGA,QAAI,KAAK,QAAQ,qBAAqB;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AAc;AAAA,MACrC,cAAc,KAAK;AAAA,MACnB,aAAa,KAAK,eAAe;AAAA,IACnC;AAAA,EACF;AAAA,EAEA,iBAAiB;AACf,QAAI,OAAO,gBAAgB,eAAe,YAAY,QAAQ;AAC5D,aAAO;AAAA,QACL,MAAM,KAAK,MAAM,YAAY,OAAO,iBAAiB,OAAO,IAAI;AAAA,QAChE,OAAO,KAAK,MAAM,YAAY,OAAO,kBAAkB,OAAO,IAAI;AAAA,QAClE,OAAO,KAAK,MAAM,YAAY,OAAO,kBAAkB,OAAO,IAAI;AAAA,MACpE;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA;AAAA,EAGA,QAAQ;AACN,WAAO;AAAA,MACL,SAAS;AAAA,MACT,YAAY,MAAM,KAAK,KAAK,kBAAkB,KAAK,CAAC;AAAA,MACpD,QAAQ,MAAM,KAAK,KAAK,cAAc,KAAK,CAAC;AAAA,MAC5C,aAAa,KAAK,qBAAqB;AAAA,MACvC,SAAS,KAAK;AAAA,IAChB;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
// src/runtimes/browser.js
|
|
2
|
+
import { render, withState, memo } from "@coherent.js/core";
|
|
3
|
+
import { hydrate, autoHydrate, makeHydratable } from "@coherent.js/client";
|
|
4
|
+
import { integrateWithWebComponents, defineCoherentElement } from "@coherent.js/web-components";
|
|
5
|
+
var BrowserRuntime = class _BrowserRuntime {
|
|
6
|
+
constructor(options = {}) {
|
|
7
|
+
this.options = {
|
|
8
|
+
autoHydrate: true,
|
|
9
|
+
enableWebComponents: true,
|
|
10
|
+
enablePerformanceMonitoring: true,
|
|
11
|
+
routingMode: "hash",
|
|
12
|
+
// 'hash', 'history', or 'memory'
|
|
13
|
+
...options
|
|
14
|
+
};
|
|
15
|
+
this.componentRegistry = /* @__PURE__ */ new Map();
|
|
16
|
+
this.routeRegistry = /* @__PURE__ */ new Map();
|
|
17
|
+
this.currentRoute = null;
|
|
18
|
+
this.isInitialized = false;
|
|
19
|
+
this.renderMetrics = [];
|
|
20
|
+
this.startTime = Date.now();
|
|
21
|
+
}
|
|
22
|
+
async initialize() {
|
|
23
|
+
if (this.isInitialized) return;
|
|
24
|
+
if (document.readyState === "loading") {
|
|
25
|
+
await new Promise((resolve) => {
|
|
26
|
+
document.addEventListener("DOMContentLoaded", resolve);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
if (this.options.enableWebComponents) {
|
|
30
|
+
await this.initializeWebComponents();
|
|
31
|
+
}
|
|
32
|
+
if (this.options.routingMode !== "none") {
|
|
33
|
+
this.initializeRouting();
|
|
34
|
+
}
|
|
35
|
+
if (this.options.autoHydrate) {
|
|
36
|
+
await this.autoHydrate();
|
|
37
|
+
}
|
|
38
|
+
if (this.options.enablePerformanceMonitoring) {
|
|
39
|
+
this.initializePerformanceMonitoring();
|
|
40
|
+
}
|
|
41
|
+
this.isInitialized = true;
|
|
42
|
+
}
|
|
43
|
+
async initializeWebComponents() {
|
|
44
|
+
try {
|
|
45
|
+
await integrateWithWebComponents(
|
|
46
|
+
Object.fromEntries(this.componentRegistry),
|
|
47
|
+
this.options.webComponents || {}
|
|
48
|
+
);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.warn("Failed to initialize Web Components:", error);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
initializeRouting() {
|
|
54
|
+
const handleRouteChange = () => {
|
|
55
|
+
const newRoute = this.getCurrentRoute();
|
|
56
|
+
if (newRoute !== this.currentRoute) {
|
|
57
|
+
this.handleRouteChange(this.currentRoute, newRoute);
|
|
58
|
+
this.currentRoute = newRoute;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
if (this.options.routingMode === "hash") {
|
|
62
|
+
window.addEventListener("hashchange", handleRouteChange);
|
|
63
|
+
} else if (this.options.routingMode === "history") {
|
|
64
|
+
window.addEventListener("popstate", handleRouteChange);
|
|
65
|
+
}
|
|
66
|
+
this.currentRoute = this.getCurrentRoute();
|
|
67
|
+
handleRouteChange();
|
|
68
|
+
}
|
|
69
|
+
getCurrentRoute() {
|
|
70
|
+
if (this.options.routingMode === "hash") {
|
|
71
|
+
return window.location.hash.slice(1) || "/";
|
|
72
|
+
} else if (this.options.routingMode === "history") {
|
|
73
|
+
return window.location.pathname;
|
|
74
|
+
}
|
|
75
|
+
return "/";
|
|
76
|
+
}
|
|
77
|
+
handleRouteChange(oldRoute, newRoute) {
|
|
78
|
+
const handler = this.routeRegistry.get(newRoute) || this.routeRegistry.get("*");
|
|
79
|
+
if (handler) {
|
|
80
|
+
try {
|
|
81
|
+
handler({ route: newRoute, oldRoute, params: this.parseRouteParams(newRoute) });
|
|
82
|
+
} catch (error) {
|
|
83
|
+
console.error("Route handler error:", error);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
parseRouteParams(route) {
|
|
88
|
+
const params = {};
|
|
89
|
+
const parts = route.split("/").filter(Boolean);
|
|
90
|
+
parts.forEach((part, index) => {
|
|
91
|
+
if (part.startsWith(":")) {
|
|
92
|
+
const key = part.slice(1);
|
|
93
|
+
const value = parts[index];
|
|
94
|
+
if (value && !value.startsWith(":")) {
|
|
95
|
+
params[key] = value;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
return params;
|
|
100
|
+
}
|
|
101
|
+
initializePerformanceMonitoring() {
|
|
102
|
+
if (typeof window === "undefined" || typeof window.PerformanceObserver === "undefined") return;
|
|
103
|
+
const observer = new window.PerformanceObserver((list) => {
|
|
104
|
+
for (const entry of list.getEntries()) {
|
|
105
|
+
if (entry.name.includes("coherent")) {
|
|
106
|
+
this.renderMetrics.push({
|
|
107
|
+
name: entry.name,
|
|
108
|
+
duration: entry.duration,
|
|
109
|
+
startTime: entry.startTime,
|
|
110
|
+
timestamp: Date.now()
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
try {
|
|
116
|
+
observer.observe({ entryTypes: ["measure", "mark"] });
|
|
117
|
+
} catch (error) {
|
|
118
|
+
console.warn("Performance monitoring not available:", error);
|
|
119
|
+
}
|
|
120
|
+
setInterval(() => {
|
|
121
|
+
const cutoff = Date.now() - 3e5;
|
|
122
|
+
this.renderMetrics = this.renderMetrics.filter((m) => m.timestamp > cutoff);
|
|
123
|
+
}, 6e4);
|
|
124
|
+
}
|
|
125
|
+
// Component management
|
|
126
|
+
registerComponent(name, component, options = {}) {
|
|
127
|
+
const hydratableComponent = makeHydratable(component, {
|
|
128
|
+
componentName: name,
|
|
129
|
+
...options
|
|
130
|
+
});
|
|
131
|
+
this.componentRegistry.set(name, hydratableComponent);
|
|
132
|
+
if (this.options.enableWebComponents && this.isInitialized) {
|
|
133
|
+
try {
|
|
134
|
+
defineCoherentElement(name, hydratableComponent, options);
|
|
135
|
+
} catch (error) {
|
|
136
|
+
console.warn(`Failed to register Web Component ${name}:`, error);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return hydratableComponent;
|
|
140
|
+
}
|
|
141
|
+
getComponent(name) {
|
|
142
|
+
return this.componentRegistry.get(name);
|
|
143
|
+
}
|
|
144
|
+
// Routing
|
|
145
|
+
addRoute(path, handler) {
|
|
146
|
+
this.routeRegistry.set(path, handler);
|
|
147
|
+
}
|
|
148
|
+
navigate(path) {
|
|
149
|
+
if (this.options.routingMode === "hash") {
|
|
150
|
+
window.location.hash = path;
|
|
151
|
+
} else if (this.options.routingMode === "history") {
|
|
152
|
+
window.history.pushState({}, "", path);
|
|
153
|
+
this.handleRouteChange(this.currentRoute, path);
|
|
154
|
+
this.currentRoute = path;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// Rendering
|
|
158
|
+
async render(component, props = {}, target = null) {
|
|
159
|
+
const startMark = `coherent-render-start-${Date.now()}`;
|
|
160
|
+
const endMark = `coherent-render-end-${Date.now()}`;
|
|
161
|
+
try {
|
|
162
|
+
performance.mark(startMark);
|
|
163
|
+
const resolvedComponent = typeof component === "string" ? this.getComponent(component) : component;
|
|
164
|
+
if (!resolvedComponent) {
|
|
165
|
+
throw new Error(`Component not found: ${component}`);
|
|
166
|
+
}
|
|
167
|
+
const vdom = resolvedComponent(props);
|
|
168
|
+
const html = render(vdom);
|
|
169
|
+
let targetElement = target;
|
|
170
|
+
if (typeof target === "string") {
|
|
171
|
+
targetElement = document.querySelector(target);
|
|
172
|
+
}
|
|
173
|
+
if (!targetElement) {
|
|
174
|
+
targetElement = document.body;
|
|
175
|
+
}
|
|
176
|
+
targetElement.innerHTML = html;
|
|
177
|
+
const instance = await hydrate(targetElement.firstElementChild, resolvedComponent, props);
|
|
178
|
+
performance.mark(endMark);
|
|
179
|
+
performance.measure(`coherent-render-${resolvedComponent.name || "anonymous"}`, startMark, endMark);
|
|
180
|
+
return instance;
|
|
181
|
+
} catch (error) {
|
|
182
|
+
performance.mark(endMark);
|
|
183
|
+
console.error("Render error:", error);
|
|
184
|
+
throw error;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
// Create a complete app
|
|
188
|
+
async createApp(_options = {}) {
|
|
189
|
+
await this.initialize();
|
|
190
|
+
return {
|
|
191
|
+
// Component management
|
|
192
|
+
component: (name, component, opts) => this.registerComponent(name, component, opts),
|
|
193
|
+
// Routing
|
|
194
|
+
route: (path, handler) => this.addRoute(path, handler),
|
|
195
|
+
navigate: (path) => this.navigate(path),
|
|
196
|
+
// Rendering
|
|
197
|
+
render: (component, props, target) => this.render(component, props, target),
|
|
198
|
+
// State management
|
|
199
|
+
state: withState,
|
|
200
|
+
memo,
|
|
201
|
+
// Hydration
|
|
202
|
+
hydrate: (element, component, props) => hydrate(element, component, props),
|
|
203
|
+
// Utilities
|
|
204
|
+
getRuntime: () => this,
|
|
205
|
+
getCurrentRoute: () => this.currentRoute,
|
|
206
|
+
getPerformanceMetrics: () => [...this.renderMetrics],
|
|
207
|
+
// Lifecycle
|
|
208
|
+
mount: async (component, target = "#app") => {
|
|
209
|
+
const app = await this.render(component, {}, target);
|
|
210
|
+
return app;
|
|
211
|
+
},
|
|
212
|
+
unmount: (target = "#app") => {
|
|
213
|
+
const element = typeof target === "string" ? document.querySelector(target) : target;
|
|
214
|
+
if (element) {
|
|
215
|
+
element.innerHTML = "";
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
// Auto-hydration
|
|
221
|
+
async autoHydrate() {
|
|
222
|
+
const componentMap = Object.fromEntries(this.componentRegistry);
|
|
223
|
+
await autoHydrate(componentMap);
|
|
224
|
+
}
|
|
225
|
+
// Static methods for quick setup
|
|
226
|
+
static async createQuickApp(components = {}, options = {}) {
|
|
227
|
+
const runtime = new _BrowserRuntime(options);
|
|
228
|
+
Object.entries(components).forEach(([name, component]) => {
|
|
229
|
+
runtime.registerComponent(name, component);
|
|
230
|
+
});
|
|
231
|
+
return await runtime.createApp(options);
|
|
232
|
+
}
|
|
233
|
+
static async renderToPage(component, props = {}, target = "#app") {
|
|
234
|
+
const runtime = new _BrowserRuntime({ autoHydrate: false });
|
|
235
|
+
await runtime.initialize();
|
|
236
|
+
return await runtime.render(component, props, target);
|
|
237
|
+
}
|
|
238
|
+
// Performance utilities
|
|
239
|
+
getPerformanceReport() {
|
|
240
|
+
const now = Date.now();
|
|
241
|
+
const uptime = now - this.startTime;
|
|
242
|
+
const recentMetrics = this.renderMetrics.filter((m) => m.timestamp >= now - 6e4);
|
|
243
|
+
const averageRenderTime = recentMetrics.length > 0 ? recentMetrics.reduce((sum, m) => sum + m.duration, 0) / recentMetrics.length : 0;
|
|
244
|
+
return {
|
|
245
|
+
uptime,
|
|
246
|
+
totalRenders: this.renderMetrics.length,
|
|
247
|
+
recentRenders: recentMetrics.length,
|
|
248
|
+
averageRenderTime: Math.round(averageRenderTime * 100) / 100,
|
|
249
|
+
registeredComponents: this.componentRegistry.size,
|
|
250
|
+
registeredRoutes: this.routeRegistry.size,
|
|
251
|
+
currentRoute: this.currentRoute,
|
|
252
|
+
memoryUsage: this.getMemoryUsage()
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
getMemoryUsage() {
|
|
256
|
+
if (typeof performance !== "undefined" && performance.memory) {
|
|
257
|
+
return {
|
|
258
|
+
used: Math.round(performance.memory.usedJSHeapSize / 1024 / 1024),
|
|
259
|
+
total: Math.round(performance.memory.totalJSHeapSize / 1024 / 1024),
|
|
260
|
+
limit: Math.round(performance.memory.jsHeapSizeLimit / 1024 / 1024)
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
// Development utilities
|
|
266
|
+
debug() {
|
|
267
|
+
return {
|
|
268
|
+
runtime: this,
|
|
269
|
+
components: Array.from(this.componentRegistry.keys()),
|
|
270
|
+
routes: Array.from(this.routeRegistry.keys()),
|
|
271
|
+
performance: this.getPerformanceReport(),
|
|
272
|
+
options: this.options
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
export {
|
|
277
|
+
BrowserRuntime
|
|
278
|
+
};
|
|
279
|
+
//# sourceMappingURL=coherent-browser.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/runtimes/browser.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Browser Runtime - Full client-side Coherent.js runtime\n * Works in browsers, Electron, and Tauri\n */\n\nimport { render, withState, memo } from '@coherent.js/core';\nimport { hydrate, autoHydrate, makeHydratable } from '@coherent.js/client';\nimport { integrateWithWebComponents, defineCoherentElement } from '@coherent.js/web-components';\n\nexport class BrowserRuntime {\n constructor(options = {}) {\n this.options = {\n autoHydrate: true,\n enableWebComponents: true,\n enablePerformanceMonitoring: true,\n routingMode: 'hash', // 'hash', 'history', or 'memory'\n ...options\n };\n \n this.componentRegistry = new Map();\n this.routeRegistry = new Map();\n this.currentRoute = null;\n this.isInitialized = false;\n \n // Performance tracking\n this.renderMetrics = [];\n this.startTime = Date.now();\n }\n\n async initialize() {\n if (this.isInitialized) return;\n\n // Wait for DOM to be ready\n if (document.readyState === 'loading') {\n await new Promise(resolve => {\n document.addEventListener('DOMContentLoaded', resolve);\n });\n }\n\n // Initialize Web Components integration\n if (this.options.enableWebComponents) {\n await this.initializeWebComponents();\n }\n\n // Initialize routing\n if (this.options.routingMode !== 'none') {\n this.initializeRouting();\n }\n\n // Auto-hydrate existing components\n if (this.options.autoHydrate) {\n await this.autoHydrate();\n }\n\n // Initialize performance monitoring\n if (this.options.enablePerformanceMonitoring) {\n this.initializePerformanceMonitoring();\n }\n\n this.isInitialized = true;\n }\n\n async initializeWebComponents() {\n try {\n await integrateWithWebComponents(\n Object.fromEntries(this.componentRegistry), \n this.options.webComponents || {}\n );\n } catch (error) {\n console.warn('Failed to initialize Web Components:', error);\n }\n }\n\n initializeRouting() {\n const handleRouteChange = () => {\n const newRoute = this.getCurrentRoute();\n if (newRoute !== this.currentRoute) {\n this.handleRouteChange(this.currentRoute, newRoute);\n this.currentRoute = newRoute;\n }\n };\n\n if (this.options.routingMode === 'hash') {\n window.addEventListener('hashchange', handleRouteChange);\n } else if (this.options.routingMode === 'history') {\n window.addEventListener('popstate', handleRouteChange);\n }\n\n // Handle initial route\n this.currentRoute = this.getCurrentRoute();\n handleRouteChange();\n }\n\n getCurrentRoute() {\n if (this.options.routingMode === 'hash') {\n return window.location.hash.slice(1) || '/';\n } else if (this.options.routingMode === 'history') {\n return window.location.pathname;\n }\n return '/';\n }\n\n handleRouteChange(oldRoute, newRoute) {\n const handler = this.routeRegistry.get(newRoute) || this.routeRegistry.get('*');\n \n if (handler) {\n try {\n handler({ route: newRoute, oldRoute, params: this.parseRouteParams(newRoute) });\n } catch (error) {\n console.error('Route handler error:', error);\n }\n }\n }\n\n parseRouteParams(route) {\n // Simple parameter parsing - can be enhanced\n const params = {};\n const parts = route.split('/').filter(Boolean);\n \n parts.forEach((part, index) => {\n if (part.startsWith(':')) {\n const key = part.slice(1);\n const value = parts[index];\n if (value && !value.startsWith(':')) {\n params[key] = value;\n }\n }\n });\n \n return params;\n }\n\n initializePerformanceMonitoring() {\n // Monitor render performance\n if (typeof window === 'undefined' || typeof window.PerformanceObserver === 'undefined') return;\n const observer = new window.PerformanceObserver((list) => {\n for (const entry of list.getEntries()) {\n if (entry.name.includes('coherent')) {\n this.renderMetrics.push({\n name: entry.name,\n duration: entry.duration,\n startTime: entry.startTime,\n timestamp: Date.now()\n });\n }\n }\n });\n\n try {\n observer.observe({ entryTypes: ['measure', 'mark'] });\n } catch (error) {\n console.warn('Performance monitoring not available:', error);\n }\n\n // Clean up old metrics periodically\n setInterval(() => {\n const cutoff = Date.now() - 300000; // 5 minutes\n this.renderMetrics = this.renderMetrics.filter(m => m.timestamp > cutoff);\n }, 60000); // Every minute\n }\n\n // Component management\n registerComponent(name, component, options = {}) {\n // Make component hydratable\n const hydratableComponent = makeHydratable(component, {\n componentName: name,\n ...options\n });\n\n this.componentRegistry.set(name, hydratableComponent);\n\n // Register as Web Component if enabled\n if (this.options.enableWebComponents && this.isInitialized) {\n try {\n defineCoherentElement(name, hydratableComponent, options);\n } catch (error) {\n console.warn(`Failed to register Web Component ${name}:`, error);\n }\n }\n\n return hydratableComponent;\n }\n\n getComponent(name) {\n return this.componentRegistry.get(name);\n }\n\n // Routing\n addRoute(path, handler) {\n this.routeRegistry.set(path, handler);\n }\n\n navigate(path) {\n if (this.options.routingMode === 'hash') {\n window.location.hash = path;\n } else if (this.options.routingMode === 'history') {\n window.history.pushState({}, '', path);\n this.handleRouteChange(this.currentRoute, path);\n this.currentRoute = path;\n }\n }\n\n // Rendering\n async render(component, props = {}, target = null) {\n const startMark = `coherent-render-start-${Date.now()}`;\n const endMark = `coherent-render-end-${Date.now()}`;\n \n try {\n performance.mark(startMark);\n\n // Resolve component\n const resolvedComponent = typeof component === 'string' \n ? this.getComponent(component) \n : component;\n\n if (!resolvedComponent) {\n throw new Error(`Component not found: ${component}`);\n }\n\n // Render component\n const vdom = resolvedComponent(props);\n const html = render(vdom);\n\n // Find or create target element\n let targetElement = target;\n if (typeof target === 'string') {\n targetElement = document.querySelector(target);\n }\n if (!targetElement) {\n targetElement = document.body;\n }\n\n // Update DOM\n targetElement.innerHTML = html;\n\n // Hydrate the rendered component\n const instance = await hydrate(targetElement.firstElementChild, resolvedComponent, props);\n\n performance.mark(endMark);\n performance.measure(`coherent-render-${resolvedComponent.name || 'anonymous'}`, startMark, endMark);\n\n return instance;\n } catch (error) {\n performance.mark(endMark);\n console.error('Render error:', error);\n throw error;\n }\n }\n\n // Create a complete app\n async createApp(_options = {}) {\n await this.initialize();\n \n return {\n // Component management\n component: (name, component, opts) => this.registerComponent(name, component, opts),\n \n // Routing\n route: (path, handler) => this.addRoute(path, handler),\n navigate: (path) => this.navigate(path),\n \n // Rendering\n render: (component, props, target) => this.render(component, props, target),\n \n // State management\n state: withState,\n memo: memo,\n \n // Hydration\n hydrate: (element, component, props) => hydrate(element, component, props),\n \n // Utilities\n getRuntime: () => this,\n getCurrentRoute: () => this.currentRoute,\n getPerformanceMetrics: () => [...this.renderMetrics],\n \n // Lifecycle\n mount: async (component, target = '#app') => {\n const app = await this.render(component, {}, target);\n return app;\n },\n \n unmount: (target = '#app') => {\n const element = typeof target === 'string' ? document.querySelector(target) : target;\n if (element) {\n element.innerHTML = '';\n }\n }\n };\n }\n\n // Auto-hydration\n async autoHydrate() {\n const componentMap = Object.fromEntries(this.componentRegistry);\n await autoHydrate(componentMap);\n }\n\n // Static methods for quick setup\n static async createQuickApp(components = {}, options = {}) {\n const runtime = new BrowserRuntime(options);\n \n // Register all components\n Object.entries(components).forEach(([name, component]) => {\n runtime.registerComponent(name, component);\n });\n \n return await runtime.createApp(options);\n }\n\n static async renderToPage(component, props = {}, target = '#app') {\n const runtime = new BrowserRuntime({ autoHydrate: false });\n await runtime.initialize();\n return await runtime.render(component, props, target);\n }\n\n // Performance utilities\n getPerformanceReport() {\n const now = Date.now();\n const uptime = now - this.startTime;\n const recentMetrics = this.renderMetrics.filter(m => m.timestamp >= now - 60000);\n \n const averageRenderTime = recentMetrics.length > 0\n ? recentMetrics.reduce((sum, m) => sum + m.duration, 0) / recentMetrics.length\n : 0;\n\n return {\n uptime,\n totalRenders: this.renderMetrics.length,\n recentRenders: recentMetrics.length,\n averageRenderTime: Math.round(averageRenderTime * 100) / 100,\n registeredComponents: this.componentRegistry.size,\n registeredRoutes: this.routeRegistry.size,\n currentRoute: this.currentRoute,\n memoryUsage: this.getMemoryUsage()\n };\n }\n\n getMemoryUsage() {\n if (typeof performance !== 'undefined' && performance.memory) {\n return {\n used: Math.round(performance.memory.usedJSHeapSize / 1024 / 1024),\n total: Math.round(performance.memory.totalJSHeapSize / 1024 / 1024),\n limit: Math.round(performance.memory.jsHeapSizeLimit / 1024 / 1024)\n };\n }\n return null;\n }\n\n // Development utilities\n debug() {\n return {\n runtime: this,\n components: Array.from(this.componentRegistry.keys()),\n routes: Array.from(this.routeRegistry.keys()),\n performance: this.getPerformanceReport(),\n options: this.options\n };\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAKA,SAAS,QAAQ,WAAW,YAAY;AACxC,SAAS,SAAS,aAAa,sBAAsB;AACrD,SAAS,4BAA4B,6BAA6B;AAE3D,IAAM,iBAAN,MAAM,gBAAe;AAAA,EAC1B,YAAY,UAAU,CAAC,GAAG;AACxB,SAAK,UAAU;AAAA,MACb,aAAa;AAAA,MACb,qBAAqB;AAAA,MACrB,6BAA6B;AAAA,MAC7B,aAAa;AAAA;AAAA,MACb,GAAG;AAAA,IACL;AAEA,SAAK,oBAAoB,oBAAI,IAAI;AACjC,SAAK,gBAAgB,oBAAI,IAAI;AAC7B,SAAK,eAAe;AACpB,SAAK,gBAAgB;AAGrB,SAAK,gBAAgB,CAAC;AACtB,SAAK,YAAY,KAAK,IAAI;AAAA,EAC5B;AAAA,EAEA,MAAM,aAAa;AACjB,QAAI,KAAK,cAAe;AAGxB,QAAI,SAAS,eAAe,WAAW;AACrC,YAAM,IAAI,QAAQ,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