@autometa/app 0.3.0 → 0.3.2
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/CHANGELOG.md +13 -0
- package/dist/esm/index.js +7 -31
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.cts +1 -5
- package/dist/index.d.ts +1 -5
- package/dist/index.js +9 -33
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -7,48 +7,24 @@ var AutometaWorld = class {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
// src/get-app.ts
|
|
10
|
-
import { container } from "tsyringe";
|
|
11
|
-
import { AutomationError } from "@autometa/errors";
|
|
12
10
|
import { v4 } from "uuid";
|
|
13
|
-
import {
|
|
14
|
-
function getApp(appType,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
Configure the app by extending 'AutometaApp' and adding it to your
|
|
19
|
-
'autometa.config.ts' file:
|
|
20
|
-
|
|
21
|
-
@AppType(MyWorld)
|
|
22
|
-
export class MyAutometaApp extends AutometaApp {
|
|
23
|
-
...
|
|
24
|
-
}
|
|
25
|
-
defineConfig({
|
|
26
|
-
roots: {
|
|
27
|
-
app: './src/app'
|
|
28
|
-
}
|
|
29
|
-
})`);
|
|
30
|
-
}
|
|
31
|
-
instances.forEach(({ token, instance, cls }) => {
|
|
32
|
-
const proxiedCls = cls ? ErrorCatcherProxy(cls) : void 0;
|
|
33
|
-
const proxiedInst = instance ? ErrorCatcherProxy(instance) : void 0;
|
|
34
|
-
return child.register(token, proxiedInst ?? proxiedCls);
|
|
35
|
-
});
|
|
36
|
-
const child = container.createChildContainer();
|
|
37
|
-
const app = ErrorCatcherProxy(child.resolve(appType));
|
|
38
|
-
app.id = v4();
|
|
39
|
-
return app;
|
|
11
|
+
import { Container, defineContainerContext } from "@autometa/injection";
|
|
12
|
+
function getApp(appType, containerName = v4()) {
|
|
13
|
+
const context = defineContainerContext(containerName);
|
|
14
|
+
const container = new Container(context);
|
|
15
|
+
return container.get(appType);
|
|
40
16
|
}
|
|
41
17
|
|
|
42
18
|
// src/decorators/app-type.ts
|
|
43
19
|
import { metadata } from "@autometa/injection";
|
|
44
|
-
function AppType(
|
|
20
|
+
function AppType(container, world, environment = "default") {
|
|
45
21
|
const env = environment ?? "default";
|
|
46
22
|
return (target) => {
|
|
47
23
|
metadata(target.prototype).set({
|
|
48
24
|
key: "world",
|
|
49
25
|
class: world
|
|
50
26
|
});
|
|
51
|
-
|
|
27
|
+
container[env] = { app: target, world };
|
|
52
28
|
};
|
|
53
29
|
}
|
|
54
30
|
export {
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/autometa-app.ts","../../src/autometa-world.ts","../../src/get-app.ts","../../src/decorators/app-type.ts"],"sourcesContent":["import { World } from \"./fixtures.typings\";\nexport abstract class AutometaApp {\n id: string;\n [key: string]: unknown;\n world: World;\n}\n","export class AutometaWorld {}\n","import {
|
|
1
|
+
{"version":3,"sources":["../../src/autometa-app.ts","../../src/autometa-world.ts","../../src/get-app.ts","../../src/decorators/app-type.ts"],"sourcesContent":["import { World } from \"./fixtures.typings\";\nexport abstract class AutometaApp {\n id: string;\n [key: string]: unknown;\n world: World;\n}\n","export class AutometaWorld {}\n","import { AutometaApp } from \"./autometa-app\";\nimport { Class } from \"@autometa/types\";\nimport { v4 } from \"uuid\";\nimport { Container, defineContainerContext } from \"@autometa/injection\";\nimport { App } from \"./fixtures.typings\";\nexport function getApp<T extends AutometaApp>(\n appType: Class<T>,\n containerName = v4()\n): App {\n const context = defineContainerContext(containerName);\n const container = new Container(context);\n return container.get(appType);\n}\n","import { Class } from \"@autometa/types\";\nimport { App, World, AutometaWorld } from \"..\";\nimport { metadata } from \"@autometa/injection\";\nexport function AppType(\n container: Record<string, { app: Class<App>; world: Class<World> }>,\n world: Class<AutometaWorld>,\n environment = \"default\"\n) {\n const env = environment ?? \"default\";\n return (target: Class<unknown>) => {\n metadata(target.prototype).set({\n key: \"world\",\n class: world\n });\n container[env] = { app: target as Class<App>, world: world as Class<World> };\n };\n}\n"],"mappings":";AACO,IAAe,cAAf,MAA2B;AAIlC;;;ACLO,IAAM,gBAAN,MAAoB;AAAC;;;ACE5B,SAAS,UAAU;AACnB,SAAS,WAAW,8BAA8B;AAE3C,SAAS,OACd,SACA,gBAAgB,GAAG,GACd;AACL,QAAM,UAAU,uBAAuB,aAAa;AACpD,QAAM,YAAY,IAAI,UAAU,OAAO;AACvC,SAAO,UAAU,IAAI,OAAO;AAC9B;;;ACVA,SAAS,gBAAgB;AAClB,SAAS,QACd,WACA,OACA,cAAc,WACd;AACA,QAAM,MAAM,eAAe;AAC3B,SAAO,CAAC,WAA2B;AACjC,aAAS,OAAO,SAAS,EAAE,IAAI;AAAA,MAC7B,KAAK;AAAA,MACL,OAAO;AAAA,IACT,CAAC;AACD,cAAU,GAAG,IAAI,EAAE,KAAK,QAAsB,MAA6B;AAAA,EAC7E;AACF;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -100,11 +100,7 @@ declare abstract class AutometaApp {
|
|
|
100
100
|
declare class AutometaWorld {
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
declare function getApp<T extends AutometaApp
|
|
104
|
-
token: any;
|
|
105
|
-
instance?: any;
|
|
106
|
-
cls?: Class<any>;
|
|
107
|
-
}[]): T;
|
|
103
|
+
declare function getApp<T extends AutometaApp>(appType: Class<T>, containerName?: string): App;
|
|
108
104
|
|
|
109
105
|
declare function AppType(container: Record<string, {
|
|
110
106
|
app: Class<App>;
|
package/dist/index.d.ts
CHANGED
|
@@ -100,11 +100,7 @@ declare abstract class AutometaApp {
|
|
|
100
100
|
declare class AutometaWorld {
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
declare function getApp<T extends AutometaApp
|
|
104
|
-
token: any;
|
|
105
|
-
instance?: any;
|
|
106
|
-
cls?: Class<any>;
|
|
107
|
-
}[]): T;
|
|
103
|
+
declare function getApp<T extends AutometaApp>(appType: Class<T>, containerName?: string): App;
|
|
108
104
|
|
|
109
105
|
declare function AppType(container: Record<string, {
|
|
110
106
|
app: Class<App>;
|
package/dist/index.js
CHANGED
|
@@ -36,48 +36,24 @@ var AutometaWorld = class {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
// src/get-app.ts
|
|
39
|
-
var import_tsyringe = require("tsyringe");
|
|
40
|
-
var import_errors = require("@autometa/errors");
|
|
41
39
|
var import_uuid = require("uuid");
|
|
42
|
-
var
|
|
43
|
-
function getApp(appType,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
Configure the app by extending 'AutometaApp' and adding it to your
|
|
48
|
-
'autometa.config.ts' file:
|
|
49
|
-
|
|
50
|
-
@AppType(MyWorld)
|
|
51
|
-
export class MyAutometaApp extends AutometaApp {
|
|
52
|
-
...
|
|
53
|
-
}
|
|
54
|
-
defineConfig({
|
|
55
|
-
roots: {
|
|
56
|
-
app: './src/app'
|
|
57
|
-
}
|
|
58
|
-
})`);
|
|
59
|
-
}
|
|
60
|
-
instances.forEach(({ token, instance, cls }) => {
|
|
61
|
-
const proxiedCls = cls ? (0, import_fixture_proxies.ErrorCatcherProxy)(cls) : void 0;
|
|
62
|
-
const proxiedInst = instance ? (0, import_fixture_proxies.ErrorCatcherProxy)(instance) : void 0;
|
|
63
|
-
return child.register(token, proxiedInst ?? proxiedCls);
|
|
64
|
-
});
|
|
65
|
-
const child = import_tsyringe.container.createChildContainer();
|
|
66
|
-
const app = (0, import_fixture_proxies.ErrorCatcherProxy)(child.resolve(appType));
|
|
67
|
-
app.id = (0, import_uuid.v4)();
|
|
68
|
-
return app;
|
|
40
|
+
var import_injection = require("@autometa/injection");
|
|
41
|
+
function getApp(appType, containerName = (0, import_uuid.v4)()) {
|
|
42
|
+
const context = (0, import_injection.defineContainerContext)(containerName);
|
|
43
|
+
const container = new import_injection.Container(context);
|
|
44
|
+
return container.get(appType);
|
|
69
45
|
}
|
|
70
46
|
|
|
71
47
|
// src/decorators/app-type.ts
|
|
72
|
-
var
|
|
73
|
-
function AppType(
|
|
48
|
+
var import_injection2 = require("@autometa/injection");
|
|
49
|
+
function AppType(container, world, environment = "default") {
|
|
74
50
|
const env = environment ?? "default";
|
|
75
51
|
return (target) => {
|
|
76
|
-
(0,
|
|
52
|
+
(0, import_injection2.metadata)(target.prototype).set({
|
|
77
53
|
key: "world",
|
|
78
54
|
class: world
|
|
79
55
|
});
|
|
80
|
-
|
|
56
|
+
container[env] = { app: target, world };
|
|
81
57
|
};
|
|
82
58
|
}
|
|
83
59
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/autometa-app.ts","../src/autometa-world.ts","../src/get-app.ts","../src/decorators/app-type.ts"],"sourcesContent":["export * from \"./autometa-app\";\nexport * from \"./autometa-world\";\nexport * from \"./get-app\";\nexport * from \"./decorators\";\nexport * from \"./fixtures.typings\";\n","import { World } from \"./fixtures.typings\";\nexport abstract class AutometaApp {\n id: string;\n [key: string]: unknown;\n world: World;\n}\n","export class AutometaWorld {}\n","import {
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/autometa-app.ts","../src/autometa-world.ts","../src/get-app.ts","../src/decorators/app-type.ts"],"sourcesContent":["export * from \"./autometa-app\";\nexport * from \"./autometa-world\";\nexport * from \"./get-app\";\nexport * from \"./decorators\";\nexport * from \"./fixtures.typings\";\n","import { World } from \"./fixtures.typings\";\nexport abstract class AutometaApp {\n id: string;\n [key: string]: unknown;\n world: World;\n}\n","export class AutometaWorld {}\n","import { AutometaApp } from \"./autometa-app\";\nimport { Class } from \"@autometa/types\";\nimport { v4 } from \"uuid\";\nimport { Container, defineContainerContext } from \"@autometa/injection\";\nimport { App } from \"./fixtures.typings\";\nexport function getApp<T extends AutometaApp>(\n appType: Class<T>,\n containerName = v4()\n): App {\n const context = defineContainerContext(containerName);\n const container = new Container(context);\n return container.get(appType);\n}\n","import { Class } from \"@autometa/types\";\nimport { App, World, AutometaWorld } from \"..\";\nimport { metadata } from \"@autometa/injection\";\nexport function AppType(\n container: Record<string, { app: Class<App>; world: Class<World> }>,\n world: Class<AutometaWorld>,\n environment = \"default\"\n) {\n const env = environment ?? \"default\";\n return (target: Class<unknown>) => {\n metadata(target.prototype).set({\n key: \"world\",\n class: world\n });\n container[env] = { app: target as Class<App>, world: world as Class<World> };\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCO,IAAe,cAAf,MAA2B;AAIlC;;;ACLO,IAAM,gBAAN,MAAoB;AAAC;;;ACE5B,kBAAmB;AACnB,uBAAkD;AAE3C,SAAS,OACd,SACA,oBAAgB,gBAAG,GACd;AACL,QAAM,cAAU,yCAAuB,aAAa;AACpD,QAAM,YAAY,IAAI,2BAAU,OAAO;AACvC,SAAO,UAAU,IAAI,OAAO;AAC9B;;;ACVA,IAAAA,oBAAyB;AAClB,SAAS,QACd,WACA,OACA,cAAc,WACd;AACA,QAAM,MAAM,eAAe;AAC3B,SAAO,CAAC,WAA2B;AACjC,oCAAS,OAAO,SAAS,EAAE,IAAI;AAAA,MAC7B,KAAK;AAAA,MACL,OAAO;AAAA,IACT,CAAC;AACD,cAAU,GAAG,IAAI,EAAE,KAAK,QAAsB,MAA6B;AAAA,EAC7E;AACF;","names":["import_injection"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autometa/app",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "App and World container for Autometa",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@autometa/asserters": "0.1.8",
|
|
52
52
|
"@autometa/errors": "0.2.2",
|
|
53
53
|
"@autometa/fixture-proxies": "^0.1.3",
|
|
54
|
-
"@autometa/injection": "^0.1.
|
|
54
|
+
"@autometa/injection": "^0.1.1",
|
|
55
55
|
"@autometa/phrases": "0.1.12",
|
|
56
56
|
"tsyringe": "^4.8.0",
|
|
57
57
|
"uuid": "^9.0.1"
|