@autometa/app 0.1.6 → 0.1.7

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @autometa/app
2
2
 
3
+ ## 0.1.7
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix: bad dist published
8
+
3
9
  ## 0.1.6
4
10
 
5
11
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/autometa-app.ts","../../src/autometa-world.ts","../../src/get-app.ts","../../src/decorators/fixture.ts","../../src/decorators/app-type.ts"],"sourcesContent":["import { World } from \"./fixtures.typings\";\n\nexport abstract class AutometaApp {\n id: string;\n [key: string]: unknown;\n world: World\n}\n","import { PhraseParser, IFromPhrase } from \"@autometa/phrases\";\n\n@PhraseParser\nexport class AutometaWorld {\n [key: string]: unknown;\n\n dfromPhrase: IFromPhrase;\n}\n","import { container } from \"tsyringe\";\nimport { AutometaApp } from \"./autometa-app\";\nimport { Class } from \"@autometa/types\";\nimport { AutomationError } from \"@autometa/errors\";\nimport { AutometaWorld } from \".\";\nimport { v4 } from \"uuid\";\n\nexport function getApp<T extends AutometaApp, K extends AutometaWorld>(\n appType: Class<T>,\n worldType: Class<K>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ...instances: { token: any; instance?: any; cls?: Class<any> }[]\n) {\n if (!appType) {\n throw new AutomationError(`A reference to an 'app' and 'world' is required to run tests.\n\nConfigure the app by extending 'AutometaApp' and adding it to your\n'autometa.config.ts' file:\n\n@AppType(MyWorld)\nexport class MyAutometaApp extends AutometaApp {\n ...\n}\ndefineConfig({\n roots: {\n app: './src/apps'\n }\n})`);\n }\n container.registerType(worldType, worldType);\n instances.forEach(({ token, instance, cls }) =>\n child.register(token, instance ?? cls)\n );\n\n const child = container.createChildContainer();\n const app = child.resolve(appType);\n app.world = child.resolve(worldType);\n app.id = v4();\n return app;\n}\n","import \"reflect-metadata\";\n\nimport { Class } from \"@autometa/types\";\nimport {\n scoped,\n inject,\n Lifecycle as LC,\n injectable,\n singleton\n} from \"tsyringe\";\n/**\n * Marks a class as an injectable fixture. Constructor parameters\n * which are also injectable will be automatically constructed\n * and passed to the constructor.\n *\n * Example fixtures are the `App` which acts as shared\n * entry point for all steps in a test, and the World,\n * which stores persistent data across tests.\n *\n * Fixtures are persistent by default, meaning each class\n * will exist as a singleton for the duration of the test\n * ```ts\n * @Fixture\n * export class World {\n * [key: string]: unknown;\n *\n * declare someExpectedData: MyDataType\n * }\n *\n * @Fixture\n * export class MyClient {\n * constructor(world: MyWorld){}\n *\n * login = async ()=>{\n * this.world.someExpectedData = await fetch(...)\n * }\n * }\n *\n * @Fixture\n * export class App {\n * constructor(\n * world: MyWorld,\n * client: MyClient\n * ){}\n * }\n * ```\n */\nexport function Fixture(target: Class<unknown>): void;\nexport function Fixture<T extends Class<unknown>>(\n scope?: Lifecycle\n): (target: T) => void;\nexport function Fixture(arg: Lifecycle | undefined | Class<unknown>) {\n if (arg && typeof arg !== \"number\") {\n injectable()(arg);\n scoped(LC.ContainerScoped)(arg);\n return;\n }\n return (target: Class<unknown>) => {\n injectable()(target);\n if (arg === LIFE_CYCLE.Singleton) {\n singleton()(target);\n return;\n }\n scoped(arg as LC.ContainerScoped | LC.ResolutionScoped)(target);\n };\n}\n\nexport const Inject = inject;\n\nexport const LIFE_CYCLE = {\n Transient: LC.Transient as 0,\n Singleton: LC.Singleton as 1,\n ResolutionScoped: LC.ResolutionScoped as 2,\n ContainerScoped: LC.ContainerScoped as 3\n} as const;\n\nexport type Lifecycle = (typeof LIFE_CYCLE)[keyof typeof LIFE_CYCLE];\n","import { Class } from \"@autometa/types\";\nimport { Lifecycle } from \"tsyringe\";\nimport { AutometaWorld } from \"..\";\nimport { Fixture } from \"./fixture\";\n\n\nexport function AppType(\n container: Record<string, { app: unknown; world: unknown; }>,\n world: Class<AutometaWorld>,\n environment = \"default\"\n) {\n const env = environment ?? \"default\";\n return (target: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;AAAA,EACd,kBAAkB,GAAG;AAAA,EACrB,iBAAiB,GAAG;AACtB;;;ACzEA,SAAS,iBAAiB;AAKnB,SAAS,QACdA,YACA,OACA,cAAc,WACd;AACA,QAAM,MAAM,eAAe;AAC3B,SAAO,CAAC,WAA2B;AACjC,YAAQ,UAAU,eAAe,EAAE,MAAM;AACzC,IAAAA,WAAU,GAAG,IAAI,EAAE,KAAK,QAAQ,MAAM;AAAA,EACxC;AACF;","names":["container"]}
1
+ {"version":3,"sources":["../../src/autometa-app.ts","../../src/autometa-world.ts","../../src/get-app.ts","../../src/decorators/fixture.ts","../../src/decorators/app-type.ts"],"sourcesContent":["import { World } from \"./fixtures.typings\";\n\nexport abstract class AutometaApp {\n id: string;\n [key: string]: unknown;\n world: World\n}\n","import { PhraseParser, IFromPhrase } from \"@autometa/phrases\";\n\n@PhraseParser\nexport class AutometaWorld {\n [key: string]: unknown;\n\n fromPhrase: IFromPhrase;\n}\n","import { container } from \"tsyringe\";\nimport { AutometaApp } from \"./autometa-app\";\nimport { Class } from \"@autometa/types\";\nimport { AutomationError } from \"@autometa/errors\";\nimport { AutometaWorld } from \".\";\nimport { v4 } from \"uuid\";\n\nexport function getApp<T extends AutometaApp, K extends AutometaWorld>(\n appType: Class<T>,\n worldType: Class<K>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ...instances: { token: any; instance?: any; cls?: Class<any> }[]\n) {\n if (!appType) {\n throw new AutomationError(`A reference to an 'app' and 'world' is required to run tests.\n\nConfigure the app by extending 'AutometaApp' and adding it to your\n'autometa.config.ts' file:\n\n@AppType(MyWorld)\nexport class MyAutometaApp extends AutometaApp {\n ...\n}\ndefineConfig({\n roots: {\n app: './src/apps'\n }\n})`);\n }\n container.registerType(worldType, worldType);\n instances.forEach(({ token, instance, cls }) =>\n child.register(token, instance ?? cls)\n );\n\n const child = container.createChildContainer();\n const app = child.resolve(appType);\n app.world = child.resolve(worldType);\n app.id = v4();\n return app;\n}\n","import \"reflect-metadata\";\n\nimport { Class } from \"@autometa/types\";\nimport {\n scoped,\n inject,\n Lifecycle as LC,\n injectable,\n singleton\n} from \"tsyringe\";\n/**\n * Marks a class as an injectable fixture. Constructor parameters\n * which are also injectable will be automatically constructed\n * and passed to the constructor.\n *\n * Example fixtures are the `App` which acts as shared\n * entry point for all steps in a test, and the World,\n * which stores persistent data across tests.\n *\n * Fixtures are persistent by default, meaning each class\n * will exist as a singleton for the duration of the test\n * ```ts\n * @Fixture\n * export class World {\n * [key: string]: unknown;\n *\n * declare someExpectedData: MyDataType\n * }\n *\n * @Fixture\n * export class MyClient {\n * constructor(world: MyWorld){}\n *\n * login = async ()=>{\n * this.world.someExpectedData = await fetch(...)\n * }\n * }\n *\n * @Fixture\n * export class App {\n * constructor(\n * world: MyWorld,\n * client: MyClient\n * ){}\n * }\n * ```\n */\nexport function Fixture(target: Class<unknown>): void;\nexport function Fixture<T extends Class<unknown>>(\n scope?: Lifecycle\n): (target: T) => void;\nexport function Fixture(arg: Lifecycle | undefined | Class<unknown>) {\n if (arg && typeof arg !== \"number\") {\n injectable()(arg);\n scoped(LC.ContainerScoped)(arg);\n return;\n }\n return (target: Class<unknown>) => {\n injectable()(target);\n if (arg === LIFE_CYCLE.Singleton) {\n singleton()(target);\n return;\n }\n scoped(arg as LC.ContainerScoped | LC.ResolutionScoped)(target);\n };\n}\n\nexport const Inject = inject;\n\nexport const LIFE_CYCLE = {\n Transient: LC.Transient as 0,\n Singleton: LC.Singleton as 1,\n ResolutionScoped: LC.ResolutionScoped as 2,\n ContainerScoped: LC.ContainerScoped as 3\n} as const;\n\nexport type Lifecycle = (typeof LIFE_CYCLE)[keyof typeof LIFE_CYCLE];\n","import { Class } from \"@autometa/types\";\nimport { Lifecycle } from \"tsyringe\";\nimport { AutometaWorld } from \"..\";\nimport { Fixture } from \"./fixture\";\n\n\nexport function AppType(\n container: Record<string, { app: unknown; world: unknown; }>,\n world: Class<AutometaWorld>,\n environment = \"default\"\n) {\n const env = environment ?? \"default\";\n return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AAG;AAAA,EACd,kBAAkB,GAAG;AAAA,EACrB,iBAAiB,GAAG;AACtB;;;ACzEA,SAAS,iBAAiB;AAKnB,SAAS,QACdA,YACA,OACA,cAAc,WACd;AACA,QAAM,MAAM,eAAe;AAC3B,SAAO,CAAC,WAA2B;AACjC,YAAQ,UAAU,eAAe,EAAE,MAAM;AACzC,IAAAA,WAAU,GAAG,IAAI,EAAE,KAAK,QAAQ,MAAM;AAAA,EACxC;AACF;","names":["container"]}
package/dist/index.d.cts CHANGED
@@ -17,7 +17,7 @@ declare abstract class AutometaApp {
17
17
 
18
18
  declare class AutometaWorld {
19
19
  [key: string]: unknown;
20
- dfromPhrase: IFromPhrase;
20
+ fromPhrase: IFromPhrase;
21
21
  }
22
22
 
23
23
  declare function getApp<T extends AutometaApp, K extends AutometaWorld>(appType: Class<T>, worldType: Class<K>, ...instances: {
package/dist/index.d.ts CHANGED
@@ -17,7 +17,7 @@ declare abstract class AutometaApp {
17
17
 
18
18
  declare class AutometaWorld {
19
19
  [key: string]: unknown;
20
- dfromPhrase: IFromPhrase;
20
+ fromPhrase: IFromPhrase;
21
21
  }
22
22
 
23
23
  declare function getApp<T extends AutometaApp, K extends AutometaWorld>(appType: Class<T>, worldType: Class<K>, ...instances: {
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/fixture.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'","import { World } from \"./fixtures.typings\";\n\nexport abstract class AutometaApp {\n id: string;\n [key: string]: unknown;\n world: World\n}\n","import { PhraseParser, IFromPhrase } from \"@autometa/phrases\";\n\n@PhraseParser\nexport class AutometaWorld {\n [key: string]: unknown;\n\n dfromPhrase: IFromPhrase;\n}\n","import { container } from \"tsyringe\";\nimport { AutometaApp } from \"./autometa-app\";\nimport { Class } from \"@autometa/types\";\nimport { AutomationError } from \"@autometa/errors\";\nimport { AutometaWorld } from \".\";\nimport { v4 } from \"uuid\";\n\nexport function getApp<T extends AutometaApp, K extends AutometaWorld>(\n appType: Class<T>,\n worldType: Class<K>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ...instances: { token: any; instance?: any; cls?: Class<any> }[]\n) {\n if (!appType) {\n throw new AutomationError(`A reference to an 'app' and 'world' is required to run tests.\n\nConfigure the app by extending 'AutometaApp' and adding it to your\n'autometa.config.ts' file:\n\n@AppType(MyWorld)\nexport class MyAutometaApp extends AutometaApp {\n ...\n}\ndefineConfig({\n roots: {\n app: './src/apps'\n }\n})`);\n }\n container.registerType(worldType, worldType);\n instances.forEach(({ token, instance, cls }) =>\n child.register(token, instance ?? cls)\n );\n\n const child = container.createChildContainer();\n const app = child.resolve(appType);\n app.world = child.resolve(worldType);\n app.id = v4();\n return app;\n}\n","import \"reflect-metadata\";\n\nimport { Class } from \"@autometa/types\";\nimport {\n scoped,\n inject,\n Lifecycle as LC,\n injectable,\n singleton\n} from \"tsyringe\";\n/**\n * Marks a class as an injectable fixture. Constructor parameters\n * which are also injectable will be automatically constructed\n * and passed to the constructor.\n *\n * Example fixtures are the `App` which acts as shared\n * entry point for all steps in a test, and the World,\n * which stores persistent data across tests.\n *\n * Fixtures are persistent by default, meaning each class\n * will exist as a singleton for the duration of the test\n * ```ts\n * @Fixture\n * export class World {\n * [key: string]: unknown;\n *\n * declare someExpectedData: MyDataType\n * }\n *\n * @Fixture\n * export class MyClient {\n * constructor(world: MyWorld){}\n *\n * login = async ()=>{\n * this.world.someExpectedData = await fetch(...)\n * }\n * }\n *\n * @Fixture\n * export class App {\n * constructor(\n * world: MyWorld,\n * client: MyClient\n * ){}\n * }\n * ```\n */\nexport function Fixture(target: Class<unknown>): void;\nexport function Fixture<T extends Class<unknown>>(\n scope?: Lifecycle\n): (target: T) => void;\nexport function Fixture(arg: Lifecycle | undefined | Class<unknown>) {\n if (arg && typeof arg !== \"number\") {\n injectable()(arg);\n scoped(LC.ContainerScoped)(arg);\n return;\n }\n return (target: Class<unknown>) => {\n injectable()(target);\n if (arg === LIFE_CYCLE.Singleton) {\n singleton()(target);\n return;\n }\n scoped(arg as LC.ContainerScoped | LC.ResolutionScoped)(target);\n };\n}\n\nexport const Inject = inject;\n\nexport const LIFE_CYCLE = {\n Transient: LC.Transient as 0,\n Singleton: LC.Singleton as 1,\n ResolutionScoped: LC.ResolutionScoped as 2,\n ContainerScoped: LC.ContainerScoped as 3\n} as const;\n\nexport type Lifecycle = (typeof LIFE_CYCLE)[keyof typeof LIFE_CYCLE];\n","import { Class } from \"@autometa/types\";\nimport { Lifecycle } from \"tsyringe\";\nimport { AutometaWorld } from \"..\";\nimport { Fixture } from \"./fixture\";\n\n\nexport function AppType(\n container: Record<string, { app: unknown; world: unknown; }>,\n world: Class<AutometaWorld>,\n environment = \"default\"\n) {\n const env = environment ?? \"default\";\n return (target: Class<unknown>) => {\n Fixture(Lifecycle.ContainerScoped)(target);\n container[env] = { app: target, world };\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAe,cAAf,MAA2B;AAIlC;;;ACNA,qBAA0C;AAGnC,IAAM,gBAAN,MAAoB;AAI3B;AAJa,gBAAN;AAAA,EADN;AAAA,GACY;;;ACHb,sBAA0B;AAG1B,oBAAgC;AAEhC,kBAAmB;AAEZ,SAAS,OACd,SACA,cAEG,WACH;AACA,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,8BAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAa3B;AAAA,EACD;AACA,4BAAU,aAAa,WAAW,SAAS;AAC3C,YAAU;AAAA,IAAQ,CAAC,EAAE,OAAO,UAAU,IAAI,MACxC,MAAM,SAAS,OAAO,YAAY,GAAG;AAAA,EACvC;AAEA,QAAM,QAAQ,0BAAU,qBAAqB;AAC7C,QAAM,MAAM,MAAM,QAAQ,OAAO;AACjC,MAAI,QAAQ,MAAM,QAAQ,SAAS;AACnC,MAAI,SAAK,gBAAG;AACZ,SAAO;AACT;;;ACvCA,8BAAO;AAGP,IAAAA,mBAMO;AA0CA,SAAS,QAAQ,KAA6C;AACnE,MAAI,OAAO,OAAO,QAAQ,UAAU;AAClC,qCAAW,EAAE,GAAG;AAChB,iCAAO,iBAAAC,UAAG,eAAe,EAAE,GAAG;AAC9B;AAAA,EACF;AACA,SAAO,CAAC,WAA2B;AACjC,qCAAW,EAAE,MAAM;AACnB,QAAI,QAAQ,WAAW,WAAW;AAChC,sCAAU,EAAE,MAAM;AAClB;AAAA,IACF;AACA,iCAAO,GAA+C,EAAE,MAAM;AAAA,EAChE;AACF;AAEO,IAAM,SAAS;AAEf,IAAM,aAAa;AAAA,EACxB,WAAW,iBAAAA,UAAG;AAAA,EACd,WAAW,iBAAAA,UAAG;AAAA,EACd,kBAAkB,iBAAAA,UAAG;AAAA,EACrB,iBAAiB,iBAAAA,UAAG;AACtB;;;ACzEA,IAAAC,mBAA0B;AAKnB,SAAS,QACdC,YACA,OACA,cAAc,WACd;AACA,QAAM,MAAM,eAAe;AAC3B,SAAO,CAAC,WAA2B;AACjC,YAAQ,2BAAU,eAAe,EAAE,MAAM;AACzC,IAAAA,WAAU,GAAG,IAAI,EAAE,KAAK,QAAQ,MAAM;AAAA,EACxC;AACF;","names":["import_tsyringe","LC","import_tsyringe","container"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/autometa-app.ts","../src/autometa-world.ts","../src/get-app.ts","../src/decorators/fixture.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'","import { World } from \"./fixtures.typings\";\n\nexport abstract class AutometaApp {\n id: string;\n [key: string]: unknown;\n world: World\n}\n","import { PhraseParser, IFromPhrase } from \"@autometa/phrases\";\n\n@PhraseParser\nexport class AutometaWorld {\n [key: string]: unknown;\n\n fromPhrase: IFromPhrase;\n}\n","import { container } from \"tsyringe\";\nimport { AutometaApp } from \"./autometa-app\";\nimport { Class } from \"@autometa/types\";\nimport { AutomationError } from \"@autometa/errors\";\nimport { AutometaWorld } from \".\";\nimport { v4 } from \"uuid\";\n\nexport function getApp<T extends AutometaApp, K extends AutometaWorld>(\n appType: Class<T>,\n worldType: Class<K>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ...instances: { token: any; instance?: any; cls?: Class<any> }[]\n) {\n if (!appType) {\n throw new AutomationError(`A reference to an 'app' and 'world' is required to run tests.\n\nConfigure the app by extending 'AutometaApp' and adding it to your\n'autometa.config.ts' file:\n\n@AppType(MyWorld)\nexport class MyAutometaApp extends AutometaApp {\n ...\n}\ndefineConfig({\n roots: {\n app: './src/apps'\n }\n})`);\n }\n container.registerType(worldType, worldType);\n instances.forEach(({ token, instance, cls }) =>\n child.register(token, instance ?? cls)\n );\n\n const child = container.createChildContainer();\n const app = child.resolve(appType);\n app.world = child.resolve(worldType);\n app.id = v4();\n return app;\n}\n","import \"reflect-metadata\";\n\nimport { Class } from \"@autometa/types\";\nimport {\n scoped,\n inject,\n Lifecycle as LC,\n injectable,\n singleton\n} from \"tsyringe\";\n/**\n * Marks a class as an injectable fixture. Constructor parameters\n * which are also injectable will be automatically constructed\n * and passed to the constructor.\n *\n * Example fixtures are the `App` which acts as shared\n * entry point for all steps in a test, and the World,\n * which stores persistent data across tests.\n *\n * Fixtures are persistent by default, meaning each class\n * will exist as a singleton for the duration of the test\n * ```ts\n * @Fixture\n * export class World {\n * [key: string]: unknown;\n *\n * declare someExpectedData: MyDataType\n * }\n *\n * @Fixture\n * export class MyClient {\n * constructor(world: MyWorld){}\n *\n * login = async ()=>{\n * this.world.someExpectedData = await fetch(...)\n * }\n * }\n *\n * @Fixture\n * export class App {\n * constructor(\n * world: MyWorld,\n * client: MyClient\n * ){}\n * }\n * ```\n */\nexport function Fixture(target: Class<unknown>): void;\nexport function Fixture<T extends Class<unknown>>(\n scope?: Lifecycle\n): (target: T) => void;\nexport function Fixture(arg: Lifecycle | undefined | Class<unknown>) {\n if (arg && typeof arg !== \"number\") {\n injectable()(arg);\n scoped(LC.ContainerScoped)(arg);\n return;\n }\n return (target: Class<unknown>) => {\n injectable()(target);\n if (arg === LIFE_CYCLE.Singleton) {\n singleton()(target);\n return;\n }\n scoped(arg as LC.ContainerScoped | LC.ResolutionScoped)(target);\n };\n}\n\nexport const Inject = inject;\n\nexport const LIFE_CYCLE = {\n Transient: LC.Transient as 0,\n Singleton: LC.Singleton as 1,\n ResolutionScoped: LC.ResolutionScoped as 2,\n ContainerScoped: LC.ContainerScoped as 3\n} as const;\n\nexport type Lifecycle = (typeof LIFE_CYCLE)[keyof typeof LIFE_CYCLE];\n","import { Class } from \"@autometa/types\";\nimport { Lifecycle } from \"tsyringe\";\nimport { AutometaWorld } from \"..\";\nimport { Fixture } from \"./fixture\";\n\n\nexport function AppType(\n container: Record<string, { app: unknown; world: unknown; }>,\n world: Class<AutometaWorld>,\n environment = \"default\"\n) {\n const env = environment ?? \"default\";\n return (target: Class<unknown>) => {\n Fixture(Lifecycle.ContainerScoped)(target);\n container[env] = { app: target, world };\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAe,cAAf,MAA2B;AAIlC;;;ACNA,qBAA0C;AAGnC,IAAM,gBAAN,MAAoB;AAI3B;AAJa,gBAAN;AAAA,EADN;AAAA,GACY;;;ACHb,sBAA0B;AAG1B,oBAAgC;AAEhC,kBAAmB;AAEZ,SAAS,OACd,SACA,cAEG,WACH;AACA,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,8BAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAa3B;AAAA,EACD;AACA,4BAAU,aAAa,WAAW,SAAS;AAC3C,YAAU;AAAA,IAAQ,CAAC,EAAE,OAAO,UAAU,IAAI,MACxC,MAAM,SAAS,OAAO,YAAY,GAAG;AAAA,EACvC;AAEA,QAAM,QAAQ,0BAAU,qBAAqB;AAC7C,QAAM,MAAM,MAAM,QAAQ,OAAO;AACjC,MAAI,QAAQ,MAAM,QAAQ,SAAS;AACnC,MAAI,SAAK,gBAAG;AACZ,SAAO;AACT;;;ACvCA,8BAAO;AAGP,IAAAA,mBAMO;AA0CA,SAAS,QAAQ,KAA6C;AACnE,MAAI,OAAO,OAAO,QAAQ,UAAU;AAClC,qCAAW,EAAE,GAAG;AAChB,iCAAO,iBAAAC,UAAG,eAAe,EAAE,GAAG;AAC9B;AAAA,EACF;AACA,SAAO,CAAC,WAA2B;AACjC,qCAAW,EAAE,MAAM;AACnB,QAAI,QAAQ,WAAW,WAAW;AAChC,sCAAU,EAAE,MAAM;AAClB;AAAA,IACF;AACA,iCAAO,GAA+C,EAAE,MAAM;AAAA,EAChE;AACF;AAEO,IAAM,SAAS;AAEf,IAAM,aAAa;AAAA,EACxB,WAAW,iBAAAA,UAAG;AAAA,EACd,WAAW,iBAAAA,UAAG;AAAA,EACd,kBAAkB,iBAAAA,UAAG;AAAA,EACrB,iBAAiB,iBAAAA,UAAG;AACtB;;;ACzEA,IAAAC,mBAA0B;AAKnB,SAAS,QACdC,YACA,OACA,cAAc,WACd;AACA,QAAM,MAAM,eAAe;AAC3B,SAAO,CAAC,WAA2B;AACjC,YAAQ,2BAAU,eAAe,EAAE,MAAM;AACzC,IAAAA,WAAU,GAAG,IAAI,EAAE,KAAK,QAAQ,MAAM;AAAA,EACxC;AACF;","names":["import_tsyringe","LC","import_tsyringe","container"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autometa/app",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "App and World container for Autometa",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -43,15 +43,15 @@
43
43
  "types": "link:packages/types",
44
44
  "typescript": "^4.9.5",
45
45
  "vitest": "0.33.0",
46
- "@autometa/types": "^0.4.0",
47
46
  "eslint-config-custom": "0.6.0",
47
+ "@autometa/types": "^0.4.0",
48
48
  "tsconfig": "0.7.0"
49
49
  },
50
50
  "dependencies": {
51
51
  "tsyringe": "^4.8.0",
52
52
  "uuid": "^9.0.0",
53
- "@autometa/errors": "0.1.2",
54
53
  "@autometa/asserters": "0.1.2",
54
+ "@autometa/errors": "0.1.2",
55
55
  "@autometa/phrases": "0.1.4"
56
56
  },
57
57
  "scripts": {