react-native-boost 0.5.7 → 0.6.0

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.
@@ -0,0 +1,25 @@
1
+ function flattenTextStyle(style) {
2
+ if (!style) return {};
3
+ return { style };
4
+ }
5
+ const userSelectToSelectableMap = {
6
+ auto: true,
7
+ text: true,
8
+ none: false,
9
+ contain: true,
10
+ all: true
11
+ };
12
+ const verticalAlignToTextAlignVerticalMap = {
13
+ auto: "auto",
14
+ top: "top",
15
+ bottom: "bottom",
16
+ middle: "center"
17
+ };
18
+ function normalizeAccessibilityProperties(props) {
19
+ return props;
20
+ }
21
+ const NativeText = require("react-native").Text;
22
+ const NativeView = require("react-native").View;
23
+
24
+ export { NativeText, NativeView, flattenTextStyle, normalizeAccessibilityProperties, userSelectToSelectableMap, verticalAlignToTextAlignVerticalMap };
25
+ //# sourceMappingURL=index.web.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.web.mjs","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;;;;"}
@@ -2,11 +2,11 @@ import { TextStyle } from 'react-native';
2
2
 
3
3
  type GenericStyleProp<T> = null | void | T | false | '' | ReadonlyArray<GenericStyleProp<T>>;
4
4
 
