@epubjs-react-native/file-system 1.1.3 → 1.1.5
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/README.md +3 -1
- package/dist/cjs/useFileSystem.js +48 -19
- package/dist/esm/useFileSystem.js +3 -3
- package/dist/types/types.d.ts +1 -1
- package/package.json +19 -30
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# epubjs-react-native-file-system
|
|
2
2
|
|
|
3
|
-
> epubjs-react-native-
|
|
3
|
+
> File system adapter for [epubjs-react-native](https://github.com/victorsoares96/epubjs-react-native) on bare React Native.
|
|
4
|
+
|
|
5
|
+
Uses [`@dr.pogodin/react-native-fs`](https://github.com/birdofpreyru/react-native-fs) (the maintained fork of `react-native-fs`).
|
|
4
6
|
|
|
5
7
|
## Usage
|
|
6
8
|
|
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -9,8 +42,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
42
|
});
|
|
10
43
|
};
|
|
11
44
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g =
|
|
45
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
46
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
47
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
48
|
function step(op) {
|
|
16
49
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -35,13 +68,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
68
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
69
|
}
|
|
37
70
|
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
71
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.useFileSystem =
|
|
72
|
+
exports.useFileSystem = useFileSystem;
|
|
73
|
+
var RNFS = __importStar(require("@dr.pogodin/react-native-fs"));
|
|
43
74
|
var react_1 = require("react");
|
|
44
|
-
var react_native_fs_1 = __importDefault(require("react-native-fs"));
|
|
45
75
|
function useFileSystem() {
|
|
46
76
|
var _this = this;
|
|
47
77
|
var _a = (0, react_1.useState)(null), file = _a[0], setFile = _a[1];
|
|
@@ -51,8 +81,8 @@ function useFileSystem() {
|
|
|
51
81
|
var _e = (0, react_1.useState)(null), error = _e[0], setError = _e[1];
|
|
52
82
|
var _f = (0, react_1.useState)(false), success = _f[0], setSuccess = _f[1];
|
|
53
83
|
var downloadFile = (0, react_1.useCallback)(function (fromUrl, toFile) {
|
|
54
|
-
var toFilePath = "".concat(
|
|
55
|
-
return
|
|
84
|
+
var toFilePath = "".concat(RNFS.CachesDirectoryPath, "/").concat(toFile);
|
|
85
|
+
return RNFS.downloadFile({
|
|
56
86
|
fromUrl: fromUrl,
|
|
57
87
|
toFile: toFilePath,
|
|
58
88
|
begin: function (_a) {
|
|
@@ -72,7 +102,7 @@ function useFileSystem() {
|
|
|
72
102
|
switch (_d.label) {
|
|
73
103
|
case 0:
|
|
74
104
|
if (!(statusCode === 200)) return [3 /*break*/, 2];
|
|
75
|
-
return [4 /*yield*/,
|
|
105
|
+
return [4 /*yield*/, RNFS.stat(toFilePath)];
|
|
76
106
|
case 1:
|
|
77
107
|
_c = _d.sent(), filePath = _c.path, fileSize = _c.size;
|
|
78
108
|
setFile(filePath);
|
|
@@ -107,10 +137,10 @@ function useFileSystem() {
|
|
|
107
137
|
var exists, _a, uri, isDirectoryFn, fileSize, isDirectory;
|
|
108
138
|
return __generator(this, function (_b) {
|
|
109
139
|
switch (_b.label) {
|
|
110
|
-
case 0: return [4 /*yield*/,
|
|
140
|
+
case 0: return [4 /*yield*/, RNFS.exists(fileUri)];
|
|
111
141
|
case 1:
|
|
112
142
|
exists = _b.sent();
|
|
113
|
-
return [4 /*yield*/,
|
|
143
|
+
return [4 /*yield*/, RNFS.stat(fileUri)];
|
|
114
144
|
case 2:
|
|
115
145
|
_a = _b.sent(), uri = _a.path, isDirectoryFn = _a.isDirectory, fileSize = _a.size;
|
|
116
146
|
isDirectory = isDirectoryFn();
|
|
@@ -130,18 +160,17 @@ function useFileSystem() {
|
|
|
130
160
|
size: size,
|
|
131
161
|
error: error,
|
|
132
162
|
success: success,
|
|
133
|
-
documentDirectory:
|
|
134
|
-
bundleDirectory:
|
|
135
|
-
cacheDirectory:
|
|
163
|
+
documentDirectory: RNFS.DocumentDirectoryPath,
|
|
164
|
+
bundleDirectory: RNFS.MainBundlePath,
|
|
165
|
+
cacheDirectory: RNFS.CachesDirectoryPath,
|
|
136
166
|
readAsStringAsync: function (fileUri, options) {
|
|
137
|
-
return
|
|
167
|
+
return RNFS.readFile(fileUri, options === null || options === void 0 ? void 0 : options.encoding);
|
|
138
168
|
},
|
|
139
169
|
writeAsStringAsync: function (fileUri, contents, options) {
|
|
140
|
-
return
|
|
170
|
+
return RNFS.writeFile(fileUri, contents, options === null || options === void 0 ? void 0 : options.encoding);
|
|
141
171
|
},
|
|
142
|
-
deleteAsync: function (fileUri) { return
|
|
172
|
+
deleteAsync: function (fileUri) { return RNFS.unlink(fileUri); },
|
|
143
173
|
downloadFile: downloadFile,
|
|
144
174
|
getFileInfo: getFileInfo,
|
|
145
175
|
};
|
|
146
176
|
}
|
|
147
|
-
exports.useFileSystem = useFileSystem;
|
|
@@ -8,8 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g =
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
13
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
14
|
function step(op) {
|
|
15
15
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -34,8 +34,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
34
34
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
+
import * as RNFS from '@dr.pogodin/react-native-fs';
|
|
37
38
|
import { useCallback, useState } from 'react';
|
|
38
|
-
import RNFS from 'react-native-fs';
|
|
39
39
|
export function useFileSystem() {
|
|
40
40
|
var _this = this;
|
|
41
41
|
var _a = useState(null), file = _a[0], setFile = _a[1];
|
package/dist/types/types.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export type FileSystem = {
|
|
|
20
20
|
/**
|
|
21
21
|
* URI to the directory where assets bundled with the application are stored.
|
|
22
22
|
*/
|
|
23
|
-
bundleDirectory: string |
|
|
23
|
+
bundleDirectory: string | undefined;
|
|
24
24
|
readAsStringAsync: (fileUri: string, options?: {
|
|
25
25
|
/**
|
|
26
26
|
* The encoding format to use when reading the file.
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epubjs-react-native/file-system",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
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",
|
|
7
7
|
"types": "dist/types/index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"prepare": "husky
|
|
9
|
+
"prepare": "husky",
|
|
10
10
|
"clean": "rimraf dist/",
|
|
11
11
|
"copy-files:cjs": "copyfiles -u 1 src/**/*.json dist/cjs",
|
|
12
12
|
"copy-files:esm": "copyfiles -u 1 src/**/*.json dist/esm",
|
|
13
13
|
"build:cjs": "tsc -p config/tsconfig.cjs.json --skipLibCheck",
|
|
14
14
|
"build:esm": "tsc -p config/tsconfig.esm.json --skipLibCheck",
|
|
15
15
|
"build:types": "tsc -p config/tsconfig.types.json --skipLibCheck",
|
|
16
|
-
"style:format": "
|
|
17
|
-
"lint": "
|
|
18
|
-
"lint:fix": "
|
|
16
|
+
"style:format": "biome format --write ./src",
|
|
17
|
+
"lint": "biome check ./src",
|
|
18
|
+
"lint:fix": "biome check --write ./src",
|
|
19
19
|
"test": "jest --no-cache --runInBand --passWithNoTests",
|
|
20
20
|
"test:coverage": "jest --coverage --no-cache --runInBand --passWithNoTests",
|
|
21
21
|
"type-check": "tsc --pretty --noEmit --skipLibCheck --esModuleInterop --resolveJsonModule",
|
|
@@ -25,7 +25,7 @@
|
|
|
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
27
|
"release": "npm run build && npm publish",
|
|
28
|
-
"release-local": "npm run build && npm link && echo [FINISH]: Run \"npm link epubjs-react-native
|
|
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": {
|
|
31
31
|
"access": "public"
|
|
@@ -47,36 +47,25 @@
|
|
|
47
47
|
"url": "https://github.com/victorsoares96/epubjs-react-native-file-system/issues"
|
|
48
48
|
},
|
|
49
49
|
"homepage": "https://github.com/victorsoares96/epubjs-react-native-file-system#readme",
|
|
50
|
-
"resolutions": {
|
|
51
|
-
"@types/react": "18.2.66"
|
|
52
|
-
},
|
|
53
50
|
"peerDependencies": {
|
|
54
|
-
"react": "*",
|
|
55
|
-
"react
|
|
51
|
+
"@dr.pogodin/react-native-fs": "*",
|
|
52
|
+
"react": "*"
|
|
56
53
|
},
|
|
57
54
|
"devDependencies": {
|
|
58
|
-
"@
|
|
59
|
-
"@
|
|
60
|
-
"@
|
|
61
|
-
"@
|
|
62
|
-
"commitizen": "4.3.
|
|
55
|
+
"@biomejs/biome": "2.5.12",
|
|
56
|
+
"@dr.pogodin/react-native-fs": "2.40.2",
|
|
57
|
+
"@types/jest": "29.5.14",
|
|
58
|
+
"@types/react": "19.2.18",
|
|
59
|
+
"commitizen": "4.3.2",
|
|
63
60
|
"commitizen-emoji": "1.0.5",
|
|
64
61
|
"copyfiles": "2.4.1",
|
|
65
|
-
"
|
|
66
|
-
"eslint-config-airbnb-base": "15.0.0",
|
|
67
|
-
"eslint-config-airbnb-typescript": "18.0.0",
|
|
68
|
-
"eslint-config-prettier": "9.1.0",
|
|
69
|
-
"eslint-plugin-import": "2.29.1",
|
|
70
|
-
"eslint-plugin-prettier": "5.1.3",
|
|
71
|
-
"husky": "9.0.11",
|
|
62
|
+
"husky": "9.1.7",
|
|
72
63
|
"jest": "29.7.0",
|
|
73
|
-
"lint-staged": "15.
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"ts-jest": "29.1.2",
|
|
79
|
-
"typescript": "5.4.2"
|
|
64
|
+
"lint-staged": "15.5.2",
|
|
65
|
+
"react": "19.2.8",
|
|
66
|
+
"rimraf": "6.1.3",
|
|
67
|
+
"ts-jest": "29.4.12",
|
|
68
|
+
"typescript": "5.9.3"
|
|
80
69
|
},
|
|
81
70
|
"config": {
|
|
82
71
|
"commitizen": {
|