@yimoka/designable-playground 0.0.0-stage → 0.1.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 (262) hide show
  1. package/README.md +8 -2
  2. package/dist/demo/components/Alert/index.d.ts +4 -0
  3. package/dist/demo/components/Alert/index.js +41 -0
  4. package/dist/demo/components/ArrayCards/index.d.ts +17 -0
  5. package/dist/demo/components/ArrayCards/index.js +62 -0
  6. package/dist/demo/components/ArrayList/index.d.ts +25 -0
  7. package/dist/demo/components/ArrayList/index.js +143 -0
  8. package/dist/demo/components/ArrayTable/index.d.ts +39 -0
  9. package/dist/demo/components/ArrayTable/index.js +247 -0
  10. package/dist/demo/components/AutoComplete/index.d.ts +4 -0
  11. package/dist/demo/components/AutoComplete/index.js +52 -0
  12. package/dist/demo/components/Avatar/index.d.ts +4 -0
  13. package/dist/demo/components/Avatar/index.js +34 -0
  14. package/dist/demo/components/Badge/index.d.ts +4 -0
  15. package/dist/demo/components/Badge/index.js +35 -0
  16. package/dist/demo/components/Button/index.d.ts +4 -0
  17. package/dist/demo/components/Button/index.js +86 -0
  18. package/dist/demo/components/Card/index.d.ts +4 -0
  19. package/dist/demo/components/Card/index.js +72 -0
  20. package/dist/demo/components/Carousel/index.d.ts +4 -0
  21. package/dist/demo/components/Carousel/index.js +33 -0
  22. package/dist/demo/components/Cascader/index.d.ts +4 -0
  23. package/dist/demo/components/Cascader/index.js +60 -0
  24. package/dist/demo/components/Checkbox/index.d.ts +8 -0
  25. package/dist/demo/components/Checkbox/index.js +55 -0
  26. package/dist/demo/components/ColorPicker/index.d.ts +4 -0
  27. package/dist/demo/components/ColorPicker/index.js +38 -0
  28. package/dist/demo/components/DatePicker/index.d.ts +4 -0
  29. package/dist/demo/components/DatePicker/index.js +61 -0
  30. package/dist/demo/components/DateRangePicker/index.d.ts +4 -0
  31. package/dist/demo/components/DateRangePicker/index.js +58 -0
  32. package/dist/demo/components/Divider/index.d.ts +4 -0
  33. package/dist/demo/components/Divider/index.js +39 -0
  34. package/dist/demo/components/Empty/index.d.ts +4 -0
  35. package/dist/demo/components/Empty/index.js +29 -0
  36. package/dist/demo/components/Flex/index.d.ts +4 -0
  37. package/dist/demo/components/Flex/index.js +51 -0
  38. package/dist/demo/components/Form/index.d.ts +21 -0
  39. package/dist/demo/components/Form/index.js +116 -0
  40. package/dist/demo/components/FormCollapse/index.d.ts +28 -0
  41. package/dist/demo/components/FormCollapse/index.js +164 -0
  42. package/dist/demo/components/FormGrid/index.d.ts +22 -0
  43. package/dist/demo/components/FormGrid/index.js +134 -0
  44. package/dist/demo/components/FormItem/index.d.ts +14 -0
  45. package/dist/demo/components/FormItem/index.js +33 -0
  46. package/dist/demo/components/FormLayout/index.d.ts +26 -0
  47. package/dist/demo/components/FormLayout/index.js +260 -0
  48. package/dist/demo/components/FormTab/index.d.ts +15 -0
  49. package/dist/demo/components/FormTab/index.js +186 -0
  50. package/dist/demo/components/GridCol/index.d.ts +4 -0
  51. package/dist/demo/components/GridCol/index.js +53 -0
  52. package/dist/demo/components/GridRow/index.d.ts +4 -0
  53. package/dist/demo/components/GridRow/index.js +70 -0
  54. package/dist/demo/components/HTMLContent/index.d.ts +4 -0
  55. package/dist/demo/components/HTMLContent/index.js +34 -0
  56. package/dist/demo/components/I18nEditor/index.d.ts +8 -0
  57. package/dist/demo/components/I18nEditor/index.js +64 -0
  58. package/dist/demo/components/Image/index.d.ts +4 -0
  59. package/dist/demo/components/Image/index.js +36 -0
  60. package/dist/demo/components/Input/index.d.ts +4 -0
  61. package/dist/demo/components/Input/index.js +36 -0
  62. package/dist/demo/components/InputSearch/index.d.ts +4 -0
  63. package/dist/demo/components/InputSearch/index.js +40 -0
  64. package/dist/demo/components/Link/index.d.ts +4 -0
  65. package/dist/demo/components/Link/index.js +37 -0
  66. package/dist/demo/components/Mentions/index.d.ts +4 -0
  67. package/dist/demo/components/Mentions/index.js +41 -0
  68. package/dist/demo/components/NumberPicker/index.d.ts +6 -0
  69. package/dist/demo/components/NumberPicker/index.js +63 -0
  70. package/dist/demo/components/ObjectContainer/index.d.ts +14 -0
  71. package/dist/demo/components/ObjectContainer/index.js +46 -0
  72. package/dist/demo/components/Password/index.d.ts +6 -0
  73. package/dist/demo/components/Password/index.js +44 -0
  74. package/dist/demo/components/QRCode/index.d.ts +4 -0
  75. package/dist/demo/components/QRCode/index.js +34 -0
  76. package/dist/demo/components/Radio/index.d.ts +6 -0
  77. package/dist/demo/components/Radio/index.js +49 -0
  78. package/dist/demo/components/Rate/index.d.ts +6 -0
  79. package/dist/demo/components/Rate/index.js +43 -0
  80. package/dist/demo/components/Search/index.d.ts +4 -0
  81. package/dist/demo/components/Search/index.js +42 -0
  82. package/dist/demo/components/SearchSelect/index.d.ts +4 -0
  83. package/dist/demo/components/SearchSelect/index.js +53 -0
  84. package/dist/demo/components/Select/index.d.ts +4 -0
  85. package/dist/demo/components/Select/index.js +59 -0
  86. package/dist/demo/components/Slider/index.d.ts +6 -0
  87. package/dist/demo/components/Slider/index.js +61 -0
  88. package/dist/demo/components/Space/index.d.ts +9 -0
  89. package/dist/demo/components/Space/index.js +61 -0
  90. package/dist/demo/components/Statistic/index.d.ts +4 -0
  91. package/dist/demo/components/Statistic/index.js +33 -0
  92. package/dist/demo/components/Switch/index.d.ts +4 -0
  93. package/dist/demo/components/Switch/index.js +49 -0
  94. package/dist/demo/components/Tabs/index.d.ts +10 -0
  95. package/dist/demo/components/Tabs/index.js +181 -0
  96. package/dist/demo/components/Tag/index.d.ts +4 -0
  97. package/dist/demo/components/Tag/index.js +33 -0
  98. package/dist/demo/components/Text/index.d.ts +11 -0
  99. package/dist/demo/components/Text/index.js +64 -0
  100. package/dist/demo/components/TextArea/index.d.ts +6 -0
  101. package/dist/demo/components/TextArea/index.js +43 -0
  102. package/dist/demo/components/TimePicker/index.d.ts +4 -0
  103. package/dist/demo/components/TimePicker/index.js +69 -0
  104. package/dist/demo/components/TimeRangePicker/index.d.ts +4 -0
  105. package/dist/demo/components/TimeRangePicker/index.js +68 -0
  106. package/dist/demo/components/Transfer/index.d.ts +6 -0
  107. package/dist/demo/components/Transfer/index.js +59 -0
  108. package/dist/demo/components/TreeSelect/index.d.ts +4 -0
  109. package/dist/demo/components/TreeSelect/index.js +63 -0
  110. package/dist/demo/components/Upload/index.d.ts +8 -0
  111. package/dist/demo/components/Upload/index.js +64 -0
  112. package/dist/demo/components/index.d.ts +55 -0
  113. package/dist/demo/components/index.js +55 -0
  114. package/dist/demo/components/shared.d.ts +143 -0
  115. package/dist/demo/components/shared.js +315 -0
  116. package/dist/src/Playground.d.ts +3 -0
  117. package/dist/src/Playground.js +304 -0
  118. package/dist/src/antd/AntdPlayground.d.ts +16 -0
  119. package/dist/src/antd/AntdPlayground.js +136 -0
  120. package/dist/src/antd/index.d.ts +1 -0
  121. package/dist/src/antd/index.js +1 -0
  122. package/dist/src/context.d.ts +4 -0
  123. package/dist/src/context.js +13 -0
  124. package/dist/src/examples/index.d.ts +267 -0
  125. package/dist/src/examples/index.js +824 -0
  126. package/dist/src/hooks/index.d.ts +4 -0
  127. package/dist/src/hooks/index.js +4 -0
  128. package/dist/src/hooks/remoteSchemaAdapter.d.ts +53 -0
  129. package/dist/src/hooks/remoteSchemaAdapter.js +262 -0
  130. package/dist/src/hooks/usePlayground.d.ts +38 -0
  131. package/dist/src/hooks/usePlayground.js +642 -0
  132. package/dist/src/hooks/usePlaygroundRemotePersistence.d.ts +135 -0
  133. package/dist/src/hooks/usePlaygroundRemotePersistence.js +736 -0
  134. package/dist/src/hooks/useSchemaEditorDraft.d.ts +4 -0
  135. package/dist/src/hooks/useSchemaEditorDraft.js +44 -0
  136. package/dist/src/index.d.ts +14 -0
  137. package/dist/src/index.js +14 -0
  138. package/dist/src/layouts/PlaygroundLayout/ErrorBoundaries.d.ts +59 -0
  139. package/dist/src/layouts/PlaygroundLayout/ErrorBoundaries.js +161 -0
  140. package/dist/src/layouts/PlaygroundLayout/index.d.ts +7 -0
  141. package/dist/src/layouts/PlaygroundLayout/index.js +443 -0
  142. package/dist/src/layouts/index.d.ts +1 -0
  143. package/dist/src/layouts/index.js +1 -0
  144. package/dist/src/panels/CompositePanel/index.d.ts +6 -0
  145. package/dist/src/panels/CompositePanel/index.js +139 -0
  146. package/dist/src/panels/ToolbarPanel/index.d.ts +3 -0
  147. package/dist/src/panels/ToolbarPanel/index.js +24 -0
  148. package/dist/src/panels/index.d.ts +2 -0
  149. package/dist/src/panels/index.js +2 -0
  150. package/dist/src/presets/antd.d.ts +19 -0
  151. package/dist/src/presets/antd.js +112 -0
  152. package/dist/src/presets/index.d.ts +4 -0
  153. package/dist/src/presets/index.js +3 -0
  154. package/dist/src/presets/runtime-array-helpers.d.ts +8 -0
  155. package/dist/src/presets/runtime-array-helpers.js +147 -0
  156. package/dist/src/presets/runtime-component-props.d.ts +3 -0
  157. package/dist/src/presets/runtime-component-props.js +5 -0
  158. package/dist/src/presets/runtime-components.d.ts +5 -0
  159. package/dist/src/presets/runtime-components.js +419 -0
  160. package/dist/src/presets/runtime-form-components.d.ts +9 -0
  161. package/dist/src/presets/runtime-form-components.js +94 -0
  162. package/dist/src/presets/scenario-catalog.d.ts +6 -0
  163. package/dist/src/presets/scenario-catalog.js +128 -0
  164. package/dist/src/presets/scenarios.d.ts +52 -0
  165. package/dist/src/presets/scenarios.js +603 -0
  166. package/dist/src/runtime/actions.d.ts +19 -0
  167. package/dist/src/runtime/actions.js +307 -0
  168. package/dist/src/runtime/contracts.d.ts +149 -0
  169. package/dist/src/runtime/contracts.js +1 -0
  170. package/dist/src/runtime/document-bindings.d.ts +3 -0
  171. package/dist/src/runtime/document-bindings.js +101 -0
  172. package/dist/src/runtime/document-core.d.ts +57 -0
  173. package/dist/src/runtime/document-core.js +379 -0
  174. package/dist/src/runtime/document-entity.d.ts +12 -0
  175. package/dist/src/runtime/document-entity.js +351 -0
  176. package/dist/src/runtime/document-expressions.d.ts +35 -0
  177. package/dist/src/runtime/document-expressions.js +346 -0
  178. package/dist/src/runtime/document-security.d.ts +34 -0
  179. package/dist/src/runtime/document-security.js +538 -0
  180. package/dist/src/runtime/document.d.ts +16 -0
  181. package/dist/src/runtime/document.js +212 -0
  182. package/dist/src/runtime/environment.d.ts +16 -0
  183. package/dist/src/runtime/environment.js +76 -0
  184. package/dist/src/runtime/i18n-schema.d.ts +36 -0
  185. package/dist/src/runtime/i18n-schema.js +338 -0
  186. package/dist/src/runtime/i18n.d.ts +25 -0
  187. package/dist/src/runtime/i18n.js +447 -0
  188. package/dist/src/runtime/index.d.ts +8 -0
  189. package/dist/src/runtime/index.js +8 -0
  190. package/dist/src/runtime/navigation.d.ts +5 -0
  191. package/dist/src/runtime/navigation.js +43 -0
  192. package/dist/src/runtime/playground.d.ts +30 -0
  193. package/dist/src/runtime/playground.js +243 -0
  194. package/dist/src/runtime/preview-boundaries.d.ts +13 -0
  195. package/dist/src/runtime/preview-boundaries.js +43 -0
  196. package/dist/src/runtime/preview.d.ts +44 -0
  197. package/dist/src/runtime/preview.js +574 -0
  198. package/dist/src/runtime/settings/RuntimeJsonEditor.d.ts +10 -0
  199. package/dist/src/runtime/settings/RuntimeJsonEditor.js +21 -0
  200. package/dist/src/runtime/settings/RuntimeStoreEntitySettings.d.ts +15 -0
  201. package/dist/src/runtime/settings/RuntimeStoreEntitySettings.js +65 -0
  202. package/dist/src/runtime/templates.d.ts +1560 -0
  203. package/dist/src/runtime/templates.js +508 -0
  204. package/dist/src/runtime/website-contact-template.d.ts +1 -0
  205. package/dist/src/runtime/website-contact-template.js +66 -0
  206. package/dist/src/runtime/website-template-shared.d.ts +14 -0
  207. package/dist/src/runtime/website-template-shared.js +210 -0
  208. package/dist/src/runtime/website-templates.d.ts +5 -0
  209. package/dist/src/runtime/website-templates.js +976 -0
  210. package/dist/src/shared/clipboard.d.ts +4 -0
  211. package/dist/src/shared/clipboard.js +56 -0
  212. package/dist/src/shared/componentRegistry.d.ts +133 -0
  213. package/dist/src/shared/componentRegistry.js +381 -0
  214. package/dist/src/shared/formilyCompatibility.d.ts +8 -0
  215. package/dist/src/shared/formilyCompatibility.js +40 -0
  216. package/dist/src/shared/index.d.ts +6 -0
  217. package/dist/src/shared/index.js +6 -0
  218. package/dist/src/shared/productionAcceptance.d.ts +63 -0
  219. package/dist/src/shared/productionAcceptance.js +201 -0
  220. package/dist/src/shared/schema-options.d.ts +16 -0
  221. package/dist/src/shared/schema-options.js +138 -0
  222. package/dist/src/shared/schema.d.ts +63 -0
  223. package/dist/src/shared/schema.js +627 -0
  224. package/dist/src/shared/styleSecurity.d.ts +2 -0
  225. package/dist/src/shared/styleSecurity.js +35 -0
  226. package/dist/src/transformers/formily.d.ts +34 -0
  227. package/dist/src/transformers/formily.js +943 -0
  228. package/dist/src/transformers/index.d.ts +1 -0
  229. package/dist/src/transformers/index.js +1 -0
  230. package/dist/src/types.d.ts +186 -0
  231. package/dist/src/types.js +1 -0
  232. package/dist/src/widgets/ActionsWidget/index.d.ts +3 -0
  233. package/dist/src/widgets/ActionsWidget/index.js +10 -0
  234. package/dist/src/widgets/ComponentTreeWidget/index.d.ts +3 -0
  235. package/dist/src/widgets/ComponentTreeWidget/index.js +333 -0
  236. package/dist/src/widgets/NodeActionsWidget/index.d.ts +2 -0
  237. package/dist/src/widgets/NodeActionsWidget/index.js +125 -0
  238. package/dist/src/widgets/OutlineTreeWidget/index.d.ts +3 -0
  239. package/dist/src/widgets/OutlineTreeWidget/index.js +432 -0
  240. package/dist/src/widgets/OutlineTreeWidget/shared.d.ts +32 -0
  241. package/dist/src/widgets/OutlineTreeWidget/shared.js +79 -0
  242. package/dist/src/widgets/PreviewWidget/index.d.ts +2 -0
  243. package/dist/src/widgets/PreviewWidget/index.js +1566 -0
  244. package/dist/src/widgets/ProductionReadinessWidget/index.d.ts +18 -0
  245. package/dist/src/widgets/ProductionReadinessWidget/index.js +356 -0
  246. package/dist/src/widgets/RemotePersistenceStatusWidget/index.d.ts +18 -0
  247. package/dist/src/widgets/RemotePersistenceStatusWidget/index.js +438 -0
  248. package/dist/src/widgets/RemoteVersionHistoryWidget/index.d.ts +39 -0
  249. package/dist/src/widgets/RemoteVersionHistoryWidget/index.js +475 -0
  250. package/dist/src/widgets/ResourceWidget/index.d.ts +3 -0
  251. package/dist/src/widgets/ResourceWidget/index.js +491 -0
  252. package/dist/src/widgets/SchemaCodeView/index.d.ts +7 -0
  253. package/dist/src/widgets/SchemaCodeView/index.js +225 -0
  254. package/dist/src/widgets/SchemaEditorWidget/index.d.ts +10 -0
  255. package/dist/src/widgets/SchemaEditorWidget/index.js +484 -0
  256. package/dist/src/widgets/SettingsPanelWidget/index.d.ts +3 -0
  257. package/dist/src/widgets/SettingsPanelWidget/index.js +190 -0
  258. package/dist/src/widgets/StorageActionsWidget/index.d.ts +2 -0
  259. package/dist/src/widgets/StorageActionsWidget/index.js +284 -0
  260. package/dist/src/widgets/index.d.ts +13 -0
  261. package/dist/src/widgets/index.js +13 -0
  262. package/package.json +100 -4
