@angular/platform-server 13.0.0-next.8 → 13.0.0-rc.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/{esm2015/index.js → esm2020/index.mjs} +0 -0
- package/{esm2015/init/index.js → esm2020/init/index.mjs} +0 -0
- package/{esm2015/init/init.js → esm2020/init/init.mjs} +0 -0
- package/{esm2015/init/public_api.js → esm2020/init/public_api.mjs} +0 -0
- package/{esm2015/init/src/init.js → esm2020/init/src/init.mjs} +0 -0
- package/{esm2015/init/src/shims.js → esm2020/init/src/shims.mjs} +0 -0
- package/esm2020/platform-server.mjs +5 -0
- package/{esm2015/public_api.js → esm2020/public_api.mjs} +0 -0
- package/esm2020/src/domino_adapter.mjs +90 -0
- package/esm2020/src/http.mjs +125 -0
- package/esm2020/src/location.mjs +125 -0
- package/{esm2015/src/platform-server.js → esm2020/src/platform-server.mjs} +0 -0
- package/esm2020/src/platform_state.mjs +42 -0
- package/{esm2015/src/private_export.js → esm2020/src/private_export.mjs} +0 -0
- package/esm2020/src/server.mjs +104 -0
- package/esm2020/src/server_events.mjs +39 -0
- package/esm2020/src/server_renderer.mjs +273 -0
- package/esm2020/src/styles_host.mjs +51 -0
- package/{esm2015/src/tokens.js → esm2020/src/tokens.mjs} +0 -0
- package/esm2020/src/transfer_state.mjs +53 -0
- package/esm2020/src/utils.mjs +99 -0
- package/{esm2015/src/version.js → esm2020/src/version.mjs} +1 -1
- package/{esm2015/testing/index.js → esm2020/testing/index.mjs} +0 -0
- package/{esm2015/testing/public_api.js → esm2020/testing/public_api.mjs} +0 -0
- package/esm2020/testing/src/server.mjs +37 -0
- package/{esm2015/testing/src/testing.js → esm2020/testing/src/testing.mjs} +0 -0
- package/{esm2015/testing/testing.js → esm2020/testing/testing.mjs} +0 -0
- package/fesm2015/{init.js → init.mjs} +4 -4
- package/fesm2015/init.mjs.map +1 -0
- package/fesm2015/platform-server.mjs +1046 -0
- package/fesm2015/platform-server.mjs.map +1 -0
- package/fesm2015/{testing.js → testing.mjs} +14 -9
- package/fesm2015/testing.mjs.map +1 -0
- package/fesm2020/init.mjs +141 -0
- package/fesm2020/init.mjs.map +1 -0
- package/{fesm2015/platform-server.js → fesm2020/platform-server.mjs} +116 -79
- package/fesm2020/platform-server.mjs.map +1 -0
- package/fesm2020/testing.mjs +75 -0
- package/fesm2020/testing.mjs.map +1 -0
- package/init/init.d.ts +1 -1
- package/init/package.json +5 -5
- package/package.json +46 -20
- package/platform-server.d.ts +19 -64
- package/testing/package.json +5 -5
- package/testing/testing.d.ts +7 -1
- package/bundles/platform-server-init.umd.js +0 -469
- package/bundles/platform-server-init.umd.js.map +0 -1
- package/bundles/platform-server-testing.umd.js +0 -79
- package/bundles/platform-server-testing.umd.js.map +0 -1
- package/bundles/platform-server.umd.js +0 -1351
- package/bundles/platform-server.umd.js.map +0 -1
- package/esm2015/init/init.externs.js +0 -6
- package/esm2015/platform-server.externs.js +0 -6
- package/esm2015/platform-server.js +0 -10
- package/esm2015/src/domino_adapter.js +0 -91
- package/esm2015/src/http.js +0 -122
- package/esm2015/src/location.js +0 -118
- package/esm2015/src/platform_state.js +0 -39
- package/esm2015/src/server.js +0 -94
- package/esm2015/src/server_events.js +0 -36
- package/esm2015/src/server_renderer.js +0 -272
- package/esm2015/src/styles_host.js +0 -44
- package/esm2015/src/transfer_state.js +0 -41
- package/esm2015/src/utils.js +0 -100
- package/esm2015/testing/src/server.js +0 -32
- package/esm2015/testing/testing.externs.js +0 -6
- package/fesm2015/init.js.map +0 -1
- package/fesm2015/platform-server.js.map +0 -1
- package/fesm2015/testing.js.map +0 -1
- package/init/init.metadata.json +0 -1
- package/init.d.ts +0 -7
- package/init.metadata.json +0 -1
- package/platform-server.metadata.json +0 -1
- package/testing/testing.metadata.json +0 -1
- package/testing.d.ts +0 -7
- package/testing.metadata.json +0 -1
|
@@ -0,0 +1,1046 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Angular v13.0.0-rc.2
|
|
3
|
+
* (c) 2010-2021 Google LLC. https://angular.io/
|
|
4
|
+
* License: MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { ɵsetRootDomAdapter, DOCUMENT, XhrFactory, PlatformLocation, ɵgetDOM, ɵPLATFORM_SERVER_ID, ViewportScroller, ɵNullViewportScroller } from '@angular/common';
|
|
8
|
+
import * as i0 from '@angular/core';
|
|
9
|
+
import { Injectable, Inject, InjectionToken, Injector, Optional, ViewEncapsulation, RendererStyleFlags2, PLATFORM_ID, PLATFORM_INITIALIZER, ɵALLOW_MULTIPLE_PLATFORMS, RendererFactory2, NgZone, Testability, NgModule, ɵsetDocument, createPlatformFactory, platformCore, APP_ID, ApplicationRef, ɵisPromise, Version } from '@angular/core';
|
|
10
|
+
import * as i1 from '@angular/platform-browser';
|
|
11
|
+
import { ɵBrowserDomAdapter, ɵflattenStyles, ɵNAMESPACE_URIS, ɵshimContentAttribute, ɵshimHostAttribute, ɵSharedStylesHost, ɵTRANSITION_ID, EVENT_MANAGER_PLUGINS, BrowserModule, ɵescapeHtml, TransferState } from '@angular/platform-browser';
|
|
12
|
+
import * as domino from 'domino';
|
|
13
|
+
import { ɵAnimationEngine } from '@angular/animations/browser';
|
|
14
|
+
import { ɵHttpInterceptingHandler, HttpHandler, HttpBackend, HttpClientModule } from '@angular/common/http';
|
|
15
|
+
import { ɵplatformCoreDynamic } from '@angular/platform-browser-dynamic';
|
|
16
|
+
import { ɵAnimationRendererFactory, NoopAnimationsModule } from '@angular/platform-browser/animations';
|
|
17
|
+
import { Observable, Subject } from 'rxjs';
|
|
18
|
+
import * as xhr2 from 'xhr2';
|
|
19
|
+
import * as url from 'url';
|
|
20
|
+
import { DomElementSchemaRegistry } from '@angular/compiler';
|
|
21
|
+
import { first } from 'rxjs/operators';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @license
|
|
25
|
+
* Copyright Google LLC All Rights Reserved.
|
|
26
|
+
*
|
|
27
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
28
|
+
* found in the LICENSE file at https://angular.io/license
|
|
29
|
+
*/
|
|
30
|
+
function setDomTypes() {
|
|
31
|
+
// Make all Domino types available in the global env.
|
|
32
|
+
Object.assign(global, domino.impl);
|
|
33
|
+
global['KeyboardEvent'] = domino.impl.Event;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Parses a document string to a Document object.
|
|
37
|
+
*/
|
|
38
|
+
function parseDocument(html, url = '/') {
|
|
39
|
+
let window = domino.createWindow(html, url);
|
|
40
|
+
let doc = window.document;
|
|
41
|
+
return doc;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Serializes a document to string.
|
|
45
|
+
*/
|
|
46
|
+
function serializeDocument(doc) {
|
|
47
|
+
return doc.serialize();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* DOM Adapter for the server platform based on https://github.com/fgnass/domino.
|
|
51
|
+
*/
|
|
52
|
+
class DominoAdapter extends ɵBrowserDomAdapter {
|
|
53
|
+
constructor() {
|
|
54
|
+
super(...arguments);
|
|
55
|
+
this.supportsDOMEvents = false;
|
|
56
|
+
}
|
|
57
|
+
static makeCurrent() {
|
|
58
|
+
setDomTypes();
|
|
59
|
+
ɵsetRootDomAdapter(new DominoAdapter());
|
|
60
|
+
}
|
|
61
|
+
createHtmlDocument() {
|
|
62
|
+
return parseDocument('<html><head><title>fakeTitle</title></head><body></body></html>');
|
|
63
|
+
}
|
|
64
|
+
getDefaultDocument() {
|
|
65
|
+
if (!DominoAdapter.defaultDoc) {
|
|
66
|
+
DominoAdapter.defaultDoc = domino.createDocument();
|
|
67
|
+
}
|
|
68
|
+
return DominoAdapter.defaultDoc;
|
|
69
|
+
}
|
|
70
|
+
isElementNode(node) {
|
|
71
|
+
return node ? node.nodeType === DominoAdapter.defaultDoc.ELEMENT_NODE : false;
|
|
72
|
+
}
|
|
73
|
+
isShadowRoot(node) {
|
|
74
|
+
return node.shadowRoot == node;
|
|
75
|
+
}
|
|
76
|
+
/** @deprecated No longer being used in Ivy code. To be removed in version 14. */
|
|
77
|
+
getGlobalEventTarget(doc, target) {
|
|
78
|
+
if (target === 'window') {
|
|
79
|
+
return doc.defaultView;
|
|
80
|
+
}
|
|
81
|
+
if (target === 'document') {
|
|
82
|
+
return doc;
|
|
83
|
+
}
|
|
84
|
+
if (target === 'body') {
|
|
85
|
+
return doc.body;
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
getBaseHref(doc) {
|
|
90
|
+
var _a;
|
|
91
|
+
// TODO(alxhub): Need relative path logic from BrowserDomAdapter here?
|
|
92
|
+
return ((_a = doc.documentElement.querySelector('base')) === null || _a === void 0 ? void 0 : _a.getAttribute('href')) || '';
|
|
93
|
+
}
|
|
94
|
+
dispatchEvent(el, evt) {
|
|
95
|
+
el.dispatchEvent(evt);
|
|
96
|
+
// Dispatch the event to the window also.
|
|
97
|
+
const doc = el.ownerDocument || el;
|
|
98
|
+
const win = doc.defaultView;
|
|
99
|
+
if (win) {
|
|
100
|
+
win.dispatchEvent(evt);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
getUserAgent() {
|
|
104
|
+
return 'Fake user agent';
|
|
105
|
+
}
|
|
106
|
+
getCookie(name) {
|
|
107
|
+
throw new Error('getCookie has not been implemented');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @license
|
|
113
|
+
* Copyright Google LLC All Rights Reserved.
|
|
114
|
+
*
|
|
115
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
116
|
+
* found in the LICENSE file at https://angular.io/license
|
|
117
|
+
*/
|
|
118
|
+
/**
|
|
119
|
+
* Representation of the current platform state.
|
|
120
|
+
*
|
|
121
|
+
* @publicApi
|
|
122
|
+
*/
|
|
123
|
+
class PlatformState {
|
|
124
|
+
constructor(_doc) {
|
|
125
|
+
this._doc = _doc;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Renders the current state of the platform to string.
|
|
129
|
+
*/
|
|
130
|
+
renderToString() {
|
|
131
|
+
return serializeDocument(this._doc);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Returns the current DOM state.
|
|
135
|
+
*/
|
|
136
|
+
getDocument() {
|
|
137
|
+
return this._doc;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
PlatformState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: PlatformState, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
141
|
+
PlatformState.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: PlatformState });
|
|
142
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: PlatformState, decorators: [{
|
|
143
|
+
type: Injectable
|
|
144
|
+
}], ctorParameters: function () {
|
|
145
|
+
return [{ type: undefined, decorators: [{
|
|
146
|
+
type: Inject,
|
|
147
|
+
args: [DOCUMENT]
|
|
148
|
+
}] }];
|
|
149
|
+
} });
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* @license
|
|
153
|
+
* Copyright Google LLC All Rights Reserved.
|
|
154
|
+
*
|
|
155
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
156
|
+
* found in the LICENSE file at https://angular.io/license
|
|
157
|
+
*/
|
|
158
|
+
/**
|
|
159
|
+
* The DI token for setting the initial config for the platform.
|
|
160
|
+
*
|
|
161
|
+
* @publicApi
|
|
162
|
+
*/
|
|
163
|
+
const INITIAL_CONFIG = new InjectionToken('Server.INITIAL_CONFIG');
|
|
164
|
+
/**
|
|
165
|
+
* A function that will be executed when calling `renderModuleFactory` or `renderModule` just
|
|
166
|
+
* before current platform state is rendered to string.
|
|
167
|
+
*
|
|
168
|
+
* @publicApi
|
|
169
|
+
*/
|
|
170
|
+
const BEFORE_APP_SERIALIZED = new InjectionToken('Server.RENDER_MODULE_HOOK');
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* @license
|
|
174
|
+
* Copyright Google LLC All Rights Reserved.
|
|
175
|
+
*
|
|
176
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
177
|
+
* found in the LICENSE file at https://angular.io/license
|
|
178
|
+
*/
|
|
179
|
+
// @see https://www.w3.org/Protocols/HTTP/1.1/draft-ietf-http-v11-spec-01#URI-syntax
|
|
180
|
+
const isAbsoluteUrl = /^[a-zA-Z\-\+.]+:\/\//;
|
|
181
|
+
class ServerXhr {
|
|
182
|
+
build() {
|
|
183
|
+
return new xhr2.XMLHttpRequest();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
ServerXhr.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: ServerXhr, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
187
|
+
ServerXhr.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: ServerXhr });
|
|
188
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: ServerXhr, decorators: [{
|
|
189
|
+
type: Injectable
|
|
190
|
+
}] });
|
|
191
|
+
class ZoneMacroTaskWrapper {
|
|
192
|
+
wrap(request) {
|
|
193
|
+
return new Observable((observer) => {
|
|
194
|
+
let task = null;
|
|
195
|
+
let scheduled = false;
|
|
196
|
+
let sub = null;
|
|
197
|
+
let savedResult = null;
|
|
198
|
+
let savedError = null;
|
|
199
|
+
const scheduleTask = (_task) => {
|
|
200
|
+
task = _task;
|
|
201
|
+
scheduled = true;
|
|
202
|
+
const delegate = this.delegate(request);
|
|
203
|
+
sub = delegate.subscribe(res => savedResult = res, err => {
|
|
204
|
+
if (!scheduled) {
|
|
205
|
+
throw new Error('An http observable was completed twice. This shouldn\'t happen, please file a bug.');
|
|
206
|
+
}
|
|
207
|
+
savedError = err;
|
|
208
|
+
scheduled = false;
|
|
209
|
+
task.invoke();
|
|
210
|
+
}, () => {
|
|
211
|
+
if (!scheduled) {
|
|
212
|
+
throw new Error('An http observable was completed twice. This shouldn\'t happen, please file a bug.');
|
|
213
|
+
}
|
|
214
|
+
scheduled = false;
|
|
215
|
+
task.invoke();
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
const cancelTask = (_task) => {
|
|
219
|
+
if (!scheduled) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
scheduled = false;
|
|
223
|
+
if (sub) {
|
|
224
|
+
sub.unsubscribe();
|
|
225
|
+
sub = null;
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
const onComplete = () => {
|
|
229
|
+
if (savedError !== null) {
|
|
230
|
+
observer.error(savedError);
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
observer.next(savedResult);
|
|
234
|
+
observer.complete();
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
// MockBackend for Http is synchronous, which means that if scheduleTask is by
|
|
238
|
+
// scheduleMacroTask, the request will hit MockBackend and the response will be
|
|
239
|
+
// sent, causing task.invoke() to be called.
|
|
240
|
+
const _task = Zone.current.scheduleMacroTask('ZoneMacroTaskWrapper.subscribe', onComplete, {}, () => null, cancelTask);
|
|
241
|
+
scheduleTask(_task);
|
|
242
|
+
return () => {
|
|
243
|
+
if (scheduled && task) {
|
|
244
|
+
task.zone.cancelTask(task);
|
|
245
|
+
scheduled = false;
|
|
246
|
+
}
|
|
247
|
+
if (sub) {
|
|
248
|
+
sub.unsubscribe();
|
|
249
|
+
sub = null;
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
class ZoneClientBackend extends ZoneMacroTaskWrapper {
|
|
256
|
+
constructor(backend, platformLocation, config) {
|
|
257
|
+
super();
|
|
258
|
+
this.backend = backend;
|
|
259
|
+
this.platformLocation = platformLocation;
|
|
260
|
+
this.config = config;
|
|
261
|
+
}
|
|
262
|
+
handle(request) {
|
|
263
|
+
const { href, protocol, hostname, port } = this.platformLocation;
|
|
264
|
+
if (this.config.useAbsoluteUrl && !isAbsoluteUrl.test(request.url) &&
|
|
265
|
+
isAbsoluteUrl.test(href)) {
|
|
266
|
+
const baseHref = this.platformLocation.getBaseHrefFromDOM() || href;
|
|
267
|
+
const urlPrefix = `${protocol}//${hostname}` + (port ? `:${port}` : '');
|
|
268
|
+
const baseUrl = new URL(baseHref, urlPrefix);
|
|
269
|
+
const url = new URL(request.url, baseUrl);
|
|
270
|
+
return this.wrap(request.clone({ url: url.toString() }));
|
|
271
|
+
}
|
|
272
|
+
return this.wrap(request);
|
|
273
|
+
}
|
|
274
|
+
delegate(request) {
|
|
275
|
+
return this.backend.handle(request);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
function zoneWrappedInterceptingHandler(backend, injector, platformLocation, config) {
|
|
279
|
+
const realBackend = new ɵHttpInterceptingHandler(backend, injector);
|
|
280
|
+
return new ZoneClientBackend(realBackend, platformLocation, config);
|
|
281
|
+
}
|
|
282
|
+
const SERVER_HTTP_PROVIDERS = [
|
|
283
|
+
{ provide: XhrFactory, useClass: ServerXhr }, {
|
|
284
|
+
provide: HttpHandler,
|
|
285
|
+
useFactory: zoneWrappedInterceptingHandler,
|
|
286
|
+
deps: [HttpBackend, Injector, PlatformLocation, INITIAL_CONFIG]
|
|
287
|
+
}
|
|
288
|
+
];
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* @license
|
|
292
|
+
* Copyright Google LLC All Rights Reserved.
|
|
293
|
+
*
|
|
294
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
295
|
+
* found in the LICENSE file at https://angular.io/license
|
|
296
|
+
*/
|
|
297
|
+
function parseUrl(urlStr) {
|
|
298
|
+
const parsedUrl = url.parse(urlStr);
|
|
299
|
+
return {
|
|
300
|
+
hostname: parsedUrl.hostname || '',
|
|
301
|
+
protocol: parsedUrl.protocol || '',
|
|
302
|
+
port: parsedUrl.port || '',
|
|
303
|
+
pathname: parsedUrl.pathname || '',
|
|
304
|
+
search: parsedUrl.search || '',
|
|
305
|
+
hash: parsedUrl.hash || '',
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Server-side implementation of URL state. Implements `pathname`, `search`, and `hash`
|
|
310
|
+
* but not the state stack.
|
|
311
|
+
*/
|
|
312
|
+
class ServerPlatformLocation {
|
|
313
|
+
constructor(_doc, _config) {
|
|
314
|
+
this._doc = _doc;
|
|
315
|
+
this.href = '/';
|
|
316
|
+
this.hostname = '/';
|
|
317
|
+
this.protocol = '/';
|
|
318
|
+
this.port = '/';
|
|
319
|
+
this.pathname = '/';
|
|
320
|
+
this.search = '';
|
|
321
|
+
this.hash = '';
|
|
322
|
+
this._hashUpdate = new Subject();
|
|
323
|
+
const config = _config;
|
|
324
|
+
if (!config) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
if (config.url) {
|
|
328
|
+
const url = parseUrl(config.url);
|
|
329
|
+
this.protocol = url.protocol;
|
|
330
|
+
this.hostname = url.hostname;
|
|
331
|
+
this.port = url.port;
|
|
332
|
+
this.pathname = url.pathname;
|
|
333
|
+
this.search = url.search;
|
|
334
|
+
this.hash = url.hash;
|
|
335
|
+
this.href = _doc.location.href;
|
|
336
|
+
}
|
|
337
|
+
if (config.useAbsoluteUrl) {
|
|
338
|
+
if (!config.baseUrl) {
|
|
339
|
+
throw new Error(`"PlatformConfig.baseUrl" must be set if "useAbsoluteUrl" is true`);
|
|
340
|
+
}
|
|
341
|
+
const url = parseUrl(config.baseUrl);
|
|
342
|
+
this.protocol = url.protocol;
|
|
343
|
+
this.hostname = url.hostname;
|
|
344
|
+
this.port = url.port;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
getBaseHrefFromDOM() {
|
|
348
|
+
return ɵgetDOM().getBaseHref(this._doc);
|
|
349
|
+
}
|
|
350
|
+
onPopState(fn) {
|
|
351
|
+
// No-op: a state stack is not implemented, so
|
|
352
|
+
// no events will ever come.
|
|
353
|
+
return () => { };
|
|
354
|
+
}
|
|
355
|
+
onHashChange(fn) {
|
|
356
|
+
const subscription = this._hashUpdate.subscribe(fn);
|
|
357
|
+
return () => subscription.unsubscribe();
|
|
358
|
+
}
|
|
359
|
+
get url() {
|
|
360
|
+
return `${this.pathname}${this.search}${this.hash}`;
|
|
361
|
+
}
|
|
362
|
+
setHash(value, oldUrl) {
|
|
363
|
+
if (this.hash === value) {
|
|
364
|
+
// Don't fire events if the hash has not changed.
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
this.hash = value;
|
|
368
|
+
const newUrl = this.url;
|
|
369
|
+
scheduleMicroTask(() => this._hashUpdate.next({ type: 'hashchange', state: null, oldUrl, newUrl }));
|
|
370
|
+
}
|
|
371
|
+
replaceState(state, title, newUrl) {
|
|
372
|
+
const oldUrl = this.url;
|
|
373
|
+
const parsedUrl = parseUrl(newUrl);
|
|
374
|
+
this.pathname = parsedUrl.pathname;
|
|
375
|
+
this.search = parsedUrl.search;
|
|
376
|
+
this.setHash(parsedUrl.hash, oldUrl);
|
|
377
|
+
}
|
|
378
|
+
pushState(state, title, newUrl) {
|
|
379
|
+
this.replaceState(state, title, newUrl);
|
|
380
|
+
}
|
|
381
|
+
forward() {
|
|
382
|
+
throw new Error('Not implemented');
|
|
383
|
+
}
|
|
384
|
+
back() {
|
|
385
|
+
throw new Error('Not implemented');
|
|
386
|
+
}
|
|
387
|
+
// History API isn't available on server, therefore return undefined
|
|
388
|
+
getState() {
|
|
389
|
+
return undefined;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
ServerPlatformLocation.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: ServerPlatformLocation, deps: [{ token: DOCUMENT }, { token: INITIAL_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
393
|
+
ServerPlatformLocation.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: ServerPlatformLocation });
|
|
394
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: ServerPlatformLocation, decorators: [{
|
|
395
|
+
type: Injectable
|
|
396
|
+
}], ctorParameters: function () {
|
|
397
|
+
return [{ type: undefined, decorators: [{
|
|
398
|
+
type: Inject,
|
|
399
|
+
args: [DOCUMENT]
|
|
400
|
+
}] }, { type: undefined, decorators: [{
|
|
401
|
+
type: Optional
|
|
402
|
+
}, {
|
|
403
|
+
type: Inject,
|
|
404
|
+
args: [INITIAL_CONFIG]
|
|
405
|
+
}] }];
|
|
406
|
+
} });
|
|
407
|
+
function scheduleMicroTask(fn) {
|
|
408
|
+
Zone.current.scheduleMicroTask('scheduleMicrotask', fn);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* @license
|
|
413
|
+
* Copyright Google LLC All Rights Reserved.
|
|
414
|
+
*
|
|
415
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
416
|
+
* found in the LICENSE file at https://angular.io/license
|
|
417
|
+
*/
|
|
418
|
+
class ServerEventManagerPlugin /* extends EventManagerPlugin which is private */ {
|
|
419
|
+
constructor(doc) {
|
|
420
|
+
this.doc = doc;
|
|
421
|
+
}
|
|
422
|
+
// Handle all events on the server.
|
|
423
|
+
supports(eventName) {
|
|
424
|
+
return true;
|
|
425
|
+
}
|
|
426
|
+
addEventListener(element, eventName, handler) {
|
|
427
|
+
return ɵgetDOM().onAndCancel(element, eventName, handler);
|
|
428
|
+
}
|
|
429
|
+
/** @deprecated No longer being used in Ivy code. To be removed in version 14. */
|
|
430
|
+
addGlobalEventListener(element, eventName, handler) {
|
|
431
|
+
const target = ɵgetDOM().getGlobalEventTarget(this.doc, element);
|
|
432
|
+
if (!target) {
|
|
433
|
+
throw new Error(`Unsupported event target ${target} for event ${eventName}`);
|
|
434
|
+
}
|
|
435
|
+
return this.addEventListener(target, eventName, handler);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
ServerEventManagerPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: ServerEventManagerPlugin /* extends EventManagerPlugin which is private */, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
439
|
+
ServerEventManagerPlugin.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: ServerEventManagerPlugin /* extends EventManagerPlugin which is private */ });
|
|
440
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: ServerEventManagerPlugin /* extends EventManagerPlugin which is private */, decorators: [{
|
|
441
|
+
type: Injectable
|
|
442
|
+
}], ctorParameters: function () {
|
|
443
|
+
return [{ type: undefined, decorators: [{
|
|
444
|
+
type: Inject,
|
|
445
|
+
args: [DOCUMENT]
|
|
446
|
+
}] }];
|
|
447
|
+
} });
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* @license
|
|
451
|
+
* Copyright Google LLC All Rights Reserved.
|
|
452
|
+
*
|
|
453
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
454
|
+
* found in the LICENSE file at https://angular.io/license
|
|
455
|
+
*/
|
|
456
|
+
const EMPTY_ARRAY = [];
|
|
457
|
+
const DEFAULT_SCHEMA = new DomElementSchemaRegistry();
|
|
458
|
+
class ServerRendererFactory2 {
|
|
459
|
+
constructor(eventManager, ngZone, document, sharedStylesHost) {
|
|
460
|
+
this.eventManager = eventManager;
|
|
461
|
+
this.ngZone = ngZone;
|
|
462
|
+
this.document = document;
|
|
463
|
+
this.sharedStylesHost = sharedStylesHost;
|
|
464
|
+
this.rendererByCompId = new Map();
|
|
465
|
+
this.schema = DEFAULT_SCHEMA;
|
|
466
|
+
this.defaultRenderer = new DefaultServerRenderer2(eventManager, document, ngZone, this.schema);
|
|
467
|
+
}
|
|
468
|
+
createRenderer(element, type) {
|
|
469
|
+
if (!element || !type) {
|
|
470
|
+
return this.defaultRenderer;
|
|
471
|
+
}
|
|
472
|
+
switch (type.encapsulation) {
|
|
473
|
+
case ViewEncapsulation.Emulated: {
|
|
474
|
+
let renderer = this.rendererByCompId.get(type.id);
|
|
475
|
+
if (!renderer) {
|
|
476
|
+
renderer = new EmulatedEncapsulationServerRenderer2(this.eventManager, this.document, this.ngZone, this.sharedStylesHost, this.schema, type);
|
|
477
|
+
this.rendererByCompId.set(type.id, renderer);
|
|
478
|
+
}
|
|
479
|
+
renderer.applyToHost(element);
|
|
480
|
+
return renderer;
|
|
481
|
+
}
|
|
482
|
+
default: {
|
|
483
|
+
if (!this.rendererByCompId.has(type.id)) {
|
|
484
|
+
const styles = ɵflattenStyles(type.id, type.styles, []);
|
|
485
|
+
this.sharedStylesHost.addStyles(styles);
|
|
486
|
+
this.rendererByCompId.set(type.id, this.defaultRenderer);
|
|
487
|
+
}
|
|
488
|
+
return this.defaultRenderer;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
begin() { }
|
|
493
|
+
end() { }
|
|
494
|
+
}
|
|
495
|
+
ServerRendererFactory2.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: ServerRendererFactory2, deps: [{ token: i1.EventManager }, { token: i0.NgZone }, { token: DOCUMENT }, { token: i1.ɵSharedStylesHost }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
496
|
+
ServerRendererFactory2.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: ServerRendererFactory2 });
|
|
497
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: ServerRendererFactory2, decorators: [{
|
|
498
|
+
type: Injectable
|
|
499
|
+
}], ctorParameters: function () {
|
|
500
|
+
return [{ type: i1.EventManager }, { type: i0.NgZone }, { type: undefined, decorators: [{
|
|
501
|
+
type: Inject,
|
|
502
|
+
args: [DOCUMENT]
|
|
503
|
+
}] }, { type: i1.ɵSharedStylesHost }];
|
|
504
|
+
} });
|
|
505
|
+
class DefaultServerRenderer2 {
|
|
506
|
+
constructor(eventManager, document, ngZone, schema) {
|
|
507
|
+
this.eventManager = eventManager;
|
|
508
|
+
this.document = document;
|
|
509
|
+
this.ngZone = ngZone;
|
|
510
|
+
this.schema = schema;
|
|
511
|
+
this.data = Object.create(null);
|
|
512
|
+
this.destroyNode = null;
|
|
513
|
+
}
|
|
514
|
+
destroy() { }
|
|
515
|
+
createElement(name, namespace, debugInfo) {
|
|
516
|
+
if (namespace) {
|
|
517
|
+
const doc = this.document || ɵgetDOM().getDefaultDocument();
|
|
518
|
+
// TODO(FW-811): Ivy may cause issues here because it's passing around
|
|
519
|
+
// full URIs for namespaces, therefore this lookup will fail.
|
|
520
|
+
return doc.createElementNS(ɵNAMESPACE_URIS[namespace], name);
|
|
521
|
+
}
|
|
522
|
+
return ɵgetDOM().createElement(name, this.document);
|
|
523
|
+
}
|
|
524
|
+
createComment(value, debugInfo) {
|
|
525
|
+
return ɵgetDOM().getDefaultDocument().createComment(value);
|
|
526
|
+
}
|
|
527
|
+
createText(value, debugInfo) {
|
|
528
|
+
const doc = ɵgetDOM().getDefaultDocument();
|
|
529
|
+
return doc.createTextNode(value);
|
|
530
|
+
}
|
|
531
|
+
appendChild(parent, newChild) {
|
|
532
|
+
parent.appendChild(newChild);
|
|
533
|
+
}
|
|
534
|
+
insertBefore(parent, newChild, refChild) {
|
|
535
|
+
if (parent) {
|
|
536
|
+
parent.insertBefore(newChild, refChild);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
removeChild(parent, oldChild) {
|
|
540
|
+
if (parent) {
|
|
541
|
+
parent.removeChild(oldChild);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
selectRootElement(selectorOrNode, debugInfo) {
|
|
545
|
+
let el;
|
|
546
|
+
if (typeof selectorOrNode === 'string') {
|
|
547
|
+
el = this.document.querySelector(selectorOrNode);
|
|
548
|
+
if (!el) {
|
|
549
|
+
throw new Error(`The selector "${selectorOrNode}" did not match any elements`);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
else {
|
|
553
|
+
el = selectorOrNode;
|
|
554
|
+
}
|
|
555
|
+
while (el.firstChild) {
|
|
556
|
+
el.removeChild(el.firstChild);
|
|
557
|
+
}
|
|
558
|
+
return el;
|
|
559
|
+
}
|
|
560
|
+
parentNode(node) {
|
|
561
|
+
return node.parentNode;
|
|
562
|
+
}
|
|
563
|
+
nextSibling(node) {
|
|
564
|
+
return node.nextSibling;
|
|
565
|
+
}
|
|
566
|
+
setAttribute(el, name, value, namespace) {
|
|
567
|
+
if (namespace) {
|
|
568
|
+
// TODO(FW-811): Ivy may cause issues here because it's passing around
|
|
569
|
+
// full URIs for namespaces, therefore this lookup will fail.
|
|
570
|
+
el.setAttributeNS(ɵNAMESPACE_URIS[namespace], namespace + ':' + name, value);
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
el.setAttribute(name, value);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
removeAttribute(el, name, namespace) {
|
|
577
|
+
if (namespace) {
|
|
578
|
+
// TODO(FW-811): Ivy may cause issues here because it's passing around
|
|
579
|
+
// full URIs for namespaces, therefore this lookup will fail.
|
|
580
|
+
el.removeAttributeNS(ɵNAMESPACE_URIS[namespace], name);
|
|
581
|
+
}
|
|
582
|
+
else {
|
|
583
|
+
el.removeAttribute(name);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
addClass(el, name) {
|
|
587
|
+
el.classList.add(name);
|
|
588
|
+
}
|
|
589
|
+
removeClass(el, name) {
|
|
590
|
+
el.classList.remove(name);
|
|
591
|
+
}
|
|
592
|
+
setStyle(el, style, value, flags) {
|
|
593
|
+
style = style.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
594
|
+
const styleMap = _readStyleAttribute(el);
|
|
595
|
+
if (flags & RendererStyleFlags2.Important) {
|
|
596
|
+
value += ' !important';
|
|
597
|
+
}
|
|
598
|
+
styleMap[style] = value == null ? '' : value;
|
|
599
|
+
_writeStyleAttribute(el, styleMap);
|
|
600
|
+
}
|
|
601
|
+
removeStyle(el, style, flags) {
|
|
602
|
+
// IE requires '' instead of null
|
|
603
|
+
// see https://github.com/angular/angular/issues/7916
|
|
604
|
+
this.setStyle(el, style, '', flags);
|
|
605
|
+
}
|
|
606
|
+
// The value was validated already as a property binding, against the property name.
|
|
607
|
+
// To know this value is safe to use as an attribute, the security context of the
|
|
608
|
+
// attribute with the given name is checked against that security context of the
|
|
609
|
+
// property.
|
|
610
|
+
_isSafeToReflectProperty(tagName, propertyName) {
|
|
611
|
+
return this.schema.securityContext(tagName, propertyName, true) ===
|
|
612
|
+
this.schema.securityContext(tagName, propertyName, false);
|
|
613
|
+
}
|
|
614
|
+
setProperty(el, name, value) {
|
|
615
|
+
checkNoSyntheticProp(name, 'property');
|
|
616
|
+
if (name === 'innerText') {
|
|
617
|
+
// Domino does not support innerText. Just map it to textContent.
|
|
618
|
+
el.textContent = value;
|
|
619
|
+
}
|
|
620
|
+
el[name] = value;
|
|
621
|
+
// Mirror property values for known HTML element properties in the attributes.
|
|
622
|
+
// Skip `innerhtml` which is conservatively marked as an attribute for security
|
|
623
|
+
// purposes but is not actually an attribute.
|
|
624
|
+
const tagName = el.tagName.toLowerCase();
|
|
625
|
+
if (value != null && (typeof value === 'number' || typeof value == 'string') &&
|
|
626
|
+
name.toLowerCase() !== 'innerhtml' && this.schema.hasElement(tagName, EMPTY_ARRAY) &&
|
|
627
|
+
this.schema.hasProperty(tagName, name, EMPTY_ARRAY) &&
|
|
628
|
+
this._isSafeToReflectProperty(tagName, name)) {
|
|
629
|
+
this.setAttribute(el, name, value.toString());
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
setValue(node, value) {
|
|
633
|
+
node.textContent = value;
|
|
634
|
+
}
|
|
635
|
+
listen(target, eventName, callback) {
|
|
636
|
+
checkNoSyntheticProp(eventName, 'listener');
|
|
637
|
+
if (typeof target === 'string') {
|
|
638
|
+
return this.eventManager.addGlobalEventListener(target, eventName, this.decoratePreventDefault(callback));
|
|
639
|
+
}
|
|
640
|
+
return this.eventManager.addEventListener(target, eventName, this.decoratePreventDefault(callback));
|
|
641
|
+
}
|
|
642
|
+
decoratePreventDefault(eventHandler) {
|
|
643
|
+
return (event) => {
|
|
644
|
+
// Ivy uses `Function` as a special token that allows us to unwrap the function
|
|
645
|
+
// so that it can be invoked programmatically by `DebugNode.triggerEventHandler`.
|
|
646
|
+
if (event === Function) {
|
|
647
|
+
return eventHandler;
|
|
648
|
+
}
|
|
649
|
+
// Run the event handler inside the ngZone because event handlers are not patched
|
|
650
|
+
// by Zone on the server. This is required only for tests.
|
|
651
|
+
const allowDefaultBehavior = this.ngZone.runGuarded(() => eventHandler(event));
|
|
652
|
+
if (allowDefaultBehavior === false) {
|
|
653
|
+
event.preventDefault();
|
|
654
|
+
event.returnValue = false;
|
|
655
|
+
}
|
|
656
|
+
return undefined;
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
const AT_CHARCODE = '@'.charCodeAt(0);
|
|
661
|
+
function checkNoSyntheticProp(name, nameKind) {
|
|
662
|
+
if (name.charCodeAt(0) === AT_CHARCODE) {
|
|
663
|
+
throw new Error(`Unexpected synthetic ${nameKind} ${name} found. Please make sure that:
|
|
664
|
+
- Either \`BrowserAnimationsModule\` or \`NoopAnimationsModule\` are imported in your application.
|
|
665
|
+
- There is corresponding configuration for the animation named \`${name}\` defined in the \`animations\` field of the \`@Component\` decorator (see https://angular.io/api/core/Component#animations).`);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
class EmulatedEncapsulationServerRenderer2 extends DefaultServerRenderer2 {
|
|
669
|
+
constructor(eventManager, document, ngZone, sharedStylesHost, schema, component) {
|
|
670
|
+
super(eventManager, document, ngZone, schema);
|
|
671
|
+
this.component = component;
|
|
672
|
+
// Add a 's' prefix to style attributes to indicate server.
|
|
673
|
+
const componentId = 's' + component.id;
|
|
674
|
+
const styles = ɵflattenStyles(componentId, component.styles, []);
|
|
675
|
+
sharedStylesHost.addStyles(styles);
|
|
676
|
+
this.contentAttr = ɵshimContentAttribute(componentId);
|
|
677
|
+
this.hostAttr = ɵshimHostAttribute(componentId);
|
|
678
|
+
}
|
|
679
|
+
applyToHost(element) {
|
|
680
|
+
super.setAttribute(element, this.hostAttr, '');
|
|
681
|
+
}
|
|
682
|
+
createElement(parent, name) {
|
|
683
|
+
const el = super.createElement(parent, name, this.document);
|
|
684
|
+
super.setAttribute(el, this.contentAttr, '');
|
|
685
|
+
return el;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
function _readStyleAttribute(element) {
|
|
689
|
+
const styleMap = {};
|
|
690
|
+
const styleAttribute = element.getAttribute('style');
|
|
691
|
+
if (styleAttribute) {
|
|
692
|
+
const styleList = styleAttribute.split(/;+/g);
|
|
693
|
+
for (let i = 0; i < styleList.length; i++) {
|
|
694
|
+
const style = styleList[i].trim();
|
|
695
|
+
if (style.length > 0) {
|
|
696
|
+
const colonIndex = style.indexOf(':');
|
|
697
|
+
if (colonIndex === -1) {
|
|
698
|
+
throw new Error(`Invalid CSS style: ${style}`);
|
|
699
|
+
}
|
|
700
|
+
const name = style.substr(0, colonIndex).trim();
|
|
701
|
+
styleMap[name] = style.substr(colonIndex + 1).trim();
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
return styleMap;
|
|
706
|
+
}
|
|
707
|
+
function _writeStyleAttribute(element, styleMap) {
|
|
708
|
+
let styleAttrValue = '';
|
|
709
|
+
for (const key in styleMap) {
|
|
710
|
+
const newValue = styleMap[key];
|
|
711
|
+
if (newValue != null) {
|
|
712
|
+
styleAttrValue += key + ':' + styleMap[key] + ';';
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
element.setAttribute('style', styleAttrValue);
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* @license
|
|
720
|
+
* Copyright Google LLC All Rights Reserved.
|
|
721
|
+
*
|
|
722
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
723
|
+
* found in the LICENSE file at https://angular.io/license
|
|
724
|
+
*/
|
|
725
|
+
class ServerStylesHost extends ɵSharedStylesHost {
|
|
726
|
+
constructor(doc, transitionId) {
|
|
727
|
+
super();
|
|
728
|
+
this.doc = doc;
|
|
729
|
+
this.transitionId = transitionId;
|
|
730
|
+
this.head = null;
|
|
731
|
+
this._styleNodes = new Set();
|
|
732
|
+
this.head = doc.getElementsByTagName('head')[0];
|
|
733
|
+
}
|
|
734
|
+
_addStyle(style) {
|
|
735
|
+
let adapter = ɵgetDOM();
|
|
736
|
+
const el = adapter.createElement('style');
|
|
737
|
+
el.textContent = style;
|
|
738
|
+
if (!!this.transitionId) {
|
|
739
|
+
el.setAttribute('ng-transition', this.transitionId);
|
|
740
|
+
}
|
|
741
|
+
this.head.appendChild(el);
|
|
742
|
+
this._styleNodes.add(el);
|
|
743
|
+
}
|
|
744
|
+
onStylesAdded(additions) {
|
|
745
|
+
additions.forEach(style => this._addStyle(style));
|
|
746
|
+
}
|
|
747
|
+
ngOnDestroy() {
|
|
748
|
+
this._styleNodes.forEach(styleNode => styleNode.remove());
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
ServerStylesHost.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: ServerStylesHost, deps: [{ token: DOCUMENT }, { token: ɵTRANSITION_ID, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
752
|
+
ServerStylesHost.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: ServerStylesHost });
|
|
753
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: ServerStylesHost, decorators: [{
|
|
754
|
+
type: Injectable
|
|
755
|
+
}], ctorParameters: function () {
|
|
756
|
+
return [{ type: undefined, decorators: [{
|
|
757
|
+
type: Inject,
|
|
758
|
+
args: [DOCUMENT]
|
|
759
|
+
}] }, { type: undefined, decorators: [{
|
|
760
|
+
type: Optional
|
|
761
|
+
}, {
|
|
762
|
+
type: Inject,
|
|
763
|
+
args: [ɵTRANSITION_ID]
|
|
764
|
+
}] }];
|
|
765
|
+
} });
|
|
766
|
+
|
|
767
|
+
/**
|
|
768
|
+
* @license
|
|
769
|
+
* Copyright Google LLC All Rights Reserved.
|
|
770
|
+
*
|
|
771
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
772
|
+
* found in the LICENSE file at https://angular.io/license
|
|
773
|
+
*/
|
|
774
|
+
function notSupported(feature) {
|
|
775
|
+
throw new Error(`platform-server does not support '${feature}'.`);
|
|
776
|
+
}
|
|
777
|
+
const INTERNAL_SERVER_PLATFORM_PROVIDERS = [
|
|
778
|
+
{ provide: DOCUMENT, useFactory: _document, deps: [Injector] },
|
|
779
|
+
{ provide: PLATFORM_ID, useValue: ɵPLATFORM_SERVER_ID },
|
|
780
|
+
{ provide: PLATFORM_INITIALIZER, useFactory: initDominoAdapter, multi: true, deps: [Injector] }, {
|
|
781
|
+
provide: PlatformLocation,
|
|
782
|
+
useClass: ServerPlatformLocation,
|
|
783
|
+
deps: [DOCUMENT, [Optional, INITIAL_CONFIG]]
|
|
784
|
+
},
|
|
785
|
+
{ provide: PlatformState, deps: [DOCUMENT] },
|
|
786
|
+
// Add special provider that allows multiple instances of platformServer* to be created.
|
|
787
|
+
{ provide: ɵALLOW_MULTIPLE_PLATFORMS, useValue: true }
|
|
788
|
+
];
|
|
789
|
+
function initDominoAdapter(injector) {
|
|
790
|
+
return () => {
|
|
791
|
+
DominoAdapter.makeCurrent();
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
function instantiateServerRendererFactory(renderer, engine, zone) {
|
|
795
|
+
return new ɵAnimationRendererFactory(renderer, engine, zone);
|
|
796
|
+
}
|
|
797
|
+
const SERVER_RENDER_PROVIDERS = [
|
|
798
|
+
ServerRendererFactory2,
|
|
799
|
+
{
|
|
800
|
+
provide: RendererFactory2,
|
|
801
|
+
useFactory: instantiateServerRendererFactory,
|
|
802
|
+
deps: [ServerRendererFactory2, ɵAnimationEngine, NgZone]
|
|
803
|
+
},
|
|
804
|
+
ServerStylesHost,
|
|
805
|
+
{ provide: ɵSharedStylesHost, useExisting: ServerStylesHost },
|
|
806
|
+
{ provide: EVENT_MANAGER_PLUGINS, multi: true, useClass: ServerEventManagerPlugin },
|
|
807
|
+
];
|
|
808
|
+
/**
|
|
809
|
+
* The ng module for the server.
|
|
810
|
+
*
|
|
811
|
+
* @publicApi
|
|
812
|
+
*/
|
|
813
|
+
class ServerModule {
|
|
814
|
+
}
|
|
815
|
+
ServerModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: ServerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
816
|
+
ServerModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: ServerModule, imports: [HttpClientModule, NoopAnimationsModule], exports: [BrowserModule] });
|
|
817
|
+
ServerModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: ServerModule, providers: [
|
|
818
|
+
SERVER_RENDER_PROVIDERS,
|
|
819
|
+
SERVER_HTTP_PROVIDERS,
|
|
820
|
+
{ provide: Testability, useValue: null },
|
|
821
|
+
{ provide: ViewportScroller, useClass: ɵNullViewportScroller },
|
|
822
|
+
], imports: [[HttpClientModule, NoopAnimationsModule], BrowserModule] });
|
|
823
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: ServerModule, decorators: [{
|
|
824
|
+
type: NgModule,
|
|
825
|
+
args: [{
|
|
826
|
+
exports: [BrowserModule],
|
|
827
|
+
imports: [HttpClientModule, NoopAnimationsModule],
|
|
828
|
+
providers: [
|
|
829
|
+
SERVER_RENDER_PROVIDERS,
|
|
830
|
+
SERVER_HTTP_PROVIDERS,
|
|
831
|
+
{ provide: Testability, useValue: null },
|
|
832
|
+
{ provide: ViewportScroller, useClass: ɵNullViewportScroller },
|
|
833
|
+
],
|
|
834
|
+
}]
|
|
835
|
+
}] });
|
|
836
|
+
function _document(injector) {
|
|
837
|
+
let config = injector.get(INITIAL_CONFIG, null);
|
|
838
|
+
const document = config && config.document ? parseDocument(config.document, config.url) :
|
|
839
|
+
ɵgetDOM().createHtmlDocument();
|
|
840
|
+
// Tell ivy about the global document
|
|
841
|
+
ɵsetDocument(document);
|
|
842
|
+
return document;
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* @publicApi
|
|
846
|
+
*/
|
|
847
|
+
const platformServer = createPlatformFactory(platformCore, 'server', INTERNAL_SERVER_PLATFORM_PROVIDERS);
|
|
848
|
+
/**
|
|
849
|
+
* The server platform that supports the runtime compiler.
|
|
850
|
+
*
|
|
851
|
+
* @publicApi
|
|
852
|
+
*/
|
|
853
|
+
const platformDynamicServer = createPlatformFactory(ɵplatformCoreDynamic, 'serverDynamic', INTERNAL_SERVER_PLATFORM_PROVIDERS);
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* @license
|
|
857
|
+
* Copyright Google LLC All Rights Reserved.
|
|
858
|
+
*
|
|
859
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
860
|
+
* found in the LICENSE file at https://angular.io/license
|
|
861
|
+
*/
|
|
862
|
+
function serializeTransferStateFactory(doc, appId, transferStore) {
|
|
863
|
+
return () => {
|
|
864
|
+
const script = doc.createElement('script');
|
|
865
|
+
script.id = appId + '-state';
|
|
866
|
+
script.setAttribute('type', 'application/json');
|
|
867
|
+
script.textContent = ɵescapeHtml(transferStore.toJson());
|
|
868
|
+
doc.body.appendChild(script);
|
|
869
|
+
};
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* NgModule to install on the server side while using the `TransferState` to transfer state from
|
|
873
|
+
* server to client.
|
|
874
|
+
*
|
|
875
|
+
* @publicApi
|
|
876
|
+
*/
|
|
877
|
+
class ServerTransferStateModule {
|
|
878
|
+
}
|
|
879
|
+
ServerTransferStateModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: ServerTransferStateModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
880
|
+
ServerTransferStateModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: ServerTransferStateModule });
|
|
881
|
+
ServerTransferStateModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: ServerTransferStateModule, providers: [
|
|
882
|
+
TransferState, {
|
|
883
|
+
provide: BEFORE_APP_SERIALIZED,
|
|
884
|
+
useFactory: serializeTransferStateFactory,
|
|
885
|
+
deps: [DOCUMENT, APP_ID, TransferState],
|
|
886
|
+
multi: true,
|
|
887
|
+
}
|
|
888
|
+
] });
|
|
889
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-rc.2", ngImport: i0, type: ServerTransferStateModule, decorators: [{
|
|
890
|
+
type: NgModule,
|
|
891
|
+
args: [{
|
|
892
|
+
providers: [
|
|
893
|
+
TransferState, {
|
|
894
|
+
provide: BEFORE_APP_SERIALIZED,
|
|
895
|
+
useFactory: serializeTransferStateFactory,
|
|
896
|
+
deps: [DOCUMENT, APP_ID, TransferState],
|
|
897
|
+
multi: true,
|
|
898
|
+
}
|
|
899
|
+
]
|
|
900
|
+
}]
|
|
901
|
+
}] });
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* @license
|
|
905
|
+
* Copyright Google LLC All Rights Reserved.
|
|
906
|
+
*
|
|
907
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
908
|
+
* found in the LICENSE file at https://angular.io/license
|
|
909
|
+
*/
|
|
910
|
+
function _getPlatform(platformFactory, options) {
|
|
911
|
+
const extraProviders = options.extraProviders ? options.extraProviders : [];
|
|
912
|
+
return platformFactory([
|
|
913
|
+
{ provide: INITIAL_CONFIG, useValue: { document: options.document, url: options.url } },
|
|
914
|
+
extraProviders
|
|
915
|
+
]);
|
|
916
|
+
}
|
|
917
|
+
function _render(platform, moduleRefPromise) {
|
|
918
|
+
return moduleRefPromise.then((moduleRef) => {
|
|
919
|
+
const transitionId = moduleRef.injector.get(ɵTRANSITION_ID, null);
|
|
920
|
+
if (!transitionId) {
|
|
921
|
+
throw new Error(`renderModule[Factory]() requires the use of BrowserModule.withServerTransition() to ensure
|
|
922
|
+
the server-rendered app can be properly bootstrapped into a client app.`);
|
|
923
|
+
}
|
|
924
|
+
const applicationRef = moduleRef.injector.get(ApplicationRef);
|
|
925
|
+
return applicationRef.isStable.pipe((first((isStable) => isStable)))
|
|
926
|
+
.toPromise()
|
|
927
|
+
.then(() => {
|
|
928
|
+
const platformState = platform.injector.get(PlatformState);
|
|
929
|
+
const asyncPromises = [];
|
|
930
|
+
// Run any BEFORE_APP_SERIALIZED callbacks just before rendering to string.
|
|
931
|
+
const callbacks = moduleRef.injector.get(BEFORE_APP_SERIALIZED, null);
|
|
932
|
+
if (callbacks) {
|
|
933
|
+
for (const callback of callbacks) {
|
|
934
|
+
try {
|
|
935
|
+
const callbackResult = callback();
|
|
936
|
+
if (ɵisPromise(callbackResult)) {
|
|
937
|
+
// TODO: in TS3.7, callbackResult is void.
|
|
938
|
+
asyncPromises.push(callbackResult);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
catch (e) {
|
|
942
|
+
// Ignore exceptions.
|
|
943
|
+
console.warn('Ignoring BEFORE_APP_SERIALIZED Exception: ', e);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
const complete = () => {
|
|
948
|
+
const output = platformState.renderToString();
|
|
949
|
+
platform.destroy();
|
|
950
|
+
return output;
|
|
951
|
+
};
|
|
952
|
+
if (asyncPromises.length === 0) {
|
|
953
|
+
return complete();
|
|
954
|
+
}
|
|
955
|
+
return Promise
|
|
956
|
+
.all(asyncPromises.map(asyncPromise => {
|
|
957
|
+
return asyncPromise.catch(e => {
|
|
958
|
+
console.warn('Ignoring BEFORE_APP_SERIALIZED Exception: ', e);
|
|
959
|
+
});
|
|
960
|
+
}))
|
|
961
|
+
.then(complete);
|
|
962
|
+
});
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
966
|
+
* Renders a Module to string.
|
|
967
|
+
*
|
|
968
|
+
* `document` is the full document HTML of the page to render, as a string.
|
|
969
|
+
* `url` is the URL for the current render request.
|
|
970
|
+
* `extraProviders` are the platform level providers for the current render request.
|
|
971
|
+
*
|
|
972
|
+
* @publicApi
|
|
973
|
+
*/
|
|
974
|
+
function renderModule(module, options) {
|
|
975
|
+
const platform = _getPlatform(platformDynamicServer, options);
|
|
976
|
+
return _render(platform, platform.bootstrapModule(module));
|
|
977
|
+
}
|
|
978
|
+
/**
|
|
979
|
+
* Renders a {@link NgModuleFactory} to string.
|
|
980
|
+
*
|
|
981
|
+
* `document` is the full document HTML of the page to render, as a string.
|
|
982
|
+
* `url` is the URL for the current render request.
|
|
983
|
+
* `extraProviders` are the platform level providers for the current render request.
|
|
984
|
+
*
|
|
985
|
+
* @publicApi
|
|
986
|
+
*
|
|
987
|
+
* @deprecated
|
|
988
|
+
* This symbol is no longer necessary as of Angular v13.
|
|
989
|
+
* Use {@link renderModule} API instead.
|
|
990
|
+
*/
|
|
991
|
+
function renderModuleFactory(moduleFactory, options) {
|
|
992
|
+
const platform = _getPlatform(platformServer, options);
|
|
993
|
+
return _render(platform, platform.bootstrapModuleFactory(moduleFactory));
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
/**
|
|
997
|
+
* @license
|
|
998
|
+
* Copyright Google LLC All Rights Reserved.
|
|
999
|
+
*
|
|
1000
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
1001
|
+
* found in the LICENSE file at https://angular.io/license
|
|
1002
|
+
*/
|
|
1003
|
+
|
|
1004
|
+
/**
|
|
1005
|
+
* @license
|
|
1006
|
+
* Copyright Google LLC All Rights Reserved.
|
|
1007
|
+
*
|
|
1008
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
1009
|
+
* found in the LICENSE file at https://angular.io/license
|
|
1010
|
+
*/
|
|
1011
|
+
/**
|
|
1012
|
+
* @publicApi
|
|
1013
|
+
*/
|
|
1014
|
+
const VERSION = new Version('13.0.0-rc.2');
|
|
1015
|
+
|
|
1016
|
+
/**
|
|
1017
|
+
* @license
|
|
1018
|
+
* Copyright Google LLC All Rights Reserved.
|
|
1019
|
+
*
|
|
1020
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
1021
|
+
* found in the LICENSE file at https://angular.io/license
|
|
1022
|
+
*/
|
|
1023
|
+
|
|
1024
|
+
/**
|
|
1025
|
+
* @license
|
|
1026
|
+
* Copyright Google LLC All Rights Reserved.
|
|
1027
|
+
*
|
|
1028
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
1029
|
+
* found in the LICENSE file at https://angular.io/license
|
|
1030
|
+
*/
|
|
1031
|
+
// This file only reexports content of the `src` folder. Keep it that way.
|
|
1032
|
+
|
|
1033
|
+
/**
|
|
1034
|
+
* @license
|
|
1035
|
+
* Copyright Google LLC All Rights Reserved.
|
|
1036
|
+
*
|
|
1037
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
1038
|
+
* found in the LICENSE file at https://angular.io/license
|
|
1039
|
+
*/
|
|
1040
|
+
|
|
1041
|
+
/**
|
|
1042
|
+
* Generated bundle index. Do not edit.
|
|
1043
|
+
*/
|
|
1044
|
+
|
|
1045
|
+
export { BEFORE_APP_SERIALIZED, INITIAL_CONFIG, PlatformState, ServerModule, ServerTransferStateModule, VERSION, platformDynamicServer, platformServer, renderModule, renderModuleFactory, INTERNAL_SERVER_PLATFORM_PROVIDERS as ɵINTERNAL_SERVER_PLATFORM_PROVIDERS, SERVER_RENDER_PROVIDERS as ɵSERVER_RENDER_PROVIDERS, ServerRendererFactory2 as ɵServerRendererFactory2 };
|
|
1046
|
+
//# sourceMappingURL=platform-server.mjs.map
|