@creatio-devkit/common 0.833.0 → 0.1000.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AI_GUIDES_INDEX.md +38 -0
- package/CHANGELOG.md +25 -1
- package/DEFERRED_REMOTE_MIGRATION_AI_GUIDE.md +1338 -0
- package/ICON_REQUIREMENTS_AI_GUIDE.md +107 -74
- package/LICENSE.md +5 -6
- package/REMOTE_COMPONENT_RUNTIME_AI_GUIDE.md +357 -4
- package/THIRD_PARTY_LICENSES.txt +160 -0
- package/fesm2022/creatio-devkit-common.mjs +674 -96
- package/fesm2022/creatio-devkit-common.mjs.map +1 -1
- package/index.d.ts +786 -14
- package/package.json +6 -19
- package/types/creatio-devkit-common.d.ts +4509 -0
- package/esm2022/creatio-devkit-common.mjs +0 -5
- package/esm2022/index.mjs +0 -2
- package/esm2022/lib/base-exports.mjs +0 -5
- package/esm2022/lib/external/file-viewer/file-viewer-factory.service.mjs +0 -26
- package/esm2022/lib/external/file-viewer/file-viewer-instance.model.mjs +0 -51
- package/esm2022/lib/external/file-viewer/file-viewer-options.model.mjs +0 -2
- package/esm2022/lib/external/file-viewer/index.mjs +0 -4
- package/esm2022/lib/external/functions/aggregation-adapter.mjs +0 -72
- package/esm2022/lib/external/functions/date-part-type-adapter.mjs +0 -48
- package/esm2022/lib/external/functions/function-type-adapter.mjs +0 -28
- package/esm2022/lib/external/functions/index.mjs +0 -5
- package/esm2022/lib/external/functions/order-direction-adapter.mjs +0 -28
- package/esm2022/lib/external/models/attribute-value-config.mjs +0 -2
- package/esm2022/lib/external/models/date-time/grouped-date-value.mjs +0 -2
- package/esm2022/lib/external/models/date-time/index.mjs +0 -2
- package/esm2022/lib/external/models/file-value.model.mjs +0 -2
- package/esm2022/lib/external/models/index.mjs +0 -4
- package/esm2022/lib/index.mjs +0 -18
- package/esm2022/lib/internal/constants/default-size.const.mjs +0 -5
- package/esm2022/lib/internal/constants/index.mjs +0 -3
- package/esm2022/lib/internal/constants/metadata.const.mjs +0 -17
- package/esm2022/lib/internal/decorators/design-time-view-element/design-time-view-element.decorator.mjs +0 -19
- package/esm2022/lib/internal/decorators/design-time-view-element/index.mjs +0 -2
- package/esm2022/lib/internal/decorators/implement-using-handler-chain/implement-using-handler-chain.decorator.mjs +0 -25
- package/esm2022/lib/internal/decorators/implement-using-handler-chain/index.mjs +0 -2
- package/esm2022/lib/internal/decorators/index.mjs +0 -4
- package/esm2022/lib/internal/decorators/request/index.mjs +0 -2
- package/esm2022/lib/internal/decorators/request/request.decorator.mjs +0 -15
- package/esm2022/lib/internal/enums/designer-group-type.enum.mjs +0 -16
- package/esm2022/lib/internal/enums/handler-source-type.enum.mjs +0 -12
- package/esm2022/lib/internal/enums/index.mjs +0 -4
- package/esm2022/lib/internal/enums/view-element-group-type.enum.mjs +0 -13
- package/esm2022/lib/internal/models/attribute-property-config.interface.mjs +0 -2
- package/esm2022/lib/internal/models/converter/converter-registry-item.mjs +0 -2
- package/esm2022/lib/internal/models/converter/index.mjs +0 -2
- package/esm2022/lib/internal/models/data-source-load-parameters.mjs +0 -2
- package/esm2022/lib/internal/models/design-time-view-element-registry-item.mjs +0 -2
- package/esm2022/lib/internal/models/handler-chain-service-registry-item.mjs +0 -2
- package/esm2022/lib/internal/models/index.mjs +0 -20
- package/esm2022/lib/internal/models/injection-context/index.mjs +0 -2
- package/esm2022/lib/internal/models/injection-context/injection-context.mjs +0 -2
- package/esm2022/lib/internal/models/interface-designer-item/base-interface-designer-item-registration-config.mjs +0 -2
- package/esm2022/lib/internal/models/interface-designer-item/index.mjs +0 -4
- package/esm2022/lib/internal/models/interface-designer-item/interface-designer-item-registration-config.model.mjs +0 -7
- package/esm2022/lib/internal/models/interface-designer-item/toolbar-view-element-config.mjs +0 -2
- package/esm2022/lib/internal/models/interface-designer-registry-item.mjs +0 -2
- package/esm2022/lib/internal/models/internal-interface-designer-item-registration-config.model.mjs +0 -2
- package/esm2022/lib/internal/models/internal-module-definition.mjs +0 -2
- package/esm2022/lib/internal/models/lazy-module-metadata.mjs +0 -2
- package/esm2022/lib/internal/models/lazy-module-ref.mjs +0 -26
- package/esm2022/lib/internal/models/lazy-registry-item.mjs +0 -2
- package/esm2022/lib/internal/models/remote-build-info.mjs +0 -9
- package/esm2022/lib/internal/models/request/index.mjs +0 -2
- package/esm2022/lib/internal/models/request/method-invoke-request.mjs +0 -12
- package/esm2022/lib/internal/models/request-handler/contexed-handler-scope-config.mjs +0 -2
- package/esm2022/lib/internal/models/request-handler/handler-config.mjs +0 -2
- package/esm2022/lib/internal/models/request-handler/handler-source.mjs +0 -2
- package/esm2022/lib/internal/models/request-handler/index.mjs +0 -6
- package/esm2022/lib/internal/models/request-handler/request-handler-factory.mjs +0 -2
- package/esm2022/lib/internal/models/request-handler/request-handler-registration-config.model.mjs +0 -2
- package/esm2022/lib/internal/models/transaction/index.mjs +0 -4
- package/esm2022/lib/internal/models/transaction/transaction-factory.mjs +0 -2
- package/esm2022/lib/internal/models/transaction/transaction-operation.mjs +0 -2
- package/esm2022/lib/internal/models/transaction/transaction.mjs +0 -2
- package/esm2022/lib/internal/models/validator/index.mjs +0 -4
- package/esm2022/lib/internal/models/validator/validator-parameters.mjs +0 -2
- package/esm2022/lib/internal/models/validator/validator-registry-item.mjs +0 -2
- package/esm2022/lib/internal/models/validator/validator-schema-config.model.mjs +0 -2
- package/esm2022/lib/internal/models/view-element/angular-view-element-registration-config.model.mjs +0 -2
- package/esm2022/lib/internal/models/view-element/index.mjs +0 -2
- package/esm2022/lib/internal/models/view-element-registry-item.mjs +0 -2
- package/esm2022/lib/internal/services/base-handler-chain.service.mjs +0 -3
- package/esm2022/lib/internal/services/base-registry/base-registry.mjs +0 -31
- package/esm2022/lib/internal/services/base-registry/index.mjs +0 -2
- package/esm2022/lib/internal/services/bootstrap-notifier/bootstrap-notifier.mjs +0 -28
- package/esm2022/lib/internal/services/bootstrap-notifier/index.mjs +0 -2
- package/esm2022/lib/internal/services/chat-message-type-registry/chat-message-type-registry.mjs +0 -22
- package/esm2022/lib/internal/services/chat-message-type-registry/index.mjs +0 -2
- package/esm2022/lib/internal/services/design-time-view-element-registry/design-time-view-element-registry.mjs +0 -32
- package/esm2022/lib/internal/services/design-time-view-element-registry/index.mjs +0 -2
- package/esm2022/lib/internal/services/element-registration-checker/element-registration-checker.mjs +0 -60
- package/esm2022/lib/internal/services/element-registration-checker/index.mjs +0 -2
- package/esm2022/lib/internal/services/global-converters-registry/converter-registry.mjs +0 -36
- package/esm2022/lib/internal/services/global-converters-registry/index.mjs +0 -2
- package/esm2022/lib/internal/services/handler-chain-services-registry/handler-chain-services-registry.mjs +0 -26
- package/esm2022/lib/internal/services/handler-chain-services-registry/index.mjs +0 -2
- package/esm2022/lib/internal/services/index.mjs +0 -17
- package/esm2022/lib/internal/services/interface-designer-item-registry/index.mjs +0 -3
- package/esm2022/lib/internal/services/interface-designer-item-registry/interface-designer-item-registry.mjs +0 -53
- package/esm2022/lib/internal/services/interface-designer-item-registry/mobile-interface-designer-item-registry.mjs +0 -12
- package/esm2022/lib/internal/services/lazy-modules-manager/index.mjs +0 -2
- package/esm2022/lib/internal/services/lazy-modules-manager/lazy-modules-manager.mjs +0 -35
- package/esm2022/lib/internal/services/pkg-topology-registry/index.mjs +0 -2
- package/esm2022/lib/internal/services/pkg-topology-registry/pkg-topology-registry.mjs +0 -18
- package/esm2022/lib/internal/services/remote-entries-registry/index.mjs +0 -2
- package/esm2022/lib/internal/services/remote-entries-registry/remote-entries-registry.mjs +0 -18
- package/esm2022/lib/internal/services/request-handler-registry/index.mjs +0 -2
- package/esm2022/lib/internal/services/request-handler-registry/request-handler-registry.service.mjs +0 -131
- package/esm2022/lib/internal/services/request-registry/index.mjs +0 -2
- package/esm2022/lib/internal/services/request-registry/request-registry.service.mjs +0 -33
- package/esm2022/lib/internal/services/request-resolver/base-requests-resolver.mjs +0 -6
- package/esm2022/lib/internal/services/request-resolver/index.mjs +0 -3
- package/esm2022/lib/internal/services/request-resolver/requests-resolver.mjs +0 -17
- package/esm2022/lib/internal/services/validator-registry/index.mjs +0 -2
- package/esm2022/lib/internal/services/validator-registry/validator-registry.mjs +0 -45
- package/esm2022/lib/internal/services/view-element-registry/base-view-element-registry.mjs +0 -74
- package/esm2022/lib/internal/services/view-element-registry/index.mjs +0 -4
- package/esm2022/lib/internal/services/view-element-registry/mobile-view-element-registry.mjs +0 -13
- package/esm2022/lib/internal/services/view-element-registry/view-element-registry.mjs +0 -12
- package/esm2022/lib/internal/types/index.mjs +0 -3
- package/esm2022/lib/internal/types/internal-resolve-dependency-fn.type.mjs +0 -2
- package/esm2022/lib/internal/types/localizable-values.type.mjs +0 -2
- package/esm2022/lib/internal/utils/handlers-order-comparer.mjs +0 -42
- package/esm2022/lib/internal/utils/index.mjs +0 -8
- package/esm2022/lib/internal/utils/instantiate.mjs +0 -24
- package/esm2022/lib/internal/utils/localization-utils.mjs +0 -24
- package/esm2022/lib/internal/utils/metadata-utils.mjs +0 -236
- package/esm2022/lib/internal/utils/module-utils.mjs +0 -38
- package/esm2022/lib/internal/utils/object-deep-keys/index.mjs +0 -2
- package/esm2022/lib/internal/utils/object-deep-keys/object-deep-keys.mjs +0 -13
- package/esm2022/lib/internal/utils/request-handler-scopes.mjs +0 -10
- package/esm2022/lib/public/decorators/chat-message-type/chat-message-type.decorator.mjs +0 -20
- package/esm2022/lib/public/decorators/chat-message-type/index.mjs +0 -2
- package/esm2022/lib/public/decorators/converter/converter.decorator.mjs +0 -21
- package/esm2022/lib/public/decorators/converter/index.mjs +0 -2
- package/esm2022/lib/public/decorators/index.mjs +0 -12
- package/esm2022/lib/public/decorators/inject/index.mjs +0 -2
- package/esm2022/lib/public/decorators/inject/inject.decorator.mjs +0 -19
- package/esm2022/lib/public/decorators/input/index.mjs +0 -2
- package/esm2022/lib/public/decorators/input/input.decorator.mjs +0 -25
- package/esm2022/lib/public/decorators/interface-designer-item/index.mjs +0 -4
- package/esm2022/lib/public/decorators/interface-designer-item/interface-designer-item-decorator-utils.mjs +0 -29
- package/esm2022/lib/public/decorators/interface-designer-item/interface-designer-item.decorator.mjs +0 -10
- package/esm2022/lib/public/decorators/interface-designer-item/mobile-interface-designer-item.decorator.mjs +0 -10
- package/esm2022/lib/public/decorators/module/index.mjs +0 -2
- package/esm2022/lib/public/decorators/module/module.decorator.mjs +0 -9
- package/esm2022/lib/public/decorators/output/index.mjs +0 -2
- package/esm2022/lib/public/decorators/output/output.decorator.mjs +0 -19
- package/esm2022/lib/public/decorators/request-handler/index.mjs +0 -2
- package/esm2022/lib/public/decorators/request-handler/request-handler.decorator.mjs +0 -22
- package/esm2022/lib/public/decorators/validation-input/index.mjs +0 -2
- package/esm2022/lib/public/decorators/validation-input/validation-input.decorator.mjs +0 -27
- package/esm2022/lib/public/decorators/validator/index.mjs +0 -2
- package/esm2022/lib/public/decorators/validator/validator.decorator.mjs +0 -25
- package/esm2022/lib/public/decorators/view-element/index.mjs +0 -4
- package/esm2022/lib/public/decorators/view-element/mobile-view-element.decorator.mjs +0 -9
- package/esm2022/lib/public/decorators/view-element/view-element-decorator-utils.mjs +0 -33
- package/esm2022/lib/public/decorators/view-element/view-element.decorator.mjs +0 -10
- package/esm2022/lib/public/enums/data-source-load-type.enum.mjs +0 -10
- package/esm2022/lib/public/enums/index.mjs +0 -5
- package/esm2022/lib/public/enums/process-status.enum.mjs +0 -28
- package/esm2022/lib/public/enums/view-element-property.enum.mjs +0 -9
- package/esm2022/lib/public/enums/view-model-collection-action-type.enum.mjs +0 -24
- package/esm2022/lib/public/functions/bootstrap-crt-module-handler-chain-services.mjs +0 -32
- package/esm2022/lib/public/functions/bootstrap-crt-module.mjs +0 -357
- package/esm2022/lib/public/functions/bootstrapped-crt-modules.mjs +0 -8
- package/esm2022/lib/public/functions/crt-module-context-hooks.mjs +0 -30
- package/esm2022/lib/public/functions/define-render-config.mjs +0 -16
- package/esm2022/lib/public/functions/index.mjs +0 -10
- package/esm2022/lib/public/functions/localize.mjs +0 -29
- package/esm2022/lib/public/functions/register-angular-view-element.mjs +0 -13
- package/esm2022/lib/public/functions/register-view-element.mjs +0 -21
- package/esm2022/lib/public/functions/reset-globals.mjs +0 -37
- package/esm2022/lib/public/handlers/base-request-handler.mjs +0 -37
- package/esm2022/lib/public/handlers/index.mjs +0 -2
- package/esm2022/lib/public/models/ai-context/ai-context-part.mjs +0 -2
- package/esm2022/lib/public/models/ai-context/index.mjs +0 -2
- package/esm2022/lib/public/models/base-response.model.mjs +0 -2
- package/esm2022/lib/public/models/converter/converter-config.mjs +0 -2
- package/esm2022/lib/public/models/converter/index.mjs +0 -2
- package/esm2022/lib/public/models/converter.model.mjs +0 -2
- package/esm2022/lib/public/models/entity.model.mjs +0 -2
- package/esm2022/lib/public/models/error-info.model.mjs +0 -2
- package/esm2022/lib/public/models/image-value.model.mjs +0 -2
- package/esm2022/lib/public/models/index.mjs +0 -21
- package/esm2022/lib/public/models/input/index.mjs +0 -2
- package/esm2022/lib/public/models/input/input-registration-config.model.mjs +0 -6
- package/esm2022/lib/public/models/interface-designer-item/index.mjs +0 -2
- package/esm2022/lib/public/models/interface-designer-item/interface-designer-item-definition.mjs +0 -2
- package/esm2022/lib/public/models/item-creation-config.mjs +0 -2
- package/esm2022/lib/public/models/license/index.mjs +0 -2
- package/esm2022/lib/public/models/license/license-restriction-operation-values.model.mjs +0 -2
- package/esm2022/lib/public/models/localizable-value.mjs +0 -20
- package/esm2022/lib/public/models/mask-settings.mjs +0 -2
- package/esm2022/lib/public/models/module-definition.mjs +0 -2
- package/esm2022/lib/public/models/process-engine/index.mjs +0 -4
- package/esm2022/lib/public/models/process-engine/process-parameter-value.model.mjs +0 -2
- package/esm2022/lib/public/models/process-engine/run-process-request.model.mjs +0 -12
- package/esm2022/lib/public/models/process-engine/run-process-response.model.mjs +0 -2
- package/esm2022/lib/public/models/request/base-request-config.mjs +0 -8
- package/esm2022/lib/public/models/request/data-source-request.mjs +0 -11
- package/esm2022/lib/public/models/request/handle-view-model-attribute-change.request.mjs +0 -29
- package/esm2022/lib/public/models/request/index.mjs +0 -6
- package/esm2022/lib/public/models/request/model-event.model.mjs +0 -2
- package/esm2022/lib/public/models/request/view-model-attribute-change-event-options.mjs +0 -2
- package/esm2022/lib/public/models/request-handler/index.mjs +0 -2
- package/esm2022/lib/public/models/request-handler/request-handler-definition.mjs +0 -2
- package/esm2022/lib/public/models/validation/base-validator.mjs +0 -40
- package/esm2022/lib/public/models/validation/crt-control-state.mjs +0 -2
- package/esm2022/lib/public/models/validation/crt-validation-errors.mjs +0 -2
- package/esm2022/lib/public/models/validation/crt-validator-fn.mjs +0 -2
- package/esm2022/lib/public/models/validation/index.mjs +0 -8
- package/esm2022/lib/public/models/validation/validation-info.mjs +0 -2
- package/esm2022/lib/public/models/validation/validator-config.mjs +0 -2
- package/esm2022/lib/public/models/validation/validator-parameter-values.mjs +0 -2
- package/esm2022/lib/public/models/view-element/base-view-element-registration-config.mjs +0 -2
- package/esm2022/lib/public/models/view-element/index.mjs +0 -6
- package/esm2022/lib/public/models/view-element/view-element-registration-config.mjs +0 -2
- package/esm2022/lib/public/models/view-element/view-element-render-strategy.mjs +0 -18
- package/esm2022/lib/public/models/view-element/view-element-reuse-strategy.enum.mjs +0 -15
- package/esm2022/lib/public/models/view-element/view-element-slot-definition.mjs +0 -2
- package/esm2022/lib/public/models/view-model-collection/index.mjs +0 -3
- package/esm2022/lib/public/models/view-model-collection/view-model-collection-change.model.mjs +0 -2
- package/esm2022/lib/public/models/view-model-collection/view-model-collection.model.mjs +0 -2
- package/esm2022/lib/public/services/ai-context/ai-context.service.mjs +0 -86
- package/esm2022/lib/public/services/ai-context/index.mjs +0 -2
- package/esm2022/lib/public/services/crt-zone/crt-zone.service.mjs +0 -22
- package/esm2022/lib/public/services/crt-zone/index.mjs +0 -2
- package/esm2022/lib/public/services/dialog-service/dialog.service.mjs +0 -24
- package/esm2022/lib/public/services/dialog-service/index.mjs +0 -2
- package/esm2022/lib/public/services/feature/feature.service.mjs +0 -26
- package/esm2022/lib/public/services/feature/index.mjs +0 -2
- package/esm2022/lib/public/services/handler-chain/handler-chain.service.mjs +0 -71
- package/esm2022/lib/public/services/handler-chain/index.mjs +0 -2
- package/esm2022/lib/public/services/handler-chain/internal-handler-chain.mjs +0 -195
- package/esm2022/lib/public/services/http-client/http-client.service.mjs +0 -83
- package/esm2022/lib/public/services/http-client/http-headers.mjs +0 -2
- package/esm2022/lib/public/services/http-client/http-response.mjs +0 -2
- package/esm2022/lib/public/services/http-client/index.mjs +0 -4
- package/esm2022/lib/public/services/index.mjs +0 -17
- package/esm2022/lib/public/services/license/index.mjs +0 -2
- package/esm2022/lib/public/services/license/license.service.mjs +0 -30
- package/esm2022/lib/public/services/mask-service/index.mjs +0 -2
- package/esm2022/lib/public/services/mask-service/mask.service.mjs +0 -46
- package/esm2022/lib/public/services/message-channel/index.mjs +0 -2
- package/esm2022/lib/public/services/message-channel/message-channel.service.mjs +0 -27
- package/esm2022/lib/public/services/model/index.mjs +0 -2
- package/esm2022/lib/public/services/model/model.mjs +0 -102
- package/esm2022/lib/public/services/process-engine/index.mjs +0 -2
- package/esm2022/lib/public/services/process-engine/process-engine.service.mjs +0 -27
- package/esm2022/lib/public/services/rights/index.mjs +0 -2
- package/esm2022/lib/public/services/rights/rights.service.mjs +0 -26
- package/esm2022/lib/public/services/schema-modal/index.mjs +0 -3
- package/esm2022/lib/public/services/schema-modal/schema-modal-config.model.mjs +0 -2
- package/esm2022/lib/public/services/schema-modal/schema-modal.service.mjs +0 -23
- package/esm2022/lib/public/services/sys-settings/index.mjs +0 -3
- package/esm2022/lib/public/services/sys-settings/sys-setting.model.mjs +0 -24
- package/esm2022/lib/public/services/sys-settings/sys-settings.service.mjs +0 -36
- package/esm2022/lib/public/services/sys-values/index.mjs +0 -3
- package/esm2022/lib/public/services/sys-values/sys-values.mjs +0 -2
- package/esm2022/lib/public/services/sys-values/sys-values.service.mjs +0 -23
- package/esm2022/lib/public/services/transaction-factory/index.mjs +0 -2
- package/esm2022/lib/public/services/transaction-factory/transaction-factory.service.mjs +0 -40
|
@@ -0,0 +1,1338 @@
|
|
|
1
|
+
# Deferred Remote Migration AI Guide
|
|
2
|
+
|
|
3
|
+
This guide is for AI agents that must migrate an existing old-style Creatio Freedom UI remote entry from eager bootstrap to the deferred remote contract based on `RemoteEntryDefinition` and `RemoteFeatureDefinition`.
|
|
4
|
+
|
|
5
|
+
## Background
|
|
6
|
+
|
|
7
|
+
Creatio Freedom UI uses webpack Module Federation to compose the shell application from independently built **remotes**. Each remote is a separately compiled UI application (often Angular-based) that the **host** (the Creatio shell) loads at runtime.
|
|
8
|
+
|
|
9
|
+
### Host–remote relationship
|
|
10
|
+
|
|
11
|
+
The host maintains a registry of remote modules. When the shell needs a capability — a page element, a request handler, a validator — it looks up the registry, fetches the remote's entry script, and asks the remote to provide the requested type. The remote never renders on its own; it always runs inside the host.
|
|
12
|
+
|
|
13
|
+
### Two-phase lifecycle: discovery → activation
|
|
14
|
+
|
|
15
|
+
In the deferred model every remote goes through two phases:
|
|
16
|
+
|
|
17
|
+
1. **Discovery** — the host imports the remote entry module and reads lightweight metadata that describes which types the remote can provide (view elements, handlers, validators, converters). No Angular modules are bootstrapped, no components are instantiated, and no side effects run.
|
|
18
|
+
2. **Activation** — only when the host actually needs a discovered type does it call the feature's `activate()` function, which bootstraps the Angular platform, creates the feature module, defines custom elements, and registers the CRT artifacts.
|
|
19
|
+
|
|
20
|
+
The eager (old) model collapses both phases into one: importing the remote entry immediately bootstraps Angular and registers everything. That blocks the shell startup with work that may never be needed.
|
|
21
|
+
|
|
22
|
+
### Artifact types
|
|
23
|
+
|
|
24
|
+
| Artifact | Purpose |
|
|
25
|
+
| --- | --- |
|
|
26
|
+
| **View element** | An Angular component wrapped as a custom element and rendered inside Freedom UI pages. Discovered via `viewElements` metadata. |
|
|
27
|
+
| **Request handler** | A class that intercepts and processes a specific request type, optionally scoped to certain pages. Discovered via `requestHandlers` metadata with `type`, `requestType`, and optional `scopes`. |
|
|
28
|
+
| **Validator** | A class that validates data or state. Discovered via `validators` metadata. |
|
|
29
|
+
| **Converter** | A class that transforms values between formats. Discovered via `converters` metadata. |
|
|
30
|
+
| **Properties panel** | A design-time-only view element shown in the page wizard to configure another view element's properties. Belongs in the design feature, not the runtime feature. |
|
|
31
|
+
|
|
32
|
+
### Why deferred
|
|
33
|
+
|
|
34
|
+
- Reduces shell startup time — remotes that are never needed on the current page cost almost nothing.
|
|
35
|
+
- Enables independent feature boundaries — each feature can be activated, loaded, and failed independently.
|
|
36
|
+
- Separates design-time from runtime — toolbox metadata and property panels load only inside the page wizard, not during normal page rendering.
|
|
37
|
+
|
|
38
|
+
## Terminology
|
|
39
|
+
|
|
40
|
+
In this guide:
|
|
41
|
+
|
|
42
|
+
- `remote entry file` — the file configured as the remote build's Angular `main` entry and exposed through `./Main`. In many projects this is `src/main.ts`, but the exact path must be verified in the target workspace.
|
|
43
|
+
- `discovery metadata` — the lightweight type descriptors returned by a feature definition so the host knows what a remote can provide before activating it.
|
|
44
|
+
- `activation` — the process of bootstrapping the Angular platform, creating the feature module, defining custom elements, and registering CRT artifacts for a specific feature.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
### When to use this guide
|
|
49
|
+
|
|
50
|
+
Use this guide when the current remote still looks like the old eager template:
|
|
51
|
+
|
|
52
|
+
- the remote entry file only imports `./bootstrap`
|
|
53
|
+
- `src/bootstrap.ts` calls `platformBrowserDynamic().bootstrapModule(AppModule)`
|
|
54
|
+
- `AppModule` eagerly registers all view elements, handlers, validators, converters, and designer metadata through `bootstrapCrtModule(...)`
|
|
55
|
+
- runtime view elements use `@CrtInterfaceDesignerItem` or `@CrtMobileInterfaceDesignerItem`
|
|
56
|
+
|
|
57
|
+
Do not use this guide for a mixed compatibility setup unless the task explicitly asks to keep both approaches at the same time.
|
|
58
|
+
|
|
59
|
+
### Document boundaries
|
|
60
|
+
|
|
61
|
+
This document is intentionally external-facing:
|
|
62
|
+
|
|
63
|
+
- it assumes the developer consumes the public NPM package API
|
|
64
|
+
- it does not assume access to any internal repository
|
|
65
|
+
- it does not refer to internal source files or internal examples
|
|
66
|
+
- it focuses on the public integration contract and migration shape only
|
|
67
|
+
|
|
68
|
+
## Goal
|
|
69
|
+
|
|
70
|
+
The target state is a fully deferred remote:
|
|
71
|
+
|
|
72
|
+
- the entry exports a `RemoteEntryDefinition`
|
|
73
|
+
- discovery metadata is published without activating runtime code
|
|
74
|
+
- runtime code activates only when a discovered type is actually requested
|
|
75
|
+
- designer toolbox metadata is loaded through `loadDesignerDefinitions(...)`
|
|
76
|
+
- runtime view elements no longer carry interface-designer decorators
|
|
77
|
+
|
|
78
|
+
## Public API Surface Used By This Guide
|
|
79
|
+
|
|
80
|
+
This guide only relies on the public API shape exposed to remote-module authors.
|
|
81
|
+
|
|
82
|
+
For localization, the detailed examples in this guide assume an `ngx-translate`-based setup.
|
|
83
|
+
If a remote uses a different translation library, keep the same deferred remote architecture, but adapt the
|
|
84
|
+
translation bootstrap, culture switching, and lookup calls to that library.
|
|
85
|
+
|
|
86
|
+
TypeScript note:
|
|
87
|
+
|
|
88
|
+
- several examples use the `satisfies` operator
|
|
89
|
+
- this requires TypeScript 4.9 or newer
|
|
90
|
+
- if the target project uses an older TypeScript version, replace `... satisfies SomeType` with an explicit type annotation
|
|
91
|
+
|
|
92
|
+
- Remote entry contracts:
|
|
93
|
+
- `RemoteEntryDefinition`
|
|
94
|
+
- `RemoteFeatureDefinition`
|
|
95
|
+
- `RemoteFeatureDesignerDefinitions`
|
|
96
|
+
- `RemoteDesignerDefinitionsLoadContext`
|
|
97
|
+
|
|
98
|
+
- Runtime registration APIs:
|
|
99
|
+
- `bootstrapCrtModule(...)`
|
|
100
|
+
- `CrtModule`
|
|
101
|
+
|
|
102
|
+
- View-element decorators:
|
|
103
|
+
- `CrtViewElement`
|
|
104
|
+
- `CrtMobileViewElement`
|
|
105
|
+
- `CrtInput`
|
|
106
|
+
- `CrtOutput`
|
|
107
|
+
- `CrtValidationInput`
|
|
108
|
+
|
|
109
|
+
- Optional design-time and localization-related APIs:
|
|
110
|
+
- `TranslateService`
|
|
111
|
+
- `TranslateModule`
|
|
112
|
+
- `TranslateHttpLoader`
|
|
113
|
+
- `SysValuesService`
|
|
114
|
+
|
|
115
|
+
Do not rely on undocumented host internals or internal registry implementations when writing the migrated remote.
|
|
116
|
+
|
|
117
|
+
## Hard Rules
|
|
118
|
+
|
|
119
|
+
- Never keep eager entry bootstrap in the final fully deferred result. The entry must export `RemoteEntryDefinition`, not run `import('./bootstrap')`.
|
|
120
|
+
- Never keep `@CrtInterfaceDesignerItem` or `@CrtMobileInterfaceDesignerItem` on runtime remote view elements in the deferred flow.
|
|
121
|
+
- Always publish designer captions, icons, default property values, and `propertiesPanel` through `RemoteFeatureDefinition.loadDesignerDefinitions(...)`.
|
|
122
|
+
- Always ensure every type returned in designer definitions was already published through the same feature's discovery metadata.
|
|
123
|
+
- Always ensure every discovered runtime type is actually registered during `activate()`.
|
|
124
|
+
- Always populate every field that the discovery metadata contract accepts when the corresponding decorator on the runtime artifact provides that data. For example, if `RemoteRequestHandlerDiscoveryMetadata` accepts `requestType` and `scopes`, and the handler's `@CrtRequestHandler` declares those values, copy them into the discovery entry. The same principle applies to all artifact kinds: view elements, converters, validators, and request handlers.
|
|
125
|
+
- Always publish only public runtime types in discovery. Internal Angular helper components stay ordinary declarations and are not discovered separately.
|
|
126
|
+
- Always keep discovery lightweight. No runtime side effects belong there.
|
|
127
|
+
- Always keep the import graph of the remote entry file and every `*.feature-definition.ts` file lightweight.
|
|
128
|
+
- Never place activation-only assets in files imported by entry or feature-definition files. This includes SVG icon strings, raw-loader imports, large default-property maps, sample data, and bulky runtime-only constants.
|
|
129
|
+
- Always keep activation idempotent. Follow the `ensureFeatureModuleRef(...)` pattern and guard `customElements.define(...)`.
|
|
130
|
+
- Always inspect the full old eager module tree, not just the root module. Old remotes may aggregate behavior through `CrtModule.includes` and Angular module imports.
|
|
131
|
+
- Treat the migration as structural only. Do not change the functional behavior of components, handlers, validators, converters, services, selectors, public type names, translations, defaults, or icons unless the task explicitly asks for such a change.
|
|
132
|
+
- Do not let other AI guides expand the migration scope. Accessibility, icon, runtime-component, or similar guidance must not trigger extra fixes, redesigns, or improvements during migration unless the task explicitly asks for them.
|
|
133
|
+
- Always physically move migrated runtime and design-time source files under their owning feature folders. Do not leave migrated `view-elements`, `handlers`, `validators`, `converters`, or `property-panels` folders at the old top level unless they contain code that is still truly shared across multiple features.
|
|
134
|
+
- After migration, the root `app/` level must contain only app-shell or truly shared infrastructure. Do not leave old eager-runtime artifacts there, such as root-level handlers, runtime components, runtime feature modules, or old remote root component/module files, unless they were intentionally converted into app-shell or truly shared cross-feature code.
|
|
135
|
+
- Do not treat feature-local barrel files as a valid migration if they only re-export old root-level runtime or design-only implementation files. When code is runtime-only or design-only, move the actual implementation files into the owning feature folder instead of pointing feature barrels back to old locations.
|
|
136
|
+
- If a custom properties panel exists, treat it as a separate design-time runtime artifact. It usually needs its own feature or at least its own discovered type and activation path.
|
|
137
|
+
|
|
138
|
+
## Old To New Mapping
|
|
139
|
+
|
|
140
|
+
| Old eager artifact | Deferred replacement |
|
|
141
|
+
| --- | --- |
|
|
142
|
+
| remote entry file imports `./bootstrap` | remote entry file default-exports `RemoteEntryDefinition` |
|
|
143
|
+
| `src/bootstrap.ts` bootstraps root Angular module | Usually removed; remote bootstrap moves into `ensureRemoteAppContext()` and feature activation modules |
|
|
144
|
+
| One `AppModule` registers everything eagerly | Split into `RemoteAppModule` plus one or more feature modules |
|
|
145
|
+
| `@CrtModule(...)` on root module only | `@CrtModule(...)` on per-feature runtime or design modules |
|
|
146
|
+
| Root `CrtModule` includes many other `CrtModule`s | flatten the old include tree and redistribute discovered runtime artifacts into runtime and design features |
|
|
147
|
+
| Root Angular module imports many helper `NgModule`s | keep shared Angular-only modules as imports of the new feature module that actually needs them |
|
|
148
|
+
| `@CrtInterfaceDesignerItem` / `@CrtMobileInterfaceDesignerItem` on runtime components | `loadDesignerDefinitions(...)` returns toolbox metadata |
|
|
149
|
+
| Toolbox caption/icon/defaults stored on runtime component decorators | Toolbox metadata returned from designer-definition loader |
|
|
150
|
+
| One shared `constants.ts` file contains both discovery IDs and large activation-only assets | split lightweight discovery constants from activation-only constants and import the heavy ones only from lazy files |
|
|
151
|
+
| Inline string literals for types, request types, scopes, and selectors in decorators | shared constants files imported by both feature-definition files (for discovery) and implementation files (for decorators) |
|
|
152
|
+
| Translation for decorator metadata via `localize()` + `localizeMetadata` | Designer metadata translated directly inside `loadDesignerDefinitions({ cultureName })` |
|
|
153
|
+
| Entry bootstrap defines custom elements immediately | `activate()` defines custom elements only when the feature is requested |
|
|
154
|
+
| `AppModule` constructor performs one-time setup such as icon registration | move one-time setup to `RemoteAppModule` bootstrap or a guarded activation helper |
|
|
155
|
+
|
|
156
|
+
## Recommended Target Structure
|
|
157
|
+
|
|
158
|
+
### Directory tree
|
|
159
|
+
|
|
160
|
+
```text
|
|
161
|
+
src/
|
|
162
|
+
main.ts
|
|
163
|
+
app/
|
|
164
|
+
remote-app.module.ts
|
|
165
|
+
remote-app-context.ts
|
|
166
|
+
localization/
|
|
167
|
+
remote-localization.module.ts
|
|
168
|
+
features/
|
|
169
|
+
runtime/
|
|
170
|
+
runtime.feature-definition.ts
|
|
171
|
+
runtime.feature-activation.ts
|
|
172
|
+
runtime.designer-definitions.ts
|
|
173
|
+
runtime.feature-ids.ts
|
|
174
|
+
runtime.activation-constants.ts
|
|
175
|
+
runtime-feature.module.ts
|
|
176
|
+
view-elements/...
|
|
177
|
+
handlers/...
|
|
178
|
+
validators/...
|
|
179
|
+
converters/...
|
|
180
|
+
design/
|
|
181
|
+
design.feature-definition.ts
|
|
182
|
+
design.feature-activation.ts
|
|
183
|
+
design-feature.module.ts
|
|
184
|
+
property-panels/...
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Treat separate runtime and design features as the default target structure.
|
|
188
|
+
|
|
189
|
+
Reasons:
|
|
190
|
+
|
|
191
|
+
- it keeps runtime and design-time activation boundaries explicit from the start
|
|
192
|
+
- it avoids reshaping the remote entry later when a custom properties panel is added
|
|
193
|
+
- it matches the most extensible deferred-remote layout even when the design feature starts minimal
|
|
194
|
+
|
|
195
|
+
The design feature may start with no discovered view elements yet. In that case, keep a minimal `design.feature-definition.ts`, `design.feature-activation.ts`, and `design-feature.module.ts` so future property panels can be added without changing the entry topology.
|
|
196
|
+
|
|
197
|
+
You may collapse to a single runtime feature only when the task explicitly asks for the smallest possible structure and there are no current or expected design-only artifacts.
|
|
198
|
+
|
|
199
|
+
### Folder-placement rules
|
|
200
|
+
|
|
201
|
+
- do not leave migrated runtime artifact folders such as `view-elements`, `handlers`, `validators`, or `converters` at the old shared `app/` level after migration
|
|
202
|
+
- move the actual source files for those runtime artifacts under the owning runtime feature folder, usually `app/features/runtime/...`
|
|
203
|
+
- move property panels and other design-only files under the owning design feature folder, usually `app/features/design/...`
|
|
204
|
+
- do not leave old eager root component/module files at the `app/` level after migration
|
|
205
|
+
- keep old top-level folders only for code that is still truly shared across multiple features
|
|
206
|
+
- do not use feature-local barrel files that merely re-export from old root-level locations; move the actual source files instead
|
|
207
|
+
|
|
208
|
+
Invalid — artifacts left at the old root level alongside the new feature structure:
|
|
209
|
+
|
|
210
|
+
- `app/view-elements/...`, `app/handlers/...`, `app/property-panels/...`
|
|
211
|
+
- `app/<old-remote-root-component>.component.ts`, `app/<old-remote-root-module>.module.ts`
|
|
212
|
+
- `app/features/runtime/services/index.ts` re-exporting from `../../../services` while the actual files remain in `app/services/...`
|
|
213
|
+
|
|
214
|
+
Valid — everything under its owning feature folder:
|
|
215
|
+
|
|
216
|
+
- `app/features/runtime/view-elements/...`
|
|
217
|
+
- `app/features/runtime/handlers/...`
|
|
218
|
+
- `app/features/runtime/services/<runtime-service>.service.ts`
|
|
219
|
+
- `app/features/runtime/runtime-feature.module.ts`
|
|
220
|
+
- `app/features/design/property-panels/...`
|
|
221
|
+
|
|
222
|
+
### Root `app/` expectations after migration
|
|
223
|
+
|
|
224
|
+
Must contain only:
|
|
225
|
+
|
|
226
|
+
- `remote-app.module.ts`
|
|
227
|
+
- `remote-app-context.ts`
|
|
228
|
+
- localization infrastructure
|
|
229
|
+
- lightweight ids/constants files
|
|
230
|
+
- truly shared models, services, or utilities that are used by more than one feature
|
|
231
|
+
|
|
232
|
+
Must not contain:
|
|
233
|
+
|
|
234
|
+
- runtime handlers, view elements, validators, or converters
|
|
235
|
+
- property panels
|
|
236
|
+
- old remote root component/module files from the eager structure
|
|
237
|
+
|
|
238
|
+
### File-role split
|
|
239
|
+
|
|
240
|
+
- `*.feature-definition.ts`
|
|
241
|
+
- imports only lightweight IDs and discovery metadata
|
|
242
|
+
- may reference lazy imports for activation and designer definitions
|
|
243
|
+
- constants files (for example `*.feature-ids.ts`, or additional files when the remote has many artifacts)
|
|
244
|
+
- contain only small string constants such as feature IDs, custom element selectors, remote names, type names, request types, and scopes
|
|
245
|
+
- imported by both `*.feature-definition.ts` (for discovery metadata) and by implementation files (for decorators)
|
|
246
|
+
- keep identifiers in sync between discovery and activation without duplication
|
|
247
|
+
- `*.designer-definitions.ts`
|
|
248
|
+
- may import icons and designer-only defaults
|
|
249
|
+
- `*.feature-activation.ts`
|
|
250
|
+
- may import activation-only constants and runtime setup helpers
|
|
251
|
+
- activation-only constant files
|
|
252
|
+
- may contain large SVG strings, raw-loader imports, or bulky default configs
|
|
253
|
+
- must not be imported by the remote entry file or by any `*.feature-definition.ts` file
|
|
254
|
+
|
|
255
|
+
## Migration Procedure
|
|
256
|
+
|
|
257
|
+
Migration scope:
|
|
258
|
+
|
|
259
|
+
- the goal is to change the remote architecture from eager to deferred
|
|
260
|
+
- do not use the migration as an opportunity to refactor behavior, rename public contracts, redesign components, or introduce unrelated fixes or improvements
|
|
261
|
+
- if other AI guides are also loaded, use them only to preserve correctness of the migration shape, not to apply their optional improvements by default
|
|
262
|
+
- if a behavior change is unavoidable to complete the deferred migration, keep the externally visible result equivalent and document the reason explicitly
|
|
263
|
+
|
|
264
|
+
### 1. Inventory the current remote
|
|
265
|
+
|
|
266
|
+
Before rewriting anything, collect:
|
|
267
|
+
|
|
268
|
+
- current entry file and webpack expose name
|
|
269
|
+
- root Angular module that currently bootstraps the remote
|
|
270
|
+
- all `CrtModule`s reachable from the root eager module, including nested `includes`
|
|
271
|
+
- all Angular `NgModule`s imported by the root module or by included feature modules
|
|
272
|
+
- all view elements
|
|
273
|
+
- all request handlers, including their `type`, `requestType`, and `scopes`
|
|
274
|
+
- all validators
|
|
275
|
+
- all converters
|
|
276
|
+
- any mobile view elements
|
|
277
|
+
- any custom properties panels
|
|
278
|
+
- all usages of `@CrtInterfaceDesignerItem`, `@CrtMobileInterfaceDesignerItem`, and `localize()`
|
|
279
|
+
- any `AppModule` constructor side effects such as icon registration, global service initialization, or one-time asset setup
|
|
280
|
+
- any `APP_INITIALIZER` logic
|
|
281
|
+
- translation files under `assets/i18n`
|
|
282
|
+
|
|
283
|
+
Do not inventory only the root module class. In old remotes, runtime artifacts may be declared in:
|
|
284
|
+
|
|
285
|
+
- the root `@CrtModule(...)`
|
|
286
|
+
- `CrtModule.includes`
|
|
287
|
+
- Angular modules imported by the root module
|
|
288
|
+
- nested feature modules imported several levels deep
|
|
289
|
+
|
|
290
|
+
### 2. Split the remote into features
|
|
291
|
+
|
|
292
|
+
Create at least one `RemoteFeatureDefinition` per activation boundary.
|
|
293
|
+
|
|
294
|
+
For the recommended default structure, create both:
|
|
295
|
+
|
|
296
|
+
- a runtime feature for runtime artifacts
|
|
297
|
+
- a design feature for property panels and other designer-only artifacts, even if that design feature starts minimal
|
|
298
|
+
|
|
299
|
+
When the old remote has many included modules, migrate by flattening the old eager tree first:
|
|
300
|
+
|
|
301
|
+
1. find every public runtime artifact exposed through the root `CrtModule` and all nested included `CrtModule`s
|
|
302
|
+
2. group those artifacts by activation boundary, not by their old module location
|
|
303
|
+
3. create one or more new feature modules that import whichever Angular helper modules they still need
|
|
304
|
+
4. move design-only artifacts such as property panels out of the old runtime tree and into a design feature
|
|
305
|
+
5. physically relocate the corresponding source files so runtime artifacts live under the owning runtime feature folder and design-only artifacts live under the owning design feature folder
|
|
306
|
+
|
|
307
|
+
Typical split:
|
|
308
|
+
|
|
309
|
+
- Runtime feature:
|
|
310
|
+
- actual runtime view elements
|
|
311
|
+
- handlers
|
|
312
|
+
- validators
|
|
313
|
+
- converters
|
|
314
|
+
- runtime toolbox metadata via `loadDesignerDefinitions(...)`
|
|
315
|
+
|
|
316
|
+
- Design feature:
|
|
317
|
+
- properties panel components
|
|
318
|
+
- design-only helper view elements
|
|
319
|
+
- a future-ready activation boundary even when no property panel exists yet
|
|
320
|
+
|
|
321
|
+
Do not put unrelated heavy artifacts into one feature if they can be activated independently.
|
|
322
|
+
|
|
323
|
+
If the source remote currently has no design-only artifacts, it is still acceptable and recommended to keep the design feature present with empty discovery and no registered view elements yet.
|
|
324
|
+
|
|
325
|
+
Old module boundaries do not need to be preserved exactly. If the old remote had many small included modules, it is acceptable to merge them into a smaller number of deferred feature modules as long as:
|
|
326
|
+
|
|
327
|
+
- runtime discovery stays correct
|
|
328
|
+
- runtime activation stays lazy
|
|
329
|
+
- design-only artifacts are separated from runtime artifacts
|
|
330
|
+
- required Angular imports and providers still exist in the feature module that now owns the code
|
|
331
|
+
|
|
332
|
+
### 3. Replace the entry point
|
|
333
|
+
|
|
334
|
+
Convert the entry from eager bootstrap to a definition export.
|
|
335
|
+
|
|
336
|
+
Old pattern:
|
|
337
|
+
|
|
338
|
+
```ts
|
|
339
|
+
import('./bootstrap').catch((err) => console.error(err));
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
Target pattern:
|
|
343
|
+
|
|
344
|
+
```ts
|
|
345
|
+
import type { RemoteEntryDefinition } from '@creatio-devkit/common';
|
|
346
|
+
|
|
347
|
+
import { runtimeFeatureDefinition } from './app/features/runtime/runtime.feature-definition';
|
|
348
|
+
import { designFeatureDefinition } from './app/features/design/design.feature-definition';
|
|
349
|
+
|
|
350
|
+
export default {
|
|
351
|
+
remoteName: 'your_remote_name',
|
|
352
|
+
features: [runtimeFeatureDefinition, designFeatureDefinition],
|
|
353
|
+
} satisfies RemoteEntryDefinition;
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
If the task requires a fully deferred result, do not keep `import('./bootstrap')` in this file.
|
|
357
|
+
|
|
358
|
+
### 4. Migrate the webpack and module-federation setup
|
|
359
|
+
|
|
360
|
+
After migration, the remote entry must expose the deferred definition from the remote entry file.
|
|
361
|
+
|
|
362
|
+
#### 4.1 Angular build options (`angular.json` / `project.json`)
|
|
363
|
+
|
|
364
|
+
Recommended build direction for a deferred remote:
|
|
365
|
+
|
|
366
|
+
- keep `builder: 'ngx-build-plus:browser'`
|
|
367
|
+
- keep `extraWebpackConfig: 'webpack.config.js'`
|
|
368
|
+
- keep `outputHashing: 'none'`
|
|
369
|
+
- set `commonChunk: true`
|
|
370
|
+
|
|
371
|
+
Why `commonChunk` matters:
|
|
372
|
+
|
|
373
|
+
- old eager remotes often used `commonChunk: false` to keep the output shape simpler
|
|
374
|
+
- deferred remotes intentionally produce several cooperating chunks
|
|
375
|
+
- with the deferred module-federation setup, shared code between emitted chunks should be factored into the build output instead of duplicated everywhere
|
|
376
|
+
|
|
377
|
+
Practical rule:
|
|
378
|
+
|
|
379
|
+
- for a deferred remote, follow the deferred baseline and use `commonChunk: true` unless repository instructions, task requirements, or a direct user request explicitly require `false`, and the resulting build or runtime behavior has been validated in that project
|
|
380
|
+
- after changing this setting, deploy the full build output folder, not only `remoteModuleEntry.js`
|
|
381
|
+
|
|
382
|
+
In this guide:
|
|
383
|
+
|
|
384
|
+
- `explicitly require` means the reason is written in repository instructions, task requirements, or a direct user request; do not invent exceptions on your own
|
|
385
|
+
- `validated` means you ran the real project build and checked the specific build or runtime behavior that depends on the non-default setting
|
|
386
|
+
- if you do not have both a written requirement and validation of the dependent behavior, remove the non-default setting and follow the deferred baseline
|
|
387
|
+
|
|
388
|
+
Example build options:
|
|
389
|
+
|
|
390
|
+
```json
|
|
391
|
+
{
|
|
392
|
+
"builder": "ngx-build-plus:browser",
|
|
393
|
+
"options": {
|
|
394
|
+
"main": "src/main.ts",
|
|
395
|
+
"extraWebpackConfig": "webpack.config.js",
|
|
396
|
+
"commonChunk": true,
|
|
397
|
+
"outputHashing": "none"
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
#### 4.2 Webpack config (`webpack.config.js`)
|
|
403
|
+
|
|
404
|
+
##### Mandatory rules
|
|
405
|
+
|
|
406
|
+
The config must:
|
|
407
|
+
|
|
408
|
+
- use `withModuleFederationPlugin(...)` from `@angular-architects/module-federation/webpack`, not a handwritten `new ModuleFederationPlugin(...)` setup
|
|
409
|
+
- expose `./Main` pointing to the file that default-exports `RemoteEntryDefinition`, using the path form correct for the builder's resolution root (the sample exposure path below is schematic, not universally correct)
|
|
410
|
+
- emit `remoteModuleEntry.js`
|
|
411
|
+
- keep the module-federation `name` and `output.uniqueName` aligned with the remote name used in `RemoteEntryDefinition`
|
|
412
|
+
|
|
413
|
+
The config must not:
|
|
414
|
+
|
|
415
|
+
- keep the legacy eager exposure such as `remoteEntry.js` plus `./RemoteEntry` for a fully deferred remote
|
|
416
|
+
- contain `config.output.scriptType` — treat its presence as a migration failure even if the build succeeds; if the old eager remote had `scriptType: 'text/javascript'`, remove it during migration and before treating any build or test results as valid
|
|
417
|
+
- carry over other legacy overrides such as `runtimeChunk: false` or custom `publicPath` unless repository instructions, task requirements, or a direct user request explicitly require them and the resulting build and runtime behavior have been validated
|
|
418
|
+
- rewrite `config.resolve`, `config.output`, or `config.optimization` as fresh objects that reintroduce eager-era overrides — if the migrated config contains that pattern, revert to the direct-mutation shape shown below
|
|
419
|
+
|
|
420
|
+
##### Reference config and implementation guidance
|
|
421
|
+
|
|
422
|
+
Replace `path/to/remote-entry-file.ts` with the actual path to the remote entry file relative to the builder's resolution root.
|
|
423
|
+
|
|
424
|
+
```js
|
|
425
|
+
const { withModuleFederationPlugin } = require('@angular-architects/module-federation/webpack');
|
|
426
|
+
|
|
427
|
+
const config = withModuleFederationPlugin({
|
|
428
|
+
name: 'your_remote_name',
|
|
429
|
+
filename: 'remoteModuleEntry.js',
|
|
430
|
+
exposes: {
|
|
431
|
+
'./Main': 'path/to/remote-entry-file.ts',
|
|
432
|
+
},
|
|
433
|
+
shared: {},
|
|
434
|
+
sharedMappings: [],
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
// Preserve any project-specific aliases the remote already relies on.
|
|
438
|
+
config.resolve.alias.lodash = 'lodash-es';
|
|
439
|
+
|
|
440
|
+
config.output.uniqueName = 'your_remote_name';
|
|
441
|
+
config.optimization.splitChunks = {
|
|
442
|
+
...config.optimization.splitChunks,
|
|
443
|
+
chunks: 'all',
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
module.exports = config;
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
This style is intentional:
|
|
450
|
+
|
|
451
|
+
- start from the object returned by `withModuleFederationPlugin(...)`
|
|
452
|
+
- mutate only the few properties you actually need to change
|
|
453
|
+
- do not rebuild `config.resolve`, `config.output`, or `config.optimization` as fresh objects unless repository instructions, task requirements, or a direct user request explicitly require it and you validated the resulting chunk-loading behavior in the real build
|
|
454
|
+
|
|
455
|
+
Why this matters:
|
|
456
|
+
|
|
457
|
+
- the generated config can contain non-obvious defaults needed for module-federation runtime behavior
|
|
458
|
+
- replacing whole nested objects with spread-based rewrites can accidentally drop or alter settings involved in chunk loading
|
|
459
|
+
- a config that still emits `remoteModuleEntry.js` can be broken if those generated defaults are disturbed
|
|
460
|
+
|
|
461
|
+
For production, if there is no environment-specific delta, the simplest matching pattern is:
|
|
462
|
+
|
|
463
|
+
```js
|
|
464
|
+
module.exports = require('./webpack.config');
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
Recommended implementation details:
|
|
468
|
+
|
|
469
|
+
- prefer extending the config returned by `withModuleFederationPlugin(...)`
|
|
470
|
+
- prefer direct property mutation such as `config.output.uniqueName = ...` over reassigning `config.output = { ... }`
|
|
471
|
+
- prefer direct nested updates such as `config.optimization.splitChunks = { ...config.optimization.splitChunks, chunks: 'all' }`
|
|
472
|
+
- do not defensively rewrite `config.resolve`, `config.output`, or `config.optimization` just because the old config was handwritten
|
|
473
|
+
- if a legacy override is reintroduced, validate that `remoteModuleEntry.js` still initializes and loads follow-up chunks correctly before keeping it
|
|
474
|
+
|
|
475
|
+
Typical follow-up customizations:
|
|
476
|
+
|
|
477
|
+
- preserve aliases such as `lodash: 'lodash-es'` if the old project depended on them
|
|
478
|
+
- keep project-specific shared settings if they were already needed
|
|
479
|
+
- keep the generated defaults from `withModuleFederationPlugin(...)` unless the project has a concrete reason to override them
|
|
480
|
+
- keep any production config that reuses the main webpack config when no environment-specific delta is required
|
|
481
|
+
|
|
482
|
+
##### Anti-pattern to avoid
|
|
483
|
+
|
|
484
|
+
```js
|
|
485
|
+
config.resolve = {
|
|
486
|
+
...(config.resolve || {}),
|
|
487
|
+
alias: {
|
|
488
|
+
...((config.resolve && config.resolve.alias) || {}),
|
|
489
|
+
lodash: 'lodash-es',
|
|
490
|
+
},
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
config.output = {
|
|
494
|
+
...(config.output || {}),
|
|
495
|
+
uniqueName: 'your_remote_name',
|
|
496
|
+
publicPath: 'auto',
|
|
497
|
+
scriptType: 'text/javascript',
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
config.optimization = {
|
|
501
|
+
...(config.optimization || {}),
|
|
502
|
+
runtimeChunk: false,
|
|
503
|
+
splitChunks: {
|
|
504
|
+
...((config.optimization && config.optimization.splitChunks) || {}),
|
|
505
|
+
chunks: 'all',
|
|
506
|
+
},
|
|
507
|
+
};
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
Treat that rewrite style as a migration failure for deferred remotes unless repository instructions, task requirements, or a direct user request explicitly require every rewritten block and every legacy override, and the real build plus the dependent chunk-loading behavior have been validated. It changes generated nested config wholesale and can break chunk loading even when `remoteModuleEntry.js` is still emitted. If that rewritten config sets `scriptType: 'text/javascript'`, stop treating the migration as valid until `scriptType` is removed. A green build does not override this rule. Prefer the small, direct-mutation pattern shown above.
|
|
511
|
+
|
|
512
|
+
Do not leave the old eager entry shape in place after changing webpack. The exposed `./Main` module must return the deferred `RemoteEntryDefinition` export from the remote entry file.
|
|
513
|
+
|
|
514
|
+
##### Validation after webpack migration (mandatory)
|
|
515
|
+
|
|
516
|
+
- run the real project build, not just a lint pass or a static config review
|
|
517
|
+
- verify that the emitted output contains `remoteModuleEntry.js`
|
|
518
|
+
- verify that the configured `./Main` exposure path resolves in the actual build environment used by the project
|
|
519
|
+
- verify that the final webpack config still uses `withModuleFederationPlugin(...)` rather than a handwritten `new ModuleFederationPlugin(...)` container setup
|
|
520
|
+
- verify that `config.output.scriptType` is absent from the final deferred config
|
|
521
|
+
- if eager-era overrides such as `runtimeChunk: false` or custom `publicPath` remain, keep them only when repository instructions, task requirements, or a direct user request explicitly require them, and document the validated build or runtime behavior that depends on them
|
|
522
|
+
|
|
523
|
+
### 5. Introduce a remote app shell
|
|
524
|
+
|
|
525
|
+
Create a minimal root module that provides shared infrastructure but does not register runtime artifacts eagerly.
|
|
526
|
+
|
|
527
|
+
Typical responsibilities of `RemoteAppModule`:
|
|
528
|
+
|
|
529
|
+
- import `BrowserModule`
|
|
530
|
+
- import localization setup such as `RemoteLocalizationModule`
|
|
531
|
+
- optionally import other app-wide providers
|
|
532
|
+
- optionally host one-time global setup that used to live in the old root module, for example icon registration or shared asset initialization
|
|
533
|
+
- implement empty `ngDoBootstrap()`
|
|
534
|
+
|
|
535
|
+
Do not place `@CrtModule(...)` registrations here unless the task explicitly requires eager global bootstrap, which is outside this guide.
|
|
536
|
+
|
|
537
|
+
If the old root module existed mostly to aggregate many imported modules, that aggregation should usually disappear. Keep only true app-wide infrastructure in `RemoteAppModule`.
|
|
538
|
+
|
|
539
|
+
What to do with old `APP_INITIALIZER` logic:
|
|
540
|
+
|
|
541
|
+
- if it initializes app-wide infrastructure needed before any feature activation, keep it in `RemoteAppModule`
|
|
542
|
+
- if it exists only to support runtime behavior of one deferred feature, move it into that feature's activation path or feature-owned module
|
|
543
|
+
- if it exists only for localization bootstrap, keep it inside `RemoteLocalizationModule`
|
|
544
|
+
- do not leave old initializer-driven behavior tied to eager entry bootstrap
|
|
545
|
+
|
|
546
|
+
### 6. Add a reusable remote app context
|
|
547
|
+
|
|
548
|
+
Create a helper like `remote-app-context.ts` that:
|
|
549
|
+
|
|
550
|
+
- bootstraps `RemoteAppModule` once
|
|
551
|
+
- caches the root `NgModuleRef`
|
|
552
|
+
- exposes the root `Injector`
|
|
553
|
+
- can later be extended with translation-specific services if the remote uses localization
|
|
554
|
+
- lazily creates per-feature `NgModuleRef`s via `createNgModule(...)`
|
|
555
|
+
|
|
556
|
+
Prefer a cached bootstrap based on `platformBrowser().bootstrapModule(RemoteAppModule)`. The old eager
|
|
557
|
+
pattern typically bootstraps Angular from a standalone `bootstrap.ts`; the deferred pattern moves bootstrap into the
|
|
558
|
+
cached app-context helper instead.
|
|
559
|
+
|
|
560
|
+
Follow this pattern:
|
|
561
|
+
|
|
562
|
+
```ts
|
|
563
|
+
import { Injector, NgModuleRef, Type, createNgModule } from '@angular/core';
|
|
564
|
+
import { platformBrowser } from '@angular/platform-browser';
|
|
565
|
+
|
|
566
|
+
import { RemoteAppModule } from './remote-app.module';
|
|
567
|
+
|
|
568
|
+
interface RemoteAppContext {
|
|
569
|
+
injector: Injector;
|
|
570
|
+
moduleRef: NgModuleRef<RemoteAppModule>;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
let remoteAppContextPromise: Promise<RemoteAppContext> | undefined;
|
|
574
|
+
const featureModuleRefs = new Map<Type<unknown>, NgModuleRef<unknown>>();
|
|
575
|
+
|
|
576
|
+
async function bootstrapRemoteApp(): Promise<RemoteAppContext> {
|
|
577
|
+
const moduleRef = await platformBrowser().bootstrapModule(RemoteAppModule);
|
|
578
|
+
const injector = moduleRef.injector;
|
|
579
|
+
|
|
580
|
+
return {
|
|
581
|
+
injector,
|
|
582
|
+
moduleRef,
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
export async function ensureRemoteAppContext(): Promise<RemoteAppContext> {
|
|
587
|
+
if (!remoteAppContextPromise) {
|
|
588
|
+
remoteAppContextPromise = bootstrapRemoteApp().catch((error) => {
|
|
589
|
+
remoteAppContextPromise = undefined;
|
|
590
|
+
throw error;
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
return remoteAppContextPromise;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
export async function ensureFeatureModuleRef<T>(moduleType: Type<T>): Promise<NgModuleRef<T>> {
|
|
598
|
+
const existingModuleRef = featureModuleRefs.get(moduleType) as NgModuleRef<T> | undefined;
|
|
599
|
+
if (existingModuleRef) {
|
|
600
|
+
return existingModuleRef;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
const { injector } = await ensureRemoteAppContext();
|
|
604
|
+
const moduleRef = createNgModule(moduleType, injector);
|
|
605
|
+
featureModuleRefs.set(moduleType, moduleRef);
|
|
606
|
+
return moduleRef;
|
|
607
|
+
}
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
This is the base app-context pattern for the guide. If the remote uses localization, extend it in Step 10.3.
|
|
611
|
+
|
|
612
|
+
### 7. Convert runtime registrations into runtime feature activation
|
|
613
|
+
|
|
614
|
+
Move the old eager CRT registration into:
|
|
615
|
+
|
|
616
|
+
- `runtime-feature.module.ts`
|
|
617
|
+
- `runtime.feature-activation.ts`
|
|
618
|
+
- `runtime.feature-definition.ts`
|
|
619
|
+
|
|
620
|
+
#### 7.1 Runtime feature module
|
|
621
|
+
|
|
622
|
+
Create an Angular module that contains the runtime artifacts only:
|
|
623
|
+
|
|
624
|
+
- declarations for runtime components
|
|
625
|
+
- imports needed by those components and injected services
|
|
626
|
+
- `@CrtModule({ viewElements, requestHandlers, validators, converters })`
|
|
627
|
+
|
|
628
|
+
Important:
|
|
629
|
+
|
|
630
|
+
- only public view elements belong in `@CrtModule({ viewElements: [...] })`
|
|
631
|
+
- internal child components used only inside the main view element remain normal Angular declarations
|
|
632
|
+
- do not publish internal helper components as discovered remote types
|
|
633
|
+
- if the old remote used several Angular helper modules, import them here only if this runtime feature still needs them
|
|
634
|
+
- if the old remote used several included `CrtModule`s, move their public runtime artifacts here only when they belong to this runtime activation boundary
|
|
635
|
+
|
|
636
|
+
Do not bootstrap this module from the entry.
|
|
637
|
+
|
|
638
|
+
#### 7.2 Runtime activation file
|
|
639
|
+
|
|
640
|
+
The activation function must:
|
|
641
|
+
|
|
642
|
+
- get or create the feature module ref
|
|
643
|
+
- define custom elements
|
|
644
|
+
- call `bootstrapCrtModule(remoteName, RuntimeFeatureModule, ...)`
|
|
645
|
+
|
|
646
|
+
Target pattern:
|
|
647
|
+
|
|
648
|
+
```ts
|
|
649
|
+
import { Injector, ProviderToken, Type } from '@angular/core';
|
|
650
|
+
import { createCustomElement } from '@angular/elements';
|
|
651
|
+
import { bootstrapCrtModule } from '@creatio-devkit/common';
|
|
652
|
+
|
|
653
|
+
import { ensureFeatureModuleRef, ensureRemoteAppContext } from '../../remote-app-context';
|
|
654
|
+
import { REMOTE_NAME, SOME_ELEMENT_SELECTOR } from './<constants-file>';
|
|
655
|
+
import { RuntimeFeatureModule } from './runtime-feature.module';
|
|
656
|
+
import { SomeComponent } from './view-elements/some-element.component';
|
|
657
|
+
|
|
658
|
+
function defineCustomElement(selector: string, component: Type<unknown>, injector: Injector): void {
|
|
659
|
+
if (!customElements.get(selector)) {
|
|
660
|
+
customElements.define(selector, createCustomElement(component, { injector }));
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
export async function activateRuntimeFeature(): Promise<void> {
|
|
665
|
+
await ensureRemoteAppContext();
|
|
666
|
+
const moduleRef = await ensureFeatureModuleRef(RuntimeFeatureModule);
|
|
667
|
+
const injector = moduleRef.injector;
|
|
668
|
+
|
|
669
|
+
defineCustomElement(SOME_ELEMENT_SELECTOR, SomeComponent, injector);
|
|
670
|
+
|
|
671
|
+
bootstrapCrtModule(REMOTE_NAME, RuntimeFeatureModule, {
|
|
672
|
+
resolveDependency: (token) => injector.get(token as ProviderToken<unknown>),
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
Notes:
|
|
678
|
+
|
|
679
|
+
- keep the `customElements.get(...)` guard
|
|
680
|
+
- keep `resolveDependency` when handlers, validators, converters, or components need DI
|
|
681
|
+
- add `localizeMetadata` only if the remote still has bootstrapped metadata that uses `localize()`, and only after applying the localized app-context variant from Step 10.3
|
|
682
|
+
- if the old root module performed one-time setup such as icon registration, move it into a guarded helper called from `activate()` or into the shared remote app shell
|
|
683
|
+
|
|
684
|
+
#### 7.3 Runtime feature definition
|
|
685
|
+
|
|
686
|
+
Create discovery metadata for every runtime type that used to be registered eagerly.
|
|
687
|
+
|
|
688
|
+
##### 7.3.1 Create constants files for shared identifiers
|
|
689
|
+
|
|
690
|
+
Before writing the feature definition, extract all type identifiers, request types, scopes, selectors, and feature IDs into lightweight constants files. These files are imported by both the feature definition (for discovery metadata) and the implementation files (for decorators), keeping identifiers in sync without duplication.
|
|
691
|
+
|
|
692
|
+
How to organize the constants files depends on the remote's size and artifact mix. A single file is fine for a small remote. When the remote has many artifacts, split by concern for readability.
|
|
693
|
+
|
|
694
|
+
All constants files must remain lightweight (only small string constants) and safe to import from feature-definition files.
|
|
695
|
+
|
|
696
|
+
##### 7.3.2 Update decorators to use constants
|
|
697
|
+
|
|
698
|
+
Replace inline string literals in decorators with the shared constants:
|
|
699
|
+
|
|
700
|
+
Old pattern:
|
|
701
|
+
|
|
702
|
+
```ts
|
|
703
|
+
@CrtRequestHandler({
|
|
704
|
+
type: 'usr.SomeHandler',
|
|
705
|
+
requestType: 'usr.SomeRequest',
|
|
706
|
+
scopes: ['SomePage_FormPage'],
|
|
707
|
+
})
|
|
708
|
+
export class SomeHandler extends BaseRequestHandler { ... }
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
Target pattern:
|
|
712
|
+
|
|
713
|
+
```ts
|
|
714
|
+
import { SOME_HANDLER, SOME_REQUEST, SOME_PAGE_SCOPE } from '../<constants-file>';
|
|
715
|
+
|
|
716
|
+
@CrtRequestHandler({
|
|
717
|
+
type: SOME_HANDLER,
|
|
718
|
+
requestType: SOME_REQUEST,
|
|
719
|
+
scopes: [SOME_PAGE_SCOPE],
|
|
720
|
+
})
|
|
721
|
+
export class SomeHandler extends BaseRequestHandler { ... }
|
|
722
|
+
```
|
|
723
|
+
|
|
724
|
+
The same approach applies to all artifact types. For example, a view element:
|
|
725
|
+
|
|
726
|
+
```ts
|
|
727
|
+
import { SOME_ELEMENT_SELECTOR, SOME_ELEMENT_TYPE } from '../<constants-file>';
|
|
728
|
+
|
|
729
|
+
@CrtViewElement({
|
|
730
|
+
selector: SOME_ELEMENT_SELECTOR,
|
|
731
|
+
type: SOME_ELEMENT_TYPE,
|
|
732
|
+
})
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
##### 7.3.3 Write the feature definition with complete discovery metadata
|
|
736
|
+
|
|
737
|
+
The feature definition must populate every field that the discovery metadata contract accepts when the runtime decorator provides that data.
|
|
738
|
+
|
|
739
|
+
Discovery metadata fields per artifact kind:
|
|
740
|
+
|
|
741
|
+
- `viewElements`: `{ type }`
|
|
742
|
+
- `mobileViewElements`: `{ type }`
|
|
743
|
+
- `converters`: `{ type }`
|
|
744
|
+
- `validators`: `{ type }`
|
|
745
|
+
- `requestHandlers`: `{ type, requestType, scopes? }`
|
|
746
|
+
|
|
747
|
+
For each artifact, check which fields the discovery metadata interface declares and copy every matching value from the decorator. For example, `RemoteRequestHandlerDiscoveryMetadata` accepts `requestType` and `scopes`, so if the handler's `@CrtRequestHandler` sets those, include them in discovery. If a field is optional and absent on the decorator, omit it. Incomplete discovery metadata causes the host to register the artifact incorrectly.
|
|
748
|
+
|
|
749
|
+
Typical shape:
|
|
750
|
+
|
|
751
|
+
```ts
|
|
752
|
+
import type { RemoteFeatureDefinition } from '@creatio-devkit/common';
|
|
753
|
+
|
|
754
|
+
import {
|
|
755
|
+
SOME_ELEMENT_TYPE, SOME_CONVERTER_TYPE, SOME_VALIDATOR_TYPE,
|
|
756
|
+
SOME_HANDLER, SOME_REQUEST, SOME_PAGE_SCOPE,
|
|
757
|
+
ANOTHER_HANDLER, HANDLE_VIEW_MODEL_INIT_REQUEST, SOME_MINI_PAGE_SCOPE,
|
|
758
|
+
} from './<constants-file>';
|
|
759
|
+
|
|
760
|
+
export const runtimeFeatureDefinition = {
|
|
761
|
+
id: 'your-remote-runtime',
|
|
762
|
+
discovery: {
|
|
763
|
+
viewElements: [
|
|
764
|
+
{ type: SOME_ELEMENT_TYPE },
|
|
765
|
+
],
|
|
766
|
+
converters: [
|
|
767
|
+
{ type: SOME_CONVERTER_TYPE },
|
|
768
|
+
],
|
|
769
|
+
validators: [
|
|
770
|
+
{ type: SOME_VALIDATOR_TYPE },
|
|
771
|
+
],
|
|
772
|
+
requestHandlers: [
|
|
773
|
+
{
|
|
774
|
+
type: SOME_HANDLER,
|
|
775
|
+
requestType: SOME_REQUEST,
|
|
776
|
+
scopes: [SOME_PAGE_SCOPE],
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
type: ANOTHER_HANDLER,
|
|
780
|
+
requestType: HANDLE_VIEW_MODEL_INIT_REQUEST,
|
|
781
|
+
scopes: [SOME_MINI_PAGE_SCOPE],
|
|
782
|
+
},
|
|
783
|
+
],
|
|
784
|
+
},
|
|
785
|
+
loadDesignerDefinitions: (context) =>
|
|
786
|
+
import('./runtime.designer-definitions').then((m) => m.loadDesignerDefinitions(context)),
|
|
787
|
+
activate: () =>
|
|
788
|
+
import('./runtime.feature-activation').then((m) => m.activateRuntimeFeature()),
|
|
789
|
+
} satisfies RemoteFeatureDefinition;
|
|
790
|
+
```
|
|
791
|
+
|
|
792
|
+
Rules:
|
|
793
|
+
|
|
794
|
+
- publish only stable public type names in discovery
|
|
795
|
+
- for request handlers, always include `requestType` in discovery; include `scopes` when the handler declares scopes on the decorator
|
|
796
|
+
- use the same constant for `type`/`requestType`/`scopes` in both the feature definition and the handler decorator to guarantee consistency
|
|
797
|
+
- do not import heavy runtime modules in the feature-definition file itself
|
|
798
|
+
- keep `activate()` and `loadDesignerDefinitions()` as dynamic imports
|
|
799
|
+
- import only lightweight identifiers from feature-definition files
|
|
800
|
+
- do not import icons, raw-loader assets, large JSON-like config objects, or activation-only constants into feature-definition files
|
|
801
|
+
- avoid barrel files if they pull activation-only data into the feature-definition import graph
|
|
802
|
+
|
|
803
|
+
Guard for existing `constants.ts` files:
|
|
804
|
+
|
|
805
|
+
- if an existing constants file already mixes small discovery IDs with activation-only data, do not keep importing that whole file from the remote entry file or `*.feature-definition.ts`
|
|
806
|
+
- split it so that lightweight discovery constants are separate from activation-only data, for example:
|
|
807
|
+
- one or more files for lightweight string constants (type names, selectors, request types, scopes)
|
|
808
|
+
- separate files for icons, big defaults, and other lazy-only data
|
|
809
|
+
- after the split, ensure entry and feature-definition files depend only on the lightweight files
|
|
810
|
+
|
|
811
|
+
### 8. Move designer metadata out of runtime decorators
|
|
812
|
+
|
|
813
|
+
This is the most important migration step.
|
|
814
|
+
|
|
815
|
+
Remove from runtime view elements:
|
|
816
|
+
|
|
817
|
+
- `@CrtInterfaceDesignerItem(...)`
|
|
818
|
+
- `@CrtMobileInterfaceDesignerItem(...)`
|
|
819
|
+
|
|
820
|
+
Keep on runtime view elements:
|
|
821
|
+
|
|
822
|
+
- `@CrtViewElement(...)`
|
|
823
|
+
- `@CrtMobileViewElement(...)`, if the remote exposes mobile elements
|
|
824
|
+
- normal `@Input()` and `@Output()` pairs with `@CrtInput()` and `@CrtOutput()`
|
|
825
|
+
|
|
826
|
+
Replace them with a designer-definition loader:
|
|
827
|
+
|
|
828
|
+
```ts
|
|
829
|
+
import { SOME_ELEMENT_TYPE } from './<constants-file>';
|
|
830
|
+
|
|
831
|
+
export async function loadDesignerDefinitions(
|
|
832
|
+
context: RemoteDesignerDefinitionsLoadContext,
|
|
833
|
+
): Promise<RemoteFeatureDesignerDefinitions> {
|
|
834
|
+
return {
|
|
835
|
+
viewElements: [
|
|
836
|
+
{
|
|
837
|
+
type: SOME_ELEMENT_TYPE,
|
|
838
|
+
toolbarConfig: {
|
|
839
|
+
caption: 'Some component',
|
|
840
|
+
icon: SOME_ICON,
|
|
841
|
+
},
|
|
842
|
+
defaultPropertyValues: {
|
|
843
|
+
label: 'Click me',
|
|
844
|
+
},
|
|
845
|
+
propertiesPanel: 'usr.SomeElementPropertiesPanel',
|
|
846
|
+
},
|
|
847
|
+
],
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
```
|
|
851
|
+
|
|
852
|
+
Important:
|
|
853
|
+
|
|
854
|
+
- `type` must match the type already published in runtime discovery; use the same shared constant to guarantee this
|
|
855
|
+
- `propertiesPanel` must point to a separately discovered design-time panel type if a custom panel exists
|
|
856
|
+
- designer definitions must return plain metadata only, not runtime registration side effects
|
|
857
|
+
- icons and large designer-only defaults must live in designer-definition-local files, not in shared constants imported by entry or feature-definition code
|
|
858
|
+
- preserve existing icon assets during migration unless the task explicitly asks to change them
|
|
859
|
+
- if icon assets are newly created or modified during migration, follow `ICON_REQUIREMENTS_AI_GUIDE.md`
|
|
860
|
+
- if the remote localizes designer metadata, translate `caption`, hints, and default values here as described in Step 10.3 and Step 10.5
|
|
861
|
+
|
|
862
|
+
### 9. Create or keep the design feature and use it for custom properties panels
|
|
863
|
+
|
|
864
|
+
In the recommended default structure, ensure the remote has a design feature even when it initially contains no discovered types.
|
|
865
|
+
|
|
866
|
+
If the old remote has no current design-only artifacts, create the design feature as a minimal placeholder and keep it in the final structure until a property panel or other design-only element is introduced.
|
|
867
|
+
|
|
868
|
+
If the old remote had a custom properties panel, do not keep it hidden inside runtime bootstrap.
|
|
869
|
+
|
|
870
|
+
This applies even when the property panel used to live:
|
|
871
|
+
|
|
872
|
+
- in the root eager module
|
|
873
|
+
- in a nested included `CrtModule`
|
|
874
|
+
- in an Angular module imported by the old root module
|
|
875
|
+
- next to a runtime component inside the same old folder or module
|
|
876
|
+
|
|
877
|
+
Create:
|
|
878
|
+
|
|
879
|
+
- `design-feature.module.ts`
|
|
880
|
+
- `design.feature-activation.ts`
|
|
881
|
+
- `design.feature-definition.ts`
|
|
882
|
+
|
|
883
|
+
Minimal future-ready pattern when no property panels exist yet:
|
|
884
|
+
|
|
885
|
+
```ts
|
|
886
|
+
export const designFeatureDefinition = {
|
|
887
|
+
id: 'your-remote-design',
|
|
888
|
+
discovery: {
|
|
889
|
+
viewElements: [],
|
|
890
|
+
},
|
|
891
|
+
activate: () =>
|
|
892
|
+
import('./design.feature-activation').then((m) => m.activateDesignFeature()),
|
|
893
|
+
} satisfies RemoteFeatureDefinition;
|
|
894
|
+
```
|
|
895
|
+
|
|
896
|
+
Later, when a property panel is added, publish it through this existing design feature instead of introducing a brand new feature shape.
|
|
897
|
+
|
|
898
|
+
The design feature must:
|
|
899
|
+
|
|
900
|
+
- publish the panel type in `discovery.viewElements`
|
|
901
|
+
- activate the panel component lazily
|
|
902
|
+
- bootstrap its own `@CrtModule(...)`
|
|
903
|
+
- keep the panel component decorated as a normal view element so the panel type can still be registered
|
|
904
|
+
|
|
905
|
+
Pattern:
|
|
906
|
+
|
|
907
|
+
```ts
|
|
908
|
+
export const designFeatureDefinition = {
|
|
909
|
+
id: 'your-remote-design',
|
|
910
|
+
discovery: {
|
|
911
|
+
viewElements: [{ type: 'usr.SomeElementPropertiesPanel' }],
|
|
912
|
+
},
|
|
913
|
+
activate: () =>
|
|
914
|
+
import('./design.feature-activation').then((m) => m.activateDesignFeature()),
|
|
915
|
+
} satisfies RemoteFeatureDefinition;
|
|
916
|
+
```
|
|
917
|
+
|
|
918
|
+
In this pattern, runtime designer definitions return `propertiesPanel`, while the actual panel component is discovered and activated through a separate design feature.
|
|
919
|
+
|
|
920
|
+
### 10. Migrate translations
|
|
921
|
+
|
|
922
|
+
Translations require special handling because the old guide assumes eager decorator metadata localization.
|
|
923
|
+
|
|
924
|
+
#### 10.1 Keep translation files in static content
|
|
925
|
+
|
|
926
|
+
Keep or add:
|
|
927
|
+
|
|
928
|
+
- `src/assets/i18n/en-US.json`
|
|
929
|
+
- `src/assets/i18n/<other-culture>.json`
|
|
930
|
+
|
|
931
|
+
Load them from the remote's public path, not from a host-relative hardcoded URL.
|
|
932
|
+
|
|
933
|
+
Example:
|
|
934
|
+
|
|
935
|
+
```json
|
|
936
|
+
{
|
|
937
|
+
"Some": {
|
|
938
|
+
"Designer": {
|
|
939
|
+
"Caption": "Some component"
|
|
940
|
+
},
|
|
941
|
+
"Runtime": {
|
|
942
|
+
"DefaultLabel": "Click me",
|
|
943
|
+
"AlertMessage": "Component says: {{label}}"
|
|
944
|
+
},
|
|
945
|
+
"PropertyPanel": {
|
|
946
|
+
"Label": "Button label",
|
|
947
|
+
"Apply": "Apply"
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
```
|
|
952
|
+
|
|
953
|
+
#### 10.2 Add a localization module
|
|
954
|
+
|
|
955
|
+
Create a localization module that:
|
|
956
|
+
|
|
957
|
+
- import `HttpClientModule`
|
|
958
|
+
- configure `TranslateModule.forRoot(...)`
|
|
959
|
+
- use `TranslateHttpLoader`
|
|
960
|
+
- build URLs from `__webpack_public_path__`
|
|
961
|
+
- use `APP_INITIALIZER` to load the user's default culture
|
|
962
|
+
|
|
963
|
+
Recommended pattern:
|
|
964
|
+
|
|
965
|
+
```ts
|
|
966
|
+
import { HttpClient, HttpClientModule } from '@angular/common/http';
|
|
967
|
+
import { APP_INITIALIZER, NgModule } from '@angular/core';
|
|
968
|
+
import { SysValuesService } from '@creatio-devkit/common';
|
|
969
|
+
import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core';
|
|
970
|
+
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
|
|
971
|
+
import { catchError, firstValueFrom } from 'rxjs';
|
|
972
|
+
|
|
973
|
+
declare const __webpack_public_path__: string;
|
|
974
|
+
const DEFAULT_CULTURE_NAME = 'en-US';
|
|
975
|
+
|
|
976
|
+
async function getUserCultureName(): Promise<string> {
|
|
977
|
+
try {
|
|
978
|
+
const sysValues = await new SysValuesService().loadSysValues();
|
|
979
|
+
return sysValues?.userCulture?.displayValue || DEFAULT_CULTURE_NAME;
|
|
980
|
+
} catch {
|
|
981
|
+
return DEFAULT_CULTURE_NAME;
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
@NgModule({
|
|
986
|
+
imports: [
|
|
987
|
+
HttpClientModule,
|
|
988
|
+
TranslateModule.forRoot({
|
|
989
|
+
defaultLanguage: DEFAULT_CULTURE_NAME,
|
|
990
|
+
loader: {
|
|
991
|
+
provide: TranslateLoader,
|
|
992
|
+
useFactory: (httpClient: HttpClient) =>
|
|
993
|
+
new TranslateHttpLoader(httpClient, `${__webpack_public_path__}assets/i18n/`, '.json'),
|
|
994
|
+
deps: [HttpClient],
|
|
995
|
+
},
|
|
996
|
+
}),
|
|
997
|
+
],
|
|
998
|
+
exports: [TranslateModule],
|
|
999
|
+
providers: [{
|
|
1000
|
+
provide: APP_INITIALIZER,
|
|
1001
|
+
useFactory: (translateService: TranslateService) => async () => {
|
|
1002
|
+
const cultureName = await getUserCultureName();
|
|
1003
|
+
await firstValueFrom(
|
|
1004
|
+
translateService.use(cultureName).pipe(
|
|
1005
|
+
catchError(() => translateService.use(DEFAULT_CULTURE_NAME)),
|
|
1006
|
+
),
|
|
1007
|
+
);
|
|
1008
|
+
},
|
|
1009
|
+
multi: true,
|
|
1010
|
+
deps: [TranslateService],
|
|
1011
|
+
}],
|
|
1012
|
+
})
|
|
1013
|
+
export class RemoteLocalizationModule {}
|
|
1014
|
+
```
|
|
1015
|
+
|
|
1016
|
+
Use `SysValuesService` to resolve the user's culture and fall back to `en-US`.
|
|
1017
|
+
|
|
1018
|
+
Note about `SysValuesService` in this example:
|
|
1019
|
+
|
|
1020
|
+
- this guide uses `new SysValuesService()` intentionally
|
|
1021
|
+
- in the current public API this service is dependency-free and is expected to be created this way
|
|
1022
|
+
- do not replace it with Angular DI unless the service contract changes in the future
|
|
1023
|
+
|
|
1024
|
+
Use `RemoteLocalizationModule` as shared remote infrastructure:
|
|
1025
|
+
|
|
1026
|
+
- import it in `RemoteAppModule`
|
|
1027
|
+
- do not re-register `TranslateModule.forRoot(...)` separately in each feature module
|
|
1028
|
+
- in runtime or design feature modules, import `TranslateModule` only when templates, pipes, or injected translation services are used there
|
|
1029
|
+
|
|
1030
|
+
Minimal `RemoteAppModule` shape:
|
|
1031
|
+
|
|
1032
|
+
```ts
|
|
1033
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
1034
|
+
import { DoBootstrap, NgModule } from '@angular/core';
|
|
1035
|
+
|
|
1036
|
+
import { RemoteLocalizationModule } from './localization/remote-localization.module';
|
|
1037
|
+
|
|
1038
|
+
@NgModule({
|
|
1039
|
+
imports: [BrowserModule, RemoteLocalizationModule],
|
|
1040
|
+
})
|
|
1041
|
+
export class RemoteAppModule implements DoBootstrap {
|
|
1042
|
+
public ngDoBootstrap(): void {}
|
|
1043
|
+
}
|
|
1044
|
+
```
|
|
1045
|
+
|
|
1046
|
+
Typical feature-module usage:
|
|
1047
|
+
|
|
1048
|
+
```ts
|
|
1049
|
+
import { CommonModule } from '@angular/common';
|
|
1050
|
+
import { NgModule } from '@angular/core';
|
|
1051
|
+
import { CrtModule } from '@creatio-devkit/common';
|
|
1052
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
1053
|
+
|
|
1054
|
+
import { SomeElementComponent } from './view-elements/some-element.component';
|
|
1055
|
+
|
|
1056
|
+
@CrtModule({
|
|
1057
|
+
viewElements: [SomeElementComponent],
|
|
1058
|
+
})
|
|
1059
|
+
@NgModule({
|
|
1060
|
+
declarations: [SomeElementComponent],
|
|
1061
|
+
imports: [CommonModule, TranslateModule],
|
|
1062
|
+
})
|
|
1063
|
+
export class RuntimeFeatureModule {}
|
|
1064
|
+
```
|
|
1065
|
+
|
|
1066
|
+
Why this split works:
|
|
1067
|
+
|
|
1068
|
+
- `RemoteLocalizationModule` initializes the translation infrastructure once for the whole remote app
|
|
1069
|
+
- feature modules can consume `TranslateService` and the `translate` pipe through normal Angular imports
|
|
1070
|
+
- `ensureRemoteAppContext(cultureName)` can reuse the same root translation service when designer definitions need a specific culture
|
|
1071
|
+
|
|
1072
|
+
#### 10.3 Make `ensureRemoteAppContext(...)` culture-aware
|
|
1073
|
+
|
|
1074
|
+
When `loadDesignerDefinitions({ cultureName })` is called, the remote must be able to switch translation state before returning localized toolbox metadata.
|
|
1075
|
+
|
|
1076
|
+
Target behavior:
|
|
1077
|
+
|
|
1078
|
+
- default bootstrap loads the user's current culture
|
|
1079
|
+
- designer metadata loading can request a specific `cultureName`
|
|
1080
|
+
- `ensureRemoteAppContext(cultureName)` switches `TranslateService` to that language if needed
|
|
1081
|
+
|
|
1082
|
+
This is required because designer definitions are loaded separately from runtime activation.
|
|
1083
|
+
|
|
1084
|
+
If the remote does not use localization, keep the base Step 6 implementation unchanged and skip this step.
|
|
1085
|
+
|
|
1086
|
+
If the remote does use localization, replace the Step 6 app-context shape with a localization-aware variant like this:
|
|
1087
|
+
|
|
1088
|
+
```ts
|
|
1089
|
+
import { Injector, NgModuleRef, Type, createNgModule } from '@angular/core';
|
|
1090
|
+
import { platformBrowser } from '@angular/platform-browser';
|
|
1091
|
+
import { TranslateService } from '@ngx-translate/core';
|
|
1092
|
+
import { firstValueFrom } from 'rxjs';
|
|
1093
|
+
|
|
1094
|
+
import { RemoteAppModule } from './remote-app.module';
|
|
1095
|
+
|
|
1096
|
+
interface RemoteAppContext {
|
|
1097
|
+
injector: Injector;
|
|
1098
|
+
moduleRef: NgModuleRef<RemoteAppModule>;
|
|
1099
|
+
translateService: TranslateService;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
let remoteAppContextPromise: Promise<RemoteAppContext> | undefined;
|
|
1103
|
+
const featureModuleRefs = new Map<Type<unknown>, NgModuleRef<unknown>>();
|
|
1104
|
+
|
|
1105
|
+
async function bootstrapRemoteApp(): Promise<RemoteAppContext> {
|
|
1106
|
+
const moduleRef = await platformBrowser().bootstrapModule(RemoteAppModule);
|
|
1107
|
+
const injector = moduleRef.injector;
|
|
1108
|
+
|
|
1109
|
+
return {
|
|
1110
|
+
injector,
|
|
1111
|
+
moduleRef,
|
|
1112
|
+
translateService: injector.get(TranslateService),
|
|
1113
|
+
};
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
export async function ensureRemoteAppContext(cultureName?: string): Promise<RemoteAppContext> {
|
|
1117
|
+
if (!remoteAppContextPromise) {
|
|
1118
|
+
remoteAppContextPromise = bootstrapRemoteApp().catch((error) => {
|
|
1119
|
+
remoteAppContextPromise = undefined;
|
|
1120
|
+
throw error;
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
const context = await remoteAppContextPromise;
|
|
1125
|
+
if (cultureName && context.translateService.currentLang !== cultureName) {
|
|
1126
|
+
await firstValueFrom(context.translateService.use(cultureName));
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
return context;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
export async function ensureFeatureModuleRef<T>(moduleType: Type<T>): Promise<NgModuleRef<T>> {
|
|
1133
|
+
const existingModuleRef = featureModuleRefs.get(moduleType) as NgModuleRef<T> | undefined;
|
|
1134
|
+
if (existingModuleRef) {
|
|
1135
|
+
return existingModuleRef;
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
const { injector } = await ensureRemoteAppContext();
|
|
1139
|
+
const moduleRef = createNgModule(moduleType, injector);
|
|
1140
|
+
featureModuleRefs.set(moduleType, moduleRef);
|
|
1141
|
+
return moduleRef;
|
|
1142
|
+
}
|
|
1143
|
+
```
|
|
1144
|
+
|
|
1145
|
+
Use this localized variant only when the remote actually needs translation infrastructure.
|
|
1146
|
+
|
|
1147
|
+
#### 10.4 Runtime strings
|
|
1148
|
+
|
|
1149
|
+
Runtime strings inside:
|
|
1150
|
+
|
|
1151
|
+
- view elements
|
|
1152
|
+
- request handlers
|
|
1153
|
+
- validators
|
|
1154
|
+
- converters
|
|
1155
|
+
|
|
1156
|
+
should keep using the translation service directly at execution time.
|
|
1157
|
+
|
|
1158
|
+
Typical patterns:
|
|
1159
|
+
|
|
1160
|
+
- inject `TranslateService` into components or services
|
|
1161
|
+
- call `translateService.instant(...)` when building runtime text
|
|
1162
|
+
- keep required Angular translation modules inside the feature module that owns those artifacts
|
|
1163
|
+
|
|
1164
|
+
Example in a runtime view element:
|
|
1165
|
+
|
|
1166
|
+
```ts
|
|
1167
|
+
import { Component, Input } from '@angular/core';
|
|
1168
|
+
import { CrtInput, CrtViewElement } from '@creatio-devkit/common';
|
|
1169
|
+
import { TranslateService } from '@ngx-translate/core';
|
|
1170
|
+
import { SOME_ELEMENT_SELECTOR, SOME_ELEMENT_TYPE } from '../<constants-file>';
|
|
1171
|
+
|
|
1172
|
+
@CrtViewElement({
|
|
1173
|
+
selector: SOME_ELEMENT_SELECTOR,
|
|
1174
|
+
type: SOME_ELEMENT_TYPE,
|
|
1175
|
+
})
|
|
1176
|
+
@Component({
|
|
1177
|
+
selector: 'usr-some-element-internal',
|
|
1178
|
+
template: `<button type="button" (click)="showAlert()">{{ effectiveLabel }}</button>`,
|
|
1179
|
+
})
|
|
1180
|
+
export class SomeElementComponent {
|
|
1181
|
+
constructor(private readonly translateService: TranslateService) {}
|
|
1182
|
+
|
|
1183
|
+
@Input()
|
|
1184
|
+
@CrtInput()
|
|
1185
|
+
public label = '';
|
|
1186
|
+
|
|
1187
|
+
public get effectiveLabel(): string {
|
|
1188
|
+
return this.label || this.translateService.instant('Some.Runtime.DefaultLabel');
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
public showAlert(): void {
|
|
1192
|
+
alert(this.translateService.instant('Some.Runtime.AlertMessage', {
|
|
1193
|
+
label: this.effectiveLabel,
|
|
1194
|
+
}));
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
```
|
|
1198
|
+
|
|
1199
|
+
Example in a runtime handler:
|
|
1200
|
+
|
|
1201
|
+
```ts
|
|
1202
|
+
import { BaseRequest, BaseRequestHandler, CrtRequestHandler } from '@creatio-devkit/common';
|
|
1203
|
+
import { TranslateService } from '@ngx-translate/core';
|
|
1204
|
+
import { SOME_HANDLER, SOME_REQUEST } from '../<constants-file>';
|
|
1205
|
+
|
|
1206
|
+
@CrtRequestHandler({
|
|
1207
|
+
type: SOME_HANDLER,
|
|
1208
|
+
requestType: SOME_REQUEST,
|
|
1209
|
+
})
|
|
1210
|
+
export class SomeHandler extends BaseRequestHandler<BaseRequest> {
|
|
1211
|
+
constructor(private readonly translateService: TranslateService) {
|
|
1212
|
+
super();
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
public async handle(request: BaseRequest): Promise<unknown> {
|
|
1216
|
+
request.$context['SomeMessage'] = this.translateService.instant('Some.Runtime.DefaultLabel');
|
|
1217
|
+
return this.next?.handle(request);
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
```
|
|
1221
|
+
|
|
1222
|
+
#### 10.5 Designer metadata strings
|
|
1223
|
+
|
|
1224
|
+
Old pattern:
|
|
1225
|
+
|
|
1226
|
+
- `caption: localize('Some.Caption')`
|
|
1227
|
+
- `bootstrapCrtModule(..., { localizeMetadata })`
|
|
1228
|
+
|
|
1229
|
+
Deferred pattern:
|
|
1230
|
+
|
|
1231
|
+
- translate caption, hint, and default property values inside `loadDesignerDefinitions(...)`
|
|
1232
|
+
- return final strings there
|
|
1233
|
+
|
|
1234
|
+
Do not depend on `@CrtInterfaceDesignerItem` metadata localization in the deferred flow.
|
|
1235
|
+
|
|
1236
|
+
Detailed example:
|
|
1237
|
+
|
|
1238
|
+
```ts
|
|
1239
|
+
import type {
|
|
1240
|
+
RemoteDesignerDefinitionsLoadContext,
|
|
1241
|
+
RemoteFeatureDesignerDefinitions,
|
|
1242
|
+
} from '@creatio-devkit/common';
|
|
1243
|
+
|
|
1244
|
+
import { ensureRemoteAppContext } from '../../remote-app-context';
|
|
1245
|
+
import { SOME_ELEMENT_TYPE } from './<constants-file>';
|
|
1246
|
+
|
|
1247
|
+
const SOME_ICON = '[existing icon content preserved during migration]';
|
|
1248
|
+
|
|
1249
|
+
export async function loadDesignerDefinitions(
|
|
1250
|
+
context: RemoteDesignerDefinitionsLoadContext,
|
|
1251
|
+
): Promise<RemoteFeatureDesignerDefinitions> {
|
|
1252
|
+
const { translateService } = await ensureRemoteAppContext(context.cultureName);
|
|
1253
|
+
|
|
1254
|
+
return {
|
|
1255
|
+
viewElements: [
|
|
1256
|
+
{
|
|
1257
|
+
type: SOME_ELEMENT_TYPE,
|
|
1258
|
+
toolbarConfig: {
|
|
1259
|
+
caption: translateService.instant('Some.Designer.Caption'),
|
|
1260
|
+
icon: SOME_ICON,
|
|
1261
|
+
},
|
|
1262
|
+
defaultPropertyValues: {
|
|
1263
|
+
label: translateService.instant('Some.Runtime.DefaultLabel'),
|
|
1264
|
+
},
|
|
1265
|
+
propertiesPanel: 'usr.SomeElementPropertiesPanel',
|
|
1266
|
+
},
|
|
1267
|
+
],
|
|
1268
|
+
};
|
|
1269
|
+
}
|
|
1270
|
+
```
|
|
1271
|
+
|
|
1272
|
+
If the remote also exposes mobile view elements, return `mobileViewElements` in the same localized way.
|
|
1273
|
+
|
|
1274
|
+
### 11. Remove obsolete eager-only artifacts
|
|
1275
|
+
|
|
1276
|
+
After migration, remove or stop using:
|
|
1277
|
+
|
|
1278
|
+
- eager `src/bootstrap.ts`
|
|
1279
|
+
- eager bootstrap import from entry
|
|
1280
|
+
- runtime interface-designer decorators
|
|
1281
|
+
- legacy designer metadata stored on runtime decorators
|
|
1282
|
+
|
|
1283
|
+
Keep legacy artifacts only if the task explicitly requests a mixed compatibility mode.
|
|
1284
|
+
|
|
1285
|
+
## Mandatory Verification Checklist
|
|
1286
|
+
|
|
1287
|
+
Consider the migration incomplete until all checks below are true:
|
|
1288
|
+
|
|
1289
|
+
- the remote entry file default-exports `RemoteEntryDefinition`
|
|
1290
|
+
- the final entry does not eagerly bootstrap Angular when the goal is fully deferred
|
|
1291
|
+
- the final webpack config is created from `withModuleFederationPlugin(...)`, not from a handwritten `new ModuleFederationPlugin(...)` migration fallback
|
|
1292
|
+
- the real project build resolves the configured `./Main` exposure path and emits `remoteModuleEntry.js`
|
|
1293
|
+
- the final deferred webpack config does not contain `config.output.scriptType`
|
|
1294
|
+
- every discovered type is registered only from `activate()`
|
|
1295
|
+
- discovery metadata for each artifact populates every field the discovery contract accepts when the decorator provides that data (for example, `requestType` and `scopes` for handlers)
|
|
1296
|
+
- artifact type identifiers, request types, scopes, and selectors use shared constants imported by both feature definitions and decorator sites
|
|
1297
|
+
- runtime components no longer use `@CrtInterfaceDesignerItem` or `@CrtMobileInterfaceDesignerItem`
|
|
1298
|
+
- designer captions/icons/defaults come from `loadDesignerDefinitions(...)`
|
|
1299
|
+
- every `propertiesPanel` type is discoverable and activatable
|
|
1300
|
+
- translations load from `assets/i18n` using `__webpack_public_path__`
|
|
1301
|
+
- `ensureRemoteAppContext(cultureName)` can switch translations for designer-definition loading
|
|
1302
|
+
- runtime handlers, validators, and converters still resolve DI through `bootstrapCrtModule(..., { resolveDependency })`
|
|
1303
|
+
- custom elements are guarded with `customElements.get(...)`
|
|
1304
|
+
- migrated source files for runtime and design-only artifacts no longer remain in obsolete old top-level folders unless those folders contain code that is still truly shared
|
|
1305
|
+
- feature-local barrel files do not merely re-export old root-level runtime-only or design-only implementation files
|
|
1306
|
+
- the remote still works in runtime pages
|
|
1307
|
+
- the component still appears in the designer toolbox, if applicable
|
|
1308
|
+
- the properties panel still opens and reads or writes values, if applicable
|
|
1309
|
+
|
|
1310
|
+
Important: a green build does not necessarily mean the migration is complete. All checks above must be satisfied to confirm the migration is successful. If any check fails, treat the migration as incomplete and address the issue before considering it done.
|
|
1311
|
+
|
|
1312
|
+
## Common Migration Mistakes
|
|
1313
|
+
|
|
1314
|
+
- Keeping `import('./bootstrap')` in the entry after adding `RemoteEntryDefinition`
|
|
1315
|
+
- Treating an example remote-entry exposure path as universal instead of verifying the builder's actual resolution root
|
|
1316
|
+
- Moving discovery metadata but forgetting to move actual registrations into `activate()`
|
|
1317
|
+
- Considering the webpack migration complete because the remote builds, even though mandatory webpack rules such as removing `scriptType` or keeping `withModuleFederationPlugin(...)` were violated
|
|
1318
|
+
- Returning designer definitions for a type that was never published in discovery
|
|
1319
|
+
- Collapsing the remote to runtime-only by default and then needing to reshape the entry when design-time functionality is added later
|
|
1320
|
+
- Forgetting to create a separate design feature for custom properties panels
|
|
1321
|
+
- Omitting discovery metadata fields that the contract accepts when the decorator provides them (for example, missing `requestType` or `scopes` for handlers), causing the host to register artifacts incorrectly
|
|
1322
|
+
- Using inline string literals for types, request types, scopes, or selectors in decorators while using different inline strings in discovery metadata, causing silent mismatches
|
|
1323
|
+
- Leaving `@CrtInterfaceDesignerItem` on runtime components, which now fails during deferred activation
|
|
1324
|
+
- Importing a mixed `constants.ts` file from a feature-definition file when that constants file also contains icons or other activation-only data
|
|
1325
|
+
- Moving SVG icons into a file imported by the remote entry file or `*.feature-definition.ts`, which bloats the startup path unnecessarily
|
|
1326
|
+
- Translating toolbox captions through old decorator metadata instead of `loadDesignerDefinitions(...)`
|
|
1327
|
+
- Loading translation JSON from a host-relative path instead of `__webpack_public_path__`
|
|
1328
|
+
- Bootstrapping the whole remote app more than once instead of caching the root app context
|
|
1329
|
+
|
|
1330
|
+
## Decision Rules For AI Agents
|
|
1331
|
+
|
|
1332
|
+
- If the task says "fully lazy" or "deferred remote", the entry must end as pure `RemoteEntryDefinition` export.
|
|
1333
|
+
- Use runtime and design features as the default target structure, even if the design feature starts with empty discovery.
|
|
1334
|
+
- If the remote has no current design-only artifacts, keep the design feature minimal and future-ready rather than collapsing it by default.
|
|
1335
|
+
- If the remote has a custom properties panel, publish and activate it through the design feature.
|
|
1336
|
+
- Collapse to a single runtime feature only when the task explicitly asks for the smallest possible structure and no future design-time extension path is needed.
|
|
1337
|
+
- If the remote has mobile elements, mirror the same migration for `mobileViewElements`.
|
|
1338
|
+
- If the task explicitly requires backward compatibility with eager bootstrap, document that as a mixed mode and keep it separate from the fully deferred target.
|