amis-core 3.2.0 → 3.3.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 (297) hide show
  1. package/esm/Root.js +1 -1
  2. package/esm/RootRenderer.d.ts +1 -1
  3. package/esm/RootRenderer.js +3 -3
  4. package/esm/SchemaRenderer.js +5 -2
  5. package/esm/Scoped.d.ts +4 -1
  6. package/esm/Scoped.js +8 -5
  7. package/esm/StatusScoped.js +1 -1
  8. package/esm/WithRootStore.js +1 -1
  9. package/esm/WithStore.js +1 -1
  10. package/esm/actions/Action.d.ts +1 -0
  11. package/esm/actions/Action.js +62 -37
  12. package/esm/actions/AjaxAction.d.ts +6 -8
  13. package/esm/actions/AjaxAction.js +20 -18
  14. package/esm/actions/BreakAction.js +1 -1
  15. package/esm/actions/BroadcastAction.js +1 -1
  16. package/esm/actions/CmptAction.d.ts +1 -2
  17. package/esm/actions/CmptAction.js +46 -31
  18. package/esm/actions/ContinueAction.js +1 -1
  19. package/esm/actions/CopyAction.js +1 -1
  20. package/esm/actions/CustomAction.js +2 -2
  21. package/esm/actions/DialogAction.js +5 -6
  22. package/esm/actions/DrawerAction.js +4 -4
  23. package/esm/actions/EmailAction.js +1 -1
  24. package/esm/actions/LinkAction.js +1 -1
  25. package/esm/actions/LoopAction.js +1 -1
  26. package/esm/actions/PageAction.js +1 -1
  27. package/esm/actions/ParallelAction.js +1 -1
  28. package/esm/actions/StatusAction.d.ts +15 -0
  29. package/esm/actions/StatusAction.js +49 -0
  30. package/esm/actions/SwitchAction.js +1 -1
  31. package/esm/actions/ToastAction.js +1 -1
  32. package/esm/actions/index.d.ts +1 -0
  33. package/esm/components/CustomStyle.js +1 -1
  34. package/esm/components/LazyComponent.js +1 -1
  35. package/esm/components/Overlay.js +2 -2
  36. package/esm/components/PopOver.js +2 -2
  37. package/esm/env.js +1 -1
  38. package/esm/envOverwrite.js +1 -1
  39. package/esm/factory.js +2 -2
  40. package/esm/index.d.ts +2 -1
  41. package/esm/index.js +13 -13
  42. package/esm/locale.js +1 -1
  43. package/esm/polyfills.js +1 -1
  44. package/esm/renderers/Form.d.ts +6 -6
  45. package/esm/renderers/Form.js +168 -124
  46. package/esm/renderers/Item.d.ts +42 -66
  47. package/esm/renderers/Item.js +11 -41
  48. package/esm/renderers/Options.js +1 -2
  49. package/esm/renderers/Placeholder.js +1 -1
  50. package/esm/renderers/builtin.js +1 -1
  51. package/esm/renderers/register.js +1 -1
  52. package/esm/renderers/wrapControl.js +101 -47
  53. package/esm/store/app.js +8 -4
  54. package/esm/store/combo.d.ts +444 -1912
  55. package/esm/store/combo.js +9 -2
  56. package/esm/store/crud.d.ts +1 -0
  57. package/esm/store/crud.js +11 -5
  58. package/esm/store/form.d.ts +132 -892
  59. package/esm/store/form.js +83 -81
  60. package/esm/store/formItem.d.ts +5 -2
  61. package/esm/store/formItem.js +13 -2
  62. package/esm/store/iRenderer.js +2 -2
  63. package/esm/store/index.js +1 -1
  64. package/esm/store/list.js +1 -1
  65. package/esm/store/manager.js +1 -1
  66. package/esm/store/modal.js +1 -1
  67. package/esm/store/node.js +1 -1
  68. package/esm/store/pagination.js +1 -1
  69. package/esm/store/root.js +2 -2
  70. package/esm/store/service.js +4 -4
  71. package/esm/store/status.js +1 -1
  72. package/esm/store/table.d.ts +503 -2040
  73. package/esm/store/table.js +79 -55
  74. package/esm/store/table2.d.ts +49 -0
  75. package/esm/store/table2.js +37 -4
  76. package/esm/theme.js +1 -1
  77. package/esm/types.d.ts +17 -3
  78. package/esm/utils/Animation.js +1 -1
  79. package/esm/utils/ColorScale.js +1 -1
  80. package/esm/utils/DataSchema.js +1 -1
  81. package/esm/utils/DataScope.js +1 -1
  82. package/esm/utils/RootClose.js +1 -1
  83. package/esm/utils/SimpleMap.js +1 -1
  84. package/esm/utils/api.d.ts +2 -2
  85. package/esm/utils/api.js +113 -81
  86. package/esm/utils/arraySlice.js +1 -1
  87. package/esm/utils/attachmentAdpator.js +1 -1
  88. package/esm/utils/autobind.js +1 -1
  89. package/esm/utils/columnsSplit.js +1 -1
  90. package/esm/utils/dataMapping.js +4 -2
  91. package/esm/utils/date.js +1 -1
  92. package/esm/utils/debug.d.ts +2 -0
  93. package/esm/utils/debug.js +34 -7
  94. package/esm/utils/decodeEntity.js +1 -1
  95. package/esm/utils/dom.js +1 -1
  96. package/esm/utils/errors.js +1 -1
  97. package/esm/utils/escapeHtml.js +1 -1
  98. package/esm/utils/filter-schema.js +1 -1
  99. package/esm/utils/filter.js +1 -1
  100. package/esm/utils/formatDuration.js +1 -1
  101. package/esm/utils/formula.d.ts +0 -1
  102. package/esm/utils/formula.js +6 -9
  103. package/esm/utils/getVariable.js +1 -1
  104. package/esm/utils/grammar.js +1 -1
  105. package/esm/utils/handleAction.js +1 -1
  106. package/esm/utils/helper.d.ts +11 -1
  107. package/esm/utils/helper.js +14 -2
  108. package/esm/utils/highlight.js +1 -1
  109. package/esm/utils/icon.d.ts +4 -2
  110. package/esm/utils/icon.js +3 -2
  111. package/esm/utils/image.js +1 -1
  112. package/esm/utils/index.d.ts +1 -0
  113. package/esm/utils/isPureVariable.js +1 -1
  114. package/esm/utils/json-schema-2-amis-schema.js +1 -1
  115. package/esm/utils/keyToPath.js +1 -1
  116. package/esm/utils/makeSorter.js +1 -1
  117. package/esm/utils/math.d.ts +3 -0
  118. package/esm/utils/math.js +52 -0
  119. package/esm/utils/memoryParse.js +1 -1
  120. package/esm/utils/normalizeLink.js +1 -1
  121. package/esm/utils/normalizeOptions.js +1 -1
  122. package/esm/utils/object.d.ts +7 -0
  123. package/esm/utils/object.js +13 -2
  124. package/esm/utils/offset.js +1 -1
  125. package/esm/utils/offsetParent.js +1 -1
  126. package/esm/utils/optionValueCompare.js +2 -2
  127. package/esm/utils/position.js +1 -1
  128. package/esm/utils/prettyBytes.js +1 -1
  129. package/esm/utils/renderer-event.d.ts +1 -1
  130. package/esm/utils/renderer-event.js +14 -6
  131. package/esm/utils/replaceText.js +1 -1
  132. package/esm/utils/resize-sensor.js +1 -1
  133. package/esm/utils/resolveCondition.js +1 -1
  134. package/esm/utils/resolveVariable.js +1 -1
  135. package/esm/utils/resolveVariableAndFilter.js +1 -1
  136. package/esm/utils/resolveVariableAndFilterForAsync.js +1 -1
  137. package/esm/utils/scrollPosition.js +1 -1
  138. package/esm/utils/string2regExp.js +1 -1
  139. package/esm/utils/stripNumber.js +1 -1
  140. package/esm/utils/style-helper.js +1 -1
  141. package/esm/utils/style.js +1 -1
  142. package/esm/utils/toNumber.js +1 -1
  143. package/esm/utils/tokenize.js +1 -1
  144. package/esm/utils/tpl-builtin.js +1 -1
  145. package/esm/utils/tpl-lodash.js +1 -1
  146. package/esm/utils/tpl.js +1 -1
  147. package/esm/utils/uncontrollable.js +1 -1
  148. package/esm/utils/validations.js +1 -1
  149. package/lib/Root.js +10 -7
  150. package/lib/RootRenderer.d.ts +1 -1
  151. package/lib/RootRenderer.js +11 -8
  152. package/lib/SchemaRenderer.js +12 -6
  153. package/lib/Scoped.d.ts +4 -1
  154. package/lib/Scoped.js +18 -13
  155. package/lib/StatusScoped.js +5 -2
  156. package/lib/WithRootStore.js +5 -2
  157. package/lib/WithStore.js +5 -2
  158. package/lib/actions/Action.d.ts +1 -0
  159. package/lib/actions/Action.js +62 -37
  160. package/lib/actions/AjaxAction.d.ts +6 -8
  161. package/lib/actions/AjaxAction.js +20 -18
  162. package/lib/actions/BreakAction.js +1 -1
  163. package/lib/actions/BroadcastAction.js +1 -1
  164. package/lib/actions/CmptAction.d.ts +1 -2
  165. package/lib/actions/CmptAction.js +46 -31
  166. package/lib/actions/ContinueAction.js +1 -1
  167. package/lib/actions/CopyAction.js +1 -1
  168. package/lib/actions/CustomAction.js +8 -5
  169. package/lib/actions/DialogAction.js +5 -6
  170. package/lib/actions/DrawerAction.js +4 -4
  171. package/lib/actions/EmailAction.js +1 -1
  172. package/lib/actions/LinkAction.js +1 -1
  173. package/lib/actions/LoopAction.js +1 -1
  174. package/lib/actions/PageAction.js +1 -1
  175. package/lib/actions/ParallelAction.js +1 -1
  176. package/lib/actions/StatusAction.d.ts +15 -0
  177. package/lib/actions/StatusAction.js +53 -0
  178. package/lib/actions/SwitchAction.js +1 -1
  179. package/lib/actions/ToastAction.js +1 -1
  180. package/lib/actions/index.d.ts +1 -0
  181. package/lib/components/CustomStyle.js +1 -1
  182. package/lib/components/LazyComponent.js +12 -14
  183. package/lib/components/Overlay.js +14 -14
  184. package/lib/components/PopOver.js +11 -10
  185. package/lib/env.js +4 -1
  186. package/lib/envOverwrite.js +1 -1
  187. package/lib/factory.js +11 -9
  188. package/lib/index.d.ts +2 -1
  189. package/lib/index.js +21 -19
  190. package/lib/locale.js +6 -3
  191. package/lib/polyfills.js +1 -1
  192. package/lib/renderers/Form.d.ts +6 -6
  193. package/lib/renderers/Form.js +180 -131
  194. package/lib/renderers/Item.d.ts +42 -66
  195. package/lib/renderers/Item.js +51 -75
  196. package/lib/renderers/Options.js +10 -5
  197. package/lib/renderers/Placeholder.js +1 -1
  198. package/lib/renderers/builtin.js +1 -1
  199. package/lib/renderers/register.js +1 -1
  200. package/lib/renderers/wrapControl.js +104 -47
  201. package/lib/store/app.js +14 -7
  202. package/lib/store/combo.d.ts +444 -1912
  203. package/lib/store/combo.js +9 -2
  204. package/lib/store/crud.d.ts +1 -0
  205. package/lib/store/crud.js +11 -5
  206. package/lib/store/form.d.ts +132 -892
  207. package/lib/store/form.js +81 -79
  208. package/lib/store/formItem.d.ts +5 -2
  209. package/lib/store/formItem.js +13 -2
  210. package/lib/store/iRenderer.js +8 -5
  211. package/lib/store/index.js +1 -1
  212. package/lib/store/list.js +1 -1
  213. package/lib/store/manager.js +1 -1
  214. package/lib/store/modal.js +1 -1
  215. package/lib/store/node.js +1 -1
  216. package/lib/store/pagination.js +1 -1
  217. package/lib/store/root.js +8 -5
  218. package/lib/store/service.js +4 -4
  219. package/lib/store/status.js +1 -1
  220. package/lib/store/table.d.ts +503 -2040
  221. package/lib/store/table.js +79 -55
  222. package/lib/store/table2.d.ts +49 -0
  223. package/lib/store/table2.js +36 -3
  224. package/lib/theme.js +6 -3
  225. package/lib/types.d.ts +17 -3
  226. package/lib/utils/Animation.js +1 -1
  227. package/lib/utils/ColorScale.js +1 -1
  228. package/lib/utils/DataSchema.js +1 -1
  229. package/lib/utils/DataScope.js +1 -1
  230. package/lib/utils/RootClose.js +1 -1
  231. package/lib/utils/SimpleMap.js +1 -1
  232. package/lib/utils/api.d.ts +2 -2
  233. package/lib/utils/api.js +113 -81
  234. package/lib/utils/arraySlice.js +1 -1
  235. package/lib/utils/attachmentAdpator.js +1 -1
  236. package/lib/utils/autobind.js +1 -1
  237. package/lib/utils/columnsSplit.js +8 -6
  238. package/lib/utils/dataMapping.js +4 -2
  239. package/lib/utils/date.js +1 -1
  240. package/lib/utils/debug.d.ts +2 -0
  241. package/lib/utils/debug.js +61 -33
  242. package/lib/utils/decodeEntity.js +1 -1
  243. package/lib/utils/dom.js +7 -5
  244. package/lib/utils/errors.js +1 -1
  245. package/lib/utils/escapeHtml.js +1 -1
  246. package/lib/utils/filter-schema.js +1 -1
  247. package/lib/utils/filter.js +1 -1
  248. package/lib/utils/formatDuration.js +1 -1
  249. package/lib/utils/formula.d.ts +0 -1
  250. package/lib/utils/formula.js +6 -10
  251. package/lib/utils/getVariable.js +1 -1
  252. package/lib/utils/grammar.js +1 -1
  253. package/lib/utils/handleAction.js +1 -1
  254. package/lib/utils/helper.d.ts +11 -1
  255. package/lib/utils/helper.js +14 -1
  256. package/lib/utils/highlight.js +8 -9
  257. package/lib/utils/icon.d.ts +4 -2
  258. package/lib/utils/icon.js +12 -10
  259. package/lib/utils/image.js +1 -1
  260. package/lib/utils/index.d.ts +1 -0
  261. package/lib/utils/isPureVariable.js +1 -1
  262. package/lib/utils/json-schema-2-amis-schema.js +1 -1
  263. package/lib/utils/keyToPath.js +1 -1
  264. package/lib/utils/makeSorter.js +1 -1
  265. package/lib/utils/math.d.ts +3 -0
  266. package/lib/utils/math.js +58 -0
  267. package/lib/utils/memoryParse.js +1 -1
  268. package/lib/utils/normalizeLink.js +1 -1
  269. package/lib/utils/normalizeOptions.js +1 -1
  270. package/lib/utils/object.d.ts +7 -0
  271. package/lib/utils/object.js +13 -1
  272. package/lib/utils/offset.js +1 -1
  273. package/lib/utils/offsetParent.js +1 -1
  274. package/lib/utils/optionValueCompare.js +7 -3
  275. package/lib/utils/position.js +1 -1
  276. package/lib/utils/prettyBytes.js +1 -1
  277. package/lib/utils/renderer-event.d.ts +1 -1
  278. package/lib/utils/renderer-event.js +13 -5
  279. package/lib/utils/replaceText.js +1 -1
  280. package/lib/utils/resize-sensor.js +1 -1
  281. package/lib/utils/resolveCondition.js +1 -1
  282. package/lib/utils/resolveVariable.js +1 -1
  283. package/lib/utils/resolveVariableAndFilter.js +1 -1
  284. package/lib/utils/resolveVariableAndFilterForAsync.js +1 -1
  285. package/lib/utils/scrollPosition.js +1 -1
  286. package/lib/utils/string2regExp.js +1 -1
  287. package/lib/utils/stripNumber.js +1 -1
  288. package/lib/utils/style-helper.js +1 -1
  289. package/lib/utils/style.js +1 -1
  290. package/lib/utils/toNumber.js +1 -1
  291. package/lib/utils/tokenize.js +1 -1
  292. package/lib/utils/tpl-builtin.js +1 -1
  293. package/lib/utils/tpl-lodash.js +1 -1
  294. package/lib/utils/tpl.js +1 -1
  295. package/lib/utils/uncontrollable.js +1 -1
  296. package/lib/utils/validations.js +1 -1
  297. package/package.json +5 -5
