@clusterenvision/ui-framework 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +295 -0
  3. package/dist/ai-assistant-Db002XYC.d.ts +92 -0
  4. package/dist/ai-assistant-EobSUV70.d.cts +92 -0
  5. package/dist/browser-DnHpnWwE.d.cts +354 -0
  6. package/dist/browser-Dx4oKf5e.d.ts +354 -0
  7. package/dist/browser-signals-07qodpYT.d.cts +66 -0
  8. package/dist/browser-signals-07qodpYT.d.ts +66 -0
  9. package/dist/browser-signals.cjs +32 -0
  10. package/dist/browser-signals.cjs.map +1 -0
  11. package/dist/browser-signals.d.cts +1 -0
  12. package/dist/browser-signals.d.ts +1 -0
  13. package/dist/browser-signals.js +3 -0
  14. package/dist/browser-signals.js.map +1 -0
  15. package/dist/browser.cjs +197 -0
  16. package/dist/browser.cjs.map +1 -0
  17. package/dist/browser.d.cts +13 -0
  18. package/dist/browser.d.ts +13 -0
  19. package/dist/browser.js +12 -0
  20. package/dist/browser.js.map +1 -0
  21. package/dist/chunk-22HQL2Y4.js +568 -0
  22. package/dist/chunk-22HQL2Y4.js.map +1 -0
  23. package/dist/chunk-3ZBRNFEE.js +1525 -0
  24. package/dist/chunk-3ZBRNFEE.js.map +1 -0
  25. package/dist/chunk-4HRORR2Q.js +1953 -0
  26. package/dist/chunk-4HRORR2Q.js.map +1 -0
  27. package/dist/chunk-4L3UXVL5.cjs +68 -0
  28. package/dist/chunk-4L3UXVL5.cjs.map +1 -0
  29. package/dist/chunk-6BYWFGQY.cjs +226 -0
  30. package/dist/chunk-6BYWFGQY.cjs.map +1 -0
  31. package/dist/chunk-7SCIB5HP.js +57 -0
  32. package/dist/chunk-7SCIB5HP.js.map +1 -0
  33. package/dist/chunk-BBAUALNU.js +888 -0
  34. package/dist/chunk-BBAUALNU.js.map +1 -0
  35. package/dist/chunk-CHLDE4JQ.js +715 -0
  36. package/dist/chunk-CHLDE4JQ.js.map +1 -0
  37. package/dist/chunk-CXTAUXLG.cjs +71 -0
  38. package/dist/chunk-CXTAUXLG.cjs.map +1 -0
  39. package/dist/chunk-D2USIT6V.js +121 -0
  40. package/dist/chunk-D2USIT6V.js.map +1 -0
  41. package/dist/chunk-D3H5CGVD.js +36 -0
  42. package/dist/chunk-D3H5CGVD.js.map +1 -0
  43. package/dist/chunk-DQBX75NJ.js +92 -0
  44. package/dist/chunk-DQBX75NJ.js.map +1 -0
  45. package/dist/chunk-DRPG2DFX.js +208 -0
  46. package/dist/chunk-DRPG2DFX.js.map +1 -0
  47. package/dist/chunk-EFOOXCY7.cjs +41 -0
  48. package/dist/chunk-EFOOXCY7.cjs.map +1 -0
  49. package/dist/chunk-FFCZSYC7.cjs +906 -0
  50. package/dist/chunk-FFCZSYC7.cjs.map +1 -0
  51. package/dist/chunk-FNXIYAET.cjs +1593 -0
  52. package/dist/chunk-FNXIYAET.cjs.map +1 -0
  53. package/dist/chunk-I6GNUM3P.cjs +63 -0
  54. package/dist/chunk-I6GNUM3P.cjs.map +1 -0
  55. package/dist/chunk-IHAMVLRY.js +129 -0
  56. package/dist/chunk-IHAMVLRY.js.map +1 -0
  57. package/dist/chunk-IRBUKIRF.cjs +133 -0
  58. package/dist/chunk-IRBUKIRF.cjs.map +1 -0
  59. package/dist/chunk-KPG5HAHK.cjs +97 -0
  60. package/dist/chunk-KPG5HAHK.cjs.map +1 -0
  61. package/dist/chunk-N7Q2ESLG.cjs +130 -0
  62. package/dist/chunk-N7Q2ESLG.cjs.map +1 -0
  63. package/dist/chunk-PFBEIFVS.js +180 -0
  64. package/dist/chunk-PFBEIFVS.js.map +1 -0
  65. package/dist/chunk-PVZVFICK.cjs +318 -0
  66. package/dist/chunk-PVZVFICK.cjs.map +1 -0
  67. package/dist/chunk-Q3KH6HMU.js +305 -0
  68. package/dist/chunk-Q3KH6HMU.js.map +1 -0
  69. package/dist/chunk-QPAAV32J.cjs +1985 -0
  70. package/dist/chunk-QPAAV32J.cjs.map +1 -0
  71. package/dist/chunk-R6XQUMWT.cjs +61 -0
  72. package/dist/chunk-R6XQUMWT.cjs.map +1 -0
  73. package/dist/chunk-SA5UD5B6.js +92 -0
  74. package/dist/chunk-SA5UD5B6.js.map +1 -0
  75. package/dist/chunk-SM35JOYD.cjs +211 -0
  76. package/dist/chunk-SM35JOYD.cjs.map +1 -0
  77. package/dist/chunk-SZQNIMYI.cjs +592 -0
  78. package/dist/chunk-SZQNIMYI.cjs.map +1 -0
  79. package/dist/chunk-T6T7QE4J.js +224 -0
  80. package/dist/chunk-T6T7QE4J.js.map +1 -0
  81. package/dist/chunk-TIF372DZ.js +65 -0
  82. package/dist/chunk-TIF372DZ.js.map +1 -0
  83. package/dist/chunk-V6JCOBGY.js +69 -0
  84. package/dist/chunk-V6JCOBGY.js.map +1 -0
  85. package/dist/chunk-VHUXNDW2.cjs +189 -0
  86. package/dist/chunk-VHUXNDW2.cjs.map +1 -0
  87. package/dist/chunk-W3LNNY3U.cjs +729 -0
  88. package/dist/chunk-W3LNNY3U.cjs.map +1 -0
  89. package/dist/chunk-ZUWSU4OA.js +61 -0
  90. package/dist/chunk-ZUWSU4OA.js.map +1 -0
  91. package/dist/chunk-ZWUA2LPB.cjs +103 -0
  92. package/dist/chunk-ZWUA2LPB.cjs.map +1 -0
  93. package/dist/cli/index.cjs +566 -0
  94. package/dist/cli/index.cjs.map +1 -0
  95. package/dist/cli/index.d.cts +1 -0
  96. package/dist/cli/index.d.ts +1 -0
  97. package/dist/cli/index.js +558 -0
  98. package/dist/cli/index.js.map +1 -0
  99. package/dist/compiler/index.cjs +80 -0
  100. package/dist/compiler/index.cjs.map +1 -0
  101. package/dist/compiler/index.d.cts +130 -0
  102. package/dist/compiler/index.d.ts +130 -0
  103. package/dist/compiler/index.js +3 -0
  104. package/dist/compiler/index.js.map +1 -0
  105. package/dist/component-BVzvepw9.d.cts +90 -0
  106. package/dist/component-wTxZ2BPD.d.ts +90 -0
  107. package/dist/index-CpxDa60m.d.cts +644 -0
  108. package/dist/index-CpxDa60m.d.ts +644 -0
  109. package/dist/index.cjs +1356 -0
  110. package/dist/index.cjs.map +1 -0
  111. package/dist/index.d.cts +165 -0
  112. package/dist/index.d.ts +165 -0
  113. package/dist/index.js +772 -0
  114. package/dist/index.js.map +1 -0
  115. package/dist/lib/dom.cjs +102 -0
  116. package/dist/lib/dom.cjs.map +1 -0
  117. package/dist/lib/dom.d.cts +373 -0
  118. package/dist/lib/dom.d.ts +373 -0
  119. package/dist/lib/dom.js +3 -0
  120. package/dist/lib/dom.js.map +1 -0
  121. package/dist/lib/icons.cjs +20 -0
  122. package/dist/lib/icons.cjs.map +1 -0
  123. package/dist/lib/icons.d.cts +64 -0
  124. package/dist/lib/icons.d.ts +64 -0
  125. package/dist/lib/icons.js +3 -0
  126. package/dist/lib/icons.js.map +1 -0
  127. package/dist/lib/index.cjs +247 -0
  128. package/dist/lib/index.cjs.map +1 -0
  129. package/dist/lib/index.d.cts +30 -0
  130. package/dist/lib/index.d.ts +30 -0
  131. package/dist/lib/index.js +92 -0
  132. package/dist/lib/index.js.map +1 -0
  133. package/dist/lib/theme.cjs +56 -0
  134. package/dist/lib/theme.cjs.map +1 -0
  135. package/dist/lib/theme.d.cts +27 -0
  136. package/dist/lib/theme.d.ts +27 -0
  137. package/dist/lib/theme.js +3 -0
  138. package/dist/lib/theme.js.map +1 -0
  139. package/dist/router-B9kms5XQ.d.ts +124 -0
  140. package/dist/router-YnpW_sIK.d.cts +124 -0
  141. package/dist/runtime/adapters/angular.cjs +48 -0
  142. package/dist/runtime/adapters/angular.cjs.map +1 -0
  143. package/dist/runtime/adapters/angular.d.cts +38 -0
  144. package/dist/runtime/adapters/angular.d.ts +38 -0
  145. package/dist/runtime/adapters/angular.js +46 -0
  146. package/dist/runtime/adapters/angular.js.map +1 -0
  147. package/dist/runtime/adapters/react.cjs +41 -0
  148. package/dist/runtime/adapters/react.cjs.map +1 -0
  149. package/dist/runtime/adapters/react.d.cts +26 -0
  150. package/dist/runtime/adapters/react.d.ts +26 -0
  151. package/dist/runtime/adapters/react.js +39 -0
  152. package/dist/runtime/adapters/react.js.map +1 -0
  153. package/dist/runtime/adapters/vue.cjs +44 -0
  154. package/dist/runtime/adapters/vue.cjs.map +1 -0
  155. package/dist/runtime/adapters/vue.d.cts +37 -0
  156. package/dist/runtime/adapters/vue.d.ts +37 -0
  157. package/dist/runtime/adapters/vue.js +42 -0
  158. package/dist/runtime/adapters/vue.js.map +1 -0
  159. package/dist/runtime/components/ai-assistant.cjs +18 -0
  160. package/dist/runtime/components/ai-assistant.cjs.map +1 -0
  161. package/dist/runtime/components/ai-assistant.d.cts +8 -0
  162. package/dist/runtime/components/ai-assistant.d.ts +8 -0
  163. package/dist/runtime/components/ai-assistant.js +9 -0
  164. package/dist/runtime/components/ai-assistant.js.map +1 -0
  165. package/dist/runtime/components/ai-summary-card.cjs +18 -0
  166. package/dist/runtime/components/ai-summary-card.cjs.map +1 -0
  167. package/dist/runtime/components/ai-summary-card.d.cts +19 -0
  168. package/dist/runtime/components/ai-summary-card.d.ts +19 -0
  169. package/dist/runtime/components/ai-summary-card.js +9 -0
  170. package/dist/runtime/components/ai-summary-card.js.map +1 -0
  171. package/dist/runtime/router.cjs +429 -0
  172. package/dist/runtime/router.cjs.map +1 -0
  173. package/dist/runtime/router.d.cts +2 -0
  174. package/dist/runtime/router.d.ts +2 -0
  175. package/dist/runtime/router.js +421 -0
  176. package/dist/runtime/router.js.map +1 -0
  177. package/dist/runtime/server.cjs +125 -0
  178. package/dist/runtime/server.cjs.map +1 -0
  179. package/dist/runtime/server.d.cts +27 -0
  180. package/dist/runtime/server.d.ts +27 -0
  181. package/dist/runtime/server.js +117 -0
  182. package/dist/runtime/server.js.map +1 -0
  183. package/dist/runtime/workflow/index.cjs +282 -0
  184. package/dist/runtime/workflow/index.cjs.map +1 -0
  185. package/dist/runtime/workflow/index.d.cts +1 -0
  186. package/dist/runtime/workflow/index.d.ts +1 -0
  187. package/dist/runtime/workflow/index.js +5 -0
  188. package/dist/runtime/workflow/index.js.map +1 -0
  189. package/dist/tracing-DGdvMCEl.d.cts +109 -0
  190. package/dist/tracing-DGdvMCEl.d.ts +109 -0
  191. package/dist/types-C4RXXKfk.d.cts +76 -0
  192. package/dist/types-C4RXXKfk.d.ts +76 -0
  193. package/package.json +166 -0
