dsh-zen-remote 1.1.2 → 1.1.4
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 +27 -9
- package/docs/interface.md +6 -5
- package/lib/client.js +2145 -1875
- package/lib/index.js +21 -1
- package/lib/index.js.map +1 -1
- package/lib/types/client/client-config.d.ts +51 -0
- package/lib/types/client/client-config.d.ts.map +1 -0
- package/lib/types/client/effects/keyboard-avoid.d.ts +14 -7
- package/lib/types/client/effects/keyboard-avoid.d.ts.map +1 -1
- package/lib/types/client/effects/turn-fold.d.ts +14 -0
- package/lib/types/client/effects/turn-fold.d.ts.map +1 -1
- package/lib/types/client/styles/compat.css.d.ts +1 -1
- package/lib/types/client/styles/compat.css.d.ts.map +1 -1
- package/lib/types/client/styles/composer.css.d.ts +1 -1
- package/lib/types/client/styles/composer.css.d.ts.map +1 -1
- package/lib/types/client/styles/turn-fold.css.d.ts.map +1 -1
- package/lib/types/index.d.ts +25 -0
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +11 -11
- package/scripts/check-keyboard-avoid.mjs +39 -0
- package/src/client/client-config.ts +86 -0
- package/src/client/effects/keyboard-avoid.ts +34 -14
- package/src/client/effects/turn-fold.ts +22 -17
- package/src/client/styles/compat.css.ts +85 -0
- package/src/client/styles/composer.css.ts +61 -1
- package/src/client/styles/turn-fold.css.ts +51 -8
- package/src/index.ts +35 -1
package/src/index.ts
CHANGED
|
@@ -51,6 +51,35 @@ export interface MobileNavConfig {
|
|
|
51
51
|
* phone breakpoint. Default false (phone-only). A browser can still opt
|
|
52
52
|
* itself in via `?mobile-nav-turn-fold=1` when this is off. */
|
|
53
53
|
turnFoldDesktop?: boolean
|
|
54
|
+
/** Calibration for the composer lift used when a phone's keyboard is
|
|
55
|
+
* invisible to the browser (src/client/effects/keyboard-avoid.ts). Leave
|
|
56
|
+
* every one of these unset to keep the shipped estimate — the route omits
|
|
57
|
+
* what the row never set, and the client half owns the defaults, so there
|
|
58
|
+
* is one place each default is written.
|
|
59
|
+
*
|
|
60
|
+
* Share of the layout viewport the estimated lift starts from (shipped
|
|
61
|
+
* 0.42). Clamped to 0-1. */
|
|
62
|
+
keyboardLiftRatio?: number
|
|
63
|
+
/** Ceiling on that estimate in CSS pixels (shipped 400). Clamped to 0-2000. */
|
|
64
|
+
keyboardLiftMaxPx?: number
|
|
65
|
+
/** Extra clearance above a keyboard the browser DID react to, Android only
|
|
66
|
+
* (shipped 15). Clamped to 0-200. */
|
|
67
|
+
keyboardSafetyPadPx?: number
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* One configured number on its way to the browser, clamped into a band that
|
|
72
|
+
* cannot break the composer — a ratio of 5 or a 9000px lift would push the
|
|
73
|
+
* input clean off the screen with no way back except editing the YAML again.
|
|
74
|
+
* Absent from the result when the row left it unset or wrote something that
|
|
75
|
+
* is not a finite number, which leaves the client on its shipped default.
|
|
76
|
+
*
|
|
77
|
+
* Exported for scripts/check-keyboard-avoid.mjs — this is the trust boundary
|
|
78
|
+
* between a hand-edited YAML row and the browser, so it is asserted directly.
|
|
79
|
+
*/
|
|
80
|
+
export function clamped(key: string, value: number | undefined, min: number, max: number): Record<string, number> {
|
|
81
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) return {}
|
|
82
|
+
return { [key]: Math.min(Math.max(value, min), max) }
|
|
54
83
|
}
|
|
55
84
|
|
|
56
85
|
/**
|
|
@@ -361,7 +390,12 @@ export function apply(ctx: Context, config: MobileNavConfig = {}): void {
|
|
|
361
390
|
responseJson(res, 405, { ok: false, error: { code: 'method-not-allowed', message: 'Use GET' } })
|
|
362
391
|
return
|
|
363
392
|
}
|
|
364
|
-
responseJson(res, 200, {
|
|
393
|
+
responseJson(res, 200, {
|
|
394
|
+
turnFoldDesktop: config.turnFoldDesktop === true,
|
|
395
|
+
...clamped('keyboardLiftRatio', config.keyboardLiftRatio, 0, 1),
|
|
396
|
+
...clamped('keyboardLiftMaxPx', config.keyboardLiftMaxPx, 0, 2000),
|
|
397
|
+
...clamped('keyboardSafetyPadPx', config.keyboardSafetyPadPx, 0, 200),
|
|
398
|
+
})
|
|
365
399
|
},
|
|
366
400
|
}), 'dsh-mobile-nav: client config route')
|
|
367
401
|
})
|