@astryxdesign/lab 0.7.13-canary.a5ad1f2 → 0.7.13-canary.fd5cf0d

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/lab.css CHANGED
@@ -43,26 +43,26 @@
43
43
  .x1eijsz{--icon-layer-primary-fill:currentColor}
44
44
  .xawlqpt{--icon-layer-primary-fill:none}
45
45
  .xgmpc9a{--icon-layer-primary-opacity:1}
46
+ .xo1qp05{--icon-layer-primary-stroke:currentColor}
47
+ .xxn8g3f{--icon-layer-primary-stroke:none}
46
48
  .x1behde{--icon-layer-primary-stroke-role-fill:none}
47
49
  .x167zosf{--icon-layer-primary-stroke-role-opacity:.4}
48
50
  .x1ixq0ah{--icon-layer-primary-stroke-role-opacity:1}
49
51
  .x12z8fwv{--icon-layer-primary-stroke-role-stroke:currentColor}
50
52
  .x1lampxp{--icon-layer-primary-stroke-role-width:2}
51
- .xo1qp05{--icon-layer-primary-stroke:currentColor}
52
- .xxn8g3f{--icon-layer-primary-stroke:none}
53
53
  .x1a7uvwd{--icon-layer-secondary-fill:currentColor}
54
54
  .x14svsep{--icon-layer-secondary-fill:none}
55
55
  .x1pm3eyu{--icon-layer-secondary-opacity:.4}
56
56
  .xontptu{--icon-layer-secondary-opacity:0}
57
57
  .xin2e9c{--icon-layer-secondary-opacity:1}
58
+ .xjilf3y{--icon-layer-secondary-stroke:currentColor}
59
+ .xqw5mls{--icon-layer-secondary-stroke:none}
58
60
  .x1q3b5jp{--icon-layer-secondary-stroke-role-fill:none}
59
61
  .x1grmq33{--icon-layer-secondary-stroke-role-opacity:.4}
60
62
  .x1m4cuqp{--icon-layer-secondary-stroke-role-opacity:0}
61
63
  .x1ddoxvq{--icon-layer-secondary-stroke-role-opacity:1}
62
64
  .xvx4rvh{--icon-layer-secondary-stroke-role-stroke:currentColor}
63
65
  .x1l94yqg{--icon-layer-secondary-stroke-role-width:2.5}
64
- .xjilf3y{--icon-layer-secondary-stroke:currentColor}
65
- .xqw5mls{--icon-layer-secondary-stroke:none}
66
66
  .x1x62q30{--icon-size:12px}
67
67
  .x1ddsvy1{--icon-size:16px}
68
68
  .xhxmg62{--icon-size:20px}
