@kirill.konshin/react-native 0.0.1 → 0.0.3

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/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from './share';
2
- export * from './update';
3
- export * from './useAppState';
1
+ export * from './share.js';
2
+ export * from './update.js';
3
+ export * from './useAppState.js';
4
4
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,9 +1,4 @@
1
1
  import { shareDialog } from "./share.js";
2
2
  import { Update } from "./update.js";
3
3
  import { useAppState } from "./useAppState.js";
4
- export {
5
- Update,
6
- shareDialog,
7
- useAppState
8
- };
9
- //# sourceMappingURL=index.js.map
4
+ export { Update, shareDialog, useAppState };
package/dist/share.js CHANGED
@@ -1,23 +1,33 @@
1
1
  import * as FileSystem from "expo-file-system";
2
2
  import * as Sharing from "expo-sharing";
3
- const shareDialog = async (base64, fileName) => {
4
- const path = `${FileSystem.documentDirectory}/${fileName}`;
5
- try {
6
- if (!await Sharing.isAvailableAsync()) throw new Error("Sharing is not available");
7
- const [header, buffer] = base64.split(",");
8
- const [, mimeTypeStr] = header.split(":");
9
- const [mimeType] = mimeTypeStr.split(";");
10
- await FileSystem.writeAsStringAsync(`${path}`, buffer, {
11
- encoding: FileSystem.EncodingType.Base64
12
- });
13
- await Sharing.shareAsync(path, { mimeType, UTI: fileName, dialogTitle: "Save or share document" });
14
- } catch (error) {
15
- alert("Sharing failed: " + error.message);
16
- } finally {
17
- await FileSystem.deleteAsync(path);
18
- }
3
+ //#region src/share.ts
4
+ /**
5
+ * data:text/plain;base64,W29iamV
6
+ * @see https://stackoverflow.com/questions/69738812/problem-to-generate-pdf-from-a-blob-in-an-expo-app-using-filesystem
7
+ * @param base64
8
+ * @param fileName
9
+ * @returns {Promise<void>}
10
+ */
11
+ var shareDialog = async (base64, fileName) => {
12
+ const path = `${FileSystem.documentDirectory}/${fileName}`;
13
+ try {
14
+ if (!await Sharing.isAvailableAsync()) throw new Error("Sharing is not available");
15
+ const [header, buffer] = base64.split(",");
16
+ const [, mimeTypeStr] = header.split(":");
17
+ const [mimeType] = mimeTypeStr.split(";");
18
+ await FileSystem.writeAsStringAsync(`${path}`, buffer, { encoding: FileSystem.EncodingType.Base64 });
19
+ await Sharing.shareAsync(path, {
20
+ mimeType,
21
+ UTI: fileName,
22
+ dialogTitle: "Save or share document"
23
+ });
24
+ } catch (error) {
25
+ alert("Sharing failed: " + error.message);
26
+ } finally {
27
+ await FileSystem.deleteAsync(path);
28
+ }
19
29
  };
20
- export {
21
- shareDialog
22
- };
23
- //# sourceMappingURL=share.js.map
30
+ //#endregion
31
+ export { shareDialog };
32
+
33
+ //# sourceMappingURL=share.js.map
package/dist/share.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"share.js","sources":["../src/share.ts"],"sourcesContent":["import * as FileSystem from 'expo-file-system';\nimport * as Sharing from 'expo-sharing';\n\n/**\n * data:text/plain;base64,W29iamV\n * @see https://stackoverflow.com/questions/69738812/problem-to-generate-pdf-from-a-blob-in-an-expo-app-using-filesystem\n * @param base64\n * @param fileName\n * @returns {Promise<void>}\n */\nexport const shareDialog = async (base64: string, fileName: string): Promise<void> => {\n const path = `${FileSystem.documentDirectory}/${fileName}`;\n\n try {\n if (!(await Sharing.isAvailableAsync())) throw new Error('Sharing is not available');\n\n const [header, buffer] = base64.split(',');\n const [, mimeTypeStr] = header.split(':');\n const [mimeType] = mimeTypeStr.split(';');\n\n await FileSystem.writeAsStringAsync(`${path}`, buffer, {\n encoding: FileSystem.EncodingType.Base64,\n });\n\n await Sharing.shareAsync(path, { mimeType, UTI: fileName, dialogTitle: 'Save or share document' });\n } catch (error) {\n alert('Sharing failed: ' + error.message);\n } finally {\n await FileSystem.deleteAsync(path);\n }\n};\n"],"names":[],"mappings":";;AAUO,MAAM,cAAc,OAAO,QAAgB,aAAoC;AAClF,QAAM,OAAO,GAAG,WAAW,iBAAiB,IAAI,QAAQ;AAExD,MAAI;AACA,QAAI,CAAE,MAAM,QAAQ,iBAAA,EAAqB,OAAM,IAAI,MAAM,0BAA0B;AAEnF,UAAM,CAAC,QAAQ,MAAM,IAAI,OAAO,MAAM,GAAG;AACzC,UAAM,CAAA,EAAG,WAAW,IAAI,OAAO,MAAM,GAAG;AACxC,UAAM,CAAC,QAAQ,IAAI,YAAY,MAAM,GAAG;AAExC,UAAM,WAAW,mBAAmB,GAAG,IAAI,IAAI,QAAQ;AAAA,MACnD,UAAU,WAAW,aAAa;AAAA,IAAA,CACrC;AAED,UAAM,QAAQ,WAAW,MAAM,EAAE,UAAU,KAAK,UAAU,aAAa,0BAA0B;AAAA,EACrG,SAAS,OAAO;AACZ,UAAM,qBAAqB,MAAM,OAAO;AAAA,EAC5C,UAAA;AACI,UAAM,WAAW,YAAY,IAAI;AAAA,EACrC;AACJ;"}
1
+ {"version":3,"file":"share.js","names":[],"sources":["../src/share.ts"],"sourcesContent":["import * as FileSystem from 'expo-file-system';\nimport * as Sharing from 'expo-sharing';\n\n/**\n * data:text/plain;base64,W29iamV\n * @see https://stackoverflow.com/questions/69738812/problem-to-generate-pdf-from-a-blob-in-an-expo-app-using-filesystem\n * @param base64\n * @param fileName\n * @returns {Promise<void>}\n */\nexport const shareDialog = async (base64: string, fileName: string): Promise<void> => {\n const path = `${FileSystem.documentDirectory}/${fileName}`;\n\n try {\n if (!(await Sharing.isAvailableAsync())) throw new Error('Sharing is not available');\n\n const [header, buffer] = base64.split(',');\n const [, mimeTypeStr] = header.split(':');\n const [mimeType] = mimeTypeStr.split(';');\n\n await FileSystem.writeAsStringAsync(`${path}`, buffer, {\n encoding: FileSystem.EncodingType.Base64,\n });\n\n await Sharing.shareAsync(path, { mimeType, UTI: fileName, dialogTitle: 'Save or share document' });\n } catch (error) {\n alert('Sharing failed: ' + error.message);\n } finally {\n await FileSystem.deleteAsync(path);\n }\n};\n"],"mappings":";;;;;;;;;;AAUA,IAAa,cAAc,OAAO,QAAgB,aAAoC;CAClF,MAAM,OAAO,GAAG,WAAW,kBAAkB,GAAG;CAEhD,IAAI;EACA,IAAI,CAAE,MAAM,QAAQ,iBAAiB,GAAI,MAAM,IAAI,MAAM,0BAA0B;EAEnF,MAAM,CAAC,QAAQ,UAAU,OAAO,MAAM,GAAG;EACzC,MAAM,GAAG,eAAe,OAAO,MAAM,GAAG;EACxC,MAAM,CAAC,YAAY,YAAY,MAAM,GAAG;EAExC,MAAM,WAAW,mBAAmB,GAAG,QAAQ,QAAQ,EACnD,UAAU,WAAW,aAAa,OACtC,CAAC;EAED,MAAM,QAAQ,WAAW,MAAM;GAAE;GAAU,KAAK;GAAU,aAAa;EAAyB,CAAC;CACrG,SAAS,OAAO;EACZ,MAAM,qBAAqB,MAAM,OAAO;CAC5C,UAAU;EACN,MAAM,WAAW,YAAY,IAAI;CACrC;AACJ"}
package/dist/update.d.ts CHANGED
@@ -1,3 +1,6 @@
1
1
  import { FC } from 'react';
