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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sygnal",
3
- "version": "5.3.1",
3
+ "version": "5.3.2",
4
4
  "description": "An intuitive framework for building fast and small components or applications based on Cycle.js",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "types": "./dist/index.d.ts",
package/src/extra/pwa.ts CHANGED
@@ -1,6 +1,10 @@
1
- import xs, {Stream} from 'xstream';
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
- function _createOnlineStatus(): Stream<boolean> {
114
- if (typeof window === 'undefined') {
115
- return xs.of(true);
116
- }
119
+ let _onlineCleanup: (() => void) | undefined;
117
120
 
118
- let cleanup: (() => void) | undefined;
119
-
120
- return xs.create<boolean>({
121
- start(listener) {
122
- listener.next(navigator.onLine);
123
- const on = () => listener.next(true);
124
- const off = () => listener.next(false);
125
- window.addEventListener('online', on);
126
- window.addEventListener('offline', off);
127
- cleanup = () => {
128
- window.removeEventListener('online', on);
129
- window.removeEventListener('offline', off);
130
- };
131
- },
132
- stop() {
133
- cleanup?.();
134
- cleanup = undefined;
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