@ait-co/polyfill 0.1.5 → 0.1.7

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 (47) hide show
  1. package/README.md +55 -3
  2. package/dist/auto.cjs +919 -0
  3. package/dist/auto.cjs.map +1 -0
  4. package/dist/auto.d.cts +1 -0
  5. package/dist/auto.js +18 -6
  6. package/dist/auto.js.map +1 -1
  7. package/dist/detect.cjs +84 -0
  8. package/dist/detect.cjs.map +1 -0
  9. package/dist/detect.d.cts +50 -0
  10. package/dist/detect.d.cts.map +1 -0
  11. package/dist/index.cjs +982 -0
  12. package/dist/index.cjs.map +1 -0
  13. package/dist/index.d.cts +222 -0
  14. package/dist/index.d.cts.map +1 -0
  15. package/dist/index.d.ts +26 -27
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +68 -8
  18. package/dist/index.js.map +1 -1
  19. package/dist/shims/clipboard.cjs +192 -0
  20. package/dist/shims/clipboard.cjs.map +1 -0
  21. package/dist/shims/clipboard.d.cts +26 -0
  22. package/dist/shims/clipboard.d.cts.map +1 -0
  23. package/dist/shims/geolocation.cjs +356 -0
  24. package/dist/shims/geolocation.cjs.map +1 -0
  25. package/dist/shims/geolocation.d.cts +41 -0
  26. package/dist/shims/geolocation.d.cts.map +1 -0
  27. package/dist/shims/network.cjs +290 -0
  28. package/dist/shims/network.cjs.map +1 -0
  29. package/dist/shims/network.d.cts +56 -0
  30. package/dist/shims/network.d.cts.map +1 -0
  31. package/dist/shims/share.cjs +239 -0
  32. package/dist/shims/share.cjs.map +1 -0
  33. package/dist/shims/share.d.cts +26 -0
  34. package/dist/shims/share.d.cts.map +1 -0
  35. package/dist/shims/vibrate-semantic.d.ts +27 -0
  36. package/dist/shims/vibrate-semantic.d.ts.map +1 -0
  37. package/dist/shims/vibrate-semantic.js +150 -0
  38. package/dist/shims/vibrate-semantic.js.map +1 -0
  39. package/dist/shims/vibrate.cjs +235 -0
  40. package/dist/shims/vibrate.cjs.map +1 -0
  41. package/dist/shims/vibrate.d.cts +43 -0
  42. package/dist/shims/vibrate.d.cts.map +1 -0
  43. package/dist/shims/vibrate.d.ts +16 -5
  44. package/dist/shims/vibrate.d.ts.map +1 -1
  45. package/dist/shims/vibrate.js +19 -7
  46. package/dist/shims/vibrate.js.map +1 -1
  47. package/package.json +80 -19
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @ait-co/polyfill
2
2
 
3
+ ![@ait-co/polyfill — 표준 Web API로 미니앱을 작성](./assets/og/image.png)
4
+
3
5
  > Part of the unofficial `apps-in-toss-community` project. Not affiliated with Toss.
4
6
  > 비공식 커뮤니티 프로젝트입니다. 토스와 제휴하지 않았습니다.
5
7
 
@@ -19,6 +21,8 @@ pnpm add @ait-co/polyfill
19
21
  pnpm add @apps-in-toss/web-framework # only if you also ship a Toss build
20
22
  ```
21
23
 
24
+ The package ships dual ESM + CJS builds, so `require('@ait-co/polyfill/auto')` works in CommonJS hosts too.
25
+
22
26
  ## Usage
23
27
 
24
28
  ### Just add the dep (recommended)
@@ -60,7 +64,7 @@ import { installClipboardShim } from '@ait-co/polyfill/clipboard';
60
64
  installClipboardShim(); // installs unconditionally — gate with detect.ts if you want Toss-only
61
65
  ```
62
66
 
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.
67
+ 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
68
 
65
69
  ## Environment detection
66
70
 
@@ -78,13 +82,61 @@ Tier 1 — all shipped; paired SDK routing is live when inside Apps in Toss.
78
82
  | `navigator.geolocation.getCurrentPosition()` | `getCurrentLocation({ accuracy })` | 0.1.1 |
79
83
  | `navigator.geolocation.watchPosition()` / `clearWatch()` | `startUpdateLocation(...)` | 0.1.1 |
80
84
  | `navigator.share({ title, text, url })` | `share({ message })` (concatenates into `message`) | 0.1.1 |
81
- | `navigator.vibrate(pattern)` | `generateHapticFeedback(...)` (best-effort, lossy) | 0.1.1 |
85
+ | `navigator.vibrate(pattern)` | `generateHapticFeedback(...)` (best-effort, lossy; see below) | 0.1.1 |
82
86
  | `navigator.onLine` / `navigator.connection.effectiveType` | `getNetworkStatus()` (poll on read; no `change` for seed) | 0.1.1 |
83
87
 
84
- See [`TODO.md`](./TODO.md) for the full backlog and tiering.
88
+ ### `navigator.vibrate` mapping
89
+
90
+ The Web `vibrate` spec only takes durations; the SDK's `generateHapticFeedback` is qualitative. Single-duration calls bucket like this inside Apps in Toss:
91
+
92
+ | Input | SDK haptic |
93
+ |---|---|
94
+ | `vibrate(0)` / `vibrate([])` | no-op (cancels native pending vibration) |
95
+ | `vibrate(1..20)` | `tickWeak` |
96
+ | `vibrate(21..45)` | `tickMedium` |
97
+ | `vibrate(>=46)` | `basicMedium` |
98
+ | `vibrate([on, off, on, off, ...])` | each non-zero "on" slot fires `tap`, with `setTimeout` honouring the gaps |
99
+
100
+ Length-only mapping cannot recover semantic intent (success vs. error vs. warning). When the caller knows what the haptic *means*, prefer the helper:
101
+
102
+ ```ts
103
+ import { vibrateSemantic } from '@ait-co/polyfill/vibrate-semantic';
104
+
105
+ vibrateSemantic('success'); // → SDK 'success'
106
+ vibrateSemantic('error'); // → SDK 'error'
107
+ vibrateSemantic('warning'); // → SDK 'tickMedium' (no direct variant)
108
+ vibrateSemantic('selection'); // → SDK 'tickWeak' (no direct variant)
109
+ ```
110
+
111
+ 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.
112
+
113
+ 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.
114
+
115
+ See [`INTEGRATION.md`](./INTEGRATION.md) for an adoption guide (Vite + React
116
+ snippet, recommended pairing with `@ait-co/devtools`, per-API one-liners).
85
117
 
86
118
  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
119
 
120
+ ## Development
121
+
122
+ ```sh
123
+ pnpm install
124
+ pnpm test
125
+ pnpm lint
126
+ pnpm typecheck
127
+ pnpm build
128
+ ```
129
+
130
+ ### Pre-commit hook
131
+
132
+ Optional but recommended. After cloning, activate the standard pre-commit hook (runs `biome check` on staged files):
133
+
134
+ ```sh
135
+ git config core.hooksPath .githooks
136
+ ```
137
+
138
+ 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.
139
+
88
140
  ## License
89
141
 
90
142
  BSD-3-Clause