@syntrologie/runtime-sdk 2.4.0-canary.25 → 2.4.0-canary.26

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.
@@ -31,8 +31,8 @@ import {
31
31
  WaitZ,
32
32
  WidgetConfigZ,
33
33
  coreActionStepSchemas
34
- } from "../chunk-YZ27S3HX.js";
35
- import "../chunk-7OZFA3CQ.js";
34
+ } from "../chunk-R5DNAIRI.js";
35
+ import "../chunk-XDYJ64IN.js";
36
36
  import "../chunk-BU4Z6PD7.js";
37
37
  export {
38
38
  AddClassZ,
@@ -124,6 +124,7 @@ function sanitizeHtml(html) {
124
124
 
125
125
  // ../adaptives/adaptive-content/dist/runtime.js
126
126
  var executeInsertHtml = async (action, context) => {
127
+ var _a2;
127
128
  let anchorEl = context.resolveAnchor(action.anchorId);
128
129
  if (!anchorEl && context.waitForAnchor) {
129
130
  anchorEl = await context.waitForAnchor(action.anchorId, 3e3);
@@ -134,8 +135,19 @@ var executeInsertHtml = async (action, context) => {
134
135
  } };
135
136
  }
136
137
  const sanitizedHtml = sanitizeHtml(action.html);
138
+ const dedupAttr = "data-syntro-insert-label";
139
+ const label = action.label;
140
+ if (label) {
141
+ const escapedLabel = CSS.escape(label);
142
+ const searchRoot = (_a2 = anchorEl.parentElement) != null ? _a2 : anchorEl;
143
+ const existing = searchRoot.querySelector(`[${dedupAttr}="${escapedLabel}"]`);
144
+ if (existing)
145
+ existing.remove();
146
+ }
137
147
  const container = document.createElement("div");
138
148
  container.setAttribute("data-syntro-action-id", context.generateId());
149
+ if (label)
150
+ container.setAttribute(dedupAttr, label);
139
151
  container.innerHTML = sanitizedHtml;
140
152
  let originalContent = null;
141
153
  switch (action.position) {
@@ -160,8 +172,8 @@ var executeInsertHtml = async (action, context) => {
160
172
  if (action.deepLink) {
161
173
  const { tileId, itemId } = action.deepLink;
162
174
  deepLinkHandler = () => {
163
- var _a2, _b, _c;
164
- const handle = (_a2 = window.SynOS) == null ? void 0 : _a2.handle;
175
+ var _a3, _b, _c;
176
+ const handle = (_a3 = window.SynOS) == null ? void 0 : _a3.handle;
165
177
  if (handle) {
166
178
  handle.open();
167
179
  (_c = (_b = handle.runtime) == null ? void 0 : _b.events) == null ? void 0 : _c.publish("notification.deep_link", { tileId, itemId });
@@ -2047,26 +2059,40 @@ function showTooltip(anchorEl, overlayRoot, opts) {
2047
2059
  }
2048
2060
  const attachTrigger = () => {
2049
2061
  if (opts.trigger === "hover") {
2050
- const enter = () => {
2062
+ let hideTimeout = null;
2063
+ const show = () => {
2064
+ if (hideTimeout) {
2065
+ clearTimeout(hideTimeout);
2066
+ hideTimeout = null;
2067
+ }
2051
2068
  div.style.visibility = "visible";
2052
2069
  div.style.opacity = "1";
2053
2070
  };
2054
- const leave = () => {
2055
- div.style.visibility = "hidden";
2056
- div.style.opacity = "0";
2071
+ const scheduleHide = () => {
2072
+ hideTimeout = setTimeout(() => {
2073
+ div.style.visibility = "hidden";
2074
+ div.style.opacity = "0";
2075
+ hideTimeout = null;
2076
+ }, 100);
2057
2077
  };
2058
2078
  div.style.visibility = "hidden";
2059
2079
  div.style.opacity = "0";
2060
2080
  div.style.transition = "opacity 200ms ease, visibility 200ms";
2061
- anchorEl.addEventListener("mouseenter", enter);
2062
- anchorEl.addEventListener("mouseleave", leave);
2063
- anchorEl.addEventListener("focus", enter);
2064
- anchorEl.addEventListener("blur", leave);
2081
+ anchorEl.addEventListener("mouseenter", show);
2082
+ anchorEl.addEventListener("mouseleave", scheduleHide);
2083
+ div.addEventListener("mouseenter", show);
2084
+ div.addEventListener("mouseleave", scheduleHide);
2085
+ anchorEl.addEventListener("focus", show);
2086
+ anchorEl.addEventListener("blur", scheduleHide);
2065
2087
  return () => {
2066
- anchorEl.removeEventListener("mouseenter", enter);
2067
- anchorEl.removeEventListener("mouseleave", leave);
2068
- anchorEl.removeEventListener("focus", enter);
2069
- anchorEl.removeEventListener("blur", leave);
2088
+ if (hideTimeout)
2089
+ clearTimeout(hideTimeout);
2090
+ anchorEl.removeEventListener("mouseenter", show);
2091
+ anchorEl.removeEventListener("mouseleave", scheduleHide);
2092
+ div.removeEventListener("mouseenter", show);
2093
+ div.removeEventListener("mouseleave", scheduleHide);
2094
+ anchorEl.removeEventListener("focus", show);
2095
+ anchorEl.removeEventListener("blur", scheduleHide);
2070
2096
  };
2071
2097
  }
2072
2098
  if (opts.trigger === "click") {
@@ -3332,7 +3358,7 @@ function getAntiFlickerSnippet(config = {}) {
3332
3358
  }
3333
3359
 
3334
3360
  // src/version.ts
3335
- var SDK_VERSION = "2.4.0-canary.25";
3361
+ var SDK_VERSION = "2.4.0-canary.26";
3336
3362
 
3337
3363
  // src/types.ts
3338
3364
  var SDK_SCHEMA_VERSION = "2.0";
@@ -4335,10 +4361,12 @@ import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
4335
4361
  function WidgetMount({ widgetId, props }) {
4336
4362
  var _a2;
4337
4363
  const runtime3 = useRuntime();
4338
- const containerRef = useRef4(null);
4364
+ const parentRef = useRef4(null);
4339
4365
  const handleRef = useRef4(null);
4340
4366
  const registry = runtime3 == null ? void 0 : runtime3.widgets;
4341
4367
  const widgetAvailable = (_a2 = registry == null ? void 0 : registry.has(widgetId)) != null ? _a2 : false;
4368
+ const propsRef = useRef4(props);
4369
+ propsRef.current = props;
4342
4370
  const [, forceUpdate] = useReducer((x) => x + 1, 0);
4343
4371
  useEffect5(() => {
4344
4372
  if (!registry || widgetAvailable) return;
@@ -4349,14 +4377,27 @@ function WidgetMount({ widgetId, props }) {
4349
4377
  });
4350
4378
  }, [registry, widgetId, widgetAvailable]);
4351
4379
  useEffect5(() => {
4352
- if (!containerRef.current || !registry || !widgetAvailable) return;
4353
- const handle = registry.mount(widgetId, containerRef.current, props);
4380
+ if (!parentRef.current || !registry || !widgetAvailable) return;
4381
+ const container = document.createElement("div");
4382
+ container.style.width = "100%";
4383
+ container.style.minHeight = "40px";
4384
+ parentRef.current.appendChild(container);
4385
+ const handle = registry.mount(widgetId, container, propsRef.current);
4354
4386
  handleRef.current = handle;
4355
4387
  return () => {
4356
4388
  handle.unmount();
4357
4389
  handleRef.current = null;
4390
+ container.remove();
4358
4391
  };
4359
- }, [registry, widgetId, props, widgetAvailable]);
4392
+ }, [registry, widgetId, widgetAvailable]);
4393
+ const propsJson = JSON.stringify(props);
4394
+ const prevPropsJsonRef = useRef4(propsJson);
4395
+ useEffect5(() => {
4396
+ var _a3;
4397
+ if (prevPropsJsonRef.current === propsJson) return;
4398
+ prevPropsJsonRef.current = propsJson;
4399
+ (_a3 = handleRef.current) == null ? void 0 : _a3.update(propsRef.current);
4400
+ }, [propsJson]);
4360
4401
  if (!registry || !registry.has(widgetId)) {
4361
4402
  return /* @__PURE__ */ jsxs2(
4362
4403
  "div",
@@ -4374,7 +4415,7 @@ function WidgetMount({ widgetId, props }) {
4374
4415
  }
4375
4416
  );
4376
4417
  }
4377
- return /* @__PURE__ */ jsx5("div", { ref: containerRef, style: { width: "100%", minHeight: "40px" } });
4418
+ return /* @__PURE__ */ jsx5("div", { ref: parentRef });
4378
4419
  }
4379
4420
  function TileCard({
4380
4421
  config,
@@ -11287,4 +11328,4 @@ export {
11287
11328
  encodeToken,
11288
11329
  Syntro
11289
11330
  };
11290
- //# sourceMappingURL=chunk-2WDY7YGN.js.map
11331
+ //# sourceMappingURL=chunk-E26VPJAS.js.map