@mpxjs/webpack-plugin 2.9.62 → 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.
- package/lib/index.js +1 -3
- package/lib/platform/style/wx/index.js +67 -53
- package/lib/react/processStyles.js +1 -0
- package/lib/react/processTemplate.js +2 -3
- package/lib/react/style-helper.js +12 -7
- package/lib/runtime/components/react/context.ts +9 -7
- package/lib/runtime/components/react/dist/context.js +1 -0
- package/lib/runtime/components/react/dist/getInnerListeners.js +12 -1
- package/lib/runtime/components/react/dist/mpx-button.jsx +52 -74
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +19 -18
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +28 -41
- package/lib/runtime/components/react/dist/mpx-form.jsx +16 -14
- package/lib/runtime/components/react/dist/mpx-icon.jsx +14 -17
- package/lib/runtime/components/react/dist/mpx-image/index.jsx +34 -33
- package/lib/runtime/components/react/dist/mpx-image/svg.jsx +3 -1
- package/lib/runtime/components/react/dist/mpx-input.jsx +35 -31
- package/lib/runtime/components/react/dist/mpx-label.jsx +29 -37
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +13 -18
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +8 -8
- package/lib/runtime/components/react/dist/mpx-picker/index.jsx +9 -9
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +7 -4
- package/lib/runtime/components/react/dist/mpx-picker/region.jsx +11 -7
- package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-picker/time.jsx +18 -18
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +102 -10
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +147 -53
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +19 -18
- package/lib/runtime/components/react/dist/mpx-radio.jsx +28 -43
- package/lib/runtime/components/react/dist/mpx-root-portal.jsx +8 -4
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +33 -26
- package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +139 -74
- package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +14 -6
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +19 -11
- package/lib/runtime/components/react/dist/mpx-switch.jsx +17 -14
- package/lib/runtime/components/react/dist/mpx-text.jsx +19 -35
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-view.jsx +284 -209
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +8 -5
- package/lib/runtime/components/react/dist/parser.js +218 -0
- package/lib/runtime/components/react/dist/utils.jsx +433 -0
- package/lib/runtime/components/react/getInnerListeners.ts +18 -8
- package/lib/runtime/components/react/mpx-button.tsx +81 -91
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +48 -43
- package/lib/runtime/components/react/mpx-checkbox.tsx +52 -63
- package/lib/runtime/components/react/mpx-form.tsx +49 -21
- package/lib/runtime/components/react/mpx-icon.tsx +30 -27
- package/lib/runtime/components/react/mpx-image/index.tsx +52 -46
- package/lib/runtime/components/react/mpx-image/svg.tsx +5 -3
- package/lib/runtime/components/react/mpx-input.tsx +58 -38
- package/lib/runtime/components/react/mpx-label.tsx +54 -59
- package/lib/runtime/components/react/mpx-movable-area.tsx +38 -24
- package/lib/runtime/components/react/mpx-movable-view.tsx +27 -28
- package/lib/runtime/components/react/mpx-navigator.tsx +2 -2
- package/lib/runtime/components/react/mpx-picker/date.tsx +2 -3
- package/lib/runtime/components/react/mpx-picker/index.tsx +10 -10
- package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +15 -12
- package/lib/runtime/components/react/mpx-picker/region.tsx +21 -18
- package/lib/runtime/components/react/mpx-picker/selector.tsx +5 -6
- package/lib/runtime/components/react/mpx-picker/time.tsx +25 -29
- package/lib/runtime/components/react/mpx-picker/type.ts +1 -1
- package/lib/runtime/components/react/mpx-picker-view-column.tsx +148 -20
- package/lib/runtime/components/react/mpx-picker-view.tsx +179 -63
- package/lib/runtime/components/react/mpx-radio-group.tsx +50 -47
- package/lib/runtime/components/react/mpx-radio.tsx +56 -72
- package/lib/runtime/components/react/mpx-root-portal.tsx +10 -8
- package/lib/runtime/components/react/mpx-scroll-view.tsx +133 -103
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +174 -96
- package/lib/runtime/components/react/mpx-swiper/index.tsx +18 -9
- package/lib/runtime/components/react/mpx-swiper/type.ts +16 -5
- package/lib/runtime/components/react/mpx-swiper-item.tsx +46 -13
- package/lib/runtime/components/react/mpx-switch.tsx +44 -23
- package/lib/runtime/components/react/mpx-text.tsx +37 -45
- package/lib/runtime/components/react/mpx-textarea.tsx +1 -1
- package/lib/runtime/components/react/mpx-view.tsx +388 -240
- package/lib/runtime/components/react/mpx-web-view.tsx +19 -20
- package/lib/runtime/components/react/parser.ts +245 -0
- package/lib/runtime/components/react/types/common.ts +4 -4
- package/lib/runtime/components/react/types/global.d.ts +14 -2
- package/lib/runtime/components/react/useNodesRef.ts +1 -2
- package/lib/runtime/components/react/utils.tsx +505 -0
- package/lib/template-compiler/compiler.js +28 -20
- package/lib/template-compiler/gen-node-react.js +1 -3
- package/lib/web/processStyles.js +2 -5
- package/package.json +6 -4
- package/lib/runtime/components/react/dist/utils.js +0 -148
- package/lib/runtime/components/react/utils.ts +0 -170
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { forwardRef, JSX, useEffect } from 'react'
|
|
2
|
-
|
|
3
|
-
import { noop } from '@mpxjs/utils'
|
|
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'
|
|
8
|
+
import { WebViewNavigationEvent, WebViewErrorEvent, WebViewMessageEvent } from 'react-native-webview/lib/WebViewTypes'
|
|
10
9
|
|
|
11
10
|
type OnMessageCallbackEvent = {
|
|
12
11
|
detail: {
|
|
@@ -21,10 +20,11 @@ type CommonCallbackEvent = {
|
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
interface WebViewProps {
|
|
24
|
-
src
|
|
23
|
+
src?: string
|
|
25
24
|
bindmessage?: (event: OnMessageCallbackEvent) => void
|
|
26
25
|
bindload?: (event: CommonCallbackEvent) => void
|
|
27
26
|
binderror?: (event: CommonCallbackEvent) => void
|
|
27
|
+
[x: string]: any
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
interface PayloadData {
|
|
@@ -42,24 +42,21 @@ interface NativeEvent {
|
|
|
42
42
|
data: string
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
interface LoadRes {
|
|
46
|
-
timeStamp: string,
|
|
47
|
-
nativeEvent: NativeEvent
|
|
48
|
-
}
|
|
49
|
-
|
|
50
45
|
interface FormRef {
|
|
51
46
|
postMessage: (value: any) => void;
|
|
52
47
|
}
|
|
53
48
|
|
|
54
49
|
const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((props, ref): JSX.Element => {
|
|
55
50
|
const { src, bindmessage = noop, bindload = noop, binderror = noop } = props
|
|
56
|
-
|
|
51
|
+
if (props.style) {
|
|
52
|
+
warn('The web-view component does not support the style prop.')
|
|
53
|
+
}
|
|
57
54
|
const defaultWebViewStyle = {
|
|
58
|
-
position: 'absolute',
|
|
59
|
-
left: 0,
|
|
60
|
-
right: 0,
|
|
61
|
-
top: 0,
|
|
62
|
-
bottom: 0
|
|
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
|
|
63
60
|
}
|
|
64
61
|
|
|
65
62
|
const { nodeRef: webViewRef } = useNodesRef<WebView, WebViewProps>(props, ref, {
|
|
@@ -83,7 +80,7 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
|
|
|
83
80
|
handleUnload()
|
|
84
81
|
}
|
|
85
82
|
}, [])
|
|
86
|
-
const _load = function (res:
|
|
83
|
+
const _load = function (res: WebViewNavigationEvent) {
|
|
87
84
|
const result = {
|
|
88
85
|
type: 'load',
|
|
89
86
|
timeStamp: res.timeStamp,
|
|
@@ -93,7 +90,7 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
|
|
|
93
90
|
}
|
|
94
91
|
bindload(result)
|
|
95
92
|
}
|
|
96
|
-
const _error = function (res:
|
|
93
|
+
const _error = function (res: WebViewErrorEvent) {
|
|
97
94
|
const result = {
|
|
98
95
|
type: 'error',
|
|
99
96
|
timeStamp: res.timeStamp,
|
|
@@ -103,13 +100,15 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
|
|
|
103
100
|
}
|
|
104
101
|
binderror(result)
|
|
105
102
|
}
|
|
106
|
-
const _message = function (res:
|
|
107
|
-
let data: MessageData
|
|
103
|
+
const _message = function (res: WebViewMessageEvent) {
|
|
104
|
+
let data: MessageData = {}
|
|
108
105
|
let asyncCallback
|
|
109
106
|
const navObj = promisify({ redirectTo, navigateTo, navigateBack, reLaunch, switchTab })
|
|
110
107
|
try {
|
|
111
108
|
const nativeEventData = res.nativeEvent?.data
|
|
112
|
-
|
|
109
|
+
if (typeof nativeEventData === 'string') {
|
|
110
|
+
data = JSON.parse(nativeEventData)
|
|
111
|
+
}
|
|
113
112
|
} catch (e) {
|
|
114
113
|
data = {}
|
|
115
114
|
}
|
|
@@ -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
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ViewStyle, ImageResizeMode} from 'react-native'
|
|
1
|
+
import { ViewStyle, ImageResizeMode } from 'react-native'
|
|
2
2
|
|
|
3
3
|
type NumberVal = number | `${number}%`
|
|
4
|
-
type backgroundPositionList = [ 'left'| 'right', NumberVal, 'top' | 'bottom',
|
|
4
|
+
type backgroundPositionList = [ 'left'| 'right', NumberVal, 'top' | 'bottom', NumberVal ] | []
|
|
5
5
|
|
|
6
6
|
export type ExtendedViewStyle = ViewStyle & {
|
|
7
7
|
backgroundImage?: string
|
|
8
|
-
backgroundSize?: Array<
|
|
8
|
+
backgroundSize?: Array<NumberVal | 'auto' | 'contain' | 'cover'>
|
|
9
9
|
borderRadius?: string | number
|
|
10
10
|
backgroundPosition?: backgroundPositionList
|
|
11
11
|
[key: string]: any
|
|
12
|
-
}
|
|
12
|
+
}
|
|
@@ -15,5 +15,17 @@ declare module 'react-native-svg/css' {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
declare module '@mpxjs/utils' {
|
|
18
|
-
export function isEmptyObject(obj:
|
|
19
|
-
|
|
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,6 +1,5 @@
|
|
|
1
1
|
import { useRef, useImperativeHandle, RefObject, ForwardedRef } from 'react'
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
type Obj = Record<string, any>
|
|
5
4
|
|
|
6
5
|
export type HandlerRef<T, P> = {
|
|
@@ -11,7 +10,7 @@ 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
15
|
const _props = useRef<P | null>(null)
|
|
17
16
|
_props.current = props
|