@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.
Files changed (50) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/dist/common/common/utils.js +9 -2
  3. package/dist/common/components/index.js +0 -3
  4. package/dist/common/core/config/config.common.js +10 -7
  5. package/dist/common/core/config/config.js +42 -23
  6. package/dist/common/core/config/config.native.js +1 -3
  7. package/dist/common/core/web/cssListener.js +1 -1
  8. package/dist/common/hooks/useCSSVariable/index.js +7 -11
  9. package/dist/common/hooks/useCSSVariable/useCSSVariable.js +22 -23
  10. package/dist/metro/index.cjs +10 -4
  11. package/dist/metro/index.mjs +11 -5
  12. package/dist/metro/metro-transformer.cjs +15 -4
  13. package/dist/metro/metro-transformer.mjs +15 -4
  14. package/dist/module/common/utils.d.ts +1 -0
  15. package/dist/module/common/utils.js +6 -0
  16. package/dist/module/components/index.js +0 -3
  17. package/dist/module/core/config/config.common.d.ts +3 -1
  18. package/dist/module/core/config/config.common.js +7 -4
  19. package/dist/module/core/config/config.d.ts +4 -4
  20. package/dist/module/core/config/config.js +44 -25
  21. package/dist/module/core/config/config.native.js +1 -3
  22. package/dist/module/core/web/cssListener.js +1 -1
  23. package/dist/module/hooks/useCSSVariable/index.d.ts +1 -1
  24. package/dist/module/hooks/useCSSVariable/index.js +1 -1
  25. package/dist/module/hooks/useCSSVariable/useCSSVariable.d.ts +4 -2
  26. package/dist/module/hooks/useCSSVariable/useCSSVariable.js +19 -21
  27. package/package.json +3 -3
  28. package/src/common/utils.ts +8 -0
  29. package/src/components/index.ts +0 -3
  30. package/src/core/config/config.common.ts +9 -7
  31. package/src/core/config/config.native.ts +1 -3
  32. package/src/core/config/config.ts +61 -29
  33. package/src/core/logger.ts +0 -2
  34. package/src/core/native/parsers/transforms.ts +0 -1
  35. package/src/core/native/store.ts +0 -1
  36. package/src/core/web/cssListener.ts +2 -3
  37. package/src/hoc/withUniwind.native.tsx +0 -1
  38. package/src/hooks/useCSSVariable/index.ts +1 -1
  39. package/src/hooks/useCSSVariable/useCSSVariable.ts +27 -31
  40. package/src/metro/addMetaToStylesTemplate.ts +1 -2
  41. package/src/metro/logger.ts +0 -2
  42. package/src/metro/metro-css-patches.ts +1 -2
  43. package/src/metro/metro-transformer.ts +1 -1
  44. package/src/metro/processor/css.ts +0 -1
  45. package/src/metro/processor/functions.ts +0 -1
  46. package/src/metro/processor/rn.ts +19 -0
  47. package/src/metro/resolvers.ts +12 -13
  48. package/src/metro/utils/common.ts +0 -1
  49. package/src/metro/utils/serialize.ts +0 -1
  50. package/src/types.ts +0 -1
@@ -91,7 +91,7 @@ export const transform = async (
91
91
  isWeb
92
92
  ? virtualCode
93
93
  : [
94
- `import { Uniwind } from '${name}';`,
94
+ `const { Uniwind } = require('${name}');`,
95
95
  `Uniwind.__reinit(rt => ${virtualCode}, ${injectedThemesCode});`,
96
96
  ].join(''),
97
97
  'utf-8',
@@ -590,7 +590,6 @@ export class CSS {
590
590
  return undefined
591
591
  }
592
592
 
593
- // eslint-disable-next-line @typescript-eslint/member-ordering
594
593
  private static readonly TRANSFORM_TYPES = new Set([
595
594
  'translate',
596
595
  'translateX',
@@ -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
  }
@@ -1,5 +1,5 @@
1
1
  import { CustomResolutionContext, CustomResolver } from 'metro-resolver'
2
- import { basename, dirname, join, sep } from 'node:path'
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
- const componentsResolution = resolver(context, `${name}/components`, platform)
51
-
52
- cachedInternalBasePath = componentsResolution.type === 'sourceFile'
53
- // Go from src/components to root
54
- ? join(dirname(componentsResolution.filePath), '../..')
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
- const componentsResolution = resolver(context, `${name}/components`, platform)
110
-
111
- cachedInternalBasePath = componentsResolution.type === 'sourceFile'
112
- // Go from dist/module/components/web to root
113
- ? join(dirname(componentsResolution.filePath), '../../../..')
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
package/src/types.ts CHANGED
@@ -20,5 +20,4 @@ export const enum ColorScheme {
20
20
  Dark = 'dark',
21
21
  }
22
22
 
23
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
24
23
  export interface UniwindConfig {}