@superblocksteam/library 2.0.89 → 2.0.90-next.1

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 { S as api_hmr_tracker_default, _ as root_store_default, t as makeWrappedComponent } from "../jsx-wrapper-DL2O6Y1G.js";
1
+ import { S as api_hmr_tracker_default, _ as root_store_default, t as makeWrappedComponent } from "../jsx-wrapper-C8LEtdzp.js";
2
2
  import { SOURCE_ID_ATTRIBUTE } from "@superblocksteam/library-shared";
3
3
  import * as ReactJsxDevRuntime from "react/jsx-dev-runtime";
4
4
 
@@ -659,7 +659,30 @@ function parentMessageHandler(e) {
659
659
  iframeMessageHandler.dispatchEvent(event);
660
660
  }
661
661
  if (isEmbeddedBySuperblocksFirstParty() && PARENT_REF) typeof window !== "undefined" && window.addEventListener("message", parentMessageHandler);
662
- /** @deprecated Use editorBridge instead */
662
+ /**
663
+ * @deprecated Use editorBridge instead
664
+ *
665
+ * IMPORTANT: For "resolve-promise" and "reject-promise" message types:
666
+ * - callbackId MUST be at the top level of the message object
667
+ * - payload contains the resolution value or error object
668
+ * - Do NOT nest callbackId inside payload
669
+ *
670
+ * Example:
671
+ * ```typescript
672
+ * // ✅ Correct
673
+ * sendMessageImmediately({
674
+ * type: "resolve-promise",
675
+ * callbackId: "abc123",
676
+ * payload: { data: "result" }
677
+ * });
678
+ *
679
+ * // ❌ Wrong
680
+ * sendMessageImmediately({
681
+ * type: "resolve-promise",
682
+ * payload: { id: "abc123", data: "result" }
683
+ * });
684
+ * ```
685
+ */
663
686
  function sendMessageImmediately(message, options) {
664
687
  if (!PARENT_REF) {
665
688
  console.warn("PARENT_REF is not set, message not delivered. Message: ", message);
@@ -1658,18 +1681,26 @@ function useSuperblocksGroups() {
1658
1681
  }, () => context$2.groups, () => context$2.groups);
1659
1682
  return useMemo(() => toJS(groups), [groups]);
1660
1683
  }
