react-native-boost 0.6.0 → 0.6.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.web.js","sources":["../../src/runtime/index.web.ts"],"sourcesContent":["// This is a dummy file to ensure that nothing breaks when using the runtime in a web environment.\n\nimport { TextStyle } from 'react-native';\nimport { GenericStyleProp } from './types';\n\nexport function flattenTextStyle(style: GenericStyleProp<TextStyle>) {\n if (!style) return {};\n\n return { style };\n}\n\n// Maps the `userSelect` prop to the native `selectable` prop\nexport const userSelectToSelectableMap = {\n auto: true,\n text: true,\n none: false,\n contain: true,\n all: true,\n};\n\n// Maps the `verticalAlign` prop to the native `textAlignVertical` prop\nexport const verticalAlignToTextAlignVerticalMap = {\n auto: 'auto',\n top: 'top',\n bottom: 'bottom',\n middle: 'center',\n};\n\n/**\n * Normalizes accessibility props.\n *\n * @param props - The props to normalize.\n * @returns The normalized props.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function normalizeAccessibilityProperties(props: Record<string, any>): Record<string, any> {\n return props;\n}\n\nexport * from './types';\n\n// On Web, the native components are not available, so we use the standard components that'll be replaced by their DOM\n// equivalents by react-native-web.\n/* eslint-disable @typescript-eslint/no-require-imports,unicorn/prefer-module */\nexport const NativeText = require('react-native').Text;\nexport const NativeView = require('react-native').View;\n/* eslint-enable @typescript-eslint/no-require-imports,unicorn/prefer-module */\n"],"names":[],"mappings":";;AAKO,SAAS,iBAAiB,KAAoC,EAAA;AACnE,EAAI,IAAA,CAAC,KAAO,EAAA,OAAO,EAAC;AAEpB,EAAA,OAAO,EAAE,KAAM,EAAA;AACjB;AAGO,MAAM,yBAA4B,GAAA;AAAA,EACvC,IAAM,EAAA,IAAA;AAAA,EACN,IAAM,EAAA,IAAA;AAAA,EACN,IAAM,EAAA,KAAA;AAAA,EACN,OAAS,EAAA,IAAA;AAAA,EACT,GAAK,EAAA;AACP;AAGO,MAAM,mCAAsC,GAAA;AAAA,EACjD,IAAM,EAAA,MAAA;AAAA,EACN,GAAK,EAAA,KAAA;AAAA,EACL,MAAQ,EAAA,QAAA;AAAA,EACR,MAAQ,EAAA;AACV;AASO,SAAS,iCAAiC,KAAiD,EAAA;AAChG,EAAO,OAAA,KAAA;AACT;AAOa,MAAA,UAAA,GAAa,OAAQ,CAAA,cAAc,CAAE,CAAA;AACrC,MAAA,UAAA,GAAa,OAAQ,CAAA,cAAc,CAAE,CAAA;;;;;;;;;"}
1
+ {"version":3,"file":"index.web.js","sources":["../../src/runtime/utils/constants.ts","../../src/runtime/index.web.ts"],"sourcesContent":["// Maps the `userSelect` prop to the native `selectable` prop\nexport const userSelectToSelectableMap = {\n auto: true,\n text: true,\n none: false,\n contain: true,\n all: true,\n};\n\n// Maps the `verticalAlign` prop to the native `textAlignVertical` prop\nexport const verticalAlignToTextAlignVerticalMap = {\n auto: 'auto',\n top: 'top',\n bottom: 'bottom',\n middle: 'center',\n};\n","// This is a dummy file to ensure that nothing breaks when using the runtime in a web environment.\n\nimport { TextProps, TextStyle } from 'react-native';\nimport { GenericStyleProp } from './types';\n\nexport const processTextStyle = (style: GenericStyleProp<TextStyle>) => ({ style }) as Partial<TextProps>;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function processAccessibilityProps(props: Record<string, any>): Record<string, any> {\n return props;\n}\n\nexport * from './types';\nexport * from './utils/constants';\n\n// On Web, the native components are not available, so we use the standard components that'll be replaced by their DOM\n// equivalents by react-native-web.\n/* eslint-disable @typescript-eslint/no-require-imports,unicorn/prefer-module */\nexport const NativeText = require('react-native').Text;\nexport const NativeView = require('react-native').View;\n/* eslint-enable @typescript-eslint/no-require-imports,unicorn/prefer-module */\n"],"names":[],"mappings":";;AACO,MAAM,yBAA4B,GAAA;AAAA,EACvC,IAAM,EAAA,IAAA;AAAA,EACN,IAAM,EAAA,IAAA;AAAA,EACN,IAAM,EAAA,KAAA;AAAA,EACN,OAAS,EAAA,IAAA;AAAA,EACT,GAAK,EAAA;AACP;AAGO,MAAM,mCAAsC,GAAA;AAAA,EACjD,IAAM,EAAA,MAAA;AAAA,EACN,GAAK,EAAA,KAAA;AAAA,EACL,MAAQ,EAAA,QAAA;AAAA,EACR,MAAQ,EAAA;AACV;;ACVO,MAAM,gBAAmB,GAAA,CAAC,KAAwC,MAAA,EAAE,KAAM,EAAA;AAG1E,SAAS,0BAA0B,KAAiD,EAAA;AACzF,EAAO,OAAA,KAAA;AACT;AAQa,MAAA,UAAA,GAAa,OAAQ,CAAA,cAAc,CAAE,CAAA;AACrC,MAAA,UAAA,GAAa,OAAQ,CAAA,cAAc,CAAE,CAAA;;;;;;;;;"}
package/package.json CHANGED
@@ -1,19 +1,12 @@
1
1
  {
2
2
  "name": "react-native-boost",
3
3
  "description": "🚀 Boost your React Native app's performance with a single line of code",
4
- "version": "0.6.0",
4
+ "version": "0.6.2",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/esm/index.mjs",
7
7
  "types": "dist/index.d.ts",
8
8
  "exports": {
9
9
  "./package.json": "./package.json",
10
- ".": {
11
- "import": {
12
- "types": "./dist/index.d.ts",
13
- "default": "./dist/esm/index.mjs"
14
- },
15
- "default": "./dist/index.js"
16
- },
17
10
  "./runtime": {
18
11
  "import": {
19
12
  "types": "./dist/runtime/index.d.ts",
@@ -174,9 +174,9 @@ function processProps(
174
174
  // Set up the accessibility import
175
175
  const normalizeIdentifier = addFileImportHint({
176
176
  file,
177
- nameHint: 'normalizeAccessibilityProps',
177
+ nameHint: 'processAccessibilityProps',
178
178
  path,
179
- importName: 'normalizeAccessibilityProps',
179
+ importName: 'processAccessibilityProps',
180
180
  moduleName: RUNTIME_MODULE_NAME,
181
181
  });
182
182
  const accessibilityObject = buildPropertiesFromAttributes(accessibilityAttributes);
@@ -185,9 +185,9 @@ function processProps(
185
185
  // Set up the style import
186
186
  const flattenIdentifier = addFileImportHint({
187
187
  file,
188
- nameHint: 'flattenTextStyle',
188
+ nameHint: 'processTextStyle',
189
189
  path,
190
- importName: 'flattenTextStyle',
190
+ importName: 'processTextStyle',
191
191
  moduleName: RUNTIME_MODULE_NAME,
192
192
  });
193
193
  const flattenedStyleExpr = t.callExpression(t.identifier(flattenIdentifier.name), [styleExpr]);
@@ -198,9 +198,9 @@ function processProps(
198
198
  // Only style attribute is present
199
199
  const flattenIdentifier = addFileImportHint({
200
200
  file,
201
- nameHint: 'flattenTextStyle',
201
+ nameHint: 'processTextStyle',
202
202
  path,
203
- importName: 'flattenTextStyle',
203
+ importName: 'processTextStyle',
204
204
  moduleName: RUNTIME_MODULE_NAME,
205
205
  });
206
206
  const flattened = t.callExpression(t.identifier(flattenIdentifier.name), [styleExpr]);
@@ -209,9 +209,9 @@ function processProps(
209
209
  // Only accessibility properties are present
210
210
  const normalizeIdentifier = addFileImportHint({
211
211
  file,
212
- nameHint: 'normalizeAccessibilityProps',
212
+ nameHint: 'processAccessibilityProps',
213
213
  path,
214
- importName: 'normalizeAccessibilityProps',
214
+ importName: 'processAccessibilityProps',
215
215
  moduleName: RUNTIME_MODULE_NAME,
216
216
  });
217
217
  const propsObject = buildPropertiesFromAttributes(originalAttributes);
@@ -42,12 +42,12 @@ export type HubFile = t.File & {
42
42
  */
43
43
  export interface FileImportOptions {
44
44
  file: HubFile;
45
- /** The name hint which also acts as the cache key to ensure the import is only added once (e.g. 'normalizeAccessibilityProps') */
45
+ /** The name hint which also acts as the cache key to ensure the import is only added once (e.g. 'processAccessibilityProps') */
46
46
  nameHint: string;
47
47
  /** The current Babel NodePath */
48
48
  path: NodePath;
49
49
  /**
50
- * The named import string (e.g. 'normalizeAccessibilityProps'). Ignored if importType is "default".
50
+ * The named import string (e.g. 'processAccessibilityProps'). Ignored if importType is "default".
51
51
  */
52
52
  importName: string;
53
53
  /** The module to import from (e.g. 'react-native-boost/runtime') */
@@ -8,9 +8,9 @@ import { RUNTIME_MODULE_NAME } from '../constants';
8
8
  *
9
9
  * @param opts - Object containing the function arguments:
10
10
  * - file: The Babel file object (e.g. HubFile)
11
- * - nameHint: The name hint which also acts as the cache key to ensure the import is only added once (e.g. 'normalizeAccessibilityProps')
11
+ * - nameHint: The name hint which also acts as the cache key to ensure the import is only added once (e.g. 'processAccessibilityProps')
12
12
  * - path: The current Babel NodePath
13
- * - importName: The named import string (e.g. 'normalizeAccessibilityProps'), used when importType is 'named'
13
+ * - importName: The named import string (e.g. 'processAccessibilityProps'), used when importType is 'named'
14
14
  * - moduleName: The module to import from (e.g. 'react-native-boost/runtime')
15
15
  * - importType: Either 'named' (default) or 'default' to determine the type of import to use.
16
16
  *
@@ -1,10 +1,10 @@
1
- import { TextStyle } from 'react-native';
2
- import flattenStyle from 'react-native/Libraries/StyleSheet/flattenStyle';
1
+ import { TextProps, TextStyle, StyleSheet } from 'react-native';
3
2
  import { GenericStyleProp } from './types';
3
+ import { userSelectToSelectableMap, verticalAlignToTextAlignVerticalMap } from './utils/constants';
4
4
 
5
5
  const propsCache = new WeakMap();
6
6
 
7
- export function flattenTextStyle(style: GenericStyleProp<TextStyle>) {
7
+ export function processTextStyle(style: GenericStyleProp<TextStyle>): Partial<TextProps> {
8
8
  if (!style) return {};
9
9
 
10
10
  // Cache the computed props
@@ -14,7 +14,7 @@ export function flattenTextStyle(style: GenericStyleProp<TextStyle>) {
14
14
  props = {};
15
15
  propsCache.set(style, props);
16
16
 
17
- style = flattenStyle(style);
17
+ style = StyleSheet.flatten(style) as TextStyle;
18
18
 
19
19
  if (!style) return {};
20
20
 
@@ -38,31 +38,8 @@ export function flattenTextStyle(style: GenericStyleProp<TextStyle>) {
38
38
  return props;
39
39
  }
40
40
 
41
- // Maps the `userSelect` prop to the native `selectable` prop
42
- export const userSelectToSelectableMap = {
43
- auto: true,
44
- text: true,
45
- none: false,
46
- contain: true,
47
- all: true,
48
- };
49
-
50
- // Maps the `verticalAlign` prop to the native `textAlignVertical` prop
51
- export const verticalAlignToTextAlignVerticalMap = {
52
- auto: 'auto',
53
- top: 'top',
54
- bottom: 'bottom',
55
- middle: 'center',
56
- };
57
-
58
- /**
59
- * Normalizes accessibility props.
60
- *
61
- * @param props - The props to normalize.
62
- * @returns The normalized props.
63
- */
64
41
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
65
- export function normalizeAccessibilityProperties(props: Record<string, any>): Record<string, any> {
42
+ export function processAccessibilityProps(props: Record<string, any>): Record<string, any> {
66
43
  const {
67
44
  accessibilityLabel,
68
45
  ['aria-label']: ariaLabel,
@@ -112,5 +89,6 @@ export function normalizeAccessibilityProperties(props: Record<string, any>): Re
112
89
  }
113
90
 
114
91
  export * from './types';
92
+ export * from './utils/constants';
115
93
  export * from './components/native-text';
116
94
  export * from './components/native-view';
@@ -1,43 +1,17 @@
1
1
  // This is a dummy file to ensure that nothing breaks when using the runtime in a web environment.
2
2
 
3
- import { TextStyle } from 'react-native';
3
+ import { TextProps, TextStyle } from 'react-native';
4
4
  import { GenericStyleProp } from './types';
5
5
 
6
- export function flattenTextStyle(style: GenericStyleProp<TextStyle>) {
7
- if (!style) return {};
6
+ export const processTextStyle = (style: GenericStyleProp<TextStyle>) => ({ style }) as Partial<TextProps>;
8
7
 
9
- return { style };
10
- }
11
-
12
- // Maps the `userSelect` prop to the native `selectable` prop
13
- export const userSelectToSelectableMap = {
14
- auto: true,
15
- text: true,
16
- none: false,
17
- contain: true,
18
- all: true,
19
- };
20
-
21
- // Maps the `verticalAlign` prop to the native `textAlignVertical` prop
22
- export const verticalAlignToTextAlignVerticalMap = {
23
- auto: 'auto',
24
- top: 'top',
25
- bottom: 'bottom',
26
- middle: 'center',
27
- };
28
-
29
- /**
30
- * Normalizes accessibility props.
31
- *
32
- * @param props - The props to normalize.
33
- * @returns The normalized props.
34
- */
35
8
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
- export function normalizeAccessibilityProperties(props: Record<string, any>): Record<string, any> {
9
+ export function processAccessibilityProps(props: Record<string, any>): Record<string, any> {
37
10
  return props;
38
11
  }
39
12
 
40
13
  export * from './types';
14
+ export * from './utils/constants';
41
15
 
42
16
  // On Web, the native components are not available, so we use the standard components that'll be replaced by their DOM
43
17
  // equivalents by react-native-web.
@@ -1,9 +1,3 @@
1
- declare module 'react-native/Libraries/StyleSheet/flattenStyle' {
2
- type GenericStyleProp<T> = null | void | T | false | '' | ReadonlyArray<GenericStyleProp<T>>;
3
-
4
- export default function flattenStyle<T>(style: T): T extends GenericStyleProp<infer U> ? U : never;
5
- }
6
-
7
1
  declare module 'react-native/Libraries/Text/TextNativeComponent' {
8
2
  export const NativeText: React.ComponentType<TextProps>;
9
3
  }
@@ -0,0 +1,16 @@
1
+ // Maps the `userSelect` prop to the native `selectable` prop
2
+ export const userSelectToSelectableMap = {
3
+ auto: true,
4
+ text: true,
5
+ none: false,
6
+ contain: true,
7
+ all: true,
8
+ };
9
+
10
+ // Maps the `verticalAlign` prop to the native `textAlignVertical` prop
11
+ export const verticalAlignToTextAlignVerticalMap = {
12
+ auto: 'auto',
13
+ top: 'top',
14
+ bottom: 'bottom',
15
+ middle: 'center',
16
+ };