@muze-nl/simplystore 0.6.17 → 0.6.19
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/package.json +3 -3
- package/src/load-worker.mjs +9 -4
- package/src/query-worker-module.mjs +4 -0
- package/src/server.mjs +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@muze-nl/simplystore",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.19",
|
|
4
4
|
"main": "src/server.mjs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"bugs": "https://github.com/simplyedit/simplystore/issues",
|
|
17
17
|
"homepage": "https://github.com/simplyedit/simplystore#readme",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@muze-nl/jsontag": "^0.9.
|
|
20
|
-
"@muze-nl/od-jsontag": "^0.2.
|
|
19
|
+
"@muze-nl/jsontag": "^0.9.1",
|
|
20
|
+
"@muze-nl/od-jsontag": "^0.2.9",
|
|
21
21
|
"codemirror": "^6.0.1",
|
|
22
22
|
"express": "^4.18.1",
|
|
23
23
|
"jaqt": "^0.9.0",
|
package/src/load-worker.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { parentPort } from 'node:worker_threads'
|
|
2
|
+
import JSONTag from '@muze-nl/jsontag'
|
|
2
3
|
import parse from '@muze-nl/od-jsontag/src/parse.mjs'
|
|
3
4
|
import fs from 'fs'
|
|
4
5
|
import serialize from '@muze-nl/od-jsontag/src/serialize.mjs'
|
|
5
6
|
|
|
6
|
-
parentPort.on('message',
|
|
7
|
+
parentPort.on('message', (files) => {
|
|
7
8
|
let meta = {
|
|
8
9
|
index: {
|
|
9
10
|
id: new Map()
|
|
@@ -11,11 +12,11 @@ parentPort.on('message', datafile => {
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
let count = 0
|
|
14
|
-
let basefile =
|
|
15
|
-
let data
|
|
15
|
+
let basefile = files.dataFile
|
|
16
|
+
let data
|
|
16
17
|
let jsontag
|
|
17
18
|
let tempMeta = {}
|
|
18
|
-
|
|
19
|
+
let datafile = files.dataFile
|
|
19
20
|
do {
|
|
20
21
|
jsontag = fs.readFileSync(datafile)
|
|
21
22
|
data = parse(jsontag, tempMeta) // tempMeta is needed to combine the resultArray, using meta conflicts with meta.index.id
|
|
@@ -23,6 +24,10 @@ parentPort.on('message', datafile => {
|
|
|
23
24
|
datafile = basefile + '.' + count
|
|
24
25
|
} while(fs.existsSync(datafile))
|
|
25
26
|
meta.parts = count
|
|
27
|
+
if (files.schemaFile) {
|
|
28
|
+
jsontag = fs.readFileSync(files.schemaFile, 'utf-8')
|
|
29
|
+
meta.schema = JSONTag.parse(jsontag, null, tempMeta)
|
|
30
|
+
}
|
|
26
31
|
|
|
27
32
|
const sab = serialize(data, {meta})
|
|
28
33
|
|
|
@@ -74,10 +74,14 @@ const tasks = {
|
|
|
74
74
|
if (task.req.meta.index) {
|
|
75
75
|
meta.index = task.req.meta.index
|
|
76
76
|
}
|
|
77
|
+
if (task.req.meta.schema) {
|
|
78
|
+
meta.schema = task.req.meta.schema
|
|
79
|
+
}
|
|
77
80
|
for (let sab of task.req.body) { //body contains an array of sharedArrayBuffers with initial data and changes
|
|
78
81
|
dataspace = parse(sab, meta)
|
|
79
82
|
}
|
|
80
83
|
metaProxy.index.id = metaIdProxy
|
|
84
|
+
metaProxy.schema = meta.schema
|
|
81
85
|
//@TODO: add meta.index.references? and baseURL
|
|
82
86
|
return true
|
|
83
87
|
},
|
package/src/server.mjs
CHANGED
|
@@ -20,6 +20,7 @@ async function main(options) {
|
|
|
20
20
|
}
|
|
21
21
|
const port = options.port || 3000
|
|
22
22
|
const datafile = options.datafile || './data.od-jsontag'
|
|
23
|
+
const schemaFile = options.schemaFile || null
|
|
23
24
|
const wwwroot = options.wwwroot || __dirname+'/www'
|
|
24
25
|
const maxWorkers = options.maxWorkers || 8
|
|
25
26
|
const queryWorker = options.queryWorker || __dirname+'/src/query-worker.mjs'
|
|
@@ -49,7 +50,7 @@ async function main(options) {
|
|
|
49
50
|
reject(error)
|
|
50
51
|
worker.terminate()
|
|
51
52
|
})
|
|
52
|
-
worker.postMessage(datafile)
|
|
53
|
+
worker.postMessage({dataFile:datafile,schemaFile})
|
|
53
54
|
})
|
|
54
55
|
}
|
|
55
56
|
try {
|