@sigx/runtime-core 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1230 @@
1
+ import { detectAccess, effect, isComputed, signal, untrack } from "@sigx/reactivity";
2
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
3
+ var plugins = [];
4
+ function registerComponentPlugin(plugin) {
5
+ plugins.push(plugin);
6
+ }
7
+ function getComponentPlugins() {
8
+ return plugins;
9
+ }
10
+ var contextExtensions = [];
11
+ function registerContextExtension(extension) {
12
+ contextExtensions.push(extension);
13
+ }
14
+ function applyContextExtensions(ctx) {
15
+ for (const extension of contextExtensions) extension(ctx);
16
+ }
17
+ var require___vite_browser_external = /* @__PURE__ */ __commonJSMin(((exports, module) => {
18
+ module.exports = {};
19
+ }));
20
+ var asyncLocalStorage = null;
21
+ try {
22
+ if (typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined") {
23
+ const nodeAsync = globalThis.process?.versions?.node ? require___vite_browser_external() : null;
24
+ if (nodeAsync?.AsyncLocalStorage) asyncLocalStorage = new nodeAsync.AsyncLocalStorage();
25
+ }
26
+ } catch {}
27
+ var _fallbackContext = {
28
+ currentComponentContext: null,
29
+ currentSuspenseBoundary: null
30
+ };
31
+ function getRequestContext() {
32
+ if (asyncLocalStorage) {
33
+ const store = asyncLocalStorage.getStore();
34
+ if (store) return store;
35
+ }
36
+ return _fallbackContext;
37
+ }
38
+ function getCurrentInstanceSafe() {
39
+ return getRequestContext().currentComponentContext;
40
+ }
41
+ function setCurrentInstanceSafe(ctx) {
42
+ const reqCtx = getRequestContext();
43
+ const prev = reqCtx.currentComponentContext;
44
+ reqCtx.currentComponentContext = ctx;
45
+ return prev;
46
+ }
47
+ function getCurrentSuspenseBoundarySafe() {
48
+ return getRequestContext().currentSuspenseBoundary;
49
+ }
50
+ function setCurrentSuspenseBoundarySafe(boundary) {
51
+ const reqCtx = getRequestContext();
52
+ const prev = reqCtx.currentSuspenseBoundary;
53
+ reqCtx.currentSuspenseBoundary = boundary;
54
+ return prev;
55
+ }
56
+ function runInRequestScope(fn) {
57
+ if (asyncLocalStorage) return asyncLocalStorage.run({
58
+ currentComponentContext: null,
59
+ currentSuspenseBoundary: null
60
+ }, fn);
61
+ return fn();
62
+ }
63
+ function hasRequestIsolation() {
64
+ return asyncLocalStorage !== null;
65
+ }
66
+ var currentComponentContext = null;
67
+ function getCurrentInstance() {
68
+ return getCurrentInstanceSafe() ?? currentComponentContext;
69
+ }
70
+ function setCurrentInstance(ctx) {
71
+ const prevSafe = setCurrentInstanceSafe(ctx);
72
+ const prevModule = currentComponentContext;
73
+ currentComponentContext = ctx;
74
+ return prevSafe ?? prevModule;
75
+ }
76
+ function onMounted(fn) {
77
+ if (currentComponentContext) currentComponentContext.onMounted(fn);
78
+ else console.warn("onMounted called outside of component setup");
79
+ }
80
+ function onUnmounted(fn) {
81
+ if (currentComponentContext) currentComponentContext.onUnmounted(fn);
82
+ else console.warn("onUnmounted called outside of component setup");
83
+ }
84
+ function onCreated(fn) {
85
+ if (currentComponentContext) currentComponentContext.onCreated(fn);
86
+ else console.warn("onCreated called outside of component setup");
87
+ }
88
+ function onUpdated(fn) {
89
+ if (currentComponentContext) currentComponentContext.onUpdated(fn);
90
+ else console.warn("onUpdated called outside of component setup");
91
+ }
92
+ var componentRegistry = /* @__PURE__ */ new Map();
93
+ function getComponentMeta(factory) {
94
+ return componentRegistry.get(factory);
95
+ }
96
+ function component(setup, options) {
97
+ const factory = function(props) {
98
+ return {
99
+ type: factory,
100
+ props: props || {},
101
+ key: props?.key || null,
102
+ children: [],
103
+ dom: null
104
+ };
105
+ };
106
+ factory.__setup = setup;
107
+ factory.__name = options?.name;
108
+ factory.__props = null;
109
+ factory.__events = null;
110
+ factory.__ref = null;
111
+ factory.__slots = null;
112
+ componentRegistry.set(factory, {
113
+ name: options?.name,
114
+ setup
115
+ });
116
+ getComponentPlugins().forEach((p) => p.onDefine?.(options?.name, factory, setup));
117
+ return factory;
118
+ }
119
+ var globalInstances = /* @__PURE__ */ new Map();
120
+ var appContextToken = Symbol("sigx:appContext");
121
+ function lookupProvided(token) {
122
+ const ctx = getCurrentInstance();
123
+ if (!ctx) return;
124
+ let current = ctx;
125
+ while (current) {
126
+ if (current.provides && current.provides.has(token)) return current.provides.get(token);
127
+ current = current.parent;
128
+ }
129
+ }
130
+ function provideAtComponent(token, value) {
131
+ const ctx = getCurrentInstance();
132
+ if (!ctx) throw new Error("defineProvide must be called inside a component setup function");
133
+ if (!ctx.provides) ctx.provides = /* @__PURE__ */ new Map();
134
+ ctx.provides.set(token, value);
135
+ }
136
+ function defineInjectable(factory) {
137
+ const token = Symbol();
138
+ const useFn = (() => {
139
+ const provided = lookupProvided(token);
140
+ if (provided !== void 0) return provided;
141
+ if (!globalInstances.has(token)) globalInstances.set(token, factory());
142
+ return globalInstances.get(token);
143
+ });
144
+ useFn._factory = factory;
145
+ useFn._token = token;
146
+ return useFn;
147
+ }
148
+ function defineProvide(useFn, factory) {
149
+ const actualFactory = factory ?? useFn._factory;
150
+ const token = useFn._token;
151
+ if (!actualFactory || !token) throw new Error("defineProvide must be called with a function created by defineInjectable");
152
+ const instance = actualFactory();
153
+ provideAtComponent(token, instance);
154
+ return instance;
155
+ }
156
+ function useAppContext() {
157
+ return lookupProvided(appContextToken) ?? null;
158
+ }
159
+ function getAppContextToken() {
160
+ return appContextToken;
161
+ }
162
+ function provideAppContext(ctx, appContext) {
163
+ if (!ctx.provides) ctx.provides = /* @__PURE__ */ new Map();
164
+ ctx.provides.set(appContextToken, appContext);
165
+ if (appContext.provides) for (const [token, value] of appContext.provides) ctx.provides.set(token, value);
166
+ }
167
+ const __DIRECTIVE__ = Symbol.for("sigx.directive");
168
+ function defineDirective(definition) {
169
+ definition[__DIRECTIVE__] = true;
170
+ return definition;
171
+ }
172
+ function isDirective(value) {
173
+ return value != null && typeof value === "object" && value[__DIRECTIVE__] === true;
174
+ }
175
+ var isDev = typeof process !== "undefined" && process.env.NODE_ENV !== "production" || true;
176
+ var defaultMountFn = null;
177
+ function setDefaultMount(mountFn) {
178
+ defaultMountFn = mountFn;
179
+ }
180
+ function getDefaultMount() {
181
+ return defaultMountFn;
182
+ }
183
+ function defineApp(rootComponent) {
184
+ const installedPlugins = /* @__PURE__ */ new Set();
185
+ const context = {
186
+ app: null,
187
+ provides: /* @__PURE__ */ new Map(),
188
+ config: {},
189
+ hooks: [],
190
+ directives: /* @__PURE__ */ new Map()
191
+ };
192
+ let isMounted = false;
193
+ let container = null;
194
+ let unmountFn = null;
195
+ const app = {
196
+ config: context.config,
197
+ use(plugin, options) {
198
+ if (installedPlugins.has(plugin)) {
199
+ if (isDev) console.warn(`Plugin ${plugin.name || "anonymous"} is already installed.`);
200
+ return app;
201
+ }
202
+ installedPlugins.add(plugin);
203
+ if (typeof plugin === "function") plugin(app, options);
204
+ else if (plugin && typeof plugin.install === "function") plugin.install(app, options);
205
+ else if (isDev) console.warn("Invalid plugin: must be a function or have an install() method.");
206
+ return app;
207
+ },
208
+ defineProvide(useFn, factory) {
209
+ const actualFactory = factory ?? useFn._factory;
210
+ const token = useFn._token;
211
+ if (!actualFactory || !token) throw new Error("defineProvide must be called with a function created by defineInjectable");
212
+ const instance = actualFactory();
213
+ context.provides.set(token, instance);
214
+ return instance;
215
+ },
216
+ hook(hooks) {
217
+ context.hooks.push(hooks);
218
+ return app;
219
+ },
220
+ directive(name, definition) {
221
+ if (definition !== void 0) {
222
+ if (isDev && !isDirective(definition)) console.warn(`[sigx] app.directive('${name}', ...) received a value that is not a valid directive definition. Use defineDirective() to create directive definitions.`);
223
+ context.directives.set(name, definition);
224
+ return app;
225
+ }
226
+ return context.directives.get(name);
227
+ },
228
+ mount(target, renderFn) {
229
+ if (isMounted) {
230
+ if (isDev) console.warn("App is already mounted. Call app.unmount() first.");
231
+ return app;
232
+ }
233
+ const mountFn = renderFn ?? defaultMountFn;
234
+ if (!mountFn) throw new Error("No mount function provided and no default mount function set. Either pass a mount function to app.mount(), or import a platform package (e.g., @sigx/runtime-dom or @sigx/runtime-terminal) that sets the default.");
235
+ container = target;
236
+ isMounted = true;
237
+ const result = mountFn(rootComponent, target, context);
238
+ if (typeof result === "function") unmountFn = result;
239
+ return app;
240
+ },
241
+ unmount() {
242
+ if (!isMounted) {
243
+ if (isDev) console.warn("App is not mounted.");
244
+ return;
245
+ }
246
+ if (unmountFn) unmountFn();
247
+ context.provides.clear();
248
+ isMounted = false;
249
+ container = null;
250
+ },
251
+ get _context() {
252
+ return context;
253
+ },
254
+ get _isMounted() {
255
+ return isMounted;
256
+ },
257
+ get _container() {
258
+ return container;
259
+ },
260
+ get _rootComponent() {
261
+ return rootComponent;
262
+ }
263
+ };
264
+ context.app = app;
265
+ const appContextToken = getAppContextToken();
266
+ context.provides.set(appContextToken, context);
267
+ return app;
268
+ }
269
+ function notifyComponentCreated(context, instance) {
270
+ if (!context) return;
271
+ for (const hooks of context.hooks) try {
272
+ hooks.onComponentCreated?.(instance);
273
+ } catch (err) {
274
+ handleHookError(context, err, instance, "onComponentCreated");
275
+ }
276
+ }
277
+ function notifyComponentMounted(context, instance) {
278
+ if (!context) return;
279
+ for (const hooks of context.hooks) try {
280
+ hooks.onComponentMounted?.(instance);
281
+ } catch (err) {
282
+ handleHookError(context, err, instance, "onComponentMounted");
283
+ }
284
+ }
285
+ function notifyComponentUnmounted(context, instance) {
286
+ if (!context) return;
287
+ for (const hooks of context.hooks) try {
288
+ hooks.onComponentUnmounted?.(instance);
289
+ } catch (err) {
290
+ handleHookError(context, err, instance, "onComponentUnmounted");
291
+ }
292
+ }
293
+ function notifyComponentUpdated(context, instance) {
294
+ if (!context) return;
295
+ for (const hooks of context.hooks) try {
296
+ hooks.onComponentUpdated?.(instance);
297
+ } catch (err) {
298
+ handleHookError(context, err, instance, "onComponentUpdated");
299
+ }
300
+ }
301
+ function handleComponentError(context, err, instance, info) {
302
+ if (!context) return false;
303
+ for (const hooks of context.hooks) try {
304
+ if (hooks.onComponentError?.(err, instance, info) === true) return true;
305
+ } catch (hookErr) {
306
+ console.error("Error in onComponentError hook:", hookErr);
307
+ }
308
+ if (context.config.errorHandler) try {
309
+ if (context.config.errorHandler(err, instance, info) === true) return true;
310
+ } catch (handlerErr) {
311
+ console.error("Error in app.config.errorHandler:", handlerErr);
312
+ }
313
+ return false;
314
+ }
315
+ function handleHookError(context, err, instance, hookName) {
316
+ console.error(`Error in ${hookName} hook:`, err);
317
+ if (context.config.errorHandler) try {
318
+ context.config.errorHandler(err, instance, `plugin hook: ${hookName}`);
319
+ } catch {}
320
+ }
321
+ var MODEL_SYMBOL = Symbol.for("sigx.model");
322
+ function createModel(tuple, updateHandler) {
323
+ const [obj, key] = tuple;
324
+ return {
325
+ get value() {
326
+ return obj[key];
327
+ },
328
+ set value(v) {
329
+ updateHandler(v);
330
+ },
331
+ get binding() {
332
+ return [
333
+ obj,
334
+ key,
335
+ updateHandler
336
+ ];
337
+ },
338
+ [MODEL_SYMBOL]: true
339
+ };
340
+ }
341
+ function createModelFromBinding(binding) {
342
+ const [obj, key, handler] = binding;
343
+ return createModel([obj, key], handler);
344
+ }
345
+ function isModel(value) {
346
+ return value !== null && typeof value === "object" && MODEL_SYMBOL in value && value[MODEL_SYMBOL] === true;
347
+ }
348
+ function getModelSymbol() {
349
+ return MODEL_SYMBOL;
350
+ }
351
+ var platformModelProcessor = null;
352
+ function setPlatformModelProcessor(fn) {
353
+ platformModelProcessor = fn;
354
+ }
355
+ function getPlatformModelProcessor() {
356
+ return platformModelProcessor;
357
+ }
358
+ function isComponent(type) {
359
+ return typeof type === "function" && "__setup" in type;
360
+ }
361
+ const Fragment = Symbol.for("sigx.Fragment");
362
+ const Text = Symbol.for("sigx.Text");
363
+ function normalizeChildren(children) {
364
+ if (children == null || children === false || children === true) return [];
365
+ if (isComputed(children)) return normalizeChildren(children.value);
366
+ if (Array.isArray(children)) return children.flatMap((c) => normalizeChildren(c));
367
+ if (typeof children === "string" || typeof children === "number") return [{
368
+ type: Text,
369
+ props: {},
370
+ key: null,
371
+ children: [],
372
+ dom: null,
373
+ text: children
374
+ }];
375
+ if (children.type) return [children];
376
+ return [];
377
+ }
378
+ function jsx(type, props, key) {
379
+ const processedProps = { ...props };
380
+ const models = {};
381
+ const isComponentType = isComponent(type);
382
+ if (props) {
383
+ for (const propKey in props) if (propKey === "model") {
384
+ let modelBinding = props[propKey];
385
+ let tuple = null;
386
+ let updateHandler = null;
387
+ if (isModel(modelBinding)) {
388
+ const [obj, key, handler] = modelBinding.binding;
389
+ tuple = [obj, key];
390
+ updateHandler = handler;
391
+ } else if (typeof modelBinding === "function") {
392
+ const detected = detectAccess(modelBinding);
393
+ if (detected && typeof detected[1] === "string") tuple = detected;
394
+ } else if (Array.isArray(modelBinding) && modelBinding.length === 2 && typeof modelBinding[1] === "string") tuple = modelBinding;
395
+ if (tuple) {
396
+ const [stateObj, stateKey] = tuple;
397
+ let handled = false;
398
+ if (!updateHandler) {
399
+ const existingHandler = processedProps["onUpdate:modelValue"];
400
+ updateHandler = (v) => {
401
+ const customHandler = stateObj[`onUpdate:${stateKey}`];
402
+ if (typeof customHandler === "function") customHandler(v);
403
+ else stateObj[stateKey] = v;
404
+ if (existingHandler) existingHandler(v);
405
+ };
406
+ }
407
+ const platformProcessor = getPlatformModelProcessor();
408
+ if (typeof type === "string" && platformProcessor) handled = platformProcessor(type, processedProps, tuple, props);
409
+ if (isComponentType) {
410
+ models.model = createModel(tuple, updateHandler);
411
+ processedProps["onUpdate:modelValue"] = updateHandler;
412
+ } else if (!handled) {
413
+ processedProps.modelValue = stateObj[stateKey];
414
+ processedProps["onUpdate:modelValue"] = updateHandler;
415
+ }
416
+ delete processedProps.model;
417
+ }
418
+ } else if (propKey.startsWith("model:")) {
419
+ let modelBinding = props[propKey];
420
+ const name = propKey.slice(6);
421
+ let tuple = null;
422
+ let updateHandler = null;
423
+ if (isModel(modelBinding)) {
424
+ const [obj, key, handler] = modelBinding.binding;
425
+ tuple = [obj, key];
426
+ updateHandler = handler;
427
+ } else if (typeof modelBinding === "function") {
428
+ const detected = detectAccess(modelBinding);
429
+ if (detected && typeof detected[1] === "string") tuple = detected;
430
+ } else if (Array.isArray(modelBinding) && modelBinding.length === 2 && typeof modelBinding[1] === "string") tuple = modelBinding;
431
+ if (tuple) {
432
+ const [stateObj, stateKey] = tuple;
433
+ const eventName = `onUpdate:${name}`;
434
+ if (!updateHandler) {
435
+ const existingHandler = processedProps[eventName];
436
+ updateHandler = (v) => {
437
+ const customHandler = stateObj[`onUpdate:${stateKey}`];
438
+ if (typeof customHandler === "function") customHandler(v);
439
+ else stateObj[stateKey] = v;
440
+ if (existingHandler) existingHandler(v);
441
+ };
442
+ }
443
+ if (isComponentType) {
444
+ models[name] = createModel(tuple, updateHandler);
445
+ processedProps[eventName] = updateHandler;
446
+ } else {
447
+ processedProps[name] = stateObj[stateKey];
448
+ processedProps[eventName] = updateHandler;
449
+ }
450
+ delete processedProps[propKey];
451
+ }
452
+ }
453
+ }
454
+ if (Object.keys(models).length > 0) processedProps.$models = models;
455
+ if (isComponent(type)) {
456
+ const { children, ...rest } = processedProps;
457
+ return {
458
+ type,
459
+ props: {
460
+ ...rest,
461
+ children
462
+ },
463
+ key: key || rest.key || null,
464
+ children: [],
465
+ dom: null
466
+ };
467
+ }
468
+ if (typeof type === "function" && type !== Fragment) return type(processedProps);
469
+ const { children, ...rest } = processedProps;
470
+ return {
471
+ type,
472
+ props: rest,
473
+ key: key || rest.key || null,
474
+ children: normalizeChildren(children),
475
+ dom: null
476
+ };
477
+ }
478
+ function jsxs(type, props, key) {
479
+ return jsx(type, props, key);
480
+ }
481
+ const jsxDEV = jsx;
482
+ var currentSuspenseBoundary = null;
483
+ function registerPendingPromise(promise) {
484
+ const boundary = getCurrentSuspenseBoundarySafe() ?? currentSuspenseBoundary;
485
+ if (boundary) {
486
+ boundary.pending.add(promise);
487
+ promise.finally(() => {
488
+ boundary.pending.delete(promise);
489
+ if (boundary.pending.size === 0) boundary.onResolve();
490
+ });
491
+ return true;
492
+ }
493
+ return false;
494
+ }
495
+ function lazy(loader) {
496
+ let Component = null;
497
+ let promise = null;
498
+ let error = null;
499
+ let state = "pending";
500
+ const LazyWrapper = component((ctx) => {
501
+ const loadState = ctx.signal({
502
+ state,
503
+ tick: 0
504
+ });
505
+ if (!promise) promise = loader().then((mod) => {
506
+ Component = "default" in mod ? mod.default : mod;
507
+ state = "resolved";
508
+ loadState.state = "resolved";
509
+ loadState.tick++;
510
+ return Component;
511
+ }).catch((err) => {
512
+ error = err instanceof Error ? err : new Error(String(err));
513
+ state = "rejected";
514
+ loadState.state = "rejected";
515
+ loadState.tick++;
516
+ throw error;
517
+ });
518
+ if (state === "resolved" && Component) return () => {
519
+ return jsx(Component, {});
520
+ };
521
+ if (state === "rejected" && error) throw error;
522
+ if (!registerPendingPromise(promise)) promise.catch(() => {});
523
+ return () => {
524
+ const currentState = loadState.state;
525
+ loadState.tick;
526
+ if (currentState === "resolved" && Component) return jsx(Component, {});
527
+ if (currentState === "rejected" && error) throw error;
528
+ return null;
529
+ };
530
+ }, { name: "LazyComponent" });
531
+ LazyWrapper.__lazy = true;
532
+ LazyWrapper.preload = () => {
533
+ if (!promise) promise = loader().then((mod) => {
534
+ Component = "default" in mod ? mod.default : mod;
535
+ state = "resolved";
536
+ return Component;
537
+ }).catch((err) => {
538
+ error = err instanceof Error ? err : new Error(String(err));
539
+ state = "rejected";
540
+ throw error;
541
+ });
542
+ return promise;
543
+ };
544
+ LazyWrapper.isLoaded = () => {
545
+ return state === "resolved";
546
+ };
547
+ return LazyWrapper;
548
+ }
549
+ const Suspense = component((ctx) => {
550
+ const { props, slots } = ctx;
551
+ const state = ctx.signal({
552
+ isReady: false,
553
+ pendingCount: 0
554
+ });
555
+ const boundary = {
556
+ pending: /* @__PURE__ */ new Set(),
557
+ onResolve: () => {
558
+ state.pendingCount = boundary.pending.size;
559
+ if (boundary.pending.size === 0) state.isReady = true;
560
+ }
561
+ };
562
+ ctx.onMounted(() => {
563
+ if (boundary.pending.size === 0) state.isReady = true;
564
+ });
565
+ return () => {
566
+ state.isReady;
567
+ state.pendingCount;
568
+ const prevBoundary = getCurrentSuspenseBoundarySafe() ?? currentSuspenseBoundary;
569
+ currentSuspenseBoundary = boundary;
570
+ setCurrentSuspenseBoundarySafe(boundary);
571
+ try {
572
+ const children = slots.default();
573
+ if (boundary.pending.size > 0) {
574
+ const fallback = props.fallback;
575
+ if (typeof fallback === "function") return fallback();
576
+ return fallback ?? null;
577
+ }
578
+ if (Array.isArray(children)) {
579
+ const filtered = children.filter((c) => c != null && c !== false && c !== true);
580
+ if (filtered.length === 0) return null;
581
+ if (filtered.length === 1) return filtered[0];
582
+ return filtered;
583
+ }
584
+ return children;
585
+ } catch (err) {
586
+ if (err instanceof Promise) {
587
+ registerPendingPromise(err);
588
+ const fallback = props.fallback;
589
+ if (typeof fallback === "function") return fallback();
590
+ return fallback ?? null;
591
+ }
592
+ throw err;
593
+ } finally {
594
+ currentSuspenseBoundary = prevBoundary;
595
+ setCurrentSuspenseBoundarySafe(prevBoundary);
596
+ }
597
+ };
598
+ }, { name: "Suspense" });
599
+ function isLazyComponent(component) {
600
+ return component && component.__lazy === true;
601
+ }
602
+ function createPropsAccessor(reactiveProps) {
603
+ return new Proxy(reactiveProps, {
604
+ get(target, key) {
605
+ if (typeof key === "symbol") return void 0;
606
+ return target[key];
607
+ },
608
+ has(target, key) {
609
+ if (typeof key === "symbol") return false;
610
+ return key in target;
611
+ },
612
+ ownKeys(target) {
613
+ return Object.keys(target);
614
+ },
615
+ getOwnPropertyDescriptor(target, key) {
616
+ if (typeof key === "symbol") return void 0;
617
+ if (key in target) return {
618
+ enumerable: true,
619
+ configurable: true,
620
+ writable: false
621
+ };
622
+ }
623
+ });
624
+ }
625
+ function createSlots(children, slotsFromProps) {
626
+ const versionSignal = signal({ v: 0 });
627
+ function extractNamedSlotsFromChildren(c) {
628
+ const defaultChildren = [];
629
+ const namedSlots = {};
630
+ if (c == null) return {
631
+ defaultChildren,
632
+ namedSlots
633
+ };
634
+ const items = Array.isArray(c) ? c : [c];
635
+ for (const child of items) if (child && typeof child === "object" && child.props && child.props.slot) {
636
+ const slotName = child.props.slot;
637
+ if (!namedSlots[slotName]) namedSlots[slotName] = [];
638
+ namedSlots[slotName].push(child);
639
+ } else defaultChildren.push(child);
640
+ return {
641
+ defaultChildren,
642
+ namedSlots
643
+ };
644
+ }
645
+ const slotsObj = {
646
+ _children: children,
647
+ _slotsFromProps: slotsFromProps || {},
648
+ _version: versionSignal,
649
+ _isPatching: false,
650
+ default: function() {
651
+ this._version.v;
652
+ const c = this._children;
653
+ const { defaultChildren } = extractNamedSlotsFromChildren(c);
654
+ return defaultChildren.filter((child) => child != null && child !== false && child !== true);
655
+ }
656
+ };
657
+ return new Proxy(slotsObj, { get(target, prop) {
658
+ if (prop in target) return target[prop];
659
+ if (typeof prop === "string") return function(scopedProps) {
660
+ target._version.v;
661
+ if (target._slotsFromProps && typeof target._slotsFromProps[prop] === "function") {
662
+ const result = target._slotsFromProps[prop](scopedProps);
663
+ if (result == null) return [];
664
+ return Array.isArray(result) ? result : [result];
665
+ }
666
+ const { namedSlots } = extractNamedSlotsFromChildren(target._children);
667
+ return namedSlots[prop] || [];
668
+ };
669
+ } });
670
+ }
671
+ function normalizeSubTree(result) {
672
+ if (result == null || result === false || result === true) return {
673
+ type: Text,
674
+ props: {},
675
+ key: null,
676
+ children: [],
677
+ dom: null,
678
+ text: ""
679
+ };
680
+ if (isComputed(result)) return normalizeSubTree(result.value);
681
+ if (Array.isArray(result)) return {
682
+ type: Fragment,
683
+ props: {},
684
+ key: null,
685
+ children: result,
686
+ dom: null
687
+ };
688
+ if (typeof result === "string" || typeof result === "number") return {
689
+ type: Text,
690
+ props: {},
691
+ key: null,
692
+ children: [],
693
+ dom: null,
694
+ text: result
695
+ };
696
+ return result;
697
+ }
698
+ const CLIENT_DIRECTIVE_PREFIX = "client:";
699
+ const CLIENT_DIRECTIVES = [
700
+ "client:load",
701
+ "client:idle",
702
+ "client:visible",
703
+ "client:media",
704
+ "client:only"
705
+ ];
706
+ function filterClientDirectives(props) {
707
+ const filtered = {};
708
+ for (const key in props) if (!key.startsWith("client:")) filtered[key] = props[key];
709
+ return filtered;
710
+ }
711
+ function getHydrationDirective(props) {
712
+ if (props["client:load"] !== void 0) return { strategy: "load" };
713
+ if (props["client:idle"] !== void 0) return { strategy: "idle" };
714
+ if (props["client:visible"] !== void 0) return { strategy: "visible" };
715
+ if (props["client:only"] !== void 0) return { strategy: "only" };
716
+ if (props["client:media"] !== void 0) return {
717
+ strategy: "media",
718
+ media: props["client:media"]
719
+ };
720
+ return null;
721
+ }
722
+ function hasClientDirective(props) {
723
+ for (const key in props) if (key.startsWith("client:")) return true;
724
+ return false;
725
+ }
726
+ function serializeProps(props) {
727
+ const filtered = filterClientDirectives(props);
728
+ const result = {};
729
+ let hasProps = false;
730
+ for (const key in filtered) {
731
+ const value = filtered[key];
732
+ if (key === "children" || key === "key" || key === "ref" || key === "slots") continue;
733
+ if (typeof value === "function") continue;
734
+ if (typeof value === "symbol") continue;
735
+ if (value === void 0) continue;
736
+ if (key.startsWith("on") && key.length > 2 && key[2] === key[2].toUpperCase()) continue;
737
+ try {
738
+ JSON.stringify(value);
739
+ result[key] = value;
740
+ hasProps = true;
741
+ } catch {}
742
+ }
743
+ return hasProps ? result : void 0;
744
+ }
745
+ function createEmit(reactiveProps) {
746
+ return (event, ...args) => {
747
+ const eventName = `on${event[0].toUpperCase() + event.slice(1)}`;
748
+ const handler = ("value" in reactiveProps ? reactiveProps.value : reactiveProps)?.[eventName];
749
+ if (handler && typeof handler === "function") handler(...args);
750
+ };
751
+ }
752
+ function createRenderer(options) {
753
+ const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: _hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, cloneNode: _hostCloneNode, insertStaticContent: _hostInsertStaticContent, patchDirective: hostPatchDirective, onElementMounted: hostOnElementMounted, onElementUnmounted: hostOnElementUnmounted, getActiveElement: hostGetActiveElement, restoreFocus: hostRestoreFocus } = options;
754
+ let currentAppContext = null;
755
+ function render(element, container, appContext) {
756
+ if (appContext) currentAppContext = appContext;
757
+ const oldVNode = container._vnode;
758
+ let vnode = null;
759
+ if (element != null && element !== false && element !== true) if (typeof element === "string" || typeof element === "number") vnode = {
760
+ type: Text,
761
+ props: {},
762
+ key: null,
763
+ children: [],
764
+ dom: null,
765
+ text: element
766
+ };
767
+ else if (isComponent(element)) vnode = {
768
+ type: element,
769
+ props: {},
770
+ key: null,
771
+ children: [],
772
+ dom: null
773
+ };
774
+ else vnode = element;
775
+ if (vnode) {
776
+ if (oldVNode) patch(oldVNode, vnode, container);
777
+ else mount(vnode, container);
778
+ container._vnode = vnode;
779
+ } else if (oldVNode) {
780
+ unmount(oldVNode, container);
781
+ container._vnode = null;
782
+ }
783
+ }
784
+ const svgTags = new Set([
785
+ "svg",
786
+ "animate",
787
+ "animateMotion",
788
+ "animateTransform",
789
+ "circle",
790
+ "clipPath",
791
+ "defs",
792
+ "desc",
793
+ "ellipse",
794
+ "feBlend",
795
+ "feColorMatrix",
796
+ "feComponentTransfer",
797
+ "feComposite",
798
+ "feConvolveMatrix",
799
+ "feDiffuseLighting",
800
+ "feDisplacementMap",
801
+ "feDistantLight",
802
+ "feDropShadow",
803
+ "feFlood",
804
+ "feFuncA",
805
+ "feFuncB",
806
+ "feFuncG",
807
+ "feFuncR",
808
+ "feGaussianBlur",
809
+ "feImage",
810
+ "feMerge",
811
+ "feMergeNode",
812
+ "feMorphology",
813
+ "feOffset",
814
+ "fePointLight",
815
+ "feSpecularLighting",
816
+ "feSpotLight",
817
+ "feTile",
818
+ "feTurbulence",
819
+ "filter",
820
+ "foreignObject",
821
+ "g",
822
+ "image",
823
+ "line",
824
+ "linearGradient",
825
+ "marker",
826
+ "mask",
827
+ "metadata",
828
+ "mpath",
829
+ "path",
830
+ "pattern",
831
+ "polygon",
832
+ "polyline",
833
+ "radialGradient",
834
+ "rect",
835
+ "set",
836
+ "stop",
837
+ "switch",
838
+ "symbol",
839
+ "text",
840
+ "textPath",
841
+ "title",
842
+ "tspan",
843
+ "use",
844
+ "view"
845
+ ]);
846
+ function isSvgTag(tag) {
847
+ return svgTags.has(tag);
848
+ }
849
+ function mount(vnode, container, before = null, parentIsSVG = false) {
850
+ if (vnode == null || vnode === false || vnode === true) return;
851
+ if (vnode.type === Text) {
852
+ const node = hostCreateText(String(vnode.text));
853
+ vnode.dom = node;
854
+ node.__vnode = vnode;
855
+ hostInsert(node, container, before);
856
+ return;
857
+ }
858
+ if (vnode.type === Fragment) {
859
+ const anchor = hostCreateComment("");
860
+ vnode.dom = anchor;
861
+ hostInsert(anchor, container, before);
862
+ if (vnode.children) vnode.children.forEach((child) => mount(child, container, anchor, parentIsSVG));
863
+ return;
864
+ }
865
+ if (isComponent(vnode.type)) {
866
+ mountComponent(vnode, container, before, vnode.type.__setup);
867
+ return;
868
+ }
869
+ const tag = vnode.type;
870
+ const isSVG = tag === "svg" || parentIsSVG && tag !== "foreignObject";
871
+ const element = hostCreateElement(tag, isSVG);
872
+ vnode.dom = element;
873
+ element.__vnode = vnode;
874
+ if (vnode.props) {
875
+ for (const key in vnode.props) if (key !== "children" && key !== "key" && key !== "ref") if (key.charCodeAt(0) === 117 && key.startsWith("use:")) {
876
+ if (hostPatchDirective) hostPatchDirective(element, key.slice(4), null, vnode.props[key], currentAppContext);
877
+ } else hostPatchProp(element, key, null, vnode.props[key], isSVG);
878
+ if (vnode.props.ref) untrack(() => {
879
+ if (typeof vnode.props.ref === "function") vnode.props.ref(element);
880
+ else if (typeof vnode.props.ref === "object") vnode.props.ref.current = element;
881
+ });
882
+ }
883
+ const childIsSVG = isSVG && tag !== "foreignObject";
884
+ if (vnode.children) vnode.children.forEach((child) => {
885
+ child.parent = vnode;
886
+ mount(child, element, null, childIsSVG);
887
+ });
888
+ hostInsert(element, container, before);
889
+ if (hostOnElementMounted) hostOnElementMounted(element);
890
+ }
891
+ function unmount(vnode, container) {
892
+ const internalVNode = vnode;
893
+ if (internalVNode._effect) internalVNode._effect.stop();
894
+ if (vnode.cleanup) vnode.cleanup();
895
+ if (isComponent(vnode.type)) {
896
+ const subTree = internalVNode._subTree;
897
+ if (subTree) unmount(subTree, container);
898
+ if (vnode.dom) hostRemove(vnode.dom);
899
+ if (vnode.props?.ref) untrack(() => {
900
+ if (typeof vnode.props.ref === "function") vnode.props.ref(null);
901
+ else if (typeof vnode.props.ref === "object") vnode.props.ref.current = null;
902
+ });
903
+ return;
904
+ }
905
+ if (vnode.type === Fragment) {
906
+ if (vnode.children) vnode.children.forEach((child) => unmount(child, container));
907
+ if (vnode.dom) hostRemove(vnode.dom);
908
+ return;
909
+ }
910
+ if (vnode.props?.ref) untrack(() => {
911
+ if (typeof vnode.props.ref === "function") vnode.props.ref(null);
912
+ else if (vnode.props.ref && typeof vnode.props.ref === "object") vnode.props.ref.current = null;
913
+ });
914
+ if (hostOnElementUnmounted && vnode.dom) hostOnElementUnmounted(vnode.dom);
915
+ if (vnode.children && vnode.children.length > 0) vnode.children.forEach((child) => unmount(child, vnode.dom));
916
+ if (vnode.dom) hostRemove(vnode.dom);
917
+ }
918
+ function patch(oldVNode, newVNode, container) {
919
+ if (oldVNode === newVNode) return;
920
+ if (!isSameVNode(oldVNode, newVNode)) {
921
+ const parent = hostParentNode(oldVNode.dom) || container;
922
+ const nextSibling = oldVNode.dom ? hostNextSibling(oldVNode.dom) : null;
923
+ unmount(oldVNode, parent);
924
+ mount(newVNode, parent, nextSibling);
925
+ return;
926
+ }
927
+ const oldInternal = oldVNode;
928
+ const newInternal = newVNode;
929
+ if (oldInternal._effect) {
930
+ newVNode.dom = oldVNode.dom;
931
+ newInternal._effect = oldInternal._effect;
932
+ newInternal._subTree = oldInternal._subTree;
933
+ newInternal._slots = oldInternal._slots;
934
+ const props = oldInternal._componentProps;
935
+ newInternal._componentProps = props;
936
+ if (props) {
937
+ const newProps = newVNode.props || {};
938
+ const newModels = newVNode.props?.$models || {};
939
+ untrack(() => {
940
+ for (const key in newProps) if (key !== "children" && key !== "key" && key !== "ref" && key !== "$models") {
941
+ if (props[key] !== newProps[key]) props[key] = newProps[key];
942
+ }
943
+ for (const modelKey in newModels) {
944
+ const newModel = newModels[modelKey];
945
+ const oldModel = props[modelKey];
946
+ if (isModel(newModel)) {
947
+ if (isModel(oldModel)) {
948
+ const [newObj, newKey] = newModel.binding;
949
+ const [oldObj, oldKey] = oldModel.binding;
950
+ if (newObj === oldObj && newKey === oldKey) continue;
951
+ }
952
+ props[modelKey] = newModel;
953
+ }
954
+ }
955
+ for (const key in props) if (!(key in newProps) && !(key in newModels) && key !== "children" && key !== "key" && key !== "ref" && key !== "$models") delete props[key];
956
+ });
957
+ }
958
+ const slotsRef = oldInternal._slots;
959
+ const newChildren = newVNode.props?.children;
960
+ const newSlotsFromProps = newVNode.props?.slots;
961
+ if (slotsRef) {
962
+ if (newChildren !== void 0) slotsRef._children = newChildren;
963
+ if (newSlotsFromProps !== void 0) slotsRef._slotsFromProps = newSlotsFromProps;
964
+ if (!slotsRef._isPatching) {
965
+ slotsRef._isPatching = true;
966
+ try {
967
+ untrack(() => {
968
+ slotsRef._version.v++;
969
+ });
970
+ } finally {
971
+ slotsRef._isPatching = false;
972
+ }
973
+ }
974
+ }
975
+ return;
976
+ }
977
+ if (newVNode.type === Text) {
978
+ newVNode.dom = oldVNode.dom;
979
+ if (!newVNode.dom) {
980
+ const textNode = hostCreateText(String(newVNode.text));
981
+ newVNode.dom = textNode;
982
+ if (container) hostInsert(textNode, container, oldVNode.dom || null);
983
+ return;
984
+ }
985
+ if (oldVNode.text !== newVNode.text) hostSetText(newVNode.dom, String(newVNode.text));
986
+ return;
987
+ }
988
+ if (newVNode.type === Fragment) {
989
+ patchChildren(oldVNode, newVNode, container, false);
990
+ return;
991
+ }
992
+ const element = newVNode.dom = oldVNode.dom;
993
+ if (!element) {
994
+ mount(newVNode, container);
995
+ return;
996
+ }
997
+ const tag = newVNode.type;
998
+ const isSVG = tag === "svg" || isSvgTag(tag);
999
+ const oldProps = oldVNode.props || {};
1000
+ const newProps = newVNode.props || {};
1001
+ for (const key in oldProps) if (!(key in newProps) && key !== "children" && key !== "key" && key !== "ref") if (key.charCodeAt(0) === 117 && key.startsWith("use:")) {
1002
+ if (hostPatchDirective) hostPatchDirective(element, key.slice(4), oldProps[key], null, currentAppContext);
1003
+ } else hostPatchProp(element, key, oldProps[key], null, isSVG);
1004
+ for (const key in newProps) {
1005
+ const oldValue = oldProps[key];
1006
+ const newValue = newProps[key];
1007
+ if (key !== "children" && key !== "key" && key !== "ref" && oldValue !== newValue) if (key.charCodeAt(0) === 117 && key.startsWith("use:")) {
1008
+ if (hostPatchDirective) hostPatchDirective(element, key.slice(4), oldValue, newValue, currentAppContext);
1009
+ } else hostPatchProp(element, key, oldValue, newValue, isSVG);
1010
+ }
1011
+ patchChildren(oldVNode, newVNode, element, isSVG && tag !== "foreignObject");
1012
+ }
1013
+ function patchChildren(oldVNode, newVNode, container, parentIsSVG = false) {
1014
+ const oldChildren = oldVNode.children;
1015
+ const newChildren = newVNode.children;
1016
+ newChildren.forEach((c) => c.parent = newVNode);
1017
+ reconcileChildrenArray(container, oldChildren, newChildren, parentIsSVG);
1018
+ }
1019
+ function checkDuplicateKeys(children) {
1020
+ if (process.env.NODE_ENV === "production") return;
1021
+ const seenKeys = /* @__PURE__ */ new Set();
1022
+ for (const child of children) if (child?.key != null) {
1023
+ const keyStr = String(child.key);
1024
+ if (seenKeys.has(keyStr)) console.warn(`[SignalX] Duplicate key "${child.key}" detected in list. Keys should be unique among siblings to ensure correct reconciliation. This may cause unexpected behavior when items are reordered, added, or removed.`);
1025
+ seenKeys.add(keyStr);
1026
+ }
1027
+ }
1028
+ function reconcileChildrenArray(parent, oldChildren, newChildren, parentIsSVG = false) {
1029
+ if (process.env.NODE_ENV !== "production") checkDuplicateKeys(newChildren);
1030
+ let oldStartIdx = 0;
1031
+ let oldEndIdx = oldChildren.length - 1;
1032
+ let oldStartVNode = oldChildren[0];
1033
+ let oldEndVNode = oldChildren[oldEndIdx];
1034
+ let newStartIdx = 0;
1035
+ let newEndIdx = newChildren.length - 1;
1036
+ let newStartVNode = newChildren[0];
1037
+ let newEndVNode = newChildren[newEndIdx];
1038
+ let oldKeyToIdx;
1039
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) if (oldStartVNode == null) oldStartVNode = oldChildren[++oldStartIdx];
1040
+ else if (oldEndVNode == null) oldEndVNode = oldChildren[--oldEndIdx];
1041
+ else if (isSameVNode(oldStartVNode, newStartVNode)) {
1042
+ patch(oldStartVNode, newStartVNode, parent);
1043
+ oldStartVNode = oldChildren[++oldStartIdx];
1044
+ newStartVNode = newChildren[++newStartIdx];
1045
+ } else if (isSameVNode(oldEndVNode, newEndVNode)) {
1046
+ patch(oldEndVNode, newEndVNode, parent);
1047
+ oldEndVNode = oldChildren[--oldEndIdx];
1048
+ newEndVNode = newChildren[--newEndIdx];
1049
+ } else if (isSameVNode(oldStartVNode, newEndVNode)) {
1050
+ patch(oldStartVNode, newEndVNode, parent);
1051
+ const nodeToMove = oldStartVNode.dom;
1052
+ const anchor = hostNextSibling(oldEndVNode.dom);
1053
+ if (nodeToMove) hostInsert(nodeToMove, parent, anchor);
1054
+ oldStartVNode = oldChildren[++oldStartIdx];
1055
+ newEndVNode = newChildren[--newEndIdx];
1056
+ } else if (isSameVNode(oldEndVNode, newStartVNode)) {
1057
+ patch(oldEndVNode, newStartVNode, parent);
1058
+ const nodeToMove = oldEndVNode.dom;
1059
+ const anchor = oldStartVNode.dom;
1060
+ if (nodeToMove) hostInsert(nodeToMove, parent, anchor);
1061
+ oldEndVNode = oldChildren[--oldEndIdx];
1062
+ newStartVNode = newChildren[++newStartIdx];
1063
+ } else {
1064
+ if (!oldKeyToIdx) oldKeyToIdx = createKeyToKeyIndexMap(oldChildren, oldStartIdx, oldEndIdx);
1065
+ const idxInOld = newStartVNode.key != null ? oldKeyToIdx.get(String(newStartVNode.key)) : findIndexInOld(oldChildren, newStartVNode, oldStartIdx, oldEndIdx);
1066
+ if (idxInOld != null) {
1067
+ const vnodeToMove = oldChildren[idxInOld];
1068
+ patch(vnodeToMove, newStartVNode, parent);
1069
+ oldChildren[idxInOld] = void 0;
1070
+ if (vnodeToMove.dom && oldStartVNode.dom) hostInsert(vnodeToMove.dom, parent, oldStartVNode.dom);
1071
+ } else mount(newStartVNode, parent, oldStartVNode.dom, parentIsSVG);
1072
+ newStartVNode = newChildren[++newStartIdx];
1073
+ }
1074
+ if (oldStartIdx > oldEndIdx) {
1075
+ if (newStartIdx <= newEndIdx) {
1076
+ const anchor = newChildren[newEndIdx + 1] == null ? null : newChildren[newEndIdx + 1].dom;
1077
+ for (let i = newStartIdx; i <= newEndIdx; i++) mount(newChildren[i], parent, anchor, parentIsSVG);
1078
+ }
1079
+ } else if (newStartIdx > newEndIdx) {
1080
+ for (let i = oldStartIdx; i <= oldEndIdx; i++) if (oldChildren[i]) unmount(oldChildren[i], parent);
1081
+ }
1082
+ }
1083
+ function isSameVNode(n1, n2) {
1084
+ const k1 = n1.key == null ? null : n1.key;
1085
+ const k2 = n2.key == null ? null : n2.key;
1086
+ if (n1.type !== n2.type) return false;
1087
+ if (k1 === k2) return true;
1088
+ return String(k1) === String(k2);
1089
+ }
1090
+ function createKeyToKeyIndexMap(children, beginIdx, endIdx) {
1091
+ const map = /* @__PURE__ */ new Map();
1092
+ for (let i = beginIdx; i <= endIdx; i++) {
1093
+ const key = children[i]?.key;
1094
+ if (key != null) {
1095
+ const keyStr = String(key);
1096
+ if (process.env.NODE_ENV !== "production" && map.has(keyStr)) console.warn(`[SignalX] Duplicate key "${key}" detected in list. Keys should be unique among siblings to ensure correct reconciliation. This may cause unexpected behavior when items are reordered, added, or removed.`);
1097
+ map.set(keyStr, i);
1098
+ }
1099
+ }
1100
+ return map;
1101
+ }
1102
+ function findIndexInOld(children, newChild, beginIdx, endIdx) {
1103
+ for (let i = beginIdx; i <= endIdx; i++) if (children[i] && isSameVNode(children[i], newChild)) return i;
1104
+ return null;
1105
+ }
1106
+ function mountComponent(vnode, container, before, setup) {
1107
+ const anchor = hostCreateComment("");
1108
+ vnode.dom = anchor;
1109
+ anchor.__vnode = vnode;
1110
+ hostInsert(anchor, container, before);
1111
+ let exposed = null;
1112
+ let exposeCalled = false;
1113
+ const { children, slots: slotsFromProps, $models: modelsData, ...propsData } = vnode.props || {};
1114
+ const propsWithModels = { ...propsData };
1115
+ if (modelsData) for (const modelKey in modelsData) {
1116
+ const modelValue = modelsData[modelKey];
1117
+ if (isModel(modelValue)) propsWithModels[modelKey] = modelValue;
1118
+ }
1119
+ const reactiveProps = signal(propsWithModels);
1120
+ const internalVNode = vnode;
1121
+ internalVNode._componentProps = reactiveProps;
1122
+ const slots = createSlots(children, slotsFromProps);
1123
+ internalVNode._slots = slots;
1124
+ const createdHooks = [];
1125
+ const mountHooks = [];
1126
+ const updatedHooks = [];
1127
+ const unmountHooks = [];
1128
+ const parentInstance = getCurrentInstance();
1129
+ const componentName = vnode.type.__name;
1130
+ const ctx = {
1131
+ el: container,
1132
+ signal,
1133
+ props: createPropsAccessor(reactiveProps),
1134
+ slots,
1135
+ emit: createEmit(reactiveProps),
1136
+ parent: parentInstance,
1137
+ onMounted: (fn) => {
1138
+ mountHooks.push(fn);
1139
+ },
1140
+ onUnmounted: (fn) => {
1141
+ unmountHooks.push(fn);
1142
+ },
1143
+ onCreated: (fn) => {
1144
+ createdHooks.push(fn);
1145
+ },
1146
+ onUpdated: (fn) => {
1147
+ updatedHooks.push(fn);
1148
+ },
1149
+ expose: (exposedValue) => {
1150
+ exposed = exposedValue;
1151
+ exposeCalled = true;
1152
+ },
1153
+ renderFn: null,
1154
+ update: () => {}
1155
+ };
1156
+ applyContextExtensions(ctx);
1157
+ ctx.__name = componentName;
1158
+ if (!parentInstance && currentAppContext) provideAppContext(ctx, currentAppContext);
1159
+ const componentInstance = {
1160
+ name: componentName,
1161
+ ctx,
1162
+ vnode
1163
+ };
1164
+ const prev = setCurrentInstance(ctx);
1165
+ let renderFn;
1166
+ try {
1167
+ const setupResult = setup(ctx);
1168
+ if (setupResult && typeof setupResult.then === "function") throw new Error(`Async setup in component "${componentName}" is only supported during SSR. On the client, use pre-loaded data from hydration or fetch in onMounted.`);
1169
+ renderFn = setupResult;
1170
+ notifyComponentCreated(currentAppContext, componentInstance);
1171
+ createdHooks.forEach((hook) => hook());
1172
+ } catch (err) {
1173
+ if (!handleComponentError(currentAppContext, err, componentInstance, "setup")) throw err;
1174
+ } finally {
1175
+ setCurrentInstance(prev);
1176
+ }
1177
+ if (vnode.props?.ref) {
1178
+ const refValue = exposeCalled ? exposed : null;
1179
+ untrack(() => {
1180
+ if (typeof vnode.props.ref === "function") vnode.props.ref(refValue);
1181
+ else if (vnode.props.ref && typeof vnode.props.ref === "object") vnode.props.ref.current = refValue;
1182
+ });
1183
+ }
1184
+ if (renderFn) {
1185
+ ctx.renderFn = renderFn;
1186
+ const componentEffect = effect(() => {
1187
+ const prevInstance = setCurrentInstance(ctx);
1188
+ try {
1189
+ const subTreeResult = ctx.renderFn();
1190
+ if (subTreeResult == null) return;
1191
+ const subTree = normalizeSubTree(subTreeResult);
1192
+ const prevSubTree = internalVNode._subTree;
1193
+ if (prevSubTree) {
1194
+ const prevFocus = hostGetActiveElement ? hostGetActiveElement() : null;
1195
+ patch(prevSubTree, subTree, container);
1196
+ if (prevFocus && hostRestoreFocus && hostGetActiveElement() !== prevFocus) hostRestoreFocus(prevFocus);
1197
+ notifyComponentUpdated(currentAppContext, componentInstance);
1198
+ updatedHooks.forEach((hook) => hook());
1199
+ } else mount(subTree, container, anchor);
1200
+ internalVNode._subTree = subTree;
1201
+ } catch (err) {
1202
+ if (!handleComponentError(currentAppContext, err, componentInstance, "render")) throw err;
1203
+ } finally {
1204
+ setCurrentInstance(prevInstance);
1205
+ }
1206
+ });
1207
+ internalVNode._effect = componentEffect;
1208
+ ctx.update = () => {
1209
+ componentEffect();
1210
+ };
1211
+ }
1212
+ const mountCtx = { el: container };
1213
+ mountHooks.forEach((hook) => hook(mountCtx));
1214
+ notifyComponentMounted(currentAppContext, componentInstance);
1215
+ vnode.cleanup = () => {
1216
+ notifyComponentUnmounted(currentAppContext, componentInstance);
1217
+ unmountHooks.forEach((hook) => hook(mountCtx));
1218
+ };
1219
+ }
1220
+ return {
1221
+ render,
1222
+ patch,
1223
+ mount,
1224
+ unmount,
1225
+ mountComponent
1226
+ };
1227
+ }
1228
+ export { runInRequestScope as $, handleComponentError as A, defineProvide as B, setPlatformModelProcessor as C, isModel as D, getModelSymbol as E, setDefaultMount as F, getComponentMeta as G, provideAppContext as H, __DIRECTIVE__ as I, onMounted as J, getCurrentInstance as K, defineDirective as L, notifyComponentMounted as M, notifyComponentUnmounted as N, defineApp as O, notifyComponentUpdated as P, hasRequestIsolation as Q, isDirective as R, getPlatformModelProcessor as S, createModelFromBinding as T, useAppContext as U, getAppContextToken as V, component as W, onUpdated as X, onUnmounted as Y, setCurrentInstance as Z, Text as _, filterClientDirectives as a, jsxs as b, serializeProps as c, createPropsAccessor as d, applyContextExtensions as et, Suspense as f, Fragment as g, registerPendingPromise as h, createEmit as i, notifyComponentCreated as j, getDefaultMount as k, normalizeSubTree as l, lazy as m, CLIENT_DIRECTIVES as n, registerComponentPlugin as nt, getHydrationDirective as o, isLazyComponent as p, onCreated as q, CLIENT_DIRECTIVE_PREFIX as r, registerContextExtension as rt, hasClientDirective as s, createRenderer as t, getComponentPlugins as tt, createSlots as u, jsx as v, createModel as w, isComponent as x, jsxDEV as y, defineInjectable as z };
1229
+
1230
+ //# sourceMappingURL=renderer-KQIgreMb.js.map