@stackable-labs/sdk-extension-react 1.72.0 → 1.73.0

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.
Files changed (2) hide show
  1. package/dist/index.js +33 -11
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -288,7 +288,9 @@ var useEvent = (eventType, handler) => {
288
288
  const event = payload;
289
289
  if (event.eventName === targetEventName) ; else if (targetEventName.startsWith(`${event.eventName}:`)) {
290
290
  const subFilter = targetEventName.slice(event.eventName.length + 1);
291
- if (event.data?.actionName !== subFilter) return;
291
+ if (event.data?.actionName !== subFilter) {
292
+ return;
293
+ }
292
294
  } else {
293
295
  return;
294
296
  }
@@ -314,10 +316,14 @@ var getSurfaceRegistry = (surfaceId) => {
314
316
  var serializeDOMNode = (domNode, registry) => {
315
317
  if (domNode.nodeType === Node.TEXT_NODE) {
316
318
  const text = domNode.textContent || "";
317
- if (!text.trim()) return [];
319
+ if (!text.trim()) {
320
+ return [];
321
+ }
318
322
  return [{ type: "text", text }];
319
323
  }
320
- if (domNode.nodeType !== Node.ELEMENT_NODE) return [];
324
+ if (domNode.nodeType !== Node.ELEMENT_NODE) {
325
+ return [];
326
+ }
321
327
  const el = domNode;
322
328
  const tag = el.tagName.toLowerCase();
323
329
  if (tag === "div" && el.hasAttribute("data-surface-id")) {
@@ -330,12 +336,18 @@ var serializeDOMNode = (domNode, registry) => {
330
336
  const reactProps = el[propsKey];
331
337
  if (reactProps) {
332
338
  for (const [key, value] of Object.entries(reactProps)) {
333
- if (key === "children") continue;
339
+ if (key === "children") {
340
+ continue;
341
+ }
334
342
  if ((key === "onClick" || key === "onChange") && typeof value === "function") {
335
343
  const id = `action-${++registry.counter}`;
336
344
  registry.handlers.set(id, value);
337
- if (key === "onClick") actionId = id;
338
- if (key === "onChange") attrs["data-onchange-id"] = id;
345
+ if (key === "onClick") {
346
+ actionId = id;
347
+ }
348
+ if (key === "onChange") {
349
+ attrs["data-onchange-id"] = id;
350
+ }
339
351
  continue;
340
352
  }
341
353
  if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
@@ -345,7 +357,9 @@ var serializeDOMNode = (domNode, registry) => {
345
357
  }
346
358
  } else {
347
359
  for (const attr of Array.from(el.attributes)) {
348
- if (attr.name === "style") continue;
360
+ if (attr.name === "style") {
361
+ continue;
362
+ }
349
363
  const name = attr.name === "class" ? "className" : attr.name;
350
364
  attrs[name] = attr.value;
351
365
  }
@@ -360,7 +374,9 @@ var Surface = ({ id, children }) => {
360
374
  const containerRef = useRef(null);
361
375
  const serializeAndSend = useCallback(() => {
362
376
  const container = containerRef.current;
363
- if (!container) return;
377
+ if (!container) {
378
+ return;
379
+ }
364
380
  const registry = getSurfaceRegistry(id);
365
381
  registry.handlers.clear();
366
382
  registry.counter = 0;
@@ -371,7 +387,9 @@ var Surface = ({ id, children }) => {
371
387
  children: serialized
372
388
  };
373
389
  const treeForComparison = JSON.stringify(tree, (key, value) => key === "actionId" || key === "data-onchange-id" ? void 0 : value);
374
- if (treeForComparison === prevTreeRef.current) return;
390
+ if (treeForComparison === prevTreeRef.current) {
391
+ return;
392
+ }
375
393
  prevTreeRef.current = treeForComparison;
376
394
  window.parent.postMessage(
377
395
  { type: "surface-update", surfaceId: id, tree },
@@ -383,7 +401,9 @@ var Surface = ({ id, children }) => {
383
401
  });
384
402
  useEffect(() => {
385
403
  const container = containerRef.current;
386
- if (!container) return;
404
+ if (!container) {
405
+ return;
406
+ }
387
407
  const observer = new MutationObserver(() => {
388
408
  serializeAndSend();
389
409
  });
@@ -398,7 +418,9 @@ var Surface = ({ id, children }) => {
398
418
  useEffect(() => {
399
419
  const handleMessage = (event) => {
400
420
  const msg = event.data;
401
- if (!msg || typeof msg !== "object") return;
421
+ if (!msg || typeof msg !== "object") {
422
+ return;
423
+ }
402
424
  if (msg.type === "context-update" && msg.surfaceId === id) {
403
425
  setContext(msg.context);
404
426
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackable-labs/sdk-extension-react",
3
- "version": "1.72.0",
3
+ "version": "1.73.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -15,7 +15,7 @@
15
15
  "@agnostack/verifyd": "alpha",
16
16
  "@remote-dom/core": "1.x",
17
17
  "@remote-dom/react": "1.x",
18
- "@stackable-labs/sdk-extension-contracts": "1.72.0"
18
+ "@stackable-labs/sdk-extension-contracts": "1.73.0"
19
19
  },
20
20
  "peerDependencies": {
21
21
  "react": ">=18.0.0 <19.0.0",