@nocobase/flow-engine 2.0.0-beta.8 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/lib/BlockScopedFlowEngine.js +0 -1
  2. package/lib/FlowDefinition.d.ts +2 -0
  3. package/lib/JSRunner.d.ts +6 -0
  4. package/lib/JSRunner.js +32 -2
  5. package/lib/ViewScopedFlowEngine.js +3 -0
  6. package/lib/acl/Acl.js +13 -3
  7. package/lib/components/FlowContextSelector.js +155 -10
  8. package/lib/components/settings/wrappers/component/SwitchWithTitle.js +2 -1
  9. package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.js +76 -15
  10. package/lib/components/settings/wrappers/contextual/FlowsContextMenu.js +24 -4
  11. package/lib/components/settings/wrappers/contextual/StepSettingsDialog.js +5 -1
  12. package/lib/components/variables/VariableInput.js +9 -4
  13. package/lib/components/variables/VariableTag.js +46 -39
  14. package/lib/components/variables/utils.d.ts +7 -0
  15. package/lib/components/variables/utils.js +42 -2
  16. package/lib/data-source/index.d.ts +7 -27
  17. package/lib/data-source/index.js +81 -51
  18. package/lib/executor/FlowExecutor.d.ts +2 -1
  19. package/lib/executor/FlowExecutor.js +163 -22
  20. package/lib/flowContext.d.ts +230 -7
  21. package/lib/flowContext.js +2267 -148
  22. package/lib/flowEngine.d.ts +21 -0
  23. package/lib/flowEngine.js +56 -8
  24. package/lib/flowI18n.js +6 -4
  25. package/lib/flowSettings.js +17 -11
  26. package/lib/index.d.ts +7 -1
  27. package/lib/index.js +21 -0
  28. package/lib/locale/en-US.json +9 -2
  29. package/lib/locale/index.d.ts +14 -0
  30. package/lib/locale/zh-CN.json +8 -1
  31. package/lib/models/CollectionFieldModel.d.ts +1 -0
  32. package/lib/models/CollectionFieldModel.js +3 -2
  33. package/lib/models/flowModel.js +12 -1
  34. package/lib/provider.js +5 -5
  35. package/lib/resources/baseRecordResource.d.ts +5 -0
  36. package/lib/resources/baseRecordResource.js +24 -0
  37. package/lib/resources/multiRecordResource.d.ts +1 -0
  38. package/lib/resources/multiRecordResource.js +11 -4
  39. package/lib/resources/singleRecordResource.js +2 -0
  40. package/lib/resources/sqlResource.d.ts +4 -3
  41. package/lib/resources/sqlResource.js +8 -3
  42. package/lib/runjs-context/contexts/FormJSFieldItemRunJSContext.js +12 -2
  43. package/lib/runjs-context/contexts/JSBlockRunJSContext.js +2 -2
  44. package/lib/runjs-context/contexts/JSEditableFieldRunJSContext.d.ts +16 -0
  45. package/lib/runjs-context/contexts/JSEditableFieldRunJSContext.js +125 -0
  46. package/lib/runjs-context/contexts/JSItemRunJSContext.js +12 -2
  47. package/lib/runjs-context/contexts/base.js +706 -41
  48. package/lib/runjs-context/contributions.d.ts +33 -0
  49. package/lib/runjs-context/contributions.js +88 -0
  50. package/lib/runjs-context/helpers.js +12 -1
  51. package/lib/runjs-context/setup.js +6 -0
  52. package/lib/runjs-context/snippets/global/api-request.snippet.js +3 -3
  53. package/lib/runjs-context/snippets/global/import-esm.snippet.js +2 -3
  54. package/lib/runjs-context/snippets/global/query-selector.snippet.js +8 -3
  55. package/lib/runjs-context/snippets/global/require-amd.snippet.js +1 -1
  56. package/lib/runjs-context/snippets/index.d.ts +11 -1
  57. package/lib/runjs-context/snippets/index.js +61 -40
  58. package/lib/runjs-context/snippets/scene/block/add-event-listener.snippet.js +10 -7
  59. package/lib/runjs-context/snippets/scene/block/api-fetch-render-list.snippet.js +3 -3
  60. package/lib/runjs-context/snippets/scene/block/chartjs-bar.snippet.js +2 -2
  61. package/lib/runjs-context/snippets/scene/block/echarts-init.snippet.js +2 -2
  62. package/lib/runjs-context/snippets/scene/block/render-iframe.snippet.js +2 -2
  63. package/lib/runjs-context/snippets/scene/block/render-react.snippet.js +1 -1
  64. package/lib/runjs-context/snippets/scene/block/render-statistics.snippet.js +1 -1
  65. package/lib/runjs-context/snippets/scene/block/render-timeline.snippet.js +1 -1
  66. package/lib/runjs-context/snippets/scene/block/resource-example.snippet.js +5 -5
  67. package/lib/runjs-context/snippets/scene/block/three-users-orbit.snippet.js +6 -6
  68. package/lib/runjs-context/snippets/scene/block/vue-component.snippet.js +3 -4
  69. package/lib/runjs-context/snippets/scene/detail/color-by-value.snippet.js +1 -1
  70. package/lib/runjs-context/snippets/scene/detail/copy-to-clipboard.snippet.js +20 -3
  71. package/lib/runjs-context/snippets/scene/detail/format-number.snippet.js +1 -1
  72. package/lib/runjs-context/snippets/scene/detail/innerHTML-value.snippet.js +1 -1
  73. package/lib/runjs-context/snippets/scene/detail/percentage-bar.snippet.js +3 -3
  74. package/lib/runjs-context/snippets/scene/detail/relative-time.snippet.js +3 -3
  75. package/lib/runjs-context/snippets/scene/detail/status-tag.snippet.js +2 -2
  76. package/lib/runjs-context/snippets/scene/form/cascade-select.snippet.js +1 -1
  77. package/lib/runjs-context/snippets/scene/form/render-basic.snippet.js +2 -2
  78. package/lib/runjs-context/snippets/scene/table/cell-open-dialog.snippet.js +6 -3
  79. package/lib/runjs-context/snippets/scene/table/concat-fields.snippet.js +3 -1
  80. package/lib/runjsLibs.d.ts +28 -0
  81. package/lib/runjsLibs.js +532 -0
  82. package/lib/scheduler/ModelOperationScheduler.d.ts +2 -0
  83. package/lib/scheduler/ModelOperationScheduler.js +25 -21
  84. package/lib/types.d.ts +27 -0
  85. package/lib/utils/associationObjectVariable.d.ts +2 -2
  86. package/lib/utils/createCollectionContextMeta.js +1 -0
  87. package/lib/utils/createEphemeralContext.js +2 -2
  88. package/lib/utils/dateVariable.d.ts +16 -0
  89. package/lib/utils/dateVariable.js +380 -0
  90. package/lib/utils/exceptions.d.ts +7 -0
  91. package/lib/utils/exceptions.js +10 -0
  92. package/lib/utils/index.d.ts +8 -3
  93. package/lib/utils/index.js +45 -0
  94. package/lib/utils/params-resolvers.js +16 -9
  95. package/lib/utils/resolveModuleUrl.d.ts +58 -0
  96. package/lib/utils/resolveModuleUrl.js +65 -0
  97. package/lib/utils/resolveRunJSObjectValues.d.ts +16 -0
  98. package/lib/utils/resolveRunJSObjectValues.js +61 -0
  99. package/lib/utils/runjsModuleLoader.d.ts +58 -0
  100. package/lib/utils/runjsModuleLoader.js +422 -0
  101. package/lib/utils/runjsTemplateCompat.d.ts +35 -0
  102. package/lib/utils/runjsTemplateCompat.js +743 -0
  103. package/lib/utils/runjsValue.d.ts +29 -0
  104. package/lib/utils/runjsValue.js +275 -0
  105. package/lib/utils/safeGlobals.d.ts +18 -8
  106. package/lib/utils/safeGlobals.js +164 -17
  107. package/lib/utils/schema-utils.d.ts +10 -0
  108. package/lib/utils/schema-utils.js +61 -0
  109. package/lib/views/createViewMeta.d.ts +0 -7
  110. package/lib/views/createViewMeta.js +19 -70
  111. package/lib/views/index.d.ts +1 -2
  112. package/lib/views/index.js +4 -3
  113. package/lib/views/useDialog.js +7 -2
  114. package/lib/views/useDrawer.js +7 -2
  115. package/lib/views/usePage.d.ts +4 -0
  116. package/lib/views/usePage.js +43 -6
  117. package/lib/views/usePopover.js +4 -1
  118. package/lib/views/viewEvents.d.ts +17 -0
  119. package/lib/views/viewEvents.js +90 -0
  120. package/package.json +4 -4
  121. package/src/BlockScopedFlowEngine.ts +2 -5
  122. package/src/JSRunner.ts +44 -2
  123. package/src/ViewScopedFlowEngine.ts +4 -0
  124. package/src/__tests__/JSRunner.test.ts +64 -0
  125. package/src/__tests__/createViewMeta.popup.test.ts +62 -1
  126. package/src/__tests__/flowContext.test.ts +693 -1
  127. package/src/__tests__/flowEngine.dataSourceDirty.test.ts +63 -0
  128. package/src/__tests__/flowModel.openView.navigation.test.ts +28 -0
  129. package/src/__tests__/flowRunJSContextDefine.test.ts +63 -0
  130. package/src/__tests__/flowRuntimeContext.test.ts +2 -1
  131. package/src/__tests__/flowSettings.open.test.tsx +123 -19
  132. package/src/__tests__/runjsContext.test.ts +10 -7
  133. package/src/__tests__/runjsContextImplementations.test.ts +34 -3
  134. package/src/__tests__/runjsContextRuntime.test.ts +3 -3
  135. package/src/__tests__/runjsContributions.test.ts +89 -0
  136. package/src/__tests__/runjsExternalLibs.test.ts +242 -0
  137. package/src/__tests__/runjsLibsLazyLoading.test.ts +44 -0
  138. package/src/__tests__/runjsLocales.test.ts +4 -1
  139. package/src/__tests__/runjsPreprocessDefault.test.ts +49 -0
  140. package/src/__tests__/runjsRuntimeFeatures.test.ts +166 -0
  141. package/src/__tests__/runjsSnippets.test.ts +40 -3
  142. package/src/acl/Acl.tsx +3 -3
  143. package/src/components/FlowContextSelector.tsx +208 -12
  144. package/src/components/settings/wrappers/component/SwitchWithTitle.tsx +2 -1
  145. package/src/components/settings/wrappers/component/__tests__/InlineControls.test.tsx +74 -0
  146. package/src/components/settings/wrappers/contextual/DefaultSettingsIcon.tsx +109 -16
  147. package/src/components/settings/wrappers/contextual/FlowsContextMenu.tsx +41 -7
  148. package/src/components/settings/wrappers/contextual/StepSettingsDialog.tsx +13 -2
  149. package/src/components/settings/wrappers/contextual/__tests__/DefaultSettingsIcon.test.tsx +157 -5
  150. package/src/components/variables/VariableInput.tsx +12 -4
  151. package/src/components/variables/VariableTag.tsx +54 -45
  152. package/src/components/variables/__tests__/FlowContextSelector.test.tsx +260 -3
  153. package/src/components/variables/__tests__/VariableTag.test.tsx +50 -0
  154. package/src/components/variables/__tests__/utils.test.ts +81 -3
  155. package/src/components/variables/utils.ts +67 -6
  156. package/src/data-source/index.ts +85 -110
  157. package/src/executor/FlowExecutor.ts +200 -23
  158. package/src/executor/__tests__/flowExecutor.test.ts +66 -0
  159. package/src/flowContext.ts +2986 -211
  160. package/src/flowEngine.ts +59 -8
  161. package/src/flowI18n.ts +7 -5
  162. package/src/flowSettings.ts +18 -12
  163. package/src/index.ts +14 -1
  164. package/src/locale/en-US.json +9 -2
  165. package/src/locale/zh-CN.json +8 -1
  166. package/src/models/CollectionFieldModel.tsx +3 -1
  167. package/src/models/__tests__/dispatchEvent.when.test.ts +554 -0
  168. package/src/models/__tests__/flowModel.test.ts +20 -4
  169. package/src/models/flowModel.tsx +13 -1
  170. package/src/provider.tsx +7 -6
  171. package/src/resources/__tests__/multiRecordResource.test.ts +44 -0
  172. package/src/resources/__tests__/sqlResource.test.ts +60 -0
  173. package/src/resources/baseRecordResource.ts +31 -0
  174. package/src/resources/multiRecordResource.ts +11 -4
  175. package/src/resources/singleRecordResource.ts +3 -0
  176. package/src/resources/sqlResource.ts +11 -6
  177. package/src/runjs-context/contexts/FormJSFieldItemRunJSContext.ts +10 -0
  178. package/src/runjs-context/contexts/JSBlockRunJSContext.ts +6 -2
  179. package/src/runjs-context/contexts/JSEditableFieldRunJSContext.ts +106 -0
  180. package/src/runjs-context/contexts/JSItemRunJSContext.ts +10 -0
  181. package/src/runjs-context/contexts/base.ts +715 -44
  182. package/src/runjs-context/contributions.ts +88 -0
  183. package/src/runjs-context/helpers.ts +11 -1
  184. package/src/runjs-context/setup.ts +6 -0
  185. package/src/runjs-context/snippets/global/api-request.snippet.ts +3 -3
  186. package/src/runjs-context/snippets/global/import-esm.snippet.ts +2 -3
  187. package/src/runjs-context/snippets/global/query-selector.snippet.ts +8 -3
  188. package/src/runjs-context/snippets/global/require-amd.snippet.ts +1 -1
  189. package/src/runjs-context/snippets/index.ts +75 -41
  190. package/src/runjs-context/snippets/scene/block/add-event-listener.snippet.ts +11 -13
  191. package/src/runjs-context/snippets/scene/block/api-fetch-render-list.snippet.ts +3 -3
  192. package/src/runjs-context/snippets/scene/block/chartjs-bar.snippet.ts +2 -2
  193. package/src/runjs-context/snippets/scene/block/echarts-init.snippet.ts +2 -2
  194. package/src/runjs-context/snippets/scene/block/render-iframe.snippet.ts +2 -2
  195. package/src/runjs-context/snippets/scene/block/render-react.snippet.ts +1 -1
  196. package/src/runjs-context/snippets/scene/block/render-statistics.snippet.ts +1 -1
  197. package/src/runjs-context/snippets/scene/block/render-timeline.snippet.ts +1 -1
  198. package/src/runjs-context/snippets/scene/block/resource-example.snippet.ts +6 -11
  199. package/src/runjs-context/snippets/scene/block/three-users-orbit.snippet.ts +6 -6
  200. package/src/runjs-context/snippets/scene/block/vue-component.snippet.ts +3 -4
  201. package/src/runjs-context/snippets/scene/detail/color-by-value.snippet.ts +1 -1
  202. package/src/runjs-context/snippets/scene/detail/copy-to-clipboard.snippet.ts +20 -3
  203. package/src/runjs-context/snippets/scene/detail/format-number.snippet.ts +1 -1
  204. package/src/runjs-context/snippets/scene/detail/innerHTML-value.snippet.ts +1 -1
  205. package/src/runjs-context/snippets/scene/detail/percentage-bar.snippet.ts +3 -3
  206. package/src/runjs-context/snippets/scene/detail/relative-time.snippet.ts +3 -3
  207. package/src/runjs-context/snippets/scene/detail/status-tag.snippet.ts +2 -2
  208. package/src/runjs-context/snippets/scene/form/cascade-select.snippet.ts +1 -1
  209. package/src/runjs-context/snippets/scene/form/render-basic.snippet.ts +3 -8
  210. package/src/runjs-context/snippets/scene/table/cell-open-dialog.snippet.ts +6 -3
  211. package/src/runjs-context/snippets/scene/table/concat-fields.snippet.ts +3 -1
  212. package/src/runjsLibs.ts +622 -0
  213. package/src/scheduler/ModelOperationScheduler.ts +27 -21
  214. package/src/types.ts +38 -1
  215. package/src/utils/__tests__/dateVariable.test.ts +101 -0
  216. package/src/utils/__tests__/params-resolvers.test.ts +40 -0
  217. package/src/utils/__tests__/runjsRequireAsyncAutoWhitelist.test.ts +38 -0
  218. package/src/utils/__tests__/runjsTemplateCompat.test.ts +159 -0
  219. package/src/utils/__tests__/runjsValue.test.ts +44 -0
  220. package/src/utils/__tests__/safeGlobals.test.ts +57 -2
  221. package/src/utils/__tests__/utils.test.ts +95 -0
  222. package/src/utils/associationObjectVariable.ts +2 -2
  223. package/src/utils/createCollectionContextMeta.ts +1 -0
  224. package/src/utils/createEphemeralContext.ts +5 -4
  225. package/src/utils/dateVariable.ts +397 -0
  226. package/src/utils/exceptions.ts +11 -0
  227. package/src/utils/index.ts +37 -3
  228. package/src/utils/params-resolvers.ts +23 -9
  229. package/src/utils/resolveModuleUrl.ts +91 -0
  230. package/src/utils/resolveRunJSObjectValues.ts +46 -0
  231. package/src/utils/runjsModuleLoader.ts +553 -0
  232. package/src/utils/runjsTemplateCompat.ts +828 -0
  233. package/src/utils/runjsValue.ts +287 -0
  234. package/src/utils/safeGlobals.ts +188 -17
  235. package/src/utils/schema-utils.ts +79 -0
  236. package/src/views/__tests__/FlowView.usePage.test.tsx +54 -1
  237. package/src/views/__tests__/useDialog.closeDestroy.test.tsx +35 -8
  238. package/src/views/__tests__/viewEvents.resolveOpenerEngine.test.ts +28 -0
  239. package/src/views/createViewMeta.ts +22 -75
  240. package/src/views/index.tsx +1 -2
  241. package/src/views/useDialog.tsx +8 -1
  242. package/src/views/useDrawer.tsx +8 -1
  243. package/src/views/usePage.tsx +51 -5
  244. package/src/views/usePopover.tsx +4 -1
  245. package/src/views/viewEvents.ts +55 -0
