fix(WebWorker): remove the platform-browser dependency on compiler

This commit is contained in:
Victor Berchet
2016-05-13 13:22:29 -07:00
parent a01a54c180
commit 6e62217b78
92 changed files with 1331 additions and 496 deletions

View File

@ -2,7 +2,7 @@
<h2 class="page-title">Drafts</h2>
<ol class="inbox-list">
<li *ngFor="#item of items" class="inbox-item-record">
<li *ngFor="let item of items" class="inbox-item-record">
<a id="item-{{ item.id }}"
[routerLink]="['/detail', item.id]">
{{ item.subject }}</a>

View File

@ -2,7 +2,7 @@
<h2 class="page-title">Inbox</h2>
<ol class="inbox-list">
<li *ngFor="#item of items" class="inbox-item-record">
<li *ngFor="let item of items" class="inbox-item-record">
<a id="item-{{ item.id }}"
[routerLink]="['/detail', item.id]">{{ item.subject }}</a>
</li>

View File

@ -2,7 +2,7 @@ import {InboxApp} from './app/inbox-app';
import {provide} from '@angular/core';
import {bootstrap} from '@angular/platform-browser-dynamic';
import {HashLocationStrategy, LocationStrategy} from '@angular/common';
import {ROUTER_PROVIDERS} from '@angular/router';
import {ROUTER_PROVIDERS} from '@angular/router-deprecated';
export function main() {
bootstrap(InboxApp,

View File

@ -8,12 +8,9 @@ declare var System: any;
writeScriptTag('/all/playground/vendor/long-stack-trace-zone.js');
writeScriptTag('/all/playground/vendor/system.src.js');
writeScriptTag('/all/playground/vendor/Reflect.js');
writeScriptTag('/all/playground/vendor/Rx.js', 'playgroundBootstrap()');
writeScriptTag('/all/playground/vendor/rxjs/bundles/Rx.js', 'playgroundBootstrap()');
global.playgroundBootstrap = playgroundBootstrap;
////////
function playgroundBootstrap() {
// check query param
var useBundles = location.search.indexOf('bundles=false') == -1;
@ -54,7 +51,8 @@ declare var System: any;
'@angular/compiler': {main: 'index.js', defaultExtension: 'js'},
'@angular/common': {main: 'index.js', defaultExtension: 'js'},
'@angular/platform-browser': {main: 'index.js', defaultExtension: 'js'},
'@angular/platform-browser-dynamic': {main: 'index.js', defaultExtension: 'js'}
'@angular/platform-browser-dynamic': {main: 'index.js', defaultExtension: 'js'},
'@angular/router': {main: 'index.js', defaultExtension: 'js'},
// 'rxjs': {
// defaultExtension: 'js'
// }

View File

@ -1,6 +1,6 @@
import {bootstrap} from '@angular/platform-browser-dynamic';
import {Component} from '@angular/core';
import {KeyEventsPlugin} from '@angular/platform-browser/src/dom/events/key_events';
import {KeyEventsPlugin} from '@angular/platform-browser';
@Component({
selector: 'key-events-app',

View File

@ -0,0 +1,124 @@
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
;(function (exports) {
'use strict';
var Arr = (typeof Uint8Array !== 'undefined')
? Uint8Array
: Array
var PLUS = '+'.charCodeAt(0)
var SLASH = '/'.charCodeAt(0)
var NUMBER = '0'.charCodeAt(0)
var LOWER = 'a'.charCodeAt(0)
var UPPER = 'A'.charCodeAt(0)
var PLUS_URL_SAFE = '-'.charCodeAt(0)
var SLASH_URL_SAFE = '_'.charCodeAt(0)
function decode (elt) {
var code = elt.charCodeAt(0)
if (code === PLUS ||
code === PLUS_URL_SAFE)
return 62 // '+'
if (code === SLASH ||
code === SLASH_URL_SAFE)
return 63 // '/'
if (code < NUMBER)
return -1 //no match
if (code < NUMBER + 10)
return code - NUMBER + 26 + 26
if (code < UPPER + 26)
return code - UPPER
if (code < LOWER + 26)
return code - LOWER + 26
}
function b64ToByteArray (b64) {
var i, j, l, tmp, placeHolders, arr
if (b64.length % 4 > 0) {
throw new Error('Invalid string. Length must be a multiple of 4')
}
// the number of equal signs (place holders)
// if there are two placeholders, than the two characters before it
// represent one byte
// if there is only one, then the three characters before it represent 2 bytes
// this is just a cheap hack to not do indexOf twice
var len = b64.length
placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
// base64 is 4/3 + up to two characters of the original data
arr = new Arr(b64.length * 3 / 4 - placeHolders)
// if there are placeholders, only get up to the last complete 4 chars
l = placeHolders > 0 ? b64.length - 4 : b64.length
var L = 0
function push (v) {
arr[L++] = v
}
for (i = 0, j = 0; i < l; i += 4, j += 3) {
tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
push((tmp & 0xFF0000) >> 16)
push((tmp & 0xFF00) >> 8)
push(tmp & 0xFF)
}
if (placeHolders === 2) {
tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
push(tmp & 0xFF)
} else if (placeHolders === 1) {
tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
push((tmp >> 8) & 0xFF)
push(tmp & 0xFF)
}
return arr
}
function uint8ToBase64 (uint8) {
var i,
extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
output = "",
temp, length
function encode (num) {
return lookup.charAt(num)
}
function tripletToBase64 (num) {
return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
}
// go through the array every three bytes, we'll deal with trailing stuff later
for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
output += tripletToBase64(temp)
}
// pad the end with zeros, but make sure to not forget the extra bytes
switch (extraBytes) {
case 1:
temp = uint8[uint8.length - 1]
output += encode(temp >> 2)
output += encode((temp << 4) & 0x3F)
output += '=='
break
case 2:
temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
output += encode(temp >> 10)
output += encode((temp >> 4) & 0x3F)
output += encode((temp << 2) & 0x3F)
output += '='
break
}
return output
}
exports.toByteArray = b64ToByteArray
exports.fromByteArray = uint8ToBase64
}(typeof exports === 'undefined' ? (this.base64js = {}) : exports))

View File

@ -1,5 +1,5 @@
import {ImageDemo} from './index_common';
import {bootstrapApp} from '../../../../@angular/platform-browser/src/worker_app';
import {bootstrapApp} from '@angular/platform-browser-dynamic';
export function main() {
bootstrapApp(ImageDemo);

View File

@ -1,6 +1,5 @@
import {Provider} from '@angular/core';
import {
bootstrapRender,
} from '../../../../@angular/platform-browser/src/worker_render';
import {bootstrapRender} from '@angular/platform-browser-dynamic';
bootstrapRender("loader.js");
export function main() {
bootstrapRender("loader.js");
}

View File

@ -1,19 +1,38 @@
$SCRIPTS$
importScripts("b64.js");
importScripts("../../../vendor/es6-shim.js",
"../../../vendor/zone.js",
"../../../vendor/long-stack-trace-zone.js",
"../../../vendor/system.src.js",
"../../../vendor/Reflect.js",
"b64.js");
System.config({
baseURL: '/',
baseURL: '/all',
map: {'rxjs': '/all/playground/vendor/rxjs'},
packages: {
'@angular/core': {main: 'index.js', defaultExtension: 'js'},
'@angular/compiler': {main: 'index.js', defaultExtension: 'js'},
'@angular/common': {main: 'index.js', defaultExtension: 'js'},
'@angular/platform-browser': {main: 'index.js', defaultExtension: 'js'},
'@angular/platform-browser-dynamic': {main: 'index.js', defaultExtension: 'js'},
'@angular/router': {main: 'index.js', defaultExtension: 'js'},
'rxjs': {
defaultExtension: 'js'
}
},
defaultJSExtensions: true
});
System.import("playground/src/web_workers/images/background_index")
.then(
function(m) {
try {
m.main();
} catch (e) {
console.error(e);
}
},
function(error) { console.error("error loading background", error); });
.then(
function(m) {
try {
m.main();
} catch (e) {
console.error(e);
}
},
function(error) { console.error("error loading background", error); });

View File

@ -1,5 +1,5 @@
import {InputCmp} from './index_common';
import {bootstrapApp} from '../../../../@angular/platform-browser/src/worker_app';
import {bootstrapApp} from '@angular/platform-browser-dynamic';
export function main() {
bootstrapApp(InputCmp);

View File

@ -1,4 +1,5 @@
import {Provider} from '@angular/core';
import {bootstrapRender} from '../../../../@angular/platform-browser/src/worker_render';
import {bootstrapRender} from '@angular/platform-browser-dynamic';
bootstrapRender("loader.js");
export function main() {
bootstrapRender("loader.js");
}

View File

@ -1,17 +1,37 @@
$SCRIPTS$
importScripts("../../../vendor/es6-shim.js",
"../../../vendor/zone.js",
"../../../vendor/long-stack-trace-zone.js",
"../../../vendor/system.src.js",
"../../../vendor/Reflect.js");
System.config({
baseURL: '/',
baseURL: '/all',
map: {'rxjs': '/all/playground/vendor/rxjs'},
packages: {
'@angular/core': {main: 'index.js', defaultExtension: 'js'},
'@angular/compiler': {main: 'index.js', defaultExtension: 'js'},
'@angular/common': {main: 'index.js', defaultExtension: 'js'},
'@angular/platform-browser': {main: 'index.js', defaultExtension: 'js'},
'@angular/platform-browser-dynamic': {main: 'index.js', defaultExtension: 'js'},
'@angular/router': {main: 'index.js', defaultExtension: 'js'},
'rxjs': {
defaultExtension: 'js'
}
},
defaultJSExtensions: true
});
System.import("playground/src/web_workers/input/background_index")
.then(
function(m) {
try {
m.main();
} catch (e) {
console.error(e);
}
},
function(error) { console.error("error loading background", error); });
.then(
function(m) {
try {
m.main();
} catch (e) {
console.error(e);
}
},
function(error) { console.error("error loading background", error); });

View File

@ -1,5 +1,5 @@
import {HelloCmp} from './index_common';
import {bootstrapApp} from '../../../../@angular/platform-browser/src/worker_app';
import {bootstrapApp} from '@angular/platform-browser-dynamic';
export function main() {
bootstrapApp(HelloCmp);

View File

@ -1,4 +1,5 @@
import {Provider} from '@angular/core';
import {bootstrapRender} from '../../../../@angular/platform-browser/src/worker_render';
import {bootstrapRender} from '@angular/platform-browser-dynamic';
bootstrapRender("loader.js");
export function main() {
bootstrapRender("loader.js");
}

View File

@ -1,17 +1,37 @@
$SCRIPTS$
importScripts("../../../vendor/es6-shim.js",
"../../../vendor/zone.js",
"../../../vendor/long-stack-trace-zone.js",
"../../../vendor/system.src.js",
"../../../vendor/Reflect.js");
System.config({
baseURL: '/',
baseURL: '/all',
map: {'rxjs': '/all/playground/vendor/rxjs'},
packages: {
'@angular/core': {main: 'index.js', defaultExtension: 'js'},
'@angular/compiler': {main: 'index.js', defaultExtension: 'js'},
'@angular/common': {main: 'index.js', defaultExtension: 'js'},
'@angular/platform-browser': {main: 'index.js', defaultExtension: 'js'},
'@angular/platform-browser-dynamic': {main: 'index.js', defaultExtension: 'js'},
'@angular/router': {main: 'index.js', defaultExtension: 'js'},
'rxjs': {
defaultExtension: 'js'
},
},
defaultJSExtensions: true
});
System.import("playground/src/web_workers/kitchen_sink/background_index")
.then(
function(m) {
try {
m.main();
} catch (e) {
console.error(e);
}
},
function(error) { console.error("error loading background", error); });
.then(
function(m) {
try {
m.main();
} catch (e) {
console.error(e);
}
},
function(error) { console.error("error loading background", error); });

View File

@ -1,4 +1,4 @@
import {bootstrapApp} from '../../../../@angular/platform-browser/src/worker_app';
import {bootstrapApp} from '@angular/platform-browser-dynamic';
import {App} from './index_common';
export function main() {

View File

@ -1,15 +1,14 @@
import {Provider, ApplicationRef} from '@angular/core';
import {
bootstrapRender,
UiArguments,
FnArg,
PRIMITIVE,
ClientMessageBrokerFactory
} from '../../../../@angular/platform-browser/src/worker_render';
import {ApplicationRef} from '@angular/core';
import {bootstrapRender} from '@angular/platform-browser-dynamic';
// TODO
import {UiArguments, FnArg, PRIMITIVE, ClientMessageBrokerFactory} from '@angular/platform-browser';
const ECHO_CHANNEL = "ECHO";
bootstrapRender("loader.js").then((ref) => afterBootstrap(ref));
export function main() {
bootstrapRender("loader.js").then((ref) => afterBootstrap(ref));
}
function afterBootstrap(ref: ApplicationRef) {
let brokerFactory: ClientMessageBrokerFactory = ref.injector.get(ClientMessageBrokerFactory);

View File

@ -1,7 +1,6 @@
import {PromiseWrapper} from '@angular/core/src/facade/async';
import {Component} from '@angular/core';
import {ServiceMessageBrokerFactory, PRIMITIVE} from '@angular/platform-browser/src/worker_app';
;
const ECHO_CHANNEL = "ECHO";

View File

@ -1,17 +1,37 @@
$SCRIPTS$
importScripts("../../../vendor/es6-shim.js",
"../../../vendor/zone.js",
"../../../vendor/long-stack-trace-zone.js",
"../../../vendor/system.src.js",
"../../../vendor/Reflect.js");
System.config({
baseURL: '/',
baseURL: '/all',
map: {'rxjs': '/all/playground/vendor/rxjs'},
packages: {
'@angular/core': {main: 'index.js', defaultExtension: 'js'},
'@angular/compiler': {main: 'index.js', defaultExtension: 'js'},
'@angular/common': {main: 'index.js', defaultExtension: 'js'},
'@angular/platform-browser': {main: 'index.js', defaultExtension: 'js'},
'@angular/platform-browser-dynamic': {main: 'index.js', defaultExtension: 'js'},
'@angular/router': {main: 'index.js', defaultExtension: 'js'},
'rxjs': {
defaultExtension: 'js'
},
},
defaultJSExtensions: true
});
System.import("playground/src/web_workers/message_broker/background_index")
.then(
function(m) {
try {
m.main();
} catch (e) {
console.error(e);
}
},
function(error) { console.error("error loading background", error); });
.then(
function(m) {
try {
m.main();
} catch (e) {
console.error(e);
}
},
function(error) { console.error("error loading background", error); });

View File

@ -1,12 +1,15 @@
import {Provider} from '@angular/core';
import {
bootstrapApp,
WORKER_APP_ROUTER
} from '../../../../@angular/platform-browser/src/worker_app';
import {ROUTER_PROVIDERS} from '@angular/router-deprecated';
import {bootstrapApp} from '@angular/platform-browser-dynamic';
import {WORKER_APP_LOCATION_PROVIDERS} from '@angular/platform-browser';
import {HashLocationStrategy, LocationStrategy} from '@angular/common';
import {App} from './index_common';
export function main() {
bootstrapApp(App,
[WORKER_APP_ROUTER, {provide: LocationStrategy, useClass: HashLocationStrategy}]);
bootstrapApp(App, [
ROUTER_PROVIDERS,
WORKER_APP_LOCATION_PROVIDERS,
{provide: LocationStrategy, useClass: HashLocationStrategy}
]);
}

View File

@ -1,6 +1,7 @@
import {
bootstrapRender,
WORKER_RENDER_ROUTER
} from '../../../../@angular/platform-browser/src/worker_render';
import {bootstrapRender} from '@angular/platform-browser-dynamic';
bootstrapRender("loader.js", WORKER_RENDER_ROUTER);
import {WORKER_RENDER_LOCATION_PROVIDERS} from '@angular/platform-browser';
export function main() {
bootstrapRender("loader.js", WORKER_RENDER_LOCATION_PROVIDERS);
}

View File

@ -1,17 +1,38 @@
$SCRIPTS$
importScripts("../../../vendor/es6-shim.js",
"../../../vendor/zone.js",
"../../../vendor/long-stack-trace-zone.js",
"../../../vendor/system.src.js",
"../../../vendor/Reflect.js");
System.config({
baseURL: '/',
baseURL: '/all',
map: {'rxjs': '/all/playground/vendor/rxjs'},
packages: {
'@angular/core': {main: 'index.js', defaultExtension: 'js'},
'@angular/compiler': {main: 'index.js', defaultExtension: 'js'},
'@angular/common': {main: 'index.js', defaultExtension: 'js'},
'@angular/platform-browser': {main: 'index.js', defaultExtension: 'js'},
'@angular/platform-browser-dynamic': {main: 'index.js', defaultExtension: 'js'},
'@angular/router': {main: 'index.js', defaultExtension: 'js'},
'@angular/router-deprecated': {main: 'index.js', defaultExtension: 'js'},
'rxjs': {
defaultExtension: 'js'
},
},
defaultJSExtensions: true
});
System.import("playground/src/web_workers/router/background_index")
.then(
function(m) {
try {
m.main();
} catch (e) {
console.error(e);
}
},
function(error) { console.error("error loading background", error); });
.then(
function(m) {
try {
m.main();
} catch (e) {
console.error(e);
}
},
function(error) { console.error("error loading background", error); });

View File

@ -1,5 +1,5 @@
import {TodoApp} from './index_common';
import {bootstrapApp} from '../../../../@angular/platform-browser/src/worker_app';
import {bootstrapApp} from '@angular/platform-browser-dynamic';
export function main() {
bootstrapApp(TodoApp);

View File

@ -1,4 +1,5 @@
import {Provider} from '@angular/core';
import {bootstrapRender} from '../../../../@angular/platform-browser/src/worker_render';
import {bootstrapRender} from '@angular/platform-browser-dynamic';
bootstrapRender("loader.js");
export function main() {
bootstrapRender("loader.js");
}

View File

@ -1,17 +1,37 @@
$SCRIPTS$
importScripts("../../../vendor/es6-shim.js",
"../../../vendor/zone.js",
"../../../vendor/long-stack-trace-zone.js",
"../../../vendor/system.src.js",
"../../../vendor/Reflect.js");
System.config({
baseURL: '/',
baseURL: '/all',
map: {'rxjs': '/all/playground/vendor/rxjs'},
packages: {
'@angular/core': {main: 'index.js', defaultExtension: 'js'},
'@angular/compiler': {main: 'index.js', defaultExtension: 'js'},
'@angular/common': {main: 'index.js', defaultExtension: 'js'},
'@angular/platform-browser': {main: 'index.js', defaultExtension: 'js'},
'@angular/platform-browser-dynamic': {main: 'index.js', defaultExtension: 'js'},
'@angular/router': {main: 'index.js', defaultExtension: 'js'},
'rxjs': {
defaultExtension: 'js'
}
},
defaultJSExtensions: true
});
System.import("playground/src/web_workers/todo/background_index")
.then(
function(m) {
try {
m.main();
} catch (e) {
console.error(e);
}
},
function(error) { console.error("error loading background", error); });
.then(
function(m) {
try {
m.main();
} catch (e) {
console.error(e);
}
},
function(error) { console.error("error loading background", error); });