@nocobase/flow-engine 2.1.0-alpha.1 → 2.1.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -661
- package/README.md +79 -10
- package/lib/BlockScopedFlowEngine.js +0 -1
- package/lib/FlowDefinition.d.ts +6 -0
- package/lib/FlowSchemaRegistry.d.ts +154 -0
- package/lib/FlowSchemaRegistry.js +1427 -0
- package/lib/JSRunner.d.ts +15 -0
- package/lib/JSRunner.js +82 -7
- package/lib/ViewScopedFlowEngine.js +8 -1
- package/lib/acl/Acl.js +13 -3
- package/lib/components/FlowContextSelector.js +155 -10
- package/lib/components/MobilePopup.js +6 -5
- package/lib/components/dnd/gridDragPlanner.d.ts +1 -0
- package/lib/components/dnd/gridDragPlanner.js +59 -3
- package/lib/components/settings/wrappers/component/SwitchWithTitle.js +2 -1
- package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.js +76 -15
- package/lib/components/settings/wrappers/contextual/FlowsContextMenu.js +24 -4
- package/lib/components/settings/wrappers/contextual/StepSettingsDialog.js +21 -3
- package/lib/components/subModel/AddSubModelButton.js +27 -1
- package/lib/components/subModel/utils.js +2 -2
- package/lib/components/variables/VariableInput.js +9 -4
- package/lib/components/variables/VariableTag.js +46 -39
- package/lib/components/variables/utils.d.ts +7 -0
- package/lib/components/variables/utils.js +42 -2
- package/lib/data-source/index.d.ts +7 -27
- package/lib/data-source/index.js +84 -51
- package/lib/executor/FlowExecutor.d.ts +2 -1
- package/lib/executor/FlowExecutor.js +190 -26
- package/lib/flow-schema-registry/fieldBinding.d.ts +32 -0
- package/lib/flow-schema-registry/fieldBinding.js +165 -0
- package/lib/flow-schema-registry/modelPatches.d.ts +16 -0
- package/lib/flow-schema-registry/modelPatches.js +235 -0
- package/lib/flow-schema-registry/schemaInference.d.ts +17 -0
- package/lib/flow-schema-registry/schemaInference.js +207 -0
- package/lib/flow-schema-registry/utils.d.ts +25 -0
- package/lib/flow-schema-registry/utils.js +293 -0
- package/lib/flowContext.d.ts +230 -7
- package/lib/flowContext.js +2270 -148
- package/lib/flowEngine.d.ts +160 -1
- package/lib/flowEngine.js +387 -27
- package/lib/flowI18n.js +6 -4
- package/lib/flowSettings.d.ts +14 -6
- package/lib/flowSettings.js +51 -17
- package/lib/index.d.ts +8 -1
- package/lib/index.js +24 -1
- package/lib/lazy-helper.d.ts +14 -0
- package/lib/lazy-helper.js +71 -0
- package/lib/locale/en-US.json +9 -2
- package/lib/locale/index.d.ts +14 -0
- package/lib/locale/zh-CN.json +8 -1
- package/lib/models/CollectionFieldModel.d.ts +1 -0
- package/lib/models/CollectionFieldModel.js +3 -2
- package/lib/models/DisplayItemModel.d.ts +1 -1
- package/lib/models/EditableItemModel.d.ts +1 -1
- package/lib/models/FilterableItemModel.d.ts +1 -1
- package/lib/models/flowModel.d.ts +7 -0
- package/lib/models/flowModel.js +83 -8
- package/lib/provider.js +7 -6
- package/lib/resources/baseRecordResource.d.ts +5 -0
- package/lib/resources/baseRecordResource.js +24 -0
- package/lib/resources/multiRecordResource.d.ts +1 -0
- package/lib/resources/multiRecordResource.js +11 -4
- package/lib/resources/singleRecordResource.js +2 -0
- package/lib/resources/sqlResource.d.ts +4 -3
- package/lib/resources/sqlResource.js +8 -3
- package/lib/runjs-context/contexts/FormJSFieldItemRunJSContext.js +12 -2
- package/lib/runjs-context/contexts/JSBlockRunJSContext.js +2 -2
- package/lib/runjs-context/contexts/JSEditableFieldRunJSContext.d.ts +16 -0
- package/lib/runjs-context/contexts/JSEditableFieldRunJSContext.js +125 -0
- package/lib/runjs-context/contexts/JSItemRunJSContext.js +12 -2
- package/lib/runjs-context/contexts/base.js +706 -41
- package/lib/runjs-context/contributions.d.ts +33 -0
- package/lib/runjs-context/contributions.js +88 -0
- package/lib/runjs-context/helpers.js +12 -1
- package/lib/runjs-context/registry.d.ts +1 -1
- package/lib/runjs-context/setup.js +23 -9
- package/lib/runjs-context/snippets/global/api-request.snippet.js +3 -3
- package/lib/runjs-context/snippets/global/import-esm.snippet.js +2 -3
- package/lib/runjs-context/snippets/global/query-selector.snippet.js +8 -3
- package/lib/runjs-context/snippets/global/require-amd.snippet.js +1 -1
- package/lib/runjs-context/snippets/index.d.ts +11 -1
- package/lib/runjs-context/snippets/index.js +61 -40
- package/lib/runjs-context/snippets/scene/block/add-event-listener.snippet.js +10 -7
- package/lib/runjs-context/snippets/scene/block/api-fetch-render-list.snippet.js +3 -3
- package/lib/runjs-context/snippets/scene/block/chartjs-bar.snippet.js +2 -2
- package/lib/runjs-context/snippets/scene/block/echarts-init.snippet.js +2 -2
- package/lib/runjs-context/snippets/scene/block/render-iframe.snippet.js +2 -2
- package/lib/runjs-context/snippets/scene/block/render-react.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/block/render-statistics.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/block/render-timeline.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/block/resource-example.snippet.js +5 -5
- package/lib/runjs-context/snippets/scene/block/three-users-orbit.snippet.js +6 -6
- package/lib/runjs-context/snippets/scene/block/vue-component.snippet.js +3 -4
- package/lib/runjs-context/snippets/scene/detail/color-by-value.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/detail/copy-to-clipboard.snippet.js +20 -3
- package/lib/runjs-context/snippets/scene/detail/format-number.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/detail/innerHTML-value.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/detail/percentage-bar.snippet.js +3 -3
- package/lib/runjs-context/snippets/scene/detail/relative-time.snippet.js +3 -3
- package/lib/runjs-context/snippets/scene/detail/status-tag.snippet.js +2 -2
- package/lib/runjs-context/snippets/scene/form/cascade-select.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/form/render-basic.snippet.js +2 -2
- package/lib/runjs-context/snippets/scene/table/cell-open-dialog.snippet.js +6 -3
- package/lib/runjs-context/snippets/scene/table/concat-fields.snippet.js +3 -1
- package/lib/runjsLibs.d.ts +28 -0
- package/lib/runjsLibs.js +532 -0
- package/lib/scheduler/ModelOperationScheduler.d.ts +7 -1
- package/lib/scheduler/ModelOperationScheduler.js +28 -23
- package/lib/server.d.ts +10 -0
- package/lib/server.js +32 -0
- package/lib/types.d.ts +296 -1
- package/lib/utils/associationObjectVariable.d.ts +2 -2
- package/lib/utils/createCollectionContextMeta.js +1 -0
- package/lib/utils/createEphemeralContext.js +2 -2
- package/lib/utils/dateVariable.d.ts +16 -0
- package/lib/utils/dateVariable.js +380 -0
- package/lib/utils/exceptions.d.ts +7 -0
- package/lib/utils/exceptions.js +10 -0
- package/lib/utils/index.d.ts +8 -3
- package/lib/utils/index.js +49 -0
- package/lib/utils/params-resolvers.js +16 -9
- package/lib/utils/parsePathnameToViewParams.js +1 -1
- package/lib/utils/resolveModuleUrl.d.ts +58 -0
- package/lib/utils/resolveModuleUrl.js +65 -0
- package/lib/utils/resolveRunJSObjectValues.d.ts +16 -0
- package/lib/utils/resolveRunJSObjectValues.js +61 -0
- package/lib/utils/runjsModuleLoader.d.ts +58 -0
- package/lib/utils/runjsModuleLoader.js +422 -0
- package/lib/utils/runjsTemplateCompat.d.ts +35 -0
- package/lib/utils/runjsTemplateCompat.js +743 -0
- package/lib/utils/runjsValue.d.ts +29 -0
- package/lib/utils/runjsValue.js +275 -0
- package/lib/utils/safeGlobals.d.ts +18 -8
- package/lib/utils/safeGlobals.js +164 -17
- package/lib/utils/schema-utils.d.ts +17 -1
- package/lib/utils/schema-utils.js +80 -0
- package/lib/views/FlowView.d.ts +7 -1
- package/lib/views/createViewMeta.d.ts +0 -7
- package/lib/views/createViewMeta.js +19 -70
- package/lib/views/index.d.ts +1 -2
- package/lib/views/index.js +4 -3
- package/lib/views/runViewBeforeClose.d.ts +10 -0
- package/lib/views/runViewBeforeClose.js +45 -0
- package/lib/views/useDialog.d.ts +2 -1
- package/lib/views/useDialog.js +28 -6
- package/lib/views/useDrawer.d.ts +2 -1
- package/lib/views/useDrawer.js +27 -5
- package/lib/views/usePage.d.ts +6 -1
- package/lib/views/usePage.js +53 -9
- package/lib/views/usePopover.js +4 -1
- package/lib/views/viewEvents.d.ts +17 -0
- package/lib/views/viewEvents.js +90 -0
- package/package.json +5 -5
- package/server.d.ts +1 -0
- package/server.js +1 -0
- package/src/BlockScopedFlowEngine.ts +2 -5
- package/src/FlowSchemaRegistry.ts +1799 -0
- package/src/JSRunner.ts +111 -5
- package/src/ViewScopedFlowEngine.ts +8 -0
- package/src/__tests__/FlowSchemaRegistry.test.ts +1951 -0
- package/src/__tests__/JSRunner.test.ts +91 -1
- package/src/__tests__/createViewMeta.popup.test.ts +62 -1
- package/src/__tests__/flow-engine.test.ts +48 -0
- package/src/__tests__/flowContext.test.ts +693 -1
- package/src/__tests__/flowEngine.dataSourceDirty.test.ts +63 -0
- package/src/__tests__/flowEngine.modelLoaders.test.ts +249 -0
- package/src/__tests__/flowEngine.saveModel.test.ts +4 -0
- package/src/__tests__/flowModel.openView.navigation.test.ts +28 -0
- package/src/__tests__/flowRunJSContextDefine.test.ts +63 -0
- package/src/__tests__/flowRuntimeContext.test.ts +2 -1
- package/src/__tests__/flowSettings.open.test.tsx +123 -19
- package/src/__tests__/flowSettings.test.ts +94 -15
- package/src/__tests__/provider.test.tsx +0 -5
- package/src/__tests__/renderHiddenInConfig.test.tsx +6 -6
- package/src/__tests__/runjsContext.test.ts +26 -7
- package/src/__tests__/runjsContextImplementations.test.ts +34 -3
- package/src/__tests__/runjsContextRuntime.test.ts +5 -3
- package/src/__tests__/runjsContributions.test.ts +89 -0
- package/src/__tests__/runjsExternalLibs.test.ts +242 -0
- package/src/__tests__/runjsLibsLazyLoading.test.ts +44 -0
- package/src/__tests__/runjsLocales.test.ts +4 -1
- package/src/__tests__/runjsPreprocessDefault.test.ts +72 -0
- package/src/__tests__/runjsRuntimeFeatures.test.ts +166 -0
- package/src/__tests__/runjsSnippets.test.ts +40 -3
- package/src/__tests__/viewScopedFlowEngine.test.ts +3 -3
- package/src/acl/Acl.tsx +3 -3
- package/src/components/FlowContextSelector.tsx +208 -12
- package/src/components/MobilePopup.tsx +4 -2
- package/src/components/__tests__/flow-model-render-error-fallback.test.tsx +3 -3
- package/src/components/__tests__/gridDragPlanner.test.ts +229 -1
- package/src/components/dnd/gridDragPlanner.ts +68 -2
- package/src/components/settings/wrappers/component/SwitchWithTitle.tsx +2 -1
- package/src/components/settings/wrappers/component/__tests__/InlineControls.test.tsx +74 -0
- package/src/components/settings/wrappers/contextual/DefaultSettingsIcon.tsx +109 -16
- package/src/components/settings/wrappers/contextual/FlowsContextMenu.tsx +41 -7
- package/src/components/settings/wrappers/contextual/StepSettingsDialog.tsx +31 -4
- package/src/components/settings/wrappers/contextual/__tests__/DefaultSettingsIcon.test.tsx +157 -5
- package/src/components/subModel/AddSubModelButton.tsx +32 -2
- package/src/components/subModel/__tests__/AddSubModelButton.test.tsx +143 -32
- package/src/components/subModel/utils.ts +1 -1
- package/src/components/variables/VariableInput.tsx +12 -4
- package/src/components/variables/VariableTag.tsx +54 -45
- package/src/components/variables/__tests__/FlowContextSelector.test.tsx +260 -3
- package/src/components/variables/__tests__/VariableTag.test.tsx +50 -0
- package/src/components/variables/__tests__/utils.test.ts +81 -3
- package/src/components/variables/utils.ts +67 -6
- package/src/data-source/index.ts +88 -110
- package/src/executor/FlowExecutor.ts +230 -28
- package/src/executor/__tests__/flowExecutor.test.ts +123 -0
- package/src/flow-schema-registry/fieldBinding.ts +171 -0
- package/src/flow-schema-registry/modelPatches.ts +260 -0
- package/src/flow-schema-registry/schemaInference.ts +210 -0
- package/src/flow-schema-registry/utils.ts +268 -0
- package/src/flowContext.ts +2989 -212
- package/src/flowEngine.ts +434 -23
- package/src/flowI18n.ts +7 -5
- package/src/flowSettings.ts +58 -18
- package/src/index.ts +15 -1
- package/src/lazy-helper.tsx +57 -0
- package/src/locale/en-US.json +9 -2
- package/src/locale/zh-CN.json +8 -1
- package/src/models/CollectionFieldModel.tsx +3 -1
- package/src/models/DisplayItemModel.tsx +1 -1
- package/src/models/EditableItemModel.tsx +1 -1
- package/src/models/FilterableItemModel.tsx +1 -1
- package/src/models/__tests__/dispatchEvent.when.test.ts +768 -0
- package/src/models/__tests__/flowModel.clone.test.ts +416 -0
- package/src/models/__tests__/flowModel.test.ts +20 -4
- package/src/models/flowModel.tsx +112 -7
- package/src/provider.tsx +9 -7
- package/src/resources/__tests__/multiRecordResource.test.ts +44 -0
- package/src/resources/__tests__/sqlResource.test.ts +60 -0
- package/src/resources/baseRecordResource.ts +31 -0
- package/src/resources/multiRecordResource.ts +11 -4
- package/src/resources/singleRecordResource.ts +3 -0
- package/src/resources/sqlResource.ts +11 -6
- package/src/runjs-context/contexts/FormJSFieldItemRunJSContext.ts +10 -0
- package/src/runjs-context/contexts/JSBlockRunJSContext.ts +6 -2
- package/src/runjs-context/contexts/JSEditableFieldRunJSContext.ts +106 -0
- package/src/runjs-context/contexts/JSItemRunJSContext.ts +10 -0
- package/src/runjs-context/contexts/base.ts +715 -44
- package/src/runjs-context/contributions.ts +88 -0
- package/src/runjs-context/helpers.ts +11 -1
- package/src/runjs-context/registry.ts +1 -1
- package/src/runjs-context/setup.ts +25 -9
- package/src/runjs-context/snippets/global/api-request.snippet.ts +3 -3
- package/src/runjs-context/snippets/global/import-esm.snippet.ts +2 -3
- package/src/runjs-context/snippets/global/query-selector.snippet.ts +8 -3
- package/src/runjs-context/snippets/global/require-amd.snippet.ts +1 -1
- package/src/runjs-context/snippets/index.ts +75 -41
- package/src/runjs-context/snippets/scene/block/add-event-listener.snippet.ts +11 -13
- package/src/runjs-context/snippets/scene/block/api-fetch-render-list.snippet.ts +3 -3
- package/src/runjs-context/snippets/scene/block/chartjs-bar.snippet.ts +2 -2
- package/src/runjs-context/snippets/scene/block/echarts-init.snippet.ts +2 -2
- package/src/runjs-context/snippets/scene/block/render-iframe.snippet.ts +2 -2
- package/src/runjs-context/snippets/scene/block/render-react.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/block/render-statistics.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/block/render-timeline.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/block/resource-example.snippet.ts +6 -11
- package/src/runjs-context/snippets/scene/block/three-users-orbit.snippet.ts +6 -6
- package/src/runjs-context/snippets/scene/block/vue-component.snippet.ts +3 -4
- package/src/runjs-context/snippets/scene/detail/color-by-value.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/detail/copy-to-clipboard.snippet.ts +20 -3
- package/src/runjs-context/snippets/scene/detail/format-number.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/detail/innerHTML-value.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/detail/percentage-bar.snippet.ts +3 -3
- package/src/runjs-context/snippets/scene/detail/relative-time.snippet.ts +3 -3
- package/src/runjs-context/snippets/scene/detail/status-tag.snippet.ts +2 -2
- package/src/runjs-context/snippets/scene/form/cascade-select.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/form/render-basic.snippet.ts +3 -8
- package/src/runjs-context/snippets/scene/table/cell-open-dialog.snippet.ts +6 -3
- package/src/runjs-context/snippets/scene/table/concat-fields.snippet.ts +3 -1
- package/src/runjsLibs.ts +622 -0
- package/src/scheduler/ModelOperationScheduler.ts +41 -24
- package/src/server.ts +11 -0
- package/src/types.ts +359 -1
- package/src/utils/__tests__/dateVariable.test.ts +101 -0
- package/src/utils/__tests__/params-resolvers.test.ts +40 -0
- package/src/utils/__tests__/parsePathnameToViewParams.test.ts +7 -0
- package/src/utils/__tests__/runjsRequireAsyncAutoWhitelist.test.ts +38 -0
- package/src/utils/__tests__/runjsTemplateCompat.test.ts +159 -0
- package/src/utils/__tests__/runjsValue.test.ts +44 -0
- package/src/utils/__tests__/safeGlobals.test.ts +57 -2
- package/src/utils/__tests__/utils.test.ts +157 -0
- package/src/utils/associationObjectVariable.ts +2 -2
- package/src/utils/createCollectionContextMeta.ts +1 -0
- package/src/utils/createEphemeralContext.ts +5 -4
- package/src/utils/dateVariable.ts +397 -0
- package/src/utils/exceptions.ts +11 -0
- package/src/utils/index.ts +38 -3
- package/src/utils/params-resolvers.ts +23 -9
- package/src/utils/parsePathnameToViewParams.ts +2 -2
- package/src/utils/resolveModuleUrl.ts +91 -0
- package/src/utils/resolveRunJSObjectValues.ts +46 -0
- package/src/utils/runjsModuleLoader.ts +553 -0
- package/src/utils/runjsTemplateCompat.ts +828 -0
- package/src/utils/runjsValue.ts +287 -0
- package/src/utils/safeGlobals.ts +188 -17
- package/src/utils/schema-utils.ts +109 -1
- package/src/views/FlowView.tsx +11 -1
- package/src/views/__tests__/FlowView.usePage.test.tsx +54 -1
- package/src/views/__tests__/runViewBeforeClose.test.ts +30 -0
- package/src/views/__tests__/useDialog.closeDestroy.test.tsx +44 -16
- package/src/views/__tests__/viewEvents.resolveOpenerEngine.test.ts +28 -0
- package/src/views/createViewMeta.ts +22 -75
- package/src/views/index.tsx +1 -2
- package/src/views/runViewBeforeClose.ts +19 -0
- package/src/views/useDialog.tsx +34 -5
- package/src/views/useDrawer.tsx +33 -4
- package/src/views/usePage.tsx +63 -8
- package/src/views/usePopover.tsx +4 -1
- package/src/views/viewEvents.ts +55 -0
package/lib/views/usePage.js
CHANGED
|
@@ -37,6 +37,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
37
37
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
38
|
var usePage_exports = {};
|
|
39
39
|
__export(usePage_exports, {
|
|
40
|
+
EMBED_REPLACING_DATA_KEY: () => EMBED_REPLACING_DATA_KEY,
|
|
41
|
+
GLOBAL_EMBED_CONTAINER_ID: () => GLOBAL_EMBED_CONTAINER_ID,
|
|
40
42
|
usePage: () => usePage
|
|
41
43
|
});
|
|
42
44
|
module.exports = __toCommonJS(usePage_exports);
|
|
@@ -48,22 +50,27 @@ var import_FlowContextProvider = require("../FlowContextProvider");
|
|
|
48
50
|
var import_createViewMeta = require("./createViewMeta");
|
|
49
51
|
var import_PageComponent = require("./PageComponent");
|
|
50
52
|
var import_usePatchElement = __toESM(require("./usePatchElement"));
|
|
53
|
+
var import_viewEvents = require("./viewEvents");
|
|
51
54
|
var import_provider = require("../provider");
|
|
52
55
|
var import_ViewScopedFlowEngine = require("../ViewScopedFlowEngine");
|
|
53
56
|
var import_variablesParams = require("../utils/variablesParams");
|
|
57
|
+
var import_runViewBeforeClose = require("./runViewBeforeClose");
|
|
54
58
|
let uuid = 0;
|
|
59
|
+
const GLOBAL_EMBED_CONTAINER_ID = "nocobase-embed-container";
|
|
60
|
+
const EMBED_REPLACING_DATA_KEY = "nocobaseEmbedReplacing";
|
|
55
61
|
const PageElementsHolder = import_react.default.memo(
|
|
56
62
|
import_react.default.forwardRef((props, ref) => {
|
|
57
63
|
const [elements, patchElement] = (0, import_usePatchElement.default)();
|
|
58
64
|
import_react.default.useImperativeHandle(ref, () => ({ patchElement }), [patchElement]);
|
|
59
|
-
console.log("[NocoBase] Rendering PageElementsHolder with elements count:", elements.length);
|
|
60
65
|
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, elements);
|
|
61
66
|
})
|
|
62
67
|
);
|
|
63
68
|
function usePage() {
|
|
64
69
|
const holderRef = import_react.default.useRef(null);
|
|
70
|
+
const globalEmbedActiveRef = import_react.default.useRef(null);
|
|
65
71
|
const open = /* @__PURE__ */ __name((config, flowContext) => {
|
|
66
72
|
var _a, _b, _c;
|
|
73
|
+
const parentEngine = flowContext == null ? void 0 : flowContext.engine;
|
|
67
74
|
uuid += 1;
|
|
68
75
|
const pageRef = import_react.default.createRef();
|
|
69
76
|
let closeFunc;
|
|
@@ -93,9 +100,27 @@ function usePage() {
|
|
|
93
100
|
}, [props]);
|
|
94
101
|
return null;
|
|
95
102
|
}, "HeaderComponent");
|
|
96
|
-
const {
|
|
103
|
+
const {
|
|
104
|
+
target,
|
|
105
|
+
content,
|
|
106
|
+
preventClose,
|
|
107
|
+
inheritContext = true,
|
|
108
|
+
inputArgs: viewInputArgs = {},
|
|
109
|
+
...restConfig
|
|
110
|
+
} = config;
|
|
111
|
+
const isGlobalEmbedContainer = target instanceof HTMLElement && target.id === GLOBAL_EMBED_CONTAINER_ID;
|
|
112
|
+
if (isGlobalEmbedContainer && globalEmbedActiveRef.current) {
|
|
113
|
+
try {
|
|
114
|
+
target.dataset[EMBED_REPLACING_DATA_KEY] = "1";
|
|
115
|
+
globalEmbedActiveRef.current.destroy();
|
|
116
|
+
} finally {
|
|
117
|
+
delete target.dataset[EMBED_REPLACING_DATA_KEY];
|
|
118
|
+
globalEmbedActiveRef.current = null;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
97
121
|
const ctx = new import_flowContext.FlowContext();
|
|
98
122
|
const scopedEngine = (0, import_ViewScopedFlowEngine.createViewScopedEngine)(flowContext.engine);
|
|
123
|
+
const openerEngine = (0, import_viewEvents.resolveOpenerEngine)(parentEngine, scopedEngine);
|
|
99
124
|
ctx.defineProperty("engine", { value: scopedEngine });
|
|
100
125
|
ctx.addDelegate(scopedEngine.context);
|
|
101
126
|
if (inheritContext) {
|
|
@@ -105,30 +130,45 @@ function usePage() {
|
|
|
105
130
|
}
|
|
106
131
|
const currentPage = {
|
|
107
132
|
type: "embed",
|
|
108
|
-
inputArgs:
|
|
133
|
+
inputArgs: viewInputArgs,
|
|
109
134
|
preventClose: !!config.preventClose,
|
|
135
|
+
beforeClose: void 0,
|
|
110
136
|
destroy: /* @__PURE__ */ __name((result) => {
|
|
111
|
-
var _a2, _b2;
|
|
137
|
+
var _a2, _b2, _c2, _d, _e;
|
|
112
138
|
(_a2 = config.onClose) == null ? void 0 : _a2.call(config);
|
|
113
139
|
resolvePromise == null ? void 0 : resolvePromise(result);
|
|
114
140
|
(_b2 = pageRef.current) == null ? void 0 : _b2.destroy();
|
|
115
141
|
closeFunc == null ? void 0 : closeFunc();
|
|
142
|
+
if (isGlobalEmbedContainer) {
|
|
143
|
+
globalEmbedActiveRef.current = null;
|
|
144
|
+
}
|
|
145
|
+
const isReplacing = isGlobalEmbedContainer && target instanceof HTMLElement && ((_c2 = target.dataset) == null ? void 0 : _c2[EMBED_REPLACING_DATA_KEY]) === "1";
|
|
146
|
+
if (!isReplacing) {
|
|
147
|
+
const openerEmitter = openerEngine == null ? void 0 : openerEngine.emitter;
|
|
148
|
+
(0, import_viewEvents.bumpViewActivatedVersion)(openerEmitter);
|
|
149
|
+
(_e = openerEmitter == null ? void 0 : openerEmitter.emit) == null ? void 0 : _e.call(openerEmitter, import_viewEvents.VIEW_ACTIVATED_EVENT, { type: "embed", viewUid: (_d = currentPage == null ? void 0 : currentPage.inputArgs) == null ? void 0 : _d.viewUid });
|
|
150
|
+
}
|
|
116
151
|
scopedEngine.unlinkFromStack();
|
|
117
152
|
}, "destroy"),
|
|
118
153
|
update: /* @__PURE__ */ __name((newConfig) => {
|
|
119
154
|
var _a2;
|
|
120
155
|
return (_a2 = pageRef.current) == null ? void 0 : _a2.update(newConfig);
|
|
121
156
|
}, "update"),
|
|
122
|
-
close: /* @__PURE__ */ __name((result, force) => {
|
|
157
|
+
close: /* @__PURE__ */ __name(async (result, force) => {
|
|
123
158
|
var _a2, _b2;
|
|
124
159
|
if (preventClose && !force) {
|
|
125
|
-
return;
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
const shouldClose = await (0, import_runViewBeforeClose.runViewBeforeClose)(currentPage, { result, force });
|
|
163
|
+
if (!shouldClose) {
|
|
164
|
+
return false;
|
|
126
165
|
}
|
|
127
166
|
if (config.triggerByRouter && ((_b2 = (_a2 = config.inputArgs) == null ? void 0 : _a2.navigation) == null ? void 0 : _b2.back)) {
|
|
128
167
|
config.inputArgs.navigation.back();
|
|
129
|
-
return;
|
|
168
|
+
return true;
|
|
130
169
|
}
|
|
131
170
|
currentPage.destroy(result);
|
|
171
|
+
return true;
|
|
132
172
|
}, "close"),
|
|
133
173
|
Header: HeaderComponent,
|
|
134
174
|
Footer: FooterComponent,
|
|
@@ -147,7 +187,6 @@ function usePage() {
|
|
|
147
187
|
};
|
|
148
188
|
ctx.defineProperty("view", {
|
|
149
189
|
get: /* @__PURE__ */ __name(() => currentPage, "get"),
|
|
150
|
-
// meta: createViewMeta(ctx),
|
|
151
190
|
// 仅当访问关联字段或前端无本地记录数据时,才交给服务端解析
|
|
152
191
|
resolveOnServer: (0, import_variablesParams.createViewRecordResolveOnServer)(ctx, () => (0, import_variablesParams.getViewRecordFromParent)(flowContext, ctx))
|
|
153
192
|
});
|
|
@@ -186,13 +225,16 @@ function usePage() {
|
|
|
186
225
|
displayName: "PageWithContext"
|
|
187
226
|
}
|
|
188
227
|
);
|
|
189
|
-
const key = (
|
|
228
|
+
const key = (viewInputArgs == null ? void 0 : viewInputArgs.viewUid) || `page-${uuid}`;
|
|
190
229
|
const page = /* @__PURE__ */ import_react.default.createElement(import_provider.FlowEngineProvider, { key, engine: scopedEngine }, /* @__PURE__ */ import_react.default.createElement(import_FlowContextProvider.FlowViewContextProvider, { context: ctx }, /* @__PURE__ */ import_react.default.createElement(PageWithContext, null)));
|
|
191
230
|
if (target && target instanceof HTMLElement) {
|
|
192
231
|
closeFunc = (_b = holderRef.current) == null ? void 0 : _b.patchElement(import_react_dom.default.createPortal(page, target, key));
|
|
193
232
|
} else {
|
|
194
233
|
closeFunc = (_c = holderRef.current) == null ? void 0 : _c.patchElement(page);
|
|
195
234
|
}
|
|
235
|
+
if (isGlobalEmbedContainer) {
|
|
236
|
+
globalEmbedActiveRef.current = { destroy: currentPage.destroy };
|
|
237
|
+
}
|
|
196
238
|
return Object.assign(promise, currentPage);
|
|
197
239
|
}, "open");
|
|
198
240
|
const api = import_react.default.useMemo(() => ({ open }), []);
|
|
@@ -201,5 +243,7 @@ function usePage() {
|
|
|
201
243
|
__name(usePage, "usePage");
|
|
202
244
|
// Annotate the CommonJS export names for ESM import in node:
|
|
203
245
|
0 && (module.exports = {
|
|
246
|
+
EMBED_REPLACING_DATA_KEY,
|
|
247
|
+
GLOBAL_EMBED_CONTAINER_ID,
|
|
204
248
|
usePage
|
|
205
249
|
});
|
package/lib/views/usePopover.js
CHANGED
|
@@ -68,8 +68,11 @@ const PopoverComponent = React.forwardRef(({ afterClose, content, placement, rec
|
|
|
68
68
|
destroyTooltipOnHide: true,
|
|
69
69
|
content: config.content,
|
|
70
70
|
placement: config.placement,
|
|
71
|
-
getPopupContainer: () => document.body,
|
|
71
|
+
getPopupContainer: () => document.querySelector("#nocobase-app-container") || document.body,
|
|
72
72
|
onOpenChange: (nextOpen) => {
|
|
73
|
+
if (!nextOpen && config.preventClose) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
73
76
|
setVisible(nextOpen);
|
|
74
77
|
if (!nextOpen) {
|
|
75
78
|
afterClose == null ? void 0 : afterClose();
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
import { FlowEngine } from '../flowEngine';
|
|
10
|
+
export declare const VIEW_ACTIVATED_VERSION: unique symbol;
|
|
11
|
+
export declare const VIEW_ACTIVATED_EVENT: "view:activated";
|
|
12
|
+
export declare const DATA_SOURCE_DIRTY_EVENT: "dataSource:dirty";
|
|
13
|
+
export declare const ENGINE_SCOPE_KEY: "__NOCOBASE_ENGINE_SCOPE__";
|
|
14
|
+
export declare const VIEW_ENGINE_SCOPE: "view";
|
|
15
|
+
export declare function getEmitterViewActivatedVersion(emitter: any): number;
|
|
16
|
+
export declare function bumpViewActivatedVersion(emitter: any): number;
|
|
17
|
+
export declare function resolveOpenerEngine(parentEngine: FlowEngine, scopedEngine: FlowEngine): FlowEngine | undefined;
|
|
@@ -0,0 +1,90 @@
|
|
|
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 __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
15
|
+
var __export = (target, all) => {
|
|
16
|
+
for (var name in all)
|
|
17
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
18
|
+
};
|
|
19
|
+
var __copyProps = (to, from, except, desc) => {
|
|
20
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
+
for (let key of __getOwnPropNames(from))
|
|
22
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
23
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
|
+
}
|
|
25
|
+
return to;
|
|
26
|
+
};
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var viewEvents_exports = {};
|
|
29
|
+
__export(viewEvents_exports, {
|
|
30
|
+
DATA_SOURCE_DIRTY_EVENT: () => DATA_SOURCE_DIRTY_EVENT,
|
|
31
|
+
ENGINE_SCOPE_KEY: () => ENGINE_SCOPE_KEY,
|
|
32
|
+
VIEW_ACTIVATED_EVENT: () => VIEW_ACTIVATED_EVENT,
|
|
33
|
+
VIEW_ACTIVATED_VERSION: () => VIEW_ACTIVATED_VERSION,
|
|
34
|
+
VIEW_ENGINE_SCOPE: () => VIEW_ENGINE_SCOPE,
|
|
35
|
+
bumpViewActivatedVersion: () => bumpViewActivatedVersion,
|
|
36
|
+
getEmitterViewActivatedVersion: () => getEmitterViewActivatedVersion,
|
|
37
|
+
resolveOpenerEngine: () => resolveOpenerEngine
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(viewEvents_exports);
|
|
40
|
+
const VIEW_ACTIVATED_VERSION = Symbol.for("__NOCOBASE_VIEW_ACTIVATED_VERSION__");
|
|
41
|
+
const VIEW_ACTIVATED_EVENT = "view:activated";
|
|
42
|
+
const DATA_SOURCE_DIRTY_EVENT = "dataSource:dirty";
|
|
43
|
+
const ENGINE_SCOPE_KEY = "__NOCOBASE_ENGINE_SCOPE__";
|
|
44
|
+
const VIEW_ENGINE_SCOPE = "view";
|
|
45
|
+
function getEmitterViewActivatedVersion(emitter) {
|
|
46
|
+
const raw = Reflect.get(emitter, VIEW_ACTIVATED_VERSION);
|
|
47
|
+
const num = typeof raw === "number" ? raw : Number(raw);
|
|
48
|
+
return Number.isFinite(num) && num > 0 ? num : 0;
|
|
49
|
+
}
|
|
50
|
+
__name(getEmitterViewActivatedVersion, "getEmitterViewActivatedVersion");
|
|
51
|
+
function bumpViewActivatedVersion(emitter) {
|
|
52
|
+
const current = getEmitterViewActivatedVersion(emitter);
|
|
53
|
+
if (!Object.isExtensible(emitter)) return current;
|
|
54
|
+
const next = current + 1;
|
|
55
|
+
Reflect.set(emitter, VIEW_ACTIVATED_VERSION, next);
|
|
56
|
+
return next;
|
|
57
|
+
}
|
|
58
|
+
__name(bumpViewActivatedVersion, "bumpViewActivatedVersion");
|
|
59
|
+
function isViewEngine(engine) {
|
|
60
|
+
return Reflect.get(engine, ENGINE_SCOPE_KEY) === VIEW_ENGINE_SCOPE;
|
|
61
|
+
}
|
|
62
|
+
__name(isViewEngine, "isViewEngine");
|
|
63
|
+
function findNearestViewEngine(engine) {
|
|
64
|
+
let cur = engine;
|
|
65
|
+
let guard = 0;
|
|
66
|
+
while (cur && guard++ < 50) {
|
|
67
|
+
if (isViewEngine(cur)) return cur;
|
|
68
|
+
cur = cur.previousEngine;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
__name(findNearestViewEngine, "findNearestViewEngine");
|
|
72
|
+
function resolveOpenerEngine(parentEngine, scopedEngine) {
|
|
73
|
+
if (!parentEngine) return void 0;
|
|
74
|
+
const parentViewEngine = findNearestViewEngine(parentEngine);
|
|
75
|
+
if (parentViewEngine) return parentViewEngine;
|
|
76
|
+
const previousEngine = scopedEngine == null ? void 0 : scopedEngine.previousEngine;
|
|
77
|
+
return findNearestViewEngine(previousEngine) || parentEngine;
|
|
78
|
+
}
|
|
79
|
+
__name(resolveOpenerEngine, "resolveOpenerEngine");
|
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
DATA_SOURCE_DIRTY_EVENT,
|
|
83
|
+
ENGINE_SCOPE_KEY,
|
|
84
|
+
VIEW_ACTIVATED_EVENT,
|
|
85
|
+
VIEW_ACTIVATED_VERSION,
|
|
86
|
+
VIEW_ENGINE_SCOPE,
|
|
87
|
+
bumpViewActivatedVersion,
|
|
88
|
+
getEmitterViewActivatedVersion,
|
|
89
|
+
resolveOpenerEngine
|
|
90
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/flow-engine",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.11",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A standalone flow engine for NocoBase, managing workflows, models, and actions.",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@formily/antd-v5": "1.x",
|
|
10
10
|
"@formily/reactive": "2.x",
|
|
11
|
-
"@nocobase/sdk": "2.1.0-alpha.
|
|
12
|
-
"@nocobase/shared": "2.1.0-alpha.
|
|
11
|
+
"@nocobase/sdk": "2.1.0-alpha.11",
|
|
12
|
+
"@nocobase/shared": "2.1.0-alpha.11",
|
|
13
13
|
"ahooks": "^3.7.2",
|
|
14
14
|
"dayjs": "^1.11.9",
|
|
15
15
|
"dompurify": "^3.0.2",
|
|
@@ -35,6 +35,6 @@
|
|
|
35
35
|
"workflow"
|
|
36
36
|
],
|
|
37
37
|
"author": "NocoBase Team",
|
|
38
|
-
"license": "
|
|
39
|
-
"gitHead": "
|
|
38
|
+
"license": "Apache-2.0",
|
|
39
|
+
"gitHead": "bb96d633a6371afb586072ff516bd0613c757db0"
|
|
40
40
|
}
|
package/server.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src/server';
|
package/server.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = process.env.IS_DEV_CMD || process.env.VITEST ? require('./src/server.ts') : require('./lib/server');
|
|
@@ -31,16 +31,13 @@ export function createBlockScopedEngine(parent: FlowEngine): FlowEngine {
|
|
|
31
31
|
local.context.addDelegate(parent.context);
|
|
32
32
|
|
|
33
33
|
// 覆盖 unlinkFromStack:BlockScoped 引擎被移除时,修复前后指针,避免“截断”后续视图/作用域
|
|
34
|
-
const originalUnlink = local.unlinkFromStack.bind(local);
|
|
35
34
|
local.unlinkFromStack = function () {
|
|
36
|
-
// 修复指针:prev -> next,next -> prev,然后清理自身指针
|
|
37
|
-
// 若不这么做,移除位于中间的 block 引擎会导致后续整段链丢失
|
|
38
35
|
const prev = (local as any)._previousEngine as FlowEngine | undefined;
|
|
39
36
|
const next = (local as any)._nextEngine as FlowEngine | undefined;
|
|
40
37
|
if (prev) (prev as any)._nextEngine = next;
|
|
41
38
|
if (next) (next as any)._previousEngine = prev;
|
|
42
|
-
(local as any)._previousEngine = undefined
|
|
43
|
-
(local as any)._nextEngine = undefined
|
|
39
|
+
(local as any)._previousEngine = undefined;
|
|
40
|
+
(local as any)._nextEngine = undefined;
|
|
44
41
|
};
|
|
45
42
|
|
|
46
43
|
// 默认全部代理到父引擎,只有少数字段(实例/缓存/执行器/上下文/链表指针)使用本地值
|