@superblocksteam/library 2.0.116-next.1 → 2.0.116-next.3

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.
@@ -1,4 +1,4 @@
1
- import { _ as root_store_default, t as makeWrappedComponent, x as api_hmr_tracker_default } from "../jsx-wrapper-C8Hy0LhA.js";
1
+ import { _ as root_store_default, t as makeWrappedComponent, x as api_hmr_tracker_default } from "../jsx-wrapper-B1B_ySZF.js";
2
2
  import { SOURCE_ID_ATTRIBUTE } from "@superblocksteam/library-shared";
3
3
  import * as ReactJsxDevRuntime from "react/jsx-dev-runtime";
4
4
 
@@ -1605,6 +1605,59 @@ const generateId = () => {
1605
1605
  return Math.random().toString(36).substring(2, 15);
1606
1606
  };
1607
1607
 
1608
+ //#endregion
1609
+ //#region src/lib/internal-details/embed-store.ts
1610
+ /**
1611
+ * Store for managing embed properties and events.
1612
+ * Used when the library is embedded in an external application (third-party embedding).
1613
+ *
1614
+ * Properties can be set by the parent window via postMessage, and events can be
1615
+ * emitted back to the parent window.
1616
+ */
1617
+ var EmbedStore = class {
1618
+ properties = {};
1619
+ constructor() {
1620
+ makeAutoObservable(this);
1621
+ }
1622
+ /**
1623
+ * Update the embed properties. Called when the parent window sends updated properties.
1624
+ */
1625
+ setProperties(properties) {
1626
+ this.properties = properties;
1627
+ }
1628
+ /**
1629
+ * Emit an event to the parent window.
1630
+ * The parent can listen for these events using window.addEventListener("message", ...).
1631
+ */
1632
+ emitEvent(eventName, payload = {}) {
1633
+ if (typeof window === "undefined" || window.parent === window) return;
1634
+ window.parent.postMessage({
1635
+ type: "embed-emit-event",
1636
+ payload: {
1637
+ eventName,
1638
+ payload
1639
+ }
1640
+ }, "*");
1641
+ }
1642
+ /**
1643
+ * Typed helper for the platform-reserved
1644
+ * `superblocks:integration-auth-error` event. Emitted when an SDK API
1645
+ * execution fails the integration-auth gate (either reactively from a
1646
+ * 401/403 response or proactively from the embed shell). Hosts subscribe
1647
+ * via the embed SDK's `onEvent` and render their own connect/retry UX.
1648
+ *
1649
+ * `status` is the HTTP status that triggered the emit (401 or 403 for
1650
+ * reactive emits; the embed shell uses 401 for its proactive emit).
1651
+ * `integrationIds` are scoped to the integrations the host should drive
1652
+ * reauth for, so a host with multiple integrations can target the right
1653
+ * one.
1654
+ */
1655
+ emitIntegrationAuthError(payload) {
1656
+ this.emitEvent("superblocks:integration-auth-error", payload);
1657
+ }
1658
+ };
1659
+ const embedStore = new EmbedStore();
1660
+
1608
1661
  //#endregion
1609
1662
  //#region src/lib/internal-details/scope/types.ts
