@seams/wallet 0.9.1 → 0.9.2

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/README.md CHANGED
@@ -1,18 +1,18 @@
1
1
  # Seams Wallet SDK
2
2
 
3
- `@seams/wallet` **0.9.1** provides browser wallet lifecycle, NEAR and EVM-family
3
+ `@seams/wallet` **0.9.2** provides browser wallet lifecycle, NEAR and EVM-family
4
4
  threshold signing, React components, and hosted wallet runtime assets.
5
5
 
6
6
  ## Install
7
7
 
8
8
  ```sh
9
- pnpm add @seams/wallet@0.9.1
9
+ pnpm add @seams/wallet@0.9.2
10
10
  ```
11
11
 
12
12
  React integrations support React 18 and 19. Import the provider and UI from
13
13
  `@seams/wallet/react` and its stylesheet from `@seams/wallet/react/styles`.
14
14
  Keep the application package, wallet-origin assets, and
15
- `@seams/wallet-server@0.9.1` on the matching release.
15
+ `@seams/wallet-server@0.9.2` on the matching release.
16
16
 
17
17
  ## Next release migration (unreleased)
18
18
 
@@ -1 +1 @@
1
- ae160ae14f2523702c4fef83cd460099dc8ebef71ae5079e056f38d97cc5d19d
1
+ 392dfb0f192f2256956e72a6ec24a6d93a8c39e38b83581ad6c62f1dd73df7a5
@@ -1,4 +1,4 @@
1
- import { dispatchSurfaceResizeBegin } from "./surface-resize-events.js";
1
+ import { addSurfaceResizeBeginListener, dispatchSurfaceResizeBegin } from "./surface-resize-events.js";
2
2
  //#region src/core/signingEngine/uiConfirm/ui/confirm-surface-resize.ts
3
3
  /**
4
4
  * Host-driven height changes for wallet-iframe confirmations.
@@ -25,6 +25,10 @@ import { dispatchSurfaceResizeBegin } from "./surface-resize-events.js";
25
25
  *
26
26
  * The module owns the rules for iframe-hosted confirmation reflow.
27
27
  */
28
+ const CONFIRM_SURFACE_MODE_ATTR = "data-seams-confirm-surface";
29
+ const CONFIRM_SURFACE_MODE_WALLET_IFRAME = "wallet-iframe";
30
+ /** Marks the confirmer host while its height is held at a motion's target. */
31
+ const CONFIRM_SURFACE_PINNED_CLASS = "seams-confirm-surface-pinned";
28
32
  /**
29
33
  * Marks the document root for the same span. It is a second class rather than
30
34
  * the one above because the host rule must match any element that hosts a
@@ -37,6 +41,24 @@ const CONFIRM_SURFACE_PINNED_ROOT_CLASS = "seams-confirm-surface-pinned-root";
37
41
  const CONFIRM_SURFACE_HEIGHT_DRIVEN_CLASS = "seams-surface-height-driven";
38
42
  /** The CSS variable the class above reads. Components own the write (CSP). */
39
43
  const CONFIRM_SURFACE_HEIGHT_DRIVEN_VAR = "--seams-surface-height-driven-target";
44
+ /** Frames the box may sit still, after it has moved, before its motion counts as over. */
45
+ const SETTLED_FRAMES_AFTER_MOTION = 8;
46
+ /** Frames to wait for the parent to react at all before giving up on it. */
47
+ const SETTLED_FRAMES_WITHOUT_MOTION = 20;
48
+ /**
49
+ * The parent writes the destination box and forces a layout BEFORE it starts
50
+ * its ease, and a cross-origin iframe can receive that destination size for one
51
+ * frame before the animation snaps it back to the origin. Landing on that
52
+ * frame finishes the interior instantly and leaves the box to ease on its
53
+ * own — the exact jank this module exists to remove. A box that jumps straight
54
+ * to the target therefore has to stay there this many frames before the
55
+ * content lands on it; a box that eased through intermediate sizes lands at
56
+ * once. The parent pins the iframe to the origin for that read
57
+ * (`overlay-styles.ts pinDialogIframe`), so this is the second of two guards.
58
+ */
59
+ const LANDING_CONFIRM_FRAMES = 3;
60
+ /** The parent rounds the measured size; allow that much slack when asking whether the box hugs the host. */
61
+ const HUG_TOLERANCE_CSS_PX = 1;
40
62
  /** A host that claims a motion and never lands it must not leave content clamped. */
