@xmachines/json-render-react 0.21.0-xm.1 → 0.21.0-xm.2

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/index.mjs CHANGED
@@ -818,10 +818,12 @@ import {
818
818
  getByPath as getByPath2,
819
819
  isDevtoolsActive,
820
820
  subscribeDevtoolsActive,
821
- createDirectiveRegistry
821
+ createDirectiveRegistry,
822
+ copySlotMetadata,
823
+ setCatalogSlotMetadata,
824
+ warnElementSlots
822
825
  } from "@xmachines/json-render-core";
823
826
  import { Fragment, jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
824
- var registryMetadata = /* @__PURE__ */ new WeakMap();
825
827
  var EMPTY_ELEMENT_PROPS = {};
826
828
  function withRenderErrorHandler(registry, onRenderError) {
827
829
  const next = { ...registry };
@@ -830,8 +832,7 @@ function withRenderErrorHandler(registry, onRenderError) {
830
832
  enumerable: false,
831
833
  configurable: true
832
834
  });
833
- const metadata = registryMetadata.get(registry);
834
- if (metadata) registryMetadata.set(next, metadata);
835
+ copySlotMetadata(registry, next);
835
836
  return next;
836
837
  }
837
838
  function useRenderErrorRegistry(registry, onRenderError) {
@@ -1221,21 +1222,7 @@ function ReactiveElementRenderer({
1221
1222
  console.warn(`No renderer for component type: ${resolvedElement.type}`);
1222
1223
  return null;
1223
1224
  }
1224
- const metadata = registryMetadata.get(registry)?.[resolvedElement.type];
1225
- if (resolvedElement.slots && metadata?.slots) {
1226
- const availableSlots = new Set(metadata.slots);
1227
- for (const slotName of Object.keys(resolvedElement.slots)) {
1228
- if (slotName === "default") {
1229
- console.warn(
1230
- `[json-render] Component "${resolvedElement.type}" uses slots.default. Use "children" for default slot content.`
1231
- );
1232
- } else if (!availableSlots.has(slotName)) {
1233
- console.warn(
1234
- `[json-render] Unknown slot "${slotName}" on component "${resolvedElement.type}". Available slots: ${metadata.slots.join(", ")}`
1235
- );
1236
- }
1237
- }
1238
- }
1225
+ warnElementSlots(registry, resolvedElement.type, resolvedElement.slots);
1239
1226
  const renderChildKeys = (childKeys, slotName) => childKeys.map((childKey) => {
1240
1227
  const childElement = spec.elements[childKey];
1241
1228
  if (!childElement) {
@@ -1481,10 +1468,7 @@ function defineRegistry(catalog, options) {
1481
1468
  };
1482
1469
  }
1483
1470
  }
1484
- const catalogComponents = catalog.data.components;
1485
- if (catalogComponents) {
1486
- registryMetadata.set(registry, catalogComponents);
1487
- }
1471
+ setCatalogSlotMetadata(registry, catalog);
1488
1472
  const actionMap = options.actions ? Object.entries(options.actions) : [];
1489
1473
  const handlers = (getSetState, getState) => {
1490
1474
  const result = {};
@@ -1518,10 +1502,7 @@ function defineRegistry(catalog, options) {
1518
1502
  }
1519
1503
  function createRenderer(catalog, components) {
1520
1504
  const registry = components;
1521
- const catalogComponents = catalog.data.components;
1522
- if (catalogComponents) {
1523
- registryMetadata.set(registry, catalogComponents);
1524
- }
1505
+ setCatalogSlotMetadata(registry, catalog);
1525
1506
  return function CatalogRenderer({
1526
1507
  spec,
1527
1508
  store,