@kithinji/orca 1.0.3 → 1.0.5
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/dist/browser/index.iife.js +30 -22
- package/dist/browser/index.iife.js.map +3 -3
- package/dist/browser/index.mjs +30 -22
- package/dist/browser/index.mjs.map +3 -3
- package/dist/node/index.cjs +30 -21
- package/dist/node/index.cjs.map +3 -3
- package/dist/node/index.mjs +30 -21
- package/dist/node/index.mjs.map +3 -3
- package/dist/types/browser/dom/dom.d.ts.map +1 -1
- package/dist/types/shared/dom/osc.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.mjs
CHANGED
|
@@ -2737,7 +2737,7 @@ var OSC = class {
|
|
|
2737
2737
|
vnode.setId(jsx2.id);
|
|
2738
2738
|
}
|
|
2739
2739
|
parent.addChild(vnode);
|
|
2740
|
-
this.loadClientComponent(path, name, jsx2.props, container
|
|
2740
|
+
this.loadClientComponent(path, name, jsx2.props, container);
|
|
2741
2741
|
return { domNode: container, vnode };
|
|
2742
2742
|
}
|
|
2743
2743
|
buildPendingReference(jsx2, parent) {
|
|
@@ -2862,35 +2862,44 @@ var OSC = class {
|
|
|
2862
2862
|
dom.removeAttribute(key);
|
|
2863
2863
|
}
|
|
2864
2864
|
}
|
|
2865
|
-
async loadClientComponent(path, name, props, container
|
|
2865
|
+
async loadClientComponent(path, name, props, container) {
|
|
2866
2866
|
try {
|
|
2867
|
+
let register2 = function(Cls, injector2) {
|
|
2868
|
+
if (seen.has(Cls))
|
|
2869
|
+
return;
|
|
2870
|
+
seen.add(Cls);
|
|
2871
|
+
injector2.addProvider({
|
|
2872
|
+
provide: Cls,
|
|
2873
|
+
useClass: Cls,
|
|
2874
|
+
scope: "transient"
|
|
2875
|
+
});
|
|
2876
|
+
const paramDeps = Reflect.getMetadata(DESIGN_PARAMTYPES, Cls) ?? [];
|
|
2877
|
+
const explicitDeps = Reflect.getMetadata(COMPONENT_DEPS, Cls) ?? [];
|
|
2878
|
+
paramDeps.filter((d) => d && d !== Object).forEach((d) => injector2.addProvider(d));
|
|
2879
|
+
explicitDeps.forEach((deps) => register2(deps, injector2));
|
|
2880
|
+
};
|
|
2881
|
+
var register = register2;
|
|
2867
2882
|
const module = await import(path);
|
|
2868
2883
|
const ComponentClass = module[name];
|
|
2869
|
-
const params = Reflect.getMetadata(DESIGN_PARAMTYPES, ComponentClass) || [];
|
|
2870
|
-
const injector = getCurrentInjector();
|
|
2871
|
-
if (injector == null) {
|
|
2872
|
-
throw new Error(`Couldn't find an injector`);
|
|
2873
|
-
}
|
|
2874
2884
|
if (!ComponentClass) {
|
|
2875
2885
|
throw new Error(`Component ${name} not found in ${path}`);
|
|
2876
2886
|
}
|
|
2877
|
-
injector
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2887
|
+
const injector = getCurrentInjector();
|
|
2888
|
+
if (injector == null) {
|
|
2889
|
+
throw new Error("Couldn't find an injector");
|
|
2890
|
+
}
|
|
2891
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2892
|
+
register2(ComponentClass, injector);
|
|
2883
2893
|
const cleanProps = { ...props };
|
|
2884
2894
|
delete cleanProps.__clientComponent;
|
|
2885
|
-
const
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
if (typeof
|
|
2889
|
-
|
|
2890
|
-
container.parentNode?.replaceChild(rendered, container);
|
|
2891
|
-
} else {
|
|
2892
|
-
throw new Error(`Component ${name} does not have a build method`);
|
|
2895
|
+
const instance = injector.resolve(ComponentClass);
|
|
2896
|
+
instance.__injector = injector;
|
|
2897
|
+
instance.props = cleanProps;
|
|
2898
|
+
if (typeof instance.build !== "function") {
|
|
2899
|
+
throw new Error(`Component ${name} does not implement build()`);
|
|
2893
2900
|
}
|
|
2901
|
+
const rendered = instance.build();
|
|
2902
|
+
container.replaceWith(rendered);
|
|
2894
2903
|
} catch (error) {
|
|
2895
2904
|
console.error(`Failed to load client component ${name}:`, error);
|
|
2896
2905
|
container.textContent = `Error loading component: ${name}`;
|
|
@@ -3082,7 +3091,6 @@ function createComponent(ComponentClass, props = {}, parentComponent) {
|
|
|
3082
3091
|
try {
|
|
3083
3092
|
instance = injector.resolve(ComponentClass);
|
|
3084
3093
|
} catch (e) {
|
|
3085
|
-
console.log(e);
|
|
3086
3094
|
throw new Error(e.message);
|
|
3087
3095
|
}
|
|
3088
3096
|
const localProviders = Reflect.getMetadata(COMPONENT_PROVIDERS, ComponentClass) || [];
|