41
63
  const ANNOUNCE_SAFETY_MS = 1500;
42
64
  /** Height changes below this are not worth a motion, and round to nothing. */
@@ -169,7 +191,156 @@ function announceClampedSurfaceResize(args) {
169
191
  if (!claimed) element.classList.remove(...addedClasses);
170
192
  return claimed;
171
193
  }
194
+ let diagnosticHost = null;
195
+ const surfaceMotionDiagnostics = {
196
+ blipFrames: 0,
197
+ trace(durationMs = 2e3) {
198
+ return new Promise((resolve) => {
199
+ const lines = [];
200
+ const startedAt = performance.now();
201
+ const tick = () => {
202
+ const host = diagnosticHost;
203
+ const pinned = host?.classList.contains(CONFIRM_SURFACE_PINNED_CLASS) ? "*" : "";
204
+ lines.push(`${Math.round(performance.now() - startedAt)}: box=${document.documentElement.clientHeight} content=${host ? Math.round(host.getBoundingClientRect().height) : "-"}${pinned}`);
205
+ if (performance.now() - startedAt < durationMs) requestAnimationFrame(tick);
206
+ else resolve(lines);
207
+ };
208
+ requestAnimationFrame(tick);
209
+ });
210
+ }
211
+ };
212
+ function publishDiagnostics(element) {
213
+ diagnosticHost = element;
214
+ try {
215
+ window.__seamsSurfaceMotion = surfaceMotionDiagnostics;
216
+ } catch {}
217
+ }
218
+ function defaultViewportHeightCssPx() {
219
+ const height = document.documentElement?.clientHeight ?? 0;
220
+ return height > 0 ? height : window.innerHeight;
221
+ }
222
+ function clamp(value, min, max) {
223
+ return Math.min(Math.max(value, min), max);
224
+ }
225
+ function isWalletIframeConfirmSurface(element) {
226
+ return element.getAttribute(CONFIRM_SURFACE_MODE_ATTR) === CONFIRM_SURFACE_MODE_WALLET_IFRAME;
227
+ }
228
+ function createHostHeightPin(element) {
229
+ if (typeof CSSStyleSheet !== "function" || !("adoptedStyleSheets" in document)) return null;
230
+ let sheet = null;
231
+ const release = () => {
232
+ element.classList.remove(CONFIRM_SURFACE_PINNED_CLASS);
233
+ document.documentElement.classList.remove(CONFIRM_SURFACE_PINNED_ROOT_CLASS);
234
+ };
235
+ return {
236
+ set(px) {
237
+ try {
238
+ if (!sheet) sheet = new CSSStyleSheet();
239
+ sheet.replaceSync(`.${CONFIRM_SURFACE_PINNED_CLASS}{height:${Math.max(0, Math.round(px))}px}.${CONFIRM_SURFACE_PINNED_ROOT_CLASS}{overflow:hidden}`);
240
+ if (!document.adoptedStyleSheets.includes(sheet)) document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
241
+ } catch {
242
+ return false;
243
+ }
244
+ element.classList.add(CONFIRM_SURFACE_PINNED_CLASS);
245
+ document.documentElement.classList.add(CONFIRM_SURFACE_PINNED_ROOT_CLASS);
246
+ return true;
247
+ },
248
+ release,
249
+ dispose() {
250
+ release();
251
+ if (!sheet) return;
252
+ const retired = sheet;
253
+ sheet = null;
254
+ try {
255
+ document.adoptedStyleSheets = document.adoptedStyleSheets.filter((s) => s !== retired);
256
+ } catch {}
257
+ }
258
+ };
259
+ }
260
+ function attachConfirmSurfaceResizeChoreographer(element, options = {}) {
261
+ const readViewportHeightCssPx = options.viewportHeightCssPx ?? defaultViewportHeightCssPx;
262
+ const pin = createHostHeightPin(element);
263
+ publishDiagnostics(element);
264
+ let active = null;
265
+ const settle = () => {
266
+ const current = active;
267
+ if (!current) return;
268
+ active = null;
269
+ if (current.frame !== null) cancelAnimationFrame(current.frame);
270
+ current.driver.setProgress(1);
271
+ current.driver.finish();
272
+ pin?.release();
273
+ };
274
+ const step = () => {
275
+ const current = active;
276
+ if (!current) return;
277
+ current.frame = null;
278
+ const viewportPx = readViewportHeightCssPx();
279
+ if (viewportPx !== current.lastViewportPx) {
280
+ current.lastViewportPx = viewportPx;
281
+ current.framesSinceChange = 0;
282
+ current.moved = true;
283
+ } else current.framesSinceChange += 1;
284
+ const progress = clamp((viewportPx - current.originHostPx) / current.deltaCssPx, 0, 1);
285
+ if (progress >= 1) {
286
+ current.framesAtTarget += 1;
287
+ if (current.sawIntermediate || current.framesAtTarget >= LANDING_CONFIRM_FRAMES) {
288
+ settle();
289
+ return;
290
+ }
291
+ current.frame = requestAnimationFrame(step);
292
+ return;
293
+ }
294
+ if (current.framesAtTarget > 0) surfaceMotionDiagnostics.blipFrames += 1;
295
+ current.framesAtTarget = 0;
296
+ if (progress > 0) current.sawIntermediate = true;
297
+ current.driver.setProgress(progress);
298
+ const settledFrames = current.moved ? SETTLED_FRAMES_AFTER_MOTION : SETTLED_FRAMES_WITHOUT_MOTION;
299
+ if (current.framesSinceChange >= settledFrames) {
300
+ settle();
301
+ return;
302
+ }
303
+ current.frame = requestAnimationFrame(step);
304
+ };
305
+ const onSurfaceResizeBegin = (event) => {
306
+ const detail = event.detail;
307
+ if (!pin || !detail || !isWalletIframeConfirmSurface(element)) return;
308
+ const deltaCssPx = detail.deltaCssPx;
309
+ if (!Number.isFinite(deltaCssPx) || Math.abs(deltaCssPx) < MIN_ANNOUNCED_DELTA_CSS_PX) return;
310
+ settle();
311
+ const viewportPx = readViewportHeightCssPx();
312
+ const hostPx = element.getBoundingClientRect().height;
313
+ if (!(viewportPx > 0) || !(hostPx > 0) || Math.abs(viewportPx - hostPx) > HUG_TOLERANCE_CSS_PX) return;
314
+ const originHostPx = Math.round(hostPx);
315
+ const targetHostPx = originHostPx + deltaCssPx;
316
+ if (!(targetHostPx > 0)) return;
317
+ if (!pin.set(targetHostPx)) return;
318
+ const driver = detail.claim();
319
+ if (!driver) {
320
+ pin.release();
321
+ return;
322
+ }
323
+ active = {
324
+ driver,
325
+ originHostPx,
326
+ deltaCssPx,
327
+ lastViewportPx: viewportPx,
328
+ framesSinceChange: 0,
329
+ moved: false,
330
+ sawIntermediate: false,
331
+ framesAtTarget: 0,
332
+ frame: null
333
+ };
334
+ active.frame = requestAnimationFrame(step);
335
+ };
336
+ const removeListener = addSurfaceResizeBeginListener(element, onSurfaceResizeBegin);
337
+ return { dispose() {
338
+ removeListener();
339
+ settle();
340
+ pin?.dispose();
341
+ } };
342
+ }
172
343
  //#endregion
