{"_id":"@cofn/di","_rev":"2-92e46e9041a1a74156207fc13a8d88f7","name":"@cofn/di","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.1":{"name":"@cofn/di","version":"0.0.1","description":"DOM as DI container","type":"module","exports":{"./package.json":"./package.json",".":{"import":{"default":"./dist/cofn-di.js"}}},"scripts":{"dev":"vite","test":"node test/run-ci.js","build":"mkdir -p dist && rollup src/index.js > dist/cofn-di.js","size":"rollup -p @rollup/plugin-terser src/index.js | gzip | wc -c"},"author":{"name":"Laurent RENARD"},"devDependencies":{"@cofn/core":"workspace:^","@cofn/test-lib":"workspace:*"},"keywords":["di","cofn","web","ui"],"license":"MIT","_id":"@cofn/di@0.0.1","gitHead":"36c0d221aa6d619fa397023dd55e958d830560e5","_nodeVersion":"20.10.0","_npmVersion":"10.2.5","dist":{"integrity":"sha512-RfEV4MIfaBKIEhRTORY0LBGZEX5EVXqd2+RsGVcrAyTmDKvra0T1E0IAM1nmKPqwuoozVb3GMivPCH/VRkUUrw==","shasum":"fdae3f174cc1b4c411a5eb13b7ceb4eb0d148278","tarball":"https://registry.npmjs.org/@cofn/di/-/di-0.0.1.tgz","fileCount":4,"unpackedSize":5455,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHK6tEdPBJg7x04zFhcrZ1aLWatNEoAvQouz2RVhwj2fAiAd/Kx2kcGmJdduCeEfUtgRQufEKeB9ODQ296BO5c4WFA=="}]},"_npmUser":{"name":"lorenzofox3","email":"laurent34azerty@gmail.com"},"directories":{},"maintainers":[{"name":"lorenzofox3","email":"laurent34azerty@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/di_0.0.1_1710930763454_0.36186136130156865"},"_hasShrinkwrap":false},"0.0.2":{"name":"@cofn/di","version":"0.0.2","description":"DOM as DI container","type":"module","exports":{"./package.json":"./package.json",".":{"import":{"default":"./dist/cofn-di.js"}}},"scripts":{"dev":"vite","test":"node test/run-ci.js","build":"mkdir -p dist && rollup src/index.js > dist/cofn-di.js","size":"rollup -p @rollup/plugin-terser src/index.js | gzip | wc -c"},"author":{"name":"Laurent RENARD"},"devDependencies":{"@cofn/core":"workspace:^","@cofn/test-lib":"workspace:*"},"keywords":["di","cofn","web","ui"],"license":"MIT","_id":"@cofn/di@0.0.2","gitHead":"ecc14facd79ab9e9768cd4edb3cbda19111b4b43","_nodeVersion":"20.10.0","_npmVersion":"10.2.5","dist":{"integrity":"sha512-64IK35Y6JOcsJNmPBFCWKXNY9+mS//Zrs7RQ7VP0S0DYOWuCsLjWfqOC3MarpuvF3dDgqvviFSE432VqTfCUBQ==","shasum":"45053788582a476381de98e075b8c2e648c55502","tarball":"https://registry.npmjs.org/@cofn/di/-/di-0.0.2.tgz","fileCount":3,"unpackedSize":4430,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAwAHYl/4igVULiT4IToP+7YInjj3o5j2PI+CIB4kO1rAiAKLT2VoTE9P4Rss9zAnWOTHooycJ0cji2r+LRWxVMDqw=="}]},"_npmUser":{"name":"lorenzofox3","email":"laurent34azerty@gmail.com"},"directories":{},"maintainers":[{"name":"lorenzofox3","email":"laurent34azerty@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/di_0.0.2_1710947387585_0.7977246653709211"},"_hasShrinkwrap":false},"0.0.3":{"name":"@cofn/di","version":"0.0.3","description":"DOM as DI container","type":"module","main":"./dist/cofn-di.js","exports":{"./package.json":"./package.json",".":{"import":{"default":"./dist/cofn-di.js"}}},"scripts":{"dev":"vite","test":"node test/run-ci.js","build":"mkdir -p dist && rollup src/index.js > dist/cofn-di.js","size":"rollup -p @rollup/plugin-terser src/index.js | gzip | wc -c"},"author":{"name":"Laurent RENARD"},"devDependencies":{"@cofn/core":"workspace:^","@cofn/test-lib":"workspace:*"},"keywords":["di","cofn","web","ui"],"license":"MIT","_id":"@cofn/di@0.0.3","gitHead":"35077e37762fd9ce9b93b4c16482585a3abb0015","_nodeVersion":"20.10.0","_npmVersion":"10.2.5","dist":{"integrity":"sha512-bbZzBftdIAhI4/IY34n3VWOHPoEtIlq+p6gucr8lqeTtjFJqs7JbxOEENfICxeVeZRtoEnCC7xnu4E3RqL1YBw==","shasum":"88e972c38066c2f2122f719b8a6a04c70e1d7b98","tarball":"https://registry.npmjs.org/@cofn/di/-/di-0.0.3.tgz","fileCount":3,"unpackedSize":4461,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD/DW1/eFJNiwqylhjBSxtJ6l8Z1ACP7wr4YgDCIxxiLQIhAPZlHngHJ1CNfNWuJbkA/heNCiefOOCHzRaiAS52xSj7"}]},"_npmUser":{"name":"lorenzofox3","email":"laurent34azerty@gmail.com"},"directories":{},"maintainers":[{"name":"lorenzofox3","email":"laurent34azerty@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/di_0.0.3_1711014574449_0.5914819704794143"},"_hasShrinkwrap":false}},"time":{"created":"2024-03-20T10:32:43.342Z","0.0.1":"2024-03-20T10:32:43.590Z","modified":"2024-03-21T09:49:34.997Z","0.0.2":"2024-03-20T15:09:47.734Z","0.0.3":"2024-03-21T09:49:34.574Z"},"maintainers":[{"name":"lorenzofox3","email":"laurent34azerty@gmail.com"}],"description":"DOM as DI container","keywords":["di","cofn","web","ui"],"author":{"name":"Laurent RENARD"},"license":"MIT","readme":"# DI\n\nDependency injection container which leans on the DOM\n\n## Installation \n\nyou can install the library with a package manager (like npm): \n``npm install @cofn/di``\n\nOr import it directly from a CDN\n\n```js\nimport {provide, inject} from 'https://unpkg.com/@cofn/di/dist/cofn-di.js';\n```\n\n## usage\n\n### provide\n\n``provide`` is a higher order function which takes as input either a function which returns a map of injectables or a map of injectables.\nIf it is a function it takes all as input all the dependencies of the bound generator (ie ``$host``, etc).\n\nThe map is an object whose keys are injection tokens (by name or symbol) and the values are factory functions (functions used to create an \"instance\" of that injectable) or values.\nThese factories can themselves depends on other injectables:\n\n```js\nimport {provide} from '@cofn/di';\nimport {define} from '@cofn/core';\n\nconst withAB = provide({\n  a: ({b}) => 'a' + b,\n  b: 'c'\n});\n\ndefine('some-provider', withAB(function*(){\n  \n}));\n```\n\nWhen a child element of the DOM tree is also a provider, it can override dependencies for its descendants\n\n```js\nconst withbbis = provide({\n  a: ({b}) => 'a' + b,\n  b: 'otherC'\n});\n\ndefine('some-other-provider', withAB(function*(){\n  \n}));\n```\n\n```html\n<some-provider>\n  \n<!-- any element will see injectable \"a\" as 'ac'  -->\n  <some-other-provider>\n    <!-- any element will see injectable \"a\" as 'aotherC'  -->\n  </some-other-provider>\n  \n</some-provider>\n```\n\n### inject\n\nA higher order function to declare that the component will have the map of services injected. Services are instantiated only when you call the getter related to a specific injected\n\n```js\nimport { inject } from '@cofn/di';\n\ndefine('some-el', inject(function* ({ services }) {\n\n  const { b } = services; // only b is instantiated\n  // etc\n\n}));\n```\n\n\n\n\n","readmeFilename":"readme.md"}