sygnal 5.3.1 → 5.3.2
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/dist/index.cjs.js +120 -119
- package/dist/index.esm.js +84 -83
- package/dist/sygnal.min.js +1 -1
- package/package.json +1 -1
- package/src/extra/pwa.ts +29 -27
package/package.json
CHANGED
package/src/extra/pwa.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _xs from './xstreamCompat';
|
|
2
|
+
import type {Stream, Listener} from 'xstream';
|
|
3
|
+
import type xsType from 'xstream';
|
|
2
4
|
import {adapt} from '../cycle/run/adapt';
|
|
3
5
|
|
|
6
|
+
const xs = _xs as typeof xsType;
|
|
7
|
+
|
|
4
8
|
// ── Types ────────────────────────────────────────────────────
|
|
5
9
|
|
|
6
10
|
export interface ServiceWorkerSource {
|
|
@@ -109,34 +113,32 @@ export function makeServiceWorkerDriver(
|
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
// ── onlineStatus$ ────────────────────────────────────────────
|
|
116
|
+
// Lazy — the real stream is created on first subscribe so importing
|
|
117
|
+
// sygnal in SSR doesn't eagerly reference window/navigator.
|
|
112
118
|
|
|
113
|
-
|
|
114
|
-
if (typeof window === 'undefined') {
|
|
115
|
-
return xs.of(true);
|
|
116
|
-
}
|
|
119
|
+
let _onlineCleanup: (() => void) | undefined;
|
|
117
120
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export const onlineStatus$: Stream<boolean> = _createOnlineStatus();
|
|
121
|
+
export const onlineStatus$: Stream<boolean> = xs.create<boolean>({
|
|
122
|
+
start(listener: Listener<boolean>) {
|
|
123
|
+
if (typeof window === 'undefined') {
|
|
124
|
+
listener.next(true);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
listener.next(navigator.onLine);
|
|
128
|
+
const on = () => listener.next(true);
|
|
129
|
+
const off = () => listener.next(false);
|
|
130
|
+
window.addEventListener('online', on);
|
|
131
|
+
window.addEventListener('offline', off);
|
|
132
|
+
_onlineCleanup = () => {
|
|
133
|
+
window.removeEventListener('online', on);
|
|
134
|
+
window.removeEventListener('offline', off);
|
|
135
|
+
};
|
|
136
|
+
},
|
|
137
|
+
stop() {
|
|
138
|
+
_onlineCleanup?.();
|
|
139
|
+
_onlineCleanup = undefined;
|
|
140
|
+
},
|
|
141
|
+
});
|
|
140
142
|
|
|
141
143
|
// ── createInstallPrompt ──────────────────────────────────────
|
|
142
144
|
|