@ait-co/polyfill 0.1.1

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 ADDED
@@ -0,0 +1,83 @@
1
+ # @ait-co/polyfill
2
+
3
+ > ๐Ÿšง **Pre-release (0.1.x)** โ€” implemented, pending `sdk-example` integration verification.
4
+ > Part of the unofficial `apps-in-toss-community` project. Not affiliated with Toss.
5
+ > ๋น„๊ณต์‹ ์ปค๋ฎค๋‹ˆํ‹ฐ ํ”„๋กœ์ ํŠธ์ž…๋‹ˆ๋‹ค. ํ† ์Šค์™€ ์ œํœดํ•˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.
6
+
7
+ Web standard API polyfill for Apps in Toss mini-apps. Write your mini-app with **standard Web APIs** (`navigator.clipboard`, `navigator.geolocation`, โ€ฆ) and have it transparently work inside Apps in Toss.
8
+
9
+ ์•ฑ์ธํ† ์Šค ๋ฏธ๋‹ˆ์•ฑ์—์„œ **์›น ํ‘œ์ค€ API๋ฅผ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉ**ํ•ด์„œ ๊ฐœ๋ฐœํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์ฃผ๋Š” polyfill. ๋Ÿฐํƒ€์ž„์— ์•ฑ์ธํ† ์Šค ํ™˜๊ฒฝ์„ ๊ฐ์ง€ํ•ด ๋‚ด๋ถ€์ ์œผ๋กœ `@apps-in-toss/web-framework` ํ˜ธ์ถœ๋กœ ๋ผ์šฐํŒ…ํ•˜๊ณ , ๊ทธ ์™ธ ํ™˜๊ฒฝ(์ผ๋ฐ˜ ๋ธŒ๋ผ์šฐ์ €, ๋กœ์ปฌ ๊ฐœ๋ฐœ, ํ…Œ์ŠคํŠธ)์—์„œ๋Š” ๋ธŒ๋ผ์šฐ์ €์˜ ์›๋ณธ ๊ตฌํ˜„์„ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค โ€” no-op shim์ด ์•„๋‹™๋‹ˆ๋‹ค.
10
+
11
+ ## Install
12
+
13
+ ```sh
14
+ pnpm add @ait-co/polyfill
15
+ ```
16
+
17
+ `@apps-in-toss/web-framework` is an **optional peer dependency**. Apps that only target a pure-web context don't need to install it โ€” the shim falls through to the native browser path.
18
+
19
+ ```sh
20
+ pnpm add @apps-in-toss/web-framework # only if you also ship a Toss build
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ### Install every shim (recommended)
26
+
27
+ Call `install()` once at app entry:
28
+
29
+ ```ts
30
+ import { install } from '@ait-co/polyfill';
31
+
32
+ install();
33
+
34
+ await navigator.clipboard.writeText('hello');
35
+ ```
36
+
37
+ `install()` is idempotent โ€” calling it again is a no-op. It returns an uninstall function; a top-level `uninstall()` is also exported for convenience.
38
+
39
+ ```ts
40
+ import { install, uninstall } from '@ait-co/polyfill';
41
+
42
+ const restore = install();
43
+ // ...
44
+ restore(); // or uninstall()
45
+ ```
46
+
47
+ Each shim stashes the original `navigator`/`window` value so `uninstall()` restores it cleanly โ€” useful in tests.
48
+
49
+ ### Subpath imports (bundle-size sensitive)
50
+
51
+ Pick just the shims you need and install them explicitly:
52
+
53
+ ```ts
54
+ import { installClipboardShim } from '@ait-co/polyfill/clipboard';
55
+ import { isTossEnvironment } from '@ait-co/polyfill/detect';
56
+
57
+ installClipboardShim();
58
+ ```
59
+
60
+ The package is marked `"sideEffects": false`, so unused shims are dropped by any modern bundler when you use subpath imports.
61
+
62
+ ## Supported APIs
63
+
64
+ ๋ชจ๋“  Tier 1 shim์ด ๋‹จ์œ„ ํ…Œ์ŠคํŠธ๊นŒ์ง€ ํ†ต๊ณผํ•œ ์ƒํƒœ์ด๊ณ , ์‹คํ™˜๊ฒฝ ๊ฒ€์ฆ(`sdk-example` ํ†ตํ•ฉ)์ด ๋‚จ์•„์žˆ์Šต๋‹ˆ๋‹ค. ์‹คํ™˜๊ฒฝ ๊ฒ€์ฆ ์ดํ›„ ์ผ๋ถ€ API ๋งคํ•‘์ด ์กฐ์ •๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
65
+
66
+ | Web standard | SDK counterpart | Landed in |
67
+ |---|---|---|
68
+ | `navigator.clipboard.readText()` / `writeText(text)` | `getClipboardText()` / `setClipboardText(text)` | 0.1.0 |
69
+ | `navigator.geolocation.getCurrentPosition()` | `getCurrentLocation({ accuracy })` | 0.1.1 (pending) |
70
+ | `navigator.geolocation.watchPosition()` / `clearWatch()` | `startUpdateLocation(...)` | 0.1.1 (pending) |
71
+ | `navigator.share({ title, text, url })` | `share({ message })` (concatenates into `message`) | 0.1.1 (pending) |
72
+ | `navigator.vibrate(pattern)` | `generateHapticFeedback(...)` (best-effort, lossy) | 0.1.1 (pending) |
73
+ | `navigator.onLine` / `navigator.connection.effectiveType` | `getNetworkStatus()` (poll on read; no `change` for seed) | 0.1.1 (pending) |
74
+
75
+ `(pending)` ํ‘œ์‹œ๋Š” ํ•ด๋‹น ํ–‰์ด ์•„์ง npm์œผ๋กœ ๊ณต๊ฐœ๋˜์ง€ ์•Š์•˜๋‹ค๋Š” ๋œป์ž…๋‹ˆ๋‹ค. ๋‹ค์Œ Version Packages PR์ด merge๋˜์–ด `0.1.1`์ด publish๋˜๋ฉด ์ด ํ‘œ์‹œ๋Š” ์ œ๊ฑฐ๋ฉ๋‹ˆ๋‹ค.
76
+
77
+ See [`TODO.md`](./TODO.md) for the full backlog and tiering.
78
+
79
+ APIs without a reasonable Web standard counterpart (auth, IAP, ads, analytics, Toss-specific environment info) stay in the `@apps-in-toss/web-framework` namespace โ€” polyfill is not the home for "everything the SDK does." Rationale in [`CLAUDE.md`](./CLAUDE.md).
80
+
81
+ ## License
82
+
83
+ BSD-3-Clause
@@ -0,0 +1,45 @@
1
+ import * as _$_apps_in_toss_web_framework0 from "@apps-in-toss/web-framework";
2
+
3
+ //#region src/detect.d.ts
4
+ /**
5
+ * Environment detection: are we running inside Apps in Toss, or a plain browser?
6
+ *
7
+ * Strategy: feature-sniff `@apps-in-toss/web-framework`. The SDK is declared as
8
+ * an **optional** peer dependency. If it resolves and exposes a known export,
9
+ * we assume we can route calls through it; otherwise we fall back to the
10
+ * browser's native implementation in each shim.
11
+ *
12
+ * We deliberately avoid UA sniffing (spoofable) and avoid calling any SDK
13
+ * function during detection (could prompt permission dialogs, fire analytics,
14
+ * etc.).
15
+ */
16
+ /**
17
+ * Reset the cached detection result. Primarily for tests.
18
+ */
19
+ declare function resetDetection(): void;
20
+ /**
21
+ * Synchronous read of the cached detection result. Returns:
22
+ * - `true` / `false` if an override is active or the async detection has
23
+ * already resolved
24
+ * - `undefined` if detection hasn't run yet
25
+ *
26
+ * Used by spec-sync APIs (e.g. `navigator.canShare`) that can't `await`
27
+ * detection.
28
+ */
29
+ declare function isTossEnvironmentCached(): boolean | undefined;
30
+ /**
31
+ * Returns `true` iff we detect we are running in an environment where the
32
+ * Apps in Toss SDK (`@apps-in-toss/web-framework`) is present and usable.
33
+ *
34
+ * Async because we use dynamic `import()` to probe the optional peer dep
35
+ * without forcing it into the consumer's bundle.
36
+ */
37
+ declare function isTossEnvironment(): Promise<boolean>;
38
+ /**
39
+ * Lazy SDK accessor โ€” returns the module if available, else `null`. Callers
40
+ * are expected to `await` and null-check. Never throws.
41
+ */
42
+ declare function loadTossSdk(): Promise<typeof _$_apps_in_toss_web_framework0 | null>;
43
+ //#endregion
44
+ export { isTossEnvironment, isTossEnvironmentCached, loadTossSdk, resetDetection };
45
+ //# sourceMappingURL=detect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect.d.ts","names":[],"sources":["../src/detect.ts"],"mappings":";;;;;;AAkBA;;;;;AAaA;;;;;AAcA;;iBA3BgB,cAAA,CAAA;;;AA8ChB;;;;;;;iBAjCgB,uBAAA,CAAA;;;;;;;;iBAcM,iBAAA,CAAA,GAAqB,OAAA;;;;;iBAmBrB,WAAA,CAAA,GAAe,OAAA,QAAJ,8BAAA"}
package/dist/detect.js ADDED
@@ -0,0 +1,65 @@
1
+ //#region src/detect.ts
2
+ /**
3
+ * Environment detection: are we running inside Apps in Toss, or a plain browser?
4
+ *
5
+ * Strategy: feature-sniff `@apps-in-toss/web-framework`. The SDK is declared as
6
+ * an **optional** peer dependency. If it resolves and exposes a known export,
7
+ * we assume we can route calls through it; otherwise we fall back to the
8
+ * browser's native implementation in each shim.
9
+ *
10
+ * We deliberately avoid UA sniffing (spoofable) and avoid calling any SDK
11
+ * function during detection (could prompt permission dialogs, fire analytics,
12
+ * etc.).
13
+ */
14
+ let cached;
15
+ /**
16
+ * Reset the cached detection result. Primarily for tests.
17
+ */
18
+ function resetDetection() {
19
+ cached = void 0;
20
+ }
21
+ /**
22
+ * Synchronous read of the cached detection result. Returns:
23
+ * - `true` / `false` if an override is active or the async detection has
24
+ * already resolved
25
+ * - `undefined` if detection hasn't run yet
26
+ *
27
+ * Used by spec-sync APIs (e.g. `navigator.canShare`) that can't `await`
28
+ * detection.
29
+ */
30
+ function isTossEnvironmentCached() {
31
+ const force = globalThis.__AIT_POLYFILL_FORCE__;
32
+ if (force === "toss") return true;
33
+ if (force === "browser") return false;
34
+ return cached;
35
+ }
36
+ /**
37
+ * Returns `true` iff we detect we are running in an environment where the
38
+ * Apps in Toss SDK (`@apps-in-toss/web-framework`) is present and usable.
39
+ *
40
+ * Async because we use dynamic `import()` to probe the optional peer dep
41
+ * without forcing it into the consumer's bundle.
42
+ */
43
+ async function isTossEnvironment() {
44
+ const force = globalThis.__AIT_POLYFILL_FORCE__;
45
+ if (force === "toss") return true;
46
+ if (force === "browser") return false;
47
+ if (cached !== void 0) return cached;
48
+ cached = typeof (await loadTossSdk())?.getClipboardText === "function";
49
+ return cached;
50
+ }
51
+ /**
52
+ * Lazy SDK accessor โ€” returns the module if available, else `null`. Callers
53
+ * are expected to `await` and null-check. Never throws.
54
+ */
55
+ async function loadTossSdk() {
56
+ try {
57
+ return await import("@apps-in-toss/web-framework");
58
+ } catch {
59
+ return null;
60
+ }
61
+ }
62
+ //#endregion
63
+ export { isTossEnvironment, isTossEnvironmentCached, loadTossSdk, resetDetection };
64
+
65
+ //# sourceMappingURL=detect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect.js","names":[],"sources":["../src/detect.ts"],"sourcesContent":["/**\n * Environment detection: are we running inside Apps in Toss, or a plain browser?\n *\n * Strategy: feature-sniff `@apps-in-toss/web-framework`. The SDK is declared as\n * an **optional** peer dependency. If it resolves and exposes a known export,\n * we assume we can route calls through it; otherwise we fall back to the\n * browser's native implementation in each shim.\n *\n * We deliberately avoid UA sniffing (spoofable) and avoid calling any SDK\n * function during detection (could prompt permission dialogs, fire analytics,\n * etc.).\n */\n\nlet cached: boolean | undefined;\n\n/**\n * Reset the cached detection result. Primarily for tests.\n */\nexport function resetDetection(): void {\n cached = undefined;\n}\n\n/**\n * Synchronous read of the cached detection result. Returns:\n * - `true` / `false` if an override is active or the async detection has\n * already resolved\n * - `undefined` if detection hasn't run yet\n *\n * Used by spec-sync APIs (e.g. `navigator.canShare`) that can't `await`\n * detection.\n */\nexport function isTossEnvironmentCached(): boolean | undefined {\n const force = globalThis.__AIT_POLYFILL_FORCE__;\n if (force === 'toss') return true;\n if (force === 'browser') return false;\n return cached;\n}\n\n/**\n * Returns `true` iff we detect we are running in an environment where the\n * Apps in Toss SDK (`@apps-in-toss/web-framework`) is present and usable.\n *\n * Async because we use dynamic `import()` to probe the optional peer dep\n * without forcing it into the consumer's bundle.\n */\nexport async function isTossEnvironment(): Promise<boolean> {\n // Override check precedes cache so `devtools` / tests can flip the result\n // mid-session without a `resetDetection()` call.\n const force = globalThis.__AIT_POLYFILL_FORCE__;\n if (force === 'toss') return true;\n if (force === 'browser') return false;\n\n if (cached !== undefined) return cached;\n\n const mod = await loadTossSdk();\n // Presence of a well-known export is our smoke test.\n cached = typeof mod?.getClipboardText === 'function';\n return cached;\n}\n\n/**\n * Lazy SDK accessor โ€” returns the module if available, else `null`. Callers\n * are expected to `await` and null-check. Never throws.\n */\nexport async function loadTossSdk(): Promise<typeof import('@apps-in-toss/web-framework') | null> {\n try {\n return await import('@apps-in-toss/web-framework');\n } catch {\n return null;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,IAAI;;;;AAKJ,SAAgB,iBAAuB;AACrC,UAAS,KAAA;;;;;;;;;;;AAYX,SAAgB,0BAA+C;CAC7D,MAAM,QAAQ,WAAW;AACzB,KAAI,UAAU,OAAQ,QAAO;AAC7B,KAAI,UAAU,UAAW,QAAO;AAChC,QAAO;;;;;;;;;AAUT,eAAsB,oBAAsC;CAG1D,MAAM,QAAQ,WAAW;AACzB,KAAI,UAAU,OAAQ,QAAO;AAC7B,KAAI,UAAU,UAAW,QAAO;AAEhC,KAAI,WAAW,KAAA,EAAW,QAAO;AAIjC,UAAS,QAFG,MAAM,aAAa,GAEV,qBAAqB;AAC1C,QAAO;;;;;;AAOT,eAAsB,cAA4E;AAChG,KAAI;AACF,SAAO,MAAM,OAAO;SACd;AACN,SAAO"}
@@ -0,0 +1,197 @@
1
+ import * as _$_apps_in_toss_web_framework0 from "@apps-in-toss/web-framework";
2
+
3
+ //#region src/detect.d.ts
4
+ /**
5
+ * Synchronous read of the cached detection result. Returns:
6
+ * - `true` / `false` if an override is active or the async detection has
7
+ * already resolved
8
+ * - `undefined` if detection hasn't run yet
9
+ *
10
+ * Used by spec-sync APIs (e.g. `navigator.canShare`) that can't `await`
11
+ * detection.
12
+ */
13
+ declare function isTossEnvironmentCached(): boolean | undefined;
14
+ /**
15
+ * Returns `true` iff we detect we are running in an environment where the
16
+ * Apps in Toss SDK (`@apps-in-toss/web-framework`) is present and usable.
17
+ *
18
+ * Async because we use dynamic `import()` to probe the optional peer dep
19
+ * without forcing it into the consumer's bundle.
20
+ */
21
+ declare function isTossEnvironment(): Promise<boolean>;
22
+ /**
23
+ * Lazy SDK accessor โ€” returns the module if available, else `null`. Callers
24
+ * are expected to `await` and null-check. Never throws.
25
+ */
26
+ declare function loadTossSdk(): Promise<typeof _$_apps_in_toss_web_framework0 | null>;
27
+ //#endregion
28
+ //#region src/shims/clipboard.d.ts
29
+ /**
30
+ * `navigator.clipboard` shim.
31
+ *
32
+ * Inside Apps in Toss โ†’ routes `readText` / `writeText` through the SDK
33
+ * (`getClipboardText` / `setClipboardText`).
34
+ *
35
+ * Outside Apps in Toss โ†’ defers to the browser's native `navigator.clipboard`.
36
+ * If the browser doesn't implement it, the standard `TypeError` / `DOMException`
37
+ * surfaces unchanged โ€” we don't paper over missing support.
38
+ */
39
+ /**
40
+ * Install the `navigator.clipboard` shim.
41
+ *
42
+ * @returns an uninstall function that restores the original `navigator.clipboard`.
43
+ * Calling install twice without uninstalling is a no-op on the second call
44
+ * and returns the same uninstall function.
45
+ */
46
+ declare function installClipboardShim(): () => void;
47
+ /**
48
+ * Remove the shim and restore the pre-install shape. Uses delete + conditional
49
+ * redefine so a prototype-level `navigator.clipboard` (non-configurable in real
50
+ * browsers) becomes visible again instead of being permanently shadowed.
51
+ */
52
+ declare function uninstallClipboardShim(): void;
53
+ //#endregion
54
+ //#region src/shims/geolocation.d.ts
55
+ /**
56
+ * `navigator.geolocation` shim.
57
+ *
58
+ * Inside Apps in Toss โ†’ routes through the SDK:
59
+ * - `getCurrentPosition` โ†’ `getCurrentLocation({ accuracy })`
60
+ * - `watchPosition` / `clearWatch` โ†’ `startUpdateLocation({ onEvent, onError, options })`
61
+ *
62
+ * Outside Apps in Toss โ†’ defers to the browser's native `navigator.geolocation`.
63
+ * If neither is available, the error callback receives a `GeolocationPositionError`.
64
+ *
65
+ * SDK/Web shape mismatch handled here:
66
+ * - SDK `Accuracy` is a numeric enum (1 = Lowest โ€ฆ 6 = BestForNavigation); the
67
+ * standard `PositionOptions.enableHighAccuracy` is a boolean. We map
68
+ * `true โ†’ Accuracy.High (4, "~10m")` and `false โ†’ Accuracy.Balanced (3)`.
69
+ * `Highest (5)` / `BestForNavigation (6)` are available but carry a battery
70
+ * cost that's rarely what mini-apps want; consumers who need them should
71
+ * call the SDK directly.
72
+ * - SDK coords lack `speed`; we surface `null` (per the W3C spec when unknown).
73
+ * - SDK `startUpdateLocation` returns an `unsubscribe` fn; we wrap it behind
74
+ * a numeric watch id so `clearWatch(id)` behaves like the standard.
75
+ *
76
+ * Caveat: watch ids reset whenever the shim is uninstalled and reinstalled;
77
+ * they are not stable across such cycles. Ids obtained before uninstall
78
+ * cannot be cleared after uninstall โ€” `clearWatch(id)` on the restored native
79
+ * `navigator.geolocation` uses a different id space, so the SDK subscription
80
+ * leaks. Consumers should `clearWatch` all outstanding ids before calling
81
+ * `uninstall()`.
82
+ */
83
+ declare function installGeolocationShim(): () => void;
84
+ declare function uninstallGeolocationShim(): void;
85
+ //#endregion
86
+ //#region src/shims/network.d.ts
87
+ /**
88
+ * `navigator.onLine` + `navigator.connection` shim.
89
+ *
90
+ * Inside Apps in Toss โ†’ seeded from SDK `getNetworkStatus()` on install and
91
+ * refreshed on read (throttled):
92
+ * - `'OFFLINE'` โ†’ `onLine = false`
93
+ * - `'WIFI'` โ†’ `onLine = true`, `effectiveType = '4g'` (no web wifi value)
94
+ * - `'2G'/'3G'/'4G'/'5G'` โ†’ `onLine = true`, `effectiveType = <lowercased>`
95
+ * - `'WWAN'/'UNKNOWN'` โ†’ `onLine = true`, `effectiveType = '4g'` (best guess)
96
+ *
97
+ * Outside Apps in Toss โ†’ both `navigator.onLine` and `navigator.connection`
98
+ * read through to the native value. Install installs own-instance getters
99
+ * that consult the Toss-seeded cache first; when the cache is empty (which
100
+ * it always is in browser mode), the getter temporarily removes its own
101
+ * shadow, reads the prototype value, and reinstates the shadow.
102
+ *
103
+ * Uninstall `delete`s the instance-level override so the prototype descriptor
104
+ * (where `onLine` and `connection` actually live in real browsers) becomes
105
+ * visible again. We never mutate the prototype โ€” doing so would throw in
106
+ * browsers where the descriptor is non-configurable.
107
+ *
108
+ * Caveat: the Web NetworkInformation API is evented (`change` fires on
109
+ * transitions). The SDK exposes only a one-shot query, so listeners attached
110
+ * to `navigator.connection` are accepted but never fire from a `change` event
111
+ * unless the shim observes a real status transition. Synthesising richer
112
+ * events via polling is tracked in TODO.md.
113
+ *
114
+ * Lifecycle: `navigator.connection` is a ShimConnection instance that lives in
115
+ * the install closure. On uninstall the instance-level override is removed,
116
+ * but listeners the consumer attached to the old instance stay bound to that
117
+ * (now-orphan) object and will not see events from a subsequent install.
118
+ * Consumers should re-attach listeners after each install.
119
+ *
120
+ * Seed-boundary race: in Toss mode, reads before the install-time SDK seed
121
+ * completes fall through to the native `navigator.connection`. After the seed
122
+ * lands, subsequent reads return the shim's ShimConnection. Consumers that
123
+ * specifically need the ShimConnection instance (e.g., to attach `change`
124
+ * listeners that fire on Toss network transitions) should wait a microtask
125
+ * after `install()` before attaching listeners, or accept that pre-seed
126
+ * reads may return the native object.
127
+ */
128
+ declare function installNetworkShim(): () => void;
129
+ declare function uninstallNetworkShim(): void;
130
+ //#endregion
131
+ //#region src/shims/share.d.ts
132
+ /**
133
+ * `navigator.share` shim.
134
+ *
135
+ * Inside Apps in Toss โ†’ routes through SDK `share({ message })`. The SDK only
136
+ * accepts a single `message` string, so we concatenate `title`, `text`, and
137
+ * `url` with newline separators (skipping missing/empty values).
138
+ *
139
+ * Outside Apps in Toss โ†’ defers to the browser's native `navigator.share`, or
140
+ * throws `NotSupportedError` if unavailable.
141
+ *
142
+ * Caveat: the SDK's share has no counterpart for `files` (Web Share Level 2).
143
+ * `canShare({ files })` returns `false` whenever the sync-accessible detection
144
+ * says Toss is active (or is being forced via the test override).
145
+ */
146
+ declare function installShareShim(): () => void;
147
+ declare function uninstallShareShim(): void;
148
+ //#endregion
149
+ //#region src/shims/vibrate.d.ts
150
+ /**
151
+ * `navigator.vibrate` shim.
152
+ *
153
+ * Inside Apps in Toss โ†’ best-effort mapping to SDK `generateHapticFeedback`:
154
+ * - `vibrate(0)` โ†’ no-op (web standard: cancels pending vibration)
155
+ * - `vibrate(number)`: short (< 40ms) โ†’ `tickWeak`, long (โ‰ฅ 40ms) โ†’ `basicMedium`
156
+ * - `vibrate(number[])`: iterate "on" segments (even indices) as `tap` pulses
157
+ *
158
+ * Outside Apps in Toss โ†’ defers to the browser's native `navigator.vibrate`,
159
+ * or returns `false` when unavailable (matches the spec โ€” browsers that don't
160
+ * support vibration simply return `false`).
161
+ *
162
+ * Caveats (documented in CLAUDE.md as the known lossy trade-off):
163
+ * - SDK haptics are qualitative ("tickWeak", "basicMedium"), not millisecond
164
+ * durations. The shim approximates intensity from duration but cannot
165
+ * reproduce exact patterns.
166
+ * - Arrays are fired sequentially via `setTimeout`; gaps between pulses are
167
+ * honoured only as "time until the next tap", not as silent-vs-vibrating.
168
+ * - `vibrate` is spec'd as **synchronous**; the SDK call is async. We return
169
+ * `true` immediately (fire-and-forget). Errors from the SDK are swallowed.
170
+ */
171
+ declare function installVibrateShim(): () => void;
172
+ declare function uninstallVibrateShim(): void;
173
+ //#endregion
174
+ //#region src/index.d.ts
175
+ declare const VERSION: string;
176
+ /**
177
+ * Install every shim this library ships. Idempotent โ€” safe to call more than
178
+ * once. Returns an uninstall function that restores every original API.
179
+ *
180
+ * Install order: clipboard โ†’ geolocation โ†’ share โ†’ vibrate โ†’ network.
181
+ * `uninstall()` tears them down in the same order (each per-shim uninstall is
182
+ * independent, so order doesn't affect correctness; documented for clarity).
183
+ *
184
+ * Not atomic on failure: if a later per-shim install throws (e.g., a consumer
185
+ * has pinned one of the target navigator properties as non-configurable),
186
+ * earlier shims are already installed. Callers should catch and invoke
187
+ * `uninstall()` to roll back.
188
+ */
189
+ declare function install(): () => void;
190
+ /**
191
+ * Uninstall every shim installed by `install()`. Safe to call when no shim is
192
+ * installed โ€” each installer's uninstall is a no-op in that case.
193
+ */
194
+ declare function uninstall(): void;
195
+ //#endregion
196
+ export { VERSION, install, installClipboardShim, installGeolocationShim, installNetworkShim, installShareShim, installVibrateShim, isTossEnvironment, isTossEnvironmentCached, loadTossSdk, uninstall, uninstallClipboardShim, uninstallGeolocationShim, uninstallNetworkShim, uninstallShareShim, uninstallVibrateShim };
197
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/detect.ts","../src/shims/clipboard.ts","../src/shims/geolocation.ts","../src/shims/network.ts","../src/shims/share.ts","../src/shims/vibrate.ts","../src/index.ts"],"mappings":";;;;;;;;ACyHA;;;;iBD1FgB,uBAAA,CAAA;AC6HhB;;;;;;;AAAA,iBD/GsB,iBAAA,CAAA,GAAqB,OAAA;AEyN3C;;;;AAAA,iBFtMsB,WAAA,CAAA,GAAe,OAAA,QAAJ,8BAAA;;;;;;AAjCjC;;;;;AAcA;;;;;AAmBA;;;;iBCyDgB,oBAAA,CAAA;;;;AAAhB;;iBAmCgB,sBAAA,CAAA;;;;;;AD7HhB;;;;;AAcA;;;;;AAmBA;;;;;;;;ACyDA;;;;;AAmCA;;iBC0GgB,sBAAA,CAAA;AAAA,iBAuBA,wBAAA,CAAA;;;;;;AF9PhB;;;;;AAcA;;;;;AAmBA;;;;;;;;ACyDA;;;;;AAmCA;;;;;;;;AC0GA;;;;;AAuBA;;iBCzJgB,kBAAA,CAAA;AAAA,iBAqGA,oBAAA,CAAA;;;;;;AH1MhB;;;;;AAcA;;;;;AAmBA;iBI2DgB,gBAAA,CAAA;AAAA,iBAsCA,kBAAA,CAAA;;;;;;AJlIhB;;;;;AAcA;;;;;AAmBA;;;;;;;;iBK2CgB,kBAAA,CAAA;AAAA,iBAuBA,oBAAA,CAAA;;;cCzGH,OAAA;;;;ALgGb;;;;;AAmCA;;;;;iBKpHgB,OAAA,CAAA;;;AJ8NhB;;iBI7MgB,SAAA,CAAA"}