@adaas/a-frame 0.0.22 → 0.1.1
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/.conf/tsconfig.browser.json +13 -0
- package/.conf/tsconfig.node.json +14 -0
- package/.env.example +12 -0
- package/dist/browser/A-FrameBrowserStorageBlobs.context-OEQr85oq.d.mts +40 -0
- package/dist/browser/A-FrameBundle.types-DaaUvViw.d.mts +33 -0
- package/dist/browser/A-FrameChannel.types-DWOEUs28.d.mts +142 -0
- package/dist/browser/A-FrameDefinition.entity-DWGN_Ujr.d.mts +329 -0
- package/dist/browser/A-FrameDynamicStructure.entity-DaBgSRCR.d.mts +188 -0
- package/dist/browser/A-FrameLogger.component.env-browser-BIPAP4oQ.d.mts +112 -0
- package/dist/browser/A-FrameNamespace.entity-rCm1AavP.d.mts +125 -0
- package/dist/browser/bundle.d.mts +8 -0
- package/dist/browser/bundle.mjs +2 -0
- package/dist/browser/bundle.mjs.map +1 -0
- package/dist/browser/channel.d.mts +165 -0
- package/dist/browser/channel.mjs +3 -0
- package/dist/browser/channel.mjs.map +1 -0
- package/dist/browser/chunk-5TTVFB3G.mjs +2 -0
- package/dist/browser/chunk-5TTVFB3G.mjs.map +1 -0
- package/dist/browser/chunk-AYN7KUQT.mjs +3 -0
- package/dist/browser/chunk-AYN7KUQT.mjs.map +1 -0
- package/dist/browser/chunk-DMGQW3AO.mjs +2 -0
- package/dist/browser/chunk-DMGQW3AO.mjs.map +1 -0
- package/dist/browser/chunk-G66IL2DR.mjs +2 -0
- package/dist/browser/chunk-G66IL2DR.mjs.map +1 -0
- package/dist/browser/chunk-GOADBDTE.mjs +2 -0
- package/dist/browser/chunk-GOADBDTE.mjs.map +1 -0
- package/dist/browser/chunk-H6OZP4ZV.mjs +2 -0
- package/dist/browser/chunk-H6OZP4ZV.mjs.map +1 -0
- package/dist/browser/chunk-INS7RO3B.mjs +2 -0
- package/dist/browser/chunk-INS7RO3B.mjs.map +1 -0
- package/dist/browser/chunk-K4MZY4ME.mjs +2 -0
- package/dist/browser/chunk-K4MZY4ME.mjs.map +1 -0
- package/dist/browser/chunk-OFKV5GNB.mjs +3 -0
- package/dist/browser/chunk-OFKV5GNB.mjs.map +1 -0
- package/dist/browser/chunk-QATIN7CO.mjs +3 -0
- package/dist/browser/chunk-QATIN7CO.mjs.map +1 -0
- package/dist/browser/chunk-QBBQ37P3.mjs +2 -0
- package/dist/browser/chunk-QBBQ37P3.mjs.map +1 -0
- package/dist/browser/chunk-VDVJWU5T.mjs +2 -0
- package/dist/browser/chunk-VDVJWU5T.mjs.map +1 -0
- package/dist/browser/chunk-X3C4I6YJ.mjs +2 -0
- package/dist/browser/chunk-X3C4I6YJ.mjs.map +1 -0
- package/dist/browser/chunk-YQJFTBGV.mjs +3 -0
- package/dist/browser/chunk-YQJFTBGV.mjs.map +1 -0
- package/dist/browser/chunk-ZVCTU2DN.mjs +3 -0
- package/dist/browser/chunk-ZVCTU2DN.mjs.map +1 -0
- package/dist/browser/core.d.mts +97 -0
- package/dist/browser/core.mjs +2 -0
- package/dist/browser/core.mjs.map +1 -0
- package/dist/browser/crypto.d.mts +35 -0
- package/dist/browser/crypto.mjs +2 -0
- package/dist/browser/crypto.mjs.map +1 -0
- package/dist/browser/definition.d.mts +13 -0
- package/dist/browser/definition.mjs +2 -0
- package/dist/browser/definition.mjs.map +1 -0
- package/dist/browser/dynamic-feature.d.mts +10 -0
- package/dist/browser/dynamic-feature.mjs +2 -0
- package/dist/browser/dynamic-feature.mjs.map +1 -0
- package/dist/browser/dynamic-structure.d.mts +12 -0
- package/dist/browser/dynamic-structure.mjs +2 -0
- package/dist/browser/dynamic-structure.mjs.map +1 -0
- package/dist/browser/env.d.mts +2 -0
- package/dist/browser/env.mjs +2 -0
- package/dist/browser/env.mjs.map +1 -0
- package/dist/browser/frame-index.d.mts +95 -0
- package/dist/browser/frame-index.mjs +2 -0
- package/dist/browser/frame-index.mjs.map +1 -0
- package/dist/browser/index.browser-CZlhzfSP.d.mts +22 -0
- package/dist/browser/index.d.mts +1 -144
- package/dist/browser/index.mjs +1 -1
- package/dist/browser/index.mjs.map +1 -1
- package/dist/browser/logger.d.mts +41 -0
- package/dist/browser/logger.mjs +2 -0
- package/dist/browser/logger.mjs.map +1 -0
- package/dist/browser/namespace.d.mts +13 -0
- package/dist/browser/namespace.mjs +2 -0
- package/dist/browser/namespace.mjs.map +1 -0
- package/dist/browser/storage.d.mts +194 -0
- package/dist/browser/storage.mjs +2 -0
- package/dist/browser/storage.mjs.map +1 -0
- package/dist/browser/vector.d.mts +15 -0
- package/dist/browser/vector.mjs +2 -0
- package/dist/browser/vector.mjs.map +1 -0
- package/dist/index.cjs +0 -0
- package/dist/node/A-FrameChannel.component-BfBcs734.d.ts +62 -0
- package/dist/node/A-FrameChannel.component-NNKcFViw.d.mts +62 -0
- package/dist/node/A-FrameChannel.types-DQF-IiRq.d.mts +146 -0
- package/dist/node/A-FrameChannel.types-DQF-IiRq.d.ts +146 -0
- package/dist/node/A-FrameDefinition.entity-CAUOdEvU.d.ts +329 -0
- package/dist/node/A-FrameDefinition.entity-DWGN_Ujr.d.mts +329 -0
- package/dist/node/A-FrameDynamicStructure.entity-DaBgSRCR.d.mts +188 -0
- package/dist/node/A-FrameDynamicStructure.entity-DaBgSRCR.d.ts +188 -0
- package/dist/node/A-FrameNamespace.entity-D3fZBGDx.d.ts +125 -0
- package/dist/node/A-FrameNamespace.entity-rCm1AavP.d.mts +125 -0
- package/dist/node/A-FrameStorage.component-BYjHfHJJ.d.mts +107 -0
- package/dist/node/A-FrameStorage.component-CT01fs-t.d.ts +107 -0
- package/dist/node/bundle.cjs +101 -0
- package/dist/node/bundle.cjs.map +1 -0
- package/dist/node/bundle.d.mts +69 -0
- package/dist/node/bundle.d.ts +69 -0
- package/dist/node/bundle.mjs +76 -0
- package/dist/node/bundle.mjs.map +1 -0
- package/dist/node/channel.cjs +60 -0
- package/dist/node/channel.cjs.map +1 -0
- package/dist/node/channel.d.mts +61 -0
- package/dist/node/channel.d.ts +61 -0
- package/dist/node/channel.mjs +11 -0
- package/dist/node/channel.mjs.map +1 -0
- package/dist/node/chunk-3LOMGNWA.cjs +8 -0
- package/dist/node/chunk-3LOMGNWA.cjs.map +1 -0
- package/dist/node/chunk-3ONWH75E.mjs +257 -0
- package/dist/node/chunk-3ONWH75E.mjs.map +1 -0
- package/dist/node/chunk-3TD2PEDZ.mjs +53 -0
- package/dist/node/chunk-3TD2PEDZ.mjs.map +1 -0
- package/dist/node/chunk-442DXGOD.mjs +16 -0
- package/dist/node/chunk-442DXGOD.mjs.map +1 -0
- package/dist/node/chunk-5BKCX2RO.mjs +33 -0
- package/dist/node/chunk-5BKCX2RO.mjs.map +1 -0
- package/dist/node/chunk-6EFXNUL4.mjs +6 -0
- package/dist/node/chunk-6EFXNUL4.mjs.map +1 -0
- package/dist/node/chunk-6KAGWGTE.mjs +529 -0
- package/dist/node/chunk-6KAGWGTE.mjs.map +1 -0
- package/dist/node/chunk-7A6XGT5J.cjs +541 -0
- package/dist/node/chunk-7A6XGT5J.cjs.map +1 -0
- package/dist/node/chunk-AOQRXZPC.mjs +207 -0
- package/dist/node/chunk-AOQRXZPC.mjs.map +1 -0
- package/dist/node/chunk-APRYHBEF.mjs +171 -0
- package/dist/node/chunk-APRYHBEF.mjs.map +1 -0
- package/dist/node/chunk-B7BXP7K4.mjs +253 -0
- package/dist/node/chunk-B7BXP7K4.mjs.map +1 -0
- package/dist/node/chunk-B7ZDJXD3.cjs +35 -0
- package/dist/node/chunk-B7ZDJXD3.cjs.map +1 -0
- package/dist/node/chunk-CP6JHUU6.cjs +541 -0
- package/dist/node/chunk-CP6JHUU6.cjs.map +1 -0
- package/dist/node/chunk-DDCEMKBP.mjs +655 -0
- package/dist/node/chunk-DDCEMKBP.mjs.map +1 -0
- package/dist/node/chunk-DMY44VUG.mjs +655 -0
- package/dist/node/chunk-DMY44VUG.mjs.map +1 -0
- package/dist/node/chunk-F46TSY2K.cjs +541 -0
- package/dist/node/chunk-F46TSY2K.cjs.map +1 -0
- package/dist/node/chunk-F4UCOZW5.mjs +33 -0
- package/dist/node/chunk-F4UCOZW5.mjs.map +1 -0
- package/dist/node/chunk-GBTFMT3K.cjs +256 -0
- package/dist/node/chunk-GBTFMT3K.cjs.map +1 -0
- package/dist/node/chunk-GNVXVK2B.cjs +8 -0
- package/dist/node/chunk-GNVXVK2B.cjs.map +1 -0
- package/dist/node/chunk-GRR6NNWY.cjs +688 -0
- package/dist/node/chunk-GRR6NNWY.cjs.map +1 -0
- package/dist/node/chunk-IIVYTS5M.mjs +239 -0
- package/dist/node/chunk-IIVYTS5M.mjs.map +1 -0
- package/dist/node/chunk-JQBYDEMW.mjs +33 -0
- package/dist/node/chunk-JQBYDEMW.mjs.map +1 -0
- package/dist/node/chunk-K4MZY4ME.mjs +3 -0
- package/dist/node/chunk-K4MZY4ME.mjs.map +1 -0
- package/dist/node/chunk-KK64VLZN.cjs +4 -0
- package/dist/node/chunk-KK64VLZN.cjs.map +1 -0
- package/dist/node/chunk-KLG6HKFU.cjs +175 -0
- package/dist/node/chunk-KLG6HKFU.cjs.map +1 -0
- package/dist/node/chunk-LJIZ47HO.cjs +688 -0
- package/dist/node/chunk-LJIZ47HO.cjs.map +1 -0
- package/dist/node/chunk-NIXKAQVP.cjs +35 -0
- package/dist/node/chunk-NIXKAQVP.cjs.map +1 -0
- package/dist/node/chunk-OI76LHVT.mjs +21 -0
- package/dist/node/chunk-OI76LHVT.mjs.map +1 -0
- package/dist/node/chunk-OJGCQNAH.mjs +529 -0
- package/dist/node/chunk-OJGCQNAH.mjs.map +1 -0
- package/dist/node/chunk-OYC6L5NX.mjs +6 -0
- package/dist/node/chunk-OYC6L5NX.mjs.map +1 -0
- package/dist/node/chunk-QFHZIG7Y.cjs +25 -0
- package/dist/node/chunk-QFHZIG7Y.cjs.map +1 -0
- package/dist/node/chunk-QFUZVN4Y.cjs +259 -0
- package/dist/node/chunk-QFUZVN4Y.cjs.map +1 -0
- package/dist/node/chunk-R2H234YO.cjs +8 -0
- package/dist/node/chunk-R2H234YO.cjs.map +1 -0
- package/dist/node/chunk-RRLTGGM7.cjs +209 -0
- package/dist/node/chunk-RRLTGGM7.cjs.map +1 -0
- package/dist/node/chunk-SDKIJDMH.mjs +655 -0
- package/dist/node/chunk-SDKIJDMH.mjs.map +1 -0
- package/dist/node/chunk-TO4BPKCY.mjs +6 -0
- package/dist/node/chunk-TO4BPKCY.mjs.map +1 -0
- package/dist/node/chunk-UKKCN7CQ.cjs +688 -0
- package/dist/node/chunk-UKKCN7CQ.cjs.map +1 -0
- package/dist/node/chunk-UPA7VN4R.mjs +153 -0
- package/dist/node/chunk-UPA7VN4R.mjs.map +1 -0
- package/dist/node/chunk-UTJ7CVVB.cjs +248 -0
- package/dist/node/chunk-UTJ7CVVB.cjs.map +1 -0
- package/dist/node/chunk-XFUF7SDO.cjs +35 -0
- package/dist/node/chunk-XFUF7SDO.cjs.map +1 -0
- package/dist/node/chunk-YVX4W6SI.cjs +155 -0
- package/dist/node/chunk-YVX4W6SI.cjs.map +1 -0
- package/dist/node/chunk-YWWGJ6EJ.cjs +55 -0
- package/dist/node/chunk-YWWGJ6EJ.cjs.map +1 -0
- package/dist/node/chunk-Z4HUCRK2.mjs +529 -0
- package/dist/node/chunk-Z4HUCRK2.mjs.map +1 -0
- package/dist/node/chunk-ZM2RLVVH.cjs +18 -0
- package/dist/node/chunk-ZM2RLVVH.cjs.map +1 -0
- package/dist/node/core.cjs +259 -0
- package/dist/node/core.cjs.map +1 -0
- package/dist/node/core.d.mts +76 -0
- package/dist/node/core.d.ts +76 -0
- package/dist/node/core.mjs +248 -0
- package/dist/node/core.mjs.map +1 -0
- package/dist/node/crypto.cjs +13 -0
- package/dist/node/crypto.cjs.map +1 -0
- package/dist/node/crypto.d.mts +44 -0
- package/dist/node/crypto.d.ts +44 -0
- package/dist/node/crypto.mjs +4 -0
- package/dist/node/crypto.mjs.map +1 -0
- package/dist/node/definition.cjs +19 -0
- package/dist/node/definition.cjs.map +1 -0
- package/dist/node/definition.d.mts +13 -0
- package/dist/node/definition.d.ts +13 -0
- package/dist/node/definition.mjs +6 -0
- package/dist/node/definition.mjs.map +1 -0
- package/dist/node/dynamic-feature.cjs +14 -0
- package/dist/node/dynamic-feature.cjs.map +1 -0
- package/dist/node/dynamic-feature.d.mts +10 -0
- package/dist/node/dynamic-feature.d.ts +10 -0
- package/dist/node/dynamic-feature.mjs +12 -0
- package/dist/node/dynamic-feature.mjs.map +1 -0
- package/dist/node/dynamic-structure.cjs +143 -0
- package/dist/node/dynamic-structure.cjs.map +1 -0
- package/dist/node/dynamic-structure.d.mts +12 -0
- package/dist/node/dynamic-structure.d.ts +12 -0
- package/dist/node/dynamic-structure.mjs +138 -0
- package/dist/node/dynamic-structure.mjs.map +1 -0
- package/dist/node/env.cjs +14 -0
- package/dist/node/env.cjs.map +1 -0
- package/dist/node/env.d.mts +22 -0
- package/dist/node/env.d.ts +22 -0
- package/dist/node/env.mjs +5 -0
- package/dist/node/env.mjs.map +1 -0
- package/dist/node/frame-index.cjs +16 -0
- package/dist/node/frame-index.cjs.map +1 -0
- package/dist/node/frame-index.d.mts +95 -0
- package/dist/node/frame-index.d.ts +95 -0
- package/dist/node/frame-index.mjs +7 -0
- package/dist/node/frame-index.mjs.map +1 -0
- package/dist/node/index.cjs +0 -288
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.mts +1 -144
- package/dist/node/index.d.ts +1 -144
- package/dist/node/index.mjs +0 -284
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/logger.cjs +41 -0
- package/dist/node/logger.cjs.map +1 -0
- package/dist/node/logger.d.mts +150 -0
- package/dist/node/logger.d.ts +150 -0
- package/dist/node/logger.mjs +4 -0
- package/dist/node/logger.mjs.map +1 -0
- package/dist/node/namespace.cjs +24 -0
- package/dist/node/namespace.cjs.map +1 -0
- package/dist/node/namespace.d.mts +13 -0
- package/dist/node/namespace.d.ts +13 -0
- package/dist/node/namespace.mjs +7 -0
- package/dist/node/namespace.mjs.map +1 -0
- package/dist/node/storage.cjs +42 -0
- package/dist/node/storage.cjs.map +1 -0
- package/dist/node/storage.d.mts +110 -0
- package/dist/node/storage.d.ts +110 -0
- package/dist/node/storage.mjs +13 -0
- package/dist/node/storage.mjs.map +1 -0
- package/dist/node/vector.cjs +13 -0
- package/dist/node/vector.cjs.map +1 -0
- package/dist/node/vector.d.mts +15 -0
- package/dist/node/vector.d.ts +15 -0
- package/dist/node/vector.mjs +4 -0
- package/dist/node/vector.mjs.map +1 -0
- package/jest.config.browser.ts +41 -0
- package/jest.config.ts +18 -8
- package/package.json +125 -13
- package/{index.ts → src/concept.ts} +5 -2
- package/src/helpers/Hash.helper.ts +14 -0
- package/src/index.ts +0 -24
- package/src/lib/A-Frame/A-Frame.component.env-browser.ts +126 -0
- package/src/lib/A-Frame/A-Frame.component.env-node.ts +105 -0
- package/src/lib/A-Frame/A-Frame.component.ts +62 -0
- package/src/lib/A-Frame/A-Frame.context.ts +40 -0
- package/src/lib/{components/Index.component.ts/Index.error.ts → A-Frame/A-Frame.error.ts} +1 -1
- package/src/lib/{components/Index.component.ts/Index.guard.ts → A-Frame/A-Frame.guard.ts} +9 -6
- package/src/lib/A-Frame/A-Frame.meta.ts +27 -0
- package/src/lib/{components/Index.component.ts/Index.types.ts → A-Frame/A-Frame.types.ts} +52 -17
- package/src/lib/A-Frame/decorators/A-FrameDefine.decorator.ts +104 -0
- package/src/lib/A-Frame/decorators/A-FrameNamespace.decorator.ts +33 -0
- package/src/lib/A-Frame/index.browser.ts +10 -0
- package/src/lib/A-Frame/index.ts +10 -0
- package/src/lib/A-FrameBundle/A-FrameBundle.builder.env-node.ts +95 -0
- package/src/lib/A-FrameBundle/A-FrameBundle.constants.ts +5 -0
- package/src/lib/A-FrameBundle/A-FrameBundle.types.ts +31 -0
- package/src/lib/A-FrameBundle/index.browser.ts +6 -0
- package/src/lib/A-FrameBundle/index.ts +7 -0
- package/src/lib/A-FrameCLI/A-FrameCLI.container.ts +333 -0
- package/src/lib/A-FrameChannel/A-FrameChannel.component.env-browser.ts +63 -0
- package/src/lib/A-FrameChannel/A-FrameChannel.component.env-node.ts +586 -0
- package/src/lib/A-FrameChannel/A-FrameChannel.component.ts +273 -0
- package/src/lib/A-FrameChannel/A-FrameChannel.constants.ts +39 -0
- package/src/lib/A-FrameChannel/A-FrameChannel.error.ts +10 -0
- package/src/lib/A-FrameChannel/A-FrameChannel.types.ts +143 -0
- package/src/lib/A-FrameChannel/A-FrameChannelEvent.context.ts +28 -0
- package/src/lib/A-FrameChannel/A-FrameChannelRequest.context.ts +36 -0
- package/src/lib/A-FrameChannel/A-FrameChannelSocket.entity.ts +189 -0
- package/src/lib/A-FrameChannel/A-FrameChannelStream.entity.ts +144 -0
- package/src/lib/A-FrameChannel/index.browser.ts +3 -0
- package/src/lib/A-FrameChannel/index.ts +10 -0
- package/src/lib/A-FrameCrypto/A-FrameCrypto.component.env-browser.ts +123 -0
- package/src/lib/A-FrameCrypto/A-FrameCrypto.component.env-node.ts +204 -0
- package/src/lib/A-FrameCrypto/index.browser.ts +1 -0
- package/src/lib/A-FrameCrypto/index.ts +1 -0
- package/src/lib/A-FrameDefinition/A-FrameDefinition.constants.ts +8 -0
- package/src/lib/A-FrameDefinition/A-FrameDefinition.entity.ts +290 -0
- package/src/lib/A-FrameDefinition/A-FrameDefinition.types.ts +109 -0
- package/src/lib/A-FrameDefinition/index.ts +3 -0
- package/src/lib/A-FrameDynamicFeature/A-FrameDynamicFeature.entity.ts +13 -0
- package/src/lib/A-FrameDynamicFeature/A-FrameDynamicFeature.types.ts +10 -0
- package/src/lib/A-FrameDynamicFeature/index.ts +2 -0
- package/src/lib/A-FrameDynamicPatch/A-FrameDynamicPatch.entity.ts +38 -0
- package/src/lib/A-FrameDynamicPatch/A-FrameDynamicPatch.types.ts +20 -0
- package/src/lib/A-FrameDynamicSession/A-FrameDynamicSession.constants.ts +9 -0
- package/src/lib/A-FrameDynamicSession/A-FrameDynamicSession.entity.ts +91 -0
- package/src/lib/A-FrameDynamicSession/A-FrameDynamicSession.types.ts +18 -0
- package/src/lib/A-FrameDynamicStructure/A-FrameDynamicStructure.constants.ts +13 -0
- package/src/lib/A-FrameDynamicStructure/A-FrameDynamicStructure.entity.ts +187 -0
- package/src/lib/A-FrameDynamicStructure/A-FrameDynamicStructure.error.ts +13 -0
- package/src/lib/A-FrameDynamicStructure/A-FrameDynamicStructure.types.ts +128 -0
- package/src/lib/A-FrameDynamicStructure/A-FrameDynamicStructureOperation.context.ts +32 -0
- package/src/lib/A-FrameDynamicStructure/index.ts +5 -0
- package/src/lib/A-FrameEnv/A-FrameEnv.fragment.env-browser.ts +31 -0
- package/src/lib/A-FrameEnv/A-FrameEnv.fragment.env-node.ts +39 -0
- package/src/lib/A-FrameEnv/A-FrameEnv.types.ts +7 -0
- package/src/lib/A-FrameEnv/index.browser.ts +1 -0
- package/src/lib/A-FrameEnv/index.ts +1 -0
- package/src/lib/A-FrameIndex/A-FrameIndex.context.ts +321 -0
- package/src/lib/A-FrameIndex/A-FrameIndex.types.ts +63 -0
- package/src/lib/A-FrameIndex/index.browser.ts +3 -0
- package/src/lib/A-FrameIndex/index.ts +3 -0
- package/src/lib/A-FrameLogger/A-FrameLogger.component.env-browser.ts +99 -0
- package/src/lib/A-FrameLogger/A-FrameLogger.component.env-node.ts +129 -0
- package/src/lib/A-FrameLogger/A-FrameLogger.component.ts +123 -0
- package/src/lib/A-FrameLogger/A-FrameLogger.constants.ts +66 -0
- package/src/lib/A-FrameLogger/A-FrameLogger.types.ts +67 -0
- package/src/lib/A-FrameLogger/index.browser.ts +4 -0
- package/src/lib/A-FrameLogger/index.ts +4 -0
- package/src/lib/A-FrameNamespace/A-FrameNamespace.constants.ts +12 -0
- package/src/lib/A-FrameNamespace/A-FrameNamespace.entity.ts +211 -0
- package/src/lib/A-FrameNamespace/A-FrameNamespace.types.ts +72 -0
- package/src/lib/A-FrameNamespace/index.ts +3 -0
- package/src/lib/A-FrameStorage/A-FrameStorage.codec.ts +338 -0
- package/src/lib/A-FrameStorage/A-FrameStorage.component.ts +191 -0
- package/src/lib/A-FrameStorage/A-FrameStorage.constants.ts +11 -0
- package/src/lib/A-FrameStorage/A-FrameStorage.error.ts +13 -0
- package/src/lib/A-FrameStorage/A-FrameStorage.types.ts +98 -0
- package/src/lib/A-FrameStorage/A-FrameStorageOperation.context.ts +59 -0
- package/src/lib/A-FrameStorage/browser/A-FrameBrowserStorage.component.ts +312 -0
- package/src/lib/A-FrameStorage/browser/A-FrameBrowserStorageBlobs.context.ts +77 -0
- package/src/lib/A-FrameStorage/index.browser.ts +11 -0
- package/src/lib/A-FrameStorage/index.ts +10 -0
- package/src/lib/A-FrameStorage/node/A-FrameNodeStorage.component.ts +464 -0
- package/src/lib/A-FrameStorage/server/A-FrameServerStorage.component.ts +177 -0
- package/src/lib/{entities/A_FrameVector/A_FrameVector.entity.ts → A-FrameVector/A-FrameVector.entity.ts} +10 -0
- package/src/lib/A-FrameVector/index.ts +3 -0
- package/tests/A-Frame.browser.test.ts +94 -0
- package/tests/A-Frame.test.ts +74 -67
- package/tests/jest.browser-environment.js +30 -0
- package/tests/jest.polyfills.browser.ts +13 -0
- package/tests/jest.setup.browser.ts +33 -0
- package/tsconfig.browser.json +54 -0
- package/tsconfig.json +16 -0
- package/tsup.config.ts +32 -2
- package/src/lib/components/Builder.component.ts/Builder.component.ts +0 -0
- package/src/lib/components/Index.component.ts/Index.component.ts +0 -79
- package/src/lib/components/Index.component.ts/Index.constants.ts +0 -0
- package/src/lib/components/Index.component.ts/Index.meta.ts +0 -28
- package/src/lib/components/Index.component.ts/IndexConfigurations.meta.ts +0 -78
- package/src/lib/components/Index.component.ts/decorators/IndexComponent.decorator.ts +0 -97
- package/src/lib/components/Index.component.ts/decorators/IndexDescribe.decorator.ts +0 -59
- package/src/lib/components/Index.component.ts/decorators/IndexNamespace.decorator.ts +0 -57
- package/src/lib/components/Search/A_FrameSearch.component.ts +0 -66
- package/src/lib/containers/CLI.container.ts +0 -27
- package/src/lib/entities/Namespace/Namespace.entity.ts +0 -8
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { A_Dependency, A_Fragment, A_Scope, ASEID } from "@adaas/a-concept";
|
|
2
|
+
import { A_FrameVector } from "../A-FrameVector/A-FrameVector.entity";
|
|
3
|
+
import { A_FrameNamespace } from "../A-FrameNamespace/A-FrameNamespace.entity";
|
|
4
|
+
import { A_FrameDefinition_SearchResult, A_FrameSearchOptions } from "./A-FrameIndex.types";
|
|
5
|
+
import { A_FrameDefinition } from "../A-FrameDefinition";
|
|
6
|
+
import { A_FRAME_DEFAULT_NAMESPACE_KEY } from "../A-FrameNamespace/A-FrameNamespace.constants";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export class A_FrameIndex extends A_Fragment {
|
|
11
|
+
|
|
12
|
+
private static _instance: A_FrameIndex;
|
|
13
|
+
|
|
14
|
+
static get instance(): A_FrameIndex {
|
|
15
|
+
if (!A_FrameIndex._instance) {
|
|
16
|
+
A_FrameIndex._instance = new A_FrameIndex();
|
|
17
|
+
}
|
|
18
|
+
return A_FrameIndex._instance;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static get indexSize(): number {
|
|
22
|
+
return A_FrameIndex.instance.indexSize;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// ------------------------------------------------------------------------------------
|
|
26
|
+
// --------------------Static Access to Instance Methods-------------------------------
|
|
27
|
+
// ------------------------------------------------------------------------------------
|
|
28
|
+
static inherit(scope: A_Scope) {
|
|
29
|
+
A_FrameIndex.instance.inherit(scope);
|
|
30
|
+
}
|
|
31
|
+
static addDefinition(def: A_FrameDefinition): void {
|
|
32
|
+
A_FrameIndex.instance.addDefinition(def);
|
|
33
|
+
}
|
|
34
|
+
static getDefinition(nameOrHash: string): A_FrameDefinition | undefined {
|
|
35
|
+
return A_FrameIndex.instance.getDefinition(nameOrHash);
|
|
36
|
+
}
|
|
37
|
+
static listDefinitions(filter: {
|
|
38
|
+
namespace?: string | A_FrameNamespace
|
|
39
|
+
}): A_FrameDefinition[] {
|
|
40
|
+
return A_FrameIndex.instance.listDefinitions(filter);
|
|
41
|
+
}
|
|
42
|
+
static removeDefinition(def: A_FrameDefinition): void {
|
|
43
|
+
A_FrameIndex.instance.removeDefinition(def);
|
|
44
|
+
}
|
|
45
|
+
static addNamespace(namespace: A_FrameNamespace): void {
|
|
46
|
+
A_FrameIndex.instance.addNamespace(namespace);
|
|
47
|
+
}
|
|
48
|
+
static getDefaultNamespace(): A_FrameNamespace {
|
|
49
|
+
return A_FrameIndex.instance.getDefaultNamespace();
|
|
50
|
+
}
|
|
51
|
+
static getNamespace(nameOrASEID: string | ASEID): A_FrameNamespace | undefined {
|
|
52
|
+
return A_FrameIndex.instance.getNamespace(nameOrASEID);
|
|
53
|
+
}
|
|
54
|
+
static listNamespaces(): A_FrameNamespace[] {
|
|
55
|
+
return A_FrameIndex.instance.listNamespaces();
|
|
56
|
+
}
|
|
57
|
+
static removeNamespace(namespace: A_FrameNamespace): void {
|
|
58
|
+
A_FrameIndex.instance.removeNamespace(namespace);
|
|
59
|
+
}
|
|
60
|
+
static search(
|
|
61
|
+
vector: A_FrameVector,
|
|
62
|
+
options: A_FrameSearchOptions = {},
|
|
63
|
+
): A_FrameDefinition_SearchResult[] {
|
|
64
|
+
return A_FrameIndex.instance.search(vector, options);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// -------------------------------------------------------------------------------------
|
|
68
|
+
// ------------------------------ Instance State --------------------------------------
|
|
69
|
+
// -------------------------------------------------------------------------------------
|
|
70
|
+
|
|
71
|
+
private definitions: Map<string, A_FrameDefinition> = new Map();
|
|
72
|
+
|
|
73
|
+
private namespaces: Map<string, A_FrameNamespace> = new Map();
|
|
74
|
+
|
|
75
|
+
private _index!: {
|
|
76
|
+
|
|
77
|
+
namespaceToDefinitions: WeakMap<A_FrameNamespace, Set<A_FrameDefinition>>,
|
|
78
|
+
|
|
79
|
+
definitionToNamespace: WeakMap<A_FrameDefinition, A_FrameNamespace>,
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Scope where all definitions and namespaces are registered as dependencies, allowing for lookup by ASEID or constructor reference.
|
|
83
|
+
*/
|
|
84
|
+
private scope!: A_Scope
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
constructor() {
|
|
88
|
+
if (A_FrameIndex._instance)
|
|
89
|
+
return A_FrameIndex._instance;
|
|
90
|
+
|
|
91
|
+
super({ name: 'A_FrameIndex' });
|
|
92
|
+
|
|
93
|
+
this.scope = new A_Scope({ name: 'A_FrameIndexScope' });
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Number of loaded records */
|
|
97
|
+
get indexSize(): number {
|
|
98
|
+
return this.definitions.size;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
// static searchByText(
|
|
103
|
+
// query: string,
|
|
104
|
+
// channel: A_FrameChannel,
|
|
105
|
+
// options: A_FrameSearchOptions = {},
|
|
106
|
+
// ): Promise<A_FrameDefinition_SearchResult[]> {
|
|
107
|
+
// return A_FrameIndex.instance.searchByText(query, channel, options);
|
|
108
|
+
// }
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
// ------------------------------------------------------------------------------------
|
|
112
|
+
// ------------------------------ Instance Methods ------------------------------------
|
|
113
|
+
// ------------------------------------------------------------------------------------
|
|
114
|
+
inherit(scope: A_Scope) {
|
|
115
|
+
this.scope.inherit(scope);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
addDefinition(def: A_FrameDefinition): void {
|
|
119
|
+
this.scope.register(def);
|
|
120
|
+
|
|
121
|
+
const existingNamespace = this.namespaces.get(def.namespace.id);
|
|
122
|
+
if (!existingNamespace) {
|
|
123
|
+
this.addNamespace(def.namespace);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
this.definitions.set(def.id, def);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
getDefinition(name: string): A_FrameDefinition | undefined {
|
|
130
|
+
// Then try name lookup
|
|
131
|
+
for (const def of this.definitions.values()) {
|
|
132
|
+
if (def.name === name) {
|
|
133
|
+
return def;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
listDefinitions(filter: {
|
|
141
|
+
namespace?: string | A_FrameNamespace
|
|
142
|
+
} = {}): A_FrameDefinition[] {
|
|
143
|
+
const namespaceName = filter.namespace
|
|
144
|
+
? typeof filter.namespace === 'string'
|
|
145
|
+
? ASEID.isASEID(filter.namespace)
|
|
146
|
+
? new ASEID(filter.namespace).id
|
|
147
|
+
: filter.namespace
|
|
148
|
+
: filter.namespace.id
|
|
149
|
+
: undefined;
|
|
150
|
+
|
|
151
|
+
return [...this.definitions.values()].filter(r => !namespaceName || r.namespace.name === namespaceName);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
removeDefinition(def: A_FrameDefinition): void {
|
|
155
|
+
this.scope.deregister(def);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
addNamespace(namespace: A_FrameNamespace): void {
|
|
159
|
+
this.scope.register(namespace);
|
|
160
|
+
|
|
161
|
+
this.namespaces.set(namespace.id, namespace);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
getNamespace(nameOrASEID: string | ASEID): A_FrameNamespace | undefined {
|
|
165
|
+
const targetKey = typeof nameOrASEID === 'string'
|
|
166
|
+
? ASEID.isASEID(nameOrASEID)
|
|
167
|
+
? new ASEID(nameOrASEID).id
|
|
168
|
+
: nameOrASEID
|
|
169
|
+
: nameOrASEID.id;
|
|
170
|
+
|
|
171
|
+
return this.namespaces.get(targetKey);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
getDefaultNamespace(): A_FrameNamespace {
|
|
175
|
+
// Ensure default namespace always exists
|
|
176
|
+
let defaultNamespace = this.getNamespace(A_FRAME_DEFAULT_NAMESPACE_KEY);
|
|
177
|
+
if (!defaultNamespace) {
|
|
178
|
+
defaultNamespace = new A_FrameNamespace({
|
|
179
|
+
name: A_FRAME_DEFAULT_NAMESPACE_KEY,
|
|
180
|
+
});
|
|
181
|
+
this.addNamespace(defaultNamespace);
|
|
182
|
+
}
|
|
183
|
+
return defaultNamespace;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
listNamespaces(): A_FrameNamespace[] {
|
|
187
|
+
return [...this.namespaces.values()];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
removeNamespace(namespace: A_FrameNamespace): void {
|
|
191
|
+
this.scope.deregister(namespace);
|
|
192
|
+
this.namespaces.delete(namespace.id);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Search by a pre-computed embedding vector (cosine similarity).
|
|
198
|
+
*/
|
|
199
|
+
search(
|
|
200
|
+
vector: A_FrameVector,
|
|
201
|
+
options: A_FrameSearchOptions = {},
|
|
202
|
+
): A_FrameDefinition_SearchResult[] {
|
|
203
|
+
|
|
204
|
+
const { topK = 10, namespace, minScore = 0 } = options;
|
|
205
|
+
|
|
206
|
+
const pool = namespace
|
|
207
|
+
? [...this.definitions.values()].filter(r => r.namespace.id === namespace)
|
|
208
|
+
: [...this.definitions.values()];
|
|
209
|
+
|
|
210
|
+
const scored = pool.map(r => ({
|
|
211
|
+
record: r,
|
|
212
|
+
score: this.cosineSimilarity(vector, r.vector),
|
|
213
|
+
}));
|
|
214
|
+
|
|
215
|
+
return scored
|
|
216
|
+
.filter(s => s.score >= minScore)
|
|
217
|
+
.sort((a, b) => b.score - a.score)
|
|
218
|
+
.slice(0, topK)
|
|
219
|
+
.map(({ record: r, score }) => ({
|
|
220
|
+
record: r,
|
|
221
|
+
score,
|
|
222
|
+
}));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// protected cosineSimilarity(vectorA: A_FrameVector, vectorB?: A_FrameVector): number {
|
|
226
|
+
// const a = vectorA.values ?? new Float32Array();
|
|
227
|
+
// const b = vectorB?.values ?? new Float32Array();
|
|
228
|
+
|
|
229
|
+
// if (a.length !== b.length) {
|
|
230
|
+
// throw new Error(`A_FrameIndex: dimension mismatch ${a.length} vs ${b.length}`);
|
|
231
|
+
// }
|
|
232
|
+
// let dot = 0, normA = 0, normB = 0;
|
|
233
|
+
// for (let i = 0; i < a.length; i++) {
|
|
234
|
+
// dot += a[i] * b[i];
|
|
235
|
+
// normA += a[i] * a[i];
|
|
236
|
+
// normB += b[i] * b[i];
|
|
237
|
+
// }
|
|
238
|
+
// const denom = Math.sqrt(normA) * Math.sqrt(normB);
|
|
239
|
+
// return denom === 0 ? 0 : dot / denom;
|
|
240
|
+
// }
|
|
241
|
+
|
|
242
|
+
cosineSimilarity(
|
|
243
|
+
a: A_FrameVector,
|
|
244
|
+
b?: A_FrameVector
|
|
245
|
+
): number {
|
|
246
|
+
if (!b) return 0
|
|
247
|
+
|
|
248
|
+
const dot = a.dot(b)
|
|
249
|
+
const mag = a.magnitude() * b.magnitude()
|
|
250
|
+
return mag === 0 ? 0 : dot / mag
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
euclideanDistance(
|
|
254
|
+
a: A_FrameVector,
|
|
255
|
+
b: A_FrameVector
|
|
256
|
+
): number {
|
|
257
|
+
this.assertSameLength(a, b)
|
|
258
|
+
|
|
259
|
+
let sum = 0
|
|
260
|
+
for (let i = 0; i < a.length; i++) {
|
|
261
|
+
const diff = a.values[i] - b.values[i]
|
|
262
|
+
sum += diff * diff
|
|
263
|
+
}
|
|
264
|
+
return Math.sqrt(sum)
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
nearest(
|
|
268
|
+
query: A_FrameVector,
|
|
269
|
+
vectors: readonly A_FrameVector[],
|
|
270
|
+
limit = 1
|
|
271
|
+
): A_FrameVector[] {
|
|
272
|
+
return [...vectors]
|
|
273
|
+
.map(v => ({
|
|
274
|
+
vector: v,
|
|
275
|
+
score: this.cosineSimilarity(query, v),
|
|
276
|
+
}))
|
|
277
|
+
.sort((a, b) => b.score - a.score)
|
|
278
|
+
.slice(0, limit)
|
|
279
|
+
.map(r => r.vector)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
rank(
|
|
283
|
+
query: A_FrameVector,
|
|
284
|
+
vectors: readonly A_FrameVector[]
|
|
285
|
+
): Array<{ vector: A_FrameVector; score: number }> {
|
|
286
|
+
return vectors
|
|
287
|
+
.map(v => ({
|
|
288
|
+
vector: v,
|
|
289
|
+
score: this.cosineSimilarity(query, v),
|
|
290
|
+
}))
|
|
291
|
+
.sort((a, b) => b.score - a.score)
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
private assertSameLength(
|
|
295
|
+
a: A_FrameVector,
|
|
296
|
+
b: A_FrameVector
|
|
297
|
+
) {
|
|
298
|
+
if (a.length !== b.length) {
|
|
299
|
+
throw new Error(
|
|
300
|
+
`Embedding dimension mismatch: ${a.length} vs ${b.length}`
|
|
301
|
+
)
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Search by plain text — sends the query to the embed server via channel first.
|
|
309
|
+
*/
|
|
310
|
+
// async searchByText(
|
|
311
|
+
// query: string,
|
|
312
|
+
// channel: A_FrameChannel,
|
|
313
|
+
// options: A_FrameSearchOptions = {},
|
|
314
|
+
// ): Promise<A_FrameDefinition_SearchResult[]> {
|
|
315
|
+
// this.assertLoaded();
|
|
316
|
+
// const resp = await channel.embed(query);
|
|
317
|
+
// const queryEmbedding = new Float32Array(resp.data[0].embedding);
|
|
318
|
+
// return this.search(queryEmbedding, options);
|
|
319
|
+
// }
|
|
320
|
+
|
|
321
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { A_Component, A_Container, A_Entity, A_Fragment, A_TYPES__Component_Constructor, A_TYPES__Container_Constructor, A_TYPES__Entity_Constructor, A_TYPES__Fragment_Constructor, A_TYPES__Required } from "@adaas/a-concept"
|
|
2
|
+
import { A_FrameTargetType } from "../A-Frame/A-Frame.types"
|
|
3
|
+
import { A_FrameNamespace } from "../A-FrameNamespace"
|
|
4
|
+
import { A_FrameDefinition } from "../A-FrameDefinition"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export type A_FrameIndexTarget = A_TYPES__Container_Constructor
|
|
9
|
+
| A_TYPES__Entity_Constructor
|
|
10
|
+
| A_TYPES__Component_Constructor
|
|
11
|
+
| A_TYPES__Fragment_Constructor
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
// ------------- A-Frame Index Configurations Meta Types----------------------
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
export type A_FrameMetaDefinition<T extends Record<string, any> = {}> = {
|
|
19
|
+
name: string,
|
|
20
|
+
hash: string,
|
|
21
|
+
source: string,
|
|
22
|
+
type: A_FrameTargetType,
|
|
23
|
+
namespace?: string | A_FrameNamespace,
|
|
24
|
+
description?: string,
|
|
25
|
+
metadata?: T,
|
|
26
|
+
examples?: string[]
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
export type A_FrameIndexMetaType = {
|
|
31
|
+
namespaces: string,
|
|
32
|
+
descriptions: string,
|
|
33
|
+
type: string,
|
|
34
|
+
name: string,
|
|
35
|
+
methods: Map<string, A_FrameIndexMetaMethodMeta>
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
export type A_FrameIndexMetaMethodMeta = {
|
|
40
|
+
name: string,
|
|
41
|
+
description?: string,
|
|
42
|
+
methodName: string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
// ---------------------------------------------------------------------------
|
|
47
|
+
// ------------- A-Frame Runtime Search Types --------------------------------
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
|
|
50
|
+
export type A_FrameSearchOptions = {
|
|
51
|
+
/** Maximum number of results; default 10 */
|
|
52
|
+
topK?: number
|
|
53
|
+
/** Restrict search to a single namespace; undefined = all */
|
|
54
|
+
namespace?: string
|
|
55
|
+
/** Minimum cosine similarity score (0–1); default 0 */
|
|
56
|
+
minScore?: number
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
export type A_FrameDefinition_SearchResult = {
|
|
61
|
+
record: A_FrameDefinition,
|
|
62
|
+
score: number
|
|
63
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { A_FrameLoggerBase } from "./A-FrameLogger.component";
|
|
2
|
+
import {
|
|
3
|
+
A_FrameLogEntry,
|
|
4
|
+
A_FrameLogLevelType,
|
|
5
|
+
A_FrameLoggerConfig,
|
|
6
|
+
A_FrameProgressBar,
|
|
7
|
+
} from "./A-FrameLogger.types";
|
|
8
|
+
import {
|
|
9
|
+
A_FRAME_BROWSER_CSS,
|
|
10
|
+
A_FRAME_LOG_DEFAULTS,
|
|
11
|
+
A_FrameLogIcon,
|
|
12
|
+
} from "./A-FrameLogger.constants";
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A_FrameLogger — Browser environment.
|
|
17
|
+
*
|
|
18
|
+
* Renders to the DevTools console using `%c` CSS styling. Progress is shown
|
|
19
|
+
* via throttled console lines (no in-place redraw available in the browser).
|
|
20
|
+
*/
|
|
21
|
+
export class A_FrameLogger extends A_FrameLoggerBase {
|
|
22
|
+
|
|
23
|
+
constructor(config: A_FrameLoggerConfig = {}) {
|
|
24
|
+
super(config);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
protected write(entry: A_FrameLogEntry): void {
|
|
28
|
+
const icon = A_FrameLogIcon[entry.level];
|
|
29
|
+
const css = A_FRAME_BROWSER_CSS[entry.level];
|
|
30
|
+
const fn: (...args: unknown[]) => void =
|
|
31
|
+
entry.level === 'error' ? console.error
|
|
32
|
+
: entry.level === 'warn' ? console.warn
|
|
33
|
+
: console.log;
|
|
34
|
+
|
|
35
|
+
if (entry.metadata && Object.keys(entry.metadata).length > 0) {
|
|
36
|
+
fn(`%c${icon} ${entry.message}`, css, entry.metadata);
|
|
37
|
+
} else {
|
|
38
|
+
fn(`%c${icon} ${entry.message}`, css);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
section(title: string): void {
|
|
43
|
+
console.log(`%c┄ ${title} ┄`, 'color: #06b; font-weight: bold; padding: 2px 0;');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
divider(): void {
|
|
47
|
+
console.log('%c────────────────────────────────────────', 'color: #aaa;');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
summary(title: string = A_FRAME_LOG_DEFAULTS.summaryTitle): void {
|
|
51
|
+
this.section(title);
|
|
52
|
+
const obj: Record<string, number | string> = {};
|
|
53
|
+
for (const [k, v] of this.counters) obj[k] = v;
|
|
54
|
+
obj.elapsed = this.elapsed();
|
|
55
|
+
// console.table is universally supported and renders much nicer than
|
|
56
|
+
// line-by-line in the browser DevTools.
|
|
57
|
+
console.table(obj);
|
|
58
|
+
this.divider();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// ─── Progress bar ────────────────────────────────────────────────────────
|
|
62
|
+
|
|
63
|
+
progress(label: string, total: number): A_FrameProgressBar {
|
|
64
|
+
const start = Date.now();
|
|
65
|
+
let current = 0;
|
|
66
|
+
let lastLabel = '';
|
|
67
|
+
let lastEmit = 0;
|
|
68
|
+
|
|
69
|
+
const emit = (force = false, status?: 'done' | 'fail') => {
|
|
70
|
+
const now = Date.now();
|
|
71
|
+
if (!force && now - lastEmit < A_FRAME_LOG_DEFAULTS.progressThrottleMs) return;
|
|
72
|
+
lastEmit = now;
|
|
73
|
+
|
|
74
|
+
const pct = total > 0 ? Math.min(100, Math.round((current / total) * 100)) : 100;
|
|
75
|
+
const tail = lastLabel ? ` — ${lastLabel}` : '';
|
|
76
|
+
|
|
77
|
+
if (status === 'done') {
|
|
78
|
+
console.log(
|
|
79
|
+
`%c✔ ${label} ${current}/${total} (${pct}%)%c — ${((now - start) / 1000).toFixed(2)}s`,
|
|
80
|
+
A_FRAME_BROWSER_CSS.success,
|
|
81
|
+
'color: #888;',
|
|
82
|
+
);
|
|
83
|
+
} else if (status === 'fail') {
|
|
84
|
+
console.log(`%c✖ ${label} FAILED at ${current}/${total}`, A_FRAME_BROWSER_CSS.error);
|
|
85
|
+
} else {
|
|
86
|
+
console.log(`%c⟳ ${label} ${current}/${total} (${pct}%)${tail}`, A_FRAME_BROWSER_CSS.info);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
emit(true);
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
tick: (l?: string) => { current = Math.min(total, current + 1); if (l) lastLabel = l; emit(); },
|
|
94
|
+
succeed: (l?: string) => { if (l) lastLabel = l; current = total; emit(true, 'done'); },
|
|
95
|
+
fail: (l?: string) => { if (l) lastLabel = l; emit(true, 'fail'); },
|
|
96
|
+
update: (n: number, l?: string) => { current = Math.min(total, Math.max(0, n)); if (l) lastLabel = l; emit(); },
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { A_FrameLoggerBase } from "./A-FrameLogger.component";
|
|
2
|
+
import {
|
|
3
|
+
A_FrameLogEntry,
|
|
4
|
+
A_FrameLogLevelType,
|
|
5
|
+
A_FrameLoggerConfig,
|
|
6
|
+
A_FrameProgressBar,
|
|
7
|
+
} from "./A-FrameLogger.types";
|
|
8
|
+
import {
|
|
9
|
+
A_FRAME_ANSI,
|
|
10
|
+
A_FRAME_LOG_DEFAULTS,
|
|
11
|
+
A_FrameLogIcon,
|
|
12
|
+
} from "./A-FrameLogger.constants";
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/** Map a level → ANSI colour code for its leading icon. */
|
|
16
|
+
const ICON_COLOR: Record<A_FrameLogLevelType, string> = {
|
|
17
|
+
debug: A_FRAME_ANSI.gray,
|
|
18
|
+
info: A_FRAME_ANSI.cyan,
|
|
19
|
+
success: A_FRAME_ANSI.green,
|
|
20
|
+
warn: A_FRAME_ANSI.yellow,
|
|
21
|
+
error: A_FRAME_ANSI.red,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A_FrameLogger — Node.js environment.
|
|
27
|
+
*
|
|
28
|
+
* Renders to stdout with ANSI colour codes and inline progress bars when
|
|
29
|
+
* stdout is a TTY. Falls back to plain text otherwise (CI, log files).
|
|
30
|
+
*/
|
|
31
|
+
export class A_FrameLogger extends A_FrameLoggerBase {
|
|
32
|
+
|
|
33
|
+
private readonly useColor: boolean;
|
|
34
|
+
|
|
35
|
+
constructor(config: A_FrameLoggerConfig = {}) {
|
|
36
|
+
super(config);
|
|
37
|
+
this.useColor = config.color ?? !!(process.stdout && process.stdout.isTTY);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private c(code: string, str: string): string {
|
|
41
|
+
return this.useColor ? `${code}${str}${A_FRAME_ANSI.reset}` : str;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
protected write(entry: A_FrameLogEntry): void {
|
|
45
|
+
const icon = this.c(ICON_COLOR[entry.level], A_FrameLogIcon[entry.level]);
|
|
46
|
+
const line = `${icon} ${entry.message}`;
|
|
47
|
+
if (entry.level === 'error') console.error(line);
|
|
48
|
+
else if (entry.level === 'warn') console.warn(line);
|
|
49
|
+
else console.log(line);
|
|
50
|
+
|
|
51
|
+
if (entry.metadata && Object.keys(entry.metadata).length > 0) {
|
|
52
|
+
console.log(this.c(A_FRAME_ANSI.gray, ` ${JSON.stringify(entry.metadata)}`));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
section(title: string): void {
|
|
57
|
+
const line = '─'.repeat(Math.max(2, 60 - title.length - 4));
|
|
58
|
+
const heading = `┄ ${title} ${line}`;
|
|
59
|
+
console.log('\n' + this.c(A_FRAME_ANSI.bold + A_FRAME_ANSI.cyan, heading));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
divider(): void {
|
|
63
|
+
console.log(this.c(A_FRAME_ANSI.gray, '─'.repeat(60)));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
summary(title: string = A_FRAME_LOG_DEFAULTS.summaryTitle): void {
|
|
67
|
+
this.section(title);
|
|
68
|
+
const keys = [...this.counters.keys()];
|
|
69
|
+
const pad = keys.reduce((m, k) => Math.max(m, k.length), 'elapsed'.length);
|
|
70
|
+
for (const key of keys) {
|
|
71
|
+
console.log(` ${this.c(A_FRAME_ANSI.gray, key.padEnd(pad))} ${this.c(A_FRAME_ANSI.bold, String(this.counters.get(key)))}`);
|
|
72
|
+
}
|
|
73
|
+
console.log(` ${this.c(A_FRAME_ANSI.gray, 'elapsed'.padEnd(pad))} ${this.c(A_FRAME_ANSI.bold, this.elapsed())}`);
|
|
74
|
+
this.divider();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ─── Progress bar ────────────────────────────────────────────────────────
|
|
78
|
+
|
|
79
|
+
progress(label: string, total: number): A_FrameProgressBar {
|
|
80
|
+
const isTTY = this.useColor; // colour ⟺ TTY by default
|
|
81
|
+
const width = A_FRAME_LOG_DEFAULTS.progressBarWidth;
|
|
82
|
+
const start = Date.now();
|
|
83
|
+
|
|
84
|
+
let current = 0;
|
|
85
|
+
let lastLabel = '';
|
|
86
|
+
|
|
87
|
+
const render = (status?: 'done' | 'fail') => {
|
|
88
|
+
if (total === 0) {
|
|
89
|
+
if (status === 'done') console.log(`${this.c(A_FRAME_ANSI.green, '✔')} ${label} (0/0)`);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const pct = Math.min(1, current / total);
|
|
93
|
+
const filled = Math.round(pct * width);
|
|
94
|
+
|
|
95
|
+
if (isTTY) {
|
|
96
|
+
const bar =
|
|
97
|
+
this.c(A_FRAME_ANSI.green, '█'.repeat(filled)) +
|
|
98
|
+
this.c(A_FRAME_ANSI.gray, '░'.repeat(width - filled));
|
|
99
|
+
const head = status === 'done' ? this.c(A_FRAME_ANSI.green, '✔')
|
|
100
|
+
: status === 'fail' ? this.c(A_FRAME_ANSI.red, '✖')
|
|
101
|
+
: this.c(A_FRAME_ANSI.cyan, '⟳');
|
|
102
|
+
const tail = lastLabel ? this.c(A_FRAME_ANSI.dim, ` — ${lastLabel}`) : '';
|
|
103
|
+
process.stdout.write(`\r\x1b[2K${head} ${label} ${bar} ${current}/${total} (${(pct * 100).toFixed(0)}%)${tail}`);
|
|
104
|
+
if (status) process.stdout.write('\n');
|
|
105
|
+
} else {
|
|
106
|
+
if (status === 'done') {
|
|
107
|
+
console.log(`[${label}] done ${current}/${total} in ${((Date.now() - start) / 1000).toFixed(2)}s`);
|
|
108
|
+
} else if (status === 'fail') {
|
|
109
|
+
console.log(`[${label}] FAILED at ${current}/${total}`);
|
|
110
|
+
} else {
|
|
111
|
+
// Throttle: only print at 10% boundaries when not on a TTY
|
|
112
|
+
const step = Math.max(1, Math.floor(total / 10));
|
|
113
|
+
if (current === total || current % step === 0) {
|
|
114
|
+
console.log(`[${label}] ${current}/${total}${lastLabel ? ` — ${lastLabel}` : ''}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
render();
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
tick: (l?: string) => { current = Math.min(total, current + 1); if (l) lastLabel = l; render(); },
|
|
124
|
+
succeed: (l?: string) => { if (l) lastLabel = l; current = total; render('done'); },
|
|
125
|
+
fail: (l?: string) => { if (l) lastLabel = l; render('fail'); },
|
|
126
|
+
update: (n: number, l?: string) => { current = Math.min(total, Math.max(0, n)); if (l) lastLabel = l; render(); },
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|