@niibase/uniwind 1.6.2 → 1.6.4
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/CHANGELOG.md +45 -0
- package/dist/common/common/utils.js +9 -2
- package/dist/common/components/index.js +0 -3
- package/dist/common/core/config/config.common.js +10 -7
- package/dist/common/core/config/config.js +42 -23
- package/dist/common/core/config/config.native.js +1 -3
- package/dist/common/core/web/cssListener.js +1 -1
- package/dist/common/hooks/useCSSVariable/index.js +7 -11
- package/dist/common/hooks/useCSSVariable/useCSSVariable.js +22 -23
- package/dist/metro/index.cjs +10 -4
- package/dist/metro/index.mjs +11 -5
- package/dist/metro/metro-transformer.cjs +15 -4
- package/dist/metro/metro-transformer.mjs +15 -4
- package/dist/module/common/utils.d.ts +1 -0
- package/dist/module/common/utils.js +6 -0
- package/dist/module/components/index.js +0 -3
- package/dist/module/core/config/config.common.d.ts +3 -1
- package/dist/module/core/config/config.common.js +7 -4
- package/dist/module/core/config/config.d.ts +4 -4
- package/dist/module/core/config/config.js +44 -25
- package/dist/module/core/config/config.native.js +1 -3
- package/dist/module/core/web/cssListener.js +1 -1
- package/dist/module/hooks/useCSSVariable/index.d.ts +1 -1
- package/dist/module/hooks/useCSSVariable/index.js +1 -1
- package/dist/module/hooks/useCSSVariable/useCSSVariable.d.ts +4 -2
- package/dist/module/hooks/useCSSVariable/useCSSVariable.js +19 -21
- package/package.json +3 -3
- package/src/common/utils.ts +8 -0
- package/src/components/index.ts +0 -3
- package/src/core/config/config.common.ts +9 -7
- package/src/core/config/config.native.ts +1 -3
- package/src/core/config/config.ts +61 -29
- package/src/core/logger.ts +0 -2
- package/src/core/native/parsers/transforms.ts +0 -1
- package/src/core/native/store.ts +0 -1
- package/src/core/web/cssListener.ts +2 -3
- package/src/hoc/withUniwind.native.tsx +0 -1
- package/src/hooks/useCSSVariable/index.ts +1 -1
- package/src/hooks/useCSSVariable/useCSSVariable.ts +27 -31
- package/src/metro/addMetaToStylesTemplate.ts +1 -2
- package/src/metro/logger.ts +0 -2
- package/src/metro/metro-css-patches.ts +1 -2
- package/src/metro/metro-transformer.ts +1 -1
- package/src/metro/processor/css.ts +0 -1
- package/src/metro/processor/functions.ts +0 -1
- package/src/metro/processor/rn.ts +19 -0
- package/src/metro/resolvers.ts +12 -13
- package/src/metro/utils/common.ts +0 -1
- package/src/metro/utils/serialize.ts +0 -1
- package/src/types.ts +0 -1
|
@@ -239,7 +239,6 @@ export class Functions {
|
|
|
239
239
|
.replace(/"/g, '')
|
|
240
240
|
.replace(new RegExp(unit, 'g'), '')
|
|
241
241
|
|
|
242
|
-
// eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func
|
|
243
242
|
return new Function(`return ${numericValue} + '${unit}'`)()
|
|
244
243
|
} catch {
|
|
245
244
|
this.logger.error(`Invalid calc ${value}`)
|
|
@@ -231,6 +231,7 @@ const cssToRNMap: Record<string, (value: any) => Record<string, any>> = {
|
|
|
231
231
|
|
|
232
232
|
const BORDER_WIDTH_KEYS = ['borderTopWidth', 'borderRightWidth', 'borderBottomWidth', 'borderLeftWidth']
|
|
233
233
|
const BORDER_COLOR_KEYS = ['borderTopColor', 'borderRightColor', 'borderBottomColor', 'borderLeftColor']
|
|
234
|
+
const BORDER_RADIUS_KEYS = ['borderTopLeftRadius', 'borderTopRightRadius', 'borderBottomLeftRadius', 'borderBottomRightRadius']
|
|
234
235
|
|
|
235
236
|
export class RN {
|
|
236
237
|
constructor(private readonly Processor: ProcessorBuilder) {}
|
|
@@ -249,6 +250,12 @@ export class RN {
|
|
|
249
250
|
.replace('Block', 'Vertical')
|
|
250
251
|
}
|
|
251
252
|
|
|
253
|
+
if (x.includes('border')) {
|
|
254
|
+
return x
|
|
255
|
+
.replace('InlineStart', 'Start')
|
|
256
|
+
.replace('InlineEnd', 'End')
|
|
257
|
+
}
|
|
258
|
+
|
|
252
259
|
return x
|
|
253
260
|
},
|
|
254
261
|
)
|
|
@@ -382,6 +389,18 @@ export class RN {
|
|
|
382
389
|
}
|
|
383
390
|
}
|
|
384
391
|
|
|
392
|
+
if (BORDER_RADIUS_KEYS.every(key => keys.includes(key))) {
|
|
393
|
+
const borderRadius = styles.borderTopLeftRadius
|
|
394
|
+
|
|
395
|
+
// Join border radius
|
|
396
|
+
if (BORDER_RADIUS_KEYS.every(key => styles[key] === borderRadius)) {
|
|
397
|
+
return {
|
|
398
|
+
...removeKeys(styles, BORDER_RADIUS_KEYS),
|
|
399
|
+
borderRadius,
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
385
404
|
return styles
|
|
386
405
|
}
|
|
387
406
|
}
|
package/src/metro/resolvers.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CustomResolutionContext, CustomResolver } from 'metro-resolver'
|
|
2
|
-
import { basename, dirname,
|
|
2
|
+
import { basename, dirname, sep } from 'node:path'
|
|
3
3
|
import { name } from '../../package.json'
|
|
4
4
|
|
|
5
5
|
type ResolverConfig = {
|
|
@@ -47,12 +47,11 @@ export const nativeResolver = (extraComponents: Record<string, string>) =>
|
|
|
47
47
|
const resolution = resolver(context, moduleName, platform)
|
|
48
48
|
|
|
49
49
|
if (cachedInternalBasePath === null) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
: ''
|
|
50
|
+
try {
|
|
51
|
+
cachedInternalBasePath = dirname(require.resolve(`${name}/package.json`))
|
|
52
|
+
} catch {
|
|
53
|
+
cachedInternalBasePath = ''
|
|
54
|
+
}
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
const isInternal = cachedInternalBasePath !== '' && context.originModulePath.startsWith(cachedInternalBasePath)
|
|
@@ -106,13 +105,13 @@ export const webResolver = (extraComponents: Record<string, string>) =>
|
|
|
106
105
|
const resolution = resolver(context, moduleName, platform)
|
|
107
106
|
|
|
108
107
|
if (cachedInternalBasePath === null) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
: ''
|
|
108
|
+
try {
|
|
109
|
+
cachedInternalBasePath = dirname(require.resolve(`${name}/package.json`))
|
|
110
|
+
} catch {
|
|
111
|
+
cachedInternalBasePath = ''
|
|
112
|
+
}
|
|
115
113
|
}
|
|
114
|
+
|
|
116
115
|
if (
|
|
117
116
|
(cachedInternalBasePath !== '' && context.originModulePath.startsWith(cachedInternalBasePath))
|
|
118
117
|
|| resolution.type !== 'sourceFile'
|
|
@@ -52,7 +52,6 @@ export const uniq = <T>(arr: Array<T>) => Array.from(new Set(arr))
|
|
|
52
52
|
|
|
53
53
|
export const isValidJSValue = (jsValueString: string) => {
|
|
54
54
|
try {
|
|
55
|
-
// eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func
|
|
56
55
|
new Function(`const test = ${jsValueString}`)
|
|
57
56
|
|
|
58
57
|
return true
|
|
@@ -103,7 +103,6 @@ export const serializeJSObject = (obj: Record<string, any>, serializer: (key: st
|
|
|
103
103
|
serializedValues =>
|
|
104
104
|
serializedValues.filter(serializedValue => {
|
|
105
105
|
try {
|
|
106
|
-
// eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func
|
|
107
106
|
new Function(`function validateJS() { const obj = ({ ${serializedValue} }) }`)
|
|
108
107
|
|
|
109
108
|
return true
|