@lark-apaas/coding-registry-buildless 0.1.25-alpha.20260922075718 → 0.1.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/coding-registry-buildless",
3
- "version": "0.1.25-alpha.20260922075718",
3
+ "version": "0.1.25",
4
4
  "description": "Miaoda registry (buildless runtime) — shadcn-style copy-in SDKs (globals + CDN-pinned, browser Babel) for buildless static HTML stacks",
5
5
  "type": "module",
6
6
  "files": [
@@ -14,6 +14,12 @@
14
14
  * On touch devices, tapping the left/right half of the stage goes
15
15
  * prev/next (not in mobile browse mode — see (g)) — taps on links,
16
16
  * buttons and other interactive slide content are left alone.
17
+ * In mobile presenting mode a swipe pages too, in all four directions:
18
+ * swipe left or up for the NEXT slide, right or down for the previous
19
+ * one — the deck moves with the finger, so the gesture is the mirror of
20
+ * the tap zones (tap left = previous), exactly as in Keynote/PPT.
21
+ * Swipes that start on interactive or scrollable slide content are left
22
+ * alone, and browse mode has no swipe — there it is the list's scroll.
17
23
  * (c) press R to reset to slide 0.
18
24
  * (d) auto-scaling — inner canvas is a fixed design size (default 1920×1080)
19
25
  * scaled with `transform: scale()` to fit the viewport, letterboxed.
@@ -65,7 +71,7 @@
65
71
  * e.detail.total // total slide count
66
72
  * e.detail.slide // the new active slide element
67
73
  * e.detail.previousSlide // the prior slide element, or null on init
68
- * e.detail.reason // 'init' | 'keyboard' | 'click' | 'tap' | 'api'
74
+ * e.detail.reason // 'init' | 'keyboard' | 'click' | 'tap' | 'swipe' | 'api'
69
75
  * });
70
76
  *
71
77
  * Persistence: none at the deck level. The host app keeps the current slide
@@ -211,6 +217,24 @@
211
217
  const NARROW_MQ = matchMedia('(max-width: 640px)');
212
218
  // Slide-authored controls that should keep a tap instead of it navigating.
213
219
  const INTERACTIVE_SEL = 'a[href], button, input, select, textarea, summary, label, video[controls], audio[controls], [role="button"], [onclick], [tabindex]:not([tabindex^="-"]), [contenteditable]:not([contenteditable="false" i])';
220
+ // Swipe paging thresholds. The travel floor is what separates a swipe from a
221
+ // sloppy tap; the axis ratio makes a diagonal drag do nothing rather than
222
+ // have the deck guess which way the user meant.
223
+ const SWIPE_MIN_PX = 40;
224
+ const SWIPE_AXIS_RATIO = 1.5;
225
+ // A slide-authored scroller owns any gesture that starts inside it — same
226
+ // yield-to-the-slide rule as INTERACTIVE_SEL, one step further out. Slide
227
+ // sections themselves are overflow:hidden, so this only ever matches
228
+ // something the author deliberately made scrollable.
229
+ const isScrollable = (el) => {
230
+ if (!el || el.nodeType !== 1) return false;
231
+ const cs = getComputedStyle(el);
232
+ const scrolls = (v) => v === 'auto' || v === 'scroll';
233
+ return (
234
+ (scrolls(cs.overflowY) && el.scrollHeight > el.clientHeight) ||
235
+ (scrolls(cs.overflowX) && el.scrollWidth > el.clientWidth)
236
+ );
237
+ };
214
238
 