2
- export declare const Update: FC<any>;
2
+ export type UpdateProps = {
3
+ children: any;
4
+ };
5
+ export declare const Update: FC<UpdateProps>;
3
6
  //# sourceMappingURL=update.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../src/update.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAuB,MAAM,OAAO,CAAC;AAGhD,eAAO,MAAM,MAAM,EAAE,EAAE,CAAC,GAAG,CAmC1B,CAAC"}
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../src/update.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,EAA6B,MAAM,OAAO,CAAC;AAG3D,MAAM,MAAM,WAAW,GAAG;IACtB,QAAQ,EAAE,GAAG,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,EAAE,CAAC,WAAW,CAmCjC,CAAC"}
package/dist/update.js CHANGED
@@ -1,40 +1,38 @@
1
- import { jsxs } from "react/jsx-runtime";
2
1
  import * as Updates from "expo-updates";
3
- import { useState, useEffect } from "react";
2
+ import { memo, useEffect, useState } from "react";
4
3
  import { Text } from "react-native";
5
- const Update = function Update2({ children }) {
6
- const [updating, setUpdating] = useState(true);
7
- useEffect(() => {
8
- (async () => {
9
- try {
10
- if (__DEV__) {
11
- setUpdating(false);
12
- return;
13
- }
14
- const update = await Updates.checkForUpdateAsync();
15
- if (!update.isAvailable) {
16
- setUpdating(false);
17
- return;
18
- }
19
- await Updates.fetchUpdateAsync();
20
- alert("Update is available. App will reload.");
21
- await Updates.reloadAsync();
22
- } catch (error) {
23
- alert(`Error fetching latest Expo update: ${error}`);
24
- setUpdating(false);
25
- }
26
- })();
27
- });
28
- if (updating) {
29
- return /* @__PURE__ */ jsxs(Text, { children: [
30
- "Checking for updates (",
31
- Updates.channel,
32
- ")..."
33
- ] });
34
- }
35
- return children;
36
- };
37
- export {
38
- Update
39
- };
40
- //# sourceMappingURL=update.js.map
4
+ import { jsxs } from "react/jsx-runtime";
5
+ //#region src/update.tsx
6
+ var Update = memo(function Update({ children }) {
7
+ const [updating, setUpdating] = useState(true);
8
+ useEffect(() => {
9
+ (async () => {
10
+ try {
11
+ if (__DEV__) {
12
+ setUpdating(false);
13
+ return;
14
+ }
15
+ if (!(await Updates.checkForUpdateAsync()).isAvailable) {
16
+ setUpdating(false);
17
+ return;
18
+ }
19
+ await Updates.fetchUpdateAsync();
20
+ alert("Update is available. App will reload.");
21
+ await Updates.reloadAsync();
22
+ } catch (error) {
23
+ alert(`Error fetching latest Expo update: ${error}`);
24
+ setUpdating(false);
25
+ }
26
+ })();
27
+ });
28
+ if (updating) return /* @__PURE__ */ jsxs(Text, { children: [
29
+ "Checking for updates (",
30
+ Updates.channel,
31
+ ")..."
32
+ ] });
33
+ return children;
34
+ });
35
+ //#endregion
36
+ export { Update };
37
+
38
+ //# sourceMappingURL=update.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"update.js","sources":["../src/update.tsx"],"sourcesContent":["import * as Updates from 'expo-updates';\nimport { FC, useEffect, useState } from 'react';\nimport { Text } from 'react-native';\n\nexport const Update: FC<any> = function Update({ children }) {\n //FIXME useUpdates https://blog.expo.dev/feature-preview-updates-js-api-for-expo-updates-3b92beb40dab\n const [updating, setUpdating] = useState(true);\n\n useEffect(() => {\n (async () => {\n try {\n if (__DEV__) {\n setUpdating(false);\n return;\n }\n\n const update = await Updates.checkForUpdateAsync();\n\n if (!update.isAvailable) {\n setUpdating(false);\n return;\n }\n\n await Updates.fetchUpdateAsync();\n alert('Update is available. App will reload.');\n await Updates.reloadAsync();\n } catch (error) {\n // You can also add an alert() to see the error message in case of an error when fetching updates.\n alert(`Error fetching latest Expo update: ${error}`);\n setUpdating(false);\n }\n })();\n });\n\n if (updating) {\n return <Text>Checking for updates ({Updates.channel})...</Text>;\n }\n\n return children;\n};\n"],"names":["Update"],"mappings":";;;;AAIO,MAAM,SAAkB,SAASA,QAAO,EAAE,YAAY;AAEzD,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,IAAI;AAE7C,YAAU,MAAM;AACZ,KAAC,YAAY;AACT,UAAI;AACA,YAAI,SAAS;AACT,sBAAY,KAAK;AACjB;AAAA,QACJ;AAEA,cAAM,SAAS,MAAM,QAAQ,oBAAA;AAE7B,YAAI,CAAC,OAAO,aAAa;AACrB,sBAAY,KAAK;AACjB;AAAA,QACJ;AAEA,cAAM,QAAQ,iBAAA;AACd,cAAM,uCAAuC;AAC7C,cAAM,QAAQ,YAAA;AAAA,MAClB,SAAS,OAAO;AAEZ,cAAM,sCAAsC,KAAK,EAAE;AACnD,oBAAY,KAAK;AAAA,MACrB;AAAA,IACJ,GAAA;AAAA,EACJ,CAAC;AAED,MAAI,UAAU;AACV,gCAAQ,MAAA,EAAK,UAAA;AAAA,MAAA;AAAA,MAAuB,QAAQ;AAAA,MAAQ;AAAA,IAAA,GAAI;AAAA,EAC5D;AAEA,SAAO;AACX;"}
1
+ {"version":3,"file":"update.js","names":[],"sources":["../src/update.tsx"],"sourcesContent":["import * as Updates from 'expo-updates';\nimport { type FC, memo, useEffect, useState } from 'react';\nimport { Text } from 'react-native';\n\nexport type UpdateProps = {\n children: any;\n};\n\nexport const Update: FC<UpdateProps> = memo(function Update({ children }) {\n //FIXME useUpdates https://blog.expo.dev/feature-preview-updates-js-api-for-expo-updates-3b92beb40dab\n const [updating, setUpdating] = useState(true);\n\n useEffect(() => {\n (async () => {\n try {\n if (__DEV__) {\n setUpdating(false);\n return;\n }\n\n const update = await Updates.checkForUpdateAsync();\n\n if (!update.isAvailable) {\n setUpdating(false);\n return;\n }\n\n await Updates.fetchUpdateAsync();\n alert('Update is available. App will reload.');\n await Updates.reloadAsync();\n } catch (error) {\n // You can also add an alert() to see the error message in case of an error when fetching updates.\n alert(`Error fetching latest Expo update: ${error}`);\n setUpdating(false);\n }\n })();\n });\n\n if (updating) {\n return <Text>Checking for updates ({Updates.channel})...</Text>;\n }\n\n return children;\n});\n"],"mappings":";;;;;AAQA,IAAa,SAA0B,KAAK,SAAS,OAAO,EAAE,YAAY;CAEtE,MAAM,CAAC,UAAU,eAAe,SAAS,IAAI;CAE7C,gBAAgB;EACZ,CAAC,YAAY;GACT,IAAI;IACA,IAAI,SAAS;KACT,YAAY,KAAK;KACjB;IACJ;IAIA,IAAI,EAAC,MAFgB,QAAQ,oBAAoB,EAAA,CAErC,aAAa;KACrB,YAAY,KAAK;KACjB;IACJ;IAEA,MAAM,QAAQ,iBAAiB;IAC/B,MAAM,uCAAuC;IAC7C,MAAM,QAAQ,YAAY;GAC9B,SAAS,OAAO;IAEZ,MAAM,sCAAsC,OAAO;IACnD,YAAY,KAAK;GACrB;EACJ,EAAA,CAAG;CACP,CAAC;CAED,IAAI,UACA,OAAO,qBAAC,MAAD,EAAA,UAAA;EAAM;EAAuB,QAAQ;EAAQ;CAAU,EAAA,CAAA;CAGlE,OAAO;AACX,CAAC"}
@@ -1,18 +1,19 @@
1
- import { useState, useEffect } from "react";
1
+ import { useEffect, useState } from "react";
2
2
  import { AppState } from "react-native";
