@fireproof/core 0.19.119-dev-log → 0.19.120
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +8 -0
- package/{chunk-WVN66YAN.js → chunk-F4FC6B2T.js} +5 -13
- package/chunk-F4FC6B2T.js.map +1 -0
- package/{chunk-2D2X6HIB.js → chunk-RXC4JGJT.js} +13 -2
- package/chunk-RXC4JGJT.js.map +1 -0
- package/deno.json +5 -5
- package/{gateway-G4CPXEQF.js → gateway-C62S56GY.js} +2 -2
- package/{gateway-G4CPXEQF.js.map → gateway-C62S56GY.js.map} +1 -1
- package/{gateway-2O7QPHGW.js → gateway-VVS4QWDA.js} +3 -3
- package/gateway-VVS4QWDA.js.map +1 -0
- package/index.cjs +47 -21
- package/index.cjs.map +1 -1
- package/index.d.cts +2 -1
- package/index.d.ts +2 -1
- package/index.js +34 -10
- package/index.js.map +1 -1
- package/{key-bag-file-CBCAWTVG.js → key-bag-file-PWZ3QE7B.js} +3 -3
- package/{key-bag-indexdb-RTSMSGM7.js → key-bag-indexdb-SYG3YD4D.js} +3 -3
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/node/mem-filesystem.cjs.map +1 -1
- package/node/mem-filesystem.d.cts +1 -1
- package/node/mem-filesystem.d.ts +1 -1
- package/node/mem-filesystem.js.map +1 -1
- package/node/metafile-cjs.json +1 -1
- package/node/metafile-esm.json +1 -1
- package/node/node-filesystem.cjs.map +1 -1
- package/node/node-filesystem.d.cts +1 -2
- package/node/node-filesystem.d.ts +1 -2
- package/node/node-filesystem.js.map +1 -1
- package/package.json +17 -17
- package/react/index.cjs +3 -3
- package/tests/fireproof/config.test.ts +1 -0
- package/tests/fireproof/multiple-ledger.test.ts +1 -1
- package/{utils-XESRUKDJ.js → utils-ZVVGAXFE.js} +3 -3
- package/web/gateway-impl.cjs +24 -167
- package/web/gateway-impl.cjs.map +1 -1
- package/web/gateway-impl.d.cts +5 -59
- package/web/gateway-impl.d.ts +5 -59
- package/web/gateway-impl.js +7 -162
- package/web/gateway-impl.js.map +1 -1
- package/web/metafile-cjs.json +1 -1
- package/web/metafile-esm.json +1 -1
- package/chunk-2D2X6HIB.js.map +0 -1
- package/chunk-WVN66YAN.js.map +0 -1
- package/gateway-2O7QPHGW.js.map +0 -1
- package/node/types-DARSfXlb.d.cts +0 -23
- package/node/types-DARSfXlb.d.ts +0 -23
- /package/{key-bag-file-CBCAWTVG.js.map → key-bag-file-PWZ3QE7B.js.map} +0 -0
- /package/{key-bag-indexdb-RTSMSGM7.js.map → key-bag-indexdb-SYG3YD4D.js.map} +0 -0
- /package/{utils-XESRUKDJ.js.map → utils-ZVVGAXFE.js.map} +0 -0
package/node/mem-filesystem.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { PathLike, MakeDirectoryOptions, Stats } from 'fs';
|
2
2
|
import { IReaddirOptions } from 'memfs/lib/node/types/options.js';
|
3
|
-
import {
|
3
|
+
import { SysFileSystem } from '@fireproof/core';
|
4
4
|
|
5
5
|
declare class MemFileSystem implements SysFileSystem {
|
6
6
|
start(): Promise<SysFileSystem>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtime/gateways/file/node/mem-filesystem.ts"],"sourcesContent":["import type { PathLike, MakeDirectoryOptions, Stats } from \"fs\";\nimport { fs } from \"memfs\";\nimport { IReaddirOptions } from \"memfs/lib/node/types/options.js\";\nimport { toArrayBuffer } from \"./to-array-buffer.js\";\nimport type { SysFileSystem } from \"
|
1
|
+
{"version":3,"sources":["../../../src/runtime/gateways/file/node/mem-filesystem.ts"],"sourcesContent":["import type { PathLike, MakeDirectoryOptions, Stats } from \"fs\";\nimport { fs } from \"memfs\";\nimport { IReaddirOptions } from \"memfs/lib/node/types/options.js\";\nimport { toArrayBuffer } from \"./to-array-buffer.js\";\nimport type { SysFileSystem } from \"@fireproof/core\";\n\nexport class MemFileSystem implements SysFileSystem {\n async start(): Promise<SysFileSystem> {\n return this;\n }\n mkdir(path: PathLike, options?: { recursive: boolean }): Promise<string | undefined> {\n return fs.promises.mkdir(path, options);\n }\n readdir(path: PathLike, options?: IReaddirOptions): Promise<string[]> {\n return fs.promises.readdir(path, options) as Promise<string[]>;\n }\n rm(path: PathLike, options?: MakeDirectoryOptions & { recursive: boolean }): Promise<void> {\n return fs.promises.rm(path, options);\n }\n copyFile(source: PathLike, destination: PathLike): Promise<void> {\n return fs.promises.copyFile(source, destination);\n }\n async readfile(path: PathLike, options?: { encoding: BufferEncoding; flag?: string }): Promise<Uint8Array> {\n const ret = await fs.promises.readFile(path, options);\n return toArrayBuffer(ret);\n }\n stat(path: PathLike): Promise<Stats> {\n return fs.promises.stat(path) as Promise<Stats>;\n }\n unlink(path: PathLike): Promise<void> {\n return fs.promises.unlink(path);\n }\n writefile(path: PathLike, data: Uint8Array | string): Promise<void> {\n return fs.promises.writeFile(path, Buffer.from(data));\n }\n}\n"],"mappings":";;;;;AACA,SAAS,UAAU;AAKZ,IAAM,gBAAN,MAA6C;AAAA,EAClD,MAAM,QAAgC;AACpC,WAAO;AAAA,EACT;AAAA,EACA,MAAM,MAAgB,SAA+D;AACnF,WAAO,GAAG,SAAS,MAAM,MAAM,OAAO;AAAA,EACxC;AAAA,EACA,QAAQ,MAAgB,SAA8C;AACpE,WAAO,GAAG,SAAS,QAAQ,MAAM,OAAO;AAAA,EAC1C;AAAA,EACA,GAAG,MAAgB,SAAwE;AACzF,WAAO,GAAG,SAAS,GAAG,MAAM,OAAO;AAAA,EACrC;AAAA,EACA,SAAS,QAAkB,aAAsC;AAC/D,WAAO,GAAG,SAAS,SAAS,QAAQ,WAAW;AAAA,EACjD;AAAA,EACA,MAAM,SAAS,MAAgB,SAA4E;AACzG,UAAM,MAAM,MAAM,GAAG,SAAS,SAAS,MAAM,OAAO;AACpD,WAAO,cAAc,GAAG;AAAA,EAC1B;AAAA,EACA,KAAK,MAAgC;AACnC,WAAO,GAAG,SAAS,KAAK,IAAI;AAAA,EAC9B;AAAA,EACA,OAAO,MAA+B;AACpC,WAAO,GAAG,SAAS,OAAO,IAAI;AAAA,EAChC;AAAA,EACA,UAAU,MAAgB,MAA0C;AAClE,WAAO,GAAG,SAAS,UAAU,MAAM,OAAO,KAAK,IAAI,CAAC;AAAA,EACtD;AACF;","names":[]}
|
package/node/metafile-cjs.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"inputs":{"src/runtime/gateways/file/node/to-array-buffer.ts":{"bytes":313,"imports":[],"format":"esm"},"src/runtime/gateways/file/node/mem-filesystem.ts":{"bytes":
|
1
|
+
{"inputs":{"src/runtime/gateways/file/node/to-array-buffer.ts":{"bytes":313,"imports":[],"format":"esm"},"src/runtime/gateways/file/node/mem-filesystem.ts":{"bytes":1461,"imports":[{"path":"memfs","kind":"import-statement","external":true},{"path":"memfs/lib/node/types/options.js","kind":"import-statement","external":true},{"path":"src/runtime/gateways/file/node/to-array-buffer.ts","kind":"import-statement","original":"./to-array-buffer.js"}],"format":"esm"},"src/runtime/gateways/file/node/node-filesystem.ts":{"bytes":3138,"imports":[{"path":"src/runtime/gateways/file/node/to-array-buffer.ts","kind":"import-statement","original":"./to-array-buffer.js"},{"path":"@adviser/cement","kind":"import-statement","external":true},{"path":"fs/promises","kind":"dynamic-import","external":true}],"format":"esm"}},"outputs":{"dist/fireproof-core/node/mem-filesystem.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3066},"dist/fireproof-core/node/mem-filesystem.cjs":{"imports":[{"path":"memfs","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/runtime/gateways/file/node/mem-filesystem.ts","inputs":{"src/runtime/gateways/file/node/mem-filesystem.ts":{"bytesInOutput":1016},"src/runtime/gateways/file/node/to-array-buffer.ts":{"bytesInOutput":277}},"bytes":2252},"dist/fireproof-core/node/node-filesystem.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4974},"dist/fireproof-core/node/node-filesystem.cjs":{"imports":[{"path":"@adviser/cement","kind":"require-call","external":true},{"path":"fs/promises","kind":"dynamic-import","external":true}],"exports":[],"entryPoint":"src/runtime/gateways/file/node/node-filesystem.ts","inputs":{"src/runtime/gateways/file/node/node-filesystem.ts":{"bytesInOutput":1084},"src/runtime/gateways/file/node/to-array-buffer.ts":{"bytesInOutput":277}},"bytes":2919}}}
|
package/node/metafile-esm.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"inputs":{"src/runtime/gateways/file/node/to-array-buffer.ts":{"bytes":313,"imports":[],"format":"esm"},"src/runtime/gateways/file/node/mem-filesystem.ts":{"bytes":
|
1
|
+
{"inputs":{"src/runtime/gateways/file/node/to-array-buffer.ts":{"bytes":313,"imports":[],"format":"esm"},"src/runtime/gateways/file/node/mem-filesystem.ts":{"bytes":1461,"imports":[{"path":"memfs","kind":"import-statement","external":true},{"path":"memfs/lib/node/types/options.js","kind":"import-statement","external":true},{"path":"src/runtime/gateways/file/node/to-array-buffer.ts","kind":"import-statement","original":"./to-array-buffer.js"}],"format":"esm"},"src/runtime/gateways/file/node/node-filesystem.ts":{"bytes":3138,"imports":[{"path":"src/runtime/gateways/file/node/to-array-buffer.ts","kind":"import-statement","original":"./to-array-buffer.js"},{"path":"@adviser/cement","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"dynamic-import","external":true}],"format":"esm"}},"outputs":{"dist/fireproof-core/node/mem-filesystem.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":2372},"dist/fireproof-core/node/mem-filesystem.js":{"imports":[{"path":"dist/fireproof-core/node/chunk-4A4RAVNS.js","kind":"import-statement"},{"path":"memfs","kind":"import-statement","external":true}],"exports":["MemFileSystem"],"entryPoint":"src/runtime/gateways/file/node/mem-filesystem.ts","inputs":{"src/runtime/gateways/file/node/mem-filesystem.ts":{"bytesInOutput":739}},"bytes":875},"dist/fireproof-core/node/node-filesystem.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":4280},"dist/fireproof-core/node/node-filesystem.js":{"imports":[{"path":"dist/fireproof-core/node/chunk-4A4RAVNS.js","kind":"import-statement"},{"path":"@adviser/cement","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"dynamic-import","external":true}],"exports":["NodeFileSystem"],"entryPoint":"src/runtime/gateways/file/node/node-filesystem.ts","inputs":{"src/runtime/gateways/file/node/node-filesystem.ts":{"bytesInOutput":898}},"bytes":1036},"dist/fireproof-core/node/chunk-4A4RAVNS.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":735},"dist/fireproof-core/node/chunk-4A4RAVNS.js":{"imports":[],"exports":["toArrayBuffer"],"inputs":{"src/runtime/gateways/file/node/to-array-buffer.ts":{"bytesInOutput":277}},"bytes":359}}}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtime/gateways/file/node/node-filesystem.ts","../../../src/runtime/gateways/file/node/to-array-buffer.ts"],"sourcesContent":["import type { PathLike, MakeDirectoryOptions, Stats, ObjectEncodingOptions } from \"node:fs\";\nimport type { mkdir, readdir, rm, copyFile, readFile, stat, unlink, writeFile } from \"node:fs/promises\";\nimport { toArrayBuffer } from \"./to-array-buffer.js\";\nimport type { SysFileSystem } from \"
|
1
|
+
{"version":3,"sources":["../../../src/runtime/gateways/file/node/node-filesystem.ts","../../../src/runtime/gateways/file/node/to-array-buffer.ts"],"sourcesContent":["import type { PathLike, MakeDirectoryOptions, Stats, ObjectEncodingOptions } from \"node:fs\";\nimport type { mkdir, readdir, rm, copyFile, readFile, stat, unlink, writeFile } from \"node:fs/promises\";\nimport { toArrayBuffer } from \"./to-array-buffer.js\";\nimport type { SysFileSystem } from \"@fireproof/core\";\nimport { runtimeFn } from \"@adviser/cement\";\n\nexport class NodeFileSystem implements SysFileSystem {\n fs?: {\n mkdir: typeof mkdir;\n readdir: typeof readdir;\n rm: typeof rm;\n copyFile: typeof copyFile;\n readFile: typeof readFile;\n stat: typeof stat;\n unlink: typeof unlink;\n writeFile: typeof writeFile;\n };\n\n async start(): Promise<SysFileSystem> {\n this.fs = await import(\"node:fs/promises\");\n return this;\n }\n async mkdir(path: PathLike, options?: { recursive: boolean }): Promise<string | undefined> {\n return this.fs?.mkdir(path, options);\n }\n async readdir(path: PathLike, options?: ObjectEncodingOptions): Promise<string[]> {\n return this.fs?.readdir(path, options) as Promise<string[]>;\n }\n async rm(path: PathLike, options?: MakeDirectoryOptions & { recursive: boolean }): Promise<void> {\n return this.fs?.rm(path, options);\n }\n async copyFile(source: PathLike, destination: PathLike): Promise<void> {\n return this.fs?.copyFile(source, destination);\n }\n async readfile(path: PathLike, options?: { encoding: BufferEncoding; flag?: string }): Promise<Uint8Array> {\n const ret = (await this.fs?.readFile(path, options)) as Buffer;\n return toArrayBuffer(ret);\n }\n stat(path: PathLike): Promise<Stats> {\n return this.fs?.stat(path) as Promise<Stats>;\n }\n async unlink(path: PathLike): Promise<void> {\n return this.fs?.unlink(path);\n }\n async writefile(path: PathLike, data: Uint8Array | string): Promise<void> {\n if (runtimeFn().isDeno) {\n return this.fs?.writeFile(path, data);\n }\n return this.fs?.writeFile(path, Buffer.from(data));\n }\n}\n\n// import { type NodeMap, join } from \"../../sys-container.js\";\n// import type { ObjectEncodingOptions, PathLike } from \"fs\";\n// import * as fs from \"fs/promises\";\n// import * as path from \"path\";\n// import * as os from \"os\";\n// import * as url from \"url\";\n// import { toArrayBuffer } from \"./utils.js\";\n\n// export async function createNodeSysContainer(): Promise<NodeMap> {\n// // const nodePath = \"node:path\";\n// // const nodeOS = \"node:os\";\n// // const nodeURL = \"node:url\";\n// // const nodeFS = \"node:fs\";\n// // const fs = (await import(\"node:fs\")).promises;\n// // const assert = \"assert\";\n// // const path = await import(\"node:path\");\n// return {\n// state: \"node\",\n// ...path,\n// // ...(await import(\"node:os\")),\n// // ...(await import(\"node:url\")),\n// ...os,\n// ...url,\n// ...fs,\n// join,\n// stat: fs.stat as NodeMap[\"stat\"],\n// readdir: fs.readdir as NodeMap[\"readdir\"],\n// readfile: async (path: PathLike, options?: ObjectEncodingOptions): Promise<Uint8Array> => {\n// const rs = await fs.readFile(path, options);\n// return toArrayBuffer(rs);\n// },\n// writefile: fs.writeFile as NodeMap[\"writefile\"],\n// };\n// }\n","export function toArrayBuffer(buffer: Buffer | string): Uint8Array {\n if (typeof buffer === \"string\") {\n buffer = Buffer.from(buffer);\n }\n const ab = new ArrayBuffer(buffer.length);\n const view = new Uint8Array(ab);\n for (let i = 0; i < buffer.length; ++i) {\n view[i] = buffer[i];\n }\n return view;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,SAAS,cAAc,QAAqC;AACjE,MAAI,OAAO,WAAW,UAAU;AAC9B,aAAS,OAAO,KAAK,MAAM;AAAA,EAC7B;AACA,QAAM,KAAK,IAAI,YAAY,OAAO,MAAM;AACxC,QAAM,OAAO,IAAI,WAAW,EAAE;AAC9B,WAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,EAAE,GAAG;AACtC,SAAK,CAAC,IAAI,OAAO,CAAC;AAAA,EACpB;AACA,SAAO;AACT;;;ADNA,oBAA0B;AAEnB,IAAM,iBAAN,MAA8C;AAAA,EAYnD,MAAM,QAAgC;AACpC,SAAK,KAAK,MAAM,OAAO,aAAkB;AACzC,WAAO;AAAA,EACT;AAAA,EACA,MAAM,MAAM,MAAgB,SAA+D;AACzF,WAAO,KAAK,IAAI,MAAM,MAAM,OAAO;AAAA,EACrC;AAAA,EACA,MAAM,QAAQ,MAAgB,SAAoD;AAChF,WAAO,KAAK,IAAI,QAAQ,MAAM,OAAO;AAAA,EACvC;AAAA,EACA,MAAM,GAAG,MAAgB,SAAwE;AAC/F,WAAO,KAAK,IAAI,GAAG,MAAM,OAAO;AAAA,EAClC;AAAA,EACA,MAAM,SAAS,QAAkB,aAAsC;AACrE,WAAO,KAAK,IAAI,SAAS,QAAQ,WAAW;AAAA,EAC9C;AAAA,EACA,MAAM,SAAS,MAAgB,SAA4E;AACzG,UAAM,MAAO,MAAM,KAAK,IAAI,SAAS,MAAM,OAAO;AAClD,WAAO,cAAc,GAAG;AAAA,EAC1B;AAAA,EACA,KAAK,MAAgC;AACnC,WAAO,KAAK,IAAI,KAAK,IAAI;AAAA,EAC3B;AAAA,EACA,MAAM,OAAO,MAA+B;AAC1C,WAAO,KAAK,IAAI,OAAO,IAAI;AAAA,EAC7B;AAAA,EACA,MAAM,UAAU,MAAgB,MAA0C;AACxE,YAAI,yBAAU,EAAE,QAAQ;AACtB,aAAO,KAAK,IAAI,UAAU,MAAM,IAAI;AAAA,IACtC;AACA,WAAO,KAAK,IAAI,UAAU,MAAM,OAAO,KAAK,IAAI,CAAC;AAAA,EACnD;AACF;","names":[]}
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import { PathLike, ObjectEncodingOptions, MakeDirectoryOptions, Stats } from 'node:fs';
|
2
2
|
import { mkdir, readdir, rm, copyFile, readFile, stat, unlink, writeFile } from 'node:fs/promises';
|
3
|
-
import {
|
4
|
-
import 'fs';
|
3
|
+
import { SysFileSystem } from '@fireproof/core';
|
5
4
|
|
6
5
|
declare class NodeFileSystem implements SysFileSystem {
|
7
6
|
fs?: {
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import { PathLike, ObjectEncodingOptions, MakeDirectoryOptions, Stats } from 'node:fs';
|
2
2
|
import { mkdir, readdir, rm, copyFile, readFile, stat, unlink, writeFile } from 'node:fs/promises';
|
3
|
-
import {
|
4
|
-
import 'fs';
|
3
|
+
import { SysFileSystem } from '@fireproof/core';
|
5
4
|
|
6
5
|
declare class NodeFileSystem implements SysFileSystem {
|
7
6
|
fs?: {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtime/gateways/file/node/node-filesystem.ts"],"sourcesContent":["import type { PathLike, MakeDirectoryOptions, Stats, ObjectEncodingOptions } from \"node:fs\";\nimport type { mkdir, readdir, rm, copyFile, readFile, stat, unlink, writeFile } from \"node:fs/promises\";\nimport { toArrayBuffer } from \"./to-array-buffer.js\";\nimport type { SysFileSystem } from \"
|
1
|
+
{"version":3,"sources":["../../../src/runtime/gateways/file/node/node-filesystem.ts"],"sourcesContent":["import type { PathLike, MakeDirectoryOptions, Stats, ObjectEncodingOptions } from \"node:fs\";\nimport type { mkdir, readdir, rm, copyFile, readFile, stat, unlink, writeFile } from \"node:fs/promises\";\nimport { toArrayBuffer } from \"./to-array-buffer.js\";\nimport type { SysFileSystem } from \"@fireproof/core\";\nimport { runtimeFn } from \"@adviser/cement\";\n\nexport class NodeFileSystem implements SysFileSystem {\n fs?: {\n mkdir: typeof mkdir;\n readdir: typeof readdir;\n rm: typeof rm;\n copyFile: typeof copyFile;\n readFile: typeof readFile;\n stat: typeof stat;\n unlink: typeof unlink;\n writeFile: typeof writeFile;\n };\n\n async start(): Promise<SysFileSystem> {\n this.fs = await import(\"node:fs/promises\");\n return this;\n }\n async mkdir(path: PathLike, options?: { recursive: boolean }): Promise<string | undefined> {\n return this.fs?.mkdir(path, options);\n }\n async readdir(path: PathLike, options?: ObjectEncodingOptions): Promise<string[]> {\n return this.fs?.readdir(path, options) as Promise<string[]>;\n }\n async rm(path: PathLike, options?: MakeDirectoryOptions & { recursive: boolean }): Promise<void> {\n return this.fs?.rm(path, options);\n }\n async copyFile(source: PathLike, destination: PathLike): Promise<void> {\n return this.fs?.copyFile(source, destination);\n }\n async readfile(path: PathLike, options?: { encoding: BufferEncoding; flag?: string }): Promise<Uint8Array> {\n const ret = (await this.fs?.readFile(path, options)) as Buffer;\n return toArrayBuffer(ret);\n }\n stat(path: PathLike): Promise<Stats> {\n return this.fs?.stat(path) as Promise<Stats>;\n }\n async unlink(path: PathLike): Promise<void> {\n return this.fs?.unlink(path);\n }\n async writefile(path: PathLike, data: Uint8Array | string): Promise<void> {\n if (runtimeFn().isDeno) {\n return this.fs?.writeFile(path, data);\n }\n return this.fs?.writeFile(path, Buffer.from(data));\n }\n}\n\n// import { type NodeMap, join } from \"../../sys-container.js\";\n// import type { ObjectEncodingOptions, PathLike } from \"fs\";\n// import * as fs from \"fs/promises\";\n// import * as path from \"path\";\n// import * as os from \"os\";\n// import * as url from \"url\";\n// import { toArrayBuffer } from \"./utils.js\";\n\n// export async function createNodeSysContainer(): Promise<NodeMap> {\n// // const nodePath = \"node:path\";\n// // const nodeOS = \"node:os\";\n// // const nodeURL = \"node:url\";\n// // const nodeFS = \"node:fs\";\n// // const fs = (await import(\"node:fs\")).promises;\n// // const assert = \"assert\";\n// // const path = await import(\"node:path\");\n// return {\n// state: \"node\",\n// ...path,\n// // ...(await import(\"node:os\")),\n// // ...(await import(\"node:url\")),\n// ...os,\n// ...url,\n// ...fs,\n// join,\n// stat: fs.stat as NodeMap[\"stat\"],\n// readdir: fs.readdir as NodeMap[\"readdir\"],\n// readfile: async (path: PathLike, options?: ObjectEncodingOptions): Promise<Uint8Array> => {\n// const rs = await fs.readFile(path, options);\n// return toArrayBuffer(rs);\n// },\n// writefile: fs.writeFile as NodeMap[\"writefile\"],\n// };\n// }\n"],"mappings":";;;;;AAIA,SAAS,iBAAiB;AAEnB,IAAM,iBAAN,MAA8C;AAAA,EAYnD,MAAM,QAAgC;AACpC,SAAK,KAAK,MAAM,OAAO,kBAAkB;AACzC,WAAO;AAAA,EACT;AAAA,EACA,MAAM,MAAM,MAAgB,SAA+D;AACzF,WAAO,KAAK,IAAI,MAAM,MAAM,OAAO;AAAA,EACrC;AAAA,EACA,MAAM,QAAQ,MAAgB,SAAoD;AAChF,WAAO,KAAK,IAAI,QAAQ,MAAM,OAAO;AAAA,EACvC;AAAA,EACA,MAAM,GAAG,MAAgB,SAAwE;AAC/F,WAAO,KAAK,IAAI,GAAG,MAAM,OAAO;AAAA,EAClC;AAAA,EACA,MAAM,SAAS,QAAkB,aAAsC;AACrE,WAAO,KAAK,IAAI,SAAS,QAAQ,WAAW;AAAA,EAC9C;AAAA,EACA,MAAM,SAAS,MAAgB,SAA4E;AACzG,UAAM,MAAO,MAAM,KAAK,IAAI,SAAS,MAAM,OAAO;AAClD,WAAO,cAAc,GAAG;AAAA,EAC1B;AAAA,EACA,KAAK,MAAgC;AACnC,WAAO,KAAK,IAAI,KAAK,IAAI;AAAA,EAC3B;AAAA,EACA,MAAM,OAAO,MAA+B;AAC1C,WAAO,KAAK,IAAI,OAAO,IAAI;AAAA,EAC7B;AAAA,EACA,MAAM,UAAU,MAAgB,MAA0C;AACxE,QAAI,UAAU,EAAE,QAAQ;AACtB,aAAO,KAAK,IAAI,UAAU,MAAM,IAAI;AAAA,IACtC;AACA,WAAO,KAAK,IAAI,UAAU,MAAM,OAAO,KAAK,IAAI,CAAC;AAAA,EACnD;AACF;","names":[]}
|
package/package.json
CHANGED
@@ -1,35 +1,35 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fireproof/core",
|
3
|
-
"version": "0.19.
|
3
|
+
"version": "0.19.120",
|
4
4
|
"description": "Live database for the web.",
|
5
5
|
"type": "module",
|
6
6
|
"module": "./index.js",
|
7
7
|
"main": "./index.cjs",
|
8
|
-
"browser": "./index.global.js",
|
9
8
|
"types": "./index.d.ts",
|
10
9
|
"exports": {
|
11
10
|
".": {
|
12
11
|
"import": "./index.js",
|
13
12
|
"require": "./index.cjs",
|
14
|
-
"script": "./index.global.js",
|
15
13
|
"types": "./index.d.ts"
|
16
14
|
},
|
17
15
|
"./node": {
|
18
|
-
"import": "./
|
19
|
-
"require": "./
|
20
|
-
"
|
21
|
-
|
16
|
+
"import": "./node/node-filesystem.js",
|
17
|
+
"require": "./node/node-filesystem.cjs",
|
18
|
+
"types": "./node/node-filesystem.d.ts"
|
19
|
+
},
|
20
|
+
"./mem": {
|
21
|
+
"import": "./node/mem-filesystem.js",
|
22
|
+
"require": "./node/mem-filesystem.cjs",
|
23
|
+
"types": "./node/mem-filesystem.d.ts"
|
22
24
|
},
|
23
25
|
"./web": {
|
24
|
-
"import": "./web/
|
25
|
-
"require": "./web/
|
26
|
-
"
|
27
|
-
"types": "./web/index.d.ts"
|
26
|
+
"import": "./web/gateway-impl.js",
|
27
|
+
"require": "./web/gateway-impl.cjs",
|
28
|
+
"types": "./web/gateway-impl.d.ts"
|
28
29
|
},
|
29
30
|
"./react": {
|
30
31
|
"import": "./react/index.js",
|
31
32
|
"require": "./react/index.cjs",
|
32
|
-
"script": "./react/index.global.js",
|
33
33
|
"types": "./react/index.d.ts"
|
34
34
|
}
|
35
35
|
},
|
@@ -64,15 +64,15 @@
|
|
64
64
|
"react": "^18.3.1"
|
65
65
|
},
|
66
66
|
"dependencies": {
|
67
|
-
"@adviser/cement": "^0.
|
68
|
-
"@fireproof/vendor": "^1.0.
|
67
|
+
"@adviser/cement": "^0.3.3",
|
68
|
+
"@fireproof/vendor": "^1.0.3",
|
69
69
|
"@ipld/unixfs": "^3.0.0",
|
70
70
|
"multiformats": "^13.3.1",
|
71
71
|
"charwise": "^3.0.1",
|
72
72
|
"prolly-trees": "^1.0.4",
|
73
|
-
"idb": "^8.0.
|
74
|
-
"memfs": "^4.15.
|
75
|
-
"p-limit": "^6.
|
73
|
+
"idb": "^8.0.1",
|
74
|
+
"memfs": "^4.15.1",
|
75
|
+
"p-limit": "^6.2.0",
|
76
76
|
"p-map": "^7.0.3",
|
77
77
|
"p-retry": "^6.2.1"
|
78
78
|
},
|
package/react/index.cjs
CHANGED
@@ -18,8 +18,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
19
|
|
20
20
|
// src/react/index.ts
|
21
|
-
var
|
22
|
-
__export(
|
21
|
+
var index_exports = {};
|
22
|
+
__export(index_exports, {
|
23
23
|
FireproofCtx: () => FireproofCtx,
|
24
24
|
useAllDocs: () => useAllDocs,
|
25
25
|
useChanges: () => useChanges,
|
@@ -27,7 +27,7 @@ __export(react_exports, {
|
|
27
27
|
useFireproof: () => useFireproof,
|
28
28
|
useLiveQuery: () => useLiveQuery
|
29
29
|
});
|
30
|
-
module.exports = __toCommonJS(
|
30
|
+
module.exports = __toCommonJS(index_exports);
|
31
31
|
|
32
32
|
// src/react/useFireproof.ts
|
33
33
|
var import_core = require("@fireproof/core");
|
@@ -2,12 +2,12 @@ import {
|
|
2
2
|
getFileName,
|
3
3
|
getFileSystem,
|
4
4
|
getPath
|
5
|
-
} from "./chunk-
|
6
|
-
import "./chunk-
|
5
|
+
} from "./chunk-F4FC6B2T.js";
|
6
|
+
import "./chunk-RXC4JGJT.js";
|
7
7
|
import "./chunk-PZ5AY32C.js";
|
8
8
|
export {
|
9
9
|
getFileName,
|
10
10
|
getFileSystem,
|
11
11
|
getPath
|
12
12
|
};
|
13
|
-
//# sourceMappingURL=utils-
|
13
|
+
//# sourceMappingURL=utils-ZVVGAXFE.js.map
|
package/web/gateway-impl.cjs
CHANGED
@@ -26,156 +26,13 @@ __export(gateway_impl_exports, {
|
|
26
26
|
});
|
27
27
|
module.exports = __toCommonJS(gateway_impl_exports);
|
28
28
|
var import_idb = require("idb");
|
29
|
-
var
|
29
|
+
var import_cement = require("@adviser/cement");
|
30
30
|
|
31
31
|
// src/runtime/gateways/indexdb/version.ts
|
32
32
|
var INDEXDB_VERSION = "v0.19-indexdb";
|
33
33
|
|
34
|
-
// src/utils.ts
|
35
|
-
var import_cement = require("@adviser/cement");
|
36
|
-
var import_base58 = require("multiformats/bases/base58");
|
37
|
-
var _globalLogger = new import_cement.ResolveOnce();
|
38
|
-
function globalLogger() {
|
39
|
-
return _globalLogger.once(() => new import_cement.LoggerImpl());
|
40
|
-
}
|
41
|
-
var registerFP_DEBUG = new import_cement.ResolveOnce();
|
42
|
-
var pathOpsImpl = class {
|
43
|
-
join(...paths) {
|
44
|
-
return paths.map((i) => i.replace(/\/+$/, "")).join("/");
|
45
|
-
}
|
46
|
-
dirname(path) {
|
47
|
-
return path.split("/").slice(0, -1).join("/");
|
48
|
-
}
|
49
|
-
// homedir() {
|
50
|
-
// throw new Error("SysContainer:homedir is not available in seeded state");
|
51
|
-
// }
|
52
|
-
};
|
53
|
-
var pathOps = new pathOpsImpl();
|
54
|
-
function ensureLogger(sthis, componentName, ctx) {
|
55
|
-
let logger;
|
56
|
-
if ((0, import_cement.IsLogger)(sthis)) {
|
57
|
-
logger = sthis;
|
58
|
-
} else if (sthis && (0, import_cement.IsLogger)(sthis.logger)) {
|
59
|
-
logger = sthis.logger;
|
60
|
-
} else {
|
61
|
-
logger = globalLogger();
|
62
|
-
}
|
63
|
-
const cLogger = logger.With().Module(componentName);
|
64
|
-
const debug = [];
|
65
|
-
let exposeStack = false;
|
66
|
-
if (ctx) {
|
67
|
-
if ("debug" in ctx) {
|
68
|
-
if (typeof ctx.debug === "string" && ctx.debug.length > 0) {
|
69
|
-
debug.push(ctx.debug);
|
70
|
-
} else {
|
71
|
-
debug.push(componentName);
|
72
|
-
}
|
73
|
-
delete ctx.debug;
|
74
|
-
}
|
75
|
-
if ("exposeStack" in ctx) {
|
76
|
-
exposeStack = true;
|
77
|
-
delete ctx.exposeStack;
|
78
|
-
}
|
79
|
-
if ("this" in ctx) {
|
80
|
-
cLogger.Str("this", sthis.nextId(4).str);
|
81
|
-
delete ctx.this;
|
82
|
-
}
|
83
|
-
for (const [key, value] of Object.entries(ctx)) {
|
84
|
-
switch (typeof value) {
|
85
|
-
case "string":
|
86
|
-
cLogger.Str(key, value);
|
87
|
-
break;
|
88
|
-
case "number":
|
89
|
-
cLogger.Uint64(key, value);
|
90
|
-
break;
|
91
|
-
default:
|
92
|
-
if (value instanceof Date) {
|
93
|
-
cLogger.Str(key, value.toISOString());
|
94
|
-
} else if ((0, import_cement.isURL)(value)) {
|
95
|
-
cLogger.Str(key, value.toString());
|
96
|
-
} else if (typeof value === "function") {
|
97
|
-
cLogger.Ref(key, value);
|
98
|
-
} else {
|
99
|
-
cLogger.Any(key, value);
|
100
|
-
}
|
101
|
-
break;
|
102
|
-
}
|
103
|
-
}
|
104
|
-
}
|
105
|
-
registerFP_DEBUG.once(async () => {
|
106
|
-
sthis.env.onSet(
|
107
|
-
(key, value) => {
|
108
|
-
switch (key) {
|
109
|
-
case "FP_FORMAT": {
|
110
|
-
switch (value) {
|
111
|
-
case "jsonice":
|
112
|
-
logger.SetFormatter(new import_cement.JSONFormatter(logger.TxtEnDe(), 2));
|
113
|
-
break;
|
114
|
-
case "yaml":
|
115
|
-
logger.SetFormatter(new import_cement.YAMLFormatter(logger.TxtEnDe(), 2));
|
116
|
-
break;
|
117
|
-
case "json":
|
118
|
-
default:
|
119
|
-
logger.SetFormatter(new import_cement.JSONFormatter(logger.TxtEnDe()));
|
120
|
-
break;
|
121
|
-
}
|
122
|
-
break;
|
123
|
-
}
|
124
|
-
case "FP_DEBUG":
|
125
|
-
logger.SetDebug(value || []);
|
126
|
-
break;
|
127
|
-
case "FP_STACK":
|
128
|
-
logger.SetExposeStack(!!value);
|
129
|
-
break;
|
130
|
-
}
|
131
|
-
},
|
132
|
-
"FP_FORMAT",
|
133
|
-
"FP_DEBUG",
|
134
|
-
"FP_STACK"
|
135
|
-
);
|
136
|
-
}).finally(() => {
|
137
|
-
});
|
138
|
-
if (debug.length > 0) {
|
139
|
-
logger.SetDebug(debug);
|
140
|
-
}
|
141
|
-
if (exposeStack) {
|
142
|
-
logger.SetExposeStack(true);
|
143
|
-
}
|
144
|
-
const out = cLogger.Logger();
|
145
|
-
return out;
|
146
|
-
}
|
147
|
-
function getStore(url, sthis, joiner) {
|
148
|
-
const store = url.getParam("store");
|
149
|
-
switch (store) {
|
150
|
-
case "data":
|
151
|
-
case "wal":
|
152
|
-
case "meta":
|
153
|
-
break;
|
154
|
-
default:
|
155
|
-
throw sthis.logger.Error().Url(url).Msg(`store not found`).AsError();
|
156
|
-
}
|
157
|
-
let name = store;
|
158
|
-
if (url.hasParam("index")) {
|
159
|
-
name = joiner(url.getParam("index") || "idx", name);
|
160
|
-
}
|
161
|
-
return { store, name };
|
162
|
-
}
|
163
|
-
function getKey(url, logger) {
|
164
|
-
const result = url.getParam("key");
|
165
|
-
if (!result) throw logger.Error().Str("url", url.toString()).Msg(`key not found`).AsError();
|
166
|
-
return result;
|
167
|
-
}
|
168
|
-
async function exceptionWrapper(fn) {
|
169
|
-
return fn().catch((e) => import_cement.Result.Err(e));
|
170
|
-
}
|
171
|
-
var NotFoundError = class extends Error {
|
172
|
-
constructor() {
|
173
|
-
super(...arguments);
|
174
|
-
this.code = "ENOENT";
|
175
|
-
}
|
176
|
-
};
|
177
|
-
|
178
34
|
// src/runtime/gateways/indexdb/web/gateway-impl.ts
|
35
|
+
var import_core = require("@fireproof/core");
|
179
36
|
function ensureVersion(url) {
|
180
37
|
return url.build().defParam("version", INDEXDB_VERSION).URI();
|
181
38
|
}
|
@@ -185,7 +42,7 @@ function sanitzeKey(key) {
|
|
185
42
|
}
|
186
43
|
return key;
|
187
44
|
}
|
188
|
-
var onceConn = new
|
45
|
+
var onceConn = new import_cement.KeyedResolvOnce();
|
189
46
|
async function connectIdb(url, sthis) {
|
190
47
|
const dbName = getIndexDBName(url, sthis);
|
191
48
|
const once = await onceConn.get(dbName.fullDb).once(async () => {
|
@@ -221,7 +78,7 @@ function getIndexDBName(iurl, sthis) {
|
|
221
78
|
const dbName = url.getParam("name");
|
222
79
|
if (!dbName) throw sthis.logger.Error().Str("url", url.toString()).Msg(`name not found`).AsError();
|
223
80
|
const result = joinDBName(fullDb, dbName);
|
224
|
-
const objStore = getStore(url, sthis, joinDBName).name;
|
81
|
+
const objStore = (0, import_core.getStore)(url, sthis, joinDBName).name;
|
225
82
|
const connectionKey = [result, objStore].join(":");
|
226
83
|
return {
|
227
84
|
fullDb: result,
|
@@ -232,12 +89,12 @@ function getIndexDBName(iurl, sthis) {
|
|
232
89
|
}
|
233
90
|
var IndexDBGatewayImpl = class {
|
234
91
|
constructor(sthis) {
|
235
|
-
this.logger = ensureLogger(sthis, "IndexDBGateway");
|
92
|
+
this.logger = (0, import_core.ensureLogger)(sthis, "IndexDBGateway");
|
236
93
|
this.sthis = sthis;
|
237
94
|
}
|
238
95
|
// _db: IDBPDatabase<unknown> = {} as IDBPDatabase<unknown>;
|
239
96
|
async start(baseURL) {
|
240
|
-
return (0,
|
97
|
+
return (0, import_cement.exception2Result)(async () => {
|
241
98
|
this.logger.Debug().Url(baseURL).Msg("starting");
|
242
99
|
await this.sthis.start();
|
243
100
|
const ic = await connectIdb(baseURL, this.sthis);
|
@@ -246,11 +103,11 @@ var IndexDBGatewayImpl = class {
|
|
246
103
|
});
|
247
104
|
}
|
248
105
|
async close() {
|
249
|
-
return
|
106
|
+
return import_cement.Result.Ok(void 0);
|
250
107
|
}
|
251
108
|
async destroy(baseUrl) {
|
252
|
-
return (0,
|
253
|
-
const type = getStore(baseUrl, this.sthis, joinDBName).name;
|
109
|
+
return (0, import_cement.exception2Result)(async () => {
|
110
|
+
const type = (0, import_core.getStore)(baseUrl, this.sthis, joinDBName).name;
|
254
111
|
const idb = await connectIdb(baseUrl, this.sthis);
|
255
112
|
const trans = idb.db.transaction(type, "readwrite");
|
256
113
|
const object_store = trans.objectStore(type);
|
@@ -265,27 +122,27 @@ var IndexDBGatewayImpl = class {
|
|
265
122
|
});
|
266
123
|
}
|
267
124
|
buildUrl(baseUrl, key) {
|
268
|
-
return Promise.resolve(
|
125
|
+
return Promise.resolve(import_cement.Result.Ok(baseUrl.build().setParam("key", key).URI()));
|
269
126
|
}
|
270
127
|
async get(url) {
|
271
|
-
return exceptionWrapper(async () => {
|
272
|
-
const key = getKey(url, this.logger);
|
273
|
-
const store = getStore(url, this.sthis, joinDBName).name;
|
128
|
+
return (0, import_core.exceptionWrapper)(async () => {
|
129
|
+
const key = (0, import_core.getKey)(url, this.logger);
|
130
|
+
const store = (0, import_core.getStore)(url, this.sthis, joinDBName).name;
|
274
131
|
this.logger.Debug().Url(url).Str("key", key).Str("store", store).Msg("getting");
|
275
132
|
const { db } = await connectIdb(url, this.sthis);
|
276
133
|
const tx = db.transaction([store], "readonly");
|
277
134
|
const bytes = await tx.objectStore(store).get(sanitzeKey(key));
|
278
135
|
await tx.done;
|
279
136
|
if (!bytes) {
|
280
|
-
return
|
137
|
+
return import_cement.Result.Err(new import_core.NotFoundError(`missing ${key}`));
|
281
138
|
}
|
282
|
-
return
|
139
|
+
return import_cement.Result.Ok(bytes);
|
283
140
|
});
|
284
141
|
}
|
285
142
|
async put(url, value) {
|
286
|
-
return (0,
|
287
|
-
const key = getKey(url, this.logger);
|
288
|
-
const store = getStore(url, this.sthis, joinDBName).name;
|
143
|
+
return (0, import_cement.exception2Result)(async () => {
|
144
|
+
const key = (0, import_core.getKey)(url, this.logger);
|
145
|
+
const store = (0, import_core.getStore)(url, this.sthis, joinDBName).name;
|
289
146
|
this.logger.Debug().Url(url).Str("key", key).Str("store", store).Msg("putting");
|
290
147
|
const { db } = await connectIdb(url, this.sthis);
|
291
148
|
const tx = db.transaction([store], "readwrite");
|
@@ -294,26 +151,26 @@ var IndexDBGatewayImpl = class {
|
|
294
151
|
});
|
295
152
|
}
|
296
153
|
async delete(url) {
|
297
|
-
return (0,
|
298
|
-
const key = getKey(url, this.logger);
|
299
|
-
const store = getStore(url, this.sthis, joinDBName).name;
|
154
|
+
return (0, import_cement.exception2Result)(async () => {
|
155
|
+
const key = (0, import_core.getKey)(url, this.logger);
|
156
|
+
const store = (0, import_core.getStore)(url, this.sthis, joinDBName).name;
|
300
157
|
this.logger.Debug().Url(url).Str("key", key).Str("store", store).Msg("deleting");
|
301
158
|
const { db } = await connectIdb(url, this.sthis);
|
302
159
|
const tx = db.transaction([store], "readwrite");
|
303
160
|
await tx.objectStore(store).delete(sanitzeKey(key));
|
304
161
|
await tx.done;
|
305
|
-
return
|
162
|
+
return import_cement.Result.Ok(void 0);
|
306
163
|
});
|
307
164
|
}
|
308
165
|
};
|
309
166
|
var IndexDBTestStore = class {
|
310
167
|
constructor(sthis) {
|
311
168
|
this.sthis = sthis;
|
312
|
-
this.logger = ensureLogger(sthis, "IndexDBTestStore", {});
|
169
|
+
this.logger = (0, import_core.ensureLogger)(sthis, "IndexDBTestStore", {});
|
313
170
|
}
|
314
171
|
async get(url, key) {
|
315
172
|
const ic = await connectIdb(url, this.sthis);
|
316
|
-
const store = getStore(ic.url, this.sthis, joinDBName).name;
|
173
|
+
const store = (0, import_core.getStore)(ic.url, this.sthis, joinDBName).name;
|
317
174
|
this.logger.Debug().Str("key", key).Str("store", store).Msg("getting");
|
318
175
|
let bytes = await ic.db.get(store, sanitzeKey(key));
|
319
176
|
this.logger.Debug().Str("key", key).Str("store", store).Int("len", bytes.length).Msg("got");
|