pico-engine 1.3.0 → 1.4.0
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/RulesetRegistryLoaderFs.js +4 -7
- package/dist/index.js +9 -4
- package/dist/logging.js +36 -27
- package/dist/server.js +9 -4
- package/dist/utils/toFileUrl.js +1 -2
- package/krl/io.picolabs.did-o.krl +25 -5
- package/krl/io.picolabs.pds.krl +344 -0
- package/krl/io.picolabs.pico-engine-ui.krl +43 -10
- package/krl/io.picolabs.wrangler.krl +17 -16
- package/package.json +22 -28
- package/public/pico-engine-ui.css +4 -4
- package/public/pico-engine-ui.js +49 -16
- package/src/RulesetRegistryLoaderFs.ts +6 -10
- package/src/index.ts +9 -5
- package/src/logging.ts +36 -47
- package/src/server.ts +13 -2
|
@@ -12,9 +12,16 @@ ruleset io.picolabs.pico-engine-ui {
|
|
|
12
12
|
.map(function(c){c["id"]})
|
|
13
13
|
.head()
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
// Cached UI channel ECIs for parent/child links. Populated at child creation
|
|
16
|
+
// and backfilled on engine started. box()/pico() read these maps only — no
|
|
17
|
+
// cross-pico ctx:query — to avoid deadlocks (#493).
|
|
18
|
+
uiEciForChild = function(familyEci){
|
|
19
|
+
ent:child_ui_ecis{familyEci}
|
|
20
|
+
}
|
|
21
|
+
childUiEcis = function(){
|
|
22
|
+
ctx:children
|
|
23
|
+
.map(uiEciForChild)
|
|
24
|
+
.filter(function(eci){eci})
|
|
18
25
|
}
|
|
19
26
|
testingECI = function(){
|
|
20
27
|
return ent:testingECI
|
|
@@ -25,8 +32,8 @@ ruleset io.picolabs.pico-engine-ui {
|
|
|
25
32
|
box = function(){
|
|
26
33
|
return {
|
|
27
34
|
"eci": uiECI(),
|
|
28
|
-
"parent":
|
|
29
|
-
"children":
|
|
35
|
+
"parent": ent:parent_ui_eci,
|
|
36
|
+
"children": childUiEcis(),
|
|
30
37
|
"name": name(),
|
|
31
38
|
"backgroundColor": ent:backgroundColor || "#87cefa",
|
|
32
39
|
"x": ent:x || 100,
|
|
@@ -38,8 +45,8 @@ ruleset io.picolabs.pico-engine-ui {
|
|
|
38
45
|
pico = function(){
|
|
39
46
|
return {
|
|
40
47
|
"eci": uiECI(),
|
|
41
|
-
"parent":
|
|
42
|
-
"children":
|
|
48
|
+
"parent": ent:parent_ui_eci,
|
|
49
|
+
"children": childUiEcis(),
|
|
43
50
|
"channels": ctx:channels,
|
|
44
51
|
"rulesets": ctx:rulesets
|
|
45
52
|
}
|
|
@@ -176,6 +183,33 @@ ruleset io.picolabs.pico-engine-ui {
|
|
|
176
183
|
ent:height := event:attrs{"height"}.as("Number") if event:attrs{"height"}
|
|
177
184
|
ent:name := event:attrs{"name"}.as("String") if event:attrs{"name"}
|
|
178
185
|
ent:backgroundColor := event:attrs{"backgroundColor"}.validateColor() if event:attrs{"backgroundColor"}
|
|
186
|
+
ent:parent_ui_eci := event:attrs{"parentUiEci"} if event:attrs{"parentUiEci"}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
rule remember_child_ui_eci {
|
|
190
|
+
select when wrangler new_child_created
|
|
191
|
+
pre {
|
|
192
|
+
uiEci = event:attr("uiEci")
|
|
193
|
+
familyEci = event:attr("eci")
|
|
194
|
+
}
|
|
195
|
+
if uiEci && familyEci then noop()
|
|
196
|
+
always {
|
|
197
|
+
ent:child_ui_ecis{[familyEci]} := uiEci
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
rule backfill_child_ui_eci {
|
|
201
|
+
select when engine started
|
|
202
|
+
foreach ctx:children setting(familyEci)
|
|
203
|
+
if ent:child_ui_ecis{familyEci}.isnull() then noop()
|
|
204
|
+
always {
|
|
205
|
+
ent:child_ui_ecis{[familyEci]} := ctx:query(familyEci, ctx:rid, "uiECI")
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
rule backfill_parent_ui_eci {
|
|
209
|
+
select when engine started
|
|
210
|
+
if ctx:parent && ent:parent_ui_eci.isnull() then noop()
|
|
211
|
+
always {
|
|
212
|
+
ent:parent_ui_eci := ctx:query(ctx:parent, ctx:rid, "uiECI")
|
|
179
213
|
}
|
|
180
214
|
}
|
|
181
215
|
rule new {
|
|
@@ -196,9 +230,8 @@ ruleset io.picolabs.pico-engine-ui {
|
|
|
196
230
|
pre {
|
|
197
231
|
delUiEci = event:attrs{"eci"}
|
|
198
232
|
delEci = ctx:children
|
|
199
|
-
.filter(function(
|
|
200
|
-
|
|
201
|
-
return other == delUiEci
|
|
233
|
+
.filter(function(familyEci){
|
|
234
|
+
ent:child_ui_ecis{familyEci} == delUiEci
|
|
202
235
|
})
|
|
203
236
|
.head()
|
|
204
237
|
}
|
|
@@ -145,8 +145,8 @@ ruleset io.picolabs.wrangler {
|
|
|
145
145
|
web_hook = buildWebHook(eci, mod, func, _host, _path, _root_url)
|
|
146
146
|
|
|
147
147
|
response = thisPico => QUERY_SELF_INVALID_HTTP_MAP |
|
|
148
|
-
thisHost => processQueryResponse(ctx:query(eci, mod, func, {}.put(params))) |
|
|
149
148
|
isDid => dido:prepareQuery(eci, {"rid": mod, "name": func, "args": params}) |
|
|
149
|
+
thisHost => processQueryResponse(ctx:query(eci, mod, func, {}.put(params))) |
|
|
150
150
|
processHTTPResponse(http:get(web_hook, {}.put(params)))
|
|
151
151
|
|
|
152
152
|
response
|
|
@@ -360,6 +360,10 @@ ruleset io.picolabs.wrangler {
|
|
|
360
360
|
"config":the_ruleset.get("config")
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
|
+
parentUiEci = ctx:channels
|
|
364
|
+
.filter(function(c){c["tags"].sort().join(",") == "engine,ui"})
|
|
365
|
+
.map(function(c){c["id"]})
|
|
366
|
+
.head()
|
|
363
367
|
}
|
|
364
368
|
every {
|
|
365
369
|
ctx:newPico(rulesets=[
|
|
@@ -385,13 +389,14 @@ ruleset io.picolabs.wrangler {
|
|
|
385
389
|
name="box",
|
|
386
390
|
attrs={
|
|
387
391
|
"name": name,
|
|
388
|
-
"backgroundColor": backgroundColor
|
|
392
|
+
"backgroundColor": backgroundColor,
|
|
393
|
+
"parentUiEci": parentUiEci
|
|
389
394
|
}
|
|
390
395
|
)
|
|
391
396
|
}
|
|
392
397
|
fired {
|
|
393
398
|
raise wrangler event "new_child_created"
|
|
394
|
-
attributes event:attrs.put({"eci":newEci})
|
|
399
|
+
attributes event:attrs.put({"eci":newEci, "uiEci": newUiECI})
|
|
395
400
|
}
|
|
396
401
|
}
|
|
397
402
|
|
|
@@ -401,25 +406,21 @@ ruleset io.picolabs.wrangler {
|
|
|
401
406
|
rule initialize_child_after_creation {
|
|
402
407
|
select when wrangler pico_created
|
|
403
408
|
pre {
|
|
404
|
-
|
|
405
|
-
subscription_rid = "io.picolabs.subscription"
|
|
409
|
+
sibling_ruleset_url = function(rid){
|
|
406
410
|
parts = ctx:rid_url.split("/")
|
|
407
|
-
parts.splice(parts.length()-1,1,
|
|
411
|
+
parts.splice(parts.length()-1,1,rid+".krl").join("/")
|
|
408
412
|
}
|
|
409
|
-
subs_url =
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
did_o_rid = "io.picolabs.did-o"
|
|
413
|
-
parts = ctx:rid_url.split("/")
|
|
414
|
-
parts.splice(parts.length()-1,1,did_o_rid+".krl").join("/")
|
|
415
|
-
}
|
|
416
|
-
did_o_url = did_o_ruleset_url()
|
|
413
|
+
subs_url = sibling_ruleset_url("io.picolabs.subscription")
|
|
414
|
+
did_o_url = sibling_ruleset_url("io.picolabs.did-o")
|
|
415
|
+
pds_url = sibling_ruleset_url("io.picolabs.pds")
|
|
417
416
|
}
|
|
418
417
|
fired {
|
|
419
418
|
raise wrangler event "install_ruleset_request"
|
|
420
|
-
attributes {"url":
|
|
419
|
+
attributes {"url": pds_url}
|
|
420
|
+
raise wrangler event "install_ruleset_request"
|
|
421
|
+
attributes {"url": subs_url}
|
|
421
422
|
raise wrangler event "install_ruleset_request"
|
|
422
|
-
attributes {"url":did_o_url}
|
|
423
|
+
attributes {"url": did_o_url}
|
|
423
424
|
ent:parent_eci := ctx:parent
|
|
424
425
|
ent:name := event:attr("name")
|
|
425
426
|
ent:id := ctx:picoId
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pico-engine",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "An implementation of the pico-engine targeting node.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,64 +30,58 @@
|
|
|
30
30
|
"pico-engine": "bin/pico-engine"
|
|
31
31
|
},
|
|
32
32
|
"engines": {
|
|
33
|
-
"node": ">=
|
|
33
|
+
"node": ">=20.0.0"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
|
-
"
|
|
36
|
+
"prepare": "npm run build",
|
|
37
37
|
"build": "rm -rf dist && tsc",
|
|
38
38
|
"start": "npm run dev -s",
|
|
39
39
|
"dev": "scriptsp -r dev:tsc dev:api",
|
|
40
40
|
"dev:tsc": "tsc -w --preserveWatchOutput",
|
|
41
41
|
"dev:api": "onchange -i -k dist/ -- node dist/cli.js",
|
|
42
|
-
"test": "ava"
|
|
42
|
+
"test": "ava reset-cache && ava"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"body-parser": "^1.18.3",
|
|
46
46
|
"charwise": "^3.0.1",
|
|
47
|
-
"
|
|
47
|
+
"classic-level": "^1.3.0",
|
|
48
|
+
"cross-fetch": "^4.0.0",
|
|
48
49
|
"cuid": "^2.1.8",
|
|
49
|
-
"encoding-down": "^6.0.2",
|
|
50
50
|
"express": "^4.16.4",
|
|
51
|
-
"helmet": "^
|
|
51
|
+
"helmet": "^7.1.0",
|
|
52
52
|
"home-dir": "^1.0.0",
|
|
53
|
-
"krl-compiler": "^1.
|
|
54
|
-
"krl-stdlib": "^1.
|
|
53
|
+
"krl-compiler": "^1.4.0",
|
|
54
|
+
"krl-stdlib": "^1.4.0",
|
|
55
55
|
"level-json-coerce-null": "^1.0.1",
|
|
56
|
-
"leveldown": "^5.0.2",
|
|
57
|
-
"levelup": "^4.0.1",
|
|
58
56
|
"lodash": "^4.17.11",
|
|
59
|
-
"make-dir": "^
|
|
60
|
-
"memdown": "^5.1.0",
|
|
57
|
+
"make-dir": "^4.0.0",
|
|
61
58
|
"minimist": "^1.2.5",
|
|
62
|
-
"pico-engine-core": "^1.
|
|
63
|
-
"pico-framework": "^0.
|
|
64
|
-
"rotating-file-stream": "^1.4.1"
|
|
65
|
-
"split": "^1.0.1",
|
|
66
|
-
"through2": "^3.0.1"
|
|
59
|
+
"pico-engine-core": "^1.4.0",
|
|
60
|
+
"pico-framework": "^0.7.0",
|
|
61
|
+
"rotating-file-stream": "^1.4.1"
|
|
67
62
|
},
|
|
68
63
|
"devDependencies": {
|
|
69
64
|
"@types/body-parser": "^1.17.0",
|
|
70
65
|
"@types/express": "^4.16.1",
|
|
71
|
-
"@types/helmet": "0.0.43",
|
|
72
|
-
"@types/leveldown": "^4.0.0",
|
|
73
|
-
"@types/levelup": "^3.1.0",
|
|
74
66
|
"@types/lodash": "^4.14.123",
|
|
75
|
-
"@types/node": "^
|
|
76
|
-
"ava": "^
|
|
77
|
-
"onchange": "^
|
|
67
|
+
"@types/node": "^20.8.10",
|
|
68
|
+
"ava": "^5.3.1",
|
|
69
|
+
"onchange": "^7.1.0",
|
|
78
70
|
"scriptsp": "^1.1.1",
|
|
79
|
-
"temp-dir": "^2.0.0",
|
|
80
71
|
"ts-node": "^10.4.0",
|
|
81
|
-
"typescript": "^
|
|
72
|
+
"typescript": "^5.2.2"
|
|
82
73
|
},
|
|
83
74
|
"ava": {
|
|
84
|
-
"compileEnhancements": false,
|
|
85
75
|
"extensions": [
|
|
86
76
|
"ts"
|
|
87
77
|
],
|
|
88
78
|
"require": [
|
|
89
79
|
"ts-node/register"
|
|
80
|
+
],
|
|
81
|
+
"files": [
|
|
82
|
+
"test/**/*",
|
|
83
|
+
"!test/helpers/**/*"
|
|
90
84
|
]
|
|
91
85
|
},
|
|
92
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "9004831f943022f7d37bc2260076ad038c6e7b9e"
|
|
93
87
|
}
|