1661
- function useSuperblocksProfiles() {
1684
+ function useSuperblocksDataTags() {
1662
1685
  const context$2 = useSuperblocksContext();
1663
- const profiles = useSyncExternalStore((onStoreChange) => {
1686
+ const dataTags = useSyncExternalStore((onStoreChange) => {
1664
1687
  return reaction(() => context$2.profiles, onStoreChange);
1665
1688
  }, () => context$2.profiles, () => context$2.profiles);
1666
1689
  return {
1667
- profiles: useMemo(() => toJS(profiles), [profiles]),
1668
- setProfile: useCallback((profileKey) => {
1669
- context$2.setProfile(profileKey);
1690
+ dataTags: useMemo(() => toJS(dataTags), [dataTags]),
1691
+ setDataTag: useCallback((dataTagKey) => {
1692
+ context$2.setProfile(dataTagKey);
1670
1693
  }, [context$2])
1671
1694
  };
1672
1695
  }
1696
+ /** @deprecated Use useSuperblocksDataTags instead */
1697
+ function useSuperblocksProfiles() {
1698
+ const { dataTags, setDataTag } = useSuperblocksDataTags();
1699
+ return {
1700
+ profiles: dataTags,
1701
+ setProfile: setDataTag
1702
+ };
1703
+ }
1673
1704
  let appMode;
1674
1705
  function getAppMode() {
1675
1706
  if (!appMode) {
@@ -2257,7 +2288,7 @@ var ApiManager = class {
2257
2288
  });
2258
2289
  await this.awaitInitApiIfNeeded();
2259
2290
  await this.awaitBootstrapIfNeeded();
2260
- const apiName = path.match(/^\/apis\/([^/]+)\/api\.yaml$/)?.[1];
2291
+ const apiName = path.match(/^\/(?:server\/)?apis\/([^/]+)\/api\.(yaml|ts)$/)?.[1];
2261
2292
  if (!apiName) {
2262
2293
  console.error("[api-store] Invalid path:", path);
2263
2294
  throw new Error(`Invalid path: ${path}`);
@@ -3027,6 +3058,14 @@ var ComponentRegistry = class {
3027
3058
 
3028
3059
  //#endregion
3029
3060
  //#region src/lib/internal-details/lib/root-store.ts
3061
+ /**
3062
+ * Default user object for when no user info is available.
3063
+ */
3064
+ const DEFAULT_SDK_USER = {
3065
+ userId: "anonymous",
3066
+ groups: [],
3067
+ customClaims: {}
3068
+ };
3030
3069
  var RootStore = class {
3031
3070
  apis;
3032
3071
  componentRegistry;
@@ -3036,6 +3075,18 @@ var RootStore = class {
3036
3075
  applicationId;
3037
3076
  userId;
3038
3077
  windowOriginUrl;
3078
+ /**
3079
+ * Current user info for SDK API execution.
3080
+ * Populated from JWT claims when available.
3081
+ */
3082
+ sdkUser = DEFAULT_SDK_USER;
3083
+ /**
3084
+ * Whether the SDK API feature is enabled.
3085
+ * Derived from the application's templateName (see `isSdkApiTemplate()`).
3086
+ * Passed to the library via the `clark.sdk-api.enabled` bootstrap flag.
3087
+ * When false, the YAML-based API system is used instead.
3088
+ */
3089
+ sdkApiEnabled = false;
3039
3090
  editorRegisteredCallbacks = [];
3040
3091
  constructor() {
3041
3092
  this.apis = new api_store_default(this);
@@ -3045,9 +3096,32 @@ var RootStore = class {
3045
3096
  editStore: observable.shallow,
3046
3097
  setEditStore: action,
3047
3098
  applicationId: observable,
3048
- userId: observable
3099
+ userId: observable,
3100
+ sdkUser: observable.ref,
3101
+ setSdkUser: action,
3102
+ sdkApiEnabled: observable,
3103
+ setSdkApiEnabled: action
3049
3104
  });
3050
3105
  }
3106
+ /**
3107
+ * Updates the SDK user info from JWT claims or bootstrap data.
3108
+ */
3109
+ setSdkUser(user) {
3110
+ this.sdkUser = {
3111
+ userId: user.userId ?? this.sdkUser.userId,
3112
+ email: user.email ?? this.sdkUser.email,
3113
+ name: user.name ?? this.sdkUser.name,
3114
+ groups: user.groups ?? this.sdkUser.groups,
3115
+ customClaims: user.customClaims ?? this.sdkUser.customClaims
3116
+ };
3117
+ }
3118
+ /**
3119
+ * Sets the SDK API feature flag state.
3120
+ * Called during bootstrap with the value from feature flags.
3121
+ */
3122
+ setSdkApiEnabled(enabled) {
3123
+ this.sdkApiEnabled = enabled;
3124
+ }
3051
3125
  setEditStore(editStore) {
3052
3126
  if (this.editStore) return;
3053
3127
  this.editStore = editStore;
@@ -3703,5 +3777,5 @@ const useJSXContext = () => {
3703
3777
  };
3704
3778
 
3705
3779
  //#endregion
3706
- export { useSuperblocksProfiles as A, PropsCategory as B, addNewPromise as C, getAppMode as D, SuperblocksContextProvider as E, iframeMessageHandler as F, createPropertiesPanelDefinition as H, isEmbeddedBySuperblocksFirstParty as I, isEditMode as L, sendNotification as M, colors as N, useSuperblocksContext as O, editorBridge as P, createManagedPropsList as R, api_hmr_tracker_default as S, resolveById as T, getEditStore as U, Section as V, root_store_default as _, FixWithClarkButton as a, createIframeSpan 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, rejectById as w, getContextFromTraceHeaders as x, generateId as y, Prop as z };
3707
- //# sourceMappingURL=jsx-wrapper-DL2O6Y1G.js.map
3780
+ export { useSuperblocksGroups as A, createManagedPropsList as B, addNewPromise as C, getAppMode as D, SuperblocksContextProvider as E, editorBridge as F, getEditStore as G, PropsCategory as H, iframeMessageHandler as I, isEmbeddedBySuperblocksFirstParty as L, useSuperblocksUser as M, sendNotification as N, useSuperblocksContext as O, colors as P, sendMessageImmediately as R, api_hmr_tracker_default as S, resolveById as T, Section as U, Prop as V, createPropertiesPanelDefinition as W, root_store_default as _, FixWithClarkButton as a, createIframeSpan as b, ErrorContent as c, ErrorMessage as d, ErrorStack as f, StyledClarkIcon as g, SecondaryButton as h, getWidgetRectAnchorName as i, useSuperblocksProfiles as j, useSuperblocksDataTags 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, rejectById as w, getContextFromTraceHeaders as x, generateId as y, isEditMode as z };
3781
+ //# sourceMappingURL=jsx-wrapper-C8LEtdzp.js.map