Skip to content
This repository was archived by the owner on May 29, 2023. It is now read-only.

Commit 2f064fb

Browse files
authored
feat(tokens): sync with new tokens from common package (#15)
1 parent ea56681 commit 2f064fb

File tree

10 files changed

+109
-19815
lines changed

10 files changed

+109
-19815
lines changed

README.md

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -35,33 +35,20 @@ import '@ng-web-apis/universal/mocks';
3535
## Tokens
3636

3737
You can provide tokens from this package into your `app.server.module.ts`
38-
to have type safe mocks for global objects on server side:
38+
to have type safe mocks for global objects on server side with `UniversalModule`:
3939

4040
```ts
4141
@NgModule({
42-
imports: [AppBrowserModule, ServerModule],
42+
imports: [
43+
AppBrowserModule,
44+
ServerModule,
45+
UniversalModule, // <-- add this
46+
],
4347
bootstrap: [AppComponent],
44-
providers: [UNIVERSAL_WINDOW],
4548
})
4649
export class AppServerModule {}
4750
```
4851

49-
- `WINDOW` — add `UNIVERSAL_WINDOW` to provide type-safe mock object, effectively mocking all `navigator` related entities
50-
- `NAVIGATOR` — add `UNIVERSAL_NAVIGATOR` to provide type-safe mock object, effectively mocking all `navigator` related entities
51-
- `NETWORK_INFORMATION` — no need to do anything
52-
- `USER_AGENT` — see _special cases_ below
53-
- `PERFORMANCE` — add `UNIVERSAL_PERFORMANCE` to use Node.js `Performance` class on Server Side
54-
- `ANIMATION_FRAME` — add `UNIVERSAL_ANIMATION_FRAME` to fallback to `NEVER` in SSR environment
55-
- `CSS` — no need to do anything, mock object is already injected as if you were using Internet Explorer
56-
- `LOCATION` — see _special cases_ below
57-
- `LOCAL_STORAGE` — add `UNIVERSAL_LOCAL_STORAGE` for a `Map` based mock for `window.localStorage`
58-
- `SESSION_STORAGE` — add `UNIVERSAL_SESSION_STORAGE` for a `Map` based mock for `window.sessionStorage`
59-
- `SPEECH_RECOGNITION` — no need to do anything
60-
- `SPEECH_SYNTHESIS` — add `UNIVERSAL_SPEECH_SYNTHESIS` for a type-safe mock for `window.speechSynthesis`
61-
- `PAGE_VISIBILITY` — no need to do anything
62-
63-
You can also provide all the tokens at once with `UNIVERSAL_PROVIDERS` constant
64-
6552
## Special cases
6653

6754
When you use plain SSR without prerender you can retrieve some of the information
@@ -79,14 +66,3 @@ app.get('/**/*', (req: Request, res: Response) => {
7966
});
8067
});
8168
```
82-
83-
**_app.server.module.ts_**
84-
85-
```typescript
86-
@NgModule({
87-
imports: [AppModule, ServerModule],
88-
bootstrap: [AppComponent],
89-
providers: [UNIVERSAL_NAVIGATOR, UNIVERSAL_USER_AGENT, UNIVERSAL_LOCATION],
90-
})
91-
export class ServerAppModule {}
92-
```

0 commit comments

Comments
 (0)