173
- export { CONFIRM_SURFACE_HEIGHT_DRIVEN_VAR, announceClampedSurfaceResize, createSurfaceHeightReflow };
344
+ export { CONFIRM_SURFACE_HEIGHT_DRIVEN_VAR, CONFIRM_SURFACE_MODE_ATTR, announceClampedSurfaceResize, announceSurfaceResize, attachConfirmSurfaceResizeChoreographer, createSurfaceHeightReflow };
174
345
 
175
346
  //# sourceMappingURL=confirm-surface-resize.js.map
@@ -7,7 +7,12 @@ function dispatchSurfaceResizeBegin(target, detail) {
7
7
  detail
8
8
  }));
9
9
  }
10
+ function addSurfaceResizeBeginListener(target, listener, options) {
11
+ const handler = listener;
12
+ target.addEventListener(SURFACE_RESIZE_BEGIN_EVENT, handler, options);
13
+ return () => target.removeEventListener(SURFACE_RESIZE_BEGIN_EVENT, handler, options);
14
+ }
10
15
  //#endregion
11
- export { dispatchSurfaceResizeBegin };
16
+ export { addSurfaceResizeBeginListener, dispatchSurfaceResizeBegin };
12
17
 
13
18
  //# sourceMappingURL=surface-resize-events.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "packageName": "@seams/wallet",