@@ -0,0 +1,346 @@
1
+ import { visitFormilySchemaNodes } from "../shared/schema.js";
2
+ import { isObjectRecord, pushRuntimeIssue, RUNTIME_EXPRESSION_PATTERN, } from "./document-core.js";
3
+ export const isRuntimeSchemaExpression = (value) => (/^\s*\{\{[\s\S]*\}\}\s*$/.test(value));
4
+ export const validateRuntimeStaticComponentNames = (value, issues, path) => {
5
+ visitFormilySchemaNodes(value, path, ({ node, path: nodePath }) => {
6
+ ['x-component', 'x-decorator'].forEach((propertyName) => {
7
+ const componentName = node[propertyName];
8
+ if (typeof componentName === 'string'
9
+ && isRuntimeSchemaExpression(componentName)) {
10
+ pushRuntimeIssue(issues, 'invalid-runtime-document', `${nodePath}.${propertyName}`, `${propertyName} 不支持动态表达式,Runtime v1 只允许静态注册组件名`);
11
+ }
12
+ else if (typeof componentName === 'string'
13
+ && componentName.trim() !== componentName) {
14
+ pushRuntimeIssue(issues, 'invalid-runtime-document', `${nodePath}.${propertyName}`, `${propertyName} 静态组件名不能包含首尾空白`);
15
+ }
16
+ });
17
+ });
18
+ };
19
+ export const RUNTIME_EXPRESSION_FORBIDDEN_SYNTAX = /(?:=>|`|[;{}()]|\+\+|--|\b(?:await|class|delete|function|import|new|yield)\b|(?:^|[^=!<>])=(?:[^=]|$))/;
20
+ export const RUNTIME_EXPRESSION_ALLOWED_PUNCTUATION = new Set('.[]?!<>=&|:+-*/%,');
21
+ export const RUNTIME_AUTO_NETWORK_PROP_KEYS = new Set([
22
+ 'fallback',
23
+ 'poster',
24
+ 'src',
25
+ 'srcSet',
26
+ 'thumbUrl',
27
+ ]);
28
+ export const RUNTIME_COMPONENT_AUTO_NETWORK_PROP_KEYS = {
29
+ Avatar: new Set(['value']),
30
+ Empty: new Set(['image']),
31
+ Image: new Set(['image', 'value']),
32
+ QRCode: new Set(['icon']),
33
+ Upload: new Set(['url']),
34
+ };
35
+ export const RUNTIME_FIELD_VALUE_AUTO_NETWORK_COMPONENTS = new Set([
36
+ 'Avatar',
37
+ 'Image',
38
+ ]);
39
+ export const RUNTIME_REACTION_FIELD_VALUE_KEYS = new Set([
40
+ 'initialValue',
41
+ 'value',
42
+ ]);
43
+ export const RUNTIME_FORM_CALLABLE_PATHS = new Set(['feedbackIcons', 'requiredMark']);
44
+ export const RUNTIME_INPUT_COUNT_CALLABLE_PATHS = new Set([
45
+ 'count.exceedFormatter',
46
+ 'count.show',
47
+ 'count.strategy',
48
+ ]);
49
+ export const RUNTIME_TABS_INDICATOR_CALLABLE_PATHS = new Set(['indicator.size']);
50
+ export const RUNTIME_CARD_TABS_CALLABLE_PATHS = new Set(['tabProps.indicator.size']);
51
+ export const RUNTIME_SAFE_NATIVE_COMPONENT_TAGS = new Set([
52
+ 'article',
53
+ 'aside',
54
+ 'div',
55
+ 'footer',
56
+ 'header',
57
+ 'main',
58
+ 'nav',
59
+ 'section',
60
+ 'span',
61
+ ]);
62
+ export const RUNTIME_COMPONENT_CALLABLE_EXPRESSION_PROP_PATHS = {
63
+ Card: RUNTIME_CARD_TABS_CALLABLE_PATHS,
64
+ Cascader: new Set(['showSearch.sort']),
65
+ ColorPicker: new Set(['showText']),
66
+ DatePicker: new Set(['components', 'format']),
67
+ DateRangePicker: new Set(['components', 'format']),
68
+ Form: RUNTIME_FORM_CALLABLE_PATHS,
69
+ FormLayout: RUNTIME_FORM_CALLABLE_PATHS,
70
+ Image: new Set(['preview.getContainer']),
71
+ Input: RUNTIME_INPUT_COUNT_CALLABLE_PATHS,
72
+ InputSearch: RUNTIME_INPUT_COUNT_CALLABLE_PATHS,
73
+ I18nEditor: new Set(['InContent', 'OutContent']),
74
+ Object: RUNTIME_CARD_TABS_CALLABLE_PATHS,
75
+ Password: RUNTIME_INPUT_COUNT_CALLABLE_PATHS,
76
+ QRCode: new Set(['statusRender']),
77
+ Rate: new Set(['character']),
78
+ Select: new Set(['menuItemSelectedIcon']),
79
+ Tabs: RUNTIME_TABS_INDICATOR_CALLABLE_PATHS,
80
+ FormTab: RUNTIME_TABS_INDICATOR_CALLABLE_PATHS,
81
+ Text: new Set(['copyable.text']),
82
+ TextArea: RUNTIME_INPUT_COUNT_CALLABLE_PATHS,
83
+ TimePicker: new Set(['components', 'format']),
84
+ TimeRangePicker: new Set(['components', 'format']),
85
+ Transfer: new Set(['children', 'footer', 'listStyle', 'selectAllLabels']),
86
+ TreeSelect: new Set(['switcherIcon']),
87
+ Upload: new Set([
88
+ 'showUploadList.downloadIcon',
89
+ 'showUploadList.extra',
90
+ 'showUploadList.previewIcon',
91
+ 'showUploadList.removeIcon',
92
+ 'showUploadList.showDownloadIcon',
93
+ 'showUploadList.showPreviewIcon',
94
+ 'showUploadList.showRemoveIcon',
95
+ ]),
96
+ };
97
+ export const RUNTIME_COMPONENT_CALLABLE_EXPRESSION_PROP_KEY_PATHS = {
98
+ DatePicker: { presets: new Set(['value']) },
99
+ DateRangePicker: { presets: new Set(['value']) },
100
+ TimePicker: { presets: new Set(['value']) },
101
+ TimeRangePicker: { presets: new Set(['value']) },
102
+ };
103
+ export const RUNTIME_DECORATOR_CALLABLE_EXPRESSION_PROP_PATHS = {
104
+ FormItem: new Set([
105
+ 'getValueFromEvent',
106
+ 'getValueProps',
107
+ 'normalize',
108
+ 'shouldUpdate',
109
+ 'tooltip',
110
+ ]),
111
+ };
112
+ export const RUNTIME_DECORATOR_CALLABLE_EXPRESSION_PROP_KEY_PATHS = {
113
+ FormItem: { rules: new Set(['transform', 'validator']) },
114
+ };
115
+ export const RUNTIME_SCHEMA_CALLABLE_EXPRESSION_KEYS = new Set(['validator']);
116
+ export const RUNTIME_CALLABLE_EXPRESSION_PROP_KEYS = new Set([
117
+ 'afterClose',
118
+ 'beforeUpload',
119
+ 'cellRender',
120
+ 'classNames',
121
+ 'component',
122
+ 'customRequest',
123
+ 'disabledDate',
124
+ 'disabledHours',
125
+ 'disabledMinutes',
126
+ 'disabledSeconds',
127
+ 'disabledTime',
128
+ 'displayRender',
129
+ 'dropdownRender',
130
+ 'expandIcon',
131
+ 'filter',
132
+ 'filterOption',
133
+ 'filterSort',
134
+ 'filterTreeNode',
135
+ 'formatter',
136
+ 'getCalendarContainer',
137
+ 'getPopupContainer',
138
+ 'iconRender',
139
+ 'imageRender',
140
+ 'isImageUrl',
141
+ 'itemRender',
142
+ 'labelRender',
143
+ 'loadData',
144
+ 'maxTagPlaceholder',
145
+ 'optionRender',
146
+ 'panelRender',
147
+ 'parser',
148
+ 'popupRender',
149
+ 'previewFile',
150
+ 'ref',
151
+ 'render',
152
+ 'renderExtraFooter',
153
+ 'renderTabBar',
154
+ 'rowKey',
155
+ 'tagRender',
156
+ 'toolbarRender',
157
+ 'treeTitleRender',
158
+ 'validateSearch',
159
+ ]);
160
+ export const RUNTIME_STYLE_PROP_TREE_KEYS = new Set(['style', 'styles']);
161
+ export const RUNTIME_DATA_KEY_FORBIDDEN_SEGMENTS = new Set([
162
+ '__proto__',
163
+ 'constructor',
164
+ 'prototype',
165
+ ]);
166
+ export const isAllowedRuntimeDataKeyPath = (dataKey) => {
167
+ if (!dataKey)
168
+ return true;
169
+ const segments = dataKey.split('.');
170
+ if (segments.some(segment => (!/^[\p{L}\p{N}_$-]+$/u.test(segment)
171
+ || RUNTIME_DATA_KEY_FORBIDDEN_SEGMENTS.has(segment))))
172
+ return false;
173
+ const [root, second] = segments;
174
+ return ((['dict', 'extInfo', 'values'].includes(root) && segments.length >= 2)
175
+ || root === 'listData'
176
+ || (root === 'response' && second === 'data'));
177
+ };
178
+ export const hasOnlyRuntimeDataExpressionCharacters = (expression) => ([...expression].every(character => (/[\s\p{L}\p{N}_$]/u.test(character)
179
+ || RUNTIME_EXPRESSION_ALLOWED_PUNCTUATION.has(character))));
180
+ export const maskRuntimeExpressionStrings = (expression) => {
181
+ let quote;
182
+ let escaped = false;
183
+ let masked = '';
184
+ for (const character of expression) {
185
+ if (quote) {
186
+ masked += ' ';
187
+ if (escaped) {
188
+ escaped = false;
189
+ }
190
+ else if (character === '\\') {
191
+ escaped = true;
192
+ }
193
+ else if (character === quote) {
194
+ quote = undefined;
195
+ }
196
+ continue;
197
+ }
198
+ if (character === '"' || character === '\'') {
199
+ quote = character;
200
+ masked += ' ';
201
+ continue;
202
+ }
203
+ masked += character;
204
+ }
205
+ return quote ? undefined : masked;
206
+ };
207
+ export const isAllowedRuntimeDataExpression = (value) => {
208
+ const match = RUNTIME_EXPRESSION_PATTERN.exec(value);
209
+ if (!match)
210
+ return true;
211
+ const masked = maskRuntimeExpressionStrings(match[1]);
212
+ return Boolean(masked
213
+ && !RUNTIME_EXPRESSION_FORBIDDEN_SYNTAX.test(masked)
214
+ && hasOnlyRuntimeDataExpressionCharacters(masked));
215
+ };
216
+ export const getRuntimePropPathValue = (value, propertyPath) => propertyPath.split('.').reduce((current, segment) => (isObjectRecord(current) ? current[segment] : undefined), value);
217
+ export const findRuntimeSchemaExpressionPaths = (value, path) => {
218
+ if (typeof value === 'string') {
219
+ return isRuntimeSchemaExpression(value) ? [path] : [];
220
+ }
221
+ if (Array.isArray(value)) {
222
+ return value.flatMap((item, index) => (findRuntimeSchemaExpressionPaths(item, `${path}[${index}]`)));
223
+ }
224
+ if (!isObjectRecord(value))
225
+ return [];
226
+ return Object.entries(value).flatMap(([key, child]) => (findRuntimeSchemaExpressionPaths(child, `${path}.${key}`)));
227
+ };
228
+ export const findRuntimeDirectExpressionPaths = (value, path) => {
229
+ if (typeof value === 'string') {
230
+ return isRuntimeSchemaExpression(value) ? [path] : [];
231
+ }
232
+ if (!Array.isArray(value))
233
+ return [];
234
+ return value.flatMap((item, index) => (findRuntimeDirectExpressionPaths(item, `${path}[${index}]`)));
235
+ };
236
+ export const findRuntimeNonEmptyStringKeyPaths = (value, path, stringKeys) => {
237
+ if (Array.isArray(value)) {
238
+ return value.flatMap((item, index) => (findRuntimeNonEmptyStringKeyPaths(item, `${path}[${index}]`, stringKeys)));
239
+ }
240
+ if (!isObjectRecord(value))
241
+ return [];
242
+ return Object.entries(value).flatMap(([key, child]) => {
243
+ const childPath = `${path}.${key}`;
244
+ if (stringKeys.has(key) && typeof child === 'string' && child.trim()) {
245
+ return [childPath];
246
+ }
247
+ return findRuntimeNonEmptyStringKeyPaths(child, childPath, stringKeys);
248
+ });
249
+ };
250
+ export const findRuntimeCallableKeyExpressionPaths = (value, path, callableKeys) => {
251
+ if (Array.isArray(value)) {
252
+ return value.flatMap((item, index) => (findRuntimeCallableKeyExpressionPaths(item, `${path}[${index}]`, callableKeys)));
253
+ }
254
+ if (!isObjectRecord(value))
255
+ return [];
256
+ return Object.entries(value).flatMap(([key, child]) => {
257
+ const childPath = `${path}.${key}`;
258
+ return callableKeys.has(key)
259
+ ? findRuntimeSchemaExpressionPaths(child, childPath)
260
+ : findRuntimeCallableKeyExpressionPaths(child, childPath, callableKeys);
261
+ });
262
+ };
263
+ export const validateRuntimeCallablePropPaths = (value, propertyPaths, path, issues) => {
264
+ propertyPaths?.forEach((propertyPath) => {
265
+ const propertyValue = getRuntimePropPathValue(value, propertyPath);
266
+ findRuntimeSchemaExpressionPaths(propertyValue, `${path}.${propertyPath}`).forEach((expressionPath) => {
267
+ pushRuntimeIssue(issues, 'invalid-runtime-document', expressionPath, 'Runtime v1 表达式只允许无调用、无赋值的数据读取,事件能力必须由受信组件提供');
268
+ });
269
+ });
270
+ };
271
+ export const validateRuntimeCallablePropKeyPaths = (value, propertyKeyPaths, path, issues) => {
272
+ Object.entries(propertyKeyPaths ?? {}).forEach(([propertyPath, callableKeys]) => {
273
+ const propertyValue = getRuntimePropPathValue(value, propertyPath);
274
+ findRuntimeCallableKeyExpressionPaths(propertyValue, `${path}.${propertyPath}`, callableKeys).forEach((expressionPath) => {
275
+ pushRuntimeIssue(issues, 'invalid-runtime-document', expressionPath, 'Runtime v1 表达式只允许无调用、无赋值的数据读取,事件能力必须由受信组件提供');
276
+ });
277
+ });
278
+ };
279
+ export const validateRuntimeExpressionCapabilities = (value, issues, path, key = '') => {
280
+ if (/^on[A-Z]/.test(key) && value !== undefined) {
281
+ pushRuntimeIssue(issues, 'invalid-runtime-document', path, 'Runtime 文档不能声明事件属性,事件能力必须由受信组件提供');
282
+ return;
283
+ }
284
+ if (Array.isArray(value)) {
285
+ value.forEach((item, index) => {
286
+ validateRuntimeExpressionCapabilities(item, issues, `${path}[${index}]`);
287
+ });
288
+ return;
289
+ }
290
+ if (typeof value === 'string' && isRuntimeSchemaExpression(value)) {
291
+ if (!isAllowedRuntimeDataExpression(value)
292
+ || RUNTIME_CALLABLE_EXPRESSION_PROP_KEYS.has(key)) {
293
+ pushRuntimeIssue(issues, 'invalid-runtime-document', path, 'Runtime v1 表达式只允许无调用、无赋值的数据读取,事件能力必须由受信组件提供');
294
+ }
295
+ return;
296
+ }
297
+ if (!isObjectRecord(value))
298
+ return;
299
+ Object.entries(value).forEach(([childKey, child]) => {
300
+ validateRuntimeExpressionCapabilities(child, issues, `${path}.${childKey}`, childKey);
301
+ });
302
+ };
303
+ export const validateRuntimeDesignableIds = (value, issues, path) => {
304
+ const seenIds = new Set();
305
+ const visitConvertedNode = (node, nodePath) => {
306
+ const { 'x-designable-id': id } = node;
307
+ if (id !== undefined) {
308
+ if (typeof id !== 'string' || !id.trim() || id !== id.trim()) {
309
+ pushRuntimeIssue(issues, 'invalid-runtime-document', `${nodePath}.x-designable-id`, 'x-designable-id 必须是无首尾空白的非空字符串');
310
+ }
311
+ else if (seenIds.has(id)) {
312
+ pushRuntimeIssue(issues, 'invalid-runtime-document', `${nodePath}.x-designable-id`, `x-designable-id ${id} 重复`);
313
+ }
314
+ else {
315
+ seenIds.add(id);
316
+ }
317
+ }
318
+ const { properties } = node;
319
+ if (isObjectRecord(properties)) {
320
+ Object.entries(properties).forEach(([key, child]) => {
321
+ if (isObjectRecord(child)) {
322
+ visitConvertedNode(child, `${nodePath}.properties.${key}`);
323
+ }
324
+ });
325
+ }
326
+ const { items } = node;
327
+ if (Array.isArray(items)) {
328
+ items.forEach((child, index) => {
329
+ if (isObjectRecord(child)) {
330
+ visitConvertedNode(child, `${nodePath}.items[${index}]`);
331
+ }
332
+ });
333
+ }
334
+ else if (isObjectRecord(items)) {
335
+ visitConvertedNode(items, `${nodePath}.items`);
336
+ }
337
+ };
338
+ const { properties } = value;
339
+ if (isObjectRecord(properties)) {
340
+ Object.entries(properties).forEach(([key, child]) => {
341
+ if (isObjectRecord(child)) {
342
+ visitConvertedNode(child, `${path}.properties.${key}`);
343
+ }
344
+ });
345
+ }
346
+ };
@@ -0,0 +1,34 @@
1
+ import type { IRuntimeDocumentValidationIssue } from "./document-core.js";
2
+ export declare const findUnsafeRuntimeHtmlPath: (value: unknown, path: string) => string | undefined;
3
+ export declare const findRuntimeAutoNetworkExpressionPaths: (value: unknown, path: string, inStyleTree?: boolean, componentPropKeys?: ReadonlySet<string>) => string[];
4
+ export declare const findRuntimeReactionSchemaPatches: (value: unknown, path: string) => Array<{
5
+ path: string;
6
+ state?: unknown;
7
+ statePath: string;
8
+ value: unknown;
9
+ }>;
10
+ export declare const findRuntimeReactionStateBranches: (value: unknown, path: string) => Array<{
11
+ schema?: unknown;
12
+ state: Record<string, unknown>;
13
+ statePath: string;
14
+ }>;
15
+ export declare const resolveRuntimeLocalSchemaReference: (schemaRoot: unknown, reference: string) => Record<string, unknown> | undefined;
16
+ export interface IRuntimeSchemaAuditNameResolution {
17
+ declared: boolean;
18
+ name?: string;
19
+ }
20
+ export declare const normalizeRuntimeComponentAuditName: (componentName: string | undefined) => string | undefined;
21
+ export declare const resolveRuntimeReferencedSchemaAuditName: (schemaRoot: unknown, node: Record<string, unknown>, propertyName: "x-component" | "x-decorator", visited: Set<Record<string, unknown>>) => IRuntimeSchemaAuditNameResolution;
22
+ export declare const resolveRuntimeSchemaAuditName: (schemaRoot: unknown, node: Record<string, unknown>, propertyName: "x-component" | "x-decorator", inheritedName: string | undefined, allowInherited: boolean) => string | undefined;
23
+ export declare const mergeRuntimeSchemaPatch: (base: unknown, patch: unknown) => unknown;
24
+ export declare const resolveRuntimeSchemaAuditNode: (schemaRoot: unknown, node: Record<string, unknown>, visited?: Set<Record<string, unknown>>) => Record<string, unknown>;
25
+ export declare const findRuntimeReactionFieldValueExpressionPaths: (value: unknown, path: string) => string[];
26
+ export declare const findRuntimeReactionValidatorExpressionPaths: (value: unknown, path: string) => string[];
27
+ export declare const createRuntimeSchemaNodeAuditSnapshot: (node: Record<string, unknown>) => {
28
+ [x: string]: unknown;
29
+ };
30
+ export declare const validateRuntimeComponentSecurity: (value: unknown, issues: IRuntimeDocumentValidationIssue[], path: string, inheritedContext?: {
31
+ componentName?: string;
32
+ decoratorName?: string;
33
+ schemaRoot?: unknown;
34
+ }) => void;