@dxos/random-access-storage 0.8.4-main.67995b8 → 0.8.4-main.70d3990
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 +92 -80
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +20 -18
- 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 +10 -10
- package/src/browser/bench.browser.test.ts +2 -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/random-access-storage",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.70d3990",
|
|
4
4
|
"description": "Multiple random storage types.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -10,10 +10,10 @@
|
|
|
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
|
-
"node": "./dist/lib/node-esm/index.mjs"
|
|
16
|
-
"source": "./src/index.ts"
|
|
16
|
+
"node": "./dist/lib/node-esm/index.mjs"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"browser": {
|
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
"random-access-file": "^2.2.1",
|
|
39
39
|
"random-access-memory": "^4.1.0",
|
|
40
40
|
"random-access-storage": "^1.3.0",
|
|
41
|
-
"@dxos/async": "0.8.4-main.
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/node-std": "0.8.4-main.
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/tracing": "0.8.4-main.
|
|
47
|
-
"@dxos/util": "0.8.4-main.
|
|
41
|
+
"@dxos/async": "0.8.4-main.70d3990",
|
|
42
|
+
"@dxos/debug": "0.8.4-main.70d3990",
|
|
43
|
+
"@dxos/node-std": "0.8.4-main.70d3990",
|
|
44
|
+
"@dxos/log": "0.8.4-main.70d3990",
|
|
45
|
+
"@dxos/invariant": "0.8.4-main.70d3990",
|
|
46
|
+
"@dxos/tracing": "0.8.4-main.70d3990",
|
|
47
|
+
"@dxos/util": "0.8.4-main.70d3990"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
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);
|