forked from rangle/angular-ssr
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring of location implementation (it now conforms to both Locat…
…ion and PlatformLocation and can therefore be used in either context)
- Loading branch information
Showing
15 changed files
with
118 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import chalk = require('chalk'); | ||
|
||
import {PlatformException} from '../../exception'; | ||
|
||
const assertionFailure = (identifier: string) => { | ||
console.error(chalk.red(`This application is executing in a context where '${identifier}' is defined`)); | ||
console.error(chalk.red(`This is completely unexpected and unsupported`)); | ||
console.error(chalk.red('Please ensure that you have not imported a conflicting DOM library like jsdom!')); | ||
|
||
throw new PlatformException(`Running in a browserless environment but '${identifier}' is non-null!`); | ||
} | ||
|
||
if (typeof window !== 'undefined') { | ||
assertionFailure('window'); | ||
} | ||
|
||
if (typeof document !== 'undefined') { | ||
assertionFailure('document'); | ||
} | ||
|
||
if (typeof Zone === 'undefined') { | ||
throw new PlatformException(`Zone is undefined (import zone.js into this process)`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
export const forkZone = <R>(documentTemplate: string, requestUri: string, execute: () => Promise<R>): Promise<R> => { | ||
return new Promise((resolve, reject) => { | ||
const zone = Zone.current.fork({ | ||
name: requestUri, | ||
properties: { | ||
documentTemplate, | ||
requestUri, | ||
}, | ||
onHandleError: function (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, error) { | ||
reject(error); | ||
let failure = (exception: Error) => true; // rethrow | ||
|
||
const zone = Zone.current.fork({ | ||
name: requestUri, | ||
properties: { | ||
documentTemplate, | ||
requestUri, | ||
}, | ||
onHandleError: function (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, error) { | ||
return failure(error); | ||
} | ||
}); | ||
|
||
return false; | ||
} | ||
}); | ||
return new Promise((resolve, reject) => { | ||
failure = exception => { | ||
reject(exception); | ||
return false; | ||
}; | ||
|
||
return zone.runGuarded(() => { | ||
execute().then(r => resolve(r)).catch(exception => reject(exception)); | ||
}) as R; | ||
return zone.runGuarded(() => Promise.resolve(execute()).then(resolve).catch(reject)) as R; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,11 @@ | ||
import {NotImplementedException} from '../../exception'; | ||
import {NotSupportedException} from '../../exception'; | ||
|
||
import domino = require('domino'); | ||
|
||
function stop() { | ||
throw new NotImplementedException(); | ||
} | ||
function stop() {} | ||
|
||
function close() {} | ||
|
||
function open(url: string, name: string, specs, replace) { | ||
return domino.createWindow(String(), url); | ||
throw new NotSupportedException(); | ||
}; | ||
|
||
export const bindControl = (target: () => Window) => ({open, close: close.bind(target), stop}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters