@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.
@@ -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, vnode);
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, vnode) {
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.addProvider({
2878
- provide: ComponentClass,
2879
- useClass: ComponentClass,
2880
- scope: "transient"
2881
- });
2882
- [...params].forEach((p) => injector.addProvider(p));
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 componentInstance = injector.resolve(ComponentClass);
2886
- componentInstance.__injector = injector;
2887
- componentInstance.props = cleanProps;
2888
- if (typeof componentInstance.build === "function") {
2889
- const rendered = componentInstance.build();
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) || [];