package/dist/index.js ADDED
@@ -0,0 +1,772 @@
1
+ export { ConsoleLogger, ConsoleWorkflowLogger, ConsoleWorkflowTraceSink, DATABASE_TASK, DELAY_TASK, DatabaseWorkflowStore, DefaultApprovalResolver, DefaultBackgroundRunner, FileWorkflowTraceSink, FunctionalDatabaseProvider, HTTP_TASK, InMemoryDatabaseRegistry, InMemorySchedulerService, InMemoryWorkflowStore, ManualOverrideApprovalResolver, MetricsConsoleEmitter, MongoWorkflowStore, NoopWorkflowTraceSink, PolicyApprovalResolver, QueueBackgroundRunner, RecordingWorkflowTraceSink, RuleBasedPolicyEngine, SCHEDULE_TASK, SystemTimeService, WorkflowBuilder, WorkflowRuntime, WorkflowStepBuilder, WorkflowTraceExporterSink, actorFromAuth0Claims, actorFromAzureAdClaims, actorFromCognitoClaims, actorFromOidcClaims, buildPolicyRequest, createAzureQueueDriver, createBullMqDriver, createDatabaseTaskHandler, createDefaultTaskMap, createDelayTaskHandler, createDrizzleProvider, createFetchHttpExecutor, createHttpTaskHandler, createMongoProvider, createMySqlProvider, createPostgresProvider, createPrismaProvider, createRestDatabaseProvider, createScheduleTaskHandler, createSqlDatabaseProvider, createSqliteProvider, createSqsDriver, createStartWorkflowMiddleware, createStepMiddleware, createSupabaseProvider, createWorkflow, databaseTask, delayTask, httpTask, multiStepApprovalResolver, registerDefaultDatabaseProviders, requireActorRoles, requireActorScopes, runAuthMiddleware, scheduleTask, task, visualSchemaToWorkflow, workflowFromJson, workflowToVisualSchema } from './chunk-3ZBRNFEE.js';
2
+ export { buildHydrationDomDiff, buildHydrationSummary, buildRouteTree, buildSignalsGraph, calculateRetryDelay, classifyError, createAiSession, createAngularAdapter, createDevtoolsDashboard, createFormController, createFormWizard, createHttpAiProvider, createHydrationReplayPanel, createHydrationReplaySession, createMockAiProvider, createReactAdapter, createResource, createResourceCache, createRouterInspector, createRouterInspectorPanel, createRuntimeDiagnosticsStore, createSignalsInspector, createSignalsInspectorPanel, createVueAdapter, getHydrationDomPayload, getHydrationReports, getResourceCache, invalidateResource, isResourceExpired, isResourceStale, normalizeResourceKey } from './chunk-4HRORR2Q.js';
3
+ export { AiAssistantPanel } from './chunk-T6T7QE4J.js';
4
+ export { AiSummaryCard } from './chunk-V6JCOBGY.js';
5
+ import { defineComponent, renderComponent } from './chunk-CHLDE4JQ.js';
6
+ export { Injector, createInjector, defineComponent, renderComponent, renderTemplateToStream, renderTemplateToString, useLocation, useNavigate, useRouteData, useRouteMatch, useRouteParams, useRouter, withRouterContext } from './chunk-CHLDE4JQ.js';
7
+ import './chunk-Q3KH6HMU.js';
8
+ export { buildRuntimeChromeTraceDocument } from './chunk-ZUWSU4OA.js';
9
+ import './chunk-IHAMVLRY.js';
10
+ import './chunk-BBAUALNU.js';
11
+ import { withRuntimeErrorBoundary, captureRuntimeError } from './chunk-DQBX75NJ.js';
12
+ export { captureRuntimeError, popRuntimeErrorBoundary, pushRuntimeErrorBoundary, withRuntimeErrorBoundary } from './chunk-DQBX75NJ.js';
13
+ import { flattenRoutes, matchRoute, getRouteId, normalizePathname, emitRuntimeErrorReport } from './chunk-SA5UD5B6.js';
14
+ export { addRuntimeErrorReporter, clearRuntimeErrorReporters, emitRuntimeErrorReport, getRuntimeErrorReporters, registerRuntimeErrorReporters } from './chunk-SA5UD5B6.js';
15
+ import { cacheRouteDataResult, clearRouteDataResult } from './chunk-D3H5CGVD.js';
16
+ import { signal } from './chunk-PFBEIFVS.js';
17
+ export { Effect, Signal, batch, clearSignalsInspectorRegistry, computed, effect, getSignalsInspectorSnapshot, signal } from './chunk-PFBEIFVS.js';
18
+ export { NoopRuntimeTraceSink, RuntimeTraceExporterSink, getCurrentRuntimeTraceSink, hasRuntimeTraceSink, nextRuntimeTraceId, recordRuntimeTrace, setRuntimeTraceSink, withRuntimeTraceSink } from './chunk-D2USIT6V.js';
19
+ export { JsonlTraceExporter, OtlpHttpTraceExporter } from './chunk-DRPG2DFX.js';
20
+ import http from 'http';
21
+ import { URL as URL$1 } from 'url';
22
+ import { promises } from 'fs';
23
+
24
+ // src/runtime/router.js
25
+ var CONTINUE_NAVIGATION = { type: "continue" };
26
+ var MAX_GUARD_REDIRECTS = 8;
27
+ function allowNavigation() {
28
+ return CONTINUE_NAVIGATION;
29
+ }
30
+ function redirectNavigation(to, options) {
31
+ return { type: "redirect", to, options };
32
+ }
33
+ function errorNavigation(error, info) {
34
+ return { type: "error", error, info: info ?? null };
35
+ }
36
+ function createRouter(input) {
37
+ const options = normalizeRouterOptions(input);
38
+ const flattened = flattenRoutes(options.routes);
39
+ const notFoundRoute = normalizeFallbackRoute(options.notFoundRoute, "not-found", "*");
40
+ const errorRoute = normalizeFallbackRoute(options.errorRoute, "error", "/__error");
41
+ const initialPath = typeof window !== "undefined" ? window.location.pathname : "/";
42
+ const currentPath = signal(initialPath);
43
+ const currentMatchSignal = signal(resolveMatch(initialPath));
44
+ function resolveMatch(path) {
45
+ for (const node of flattened) {
46
+ const params = matchRoute(path, node.fullPath);
47
+ if (params) {
48
+ return instantiateMatch(node, params);
49
+ }
50
+ }
51
+ if (notFoundRoute) {
52
+ return createFallbackMatch(notFoundRoute, path, "not-found");
53
+ }
54
+ return null;
55
+ }
56
+ function instantiateMatch(node, params) {
57
+ const layouts = collectLayouts(node.branch, node.fullPath, params);
58
+ const routeBoundary = createRouterBoundaryState("route", normalizeBoundaryConfig("route", node.route.boundary, {
59
+ routeId: getRouteId(node.route),
60
+ path: node.fullPath,
61
+ params
62
+ }));
63
+ return {
64
+ route: node.route,
65
+ params,
66
+ fullPath: node.fullPath,
67
+ layouts,
68
+ boundary: routeBoundary
69
+ };
70
+ }
71
+ function collectLayouts(branch, fullPath, params) {
72
+ const states = [];
73
+ branch.forEach((route) => {
74
+ (route.layouts ?? []).forEach((layout, index) => {
75
+ states.push(createRouterBoundaryState("layout", normalizeBoundaryConfig("layout", layout, {
76
+ routeId: getRouteId(route),
77
+ path: fullPath,
78
+ layoutIndex: index,
79
+ params
80
+ })));
81
+ });
82
+ });
83
+ return states;
84
+ }
85
+ function createFallbackMatch(route, requestedPath, reason, error, errorMessage) {
86
+ const normalizedPath = normalizePathname(requestedPath);
87
+ const params = matchRoute(normalizedPath, route.path) ?? {};
88
+ const statusCode = reason === "not-found" ? 404 : 500;
89
+ const boundaryConfig = {
90
+ ...route.boundary ?? {},
91
+ attributes: {
92
+ ...route.boundary?.attributes ?? {},
93
+ requestedPath: normalizedPath,
94
+ statusCode,
95
+ reason,
96
+ errorMessage: errorMessage ?? error?.message
97
+ }
98
+ };
99
+ const layouts = collectLayouts([route], normalizedPath, params);
100
+ const routeBoundary = createRouterBoundaryState("route", normalizeBoundaryConfig("route", boundaryConfig, {
101
+ routeId: getRouteId(route),
102
+ path: normalizedPath,
103
+ params
104
+ }));
105
+ return {
106
+ route,
107
+ params,
108
+ fullPath: normalizedPath,
109
+ layouts,
110
+ boundary: routeBoundary
111
+ };
112
+ }
113
+ function match(path) {
114
+ const resolved = resolveMatch(path ?? currentPath());
115
+ if (path === void 0) {
116
+ currentMatchSignal.set(resolved);
117
+ }
118
+ return resolved;
119
+ }
120
+ function navigate(path, options2) {
121
+ return runNavigation(path, options2, 0);
122
+ }
123
+ function onPopState() {
124
+ if (typeof window === "undefined") {
125
+ return;
126
+ }
127
+ const nextPath = window.location.pathname;
128
+ runNavigation(nextPath, { replace: true }, 0);
129
+ }
130
+ const start = () => {
131
+ if (typeof window === "undefined") {
132
+ return;
133
+ }
134
+ window.addEventListener("popstate", onPopState);
135
+ };
136
+ const dispose = () => {
137
+ if (typeof window === "undefined") {
138
+ return;
139
+ }
140
+ window.removeEventListener("popstate", onPopState);
141
+ };
142
+ function runNavigation(path, options2, depth) {
143
+ const resolved = resolveMatch(path);
144
+ if (!resolved) {
145
+ applyHistory(path, options2);
146
+ currentPath.set(path);
147
+ currentMatchSignal.set(null);
148
+ return null;
149
+ }
150
+ const guardResult = runRouteGuards(resolved);
151
+ if (guardResult.type === "redirect") {
152
+ if (depth >= MAX_GUARD_REDIRECTS) {
153
+ throw new Error("Router redirect loop detected.");
154
+ }
155
+ const nextOptions = { ...options2, ...guardResult.options, replace: true };
156
+ return runNavigation(guardResult.to, nextOptions, depth + 1);
157
+ }
158
+ if (guardResult.type === "error") {
159
+ const info = guardResult.info ?? createGuardErrorInfo(resolved);
160
+ const rawMessage = guardResult.error.message;
161
+ if (errorRoute) {
162
+ try {
163
+ captureRuntimeError(guardResult.error, info);
164
+ } catch {
165
+ }
166
+ const errorMatch = createFallbackMatch(errorRoute, path, "error", guardResult.error, rawMessage);
167
+ applyHistory(path, options2);
168
+ currentPath.set(path);
169
+ currentMatchSignal.set(errorMatch);
170
+ return errorMatch;
171
+ }
172
+ captureRuntimeError(guardResult.error, info);
173
+ return currentMatchSignal();
174
+ }
175
+ applyHistory(path, options2);
176
+ currentPath.set(path);
177
+ currentMatchSignal.set(resolved);
178
+ return resolved;
179
+ }
180
+ function applyHistory(path, options2) {
181
+ if (typeof window === "undefined") {
182
+ return;
183
+ }
184
+ const historyState = options2?.state ?? {};
185
+ if (options2?.replace) {
186
+ window.history.replaceState(historyState, "", path);
187
+ } else {
188
+ window.history.pushState(historyState, "", path);
189
+ }
190
+ }
191
+ function runRouteGuards(match2) {
192
+ const guards = match2.route.guards ?? [];
193
+ for (const guard of guards) {
194
+ const result = guard({ match: match2, params: match2.params }) ?? CONTINUE_NAVIGATION;
195
+ if (result.type !== "continue") {
196
+ return result;
197
+ }
198
+ }
199
+ return CONTINUE_NAVIGATION;
200
+ }
201
+ function createGuardErrorInfo(match2) {
202
+ return {
203
+ phase: "navigation",
204
+ componentName: match2.boundary.definition.componentName,
205
+ componentInstanceId: match2.boundary.id,
206
+ templateId: match2.boundary.definition.templateId,
207
+ attributes: {
208
+ routeId: match2.route.id ?? match2.fullPath,
209
+ fullPath: match2.fullPath
210
+ }
211
+ };
212
+ }
213
+ return {
214
+ currentPath,
215
+ currentMatch: currentMatchSignal,
216
+ navigate,
217
+ match,
218
+ start,
219
+ dispose
220
+ };
221
+ }
222
+ function normalizeRouterOptions(input) {
223
+ if (Array.isArray(input)) {
224
+ return { routes: input };
225
+ }
226
+ return input;
227
+ }
228
+ function normalizeFallbackRoute(route, fallbackId, fallbackPath) {
229
+ if (!route) {
230
+ return void 0;
231
+ }
232
+ return {
233
+ ...route,
234
+ id: route.id ?? fallbackId,
235
+ path: route.path ?? fallbackPath
236
+ };
237
+ }
238
+ async function runRouteLoader(match, args) {
239
+ const result = await executeRouteHandler("loader", match.route.loader, match, args);
240
+ updateRouteDataCache(match, result);
241
+ return result;
242
+ }
243
+ async function runRouteAction(match, args) {
244
+ const result = await executeRouteHandler("action", match.route.action, match, args);
245
+ updateRouteDataCache(match, result);
246
+ return result;
247
+ }
248
+ async function prefetchRoute(match, options) {
249
+ await Promise.resolve(match.route.component());
250
+ if (options?.loadData) {
251
+ await runRouteLoader(match, options.loaderArgs);
252
+ }
253
+ }
254
+ function normalizeBoundaryConfig(kind, config, context) {
255
+ const layoutSuffix = typeof context.layoutIndex === "number" ? `:${String(context.layoutIndex)}` : "";
256
+ const fallbackId = `${kind}:${context.routeId}${layoutSuffix}`;
257
+ const componentName = config?.componentName ?? config?.name ?? context.routeId;
258
+ const attributes = {
259
+ ...config?.attributes ?? {},
260
+ routeId: context.routeId,
261
+ path: context.path,
262
+ layoutIndex: context.layoutIndex,
263
+ params: context.params ? { ...context.params } : void 0
264
+ };
265
+ return {
266
+ ...config,
267
+ id: config?.id ?? fallbackId,
268
+ name: config?.name ?? componentName,
269
+ componentName,
270
+ attributes
271
+ };
272
+ }
273
+ function createRouterBoundaryState(kind, definition) {
274
+ const state = {
275
+ id: definition.id,
276
+ kind,
277
+ definition,
278
+ boundary: {
279
+ id: definition.id,
280
+ handle(error, info) {
281
+ state.error = error;
282
+ state.info = info;
283
+ if (definition.onError) {
284
+ try {
285
+ const handled = definition.onError(error, info);
286
+ if (handled === false) {
287
+ return false;
288
+ }
289
+ } catch (hookError) {
290
+ state.error = hookError instanceof Error ? hookError : new Error(String(hookError));
291
+ state.info = info;
292
+ }
293
+ }
294
+ return true;
295
+ }
296
+ },
297
+ error: null,
298
+ info: null,
299
+ reset() {
300
+ state.error = null;
301
+ state.info = null;
302
+ }
303
+ };
304
+ return state;
305
+ }
306
+ async function executeRouteHandler(kind, handler, match, args) {
307
+ const startedAt = Date.now();
308
+ if (!handler) {
309
+ return {
310
+ handled: true,
311
+ startedAt,
312
+ endedAt: startedAt,
313
+ durationMs: 0
314
+ };
315
+ }
316
+ const normalizedArgs = normalizeHandlerArgs(match, args);
317
+ const boundaries = [...match.layouts, match.boundary];
318
+ boundaries.forEach((boundary) => {
319
+ boundary.reset();
320
+ });
321
+ try {
322
+ const data = await runWithBoundaries(boundaries, () => invokeRouteHandler(handler, kind, match, normalizedArgs));
323
+ const boundaryError = firstErroredBoundary(boundaries);
324
+ const endedAt = Date.now();
325
+ if (boundaryError) {
326
+ return {
327
+ handled: true,
328
+ error: boundaryError.error ?? void 0,
329
+ info: boundaryError.info ?? null,
330
+ startedAt,
331
+ endedAt,
332
+ durationMs: endedAt - startedAt
333
+ };
334
+ }
335
+ return {
336
+ handled: true,
337
+ data,
338
+ info: null,
339
+ startedAt,
340
+ endedAt,
341
+ durationMs: endedAt - startedAt
342
+ };
343
+ } catch (error) {
344
+ const normalized = error instanceof Error ? error : new Error(String(error));
345
+ const endedAt = Date.now();
346
+ return {
347
+ handled: false,
348
+ error: normalized,
349
+ info: null,
350
+ startedAt,
351
+ endedAt,
352
+ durationMs: endedAt - startedAt
353
+ };
354
+ }
355
+ }
356
+ function normalizeHandlerArgs(match, args) {
357
+ return {
358
+ params: args?.params ?? match.params,
359
+ request: args?.request,
360
+ signal: args?.signal,
361
+ context: args?.context
362
+ };
363
+ }
364
+ function runWithBoundaries(boundaries, run) {
365
+ return boundaries.reduceRight((next, boundary) => {
366
+ return () => withRuntimeErrorBoundary(boundary.boundary, next);
367
+ }, run)();
368
+ }
369
+ function invokeRouteHandler(handler, kind, match, args) {
370
+ const phase = kind === "loader" ? "loader" : "action";
371
+ const info = createHandlerErrorInfo(phase, match, args);
372
+ try {
373
+ const result = handler(args);
374
+ if (isPromiseLike(result)) {
375
+ return result.catch((error) => {
376
+ const handled = captureRuntimeError(error, info);
377
+ if (!handled) {
378
+ throw error;
379
+ }
380
+ return void 0;
381
+ });
382
+ }
383
+ return result;
384
+ } catch (error) {
385
+ const handled = captureRuntimeError(error, info);
386
+ if (!handled) {
387
+ throw error;
388
+ }
389
+ return void 0;
390
+ }
391
+ }
392
+ function createHandlerErrorInfo(phase, match, args) {
393
+ const attributes = {
394
+ ...match.boundary.definition.attributes,
395
+ params: args.params,
396
+ requestMethod: args.request?.method,
397
+ layoutStack: match.layouts.map((layout) => layout.definition.id)
398
+ };
399
+ return {
400
+ phase,
401
+ componentName: match.boundary.definition.componentName,
402
+ componentInstanceId: match.boundary.id,
403
+ templateId: match.boundary.definition.templateId,
404
+ attributes
405
+ };
406
+ }
407
+ function firstErroredBoundary(boundaries) {
408
+ for (let i = boundaries.length - 1; i >= 0; i -= 1) {
409
+ if (boundaries[i].error) {
410
+ return boundaries[i];
411
+ }
412
+ }
413
+ return void 0;
414
+ }
415
+ function isPromiseLike(value) {
416
+ return Boolean(value) && typeof value === "object" && "then" in value;
417
+ }
418
+ function updateRouteDataCache(match, result) {
419
+ if (result.handled) {
420
+ cacheRouteDataResult(match, result);
421
+ return;
422
+ }
423
+ clearRouteDataResult(match);
424
+ }
425
+
426
+ // src/runtime/router-provider.js
427
+ function renderRouterApp(component, options) {
428
+ return renderComponent(component, options);
429
+ }
430
+ function createHttpApp() {
431
+ const middlewares = [];
432
+ const runMiddlewares = async (ctx, index = 0) => {
433
+ if (index >= middlewares.length) {
434
+ return;
435
+ }
436
+ const next = () => {
437
+ return runMiddlewares(ctx, index + 1);
438
+ };
439
+ await middlewares[index](ctx, next);
440
+ };
441
+ return {
442
+ use(middleware) {
443
+ middlewares.push(middleware);
444
+ return this;
445
+ },
446
+ handle(req, res) {
447
+ const host = req.headers.host ?? "localhost";
448
+ const url = new URL$1(req.url ?? "/", `http://${host}`);
449
+ const ctx = { req, res, url, state: {} };
450
+ runMiddlewares(ctx).catch((err) => {
451
+ res.statusCode = 500;
452
+ res.end(err instanceof Error ? err.message : "Unknown error");
453
+ });
454
+ },
455
+ listen(port) {
456
+ const server = http.createServer((req, res) => this.handle(req, res));
457
+ return new Promise((resolve) => {
458
+ server.listen(port, () => resolve(server));
459
+ });
460
+ }
461
+ };
462
+ }
463
+ function json(handler) {
464
+ return async (ctx, next) => {
465
+ if (ctx.req.method === "GET") {
466
+ ctx.data = await handler(ctx);
467
+ ctx.res.setHeader("Content-Type", "application/json");
468
+ ctx.res.end(JSON.stringify(ctx.data));
469
+ return;
470
+ }
471
+ await next();
472
+ };
473
+ }
474
+ function serveStatic(root) {
475
+ return async (ctx, next) => {
476
+ if (ctx.req.method !== "GET") {
477
+ await next();
478
+ return;
479
+ }
480
+ const host = ctx.req.headers.host ?? "localhost";
481
+ const path = new URL$1(ctx.req.url ?? "/", `http://${host}`).pathname;
482
+ const filePath = new URL$1(path === "/" ? "/index.html" : path, `file://${root}`);
483
+ try {
484
+ const data = await promises.readFile(filePath);
485
+ ctx.res.end(data);
486
+ } catch (error) {
487
+ if (error.code === "ENOENT") {
488
+ await next();
489
+ return;
490
+ }
491
+ throw error;
492
+ }
493
+ };
494
+ }
495
+
496
+ // src/runtime/ssr-app.js
497
+ var DEFAULT_TEMPLATE = "<!doctype html><html><head><!--ce-ui-head--><!--ce-ui-assets--></head><body><!--ce-ui-app--></body></html>";
498
+ function renderAssetTags(manifest) {
499
+ if (!manifest) {
500
+ return "";
501
+ }
502
+ const styles = (manifest.styles ?? []).map((href) => `<link rel="stylesheet" href="${href}">`).join("");
503
+ const preloads = (manifest.preloads ?? []).map((href) => `<link rel="preload" href="${href}" as="script">`).join("");
504
+ const scripts = (manifest.scripts ?? []).map((src) => `<script type="module" src="${src}"></script>`).join("");
505
+ const hydrate = (manifest.hydrate ?? []).map((src) => `<script type="module" data-ce-hydrate src="${src}"></script>`).join("");
506
+ return `${preloads}${styles}${scripts}${hydrate}`;
507
+ }
508
+ function renderHtmlDocument(options) {
509
+ const template = options.template ?? DEFAULT_TEMPLATE;
510
+ const head = options.head ?? "";
511
+ const assets = renderAssetTags(options.manifest);
512
+ const htmlAttrs = options.htmlAttributes ? ` ${options.htmlAttributes}` : "";
513
+ const bodyAttrs = options.bodyAttributes ? ` ${options.bodyAttributes}` : "";
514
+ return applyTemplate(template, {
515
+ head,
516
+ assets,
517
+ body: options.body,
518
+ htmlAttributes: htmlAttrs,
519
+ bodyAttributes: bodyAttrs
520
+ });
521
+ }
522
+ function isAsyncIterable(value) {
523
+ return Boolean(value) && typeof value === "object" && Symbol.asyncIterator in value;
524
+ }
525
+ function createNodeSsrMiddleware(options) {
526
+ return async (ctx, next) => {
527
+ if (ctx.req.method !== "GET") {
528
+ await next();
529
+ return;
530
+ }
531
+ const bodyResult = await options.render(ctx);
532
+ ctx.res.statusCode = options.status ?? 200;
533
+ ctx.res.setHeader("Content-Type", "text/html; charset=utf-8");
534
+ if (options.headers) {
535
+ Object.entries(options.headers).forEach(([key, value]) => ctx.res.setHeader(key, value));
536
+ }
537
+ if (isAsyncIterable(bodyResult)) {
538
+ const shell = renderHtmlShell({
539
+ template: options.template,
540
+ head: options.head,
541
+ manifest: options.manifest
542
+ });
543
+ ctx.res.write(shell.start);
544
+ for await (const chunk of bodyResult) {
545
+ ctx.res.write(chunk);
546
+ }
547
+ ctx.res.end(shell.end);
548
+ return;
549
+ }
550
+ const html = renderHtmlDocument({
551
+ template: options.template,
552
+ head: options.head,
553
+ body: bodyResult,
554
+ manifest: options.manifest
555
+ });
556
+ ctx.res.end(html);
557
+ };
558
+ }
559
+ function createEdgeSsrHandler(options) {
560
+ return async (request) => {
561
+ const url = new URL(request.url);
562
+ const bodyResult = await options.render({ request, url });
563
+ const headers = new Headers(options.headers);
564
+ if (!headers.has("Content-Type")) {
565
+ headers.set("Content-Type", "text/html; charset=utf-8");
566
+ }
567
+ if (isAsyncIterable(bodyResult)) {
568
+ const shell = renderHtmlShell({
569
+ template: options.template,
570
+ head: options.head,
571
+ manifest: options.manifest
572
+ });
573
+ const encoder = new TextEncoder();
574
+ const stream = new ReadableStream({
575
+ async start(controller) {
576
+ controller.enqueue(encoder.encode(shell.start));
577
+ for await (const chunk of bodyResult) {
578
+ controller.enqueue(encoder.encode(chunk));
579
+ }
580
+ controller.enqueue(encoder.encode(shell.end));
581
+ controller.close();
582
+ }
583
+ });
584
+ return new Response(stream, { status: options.status ?? 200, headers });
585
+ }
586
+ const html = renderHtmlDocument({
587
+ template: options.template,
588
+ head: options.head,
589
+ body: bodyResult,
590
+ manifest: options.manifest
591
+ });
592
+ return new Response(html, { status: options.status ?? 200, headers });
593
+ };
594
+ }
595
+ function renderHtmlShell(options) {
596
+ const template = options.template ?? DEFAULT_TEMPLATE;
597
+ const head = options.head ?? "";
598
+ const assets = renderAssetTags(options.manifest);
599
+ const resolved = applyTemplate(template, {
600
+ head,
601
+ assets,
602
+ body: "<!--ce-ui-app-->",
603
+ htmlAttributes: "",
604
+ bodyAttributes: ""
605
+ });
606
+ const marker = "<!--ce-ui-app-->";
607
+ const index = resolved.indexOf(marker);
608
+ if (index === -1) {
609
+ return { start: resolved, end: "" };
610
+ }
611
+ return {
612
+ start: resolved.slice(0, index),
613
+ end: resolved.slice(index + marker.length)
614
+ };
615
+ }
616
+ function applyTemplate(template, payload) {
617
+ if (template.includes("<html") || template.includes("<body")) {
618
+ return template.replace("<html", `<html${payload.htmlAttributes}`).replace("<body", `<body${payload.bodyAttributes}`).replace("<!--ce-ui-head-->", payload.head).replace("<!--ce-ui-assets-->", payload.assets).replace("<!--ce-ui-app-->", payload.body);
619
+ }
620
+ return template.replace("<!--ce-ui-head-->", payload.head).replace("<!--ce-ui-assets-->", payload.assets).replace("<!--ce-ui-app-->", payload.body);
621
+ }
622
+ function useErrorBoundary(handler) {
623
+ {
624
+ throw new Error("useErrorBoundary() can only be used while executing a component setup function.");
625
+ }
626
+ }
627
+
628
+ // src/runtime/error-boundary.ts
629
+ var ErrorBoundary = defineComponent({
630
+ name: "ErrorBoundary",
631
+ template: `
632
+ <div ce:if="!hasError()" class="ce-error-boundary__content">
633
+ <slot></slot>
634
+ </div>
635
+ <div ce:if="hasError()" class="ce-error-boundary__fallback">
636
+ <slot name="fallback">
637
+ <section class="ce-error-boundary__panel">
638
+ <p class="ce-error-boundary__title">Something went wrong.</p>
639
+ <pre>{{ errorMessage() }}</pre>
640
+ <button type="button" on:click="reset" class="ce-error-boundary__reset">Try again</button>
641
+ </section>
642
+ </slot>
643
+ </div>
644
+ `,
645
+ styles: [
646
+ `.ce-error-boundary__fallback {
647
+ display: block;
648
+ }
649
+ .ce-error-boundary__panel {
650
+ border: 1px dashed var(--ce-border, #f87171);
651
+ padding: 1rem;
652
+ border-radius: 0.75rem;
653
+ background: rgba(248, 113, 113, 0.08);
654
+ color: inherit;
655
+ }
656
+ .ce-error-boundary__title {
657
+ font-weight: 600;
658
+ margin: 0 0 0.5rem;
659
+ }
660
+ .ce-error-boundary__panel pre {
661
+ margin: 0 0 0.75rem;
662
+ padding: 0.5rem;
663
+ background: rgba(15, 23, 42, 0.65);
664
+ border-radius: 0.5rem;
665
+ font-size: 0.85rem;
666
+ line-height: 1.4;
667
+ white-space: pre-wrap;
668
+ }
669
+ .ce-error-boundary__reset {
670
+ display: inline-flex;
671
+ align-items: center;
672
+ padding: 0.35rem 0.75rem;
673
+ border-radius: 0.5rem;
674
+ border: 0;
675
+ cursor: pointer;
676
+ background: var(--ce-primary, #2563eb);
677
+ color: var(--ce-on-primary, #f8fafc);
678
+ }`
679
+ ],
680
+ setup({ props, emit }) {
681
+ const boundary = useErrorBoundary();
682
+ const hasError = () => Boolean(boundary.error());
683
+ const errorMessage = () => boundary.error()?.message ?? "Unknown error";
684
+ const reset = () => {
685
+ boundary.reset();
686
+ };
687
+ return {
688
+ hasError,
689
+ error: boundary.error,
690
+ info: boundary.info,
691
+ errorMessage,
692
+ reset
693
+ };
694
+ }
695
+ });
696
+
697
+ // src/runtime/hydration-diagnostics.js
698
+ var inspectedTargets = /* @__PURE__ */ new WeakSet();
699
+ function ensureHydrationConsistency(target, context) {
700
+ if (typeof document === "undefined") {
701
+ return;
702
+ }
703
+ if (inspectedTargets.has(target)) {
704
+ return;
705
+ }
706
+ inspectedTargets.add(target);
707
+ if (!hasServerDom(target)) {
708
+ return;
709
+ }
710
+ const serverDom = snapshotDom(target);
711
+ reportHydrationMismatch({
712
+ templateId: context.templateId,
713
+ componentName: context.componentName,
714
+ componentInstanceId: context.componentInstanceId,
715
+ reason: "Detected existing server-rendered DOM before client render. Hydration support is not enabled yet.",
716
+ receivedDom: serverDom,
717
+ attributes: {
718
+ serverDomLength: serverDom.length
719
+ }
720
+ });
721
+ clearNode(target);
722
+ }
723
+ function reportHydrationMismatch(details) {
724
+ const error = new Error(`[hydration] ${details.reason}`);
725
+ const info = {
726
+ phase: "hydration",
727
+ componentName: details.componentName,
728
+ componentInstanceId: details.componentInstanceId,
729
+ templateId: details.templateId,
730
+ attributes: {
731
+ ...details.attributes ?? {},
732
+ expectedDom: details.expectedDom,
733
+ receivedDom: details.receivedDom,
734
+ timestamp: Date.now()
735
+ }
736
+ };
737
+ emitRuntimeErrorReport({
738
+ error,
739
+ info,
740
+ handled: true
741
+ });
742
+ if (typeof console !== "undefined") {
743
+ console.warn("[ce-ui] hydration mismatch detected", {
744
+ reason: details.reason,
745
+ templateId: details.templateId,
746
+ componentName: details.componentName
747
+ });
748
+ }
749
+ }
750
+ function snapshotDom(node) {
751
+ if (node instanceof Element) {
752
+ return node.innerHTML;
753
+ }
754
+ if (node instanceof DocumentFragment) {
755
+ const div = document.createElement("div");
756
+ div.appendChild(node.cloneNode(true));
757
+ return div.innerHTML;
758
+ }
759
+ return node.textContent ?? "";
760
+ }
761
+ function hasServerDom(target) {
762
+ return "childNodes" in target && target.childNodes.length > 0;
763
+ }
764
+ function clearNode(target) {
765
+ while (target.firstChild) {
766
+ target.removeChild(target.firstChild);
767
+ }
768
+ }
769
+
770
+ export { ErrorBoundary, allowNavigation, createEdgeSsrHandler, createHttpApp, createNodeSsrMiddleware, createRouter, ensureHydrationConsistency, errorNavigation, json, prefetchRoute, redirectNavigation, renderAssetTags, renderHtmlDocument, renderRouterApp, reportHydrationMismatch, runRouteAction, runRouteLoader, serveStatic, snapshotDom };
771
+ //# sourceMappingURL=index.js.map
772
+ //# sourceMappingURL=index.js.map