@superblocksteam/library 2.0.169-next.4 → 2.0.169-next.6

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.
@@ -203,6 +203,70 @@ function getEditStore() {
203
203
  return window.__SUPERBLOCKS_EDITOR_HOOK__;
204
204
  }
205
205
  //#endregion
206
+ //#region src/edit-mode/load-timings.ts
207
+ const MARK_PREFIX = "sb-load:";
208
+ const SLOWEST_RESOURCE_COUNT = 5;
209
+ /** Records the first time this iframe document reaches a load milestone. */
210
+ function markLoad(name) {
211
+ const markName = MARK_PREFIX + name;
212
+ try {
213
+ if (performance.getEntriesByName(markName, "mark").length === 0) performance.mark(markName);
214
+ } catch {}
215
+ }
216
+ function resourceCategory(path) {
217
+ if (path.includes("/deps/") || path.includes("/node_modules/")) return "dependency";
218
+ if (path.startsWith("/@")) return "vite";
219
+ if (path.startsWith("/src/")) return "app";
220
+ return "other";
221
+ }
222
+ function isNavigationTiming(entry) {
223
+ return entry.entryType === "navigation";
224
+ }
225
+ function isResourceTiming(entry) {
226
+ return entry.entryType === "resource";
227
+ }
228
+ /**
229
+ * Reads this document's load milestones and module request totals. Returns
230
+ * undefined instead of throwing so telemetry can never block `sb-ready`.
231
+ */
232
+ function getLoadTimings() {
233
+ try {
234
+ const markTime = (name) => performance.getEntriesByName(MARK_PREFIX + name, "mark")[0]?.startTime;
235
+ return summarizeLoadTimings({
236
+ timeOrigin: performance.timeOrigin,
237
+ now: performance.now(),
238
+ navigation: performance.getEntriesByType("navigation").find(isNavigationTiming),
239
+ marks: {
240
+ libraryEvaluated: markTime("libraryEvaluated"),
241
+ bootstrapRequested: markTime("bootstrapRequested"),
242
+ bootstrapReceived: markTime("bootstrapReceived")
243
+ },
244
+ resources: performance.getEntriesByType("resource").filter(isResourceTiming)
245
+ });
246
+ } catch {
247
+ return;
248
+ }
249
+ }
250
+ function summarizeLoadTimings(input) {
251
+ const { navigation, resources } = input;
252
+ return {
253
+ timeOrigin: input.timeOrigin,
254
+ responseStart: navigation?.responseStart,
255
+ responseEnd: navigation?.responseEnd,
256
+ ...input.marks,
257
+ domContentLoaded: navigation?.domContentLoadedEventEnd || void 0,
258
+ ready: input.now,
259
+ resourceCount: resources.length,
260
+ cachedResourceCount: resources.filter((r) => r.transferSize === 0 && r.decodedBodySize > 0).length,
261
+ resourceDurationSumMs: Math.round(resources.reduce((sum, r) => sum + r.duration, 0)),
262
+ slowestResources: [...resources].sort((a, b) => b.duration - a.duration).slice(0, SLOWEST_RESOURCE_COUNT).map((r) => ({
263
+ category: resourceCategory(new URL(r.name).pathname),
264
+ startMs: Math.round(r.startTime),
265
+ durationMs: Math.round(r.duration)
266
+ }))
267
+ };
268
+ }
269
+ //#endregion
206
270
  //#region src/edit-mode/message-queue.ts
207
271
  const MESSAGE_BATCH_TIME = 50;
208
272
  const DEFAULT_KEY = "default";
@@ -251,7 +315,10 @@ var SuperblocksEditorBridge = class SuperblocksEditorBridge {
251
315
  sendReady(connectionStartTime) {
252
316
  this.sendImmediate({
253
317
  type: "sb-ready",
254
- payload: { connectionStartTime }
318
+ payload: {
319
+ connectionStartTime,
320
+ loadTimings: getLoadTimings()
321
+ }
255
322
  }, true);
256
323
  }
257
324
  sendLoadError(error, source) {
@@ -2360,7 +2427,7 @@ var ApiManager = class {
2360
2427
  }
2361
2428
  if (!entryPoint && this.rootStore.sdkApiEnabled) try {
2362
2429
  const rediscoveryT0 = performance.now();
2363
- const { discoverAndRegisterSdkApis } = await import("./sdk-api-discovery-D6Xp39R4.js").then((n) => n.n);
2430
+ const { discoverAndRegisterSdkApis } = await import("./sdk-api-discovery-BIiatBdN.js").then((n) => n.n);
2364
2431
  await discoverAndRegisterSdkApis();
2365
2432
  const rediscoveryMs = Math.round(performance.now() - rediscoveryT0);
2366
2433
  discoveryMs += rediscoveryMs;
@@ -3194,6 +3261,6 @@ var RootStore = class {
3194
3261
  };
3195
3262
  var root_store_default = new RootStore();
3196
3263
  //#endregion
3197
- export { iframeMessageHandler as C, isEditMode as E, getParentOrigin as S, sendMessageImmediately as T, generateId as _, tracker as a, editorBridge as b, resolveById as c, useSuperblocksContext as d, useSuperblocksDataTags as f, embedStore as g, useSuperblocksUser as h, getContextFromTraceHeaders as i, SuperblocksContextProvider as l, useSuperblocksProfiles as m, root_store_default as n, addNewPromise as o, useSuperblocksGroups as p, createIframeSpan as r, rejectById as s, ORCHESTRATOR_EXECUTE_RESPONSE_SIZE_LIMIT_FLAG as t, getAppMode as u, sendNotification as v, isEmbeddedBySuperblocksFirstParty as w, getEditStore as x, colors as y };
3264
+ export { getParentOrigin as C, isEditMode as D, sendMessageImmediately as E, getEditStore as S, isEmbeddedBySuperblocksFirstParty as T, generateId as _, tracker as a, editorBridge as b, resolveById as c, useSuperblocksContext as d, useSuperblocksDataTags as f, embedStore as g, useSuperblocksUser as h, getContextFromTraceHeaders as i, SuperblocksContextProvider as l, useSuperblocksProfiles as m, root_store_default as n, addNewPromise as o, useSuperblocksGroups as p, createIframeSpan as r, rejectById as s, ORCHESTRATOR_EXECUTE_RESPONSE_SIZE_LIMIT_FLAG as t, getAppMode as u, sendNotification as v, iframeMessageHandler as w, markLoad as x, colors as y };
3198
3265
 
3199
- //# sourceMappingURL=root-store-B4NzJHt8.js.map
3266
+ //# sourceMappingURL=root-store-cNRXF6N6.js.map