pico-engine 1.8.0 → 1.9.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/README.md +3 -1
- package/dist/RulesetRegistryLoaderFs.js +46 -4
- package/dist/cli.js +3 -1
- package/dist/engineConfig.js +11 -0
- package/dist/index.js +2 -5
- package/dist/logging.js +148 -4
- package/dist/server.js +206 -1
- package/dist/stageKrl.js +26 -0
- package/dist/xmluiRuntime.js +68 -0
- package/krl/io.picolabs.pico-engine-ui.krl +12 -77
- package/krl/io.picolabs.wrangler.krl +21 -4
- package/krl/io.picolabs.xmlui.krl +295 -0
- package/package.json +9 -6
- package/public/.DS_Store +0 -0
- package/public/docs/_sidebar.md +1 -0
- package/public/docs/llms-full.txt +154 -3
- package/public/docs/llms.txt +1 -0
- package/public/docs/pico-engine.md +7 -3
- package/public/docs/pico-views-xmlui.md +5 -0
- package/public/docs/pico-views.md +140 -0
- package/public/docs/rulesets/README.md +1 -0
- package/public/pico-engine-ui.css +1 -1
- package/public/pico-engine-ui.js +27 -25
- package/public/xmlui/0.12.7.js +419 -0
- package/public/xmlui/pico-view-boot.js +153 -0
- package/src/RulesetRegistryLoaderFs.ts +48 -4
- package/src/cli.ts +3 -1
- package/src/engineConfig.ts +18 -0
- package/src/index.ts +4 -6
- package/src/logging.ts +165 -4
- package/src/server.ts +250 -2
- package/src/stageKrl.ts +26 -0
- package/src/xmluiRuntime.ts +66 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XMLUI_EMPTY_CODE_BEHIND = exports.XMLUI_RUNTIME_PUBLIC_PATH = exports.XMLUI_RUNTIME_VERSION = void 0;
|
|
4
|
+
exports.isXmluiCodeBehindPath = isXmluiCodeBehindPath;
|
|
5
|
+
exports.viewComponentFileName = viewComponentFileName;
|
|
6
|
+
exports.parseComponentXmluiPath = parseComponentXmluiPath;
|
|
7
|
+
exports.isXmluiSpaClientRoute = isXmluiSpaClientRoute;
|
|
8
|
+
exports.viewQueryNameForComponent = viewQueryNameForComponent;
|
|
9
|
+
exports.contentTypeForUiPath = contentTypeForUiPath;
|
|
10
|
+
/** Pinned XMLUI standalone runtime shipped under `public/xmlui/`. */
|
|
11
|
+
exports.XMLUI_RUNTIME_VERSION = "0.12.7";
|
|
12
|
+
exports.XMLUI_RUNTIME_PUBLIC_PATH = `/xmlui/${exports.XMLUI_RUNTIME_VERSION}.js`;
|
|
13
|
+
/** XMLUI standalone always requests Main.xmlui.xs (and per-component .xmlui.xs). */
|
|
14
|
+
exports.XMLUI_EMPTY_CODE_BEHIND = "var __pico_xmlui_codebehind = 0;\n";
|
|
15
|
+
function isXmluiCodeBehindPath(relPath) {
|
|
16
|
+
if (relPath === "Main.xmlui.xs")
|
|
17
|
+
return true;
|
|
18
|
+
return /^components\/.+\.xmlui\.xs$/i.test(relPath);
|
|
19
|
+
}
|
|
20
|
+
/** Map a shared function name to the XMLUI component file name (Hello, ColorView, …). */
|
|
21
|
+
function viewComponentFileName(fnName) {
|
|
22
|
+
if (!fnName)
|
|
23
|
+
return fnName;
|
|
24
|
+
return fnName.charAt(0).toUpperCase() + fnName.slice(1);
|
|
25
|
+
}
|
|
26
|
+
function parseComponentXmluiPath(relPath) {
|
|
27
|
+
const m = /^components\/(.+)\.xmlui$/i.exec(relPath);
|
|
28
|
+
return m ? m[1] : null;
|
|
29
|
+
}
|
|
30
|
+
/** Client route segment (e.g. list, contact/abc) — not a static XMLUI asset. */
|
|
31
|
+
function isXmluiSpaClientRoute(relPath) {
|
|
32
|
+
const rel = relPath.replace(/^\/+/, "");
|
|
33
|
+
if (!rel || rel === "index.html")
|
|
34
|
+
return false;
|
|
35
|
+
if (rel === "Main.xmlui" || rel === "config.json")
|
|
36
|
+
return false;
|
|
37
|
+
if (isXmluiCodeBehindPath(rel))
|
|
38
|
+
return false;
|
|
39
|
+
if (parseComponentXmluiPath(rel))
|
|
40
|
+
return false;
|
|
41
|
+
const lastSegment = rel.split("/").pop() || "";
|
|
42
|
+
if (lastSegment.includes("."))
|
|
43
|
+
return false;
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
function viewQueryNameForComponent(queries, appRid, componentName) {
|
|
47
|
+
var _a;
|
|
48
|
+
if (!(queries === null || queries === void 0 ? void 0 : queries.length))
|
|
49
|
+
return null;
|
|
50
|
+
const hit = queries.find((q) => q.rid === appRid &&
|
|
51
|
+
q.view != null &&
|
|
52
|
+
viewComponentFileName(q.name) === componentName);
|
|
53
|
+
return (_a = hit === null || hit === void 0 ? void 0 : hit.name) !== null && _a !== void 0 ? _a : null;
|
|
54
|
+
}
|
|
55
|
+
function contentTypeForUiPath(filePath) {
|
|
56
|
+
const lower = filePath.toLowerCase();
|
|
57
|
+
if (lower.endsWith(".html"))
|
|
58
|
+
return "text/html; charset=utf-8";
|
|
59
|
+
if (lower.endsWith(".xmlui"))
|
|
60
|
+
return "application/xml; charset=utf-8";
|
|
61
|
+
if (lower.endsWith(".xs"))
|
|
62
|
+
return "text/plain; charset=utf-8";
|
|
63
|
+
if (lower.endsWith(".json"))
|
|
64
|
+
return "application/json; charset=utf-8";
|
|
65
|
+
if (lower.endsWith(".css"))
|
|
66
|
+
return "text/css; charset=utf-8";
|
|
67
|
+
return "text/plain; charset=utf-8";
|
|
68
|
+
}
|
|
@@ -98,83 +98,13 @@ ruleset io.picolabs.pico-engine-ui {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
|
-
* Recent activity on this pico,
|
|
102
|
-
*
|
|
103
|
-
* The
|
|
104
|
-
* @returns Array "[ { txnId,
|
|
101
|
+
* Recent activity on this pico, newest first. Each transaction is a list of
|
|
102
|
+
* steps (`in`, `rule`, `raise`, `klog`, `log`, `error`, `done`) assembled
|
|
103
|
+
* from the engine log. The Logging tab hides engine rulesets in the browser.
|
|
104
|
+
* @returns Array "[ { txnId, kind, start, durationMs, outcome, steps } ]"
|
|
105
105
|
*/
|
|
106
106
|
logs = function(){
|
|
107
|
-
|
|
108
|
-
entry.delete("time")
|
|
109
|
-
.delete("level")
|
|
110
|
-
.delete("msg")
|
|
111
|
-
.delete("txnId")
|
|
112
|
-
.encode()
|
|
113
|
-
}
|
|
114
|
-
logQuery = function(query){
|
|
115
|
-
args = query.get("args").delete("_headers") || {}
|
|
116
|
-
<<QUERY #{query.get("eci")} #{query.get("rid")}/#{query.get("name")} #{args.encode()}>>
|
|
117
|
-
}
|
|
118
|
-
logEvent = function(event){
|
|
119
|
-
attrs = event.get(["data","attrs"]).delete("_headers") || {}
|
|
120
|
-
<<EVENT #{event.get("eci")} #{event.get("domain")}:#{event.get("name")} #{attrs.encode()}>>
|
|
121
|
-
}
|
|
122
|
-
logFirst = function(entry){
|
|
123
|
-
txn = entry.get("txn")
|
|
124
|
-
kind = txn.get("kind")
|
|
125
|
-
kind == "query" => logQuery(txn.get("query")) |
|
|
126
|
-
kind == "event" => logEvent(txn.get("event")) |
|
|
127
|
-
logOther(entry)
|
|
128
|
-
}
|
|
129
|
-
logDetails = function(entry){
|
|
130
|
-
msg = entry.get("msg")
|
|
131
|
-
msg == "txnQueued" => logFirst(entry) |
|
|
132
|
-
msg == "event added to schedule" => entry.get("event").encode() |
|
|
133
|
-
msg == "rule selected" => <<#{entry.get("rid")} : #{entry.get("rule_name")}>> |
|
|
134
|
-
entry.get("level") == "klog" => entry.get("val").encode() || "null" |
|
|
135
|
-
msg.match(re#fired$#) => "" |
|
|
136
|
-
logOther(entry)
|
|
137
|
-
}
|
|
138
|
-
episode_line = function(x,i){
|
|
139
|
-
level = x{"level"}.uc();
|
|
140
|
-
x{"time"}.split("T")[1] +
|
|
141
|
-
" [" +
|
|
142
|
-
level +
|
|
143
|
-
"] "+
|
|
144
|
-
x{"msg"} +
|
|
145
|
-
" " +
|
|
146
|
-
logDetails(x)
|
|
147
|
-
};
|
|
148
|
-
entryMap = function(a,e){
|
|
149
|
-
// a.head() is array of entries; a[1] is whether last entry is eats
|
|
150
|
-
// a[2] is domain:name of the event
|
|
151
|
-
eats = e{"msg"} == "event added to schedule"
|
|
152
|
-
event_dt = eats => e{["event","domain"]} + ":" + e{["event","name"]}
|
|
153
|
-
| ""
|
|
154
|
-
a[1] && eats && a[2]==event_dt
|
|
155
|
-
=> [a.head(),true,event_dt] // omit a duplicate eats
|
|
156
|
-
| [a.head().append(episode_line(e)),eats,event_dt]
|
|
157
|
-
}
|
|
158
|
-
episodes = ctx:logs()
|
|
159
|
-
.collect(function(e){e.get("txnId")})
|
|
160
|
-
episodes.keys()
|
|
161
|
-
.map(function(k){
|
|
162
|
-
episode = episodes.get(k)
|
|
163
|
-
entries = episode
|
|
164
|
-
.reduce(entryMap,[[],false,""]).head()
|
|
165
|
-
return {
|
|
166
|
-
"txnId": k,
|
|
167
|
-
"time": episode.head().get("time"),
|
|
168
|
-
"header": entries.head().split(re# txnQueued #)[1],
|
|
169
|
-
"entries": entries,
|
|
170
|
-
}
|
|
171
|
-
})
|
|
172
|
-
.filter(function(g){
|
|
173
|
-
g{"header"}.match(re#^QUERY .*io.picolabs.pico-engine-ui/#) => false |
|
|
174
|
-
g{"header"}.match(re#^QUERY .*io.picolabs.subscription/established#) => false |
|
|
175
|
-
true
|
|
176
|
-
})
|
|
177
|
-
.reverse()
|
|
107
|
+
ctx:logTransactions()
|
|
178
108
|
}
|
|
179
109
|
uiChannelEventPolicy = function() {
|
|
180
110
|
{
|
|
@@ -291,12 +221,15 @@ ruleset io.picolabs.pico-engine-ui {
|
|
|
291
221
|
pre {
|
|
292
222
|
uiEci = event:attr("uiEci")
|
|
293
223
|
familyEci = event:attr("eci")
|
|
224
|
+
requestedColor = event:attrs{"backgroundColor"}
|
|
294
225
|
childIndex = childLayoutIndex(familyEci)
|
|
295
226
|
gridCol = childIndex % 4
|
|
296
227
|
gridRow = (childIndex - childIndex % 4) / 4
|
|
297
228
|
layoutX = ent:x.defaultsTo(100) + 48 + gridCol * 143
|
|
298
229
|
layoutY = ent:y.defaultsTo(100) + 48 + gridRow * 108
|
|
299
|
-
layoutColor =
|
|
230
|
+
layoutColor = requestedColor.match(re#^\#[0-9A-F]{6}$#i)
|
|
231
|
+
=> requestedColor
|
|
232
|
+
| childPalette[childIndex % childPalette.length]
|
|
300
233
|
}
|
|
301
234
|
if uiEci && familyEci then
|
|
302
235
|
ctx:event(
|
|
@@ -326,7 +259,9 @@ ruleset io.picolabs.pico-engine-ui {
|
|
|
326
259
|
gridRow = (childIndex - childIndex % 4) / 4
|
|
327
260
|
layoutX = ent:x.defaultsTo(100) + 48 + gridCol * 143
|
|
328
261
|
layoutY = ent:y.defaultsTo(100) + 48 + gridRow * 108
|
|
329
|
-
|
|
262
|
+
childBox = ctx:query(uiEci, ctx:rid, "box")
|
|
263
|
+
layoutColor = childBox{"backgroundColor"}
|
|
264
|
+
.defaultsTo(childPalette[childIndex % childPalette.length])
|
|
330
265
|
}
|
|
331
266
|
if uiEci && ctx:query(uiEci, ctx:rid, "needsStartupLayout") then
|
|
332
267
|
ctx:event(
|
|
@@ -160,6 +160,19 @@ ruleset io.picolabs.wrangler {
|
|
|
160
160
|
* @example "child's name" { "eci": "<child family eci>", "mod": "io.picolabs.wrangler", "func": "name" }
|
|
161
161
|
* @example "another engine" { "eci": "<eci>", "mod": "<rid>", "func": "<function>", "params": {}, "_host": "https://other.example" }
|
|
162
162
|
*/
|
|
163
|
+
/**
|
|
164
|
+
* Query through a channel on this pico (policy applies). Used by view file()
|
|
165
|
+
* to render components on the same channel as the browser request.
|
|
166
|
+
* @param eci String "channel on this pico"
|
|
167
|
+
* @param rid String "ruleset id"
|
|
168
|
+
* @param name String "shared function"
|
|
169
|
+
* @param params Map "query arguments"
|
|
170
|
+
* @returns Any
|
|
171
|
+
*/
|
|
172
|
+
channelQuery = function(eci, rid, name, params) {
|
|
173
|
+
ctx:query(eci, rid, name, params.defaultsTo({}))
|
|
174
|
+
}
|
|
175
|
+
|
|
163
176
|
picoQuery = function(eci, mod, func, params,_host,_path,_root_url) {
|
|
164
177
|
isDid = eci.match(re#^did:#)
|
|
165
178
|
thisPico = ctx:channels.any(function(c){c{"id"}==eci})
|
|
@@ -523,6 +536,13 @@ ruleset io.picolabs.wrangler {
|
|
|
523
536
|
.filter(function(c){c["tags"].sort().join(",") == "engine,ui"})
|
|
524
537
|
.map(function(c){c["id"]})
|
|
525
538
|
.head()
|
|
539
|
+
childBoxAttrs = {
|
|
540
|
+
"name": name,
|
|
541
|
+
"parentUiEci": parentUiEci
|
|
542
|
+
}
|
|
543
|
+
boxAttrs = attrs{"backgroundColor"}.match(re#^\#[0-9A-F]{6}$#i)
|
|
544
|
+
=> childBoxAttrs.put("backgroundColor", attrs{"backgroundColor"})
|
|
545
|
+
| childBoxAttrs
|
|
526
546
|
every {
|
|
527
547
|
ctx:newPico(
|
|
528
548
|
rulesets=[
|
|
@@ -548,10 +568,7 @@ ruleset io.picolabs.wrangler {
|
|
|
548
568
|
eci=newUiECI,
|
|
549
569
|
domain="engine_ui",
|
|
550
570
|
name="box",
|
|
551
|
-
attrs=
|
|
552
|
-
"name": name,
|
|
553
|
-
"parentUiEci": parentUiEci
|
|
554
|
-
}
|
|
571
|
+
attrs=boxAttrs
|
|
555
572
|
)
|
|
556
573
|
}
|
|
557
574
|
return {"eci": newEci, "uiEci": newUiECI}
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
ruleset io.picolabs.xmlui {
|
|
2
|
+
meta {
|
|
3
|
+
name "XMLUI views"
|
|
4
|
+
description "Optional ruleset for pico views (XMLUI): file(), markup helpers, app channels."
|
|
5
|
+
author "PICOLABS"
|
|
6
|
+
|
|
7
|
+
use module io.picolabs.wrangler alias wrangler
|
|
8
|
+
|
|
9
|
+
provides query_url, event_url, query, event, escape, app_url, create_app_channel, rotate_app_channel, xmluiRuntimePath
|
|
10
|
+
shares file, query_url, event_url, query, event, escape, app_url, xmluiRuntimePath
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
global {
|
|
14
|
+
xmluiRuntimeVersion = "0.12.7"
|
|
15
|
+
xmluiFileRid = "io.picolabs.xmlui"
|
|
16
|
+
|
|
17
|
+
xmluiRuntimePath = function() {
|
|
18
|
+
"/xmlui/" + xmluiRuntimeVersion + ".js"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
query_url = function(name, rid, eci) {
|
|
22
|
+
"/sky/query/" + (eci || meta:eci) + "/" + (rid || meta:rid) + "/" + name
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
event_url = function(domain, type, eci) {
|
|
26
|
+
"/sky/event/" + (eci || meta:eci) + "/xmlui/" + domain + "/" + type
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
escape = function(s) {
|
|
30
|
+
s.replace("&", "&")
|
|
31
|
+
.replace("<", "<")
|
|
32
|
+
.replace(">", ">")
|
|
33
|
+
.replace("\"", """)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
escapeAttr = function(s) {
|
|
37
|
+
escape(s)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
queryArgsSuffix = function(args) {
|
|
41
|
+
args.isnull() || args == {} => "" |
|
|
42
|
+
args.keys().length() == 0 => "" |
|
|
43
|
+
"?" + args.keys()
|
|
44
|
+
.sort()
|
|
45
|
+
.map(function(k) {
|
|
46
|
+
k + "=" + args{k}
|
|
47
|
+
})
|
|
48
|
+
.join("&")
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @param id DataSource id
|
|
53
|
+
* @param name shared query name on app_rid
|
|
54
|
+
* @param opts rid, args (map, values may be XMLUI bindings), select
|
|
55
|
+
*/
|
|
56
|
+
query = function(id, name, opts) {
|
|
57
|
+
"<DataSource id=\"" + escapeAttr(id) + "\" url=\"" +
|
|
58
|
+
escapeAttr(
|
|
59
|
+
query_url(
|
|
60
|
+
name,
|
|
61
|
+
(opts.defaultsTo({}){"rid"} || meta:rid),
|
|
62
|
+
meta:eci
|
|
63
|
+
) + queryArgsSuffix(opts.defaultsTo({}){"args"})
|
|
64
|
+
) +
|
|
65
|
+
"\" headers=\"{appGlobals.auth}\"" +
|
|
66
|
+
(opts.defaultsTo({}){"select"}.isnull() => "" |
|
|
67
|
+
" resultSelector=\"" + escapeAttr(opts.defaultsTo({}){"select"}) + "\"") +
|
|
68
|
+
" />"
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @param id APICall id
|
|
73
|
+
* @param opts refresh (array of DataSource ids), confirm
|
|
74
|
+
*/
|
|
75
|
+
event = function(id, domain, type, opts) {
|
|
76
|
+
"<APICall id=\"" + escapeAttr(id) + "\" method=\"post\" url=\"" +
|
|
77
|
+
escapeAttr(event_url(domain, type, meta:eci)) +
|
|
78
|
+
"\" headers=\"{appGlobals.auth}\" body=\"{$param}\"" +
|
|
79
|
+
(opts.defaultsTo({}){"refresh"}.isnull() => "" |
|
|
80
|
+
" onSuccess=\"" + opts.defaultsTo({}){"refresh"}.map(function(ds) {
|
|
81
|
+
ds + ".refetch()"
|
|
82
|
+
}).join(";") + "\"") +
|
|
83
|
+
(opts.defaultsTo({}){"confirm"}.isnull() => "" |
|
|
84
|
+
" confirm=\"" + escapeAttr(opts.defaultsTo({}){"confirm"}) + "\"") +
|
|
85
|
+
" />"
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
newestChannelWithTags = function(tags) {
|
|
89
|
+
wrangler:channels(tags).sort(function(a, b) {
|
|
90
|
+
a{"id"} cmp b{"id"}
|
|
91
|
+
}).reverse().head()
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
app_url = function(tags, app_rid) {
|
|
95
|
+
newestChannelWithTags(tags).isnull() => null |
|
|
96
|
+
"/ui/" + newestChannelWithTags(tags){"id"} + "/" +
|
|
97
|
+
(app_rid || meta:rid) + "/"
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
shareNamesForApp = function(app_rid) {
|
|
101
|
+
wrangler:rulesetSchema(app_rid){"queries"}
|
|
102
|
+
.defaultsTo([])
|
|
103
|
+
.map(function(q) {
|
|
104
|
+
q{"name"}
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
queryPolicyForApp = function(app_rid, queries) {
|
|
109
|
+
(queries.isnull() => shareNamesForApp(app_rid) | queries)
|
|
110
|
+
.map(function(q) {
|
|
111
|
+
{ "rid": app_rid, "name": q }
|
|
112
|
+
})
|
|
113
|
+
.append([{ "rid": xmluiFileRid, "name": "file" }])
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
eventPolicyForDomains = function(domains) {
|
|
117
|
+
{
|
|
118
|
+
"allow": domains.map(function(d) {
|
|
119
|
+
{ "domain": d, "name": "*" }
|
|
120
|
+
}),
|
|
121
|
+
"deny": []
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
create_app_channel = defaction(tags, domains, queries, app_rid) {
|
|
126
|
+
wrangler:createChannel(
|
|
127
|
+
tags,
|
|
128
|
+
eventPolicyForDomains(domains.defaultsTo([])),
|
|
129
|
+
{
|
|
130
|
+
"allow": queryPolicyForApp(app_rid || meta:rid, queries),
|
|
131
|
+
"deny": []
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
rotate_app_channel = defaction(tags) {
|
|
137
|
+
template = newestChannelWithTags(tags)
|
|
138
|
+
wrangler:createChannel(
|
|
139
|
+
template{"tags"},
|
|
140
|
+
template{"eventPolicy"},
|
|
141
|
+
template{"queryPolicy"}
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
viewComponentName = function(fn) {
|
|
146
|
+
fn.substr(0, 1).uc() + fn.substr(1)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
viewQueriesOnChannel = function(app_rid) {
|
|
150
|
+
wrangler:channelSchema(meta:eci){"queries"}
|
|
151
|
+
.defaultsTo([])
|
|
152
|
+
.filter(function(q) {
|
|
153
|
+
q{"rid"} == app_rid && not q{"view"}.isnull()
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
launcherRids = function() {
|
|
158
|
+
wrangler:channelSchema(meta:eci){"queries"}
|
|
159
|
+
.defaultsTo([])
|
|
160
|
+
.filter(function(q) {
|
|
161
|
+
not q{"view"}.isnull()
|
|
162
|
+
})
|
|
163
|
+
.map(function(q) {
|
|
164
|
+
q{"rid"}
|
|
165
|
+
})
|
|
166
|
+
.sort()
|
|
167
|
+
.reduce(function(acc, rid) {
|
|
168
|
+
acc >< rid => acc | acc.append(rid)
|
|
169
|
+
}, [])
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
pageRoute = function(view, fn, multiView) {
|
|
173
|
+
not view{"path"}.isnull() => view{"path"} |
|
|
174
|
+
multiView => "/" + fn | "/"
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
navVisible = function(view) {
|
|
178
|
+
view{"path"}.isnull() => true |
|
|
179
|
+
view{"path"}.split(":").length() == 1
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
firstNavViewQuery = function(app_rid) {
|
|
183
|
+
viewQueriesOnChannel(app_rid).filter(function(q) {
|
|
184
|
+
navVisible(q{"view"})
|
|
185
|
+
}).head()
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
fallbackWhenNoNavViews = function(multiView) {
|
|
189
|
+
not multiView => "/" | "/"
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
fallbackPathForApp = function(app_rid, multiView) {
|
|
193
|
+
nav = firstNavViewQuery(app_rid)
|
|
194
|
+
nav.isnull() => fallbackWhenNoNavViews(multiView) |
|
|
195
|
+
pageRoute(nav{"view"}, nav{"name"}, multiView)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
multiViewForApp = function(app_rid) {
|
|
199
|
+
viewQueriesOnChannel(app_rid).length() > 1
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
appRulesetName = function(app_rid) {
|
|
203
|
+
wrangler:rulesetMeta(app_rid).isnull() => app_rid |
|
|
204
|
+
wrangler:rulesetMeta(app_rid){"name"} || app_rid
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
indexHtml = function(app_rid) {
|
|
208
|
+
"<html lang=\"en\"><head><meta charset=\"UTF-8\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" /><script>window.__PUBLIC_PATH=\"/ui/" +
|
|
209
|
+
meta:eci + "/" + app_rid + "\";window.__PICO_VIEW_ECI=\"" + meta:eci +
|
|
210
|
+
"\";window.__PICO_XMLUI_SCRIPT=\"" + xmluiRuntimePath() +
|
|
211
|
+
"\";window.__XMLUI_FALLBACK_PATH=\"" +
|
|
212
|
+
escapeAttr(fallbackPathForApp(app_rid, multiViewForApp(app_rid))) +
|
|
213
|
+
"\";window.__PICO_VIEW_USE_HASH_ROUTING=\"true\";</script><base href=\"/ui/" +
|
|
214
|
+
meta:eci + "/" + app_rid +
|
|
215
|
+
"/\" /><script src=\"/xmlui/pico-view-boot.js?v=" + xmluiRuntimeVersion +
|
|
216
|
+
"-pico2\"></script></head><body></body></html>"
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
launcherTitle = function(rid) {
|
|
220
|
+
wrangler:rulesetMeta(rid).isnull() => rid |
|
|
221
|
+
wrangler:rulesetMeta(rid){"name"} || rid
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
launcherHtml = function() {
|
|
225
|
+
"<html><body><ul>" +
|
|
226
|
+
launcherRids().map(function(rid) {
|
|
227
|
+
"<li><a href=\"/ui/" + meta:eci + "/" + rid + "\">" +
|
|
228
|
+
escape(launcherTitle(rid)) + "</a></li>"
|
|
229
|
+
}).join("") +
|
|
230
|
+
"</ul></body></html>"
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
navLinksForApp = function(app_rid, multiView) {
|
|
234
|
+
viewQueriesOnChannel(app_rid).filter(function(q) {
|
|
235
|
+
navVisible(q{"view"})
|
|
236
|
+
}).map(function(q) {
|
|
237
|
+
"<NavLink label=\"" + escapeAttr(q{"view"}{"title"}) + "\" to=\"" +
|
|
238
|
+
escapeAttr(pageRoute(q{"view"}, q{"name"}, multiView)) + "\" />"
|
|
239
|
+
}).join("")
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
pagesForApp = function(app_rid, multiView) {
|
|
243
|
+
viewQueriesOnChannel(app_rid).map(function(q) {
|
|
244
|
+
"<Page url=\"" + escapeAttr(pageRoute(q{"view"}, q{"name"}, multiView)) +
|
|
245
|
+
"\"><" + viewComponentName(q{"name"}) + " /></Page>"
|
|
246
|
+
}).join("")
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
navPanelForApp = function(app_rid, multiView) {
|
|
250
|
+
not multiView => "" |
|
|
251
|
+
navLinksForApp(app_rid, multiView) == "" => "" |
|
|
252
|
+
"<NavPanel>" + navLinksForApp(app_rid, multiView) + "</NavPanel>"
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// XMLUI defaults: layout condensed-sticky, scrollWholePage true. That combo
|
|
256
|
+
// mis-measures header height in WebKit (Safari) and can hide page content.
|
|
257
|
+
shellAppAttrs = function() {
|
|
258
|
+
" layout=\"vertical-sticky\" scrollWholePage=\"false\""
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
mainXmlui = function(app_rid) {
|
|
262
|
+
viewQueriesOnChannel(app_rid).length() == 0 => null |
|
|
263
|
+
"<App name=\"" + escapeAttr(appRulesetName(app_rid)) + "\"" +
|
|
264
|
+
shellAppAttrs() + ">" +
|
|
265
|
+
navPanelForApp(app_rid, multiViewForApp(app_rid)) +
|
|
266
|
+
"<Pages fallbackPath=\"" +
|
|
267
|
+
escapeAttr(fallbackPathForApp(app_rid, multiViewForApp(app_rid))) +
|
|
268
|
+
"\">" +
|
|
269
|
+
pagesForApp(app_rid, multiViewForApp(app_rid)) +
|
|
270
|
+
"</Pages></App>"
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
configJson = function(app_rid) {
|
|
274
|
+
{
|
|
275
|
+
"name": appRulesetName(app_rid),
|
|
276
|
+
"appGlobals": {
|
|
277
|
+
"eci": meta:eci,
|
|
278
|
+
"appRid": app_rid,
|
|
279
|
+
"picoName": wrangler:name(),
|
|
280
|
+
"useHashBasedRouting": true
|
|
281
|
+
},
|
|
282
|
+
"xmluiConfig": { "useHashBasedRouting": true }
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
file = function(rid, path) {
|
|
287
|
+
rid == "" => launcherHtml() |
|
|
288
|
+
path.defaultsTo("index.html") == "index.html" => indexHtml(rid) |
|
|
289
|
+
path.defaultsTo("index.html") == "Main.xmlui" => mainXmlui(rid) |
|
|
290
|
+
path.defaultsTo("index.html") == "config.json" => configJson(rid) |
|
|
291
|
+
null
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pico-engine",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "An implementation of the pico-engine targeting node.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -65,7 +65,9 @@
|
|
|
65
65
|
"test:relationship-self": "ava reset-cache && ava --serial ./test/relationshipSelf.ts --timeout=2m",
|
|
66
66
|
"test:relationship-lifecycle": "ava reset-cache && ava --serial ./test/relationshipLifecycle.ts --timeout=2m",
|
|
67
67
|
"test:epic9": "ava reset-cache && ava --serial ./test/epic9Matrix.ts --timeout=3m",
|
|
68
|
-
"test:peer-did4": "ava reset-cache && ava --serial ./test/peerDid4.ts --timeout=2m"
|
|
68
|
+
"test:peer-did4": "ava reset-cache && ava --serial ./test/peerDid4.ts --timeout=2m",
|
|
69
|
+
"test:views": "ava reset-cache && ava --serial ./test/xmluiSpike.ts ./test/xmluiRoutes.ts ./test/xmluiLauncher.ts ./test/xmluiConfig.ts ./test/xmluiViewSchema.ts ./test/xmluiViewPolicy.ts ./test/xmluiViewsOAuth.ts ./test/xmluiS2Demos.ts --timeout=2m",
|
|
70
|
+
"vendor:xmlui": "node scripts/copy-xmlui-runtime.mjs"
|
|
69
71
|
},
|
|
70
72
|
"dependencies": {
|
|
71
73
|
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
@@ -90,13 +92,13 @@
|
|
|
90
92
|
"express": "^4.16.4",
|
|
91
93
|
"helmet": "^7.1.0",
|
|
92
94
|
"home-dir": "^1.0.0",
|
|
93
|
-
"krl-compiler": "^1.6.
|
|
95
|
+
"krl-compiler": "^1.6.1",
|
|
94
96
|
"krl-stdlib": "^1.6.0",
|
|
95
97
|
"level-json-coerce-null": "^1.0.1",
|
|
96
98
|
"lodash": "^4.17.11",
|
|
97
99
|
"make-dir": "^4.0.0",
|
|
98
100
|
"minimist": "^1.2.5",
|
|
99
|
-
"pico-engine-core": "^1.
|
|
101
|
+
"pico-engine-core": "^1.9.0",
|
|
100
102
|
"pico-framework": "^0.8.2",
|
|
101
103
|
"rotating-file-stream": "^1.4.1",
|
|
102
104
|
"zod": "^3.25.76"
|
|
@@ -111,7 +113,8 @@
|
|
|
111
113
|
"onchange": "^7.1.0",
|
|
112
114
|
"scriptsp": "^1.1.1",
|
|
113
115
|
"ts-node": "^10.4.0",
|
|
114
|
-
"typescript": "^5.2.2"
|
|
116
|
+
"typescript": "^5.2.2",
|
|
117
|
+
"xmlui": "^0.12.7"
|
|
115
118
|
},
|
|
116
119
|
"ava": {
|
|
117
120
|
"extensions": [
|
|
@@ -127,5 +130,5 @@
|
|
|
127
130
|
"!test/helpers/**/*"
|
|
128
131
|
]
|
|
129
132
|
},
|
|
130
|
-
"gitHead": "
|
|
133
|
+
"gitHead": "416c55ae5637c9d83ca14d40bc76a1ccbfa1d657"
|
|
131
134
|
}
|
package/public/.DS_Store
ADDED
|
Binary file
|