@livx.cc/native-kit 0.18.0 → 0.20.0
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/package.json
CHANGED
package/src/core/web-adapter.ts
CHANGED
|
@@ -297,6 +297,9 @@ export class WebAdapter implements NativeKitAdapter {
|
|
|
297
297
|
return { picked: true, name: c.name?.[0], phones: c.tel, emails: c.email } as T;
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
+
case 'contacts.getAll':
|
|
301
|
+
throw new KitError('UNSUPPORTED', 'No bulk contacts read on web — use contacts.pick');
|
|
302
|
+
|
|
300
303
|
case 'calendar.createEvent':
|
|
301
304
|
throw new KitError('UNSUPPORTED', 'No calendar access on web');
|
|
302
305
|
|
|
@@ -337,6 +340,7 @@ export class WebAdapter implements NativeKitAdapter {
|
|
|
337
340
|
case 'billing.purchase':
|
|
338
341
|
case 'billing.restore':
|
|
339
342
|
case 'billing.entitlements':
|
|
343
|
+
case 'billing.appReceipt':
|
|
340
344
|
case 'billing.manageSubscriptions':
|
|
341
345
|
throw new KitError('UNSUPPORTED', 'No in-app purchases on web — use a web checkout');
|
|
342
346
|
|
|
@@ -79,6 +79,26 @@ export class BillingModule {
|
|
|
79
79
|
return out;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Confirm entitlements **silently** from the on-device App Store receipt — no Apple-ID
|
|
84
|
+
* prompt and no `restore()` round-trip (unlike {@link restore}/{@link entitlements} on
|
|
85
|
+
* StoreKit 1). For an in-place update of the SAME bundle id the receipt already holds the
|
|
86
|
+
* user's active/grandfathered subscriptions, so this is the zero-user-action path for
|
|
87
|
+
* migrating existing subscribers into a new build.
|
|
88
|
+
*
|
|
89
|
+
* Native iOS only, and only meaningful with a **server validator** (the bare receipt has no
|
|
90
|
+
* product id — a client-trusted validator can't interpret it). Resolves `[]` on the web,
|
|
91
|
+
* on Android (no StoreKit-1 receipt), or when no receipt is present (e.g. a dev build).
|
|
92
|
+
*/
|
|
93
|
+
async entitlementsFromReceipt(): Promise<Entitlement[]> {
|
|
94
|
+
await this.kit.ready();
|
|
95
|
+
if (this.capability !== 'native') return []; // web, or a shell with no native store handler (Android today)
|
|
96
|
+
if (this.validator instanceof ClientTrustedValidator) return []; // bare receipt has no product id → would grant a bogus active entitlement; needs a server validator
|
|
97
|
+
const receipt = await this.kit.invoke<PurchaseReceipt>('billing.appReceipt');
|
|
98
|
+
if (!receipt?.appReceipt) return [];
|
|
99
|
+
return this.validator.validate(receipt); // server-of-record turns the receipt into entitlements
|
|
100
|
+
}
|
|
101
|
+
|
|
82
102
|
/** Current entitlements from the configured server-of-record (web provider or validator). */
|
|
83
103
|
async entitlements(): Promise<Entitlement[]> {
|
|
84
104
|
await this.kit.ready();
|
package/src/modules/contacts.ts
CHANGED
|
@@ -7,6 +7,12 @@ export interface PickedContact {
|
|
|
7
7
|
emails?: string[];
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
export interface Contact {
|
|
11
|
+
name?: string;
|
|
12
|
+
phones?: string[];
|
|
13
|
+
emails?: string[];
|
|
14
|
+
}
|
|
15
|
+
|
|
10
16
|
/** Contact picker — native: CNContactPicker (no permission needed); web: Contact Picker API where present. */
|
|
11
17
|
export class ContactsModule {
|
|
12
18
|
constructor(private kit: NativeKit) {}
|
|
@@ -19,4 +25,9 @@ export class ContactsModule {
|
|
|
19
25
|
pick(): Promise<PickedContact> {
|
|
20
26
|
return this.kit.invoke('contacts.pick', undefined, { timeoutMs: 120_000 });
|
|
21
27
|
}
|
|
28
|
+
|
|
29
|
+
/** Read the full address book; native-only (requires permission), unsupported on web. */
|
|
30
|
+
getAll(): Promise<{ contacts: Contact[] }> {
|
|
31
|
+
return this.kit.invoke('contacts.getAll', undefined, { timeoutMs: 120_000 });
|
|
32
|
+
}
|
|
22
33
|
}
|
package/src/modules/updates.ts
CHANGED
|
@@ -44,6 +44,9 @@ export class UpdatesModule {
|
|
|
44
44
|
private timer: ReturnType<typeof setInterval> | null = null;
|
|
45
45
|
private unsubs: Unsubscribe[] = [];
|
|
46
46
|
private listeners = new Set<(s: UpdateStatus) => void>();
|
|
47
|
+
/** The auto banner is shown at most once per JS session — so a dismissed prompt doesn't nag on
|
|
48
|
+
* every poll. A reload (the intended response) boots a fresh bundle/context and resets this; until
|
|
49
|
+
* then, {@link onAvailable} listeners still fire each check so an app can re-surface it itself. */
|
|
47
50
|
private prompted = false;
|
|
48
51
|
|
|
49
52
|
constructor(private kit: NativeKit) {}
|
|
@@ -110,7 +113,7 @@ export class UpdatesModule {
|
|
|
110
113
|
this.stop(/* keepStarted */ true);
|
|
111
114
|
}
|
|
112
115
|
this.started = true;
|
|
113
|
-
//
|
|
116
|
+
// Re-check whenever the app returns to the foreground (catches a deploy made while backgrounded).
|
|
114
117
|
this.unsubs.push(this.kit.on('app.resume', () => void this.check()));
|
|
115
118
|
// Banner tap (or any 'appwrap.update' action) → reload.
|
|
116
119
|
this.unsubs.push(
|