demoman 0.9.3 → 0.9.5

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.
@@ -22493,32 +22493,6 @@
22493
22493
  }
22494
22494
  return moves;
22495
22495
  }
22496
- function insideOnly(a, b, w, filmWidth, inset) {
22497
- const k = b.width / filmWidth;
22498
- const x0 = w.x * k + inset;
22499
- const y0 = w.y * k + inset;
22500
- const x1 = (w.x + w.width) * k - inset;
22501
- const y1 = (w.y + w.height) * k - inset;
22502
- const r = Math.max(0, w.radius * k - inset);
22503
- const rgba = new Uint8ClampedArray(a.rgba);
22504
- for (let y = 0; y < b.height; y++) {
22505
- const cy = y + 0.5;
22506
- if (cy < y0 || cy > y1)
22507
- continue;
22508
- for (let x = 0; x < b.width; x++) {
22509
- const cx = x + 0.5;
22510
- if (cx < x0 || cx > x1)
22511
- continue;
22512
- const dx = cx < x0 + r ? x0 + r - cx : cx > x1 - r ? cx - (x1 - r) : 0;
22513
- const dy = cy < y0 + r ? y0 + r - cy : cy > y1 - r ? cy - (y1 - r) : 0;
22514
- if (dx > 0 && dy > 0 && dx * dx + dy * dy > r * r)
22515
- continue;
22516
- const p = (y * b.width + x) * 4;
22517
- rgba.set(b.rgba.subarray(p, p + 4), p);
22518
- }
22519
- }
22520
- return { width: b.width, height: b.height, rgba };
22521
- }
22522
22496
  function changedShare(a, b, look) {
22523
22497
  const moves = blockMoves(a, b, look.block);
22524
22498
  let changed = 0;
@@ -22843,125 +22817,8 @@
22843
22817
  ctx.drawImage(source, 0, 0, width, height);
22844
22818
  return { width, height, rgba: ctx.getImageData(0, 0, width, height).data };
22845
22819
  }
