@superblocksteam/library 2.0.115-next.0 → 2.0.115-next.2
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/jsx-dev-runtime/index.js +1 -1
- package/dist/{jsx-wrapper-BCVlG9Wg.js → jsx-wrapper-C8Hy0LhA.js} +66 -13
- package/dist/jsx-wrapper-C8Hy0LhA.js.map +1 -0
- package/dist/lib/index.d.ts +11 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +27 -11
- package/dist/lib/index.js.map +1 -1
- package/package.json +8 -8
- package/dist/jsx-wrapper-BCVlG9Wg.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as root_store_default, t as makeWrappedComponent, x as api_hmr_tracker_default } from "../jsx-wrapper-
|
|
1
|
+
import { _ as root_store_default, t as makeWrappedComponent, x as api_hmr_tracker_default } from "../jsx-wrapper-C8Hy0LhA.js";
|
|
2
2
|
import { SOURCE_ID_ATTRIBUTE } from "@superblocksteam/library-shared";
|
|
3
3
|
import * as ReactJsxDevRuntime from "react/jsx-dev-runtime";
|
|
4
4
|
|
|
@@ -2212,6 +2212,20 @@ var ApiManager = class {
|
|
|
2212
2212
|
waitForBootstrapPromise = void 0;
|
|
2213
2213
|
resolveBootstrapPromise = void 0;
|
|
2214
2214
|
callContexts = {};
|
|
2215
|
+
/**
|
|
2216
|
+
* Flush pending file writes to DBFS, logging a warning if it blocks for
|
|
2217
|
+
* >50ms. Returns the elapsed time in ms so callers can record it in the
|
|
2218
|
+
* execution timing breakdown.
|
|
2219
|
+
*/
|
|
2220
|
+
async timedEnsureFilesSynced(label) {
|
|
2221
|
+
const opManager = this.rootStore.editStore?.operationManager;
|
|
2222
|
+
if (!opManager) return 0;
|
|
2223
|
+
const t0 = performance.now();
|
|
2224
|
+
await opManager.ensureFilesSynced();
|
|
2225
|
+
const ms = Math.round(performance.now() - t0);
|
|
2226
|
+
if (ms > 50) console.warn(`[api-store] ensureFilesSynced blocked ${label} for ${String(ms)}ms`);
|
|
2227
|
+
return ms;
|
|
2228
|
+
}
|
|
2215
2229
|
constructor(rootStore) {
|
|
2216
2230
|
this.rootStore = rootStore;
|
|
2217
2231
|
this.waitForBootstrapPromise = new Promise((resolve) => {
|
|
@@ -2265,6 +2279,13 @@ var ApiManager = class {
|
|
|
2265
2279
|
}
|
|
2266
2280
|
notifyBootstrapComplete() {
|
|
2267
2281
|
if (this.resolveBootstrapPromise) this.resolveBootstrapPromise();
|
|
2282
|
+
this.prewarmExecutionPath();
|
|
2283
|
+
}
|
|
2284
|
+
async prewarmExecutionPath() {
|
|
2285
|
+
try {
|
|
2286
|
+
await this.rootStore.awaitDiscovery();
|
|
2287
|
+
await this.rootStore.editStore?.operationManager.ensureFilesSynced();
|
|
2288
|
+
} catch {}
|
|
2268
2289
|
}
|
|
2269
2290
|
loadApiManifest({ apis = {} }) {
|
|
2270
2291
|
const apisToSet = Object.values(apis).map(({ api, scopeId }) => {
|
|
@@ -2420,7 +2441,7 @@ var ApiManager = class {
|
|
|
2420
2441
|
const orchestratorUrl = new URL("v2/execute", agentBaseUrl).href;
|
|
2421
2442
|
const profileId = context$1.profiles?.selected?.id ?? "";
|
|
2422
2443
|
const events = [];
|
|
2423
|
-
await this.
|
|
2444
|
+
await this.timedEnsureFilesSynced("executeApi");
|
|
2424
2445
|
const abortController = new AbortController();
|
|
2425
2446
|
(this.runningApiControllers[apiName] ??= /* @__PURE__ */ new Set()).add(abortController);
|
|
2426
2447
|
const editMode$1 = isEditMode();
|
|
@@ -2605,14 +2626,28 @@ var ApiManager = class {
|
|
|
2605
2626
|
* caller doesn't need to resolve them through the parent frame.
|
|
2606
2627
|
*/
|
|
2607
2628
|
async executeSdkApiV3(apiName, inputs, options) {
|
|
2629
|
+
const timingT0 = performance.now();
|
|
2608
2630
|
await this.awaitBootstrapIfNeeded();
|
|
2631
|
+
const bootstrapMs = Math.round(performance.now() - timingT0);
|
|
2632
|
+
let authCheckMs = 0;
|
|
2633
|
+
let discoveryMs = 0;
|
|
2634
|
+
let fileSyncMs = 0;
|
|
2635
|
+
let networkMs;
|
|
2636
|
+
const buildTimingBreakdown = () => ({
|
|
2637
|
+
authCheckMs,
|
|
2638
|
+
bootstrapMs,
|
|
2639
|
+
discoveryMs,
|
|
2640
|
+
fileSyncMs,
|
|
2641
|
+
networkMs
|
|
2642
|
+
});
|
|
2609
2643
|
const applicationId = this.rootStore.applicationId;
|
|
2610
2644
|
if (!applicationId) return {
|
|
2611
2645
|
success: false,
|
|
2612
2646
|
error: {
|
|
2613
2647
|
code: "NO_APP_ID",
|
|
2614
2648
|
message: "No application ID found"
|
|
2615
|
-
}
|
|
2649
|
+
},
|
|
2650
|
+
timingBreakdown: buildTimingBreakdown()
|
|
2616
2651
|
};
|
|
2617
2652
|
const abortController = new AbortController();
|
|
2618
2653
|
(this.runningApiControllers[apiName] ??= /* @__PURE__ */ new Set()).add(abortController);
|
|
@@ -2622,7 +2657,10 @@ var ApiManager = class {
|
|
|
2622
2657
|
try {
|
|
2623
2658
|
let entryPoint = this.rootStore.getApiEntryPoint(apiName);
|
|
2624
2659
|
if (!entryPoint) {
|
|
2660
|
+
const discoveryT0 = performance.now();
|
|
2625
2661
|
await this.rootStore.awaitDiscovery();
|
|
2662
|
+
discoveryMs = Math.round(performance.now() - discoveryT0);
|
|
2663
|
+
if (discoveryMs > 50) console.warn(`[api-store] awaitDiscovery blocked executeSdkApiV3(${apiName}) for ${String(discoveryMs)}ms`);
|
|
2626
2664
|
entryPoint = this.rootStore.getApiEntryPoint(apiName);
|
|
2627
2665
|
}
|
|
2628
2666
|
if (!entryPoint) return {
|
|
@@ -2630,9 +2668,10 @@ var ApiManager = class {
|
|
|
2630
2668
|
error: {
|
|
2631
2669
|
code: "UNKNOWN_API",
|
|
2632
2670
|
message: `No entryPoint registered for API "${apiName}". Was it discovered?`
|
|
2633
|
-
}
|
|
2671
|
+
},
|
|
2672
|
+
timingBreakdown: buildTimingBreakdown()
|
|
2634
2673
|
};
|
|
2635
|
-
await this.
|
|
2674
|
+
fileSyncMs = await this.timedEnsureFilesSynced(`executeSdkApiV3(${apiName})`);
|
|
2636
2675
|
const profile = this.rootStore.profile;
|
|
2637
2676
|
const editModeBranchName = this.rootStore.branchName ?? "main";
|
|
2638
2677
|
const commitId = this.rootStore.commitId;
|
|
@@ -2653,7 +2692,8 @@ var ApiManager = class {
|
|
|
2653
2692
|
error: {
|
|
2654
2693
|
code: "NO_AGENT",
|
|
2655
2694
|
message: "Unable to resolve agent for API execution"
|
|
2656
|
-
}
|
|
2695
|
+
},
|
|
2696
|
+
timingBreakdown: buildTimingBreakdown()
|
|
2657
2697
|
};
|
|
2658
2698
|
const { inputs: finalInputs, files } = await getInputsWithFileMetadata(inputs);
|
|
2659
2699
|
const body = {
|
|
@@ -2673,7 +2713,8 @@ var ApiManager = class {
|
|
|
2673
2713
|
if (!editMode$1 && commitId) body.commitId = commitId;
|
|
2674
2714
|
const integrationIds = (this.rootStore.getApiIntegrations(apiName) ?? []).map((integration) => integration.id);
|
|
2675
2715
|
if (integrationIds.length > 0) {
|
|
2676
|
-
const
|
|
2716
|
+
const authCheckT0 = performance.now();
|
|
2717
|
+
const authResult = await new Promise((resolve) => {
|
|
2677
2718
|
const callbackId = addNewPromise(resolve);
|
|
2678
2719
|
window.parent.postMessage({
|
|
2679
2720
|
type: "authenticate-api-request",
|
|
@@ -2684,6 +2725,8 @@ var ApiManager = class {
|
|
|
2684
2725
|
}
|
|
2685
2726
|
}, "*");
|
|
2686
2727
|
});
|
|
2728
|
+
authCheckMs = Math.round(performance.now() - authCheckT0);
|
|
2729
|
+
const result$1 = authResult;
|
|
2687
2730
|
if (result$1?.tokens?.token && result$1?.tokens?.accessToken) this.setTokens(result$1.tokens.token, result$1.tokens.accessToken);
|
|
2688
2731
|
if (result$1?.errors?.length) {
|
|
2689
2732
|
console.warn("[api-store] SDK API authentication failed", apiName, result$1.errors);
|
|
@@ -2692,11 +2735,13 @@ var ApiManager = class {
|
|
|
2692
2735
|
error: {
|
|
2693
2736
|
code: "AUTH_ERROR",
|
|
2694
2737
|
message: result$1.errors.map((e) => e.message).join("; ")
|
|
2695
|
-
}
|
|
2738
|
+
},
|
|
2739
|
+
timingBreakdown: buildTimingBreakdown()
|
|
2696
2740
|
};
|
|
2697
2741
|
}
|
|
2698
2742
|
}
|
|
2699
2743
|
const fetchStartMs = Date.now();
|
|
2744
|
+
const fetchPerfT0 = performance.now();
|
|
2700
2745
|
const response = await fetch(`${agentBaseUrl}v3/execute`, {
|
|
2701
2746
|
method: "POST",
|
|
2702
2747
|
credentials: "include",
|
|
@@ -2711,6 +2756,7 @@ var ApiManager = class {
|
|
|
2711
2756
|
});
|
|
2712
2757
|
if (!response.ok) {
|
|
2713
2758
|
const text = await response.text();
|
|
2759
|
+
networkMs = Math.round(performance.now() - fetchPerfT0);
|
|
2714
2760
|
let message;
|
|
2715
2761
|
try {
|
|
2716
2762
|
const json = JSON.parse(text);
|
|
@@ -2723,14 +2769,17 @@ var ApiManager = class {
|
|
|
2723
2769
|
error: {
|
|
2724
2770
|
code: "SYSTEM_ERROR",
|
|
2725
2771
|
message
|
|
2726
|
-
}
|
|
2772
|
+
},
|
|
2773
|
+
timingBreakdown: buildTimingBreakdown()
|
|
2727
2774
|
};
|
|
2728
2775
|
}
|
|
2729
2776
|
const result = await response.json();
|
|
2777
|
+
networkMs = Math.round(performance.now() - fetchPerfT0);
|
|
2730
2778
|
const eventPerf = result.events?.find((e) => e.end?.performance != null);
|
|
2731
2779
|
const perfObj = result.performance ?? (eventPerf?.end)?.performance;
|
|
2732
2780
|
const executionStartMs = perfObj?.start != null && Number.isFinite(Number(perfObj.start)) ? Number(perfObj.start) : void 0;
|
|
2733
2781
|
const executionDurationMs = perfObj?.total != null && Number.isFinite(Number(perfObj.total)) ? Number(perfObj.total) : void 0;
|
|
2782
|
+
const timingBreakdown = buildTimingBreakdown();
|
|
2734
2783
|
if (result.errors?.length) return {
|
|
2735
2784
|
success: false,
|
|
2736
2785
|
error: {
|
|
@@ -2740,7 +2789,8 @@ var ApiManager = class {
|
|
|
2740
2789
|
diagnostics: result.diagnostics,
|
|
2741
2790
|
executionStartMs,
|
|
2742
2791
|
executionDurationMs,
|
|
2743
|
-
fetchStartMs
|
|
2792
|
+
fetchStartMs,
|
|
2793
|
+
timingBreakdown
|
|
2744
2794
|
};
|
|
2745
2795
|
return {
|
|
2746
2796
|
success: true,
|
|
@@ -2748,7 +2798,8 @@ var ApiManager = class {
|
|
|
2748
2798
|
diagnostics: result.diagnostics,
|
|
2749
2799
|
executionStartMs,
|
|
2750
2800
|
executionDurationMs,
|
|
2751
|
-
fetchStartMs
|
|
2801
|
+
fetchStartMs,
|
|
2802
|
+
timingBreakdown
|
|
2752
2803
|
};
|
|
2753
2804
|
} catch (error) {
|
|
2754
2805
|
if (error instanceof Error && error.name === "AbortError") return {
|
|
@@ -2756,7 +2807,8 @@ var ApiManager = class {
|
|
|
2756
2807
|
error: {
|
|
2757
2808
|
code: "ABORTED",
|
|
2758
2809
|
message: `API "${apiName}" execution was aborted`
|
|
2759
|
-
}
|
|
2810
|
+
},
|
|
2811
|
+
timingBreakdown: buildTimingBreakdown()
|
|
2760
2812
|
};
|
|
2761
2813
|
console.error(`[api-store] executeSdkApiV3 failed for "${apiName}":`, error);
|
|
2762
2814
|
return {
|
|
@@ -2764,7 +2816,8 @@ var ApiManager = class {
|
|
|
2764
2816
|
error: {
|
|
2765
2817
|
code: "NETWORK_ERROR",
|
|
2766
2818
|
message: error instanceof Error ? error.message : "Network error occurred"
|
|
2767
|
-
}
|
|
2819
|
+
},
|
|
2820
|
+
timingBreakdown: buildTimingBreakdown()
|
|
2768
2821
|
};
|
|
2769
2822
|
} finally {
|
|
2770
2823
|
options?.signal?.removeEventListener("abort", forwardAbort);
|
|
@@ -4131,4 +4184,4 @@ const useJSXContext = () => {
|
|
|
4131
4184
|
|
|
4132
4185
|
//#endregion
|
|
4133
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 };
|
|
4134
|
-
//# sourceMappingURL=jsx-wrapper-
|
|
4187
|
+
//# sourceMappingURL=jsx-wrapper-C8Hy0LhA.js.map
|