package/esm/utils/api.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -47,10 +47,10 @@ function buildApi(api, data, options) {
47
47
  api.headers = dataMapping(api.headers, data, undefined, false);
48
48
  }
49
49
  if (api.requestAdaptor && typeof api.requestAdaptor === 'string') {
50
- api.requestAdaptor = str2function(api.requestAdaptor, 'api');
50
+ api.requestAdaptor = str2AsyncFunction(api.requestAdaptor, 'api', 'context');
51
51
  }
52
52
  if (api.adaptor && typeof api.adaptor === 'string') {
53
- api.adaptor = str2function(api.adaptor, 'payload', 'response', 'api');
53
+ api.adaptor = str2AsyncFunction(api.adaptor, 'payload', 'response', 'api', 'context');
54
54
  }
55
55
  if (!data) {
56
56
  return api;
@@ -354,68 +354,84 @@ function wrapFetcher(fn, tracker) {
354
354
  }
355
355
  var wrappedFetcher = function (api, data, options) {
356
356
  var _a, _b, _c;
357
- api = buildApi(api, data, options);
358
- if (api.requestAdaptor) {
359
- debug('api', 'before requestAdaptor', api);
360
- api = api.requestAdaptor(api) || api;
361
- debug('api', 'after requestAdaptor', api);
362
- }
363
- if (api.data &&
364
- (api.data instanceof FormData ||
365
- hasFile(api.data) ||
366
- api.dataType === 'form-data')) {
367
- api.data =
368
- api.data instanceof FormData
369
- ? api.data
370
- : object2formData(api.data, api.qsOptions);
371
- }
372
- else if (api.data &&
373
- typeof api.data !== 'string' &&
374
- api.dataType === 'form') {
375
- api.data = qsstringify(api.data, api.qsOptions);
376
- api.headers = api.headers || (api.headers = {});
377
- api.headers['Content-Type'] = 'application/x-www-form-urlencoded';
378
- }
379
- else if (api.data &&
380
- typeof api.data !== 'string' &&
381
- api.dataType === 'json') {
382
- api.data = JSON.stringify(api.data);
383
- api.headers = api.headers || (api.headers = {});
384
- api.headers['Content-Type'] = 'application/json';
385
- }
386
- if (!isValidApi(api.url)) {
387
- throw new Error("invalid api url:".concat(api.url));
388
- }
389
- debug('api', 'request api', api);
390
- tracker === null || tracker === void 0 ? void 0 : tracker({ eventType: 'api', eventData: omit(api, ['config', 'data', 'body']) }, api.data);
391
- if (((_a = api.method) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase()) === 'jsonp') {
392
- return wrapAdaptor(jsonpFetcher(api), api);
393
- }
394
- if (((_b = api.method) === null || _b === void 0 ? void 0 : _b.toLocaleLowerCase()) === 'js') {
395
- return wrapAdaptor(jsFetcher(fn, api), api);
396
- }
397
- if (typeof api.cache === 'number' && api.cache > 0) {
398
- var apiCache = getApiCache(api);
399
- return wrapAdaptor(apiCache
400
- ? apiCache.cachedPromise
401
- : setApiCache(api, fn(api)), api);
402
- }
403
- // IE get 请求会被缓存,所以自动加个时间戳
404
- if (isIE && api && ((_c = api.method) === null || _c === void 0 ? void 0 : _c.toLocaleLowerCase()) === 'get') {
405
- var timeStamp = "_t=".concat(Date.now());
406
- if (api.url.indexOf('?') === -1) {
407
- api.url = api.url + "?".concat(timeStamp);
408
- }
409
- else {
410
- api.url = api.url + "&".concat(timeStamp);
411
- }
412
- }
413
- return wrapAdaptor(fn(api), api);
357
+ return __awaiter(this, void 0, void 0, function () {
358
+ var apiCache, timeStamp;
359
+ return __generator(this, function (_d) {
360
+ switch (_d.label) {
361
+ case 0:
362
+ api = buildApi(api, data, options);
363
+ if (!api.requestAdaptor) return [3 /*break*/, 2];
364
+ debug('api', 'before requestAdaptor', api);
365
+ return [4 /*yield*/, api.requestAdaptor(api, data)];
366
+ case 1:
367
+ api = (_d.sent()) || api;
368
+ debug('api', 'after requestAdaptor', api);
369
+ _d.label = 2;
370
+ case 2:
371
+ if (api.data &&
372
+ (api.data instanceof FormData ||
373
+ hasFile(api.data) ||
374
+ api.dataType === 'form-data')) {
375
+ api.data =
376
+ api.data instanceof FormData
377
+ ? api.data
378
+ : object2formData(api.data, api.qsOptions);
379
+ }
380
+ else if (api.data &&
381
+ typeof api.data !== 'string' &&
382
+ api.dataType === 'form') {
383
+ api.data = qsstringify(api.data, api.qsOptions);
384
+ api.headers = api.headers || (api.headers = {});
385
+ api.headers['Content-Type'] = 'application/x-www-form-urlencoded';
386
+ }
387
+ else if (api.data &&
388
+ typeof api.data !== 'string' &&
389
+ api.dataType === 'json') {
390
+ api.data = JSON.stringify(api.data);
391
+ api.headers = api.headers || (api.headers = {});
392
+ api.headers['Content-Type'] = 'application/json';
393
+ }
394
+ // 如果发送适配器中设置了 mockResponse
395
+ // 则直接跳过请求发送
396
+ if (api.mockResponse) {
397
+ return [2 /*return*/, wrapAdaptor(Promise.resolve(api.mockResponse), api, data)];
398
+ }
399
+ if (!isValidApi(api.url)) {
400
+ throw new Error("invalid api url:".concat(api.url));
401
+ }
402
+ debug('api', 'request api', api);
403
+ tracker === null || tracker === void 0 ? void 0 : tracker({ eventType: 'api', eventData: omit(api, ['config', 'data', 'body']) }, api.data);
404
+ if (((_a = api.method) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase()) === 'jsonp') {
405
+ return [2 /*return*/, wrapAdaptor(jsonpFetcher(api), api, data)];
406
+ }
407
+ if (((_b = api.method) === null || _b === void 0 ? void 0 : _b.toLocaleLowerCase()) === 'js') {
408
+ return [2 /*return*/, wrapAdaptor(jsFetcher(fn, api), api, data)];
409
+ }
410
+ if (typeof api.cache === 'number' && api.cache > 0) {
411
+ apiCache = getApiCache(api);
412
+ return [2 /*return*/, wrapAdaptor(apiCache
413
+ ? apiCache.cachedPromise
414
+ : setApiCache(api, fn(api)), api, data)];
415
+ }
416
+ // IE 下 get 请求会被缓存,所以自动加个时间戳
417
+ if (isIE && api && ((_c = api.method) === null || _c === void 0 ? void 0 : _c.toLocaleLowerCase()) === 'get') {
418
+ timeStamp = "_t=".concat(Date.now());
419
+ if (api.url.indexOf('?') === -1) {
420
+ api.url = api.url + "?".concat(timeStamp);
421
+ }
422
+ else {
423
+ api.url = api.url + "&".concat(timeStamp);
424
+ }
425
+ }
426
+ return [2 /*return*/, wrapAdaptor(fn(api), api, data)];
427
+ }
428
+ });
429
+ });
414
430
  };
415
431
  wrappedFetcher._wrappedFetcher = true;
416
432
  return wrappedFetcher;
417
433
  }
