UNPKG

13.7 kBSource Map (JSON)View Raw
1{"version":3,"sources":["../src/inversify.config.ts"],"names":["Container","getDecorators","ComponentManager","ResourcePool","FrameGraphSystem","GeometryComponent","GeometrySystem","MaterialComponent","MaterialSystem","CullableComponent","MeshComponent","MeshSystem","CopyPass","PixelPickingPass","RenderPass","RendererSystem","HierarchyComponent","NameComponent","SceneGraphSystem","TransformComponent","IDENTIFIER","ConfigService","InteractorService","ShaderModuleService","container","DECORATORS","lazyInject","serviceIdentifier","original","proto","key","descriptor","call","initializer","lazyMultiInject","bind","to","inSingletonScope","NameComponentManager","toConstantValue","HierarchyComponentManager","TransformComponentManager","MeshComponentManager","CullableComponentManager","GeometryComponentManager","MaterialComponentManager","createWorldContainer","worldContainer","parent","Systems","whenTargetNamed","RenderPassFactory","toFactory","context","name","getNamed"],"mappings":"AAAA;AACA;AACA;AACA;AACA,OAAO,kBAAP;AAGA,SACEA,SADF,QAMO,WANP;AAOA,OAAOC,aAAP,MAA0B,6BAA1B;AAEA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,YAAT,QAA6B,sCAA7B;AACA,SAASC,gBAAT,QAAiC,gCAAjC;AACA,SAASC,iBAAT,QAAkC,yCAAlC;AACA,SAASC,cAAT,QAA+B,8BAA/B,C,CACA;;AACA,SAASC,iBAAT,QAAkC,yCAAlC;AACA,SAASC,cAAT,QAA+B,8BAA/B;AACA,SAASC,iBAAT,QAAkC,qCAAlC;AACA,SAASC,aAAT,QAA8B,iCAA9B;AACA,SAASC,UAAT,QAA2B,0BAA3B;AACA,SAASC,QAAT,QAAyB,uCAAzB;AAEA,SAASC,gBAAT,QAAiC,+CAAjC;AACA,SAASC,UAAT,QAA2B,yCAA3B;AACA,SAASC,cAAT,QAA+B,8BAA/B;AACA,SAASC,kBAAT,QAAmC,4CAAnC;AACA,SAASC,aAAT,QAA8B,uCAA9B;AACA,SAASC,gBAAT,QAAiC,gCAAjC;AACA,SAASC,kBAAT,QAAmC,4CAAnC;AACA,SAASC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CAEMxB,QAFN,EAGGyB,gBAHH,GAIGa,eAJH,CAImBtC,QAAQ,CAACQ,UAJ5B;AAKA2B,EAAAA,cAAc,CACXZ,IADH,CAC0Bf,UAAU,CAACN,UADrC,EAEGsB,EAFH,CAEMvB,gBAFN,EAGGwB,gBAHH,GAIGa,eAJH,CAImBrC,gBAAgB,CAACO,UAJpC;AAMA2B,EAAAA,cAAc,CACXZ,IADH,CAC8Cf,UAAU,CAAC+B,iBADzD,EAEGC,SAFH,CAE+B,UAACC,OAAD,EAAiC;AAC5D,WAAO,UAACC,IAAD,EAAkB;AACvB,aAAOD,OAAO,CAAC7B,SAAR,CAAkB+B,QAAlB,CAA2BnC,UAAU,CAACN,UAAtC,EAAkDwC,IAAlD,CAAP;AACD,KAFD;AAGD,GANH;AAQA,SAAOP,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