@sima-land/isomorph 11.0.0-alpha.36 → 11.0.0-alpha.37
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/LICENSE +201 -0
- package/README.md +25 -0
- package/dist/cjs/cache/index.js +6 -0
- package/dist/cjs/cache/index.js.map +1 -0
- package/dist/cjs/cache/types.js +6 -0
- package/dist/cjs/cache/types.js.map +1 -0
- package/dist/cjs/config/base.js +22 -0
- package/dist/cjs/config/base.js.map +1 -0
- package/dist/cjs/config/index.js +20 -0
- package/dist/cjs/config/index.js.map +1 -0
- package/dist/cjs/config/source.js +25 -0
- package/dist/cjs/config/source.js.map +1 -0
- package/dist/cjs/config/types.js +6 -0
- package/dist/cjs/config/types.js.map +1 -0
- package/dist/cjs/di/application.js +106 -0
- package/dist/cjs/di/application.js.map +1 -0
- package/dist/cjs/di/container.js +55 -0
- package/dist/cjs/di/container.js.map +1 -0
- package/dist/cjs/di/errors.js +65 -0
- package/dist/cjs/di/errors.js.map +1 -0
- package/dist/cjs/di/index.js +59 -0
- package/dist/cjs/di/index.js.map +1 -0
- package/dist/cjs/di/preset.js +32 -0
- package/dist/cjs/di/preset.js.map +1 -0
- package/dist/cjs/di/token.js +44 -0
- package/dist/cjs/di/token.js.map +1 -0
- package/dist/cjs/di/types.js +6 -0
- package/dist/cjs/di/types.js.map +1 -0
- package/dist/cjs/http/errors.js +47 -0
- package/dist/cjs/http/errors.js.map +1 -0
- package/dist/cjs/http/index.js +63 -0
- package/dist/cjs/http/index.js.map +1 -0
- package/dist/cjs/http/types.js +6 -0
- package/dist/cjs/http/types.js.map +1 -0
- package/dist/cjs/log/errors.js +35 -0
- package/dist/cjs/log/errors.js.map +1 -0
- package/dist/cjs/log/handler/pino.js +31 -0
- package/dist/cjs/log/handler/pino.js.map +1 -0
- package/dist/cjs/log/handler/sentry.js +57 -0
- package/dist/cjs/log/handler/sentry.js.map +1 -0
- package/dist/cjs/log/index.js +26 -0
- package/dist/cjs/log/index.js.map +1 -0
- package/dist/cjs/log/logger.js +35 -0
- package/dist/cjs/log/logger.js.map +1 -0
- package/dist/cjs/log/types.js +6 -0
- package/dist/cjs/log/types.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/preset/isomorphic/constants.js +14 -0
- package/dist/cjs/preset/isomorphic/constants.js.map +1 -0
- package/{preset → dist/cjs/preset}/isomorphic/providers/index.js +19 -15
- package/dist/cjs/preset/isomorphic/providers/index.js.map +1 -0
- package/dist/cjs/preset/isomorphic/types.js +6 -0
- package/dist/cjs/preset/isomorphic/types.js.map +1 -0
- package/dist/cjs/preset/isomorphic/utils/index.js +322 -0
- package/dist/cjs/preset/isomorphic/utils/index.js.map +1 -0
- package/dist/cjs/preset/node/handler/index.js +52 -0
- package/dist/cjs/preset/node/handler/index.js.map +1 -0
- package/dist/cjs/preset/node/handler/providers/index.js +212 -0
- package/dist/cjs/preset/node/handler/providers/index.js.map +1 -0
- package/dist/cjs/preset/node/handler/utils/index.js +132 -0
- package/dist/cjs/preset/node/handler/utils/index.js.map +1 -0
- package/dist/cjs/preset/node/index.js +26 -0
- package/dist/cjs/preset/node/index.js.map +1 -0
- package/dist/cjs/preset/node/node/index.js +61 -0
- package/dist/cjs/preset/node/node/index.js.map +1 -0
- package/dist/cjs/preset/node/node/providers/index.js +403 -0
- package/dist/cjs/preset/node/node/providers/index.js.map +1 -0
- package/dist/cjs/preset/node/node/utils/http-client/index.js +122 -0
- package/dist/cjs/preset/node/node/utils/http-client/index.js.map +1 -0
- package/dist/cjs/preset/node/node/utils/http-server/index.js +18 -0
- package/dist/cjs/preset/node/node/utils/http-server/index.js.map +1 -0
- package/dist/cjs/preset/node/node/utils/index.js +20 -0
- package/dist/cjs/preset/node/node/utils/index.js.map +1 -0
- package/dist/cjs/preset/web/index.js +34 -0
- package/dist/cjs/preset/web/index.js.map +1 -0
- package/dist/cjs/preset/web/providers/index.js +94 -0
- package/dist/cjs/preset/web/providers/index.js.map +1 -0
- package/dist/cjs/tokens.js +86 -0
- package/dist/cjs/tokens.js.map +1 -0
- package/dist/cjs/utils/axios/index.js +40 -0
- package/dist/cjs/utils/axios/index.js.map +1 -0
- package/dist/cjs/utils/axios/middleware/cookie.js +28 -0
- package/dist/cjs/utils/axios/middleware/cookie.js.map +1 -0
- package/dist/cjs/utils/axios/middleware/log.js +37 -0
- package/dist/cjs/utils/axios/middleware/log.js.map +1 -0
- package/dist/cjs/utils/axios/sauce/index.js +57 -0
- package/dist/cjs/utils/axios/sauce/index.js.map +1 -0
- package/{utils → dist/cjs/utils}/axios/utils/index.js +19 -14
- package/dist/cjs/utils/axios/utils/index.js.map +1 -0
- package/{utils → dist/cjs/utils}/express/handler/health-check.js +11 -7
- package/dist/cjs/utils/express/handler/health-check.js.map +1 -0
- package/dist/cjs/utils/express/index.js +20 -0
- package/dist/cjs/utils/express/index.js.map +1 -0
- package/dist/cjs/utils/express/utils/index.js +22 -0
- package/dist/cjs/utils/express/utils/index.js.map +1 -0
- package/dist/cjs/utils/function.js +44 -0
- package/dist/cjs/utils/function.js.map +1 -0
- package/dist/cjs/utils/index.js +20 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/{utils/number.js → dist/cjs/utils/math.js} +7 -5
- package/dist/cjs/utils/math.js.map +1 -0
- package/dist/cjs/utils/react/error-handlers/index.js +80 -0
- package/dist/cjs/utils/react/error-handlers/index.js.map +1 -0
- package/dist/cjs/utils/react/index.js +19 -0
- package/dist/cjs/utils/react/index.js.map +1 -0
- package/dist/cjs/utils/redux/index.js +19 -0
- package/dist/cjs/utils/redux/index.js.map +1 -0
- package/dist/cjs/utils/redux/remote-data.js +118 -0
- package/dist/cjs/utils/redux/remote-data.js.map +1 -0
- package/dist/cjs/utils/redux-saga/index.js +20 -0
- package/dist/cjs/utils/redux-saga/index.js.map +1 -0
- package/dist/cjs/utils/redux-saga/middleware.js +149 -0
- package/dist/cjs/utils/redux-saga/middleware.js.map +1 -0
- package/dist/cjs/utils/redux-saga/take-chain.js +66 -0
- package/dist/cjs/utils/redux-saga/take-chain.js.map +1 -0
- package/dist/cjs/utils/redux-saga/types.js +6 -0
- package/dist/cjs/utils/redux-saga/types.js.map +1 -0
- package/dist/cjs/utils/ssr/index.js +73 -0
- package/dist/cjs/utils/ssr/index.js.map +1 -0
- package/dist/cjs/utils/web/analytics/data-layer.js +20 -0
- package/dist/cjs/utils/web/analytics/data-layer.js.map +1 -0
- package/dist/cjs/utils/web/analytics/index.js +20 -0
- package/dist/cjs/utils/web/analytics/index.js.map +1 -0
- package/dist/cjs/utils/web/analytics/oko.js +20 -0
- package/dist/cjs/utils/web/analytics/oko.js.map +1 -0
- package/dist/cjs/utils/web/storage/index.js +75 -0
- package/dist/cjs/utils/web/storage/index.js.map +1 -0
- package/dist/cjs/utils/webpack/env/index.js +96 -0
- package/dist/cjs/utils/webpack/env/index.js.map +1 -0
- package/dist/cjs/utils/webpack/env/types.js +6 -0
- package/dist/cjs/utils/webpack/env/types.js.map +1 -0
- package/dist/cjs/utils/webpack/env/utils.js +55 -0
- package/dist/cjs/utils/webpack/env/utils.js.map +1 -0
- package/dist/cjs/utils/webpack/index.js +20 -0
- package/dist/cjs/utils/webpack/index.js.map +1 -0
- package/dist/cjs/utils/webpack/module-federation/index.js +110 -0
- package/dist/cjs/utils/webpack/module-federation/index.js.map +1 -0
- package/dist/cjs/utils/webpack/module-federation/types.js +6 -0
- package/dist/cjs/utils/webpack/module-federation/types.js.map +1 -0
- package/{utils → dist/cjs/utils}/webpack/module-federation/utils.js +26 -31
- package/dist/cjs/utils/webpack/module-federation/utils.js.map +1 -0
- package/dist/esm/cache/index.js +2 -0
- package/dist/esm/cache/index.js.map +1 -0
- package/dist/esm/cache/types.js +2 -0
- package/dist/esm/cache/types.js.map +1 -0
- package/dist/esm/config/base.js +16 -0
- package/dist/esm/config/base.js.map +1 -0
- package/dist/esm/config/index.js +3 -0
- package/dist/esm/config/index.js.map +1 -0
- package/dist/esm/config/source.js +19 -0
- package/dist/esm/config/source.js.map +1 -0
- package/dist/esm/config/types.js +2 -0
- package/dist/esm/config/types.js.map +1 -0
- package/dist/esm/di/application.js +100 -0
- package/dist/esm/di/application.js.map +1 -0
- package/dist/esm/di/container.js +49 -0
- package/dist/esm/di/container.js.map +1 -0
- package/dist/esm/di/errors.js +56 -0
- package/dist/esm/di/errors.js.map +1 -0
- package/dist/esm/di/index.js +6 -0
- package/dist/esm/di/index.js.map +1 -0
- package/dist/esm/di/preset.js +26 -0
- package/dist/esm/di/preset.js.map +1 -0
- package/dist/esm/di/token.js +38 -0
- package/dist/esm/di/token.js.map +1 -0
- package/dist/esm/di/types.js +2 -0
- package/dist/esm/di/types.js.map +1 -0
- package/dist/esm/http/errors.js +39 -0
- package/dist/esm/http/errors.js.map +1 -0
- package/dist/esm/http/index.js +4 -0
- package/dist/esm/http/index.js.map +1 -0
- package/dist/esm/http/types.js +2 -0
- package/dist/esm/http/types.js.map +1 -0
- package/dist/esm/log/errors.js +27 -0
- package/dist/esm/log/errors.js.map +1 -0
- package/dist/esm/log/handler/pino.js +25 -0
- package/dist/esm/log/handler/pino.js.map +1 -0
- package/dist/esm/log/handler/sentry.js +52 -0
- package/dist/esm/log/handler/sentry.js.map +1 -0
- package/dist/esm/log/index.js +3 -0
- package/dist/esm/log/index.js.map +1 -0
- package/dist/esm/log/logger.js +29 -0
- package/dist/esm/log/logger.js.map +1 -0
- package/dist/esm/log/types.js +2 -0
- package/dist/esm/log/types.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/preset/isomorphic/constants.js +8 -0
- package/dist/esm/preset/isomorphic/constants.js.map +1 -0
- package/dist/esm/preset/isomorphic/providers/index.js +35 -0
- package/dist/esm/preset/isomorphic/providers/index.js.map +1 -0
- package/dist/esm/preset/isomorphic/types.js +2 -0
- package/dist/esm/preset/isomorphic/types.js.map +1 -0
- package/dist/esm/preset/isomorphic/utils/index.js +309 -0
- package/dist/esm/preset/isomorphic/utils/index.js.map +1 -0
- package/dist/esm/preset/node/handler/index.js +42 -0
- package/dist/esm/preset/node/handler/index.js.map +1 -0
- package/dist/esm/preset/node/handler/providers/index.js +194 -0
- package/dist/esm/preset/node/handler/providers/index.js.map +1 -0
- package/dist/esm/preset/node/handler/utils/index.js +113 -0
- package/dist/esm/preset/node/handler/utils/index.js.map +1 -0
- package/dist/esm/preset/node/index.js +3 -0
- package/dist/esm/preset/node/index.js.map +1 -0
- package/dist/esm/preset/node/node/index.js +56 -0
- package/dist/esm/preset/node/node/index.js.map +1 -0
- package/dist/esm/preset/node/node/providers/index.js +378 -0
- package/dist/esm/preset/node/node/providers/index.js.map +1 -0
- package/dist/esm/preset/node/node/utils/http-client/index.js +114 -0
- package/dist/esm/preset/node/node/utils/http-client/index.js.map +1 -0
- package/dist/esm/preset/node/node/utils/http-server/index.js +12 -0
- package/dist/esm/preset/node/node/utils/http-server/index.js.map +1 -0
- package/dist/esm/preset/node/node/utils/index.js +3 -0
- package/dist/esm/preset/node/node/utils/index.js.map +1 -0
- package/dist/esm/preset/web/index.js +29 -0
- package/dist/esm/preset/web/index.js.map +1 -0
- package/dist/esm/preset/web/providers/index.js +85 -0
- package/dist/esm/preset/web/providers/index.js.map +1 -0
- package/dist/esm/tokens.js +81 -0
- package/dist/esm/tokens.js.map +1 -0
- package/dist/esm/utils/axios/index.js +5 -0
- package/dist/esm/utils/axios/index.js.map +1 -0
- package/dist/esm/utils/axios/middleware/cookie.js +22 -0
- package/dist/esm/utils/axios/middleware/cookie.js.map +1 -0
- package/dist/esm/utils/axios/middleware/log.js +31 -0
- package/dist/esm/utils/axios/middleware/log.js.map +1 -0
- package/dist/esm/utils/axios/sauce/index.js +50 -0
- package/dist/esm/utils/axios/sauce/index.js.map +1 -0
- package/dist/esm/utils/axios/utils/index.js +24 -0
- package/dist/esm/utils/axios/utils/index.js.map +1 -0
- package/dist/esm/utils/express/handler/health-check.js +13 -0
- package/dist/esm/utils/express/handler/health-check.js.map +1 -0
- package/dist/esm/utils/express/index.js +3 -0
- package/dist/esm/utils/express/index.js.map +1 -0
- package/dist/esm/utils/express/utils/index.js +16 -0
- package/dist/esm/utils/express/utils/index.js.map +1 -0
- package/dist/esm/utils/function.js +38 -0
- package/dist/esm/utils/function.js.map +1 -0
- package/dist/esm/utils/index.js +3 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/esm/utils/math.js +9 -0
- package/dist/esm/utils/math.js.map +1 -0
- package/dist/esm/utils/react/error-handlers/index.js +69 -0
- package/dist/esm/utils/react/error-handlers/index.js.map +1 -0
- package/dist/esm/utils/react/index.js +3 -0
- package/dist/esm/utils/react/index.js.map +1 -0
- package/dist/esm/utils/redux/index.js +3 -0
- package/dist/esm/utils/redux/index.js.map +1 -0
- package/dist/esm/utils/redux/remote-data.js +108 -0
- package/dist/esm/utils/redux/remote-data.js.map +1 -0
- package/dist/esm/utils/redux-saga/index.js +3 -0
- package/dist/esm/utils/redux-saga/index.js.map +1 -0
- package/dist/esm/utils/redux-saga/middleware.js +143 -0
- package/dist/esm/utils/redux-saga/middleware.js.map +1 -0
- package/dist/esm/utils/redux-saga/take-chain.js +59 -0
- package/dist/esm/utils/redux-saga/take-chain.js.map +1 -0
- package/dist/esm/utils/redux-saga/types.js +2 -0
- package/dist/esm/utils/redux-saga/types.js.map +1 -0
- package/dist/esm/utils/ssr/index.js +66 -0
- package/dist/esm/utils/ssr/index.js.map +1 -0
- package/dist/esm/utils/web/analytics/data-layer.js +14 -0
- package/dist/esm/utils/web/analytics/data-layer.js.map +1 -0
- package/dist/esm/utils/web/analytics/index.js +3 -0
- package/dist/esm/utils/web/analytics/index.js.map +1 -0
- package/dist/esm/utils/web/analytics/oko.js +14 -0
- package/dist/esm/utils/web/analytics/oko.js.map +1 -0
- package/dist/esm/utils/web/storage/index.js +69 -0
- package/dist/esm/utils/web/storage/index.js.map +1 -0
- package/dist/esm/utils/webpack/env/index.js +89 -0
- package/dist/esm/utils/webpack/env/index.js.map +1 -0
- package/dist/esm/utils/webpack/env/types.js +2 -0
- package/dist/esm/utils/webpack/env/types.js.map +1 -0
- package/dist/esm/utils/webpack/env/utils.js +48 -0
- package/dist/esm/utils/webpack/env/utils.js.map +1 -0
- package/dist/esm/utils/webpack/index.js +4 -0
- package/dist/esm/utils/webpack/index.js.map +1 -0
- package/dist/esm/utils/webpack/module-federation/index.js +96 -0
- package/dist/esm/utils/webpack/module-federation/index.js.map +1 -0
- package/dist/esm/utils/webpack/module-federation/types.js +2 -0
- package/dist/esm/utils/webpack/module-federation/types.js.map +1 -0
- package/dist/esm/utils/webpack/module-federation/utils.js +80 -0
- package/dist/esm/utils/webpack/module-federation/utils.js.map +1 -0
- package/dist/types/cache/index.d.ts +1 -0
- package/dist/types/log/index.d.ts +3 -0
- package/{preset → dist/types/preset}/isomorphic/types.d.ts +1 -0
- package/dist/types/preset/node/node/utils/index.d.ts +2 -0
- package/{utils → dist/types/utils}/axios/sauce/index.d.ts +1 -1
- package/dist/types/utils/index.d.ts +2 -0
- package/{utils → dist/types/utils}/redux/remote-data.d.ts +8 -8
- package/{utils → dist/types/utils}/ssr/index.d.ts +1 -0
- package/dist/types/utils/web/analytics/index.d.ts +2 -0
- package/{utils → dist/types/utils}/webpack/module-federation/index.d.ts +2 -2
- package/package.json +167 -9
- package/src/cache/index.ts +1 -0
- package/src/cache/types.ts +34 -0
- package/src/config/base.ts +18 -0
- package/src/config/index.ts +3 -0
- package/src/config/source.ts +23 -0
- package/src/config/types.ts +25 -0
- package/src/di/__test__/application.test.ts +258 -0
- package/src/di/__test__/container.test.ts +103 -0
- package/src/di/__test__/errors.test.ts +56 -0
- package/src/di/__test__/preset.test.ts +23 -0
- package/src/di/__test__/token.test.ts +25 -0
- package/src/di/application.ts +126 -0
- package/src/di/container.ts +60 -0
- package/src/di/errors.ts +59 -0
- package/src/di/index.ts +6 -0
- package/src/di/preset.ts +32 -0
- package/src/di/token.ts +41 -0
- package/src/di/types.ts +105 -0
- package/src/http/__test__/errors.test.ts +35 -0
- package/src/http/errors.ts +42 -0
- package/src/http/index.ts +14 -0
- package/src/http/types.ts +8 -0
- package/src/log/__test__/errors.test.ts +13 -0
- package/src/log/__test__/logger.test.ts +24 -0
- package/src/log/errors.ts +33 -0
- package/src/log/handler/pino.ts +27 -0
- package/src/log/handler/sentry.ts +57 -0
- package/src/log/index.ts +12 -0
- package/src/log/logger.ts +30 -0
- package/src/log/types.ts +76 -0
- package/src/preset/isomorphic/constants.ts +7 -0
- package/src/preset/isomorphic/providers/index.ts +40 -0
- package/src/preset/isomorphic/types.ts +48 -0
- package/src/preset/isomorphic/utils/__test__/index.test.ts +541 -0
- package/src/preset/isomorphic/utils/index.ts +349 -0
- package/src/preset/node/handler/index.ts +46 -0
- package/src/preset/node/handler/providers/index.tsx +214 -0
- package/src/preset/node/handler/utils/index.tsx +110 -0
- package/src/preset/node/index.ts +2 -0
- package/src/preset/node/node/index.ts +73 -0
- package/src/preset/node/node/providers/index.ts +434 -0
- package/src/preset/node/node/utils/http-client/__test__/index.test.ts +232 -0
- package/src/preset/node/node/utils/http-client/index.ts +129 -0
- package/src/preset/node/node/utils/http-server/index.ts +17 -0
- package/src/preset/node/node/utils/index.ts +2 -0
- package/src/preset/web/index.ts +40 -0
- package/src/preset/web/providers/index.ts +108 -0
- package/src/tokens.ts +112 -0
- package/src/utils/axios/index.ts +12 -0
- package/src/utils/axios/middleware/__test__/cookie.test.ts +94 -0
- package/src/utils/axios/middleware/__test__/log.test.ts +121 -0
- package/src/utils/axios/middleware/cookie.ts +26 -0
- package/src/utils/axios/middleware/log.ts +52 -0
- package/src/utils/axios/sauce/index.ts +76 -0
- package/src/utils/axios/utils/__test__/index.test.ts +89 -0
- package/src/utils/axios/utils/index.ts +26 -0
- package/src/utils/express/handler/health-check.ts +13 -0
- package/src/utils/express/index.ts +2 -0
- package/src/utils/express/utils/index.ts +18 -0
- package/src/utils/function.ts +57 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/math.ts +8 -0
- package/src/utils/react/error-handlers/__test__/__snapshots__/index.test.tsx.snap +27 -0
- package/src/utils/react/error-handlers/__test__/index.test.tsx +63 -0
- package/src/utils/react/error-handlers/index.tsx +68 -0
- package/src/utils/react/index.ts +3 -0
- package/src/utils/redux/__test__/remote-data.test.ts +172 -0
- package/src/utils/redux/index.ts +4 -0
- package/src/utils/redux/remote-data.ts +138 -0
- package/src/utils/redux-saga/__test__/take-chain.test.ts +141 -0
- package/src/utils/redux-saga/index.ts +3 -0
- package/src/utils/redux-saga/middleware.ts +168 -0
- package/src/utils/redux-saga/take-chain.ts +67 -0
- package/src/utils/redux-saga/types.ts +43 -0
- package/src/utils/ssr/index.tsx +78 -0
- package/src/utils/web/analytics/__test__/data-layer.test.ts +50 -0
- package/src/utils/web/analytics/__test__/oko.test.ts +50 -0
- package/src/utils/web/analytics/data-layer.ts +12 -0
- package/src/utils/web/analytics/index.ts +2 -0
- package/src/utils/web/analytics/oko.ts +14 -0
- package/src/utils/web/storage/index.ts +84 -0
- package/src/utils/webpack/env/index.ts +91 -0
- package/src/utils/webpack/env/types.ts +14 -0
- package/src/utils/webpack/env/utils.ts +53 -0
- package/src/utils/webpack/index.ts +7 -0
- package/src/utils/webpack/module-federation/__test__/__snapshots__/utils.test.ts.snap +124 -0
- package/src/utils/webpack/module-federation/__test__/index.test.ts +311 -0
- package/src/utils/webpack/module-federation/__test__/utils.test.ts +28 -0
- package/src/utils/webpack/module-federation/index.ts +102 -0
- package/src/utils/webpack/module-federation/types.ts +54 -0
- package/src/utils/webpack/module-federation/utils.ts +104 -0
- package/cache/types.js +0 -3
- package/cache/types.js.map +0 -1
- package/config/base.js +0 -20
- package/config/base.js.map +0 -1
- package/config/index.js +0 -8
- package/config/index.js.map +0 -1
- package/config/source.js +0 -21
- package/config/source.js.map +0 -1
- package/config/types.js +0 -3
- package/config/types.js.map +0 -1
- package/di/application.js +0 -88
- package/di/application.js.map +0 -1
- package/di/container.js +0 -52
- package/di/container.js.map +0 -1
- package/di/errors.js +0 -59
- package/di/errors.js.map +0 -1
- package/di/index.js +0 -17
- package/di/index.js.map +0 -1
- package/di/preset.js +0 -27
- package/di/preset.js.map +0 -1
- package/di/token.js +0 -39
- package/di/token.js.map +0 -1
- package/di/types.js +0 -3
- package/di/types.js.map +0 -1
- package/http/errors.js +0 -42
- package/http/errors.js.map +0 -1
- package/http/index.js +0 -16
- package/http/index.js.map +0 -1
- package/http/types.js +0 -3
- package/http/types.js.map +0 -1
- package/log/errors.js +0 -31
- package/log/errors.js.map +0 -1
- package/log/handler/pino.js +0 -29
- package/log/handler/pino.js.map +0 -1
- package/log/handler/sentry.js +0 -50
- package/log/handler/sentry.js.map +0 -1
- package/log/index.d.ts +0 -3
- package/log/index.js +0 -9
- package/log/index.js.map +0 -1
- package/log/logger.js +0 -29
- package/log/logger.js.map +0 -1
- package/log/types.js +0 -3
- package/log/types.js.map +0 -1
- package/preset/isomorphic/constants.js +0 -11
- package/preset/isomorphic/constants.js.map +0 -1
- package/preset/isomorphic/providers/index.js.map +0 -1
- package/preset/isomorphic/types.js +0 -3
- package/preset/isomorphic/types.js.map +0 -1
- package/preset/isomorphic/utils/index.js +0 -289
- package/preset/isomorphic/utils/index.js.map +0 -1
- package/preset/node/handler/index.js +0 -38
- package/preset/node/handler/index.js.map +0 -1
- package/preset/node/handler/providers/index.js +0 -184
- package/preset/node/handler/providers/index.js.map +0 -1
- package/preset/node/handler/utils/index.js +0 -81
- package/preset/node/handler/utils/index.js.map +0 -1
- package/preset/node/index.js +0 -9
- package/preset/node/index.js.map +0 -1
- package/preset/node/node/index.js +0 -49
- package/preset/node/node/index.js.map +0 -1
- package/preset/node/node/providers/index.js +0 -392
- package/preset/node/node/providers/index.js.map +0 -1
- package/preset/node/node/utils/http-client/index.js +0 -109
- package/preset/node/node/utils/http-client/index.js.map +0 -1
- package/preset/node/node/utils/http-server/index.js +0 -21
- package/preset/node/node/utils/http-server/index.js.map +0 -1
- package/preset/web/index.js +0 -30
- package/preset/web/index.js.map +0 -1
- package/preset/web/providers/index.js +0 -88
- package/preset/web/providers/index.js.map +0 -1
- package/tokens.js +0 -81
- package/tokens.js.map +0 -1
- package/utils/axios/index.js +0 -13
- package/utils/axios/index.js.map +0 -1
- package/utils/axios/middleware/cookie.js +0 -26
- package/utils/axios/middleware/cookie.js.map +0 -1
- package/utils/axios/middleware/log.js +0 -26
- package/utils/axios/middleware/log.js.map +0 -1
- package/utils/axios/sauce/index.js +0 -50
- package/utils/axios/sauce/index.js.map +0 -1
- package/utils/axios/utils/index.js.map +0 -1
- package/utils/express/handler/health-check.js.map +0 -1
- package/utils/express/index.js +0 -8
- package/utils/express/index.js.map +0 -1
- package/utils/express/utils/index.js +0 -20
- package/utils/express/utils/index.js.map +0 -1
- package/utils/function.js +0 -23
- package/utils/function.js.map +0 -1
- package/utils/number.js.map +0 -1
- package/utils/react/error-handlers/index.js +0 -47
- package/utils/react/error-handlers/index.js.map +0 -1
- package/utils/react/index.js +0 -7
- package/utils/react/index.js.map +0 -1
- package/utils/redux/index.js +0 -7
- package/utils/redux/index.js.map +0 -1
- package/utils/redux/remote-data.js +0 -91
- package/utils/redux/remote-data.js.map +0 -1
- package/utils/redux-saga/index.js +0 -8
- package/utils/redux-saga/index.js.map +0 -1
- package/utils/redux-saga/middleware.js +0 -142
- package/utils/redux-saga/middleware.js.map +0 -1
- package/utils/redux-saga/take-chain.js +0 -58
- package/utils/redux-saga/take-chain.js.map +0 -1
- package/utils/redux-saga/types.js +0 -3
- package/utils/redux-saga/types.js.map +0 -1
- package/utils/ssr/index.js +0 -54
- package/utils/ssr/index.js.map +0 -1
- package/utils/web/analytics/data-layer.js +0 -16
- package/utils/web/analytics/data-layer.js.map +0 -1
- package/utils/web/analytics/oko.js +0 -16
- package/utils/web/analytics/oko.js.map +0 -1
- package/utils/web/storage/index.js +0 -69
- package/utils/web/storage/index.js.map +0 -1
- package/utils/webpack/env/index.js +0 -76
- package/utils/webpack/env/index.js.map +0 -1
- package/utils/webpack/env/types.js +0 -3
- package/utils/webpack/env/types.js.map +0 -1
- package/utils/webpack/env/utils.js +0 -52
- package/utils/webpack/env/utils.js.map +0 -1
- package/utils/webpack/index.js +0 -8
- package/utils/webpack/index.js.map +0 -1
- package/utils/webpack/module-federation/index.js +0 -81
- package/utils/webpack/module-federation/index.js.map +0 -1
- package/utils/webpack/module-federation/types.js +0 -3
- package/utils/webpack/module-federation/types.js.map +0 -1
- package/utils/webpack/module-federation/utils.js.map +0 -1
- /package/{cache → dist/types/cache}/types.d.ts +0 -0
- /package/{config → dist/types/config}/base.d.ts +0 -0
- /package/{config → dist/types/config}/index.d.ts +0 -0
- /package/{config → dist/types/config}/source.d.ts +0 -0
- /package/{config → dist/types/config}/types.d.ts +0 -0
- /package/{di → dist/types/di}/application.d.ts +0 -0
- /package/{di → dist/types/di}/container.d.ts +0 -0
- /package/{di → dist/types/di}/errors.d.ts +0 -0
- /package/{di → dist/types/di}/index.d.ts +0 -0
- /package/{di → dist/types/di}/preset.d.ts +0 -0
- /package/{di → dist/types/di}/token.d.ts +0 -0
- /package/{di → dist/types/di}/types.d.ts +0 -0
- /package/{http → dist/types/http}/errors.d.ts +0 -0
- /package/{http → dist/types/http}/index.d.ts +0 -0
- /package/{http → dist/types/http}/types.d.ts +0 -0
- /package/{log → dist/types/log}/errors.d.ts +0 -0
- /package/{log → dist/types/log}/handler/pino.d.ts +0 -0
- /package/{log → dist/types/log}/handler/sentry.d.ts +0 -0
- /package/{log → dist/types/log}/logger.d.ts +0 -0
- /package/{log → dist/types/log}/types.d.ts +0 -0
- /package/{preset → dist/types/preset}/isomorphic/constants.d.ts +0 -0
- /package/{preset → dist/types/preset}/isomorphic/providers/index.d.ts +0 -0
- /package/{preset → dist/types/preset}/isomorphic/utils/index.d.ts +0 -0
- /package/{preset → dist/types/preset}/node/handler/index.d.ts +0 -0
- /package/{preset → dist/types/preset}/node/handler/providers/index.d.ts +0 -0
- /package/{preset → dist/types/preset}/node/handler/utils/index.d.ts +0 -0
- /package/{preset → dist/types/preset}/node/index.d.ts +0 -0
- /package/{preset → dist/types/preset}/node/node/index.d.ts +0 -0
- /package/{preset → dist/types/preset}/node/node/providers/index.d.ts +0 -0
- /package/{preset → dist/types/preset}/node/node/utils/http-client/index.d.ts +0 -0
- /package/{preset → dist/types/preset}/node/node/utils/http-server/index.d.ts +0 -0
- /package/{preset → dist/types/preset}/web/index.d.ts +0 -0
- /package/{preset → dist/types/preset}/web/providers/index.d.ts +0 -0
- /package/{tokens.d.ts → dist/types/tokens.d.ts} +0 -0
- /package/{utils → dist/types/utils}/axios/index.d.ts +0 -0
- /package/{utils → dist/types/utils}/axios/middleware/cookie.d.ts +0 -0
- /package/{utils → dist/types/utils}/axios/middleware/log.d.ts +0 -0
- /package/{utils → dist/types/utils}/axios/utils/index.d.ts +0 -0
- /package/{utils → dist/types/utils}/express/handler/health-check.d.ts +0 -0
- /package/{utils → dist/types/utils}/express/index.d.ts +0 -0
- /package/{utils → dist/types/utils}/express/utils/index.d.ts +0 -0
- /package/{utils → dist/types/utils}/function.d.ts +0 -0
- /package/{utils/number.d.ts → dist/types/utils/math.d.ts} +0 -0
- /package/{utils → dist/types/utils}/react/error-handlers/index.d.ts +0 -0
- /package/{utils → dist/types/utils}/react/index.d.ts +0 -0
- /package/{utils → dist/types/utils}/redux/index.d.ts +0 -0
- /package/{utils → dist/types/utils}/redux-saga/index.d.ts +0 -0
- /package/{utils → dist/types/utils}/redux-saga/middleware.d.ts +0 -0
- /package/{utils → dist/types/utils}/redux-saga/take-chain.d.ts +0 -0
- /package/{utils → dist/types/utils}/redux-saga/types.d.ts +0 -0
- /package/{utils → dist/types/utils}/web/analytics/data-layer.d.ts +0 -0
- /package/{utils → dist/types/utils}/web/analytics/oko.d.ts +0 -0
- /package/{utils → dist/types/utils}/web/storage/index.d.ts +0 -0
- /package/{utils → dist/types/utils}/webpack/env/index.d.ts +0 -0
- /package/{utils → dist/types/utils}/webpack/env/types.d.ts +0 -0
- /package/{utils → dist/types/utils}/webpack/env/utils.d.ts +0 -0
- /package/{utils → dist/types/utils}/webpack/index.d.ts +0 -0
- /package/{utils → dist/types/utils}/webpack/module-federation/types.d.ts +0 -0
- /package/{utils → dist/types/utils}/webpack/module-federation/utils.d.ts +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Isomorph
|
|
2
|
+
|
|
3
|
+
Минималистичный фреймворк для быстрого старта frontend-микросервисов.
|
|
4
|
+
|
|
5
|
+
Содержит утилиты для стека:
|
|
6
|
+
|
|
7
|
+
- react
|
|
8
|
+
- redux
|
|
9
|
+
- redux-saga
|
|
10
|
+
- axios
|
|
11
|
+
- express
|
|
12
|
+
- webpack
|
|
13
|
+
- sentry (логирование ошибок)
|
|
14
|
+
- opentelemetry/jaeger (трассировка)
|
|
15
|
+
- prometheus (метрики)
|
|
16
|
+
|
|
17
|
+
## Установка
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
# npm
|
|
21
|
+
npm i -S @sima-land/isomorph
|
|
22
|
+
|
|
23
|
+
# или yarn
|
|
24
|
+
yarn add @sima-land/isomorph
|
|
25
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cache/index.ts"],"sourcesContent":["export type { Cache } from './types';\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/cache/types.ts"],"sourcesContent":["/**\n * Простейший интерфейс кэша.\n * @todo Рассмотреть web-стандарт CacheStorage.\n */\nexport interface Cache {\n /**\n * Возвращает значение из кэша по ключу.\n * @param key Ключ.\n * @return Значение.\n */\n get: (key: string) => unknown;\n\n /**\n * Записывает значение в кэш по ключу.\n * @param key Ключ.\n */\n set: (key: string, value: any) => void;\n\n /**\n * Удаляет значение из кэша по ключу.\n * @param key Ключ.\n */\n delete: (key: string) => void;\n\n /**\n * Полностью очищает кэш.\n */\n clear: () => void;\n\n /**\n * Возвращает `true` в случае, если значение под переданным ключом присутствует в кэше, `false` в противном случае.\n */\n has: (key: string) => boolean;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createBaseConfig = createBaseConfig;
|
|
7
|
+
/**
|
|
8
|
+
* Возвращает новую базовую конфигурацию.
|
|
9
|
+
* @param source Источник конфигурации.
|
|
10
|
+
* @return Базовая конфигурация.
|
|
11
|
+
*/
|
|
12
|
+
function createBaseConfig(source) {
|
|
13
|
+
const env = source.require('NODE_ENV');
|
|
14
|
+
const appName = source.require('APP_NAME');
|
|
15
|
+
const appVersion = source.require('APP_VERSION');
|
|
16
|
+
return {
|
|
17
|
+
env,
|
|
18
|
+
appName,
|
|
19
|
+
appVersion
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","names":["createBaseConfig","source","env","require","appName","appVersion"],"sources":["../../../src/config/base.ts"],"sourcesContent":["import type { ConfigSource, BaseConfig } from './types';\n\n/**\n * Возвращает новую базовую конфигурацию.\n * @param source Источник конфигурации.\n * @return Базовая конфигурация.\n */\nexport function createBaseConfig(source: ConfigSource): BaseConfig {\n const env = source.require('NODE_ENV');\n const appName = source.require('APP_NAME');\n const appVersion = source.require('APP_VERSION');\n\n return {\n env,\n appName,\n appVersion,\n };\n}\n"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAgBA,CAACC,MAAoB,EAAc;EACjE,MAAMC,GAAG,GAAGD,MAAM,CAACE,OAAO,CAAC,UAAU,CAAC;EACtC,MAAMC,OAAO,GAAGH,MAAM,CAACE,OAAO,CAAC,UAAU,CAAC;EAC1C,MAAME,UAAU,GAAGJ,MAAM,CAACE,OAAO,CAAC,aAAa,CAAC;EAEhD,OAAO;IACLD,GAAG;IACHE,OAAO;IACPC;EACF,CAAC;AACH"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "createBaseConfig", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _base.createBaseConfig;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "createConfigSource", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _source.createConfigSource;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _source = require("./source");
|
|
19
|
+
var _base = require("./base");
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_source","require","_base"],"sources":["../../../src/config/index.ts"],"sourcesContent":["export type { ConfigSource, BaseConfig } from './types';\nexport { createConfigSource } from './source';\nexport { createBaseConfig } from './base';\n"],"mappings":";;;;;;;;;;;;;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createConfigSource = createConfigSource;
|
|
7
|
+
var _env = require("@humanwhocodes/env");
|
|
8
|
+
/**
|
|
9
|
+
* Возвращает новый источник конфигурации.
|
|
10
|
+
* @param dictionary Опции.
|
|
11
|
+
* @return Источник.
|
|
12
|
+
*/
|
|
13
|
+
function createConfigSource(dictionary) {
|
|
14
|
+
const source = {};
|
|
15
|
+
|
|
16
|
+
// берем все переменные из предоставленной среды
|
|
17
|
+
Object.assign(source, dictionary);
|
|
18
|
+
|
|
19
|
+
// докидываем зашиваемые переменные окружения
|
|
20
|
+
if (typeof __ISOMORPH_ENV__ !== 'undefined') {
|
|
21
|
+
Object.assign(source, __ISOMORPH_ENV__);
|
|
22
|
+
}
|
|
23
|
+
return new _env.Env(source);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source.js","names":["_env","require","createConfigSource","dictionary","source","Object","assign","__ISOMORPH_ENV__","Env"],"sources":["../../../src/config/source.ts"],"sourcesContent":["import type { ConfigSource, Dictionary } from './types';\nimport { Env } from '@humanwhocodes/env';\n\ndeclare const __ISOMORPH_ENV__: unknown;\n\n/**\n * Возвращает новый источник конфигурации.\n * @param dictionary Опции.\n * @return Источник.\n */\nexport function createConfigSource(dictionary: Dictionary): ConfigSource {\n const source: Dictionary = {};\n\n // берем все переменные из предоставленной среды\n Object.assign(source, dictionary);\n\n // докидываем зашиваемые переменные окружения\n if (typeof __ISOMORPH_ENV__ !== 'undefined') {\n Object.assign(source, __ISOMORPH_ENV__);\n }\n\n return new Env(source);\n}\n"],"mappings":";;;;;;AACA,IAAAA,IAAA,GAAAC,OAAA;AAIA;AACA;AACA;AACA;AACA;AACO,SAASC,kBAAkBA,CAACC,UAAsB,EAAgB;EACvE,MAAMC,MAAkB,GAAG,CAAC,CAAC;;EAE7B;EACAC,MAAM,CAACC,MAAM,CAACF,MAAM,EAAED,UAAU,CAAC;;EAEjC;EACA,IAAI,OAAOI,gBAAgB,KAAK,WAAW,EAAE;IAC3CF,MAAM,CAACC,MAAM,CAACF,MAAM,EAAEG,gBAAgB,CAAC;EACzC;EAEA,OAAO,IAAIC,QAAG,CAACJ,MAAM,CAAC;AACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/config/types.ts"],"sourcesContent":["import type { Env } from '@humanwhocodes/env';\n\n/** Источник конфигурации. */\nexport type ConfigSource = Env;\n\n/**\n * Базовая информация о приложении, необходимая в большинстве мест.\n */\nexport interface BaseConfig {\n /** Строка, характеризующая среду выполнения, например \"production\". */\n env: string;\n\n /** Имя приложения. */\n appName: string;\n\n /** Версия приложения. */\n appVersion: string;\n}\n\n/**\n * Словарь.\n */\nexport interface Dictionary {\n readonly [key: string]: string | undefined;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CURRENT_APP = void 0;
|
|
7
|
+
exports.createApplication = createApplication;
|
|
8
|
+
var _errors = require("./errors");
|
|
9
|
+
var _token = require("./token");
|
|
10
|
+
/* eslint-disable require-jsdoc, jsdoc/require-jsdoc */
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Токен, с помощью которого можно достать из приложения само приложение.
|
|
14
|
+
*/
|
|
15
|
+
const CURRENT_APP = exports.CURRENT_APP = (0, _token.createToken)('application/self');
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Реализация Application.
|
|
19
|
+
*/
|
|
20
|
+
class ApplicationImplementation {
|
|
21
|
+
/** Родительское приложение. */
|
|
22
|
+
|
|
23
|
+
/** Зарегистрированные пресеты. */
|
|
24
|
+
|
|
25
|
+
/** Зарегистрированные провайдеры. */
|
|
26
|
+
|
|
27
|
+
/** Инициализированные компоненты (синглтоны). */
|
|
28
|
+
|
|
29
|
+
/** Инициализировано ли приложение. */
|
|
30
|
+
|
|
31
|
+
constructor() {
|
|
32
|
+
this.providers = new Map();
|
|
33
|
+
this.components = new Map();
|
|
34
|
+
this.presets = [];
|
|
35
|
+
this.initialized = false;
|
|
36
|
+
}
|
|
37
|
+
toString() {
|
|
38
|
+
return 'Application';
|
|
39
|
+
}
|
|
40
|
+
bind(token) {
|
|
41
|
+
if (this.providers.has(token._key)) {
|
|
42
|
+
throw new _errors.AlreadyBoundError(token, this.toString());
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
toValue: value => {
|
|
46
|
+
this.providers.set(token._key, () => value);
|
|
47
|
+
},
|
|
48
|
+
toProvider: provider => {
|
|
49
|
+
this.providers.set(token._key, provider);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
get(token) {
|
|
54
|
+
if (!this.initialized) {
|
|
55
|
+
this.bind(CURRENT_APP).toValue(this);
|
|
56
|
+
for (const preset of this.presets) {
|
|
57
|
+
preset.apply(this);
|
|
58
|
+
}
|
|
59
|
+
this.initialized = true;
|
|
60
|
+
}
|
|
61
|
+
return this.resolve(token, []);
|
|
62
|
+
}
|
|
63
|
+
resolve(token, chain) {
|
|
64
|
+
const nextChain = () => [...chain, token];
|
|
65
|
+
if (chain.includes(token)) {
|
|
66
|
+
throw new _errors.CircularDependencyError(nextChain(), this.toString());
|
|
67
|
+
}
|
|
68
|
+
if (this.components.has(token._key)) {
|
|
69
|
+
return this.components.get(token._key);
|
|
70
|
+
}
|
|
71
|
+
if (this.providers.has(token._key)) {
|
|
72
|
+
const provider = this.providers.get(token._key);
|
|
73
|
+
const component = provider(otherToken => this.resolve(otherToken, nextChain()));
|
|
74
|
+
|
|
75
|
+
// ВАЖНО: всегда как singleton
|
|
76
|
+
this.components.set(token._key, component);
|
|
77
|
+
return component;
|
|
78
|
+
}
|
|
79
|
+
if (this.parent) {
|
|
80
|
+
// ВАЖНО: передаём именно chain а не nextChain()
|
|
81
|
+
return this.parent.resolve(token, chain);
|
|
82
|
+
}
|
|
83
|
+
throw new _errors.NothingBoundError(token, this.toString());
|
|
84
|
+
}
|
|
85
|
+
attach(parent) {
|
|
86
|
+
if (this.parent) {
|
|
87
|
+
throw new Error('Cannot reattach application');
|
|
88
|
+
}
|
|
89
|
+
this.parent = parent;
|
|
90
|
+
}
|
|
91
|
+
preset(preset) {
|
|
92
|
+
this.presets.push(preset);
|
|
93
|
+
}
|
|
94
|
+
invoke(tokens, fn) {
|
|
95
|
+
fn(...tokens.map(token => this.get(token)));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Возвращает новое DI-приложение.
|
|
101
|
+
* @return DI-приложение.
|
|
102
|
+
*/
|
|
103
|
+
function createApplication() {
|
|
104
|
+
return new ApplicationImplementation();
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=application.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application.js","names":["_errors","require","_token","CURRENT_APP","exports","createToken","ApplicationImplementation","constructor","providers","Map","components","presets","initialized","toString","bind","token","has","_key","AlreadyBoundError","toValue","value","set","toProvider","provider","get","preset","apply","resolve","chain","nextChain","includes","CircularDependencyError","component","otherToken","parent","NothingBoundError","attach","Error","push","invoke","tokens","fn","map","createApplication"],"sources":["../../../src/di/application.ts"],"sourcesContent":["/* eslint-disable require-jsdoc, jsdoc/require-jsdoc */\nimport type { Application, Provider, Token, Binding, ExtractType, Preset } from './types';\nimport { AlreadyBoundError, CircularDependencyError, NothingBoundError } from './errors';\nimport { createToken } from './token';\n\n/**\n * Токен, с помощью которого можно достать из приложения само приложение.\n */\nexport const CURRENT_APP = createToken<Application>('application/self');\n\n/**\n * Реализация Application.\n */\nclass ApplicationImplementation implements Application {\n /** Родительское приложение. */\n private parent?: ApplicationImplementation;\n\n /** Зарегистрированные пресеты. */\n private presets: Preset[];\n\n /** Зарегистрированные провайдеры. */\n private providers: Map<symbol, Provider<unknown>>;\n\n /** Инициализированные компоненты (синглтоны). */\n private components: Map<symbol, unknown>;\n\n /** Инициализировано ли приложение. */\n private initialized: boolean;\n\n constructor() {\n this.providers = new Map();\n this.components = new Map();\n this.presets = [];\n this.initialized = false;\n }\n\n toString() {\n return 'Application';\n }\n\n bind<T>(token: Token<T>): Binding<T> {\n if (this.providers.has(token._key)) {\n throw new AlreadyBoundError(token, this.toString());\n }\n\n return {\n toValue: value => {\n this.providers.set(token._key, () => value);\n },\n toProvider: provider => {\n this.providers.set(token._key, provider);\n },\n };\n }\n\n get<T>(token: Token<T>): T {\n if (!this.initialized) {\n this.bind(CURRENT_APP).toValue(this);\n\n for (const preset of this.presets) {\n preset.apply(this);\n }\n\n this.initialized = true;\n }\n\n return this.resolve(token, []);\n }\n\n protected resolve<T>(token: Token<T>, chain: Token<any>[]): T {\n const nextChain = () => [...chain, token];\n\n if (chain.includes(token)) {\n throw new CircularDependencyError(nextChain(), this.toString());\n }\n\n if (this.components.has(token._key)) {\n return this.components.get(token._key) as T;\n }\n\n if (this.providers.has(token._key)) {\n const provider = this.providers.get(token._key) as Provider<T>;\n\n const component = provider(otherToken => this.resolve(otherToken, nextChain()));\n\n // ВАЖНО: всегда как singleton\n this.components.set(token._key, component);\n\n return component as T;\n }\n\n if (this.parent) {\n // ВАЖНО: передаём именно chain а не nextChain()\n return this.parent.resolve(token, chain);\n }\n\n throw new NothingBoundError(token, this.toString());\n }\n\n attach(parent: ApplicationImplementation): void {\n if (this.parent) {\n throw new Error('Cannot reattach application');\n }\n\n this.parent = parent;\n }\n\n preset(preset: Preset): void {\n this.presets.push(preset);\n }\n\n invoke<Tokens extends readonly Token<any>[]>(\n tokens: [...Tokens],\n fn: (...args: ExtractType<Tokens>) => void,\n ): void {\n fn(...(tokens.map(token => this.get(token)) as any));\n }\n}\n\n/**\n * Возвращает новое DI-приложение.\n * @return DI-приложение.\n */\nexport function createApplication(): Application {\n return new ApplicationImplementation();\n}\n"],"mappings":";;;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAHA;;AAKA;AACA;AACA;AACO,MAAME,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG,IAAAE,kBAAW,EAAc,kBAAkB,CAAC;;AAEvE;AACA;AACA;AACA,MAAMC,yBAAyB,CAAwB;EACrD;;EAGA;;EAGA;;EAGA;;EAGA;;EAGAC,WAAWA,CAAA,EAAG;IACZ,IAAI,CAACC,SAAS,GAAG,IAAIC,GAAG,CAAC,CAAC;IAC1B,IAAI,CAACC,UAAU,GAAG,IAAID,GAAG,CAAC,CAAC;IAC3B,IAAI,CAACE,OAAO,GAAG,EAAE;IACjB,IAAI,CAACC,WAAW,GAAG,KAAK;EAC1B;EAEAC,QAAQA,CAAA,EAAG;IACT,OAAO,aAAa;EACtB;EAEAC,IAAIA,CAAIC,KAAe,EAAc;IACnC,IAAI,IAAI,CAACP,SAAS,CAACQ,GAAG,CAACD,KAAK,CAACE,IAAI,CAAC,EAAE;MAClC,MAAM,IAAIC,yBAAiB,CAACH,KAAK,EAAE,IAAI,CAACF,QAAQ,CAAC,CAAC,CAAC;IACrD;IAEA,OAAO;MACLM,OAAO,EAAEC,KAAK,IAAI;QAChB,IAAI,CAACZ,SAAS,CAACa,GAAG,CAACN,KAAK,CAACE,IAAI,EAAE,MAAMG,KAAK,CAAC;MAC7C,CAAC;MACDE,UAAU,EAAEC,QAAQ,IAAI;QACtB,IAAI,CAACf,SAAS,CAACa,GAAG,CAACN,KAAK,CAACE,IAAI,EAAEM,QAAQ,CAAC;MAC1C;IACF,CAAC;EACH;EAEAC,GAAGA,CAAIT,KAAe,EAAK;IACzB,IAAI,CAAC,IAAI,CAACH,WAAW,EAAE;MACrB,IAAI,CAACE,IAAI,CAACX,WAAW,CAAC,CAACgB,OAAO,CAAC,IAAI,CAAC;MAEpC,KAAK,MAAMM,MAAM,IAAI,IAAI,CAACd,OAAO,EAAE;QACjCc,MAAM,CAACC,KAAK,CAAC,IAAI,CAAC;MACpB;MAEA,IAAI,CAACd,WAAW,GAAG,IAAI;IACzB;IAEA,OAAO,IAAI,CAACe,OAAO,CAACZ,KAAK,EAAE,EAAE,CAAC;EAChC;EAEUY,OAAOA,CAAIZ,KAAe,EAAEa,KAAmB,EAAK;IAC5D,MAAMC,SAAS,GAAGA,CAAA,KAAM,CAAC,GAAGD,KAAK,EAAEb,KAAK,CAAC;IAEzC,IAAIa,KAAK,CAACE,QAAQ,CAACf,KAAK,CAAC,EAAE;MACzB,MAAM,IAAIgB,+BAAuB,CAACF,SAAS,CAAC,CAAC,EAAE,IAAI,CAAChB,QAAQ,CAAC,CAAC,CAAC;IACjE;IAEA,IAAI,IAAI,CAACH,UAAU,CAACM,GAAG,CAACD,KAAK,CAACE,IAAI,CAAC,EAAE;MACnC,OAAO,IAAI,CAACP,UAAU,CAACc,GAAG,CAACT,KAAK,CAACE,IAAI,CAAC;IACxC;IAEA,IAAI,IAAI,CAACT,SAAS,CAACQ,GAAG,CAACD,KAAK,CAACE,IAAI,CAAC,EAAE;MAClC,MAAMM,QAAQ,GAAG,IAAI,CAACf,SAAS,CAACgB,GAAG,CAACT,KAAK,CAACE,IAAI,CAAgB;MAE9D,MAAMe,SAAS,GAAGT,QAAQ,CAACU,UAAU,IAAI,IAAI,CAACN,OAAO,CAACM,UAAU,EAAEJ,SAAS,CAAC,CAAC,CAAC,CAAC;;MAE/E;MACA,IAAI,CAACnB,UAAU,CAACW,GAAG,CAACN,KAAK,CAACE,IAAI,EAAEe,SAAS,CAAC;MAE1C,OAAOA,SAAS;IAClB;IAEA,IAAI,IAAI,CAACE,MAAM,EAAE;MACf;MACA,OAAO,IAAI,CAACA,MAAM,CAACP,OAAO,CAACZ,KAAK,EAAEa,KAAK,CAAC;IAC1C;IAEA,MAAM,IAAIO,yBAAiB,CAACpB,KAAK,EAAE,IAAI,CAACF,QAAQ,CAAC,CAAC,CAAC;EACrD;EAEAuB,MAAMA,CAACF,MAAiC,EAAQ;IAC9C,IAAI,IAAI,CAACA,MAAM,EAAE;MACf,MAAM,IAAIG,KAAK,CAAC,6BAA6B,CAAC;IAChD;IAEA,IAAI,CAACH,MAAM,GAAGA,MAAM;EACtB;EAEAT,MAAMA,CAACA,MAAc,EAAQ;IAC3B,IAAI,CAACd,OAAO,CAAC2B,IAAI,CAACb,MAAM,CAAC;EAC3B;EAEAc,MAAMA,CACJC,MAAmB,EACnBC,EAA0C,EACpC;IACNA,EAAE,CAAC,GAAID,MAAM,CAACE,GAAG,CAAC3B,KAAK,IAAI,IAAI,CAACS,GAAG,CAACT,KAAK,CAAC,CAAS,CAAC;EACtD;AACF;;AAEA;AACA;AACA;AACA;AACO,SAAS4B,iBAAiBA,CAAA,EAAgB;EAC/C,OAAO,IAAIrC,yBAAyB,CAAC,CAAC;AACxC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createContainer = createContainer;
|
|
7
|
+
var _errors = require("./errors");
|
|
8
|
+
/* eslint-disable require-jsdoc, jsdoc/require-jsdoc */
|
|
9
|
+
|
|
10
|
+
class ContainerImplementation {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.cache = new Map();
|
|
13
|
+
this.registry = new Map();
|
|
14
|
+
}
|
|
15
|
+
set(token, provider) {
|
|
16
|
+
if (this.registry.has(token._key)) {
|
|
17
|
+
throw new _errors.AlreadyBoundError(token);
|
|
18
|
+
}
|
|
19
|
+
this.registry.set(token._key, provider);
|
|
20
|
+
}
|
|
21
|
+
get(token) {
|
|
22
|
+
return this.resolve(token, []);
|
|
23
|
+
}
|
|
24
|
+
resolve(token, chain) {
|
|
25
|
+
if (chain.includes(token)) {
|
|
26
|
+
throw new _errors.CircularDependencyError([...chain, token]);
|
|
27
|
+
} else {
|
|
28
|
+
chain.push(token);
|
|
29
|
+
}
|
|
30
|
+
if (this.cache.has(token._key)) {
|
|
31
|
+
return this.cache.get(token._key);
|
|
32
|
+
} else if (this.registry.has(token._key)) {
|
|
33
|
+
const provider = this.registry.get(token._key);
|
|
34
|
+
if (typeof provider !== 'function') {
|
|
35
|
+
throw new Error('Provider is not a function');
|
|
36
|
+
}
|
|
37
|
+
const value = provider(otherToken => this.resolve(otherToken, chain));
|
|
38
|
+
|
|
39
|
+
// всегда как singleton
|
|
40
|
+
this.cache.set(token._key, value);
|
|
41
|
+
return value;
|
|
42
|
+
} else {
|
|
43
|
+
throw new _errors.NothingBoundError(token);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Возвращает новый DI-контейнер.
|
|
50
|
+
* @return DI-контейнер.
|
|
51
|
+
*/
|
|
52
|
+
function createContainer() {
|
|
53
|
+
return new ContainerImplementation();
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=container.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container.js","names":["_errors","require","ContainerImplementation","constructor","cache","Map","registry","set","token","provider","has","_key","AlreadyBoundError","get","resolve","chain","includes","CircularDependencyError","push","Error","value","otherToken","NothingBoundError","createContainer"],"sources":["../../../src/di/container.ts"],"sourcesContent":["/* eslint-disable require-jsdoc, jsdoc/require-jsdoc */\nimport type { Container, Provider, Token } from './types';\nimport { AlreadyBoundError, CircularDependencyError, NothingBoundError } from './errors';\n\nclass ContainerImplementation implements Container {\n cache: Map<symbol, any>;\n registry: Map<symbol, Provider<any>>;\n\n constructor() {\n this.cache = new Map<symbol, any>();\n this.registry = new Map<symbol, Provider<any>>();\n }\n\n set<T>(token: Token<T>, provider: Provider<T>): void {\n if (this.registry.has(token._key)) {\n throw new AlreadyBoundError(token);\n }\n\n this.registry.set(token._key, provider);\n }\n\n get<T>(token: Token<T>): T {\n return this.resolve(token, []);\n }\n\n private resolve<T>(token: Token<T>, chain: Token<any>[]): T {\n if (chain.includes(token)) {\n throw new CircularDependencyError([...chain, token]);\n } else {\n chain.push(token);\n }\n\n if (this.cache.has(token._key)) {\n return this.cache.get(token._key);\n } else if (this.registry.has(token._key)) {\n const provider = this.registry.get(token._key);\n\n if (typeof provider !== 'function') {\n throw new Error('Provider is not a function');\n }\n\n const value = provider(otherToken => this.resolve(otherToken, chain));\n\n // всегда как singleton\n this.cache.set(token._key, value);\n\n return value;\n } else {\n throw new NothingBoundError(token);\n }\n }\n}\n\n/**\n * Возвращает новый DI-контейнер.\n * @return DI-контейнер.\n */\nexport function createContainer(): Container {\n return new ContainerImplementation();\n}\n"],"mappings":";;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AAFA;;AAIA,MAAMC,uBAAuB,CAAsB;EAIjDC,WAAWA,CAAA,EAAG;IACZ,IAAI,CAACC,KAAK,GAAG,IAAIC,GAAG,CAAc,CAAC;IACnC,IAAI,CAACC,QAAQ,GAAG,IAAID,GAAG,CAAwB,CAAC;EAClD;EAEAE,GAAGA,CAAIC,KAAe,EAAEC,QAAqB,EAAQ;IACnD,IAAI,IAAI,CAACH,QAAQ,CAACI,GAAG,CAACF,KAAK,CAACG,IAAI,CAAC,EAAE;MACjC,MAAM,IAAIC,yBAAiB,CAACJ,KAAK,CAAC;IACpC;IAEA,IAAI,CAACF,QAAQ,CAACC,GAAG,CAACC,KAAK,CAACG,IAAI,EAAEF,QAAQ,CAAC;EACzC;EAEAI,GAAGA,CAAIL,KAAe,EAAK;IACzB,OAAO,IAAI,CAACM,OAAO,CAACN,KAAK,EAAE,EAAE,CAAC;EAChC;EAEQM,OAAOA,CAAIN,KAAe,EAAEO,KAAmB,EAAK;IAC1D,IAAIA,KAAK,CAACC,QAAQ,CAACR,KAAK,CAAC,EAAE;MACzB,MAAM,IAAIS,+BAAuB,CAAC,CAAC,GAAGF,KAAK,EAAEP,KAAK,CAAC,CAAC;IACtD,CAAC,MAAM;MACLO,KAAK,CAACG,IAAI,CAACV,KAAK,CAAC;IACnB;IAEA,IAAI,IAAI,CAACJ,KAAK,CAACM,GAAG,CAACF,KAAK,CAACG,IAAI,CAAC,EAAE;MAC9B,OAAO,IAAI,CAACP,KAAK,CAACS,GAAG,CAACL,KAAK,CAACG,IAAI,CAAC;IACnC,CAAC,MAAM,IAAI,IAAI,CAACL,QAAQ,CAACI,GAAG,CAACF,KAAK,CAACG,IAAI,CAAC,EAAE;MACxC,MAAMF,QAAQ,GAAG,IAAI,CAACH,QAAQ,CAACO,GAAG,CAACL,KAAK,CAACG,IAAI,CAAC;MAE9C,IAAI,OAAOF,QAAQ,KAAK,UAAU,EAAE;QAClC,MAAM,IAAIU,KAAK,CAAC,4BAA4B,CAAC;MAC/C;MAEA,MAAMC,KAAK,GAAGX,QAAQ,CAACY,UAAU,IAAI,IAAI,CAACP,OAAO,CAACO,UAAU,EAAEN,KAAK,CAAC,CAAC;;MAErE;MACA,IAAI,CAACX,KAAK,CAACG,GAAG,CAACC,KAAK,CAACG,IAAI,EAAES,KAAK,CAAC;MAEjC,OAAOA,KAAK;IACd,CAAC,MAAM;MACL,MAAM,IAAIE,yBAAiB,CAACd,KAAK,CAAC;IACpC;EACF;AACF;;AAEA;AACA;AACA;AACA;AACO,SAASe,eAAeA,CAAA,EAAc;EAC3C,OAAO,IAAIrB,uBAAuB,CAAC,CAAC;AACtC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NothingBoundError = exports.CircularDependencyError = exports.AlreadyBoundError = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Ошибка, сообщающая, что в контейнере нет сервиса по заданному ключу.
|
|
9
|
+
*/
|
|
10
|
+
class NothingBoundError extends Error {
|
|
11
|
+
/**
|
|
12
|
+
* Конструктор.
|
|
13
|
+
* @param token Токен.
|
|
14
|
+
* @param containerName Имя контейнера.
|
|
15
|
+
*/
|
|
16
|
+
constructor(token, containerName) {
|
|
17
|
+
super(`Nothing bound to ${String(token)} in ${display(containerName)}`);
|
|
18
|
+
this.name = 'NothingBoundError';
|
|
19
|
+
this.token = token;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Ошибка, сообщающая, что в контейнере уже зарегистрирован компонент под таким токеном.
|
|
25
|
+
*/
|
|
26
|
+
exports.NothingBoundError = NothingBoundError;
|
|
27
|
+
class AlreadyBoundError extends Error {
|
|
28
|
+
/**
|
|
29
|
+
* Конструктор.
|
|
30
|
+
* @param token Токен.
|
|
31
|
+
* @param containerName Имя контейнера.
|
|
32
|
+
*/
|
|
33
|
+
constructor(token, containerName) {
|
|
34
|
+
super(`Cannot rebind token in ${display(containerName)}, already bound: ${String(token)}`);
|
|
35
|
+
this.name = 'AlreadyBoundError';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Ошибка, сообщающая, что обнаружена циклическая зависимость.
|
|
41
|
+
*/
|
|
42
|
+
exports.AlreadyBoundError = AlreadyBoundError;
|
|
43
|
+
class CircularDependencyError extends Error {
|
|
44
|
+
/**
|
|
45
|
+
* Конструктор.
|
|
46
|
+
* @param trace Список токенов, в котором обнаружен цикл.
|
|
47
|
+
* @param containerName Имя контейнера.
|
|
48
|
+
*/
|
|
49
|
+
constructor(trace, containerName) {
|
|
50
|
+
const names = trace.map(String).join(' >> ');
|
|
51
|
+
super(`Circular dependency found in ${display(containerName)}, trace: ${names}`);
|
|
52
|
+
this.name = 'CircularDependencyError';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Вернёт переданное имя контейнера или заглушку.
|
|
58
|
+
* @param containerName Имя.
|
|
59
|
+
* @return Имя или заглушка.
|
|
60
|
+
*/
|
|
61
|
+
exports.CircularDependencyError = CircularDependencyError;
|
|
62
|
+
function display(containerName) {
|
|
63
|
+
return containerName ?? '[unknown container]';
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","names":["NothingBoundError","Error","constructor","token","containerName","String","display","name","exports","AlreadyBoundError","CircularDependencyError","trace","names","map","join"],"sources":["../../../src/di/errors.ts"],"sourcesContent":["import type { Token } from './types';\n\n/**\n * Ошибка, сообщающая, что в контейнере нет сервиса по заданному ключу.\n */\nexport class NothingBoundError extends Error {\n readonly token: Token<unknown>;\n\n /**\n * Конструктор.\n * @param token Токен.\n * @param containerName Имя контейнера.\n */\n constructor(token: Token<unknown>, containerName?: string) {\n super(`Nothing bound to ${String(token)} in ${display(containerName)}`);\n this.name = 'NothingBoundError';\n this.token = token;\n }\n}\n\n/**\n * Ошибка, сообщающая, что в контейнере уже зарегистрирован компонент под таким токеном.\n */\nexport class AlreadyBoundError extends Error {\n /**\n * Конструктор.\n * @param token Токен.\n * @param containerName Имя контейнера.\n */\n constructor(token: Token<unknown>, containerName?: string) {\n super(`Cannot rebind token in ${display(containerName)}, already bound: ${String(token)}`);\n this.name = 'AlreadyBoundError';\n }\n}\n\n/**\n * Ошибка, сообщающая, что обнаружена циклическая зависимость.\n */\nexport class CircularDependencyError extends Error {\n /**\n * Конструктор.\n * @param trace Список токенов, в котором обнаружен цикл.\n * @param containerName Имя контейнера.\n */\n constructor(trace: Token<unknown>[], containerName?: string) {\n const names = trace.map(String).join(' >> ');\n super(`Circular dependency found in ${display(containerName)}, trace: ${names}`);\n this.name = 'CircularDependencyError';\n }\n}\n\n/**\n * Вернёт переданное имя контейнера или заглушку.\n * @param containerName Имя.\n * @return Имя или заглушка.\n */\nfunction display(containerName?: string) {\n return containerName ?? '[unknown container]';\n}\n"],"mappings":";;;;;;AAEA;AACA;AACA;AACO,MAAMA,iBAAiB,SAASC,KAAK,CAAC;EAG3C;AACF;AACA;AACA;AACA;EACEC,WAAWA,CAACC,KAAqB,EAAEC,aAAsB,EAAE;IACzD,KAAK,CAAE,oBAAmBC,MAAM,CAACF,KAAK,CAAE,OAAMG,OAAO,CAACF,aAAa,CAAE,EAAC,CAAC;IACvE,IAAI,CAACG,IAAI,GAAG,mBAAmB;IAC/B,IAAI,CAACJ,KAAK,GAAGA,KAAK;EACpB;AACF;;AAEA;AACA;AACA;AAFAK,OAAA,CAAAR,iBAAA,GAAAA,iBAAA;AAGO,MAAMS,iBAAiB,SAASR,KAAK,CAAC;EAC3C;AACF;AACA;AACA;AACA;EACEC,WAAWA,CAACC,KAAqB,EAAEC,aAAsB,EAAE;IACzD,KAAK,CAAE,0BAAyBE,OAAO,CAACF,aAAa,CAAE,oBAAmBC,MAAM,CAACF,KAAK,CAAE,EAAC,CAAC;IAC1F,IAAI,CAACI,IAAI,GAAG,mBAAmB;EACjC;AACF;;AAEA;AACA;AACA;AAFAC,OAAA,CAAAC,iBAAA,GAAAA,iBAAA;AAGO,MAAMC,uBAAuB,SAAST,KAAK,CAAC;EACjD;AACF;AACA;AACA;AACA;EACEC,WAAWA,CAACS,KAAuB,EAAEP,aAAsB,EAAE;IAC3D,MAAMQ,KAAK,GAAGD,KAAK,CAACE,GAAG,CAACR,MAAM,CAAC,CAACS,IAAI,CAAC,MAAM,CAAC;IAC5C,KAAK,CAAE,gCAA+BR,OAAO,CAACF,aAAa,CAAE,YAAWQ,KAAM,EAAC,CAAC;IAChF,IAAI,CAACL,IAAI,GAAG,yBAAyB;EACvC;AACF;;AAEA;AACA;AACA;AACA;AACA;AAJAC,OAAA,CAAAE,uBAAA,GAAAA,uBAAA;AAKA,SAASJ,OAAOA,CAACF,aAAsB,EAAE;EACvC,OAAOA,aAAa,IAAI,qBAAqB;AAC/C"}
|