@sevenfold/setto-client 0.2.7 → 0.2.9

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.
@@ -9,6 +9,8 @@ export declare const STALE_BUILDING_MS: number;
9
9
  export declare function isDeploymentStale(row: Pick<DeploymentRow, 'status' | 'started_at' | 'updated_at'>): boolean;
10
10
  /** Latest in-flight deployment for a site, if any (ignores stale rows). */
11
11
  export declare function fetchInProgressDeploymentId(supabase: SupabaseClient, siteId: string): Promise<string | null>;
12
+ /** Wait for a deployment row (e.g. webhook backstop) after trackingDeferred publish. */
13
+ export declare function waitForDeploymentByCommit(supabase: SupabaseClient, siteId: string, commitSha: string, timeoutMs?: number): Promise<string | null>;
12
14
  /** Subscribe to a single deployment row via Supabase Realtime. */
13
15
  export declare function useDeploymentStatus(supabase: SupabaseClient, deploymentId: string | null): {
14
16
  row: DeploymentRow | null;
@@ -10,9 +10,7 @@ interface PublishDialogProps {
10
10
  onComplete: () => void;
11
11
  }
12
12
  /**
13
-
14
13
  * Centered modal showing publish progress (Committed → Building → Deployed).
15
-
16
14
  */
17
15
  export declare function PublishDialog({ row, status, onClose, onComplete, }: PublishDialogProps): import("react/jsx-runtime").JSX.Element;
18
16
  export {};
@@ -21672,6 +21672,15 @@ async function fetchInProgressDeploymentId(supabase, siteId) {
21672
21672
  const fresh = rows.find((r) => !isDeploymentStale(r));
21673
21673
  return fresh?.id ?? null;
21674
21674
  }
21675
+ async function waitForDeploymentByCommit(supabase, siteId, commitSha, timeoutMs = 6e4) {
21676
+ const deadline = Date.now() + timeoutMs;
21677
+ while (Date.now() < deadline) {
21678
+ const { data } = await supabase.from("deployments").select("id").eq("site_id", siteId).eq("commit_sha", commitSha).order("started_at", { ascending: false }).limit(1).maybeSingle();
21679
+ if (data?.id) return data.id;
21680
+ await new Promise((r) => setTimeout(r, 2e3));
21681
+ }
21682
+ return null;
21683
+ }
21675
21684
  function useDeploymentStatus(supabase, deploymentId) {
21676
21685
  const [row, setRow] = useState(null);
21677
21686
  useEffect(() => {
@@ -21871,16 +21880,6 @@ function PublishDialog({
21871
21880
  return /* @__PURE__ */ jsx(EditOverlay, { onClose: void 0, children: isReady ? /* @__PURE__ */ jsxs(Fragment, { children: [
21872
21881
  /* @__PURE__ */ jsx("h2", { style: { margin: "0 0 12px", fontSize: 18, fontWeight: 600 }, children: "Publisert" }),
21873
21882
  /* @__PURE__ */ jsx("p", { style: { margin: "0 0 20px", fontSize: 14, lineHeight: 1.5, color: "#444" }, children: "Endringene dine er live." }),
21874
- row?.url ? /* @__PURE__ */ jsx(
21875
- "a",
21876
- {
21877
- href: row.url,
21878
- target: "_blank",
21879
- rel: "noreferrer",
21880
- style: { ...linkStyle$1, display: "block", marginBottom: 16 },
21881
- children: "Åpne publisert side →"
21882
- }
21883
- ) : null,
21884
21883
  /* @__PURE__ */ jsx("button", { type: "button", onClick: onComplete, style: primaryBtnStyle, children: "OK" })
21885
21884
  ] }) : errored ? /* @__PURE__ */ jsxs(Fragment, { children: [
21886
21885
  /* @__PURE__ */ jsx("h2", { style: { margin: "0 0 12px", fontSize: 18, fontWeight: 600, color: "#dc2626" }, children: "Publisering feilet" }),
@@ -21918,11 +21917,6 @@ const secondaryBtnStyle = {
21918
21917
  color: "#666",
21919
21918
  border: "1px solid #ddd"
21920
21919
  };
21921
- const linkStyle$1 = {
21922
- color: "#640AFF",
21923
- fontSize: 14,
21924
- textDecoration: "none"
21925
- };
21926
21920
  function guessLangFromPath(path, languages) {
21927
21921
  for (const lng of languages) {
21928
21922
  if (path.includes(`/${lng}.`) || path.includes(`/${lng}/`)) return lng;
@@ -22118,7 +22112,20 @@ function EditToolbar() {
22118
22112
  const result = await api.publish(config.siteId, files);
22119
22113
  store.commit();
22120
22114
  themeStore?.commit();
22121
- setActiveDeployment(result.deploymentId);
22115
+ let deploymentId = result.deploymentId;
22116
+ if (!deploymentId && result.trackingDeferred) {
22117
+ deploymentId = await waitForDeploymentByCommit(
22118
+ supabase,
22119
+ config.siteId,
22120
+ result.commitSha
22121
+ );
22122
+ }
22123
+ if (deploymentId) {
22124
+ setActiveDeployment(deploymentId);
22125
+ } else {
22126
+ setPublishDialogOpen(false);
22127
+ setPublishedNotice(true);
22128
+ }
22122
22129
  } catch (err) {
22123
22130
  setError(err instanceof Error ? err.message : "unknown error");
22124
22131
  setPublishDialogOpen(false);