Commit bce4325a authored by Ασπασία Κατσή's avatar Ασπασία Κατσή

Merge branch 'develop' into 'develop'

Develop

See merge request !293
parents 83d65678 f8da7dd2
dist/*
source/app.settings.ts
node_modules/*
!node_modules/zone.js/
!drupal/
drupal/*
!drupal/modules/
......
Language: JavaScript
BasedOnStyle: Google
ColumnLimit: 100
# http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
build/
build-esm/
blink-core/
blink-idl/
parsed-idl/
/node_modules
.idea
.vscode
npm-debug.log
build-esm/
language: node_js
sudo: false
node_js:
- '6.3.1'
env:
global:
- BROWSER_PROVIDER_READY_FILE=/tmp/sauce-connect-ready
- LOGS_DIR=/tmp/angular-templating-build/logs
- SAUCE_USERNAME=angular-ci
- SAUCE_ACCESS_KEY=9b988f434ff8-fbca-8aa4-4ae3-35442987
# Token for tsd to increase github rate limit
# See https://github.com/DefinitelyTyped/tsd#tsdrc
# This does not use http://docs.travis-ci.com/user/environment-variables/#Secure-Variables
# because those are not visible for pull requests, and those should also be reliable.
# This SSO token belongs to github account angular-github-ratelimit-token which has no access
# (password is in Valentine)
- TSD_GITHUB_TOKEN=ef474500309daea53d5991b3079159a29520a40b
before_script:
- mkdir -p $LOGS_DIR
- ./scripts/sauce/sauce_connect_setup.sh
- ./scripts/sauce/sauce_connect_block.sh
script:
- node_modules/.bin/gulp lint
- node_modules/.bin/gulp format:enforce
- node_modules/.bin/gulp build
- scripts/closure/closure_compiler.sh
- node_modules/.bin/gulp promisetest
- npm run test:phantomjs-single
- node_modules/.bin/karma start karma-dist-sauce-jasmine.conf.js --single-run
- node_modules/.bin/karma start karma-build-sauce-mocha.conf.js --single-run
- node_modules/.bin/karma start karma-dist-sauce-selenium3-jasmine.conf.js --single-run
- node_modules/.bin/karma start karma-build-sauce-selenium3-mocha.conf.js --single-run
- node_modules/.bin/gulp test/node
- node simple-server.js 2>&1> server.log&
- node ./test/webdriver/test.sauce.js
\ No newline at end of file
This diff is collapsed.
Submitting Changes
------------------
Do NOT submit changes to the built files in the `dist` folder. These are generated before
releases.
To run tests
------------
Make sure your environment is set up with:
`npm install`
In a separate process, run the WebSockets server:
`npm run ws-server`
Run the browser tests using Karma:
`npm test`
Run the node.js tests:
`npm run test-node`
Run tslint:
`npm run lint`
Run format with clang-format:
`npm run format`
Run all checks (lint/format/browser test/test-node):
`npm run ci`
Before Commit
------------
Please make sure you pass all following checks before commit
- gulp lint (tslint)
- gulp format:enforce (clang-format)
- gulp promisetest (promise a+ test)
- npm test (karma browser test)
- gulp test-node (node test)
You can run
`npm run ci`
to do all those checks for you.
You can also add the script into your git pre-commit hook
```
echo -e 'exec npm run ci' > .git/hooks/pre-commit
chmod u+x .git/hooks/pre-commit
```
Webdriver Test
--------------
`zone.js` also supports running webdriver e2e tests.
1. run locally
```
npm run webdriver-start
npm run webdriver-http
npm run webdriver-test
```
2. run locally with sauce connect
```
// export SAUCE_USERNAME and SAUCE_ACCESS_KEY
export SAUCE_USERNAME=XXXX
export SAUCE_ACCESS_KEY=XXX
sc -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY
npm run webdriver-http
npm run webdriver-sauce-test
```
\ No newline at end of file
The MIT License
Copyright (c) 2016 Google, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
/**
@license
The MIT License
Copyright (c) 2016 Google, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
# Modules
Starting from zone.js v0.8.9, you can choose which web API modules you want to patch as to reduce overhead introduced by the patching of these modules. For example,
the below samples show how to disable some modules. You just need to define a few global variables
before loading zone.js.
```
<script>
__Zone_disable_Error = true; // Zone will not patch Error
__Zone_disable_on_property = true; // Zone will not patch onProperty such as button.onclick
__Zone_disable_geolocation = true; // Zone will not patch geolocation API
__Zone_disable_toString = true; // Zone will not patch Function.prototype.toString
__Zone_disable_blocking = true; // Zone will not patch alert/prompt/confirm
__Zone_disable_PromiseRejectionEvent = true; // Zone will not patch PromiseRejectionEventHandler
</script>
<script src="../dist/zone.js"></script>
```
Below is the full list of currently supported modules.
- Common
|Module Name|Behavior with zone.js patch|How to disable|
|--|--|--|
|Error|stack frames will have the Zone's name information, (By default, Error patch will not be loaded by zone.js)|__Zone_disable_Error = true|
|toString|Function.toString will be patched to return native version of toString|__Zone_disable_toString = true|
|ZoneAwarePromise|Promise.then will be patched as Zone aware MicroTask|__Zone_disable_ZoneAwarePromise = true|
|bluebird|Bluebird will use Zone.scheduleMicroTask as async scheduler. (By default, bluebird patch will not be loaded by zone.js)|__Zone_disable_bluebird = true|
- Browser
|Module Name|Behavior with zone.js patch|How to disable|
|--|--|--|
|on_property|target.onProp will become zone aware target.addEventListener(prop)|__Zone_disable_on_property = true|
|timers|setTimeout/setInterval/setImmediate will be patched as Zone MacroTask|__Zone_disable_timer = true|
|requestAnimationFrame|requestAnimationFrame will be patched as Zone MacroTask|__Zone_disable_requestAnimationFrame = true|
|blocking|alert/prompt/confirm will be patched as Zone.run|__Zone_disable_blocking = true|
|EventTarget|target.addEventListener will be patched as Zone aware EventTask|__Zone_disable_EventTarget = true|
|IE BrowserTools check|in IE, browser tool will not use zone patched eventListener|__Zone_disable_IE_check = true|
|CrossContext check|in webdriver, enable check event listener is cross context|__Zone_enable_cross_context_check = true|
|XHR|XMLHttpRequest will be patched as Zone aware MacroTask|__Zone_disable_XHR = true|
|geolocation|navigator.geolocation's prototype will be patched as Zone.run|__Zone_disable_geolocation = true|
|PromiseRejectionEvent|PromiseRejectEvent will fire when ZoneAwarePromise has unhandled error|__Zone_disable_PromiseRejectionEvent = true|
|mediaQuery|mediaQuery addListener API will be patched as Zone aware EventTask. (By default, mediaQuery patch will not be loaded by zone.js) |__Zone_disable_mediaQuery = true|
|notification|notification onProperties API will be patched as Zone aware EventTask. (By default, notification patch will not be loaded by zone.js) |__Zone_disable_notification = true|
- NodeJS
|Module Name|Behavior with zone.js patch|How to disable|
|--|--|--|
|node_timers|NodeJS patch timer|__Zone_disable_node_timers = true|
|fs|NodeJS patch fs function as macroTask|__Zone_disable_fs = true|
|EventEmitter|NodeJS patch EventEmitter as Zone aware EventTask|__Zone_disable_EventEmitter = true|
|nextTick|NodeJS patch process.nextTick as microTask|__Zone_disable_nextTick = true|
|handleUnhandledPromiseRejection|NodeJS handle unhandledPromiseRejection from ZoneAwarePromise|__Zone_disable_handleUnhandledPromiseRejection = true|
|crypto|NodeJS patch crypto function as macroTask|__Zone_disable_crypto = true|
- on_property
You can also disable specific on_properties by setting `__Zone_ignore_on_properties` as follows: for example,
if you want to disable `window.onmessage` and `HTMLElement.prototype.onclick` from zone.js patching,
you can do like this.
```
<script>
__Zone_ignore_on_properties = [
{
target: window,
ignoreProperties: ['message']
}, {
target: HTMLElement.prototype,
ignoreProperties: ['click']
}
];
</script>
<script src="../dist/zone.js"></script>
```
- Angular(2+)
Angular uses zone.js to manage async operations and decide when to perform change detection. Thus, in Angular,
the following APIs should be patched, otherwise Angular may not work as expected.
1. ZoneAwarePromise
2. timer
3. on_property
4. EventTarget
5. XHR
\ No newline at end of file
# Zone.js's support for non standard apis
Zone.js patched most standard APIs such as DOM event listeners, XMLHttpRequest in Browser, EventEmitter and fs API in Node.js so they can be in zone.
But there are still a lot of non standard APIs that are not patched by default, such as MediaQuery, Notification,
WebAudio and so on. We are adding support to those APIs, and our progress is updated here.
## Currently supported non standard Web APIs
* MediaQuery
* Notification
## Currently supported polyfills
* webcomponents
Usage:
```
<script src="webcomponents-lite.js"></script>
<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/zone.js/dist/webapis-shadydom.js"></script>
```
## Currently supported non standard node APIs
## Currently supported non standard common APIs
* bluebird promise
Browser Usage:
```
<script src="zone.js"></script>
<script src="bluebird.js"></script>
<script src="zone-bluebird.js"></script>
<script>
Zone[Zone['__symbol__']('bluebird')](Promise);
</script>
```
After those steps, window.Promise will become a ZoneAware Bluebird Promise.
Node Sample Usage:
```
require('zone.js');
const Bluebird = require('bluebird');
require('zone.js/dist/zone-bluebird');
Zone[Zone['__symbol__']('bluebird')](Bluebird);
Zone.current.fork({
name: 'bluebird'
}).run(() => {
Bluebird.resolve(1).then(r => {
console.log('result ', r, 'Zone', Zone.current.name);
});
});
```
In NodeJS environment, you can choose to use Bluebird Promise as global.Promise
or use ZoneAwarePromise as global.Promise.
To run the jasmine test cases of bluebird
```
npm install bluebird
```
then modify test/node_tests.ts
remove the comment of the following line
```
//import './extra/bluebird.spec';
```
## Others
* Cordova
patch `cordova.exec` API
`cordova.exec(success, error, service, action, args);`
`success` and `error` will be patched with `Zone.wrap`.
to load the patch, you should load in the following order.
```
<script src="zone.js"></script>
<script src="cordova.js"></script>
<script src="zone-patch-cordova.js"></script>
```
## Usage
By default, those APIs' support will not be loaded in zone.js or zone-node.js,
so if you want to load those API's support, you should load those files by yourself.
For example, if you want to add MediaQuery patch, you should do like this:
```
<script src="path/zone.js"></script>
<script src="path/webapis-media-query.js"></script>
```
* rxjs
`zone.js` also provide a `rxjs` patch to make sure rxjs Observable/Subscription/Operator run in correct zone.
For details please refer to [pull request 843](https://github.com/angular/zone.js/pull/843). The following sample code describes the idea.
```
const constructorZone = Zone.current.fork({name: 'constructor'});
const subscriptionZone = Zone.current.fork({name: 'subscription'});
const operatorZone = Zone.current.fork({name: 'operator'});
let observable;
let subscriber;
constructorZone.run(() => {
observable = new Observable((_subscriber) => {
subscriber = _subscriber;
console.log('current zone when construct observable:', Zone.current.name); // will output constructor.
return () => {
console.log('current zone when unsubscribe observable:', Zone.current.name); // will output constructor.
}
});
});
subscriptionZone.run(() => {
observable.subscribe(() => {
console.log('current zone when subscription next', Zone.current.name); // will output subscription.
}, () => {
console.log('current zone when subscription error', Zone.current.name); // will output subscription.
}, () => {
console.log('current zone when subscription complete', Zone.current.name); // will output subscription.
});
});
operatorZone.run(() => {
observable.map(() => {
console.log('current zone when map operator', Zone.current.name); // will output operator.
});
});
```
Currently basically everything the `rxjs` API includes
- Observable
- Subscription
- Subscriber
- Operators
- Scheduler
is patched, so each asynchronous call will run in the correct zone.
## Usage.
For example, in an Angular application, you can load this patch in your `app.module.ts`.
```
import 'zone.js/dist/zone-patch-rxjs';
```
# Zone.js
[![Build Status](https://travis-ci.org/angular/zone.js.png)](https://travis-ci.org/angular/zone.js)
[![CDNJS](https://img.shields.io/cdnjs/v/zone.js.svg)](https://cdnjs.com/libraries/zone.js)
Implements _Zones_ for JavaScript, inspired by [Dart](https://www.dartlang.org/articles/zones/).
> If you're using zone.js via unpkg please provide a query param `?main=browser`
`https://unpkg.com/zone.js?main=browser`
> If you're using any of the following libraries, make sure you import them first
> * 'newrelic' as it patches global.Promise before zone.js does
> * 'async-listener' as it patches global.setTimeout, global.setInterval before zone.js does
> * 'continuation-local-storage' as it uses async-listener
# NEW Zone.js POST-v0.6.0
See the new API [here](./dist/zone.js.d.ts).
Read up on [Zone Primer](https://docs.google.com/document/d/1F5Ug0jcrm031vhSMJEOgp1l-Is-Vf0UCNDY-LsQtAIY).
## What's a Zone?
A Zone is an execution context that persists across async tasks.
You can think of it as [thread-local storage](http://en.wikipedia.org/wiki/Thread-local_storage) for JavaScript VMs.
See this video from ng-conf 2014 for a detailed explanation:
[![screenshot of the zone.js presentation and ng-conf 2014](/presentation.png)](//www.youtube.com/watch?v=3IqtmUscE_U)
## See also
* [async-listener](https://github.com/othiym23/async-listener) - a similar library for node
* [Async stack traces in Chrome](http://www.html5rocks.com/en/tutorials/developertools/async-call-stack/)
* [strongloop/zone](https://github.com/strongloop/zone) (Deprecated)
* [vizone](https://github.com/gilbox/vizone) - control flow visualizer that uses zone.js
## Standard API support
zone.js patched most standard web APIs(such as DOM events, XMLHttpRequest...) and nodejs APIs
(EventEmitter,fs ...), for more details, please see [STANDARD-APIS.md](STANDARD-APIS.md).
## Non standard API support
We are adding support to some non standard APIs, such as MediaQuery and
Notification. Please see [NON-STANDARD-APIS.md](NON-STANDARD-APIS.md) for more details.
## Modules
zone.js patches the async APIs described above, but those patches will have some overhead.
Starting from zone.js v0.8.9, you can choose which web API module you want to patch.
For more details, please
see [MODULE.md](MODULE.md).
## Promise A+ test passed
[![Promises/A+ 1.1 compliant](https://promisesaplus.com/assets/logo-small.png)](https://promisesaplus.com/)
## License
MIT
# Zone.js's support for standard apis
Zone.js patched most standard APIs such as DOM event listeners, XMLHttpRequest in Browser, EventEmitter and fs API in Node.js so they can be in zone.
In this document, all patched API are listed.
For non-standard APIs, please see [NON-STANDARD-APIS.md](NON-STANDARD-APIS.md)
## Patch Mechanisms
There are several patch mechanisms
- wrap: makes callbacks run in zones, and makes applications able to receive onInvoke and onIntercept callbacks
- Task: just like in the JavaScript VM, applications can receive onScheduleTask, onInvokeTask, onCancelTask and onHasTask callbacks
1. MacroTask
2. MicroTask
3. EventTask
Some APIs which should be treated as Tasks, but are currently still patched in the wrap way. These will be patched as Tasks soon.
## Browser
Web APIs
| API | Patch Mechanism | Others |
| --- | --- | --- |
| setTimeout/clearTimeout | MacroTask | app can get handlerId, interval, args, isPeriodic(false) through task.data |
| setImmediate/clearImmediate | MacroTask | same with setTimeout |
| setInterval/clearInterval | MacroTask | isPeriodic is true, so setInterval will not trigger onHasTask callback |
| requestAnimationFrame/cancelAnimationFrame | MacroTask | |
| mozRequestAnimationFrame/mozCancelAnimationFrame | MacroTask | |
| webkitRequestAnimationFrame/webkitCancelAnimationFrame | MacroTask | |
| alert | wrap | |
| prompt | wrap | |
| confirm | wrap | |
| Promise | MicroTask | |
| EventTarget | EventTask | see below Event Target for more details |
| HTMLElement on properties | EventTask | see below on properties for more details |
| XMLHttpRequest.send/abort | MacroTask | |
| XMLHttpRequest on properties | EventTask | |
| IDBIndex on properties | EventTask | |
| IDBRequest on properties | EventTask | |
| IDBOpenDBRequest on properties | EventTask | |
| IDBDatabaseRequest on properties | EventTask | |
| IDBTransaction on properties | EventTask | |
| IDBCursor on properties | EventTask | |
| WebSocket on properties | EventTask | |
| MutationObserver | wrap | |
| WebkitMutationObserver | wrap | |
| FileReader | wrap | |
| registerElement | wrap | |
EventTarget
- For browsers supporting EventTarget, Zone.js just patches EventTarget, so everything that inherits
from EventTarget will also be patched.
- For browsers that do not support EventTarget, Zone.js will patch the following APIs in the IDL
that inherit from EventTarget
|||||
|---|---|---|---|
|ApplicationCache|EventSource|FileReader|InputMethodContext|
|MediaController|MessagePort|Node|Performance|
|SVGElementInstance|SharedWorker|TextTrack|TextTrackCue|
|TextTrackList|WebKitNamedFlow|Window|Worker|
|WorkerGlobalScope|XMLHttpRequest|XMLHttpRequestEventTarget|XMLHttpRequestUpload|
|IDBRequest|IDBOpenDBRequest|IDBDatabase|IDBTransaction|
|IDBCursor|DBIndex|WebSocket|
The following 'on' properties, such as onclick, onreadystatechange, are patched in Zone.js as EventTasks
|||||
|---|---|---|---|
|copy|cut|paste|abort|
|blur|focus|canplay|canplaythrough|
|change|click|contextmenu|dblclick|
|drag|dragend|dragenter|dragleave|
|dragover|dragstart|drop|durationchange|
|emptied|ended|input|invalid|
|keydown|keypress|keyup|load|
|loadeddata|loadedmetadata|loadstart|message|
|mousedown|mouseenter|mouseleave|mousemove|
|mouseout|mouseover|mouseup|pause|
|play|playing|progress|ratechange|
|reset|scroll|seeked|seeking|
|select|show|stalled|submit|
|suspend|timeupdate|volumechange|waiting|
|mozfullscreenchange|mozfullscreenerror|mozpointerlockchange|mozpointerlockerror|
|error|webglcontextrestored|webglcontextlost|webglcontextcreationerror|
## NodeJS
| API | Patch Mechanism | Others |
| --- | --- | --- |
| setTimeout/clearTimeout | MacroTask | app can get handlerId, interval, args, isPeriodic(false) through task.data |
| setImmediate/clearImmediate | MacroTask | same with setTimeout |
| setInterval/clearInterval | MacroTask | isPeriodic is true, so setInterval will not trigger onHasTask callback |
| process.nextTick | Microtask | isPeriodic is true, so setInterval will not trigger onHasTask callback |
| Promise | MicroTask | |
| EventEmitter | EventTask | All APIs inherit EventEmitter are patched as EventTask |
| crypto | MacroTask | |
| fs | MacroTask | all async methods are patched |
EventEmitter, addEventListener, prependEventListener and 'on' will be patched once as EventTasks, and removeEventListener and
removeAllListeners will remove those EventTasks
## Electron
</