@mpxjs/webpack-plugin 2.9.59 → 2.9.64

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 (115) hide show
  1. package/lib/index.js +1 -3
  2. package/lib/platform/style/wx/index.js +344 -270
  3. package/lib/platform/template/wx/component-config/checkbox-group.js +8 -0
  4. package/lib/platform/template/wx/component-config/checkbox.js +8 -0
  5. package/lib/platform/template/wx/component-config/cover-image.js +15 -0
  6. package/lib/platform/template/wx/component-config/cover-view.js +9 -0
  7. package/lib/platform/template/wx/component-config/form.js +13 -1
  8. package/lib/platform/template/wx/component-config/icon.js +8 -0
  9. package/lib/platform/template/wx/component-config/index.js +5 -1
  10. package/lib/platform/template/wx/component-config/label.js +15 -0
  11. package/lib/platform/template/wx/component-config/movable-area.js +18 -1
  12. package/lib/platform/template/wx/component-config/movable-view.js +18 -1
  13. package/lib/platform/template/wx/component-config/navigator.js +8 -0
  14. package/lib/platform/template/wx/component-config/picker-view-column.js +8 -0
  15. package/lib/platform/template/wx/component-config/picker-view.js +18 -2
  16. package/lib/platform/template/wx/component-config/picker.js +14 -1
  17. package/lib/platform/template/wx/component-config/radio-group.js +8 -0
  18. package/lib/platform/template/wx/component-config/radio.js +8 -0
  19. package/lib/platform/template/wx/component-config/root-portal.js +15 -0
  20. package/lib/platform/template/wx/component-config/switch.js +8 -0
  21. package/lib/platform/template/wx/component-config/unsupported.js +1 -3
  22. package/lib/react/processScript.js +2 -0
  23. package/lib/react/processStyles.js +1 -0
  24. package/lib/react/processTemplate.js +2 -3
  25. package/lib/react/style-helper.js +12 -7
  26. package/lib/runtime/components/react/context.ts +40 -0
  27. package/lib/runtime/components/react/dist/context.js +8 -0
  28. package/lib/runtime/components/react/dist/getInnerListeners.js +34 -12
  29. package/lib/runtime/components/react/dist/mpx-button.jsx +88 -88
  30. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +82 -0
  31. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +139 -0
  32. package/lib/runtime/components/react/dist/mpx-form.jsx +61 -0
  33. package/lib/runtime/components/react/dist/mpx-icon.jsx +48 -0
  34. package/lib/runtime/components/react/dist/mpx-image/index.jsx +39 -43
  35. package/lib/runtime/components/react/dist/mpx-image/svg.jsx +3 -2
  36. package/lib/runtime/components/react/dist/mpx-input.jsx +63 -37
  37. package/lib/runtime/components/react/dist/mpx-label.jsx +55 -0
  38. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +41 -0
  39. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +346 -0
  40. package/lib/runtime/components/react/dist/mpx-navigator.jsx +35 -0
  41. package/lib/runtime/components/react/dist/mpx-picker/date.jsx +69 -0
  42. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +138 -0
  43. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +142 -0
  44. package/lib/runtime/components/react/dist/mpx-picker/region.jsx +94 -0
  45. package/lib/runtime/components/react/dist/mpx-picker/regionData.js +6099 -0
  46. package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +76 -0
  47. package/lib/runtime/components/react/dist/mpx-picker/time.jsx +244 -0
  48. package/lib/runtime/components/react/dist/mpx-picker/type.js +1 -0
  49. package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +107 -0
  50. package/lib/runtime/components/react/dist/mpx-picker-view.jsx +162 -0
  51. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +80 -0
  52. package/lib/runtime/components/react/dist/mpx-radio.jsx +154 -0
  53. package/lib/runtime/components/react/dist/mpx-root-portal.jsx +15 -0
  54. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +93 -70
  55. package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +281 -157
  56. package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +21 -11
  57. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +19 -11
  58. package/lib/runtime/components/react/dist/mpx-switch.jsx +79 -0
  59. package/lib/runtime/components/react/dist/mpx-text.jsx +21 -49
  60. package/lib/runtime/components/react/dist/mpx-textarea.jsx +2 -2
  61. package/lib/runtime/components/react/dist/mpx-view.jsx +451 -146
  62. package/lib/runtime/components/react/dist/mpx-web-view.jsx +17 -20
  63. package/lib/runtime/components/react/dist/parser.js +218 -0
  64. package/lib/runtime/components/react/dist/types/common.js +1 -0
  65. package/lib/runtime/components/react/dist/useNodesRef.js +3 -8
  66. package/lib/runtime/components/react/dist/utils.jsx +433 -0
  67. package/lib/runtime/components/react/getInnerListeners.ts +43 -21
  68. package/lib/runtime/components/react/mpx-button.tsx +129 -119
  69. package/lib/runtime/components/react/mpx-checkbox-group.tsx +152 -0
  70. package/lib/runtime/components/react/mpx-checkbox.tsx +234 -0
  71. package/lib/runtime/components/react/mpx-form.tsx +117 -0
  72. package/lib/runtime/components/react/mpx-icon.tsx +106 -0
  73. package/lib/runtime/components/react/mpx-image/index.tsx +62 -68
  74. package/lib/runtime/components/react/mpx-image/svg.tsx +7 -5
  75. package/lib/runtime/components/react/mpx-input.tsx +90 -42
  76. package/lib/runtime/components/react/mpx-label.tsx +110 -0
  77. package/lib/runtime/components/react/mpx-movable-area.tsx +81 -0
  78. package/lib/runtime/components/react/mpx-movable-view.tsx +424 -0
  79. package/lib/runtime/components/react/mpx-navigator.tsx +67 -0
  80. package/lib/runtime/components/react/mpx-picker/date.tsx +82 -0
  81. package/lib/runtime/components/react/mpx-picker/index.tsx +155 -0
  82. package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +156 -0
  83. package/lib/runtime/components/react/mpx-picker/region.tsx +107 -0
  84. package/lib/runtime/components/react/mpx-picker/regionData.ts +6101 -0
  85. package/lib/runtime/components/react/mpx-picker/selector.tsx +91 -0
  86. package/lib/runtime/components/react/mpx-picker/time.tsx +270 -0
  87. package/lib/runtime/components/react/mpx-picker/type.ts +107 -0
  88. package/lib/runtime/components/react/mpx-picker-view-column.tsx +156 -0
  89. package/lib/runtime/components/react/mpx-picker-view.tsx +220 -0
  90. package/lib/runtime/components/react/mpx-radio-group.tsx +150 -0
  91. package/lib/runtime/components/react/mpx-radio.tsx +230 -0
  92. package/lib/runtime/components/react/mpx-root-portal.tsx +27 -0
  93. package/lib/runtime/components/react/mpx-scroll-view.tsx +184 -130
  94. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +308 -183
  95. package/lib/runtime/components/react/mpx-swiper/index.tsx +27 -19
  96. package/lib/runtime/components/react/mpx-swiper/type.ts +23 -5
  97. package/lib/runtime/components/react/mpx-swiper-item.tsx +49 -14
  98. package/lib/runtime/components/react/mpx-switch.tsx +148 -0
  99. package/lib/runtime/components/react/mpx-text.tsx +53 -77
  100. package/lib/runtime/components/react/mpx-textarea.tsx +3 -3
  101. package/lib/runtime/components/react/mpx-view.tsx +576 -195
  102. package/lib/runtime/components/react/mpx-web-view.tsx +34 -39
  103. package/lib/runtime/components/react/parser.ts +245 -0
  104. package/lib/runtime/components/react/types/common.ts +12 -0
  105. package/lib/runtime/components/react/types/getInnerListeners.ts +2 -1
  106. package/lib/runtime/components/react/types/global.d.ts +17 -1
  107. package/lib/runtime/components/react/useNodesRef.ts +4 -10
  108. package/lib/runtime/components/react/utils.tsx +505 -0
  109. package/lib/runtime/optionProcessor.js +19 -17
  110. package/lib/template-compiler/compiler.js +84 -61
  111. package/lib/template-compiler/gen-node-react.js +7 -9
  112. package/lib/web/processStyles.js +2 -5
  113. package/package.json +8 -3
  114. package/lib/runtime/components/react/dist/utils.js +0 -80
  115. package/lib/runtime/components/react/utils.ts +0 -92