22846
- async function pictureReader(url, type, width) {
22847
- if (type === "image/gif") {
22848
- const res = await fetch(url);
22849
- if (!res.ok)
22850
- throw new Error(`${url} answered ${res.status}`);
22851
- const decoder = new ImageDecoder({ data: await res.arrayBuffer(), type });
22852
- try {
22853
- await decoder.tracks.ready;
22854
- const count = decoder.tracks.selectedTrack?.frameCount ?? 0;
22855
- if (count === 0)
22856
- throw new Error(`${url} has no frames`);
22857
- const ends = [];
22858
- let w = 0;
22859
- let h = 0;
22860
- let end = 0;
22861
- for (let i = 0; i < count; i++) {
22862
- const { image } = await decoder.decode({ frameIndex: i });
22863
- w = image.displayWidth;
22864
- h = image.displayHeight;
22865
- end += (image.duration ?? 0) / 1e6;
22866
- ends.push(end);
22867
- image.close();
22868
- }
22869
- const frame2 = Math.min(...ends.map((e, i) => e - (ends[i - 1] ?? 0)).filter((d) => d > 0));
22870
- const indexAt = (t) => {
22871
- const i = ends.findIndex((e) => t < e);
22872
- return i < 0 ? count - 1 : i;
22873
- };
22874
- const drawnAt = async (i) => {
22875
- const { image } = await decoder.decode({ frameIndex: i });
22876
- try {
22877
- return drawnOf(image, w, h, width);
22878
- } finally {
22879
- image.close();
22880
- }
22881
- };
22882
- return {
22883
- width: w,
22884
- height: h,
22885
- length: end,
22886
- frame: frame2,
22887
- at: async (times) => {
22888
- const out = [];
22889
- for (const t of times)
22890
- out.push(await drawnAt(indexAt(t)));
22891
- return out;
22892
- },
22893
- close: () => decoder.close()
22894
- };
22895
- } catch (error) {
22896
- decoder.close();
22897
- throw error;
22898
- }
22899
- }
22900
- const input = new Input({
22901
- source: new UrlSource(url, { getRetryDelay: () => null }),
22902
- formats: ALL_FORMATS
22903
- });
22904
- const track = await input.getPrimaryVideoTrack();
22905
- if (track === null)
22906
- throw new Error(`${url} has no video track`);
22907
- if (!await track.canDecode()) {
22908
- throw new Error(`${url}'s video track (${track.codec ?? "unknown codec"}) cannot be decoded in this browser`);
22909
- }
22910
- const length = await input.computeDuration();
22911
- const rate = (await track.computePacketStats()).averagePacketRate;
22912
- const frame = rate > 0 ? 1 / rate : 1 / 30;
22913
- const at = async (times) => {
22914
- const drawn = [];
22915
- for await (const wrapped of new CanvasSink(track).canvasesAtTimestamps(times)) {
22916
- const t = times[drawn.length];
22917
- if (!wrapped)
22918
- throw new Error(`no frame decoded at ${t.toFixed(3)}s`);
22919
- const c = wrapped.canvas;
22920
- drawn.push(drawnOf(c, c.width, c.height, width));
22921
- }
22922
- return drawn;
22923
- };
22924
- return {
22925
- width: track.displayWidth,
22926
- height: track.displayHeight,
22927
- length,
22928
- frame,
22929
- at,
22930
- close: () => input.dispose()
22931
- };
22932
- }
22933
- async function screensDiff(urlA, urlB, type, msA, msB, windows, o) {
22934
- try {
22935
- const ra = await blamed("a", urlA, type, o.width);
22936
- try {
22937
- const rb = await blamed("b", urlB, type, o.width);
22938
- try {
22939
- return await diffOf(ra, rb, msA, msB, windows, o);
22940
- } finally {
22941
- rb.close();
22942
- }
22943
- } finally {
22944
- ra.close();
22945
- }
22946
- } catch (error) {
22947
- if (error instanceof Unreadable)
22948
- return { unreadable: error.side, error: error.message };
22949
- throw error;
22950
- }
22951
- }
22952
- async function imagesDiff(urlsA, urlsB, sizeA, sizeB, windows, o) {
22953
- const file = (size) => ({
22954
- ...size,
22955
- length: 0,
22956
- frame: 0
22957
- });
22958
- const answer = {
22959
- a: file(sizeA),
22960
- b: file(sizeB),
22961
- changed: []
22962
- };
22963
- if (sizeA.width !== sizeB.width || sizeA.height !== sizeB.height)
22964
- return answer;
22820
+ async function imagesDiff(urlsA, urlsB, looks) {
22821
+ const answer = { changed: [] };
22965
22822
  const read = async (side, url) => {
22966
22823
  try {
22967
22824
  const res = await fetch(url);
@@ -22969,7 +22826,7 @@
22969
22826
  throw new Error(`answered ${res.status}`);
22970
22827
  const bitmap = await createImageBitmap(await res.blob());
22971
22828
  try {
22972
- return drawnOf(bitmap, bitmap.width, bitmap.height, o.width);
22829
+ return drawnOf(bitmap, bitmap.width, bitmap.height, bitmap.width);
22973
22830
  } finally {
22974
22831
  bitmap.close();
22975
22832
  }
@@ -22980,10 +22837,10 @@
22980
22837
  try {
22981
22838
  for (const [i, urlA] of urlsA.entries()) {
22982
22839
  const da = await read("a", urlA);
22983
- const gb = await read("b", urlsB[i]);
22984
- const w = windows[i] ?? null;
22985
- const db = w === null ? gb : insideOnly(da, gb, w, sizeB.width, o.inset);
22986
- answer.changed.push(o.looks.map((look) => changedShare(da, db, look)));
22840
+ const db = await read("b", urlsB[i]);
22841
+ if (da.width !== db.width || da.height !== db.height)
22842
+ throw new Error(`${urlA} is ${da.width}x${da.height} and ${urlsB[i]} ${db.width}x${db.height}: images of two sizes are not compared`);
22843
+ answer.changed.push(looks.map((look) => changedShare(da, db, look)));
22987
22844
  }
22988
22845
  } catch (error) {
22989
22846
  if (error instanceof Unreadable)
@@ -22999,48 +22856,6 @@
22999
22856
  this.side = side;
23000
22857
  }
23001
22858
  };
23002
- async function blamed(side, url, type, width) {
23003
- const blame = (p) => p.catch((error) => {
23004
- throw new Unreadable(side, error);
23005
- });
23006
- const r = await blame(pictureReader(url, type, width));
23007
- return {
23008
- ...r,
23009
- at: (times) => blame(r.at(times))
23010
- };
23011
- }
23012
- async function diffOf(ra, rb, msA, msB, windows, o) {
23013
- const file = (r) => ({
23014
- width: r.width,
23015
- height: r.height,
23016
- length: r.length,
23017
- frame: r.frame
23018
- });
23019
- const answer = {
23020
- a: file(ra),
23021
- b: file(rb),
23022
- changed: []
23023
- };
23024
- if (ra.width !== rb.width || ra.height !== rb.height)
23025
- return answer;
23026
- const within = (r, ms) => ms / 1e3 < r.length;
23027
- const keep = msA.map((a, i) => within(ra, a) && within(rb, msB[i]) ? i : -1);
23028
- const ids = keep.filter((i) => i >= 0);
23029
- const ga = await ra.at(ids.map((i) => msA[i] / 1e3));
23030
- const gb = await rb.at(ids.map((i) => msB[i] / 1e3));
23031
- for (const i of msA.keys()) {
23032
- const k = ids.indexOf(i);
23033
- if (k < 0) {
23034
- answer.changed.push(null);
23035
- continue;
23036
- }
23037
- const da = ga[k];
23038
- const w = windows[i] ?? null;
23039
- const db = w === null ? gb[k] : insideOnly(da, gb[k], w, rb.width, o.inset);
23040
- answer.changed.push(o.looks.map((look) => changedShare(da, db, look)));
23041
- }
23042
- return answer;
23043
- }
23044
22859
  function meanAbsoluteDifference(a, b) {
23045
22860
  let sum = 0;
23046
22861
  for (let p = 0; p < a.length; p += 4) {
@@ -23049,7 +22864,6 @@
23049
22864
  return sum / (a.length / 4 * 3);
23050
22865
  }
23051
22866
  var entry = {
23052
- screensDiff,
23053
22867
  imagesDiff,
23054
22868
  decodeFrame,
23055
22869
  readCrops,
@@ -1638,7 +1638,40 @@
1638
1638
 
1639
1639
  // ../../packages/run-core/dist/url.js
1640
1640
  var PLACEHOLDER = "redacted";
1641
+ var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
1642
+ function charClass(c) {
1643
+ if (c >= "a" && c <= "z")
1644
+ return "l";
1645
+ if (c >= "A" && c <= "Z")
1646
+ return "u";
1647
+ if (c >= "0" && c <= "9")
1648
+ return "d";
1649
+ return null;
1650
+ }
1651
+ function looksLikeToken(raw) {
1652
+ let segment;
1653
+ try {
1654
+ segment = decodeURIComponent(raw);
1655
+ } catch {
1656
+ segment = raw;
1657
+ }
1658
+ if (!/^[\w.~+=-]{20,}$/.test(segment) || UUID.test(segment))
1659
+ return false;
1660
+ const classes = [...segment].map(charClass).filter((c) => c !== null);
1661
+ let switches = 0;
1662
+ for (let i = 1; i < classes.length; i++) {
1663
+ if (classes[i] !== classes[i - 1])
1664
+ switches++;
1665
+ }
1666
+ return switches * (/[A-Z]/.test(segment) ? 3 : 4) >= segment.length;
1667
+ }
1641
1668
  function scrubUrl(raw) {
1669
+ return scrub(raw, true);
1670
+ }
1671
+ function pageKey(raw) {
1672
+ return scrub(raw, false);
1673
+ }
1674
+ function scrub(raw, path) {
1642
1675
  let url;
1643
1676
  try {
1644
1677
  url = new URL(raw);
@@ -1648,7 +1681,9 @@
1648
1681
  url.username = "";
1649
1682
  url.password = "";
1650
1683
  url.hash = "";
1651
- url.pathname = url.pathname.split("/").map((segment) => scrubSecrets(segment) === segment ? segment : PLACEHOLDER).join("/");
1684
+ if (path) {
1685
+ url.pathname = url.pathname.split("/").map((segment) => looksLikeToken(segment) || scrubSecrets(segment) !== segment ? PLACEHOLDER : segment).join("/");
1686
+ }
1652
1687
  for (const key of Array.from(new Set(url.searchParams.keys()))) {
1653
1688
  url.searchParams.set(key, PLACEHOLDER);
1654
1689
  }
@@ -1666,9 +1701,10 @@
1666
1701
  failureReason: report.failureReason
1667
1702
  };
1668
1703
  if (resolved && report.element !== null) {
1704
+ const href = window.location.href;
1669
1705
  const { anchor } = await captureAnchor(report.element, {
1670
1706
  anchorId: intent.id,
1671
- url: scrubUrl(window.location.href),
1707
+ url: scrubUrl(href),
1672
1708
  // No step index exists yet for a freshly authored anchor;
1673
1709
  // driftPick's own remap capture makes the same choice.
1674
1710
  actionIndex: 0,
@@ -1692,6 +1728,7 @@
1692
1728
  failureReason: null,
1693
1729
  intentResolution,
1694
1730
  pageUrl: null,
1731
+ here: pageKey(href),
1695
1732
  document: documentOf(),
1696
1733
  ...credentialField === void 0 ? {} : { credentialField }
1697
1734
  };
@@ -1711,6 +1748,7 @@
1711
1748
  // frame knows which document just failed to resolve the intent. Scrubbed
1712
1749
  // like every other URL that leaves the page.
1713
1750
  pageUrl: scrubUrl(window.location.href),
1751
+ here: pageKey(window.location.href),
1714
1752
  document: documentOf(),
1715
1753
  // No element to ask: when the caller checks credentials, that is "could
1716
1754
  // not tell", which a typed step hides (launch C spec 3.5).
@@ -1842,8 +1880,10 @@
1842
1880
  fields.push({ target, value });
1843
1881
  }
1844
1882
  const notListed = candidates.length - END_PAGE_MAX_FIELDS;
1883
+ const href = doc.location?.href;
1845
1884
  return {
1846
- url: doc.location?.href ?? "",
1885
+ // Written to `report.json`: scrubbed like every address that is.
1886
+ url: href === void 0 ? "" : scrubUrl(href),
1847
1887
  text,
1848
1888
  fields,
1849
1889
  ...notListed > 0 ? { fieldsNotListed: notListed } : {}
@@ -15416,6 +15416,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15416
15416
  pressMs: external_exports.number().nonnegative(),
15417
15417
  releaseMs: external_exports.number().nonnegative()
15418
15418
  });
15419
+ var PageScreenSchema = external_exports.object({
15420
+ after: external_exports.number().int().min(0),
15421
+ sourceTimeMs: external_exports.number(),
15422
+ ref: external_exports.string(),
15423
+ width: external_exports.number().int().positive(),
15424
+ height: external_exports.number().int().positive(),
15425
+ heldAnimations: external_exports.number().int().min(0),
15426
+ waitedMs: external_exports.number().min(0),
15427
+ unsettled: external_exports.string().optional()
15428
+ }).refine((s) => s.ref !== "" || s.unsettled !== void 0, {
15429
+ message: 'a page screen with no bytes (ref "") must say why in `unsettled`',
15430
+ path: ["unsettled"]
15431
+ });
15419
15432
  var ViewportTransformSchema = external_exports.object({
15420
15433
  sourceTimeMs: external_exports.number().nonnegative(),
15421
15434
  scale: external_exports.number().positive(),
@@ -15541,7 +15554,27 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15541
15554
  // A native drag's picture could not be drawn in the page (the element
15542
15555
  // the page named for it was gone, or copying it threw). The drag still
15543
15556
  // ran; the film shows the card jump to its drop instead of travelling.
15544
- "dragPictureMissing"
15557
+ "dragPictureMissing",
15558
+ // A step's page had not settled when the cap ran out (requests in
15559
+ // flight, an animation running, the DOM still changing) or showed a
15560
+ // caret it would not hide: the page's own doing. The video is
15561
+ // unaffected; refresh cannot compare that screen. The note names the
15562
+ // step and the conditions.
15563
+ "stepUnsettled",
15564
+ // As `stepUnsettled`, but at least one condition was this machine's:
15565
+ // the first paint never came, the settle probe or the page screen
15566
+ // failed, requests could not be watched. Recording again may change
15567
+ // it, so refresh does (DEM-55); the note names the step and the
15568
+ // conditions, the page's beside the machine's.
15569
+ "stepSettleFailed",
15570
+ // A step's settle left out a request open since more than a request cap
15571
+ // before the step began (a long poll): its own step waited for it. The
15572
+ // screen counts as settled; the note names the step and how many.
15573
+ "requestNotWaited",
15574
+ // A page screen's hold (caret hidden, endless animations held) could not
15575
+ // be undone after the capture: the video after that step may show no
15576
+ // caret and frozen spinners. About the video, so not forgiven.
15577
+ "pageHoldNotReleased"
15545
15578
  ]),
15546
15579
  note: external_exports.string()
15547
15580
  });
@@ -15603,6 +15636,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15603
15636
  // 2026-10-11 carries none, and identity is what they were drawn as.
15604
15637
  // See `ViewportTransformSchema`.
15605
15638
  viewportTransforms: external_exports.array(ViewportTransformSchema).optional(),
15639
+ // Optional, and absent is none: a sampled replay, a capture, and every
15640
+ // bundle written before 2026-11-10 carry none.
15641
+ pageScreens: external_exports.array(PageScreenSchema).optional(),
15606
15642
  markers: external_exports.array(MarkerSchema),
15607
15643
  degradations: external_exports.array(DegradationSchema),
15608
15644
  /**
@@ -16208,14 +16244,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16208
16244
  * unchanged, but its MEANING narrows: this now records which frames PLAY,
16209
16245
  * not which the author chose. The editor writes it nowhere — since
16210
16246
  * 2026-09-28 every write the editor makes carries the store's current
16211
- * value (`persist()` in `apps/extension/src/editor/session.ts`). Two
16212
- * writers flip it, both outside the editor: the run page's re-shoot
16213
- * promotion (`promote` in `apps/extension/src/adapters/reshoot.ts`) sets
16214
- * `demo` when a re-shoot finishes complete, and the library card's "Back
16215
- * to your recording" (`backToRecording` in
16216
- * `apps/extension/entrypoints/library/main.ts`) sets `screen`. Neither
16217
- * deletes anything to do it — the recording stays on disk under either
16218
- * mode (`chooseActiveBundle`'s own docblock) — so a re-shoot that turns
16247
+ * value (`persist()` in `apps/studio/pages/src/editor/session.ts`). Two
16248
+ * writers set it, both outside the editor: `assembleAuthored`
16249
+ * (`@demoman/replay-engine`) writes `screen` on every new take, and the
16250
+ * library card's "Back to your recording"
16251
+ * (`apps/studio/pages/entrypoints/library/main.ts`) sets `screen`. Nothing writes `demo` today; it is
16252
+ * read from takes the retired extension re-shot. Neither writer deletes
16253
+ * anything — the recording stays on disk under either mode
16254
+ * (`chooseActiveBundle`'s own docblock) — so a re-shoot that turns
16219
16255
  * out worse than the recording is always reversible by writing this field
16220
16256
  * back.
16221
16257
  */
@@ -16763,9 +16799,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16763
16799
  branding: ScriptBrandingSchema.optional(),
16764
16800
  /**
16765
16801
  * One of the author's brand kits, by the name Settings shows (case and
16766
- * surrounding space ignored). Resolved by the extension at the run's
16767
- * door; a name that is not there is refused (`unknownKit`), never
16768
- * replaced by the default kit (spec 2026-10-08 §3).
16802
+ * surrounding space ignored). Resolved by the runner at the run's
16803
+ * door (`lookForRun`, in `@demoman/run-core`); a name that is not
16804
+ * there is refused (`unknownKit`), never replaced by the default kit
16805
+ * (spec 2026-10-08 §3).
16769
16806
  */
16770
16807
  kit: external_exports.string().trim().min(1).optional(),
16771
16808
  cursor: CursorSchema.optional(),
@@ -16938,9 +16975,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16938
16975
  verticalMaxScale: 1.15,
16939
16976
  /**
16940
16977
  * CSS px of page kept round a zoomed target on every side, so its edges
16941
- * and the cursor on it are not flush with the frame. The extension's
16942
- * generated zooms fit against the capture viewport with it
16943
- * (`zoomsForClicks`); a `cover` render fits against its own crop with it
16978
+ * and the cursor on it are not flush with the frame. Generated zooms fit
16979
+ * against the capture viewport with it (`zoomsForClicks`,
16980
+ * `@demoman/run-core`); a `cover` render fits against its own crop with it
16944
16981
  * (`solveCamera`'s `fitWindow`).
16945
16982
  */
16946
16983
  fitMarginPx: 24,
@@ -16954,8 +16991,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16954
16991
  */
16955
16992
  actSettleMs: 400,
16956
16993
  /**
16957
- * The push-in and the pull-out at the DEFAULT smoothness — what the
16958
- * extension sizes a fresh zoom's length by (`zoom-defaults.ts`) and the
16994
+ * The push-in and the pull-out at the DEFAULT smoothness — what
16995
+ * `@demoman/run-core` sizes a fresh zoom's length by (`zoom-defaults.ts`) and the
16959
16996
  * editor draws an unauthored end with. A render reads the document's own
16960
16997
  * smoothness through `motionTimings`, so these are the timings of a take
16961
16998
  * that never touched the slider, not of every take.
@@ -26805,7 +26842,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
26805
26842
  },
26806
26843
  // Bytes or a reason, never an empty array: a 0-byte file stored as a
26807
26844
  // successful output is a Download button that does nothing, and the
26808
- // render loop, the offscreen host and the editor all read `bytes` as
26845
+ // render loop, the runner's render page and the editor all read `bytes` as
26809
26846
  // "it worked".
26810
26847
  async finish() {
26811
26848
  finished = true;
@@ -26901,7 +26938,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
26901
26938
  const blob = await response.blob();
26902
26939
  const bitmap = await createImageBitmap(blob);
26903
26940
  try {
26904
- ctx.drawImage(bitmap, 0, 0, manifest.width, manifest.height);
26941
+ const evened = [0, 1].includes(bitmap.width - manifest.width) && [0, 1].includes(bitmap.height - manifest.height);
26942
+ if (evened)
26943
+ ctx.drawImage(bitmap, 0, 0);
26944
+ else
26945
+ ctx.drawImage(bitmap, 0, 0, manifest.width, manifest.height);
26905
26946
  } finally {
26906
26947
  bitmap.close();
26907
26948
  }