@fireproof/core 0.7.0-alpha.0 → 0.7.0-alpha.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/fireproof.js CHANGED
@@ -9,21 +9,10 @@ class Fireproof {
9
9
  * Creates a new Fireproof instance with default storage settings
10
10
  * Most apps should use this and not worry about the details.
11
11
  * @static
12
- * @returns {Database|Promise<Database>} - a new Fireproof instance or a promise for remote loaders
12
+ * @returns {Database} - a new Fireproof instance
13
13
  */
14
14
  static storage = (name = null, opts = {}) => {
15
- if (!name) {
16
- return new Database(null, opts);
17
- }
18
- else {
19
- // const primaryLoader = Loader.appropriate(name, opts.primary, { key: null })
20
- // const secondaryLoader = opts.secondary ? Loader.appropriate(name, opts.secondary, { key: null }) : null
21
- const db = new Database(name, opts);
22
- return db;
23
- // const loaders = [pr]
24
- // todo we need branch names here
25
- // console.log('storage', name, opts, primaryLoader, secondaryLoader)
26
- }
15
+ return new Database(name, opts);
27
16
  };
28
17
  // static fromConfig (name, primary, secondary, opts = {}) {
29
18
  // console.log('fromConfig', name, primary, secondary, opts)
@@ -569,9 +569,9 @@ declare class Fireproof {
569
569
  * Creates a new Fireproof instance with default storage settings
570
570
  * Most apps should use this and not worry about the details.
571
571
  * @static
572
- * @returns {Database|Promise<Database>} - a new Fireproof instance or a promise for remote loaders
572
+ * @returns {Database} - a new Fireproof instance
573
573
  */
574
- static storage: (name?: any, opts?: {}) => Database | Promise<Database>;
574
+ static storage: (name?: any, opts?: {}) => Database;
575
575
  static fromJSON(primary: any, secondary: any, database: any): any;
576
576
  static snapshot(database: any, clock: any): any;
577
577
  static zoom(database: any, clock: any): Promise<any>;
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var node_fs = require('node:fs');
4
- var promises = require('node:fs/promises');
3
+ var promises = require('fs/promises');
5
4
  var http = require('node:http');
6
5
  var https = require('node:https');
7
6
  var zlib = require('node:zlib');
@@ -10,6 +9,7 @@ var node_buffer = require('node:buffer');
10
9
  var node_util = require('node:util');
11
10
  var node_url = require('node:url');
12
11
  var node_net = require('node:net');
12
+ require('node:fs');
13
13
  require('node:path');
14
14
 
15
15
  var encode_1$2 = encode$9;
@@ -39186,6 +39186,10 @@ function homedir(){
39186
39186
  return '$HOME'
39187
39187
  }
39188
39188
 
39189
+ var fs = {};
39190
+
39191
+ const readFileSync = fs.readFileSync;
39192
+
39189
39193
  const defaultConfig$1 = {
39190
39194
  dataDir: join(homedir(), '.fireproof')
39191
39195
  };
@@ -39210,7 +39214,7 @@ class Filesystem extends Base {
39210
39214
 
39211
39215
  async readCar (carCid) {
39212
39216
  const carFilename = join(this.config.dataDir, this.name, `${carCid.toString()}.car`);
39213
- const got = node_fs.readFileSync(carFilename);
39217
+ const got = readFileSync(carFilename);
39214
39218
  // console.log('readCar', carFilename, got.constructor.name)
39215
39219
  return got
39216
39220
  }
@@ -39238,7 +39242,7 @@ class Filesystem extends Base {
39238
39242
 
39239
39243
  function loadSync (filename) {
39240
39244
  try {
39241
- return node_fs.readFileSync(filename, 'utf8').toString()
39245
+ return readFileSync(filename, 'utf8').toString()
39242
39246
  } catch (error) {
39243
39247
  // console.log('error', error)
39244
39248
  return null
@@ -50348,22 +50352,10 @@ class Fireproof {
50348
50352
  * Creates a new Fireproof instance with default storage settings
50349
50353
  * Most apps should use this and not worry about the details.
50350
50354
  * @static
50351
- * @returns {Database|Promise<Database>} - a new Fireproof instance or a promise for remote loaders
50355
+ * @returns {Database} - a new Fireproof instance
50352
50356
  */
50353
50357
  static storage = (name = null, opts = {}) => {
50354
- if (!name) {
50355
- return new Database(null, opts)
50356
- } else {
50357
- // const primaryLoader = Loader.appropriate(name, opts.primary, { key: null })
50358
- // const secondaryLoader = opts.secondary ? Loader.appropriate(name, opts.secondary, { key: null }) : null
50359
- const db = new Database(name, opts);
50360
- return db
50361
- // const loaders = [pr]
50362
-
50363
- // todo we need branch names here
50364
-
50365
- // console.log('storage', name, opts, primaryLoader, secondaryLoader)
50366
- }
50358
+ return new Database(name, opts)
50367
50359
  }
50368
50360
 
50369
50361
  // static fromConfig (name, primary, secondary, opts = {}) {