capacitor-device-profile 0.0.0-stage → 0.1.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.
Files changed (59) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/CONTRIBUTING.md +52 -0
  3. package/LICENSE +21 -0
  4. package/README.md +83 -2
  5. package/SECURITY.md +26 -0
  6. package/dist/cjs/haptics.cjs +37 -0
  7. package/dist/cjs/haptics.d.cts +36 -0
  8. package/dist/cjs/haptics.d.cts.map +1 -0
  9. package/dist/cjs/index.cjs +24 -0
  10. package/dist/cjs/index.d.cts +6 -0
  11. package/dist/cjs/index.d.cts.map +1 -0
  12. package/dist/cjs/lifecycle.cjs +85 -0
  13. package/dist/cjs/lifecycle.d.cts +48 -0
  14. package/dist/cjs/lifecycle.d.cts.map +1 -0
  15. package/dist/cjs/orientation.cjs +16 -0
  16. package/dist/cjs/orientation.d.cts +21 -0
  17. package/dist/cjs/orientation.d.cts.map +1 -0
  18. package/dist/cjs/package.json +3 -0
  19. package/dist/cjs/profile.cjs +86 -0
  20. package/dist/cjs/profile.d.cts +71 -0
  21. package/dist/cjs/profile.d.cts.map +1 -0
  22. package/dist/cjs/react.cjs +61 -0
  23. package/dist/cjs/react.d.cts +16 -0
  24. package/dist/cjs/react.d.cts.map +1 -0
  25. package/dist/cjs/safeArea.cjs +99 -0
  26. package/dist/cjs/safeArea.d.cts +33 -0
  27. package/dist/cjs/safeArea.d.cts.map +1 -0
  28. package/dist/esm/haptics.d.ts +36 -0
  29. package/dist/esm/haptics.d.ts.map +1 -0
  30. package/dist/esm/haptics.js +34 -0
  31. package/dist/esm/index.d.ts +6 -0
  32. package/dist/esm/index.d.ts.map +1 -0
  33. package/dist/esm/index.js +5 -0
  34. package/dist/esm/lifecycle.d.ts +48 -0
  35. package/dist/esm/lifecycle.d.ts.map +1 -0
  36. package/dist/esm/lifecycle.js +82 -0
  37. package/dist/esm/orientation.d.ts +21 -0
  38. package/dist/esm/orientation.d.ts.map +1 -0
  39. package/dist/esm/orientation.js +13 -0
  40. package/dist/esm/profile.d.ts +71 -0
  41. package/dist/esm/profile.d.ts.map +1 -0
  42. package/dist/esm/profile.js +77 -0
  43. package/dist/esm/react.d.ts +16 -0
  44. package/dist/esm/react.d.ts.map +1 -0
  45. package/dist/esm/react.js +56 -0
  46. package/dist/esm/safeArea.d.ts +33 -0
  47. package/dist/esm/safeArea.d.ts.map +1 -0
  48. package/dist/esm/safeArea.js +93 -0
  49. package/docs/API.md +123 -0
  50. package/docs/ARCHITECTURE.md +49 -0
  51. package/docs/contributing.md +26 -0
  52. package/package.json +143 -4
  53. package/src/haptics.ts +63 -0
  54. package/src/index.ts +47 -0
  55. package/src/lifecycle.ts +130 -0
  56. package/src/orientation.ts +39 -0
  57. package/src/profile.ts +126 -0
  58. package/src/react.tsx +80 -0
  59. package/src/safeArea.ts +114 -0
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Device profile: a pure classification of the current viewport into the categories a game's layout
3
+ * actually branches on. Every input is injectable so the classification unit-tests without a browser
4
+ * and so a native shell can feed it platform facts (Capacitor `Device.getInfo()`).
5
+ */
6
+ /** `compact` lays a HUD out for a phone; `expanded` has room for side panels. */
7
+ export type FrameClass = 'compact' | 'expanded';
8
+ export type ViewOrientation = 'portrait' | 'landscape';
9
+ /**
10
+ * The form factor a layout targets. `foldable-open` is an unfolded book-style foldable (OnePlus Open,
11
+ * Galaxy Z Fold, Pixel Fold): touch-primary, tablet-sized and near-square, so it plays in either
12
+ * orientation and needs a layout of its own rather than a stretched phone or a squashed tablet one.
13
+ */
14
+ export type FormFactor = 'phone' | 'foldable-open' | 'tablet' | 'desktop';
15
+ /** Platform names as Capacitor's `Device.getInfo().platform` reports them. */
16
+ export type DevicePlatform = 'web' | 'android' | 'ios' | 'electron';
17
+ export interface ViewportFacts {
18
+ /** CSS pixels (`window.innerWidth`). */
19
+ width: number;
20
+ /** CSS pixels (`window.innerHeight`). */
21
+ height: number;
22
+ devicePixelRatio: number;
23
+ /** True when the primary input is touch (`maxTouchPoints > 0`). */
24
+ touch: boolean;
25
+ platform: DevicePlatform;
26
+ /** Native model string; used only to recognise iPads, which report a phone-like platform. */
27
+ model: string;
28
+ }
29
+ export type DeviceProfile = Readonly<{
30
+ frame: FrameClass;
31
+ formFactor: FormFactor;
32
+ orientation: ViewOrientation;
33
+ platform: DevicePlatform;
34
+ native: boolean;
35
+ touch: boolean;
36
+ shortEdge: number;
37
+ longEdge: number;
38
+ /** Long edge divided by short edge; 1 is square. */
39
+ aspect: number;
40
+ devicePixelRatio: number;
41
+ }>;
42
+ /** Short edge (CSS px) at which a frame counts as expanded. Phones stay below ~480. */
43
+ export declare const EXPANDED_MIN_SHORT_EDGE = 700;
44
+ /** Short edge (CSS px) from which a touch screen is tablet-sized rather than a phone. */
45
+ export declare const TABLET_MIN_SHORT_EDGE = 600;
46
+ /**
47
+ * Long/short aspect at or below which a screen is near-square. A phone in portrait is ~2.1, a 4:3
48
+ * tablet 1.33, an unfolded OnePlus Open ~1.08.
49
+ */
50
+ export declare const NEAR_SQUARE_MAX_ASPECT = 1.3;
51
+ export declare function classifyOrientation(width: number, height: number): ViewOrientation;
52
+ /** True for an unfolded book-style foldable: near-square and tablet-sized, on a touch screen. */
53
+ export declare function isFoldableOpen(facts: Pick<ViewportFacts, 'width' | 'height' | 'touch'>): boolean;
54
+ export declare function classifyFormFactor(facts: ViewportFacts): FormFactor;
55
+ export declare function classifyFrame(facts: ViewportFacts): FrameClass;
56
+ export declare function classifyDevice(facts: ViewportFacts): DeviceProfile;
57
+ interface BrowserLike {
58
+ innerWidth: number;
59
+ innerHeight: number;
60
+ devicePixelRatio?: number;
61
+ navigator?: {
62
+ maxTouchPoints?: number;
63
+ };
64
+ }
65
+ /**
66
+ * Reads viewport facts from a window (`null` outside a browser gives a 1280x720 desktop default).
67
+ * Platform facts default to `web` until a native shell says otherwise.
68
+ */
69
+ export declare function readViewportFacts(win?: BrowserLike | null, platform?: Pick<ViewportFacts, 'platform' | 'model'>): ViewportFacts;
70
+ export {};
71
+ //# sourceMappingURL=profile.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/profile.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,iFAAiF;AACjF,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,UAAU,CAAA;AAC/C,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,WAAW,CAAA;AACtD;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,eAAe,GAAG,QAAQ,GAAG,SAAS,CAAA;AACzE,8EAA8E;AAC9E,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,UAAU,CAAA;AAEnE,MAAM,WAAW,aAAa;IAC5B,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAA;IACb,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAA;IACd,gBAAgB,EAAE,MAAM,CAAA;IACxB,mEAAmE;IACnE,KAAK,EAAE,OAAO,CAAA;IACd,QAAQ,EAAE,cAAc,CAAA;IACxB,6FAA6F;IAC7F,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IACnC,KAAK,EAAE,UAAU,CAAA;IACjB,UAAU,EAAE,UAAU,CAAA;IACtB,WAAW,EAAE,eAAe,CAAA;IAC5B,QAAQ,EAAE,cAAc,CAAA;IACxB,MAAM,EAAE,OAAO,CAAA;IACf,KAAK,EAAE,OAAO,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAA;IACd,gBAAgB,EAAE,MAAM,CAAA;CACzB,CAAC,CAAA;AAEF,uFAAuF;AACvF,eAAO,MAAM,uBAAuB,MAAM,CAAA;AAC1C,yFAAyF;AACzF,eAAO,MAAM,qBAAqB,MAAM,CAAA;AACxC;;;GAGG;AACH,eAAO,MAAM,sBAAsB,MAAM,CAAA;AAEzC,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,eAAe,CAElF;AAED,iGAAiG;AACjG,wBAAgB,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC,GAAG,OAAO,CAMhG;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,aAAa,GAAG,UAAU,CAOnE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,UAAU,CAG9D;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CAgBlE;AAED,UAAU,WAAW;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,SAAS,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CACxC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,GAAE,WAAW,GAAG,IAAoD,EACvE,QAAQ,GAAE,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,OAAO,CAAkC,GACnF,aAAa,CAWf"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.subscribeViewportGeometry = subscribeViewportGeometry;
4
+ exports.useDeviceProfile = useDeviceProfile;
5
+ exports.useSafeAreaInsets = useSafeAreaInsets;
6
+ /**
7
+ * React bindings: a live device profile and live safe-area insets. Both re-read on resize,
8
+ * orientation change, visual-viewport resize and fold posture change, so a foldable switches layout
9
+ * when it is folded or unfolded without a reload.
10
+ */
11
+ const react_1 = require("react");
12
+ const profile_js_1 = require("./profile.cjs");
13
+ const safeArea_js_1 = require("./safeArea.cjs");
14
+ const WEB = { platform: 'web', model: '' };
15
+ /** Subscribes to every event that changes viewport geometry, including fold posture changes. */
16
+ function subscribeViewportGeometry(callback) {
17
+ const fold = typeof window.matchMedia === 'function'
18
+ ? window.matchMedia('(horizontal-viewport-segments: 2), (vertical-viewport-segments: 2)')
19
+ : null;
20
+ window.addEventListener('resize', callback);
21
+ window.addEventListener('orientationchange', callback);
22
+ window.visualViewport?.addEventListener('resize', callback);
23
+ fold?.addEventListener('change', callback);
24
+ return () => {
25
+ window.removeEventListener('resize', callback);
26
+ window.removeEventListener('orientationchange', callback);
27
+ window.visualViewport?.removeEventListener('resize', callback);
28
+ fold?.removeEventListener('change', callback);
29
+ };
30
+ }
31
+ function useDeviceProfile(options = {}) {
32
+ const [platform, setPlatform] = (0, react_1.useState)(options.platform ?? WEB);
33
+ const [profile, setProfile] = (0, react_1.useState)(() => (0, profile_js_1.classifyDevice)((0, profile_js_1.readViewportFacts)(typeof window === 'undefined' ? null : window, platform)));
34
+ const loadPlatform = options.loadPlatform;
35
+ (0, react_1.useEffect)(() => {
36
+ if (!loadPlatform)
37
+ return;
38
+ let cancelled = false;
39
+ loadPlatform()
40
+ .then((info) => {
41
+ if (!cancelled)
42
+ setPlatform({ platform: info.platform, model: info.model });
43
+ })
44
+ .catch(() => undefined);
45
+ return () => {
46
+ cancelled = true;
47
+ };
48
+ }, [loadPlatform]);
49
+ (0, react_1.useEffect)(() => {
50
+ const update = () => setProfile((0, profile_js_1.classifyDevice)((0, profile_js_1.readViewportFacts)(window, platform)));
51
+ update();
52
+ return subscribeViewportGeometry(update);
53
+ }, [platform]);
54
+ return profile;
55
+ }
56
+ /** Live safe-area insets; also publishes `--safe-*` CSS variables on the root element. */
57
+ function useSafeAreaInsets() {
58
+ const [insets, setInsets] = (0, react_1.useState)(() => typeof document === 'undefined' ? { ...safeArea_js_1.ZERO_INSETS } : (0, safeArea_js_1.readSafeAreaInsets)(document));
59
+ (0, react_1.useEffect)(() => (0, safeArea_js_1.watchSafeArea)({ onChange: setInsets }), []);
60
+ return insets;
61
+ }
@@ -0,0 +1,16 @@
1
+ import { type DeviceProfile, type ViewportFacts } from './profile.cjs';
2
+ import { type SafeAreaInsets } from './safeArea.cjs';
3
+ type PlatformFacts = Pick<ViewportFacts, 'platform' | 'model'>;
4
+ export interface UseDeviceProfileOptions {
5
+ /** Platform facts known synchronously, e.g. `{ platform: Capacitor.getPlatform(), model: '' }`. */
6
+ platform?: PlatformFacts;
7
+ /** Async platform lookup, e.g. `() => Device.getInfo()` from `@capacitor/device`. */
8
+ loadPlatform?: () => Promise<PlatformFacts>;
9
+ }
10
+ /** Subscribes to every event that changes viewport geometry, including fold posture changes. */
11
+ export declare function subscribeViewportGeometry(callback: () => void): () => void;
12
+ export declare function useDeviceProfile(options?: UseDeviceProfileOptions): DeviceProfile;
13
+ /** Live safe-area insets; also publishes `--safe-*` CSS variables on the root element. */
14
+ export declare function useSafeAreaInsets(): SafeAreaInsets;
15
+ export {};
16
+ //# sourceMappingURL=react.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../src/react.tsx"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,aAAa,EAElB,KAAK,aAAa,EACnB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAsB,KAAK,cAAc,EAA8B,MAAM,eAAe,CAAA;AAEnG,KAAK,aAAa,GAAG,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,OAAO,CAAC,CAAA;AAE9D,MAAM,WAAW,uBAAuB;IACtC,mGAAmG;IACnG,QAAQ,CAAC,EAAE,aAAa,CAAA;IACxB,qFAAqF;IACrF,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,CAAA;CAC5C;AAID,gGAAgG;AAChG,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAe1E;AAED,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,uBAA4B,GAAG,aAAa,CA2BrF;AAED,0FAA0F;AAC1F,wBAAgB,iBAAiB,IAAI,cAAc,CAMlD"}
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ /**
3
+ * Safe-area insets as numbers and as CSS variables.
4
+ *
5
+ * `env(safe-area-inset-*)` already works inside CSS, but JavaScript layout (canvas HUDs, joystick
6
+ * placement) needs the numbers, and some Android WebViews do not refresh `env()` consumers after a
7
+ * fold, an orientation change or a cut-out change. `watchSafeArea` measures the insets through a
8
+ * hidden probe element and republishes them as `--safe-top/right/bottom/left` px variables on every
9
+ * resize, orientation change, visual-viewport resize and fold posture change.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ZERO_INSETS = void 0;
13
+ exports.readSafeAreaInsets = readSafeAreaInsets;
14
+ exports.applySafeAreaVariables = applySafeAreaVariables;
15
+ exports.watchSafeArea = watchSafeArea;
16
+ exports.ZERO_INSETS = Object.freeze({
17
+ top: 0,
18
+ right: 0,
19
+ bottom: 0,
20
+ left: 0,
21
+ });
22
+ const SIDES = ['top', 'right', 'bottom', 'left'];
23
+ function parsePx(value) {
24
+ const parsed = Number.parseFloat(value);
25
+ return Number.isFinite(parsed) ? parsed : 0;
26
+ }
27
+ /** Measures the current safe-area insets through a temporary probe element. */
28
+ function readSafeAreaInsets(doc = document) {
29
+ const view = doc.defaultView;
30
+ if (!view || !doc.body)
31
+ return { ...exports.ZERO_INSETS };
32
+ const probe = doc.createElement('div');
33
+ probe.setAttribute('aria-hidden', 'true');
34
+ probe.style.cssText = [
35
+ 'position:fixed',
36
+ 'visibility:hidden',
37
+ 'pointer-events:none',
38
+ 'padding-top:env(safe-area-inset-top,0px)',
39
+ 'padding-right:env(safe-area-inset-right,0px)',
40
+ 'padding-bottom:env(safe-area-inset-bottom,0px)',
41
+ 'padding-left:env(safe-area-inset-left,0px)',
42
+ ].join(';');
43
+ doc.body.appendChild(probe);
44
+ const style = view.getComputedStyle(probe);
45
+ const insets = {
46
+ top: parsePx(style.paddingTop),
47
+ right: parsePx(style.paddingRight),
48
+ bottom: parsePx(style.paddingBottom),
49
+ left: parsePx(style.paddingLeft),
50
+ };
51
+ probe.remove();
52
+ return insets;
53
+ }
54
+ function applySafeAreaVariables(insets, target, prefix = '--safe-') {
55
+ for (const side of SIDES)
56
+ target.style.setProperty(`${prefix}${side}`, `${insets[side]}px`);
57
+ }
58
+ /**
59
+ * Measures the insets now and again after every geometry change. Returns a disposer that removes all
60
+ * listeners. Measurement runs on the next animation frame so a fold reports post-layout values.
61
+ */
62
+ function watchSafeArea(options = {}) {
63
+ if (typeof window === 'undefined' || typeof document === 'undefined')
64
+ return () => undefined;
65
+ const target = options.target ?? document.documentElement;
66
+ const prefix = options.prefix ?? '--safe-';
67
+ let frame = 0;
68
+ const measure = () => {
69
+ frame = 0;
70
+ const insets = readSafeAreaInsets(document);
71
+ applySafeAreaVariables(insets, target, prefix);
72
+ options.onChange?.(insets);
73
+ };
74
+ const schedule = () => {
75
+ if (frame !== 0)
76
+ return;
77
+ frame = window.requestAnimationFrame(measure);
78
+ };
79
+ measure();
80
+ window.addEventListener('resize', schedule);
81
+ window.addEventListener('orientationchange', schedule);
82
+ window.visualViewport?.addEventListener('resize', schedule);
83
+ const fold = foldPostureMedia(window);
84
+ fold?.addEventListener('change', schedule);
85
+ return () => {
86
+ if (frame !== 0)
87
+ window.cancelAnimationFrame(frame);
88
+ window.removeEventListener('resize', schedule);
89
+ window.removeEventListener('orientationchange', schedule);
90
+ window.visualViewport?.removeEventListener('resize', schedule);
91
+ fold?.removeEventListener('change', schedule);
92
+ };
93
+ }
94
+ /** Media query that flips when a foldable changes posture; `null` where unsupported. */
95
+ function foldPostureMedia(win) {
96
+ if (typeof win.matchMedia !== 'function')
97
+ return null;
98
+ return win.matchMedia('(horizontal-viewport-segments: 2), (vertical-viewport-segments: 2)');
99
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Safe-area insets as numbers and as CSS variables.
3
+ *
4
+ * `env(safe-area-inset-*)` already works inside CSS, but JavaScript layout (canvas HUDs, joystick
5
+ * placement) needs the numbers, and some Android WebViews do not refresh `env()` consumers after a
6
+ * fold, an orientation change or a cut-out change. `watchSafeArea` measures the insets through a
7
+ * hidden probe element and republishes them as `--safe-top/right/bottom/left` px variables on every
8
+ * resize, orientation change, visual-viewport resize and fold posture change.
9
+ */
10
+ export interface SafeAreaInsets {
11
+ top: number;
12
+ right: number;
13
+ bottom: number;
14
+ left: number;
15
+ }
16
+ export declare const ZERO_INSETS: Readonly<SafeAreaInsets>;
17
+ export interface SafeAreaWatchOptions {
18
+ /** Element that receives the CSS variables. Defaults to `document.documentElement`. */
19
+ target?: HTMLElement;
20
+ /** CSS variable prefix. Defaults to `--safe-` (so `--safe-top` ...). */
21
+ prefix?: string;
22
+ /** Called with fresh insets after every measurement. */
23
+ onChange?: (insets: SafeAreaInsets) => void;
24
+ }
25
+ /** Measures the current safe-area insets through a temporary probe element. */
26
+ export declare function readSafeAreaInsets(doc?: Document): SafeAreaInsets;
27
+ export declare function applySafeAreaVariables(insets: SafeAreaInsets, target: HTMLElement, prefix?: string): void;
28
+ /**
29
+ * Measures the insets now and again after every geometry change. Returns a disposer that removes all
30
+ * listeners. Measurement runs on the next animation frame so a fold reports post-layout values.
31
+ */
32
+ export declare function watchSafeArea(options?: SafeAreaWatchOptions): () => void;
33
+ //# sourceMappingURL=safeArea.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safeArea.d.ts","sourceRoot":"","sources":["../../src/safeArea.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;CACb;AAED,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,cAAc,CAK/C,CAAA;AAIF,MAAM,WAAW,oBAAoB;IACnC,uFAAuF;IACvF,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,wEAAwE;IACxE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,wDAAwD;IACxD,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAA;CAC5C;AAOD,+EAA+E;AAC/E,wBAAgB,kBAAkB,CAAC,GAAG,GAAE,QAAmB,GAAG,cAAc,CAwB3E;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,WAAW,EACnB,MAAM,SAAY,GACjB,IAAI,CAEN;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,MAAM,IAAI,CA4B5E"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Haptics facade. Native shells pass Capacitor's `Haptics` plugin; everywhere else every call is a
3
+ * no-op, so game code calls `haptics.impact()` unconditionally. A player setting can switch it off at
4
+ * runtime through `setEnabled`, and plugin failures are swallowed: a missing buzz must never throw
5
+ * into a frame loop.
6
+ */
7
+ export type ImpactStrength = 'light' | 'medium' | 'heavy';
8
+ export type NotificationKind = 'success' | 'warning' | 'error';
9
+ /**
10
+ * The subset of Capacitor's `Haptics` plugin this module uses. The values sent are the string values
11
+ * of Capacitor's `ImpactStyle` and `NotificationType` enums; the fields are typed `string` so the real
12
+ * plugin (whose parameters are those enums) is assignable without this package importing Capacitor.
13
+ */
14
+ export interface HapticsPluginLike {
15
+ impact(options?: {
16
+ style?: string;
17
+ }): Promise<void>;
18
+ notification(options?: {
19
+ type?: string;
20
+ }): Promise<void>;
21
+ selectionChanged(): Promise<void>;
22
+ }
23
+ export interface Haptics {
24
+ readonly enabled: boolean;
25
+ setEnabled(enabled: boolean): void;
26
+ impact(strength?: ImpactStrength): void;
27
+ notify(kind: NotificationKind): void;
28
+ selection(): void;
29
+ }
30
+ export interface HapticsOptions {
31
+ plugin?: HapticsPluginLike;
32
+ native: boolean;
33
+ enabled?: boolean;
34
+ }
35
+ export declare function createHaptics(options: HapticsOptions): Haptics;
36
+ //# sourceMappingURL=haptics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"haptics.d.ts","sourceRoot":"","sources":["../../src/haptics.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAA;AACzD,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAA;AAE9D;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACnD,YAAY,CAAC,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACxD,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAClC;AAED,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAA;IAClC,MAAM,CAAC,QAAQ,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;IACvC,MAAM,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAAA;IACpC,SAAS,IAAI,IAAI,CAAA;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,iBAAiB,CAAA;IAC1B,MAAM,EAAE,OAAO,CAAA;IACf,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAKD,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAwB9D"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Haptics facade. Native shells pass Capacitor's `Haptics` plugin; everywhere else every call is a
3
+ * no-op, so game code calls `haptics.impact()` unconditionally. A player setting can switch it off at
4
+ * runtime through `setEnabled`, and plugin failures are swallowed: a missing buzz must never throw
5
+ * into a frame loop.
6
+ */
7
+ const IMPACT_STYLE = { light: 'LIGHT', medium: 'MEDIUM', heavy: 'HEAVY' };
8
+ const NOTIFICATION_TYPE = { success: 'SUCCESS', warning: 'WARNING', error: 'ERROR' };
9
+ export function createHaptics(options) {
10
+ let enabled = options.enabled ?? true;
11
+ const plugin = options.native ? options.plugin : undefined;
12
+ const fire = (call) => {
13
+ if (!enabled || !plugin)
14
+ return;
15
+ void call(plugin).catch(() => undefined);
16
+ };
17
+ return {
18
+ get enabled() {
19
+ return enabled;
20
+ },
21
+ setEnabled(next) {
22
+ enabled = next;
23
+ },
24
+ impact(strength = 'light') {
25
+ fire((target) => target.impact({ style: IMPACT_STYLE[strength] }));
26
+ },
27
+ notify(kind) {
28
+ fire((target) => target.notification({ type: NOTIFICATION_TYPE[kind] }));
29
+ },
30
+ selection() {
31
+ fire((target) => target.selectionChanged());
32
+ },
33
+ };
34
+ }
@@ -0,0 +1,6 @@
1
+ export { createHaptics, type Haptics, type HapticsOptions, type HapticsPluginLike, type ImpactStrength, type NotificationKind, } from './haptics.js';
2
+ export { type AppLifecycle, type AppLifecycleOptions, type AppPluginLike, type BackHandler, createAppLifecycle, type LifecycleState, type PluginListenerHandleLike, } from './lifecycle.js';
3
+ export { decideOrientation, type OrientationDecision, type PreferredOrientation, } from './orientation.js';
4
+ export { classifyDevice, classifyFormFactor, classifyFrame, classifyOrientation, type DevicePlatform, type DeviceProfile, EXPANDED_MIN_SHORT_EDGE, type FormFactor, type FrameClass, isFoldableOpen, NEAR_SQUARE_MAX_ASPECT, readViewportFacts, TABLET_MIN_SHORT_EDGE, type ViewOrientation, type ViewportFacts, } from './profile.js';
5
+ export { applySafeAreaVariables, readSafeAreaInsets, type SafeAreaInsets, type SafeAreaWatchOptions, watchSafeArea, ZERO_INSETS, } from './safeArea.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,gBAAgB,GACtB,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,kBAAkB,EAClB,KAAK,cAAc,EACnB,KAAK,wBAAwB,GAC9B,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,iBAAiB,EACjB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,GAC1B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,uBAAuB,EACvB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,EACrB,KAAK,eAAe,EACpB,KAAK,aAAa,GACnB,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,aAAa,EACb,WAAW,GACZ,MAAM,eAAe,CAAA"}
@@ -0,0 +1,5 @@
1
+ export { createHaptics, } from './haptics.js';
2
+ export { createAppLifecycle, } from './lifecycle.js';
3
+ export { decideOrientation, } from './orientation.js';
4
+ export { classifyDevice, classifyFormFactor, classifyFrame, classifyOrientation, EXPANDED_MIN_SHORT_EDGE, isFoldableOpen, NEAR_SQUARE_MAX_ASPECT, readViewportFacts, TABLET_MIN_SHORT_EDGE, } from './profile.js';
5
+ export { applySafeAreaVariables, readSafeAreaInsets, watchSafeArea, ZERO_INSETS, } from './safeArea.js';
@@ -0,0 +1,48 @@
1
+ /**
2
+ * App lifecycle: pause/resume and the Android back button, on native shells and in the browser.
3
+ *
4
+ * The Capacitor `App` plugin is passed in rather than imported, so this package carries no runtime
5
+ * dependency on Capacitor and the logic unit-tests with a fake. On the web, pause/resume comes from
6
+ * `visibilitychange`, `pagehide` and `pageshow`.
7
+ *
8
+ * Back handling is a stack: the most recently pushed handler (an open modal, then the pause menu)
9
+ * runs first, and returning `true` consumes the press. An unconsumed press minimises the app instead
10
+ * of exiting it, so a stray back never discards unsaved progress.
11
+ */
12
+ export type LifecycleState = 'active' | 'background';
13
+ export interface PluginListenerHandleLike {
14
+ remove(): Promise<void>;
15
+ }
16
+ /** The subset of Capacitor's `App` plugin this module uses. */
17
+ export interface AppPluginLike {
18
+ addListener(event: 'appStateChange', listener: (state: {
19
+ isActive: boolean;
20
+ }) => void): Promise<PluginListenerHandleLike>;
21
+ addListener(event: 'backButton', listener: (event: {
22
+ canGoBack: boolean;
23
+ }) => void): Promise<PluginListenerHandleLike>;
24
+ minimizeApp(): Promise<void>;
25
+ }
26
+ /** Returns true when it handled the press. */
27
+ export type BackHandler = () => boolean;
28
+ export interface AppLifecycleOptions {
29
+ /** Capacitor's `App` plugin; required for native back-button and state events. */
30
+ app?: AppPluginLike;
31
+ /** True inside a native shell (`Capacitor.isNativePlatform()`). */
32
+ native: boolean;
33
+ onPause?: () => void;
34
+ onResume?: () => void;
35
+ /** Window and document for the web path; default to the globals. */
36
+ window?: Window;
37
+ document?: Document;
38
+ }
39
+ export interface AppLifecycle {
40
+ readonly state: LifecycleState;
41
+ /** Pushes a back handler; the returned function removes it. */
42
+ pushBackHandler(handler: BackHandler): () => void;
43
+ /** Runs the back stack as a hardware back press would. Returns true when a handler consumed it. */
44
+ handleBack(): boolean;
45
+ dispose(): Promise<void>;
46
+ }
47
+ export declare function createAppLifecycle(options: AppLifecycleOptions): AppLifecycle;
48
+ //# sourceMappingURL=lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../src/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,YAAY,CAAA;AAEpD,MAAM,WAAW,wBAAwB;IACvC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACxB;AAED,+DAA+D;AAC/D,MAAM,WAAW,aAAa;IAC5B,WAAW,CACT,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,GAC/C,OAAO,CAAC,wBAAwB,CAAC,CAAA;IACpC,WAAW,CACT,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,CAAC,KAAK,EAAE;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,GAChD,OAAO,CAAC,wBAAwB,CAAC,CAAA;IACpC,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAC7B;AAED,8CAA8C;AAC9C,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,CAAA;AAEvC,MAAM,WAAW,mBAAmB;IAClC,kFAAkF;IAClF,GAAG,CAAC,EAAE,aAAa,CAAA;IACnB,mEAAmE;IACnE,MAAM,EAAE,OAAO,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IACrB,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,QAAQ,CAAA;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAA;IAC9B,+DAA+D;IAC/D,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,IAAI,CAAA;IACjD,mGAAmG;IACnG,UAAU,IAAI,OAAO,CAAA;IACrB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACzB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CA0E7E"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * App lifecycle: pause/resume and the Android back button, on native shells and in the browser.
3
+ *
4
+ * The Capacitor `App` plugin is passed in rather than imported, so this package carries no runtime
5
+ * dependency on Capacitor and the logic unit-tests with a fake. On the web, pause/resume comes from
6
+ * `visibilitychange`, `pagehide` and `pageshow`.
7
+ *
8
+ * Back handling is a stack: the most recently pushed handler (an open modal, then the pause menu)
9
+ * runs first, and returning `true` consumes the press. An unconsumed press minimises the app instead
10
+ * of exiting it, so a stray back never discards unsaved progress.
11
+ */
12
+ export function createAppLifecycle(options) {
13
+ const handlers = [];
14
+ const handles = [];
15
+ const removers = [];
16
+ let state = 'active';
17
+ let disposed = false;
18
+ const transition = (next) => {
19
+ if (disposed || next === state)
20
+ return;
21
+ state = next;
22
+ if (next === 'active')
23
+ options.onResume?.();
24
+ else
25
+ options.onPause?.();
26
+ };
27
+ const handleBack = () => {
28
+ for (let index = handlers.length - 1; index >= 0; index -= 1) {
29
+ const handler = handlers[index];
30
+ if (handler?.())
31
+ return true;
32
+ }
33
+ return false;
34
+ };
35
+ if (options.native && options.app) {
36
+ const app = options.app;
37
+ handles.push(app.addListener('appStateChange', ({ isActive }) => transition(isActive ? 'active' : 'background')));
38
+ handles.push(app.addListener('backButton', () => {
39
+ if (!handleBack())
40
+ void app.minimizeApp().catch(() => undefined);
41
+ }));
42
+ }
43
+ else {
44
+ const win = options.window ?? (typeof window === 'undefined' ? undefined : window);
45
+ const doc = options.document ?? (typeof document === 'undefined' ? undefined : document);
46
+ if (win && doc) {
47
+ const onVisibility = () => transition(doc.hidden ? 'background' : 'active');
48
+ const onHide = () => transition('background');
49
+ const onShow = () => transition('active');
50
+ doc.addEventListener('visibilitychange', onVisibility);
51
+ win.addEventListener('pagehide', onHide);
52
+ win.addEventListener('pageshow', onShow);
53
+ removers.push(() => {
54
+ doc.removeEventListener('visibilitychange', onVisibility);
55
+ win.removeEventListener('pagehide', onHide);
56
+ win.removeEventListener('pageshow', onShow);
57
+ });
58
+ }
59
+ }
60
+ return {
61
+ get state() {
62
+ return state;
63
+ },
64
+ pushBackHandler(handler) {
65
+ handlers.push(handler);
66
+ return () => {
67
+ const index = handlers.lastIndexOf(handler);
68
+ if (index >= 0)
69
+ handlers.splice(index, 1);
70
+ };
71
+ },
72
+ handleBack,
73
+ async dispose() {
74
+ disposed = true;
75
+ handlers.length = 0;
76
+ for (const remove of removers.splice(0))
77
+ remove();
78
+ const settled = await Promise.allSettled(handles.splice(0));
79
+ await Promise.allSettled(settled.flatMap((result) => (result.status === 'fulfilled' ? [result.value.remove()] : [])));
80
+ },
81
+ };
82
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Orientation policy. A game declares the orientation it is designed around; the policy decides, per
3
+ * device, which orientations are acceptable and whether to ask a phone player to rotate. Tablets and
4
+ * unfolded foldables are usable either way, so they are never nagged.
5
+ *
6
+ * Never force-rotate. The decision drives a per-screen "turn the device" hint only; the
7
+ * native shell leaves the screen orientation unlocked.
8
+ */
9
+ import type { DeviceProfile, ViewOrientation } from './profile.js';
10
+ /** `any` means the game lays out in both orientations on every device. */
11
+ export type PreferredOrientation = ViewOrientation | 'any';
12
+ export interface OrientationDecision {
13
+ /** Orientations the game should accept on this device. */
14
+ allowed: readonly ViewOrientation[];
15
+ /** True when the player should be asked to rotate the device. */
16
+ promptRotate: boolean;
17
+ /** The orientation to ask for when `promptRotate` is true. */
18
+ target: ViewOrientation | null;
19
+ }
20
+ export declare function decideOrientation(profile: Pick<DeviceProfile, 'formFactor' | 'orientation' | 'touch'>, preferred: PreferredOrientation): OrientationDecision;
21
+ //# sourceMappingURL=orientation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orientation.d.ts","sourceRoot":"","sources":["../../src/orientation.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAElE,0EAA0E;AAC1E,MAAM,MAAM,oBAAoB,GAAG,eAAe,GAAG,KAAK,CAAA;AAE1D,MAAM,WAAW,mBAAmB;IAClC,0DAA0D;IAC1D,OAAO,EAAE,SAAS,eAAe,EAAE,CAAA;IACnC,iEAAiE;IACjE,YAAY,EAAE,OAAO,CAAA;IACrB,8DAA8D;IAC9D,MAAM,EAAE,eAAe,GAAG,IAAI,CAAA;CAC/B;AAID,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,YAAY,GAAG,aAAa,GAAG,OAAO,CAAC,EACpE,SAAS,EAAE,oBAAoB,GAC9B,mBAAmB,CAWrB"}
@@ -0,0 +1,13 @@
1
+ const BOTH = ['portrait', 'landscape'];
2
+ export function decideOrientation(profile, preferred) {
3
+ const flexible = preferred === 'any' ||
4
+ !profile.touch ||
5
+ profile.formFactor === 'desktop' ||
6
+ profile.formFactor === 'tablet' ||
7
+ profile.formFactor === 'foldable-open';
8
+ if (flexible)
9
+ return { allowed: BOTH, promptRotate: false, target: null };
10
+ const allowed = [preferred];
11
+ const promptRotate = profile.orientation !== preferred;
12
+ return { allowed, promptRotate, target: promptRotate ? preferred : null };
13
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Device profile: a pure classification of the current viewport into the categories a game's layout
3
+ * actually branches on. Every input is injectable so the classification unit-tests without a browser
4
+ * and so a native shell can feed it platform facts (Capacitor `Device.getInfo()`).
5
+ */
6
+ /** `compact` lays a HUD out for a phone; `expanded` has room for side panels. */
7
+ export type FrameClass = 'compact' | 'expanded';
8
+ export type ViewOrientation = 'portrait' | 'landscape';
9
+ /**
10
+ * The form factor a layout targets. `foldable-open` is an unfolded book-style foldable (OnePlus Open,
11
+ * Galaxy Z Fold, Pixel Fold): touch-primary, tablet-sized and near-square, so it plays in either
12
+ * orientation and needs a layout of its own rather than a stretched phone or a squashed tablet one.
13
+ */
14
+ export type FormFactor = 'phone' | 'foldable-open' | 'tablet' | 'desktop';
15
+ /** Platform names as Capacitor's `Device.getInfo().platform` reports them. */
16
+ export type DevicePlatform = 'web' | 'android' | 'ios' | 'electron';
17
+ export interface ViewportFacts {
18
+ /** CSS pixels (`window.innerWidth`). */
19
+ width: number;
20
+ /** CSS pixels (`window.innerHeight`). */
21
+ height: number;
22
+ devicePixelRatio: number;
23
+ /** True when the primary input is touch (`maxTouchPoints > 0`). */
24
+ touch: boolean;
25
+ platform: DevicePlatform;
26
+ /** Native model string; used only to recognise iPads, which report a phone-like platform. */
27
+ model: string;
28
+ }
29
+ export type DeviceProfile = Readonly<{
30
+ frame: FrameClass;
31
+ formFactor: FormFactor;
32
+ orientation: ViewOrientation;
33
+ platform: DevicePlatform;
34
+ native: boolean;
35
+ touch: boolean;
36
+ shortEdge: number;
37
+ longEdge: number;
38
+ /** Long edge divided by short edge; 1 is square. */
39
+ aspect: number;
40
+ devicePixelRatio: number;
41
+ }>;
42
+ /** Short edge (CSS px) at which a frame counts as expanded. Phones stay below ~480. */
43
+ export declare const EXPANDED_MIN_SHORT_EDGE = 700;
44
+ /** Short edge (CSS px) from which a touch screen is tablet-sized rather than a phone. */
45
+ export declare const TABLET_MIN_SHORT_EDGE = 600;
46
+ /**
47
+ * Long/short aspect at or below which a screen is near-square. A phone in portrait is ~2.1, a 4:3
48
+ * tablet 1.33, an unfolded OnePlus Open ~1.08.
49
+ */
50
+ export declare const NEAR_SQUARE_MAX_ASPECT = 1.3;
51
+ export declare function classifyOrientation(width: number, height: number): ViewOrientation;
52
+ /** True for an unfolded book-style foldable: near-square and tablet-sized, on a touch screen. */
53
+ export declare function isFoldableOpen(facts: Pick<ViewportFacts, 'width' | 'height' | 'touch'>): boolean;
54
+ export declare function classifyFormFactor(facts: ViewportFacts): FormFactor;
55
+ export declare function classifyFrame(facts: ViewportFacts): FrameClass;
56
+ export declare function classifyDevice(facts: ViewportFacts): DeviceProfile;
57
+ interface BrowserLike {
58
+ innerWidth: number;
59
+ innerHeight: number;
60
+ devicePixelRatio?: number;
61
+ navigator?: {
62
+ maxTouchPoints?: number;
63
+ };
64
+ }
65
+ /**
66
+ * Reads viewport facts from a window (`null` outside a browser gives a 1280x720 desktop default).
67
+ * Platform facts default to `web` until a native shell says otherwise.
68
+ */
69
+ export declare function readViewportFacts(win?: BrowserLike | null, platform?: Pick<ViewportFacts, 'platform' | 'model'>): ViewportFacts;
70
+ export {};
71
+ //# sourceMappingURL=profile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/profile.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,iFAAiF;AACjF,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,UAAU,CAAA;AAC/C,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,WAAW,CAAA;AACtD;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,eAAe,GAAG,QAAQ,GAAG,SAAS,CAAA;AACzE,8EAA8E;AAC9E,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,UAAU,CAAA;AAEnE,MAAM,WAAW,aAAa;IAC5B,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAA;IACb,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAA;IACd,gBAAgB,EAAE,MAAM,CAAA;IACxB,mEAAmE;IACnE,KAAK,EAAE,OAAO,CAAA;IACd,QAAQ,EAAE,cAAc,CAAA;IACxB,6FAA6F;IAC7F,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IACnC,KAAK,EAAE,UAAU,CAAA;IACjB,UAAU,EAAE,UAAU,CAAA;IACtB,WAAW,EAAE,eAAe,CAAA;IAC5B,QAAQ,EAAE,cAAc,CAAA;IACxB,MAAM,EAAE,OAAO,CAAA;IACf,KAAK,EAAE,OAAO,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAA;IACd,gBAAgB,EAAE,MAAM,CAAA;CACzB,CAAC,CAAA;AAEF,uFAAuF;AACvF,eAAO,MAAM,uBAAuB,MAAM,CAAA;AAC1C,yFAAyF;AACzF,eAAO,MAAM,qBAAqB,MAAM,CAAA;AACxC;;;GAGG;AACH,eAAO,MAAM,sBAAsB,MAAM,CAAA;AAEzC,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,eAAe,CAElF;AAED,iGAAiG;AACjG,wBAAgB,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC,GAAG,OAAO,CAMhG;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,aAAa,GAAG,UAAU,CAOnE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,UAAU,CAG9D;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CAgBlE;AAED,UAAU,WAAW;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,SAAS,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CACxC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,GAAE,WAAW,GAAG,IAAoD,EACvE,QAAQ,GAAE,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,OAAO,CAAkC,GACnF,aAAa,CAWf"}