| @@ -0,0 +1,46 | |||||
|
|
1 | import { Uuid } from "../Uuid"; | |||
|
|
2 | import { argumentNotEmptyString } from "../safe"; | |||
|
|
3 | import { TraceSource } from "../log/TraceSource"; | |||
|
|
4 | ||||
|
|
5 | export interface RequireFn { | |||
|
|
6 | (module: string): any; | |||
|
|
7 | (modules: string[], cb?: (...args: any[]) => any): void; | |||
|
|
8 | } | |||
|
|
9 | ||||
|
|
10 | declare const require: RequireFn; | |||
|
|
11 | ||||
|
|
12 | export const rjs = require; | |||
|
|
13 | ||||
|
|
14 | declare function define(name: string, modules: string[], cb?: (...args: any[]) => any, eb?: (e) => any): void; | |||
|
|
15 | declare function define(modules: string[], cb?: (...args: any[]) => any, eb?: (e) => any): void; | |||
|
|
16 | ||||
|
|
17 | interface RequireJsResolverParams { | |||
|
|
18 | contextRequire: RequireFn; | |||
|
|
19 | } | |||
|
|
20 | ||||
|
|
21 | const trace = TraceSource.get("@implab/core/di/RequireJsHelper"); | |||
|
|
22 | ||||
|
|
23 | export async function createContextRequire(moduleName: string): Promise<RequireFn> { | |||
|
|
24 | argumentNotEmptyString(moduleName, "moduleName"); | |||
|
|
25 | ||||
|
|
26 | const parts = moduleName.split("/"); | |||
|
|
27 | if (parts[0] === ".") | |||
|
|
28 | throw new Error("An absolute module path is required"); | |||
|
|
29 | ||||
|
|
30 | if (parts.length > 1) | |||
|
|
31 | parts.splice(-1, 1, Uuid()); | |||
|
|
32 | else | |||
|
|
33 | parts.push(Uuid()); | |||
|
|
34 | ||||
|
|
35 | const shim = parts.join("/"); | |||
|
|
36 | ||||
|
|
37 | trace.debug(`define shim ${shim}`); | |||
|
|
38 | ||||
|
|
39 | return new Promise<RequireFn>(fulfill => { | |||
|
|
40 | define(shim, ["require"], r => { | |||
|
|
41 | trace.debug("shim resolved"); | |||
|
|
42 | return r; | |||
|
|
43 | }); | |||
|
|
44 | require([shim], fulfill); | |||
|
|
45 | }); | |||
|
|
46 | } | |||
| @@ -1,105 +1,111 | |||||
| 1 | if (release != 'rtm') { |
|
1 | if (release != 'rtm') { | |
| 2 | version += "-$release" |
|
2 | version += "-$release" | |
| 3 | } |
|
3 | } | |
| 4 |
|
4 | |||
| 5 | if(!npmName) |
|
5 | if(!npmName) | |
| 6 | npmName = name; |
|
6 | npmName = name; | |
| 7 |
|
7 | |||
| 8 | ext.packageName="$npmScope/$npmName"; |
|
8 | ext.packageName="$npmScope/$npmName"; | |
| 9 |
|
9 | |||
| 10 | def packageDir = "$buildDir/dist" |
|
10 | def packageDir = "$buildDir/dist" | |
| 11 | def distDir = "$packageDir/$platform" |
|
11 | def distDir = "$packageDir/$platform" | |
| 12 | def testDir = "$packageDir/$platform" |
|
12 | def testDir = "$packageDir/$platform" | |
| 13 |
|
13 | |||
| 14 | task printVersion { |
|
14 | task printVersion { | |
| 15 | println "version: $version" |
|
15 | doLast { | |
| 16 | println "packageName: $packageName" |
|
16 | println "version: $version" | |
| 17 |
println "p |
|
17 | println "packageName: $packageName" | |
|
|
18 | println "platform: $platform" | |||
|
|
19 | } | |||
| 18 | } |
|
20 | } | |
| 19 |
|
21 | |||
| 20 |
|
22 | |||
| 21 | task clean { |
|
23 | task clean { | |
| 22 | doLast { |
|
24 | doLast { | |
| 23 | delete buildDir |
|
25 | delete buildDir | |
| 24 | delete "node_modules/$packageName" |
|
26 | delete "node_modules/$packageName" | |
| 25 | } |
|
27 | } | |
| 26 | } |
|
28 | } | |
| 27 |
|
29 | |||
| 28 | task cleanNpm { |
|
30 | task cleanNpm { | |
| 29 | doLast { |
|
31 | doLast { | |
| 30 | delete 'node_modules' |
|
32 | delete 'node_modules' | |
| 31 | } |
|
33 | } | |
| 32 | } |
|
34 | } | |
| 33 |
|
35 | |||
| 34 | task _npmInstall() { |
|
36 | task _npmInstall() { | |
| 35 | inputs.file("package.json") |
|
37 | inputs.file("package.json") | |
| 36 | outputs.dir("node_modules") |
|
38 | outputs.dir("node_modules") | |
| 37 | doLast { |
|
39 | doLast { | |
| 38 | exec { |
|
40 | exec { | |
| 39 | commandLine 'npm', 'install' |
|
41 | commandLine 'npm', 'install' | |
| 40 | } |
|
42 | } | |
| 41 | } |
|
43 | } | |
| 42 | } |
|
44 | } | |
| 43 |
|
45 | |||
| 44 | task _legacyJs(type:Copy) { |
|
46 | task _legacyJs(type:Copy) { | |
| 45 | from 'src/js/' |
|
47 | from 'src/js/' | |
| 46 | into distDir |
|
48 | into distDir | |
| 47 | } |
|
49 | } | |
| 48 |
|
50 | |||
| 49 | task _buildTs(dependsOn: _npmInstall, type:Exec) { |
|
51 | task _buildTs(dependsOn: _npmInstall, type:Exec) { | |
| 50 | inputs.dir('src/ts') |
|
52 | inputs.dir('src/ts') | |
| 51 | inputs.file('tsconfig.json') |
|
53 | inputs.file('src/tsconfig.json') | |
| 52 | outputs.dir(distDir) |
|
54 | outputs.dir(distDir) | |
| 53 |
|
55 | |||
| 54 |
commandLine 'node_modules/.bin/tsc', |
|
56 | commandLine 'node_modules/.bin/tsc', | |
|
|
57 | '-p', 'src/tsconfig.json', | |||
|
|
58 | '--outDir', distDir, | |||
|
|
59 | '--listFiles', | |||
|
|
60 | '--traceResolution' | |||
| 55 | } |
|
61 | } | |
| 56 |
|
62 | |||
| 57 | task _packageMeta(type: Copy) { |
|
63 | task _packageMeta(type: Copy) { | |
| 58 | inputs.property("version", version) |
|
64 | inputs.property("version", version) | |
| 59 | from('.') { |
|
65 | from('.') { | |
| 60 | include 'package.json', '.npmignore', 'readme.md', 'license', 'history.md' |
|
66 | include 'package.json', '.npmignore', 'readme.md', 'license', 'history.md' | |
| 61 | } |
|
67 | } | |
| 62 | into distDir |
|
68 | into distDir | |
| 63 | doLast { |
|
69 | doLast { | |
| 64 | exec { |
|
70 | exec { | |
| 65 | workingDir distDir |
|
71 | workingDir distDir | |
| 66 | commandLine 'npm', 'version', version |
|
72 | commandLine 'npm', 'version', version | |
| 67 | } |
|
73 | } | |
| 68 | } |
|
74 | } | |
| 69 | } |
|
75 | } | |
| 70 |
|
76 | |||
| 71 | task build(dependsOn: [_legacyJs, _npmInstall, _buildTs, _packageMeta]) { |
|
77 | task build(dependsOn: [_legacyJs, _npmInstall, _buildTs, _packageMeta]) { | |
| 72 |
|
78 | |||
| 73 | } |
|
79 | } | |
| 74 |
|
80 | |||
| 75 | task _localInstall(dependsOn: build, type: Exec) { |
|
81 | task _localInstall(dependsOn: build, type: Exec) { | |
| 76 | inputs.file("$distDir/package.json") |
|
82 | inputs.file("$distDir/package.json") | |
| 77 | outputs.upToDateWhen { |
|
83 | outputs.upToDateWhen { | |
| 78 | new File("$projectDir/node_modules/$packageName").exists() |
|
84 | new File("$projectDir/node_modules/$packageName").exists() | |
| 79 | } |
|
85 | } | |
| 80 |
|
86 | |||
| 81 | commandLine 'npm', 'install', '--no-save', '--force', distDir |
|
87 | commandLine 'npm', 'install', '--no-save', '--force', distDir | |
| 82 | } |
|
88 | } | |
| 83 |
|
89 | |||
| 84 | task copyJsTests(type: Copy) { |
|
90 | task copyJsTests(type: Copy) { | |
| 85 | from 'test/js' |
|
91 | from 'test/js' | |
| 86 | into testDir |
|
92 | into testDir | |
| 87 | } |
|
93 | } | |
| 88 |
|
94 | |||
| 89 | task buildTests(dependsOn: _localInstall, type: Exec) { |
|
95 | task buildTests(dependsOn: _localInstall, type: Exec) { | |
| 90 | inputs.dir('test/ts') |
|
96 | inputs.dir('test/ts') | |
| 91 | inputs.file('test/tsconfig.json') |
|
97 | inputs.file('test/tsconfig.json') | |
| 92 | outputs.dir(testDir) |
|
98 | outputs.dir(testDir) | |
| 93 |
|
99 | |||
| 94 | commandLine 'node_modules/.bin/tsc', '-p', 'test/tsconfig.json', '--outDir', distDir |
|
100 | commandLine 'node_modules/.bin/tsc', '-p', 'test/tsconfig.json', '--outDir', distDir | |
| 95 | } |
|
101 | } | |
| 96 |
|
102 | |||
| 97 | task test(dependsOn: [copyJsTests, buildTests], type: Exec) { |
|
103 | task test(dependsOn: [copyJsTests, buildTests], type: Exec) { | |
| 98 | commandLine 'node', 'run-amd-tests.js' |
|
104 | commandLine 'node', 'run-amd-tests.js' | |
| 99 | } |
|
105 | } | |
| 100 |
|
106 | |||
| 101 | task pack(dependsOn: build, type: Exec) { |
|
107 | task pack(dependsOn: build, type: Exec) { | |
| 102 | workingDir = distDir |
|
108 | workingDir = distDir | |
| 103 |
|
109 | |||
| 104 | commandLine 'npm', 'pack' |
|
110 | commandLine 'npm', 'pack' | |
| 105 | } No newline at end of file |
|
111 | } | |
| @@ -1,450 +1,450 | |||||
| 1 | { |
|
1 | { | |
| 2 | "name": "@implab/core", |
|
2 | "name": "@implab/core", | |
| 3 | "version": "0.0.1-dev", |
|
3 | "version": "0.0.1-dev", | |
| 4 | "lockfileVersion": 1, |
|
4 | "lockfileVersion": 1, | |
| 5 | "requires": true, |
|
5 | "requires": true, | |
| 6 | "dependencies": { |
|
6 | "dependencies": { | |
| 7 | "@types/node": { |
|
7 | "@types/node": { | |
| 8 | "version": "10.12.12", |
|
8 | "version": "10.12.12", | |
| 9 | "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.12.tgz", |
|
9 | "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.12.tgz", | |
| 10 | "integrity": "sha512-Pr+6JRiKkfsFvmU/LK68oBRCQeEg36TyAbPhc2xpez24OOZZCuoIhWGTd39VZy6nGafSbxzGouFPTFD/rR1A0A==", |
|
10 | "integrity": "sha512-Pr+6JRiKkfsFvmU/LK68oBRCQeEg36TyAbPhc2xpez24OOZZCuoIhWGTd39VZy6nGafSbxzGouFPTFD/rR1A0A==", | |
| 11 | "dev": true |
|
11 | "dev": true | |
| 12 | }, |
|
12 | }, | |
| 13 | "@types/tape": { |
|
13 | "@types/tape": { | |
| 14 | "version": "4.2.32", |
|
14 | "version": "4.2.32", | |
| 15 | "resolved": "http://registry.npmjs.org/@types/tape/-/tape-4.2.32.tgz", |
|
15 | "resolved": "http://registry.npmjs.org/@types/tape/-/tape-4.2.32.tgz", | |
| 16 | "integrity": "sha512-xil0KO5wkPoixdBWGIGolPv9dekf6dVkjjJLAFYchfKcd4DICou67rgGCIO7wAh3i5Ff/6j9IDgZz+GU9cMaqQ==", |
|
16 | "integrity": "sha512-xil0KO5wkPoixdBWGIGolPv9dekf6dVkjjJLAFYchfKcd4DICou67rgGCIO7wAh3i5Ff/6j9IDgZz+GU9cMaqQ==", | |
| 17 | "dev": true, |
|
17 | "dev": true, | |
| 18 | "requires": { |
|
18 | "requires": { | |
| 19 | "@types/node": "*" |
|
19 | "@types/node": "*" | |
| 20 | } |
|
20 | } | |
| 21 | }, |
|
21 | }, | |
| 22 | "balanced-match": { |
|
22 | "balanced-match": { | |
| 23 | "version": "1.0.0", |
|
23 | "version": "1.0.0", | |
| 24 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", |
|
24 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", | |
| 25 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", |
|
25 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", | |
| 26 | "dev": true |
|
26 | "dev": true | |
| 27 | }, |
|
27 | }, | |
| 28 | "brace-expansion": { |
|
28 | "brace-expansion": { | |
| 29 | "version": "1.1.11", |
|
29 | "version": "1.1.11", | |
| 30 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", |
|
30 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", | |
| 31 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", |
|
31 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", | |
| 32 | "dev": true, |
|
32 | "dev": true, | |
| 33 | "requires": { |
|
33 | "requires": { | |
| 34 | "balanced-match": "^1.0.0", |
|
34 | "balanced-match": "^1.0.0", | |
| 35 | "concat-map": "0.0.1" |
|
35 | "concat-map": "0.0.1" | |
| 36 | } |
|
36 | } | |
| 37 | }, |
|
37 | }, | |
| 38 | "concat-map": { |
|
38 | "concat-map": { | |
| 39 | "version": "0.0.1", |
|
39 | "version": "0.0.1", | |
| 40 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", |
|
40 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", | |
| 41 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", |
|
41 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", | |
| 42 | "dev": true |
|
42 | "dev": true | |
| 43 | }, |
|
43 | }, | |
| 44 | "core-util-is": { |
|
44 | "core-util-is": { | |
| 45 | "version": "1.0.2", |
|
45 | "version": "1.0.2", | |
| 46 | "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", |
|
46 | "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", | |
| 47 | "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", |
|
47 | "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", | |
| 48 | "dev": true |
|
48 | "dev": true | |
| 49 | }, |
|
49 | }, | |
| 50 | "deep-equal": { |
|
50 | "deep-equal": { | |
| 51 | "version": "0.1.2", |
|
51 | "version": "0.1.2", | |
| 52 | "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-0.1.2.tgz", |
|
52 | "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-0.1.2.tgz", | |
| 53 | "integrity": "sha1-skbCuApXCkfBG+HZvRBw7IeLh84=", |
|
53 | "integrity": "sha1-skbCuApXCkfBG+HZvRBw7IeLh84=", | |
| 54 | "dev": true |
|
54 | "dev": true | |
| 55 | }, |
|
55 | }, | |
| 56 | "define-properties": { |
|
56 | "define-properties": { | |
| 57 | "version": "1.1.3", |
|
57 | "version": "1.1.3", | |
| 58 | "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", |
|
58 | "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", | |
| 59 | "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", |
|
59 | "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", | |
| 60 | "dev": true, |
|
60 | "dev": true, | |
| 61 | "requires": { |
|
61 | "requires": { | |
| 62 | "object-keys": "^1.0.12" |
|
62 | "object-keys": "^1.0.12" | |
| 63 | }, |
|
63 | }, | |
| 64 | "dependencies": { |
|
64 | "dependencies": { | |
| 65 | "object-keys": { |
|
65 | "object-keys": { | |
| 66 | "version": "1.0.12", |
|
66 | "version": "1.0.12", | |
| 67 | "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.12.tgz", |
|
67 | "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.12.tgz", | |
| 68 | "integrity": "sha512-FTMyFUm2wBcGHnH2eXmz7tC6IwlqQZ6mVZ+6dm6vZ4IQIHjs6FdNsQBuKGPuUUUY6NfJw2PshC08Tn6LzLDOag==", |
|
68 | "integrity": "sha512-FTMyFUm2wBcGHnH2eXmz7tC6IwlqQZ6mVZ+6dm6vZ4IQIHjs6FdNsQBuKGPuUUUY6NfJw2PshC08Tn6LzLDOag==", | |
| 69 | "dev": true |
|
69 | "dev": true | |
| 70 | } |
|
70 | } | |
| 71 | } |
|
71 | } | |
| 72 | }, |
|
72 | }, | |
| 73 | "defined": { |
|
73 | "defined": { | |
| 74 | "version": "0.0.0", |
|
74 | "version": "0.0.0", | |
| 75 | "resolved": "https://registry.npmjs.org/defined/-/defined-0.0.0.tgz", |
|
75 | "resolved": "https://registry.npmjs.org/defined/-/defined-0.0.0.tgz", | |
| 76 | "integrity": "sha1-817qfXBekzuvE7LwOz+D2SFAOz4=", |
|
76 | "integrity": "sha1-817qfXBekzuvE7LwOz+D2SFAOz4=", | |
| 77 | "dev": true |
|
77 | "dev": true | |
| 78 | }, |
|
78 | }, | |
| 79 | "dojo": { |
|
79 | "dojo": { | |
| 80 | "version": "1.14.2", |
|
80 | "version": "1.14.2", | |
| 81 | "resolved": "https://registry.npmjs.org/dojo/-/dojo-1.14.2.tgz", |
|
81 | "resolved": "https://registry.npmjs.org/dojo/-/dojo-1.14.2.tgz", | |
| 82 | "integrity": "sha512-TI+Ytgfh/VfmHWERp45Jte6NFMdoJTPsvUP/uzJUvAXET8FP2h442LePWWJ/q/xZ4V0V8OtdJhx8It/GB+Zbxg==", |
|
82 | "integrity": "sha512-TI+Ytgfh/VfmHWERp45Jte6NFMdoJTPsvUP/uzJUvAXET8FP2h442LePWWJ/q/xZ4V0V8OtdJhx8It/GB+Zbxg==", | |
| 83 | "dev": true |
|
83 | "dev": true | |
| 84 | }, |
|
84 | }, | |
| 85 | "duplexer": { |
|
85 | "duplexer": { | |
| 86 | "version": "0.1.1", |
|
86 | "version": "0.1.1", | |
| 87 | "resolved": "http://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", |
|
87 | "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", | |
| 88 | "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", |
|
88 | "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", | |
| 89 | "dev": true |
|
89 | "dev": true | |
| 90 | }, |
|
90 | }, | |
| 91 | "es-abstract": { |
|
91 | "es-abstract": { | |
| 92 | "version": "1.12.0", |
|
92 | "version": "1.12.0", | |
| 93 | "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.12.0.tgz", |
|
93 | "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.12.0.tgz", | |
| 94 | "integrity": "sha512-C8Fx/0jFmV5IPoMOFPA9P9G5NtqW+4cOPit3MIuvR2t7Ag2K15EJTpxnHAYTzL+aYQJIESYeXZmDBfOBE1HcpA==", |
|
94 | "integrity": "sha512-C8Fx/0jFmV5IPoMOFPA9P9G5NtqW+4cOPit3MIuvR2t7Ag2K15EJTpxnHAYTzL+aYQJIESYeXZmDBfOBE1HcpA==", | |
| 95 | "dev": true, |
|
95 | "dev": true, | |
| 96 | "requires": { |
|
96 | "requires": { | |
| 97 | "es-to-primitive": "^1.1.1", |
|
97 | "es-to-primitive": "^1.1.1", | |
| 98 | "function-bind": "^1.1.1", |
|
98 | "function-bind": "^1.1.1", | |
| 99 | "has": "^1.0.1", |
|
99 | "has": "^1.0.1", | |
| 100 | "is-callable": "^1.1.3", |
|
100 | "is-callable": "^1.1.3", | |
| 101 | "is-regex": "^1.0.4" |
|
101 | "is-regex": "^1.0.4" | |
| 102 | } |
|
102 | } | |
| 103 | }, |
|
103 | }, | |
| 104 | "es-to-primitive": { |
|
104 | "es-to-primitive": { | |
| 105 | "version": "1.2.0", |
|
105 | "version": "1.2.0", | |
| 106 | "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz", |
|
106 | "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz", | |
| 107 | "integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==", |
|
107 | "integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==", | |
| 108 | "dev": true, |
|
108 | "dev": true, | |
| 109 | "requires": { |
|
109 | "requires": { | |
| 110 | "is-callable": "^1.1.4", |
|
110 | "is-callable": "^1.1.4", | |
| 111 | "is-date-object": "^1.0.1", |
|
111 | "is-date-object": "^1.0.1", | |
| 112 | "is-symbol": "^1.0.2" |
|
112 | "is-symbol": "^1.0.2" | |
| 113 | } |
|
113 | } | |
| 114 | }, |
|
114 | }, | |
| 115 | "faucet": { |
|
115 | "faucet": { | |
| 116 | "version": "0.0.1", |
|
116 | "version": "0.0.1", | |
| 117 | "resolved": "https://registry.npmjs.org/faucet/-/faucet-0.0.1.tgz", |
|
117 | "resolved": "https://registry.npmjs.org/faucet/-/faucet-0.0.1.tgz", | |
| 118 | "integrity": "sha1-WX3PHSGJosBiMhtZHo8VHtIDnZw=", |
|
118 | "integrity": "sha1-WX3PHSGJosBiMhtZHo8VHtIDnZw=", | |
| 119 | "dev": true, |
|
119 | "dev": true, | |
| 120 | "requires": { |
|
120 | "requires": { | |
| 121 | "defined": "0.0.0", |
|
121 | "defined": "0.0.0", | |
| 122 | "duplexer": "~0.1.1", |
|
122 | "duplexer": "~0.1.1", | |
| 123 | "minimist": "0.0.5", |
|
123 | "minimist": "0.0.5", | |
| 124 | "sprintf": "~0.1.3", |
|
124 | "sprintf": "~0.1.3", | |
| 125 | "tap-parser": "~0.4.0", |
|
125 | "tap-parser": "~0.4.0", | |
| 126 | "tape": "~2.3.2", |
|
126 | "tape": "~2.3.2", | |
| 127 | "through2": "~0.2.3" |
|
127 | "through2": "~0.2.3" | |
| 128 | }, |
|
128 | }, | |
| 129 | "dependencies": { |
|
129 | "dependencies": { | |
| 130 | "tape": { |
|
130 | "tape": { | |
| 131 | "version": "2.3.3", |
|
131 | "version": "2.3.3", | |
| 132 | "resolved": "http://registry.npmjs.org/tape/-/tape-2.3.3.tgz", |
|
132 | "resolved": "https://registry.npmjs.org/tape/-/tape-2.3.3.tgz", | |
| 133 | "integrity": "sha1-Lnzgox3wn41oUWZKcYQuDKUFevc=", |
|
133 | "integrity": "sha1-Lnzgox3wn41oUWZKcYQuDKUFevc=", | |
| 134 | "dev": true, |
|
134 | "dev": true, | |
| 135 | "requires": { |
|
135 | "requires": { | |
| 136 | "deep-equal": "~0.1.0", |
|
136 | "deep-equal": "~0.1.0", | |
| 137 | "defined": "~0.0.0", |
|
137 | "defined": "~0.0.0", | |
| 138 | "inherits": "~2.0.1", |
|
138 | "inherits": "~2.0.1", | |
| 139 | "jsonify": "~0.0.0", |
|
139 | "jsonify": "~0.0.0", | |
| 140 | "resumer": "~0.0.0", |
|
140 | "resumer": "~0.0.0", | |
| 141 | "through": "~2.3.4" |
|
141 | "through": "~2.3.4" | |
| 142 | } |
|
142 | } | |
| 143 | } |
|
143 | } | |
| 144 | } |
|
144 | } | |
| 145 | }, |
|
145 | }, | |
| 146 | "for-each": { |
|
146 | "for-each": { | |
| 147 | "version": "0.3.3", |
|
147 | "version": "0.3.3", | |
| 148 | "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", |
|
148 | "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", | |
| 149 | "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", |
|
149 | "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", | |
| 150 | "dev": true, |
|
150 | "dev": true, | |
| 151 | "requires": { |
|
151 | "requires": { | |
| 152 | "is-callable": "^1.1.3" |
|
152 | "is-callable": "^1.1.3" | |
| 153 | } |
|
153 | } | |
| 154 | }, |
|
154 | }, | |
| 155 | "fs.realpath": { |
|
155 | "fs.realpath": { | |
| 156 | "version": "1.0.0", |
|
156 | "version": "1.0.0", | |
| 157 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", |
|
157 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", | |
| 158 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", |
|
158 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", | |
| 159 | "dev": true |
|
159 | "dev": true | |
| 160 | }, |
|
160 | }, | |
| 161 | "function-bind": { |
|
161 | "function-bind": { | |
| 162 | "version": "1.1.1", |
|
162 | "version": "1.1.1", | |
| 163 | "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", |
|
163 | "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", | |
| 164 | "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", |
|
164 | "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", | |
| 165 | "dev": true |
|
165 | "dev": true | |
| 166 | }, |
|
166 | }, | |
| 167 | "glob": { |
|
167 | "glob": { | |
| 168 | "version": "7.1.3", |
|
168 | "version": "7.1.3", | |
| 169 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", |
|
169 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", | |
| 170 | "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", |
|
170 | "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", | |
| 171 | "dev": true, |
|
171 | "dev": true, | |
| 172 | "requires": { |
|
172 | "requires": { | |
| 173 | "fs.realpath": "^1.0.0", |
|
173 | "fs.realpath": "^1.0.0", | |
| 174 | "inflight": "^1.0.4", |
|
174 | "inflight": "^1.0.4", | |
| 175 | "inherits": "2", |
|
175 | "inherits": "2", | |
| 176 | "minimatch": "^3.0.4", |
|
176 | "minimatch": "^3.0.4", | |
| 177 | "once": "^1.3.0", |
|
177 | "once": "^1.3.0", | |
| 178 | "path-is-absolute": "^1.0.0" |
|
178 | "path-is-absolute": "^1.0.0" | |
| 179 | } |
|
179 | } | |
| 180 | }, |
|
180 | }, | |
| 181 | "has": { |
|
181 | "has": { | |
| 182 | "version": "1.0.3", |
|
182 | "version": "1.0.3", | |
| 183 | "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", |
|
183 | "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", | |
| 184 | "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", |
|
184 | "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", | |
| 185 | "dev": true, |
|
185 | "dev": true, | |
| 186 | "requires": { |
|
186 | "requires": { | |
| 187 | "function-bind": "^1.1.1" |
|
187 | "function-bind": "^1.1.1" | |
| 188 | } |
|
188 | } | |
| 189 | }, |
|
189 | }, | |
| 190 | "has-symbols": { |
|
190 | "has-symbols": { | |
| 191 | "version": "1.0.0", |
|
191 | "version": "1.0.0", | |
| 192 | "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", |
|
192 | "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", | |
| 193 | "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", |
|
193 | "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", | |
| 194 | "dev": true |
|
194 | "dev": true | |
| 195 | }, |
|
195 | }, | |
| 196 | "inflight": { |
|
196 | "inflight": { | |
| 197 | "version": "1.0.6", |
|
197 | "version": "1.0.6", | |
| 198 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", |
|
198 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", | |
| 199 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", |
|
199 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", | |
| 200 | "dev": true, |
|
200 | "dev": true, | |
| 201 | "requires": { |
|
201 | "requires": { | |
| 202 | "once": "^1.3.0", |
|
202 | "once": "^1.3.0", | |
| 203 | "wrappy": "1" |
|
203 | "wrappy": "1" | |
| 204 | } |
|
204 | } | |
| 205 | }, |
|
205 | }, | |
| 206 | "inherits": { |
|
206 | "inherits": { | |
| 207 | "version": "2.0.3", |
|
207 | "version": "2.0.3", | |
| 208 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", |
|
208 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", | |
| 209 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", |
|
209 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", | |
| 210 | "dev": true |
|
210 | "dev": true | |
| 211 | }, |
|
211 | }, | |
| 212 | "is-callable": { |
|
212 | "is-callable": { | |
| 213 | "version": "1.1.4", |
|
213 | "version": "1.1.4", | |
| 214 | "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", |
|
214 | "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", | |
| 215 | "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==", |
|
215 | "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==", | |
| 216 | "dev": true |
|
216 | "dev": true | |
| 217 | }, |
|
217 | }, | |
| 218 | "is-date-object": { |
|
218 | "is-date-object": { | |
| 219 | "version": "1.0.1", |
|
219 | "version": "1.0.1", | |
| 220 | "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", |
|
220 | "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", | |
| 221 | "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", |
|
221 | "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", | |
| 222 | "dev": true |
|
222 | "dev": true | |
| 223 | }, |
|
223 | }, | |
| 224 | "is-regex": { |
|
224 | "is-regex": { | |
| 225 | "version": "1.0.4", |
|
225 | "version": "1.0.4", | |
| 226 | "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", |
|
226 | "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", | |
| 227 | "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", |
|
227 | "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", | |
| 228 | "dev": true, |
|
228 | "dev": true, | |
| 229 | "requires": { |
|
229 | "requires": { | |
| 230 | "has": "^1.0.1" |
|
230 | "has": "^1.0.1" | |
| 231 | } |
|
231 | } | |
| 232 | }, |
|
232 | }, | |
| 233 | "is-symbol": { |
|
233 | "is-symbol": { | |
| 234 | "version": "1.0.2", |
|
234 | "version": "1.0.2", | |
| 235 | "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", |
|
235 | "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", | |
| 236 | "integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==", |
|
236 | "integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==", | |
| 237 | "dev": true, |
|
237 | "dev": true, | |
| 238 | "requires": { |
|
238 | "requires": { | |
| 239 | "has-symbols": "^1.0.0" |
|
239 | "has-symbols": "^1.0.0" | |
| 240 | } |
|
240 | } | |
| 241 | }, |
|
241 | }, | |
| 242 | "isarray": { |
|
242 | "isarray": { | |
| 243 | "version": "0.0.1", |
|
243 | "version": "0.0.1", | |
| 244 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", |
|
244 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", | |
| 245 | "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", |
|
245 | "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", | |
| 246 | "dev": true |
|
246 | "dev": true | |
| 247 | }, |
|
247 | }, | |
| 248 | "jsonify": { |
|
248 | "jsonify": { | |
| 249 | "version": "0.0.0", |
|
249 | "version": "0.0.0", | |
| 250 | "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", |
|
250 | "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", | |
| 251 | "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", |
|
251 | "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", | |
| 252 | "dev": true |
|
252 | "dev": true | |
| 253 | }, |
|
253 | }, | |
| 254 | "minimatch": { |
|
254 | "minimatch": { | |
| 255 | "version": "3.0.4", |
|
255 | "version": "3.0.4", | |
| 256 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", |
|
256 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", | |
| 257 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", |
|
257 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", | |
| 258 | "dev": true, |
|
258 | "dev": true, | |
| 259 | "requires": { |
|
259 | "requires": { | |
| 260 | "brace-expansion": "^1.1.7" |
|
260 | "brace-expansion": "^1.1.7" | |
| 261 | } |
|
261 | } | |
| 262 | }, |
|
262 | }, | |
| 263 | "minimist": { |
|
263 | "minimist": { | |
| 264 | "version": "0.0.5", |
|
264 | "version": "0.0.5", | |
| 265 | "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.5.tgz", |
|
265 | "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.5.tgz", | |
| 266 | "integrity": "sha1-16oye87PUY+RBqxrjwA/o7zqhWY=", |
|
266 | "integrity": "sha1-16oye87PUY+RBqxrjwA/o7zqhWY=", | |
| 267 | "dev": true |
|
267 | "dev": true | |
| 268 | }, |
|
268 | }, | |
| 269 | "object-inspect": { |
|
269 | "object-inspect": { | |
| 270 | "version": "1.6.0", |
|
270 | "version": "1.6.0", | |
| 271 | "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.6.0.tgz", |
|
271 | "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.6.0.tgz", | |
| 272 | "integrity": "sha512-GJzfBZ6DgDAmnuaM3104jR4s1Myxr3Y3zfIyN4z3UdqN69oSRacNK8UhnobDdC+7J2AHCjGwxQubNJfE70SXXQ==", |
|
272 | "integrity": "sha512-GJzfBZ6DgDAmnuaM3104jR4s1Myxr3Y3zfIyN4z3UdqN69oSRacNK8UhnobDdC+7J2AHCjGwxQubNJfE70SXXQ==", | |
| 273 | "dev": true |
|
273 | "dev": true | |
| 274 | }, |
|
274 | }, | |
| 275 | "object-keys": { |
|
275 | "object-keys": { | |
| 276 | "version": "0.4.0", |
|
276 | "version": "0.4.0", | |
| 277 | "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.4.0.tgz", |
|
277 | "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.4.0.tgz", | |
| 278 | "integrity": "sha1-KKaq50KN0sOpLz2V8hM13SBOAzY=", |
|
278 | "integrity": "sha1-KKaq50KN0sOpLz2V8hM13SBOAzY=", | |
| 279 | "dev": true |
|
279 | "dev": true | |
| 280 | }, |
|
280 | }, | |
| 281 | "once": { |
|
281 | "once": { | |
| 282 | "version": "1.4.0", |
|
282 | "version": "1.4.0", | |
| 283 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", |
|
283 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", | |
| 284 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", |
|
284 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", | |
| 285 | "dev": true, |
|
285 | "dev": true, | |
| 286 | "requires": { |
|
286 | "requires": { | |
| 287 | "wrappy": "1" |
|
287 | "wrappy": "1" | |
| 288 | } |
|
288 | } | |
| 289 | }, |
|
289 | }, | |
| 290 | "path-is-absolute": { |
|
290 | "path-is-absolute": { | |
| 291 | "version": "1.0.1", |
|
291 | "version": "1.0.1", | |
| 292 | "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", |
|
292 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", | |
| 293 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", |
|
293 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", | |
| 294 | "dev": true |
|
294 | "dev": true | |
| 295 | }, |
|
295 | }, | |
| 296 | "path-parse": { |
|
296 | "path-parse": { | |
| 297 | "version": "1.0.6", |
|
297 | "version": "1.0.6", | |
| 298 | "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", |
|
298 | "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", | |
| 299 | "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", |
|
299 | "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", | |
| 300 | "dev": true |
|
300 | "dev": true | |
| 301 | }, |
|
301 | }, | |
| 302 | "readable-stream": { |
|
302 | "readable-stream": { | |
| 303 | "version": "1.1.14", |
|
303 | "version": "1.1.14", | |
| 304 | "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", |
|
304 | "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", | |
| 305 | "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", |
|
305 | "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", | |
| 306 | "dev": true, |
|
306 | "dev": true, | |
| 307 | "requires": { |
|
307 | "requires": { | |
| 308 | "core-util-is": "~1.0.0", |
|
308 | "core-util-is": "~1.0.0", | |
| 309 | "inherits": "~2.0.1", |
|
309 | "inherits": "~2.0.1", | |
| 310 | "isarray": "0.0.1", |
|
310 | "isarray": "0.0.1", | |
| 311 | "string_decoder": "~0.10.x" |
|
311 | "string_decoder": "~0.10.x" | |
| 312 | } |
|
312 | } | |
| 313 | }, |
|
313 | }, | |
| 314 | "requirejs": { |
|
314 | "requirejs": { | |
| 315 | "version": "2.3.6", |
|
315 | "version": "2.3.6", | |
| 316 | "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz", |
|
316 | "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.6.tgz", | |
| 317 | "integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==", |
|
317 | "integrity": "sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==", | |
| 318 | "dev": true |
|
318 | "dev": true | |
| 319 | }, |
|
319 | }, | |
| 320 | "resolve": { |
|
320 | "resolve": { | |
| 321 | "version": "1.7.1", |
|
321 | "version": "1.7.1", | |
| 322 | "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz", |
|
322 | "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz", | |
| 323 | "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==", |
|
323 | "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==", | |
| 324 | "dev": true, |
|
324 | "dev": true, | |
| 325 | "requires": { |
|
325 | "requires": { | |
| 326 | "path-parse": "^1.0.5" |
|
326 | "path-parse": "^1.0.5" | |
| 327 | } |
|
327 | } | |
| 328 | }, |
|
328 | }, | |
| 329 | "resumer": { |
|
329 | "resumer": { | |
| 330 | "version": "0.0.0", |
|
330 | "version": "0.0.0", | |
| 331 | "resolved": "https://registry.npmjs.org/resumer/-/resumer-0.0.0.tgz", |
|
331 | "resolved": "https://registry.npmjs.org/resumer/-/resumer-0.0.0.tgz", | |
| 332 | "integrity": "sha1-8ej0YeQGS6Oegq883CqMiT0HZ1k=", |
|
332 | "integrity": "sha1-8ej0YeQGS6Oegq883CqMiT0HZ1k=", | |
| 333 | "dev": true, |
|
333 | "dev": true, | |
| 334 | "requires": { |
|
334 | "requires": { | |
| 335 | "through": "~2.3.4" |
|
335 | "through": "~2.3.4" | |
| 336 | } |
|
336 | } | |
| 337 | }, |
|
337 | }, | |
| 338 | "sprintf": { |
|
338 | "sprintf": { | |
| 339 | "version": "0.1.5", |
|
339 | "version": "0.1.5", | |
| 340 | "resolved": "https://registry.npmjs.org/sprintf/-/sprintf-0.1.5.tgz", |
|
340 | "resolved": "https://registry.npmjs.org/sprintf/-/sprintf-0.1.5.tgz", | |
| 341 | "integrity": "sha1-j4PjmpMXwaUCy324BQ5Rxnn27c8=", |
|
341 | "integrity": "sha1-j4PjmpMXwaUCy324BQ5Rxnn27c8=", | |
| 342 | "dev": true |
|
342 | "dev": true | |
| 343 | }, |
|
343 | }, | |
| 344 | "string.prototype.trim": { |
|
344 | "string.prototype.trim": { | |
| 345 | "version": "1.1.2", |
|
345 | "version": "1.1.2", | |
| 346 | "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz", |
|
346 | "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz", | |
| 347 | "integrity": "sha1-0E3iyJ4Tf019IG8Ia17S+ua+jOo=", |
|
347 | "integrity": "sha1-0E3iyJ4Tf019IG8Ia17S+ua+jOo=", | |
| 348 | "dev": true, |
|
348 | "dev": true, | |
| 349 | "requires": { |
|
349 | "requires": { | |
| 350 | "define-properties": "^1.1.2", |
|
350 | "define-properties": "^1.1.2", | |
| 351 | "es-abstract": "^1.5.0", |
|
351 | "es-abstract": "^1.5.0", | |
| 352 | "function-bind": "^1.0.2" |
|
352 | "function-bind": "^1.0.2" | |
| 353 | } |
|
353 | } | |
| 354 | }, |
|
354 | }, | |
| 355 | "string_decoder": { |
|
355 | "string_decoder": { | |
| 356 | "version": "0.10.31", |
|
356 | "version": "0.10.31", | |
| 357 | "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", |
|
357 | "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", | |
| 358 | "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", |
|
358 | "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", | |
| 359 | "dev": true |
|
359 | "dev": true | |
| 360 | }, |
|
360 | }, | |
| 361 | "tap-parser": { |
|
361 | "tap-parser": { | |
| 362 | "version": "0.4.3", |
|
362 | "version": "0.4.3", | |
| 363 | "resolved": "https://registry.npmjs.org/tap-parser/-/tap-parser-0.4.3.tgz", |
|
363 | "resolved": "https://registry.npmjs.org/tap-parser/-/tap-parser-0.4.3.tgz", | |
| 364 | "integrity": "sha1-pOrhkMENdsehEZIf84u+TVjwnuo=", |
|
364 | "integrity": "sha1-pOrhkMENdsehEZIf84u+TVjwnuo=", | |
| 365 | "dev": true, |
|
365 | "dev": true, | |
| 366 | "requires": { |
|
366 | "requires": { | |
| 367 | "inherits": "~2.0.1", |
|
367 | "inherits": "~2.0.1", | |
| 368 | "readable-stream": "~1.1.11" |
|
368 | "readable-stream": "~1.1.11" | |
| 369 | } |
|
369 | } | |
| 370 | }, |
|
370 | }, | |
| 371 | "tape": { |
|
371 | "tape": { | |
| 372 | "version": "4.9.1", |
|
372 | "version": "4.9.1", | |
| 373 | "resolved": "https://registry.npmjs.org/tape/-/tape-4.9.1.tgz", |
|
373 | "resolved": "https://registry.npmjs.org/tape/-/tape-4.9.1.tgz", | |
| 374 | "integrity": "sha512-6fKIXknLpoe/Jp4rzHKFPpJUHDHDqn8jus99IfPnHIjyz78HYlefTGD3b5EkbQzuLfaEvmfPK3IolLgq2xT3kw==", |
|
374 | "integrity": "sha512-6fKIXknLpoe/Jp4rzHKFPpJUHDHDqn8jus99IfPnHIjyz78HYlefTGD3b5EkbQzuLfaEvmfPK3IolLgq2xT3kw==", | |
| 375 | "dev": true, |
|
375 | "dev": true, | |
| 376 | "requires": { |
|
376 | "requires": { | |
| 377 | "deep-equal": "~1.0.1", |
|
377 | "deep-equal": "~1.0.1", | |
| 378 | "defined": "~1.0.0", |
|
378 | "defined": "~1.0.0", | |
| 379 | "for-each": "~0.3.3", |
|
379 | "for-each": "~0.3.3", | |
| 380 | "function-bind": "~1.1.1", |
|
380 | "function-bind": "~1.1.1", | |
| 381 | "glob": "~7.1.2", |
|
381 | "glob": "~7.1.2", | |
| 382 | "has": "~1.0.3", |
|
382 | "has": "~1.0.3", | |
| 383 | "inherits": "~2.0.3", |
|
383 | "inherits": "~2.0.3", | |
| 384 | "minimist": "~1.2.0", |
|
384 | "minimist": "~1.2.0", | |
| 385 | "object-inspect": "~1.6.0", |
|
385 | "object-inspect": "~1.6.0", | |
| 386 | "resolve": "~1.7.1", |
|
386 | "resolve": "~1.7.1", | |
| 387 | "resumer": "~0.0.0", |
|
387 | "resumer": "~0.0.0", | |
| 388 | "string.prototype.trim": "~1.1.2", |
|
388 | "string.prototype.trim": "~1.1.2", | |
| 389 | "through": "~2.3.8" |
|
389 | "through": "~2.3.8" | |
| 390 | }, |
|
390 | }, | |
| 391 | "dependencies": { |
|
391 | "dependencies": { | |
| 392 | "deep-equal": { |
|
392 | "deep-equal": { | |
| 393 | "version": "1.0.1", |
|
393 | "version": "1.0.1", | |
| 394 | "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", |
|
394 | "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", | |
| 395 | "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=", |
|
395 | "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=", | |
| 396 | "dev": true |
|
396 | "dev": true | |
| 397 | }, |
|
397 | }, | |
| 398 | "defined": { |
|
398 | "defined": { | |
| 399 | "version": "1.0.0", |
|
399 | "version": "1.0.0", | |
| 400 | "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", |
|
400 | "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", | |
| 401 | "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", |
|
401 | "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", | |
| 402 | "dev": true |
|
402 | "dev": true | |
| 403 | }, |
|
403 | }, | |
| 404 | "minimist": { |
|
404 | "minimist": { | |
| 405 | "version": "1.2.0", |
|
405 | "version": "1.2.0", | |
| 406 | "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", |
|
406 | "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", | |
| 407 | "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", |
|
407 | "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", | |
| 408 | "dev": true |
|
408 | "dev": true | |
| 409 | } |
|
409 | } | |
| 410 | } |
|
410 | } | |
| 411 | }, |
|
411 | }, | |
| 412 | "through": { |
|
412 | "through": { | |
| 413 | "version": "2.3.8", |
|
413 | "version": "2.3.8", | |
| 414 | "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", |
|
414 | "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", | |
| 415 | "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", |
|
415 | "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", | |
| 416 | "dev": true |
|
416 | "dev": true | |
| 417 | }, |
|
417 | }, | |
| 418 | "through2": { |
|
418 | "through2": { | |
| 419 | "version": "0.2.3", |
|
419 | "version": "0.2.3", | |
| 420 | "resolved": "http://registry.npmjs.org/through2/-/through2-0.2.3.tgz", |
|
420 | "resolved": "https://registry.npmjs.org/through2/-/through2-0.2.3.tgz", | |
| 421 | "integrity": "sha1-6zKE2k6jEbbMis42U3SKUqvyWj8=", |
|
421 | "integrity": "sha1-6zKE2k6jEbbMis42U3SKUqvyWj8=", | |
| 422 | "dev": true, |
|
422 | "dev": true, | |
| 423 | "requires": { |
|
423 | "requires": { | |
| 424 | "readable-stream": "~1.1.9", |
|
424 | "readable-stream": "~1.1.9", | |
| 425 | "xtend": "~2.1.1" |
|
425 | "xtend": "~2.1.1" | |
| 426 | } |
|
426 | } | |
| 427 | }, |
|
427 | }, | |
| 428 | "typescript": { |
|
428 | "typescript": { | |
| 429 | "version": "3.2.1", |
|
429 | "version": "3.2.1", | |
| 430 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.2.1.tgz", |
|
430 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.2.1.tgz", | |
| 431 | "integrity": "sha512-jw7P2z/h6aPT4AENXDGjcfHTu5CSqzsbZc6YlUIebTyBAq8XaKp78x7VcSh30xwSCcsu5irZkYZUSFP1MrAMbg==", |
|
431 | "integrity": "sha512-jw7P2z/h6aPT4AENXDGjcfHTu5CSqzsbZc6YlUIebTyBAq8XaKp78x7VcSh30xwSCcsu5irZkYZUSFP1MrAMbg==", | |
| 432 | "dev": true |
|
432 | "dev": true | |
| 433 | }, |
|
433 | }, | |
| 434 | "wrappy": { |
|
434 | "wrappy": { | |
| 435 | "version": "1.0.2", |
|
435 | "version": "1.0.2", | |
| 436 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", |
|
436 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", | |
| 437 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", |
|
437 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", | |
| 438 | "dev": true |
|
438 | "dev": true | |
| 439 | }, |
|
439 | }, | |
| 440 | "xtend": { |
|
440 | "xtend": { | |
| 441 | "version": "2.1.2", |
|
441 | "version": "2.1.2", | |
| 442 | "resolved": "https://registry.npmjs.org/xtend/-/xtend-2.1.2.tgz", |
|
442 | "resolved": "https://registry.npmjs.org/xtend/-/xtend-2.1.2.tgz", | |
| 443 | "integrity": "sha1-bv7MKk2tjmlixJAbM3znuoe10os=", |
|
443 | "integrity": "sha1-bv7MKk2tjmlixJAbM3znuoe10os=", | |
| 444 | "dev": true, |
|
444 | "dev": true, | |
| 445 | "requires": { |
|
445 | "requires": { | |
| 446 | "object-keys": "~0.4.0" |
|
446 | "object-keys": "~0.4.0" | |
| 447 | } |
|
447 | } | |
| 448 | } |
|
448 | } | |
| 449 | } |
|
449 | } | |
| 450 | } |
|
450 | } | |
| @@ -1,267 +1,269 | |||||
| 1 | // Typescript port of the uuid.js |
|
1 | // Typescript port of the uuid.js | |
| 2 | // Copyright (c) 2018 Sergey Smirnov |
|
2 | // Copyright (c) 2018 Sergey Smirnov | |
| 3 | // BSD-2-Clause License https://opensource.org/licenses/BSD-2-Clause |
|
3 | // BSD-2-Clause License https://opensource.org/licenses/BSD-2-Clause | |
| 4 | // |
|
4 | // | |
| 5 | // uuid.js |
|
5 | // uuid.js | |
| 6 | // Copyright (c) 2010-2012 Robert Kieffer |
|
6 | // Copyright (c) 2010-2012 Robert Kieffer | |
| 7 | // MIT License - http://opensource.org/licenses/mit-license.php |
|
7 | // MIT License - http://opensource.org/licenses/mit-license.php | |
| 8 |
|
8 | |||
| 9 |
declare |
|
9 | declare const window: any; | |
|
|
10 | declare const require; | |||
|
|
11 | declare const Buffer; | |||
| 10 |
|
12 | |||
| 11 | const _window: any = "undefined" !== typeof window ? window : null; |
|
13 | const _window: any = "undefined" !== typeof window ? window : null; | |
| 12 |
|
14 | |||
| 13 | // Unique ID creation requires a high quality random # generator. We |
|
15 | // Unique ID creation requires a high quality random # generator. We | |
| 14 | // feature |
|
16 | // feature | |
| 15 | // detect to determine the best RNG source, normalizing to a function |
|
17 | // detect to determine the best RNG source, normalizing to a function | |
| 16 | // that |
|
18 | // that | |
| 17 | // returns 128-bits of randomness, since that's what's usually required |
|
19 | // returns 128-bits of randomness, since that's what's usually required | |
| 18 | let _rng; |
|
20 | let _rng; | |
| 19 |
|
21 | |||
| 20 | function setupBrowser() { |
|
22 | function setupBrowser() { | |
| 21 | // Allow for MSIE11 msCrypto |
|
23 | // Allow for MSIE11 msCrypto | |
| 22 | const _crypto = _window.crypto || _window.msCrypto; |
|
24 | const _crypto = _window.crypto || _window.msCrypto; | |
| 23 |
|
25 | |||
| 24 | if (!_rng && _crypto && _crypto.getRandomValues) { |
|
26 | if (!_rng && _crypto && _crypto.getRandomValues) { | |
| 25 | // WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto |
|
27 | // WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto | |
| 26 | // |
|
28 | // | |
| 27 | // Moderately fast, high quality |
|
29 | // Moderately fast, high quality | |
| 28 | try { |
|
30 | try { | |
| 29 | const _rnds8 = new Uint8Array(16); |
|
31 | const _rnds8 = new Uint8Array(16); | |
| 30 | _rng = function whatwgRNG() { |
|
32 | _rng = function whatwgRNG() { | |
| 31 | _crypto.getRandomValues(_rnds8); |
|
33 | _crypto.getRandomValues(_rnds8); | |
| 32 | return _rnds8; |
|
34 | return _rnds8; | |
| 33 | }; |
|
35 | }; | |
| 34 | _rng(); |
|
36 | _rng(); | |
| 35 | } catch (e) { /**/ } |
|
37 | } catch (e) { /**/ } | |
| 36 | } |
|
38 | } | |
| 37 |
|
39 | |||
| 38 | if (!_rng) { |
|
40 | if (!_rng) { | |
| 39 | // Math.random()-based (RNG) |
|
41 | // Math.random()-based (RNG) | |
| 40 | // |
|
42 | // | |
| 41 | // If all else fails, use Math.random(). It's fast, but is of |
|
43 | // If all else fails, use Math.random(). It's fast, but is of | |
| 42 | // unspecified |
|
44 | // unspecified | |
| 43 | // quality. |
|
45 | // quality. | |
| 44 | const _rnds = new Array(16); |
|
46 | const _rnds = new Array(16); | |
| 45 | _rng = () => { |
|
47 | _rng = () => { | |
| 46 | for (let i = 0, r; i < 16; i++) { |
|
48 | for (let i = 0, r; i < 16; i++) { | |
| 47 | if ((i & 0x03) === 0) { |
|
49 | if ((i & 0x03) === 0) { | |
| 48 | r = Math.random() * 0x100000000; |
|
50 | r = Math.random() * 0x100000000; | |
| 49 | } |
|
51 | } | |
| 50 | _rnds[i] = r >>> ((i & 0x03) << 3) & 0xff; |
|
52 | _rnds[i] = r >>> ((i & 0x03) << 3) & 0xff; | |
| 51 | } |
|
53 | } | |
| 52 |
|
54 | |||
| 53 | return _rnds; |
|
55 | return _rnds; | |
| 54 | }; |
|
56 | }; | |
| 55 | if ("undefined" !== typeof console && console.warn) { |
|
57 | if ("undefined" !== typeof console && console.warn) { | |
| 56 | console.warn("[SECURITY] node-uuid: crypto not usable, falling back to insecure Math.random()"); |
|
58 | console.warn("[SECURITY] node-uuid: crypto not usable, falling back to insecure Math.random()"); | |
| 57 | } |
|
59 | } | |
| 58 | } |
|
60 | } | |
| 59 | } |
|
61 | } | |
| 60 |
|
62 | |||
| 61 | function setupNode() { |
|
63 | function setupNode() { | |
| 62 | // Node.js crypto-based RNG - |
|
64 | // Node.js crypto-based RNG - | |
| 63 | // http://nodejs.org/docs/v0.6.2/api/crypto.html |
|
65 | // http://nodejs.org/docs/v0.6.2/api/crypto.html | |
| 64 | // |
|
66 | // | |
| 65 | // Moderately fast, high quality |
|
67 | // Moderately fast, high quality | |
| 66 | if ("function" === typeof require) { |
|
68 | if ("function" === typeof require) { | |
| 67 | try { |
|
69 | try { | |
| 68 | const _rb = require("crypto").randomBytes; |
|
70 | const _rb = require("crypto").randomBytes; | |
| 69 | _rng = _rb && (() => _rb(16)); |
|
71 | _rng = _rb && (() => _rb(16)); | |
| 70 | _rng(); |
|
72 | _rng(); | |
| 71 | } catch (e) { /**/ } |
|
73 | } catch (e) { /**/ } | |
| 72 | } |
|
74 | } | |
| 73 | } |
|
75 | } | |
| 74 |
|
76 | |||
| 75 | if (_window) { |
|
77 | if (_window) { | |
| 76 | setupBrowser(); |
|
78 | setupBrowser(); | |
| 77 | } else { |
|
79 | } else { | |
| 78 | setupNode(); |
|
80 | setupNode(); | |
| 79 | } |
|
81 | } | |
| 80 |
|
82 | |||
| 81 | // Buffer class to use |
|
83 | // Buffer class to use | |
| 82 | const BufferClass = ("function" === typeof Buffer) ? Buffer : Array; |
|
84 | const BufferClass = ("function" === typeof Buffer) ? Buffer : Array; | |
| 83 |
|
85 | |||
| 84 | // Maps for number <-> hex string conversion |
|
86 | // Maps for number <-> hex string conversion | |
| 85 | const _byteToHex = []; |
|
87 | const _byteToHex = []; | |
| 86 | const _hexToByte = {}; |
|
88 | const _hexToByte = {}; | |
| 87 | for (let i = 0; i < 256; i++) { |
|
89 | for (let i = 0; i < 256; i++) { | |
| 88 | _byteToHex[i] = (i + 0x100).toString(16).substr(1); |
|
90 | _byteToHex[i] = (i + 0x100).toString(16).substr(1); | |
| 89 | _hexToByte[_byteToHex[i]] = i; |
|
91 | _hexToByte[_byteToHex[i]] = i; | |
| 90 | } |
|
92 | } | |
| 91 |
|
93 | |||
| 92 | // **`parse()` - Parse a UUID into it's component bytes** |
|
94 | // **`parse()` - Parse a UUID into it's component bytes** | |
| 93 | export function _parse(s, buf?, offset?): Array<string> { |
|
95 | export function _parse(s, buf?, offset?): Array<string> { | |
| 94 | const i = (buf && offset) || 0; let ii = 0; |
|
96 | const i = (buf && offset) || 0; let ii = 0; | |
| 95 |
|
97 | |||
| 96 | buf = buf || []; |
|
98 | buf = buf || []; | |
| 97 | s.toLowerCase().replace(/[0-9a-f]{2}/g, oct => { |
|
99 | s.toLowerCase().replace(/[0-9a-f]{2}/g, oct => { | |
| 98 | if (ii < 16) { // Don't overflow! |
|
100 | if (ii < 16) { // Don't overflow! | |
| 99 | buf[i + ii++] = _hexToByte[oct]; |
|
101 | buf[i + ii++] = _hexToByte[oct]; | |
| 100 | } |
|
102 | } | |
| 101 | }); |
|
103 | }); | |
| 102 |
|
104 | |||
| 103 | // Zero out remaining bytes if string was short |
|
105 | // Zero out remaining bytes if string was short | |
| 104 | while (ii < 16) { |
|
106 | while (ii < 16) { | |
| 105 | buf[i + ii++] = 0; |
|
107 | buf[i + ii++] = 0; | |
| 106 | } |
|
108 | } | |
| 107 |
|
109 | |||
| 108 | return buf; |
|
110 | return buf; | |
| 109 | } |
|
111 | } | |
| 110 |
|
112 | |||
| 111 | // **`unparse()` - Convert UUID byte array (ala parse()) into a string** |
|
113 | // **`unparse()` - Convert UUID byte array (ala parse()) into a string** | |
| 112 | function _unparse(buf, offset?): string { |
|
114 | function _unparse(buf, offset?): string { | |
| 113 | let i = offset || 0; const bth = _byteToHex; |
|
115 | let i = offset || 0; const bth = _byteToHex; | |
| 114 | return bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + |
|
116 | return bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + | |
| 115 | bth[buf[i++]] + "-" + bth[buf[i++]] + bth[buf[i++]] + "-" + |
|
117 | bth[buf[i++]] + "-" + bth[buf[i++]] + bth[buf[i++]] + "-" + | |
| 116 | bth[buf[i++]] + bth[buf[i++]] + "-" + bth[buf[i++]] + |
|
118 | bth[buf[i++]] + bth[buf[i++]] + "-" + bth[buf[i++]] + | |
| 117 | bth[buf[i++]] + "-" + bth[buf[i++]] + bth[buf[i++]] + |
|
119 | bth[buf[i++]] + "-" + bth[buf[i++]] + bth[buf[i++]] + | |
| 118 | bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]]; |
|
120 | bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]] + bth[buf[i++]]; | |
| 119 | } |
|
121 | } | |
| 120 |
|
122 | |||
| 121 | // **`v1()` - Generate time-based UUID** |
|
123 | // **`v1()` - Generate time-based UUID** | |
| 122 | // |
|
124 | // | |
| 123 | // Inspired by https://github.com/LiosK/UUID.js |
|
125 | // Inspired by https://github.com/LiosK/UUID.js | |
| 124 | // and http://docs.python.org/library/uuid.html |
|
126 | // and http://docs.python.org/library/uuid.html | |
| 125 |
|
127 | |||
| 126 | // random #'s we need to init node and clockseq |
|
128 | // random #'s we need to init node and clockseq | |
| 127 | const _seedBytes = _rng(); |
|
129 | const _seedBytes = _rng(); | |
| 128 |
|
130 | |||
| 129 | // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = |
|
131 | // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = | |
| 130 | // 1) |
|
132 | // 1) | |
| 131 | const _nodeId = [ |
|
133 | const _nodeId = [ | |
| 132 | _seedBytes[0] | 0x01, |
|
134 | _seedBytes[0] | 0x01, | |
| 133 | _seedBytes[1], |
|
135 | _seedBytes[1], | |
| 134 | _seedBytes[2], |
|
136 | _seedBytes[2], | |
| 135 | _seedBytes[3], |
|
137 | _seedBytes[3], | |
| 136 | _seedBytes[4], |
|
138 | _seedBytes[4], | |
| 137 | _seedBytes[5] |
|
139 | _seedBytes[5] | |
| 138 | ]; |
|
140 | ]; | |
| 139 |
|
141 | |||
| 140 | // Per 4.2.2, randomize (14 bit) clockseq |
|
142 | // Per 4.2.2, randomize (14 bit) clockseq | |
| 141 | let _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 0x3fff; |
|
143 | let _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 0x3fff; | |
| 142 |
|
144 | |||
| 143 | // Previous uuid creation time |
|
145 | // Previous uuid creation time | |
| 144 | let _lastMSecs = 0; let _lastNSecs = 0; |
|
146 | let _lastMSecs = 0; let _lastNSecs = 0; | |
| 145 |
|
147 | |||
| 146 | // See https://github.com/broofa/node-uuid for API details |
|
148 | // See https://github.com/broofa/node-uuid for API details | |
| 147 | export function _v1(options?, buf?, offset?): string { |
|
149 | export function _v1(options?, buf?, offset?): string { | |
| 148 | let i = buf && offset || 0; |
|
150 | let i = buf && offset || 0; | |
| 149 | const b = buf || []; |
|
151 | const b = buf || []; | |
| 150 |
|
152 | |||
| 151 | options = options || {}; |
|
153 | options = options || {}; | |
| 152 |
|
154 | |||
| 153 | let clockseq = (options.clockseq != null) ? options.clockseq : _clockseq; |
|
155 | let clockseq = (options.clockseq != null) ? options.clockseq : _clockseq; | |
| 154 |
|
156 | |||
| 155 | // UUID timestamps are 100 nano-second units since the Gregorian |
|
157 | // UUID timestamps are 100 nano-second units since the Gregorian | |
| 156 | // epoch, |
|
158 | // epoch, | |
| 157 | // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so |
|
159 | // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so | |
| 158 | // time is handled internally as 'msecs' (integer milliseconds) and |
|
160 | // time is handled internally as 'msecs' (integer milliseconds) and | |
| 159 | // 'nsecs' |
|
161 | // 'nsecs' | |
| 160 | // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 |
|
162 | // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 | |
| 161 | // 00:00. |
|
163 | // 00:00. | |
| 162 | let msecs = (options.msecs != null) ? options.msecs : new Date() |
|
164 | let msecs = (options.msecs != null) ? options.msecs : new Date() | |
| 163 | .getTime(); |
|
165 | .getTime(); | |
| 164 |
|
166 | |||
| 165 | // Per 4.2.1.2, use count of uuid's generated during the current |
|
167 | // Per 4.2.1.2, use count of uuid's generated during the current | |
| 166 | // clock |
|
168 | // clock | |
| 167 | // cycle to simulate higher resolution clock |
|
169 | // cycle to simulate higher resolution clock | |
| 168 | let nsecs = (options.nsecs != null) ? options.nsecs : _lastNSecs + 1; |
|
170 | let nsecs = (options.nsecs != null) ? options.nsecs : _lastNSecs + 1; | |
| 169 |
|
171 | |||
| 170 | // Time since last uuid creation (in msecs) |
|
172 | // Time since last uuid creation (in msecs) | |
| 171 | const dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs) / 10000; |
|
173 | const dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs) / 10000; | |
| 172 |
|
174 | |||
| 173 | // Per 4.2.1.2, Bump clockseq on clock regression |
|
175 | // Per 4.2.1.2, Bump clockseq on clock regression | |
| 174 | if (dt < 0 && options.clockseq == null) { |
|
176 | if (dt < 0 && options.clockseq == null) { | |
| 175 | clockseq = clockseq + 1 & 0x3fff; |
|
177 | clockseq = clockseq + 1 & 0x3fff; | |
| 176 | } |
|
178 | } | |
| 177 |
|
179 | |||
| 178 | // Reset nsecs if clock regresses (new clockseq) or we've moved onto |
|
180 | // Reset nsecs if clock regresses (new clockseq) or we've moved onto | |
| 179 | // a new |
|
181 | // a new | |
| 180 | // time interval |
|
182 | // time interval | |
| 181 | if ((dt < 0 || msecs > _lastMSecs) && options.nsecs == null) { |
|
183 | if ((dt < 0 || msecs > _lastMSecs) && options.nsecs == null) { | |
| 182 | nsecs = 0; |
|
184 | nsecs = 0; | |
| 183 | } |
|
185 | } | |
| 184 |
|
186 | |||
| 185 | // Per 4.2.1.2 Throw error if too many uuids are requested |
|
187 | // Per 4.2.1.2 Throw error if too many uuids are requested | |
| 186 | if (nsecs >= 10000) { |
|
188 | if (nsecs >= 10000) { | |
| 187 | throw new Error( |
|
189 | throw new Error( | |
| 188 | "uuid.v1(): Can't create more than 10M uuids/sec"); |
|
190 | "uuid.v1(): Can't create more than 10M uuids/sec"); | |
| 189 | } |
|
191 | } | |
| 190 |
|
192 | |||
| 191 | _lastMSecs = msecs; |
|
193 | _lastMSecs = msecs; | |
| 192 | _lastNSecs = nsecs; |
|
194 | _lastNSecs = nsecs; | |
| 193 | _clockseq = clockseq; |
|
195 | _clockseq = clockseq; | |
| 194 |
|
196 | |||
| 195 | // Per 4.1.4 - Convert from unix epoch to Gregorian epoch |
|
197 | // Per 4.1.4 - Convert from unix epoch to Gregorian epoch | |
| 196 | msecs += 12219292800000; |
|
198 | msecs += 12219292800000; | |
| 197 |
|
199 | |||
| 198 | // `time_low` |
|
200 | // `time_low` | |
| 199 | const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; |
|
201 | const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; | |
| 200 | b[i++] = tl >>> 24 & 0xff; |
|
202 | b[i++] = tl >>> 24 & 0xff; | |
| 201 | b[i++] = tl >>> 16 & 0xff; |
|
203 | b[i++] = tl >>> 16 & 0xff; | |
| 202 | b[i++] = tl >>> 8 & 0xff; |
|
204 | b[i++] = tl >>> 8 & 0xff; | |
| 203 | b[i++] = tl & 0xff; |
|
205 | b[i++] = tl & 0xff; | |
| 204 |
|
206 | |||
| 205 | // `time_mid` |
|
207 | // `time_mid` | |
| 206 | const tmh = (msecs / 0x100000000 * 10000) & 0xfffffff; |
|
208 | const tmh = (msecs / 0x100000000 * 10000) & 0xfffffff; | |
| 207 | b[i++] = tmh >>> 8 & 0xff; |
|
209 | b[i++] = tmh >>> 8 & 0xff; | |
| 208 | b[i++] = tmh & 0xff; |
|
210 | b[i++] = tmh & 0xff; | |
| 209 |
|
211 | |||
| 210 | // `time_high_and_version` |
|
212 | // `time_high_and_version` | |
| 211 | b[i++] = tmh >>> 24 & 0xf | 0x10; // include version |
|
213 | b[i++] = tmh >>> 24 & 0xf | 0x10; // include version | |
| 212 | b[i++] = tmh >>> 16 & 0xff; |
|
214 | b[i++] = tmh >>> 16 & 0xff; | |
| 213 |
|
215 | |||
| 214 | // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) |
|
216 | // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) | |
| 215 | b[i++] = clockseq >>> 8 | 0x80; |
|
217 | b[i++] = clockseq >>> 8 | 0x80; | |
| 216 |
|
218 | |||
| 217 | // `clock_seq_low` |
|
219 | // `clock_seq_low` | |
| 218 | b[i++] = clockseq & 0xff; |
|
220 | b[i++] = clockseq & 0xff; | |
| 219 |
|
221 | |||
| 220 | // `node` |
|
222 | // `node` | |
| 221 | const node = options.node || _nodeId; |
|
223 | const node = options.node || _nodeId; | |
| 222 | for (let n = 0; n < 6; n++) { |
|
224 | for (let n = 0; n < 6; n++) { | |
| 223 | b[i + n] = node[n]; |
|
225 | b[i + n] = node[n]; | |
| 224 | } |
|
226 | } | |
| 225 |
|
227 | |||
| 226 | return buf ? buf : _unparse(b); |
|
228 | return buf ? buf : _unparse(b); | |
| 227 | } |
|
229 | } | |
| 228 |
|
230 | |||
| 229 | // **`v4()` - Generate random UUID** |
|
231 | // **`v4()` - Generate random UUID** | |
| 230 |
|
232 | |||
| 231 | // See https://github.com/broofa/node-uuid for API details |
|
233 | // See https://github.com/broofa/node-uuid for API details | |
| 232 | export function _v4(options?, buf?, offset?): string { |
|
234 | export function _v4(options?, buf?, offset?): string { | |
| 233 | // Deprecated - 'format' argument, as supported in v1.2 |
|
235 | // Deprecated - 'format' argument, as supported in v1.2 | |
| 234 | const i = buf && offset || 0; |
|
236 | const i = buf && offset || 0; | |
| 235 |
|
237 | |||
| 236 | if (typeof (options) === "string") { |
|
238 | if (typeof (options) === "string") { | |
| 237 | buf = (options === "binary") ? new BufferClass(16) : null; |
|
239 | buf = (options === "binary") ? new BufferClass(16) : null; | |
| 238 | options = null; |
|
240 | options = null; | |
| 239 | } |
|
241 | } | |
| 240 | options = options || {}; |
|
242 | options = options || {}; | |
| 241 |
|
243 | |||
| 242 | const rnds = options.random || (options.rng || _rng)(); |
|
244 | const rnds = options.random || (options.rng || _rng)(); | |
| 243 |
|
245 | |||
| 244 | // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` |
|
246 | // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` | |
| 245 | rnds[6] = (rnds[6] & 0x0f) | 0x40; |
|
247 | rnds[6] = (rnds[6] & 0x0f) | 0x40; | |
| 246 | rnds[8] = (rnds[8] & 0x3f) | 0x80; |
|
248 | rnds[8] = (rnds[8] & 0x3f) | 0x80; | |
| 247 |
|
249 | |||
| 248 | // Copy bytes to buffer, if provided |
|
250 | // Copy bytes to buffer, if provided | |
| 249 | if (buf) { |
|
251 | if (buf) { | |
| 250 | for (let ii = 0; ii < 16; ii++) { |
|
252 | for (let ii = 0; ii < 16; ii++) { | |
| 251 | buf[i + ii] = rnds[ii]; |
|
253 | buf[i + ii] = rnds[ii]; | |
| 252 | } |
|
254 | } | |
| 253 | } |
|
255 | } | |
| 254 |
|
256 | |||
| 255 | return buf || _unparse(rnds); |
|
257 | return buf || _unparse(rnds); | |
| 256 | } |
|
258 | } | |
| 257 |
|
259 | |||
| 258 | export function Uuid() { |
|
260 | export function Uuid() { | |
| 259 | return _v4(); |
|
261 | return _v4(); | |
| 260 | } |
|
262 | } | |
| 261 |
|
263 | |||
| 262 | export namespace Uuid { |
|
264 | export namespace Uuid { | |
| 263 | export const v4 = _v4; |
|
265 | export const v4 = _v4; | |
| 264 | export const v1 = _v1; |
|
266 | export const v1 = _v1; | |
| 265 | export const empty = "00000000-0000-0000-0000-000000000000"; |
|
267 | export const empty = "00000000-0000-0000-0000-000000000000"; | |
| 266 | export const parse = _parse; |
|
268 | export const parse = _parse; | |
| 267 | } |
|
269 | } | |
| @@ -1,353 +1,353 | |||||
| 1 | import { |
|
1 | import { | |
| 2 | ServiceRegistration, |
|
2 | ServiceRegistration, | |
| 3 | TypeRegistration, |
|
3 | TypeRegistration, | |
| 4 | FactoryRegistration, |
|
4 | FactoryRegistration, | |
| 5 | ServiceMap, |
|
5 | ServiceMap, | |
| 6 | isDescriptor, |
|
6 | isDescriptor, | |
| 7 | isDependencyRegistration, |
|
7 | isDependencyRegistration, | |
| 8 | DependencyRegistration, |
|
8 | DependencyRegistration, | |
| 9 | ValueRegistration, |
|
9 | ValueRegistration, | |
| 10 | ActivationType, |
|
10 | ActivationType, | |
| 11 | isValueRegistration, |
|
11 | isValueRegistration, | |
| 12 | isTypeRegistration, |
|
12 | isTypeRegistration, | |
| 13 | isFactoryRegistration |
|
13 | isFactoryRegistration | |
| 14 | } from "./interfaces"; |
|
14 | } from "./interfaces"; | |
| 15 |
|
15 | |||
| 16 | import { argumentNotEmptyString, isPrimitive, isPromise, delegate, argumentOfType, argumentNotNull, get } from "../safe"; |
|
16 | import { argumentNotEmptyString, isPrimitive, isPromise, delegate, argumentOfType, argumentNotNull, get } from "../safe"; | |
| 17 | import { AggregateDescriptor } from "./AggregateDescriptor"; |
|
17 | import { AggregateDescriptor } from "./AggregateDescriptor"; | |
| 18 | import { ValueDescriptor } from "./ValueDescriptor"; |
|
18 | import { ValueDescriptor } from "./ValueDescriptor"; | |
| 19 | import { Container } from "./Container"; |
|
19 | import { Container } from "./Container"; | |
| 20 | import { ReferenceDescriptor } from "./ReferenceDescriptor"; |
|
20 | import { ReferenceDescriptor } from "./ReferenceDescriptor"; | |
| 21 | import { TypeServiceDescriptor } from "./TypeServiceDescriptor"; |
|
21 | import { TypeServiceDescriptor } from "./TypeServiceDescriptor"; | |
| 22 | import { FactoryServiceDescriptor } from "./FactoryServiceDescriptor"; |
|
22 | import { FactoryServiceDescriptor } from "./FactoryServiceDescriptor"; | |
| 23 | import { rjs, createContextRequire, RequireFn } from "./RequireJsHelper"; |
|
23 | import { rjs, createContextRequire, RequireFn } from "../../amd/ts/RequireJsHelper"; | |
| 24 | import { TraceSource } from "../log/TraceSource"; |
|
24 | import { TraceSource } from "../log/TraceSource"; | |
| 25 | import { ConfigError } from "./ConfigError"; |
|
25 | import { ConfigError } from "./ConfigError"; | |
| 26 | import { Cancellation } from "../Cancellation"; |
|
26 | import { Cancellation } from "../Cancellation"; | |
| 27 |
|
27 | |||
| 28 | const trace = TraceSource.get("@implab/core/di/Configuration"); |
|
28 | const trace = TraceSource.get("@implab/core/di/Configuration"); | |
| 29 |
|
29 | |||
| 30 | async function mapAll(data: object | any[], map?: (v, k) => any): Promise<any> { |
|
30 | async function mapAll(data: object | any[], map?: (v, k) => any): Promise<any> { | |
| 31 | if (data instanceof Array) { |
|
31 | if (data instanceof Array) { | |
| 32 | return Promise.all(map ? data.map(map) : data); |
|
32 | return Promise.all(map ? data.map(map) : data); | |
| 33 | } else { |
|
33 | } else { | |
| 34 | const keys = Object.keys(data); |
|
34 | const keys = Object.keys(data); | |
| 35 |
|
35 | |||
| 36 | const o: any = {}; |
|
36 | const o: any = {}; | |
| 37 |
|
37 | |||
| 38 | await Promise.all(keys.map(async k => { |
|
38 | await Promise.all(keys.map(async k => { | |
| 39 | const v = map ? map(data[k], k) : data[k]; |
|
39 | const v = map ? map(data[k], k) : data[k]; | |
| 40 | o[k] = isPromise(v) ? await v : v; |
|
40 | o[k] = isPromise(v) ? await v : v; | |
| 41 | })); |
|
41 | })); | |
| 42 |
|
42 | |||
| 43 | return o; |
|
43 | return o; | |
| 44 | } |
|
44 | } | |
| 45 | } |
|
45 | } | |
| 46 |
|
46 | |||
| 47 | interface MapOf<T> { |
|
47 | interface MapOf<T> { | |
| 48 | [key: string]: T; |
|
48 | [key: string]: T; | |
| 49 | } |
|
49 | } | |
| 50 |
|
50 | |||
| 51 | type _key = string | number; |
|
51 | type _key = string | number; | |
| 52 |
|
52 | |||
| 53 | export class Configuration { |
|
53 | export class Configuration { | |
| 54 |
|
54 | |||
| 55 | _hasInnerDescriptors = false; |
|
55 | _hasInnerDescriptors = false; | |
| 56 |
|
56 | |||
| 57 | _container: Container; |
|
57 | _container: Container; | |
| 58 |
|
58 | |||
| 59 | _path: Array<_key>; |
|
59 | _path: Array<_key>; | |
| 60 |
|
60 | |||
| 61 | _configName: string; |
|
61 | _configName: string; | |
| 62 |
|
62 | |||
| 63 | _require = rjs; |
|
63 | _require = rjs; | |
| 64 |
|
64 | |||
| 65 | constructor(container: Container) { |
|
65 | constructor(container: Container) { | |
| 66 | argumentNotNull(container, container); |
|
66 | argumentNotNull(container, container); | |
| 67 | this._container = container; |
|
67 | this._container = container; | |
| 68 | this._path = []; |
|
68 | this._path = []; | |
| 69 | } |
|
69 | } | |
| 70 |
|
70 | |||
| 71 | async loadConfiguration(moduleName: string, ct = Cancellation.none) { |
|
71 | async loadConfiguration(moduleName: string, ct = Cancellation.none) { | |
| 72 | argumentNotEmptyString(moduleName, "moduleName"); |
|
72 | argumentNotEmptyString(moduleName, "moduleName"); | |
| 73 |
|
73 | |||
| 74 | trace.log("loadConfiguration {0}", moduleName); |
|
74 | trace.log("loadConfiguration {0}", moduleName); | |
| 75 |
|
75 | |||
| 76 | this._configName = moduleName; |
|
76 | this._configName = moduleName; | |
| 77 |
|
77 | |||
| 78 | const config = await this._loadModule(moduleName); |
|
78 | const config = await this._loadModule(moduleName); | |
| 79 |
|
79 | |||
| 80 | this._require = await this._createContextRequire(moduleName); |
|
80 | this._require = await this._createContextRequire(moduleName); | |
| 81 |
|
81 | |||
| 82 | let services: ServiceMap; |
|
82 | let services: ServiceMap; | |
| 83 |
|
83 | |||
| 84 | try { |
|
84 | try { | |
| 85 | services = await this._visitRegistrations(config, moduleName); |
|
85 | services = await this._visitRegistrations(config, moduleName); | |
| 86 | } catch (e) { |
|
86 | } catch (e) { | |
| 87 | throw this._makeError(e); |
|
87 | throw this._makeError(e); | |
| 88 | } |
|
88 | } | |
| 89 |
|
89 | |||
| 90 | this._container.register(services); |
|
90 | this._container.register(services); | |
| 91 | } |
|
91 | } | |
| 92 |
|
92 | |||
| 93 | async applyConfiguration(data: object, contextRequire?: RequireFn, ct = Cancellation.none) { |
|
93 | async applyConfiguration(data: object, contextRequire?: RequireFn, ct = Cancellation.none) { | |
| 94 | argumentNotNull(data, "data"); |
|
94 | argumentNotNull(data, "data"); | |
| 95 |
|
95 | |||
| 96 | trace.log("applyConfiguration"); |
|
96 | trace.log("applyConfiguration"); | |
| 97 |
|
97 | |||
| 98 | this._configName = "$"; |
|
98 | this._configName = "$"; | |
| 99 |
|
99 | |||
| 100 | if (contextRequire) |
|
100 | if (contextRequire) | |
| 101 | this._require = contextRequire; |
|
101 | this._require = contextRequire; | |
| 102 |
|
102 | |||
| 103 | let services: ServiceMap; |
|
103 | let services: ServiceMap; | |
| 104 |
|
104 | |||
| 105 | try { |
|
105 | try { | |
| 106 | services = await this._visitRegistrations(data, "$"); |
|
106 | services = await this._visitRegistrations(data, "$"); | |
| 107 | } catch (e) { |
|
107 | } catch (e) { | |
| 108 | throw this._makeError(e); |
|
108 | throw this._makeError(e); | |
| 109 | } |
|
109 | } | |
| 110 |
|
110 | |||
| 111 | this._container.register(services); |
|
111 | this._container.register(services); | |
| 112 | } |
|
112 | } | |
| 113 |
|
113 | |||
| 114 | _makeError(inner) { |
|
114 | _makeError(inner) { | |
| 115 | const e = new ConfigError("Failed to load configuration", inner); |
|
115 | const e = new ConfigError("Failed to load configuration", inner); | |
| 116 | e.configName = this._configName; |
|
116 | e.configName = this._configName; | |
| 117 | e.path = this._makePath(); |
|
117 | e.path = this._makePath(); | |
| 118 | return e; |
|
118 | return e; | |
| 119 | } |
|
119 | } | |
| 120 |
|
120 | |||
| 121 | _makePath() { |
|
121 | _makePath() { | |
| 122 | return this._path |
|
122 | return this._path | |
| 123 | .reduce( |
|
123 | .reduce( | |
| 124 | (prev, cur) => typeof cur === "number" ? |
|
124 | (prev, cur) => typeof cur === "number" ? | |
| 125 | `${prev}[${cur}]` : |
|
125 | `${prev}[${cur}]` : | |
| 126 | `${prev}.${cur}` |
|
126 | `${prev}.${cur}` | |
| 127 | ) |
|
127 | ) | |
| 128 | .toString(); |
|
128 | .toString(); | |
| 129 | } |
|
129 | } | |
| 130 |
|
130 | |||
| 131 | async _resolveType(moduleName: string, localName: string) { |
|
131 | async _resolveType(moduleName: string, localName: string) { | |
| 132 | trace.log("resolveType moduleName={0}, localName={1}", moduleName, localName); |
|
132 | trace.log("resolveType moduleName={0}, localName={1}", moduleName, localName); | |
| 133 | try { |
|
133 | try { | |
| 134 | const m = await this._loadModule(moduleName); |
|
134 | const m = await this._loadModule(moduleName); | |
| 135 | return localName ? get(localName, m) : m; |
|
135 | return localName ? get(localName, m) : m; | |
| 136 | } catch (e) { |
|
136 | } catch (e) { | |
| 137 | trace.error("Failed to resolve type moduleName={0}, localName={1}", moduleName, localName); |
|
137 | trace.error("Failed to resolve type moduleName={0}, localName={1}", moduleName, localName); | |
| 138 | throw e; |
|
138 | throw e; | |
| 139 | } |
|
139 | } | |
| 140 | } |
|
140 | } | |
| 141 |
|
141 | |||
| 142 | async _loadModule(moduleName: string) { |
|
142 | async _loadModule(moduleName: string) { | |
| 143 | trace.debug("loadModule {0}", moduleName); |
|
143 | trace.debug("loadModule {0}", moduleName); | |
| 144 |
|
144 | |||
| 145 | const m = await new Promise(fulfill => { |
|
145 | const m = await new Promise(fulfill => { | |
| 146 | this._require([moduleName], fulfill); |
|
146 | this._require([moduleName], fulfill); | |
| 147 | }); |
|
147 | }); | |
| 148 |
|
148 | |||
| 149 | return m; |
|
149 | return m; | |
| 150 | } |
|
150 | } | |
| 151 |
|
151 | |||
| 152 | _createContextRequire(moduleName: string) { |
|
152 | _createContextRequire(moduleName: string) { | |
| 153 | return createContextRequire(moduleName); |
|
153 | return createContextRequire(moduleName); | |
| 154 | } |
|
154 | } | |
| 155 |
|
155 | |||
| 156 | async _visitRegistrations(data, name: _key) { |
|
156 | async _visitRegistrations(data, name: _key) { | |
| 157 | this._enter(name); |
|
157 | this._enter(name); | |
| 158 |
|
158 | |||
| 159 | if (data.constructor && |
|
159 | if (data.constructor && | |
| 160 | data.constructor.prototype !== Object.prototype) |
|
160 | data.constructor.prototype !== Object.prototype) | |
| 161 | throw new Error("Configuration must be a simple object"); |
|
161 | throw new Error("Configuration must be a simple object"); | |
| 162 |
|
162 | |||
| 163 | const o: ServiceMap = {}; |
|
163 | const o: ServiceMap = {}; | |
| 164 | const keys = Object.keys(data); |
|
164 | const keys = Object.keys(data); | |
| 165 |
|
165 | |||
| 166 | const services = await mapAll(data, async (v, k) => { |
|
166 | const services = await mapAll(data, async (v, k) => { | |
| 167 | const d = await this._visit(v, k); |
|
167 | const d = await this._visit(v, k); | |
| 168 | return isDescriptor(d) ? d : new AggregateDescriptor(d); |
|
168 | return isDescriptor(d) ? d : new AggregateDescriptor(d); | |
| 169 | }) as ServiceMap; |
|
169 | }) as ServiceMap; | |
| 170 |
|
170 | |||
| 171 | this._leave(); |
|
171 | this._leave(); | |
| 172 |
|
172 | |||
| 173 | return services; |
|
173 | return services; | |
| 174 | } |
|
174 | } | |
| 175 |
|
175 | |||
| 176 | _enter(name: _key) { |
|
176 | _enter(name: _key) { | |
| 177 | this._path.push(name); |
|
177 | this._path.push(name); | |
| 178 | trace.debug(">{0}", name); |
|
178 | trace.debug(">{0}", name); | |
| 179 | } |
|
179 | } | |
| 180 |
|
180 | |||
| 181 | _leave() { |
|
181 | _leave() { | |
| 182 | const name = this._path.pop(); |
|
182 | const name = this._path.pop(); | |
| 183 | trace.debug("<{0}", name); |
|
183 | trace.debug("<{0}", name); | |
| 184 | } |
|
184 | } | |
| 185 |
|
185 | |||
| 186 | async _visit(data, name: string): Promise<any> { |
|
186 | async _visit(data, name: string): Promise<any> { | |
| 187 | if (isPrimitive(data) || isDescriptor(data)) |
|
187 | if (isPrimitive(data) || isDescriptor(data)) | |
| 188 | return data; |
|
188 | return data; | |
| 189 |
|
189 | |||
| 190 | if (isDependencyRegistration(data)) { |
|
190 | if (isDependencyRegistration(data)) { | |
| 191 | return this._visitDependencyRegistration(data, name); |
|
191 | return this._visitDependencyRegistration(data, name); | |
| 192 | } else if (isValueRegistration(data)) { |
|
192 | } else if (isValueRegistration(data)) { | |
| 193 | return this._visitValueRegistration(data, name); |
|
193 | return this._visitValueRegistration(data, name); | |
| 194 | } else if (isTypeRegistration(data)) { |
|
194 | } else if (isTypeRegistration(data)) { | |
| 195 | return this._visitTypeRegistration(data, name); |
|
195 | return this._visitTypeRegistration(data, name); | |
| 196 | } else if (isFactoryRegistration(data)) { |
|
196 | } else if (isFactoryRegistration(data)) { | |
| 197 | return this._visitFactoryRegistration(data, name); |
|
197 | return this._visitFactoryRegistration(data, name); | |
| 198 | } else if (data instanceof Array) { |
|
198 | } else if (data instanceof Array) { | |
| 199 | return this._visitArray(data, name); |
|
199 | return this._visitArray(data, name); | |
| 200 | } |
|
200 | } | |
| 201 |
|
201 | |||
| 202 | return this._visitObject(data, name); |
|
202 | return this._visitObject(data, name); | |
| 203 | } |
|
203 | } | |
| 204 |
|
204 | |||
| 205 | async _visitObject(data: object, name: _key) { |
|
205 | async _visitObject(data: object, name: _key) { | |
| 206 | if (data.constructor && |
|
206 | if (data.constructor && | |
| 207 | data.constructor.prototype !== Object.prototype) |
|
207 | data.constructor.prototype !== Object.prototype) | |
| 208 | return new ValueDescriptor(data); |
|
208 | return new ValueDescriptor(data); | |
| 209 |
|
209 | |||
| 210 | this._enter(name); |
|
210 | this._enter(name); | |
| 211 |
|
211 | |||
| 212 | const v = await mapAll(data, delegate(this, "_visit")); |
|
212 | const v = await mapAll(data, delegate(this, "_visit")); | |
| 213 |
|
213 | |||
| 214 | // TODO: handle inline descriptors properly |
|
214 | // TODO: handle inline descriptors properly | |
| 215 | // const ex = { |
|
215 | // const ex = { | |
| 216 | // activate(ctx) { |
|
216 | // activate(ctx) { | |
| 217 | // const value = ctx.activate(this.prop, "prop"); |
|
217 | // const value = ctx.activate(this.prop, "prop"); | |
| 218 | // // some code |
|
218 | // // some code | |
| 219 | // }, |
|
219 | // }, | |
| 220 | // // will be turned to ReferenceDescriptor |
|
220 | // // will be turned to ReferenceDescriptor | |
| 221 | // prop: { $dependency: "depName" } |
|
221 | // prop: { $dependency: "depName" } | |
| 222 | // }; |
|
222 | // }; | |
| 223 |
|
223 | |||
| 224 | this._leave(); |
|
224 | this._leave(); | |
| 225 | return v; |
|
225 | return v; | |
| 226 | } |
|
226 | } | |
| 227 |
|
227 | |||
| 228 | async _visitArray(data: any[], name: _key) { |
|
228 | async _visitArray(data: any[], name: _key) { | |
| 229 | if (data.constructor && |
|
229 | if (data.constructor && | |
| 230 | data.constructor.prototype !== Array.prototype) |
|
230 | data.constructor.prototype !== Array.prototype) | |
| 231 | return new ValueDescriptor(data); |
|
231 | return new ValueDescriptor(data); | |
| 232 |
|
232 | |||
| 233 | this._enter(name); |
|
233 | this._enter(name); | |
| 234 |
|
234 | |||
| 235 | const v = await mapAll(data, delegate(this, "_visit")); |
|
235 | const v = await mapAll(data, delegate(this, "_visit")); | |
| 236 | this._leave(); |
|
236 | this._leave(); | |
| 237 |
|
237 | |||
| 238 | return v; |
|
238 | return v; | |
| 239 | } |
|
239 | } | |
| 240 |
|
240 | |||
| 241 | _makeServiceParams(data: ServiceRegistration) { |
|
241 | _makeServiceParams(data: ServiceRegistration) { | |
| 242 | const opts: any = { |
|
242 | const opts: any = { | |
| 243 | owner: this._container |
|
243 | owner: this._container | |
| 244 | }; |
|
244 | }; | |
| 245 | if (data.services) |
|
245 | if (data.services) | |
| 246 | opts.services = this._visitRegistrations(data.services, "services"); |
|
246 | opts.services = this._visitRegistrations(data.services, "services"); | |
| 247 |
|
247 | |||
| 248 | if (data.inject) { |
|
248 | if (data.inject) { | |
| 249 | this._path.push("inject"); |
|
249 | this._path.push("inject"); | |
| 250 | opts.inject = mapAll( |
|
250 | opts.inject = mapAll( | |
| 251 | data.inject instanceof Array ? |
|
251 | data.inject instanceof Array ? | |
| 252 | data.inject : |
|
252 | data.inject : | |
| 253 | [data.inject], |
|
253 | [data.inject], | |
| 254 | delegate(this, "_visitObject") |
|
254 | delegate(this, "_visitObject") | |
| 255 | ); |
|
255 | ); | |
| 256 | this._leave(); |
|
256 | this._leave(); | |
| 257 | } |
|
257 | } | |
| 258 |
|
258 | |||
| 259 | if ("params" in data) |
|
259 | if ("params" in data) | |
| 260 | opts.params = data.params instanceof Array ? |
|
260 | opts.params = data.params instanceof Array ? | |
| 261 | this._visitArray(data.params, "params") : |
|
261 | this._visitArray(data.params, "params") : | |
| 262 | this._visit(data.params, "params"); |
|
262 | this._visit(data.params, "params"); | |
| 263 |
|
263 | |||
| 264 | if (data.activation) { |
|
264 | if (data.activation) { | |
| 265 | if (typeof (data.activation) === "string") { |
|
265 | if (typeof (data.activation) === "string") { | |
| 266 | switch (data.activation.toLowerCase()) { |
|
266 | switch (data.activation.toLowerCase()) { | |
| 267 | case "singleton": |
|
267 | case "singleton": | |
| 268 | opts.activation = ActivationType.Singleton; |
|
268 | opts.activation = ActivationType.Singleton; | |
| 269 | break; |
|
269 | break; | |
| 270 | case "container": |
|
270 | case "container": | |
| 271 | opts.activation = ActivationType.Container; |
|
271 | opts.activation = ActivationType.Container; | |
| 272 | break; |
|
272 | break; | |
| 273 | case "hierarchy": |
|
273 | case "hierarchy": | |
| 274 | opts.activation = ActivationType.Hierarchy; |
|
274 | opts.activation = ActivationType.Hierarchy; | |
| 275 | break; |
|
275 | break; | |
| 276 | case "context": |
|
276 | case "context": | |
| 277 | opts.activation = ActivationType.Context; |
|
277 | opts.activation = ActivationType.Context; | |
| 278 | break; |
|
278 | break; | |
| 279 | case "call": |
|
279 | case "call": | |
| 280 | opts.activation = ActivationType.Call; |
|
280 | opts.activation = ActivationType.Call; | |
| 281 | break; |
|
281 | break; | |
| 282 | default: |
|
282 | default: | |
| 283 | throw new Error("Unknown activation type: " + |
|
283 | throw new Error("Unknown activation type: " + | |
| 284 | data.activation); |
|
284 | data.activation); | |
| 285 | } |
|
285 | } | |
| 286 | } else { |
|
286 | } else { | |
| 287 | opts.activation = Number(data.activation); |
|
287 | opts.activation = Number(data.activation); | |
| 288 | } |
|
288 | } | |
| 289 | } |
|
289 | } | |
| 290 |
|
290 | |||
| 291 | if (data.cleanup) |
|
291 | if (data.cleanup) | |
| 292 | opts.cleanup = data.cleanup; |
|
292 | opts.cleanup = data.cleanup; | |
| 293 |
|
293 | |||
| 294 | return opts; |
|
294 | return opts; | |
| 295 | } |
|
295 | } | |
| 296 |
|
296 | |||
| 297 | async _visitValueRegistration(data: ValueRegistration, name: _key) { |
|
297 | async _visitValueRegistration(data: ValueRegistration, name: _key) { | |
| 298 | this._enter(name); |
|
298 | this._enter(name); | |
| 299 | const d = data.parse ? new AggregateDescriptor(data.$value) : new ValueDescriptor(data.$value); |
|
299 | const d = data.parse ? new AggregateDescriptor(data.$value) : new ValueDescriptor(data.$value); | |
| 300 | this._leave(); |
|
300 | this._leave(); | |
| 301 | return d; |
|
301 | return d; | |
| 302 | } |
|
302 | } | |
| 303 |
|
303 | |||
| 304 | async _visitDependencyRegistration(data: DependencyRegistration, name: _key) { |
|
304 | async _visitDependencyRegistration(data: DependencyRegistration, name: _key) { | |
| 305 | argumentNotEmptyString(data && data.$dependency, "data.$dependency"); |
|
305 | argumentNotEmptyString(data && data.$dependency, "data.$dependency"); | |
| 306 | this._enter(name); |
|
306 | this._enter(name); | |
| 307 | const d = new ReferenceDescriptor({ |
|
307 | const d = new ReferenceDescriptor({ | |
| 308 | name: data.$dependency, |
|
308 | name: data.$dependency, | |
| 309 | lazy: data.lazy, |
|
309 | lazy: data.lazy, | |
| 310 | optional: data.optional, |
|
310 | optional: data.optional, | |
| 311 | default: data.default, |
|
311 | default: data.default, | |
| 312 | services: data.services && await this._visitRegistrations(data.services, "services") |
|
312 | services: data.services && await this._visitRegistrations(data.services, "services") | |
| 313 | }); |
|
313 | }); | |
| 314 | this._leave(); |
|
314 | this._leave(); | |
| 315 | return d; |
|
315 | return d; | |
| 316 | } |
|
316 | } | |
| 317 |
|
317 | |||
| 318 | async _visitTypeRegistration(data: TypeRegistration, name: _key) { |
|
318 | async _visitTypeRegistration(data: TypeRegistration, name: _key) { | |
| 319 | argumentNotNull(data.$type, "data.$type"); |
|
319 | argumentNotNull(data.$type, "data.$type"); | |
| 320 | this._enter(name); |
|
320 | this._enter(name); | |
| 321 |
|
321 | |||
| 322 | const opts = this._makeServiceParams(data); |
|
322 | const opts = this._makeServiceParams(data); | |
| 323 | if (data.$type instanceof Function) { |
|
323 | if (data.$type instanceof Function) { | |
| 324 | opts.type = data.$type; |
|
324 | opts.type = data.$type; | |
| 325 | } else { |
|
325 | } else { | |
| 326 | const [moduleName, typeName] = data.$type.split(":", 2); |
|
326 | const [moduleName, typeName] = data.$type.split(":", 2); | |
| 327 | opts.type = this._resolveType(moduleName, typeName); |
|
327 | opts.type = this._resolveType(moduleName, typeName); | |
| 328 | } |
|
328 | } | |
| 329 |
|
329 | |||
| 330 | const d = new TypeServiceDescriptor( |
|
330 | const d = new TypeServiceDescriptor( | |
| 331 | await mapAll(opts) |
|
331 | await mapAll(opts) | |
| 332 | ); |
|
332 | ); | |
| 333 |
|
333 | |||
| 334 | this._leave(); |
|
334 | this._leave(); | |
| 335 |
|
335 | |||
| 336 | return d; |
|
336 | return d; | |
| 337 | } |
|
337 | } | |
| 338 |
|
338 | |||
| 339 | async _visitFactoryRegistration(data: FactoryRegistration, name: _key) { |
|
339 | async _visitFactoryRegistration(data: FactoryRegistration, name: _key) { | |
| 340 | argumentOfType(data.$factory, Function, "data.$type"); |
|
340 | argumentOfType(data.$factory, Function, "data.$type"); | |
| 341 | this._enter(name); |
|
341 | this._enter(name); | |
| 342 |
|
342 | |||
| 343 | const opts = this._makeServiceParams(data); |
|
343 | const opts = this._makeServiceParams(data); | |
| 344 | opts.factory = opts.$factory; |
|
344 | opts.factory = opts.$factory; | |
| 345 |
|
345 | |||
| 346 | const d = new FactoryServiceDescriptor( |
|
346 | const d = new FactoryServiceDescriptor( | |
| 347 | await mapAll(opts) |
|
347 | await mapAll(opts) | |
| 348 | ); |
|
348 | ); | |
| 349 |
|
349 | |||
| 350 | this._leave(); |
|
350 | this._leave(); | |
| 351 | return d; |
|
351 | return d; | |
| 352 | } |
|
352 | } | |
| 353 | } |
|
353 | } | |
| @@ -1,16 +1,22 | |||||
| 1 | { |
|
1 | { | |
| 2 | "compilerOptions": { |
|
2 | "compilerOptions": { | |
| 3 | "target": "es3", |
|
3 | "target": "es3", | |
| 4 | "module": "amd", |
|
4 | "module": "amd", | |
| 5 | "sourceMap": true, |
|
5 | "sourceMap": true, | |
| 6 | "declaration": true, |
|
6 | "declaration": true, | |
| 7 | "lib": [ |
|
7 | "lib": [ | |
| 8 | "es5", |
|
8 | "es5", | |
| 9 | "es2015.promise", |
|
9 | "es2015.promise", | |
| 10 | "es2015.symbol" |
|
10 | "es2015.symbol", | |
| 11 |
|
|
11 | "dom" | |
|
|
12 | ], | |||
|
|
13 | "rootDirs": [ | |||
|
|
14 | "ts", | |||
|
|
15 | "amd/ts" | |||
|
|
16 | ], | |||
|
|
17 | "types": [] | |||
| 12 | }, |
|
18 | }, | |
| 13 | "include" : [ |
|
19 | "include" : [ | |
| 14 | "ts/**/*.ts" |
|
20 | "ts/**/*.ts", "amd/ts/**/*.ts" | |
| 15 | ] |
|
21 | ] | |
| 16 | } No newline at end of file |
|
22 | } | |
| 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