3
+ //#region src/useAppState.ts
3
4
  function useAppState() {
4
- const [appState, setAppState] = useState(AppState.currentState);
5
- useEffect(() => {
6
- const subscription = AppState.addEventListener("change", (nextAppState) => {
7
- setAppState(nextAppState);
8
- });
9
- return () => {
10
- subscription.remove();
11
- };
12
- }, []);
13
- return appState;
5
+ const [appState, setAppState] = useState(AppState.currentState);
6
+ useEffect(() => {
7
+ const subscription = AppState.addEventListener("change", (nextAppState) => {
8
+ setAppState(nextAppState);
9
+ });
10
+ return () => {
11
+ subscription.remove();
12
+ };
13
+ }, []);
14
+ return appState;
14
15
  }
15
- export {
16
- useAppState
17
- };
18
- //# sourceMappingURL=useAppState.js.map
16
+ //#endregion
17
+ export { useAppState };
18
+
19
+ //# sourceMappingURL=useAppState.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAppState.js","sources":["../src/useAppState.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { AppState } from 'react-native';\n\nexport function useAppState(): 'active' | 'background' | 'inactive' | 'unknown' | 'extension' {\n const [appState, setAppState] = useState(AppState.currentState);\n\n useEffect(() => {\n const subscription = AppState.addEventListener('change', (nextAppState) => {\n setAppState(nextAppState);\n });\n\n return () => {\n subscription.remove();\n };\n }, []);\n\n return appState;\n}\n"],"names":[],"mappings":";;AAGO,SAAS,cAA8E;AAC1F,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,SAAS,YAAY;AAE9D,YAAU,MAAM;AACZ,UAAM,eAAe,SAAS,iBAAiB,UAAU,CAAC,iBAAiB;AACvE,kBAAY,YAAY;AAAA,IAC5B,CAAC;AAED,WAAO,MAAM;AACT,mBAAa,OAAA;AAAA,IACjB;AAAA,EACJ,GAAG,CAAA,CAAE;AAEL,SAAO;AACX;"}
1
+ {"version":3,"file":"useAppState.js","names":[],"sources":["../src/useAppState.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { AppState } from 'react-native';\n\nexport function useAppState(): 'active' | 'background' | 'inactive' | 'unknown' | 'extension' {\n const [appState, setAppState] = useState(AppState.currentState);\n\n useEffect(() => {\n const subscription = AppState.addEventListener('change', (nextAppState) => {\n setAppState(nextAppState);\n });\n\n return () => {\n subscription.remove();\n };\n }, []);\n\n return appState;\n}\n"],"mappings":";;;AAGA,SAAgB,cAA8E;CAC1F,MAAM,CAAC,UAAU,eAAe,SAAS,SAAS,YAAY;CAE9D,gBAAgB;EACZ,MAAM,eAAe,SAAS,iBAAiB,WAAW,iBAAiB;GACvE,YAAY,YAAY;EAC5B,CAAC;EAED,aAAa;GACT,aAAa,OAAO;EACxB;CACJ,GAAG,CAAC,CAAC;CAEL,OAAO;AACX"}
package/package.json CHANGED
@@ -1,18 +1,16 @@
1
1
  {
2
2
  "name": "@kirill.konshin/react-native",
3
3
  "description": "Utilities",
4
- "version": "0.0.1",
4
+ "version": "0.0.3",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "----- BUILD -----": "",
8
8
  "clean": "rm -rf dist .tscache tsconfig.tsbuildinfo",
9
9
  "build": "vite build",
10
- "build:index": "cti create ./src",
11
- "build:check-types": "attw --pack .",
12
10
  "start": "yarn build --watch",
13
11
  "wait": "wait-on ./dist/index.js",
14
12
  "----- TEST -----": "",
15
- "test:disabled": "vitest run --coverage",
13
+ "test": "vitest run --coverage",
16
14
  "test:watch": "vitest watch --coverage",
17
15
  "----- STORYBOOK -----": "",
18
16
  "storybook:start": "storybook dev -p 6006",
@@ -55,5 +53,18 @@
55
53
  },