@@ -390,8 +390,8 @@
390
390
  .x1lfs0n9:not(#\#):not(#\#):not(#\#){column-gap:var(--spacing-1)}
391
391
  .xak3so:not(#\#):not(#\#):not(#\#){column-gap:var(--spacing-2)}
392
392
  .xewh9hi:not(#\#):not(#\#):not(#\#){column-gap:var(--spacing-3)}
393
- .x1w36mze:not(#\#):not(#\#):not(#\#){contain-intrinsic-height:auto 28px}
394
393
  .x41o525:not(#\#):not(#\#):not(#\#){contain:inline-size}
394
+ .x1w36mze:not(#\#):not(#\#):not(#\#){contain-intrinsic-height:auto 28px}
395
395
  .x63rumg:not(#\#):not(#\#):not(#\#){container-name:list-input}
396
396
  .x12h1iku:not(#\#):not(#\#):not(#\#){container-type:inline-size}
397
397
  .xb5mbof:not(#\#):not(#\#):not(#\#){content-visibility:auto}
@@ -557,7 +557,6 @@
557
557
  .xocuifg:not(#\#):not(#\#):not(#\#){scale:var(--_page-control-scale,1)}
558
558
  .x185mbhu:not(#\#):not(#\#):not(#\#){scrollbar-gutter:stable}
559
559
  .x1597r2g:not(#\#):not(#\#):not(#\#){scrollbar-width:thin}
560
- .x1owpc8m:not(#\#):not(#\#):not(#\#){stroke-linecap:round}
561
560
  .ximx5ud:not(#\#):not(#\#):not(#\#){stroke:var(--color-accent-muted)}
562
561
  .xjsr54c:not(#\#):not(#\#):not(#\#){stroke:var(--color-accent)}
563
562
  .xjswp7v:not(#\#):not(#\#):not(#\#){stroke:var(--color-error-muted)}
@@ -568,6 +567,7 @@
568
567
  .x16d96h5:not(#\#):not(#\#):not(#\#){stroke:var(--color-text-warning)}
569
568
  .xpi25hw:not(#\#):not(#\#):not(#\#){stroke:var(--color-track)}
570
569
  .x1wjzxuj:not(#\#):not(#\#):not(#\#){stroke:var(--color-warning-muted)}
570
+ .x1owpc8m:not(#\#):not(#\#):not(#\#){stroke-linecap:round}
571
571
  .xeq4nuv:not(#\#):not(#\#):not(#\#){tab-size:2}
572
572
  .x140o2bo:not(#\#):not(#\#):not(#\#){table-layout:fixed}
573
573
  .x2b8uid:not(#\#):not(#\#):not(#\#){text-align:center}
@@ -580,11 +580,11 @@
580
580
  .xggy1nq:not(#\#):not(#\#):not(#\#){touch-action:manipulation}
581
581
  .x5ve5x3:not(#\#):not(#\#):not(#\#){touch-action:none}
582
582
  .xge0x1e:not(#\#):not(#\#):not(#\#){touch-action:pan-y pinch-zoom}
583
- .x1bd091l:not(#\#):not(#\#):not(#\#){transform-origin:left bottom}
584
583
  .x9tu13d:not(#\#):not(#\#):not(#\#){transform:rotate(-90deg)}
585
584
  .x19jd1h0:not(#\#):not(#\#):not(#\#){transform:rotate(180deg)}
586
585
  .x1iffjtl:not(#\#):not(#\#):not(#\#){transform:rotate(90deg)}
587
586
  .x1cb1t30:not(#\#):not(#\#):not(#\#){transform:translateY(-50%)}
587
+ .x1bd091l:not(#\#):not(#\#):not(#\#){transform-origin:left bottom}
588
588
  .xkvfbh3:not(#\#):not(#\#):not(#\#){transition-duration:var(--duration-fast-min)}
589
589
  .xuedmi6:not(#\#):not(#\#):not(#\#){transition-duration:var(--duration-fast)}
590
590
  .x80gvsz:not(#\#):not(#\#):not(#\#){transition-duration:var(--duration-medium)}
@@ -636,8 +636,8 @@
636
636
  .x1nw7mhf:focus-visible:not(#\#):not(#\#):not(#\#){outline-offset:calc(-1 * var(--focus-outline-width))}
637
637
  .x1jhp3zv:focus-visible:not(#\#):not(#\#):not(#\#){outline-style:var(--focus-outline-style)}
638
638
  .xmbzu5e.xmbzu5e:hover:where(:not(:disabled,[aria-disabled="true"])):not(#\#):not(#\#):not(#\#){text-decoration-line:underline}
639
- .x173emx3:is([dir="rtl"] *):not(#\#):not(#\#):not(#\#){transform-origin:right bottom}
640
639
  .xgtlewx:is([dir="rtl"] *):not(#\#):not(#\#):not(#\#){transform:scaleX(-1)}
640
+ .x173emx3:is([dir="rtl"] *):not(#\#):not(#\#):not(#\#){transform-origin:right bottom}
641
641
  .xh1l8ak:is([dir="rtl"] *):not(#\#):not(#\#):not(#\#){translate:var(--_page-control-rest,0px) 0}
642
642
  .xuuqkwq:is([dir="rtl"] *):not(#\#):not(#\#):not(#\#){translate:var(--x-7zq8zw)}
643
643
  .x135w3n3:focus-visible:not(#\#):not(#\#):not(#\#){z-index:1}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/lab",
3
- "version": "0.7.13-canary.a5ad1f2",
3
+ "version": "0.7.13-canary.fd5cf0d",
4
4
  "description": "Experimental Astryx components — published to npm only under the @canary dist-tag for early testing; never released as a stable (latest) version.",
5
5
  "author": "Meta Open Source",
6
6
  "license": "MIT",
@@ -49,7 +49,7 @@
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@stylexjs/stylex": ">=0.10.0",
52
- "@astryxdesign/core": "0.7.13-canary.a5ad1f2",
52
+ "@astryxdesign/core": "0.7.13-canary.fd5cf0d",
53
53
  "react": ">=19.0.0",
54
54
  "react-dom": ">=19.0.0"
55
55
  },
@@ -59,15 +59,15 @@
59
59
  "d3-shape": "^3.2.0"
60
60
  },
61
61
  "devDependencies": {
62
- "@astryxdesign/a11y-spec": "0.7.13-canary.a5ad1f2",
63
- "@astryxdesign/cli": "0.7.13-canary.a5ad1f2",
64
- "@astryxdesign/interaction-harness": "0.7.13-canary.a5ad1f2",
62
+ "@astryxdesign/a11y-spec": "0.7.13-canary.fd5cf0d",
63
+ "@astryxdesign/cli": "0.7.13-canary.fd5cf0d",
64
+ "@astryxdesign/interaction-harness": "0.7.13-canary.fd5cf0d",
65
65
  "@babel/cli": "^7.29.7",
66
66
  "@babel/core": "^7.29.7",
67
67
  "@babel/preset-react": "^7.29.7",
68
68
  "@babel/preset-typescript": "^7.29.7",
69
- "@stylexjs/babel-plugin": "^0.19.0",
70
- "@testing-library/react": "^16.3.2",
69
+ "@stylexjs/babel-plugin": "^0.19.1",
70
+ "@testing-library/react": "^16.3.3",
71
71
  "@types/d3-array": "^3.2.2",
72
72
  "@types/d3-scale": "^4.0.9",
73
73
  "@types/d3-shape": "^3.1.8",
@@ -37,12 +37,12 @@ import {
37
37
  FrameStarvationError,
38
38
  freezePageOn,
39
39
  freezePageWhen,
40
- holdAnimations,
41
40
  installPageFreeze,
42
41
  installTimerGate,
43
42
  MARKER_RGB,
44
43
  openStory,
45
44
  releaseAnimations,
45
+ requireFrames,
46
46
  sampleCurve,
47
47
  sampleRects,
48
48
  seekAnimations,
@@ -878,11 +878,15 @@ test('brought back past its start, the screen follows with resistance, then spri
878
878
  });
879
879
  }
880
880
  frames.push({t: last.t + steps * 16.7 + 4, fingers: []});
881
- await driver.play(frames);
882
- // The return, held where it runs and read every 2 ms from its start.
883
- const heldAnimations = await holdAnimations(page, top, {
881
+ // The return, held as it starts and read every 2 ms from its start. The
882
+ // page holds it itself. A hold sent after the play reaches the page later
883
+ // the busier the machine is, and the return can be over by then.
884
+ const returning = await armHold(page, top, {
884
885
  judges: {target: top, property: 'translate'},
886
+ newOnly: true,
885
887
  });
888
+ await driver.play(frames);
889
+ const heldAnimations = await returning.held();
886
890
  const returnIndex = await top.evaluate(element =>
887
891
  (
888
892
  (window as unknown as {__harnessHeld?: Animation[]}).__harnessHeld ?? []
@@ -2467,22 +2471,28 @@ test('under Reduce Motion the bar title cross-fades in place, without the rise',
2467
2471
  await page.emulateMedia({reducedMotion: 'reduce'});
2468
2472
  await openStack(page, 'large-title');
2469
2473
  const barText = page.locator('[data-navigation-bar="root"] h2');
2470
- await card(page, 'root').evaluate(element =>
2471
- (element.firstElementChild as HTMLElement).scrollTo({top: 300}),
2472
- );
2473
- const samples = await sampleRects(barText, 900);
2474
- await expect
2475
- .poll(async () =>
2476
- barText.evaluate(e => Number(getComputedStyle(e).opacity)),
2477
- )
2478
- .toBe(1);
2474
+ const scrollTo = (top: number) =>
2475
+ card(page, 'root').evaluate(
2476
+ (element, y) =>
2477
+ (element.firstElementChild as HTMLElement).scrollTo({top: y}),
2478
+ top,
2479
+ );
2480
+ const opacity = () =>
2481
+ barText.evaluate(e => Number(getComputedStyle(e).opacity));
2482
+ // The read starts before the scroll, so it covers the whole fade.
2483
+ const reading = sampleRects(barText, 900);
2484
+ await scrollTo(300);
2485
+ const samples = await reading;
2486
+ await expect.poll(opacity).toBe(1);
2479
2487
  // Where the shown title rests (hidden, it sits 15 px lower for the rise).
2480
2488
  const rest = await barText.boundingBox();
2481
- const fading = samples.filter(
2482
- sample => sample.opacity > 0.05 && sample.opacity < 0.95,
2483
- );
2484
- // A fade, not a jump…
2485
- expect(fading.length, JSON.stringify(samples)).toBeGreaterThan(2);
2489
+ // A fade, not a jump: frames the page drew mid-fade. A page starved of
2490
+ // frames draws too few of them, and fails by name.
2491
+ requireFrames(samples, {
2492
+ min: 3,
2493
+ during: 'the bar title faded in',
2494
+ where: sample => sample.opacity > 0.05 && sample.opacity < 0.95,
2495
+ });
2486
2496
  // …in place: every visible frame is already at the resting position.
2487
2497
  for (const sample of samples.filter(item => item.opacity > 0.05)) {
2488
2498
  expect(
@@ -2490,6 +2500,32 @@ test('under Reduce Motion the bar title cross-fades in place, without the rise',
2490
2500
  JSON.stringify(samples),
2491
2501
  ).toBeLessThan(0.5);
2492
2502
  }
2503
+ // The same fade, held as it starts and read at fixed times through the
2504
+ // 200 ms cross-fade. It is part-way at more than two of them, so it is a
2505
+ // fade and not a jump. The title is in place at each.
2506
+ await scrollTo(0);
2507
+ await expect.poll(opacity).toBe(0);
2508
+ const fade = await armHold(page, barText, {
2509
+ judges: {target: barText, property: 'opacity'},
2510
+ newOnly: true,
2511
+ });
2512
+ await scrollTo(300);
2513
+ await fade.held();
2514
+ const curve = await sampleCurve(
2515
+ barText,
2516
+ Array.from({length: 9}, (_, i) => (i + 1) * 20),
2517
+ );
2518
+ await releaseAnimations(page, {finish: true});
2519
+ const trace = JSON.stringify(
2520
+ curve.map(c => [c.t, c.opacity, c.transform.translateY]),
2521
+ );
2522
+ expect(
2523
+ curve.filter(c => c.opacity > 0.05 && c.opacity < 0.95).length,
2524
+ trace,
2525
+ ).toBeGreaterThan(2);
2526
+ for (const c of curve) {
2527
+ expect(Math.abs(c.transform.translateY), trace).toBeLessThan(0.5);
2528
+ }
2493
2529
  });
2494
2530
 
2495
2531
  /** The bar title's opacity, every frame for `ms`. */
@@ -26,6 +26,7 @@ import {
26
26
  drag,
27
27
  FRAME_STARVATION_MS,
28
28
  FrameStarvationError,
29
+ frameGaps,
29
30
  MARKER_RGB,
30
31
  releaseAnimations,
31
32
  openStory,
@@ -37,6 +38,7 @@ import {
37
38
  waitForRest,
38
39
  withStorybook,
39
40
  } from '@astryxdesign/interaction-harness';
41
+ import {jogInterval} from '../pageControlModel';
40
42
 
41
43
  const storybook = withStorybook(test);
42
44
 
@@ -133,6 +135,79 @@ function msPerPage(window: ReadonlyArray<{t: number; page: number}>) {
133
135
  return (last.t - first.t) / Math.abs(last.page - first.page);
134
136
  }
135
137
 
138
+ /** Logs when the page draws each frame from now on; the reader returns them. */
139
+ async function logFrames(page: Page) {
140
+ await page.evaluate(() => {
141
+ const frames: number[] = [];
142
+ (window as unknown as {frameLog: number[]}).frameLog = frames;
143
+ const step = (t: number) => {
144
+ frames.push(t);
145
+ requestAnimationFrame(step);
146
+ };
147
+ requestAnimationFrame(step);
148
+ });
149
+ return () =>
150
+ page.evaluate(() => (window as unknown as {frameLog: number[]}).frameLog);
151
+ }
152
+
153
+ /**
154
+ * Judges a jog's rate across a held window against its bounds, ms per page.
155
+ * The jog restarts its count after a timer that runs later than one step, so
156
+ * a stall longer than `stepMs` slows the steps it overlaps. A rate too slow
157
+ * fails by name only when the steps clear of such a stall are in bounds, or
158
+ * when no step is clear. Any other rate out of bounds fails as it is.
159
+ */
160
+ function expectJogRate(
161
+ held: ReadonlyArray<{t: number; page: number}>,
162
+ frames: readonly number[],
163
+ {
164
+ above,
165
+ below,
166
+ stepMs,
167
+ during,
168
+ }: {above: number; below: number; stepMs: number; during: string},
169
+ ): void {
170
+ const rate = msPerPage(held);
171
+ const gaps = frameGaps(frames, held[0].t, held[held.length - 1].t);
172
+ const stalls = gaps.filter(gap => gap.to - gap.from > stepMs);
173
+ if (rate >= below && stalls.length > 0) {
174
+ const clear = held
175
+ .slice(1)
176
+ .map((step, i) => ({
177
+ ms: step.t - held[i].t,
178
+ pages: Math.abs(step.page - held[i].page),
179
+ stalled: stalls.some(
180
+ stall => stall.from < step.t && stall.to > held[i].t,
181
+ ),
182
+ }))
183
+ .filter(step => !step.stalled);
184
+ const clearPages = clear.reduce((sum, step) => sum + step.pages, 0);
185
+ const clearRate =
186
+ clearPages > 0
187
+ ? clear.reduce((sum, step) => sum + step.ms, 0) / clearPages
188
+ : null;
189
+ if (clearRate == null || (clearRate > above && clearRate < below)) {
190
+ // The frames the window needs: those drawn, and enough more to keep
191
+ // every gap within one step.
192
+ const drawn = gaps.length - 1;
193
+ const missing = stalls.reduce(
194
+ (sum, stall) => sum + Math.ceil((stall.to - stall.from) / stepMs) - 1,
195
+ 0,
196
+ );
197
+ throw new FrameStarvationError({
198
+ by: 'the jog',
199
+ during,
200
+ frames: drawn,
201
+ min: drawn + missing,
202
+ longestGapMs: Math.max(...stalls.map(stall => stall.to - stall.from)),
203
+ cause: `a stall longer than one ${stepMs.toFixed(0)} ms step restarts the jog's count. The jog ran at ${rate.toFixed(0)} ms per page, ${clearRate == null ? 'with no step clear of a stall' : `and at ${clearRate.toFixed(0)} ms per page clear of a stall`}, so the run proves nothing about its rate`,
204
+ });
205
+ }
206
+ }
207
+ expect(rate).toBeGreaterThan(above);
208
+ expect(rate).toBeLessThan(below);
209
+ }
210
+
136
211
  async function logPages(slider: Locator) {
137
212
  await slider.evaluate(el => {
138
213
  const log: Array<{t: number; page: number}> = [];
@@ -301,6 +376,7 @@ test('past the edge of a windowed control the page keeps stepping, faster the fu
301
376
  }
302
377
  const contentEnd = box.x + box.width - 14;
303
378
  const current = await indicatorCenter(slider, 25);
379
+ const frames = await logFrames(page);
304
380
  const pages = await logPages(slider);
305
381
  // Scrub 40 px past the content's edge and hold there for 1.2 s:
306
382
  // 0.173 pages/s per px → about 7 pages a second.
@@ -313,9 +389,12 @@ test('past the edge of a windowed control the page keeps stepping, faster the fu
313
389
  );
314
390
  const log = await pages();
315
391
  const held = log.filter(e => e.t >= log[0].t + 400);
316
- const nearStep = msPerPage(held);
317
- expect(nearStep).toBeGreaterThan(110);
318
- expect(nearStep).toBeLessThan(190);
392
+ expectJogRate(held, await frames(), {
393
+ above: 110,
394
+ below: 190,
395
+ stepMs: jogInterval(40) * 1000,
396
+ during: 'the jog stepped 40 px past the edge',
397
+ });
319
398
  expect(log[log.length - 1].page).toBeGreaterThan(30);
320
399
  // Far past (100 px): 15 pages a second.
321
400
  const far = await logPages(slider);
@@ -328,9 +407,12 @@ test('past the edge of a windowed control the page keeps stepping, faster the fu
328
407
  ),
329
408
  );
330
409
  const fast = (await far()).filter((e, i, all) => e.t >= all[0].t + 300);
331
- const farStep = msPerPage(fast);
332
- expect(farStep).toBeGreaterThan(50);
333
- expect(farStep).toBeLessThan(85);
410
+ expectJogRate(fast, await frames(), {
411
+ above: 50,
412
+ below: 85,
413
+ stepMs: jogInterval(100) * 1000,
414
+ during: 'the jog stepped 100 px past the edge',
415
+ });
334
416
  });
335
417
 
336
418
  test('a held finger shows the platter, the pressed overlay, and dims the other indicators after 155 ms; the touched indicator does not transform', async ({