@nocobase/flow-engine 2.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +30 -0
- package/lib/ContextPathProxy.d.ts +17 -0
- package/lib/ContextPathProxy.js +65 -0
- package/lib/ElementProxy.d.ts +17 -0
- package/lib/ElementProxy.js +93 -0
- package/lib/FlowContextProvider.d.ts +24 -0
- package/lib/FlowContextProvider.js +82 -0
- package/lib/FlowDefinition.d.ts +423 -0
- package/lib/FlowDefinition.js +257 -0
- package/lib/JSRunner.d.ts +32 -0
- package/lib/JSRunner.js +95 -0
- package/lib/ReactView.d.ts +20 -0
- package/lib/ReactView.js +120 -0
- package/lib/ViewScopedFlowEngine.d.ts +23 -0
- package/lib/ViewScopedFlowEngine.js +81 -0
- package/lib/acl/Acl.d.ts +31 -0
- package/lib/acl/Acl.js +115 -0
- package/lib/action-registry/BaseActionRegistry.d.ts +23 -0
- package/lib/action-registry/BaseActionRegistry.js +57 -0
- package/lib/action-registry/EngineActionRegistry.d.ts +20 -0
- package/lib/action-registry/EngineActionRegistry.js +47 -0
- package/lib/action-registry/ModelActionRegistry.d.ts +34 -0
- package/lib/action-registry/ModelActionRegistry.js +79 -0
- package/lib/components/DynamicFlowsEditor.d.ts +17 -0
- package/lib/components/DynamicFlowsEditor.js +49 -0
- package/lib/components/FieldModelRenderer.d.ts +10 -0
- package/lib/components/FieldModelRenderer.js +94 -0
- package/lib/components/FlowContextSelector.d.ts +11 -0
- package/lib/components/FlowContextSelector.js +221 -0
- package/lib/components/FlowErrorFallback.d.ts +25 -0
- package/lib/components/FlowErrorFallback.js +264 -0
- package/lib/components/FlowModelRenderer.d.ts +64 -0
- package/lib/components/FlowModelRenderer.js +254 -0
- package/lib/components/FormItem.d.ts +18 -0
- package/lib/components/FormItem.js +147 -0
- package/lib/components/common/FlowSettingsButton.d.ts +11 -0
- package/lib/components/common/FlowSettingsButton.js +66 -0
- package/lib/components/common/index.d.ts +9 -0
- package/lib/components/common/index.js +30 -0
- package/lib/components/common/withFlowDesignMode.d.ts +26 -0
- package/lib/components/common/withFlowDesignMode.js +61 -0
- package/lib/components/dnd/getMousePositionOnElement.d.ts +50 -0
- package/lib/components/dnd/getMousePositionOnElement.js +95 -0
- package/lib/components/dnd/index.d.ts +24 -0
- package/lib/components/dnd/index.js +164 -0
- package/lib/components/dnd/moveBlock.d.ts +33 -0
- package/lib/components/dnd/moveBlock.js +302 -0
- package/lib/components/index.d.ts +18 -0
- package/lib/components/index.js +48 -0
- package/lib/components/settings/independents/dropdown/FlowsDropdownButton.d.ts +46 -0
- package/lib/components/settings/independents/dropdown/FlowsDropdownButton.js +225 -0
- package/lib/components/settings/independents/dropdown/index.d.ts +9 -0
- package/lib/components/settings/independents/dropdown/index.js +30 -0
- package/lib/components/settings/independents/index.d.ts +1 -0
- package/lib/components/settings/independents/index.js +30 -0
- package/lib/components/settings/index.d.ts +10 -0
- package/lib/components/settings/index.js +32 -0
- package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.d.ts +24 -0
- package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.js +501 -0
- package/lib/components/settings/wrappers/contextual/FlowsContextMenu.d.ts +45 -0
- package/lib/components/settings/wrappers/contextual/FlowsContextMenu.js +231 -0
- package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.d.ts +111 -0
- package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.js +484 -0
- package/lib/components/settings/wrappers/contextual/StepRequiredSettingsDialog.d.ts +26 -0
- package/lib/components/settings/wrappers/contextual/StepRequiredSettingsDialog.js +342 -0
- package/lib/components/settings/wrappers/contextual/StepSettings.d.ts +23 -0
- package/lib/components/settings/wrappers/contextual/StepSettings.js +110 -0
- package/lib/components/settings/wrappers/contextual/StepSettingsDialog.d.ts +20 -0
- package/lib/components/settings/wrappers/contextual/StepSettingsDialog.js +206 -0
- package/lib/components/settings/wrappers/contextual/StepSettingsDrawer.d.ts +20 -0
- package/lib/components/settings/wrappers/contextual/StepSettingsDrawer.js +47 -0
- package/lib/components/settings/wrappers/contextual/index.d.ts +14 -0
- package/lib/components/settings/wrappers/contextual/index.js +40 -0
- package/lib/components/settings/wrappers/embedded/FlowSettings.d.ts +33 -0
- package/lib/components/settings/wrappers/embedded/FlowSettings.js +207 -0
- package/lib/components/settings/wrappers/embedded/FlowsSettings.d.ts +41 -0
- package/lib/components/settings/wrappers/embedded/FlowsSettings.js +84 -0
- package/lib/components/settings/wrappers/embedded/FlowsSettingsContent.d.ts +16 -0
- package/lib/components/settings/wrappers/embedded/FlowsSettingsContent.js +88 -0
- package/lib/components/settings/wrappers/embedded/index.d.ts +10 -0
- package/lib/components/settings/wrappers/embedded/index.js +32 -0
- package/lib/components/settings/wrappers/index.d.ts +2 -0
- package/lib/components/settings/wrappers/index.js +32 -0
- package/lib/components/subModel/AddSubModelButton.d.ts +62 -0
- package/lib/components/subModel/AddSubModelButton.js +415 -0
- package/lib/components/subModel/LazyDropdown.d.ts +55 -0
- package/lib/components/subModel/LazyDropdown.js +524 -0
- package/lib/components/subModel/index.d.ts +10 -0
- package/lib/components/subModel/index.js +32 -0
- package/lib/components/subModel/utils.d.ts +34 -0
- package/lib/components/subModel/utils.js +287 -0
- package/lib/components/variables/InlineVariableTag.d.ts +21 -0
- package/lib/components/variables/InlineVariableTag.js +123 -0
- package/lib/components/variables/SlateVariableEditor.d.ts +46 -0
- package/lib/components/variables/SlateVariableEditor.js +302 -0
- package/lib/components/variables/VariableInput.d.ts +11 -0
- package/lib/components/variables/VariableInput.js +322 -0
- package/lib/components/variables/VariableTag.d.ts +11 -0
- package/lib/components/variables/VariableTag.js +148 -0
- package/lib/components/variables/VariableTrigger.d.ts +20 -0
- package/lib/components/variables/VariableTrigger.js +136 -0
- package/lib/components/variables/index.d.ts +15 -0
- package/lib/components/variables/index.js +53 -0
- package/lib/components/variables/types.d.ts +93 -0
- package/lib/components/variables/types.js +24 -0
- package/lib/components/variables/useResolvedMetaTree.d.ts +19 -0
- package/lib/components/variables/useResolvedMetaTree.js +91 -0
- package/lib/components/variables/utils.d.ts +22 -0
- package/lib/components/variables/utils.js +177 -0
- package/lib/data-source/index.d.ts +180 -0
- package/lib/data-source/index.js +733 -0
- package/lib/data-source/jioToJoiSchema.d.ts +19 -0
- package/lib/data-source/jioToJoiSchema.js +114 -0
- package/lib/decorators/index.d.ts +9 -0
- package/lib/decorators/index.js +36 -0
- package/lib/decorators/largeField.d.ts +9 -0
- package/lib/decorators/largeField.js +42 -0
- package/lib/emitter.d.ts +16 -0
- package/lib/emitter.js +58 -0
- package/lib/event-registry/BaseEventRegistry.d.ts +22 -0
- package/lib/event-registry/BaseEventRegistry.js +57 -0
- package/lib/event-registry/EngineEventRegistry.d.ts +19 -0
- package/lib/event-registry/EngineEventRegistry.js +47 -0
- package/lib/event-registry/ModelEventRegistry.d.ts +33 -0
- package/lib/event-registry/ModelEventRegistry.js +79 -0
- package/lib/executor/FlowExecutor.d.ts +26 -0
- package/lib/executor/FlowExecutor.js +262 -0
- package/lib/flow-registry/BaseFlowRegistry.d.ts +46 -0
- package/lib/flow-registry/BaseFlowRegistry.js +86 -0
- package/lib/flow-registry/GlobalFlowRegistry.d.ts +22 -0
- package/lib/flow-registry/GlobalFlowRegistry.js +95 -0
- package/lib/flow-registry/InstanceFlowRegistry.d.ts +21 -0
- package/lib/flow-registry/InstanceFlowRegistry.js +59 -0
- package/lib/flow-registry/index.d.ts +11 -0
- package/lib/flow-registry/index.js +34 -0
- package/lib/flowContext.d.ts +215 -0
- package/lib/flowContext.js +1266 -0
- package/lib/flowEngine.d.ts +340 -0
- package/lib/flowEngine.js +781 -0
- package/lib/flowI18n.d.ts +46 -0
- package/lib/flowI18n.js +117 -0
- package/lib/flowSettings.d.ts +266 -0
- package/lib/flowSettings.js +850 -0
- package/lib/hooks/index.d.ts +14 -0
- package/lib/hooks/index.js +40 -0
- package/lib/hooks/useApplyAutoFlows.d.ts +21 -0
- package/lib/hooks/useApplyAutoFlows.js +62 -0
- package/lib/hooks/useFlowModel.d.ts +29 -0
- package/lib/hooks/useFlowModel.js +72 -0
- package/lib/hooks/useFlowModelById.d.ts +11 -0
- package/lib/hooks/useFlowModelById.js +61 -0
- package/lib/hooks/useFlowSettingsContext.d.ts +20 -0
- package/lib/hooks/useFlowSettingsContext.js +61 -0
- package/lib/hooks/useFlowStep.d.ts +17 -0
- package/lib/hooks/useFlowStep.js +56 -0
- package/lib/hooks/useNiceDropdownMaxHeight.d.ts +13 -0
- package/lib/hooks/useNiceDropdownMaxHeight.js +52 -0
- package/lib/index.d.ts +27 -0
- package/lib/index.js +73 -0
- package/lib/locale/en-US.json +61 -0
- package/lib/locale/index.d.ts +141 -0
- package/lib/locale/index.js +70 -0
- package/lib/locale/zh-CN.json +61 -0
- package/lib/models/CollectionFieldModel.d.ts +50 -0
- package/lib/models/CollectionFieldModel.js +242 -0
- package/lib/models/DisplayItemModel.d.ts +12 -0
- package/lib/models/DisplayItemModel.js +41 -0
- package/lib/models/EditableItemModel.d.ts +12 -0
- package/lib/models/EditableItemModel.js +41 -0
- package/lib/models/FilterableItemModel.d.ts +12 -0
- package/lib/models/FilterableItemModel.js +41 -0
- package/lib/models/flowModel.d.ts +344 -0
- package/lib/models/flowModel.js +1133 -0
- package/lib/models/forkFlowModel.d.ts +83 -0
- package/lib/models/forkFlowModel.js +257 -0
- package/lib/models/index.d.ts +14 -0
- package/lib/models/index.js +40 -0
- package/lib/provider.d.ts +22 -0
- package/lib/provider.js +114 -0
- package/lib/resources/apiResource.d.ts +34 -0
- package/lib/resources/apiResource.js +153 -0
- package/lib/resources/baseRecordResource.d.ts +61 -0
- package/lib/resources/baseRecordResource.js +264 -0
- package/lib/resources/filterItem.d.ts +33 -0
- package/lib/resources/filterItem.js +93 -0
- package/lib/resources/flowResource.d.ts +45 -0
- package/lib/resources/flowResource.js +146 -0
- package/lib/resources/index.d.ts +15 -0
- package/lib/resources/index.js +42 -0
- package/lib/resources/multiRecordResource.d.ts +53 -0
- package/lib/resources/multiRecordResource.js +230 -0
- package/lib/resources/singleRecordResource.d.ts +23 -0
- package/lib/resources/singleRecordResource.js +111 -0
- package/lib/resources/sqlResource.d.ts +73 -0
- package/lib/resources/sqlResource.js +294 -0
- package/lib/runjs-context/contexts/FlowRunJSContext.d.ts +38 -0
- package/lib/runjs-context/contexts/FlowRunJSContext.js +217 -0
- package/lib/runjs-context/contexts/FormJSFieldItemRunJSContext.d.ts +16 -0
- package/lib/runjs-context/contexts/FormJSFieldItemRunJSContext.js +66 -0
- package/lib/runjs-context/contexts/JSBlockRunJSContext.d.ts +16 -0
- package/lib/runjs-context/contexts/JSBlockRunJSContext.js +78 -0
- package/lib/runjs-context/contexts/JSCollectionActionRunJSContext.d.ts +12 -0
- package/lib/runjs-context/contexts/JSCollectionActionRunJSContext.js +59 -0
- package/lib/runjs-context/contexts/JSFieldRunJSContext.d.ts +16 -0
- package/lib/runjs-context/contexts/JSFieldRunJSContext.js +70 -0
- package/lib/runjs-context/contexts/JSItemRunJSContext.d.ts +16 -0
- package/lib/runjs-context/contexts/JSItemRunJSContext.js +66 -0
- package/lib/runjs-context/contexts/JSRecordActionRunJSContext.d.ts +12 -0
- package/lib/runjs-context/contexts/JSRecordActionRunJSContext.js +61 -0
- package/lib/runjs-context/contexts/LinkageRunJSContext.d.ts +12 -0
- package/lib/runjs-context/contexts/LinkageRunJSContext.js +62 -0
- package/lib/runjs-context/helpers.d.ts +17 -0
- package/lib/runjs-context/helpers.js +79 -0
- package/lib/runjs-context/index.d.ts +19 -0
- package/lib/runjs-context/index.js +57 -0
- package/lib/runjs-context/registry.d.ts +17 -0
- package/lib/runjs-context/registry.js +93 -0
- package/lib/runjs-context/snippets/global/api-request-get.snippet.d.ts +16 -0
- package/lib/runjs-context/snippets/global/api-request-get.snippet.js +42 -0
- package/lib/runjs-context/snippets/global/api-request-post.snippet.d.ts +16 -0
- package/lib/runjs-context/snippets/global/api-request-post.snippet.js +42 -0
- package/lib/runjs-context/snippets/global/console-log-ctx.snippet.d.ts +16 -0
- package/lib/runjs-context/snippets/global/console-log-ctx.snippet.js +41 -0
- package/lib/runjs-context/snippets/global/copy-record-json.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/copy-record-json.snippet.js +42 -0
- package/lib/runjs-context/snippets/global/copy-to-clipboard.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/copy-to-clipboard.snippet.js +42 -0
- package/lib/runjs-context/snippets/global/log-json-record.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/log-json-record.snippet.js +42 -0
- package/lib/runjs-context/snippets/global/message-error.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/message-error.snippet.js +41 -0
- package/lib/runjs-context/snippets/global/message-success.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/message-success.snippet.js +41 -0
- package/lib/runjs-context/snippets/global/notification-open.snippet.d.ts +16 -0
- package/lib/runjs-context/snippets/global/notification-open.snippet.js +43 -0
- package/lib/runjs-context/snippets/global/open-view-dialog.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/open-view-dialog.snippet.js +47 -0
- package/lib/runjs-context/snippets/global/open-view-drawer.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/open-view-drawer.snippet.js +47 -0
- package/lib/runjs-context/snippets/global/requireAsync.snippet.d.ts +16 -0
- package/lib/runjs-context/snippets/global/requireAsync.snippet.js +46 -0
- package/lib/runjs-context/snippets/global/sleep.snippet.d.ts +16 -0
- package/lib/runjs-context/snippets/global/sleep.snippet.js +43 -0
- package/lib/runjs-context/snippets/global/try-catch-async.snippet.d.ts +16 -0
- package/lib/runjs-context/snippets/global/try-catch-async.snippet.js +44 -0
- package/lib/runjs-context/snippets/global/view-navigation-push.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/view-navigation-push.snippet.js +44 -0
- package/lib/runjs-context/snippets/global/window-open.snippet.d.ts +16 -0
- package/lib/runjs-context/snippets/global/window-open.snippet.js +41 -0
- package/lib/runjs-context/snippets/index.d.ts +11 -0
- package/lib/runjs-context/snippets/index.js +94 -0
- package/lib/runjs-context/snippets/libs/echarts-init.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/libs/echarts-init.snippet.js +46 -0
- package/lib/runjs-context/snippets/scene/actions/collection-selected-count.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/actions/collection-selected-count.snippet.js +44 -0
- package/lib/runjs-context/snippets/scene/actions/iterate-selected-rows.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/actions/iterate-selected-rows.snippet.js +43 -0
- package/lib/runjs-context/snippets/scene/actions/record-id-message.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/actions/record-id-message.snippet.js +43 -0
- package/lib/runjs-context/snippets/scene/actions/run-action-basic.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/actions/run-action-basic.snippet.js +40 -0
- package/lib/runjs-context/snippets/scene/jsblock/add-event-listener.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsblock/add-event-listener.snippet.js +46 -0
- package/lib/runjs-context/snippets/scene/jsblock/append-style.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsblock/append-style.snippet.js +42 -0
- package/lib/runjs-context/snippets/scene/jsblock/jsx-mount.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsblock/jsx-mount.snippet.js +46 -0
- package/lib/runjs-context/snippets/scene/jsblock/jsx-unmount.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsblock/jsx-unmount.snippet.js +41 -0
- package/lib/runjs-context/snippets/scene/jsblock/render-basic.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsblock/render-basic.snippet.js +41 -0
- package/lib/runjs-context/snippets/scene/jsblock/render-button-handler.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsblock/render-button-handler.snippet.js +46 -0
- package/lib/runjs-context/snippets/scene/jsblock/render-card.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/jsblock/render-card.snippet.js +45 -0
- package/lib/runjs-context/snippets/scene/jsblock/render-react.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsblock/render-react.snippet.js +56 -0
- package/lib/runjs-context/snippets/scene/jsfield/color-by-value.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsfield/color-by-value.snippet.js +42 -0
- package/lib/runjs-context/snippets/scene/jsfield/format-number.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsfield/format-number.snippet.js +41 -0
- package/lib/runjs-context/snippets/scene/jsfield/innerHTML-value.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsfield/innerHTML-value.snippet.js +40 -0
- package/lib/runjs-context/snippets/scene/jsitem/render-basic.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsitem/render-basic.snippet.js +44 -0
- package/lib/runjs-context/snippets/scene/linkage/set-disabled.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/linkage/set-disabled.snippet.js +60 -0
- package/lib/runjs-context/snippets/scene/linkage/set-field-value.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/linkage/set-field-value.snippet.js +59 -0
- package/lib/runjs-context/snippets/scene/linkage/set-required.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/linkage/set-required.snippet.js +60 -0
- package/lib/runjs-context/snippets/scene/linkage/toggle-visible.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/linkage/toggle-visible.snippet.js +60 -0
- package/lib/runjs-context/snippets/types.d.ts +16 -0
- package/lib/runjs-context/snippets/types.js +24 -0
- package/lib/types.d.ts +398 -0
- package/lib/types.js +43 -0
- package/lib/utils/autoFlowError.d.ts +16 -0
- package/lib/utils/autoFlowError.js +53 -0
- package/lib/utils/constants.d.ts +29 -0
- package/lib/utils/constants.js +77 -0
- package/lib/utils/context.d.ts +40 -0
- package/lib/utils/context.js +63 -0
- package/lib/utils/createCollectionContextMeta.d.ts +11 -0
- package/lib/utils/createCollectionContextMeta.js +117 -0
- package/lib/utils/exceptions.d.ts +22 -0
- package/lib/utils/exceptions.js +62 -0
- package/lib/utils/flow-definitions.d.ts +11 -0
- package/lib/utils/flow-definitions.js +40 -0
- package/lib/utils/index.d.ts +22 -0
- package/lib/utils/index.js +117 -0
- package/lib/utils/inheritance.d.ts +16 -0
- package/lib/utils/inheritance.js +53 -0
- package/lib/utils/params-resolvers.d.ts +51 -0
- package/lib/utils/params-resolvers.js +309 -0
- package/lib/utils/parsePathnameToViewParams.d.ts +34 -0
- package/lib/utils/parsePathnameToViewParams.js +84 -0
- package/lib/utils/safeGlobals.d.ts +16 -0
- package/lib/utils/safeGlobals.js +179 -0
- package/lib/utils/schema-utils.d.ts +40 -0
- package/lib/utils/schema-utils.js +161 -0
- package/lib/utils/serverContextParams.d.ts +28 -0
- package/lib/utils/serverContextParams.js +106 -0
- package/lib/utils/setupRuntimeContextSteps.d.ts +19 -0
- package/lib/utils/setupRuntimeContextSteps.js +88 -0
- package/lib/utils/translation.d.ts +18 -0
- package/lib/utils/translation.js +58 -0
- package/lib/utils/variablesParams.d.ts +51 -0
- package/lib/utils/variablesParams.js +150 -0
- package/lib/views/DialogComponent.d.ts +22 -0
- package/lib/views/DialogComponent.js +98 -0
- package/lib/views/DrawerComponent.d.ts +11 -0
- package/lib/views/DrawerComponent.js +101 -0
- package/lib/views/FlowView.d.ts +76 -0
- package/lib/views/FlowView.js +81 -0
- package/lib/views/PageComponent.d.ts +10 -0
- package/lib/views/PageComponent.js +167 -0
- package/lib/views/ViewNavigation.d.ts +45 -0
- package/lib/views/ViewNavigation.js +97 -0
- package/lib/views/createViewMeta.d.ts +16 -0
- package/lib/views/createViewMeta.js +171 -0
- package/lib/views/index.d.ts +13 -0
- package/lib/views/index.js +48 -0
- package/lib/views/useDialog.d.ts +32 -0
- package/lib/views/useDialog.js +199 -0
- package/lib/views/useDrawer.d.ts +33 -0
- package/lib/views/useDrawer.js +206 -0
- package/lib/views/usePage.d.ts +32 -0
- package/lib/views/usePage.js +193 -0
- package/lib/views/usePatchElement.d.ts +10 -0
- package/lib/views/usePatchElement.js +54 -0
- package/lib/views/usePopover.d.ts +17 -0
- package/lib/views/usePopover.js +159 -0
- package/package.json +37 -0
- package/src/ContextPathProxy.ts +45 -0
- package/src/ElementProxy.ts +69 -0
- package/src/FlowContextProvider.tsx +40 -0
- package/src/FlowDefinition.ts +275 -0
- package/src/JSRunner.ts +84 -0
- package/src/ReactView.tsx +104 -0
- package/src/ViewScopedFlowEngine.ts +75 -0
- package/src/__tests__/ElementProxy.test.ts +51 -0
- package/src/__tests__/JSRunner.test.ts +92 -0
- package/src/__tests__/ReactView.test.tsx +63 -0
- package/src/__tests__/context-path-proxy.test.ts +35 -0
- package/src/__tests__/flow-engine.test.ts +189 -0
- package/src/__tests__/flowContext.test.ts +2012 -0
- package/src/__tests__/flowEngine.saveModel.test.ts +171 -0
- package/src/__tests__/flowI18n.test.ts +28 -0
- package/src/__tests__/flowModel.getFlows.test.ts +61 -0
- package/src/__tests__/flowModel.openView.navigation.test.ts +78 -0
- package/src/__tests__/flowRuntimeContext.test.ts +187 -0
- package/src/__tests__/flowSettings.open.test.tsx +1920 -0
- package/src/__tests__/flowSettings.test.ts +566 -0
- package/src/__tests__/globalFlowRegistry.test.ts +77 -0
- package/src/__tests__/isFieldInterfaceMatch.test.ts +51 -0
- package/src/__tests__/metaTreeNodeCache.test.ts +234 -0
- package/src/__tests__/path-aggregation.test.ts +85 -0
- package/src/__tests__/provider.test.tsx +28 -0
- package/src/__tests__/renderHiddenInConfig.test.tsx +91 -0
- package/src/__tests__/runjsContext.test.ts +60 -0
- package/src/__tests__/viewScopedFlowEngine.test.ts +212 -0
- package/src/acl/Acl.tsx +109 -0
- package/src/acl/__tests__/Acl.test.tsx +72 -0
- package/src/action-registry/BaseActionRegistry.ts +46 -0
- package/src/action-registry/EngineActionRegistry.ts +32 -0
- package/src/action-registry/ModelActionRegistry.ts +75 -0
- package/src/action-registry/__tests__/engineActionRegistry.test.ts +43 -0
- package/src/action-registry/__tests__/modelActionRegistry.test.ts +107 -0
- package/src/components/DynamicFlowsEditor.tsx +318 -0
- package/src/components/FieldModelRenderer.tsx +62 -0
- package/src/components/FlowContextSelector.tsx +255 -0
- package/src/components/FlowErrorFallback.tsx +316 -0
- package/src/components/FlowModelRenderer.tsx +428 -0
- package/src/components/FormItem.tsx +130 -0
- package/src/components/__tests__/flow-model-render-error-fallback.test.tsx +226 -0
- package/src/components/common/FlowSettingsButton.tsx +30 -0
- package/src/components/common/index.ts +10 -0
- package/src/components/common/withFlowDesignMode.tsx +49 -0
- package/src/components/dnd/getMousePositionOnElement.ts +115 -0
- package/src/components/dnd/index.tsx +128 -0
- package/src/components/dnd/moveBlock.ts +379 -0
- package/src/components/index.ts +20 -0
- package/src/components/settings/independents/dropdown/FlowsDropdownButton.tsx +279 -0
- package/src/components/settings/independents/dropdown/index.ts +10 -0
- package/src/components/settings/independents/index.ts +2 -0
- package/src/components/settings/index.ts +11 -0
- package/src/components/settings/wrappers/contextual/DefaultSettingsIcon.tsx +617 -0
- package/src/components/settings/wrappers/contextual/FlowsContextMenu.tsx +292 -0
- package/src/components/settings/wrappers/contextual/FlowsFloatContextMenu.tsx +655 -0
- package/src/components/settings/wrappers/contextual/StepRequiredSettingsDialog.tsx +446 -0
- package/src/components/settings/wrappers/contextual/StepSettings.tsx +109 -0
- package/src/components/settings/wrappers/contextual/StepSettingsDialog.tsx +217 -0
- package/src/components/settings/wrappers/contextual/StepSettingsDrawer.tsx +32 -0
- package/src/components/settings/wrappers/contextual/index.ts +15 -0
- package/src/components/settings/wrappers/embedded/FlowSettings.tsx +258 -0
- package/src/components/settings/wrappers/embedded/FlowsSettings.tsx +111 -0
- package/src/components/settings/wrappers/embedded/FlowsSettingsContent.tsx +96 -0
- package/src/components/settings/wrappers/embedded/index.ts +11 -0
- package/src/components/settings/wrappers/index.ts +5 -0
- package/src/components/subModel/AddSubModelButton.tsx +575 -0
- package/src/components/subModel/LazyDropdown.tsx +714 -0
- package/src/components/subModel/__tests__/AddSubModelButton.test.tsx +1185 -0
- package/src/components/subModel/__tests__/buildWrapperFieldChildren.test.ts +192 -0
- package/src/components/subModel/__tests__/utils.test.ts +425 -0
- package/src/components/subModel/index.ts +12 -0
- package/src/components/subModel/utils.ts +278 -0
- package/src/components/variables/InlineVariableTag.tsx +97 -0
- package/src/components/variables/SlateVariableEditor.tsx +384 -0
- package/src/components/variables/VariableInput.tsx +342 -0
- package/src/components/variables/VariableTag.tsx +123 -0
- package/src/components/variables/VariableTrigger.tsx +116 -0
- package/src/components/variables/__tests__/FlowContextSelector.test.tsx +553 -0
- package/src/components/variables/__tests__/VariableInput.test.tsx +550 -0
- package/src/components/variables/__tests__/VariableTag.test.tsx +347 -0
- package/src/components/variables/__tests__/test-utils.tsx +62 -0
- package/src/components/variables/__tests__/utils.test.ts +310 -0
- package/src/components/variables/index.ts +16 -0
- package/src/components/variables/types.ts +100 -0
- package/src/components/variables/useResolvedMetaTree.ts +76 -0
- package/src/components/variables/utils.ts +192 -0
- package/src/data-source/__tests__/collection.test.ts +58 -0
- package/src/data-source/__tests__/index.test.ts +82 -0
- package/src/data-source/__tests__/jioToJoiSchema.test.ts +56 -0
- package/src/data-source/index.ts +812 -0
- package/src/data-source/jioToJoiSchema.ts +103 -0
- package/src/decorators/index.ts +10 -0
- package/src/decorators/largeField.ts +14 -0
- package/src/emitter.ts +33 -0
- package/src/event-registry/BaseEventRegistry.ts +40 -0
- package/src/event-registry/EngineEventRegistry.ts +26 -0
- package/src/event-registry/ModelEventRegistry.ts +69 -0
- package/src/event-registry/__tests__/engineEventRegistry.test.ts +48 -0
- package/src/executor/FlowExecutor.ts +256 -0
- package/src/executor/__tests__/eventStep.test.ts +157 -0
- package/src/executor/__tests__/flowExecutor.test.ts +163 -0
- package/src/flow-registry/BaseFlowRegistry.ts +91 -0
- package/src/flow-registry/GlobalFlowRegistry.ts +82 -0
- package/src/flow-registry/InstanceFlowRegistry.ts +39 -0
- package/src/flow-registry/__tests__/globalFlowRegistry.test.ts +141 -0
- package/src/flow-registry/__tests__/instance-and-global-registry.test.ts +67 -0
- package/src/flow-registry/__tests__/instanceFlowRegistry.test.ts +83 -0
- package/src/flow-registry/index.ts +12 -0
- package/src/flowContext.ts +1639 -0
- package/src/flowEngine.ts +905 -0
- package/src/flowI18n.ts +96 -0
- package/src/flowSettings.ts +1045 -0
- package/src/hooks/index.ts +15 -0
- package/src/hooks/useApplyAutoFlows.ts +51 -0
- package/src/hooks/useFlowModel.tsx +59 -0
- package/src/hooks/useFlowModelById.ts +37 -0
- package/src/hooks/useFlowSettingsContext.tsx +37 -0
- package/src/hooks/useFlowStep.tsx +19 -0
- package/src/hooks/useNiceDropdownMaxHeight.ts +34 -0
- package/src/index.ts +38 -0
- package/src/locale/en-US.json +61 -0
- package/src/locale/index.ts +38 -0
- package/src/locale/zh-CN.json +61 -0
- package/src/models/CollectionFieldModel.tsx +269 -0
- package/src/models/DisplayItemModel.tsx +13 -0
- package/src/models/EditableItemModel.tsx +13 -0
- package/src/models/FilterableItemModel.tsx +13 -0
- package/src/models/__tests__/CollectionFieldModel.test.ts +122 -0
- package/src/models/__tests__/defaultParams-on-create.test.ts +83 -0
- package/src/models/__tests__/flow-model-oninit.test.ts +44 -0
- package/src/models/__tests__/flowModel.actions.integration.test.ts +100 -0
- package/src/models/__tests__/flowModel.getFlows.sort.test.ts +100 -0
- package/src/models/__tests__/flowModel.test.ts +2746 -0
- package/src/models/__tests__/flowRegistry.test.ts +512 -0
- package/src/models/__tests__/forkFlowModel.test.ts +1047 -0
- package/src/models/__tests__/model-actions.test.ts +70 -0
- package/src/models/__tests__/model-events.test.ts +69 -0
- package/src/models/flowModel.tsx +1398 -0
- package/src/models/forkFlowModel.ts +287 -0
- package/src/models/index.ts +17 -0
- package/src/provider.tsx +101 -0
- package/src/resources/__tests__/apiResource.test.ts +201 -0
- package/src/resources/__tests__/baseRecordResource.test.ts +262 -0
- package/src/resources/__tests__/filterItem.test.ts +260 -0
- package/src/resources/__tests__/flowResource.test.ts +127 -0
- package/src/resources/apiResource.ts +148 -0
- package/src/resources/baseRecordResource.ts +279 -0
- package/src/resources/filterItem.ts +74 -0
- package/src/resources/flowResource.ts +143 -0
- package/src/resources/index.ts +17 -0
- package/src/resources/multiRecordResource.ts +219 -0
- package/src/resources/singleRecordResource.ts +83 -0
- package/src/resources/sqlResource.ts +299 -0
- package/src/runjs-context/contexts/FlowRunJSContext.ts +190 -0
- package/src/runjs-context/contexts/FormJSFieldItemRunJSContext.ts +39 -0
- package/src/runjs-context/contexts/JSBlockRunJSContext.ts +52 -0
- package/src/runjs-context/contexts/JSCollectionActionRunJSContext.ts +32 -0
- package/src/runjs-context/contexts/JSFieldRunJSContext.ts +43 -0
- package/src/runjs-context/contexts/JSItemRunJSContext.ts +39 -0
- package/src/runjs-context/contexts/JSRecordActionRunJSContext.ts +34 -0
- package/src/runjs-context/contexts/LinkageRunJSContext.ts +35 -0
- package/src/runjs-context/helpers.ts +56 -0
- package/src/runjs-context/index.ts +20 -0
- package/src/runjs-context/registry.ts +65 -0
- package/src/runjs-context/snippets/global/api-request-get.snippet.ts +20 -0
- package/src/runjs-context/snippets/global/api-request-post.snippet.ts +20 -0
- package/src/runjs-context/snippets/global/console-log-ctx.snippet.ts +19 -0
- package/src/runjs-context/snippets/global/copy-record-json.snippet.ts +21 -0
- package/src/runjs-context/snippets/global/copy-to-clipboard.snippet.ts +21 -0
- package/src/runjs-context/snippets/global/log-json-record.snippet.ts +21 -0
- package/src/runjs-context/snippets/global/message-error.snippet.ts +20 -0
- package/src/runjs-context/snippets/global/message-success.snippet.ts +20 -0
- package/src/runjs-context/snippets/global/notification-open.snippet.ts +21 -0
- package/src/runjs-context/snippets/global/open-view-dialog.snippet.ts +26 -0
- package/src/runjs-context/snippets/global/open-view-drawer.snippet.ts +26 -0
- package/src/runjs-context/snippets/global/requireAsync.snippet.ts +24 -0
- package/src/runjs-context/snippets/global/sleep.snippet.ts +21 -0
- package/src/runjs-context/snippets/global/try-catch-async.snippet.ts +22 -0
- package/src/runjs-context/snippets/global/view-navigation-push.snippet.ts +23 -0
- package/src/runjs-context/snippets/global/window-open.snippet.ts +19 -0
- package/src/runjs-context/snippets/index.ts +59 -0
- package/src/runjs-context/snippets/libs/echarts-init.snippet.ts +24 -0
- package/src/runjs-context/snippets/scene/actions/collection-selected-count.snippet.ts +22 -0
- package/src/runjs-context/snippets/scene/actions/iterate-selected-rows.snippet.ts +21 -0
- package/src/runjs-context/snippets/scene/actions/record-id-message.snippet.ts +21 -0
- package/src/runjs-context/snippets/scene/actions/run-action-basic.snippet.ts +18 -0
- package/src/runjs-context/snippets/scene/jsblock/add-event-listener.snippet.ts +29 -0
- package/src/runjs-context/snippets/scene/jsblock/append-style.snippet.ts +20 -0
- package/src/runjs-context/snippets/scene/jsblock/jsx-mount.snippet.ts +24 -0
- package/src/runjs-context/snippets/scene/jsblock/jsx-unmount.snippet.ts +19 -0
- package/src/runjs-context/snippets/scene/jsblock/render-basic.snippet.ts +24 -0
- package/src/runjs-context/snippets/scene/jsblock/render-button-handler.snippet.ts +24 -0
- package/src/runjs-context/snippets/scene/jsblock/render-card.snippet.ts +30 -0
- package/src/runjs-context/snippets/scene/jsblock/render-react.snippet.ts +34 -0
- package/src/runjs-context/snippets/scene/jsfield/color-by-value.snippet.ts +20 -0
- package/src/runjs-context/snippets/scene/jsfield/format-number.snippet.ts +19 -0
- package/src/runjs-context/snippets/scene/jsfield/innerHTML-value.snippet.ts +18 -0
- package/src/runjs-context/snippets/scene/jsitem/render-basic.snippet.ts +27 -0
- package/src/runjs-context/snippets/scene/linkage/set-disabled.snippet.ts +38 -0
- package/src/runjs-context/snippets/scene/linkage/set-field-value.snippet.ts +37 -0
- package/src/runjs-context/snippets/scene/linkage/set-required.snippet.ts +38 -0
- package/src/runjs-context/snippets/scene/linkage/toggle-visible.snippet.ts +38 -0
- package/src/runjs-context/snippets/types.ts +17 -0
- package/src/types.ts +474 -0
- package/src/utils/__tests__/context.test.ts +93 -0
- package/src/utils/__tests__/params-resolvers.test.ts +652 -0
- package/src/utils/__tests__/parsePathnameToViewParams.test.ts +104 -0
- package/src/utils/__tests__/safeGlobals.test.ts +29 -0
- package/src/utils/__tests__/utils.test.ts +1021 -0
- package/src/utils/__tests__/variablesParams.test.ts +52 -0
- package/src/utils/autoFlowError.ts +29 -0
- package/src/utils/constants.ts +60 -0
- package/src/utils/context.ts +70 -0
- package/src/utils/createCollectionContextMeta.ts +122 -0
- package/src/utils/exceptions.ts +36 -0
- package/src/utils/flow-definitions.ts +16 -0
- package/src/utils/index.ts +63 -0
- package/src/utils/inheritance.ts +39 -0
- package/src/utils/params-resolvers.ts +482 -0
- package/src/utils/parsePathnameToViewParams.ts +103 -0
- package/src/utils/safeGlobals.ts +188 -0
- package/src/utils/schema-utils.ts +201 -0
- package/src/utils/serverContextParams.ts +111 -0
- package/src/utils/setupRuntimeContextSteps.ts +89 -0
- package/src/utils/translation.ts +37 -0
- package/src/utils/variablesParams.ts +175 -0
- package/src/views/DialogComponent.tsx +79 -0
- package/src/views/DrawerComponent.tsx +72 -0
- package/src/views/FlowView.tsx +103 -0
- package/src/views/PageComponent.tsx +150 -0
- package/src/views/ViewNavigation.ts +122 -0
- package/src/views/__tests__/FlowView.test.ts +31 -0
- package/src/views/__tests__/ViewNavigation.test.ts +191 -0
- package/src/views/__tests__/usePatchElement.test.tsx +28 -0
- package/src/views/createViewMeta.ts +157 -0
- package/src/views/index.tsx +14 -0
- package/src/views/useDialog.tsx +192 -0
- package/src/views/useDrawer.tsx +205 -0
- package/src/views/usePage.tsx +182 -0
- package/src/views/usePatchElement.tsx +27 -0
- package/src/views/usePopover.tsx +131 -0
|
@@ -0,0 +1,1266 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __typeError = (msg) => {
|
|
17
|
+
throw TypeError(msg);
|
|
18
|
+
};
|
|
19
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
20
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
21
|
+
var __export = (target, all) => {
|
|
22
|
+
for (var name in all)
|
|
23
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
24
|
+
};
|
|
25
|
+
var __copyProps = (to, from, except, desc) => {
|
|
26
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
27
|
+
for (let key of __getOwnPropNames(from))
|
|
28
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
29
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
30
|
+
}
|
|
31
|
+
return to;
|
|
32
|
+
};
|
|
33
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
34
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
35
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
36
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
37
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
38
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
39
|
+
mod
|
|
40
|
+
));
|
|
41
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
42
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
43
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
44
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
45
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
46
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
47
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
48
|
+
var flowContext_exports = {};
|
|
49
|
+
__export(flowContext_exports, {
|
|
50
|
+
FlowContext: () => FlowContext,
|
|
51
|
+
FlowEngineContext: () => FlowEngineContext,
|
|
52
|
+
FlowForkModelContext: () => FlowForkModelContext,
|
|
53
|
+
FlowModelContext: () => FlowModelContext,
|
|
54
|
+
FlowRunjsContext: () => FlowRunjsContext,
|
|
55
|
+
FlowRuntimeContext: () => FlowRuntimeContext
|
|
56
|
+
});
|
|
57
|
+
module.exports = __toCommonJS(flowContext_exports);
|
|
58
|
+
var import_reactive = require("@formily/reactive");
|
|
59
|
+
var antd = __toESM(require("antd"));
|
|
60
|
+
var import_lodash = __toESM(require("lodash"));
|
|
61
|
+
var import_qs = __toESM(require("qs"));
|
|
62
|
+
var import_react = __toESM(require("react"));
|
|
63
|
+
var import_Acl = require("./acl/Acl");
|
|
64
|
+
var import_ContextPathProxy = require("./ContextPathProxy");
|
|
65
|
+
var import_data_source = require("./data-source");
|
|
66
|
+
var import_flowEngine = require("./flowEngine");
|
|
67
|
+
var import_flowI18n = require("./flowI18n");
|
|
68
|
+
var import_JSRunner = require("./JSRunner");
|
|
69
|
+
var import_models = require("./models");
|
|
70
|
+
var import_resources = require("./resources");
|
|
71
|
+
var import_utils = require("./utils");
|
|
72
|
+
var import_exceptions = require("./utils/exceptions");
|
|
73
|
+
var import_params_resolvers = require("./utils/params-resolvers");
|
|
74
|
+
var import_serverContextParams = require("./utils/serverContextParams");
|
|
75
|
+
var _proxy, _FlowContext_instances, createChildNodes_fn, findMetaByPath_fn, findMetaInDelegatesDeep_fn, findMetaInProperty_fn, resolvePathInMeta_fn, resolvePathInMetaAsync_fn, buildParentTitles_fn, toTreeNode_fn;
|
|
76
|
+
function isRecordRefLike(val) {
|
|
77
|
+
return !!(val && typeof val === "object" && "collection" in val && "filterByTk" in val);
|
|
78
|
+
}
|
|
79
|
+
__name(isRecordRefLike, "isRecordRefLike");
|
|
80
|
+
function filterBuilderOutputByPaths(built, neededPaths) {
|
|
81
|
+
if (!neededPaths || neededPaths.length === 0) return void 0;
|
|
82
|
+
if (isRecordRefLike(built)) return built;
|
|
83
|
+
if (built && typeof built === "object" && !Array.isArray(built)) {
|
|
84
|
+
const out = {};
|
|
85
|
+
for (const [k, v] of Object.entries(built)) {
|
|
86
|
+
const hit = neededPaths.some((p) => p === k || p.startsWith(`${k}.`) || p.startsWith(`${k}[`));
|
|
87
|
+
if (hit) out[k] = v;
|
|
88
|
+
}
|
|
89
|
+
return out;
|
|
90
|
+
}
|
|
91
|
+
return void 0;
|
|
92
|
+
}
|
|
93
|
+
__name(filterBuilderOutputByPaths, "filterBuilderOutputByPaths");
|
|
94
|
+
const _FlowContext = class _FlowContext {
|
|
95
|
+
constructor() {
|
|
96
|
+
__privateAdd(this, _FlowContext_instances);
|
|
97
|
+
__publicField(this, "_props", {});
|
|
98
|
+
__publicField(this, "_methods", {});
|
|
99
|
+
__publicField(this, "_cache", {});
|
|
100
|
+
__publicField(this, "_observableCache", import_reactive.observable.shallow({}));
|
|
101
|
+
__publicField(this, "_delegates", []);
|
|
102
|
+
__publicField(this, "_pending", {});
|
|
103
|
+
__privateAdd(this, _proxy, null);
|
|
104
|
+
__publicField(this, "_metaNodeCache", /* @__PURE__ */ new WeakMap());
|
|
105
|
+
return this.createProxy();
|
|
106
|
+
}
|
|
107
|
+
createProxy() {
|
|
108
|
+
if (__privateGet(this, _proxy)) {
|
|
109
|
+
return __privateGet(this, _proxy);
|
|
110
|
+
}
|
|
111
|
+
__privateSet(this, _proxy, new Proxy(this, {
|
|
112
|
+
get: /* @__PURE__ */ __name((target, key, receiver) => {
|
|
113
|
+
if (typeof key === "string") {
|
|
114
|
+
if (Reflect.has(target, key)) {
|
|
115
|
+
const val = Reflect.get(target, key, receiver);
|
|
116
|
+
if (typeof val === "function") return val.bind(target);
|
|
117
|
+
return val;
|
|
118
|
+
}
|
|
119
|
+
if (Object.prototype.hasOwnProperty.call(target._props, key)) {
|
|
120
|
+
return target._getOwnProperty(key, this.createProxy());
|
|
121
|
+
}
|
|
122
|
+
if (Object.prototype.hasOwnProperty.call(target._methods, key)) {
|
|
123
|
+
return target._getOwnMethod(key, this.createProxy());
|
|
124
|
+
}
|
|
125
|
+
const found = this._findInDelegates(target._delegates, key);
|
|
126
|
+
if (found !== void 0) return found.result;
|
|
127
|
+
return void 0;
|
|
128
|
+
}
|
|
129
|
+
return Reflect.get(target, key, receiver);
|
|
130
|
+
}, "get"),
|
|
131
|
+
has: /* @__PURE__ */ __name((target, key) => {
|
|
132
|
+
if (typeof key === "string") {
|
|
133
|
+
if (Reflect.has(target, key)) return true;
|
|
134
|
+
if (Object.prototype.hasOwnProperty.call(target._props, key)) return true;
|
|
135
|
+
if (Object.prototype.hasOwnProperty.call(target._methods, key)) return true;
|
|
136
|
+
if (this._hasInDelegates(target._delegates, key)) return true;
|
|
137
|
+
}
|
|
138
|
+
return Reflect.has(target, key);
|
|
139
|
+
}, "has")
|
|
140
|
+
}));
|
|
141
|
+
return __privateGet(this, _proxy);
|
|
142
|
+
}
|
|
143
|
+
defineProperty(key, options) {
|
|
144
|
+
var _a;
|
|
145
|
+
if (this._props[key] && ((_a = this._props[key]) == null ? void 0 : _a.once)) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const oldOptions = this._props[key];
|
|
149
|
+
if (oldOptions == null ? void 0 : oldOptions.meta) {
|
|
150
|
+
this._clearMetaNodeCacheFor(oldOptions.meta);
|
|
151
|
+
}
|
|
152
|
+
this._props[key] = options;
|
|
153
|
+
delete this._observableCache[key];
|
|
154
|
+
delete this._cache[key];
|
|
155
|
+
Object.defineProperty(this, key, {
|
|
156
|
+
configurable: true,
|
|
157
|
+
enumerable: true,
|
|
158
|
+
get: /* @__PURE__ */ __name(() => this._getOwnProperty(key, this.createProxy()), "get")
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
defineMethod(name, fn, des) {
|
|
162
|
+
this._methods[name] = fn;
|
|
163
|
+
Object.defineProperty(this, name, {
|
|
164
|
+
configurable: true,
|
|
165
|
+
enumerable: false,
|
|
166
|
+
writable: false,
|
|
167
|
+
value: fn.bind(this.createProxy())
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
removeCache(key) {
|
|
171
|
+
if (key in this._observableCache) {
|
|
172
|
+
delete this._observableCache[key];
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
if (key in this._cache) {
|
|
176
|
+
delete this._cache[key];
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
if (key in this._pending) {
|
|
180
|
+
delete this._pending[key];
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
for (const delegate of this._delegates) {
|
|
184
|
+
if (delegate.removeCache(key)) {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
delegate(ctx) {
|
|
190
|
+
if (!(ctx instanceof _FlowContext)) {
|
|
191
|
+
throw new Error("Delegate must be an instance of FlowContext");
|
|
192
|
+
}
|
|
193
|
+
if (this._delegates.includes(ctx)) {
|
|
194
|
+
console.warn(`[FlowContext] delegate - skip duplicate delegate: ${this._delegates.length}`);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
this._delegates.unshift(ctx);
|
|
198
|
+
}
|
|
199
|
+
addDelegate(ctx) {
|
|
200
|
+
if (!(ctx instanceof _FlowContext)) {
|
|
201
|
+
throw new Error("Delegate must be an instance of FlowContext");
|
|
202
|
+
}
|
|
203
|
+
if (!this._delegates.includes(ctx)) {
|
|
204
|
+
this._delegates.unshift(ctx);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
clearDelegates() {
|
|
208
|
+
this._delegates = [];
|
|
209
|
+
this._metaNodeCache = /* @__PURE__ */ new WeakMap();
|
|
210
|
+
}
|
|
211
|
+
removeDelegate(ctx) {
|
|
212
|
+
if (!(ctx instanceof _FlowContext)) {
|
|
213
|
+
throw new Error("Delegate must be an instance of FlowContext");
|
|
214
|
+
}
|
|
215
|
+
const index = this._delegates.indexOf(ctx);
|
|
216
|
+
if (index !== -1) {
|
|
217
|
+
this._delegates.splice(index, 1);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* 清除特定 meta 对象的缓存
|
|
222
|
+
*/
|
|
223
|
+
_clearMetaNodeCacheFor(meta) {
|
|
224
|
+
this._metaNodeCache.delete(meta);
|
|
225
|
+
}
|
|
226
|
+
has(key) {
|
|
227
|
+
return !!this._props[key];
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* 获取属性元数据树
|
|
231
|
+
* 返回的 MetaTreeNode 中可能包含异步的延迟加载逻辑
|
|
232
|
+
* @param value 可选参数,指定要获取的属性路径,格式: "{{ ctx.propertyName }}"
|
|
233
|
+
* @returns MetaTreeNode[] 根级属性的元数据树,或指定路径的子树
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* // 同步调用,获取完整 meta tree
|
|
237
|
+
* const metaTree = flowContext.getPropertyMetaTree();
|
|
238
|
+
*
|
|
239
|
+
* // 获取指定属性的子树
|
|
240
|
+
* const subTree = flowContext.getPropertyMetaTree("{{ ctx.user }}");
|
|
241
|
+
*
|
|
242
|
+
* // 获取多层级属性的子树
|
|
243
|
+
* const profileTree = flowContext.getPropertyMetaTree("{{ ctx.user.profile }}");
|
|
244
|
+
*/
|
|
245
|
+
getPropertyMetaTree(value, options) {
|
|
246
|
+
const metaMap = this._getPropertiesMeta();
|
|
247
|
+
if (value) {
|
|
248
|
+
const propertyPath = (0, import_utils.extractPropertyPath)(value);
|
|
249
|
+
if (propertyPath && propertyPath.length > 0) {
|
|
250
|
+
const loadChildrenFrom = /* @__PURE__ */ __name(async (metaOrFactory, fullPath, finalKey) => {
|
|
251
|
+
try {
|
|
252
|
+
const meta = typeof metaOrFactory === "function" ? await metaOrFactory() : metaOrFactory;
|
|
253
|
+
if (!(meta == null ? void 0 : meta.properties)) return [];
|
|
254
|
+
let props = meta.properties;
|
|
255
|
+
if (typeof props === "function") {
|
|
256
|
+
const resolved = await props();
|
|
257
|
+
meta.properties = resolved;
|
|
258
|
+
props = resolved;
|
|
259
|
+
}
|
|
260
|
+
const childNodes = __privateMethod(this, _FlowContext_instances, createChildNodes_fn).call(this, props, fullPath, [], meta);
|
|
261
|
+
return Array.isArray(childNodes) ? childNodes : await childNodes();
|
|
262
|
+
} catch (error) {
|
|
263
|
+
console.warn(`Failed to load meta for ${finalKey}:`, error);
|
|
264
|
+
return [];
|
|
265
|
+
}
|
|
266
|
+
}, "loadChildrenFrom");
|
|
267
|
+
const targetMeta = __privateMethod(this, _FlowContext_instances, findMetaByPath_fn).call(this, propertyPath);
|
|
268
|
+
if (targetMeta) {
|
|
269
|
+
const [finalKey, metaOrFactory, fullPath] = targetMeta;
|
|
270
|
+
const depth = propertyPath.length;
|
|
271
|
+
if (depth === 1) {
|
|
272
|
+
if (typeof metaOrFactory === "function") {
|
|
273
|
+
return () => loadChildrenFrom(metaOrFactory, fullPath, finalKey);
|
|
274
|
+
}
|
|
275
|
+
if (metaOrFactory.properties) {
|
|
276
|
+
if (typeof metaOrFactory.properties === "function") {
|
|
277
|
+
return () => loadChildrenFrom(metaOrFactory, fullPath, finalKey);
|
|
278
|
+
}
|
|
279
|
+
const childNodes = __privateMethod(this, _FlowContext_instances, createChildNodes_fn).call(this, metaOrFactory.properties, fullPath, [], metaOrFactory);
|
|
280
|
+
return Array.isArray(childNodes) ? childNodes : [];
|
|
281
|
+
}
|
|
282
|
+
return [];
|
|
283
|
+
}
|
|
284
|
+
if (typeof metaOrFactory === "function") {
|
|
285
|
+
if (options == null ? void 0 : options.flatten) {
|
|
286
|
+
return () => loadChildrenFrom(metaOrFactory, fullPath, finalKey);
|
|
287
|
+
}
|
|
288
|
+
const parentTitles = __privateMethod(this, _FlowContext_instances, buildParentTitles_fn).call(this, fullPath);
|
|
289
|
+
return [__privateMethod(this, _FlowContext_instances, toTreeNode_fn).call(this, finalKey, metaOrFactory, fullPath, parentTitles)];
|
|
290
|
+
}
|
|
291
|
+
if (metaOrFactory.properties) {
|
|
292
|
+
const parentTitles = [...__privateMethod(this, _FlowContext_instances, buildParentTitles_fn).call(this, fullPath), metaOrFactory.title];
|
|
293
|
+
const childNodes = __privateMethod(this, _FlowContext_instances, createChildNodes_fn).call(this, metaOrFactory.properties, fullPath, parentTitles, metaOrFactory);
|
|
294
|
+
return Array.isArray(childNodes) ? childNodes : [];
|
|
295
|
+
}
|
|
296
|
+
return [];
|
|
297
|
+
}
|
|
298
|
+
return [];
|
|
299
|
+
} else if (propertyPath === null) {
|
|
300
|
+
console.warn(
|
|
301
|
+
`[FlowContext] getPropertyMetaTree - unsupported value format: "${value}". Only "{{ ctx.propertyName }}" format is supported. Returning empty meta tree.`
|
|
302
|
+
);
|
|
303
|
+
return [];
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
const sorted = Object.entries(metaMap).sort(([, a], [, b]) => {
|
|
307
|
+
const sa = (typeof a === "function" ? a.sort : a == null ? void 0 : a.sort) ?? 0;
|
|
308
|
+
const sb = (typeof b === "function" ? b.sort : b == null ? void 0 : b.sort) ?? 0;
|
|
309
|
+
return sb - sa;
|
|
310
|
+
});
|
|
311
|
+
return sorted.map(([key, metaOrFactory]) => __privateMethod(this, _FlowContext_instances, toTreeNode_fn).call(this, key, metaOrFactory, [key], []));
|
|
312
|
+
}
|
|
313
|
+
_getPropertiesMeta() {
|
|
314
|
+
const metaMap = {};
|
|
315
|
+
for (const delegate of this._delegates) {
|
|
316
|
+
Object.assign(metaMap, delegate._getPropertiesMeta());
|
|
317
|
+
}
|
|
318
|
+
for (const [key, options] of Object.entries(this._props)) {
|
|
319
|
+
if (options.meta) {
|
|
320
|
+
metaMap[key] = typeof options.meta === "function" ? options.meta : options.meta;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return metaMap;
|
|
324
|
+
}
|
|
325
|
+
// 只查找自身 _props
|
|
326
|
+
_getOwnProperty(key, currentContext) {
|
|
327
|
+
const options = this._props[key];
|
|
328
|
+
if (!options) return void 0;
|
|
329
|
+
if ("value" in options) {
|
|
330
|
+
return options.value;
|
|
331
|
+
}
|
|
332
|
+
if (options.get) {
|
|
333
|
+
if (options.cache === false) {
|
|
334
|
+
return options.get(currentContext);
|
|
335
|
+
}
|
|
336
|
+
const cacheKey = options.observable ? "_observableCache" : "_cache";
|
|
337
|
+
if (key in this[cacheKey]) {
|
|
338
|
+
return this[cacheKey][key];
|
|
339
|
+
}
|
|
340
|
+
if (this._pending[key]) return this._pending[key];
|
|
341
|
+
const result = options.get(this.createProxy());
|
|
342
|
+
const isPromise = typeof result === "object" && result !== null && typeof result.then === "function" || typeof result === "function" && typeof result.then === "function";
|
|
343
|
+
if (isPromise) {
|
|
344
|
+
this._pending[key] = result.then(
|
|
345
|
+
(v) => {
|
|
346
|
+
this[cacheKey][key] = v;
|
|
347
|
+
delete this._pending[key];
|
|
348
|
+
return v;
|
|
349
|
+
},
|
|
350
|
+
(err) => {
|
|
351
|
+
delete this._pending[key];
|
|
352
|
+
throw err;
|
|
353
|
+
}
|
|
354
|
+
);
|
|
355
|
+
return this._pending[key];
|
|
356
|
+
}
|
|
357
|
+
this[cacheKey][key] = result;
|
|
358
|
+
return result;
|
|
359
|
+
}
|
|
360
|
+
return void 0;
|
|
361
|
+
}
|
|
362
|
+
// 只查找自身 _methods
|
|
363
|
+
_getOwnMethod(key, flowContext) {
|
|
364
|
+
const fn = this._methods[key];
|
|
365
|
+
if (typeof fn === "function") {
|
|
366
|
+
return fn.bind(flowContext);
|
|
367
|
+
}
|
|
368
|
+
return fn;
|
|
369
|
+
}
|
|
370
|
+
_findPropertyInDelegates(delegates, key) {
|
|
371
|
+
for (const delegate of delegates) {
|
|
372
|
+
if (Object.prototype.hasOwnProperty.call(delegate._props, key)) {
|
|
373
|
+
return delegate._props[key];
|
|
374
|
+
}
|
|
375
|
+
const found = this._findPropertyInDelegates(delegate._delegates, key);
|
|
376
|
+
if (found !== void 0) return found;
|
|
377
|
+
}
|
|
378
|
+
return void 0;
|
|
379
|
+
}
|
|
380
|
+
_findInDelegates(delegates, key) {
|
|
381
|
+
for (const delegate of delegates) {
|
|
382
|
+
if (Object.prototype.hasOwnProperty.call(delegate._props, key)) {
|
|
383
|
+
return {
|
|
384
|
+
result: delegate._getOwnProperty(key, this.createProxy())
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
if (Object.prototype.hasOwnProperty.call(delegate._methods, key)) {
|
|
388
|
+
return {
|
|
389
|
+
result: delegate._getOwnMethod(key, this.createProxy())
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
const found = this._findInDelegates(delegate._delegates, key);
|
|
393
|
+
if (found !== void 0) return found;
|
|
394
|
+
}
|
|
395
|
+
return void 0;
|
|
396
|
+
}
|
|
397
|
+
// 递归查找委托链
|
|
398
|
+
_hasInDelegates(delegates, key) {
|
|
399
|
+
for (const delegate of delegates) {
|
|
400
|
+
if (Object.prototype.hasOwnProperty.call(delegate._props, key)) return true;
|
|
401
|
+
if (Object.prototype.hasOwnProperty.call(delegate._methods, key)) return true;
|
|
402
|
+
if (this._hasInDelegates(delegate._delegates, key)) return true;
|
|
403
|
+
}
|
|
404
|
+
return false;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* 获取属性定义选项(包含代理链)。
|
|
408
|
+
*
|
|
409
|
+
* - 优先查找当前上下文自身通过 defineProperty 注册的属性定义
|
|
410
|
+
* - 若自身不存在,则沿委托链(delegates)向上查找第一个命中的定义
|
|
411
|
+
*
|
|
412
|
+
* @param key 顶层属性名(例如 'user'、'view')
|
|
413
|
+
* @returns 属性定义选项,或 undefined(未定义)
|
|
414
|
+
*/
|
|
415
|
+
getPropertyOptions(key) {
|
|
416
|
+
if (Object.prototype.hasOwnProperty.call(this._props, key)) {
|
|
417
|
+
return this._props[key];
|
|
418
|
+
}
|
|
419
|
+
return this._findPropertyInDelegates(this._delegates, key);
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
_proxy = new WeakMap();
|
|
423
|
+
_FlowContext_instances = new WeakSet();
|
|
424
|
+
createChildNodes_fn = /* @__PURE__ */ __name(function(properties, parentPaths = [], parentTitles = [], parentMeta) {
|
|
425
|
+
return typeof properties === "function" ? async () => {
|
|
426
|
+
const resolved = await properties();
|
|
427
|
+
if (parentMeta) {
|
|
428
|
+
parentMeta.properties = resolved;
|
|
429
|
+
}
|
|
430
|
+
const entries = Object.entries(resolved);
|
|
431
|
+
entries.sort(([, a], [, b]) => ((b == null ? void 0 : b.sort) ?? 0) - ((a == null ? void 0 : a.sort) ?? 0));
|
|
432
|
+
return entries.map(([name, meta]) => __privateMethod(this, _FlowContext_instances, toTreeNode_fn).call(this, name, meta, [...parentPaths, name], parentTitles));
|
|
433
|
+
} : Object.entries(properties).sort(([, a], [, b]) => ((b == null ? void 0 : b.sort) ?? 0) - ((a == null ? void 0 : a.sort) ?? 0)).map(([name, meta]) => __privateMethod(this, _FlowContext_instances, toTreeNode_fn).call(this, name, meta, [...parentPaths, name], parentTitles));
|
|
434
|
+
}, "#createChildNodes");
|
|
435
|
+
/**
|
|
436
|
+
* 根据属性路径查找对应的 meta
|
|
437
|
+
* @param propertyPath 属性路径数组,例如 ["aaa", "bbb"]
|
|
438
|
+
* @returns [finalKey, metaOrFactory, fullPath] 或 null
|
|
439
|
+
*/
|
|
440
|
+
findMetaByPath_fn = /* @__PURE__ */ __name(function(propertyPath) {
|
|
441
|
+
if (propertyPath.length === 0) return null;
|
|
442
|
+
const [firstKey, ...remainingPath] = propertyPath;
|
|
443
|
+
const ownProperty = this._props[firstKey];
|
|
444
|
+
if (ownProperty == null ? void 0 : ownProperty.meta) {
|
|
445
|
+
return __privateMethod(this, _FlowContext_instances, findMetaInProperty_fn).call(this, firstKey, ownProperty.meta, remainingPath, [firstKey]);
|
|
446
|
+
}
|
|
447
|
+
const deepMeta = __privateMethod(this, _FlowContext_instances, findMetaInDelegatesDeep_fn).call(this, this._delegates, firstKey);
|
|
448
|
+
if (deepMeta) {
|
|
449
|
+
return __privateMethod(this, _FlowContext_instances, findMetaInProperty_fn).call(this, firstKey, deepMeta, remainingPath, [firstKey]);
|
|
450
|
+
}
|
|
451
|
+
return null;
|
|
452
|
+
}, "#findMetaByPath");
|
|
453
|
+
/**
|
|
454
|
+
* 递归在委托链中查找指定 key 的 meta(只返回 metaOrFactory,不解析路径)。
|
|
455
|
+
*/
|
|
456
|
+
findMetaInDelegatesDeep_fn = /* @__PURE__ */ __name(function(delegates, key) {
|
|
457
|
+
for (const delegate of delegates) {
|
|
458
|
+
const prop = delegate._props[key];
|
|
459
|
+
if (prop == null ? void 0 : prop.meta) return prop.meta;
|
|
460
|
+
const deeper = __privateMethod(this, _FlowContext_instances, findMetaInDelegatesDeep_fn).call(this, delegate._delegates, key);
|
|
461
|
+
if (deeper) return deeper;
|
|
462
|
+
}
|
|
463
|
+
return null;
|
|
464
|
+
}, "#findMetaInDelegatesDeep");
|
|
465
|
+
/**
|
|
466
|
+
* 在给定属性的 meta 中查找剩余路径
|
|
467
|
+
*/
|
|
468
|
+
findMetaInProperty_fn = /* @__PURE__ */ __name(function(currentKey, metaOrFactory, remainingPath, currentPath) {
|
|
469
|
+
if (remainingPath.length === 0) {
|
|
470
|
+
return [currentKey, metaOrFactory, currentPath];
|
|
471
|
+
}
|
|
472
|
+
if (typeof metaOrFactory === "function") {
|
|
473
|
+
const finalKey = remainingPath[remainingPath.length - 1];
|
|
474
|
+
const finalPath = [...currentPath, ...remainingPath];
|
|
475
|
+
const wrappedFactory = /* @__PURE__ */ __name(async () => {
|
|
476
|
+
const resolvedMeta = await metaOrFactory();
|
|
477
|
+
const result = await __privateMethod(this, _FlowContext_instances, resolvePathInMetaAsync_fn).call(this, resolvedMeta, remainingPath);
|
|
478
|
+
return result;
|
|
479
|
+
}, "wrappedFactory");
|
|
480
|
+
return [finalKey, wrappedFactory, finalPath];
|
|
481
|
+
}
|
|
482
|
+
if (metaOrFactory.properties) {
|
|
483
|
+
const [nextKey, ...restPath] = remainingPath;
|
|
484
|
+
const nextPath = [...currentPath, nextKey];
|
|
485
|
+
if (typeof metaOrFactory.properties === "function") {
|
|
486
|
+
const finalKey = remainingPath[remainingPath.length - 1];
|
|
487
|
+
const finalPath = [...currentPath, ...remainingPath];
|
|
488
|
+
const wrappedFactory = /* @__PURE__ */ __name(async () => {
|
|
489
|
+
const propertiesFactory = metaOrFactory.properties;
|
|
490
|
+
const resolvedProperties = await propertiesFactory();
|
|
491
|
+
metaOrFactory.properties = resolvedProperties;
|
|
492
|
+
const startMeta = resolvedProperties[nextKey];
|
|
493
|
+
if (!startMeta) {
|
|
494
|
+
throw new Error(`Property ${nextKey} not found in resolved properties`);
|
|
495
|
+
}
|
|
496
|
+
const result = await __privateMethod(this, _FlowContext_instances, resolvePathInMetaAsync_fn).call(this, startMeta, restPath);
|
|
497
|
+
return result;
|
|
498
|
+
}, "wrappedFactory");
|
|
499
|
+
return [finalKey, wrappedFactory, finalPath];
|
|
500
|
+
}
|
|
501
|
+
const nextMeta = metaOrFactory.properties[nextKey];
|
|
502
|
+
if (nextMeta) {
|
|
503
|
+
return __privateMethod(this, _FlowContext_instances, findMetaInProperty_fn).call(this, nextKey, nextMeta, restPath, nextPath);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
return null;
|
|
507
|
+
}, "#findMetaInProperty");
|
|
508
|
+
/**
|
|
509
|
+
* 在给定的 meta 中递归解析路径
|
|
510
|
+
*/
|
|
511
|
+
resolvePathInMeta_fn = /* @__PURE__ */ __name(function(meta, path) {
|
|
512
|
+
if (path.length === 0) {
|
|
513
|
+
return meta;
|
|
514
|
+
}
|
|
515
|
+
let current = meta;
|
|
516
|
+
for (const key of path) {
|
|
517
|
+
const properties = import_lodash.default.get(current, "properties");
|
|
518
|
+
if (!properties || typeof properties === "function") {
|
|
519
|
+
return null;
|
|
520
|
+
}
|
|
521
|
+
current = import_lodash.default.get(properties, key);
|
|
522
|
+
if (!current) {
|
|
523
|
+
return null;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
return current;
|
|
527
|
+
}, "#resolvePathInMeta");
|
|
528
|
+
resolvePathInMetaAsync_fn = /* @__PURE__ */ __name(async function(meta, path) {
|
|
529
|
+
if (path.length === 0) return meta;
|
|
530
|
+
let current = meta;
|
|
531
|
+
for (const key of path) {
|
|
532
|
+
let properties = import_lodash.default.get(current, "properties");
|
|
533
|
+
if (!properties) {
|
|
534
|
+
throw new Error(`Property path not found: ${path.join(".")}`);
|
|
535
|
+
}
|
|
536
|
+
if (typeof properties === "function") {
|
|
537
|
+
const resolved = await properties();
|
|
538
|
+
current.properties = resolved;
|
|
539
|
+
properties = resolved;
|
|
540
|
+
}
|
|
541
|
+
const next = properties[key];
|
|
542
|
+
if (!next) {
|
|
543
|
+
throw new Error(`Property ${key} not found while resolving path: ${path.join(".")}`);
|
|
544
|
+
}
|
|
545
|
+
current = next;
|
|
546
|
+
}
|
|
547
|
+
return current;
|
|
548
|
+
}, "#resolvePathInMetaAsync");
|
|
549
|
+
/**
|
|
550
|
+
* 构建 parentTitles 数组,通过递归查找每个路径层级对应的 meta title
|
|
551
|
+
* @param propertyPath 属性路径数组,例如 ['aaa', 'bbb', 'ccc']
|
|
552
|
+
* @param excludeLastLevel 是否排除最后一层,默认为 true(parentTitles 不包含当前节点)
|
|
553
|
+
* @returns string[] 父级标题数组
|
|
554
|
+
*/
|
|
555
|
+
buildParentTitles_fn = /* @__PURE__ */ __name(function(propertyPath, excludeLastLevel = true) {
|
|
556
|
+
if (propertyPath.length === 0) return [];
|
|
557
|
+
const pathToProcess = excludeLastLevel ? propertyPath.slice(0, -1) : propertyPath;
|
|
558
|
+
if (pathToProcess.length === 0) return [];
|
|
559
|
+
const parentTitles = [];
|
|
560
|
+
let currentMetas = this._getPropertiesMeta();
|
|
561
|
+
for (let i = 0; i < pathToProcess.length; i++) {
|
|
562
|
+
const currentKey = pathToProcess[i];
|
|
563
|
+
const currentMeta = currentMetas[currentKey];
|
|
564
|
+
if (!currentMeta || typeof currentMeta === "function") {
|
|
565
|
+
parentTitles.push(currentKey);
|
|
566
|
+
break;
|
|
567
|
+
}
|
|
568
|
+
parentTitles.push(currentMeta.title || currentKey);
|
|
569
|
+
if (i < pathToProcess.length - 1 && currentMeta.properties && typeof currentMeta.properties !== "function") {
|
|
570
|
+
currentMetas = currentMeta.properties;
|
|
571
|
+
} else if (i < pathToProcess.length - 1) {
|
|
572
|
+
for (let j = i + 1; j < pathToProcess.length; j++) {
|
|
573
|
+
parentTitles.push(pathToProcess[j]);
|
|
574
|
+
}
|
|
575
|
+
break;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
return parentTitles;
|
|
579
|
+
}, "#buildParentTitles");
|
|
580
|
+
toTreeNode_fn = /* @__PURE__ */ __name(function(name, metaOrFactory, paths = [name], parentTitles = []) {
|
|
581
|
+
const cached = this._metaNodeCache.get(metaOrFactory);
|
|
582
|
+
if (cached) {
|
|
583
|
+
cached.paths = paths;
|
|
584
|
+
cached.parentTitles = parentTitles.length > 0 ? parentTitles : void 0;
|
|
585
|
+
return cached;
|
|
586
|
+
}
|
|
587
|
+
let node;
|
|
588
|
+
const computeDisabledFromMeta = /* @__PURE__ */ __name((m) => {
|
|
589
|
+
if (!m) return { disabled: false };
|
|
590
|
+
const disabledVal = typeof m.disabled === "function" ? m.disabled() : m.disabled;
|
|
591
|
+
const reason = typeof m.disabledReason === "function" ? m.disabledReason() : m.disabledReason;
|
|
592
|
+
return { disabled: !!disabledVal, reason };
|
|
593
|
+
}, "computeDisabledFromMeta");
|
|
594
|
+
if (typeof metaOrFactory === "function") {
|
|
595
|
+
const initialTitle = name;
|
|
596
|
+
const hasChildrenHint = metaOrFactory.hasChildren;
|
|
597
|
+
node = {
|
|
598
|
+
name,
|
|
599
|
+
title: metaOrFactory.title || initialTitle,
|
|
600
|
+
// 初始使用 name 作为 title
|
|
601
|
+
type: "object",
|
|
602
|
+
// 初始类型
|
|
603
|
+
interface: void 0,
|
|
604
|
+
uiSchema: void 0,
|
|
605
|
+
paths,
|
|
606
|
+
parentTitles: parentTitles.length > 0 ? parentTitles : void 0,
|
|
607
|
+
disabled: /* @__PURE__ */ __name(() => {
|
|
608
|
+
const maybe = metaOrFactory();
|
|
609
|
+
if (maybe && typeof maybe["then"] === "function") return false;
|
|
610
|
+
return computeDisabledFromMeta(maybe).disabled;
|
|
611
|
+
}, "disabled"),
|
|
612
|
+
disabledReason: /* @__PURE__ */ __name(() => {
|
|
613
|
+
const maybe = metaOrFactory();
|
|
614
|
+
if (maybe && typeof maybe["then"] === "function") return void 0;
|
|
615
|
+
return computeDisabledFromMeta(maybe).reason;
|
|
616
|
+
}, "disabledReason"),
|
|
617
|
+
// 注意:即便 hasChildren === false,也只是“没有子节点”的 UI 提示;
|
|
618
|
+
// 节点自身依然通过 meta 工厂保持惰性特性(需要时可解析出 title/type 等)。
|
|
619
|
+
// 这里仅在 hasChildren !== false 时,提供子节点的懒加载逻辑。
|
|
620
|
+
children: hasChildrenHint === false ? void 0 : async () => {
|
|
621
|
+
try {
|
|
622
|
+
const meta = await metaOrFactory();
|
|
623
|
+
const finalTitle = (meta == null ? void 0 : meta.title) || name;
|
|
624
|
+
node.title = finalTitle;
|
|
625
|
+
node.type = meta == null ? void 0 : meta.type;
|
|
626
|
+
node.interface = meta == null ? void 0 : meta.interface;
|
|
627
|
+
node.uiSchema = meta == null ? void 0 : meta.uiSchema;
|
|
628
|
+
if (!(meta == null ? void 0 : meta.properties)) return [];
|
|
629
|
+
const childNodes = __privateMethod(this, _FlowContext_instances, createChildNodes_fn).call(this, meta.properties, paths, [...parentTitles, finalTitle], meta);
|
|
630
|
+
const resolvedChildren = Array.isArray(childNodes) ? childNodes : await childNodes();
|
|
631
|
+
node.children = resolvedChildren;
|
|
632
|
+
return resolvedChildren;
|
|
633
|
+
} catch (error) {
|
|
634
|
+
console.warn(`Failed to load meta for ${name}:`, error);
|
|
635
|
+
return [];
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
} else {
|
|
640
|
+
const nodeTitle = metaOrFactory.title;
|
|
641
|
+
const { disabled, reason } = computeDisabledFromMeta(metaOrFactory);
|
|
642
|
+
node = {
|
|
643
|
+
name,
|
|
644
|
+
title: nodeTitle,
|
|
645
|
+
type: metaOrFactory.type,
|
|
646
|
+
interface: metaOrFactory.interface,
|
|
647
|
+
uiSchema: metaOrFactory.uiSchema,
|
|
648
|
+
paths,
|
|
649
|
+
parentTitles: parentTitles.length > 0 ? parentTitles : void 0,
|
|
650
|
+
disabled,
|
|
651
|
+
disabledReason: reason,
|
|
652
|
+
children: metaOrFactory.properties ? __privateMethod(this, _FlowContext_instances, createChildNodes_fn).call(this, metaOrFactory.properties, paths, [...parentTitles, nodeTitle], metaOrFactory) : void 0
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
this._metaNodeCache.set(metaOrFactory, node);
|
|
656
|
+
return node;
|
|
657
|
+
}, "#toTreeNode");
|
|
658
|
+
__name(_FlowContext, "FlowContext");
|
|
659
|
+
let FlowContext = _FlowContext;
|
|
660
|
+
const _FlowRunjsContext = class _FlowRunjsContext extends FlowContext {
|
|
661
|
+
constructor(delegate) {
|
|
662
|
+
super();
|
|
663
|
+
this.addDelegate(delegate);
|
|
664
|
+
this.defineProperty("React", { value: import_react.default });
|
|
665
|
+
this.defineProperty("antd", { value: antd });
|
|
666
|
+
this.defineMethod(
|
|
667
|
+
"dispatchModelEvent",
|
|
668
|
+
async (modelOrUid, eventName, inputArgs) => {
|
|
669
|
+
var _a, _b;
|
|
670
|
+
let model = null;
|
|
671
|
+
if (typeof modelOrUid === "string") {
|
|
672
|
+
model = await this.engine.loadModel({ uid: modelOrUid });
|
|
673
|
+
} else if (modelOrUid instanceof import_models.FlowModel) {
|
|
674
|
+
model = modelOrUid;
|
|
675
|
+
}
|
|
676
|
+
if (model) {
|
|
677
|
+
model.context.addDelegate(this);
|
|
678
|
+
model.dispatchEvent(eventName, { navigation: false, ...(_b = (_a = this.model) == null ? void 0 : _a["getInputArgs"]) == null ? void 0 : _b.call(_a), ...inputArgs });
|
|
679
|
+
} else {
|
|
680
|
+
this.message.error(this.t("Model with ID {{uid}} not found", { uid: modelOrUid }));
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
);
|
|
684
|
+
}
|
|
685
|
+
};
|
|
686
|
+
__name(_FlowRunjsContext, "FlowRunjsContext");
|
|
687
|
+
let FlowRunjsContext = _FlowRunjsContext;
|
|
688
|
+
const _BaseFlowEngineContext = class _BaseFlowEngineContext extends FlowContext {
|
|
689
|
+
};
|
|
690
|
+
__name(_BaseFlowEngineContext, "BaseFlowEngineContext");
|
|
691
|
+
let BaseFlowEngineContext = _BaseFlowEngineContext;
|
|
692
|
+
const _BaseFlowModelContext = class _BaseFlowModelContext extends BaseFlowEngineContext {
|
|
693
|
+
};
|
|
694
|
+
__name(_BaseFlowModelContext, "BaseFlowModelContext");
|
|
695
|
+
let BaseFlowModelContext = _BaseFlowModelContext;
|
|
696
|
+
const _FlowEngineContext = class _FlowEngineContext extends BaseFlowEngineContext {
|
|
697
|
+
// public dataSourceManager: DataSourceManager;
|
|
698
|
+
constructor(engine) {
|
|
699
|
+
if (!(engine instanceof import_flowEngine.FlowEngine)) {
|
|
700
|
+
throw new Error("Invalid FlowEngine instance");
|
|
701
|
+
}
|
|
702
|
+
super();
|
|
703
|
+
this.engine = engine;
|
|
704
|
+
this.engine = engine;
|
|
705
|
+
const dataSourceManager = new import_data_source.DataSourceManager();
|
|
706
|
+
dataSourceManager.setFlowEngine(this.engine);
|
|
707
|
+
const mainDataSource = new import_data_source.DataSource({
|
|
708
|
+
key: "main",
|
|
709
|
+
displayName: "Main"
|
|
710
|
+
});
|
|
711
|
+
dataSourceManager.addDataSource(mainDataSource);
|
|
712
|
+
this.defineProperty("engine", {
|
|
713
|
+
value: this.engine
|
|
714
|
+
});
|
|
715
|
+
this.defineProperty("sql", {
|
|
716
|
+
get: /* @__PURE__ */ __name(() => new import_resources.FlowSQLRepository(this), "get")
|
|
717
|
+
});
|
|
718
|
+
this.defineProperty("dataSourceManager", {
|
|
719
|
+
value: dataSourceManager
|
|
720
|
+
});
|
|
721
|
+
const i18n = new import_flowI18n.FlowI18n(this);
|
|
722
|
+
this.defineMethod("t", (keyOrTemplate, options) => {
|
|
723
|
+
return i18n.translate(keyOrTemplate, options);
|
|
724
|
+
});
|
|
725
|
+
this.defineMethod("runjs", async (code, variables, options) => {
|
|
726
|
+
const mergedGlobals = { ...(options == null ? void 0 : options.globals) || {}, ...variables || {} };
|
|
727
|
+
const runner = this.createJSRunner({
|
|
728
|
+
...options || {},
|
|
729
|
+
globals: mergedGlobals
|
|
730
|
+
});
|
|
731
|
+
return runner.run(code);
|
|
732
|
+
});
|
|
733
|
+
this.defineMethod("renderJson", function(template) {
|
|
734
|
+
return this.resolveJsonTemplate(template);
|
|
735
|
+
});
|
|
736
|
+
this.defineMethod("resolveJsonTemplate", async function(template) {
|
|
737
|
+
var _a, _b;
|
|
738
|
+
const used = (0, import_utils.extractUsedVariablePaths)(template);
|
|
739
|
+
const usedVarNames = Object.keys(used || {});
|
|
740
|
+
if (!usedVarNames.length) {
|
|
741
|
+
return (0, import_utils.resolveExpressions)(template, this);
|
|
742
|
+
}
|
|
743
|
+
const serverVarPaths = {};
|
|
744
|
+
for (const varName of usedVarNames) {
|
|
745
|
+
const paths = used[varName] || [];
|
|
746
|
+
const opt = this.getPropertyOptions(varName);
|
|
747
|
+
const mark = opt == null ? void 0 : opt.resolveOnServer;
|
|
748
|
+
if (mark === true) {
|
|
749
|
+
serverVarPaths[varName] = paths;
|
|
750
|
+
} else if (typeof mark === "function") {
|
|
751
|
+
const filtered = paths.filter((p) => {
|
|
752
|
+
try {
|
|
753
|
+
return !!mark(p);
|
|
754
|
+
} catch (_2) {
|
|
755
|
+
return false;
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
if (filtered.length) serverVarPaths[varName] = filtered;
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
const needServer = Object.keys(serverVarPaths).length > 0;
|
|
762
|
+
let serverResolved = template;
|
|
763
|
+
if (needServer) {
|
|
764
|
+
const collectFromMeta = /* @__PURE__ */ __name(async () => {
|
|
765
|
+
var _a2;
|
|
766
|
+
const out = {};
|
|
767
|
+
try {
|
|
768
|
+
const metas = (_a2 = this._getPropertiesMeta) == null ? void 0 : _a2.call(this);
|
|
769
|
+
if (!metas || typeof metas !== "object") return out;
|
|
770
|
+
for (const [key, metaOrFactory] of Object.entries(metas)) {
|
|
771
|
+
if (!serverVarPaths[key]) continue;
|
|
772
|
+
try {
|
|
773
|
+
let meta;
|
|
774
|
+
if (typeof metaOrFactory === "function") {
|
|
775
|
+
const fn = metaOrFactory;
|
|
776
|
+
meta = await fn();
|
|
777
|
+
} else {
|
|
778
|
+
meta = metaOrFactory;
|
|
779
|
+
}
|
|
780
|
+
if (!meta || typeof meta !== "object") continue;
|
|
781
|
+
const builder = meta.buildVariablesParams;
|
|
782
|
+
if (typeof builder !== "function") continue;
|
|
783
|
+
const built = await builder(this);
|
|
784
|
+
if (!built) continue;
|
|
785
|
+
const neededPaths = serverVarPaths[key] || [];
|
|
786
|
+
const filtered = filterBuilderOutputByPaths(built, neededPaths);
|
|
787
|
+
if (filtered && (typeof filtered !== "object" || Object.keys(filtered).length)) {
|
|
788
|
+
out[key] = filtered;
|
|
789
|
+
}
|
|
790
|
+
} catch (_2) {
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
} catch (_2) {
|
|
794
|
+
}
|
|
795
|
+
return out;
|
|
796
|
+
}, "collectFromMeta");
|
|
797
|
+
const inputFromMeta = await collectFromMeta();
|
|
798
|
+
const autoInput = { ...inputFromMeta };
|
|
799
|
+
const autoContextParams = Object.keys(autoInput).length ? (0, import_serverContextParams.buildServerContextParams)(this, autoInput) : void 0;
|
|
800
|
+
if (this.api) {
|
|
801
|
+
try {
|
|
802
|
+
serverResolved = await (0, import_params_resolvers.enqueueVariablesResolve)(this, {
|
|
803
|
+
template,
|
|
804
|
+
contextParams: autoContextParams || {}
|
|
805
|
+
});
|
|
806
|
+
} catch (e) {
|
|
807
|
+
(_b = (_a = this.logger) == null ? void 0 : _a.warn) == null ? void 0 : _b.call(_a, { err: e }, "variables:resolve failed, fallback to client-only");
|
|
808
|
+
serverResolved = template;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
return (0, import_utils.resolveExpressions)(serverResolved, this);
|
|
813
|
+
});
|
|
814
|
+
this.defineProperty("requirejs", {
|
|
815
|
+
get: /* @__PURE__ */ __name(() => {
|
|
816
|
+
var _a, _b;
|
|
817
|
+
return (_b = (_a = this.app) == null ? void 0 : _a.requirejs) == null ? void 0 : _b.requirejs;
|
|
818
|
+
}, "get")
|
|
819
|
+
});
|
|
820
|
+
this.defineProperty("token", {
|
|
821
|
+
get: /* @__PURE__ */ __name(() => {
|
|
822
|
+
var _a, _b;
|
|
823
|
+
return (_b = (_a = this.api) == null ? void 0 : _a.auth) == null ? void 0 : _b.token;
|
|
824
|
+
}, "get"),
|
|
825
|
+
cache: false,
|
|
826
|
+
// 注意:使用惰性 meta 工厂,避免在 i18n 尚未注入时提前求值导致无法翻译
|
|
827
|
+
meta: Object.assign(() => ({ type: "string", title: this.t("API Token"), sort: 980 }), {
|
|
828
|
+
title: "API Token",
|
|
829
|
+
sort: 980,
|
|
830
|
+
hasChildren: false
|
|
831
|
+
})
|
|
832
|
+
});
|
|
833
|
+
this.defineProperty("role", {
|
|
834
|
+
get: /* @__PURE__ */ __name(() => {
|
|
835
|
+
var _a, _b;
|
|
836
|
+
return (_b = (_a = this.api) == null ? void 0 : _a.auth) == null ? void 0 : _b.role;
|
|
837
|
+
}, "get"),
|
|
838
|
+
cache: false,
|
|
839
|
+
// 注意:使用惰性 meta 工厂,避免在 i18n 尚未注入时提前求值导致无法翻译
|
|
840
|
+
meta: Object.assign(() => ({ type: "string", title: this.t("Current role"), sort: 990 }), {
|
|
841
|
+
title: (0, import_utils.escapeT)("Current role"),
|
|
842
|
+
sort: 990,
|
|
843
|
+
hasChildren: false
|
|
844
|
+
})
|
|
845
|
+
});
|
|
846
|
+
this.defineProperty("urlSearchParams", {
|
|
847
|
+
// 不缓存,确保随 URL 变化实时生效
|
|
848
|
+
cache: false,
|
|
849
|
+
get: /* @__PURE__ */ __name(() => {
|
|
850
|
+
var _a;
|
|
851
|
+
const search = ((_a = this.location) == null ? void 0 : _a.search) || "";
|
|
852
|
+
const str = search.startsWith("?") ? search.slice(1) : search;
|
|
853
|
+
return import_qs.default.parse(str) || {};
|
|
854
|
+
}, "get"),
|
|
855
|
+
// 变量选择器中的元信息与动态子项
|
|
856
|
+
meta: Object.assign(
|
|
857
|
+
() => ({
|
|
858
|
+
type: "object",
|
|
859
|
+
title: this.t("URL search params"),
|
|
860
|
+
sort: 970,
|
|
861
|
+
disabled: /* @__PURE__ */ __name(() => {
|
|
862
|
+
var _a;
|
|
863
|
+
const search = ((_a = this.location) == null ? void 0 : _a.search) || "";
|
|
864
|
+
const str = search.startsWith("?") ? search.slice(1) : search;
|
|
865
|
+
const params = import_qs.default.parse(str) || {};
|
|
866
|
+
return Object.keys(params).length === 0;
|
|
867
|
+
}, "disabled"),
|
|
868
|
+
disabledReason: /* @__PURE__ */ __name(() => this.t(
|
|
869
|
+
"The value of this variable is derived from the query string of the page URL. This variable can only be used normally when the page has a query string."
|
|
870
|
+
), "disabledReason"),
|
|
871
|
+
properties: /* @__PURE__ */ __name(async () => {
|
|
872
|
+
var _a;
|
|
873
|
+
const search = ((_a = this.location) == null ? void 0 : _a.search) || "";
|
|
874
|
+
const str = search.startsWith("?") ? search.slice(1) : search;
|
|
875
|
+
const params = import_qs.default.parse(str) || {};
|
|
876
|
+
const props = {};
|
|
877
|
+
for (const key of Object.keys(params)) {
|
|
878
|
+
props[key] = { type: "string", title: key };
|
|
879
|
+
}
|
|
880
|
+
return props;
|
|
881
|
+
}, "properties")
|
|
882
|
+
}),
|
|
883
|
+
{
|
|
884
|
+
title: (0, import_utils.escapeT)("URL search params"),
|
|
885
|
+
sort: 970,
|
|
886
|
+
hasChildren: true
|
|
887
|
+
}
|
|
888
|
+
)
|
|
889
|
+
});
|
|
890
|
+
this.defineProperty("logger", {
|
|
891
|
+
get: /* @__PURE__ */ __name(() => {
|
|
892
|
+
return this.engine.logger.child({ module: "flow-engine" });
|
|
893
|
+
}, "get")
|
|
894
|
+
});
|
|
895
|
+
this.defineProperty("auth", {
|
|
896
|
+
get: /* @__PURE__ */ __name(() => ({
|
|
897
|
+
roleName: this.api.auth.role,
|
|
898
|
+
locale: this.api.auth.locale,
|
|
899
|
+
token: this.api.auth.token,
|
|
900
|
+
user: this.user
|
|
901
|
+
}), "get")
|
|
902
|
+
});
|
|
903
|
+
this.defineMethod("loadCSS", async (url) => {
|
|
904
|
+
return new Promise((resolve, reject) => {
|
|
905
|
+
const existingLink = document.querySelector(`link[href="${url}"]`);
|
|
906
|
+
if (existingLink) {
|
|
907
|
+
resolve(null);
|
|
908
|
+
return;
|
|
909
|
+
}
|
|
910
|
+
const link = document.createElement("link");
|
|
911
|
+
link.rel = "stylesheet";
|
|
912
|
+
link.href = url;
|
|
913
|
+
link.onload = () => resolve(null);
|
|
914
|
+
link.onerror = () => reject(new Error(`Failed to load CSS: ${url}`));
|
|
915
|
+
document.head.appendChild(link);
|
|
916
|
+
});
|
|
917
|
+
});
|
|
918
|
+
this.defineMethod("requireAsync", async (url) => {
|
|
919
|
+
return new Promise((resolve, reject) => {
|
|
920
|
+
if (!this.requirejs) {
|
|
921
|
+
reject(new Error("requirejs is not available"));
|
|
922
|
+
return;
|
|
923
|
+
}
|
|
924
|
+
this.requirejs(
|
|
925
|
+
[url],
|
|
926
|
+
(...args) => {
|
|
927
|
+
resolve(args[0]);
|
|
928
|
+
},
|
|
929
|
+
reject
|
|
930
|
+
);
|
|
931
|
+
});
|
|
932
|
+
});
|
|
933
|
+
this.defineMethod("createJSRunner", function(options) {
|
|
934
|
+
const runCtx = new FlowRunjsContext(this.createProxy());
|
|
935
|
+
return new import_JSRunner.JSRunner({
|
|
936
|
+
...options,
|
|
937
|
+
globals: {
|
|
938
|
+
ctx: runCtx,
|
|
939
|
+
window: (0, import_utils.createSafeWindow)(),
|
|
940
|
+
document: (0, import_utils.createSafeDocument)(),
|
|
941
|
+
...options == null ? void 0 : options.globals
|
|
942
|
+
}
|
|
943
|
+
});
|
|
944
|
+
});
|
|
945
|
+
this.defineMethod("copyToClipboard", async (text) => {
|
|
946
|
+
const content = String(text ?? "");
|
|
947
|
+
try {
|
|
948
|
+
if (typeof navigator !== "undefined" && navigator.clipboard && navigator.clipboard.writeText) {
|
|
949
|
+
await navigator.clipboard.writeText(content);
|
|
950
|
+
return;
|
|
951
|
+
}
|
|
952
|
+
} catch (e) {
|
|
953
|
+
}
|
|
954
|
+
return new Promise((resolve, reject) => {
|
|
955
|
+
try {
|
|
956
|
+
const ta = document.createElement("textarea");
|
|
957
|
+
ta.value = content;
|
|
958
|
+
ta.setAttribute("readonly", "");
|
|
959
|
+
ta.style.position = "fixed";
|
|
960
|
+
ta.style.top = "-9999px";
|
|
961
|
+
document.body.appendChild(ta);
|
|
962
|
+
ta.focus();
|
|
963
|
+
ta.select();
|
|
964
|
+
const ok = document.execCommand("copy");
|
|
965
|
+
document.body.removeChild(ta);
|
|
966
|
+
if (ok) resolve();
|
|
967
|
+
else reject(new Error("execCommand copy failed"));
|
|
968
|
+
} catch (err) {
|
|
969
|
+
reject(err);
|
|
970
|
+
}
|
|
971
|
+
});
|
|
972
|
+
});
|
|
973
|
+
this.defineMethod("buildServerContextParams", function(input) {
|
|
974
|
+
return (0, import_serverContextParams.buildServerContextParams)(this, input);
|
|
975
|
+
});
|
|
976
|
+
this.defineMethod("getAction", function(name) {
|
|
977
|
+
return this.engine.getAction(name);
|
|
978
|
+
});
|
|
979
|
+
this.defineMethod("getActions", function() {
|
|
980
|
+
return this.engine.getActions();
|
|
981
|
+
});
|
|
982
|
+
this.defineMethod("getEvents", function() {
|
|
983
|
+
return this.engine.getEvents();
|
|
984
|
+
});
|
|
985
|
+
this.defineMethod(
|
|
986
|
+
"runAction",
|
|
987
|
+
async function(actionName, params) {
|
|
988
|
+
const def = this.engine.getAction(actionName);
|
|
989
|
+
const ctx = this.createProxy();
|
|
990
|
+
if (!def) {
|
|
991
|
+
throw new Error(`Action '${actionName}' not found.`);
|
|
992
|
+
}
|
|
993
|
+
const defaultParams = await (0, import_utils.resolveDefaultParams)(def.defaultParams, ctx);
|
|
994
|
+
let combinedParams = { ...defaultParams || {}, ...params || {} };
|
|
995
|
+
let useRawParams = def.useRawParams;
|
|
996
|
+
if (typeof useRawParams === "function") {
|
|
997
|
+
useRawParams = await useRawParams(ctx);
|
|
998
|
+
}
|
|
999
|
+
if (!useRawParams) {
|
|
1000
|
+
combinedParams = await ctx.resolveJsonTemplate(combinedParams);
|
|
1001
|
+
}
|
|
1002
|
+
if (!def.handler) {
|
|
1003
|
+
throw new Error(`Action '${actionName}' has no handler.`);
|
|
1004
|
+
}
|
|
1005
|
+
return def.handler(ctx, combinedParams);
|
|
1006
|
+
}
|
|
1007
|
+
);
|
|
1008
|
+
this.defineProperty("acl", {
|
|
1009
|
+
get: /* @__PURE__ */ __name(() => {
|
|
1010
|
+
const acl = new import_Acl.ACL(this.engine);
|
|
1011
|
+
return acl;
|
|
1012
|
+
}, "get")
|
|
1013
|
+
});
|
|
1014
|
+
this.defineMethod("aclCheck", function(params) {
|
|
1015
|
+
return this.acl.aclCheck(params);
|
|
1016
|
+
});
|
|
1017
|
+
this.defineMethod("createResource", function(resourceType) {
|
|
1018
|
+
return this.engine.createResource(resourceType, {
|
|
1019
|
+
context: this.createProxy()
|
|
1020
|
+
});
|
|
1021
|
+
});
|
|
1022
|
+
}
|
|
1023
|
+
};
|
|
1024
|
+
__name(_FlowEngineContext, "FlowEngineContext");
|
|
1025
|
+
let FlowEngineContext = _FlowEngineContext;
|
|
1026
|
+
const _FlowModelContext = class _FlowModelContext extends BaseFlowModelContext {
|
|
1027
|
+
constructor(model) {
|
|
1028
|
+
if (!(model instanceof import_models.FlowModel)) {
|
|
1029
|
+
throw new Error("Invalid FlowModel instance");
|
|
1030
|
+
}
|
|
1031
|
+
super();
|
|
1032
|
+
this.addDelegate(model.flowEngine.context);
|
|
1033
|
+
this.defineMethod("onRefReady", (ref, cb, timeout) => {
|
|
1034
|
+
this.engine.reactView.onRefReady(ref, cb, timeout);
|
|
1035
|
+
});
|
|
1036
|
+
this.defineMethod("runjs", async (code, variables, options) => {
|
|
1037
|
+
const runner = this.createJSRunner({
|
|
1038
|
+
globals: variables,
|
|
1039
|
+
version: options == null ? void 0 : options.version
|
|
1040
|
+
});
|
|
1041
|
+
return runner.run(code);
|
|
1042
|
+
});
|
|
1043
|
+
this.defineProperty("model", {
|
|
1044
|
+
value: model
|
|
1045
|
+
});
|
|
1046
|
+
this.defineProperty("ref", {
|
|
1047
|
+
get: /* @__PURE__ */ __name(() => {
|
|
1048
|
+
this.model["_refCreated"] = true;
|
|
1049
|
+
return (0, import_react.createRef)();
|
|
1050
|
+
}, "get")
|
|
1051
|
+
});
|
|
1052
|
+
this.defineMethod("openView", async function(uid, options) {
|
|
1053
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1054
|
+
const opts = { ...options };
|
|
1055
|
+
if (opts.defineProperties || opts.defineMethod) {
|
|
1056
|
+
opts.navigation = false;
|
|
1057
|
+
}
|
|
1058
|
+
let model2 = null;
|
|
1059
|
+
model2 = await this.engine.loadModel({ uid });
|
|
1060
|
+
if (!model2) {
|
|
1061
|
+
model2 = this.engine.createModel({
|
|
1062
|
+
uid,
|
|
1063
|
+
// 注意: 新建的 model 应该使用 ${parentModel.uid}-xxx 形式的 uid
|
|
1064
|
+
use: "PopupActionModel",
|
|
1065
|
+
parentId: this.model.uid,
|
|
1066
|
+
subType: "object",
|
|
1067
|
+
subKey: uid,
|
|
1068
|
+
stepParams: {
|
|
1069
|
+
popupSettings: {
|
|
1070
|
+
openView: {
|
|
1071
|
+
...import_lodash.default.pick(opts, ["dataSourceKey", "collectionName", "associationName"])
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
});
|
|
1076
|
+
await model2.save();
|
|
1077
|
+
}
|
|
1078
|
+
if ((_b = (_a = model2.getStepParams("popupSettings")) == null ? void 0 : _a.openView) == null ? void 0 : _b.dataSourceKey) {
|
|
1079
|
+
model2.setStepParams("popupSettings", {
|
|
1080
|
+
openView: {
|
|
1081
|
+
...(_c = model2.getStepParams("popupSettings")) == null ? void 0 : _c.openView,
|
|
1082
|
+
...import_lodash.default.pick(opts, ["dataSourceKey", "collectionName", "associationName"])
|
|
1083
|
+
}
|
|
1084
|
+
});
|
|
1085
|
+
await model2.save();
|
|
1086
|
+
}
|
|
1087
|
+
const viewUid = (opts == null ? void 0 : opts.routeViewUid) ?? (opts == null ? void 0 : opts.viewUid) ?? (((_e = (_d = model2.stepParams) == null ? void 0 : _d.popupSettings) == null ? void 0 : _e.openView) ? model2.uid : this.model.uid);
|
|
1088
|
+
const parentView = this.view;
|
|
1089
|
+
const pendingType = (opts == null ? void 0 : opts.isMobileLayout) ? "embed" : (opts == null ? void 0 : opts.mode) || "drawer";
|
|
1090
|
+
const pendingInputArgs = { ...opts, viewUid, navigation: opts.navigation };
|
|
1091
|
+
pendingInputArgs.filterByTk = pendingInputArgs.filterByTk || ((_f = this.inputArgs) == null ? void 0 : _f.filterByTk);
|
|
1092
|
+
pendingInputArgs.sourceId = pendingInputArgs.sourceId || ((_g = this.inputArgs) == null ? void 0 : _g.sourceId);
|
|
1093
|
+
const pendingView = {
|
|
1094
|
+
type: pendingType,
|
|
1095
|
+
inputArgs: pendingInputArgs,
|
|
1096
|
+
navigation: parentView == null ? void 0 : parentView.navigation,
|
|
1097
|
+
preventClose: !!(opts == null ? void 0 : opts.preventClose),
|
|
1098
|
+
engineCtx: this.engine.context
|
|
1099
|
+
};
|
|
1100
|
+
model2.context.defineProperty("view", { value: pendingView });
|
|
1101
|
+
await model2.dispatchEvent("click", {
|
|
1102
|
+
// navigation: false, // TODO: 路由模式有bug,不支持多层同样viewId的弹窗,因此这里默认先用false
|
|
1103
|
+
// ...this.model?.['getInputArgs']?.(), // 避免部分关系字段信息丢失, 仿照 ClickableCollectionField 做法
|
|
1104
|
+
...opts
|
|
1105
|
+
});
|
|
1106
|
+
model2.context.defineProperty("view", { value: void 0 });
|
|
1107
|
+
});
|
|
1108
|
+
this.defineMethod("getEvents", function() {
|
|
1109
|
+
return this.model.getEvents();
|
|
1110
|
+
});
|
|
1111
|
+
this.defineMethod("getAction", function(name) {
|
|
1112
|
+
return this.model.getAction(name);
|
|
1113
|
+
});
|
|
1114
|
+
this.defineMethod("getActions", function() {
|
|
1115
|
+
return this.model.getActions();
|
|
1116
|
+
});
|
|
1117
|
+
this.defineMethod(
|
|
1118
|
+
"runAction",
|
|
1119
|
+
async function(actionName, params) {
|
|
1120
|
+
const def = this.model.getAction(actionName);
|
|
1121
|
+
const ctx = this.createProxy();
|
|
1122
|
+
if (!def) {
|
|
1123
|
+
throw new Error(`Action '${actionName}' not found.`);
|
|
1124
|
+
}
|
|
1125
|
+
const defaultParams = await (0, import_utils.resolveDefaultParams)(def.defaultParams, ctx);
|
|
1126
|
+
let combinedParams = { ...defaultParams || {}, ...params || {} };
|
|
1127
|
+
let useRawParams = def.useRawParams;
|
|
1128
|
+
if (typeof useRawParams === "function") {
|
|
1129
|
+
useRawParams = await useRawParams(ctx);
|
|
1130
|
+
}
|
|
1131
|
+
if (!useRawParams) {
|
|
1132
|
+
combinedParams = await ctx.resolveJsonTemplate(combinedParams);
|
|
1133
|
+
}
|
|
1134
|
+
if (!def.handler) {
|
|
1135
|
+
throw new Error(`Action '${actionName}' has no handler.`);
|
|
1136
|
+
}
|
|
1137
|
+
return def.handler(ctx, combinedParams);
|
|
1138
|
+
}
|
|
1139
|
+
);
|
|
1140
|
+
}
|
|
1141
|
+
};
|
|
1142
|
+
__name(_FlowModelContext, "FlowModelContext");
|
|
1143
|
+
let FlowModelContext = _FlowModelContext;
|
|
1144
|
+
const _FlowForkModelContext = class _FlowForkModelContext extends BaseFlowModelContext {
|
|
1145
|
+
constructor(master, fork) {
|
|
1146
|
+
if (!(master instanceof import_models.FlowModel)) {
|
|
1147
|
+
throw new Error("Invalid FlowModel instance");
|
|
1148
|
+
}
|
|
1149
|
+
super();
|
|
1150
|
+
this.master = master;
|
|
1151
|
+
this.fork = fork;
|
|
1152
|
+
this.addDelegate(this.master.context);
|
|
1153
|
+
this.defineMethod("onRefReady", (ref, cb, timeout) => {
|
|
1154
|
+
this.engine.reactView.onRefReady(ref, cb, timeout);
|
|
1155
|
+
});
|
|
1156
|
+
this.defineProperty("model", {
|
|
1157
|
+
get: /* @__PURE__ */ __name(() => this.fork, "get")
|
|
1158
|
+
});
|
|
1159
|
+
this.defineProperty("ref", {
|
|
1160
|
+
get: /* @__PURE__ */ __name(() => {
|
|
1161
|
+
this.fork["_refCreated"] = true;
|
|
1162
|
+
return (0, import_react.createRef)();
|
|
1163
|
+
}, "get")
|
|
1164
|
+
});
|
|
1165
|
+
this.defineMethod("runjs", async (code, variables, options) => {
|
|
1166
|
+
const runner = this.createJSRunner({
|
|
1167
|
+
globals: variables,
|
|
1168
|
+
version: options == null ? void 0 : options.version
|
|
1169
|
+
});
|
|
1170
|
+
return runner.run(code);
|
|
1171
|
+
});
|
|
1172
|
+
}
|
|
1173
|
+
};
|
|
1174
|
+
__name(_FlowForkModelContext, "FlowForkModelContext");
|
|
1175
|
+
let FlowForkModelContext = _FlowForkModelContext;
|
|
1176
|
+
const _FlowRuntimeContext = class _FlowRuntimeContext extends BaseFlowModelContext {
|
|
1177
|
+
constructor(model, flowKey, _mode = "runtime") {
|
|
1178
|
+
super();
|
|
1179
|
+
this.model = model;
|
|
1180
|
+
this.flowKey = flowKey;
|
|
1181
|
+
this._mode = _mode;
|
|
1182
|
+
this.addDelegate(this.model.context);
|
|
1183
|
+
this.defineMethod("getStepParams", (stepKey) => {
|
|
1184
|
+
return model.getStepParams(flowKey, stepKey) || {};
|
|
1185
|
+
});
|
|
1186
|
+
this.defineMethod("setStepParams", (stepKey, params) => {
|
|
1187
|
+
return model.setStepParams(flowKey, stepKey, params);
|
|
1188
|
+
});
|
|
1189
|
+
this.defineMethod("getStepResults", (stepKey) => {
|
|
1190
|
+
return import_lodash.default.get(this.steps, [stepKey, "result"]);
|
|
1191
|
+
});
|
|
1192
|
+
this.defineMethod(
|
|
1193
|
+
"useResource",
|
|
1194
|
+
(className) => {
|
|
1195
|
+
if (model.context.has("resource")) {
|
|
1196
|
+
console.warn(`[FlowRuntimeContext] useResource - resource already defined in context: ${className}`);
|
|
1197
|
+
return;
|
|
1198
|
+
}
|
|
1199
|
+
model.context.defineProperty("resource", {
|
|
1200
|
+
get: /* @__PURE__ */ __name(() => {
|
|
1201
|
+
return this.createResource(className);
|
|
1202
|
+
}, "get")
|
|
1203
|
+
});
|
|
1204
|
+
if (!model["resource"]) {
|
|
1205
|
+
model["resource"] = model.context.resource;
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
);
|
|
1209
|
+
this.defineProperty("resource", {
|
|
1210
|
+
get: /* @__PURE__ */ __name(() => model["resource"] || model.context["resource"], "get"),
|
|
1211
|
+
cache: false
|
|
1212
|
+
});
|
|
1213
|
+
this.defineMethod("onRefReady", (ref, cb, timeout) => {
|
|
1214
|
+
this.engine.reactView.onRefReady(ref, cb, timeout);
|
|
1215
|
+
});
|
|
1216
|
+
this.defineMethod("runjs", async (code, variables, options) => {
|
|
1217
|
+
const runner = this.createJSRunner({
|
|
1218
|
+
globals: variables,
|
|
1219
|
+
version: options == null ? void 0 : options.version
|
|
1220
|
+
});
|
|
1221
|
+
return runner.run(code);
|
|
1222
|
+
});
|
|
1223
|
+
}
|
|
1224
|
+
stepResults = {};
|
|
1225
|
+
_getOwnProperty(key) {
|
|
1226
|
+
if (this.mode === "runtime") {
|
|
1227
|
+
return super._getOwnProperty(key, this.createProxy());
|
|
1228
|
+
}
|
|
1229
|
+
const options = this._props[key];
|
|
1230
|
+
if (!options) return void 0;
|
|
1231
|
+
if ("value" in options) {
|
|
1232
|
+
return import_ContextPathProxy.ContextPathProxy.create()[key];
|
|
1233
|
+
}
|
|
1234
|
+
if (options.get) {
|
|
1235
|
+
if (options.cache === false) {
|
|
1236
|
+
return import_ContextPathProxy.ContextPathProxy.create()[key];
|
|
1237
|
+
}
|
|
1238
|
+
const cacheKey = options.observable ? "_observableCache" : "_cache";
|
|
1239
|
+
if (!(key in this[cacheKey])) {
|
|
1240
|
+
this[cacheKey][key] = import_ContextPathProxy.ContextPathProxy.create()[key];
|
|
1241
|
+
}
|
|
1242
|
+
return this[cacheKey][key];
|
|
1243
|
+
}
|
|
1244
|
+
return void 0;
|
|
1245
|
+
}
|
|
1246
|
+
exit() {
|
|
1247
|
+
throw new import_utils.FlowExitException(this.flowKey, this.model.uid);
|
|
1248
|
+
}
|
|
1249
|
+
exitAll() {
|
|
1250
|
+
throw new import_exceptions.FlowExitAllException(this.flowKey, this.model.uid);
|
|
1251
|
+
}
|
|
1252
|
+
get mode() {
|
|
1253
|
+
return this._mode;
|
|
1254
|
+
}
|
|
1255
|
+
};
|
|
1256
|
+
__name(_FlowRuntimeContext, "FlowRuntimeContext");
|
|
1257
|
+
let FlowRuntimeContext = _FlowRuntimeContext;
|
|
1258
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1259
|
+
0 && (module.exports = {
|
|
1260
|
+
FlowContext,
|
|
1261
|
+
FlowEngineContext,
|
|
1262
|
+
FlowForkModelContext,
|
|
1263
|
+
FlowModelContext,
|
|
1264
|
+
FlowRunjsContext,
|
|
1265
|
+
FlowRuntimeContext
|
|
1266
|
+
});
|