@loaders.gl/loader-utils 4.0.0-beta.1 → 4.0.0-beta.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.
- package/dist/es5/json-loader.js +1 -1
- package/dist/es5/lib/filesystems/node-filesystem.js +26 -60
- package/dist/es5/lib/filesystems/node-filesystem.js.map +1 -1
- package/dist/esm/json-loader.js +1 -1
- package/dist/esm/lib/filesystems/node-filesystem.js +17 -24
- package/dist/esm/lib/filesystems/node-filesystem.js.map +1 -1
- package/dist/lib/filesystems/node-filesystem.d.ts +1 -1
- package/dist/lib/filesystems/node-filesystem.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/lib/filesystems/node-filesystem.ts +15 -27
- package/dist/es5/lib/filesystems/node-filesystem.browser.js +0 -172
- package/dist/es5/lib/filesystems/node-filesystem.browser.js.map +0 -1
- package/dist/esm/lib/filesystems/node-filesystem.browser.js +0 -42
- package/dist/esm/lib/filesystems/node-filesystem.browser.js.map +0 -1
- package/dist/lib/filesystems/node-filesystem.browser.d.ts +0 -39
- package/dist/lib/filesystems/node-filesystem.browser.d.ts.map +0 -1
- package/src/lib/filesystems/node-filesystem.browser.ts +0 -61
package/dist/es5/json-loader.js
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.JSONLoader = void 0;
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
-
var VERSION = typeof "4.0.0-beta.
|
|
10
|
+
var VERSION = typeof "4.0.0-beta.2" !== 'undefined' ? "4.0.0-beta.2" : 'latest';
|
|
11
11
|
var JSONLoader = {
|
|
12
12
|
name: 'JSON',
|
|
13
13
|
id: 'json',
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -10,13 +9,14 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
10
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
var fs = _interopRequireWildcard(require("../node/fs"));
|
|
14
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
12
|
var NodeFileSystem = function () {
|
|
17
13
|
function NodeFileSystem(options) {
|
|
14
|
+
var _globalThis$loaders;
|
|
18
15
|
(0, _classCallCheck2.default)(this, NodeFileSystem);
|
|
19
|
-
|
|
16
|
+
if ((_globalThis$loaders = globalThis.loaders) !== null && _globalThis$loaders !== void 0 && _globalThis$loaders.NodeFileSystem) {
|
|
17
|
+
return new globalThis.loaders.NodeFileSystem(options);
|
|
18
|
+
}
|
|
19
|
+
throw new Error('Can\'t instantiate NodeFileSystem in browser. Make sure to import @loaders.gl/polyfills first.');
|
|
20
20
|
}
|
|
21
21
|
(0, _createClass2.default)(NodeFileSystem, [{
|
|
22
22
|
key: "readdir",
|
|
@@ -30,11 +30,8 @@ var NodeFileSystem = function () {
|
|
|
30
30
|
case 0:
|
|
31
31
|
dirname = _args.length > 0 && _args[0] !== undefined ? _args[0] : '.';
|
|
32
32
|
options = _args.length > 1 ? _args[1] : undefined;
|
|
33
|
-
_context.
|
|
34
|
-
|
|
35
|
-
case 4:
|
|
36
|
-
return _context.abrupt("return", _context.sent);
|
|
37
|
-
case 5:
|
|
33
|
+
return _context.abrupt("return", []);
|
|
34
|
+
case 3:
|
|
38
35
|
case "end":
|
|
39
36
|
return _context.stop();
|
|
40
37
|
}
|
|
@@ -49,22 +46,16 @@ var NodeFileSystem = function () {
|
|
|
49
46
|
key: "stat",
|
|
50
47
|
value: function () {
|
|
51
48
|
var _stat = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(path, options) {
|
|
52
|
-
var info;
|
|
53
49
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
54
50
|
while (1) switch (_context2.prev = _context2.next) {
|
|
55
51
|
case 0:
|
|
56
|
-
_context2.next = 2;
|
|
57
|
-
return fs.stat(path, options);
|
|
58
|
-
case 2:
|
|
59
|
-
info = _context2.sent;
|
|
60
52
|
return _context2.abrupt("return", {
|
|
61
|
-
size:
|
|
53
|
+
size: 0,
|
|
62
54
|
isDirectory: function isDirectory() {
|
|
63
55
|
return false;
|
|
64
|
-
}
|
|
65
|
-
info: info
|
|
56
|
+
}
|
|
66
57
|
});
|
|
67
|
-
case
|
|
58
|
+
case 1:
|
|
68
59
|
case "end":
|
|
69
60
|
return _context2.stop();
|
|
70
61
|
}
|
|
@@ -79,17 +70,15 @@ var NodeFileSystem = function () {
|
|
|
79
70
|
key: "fetch",
|
|
80
71
|
value: function () {
|
|
81
72
|
var _fetch = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(path, options) {
|
|
82
|
-
var fallbackFetch;
|
|
83
73
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
84
74
|
while (1) switch (_context3.prev = _context3.next) {
|
|
85
75
|
case 0:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
case 2:
|
|
76
|
+
return _context3.abrupt("return", globalThis.fetch(path, options));
|
|
77
|
+
case 1:
|
|
89
78
|
case "end":
|
|
90
79
|
return _context3.stop();
|
|
91
80
|
}
|
|
92
|
-
}, _callee3
|
|
81
|
+
}, _callee3);
|
|
93
82
|
}));
|
|
94
83
|
function fetch(_x3, _x4) {
|
|
95
84
|
return _fetch.apply(this, arguments);
|
|
@@ -103,11 +92,8 @@ var NodeFileSystem = function () {
|
|
|
103
92
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
104
93
|
while (1) switch (_context4.prev = _context4.next) {
|
|
105
94
|
case 0:
|
|
106
|
-
_context4.
|
|
107
|
-
|
|
108
|
-
case 2:
|
|
109
|
-
return _context4.abrupt("return", _context4.sent);
|
|
110
|
-
case 3:
|
|
95
|
+
return _context4.abrupt("return", 0);
|
|
96
|
+
case 1:
|
|
111
97
|
case "end":
|
|
112
98
|
return _context4.stop();
|
|
113
99
|
}
|
|
@@ -125,11 +111,6 @@ var NodeFileSystem = function () {
|
|
|
125
111
|
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
126
112
|
while (1) switch (_context5.prev = _context5.next) {
|
|
127
113
|
case 0:
|
|
128
|
-
_context5.next = 2;
|
|
129
|
-
return fs.close(fd);
|
|
130
|
-
case 2:
|
|
131
|
-
return _context5.abrupt("return", _context5.sent);
|
|
132
|
-
case 3:
|
|
133
114
|
case "end":
|
|
134
115
|
return _context5.stop();
|
|
135
116
|
}
|
|
@@ -144,16 +125,16 @@ var NodeFileSystem = function () {
|
|
|
144
125
|
key: "fstat",
|
|
145
126
|
value: function () {
|
|
146
127
|
var _fstat = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee6(fd) {
|
|
147
|
-
var info;
|
|
148
128
|
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
149
129
|
while (1) switch (_context6.prev = _context6.next) {
|
|
150
130
|
case 0:
|
|
151
|
-
_context6.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
131
|
+
return _context6.abrupt("return", {
|
|
132
|
+
size: 0,
|
|
133
|
+
isDirectory: function isDirectory() {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
case 1:
|
|
157
138
|
case "end":
|
|
158
139
|
return _context6.stop();
|
|
159
140
|
}
|
|
@@ -168,31 +149,16 @@ var NodeFileSystem = function () {
|
|
|
168
149
|
key: "read",
|
|
169
150
|
value: function () {
|
|
170
151
|
var _read = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee7(fd, _ref) {
|
|
171
|
-
var _ref$buffer, buffer, _ref$offset, offset, _ref$length, length, _ref$position, position
|
|
152
|
+
var _ref$buffer, buffer, _ref$offset, offset, _ref$length, length, _ref$position, position;
|
|
172
153
|
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
173
154
|
while (1) switch (_context7.prev = _context7.next) {
|
|
174
155
|
case 0:
|
|
175
156
|
_ref$buffer = _ref.buffer, buffer = _ref$buffer === void 0 ? null : _ref$buffer, _ref$offset = _ref.offset, offset = _ref$offset === void 0 ? 0 : _ref$offset, _ref$length = _ref.length, length = _ref$length === void 0 ? buffer.byteLength : _ref$length, _ref$position = _ref.position, position = _ref$position === void 0 ? null : _ref$position;
|
|
176
|
-
totalBytesRead = 0;
|
|
177
|
-
case 2:
|
|
178
|
-
if (!(totalBytesRead < length)) {
|
|
179
|
-
_context7.next = 10;
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
_context7.next = 5;
|
|
183
|
-
return fs.read(fd, buffer, offset + totalBytesRead, length - totalBytesRead, position + totalBytesRead);
|
|
184
|
-
case 5:
|
|
185
|
-
_yield$fs$read = _context7.sent;
|
|
186
|
-
bytesRead = _yield$fs$read.bytesRead;
|
|
187
|
-
totalBytesRead += bytesRead;
|
|
188
|
-
_context7.next = 2;
|
|
189
|
-
break;
|
|
190
|
-
case 10:
|
|
191
157
|
return _context7.abrupt("return", {
|
|
192
|
-
bytesRead:
|
|
193
|
-
buffer:
|
|
158
|
+
bytesRead: 0,
|
|
159
|
+
buffer: new Uint8Array(0)
|
|
194
160
|
});
|
|
195
|
-
case
|
|
161
|
+
case 2:
|
|
196
162
|
case "end":
|
|
197
163
|
return _context7.stop();
|
|
198
164
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-filesystem.js","names":["
|
|
1
|
+
{"version":3,"file":"node-filesystem.js","names":["NodeFileSystem","options","_globalThis$loaders","_classCallCheck2","default","globalThis","loaders","Error","_createClass2","key","value","_readdir","_asyncToGenerator2","_regenerator","mark","_callee","dirname","_args","arguments","wrap","_callee$","_context","prev","next","length","undefined","abrupt","stop","readdir","apply","_stat","_callee2","path","_callee2$","_context2","size","isDirectory","stat","_x","_x2","_fetch","_callee3","_callee3$","_context3","fetch","_x3","_x4","_open","_callee4","flags","mode","_callee4$","_context4","open","_x5","_x6","_x7","_close","_callee5","fd","_callee5$","_context5","close","_x8","_fstat","_callee6","_callee6$","_context6","fstat","_x9","_read","_callee7","_ref","_ref$buffer","buffer","_ref$offset","offset","_ref$length","_ref$position","position","_callee7$","_context7","byteLength","bytesRead","Uint8Array","read","_x10","_x11","exports"],"sources":["../../../../src/lib/filesystems/node-filesystem.ts"],"sourcesContent":["import * as fs from '../node/fs';\nimport {FileSystem, RandomAccessReadFileSystem} from './filesystem';\n// import {fetchFile} from \"../fetch/fetch-file\"\n// import {selectLoader} from \"../api/select-loader\";\n\ntype Stat = {\n size: number;\n isDirectory: () => boolean;\n info?: fs.Stats;\n};\n\ntype ReadOptions = {\n buffer?: Buffer;\n offset?: number;\n length?: number;\n position?: number;\n};\n\n/**\n * FileSystem pass-through for Node.js\n * Compatible with BrowserFileSystem.\n * @param options\n */\nexport class NodeFileSystem implements FileSystem, RandomAccessReadFileSystem {\n // implements FileSystem\n constructor(options: {[key: string]: any}) {\n if (globalThis.loaders?.NodeFileSystem) {\n return new globalThis.loaders.NodeFileSystem(options);\n }\n throw new Error(\n 'Can\\'t instantiate NodeFileSystem in browser. Make sure to import @loaders.gl/polyfills first.'\n );\n }\n\n async readdir(dirname = '.', options?: {}): Promise<any[]> {\n return [];\n }\n\n async stat(path: string, options?: {}): Promise<Stat> {\n return {size: 0, isDirectory: () => false};\n }\n\n async fetch(path: string, options: {[key: string]: any}) {\n return globalThis.fetch(path, options);\n }\n\n // implements IRandomAccessFileSystem\n\n async open(path: string, flags: string | number, mode?: any): Promise<number> {\n return 0;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n async close(fd: number): Promise<void> {}\n\n async fstat(fd: number): Promise<Stat> {\n return {size: 0, isDirectory: () => false};\n }\n\n async read(\n fd: number,\n // @ts-ignore Possibly null\n {buffer = null, offset = 0, length = buffer.byteLength, position = null}: ReadOptions\n ): Promise<{bytesRead: number; buffer: Uint8Array}> {\n return {bytesRead: 0, buffer: new Uint8Array(0)};\n }\n}\n"],"mappings":";;;;;;;;;;;IAuBaA,cAAc;EAEzB,SAAAA,eAAYC,OAA6B,EAAE;IAAA,IAAAC,mBAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,QAAAJ,cAAA;IACzC,KAAAE,mBAAA,GAAIG,UAAU,CAACC,OAAO,cAAAJ,mBAAA,eAAlBA,mBAAA,CAAoBF,cAAc,EAAE;MACtC,OAAO,IAAIK,UAAU,CAACC,OAAO,CAACN,cAAc,CAACC,OAAO,CAAC;IACvD;IACA,MAAM,IAAIM,K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,34 +1,34 @@
|
|
|
1
|
-
import * as fs from '../node/fs';
|
|
2
1
|
export class NodeFileSystem {
|
|
3
2
|
constructor(options) {
|
|
4
|
-
|
|
3
|
+
var _globalThis$loaders;
|
|
4
|
+
if ((_globalThis$loaders = globalThis.loaders) !== null && _globalThis$loaders !== void 0 && _globalThis$loaders.NodeFileSystem) {
|
|
5
|
+
return new globalThis.loaders.NodeFileSystem(options);
|
|
6
|
+
}
|
|
7
|
+
throw new Error('Can\'t instantiate NodeFileSystem in browser. Make sure to import @loaders.gl/polyfills first.');
|
|
5
8
|
}
|
|
6
9
|
async readdir() {
|
|
7
10
|
let dirname = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '.';
|
|
8
11
|
let options = arguments.length > 1 ? arguments[1] : undefined;
|
|
9
|
-
return
|
|
12
|
+
return [];
|
|
10
13
|
}
|
|
11
14
|
async stat(path, options) {
|
|
12
|
-
const info = await fs.stat(path, options);
|
|
13
15
|
return {
|
|
14
|
-
size:
|
|
15
|
-
isDirectory: () => false
|
|
16
|
-
info
|
|
16
|
+
size: 0,
|
|
17
|
+
isDirectory: () => false
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
async fetch(path, options) {
|
|
20
|
-
|
|
21
|
-
return fallbackFetch(path, options);
|
|
21
|
+
return globalThis.fetch(path, options);
|
|
22
22
|
}
|
|
23
23
|
async open(path, flags, mode) {
|
|
24
|
-
return
|
|
25
|
-
}
|
|
26
|
-
async close(fd) {
|
|
27
|
-
return await fs.close(fd);
|
|
24
|
+
return 0;
|
|
28
25
|
}
|
|
26
|
+
async close(fd) {}
|
|
29
27
|
async fstat(fd) {
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
return {
|
|
29
|
+
size: 0,
|
|
30
|
+
isDirectory: () => false
|
|
31
|
+
};
|
|
32
32
|
}
|
|
33
33
|
async read(fd, _ref) {
|
|
34
34
|
let {
|
|
@@ -37,16 +37,9 @@ export class NodeFileSystem {
|
|
|
37
37
|
length = buffer.byteLength,
|
|
38
38
|
position = null
|
|
39
39
|
} = _ref;
|
|
40
|
-
let totalBytesRead = 0;
|
|
41
|
-
while (totalBytesRead < length) {
|
|
42
|
-
const {
|
|
43
|
-
bytesRead
|
|
44
|
-
} = await fs.read(fd, buffer, offset + totalBytesRead, length - totalBytesRead, position + totalBytesRead);
|
|
45
|
-
totalBytesRead += bytesRead;
|
|
46
|
-
}
|
|
47
40
|
return {
|
|
48
|
-
bytesRead:
|
|
49
|
-
buffer
|
|
41
|
+
bytesRead: 0,
|
|
42
|
+
buffer: new Uint8Array(0)
|
|
50
43
|
};
|
|
51
44
|
}
|
|
52
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-filesystem.js","names":["
|
|
1
|
+
{"version":3,"file":"node-filesystem.js","names":["NodeFileSystem","constructor","options","_globalThis$loaders","globalThis","loaders","Error","readdir","dirname","arguments","length","undefined","stat","path","size","isDirectory","fetch","open","flags","mode","close","fd","fstat","read","_ref","buffer","offset","byteLength","position","bytesRead","Uint8Array"],"sources":["../../../../src/lib/filesystems/node-filesystem.ts"],"sourcesContent":["import * as fs from '../node/fs';\nimport {FileSystem, RandomAccessReadFileSystem} from './filesystem';\n// import {fetchFile} from \"../fetch/fetch-file\"\n// import {selectLoader} from \"../api/select-loader\";\n\ntype Stat = {\n size: number;\n isDirectory: () => boolean;\n info?: fs.Stats;\n};\n\ntype ReadOptions = {\n buffer?: Buffer;\n offset?: number;\n length?: number;\n position?: number;\n};\n\n/**\n * FileSystem pass-through for Node.js\n * Compatible with BrowserFileSystem.\n * @param options\n */\nexport class NodeFileSystem implements FileSystem, RandomAccessReadFileSystem {\n // implements FileSystem\n constructor(options: {[key: string]: any}) {\n if (globalThis.loaders?.NodeFileSystem) {\n return new globalThis.loaders.NodeFileSystem(options);\n }\n throw new Error(\n 'Can\\'t instantiate NodeFileSystem in browser. Make sure to import @loaders.gl/polyfills first.'\n );\n }\n\n async readdir(dirname = '.', options?: {}): Promise<any[]> {\n return [];\n }\n\n async stat(path: string, options?: {}): Promise<Stat> {\n return {size: 0, isDirectory: () => false};\n }\n\n async fetch(path: string, options: {[key: string]: any}) {\n return globalThis.fetch(path, options);\n }\n\n // implements IRandomAccessFileSystem\n\n async open(path: string, flags: string | number, mode?: any): Promise<number> {\n return 0;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n async close(fd: number): Promise<void> {}\n\n async fstat(fd: number): Promise<Stat> {\n return {size: 0, isDirectory: () => false};\n }\n\n async read(\n fd: number,\n // @ts-ignore Possibly null\n {buffer = null, offset = 0, length = buffer.byteLength, position = null}: ReadOptions\n ): Promise<{bytesRead: number; buffer: Uint8Array}> {\n return {bytesRead: 0, buffer: new Uint8Array(0)};\n }\n}\n"],"mappings":"AAuBA,OAAO,MAAMA,cAAc,CAAmD;EAE5EC,WAAWA,CAACC,OAA6B,EAAE;IAAA,IAAAC,mBAAA;IACzC,KAAAA,mBAAA,GAAIC,UAAU,CAACC,OAAO,cAAAF,mBAAA,eAAlBA,mBAAA,CAAoBH,cAAc,EAAE;MACtC,OAAO,IAAII,UAAU,CAACC,OAAO,CAACL,cAAc,CAACE,OAAO,CAAC;IACvD;IACA,MAAM,IAAII,KAAK,CACb,gGACF,CAAC;EACH;EAEA,MAAMC,OAAOA,CAAA,EAA8C;IAAA,IAA7CC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,GAAG;IAAA,IAAEP,OAAY,GAAAO,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;IACvC,OAAO,EAAE;EACX;EAEA,MAAMC,IAAIA,CAACC,IAAY,EAAEX,OAAY,EAAiB;IACpD,OAAO;MAACY,IAAI,EAAE,CAAC;MAAEC,WAAW,EAAEA,CAAA,KAAM;IAAK,CAAC;EAC5C;EAEA,MAAMC,KAAKA,CAACH,IAAY,EAAEX,OAA6B,EAAE;IACvD,OAAOE,UAAU,CAACY,KAAK,CAACH,IAAI,EAAEX,OAAO,CAAC;EACxC;EAIA,MAAMe,IAAIA,CAACJ,IAAY,EAAEK,KAAsB,EAAEC,IAAU,EAAmB;IAC5E,OAAO,CAAC;EACV;EAGA,MAAMC,KAAKA,CAACC,EAAU,EAAiB,CAAC;EAExC,MAAMC,KAAKA,CAACD,EAAU,EAAiB;IACrC,OAAO;MAACP,IAAI,EAAE,CAAC;MAAEC,WAAW,EAAEA,CAAA,KAAM;IAAK,CAAC;EAC5C;EAEA,MAAMQ,IAAIA,CACRF,EAAU,EAAAG,IAAA,EAGwC;IAAA,IADlD;MAACC,MAAM,GAAG,IAAI;MAAEC,MAAM,GAAG,CAAC;MAAEhB,MAAM,GAAGe,MAAM,CAACE,UAAU;MAAEC,QAAQ,GAAG;IAAiB,CAAC,GAAAJ,IAAA;IAErF,OAAO;MAACK,SAAS,EAAE,CAAC;MAAEJ,MAAM,EAAE,IAAIK,UAAU,CAAC,CAAC;IAAC,CAAC;EAClD;AACF"}
|
|
@@ -26,7 +26,7 @@ export declare class NodeFileSystem implements FileSystem, RandomAccessReadFileS
|
|
|
26
26
|
stat(path: string, options?: {}): Promise<Stat>;
|
|
27
27
|
fetch(path: string, options: {
|
|
28
28
|
[key: string]: any;
|
|
29
|
-
}): Promise<
|
|
29
|
+
}): Promise<Response>;
|
|
30
30
|
open(path: string, flags: string | number, mode?: any): Promise<number>;
|
|
31
31
|
close(fd: number): Promise<void>;
|
|
32
32
|
fstat(fd: number): Promise<Stat>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-filesystem.d.ts","sourceRoot":"","sources":["../../../src/lib/filesystems/node-filesystem.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAC,UAAU,EAAE,0BAA0B,EAAC,MAAM,cAAc,CAAC;AAIpE,KAAK,IAAI,GAAG;IACV,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,OAAO,CAAC;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AI,CAAC;IAI/C,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC;IAMjD,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAKvE,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAEhC,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhC,IAAI,CACR,EAAE,EAAE,MAAM,EAEV,EAAC,MAAa,EAAE,MAAU,EAAE,MAA0B,EAAE,QAAe,EAAC,EAAE,WAAW,GACpF,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,UAAU,CAAA;KAAC,CAAC;CAGpD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/loader-utils",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.2",
|
|
4
4
|
"description": "Framework-independent loaders for 3D graphics formats",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"scripts": {},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@babel/runtime": "^7.3.1",
|
|
45
|
-
"@loaders.gl/worker-utils": "4.0.0-beta.
|
|
45
|
+
"@loaders.gl/worker-utils": "4.0.0-beta.2",
|
|
46
46
|
"@probe.gl/stats": "^4.0.2"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "79c2033f755e88e11bc30a04428e3666b177b8fc"
|
|
49
49
|
}
|
|
@@ -24,37 +24,37 @@ type ReadOptions = {
|
|
|
24
24
|
export class NodeFileSystem implements FileSystem, RandomAccessReadFileSystem {
|
|
25
25
|
// implements FileSystem
|
|
26
26
|
constructor(options: {[key: string]: any}) {
|
|
27
|
-
|
|
27
|
+
if (globalThis.loaders?.NodeFileSystem) {
|
|
28
|
+
return new globalThis.loaders.NodeFileSystem(options);
|
|
29
|
+
}
|
|
30
|
+
throw new Error(
|
|
31
|
+
'Can\'t instantiate NodeFileSystem in browser. Make sure to import @loaders.gl/polyfills first.'
|
|
32
|
+
);
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
async readdir(dirname = '.', options?: {}): Promise<any[]> {
|
|
31
|
-
return
|
|
36
|
+
return [];
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
async stat(path: string, options?: {}): Promise<Stat> {
|
|
35
|
-
|
|
36
|
-
return {size: Number(info.size), isDirectory: () => false, info};
|
|
40
|
+
return {size: 0, isDirectory: () => false};
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
async fetch(path: string, options: {[key: string]: any}) {
|
|
40
|
-
|
|
41
|
-
// eslint-disable-next-line
|
|
42
|
-
const fallbackFetch = options.fetch || this.fetch;
|
|
43
|
-
return fallbackFetch(path, options);
|
|
44
|
+
return globalThis.fetch(path, options);
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
// implements IRandomAccessFileSystem
|
|
48
|
+
|
|
47
49
|
async open(path: string, flags: string | number, mode?: any): Promise<number> {
|
|
48
|
-
return
|
|
50
|
+
return 0;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
54
|
+
async close(fd: number): Promise<void> {}
|
|
54
55
|
|
|
55
56
|
async fstat(fd: number): Promise<Stat> {
|
|
56
|
-
|
|
57
|
-
return info;
|
|
57
|
+
return {size: 0, isDirectory: () => false};
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
async read(
|
|
@@ -62,18 +62,6 @@ export class NodeFileSystem implements FileSystem, RandomAccessReadFileSystem {
|
|
|
62
62
|
// @ts-ignore Possibly null
|
|
63
63
|
{buffer = null, offset = 0, length = buffer.byteLength, position = null}: ReadOptions
|
|
64
64
|
): Promise<{bytesRead: number; buffer: Uint8Array}> {
|
|
65
|
-
|
|
66
|
-
// Read in loop until we get required number of bytes
|
|
67
|
-
while (totalBytesRead < length) {
|
|
68
|
-
const {bytesRead} = await fs.read(
|
|
69
|
-
fd,
|
|
70
|
-
buffer,
|
|
71
|
-
offset + totalBytesRead,
|
|
72
|
-
length - totalBytesRead,
|
|
73
|
-
position + totalBytesRead
|
|
74
|
-
);
|
|
75
|
-
totalBytesRead += bytesRead;
|
|
76
|
-
}
|
|
77
|
-
return {bytesRead: totalBytesRead, buffer};
|
|
65
|
+
return {bytesRead: 0, buffer: new Uint8Array(0)};
|
|
78
66
|
}
|
|
79
67
|
}
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.NodeFileSystem = void 0;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
|
-
var NodeFileSystem = function () {
|
|
13
|
-
function NodeFileSystem(options) {
|
|
14
|
-
(0, _classCallCheck2.default)(this, NodeFileSystem);
|
|
15
|
-
throw new Error('Can\'t instantiate NodeFileSystem in browser');
|
|
16
|
-
}
|
|
17
|
-
(0, _createClass2.default)(NodeFileSystem, [{
|
|
18
|
-
key: "readdir",
|
|
19
|
-
value: function () {
|
|
20
|
-
var _readdir = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee() {
|
|
21
|
-
var dirname,
|
|
22
|
-
options,
|
|
23
|
-
_args = arguments;
|
|
24
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
25
|
-
while (1) switch (_context.prev = _context.next) {
|
|
26
|
-
case 0:
|
|
27
|
-
dirname = _args.length > 0 && _args[0] !== undefined ? _args[0] : '.';
|
|
28
|
-
options = _args.length > 1 ? _args[1] : undefined;
|
|
29
|
-
return _context.abrupt("return", []);
|
|
30
|
-
case 3:
|
|
31
|
-
case "end":
|
|
32
|
-
return _context.stop();
|
|
33
|
-
}
|
|
34
|
-
}, _callee);
|
|
35
|
-
}));
|
|
36
|
-
function readdir() {
|
|
37
|
-
return _readdir.apply(this, arguments);
|
|
38
|
-
}
|
|
39
|
-
return readdir;
|
|
40
|
-
}()
|
|
41
|
-
}, {
|
|
42
|
-
key: "stat",
|
|
43
|
-
value: function () {
|
|
44
|
-
var _stat = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(path, options) {
|
|
45
|
-
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
46
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
47
|
-
case 0:
|
|
48
|
-
return _context2.abrupt("return", {
|
|
49
|
-
size: 0,
|
|
50
|
-
isDirectory: function isDirectory() {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
case 1:
|
|
55
|
-
case "end":
|
|
56
|
-
return _context2.stop();
|
|
57
|
-
}
|
|
58
|
-
}, _callee2);
|
|
59
|
-
}));
|
|
60
|
-
function stat(_x, _x2) {
|
|
61
|
-
return _stat.apply(this, arguments);
|
|
62
|
-
}
|
|
63
|
-
return stat;
|
|
64
|
-
}()
|
|
65
|
-
}, {
|
|
66
|
-
key: "fetch",
|
|
67
|
-
value: function () {
|
|
68
|
-
var _fetch = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(path, options) {
|
|
69
|
-
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
70
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
71
|
-
case 0:
|
|
72
|
-
return _context3.abrupt("return", globalThis.fetch(path, options));
|
|
73
|
-
case 1:
|
|
74
|
-
case "end":
|
|
75
|
-
return _context3.stop();
|
|
76
|
-
}
|
|
77
|
-
}, _callee3);
|
|
78
|
-
}));
|
|
79
|
-
function fetch(_x3, _x4) {
|
|
80
|
-
return _fetch.apply(this, arguments);
|
|
81
|
-
}
|
|
82
|
-
return fetch;
|
|
83
|
-
}()
|
|
84
|
-
}, {
|
|
85
|
-
key: "open",
|
|
86
|
-
value: function () {
|
|
87
|
-
var _open = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee4(path, flags, mode) {
|
|
88
|
-
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
89
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
90
|
-
case 0:
|
|
91
|
-
return _context4.abrupt("return", 0);
|
|
92
|
-
case 1:
|
|
93
|
-
case "end":
|
|
94
|
-
return _context4.stop();
|
|
95
|
-
}
|
|
96
|
-
}, _callee4);
|
|
97
|
-
}));
|
|
98
|
-
function open(_x5, _x6, _x7) {
|
|
99
|
-
return _open.apply(this, arguments);
|
|
100
|
-
}
|
|
101
|
-
return open;
|
|
102
|
-
}()
|
|
103
|
-
}, {
|
|
104
|
-
key: "close",
|
|
105
|
-
value: function () {
|
|
106
|
-
var _close = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee5(fd) {
|
|
107
|
-
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
108
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
109
|
-
case 0:
|
|
110
|
-
case "end":
|
|
111
|
-
return _context5.stop();
|
|
112
|
-
}
|
|
113
|
-
}, _callee5);
|
|
114
|
-
}));
|
|
115
|
-
function close(_x8) {
|
|
116
|
-
return _close.apply(this, arguments);
|
|
117
|
-
}
|
|
118
|
-
return close;
|
|
119
|
-
}()
|
|
120
|
-
}, {
|
|
121
|
-
key: "fstat",
|
|
122
|
-
value: function () {
|
|
123
|
-
var _fstat = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee6(fd) {
|
|
124
|
-
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
125
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
126
|
-
case 0:
|
|
127
|
-
return _context6.abrupt("return", {
|
|
128
|
-
size: 0,
|
|
129
|
-
isDirectory: function isDirectory() {
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
case 1:
|
|
134
|
-
case "end":
|
|
135
|
-
return _context6.stop();
|
|
136
|
-
}
|
|
137
|
-
}, _callee6);
|
|
138
|
-
}));
|
|
139
|
-
function fstat(_x9) {
|
|
140
|
-
return _fstat.apply(this, arguments);
|
|
141
|
-
}
|
|
142
|
-
return fstat;
|
|
143
|
-
}()
|
|
144
|
-
}, {
|
|
145
|
-
key: "read",
|
|
146
|
-
value: function () {
|
|
147
|
-
var _read = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee7(fd, _ref) {
|
|
148
|
-
var _ref$buffer, buffer, _ref$offset, offset, _ref$length, length, _ref$position, position;
|
|
149
|
-
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
150
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
151
|
-
case 0:
|
|
152
|
-
_ref$buffer = _ref.buffer, buffer = _ref$buffer === void 0 ? null : _ref$buffer, _ref$offset = _ref.offset, offset = _ref$offset === void 0 ? 0 : _ref$offset, _ref$length = _ref.length, length = _ref$length === void 0 ? buffer.byteLength : _ref$length, _ref$position = _ref.position, position = _ref$position === void 0 ? null : _ref$position;
|
|
153
|
-
return _context7.abrupt("return", {
|
|
154
|
-
bytesRead: 0,
|
|
155
|
-
buffer: new Uint8Array(0)
|
|
156
|
-
});
|
|
157
|
-
case 2:
|
|
158
|
-
case "end":
|
|
159
|
-
return _context7.stop();
|
|
160
|
-
}
|
|
161
|
-
}, _callee7);
|
|
162
|
-
}));
|
|
163
|
-
function read(_x10, _x11) {
|
|
164
|
-
return _read.apply(this, arguments);
|
|
165
|
-
}
|
|
166
|
-
return read;
|
|
167
|
-
}()
|
|
168
|
-
}]);
|
|
169
|
-
return NodeFileSystem;
|
|
170
|
-
}();
|
|
171
|
-
exports.NodeFileSystem = NodeFileSystem;
|
|
172
|
-
//# sourceMappingURL=node-filesystem.browser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"node-filesystem.browser.js","names":["NodeFileSystem","options","_classCallCheck2","default","Error","_createClass2","key","value","_readdir","_asyncToGenerator2","_regenerator","mark","_callee","dirname","_args","arguments","wrap","_callee$","_context","prev","next","length","undefined","abrupt","stop","readdir","apply","_stat","_callee2","path","_callee2$","_context2","size","isDirectory","stat","_x","_x2","_fetch","_callee3","_callee3$","_context3","globalThis","fetch","_x3","_x4","_open","_callee4","flags","mode","_callee4$","_context4","open","_x5","_x6","_x7","_close","_callee5","fd","_callee5$","_context5","close","_x8","_fstat","_callee6","_callee6$","_context6","fstat","_x9","_read","_callee7","_ref","_ref$buffer","buffer","_ref$offset","offset","_ref$length","_ref$position","position","_callee7$","_context7","byteLength","bytesRead","Uint8Array","read","_x10","_x11","exports"],"sources":["../../../../src/lib/filesystems/node-filesystem.browser.ts"],"sourcesContent":["import * as fs from '../node/fs';\nimport {FileSystem, RandomAccessReadFileSystem} from './filesystem';\n// import {fetchFile} from \"../fetch/fetch-file\"\n// import {selectLoader} from \"../api/select-loader\";\n\ntype Stat = {\n size: number;\n isDirectory: () => boolean;\n info?: fs.Stats;\n};\n\ntype ReadOptions = {\n buffer?: Buffer;\n offset?: number;\n length?: number;\n position?: number;\n};\n\n/**\n * FileSystem pass-through for Node.js\n * Compatible with BrowserFileSystem.\n * @param options\n */\nexport class NodeFileSystem implements FileSystem, RandomAccessReadFileSystem {\n // implements FileSystem\n constructor(options: {[key: string]: any}) {\n throw new Error('Can\\'t instantiate NodeFileSystem in browser');\n }\n\n async readdir(dirname = '.', options?: {}): Promise<any[]> {\n return [];\n }\n\n async stat(path: string, options?: {}): Promise<Stat> {\n return {size: 0, isDirectory: () => false};\n }\n\n async fetch(path: string, options: {[key: string]: any}) {\n return globalThis.fetch(path, options);\n }\n\n // implements IRandomAccessFileSystem\n async open(path: string, flags: string | number, mode?: any): Promise<number> {\n return 0;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n async close(fd: number): Promise<void> {}\n\n async fstat(fd: number): Promise<Stat> {\n return {size: 0, isDirectory: () => false};\n }\n\n async read(\n fd: number,\n // @ts-ignore Possibly null\n {buffer = null, offset = 0, length = buffer.byteLength, position = null}: ReadOptions\n ): Promise<{bytesRead: number; buffer: Uint8Array}> {\n return {bytesRead: 0, buffer: new Uint8Array(0)};\n }\n}\n"],"mappings":";;;;;;;;;;;IAuBaA,cAAc;EAEzB,SAAAA,eAAYC,OAA6B,EAAE;IAAA,IAAAC,gBAAA,CAAAC,OAAA,QAAAH,cAAA;IACzC,MAAM,IAAII,KAAK,CAAC,8CAA8C,CAAC;EACjE;EAAC,IAAAC,aAAA,CAAAF,OAAA,EAAAH,cAAA;IAAAM,GAAA;IAAAC,KAAA;MAAA,IAAAC,QAAA,OAAAC,kBAAA,CAAAN,OAAA,EAAAO,YAAA,CAAAP,OAAA,CAAAQ,IAAA,CAED,SAAAC,QAAA;QAAA,IAAAC,OAAA;UAAAZ,OAAA;UAAAa,KAAA,GAAAC,SAAA;QAAA,OAAAL,YAAA,CAAAP,OAAA,CAAAa,IAAA,UAAAC,SAAAC,QAAA;UAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;YAAA;cAAcP,OAAO,GAAAC,KAAA,CAAAO,MAAA,QAAAP,KAAA,QAAAQ,SAAA,GAAAR,KAAA,MAAG,GAAG;cAAEb,OAAY,GAAAa,KAAA,CAAAO,MAAA,OAAAP,KAAA,MAAAQ,SA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M,GAAAD,WAAA,cAAG,CAAC,GAAAA,WAAA,EAAAE,WAAA,GAAAL,IAAA,CAAEjD,MAAM,EAANA,MAAM,GAAAsD,WAAA,cAAGH,MAAM,CAACQ,UAAU,GAAAL,WAAA,EAAAC,aAAA,GAAAN,IAAA,CAAEO,QAAQ,EAARA,QAAQ,GAAAD,aAAA,cAAG,IAAI,GAAAA,aAAA;cAAA,OAAAG,SAAA,CAAAxD,MAAA,WAEhE;gBAAC0D,SAAS,EAAE,CAAC;gBAAET,MAAM,EAAE,IAAIU,UAAU,CAAC,CAAC;cAAC,CAAC;YAAA;YAAA;cAAA,OAAAH,SAAA,CAAAvD,IAAA;UAAA;QAAA,GAAA6C,QAAA;MAAA,CACjD;MAAA,SAAAc,KAAAC,IAAA,EAAAC,IAAA;QAAA,OAAAjB,KAAA,CAAA1C,KAAA,OAAAX,SAAA;MAAA;MAAA,OAAAoE,IAAA;IAAA;EAAA;EAAA,OAAAnF,cAAA;AAAA;AAAAsF,OAAA,CAAAtF,cAAA,GAAAA,cAAA"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export class NodeFileSystem {
|
|
2
|
-
constructor(options) {
|
|
3
|
-
throw new Error('Can\'t instantiate NodeFileSystem in browser');
|
|
4
|
-
}
|
|
5
|
-
async readdir() {
|
|
6
|
-
let dirname = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '.';
|
|
7
|
-
let options = arguments.length > 1 ? arguments[1] : undefined;
|
|
8
|
-
return [];
|
|
9
|
-
}
|
|
10
|
-
async stat(path, options) {
|
|
11
|
-
return {
|
|
12
|
-
size: 0,
|
|
13
|
-
isDirectory: () => false
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
async fetch(path, options) {
|
|
17
|
-
return globalThis.fetch(path, options);
|
|
18
|
-
}
|
|
19
|
-
async open(path, flags, mode) {
|
|
20
|
-
return 0;
|
|
21
|
-
}
|
|
22
|
-
async close(fd) {}
|
|
23
|
-
async fstat(fd) {
|
|
24
|
-
return {
|
|
25
|
-
size: 0,
|
|
26
|
-
isDirectory: () => false
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
async read(fd, _ref) {
|
|
30
|
-
let {
|
|
31
|
-
buffer = null,
|
|
32
|
-
offset = 0,
|
|
33
|
-
length = buffer.byteLength,
|
|
34
|
-
position = null
|
|
35
|
-
} = _ref;
|
|
36
|
-
return {
|
|
37
|
-
bytesRead: 0,
|
|
38
|
-
buffer: new Uint8Array(0)
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=node-filesystem.browser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"node-filesystem.browser.js","names":["NodeFileSystem","constructor","options","Error","readdir","dirname","arguments","length","undefined","stat","path","size","isDirectory","fetch","globalThis","open","flags","mode","close","fd","fstat","read","_ref","buffer","offset","byteLength","position","bytesRead","Uint8Array"],"sources":["../../../../src/lib/filesystems/node-filesystem.browser.ts"],"sourcesContent":["import * as fs from '../node/fs';\nimport {FileSystem, RandomAccessReadFileSystem} from './filesystem';\n// import {fetchFile} from \"../fetch/fetch-file\"\n// import {selectLoader} from \"../api/select-loader\";\n\ntype Stat = {\n size: number;\n isDirectory: () => boolean;\n info?: fs.Stats;\n};\n\ntype ReadOptions = {\n buffer?: Buffer;\n offset?: number;\n length?: number;\n position?: number;\n};\n\n/**\n * FileSystem pass-through for Node.js\n * Compatible with BrowserFileSystem.\n * @param options\n */\nexport class NodeFileSystem implements FileSystem, RandomAccessReadFileSystem {\n // implements FileSystem\n constructor(options: {[key: string]: any}) {\n throw new Error('Can\\'t instantiate NodeFileSystem in browser');\n }\n\n async readdir(dirname = '.', options?: {}): Promise<any[]> {\n return [];\n }\n\n async stat(path: string, options?: {}): Promise<Stat> {\n return {size: 0, isDirectory: () => false};\n }\n\n async fetch(path: string, options: {[key: string]: any}) {\n return globalThis.fetch(path, options);\n }\n\n // implements IRandomAccessFileSystem\n async open(path: string, flags: string | number, mode?: any): Promise<number> {\n return 0;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n async close(fd: number): Promise<void> {}\n\n async fstat(fd: number): Promise<Stat> {\n return {size: 0, isDirectory: () => false};\n }\n\n async read(\n fd: number,\n // @ts-ignore Possibly null\n {buffer = null, offset = 0, length = buffer.byteLength, position = null}: ReadOptions\n ): Promise<{bytesRead: number; buffer: Uint8Array}> {\n return {bytesRead: 0, buffer: new Uint8Array(0)};\n }\n}\n"],"mappings":"AAuBA,OAAO,MAAMA,cAAc,CAAmD;EAE5EC,WAAWA,CAACC,OAA6B,EAAE;IACzC,MAAM,IAAIC,KAAK,CAAC,8CAA8C,CAAC;EACjE;EAEA,MAAMC,OAAOA,CAAA,EAA8C;IAAA,IAA7CC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,GAAG;IAAA,IAAEJ,OAAY,GAAAI,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;IACvC,OAAO,EAAE;EACX;EAEA,MAAMC,IAAIA,CAACC,IAAY,EAAER,OAAY,EAAiB;IACpD,OAAO;MAACS,IAAI,EAAE,CAAC;MAAEC,WAAW,EAAEA,CAAA,KAAM;IAAK,CAAC;EAC5C;EAEA,MAAMC,KAAKA,CAACH,IAAY,EAAER,OAA6B,EAAE;IACvD,OAAOY,UAAU,CAACD,KAAK,CAACH,IAAI,EAAER,OAAO,CAAC;EACxC;EAGA,MAAMa,IAAIA,CAACL,IAAY,EAAEM,KAAsB,EAAEC,IAAU,EAAmB;IAC5E,OAAO,CAAC;EACV;EAGA,MAAMC,KAAKA,CAACC,EAAU,EAAiB,CAAC;EAExC,MAAMC,KAAKA,CAACD,EAAU,EAAiB;IACrC,OAAO;MAACR,IAAI,EAAE,CAAC;MAAEC,WAAW,EAAEA,CAAA,KAAM;IAAK,CAAC;EAC5C;EAEA,MAAMS,IAAIA,CACRF,EAAU,EAAAG,IAAA,EAGwC;IAAA,IADlD;MAACC,MAAM,GAAG,IAAI;MAAEC,MAAM,GAAG,CAAC;MAAEjB,MAAM,GAAGgB,MAAM,CAACE,UAAU;MAAEC,QAAQ,GAAG;IAAiB,CAAC,GAAAJ,IAAA;IAErF,OAAO;MAACK,SAAS,EAAE,CAAC;MAAEJ,MAAM,EAAE,IAAIK,UAAU,CAAC,CAAC;IAAC,CAAC;EAClD;AACF"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import * as fs from '../node/fs';
|
|
4
|
-
import { FileSystem, RandomAccessReadFileSystem } from './filesystem';
|
|
5
|
-
type Stat = {
|
|
6
|
-
size: number;
|
|
7
|
-
isDirectory: () => boolean;
|
|
8
|
-
info?: fs.Stats;
|
|
9
|
-
};
|
|
10
|
-
type ReadOptions = {
|
|
11
|
-
buffer?: Buffer;
|
|
12
|
-
offset?: number;
|
|
13
|
-
length?: number;
|
|
14
|
-
position?: number;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* FileSystem pass-through for Node.js
|
|
18
|
-
* Compatible with BrowserFileSystem.
|
|
19
|
-
* @param options
|
|
20
|
-
*/
|
|
21
|
-
export declare class NodeFileSystem implements FileSystem, RandomAccessReadFileSystem {
|
|
22
|
-
constructor(options: {
|
|
23
|
-
[key: string]: any;
|
|
24
|
-
});
|
|
25
|
-
readdir(dirname?: string, options?: {}): Promise<any[]>;
|
|
26
|
-
stat(path: string, options?: {}): Promise<Stat>;
|
|
27
|
-
fetch(path: string, options: {
|
|
28
|
-
[key: string]: any;
|
|
29
|
-
}): Promise<Response>;
|
|
30
|
-
open(path: string, flags: string | number, mode?: any): Promise<number>;
|
|
31
|
-
close(fd: number): Promise<void>;
|
|
32
|
-
fstat(fd: number): Promise<Stat>;
|
|
33
|
-
read(fd: number, { buffer, offset, length, position }: ReadOptions): Promise<{
|
|
34
|
-
bytesRead: number;
|
|
35
|
-
buffer: Uint8Array;
|
|
36
|
-
}>;
|
|
37
|
-
}
|
|
38
|
-
export {};
|
|
39
|
-
//# sourceMappingURL=node-filesystem.browser.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"node-filesystem.browser.d.ts","sourceRoot":"","sources":["../../../src/lib/filesystems/node-filesystem.browser.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAC,UAAU,EAAE,0BAA0B,EAAC,MAAM,cAAc,CAAC;AAIpE,KAAK,IAAI,GAAG;IACV,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,OAAO,CAAC;IAC3B,IAAI,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC;CACjB,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;GAIG;AACH,qBAAa,cAAe,YAAW,UAAU,EAAE,0BAA0B;gBAE/D,OAAO,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC;IAInC,OAAO,CAAC,OAAO,SAAM,EAAE,OAAO,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAIpD,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC;IAKjD,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAKvE,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAEhC,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhC,IAAI,CACR,EAAE,EAAE,MAAM,EAEV,EAAC,MAAa,EAAE,MAAU,EAAE,MAA0B,EAAE,QAAe,EAAC,EAAE,WAAW,GACpF,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,UAAU,CAAA;KAAC,CAAC;CAGpD"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import * as fs from '../node/fs';
|
|
2
|
-
import {FileSystem, RandomAccessReadFileSystem} from './filesystem';
|
|
3
|
-
// import {fetchFile} from "../fetch/fetch-file"
|
|
4
|
-
// import {selectLoader} from "../api/select-loader";
|
|
5
|
-
|
|
6
|
-
type Stat = {
|
|
7
|
-
size: number;
|
|
8
|
-
isDirectory: () => boolean;
|
|
9
|
-
info?: fs.Stats;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
type ReadOptions = {
|
|
13
|
-
buffer?: Buffer;
|
|
14
|
-
offset?: number;
|
|
15
|
-
length?: number;
|
|
16
|
-
position?: number;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* FileSystem pass-through for Node.js
|
|
21
|
-
* Compatible with BrowserFileSystem.
|
|
22
|
-
* @param options
|
|
23
|
-
*/
|
|
24
|
-
export class NodeFileSystem implements FileSystem, RandomAccessReadFileSystem {
|
|
25
|
-
// implements FileSystem
|
|
26
|
-
constructor(options: {[key: string]: any}) {
|
|
27
|
-
throw new Error('Can\'t instantiate NodeFileSystem in browser');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async readdir(dirname = '.', options?: {}): Promise<any[]> {
|
|
31
|
-
return [];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async stat(path: string, options?: {}): Promise<Stat> {
|
|
35
|
-
return {size: 0, isDirectory: () => false};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async fetch(path: string, options: {[key: string]: any}) {
|
|
39
|
-
return globalThis.fetch(path, options);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// implements IRandomAccessFileSystem
|
|
43
|
-
async open(path: string, flags: string | number, mode?: any): Promise<number> {
|
|
44
|
-
return 0;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
48
|
-
async close(fd: number): Promise<void> {}
|
|
49
|
-
|
|
50
|
-
async fstat(fd: number): Promise<Stat> {
|
|
51
|
-
return {size: 0, isDirectory: () => false};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
async read(
|
|
55
|
-
fd: number,
|
|
56
|
-
// @ts-ignore Possibly null
|
|
57
|
-
{buffer = null, offset = 0, length = buffer.byteLength, position = null}: ReadOptions
|
|
58
|
-
): Promise<{bytesRead: number; buffer: Uint8Array}> {
|
|
59
|
-
return {bytesRead: 0, buffer: new Uint8Array(0)};
|
|
60
|
-
}
|
|
61
|
-
}
|