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.
Add preboot support to ng-render (you can give it a configuration JSO…
…N or a static JSON string in the command-line arguments, and it will inject preboot into the application)
- Loading branch information
Showing
10 changed files
with
171 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import {PrebootConfiguration} from '../application/contracts'; | ||
|
||
import {JsonSchema, ValidatorResult} from '../transformation'; | ||
|
||
const prebootSchema = new JsonSchema({ | ||
$schema: 'http://json-schema.org/draft-04/schema#', | ||
type: 'object', | ||
oneOf: [ | ||
{required: ['appRoot']}, | ||
{required: ['serverClientRoot']} | ||
], | ||
properties: { | ||
appRoot: { | ||
anyOf: [ | ||
{type: 'string'}, | ||
{type: 'array', items: {type: 'string'}} | ||
] | ||
}, | ||
serverClientRoot: { | ||
type: 'array', | ||
items: { | ||
type: 'object', | ||
properties: { | ||
clientSelector: {type: 'string'}, | ||
serverSelector: {type: 'string'} | ||
}, | ||
}, | ||
}, | ||
buffer: {type: 'boolean'}, | ||
uglify: {type: 'boolean'}, | ||
noInlineCache: {type: 'boolean'}, | ||
eventSelectors: { | ||
type: 'array', | ||
items: { | ||
type: 'object', | ||
properties: { | ||
selector: {type: 'string'}, | ||
events: { | ||
type: 'array', | ||
items: {type: 'string'} | ||
}, | ||
keyCodes: { | ||
type: 'array', | ||
items: {type: 'number'}, | ||
}, | ||
preventDefault: {type: 'boolean'}, | ||
freeze: {type: 'boolean'}, | ||
noReplay: {type: 'boolean'} | ||
} | ||
}, | ||
}, | ||
} | ||
}); | ||
|
||
export const validatePrebootOptionsAgainstSchema = | ||
(configuration: PrebootConfiguration): ValidatorResult => prebootSchema.validate(configuration); |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from './array'; | ||
export * from './flatten'; | ||
export * from './json'; | ||
export * from './schema'; | ||
export * from './type-to-function'; |
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,15 @@ | ||
import {Schema, Validator, ValidatorResult} from 'jsonschema'; | ||
|
||
export {ValidatorResult}; | ||
|
||
export class JsonSchema { | ||
constructor(private schema: Schema) {} | ||
|
||
add(schema: Schema) {} | ||
|
||
validate<T>(document: T): ValidatorResult { | ||
const validator = new Validator(); | ||
|
||
return validator.validate(document, this.schema, {allowUnknownAttributes: false}); | ||
} | ||
} |