@nocobase/flow-engine 2.0.0-beta.9 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -29,6 +29,7 @@ __export(utils_exports, {
29
29
  BLOCK_GROUP_CONFIGS: () => import_constants.BLOCK_GROUP_CONFIGS,
30
30
  BLOCK_TYPES: () => import_constants.BLOCK_TYPES,
31
31
  FLOW_ENGINE_NAMESPACE: () => import_constants.FLOW_ENGINE_NAMESPACE,
32
+ FlowCancelSaveException: () => import_exceptions.FlowCancelSaveException,
32
33
  FlowExitException: () => import_exceptions.FlowExitException,
33
34
  MENU_KEYS: () => import_constants.MENU_KEYS,
34
35
  buildRecordMeta: () => import_variablesParams.buildRecordMeta,
@@ -44,26 +45,45 @@ __export(utils_exports, {
44
45
  createRecordResolveOnServerWithLocal: () => import_variablesParams.createRecordResolveOnServerWithLocal,
45
46
  createSafeDocument: () => import_safeGlobals.createSafeDocument,
46
47
  createSafeNavigator: () => import_safeGlobals.createSafeNavigator,
48
+ createSafeRunJSGlobals: () => import_safeGlobals.createSafeRunJSGlobals,
47
49
  createSafeWindow: () => import_safeGlobals.createSafeWindow,
50
+ decodeBase64Url: () => import_dateVariable.decodeBase64Url,
48
51
  defineAction: () => import_flow_definitions.defineAction,
52
+ encodeBase64Url: () => import_dateVariable.encodeBase64Url,
49
53
  escapeT: () => import_translation.escapeT,
50
54
  extractPropertyPath: () => import_context.extractPropertyPath,
51
55
  extractUsedVariableNames: () => import_variablesParams.extractUsedVariableNames,
52
56
  extractUsedVariablePaths: () => import_variablesParams.extractUsedVariablePaths,
57
+ extractUsedVariablePathsFromRunJS: () => import_runjsValue.extractUsedVariablePathsFromRunJS,
53
58
  formatPathToVariable: () => import_context.formatPathToVariable,
54
59
  getAutoFlowError: () => import_autoFlowError.getAutoFlowError,
55
60
  getT: () => import_translation.getT,
56
61
  inferRecordRef: () => import_variablesParams.inferRecordRef,
57
62
  isBeforeRenderFlow: () => import_flows.isBeforeRenderFlow,
63
+ isCompleteCtxDatePath: () => import_dateVariable.isCompleteCtxDatePath,
64
+ isCssFile: () => import_resolveModuleUrl.isCssFile,
65
+ isCtxDateExpression: () => import_dateVariable.isCtxDateExpression,
66
+ isCtxDatePathPrefix: () => import_dateVariable.isCtxDatePathPrefix,
58
67
  isInheritedFrom: () => import_inheritance.isInheritedFrom,
68
+ isRunJSValue: () => import_runjsValue.isRunJSValue,
59
69
  isVariableExpression: () => import_context.isVariableExpression,
70
+ normalizeRunJSValue: () => import_runjsValue.normalizeRunJSValue,
71
+ parseCtxDateExpression: () => import_dateVariable.parseCtxDateExpression,
60
72
  parsePathnameToViewParams: () => import_parsePathnameToViewParams.parsePathnameToViewParams,
73
+ prepareRunJsCode: () => import_runjsTemplateCompat.prepareRunJsCode,
74
+ preprocessRunJsTemplates: () => import_runjsTemplateCompat.preprocessRunJsTemplates,
61
75
  pruneFilter: () => import_pruneFilter.pruneFilter,
62
76
  resolveCreateModelOptions: () => import_params_resolvers.resolveCreateModelOptions,
77
+ resolveCtxDatePath: () => import_dateVariable.resolveCtxDatePath,
63
78
  resolveDefaultParams: () => import_params_resolvers.resolveDefaultParams,
64
79
  resolveExpressions: () => import_params_resolvers.resolveExpressions,
80
+ resolveModuleUrl: () => import_resolveModuleUrl.resolveModuleUrl,
81
+ resolveRunJSObjectValues: () => import_resolveRunJSObjectValues.resolveRunJSObjectValues,
82
+ resolveStepDisabledInSettings: () => import_schema_utils.resolveStepDisabledInSettings,
65
83
  resolveStepUiSchema: () => import_schema_utils.resolveStepUiSchema,
66
84
  resolveUiMode: () => import_schema_utils.resolveUiMode,
85
+ runjsWithSafeGlobals: () => import_safeGlobals.runjsWithSafeGlobals,
86
+ serializeCtxDateValue: () => import_dateVariable.serializeCtxDateValue,
67
87
  setAutoFlowError: () => import_autoFlowError.setAutoFlowError,
68
88
  setupRuntimeContextSteps: () => import_setupRuntimeContextSteps.setupRuntimeContextSteps,
69
89
  shouldHideStepInSettings: () => import_schema_utils.shouldHideStepInSettings,
@@ -84,15 +104,21 @@ var import_variablesParams = require("./variablesParams");
84
104
  var import_context = require("./context");
85
105
  var import_autoFlowError = require("./autoFlowError");
86
106
  var import_parsePathnameToViewParams = require("./parsePathnameToViewParams");
107
+ var import_dateVariable = require("./dateVariable");
87
108
  var import_safeGlobals = require("./safeGlobals");
109
+ var import_runjsValue = require("./runjsValue");
110
+ var import_resolveRunJSObjectValues = require("./resolveRunJSObjectValues");
111
+ var import_runjsTemplateCompat = require("./runjsTemplateCompat");
88
112
  var import_createEphemeralContext = require("./createEphemeralContext");
89
113
  var import_pruneFilter = require("./pruneFilter");
90
114
  var import_flows = require("./flows");
115
+ var import_resolveModuleUrl = require("./resolveModuleUrl");
91
116
  // Annotate the CommonJS export names for ESM import in node:
92
117
  0 && (module.exports = {
93
118
  BLOCK_GROUP_CONFIGS,
94
119
  BLOCK_TYPES,
95
120
  FLOW_ENGINE_NAMESPACE,
121
+ FlowCancelSaveException,
96
122
  FlowExitException,
97
123
  MENU_KEYS,
98
124
  buildRecordMeta,
@@ -108,26 +134,45 @@ var import_flows = require("./flows");
108
134
  createRecordResolveOnServerWithLocal,
109
135
  createSafeDocument,
110
136
  createSafeNavigator,
137
+ createSafeRunJSGlobals,
111
138
  createSafeWindow,
139
+ decodeBase64Url,
112
140
  defineAction,
141
+ encodeBase64Url,
113
142
  escapeT,
114
143
  extractPropertyPath,
115
144
  extractUsedVariableNames,
116
145
  extractUsedVariablePaths,
146
+ extractUsedVariablePathsFromRunJS,
117
147
  formatPathToVariable,
118
148
  getAutoFlowError,
119
149
  getT,
120
150
  inferRecordRef,
121
151
  isBeforeRenderFlow,
152
+ isCompleteCtxDatePath,
153
+ isCssFile,
154
+ isCtxDateExpression,
155
+ isCtxDatePathPrefix,
122
156
  isInheritedFrom,
157
+ isRunJSValue,
123
158
  isVariableExpression,
159
+ normalizeRunJSValue,
160
+ parseCtxDateExpression,
124
161
  parsePathnameToViewParams,
162
+ prepareRunJsCode,
163
+ preprocessRunJsTemplates,
125
164
  pruneFilter,
126
165
  resolveCreateModelOptions,
166
+ resolveCtxDatePath,
127
167
  resolveDefaultParams,
128
168
  resolveExpressions,
169
+ resolveModuleUrl,
170
+ resolveRunJSObjectValues,
171
+ resolveStepDisabledInSettings,
129
172
  resolveStepUiSchema,
130
173
  resolveUiMode,
174
+ runjsWithSafeGlobals,
175
+ serializeCtxDateValue,
131
176
  setAutoFlowError,
132
177
  setupRuntimeContextSteps,
133
178
  shouldHideStepInSettings,
@@ -266,8 +266,9 @@ async function preprocessExpression(expression, ctx) {
266
266
  __name(preprocessExpression, "preprocessExpression");
267
267
  async function compileExpression(expression, ctx) {
268
268
  const matchDotOnly = /* @__PURE__ */ __name((expr) => {
269
- const m = expr.trim().match(/^ctx\.([a-zA-Z_$][a-zA-Z0-9_$]*(?:\.[a-zA-Z_$][a-zA-Z0-9_$]*)*)$/);
270
- return m ? m[1] : null;
269
+ const m = expr.trim().match(/^ctx\.([a-zA-Z_$][a-zA-Z0-9_$]*)(?:\.([a-zA-Z_$][a-zA-Z0-9_$-]*(?:\.[a-zA-Z_$][a-zA-Z0-9_$-]*)*))?$/);
270
+ if (!m) return null;
271
+ return m[2] ? `${m[1]}.${m[2]}` : m[1];
271
272
  }, "matchDotOnly");
272
273
  const resolveDotOnlyPath = /* @__PURE__ */ __name(async (dotPath) => {
273
274
  const segs = dotPath.split(".");
@@ -277,20 +278,26 @@ async function compileExpression(expression, ctx) {
277
278
  if (segs.length === 0) return base;
278
279
  return (0, import_shared.getValuesByPath)(base, segs.join("."));
279
280
  }, "resolveDotOnlyPath");
281
+ const resolveInnerExpression = /* @__PURE__ */ __name(async (innerExpr) => {
282
+ const dotPath = matchDotOnly(innerExpr);
283
+ if (dotPath) {
284
+ const resolved = await resolveDotOnlyPath(dotPath);
285
+ if (resolved === void 0 && dotPath.includes("-")) {
286
+ return await processExpression(innerExpr, ctx);
287
+ }
288
+ return resolved;
289
+ }
290
+ return await processExpression(innerExpr, ctx);
291
+ }, "resolveInnerExpression");
280
292
  const singleMatch = expression.match(/^\s*\{\{\s*([^{}]+?)\s*\}\}\s*$/);
281
293
  if (singleMatch) {
282
294
  const inner = singleMatch[1];
283
- const dotPath = matchDotOnly(inner);
284
- if (dotPath) {
285
- return await resolveDotOnlyPath(dotPath);
286
- }
287
- return await processExpression(inner, ctx);
295
+ return await resolveInnerExpression(inner);
288
296
  }
289
297
  const matches = [...expression.matchAll(/\{\{\s*(.+?)\s*\}\}/g)];
290
298
  let result = expression;
291
299
  for (const [fullMatch, innerExpr] of matches) {
292
- const dotPath = matchDotOnly(innerExpr);
293
- const value = dotPath ? await resolveDotOnlyPath(dotPath) : await processExpression(innerExpr, ctx);
300
+ const value = await resolveInnerExpression(innerExpr);
294
301
  if (value !== void 0) {
295
302
  const replacement = typeof value === "object" && value !== null ? JSON.stringify(value) : String(value);
296
303
  result = result.replace(fullMatch, replacement);
@@ -0,0 +1,58 @@
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
+ * 解析模块 URL,将相对路径转换为完整的 CDN URL
11
+ *
12
+ * @param url - 模块地址(支持相对路径或完整 URL)
13
+ * @param options - 可选配置
14
+ * @param options.addSuffix - 是否添加 ESM_CDN_SUFFIX 后缀(如 `+esm`),默认为 `true`
15
+ * @returns 解析后的完整 URL
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * // 相对路径会被拼接上 CDN 前缀和后缀(默认添加)
20
+ * // 如果使用 esm.sh(默认),不需要后缀
21
+ * resolveModuleUrl('vue@3.4.0')
22
+ * // => 'https://esm.sh/vue@3.4.0'
23
+ *
24
+ * // 如果使用 jsdelivr,需要配置 ESM_CDN_SUFFIX='/+esm'
25
+ * // resolveModuleUrl('vue@3.4.0') => 'https://cdn.jsdelivr.net/npm/vue@3.4.0/+esm'
26
+ *
27
+ * // 不添加后缀(适用于 UMD 库或 CSS 文件)
28
+ * resolveModuleUrl('vue@3.4.0', { addSuffix: false })
29
+ * // => 'https://esm.sh/vue@3.4.0' (即使配置了 suffix 也不会添加)
30
+ *
31
+ * // 原始 URL(适用于 UMD 库)
32
+ * resolveModuleUrl('lodash@4.17.21/lodash.js', { raw: true })
33
+ * // => 'https://esm.sh/lodash@4.17.21/lodash.js?raw' (即使配置了 suffix 也不会添加)
34
+ *
35
+ * // 完整 URL 保持不变
36
+ * resolveModuleUrl('https://cdn.jsdelivr.net/npm/vue@3.4.0')
37
+ * // => 'https://cdn.jsdelivr.net/npm/vue@3.4.0'
38
+ * ```
39
+ */
40
+ export declare function resolveModuleUrl(url: string, options?: {
41
+ addSuffix?: boolean;
42
+ raw?: boolean;
43
+ }): string;
44
+ /**
45
+ * 判断 URL 是否为 CSS 文件
46
+ *
47
+ * @param url - 文件 URL(支持带 query 和 hash,如 `example.css?v=123`)
48
+ * @returns 如果是 CSS 文件返回 `true`,否则返回 `false`
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * isCssFile('style.css') // => true
53
+ * isCssFile('style.css?v=123') // => true
54
+ * isCssFile('style.css#section') // => true
55
+ * isCssFile('script.js') // => false
56
+ * ```
57
+ */
58
+ export declare function isCssFile(url: string): boolean;
@@ -0,0 +1,65 @@
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 resolveModuleUrl_exports = {};
29
+ __export(resolveModuleUrl_exports, {
30
+ isCssFile: () => isCssFile,
31
+ resolveModuleUrl: () => resolveModuleUrl
32
+ });
33
+ module.exports = __toCommonJS(resolveModuleUrl_exports);
34
+ function resolveModuleUrl(url, options) {
35
+ if (!url || typeof url !== "string") {
36
+ throw new Error("invalid url");
37
+ }
38
+ const u = url.trim();
39
+ if (u.startsWith("http://") || u.startsWith("https://")) {
40
+ return u;
41
+ }
42
+ const ESM_CDN_BASE_URL = window["__esm_cdn_base_url__"] || "https://esm.sh";
43
+ const ESM_CDN_SUFFIX = (options == null ? void 0 : options.addSuffix) ? window["__esm_cdn_suffix__"] || "" : "";
44
+ const base = ESM_CDN_BASE_URL.replace(/\/$/, "");
45
+ const path = u.replace(/^\//, "");
46
+ if (options == null ? void 0 : options.raw) {
47
+ const sep = path.includes("?") ? "&" : "?";
48
+ return `${base}/${path}${sep}raw`;
49
+ }
50
+ return `${base}/${path}${ESM_CDN_SUFFIX}`;
51
+ }
52
+ __name(resolveModuleUrl, "resolveModuleUrl");
53
+ function isCssFile(url) {
54
+ if (!url || typeof url !== "string") {
55
+ return false;
56
+ }
57
+ const pathPart = url.split("?")[0].split("#")[0];
58
+ return pathPart.endsWith(".css");
59
+ }
60
+ __name(isCssFile, "isCssFile");
61
+ // Annotate the CommonJS export names for ESM import in node:
62
+ 0 && (module.exports = {
63
+ isCssFile,
64
+ resolveModuleUrl
65
+ });
@@ -0,0 +1,16 @@
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
+ * Resolve an object's values, executing any RunJSValue entries via ctx.runjs.
11
+ *
12
+ * - Skips `undefined` values
13
+ * - Skips empty RunJS code (treated as not configured)
14
+ * - Throws when a RunJS execution fails
15
+ */
16
+ export declare function resolveRunJSObjectValues(ctx: unknown, raw: unknown): Promise<Record<string, any>>;
@@ -0,0 +1,61 @@
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 resolveRunJSObjectValues_exports = {};
29
+ __export(resolveRunJSObjectValues_exports, {
30
+ resolveRunJSObjectValues: () => resolveRunJSObjectValues
31
+ });
32
+ module.exports = __toCommonJS(resolveRunJSObjectValues_exports);
33
+ var import_runjsValue = require("./runjsValue");
34
+ var import_safeGlobals = require("./safeGlobals");
35
+ async function resolveRunJSObjectValues(ctx, raw) {
36
+ const out = {};
37
+ if (!raw || typeof raw !== "object") return out;
38
+ if (Array.isArray(raw)) return out;
39
+ for (const [key, value] of Object.entries(raw)) {
40
+ if (typeof value === "undefined") continue;
41
+ if ((0, import_runjsValue.isRunJSValue)(value)) {
42
+ const { code, version } = (0, import_runjsValue.normalizeRunJSValue)(value);
43
+ if (!code.trim()) continue;
44
+ const ret = await (0, import_safeGlobals.runjsWithSafeGlobals)(ctx, code, { version });
45
+ if (!(ret == null ? void 0 : ret.success)) {
46
+ throw new Error(`RunJS execution failed for "${key}"`);
47
+ }
48
+ if (typeof ret.value !== "undefined") {
49
+ out[key] = ret.value;
50
+ }
51
+ continue;
52
+ }
53
+ out[key] = value;
54
+ }
55
+ return out;
56
+ }
57
+ __name(resolveRunJSObjectValues, "resolveRunJSObjectValues");
58
+ // Annotate the CommonJS export names for ESM import in node:
59
+ 0 && (module.exports = {
60
+ resolveRunJSObjectValues
61
+ });
@@ -0,0 +1,58 @@
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
+ * RunJS 外部模块加载辅助(浏览器侧)。
11
+ *
12
+ * 背景:
13
+ * - NocoBase 前端整体使用 requirejs(AMD)来加载插件与模块;
14
+ * - RunJS 场景下又需要支持 `ctx.importAsync(url)` 直接用浏览器原生 `import()` 加载远端 ESM;
15
+ * - 某些第三方库(典型:UMD/CJS 产物,例如 lodash)会在运行时探测 `define.amd`:
16
+ * - 若存在 AMD,则优先走 `define(...)` 分支;
17
+ * - 但像 esm.sh 这类 CDN 的“CJS/UMD → ESM 包装”往往依赖 `module.exports` 提取导出;
18
+ * - 当 UMD 走了 AMD 分支时,`module.exports` 不会被赋值,最终表现为 ESM 导出(default/命名导出)为 `undefined`。
19
+ *
20
+ * 这里的策略:
21
+ * 1) 全局串行锁:避免 `requireAsync` / `importAsync` 并发时互相影响(尤其是临时 patch 全局 `define.amd`)。
22
+ * 2) 尽量缩小影响窗口:先预取模块(不改全局),再等待 requirejs 空闲,最后只在真正执行 `import()` 的瞬间临时屏蔽 `define.amd`。
23
+ * 3) 所有操作均为 best-effort:内部结构变化、浏览器能力差异等情况下不会阻断正常流程。
24
+ */
25
+ type RequireJsLike = ((deps: string[], onLoad: (...args: any[]) => void, onError: (err: any) => void) => void) | undefined;
26
+ /**
27
+ * 在 RunJS 内部按 URL 通过 requirejs 加载模块:
28
+ * - 与 `runjsImportAsync` 共用同一把锁,避免并发加载期间全局 patch 互相干扰;
29
+ * - 返回 requirejs 回调的第一个模块值(与现有 `ctx.requireAsync` 行为保持一致)。
30
+ */
31
+ export declare function runjsRequireAsync(requirejs: RequireJsLike, url: string): Promise<any>;
32
+ /**
33
+ * 在 RunJS 内部按 URL 动态导入 ESM 模块(返回模块命名空间对象)。
34
+ *
35
+ * 兼容点:
36
+ * - 若检测到 `globalThis.define.amd`,则会在导入前做预取,并在真正执行 `import()` 时短暂屏蔽 `define.amd`;
37
+ * - 为了进一步降低风险,会先等待 requirejs 没有挂起加载;
38
+ * - 使用带 `@vite-ignore` / `webpackIgnore: true` 标记的 dynamic import,避免被打包器重写;
39
+ * - 若仍被拦截,再用 `eval('u => import(u)')` 兜底。
40
+ *
41
+ * 重要说明:
42
+ * - 这里不做 URL 解析(如拼 CDN base/suffix),调用方应传入“最终可 import 的 URL”;
43
+ * - 缓存通常由上层(例如 `ctx.importAsync`)按 URL 做 Map 缓存,此处只负责导入与兼容逻辑。
44
+ */
45
+ export declare function runjsImportAsync(url: string): Promise<any>;
46
+ /**
47
+ * RunJS 专用:按“用户 specifier”导入模块,并在导入 core UI libs 时自动覆盖 ctx/libs。
48
+ *
49
+ * 说明:
50
+ * - 这里负责:specifier rewrite(如 esm.sh antd bundle)、URL 解析、全局 import cache、以及 override。
51
+ * - 具体的 dynamic import 由 `options.importer` 执行(默认使用 `runjsImportAsync`)。
52
+ * 这样在测试中可注入 mock importer,避免真实网络导入。
53
+ */
54
+ export declare function runjsImportModule(ctx: any, specifier: string, options?: {
55
+ importer?: (url: string) => Promise<any>;
56
+ addSuffix?: boolean;
57
+ }): Promise<any>;
58
+ export {};