@epubjs-react-native/file-system 1.1.0 → 1.1.2-beta.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.
@@ -123,6 +123,9 @@ function useFileSystem() {
123
123
  }
124
124
  });
125
125
  }); }, []);
126
+ var writeAsStringAsync = (0, react_1.useCallback)(function (fileUri, contents, options) {
127
+ return react_native_fs_1.default.writeFile(fileUri, contents, options === null || options === void 0 ? void 0 : options.encoding);
128
+ }, []);
126
129
  return {
127
130
  file: file,
128
131
  progress: progress,
@@ -130,6 +133,14 @@ function useFileSystem() {
130
133
  size: size,
131
134
  error: error,
132
135
  success: success,
136
+ documentDirectory: react_native_fs_1.default.DocumentDirectoryPath,
137
+ bundleDirectory: react_native_fs_1.default.MainBundlePath,
138
+ cacheDirectory: react_native_fs_1.default.CachesDirectoryPath,
139
+ readAsStringAsync: function (fileUri, options) {
140
+ return react_native_fs_1.default.readFile(fileUri, options === null || options === void 0 ? void 0 : options.encoding);
141
+ },
142
+ writeAsStringAsync: writeAsStringAsync,
143
+ deleteAsync: function (fileUri) { return react_native_fs_1.default.unlink(fileUri); },
133
144
  downloadFile: downloadFile,
134
145
  getFileInfo: getFileInfo,
135
146
  };
@@ -117,6 +117,9 @@ export function useFileSystem() {
117
117
  }
118
118
  });
119
119
  }); }, []);
120
+ var writeAsStringAsync = useCallback(function (fileUri, contents, options) {
121
+ return RNFS.writeFile(fileUri, contents, options === null || options === void 0 ? void 0 : options.encoding);
122
+ }, []);
120
123
  return {
121
124
  file: file,
122
125
  progress: progress,
@@ -124,6 +127,14 @@ export function useFileSystem() {
124
127
  size: size,
125
128
  error: error,
126
129
  success: success,
130
+ documentDirectory: RNFS.DocumentDirectoryPath,
131
+ bundleDirectory: RNFS.MainBundlePath,
132
+ cacheDirectory: RNFS.CachesDirectoryPath,
133
+ readAsStringAsync: function (fileUri, options) {
134
+ return RNFS.readFile(fileUri, options === null || options === void 0 ? void 0 : options.encoding);
135
+ },
136
+ writeAsStringAsync: writeAsStringAsync,
137
+ deleteAsync: function (fileUri) { return RNFS.unlink(fileUri); },
127
138
  downloadFile: downloadFile,
128
139
  getFileInfo: getFileInfo,
129
140
  };
@@ -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.0",
3
+ "version": "1.1.2-beta.0",
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",
@@ -24,7 +24,7 @@
24
24
  "build": "npm run build:cjs && npm run build:esm && npm run build:types",
25
25
  "postbuild": "npm run copy-files:cjs && npm run copy-files:esm",
26
26
  "prerelease": "npm run lint:fix && npm run type-check && npm run test:coverage",
27
- "release": "npm run build && npm publish",
27
+ "release": "npm run build && npm publish --tag beta",
28
28
  "release-local": "npm run build && npm link && echo [FINISH]: Run \"npm link epubjs-react-native-file-system\" to link the package to your project"
29
29
  },
30
30
  "publishConfig": {
@@ -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",
@@ -78,10 +78,6 @@
78
78
  "ts-jest": "29.1.2",
79
79
  "typescript": "5.4.2"
80
80
  },
81
- "engines": {
82
- "yarn": ">= 1.22.0",
83
- "node": ">=20.0.0"
84
- },
85
81
  "config": {
86
82
  "commitizen": {
87
83
  "path": "./node_modules/commitizen-emoji"