@syntrologie/runtime-sdk 2.2.0-canary.14 → 2.2.0-canary.16

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.
@@ -2091,7 +2091,7 @@ function getAntiFlickerSnippet(config = {}) {
2091
2091
  }
2092
2092
 
2093
2093
  // src/version.ts
2094
- var SDK_VERSION = "2.2.0-canary.14";
2094
+ var SDK_VERSION = "2.2.0-canary.16";
2095
2095
 
2096
2096
  // src/types.ts
2097
2097
  var SDK_SCHEMA_VERSION = "2.0";
@@ -3125,26 +3125,33 @@ function useDecision(strategy, defaultValue) {
3125
3125
  }
3126
3126
 
3127
3127
  // src/components/TileCard.tsx
3128
- import { useCallback as useCallback2, useEffect as useEffect5, useRef as useRef3, useState as useState4 } from "react";
3128
+ import { useCallback as useCallback2, useEffect as useEffect5, useReducer, useRef as useRef3, useState as useState4 } from "react";
3129
3129
  import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
3130
3130
  function WidgetMount({ widgetId, props }) {
3131
+ var _a2;
3131
3132
  const runtime3 = useRuntime();
3132
3133
  const containerRef = useRef3(null);
3133
3134
  const handleRef = useRef3(null);
3134
3135
  const registry = runtime3 == null ? void 0 : runtime3.widgets;
3136
+ const widgetAvailable = (_a2 = registry == null ? void 0 : registry.has(widgetId)) != null ? _a2 : false;
3137
+ const [, forceUpdate] = useReducer((x) => x + 1, 0);
3135
3138
  useEffect5(() => {
3136
- if (!containerRef.current || !registry) return;
3137
- if (!registry.has(widgetId)) {
3138
- console.warn(`[TileCard] Widget not found in registry: ${widgetId}`);
3139
- return;
3140
- }
3139
+ if (!registry || widgetAvailable) return;
3140
+ return registry.subscribe((event) => {
3141
+ if (event.type === "registered" && event.widgetId === widgetId) {
3142
+ forceUpdate();
3143
+ }
3144
+ });
3145
+ }, [registry, widgetId, widgetAvailable]);
3146
+ useEffect5(() => {
3147
+ if (!containerRef.current || !registry || !widgetAvailable) return;
3141
3148
  const handle = registry.mount(widgetId, containerRef.current, props);
3142
3149
  handleRef.current = handle;
3143
3150
  return () => {
3144
3151
  handle.unmount();
3145
3152
  handleRef.current = null;
3146
3153
  };
3147
- }, [registry, widgetId, props]);
3154
+ }, [registry, widgetId, props, widgetAvailable]);
3148
3155
  if (!registry || !registry.has(widgetId)) {
3149
3156
  return /* @__PURE__ */ jsxs2(
3150
3157
  "div",
@@ -8250,6 +8257,7 @@ var WidgetRegistry = class {
8250
8257
  __publicField(this, "mountedWidgets", /* @__PURE__ */ new Map());
8251
8258
  __publicField(this, "mountIdCounter", 0);
8252
8259
  __publicField(this, "runtimeRef");
8260
+ __publicField(this, "listeners", /* @__PURE__ */ new Set());
8253
8261
  }
8254
8262
  /**
8255
8263
  * Bind a runtime reference so it can be injected into widget mount() calls.
@@ -8280,6 +8288,7 @@ var WidgetRegistry = class {
8280
8288
  source,
8281
8289
  metadata
8282
8290
  });
8291
+ this.notify({ type: "registered", widgetId: id });
8283
8292
  }
8284
8293
  /**
8285
8294
  * Unregister a widget.
@@ -8297,6 +8306,7 @@ var WidgetRegistry = class {
8297
8306
  return false;
8298
8307
  }
8299
8308
  this.widgets.delete(id);
8309
+ this.notify({ type: "unregistered", widgetId: id });
8300
8310
  return true;
8301
8311
  }
8302
8312
  /**
@@ -8404,6 +8414,24 @@ var WidgetRegistry = class {
8404
8414
  (registration) => registration.source === source
8405
8415
  );
8406
8416
  }
8417
+ /**
8418
+ * Subscribe to widget registration changes.
8419
+ */
8420
+ subscribe(callback) {
8421
+ this.listeners.add(callback);
8422
+ return () => {
8423
+ this.listeners.delete(callback);
8424
+ };
8425
+ }
8426
+ notify(event) {
8427
+ for (const listener of this.listeners) {
8428
+ try {
8429
+ listener(event);
8430
+ } catch (error2) {
8431
+ console.error("[WidgetRegistry] Listener error:", error2);
8432
+ }
8433
+ }
8434
+ }
8407
8435
  /**
8408
8436
  * Clean up all mounted widgets.
8409
8437
  */
@@ -9294,4 +9322,4 @@ export {
9294
9322
  encodeToken,
9295
9323
  Syntro
9296
9324
  };
9297
- //# sourceMappingURL=chunk-GUDQECKY.js.map
9325
+ //# sourceMappingURL=chunk-GOEPJYL6.js.map