56
54
  "main": "./dist/index.js",
57
55
  "module": "./dist/index.js",
58
- "types": "./dist/index.d.ts"
56
+ "types": "./dist/index.d.ts",
57
+ "repository": {
58
+ "type": "git",
59
+ "url": "https://github.com/kirill-konshin/utils.git",
60
+ "directory": "packages/react-native"
61
+ },
62
+ "nx": {
63
+ "tags": [
64
+ "platform:react-native"
65
+ ]
66
+ },
67
+ "files": [
68
+ "dist"
69
+ ]
59
70
  }
package/.ctirc DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "addNewline": true,
3
- "fileExcludePatterns": [
4
- "*.stories.*",
5
- "*.test.*",
6
- "*.fixture.*"
7
- ],
8
- "verbose": false,
9
- "withoutBackupFile": true,
10
- "withoutComment": true
11
- }
@@ -1,15 +0,0 @@
1
- vite v7.0.6 building SSR bundle for production...
2
- create succeeded: /home/runner/work/utils/utils/packages/react-native/src
3
- transforming...
4
- ✓ 4 modules transformed.
5
- rendering chunks...
6
-
7
- [vite:dts] Start generate declaration files...
8
- dist/index.js 0.21 kB │ map: 0.09 kB
9
- dist/useAppState.js 0.47 kB │ map: 0.89 kB
10
- dist/share.js 0.85 kB │ map: 1.78 kB
11
- dist/update.js 1.05 kB │ map: 2.00 kB
12
- [vite:dts] Declaration files built in 1414ms.
13
-
14
- ✓ built in 2.11s
15
- Updated package.json with exports
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
package/src/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './share';
2
- export * from './update';
3
- export * from './useAppState';
package/src/share.ts DELETED
@@ -1,31 +0,0 @@
1
- import * as FileSystem from 'expo-file-system';
2
- import * as Sharing from 'expo-sharing';
3
-
4
- /**
5
- * data:text/plain;base64,W29iamV
6
- * @see https://stackoverflow.com/questions/69738812/problem-to-generate-pdf-from-a-blob-in-an-expo-app-using-filesystem
7
- * @param base64
8
- * @param fileName
9
- * @returns {Promise<void>}
10
- */
11
- export const shareDialog = async (base64: string, fileName: string): Promise<void> => {
12
- const path = `${FileSystem.documentDirectory}/${fileName}`;
13
-
14
- try {
15
- if (!(await Sharing.isAvailableAsync())) throw new Error('Sharing is not available');
16
-
17
- const [header, buffer] = base64.split(',');
18
- const [, mimeTypeStr] = header.split(':');
19
- const [mimeType] = mimeTypeStr.split(';');
20
-
21
- await FileSystem.writeAsStringAsync(`${path}`, buffer, {
22
- encoding: FileSystem.EncodingType.Base64,
23
- });
24
-
25
- await Sharing.shareAsync(path, { mimeType, UTI: fileName, dialogTitle: 'Save or share document' });
26
- } catch (error) {
27
- alert('Sharing failed: ' + error.message);
28
- } finally {
29
- await FileSystem.deleteAsync(path);
30
- }
31
- };
package/src/update.tsx DELETED
@@ -1,40 +0,0 @@
1
- import * as Updates from 'expo-updates';
2
- import { FC, useEffect, useState } from 'react';
3
- import { Text } from 'react-native';
4
-
5
- export const Update: FC<any> = function Update({ children }) {
6
- //FIXME useUpdates https://blog.expo.dev/feature-preview-updates-js-api-for-expo-updates-3b92beb40dab
7
- const [updating, setUpdating] = useState(true);
8
-
9
- useEffect(() => {
10
- (async () => {
11
- try {
12
- if (__DEV__) {
13
- setUpdating(false);
14
- return;
15
- }
16
-
17
- const update = await Updates.checkForUpdateAsync();
18
-
19
- if (!update.isAvailable) {
20
- setUpdating(false);
21
- return;
22
- }
23
-
24
- await Updates.fetchUpdateAsync();
25
- alert('Update is available. App will reload.');
26
- await Updates.reloadAsync();
27
- } catch (error) {
28
- // You can also add an alert() to see the error message in case of an error when fetching updates.
29
- alert(`Error fetching latest Expo update: ${error}`);
30
- setUpdating(false);
31
- }
32
- })();
33
- });
34
-
35
- if (updating) {
36
- return <Text>Checking for updates ({Updates.channel})...</Text>;
37
- }
38
-
39
- return children;
40
- };
@@ -1,18 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import { AppState } from 'react-native';
3
-
4
- export function useAppState(): 'active' | 'background' | 'inactive' | 'unknown' | 'extension' {
5
- const [appState, setAppState] = useState(AppState.currentState);
6
-
7
- useEffect(() => {
8
- const subscription = AppState.addEventListener('change', (nextAppState) => {
9
- setAppState(nextAppState);
10
- });
11
-
12
- return () => {
13
- subscription.remove();
14
- };
15
- }, []);
16
-
17
- return appState;
18
- }
@@ -1,177 +0,0 @@
1
- // 'use client';
2
- //
3
- // import { Auth0Provider, useAuth0 } from '@auth0/auth0-react';
4
- // import { Button, ButtonProps } from 'react-bootstrap';
5
- // import { useRouter } from 'next/navigation';
6
- // import { useEffect } from 'react';
7
- // import { emitter } from '../api/apiClient';
8
- // import RestResponse from '../api/restResponse';
9
- // import { useToaster } from '../redux/toasterSlice';
10
- // import { end_session } from '../api/miscCommands';
11
- // import { createAuth0Client, Auth0Client } from '@auth0/auth0-spa-js';
12
- //
13
- // const isSSR = typeof window === 'undefined';
14
- //
15
- // const origin = !isSSR ? window.location.origin : '';
16
- //
17
- // // @ts-ignore
18
- // export const isReactNative = () => !isSSR && window.ReactNativeWebView?.postMessage;
19
- //
20
- // // @ts-ignore
21
- // export const postMessage = (data: any = null) => window.ReactNativeWebView?.postMessage(JSON.stringify(data));
22
- //
23
- // if (isReactNative()) {
24
- // const originalConsole = { ...console };
25
- //
26
- // const makeLogger =
27
- // (type) =>
28
- // (...args) => {
29
- // postMessage(
30
- // JSON.stringify({
31
- // type,
32
- // data: args,
33
- // })
34
- // );
35
- // originalConsole[type].apply(console, args);
36
- // };
37
- //
38
- // console.log = makeLogger('log');
39
- // console.log = makeLogger('error');
40
- // console.log = makeLogger('info');
41
- // console.log = makeLogger('warn');
42
- // }
43
- //
44
- // export const externalAuth =
45
- // !isSSR && window['auth0data']
46
- // ? ({
47
- // user: window['auth0data'].user,
48
- // getAccessTokenSilently: async () => window['auth0data'].token.accessToken,
49
- // isLoading: !window['auth0data'].user,
50
- // isAuthenticated: !!window['auth0data'].user,
51
- // loginWithRedirect: () => {},
52
- // logout: () => postMessage({ type: 'logout' }),
53
- // } as any)
54
- // : null;
55
- //
56
- // export const useAuth = (): ReturnType<typeof useAuth0> => {
57
- // const auth0 = useAuth0();
58
- // return externalAuth || auth0;
59
- // };
60
- //
61
- // // To support passing parameters and hints to Auth0 we need to use lower level API
62
- // const auth0Config = {
63
- // domain: process.env.NEXT_PUBLIC_AUTH0_DOMAIN as string,
64
- // clientId: process.env.NEXT_PUBLIC_AUTH0_CLIENT_ID as string,
65
- // redirectUri: origin,
66
- // audience: process.env.NEXT_PUBLIC_AUTH0_AUDIENCE,
67
- // };
68
- //
69
- // let auth0ClientInstance: Auth0Client | null = null;
70
- //
71
- // const getAuth0Client = async () => {
72
- // if (!auth0ClientInstance) {
73
- // auth0ClientInstance = await createAuth0Client(auth0Config);
74
- // }
75
- // return auth0ClientInstance;
76
- // };
77
- //
78
- // export const useExtendedAuth = () => {
79
- // const auth = useAuth0();
80
- //
81
- // const extendedLoginWithRedirect = async (options: any) => {
82
- // if (options.login_hint || options.screen_hint) {
83
- // const auth0Client = await getAuth0Client();
84
- // return auth0Client.loginWithRedirect(options);
85
- // }
86
- //
87
- // return auth.loginWithRedirect(options);
88
- // };
89
- //
90
- // return {
91
- // ...auth,
92
- // loginWithRedirect: extendedLoginWithRedirect,
93
- // };
94
- // };
95
- //
96
- // export const Provider = ({ children, authParams = {} }) => {
97
- // return (
98
- // <Auth0Provider
99
- // domain={process.env.NEXT_PUBLIC_AUTH0_DOMAIN as string}
100
- // clientId={process.env.NEXT_PUBLIC_AUTH0_CLIENT_ID as string}
101
- // authorizationParams={{
102
- // ...authParams,
103
- // redirect_uri: origin,
104
- // audience: process.env.NEXT_PUBLIC_AUTH0_AUDIENCE,
105
- // }}
106
- // >
107
- // {children}
108
- // </Auth0Provider>
109
- // );
110
- // };
111
- //
112
- // export const LoginButton = (props: ButtonProps) => {
113
- // const { loginWithRedirect } = useAuth(); //FIXME add state
114
- // return (
115
- // <Button {...props} onClick={() => loginWithRedirect()}>
116
- // Log In
117
- // </Button>
118
- // );
119
- // };
120
- //
121
- // export const LogoutButton = ({ as: Cmp = Button, children, ...props }: any) => {
122
- // const { logout, isAuthenticated, isLoading } = useAuth();
123
- // if (!isAuthenticated || isLoading) return null;
124
- //
125
- // const handleLogout = async () => {
126
- // try {
127
- // await end_session();
128
- // } catch (e) {
129
- // console.error('Cannot end session', e); // will get here if in Native
130
- // }
131
- // logout({ logoutParams: { returnTo: origin } });
132
- // };
133
- //
134
- // return (
135
- // <Cmp {...props} onClick={handleLogout} role="button">
136
- // {children || 'Log Out'}
137
- // </Cmp>
138
- // );
139
- // };
140
- //
141
- // export const useLogoutTracker = () => {
142
- // const router = useRouter();
143
- // const { logout } = useAuth();
144
- // const { setToast } = useToaster();
145
- //
146
- // useEffect(() => {
147
- // let onError;
148
- //
149
- // emitter.on(
150
- // 'error',
151
- // (onError = (restResponse: RestResponse) => {
152
- // if (restResponse.code === 401 || restResponse.message.includes('(Unauthorized)')) {
153
- // if (restResponse.message.includes('OpenAI API Key')) {
154
- // setToast('Your account is not provisioned yet. Please check your email for instructions.');
155
- // return;
156
- // }
157
- //
158
- // if (externalAuth) {
159
- // externalAuth.logout();
160
- // return;
161
- // }
162
- //
163
- // logout({
164
- // async openUrl() {
165
- // router.replace('/' as any); //FIXME Return to the same page
166
- // setToast('You have been logged out');
167
- // },
168
- // });
169
- // }
170
- // })
171
- // );
172
- //
173
- // return () => {
174
- // emitter.off('error', onError);
175
- // };
176
- // }, [logout, router, setToast]);
177
- // };
package/tsconfig.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "../utils-private/tsconfig.json",
3
- "compilerOptions": {
4
- "rootDir": "src",
5
- "outDir": "dist",
6
- "declarationDir": "dist"
7
- },
8
- "include": ["src"],
9
- "exclude": []
10
- }
package/turbo.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "$schema": "https://turbo.build/schema.json",
3
- "extends": ["//"],
4
- "tasks": {
5
- "build": {
6
- "dependsOn": ["^build"],
7
- "outputs": ["src/**/*/index.ts", "package.json", "dist/**/*"]
8
- }
9
- }
10
- }
package/vite.config.ts DELETED
@@ -1,2 +0,0 @@
1
- import config from '../utils-private/vite.config';
2
- export default config;