├── .gitignore ├── Dockerfile ├── Makefile ├── README.md ├── build └── deps.makefile ├── deps ├── angular │ └── angular.version ├── closure-compiler │ └── closure-compiler.version ├── closure-externs │ └── closure-externs.version ├── closure-library │ └── closure-library.version ├── clutz │ └── clutz.version ├── gradle │ └── gradle.version ├── node │ ├── node.version │ └── node.version.darwin ├── rxjs │ └── rxjs.version ├── symbol-observable │ └── symbol-observable.version └── tsickle │ └── tsickle.version ├── index.html ├── js └── app │ ├── externs │ ├── jasmine-2.0.js │ ├── misc.js │ ├── reflect_externs.js │ └── zone_externs.js │ ├── statement.js │ └── tslib │ └── tslib.es6.js ├── package.json └── ts └── app ├── basic.html ├── basic.ts ├── bootstrap.ts ├── greeter.ts └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | deps/closure-compiler/closure-compiler 2 | deps/closure-externs/closure-externs 3 | deps/closure-library/closure-library 4 | deps/clutz/clutz 5 | deps/gradle/gradle 6 | deps/node/node 7 | deps/tsickle/tsickle 8 | deps/angular/angular 9 | deps/rxjs/rxjs 10 | deps/symbol-observable/symbol-observable 11 | 12 | js/closure-library 13 | js/tsickle_externs.js 14 | js/clutz-externs 15 | js/bin 16 | js/app/ts 17 | js/closure-node-modules 18 | 19 | ts/app/definitions/clutz 20 | ts/app/basic.ngfactory.ts 21 | 22 | node_modules/ 23 | 24 | build/**/.* 25 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | 3 | RUN apt-get update && apt-get install -y openjdk-7-jdk build-essential git curl unzip nodejs vim python gyp 4 | 5 | RUN curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - 6 | RUN apt-get install -y nodejs 7 | RUN npm install -g npm 8 | 9 | RUN locale-gen en_US.UTF-8 10 | ENV LANG en_US.UTF-8 11 | ENV LANGUAGE en_US:en 12 | ENV LC_ALL en_US.UTF-8 13 | 14 | RUN useradd -ms /bin/bash foo 15 | 16 | ENV HOME /home/foo 17 | USER foo 18 | 19 | WORKDIR /home/foo 20 | 21 | RUN git clone https://github.com/lucidsoftware/closure-typescript-example.git 22 | RUN cd closure-typescript-example && make all -j 8 23 | CMD cd closure-typescript-example && make run 24 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .DEFAULT_GOAL := all 2 | 3 | all: js depsfile 4 | 5 | .PHONY: run 6 | run: js depsfile 7 | python -m SimpleHTTPServer 8000 8 | 9 | define HELP_TEXT 10 | all - make js and depsfile (compiled and uncompiled) 11 | run - make compiled and uncompiled js and run a webserver on port 8000 12 | deps - locally install all dependencies 13 | 14 | js - compile all js 15 | ts - compile all ts 16 | clutz - generate ts definition file from closure js 17 | depsfile - generate the deps.js file needed for uncompiled mode 18 | 19 | clean-app - remove all generated files - does NOT uninstall dependencies 20 | clean - remove all generated files and uninstalls all dependencies 21 | clean-* - remove files created by target * 22 | help - print this message 23 | endef 24 | export HELP_TEXT 25 | 26 | .PHONY: help 27 | help: 28 | $(info $(HELP_TEXT)) 29 | 30 | UNAME_S := $(shell uname -s) 31 | 32 | LEFT_PAREN := ( 33 | RIGHT_PAREN := ) 34 | 35 | # js 36 | JS_ROOT := js/app 37 | TS_OUTPUT_DIR := $(JS_ROOT)/ts 38 | JS_BIN_PATH := js/bin 39 | JS_EXTERNS_ROOT := $(JS_ROOT)/externs 40 | CLUTZ_EXTERNS_ROOT := js/clutz-externs 41 | JS_CLOSURE_LIBRARY_ROOTS := js/closure-library/closure/goog js/closure-library/third_party 42 | CLOSURE_NODE_MODULES_ROOT := js/closure-node-modules 43 | 44 | JS_SOURCES = $(sort \ 45 | $(shell find $(JS_ROOT) \ 46 | -type f \ 47 | -name "*.js" \ 48 | ) \ 49 | ) 50 | JS_SOURCES_NO_TS = $(sort \ 51 | $(shell find $(JS_ROOT) \ 52 | -not -path "$(TS_OUTPUT_DIR)/*" \ 53 | -type f \ 54 | -name "*.js" \ 55 | ) \ 56 | ) 57 | BASE_JS = $(sort \ 58 | $(shell find $(JS_CLOSURE_LIBRARY_ROOTS) \ 59 | -not -name "*_test.js" \ 60 | -type f \ 61 | -name "base.js" \ 62 | ) \ 63 | ) 64 | CLOSURE_JS = $(sort \ 65 | $(shell find $(JS_CLOSURE_LIBRARY_ROOTS) \ 66 | -not -name "*_test.js" \ 67 | -type f \ 68 | -name "*.js" \ 69 | ) \ 70 | ) 71 | JS_EXTERNS = $(shell find $(JS_EXTERNS_ROOT) -type f -name '*.js') 72 | CLUTZ_EXTERNS = $(shell find $(CLUTZ_EXTERNS_ROOT) -type f -name '*.js') 73 | 74 | # --externs=$(TS_EXTERNS_PATH) 75 | 76 | js: $(JS_BIN_PATH)/main.js 77 | .PHONY: $(JS_BIN_PATH)/main.js 78 | $(JS_BIN_PATH)/main.js: $(JS_SOURCES) $(JS_EXTERNS) build/.ngc-output build/.closure-compiler build/.npm-install 79 | mkdir -p $(JS_BIN_PATH) 80 | $(CLOSURE_COMPILE) \ 81 | $(JS_EXTERNS:%=--externs %) \ 82 | --js_output_file=$(JS_BIN_PATH)/main.js \ 83 | --language_in=ES6_STRICT \ 84 | --language_out=ES5 \ 85 | --compilation_level=ADVANCED \ 86 | --entry_point="js.app.ts.bootstrap" \ 87 | --variable_renaming_report=$(JS_BIN_PATH)/variable_renaming_report \ 88 | --property_renaming_report=$(JS_BIN_PATH)/property_renaming_report \ 89 | --use_types_for_optimization true \ 90 | --dependency_mode=STRICT \ 91 | $(JS_ROOT:%='%/**.js') \ 92 | '!$(JS_EXTERNS_ROOT)/**.js' \ 93 | '$(CLOSURE_NODE_MODULES_ROOT)/angular/core/esm/**.js' \ 94 | '$(CLOSURE_NODE_MODULES_ROOT)/angular/common/esm/**.js' \ 95 | '$(CLOSURE_NODE_MODULES_ROOT)/angular/compiler/esm/**.js' \ 96 | '$(CLOSURE_NODE_MODULES_ROOT)/angular/platform-browser/esm/**.js' \ 97 | '$(CLOSURE_NODE_MODULES_ROOT)/rxjs-closure/**.js' \ 98 | '$(CLOSURE_NODE_MODULES_ROOT)/symbol-observable/es/**.js' 99 | 100 | clean-js: 101 | rm -rf $(JS_BIN_PATH) 102 | 103 | # ts 104 | TS_ROOT := ts/app 105 | TS_DEFINITIONS_ROOT := $(TS_ROOT)/definitions 106 | CLUTZ_DEFINITIONS_ROOT := $(TS_DEFINITIONS_ROOT)/clutz 107 | TS_SOURCES := $(shell find $(TS_ROOT) \ 108 | -type f \ 109 | -name '*.ts' \ 110 | -not -name "*.ngfactory.ts" \ 111 | ) 112 | TSCONFIG := $(shell find $(TS_ROOT) -type f -name 'tsconfig.json') 113 | TS_EXTERNS_PATH := js/tsickle_externs.js 114 | 115 | # TypeScript compiler options are in ts/tsconfig.json 116 | ts: build/.ngc-output 117 | build/.ngc-output: build/.npm-install build/.tsickle $(TS_SOURCES) $(TSCONFIG) build/.clutz-output 118 | mkdir -p $(TS_OUTPUT_DIR) 119 | node_modules/.bin/ngc -p $(TS_ROOT) 120 | @> $@ 121 | 122 | clean-ts: 123 | rm -rf $(TS_ROOT)/*.ngfactory.ts build/.ngc-output $(TS_OUTPUT_DIR) 124 | 125 | clean: clean-deps \ 126 | clean-js \ 127 | clean-ts 128 | rm -rf $(CLUTZ_EXTERNS_ROOT) 129 | 130 | clean-app: clean-clutz \ 131 | clean-js \ 132 | clean-ts 133 | 134 | # external makefiles 135 | include build/deps.makefile 136 | 137 | essential: $(DEPS_FILE) 138 | 139 | .PHONY: js/bin/deps.js 140 | DEPS_FILE := $(JS_BIN_PATH)/deps.js 141 | depsfile: $(DEPS_FILE) 142 | $(DEPS_FILE): $(JS_SOURCES) $(CLOSURE_JS) build/.closure-library build/.ngc-output 143 | python js/closure-library/closure/bin/build/depswriter.py \ 144 | $(foreach root, $(CLOSURE_NODE_MODULES_ROOT) $(JS_ROOT) $(JS_CLOSURE_LIBRARY_ROOTS), --root_with_prefix "$(root) $(patsubst %,../../../../%,$(root))") \ 145 | --output_file="$(DEPS_FILE)" 146 | clean-depsfile: 147 | rm $(DEPS_FILE) 148 | 149 | CLUTZ_OUTPUT_PATH := $(CLUTZ_DEFINITIONS_ROOT)/main.d.ts 150 | CLUTZ_CLOSURE_DEF_PATH := $(CLUTZ_DEFINITIONS_ROOT)/closure.lib.d.ts 151 | 152 | clutz: build/.clutz-output 153 | build/.clutz-output: build/.clutz build/.closure-library build/.closure-externs $(CLUTZ_EXTERNS) $(JS_SOURCES_NO_TS) 154 | mkdir -p $(CLUTZ_DEFINITIONS_ROOT) 155 | $(CLUTZ) $(foreach extern, $(CLUTZ_EXTERNS), --externs $(extern)) \ 156 | -o $(CLUTZ_OUTPUT_PATH) $(sort $(BASE_JS) $(JS_SOURCES_NO_TS)) 157 | cp $(CLUTZ_PATH)/src/resources/closure.lib.d.ts $(CLUTZ_CLOSURE_DEF_PATH) 158 | @> $@ 159 | 160 | clean-clutz: 161 | rm -f $(CLUTZ_OUTPUT_PATH) $(CLUTZ_CLOSURE_DEF_PATH) build/.clutz-output 162 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # closure-typescript-example 2 | An example of using the Google Closure Compiler with Angular 2, TypeScript, 3 | Tsickle, and Clutz. 4 | 5 | ## Usage 6 | To run the provided example, run `make run` at the root of the project. `make 7 | help` lists available make targets. 8 | 9 | ## Dependencies 10 | * Linux or Mac OSX 11 | * Make 12 | * Java 13 | * npm 14 | * python (for SimpleHTTPServer) 15 | 16 | All other dependencies will be downloaded and installed locally in the project 17 | when you run make. 18 | 19 | The project has been tested on Ubuntu 14.04. 20 | 21 | ### Custom built dependencies 22 | This project builds Closure compilable versions of Angular and its dependencies 23 | and transitive dependencies. These include RxJS and symbol-observable. 24 | 25 | The changes which make this possible have not been committed upstream. Discussion 26 | around these changes can be found at https://github.com/angular/angular/issues/8550. 27 | The discussion is not exhaustive. If you have any questions, the build process and 28 | changes to the source of the dependencies are the best documentation. 29 | 30 | ## Docker 31 | A Docker container exists for this repository. To see the project in action, 32 | just run the Docker container and go to `localhost:8000`. 33 | 34 | To run the docker container: 35 | ``` 36 | docker pull jjudd/closure-typescript-example 37 | docker run -t -i -p 8000:8000 --net=host jjudd/closure-typescript-example 38 | ``` 39 | 40 | Then open a browser and go to `localhost:8000`. This loads the example in 41 | compiled mode. 42 | 43 | To switch between compiled and uncompiled: 44 | 45 | ``` 46 | localhost:8000/index.html?compiled=1 47 | localhost:8000/index.html?compiled=0 48 | ``` 49 | 50 | If you want to play around with the source in the container, you can launch 51 | the container as follows 52 | 53 | ``` 54 | docker run -t -i -p 8000:8000 --net=host jjudd/closure-typescript-example /bin/bash 55 | ``` 56 | -------------------------------------------------------------------------------- /build/deps.makefile: -------------------------------------------------------------------------------- 1 | deps: build/.clutz \ 2 | build/.node \ 3 | build/.npm-install \ 4 | build/.tsickle \ 5 | build/.closure-compiler \ 6 | build/.closure-externs \ 7 | build/.closure-library \ 8 | build/.gradle \ 9 | build/.rxjs \ 10 | build/.angular \ 11 | build/.symbol-observable 12 | 13 | clean-deps: clean-build/.clutz \ 14 | clean-build/.node \ 15 | clean-build/.npm-install \ 16 | clean-build/.tsickle \ 17 | clean-build/.closure-compiler \ 18 | clean-build/.closure-externs \ 19 | clean-build/.closure-library \ 20 | clean-build/.gradle \ 21 | clean-build/.rxjs \ 22 | clean-build/.angular \ 23 | clean-build/.symbol-observable 24 | rm -rf $(CLOSURE_NODE_MODULES_ROOT) 25 | 26 | # clutz 27 | CLUTZ_ROOT := deps/clutz 28 | CLUTZ_PATH := $(CLUTZ_ROOT)/clutz 29 | CLUTZ := $(abspath $(CLUTZ_PATH)/build/install/clutz/bin/clutz) 30 | CLUTZ_VERSION := $(CLUTZ_ROOT)/clutz.version 31 | 32 | build/.clutz: $(CLUTZ_VERSION) build/.gradle 33 | rm -rf $(CLUTZ_PATH) 34 | mkdir -p $(CLUTZ_PATH) 35 | curl -L `cat $<` | tar xz -C $(CLUTZ_PATH) --strip-components=1 36 | cd $(CLUTZ_PATH) && $(GRADLE) build installDist || exit 1 37 | @> $@ 38 | 39 | clean-build/.clutz: clean-clutz 40 | rm -rf $(CLUTZ_PATH) build/.clutz 41 | 42 | # node and npm 43 | NODE_ROOT := deps/node 44 | NODE_PATH := $(NODE_ROOT)/node 45 | 46 | NODE_VERSION := $(NODE_ROOT)/node.version 47 | ifeq ($(UNAME_S),Darwin) 48 | NODE_VERSION := $(NODE_ROOT)/node.version.darwin 49 | endif 50 | 51 | NODE := $(abspath $(NODE_PATH)/bin/node) 52 | NPM := $(abspath node_modules/.bin/npm) --nodedir=$(abspath $(NODE_PATH)) 53 | 54 | build/.node: $(NODE_VERSION) 55 | rm -rf $(NODE_PATH) 56 | mkdir -p $(NODE_PATH) 57 | curl -L `cat $<` | tar xJ -C $(NODE_PATH) --strip-components=1 58 | $(NODE_PATH)/bin/npm install npm@3.9.6 59 | @> $@ 60 | 61 | clean-build/.node: 62 | rm -rf $(NODE_PATH) build/.node 63 | 64 | build/.npm-install: package.json build/.node build/.angular build/.rxjs build/.symbol-observable 65 | $(NPM) install 66 | @> $@ 67 | 68 | clean-build/.npm-install: 69 | rm -rf node_modules build/.npm-install 70 | 71 | # tsickle 72 | TSICKLE_ROOT := deps/tsickle 73 | TSICKLE_PATH := $(TSICKLE_ROOT)/tsickle 74 | TSICKLE := $(NODE) $(abspath $(TSICKLE_PATH)/build/src/main.js) 75 | TSICKLE_VERSION := $(TSICKLE_ROOT)/tsickle.version 76 | 77 | build/.tsickle: $(TSICKLE_VERSION) build/.node 78 | rm -rf $(TSICKLE_PATH) 79 | mkdir -p $(TSICKLE_PATH) 80 | curl -L `cat $<` | tar xz -C $(TSICKLE_PATH) --strip-components=1 81 | cd $(TSICKLE_PATH) && $(NPM) install || exit 1 82 | @> $@ 83 | 84 | clean-build/.tsickle: 85 | rm -rf $(TSICKLE_PATH) build/.tsickle 86 | 87 | # closure compiler 88 | CLOSURE_COMPILER_ROOT := deps/closure-compiler 89 | CLOSURE_COMPILER_PATH := $(CLOSURE_COMPILER_ROOT)/closure-compiler 90 | CLOSURE_JAR := $(CLOSURE_COMPILER_PATH)/closure-compiler.jar 91 | CLOSURE_COMPILE := java -jar $(CLOSURE_JAR) 92 | CLOSURE_COMPILER_VERSION := $(CLOSURE_COMPILER_ROOT)/closure-compiler.version 93 | 94 | build/.closure-compiler: $(CLOSURE_COMPILER_VERSION) 95 | rm -rf $(CLOSURE_COMPILER_PATH) 96 | mkdir -p $(CLOSURE_COMPILER_PATH) 97 | curl -L `cat $<` -o $(CLOSURE_JAR) 98 | @> $@ 99 | 100 | clean-build/.closure-compiler: 101 | rm -rf $(CLOSURE_COMPILER_PATH) build/.closure-compiler 102 | 103 | # closure compiler externs 104 | CLOSURE_EXTERNS_ROOT := deps/closure-externs 105 | CLOSURE_EXTERNS_PATH := $(CLOSURE_EXTERNS_ROOT)/closure-externs 106 | CLOSURE_EXTERNS_DESTINATION := $(CLUTZ_EXTERNS_ROOT)/closure 107 | CLOSURE_EXTERNS_VERSION := $(CLOSURE_EXTERNS_ROOT)/closure-externs.version 108 | 109 | build/.closure-externs: $(CLOSURE_EXTERNS_VERSION) 110 | rm -rf $(CLOSURE_EXTERNS_PATH) $(CLOSURE_EXTERNS_DESTINATION) 111 | mkdir -p $(CLOSURE_EXTERNS_PATH) $(JS_EXTERNS_ROOT) $(CLOSURE_EXTERNS_DESTINATION) 112 | curl -L `cat $<` | tar xz -C $(CLOSURE_EXTERNS_PATH) --strip-components=1 113 | cp -r $(CLOSURE_EXTERNS_PATH)/externs/ $(CLOSURE_EXTERNS_DESTINATION) 114 | @> $@ 115 | 116 | clean-build/.closure-externs: 117 | rm -rf $(CLOSURE_EXTERNS_PATH) \ 118 | $(CLOSURE_EXTERNS_DESTINATION) \ 119 | build/.closure-externs 120 | 121 | # closure library 122 | CLOSURE_LIBRARY_ROOT := deps/closure-library 123 | CLOSURE_LIBRARY_PATH := js/closure-library 124 | CLOSURE_LIBRARY_VERSION := $(CLOSURE_LIBRARY_ROOT)/closure-library.version 125 | 126 | build/.closure-library: $(CLOSURE_LIBRARY_VERSION) 127 | rm -rf $(CLOSURE_LIBRARY_PATH) 128 | mkdir -p $(CLOSURE_LIBRARY_PATH) 129 | curl -L `cat $<` | tar xz -C $(CLOSURE_LIBRARY_PATH) --strip-components=1 130 | @> $@ 131 | 132 | clean-build/.closure-library: 133 | rm -rf $(CLOSURE_LIBRARY_PATH) build/.closure-library 134 | 135 | # gradle 136 | GRADLE_ROOT := deps/gradle 137 | GRADLE_PATH := $(GRADLE_ROOT)/gradle 138 | GRADLE := $(abspath $(GRADLE_PATH)/bin/gradle) 139 | GRADLE_ZIP := $(GRADLE_ROOT)/gradle.zip 140 | GRADLE_VERSION := $(GRADLE_ROOT)/gradle.version 141 | 142 | build/.gradle: $(GRADLE_VERSION) 143 | rm -rf $(GRADLE_PATH) 144 | mkdir -p $(GRADLE_PATH) 145 | curl -o $(GRADLE_ZIP) -L `cat $<` 146 | unzip -d $(GRADLE_PATH) $(GRADLE_ZIP) 147 | mv $(GRADLE_PATH)/gradle-*/* $(GRADLE_PATH) 148 | rm -f $(GRADLE_ZIP) 149 | @> $@ 150 | 151 | clean-build/.gradle: 152 | rm -rf $(GRADLE_PATH) build/.gradle 153 | 154 | # angular 155 | ANGULAR_ROOT := deps/angular 156 | ANGULAR_PATH := $(ANGULAR_ROOT)/angular 157 | ANGULAR_VERSION := $(ANGULAR_ROOT)/angular.version 158 | ANGULAR_DEST := $(CLOSURE_NODE_MODULES_ROOT)/angular 159 | 160 | build/.angular: $(ANGULAR_VERSION) build/.node build/.tsickle 161 | rm -rf $(ANGULAR_PATH) 162 | mkdir -p $(ANGULAR_PATH) 163 | curl -L `cat $<` | tar xz -C $(ANGULAR_PATH) --strip-components=1 164 | cd $(ANGULAR_PATH) && \ 165 | npm install --ignore-scripts $(abspath $(TSICKLE_PATH)) && \ 166 | $(NPM) install && ./build.sh 167 | for pkg in `find $(ANGULAR_PATH)/dist/packages-dist -name package.json`; do \ 168 | sed -i 's/0.0.0-PLACEHOLDER/2.0.0-rc.6-snap/g' $$pkg; \ 169 | sed -i 's/5.0.0-beta.6/5.0.0-beta.9/g' $$pkg; \ 170 | done 171 | for pkg in `find $(ANGULAR_PATH)/dist/packages-dist/*/esm/ -name "*.js"`; do \ 172 | sed -i 's$$^\(.*static \)$$/** @nocollapse */\n\1$$g' $$pkg; \ 173 | done 174 | mkdir -p $(ANGULAR_DEST) 175 | cp -r $(ANGULAR_PATH)/dist/packages-dist/* $(ANGULAR_DEST) 176 | cp -r $(ANGULAR_PATH)/dist/tools/@angular/tsc-wrapped $(ANGULAR_DEST) 177 | @> $@ 178 | 179 | clean-build/.angular: 180 | rm -rf $(ANGULAR_PATH) $(ANGULAR_DEST) build/.angular 181 | 182 | # rxjs 183 | RXJS_ROOT := deps/rxjs 184 | RXJS_PATH := $(RXJS_ROOT)/rxjs 185 | RXJS_VERSION := $(RXJS_ROOT)/rxjs.version 186 | RXJS_DEST := $(CLOSURE_NODE_MODULES_ROOT)/rxjs-closure 187 | 188 | build/.rxjs: $(RXJS_VERSION) build/.tsickle build/.node 189 | rm -rf $(RXJS_PATH) 190 | mkdir -p $(RXJS_PATH) 191 | curl -L `cat $<` | tar xz -C $(RXJS_PATH) --strip-components=1 192 | cd $(RXJS_PATH) && \ 193 | $(NPM) install $(abspath $(TSICKLE_PATH)) && \ 194 | $(NPM) install && \ 195 | for js in `find dist/closure -name "*.js"`; do \ 196 | sed -i "s/goog.module('dist.closure/goog.module('rxjs/g" $$js; \ 197 | sed -i "s/goog.require('dist.closure/goog.require('rxjs/g" $$js; \ 198 | sed -i "s/(this && this.__assign) ||//g" $$js; \ 199 | sed -i "s/(this && this.__decorate) ||//g" $$js; \ 200 | sed -i "s/(this && this.__metadata) ||//g" $$js; \ 201 | sed -i "s/(this && this.__awaiter) ||//g" $$js; \ 202 | sed -i "s/(this && this.__param) ||//g" $$js; \ 203 | sed -i "s/(this && this.__extends) ||//g" $$js; \ 204 | done 205 | mkdir -p $(RXJS_DEST) && cp -r $(RXJS_PATH)/dist/closure/* $(RXJS_DEST) 206 | @> $@ 207 | 208 | clean-build/.rxjs: 209 | rm -rf $(RXJS_PATH) $(RXJS_DEST) build/.rxjs 210 | 211 | # symbol-observable 212 | SYMBOL_OBSERVABLE_ROOT := deps/symbol-observable 213 | SYMBOL_OBSERVABLE_PATH := $(SYMBOL_OBSERVABLE_ROOT)/symbol-observable 214 | SYMBOL_OBSERVABLE_VERSION := $(SYMBOL_OBSERVABLE_ROOT)/symbol-observable.version 215 | SYMBOL_OBSERVABLE_DEST := $(CLOSURE_NODE_MODULES_ROOT)/symbol-observable 216 | 217 | build/.symbol-observable: $(SYMBOL_OBSERVABLE_VERSION) build/.node 218 | rm -rf $(SYMBOL_OBSERVABLE_PATH) 219 | mkdir -p $(SYMBOL_OBSERVABLE_PATH) 220 | curl -L `cat $<` | tar xz -C $(SYMBOL_OBSERVABLE_PATH) --strip-components=1 221 | cd $(SYMBOL_OBSERVABLE_PATH) && \ 222 | $(NPM) install 223 | mkdir -p $(SYMBOL_OBSERVABLE_DEST) && cp -r $(SYMBOL_OBSERVABLE_PATH)/* $(SYMBOL_OBSERVABLE_DEST) 224 | @> $@ 225 | 226 | clean-build/.symbol-observable: 227 | rm -rf $(SYMBOL_OBSERVABLE_PATH) $(SYMBOL_OBSERVABLE_DEST) build/.symbol-observable 228 | -------------------------------------------------------------------------------- /deps/angular/angular.version: -------------------------------------------------------------------------------- 1 | https://github.com/lucidsoftware/angular/archive/582ad836cb4a35d11fc8d7f922d6f8823ee4f5cf.tar.gz 2 | -------------------------------------------------------------------------------- /deps/closure-compiler/closure-compiler.version: -------------------------------------------------------------------------------- 1 | http://central.maven.org/maven2/com/google/javascript/closure-compiler/v20160713/closure-compiler-v20160713.jar -------------------------------------------------------------------------------- /deps/closure-externs/closure-externs.version: -------------------------------------------------------------------------------- 1 | https://github.com/google/closure-compiler/archive/v20160713.tar.gz -------------------------------------------------------------------------------- /deps/closure-library/closure-library.version: -------------------------------------------------------------------------------- 1 | https://github.com/google/closure-library/archive/v20160619.tar.gz -------------------------------------------------------------------------------- /deps/clutz/clutz.version: -------------------------------------------------------------------------------- 1 | https://github.com/lucidsoftware/clutz/archive/17e5d4d037151b924b76f8a6c3a64a7095b33681.tar.gz 2 | -------------------------------------------------------------------------------- /deps/gradle/gradle.version: -------------------------------------------------------------------------------- 1 | https://services.gradle.org/distributions/gradle-2.14-bin.zip 2 | -------------------------------------------------------------------------------- /deps/node/node.version: -------------------------------------------------------------------------------- 1 | https://nodejs.org/dist/v4.4.5/node-v4.4.5-linux-x64.tar.xz 2 | -------------------------------------------------------------------------------- /deps/node/node.version.darwin: -------------------------------------------------------------------------------- 1 | https://nodejs.org/dist/v4.4.5/node-v4.4.5-darwin-x64.tar.gz -------------------------------------------------------------------------------- /deps/rxjs/rxjs.version: -------------------------------------------------------------------------------- 1 | https://github.com/lucidsoftware/rxjs/archive/129b630b1b578d19d7192636de49c930476cf013.tar.gz 2 | 3 | -------------------------------------------------------------------------------- /deps/symbol-observable/symbol-observable.version: -------------------------------------------------------------------------------- 1 | https://github.com/lucidsoftware/symbol-observable/archive/c816eea581608882c4b081a8472298696ee98dd9.tar.gz -------------------------------------------------------------------------------- /deps/tsickle/tsickle.version: -------------------------------------------------------------------------------- 1 | https://github.com/lucidsoftware/tsickle/archive/6fbaaab03bf665e78c84b987181434b86ede4cbe.tar.gz 2 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | NG2 Compiler Testing 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /js/app/externs/jasmine-2.0.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 The Closure Compiler Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @fileoverview Externs for Jasmine 2.0 (not backwards compatibile with 1.3). 19 | * 20 | * TODO: Missing externs for JsApiReporter, real type support for defining 21 | * matchers. 22 | * 23 | * @see http://jasmine.github.io/2.0/introduction.html 24 | * @externs 25 | */ 26 | 27 | 28 | /** @const */ 29 | var jasmine = {}; 30 | 31 | 32 | /** 33 | * @param {Object} matchers 34 | */ 35 | jasmine.addMatchers = function(matchers) {}; 36 | 37 | 38 | /** 39 | * @return {!jasmine.Clock} 40 | */ 41 | jasmine.clock = function() {}; 42 | 43 | 44 | /** 45 | * @param {string} name 46 | * @param {Function=} originalFn 47 | * @return {(!Function|!jasmine.Spy)} spy 48 | */ 49 | jasmine.createSpy = function(name, originalFn) {}; 50 | 51 | 52 | /** 53 | * @param {string} baseName 54 | * @param {Array} methodNames 55 | */ 56 | jasmine.createSpyObj = function(baseName, methodNames) {}; 57 | 58 | /** 59 | * @template T 60 | * @param {function(T, T):(boolean|undefined)} tester 61 | */ 62 | jasmine.addCustomEqualityTester = function(tester) {}; 63 | 64 | 65 | /** @constructor */ 66 | jasmine.Clock = function() {}; 67 | 68 | 69 | /** */ 70 | jasmine.Clock.prototype.install = function() {}; 71 | 72 | 73 | /** */ 74 | jasmine.Clock.prototype.uninstall = function() {}; 75 | 76 | 77 | /** @param {number} ms */ 78 | jasmine.Clock.prototype.tick = function(ms) {}; 79 | 80 | 81 | /** @param {!Date} date */ 82 | jasmine.Clock.prototype.mockDate = function(date) {}; 83 | 84 | 85 | 86 | /** @constructor @template T */ 87 | jasmine.Matchers = function() {}; 88 | 89 | 90 | /** @type {jasmine.Matchers} */ 91 | jasmine.Matchers.prototype.not; 92 | 93 | 94 | /** @type {T} */ 95 | jasmine.Matchers.prototype.actual; 96 | 97 | 98 | /** @param {*} value */ 99 | jasmine.Matchers.prototype.toBe = function(value) {}; 100 | 101 | 102 | /** @return {void} */ 103 | jasmine.Matchers.prototype.toBeDefined = function() {}; 104 | 105 | 106 | /** @return {void} */ 107 | jasmine.Matchers.prototype.toBeFalsy = function() {}; 108 | 109 | 110 | /** @param {*} value */ 111 | jasmine.Matchers.prototype.toBeGreaterThan = function(value) {}; 112 | 113 | 114 | /** @param {*} value */ 115 | jasmine.Matchers.prototype.toBeLessThan = function(value) {}; 116 | 117 | 118 | /** @param {*} value */ 119 | jasmine.Matchers.prototype.toBeCloseTo = function(value, precision) {}; 120 | 121 | 122 | /** @return {void} */ 123 | jasmine.Matchers.prototype.toBeNull = function() {}; 124 | 125 | 126 | /** @return {void} */ 127 | jasmine.Matchers.prototype.toBeTruthy = function() {}; 128 | 129 | 130 | /** @return {void} */ 131 | jasmine.Matchers.prototype.toBeUndefined = function() {}; 132 | 133 | 134 | /** @return {void} */ 135 | jasmine.Matchers.prototype.toBeNaN = function() {}; 136 | 137 | 138 | /** @param {*} value */ 139 | jasmine.Matchers.prototype.toContain = function(value) {}; 140 | 141 | 142 | /** @param {*} value */ 143 | jasmine.Matchers.prototype.toEqual = function(value) {}; 144 | 145 | 146 | /** @return {void} */ 147 | jasmine.Matchers.prototype.toHaveBeenCalled = function() {}; 148 | 149 | 150 | /** @param {...*} var_args */ 151 | jasmine.Matchers.prototype.toHaveBeenCalledWith = function(var_args) {}; 152 | 153 | 154 | /** @param {(string|RegExp)} pattern */ 155 | jasmine.Matchers.prototype.toMatch = function(pattern) {}; 156 | 157 | 158 | /** @param {Error=} opt_expected */ 159 | jasmine.Matchers.prototype.toThrow = function(opt_expected) {}; 160 | 161 | 162 | /** 163 | * @param {(!Function|string|!RegExp)} errorTypeOrMessageOrPattern 164 | * @param {(string|RegExp)=} opt_messageOrPattern 165 | */ 166 | jasmine.Matchers.prototype.toThrowError = function( 167 | errorTypeOrMessageOrPattern, opt_messageOrPattern) {}; 168 | 169 | 170 | /** 171 | * @param {!Object} clazz 172 | * @return {!jasmine.Matchers} 173 | */ 174 | jasmine.any = function(clazz) {}; 175 | 176 | 177 | /** 178 | * @param {!Object} sample 179 | * @return {!jasmine.Matchers} 180 | */ 181 | jasmine.objectContaining = function(sample) {}; 182 | 183 | 184 | 185 | /** @constructor */ 186 | jasmine.Spec = function() {}; 187 | 188 | 189 | /** @type {undefined|function(): string} */ 190 | jasmine.Spec.prototype.message; 191 | 192 | 193 | /** 194 | * @param {function(this:jasmine.Spec)} after 195 | */ 196 | jasmine.Spec.prototype.after = function(after) {}; 197 | 198 | 199 | /** @param {Error|string} e */ 200 | jasmine.Spec.prototype.fail = function(e) {}; 201 | 202 | 203 | /** 204 | * @param {function()=} opt_onComplete 205 | */ 206 | jasmine.Spec.prototype.finish = function(opt_onComplete) {}; 207 | 208 | 209 | 210 | /** 211 | * @constructor 212 | * @extends {Function} 213 | */ 214 | jasmine.Spy = function() {}; 215 | 216 | 217 | /** @type {!jasmine.SpyStrategy} */ 218 | jasmine.Spy.prototype.and; 219 | 220 | 221 | /** 222 | * @return {void} 223 | */ 224 | jasmine.Spy.prototype.reset = function() {}; 225 | 226 | 227 | /** @type {!jasmine.CallTracker} */ 228 | jasmine.Spy.prototype.calls; 229 | 230 | 231 | 232 | /** 233 | * @constructor 234 | */ 235 | jasmine.CallTracker = function() {}; 236 | 237 | 238 | /** 239 | * @return {boolean} 240 | */ 241 | jasmine.CallTracker.prototype.any = function() {}; 242 | 243 | 244 | /** 245 | * @return {number} 246 | */ 247 | jasmine.CallTracker.prototype.count = function() {}; 248 | 249 | 250 | /** 251 | * @param {number} index 252 | * @return {!Array} 253 | */ 254 | jasmine.CallTracker.prototype.argsFor = function(index) {}; 255 | 256 | 257 | /** 258 | * @return {!Array.<{args: !Array, object: Object}>} 259 | */ 260 | jasmine.CallTracker.prototype.allArgs = function() {}; 261 | 262 | 263 | /** 264 | * @return {{args: !Array, object: Object}} 265 | */ 266 | jasmine.CallTracker.prototype.mostRecent = function() {}; 267 | 268 | 269 | /** 270 | * @return {!{args: !Array, object: Object}} 271 | */ 272 | jasmine.CallTracker.prototype.first = function() {}; 273 | 274 | 275 | /** @return {void} */ 276 | jasmine.CallTracker.prototype.reset = function() {}; 277 | 278 | 279 | 280 | /** 281 | * @constructor 282 | */ 283 | jasmine.SpyStrategy = function() {}; 284 | 285 | 286 | /** @return {!jasmine.Spy} */ 287 | jasmine.SpyStrategy.prototype.callThrough = function() {}; 288 | 289 | 290 | /** 291 | * @param {*} value 292 | * @return {!jasmine.Spy} 293 | */ 294 | jasmine.SpyStrategy.prototype.returnValue = function(value) {}; 295 | 296 | 297 | /** 298 | * @param {...*} var_args 299 | * @return {!jasmine.Spy} 300 | */ 301 | jasmine.SpyStrategy.prototype.returnValues = function(var_args) {}; 302 | 303 | 304 | /** 305 | * @param {*} error 306 | * @return {!jasmine.Spy} 307 | */ 308 | jasmine.SpyStrategy.prototype.throwError = function(error) {}; 309 | 310 | 311 | /** 312 | * @param {Function} fn 313 | * @return {!jasmine.Spy} 314 | */ 315 | jasmine.SpyStrategy.prototype.callFake = function(fn) {}; 316 | 317 | 318 | /** @return {!jasmine.Spy} */ 319 | jasmine.SpyStrategy.prototype.stub = function() {}; 320 | 321 | 322 | 323 | /** @constructor */ 324 | jasmine.Suite = function() {}; 325 | 326 | 327 | /** 328 | * @param {function()=} opt_onComplete 329 | */ 330 | jasmine.Suite.prototype.finish = function(opt_onComplete) {}; 331 | 332 | 333 | /** 334 | * @param {function(this:jasmine.Spec)} beforeEachFunction 335 | */ 336 | jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) {}; 337 | 338 | 339 | /** 340 | * @param {function(this:jasmine.Spec)} afterEachFunction 341 | */ 342 | jasmine.Suite.prototype.afterEach = function(afterEachFunction) {}; 343 | 344 | /** 345 | * @param {function(this:jasmine.Spec)} beforeAllFunction 346 | */ 347 | jasmine.Suite.prototype.beforeAll = function(beforeAllFunction) {}; 348 | 349 | /** 350 | * @param {function(this:jasmine.Spec)} afterAllFunction 351 | */ 352 | jasmine.Suite.prototype.afterAll = function(afterAllFunction) {}; 353 | 354 | 355 | 356 | /** @constructor */ 357 | jasmine.Env = function() {}; 358 | 359 | 360 | /** @type {jasmine.Spec} */ 361 | jasmine.Env.prototype.currentSpec; 362 | 363 | 364 | /** @return {void} */ 365 | jasmine.Env.prototype.execute = function() {}; 366 | 367 | 368 | /** @param {function(this:jasmine.Spec)} handler */ 369 | jasmine.Env.prototype.afterEach = function(handler) {}; 370 | 371 | 372 | /** @param {function(this:jasmine.Spec)} handler */ 373 | jasmine.Env.prototype.beforeEach = function(handler) {}; 374 | 375 | /** 376 | * @param {function(this:jasmine.Spec)} beforeAllFunction 377 | */ 378 | jasmine.Env.prototype.beforeAll = function(beforeAllFunction) {}; 379 | 380 | /** 381 | * @param {function(this:jasmine.Spec)} afterAllFunction 382 | */ 383 | jasmine.Env.prototype.afterAll = function(afterAllFunction) {}; 384 | 385 | 386 | /** 387 | * @return {!jasmine.Env} 388 | */ 389 | jasmine.getEnv = function() {}; 390 | 391 | 392 | /** @param {function(this:jasmine.Spec, function())} handler */ 393 | function afterEach(handler) {} 394 | 395 | 396 | /** @param {function(this:jasmine.Spec, function())} handler */ 397 | function beforeEach(handler) {} 398 | 399 | /** @param {function(this:jasmine.Spec, function())} handler */ 400 | function beforeAll(handler) {}; 401 | 402 | /** @param {function(this:jasmine.Spec, function())} handler */ 403 | function afterAll(handler) {}; 404 | 405 | 406 | /** 407 | * @param {string} description 408 | * @param {function(this:jasmine.Suite)} handler 409 | */ 410 | function describe(description, handler) {} 411 | 412 | 413 | /** 414 | * @param {string} description 415 | * @param {function(this:jasmine.Suite)} handler 416 | */ 417 | function fdescribe(description, handler) {} 418 | 419 | 420 | /** 421 | * @param {*} expectedValue 422 | * @return {jasmine.Matchers} matcher 423 | */ 424 | function expect(expectedValue) {} 425 | 426 | 427 | /** 428 | * @param {string} description 429 | * @param {function(this:jasmine.Spec, function())} handler 430 | */ 431 | function it(description, handler) {} 432 | 433 | 434 | /** 435 | * @param {string} description 436 | * @param {function(this:jasmine.Spec, function())} handler 437 | */ 438 | function fit(description, handler) {} 439 | 440 | 441 | /** 442 | * @param {Object} spiedOnObject 443 | * @param {string} methodName 444 | * @return {jasmine.Spy} spy 445 | */ 446 | function spyOn(spiedOnObject, methodName) {} 447 | 448 | 449 | /** 450 | * @nosideeffects 451 | * @param {string} description 452 | * @param {function(this:jasmine.Suite)} handler 453 | */ 454 | function xdescribe(description, handler) {} 455 | 456 | 457 | /** 458 | * @param {string} description 459 | * @param {function(this:jasmine.Spec, function()=)} handler 460 | */ 461 | function xit(description, handler) {} 462 | 463 | 464 | /** 465 | * @type {jasmine.Spec} 466 | */ 467 | var currentSpec; 468 | 469 | 470 | /** 471 | * Provided by angular-mocks.js. 472 | * @type {angular.$injector} 473 | */ 474 | jasmine.Spec.prototype.$injector; 475 | 476 | 477 | /** 478 | * Provided by angular-mocks.js. 479 | * @param {...(Function|Array)} var_args 480 | */ 481 | function inject(var_args) {} 482 | 483 | 484 | /** 485 | * Provided by angular-mocks.js. 486 | * @param {...(string|Function|Array)} var_args 487 | * @suppress {checkTypes} 488 | */ 489 | function module(var_args) {} 490 | -------------------------------------------------------------------------------- /js/app/externs/misc.js: -------------------------------------------------------------------------------- 1 | /** @type {?} */ 2 | var global = {}; 3 | 4 | /** @type {?} */ 5 | var Hammer = {}; 6 | -------------------------------------------------------------------------------- /js/app/externs/reflect_externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * define metadata on an object or property 3 | * @param {?} metadataKey 4 | * @param {?} metadataValue 5 | * @param {?} target 6 | * @param {?=} propertyKey 7 | */ 8 | Reflect.prototype.defineMetadata = function(metadataKey, metadataValue, target, propertyKey) {}; 9 | 10 | /** 11 | * check for presence of a metadata key on the prototype chain of an object or property 12 | * @param {?} metadataKey 13 | * @param {?} target 14 | * @param {?=} propertyKey 15 | * @return {?} 16 | */ 17 | Reflect.prototype.hasMetadata = function(metadataKey, target, propertyKey){}; 18 | 19 | /** 20 | * check for presence of an own metadata key of an object or property 21 | * @param {?} metadataKey 22 | * @param {?} target 23 | * @param {?=} propertyKey 24 | * @return {?} 25 | */ 26 | Reflect.prototype.hasOwnMetadata = function(metadataKey, target, propertyKey){}; 27 | 28 | /** 29 | * get metadata value of a metadata key on the prototype chain of an object or property 30 | * @param {?} metadataKey 31 | * @param {?} target 32 | * @param {?=} propertyKey 33 | */ 34 | Reflect.prototype.getMetadata = function(metadataKey, target, propertyKey){}; 35 | 36 | /** 37 | * get metadata value of an own metadata key of an object or property 38 | * @param {?} metadataKey 39 | * @param {?} target 40 | * @param {?=} propertyKey 41 | * @return {?} 42 | */ 43 | Reflect.prototype.getOwnMetadata = function(metadataKey, target, propertyKey){}; 44 | 45 | /** 46 | * get all metadata keys on the prototype chain of an object or property 47 | * @param {?} target 48 | * @param {?=} propertyKey 49 | * @return {?} 50 | */ 51 | Reflect.prototype.getMetadataKeys = function(target, propertyKey){}; 52 | 53 | /** 54 | * get all own metadata keys of an object or property 55 | * @param {?} target 56 | * @param {?=} propertyKey 57 | * @return {?} 58 | */ 59 | Reflect.prototype.getOwnMetadataKeys = function(target, propertyKey){}; 60 | 61 | /** 62 | * delete metadata from an object or property 63 | * @param {?} metadataKey 64 | * @param {?} target 65 | * @param {?=} propertyKey 66 | */ 67 | Reflect.prototype.deleteMetadata = function(metadataKey, target, propertyKey){}; 68 | 69 | /** 70 | * apply metadata via a decorator to a constructor 71 | * @param {?} metadataKey 72 | * @param {?} metadataValue 73 | */ 74 | Reflect.prototype.metadata = function(metadataKey, metadataValue){}; 75 | 76 | /** 77 | * Applies a set of decorators to a property of a target object. 78 | * @param {?} decorators An array of decorators. 79 | * @param {?=} target The target object. 80 | * @param {?=} targetKey (Optional) The property key to decorate. 81 | * @param {?=} targetDescriptor (Optional) The property descriptor for the target key 82 | * @return {?} 83 | */ 84 | Reflect.prototype.decorate = function(decorators, target, targetKey, targetDescriptor){}; -------------------------------------------------------------------------------- /js/app/externs/zone_externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @constructor 3 | */ 4 | var Zone = function(){}; 5 | 6 | /** @type {Zone} */ 7 | Zone.prototype.parent; 8 | 9 | /** @type {string} */ 10 | Zone.prototype.name; 11 | 12 | /** 13 | * Returns a value associated with the `key`. 14 | * 15 | * If the current zone does not have a key, the request is delegated to the parent zone. Use 16 | * [ZoneSpec.properties] to configure the set of properties asseciated with the current zone. 17 | * 18 | * @param {?} key The key to retrieve. 19 | * @return {?} Tha value for the key, or `undefined` if not found. 20 | */ 21 | Zone.prototype.get = function(key){}; 22 | 23 | /** 24 | * Used to create a child zone. 25 | * 26 | * @param {?} zoneSpec A set of rules which the child zone should follow. 27 | * @return {Zone} A new child zone. 28 | */ 29 | Zone.prototype.fork = function(zoneSpec){}; 30 | 31 | /** 32 | * Wraps a callback function in a new function which will properly restore the current zone upon 33 | * invocation. 34 | * 35 | * The wrapped function will properly forward `this` as well as `arguments` to the `callback`. 36 | * 37 | * Before the function is wrapped the zone can intercept the `callback` by declaring 38 | * [ZoneSpec.onIntercept]. 39 | * 40 | * @param {?} callback the function which will be wrapped in the zone. 41 | * @param {string} source A unique debug location of the API being wrapped. 42 | * @return {?} A function which will invoke the `callback` through [Zone.runGuarded]. 43 | */ 44 | Zone.prototype.wrap = function(callback, source) {}; 45 | 46 | /** 47 | * Invokes a function in a given zone. 48 | * 49 | * The invocation of `callback` can be intercepted be declaring [ZoneSpec.onInvoke]. 50 | * 51 | * @param {?} callback The function to invoke. 52 | * @param {?=} applyThis 53 | * @param {?=} applyArgs 54 | * @param {string=} source A unique debug location of the API being invoked. 55 | * @return {?} Value from the `callback` function. 56 | */ 57 | Zone.prototype.run = function(callback, applyThis, applyArgs, source) {}; 58 | 59 | /** 60 | * Invokes a function in a given zone and catches any exceptions. 61 | * 62 | * Any exceptions thrown will be forwarded to [Zone.HandleError]. 63 | * 64 | * The invocation of `callback` can be intercepted be declaring [ZoneSpec.onInvoke]. The 65 | * handling of exceptions can intercepted by declaring [ZoneSpec.handleError]. 66 | * 67 | * @param {?} callback The function to invoke. 68 | * @param {?=} applyThis 69 | * @param {?=} applyArgs 70 | * @param {string=} source A unique debug location of the API being invoked. 71 | * @return {?} Value from the `callback` function. 72 | */ 73 | Zone.prototype.runGuarded = function(callback, applyThis, applyArgs, source) {}; 74 | 75 | /** 76 | * Execute the Task by restoring the [Zone.currentTask] in the Task's zone. 77 | * 78 | * @param {?} task 79 | * @param {?=} applyThis 80 | * @param {?=} applyArgs 81 | * @return {?} 82 | */ 83 | Zone.prototype.runTask = function(task, applyThis, applyArgs) {}; 84 | 85 | /** 86 | * @param {string} source 87 | * @param {?} callback 88 | * @param {?=} data 89 | * @param {?=} customSchedule 90 | * @return {?} 91 | */ 92 | Zone.prototype.scheduleMicroTask = function(source, callback, data, customSchedule) {}; 93 | 94 | /** 95 | * @param {string} source 96 | * @param {?} callback 97 | * @param {?} data 98 | * @param {?} customSchedule 99 | * @return {?} 100 | */ 101 | Zone.prototype.scheduleMacroTask = function(source, callback, data, customSchedule, customCancel) {}; 102 | 103 | 104 | /** 105 | * @param {string} source 106 | * @param {?} callback 107 | * @param {?} data 108 | * @param {?} customSchedule 109 | * @param {?} customCancel 110 | * @return {?} 111 | */ 112 | Zone.prototype.scheduleEventTask = function(source, callback, data, customSchedule, customCancel) {}; 113 | 114 | /** 115 | * @param {?} task 116 | * @return {?} 117 | */ 118 | Zone.prototype.cancelTask = function(task) {}; 119 | 120 | /** 121 | * @constructor 122 | */ 123 | var ZoneType = function(){}; 124 | 125 | /** @type {Zone} */ 126 | ZoneType.prototype.current; 127 | 128 | /** @type {Task} */ 129 | ZoneType.prototype.currentTask; 130 | 131 | /** 132 | * @constructor 133 | */ 134 | var ZoneSpec = function(){}; 135 | 136 | /** @type {string} */ 137 | ZoneType.prototype.name; 138 | 139 | /** @type {?} */ 140 | ZoneType.prototype.properties; 141 | 142 | /** 143 | * Allows the interception of zone forking. 144 | * 145 | * When the zone is being forked, the request is forwarded to this method for interception. 146 | * 147 | * @param {ZoneDelegate} parentZoneDelegate Delegate which performs the parent [ZoneSpec] operation. 148 | * @param {Zone} currentZone The current [Zone] where the current interceptor has beed declared. 149 | * @param {Zone} targetZone The [Zone] which originally received the request. 150 | * @param {ZoneSpec} zoneSpec The argument passed into the `fork` method. 151 | * @return {Zone} 152 | */ 153 | ZoneType.prototype.onFork = function(parentZoneDelegate, currentZone, targetZone, zoneSpec){}; 154 | 155 | /** 156 | * Allows interception of the wrapping of the callback. 157 | * 158 | * @param {ZoneDelegate} parentZoneDelegate Delegate which performs the parent [ZoneSpec] operation. 159 | * @param {Zone} currentZone The current [Zone] where the current interceptor has beed declared. 160 | * @param {Zone} targetZone The [Zone] which originally received the request. 161 | * @param {?} delegate The argument passed into the `warp` method. 162 | * @param {string} source The argument passed into the `warp` method. 163 | * @return {?} 164 | */ 165 | ZoneType.prototype.onIntercept = function(parentZoneDelegate, currentZone, targetZone, delegate, source){}; 166 | 167 | /** 168 | * Allows interception of the callback invocation. 169 | * 170 | * @param {ZoneDelegate} parentZoneDelegate Delegate which performs the parent [ZoneSpec] operation. 171 | * @param {Zone} currentZone The current [Zone] where the current interceptor has beed declared. 172 | * @param {Zone} targetZone The [Zone] which originally received the request. 173 | * @param {?} delegate The argument passed into the `run` method. 174 | * @param {?} applyThis The argument passed into the `run` method. 175 | * @param {?} applyArgs The argument passed into the `run` method. 176 | * @param {string} source The argument passed into the `run` method. 177 | * @return {?} 178 | */ 179 | ZoneType.prototype.onInvoke = function(parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source){}; 180 | 181 | /** 182 | * Allows interception of the error handling. 183 | * 184 | * @param {ZoneDelegate} parentZoneDelegate Delegate which performs the parent [ZoneSpec] operation. 185 | * @param {Zone} currentZone The current [Zone] where the current interceptor has beed declared. 186 | * @param {Zone} targetZone The [Zone] which originally received the request. 187 | * @param {?} error The argument passed into the `handleError` method. 188 | * @return {boolean} 189 | */ 190 | ZoneType.prototype.onHandleError = function(parentZoneDelegate, currentZone, targetZone, error){}; 191 | 192 | /** 193 | * Allows interception of task scheduling. 194 | * 195 | * @param {ZoneDelegate} parentZoneDelegate Delegate which performs the parent [ZoneSpec] operation. 196 | * @param {Zone} currentZone The current [Zone] where the current interceptor has beed declared. 197 | * @param {Zone} targetZone The [Zone] which originally received the request. 198 | * @param {Task} task The argument passed into the `scheduleTask` method. 199 | * @return {Task} 200 | */ 201 | ZoneType.prototype.onScheduleTask = function(parentZoneDelegate, currentZone, targetZone, task){}; 202 | 203 | /** 204 | * Allows interception of task scheduling. 205 | * 206 | * @param {ZoneDelegate} parentZoneDelegate Delegate which performs the parent [ZoneSpec] operation. 207 | * @param {Zone} currentZone The current [Zone] where the current interceptor has beed declared. 208 | * @param {Zone} targetZone The [Zone] which originally received the request. 209 | * @param {?} task The argument passed into the `scheduleTask` method. 210 | * @param {?} applyArgs 211 | * @return {?} 212 | */ 213 | ZoneType.prototype.onInvokeTask = function(parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs){}; 214 | 215 | /** 216 | * Allows interception of task cancelation. 217 | * 218 | * @param {ZoneDelegate} parentZoneDelegate Delegate which performs the parent [ZoneSpec] operation. 219 | * @param {Zone} currentZone The current [Zone] where the current interceptor has beed declared. 220 | * @param {Zone} targetZone The [Zone] which originally received the request. 221 | * @param {Task} task The argument passed into the `cancelTask` method. 222 | * @return {?} 223 | */ 224 | ZoneType.prototype.onCancelTask = function(parentZoneDelegate, currentZone, targetZone, task){}; 225 | 226 | /** 227 | * Notifies of changes to the task queue empty status. 228 | * 229 | * @param {ZoneDelegate} delegate Delegate which performs the parent [ZoneSpec] operation. 230 | * @param {Zone} current The current [Zone] where the current interceptor has beed declared. 231 | * @param {Zone} target The [Zone] which originally received the request. 232 | * @param {HasTaskState} hasTaskState 233 | */ 234 | ZoneType.prototype.onHasTask = function(delegate, current, target, hasTaskState){}; 235 | 236 | /** 237 | * @constructor 238 | */ 239 | var ZoneDelegate = function(){}; 240 | 241 | /** @type {Zone} */ 242 | ZoneDelegate.prototype.zone; 243 | 244 | /** 245 | * @param {Zone} targetZone 246 | * @param {ZoneSpec} zoneSpec 247 | * @return {Zone} 248 | */ 249 | ZoneDelegate.prototype.fork = function(targetZone, zoneSpec){}; 250 | 251 | /** 252 | * @param {Zone} targetZone 253 | * @param {ZoneSpec} callback 254 | * @param {ZoneSpec} source 255 | * @return {?} 256 | */ 257 | ZoneDelegate.prototype.intercept = function(targetZone, callback, source){}; 258 | 259 | /** 260 | * @param {Zone} targetZone 261 | * @param {?} callback 262 | * @param {?} applyThis 263 | * @param {?} applyArgs 264 | * @param {string} source 265 | * @return {?} 266 | */ 267 | ZoneDelegate.prototype.invoke = function(targetZone, callback, applyThis, applyArgs, source){}; 268 | 269 | /** 270 | * @param {Zone} targetZone 271 | * @param {?} error 272 | * @return {boolean} 273 | */ 274 | ZoneDelegate.prototype.handleError = function(targetZone, error){}; 275 | 276 | /** 277 | * @param {Zone} targetZone 278 | * @param {Task} task 279 | * @return {Task} 280 | */ 281 | ZoneDelegate.prototype.scheduleTask = function(targetZone, task){}; 282 | 283 | /** 284 | * @param {Zone} targetZone 285 | * @param {Task} task 286 | * @param {?} applyThis 287 | * @param {?} applyArgs 288 | * @return {?} 289 | */ 290 | ZoneDelegate.prototype.invokeTask = function(targetZone, task, applyThis, applyArgs){}; 291 | 292 | /** 293 | * @param {Zone} targetZone 294 | * @param {Task} task 295 | * @return {?} 296 | */ 297 | ZoneDelegate.prototype.cancelTask = function(targetZone, task){}; 298 | 299 | /** 300 | * @param {Zone} targetZone 301 | * @param {HasTaskState} isEmpty 302 | */ 303 | ZoneDelegate.prototype.hasTask = function(targetZone, isEmpty){}; 304 | 305 | /** 306 | * @typedef {{ 307 | * microTask: boolean, 308 | * macroTask: boolean, 309 | * eventTask: boolean, 310 | * change: TaskType 311 | * }} 312 | */ 313 | var HasTaskState; 314 | 315 | /** @typedef {string} */ 316 | var TaskType; 317 | 318 | /** 319 | * @constructor 320 | */ 321 | var TaskData = function(){}; 322 | 323 | /** @type {boolean} */ 324 | TaskData.prototype.isPeriodic; 325 | 326 | /** @type {number} */ 327 | TaskData.prototype.delay; 328 | 329 | /** 330 | * @constructor 331 | */ 332 | var Task = function(){}; 333 | 334 | /** @type {?} */ 335 | Task.prototype.type; 336 | 337 | /** @type {string} */ 338 | Task.prototype.source; 339 | 340 | /** @type {?} */ 341 | Task.prototype.invoke; 342 | 343 | /** @type {?} */ 344 | Task.prototype.callback; 345 | 346 | /** @type {TaskData} */ 347 | Task.prototype.data; 348 | 349 | /** @type {?} */ 350 | Task.prototype.scheduleFn; 351 | 352 | /** @type {?} */ 353 | Task.prototype.cancelFn; 354 | 355 | /** @type {Zone} */ 356 | Task.prototype.zone; 357 | 358 | /** @type {number} */ 359 | Task.prototype.runCount; 360 | 361 | /** 362 | * @constructor 363 | */ 364 | var MicroTask = function(){}; 365 | /** 366 | * @constructor 367 | */ 368 | var MacroTask = function(){}; 369 | /** 370 | * @constructor 371 | */ 372 | var EventTask = function(){}; -------------------------------------------------------------------------------- /js/app/statement.js: -------------------------------------------------------------------------------- 1 | goog.provide('Statement'); 2 | 3 | /** 4 | * @constructor 5 | * @param {string} statement 6 | */ 7 | var Statement = function(statement) { 8 | /** @private {string} */ 9 | this.statement = statement; 10 | } 11 | 12 | /** 13 | * @return {string} 14 | */ 15 | Statement.prototype.getStatement = function() { 16 | return this.statement; 17 | } 18 | 19 | /** 20 | * @param {string} statement 21 | * @return {string} 22 | */ 23 | Statement.prototype.setStatement = function(statement) { 24 | this.statement = statement; 25 | } -------------------------------------------------------------------------------- /js/app/tslib/tslib.es6.js: -------------------------------------------------------------------------------- 1 | /*! ***************************************************************************** 2 | Copyright (c) Microsoft Corporation. All rights reserved. 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | this file except in compliance with the License. You may obtain a copy of the 5 | License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 8 | KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 9 | WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 10 | MERCHANTABLITY OR NON-INFRINGEMENT. 11 | 12 | See the Apache Version 2.0 License for specific language governing permissions 13 | and limitations under the License. 14 | ***************************************************************************** */ 15 | 16 | /* global Reflect, Promise */ 17 | var __assign = Object.assign || /** @param {?} t @return {?} */(function (t) { 18 | for (var s, i = 1, n = arguments.length; i < n; i++) { 19 | s = arguments[i]; 20 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; 21 | } 22 | return t; 23 | }); 24 | 25 | /** 26 | * @param {?} decorators 27 | * @param {?} target 28 | * @param {?} key 29 | * @param {?} desc 30 | * @return {?} 31 | */ 32 | var __decorate = function (decorators, target, key, desc) { 33 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 34 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 35 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 36 | return c > 3 && r && Object.defineProperty(target, key, r), r; 37 | } 38 | 39 | /** 40 | * @param {?} paramIndex 41 | * @param {?} decorator 42 | * @return {?} 43 | */ 44 | var __param = function (paramIndex, decorator) { 45 | return function (target, key) { decorator(target, key, paramIndex); } 46 | }; 47 | 48 | /** 49 | * @param {?} metadataKey 50 | * @param {?} metadataValue 51 | * @return {?} 52 | */ 53 | var __metadata = function (metadataKey, metadataValue) { 54 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); 55 | }; 56 | 57 | /** 58 | * @param {?} thisArg 59 | * @param {?} _arguments 60 | * @param {?} P 61 | * @param {?} generator 62 | * @return {?} 63 | */ 64 | var __awaiter = function (thisArg, _arguments, P, generator) { 65 | return new (P || (P = Promise))(function (resolve, reject) { 66 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 67 | function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } 68 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } 69 | step((generator = generator.apply(thisArg, _arguments)).next()); 70 | }); 71 | }; 72 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "typescript-closure-example", 3 | "version": "0.0.0", 4 | "homepage": "https://github.com/lucid-software/typescript-closure-example", 5 | "devDependencies": { 6 | "@angular/common": "file:js/closure-node-modules/angular/common", 7 | "@angular/compiler": "file:js/closure-node-modules/angular/compiler", 8 | "@angular/compiler-cli": "file:js/closure-node-modules/angular/compiler-cli", 9 | "@angular/core": "file:js/closure-node-modules/angular/core", 10 | "@angular/platform-browser": "file:js/closure-node-modules/angular/platform-browser", 11 | "@angular/platform-browser-dynamic": "file:js/closure-node-modules/angular/platform-browser-dynamic", 12 | "@angular/platform-server": "file:js/closure-node-modules/angular/platform-server", 13 | "@angular/tsc-wrapped": "file:js/closure-node-modules/angular/tsc-wrapped", 14 | "es6-shim": "^0.35.0", 15 | "reflect-metadata": "^0.1.3", 16 | "rxjs": "5.0.0-beta.9", 17 | "rxjs-closure": "file:js/closure-node-modules/rxjs-closure", 18 | "symbol-observable": "file:js/closure-node-modules/symbol-observable", 19 | "tsickle": "file:deps/tsickle/tsickle", 20 | "tslib": "1.0.0", 21 | "typescript": "2.0.0", 22 | "zone.js": "^0.6.12" 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /ts/app/basic.html: -------------------------------------------------------------------------------- 1 |
{{ctxProp}}
2 | 3 | -------------------------------------------------------------------------------- /ts/app/basic.ts: -------------------------------------------------------------------------------- 1 | import {BrowserModule} from '@angular/platform-browser'; 2 | import {ApplicationRef, NgModule, Component, Injectable} from '@angular/core'; 3 | import {Greeter} from './greeter'; 4 | import Statement from 'goog:Statement'; 5 | 6 | @Component({ 7 | selector: 'basic', 8 | templateUrl: './basic.html', 9 | }) 10 | @Injectable() 11 | export class Basic { 12 | ctxProp: string; 13 | constructor() { this.ctxProp = new Greeter(new Statement('Hello from basic.ts')).greet();} 14 | } 15 | 16 | @NgModule({ 17 | declarations: [Basic], 18 | entryComponents: [Basic], 19 | imports: [BrowserModule], 20 | }) 21 | export class BasicModule { 22 | ngDoBootstrap(appRef: ApplicationRef) { 23 | var compRef = 24 | appRef.bootstrap(Basic); 25 | } 26 | } -------------------------------------------------------------------------------- /ts/app/bootstrap.ts: -------------------------------------------------------------------------------- 1 | import {platformBrowser} from '@angular/platform-browser'; 2 | import {BasicModuleNgFactory} from './basic.ngfactory'; 3 | import {createPlatformFactory} from '@angular/core'; 4 | 5 | 6 | platformBrowser().bootstrapModuleFactory(BasicModuleNgFactory); -------------------------------------------------------------------------------- /ts/app/greeter.ts: -------------------------------------------------------------------------------- 1 | import Statement from 'goog:Statement'; 2 | 3 | export class Greeter { 4 | constructor(public statement: Statement) {} 5 | greet(): string { 6 | return this.statement.getStatement(); 7 | } 8 | }; 9 | -------------------------------------------------------------------------------- /ts/app/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "angularCompilerOptions": { 3 | "googleClosureOutput": true 4 | }, 5 | "compilerOptions": { 6 | "charset": "UTF-8", 7 | "experimentalDecorators": true, 8 | "module": "commonjs", 9 | "newLine": "lf", 10 | "noEmitHelpers": true, 11 | "noEmitOnError": true, 12 | "noImplicitAny": true, 13 | "outDir": "../../js/app/ts", 14 | "pretty": true, 15 | "removeComments": false, 16 | "sourceMap": true, 17 | "target": "es6" 18 | } 19 | } 20 | 21 | --------------------------------------------------------------------------------