@v-ibe/core 0.1.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.
- package/LICENSE +21 -0
- package/README.md +40 -0
- package/dist/DI/__tests__/scoped-container-dependencies.test.d.ts +1 -0
- package/dist/DI/bootstrap.d.ts +18 -0
- package/dist/DI/decorators/inject.d.ts +37 -0
- package/dist/DI/decorators/inject.js +45 -0
- package/dist/DI/decorators/service.d.ts +24 -0
- package/dist/DI/decorators/service.js +13 -0
- package/dist/DI/di-container.d.ts +53 -0
- package/dist/DI/di-container.js +158 -0
- package/dist/DI/lifecycle.d.ts +37 -0
- package/dist/DI/lifecycle.js +6 -0
- package/dist/DI/scoped-container.d.ts +68 -0
- package/dist/DI/scoped-container.js +193 -0
- package/dist/DI/service-metadata.d.ts +32 -0
- package/dist/DI/service-metadata.js +31 -0
- package/dist/DI/types.d.ts +4 -0
- package/dist/behaviors/__tests__/behavior-system.test.d.ts +1 -0
- package/dist/behaviors/behavior-manager.d.ts +60 -0
- package/dist/behaviors/behavior-manager.js +131 -0
- package/dist/behaviors/behavior-registry.d.ts +68 -0
- package/dist/behaviors/behavior-registry.js +105 -0
- package/dist/behaviors/constants.d.ts +16 -0
- package/dist/behaviors/constants.js +8 -0
- package/dist/behaviors/decorators.d.ts +87 -0
- package/dist/behaviors/decorators.js +46 -0
- package/dist/behaviors/index.d.ts +4 -0
- package/dist/components/__tests__/host.test.d.ts +1 -0
- package/dist/components/app-tree.d.ts +49 -0
- package/dist/components/app-tree.js +122 -0
- package/dist/components/base-component.d.ts +85 -0
- package/dist/components/base-component.js +438 -0
- package/dist/components/decorators/component.d.ts +27 -0
- package/dist/components/decorators/component.js +47 -0
- package/dist/components/decorators/prop.d.ts +14 -0
- package/dist/components/decorators/prop.js +37 -0
- package/dist/components/types.d.ts +26 -0
- package/dist/core.d.ts +23 -0
- package/dist/core.js +8 -0
- package/dist/custom-components/__tests__/for.test.d.ts +1 -0
- package/dist/custom-components/__tests__/show.test.d.ts +1 -0
- package/dist/custom-components/for.d.ts +58 -0
- package/dist/custom-components/for.js +313 -0
- package/dist/custom-components/index.d.ts +2 -0
- package/dist/custom-components/show.d.ts +78 -0
- package/dist/custom-components/show.js +88 -0
- package/dist/data-management/cache/cache-invalidate.decorator.d.ts +35 -0
- package/dist/data-management/cache/cache-invalidate.decorator.js +21 -0
- package/dist/data-management/cache/cache-metadata.d.ts +15 -0
- package/dist/data-management/cache/cache-provider.interface.d.ts +67 -0
- package/dist/data-management/cache/cache-tags.decorator.d.ts +52 -0
- package/dist/data-management/cache/cache-tags.decorator.js +13 -0
- package/dist/data-management/cache/cache-update.decorator.d.ts +28 -0
- package/dist/data-management/cache/cache-update.decorator.js +21 -0
- package/dist/data-management/cache/cache.decorator.d.ts +28 -0
- package/dist/data-management/cache/cache.decorator.js +13 -0
- package/dist/data-management/cache/index.d.ts +11 -0
- package/dist/data-management/cache/local-storage-cache.d.ts +40 -0
- package/dist/data-management/cache/local-storage-cache.js +268 -0
- package/dist/data-management/cache/memory-cache.d.ts +37 -0
- package/dist/data-management/cache/memory-cache.js +149 -0
- package/dist/data-management/cache/session-storage-cache.d.ts +35 -0
- package/dist/data-management/cache/session-storage-cache.js +242 -0
- package/dist/data-management/cache/ttl.decorator.d.ts +31 -0
- package/dist/data-management/cache/ttl.decorator.js +34 -0
- package/dist/data-management/decorators/consume.d.ts +29 -0
- package/dist/data-management/decorators/consume.js +28 -0
- package/dist/data-management/decorators/id.d.ts +28 -0
- package/dist/data-management/decorators/id.js +19 -0
- package/dist/data-management/decorators/model.d.ts +48 -0
- package/dist/data-management/decorators/model.js +24 -0
- package/dist/data-management/decorators/prop.d.ts +43 -0
- package/dist/data-management/decorators/prop.js +32 -0
- package/dist/data-management/index.d.ts +13 -0
- package/dist/data-management/store/json-to-model.d.ts +45 -0
- package/dist/data-management/store/json-to-model.js +36 -0
- package/dist/data-management/store/store.d.ts +108 -0
- package/dist/data-management/store/store.js +207 -0
- package/dist/data-management/store/types.d.ts +53 -0
- package/dist/events-handler/decorators/emit.d.ts +29 -0
- package/dist/events-handler/decorators/emit.js +51 -0
- package/dist/events-handler/event-decorators.d.ts +1 -0
- package/dist/events-handler/event-emitter.service.d.ts +21 -0
- package/dist/events-handler/event-emitter.service.js +85 -0
- package/dist/events-handler/event-types.d.ts +12 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.js +121 -0
- package/dist/jsx/dynamic/__tests__/granular-array-renderer.test.d.ts +1 -0
- package/dist/jsx/dynamic/__tests__/jsx-array-rendering.test.d.ts +1 -0
- package/dist/jsx/dynamic/array-renderer.d.ts +2 -0
- package/dist/jsx/dynamic/array-renderer.js +133 -0
- package/dist/jsx/dynamic/child-renderer.d.ts +1 -0
- package/dist/jsx/dynamic/child-renderer.js +180 -0
- package/dist/jsx/dynamic/dom-utils.d.ts +5 -0
- package/dist/jsx/dynamic/dom-utils.js +22 -0
- package/dist/jsx/dynamic/granular-array-renderer.d.ts +16 -0
- package/dist/jsx/dynamic/granular-array-renderer.js +153 -0
- package/dist/jsx/dynamic/node-renderer.d.ts +2 -0
- package/dist/jsx/dynamic/props-handler.d.ts +3 -0
- package/dist/jsx/dynamic/props-handler.js +281 -0
- package/dist/jsx/dynamic/text-renderer.d.ts +2 -0
- package/dist/jsx/jsx-dev-runtime.d.ts +2 -0
- package/dist/jsx/jsx-runtime.d.ts +3 -0
- package/dist/jsx/types.d.ts +35 -0
- package/dist/jsx/types.js +4 -0
- package/dist/jsx-dev-runtime.d.ts +2 -0
- package/dist/jsx-dev-runtime.js +8 -0
- package/dist/jsx-runtime.d.ts +2 -0
- package/dist/jsx-runtime.js +11 -0
- package/dist/reactivity/__tests__/context-stack.test.d.ts +1 -0
- package/dist/reactivity/__tests__/nested-effects-untrack.test.d.ts +22 -0
- package/dist/reactivity/context-scope.d.ts +57 -0
- package/dist/reactivity/context-scope.js +35 -0
- package/dist/reactivity/decorators/__tests__/ctx-integration.test.d.ts +5 -0
- package/dist/reactivity/decorators/__tests__/ctx-loop.test.d.ts +10 -0
- package/dist/reactivity/decorators/__tests__/state-intelligent.test.d.ts +1 -0
- package/dist/reactivity/decorators/computed.d.ts +6 -0
- package/dist/reactivity/decorators/computed.js +17 -0
- package/dist/reactivity/decorators/create-event-decorator.d.ts +5 -0
- package/dist/reactivity/decorators/create-event-decorator.js +28 -0
- package/dist/reactivity/decorators/ctx.d.ts +9 -0
- package/dist/reactivity/decorators/ctx.js +91 -0
- package/dist/reactivity/decorators/effect.d.ts +9 -0
- package/dist/reactivity/decorators/effect.js +24 -0
- package/dist/reactivity/decorators/resource.d.ts +48 -0
- package/dist/reactivity/decorators/resource.js +20 -0
- package/dist/reactivity/decorators/state.d.ts +8 -0
- package/dist/reactivity/decorators/state.js +68 -0
- package/dist/reactivity/decorators/store.d.ts +6 -0
- package/dist/reactivity/decorators/store.js +25 -0
- package/dist/reactivity/phase-scheduler.d.ts +81 -0
- package/dist/reactivity/phase-scheduler.js +88 -0
- package/dist/reactivity/phase-scheduler.test.d.ts +1 -0
- package/dist/reactivity/reactive-cache.d.ts +21 -0
- package/dist/reactivity/reactive-cache.js +31 -0
- package/dist/reactivity/reactive-cache.test.d.ts +1 -0
- package/dist/reactivity/reactive-context.d.ts +152 -0
- package/dist/reactivity/reactive-context.js +184 -0
- package/dist/reactivity/signals/__tests__/composicion-automatica.test.d.ts +1 -0
- package/dist/reactivity/signals/__tests__/composite/nivel-1-estructura-basica.test.d.ts +1 -0
- package/dist/reactivity/signals/__tests__/composite/nivel-2-registro-subscribers.test.d.ts +1 -0
- package/dist/reactivity/signals/__tests__/composite/nivel-3-notificaciones-basicas.test.d.ts +1 -0
- package/dist/reactivity/signals/__tests__/composite/nivel-4-comparacion-valores.test.d.ts +1 -0
- package/dist/reactivity/signals/__tests__/composite/nivel-5-tracking-automatico.test.d.ts +1 -0
- package/dist/reactivity/signals/__tests__/composite/nivel-6-anti-glitch.test.d.ts +1 -0
- package/dist/reactivity/signals/__tests__/composite/nivel-7-objetos-anidados.test.d.ts +1 -0
- package/dist/reactivity/signals/__tests__/composite/nivel-8-observable-array-support.test.d.ts +1 -0
- package/dist/reactivity/signals/__tests__/composite-shallow-tracking.test.d.ts +1 -0
- package/dist/reactivity/signals/__tests__/effect.test.d.ts +1 -0
- package/dist/reactivity/signals/__tests__/reactive-array/nivel-1-estructura-basica.test.d.ts +1 -0
- package/dist/reactivity/signals/__tests__/reactive-array/nivel-2-metodos-mutadores.test.d.ts +1 -0
- package/dist/reactivity/signals/__tests__/reactive-array/nivel-3-tracking-por-indice.test.d.ts +1 -0
- package/dist/reactivity/signals/__tests__/reactive-array/nivel-4-tracking-length.test.d.ts +1 -0
- package/dist/reactivity/signals/__tests__/reactive-array/nivel-5-tracking-mutation.test.d.ts +1 -0
- package/dist/reactivity/signals/__tests__/reactive-array/nivel-6-metodos-no-mutadores.test.d.ts +1 -0
- package/dist/reactivity/signals/__tests__/reactive-array/nivel-7-composicion-bidireccional.test.d.ts +1 -0
- package/dist/reactivity/signals/__tests__/reactive-array/nivel-8-proxies.test.d.ts +1 -0
- package/dist/reactivity/signals/__tests__/reactive-array/nivel-9-derived-cache-optimization.test.d.ts +1 -0
- package/dist/reactivity/signals/__tests__/resource.test.d.ts +1 -0
- package/dist/reactivity/signals/__tests__/signal.test.d.ts +1 -0
- package/dist/reactivity/signals/array-strategies.d.ts +120 -0
- package/dist/reactivity/signals/array-strategies.js +261 -0
- package/dist/reactivity/signals/composite.d.ts +89 -0
- package/dist/reactivity/signals/composite.js +145 -0
- package/dist/reactivity/signals/computed.d.ts +61 -0
- package/dist/reactivity/signals/computed.js +107 -0
- package/dist/reactivity/signals/computed.test.d.ts +1 -0
- package/dist/reactivity/signals/derived.d.ts +10 -0
- package/dist/reactivity/signals/derived.js +24 -0
- package/dist/reactivity/signals/effect.d.ts +27 -0
- package/dist/reactivity/signals/effect.js +46 -0
- package/dist/reactivity/signals/event.d.ts +9 -0
- package/dist/reactivity/signals/event.js +15 -0
- package/dist/reactivity/signals/reactive-array.d.ts +133 -0
- package/dist/reactivity/signals/reactive-array.js +490 -0
- package/dist/reactivity/signals/reactive-proxy.d.ts +54 -0
- package/dist/reactivity/signals/reactive-proxy.js +299 -0
- package/dist/reactivity/signals/reactive-tracking.test.d.ts +1 -0
- package/dist/reactivity/signals/resource.d.ts +9 -0
- package/dist/reactivity/signals/resource.js +58 -0
- package/dist/reactivity/signals/signal.d.ts +39 -0
- package/dist/reactivity/signals/signal.js +56 -0
- package/dist/reactivity/signals/subscription-management.test.d.ts +1 -0
- package/dist/reactivity/types.d.ts +12 -0
- package/dist/router/__tests__/link-behavior-active-class.test.d.ts +1 -0
- package/dist/router/__tests__/loop-detector.test.d.ts +1 -0
- package/dist/router/__tests__/params-container-resolution.test.d.ts +1 -0
- package/dist/router/__tests__/router-generated-routes.test.d.ts +1 -0
- package/dist/router/__tests__/router-params-granular.test.d.ts +1 -0
- package/dist/router/__tests__/router-params-simple.test.d.ts +1 -0
- package/dist/router/__tests__/router-query-params.test.d.ts +1 -0
- package/dist/router/__tests__/router-route-candidates.test.d.ts +1 -0
- package/dist/router/__tests__/routeview-app-articles.test.d.ts +1 -0
- package/dist/router/__tests__/routeview-debug.test.d.ts +1 -0
- package/dist/router/__tests__/routeview-integration.test.d.ts +1 -0
- package/dist/router/__tests__/routeview-this.test.d.ts +1 -0
- package/dist/router/decorators/base-policy.d.ts +141 -0
- package/dist/router/decorators/base-policy.js +63 -0
- package/dist/router/decorators/index.d.ts +6 -0
- package/dist/router/decorators/params.d.ts +31 -0
- package/dist/router/decorators/params.js +97 -0
- package/dist/router/decorators/route-metadata.d.ts +11 -0
- package/dist/router/decorators/route-metadata.js +23 -0
- package/dist/router/decorators/route.d.ts +39 -0
- package/dist/router/decorators/route.js +7 -0
- package/dist/router/link.behavior.d.ts +87 -0
- package/dist/router/link.behavior.js +227 -0
- package/dist/router/policy-evaluator.d.ts +81 -0
- package/dist/router/policy-evaluator.js +209 -0
- package/dist/router/route-view.d.ts +56 -0
- package/dist/router/route-view.js +156 -0
- package/dist/router/router.d.ts +67 -0
- package/dist/router/router.js +308 -0
- package/dist/router/static-analysis/index.d.ts +37 -0
- package/dist/router/static-analysis/parser.d.ts +14 -0
- package/dist/router/static-analysis/parser.js +147 -0
- package/dist/router/static-analysis/scanner.d.ts +27 -0
- package/dist/router/static-analysis/scanner.js +91 -0
- package/dist/router/trie.d.ts +14 -0
- package/dist/router/trie.js +126 -0
- package/dist/router/trie.types.d.ts +36 -0
- package/dist/styles/base-style-sheet.d.ts +96 -0
- package/dist/styles/base-style-sheet.js +149 -0
- package/dist/styles/decorators/factories.d.ts +76 -0
- package/dist/styles/decorators/factories.js +11 -0
- package/dist/styles/decorators/keyframes.d.ts +238 -0
- package/dist/styles/decorators/keyframes.js +79 -0
- package/dist/styles/decorators/rule.d.ts +177 -0
- package/dist/styles/decorators/rule.js +72 -0
- package/dist/styles/decorators/scope.d.ts +66 -0
- package/dist/styles/decorators/scope.js +17 -0
- package/dist/styles/decorators/style.d.ts +1 -0
- package/dist/styles/decorators/style.js +20 -0
- package/dist/styles/decorators/useStyles.d.ts +5 -0
- package/dist/styles/decorators/useStyles.js +29 -0
- package/dist/styles/global-styles-registry.d.ts +72 -0
- package/dist/styles/global-styles-registry.js +155 -0
- package/dist/types.d.ts +1 -0
- package/dist/vite-plugins/__tests__/jsx-control-flow-transform.test.d.ts +1 -0
- package/dist/vite-plugins/index.d.ts +4 -0
- package/dist/vite-plugins/index.js +10 -0
- package/dist/vite-plugins/jsx-contextual.d.ts +7 -0
- package/dist/vite-plugins/jsx-contextual.js +53 -0
- package/dist/vite-plugins/jsx-control-flow-transform.d.ts +60 -0
- package/dist/vite-plugins/jsx-control-flow-transform.js +180 -0
- package/dist/vite-plugins/jsx-signals.d.ts +2 -0
- package/dist/vite-plugins/jsx-signals.js +124 -0
- package/dist/vite-plugins/router/route-generator-plugin.d.ts +63 -0
- package/dist/vite-plugins/router/route-generator-plugin.js +310 -0
- package/package.json +85 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @Behavior class decorator.
|
|
3
|
+
*
|
|
4
|
+
* Marks a class as a Behavior and registers it in the BehaviorRegistry.
|
|
5
|
+
* The class should have at least one @Prop decorated field that serves as
|
|
6
|
+
* the activator (a boolean prop that enables the behavior).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* @Behavior
|
|
10
|
+
* export class Link {
|
|
11
|
+
* @Host
|
|
12
|
+
* el!: HTMLAnchorElement;
|
|
13
|
+
*
|
|
14
|
+
* @Prop link: boolean = true; // Activator
|
|
15
|
+
* @Prop href: string = ''; // Config
|
|
16
|
+
* @Prop activeClass?: string; // Optional config
|
|
17
|
+
*
|
|
18
|
+
* onInit() {
|
|
19
|
+
* this.el.href = this.href;
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* // Usage in JSX:
|
|
24
|
+
* <a link href="/home" activeClass="active">Home</a>
|
|
25
|
+
*/
|
|
26
|
+
export declare function Behavior<T extends new (...args: any[]) => any>(target: T, context: ClassDecoratorContext): T;
|
|
27
|
+
/**
|
|
28
|
+
* @Host field decorator.
|
|
29
|
+
*
|
|
30
|
+
* Marks a field to receive the host element. Works with both:
|
|
31
|
+
* - Behaviors: BehaviorManager injects the DOM element before calling onInit()
|
|
32
|
+
* - StyleSheets: BaseStyleSheet injects the component via setHost()
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // In a Behavior:
|
|
36
|
+
* @Behavior
|
|
37
|
+
* class Tooltip {
|
|
38
|
+
* @Host
|
|
39
|
+
* el!: HTMLElement;
|
|
40
|
+
*
|
|
41
|
+
* onInit() {
|
|
42
|
+
* console.log('Attached to:', this.el.tagName);
|
|
43
|
+
* }
|
|
44
|
+
* }
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* // In a StyleSheet:
|
|
48
|
+
* class MyStyles extends BaseStyleSheet {
|
|
49
|
+
* @Host
|
|
50
|
+
* host!: BaseComponent;
|
|
51
|
+
*
|
|
52
|
+
* @Rule(':host')
|
|
53
|
+
* get hostRule() {
|
|
54
|
+
* return { display: 'block' };
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
*/
|
|
58
|
+
export declare function Host<T = Element>(target: undefined, context: ClassFieldDecoratorContext<any, T>): (this: any, initialValue: T) => T;
|
|
59
|
+
/**
|
|
60
|
+
* @ComponentHost field decorator.
|
|
61
|
+
*
|
|
62
|
+
* Marks a field to receive the host component that contains this behavior.
|
|
63
|
+
* Allows behaviors to access the context (@Ctx) of the component.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* @Behavior
|
|
67
|
+
* class Link {
|
|
68
|
+
* @Host
|
|
69
|
+
* el!: HTMLAnchorElement; // DOM element
|
|
70
|
+
*
|
|
71
|
+
* @ComponentHost
|
|
72
|
+
* hostComponent?: BaseComponent; // Component container
|
|
73
|
+
*
|
|
74
|
+
* @Inject(Router)
|
|
75
|
+
* router!: Router;
|
|
76
|
+
*
|
|
77
|
+
* onInit() {
|
|
78
|
+
* // Access component context
|
|
79
|
+
* const basePath = (this.hostComponent as any).routeBasePath;
|
|
80
|
+
* // Use basePath for route resolution...
|
|
81
|
+
* }
|
|
82
|
+
* }
|
|
83
|
+
*
|
|
84
|
+
* // Usage in JSX (no changes needed):
|
|
85
|
+
* <a link href="sales" activeClass="active">Sales</a>
|
|
86
|
+
*/
|
|
87
|
+
export declare function ComponentHost<T = any>(target: undefined, context: ClassFieldDecoratorContext<any, T>): (this: any, initialValue: T) => T;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { BehaviorRegistry } from "./behavior-registry.js";
|
|
2
|
+
import { BEHAVIOR_PROPS, HOST_KEY, COMPONENT_HOST_KEY } from "./constants.js";
|
|
3
|
+
function Behavior(target, context) {
|
|
4
|
+
const metadata = context.metadata;
|
|
5
|
+
const props = metadata[BEHAVIOR_PROPS];
|
|
6
|
+
const hostField = metadata[HOST_KEY];
|
|
7
|
+
if (props) {
|
|
8
|
+
target[BEHAVIOR_PROPS] = props;
|
|
9
|
+
}
|
|
10
|
+
if (hostField) {
|
|
11
|
+
target[HOST_KEY] = hostField;
|
|
12
|
+
}
|
|
13
|
+
BehaviorRegistry.register(target);
|
|
14
|
+
return target;
|
|
15
|
+
}
|
|
16
|
+
function Host(target, context) {
|
|
17
|
+
if (context.kind !== "field") {
|
|
18
|
+
throw new Error("@Host can only be applied to class fields.");
|
|
19
|
+
}
|
|
20
|
+
const metadata = context.metadata;
|
|
21
|
+
metadata[HOST_KEY] = context.name;
|
|
22
|
+
context.addInitializer(function() {
|
|
23
|
+
this.constructor[HOST_KEY] = context.name;
|
|
24
|
+
});
|
|
25
|
+
return function(initialValue) {
|
|
26
|
+
return initialValue;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function ComponentHost(target, context) {
|
|
30
|
+
if (context.kind !== "field") {
|
|
31
|
+
throw new Error("@ComponentHost can only be applied to class fields.");
|
|
32
|
+
}
|
|
33
|
+
const metadata = context.metadata;
|
|
34
|
+
metadata[COMPONENT_HOST_KEY] = context.name;
|
|
35
|
+
context.addInitializer(function() {
|
|
36
|
+
this.constructor[COMPONENT_HOST_KEY] = context.name;
|
|
37
|
+
});
|
|
38
|
+
return function(initialValue) {
|
|
39
|
+
return initialValue;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
Behavior,
|
|
44
|
+
ComponentHost,
|
|
45
|
+
Host
|
|
46
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { BaseComponent } from './base-component';
|
|
2
|
+
import { Constructor } from '../DI/types';
|
|
3
|
+
import { ComponentMetadata, INode } from './types';
|
|
4
|
+
import { ISignal } from '../reactivity/signals/signal';
|
|
5
|
+
import { ScopedContainer } from '../DI/scoped-container';
|
|
6
|
+
export declare class AppTree {
|
|
7
|
+
private static metadataRegistry;
|
|
8
|
+
private static nodes;
|
|
9
|
+
private static root;
|
|
10
|
+
/**
|
|
11
|
+
* Registra la metadata de una clase de Componente.
|
|
12
|
+
* Se llama desde el decorador @Component.
|
|
13
|
+
*/
|
|
14
|
+
static registerMetadata(metadata: ComponentMetadata): void;
|
|
15
|
+
/**
|
|
16
|
+
* Obtiene la metadata para una clase de componente específica.
|
|
17
|
+
*/
|
|
18
|
+
static getMetadata(componentClass: Constructor<BaseComponent>): ComponentMetadata | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Registra una instancia de componente en el árbol jerárquico.
|
|
21
|
+
* Se llama desde connectedCallback.
|
|
22
|
+
*/
|
|
23
|
+
static registerInstance(instance: BaseComponent, parent?: INode): INode;
|
|
24
|
+
/**
|
|
25
|
+
* Elimina una instancia del árbol jerárquico.
|
|
26
|
+
* Se llama desde disconnectedCallback.
|
|
27
|
+
*/
|
|
28
|
+
static unregisterInstance(node: INode): void;
|
|
29
|
+
static getRoot(): INode | null;
|
|
30
|
+
static findByTag(tagName: string): INode[];
|
|
31
|
+
static findByInstance(instance: BaseComponent): INode | undefined;
|
|
32
|
+
static getParentFor(instance: BaseComponent): INode | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Busca recursivamente hacia arriba desde un nodo inicial una propiedad
|
|
35
|
+
* que represente una señal de contexto (ej: "$level").
|
|
36
|
+
* @param signalPropName El nombre de la propiedad de la señal (ej: "$level").
|
|
37
|
+
* @param startNode El nodo desde el cual comenzar la búsqueda hacia arriba.
|
|
38
|
+
* @returns La señal encontrada o undefined.
|
|
39
|
+
*/
|
|
40
|
+
static findContextSignalFor(signalPropName: string, startNode: INode | undefined): ISignal<any> | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Busca recursivamente hacia arriba desde un nodo inicial el
|
|
43
|
+
* ScopedContainer más cercano en la jerarquía de componentes.
|
|
44
|
+
*
|
|
45
|
+
* Sigue el mismo patrón que findContextSignalFor:
|
|
46
|
+
* sube por el árbol buscando un nodo que tenga un container.
|
|
47
|
+
*/
|
|
48
|
+
static findContainerFor(startNode: INode | undefined): ScopedContainer | undefined;
|
|
49
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { isSignal } from "../reactivity/signals/signal.js";
|
|
2
|
+
const _AppTree = class _AppTree {
|
|
3
|
+
// --- MÉTODOS PARA GESTIONAR METADATA ---
|
|
4
|
+
/**
|
|
5
|
+
* Registra la metadata de una clase de Componente.
|
|
6
|
+
* Se llama desde el decorador @Component.
|
|
7
|
+
*/
|
|
8
|
+
static registerMetadata(metadata) {
|
|
9
|
+
this.metadataRegistry.set(metadata.componentClass, metadata);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Obtiene la metadata para una clase de componente específica.
|
|
13
|
+
*/
|
|
14
|
+
// CAMBIO: El método ahora espera una clase (Constructor) en lugar de un tagName (string).
|
|
15
|
+
static getMetadata(componentClass) {
|
|
16
|
+
return this.metadataRegistry.get(componentClass);
|
|
17
|
+
}
|
|
18
|
+
// --- MÉTODOS PARA GESTIONAR INSTANCIAS ---
|
|
19
|
+
/**
|
|
20
|
+
* Registra una instancia de componente en el árbol jerárquico.
|
|
21
|
+
* Se llama desde connectedCallback.
|
|
22
|
+
*/
|
|
23
|
+
static registerInstance(instance, parent) {
|
|
24
|
+
const metadata = this.getMetadata(
|
|
25
|
+
instance.constructor
|
|
26
|
+
);
|
|
27
|
+
if (!metadata) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
// El mensaje de error es más preciso ahora.
|
|
30
|
+
`Intentando instanciar <${instance.tagName}> pero sus metadatos no fueron registrados. ¿Olvidaste el decorador @Component en la clase ${instance.constructor.name}?`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
const node = {
|
|
34
|
+
id: crypto.randomUUID(),
|
|
35
|
+
metadata,
|
|
36
|
+
instance,
|
|
37
|
+
parent,
|
|
38
|
+
children: []
|
|
39
|
+
};
|
|
40
|
+
this.nodes.set(node.id, node);
|
|
41
|
+
if (parent) {
|
|
42
|
+
parent.children.push(node);
|
|
43
|
+
} else {
|
|
44
|
+
this.root = node;
|
|
45
|
+
}
|
|
46
|
+
return node;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Elimina una instancia del árbol jerárquico.
|
|
50
|
+
* Se llama desde disconnectedCallback.
|
|
51
|
+
*/
|
|
52
|
+
static unregisterInstance(node) {
|
|
53
|
+
if (node.parent) {
|
|
54
|
+
node.parent.children = node.parent.children.filter((c) => c !== node);
|
|
55
|
+
} else if (this.root === node) {
|
|
56
|
+
this.root = null;
|
|
57
|
+
}
|
|
58
|
+
this.nodes.delete(node.id);
|
|
59
|
+
}
|
|
60
|
+
// --- MÉTODOS DE BÚSQUEDA (sin cambios, siguen siendo útiles) ---
|
|
61
|
+
static getRoot() {
|
|
62
|
+
return this.root;
|
|
63
|
+
}
|
|
64
|
+
static findByTag(tagName) {
|
|
65
|
+
const lowerCaseTag = tagName.toLowerCase();
|
|
66
|
+
return [...this.nodes.values()].filter(
|
|
67
|
+
(n) => n.metadata.tagName.toLowerCase() === lowerCaseTag
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
static findByInstance(instance) {
|
|
71
|
+
return [...this.nodes.values()].find((n) => n.instance === instance);
|
|
72
|
+
}
|
|
73
|
+
static getParentFor(instance) {
|
|
74
|
+
const node = this.findByInstance(instance);
|
|
75
|
+
return node ? node.parent : void 0;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Busca recursivamente hacia arriba desde un nodo inicial una propiedad
|
|
79
|
+
* que represente una señal de contexto (ej: "$level").
|
|
80
|
+
* @param signalPropName El nombre de la propiedad de la señal (ej: "$level").
|
|
81
|
+
* @param startNode El nodo desde el cual comenzar la búsqueda hacia arriba.
|
|
82
|
+
* @returns La señal encontrada o undefined.
|
|
83
|
+
*/
|
|
84
|
+
static findContextSignalFor(signalPropName, startNode) {
|
|
85
|
+
let currentNode = startNode;
|
|
86
|
+
while (currentNode) {
|
|
87
|
+
const instance = currentNode.instance;
|
|
88
|
+
if (instance && signalPropName in instance) {
|
|
89
|
+
const potentialSignal = instance[signalPropName];
|
|
90
|
+
if (isSignal(potentialSignal)) {
|
|
91
|
+
return potentialSignal;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
currentNode = currentNode.parent;
|
|
95
|
+
}
|
|
96
|
+
return void 0;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Busca recursivamente hacia arriba desde un nodo inicial el
|
|
100
|
+
* ScopedContainer más cercano en la jerarquía de componentes.
|
|
101
|
+
*
|
|
102
|
+
* Sigue el mismo patrón que findContextSignalFor:
|
|
103
|
+
* sube por el árbol buscando un nodo que tenga un container.
|
|
104
|
+
*/
|
|
105
|
+
static findContainerFor(startNode) {
|
|
106
|
+
let currentNode = startNode;
|
|
107
|
+
while (currentNode) {
|
|
108
|
+
if (currentNode.container) {
|
|
109
|
+
return currentNode.container;
|
|
110
|
+
}
|
|
111
|
+
currentNode = currentNode.parent;
|
|
112
|
+
}
|
|
113
|
+
return void 0;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
_AppTree.metadataRegistry = /* @__PURE__ */ new Map();
|
|
117
|
+
_AppTree.nodes = /* @__PURE__ */ new Map();
|
|
118
|
+
_AppTree.root = null;
|
|
119
|
+
let AppTree = _AppTree;
|
|
120
|
+
export {
|
|
121
|
+
AppTree
|
|
122
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { INode } from './types';
|
|
2
|
+
import { BehaviorManager } from '../behaviors/behavior-manager';
|
|
3
|
+
export declare class BaseComponent extends HTMLElement {
|
|
4
|
+
#private;
|
|
5
|
+
protected appNode?: INode;
|
|
6
|
+
protected _pendingContextInitializers?: (() => void)[];
|
|
7
|
+
_pendingEffects?: (() => void)[];
|
|
8
|
+
protected behaviorManager: BehaviorManager;
|
|
9
|
+
constructor();
|
|
10
|
+
/**
|
|
11
|
+
* Obtiene el root donde se renderizan los elementos.
|
|
12
|
+
* Puede ser shadowRoot o el elemento mismo si no usa shadow DOM.
|
|
13
|
+
*/
|
|
14
|
+
protected get renderRoot(): HTMLElement | ShadowRoot;
|
|
15
|
+
/**
|
|
16
|
+
* Registra un efecto pendiente que se ejecutará después de la inicialización
|
|
17
|
+
* Usado por el decorador @Effect para diferir la ejecución
|
|
18
|
+
*/
|
|
19
|
+
queueEffect(effectFn: () => void): void;
|
|
20
|
+
/**
|
|
21
|
+
* Ejecuta todos los efectos pendientes
|
|
22
|
+
* Se llama al final de initializeForJSX()
|
|
23
|
+
*/
|
|
24
|
+
private flushPendingEffects;
|
|
25
|
+
initializeForJSX(): void;
|
|
26
|
+
connectedCallback(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Bootstrap services declared in @Component({ services: [...] })
|
|
29
|
+
* for a given node. Creates a ScopedContainer with parent chain resolution.
|
|
30
|
+
* Used by both init() (DOM path) and createAndRenderComponent() (JSX path).
|
|
31
|
+
*/
|
|
32
|
+
private static bootstrapServicesForNode;
|
|
33
|
+
/**
|
|
34
|
+
* Assign __container to a component instance.
|
|
35
|
+
* Uses the node's own container if it has one, otherwise walks up the tree.
|
|
36
|
+
*/
|
|
37
|
+
private static assignContainer;
|
|
38
|
+
/**
|
|
39
|
+
* Proceso de inicialización asíncrona del componente
|
|
40
|
+
* Incluye renderizado progresivo
|
|
41
|
+
*/
|
|
42
|
+
private init;
|
|
43
|
+
/**
|
|
44
|
+
* Renderiza un estado de error si la inicialización falla
|
|
45
|
+
*/
|
|
46
|
+
private renderError;
|
|
47
|
+
/**
|
|
48
|
+
* Encuentra el nodo padre de este componente en el AppTree.
|
|
49
|
+
*/
|
|
50
|
+
private findParentNode;
|
|
51
|
+
disconnectedCallback(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Registra las stylesheets @Shared si este componente las declara.
|
|
54
|
+
*/
|
|
55
|
+
private registerSharedStylesheetsIfNeeded;
|
|
56
|
+
/**
|
|
57
|
+
* Registra las stylesheets @ForDocument si este componente las declara.
|
|
58
|
+
*/
|
|
59
|
+
private registerDocumentStylesIfNeeded;
|
|
60
|
+
/**
|
|
61
|
+
* Adopta todas las stylesheets @Shared registradas en el shadow root.
|
|
62
|
+
*/
|
|
63
|
+
private adoptSharedStylesheets;
|
|
64
|
+
/**
|
|
65
|
+
* Adopta las stylesheets LOCALES de este componente específico.
|
|
66
|
+
*/
|
|
67
|
+
private adoptLocalStylesheet;
|
|
68
|
+
private initializeContexts;
|
|
69
|
+
private initializeResources;
|
|
70
|
+
jsx(type: any, props: any): any;
|
|
71
|
+
jsxDEV(type: any, props: any): any;
|
|
72
|
+
jsxs(type: any, props: any): any;
|
|
73
|
+
/**
|
|
74
|
+
* Aplica className al host element del componente.
|
|
75
|
+
*/
|
|
76
|
+
private applyClassNameToHost;
|
|
77
|
+
/**
|
|
78
|
+
* Establece las clases CSS en el host element.
|
|
79
|
+
*/
|
|
80
|
+
private setHostClassName;
|
|
81
|
+
private createAndRenderComponent;
|
|
82
|
+
private createNativeElement;
|
|
83
|
+
private normalizeChildren;
|
|
84
|
+
private convertClassNameToTagName;
|
|
85
|
+
}
|