@ohhwells/bridge 0.1.21 → 0.1.22

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.cjs CHANGED
@@ -256,10 +256,10 @@ function buildTimezoneLabel(tz) {
256
256
  return tz;
257
257
  }
258
258
  }
259
- function EmptyState({ inEditor }) {
259
+ function EmptyState({ inEditor, insertAfter }) {
260
260
  const handleAddSchedule = () => {
261
261
  if (inEditor) {
262
- window.parent.postMessage({ type: "ow:scheduling-not-connected" }, "*");
262
+ window.parent.postMessage({ type: "ow:scheduling-not-connected", insertAfter }, "*");
263
263
  }
264
264
  };
265
265
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex flex-col items-center justify-center gap-6 p-12 bg-[#FAFAF9] border-2 border-dashed border-[#E7E5E4] rounded-[10px] h-[264px] w-full box-border", children: [
@@ -714,6 +714,7 @@ function SchedulingWidget({ notifyOnConnect = false, initialScheduleId, insertAf
714
714
  window.parent.postMessage({ type: "ow:scheduling-not-connected", insertAfter }, "*");
715
715
  }
716
716
  };
717
+ if (!inEditor && !loading && !schedule) return null;
717
718
  const sectionId = `scheduling-${insertAfter}`;
718
719
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
719
720
  "section",
@@ -759,7 +760,7 @@ function SchedulingWidget({ notifyOnConnect = false, initialScheduleId, insertAf
759
760
  ] }),
760
761
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "w-full flex flex-col items-end gap-3", children: [
761
762
  timezoneLabel && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "font-body text-sm font-normal text-(--color-accent,#A89B83)", children: timezoneLabel }),
762
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "w-full p-0 sm:p-10 box-border", children: loading ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LoadingSkeleton, {}) : !schedule ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(EmptyState, { inEditor }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
763
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "w-full p-0 sm:p-10 box-border", children: loading ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LoadingSkeleton, {}) : !schedule ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(EmptyState, { inEditor, insertAfter }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
763
764
  ScheduleView,
764
765
  {
765
766
  schedule,
@@ -4378,9 +4379,10 @@ function initSectionsFromContent(content, removeExisting = false) {
4378
4379
  const inEditor = typeof window !== "undefined" && window.self !== window.top;
4379
4380
  if (inEditor) getSectionsTracker().textContent = raw;
4380
4381
  const pageEntries = getPageSchedulingEntries(raw);
4381
- mountSchedulingEntries(pageEntries, false);
4382
- requestAnimationFrame(() => retryMissingSchedulingMounts(pageEntries, false));
4383
- setTimeout(() => retryMissingSchedulingMounts(pageEntries, false), 250);
4382
+ const notifyForEntry = inEditor ? (e) => !e.scheduleId : false;
4383
+ mountSchedulingEntries(pageEntries, notifyForEntry);
4384
+ requestAnimationFrame(() => retryMissingSchedulingMounts(pageEntries, notifyForEntry));
4385
+ setTimeout(() => retryMissingSchedulingMounts(pageEntries, notifyForEntry), 250);
4384
4386
  } catch {
4385
4387
  }
4386
4388
  }
@@ -4439,8 +4441,9 @@ function mountSchedulingEntries(entries, notifyOnConnect = false) {
4439
4441
  const pending = entries.filter((e) => e.type === "scheduling").sort((a, b) => schedulingMountDepth(a.insertAfter) - schedulingMountDepth(b.insertAfter));
4440
4442
  for (let attempt = 0; attempt < pending.length + 1 && pending.length > 0; attempt++) {
4441
4443
  for (let i = pending.length - 1; i >= 0; i--) {
4442
- const { insertAfter, scheduleId } = pending[i];
4443
- if (mountSchedulingWidget(insertAfter, notifyOnConnect, scheduleId)) {
4444
+ const entry = pending[i];
4445
+ const shouldNotify = typeof notifyOnConnect === "function" ? notifyOnConnect(entry) : notifyOnConnect;
4446
+ if (mountSchedulingWidget(entry.insertAfter, shouldNotify, entry.scheduleId)) {
4444
4447
  pending.splice(i, 1);
4445
4448
  }
4446
4449
  }