@@ -1,13 +1,11 @@
1
- import { forwardRef, JSX, useRef, useEffect } from 'react'
2
- // @ts-ignore
3
- import { noop } from '@mpxjs/utils'
1
+ import { forwardRef, JSX, useEffect } from 'react'
2
+ import { noop, warn } from '@mpxjs/utils'
4
3
  import { Portal } from '@ant-design/react-native'
5
4
  import { getCustomEvent } from './getInnerListeners'
6
5
  import { promisify, redirectTo, navigateTo, navigateBack, reLaunch, switchTab } from '@mpxjs/api-proxy'
7
- // @ts-ignore
8
6
  import { WebView } from 'react-native-webview'
9
7
  import useNodesRef, { HandlerRef } from './useNodesRef'
10
- import { StyleSheet } from 'react-native'
8
+ import { WebViewNavigationEvent, WebViewErrorEvent, WebViewMessageEvent } from 'react-native-webview/lib/WebViewTypes'
11
9
 
12
10
  type OnMessageCallbackEvent = {
13
11
  detail: {
@@ -22,10 +20,11 @@ type CommonCallbackEvent = {
22
20
  }
23
21
 
24
22
  interface WebViewProps {
25
- src: string
23
+ src?: string
26
24
  bindmessage?: (event: OnMessageCallbackEvent) => void
27
25
  bindload?: (event: CommonCallbackEvent) => void
28
26
  binderror?: (event: CommonCallbackEvent) => void
27
+ [x: string]: any
29
28
  }
30
29
 
31
30
  interface PayloadData {
@@ -43,33 +42,28 @@ interface NativeEvent {
43
42
  data: string
44
43
  }
45
44
 
46
- interface LoadRes {
47
- timeStamp: string,
48
- nativeEvent: NativeEvent
49
- }
50
-
51
45
  interface FormRef {
52
46
  postMessage: (value: any) => void;
53
47
  }
54
48
 
55
49
  const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((props, ref): JSX.Element => {
56
50
  const { src, bindmessage = noop, bindload = noop, binderror = noop } = props
51
+ if (props.style) {
52
+ warn('The web-view component does not support the style prop.')
53
+ }
54
+ const defaultWebViewStyle = {
55
+ position: 'absolute' as 'absolute' | 'relative' | 'static',
56
+ left: 0 as number,
57
+ right: 0 as number,
58
+ top: 0 as number,
59
+ bottom: 0 as number
60
+ }
57
61
 
58
- const defaultWebViewStyle = [
59
- {
60
- position: 'absolute',
61
- left: 0,
62
- right: 0,
63
- top: 0,
64
- bottom: 0
65
- }
66
- ]
67
62
  const { nodeRef: webViewRef } = useNodesRef<WebView, WebViewProps>(props, ref, {
68
- defaultStyle: StyleSheet.flatten([
69
- ...defaultWebViewStyle
70
- ])
63
+ defaultStyle: defaultWebViewStyle
71
64
  })
72
- const _messageList:any[] = []
65
+
66
+ const _messageList: any[] = []
73
67
  const handleUnload = () => {
74
68
  // 这里是 WebView 销毁前执行的逻辑
75
69
  bindmessage(getCustomEvent('messsage', {}, {
@@ -86,7 +80,7 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
86
80
  handleUnload()
87
81
  }
88
82
  }, [])
89
- const _load = function(res:LoadRes) {
83
+ const _load = function (res: WebViewNavigationEvent) {
90
84
  const result = {
91
85
  type: 'load',
92
86
  timeStamp: res.timeStamp,
@@ -96,7 +90,7 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
96
90
  }
97
91
  bindload(result)
98
92
  }
99
- const _error = function(res:LoadRes) {
93
+ const _error = function (res: WebViewErrorEvent) {
100
94
  const result = {
101
95
  type: 'error',
102
96
  timeStamp: res.timeStamp,
@@ -106,17 +100,19 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
106
100
  }
107
101
  binderror(result)
108
102
  }
109
- const _message = function(res:LoadRes) {
110
- let data: MessageData
103
+ const _message = function (res: WebViewMessageEvent) {
104
+ let data: MessageData = {}
111
105
  let asyncCallback
112
106
  const navObj = promisify({ redirectTo, navigateTo, navigateBack, reLaunch, switchTab })
113
107
  try {
114
108
  const nativeEventData = res.nativeEvent?.data
115
- data = JSON.parse(nativeEventData)
109
+ if (typeof nativeEventData === 'string') {
110
+ data = JSON.parse(nativeEventData)
111
+ }
116
112
  } catch (e) {
117
113
  data = {}
118
114
  }
119
- const postData:PayloadData = data.payload || {}
115
+ const postData: PayloadData = data.payload || {}
120
116
  switch (data.type) {
121
117
  case 'postMessage':
122
118
  _messageList.push(postData.data)
@@ -152,16 +148,15 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
152
148
  }
153
149
  })
154
150
  }
155
- // @ts-ignore
156
- return(<Portal>
151
+ return (<Portal>
157
152
  <WebView
158
- style={[ ...defaultWebViewStyle ]}
159
- source={{ uri: src }}
160
- ref={webViewRef}
161
- onLoad={_load}
162
- onError={_error}
163
- onMessage={_message}
164
- javaScriptEnabled={true}
153
+ style={defaultWebViewStyle}
154
+ source={{ uri: src }}
155
+ ref={webViewRef}
156
+ onLoad={_load}
157
+ onError={_error}
158
+ onMessage={_message}
159
+ javaScriptEnabled={true}
165
160
  ></WebView>
166
161
  </Portal>)
167
162
  })
@@ -0,0 +1,245 @@
1
+ interface Token {
2
+ type: string
3
+ value: string | number
4
+ }
5
+
6
+ interface ExpressionNode {
7
+ type: 'NUMBER'
8
+ value: number
9
+ }
10
+
11
+ export class ExpressionParser {
12
+ private tokens: Token[]
13
+ private formatter: (val: string) => number
14
+ private functions: { [key: string]: (...args: number[]) => number }
15
+ private current: number
16
+
17
+ constructor (input: string, formatter: (val: string) => number = val => parseFloat(val), functions: { [key: string]: (...args: number[]) => number } = {}) {
18
+ this.tokens = this.tokenize(input)
19
+ this.formatter = formatter
20
+ this.functions = functions
21
+ this.current = 0
22
+ }
23
+
24
+ tokenize (input: string): Token[] {
25
+ const tokens: Token[] = []
26
+ const regex = /(\d+\.?\d*(?:px|rpx|%|vw|vh)?|[+\-*/(),]|\b[a-zA-Z_][a-zA-Z0-9_]*\b)/g
27
+ let match: RegExpExecArray | null
28
+ while ((match = regex.exec(input))) {
29
+ if (/^\d+\.?\d*(?:px|rpx|%|vw|vh)?$/.test(match[0])) {
30
+ const lastToken = tokens[tokens.length - 1]
31
+ const last2Token = tokens[tokens.length - 2]
32
+ if (lastToken?.type === '-' && (!last2Token || /^[+\-*/(,]$/.test(last2Token?.type))) {
33
+ tokens.pop()
34
+ tokens.push({
35
+ type: 'NUMBER',
36
+ value: '-' + match[0]
37
+ })
38
+ } else {
39
+ tokens.push({
40
+ type: 'NUMBER',
41
+ value: match[0]
42
+ })
43
+ }
44
+ } else {
45
+ tokens.push({
46
+ type: match[0],
47
+ value: match[0]
48
+ })
49
+ }
50
+ }
51
+ return tokens
52
+ }
53
+
54
+ parse (): ExpressionNode {
55
+ return this.expression()
56
+ }
57
+
58
+ private expression (): ExpressionNode {
59
+ let node = this.term()
60
+ while (this.current < this.tokens.length &&
61
+ (this.tokens[this.current].type === '+' || this.tokens[this.current].type === '-')) {
62
+ const operator = this.tokens[this.current].type
63
+ this.current++
64
+ const right = this.term()
65
+ node = this.applyOperator(operator, node, right)
66
+ }
67
+ return node
68
+ }
69
+
70
+ private term (): ExpressionNode {
71
+ let node = this.factor()
72
+ while (this.current < this.tokens.length &&
73
+ (this.tokens[this.current].type === '*' || this.tokens[this.current].type === '/')) {
74
+ const operator = this.tokens[this.current].type
75
+ this.current++
76
+ const right = this.factor()
77
+ node = this.applyOperator(operator, node, right)
78
+ }
79
+ return node
80
+ }
81
+
82
+ private factor (): ExpressionNode {
83
+ const token = this.tokens[this.current]
84
+ if (token.type === 'NUMBER') {
85
+ this.current++
86
+ const numericValue = this.formatter(token.value as string)
87
+ return { type: 'NUMBER', value: numericValue }
88
+ } else if (token.type === '(') {
89
+ this.current++
90
+ const node = this.expression()
91
+ if (this.tokens[this.current].type !== ')') {
92
+ throw new Error('Expected closing parenthesis')
93
+ }
94
+ this.current++
95
+ return node
96
+ } else if (this.functions[token.type]) {
97
+ this.current++
98
+ if (this.tokens[this.current].type !== '(') {
99
+ throw new Error('Expected opening parenthesis after function')
100
+ }
101
+ this.current++
102
+ const args = this.parseArguments()
103
+ if (this.tokens[this.current].type !== ')') {
104
+ throw new Error('Expected closing parenthesis')
105
+ }
106
+ this.current++
107
+ return this.applyFunction(token.type, args)
108
+ }
109
+ throw new Error(`Unexpected token: ${token.type}`)
110
+ }
111
+
112
+ private parseArguments (): ExpressionNode[] {
113
+ const args: ExpressionNode[] = []
114
+ while (this.current < this.tokens.length && this.tokens[this.current].type !== ')') {
115
+ args.push(this.expression())
116
+ if (this.tokens[this.current].type === ',') {
117
+ this.current++
118
+ }
119
+ }
120
+ return args
121
+ }
122
+
123
+ private applyOperator (operator: string, left: ExpressionNode, right: ExpressionNode): ExpressionNode {
124
+ const leftVal = left.value
125
+ const rightVal = right.value
126
+ let result: number
127
+ switch (operator) {
128
+ case '+': result = leftVal + rightVal; break
129
+ case '-': result = leftVal - rightVal; break
130
+ case '*': result = leftVal * rightVal; break
131
+ case '/': result = leftVal / rightVal; break
132
+ default: throw new Error(`Unknown operator: ${operator}`)
133
+ }
134
+ return { type: 'NUMBER', value: result }
135
+ }
136
+
137
+ private applyFunction (func: string, args: ExpressionNode[]): ExpressionNode {
138
+ if (args.some(arg => arg.type !== 'NUMBER')) {
139
+ throw new Error('Function arguments must be numbers')
140
+ }
141
+ const numericArgs = args.map(arg => arg.value)
142
+ if (this.functions[func]) {
143
+ return { type: 'NUMBER', value: this.functions[func].apply(null, numericArgs) }
144
+ } else {
145
+ throw new Error(`Unknown function: ${func}`)
146
+ }
147
+ }
148
+ }
149
+
150
+ interface FuncInfo {
151
+ start: number
152
+ end: number
153
+ args: string[]
154
+ }
155
+
156
+ export function parseFunc (str: string, funcName: string): FuncInfo[] {
157
+ const regex = new RegExp(`${funcName}\\(`, 'g')
158
+ const result: FuncInfo[] = []
159
+ let match: RegExpExecArray | null
160
+
161
+ while ((match = regex.exec(str)) !== null) {
162
+ const start = match.index
163
+ let i = start + funcName.length + 1
164
+ let depth = 1
165
+ const args: string[] = []
166
+ let arg = ''
167
+
168
+ while (depth && i < str.length) {
169
+ if (depth === 1 && (str[i] === ',' || str[i] === ')')) {
170
+ args.push(arg.trim())
171
+ arg = ''
172
+ } else {
173
+ arg += str[i]
174
+ }
175
+ switch (str[i]) {
176
+ case '(':
177
+ depth++
178
+ break
179
+ case ')':
180
+ depth--
181
+ break
182
+ default:
183
+ // Do nothing
184
+ }
185
+ i++
186
+ }
187
+
188
+ const end = regex.lastIndex = i
189
+ result.push({
190
+ start,
191
+ end,
192
+ args
193
+ })
194
+ }
195
+
196
+ return result
197
+ }
198
+
199
+ interface Replacement {
200
+ start: number
201
+ end: number
202
+ content: string
203
+ }
204
+
205
+ export class ReplaceSource {
206
+ private _source: string
207
+ private _replacements: Replacement[]
208
+
209
+ constructor (source: string) {
210
+ this._source = source
211
+ this._replacements = []
212
+ }
213
+
214
+ replace (start: number, end: number, content: string): void {
215
+ this._replacements.push({ start, end, content })
216
+ }
217
+
218
+ source (): string {
219
+ if (this._replacements.length === 0) {
220
+ return this._source
221
+ }
222
+ let current = this._source
223
+ let pos = 0
224
+ const result: string[] = []
225
+
226
+ for (const replacement of this._replacements) {
227
+ const start = Math.floor(replacement.start)
228
+ const end = Math.floor(replacement.end) + 1
229
+ if (pos < start) {
230
+ const offset = start - pos
231
+ result.push(current.slice(0, offset))
232
+ current = current.slice(offset)
233
+ pos = start
234
+ }
235
+ result.push(replacement.content)
236
+ if (pos < end) {
237
+ const offset = end - pos
238
+ current = current.slice(offset)
239
+ pos = end
240
+ }
241
+ }
242
+ result.push(current)
243
+ return result.join('')
244
+ }
245
+ }
@@ -0,0 +1,12 @@
1
+ import { ViewStyle, ImageResizeMode } from 'react-native'
2
+
3
+ type NumberVal = number | `${number}%`
4
+ type backgroundPositionList = [ 'left'| 'right', NumberVal, 'top' | 'bottom', NumberVal ] | []
5
+
6
+ export type ExtendedViewStyle = ViewStyle & {
7
+ backgroundImage?: string
8
+ backgroundSize?: Array<NumberVal | 'auto' | 'contain' | 'cover'>
9
+ borderRadius?: string | number
10
+ backgroundPosition?: backgroundPositionList
11
+ [key: string]: any
12
+ }
@@ -49,7 +49,8 @@ interface InnerRef {
49
49
  }
50
50
  interface UseInnerPropsConfig {
51
51
  layoutRef: LayoutRef;
52
- disableTouch?: boolean
52
+ disableTouch?: boolean;
53
+ disableTap?: boolean
53
54
  }
54
55
  interface DataSetType {
55
56
  [key: string]: string;
@@ -12,4 +12,20 @@ declare module 'react-native-svg/css' {
12
12
  }
13
13
 
14
14
  export const WithLocalSvg: React.ComponentType<WithLocalSvgProps>
15
- }
15
+ }
16
+
17
+ declare module '@mpxjs/utils' {
18
+ export function isEmptyObject (obj: Object): boolean
19
+ export function hasOwn (obj: Object, key: string): boolean
20
+ export function noop (...arg: any): void
21
+ export function diffAndCloneA<A, B> (a: A, b?: B): {
22
+ clone: A
23
+ diff: boolean
24
+ diffData: Object | null
25
+ }
26
+ export function isObject (value): value is Object
27
+ export function error (msg: string, location?: string, e?: any): void
28
+ export function warn (msg: string, location?: string, e?: any): void
29
+ }
30
+
31
+ declare let global: Record<string, any>
@@ -1,5 +1,4 @@
1
- import { useRef, useEffect, useImperativeHandle, RefObject, ForwardedRef } from 'react'
2
-
1
+ import { useRef, useImperativeHandle, RefObject, ForwardedRef } from 'react'
3
2
 
4
3
  type Obj = Record<string, any>
5
4
 
@@ -11,16 +10,11 @@ export type HandlerRef<T, P> = {
11
10
  }
12
11
  }
13
12
 
14
- export default function useNodesRef<T, P>(props: P, ref: ForwardedRef<HandlerRef<T, P>>, instance:Obj = {} ) {
13
+ export default function useNodesRef<T, P> (props: P, ref: ForwardedRef<HandlerRef<T, P>>, instance:Obj = {}) {
15
14
  const nodeRef = useRef<T>(null)
16
- const _props = useRef<P | null>(props)
15
+ const _props = useRef<P | null>(null)
16
+ _props.current = props
17
17
 
18
- useEffect(() => {
19
- _props.current = props
20
- return () => {
21
- _props.current = null // 组件销毁,清空 _props 依赖数据
22
- }
23
- }, [props])
24
18
  useImperativeHandle(ref, () => {
25
19
  return {
26
20
  getNodeInstance () {