web-launch-kit 0.0.1 → 0.0.3

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 CHANGED
@@ -28,14 +28,13 @@ The bundle is self-contained (OS/locale detection is inlined) — no peer script
28
28
  | `LaunchKit.telephone(options?)` | `Promise<void>` | Open the dialer (`tel:`) |
29
29
  | `LaunchKit.message(options?)` | `Promise<void>` | Open the SMS composer (`sms:`) |
30
30
  | `LaunchKit.mail(options?)` | `Promise<void>` | Open the mail composer (`mailto:`) |
31
+ | `LaunchKit.map(options?)` | `Promise<void>` | Open a map by query, coordinate, or directions; native app per-OS with a Google Maps web fallback |
31
32
  | `LaunchKit.filepicker(options?)` | `Promise<File[]>` | Pick files or a directory (File System Access API, with input fallback) |
32
33
  | `LaunchKit.setting(type?)` | `Promise<void>` | Open a system-settings pane where supported |
33
34
  | `LaunchKit.utils` | object | `canOpenIntent` / `canOpenUniversal` / `canOpenSetting` getters, plus async `getTrackId` / `getProductId` |
34
35
 
35
36
  `AppOpenedBy` is one of: `"scheme"`, `"universal"`, `"intent"`, `"fallback"`, `"store"`.
36
37
 
37
- Named exports `getProductId` / `getTrackId` (synchronous store-id lookups) are also available.
38
-
39
38
  ---
40
39
 
41
40
  ## Launching an app
@@ -43,7 +42,6 @@ Named exports `getProductId` / `getTrackId` (synchronous store-id lookups) are a
43
42
  `app()` takes per-platform options and only acts on the block matching the current
44
43
  OS. It builds an ordered list of candidates and tries each until one launches the
45
44
  app, resolving with the route that worked.
46
-
47
45
  ```mermaid
48
46
  flowchart TD
49
47
  A([LaunchKit.app called]) --> B{Detect OS via PlatformKit}
@@ -60,14 +58,14 @@ flowchart TD
60
58
  A2 --> A3{"scheme given, but intent missing?"}
61
59
  A3 -->|yes| A4["createIntentURL:<br/>scheme + packageName + fallback"]
62
60
  A3 -->|no| A5
63
- A4 --> A5["Priority list:<br/>intent (if canOpenIntent) ⭢ scheme fallback<br/>⭢ app store ⭢ web store (by packageName)"]
61
+ A4 --> A5["Priority list:<br/>intent (if canOpenIntent) ⭢ scheme (if canOpenScheme)<br/>⭢ fallback ⭢ app store (if canOpenScheme) ⭢ web store"]
64
62
  end
65
63
 
66
64
  subgraph IOS["ios · resolveOptions"]
67
65
  I1{"bundleId given, but trackId missing?"}
68
66
  I1 -->|yes| I2["getTrackId:<br/>iTunes lookup API (bundleId ⭢ trackId)"]
69
67
  I1 -->|no| I3
70
- I2 --> I3["Priority list:<br/>universal (if iOS ≥ 9) ⭢ scheme fallback<br/>⭢ app store ⭢ web store (by trackId)"]
68
+ I2 --> I3["Priority list:<br/>universal (if canOpenUniversal) ⭢ scheme (if canOpenScheme)<br/>⭢ fallback ⭢ app store (if canOpenScheme) ⭢ web store"]
71
69
  end
72
70
 
73
71
  subgraph WIN["windows · resolveOptions"]
@@ -123,43 +121,18 @@ flowchart TD
123
121
  import LaunchKit from 'web-launch-kit'
124
122
 
125
123
  const openedBy = await LaunchKit.app({
126
- android: {
127
- scheme: 'ms-excel://',
128
- packageName: 'com.microsoft.office.excel',
129
- intent: 'intent://#Intent;scheme=ms-excel;package=com.microsoft.office.excel;action=android.intent.action.VIEW;category=android.intent.category.BROWSABLE;S.browser_fallback_url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.microsoft.office.excel;end',
130
- fallback: 'https://www.microsoft.com/ko-kr/microsoft-365/excel',
131
- allowAppStore: true,
132
- allowWebStore: false,
133
- timeout: 1000,
134
- },
135
- ios: {
136
- scheme: 'ms-excel://',
137
- bundleId: 'com.microsoft.Office.Excel',
138
- trackId: '586683407',
139
- universal: 'https://1drv.ms/x/c/7f3d9a02c81b4e65/IQBk2wYfN8pTQ5vHmR9xLzUcAeXtP0jWnK4oD3iFgZs7bQY?e=Rk9mZ2',
140
- fallback: 'https://www.microsoft.com/ko-kr/microsoft-365/excel',
141
- allowAppStore: true,
142
- allowWebStore: false,
143
- timeout: 2000,
144
- },
145
- windows: {
146
- scheme: 'ms-excel://',
147
- packageFamilyName: 'Microsoft.Office.Desktop_8wekyb3d8bbwe',
148
- productId: 'cfq7ttc0pr28',
149
- fallback: 'https://www.microsoft.com/ko-kr/microsoft-365/excel',
150
- allowAppStore: true,
151
- allowWebStore: false,
152
- timeout: 750,
153
- },
154
- macos: {
155
- scheme: 'ms-excel://',
156
- bundleId: 'com.microsoft.Excel',
157
- trackId: '462058435',
158
- fallback: 'https://www.microsoft.com/ko-kr/microsoft-365/excel',
159
- allowAppStore: true,
160
- allowWebStore: false,
161
- timeout: 750,
162
- }
124
+ android: {
125
+ scheme: 'myapp://profile/42',
126
+ packageName: 'com.example.myapp',
127
+ allowAppStore: true,
128
+ allowWebStore: true,
129
+ },
130
+ ios: {
131
+ universal: 'https://example.com/profile/42',
132
+ scheme: 'myapp://profile/42',
133
+ bundleId: 'com.example.myapp', // resolved to a trackId for the store fallback
134
+ allowAppStore: true,
135
+ },
163
136
  })
164
137
 
165
138
  console.log(openedBy) // "universal" | "scheme" | "intent" | "fallback" | "store"
@@ -169,7 +142,12 @@ Per-platform fields: Android accepts `intent` / `scheme` / `packageName` / `fall
169
142
  (scheme ⇄ intent are derived from each other); iOS accepts `universal` / `scheme` /
