@epubjs-react-native/file-system 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -130,6 +130,16 @@ function useFileSystem() {
130
130
  size: size,
131
131
  error: error,
132
132
  success: success,
133
+ documentDirectory: react_native_fs_1.default.DocumentDirectoryPath,
134
+ bundleDirectory: react_native_fs_1.default.MainBundlePath,
135
+ cacheDirectory: react_native_fs_1.default.CachesDirectoryPath,
136
+ readAsStringAsync: function (fileUri, options) {
137
+ return react_native_fs_1.default.readFile(fileUri, options === null || options === void 0 ? void 0 : options.encoding);
138
+ },
139
+ writeAsStringAsync: function (fileUri, contents, options) {
140
+ return react_native_fs_1.default.writeFile(fileUri, contents, options === null || options === void 0 ? void 0 : options.encoding);
141
+ },
142
+ deleteAsync: function (fileUri) { return react_native_fs_1.default.unlink(fileUri); },
133
143
  downloadFile: downloadFile,
134
144
  getFileInfo: getFileInfo,
135
145
  };
@@ -124,6 +124,16 @@ export function useFileSystem() {
124
124
  size: size,
125
125
  error: error,
126
126
  success: success,
127
+ documentDirectory: RNFS.DocumentDirectoryPath,
128
+ bundleDirectory: RNFS.MainBundlePath,
129
+ cacheDirectory: RNFS.CachesDirectoryPath,
130
+ readAsStringAsync: function (fileUri, options) {
131
+ return RNFS.readFile(fileUri, options === null || options === void 0 ? void 0 : options.encoding);
132
+ },
133
+ writeAsStringAsync: function (fileUri, contents, options) {
134
+ return RNFS.writeFile(fileUri, contents, options === null || options === void 0 ? void 0 : options.encoding);
135
+ },
136
+ deleteAsync: function (fileUri) { return RNFS.unlink(fileUri); },
127
137
  downloadFile: downloadFile,
128
138
  getFileInfo: getFileInfo,
129
139
  };
@@ -5,6 +5,37 @@ export type FileSystem = {
5
5
  size: number;
6
6
  error: string | null;
7
7
  success: boolean;
8
+ /**
9
+ * `file://` URI pointing to the directory where user documents for this app will be stored.
10
+ * Files stored here will remain until explicitly deleted by the app. Ends with a trailing `/`.
11
+ * Example uses are for files the user saves that they expect to see again.
12
+ */
13
+ documentDirectory: string | null;
14
+ /**
15
+ * `file://` URI pointing to the directory where temporary files used by this app will be stored.
16
+ * Files stored here may be automatically deleted by the system when low on storage.
17
+ * Example uses are for downloaded or generated files that the app just needs for one-time usage.
18
+ */
19
+ cacheDirectory: string | null;
20
+ /**
21
+ * URI to the directory where assets bundled with the application are stored.
22
+ */
23
+ bundleDirectory: string | null;
24
+ readAsStringAsync: (fileUri: string, options?: {
25
+ /**
26
+ * The encoding format to use when reading the file.
27
+ * @default 'utf8'
28
+ */
29
+ encoding?: 'utf8' | 'base64';
30
+ }) => Promise<string>;
31
+ writeAsStringAsync: (fileUri: string, contents: string, options?: {
32
+ /**
33
+ * The encoding format to use when reading the file.
34
+ * @default 'utf8'
35
+ */
36
+ encoding?: 'utf8' | 'base64';
37
+ }) => Promise<void>;
38
+ deleteAsync: (fileUri: string) => Promise<void>;
8
39
  downloadFile: (fromUrl: string, toFile: string) => Promise<{
9
40
  uri: string | null;
10
41
  mimeType: string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epubjs-react-native/file-system",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "An file system module for epubjs-react-native library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "homepage": "https://github.com/victorsoares96/epubjs-react-native-file-system#readme",
50
50
  "resolutions": {
51
- "@types/react": "18.2.65"
51
+ "@types/react": "18.2.66"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "react": "*",
@@ -56,7 +56,7 @@
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/jest": "29.5.12",
59
- "@types/react": "18.2.65",
59
+ "@types/react": "18.2.66",
60
60
  "@typescript-eslint/eslint-plugin": "7.2.0",
61
61
  "@typescript-eslint/parser": "7.2.0",
62
62
  "commitizen": "4.3.0",