@workflow/web 5.0.0-beta.42 → 5.0.0-beta.43

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 +1 @@
1
- window.__reactRouterManifest={"entry":{"module":"/assets/entry.client-LwI3HNYl.js","imports":["/assets/index-PFjW8YjQ.js"],"css":[]},"routes":{"root":{"id":"root","path":"","hasAction":true,"hasLoader":true,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":true,"hasErrorBoundary":true,"module":"/assets/root-BfhMCbkz.js","imports":["/assets/index-PFjW8YjQ.js","/assets/mermaid-3ZIDBTTL-gEw-Ch1C.js","/assets/loader-circle-BOxaTUjK.js","/assets/arrow-up-right-D39pnGsD.js"],"css":["/assets/root-Bl5xphvU.css","/assets/mermaid-3ZIDBTTL-D8CjRQta.css"]},"routes/home":{"id":"routes/home","parentId":"root","index":true,"hasAction":false,"hasLoader":false,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":true,"hasErrorBoundary":false,"module":"/assets/home-C6CuMqQu.js","imports":["/assets/index-PFjW8YjQ.js","/assets/workflow-graph-viewer-CxrWityD.js","/assets/mermaid-3ZIDBTTL-gEw-Ch1C.js","/assets/loader-circle-BOxaTUjK.js"],"css":["/assets/workflow-graph-viewer-DnlNuQQH.css","/assets/mermaid-3ZIDBTTL-D8CjRQta.css"]},"routes/run-detail":{"id":"routes/run-detail","parentId":"root","path":"run/:runId","hasAction":false,"hasLoader":false,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":true,"hasErrorBoundary":false,"module":"/assets/run-detail-DKz7lp2q.js","imports":["/assets/index-PFjW8YjQ.js","/assets/workflow-graph-viewer-CxrWityD.js","/assets/mermaid-3ZIDBTTL-gEw-Ch1C.js","/assets/arrow-up-right-D39pnGsD.js"],"css":["/assets/run-detail-CWoGxu_0.css","/assets/workflow-graph-viewer-DnlNuQQH.css","/assets/mermaid-3ZIDBTTL-D8CjRQta.css"]},"routes/api.rpc":{"id":"routes/api.rpc","parentId":"root","path":"api/rpc","hasAction":true,"hasLoader":true,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":false,"hasErrorBoundary":false,"module":"/assets/api.rpc-l0sNRNKZ.js","imports":[],"css":[]},"routes/api.stream.$streamId":{"id":"routes/api.stream.$streamId","parentId":"root","path":"api/stream/:streamId","hasAction":false,"hasLoader":true,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":false,"hasErrorBoundary":false,"module":"/assets/api.stream._streamId-l0sNRNKZ.js","imports":[],"css":[]}},"url":"/assets/manifest-cf88886b.js","version":"cf88886b"};
1
+ window.__reactRouterManifest={"entry":{"module":"/assets/entry.client-LwI3HNYl.js","imports":["/assets/index-PFjW8YjQ.js"],"css":[]},"routes":{"root":{"id":"root","path":"","hasAction":true,"hasLoader":true,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":true,"hasErrorBoundary":true,"module":"/assets/root-BfhMCbkz.js","imports":["/assets/index-PFjW8YjQ.js","/assets/mermaid-3ZIDBTTL-gEw-Ch1C.js","/assets/loader-circle-BOxaTUjK.js","/assets/arrow-up-right-D39pnGsD.js"],"css":["/assets/root-Bl5xphvU.css","/assets/mermaid-3ZIDBTTL-D8CjRQta.css"]},"routes/home":{"id":"routes/home","parentId":"root","index":true,"hasAction":false,"hasLoader":false,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":true,"hasErrorBoundary":false,"module":"/assets/home-C6CuMqQu.js","imports":["/assets/index-PFjW8YjQ.js","/assets/workflow-graph-viewer-CxrWityD.js","/assets/mermaid-3ZIDBTTL-gEw-Ch1C.js","/assets/loader-circle-BOxaTUjK.js"],"css":["/assets/workflow-graph-viewer-DnlNuQQH.css","/assets/mermaid-3ZIDBTTL-D8CjRQta.css"]},"routes/run-detail":{"id":"routes/run-detail","parentId":"root","path":"run/:runId","hasAction":false,"hasLoader":false,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":true,"hasErrorBoundary":false,"module":"/assets/run-detail-BG_1K2Hq.js","imports":["/assets/index-PFjW8YjQ.js","/assets/workflow-graph-viewer-CxrWityD.js","/assets/mermaid-3ZIDBTTL-gEw-Ch1C.js","/assets/arrow-up-right-D39pnGsD.js"],"css":["/assets/run-detail-CWoGxu_0.css","/assets/workflow-graph-viewer-DnlNuQQH.css","/assets/mermaid-3ZIDBTTL-D8CjRQta.css"]},"routes/api.rpc":{"id":"routes/api.rpc","parentId":"root","path":"api/rpc","hasAction":true,"hasLoader":true,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":false,"hasErrorBoundary":false,"module":"/assets/api.rpc-l0sNRNKZ.js","imports":[],"css":[]},"routes/api.stream.$streamId":{"id":"routes/api.stream.$streamId","parentId":"root","path":"api/stream/:streamId","hasAction":false,"hasLoader":true,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":false,"hasErrorBoundary":false,"module":"/assets/api.stream._streamId-l0sNRNKZ.js","imports":[],"css":[]}},"url":"/assets/manifest-157e28f1.js","version":"157e28f1"};
@@ -324,6 +324,33 @@ function getMiddleTruncateCopyTextFromSelectionText({ prefixText, selectionText,
324
324
  });
325
325
  return mappedText === null ? null : leading + mappedText + trailing;
326
326
  }
327
+ const pendingMeasurements = /* @__PURE__ */ new Map();
328
+ let measurementFrame = 0;
329
+ function flushMeasurements() {
330
+ measurementFrame = 0;
331
+ const reads = [...pendingMeasurements.values()];
332
+ pendingMeasurements.clear();
333
+ const measures = reads.map((read) => read());
334
+ for (const measure of measures) {
335
+ measure == null ? void 0 : measure();
336
+ }
337
+ }
338
+ function scheduleMeasurement(key, { read, measure }) {
339
+ pendingMeasurements.set(key, () => {
340
+ const measurement = read();
341
+ return measurement === null ? null : () => measure(measurement);
342
+ });
343
+ if (measurementFrame === 0) {
344
+ measurementFrame = requestAnimationFrame(flushMeasurements);
345
+ }
346
+ }
347
+ function cancelMeasurement(key) {
348
+ pendingMeasurements.delete(key);
349
+ if (pendingMeasurements.size === 0 && measurementFrame !== 0) {
350
+ cancelAnimationFrame(measurementFrame);
351
+ measurementFrame = 0;
352
+ }
353
+ }
327
354
  const useIsomorphicLayoutEffect = typeof window === "undefined" ? reactExports.useEffect : reactExports.useLayoutEffect;
328
355
  function createFullState(value, graphemes) {
329
356
  return {
@@ -341,7 +368,13 @@ function useMiddleTruncate(value) {
341
368
  const ref = reactExports.useRef(null);
342
369
  const measureRef = reactExports.useRef(null);
343
370
  const [state, setState] = reactExports.useState(() => fullState);
344
- const rafRef = reactExports.useRef(0);
371
+ const measurementKeyRef = reactExports.useRef({});
372
+ const textMeasurementCacheRef = reactExports.useRef({
373
+ typography: "",
374
+ value,
375
+ widths: /* @__PURE__ */ new Map()
376
+ });
377
+ const lastMeasurementRef = reactExports.useRef(null);
345
378
  const updateState = reactExports.useCallback((nextState) => {
346
379
  setState((currentState) => {
347
380
  if (currentState.displayText === nextState.displayText && currentState.isTruncated === nextState.isTruncated && currentState.prefixText === nextState.prefixText && currentState.prefixGraphemeCount === nextState.prefixGraphemeCount && currentState.suffixText === nextState.suffixText && currentState.suffixGraphemeCount === nextState.suffixGraphemeCount) {
@@ -350,26 +383,68 @@ function useMiddleTruncate(value) {
350
383
  return nextState;
351
384
  });
352
385
  }, []);
353
- const recalculate = reactExports.useCallback(() => {
386
+ const readMeasurement = reactExports.useCallback(() => {
354
387
  const el = ref.current;
355
388
  const measureEl = measureRef.current;
356
389
  if (!el || !measureEl)
390
+ return null;
391
+ const availableWidth = el.clientWidth;
392
+ const style = getComputedStyle(measureEl);
393
+ return {
394
+ availableWidth,
395
+ typography: [
396
+ style.fontFamily,
397
+ style.fontFeatureSettings,
398
+ style.fontKerning,
399
+ style.fontSize,
400
+ style.fontStretch,
401
+ style.fontStyle,
402
+ style.fontVariationSettings,
403
+ style.fontWeight,
404
+ style.letterSpacing,
405
+ style.textTransform
406
+ ].join("\0")
407
+ };
408
+ }, []);
409
+ const recalculate = reactExports.useCallback(({ availableWidth, typography }) => {
410
+ const measureEl = measureRef.current;
411
+ if (!measureEl)
357
412
  return;
358
- const available = el.clientWidth;
359
- if (available <= 0) {
413
+ const lastMeasurement = lastMeasurementRef.current;
414
+ if ((lastMeasurement == null ? void 0 : lastMeasurement.availableWidth) === availableWidth && lastMeasurement.typography === typography && lastMeasurement.value === value) {
415
+ return;
416
+ }
417
+ lastMeasurementRef.current = {
418
+ availableWidth,
419
+ typography,
420
+ value
421
+ };
422
+ if (availableWidth <= 0) {
360
423
  updateState(fullState);
361
424
  return;
362
425
  }
426
+ const textMeasurementCache = textMeasurementCacheRef.current;
427
+ if (textMeasurementCache.typography !== typography || textMeasurementCache.value !== value) {
428
+ textMeasurementCache.typography = typography;
429
+ textMeasurementCache.value = value;
430
+ textMeasurementCache.widths.clear();
431
+ }
363
432
  const measure = (text) => {
433
+ const cachedWidth = textMeasurementCache.widths.get(text);
434
+ if (cachedWidth !== void 0) {
435
+ return cachedWidth;
436
+ }
364
437
  measureEl.textContent = text;
365
- return measureEl.scrollWidth;
438
+ const width = measureEl.scrollWidth;
439
+ textMeasurementCache.widths.set(text, width);
440
+ return width;
366
441
  };
367
442
  const fullWidth = measure(value);
368
- if (fullWidth <= available) {
443
+ if (fullWidth <= availableWidth) {
369
444
  updateState(fullState);
370
445
  return;
371
446
  }
372
- const result = middleTruncate(graphemes, available, measure, fullWidth);
447
+ const result = middleTruncate(graphemes, availableWidth, measure, fullWidth);
373
448
  updateState({
374
449
  displayText: result.text,
375
450
  isTruncated: result.truncated,
@@ -380,33 +455,45 @@ function useMiddleTruncate(value) {
380
455
  });
381
456
  }, [fullState, graphemes, updateState, value]);
382
457
  useIsomorphicLayoutEffect(() => {
383
- recalculate();
384
- }, [recalculate]);
458
+ const measurement = readMeasurement();
459
+ if (measurement) {
460
+ recalculate(measurement);
461
+ }
462
+ }, [readMeasurement, recalculate]);
385
463
  reactExports.useEffect(() => {
386
464
  var _a;
387
465
  const el = ref.current;
388
466
  if (!el)
389
467
  return;
390
- const debouncedRecalc = () => {
391
- cancelAnimationFrame(rafRef.current);
392
- rafRef.current = requestAnimationFrame(recalculate);
468
+ const measurementKey = measurementKeyRef.current;
469
+ const scheduleRecalculation = () => {
470
+ scheduleMeasurement(measurementKey, {
471
+ read: readMeasurement,
472
+ measure: recalculate
473
+ });
393
474
  };
394
- const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(debouncedRecalc) : null;
475
+ const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(scheduleRecalculation) : null;
395
476
  ro == null ? void 0 : ro.observe(el);
396
- window.addEventListener("resize", debouncedRecalc);
477
+ if (!ro) {
478
+ window.addEventListener("resize", scheduleRecalculation);
479
+ }
397
480
  const onFontsLoaded = () => {
398
- debouncedRecalc();
481
+ textMeasurementCacheRef.current.widths.clear();
482
+ lastMeasurementRef.current = null;
483
+ scheduleRecalculation();
399
484
  };
400
485
  const fontSet = "fonts" in document ? document.fonts : null;
401
486
  (_a = fontSet == null ? void 0 : fontSet.addEventListener) == null ? void 0 : _a.call(fontSet, "loadingdone", onFontsLoaded);
402
487
  return () => {
403
488
  var _a2;
404
489
  ro == null ? void 0 : ro.disconnect();
405
- window.removeEventListener("resize", debouncedRecalc);
406
- cancelAnimationFrame(rafRef.current);
490
+ if (!ro) {
491
+ window.removeEventListener("resize", scheduleRecalculation);
492
+ }
493
+ cancelMeasurement(measurementKey);
407
494
  (_a2 = fontSet == null ? void 0 : fontSet.removeEventListener) == null ? void 0 : _a2.call(fontSet, "loadingdone", onFontsLoaded);
408
495
  };
409
- }, [recalculate]);
496
+ }, [readMeasurement, recalculate]);
410
497
  return {
411
498
  ref,
412
499
  measureRef,
@@ -422,12 +509,18 @@ function getRangeOffsets(container, range) {
422
509
  if (!container.contains(range.startContainer) || !container.contains(range.endContainer)) {
423
510
  return null;
424
511
  }
425
- const startRange = document.createRange();
426
- startRange.selectNodeContents(container);
427
- startRange.setEnd(range.startContainer, range.startOffset);
428
- const endRange = document.createRange();
429
- endRange.selectNodeContents(container);
430
- endRange.setEnd(range.endContainer, range.endOffset);
512
+ let startRange;
513
+ let endRange;
514
+ try {
515
+ startRange = document.createRange();
516
+ startRange.selectNodeContents(container);
517
+ startRange.setEnd(range.startContainer, range.startOffset);
518
+ endRange = document.createRange();
519
+ endRange.selectNodeContents(container);
520
+ endRange.setEnd(range.endContainer, range.endOffset);
521
+ } catch {
522
+ return null;
523
+ }
431
524
  return {
432
525
  end: endRange.toString().length,
433
526
  start: startRange.toString().length
@@ -449,7 +542,7 @@ function MiddleTruncate({ value, className, onCopy: onCopyProp, ...props }) {
449
542
  const range = selection.getRangeAt(0);
450
543
  const visibleEl = visibleRef.current;
451
544
  let copyText = null;
452
- if (e.currentTarget.contains(range.startContainer) && e.currentTarget.contains(range.endContainer) && visibleEl) {
545
+ if (selectionText.includes(ELLIPSIS) && e.currentTarget.contains(range.startContainer) && e.currentTarget.contains(range.endContainer) && visibleEl) {
453
546
  const offsets = getRangeOffsets(visibleEl, range);
454
547
  if (offsets) {
455
548
  copyText = getMiddleTruncateCopyText({