@kithinji/orca 1.0.4 → 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 -29
- package/dist/browser/index.iife.js.map +3 -3
- package/dist/browser/index.mjs +30 -29
- package/dist/browser/index.mjs.map +3 -3
- package/dist/node/index.cjs +30 -29
- package/dist/node/index.cjs.map +3 -3
- package/dist/node/index.mjs +30 -29
- package/dist/node/index.mjs.map +3 -3
- package/dist/types/shared/dom/osc.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -1574,7 +1574,7 @@ var OSC = class {
|
|
|
1574
1574
|
vnode.setId(jsx2.id);
|
|
1575
1575
|
}
|
|
1576
1576
|
parent.addChild(vnode);
|
|
1577
|
-
this.loadClientComponent(path2, name, jsx2.props, container
|
|
1577
|
+
this.loadClientComponent(path2, name, jsx2.props, container);
|
|
1578
1578
|
return { domNode: container, vnode };
|
|
1579
1579
|
}
|
|
1580
1580
|
buildPendingReference(jsx2, parent) {
|
|
@@ -1699,43 +1699,44 @@ var OSC = class {
|
|
|
1699
1699
|
dom.removeAttribute(key);
|
|
1700
1700
|
}
|
|
1701
1701
|
}
|
|
1702
|
-
async loadClientComponent(path2, name, props, container
|
|
1702
|
+
async loadClientComponent(path2, name, props, container) {
|
|
1703
1703
|
try {
|
|
1704
|
+
let register2 = function(Cls, injector2) {
|
|
1705
|
+
if (seen.has(Cls))
|
|
1706
|
+
return;
|
|
1707
|
+
seen.add(Cls);
|
|
1708
|
+
injector2.addProvider({
|
|
1709
|
+
provide: Cls,
|
|
1710
|
+
useClass: Cls,
|
|
1711
|
+
scope: "transient"
|
|
1712
|
+
});
|
|
1713
|
+
const paramDeps = Reflect.getMetadata(DESIGN_PARAMTYPES, Cls) ?? [];
|
|
1714
|
+
const explicitDeps = Reflect.getMetadata(COMPONENT_DEPS, Cls) ?? [];
|
|
1715
|
+
paramDeps.filter((d) => d && d !== Object).forEach((d) => injector2.addProvider(d));
|
|
1716
|
+
explicitDeps.forEach((deps) => register2(deps, injector2));
|
|
1717
|
+
};
|
|
1718
|
+
var register = register2;
|
|
1704
1719
|
const module = await import(path2);
|
|
1705
1720
|
const ComponentClass = module[name];
|
|
1706
|
-
const params = Reflect.getMetadata(DESIGN_PARAMTYPES, ComponentClass) || [];
|
|
1707
|
-
const deps = Reflect.getMetadata(COMPONENT_DEPS, ComponentClass) || [];
|
|
1708
|
-
const injector = getCurrentInjector();
|
|
1709
|
-
if (injector == null) {
|
|
1710
|
-
throw new Error(`Couldn't find an injector`);
|
|
1711
|
-
}
|
|
1712
1721
|
if (!ComponentClass) {
|
|
1713
1722
|
throw new Error(`Component ${name} not found in ${path2}`);
|
|
1714
1723
|
}
|
|
1715
|
-
injector
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
(depClass) => injector.addProvider({
|
|
1722
|
-
provide: depClass,
|
|
1723
|
-
useClass: depClass,
|
|
1724
|
-
scope: "transient"
|
|
1725
|
-
})
|
|
1726
|
-
);
|
|
1727
|
-
params.forEach((p) => injector.addProvider(p));
|
|
1724
|
+
const injector = getCurrentInjector();
|
|
1725
|
+
if (injector == null) {
|
|
1726
|
+
throw new Error("Couldn't find an injector");
|
|
1727
|
+
}
|
|
1728
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1729
|
+
register2(ComponentClass, injector);
|
|
1728
1730
|
const cleanProps = { ...props };
|
|
1729
1731
|
delete cleanProps.__clientComponent;
|
|
1730
|
-
const
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
if (typeof
|
|
1734
|
-
|
|
1735
|
-
container.parentNode?.replaceChild(rendered, container);
|
|
1736
|
-
} else {
|
|
1737
|
-
throw new Error(`Component ${name} does not have a build method`);
|
|
1732
|
+
const instance = injector.resolve(ComponentClass);
|
|
1733
|
+
instance.__injector = injector;
|
|
1734
|
+
instance.props = cleanProps;
|
|
1735
|
+
if (typeof instance.build !== "function") {
|
|
1736
|
+
throw new Error(`Component ${name} does not implement build()`);
|
|
1738
1737
|
}
|
|
1738
|
+
const rendered = instance.build();
|
|
1739
|
+
container.replaceWith(rendered);
|
|
1739
1740
|
} catch (error) {
|
|
1740
1741
|
console.error(`Failed to load client component ${name}:`, error);
|
|
1741
1742
|
container.textContent = `Error loading component: ${name}`;
|