##// END OF EJS Templates
working on support commonjs modules format
cin -
r59:ba3ff79c2832 default
parent child
Show More
@@ -0,0 +1,13
1 # Сборка проекта
2
3 Проект представляет собой сложную структуру, которая делится на несколько наборов, которые используются при условной сборке.
4 Каждый набор сожержит в себе множество артефактов, которые класифицируются по способу сборки, например, исходные тексты js и ts и набор файлов, которые будут просто скопированы без изменений.
5
6 Такая структура позволяет сочитать в проекте несколько языков, а также делать сборки с разными параметрами для разных платформ.
7
8 ## NPM
9
10 Довольно ограниченная среда, поскольку может быть опубликован только один вариант библиотеки, можно конечно использовать разные версии, чтобы публиковать разные сборки, но это приведет к определенным сложностям, по крайней мере при использовании зависимостей, уже не говоря о том, что это будет путать разработчиков.
11 Использование суффиксов в имени пакета только частично решает задачу, поскольку не все системы могут использовать указание путей при настройке загрузчиков. RequireJS позволяет указывать месторасположение пакета, commonJs не позволяет это сделать без использования специальных средств.
12
13 npm позволяет устанавливать библиотеку используя ссылку, что дает возможность ее устанавки из произвольных мест. например, можно установить нужный вариант библиотеки по ссылке <https://implab.org/pub/js/implab/core-es2017-commonjs-1.2.0-rc1.tgz> . No newline at end of file
@@ -0,0 +1,56
1 # Обмен сообщениями
2
3 ## Session
4
5 Контекст обмена сообщениями, отвечает за создание конечных точек для получения и отправки сообщений, а также инкапсулирует в себе работу с провайдером системы обмена сообщениями.
6
7 Сессия позволяет выполнить конфигурацию компонент обработки сообщений, до начала реального обмена и после окончания конфигурации выполнить метод `start` после которого начнется реальная обработка. Такой способ позволяет избежать ошибки и потерю сообщений по причине того, что часть компонент готова к работе и уже получает и отправляет сообщения, а часть еще не настроена.
8
9 ```ts
10
11 // some provider related code
12 const connection = new StompService("ws://broker.329broker.com:15674/ws", { user: "user", pass: "secret" });
13 const session = connection.createSession();
14
15 // create and configure consumers and producers
16 const consumer = session.createConsumer("topic://notify");
17
18 // make event driven consumer
19 consumer.observe().on(msg => {
20 // do something
21
22 // mark the message as processed
23 msg.ack();
24 });
25
26 const producer = session.createProducer("queue://requests");
27
28 // signal the session to start
29 session.start();
30
31 // await the session is started
32 await session.getCompletion();
33
34 ```
35
36 ### start
37
38 Начинает сессию
39
40 ### createConsumer
41
42 ### createProducer
43
44 ## Consumer
45
46 ### Push-consumer
47
48 #### messages
49
50 ### Pull-consumer
51
52 #### read
53
54 ## Producer
55
56 ### post No newline at end of file
@@ -0,0 +1,66
1 import { Uuid } from "../Uuid";
2 import { argumentNotEmptyString, getGlobal } from "../safe";
3 import { TraceSource, DebugLevel } from "../log/TraceSource";
4 import m = require("module");
5
6 const sandboxId = Uuid();
7 define(sandboxId, ["require"], r => r);
8
9 // tslint:disable-next-line:no-var-requires
10 const globalRequire = require(sandboxId);
11
12 const trace = TraceSource.get(m.id);
13
14 export async function createContextRequire(moduleName: string): Promise<Require> {
15 argumentNotEmptyString(moduleName, "moduleName");
16
17 const parts = moduleName.split("/");
18 if (parts[0] === ".")
19 throw new Error("An absolute module path is required");
20
21 if (parts.length > 1)
22 parts.splice(-1, 1, Uuid());
23 else
24 parts.push(Uuid());
25
26 const shim = parts.join("/");
27
28 trace.debug(`define shim ${shim}`);
29
30 return new Promise<Require>(cb => {
31 define(shim, ["require"], r => {
32 trace.debug("shim resolved");
33 return r;
34 });
35 require([shim], cb);
36 });
37 }
38
39 class ModuleResolver {
40 _base: string;
41 _require: Require;
42
43 constructor(req: Require, base?: string) {
44 this._base = base;
45 this._require = req || globalRequire;
46 }
47
48 resolve(moduleName: string) {
49 argumentNotEmptyString(moduleName, "moduleName");
50 const resolvedName = moduleName[0] === "." && this._base ? [this._base, moduleName].join("/") : moduleName;
51 trace.debug(`${moduleName} -> ${resolvedName}`);
52
53 const req = this._require;
54
55 return new Promise<any>((cb, eb) => {
56 req([resolvedName], cb, eb);
57 });
58 }
59 }
60
61 export function makeResolver(moduleName: string, contextRequire: Require) {
62 const base = moduleName && moduleName.split("/").slice(0, -1).join("/");
63
64 const resolver = new ModuleResolver(contextRequire, base);
65 return (id: string) => resolver.resolve(id);
66 }
@@ -0,0 +1,44
1 import { TraceSource } from "./TraceSource";
2 import { Predicate } from "../interfaces";
3
4 export = {
5 on(filter: any , cb: any) {
6 if (arguments.length === 1) {
7 cb = filter;
8 filter = undefined;
9 }
10 let test: Predicate<string>;
11 if (filter instanceof RegExp) {
12 test = chId => filter.test(chId);
13 } else if (filter instanceof Function) {
14 test = filter;
15 } else if (filter) {
16 test = chId => chId === filter;
17 }
18
19 if (test) {
20 TraceSource.on(source => {
21 if (test(source.id))
22 source.events.on(cb);
23 });
24 } else {
25 TraceSource.on(source => {
26 source.events.on(cb);
27 });
28 }
29 },
30
31 load(id: string, require: any, cb: (trace: TraceSource) => void) {
32 if (id) {
33 cb(TraceSource.get(id));
34 } else if (require.module && require.module.mid) {
35 cb(TraceSource.get(require.module.mid));
36 } else {
37 require(["module"], (module: { id: any; }) => {
38 cb(TraceSource.get(module && module.id));
39 });
40 }
41 },
42
43 dynamic: true
44 };
@@ -0,0 +1,104
1 import { format } from "./StringFormat";
2 import { TraceSource, DebugLevel } from "../log/TraceSource";
3 import { ITemplateParser, TokenType } from "./TemplateParser";
4 import m = require("module");
5
6 const trace = TraceSource.get(m.id);
7
8 type TemplateFn = (obj: object) => string;
9
10 export class TemplateCompiler {
11
12 _data: string[];
13 _code: string[];
14 _wrapWith = true;
15
16 constructor() {
17 this._code = [];
18 this._data = [];
19 }
20
21 compile(parser: ITemplateParser): TemplateFn {
22 this.preamble();
23 this.visitTemplate(parser);
24 this.postamble();
25
26 const text = this._code.join("\n");
27
28 try {
29 // tslint:disable-next-line:function-constructor
30 const compiled = new Function("obj, format, $data", text);
31 /**
32 * Функция форматирования по шаблону
33 *
34 * @type{Function}
35 * @param{Object} obj объект с параметрами для подстановки
36 */
37 return (obj: object) => compiled(obj || {}, format, this._data);
38 } catch (e) {
39 trace.traceEvent(DebugLevel, [e, text, this._data]);
40 throw e;
41 }
42 }
43
44 preamble() {
45 this._code.push(
46 "var $p = [];",
47 "var print = function(){",
48 " $p.push(format.apply(null,arguments));",
49 "};"
50 );
51
52 if (this._wrapWith)
53 this._code.push("with(obj){");
54 }
55
56 postamble() {
57 if (this._wrapWith)
58 this._code.push("}");
59
60 this._code.push("return $p.join('');");
61 }
62
63 visitTemplate(parser: ITemplateParser) {
64 while (parser.next()) {
65 switch (parser.token()) {
66 case TokenType.OpenBlock:
67 this.visitCode(parser);
68 break;
69 case TokenType.OpenInlineBlock:
70 this.visitInline(parser);
71 break;
72 default:
73 this.visitTextFragment(parser);
74 break;
75 }
76 }
77 }
78
79 visitInline(parser: ITemplateParser) {
80 const code = ["$p.push("];
81 while (parser.next()) {
82 if (parser.token() === TokenType.CloseBlock)
83 break;
84 code.push(parser.value());
85 }
86 code.push(");");
87 this._code.push(code.join(""));
88 }
89
90 visitCode(parser: ITemplateParser) {
91 const code = [];
92 while (parser.next()) {
93 if (parser.token() === TokenType.CloseBlock)
94 break;
95 code.push(parser.value());
96 }
97 this._code.push(code.join(""));
98 }
99
100 visitTextFragment(parser: ITemplateParser) {
101 const i = this._data.push(parser.value());
102 this._code.push("$p.push($data[" + i + "]);");
103 }
104 }
@@ -0,0 +1,64
1 import { argumentNotEmptyString } from "../safe";
2 import { MapOf } from "../interfaces";
3
4 const splitRx = /(<%=|\[%=|<%|\[%|%\]|%>)/;
5
6 export enum TokenType {
7 None,
8 Text,
9 OpenInlineBlock,
10 OpenBlock,
11 CloseBlock
12 }
13
14 const tokenMap: MapOf<TokenType> = {
15 "<%": TokenType.OpenBlock,
16 "[%": TokenType.OpenBlock,
17 "<%=": TokenType.OpenInlineBlock,
18 "[%=": TokenType.OpenInlineBlock,
19 "%>": TokenType.CloseBlock,
20 "%]": TokenType.CloseBlock
21 };
22
23 export interface ITemplateParser {
24 next(): boolean;
25 token(): TokenType;
26 value(): string;
27 }
28
29 export class TemplateParser implements ITemplateParser {
30
31 _tokens: string[];
32 _pos = -1;
33 _type: TokenType;
34 _value: string;
35
36 constructor(text: string) {
37 argumentNotEmptyString(text, "text");
38
39 this._tokens = text.split(splitRx);
40 this._type = TokenType.None;
41 }
42
43 next() {
44 this._pos++;
45 if (this._pos < this._tokens.length) {
46 this._value = this._tokens[this._pos];
47 this._type = tokenMap[this._value] || TokenType.Text;
48 return true;
49 } else {
50 this._type = TokenType.None;
51 this._value = undefined;
52 return false;
53 }
54 }
55
56 token() {
57 return this._type;
58 }
59
60 value() {
61 return this._value;
62 }
63
64 }
@@ -0,0 +1,33
1 import { argumentNotEmptyString } from "../safe";
2 import { TraceSource } from "../log/TraceSource";
3
4 const trace = TraceSource.get(module.id);
5
6 const mainModule = require.main;
7 const mainRequire = (id: string) => mainModule.require(id);
8
9 class ModuleResolver {
10 _base: string;
11 _require: NodeRequireFunction;
12
13 constructor(req: NodeRequireFunction, base?: string) {
14 this._base = base;
15 this._require = (req || mainRequire).bind(null);
16 }
17
18 resolve(moduleName: string) {
19 argumentNotEmptyString(moduleName, "moduleName");
20 const resolvedName = moduleName[0] === "." && this._base ? [this._base, moduleName].join("/") : moduleName;
21
22 trace.debug(`${moduleName} -> ${resolvedName}`);
23
24 return this._require(resolvedName);
25 }
26 }
27
28 export function makeResolver(moduleName: string, contextRequire: NodeRequireFunction) {
29 const base = moduleName && moduleName.split("/").slice(0, -1).join("/");
30
31 const resolver = new ModuleResolver(contextRequire, base);
32 return (id: string) => resolver.resolve(id);
33 }
@@ -0,0 +1,3
1 import { ModuleResolver } from "./Configuration";
2
3 export declare function makeResolver(moduleName?: string, contextRequire?: any): ModuleResolver; No newline at end of file
@@ -0,0 +1,33
1 import { ICancellation } from "../interfaces";
2
3 /** interface for message consumers, used to recieve messages from a single endpoint.
4 */
5 export interface IConsumer<T> {
6 /** Reads the next message from the destination for which the consumer was created.
7 * @param options A provider specific options.
8 * @param ct The cancellation token for this operation.
9 * @returns A recieved message or a promise. If message is prefetched it will
10 * be returned immediately, otherwise a promise is returned.
11 */
12 read(options?: object, ct?: ICancellation): T | Promise<T>;
13 }
14
15 /** Interface for message produsers, used to send messages to the endpoints.
16 * The producer can be bound to the particular destination or a destination
17 * can be specified as an additional option during post if supported.
18 */
19 export interface IProducer<T> {
20 /** Sends a message
21 * @param msg The message to send.
22 * @param options A provider specific options
23 * @param ct The cancellation token for this operation
24 */
25 post(msg: T, options?: object, ct?: ICancellation): void | Promise<void>;
26 }
27
28 export interface ISession {
29 start(ct: ICancellation): void;
30
31 createConsumer<T = any>(destination: string, options?: object): IConsumer<T>;
32 createProducer<T = any>(destination: string, options?: object): IProducer<T>;
33 }
@@ -0,0 +1,24
1 {
2 "name": "${packageName}",
3 "version": "${version}",
4 "description": "${description}",
5 "main": "main.js",
6 "keywords": [
7 "di",
8 "ioc",
9 "logging",
10 "template engine",
11 "dependency injection"
12 ],
13 "author": "${author}",
14 "license": "${license}",
15 "repository": "$repository",
16 "publishConfig": {
17 "access": "public"
18 },
19 "peerDependencies": {
20 "dojo": "^1.10.0"
21 },
22 "module": "${jsmodule}",
23 "target": "${target}"
24 } No newline at end of file
@@ -0,0 +1,21
1 {
2 "name": "${packageName}",
3 "version": "${version}",
4 "description": "${description}",
5 "main": "main.js",
6 "keywords": [
7 "di",
8 "ioc",
9 "logging",
10 "template engine",
11 "dependency injection"
12 ],
13 "author": "${author}",
14 "license": "${license}",
15 "repository": "$repository",
16 "publishConfig": {
17 "access": "public"
18 },
19 "module": "${jsmodule}",
20 "target": "${target}"
21 } No newline at end of file
@@ -0,0 +1,7
1 define(["tape", "core/Uuid"], function(tape, Uuid) {
2 "use strict";
3 tape('uuid', function(t) {
4 t.notEqual(Uuid(),Uuid());
5 t.end();
6 });
7 }); No newline at end of file
@@ -0,0 +1,20
1 define({
2 foo: {
3 $type: "./Foo:Foo"
4 },
5
6 bar: {
7 $type: "./Bar:Bar",
8 params: {
9 db: {
10 provider: {
11 $dependency: "db"
12 }
13 },
14 foo: {
15 $type: "./Foo:Foo"
16 }
17 }
18 },
19 db: "db://localhost"
20 }); No newline at end of file
@@ -0,0 +1,8
1 define([
2 "./ActivatableTests",
3 "./trace-test",
4 "./TraceSourceTests",
5 "./CancellationTests",
6 "./ObservableTests",
7 "./ContainerTests"
8 ]); No newline at end of file
@@ -0,0 +1,22
1 var rjs = require('requirejs');
2
3 rjs.config({
4 baseUrl: '.',
5 packages: [{
6 name: "@implab/core",
7 location: "build/dist"
8 },
9 {
10 name: "test",
11 location: "build/test"
12 },
13 {
14 name: "dojo",
15 location: "node_modules/dojo"
16 }
17 ],
18 nodeRequire: require
19 });
20
21
22 rjs(['test/plan']); No newline at end of file
@@ -0,0 +1,30
1 define(["tape"], function(tape) {
2 "use strict";
3 var sourceId = '73a633f3-eab8-49b0-8601-07cae710f234';
4 var sourceId2 = '3ba9c7cd-ed77-437b-9a2f-1cbeb1226b5b';
5 tape('Load TraceSource for the module', function(t) {
6 require(["@implab/core/log/trace!" + sourceId, "@implab/core/log/TraceSource"], function(trace, TraceSource_1) {
7 var TraceSource = TraceSource_1.TraceSource;
8 t.equal(trace && trace.id, sourceId, "trace should be taken from the loader plugin parameter");
9
10 var count = 0;
11
12 var h = TraceSource.on(function(x) {
13 if(x.id == sourceId || x.id == sourceId2)
14 count++;
15 });
16
17 t.equal(count, 1, "should see created channel immediatelly");
18 t.equal(trace, TraceSource.get(sourceId), "should get same TraceSource from registry");
19 t.equal(count, 1);
20
21 TraceSource.get(sourceId2);
22
23 t.equal(count, 2);
24
25 h.destroy();
26
27 t.end();
28 });
29 });
30 }); No newline at end of file
@@ -0,0 +1,22
1 {
2 "extends": "../tsconfig",
3 "compilerOptions": {
4 "rootDir": "ts",
5 "baseUrl": ".",
6 "paths": {
7 "@implab/core/*": [
8 "../../build/dist/*"
9 ]
10 },
11 "types": [
12 "requirejs"
13 ],
14 "rootDirs": [
15 "ts",
16 "../typings/test"
17 ]
18 },
19 "include" : [
20 "ts/**/*.ts"
21 ]
22 } No newline at end of file
@@ -5,41 +5,128 if (release != 'rtm') {
5 if(!npmName)
5 if(!npmName)
6 npmName = name;
6 npmName = name;
7
7
8 if(!["amd", "cjs"].contains(platform))
8 if(!["amd", "commonjs", "system", "umd", "es6", "esnext"].contains(jsmodule))
9 throw new Exception("Invalid platform specified: $platform");
9 throw new Exception("Invalid jsmodule specified: $jsmodule");
10 if(!["es3", "es5", "es6", "es2016", "es2017", "esnext"].contains(target))
11 throw new Exception("Invalid target specified: $target")
10
12
11 def moduleTypes = [
13 def targetLibs = [
12 "amd": "amd",
14 "es3" : "es5,es2015.promise,es2015.symbol,dom,scripthost",
13 "cjs": "commonjs"
15 "es5" : "es5,es2015.promise,es2015.symbol,dom,scripthost"
14 ]
16 ];
15
17
16 ext.packageName="$npmScope/$npmName-$platform";
18 ext.packageName="$npmScope/$npmName";
17
19
18 def srcDir = "$projectDir/src"
20 def srcDir = "$projectDir/src"
19 def typingsDir = "$srcDir/typings"
21 def typingsDir = "$srcDir/typings"
20 def distDir = "$buildDir/dist/$platform"
22 def distDir = "$buildDir/dist"
21 def testDir = "$buildDir/test/$platform"
23 def testDir = "$buildDir/test"
22 def moduleType = moduleTypes[platform]
24 def lib = targetLibs[target] ?: "${target},dom";
25
26 println "lib: $lib";
27
28 def sourceSets = ["main", "amd", "cjs"];
29 def testSets = ["test", "testAmd", "testCjs"];
30
31 task beforeBuild {
32 }
33
34 def createSoursetTasks = { String name, String outDir ->
35 def setName = name.capitalize();
36
37 def destDir = "$buildDir/compile/$name"
38 def declDir = "$typingsDir/$name"
39 def setDir = "$projectDir/src/$name"
40
41 def beforeBuildTask = task "beforeBuild$setName"(dependsOn: beforeBuild) {
42 }
43
44 def copyJsTask = task "copyJs$setName"(dependsOn: beforeBuildTask, type: Copy) {
45 from "$setDir/js"
46 into outDir
47 }
48
49 def compileTypingsTask = task "compileTypings$setName"(dependsOn: beforeBuildTask, type: Exec) {
50 inputs.dir("$setDir/ts")
51 inputs.file("$srcDir/tsconfig.json")
52 inputs.file("$setDir/tsconfig.json")
53 outputs.dir(declDir)
23
54
24 def sourceSets = ["main", "amd", "cjs", "test"];
55 commandLine 'node_modules/.bin/tsc',
56 '-p', "$setDir/tsconfig.json",
57 '-t', target,
58 '-m', jsmodule,
59 '-d',
60 '--emitDeclarationOnly',
61 '--declarationDir', declDir
62
63 if (lib)
64 args '--lib', lib
65 }
66
67 def compileTsTask = task "compileTs$setName"(dependsOn: beforeBuildTask, type: Exec) {
68 inputs.dir("$setDir/ts")
69 inputs.file("$srcDir/tsconfig.json")
70 inputs.file("$setDir/tsconfig.json")
71 outputs.dir(destDir)
72
73 commandLine 'node_modules/.bin/tsc',
74 '-p', "$setDir/tsconfig.json",
75 '-t', target,
76 '-m', jsmodule,
77 '--outDir', destDir
78
79 if (lib)
80 args '--lib', lib
81 }
82
83 def copyTsOutputTask = task "copyTsOutput$setName"(dependsOn: compileTsTask, type: Copy) {
84 from compileTsTask
85 into outDir
86 }
87
88 def copyTypingsTask = task "copyTypings$setName"(dependsOn: compileTypingsTask, type: Copy) {
89 from compileTypingsTask
90 into outDir
91 }
92
93 task "build$setName"(dependsOn: [copyTypingsTask, copyTsOutputTask, copyJsTask]) {
94 }
95 }
25
96
26 task printVersion {
97 task printVersion {
27 doLast {
98 doLast {
28 println "version: $version"
99 println "version: $version"
29 println "packageName: $packageName"
100 println "packageName: $packageName"
30 println "platform: $platform"
101 println "target: $target"
31 println "module: $moduleType"
102 println "module: $jsmodule"
32 }
103 }
33 }
104 }
34
105
35 task clean {
106 task clean {
36 doLast {
107 doLast {
37 delete buildDir
108 delete buildDir
38 delete "node_modules/$packageName"
39 delete typingsDir
109 delete typingsDir
40 }
110 }
41 }
111 }
42
112
113 task _initBuild {
114 mustRunAfter clean
115
116 def buildInfoFile = "$buildDir/platform";
117 inputs.property('target',target);
118 inputs.property('jsmodule',jsmodule);
119 outputs.file(buildInfoFile);
120
121 doLast {
122 delete buildDir
123 mkdir buildDir
124
125 def f = new File(buildInfoFile);
126 f << "$target-$jsmodule";
127 }
128 }
129
43 task cleanNpm {
130 task cleanNpm {
44 doLast {
131 doLast {
45 delete 'node_modules'
132 delete 'node_modules'
@@ -56,78 +143,55 task _npmInstall() {
56 }
143 }
57 }
144 }
58
145
59 sourceSets.each {
146 beforeBuild {
60 def setName = it.capitalize();
147 dependsOn _initBuild
148 dependsOn _npmInstall
149 }
61
150
62 def destDir = "$buildDir/compile/$it"
151 sourceSets.each { createSoursetTasks(it, distDir) }
63 def declDir = "$typingsDir/$it"
64 def setDir = "$projectDir/src/$it"
65
152
66 task "_copyJs$setName"(type:Copy) {
153 testSets.each { createSoursetTasks(it, testDir) }
67 from "$setDir/js"
154
68 into distDir
155 compileTsAmd {
156 dependsOn compileTypingsMain
69 }
157 }
70
158
71 task "_compileTs$setName"(dependsOn: _npmInstall, type:Exec) {
159 compileTypingsAmd {
72 inputs.dir("$setDir/ts")
160 dependsOn compileTypingsMain
73 inputs.file("$srcDir/tsconfig.json")
161 }
74 inputs.file("$setDir/tsconfig.json")
75 outputs.dir(destDir)
76 outputs.dir(declDir)
77
162
78 commandLine 'node_modules/.bin/tsc',
163 task build(dependsOn: buildMain) {
79 '-p', "$setDir/tsconfig.json",
164 if (jsmodule == "amd")
80 '-m', moduleType,
165 dependsOn buildAmd
81 '--outDir', destDir,
82 '--declarationDir', declDir
83 }
166 }
84
167
85 task "_buildTs$setName"(dependsOn: "_compileTs$setName", type:Copy) {
168 compileTsTest {
86 from tasks.getByPath("_compileTs$setName");
169 dependsOn build
87 into distDir
88 }
89 }
170 }
90
171
91 _compileTsAmd {
172 compileTsTestAmd {
92 dependsOn _buildTsMain
173 dependsOn compileTypingsTestAmd
93 }
174 }
94
175
95 _buildTsTest {
176 task test(dependsOn: [buildTest, buildTestAmd], type: Exec) {
96 into testDir
177 commandLine 'node', "$testDir/run-amd-tests.js"
97 }
98
99 _copyJsTest {
100 into testDir
101 }
178 }
102
179
103 task _packageMeta(type: Copy) {
180 task _packageMeta(type: Copy) {
181 mustRunAfter build
182
104 inputs.property("version", version)
183 inputs.property("version", version)
105 from('.') {
184 from('.') {
106 include '.npmignore', 'readme.md', 'license', 'history.md'
185 include '.npmignore', 'readme.md', 'license', 'history.md'
107 }
186 }
108 from("$srcDir/package.template.json") {
187 from("$srcDir/package.${jsmodule}.tmpl.json") {
109 expand project.properties
188 expand project.properties
110 rename { "package.json" }
189 rename { "package.json" }
111 }
190 }
112 into distDir
191 into distDir
113 }
192 }
114
193
115 task build(dependsOn: [_copyJsMain, _copyJsAmd, _npmInstall, _buildTsMain, _buildTsAmd, _packageMeta]) {
194 task pack(dependsOn: [build, _packageMeta], type: Exec) {
116
117 }
118
119 _compileTsTest {
120 dependsOn build
121 }
122
123 task buildTests(dependsOn: [_copyJsTest, _buildTsTest]) {
124 }
125
126 task test(dependsOn: buildTests, type: Exec) {
127 commandLine 'node', "$testDir/run-amd-tests.js"
128 }
129
130 task pack(dependsOn: build, type: Exec) {
131 workingDir distDir
195 workingDir distDir
132
196
133 commandLine 'npm', 'pack'
197 commandLine 'npm', 'pack'
@@ -119,13 +119,9 let msg = await pushEvents.next();
119
119
120 class Map {
120 class Map {
121 /**
121 /**
122
123 Получает координаты по щелчку мыши.
122 Получает координаты по щелчку мыши.
124
125 @async
123 @async
126
127 @returns [lon,lat]
124 @returns [lon,lat]
128
129 */
125 */
130 async peekCoordinates(ct: ICancellation = Cancellation.none) {
126 async peekCoordinates(ct: ICancellation = Cancellation.none) {
131 // получаем событие клика
127 // получаем событие клика
@@ -1,7 +1,8
1 version=1.2.0
1 version=1.2.0
2 release=rc
2 release=rc
3 author=Implab team
3 author=Implab team
4 platform=amd
4 jsmodule=amd
5 target=es5
5 description=Dependency injection, logging, simple and fast text template engine
6 description=Dependency injection, logging, simple and fast text template engine
6 license=BSD-2-Clause
7 license=BSD-2-Clause
7 repository=https://bitbucket.org/implab/implabjs
8 repository=https://bitbucket.org/implab/implabjs
@@ -1,12 +1,20
1 HISTORY
1 HISTORY
2 =======
2 =======
3
3
4 1.2.0
5 -----
6
7 Major rafactoring, moving to support browser (rjs) and server (cjs) environments.
8
9 - dependency injection container ported to typescript
10 - sources are split to several sets to provide the ability for the conditional build of the project.
11
4 1.0.1
12 1.0.1
5 -----
13 -----
6
14
7 First release, intorduces the followinf features
15 First release, intorduces the following features
8
16
9 - `di` - dependency injection conyainer
17 - `di` - dependency injection container
10 - `log` - log4 style logging system
18 - `log` - log4 style logging system
11 - `text` - simple and fast text templating and formatting
19 - `text` - simple and fast text templating and formatting
12 - `Uuid` - uuid generation traits No newline at end of file
20 - `Uuid` - uuid generation traits
@@ -5,9 +5,9
5 "requires": true,
5 "requires": true,
6 "dependencies": {
6 "dependencies": {
7 "@types/node": {
7 "@types/node": {
8 "version": "10.12.15",
8 "version": "10.12.18",
9 "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.15.tgz",
9 "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz",
10 "integrity": "sha512-9kROxduaN98QghwwHmxXO2Xz3MaWf+I1sLVAA6KJDF5xix+IyXVhds0MAfdNwtcpSrzhaTsNB0/jnL86fgUhqA==",
10 "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==",
11 "dev": true
11 "dev": true
12 },
12 },
13 "@types/requirejs": {
13 "@types/requirejs": {
@@ -17,9 +17,9
17 "dev": true
17 "dev": true
18 },
18 },
19 "@types/tape": {
19 "@types/tape": {
20 "version": "4.2.32",
20 "version": "4.2.33",
21 "resolved": "http://registry.npmjs.org/@types/tape/-/tape-4.2.32.tgz",
21 "resolved": "https://registry.npmjs.org/@types/tape/-/tape-4.2.33.tgz",
22 "integrity": "sha512-xil0KO5wkPoixdBWGIGolPv9dekf6dVkjjJLAFYchfKcd4DICou67rgGCIO7wAh3i5Ff/6j9IDgZz+GU9cMaqQ==",
22 "integrity": "sha512-ltfyuY5BIkYlGuQfwqzTDT8f0q8Z5DGppvUnWGs39oqDmMd6/UWhNpX3ZMh/VYvfxs3rFGHMrLC/eGRdLiDGuw==",
23 "dev": true,
23 "dev": true,
24 "requires": {
24 "requires": {
25 "@types/node": "*"
25 "@types/node": "*"
@@ -95,16 +95,25
95 "dev": true
95 "dev": true
96 },
96 },
97 "es-abstract": {
97 "es-abstract": {
98 "version": "1.12.0",
98 "version": "1.13.0",
99 "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.12.0.tgz",
99 "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.13.0.tgz",
100 "integrity": "sha512-C8Fx/0jFmV5IPoMOFPA9P9G5NtqW+4cOPit3MIuvR2t7Ag2K15EJTpxnHAYTzL+aYQJIESYeXZmDBfOBE1HcpA==",
100 "integrity": "sha512-vDZfg/ykNxQVwup/8E1BZhVzFfBxs9NqMzGcvIJrqg5k2/5Za2bWo40dK2J1pgLngZ7c+Shh8lwYtLGyrwPutg==",
101 "dev": true,
101 "dev": true,
102 "requires": {
102 "requires": {
103 "es-to-primitive": "^1.1.1",
103 "es-to-primitive": "^1.2.0",
104 "function-bind": "^1.1.1",
104 "function-bind": "^1.1.1",
105 "has": "^1.0.1",
105 "has": "^1.0.3",
106 "is-callable": "^1.1.3",
106 "is-callable": "^1.1.4",
107 "is-regex": "^1.0.4"
107 "is-regex": "^1.0.4",
108 "object-keys": "^1.0.12"
109 },
110 "dependencies": {
111 "object-keys": {
112 "version": "1.0.12",
113 "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.12.tgz",
114 "integrity": "sha512-FTMyFUm2wBcGHnH2eXmz7tC6IwlqQZ6mVZ+6dm6vZ4IQIHjs6FdNsQBuKGPuUUUY6NfJw2PshC08Tn6LzLDOag==",
115 "dev": true
116 }
108 }
117 }
109 },
118 },
110 "es-to-primitive": {
119 "es-to-primitive": {
@@ -375,9 +384,9
375 }
384 }
376 },
385 },
377 "tape": {
386 "tape": {
378 "version": "4.9.1",
387 "version": "4.9.2",
379 "resolved": "https://registry.npmjs.org/tape/-/tape-4.9.1.tgz",
388 "resolved": "https://registry.npmjs.org/tape/-/tape-4.9.2.tgz",
380 "integrity": "sha512-6fKIXknLpoe/Jp4rzHKFPpJUHDHDqn8jus99IfPnHIjyz78HYlefTGD3b5EkbQzuLfaEvmfPK3IolLgq2xT3kw==",
389 "integrity": "sha512-lPXKRKILZ1kZaUy5ynWKs8ATGSUO7HAFHCFnBam6FaGSqPdOwMWbxXHq4EXFLE8WRTleo/YOMXkaUTRmTB1Fiw==",
381 "dev": true,
390 "dev": true,
382 "requires": {
391 "requires": {
383 "deep-equal": "~1.0.1",
392 "deep-equal": "~1.0.1",
@@ -21,15 +21,15
21 "tslib": "latest"
21 "tslib": "latest"
22 },
22 },
23 "devDependencies": {
23 "devDependencies": {
24 "typescript": "latest",
24 "@types/node": "latest",
25 "tape": "latest",
26 "@types/tape": "latest",
27 "@types/requirejs": "latest",
25 "@types/requirejs": "latest",
28 "@types/node": "latest",
26 "@types/tape": "latest",
29 "requirejs": "latest",
27 "dojo": "^1.10.0",
30 "faucet": "latest",
28 "faucet": "latest",
31 "dojo": "^1.10.0",
29 "requirejs": "latest",
32 "tslib": "latest"
30 "tape": "^4.9.2",
31 "tslib": "latest",
32 "typescript": "latest"
33 },
33 },
34 "types": "main.d.ts"
34 "types": "main.d.ts"
35 }
35 }
@@ -1,6 +1,6
1 define(
1 define(["./declare", "./log/trace!"], function (declare, trace) {
2 [ "./declare" ],
2 trace.warn("THIS MODULE IS DEPRECATED! use uri-js or similar alternatives.");
3 function(declare) {
3
4 function parseURI(uri) {
4 function parseURI(uri) {
5 var schema, host, port, path, query, hash, i;
5 var schema, host, port, path, query, hash, i;
6 if (typeof (uri) == "string") {
6 if (typeof (uri) == "string") {
@@ -85,7 +85,9 define(
85 }
85 }
86
86
87 function reducePath(parts) {
87 function reducePath(parts) {
88 var balance = 0, result = [], isRoot;
88 var balance = 0,
89 result = [],
90 isRoot;
89
91
90 for (var i = 0; i < parts.length; i++) {
92 for (var i = 0; i < parts.length; i++) {
91 var part = parts[i];
93 var part = parts[i];
@@ -130,6 +132,7 define(
130
132
131 var URI = declare(null, {
133 var URI = declare(null, {
132 constructor : function(opts) {
134 constructor: function (opts) {
135 trace.warn("This class is deprecated use uri-js or similar");
133 if (typeof (opts) == "string")
136 if (typeof (opts) == "string")
134 opts = parseURI(opts);
137 opts = parseURI(opts);
135 for ( var p in meta)
138 for (var p in meta)
@@ -195,7 +198,8 define(
195 },
198 },
196
199
197 toString : function() {
200 toString: function () {
198 var uri = [], me = this;
201 var uri = [],
202 me = this;
199
203
200 if (me.schema)
204 if (me.schema)
201 uri.push(me.schema, ":");
205 uri.push(me.schema, ":");
@@ -1,18 +1,14
1 define(
1 define([
2 [
3 "dojo/_base/declare",
2 "dojo/_base/declare",
4 "dojo/_base/lang",
5 "dojo/request",
3 "dojo/request",
6 "./Destination",
4 "./Destination",
7 "dojo/Evented",
5 "dojo/Evented",
8 "dojo/Deferred",
6 "dojo/Deferred",
9 "../log/_LogMixin" ],
7 "../log/_LogMixin"
10
8 ], function (declare, request, Destination, Evented, Deferred, _LogMixin) {
11 function(declare, lang, request, Destination, Evented, Deferred, _LogMixin) {
12
9
13 var cls = declare(
10 var cls = declare(
14 [ Evented, _LogMixin ],
11 [Evented, _LogMixin], {
15 {
16 _id : null,
12 _id: null,
17 _baseUrl : null,
13 _baseUrl: null,
18 _destinations : null,
14 _destinations: null,
@@ -88,9 +84,9
88 id,
84 id,
89 options.mode,
85 options.mode,
90 options.destination);
86 options.destination);
91 me._clients[id] = options.client
87 me._clients[id] = options.client ?
92 ? options.client
88 options.client :
93 : function(msg) {
89 function (msg) {
94 me
90 me
95 .warn(
91 .warn(
96 "The client id=${0}, mode=${1}, destination=${2} isn't accepting mesages",
92 "The client id=${0}, mode=${1}, destination=${2} isn't accepting mesages",
@@ -108,7 +104,8
108 if (!options || !options.clientId)
104 if (!options || !options.clientId)
109 throw new Error("Invalid argument");
105 throw new Error("Invalid argument");
110
106
111 var me = this, id = options.clientId;
107 var me = this,
108 id = options.clientId;
112
109
113 return me._started.then(function() {
110 return me._started.then(function () {
114 var url = me._makeUrl(me._id, options.clientId);
111 var url = me._makeUrl(me._id, options.clientId);
@@ -126,7 +123,8
126 },
123 },
127
124
128 _poll : function() {
125 _poll: function () {
129 var me = this, url = this._makeUrl(this._id);
126 var me = this,
127 url = this._makeUrl(this._id);
130 me.log("POLL timeout=${0}", me._timeout);
128 me.log("POLL timeout=${0}", me._timeout);
131 request(url, {
129 request(url, {
132 method : "GET",
130 method: "GET",
@@ -214,4 +212,4
214 };
212 };
215
213
216 return cls;
214 return cls;
217 });
215 }); No newline at end of file
@@ -2,7 +2,12
2 "extends": "../tsconfig",
2 "extends": "../tsconfig",
3 "compilerOptions": {
3 "compilerOptions": {
4 "types": [
4 "types": [
5 "@types/node"
5 "node"
6 ],
7 "rootDir": "ts",
8 "rootDirs": [
9 "ts",
10 "../typings/main"
6 ]
11 ]
7 },
12 },
8 "include": [
13 "include": [
@@ -3,7 +3,7 import { IAsyncComponent, ICancellation,
3 import { destroy } from "../safe";
3 import { destroy } from "../safe";
4
4
5 export class AsyncComponent implements IAsyncComponent, ICancellable {
5 export class AsyncComponent implements IAsyncComponent, ICancellable {
6 _cancel: (e) => void;
6 _cancel: (e: any) => void;
7
7
8 _completion: Promise<void> = Promise.resolve();
8 _completion: Promise<void> = Promise.resolve();
9
9
@@ -33,7 +33,7 export class AsyncComponent implements I
33 return this._completion = guard();
33 return this._completion = guard();
34 }
34 }
35
35
36 cancel(reason) {
36 cancel(reason: any) {
37 if (this._cancel)
37 if (this._cancel)
38 this._cancel(reason);
38 this._cancel(reason);
39 }
39 }
@@ -0,0 +1,1
1 export { Container } from "./di/Container";
@@ -1,11 +1,11
1 export class ConfigError extends Error {
1 export class ConfigError extends Error {
2 inner;
2 inner: any;
3
3
4 path: string;
4 path: string;
5
5
6 configName: string;
6 configName: string;
7
7
8 constructor(message: string, inner?) {
8 constructor(message: string, inner?: any) {
9 super(message);
9 super(message);
10 this.inner = inner;
10 this.inner = inner;
11 }
11 }
@@ -23,14 +23,30 import { FactoryServiceDescriptor } from
23 import { TraceSource } from "../log/TraceSource";
23 import { TraceSource } from "../log/TraceSource";
24 import { ConfigError } from "./ConfigError";
24 import { ConfigError } from "./ConfigError";
25 import { Cancellation } from "../Cancellation";
25 import { Cancellation } from "../Cancellation";
26 import { makeResolver } from "./ResolverHelper";
27 import { ICancellation } from "../interfaces";
26
28
27 const trace = TraceSource.get("@implab/core/di/Configuration");
29 const trace = TraceSource.get("@implab/core/di/Configuration");
28
30
29 declare const define;
31 declare const define;
30 declare const require;
32 declare const require;
33 declare const module;
31
34
32 function hasAmdLoader() {
35 function hasAmdLoader() {
36 try {
37 // es6 may throw the exception
33 return (typeof define === "function" && define.amd);
38 return (typeof define === "function" && define.amd);
39 } catch {
40 return false;
41 }
42 }
43
44 function hasNodeJs() {
45 try {
46 return (typeof module !== "undefined" && module.exports);
47 } catch {
48 return false;
49 }
34 }
50 }
35
51
36 async function mapAll(data: object | any[], map?: (v, k) => any): Promise<any> {
52 async function mapAll(data: object | any[], map?: (v, k) => any): Promise<any> {
@@ -50,7 +66,7 async function mapAll(data: object | any
50 }
66 }
51 }
67 }
52
68
53 type Resolver = (qname: string) => any;
69 export type ModuleResolver = (moduleName: string, ct?: ICancellation) => any;
54
70
55 type _key = string | number;
71 type _key = string | number;
56
72
@@ -64,7 +80,7 export class Configuration {
64
80
65 _configName: string;
81 _configName: string;
66
82
67 _require: Resolver;
83 _require: ModuleResolver;
68
84
69 constructor(container: Container) {
85 constructor(container: Container) {
70 argumentNotNull(container, container);
86 argumentNotNull(container, container);
@@ -72,28 +88,31 export class Configuration {
72 this._path = [];
88 this._path = [];
73 }
89 }
74
90
75 async loadConfiguration(moduleName: string, ct = Cancellation.none) {
91 async loadConfiguration(moduleName: string, contextRequire?: any, ct = Cancellation.none) {
76 argumentNotEmptyString(moduleName, "moduleName");
92 argumentNotEmptyString(moduleName, "moduleName");
77 // TODO remove the code below somewehere else
93
78 if (hasAmdLoader()) {
94 trace.log("loadConfiguration moduleName={0}", moduleName);
79 // if we have a requirejs loader, use it directly
95
80 // don't rely on typescript 'import' function
96 this._configName = moduleName;
81 const m = await new Promise<any>(cb => require(["./RequireJsHelper"], cb));
97
82 const r = m.makeResolver(require);
98 const r = makeResolver(null, contextRequire);
83 const config = await r(moduleName);
84
99
85 return this.applyConfiguration(
100 const config = await r(moduleName, ct);
101
102 await this._applyConfiguration(
86 config,
103 config,
87 m.makeResolver(await m.createContextRequire(moduleName))
104 makeResolver(moduleName, contextRequire),
105 ct
88 );
106 );
89 } else {
90 throw new Error("This feature is supported only with the amd loader");
91 }
92 }
107 }
93
108
94 async applyConfiguration(data: object, resolver?: Resolver, ct = Cancellation.none) {
109 applyConfiguration(data: object, contextRequire?: any, ct = Cancellation.none) {
95 argumentNotNull(data, "data");
110 argumentNotNull(data, "data");
96
111
112 return this._applyConfiguration(data, makeResolver(void(0), contextRequire), ct);
113 }
114
115 async _applyConfiguration(data: object, resolver?: ModuleResolver, ct = Cancellation.none) {
97 trace.log("applyConfiguration");
116 trace.log("applyConfiguration");
98
117
99 this._configName = "$";
118 this._configName = "$";
@@ -140,12 +159,10 export class Configuration {
140 }
159 }
141 }
160 }
142
161
143 async _loadModule(moduleName: string) {
162 _loadModule(moduleName: string) {
144 trace.debug("loadModule {0}", moduleName);
163 trace.debug("loadModule {0}", moduleName);
145
164
146 const m = await this._require(moduleName);
165 return this._require(moduleName);
147
148 return m;
149 }
166 }
150
167
151 async _visitRegistrations(data, name: _key) {
168 async _visitRegistrations(data, name: _key) {
@@ -178,7 +195,7 export class Configuration {
178 trace.debug("<{0}", name);
195 trace.debug("<{0}", name);
179 }
196 }
180
197
181 async _visit(data, name: string): Promise<any> {
198 _visit(data, name: string): Promise<any> {
182 if (isPrimitive(data) || isDescriptor(data))
199 if (isPrimitive(data) || isDescriptor(data))
183 return data;
200 return data;
184
201
@@ -99,11 +99,11 export class Container {
99 * The function which will be used to load a configuration or types for services.
99 * The function which will be used to load a configuration or types for services.
100 *
100 *
101 */
101 */
102 async configure(config: string | object, opts?, ct = Cancellation.none) {
102 async configure(config: string | object, opts?: any, ct = Cancellation.none) {
103 const c = new Configuration(this);
103 const c = new Configuration(this);
104
104
105 if (typeof (config) === "string") {
105 if (typeof (config) === "string") {
106 return c.loadConfiguration(config, ct);
106 return c.loadConfiguration(config, opts && opts.contextRequire, ct);
107 } else {
107 } else {
108 return c.applyConfiguration(config, opts && opts.contextRequire, ct);
108 return c.applyConfiguration(config, opts && opts.contextRequire, ct);
109 }
109 }
@@ -2,6 +2,8 export type Constructor<T = {}> = new (.
2
2
3 export type Factory<T = {}> = (...args: any[]) => T;
3 export type Factory<T = {}> = (...args: any[]) => T;
4
4
5 export type Predicate<T = any> = (x: T) => boolean;
6
5 export interface MapOf<T> {
7 export interface MapOf<T> {
6 [key: string]: T;
8 [key: string]: T;
7 }
9 }
@@ -47,7 +47,7 export class TraceSource {
47
47
48 debug(msg: string, ...args: any[]) {
48 debug(msg: string, ...args: any[]) {
49 if (this.isEnabled(DebugLevel))
49 if (this.isEnabled(DebugLevel))
50 this.emit(DebugLevel, format(msg, args));
50 this.emit(DebugLevel, format.apply(null, arguments));
51 }
51 }
52
52
53 isLogEnabled() {
53 isLogEnabled() {
@@ -56,7 +56,7 export class TraceSource {
56
56
57 log(msg: string, ...args: any[]) {
57 log(msg: string, ...args: any[]) {
58 if (this.isEnabled(LogLevel))
58 if (this.isEnabled(LogLevel))
59 this.emit(LogLevel, format(msg, args));
59 this.emit(LogLevel, format.apply(null, arguments));
60 }
60 }
61
61
62 isWarnEnabled() {
62 isWarnEnabled() {
@@ -65,7 +65,7 export class TraceSource {
65
65
66 warn(msg: string, ...args: any[]) {
66 warn(msg: string, ...args: any[]) {
67 if (this.isEnabled(WarnLevel))
67 if (this.isEnabled(WarnLevel))
68 this.emit(WarnLevel, format(msg, args));
68 this.emit(WarnLevel, format.apply(null, arguments));
69 }
69 }
70
70
71 /**
71 /**
@@ -3,6 +3,15 import { TraceEvent, LogLevel, WarnLevel
3 import { Cancellation } from "../../Cancellation";
3 import { Cancellation } from "../../Cancellation";
4 import { destroy } from "../../safe";
4 import { destroy } from "../../safe";
5
5
6 function hasConsole() {
7 try {
8 // tslint:disable-next-line:no-console
9 return (typeof console !== "undefined" && typeof console.log === "function");
10 } catch {
11 return false;
12 }
13 }
14
6 export class ConsoleWriter implements IDestroyable {
15 export class ConsoleWriter implements IDestroyable {
7 readonly _subscriptions = new Array<IDestroyable>();
16 readonly _subscriptions = new Array<IDestroyable>();
8
17
@@ -15,17 +24,21 export class ConsoleWriter implements ID
15 }
24 }
16
25
17 writeEvent(next: TraceEvent) {
26 writeEvent(next: TraceEvent) {
27 // IE will create console only when devepoler tools are activated
28 if (!hasConsole())
29 return;
30
18 if (next.level >= DebugLevel) {
31 if (next.level >= DebugLevel) {
19 // tslint:disable-next-line
32 // tslint:disable-next-line:no-console
20 console.debug(next.source.id.toString(), next.arg);
33 console.debug(next.source.id.toString(), next.arg);
21 } else if (next.level >= LogLevel) {
34 } else if (next.level >= LogLevel) {
22 // tslint:disable-next-line
35 // tslint:disable-next-line:no-console
23 console.log(next.source.id.toString(), next.arg);
36 console.log(next.source.id.toString(), next.arg);
24 } else if (next.level >= WarnLevel) {
37 } else if (next.level >= WarnLevel) {
25 // tslint:disable-next-line
38 // tslint:disable-next-line:no-console
26 console.warn(next.source.id.toString(), next.arg);
39 console.warn(next.source.id.toString(), next.arg);
27 } else {
40 } else {
28 // tslint:disable-next-line
41 // tslint:disable-next-line:no-console
29 console.error(next.source.id.toString(), next.arg);
42 console.error(next.source.id.toString(), next.arg);
30 }
43 }
31 }
44 }
@@ -1,9 +1,8
1 import { test, TapeWriter } from "./TestTraits";
1 import { test } from "./TestTraits";
2 import { Container } from "@implab/core/di/Container";
2 import { Container } from "@implab/core/di/Container";
3 import { ReferenceDescriptor } from "@implab/core/di/ReferenceDescriptor";
3 import { ReferenceDescriptor } from "@implab/core/di/ReferenceDescriptor";
4 import { AggregateDescriptor } from "@implab/core/di/AggregateDescriptor";
4 import { AggregateDescriptor } from "@implab/core/di/AggregateDescriptor";
5 import { ValueDescriptor } from "@implab/core/di/ValueDescriptor";
5 import { ValueDescriptor } from "@implab/core/di/ValueDescriptor";
6 import { TraceSource, DebugLevel } from "@implab/core/log/TraceSource";
7 import { Foo } from "./mock/Foo";
6 import { Foo } from "./mock/Foo";
8 import { Bar } from "./mock/Bar";
7 import { Bar } from "./mock/Bar";
9 import { isNull } from "@implab/core/safe";
8 import { isNull } from "@implab/core/safe";
@@ -2,7 +2,7 import { IObservable, ICancellation, IDe
2 import { Cancellation } from "@implab/core/Cancellation";
2 import { Cancellation } from "@implab/core/Cancellation";
3 import { TraceEvent, LogLevel, WarnLevel, DebugLevel, TraceSource } from "@implab/core/log/TraceSource";
3 import { TraceEvent, LogLevel, WarnLevel, DebugLevel, TraceSource } from "@implab/core/log/TraceSource";
4 import * as tape from "tape";
4 import * as tape from "tape";
5 import { argumentNotNull } from "@implab/core/safe";
5 import { argumentNotNull, destroy } from "@implab/core/safe";
6
6
7 export class TapeWriter implements IDestroyable {
7 export class TapeWriter implements IDestroyable {
8 readonly _tape: tape.Test;
8 readonly _tape: tape.Test;
@@ -35,7 +35,7 export class TapeWriter implements IDest
35 }
35 }
36
36
37 destroy() {
37 destroy() {
38 this._subscriptions.forEach(x => x.destroy());
38 this._subscriptions.forEach(destroy);
39 }
39 }
40 }
40 }
41
41
@@ -58,8 +58,7 export async function delay(timeout: num
58 }
58 }
59 });
59 });
60 } finally {
60 } finally {
61 if (un)
61 destroy(un);
62 un.destroy();
63 }
62 }
64 }
63 }
65
64
@@ -83,7 +82,7 export function test(name: string, cb: (
83
82
84 } finally {
83 } finally {
85 t.end();
84 t.end();
86 writer.destroy();
85 destroy(writer);
87 }
86 }
88 });
87 });
89 }
88 }
@@ -5,7 +5,7
5 "baseUrl": ".",
5 "baseUrl": ".",
6 "paths": {
6 "paths": {
7 "@implab/core/*": [
7 "@implab/core/*": [
8 "../../build/dist/amd/*"
8 "../../build/dist/*"
9 ]
9 ]
10 }
10 }
11 },
11 },
@@ -1,18 +1,10
1 {
1 {
2 "compilerOptions": {
2 "compilerOptions": {
3 "target": "es3",
4 "sourceMap": true,
5 "declaration": true,
6 "moduleResolution": "node",
3 "moduleResolution": "node",
7 "noEmitOnError": true,
4 "noEmitOnError": true,
8 "listFiles": true,
5 "listFiles": true,
9 "lib": [
6 "types": [],
10 "es5",
7 "lib": ["es5", "es2015.promise", "es2015.symbol", "dom", "scripthost"]
11 "es2015.promise",
12 "es2015.symbol",
13 "dom"
14 ],
15 "types": []
16 },
8 },
17 "files": []
9 "files": []
18 } No newline at end of file
10 }
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now