@dxos/random-access-storage 0.8.3 → 0.8.4-main.1f223c7
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/lib/browser/index.mjs +170 -122
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +99 -41
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/browser/storage.d.ts.map +1 -1
- package/dist/types/src/browser/web-fs.d.ts.map +1 -1
- package/dist/types/src/common/abstract-storage.d.ts.map +1 -1
- package/dist/types/src/node/node-storage.d.ts.map +1 -1
- package/dist/types/src/node/storage.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -8
- package/src/browser/bench.browser.test.ts +2 -1
- package/src/browser/idb-storage.ts +1 -1
- package/src/browser/storage.browser.test.ts +3 -2
- package/src/browser/storage.ts +2 -1
- package/src/browser/web-fs.ts +2 -1
- package/src/common/abstract-storage.ts +1 -0
- package/src/node/bench.node.test.ts +4 -2
- package/src/node/node-storage.ts +2 -1
- package/src/node/storage.node.test.ts +5 -3
- package/src/node/storage.ts +2 -1
- package/dist/lib/node/index.cjs +0 -413
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/random-access-storage",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4-main.1f223c7",
|
|
4
4
|
"description": "Multiple random storage types.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"type": "module",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
+
"source": "./src/index.ts",
|
|
13
14
|
"types": "./dist/types/src/index.d.ts",
|
|
14
15
|
"browser": "./dist/lib/browser/index.mjs",
|
|
15
16
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
@@ -37,13 +38,13 @@
|
|
|
37
38
|
"random-access-file": "^2.2.1",
|
|
38
39
|
"random-access-memory": "^4.1.0",
|
|
39
40
|
"random-access-storage": "^1.3.0",
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/log": "0.8.
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
41
|
+
"@dxos/debug": "0.8.4-main.1f223c7",
|
|
42
|
+
"@dxos/log": "0.8.4-main.1f223c7",
|
|
43
|
+
"@dxos/invariant": "0.8.4-main.1f223c7",
|
|
44
|
+
"@dxos/node-std": "0.8.4-main.1f223c7",
|
|
45
|
+
"@dxos/tracing": "0.8.4-main.1f223c7",
|
|
46
|
+
"@dxos/async": "0.8.4-main.1f223c7",
|
|
47
|
+
"@dxos/util": "0.8.4-main.1f223c7"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
50
|
"@types/pify": "^3.0.2",
|
|
@@ -4,10 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
import { describe } from 'vitest';
|
|
6
6
|
|
|
7
|
-
import { createStorage } from './storage';
|
|
8
7
|
import { StorageType } from '../common';
|
|
9
8
|
import { storageBenchmark } from '../testing/benchmark.blueprint-test';
|
|
10
9
|
|
|
10
|
+
import { createStorage } from './storage';
|
|
11
|
+
|
|
11
12
|
const ROOT_DIRECTORY = 'testing';
|
|
12
13
|
|
|
13
14
|
describe.skip('bench', () => {
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
|
-
import { createStorage } from './storage';
|
|
8
7
|
import { StorageType } from '../common';
|
|
9
8
|
import { storageTests } from '../testing';
|
|
10
9
|
|
|
10
|
+
import { createStorage } from './storage';
|
|
11
|
+
|
|
11
12
|
const ROOT_DIRECTORY = 'testing';
|
|
12
13
|
|
|
13
14
|
describe('Tests for different storage types in different browsers', () => {
|
package/src/browser/storage.ts
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { MemoryStorage, type Storage, type StorageConstructor, StorageType } from '../common';
|
|
6
|
+
|
|
5
7
|
import { IDbStorage } from './idb-storage';
|
|
6
8
|
import { WebFS } from './web-fs';
|
|
7
|
-
import { MemoryStorage, StorageType, type Storage, type StorageConstructor } from '../common';
|
|
8
9
|
|
|
9
10
|
export const createStorage: StorageConstructor = ({ type, root = '' } = {}): Storage => {
|
|
10
11
|
if (type === undefined) {
|
package/src/browser/web-fs.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { EventEmitter } from 'node:events';
|
|
6
6
|
import { callbackify } from 'node:util';
|
|
7
|
+
|
|
7
8
|
import { type RandomAccessStorage } from 'random-access-storage';
|
|
8
9
|
|
|
9
10
|
import { synchronized } from '@dxos/async';
|
|
@@ -301,7 +302,7 @@ export class WebFile extends EventEmitter implements File {
|
|
|
301
302
|
|
|
302
303
|
const fileHandle = await this._fileHandle;
|
|
303
304
|
const writable = await fileHandle.createWritable({ keepExistingData: true });
|
|
304
|
-
await writable.write({ type: 'write', data: this._buffer
|
|
305
|
+
await writable.write({ type: 'write', data: this._buffer as Uint8Array<ArrayBuffer>, position: 0 });
|
|
305
306
|
await writable.close();
|
|
306
307
|
}
|
|
307
308
|
|
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import del from 'del';
|
|
6
5
|
import path from 'path';
|
|
6
|
+
|
|
7
|
+
import del from 'del';
|
|
7
8
|
import { afterAll, beforeAll, describe } from 'vitest';
|
|
8
9
|
|
|
9
|
-
import { createStorage } from './storage';
|
|
10
10
|
import { StorageType } from '../common';
|
|
11
11
|
import { storageBenchmark } from '../testing/benchmark.blueprint-test';
|
|
12
12
|
|
|
13
|
+
import { createStorage } from './storage';
|
|
14
|
+
|
|
13
15
|
const ROOT_DIRECTORY = path.resolve(path.join(__dirname, '../out', 'testing'));
|
|
14
16
|
|
|
15
17
|
/**
|
package/src/node/node-storage.ts
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import del from 'del';
|
|
6
5
|
import { existsSync } from 'node:fs';
|
|
7
6
|
import { readdir, stat } from 'node:fs/promises';
|
|
8
7
|
import { join } from 'node:path';
|
|
8
|
+
|
|
9
|
+
import del from 'del';
|
|
9
10
|
import raf from 'random-access-file';
|
|
10
11
|
import { type RandomAccessStorage } from 'random-access-storage';
|
|
11
12
|
|
|
@@ -2,16 +2,18 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import del from 'del';
|
|
6
5
|
import crypto from 'node:crypto';
|
|
7
|
-
import { promises as fs
|
|
6
|
+
import { constants, promises as fs } from 'node:fs';
|
|
8
7
|
import path from 'node:path';
|
|
8
|
+
|
|
9
|
+
import del from 'del';
|
|
9
10
|
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
|
|
10
11
|
|
|
11
|
-
import { createStorage } from './storage';
|
|
12
12
|
import { type File, StorageType } from '../common';
|
|
13
13
|
import { randomText, storageTests } from '../testing';
|
|
14
14
|
|
|
15
|
+
import { createStorage } from './storage';
|
|
16
|
+
|
|
15
17
|
const ROOT_DIRECTORY = path.resolve(path.join(__dirname, '../out', 'testing'));
|
|
16
18
|
|
|
17
19
|
const temp = () => path.join(ROOT_DIRECTORY, crypto.randomBytes(32).toString('hex'));
|
package/src/node/storage.ts
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { NodeStorage } from './node-storage';
|
|
6
5
|
import { MemoryStorage, type Storage, type StorageConstructor, StorageType } from '../common';
|
|
7
6
|
|
|
7
|
+
import { NodeStorage } from './node-storage';
|
|
8
|
+
|
|
8
9
|
export const createStorage: StorageConstructor = ({ type, root = '/tmp/dxos/testing' } = {}): Storage => {
|
|
9
10
|
if (type === undefined) {
|
|
10
11
|
return new NodeStorage(root);
|
package/dist/lib/node/index.cjs
DELETED
|
@@ -1,413 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var node_exports = {};
|
|
30
|
-
__export(node_exports, {
|
|
31
|
-
AbstractStorage: () => AbstractStorage,
|
|
32
|
-
Directory: () => Directory,
|
|
33
|
-
MemoryStorage: () => MemoryStorage,
|
|
34
|
-
StorageType: () => StorageType,
|
|
35
|
-
createStorage: () => createStorage,
|
|
36
|
-
getFullPath: () => getFullPath,
|
|
37
|
-
stringDiff: () => stringDiff,
|
|
38
|
-
wrapFile: () => wrapFile
|
|
39
|
-
});
|
|
40
|
-
module.exports = __toCommonJS(node_exports);
|
|
41
|
-
var import_node_path = require("node:path");
|
|
42
|
-
var import_node_util = require("node:util");
|
|
43
|
-
var import_debug = require("@dxos/debug");
|
|
44
|
-
var import_log = require("@dxos/log");
|
|
45
|
-
var import_node_path2 = require("node:path");
|
|
46
|
-
var import_pify = __toESM(require("pify"));
|
|
47
|
-
var import_log2 = require("@dxos/log");
|
|
48
|
-
var import_random_access_memory = __toESM(require("random-access-memory"));
|
|
49
|
-
var import_util = require("@dxos/util");
|
|
50
|
-
var import_del = __toESM(require("del"));
|
|
51
|
-
var import_node_fs = require("node:fs");
|
|
52
|
-
var import_promises = require("node:fs/promises");
|
|
53
|
-
var import_node_path3 = require("node:path");
|
|
54
|
-
var import_random_access_file = __toESM(require("random-access-file"));
|
|
55
|
-
var stringDiff = (first, second) => first.split(second).join("");
|
|
56
|
-
var getFullPath = (root, path) => (0, import_node_path2.join)(root, stringDiff(path, root));
|
|
57
|
-
var Directory = class _Directory {
|
|
58
|
-
constructor({ type, path, list, getOrCreateFile, remove, onFlush }) {
|
|
59
|
-
this.type = type;
|
|
60
|
-
this.path = path;
|
|
61
|
-
this._list = list;
|
|
62
|
-
this._getOrCreateFile = getOrCreateFile;
|
|
63
|
-
this._remove = remove;
|
|
64
|
-
this._onFlush = onFlush;
|
|
65
|
-
}
|
|
66
|
-
toString() {
|
|
67
|
-
return `Directory(${JSON.stringify({
|
|
68
|
-
type: this.type,
|
|
69
|
-
path: this.path
|
|
70
|
-
})})`;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Create a new sub-directory.
|
|
74
|
-
*/
|
|
75
|
-
createDirectory(path) {
|
|
76
|
-
return new _Directory({
|
|
77
|
-
type: this.type,
|
|
78
|
-
path: getFullPath(this.path, path),
|
|
79
|
-
list: this._list,
|
|
80
|
-
getOrCreateFile: this._getOrCreateFile,
|
|
81
|
-
remove: this._remove
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Get all files in the current directory.
|
|
86
|
-
*/
|
|
87
|
-
list() {
|
|
88
|
-
return this._list(this.path);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Get or create a new file.
|
|
92
|
-
*/
|
|
93
|
-
getOrCreateFile(filename, opts) {
|
|
94
|
-
return this._getOrCreateFile(this.path, filename, opts);
|
|
95
|
-
}
|
|
96
|
-
async flush() {
|
|
97
|
-
await this._onFlush?.();
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Close and delete all files in the directory and all its sub-directories.
|
|
101
|
-
*/
|
|
102
|
-
async delete() {
|
|
103
|
-
await this._remove();
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/common/random-access-storage/src/common/file.ts";
|
|
107
|
-
var MAX_STORAGE_OPERATION_TIME = 50;
|
|
108
|
-
var pifyFields = (object, type, fields) => {
|
|
109
|
-
for (const field of fields) {
|
|
110
|
-
if (!object[field]) {
|
|
111
|
-
} else {
|
|
112
|
-
const fn = (0, import_pify.default)(object[field].bind(object));
|
|
113
|
-
object[field] = async (...args) => {
|
|
114
|
-
const before = performance.now();
|
|
115
|
-
const res = await fn(...args);
|
|
116
|
-
const elapsed = performance.now() - before;
|
|
117
|
-
if (elapsed > MAX_STORAGE_OPERATION_TIME) {
|
|
118
|
-
(0, import_log2.log)("Slow storage operation", {
|
|
119
|
-
type,
|
|
120
|
-
operation: field,
|
|
121
|
-
elapsed
|
|
122
|
-
}, {
|
|
123
|
-
F: __dxlog_file,
|
|
124
|
-
L: 62,
|
|
125
|
-
S: void 0,
|
|
126
|
-
C: (f, a) => f(...a)
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
return res;
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return object;
|
|
134
|
-
};
|
|
135
|
-
var wrapFile = (native, type) => {
|
|
136
|
-
const file = pifyFields(native, type, [
|
|
137
|
-
"write",
|
|
138
|
-
"read",
|
|
139
|
-
"del",
|
|
140
|
-
"stat",
|
|
141
|
-
"close",
|
|
142
|
-
"destroy",
|
|
143
|
-
"truncate"
|
|
144
|
-
]);
|
|
145
|
-
return Object.assign(file, {
|
|
146
|
-
type,
|
|
147
|
-
native
|
|
148
|
-
});
|
|
149
|
-
};
|
|
150
|
-
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/common/random-access-storage/src/common/abstract-storage.ts";
|
|
151
|
-
var AbstractStorage = class {
|
|
152
|
-
// TODO(burdon): Make required.
|
|
153
|
-
constructor(path) {
|
|
154
|
-
this.path = path;
|
|
155
|
-
this._files = /* @__PURE__ */ new Map();
|
|
156
|
-
}
|
|
157
|
-
[import_node_util.inspect.custom]() {
|
|
158
|
-
return (0, import_debug.inspectObject)(this);
|
|
159
|
-
}
|
|
160
|
-
toJSON() {
|
|
161
|
-
return {
|
|
162
|
-
type: this.type,
|
|
163
|
-
path: this.path
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
get size() {
|
|
167
|
-
return this._files.size;
|
|
168
|
-
}
|
|
169
|
-
// TODO(burdon): Make required.
|
|
170
|
-
createDirectory(sub = "") {
|
|
171
|
-
return new Directory({
|
|
172
|
-
type: this.type,
|
|
173
|
-
path: getFullPath(this.path, sub),
|
|
174
|
-
list: this._list.bind(this),
|
|
175
|
-
getOrCreateFile: (...args) => this.getOrCreateFile(...args),
|
|
176
|
-
remove: () => this._remove(sub)
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Delete all files.
|
|
181
|
-
*/
|
|
182
|
-
async reset() {
|
|
183
|
-
try {
|
|
184
|
-
import_log.log.info("Erasing all data...", void 0, {
|
|
185
|
-
F: __dxlog_file2,
|
|
186
|
-
L: 60,
|
|
187
|
-
S: this,
|
|
188
|
-
C: (f, a) => f(...a)
|
|
189
|
-
});
|
|
190
|
-
await this._closeFilesInPath("");
|
|
191
|
-
await this._remove("");
|
|
192
|
-
await this._destroy();
|
|
193
|
-
(0, import_log.log)("Erased...", void 0, {
|
|
194
|
-
F: __dxlog_file2,
|
|
195
|
-
L: 64,
|
|
196
|
-
S: this,
|
|
197
|
-
C: (f, a) => f(...a)
|
|
198
|
-
});
|
|
199
|
-
} catch (err) {
|
|
200
|
-
import_log.log.catch(err, void 0, {
|
|
201
|
-
F: __dxlog_file2,
|
|
202
|
-
L: 66,
|
|
203
|
-
S: this,
|
|
204
|
-
C: (f, a) => f(...a)
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
async _list(path) {
|
|
209
|
-
return Array.from((await this._getFiles(path)).keys()).map((filename) => {
|
|
210
|
-
let name = filename.replace(path, "");
|
|
211
|
-
if (name.startsWith("/")) {
|
|
212
|
-
name = name.substring(1);
|
|
213
|
-
}
|
|
214
|
-
return name;
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
getOrCreateFile(path, filename, opts) {
|
|
218
|
-
const fullPath = (0, import_node_path.join)(path, filename);
|
|
219
|
-
let native;
|
|
220
|
-
let file = this._getFileIfExists(fullPath);
|
|
221
|
-
if (file) {
|
|
222
|
-
if (!file.closed) {
|
|
223
|
-
return file;
|
|
224
|
-
}
|
|
225
|
-
native = this._openFile(file.native);
|
|
226
|
-
}
|
|
227
|
-
if (!native) {
|
|
228
|
-
native = this._createFile(path, filename, opts);
|
|
229
|
-
}
|
|
230
|
-
file = wrapFile(native, this.type);
|
|
231
|
-
this._files.set(fullPath, file);
|
|
232
|
-
return file;
|
|
233
|
-
}
|
|
234
|
-
_destroy() {
|
|
235
|
-
return void 0;
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Attempt to reopen file.
|
|
239
|
-
*/
|
|
240
|
-
_openFile(file) {
|
|
241
|
-
return void 0;
|
|
242
|
-
}
|
|
243
|
-
_getFileIfExists(filename) {
|
|
244
|
-
if (this._files.has(filename)) {
|
|
245
|
-
const file = this._files.get(filename);
|
|
246
|
-
if (file && !file.destroyed) {
|
|
247
|
-
return file;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
async _getFiles(path) {
|
|
252
|
-
const fullPath = getFullPath(this.path, path);
|
|
253
|
-
return new Map([
|
|
254
|
-
...this._files.entries()
|
|
255
|
-
].filter(([path2, file]) => path2.includes(fullPath) && file.destroyed !== true));
|
|
256
|
-
}
|
|
257
|
-
async _closeFilesInPath(path) {
|
|
258
|
-
await Promise.all(Array.from((await this._getFiles(path)).values()).map((file) => file.close().catch((err) => import_log.log.catch(err, void 0, {
|
|
259
|
-
F: __dxlog_file2,
|
|
260
|
-
L: 134,
|
|
261
|
-
S: this,
|
|
262
|
-
C: (f, a) => f(...a)
|
|
263
|
-
}))));
|
|
264
|
-
}
|
|
265
|
-
async close() {
|
|
266
|
-
await this._closeFilesInPath("");
|
|
267
|
-
}
|
|
268
|
-
// TODO(burdon): Delete directory (not just listed files).
|
|
269
|
-
async _remove(path) {
|
|
270
|
-
await Promise.all(Array.from(await this._getFiles(path)).map(([path2, file]) => {
|
|
271
|
-
return file.destroy().then(() => this._files.delete(path2)).catch((err) => import_log.log.error(err.message, void 0, {
|
|
272
|
-
F: __dxlog_file2,
|
|
273
|
-
L: 149,
|
|
274
|
-
S: this,
|
|
275
|
-
C: (f, a) => f(...a)
|
|
276
|
-
}));
|
|
277
|
-
}));
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
var StorageType = /* @__PURE__ */ function(StorageType2) {
|
|
281
|
-
StorageType2["RAM"] = "ram";
|
|
282
|
-
StorageType2["IDB"] = "idb";
|
|
283
|
-
StorageType2["CHROME"] = "chrome";
|
|
284
|
-
StorageType2["FIREFOX"] = "firefox";
|
|
285
|
-
StorageType2["NODE"] = "node";
|
|
286
|
-
StorageType2["WEBFS"] = "webfs";
|
|
287
|
-
return StorageType2;
|
|
288
|
-
}({});
|
|
289
|
-
var MemoryStorage = class extends AbstractStorage {
|
|
290
|
-
constructor() {
|
|
291
|
-
super(...arguments);
|
|
292
|
-
this.type = StorageType.RAM;
|
|
293
|
-
}
|
|
294
|
-
_createFile(path, filename) {
|
|
295
|
-
return this._patchFile((0, import_random_access_memory.default)());
|
|
296
|
-
}
|
|
297
|
-
_openFile(file) {
|
|
298
|
-
const newFile = file.clone();
|
|
299
|
-
newFile.closed = false;
|
|
300
|
-
return this._patchFile(newFile);
|
|
301
|
-
}
|
|
302
|
-
_patchFile(file) {
|
|
303
|
-
const trueRead = file.read.bind(file);
|
|
304
|
-
file.read = (offset, size, cb) => trueRead(offset, size, (err, data) => {
|
|
305
|
-
if (err) {
|
|
306
|
-
return cb(err);
|
|
307
|
-
} else {
|
|
308
|
-
return cb(err, (0, import_util.arrayToBuffer)(data));
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
return file;
|
|
312
|
-
}
|
|
313
|
-
async getDiskInfo() {
|
|
314
|
-
let used = 0;
|
|
315
|
-
for (const file of this._files.values()) {
|
|
316
|
-
const size = file.length;
|
|
317
|
-
used += Number.isNaN(size) ? 0 : size;
|
|
318
|
-
}
|
|
319
|
-
return {
|
|
320
|
-
used
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
};
|
|
324
|
-
var NodeStorage = class extends AbstractStorage {
|
|
325
|
-
constructor() {
|
|
326
|
-
super(...arguments);
|
|
327
|
-
this.type = StorageType.NODE;
|
|
328
|
-
this._initialized = false;
|
|
329
|
-
}
|
|
330
|
-
async _loadFiles(path) {
|
|
331
|
-
if (!(0, import_node_fs.existsSync)(path)) {
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
|
-
const dir = await (0, import_promises.readdir)(path);
|
|
335
|
-
for (const entry of dir) {
|
|
336
|
-
const fullPath = (0, import_node_path3.join)(path, entry);
|
|
337
|
-
if (this._files.has(fullPath)) {
|
|
338
|
-
continue;
|
|
339
|
-
}
|
|
340
|
-
const entryInfo = await (0, import_promises.stat)(fullPath);
|
|
341
|
-
if (entryInfo.isDirectory()) {
|
|
342
|
-
await this._loadFiles(fullPath);
|
|
343
|
-
} else if (entryInfo.isFile()) {
|
|
344
|
-
const file = this._createFile(path, entry);
|
|
345
|
-
this._files.set(fullPath, wrapFile(file, this.type));
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
_createFile(path, filename, opts = {}) {
|
|
350
|
-
const file = (0, import_random_access_file.default)(filename, {
|
|
351
|
-
directory: path,
|
|
352
|
-
...opts
|
|
353
|
-
});
|
|
354
|
-
file.write(0, Buffer.from(""));
|
|
355
|
-
return file;
|
|
356
|
-
}
|
|
357
|
-
async _destroy() {
|
|
358
|
-
await (0, import_del.default)(this.path, {
|
|
359
|
-
force: true
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
async _getFiles(path) {
|
|
363
|
-
if (!this._initialized) {
|
|
364
|
-
await this._loadFiles(this.path);
|
|
365
|
-
this._initialized = true;
|
|
366
|
-
}
|
|
367
|
-
return super._getFiles(path);
|
|
368
|
-
}
|
|
369
|
-
async getDiskInfo() {
|
|
370
|
-
let used = 0;
|
|
371
|
-
const recurse = async (path) => {
|
|
372
|
-
const pathStats = await (0, import_promises.stat)(path);
|
|
373
|
-
if (pathStats.isDirectory()) {
|
|
374
|
-
const entries = await (0, import_promises.readdir)(path);
|
|
375
|
-
await Promise.all(entries.map((entry) => recurse((0, import_node_path3.join)(path, entry))));
|
|
376
|
-
} else {
|
|
377
|
-
used += pathStats.size;
|
|
378
|
-
}
|
|
379
|
-
};
|
|
380
|
-
await recurse(this.path);
|
|
381
|
-
return {
|
|
382
|
-
used
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
};
|
|
386
|
-
var createStorage = ({ type, root = "/tmp/dxos/testing" } = {}) => {
|
|
387
|
-
if (type === void 0) {
|
|
388
|
-
return new NodeStorage(root);
|
|
389
|
-
}
|
|
390
|
-
switch (type) {
|
|
391
|
-
case StorageType.RAM: {
|
|
392
|
-
return new MemoryStorage(root);
|
|
393
|
-
}
|
|
394
|
-
case StorageType.NODE: {
|
|
395
|
-
return new NodeStorage(root);
|
|
396
|
-
}
|
|
397
|
-
default: {
|
|
398
|
-
throw new Error(`Invalid type: ${type}`);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
};
|
|
402
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
403
|
-
0 && (module.exports = {
|
|
404
|
-
AbstractStorage,
|
|
405
|
-
Directory,
|
|
406
|
-
MemoryStorage,
|
|
407
|
-
StorageType,
|
|
408
|
-
createStorage,
|
|
409
|
-
getFullPath,
|
|
410
|
-
stringDiff,
|
|
411
|
-
wrapFile
|
|
412
|
-
});
|
|
413
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/common/abstract-storage.ts", "../../../src/common/utils.ts", "../../../src/common/directory.ts", "../../../src/common/file.ts", "../../../src/common/memory-storage.ts", "../../../src/common/storage.ts", "../../../src/node/node-storage.ts", "../../../src/node/storage.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2021 DXOS.org\n//\n\nimport { join } from 'node:path';\nimport { inspect } from 'node:util';\nimport type { RandomAccessStorage } from 'random-access-storage';\n\nimport { inspectObject } from '@dxos/debug';\nimport { log } from '@dxos/log';\n\nimport { Directory } from './directory';\nimport { type File, wrapFile } from './file';\nimport { type Storage, type StorageType } from './storage';\nimport { getFullPath } from './utils';\n\n/**\n * Base class for all storage implementations.\n * https://github.com/random-access-storage\n * https://github.com/random-access-storage/random-access-storage\n */\n// TODO(dmaretskyi): Remove this class.\nexport abstract class AbstractStorage implements Storage {\n protected readonly _files = new Map<string, File>();\n\n public abstract readonly type: StorageType;\n\n // TODO(burdon): Make required.\n constructor(public readonly path: string) {}\n\n [inspect.custom](): string {\n return inspectObject(this);\n }\n\n toJSON(): { type: StorageType; path: string } {\n return { type: this.type, path: this.path };\n }\n\n public get size() {\n return this._files.size;\n }\n\n // TODO(burdon): Make required.\n public createDirectory(sub = ''): Directory {\n // invariant(sub.length);\n return new Directory({\n type: this.type,\n path: getFullPath(this.path, sub),\n list: this._list.bind(this),\n getOrCreateFile: (...args) => this.getOrCreateFile(...args),\n remove: () => this._remove(sub),\n });\n }\n\n /**\n * Delete all files.\n */\n async reset(): Promise<void> {\n try {\n log.info('Erasing all data...');\n await this._closeFilesInPath('');\n await this._remove('');\n await this._destroy();\n log('Erased...');\n } catch (err: any) {\n log.catch(err);\n }\n }\n\n protected async _list(path: string): Promise<string[]> {\n // TODO(dmaretskyi): Fix me.\n return Array.from((await this._getFiles(path)).keys()).map((filename) => {\n let name = filename.replace(path, '');\n if (name.startsWith('/')) {\n name = name.substring(1);\n }\n return name;\n });\n }\n\n protected getOrCreateFile(path: string, filename: string, opts?: any): File {\n const fullPath = join(path, filename);\n\n let native;\n let file = this._getFileIfExists(fullPath);\n if (file) {\n if (!file.closed) {\n return file;\n }\n\n native = this._openFile(file.native);\n }\n\n if (!native) {\n native = this._createFile(path, filename, opts);\n }\n\n file = wrapFile(native, this.type);\n this._files.set(fullPath, file);\n return file;\n }\n\n protected _destroy(): Promise<void> | undefined {\n return undefined;\n }\n\n /**\n * Attempt to reopen file.\n */\n protected _openFile(file: RandomAccessStorage): RandomAccessStorage | undefined {\n return undefined;\n }\n\n protected abstract _createFile(path: string, filename: string, opts?: any): RandomAccessStorage;\n\n private _getFileIfExists(filename: string): File | undefined {\n if (this._files.has(filename)) {\n const file = this._files.get(filename);\n if (file && !file.destroyed) {\n return file;\n }\n }\n }\n\n protected async _getFiles(path: string): Promise<Map<string, File>> {\n const fullPath = getFullPath(this.path, path);\n return new Map(\n [...this._files.entries()].filter(([path, file]) => path.includes(fullPath) && file.destroyed !== true),\n );\n }\n\n protected async _closeFilesInPath(path: string): Promise<void> {\n await Promise.all(\n Array.from((await this._getFiles(path)).values()).map((file) => file.close().catch((err: any) => log.catch(err))),\n );\n }\n\n async close(): Promise<void> {\n await this._closeFilesInPath('');\n }\n\n // TODO(burdon): Delete directory (not just listed files).\n protected async _remove(path: string): Promise<void> {\n await Promise.all(\n Array.from(await this._getFiles(path)).map(([path, file]) => {\n return file\n .destroy()\n .then(() => this._files.delete(path))\n .catch((err: any) => log.error(err.message));\n }),\n );\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { join } from 'node:path';\n\n// TODO(burdon): Document.\nexport const stringDiff = (first: string, second: string) => first.split(second).join('');\n\nexport const getFullPath = (root: string, path: string) => join(root, stringDiff(path, root));\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { type File } from './file';\nimport { type StorageType } from './storage';\nimport { getFullPath } from './utils';\n\nexport type DirectoryParams = {\n type: StorageType;\n path: string;\n // TODO(burdon): Create interface for these methods (shared with AbstractStorage).\n list: (path: string) => Promise<string[]>;\n getOrCreateFile: (path: string, filename: string, opts?: any) => File;\n remove: () => Promise<void>;\n onFlush?: () => Promise<void>;\n};\n\n/**\n * Wraps a directory in the storage file system.\n */\nexport class Directory {\n public readonly type: StorageType;\n public readonly path: string;\n // TODO(burdon): Create interface for these methods (shared with AbstractStorage).\n private readonly _list: (path: string) => Promise<string[]>;\n private readonly _getOrCreateFile: (path: string, filename: string, opts?: any) => File;\n private readonly _remove: () => Promise<void>;\n private readonly _onFlush?: () => Promise<void>;\n\n constructor({ type, path, list, getOrCreateFile, remove, onFlush }: DirectoryParams) {\n this.type = type;\n this.path = path;\n this._list = list;\n this._getOrCreateFile = getOrCreateFile;\n this._remove = remove;\n this._onFlush = onFlush;\n }\n\n toString(): string {\n return `Directory(${JSON.stringify({ type: this.type, path: this.path })})`;\n }\n\n /**\n * Create a new sub-directory.\n */\n createDirectory(path: string): Directory {\n return new Directory({\n type: this.type,\n path: getFullPath(this.path, path),\n list: this._list,\n getOrCreateFile: this._getOrCreateFile,\n remove: this._remove,\n });\n }\n\n /**\n * Get all files in the current directory.\n */\n list(): Promise<string[]> {\n return this._list(this.path);\n }\n\n /**\n * Get or create a new file.\n */\n getOrCreateFile(filename: string, opts?: any): File {\n return this._getOrCreateFile(this.path, filename, opts);\n }\n\n async flush(): Promise<void> {\n await this._onFlush?.();\n }\n\n /**\n * Close and delete all files in the directory and all its sub-directories.\n */\n async delete(): Promise<void> {\n await this._remove();\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport pify from 'pify';\nimport type { FileStat, RandomAccessStorage, RandomAccessStorageProperties } from 'random-access-storage';\n\nimport { log } from '@dxos/log';\n\nimport { type StorageType } from './storage';\n\nconst MAX_STORAGE_OPERATION_TIME = 50;\n\n/**\n * Random access file wrapper.\n * https://github.com/random-access-storage/random-access-storage\n */\nexport interface File extends RandomAccessStorageProperties {\n readonly destroyed: boolean;\n\n // TODO(burdon): Can we remove these since they are not standard across implementations?\n readonly directory: string;\n readonly filename: string;\n\n // Added by factory.\n readonly type: StorageType;\n readonly native: RandomAccessStorage;\n\n write(offset: number, data: Buffer): Promise<void>;\n read(offset: number, size: number): Promise<Buffer>;\n del(offset: number, size: number): Promise<void>;\n stat(): Promise<FileStat>;\n close(): Promise<Error | void>;\n destroy(): Promise<Error | void>;\n\n /**\n * Save changes to disk.\n */\n flush?(): Promise<void>;\n\n // Not supported in node, memory.\n truncate?(offset: number): Promise<void>;\n\n // random-access-memory only.\n clone?(): RandomAccessStorage;\n}\n\nconst pifyFields = (object: any, type: StorageType, fields: string[]) => {\n for (const field of fields) {\n if (!object[field]) {\n // TODO(burdon): Suppress warning and throw error if used.\n // console.warn(`Field not supported for type: ${JSON.stringify({ type, field })}`);\n } else {\n const fn = pify(object[field].bind(object));\n object[field] = async (...args: any) => {\n const before = performance.now();\n\n const res = await fn(...args);\n\n const elapsed = performance.now() - before;\n if (elapsed > MAX_STORAGE_OPERATION_TIME) {\n log('Slow storage operation', { type, operation: field, elapsed });\n }\n\n return res;\n };\n }\n }\n\n return object;\n};\n\n/**\n * Construct async File wrapper.\n * NOTE: This is safe since these are interface methods only (not used internally).\n */\nexport const wrapFile = (native: RandomAccessStorage, type: StorageType): File => {\n const file = pifyFields(native, type, ['write', 'read', 'del', 'stat', 'close', 'destroy', 'truncate']);\n return Object.assign(file, { type, native });\n};\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport ram from 'random-access-memory';\nimport { type Callback, type RandomAccessStorage } from 'random-access-storage';\n\nimport { arrayToBuffer } from '@dxos/util';\n\nimport { AbstractStorage } from './abstract-storage';\nimport { type DiskInfo, StorageType } from './storage';\n\n/**\n * Storage interface implementation for RAM.\n * https://github.com/random-access-storage/random-access-memory\n */\nexport class MemoryStorage extends AbstractStorage {\n public override type: StorageType = StorageType.RAM;\n\n protected override _createFile(path: string, filename: string): RandomAccessStorage {\n return this._patchFile(ram());\n }\n\n protected override _openFile(file: RandomAccessStorage): RandomAccessStorage {\n const newFile = file.clone!();\n (newFile as any).closed = false;\n return this._patchFile(newFile);\n }\n\n private _patchFile(file: RandomAccessStorage): RandomAccessStorage {\n // Patch required to make consistent across platforms.\n const trueRead = file.read.bind(file);\n\n file.read = (offset: number, size: number, cb: Callback<Buffer>) =>\n trueRead(offset, size, (err: Error | null, data?: Buffer) => {\n if (err) {\n return cb(err);\n } else {\n return cb(err, arrayToBuffer(data!));\n }\n });\n\n return file;\n }\n\n async getDiskInfo(): Promise<DiskInfo> {\n let used = 0;\n\n for (const file of this._files.values()) {\n const size = (file as any).length;\n used += Number.isNaN(size) ? 0 : size;\n }\n\n return {\n used,\n };\n }\n}\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport { type Directory } from './directory';\n\n// TODO(burdon): Reconcile with ConfigProto.\nexport enum StorageType {\n RAM = 'ram',\n IDB = 'idb',\n /**\n * @deprecated\n */\n CHROME = 'chrome',\n /**\n * @deprecated\n */\n FIREFOX = 'firefox',\n NODE = 'node',\n /**\n * @deprecated\n */\n WEBFS = 'webfs',\n}\n\nexport type DiskInfo = {\n /**\n * Bytes.\n */\n used: number;\n};\n\nexport interface Storage {\n readonly path: string;\n readonly type: StorageType;\n readonly size: number;\n\n getDiskInfo?(): Promise<DiskInfo>;\n\n // TODO(burdon): Make required.\n createDirectory: (path?: string) => Directory;\n reset: () => Promise<void>;\n close: () => Promise<void>;\n}\n\nexport type StorageConstructor = (params?: { type?: StorageType; root?: string }) => Storage;\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport del from 'del';\nimport { existsSync } from 'node:fs';\nimport { readdir, stat } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport raf from 'random-access-file';\nimport { type RandomAccessStorage } from 'random-access-storage';\n\nimport { AbstractStorage, type DiskInfo, type Storage, StorageType, wrapFile } from '../common';\n\n/**\n * Storage interface implementation for Node.\n */\nexport class NodeStorage extends AbstractStorage implements Storage {\n public override type: StorageType = StorageType.NODE;\n private _initialized = false;\n\n private async _loadFiles(path: string): Promise<void> {\n // TODO(mykola): Do not load all files at once. It is a quick fix.\n if (!existsSync(path)) {\n return;\n }\n\n // Preload all files in a directory.\n const dir = await readdir(path);\n for (const entry of dir) {\n const fullPath = join(path, entry);\n if (this._files.has(fullPath)) {\n continue;\n }\n const entryInfo = await stat(fullPath);\n if (entryInfo.isDirectory()) {\n await this._loadFiles(fullPath);\n } else if (entryInfo.isFile()) {\n const file = this._createFile(path, entry);\n this._files.set(fullPath, wrapFile(file, this.type));\n }\n }\n }\n\n protected override _createFile(path: string, filename: string, opts: any = {}): RandomAccessStorage {\n const file = raf(filename, { directory: path, ...opts });\n\n // Empty write to create file on a drive.\n file.write(0, Buffer.from(''));\n\n return file;\n }\n\n protected override async _destroy(): Promise<void> {\n await del(this.path, { force: true });\n }\n\n protected override async _getFiles(path: string) {\n if (!this._initialized) {\n await this._loadFiles(this.path);\n this._initialized = true;\n }\n\n return super._getFiles(path);\n }\n\n async getDiskInfo(): Promise<DiskInfo> {\n let used = 0;\n\n const recurse = async (path: string) => {\n const pathStats = await stat(path);\n\n if (pathStats.isDirectory()) {\n const entries = await readdir(path);\n await Promise.all(entries.map((entry) => recurse(join(path, entry))));\n } else {\n used += pathStats.size;\n }\n };\n\n await recurse(this.path);\n\n return {\n used,\n };\n }\n}\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport { NodeStorage } from './node-storage';\nimport { MemoryStorage, type Storage, type StorageConstructor, StorageType } from '../common';\n\nexport const createStorage: StorageConstructor = ({ type, root = '/tmp/dxos/testing' } = {}): Storage => {\n if (type === undefined) {\n return new NodeStorage(root);\n }\n\n switch (type) {\n case StorageType.RAM: {\n return new MemoryStorage(root);\n }\n\n case StorageType.NODE: {\n return new NodeStorage(root);\n }\n\n default: {\n throw new Error(`Invalid type: ${type}`);\n }\n }\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,uBAAqB;AACrB,uBAAwB;AAGxB,mBAA8B;AAC9B,iBAAoB;ACLpB,IAAAA,oBAAqB;AEArB,kBAAiB;AAGjB,IAAAC,cAAoB;ACHpB,kCAAgB;AAGhB,kBAA8B;AEH9B,iBAAgB;AAChB,qBAA2B;AAC3B,sBAA8B;AAC9B,IAAAD,oBAAqB;AACrB,gCAAgB;ALDT,IAAME,aAAa,CAACC,OAAeC,WAAmBD,MAAME,MAAMD,MAAAA,EAAQE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AM;AACrB,aAAO,IAAID,YAAYxG,IAAAA;IACzB;IAEA,SAAS;AACP,YAAM,IAAI6H,MAAM,iBAAiB1H,IAAAA,EAAM;IACzC;EACF;AACF;",
|
|
6
|
-
"names": ["import_node_path", "import_log", "stringDiff", "first", "second", "split", "join", "getFullPath", "root", "path", "Directory", "type", "list", "getOrCreateFile", "remove", "onFlush", "_list", "_getOrCreateFile", "_remove", "_onFlush", "toString", "JSON", "stringify", "createDirectory", "filename", "opts", "flush", "delete", "MAX_STORAGE_OPERATION_TIME", "pifyFields", "object", "fields", "field", "fn", "pify", "bind", "args", "before", "performance", "now", "res", "elapsed", "log", "operation", "wrapFile", "native", "file", "Object", "assign", "AbstractStorage", "_files", "Map", "inspect", "custom", "inspectObject", "toJSON", "size", "sub", "reset", "info", "_closeFilesInPath", "_destroy", "err", "catch", "Array", "from", "_getFiles", "keys", "map", "name", "replace", "startsWith", "substring", "fullPath", "_getFileIfExists", "closed", "_openFile", "_createFile", "set", "undefined", "has", "get", "destroyed", "entries", "filter", "includes", "Promise", "all", "values", "close", "destroy", "then", "error", "message", "StorageType", "MemoryStorage", "RAM", "_patchFile", "ram", "newFile", "clone", "trueRead", "read", "offset", "cb", "data", "arrayToBuffer", "getDiskInfo", "used", "length", "Number", "isNaN", "NodeStorage", "NODE", "_initialized", "_loadFiles", "existsSync", "dir", "readdir", "entry", "entryInfo", "stat", "isDirectory", "isFile", "raf", "directory", "write", "Buffer", "del", "force", "recurse", "pathStats", "createStorage", "Error"]
|
|
7
|
-
}
|