1610
1663
  const AppMode = {
@@ -2712,33 +2765,31 @@ var ApiManager = class {
2712
2765
  }
2713
2766
  if (!editMode$1 && commitId) body.commitId = commitId;
2714
2767
  const integrationIds = (this.rootStore.getApiIntegrations(apiName) ?? []).map((integration) => integration.id);
2715
- if (integrationIds.length > 0) {
2716
- const authCheckT0 = performance.now();
2717
- const authResult = await new Promise((resolve) => {
2718
- const callbackId = addNewPromise(resolve);
2719
- window.parent.postMessage({
2720
- type: "authenticate-api-request",
2721
- payload: {
2722
- apiId: apiName,
2723
- callbackId,
2724
- integrationIds
2725
- }
2726
- }, "*");
2727
- });
2728
- authCheckMs = Math.round(performance.now() - authCheckT0);
2729
- const result$1 = authResult;
2730
- if (result$1?.tokens?.token && result$1?.tokens?.accessToken) this.setTokens(result$1.tokens.token, result$1.tokens.accessToken);
2731
- if (result$1?.errors?.length) {
2732
- console.warn("[api-store] SDK API authentication failed", apiName, result$1.errors);
2733
- return {
2734
- success: false,
2735
- error: {
2736
- code: "AUTH_ERROR",
2737
- message: result$1.errors.map((e) => e.message).join("; ")
2738
- },
2739
- timingBreakdown: buildTimingBreakdown()
2740
- };
2741
- }
2768
+ const authCheckT0 = performance.now();
2769
+ const authResult = await new Promise((resolve) => {
2770
+ const callbackId = addNewPromise(resolve);
2771
+ window.parent.postMessage({
2772
+ type: "authenticate-api-request",
2773
+ payload: {
2774
+ apiId: apiName,
2775
+ callbackId,
2776
+ integrationIds
2777
+ }
2778
+ }, "*");
2779
+ });
2780
+ authCheckMs = Math.round(performance.now() - authCheckT0);
2781
+ const authData = authResult;
2782
+ if (authData?.tokens?.token && authData?.tokens?.accessToken) this.setTokens(authData.tokens.token, authData.tokens.accessToken);
2783
+ if (authData?.errors?.length) {
2784
+ console.warn("[api-store] SDK API authentication failed", apiName, authData.errors);
2785
+ return {
2786
+ success: false,
2787
+ error: {
2788
+ code: "AUTH_ERROR",
2789
+ message: authData.errors.map((e) => e.message).join("; ")
2790
+ },
2791
+ timingBreakdown: buildTimingBreakdown()
2792
+ };
2742
2793
  }
2743
2794
  const fetchStartMs = Date.now();
2744
2795
  const fetchPerfT0 = performance.now();
@@ -2764,6 +2815,12 @@ var ApiManager = class {
2764
2815
  } catch {
2765
2816
  message = text || `HTTP ${response.status}`;
2766
2817
  }
2818
+ if ((response.status === 401 || response.status === 403) && integrationIds.length > 0) embedStore.emitIntegrationAuthError({
2819
+ apiId: apiName,
2820
+ integrationIds,
2821
+ status: response.status,
2822
+ message
2823
+ });
2767
2824
  return {
2768
2825
  success: false,
2769
2826
  error: {
@@ -4183,5 +4240,5 @@ const useJSXContext = () => {
4183
4240
  };
4184
4241
 
4185
4242
  //#endregion
4186
- export { useSuperblocksProfiles as A, createManagedPropsList as B, rejectById as C, useSuperblocksContext as D, getAppMode as E, editorBridge as F, getEditStore as G, PropsCategory as H, iframeMessageHandler as I, isEmbeddedBySuperblocksFirstParty as L, generateId as M, sendNotification as N, useSuperblocksDataTags as O, colors as P, sendMessageImmediately as R, addNewPromise as S, SuperblocksContextProvider as T, Section as U, Prop as V, createPropertiesPanelDefinition as W, root_store_default as _, FixWithClarkButton as a, getContextFromTraceHeaders as b, ErrorContent as c, ErrorMessage as d, ErrorStack as f, StyledClarkIcon as g, SecondaryButton as h, getWidgetRectAnchorName as i, useSuperblocksUser as j, useSuperblocksGroups as k, ErrorDetails as l, ErrorTitle as m, useJSXContext as n, ActionsContainer as o, ErrorSummary as p, getWidgetAnchorName as r, ErrorContainer as s, makeWrappedComponent as t, ErrorIconContainer as u, startEditorSync as v, resolveById as w, api_hmr_tracker_default as x, createIframeSpan as y, isEditMode as z };
4187
- //# sourceMappingURL=jsx-wrapper-C8Hy0LhA.js.map
4243
+ export { useSuperblocksProfiles as A, isEditMode as B, rejectById as C, useSuperblocksContext as D, getAppMode as E, colors as F, createPropertiesPanelDefinition as G, Prop as H, editorBridge as I, getEditStore as K, iframeMessageHandler as L, embedStore as M, generateId as N, useSuperblocksDataTags as O, sendNotification as P, isEmbeddedBySuperblocksFirstParty as R, addNewPromise as S, SuperblocksContextProvider as T, PropsCategory as U, createManagedPropsList as V, Section as W, root_store_default as _, FixWithClarkButton as a, getContextFromTraceHeaders as b, ErrorContent as c, ErrorMessage as d, ErrorStack as f, StyledClarkIcon as g, SecondaryButton as h, getWidgetRectAnchorName as i, useSuperblocksUser as j, useSuperblocksGroups as k, ErrorDetails as l, ErrorTitle as m, useJSXContext as n, ActionsContainer as o, ErrorSummary as p, getWidgetAnchorName as r, ErrorContainer as s, makeWrappedComponent as t, ErrorIconContainer as u, startEditorSync as v, resolveById as w, api_hmr_tracker_default as x, createIframeSpan as y, sendMessageImmediately as z };
4244
+ //# sourceMappingURL=jsx-wrapper-B1B_ySZF.js.map