@livx.cc/native-kit 0.26.0 → 0.28.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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livx.cc/native-kit",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Isomorphic native-capabilities kit for PWAs
|
|
3
|
+
"version": "0.28.0",
|
|
4
|
+
"description": "Isomorphic native-capabilities kit for PWAs \u2014 same API in browser and in an appwrap native shell. Zero dependencies.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Elya Livshitz",
|
|
7
7
|
"homepage": "https://github.com/Livshitz/appwrap#readme",
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"src"
|
|
38
38
|
],
|
|
39
39
|
"scripts": {
|
|
40
|
-
"
|
|
40
|
+
"typecheck": "tsc --noEmit",
|
|
41
|
+
"build": "tsc --noEmit && bun build src/index.ts --outdir=dist --format=esm && bun build src/index.ts --outfile=dist/native-kit.iife.js --format=iife --global-name=NativeKitLib"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
44
|
"typescript": "^5.4.0"
|
package/src/core/web-adapter.ts
CHANGED
|
@@ -417,6 +417,7 @@ export class WebAdapter implements NativeKitAdapter {
|
|
|
417
417
|
case 'push.requestPermission':
|
|
418
418
|
case 'push.register':
|
|
419
419
|
case 'push.unregister':
|
|
420
|
+
case 'push.sendTest':
|
|
420
421
|
throw new KitError('UNSUPPORTED', 'No native remote push on web — use Web Push (VAPID) in your app, or run inside the appwrap shell');
|
|
421
422
|
|
|
422
423
|
default:
|
package/src/modules/push.ts
CHANGED
|
@@ -65,6 +65,13 @@ export class PushModule {
|
|
|
65
65
|
return this.kit.invoke('push.unregister');
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
/** Dev/demo: ask your backend (via `push.registrationUrl`) to push THIS device on demand. The shell
|
|
69
|
+
* POSTs the token natively (no WebView CORS) with `test:true`. Resolves `{ status }` (the backend's
|
|
70
|
+
* HTTP code). Requires a configured registrationUrl + a registered token. */
|
|
71
|
+
sendTest(): Promise<{ status: number }> {
|
|
72
|
+
return this.kit.invoke('push.sendTest', undefined, { timeoutMs: 20_000 });
|
|
73
|
+
}
|
|
74
|
+
|
|
68
75
|
/** Foreground message delivery (app open, no tap). */
|
|
69
76
|
onMessage(cb: (m: PushMessage) => void): Unsubscribe {
|
|
70
77
|
return this.kit.on('push.message', (p) => cb(p as PushMessage));
|
package/src/modules/scanner.ts
CHANGED
|
@@ -53,7 +53,9 @@ export class ScannerModule {
|
|
|
53
53
|
|
|
54
54
|
/** Open the scanner; resolve the first code, or `{ cancelled: true }` if dismissed. */
|
|
55
55
|
scan(opts: ScanOptions = {}): Promise<ScanResult | ScanCancelled> {
|
|
56
|
-
|
|
56
|
+
// Open-ended: the camera stays up until a code is found or the user cancels — lining up a QR
|
|
57
|
+
// routinely takes longer than the 10s invoke default, which would abandon the scan mid-aim.
|
|
58
|
+
return this.kit.invoke('scanner.scan', opts, { timeoutMs: 300_000 });
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
/** Dismiss an in-progress {@link scan} (its promise then resolves `{ cancelled: true }`). */
|
package/src/modules/speech.ts
CHANGED
|
@@ -68,7 +68,9 @@ export class SpeechModule {
|
|
|
68
68
|
|
|
69
69
|
/** Speak `text` aloud; resolves when the utterance finishes (or is stopped). */
|
|
70
70
|
speak(text: string, opts: SpeakOptions = {}): Promise<void> {
|
|
71
|
-
|
|
71
|
+
// Resolves only when the utterance (or its queue) finishes — easily exceeds the 10s invoke
|
|
72
|
+
// default for longer text or back-to-back speak() calls, dropping the result. Give it room.
|
|
73
|
+
return this.kit.invoke('speech.speak', { text, ...opts }, { timeoutMs: 120_000 });
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
/** Cancel the current/queued utterance immediately. */
|
|
@@ -84,7 +86,9 @@ export class SpeechModule {
|
|
|
84
86
|
/** Start capturing the mic; resolves the FINAL transcript. With `{ partial:true }`, interim
|
|
85
87
|
* results stream via {@link onPartial}. Throws `KitError('UNSUPPORTED')` where STT is absent. */
|
|
86
88
|
listen(opts: ListenOptions = {}): Promise<string> {
|
|
87
|
-
|
|
89
|
+
// Open-ended: resolves on the final result or when stopListening() is called — a person may take
|
|
90
|
+
// a while to speak, so it must not be cut off by the 10s invoke default.
|
|
91
|
+
return this.kit.invoke('speech.listen', opts, { timeoutMs: 600_000 });
|
|
88
92
|
}
|
|
89
93
|
|
|
90
94
|
/** Stop capture early; the pending {@link listen} resolves with the best transcript so far. */
|