@kirill.konshin/react-native 0.0.2 → 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 +3 -3
- package/dist/index.js +1 -6
- package/dist/share.js +30 -20
- package/dist/share.js.map +1 -1
- package/dist/update.d.ts.map +1 -1
- package/dist/update.js +35 -37
- package/dist/update.js.map +1 -1
- package/dist/useAppState.js +16 -15
- package/dist/useAppState.js.map +1 -1
- package/package.json +16 -5
- package/.ctirc +0 -20
- package/.turbo/turbo-build.log +0 -22
- package/CHANGELOG.md +0 -8
- package/dist/index.js.map +0 -1
- package/src/index.ts +0 -3
- package/src/share.ts +0 -31
- package/src/update.tsx +0 -44
- package/src/useAppState.ts +0 -18
- package/src-todo/auth0.tsx +0 -177
- package/tsconfig.json +0 -10
- package/turbo.json +0 -10
- package/vite.config.ts +0 -2
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
21
|
-
|
|
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"],"
|
|
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.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../src/update.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAA6B,MAAM,OAAO,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 { memo,
|
|
2
|
+
import { memo, useEffect, useState } from "react";
|
|
4
3
|
import { Text } from "react-native";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return children;
|
|
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;
|
|
36
34
|
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
//# sourceMappingURL=update.js.map
|
|
35
|
+
//#endregion
|
|
36
|
+
export { Update };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=update.js.map
|
package/dist/update.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sources":["../src/update.tsx"],"sourcesContent":["import * as Updates from 'expo-updates';\nimport { 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"],"
|
|
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"}
|
package/dist/useAppState.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
2
|
import { AppState } from "react-native";
|
|
3
|
+
//#region src/useAppState.ts
|
|
3
4
|
function useAppState() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
//# sourceMappingURL=useAppState.js.map
|
|
16
|
+
//#endregion
|
|
17
|
+
export { useAppState };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=useAppState.js.map
|
package/dist/useAppState.js.map
CHANGED
|
@@ -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"],"
|
|
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.
|
|
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": "ctix build",
|
|
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
|
|
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,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"options": [
|
|
3
|
-
{
|
|
4
|
-
"mode": "create",
|
|
5
|
-
"project": "tsconfig.json",
|
|
6
|
-
"include": "src/**/*.{ts,tsx}",
|
|
7
|
-
"exclude": [
|
|
8
|
-
"**/*.stories.*",
|
|
9
|
-
"**/*.test.*",
|
|
10
|
-
"**/*.fixture.*"
|
|
11
|
-
],
|
|
12
|
-
"startFrom": "src",
|
|
13
|
-
"backup": false,
|
|
14
|
-
"overwrite": true,
|
|
15
|
-
"generationStyle": "default-alias-named-star",
|
|
16
|
-
"output": "src",
|
|
17
|
-
"verbose": true
|
|
18
|
-
}
|
|
19
|
-
]
|
|
20
|
-
}
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
[36mvite v7.0.6 [32mbuilding SSR bundle for production...[36m[39m
|
|
2
|
-
- ctix 'create' mode start, ...
|
|
3
|
-
✔ /home/runner/work/utils/utils/packages/react-native/tsconfig.json loading complete!
|
|
4
|
-
✔ analysis export statements completed!
|
|
5
|
-
- build "index.ts" file start
|
|
6
|
-
- output file exists check, ...
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
✔ ctix 'create' mode complete!
|
|
10
|
-
transforming...
|
|
11
|
-
[32m✓[39m 4 modules transformed.
|
|
12
|
-
rendering chunks...
|
|
13
|
-
|
|
14
|
-
[vite:dts] Start generate declaration files...
|
|
15
|
-
[2mdist/[22m[36mindex.js [39m[1m[2m0.21 kB[22m[1m[22m[2m │ map: 0.09 kB[22m
|
|
16
|
-
[2mdist/[22m[36museAppState.js [39m[1m[2m0.47 kB[22m[1m[22m[2m │ map: 0.89 kB[22m
|
|
17
|
-
[2mdist/[22m[36mshare.js [39m[1m[2m0.85 kB[22m[1m[22m[2m │ map: 1.78 kB[22m
|
|
18
|
-
[2mdist/[22m[36mupdate.js [39m[1m[2m1.06 kB[22m[1m[22m[2m │ map: 2.09 kB[22m
|
|
19
|
-
[vite:dts] Declaration files built in 1478ms.
|
|
20
|
-
|
|
21
|
-
[32m✓ built in 4.71s[39m
|
|
22
|
-
Updated package.json with exports
|
package/CHANGELOG.md
DELETED
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
package/src/index.ts
DELETED
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,44 +0,0 @@
|
|
|
1
|
-
import * as Updates from 'expo-updates';
|
|
2
|
-
import { FC, memo, useEffect, useState } from 'react';
|
|
3
|
-
import { Text } from 'react-native';
|
|
4
|
-
|
|
5
|
-
export type UpdateProps = {
|
|
6
|
-
children: any;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const Update: FC<UpdateProps> = memo(function Update({ children }) {
|
|
10
|
-
//FIXME useUpdates https://blog.expo.dev/feature-preview-updates-js-api-for-expo-updates-3b92beb40dab
|
|
11
|
-
const [updating, setUpdating] = useState(true);
|
|
12
|
-
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
(async () => {
|
|
15
|
-
try {
|
|
16
|
-
if (__DEV__) {
|
|
17
|
-
setUpdating(false);
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const update = await Updates.checkForUpdateAsync();
|
|
22
|
-
|
|
23
|
-
if (!update.isAvailable) {
|
|
24
|
-
setUpdating(false);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
await Updates.fetchUpdateAsync();
|
|
29
|
-
alert('Update is available. App will reload.');
|
|
30
|
-
await Updates.reloadAsync();
|
|
31
|
-
} catch (error) {
|
|
32
|
-
// You can also add an alert() to see the error message in case of an error when fetching updates.
|
|
33
|
-
alert(`Error fetching latest Expo update: ${error}`);
|
|
34
|
-
setUpdating(false);
|
|
35
|
-
}
|
|
36
|
-
})();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
if (updating) {
|
|
40
|
-
return <Text>Checking for updates ({Updates.channel})...</Text>;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return children;
|
|
44
|
-
});
|
package/src/useAppState.ts
DELETED
|
@@ -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
|
-
}
|
package/src-todo/auth0.tsx
DELETED
|
@@ -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
package/turbo.json
DELETED
package/vite.config.ts
DELETED