@@ -35,33 +35,20 @@ import '@ng-web-apis/universal/mocks';
3535## Tokens
3636
3737You 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})
4649export 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
6754When 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