@@ -0,0 +1,532 @@
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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
17
+ var __export = (target, all) => {
18
+ for (var name in all)
19
+ __defProp(target, name, { get: all[name], enumerable: true });
20
+ };
21
+ var __copyProps = (to, from, except, desc) => {
22
+ if (from && typeof from === "object" || typeof from === "function") {
23
+ for (let key of __getOwnPropNames(from))
24
+ if (!__hasOwnProp.call(to, key) && key !== except)
25
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
26
+ }
27
+ return to;
28
+ };
29
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
30
+ // If the importer is in node compatibility mode or this is not an ESM
31
+ // file that has been converted to a CommonJS file using a Babel-
32
+ // compatible transform (i.e. "__esModule" has not been set), then set
33
+ // "default" to the CommonJS "module.exports" for node compatibility.
34
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
+ mod
36
+ ));
37
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
+ var runjsLibs_exports = {};
39
+ __export(runjsLibs_exports, {
40
+ externalReactRender: () => externalReactRender,
41
+ registerRunJSLib: () => registerRunJSLib,
42
+ setRunJSLibOverride: () => setRunJSLibOverride,
43
+ setupRunJSLibs: () => setupRunJSLibs
44
+ });
45
+ module.exports = __toCommonJS(runjsLibs_exports);
46
+ var antdIcons = __toESM(require("@ant-design/icons"));
47
+ var import_reactive = require("@formily/reactive");
48
+ const __runjsLibRegistry = /* @__PURE__ */ new Map();
49
+ const __runjsLibResolvedCache = /* @__PURE__ */ new Map();
50
+ const __runjsLibPendingCache = /* @__PURE__ */ new Map();
51
+ const __runjsLibPendingByCtx = /* @__PURE__ */ new WeakMap();
52
+ const __runjsErrorBoundaryByReact = /* @__PURE__ */ new WeakMap();
53
+ function __runjsGetPendingMapForCtx(ctx) {
54
+ let m = __runjsLibPendingByCtx.get(ctx);
55
+ if (!m) {
56
+ m = /* @__PURE__ */ new Map();
57
+ __runjsLibPendingByCtx.set(ctx, m);
58
+ }
59
+ return m;
60
+ }
61
+ __name(__runjsGetPendingMapForCtx, "__runjsGetPendingMapForCtx");
62
+ function registerRunJSLib(name, loader, options) {
63
+ if (typeof name !== "string" || !name) return;
64
+ if (typeof loader !== "function") return;
65
+ __runjsLibRegistry.set(name, { loader, cache: (options == null ? void 0 : options.cache) || "global" });
66
+ __runjsLibResolvedCache.delete(name);
67
+ __runjsLibPendingCache.delete(name);
68
+ }
69
+ __name(registerRunJSLib, "registerRunJSLib");
70
+ function __runjsIsObject(val) {
71
+ return !!val && typeof val === "object";
72
+ }
73
+ __name(__runjsIsObject, "__runjsIsObject");
74
+ function __runjsHasOwn(obj, key) {
75
+ return __runjsIsObject(obj) && Object.prototype.hasOwnProperty.call(obj, key);
76
+ }
77
+ __name(__runjsHasOwn, "__runjsHasOwn");
78
+ function __runjsIsPromiseLike(val) {
79
+ if (!__runjsIsObject(val)) return false;
80
+ const then = val.then;
81
+ return typeof then === "function";
82
+ }
83
+ __name(__runjsIsPromiseLike, "__runjsIsPromiseLike");
84
+ function __runjsGetCtxValue(ctx, key) {
85
+ return ctx[key];
86
+ }
87
+ __name(__runjsGetCtxValue, "__runjsGetCtxValue");
88
+ async function __runjsEnsureLib(ctx, name) {
89
+ const libs = ctx == null ? void 0 : ctx.libs;
90
+ if (__runjsHasOwn(libs, name)) {
91
+ const existing = libs[name];
92
+ if (typeof existing !== "undefined") return existing;
93
+ }
94
+ const entry = __runjsLibRegistry.get(name);
95
+ if (!entry) return __runjsIsObject(libs) ? libs[name] : void 0;
96
+ const setLib = /* @__PURE__ */ __name((v2) => {
97
+ if (__runjsIsObject(libs)) libs[name] = v2;
98
+ }, "setLib");
99
+ if (entry.cache === "context") {
100
+ const pendingMap = __runjsGetPendingMapForCtx(ctx);
101
+ const existingPending2 = pendingMap.get(name);
102
+ if (existingPending2) {
103
+ const v3 = await existingPending2;
104
+ setLib(v3);
105
+ return v3;
106
+ }
107
+ const task2 = Promise.resolve().then(() => entry.loader(ctx)).then(
108
+ (v3) => {
109
+ pendingMap.delete(name);
110
+ return v3;
111
+ },
112
+ (err) => {
113
+ pendingMap.delete(name);
114
+ throw err;
115
+ }
116
+ );
117
+ pendingMap.set(name, task2);
118
+ const v2 = await task2;
119
+ setLib(v2);
120
+ return v2;
121
+ }
122
+ if (__runjsLibResolvedCache.has(name)) {
123
+ const v2 = __runjsLibResolvedCache.get(name);
124
+ setLib(v2);
125
+ return v2;
126
+ }
127
+ const existingPending = __runjsLibPendingCache.get(name);
128
+ if (existingPending) {
129
+ const v2 = await existingPending;
130
+ setLib(v2);
131
+ return v2;
132
+ }
133
+ const task = Promise.resolve().then(() => entry.loader(ctx)).then(
134
+ (v2) => {
135
+ __runjsLibResolvedCache.set(name, v2);
136
+ __runjsLibPendingCache.delete(name);
137
+ return v2;
138
+ },
139
+ (err) => {
140
+ __runjsLibPendingCache.delete(name);
141
+ throw err;
142
+ }
143
+ );
144
+ __runjsLibPendingCache.set(name, task);
145
+ const v = await task;
146
+ setLib(v);
147
+ return v;
148
+ }
149
+ __name(__runjsEnsureLib, "__runjsEnsureLib");
150
+ function setupRunJSLibAPIs(ctx) {
151
+ if (!ctx || typeof ctx !== "object") return;
152
+ if (typeof ctx.defineMethod !== "function") return;
153
+ ctx.defineMethod("__ensureLib", async function(name) {
154
+ if (typeof name !== "string" || !name) return void 0;
155
+ return await __runjsEnsureLib(this, name);
156
+ });
157
+ ctx.defineMethod("__ensureLibs", async function(names) {
158
+ if (!Array.isArray(names)) return;
159
+ for (const n of names) {
160
+ if (typeof n !== "string" || !n) continue;
161
+ await __runjsEnsureLib(this, n);
162
+ }
163
+ });
164
+ }
165
+ __name(setupRunJSLibAPIs, "setupRunJSLibAPIs");
166
+ const DEFAULT_RUNJS_LIBS = [
167
+ { name: "React", cache: "context", loader: /* @__PURE__ */ __name((ctx) => __runjsGetCtxValue(ctx, "React"), "loader") },
168
+ { name: "ReactDOM", cache: "context", loader: /* @__PURE__ */ __name((ctx) => __runjsGetCtxValue(ctx, "ReactDOM"), "loader") },
169
+ { name: "antd", cache: "context", loader: /* @__PURE__ */ __name((ctx) => __runjsGetCtxValue(ctx, "antd"), "loader") },
170
+ { name: "dayjs", cache: "context", loader: /* @__PURE__ */ __name((ctx) => __runjsGetCtxValue(ctx, "dayjs"), "loader") },
171
+ { name: "antdIcons", cache: "global", loader: /* @__PURE__ */ __name(() => antdIcons, "loader") },
172
+ { name: "lodash", cache: "global", loader: /* @__PURE__ */ __name(() => import("lodash").then((m) => m.default || m), "loader") },
173
+ { name: "formula", cache: "global", loader: /* @__PURE__ */ __name(() => import("@formulajs/formulajs").then((m) => m.default || m), "loader") },
174
+ { name: "math", cache: "global", loader: /* @__PURE__ */ __name(() => import("mathjs").then((m) => m), "loader") }
175
+ ];
176
+ let __defaultRunJSLibsRegistered = false;
177
+ function ensureDefaultRunJSLibsRegistered() {
178
+ if (__defaultRunJSLibsRegistered) return;
179
+ __defaultRunJSLibsRegistered = true;
180
+ for (const { name, loader, cache } of DEFAULT_RUNJS_LIBS) {
181
+ if (__runjsLibRegistry.has(name)) continue;
182
+ registerRunJSLib(name, loader, { cache });
183
+ }
184
+ }
185
+ __name(ensureDefaultRunJSLibsRegistered, "ensureDefaultRunJSLibsRegistered");
186
+ function resolveRegisteredLibSync(ctx, name) {
187
+ const entry = __runjsLibRegistry.get(name);
188
+ if (!entry) return void 0;
189
+ if (entry.cache === "global" && __runjsLibResolvedCache.has(name)) {
190
+ return __runjsLibResolvedCache.get(name);
191
+ }
192
+ const v = entry.loader(ctx);
193
+ if (__runjsIsPromiseLike(v)) return void 0;
194
+ if (entry.cache === "global") __runjsLibResolvedCache.set(name, v);
195
+ return v;
196
+ }
197
+ __name(resolveRegisteredLibSync, "resolveRegisteredLibSync");
198
+ function setupRunJSLibs(ctx) {
199
+ if (!ctx || typeof ctx !== "object") return;
200
+ if (typeof ctx.defineProperty !== "function") return;
201
+ ensureDefaultRunJSLibsRegistered();
202
+ const libs = {};
203
+ for (const { name } of DEFAULT_RUNJS_LIBS) {
204
+ Object.defineProperty(libs, name, {
205
+ configurable: true,
206
+ enumerable: true,
207
+ get() {
208
+ const v = resolveRegisteredLibSync(ctx, name);
209
+ Object.defineProperty(libs, name, {
210
+ configurable: true,
211
+ enumerable: true,
212
+ writable: true,
213
+ value: v
214
+ });
215
+ return v;
216
+ }
217
+ });
218
+ }
219
+ ctx.defineProperty("libs", { value: libs });
220
+ setupRunJSLibAPIs(ctx);
221
+ }
222
+ __name(setupRunJSLibs, "setupRunJSLibs");
223
+ function setRunJSLibOverride(ctx, name, value, options) {
224
+ const topLevelKey = (options == null ? void 0 : options.topLevelKey) === false ? null : (options == null ? void 0 : options.topLevelKey) || name;
225
+ if (topLevelKey) {
226
+ ctx.defineProperty(topLevelKey, { value });
227
+ }
228
+ const libs = ctx.libs;
229
+ Object.defineProperty(libs, name, {
230
+ configurable: true,
231
+ enumerable: true,
232
+ writable: true,
233
+ value
234
+ });
235
+ }
236
+ __name(setRunJSLibOverride, "setRunJSLibOverride");
237
+ function buildMixedReactHint(options) {
238
+ var _a;
239
+ const { ctx, internalReact, internalAntd } = options;
240
+ const lines = [];
241
+ const externalReact = ctx.React && ctx.React !== internalReact;
242
+ const internalReactDOM = !!((_a = ctx.ReactDOM) == null ? void 0 : _a.__nbRunjsInternalShim);
243
+ const usingInternalAntd = ctx.antd === internalAntd;
244
+ const externalAntd = ctx.antd && ctx.antd !== internalAntd;
245
+ if (externalReact && internalReactDOM) {
246
+ const reactInfo = ctx.__runjsExternalReact;
247
+ const v = reactInfo == null ? void 0 : reactInfo.version;
248
+ const domHint = v ? `react-dom@${v}/client` : "react-dom/client";
249
+ lines.push(
250
+ `- You have imported external React, but you're still using the built-in ReactDOM Root; please also run: await ctx.importAsync("${domHint}")`
251
+ );
252
+ }
253
+ if (externalAntd && !externalReact) {
254
+ lines.push(
255
+ `- You have imported external antd, but you're still using the built-in React; please run: await ctx.importAsync("react@18.x")`
256
+ );
257
+ lines.push(`- And make sure ReactDOM matches: await ctx.importAsync("react-dom@18.x/client")`);
258
+ }
259
+ if (externalReact && usingInternalAntd) {
260
+ lines.push(
261
+ `- You have imported external React, but you're still using the built-in antd; please switch to: await ctx.importAsync("antd@5.x")`
262
+ );
263
+ lines.push(`- If you use icon components, also import: await ctx.importAsync("@ant-design/icons@5.x")`);
264
+ }
265
+ return lines.length ? `
266
+
267
+ [RunJS Hint]
268
+ ${lines.join("\n")}` : "";
269
+ }
270
+ __name(buildMixedReactHint, "buildMixedReactHint");
271
+ function isReactHooksDispatcherNullError(err) {
272
+ const msg = String((err == null ? void 0 : err.message) || "");
273
+ if (!msg) return false;
274
+ if (!/Cannot read (?:properties|property) of (?:null|undefined) \(reading 'use[A-Za-z]+'\)/.test(msg)) return false;
275
+ const stack = String((err == null ? void 0 : err.stack) || "");
276
+ if (!stack) return false;
277
+ return /(?:^|\W)react@[^/\s)]+/i.test(stack) || /react\.mjs/i.test(stack) || /react\.(?:development|production)/i.test(stack);
278
+ }
279
+ __name(isReactHooksDispatcherNullError, "isReactHooksDispatcherNullError");
280
+ function extractReactVersionFromStack(err) {
281
+ var _a;
282
+ const stack = String((err == null ? void 0 : err.stack) || "");
283
+ if (!stack) return void 0;
284
+ const m = stack.match(/(?:^|\W)react@([^/\s)]+)/i);
285
+ const v = (_a = m == null ? void 0 : m[1]) == null ? void 0 : _a.trim();
286
+ return v || void 0;
287
+ }
288
+ __name(extractReactVersionFromStack, "extractReactVersionFromStack");
289
+ function buildReactDispatcherNullHint(options) {
290
+ const { ctx, internalReact, internalAntd, err } = options;
291
+ if (!isReactHooksDispatcherNullError(err)) return "";
292
+ const v = extractReactVersionFromStack(err);
293
+ const lines = [];
294
+ lines.push(`- This looks like a React Hooks crash caused by multiple React instances (hook dispatcher is null).`);
295
+ if (v) {
296
+ lines.push(`- Your stack trace includes external React: react@${v}.`);
297
+ lines.push(
298
+ `- Fix: import the same React BEFORE you read ctx.libs.React / call hooks / import React-based libs: await ctx.importAsync("react@${v}")`
299
+ );
300
+ } else {
301
+ lines.push(
302
+ `- Fix: import external React BEFORE you read ctx.libs.React / call hooks / import React-based libs (use the same version shown in the stack trace).`
303
+ );
304
+ }
305
+ const usingInternalAntd = ctx.antd === internalAntd;
306
+ if (usingInternalAntd) {
307
+ lines.push(`- If you use antd components, also switch to external antd: await ctx.importAsync("antd@5.x")`);
308
+ lines.push(`- If you use icon components, also import: await ctx.importAsync("@ant-design/icons@5.x")`);
309
+ }
310
+ return lines.length ? `
311
+
312
+ [RunJS Hint]
313
+ ${lines.join("\n")}` : "";
314
+ }
315
+ __name(buildReactDispatcherNullHint, "buildReactDispatcherNullHint");
316
+ function wrapErrorWithHint(err, messageWithHint) {
317
+ const e = new Error(messageWithHint);
318
+ e.cause = err;
319
+ try {
320
+ const name = typeof (err == null ? void 0 : err.name) === "string" ? err.name : "";
321
+ if (name) e.name = name;
322
+ } catch (_) {
323
+ }
324
+ try {
325
+ const stack = typeof (err == null ? void 0 : err.stack) === "string" ? err.stack : "";
326
+ if (stack) {
327
+ const lines = String(stack).split("\n");
328
+ if (lines.length) {
329
+ lines[0] = `${e.name}: ${messageWithHint}`;
330
+ e.stack = lines.join("\n");
331
+ }
332
+ }
333
+ } catch (_) {
334
+ }
335
+ return e;
336
+ }
337
+ __name(wrapErrorWithHint, "wrapErrorWithHint");
338
+ function getRunjsErrorBoundary(ReactLike) {
339
+ if (!ReactLike) return null;
340
+ const cached = __runjsErrorBoundaryByReact.get(ReactLike);
341
+ if (cached) return cached;
342
+ if (typeof ReactLike.createElement !== "function") return null;
343
+ const Base = ReactLike.Component;
344
+ if (typeof Base !== "function") return null;
345
+ const _RunjsErrorBoundary = class _RunjsErrorBoundary extends Base {
346
+ static getDerivedStateFromError(error) {
347
+ return { error };
348
+ }
349
+ state = {};
350
+ componentDidCatch(error) {
351
+ var _a, _b, _c;
352
+ try {
353
+ const enhance = (_a = this.props) == null ? void 0 : _a.enhanceReactError;
354
+ const enhanced = typeof enhance === "function" ? enhance(error) : error;
355
+ const msg = String((enhanced == null ? void 0 : enhanced.message) || "");
356
+ if (msg && /\[RunJS Hint\]/.test(msg)) {
357
+ console.error(msg);
358
+ const logger = (_c = (_b = this.props) == null ? void 0 : _b.ctx) == null ? void 0 : _c.logger;
359
+ if (logger && typeof logger.error === "function") {
360
+ logger.error(msg);
361
+ }
362
+ }
363
+ } catch (_) {
364
+ }
365
+ }
366
+ componentDidUpdate(prevProps) {
367
+ var _a, _b;
368
+ if ((prevProps == null ? void 0 : prevProps.resetKey) !== ((_a = this.props) == null ? void 0 : _a.resetKey) && ((_b = this.state) == null ? void 0 : _b.error)) {
369
+ this.setState({ error: void 0 });
370
+ }
371
+ }
372
+ render() {
373
+ var _a, _b;
374
+ const error = (_a = this.state) == null ? void 0 : _a.error;
375
+ if (!error) return this.props.children;
376
+ let msg = "";
377
+ try {
378
+ const enhance = (_b = this.props) == null ? void 0 : _b.enhanceReactError;
379
+ const enhanced = typeof enhance === "function" ? enhance(error) : error;
380
+ msg = String((enhanced == null ? void 0 : enhanced.message) || enhanced || (error == null ? void 0 : error.message) || error || "");
381
+ } catch (_) {
382
+ msg = String((error == null ? void 0 : error.message) || error || "");
383
+ }
384
+ const containerStyle = {
385
+ boxSizing: "border-box",
386
+ padding: 12,
387
+ borderRadius: 6,
388
+ border: "1px solid #ffccc7",
389
+ background: "#fff2f0",
390
+ color: "#a8071a",
391
+ fontSize: 12,
392
+ lineHeight: 1.5,
393
+ maxWidth: "100%",
394
+ overflow: "auto"
395
+ };
396
+ const preStyle = {
397
+ margin: 0,
398
+ whiteSpace: "pre-wrap",
399
+ wordBreak: "break-word",
400
+ fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'
401
+ };
402
+ const titleStyle = { fontWeight: 600, marginBottom: 8 };
403
+ return ReactLike.createElement(
404
+ "div",
405
+ { style: containerStyle },
406
+ ReactLike.createElement("div", { style: titleStyle }, "RunJS render error"),
407
+ ReactLike.createElement("pre", { style: preStyle }, msg)
408
+ );
409
+ }
410
+ };
411
+ __name(_RunjsErrorBoundary, "RunjsErrorBoundary");
412
+ let RunjsErrorBoundary = _RunjsErrorBoundary;
413
+ __runjsErrorBoundaryByReact.set(ReactLike, RunjsErrorBoundary);
414
+ return RunjsErrorBoundary;
415
+ }
416
+ __name(getRunjsErrorBoundary, "getRunjsErrorBoundary");
417
+ function wrapVnodeWithRunjsErrorBoundary(options) {
418
+ const { ctx, vnode, enhanceReactError, resetKey } = options;
419
+ const ReactLike = ctx == null ? void 0 : ctx.React;
420
+ const Boundary = getRunjsErrorBoundary(ReactLike);
421
+ if (!Boundary) return vnode;
422
+ return ReactLike.createElement(Boundary, { ctx, enhanceReactError, resetKey }, vnode);
423
+ }
424
+ __name(wrapVnodeWithRunjsErrorBoundary, "wrapVnodeWithRunjsErrorBoundary");
425
+ function tryRenderWithExternalAntdTheme(options) {
426
+ var _a;
427
+ const { ctx, entry, containerEl, rootMap, unmountContainerRoot, enhanceReactError, internalReact, internalAntd } = options;
428
+ const canUseExternalAntd = !((_a = ctx.ReactDOM) == null ? void 0 : _a.__nbRunjsInternalShim) && ctx.React && ctx.React !== internalReact && ctx.antd && ctx.antd !== internalAntd && typeof ctx.antd.ConfigProvider !== "undefined";
429
+ if (!canUseExternalAntd) {
430
+ if (entry.disposeTheme) {
431
+ try {
432
+ entry.disposeTheme();
433
+ } catch (_) {
434
+ }
435
+ entry.disposeTheme = void 0;
436
+ }
437
+ return false;
438
+ }
439
+ const renderWithExternalAntdTheme = /* @__PURE__ */ __name(() => {
440
+ var _a2, _b, _c, _d, _e, _f, _g;
441
+ const themeToken = (_b = (_a2 = ctx == null ? void 0 : ctx.engine) == null ? void 0 : _a2.context) == null ? void 0 : _b.themeToken;
442
+ const appConfig = (_d = (_c = ctx == null ? void 0 : ctx.engine) == null ? void 0 : _c.context) == null ? void 0 : _d.antdConfig;
443
+ const locale = ((_g = (_f = (_e = ctx == null ? void 0 : ctx.engine) == null ? void 0 : _e.context) == null ? void 0 : _f.locales) == null ? void 0 : _g.antd) || (appConfig == null ? void 0 : appConfig.locale);
444
+ const ConfigProvider = ctx.antd.ConfigProvider;
445
+ const App = ctx.antd.App;
446
+ const configProps = {
447
+ popupMatchSelectWidth: false,
448
+ locale: locale || {}
449
+ };
450
+ if (appConfig && typeof appConfig === "object") {
451
+ if (typeof appConfig.direction !== "undefined") configProps.direction = appConfig.direction;
452
+ if (typeof appConfig.prefixCls === "string") configProps.prefixCls = appConfig.prefixCls;
453
+ if (typeof appConfig.iconPrefixCls === "string") configProps.iconPrefixCls = appConfig.iconPrefixCls;
454
+ if (typeof appConfig.getPopupContainer === "function")
455
+ configProps.getPopupContainer = appConfig.getPopupContainer;
456
+ if (appConfig.theme && typeof appConfig.theme === "object") configProps.theme = appConfig.theme;
457
+ }
458
+ const child = entry.lastVnode;
459
+ const wrapped = App ? ctx.React.createElement(ConfigProvider, configProps, ctx.React.createElement(App, null, child)) : ctx.React.createElement(ConfigProvider, configProps, child);
460
+ entry.root.render(wrapped);
461
+ }, "renderWithExternalAntdTheme");
462
+ if (!entry.disposeTheme) {
463
+ entry.disposeTheme = (0, import_reactive.autorun)(() => {
464
+ try {
465
+ if (containerEl && containerEl.nodeType === 1 && typeof containerEl.isConnected === "boolean" && !containerEl.isConnected && entry.wasConnected) {
466
+ queueMicrotask(() => {
467
+ const cur = rootMap.get(containerEl);
468
+ if (cur === entry) unmountContainerRoot();
469
+ });
470
+ return;
471
+ }
472
+ if (containerEl && containerEl.nodeType === 1 && typeof containerEl.isConnected === "boolean" && containerEl.isConnected) {
473
+ entry.wasConnected = true;
474
+ }
475
+ renderWithExternalAntdTheme();
476
+ } catch (e) {
477
+ throw enhanceReactError(e);
478
+ }
479
+ });
480
+ } else {
481
+ renderWithExternalAntdTheme();
482
+ }
483
+ return true;
484
+ }
485
+ __name(tryRenderWithExternalAntdTheme, "tryRenderWithExternalAntdTheme");
486
+ function externalReactRender(options) {
487
+ const { ctx, entry, vnode, containerEl, rootMap, unmountContainerRoot, internalReact, internalAntd } = options;
488
+ const enhanceReactError = /* @__PURE__ */ __name((err) => {
489
+ const msg = String((err == null ? void 0 : err.message) || err || "");
490
+ if (!msg) return err;
491
+ if (/\[RunJS Hint\]/.test(msg)) return err;
492
+ const invalidHookCall = /invalid hook call/i.test(msg);
493
+ const dispatcherNull = isReactHooksDispatcherNullError(err);
494
+ if (!invalidHookCall && !dispatcherNull) return err;
495
+ const hint = buildMixedReactHint({ ctx, internalReact, internalAntd }) || buildReactDispatcherNullHint({ ctx, internalReact, internalAntd, err });
496
+ if (!hint) return err;
497
+ return wrapErrorWithHint(err, `${msg}${hint}`);
498
+ }, "enhanceReactError");
499
+ try {
500
+ entry.__nbRunjsRenderSeq = (entry.__nbRunjsRenderSeq || 0) + 1;
501
+ entry.lastVnode = wrapVnodeWithRunjsErrorBoundary({
502
+ ctx,
503
+ vnode,
504
+ enhanceReactError,
505
+ resetKey: entry.__nbRunjsRenderSeq
506
+ });
507
+ const renderedWithExternalAntdTheme = tryRenderWithExternalAntdTheme({
508
+ ctx,
509
+ entry,
510
+ containerEl,
511
+ rootMap,
512
+ unmountContainerRoot,
513
+ enhanceReactError,
514
+ internalReact,
515
+ internalAntd
516
+ });
517
+ if (!renderedWithExternalAntdTheme) {
518
+ entry.root.render(entry.lastVnode);
519
+ }
520
+ return entry.root;
521
+ } catch (e) {
522
+ throw enhanceReactError(e);
523
+ }
524
+ }
525
+ __name(externalReactRender, "externalReactRender");
526
+ // Annotate the CommonJS export names for ESM import in node:
527
+ 0 && (module.exports = {
528
+ externalReactRender,
529
+ registerRunJSLib,
530
+ setRunJSLibOverride,
531
+ setupRunJSLibs
532
+ });
@@ -22,6 +22,8 @@ export interface LifecycleEvent {
22
22
  error?: any;
23
23
  inputArgs?: Record<string, any>;
24
24
  result?: any;
25
+ flowKey?: string;
26
+ stepKey?: string;
25
27
  }
