@proveanything/smartlinks-utils-ui 0.8.1 → 0.8.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.
@@ -2422,13 +2422,17 @@ var createPostMessageDeepLinkAdapter = (paramNames) => {
2422
2422
  overlay("scope", paramNames.scope);
2423
2423
  overlay("view", paramNames.view);
2424
2424
  try {
2425
- window.parent.postMessage({
2425
+ const message = {
2426
2426
  type: "smartlinks-route-change",
2427
2427
  path,
2428
2428
  context,
2429
2429
  state,
2430
2430
  appId: context.appId
2431
- }, "*");
2431
+ };
2432
+ console.debug("[smartlinks-ui] postMessage \u2192 parent", message, {
2433
+ sameWindow: window.parent === window
2434
+ });
2435
+ window.parent.postMessage(message, "*");
2432
2436
  } catch {
2433
2437
  }
2434
2438
  };
@@ -2481,7 +2485,13 @@ function useDeepLinkState(options) {
2481
2485
  if (!enabled) return null;
2482
2486
  if (options?.adapter) return options.adapter;
2483
2487
  if (!defaultAdapterRef.current) {
2484
- defaultAdapterRef.current = isInSmartLinksIframe() ? createPostMessageDeepLinkAdapter(paramNames) : createDefaultDeepLinkAdapter(paramNames);
2488
+ const inIframe = isInSmartLinksIframe();
2489
+ console.debug("[smartlinks-ui] deep-link adapter selected", {
2490
+ adapter: inIframe ? "postMessage" : "default",
2491
+ inIframe,
2492
+ href: typeof window !== "undefined" ? window.location.href : "(ssr)"
2493
+ });
2494
+ defaultAdapterRef.current = inIframe ? createPostMessageDeepLinkAdapter(paramNames) : createDefaultDeepLinkAdapter(paramNames);
2485
2495
  }
2486
2496
  return defaultAdapterRef.current;
2487
2497
  }, [enabled, options?.adapter, paramNames]);
@@ -4752,7 +4762,7 @@ var createEditorStore = () => {
4752
4762
  const editorId = input.editorId ?? mintEditorId();
4753
4763
  if (map.has(editorId)) return editorId;
4754
4764
  const seedValue = input.seed?.value ?? input.defaultValue;
4755
- const seedFacetRule = input.seed?.facetRule ?? input.spec.initialFacetRule ?? null;
4765
+ const seedFacetRule = input.spec.initialFacetRule !== void 0 && input.spec.initialFacetRule !== null ? input.spec.initialFacetRule : input.seed?.facetRule ?? null;
4756
4766
  const source = input.seed?.source ?? "empty";
4757
4767
  const value = cloneDeep(seedValue);
4758
4768
  const baseline = cloneDeep(seedValue);
@@ -4891,8 +4901,8 @@ var createEditorStore = () => {
4891
4901
  nextRecordId = upserted.record?.id ?? nextRecordId;
4892
4902
  }
4893
4903
  update(editorId, (e) => {
4894
- e.baseline = cloneDeep(persistedValue);
4895
- e.baselineFacetRule = persistedFacetRule;
4904
+ e.baseline = cloneDeep(e.value);
4905
+ e.baselineFacetRule = e.facetRule;
4896
4906
  e.recordId = nextRecordId;
4897
4907
  e.source = "self";
4898
4908
  e.status = "saved";