@superblocksteam/library 2.0.70-next.2 → 2.0.70-next.4

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-DZ9RpgLV.js";
1
+ import { S as api_hmr_tracker_default, _ as root_store_default, t as makeWrappedComponent } from "../jsx-wrapper-DT5FMME0.js";
2
2
  import "../utils-Clb3lSiX.js";
3
3
  import { SOURCE_ID_ATTRIBUTE } from "@superblocksteam/library-shared";
4
4
  import * as ReactJsxDevRuntime from "react/jsx-dev-runtime";
@@ -1650,120 +1650,6 @@ function rejectById(id, payload) {
1650
1650
  }
1651
1651
  }
1652
1652
 
1653
- //#endregion
1654
- //#region src/lib/internal-details/lib/features/api-activity-tracker.ts
1655
- /**
1656
- * Tracks in-flight API requests to enable waiting for APIs to settle
1657
- * before capturing screenshots. This is used by the screenshot handler
1658
- * to avoid capturing loading states.
1659
- */
1660
- const API_ACTIVITY_EVENT = "sb-api-activity-changed";
1661
- var ApiActivityTracker = class {
1662
- inFlightTokens = /* @__PURE__ */ new Set();
1663
- lastActivityTime = Date.now();
1664
- eventTarget = new EventTarget();
1665
- /**
1666
- * Call when an API request starts.
1667
- * Returns a unique token that must be passed to trackEnd().
1668
- */
1669
- trackStart() {
1670
- const token = Symbol("api-request");
1671
- this.inFlightTokens.add(token);
1672
- this.lastActivityTime = Date.now();
1673
- console.log(`[ApiActivityTracker] API started. In-flight count: ${this.inFlightTokens.size}`);
1674
- this.emitChange();
1675
- return token;
1676
- }
1677
- /**
1678
- * Call when an API request completes (success, error, or cancellation).
1679
- * The token must match the one returned by trackStart().
1680
- * Calling with an unknown or already-ended token is a no-op (guards against double trackEnd).
1681
- */
1682
- trackEnd(token) {
1683
- if (!this.inFlightTokens.has(token)) return;
1684
- this.inFlightTokens.delete(token);
1685
- this.lastActivityTime = Date.now();
1686
- console.log(`[ApiActivityTracker] API finished. In-flight count: ${this.inFlightTokens.size}`);
1687
- this.emitChange();
1688
- }
1689
- /**
1690
- * Get the current in-flight count.
1691
- */
1692
- get inFlightCount() {
1693
- return this.inFlightTokens.size;
1694
- }
1695
- /**
1696
- * Get the current API activity state.
1697
- */
1698
- getState() {
1699
- return {
1700
- inFlightCount: this.inFlightTokens.size,
1701
- lastActivityTime: this.lastActivityTime
1702
- };
1703
- }
1704
- /**
1705
- * Check if there are any in-flight API requests.
1706
- */
1707
- isIdle() {
1708
- return this.inFlightTokens.size === 0;
1709
- }
1710
- /**
1711
- * Wait for all APIs to become idle, with a timeout.
1712
- * Resolves when either:
1713
- * - All in-flight requests complete
1714
- * - The timeout is reached
1715
- *
1716
- * @param timeoutMs Maximum time to wait (default: 10000ms)
1717
- * @returns Promise that resolves with { timedOut: boolean }
1718
- */
1719
- waitForIdle(timeoutMs = 1e4) {
1720
- return new Promise((resolve) => {
1721
- if (this.isIdle()) {
1722
- console.log(`[ApiActivityTracker] waitForIdle: Already idle, resolving immediately`);
1723
- resolve({ timedOut: false });
1724
- return;
1725
- }
1726
- console.log(`[ApiActivityTracker] waitForIdle: Waiting for ${this.inFlightTokens.size} in-flight request(s) to complete (timeout: ${timeoutMs}ms)`);
1727
- let resolved = false;
1728
- const timeoutId = setTimeout(() => {
1729
- if (resolved) return;
1730
- if (this.isIdle()) {
1731
- resolved = true;
1732
- this.eventTarget.removeEventListener(API_ACTIVITY_EVENT, handleChange);
1733
- console.log(`[ApiActivityTracker] waitForIdle: All APIs now idle, proceeding`);
1734
- resolve({ timedOut: false });
1735
- return;
1736
- }
1737
- console.warn(`[ApiActivityTracker] Timeout waiting for APIs to become idle after ${timeoutMs}ms. ${this.inFlightTokens.size} request(s) still in flight.`);
1738
- this.eventTarget.removeEventListener(API_ACTIVITY_EVENT, handleChange);
1739
- resolve({ timedOut: true });
1740
- }, timeoutMs);
1741
- const handleChange = () => {
1742
- if (resolved) return;
1743
- if (this.isIdle()) {
1744
- resolved = true;
1745
- clearTimeout(timeoutId);
1746
- this.eventTarget.removeEventListener(API_ACTIVITY_EVENT, handleChange);
1747
- console.log(`[ApiActivityTracker] waitForIdle: All APIs now idle, proceeding`);
1748
- resolve({ timedOut: false });
1749
- }
1750
- };
1751
- this.eventTarget.addEventListener(API_ACTIVITY_EVENT, handleChange);
1752
- });
1753
- }
1754
- /**
1755
- * Reset the tracker state. Useful for testing.
1756
- */
1757
- reset() {
1758
- this.inFlightTokens.clear();
1759
- this.lastActivityTime = Date.now();
1760
- }
1761
- emitChange() {
1762
- this.eventTarget.dispatchEvent(new Event(API_ACTIVITY_EVENT));
1763
- }
1764
- };
1765
- const apiActivityTracker = new ApiActivityTracker();
1766
-
1767
1653
  //#endregion
