@live-change/db-web 0.7.2 → 0.8.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/LICENSE.md ADDED
@@ -0,0 +1,11 @@
1
+ Copyright 2019-2024 Michał Łaszczewski
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
+
5
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
+
7
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
+
9
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
+
11
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/index.js CHANGED
@@ -1 +1,3 @@
1
- module.exports = require('./lib/Server.js')
1
+ import Server from './lib/Server.js'
2
+
3
+ export default Server
package/lib/Server.js CHANGED
@@ -1,11 +1,11 @@
1
- const ScriptContext = require('@live-change/db/lib/WebScriptContext.js')
2
- const dbDao = require('./dbDao.js')
3
- const storeDao = require('./storeDao.js')
4
- const createBackend = require("./backend.js")
1
+ import ScriptContext from '@live-change/db/lib/WebScriptContext.js'
2
+ import * as dbDao from './dbDao.js'
3
+ import * as storeDao from './storeDao.js'
4
+ import createBackend from "./backend.js"
5
5
 
6
- const ReactiveDao = require("@live-change/dao")
6
+ import ReactiveDao from "@live-change/dao"
7
7
 
8
- const Database = require('@live-change/db').Database
8
+ import { Database } from '@live-change/db'
9
9
 
10
10
  class DatabaseStore {
11
11
  constructor(path, backends, options) {
@@ -187,4 +187,4 @@ class Server {
187
187
  }
188
188
  }
189
189
 
190
- module.exports = Server
190
+ export default Server
package/lib/backend.js CHANGED
@@ -1,8 +1,12 @@
1
+ import localStorageStore from '@live-change/db-store-localstorage'
2
+ import indexedDbStore from '@live-change/db-store-indexeddb'
3
+ import rbTreeStore from '@live-change/db-store-rbtree'
4
+
1
5
  function createBackend(config) {
2
6
  console.log("CREATE BACKEND", config)
3
7
  if(config.name == 'mem' || config.name == 'memory') {
4
8
  return {
5
- Store: require('@live-change/db-store-rbtree'),
9
+ Store: rbTreeStore,
6
10
  createDb(path, options) {
7
11
  const db = {}
8
12
  db.path = path
@@ -20,12 +24,11 @@ function createBackend(config) {
20
24
  closeStore(store) {
21
25
  },
22
26
  async deleteStore(store) {
23
- await store.clear()
24
27
  }
25
28
  }
26
29
  } if(config.name == 'indexeddb') {
27
30
  return {
28
- Store: require('@live-change/db-store-indexeddb'),
31
+ Store: indexedDbStore,
29
32
  createDb(path, options) {
30
33
  const db = {}
31
34
  db.path = path
@@ -49,7 +52,7 @@ function createBackend(config) {
49
52
  }
50
53
  } if(config.name == 'local') {
51
54
  return {
52
- Store: require('@live-change/db-store-localstorage'),
55
+ Store: localStorageStore,
53
56
  createDb(path, options) {
54
57
  const db = {}
55
58
  db.path = path
@@ -73,7 +76,7 @@ function createBackend(config) {
73
76
  }
74
77
  } if(config.name == 'session') {
75
78
  return {
76
- Store: require('@live-change/db-store-localstorage'),
79
+ Store: localStorageStore,
77
80
  createDb(path, options) {
78
81
  const db = {}
79
82
  db.path = path
@@ -100,4 +103,4 @@ function createBackend(config) {
100
103
  }
101
104
  }
102
105
 
103
- module.exports = createBackend
106
+ export default createBackend
package/lib/dbDao.js CHANGED
@@ -1,4 +1,4 @@
1
- const ReactiveDao = require("@live-change/dao")
1
+ import ReactiveDao from "@live-change/dao"
2
2
 
3
3
  function localRequests(server, scriptContext) {
4
4
  return {
@@ -847,7 +847,7 @@ function localReads(server, scriptContext) {
847
847
  }
848
848
  }
849
849
 
850
- module.exports = {
850
+ export {
851
851
  localRequests,
852
852
  remoteRequests,
853
853
  localReads
package/lib/storeDao.js CHANGED
@@ -1,4 +1,4 @@
1
- function localRequests(server) {
1
+ export function localRequests(server) {
2
2
  return {
3
3
  put: (dbName, storeName, object) => {
4
4
  const db = server.databaseStores.get(dbName)
@@ -17,7 +17,7 @@ function localRequests(server) {
17
17
  }
18
18
  }
19
19
 
20
- function localReads(server) {
20
+ export function localReads(server) {
21
21
  return {
22
22
  object: {
23
23
  observable(dbName, storeName, id) {
@@ -53,8 +53,3 @@ function localReads(server) {
53
53
  }
54
54
  }
55
55
  }
56
-
57
- module.exports = {
58
- localRequests,
59
- localReads
60
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/db-web",
3
- "version": "0.7.2",
3
+ "version": "0.8.2",
4
4
  "author": {
5
5
  "email": "michal@laszczewski.com",
6
6
  "name": "Michał Łaszczewski",
@@ -22,19 +22,19 @@
22
22
  },
23
23
  "description": "live data access object",
24
24
  "readme": "README.md",
25
- "directories": {},
26
25
  "license": "MIT",
27
26
  "main": "index.js",
28
27
  "devDependencies": {
29
28
  "tape": "^5.7.4"
30
29
  },
30
+ "type": "module",
31
31
  "dependencies": {
32
32
  "@live-change/dao": "0.6.0",
33
- "@live-change/db": "^0.7.2",
34
- "@live-change/db-store-indexeddb": "^0.7.2",
35
- "@live-change/db-store-localstorage": "^0.7.2",
36
- "@live-change/db-store-rbtree": "^0.7.2",
33
+ "@live-change/db": "^0.8.2",
34
+ "@live-change/db-store-indexeddb": "^0.8.2",
35
+ "@live-change/db-store-localstorage": "^0.8.2",
36
+ "@live-change/db-store-rbtree": "^0.8.2",
37
37
  "debug": "^4.3.4"
38
38
  },
39
- "gitHead": "36d5b8a4430d82526b8b63290c44209e6187da96"
39
+ "gitHead": "53b8efc8ec7f5c1c4af33077d8fb4a8a5580f1d9"
40
40
  }