418
- function wrapAdaptor(promise, api) {
434
+ function wrapAdaptor(promise, api, context) {
419
435
  var _this = this;
420
436
  var adaptor = api.adaptor;
421
437
  return adaptor
@@ -426,7 +442,7 @@ function wrapAdaptor(promise, api) {
426
442
  switch (_a.label) {
427
443
  case 0:
428
444
  debug('api', 'before adaptor data', response.data);
429
- result = adaptor(response.data, response, api);
445
+ result = adaptor(response.data, response, api, context);
430
446
  if (!(result === null || result === void 0 ? void 0 : result.then)) return [3 /*break*/, 2];
431
447
  return [4 /*yield*/, result];
432
448
  case 1:
@@ -540,41 +556,57 @@ function isApiOutdated(prevApi, nextApi, prevData, nextData) {
540
556
  return true;
541
557
  }
542
558
  nextApi = normalizeApi(nextApi);
559
+ prevApi = (prevApi ? normalizeApi(prevApi) : prevApi);
543
560
  if (nextApi.autoRefresh === false) {
544
561
  return false;
545
562
  }
563
+ // api 本身有变化
564
+ if ((prevApi && prevApi.url !== nextApi.url) || !prevApi) {
565
+ return !!(isValidApi(nextApi.url) &&
566
+ (!nextApi.sendOn || evalExpression(nextApi.sendOn, nextData)));
567
+ }
546
568
  var trackExpression = (_a = nextApi.trackExpression) !== null && _a !== void 0 ? _a : nextApi.url;
547
569
  if (typeof trackExpression !== 'string' || !~trackExpression.indexOf('$')) {
548
570
  return false;
549
571
  }
550
572
  var isModified = false;
551
- if (prevApi) {
552
- prevApi = normalizeApi(prevApi);
553
- if (nextApi.trackExpression || prevApi.trackExpression) {
554
- isModified =
555
- tokenize(prevApi.trackExpression || '', prevData) !==
556
- tokenize(nextApi.trackExpression || '', nextData);
557
- }
558
- else {
559
- prevApi = buildApi(prevApi, prevData, {
560
- ignoreData: true
561
- });
562
- nextApi = buildApi(nextApi, nextData, {
563
- ignoreData: true
564
- });
565
- isModified = prevApi.url !== nextApi.url;
566
- }
573
+ if (nextApi.trackExpression || prevApi.trackExpression) {
574
+ isModified =
575
+ tokenize(prevApi.trackExpression || '', prevData) !==
576
+ tokenize(nextApi.trackExpression || '', nextData);
567
577
  }
568
578
  else {
569
- isModified = true;
579
+ prevApi = buildApi(prevApi, prevData, {
580
+ ignoreData: true
581
+ });
582
+ nextApi = buildApi(nextApi, nextData, {
583
+ ignoreData: true
584
+ });
585
+ isModified = prevApi.url !== nextApi.url;
570
586
  }
571
587
  return !!(isModified &&
572
588
  isValidApi(nextApi.url) &&
573
589
  (!nextApi.sendOn || evalExpression(nextApi.sendOn, nextData)));
574
590
  }
575
591
  function isValidApi(api) {
576
- return (api &&
577
- /^(?:(https?|wss?|taf):\/\/[^\/]+)?(\/?[^\s\/\?]*){1,}(\?.*)?$/.test(api));
592
+ if (!api || typeof api !== 'string') {
593
+ return false;
594
+ }
595
+ var idx = api.indexOf('://');
596
+ // 不允许直接相对路径写 api
597
+ // 不允许 :// 结尾
598
+ if ((!~idx && api[0] !== '/') || (~idx && idx + 3 === api.length)) {
599
+ return false;
600
+ }
601
+ try {
602
+ // 不补一个协议,URL 判断为 false
603
+ api = (~idx ? '' : 'schema://domain') + api;
604
+ new URL(api);
605
+ }
606
+ catch (error) {
607
+ return false;
608
+ }
609
+ return true;
578
610
  }
579
611
  function isEffectiveApi(api, data, initFetch, initFetchOn) {
580
612
  if (!api) {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -131,7 +131,9 @@ function dataMapping(to, from, ignoreFunction, convertKeyToPath, ignoreIfNotMatc
131
131
  else if (value === '$$') {
132
132
  setVariable(ret, key, from, convertKeyToPath);
133
133
  }
134
- else if (value && value[0] === '$') {
134
+ else if (typeof value === 'string' &&
135
+ value.length > 0 &&
136
+ value[0] === '$') {
135
137
  var v = resolveMapping(value, from, undefined, ignoreIfNotMatch);
136
138
  setVariable(ret, key, v, convertKeyToPath);
137
139
  if (v === '__undefined') {
package/esm/utils/date.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -2,7 +2,9 @@
2
2
  * amis 运行时调试功能,为了避免循环引用,这个组件不要依赖 amis 里的组件
3
3
  */
4
4
  import React, { Component } from 'react';
5
+ export declare const JsonView: React.LazyExoticComponent<React.ComponentType<import("react-json-view").ReactJsonViewProps>>;
5
6
  export declare function enableDebug(): void;
7
+ export declare function disableDebug(): void;
6
8
  interface DebugWrapperProps {
7
9
  renderer: any;
8
10
  children?: React.ReactNode;
@@ -1,13 +1,12 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __decorate, __metadata, __values, __read, __extends } from 'tslib';
7
7
  import React, { useRef, useState, useEffect, Component } from 'react';
8
8
  import cx from 'classnames';
9
- import { findDOMNode, render } from 'react-dom';
10
- import JsonView from 'react-json-view';
9
+ import { findDOMNode, render, unmountComponentAtNode } from 'react-dom';
11
10
  import { observable, autorun } from 'mobx';
12
11
  import { observer } from 'mobx-react';
13
12
  import { uuidv4 } from './helper.js';
@@ -16,6 +15,7 @@ import { position } from './position.js';
16
15
  /**
17
16
  * amis 运行时调试功能,为了避免循环引用,这个组件不要依赖 amis 里的组件
18
17
  */
18
+ var JsonView = React.lazy(function () { return import('react-json-view'); });
19
19
  /** @class */ ((function () {
20
20
  function Log() {
21
21
  this.cat = '';
@@ -113,7 +113,8 @@ var LogView = observer(function (_a) {
113
113
  log.cat,
114
114
  "] ",
115
115
  log.msg),
116
- log.ext ? (React.createElement(JsonView, { name: null, theme: "monokai", src: JSON.parse(log.ext), collapsed: true, enableClipboard: false, displayDataTypes: false, collapseStringsAfterLength: ellipsisThreshold, iconStyle: "square" })) : null));
116
+ log.ext ? (React.createElement(React.Suspense, { fallback: React.createElement("div", null, "Loading...") },
117
+ React.createElement(JsonView, { name: null, theme: "monokai", src: JSON.parse(log.ext), collapsed: true, enableClipboard: false, displayDataTypes: false, collapseStringsAfterLength: ellipsisThreshold, iconStyle: "square" }))) : null));
117
118
  })));
118
119
  });
119
120
  var AMISDebug = observer(function (_a) {
@@ -143,7 +144,8 @@ var AMISDebug = observer(function (_a) {
143
144
  React.createElement("h3", null,
144
145
  "Data Level-",
145
146
  level),
146
- React.createElement(JsonView, { key: "dataview-".concat(stack), name: null, theme: "monokai", src: stack, collapsed: level === 0 ? false : true, enableClipboard: false, displayDataTypes: false, iconStyle: "square" })));
147
+ React.createElement(React.Suspense, { fallback: React.createElement("div", null, "Loading...") },
148
+ React.createElement(JsonView, { key: "dataview-".concat(stack), name: null, theme: "monokai", src: stack, collapsed: level === 0 ? false : true, enableClipboard: false, displayDataTypes: false, iconStyle: "square" }))));
147
149
  level += 1;
148
150
  }
149
151
  }
@@ -254,7 +256,7 @@ function handleMouseclick(e) {
254
256
  }
255
257
  var dom = e.target;
256
258
  var target = dom.closest("[data-debug-id]");
257
- if (target) {
259
+ if (target && !target.closest('.AMISDebug')) {
258
260
  store.activeId = target.getAttribute('data-debug-id');
259
261
  store.tab = 'inspect';
260
262
  }
@@ -294,6 +296,7 @@ autorun(function () {
294
296
  });
295
297
  // 页面中只能有一个实例
296
298
  var isEnabled = false;
299
+ var unmount;
297
300
  function enableDebug() {
298
301
  if (isEnabled) {
299
302
  return;
@@ -302,12 +305,36 @@ function enableDebug() {
302
305
  var amisDebugElement = document.createElement('div');
303
306
  document.body.appendChild(amisDebugElement);
304
307
  var element = React.createElement(AMISDebug, { store: store });
308
+ // if (parseInt(version.split('.')[0], 10) >= 18) {
309
+ // const root = createRoot(amisDebugElement);
310
+ // root.render(element);
311
+ // unmount = () => {
312
+ // root.unmount();
313
+ // document.body.removeChild(amisDebugElement);
314
+ // };
315
+ // } else {
305
316
  render(element, amisDebugElement);
317
+ unmount = function () {
318
+ unmountComponentAtNode(amisDebugElement);
319
+ document.body.removeChild(amisDebugElement);
320
+ };
321
+ // }
306
322
  document.body.appendChild(amisHoverBox);
307
323
  document.body.appendChild(amisActiveBox);
308
324
  document.addEventListener('mousemove', handleMouseMove);
309
325
  document.addEventListener('click', handleMouseclick);
310
326
  }
327
+ function disableDebug() {
328
+ if (!isEnabled) {
329
+ return;
330
+ }
331
+ isEnabled = false;
332
+ unmount === null || unmount === void 0 ? void 0 : unmount();
333
+ document.body.removeChild(amisHoverBox);
334
+ document.body.removeChild(amisActiveBox);
335
+ document.removeEventListener('mousemove', handleMouseMove);
336
+ document.removeEventListener('click', handleMouseclick);
337
+ }
311
338
  var DebugWrapper = /** @class */ (function (_super) {
312
339
  __extends(DebugWrapper, _super);
313
340
  function DebugWrapper() {
@@ -386,4 +413,4 @@ function warning(cat, msg, ext) {
386
413
  store.logs.push(log);
387
414
  }
388
415
 
389
- export { DebugWrapper, debug, enableDebug, warning };
416
+ export { DebugWrapper, JsonView, debug, disableDebug, enableDebug, warning };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
package/esm/utils/dom.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -13,5 +13,4 @@ export declare function isNeedFormula(expression: any, prevData: {
13
13
  }, curData: {
14
14
  [propName: string]: any;
15
15
  }): boolean;
16
- export declare function isNowFormula(expression: string): boolean;
17
16
  export declare function replaceExpression(expression: any): any;
@@ -1,9 +1,9 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
- import isObjectByLodash from 'lodash/isObject';
6
+ import isObject from 'lodash/isObject';
7
7
  import isString from 'lodash/isString';
8
8
  import isBoolean from 'lodash/isBoolean';
9
9
  import { evaluate, getFilters } from 'amis-formula';
@@ -114,7 +114,7 @@ var FormulaExec = {
114
114
  },
115
115
  collect: function (expression) {
116
116
  var variables = [];
117
- if (isObjectByLodash(expression) || isString(expression)) {
117
+ if (isObject(expression) || isString(expression)) {
118
118
  // 仅对 Object类型 和 String类型 进行变量提取
119
119
  variables = collectVariables(expression);
120
120
  }
@@ -198,7 +198,8 @@ function isNeedFormula(expression, prevData, curData) {
198
198
  try {
199
199
  var variables = FormulaExec.collect(expression);
200
200
  return variables.some(function (variable) {
201
- return FormulaExec.var(variable, prevData) !== FormulaExec.var(variable, curData);
201
+ return FormulaExec.var(variable, prevData) !==
202
+ FormulaExec.var(variable, curData);
202
203
  });
203
204
  }
204
205
  catch (e) {
@@ -206,10 +207,6 @@ function isNeedFormula(expression, prevData, curData) {
206
207
  return false;
207
208
  }
208
209
  }
209
- function isNowFormula(expression) {
210
- var block = expression.split(/\${|\||}/).filter(function (item) { return item; });
211
- return block[1] === 'now';
212
- }
213
210
  // 将 \${xx} 替换成 ${xx}
214
211
  function replaceExpression(expression) {
215
212
  if (expression &&
@@ -220,4 +217,4 @@ function replaceExpression(expression) {
220
217
  return expression;
221
218
  }
222
219
 
223
- export { FormulaExec, formulaExec, isExpression, isNeedFormula, isNowFormula, registerFormulaExec, replaceExpression };
220
+ export { FormulaExec, formulaExec, isExpression, isNeedFormula, registerFormulaExec, replaceExpression };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -268,6 +268,15 @@ export declare function loadScript(src: string): Promise<void>;
268
268
  export declare function loadStyle(href: string): Promise<void>;
269
269
  export declare class SkipOperation extends Error {
270
270
  }
271
+ export declare class ValidateError extends Error {
272
+ name: 'ValidateError';
273
+ detail: {
274
+ [propName: string]: Array<string> | string;
275
+ };
276
+ constructor(message: string, error: {
277
+ [propName: string]: Array<string> | string;
278
+ });
279
+ }
271
280
  /**
272
281
  * 深度查找具有某个 key 名字段的对象,实际实现是 internalFindObjectsWithKey,这里包一层是为了做循环引用检测
273
282
  * @param obj
@@ -283,7 +292,8 @@ export declare function getPropValue<T extends {
283
292
  name?: string;
284
293
  data?: any;
285
294
  defaultValue?: any;
286
- }>(props: T, getter?: (props: T) => any, canAccessSuper?: boolean): any;
295
+ canAccessSuperData?: boolean;
296
+ }>(props: T, getter?: (props: T) => any, canAccessSuper?: boolean | undefined): any;
287
297
  export declare function detectPropValueChanged<T extends {
288
298
  value?: any;
289
299
  name?: string;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1041,6 +1041,17 @@ var SkipOperation = /** @class */ (function (_super) {
1041
1041
  }
1042
1042
  return SkipOperation;
1043
1043
  }(Error));
1044
+ var ValidateError = /** @class */ (function (_super) {
1045
+ __extends(ValidateError, _super);
1046
+ function ValidateError(message, error) {
1047
+ var _this = _super.call(this) || this;
1048
+ _this.name = 'ValidateError';
1049
+ _this.message = message;
1050
+ _this.detail = error;
1051
+ return _this;
1052
+ }
1053
+ return ValidateError;
1054
+ }(Error));
1044
1055
  /**
1045
1056
  * 检查对象是否有循环引用,来自 https://stackoverflow.com/a/34909127
1046
1057
  * @param obj
@@ -1123,6 +1134,7 @@ function resolveValueByName(data, name, canAccessSuper) {
1123
1134
  // 统一的获取 value 值方法
1124
1135
  function getPropValue(props, getter, canAccessSuper) {
1125
1136
  var _a, _b;
1137
+ if (canAccessSuper === void 0) { canAccessSuper = props.canAccessSuperData; }
1126
1138
  var name = props.name, value = props.value, data = props.data, defaultValue = props.defaultValue;
1127
1139
  return ((_b = (_a = value !== null && value !== void 0 ? value : getter === null || getter === void 0 ? void 0 : getter(props)) !== null && _a !== void 0 ? _a : resolveValueByName(data, name, canAccessSuper)) !== null && _b !== void 0 ? _b : defaultValue);
1128
1140
  }
@@ -1337,4 +1349,4 @@ function parseQuery(location) {
1337
1349
  return merge(normalizedQuery, hashQuery);
1338
1350
  }
1339
1351
 
1340
- export { JSONTraverse, JSONValueMap, SkipOperation, __uri, anyChanged, autobind, bulkBindFunctions, camel, chainEvents, chainFunctions, convertArrayValueToMoment, detectPropValueChanged, difference, eachTree, everyTree, filterTree, findIndex, findObjectsWithKey, findTree, findTreeAll, findTreeIndex, flattenTree, flattenTreeWithLeafNodes, getLevelFromClassName, getPropValue, getRange, getScrollParent, getScrollbarWidth, getTree, getTreeAncestors, getTreeDepth, getTreeParent, getWidthRate, guid, hasAbility, hasFile, hasOwnPropertyInPath, hasVisibleExpression, hashCode, immutableExtends, injectPropsToObject, isArrayChildrenModified, isBreakpoint, isClickOnInput, isDisabled, isEmpty, isMobile, isNumeric, isObjectShallowModified, isSuperDataModified, isUnfolded, isVisible, lcFirst, loadScript, loadStyle, makeColumnClassBuild, makeHorizontalDeeper, mapObject, mapTree, noop, normalizeNodePath, object2formData, omitControls, padArr, parseQuery, pickEventsProps, preventDefault, promisify, qsparse, qsstringify, range, removeHTMLTag, repeatCount, rmUndefined, someTree, sortArray, spliceTree, syncDataFromSuper, ucFirst, until, uuid, uuidv4, visibilityFilter };
1352
+ export { JSONTraverse, JSONValueMap, SkipOperation, ValidateError, __uri, anyChanged, autobind, bulkBindFunctions, camel, chainEvents, chainFunctions, convertArrayValueToMoment, detectPropValueChanged, difference, eachTree, everyTree, filterTree, findIndex, findObjectsWithKey, findTree, findTreeAll, findTreeIndex, flattenTree, flattenTreeWithLeafNodes, getLevelFromClassName, getPropValue, getRange, getScrollParent, getScrollbarWidth, getTree, getTreeAncestors, getTreeDepth, getTreeParent, getWidthRate, guid, hasAbility, hasFile, hasOwnPropertyInPath, hasVisibleExpression, hashCode, immutableExtends, injectPropsToObject, isArrayChildrenModified, isBreakpoint, isClickOnInput, isDisabled, isEmpty, isMobile, isNumeric, isObjectShallowModified, isSuperDataModified, isUnfolded, isVisible, lcFirst, loadScript, loadStyle, makeColumnClassBuild, makeHorizontalDeeper, mapObject, mapTree, noop, normalizeNodePath, object2formData, omitControls, padArr, parseQuery, pickEventsProps, preventDefault, promisify, qsparse, qsstringify, range, removeHTMLTag, repeatCount, rmUndefined, someTree, sortArray, spliceTree, syncDataFromSuper, ucFirst, until, uuid, uuidv4, visibilityFilter };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.2.0
2
+ * amis-core v3.3.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5