@teambit/harmony 0.2.9 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/aspect.ts +49 -0
- package/config/config.ts +36 -0
- package/config/index.ts +1 -0
- package/container.ts +22 -0
- package/dist/aspect.js +1 -0
- package/dist/aspect.js.map +1 -0
- package/dist/config/config.d.ts +2 -1
- package/dist/config/config.js +7 -0
- package/dist/config/config.js.map +1 -0
- package/dist/config/index.js +2 -0
- package/dist/config/index.js.map +1 -0
- package/dist/container.js +1 -0
- package/dist/container.js.map +1 -0
- package/dist/exceptions/extension-init-error.js +1 -0
- package/dist/exceptions/extension-init-error.js.map +1 -0
- package/dist/exceptions/extension-load-error.d.ts +1 -1
- package/dist/exceptions/extension-load-error.js +1 -0
- package/dist/exceptions/extension-load-error.js.map +1 -0
- package/dist/exceptions/extension-potential-circular.js +1 -0
- package/dist/exceptions/extension-potential-circular.js.map +1 -0
- package/dist/exceptions/harmony-already-running.js +1 -0
- package/dist/exceptions/harmony-already-running.js.map +1 -0
- package/dist/exceptions/harmony-error.js +1 -0
- package/dist/exceptions/harmony-error.js.map +1 -0
- package/dist/exceptions/hook-not-found.js +1 -0
- package/dist/exceptions/hook-not-found.js.map +1 -0
- package/dist/exceptions/index.js +7 -2
- package/dist/exceptions/index.js.map +1 -0
- package/dist/exceptions/runtime-not-defined.js +1 -1
- package/dist/exceptions/runtime-not-defined.js.map +1 -0
- package/dist/extension/any-extension.js +1 -0
- package/dist/extension/any-extension.js.map +1 -0
- package/dist/extension/decorator.d.ts +2 -2
- package/dist/extension/decorator.js +1 -0
- package/dist/extension/decorator.js.map +1 -0
- package/dist/extension/extension-manifest.js +1 -0
- package/dist/extension/extension-manifest.js.map +1 -0
- package/dist/extension/extension.d.ts +2 -2
- package/dist/extension/extension.js +2 -1
- package/dist/extension/extension.js.map +1 -0
- package/dist/extension/index.js +2 -0
- package/dist/extension/index.js.map +1 -0
- package/dist/extension-graph/extension-graph.d.ts +2 -2
- package/dist/extension-graph/extension-graph.js +5 -4
- package/dist/extension-graph/extension-graph.js.map +1 -0
- package/dist/extension-graph/from-extension.js +3 -2
- package/dist/extension-graph/from-extension.js.map +1 -0
- package/dist/extension-graph/index.js +6 -1
- package/dist/extension-graph/index.js.map +1 -0
- package/dist/factory/extension-factory.js +1 -0
- package/dist/factory/extension-factory.js.map +1 -0
- package/dist/factory/index.js +2 -0
- package/dist/factory/index.js.map +1 -0
- package/dist/fixtures/aspects/babel/babel.aspect.js +1 -0
- package/dist/fixtures/aspects/babel/babel.aspect.js.map +1 -0
- package/dist/fixtures/aspects/babel/babel.cli.js +1 -0
- package/dist/fixtures/aspects/babel/babel.cli.js.map +1 -0
- package/dist/fixtures/aspects/react/react.aspect.js +1 -0
- package/dist/fixtures/aspects/react/react.aspect.js.map +1 -0
- package/dist/fixtures/aspects/react/react.cli.js +2 -1
- package/dist/fixtures/aspects/react/react.cli.js.map +1 -0
- package/dist/fixtures/aspects/react/react.ui.js +1 -0
- package/dist/fixtures/aspects/react/react.ui.js.map +1 -0
- package/dist/fixtures/aspects/ui/ui.aspect.js +1 -0
- package/dist/fixtures/aspects/ui/ui.aspect.js.map +1 -0
- package/dist/fixtures/aspects/ui/ui.ui.js +1 -0
- package/dist/fixtures/aspects/ui/ui.ui.js.map +1 -0
- package/dist/fixtures/babel/babel.extension.d.ts +1 -1
- package/dist/fixtures/babel/babel.extension.js +8 -26
- package/dist/fixtures/babel/babel.extension.js.map +1 -0
- package/dist/fixtures/babel/index.js +1 -1
- package/dist/fixtures/babel/index.js.map +1 -0
- package/dist/fixtures/base-compiler/base-compiler.extension.js +5 -23
- package/dist/fixtures/base-compiler/base-compiler.extension.js.map +1 -0
- package/dist/fixtures/base-compiler/index.js +2 -0
- package/dist/fixtures/base-compiler/index.js.map +1 -0
- package/dist/fixtures/cli/cli.extension.js +5 -12
- package/dist/fixtures/cli/cli.extension.js.map +1 -0
- package/dist/fixtures/cli/command.js +1 -1
- package/dist/fixtures/cli/command.js.map +1 -0
- package/dist/fixtures/cli/index.js +2 -1
- package/dist/fixtures/cli/index.js.map +1 -0
- package/dist/fixtures/typescript/index.js +1 -1
- package/dist/fixtures/typescript/index.js.map +1 -0
- package/dist/fixtures/typescript/typescript.js +8 -22
- package/dist/fixtures/typescript/typescript.js.map +1 -0
- package/dist/harmony-config/config-reader.js +3 -2
- package/dist/harmony-config/config-reader.js.map +1 -0
- package/dist/harmony-config/exceptions/index.js +2 -0
- package/dist/harmony-config/exceptions/index.js.map +1 -0
- package/dist/harmony-config/exceptions/read-config-error.d.ts +1 -1
- package/dist/harmony-config/exceptions/read-config-error.js +1 -0
- package/dist/harmony-config/exceptions/read-config-error.js.map +1 -0
- package/dist/harmony-config/harmony-config.js +5 -4
- package/dist/harmony-config/harmony-config.js.map +1 -0
- package/dist/harmony-config/index.js +2 -0
- package/dist/harmony-config/index.js.map +1 -0
- package/dist/harmony-config/locator.js +1 -1
- package/dist/harmony-config/locator.js.map +1 -0
- package/dist/harmony.docs.mdx +249 -0
- package/dist/harmony.js +3 -2
- package/dist/harmony.js.map +1 -0
- package/dist/{factory/extension-factory.spec.d.ts → harmony.spec.old.d.ts} +0 -0
- package/dist/{harmony.spec.js → harmony.spec.old.js} +12 -23
- package/dist/harmony.spec.old.js.map +1 -0
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -0
- package/dist/readme.md +80 -0
- package/dist/runtimes/exceptions/index.js +2 -0
- package/dist/runtimes/exceptions/index.js.map +1 -0
- package/dist/runtimes/exceptions/runtime-module-error.d.ts +1 -1
- package/dist/runtimes/exceptions/runtime-module-error.js +1 -0
- package/dist/runtimes/exceptions/runtime-module-error.js.map +1 -0
- package/dist/runtimes/exceptions/runtime-not-defined.js +1 -0
- package/dist/runtimes/exceptions/runtime-not-defined.js.map +1 -0
- package/dist/runtimes/index.js +2 -0
- package/dist/runtimes/index.js.map +1 -0
- package/dist/runtimes/runtime-definition.js +1 -0
- package/dist/runtimes/runtime-definition.js.map +1 -0
- package/dist/runtimes/runtime-manifest.js +1 -0
- package/dist/runtimes/runtime-manifest.js.map +1 -0
- package/dist/runtimes/runtimes.js +1 -0
- package/dist/runtimes/runtimes.js.map +1 -0
- package/dist/slots/index.js +2 -0
- package/dist/slots/index.js.map +1 -0
- package/dist/slots/registry.js +1 -0
- package/dist/slots/registry.js.map +1 -0
- package/dist/slots/slot.js +1 -0
- package/dist/slots/slot.js.map +1 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/async-for-each.js +1 -0
- package/dist/utils/async-for-each.js.map +1 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -0
- package/exceptions/extension-init-error.ts +1 -0
- package/exceptions/extension-load-error.ts +28 -0
- package/exceptions/extension-potential-circular.ts +24 -0
- package/exceptions/harmony-already-running.ts +1 -0
- package/exceptions/harmony-error.ts +1 -0
- package/exceptions/hook-not-found.ts +1 -0
- package/exceptions/index.ts +5 -0
- package/{dist/extension-graph/extension-graph.spec.d.ts → exceptions/runtime-not-defined.ts} +0 -0
- package/extension/any-extension.ts +8 -0
- package/extension/decorator.ts +126 -0
- package/extension/extension-manifest.ts +51 -0
- package/extension/extension.ts +138 -0
- package/extension/index.ts +3 -0
- package/extension-graph/extension-graph.ts +151 -0
- package/extension-graph/from-extension.ts +72 -0
- package/extension-graph/index.ts +1 -0
- package/factory/extension-factory.ts +8 -0
- package/factory/index.ts +1 -0
- package/fixtures/aspects/babel/babel.aspect.ts +14 -0
- package/fixtures/aspects/babel/babel.cli.ts +16 -0
- package/fixtures/aspects/react/react.aspect.ts +22 -0
- package/fixtures/aspects/react/react.cli.ts +26 -0
- package/fixtures/aspects/react/react.ui.ts +16 -0
- package/fixtures/aspects/ui/ui.aspect.ts +13 -0
- package/fixtures/aspects/ui/ui.ui.ts +11 -0
- package/fixtures/babel/babel.extension.ts +20 -0
- package/{dist/extension/extension.spec.d.ts → fixtures/babel/index.ts} +0 -0
- package/fixtures/base-compiler/base-compiler.extension.ts +31 -0
- package/fixtures/base-compiler/index.ts +1 -0
- package/fixtures/cli/cli.extension.ts +25 -0
- package/fixtures/cli/command.ts +6 -0
- package/fixtures/cli/index.ts +1 -0
- package/fixtures/typescript/index.ts +0 -0
- package/fixtures/typescript/typescript.ts +20 -0
- package/harmony-config/config-reader.ts +17 -0
- package/harmony-config/exceptions/index.ts +1 -0
- package/harmony-config/exceptions/read-config-error.ts +9 -0
- package/harmony-config/harmony-config.ts +49 -0
- package/harmony-config/index.ts +1 -0
- package/harmony-config/locator.ts +0 -0
- package/harmony.docs.mdx +249 -0
- package/harmony.spec.old.ts +177 -0
- package/harmony.ts +146 -0
- package/index.ts +10 -0
- package/package-tar/teambit-harmony-0.3.0.tgz +0 -0
- package/package.json +41 -28
- package/preview-1649080456374.js +1 -0
- package/readme.md +58 -137
- package/runtimes/exceptions/index.ts +2 -0
- package/runtimes/exceptions/runtime-module-error.ts +9 -0
- package/runtimes/exceptions/runtime-not-defined.ts +5 -0
- package/runtimes/index.ts +3 -0
- package/runtimes/runtime-definition.ts +32 -0
- package/runtimes/runtime-manifest.ts +12 -0
- package/runtimes/runtimes.ts +34 -0
- package/slots/index.ts +2 -0
- package/slots/registry.ts +36 -0
- package/slots/slot.ts +11 -0
- package/tsconfig.json +26 -0
- package/types/asset.d.ts +29 -0
- package/types/style.d.ts +42 -0
- package/types.ts +7 -0
- package/utils/async-for-each.ts +10 -0
- package/utils/index.ts +1 -0
- package/dist/extension/extension.spec.js +0 -1
- package/dist/extension-graph/extension-graph.spec.js +0 -1
- package/dist/factory/extension-factory.spec.js +0 -6
- package/dist/harmony-config/harmony-config.spec.d.ts +0 -1
- package/dist/harmony-config/harmony-config.spec.js +0 -8
- package/dist/harmony.spec.d.ts +0 -1
package/package.json
CHANGED
|
@@ -1,42 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/harmony",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "abstract extension system",
|
|
3
|
+
"version": "0.3.0",
|
|
5
4
|
"main": "dist/index.js",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"clean": "rm -rf dist",
|
|
11
|
-
"watch": "tsc -d -w",
|
|
12
|
-
"prepublishOnly": "npm run clean && npm run build"
|
|
5
|
+
"componentId": {
|
|
6
|
+
"scope": "teambit.harmony",
|
|
7
|
+
"name": "harmony",
|
|
8
|
+
"version": "0.3.0"
|
|
13
9
|
},
|
|
14
|
-
"files": [
|
|
15
|
-
"/dist"
|
|
16
|
-
],
|
|
17
|
-
"keywords": [],
|
|
18
|
-
"author": "Ran Mizrahi <ran@bit.dev>",
|
|
19
|
-
"license": "MIT",
|
|
20
10
|
"dependencies": {
|
|
11
|
+
"reflect-metadata": "^0.1.13",
|
|
21
12
|
"cleargraph": "^5.6.0",
|
|
22
13
|
"comment-json": "^3.0.3",
|
|
23
14
|
"fs-extra": "^8.1.0",
|
|
24
|
-
"lodash": "^4.17.20",
|
|
25
|
-
"loud-rejection": "^1.6.0",
|
|
26
|
-
"reflect-metadata": "^0.1.13",
|
|
27
15
|
"user-home": "^2.0.0"
|
|
28
16
|
},
|
|
29
17
|
"devDependencies": {
|
|
30
18
|
"@types/comment-json": "^1.1.1",
|
|
31
19
|
"@types/fs-extra": "^8.1.0",
|
|
32
|
-
"@
|
|
33
|
-
"@types/
|
|
34
|
-
"@types/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
20
|
+
"@babel/runtime": "7.12.18",
|
|
21
|
+
"@types/node": "12.20.4",
|
|
22
|
+
"@types/jest": "26.0.20"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {},
|
|
25
|
+
"license": "Apache-2.0",
|
|
26
|
+
"bit": {
|
|
27
|
+
"bindingPrefix": "@teambit",
|
|
28
|
+
"env": {},
|
|
29
|
+
"overrides": {
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@babel/runtime": "7.12.18",
|
|
32
|
+
"@types/node": "12.20.4",
|
|
33
|
+
"@types/jest": "26.0.20"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"private": false,
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=12.22.0"
|
|
40
|
+
},
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "https://github.com/teambit/harmony"
|
|
44
|
+
},
|
|
45
|
+
"description": "abstract extension system",
|
|
46
|
+
"keywords": [
|
|
47
|
+
"bit",
|
|
48
|
+
"bit-aspect",
|
|
49
|
+
"components",
|
|
50
|
+
"collaboration",
|
|
51
|
+
"harmony",
|
|
52
|
+
"aspects",
|
|
53
|
+
"extensions"
|
|
54
|
+
]
|
|
42
55
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const overview = [require('/Users/giladshoham/Library/Caches/Bit/capsules/0c2e8decf63b913c66a649e2a025161ea05f3ab6/teambit.harmony_harmony@0.3.0/dist/harmony.docs.mdx')]
|
package/readme.md
CHANGED
|
@@ -1,159 +1,80 @@
|
|
|
1
|
-
# Harmony
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Module
|
|
5
|
-
Extension
|
|
6
|
-
* Feature
|
|
7
|
-
Plugin
|
|
8
|
-
Trait
|
|
9
|
-
* Component (could be a composition of other components)
|
|
10
|
-
|
|
11
|
-
Plugability
|
|
12
|
-
- Hook
|
|
13
|
-
- Slot
|
|
14
|
-
|
|
15
|
-
Harmony is the engine that drives Bit extensibility and composability.
|
|
16
|
-
It's an abstract extension system you can use to make any software extendable and composable.
|
|
17
|
-
|
|
18
|
-
## composition model
|
|
19
|
-
Harmony proposes a graph composition model.
|
|
20
|
-
compoisiton model should allow:
|
|
21
|
-
- full control over composition including dependency composition.
|
|
22
|
-
- easy overrides mechanaism for configs.
|
|
23
|
-
- full encapsulation of an extension.
|
|
24
|
-
|
|
25
|
-
bit.config.js
|
|
26
|
-
```js
|
|
27
|
-
import FlowSchemaPlugin from '@bit/plugins.flow-schema';
|
|
28
|
-
|
|
29
|
-
export default () => {
|
|
30
|
-
return [ // returns an array of PluginInstance
|
|
31
|
-
[FlowScehmaPlugin, {
|
|
32
|
-
|
|
33
|
-
}],
|
|
34
|
-
[ReactSchemaPlugin, {
|
|
35
|
-
eslintrc: './.eslintrc'
|
|
36
|
-
}]
|
|
37
|
-
];
|
|
38
|
-
}
|
|
39
|
-
```
|
|
1
|
+
# Harmony
|
|
2
|
+
Harmony is the engine that drives Bit extensibility and composability.
|
|
3
|
+
It's an abstract extension system indended to make any software extendable and composable.
|
|
40
4
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"eslintrc": "./.eslintrc"
|
|
47
|
-
},
|
|
48
|
-
"bit.envs/babel@0.0.1": {
|
|
49
|
-
"babelrc": "./.babelrc",
|
|
50
|
-
"strict": true,
|
|
51
|
-
"__alias": "compile"
|
|
52
|
-
},
|
|
53
|
-
"bit.envs/webpack@0.0.1": {
|
|
54
|
-
"config": "./webpack.config.js",
|
|
55
|
-
"mode": "prod",
|
|
56
|
-
"__alias": "bundle"
|
|
57
|
-
},
|
|
58
|
-
"bit.envs/mocha@0.0.1": {
|
|
59
|
-
"reporter": "json",
|
|
60
|
-
"mochaOptions": "./mocha.opts",
|
|
61
|
-
"__alias": "test-mocha"
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
"pipes": {
|
|
65
|
-
"tag": [""]
|
|
66
|
-
},
|
|
67
|
-
"dist": {
|
|
68
|
-
"target": "",
|
|
69
|
-
"entry": ""
|
|
70
|
-
}
|
|
71
|
-
}
|
|
5
|
+
Harmony takes a "micro-kernel" approach and implements the near-minimum amount of software required to build any JavaScript system from independent components through composition.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
```bash
|
|
9
|
+
$ bit install @teambit/harmony
|
|
72
10
|
```
|
|
73
11
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
- What's the impl. behind `bit use <plugin/extension name>`
|
|
78
|
-
- maybe an composition model can co-exist as json and js? what are the tradeoffs?
|
|
12
|
+
## Quick start
|
|
13
|
+
```ts
|
|
14
|
+
import { Harmony, Extension } from 'harmony';
|
|
79
15
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
16
|
+
@Extensioin
|
|
17
|
+
class Person {
|
|
18
|
+
sayHello(name = 'world') {
|
|
19
|
+
return `hello ${name}!`;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
84
22
|
|
|
85
|
-
const
|
|
23
|
+
const person = Harmony.load(Person);
|
|
24
|
+
helloWorld.sayHello(); // returns 'hello world!'
|
|
86
25
|
```
|
|
87
26
|
|
|
88
|
-
##
|
|
89
|
-
|
|
90
|
-
```js
|
|
91
|
-
import { invoke } from 'harmony';
|
|
27
|
+
## Component composition
|
|
92
28
|
|
|
93
|
-
|
|
94
|
-
```
|
|
29
|
+
### DI
|
|
30
|
+
```ts
|
|
31
|
+
class Dude {
|
|
32
|
+
constructor(
|
|
33
|
+
private person: Person
|
|
34
|
+
) {}
|
|
95
35
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
36
|
+
sayHello() {
|
|
37
|
+
return this.person.sayHello('dude');
|
|
38
|
+
}
|
|
39
|
+
};
|
|
99
40
|
|
|
100
|
-
|
|
101
|
-
function tag() {
|
|
102
|
-
|
|
103
|
-
}
|
|
41
|
+
Harmony.load([Dude]).sayHello(); // echos 'hello dude!'
|
|
104
42
|
```
|
|
105
43
|
|
|
106
|
-
|
|
44
|
+
### Hooks
|
|
107
45
|
```ts
|
|
108
|
-
@
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
46
|
+
@Extension()
|
|
47
|
+
class CLI {
|
|
48
|
+
// @hook('command') commands = Hook.create<Command>();
|
|
49
|
+
static command() {
|
|
50
|
+
return Hook.create<Command>();
|
|
51
|
+
}
|
|
115
52
|
|
|
116
|
-
|
|
53
|
+
run() {
|
|
54
|
+
const allCommands = this.commands.list(); // outputs all hook subscribers
|
|
55
|
+
}
|
|
56
|
+
}
|
|
117
57
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
58
|
+
@Extension()
|
|
59
|
+
class Compiler {
|
|
60
|
+
|
|
61
|
+
@command()
|
|
62
|
+
main() {
|
|
63
|
+
return {
|
|
64
|
+
synopsis: 'compile <path>',
|
|
65
|
+
render: () => <Box></Box>
|
|
66
|
+
};
|
|
67
|
+
}
|
|
121
68
|
}
|
|
122
69
|
```
|
|
123
70
|
|
|
124
|
-
## configuration
|
|
125
|
-
an extension can declaratively ask for configuration type. this can be reflected
|
|
126
|
-
- extensions can be configured during instantiation.
|
|
127
|
-
- configuration types can be built from multiple sources
|
|
128
|
-
|
|
129
|
-
## context
|
|
130
|
-
- standard context can be shared between all extensions in the same instance.
|
|
71
|
+
## Extension configuration
|
|
131
72
|
|
|
132
|
-
##
|
|
133
|
-
- hook invocation from an extension
|
|
134
|
-
- extension dependencies? how can an extension declare a dependency as part of its execution?
|
|
135
|
-
- contextual/namespaced hooks
|
|
136
|
-
- config api
|
|
137
|
-
|
|
138
|
-
## extension resolution
|
|
139
|
-
```js
|
|
140
|
-
import { resolve } from 'harmony';
|
|
141
|
-
|
|
142
|
-
const extension = resolve('doc-gen');
|
|
143
|
-
```
|
|
73
|
+
## Extension metadata
|
|
144
74
|
|
|
145
|
-
##
|
|
146
|
-
- can extensions be added/configured during runtime? DI
|
|
147
|
-
- is there a difference between extension composition to registration?
|
|
148
|
-
- how to make autocomplete work for hooks?
|
|
149
|
-
- how to avoid unintentional hook invocation (decorators?)
|
|
150
|
-
- how to declare a new hook..
|
|
151
|
-
- schema validator
|
|
152
|
-
- dev expereience of an extension.
|
|
153
|
-
- how do manage different runtime environments? should I? Why is that relavent?
|
|
154
|
-
- runtime capsules?
|
|
155
|
-
- how can one extension run from both server and client? how capsule is related?
|
|
156
|
-
- in which process extensions will run from? also, what will happen from the backend?
|
|
157
|
-
-
|
|
75
|
+
## API reference
|
|
158
76
|
|
|
77
|
+
## License
|
|
78
|
+
Apache License, Version 2.0
|
|
159
79
|
|
|
80
|
+
Made with ❤ to open software by Team Bit.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { RuntimeModuleError } from './exceptions';
|
|
2
|
+
|
|
3
|
+
export type RuntimeDefProps = {
|
|
4
|
+
name: string
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const DEFAULT_PREDICATE = (filePath: string, name: string) => {
|
|
8
|
+
return filePath.includes(`.${name}.`);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class RuntimeDefinition {
|
|
12
|
+
constructor(
|
|
13
|
+
readonly name: string,
|
|
14
|
+
readonly filePredicate: (filePath: string, name: string) => boolean = DEFAULT_PREDICATE
|
|
15
|
+
) {}
|
|
16
|
+
|
|
17
|
+
getRuntimeFile(paths: string[]): string|undefined {
|
|
18
|
+
return paths.find(path => this.filePredicate(path, this.name));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
require(file: string) {
|
|
22
|
+
// try {
|
|
23
|
+
// require(file);
|
|
24
|
+
// } catch(err) {
|
|
25
|
+
// throw new RuntimeModuleError(err);
|
|
26
|
+
// }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static create(def: RuntimeDefProps) {
|
|
30
|
+
return new RuntimeDefinition(def.name);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RuntimeDefinition } from './runtime-definition';
|
|
2
|
+
import { ProviderFn } from '../types';
|
|
3
|
+
import { Aspect } from '../aspect';
|
|
4
|
+
import { SlotProvider } from '../slots';
|
|
5
|
+
|
|
6
|
+
export interface RuntimeManifest {
|
|
7
|
+
runtime: RuntimeDefinition|string
|
|
8
|
+
provider: ProviderFn,
|
|
9
|
+
dependencies?: Aspect[],
|
|
10
|
+
slots?: SlotProvider<unknown>[],
|
|
11
|
+
defaultConfig?: {[key: string]: any},
|
|
12
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { RuntimeDefinition } from './runtime-definition';
|
|
2
|
+
import DependencyGraph from '../extension-graph/extension-graph';
|
|
3
|
+
import { RuntimeNotDefined } from './exceptions';
|
|
4
|
+
|
|
5
|
+
export class Runtimes {
|
|
6
|
+
constructor(
|
|
7
|
+
readonly runtimeDefinition: {[key: string]: RuntimeDefinition}
|
|
8
|
+
) {}
|
|
9
|
+
|
|
10
|
+
add(runtime: RuntimeDefinition) {
|
|
11
|
+
this.runtimeDefinition[runtime.name] = runtime;
|
|
12
|
+
return this;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
get(name: string): RuntimeDefinition {
|
|
16
|
+
const runtime = this.runtimeDefinition[name];
|
|
17
|
+
if (!runtime) throw new RuntimeNotDefined(name);
|
|
18
|
+
return this.runtimeDefinition[name];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
dispose() {
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static async load(graph: DependencyGraph) {
|
|
26
|
+
const runtimes: { [key: string]: RuntimeDefinition } = {};
|
|
27
|
+
graph.extensions.forEach(manifest => {
|
|
28
|
+
if (!manifest.declareRuntime) return;
|
|
29
|
+
runtimes[manifest.declareRuntime.name] = manifest.declareRuntime;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return new Runtimes(runtimes);
|
|
33
|
+
}
|
|
34
|
+
}
|
package/slots/index.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
export class SlotRegistry<T> {
|
|
3
|
+
constructor(
|
|
4
|
+
private registerFn: () => string,
|
|
5
|
+
readonly map = new Map<string, T>()
|
|
6
|
+
) {}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* get a slot value by extension id.
|
|
10
|
+
*/
|
|
11
|
+
get(id: string): T|undefined {
|
|
12
|
+
return this.map.get(id);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* return an array of all slots.
|
|
17
|
+
*/
|
|
18
|
+
toArray() {
|
|
19
|
+
return Array.from(this.map.entries());
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* get all registered values.
|
|
24
|
+
*/
|
|
25
|
+
values() {
|
|
26
|
+
return Array.from(this.map.values());
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* register a new entry to the slot registry
|
|
31
|
+
*/
|
|
32
|
+
register(value: T) {
|
|
33
|
+
const id = this.registerFn();
|
|
34
|
+
this.map.set(id, value);
|
|
35
|
+
}
|
|
36
|
+
}
|
package/slots/slot.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SlotRegistry } from './registry';
|
|
2
|
+
|
|
3
|
+
export class Slot {
|
|
4
|
+
static withType<T>() {
|
|
5
|
+
return (registerFn: () => string) => {
|
|
6
|
+
return new SlotRegistry<T>(registerFn);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type SlotProvider<T> = (registerFn: () => string) => SlotRegistry<T>;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"lib": [
|
|
4
|
+
"es2019",
|
|
5
|
+
"DOM",
|
|
6
|
+
"ES6",
|
|
7
|
+
"DOM.Iterable"
|
|
8
|
+
],
|
|
9
|
+
"target": "es2015",
|
|
10
|
+
"module": "commonjs",
|
|
11
|
+
"jsx": "react",
|
|
12
|
+
"allowJs": true,
|
|
13
|
+
"composite": true,
|
|
14
|
+
"declaration": true,
|
|
15
|
+
"sourceMap": true,
|
|
16
|
+
"skipLibCheck": true,
|
|
17
|
+
"outDir": "dist",
|
|
18
|
+
"moduleResolution": "node",
|
|
19
|
+
"esModuleInterop": true,
|
|
20
|
+
"rootDir": ".",
|
|
21
|
+
"resolveJsonModule": true
|
|
22
|
+
},
|
|
23
|
+
"exclude": [
|
|
24
|
+
"dist"
|
|
25
|
+
]
|
|
26
|
+
}
|
package/types/asset.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
declare module '*.png' {
|
|
2
|
+
const value: any;
|
|
3
|
+
export = value;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.svg' {
|
|
6
|
+
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
|
+
|
|
8
|
+
export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
|
|
9
|
+
const src: string;
|
|
10
|
+
export default src;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// @TODO Gilad
|
|
14
|
+
declare module '*.jpg' {
|
|
15
|
+
const value: any;
|
|
16
|
+
export = value;
|
|
17
|
+
}
|
|
18
|
+
declare module '*.jpeg' {
|
|
19
|
+
const value: any;
|
|
20
|
+
export = value;
|
|
21
|
+
}
|
|
22
|
+
declare module '*.gif' {
|
|
23
|
+
const value: any;
|
|
24
|
+
export = value;
|
|
25
|
+
}
|
|
26
|
+
declare module '*.bmp' {
|
|
27
|
+
const value: any;
|
|
28
|
+
export = value;
|
|
29
|
+
}
|
package/types/style.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
declare module '*.module.css' {
|
|
2
|
+
const classes: { readonly [key: string]: string };
|
|
3
|
+
export default classes;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.module.scss' {
|
|
6
|
+
const classes: { readonly [key: string]: string };
|
|
7
|
+
export default classes;
|
|
8
|
+
}
|
|
9
|
+
declare module '*.module.sass' {
|
|
10
|
+
const classes: { readonly [key: string]: string };
|
|
11
|
+
export default classes;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module '*.module.less' {
|
|
15
|
+
const classes: { readonly [key: string]: string };
|
|
16
|
+
export default classes;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module '*.less' {
|
|
20
|
+
const classes: { readonly [key: string]: string };
|
|
21
|
+
export default classes;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare module '*.css' {
|
|
25
|
+
const classes: { readonly [key: string]: string };
|
|
26
|
+
export default classes;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare module '*.sass' {
|
|
30
|
+
const classes: { readonly [key: string]: string };
|
|
31
|
+
export default classes;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare module '*.scss' {
|
|
35
|
+
const classes: { readonly [key: string]: string };
|
|
36
|
+
export default classes;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare module '*.mdx' {
|
|
40
|
+
const component: any;
|
|
41
|
+
export default component;
|
|
42
|
+
}
|
package/types.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* asynchronously iterate an array.
|
|
3
|
+
* :TODO improve function singature
|
|
4
|
+
*/
|
|
5
|
+
export async function asyncForEach(array: any[], callback: any) {
|
|
6
|
+
for (let index = 0; index < array.length; index += 1) {
|
|
7
|
+
// eslint-disable-next-line no-await-in-loop
|
|
8
|
+
await callback(array[index], index, array);
|
|
9
|
+
}
|
|
10
|
+
}
|
package/utils/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { asyncForEach } from './async-for-each';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const harmony_config_1 = require("./harmony-config");
|
|
4
|
-
describe('HarmonyConfig', () => {
|
|
5
|
-
it('should parse both files', () => {
|
|
6
|
-
harmony_config_1.HarmonyConfig.load('workspace.json');
|
|
7
|
-
});
|
|
8
|
-
});
|
package/dist/harmony.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|