@ait-co/polyfill 0.1.4 → 0.1.6
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 +53 -3
- package/dist/auto.cjs +919 -0
- package/dist/auto.cjs.map +1 -0
- package/dist/auto.d.cts +1 -0
- package/dist/auto.js +18 -6
- package/dist/auto.js.map +1 -1
- package/dist/detect.cjs +84 -0
- package/dist/detect.cjs.map +1 -0
- package/dist/detect.d.cts +50 -0
- package/dist/detect.d.cts.map +1 -0
- package/dist/index.cjs +982 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +222 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +26 -27
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +68 -8
- package/dist/index.js.map +1 -1
- package/dist/shims/clipboard.cjs +192 -0
- package/dist/shims/clipboard.cjs.map +1 -0
- package/dist/shims/clipboard.d.cts +26 -0
- package/dist/shims/clipboard.d.cts.map +1 -0
- package/dist/shims/geolocation.cjs +356 -0
- package/dist/shims/geolocation.cjs.map +1 -0
- package/dist/shims/geolocation.d.cts +41 -0
- package/dist/shims/geolocation.d.cts.map +1 -0
- package/dist/shims/network.cjs +290 -0
- package/dist/shims/network.cjs.map +1 -0
- package/dist/shims/network.d.cts +56 -0
- package/dist/shims/network.d.cts.map +1 -0
- package/dist/shims/share.cjs +239 -0
- package/dist/shims/share.cjs.map +1 -0
- package/dist/shims/share.d.cts +26 -0
- package/dist/shims/share.d.cts.map +1 -0
- package/dist/shims/vibrate-semantic.d.ts +27 -0
- package/dist/shims/vibrate-semantic.d.ts.map +1 -0
- package/dist/shims/vibrate-semantic.js +150 -0
- package/dist/shims/vibrate-semantic.js.map +1 -0
- package/dist/shims/vibrate.cjs +235 -0
- package/dist/shims/vibrate.cjs.map +1 -0
- package/dist/shims/vibrate.d.cts +43 -0
- package/dist/shims/vibrate.d.cts.map +1 -0
- package/dist/shims/vibrate.d.ts +16 -5
- package/dist/shims/vibrate.d.ts.map +1 -1
- package/dist/shims/vibrate.js +19 -7
- package/dist/shims/vibrate.js.map +1 -1
- package/package.json +83 -30
package/README.md
CHANGED
|
@@ -19,6 +19,8 @@ pnpm add @ait-co/polyfill
|
|
|
19
19
|
pnpm add @apps-in-toss/web-framework # only if you also ship a Toss build
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
The package ships dual ESM + CJS builds, so `require('@ait-co/polyfill/auto')` works in CommonJS hosts too.
|
|
23
|
+
|
|
22
24
|
## Usage
|
|
23
25
|
|
|
24
26
|
### Just add the dep (recommended)
|
|
@@ -60,7 +62,7 @@ import { installClipboardShim } from '@ait-co/polyfill/clipboard';
|
|
|
60
62
|
installClipboardShim(); // installs unconditionally — gate with detect.ts if you want Toss-only
|
|
61
63
|
```
|
|
62
64
|
|
|
63
|
-
The package is marked `sideEffects: ["./dist/auto.js"]`, so only the `/auto` entry is kept when tree-shaking; everything else is drop-if-unused.
|
|
65
|
+
The package is marked `sideEffects: ["./dist/auto.js", "./dist/auto.cjs"]`, so only the `/auto` entry (in either format) is kept when tree-shaking; everything else is drop-if-unused.
|
|
64
66
|
|
|
65
67
|
## Environment detection
|
|
66
68
|
|
|
@@ -78,13 +80,61 @@ Tier 1 — all shipped; paired SDK routing is live when inside Apps in Toss.
|
|
|
78
80
|
| `navigator.geolocation.getCurrentPosition()` | `getCurrentLocation({ accuracy })` | 0.1.1 |
|
|
79
81
|
| `navigator.geolocation.watchPosition()` / `clearWatch()` | `startUpdateLocation(...)` | 0.1.1 |
|
|
80
82
|
| `navigator.share({ title, text, url })` | `share({ message })` (concatenates into `message`) | 0.1.1 |
|
|
81
|
-
| `navigator.vibrate(pattern)` | `generateHapticFeedback(...)` (best-effort, lossy) | 0.1.1 |
|
|
83
|
+
| `navigator.vibrate(pattern)` | `generateHapticFeedback(...)` (best-effort, lossy; see below) | 0.1.1 |
|
|
82
84
|
| `navigator.onLine` / `navigator.connection.effectiveType` | `getNetworkStatus()` (poll on read; no `change` for seed) | 0.1.1 |
|
|
83
85
|
|
|
84
|
-
|
|
86
|
+
### `navigator.vibrate` mapping
|
|
87
|
+
|
|
88
|
+
The Web `vibrate` spec only takes durations; the SDK's `generateHapticFeedback` is qualitative. Single-duration calls bucket like this inside Apps in Toss:
|
|
89
|
+
|
|
90
|
+
| Input | SDK haptic |
|
|
91
|
+
|---|---|
|
|
92
|
+
| `vibrate(0)` / `vibrate([])` | no-op (cancels native pending vibration) |
|
|
93
|
+
| `vibrate(1..20)` | `tickWeak` |
|
|
94
|
+
| `vibrate(21..45)` | `tickMedium` |
|
|
95
|
+
| `vibrate(>=46)` | `basicMedium` |
|
|
96
|
+
| `vibrate([on, off, on, off, ...])` | each non-zero "on" slot fires `tap`, with `setTimeout` honouring the gaps |
|
|
97
|
+
|
|
98
|
+
Length-only mapping cannot recover semantic intent (success vs. error vs. warning). When the caller knows what the haptic *means*, prefer the helper:
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
import { vibrateSemantic } from '@ait-co/polyfill/vibrate-semantic';
|
|
102
|
+
|
|
103
|
+
vibrateSemantic('success'); // → SDK 'success'
|
|
104
|
+
vibrateSemantic('error'); // → SDK 'error'
|
|
105
|
+
vibrateSemantic('warning'); // → SDK 'tickMedium' (no direct variant)
|
|
106
|
+
vibrateSemantic('selection'); // → SDK 'tickWeak' (no direct variant)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The helper does not install anything and does not touch `navigator.vibrate`. It also re-exports from the package root (`import { vibrateSemantic } from '@ait-co/polyfill'`) for convenience, but the sub-path is the tree-shake-friendly form.
|
|
110
|
+
|
|
111
|
+
Outside Apps in Toss, `vibrateSemantic` falls back to a short `navigator.vibrate(...)` so the user still gets *some* feedback. `navigator.vibrate(...)` keeps its standard signature in every environment — the helper is the only way to pass intent.
|
|
112
|
+
|
|
113
|
+
See [`INTEGRATION.md`](./INTEGRATION.md) for an adoption guide (Vite + React
|
|
114
|
+
snippet, recommended pairing with `@ait-co/devtools`, per-API one-liners).
|
|
85
115
|
|
|
86
116
|
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).
|
|
87
117
|
|
|
118
|
+
## Development
|
|
119
|
+
|
|
120
|
+
```sh
|
|
121
|
+
pnpm install
|
|
122
|
+
pnpm test
|
|
123
|
+
pnpm lint
|
|
124
|
+
pnpm typecheck
|
|
125
|
+
pnpm build
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Pre-commit hook
|
|
129
|
+
|
|
130
|
+
Optional but recommended. After cloning, activate the standard pre-commit hook (runs `biome check` on staged files):
|
|
131
|
+
|
|
132
|
+
```sh
|
|
133
|
+
git config core.hooksPath .githooks
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
This is a developer convenience for fast feedback before push. CI runs the same checks as the enforcement layer, so contributors who don't activate the hook will still see lint failures in their PR.
|
|
137
|
+
|
|
88
138
|
## License
|
|
89
139
|
|
|
90
140
|
BSD-3-Clause
|