react-alp-connection-state 6.0.1 → 6.1.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [6.1.0](https://github.com/christophehurpeau/alp/compare/react-alp-connection-state@6.0.1...react-alp-connection-state@6.1.0) (2022-03-05)
7
+
8
+
9
+ ### Features
10
+
11
+ * **react-alp-connection-state:** create cjs version ([8171bc6](https://github.com/christophehurpeau/alp/commit/8171bc62dd38810679ff5297a054e80459d96881))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [6.0.1](https://github.com/christophehurpeau/alp/compare/react-alp-connection-state@6.0.0...react-alp-connection-state@6.0.1) (2022-02-20)
7
18
 
8
19
  **Note:** Version bump only for package react-alp-connection-state
@@ -0,0 +1,115 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var react = require('react');
6
+ var reactNative = require('react-native');
7
+ var jsxRuntime_js = require('react/jsx-runtime.js');
8
+
9
+ var defaultTheme = {
10
+ container: {
11
+ backgroundColor: 'rgba(247, 25, 0, 0.8)',
12
+ color: '#fff',
13
+ textShadowColor: '#111',
14
+ textShadowOffset: {
15
+ width: 0,
16
+ height: -1
17
+ },
18
+ textShadowRadius: 1
19
+ },
20
+ backgroundColorConnected: 'rgba(25, 200, 60, 0.8)'
21
+ };
22
+
23
+ var useCreateCalcNative = function useCreateCalcNative() {
24
+ var dimensions = reactNative.useWindowDimensions();
25
+ return function (webCalc, createCalc) {
26
+ return createCalc(dimensions);
27
+ };
28
+ };
29
+
30
+ var useCreateCalcWeb = function useCreateCalcWeb() {
31
+ return function (webCalc) {
32
+ return "calc(" + webCalc + ")";
33
+ };
34
+ };
35
+
36
+ var useCreateCalc = reactNative.Platform.OS === 'web' ? useCreateCalcWeb : useCreateCalcNative; // example: const left = createCalc('50% - 100px', ({ width }) => width / 2 - 100);
37
+
38
+ var styles = reactNative.StyleSheet.create({
39
+ connectionStateContainer: {
40
+ backgroundColor: defaultTheme.container.backgroundColor,
41
+ position: 'absolute',
42
+ top: 0,
43
+ right: 0,
44
+ left: 0,
45
+ height: 2,
46
+ color: defaultTheme.container.color,
47
+ textShadowOffset: defaultTheme.container.textShadowOffset,
48
+ textShadowRadius: defaultTheme.container.textShadowRadius,
49
+ boxShadow: "0 2px 3px 0 rgba(0, 0, 0, 0.15), 0 2px 5px 0 rgba(0, 0, 0, 0.2)",
50
+ zIndex: 9,
51
+ transition: 'top .8s, background-color .2s'
52
+ },
53
+ hide: {
54
+ top: -24
55
+ },
56
+ connectionStateText: {
57
+ backgroundColor: defaultTheme.container.backgroundColor,
58
+ position: 'absolute',
59
+ width: 200,
60
+ height: 22,
61
+ lineHeight: 22,
62
+ top: 2,
63
+ textAlign: 'center',
64
+ borderBottomLeftRadius: 5,
65
+ borderBottomRightRadius: 5,
66
+ transition: 'background-color .2s'
67
+ }
68
+ });
69
+ function ConnectionState(_ref) {
70
+ var theme = _ref.theme,
71
+ forceHidden = _ref.forceHidden,
72
+ state = _ref.state,
73
+ children = _ref.children;
74
+ console.log({
75
+ state: state,
76
+ forceHidden: forceHidden
77
+ });
78
+ var unloadingRef = react.useRef(false);
79
+ var createCalc = useCreateCalc();
80
+ var left = createCalc('50% - 100px', function (_ref2) {
81
+ var width = _ref2.width;
82
+ return width / 2 - 100;
83
+ }); // TODO use calc() in web ?
84
+
85
+ react.useEffect(function () {
86
+ if (typeof window === 'undefined') return;
87
+
88
+ var beforeUnloadHandler = function beforeUnloadHandler() {
89
+ unloadingRef.current = true;
90
+ };
91
+
92
+ window.addEventListener('beforeunload', beforeUnloadHandler);
93
+ return function () {
94
+ window.removeEventListener('beforeunload', beforeUnloadHandler);
95
+ };
96
+ }, []);
97
+ return /*#__PURE__*/jsxRuntime_js.jsx(reactNative.View, {
98
+ style: [styles.connectionStateContainer, (forceHidden || !state || state === 'connected') && styles.hide, theme == null ? void 0 : theme.container, state === 'connected' && {
99
+ backgroundColor: (theme || defaultTheme).backgroundColorConnected
100
+ }],
101
+ children: !state ? null : /*#__PURE__*/jsxRuntime_js.jsx(reactNative.View, {
102
+ style: [styles.connectionStateText, theme && {
103
+ backgroundColor: theme.container.backgroundColor
104
+ }, state === 'connected' && {
105
+ backgroundColor: (theme || defaultTheme).backgroundColorConnected
106
+ }, {
107
+ left: left
108
+ }],
109
+ children: children
110
+ })
111
+ });
112
+ }
113
+
114
+ exports.ConnectionState = ConnectionState;
115
+ //# sourceMappingURL=index-browser.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-browser.cjs.js","sources":["../src/index.tsx"],"sourcesContent":["import type { ReactElement, ReactNode } from 'react';\nimport { useEffect, useRef } from 'react';\nimport type { ScaledSize } from 'react-native';\nimport { View, StyleSheet, Platform, useWindowDimensions } from 'react-native';\n\nconst defaultTheme = {\n container: {\n backgroundColor: 'rgba(247, 25, 0, 0.8)',\n color: '#fff',\n textShadowColor: '#111',\n textShadowOffset: { width: 0, height: -1 },\n textShadowRadius: 1,\n },\n backgroundColorConnected: 'rgba(25, 200, 60, 0.8)',\n};\n\nexport type ConnectionStateTheme = typeof defaultTheme;\nexport type State = null | 'connecting' | 'connected' | 'disconnected';\n\nexport interface ConnectionStateProps {\n theme?: ConnectionStateTheme;\n forceHidden?: boolean;\n state: State;\n children: NonNullable<ReactNode>;\n}\n\nconst zDepth1 =\n '0 2px 3px 0 rgba(0, 0, 0, 0.15), 0 2px 5px 0 rgba(0, 0, 0, 0.2)';\n\ntype CreateCalc = (\n webCalc: string,\n createCalc: (dimensions: ScaledSize) => number,\n) => string | number;\n\nconst useCreateCalcNative = (): CreateCalc => {\n const dimensions = useWindowDimensions();\n return (webCalc, createCalc) => createCalc(dimensions);\n};\nconst useCreateCalcWeb = (): CreateCalc => {\n return (webCalc) => `calc(${webCalc})`;\n};\nconst useCreateCalc =\n Platform.OS === 'web' ? useCreateCalcWeb : useCreateCalcNative;\n\n// example: const left = createCalc('50% - 100px', ({ width }) => width / 2 - 100);\n\nconst styles = StyleSheet.create({\n connectionStateContainer: {\n backgroundColor: defaultTheme.container.backgroundColor,\n position: 'absolute',\n top: 0,\n right: 0,\n left: 0,\n height: 2,\n color: defaultTheme.container.color,\n textShadowOffset: defaultTheme.container.textShadowOffset,\n textShadowRadius: defaultTheme.container.textShadowRadius,\n boxShadow: zDepth1,\n zIndex: 9,\n transition: 'top .8s, background-color .2s',\n },\n hide: {\n top: -24,\n },\n connectionStateText: {\n backgroundColor: defaultTheme.container.backgroundColor,\n position: 'absolute',\n width: 200,\n height: 22,\n lineHeight: 22,\n top: 2,\n textAlign: 'center',\n borderBottomLeftRadius: 5,\n borderBottomRightRadius: 5,\n transition: 'background-color .2s',\n },\n});\n\nexport function ConnectionState({\n theme,\n forceHidden,\n state,\n children,\n}: ConnectionStateProps): ReactElement | null {\n console.log({ state, forceHidden });\n const unloadingRef = useRef<boolean>(false);\n\n const createCalc = useCreateCalc();\n const left = createCalc('50% - 100px', ({ width }) => width / 2 - 100); // TODO use calc() in web ?\n\n useEffect((): (() => void) | undefined => {\n if (typeof window === 'undefined') return;\n\n const beforeUnloadHandler = (): void => {\n unloadingRef.current = true;\n };\n window.addEventListener('beforeunload', beforeUnloadHandler);\n\n return (): void => {\n window.removeEventListener('beforeunload', beforeUnloadHandler);\n };\n }, []);\n\n const shouldHide = forceHidden || !state || state === 'connected';\n\n return (\n <View\n style={[\n styles.connectionStateContainer,\n shouldHide && styles.hide,\n theme?.container,\n state === 'connected' && {\n backgroundColor: (theme || defaultTheme).backgroundColorConnected,\n },\n ]}\n >\n {!state ? null : (\n <View\n style={[\n styles.connectionStateText,\n theme && { backgroundColor: theme.container.backgroundColor },\n state === 'connected' && {\n backgroundColor: (theme || defaultTheme).backgroundColorConnected,\n },\n { left },\n ]}\n >\n {children}\n </View>\n )}\n </View>\n );\n}\n"],"names":["defaultTheme","container","backgroundColor","color","textShadowColor","textShadowOffset","width","height","textShadowRadius","backgroundColorConnected","useCreateCalcNative","dimensions","useWindowDimensions","webCalc","createCalc","useCreateCalcWeb","useCreateCalc","Platform","OS","styles","StyleSheet","create","connectionStateContainer","position","top","right","left","boxShadow","zIndex","transition","hide","connectionStateText","lineHeight","textAlign","borderBottomLeftRadius","borderBottomRightRadius","ConnectionState","theme","forceHidden","state","children","console","log","unloadingRef","useRef","useEffect","window","beforeUnloadHandler","current","addEventListener","removeEventListener","_jsx","View"],"mappings":";;;;;;;;AAKA,IAAMA,YAAY,GAAG;AACnBC,EAAAA,SAAS,EAAE;AACTC,IAAAA,eAAe,EAAE,uBADR;AAETC,IAAAA,KAAK,EAAE,MAFE;AAGTC,IAAAA,eAAe,EAAE,MAHR;AAITC,IAAAA,gBAAgB,EAAE;AAAEC,MAAAA,KAAK,EAAE,CAAT;AAAYC,MAAAA,MAAM,EAAE,CAAC;AAArB,KAJT;AAKTC,IAAAA,gBAAgB,EAAE;AALT,GADQ;AAQnBC,EAAAA,wBAAwB,EAAE;AARP,CAArB;;AA6BA,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAsB,GAAkB;AAC5C,MAAMC,UAAU,GAAGC,+BAAmB,EAAtC;AACA,SAAO,UAACC,OAAD,EAAUC,UAAV;AAAA,WAAyBA,UAAU,CAACH,UAAD,CAAnC;AAAA,GAAP;AACD,CAHD;;AAIA,IAAMI,gBAAgB,GAAG,SAAnBA,gBAAmB,GAAkB;AACzC,SAAO,UAACF,OAAD;AAAA,qBAAqBA,OAArB;AAAA,GAAP;AACD,CAFD;;AAGA,IAAMG,aAAa,GACjBC,oBAAQ,CAACC,EAAT,KAAgB,KAAhB,GAAwBH,gBAAxB,GAA2CL,mBAD7C;;AAKA,IAAMS,MAAM,GAAGC,sBAAU,CAACC,MAAX,CAAkB;AAC/BC,EAAAA,wBAAwB,EAAE;AACxBpB,IAAAA,eAAe,EAAEF,YAAY,CAACC,SAAb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AAAA,eAAe,EAAE,CAACmC,KAAK,IAAIrC,YAAV,EAAwBS;AADlB,OAHpB,EAML;AAAEiB,QAAAA,IAAI,EAAJA;AAAF,OANK,CADT;AAAA,gBAUGc;AAVH;AAXJ,IADF;AA2BD;;;;"}
@@ -0,0 +1,111 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const react = require('react');
6
+ const reactNative = require('react-native');
7
+ const jsxRuntime_js = require('react/jsx-runtime.js');
8
+
9
+ const defaultTheme = {
10
+ container: {
11
+ backgroundColor: 'rgba(247, 25, 0, 0.8)',
12
+ color: '#fff',
13
+ textShadowColor: '#111',
14
+ textShadowOffset: {
15
+ width: 0,
16
+ height: -1
17
+ },
18
+ textShadowRadius: 1
19
+ },
20
+ backgroundColorConnected: 'rgba(25, 200, 60, 0.8)'
21
+ };
22
+
23
+ const useCreateCalcNative = () => {
24
+ const dimensions = reactNative.useWindowDimensions();
25
+ return (webCalc, createCalc) => createCalc(dimensions);
26
+ };
27
+
28
+ const useCreateCalcWeb = () => {
29
+ return webCalc => `calc(${webCalc})`;
30
+ };
31
+
32
+ const useCreateCalc = reactNative.Platform.OS === 'web' ? useCreateCalcWeb : useCreateCalcNative; // example: const left = createCalc('50% - 100px', ({ width }) => width / 2 - 100);
33
+
34
+ const styles = reactNative.StyleSheet.create({
35
+ connectionStateContainer: {
36
+ backgroundColor: defaultTheme.container.backgroundColor,
37
+ position: 'absolute',
38
+ top: 0,
39
+ right: 0,
40
+ left: 0,
41
+ height: 2,
42
+ color: defaultTheme.container.color,
43
+ textShadowOffset: defaultTheme.container.textShadowOffset,
44
+ textShadowRadius: defaultTheme.container.textShadowRadius,
45
+ boxShadow: "0 2px 3px 0 rgba(0, 0, 0, 0.15), 0 2px 5px 0 rgba(0, 0, 0, 0.2)",
46
+ zIndex: 9,
47
+ transition: 'top .8s, background-color .2s'
48
+ },
49
+ hide: {
50
+ top: -24
51
+ },
52
+ connectionStateText: {
53
+ backgroundColor: defaultTheme.container.backgroundColor,
54
+ position: 'absolute',
55
+ width: 200,
56
+ height: 22,
57
+ lineHeight: 22,
58
+ top: 2,
59
+ textAlign: 'center',
60
+ borderBottomLeftRadius: 5,
61
+ borderBottomRightRadius: 5,
62
+ transition: 'background-color .2s'
63
+ }
64
+ });
65
+ function ConnectionState({
66
+ theme,
67
+ forceHidden,
68
+ state,
69
+ children
70
+ }) {
71
+ console.log({
72
+ state,
73
+ forceHidden
74
+ });
75
+ const unloadingRef = react.useRef(false);
76
+ const createCalc = useCreateCalc();
77
+ const left = createCalc('50% - 100px', ({
78
+ width
79
+ }) => width / 2 - 100); // TODO use calc() in web ?
80
+
81
+ react.useEffect(() => {
82
+ if (typeof window === 'undefined') return;
83
+
84
+ const beforeUnloadHandler = () => {
85
+ unloadingRef.current = true;
86
+ };
87
+
88
+ window.addEventListener('beforeunload', beforeUnloadHandler);
89
+ return () => {
90
+ window.removeEventListener('beforeunload', beforeUnloadHandler);
91
+ };
92
+ }, []);
93
+ return /*#__PURE__*/jsxRuntime_js.jsx(reactNative.View, {
94
+ style: [styles.connectionStateContainer, (forceHidden || !state || state === 'connected') && styles.hide, theme?.container, state === 'connected' && {
95
+ backgroundColor: (theme || defaultTheme).backgroundColorConnected
96
+ }],
97
+ children: !state ? null : /*#__PURE__*/jsxRuntime_js.jsx(reactNative.View, {
98
+ style: [styles.connectionStateText, theme && {
99
+ backgroundColor: theme.container.backgroundColor
100
+ }, state === 'connected' && {
101
+ backgroundColor: (theme || defaultTheme).backgroundColorConnected
102
+ }, {
103
+ left
104
+ }],
105
+ children: children
106
+ })
107
+ });
108
+ }
109
+
110
+ exports.ConnectionState = ConnectionState;
111
+ //# sourceMappingURL=index-node14.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-node14.cjs","sources":["../src/index.tsx"],"sourcesContent":["import type { ReactElement, ReactNode } from 'react';\nimport { useEffect, useRef } from 'react';\nimport type { ScaledSize } from 'react-native';\nimport { View, StyleSheet, Platform, useWindowDimensions } from 'react-native';\n\nconst defaultTheme = {\n container: {\n backgroundColor: 'rgba(247, 25, 0, 0.8)',\n color: '#fff',\n textShadowColor: '#111',\n textShadowOffset: { width: 0, height: -1 },\n textShadowRadius: 1,\n },\n backgroundColorConnected: 'rgba(25, 200, 60, 0.8)',\n};\n\nexport type ConnectionStateTheme = typeof defaultTheme;\nexport type State = null | 'connecting' | 'connected' | 'disconnected';\n\nexport interface ConnectionStateProps {\n theme?: ConnectionStateTheme;\n forceHidden?: boolean;\n state: State;\n children: NonNullable<ReactNode>;\n}\n\nconst zDepth1 =\n '0 2px 3px 0 rgba(0, 0, 0, 0.15), 0 2px 5px 0 rgba(0, 0, 0, 0.2)';\n\ntype CreateCalc = (\n webCalc: string,\n createCalc: (dimensions: ScaledSize) => number,\n) => string | number;\n\nconst useCreateCalcNative = (): CreateCalc => {\n const dimensions = useWindowDimensions();\n return (webCalc, createCalc) => createCalc(dimensions);\n};\nconst useCreateCalcWeb = (): CreateCalc => {\n return (webCalc) => `calc(${webCalc})`;\n};\nconst useCreateCalc =\n Platform.OS === 'web' ? useCreateCalcWeb : useCreateCalcNative;\n\n// example: const left = createCalc('50% - 100px', ({ width }) => width / 2 - 100);\n\nconst styles = StyleSheet.create({\n connectionStateContainer: {\n backgroundColor: defaultTheme.container.backgroundColor,\n position: 'absolute',\n top: 0,\n right: 0,\n left: 0,\n height: 2,\n color: defaultTheme.container.color,\n textShadowOffset: defaultTheme.container.textShadowOffset,\n textShadowRadius: defaultTheme.container.textShadowRadius,\n boxShadow: zDepth1,\n zIndex: 9,\n transition: 'top .8s, background-color .2s',\n },\n hide: {\n top: -24,\n },\n connectionStateText: {\n backgroundColor: defaultTheme.container.backgroundColor,\n position: 'absolute',\n width: 200,\n height: 22,\n lineHeight: 22,\n top: 2,\n textAlign: 'center',\n borderBottomLeftRadius: 5,\n borderBottomRightRadius: 5,\n transition: 'background-color .2s',\n },\n});\n\nexport function ConnectionState({\n theme,\n forceHidden,\n state,\n children,\n}: ConnectionStateProps): ReactElement | null {\n console.log({ state, forceHidden });\n const unloadingRef = useRef<boolean>(false);\n\n const createCalc = useCreateCalc();\n const left = createCalc('50% - 100px', ({ width }) => width / 2 - 100); // TODO use calc() in web ?\n\n useEffect((): (() => void) | undefined => {\n if (typeof window === 'undefined') return;\n\n const beforeUnloadHandler = (): void => {\n unloadingRef.current = true;\n };\n window.addEventListener('beforeunload', beforeUnloadHandler);\n\n return (): void => {\n window.removeEventListener('beforeunload', beforeUnloadHandler);\n };\n }, []);\n\n const shouldHide = forceHidden || !state || state === 'connected';\n\n return (\n <View\n style={[\n styles.connectionStateContainer,\n shouldHide && styles.hide,\n theme?.container,\n state === 'connected' && {\n backgroundColor: (theme || defaultTheme).backgroundColorConnected,\n },\n ]}\n >\n {!state ? null : (\n <View\n style={[\n styles.connectionStateText,\n theme && { backgroundColor: theme.container.backgroundColor },\n state === 'connected' && {\n backgroundColor: (theme || defaultTheme).backgroundColorConnected,\n },\n { left },\n ]}\n >\n {children}\n </View>\n )}\n </View>\n );\n}\n"],"names":["defaultTheme","container","backgroundColor","color","textShadowColor","textShadowOffset","width","height","textShadowRadius","backgroundColorConnected","useCreateCalcNative","dimensions","useWindowDimensions","webCalc","createCalc","useCreateCalcWeb","useCreateCalc","Platform","OS","styles","StyleSheet","create","connectionStateContainer","position","top","right","left","boxShadow","zIndex","transition","hide","connectionStateText","lineHeight","textAlign","borderBottomLeftRadius","borderBottomRightRadius","ConnectionState","theme","forceHidden","state","children","console","log","unloadingRef","useRef","useEffect","window","beforeUnloadHandler","current","addEventListener","removeEventListener","_jsx","View"],"mappings":";;;;;;;;AAKA,MAAMA,YAAY,GAAG;AACnBC,EAAAA,SAAS,EAAE;AACTC,IAAAA,eAAe,EAAE,uBADR;AAETC,IAAAA,KAAK,EAAE,MAFE;AAGTC,IAAAA,eAAe,EAAE,MAHR;AAITC,IAAAA,gBAAgB,EAAE;AAAEC,MAAAA,KAAK,EAAE,CAAT;AAAYC,MAAAA,M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agB,WAAW,IAAI,CAACC,KAAhB,IAAyBA,KAAK,KAAK,WAMhD,KAAcpB,MAAM,CAACW,IAFhB,EAGLO,KAAK,EAAEpC,SAHF,EAILsC,KAAK,KAAK,WAAV,IAAyB;AACvBrC,MAAAA,eAAe,EAAE,CAACmC,KAAK,IAAIrC,YAAV,EAAwBS;AADlB,KAJpB,CADT;AAAA,cAUG,CAAC8B,KAAD,GAAS,IAAT,gBACCY,kBAACC,gBAAD;AACE,MAAA,KAAK,EAAE,CACLjC,MAAM,CAACY,mBADF,EAELM,KAAK,IAAI;AAAEnC,QAAAA,eAAe,EAAEmC,KAAK,CAACpC,SAAN,CAAgBC;AAAnC,OAFJ,EAGLqC,KAAK,KAAK,WAAV,IAAyB;AACvBrC,QAAAA,eAAe,EAAE,CAACmC,KAAK,IAAIrC,YAAV,EAAwBS;AADlB,OAHpB,EAML;AAAEiB,QAAAA;AAAF,OANK,CADT;AAAA,gBAUGc;AAVH;AAXJ,IADF;AA2BD;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-alp-connection-state",
3
- "version": "6.0.1",
3
+ "version": "6.1.0",
4
4
  "description": "connection state",
5
5
  "keywords": [],
6
6
  "author": "Christophe Hurpeau <christophe@hurpeau.com> (https://christophe.hurpeau.com)",
@@ -30,13 +30,15 @@
30
30
  "./package.json": "./package.json",
31
31
  ".": {
32
32
  "node": {
33
- "import": "./dist/index-node14.mjs"
33
+ "import": "./dist/index-node14.mjs",
34
+ "require": "./dist/index-node14.cjs"
34
35
  },
35
36
  "browser": {
36
37
  "browser:modern": {
37
38
  "import": "./dist/index-browsermodern.es.js"
38
39
  },
39
- "import": "./dist/index-browser.es.js"
40
+ "import": "./dist/index-browser.es.js",
41
+ "require": "./dist/index-browser.cjs.js"
40
42
  }
41
43
  }
42
44
  },
@@ -63,6 +65,7 @@
63
65
  "target": "node",
64
66
  "version": "14",
65
67
  "formats": [
68
+ "cjs",
66
69
  "es"
67
70
  ]
68
71
  },
@@ -76,6 +79,7 @@
76
79
  {
77
80
  "target": "browser",
78
81
  "formats": [
82
+ "cjs",
79
83
  "es"
80
84
  ]
81
85
  }
@@ -105,8 +109,8 @@
105
109
  "babel-preset-modern-browsers": "15.0.2",
106
110
  "pob-babel": "32.2.0",
107
111
  "react": "17.0.2",
108
- "react-native": "0.67.2",
109
- "typescript": "4.5.5"
112
+ "react-native": "0.67.3",
113
+ "typescript": "4.6.2"
110
114
  },
111
- "gitHead": "5743ca423201457801590e12f607b1a60f7fa51a"
115
+ "gitHead": "b6ce6531ed3bd7f594c7e3068c730864776824a0"
112
116
  }