26
28
  export declare class ModelOperationScheduler {
27
29
  private engine;
@@ -32,6 +32,7 @@ __export(ModelOperationScheduler_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(ModelOperationScheduler_exports);
34
34
  var import_secure = require("uid/secure");
35
+ var import_exceptions = require("../utils/exceptions");
35
36
  const _ModelOperationScheduler = class _ModelOperationScheduler {
36
37
  constructor(engine) {
37
38
  this.engine = engine;
@@ -125,32 +126,32 @@ const _ModelOperationScheduler = class _ModelOperationScheduler {
125
126
  bindEngineLifecycle() {
126
127
  const emitter = this.engine.emitter;
127
128
  if (!emitter || typeof emitter.on !== "function") return;
128
- const onCreated = /* @__PURE__ */ __name((e) => {
129
- this.processLifecycleEvent(e.uid, { ...e, type: "created" });
129
+ const onCreated = /* @__PURE__ */ __name(async (e) => {
130
+ await this.processLifecycleEvent(e.uid, { ...e, type: "created" });
130
131
  }, "onCreated");
131
132
  emitter.on("model:created", onCreated);
132
133
  this.unbindHandlers.push(() => emitter.off("model:created", onCreated));
133
- const onMounted = /* @__PURE__ */ __name((e) => {
134
- this.processLifecycleEvent(e.uid, { ...e, type: "mounted" });
134
+ const onMounted = /* @__PURE__ */ __name(async (e) => {
135
+ await this.processLifecycleEvent(e.uid, { ...e, type: "mounted" });
135
136
  }, "onMounted");
136
137
  emitter.on("model:mounted", onMounted);
137
138
  this.unbindHandlers.push(() => emitter.off("model:mounted", onMounted));
138
- const onGenericBeforeStart = /* @__PURE__ */ __name((e) => {
139
- this.processLifecycleEvent(e.uid, { ...e, type: "event:beforeRender:start" });
139
+ const onGenericBeforeStart = /* @__PURE__ */ __name(async (e) => {
140
+ await this.processLifecycleEvent(e.uid, { ...e, type: "event:beforeRender:start" });
140
141
  }, "onGenericBeforeStart");
141
142
  emitter.on("model:event:beforeRender:start", onGenericBeforeStart);
142
143
  this.unbindHandlers.push(() => emitter.off("model:event:beforeRender:start", onGenericBeforeStart));
143
- const onGenericBeforeEnd = /* @__PURE__ */ __name((e) => {
144
- this.processLifecycleEvent(e.uid, { ...e, type: "event:beforeRender:end" });
144
+ const onGenericBeforeEnd = /* @__PURE__ */ __name(async (e) => {
145
+ await this.processLifecycleEvent(e.uid, { ...e, type: "event:beforeRender:end" });
145
146
  }, "onGenericBeforeEnd");
146
147
  emitter.on("model:event:beforeRender:end", onGenericBeforeEnd);
147
148
  this.unbindHandlers.push(() => emitter.off("model:event:beforeRender:end", onGenericBeforeEnd));
148
- const onUnmounted = /* @__PURE__ */ __name((e) => {
149
- this.processLifecycleEvent(e.uid, { ...e, type: "unmounted" });
149
+ const onUnmounted = /* @__PURE__ */ __name(async (e) => {
150
+ await this.processLifecycleEvent(e.uid, { ...e, type: "unmounted" });
150
151
  }, "onUnmounted");
151
152
  emitter.on("model:unmounted", onUnmounted);
152
153
  this.unbindHandlers.push(() => emitter.off("model:unmounted", onUnmounted));
153
- const onDestroyed = /* @__PURE__ */ __name((e) => {
154
+ const onDestroyed = /* @__PURE__ */ __name(async (e) => {
154
155
  const targetBucket = this.itemsByTargetUid.get(e.uid);
155
156
  const event = { ...e, type: "destroyed" };
156
157
  if (targetBucket && targetBucket.size) {
@@ -159,7 +160,7 @@ const _ModelOperationScheduler = class _ModelOperationScheduler {
159
160
  const it = this.itemsById.get(id);
160
161
  if (!it) continue;
161
162
  if (this.shouldTrigger(it.options.when, event)) {
162
- void this.tryExecuteOnce(id, event);
163
+ await this.tryExecuteOnce(id, event);
163
164
  } else {
164
165
  this.internalCancel(id);
165
166
  }
@@ -177,14 +178,14 @@ const _ModelOperationScheduler = class _ModelOperationScheduler {
177
178
  if (this.subscribedEventNames.has(name)) return;
178
179
  this.subscribedEventNames.add(name);
179
180
  const emitter = this.engine.emitter;
180
- const onStart = /* @__PURE__ */ __name((e) => {
181
- this.processLifecycleEvent(e.uid, { ...e, type: `event:${name}:start` });
181
+ const onStart = /* @__PURE__ */ __name(async (e) => {
182
+ await this.processLifecycleEvent(e.uid, { ...e, type: `event:${name}:start` });
182
183
  }, "onStart");
183
- const onEnd = /* @__PURE__ */ __name((e) => {
184
- this.processLifecycleEvent(e.uid, { ...e, type: `event:${name}:end` });
184
+ const onEnd = /* @__PURE__ */ __name(async (e) => {
185
+ await this.processLifecycleEvent(e.uid, { ...e, type: `event:${name}:end` });
185
186
  }, "onEnd");
186
- const onError = /* @__PURE__ */ __name((e) => {
187
- this.processLifecycleEvent(e.uid, { ...e, type: `event:${name}:error` });
187
+ const onError = /* @__PURE__ */ __name(async (e) => {
188
+ await this.processLifecycleEvent(e.uid, { ...e, type: `event:${name}:error` });
188
189
  }, "onError");
189
190
  emitter.on(`model:event:${name}:start`, onStart);
190
191
  emitter.on(`model:event:${name}:end`, onEnd);
@@ -195,11 +196,11 @@ const _ModelOperationScheduler = class _ModelOperationScheduler {
195
196
  }
196
197
  parseEventWhen(when) {
197
198
  if (!when || typeof when !== "string") return null;
198
- const m = /^event:([^:]+):(start|end|error)$/.exec(when);
199
+ const m = /^event:(.+):(start|end|error)$/.exec(when);
199
200
  if (!m) return null;
200
201
  return { name: m[1], phase: m[2] };
201
202
  }
202
- processLifecycleEvent(targetUid, event) {
203
+ async processLifecycleEvent(targetUid, event) {
203
204
  const targetBucket = this.itemsByTargetUid.get(targetUid);
204
205
  if (!targetBucket || targetBucket.size === 0) return;
205
206
  const ids = Array.from(targetBucket.keys());
@@ -208,7 +209,7 @@ const _ModelOperationScheduler = class _ModelOperationScheduler {
208
209
  if (!item) continue;
209
210
  const should = this.shouldTrigger(item.options.when, event);
210
211
  if (!should) continue;
211
- void this.tryExecuteOnce(id, event);
212
+ await this.tryExecuteOnce(id, event);
212
213
  }
213
214
  }
214
215
  shouldTrigger(when, event) {
@@ -225,6 +226,9 @@ const _ModelOperationScheduler = class _ModelOperationScheduler {
225
226
  if (!model) return;
226
227
  await Promise.resolve(item.fn(model));
227
228
  } catch (err) {
229
+ if (err instanceof import_exceptions.FlowExitAllException) {
230
+ throw err;
231
+ }
228
232
  (_b = (_a = this.engine.logger) == null ? void 0 : _a.error) == null ? void 0 : _b.call(
229
233
  _a,
230
234
  { err, id, fromUid: item.fromUid, toUid: item.toUid, when: item.options.when },