4
- "packageVersion": "0.9.1",
4
+ "packageVersion": "0.9.2",
5
5
  "assetRoot": "dist/public",
6
6
  "routeClasses": [
7
7
  {
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "packageName": "@seams/wallet",
4
- "packageVersion": "0.9.1",
4
+ "packageVersion": "0.9.2",
5
5
  "assetRoot": "dist/public",
6
6
  "sdkBasePath": "/sdk",
7
7
  "walletServicePath": "/wallet-service",
8
8
  "headersManifest": "headers.manifest.json",
9
9
  "versionSkewContract": {
10
10
  "kind": "wallet_iframe_protocol_handshake",
11
- "packageVersion": "0.9.1",
11
+ "packageVersion": "0.9.2",
12
12
  "protocolVersion": "15.0.0",
13
13
  "readyPayloadField": "protocolVersion",
14
14
  "failureMode": "typed_error",
@@ -5,14 +5,14 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
6
  <title>Web3Authn Wallet Service</title>
7
7
  <!-- Surface styles are external so strict CSP can keep style-src 'self' -->
8
- <link rel="stylesheet" href="/sdk/wallet-ui.css?v=0.9.1" />
8
+ <link rel="stylesheet" href="/sdk/wallet-ui.css?v=0.9.2" />
9
9
  <!-- Minimal shims some ESM bundles expect (externalized to enable strict CSP) -->
10
- <script src="/sdk/wallet-shims.js?v=0.9.1"></script>
10
+ <script src="/sdk/wallet-shims.js?v=0.9.2"></script>
11
11
  <!-- Hint the browser to fetch the host script earlier -->
12
- <link rel="modulepreload" href="/sdk/wallet-iframe-host-runtime.js?v=0.9.1" crossorigin>
12
+ <link rel="modulepreload" href="/sdk/wallet-iframe-host-runtime.js?v=0.9.2" crossorigin>
13
13
  </head>
14
14
  <body>
15
15
  <!-- sdkBasePath points to the SDK root (e.g. '/sdk'). Load the host directly. -->
16
- <script type="module" src="/sdk/wallet-iframe-host-runtime.js?v=0.9.1"></script>
16
+ <script type="module" src="/sdk/wallet-iframe-host-runtime.js?v=0.9.2"></script>
17
17
  </body>
18
18
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seams/wallet",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "type": "module",
5
5
  "description": "Seams web and runtime TypeScript SDK for NEAR and EVM-family wallets",
6
6
  "main": "./dist/esm/index.js",