UNPKG

13 kBSource Map (JSON)View Raw
1{"version":3,"sources":["../src/inversify.config.ts"],"names":["container","Container","DECORATORS","lazyInject","serviceIdentifier","original","proto","key","descriptor","call","initializer","lazyMultiInject","bind","IDENTIFIER","ShaderModuleService","to","inSingletonScope","NameComponentManager","toConstantValue","ComponentManager","NameComponent","HierarchyComponentManager","HierarchyComponent","TransformComponentManager","TransformComponent","MeshComponentManager","MeshComponent","CullableComponentManager","CullableComponent","GeometryComponentManager","GeometryComponent","MaterialComponentManager","MaterialComponent","createWorldContainer","worldContainer","parent","Systems","SceneGraphSystem","whenTargetNamed","FrameGraphSystem","MeshSystem","GeometrySystem","MaterialSystem","RendererSystem","ResourcePool","ConfigService","InteractorService","RenderPass","CopyPass","PixelPickingPass","RenderPassFactory","toFactory","context","name","getNamed"],"mappings":";;;;;;;;;;AAIA;;AAGA;;AAOA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAvCA;AACA;AACA;AACA;AAkBA;AAoBA;AACO,IAAMA,SAAS,GAAG,IAAIC,oBAAJ,EAAlB,C,CAEP;AACA;AACA;AACA;AACA;;;AACA,IAAMC,UAAU,GAAG,wCAAcF,SAAd,EAAyB,KAAzB,CAAnB;;AAKA;AACA;AACA;AACO,IAAMG,UAAU,GAAG,SAAbA,UAAa,CACxBC,iBADwB,EAErB;AACH,MAAMC,QAAQ,GAAGH,UAAU,CAACC,UAAX,CAAsBC,iBAAtB,CAAjB,CADG,CAEH;AACA;;AACA,SAAO,UAELE,KAFK,EAGLC,GAHK,EAILC,UAJK,EAKC;AACN;AACAH,IAAAA,QAAQ,CAACI,IAAT,CAAc,IAAd,EAAoBH,KAApB,EAA2BC,GAA3B,EAFM,CAGN;;AACA,QAAIC,UAAJ,EAAgB;AACdA,MAAAA,UAAU,CAACE,WAAX,GAAyB,YAAM;AAC7B,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AEG7B,EAFH,CAEM6B,0BAFN,EAGG5B,gBAHH;AAIAkB,EAAAA,cAAc,CACXtB,IADH,CACQC,uBAAWgC,aADnB,EAEG9B,EAFH,CAEM8B,4BAFN,EAGG7B,gBAHH;AAIAkB,EAAAA,cAAc,CACXtB,IADH,CACQC,uBAAWiC,iBADnB,EAEG/B,EAFH,CAEM+B,mCAFN,EAGG9B,gBAHH;AAKA;AACF;AACA;;AACEkB,EAAAA,cAAc,CACXtB,IADH,CAC0BC,uBAAWkC,UADrC,EAEGhC,EAFH,CAEMgC,sBAFN,EAGG/B,gBAHH,GAIGsB,eAJH,CAImBS,uBAAWlC,UAJ9B;AAKAqB,EAAAA,cAAc,CACXtB,IADH,CAC0BC,uBAAWkC,UADrC,EAEGhC,EAFH,CAEMiC,kBAFN,EAGGhC,gBAHH,GAIGsB,eAJH,CAImBU,mBAASnC,UAJ5B;AAKAqB,EAAAA,cAAc,CACXtB,IADH,CAC0BC,uBAAWkC,UADrC,EAEGhC,EAFH,CAEMkC,kCAFN,EAGGjC,gBAHH,GAIGsB,eAJH,CAImBW,mCAAiBpC,UAJpC;AAMAqB,EAAAA,cAAc,CACXtB,IADH,CAC8CC,uBAAWqC,iBADzD,EAEGC,SAFH,CAE+B,UAACC,OAAD,EAAiC;AAC5D,WAAO,UAACC,IAAD,EAAkB;AACvB,aAAOD,OAAO,CAACpD,SAAR,CAAkBsD,QAAlB,CAA2BzC,uBAAWkC,UAAtC,EAAkDM,IAAlD,CAAP;AACD,KAFD;AAGD,GANH;AAQA,SAAOnB,cAAP;AACD","sourcesContent":["/**\n * Root Container\n * @see /dev-docs/IoC 容器、依赖注入与服务说明.md\n */\nimport 'reflect-metadata';\n\nimport { EventEmitter } from 'eventemitter3';\nimport {\n Container,\n ContainerModule,\n decorate,\n injectable,\n interfaces,\n} from 'inversify';\nimport getDecorators from 'inversify-inject-decorators';\nimport { ISystem } from '.';\nimport { ComponentManager } from './ComponentManager';\nimport { ResourcePool } from './components/framegraph/ResourcePool';\nimport { FrameGraphSystem } from './components/framegraph/System';\nimport { GeometryComponent } from './components/geometry/GeometryComponent';\nimport { GeometrySystem } from './components/geometry/System';\n// import { InteractionSystem } from './components/interaction/System';\nimport { MaterialComponent } from './components/material/MaterialComponent';\nimport { MaterialSystem } from './components/material/System';\nimport { CullableComponent } from './components/mesh/CullableComponent';\nimport { MeshComponent } from './components/mesh/MeshComponent';\nimport { MeshSystem } from './components/mesh/System';\nimport { CopyPass } from './components/renderer/passes/CopyPass';\nimport { IRenderPass } from './components/renderer/passes/IRenderPass';\nimport { PixelPickingPass } from './components/renderer/passes/PixelPickingPass';\nimport { RenderPass } from './components/renderer/passes/RenderPass';\nimport { RendererSystem } from './components/renderer/System';\nimport { HierarchyComponent } from './components/scenegraph/HierarchyComponent';\nimport { NameComponent } from './components/scenegraph/NameComponent';\nimport { SceneGraphSystem } from './components/scenegraph/System';\nimport { TransformComponent } from './components/scenegraph/TransformComponent';\nimport { IDENTIFIER } from './identifier';\nimport { ConfigService } from './services/config/ConfigService';\nimport { InteractorService } from './services/interactor/IteractorService';\nimport ShaderModuleService from './services/shader-module/ShaderModuleService';\n\n// @see https://github.com/inversify/InversifyJS/blob/master/wiki/container_api.md#defaultscope\nexport const container = new Container();\n\n// @see https://github.com/inversify/InversifyJS/blob/master/wiki/inheritance.md#what-can-i-do-when-my-base-class-is-provided-by-a-third-party-module\n// decorate(injectable(), EventEmitter);\n// container.bind(IDENTIFIER.IEventEmitter).to(EventEmitter);\n// 支持使用 new 而非容器实例化的场景,同时禁止 lazyInject cache\n// @see https://github.com/inversify/inversify-inject-decorators#caching-vs-non-caching-behaviour\nconst DECORATORS = getDecorators(container, false);\n\ninterface IBabelPropertyDescriptor extends PropertyDescriptor {\n initializer(): any;\n}\n// Add babel legacy decorators support\n// @see https://github.com/inversify/InversifyJS/issues/1050\n// @see https://github.com/inversify/InversifyJS/issues/1026#issuecomment-504936034\nexport const lazyInject = (\n serviceIdentifier: interfaces.ServiceIdentifier<any>,\n) => {\n const original = DECORATORS.lazyInject(serviceIdentifier);\n // the 'descriptor' parameter is actually always defined for class fields for Babel, but is considered undefined for TSC\n // so we just hack it with ?/! combination to avoid \"TS1240: Unable to resolve signature of property decorator when called as an expression\"\n return function(\n this: any,\n proto: any,\n key: string,\n descriptor?: IBabelPropertyDescriptor,\n ): void {\n // make it work as usual\n original.call(this, proto, key);\n // return link to proto, so own value wont be 'undefined' after component's creation\n if (descriptor) {\n descriptor.initializer = () => {\n return proto[key];\n };\n }\n };\n};\n\nexport const lazyMultiInject = (\n serviceIdentifier: interfaces.ServiceIdentifier<any>,\n) => {\n const original = DECORATORS.lazyMultiInject(serviceIdentifier);\n // the 'descriptor' parameter is actually always defined for class fields for Babel, but is considered undefined for TSC\n // so we just hack it with ?/! combination to avoid \"TS1240: Unable to resolve signature of property decorator when called as an expression\"\n return function(\n this: any,\n proto: any,\n key: string,\n descriptor?: IBabelPropertyDescriptor,\n ): void {\n // make it work as usual\n original.call(this, proto, key);\n if (descriptor) {\n // return link to proto, so own value wont be 'undefined' after component's creation\n descriptor!.initializer = () => {\n return proto[key];\n };\n }\n };\n};\n\n/** global services */\ncontainer\n .bind(IDENTIFIER.ShaderModuleService)\n .to(ShaderModuleService)\n .inSingletonScope();\n\n/**\n * bind global component managers in root container\n */\ncontainer\n .bind<ComponentManager<NameComponent>>(IDENTIFIER.NameComponentManager)\n .toConstantValue(new ComponentManager(NameComponent));\ncontainer\n .bind<ComponentManager<HierarchyComponent>>(\n IDENTIFIER.HierarchyComponentManager,\n )\n .toConstantValue(new ComponentManager(HierarchyComponent));\ncontainer\n .bind<ComponentManager<TransformComponent>>(\n IDENTIFIER.TransformComponentManager,\n )\n .toConstantValue(new ComponentManager(TransformComponent));\ncontainer\n .bind<ComponentManager<MeshComponent>>(IDENTIFIER.MeshComponentManager)\n .toConstantValue(new ComponentManager(MeshComponent));\ncontainer\n .bind<ComponentManager<CullableComponent>>(\n IDENTIFIER.CullableComponentManager,\n )\n .toConstantValue(new ComponentManager(CullableComponent));\ncontainer\n .bind<ComponentManager<GeometryComponent>>(\n IDENTIFIER.GeometryComponentManager,\n )\n .toConstantValue(new ComponentManager(GeometryComponent));\ncontainer\n .bind<ComponentManager<MaterialComponent>>(\n IDENTIFIER.MaterialComponentManager,\n )\n .toConstantValue(new ComponentManager(MaterialComponent));\n\n// https://github.com/inversify/InversifyJS/blob/master/wiki/hierarchical_di.md#support-for-hierarchical-di-systems\nexport function createWorldContainer() {\n const worldContainer = new Container();\n worldContainer.parent = container;\n\n /**\n * bind systems\n */\n worldContainer\n .bind<ISystem>(IDENTIFIER.Systems)\n .to(SceneGraphSystem)\n .inSingletonScope()\n .whenTargetNamed(IDENTIFIER.SceneGraphSystem);\n\n worldContainer\n .bind<ISystem>(IDENTIFIER.Systems)\n .to(FrameGraphSystem)\n .inSingletonScope()\n .whenTargetNamed(IDENTIFIER.FrameGraphSystem);\n\n worldContainer\n .bind<ISystem>(IDENTIFIER.Systems)\n .to(MeshSystem)\n .inSingletonScope()\n .whenTargetNamed(IDENTIFIER.MeshSystem);\n\n worldContainer\n .bind<ISystem>(IDENTIFIER.Systems)\n .to(GeometrySystem)\n .inSingletonScope()\n .whenTargetNamed(IDENTIFIER.GeometrySystem);\n\n worldContainer\n .bind<ISystem>(IDENTIFIER.Systems)\n .to(MaterialSystem)\n .inSingletonScope()\n .whenTargetNamed(IDENTIFIER.MaterialSystem);\n\n worldContainer\n .bind<ISystem>(IDENTIFIER.Systems)\n .to(RendererSystem)\n .inSingletonScope()\n .whenTargetNamed(IDENTIFIER.RendererSystem);\n\n // 资源池\n worldContainer\n .bind(IDENTIFIER.ResourcePool)\n .to(ResourcePool)\n .inSingletonScope();\n worldContainer\n .bind(IDENTIFIER.ConfigService)\n .to(ConfigService)\n .inSingletonScope();\n worldContainer\n .bind(IDENTIFIER.InteractorService)\n .to(InteractorService)\n .inSingletonScope();\n\n /**\n * bind render passes\n */\n worldContainer\n .bind<IRenderPass<any>>(IDENTIFIER.RenderPass)\n .to(RenderPass)\n .inSingletonScope()\n .whenTargetNamed(RenderPass.IDENTIFIER);\n worldContainer\n .bind<IRenderPass<any>>(IDENTIFIER.RenderPass)\n .to(CopyPass)\n .inSingletonScope()\n .whenTargetNamed(CopyPass.IDENTIFIER);\n worldContainer\n .bind<IRenderPass<any>>(IDENTIFIER.RenderPass)\n .to(PixelPickingPass)\n .inSingletonScope()\n .whenTargetNamed(PixelPickingPass.IDENTIFIER);\n\n worldContainer\n .bind<interfaces.Factory<IRenderPass<any>>>(IDENTIFIER.RenderPassFactory)\n .toFactory<IRenderPass<any>>((context: interfaces.Context) => {\n return (name: string) => {\n return context.container.getNamed(IDENTIFIER.RenderPass, name);\n };\n });\n\n return worldContainer;\n}\n"],"file":"inversify.config.js"}
\No newline at end of file