170
143
  `bundleId` / `trackId`; Windows accepts `scheme` / `packageFamilyName` / `productId`;
171
144
  macOS accepts `scheme` / `bundleId` / `trackId`. All accept `fallback`, `timeout`,
172
- `allowAppStore`, `allowWebStore`.
145
+ `allowAppStore`, `allowWebStore`.
146
+
147
+ Android and iOS additionally accept
148
+ `assumeAllowedInApp` — declare it `true` only when your app is whitelisted by a
149
+ partner-gated in-app browser (e.g. Weibo) so scheme / universal-link candidates are
150
+ kept there; it never bypasses hard-blocked webviews or OS version requirements.
173
151
 
174
152
  ## Communication intents
175
153
 
@@ -200,6 +178,33 @@ const files = await LaunchKit.filepicker({ accept: ['image/*', '.pdf'], multiple
200
178
  const tree = await LaunchKit.filepicker({ directory: true })
201
179
  ```
202
180
 
181
+ ## Maps
182
+
183
+ `map()` takes an intent — a search query, a coordinate, or a route — and builds the
184
+ right URL for the current OS (`maps://` on iOS/macOS, `geo:` on Android, `bingmaps:`
185
+ on Windows), falling back to Google Maps on the web.
186
+
187
+ ```js
188
+ import LaunchKit from 'web-launch-kit'
189
+
190
+ // Search for a place
191
+ await LaunchKit.map({ query: 'Seoul City Hall' })
192
+
193
+ // Show a coordinate with a labelled pin
194
+ await LaunchKit.map({ coordinate: [37.5665, 126.9780], label: 'Seoul City Hall', zoom: 15 })
195
+
196
+ // Directions (origin defaults to current location when omitted)
197
+ await LaunchKit.map({ directions: { destination: 'Seoul Station', origin: [37.5665, 126.9780] } })
198
+ ```
199
+
200
+ Provide exactly one of `query` / `coordinate` / `directions`; when several are set,
201
+ `directions` wins, then `coordinate`, then `query`. A `label` with `coordinate`
202
+ renders a named pin on iOS/macOS/Windows and is ignored on Android, where `geo:`
203
+ handlers other than Google Maps misread the labelled form as a search. Android's
204
+ `geo:` scheme also has no standard directions support, so routes use the Google Maps
205
+ fallback there, and on Windows the discontinued Maps app means `bingmaps:` usually
206
+ defers to the web fallback too.
207
+
203
208
  ## System settings
204
209
 
205
210
  ```js
@@ -239,3 +244,10 @@ const { default: LaunchKit } = require('web-launch-kit')
239
244
  exports are synchronous (blocking XHR) and intended for internal/legacy use.
240
245
  - **Store-id lookups depend on remote APIs** (iTunes Lookup, Microsoft display catalog)
241
246
  and are cached for one hour; failures resolve to `undefined` rather than throwing.
247
+ - **In-app browsers are gated per candidate.** Inside webviews that block launches
248
+ (WeChat, QQ, Qzone, Baidu; Weibo unless partnered), dead candidates — custom schemes,
249
+ `intent://`, and store schemes like `market://` — are skipped up front instead of
250
+ burning their timeouts, so the chain falls straight through to `fallback` / web store
251
+ (the only routes that work there). Whitelisted partner apps opt back in with
252
+ `assumeAllowedInApp: true`.
253
+ - **`map()` uses the per-OS timeout** for each candidate.
package/dist/index.d.ts CHANGED
@@ -82,11 +82,13 @@ declare interface AppInfo {
82
82
  declare interface AndroidAppInfo extends AppInfo {
83
83
  intent?: URLCandidate;
84
84
  packageName?: string;
85
+ assumeAllowedInApp?: boolean;
85
86
  }
86
87
  declare interface IOSAppInfo extends AppInfo {
87
88
  universal?: URLCandidate;
88
89
  bundleId?: string;
89
90
  trackId?: string;
91
+ assumeAllowedInApp?: boolean;
90
92
  }
91
93
  declare interface WindowsAppInfo extends AppInfo {
92
94
  packageFamilyName?: string;
@@ -123,6 +125,17 @@ declare interface FilepickerOptions {
123
125
  multiple?: boolean;
124
126
  startIn?: OpenPickerStartIn;
125
127
  }
128
+ declare interface MapOptions {
129
+ query?: string;
130
+ coordinate?: [number, number];
131
+ label?: string;
132
+ directions?: {
133
+ destination: string | [number, number];
134
+ origin?: string | [number, number];
135
+ };
136
+ zoom?: number;
137
+ fallback?: URLStringOrFallback;
138
+ }
126
139
  interface LaunchKitUtils {
127
140
  get canOpenIntent(): boolean;
128
141
  get canOpenUniversal(): boolean;
@@ -138,10 +151,11 @@ interface LaunchKitInstance {
138
151
  telephone(options?: TelephoneOptions): Promise<void>;
139
152
  message(options?: MessageOptions): Promise<void>;
140
153
  mail(options?: MailOptions): Promise<void>;
154
+ map(options?: MapOptions): Promise<void>;
141
155
  filepicker(options?: FilepickerOptions): Promise<File[]>;
142
156
  setting(type?: SettingType): Promise<void>;
143
157
  }
144
158
  declare const LaunchKit: LaunchKitInstance;
145
159
 
146
160
  export { SettingType, LaunchKit as default };
147
- export type { AndroidAppInfo, AppInfo, AppOpenOptions, AppOpenedBy, FilepickerOptions, IOSAppInfo, LaunchKitInstance, MacOSAppInfo, MailOptions, MessageOptions, OpenPickerStartIn, TelephoneOptions, URLCandidate, URLCandidateOrFallback, URLStringOrFallback, WindowsAppInfo };
161
+ export type { AndroidAppInfo, AppInfo, AppOpenOptions, AppOpenedBy, FilepickerOptions, IOSAppInfo, LaunchKitInstance, MacOSAppInfo, MailOptions, MapOptions, MessageOptions, OpenPickerStartIn, TelephoneOptions, URLCandidate, URLCandidateOrFallback, URLStringOrFallback, WindowsAppInfo };