1768
1654
  //#region src/lib/internal-details/lib/features/api-hmr-tracker.ts
1769
1655
  var ApiHmrTracker = class ApiHmrTracker {
@@ -2251,28 +2137,23 @@ var ApiManager = class {
2251
2137
  console.debug("[api-store.runApiByPath] Extracted apiName:", apiName);
2252
2138
  editorBridge.setApiStarted(apiName);
2253
2139
  console.debug("[api-store.runApiByPath] Executing API internally...");
2254
- const activityToken = isEditMode() ? apiActivityTracker.trackStart() : void 0;
2255
- try {
2256
- const result = await this.executeApi({
2257
- apiId: apiName,
2258
- apiName,
2259
- path,
2260
- inputs,
2261
- options: inputs ?? {},
2262
- callId,
2263
- isTestRun,
2264
- callback,
2265
- injectedCallerId
2266
- });
2267
- console.debug("[api-store.runApiByPath] Execution complete, calling setApiResponse for:", apiName);
2268
- editorBridge.setApiResponse(apiName, result.parsedResult);
2269
- return {
2270
- data: result.data,
2271
- error: result.error
2272
- };
2273
- } finally {
2274
- if (activityToken) apiActivityTracker.trackEnd(activityToken);
2275
- }
2140
+ const result = await this.executeApi({
2141
+ apiId: apiName,
2142
+ apiName,
2143
+ path,
2144
+ inputs,
2145
+ options: inputs ?? {},
2146
+ callId,
2147
+ isTestRun,
2148
+ callback,
2149
+ injectedCallerId
2150
+ });
2151
+ console.debug("[api-store.runApiByPath] Execution complete, calling setApiResponse for:", apiName);
2152
+ editorBridge.setApiResponse(apiName, result.parsedResult);
2153
+ return {
2154
+ data: result.data,
2155
+ error: result.error
2156
+ };
2276
2157
  }
2277
2158
  getHMRCallHash(params) {
2278
2159
  return `${params.injectedCallerId ?? ""}-${params.apiId}`;
@@ -3664,5 +3545,5 @@ const useJSXContext = () => {
3664
3545
  };
3665
3546
 
3666
3547
  //#endregion
3667
- export { useSuperblocksProfiles as A, PropsCategory as B, apiActivityTracker 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 };
3668
- //# sourceMappingURL=jsx-wrapper-DZ9RpgLV.js.map
3548
+ export { useSuperblocksUser as A, Section as B, rejectById as C, useSuperblocksContext as D, getAppMode as E, isEmbeddedBySuperblocksFirstParty as F, getEditStore as H, isEditMode as I, createManagedPropsList as L, colors as M, editorBridge as N, useSuperblocksGroups as O, iframeMessageHandler as P, Prop as R, api_hmr_tracker_default as S, SuperblocksContextProvider as T, createPropertiesPanelDefinition 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, sendNotification as j, useSuperblocksProfiles 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, getContextFromTraceHeaders as x, generateId as y, PropsCategory as z };
3549
+ //# sourceMappingURL=jsx-wrapper-DT5FMME0.js.map