oak-domain 6.0.0 → 6.1.0
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/README.md +5 -1
- package/es/actions/action.d.ts +1 -1
- package/es/base-app-domain/EntityDict.d.ts +27 -0
- package/es/base-app-domain/LocalizedContent/Schema.d.ts +19 -0
- package/es/base-app-domain/LocalizedContent/Schema.js +1 -0
- package/es/base-app-domain/LocalizedContent/Storage.d.ts +3 -0
- package/es/base-app-domain/LocalizedContent/Storage.js +75 -0
- package/es/base-app-domain/LocalizedContent/Style.d.ts +3 -0
- package/es/base-app-domain/LocalizedContent/Style.js +12 -0
- package/es/base-app-domain/LocalizedContent/_baseSchema.d.ts +58 -0
- package/es/base-app-domain/Storage.js +2 -0
- package/es/base-app-domain/StyleDict.js +2 -0
- package/es/compiler/customChecks/i18n.js +4 -1
- package/es/compiler/customChecks/runner.d.ts +1 -1
- package/es/compiler/customChecks/runner.js +1 -1
- package/es/compiler/customChecks/types.d.ts +2 -1
- package/es/compiler/dependencyBuilder.d.ts +11 -2
- package/es/compiler/dependencyBuilder.js +188 -199
- package/es/compiler/entityDescEnum.d.ts +5 -0
- package/es/compiler/entityDescEnum.js +443 -0
- package/es/compiler/entitySource.d.ts +28 -0
- package/es/compiler/entitySource.js +521 -0
- package/es/compiler/localeBuilder.d.ts +7 -2
- package/es/compiler/localeBuilder.js +52 -56
- package/es/compiler/routerBuilder.d.ts +32 -3
- package/es/compiler/routerBuilder.js +157 -45
- package/es/compiler/schemaBuilder.d.ts +12 -2
- package/es/compiler/schemaBuilder.js +653 -148
- package/es/compiler/tscBuilder.d.ts +20 -2
- package/es/compiler/tscBuilder.js +231 -45
- package/es/context/BackendRuntimeContext.d.ts +6 -4
- package/es/context/BackendRuntimeContext.js +9 -1
- package/es/context/ContextComposer.d.ts +93 -0
- package/es/context/ContextComposer.js +353 -0
- package/es/context/SerializedData.d.ts +2 -1
- package/es/data/i18n.d.ts +1 -1
- package/es/data/i18n.js +1 -86
- package/es/data/i18n.json +86 -0
- package/es/entities/ActionAuth.d.ts +3 -3
- package/es/entities/I18n.d.ts +2 -2
- package/es/entities/LocalizedContent.d.ts +22 -0
- package/es/entities/LocalizedContent.js +101 -0
- package/es/entities/Log.d.ts +3 -3
- package/es/entities/Modi.d.ts +2 -2
- package/es/entities/ModiEntity.d.ts +3 -3
- package/es/entities/Oper.d.ts +5 -5
- package/es/entities/OperEntity.d.ts +3 -3
- package/es/entities/Path.d.ts +2 -2
- package/es/entities/Relation.d.ts +2 -2
- package/es/entities/RelationAuth.d.ts +3 -3
- package/es/entities/User.d.ts +4 -4
- package/es/entities/UserEntityClaim.d.ts +6 -6
- package/es/entities/UserEntityGrant.d.ts +2 -2
- package/es/entities/UserRelation.d.ts +4 -4
- package/es/store/AsyncRowStore.d.ts +2 -2
- package/es/store/AsyncRowStore.js +2 -2
- package/es/store/CascadeStore.d.ts +5 -3
- package/es/store/CascadeStore.js +56 -24
- package/es/store/IntrinsicCheckers.d.ts +1 -1
- package/es/store/IntrinsicCheckers.js +2 -2
- package/es/store/IntrinsicLogics.d.ts +1 -1
- package/es/store/RelationAuth.js +3 -3
- package/es/store/SyncRowStore.d.ts +1 -1
- package/es/store/SyncRowStore.js +1 -1
- package/es/store/TriggerExecutor.d.ts +6 -4
- package/es/store/TriggerExecutor.js +16 -4
- package/es/store/checker.d.ts +2 -2
- package/es/store/checker.js +45 -9
- package/es/store/filter.d.ts +3 -3
- package/es/store/filter.js +4 -4
- package/es/store/modi.d.ts +5 -5
- package/es/store/modi.js +4 -4
- package/es/store/projection.d.ts +1 -1
- package/es/store/relation.js +1 -1
- package/es/store/triggers.d.ts +4 -4
- package/es/store/triggers.js +2 -2
- package/es/timers/oper.d.ts +3 -3
- package/es/timers/oper.js +1 -1
- package/es/timers/vaccum.d.ts +3 -3
- package/es/types/Action.d.ts +1 -1
- package/es/types/AppLoader.d.ts +1 -1
- package/es/types/Aspect.d.ts +1 -1
- package/es/types/Auth.d.ts +2 -2
- package/es/types/Configuration.d.ts +7 -6
- package/es/types/Connector.d.ts +47 -1
- package/es/types/DataType.d.ts +2 -2
- package/es/types/Demand.d.ts +40 -6
- package/es/types/Endpoint.d.ts +17 -1
- package/es/types/Entity.d.ts +21 -4
- package/es/types/Entity.js +23 -0
- package/es/types/EntityDesc.d.ts +9 -8
- package/es/types/Environment.d.ts +17 -0
- package/es/types/Exception.d.ts +1 -1
- package/es/types/Exception.js +1 -1
- package/es/types/Expression.d.ts +13 -2
- package/es/types/Expression.js +36 -1
- package/es/types/Locale.d.ts +14 -1
- package/es/types/Locale.js +13 -1
- package/es/types/OakPackage.d.ts +29 -0
- package/es/types/OakPackage.js +30 -0
- package/es/types/Port.d.ts +1 -1
- package/es/types/RowStore.d.ts +9 -7
- package/es/types/Storage.d.ts +11 -3
- package/es/types/Storage.js +12 -1
- package/es/types/Style.d.ts +2 -2
- package/es/types/Sync.d.ts +3 -3
- package/es/types/Timer.d.ts +14 -2
- package/es/types/Trigger.d.ts +1 -1
- package/es/types/Watcher.d.ts +1 -1
- package/es/types/index.d.ts +1 -0
- package/es/types/index.js +1 -0
- package/es/utils/SimpleConnector.d.ts +30 -4
- package/es/utils/SimpleConnector.js +294 -21
- package/es/utils/concurrent.js +1 -1
- package/es/utils/decimal.d.ts +26 -0
- package/es/utils/decimal.js +87 -0
- package/es/utils/fetch/index.d.ts +1 -0
- package/es/utils/fetch/index.js +3 -0
- package/es/utils/fetch/index.mp.d.ts +3 -0
- package/es/utils/fetch/index.mp.js +280 -0
- package/es/utils/fetch/index.native.d.ts +1 -0
- package/es/utils/fetch/index.native.js +3 -0
- package/es/utils/fetch/index.web.d.ts +1 -0
- package/es/utils/fetch/index.web.js +3 -0
- package/es/utils/fetch/shared.d.ts +6 -0
- package/es/utils/fetch/shared.js +23 -0
- package/es/utils/localizedContent.d.ts +11 -0
- package/es/utils/localizedContent.js +346 -0
- package/es/utils/lodash.d.ts +1 -35
- package/es/utils/lodash.js +1 -52
- package/es/utils/module/combine.common.d.ts +3 -3
- package/es/utils/module/combine.common.js +2 -2
- package/es/utils/module/combine.dev.d.ts +2 -2
- package/es/utils/module/combine.dev.js +2 -2
- package/es/utils/module/combine.prod.d.ts +1 -1
- package/es/utils/module/combine.server.d.ts +2 -2
- package/es/utils/module/combine.server.js +2 -2
- package/es/utils/money.d.ts +2 -2
- package/es/utils/money.js +2 -2
- package/es/utils/operationResult.js +1 -1
- package/es/utils/projection.d.ts +3 -3
- package/es/utils/projection.js +1 -1
- package/es/utils/relationPath.d.ts +1 -1
- package/es/utils/relationPath.js +1 -1
- package/es/utils/row.d.ts +3 -3
- package/es/utils/row.js +2 -2
- package/es/utils/sseEndpoint.d.ts +41 -0
- package/es/utils/sseEndpoint.js +151 -0
- package/es/utils/toolkit.d.ts +28 -0
- package/es/utils/toolkit.js +220 -0
- package/es/utils/url/index.d.ts +1 -3
- package/es/utils/url/index.js +1 -1
- package/es/utils/url/index.mp.d.ts +16 -3
- package/es/utils/url/index.mp.js +2 -2
- package/es/utils/url/index.native.d.ts +13 -1
- package/es/utils/url/index.native.js +3 -1
- package/es/utils/url/index.web.d.ts +13 -1
- package/es/utils/url/index.web.js +3 -1
- package/es/utils/url/lightweight.d.ts +65 -0
- package/es/utils/url/lightweight.js +530 -0
- package/es/utils/url/urlObject.d.ts +16 -0
- package/es/utils/validate/id.d.ts +5 -0
- package/es/utils/validate/id.js +28 -0
- package/es/utils/validate/index.d.ts +4 -0
- package/es/utils/validate/index.js +4 -0
- package/es/utils/validate/mobile.d.ts +6 -0
- package/es/utils/validate/mobile.js +49 -0
- package/es/utils/validate/nationality.d.ts +14 -0
- package/es/utils/validate/nationality.data.d.ts +9 -0
- package/es/utils/validate/nationality.data.js +257 -0
- package/es/utils/validate/nationality.js +64 -0
- package/es/utils/validate/passport.d.ts +3 -0
- package/es/utils/validate/passport.js +19 -0
- package/es/utils/validator.d.ts +10 -8
- package/es/utils/validator.js +24 -40
- package/lib/actions/action.d.ts +1 -1
- package/lib/base-app-domain/EntityDict.d.ts +27 -0
- package/lib/base-app-domain/LocalizedContent/Schema.d.ts +19 -0
- package/lib/base-app-domain/LocalizedContent/Schema.js +4 -0
- package/lib/base-app-domain/LocalizedContent/Storage.d.ts +3 -0
- package/lib/base-app-domain/LocalizedContent/Storage.js +78 -0
- package/lib/base-app-domain/LocalizedContent/Style.d.ts +3 -0
- package/lib/base-app-domain/LocalizedContent/Style.js +15 -0
- package/lib/base-app-domain/LocalizedContent/_baseSchema.d.ts +58 -0
- package/lib/base-app-domain/Storage.js +26 -24
- package/lib/base-app-domain/StyleDict.js +10 -8
- package/lib/compiler/customChecks/i18n.js +5 -2
- package/lib/compiler/customChecks/runner.d.ts +1 -1
- package/lib/compiler/customChecks/types.d.ts +2 -1
- package/lib/compiler/dependencyBuilder.d.ts +11 -2
- package/lib/compiler/dependencyBuilder.js +237 -243
- package/lib/compiler/entityDescEnum.d.ts +5 -0
- package/lib/compiler/entityDescEnum.js +450 -0
- package/lib/compiler/entitySource.d.ts +28 -0
- package/lib/compiler/entitySource.js +529 -0
- package/lib/compiler/localeBuilder.d.ts +7 -2
- package/lib/compiler/localeBuilder.js +52 -56
- package/lib/compiler/routerBuilder.d.ts +32 -3
- package/lib/compiler/routerBuilder.js +160 -48
- package/lib/compiler/schemaBuilder.d.ts +12 -2
- package/lib/compiler/schemaBuilder.js +855 -350
- package/lib/compiler/tscBuilder.d.ts +20 -2
- package/lib/compiler/tscBuilder.js +217 -37
- package/lib/context/BackendRuntimeContext.d.ts +6 -4
- package/lib/context/BackendRuntimeContext.js +10 -3
- package/lib/context/ContextComposer.d.ts +93 -0
- package/lib/context/ContextComposer.js +361 -0
- package/lib/context/SerializedData.d.ts +2 -1
- package/lib/data/i18n.d.ts +1 -1
- package/lib/data/i18n.js +1 -86
- package/lib/data/i18n.json +86 -0
- package/lib/entities/ActionAuth.d.ts +3 -3
- package/lib/entities/I18n.d.ts +2 -2
- package/lib/entities/LocalizedContent.d.ts +22 -0
- package/lib/entities/LocalizedContent.js +104 -0
- package/lib/entities/Log.d.ts +3 -3
- package/lib/entities/Modi.d.ts +2 -2
- package/lib/entities/ModiEntity.d.ts +3 -3
- package/lib/entities/Oper.d.ts +5 -5
- package/lib/entities/OperEntity.d.ts +3 -3
- package/lib/entities/Path.d.ts +2 -2
- package/lib/entities/Relation.d.ts +2 -2
- package/lib/entities/RelationAuth.d.ts +3 -3
- package/lib/entities/User.d.ts +4 -4
- package/lib/entities/UserEntityClaim.d.ts +6 -6
- package/lib/entities/UserEntityGrant.d.ts +2 -2
- package/lib/entities/UserRelation.d.ts +4 -4
- package/lib/store/AsyncRowStore.d.ts +2 -2
- package/lib/store/AsyncRowStore.js +6 -7
- package/lib/store/CascadeStore.d.ts +5 -3
- package/lib/store/CascadeStore.js +101 -70
- package/lib/store/IntrinsicCheckers.d.ts +1 -1
- package/lib/store/IntrinsicCheckers.js +12 -13
- package/lib/store/IntrinsicLogics.d.ts +1 -1
- package/lib/store/RelationAuth.js +42 -43
- package/lib/store/SyncRowStore.d.ts +1 -1
- package/lib/store/SyncRowStore.js +4 -5
- package/lib/store/TriggerExecutor.d.ts +6 -4
- package/lib/store/TriggerExecutor.js +39 -28
- package/lib/store/checker.d.ts +2 -2
- package/lib/store/checker.js +55 -20
- package/lib/store/filter.d.ts +3 -3
- package/lib/store/filter.js +47 -48
- package/lib/store/modi.d.ts +5 -5
- package/lib/store/modi.js +5 -6
- package/lib/store/projection.d.ts +1 -1
- package/lib/store/relation.js +4 -5
- package/lib/store/triggers.d.ts +4 -4
- package/lib/store/triggers.js +13 -14
- package/lib/timers/oper.d.ts +3 -3
- package/lib/timers/vaccum.d.ts +3 -3
- package/lib/types/Action.d.ts +1 -1
- package/lib/types/AppLoader.d.ts +1 -1
- package/lib/types/Aspect.d.ts +1 -1
- package/lib/types/Auth.d.ts +2 -2
- package/lib/types/Configuration.d.ts +7 -6
- package/lib/types/Connector.d.ts +47 -1
- package/lib/types/DataType.d.ts +2 -2
- package/lib/types/Demand.d.ts +40 -6
- package/lib/types/Endpoint.d.ts +17 -1
- package/lib/types/Entity.d.ts +21 -4
- package/lib/types/Entity.js +27 -0
- package/lib/types/EntityDesc.d.ts +9 -8
- package/lib/types/Environment.d.ts +17 -0
- package/lib/types/Exception.d.ts +1 -1
- package/lib/types/Exception.js +2 -2
- package/lib/types/Expression.d.ts +13 -2
- package/lib/types/Expression.js +40 -5
- package/lib/types/Locale.d.ts +14 -1
- package/lib/types/Locale.js +14 -0
- package/lib/types/OakPackage.d.ts +29 -0
- package/lib/types/OakPackage.js +36 -0
- package/lib/types/Port.d.ts +1 -1
- package/lib/types/RowStore.d.ts +9 -7
- package/lib/types/Storage.d.ts +11 -3
- package/lib/types/Storage.js +13 -0
- package/lib/types/Style.d.ts +2 -2
- package/lib/types/Sync.d.ts +3 -3
- package/lib/types/Timer.d.ts +14 -2
- package/lib/types/Trigger.d.ts +1 -1
- package/lib/types/Watcher.d.ts +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/utils/SimpleConnector.d.ts +30 -4
- package/lib/utils/SimpleConnector.js +297 -24
- package/lib/utils/concurrent.js +4 -5
- package/lib/utils/decimal.d.ts +26 -0
- package/lib/utils/decimal.js +112 -0
- package/lib/utils/fetch/index.d.ts +1 -0
- package/lib/utils/fetch/index.js +6 -0
- package/lib/utils/fetch/index.mp.d.ts +3 -0
- package/lib/utils/fetch/index.mp.js +285 -0
- package/lib/utils/fetch/index.native.d.ts +1 -0
- package/lib/utils/fetch/index.native.js +6 -0
- package/lib/utils/fetch/index.web.d.ts +1 -0
- package/lib/utils/fetch/index.web.js +6 -0
- package/lib/utils/fetch/shared.d.ts +6 -0
- package/lib/utils/fetch/shared.js +28 -0
- package/lib/utils/localizedContent.d.ts +11 -0
- package/lib/utils/localizedContent.js +352 -0
- package/lib/utils/lodash.d.ts +1 -35
- package/lib/utils/lodash.js +1 -76
- package/lib/utils/module/combine.common.d.ts +3 -3
- package/lib/utils/module/combine.common.js +6 -7
- package/lib/utils/module/combine.dev.d.ts +2 -2
- package/lib/utils/module/combine.dev.js +19 -19
- package/lib/utils/module/combine.prod.d.ts +1 -1
- package/lib/utils/module/combine.server.d.ts +2 -2
- package/lib/utils/module/combine.server.js +19 -19
- package/lib/utils/money.d.ts +2 -2
- package/lib/utils/money.js +2 -2
- package/lib/utils/operationResult.js +4 -4
- package/lib/utils/projection.d.ts +3 -3
- package/lib/utils/relationPath.d.ts +1 -1
- package/lib/utils/relationPath.js +10 -11
- package/lib/utils/row.d.ts +3 -3
- package/lib/utils/row.js +4 -5
- package/lib/utils/sseEndpoint.d.ts +41 -0
- package/lib/utils/sseEndpoint.js +156 -0
- package/lib/utils/toolkit.d.ts +28 -0
- package/lib/utils/toolkit.js +253 -0
- package/lib/utils/url/index.d.ts +1 -3
- package/lib/utils/url/index.js +3 -1
- package/lib/utils/url/index.mp.d.ts +16 -3
- package/lib/utils/url/index.mp.js +6 -4
- package/lib/utils/url/index.native.d.ts +13 -1
- package/lib/utils/url/index.native.js +5 -1
- package/lib/utils/url/index.web.d.ts +13 -1
- package/lib/utils/url/index.web.js +5 -1
- package/lib/utils/url/lightweight.d.ts +65 -0
- package/lib/utils/url/lightweight.js +535 -0
- package/lib/utils/url/urlObject.d.ts +16 -0
- package/lib/utils/url/urlObject.js +2 -0
- package/lib/utils/url/whatwg-url/lib/URL-impl.d.ts +8 -15
- package/lib/utils/url/whatwg-url/lib/infra.js +5 -4
- package/lib/utils/url/whatwg-url/lib/urlencoded.d.ts +3 -1
- package/lib/utils/url/whatwg-url/lib/utils.d.ts +1 -1
- package/lib/utils/validate/id.d.ts +5 -0
- package/lib/utils/validate/id.js +35 -0
- package/lib/utils/validate/index.d.ts +4 -0
- package/lib/utils/validate/index.js +7 -0
- package/lib/utils/validate/mobile.d.ts +6 -0
- package/lib/utils/validate/mobile.js +57 -0
- package/lib/utils/validate/nationality.d.ts +14 -0
- package/lib/utils/validate/nationality.data.d.ts +9 -0
- package/lib/utils/validate/nationality.data.js +260 -0
- package/lib/utils/validate/nationality.js +76 -0
- package/lib/utils/validate/passport.d.ts +3 -0
- package/lib/utils/validate/passport.js +24 -0
- package/lib/utils/validator.d.ts +10 -8
- package/lib/utils/validator.js +38 -42
- package/package.json +19 -9
- package/es/utils/url/whatwg-url/index.d.ts +0 -3
- package/es/utils/url/whatwg-url/index.js +0 -12
- package/es/utils/url/whatwg-url/lib/URL-impl.d.ts +0 -27
- package/es/utils/url/whatwg-url/lib/URL-impl.js +0 -172
- package/es/utils/url/whatwg-url/lib/URL.js +0 -295
- package/es/utils/url/whatwg-url/lib/URLSearchParams-impl.d.ts +0 -19
- package/es/utils/url/whatwg-url/lib/URLSearchParams-impl.js +0 -123
- package/es/utils/url/whatwg-url/lib/URLSearchParams.js +0 -423
- package/es/utils/url/whatwg-url/lib/infra.d.ts +0 -12
- package/es/utils/url/whatwg-url/lib/infra.js +0 -19
- package/es/utils/url/whatwg-url/lib/url-state-machine.d.ts +0 -24
- package/es/utils/url/whatwg-url/lib/url-state-machine.js +0 -1228
- package/es/utils/url/whatwg-url/lib/urlencoded.d.ts +0 -14
- package/es/utils/url/whatwg-url/lib/urlencoded.js +0 -160
- package/es/utils/url/whatwg-url/lib/utils.d.ts +0 -37
- package/es/utils/url/whatwg-url/lib/utils.js +0 -99
- package/lib/store/diffSchema.d.ts +0 -1
- package/lib/utils/url/whatwg-url/index.d.ts +0 -3
- package/lib/utils/url/whatwg-url/index.js +0 -16
- package/lib/utils/url/whatwg-url/lib/URL-impl.js +0 -175
- package/lib/utils/url/whatwg-url/lib/URL.d.ts +0 -1
- package/lib/utils/url/whatwg-url/lib/URL.js +0 -298
- package/lib/utils/url/whatwg-url/lib/URLSearchParams-impl.d.ts +0 -19
- package/lib/utils/url/whatwg-url/lib/URLSearchParams-impl.js +0 -126
- package/lib/utils/url/whatwg-url/lib/URLSearchParams.d.ts +0 -1
- package/lib/utils/url/whatwg-url/lib/URLSearchParams.js +0 -426
- package/lib/utils/url/whatwg-url/lib/infra.d.ts +0 -12
- package/lib/utils/url/whatwg-url/lib/url-state-machine.d.ts +0 -24
- package/lib/utils/url/whatwg-url/lib/url-state-machine.js +0 -1238
- package/lib/utils/url/whatwg-url/lib/urlencoded.js +0 -162
- package/lib/utils/url/whatwg-url/lib/utils.js +0 -101
- package/src/entities/ActionAuth.ts +0 -50
- package/src/entities/I18n.ts +0 -53
- package/src/entities/Log.ts +0 -62
- package/src/entities/Modi.ts +0 -107
- package/src/entities/ModiEntity.ts +0 -35
- package/src/entities/Oper.ts +0 -115
- package/src/entities/OperEntity.ts +0 -36
- package/src/entities/Path.ts +0 -56
- package/src/entities/Relation.ts +0 -53
- package/src/entities/RelationAuth.ts +0 -53
- package/src/entities/User.ts +0 -85
- package/src/entities/UserEntityClaim.ts +0 -41
- package/src/entities/UserEntityGrant.ts +0 -33
- package/src/entities/UserRelation.ts +0 -60
- /package/es/{utils/url/whatwg-url/lib/URL.d.ts → base-app-domain/LocalizedContent/_baseSchema.js} +0 -0
- /package/es/utils/url/{whatwg-url/lib/URLSearchParams.d.ts → urlObject.js} +0 -0
- /package/lib/{store/diffSchema.js → base-app-domain/LocalizedContent/_baseSchema.js} +0 -0
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
|
-
import {
|
|
2
|
+
import { CustomDiagnostic, ExtendedTsConfig, OAK_IGNORE_TAGS, performCustomChecks } from './customChecks';
|
|
3
3
|
export type CompileOptions = {
|
|
4
|
+
compilerPlugins?: readonly TscCompilerPlugin[];
|
|
4
5
|
project?: string;
|
|
5
6
|
noEmit?: boolean;
|
|
6
7
|
skipExtraCheck?: boolean;
|
|
7
8
|
skipEmitDiagnostics?: boolean;
|
|
8
9
|
watch?: boolean;
|
|
9
10
|
};
|
|
11
|
+
export interface TscCompilerPluginContext {
|
|
12
|
+
compilerOptions: ts.CompilerOptions;
|
|
13
|
+
host: ts.CompilerHost;
|
|
14
|
+
oldProgram?: ts.Program;
|
|
15
|
+
projectReferences?: readonly ts.ProjectReference[];
|
|
16
|
+
rootNames: readonly string[];
|
|
17
|
+
typescript: typeof ts;
|
|
18
|
+
watch: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface TscCompilerPluginEnvironment {
|
|
21
|
+
host?: ts.CompilerHost;
|
|
22
|
+
mapDiagnostic?: (diagnostic: ts.Diagnostic) => ts.Diagnostic | undefined;
|
|
23
|
+
rootNames?: readonly string[];
|
|
24
|
+
}
|
|
25
|
+
export interface TscCompilerPlugin {
|
|
26
|
+
prepareProgram: (context: TscCompilerPluginContext) => TscCompilerPluginEnvironment;
|
|
27
|
+
}
|
|
10
28
|
type PathAliasImportRule = {
|
|
11
29
|
aliasKey: string;
|
|
12
30
|
preferredSpecifier: string;
|
|
@@ -25,5 +43,5 @@ export declare function createPathAliasEmitRewriter(configPath: string): {
|
|
|
25
43
|
createWriteFile: (baseWriteFile?: ts.WriteFileCallback) => ts.WriteFileCallback;
|
|
26
44
|
};
|
|
27
45
|
declare function collectPathAliasImportDiagnostics(program: ts.Program, rules: PathAliasImportRule[], changedFiles?: Set<string>): CustomDiagnostic[];
|
|
28
|
-
export declare const build: (pwd: string, args: any[]) => void;
|
|
46
|
+
export declare const build: (pwd: string, args: any[], compilerPlugins?: readonly TscCompilerPlugin[]) => void;
|
|
29
47
|
export { performCustomChecks, OAK_IGNORE_TAGS, buildPathAliasImportRules, collectPathAliasImportDiagnostics, type CustomDiagnostic, type ExtendedTsConfig, };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
import * as ts from 'typescript';
|
|
4
|
-
import { CustomCheckState, OAK_IGNORE_TAGS, performCustomChecks
|
|
4
|
+
import { CustomCheckState, OAK_IGNORE_TAGS, performCustomChecks } from './customChecks';
|
|
5
5
|
const colors = {
|
|
6
6
|
reset: '\x1b[0m',
|
|
7
7
|
cyan: '\x1b[36m',
|
|
@@ -10,6 +10,9 @@ const colors = {
|
|
|
10
10
|
gray: '\x1b[90m',
|
|
11
11
|
green: '\x1b[92m',
|
|
12
12
|
};
|
|
13
|
+
function normalizeConfigPath(configPath) {
|
|
14
|
+
return path.resolve(configPath).replace(/\\/g, '/');
|
|
15
|
+
}
|
|
13
16
|
const PATH_ALIAS_IMPORT_WARNING_CODE = 9400;
|
|
14
17
|
function sendWatchIpcMessage(message) {
|
|
15
18
|
if (typeof process.send === 'function') {
|
|
@@ -100,6 +103,47 @@ function normalizeModulePathSegment(value) {
|
|
|
100
103
|
function stripKnownModuleExtension(value) {
|
|
101
104
|
return value.replace(/(\.d)?\.[cm]?[jt]sx?$/i, '');
|
|
102
105
|
}
|
|
106
|
+
function isRelativeModuleSpecifier(value) {
|
|
107
|
+
return value.startsWith('./') || value.startsWith('../');
|
|
108
|
+
}
|
|
109
|
+
function isJsonModuleSpecifier(value) {
|
|
110
|
+
return /\.json$/i.test(value);
|
|
111
|
+
}
|
|
112
|
+
function isDeclarationSourceFile(sourceFile) {
|
|
113
|
+
return /\.d\.[cm]?ts$/i.test(sourceFile.fileName);
|
|
114
|
+
}
|
|
115
|
+
function getCommonDirectory(fileNames) {
|
|
116
|
+
if (fileNames.length === 0) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const normalizedDirectories = fileNames.map((fileName) => path.resolve(path.dirname(fileName)));
|
|
120
|
+
const [firstDirectory, ...restDirectories] = normalizedDirectories;
|
|
121
|
+
const root = path.parse(firstDirectory).root;
|
|
122
|
+
let commonParts = firstDirectory.slice(root.length).split(path.sep).filter(Boolean);
|
|
123
|
+
restDirectories.forEach((directory) => {
|
|
124
|
+
if (path.parse(directory).root.toLowerCase() !== root.toLowerCase()) {
|
|
125
|
+
commonParts = [];
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const parts = directory.slice(root.length).split(path.sep).filter(Boolean);
|
|
129
|
+
let index = 0;
|
|
130
|
+
while (index < commonParts.length &&
|
|
131
|
+
index < parts.length &&
|
|
132
|
+
commonParts[index].toLowerCase() === parts[index].toLowerCase()) {
|
|
133
|
+
index++;
|
|
134
|
+
}
|
|
135
|
+
commonParts = commonParts.slice(0, index);
|
|
136
|
+
});
|
|
137
|
+
return path.join(root, ...commonParts);
|
|
138
|
+
}
|
|
139
|
+
function getCommonSourceDirectory(program) {
|
|
140
|
+
return getCommonDirectory(program
|
|
141
|
+
.getSourceFiles()
|
|
142
|
+
.filter((sourceFile) => (!sourceFile.isDeclarationFile &&
|
|
143
|
+
!isDeclarationSourceFile(sourceFile) &&
|
|
144
|
+
!normalizeModulePathSegment(sourceFile.fileName).includes('/node_modules/')))
|
|
145
|
+
.map((sourceFile) => sourceFile.fileName));
|
|
146
|
+
}
|
|
103
147
|
function stripTrailingWildcard(value) {
|
|
104
148
|
if (value.endsWith('/*')) {
|
|
105
149
|
return {
|
|
@@ -127,6 +171,75 @@ function extractPackageSpecifierFromPathAliasTarget(target) {
|
|
|
127
171
|
}
|
|
128
172
|
return normalizedTarget.slice(markerIndex + marker.length);
|
|
129
173
|
}
|
|
174
|
+
function resolveOutputFileForSourceAsset(program, parsedConfig, sourceFileName) {
|
|
175
|
+
const { outDir } = parsedConfig.options;
|
|
176
|
+
const rootDir = parsedConfig.options.rootDir || getCommonSourceDirectory(program);
|
|
177
|
+
if (!rootDir || !outDir) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const absoluteSourceFileName = path.resolve(sourceFileName);
|
|
181
|
+
const relativePath = path.relative(path.resolve(rootDir), absoluteSourceFileName);
|
|
182
|
+
if (!relativePath ||
|
|
183
|
+
relativePath.startsWith('..') ||
|
|
184
|
+
path.isAbsolute(relativePath)) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
return path.resolve(outDir, relativePath);
|
|
188
|
+
}
|
|
189
|
+
function collectRuntimeJsonAssets(program, parsedConfig) {
|
|
190
|
+
const assets = new Map();
|
|
191
|
+
const addAsset = (containingSourceFile, specifier) => {
|
|
192
|
+
if (!isRelativeModuleSpecifier(specifier) || !isJsonModuleSpecifier(specifier)) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const sourceFileName = path.resolve(path.dirname(containingSourceFile.fileName), specifier);
|
|
196
|
+
if (!fs.existsSync(sourceFileName) || !fs.statSync(sourceFileName).isFile()) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const outputFileName = resolveOutputFileForSourceAsset(program, parsedConfig, sourceFileName);
|
|
200
|
+
if (!outputFileName) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
assets.set(path.normalize(sourceFileName), {
|
|
204
|
+
sourceFileName,
|
|
205
|
+
outputFileName,
|
|
206
|
+
});
|
|
207
|
+
};
|
|
208
|
+
program.getSourceFiles().forEach((sourceFile) => {
|
|
209
|
+
if (sourceFile.isDeclarationFile || isDeclarationSourceFile(sourceFile)) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const visit = (node) => {
|
|
213
|
+
if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier)) {
|
|
214
|
+
addAsset(sourceFile, node.moduleSpecifier.text);
|
|
215
|
+
}
|
|
216
|
+
else if (ts.isExportDeclaration(node) &&
|
|
217
|
+
node.moduleSpecifier &&
|
|
218
|
+
ts.isStringLiteral(node.moduleSpecifier)) {
|
|
219
|
+
addAsset(sourceFile, node.moduleSpecifier.text);
|
|
220
|
+
}
|
|
221
|
+
else if (ts.isCallExpression(node) &&
|
|
222
|
+
node.arguments.length > 0 &&
|
|
223
|
+
ts.isStringLiteral(node.arguments[0]) &&
|
|
224
|
+
((ts.isIdentifier(node.expression) && node.expression.text === 'require') ||
|
|
225
|
+
node.expression.kind === ts.SyntaxKind.ImportKeyword)) {
|
|
226
|
+
addAsset(sourceFile, node.arguments[0].text);
|
|
227
|
+
}
|
|
228
|
+
ts.forEachChild(node, visit);
|
|
229
|
+
};
|
|
230
|
+
visit(sourceFile);
|
|
231
|
+
});
|
|
232
|
+
return Array.from(assets.values());
|
|
233
|
+
}
|
|
234
|
+
function copyRuntimeJsonAssets(program, parsedConfig, options) {
|
|
235
|
+
if (options.noEmit || parsedConfig.options.noEmit) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
collectRuntimeJsonAssets(program, parsedConfig).forEach(({ sourceFileName, outputFileName }) => {
|
|
239
|
+
fs.mkdirSync(path.dirname(outputFileName), { recursive: true });
|
|
240
|
+
fs.copyFileSync(sourceFileName, outputFileName);
|
|
241
|
+
});
|
|
242
|
+
}
|
|
130
243
|
function buildPathAliasImportRules(paths) {
|
|
131
244
|
if (!paths) {
|
|
132
245
|
return [];
|
|
@@ -413,7 +526,7 @@ function createPathAliasEmitRewriterCore(parsedConfig, configPath) {
|
|
|
413
526
|
if (directPackageSpecifier) {
|
|
414
527
|
return directPackageSpecifier;
|
|
415
528
|
}
|
|
416
|
-
if (!matchesPathAliasImport(importPath, matchers)) {
|
|
529
|
+
if (!containingFile || !matchesPathAliasImport(importPath, matchers)) {
|
|
417
530
|
return;
|
|
418
531
|
}
|
|
419
532
|
const resolutionKey = `${path.normalize(containingFile)}::${importPath}`;
|
|
@@ -446,9 +559,6 @@ function createPathAliasEmitRewriterCore(parsedConfig, configPath) {
|
|
|
446
559
|
return fileContents;
|
|
447
560
|
}
|
|
448
561
|
const containingFile = sourceFilePaths?.find((sourceFilePath) => !sourceFilePath.endsWith('.d.ts')) || sourceFilePaths?.[0] || emittedFileToSourceFile.get(canonicalFileName(path.resolve(fileName)));
|
|
449
|
-
if (!containingFile) {
|
|
450
|
-
return fileContents;
|
|
451
|
-
}
|
|
452
562
|
const sourceFile = ts.createSourceFile(fileName, fileContents, ts.ScriptTarget.Latest, true, getScriptKindForEmittedFile(fileName));
|
|
453
563
|
const replacements = [];
|
|
454
564
|
const addReplacement = (literal) => {
|
|
@@ -534,15 +644,16 @@ function createPathAliasEmitRewriterCore(parsedConfig, configPath) {
|
|
|
534
644
|
};
|
|
535
645
|
}
|
|
536
646
|
export function createPathAliasEmitRewriter(configPath) {
|
|
537
|
-
const
|
|
647
|
+
const normalizedConfigPath = normalizeConfigPath(configPath);
|
|
648
|
+
const configFile = ts.readConfigFile(normalizedConfigPath, ts.sys.readFile);
|
|
538
649
|
if (configFile.error) {
|
|
539
650
|
throw new Error(ts.formatDiagnostic(configFile.error, createDiagnosticsFormatHost()));
|
|
540
651
|
}
|
|
541
|
-
const parsedConfig = ts.parseJsonConfigFileContent(configFile.config, ts.sys, path.dirname(
|
|
652
|
+
const parsedConfig = ts.parseJsonConfigFileContent(configFile.config, ts.sys, path.dirname(normalizedConfigPath), undefined, normalizedConfigPath);
|
|
542
653
|
if (parsedConfig.errors.length > 0) {
|
|
543
654
|
throw new Error(parsedConfig.errors.map((diagnostic) => ts.formatDiagnostic(diagnostic, createDiagnosticsFormatHost())).join('\n'));
|
|
544
655
|
}
|
|
545
|
-
return createPathAliasEmitRewriterCore(parsedConfig,
|
|
656
|
+
return createPathAliasEmitRewriterCore(parsedConfig, normalizedConfigPath);
|
|
546
657
|
}
|
|
547
658
|
function createPathAliasImportDiagnostic(sourceFile, moduleSpecifier, importPath, rule, preferredSpecifier) {
|
|
548
659
|
return {
|
|
@@ -642,7 +753,9 @@ function printDiagnostic(pwd, diagnostic, index) {
|
|
|
642
753
|
console.log(`${colors.cyan}│${colors.reset} ${categoryColor}${category}${colors.reset} ${colors.gray}TS${diagnostic.code}${colors.reset}: ${message}`);
|
|
643
754
|
const sourceFile = diagnostic.file;
|
|
644
755
|
const lineStart = sourceFile.getPositionOfLineAndCharacter(line, 0);
|
|
645
|
-
const lineEnd =
|
|
756
|
+
const lineEnd = line + 1 < sourceFile.getLineStarts().length
|
|
757
|
+
? sourceFile.getPositionOfLineAndCharacter(line + 1, 0)
|
|
758
|
+
: sourceFile.text.length;
|
|
646
759
|
let lineText = sourceFile.text.substring(lineStart, lineEnd).trimEnd();
|
|
647
760
|
const newlineIndex = lineText.indexOf('\n');
|
|
648
761
|
if (newlineIndex !== -1) {
|
|
@@ -703,7 +816,41 @@ function printDiagnostic(pwd, diagnostic, index) {
|
|
|
703
816
|
const categoryColor = isError ? colors.red : colors.yellow;
|
|
704
817
|
console.log(`\n${index + 1}. ${categoryColor}${category}${colors.reset} ${colors.gray}TS${diagnostic.code}${colors.reset}: ${ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n')}`);
|
|
705
818
|
}
|
|
706
|
-
function
|
|
819
|
+
function prepareCompilerPlugins(options, context) {
|
|
820
|
+
let host = context.host;
|
|
821
|
+
let rootNames = context.rootNames;
|
|
822
|
+
const diagnosticMappers = [];
|
|
823
|
+
for (const plugin of options.compilerPlugins || []) {
|
|
824
|
+
const environment = plugin.prepareProgram({
|
|
825
|
+
...context,
|
|
826
|
+
host,
|
|
827
|
+
rootNames,
|
|
828
|
+
});
|
|
829
|
+
host = environment.host || host;
|
|
830
|
+
rootNames = environment.rootNames || rootNames;
|
|
831
|
+
if (environment.mapDiagnostic) {
|
|
832
|
+
diagnosticMappers.push(environment.mapDiagnostic);
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
return {
|
|
836
|
+
diagnosticMappers,
|
|
837
|
+
host,
|
|
838
|
+
rootNames,
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
function mapCompilerDiagnostics(diagnostics, mappers) {
|
|
842
|
+
return diagnostics.flatMap((diagnostic) => {
|
|
843
|
+
let current = diagnostic;
|
|
844
|
+
for (const mapper of mappers) {
|
|
845
|
+
if (!current) {
|
|
846
|
+
break;
|
|
847
|
+
}
|
|
848
|
+
current = mapper(current);
|
|
849
|
+
}
|
|
850
|
+
return current ? [current] : [];
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
function performChecksAndReport(pwd, program, customConfig, pathAliasImportRules, options, state, changedFiles, standardDiagnostics, diagnosticMappers = []) {
|
|
707
854
|
const overallStartTime = Date.now();
|
|
708
855
|
const fileInfo = changedFiles?.size ? `${changedFiles.size} file(s)` : 'all files';
|
|
709
856
|
const shouldRunExtraChecks = !options.skipExtraCheck;
|
|
@@ -733,7 +880,7 @@ function performChecksAndReport(pwd, program, customConfig, pathAliasImportRules
|
|
|
733
880
|
let index = 0;
|
|
734
881
|
if (!options.skipEmitDiagnostics) {
|
|
735
882
|
const diagnosticsStartTime = Date.now();
|
|
736
|
-
const
|
|
883
|
+
const rawDiagnostics = standardDiagnostics
|
|
737
884
|
? [...standardDiagnostics]
|
|
738
885
|
: state
|
|
739
886
|
? ts.getPreEmitDiagnostics(program)
|
|
@@ -741,6 +888,7 @@ function performChecksAndReport(pwd, program, customConfig, pathAliasImportRules
|
|
|
741
888
|
...ts.getPreEmitDiagnostics(program),
|
|
742
889
|
...(options.noEmit ? [] : program.emit().diagnostics),
|
|
743
890
|
];
|
|
891
|
+
const allDiagnostics = mapCompilerDiagnostics(rawDiagnostics, diagnosticMappers);
|
|
744
892
|
allDiagnostics.forEach(diagnostic => {
|
|
745
893
|
const level = getDiagnosticLevel(diagnostic);
|
|
746
894
|
if (level === 'error') {
|
|
@@ -774,13 +922,14 @@ function performChecksAndReport(pwd, program, customConfig, pathAliasImportRules
|
|
|
774
922
|
};
|
|
775
923
|
}
|
|
776
924
|
const compile = (pwd, options) => {
|
|
777
|
-
const
|
|
925
|
+
const projectConfigPath = normalizeConfigPath(options.project);
|
|
926
|
+
const configFile = ts.readConfigFile(projectConfigPath, ts.sys.readFile);
|
|
778
927
|
if (configFile.error) {
|
|
779
928
|
console.error(ts.formatDiagnostic(configFile.error, createDiagnosticsFormatHost()));
|
|
780
929
|
process.exit(1);
|
|
781
930
|
}
|
|
782
931
|
const customConfig = configFile.config.oakBuildChecks || {};
|
|
783
|
-
const parsedConfig = ts.parseJsonConfigFileContent(configFile.config, ts.sys, path.dirname(
|
|
932
|
+
const parsedConfig = ts.parseJsonConfigFileContent(configFile.config, ts.sys, path.dirname(projectConfigPath), undefined, projectConfigPath);
|
|
784
933
|
const pathAliasImportRules = buildPathAliasImportRules(parsedConfig.options.paths);
|
|
785
934
|
if (parsedConfig.errors.length > 0) {
|
|
786
935
|
parsedConfig.errors.forEach(diagnostic => {
|
|
@@ -788,46 +937,55 @@ const compile = (pwd, options) => {
|
|
|
788
937
|
});
|
|
789
938
|
process.exit(1);
|
|
790
939
|
}
|
|
791
|
-
const emitAliasRewriter = createPathAliasEmitRewriterCore(parsedConfig,
|
|
792
|
-
const
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
:
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
940
|
+
const emitAliasRewriter = createPathAliasEmitRewriterCore(parsedConfig, projectConfigPath);
|
|
941
|
+
const incremental = Boolean(parsedConfig.options.incremental || parsedConfig.options.composite);
|
|
942
|
+
const baseHost = incremental
|
|
943
|
+
? ts.createIncrementalCompilerHost(parsedConfig.options)
|
|
944
|
+
: ts.createCompilerHost(parsedConfig.options);
|
|
945
|
+
baseHost.writeFile = emitAliasRewriter.createWriteFile(baseHost.writeFile);
|
|
946
|
+
const prepared = prepareCompilerPlugins(options, {
|
|
947
|
+
compilerOptions: parsedConfig.options,
|
|
948
|
+
host: baseHost,
|
|
949
|
+
projectReferences: parsedConfig.projectReferences,
|
|
950
|
+
rootNames: parsedConfig.fileNames,
|
|
951
|
+
typescript: ts,
|
|
952
|
+
watch: false,
|
|
953
|
+
});
|
|
954
|
+
const program = incremental
|
|
955
|
+
? ts.createIncrementalProgram({
|
|
956
|
+
rootNames: prepared.rootNames,
|
|
957
|
+
options: parsedConfig.options,
|
|
958
|
+
host: prepared.host,
|
|
959
|
+
projectReferences: parsedConfig.projectReferences,
|
|
960
|
+
configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics(parsedConfig),
|
|
961
|
+
}).getProgram()
|
|
962
|
+
: ts.createProgram({
|
|
963
|
+
rootNames: prepared.rootNames,
|
|
964
|
+
options: parsedConfig.options,
|
|
965
|
+
host: prepared.host,
|
|
966
|
+
projectReferences: parsedConfig.projectReferences,
|
|
967
|
+
});
|
|
968
|
+
const result = performChecksAndReport(pwd, program, customConfig, pathAliasImportRules, options, undefined, undefined, undefined, prepared.diagnosticMappers);
|
|
813
969
|
if (result.hasErrors) {
|
|
814
970
|
console.log(`${colors.red}Compilation failed due to errors.${colors.reset}`);
|
|
815
971
|
process.exit(1);
|
|
816
972
|
}
|
|
973
|
+
copyRuntimeJsonAssets(program, parsedConfig, options);
|
|
817
974
|
console.log(`${colors.green}Compilation completed successfully.${colors.reset}`);
|
|
818
975
|
};
|
|
819
976
|
const compileWithWatch = (pwd, options) => {
|
|
820
|
-
const
|
|
977
|
+
const projectConfigPath = normalizeConfigPath(options.project);
|
|
978
|
+
const configFile = ts.readConfigFile(projectConfigPath, ts.sys.readFile);
|
|
821
979
|
if (configFile.error) {
|
|
822
980
|
console.error(ts.formatDiagnostic(configFile.error, createDiagnosticsFormatHost()));
|
|
823
981
|
process.exit(1);
|
|
824
982
|
}
|
|
825
983
|
const customConfig = configFile.config.oakBuildChecks || {};
|
|
826
|
-
const parsedConfig = ts.parseJsonConfigFileContent(configFile.config, ts.sys, path.dirname(
|
|
984
|
+
const parsedConfig = ts.parseJsonConfigFileContent(configFile.config, ts.sys, path.dirname(projectConfigPath), undefined, projectConfigPath);
|
|
827
985
|
const pathAliasImportRules = buildPathAliasImportRules(parsedConfig.options.paths);
|
|
828
986
|
if (parsedConfig.options.incremental === undefined) {
|
|
829
987
|
parsedConfig.options.incremental = true;
|
|
830
|
-
parsedConfig.options.tsBuildInfoFile = path.join(path.dirname(
|
|
988
|
+
parsedConfig.options.tsBuildInfoFile = normalizeConfigPath(path.join(path.dirname(projectConfigPath), '.tsbuildinfo'));
|
|
831
989
|
}
|
|
832
990
|
// Watch 模式优先保证运行时产物持续可用,即使存在类型错误也继续 emit。
|
|
833
991
|
if (!options.noEmit) {
|
|
@@ -839,14 +997,40 @@ const compileWithWatch = (pwd, options) => {
|
|
|
839
997
|
});
|
|
840
998
|
process.exit(1);
|
|
841
999
|
}
|
|
842
|
-
const emitAliasRewriter = createPathAliasEmitRewriterCore(parsedConfig,
|
|
1000
|
+
const emitAliasRewriter = createPathAliasEmitRewriterCore(parsedConfig, projectConfigPath);
|
|
1001
|
+
let activeDiagnosticMappers = [];
|
|
843
1002
|
const createBuilderProgramWithAliasRewrite = (rootNames, compilerOptions, compilerHost, oldProgram, configFileParsingDiagnostics, projectReferences) => {
|
|
844
|
-
|
|
845
|
-
|
|
1003
|
+
const resolvedCompilerOptions = compilerOptions || parsedConfig.options;
|
|
1004
|
+
const resolvedRootNames = rootNames || parsedConfig.fileNames;
|
|
1005
|
+
const baseCompilerHost = compilerHost
|
|
1006
|
+
|| ts.createCompilerHost(resolvedCompilerOptions);
|
|
1007
|
+
baseCompilerHost.writeFile = emitAliasRewriter.createWriteFile(baseCompilerHost.writeFile);
|
|
1008
|
+
let oldTypeScriptProgram;
|
|
1009
|
+
if (!options.compilerPlugins?.length) {
|
|
1010
|
+
try {
|
|
1011
|
+
oldTypeScriptProgram = oldProgram?.getProgram?.();
|
|
1012
|
+
}
|
|
1013
|
+
catch {
|
|
1014
|
+
// TypeScript supplies a placeholder builder on the initial watch pass.
|
|
1015
|
+
oldTypeScriptProgram = undefined;
|
|
1016
|
+
}
|
|
846
1017
|
}
|
|
1018
|
+
const prepared = prepareCompilerPlugins(options, {
|
|
1019
|
+
compilerOptions: resolvedCompilerOptions,
|
|
1020
|
+
host: baseCompilerHost,
|
|
1021
|
+
oldProgram: oldTypeScriptProgram,
|
|
1022
|
+
projectReferences,
|
|
1023
|
+
rootNames: resolvedRootNames,
|
|
1024
|
+
typescript: ts,
|
|
1025
|
+
watch: true,
|
|
1026
|
+
});
|
|
1027
|
+
activeDiagnosticMappers = prepared.diagnosticMappers;
|
|
1028
|
+
const reusableOldProgram = options.compilerPlugins?.length
|
|
1029
|
+
? undefined
|
|
1030
|
+
: oldProgram;
|
|
847
1031
|
return options.noEmit
|
|
848
|
-
? ts.createSemanticDiagnosticsBuilderProgram(rootNames,
|
|
849
|
-
: ts.createEmitAndSemanticDiagnosticsBuilderProgram(rootNames,
|
|
1032
|
+
? ts.createSemanticDiagnosticsBuilderProgram(prepared.rootNames, resolvedCompilerOptions, prepared.host, reusableOldProgram, configFileParsingDiagnostics, projectReferences)
|
|
1033
|
+
: ts.createEmitAndSemanticDiagnosticsBuilderProgram(prepared.rootNames, resolvedCompilerOptions, prepared.host, reusableOldProgram, configFileParsingDiagnostics, projectReferences);
|
|
850
1034
|
};
|
|
851
1035
|
console.log(`${colors.cyan}Starting compilation in watch mode...${colors.reset}\n`);
|
|
852
1036
|
const checkState = new CustomCheckState();
|
|
@@ -916,9 +1100,10 @@ const compileWithWatch = (pwd, options) => {
|
|
|
916
1100
|
console.log(`${colors.cyan}Detected ${changedFiles.size} changed file(s) from watch events${colors.reset}`);
|
|
917
1101
|
}
|
|
918
1102
|
const customChecksStartTime = Date.now();
|
|
919
|
-
const result = performChecksAndReport(pwd, currentProgram, customConfig, pathAliasImportRules, options, checkState, changedFiles, watchDiagnostics);
|
|
1103
|
+
const result = performChecksAndReport(pwd, currentProgram, customConfig, pathAliasImportRules, options, checkState, changedFiles, watchDiagnostics, activeDiagnosticMappers);
|
|
920
1104
|
const customChecksTime = Date.now() - customChecksStartTime;
|
|
921
1105
|
watchDiagnostics = [];
|
|
1106
|
+
copyRuntimeJsonAssets(currentProgram, parsedConfig, options);
|
|
922
1107
|
const timestamp = new Date().toLocaleTimeString();
|
|
923
1108
|
const totalPhaseTime = Date.now() - wholePhaseStartTime;
|
|
924
1109
|
const unaccountedTime = totalPhaseTime - tsCallbackTime - customChecksTime;
|
|
@@ -948,8 +1133,9 @@ const compileWithWatch = (pwd, options) => {
|
|
|
948
1133
|
};
|
|
949
1134
|
ts.createWatchProgram(host);
|
|
950
1135
|
};
|
|
951
|
-
export const build = (pwd, args) => {
|
|
1136
|
+
export const build = (pwd, args, compilerPlugins = []) => {
|
|
952
1137
|
const options = parseArgs(args);
|
|
1138
|
+
options.compilerPlugins = compilerPlugins;
|
|
953
1139
|
let configPath;
|
|
954
1140
|
if (fs.existsSync(options.project)) {
|
|
955
1141
|
const stat = fs.statSync(options.project);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { EntityDict } from
|
|
2
|
-
import { BriefEnv } from
|
|
3
|
-
import { EntityDict as BaseEntityDict } from
|
|
1
|
+
import { EntityDict } from "../base-app-domain";
|
|
2
|
+
import { BriefEnv } from "../types/Environment";
|
|
3
|
+
import { EntityDict as BaseEntityDict } from "../types/Entity";
|
|
4
4
|
import { AsyncContext } from '../store/AsyncRowStore';
|
|
5
|
-
import { SerializedData } from
|
|
5
|
+
import { SerializedData } from "./SerializedData";
|
|
6
6
|
export declare abstract class BackendRuntimeContext<ED extends EntityDict & BaseEntityDict> extends AsyncContext<ED> {
|
|
7
7
|
private subscriberId?;
|
|
8
8
|
private be?;
|
|
9
|
+
private locale?;
|
|
9
10
|
private ns?;
|
|
10
11
|
eventOperationMap: Record<string, string[]>;
|
|
11
12
|
getNavigatorState(): {
|
|
@@ -14,6 +15,7 @@ export declare abstract class BackendRuntimeContext<ED extends EntityDict & Base
|
|
|
14
15
|
} | undefined;
|
|
15
16
|
getSubscriberId(): string | undefined;
|
|
16
17
|
getBriefEnvironment(): BriefEnv | undefined;
|
|
18
|
+
getLocale(): string | undefined;
|
|
17
19
|
protected getSerializedData(): Promise<SerializedData>;
|
|
18
20
|
initialize(data?: SerializedData): Promise<void>;
|
|
19
21
|
/**
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import assert from 'assert';
|
|
1
|
+
import { assert } from '../utils/assert';
|
|
2
2
|
import { AsyncContext } from '../store/AsyncRowStore';
|
|
3
3
|
export class BackendRuntimeContext extends AsyncContext {
|
|
4
4
|
subscriberId;
|
|
5
5
|
be;
|
|
6
|
+
locale;
|
|
6
7
|
ns;
|
|
7
8
|
// 本 map 中记录了要求推送 event 到客户端的 operation
|
|
8
9
|
eventOperationMap = {};
|
|
@@ -15,11 +16,15 @@ export class BackendRuntimeContext extends AsyncContext {
|
|
|
15
16
|
getBriefEnvironment() {
|
|
16
17
|
return this.be;
|
|
17
18
|
}
|
|
19
|
+
getLocale() {
|
|
20
|
+
return this.locale;
|
|
21
|
+
}
|
|
18
22
|
async getSerializedData() {
|
|
19
23
|
return {
|
|
20
24
|
// 在后台事务 restart 时,subscriberId 不能跟随,此时是在完全后台异步的环境里执行
|
|
21
25
|
// sid: this.subscriberId,
|
|
22
26
|
be: this.be,
|
|
27
|
+
locale: this.locale,
|
|
23
28
|
ns: this.ns,
|
|
24
29
|
};
|
|
25
30
|
}
|
|
@@ -30,6 +35,9 @@ export class BackendRuntimeContext extends AsyncContext {
|
|
|
30
35
|
if (data?.be) {
|
|
31
36
|
this.be = data.be;
|
|
32
37
|
}
|
|
38
|
+
if (data?.locale) {
|
|
39
|
+
this.locale = data.locale;
|
|
40
|
+
}
|
|
33
41
|
if (data?.ns) {
|
|
34
42
|
this.ns = data.ns;
|
|
35
43
|
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export type ContextConstructor<Instance extends object = object> = abstract new (...args: never[]) => Instance;
|
|
2
|
+
export type ContextMemberKind = 'field' | 'method';
|
|
3
|
+
export type ContextMemberPolicy = 'unique' | 'replace' | 'final' | 'series' | 'reduce';
|
|
4
|
+
export type ContextHookOrder = 'forward' | 'reverse';
|
|
5
|
+
export type ContextHookPhase = 'before' | 'after';
|
|
6
|
+
export type ContextMemberDeclaration = {
|
|
7
|
+
kind: ContextMemberKind;
|
|
8
|
+
policy?: ContextMemberPolicy;
|
|
9
|
+
};
|
|
10
|
+
export type ContextSeriesHook<Context extends object> = {
|
|
11
|
+
handler: (this: Context, ...args: never[]) => unknown;
|
|
12
|
+
order?: ContextHookOrder;
|
|
13
|
+
phase?: ContextHookPhase;
|
|
14
|
+
};
|
|
15
|
+
export type ContextReducer<Context extends object> = {
|
|
16
|
+
handler: (this: Context, value: never, ...args: never[]) => unknown;
|
|
17
|
+
order?: ContextHookOrder;
|
|
18
|
+
};
|
|
19
|
+
type RuntimeHandler = (this: object, ...args: never[]) => unknown;
|
|
20
|
+
type RuntimeReducer = (this: object, value: never, ...args: never[]) => unknown;
|
|
21
|
+
type RuntimeContextLayer = {
|
|
22
|
+
apply?: (Base: ContextConstructor) => ContextConstructor;
|
|
23
|
+
base?: ContextConstructor;
|
|
24
|
+
hooks?: Record<string, {
|
|
25
|
+
handler: RuntimeHandler;
|
|
26
|
+
order?: ContextHookOrder;
|
|
27
|
+
phase?: ContextHookPhase;
|
|
28
|
+
}>;
|
|
29
|
+
members?: Record<string, ContextMemberDeclaration>;
|
|
30
|
+
reducers?: Record<string, {
|
|
31
|
+
handler: RuntimeReducer;
|
|
32
|
+
order?: ContextHookOrder;
|
|
33
|
+
}>;
|
|
34
|
+
};
|
|
35
|
+
declare const contextLayerRequires: unique symbol;
|
|
36
|
+
declare const contextLayerProvides: unique symbol;
|
|
37
|
+
declare const contextModuleContract: unique symbol;
|
|
38
|
+
export type ContextLayer<Requires extends object, Provides extends object> = RuntimeContextLayer & {
|
|
39
|
+
readonly [contextLayerRequires]?: Requires;
|
|
40
|
+
readonly [contextLayerProvides]?: Provides;
|
|
41
|
+
};
|
|
42
|
+
export type ContextLayerDefinition<Requires extends object, Provides extends object> = {
|
|
43
|
+
apply?: (Base: ContextConstructor<Requires>) => ContextConstructor<Requires & Provides>;
|
|
44
|
+
base?: ContextConstructor<Requires & Provides>;
|
|
45
|
+
hooks?: Record<string, ContextSeriesHook<Requires & Provides>>;
|
|
46
|
+
members?: Record<string, ContextMemberDeclaration>;
|
|
47
|
+
reducers?: Record<string, ContextReducer<Requires & Provides>>;
|
|
48
|
+
};
|
|
49
|
+
export declare function defineContextLayer<Requires extends object, Provides extends object = object>(definition: ContextLayerDefinition<Requires, Provides>): ContextLayer<Requires, Provides>;
|
|
50
|
+
export type ContextModule<Contract extends object = object> = {
|
|
51
|
+
dependencies?: readonly ContextModule[];
|
|
52
|
+
id: string;
|
|
53
|
+
layer?: RuntimeContextLayer;
|
|
54
|
+
version: string;
|
|
55
|
+
readonly [contextModuleContract]?: Contract;
|
|
56
|
+
};
|
|
57
|
+
export type ContextModuleDefinition<Contract extends object> = {
|
|
58
|
+
dependencies?: readonly ContextModule[];
|
|
59
|
+
id: string;
|
|
60
|
+
layer?: RuntimeContextLayer;
|
|
61
|
+
version: string;
|
|
62
|
+
};
|
|
63
|
+
export declare function defineContextModule<Contract extends object = object>(definition: ContextModuleDefinition<Contract>): ContextModule<Contract>;
|
|
64
|
+
type CompatibleMember<Left, Right> = [Left] extends [Right] ? true : [Right] extends [Left] ? true : false;
|
|
65
|
+
export type ContextConflictKeys<Left extends object, Right extends object> = {
|
|
66
|
+
[Key in keyof Left & keyof Right]: CompatibleMember<Left[Key], Right[Key]> extends true ? never : Key;
|
|
67
|
+
}[keyof Left & keyof Right];
|
|
68
|
+
export type MergeContextContract<Left extends object, Right extends object> = Left & Right;
|
|
69
|
+
export type MergeContextContracts<Contracts extends readonly object[], Accumulator extends object = object> = Contracts extends readonly [
|
|
70
|
+
infer Head extends object,
|
|
71
|
+
...infer Tail extends readonly object[]
|
|
72
|
+
] ? MergeContextContracts<Tail, MergeContextContract<Accumulator, Head>> : Accumulator;
|
|
73
|
+
export type ContextCompositionScope = 'backend' | 'frontend' | string;
|
|
74
|
+
export declare class OakContextCompositionException extends Error {
|
|
75
|
+
readonly leftModule: string;
|
|
76
|
+
readonly rightModule: string;
|
|
77
|
+
readonly scope: ContextCompositionScope;
|
|
78
|
+
constructor(scope: ContextCompositionScope, leftModule: string, rightModule: string, detail: string);
|
|
79
|
+
}
|
|
80
|
+
export type ContextCompositionOptions = {
|
|
81
|
+
scope?: ContextCompositionScope;
|
|
82
|
+
};
|
|
83
|
+
export declare const CONTEXT_COMPOSITION: unique symbol;
|
|
84
|
+
export type ContextCompositionInfo = {
|
|
85
|
+
modules: readonly {
|
|
86
|
+
id: string;
|
|
87
|
+
version: string;
|
|
88
|
+
}[];
|
|
89
|
+
scope: ContextCompositionScope;
|
|
90
|
+
};
|
|
91
|
+
export declare function composeContextModules<Base extends ContextConstructor, Roots extends readonly ContextModule[]>(BaseContext: Base, roots: Roots, options?: ContextCompositionOptions): Base;
|
|
92
|
+
export declare function getContextComposition(ContextClass: ContextConstructor): ContextCompositionInfo | undefined;
|
|
93
|
+
export {};
|