@sparkelf/dsh-mobile-bridge-server 0.2.9 → 0.2.11
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 +1 -1
- package/src/phone.ts +3 -3
- package/src/pwa.spec.ts +14 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sparkelf/dsh-mobile-bridge-server",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Multi-user bridge server connecting mobile browsers to local DeepSeek Harness instances through outbound tunnels.",
|
|
6
6
|
"license": "MIT",
|
package/src/phone.ts
CHANGED
|
@@ -212,8 +212,8 @@ function wsReady() {
|
|
|
212
212
|
}
|
|
213
213
|
if ((full.headers?.['content-type'] ?? '').includes('text/html')) {
|
|
214
214
|
let html = new TextDecoder().decode(body)
|
|
215
|
-
if (!html.includes('/bridge/socket-client.js')) html = html.replace('</head>', PWA_HEAD + '<script src="/bridge/socket-client.js"></script></head>')
|
|
216
|
-
else if (!html.includes('/bridge/manifest.webmanifest')) html = html.replace('</head>', PWA_HEAD + '</head>')
|
|
215
|
+
if (!html.includes('/bridge/socket-client.js')) html = html.replace('</head>', '${PWA_HEAD}' + '<script src="/bridge/socket-client.js"></script></head>')
|
|
216
|
+
else if (!html.includes('/bridge/manifest.webmanifest')) html = html.replace('</head>', '${PWA_HEAD}' + '</head>')
|
|
217
217
|
body = new TextEncoder().encode(html)
|
|
218
218
|
}
|
|
219
219
|
pending.delete(frame.id)
|
|
@@ -528,7 +528,7 @@ export const CLIENT_SOURCE = `/* DSH mobile bridge client bootstrap: login, pair
|
|
|
528
528
|
|
|
529
529
|
function registerSw(pair) {
|
|
530
530
|
if (!('serviceWorker' in navigator)) return Promise.reject(new Error('serviceWorkerUnsupported'))
|
|
531
|
-
return navigator.serviceWorker.register('/
|
|
531
|
+
return navigator.serviceWorker.register('/sw.js', { scope: '/', updateViaCache: 'none' })
|
|
532
532
|
.then(activateLatestWorker)
|
|
533
533
|
.then(function () { return navigator.serviceWorker.ready })
|
|
534
534
|
.then(function (registration) { return persistPair(registration, pair) })
|
package/src/pwa.spec.ts
CHANGED
|
@@ -5,7 +5,8 @@ import { join } from 'node:path'
|
|
|
5
5
|
import type { AddressInfo } from 'node:net'
|
|
6
6
|
import { createBridgeServer } from './server.ts'
|
|
7
7
|
import { UserStore } from './store.ts'
|
|
8
|
-
import { CLIENT_SOURCE, PWA_HEAD } from './phone.ts'
|
|
8
|
+
import { CLIENT_SOURCE, PWA_HEAD, SW_SOURCE } from './phone.ts'
|
|
9
|
+
import { Script } from 'node:vm'
|
|
9
10
|
|
|
10
11
|
const open: Array<{ close: () => void }> = []
|
|
11
12
|
afterEach(() => { for (const entry of open.splice(0)) entry.close() })
|
|
@@ -58,6 +59,17 @@ describe('phone PWA install surface', () => {
|
|
|
58
59
|
expect(PWA_HEAD).toContain('rel="manifest" href="/bridge/manifest.webmanifest"')
|
|
59
60
|
expect(PWA_HEAD).toContain('rel="apple-touch-icon"')
|
|
60
61
|
expect(PWA_HEAD).toContain('/bridge/pwa-install.js')
|
|
61
|
-
expect(CLIENT_SOURCE).toContain("register('/
|
|
62
|
+
expect(CLIENT_SOURCE).toContain("register('/sw.js', { scope: '/'")
|
|
63
|
+
// SW scope '/' is an ancestor of the manifest start_url '/bridge/', so install
|
|
64
|
+
// criteria hold while '/' navigations stay relay-forwarded (not Sub2API).
|
|
65
|
+
expect(CLIENT_SOURCE).toContain("location.assign('/')")
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('SW source interpolates PWA_HEAD (no bare module identifier) and parses', () => {
|
|
69
|
+
// The head-inject lives inside the SW template; a bare PWA_HEAD there is a
|
|
70
|
+
// ReferenceError at SW runtime that kills every relayed HTML navigation.
|
|
71
|
+
expect(SW_SOURCE).not.toMatch(/\bPWA_HEAD\b/)
|
|
72
|
+
expect(SW_SOURCE).toContain('rel="manifest" href="/bridge/manifest.webmanifest"')
|
|
73
|
+
expect(() => new Script(SW_SOURCE)).not.toThrow()
|
|
62
74
|
})
|
|
63
75
|
})
|