5
- declare const NativeText: any;
6
-
7
- declare const NativeView: any;
8
-
9
- declare function flattenTextStyle(style: GenericStyleProp<TextStyle>): any;
5
+ declare function flattenTextStyle(style: GenericStyleProp<TextStyle>): {
6
+ style?: undefined;
7
+ } | {
8
+ style: TextStyle | readonly GenericStyleProp<TextStyle>[];
9
+ };
10
10
  declare const userSelectToSelectableMap: {
11
11
  auto: boolean;
12
12
  text: boolean;
@@ -28,4 +28,7 @@ declare const verticalAlignToTextAlignVerticalMap: {
28
28
  */
29
29
  declare function normalizeAccessibilityProperties(props: Record<string, any>): Record<string, any>;
30
30
 
31
+ declare const NativeText: any;
32
+ declare const NativeView: any;
33
+
31
34
  export { type GenericStyleProp, NativeText, NativeView, flattenTextStyle, normalizeAccessibilityProperties, userSelectToSelectableMap, verticalAlignToTextAlignVerticalMap };
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ function flattenTextStyle(style) {
4
+ if (!style) return {};
5
+ return { style };
6
+ }
7
+ const userSelectToSelectableMap = {
8
+ auto: true,
9
+ text: true,
10
+ none: false,
11
+ contain: true,
12
+ all: true
13
+ };
14
+ const verticalAlignToTextAlignVerticalMap = {
15
+ auto: "auto",
16
+ top: "top",
17
+ bottom: "bottom",
18
+ middle: "center"
19
+ };
20
+ function normalizeAccessibilityProperties(props) {
21
+ return props;
22
+ }
23
+ const NativeText = require("react-native").Text;
24
+ const NativeView = require("react-native").View;
25
+
26
+ exports.NativeText = NativeText;
27
+ exports.NativeView = NativeView;
28
+ exports.flattenTextStyle = flattenTextStyle;
29
+ exports.normalizeAccessibilityProperties = normalizeAccessibilityProperties;
30
+ exports.userSelectToSelectableMap = userSelectToSelectableMap;
31
+ exports.verticalAlignToTextAlignVerticalMap = verticalAlignToTextAlignVerticalMap;
32
+ //# sourceMappingURL=index.web.js.map
@@ -0,0 +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;;;;;;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
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.5.7",
4
+ "version": "0.6.0",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/esm/index.mjs",
7
7
  "types": "dist/index.d.ts",
@@ -0,0 +1,47 @@
1
+ // This is a dummy file to ensure that nothing breaks when using the runtime in a web environment.
2
+
3
+ import { TextStyle } from 'react-native';
4
+ import { GenericStyleProp } from './types';
5
+
6
+ export function flattenTextStyle(style: GenericStyleProp<TextStyle>) {
7
+ if (!style) return {};
8
+
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
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
+ export function normalizeAccessibilityProperties(props: Record<string, any>): Record<string, any> {
37
+ return props;
38
+ }
39
+
40
+ export * from './types';
41
+
42
+ // On Web, the native components are not available, so we use the standard components that'll be replaced by their DOM
43
+ // equivalents by react-native-web.
44
+ /* eslint-disable @typescript-eslint/no-require-imports,unicorn/prefer-module */
45
+ export const NativeText = require('react-native').Text;
46
+ export const NativeView = require('react-native').View;
47
+ /* eslint-enable @typescript-eslint/no-require-imports,unicorn/prefer-module */
@@ -1,84 +0,0 @@
1
- import flattenStyle from 'react-native/Libraries/StyleSheet/flattenStyle';
2
- import { Platform } from 'react-native';
3
-
4
- const NativeText = Platform.OS === "web" ? require("react-native").Text : require("react-native/Libraries/Text/TextNativeComponent").NativeText;
5
-
6
- const NativeView = Platform.OS === "web" ? require("react-native").View : require("react-native/Libraries/Components/View/ViewNativeComponent").default;
7
-
8
- const propsCache = /* @__PURE__ */ new WeakMap();
9
- function flattenTextStyle(style) {
10
- if (!style) return {};
11
- let props = propsCache.get(style);
12
- if (props) return props;
13
- props = {};
14
- propsCache.set(style, props);
15
- style = flattenStyle(style);
16
- if (!style) return {};
17
- if (typeof (style == null ? void 0 : style.fontWeight) === "number") {
18
- style.fontWeight = style.fontWeight.toString();
19
- }
20
- if ((style == null ? void 0 : style.userSelect) != null) {
21
- props.selectable = userSelectToSelectableMap[style.userSelect];
22
- delete style.userSelect;
23
- }
24
- if ((style == null ? void 0 : style.verticalAlign) != null) {
25
- style.textAlignVertical = verticalAlignToTextAlignVerticalMap[style.verticalAlign];
26
- delete style.verticalAlign;
27
- }
28
- props.style = style;
29
- return props;
30
- }
31
- const userSelectToSelectableMap = {
32
- auto: true,
33
- text: true,
34
- none: false,
35
- contain: true,
36
- all: true
37
- };
38
- const verticalAlignToTextAlignVerticalMap = {
39
- auto: "auto",
40
- top: "top",
41
- bottom: "bottom",
42
- middle: "center"
43
- };
44
- function normalizeAccessibilityProperties(props) {
45
- const {
46
- accessibilityLabel,
47
- ["aria-label"]: ariaLabel,
48
- accessibilityState,
49
- ["aria-busy"]: ariaBusy,
50
- ["aria-checked"]: ariaChecked,
51
- ["aria-disabled"]: ariaDisabled,
52
- ["aria-expanded"]: ariaExpanded,
53
- ["aria-selected"]: ariaSelected,
54
- accessible,
55
- ...restProperties
56
- } = props;
57
- const normalizedLabel = ariaLabel != null ? ariaLabel : accessibilityLabel;
58
- let normalizedState = accessibilityState;
59
- if (ariaBusy != null || ariaChecked != null || ariaDisabled != null || ariaExpanded != null || ariaSelected != null) {
60
- normalizedState = normalizedState == null ? {
61
- busy: ariaBusy,
62
- checked: ariaChecked,
63
- disabled: ariaDisabled,
64
- expanded: ariaExpanded,
65
- selected: ariaSelected
66
- } : {
67
- busy: ariaBusy != null ? ariaBusy : normalizedState.busy,
68
- checked: ariaChecked != null ? ariaChecked : normalizedState.checked,
69
- disabled: ariaDisabled != null ? ariaDisabled : normalizedState.disabled,
70
- expanded: ariaExpanded != null ? ariaExpanded : normalizedState.expanded,
71
- selected: ariaSelected != null ? ariaSelected : normalizedState.selected
72
- };
73
- }
74
- const normalizedAccessible = accessible == null ? true : accessible;
75
- return {
76
- ...restProperties,
77
- accessibilityLabel: normalizedLabel,
78
- accessibilityState: normalizedState,
79
- accessible: normalizedAccessible
80
- };
81
- }
82
-
83
- export { NativeText, NativeView, flattenTextStyle, normalizeAccessibilityProperties, userSelectToSelectableMap, verticalAlignToTextAlignVerticalMap };
84
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/runtime/components/native-text.tsx","../../src/runtime/components/native-view.tsx","../../src/runtime/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-require-imports,unicorn/prefer-module */\nimport { Platform } from 'react-native';\n\nexport const NativeText =\n Platform.OS === 'web'\n ? require('react-native').Text\n : require('react-native/Libraries/Text/TextNativeComponent').NativeText;\n","/* eslint-disable @typescript-eslint/no-require-imports,unicorn/prefer-module */\nimport { Platform } from 'react-native';\n\nexport const NativeView =\n Platform.OS === 'web'\n ? require('react-native').View\n : require('react-native/Libraries/Components/View/ViewNativeComponent').default;\n","import { TextStyle } from 'react-native';\nimport flattenStyle from 'react-native/Libraries/StyleSheet/flattenStyle';\nimport { GenericStyleProp } from './types';\n\nconst propsCache = new WeakMap();\n\nexport function flattenTextStyle(style: GenericStyleProp<TextStyle>) {\n if (!style) return {};\n\n // Cache the computed props\n let props = propsCache.get(style);\n if (props) return props;\n\n props = {};\n propsCache.set(style, props);\n\n style = flattenStyle(style);\n\n if (!style) return {};\n\n if (typeof style?.fontWeight === 'number') {\n style.fontWeight = style.fontWeight.toString() as TextStyle['fontWeight'];\n }\n\n if (style?.userSelect != null) {\n props.selectable = userSelectToSelectableMap[style.userSelect];\n delete style.userSelect;\n }\n\n if (style?.verticalAlign != null) {\n style.textAlignVertical = verticalAlignToTextAlignVerticalMap[\n style.verticalAlign\n ] as TextStyle['textAlignVertical'];\n delete style.verticalAlign;\n }\n\n props.style = style;\n return props;\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 const {\n accessibilityLabel,\n ['aria-label']: ariaLabel,\n accessibilityState,\n ['aria-busy']: ariaBusy,\n ['aria-checked']: ariaChecked,\n ['aria-disabled']: ariaDisabled,\n ['aria-expanded']: ariaExpanded,\n ['aria-selected']: ariaSelected,\n accessible,\n ...restProperties\n } = props;\n\n // Merge label props: prefer the aria-label if defined.\n const normalizedLabel = ariaLabel ?? accessibilityLabel;\n\n // Merge the accessibilityState with any provided ARIA properties.\n let normalizedState = accessibilityState;\n if (ariaBusy != null || ariaChecked != null || ariaDisabled != null || ariaExpanded != null || ariaSelected != null) {\n normalizedState =\n normalizedState == null\n ? {\n busy: ariaBusy,\n checked: ariaChecked,\n disabled: ariaDisabled,\n expanded: ariaExpanded,\n selected: ariaSelected,\n }\n : {\n busy: ariaBusy ?? normalizedState.busy,\n checked: ariaChecked ?? normalizedState.checked,\n disabled: ariaDisabled ?? normalizedState.disabled,\n expanded: ariaExpanded ?? normalizedState.expanded,\n selected: ariaSelected ?? normalizedState.selected,\n };\n }\n\n // For the accessible prop, if not provided, default to `true`\n const normalizedAccessible = accessible == null ? true : accessible;\n\n return {\n ...restProperties,\n accessibilityLabel: normalizedLabel,\n accessibilityState: normalizedState,\n accessible: normalizedAccessible,\n };\n}\n\nexport * from './types';\nexport * from './components/native-text';\nexport * from './components/native-view';\n"],"names":[],"mappings":";;;AAGa,MAAA,UAAA,GACX,QAAS,CAAA,EAAA,KAAO,KACZ,GAAA,OAAA,CAAQ,cAAc,CAAE,CA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Ae,eAAgB,CAAA,OAAA;AAAA,MACxC,QAAA,EAAU,sCAAgB,eAAgB,CAAA,QAAA;AAAA,MAC1C,QAAA,EAAU,sCAAgB,eAAgB,CAAA,QAAA;AAAA,MAC1C,QAAA,EAAU,sCAAgB,eAAgB,CAAA;AAAA,KAC5C;AAAA;AAIR,EAAM,MAAA,oBAAA,GAAuB,UAAc,IAAA,IAAA,GAAO,IAAO,GAAA,UAAA;AAEzD,EAAO,OAAA;AAAA,IACL,GAAG,cAAA;AAAA,IACH,kBAAoB,EAAA,eAAA;AAAA,IACpB,kBAAoB,EAAA,eAAA;AAAA,IACpB,UAAY,EAAA;AAAA,GACd;AACF;;;;"}
package/dist/index.js DELETED
@@ -1,91 +0,0 @@
1
- 'use strict';
2
-
3
- var flattenStyle = require('react-native/Libraries/StyleSheet/flattenStyle');
4
- var reactNative = require('react-native');
5
-
6
- const NativeText = reactNative.Platform.OS === "web" ? require("react-native").Text : require("react-native/Libraries/Text/TextNativeComponent").NativeText;
7
-
8
- const NativeView = reactNative.Platform.OS === "web" ? require("react-native").View : require("react-native/Libraries/Components/View/ViewNativeComponent").default;
9
-
10
- const propsCache = /* @__PURE__ */ new WeakMap();
11
- function flattenTextStyle(style) {
12
- if (!style) return {};
13
- let props = propsCache.get(style);
14
- if (props) return props;
15
- props = {};
16
- propsCache.set(style, props);
17
- style = flattenStyle(style);
18
- if (!style) return {};
19
- if (typeof (style == null ? void 0 : style.fontWeight) === "number") {
20
- style.fontWeight = style.fontWeight.toString();
21
- }
22
- if ((style == null ? void 0 : style.userSelect) != null) {
23
- props.selectable = userSelectToSelectableMap[style.userSelect];
24
- delete style.userSelect;
25
- }
26
- if ((style == null ? void 0 : style.verticalAlign) != null) {
27
- style.textAlignVertical = verticalAlignToTextAlignVerticalMap[style.verticalAlign];
28
- delete style.verticalAlign;
29
- }
30
- props.style = style;
31
- return props;
32
- }
33
- const userSelectToSelectableMap = {
34
- auto: true,
35
- text: true,
36
- none: false,
37
- contain: true,
38
- all: true
39
- };
40
- const verticalAlignToTextAlignVerticalMap = {
41
- auto: "auto",
42
- top: "top",
43
- bottom: "bottom",
44
- middle: "center"
45
- };
46
- function normalizeAccessibilityProperties(props) {
47
- const {
48
- accessibilityLabel,
49
- ["aria-label"]: ariaLabel,
50
- accessibilityState,
51
- ["aria-busy"]: ariaBusy,
52
- ["aria-checked"]: ariaChecked,
53
- ["aria-disabled"]: ariaDisabled,
54
- ["aria-expanded"]: ariaExpanded,
55
- ["aria-selected"]: ariaSelected,
56
- accessible,
57
- ...restProperties
58
- } = props;
59
- const normalizedLabel = ariaLabel != null ? ariaLabel : accessibilityLabel;
60
- let normalizedState = accessibilityState;
61
- if (ariaBusy != null || ariaChecked != null || ariaDisabled != null || ariaExpanded != null || ariaSelected != null) {
62
- normalizedState = normalizedState == null ? {
63
- busy: ariaBusy,
64
- checked: ariaChecked,
65
- disabled: ariaDisabled,
66
- expanded: ariaExpanded,
67
- selected: ariaSelected
68
- } : {
69
- busy: ariaBusy != null ? ariaBusy : normalizedState.busy,
70
- checked: ariaChecked != null ? ariaChecked : normalizedState.checked,
71
- disabled: ariaDisabled != null ? ariaDisabled : normalizedState.disabled,
72
- expanded: ariaExpanded != null ? ariaExpanded : normalizedState.expanded,
73
- selected: ariaSelected != null ? ariaSelected : normalizedState.selected
74
- };
75
- }
76
- const normalizedAccessible = accessible == null ? true : accessible;
77
- return {
78
- ...restProperties,
79
- accessibilityLabel: normalizedLabel,
80
- accessibilityState: normalizedState,
81
- accessible: normalizedAccessible
82
- };
83
- }
84
-
85
- exports.NativeText = NativeText;
86
- exports.NativeView = NativeView;
87
- exports.flattenTextStyle = flattenTextStyle;
88
- exports.normalizeAccessibilityProperties = normalizeAccessibilityProperties;
89
- exports.userSelectToSelectableMap = userSelectToSelectableMap;
90
- exports.verticalAlignToTextAlignVerticalMap = verticalAlignToTextAlignVerticalMap;
91
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../src/runtime/components/native-text.tsx","../src/runtime/components/native-view.tsx","../src/runtime/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-require-imports,unicorn/prefer-module */\nimport { Platform } from 'react-native';\n\nexport const NativeText =\n Platform.OS === 'web'\n ? require('react-native').Text\n : require('react-native/Libraries/Text/TextNativeComponent').NativeText;\n","/* eslint-disable @typescript-eslint/no-require-imports,unicorn/prefer-module */\nimport { Platform } from 'react-native';\n\nexport const NativeView =\n Platform.OS === 'web'\n ? require('react-native').View\n : require('react-native/Libraries/Components/View/ViewNativeComponent').default;\n","import { TextStyle } from 'react-native';\nimport flattenStyle from 'react-native/Libraries/StyleSheet/flattenStyle';\nimport { GenericStyleProp } from './types';\n\nconst propsCache = new WeakMap();\n\nexport function flattenTextStyle(style: GenericStyleProp<TextStyle>) {\n if (!style) return {};\n\n // Cache the computed props\n let props = propsCache.get(style);\n if (props) return props;\n\n props = {};\n propsCache.set(style, props);\n\n style = flattenStyle(style);\n\n if (!style) return {};\n\n if (typeof style?.fontWeight === 'number') {\n style.fontWeight = style.fontWeight.toString() as TextStyle['fontWeight'];\n }\n\n if (style?.userSelect != null) {\n props.selectable = userSelectToSelectableMap[style.userSelect];\n delete style.userSelect;\n }\n\n if (style?.verticalAlign != null) {\n style.textAlignVertical = verticalAlignToTextAlignVerticalMap[\n style.verticalAlign\n ] as TextStyle['textAlignVertical'];\n delete style.verticalAlign;\n }\n\n props.style = style;\n return props;\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 const {\n accessibilityLabel,\n ['aria-label']: ariaLabel,\n accessibilityState,\n ['aria-busy']: ariaBusy,\n ['aria-checked']: ariaChecked,\n ['aria-disabled']: ariaDisabled,\n ['aria-expanded']: ariaExpanded,\n ['aria-selected']: ariaSelected,\n accessible,\n ...restProperties\n } = props;\n\n // Merge label props: prefer the aria-label if defined.\n const normalizedLabel = ariaLabel ?? accessibilityLabel;\n\n // Merge the accessibilityState with any provided ARIA properties.\n let normalizedState = accessibilityState;\n if (ariaBusy != null || ariaChecked != null || ariaDisabled != null || ariaExpanded != null || ariaSelected != null) {\n normalizedState =\n normalizedState == null\n ? {\n busy: ariaBusy,\n checked: ariaChecked,\n disabled: ariaDisabled,\n expanded: ariaExpanded,\n selected: ariaSelected,\n }\n : {\n busy: ariaBusy ?? normalizedState.busy,\n checked: ariaChecked ?? normalizedState.checked,\n disabled: ariaDisabled ?? normalizedState.disabled,\n expanded: ariaExpanded ?? normalizedState.expanded,\n selected: ariaSelected ?? normalizedState.selected,\n };\n }\n\n // For the accessible prop, if not provided, default to `true`\n const normalizedAccessible = accessible == null ? true : accessible;\n\n return {\n ...restProperties,\n accessibilityLabel: normalizedLabel,\n accessibilityState: normalizedState,\n accessible: normalizedAccessible,\n };\n}\n\nexport * from './types';\nexport * from './components/native-text';\nexport * from './components/native-view';\n"],"names":["Platform"],"mappings":";;;;;AAGa,MAAA,UAAA,GACXA,oBAAS,CAAA,EAAA,KAAO,KACZ,GAAA,OAAA,CAAQ,cAAc,CAAE,CAAA,IAAA,GACxB,OAAQ,CAAA,iDAAiD,CAAE,CAAA;;ACHpD,MAAA,UAAA,GACXA,oBAAS,CAAA,EAAA,KAAO,KACZ,GAAA,OAAA,CAAQ,cAAc,CAAE,CAAA,IAAA,GACxB,OAAQ,CAAA,4DAA4D,CAAE,CAAA;;ACF5E,MAAM,UAAA,uBAAiB,OAAQ,EAAA;AAExB,SAAS,iBAAiB,KAAoC,EAAA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