@invictus-test/browser-api 0.0.0-stage → 0.0.2-dev.6
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/README.md +62 -2
- package/fesm2022/invictus-test-browser-api.mjs +214 -0
- package/fesm2022/invictus-test-browser-api.mjs.map +1 -0
- package/package.json +39 -4
- package/schematics/collection.json +10 -0
- package/schematics/ng-add/index.js +68 -0
- package/schematics/ng-add/schema.json +9 -0
- package/schematics/package.json +3 -0
- package/types/invictus-test-browser-api.d.ts +123 -0
package/README.md
CHANGED
|
@@ -1,3 +1,63 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @invictus-test/browser-api
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
SSR-safe Angular injection tokens for browser APIs, part of the Invictus monorepo.
|
|
4
|
+
|
|
5
|
+
Each token resolves to the browser object when it exists and to a safe fallback during server-side
|
|
6
|
+
rendering or when the browser does not support the API, so components never touch `window`,
|
|
7
|
+
`navigator` or `document` globals directly.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
ng add @invictus-test/browser-api
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
`ng add` installs the package into `dependencies` and checks that your Angular version is supported. It changes no
|
|
16
|
+
application files, and no providers, modules or styles need to be registered. Running it again is safe.
|
|
17
|
+
`npm install @invictus-test/browser-api` works as well.
|
|
18
|
+
|
|
19
|
+
> `ng add` support is verified against a locally built archive and is not yet available from npm; it ships with the
|
|
20
|
+
> first release that includes it.
|
|
21
|
+
|
|
22
|
+
Peer dependencies: `@angular/core` and `@angular/common` `^22.0.0`, `rxjs` `^7.4.0`.
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { Component, inject } from '@angular/core';
|
|
28
|
+
import { toSignal } from '@angular/core/rxjs-interop';
|
|
29
|
+
import { LOCAL_STORAGE, MATCH_MEDIA, ONLINE_STATUS } from '@invictus-test/browser-api';
|
|
30
|
+
|
|
31
|
+
@Component({ selector: 'app-status', template: `{{ online() }}` })
|
|
32
|
+
export class Status {
|
|
33
|
+
protected readonly online = toSignal(inject(ONLINE_STATUS), { initialValue: true });
|
|
34
|
+
private readonly storage = inject(LOCAL_STORAGE); // Storage | null
|
|
35
|
+
private readonly prefersDark = inject(MATCH_MEDIA)?.('(prefers-color-scheme: dark)').matches ?? false;
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Tokens
|
|
40
|
+
|
|
41
|
+
| Kind | Tokens |
|
|
42
|
+
| -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
43
|
+
| Value, `null` when unavailable | `WINDOW`, `NAVIGATOR`, `BROWSER_LOCATION`, `HISTORY`, `SCREEN`, `VISUAL_VIEWPORT`, `DEVICE_PIXEL_RATIO`, `PERFORMANCE`, `CRYPTO`, `CACHES`, `INDEXED_DB`, `LOCAL_STORAGE`, `SESSION_STORAGE`, `CLIPBOARD`, `GEOLOCATION`, `MEDIA_DEVICES`, `PERMISSIONS`, `USER_AGENT`, `NETWORK_INFORMATION`, `SPEECH_RECOGNITION`, `SPEECH_SYNTHESIS`, `BROADCAST_CHANNEL` |
|
|
44
|
+
| Function, `null` when unavailable | `MATCH_MEDIA` |
|
|
45
|
+
| Inert stub object, never `null` | `CSS_REF` |
|
|
46
|
+
| Observable, completes when unavailable | `ONLINE_STATUS`, `STORAGE_EVENT`, `ANIMATION_FRAME` |
|
|
47
|
+
| Observable over `DOCUMENT` | `PAGE_VISIBILITY` |
|
|
48
|
+
|
|
49
|
+
Types: `CSSRef`, `NetworkInformation`, `SpeechRecognitionCtor`. Why each token has the shape it has is explained in
|
|
50
|
+
`packages/angular/browser-api/CLAUDE.md` in the Invictus repository.
|
|
51
|
+
|
|
52
|
+
## Development
|
|
53
|
+
|
|
54
|
+
Run from the repository root (see the root README for the environment):
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npx nx run angular-browser-api:lint
|
|
58
|
+
npx nx run angular-browser-api:typecheck
|
|
59
|
+
npx nx run angular-browser-api:test # Vitest with coverage thresholds
|
|
60
|
+
npx nx run angular-browser-api:test-schematics # ng-add schematic tests against the built package
|
|
61
|
+
npx nx run angular-browser-api:build # ng-packagr (partial compilation) + schematics → dist/packages/angular/browser-api
|
|
62
|
+
npx nx run angular-browser-api:verify-package # ng add of the packed archive in a clean Angular app, browser and SSR builds
|
|
63
|
+
```
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { InjectionToken, inject } from '@angular/core';
|
|
2
|
+
import { Observable, share, EMPTY, merge, of, fromEvent, distinctUntilChanged, shareReplay } from 'rxjs';
|
|
3
|
+
import { DOCUMENT } from '@angular/common';
|
|
4
|
+
import { map } from 'rxjs/operators';
|
|
5
|
+
|
|
6
|
+
/** The global `Window`, resolved via `Document.defaultView`, or `null` during SSR. */
|
|
7
|
+
const WINDOW = new InjectionToken(ngDevMode ? '[WINDOW]' : '', {
|
|
8
|
+
factory: () => inject(DOCUMENT).defaultView,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
/** Emits the frame timestamp on every `requestAnimationFrame` tick; completes immediately with no `Window` (SSR). */
|
|
12
|
+
const ANIMATION_FRAME = new InjectionToken(ngDevMode ? '[ANIMATION_FRAME]' : '', {
|
|
13
|
+
factory: () => {
|
|
14
|
+
const win = inject(WINDOW);
|
|
15
|
+
return new Observable(subscriber => {
|
|
16
|
+
// Same shim gap as MATCH_MEDIA: `defaultView` is truthy on the server but has no rAF.
|
|
17
|
+
if (!win || typeof win.requestAnimationFrame !== 'function') {
|
|
18
|
+
subscriber.complete();
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
let id = NaN;
|
|
22
|
+
const callback = (timestamp) => {
|
|
23
|
+
subscriber.next(timestamp);
|
|
24
|
+
if (!subscriber.closed) {
|
|
25
|
+
id = win.requestAnimationFrame(callback);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
id = win.requestAnimationFrame(callback);
|
|
29
|
+
return () => {
|
|
30
|
+
win.cancelAnimationFrame(id);
|
|
31
|
+
};
|
|
32
|
+
}).pipe(share());
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const CHANNEL_NAME = 'invictus-persistence';
|
|
37
|
+
/** A `BroadcastChannel` scoped to Invictus persistence, or `null` on the server or when unsupported. */
|
|
38
|
+
const BROADCAST_CHANNEL = new InjectionToken(ngDevMode ? '[BROADCAST_CHANNEL]' : '', {
|
|
39
|
+
factory: () => {
|
|
40
|
+
const { defaultView } = inject(DOCUMENT);
|
|
41
|
+
if (!defaultView?.BroadcastChannel) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return new defaultView.BroadcastChannel(CHANNEL_NAME);
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
/** The `Window.caches` `CacheStorage`, or `null` on the server or when unsupported. */
|
|
49
|
+
const CACHES = new InjectionToken(ngDevMode ? '[CACHES]' : '', {
|
|
50
|
+
factory: () => inject(WINDOW)?.caches ?? null,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
/** The `Window.navigator` object, or `null` on the server. */
|
|
54
|
+
const NAVIGATOR = new InjectionToken(ngDevMode ? '[NAVIGATOR]' : '', {
|
|
55
|
+
factory: () => inject(WINDOW)?.navigator ?? null,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
/** The `Navigator.clipboard` API, or `null` on the server or when unsupported. */
|
|
59
|
+
const CLIPBOARD = new InjectionToken(ngDevMode ? '[CLIPBOARD]' : '', {
|
|
60
|
+
factory: () => inject(NAVIGATOR)?.clipboard ?? null,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
/** The `Window.crypto` object, or `null` on the server. */
|
|
64
|
+
const CRYPTO = new InjectionToken(ngDevMode ? '[CRYPTO]' : '', {
|
|
65
|
+
factory: () => inject(WINDOW)?.crypto ?? null,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
/** The `CSS` global, or an inert stub (identity `escape`, `supports` always `false`) when unavailable — never `null`. */
|
|
69
|
+
const CSS_REF = new InjectionToken(ngDevMode ? '[CSS_REF]' : '', {
|
|
70
|
+
factory: () => {
|
|
71
|
+
const win = inject(WINDOW);
|
|
72
|
+
return (win?.CSS ?? {
|
|
73
|
+
escape: (ident) => ident,
|
|
74
|
+
supports: () => false,
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
/** The `Window.devicePixelRatio`, or `null` on the server. */
|
|
80
|
+
const DEVICE_PIXEL_RATIO = new InjectionToken(ngDevMode ? '[DEVICE_PIXEL_RATIO]' : '', {
|
|
81
|
+
factory: () => inject(WINDOW)?.devicePixelRatio ?? null,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
/** The `Navigator.geolocation` API, or `null` on the server or when unsupported. */
|
|
85
|
+
const GEOLOCATION = new InjectionToken(ngDevMode ? '[GEOLOCATION]' : '', {
|
|
86
|
+
factory: () => inject(NAVIGATOR)?.geolocation ?? null,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
/** The `Window.history` object, or `null` on the server. */
|
|
90
|
+
const HISTORY = new InjectionToken(ngDevMode ? '[HISTORY]' : '', {
|
|
91
|
+
factory: () => inject(WINDOW)?.history ?? null,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
/** The `Window.indexedDB` factory, or `null` on the server or when unsupported. */
|
|
95
|
+
const INDEXED_DB = new InjectionToken(ngDevMode ? '[INDEXED_DB]' : '', {
|
|
96
|
+
factory: () => inject(WINDOW)?.indexedDB ?? null,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
/** The `Window.localStorage`, or `null` on the server. */
|
|
100
|
+
const LOCAL_STORAGE = new InjectionToken(ngDevMode ? '[LOCAL_STORAGE]' : '', {
|
|
101
|
+
factory: () => inject(WINDOW)?.localStorage ?? null,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
/** The `Window.location`, or `null` on the server. */
|
|
105
|
+
const BROWSER_LOCATION = new InjectionToken(ngDevMode ? '[BROWSER_LOCATION]' : '', {
|
|
106
|
+
factory: () => inject(WINDOW)?.location ?? null,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
/** A bound `Window.matchMedia`, or `null` when unavailable (SSR). Call as `matchMediaFn?.(query)`. */
|
|
110
|
+
const MATCH_MEDIA = new InjectionToken(ngDevMode ? '[MATCH_MEDIA]' : '', {
|
|
111
|
+
factory: () => {
|
|
112
|
+
const win = inject(WINDOW);
|
|
113
|
+
/* Angular's server DOM shim makes `document.defaultView` truthy but omits `matchMedia`, so the
|
|
114
|
+
method — not just the window — is what has to be feature-detected here. */
|
|
115
|
+
return typeof win?.matchMedia === 'function' ? (query) => win.matchMedia(query) : null;
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
/** The `Navigator.mediaDevices` API, or `null` on the server or when unsupported. */
|
|
120
|
+
const MEDIA_DEVICES = new InjectionToken(ngDevMode ? '[MEDIA_DEVICES]' : '', {
|
|
121
|
+
factory: () => inject(NAVIGATOR)?.mediaDevices ?? null,
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
/** The non-standard `Navigator.connection` API, or `null` on the server or when unsupported. */
|
|
125
|
+
const NETWORK_INFORMATION = new InjectionToken(ngDevMode ? '[NETWORK_INFORMATION]' : '', {
|
|
126
|
+
factory: () => inject(NAVIGATOR)?.connection ?? null,
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
/** Emits online/offline status and later transitions; completes immediately with no `Window`/`Navigator` (SSR). */
|
|
130
|
+
const ONLINE_STATUS = new InjectionToken(ngDevMode ? '[ONLINE_STATUS]' : '', {
|
|
131
|
+
factory: () => {
|
|
132
|
+
const win = inject(WINDOW);
|
|
133
|
+
const navigator = inject(NAVIGATOR);
|
|
134
|
+
if (!win || !navigator) {
|
|
135
|
+
return EMPTY;
|
|
136
|
+
}
|
|
137
|
+
return merge(of(navigator.onLine), fromEvent(win, 'online').pipe(map(() => true)), fromEvent(win, 'offline').pipe(map(() => false))).pipe(distinctUntilChanged(), shareReplay({
|
|
138
|
+
refCount: false,
|
|
139
|
+
bufferSize: 1,
|
|
140
|
+
}));
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
/** Emits whether the document is currently visible, and every later `visibilitychange`. */
|
|
145
|
+
const PAGE_VISIBILITY = new InjectionToken(ngDevMode ? '[PAGE_VISIBILITY]' : '', {
|
|
146
|
+
factory: () => {
|
|
147
|
+
const documentRef = inject(DOCUMENT);
|
|
148
|
+
return merge(of(documentRef.visibilityState !== 'hidden'), fromEvent(documentRef, 'visibilitychange').pipe(map(() => documentRef.visibilityState !== 'hidden'))).pipe(distinctUntilChanged(), shareReplay({
|
|
149
|
+
refCount: false,
|
|
150
|
+
bufferSize: 1,
|
|
151
|
+
}));
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
/** The `Window.performance` object, or `null` on the server. */
|
|
156
|
+
const PERFORMANCE = new InjectionToken(ngDevMode ? '[PERFORMANCE]' : '', {
|
|
157
|
+
factory: () => inject(WINDOW)?.performance ?? null,
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
/** The `Navigator.permissions` API, or `null` on the server or when unsupported. */
|
|
161
|
+
const PERMISSIONS = new InjectionToken(ngDevMode ? '[PERMISSIONS]' : '', {
|
|
162
|
+
factory: () => inject(NAVIGATOR)?.permissions ?? null,
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
/** The `Window.screen` object, or `null` on the server. */
|
|
166
|
+
const SCREEN = new InjectionToken(ngDevMode ? '[SCREEN]' : '', {
|
|
167
|
+
factory: () => inject(WINDOW)?.screen ?? null,
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
/** The `Window.sessionStorage`, or `null` on the server. */
|
|
171
|
+
const SESSION_STORAGE = new InjectionToken(ngDevMode ? '[SESSION_STORAGE]' : '', {
|
|
172
|
+
factory: () => inject(WINDOW)?.sessionStorage ?? null,
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
/** The `SpeechRecognition` constructor (standard or `webkit`-prefixed), or `null` on the server or when unsupported. */
|
|
176
|
+
const SPEECH_RECOGNITION = new InjectionToken(ngDevMode ? '[SPEECH_RECOGNITION]' : '', {
|
|
177
|
+
factory: () => {
|
|
178
|
+
const win = inject(WINDOW);
|
|
179
|
+
return win?.SpeechRecognition ?? win?.webkitSpeechRecognition ?? null;
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
/** The `Window.speechSynthesis` API, or `null` on the server or when unsupported. */
|
|
184
|
+
const SPEECH_SYNTHESIS = new InjectionToken(ngDevMode ? '[SPEECH_SYNTHESIS]' : '', {
|
|
185
|
+
factory: () => inject(WINDOW)?.speechSynthesis ?? null,
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
/** Emits every cross-tab `storage` event; completes immediately with no `Window` (SSR). */
|
|
189
|
+
const STORAGE_EVENT = new InjectionToken(ngDevMode ? '[STORAGE_EVENT]' : '', {
|
|
190
|
+
factory: () => {
|
|
191
|
+
const { defaultView } = inject(DOCUMENT);
|
|
192
|
+
if (!defaultView) {
|
|
193
|
+
return EMPTY;
|
|
194
|
+
}
|
|
195
|
+
return fromEvent(defaultView, 'storage').pipe(share());
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
/** The `Navigator.userAgent` string, or `null` on the server. */
|
|
200
|
+
const USER_AGENT = new InjectionToken(ngDevMode ? '[USER_AGENT]' : '', {
|
|
201
|
+
factory: () => inject(NAVIGATOR)?.userAgent ?? null,
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
/** The `Window.visualViewport`, or `null` on the server or when unsupported. */
|
|
205
|
+
const VISUAL_VIEWPORT = new InjectionToken(ngDevMode ? '[VISUAL_VIEWPORT]' : '', {
|
|
206
|
+
factory: () => inject(WINDOW)?.visualViewport ?? null,
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Generated bundle index. Do not edit.
|
|
211
|
+
*/
|
|
212
|
+
|
|
213
|
+
export { ANIMATION_FRAME, BROADCAST_CHANNEL, BROWSER_LOCATION, CACHES, CLIPBOARD, CRYPTO, CSS_REF, DEVICE_PIXEL_RATIO, GEOLOCATION, HISTORY, INDEXED_DB, LOCAL_STORAGE, MATCH_MEDIA, MEDIA_DEVICES, NAVIGATOR, NETWORK_INFORMATION, ONLINE_STATUS, PAGE_VISIBILITY, PERFORMANCE, PERMISSIONS, SCREEN, SESSION_STORAGE, SPEECH_RECOGNITION, SPEECH_SYNTHESIS, STORAGE_EVENT, USER_AGENT, VISUAL_VIEWPORT, WINDOW };
|
|
214
|
+
//# sourceMappingURL=invictus-test-browser-api.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invictus-test-browser-api.mjs","sources":["../../../../../packages/angular/browser-api/src/tokens/window.token.ts","../../../../../packages/angular/browser-api/src/tokens/animation-frame.token.ts","../../../../../packages/angular/browser-api/src/tokens/broadcast-channel.token.ts","../../../../../packages/angular/browser-api/src/tokens/caches.token.ts","../../../../../packages/angular/browser-api/src/tokens/navigator.token.ts","../../../../../packages/angular/browser-api/src/tokens/clipboard.token.ts","../../../../../packages/angular/browser-api/src/tokens/crypto.token.ts","../../../../../packages/angular/browser-api/src/tokens/css.token.ts","../../../../../packages/angular/browser-api/src/tokens/device-pixel-ratio.token.ts","../../../../../packages/angular/browser-api/src/tokens/geolocation.token.ts","../../../../../packages/angular/browser-api/src/tokens/history.token.ts","../../../../../packages/angular/browser-api/src/tokens/indexed-db.token.ts","../../../../../packages/angular/browser-api/src/tokens/local-storage.token.ts","../../../../../packages/angular/browser-api/src/tokens/location.token.ts","../../../../../packages/angular/browser-api/src/tokens/match-media.token.ts","../../../../../packages/angular/browser-api/src/tokens/media-devices.token.ts","../../../../../packages/angular/browser-api/src/tokens/network-information.token.ts","../../../../../packages/angular/browser-api/src/tokens/online-status.token.ts","../../../../../packages/angular/browser-api/src/tokens/page-visibility.token.ts","../../../../../packages/angular/browser-api/src/tokens/performance.token.ts","../../../../../packages/angular/browser-api/src/tokens/permissions.token.ts","../../../../../packages/angular/browser-api/src/tokens/screen.token.ts","../../../../../packages/angular/browser-api/src/tokens/session-storage.token.ts","../../../../../packages/angular/browser-api/src/tokens/speech-recognition.token.ts","../../../../../packages/angular/browser-api/src/tokens/speech-synthesis.token.ts","../../../../../packages/angular/browser-api/src/tokens/storage-event.token.ts","../../../../../packages/angular/browser-api/src/tokens/user-agent.token.ts","../../../../../packages/angular/browser-api/src/tokens/visual-viewport.token.ts","../../../../../packages/angular/browser-api/src/invictus-test-browser-api.ts"],"sourcesContent":["import { DOCUMENT } from '@angular/common';\nimport { inject, InjectionToken } from '@angular/core';\n\n/** The global `Window`, resolved via `Document.defaultView`, or `null` during SSR. */\nexport const WINDOW = new InjectionToken<null | Window>(ngDevMode ? '[WINDOW]' : '', {\n factory: (): null | Window => inject(DOCUMENT).defaultView,\n});\n","import { inject, InjectionToken } from '@angular/core';\nimport { Observable, share } from 'rxjs';\nimport { WINDOW } from './window.token';\n\n/** Emits the frame timestamp on every `requestAnimationFrame` tick; completes immediately with no `Window` (SSR). */\nexport const ANIMATION_FRAME = new InjectionToken<Observable<number>>(ngDevMode ? '[ANIMATION_FRAME]' : '', {\n factory: (): Observable<number> => {\n const win = inject(WINDOW);\n\n return new Observable<number>(subscriber => {\n // Same shim gap as MATCH_MEDIA: `defaultView` is truthy on the server but has no rAF.\n if (!win || typeof win.requestAnimationFrame !== 'function') {\n subscriber.complete();\n\n return undefined;\n }\n\n let id = NaN;\n\n const callback = (timestamp: number): void => {\n subscriber.next(timestamp);\n\n if (!subscriber.closed) {\n id = win.requestAnimationFrame(callback);\n }\n };\n\n id = win.requestAnimationFrame(callback);\n\n return () => {\n win.cancelAnimationFrame(id);\n };\n }).pipe(share());\n },\n});\n","import { DOCUMENT } from '@angular/common';\nimport { inject, InjectionToken } from '@angular/core';\n\nconst CHANNEL_NAME = 'invictus-persistence';\n\n/** A `BroadcastChannel` scoped to Invictus persistence, or `null` on the server or when unsupported. */\nexport const BROADCAST_CHANNEL = new InjectionToken<BroadcastChannel | null>(ngDevMode ? '[BROADCAST_CHANNEL]' : '', {\n factory: (): BroadcastChannel | null => {\n const { defaultView } = inject(DOCUMENT);\n\n if (!defaultView?.BroadcastChannel) {\n return null;\n }\n\n return new defaultView.BroadcastChannel(CHANNEL_NAME);\n },\n});\n","import { inject, InjectionToken } from '@angular/core';\nimport { WINDOW } from './window.token';\n\n/** The `Window.caches` `CacheStorage`, or `null` on the server or when unsupported. */\nexport const CACHES = new InjectionToken<CacheStorage | null>(ngDevMode ? '[CACHES]' : '', {\n factory: (): CacheStorage | null => inject(WINDOW)?.caches ?? null,\n});\n","import { inject, InjectionToken } from '@angular/core';\nimport { WINDOW } from './window.token';\n\n/** The `Window.navigator` object, or `null` on the server. */\nexport const NAVIGATOR = new InjectionToken<Navigator | null>(ngDevMode ? '[NAVIGATOR]' : '', {\n factory: (): Navigator | null => inject(WINDOW)?.navigator ?? null,\n});\n","import { inject, InjectionToken } from '@angular/core';\nimport { NAVIGATOR } from './navigator.token';\n\n/** The `Navigator.clipboard` API, or `null` on the server or when unsupported. */\nexport const CLIPBOARD = new InjectionToken<Clipboard | null>(ngDevMode ? '[CLIPBOARD]' : '', {\n factory: (): Clipboard | null => inject(NAVIGATOR)?.clipboard ?? null,\n});\n","import { inject, InjectionToken } from '@angular/core';\nimport { WINDOW } from './window.token';\n\n/** The `Window.crypto` object, or `null` on the server. */\nexport const CRYPTO = new InjectionToken<Crypto | null>(ngDevMode ? '[CRYPTO]' : '', {\n factory: (): Crypto | null => inject(WINDOW)?.crypto ?? null,\n});\n","import { inject, InjectionToken } from '@angular/core';\nimport type { CSSRef } from '../domain/interfaces/css-ref.interface';\nimport { WINDOW } from './window.token';\n\ndeclare global {\n interface Window {\n readonly CSS?: CSSRef;\n }\n}\n\n/** The `CSS` global, or an inert stub (identity `escape`, `supports` always `false`) when unavailable — never `null`. */\nexport const CSS_REF = new InjectionToken<CSSRef>(ngDevMode ? '[CSS_REF]' : '', {\n factory: (): CSSRef => {\n const win = inject(WINDOW);\n\n return (\n win?.CSS ?? {\n escape: (ident: string) => ident,\n supports: () => false,\n }\n );\n },\n});\n","import { inject, InjectionToken } from '@angular/core';\nimport { WINDOW } from './window.token';\n\n/** The `Window.devicePixelRatio`, or `null` on the server. */\nexport const DEVICE_PIXEL_RATIO = new InjectionToken<null | number>(ngDevMode ? '[DEVICE_PIXEL_RATIO]' : '', {\n factory: (): null | number => inject(WINDOW)?.devicePixelRatio ?? null,\n});\n","import { inject, InjectionToken } from '@angular/core';\nimport { NAVIGATOR } from './navigator.token';\n\n/** The `Navigator.geolocation` API, or `null` on the server or when unsupported. */\nexport const GEOLOCATION = new InjectionToken<Geolocation | null>(ngDevMode ? '[GEOLOCATION]' : '', {\n factory: (): Geolocation | null => inject(NAVIGATOR)?.geolocation ?? null,\n});\n","import { inject, InjectionToken } from '@angular/core';\nimport { WINDOW } from './window.token';\n\n/** The `Window.history` object, or `null` on the server. */\nexport const HISTORY = new InjectionToken<History | null>(ngDevMode ? '[HISTORY]' : '', {\n factory: (): History | null => inject(WINDOW)?.history ?? null,\n});\n","import { inject, InjectionToken } from '@angular/core';\nimport { WINDOW } from './window.token';\n\n/** The `Window.indexedDB` factory, or `null` on the server or when unsupported. */\nexport const INDEXED_DB = new InjectionToken<IDBFactory | null>(ngDevMode ? '[INDEXED_DB]' : '', {\n factory: (): IDBFactory | null => inject(WINDOW)?.indexedDB ?? null,\n});\n","import { inject, InjectionToken } from '@angular/core';\nimport { WINDOW } from './window.token';\n\n/** The `Window.localStorage`, or `null` on the server. */\nexport const LOCAL_STORAGE = new InjectionToken<null | Storage>(ngDevMode ? '[LOCAL_STORAGE]' : '', {\n factory: (): null | Storage => inject(WINDOW)?.localStorage ?? null,\n});\n","import { inject, InjectionToken } from '@angular/core';\nimport { WINDOW } from './window.token';\n\n/** The `Window.location`, or `null` on the server. */\nexport const BROWSER_LOCATION = new InjectionToken<Location | null>(ngDevMode ? '[BROWSER_LOCATION]' : '', {\n factory: (): Location | null => inject(WINDOW)?.location ?? null,\n});\n","import { inject, InjectionToken } from '@angular/core';\nimport { WINDOW } from './window.token';\n\n/** A bound `Window.matchMedia`, or `null` when unavailable (SSR). Call as `matchMediaFn?.(query)`. */\nexport const MATCH_MEDIA = new InjectionToken<((query: string) => MediaQueryList) | null>(ngDevMode ? '[MATCH_MEDIA]' : '', {\n factory: (): ((query: string) => MediaQueryList) | null => {\n const win = inject(WINDOW);\n\n /* Angular's server DOM shim makes `document.defaultView` truthy but omits `matchMedia`, so the\n method — not just the window — is what has to be feature-detected here. */\n return typeof win?.matchMedia === 'function' ? (query: string): MediaQueryList => win.matchMedia(query) : null;\n },\n});\n","import { inject, InjectionToken } from '@angular/core';\nimport { NAVIGATOR } from './navigator.token';\n\n/** The `Navigator.mediaDevices` API, or `null` on the server or when unsupported. */\nexport const MEDIA_DEVICES = new InjectionToken<MediaDevices | null>(ngDevMode ? '[MEDIA_DEVICES]' : '', {\n factory: (): MediaDevices | null => inject(NAVIGATOR)?.mediaDevices ?? null,\n});\n","import { inject, InjectionToken } from '@angular/core';\nimport type { NetworkInformation } from '../domain/interfaces/network-information.interface';\nimport { NAVIGATOR } from './navigator.token';\n\ndeclare global {\n interface Navigator {\n readonly connection?: NetworkInformation;\n }\n}\n\n/** The non-standard `Navigator.connection` API, or `null` on the server or when unsupported. */\nexport const NETWORK_INFORMATION = new InjectionToken<NetworkInformation | null>(ngDevMode ? '[NETWORK_INFORMATION]' : '', {\n factory: (): NetworkInformation | null => inject(NAVIGATOR)?.connection ?? null,\n});\n","import { inject, InjectionToken } from '@angular/core';\nimport type { Observable } from 'rxjs';\nimport { distinctUntilChanged, EMPTY, fromEvent, merge, of, shareReplay } from 'rxjs';\nimport { map } from 'rxjs/operators';\nimport { NAVIGATOR } from './navigator.token';\nimport { WINDOW } from './window.token';\n\n/** Emits online/offline status and later transitions; completes immediately with no `Window`/`Navigator` (SSR). */\nexport const ONLINE_STATUS = new InjectionToken<Observable<boolean>>(ngDevMode ? '[ONLINE_STATUS]' : '', {\n factory: (): Observable<boolean> => {\n const win = inject(WINDOW);\n const navigator = inject(NAVIGATOR);\n\n if (!win || !navigator) {\n return EMPTY;\n }\n\n return merge(\n of(navigator.onLine),\n fromEvent(win, 'online').pipe(map(() => true)),\n fromEvent(win, 'offline').pipe(map(() => false)),\n ).pipe(\n distinctUntilChanged(),\n shareReplay({\n refCount: false,\n bufferSize: 1,\n }),\n );\n },\n});\n","import { DOCUMENT } from '@angular/common';\nimport { inject, InjectionToken } from '@angular/core';\nimport type { Observable } from 'rxjs';\nimport { distinctUntilChanged, fromEvent, merge, of, shareReplay } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\n/** Emits whether the document is currently visible, and every later `visibilitychange`. */\nexport const PAGE_VISIBILITY = new InjectionToken<Observable<boolean>>(ngDevMode ? '[PAGE_VISIBILITY]' : '', {\n factory: (): Observable<boolean> => {\n const documentRef = inject(DOCUMENT);\n\n return merge(\n of(documentRef.visibilityState !== 'hidden'),\n fromEvent(documentRef, 'visibilitychange').pipe(map(() => documentRef.visibilityState !== 'hidden')),\n ).pipe(\n distinctUntilChanged(),\n shareReplay({\n refCount: false,\n bufferSize: 1,\n }),\n );\n },\n});\n","import { inject, InjectionToken } from '@angular/core';\nimport { WINDOW } from './window.token';\n\n/** The `Window.performance` object, or `null` on the server. */\nexport const PERFORMANCE = new InjectionToken<null | Performance>(ngDevMode ? '[PERFORMANCE]' : '', {\n factory: (): null | Performance => inject(WINDOW)?.performance ?? null,\n});\n","import { inject, InjectionToken } from '@angular/core';\nimport { NAVIGATOR } from './navigator.token';\n\n/** The `Navigator.permissions` API, or `null` on the server or when unsupported. */\nexport const PERMISSIONS = new InjectionToken<null | Permissions>(ngDevMode ? '[PERMISSIONS]' : '', {\n factory: (): null | Permissions => inject(NAVIGATOR)?.permissions ?? null,\n});\n","import { inject, InjectionToken } from '@angular/core';\nimport { WINDOW } from './window.token';\n\n/** The `Window.screen` object, or `null` on the server. */\nexport const SCREEN = new InjectionToken<null | Screen>(ngDevMode ? '[SCREEN]' : '', {\n factory: (): null | Screen => inject(WINDOW)?.screen ?? null,\n});\n","import { inject, InjectionToken } from '@angular/core';\nimport { WINDOW } from './window.token';\n\n/** The `Window.sessionStorage`, or `null` on the server. */\nexport const SESSION_STORAGE = new InjectionToken<null | Storage>(ngDevMode ? '[SESSION_STORAGE]' : '', {\n factory: (): null | Storage => inject(WINDOW)?.sessionStorage ?? null,\n});\n","import { inject, InjectionToken } from '@angular/core';\nimport type { SpeechRecognitionCtor } from '../domain/types/speech-recognition-ctor.type';\nimport { WINDOW } from './window.token';\n\ndeclare global {\n interface Window {\n readonly SpeechRecognition?: SpeechRecognitionCtor;\n readonly webkitSpeechRecognition?: SpeechRecognitionCtor;\n }\n}\n\n/** The `SpeechRecognition` constructor (standard or `webkit`-prefixed), or `null` on the server or when unsupported. */\nexport const SPEECH_RECOGNITION = new InjectionToken<null | SpeechRecognitionCtor>(ngDevMode ? '[SPEECH_RECOGNITION]' : '', {\n factory: (): null | SpeechRecognitionCtor => {\n const win = inject(WINDOW);\n\n return win?.SpeechRecognition ?? win?.webkitSpeechRecognition ?? null;\n },\n});\n","import { inject, InjectionToken } from '@angular/core';\nimport { WINDOW } from './window.token';\n\n/** The `Window.speechSynthesis` API, or `null` on the server or when unsupported. */\nexport const SPEECH_SYNTHESIS = new InjectionToken<null | SpeechSynthesis>(ngDevMode ? '[SPEECH_SYNTHESIS]' : '', {\n factory: (): null | SpeechSynthesis => inject(WINDOW)?.speechSynthesis ?? null,\n});\n","import { DOCUMENT } from '@angular/common';\nimport { inject, InjectionToken } from '@angular/core';\nimport type { Observable } from 'rxjs';\nimport { EMPTY, fromEvent, share } from 'rxjs';\n\n/** Emits every cross-tab `storage` event; completes immediately with no `Window` (SSR). */\nexport const STORAGE_EVENT = new InjectionToken<Observable<StorageEvent>>(ngDevMode ? '[STORAGE_EVENT]' : '', {\n factory: (): Observable<StorageEvent> => {\n const { defaultView } = inject(DOCUMENT);\n\n if (!defaultView) {\n return EMPTY;\n }\n\n return fromEvent<StorageEvent>(defaultView, 'storage').pipe(share());\n },\n});\n","import { inject, InjectionToken } from '@angular/core';\nimport { NAVIGATOR } from './navigator.token';\n\n/** The `Navigator.userAgent` string, or `null` on the server. */\nexport const USER_AGENT = new InjectionToken<null | string>(ngDevMode ? '[USER_AGENT]' : '', {\n factory: (): null | string => inject(NAVIGATOR)?.userAgent ?? null,\n});\n","import { inject, InjectionToken } from '@angular/core';\nimport { WINDOW } from './window.token';\n\n/** The `Window.visualViewport`, or `null` on the server or when unsupported. */\nexport const VISUAL_VIEWPORT = new InjectionToken<null | VisualViewport>(ngDevMode ? '[VISUAL_VIEWPORT]' : '', {\n factory: (): null | VisualViewport => inject(WINDOW)?.visualViewport ?? null,\n});\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAGA;AACO,MAAM,MAAM,GAAG,IAAI,cAAc,CAAgB,SAAS,GAAG,UAAU,GAAG,EAAE,EAAE;IACnF,OAAO,EAAE,MAAqB,MAAM,CAAC,QAAQ,CAAC,CAAC,WAAW;AAC3D,CAAA;;ACFD;AACO,MAAM,eAAe,GAAG,IAAI,cAAc,CAAqB,SAAS,GAAG,mBAAmB,GAAG,EAAE,EAAE;IAC1G,OAAO,EAAE,MAAyB;AAChC,QAAA,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC;AAE1B,QAAA,OAAO,IAAI,UAAU,CAAS,UAAU,IAAG;;YAEzC,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,CAAC,qBAAqB,KAAK,UAAU,EAAE;gBAC3D,UAAU,CAAC,QAAQ,EA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,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC;QAExC,IAAI,CAAC,WAAW,EAAE;AAChB,YAAA,OAAO,KAAK;QACd;AAEA,QAAA,OAAO,SAAS,CAAe,WAAW,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IACtE,CAAC;AACF,CAAA;;ACbD;AACO,MAAM,UAAU,GAAG,IAAI,cAAc,CAAgB,SAAS,GAAG,cAAc,GAAG,EAAE,EAAE;IAC3F,OAAO,EAAE,MAAqB,MAAM,CAAC,SAAS,CAAC,EAAE,SAAS,IAAI,IAAI;AACnE,CAAA;;ACHD;AACO,MAAM,eAAe,GAAG,IAAI,cAAc,CAAwB,SAAS,GAAG,mBAAmB,GAAG,EAAE,EAAE;IAC7G,OAAO,EAAE,MAA6B,MAAM,CAAC,MAAM,CAAC,EAAE,cAAc,IAAI,IAAI;AAC7E,CAAA;;ACND;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@invictus-test/browser-api",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.2-dev.6",
|
|
4
|
+
"description": "SSR-safe Angular injection tokens for browser APIs, with an ng-add schematic.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/VelenTek/invictus.git",
|
|
9
|
+
"directory": "packages/angular/browser-api"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public",
|
|
13
|
+
"registry": "https://registry.npmjs.org/"
|
|
14
|
+
},
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"@angular/common": "^22.0.0",
|
|
17
|
+
"@angular/core": "^22.0.0",
|
|
18
|
+
"rxjs": "^7.4.0"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"semver": "^7.7.0",
|
|
22
|
+
"tslib": "^2.3.0"
|
|
23
|
+
},
|
|
24
|
+
"schematics": "./schematics/collection.json",
|
|
25
|
+
"ng-add": {
|
|
26
|
+
"save": "dependencies"
|
|
27
|
+
},
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"module": "fesm2022/invictus-test-browser-api.mjs",
|
|
30
|
+
"typings": "types/invictus-test-browser-api.d.ts",
|
|
31
|
+
"exports": {
|
|
32
|
+
"./package.json": {
|
|
33
|
+
"default": "./package.json"
|
|
34
|
+
},
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./types/invictus-test-browser-api.d.ts",
|
|
37
|
+
"default": "./fesm2022/invictus-test-browser-api.mjs"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"type": "module"
|
|
41
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../../../node_modules/@angular-devkit/schematics/collection-schema.json",
|
|
3
|
+
"schematics": {
|
|
4
|
+
"ng-add": {
|
|
5
|
+
"description": "Verifies that the Angular version is supported by Browser API.",
|
|
6
|
+
"factory": "./ng-add/index#ngAdd",
|
|
7
|
+
"schema": "./ng-add/schema.json"
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ngAdd = ngAdd;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const semver_1 = require("semver");
|
|
7
|
+
const ANGULAR_PEERS = ['@angular/core', '@angular/common'];
|
|
8
|
+
function ngAdd() {
|
|
9
|
+
return (tree, context) => {
|
|
10
|
+
const own = readOwnManifest();
|
|
11
|
+
const packageName = own.name ?? '@invictus-test/browser-api';
|
|
12
|
+
const problems = findProblems(tree, own, packageName);
|
|
13
|
+
if (problems.length > 0) {
|
|
14
|
+
throw new Error(describeFailure(packageName, problems));
|
|
15
|
+
}
|
|
16
|
+
context.logger.info(`${packageName} is ready: no providers, modules or styles to configure.`);
|
|
17
|
+
context.logger.info(`Import the tokens where you need them: import { WINDOW } from '${packageName}';`);
|
|
18
|
+
return tree;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function declaredVersion(workspace, dependency) {
|
|
22
|
+
const { dependencies = {}, devDependencies = {} } = workspace ?? {};
|
|
23
|
+
return lowestVersion(dependencies[dependency] ?? devDependencies[dependency]);
|
|
24
|
+
}
|
|
25
|
+
function describeFailure(packageName, problems) {
|
|
26
|
+
return [
|
|
27
|
+
`${packageName} cannot be used with this workspace:`,
|
|
28
|
+
...problems.map(problem => ` - ${problem}`),
|
|
29
|
+
`The package stays installed. Upgrade Angular to a supported version, or remove it with "npm uninstall ${packageName}".`,
|
|
30
|
+
].join('\n');
|
|
31
|
+
}
|
|
32
|
+
/** Installed version first (exact), then the lowest version allowed by the workspace `package.json`. */
|
|
33
|
+
function detectVersion(tree, dependency, workspace) {
|
|
34
|
+
const installed = readManifest(tree, `node_modules/${dependency}/package.json`)?.version;
|
|
35
|
+
return installed !== undefined && (0, semver_1.coerce)(installed) !== null ? installed : declaredVersion(workspace, dependency);
|
|
36
|
+
}
|
|
37
|
+
function findProblems(tree, own, packageName) {
|
|
38
|
+
const workspace = readManifest(tree, 'package.json');
|
|
39
|
+
return ANGULAR_PEERS.flatMap(dependency => {
|
|
40
|
+
const range = own.peerDependencies?.[dependency];
|
|
41
|
+
if (range === undefined) {
|
|
42
|
+
throw new Error(`${packageName} does not declare a peer range for ${dependency}.`);
|
|
43
|
+
}
|
|
44
|
+
const version = detectVersion(tree, dependency, workspace);
|
|
45
|
+
if (version === null) {
|
|
46
|
+
return [`${dependency} was not found. Install Angular (${range}) in this workspace first.`];
|
|
47
|
+
}
|
|
48
|
+
return (0, semver_1.satisfies)(version, range, { includePrerelease: true })
|
|
49
|
+
? []
|
|
50
|
+
: [`${dependency} ${version} is not supported; ${packageName} requires ${range}.`];
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function lowestVersion(declared) {
|
|
54
|
+
const range = declared === undefined ? null : (0, semver_1.validRange)(declared);
|
|
55
|
+
return range === null ? null : ((0, semver_1.minVersion)(range)?.version ?? null);
|
|
56
|
+
}
|
|
57
|
+
function parseManifest(source) {
|
|
58
|
+
const manifest = JSON.parse(source);
|
|
59
|
+
return typeof manifest === 'object' && manifest !== null ? manifest : {};
|
|
60
|
+
}
|
|
61
|
+
function readManifest(tree, path) {
|
|
62
|
+
const buffer = tree.read(path);
|
|
63
|
+
return buffer === null ? null : parseManifest(buffer.toString('utf8'));
|
|
64
|
+
}
|
|
65
|
+
/** The package's own manifest is the single source of the supported Angular range. */
|
|
66
|
+
function readOwnManifest() {
|
|
67
|
+
return parseManifest((0, node_fs_1.readFileSync)((0, node_path_1.join)(__dirname, '..', '..', 'package.json'), 'utf8'));
|
|
68
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "InvictusBrowserApiNgAdd",
|
|
4
|
+
"title": "Browser API ng-add",
|
|
5
|
+
"description": "Browser API needs no providers, modules or styles, so ng add takes no options.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {},
|
|
8
|
+
"additionalProperties": false
|
|
9
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
|
|
4
|
+
/** The subset of the global `CSS` object this package depends on. */
|
|
5
|
+
interface CSSRef {
|
|
6
|
+
escape(ident: string): string;
|
|
7
|
+
supports(property: string, value?: string): boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** The non-standard Network Information API shape exposed via `Navigator.connection`. */
|
|
11
|
+
interface NetworkInformation {
|
|
12
|
+
readonly downlink: number;
|
|
13
|
+
readonly effectiveType: '2g' | '3g' | '4g' | 'slow-2g';
|
|
14
|
+
readonly rtt: number;
|
|
15
|
+
readonly saveData: boolean;
|
|
16
|
+
readonly type?: 'bluetooth' | 'cellular' | 'ethernet' | 'none' | 'other' | 'unknown' | 'wifi' | 'wimax';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Constructor shape for the experimental `SpeechRecognition` API, not yet part of `lib.dom.d.ts`. */
|
|
20
|
+
type SpeechRecognitionCtor = new () => unknown;
|
|
21
|
+
|
|
22
|
+
/** Emits the frame timestamp on every `requestAnimationFrame` tick; completes immediately with no `Window` (SSR). */
|
|
23
|
+
declare const ANIMATION_FRAME: InjectionToken<Observable<number>>;
|
|
24
|
+
|
|
25
|
+
/** A `BroadcastChannel` scoped to Invictus persistence, or `null` on the server or when unsupported. */
|
|
26
|
+
declare const BROADCAST_CHANNEL: InjectionToken<BroadcastChannel | null>;
|
|
27
|
+
|
|
28
|
+
/** The `Window.caches` `CacheStorage`, or `null` on the server or when unsupported. */
|
|
29
|
+
declare const CACHES: InjectionToken<CacheStorage | null>;
|
|
30
|
+
|
|
31
|
+
/** The `Navigator.clipboard` API, or `null` on the server or when unsupported. */
|
|
32
|
+
declare const CLIPBOARD: InjectionToken<Clipboard | null>;
|
|
33
|
+
|
|
34
|
+
/** The `Window.crypto` object, or `null` on the server. */
|
|
35
|
+
declare const CRYPTO: InjectionToken<Crypto | null>;
|
|
36
|
+
|
|
37
|
+
declare global {
|
|
38
|
+
interface Window {
|
|
39
|
+
readonly CSS?: CSSRef;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** The `CSS` global, or an inert stub (identity `escape`, `supports` always `false`) when unavailable — never `null`. */
|
|
43
|
+
declare const CSS_REF: InjectionToken<CSSRef>;
|
|
44
|
+
|
|
45
|
+
/** The `Window.devicePixelRatio`, or `null` on the server. */
|
|
46
|
+
declare const DEVICE_PIXEL_RATIO: InjectionToken<number | null>;
|
|
47
|
+
|
|
48
|
+
/** The `Navigator.geolocation` API, or `null` on the server or when unsupported. */
|
|
49
|
+
declare const GEOLOCATION: InjectionToken<Geolocation | null>;
|
|
50
|
+
|
|
51
|
+
/** The `Window.history` object, or `null` on the server. */
|
|
52
|
+
declare const HISTORY: InjectionToken<History | null>;
|
|
53
|
+
|
|
54
|
+
/** The `Window.indexedDB` factory, or `null` on the server or when unsupported. */
|
|
55
|
+
declare const INDEXED_DB: InjectionToken<IDBFactory | null>;
|
|
56
|
+
|
|
57
|
+
/** The `Window.localStorage`, or `null` on the server. */
|
|
58
|
+
declare const LOCAL_STORAGE: InjectionToken<Storage | null>;
|
|
59
|
+
|
|
60
|
+
/** The `Window.location`, or `null` on the server. */
|
|
61
|
+
declare const BROWSER_LOCATION: InjectionToken<Location | null>;
|
|
62
|
+
|
|
63
|
+
/** A bound `Window.matchMedia`, or `null` when unavailable (SSR). Call as `matchMediaFn?.(query)`. */
|
|
64
|
+
declare const MATCH_MEDIA: InjectionToken<((query: string) => MediaQueryList) | null>;
|
|
65
|
+
|
|
66
|
+
/** The `Navigator.mediaDevices` API, or `null` on the server or when unsupported. */
|
|
67
|
+
declare const MEDIA_DEVICES: InjectionToken<MediaDevices | null>;
|
|
68
|
+
|
|
69
|
+
/** The `Window.navigator` object, or `null` on the server. */
|
|
70
|
+
declare const NAVIGATOR: InjectionToken<Navigator | null>;
|
|
71
|
+
|
|
72
|
+
declare global {
|
|
73
|
+
interface Navigator {
|
|
74
|
+
readonly connection?: NetworkInformation;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/** The non-standard `Navigator.connection` API, or `null` on the server or when unsupported. */
|
|
78
|
+
declare const NETWORK_INFORMATION: InjectionToken<NetworkInformation | null>;
|
|
79
|
+
|
|
80
|
+
/** Emits online/offline status and later transitions; completes immediately with no `Window`/`Navigator` (SSR). */
|
|
81
|
+
declare const ONLINE_STATUS: InjectionToken<Observable<boolean>>;
|
|
82
|
+
|
|
83
|
+
/** Emits whether the document is currently visible, and every later `visibilitychange`. */
|
|
84
|
+
declare const PAGE_VISIBILITY: InjectionToken<Observable<boolean>>;
|
|
85
|
+
|
|
86
|
+
/** The `Window.performance` object, or `null` on the server. */
|
|
87
|
+
declare const PERFORMANCE: InjectionToken<Performance | null>;
|
|
88
|
+
|
|
89
|
+
/** The `Navigator.permissions` API, or `null` on the server or when unsupported. */
|
|
90
|
+
declare const PERMISSIONS: InjectionToken<Permissions | null>;
|
|
91
|
+
|
|
92
|
+
/** The `Window.screen` object, or `null` on the server. */
|
|
93
|
+
declare const SCREEN: InjectionToken<Screen | null>;
|
|
94
|
+
|
|
95
|
+
/** The `Window.sessionStorage`, or `null` on the server. */
|
|
96
|
+
declare const SESSION_STORAGE: InjectionToken<Storage | null>;
|
|
97
|
+
|
|
98
|
+
declare global {
|
|
99
|
+
interface Window {
|
|
100
|
+
readonly SpeechRecognition?: SpeechRecognitionCtor;
|
|
101
|
+
readonly webkitSpeechRecognition?: SpeechRecognitionCtor;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/** The `SpeechRecognition` constructor (standard or `webkit`-prefixed), or `null` on the server or when unsupported. */
|
|
105
|
+
declare const SPEECH_RECOGNITION: InjectionToken<SpeechRecognitionCtor | null>;
|
|
106
|
+
|
|
107
|
+
/** The `Window.speechSynthesis` API, or `null` on the server or when unsupported. */
|
|
108
|
+
declare const SPEECH_SYNTHESIS: InjectionToken<SpeechSynthesis | null>;
|
|
109
|
+
|
|
110
|
+
/** Emits every cross-tab `storage` event; completes immediately with no `Window` (SSR). */
|
|
111
|
+
declare const STORAGE_EVENT: InjectionToken<Observable<StorageEvent>>;
|
|
112
|
+
|
|
113
|
+
/** The `Navigator.userAgent` string, or `null` on the server. */
|
|
114
|
+
declare const USER_AGENT: InjectionToken<string | null>;
|
|
115
|
+
|
|
116
|
+
/** The `Window.visualViewport`, or `null` on the server or when unsupported. */
|
|
117
|
+
declare const VISUAL_VIEWPORT: InjectionToken<VisualViewport | null>;
|
|
118
|
+
|
|
119
|
+
/** The global `Window`, resolved via `Document.defaultView`, or `null` during SSR. */
|
|
120
|
+
declare const WINDOW: InjectionToken<Window | null>;
|
|
121
|
+
|
|
122
|
+
export { ANIMATION_FRAME, BROADCAST_CHANNEL, BROWSER_LOCATION, CACHES, CLIPBOARD, CRYPTO, CSS_REF, DEVICE_PIXEL_RATIO, GEOLOCATION, HISTORY, INDEXED_DB, LOCAL_STORAGE, MATCH_MEDIA, MEDIA_DEVICES, NAVIGATOR, NETWORK_INFORMATION, ONLINE_STATUS, PAGE_VISIBILITY, PERFORMANCE, PERMISSIONS, SCREEN, SESSION_STORAGE, SPEECH_RECOGNITION, SPEECH_SYNTHESIS, STORAGE_EVENT, USER_AGENT, VISUAL_VIEWPORT, WINDOW };
|
|
123
|
+
export type { CSSRef, NetworkInformation, SpeechRecognitionCtor };
|