215
239
  /* Custom element families whose thumbnail clones keep their tag instead of
216
240
  * being neutered (see _materialize).
@@ -869,6 +893,8 @@
869
893
  this._onResize = this._onResize.bind(this);
870
894
  this._onSlotChange = this._onSlotChange.bind(this);
871
895
  this._onTap = this._onTap.bind(this);
896
+ this._onTouchStart = this._onTouchStart.bind(this);
897
+ this._onTouchEnd = this._onTouchEnd.bind(this);
872
898
  this._onMessage = this._onMessage.bind(this);
873
899
  this._onHashChange = this._onHashChange.bind(this);
874
900
  // Capture-phase close so a click anywhere dismisses the menu, but
@@ -937,6 +963,10 @@
937
963
  window.addEventListener('hashchange', this._onHashChange);
938
964
  window.addEventListener('click', this._onDocClick, true);
939
965
  this.addEventListener('click', this._onTap);
966
+ // touchend stays non-passive: preventDefault there is what stops the
967
+ // trailing compatibility click from paging a second time.
968
+ this.addEventListener('touchstart', this._onTouchStart, { passive: true });
969
+ this.addEventListener('touchend', this._onTouchEnd, { passive: false });
940
970
  // Print lays every slide out as its own page, so [data-deck-active]-
941
971
  // gated entrance styles need the attribute on every slide (not just
942
972
  // the current one) or their content prints at the hidden base style.
@@ -1369,6 +1399,8 @@
1369
1399
  if (this._freezeStyle) { this._freezeStyle.remove(); this._freezeStyle = null; }
1370
1400
  if (this._dragGhost) { this._dragGhost.remove(); this._dragGhost = null; }
1371
1401
  this.removeEventListener('click', this._onTap);
1402
+ this.removeEventListener('touchstart', this._onTouchStart);
1403
+ this.removeEventListener('touchend', this._onTouchEnd);
1372
1404
  if (this._liveTimer) clearTimeout(this._liveTimer);
1373
1405
  if (this._authorCssTimer) clearTimeout(this._authorCssTimer);
1374
1406
  if (this._railAnimTimer) clearTimeout(this._railAnimTimer);
@@ -1897,7 +1929,7 @@
1897
1929
  total: this._slides.length,
1898
1930
  slide: this._slides[curr] || null,
1899
1931
  previousSlide: prev >= 0 ? (this._slides[prev] || null) : null,
1900
- reason: reason, // 'init' | 'keyboard' | 'click' | 'tap' | 'api'
1932
+ reason: reason, // 'init' | 'keyboard' | 'click' | 'tap' | 'swipe' | 'api'
1901
1933
  };
1902
1934
  this.dispatchEvent(new CustomEvent('slidechange', {
1903
1935
  detail,
@@ -2241,6 +2273,9 @@
2241
2273
  }
2242
2274
 
2243
2275
  _onTap(e) {
2276
+ // A swipe already paged; the click the browser synthesises after it must
2277
+ // not page again. Set in _onTouchEnd, cleared on the next touchstart.
2278
+ if (this._swipeNav) return;
2244
2279
  // Touch-only for normal browse/edit — on desktop there, keyboard + the
2245
2280
  // overlay toolbar cover nav. But in presenting mode the overlay is hidden
2246
2281
  // and click-to-advance is the expected gesture (Keynote/PPT), so allow it
@@ -2293,6 +2328,62 @@
2293
2328
  return x < 1 / 3 ? 'prev' : x > 2 / 3 ? 'next' : 'menu';
2294
2329
  }
2295
2330
 
2331
+ // Swipe paging, mobile presenting only. The deck travels with the finger:
2332
+ // dragging left/up pulls the next slide in, right/down the previous one.
2333
+ // That is deliberately the mirror of the tap zones (tap left = previous,
2334
+ // a positional target rather than a drag) — the same pair every deck app
2335
+ // ships, so neither half should be "fixed" to match the other.
2336
+ // Browse mode is excluded on purpose — there the vertical gesture is the
2337
+ // card list's own scroll, and a horizontal one has no counterpart.
2338
+ _onTouchStart(e) {
2339
+ // Cleared at the start of every touch rather than after the suppressed
2340
+ // click: a WebView that swallows that click outright would otherwise
2341
+ // leave the flag set and eat the next genuine tap. Resetting here is
2342
+ // also what makes a second finger (pinch) abandon the gesture.
2343
+ this._swipeNav = false;
2344
+ this._swipeFrom = null;
2345
+ if (e.touches.length !== 1) return;
2346
+ if (!this.hasAttribute('data-mobile-present')) return;
2347
+ const path = e.composedPath();
2348
+ if (!this._stage || !path.includes(this._stage)) return;
2349
+ for (const n of path) {
2350
+ if (n === this._stage) break;
2351
+ if (n.matches && n.matches(INTERACTIVE_SEL)) return;
2352
+ if (isScrollable(n)) return;
2353
+ }
2354
+ const t = e.touches[0];
2355
+ this._swipeFrom = { x: t.clientX, y: t.clientY };
2356
+ }
2357
+
2358
+ _onTouchEnd(e) {
2359
+ const from = this._swipeFrom;
2360
+ this._swipeFrom = null;
2361
+ // Another finger still down: this is the tail of a multi-touch gesture,
2362
+ // not a swipe that ended.
2363
+ if (!from || e.touches.length) return;
2364
+ const t = e.changedTouches && e.changedTouches[0];
2365
+ if (!t) return;
2366
+ const dx = t.clientX - from.x;
2367
+ const dy = t.clientY - from.y;
2368
+ // Rotated stage = the visual axes come off the viewport swapped. Reached
2369
+ // through the same predicate as the tap zones, and derived the same way:
2370
+ // _mobPresentZone reads visual x off viewport y, which fixes visual y as
2371
+ // the negated viewport x.
2372
+ const rotated = this._presentRotated();
2373
+ const vx = rotated ? dy : dx;
2374
+ const vy = rotated ? -dx : dy;
2375
+ const major = Math.abs(vx) >= Math.abs(vy) ? vx : vy;
2376
+ const minor = Math.abs(vx) >= Math.abs(vy) ? vy : vx;
2377
+ if (Math.abs(major) < SWIPE_MIN_PX) return;
2378
+ if (Math.abs(major) < Math.abs(minor) * SWIPE_AXIS_RATIO) return;
2379
+ this._swipeNav = true;
2380
+ e.preventDefault();
2381
+ this._advance(major < 0 ? 1 : -1, 'swipe');
2382
+ // Parity with tap: a gesture while the control layer is up restarts its
2383
+ // auto-hide instead of letting it disappear mid-navigation.
2384
+ if (this.hasAttribute('data-mob-ui')) this._toggleMobUi(true);
2385
+ }
2386
+
2296
2387
  _toggleMobUi(force) {
2297
2388
  const wasOpen = this.hasAttribute('data-mob-ui');
2298
2389
  const on = force != null ? !!force : !wasOpen;