@live-change/db 0.9.83 → 0.9.85
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/lib/Index.js +3 -0
- package/lib/ScriptContext.js +15 -9
- package/package.json +5 -5
package/lib/Index.js
CHANGED
|
@@ -535,10 +535,13 @@ class Index extends Table {
|
|
|
535
535
|
this.scriptContext = this.database.createScriptContext({
|
|
536
536
|
/// TODO: script available routines
|
|
537
537
|
})
|
|
538
|
+
console.log("COMPILE INDEX CODE", this.code)
|
|
538
539
|
const queryFunction = this.scriptContext.getOrCreateFunction(this.code,
|
|
539
540
|
`userCode:${this.database.name}/indexes/${this.name}`)
|
|
540
541
|
if(typeof queryFunction != 'function') {
|
|
541
542
|
console.error("INDEX CODE", this.code)
|
|
543
|
+
console.error("QUERY FUNCTION", typeof queryFunction, queryFunction)
|
|
544
|
+
process.exit(1)
|
|
542
545
|
throw new Error("Index code is not a function")
|
|
543
546
|
}
|
|
544
547
|
this.codeFunction = (input, output) => queryFunction(input, output, this.params)
|
package/lib/ScriptContext.js
CHANGED
|
@@ -90,16 +90,22 @@ class ScriptContext {
|
|
|
90
90
|
|
|
91
91
|
getOrCreateFunction(code, filename) {
|
|
92
92
|
const cleanCode = code.replace(/\n +/g, "\n")
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
if(!globalThis.compiledFunctions) globalThis.compiledFunctions = {}
|
|
94
|
+
const compiledFunction = globalThis.compiledFunctions[cleanCode]
|
|
95
|
+
if(compiledFunction) {
|
|
96
|
+
/* console.log("found compiled function!", cleanCode) */
|
|
97
|
+
if(typeof compiledFunction != 'function') {
|
|
98
|
+
console.error("compiled function is not a function!", cleanCode)
|
|
99
|
+
process.exit(1)
|
|
98
100
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
return compiledFunction
|
|
102
|
+
}
|
|
103
|
+
const queryFunction = this.run(code, filename)
|
|
104
|
+
if(typeof queryFunction != 'function') {
|
|
105
|
+
console.error("compiled query function is not a function!", cleanCode)
|
|
106
|
+
process.exit(1)
|
|
107
|
+
}
|
|
108
|
+
globalThis.compiledFunctions[cleanCode] = queryFunction
|
|
103
109
|
return queryFunction
|
|
104
110
|
}
|
|
105
111
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/db",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.85",
|
|
4
4
|
"description": "Database with observable data for live queries",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"type": "module",
|
|
23
23
|
"homepage": "https://github.com/live-change/live-change-stack",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@live-change/db-store-level": "^0.9.
|
|
26
|
-
"@live-change/db-store-lmdb": "^0.9.
|
|
25
|
+
"@live-change/db-store-level": "^0.9.85",
|
|
26
|
+
"@live-change/db-store-lmdb": "^0.9.85",
|
|
27
27
|
"minimist": ">=1.2.3",
|
|
28
28
|
"next-tick": "^1.1.0",
|
|
29
29
|
"rimraf": "^5.0.5",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"websocket-extensions": ">=0.1.4"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@live-change/dao": "^0.9.
|
|
35
|
+
"@live-change/dao": "^0.9.85",
|
|
36
36
|
"get-random-values": "^1.2.2",
|
|
37
37
|
"node-interval-tree": "^1.3.3"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "126afb0aad3ab6e03aa5742726f429c95c46783a"
|
|
40
40
|
}
|