pico-engine 1.6.4 → 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 +16 -9
- package/dist/RulesetRegistryLoaderFs.js +60 -6
- package/dist/auth/cookies.js +32 -0
- package/dist/auth/index.js +6 -1
- package/dist/channelIdentityPolicy.js +22 -0
- package/dist/cli.js +106 -69
- package/dist/engineConfig.js +291 -0
- package/dist/identity/IdentityService.js +90 -0
- package/dist/identity/crossPico.js +24 -8
- package/dist/identity/didoModule.js +80 -18
- package/dist/identity/establishSubscription.js +2 -2
- package/dist/identity/identityPortable.js +92 -0
- package/dist/identity/index.js +10 -1
- package/dist/identity/localPeerReconcile.js +65 -0
- package/dist/identity/peerDid4.js +175 -0
- package/dist/identity/peerDid4Create.js +90 -0
- package/dist/identity/portableExportPrepare.js +196 -0
- package/dist/identity/portableMove.js +87 -0
- package/dist/identity/skyIntro.js +6 -3
- package/dist/identity/skyProtocol.js +26 -1
- package/dist/identity/skyRotation.js +121 -0
- package/dist/identity/store.js +5 -1
- package/dist/identity/subscriptionEntSync.js +72 -0
- package/dist/identity/veramoDidComm.js +41 -2
- package/dist/identity/webvh.js +4 -2
- package/dist/identity/webvhRelocation.js +115 -0
- package/dist/index.js +84 -27
- package/dist/logging.js +156 -16
- package/dist/oauth/OAuthService.js +6 -2
- package/dist/policyConfigFromJson.js +112 -0
- package/dist/runMcp.js +27 -0
- package/dist/server.js +261 -24
- package/dist/stageKrl.js +26 -0
- package/dist/subtreeWrangler.js +180 -0
- package/dist/uiChannelPolicies.js +15 -0
- package/dist/xmluiRuntime.js +68 -0
- package/krl/io.picolabs.oauth.krl +41 -2
- package/krl/io.picolabs.pds.krl +131 -10
- package/krl/io.picolabs.pico-engine-ui.krl +217 -94
- package/krl/io.picolabs.portable_subtree.krl +97 -0
- package/krl/io.picolabs.subscription.krl +180 -72
- package/krl/io.picolabs.wrangler.krl +313 -57
- package/krl/io.picolabs.xmlui.krl +295 -0
- package/mcp/devResources.js +118 -0
- package/mcp/devTools.js +351 -0
- package/mcp/engineClient.js +133 -0
- package/mcp/meshHttp.js +137 -0
- package/mcp/meshTools.js +189 -0
- package/mcp/runStdio.js +34 -0
- package/mcp/schemaToZod.js +56 -0
- package/package.json +24 -9
- package/public/.DS_Store +0 -0
- package/public/docs/_sidebar.md +3 -1
- package/public/docs/llms-full.txt +630 -0
- package/public/docs/llms.txt +38 -0
- package/public/docs/openapi.yaml +78 -0
- package/public/docs/pico-engine.md +239 -4
- package/public/docs/pico-overview.md +117 -0
- package/public/docs/pico-views-xmlui.md +5 -0
- package/public/docs/pico-views.md +140 -0
- package/public/docs/pico.md +3 -1
- package/public/docs/rulesets/README.md +26 -0
- package/public/docs/rulesets/io.picolabs.oauth.md +71 -0
- package/public/docs/rulesets/io.picolabs.pds.md +327 -0
- package/public/docs/rulesets/io.picolabs.pico-engine-ui.md +65 -0
- package/public/docs/rulesets/io.picolabs.portable_subtree.md +94 -0
- package/public/docs/rulesets/io.picolabs.subscription.md +398 -0
- package/public/docs/rulesets/io.picolabs.wrangler.md +471 -0
- package/public/pico-engine-ui.css +1 -1
- package/public/pico-engine-ui.js +27 -23
- package/public/xmlui/0.12.7.js +419 -0
- package/public/xmlui/pico-view-boot.js +153 -0
- package/src/RulesetRegistryLoaderFs.ts +66 -7
- package/src/auth/cookies.ts +34 -0
- package/src/auth/index.ts +7 -0
- package/src/channelIdentityPolicy.ts +29 -0
- package/src/cli.ts +70 -37
- package/src/engineConfig.ts +363 -0
- package/src/identity/IdentityService.ts +189 -1
- package/src/identity/crossPico.ts +57 -8
- package/src/identity/didoModule.ts +140 -23
- package/src/identity/establishSubscription.ts +2 -2
- package/src/identity/identityPortable.ts +153 -0
- package/src/identity/index.ts +14 -0
- package/src/identity/localPeerReconcile.ts +97 -0
- package/src/identity/peerDid4.ts +197 -0
- package/src/identity/peerDid4Create.ts +121 -0
- package/src/identity/portableExportPrepare.ts +302 -0
- package/src/identity/portableMove.ts +193 -0
- package/src/identity/skyIntro.ts +11 -11
- package/src/identity/skyProtocol.ts +46 -0
- package/src/identity/skyRotation.ts +211 -0
- package/src/identity/store.ts +5 -1
- package/src/identity/subscriptionEntSync.ts +97 -0
- package/src/identity/veramoDidComm.ts +52 -2
- package/src/identity/webvh.ts +4 -4
- package/src/identity/webvhRelocation.ts +167 -0
- package/src/index.ts +123 -31
- package/src/logging.ts +173 -18
- package/src/oauth/OAuthService.ts +11 -3
- package/src/policyConfigFromJson.ts +131 -0
- package/src/runMcp.ts +30 -0
- package/src/server.ts +328 -27
- package/src/stageKrl.ts +26 -0
- package/src/subtreeWrangler.ts +278 -0
- package/src/uiChannelPolicies.ts +15 -0
- package/src/xmluiRuntime.ts +66 -0
- package/krl/io.picolabs.did-o.krl +0 -349
package/src/stageKrl.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import * as os from "os";
|
|
4
|
+
import { toFileUrl } from "./utils/toFileUrl";
|
|
5
|
+
|
|
6
|
+
const STAGE_DIR = path.join(os.tmpdir(), "pico-engine-staged-krl");
|
|
7
|
+
|
|
8
|
+
/** Write KRL source to a temp file and return a file:// URL the registry can load. */
|
|
9
|
+
export function stageKrlContent(content: string, filename: string): string {
|
|
10
|
+
if (typeof content !== "string" || !/^ruleset\s+/m.test(content)) {
|
|
11
|
+
throw new Error("File must contain a KRL ruleset (starting with ruleset …)");
|
|
12
|
+
}
|
|
13
|
+
let base = path.basename(filename || "staged.krl");
|
|
14
|
+
if (!base.toLowerCase().endsWith(".krl")) {
|
|
15
|
+
base = base + ".krl";
|
|
16
|
+
}
|
|
17
|
+
base = base.replace(/[^\w.-]+/g, "_");
|
|
18
|
+
if (base === ".krl" || base === "") {
|
|
19
|
+
base = "staged.krl";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
fs.mkdirSync(STAGE_DIR, { recursive: true });
|
|
23
|
+
const dest = path.join(STAGE_DIR, `${Date.now()}-${base}`);
|
|
24
|
+
fs.writeFileSync(dest, content, { encoding: "utf8", flag: "wx" });
|
|
25
|
+
return toFileUrl(dest);
|
|
26
|
+
}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subtree import child creation via wrangler (engine layer — above ctx).
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
allowsEventPolicy,
|
|
7
|
+
ChannelReadOnly,
|
|
8
|
+
Pico,
|
|
9
|
+
PicoEvent,
|
|
10
|
+
PicoFramework,
|
|
11
|
+
} from "pico-framework";
|
|
12
|
+
import type {
|
|
13
|
+
CreateImportChildOptions,
|
|
14
|
+
RulesetRegistry,
|
|
15
|
+
RulesetStateServices,
|
|
16
|
+
} from "pico-engine-core";
|
|
17
|
+
|
|
18
|
+
const WRANGLER_RID = "io.picolabs.wrangler";
|
|
19
|
+
const ENGINE_UI_RID = "io.picolabs.pico-engine-ui";
|
|
20
|
+
const SUBSCRIPTION_RID = "io.picolabs.subscription";
|
|
21
|
+
const PDS_RID = "io.picolabs.pds";
|
|
22
|
+
|
|
23
|
+
function isUiChannel(c: ChannelReadOnly): boolean {
|
|
24
|
+
return [...c.tags].sort().join(",") === "engine,ui";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function nonFamilyChannels(pico: Pico): ChannelReadOnly[] {
|
|
28
|
+
return pico.toReadOnly().channels.filter((c) => !c.familyChannelPicoID);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function channelAllowsEvent(
|
|
32
|
+
c: ChannelReadOnly,
|
|
33
|
+
event: Pick<PicoEvent, "domain" | "name">
|
|
34
|
+
): boolean {
|
|
35
|
+
return allowsEventPolicy(c.eventPolicy, event);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Pick a channel that may deliver a specific wrangler bootstrap event. */
|
|
39
|
+
function pickEventEci(
|
|
40
|
+
pico: Pico,
|
|
41
|
+
event: Pick<PicoEvent, "domain" | "name">
|
|
42
|
+
): string {
|
|
43
|
+
const channels = nonFamilyChannels(pico);
|
|
44
|
+
if (channels.length === 0) {
|
|
45
|
+
throw new Error(
|
|
46
|
+
`Pico ${pico.id} has no non-family channels for wrangler events`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
const permitted = channels.filter((c) => channelAllowsEvent(c, event));
|
|
50
|
+
if (permitted.length > 0) {
|
|
51
|
+
const ui = permitted.find((c) => isUiChannel(c));
|
|
52
|
+
return (ui ?? permitted[0]).id;
|
|
53
|
+
}
|
|
54
|
+
throw new Error(
|
|
55
|
+
`Pico ${pico.id} has no channel that allows ${event.domain}:${event.name}`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Prefer caller's channel when it allows the event; otherwise pick one that does.
|
|
61
|
+
* HTTP/UI import passes the UI ECI — skip it when policy blocks wrangler bootstrap.
|
|
62
|
+
*/
|
|
63
|
+
function resolveWranglerChannelEci(
|
|
64
|
+
pico: Pico,
|
|
65
|
+
event: Pick<PicoEvent, "domain" | "name">,
|
|
66
|
+
preferred?: string
|
|
67
|
+
): string {
|
|
68
|
+
if (preferred) {
|
|
69
|
+
const ch = nonFamilyChannels(pico).find((c) => c.id === preferred);
|
|
70
|
+
if (ch && channelAllowsEvent(ch, event)) {
|
|
71
|
+
return preferred;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return pickEventEci(pico, event);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async function rulesetFromParent(
|
|
78
|
+
parent: Pico,
|
|
79
|
+
rid: string,
|
|
80
|
+
rsRegistry: RulesetRegistry
|
|
81
|
+
) {
|
|
82
|
+
const config = parent.rulesets[rid]?.config;
|
|
83
|
+
if (!config?.url) {
|
|
84
|
+
throw new Error(
|
|
85
|
+
`Parent pico ${parent.id} does not have ${rid} installed (required for wrangler import bootstrap)`
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
const loaded = await rsRegistry.load(config.url);
|
|
89
|
+
return { rs: loaded.ruleset, config };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Same bootstrap as wrangler bootstrapNewChild, without blocking the parent's event queue. */
|
|
93
|
+
async function bootstrapImportChildSync(
|
|
94
|
+
pf: PicoFramework,
|
|
95
|
+
parent: Pico,
|
|
96
|
+
name: string,
|
|
97
|
+
rsRegistry: RulesetRegistry,
|
|
98
|
+
options?: CreateImportChildOptions
|
|
99
|
+
): Promise<{ familyEci: string; child: Pico }> {
|
|
100
|
+
const ui = await rulesetFromParent(parent, ENGINE_UI_RID, rsRegistry);
|
|
101
|
+
const wrangler = await rulesetFromParent(parent, WRANGLER_RID, rsRegistry);
|
|
102
|
+
const familyEci = await parent.newPico({
|
|
103
|
+
rulesets: [ui, wrangler],
|
|
104
|
+
});
|
|
105
|
+
const child = pf.getPico(familyEci);
|
|
106
|
+
if (!child) {
|
|
107
|
+
throw new Error(`Failed to resolve child for family ECI ${familyEci}`);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const parentUi = parent.toReadOnly().channels.find(
|
|
111
|
+
(c) => [...c.tags].sort().join(",") === "engine,ui"
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
await pf.eventWait(
|
|
115
|
+
{
|
|
116
|
+
eci: familyEci,
|
|
117
|
+
domain: "wrangler",
|
|
118
|
+
name: "pico_created",
|
|
119
|
+
data: { attrs: { name: name || "imported" } },
|
|
120
|
+
time: Date.now(),
|
|
121
|
+
},
|
|
122
|
+
parent.id
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
await waitForWranglerBootstrapRulesets(
|
|
126
|
+
pf,
|
|
127
|
+
parent.id,
|
|
128
|
+
familyEci,
|
|
129
|
+
child
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
const uiEci = await pf.eventQuery(
|
|
133
|
+
{
|
|
134
|
+
eci: familyEci,
|
|
135
|
+
domain: "engine_ui",
|
|
136
|
+
name: "setup",
|
|
137
|
+
data: { attrs: {} },
|
|
138
|
+
time: Date.now(),
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
eci: familyEci,
|
|
142
|
+
rid: ENGINE_UI_RID,
|
|
143
|
+
name: "uiECI",
|
|
144
|
+
args: {},
|
|
145
|
+
},
|
|
146
|
+
parent.id
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
await pf.event({
|
|
150
|
+
eci: uiEci,
|
|
151
|
+
domain: "engine_ui",
|
|
152
|
+
name: "box",
|
|
153
|
+
data: {
|
|
154
|
+
attrs: {
|
|
155
|
+
name: name || "imported",
|
|
156
|
+
parentUiEci: parentUi?.id,
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
time: Date.now(),
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
const newChildCreated = {
|
|
163
|
+
domain: "wrangler" as const,
|
|
164
|
+
name: "new_child_created" as const,
|
|
165
|
+
};
|
|
166
|
+
const parentEci = resolveWranglerChannelEci(
|
|
167
|
+
parent,
|
|
168
|
+
newChildCreated,
|
|
169
|
+
options?.channelEci
|
|
170
|
+
);
|
|
171
|
+
await pf.event({
|
|
172
|
+
eci: parentEci,
|
|
173
|
+
domain: newChildCreated.domain,
|
|
174
|
+
name: newChildCreated.name,
|
|
175
|
+
data: {
|
|
176
|
+
attrs: {
|
|
177
|
+
name: name || "imported",
|
|
178
|
+
eci: familyEci,
|
|
179
|
+
uiEci,
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
time: Date.now(),
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
return { familyEci, child };
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function parentIsHandlingEvent(parent: Pico): boolean {
|
|
189
|
+
return parent.getCurrentTxn()?.kind === "event";
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** Wait for pico_created's queued install_ruleset_request (pds + subscription). */
|
|
193
|
+
async function waitForWranglerBootstrapRulesets(
|
|
194
|
+
pf: PicoFramework,
|
|
195
|
+
parentPicoId: string,
|
|
196
|
+
familyEci: string,
|
|
197
|
+
child: Pico,
|
|
198
|
+
timeoutMs = 20000
|
|
199
|
+
): Promise<void> {
|
|
200
|
+
const need = [SUBSCRIPTION_RID, PDS_RID];
|
|
201
|
+
const deadline = Date.now() + timeoutMs;
|
|
202
|
+
while (Date.now() < deadline) {
|
|
203
|
+
if (need.every((rid) => child.rulesets[rid])) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
await pf
|
|
207
|
+
.query(
|
|
208
|
+
{
|
|
209
|
+
eci: familyEci,
|
|
210
|
+
rid: WRANGLER_RID,
|
|
211
|
+
name: "id",
|
|
212
|
+
args: {},
|
|
213
|
+
},
|
|
214
|
+
parentPicoId
|
|
215
|
+
)
|
|
216
|
+
.catch(() => undefined);
|
|
217
|
+
await new Promise((resolve) => setTimeout(resolve, 15));
|
|
218
|
+
}
|
|
219
|
+
const missing = need.filter((rid) => !child.rulesets[rid]);
|
|
220
|
+
throw new Error(
|
|
221
|
+
`Import child wrangler bootstrap missing rulesets: ${missing.join(", ")}`
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Create an import child through wrangler (sync bootstrap when parent queue is busy). */
|
|
226
|
+
export async function createImportChildViaWrangler(
|
|
227
|
+
pf: PicoFramework,
|
|
228
|
+
parent: Pico,
|
|
229
|
+
name: string,
|
|
230
|
+
rsRegistry: RulesetRegistry,
|
|
231
|
+
options?: CreateImportChildOptions
|
|
232
|
+
): Promise<{ familyEci: string; child: Pico }> {
|
|
233
|
+
if (parentIsHandlingEvent(parent)) {
|
|
234
|
+
return bootstrapImportChildSync(pf, parent, name, rsRegistry, options);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const newChildRequest = {
|
|
238
|
+
domain: "wrangler" as const,
|
|
239
|
+
name: "new_child_request" as const,
|
|
240
|
+
};
|
|
241
|
+
const parentEci = resolveWranglerChannelEci(
|
|
242
|
+
parent,
|
|
243
|
+
newChildRequest,
|
|
244
|
+
options?.channelEci
|
|
245
|
+
);
|
|
246
|
+
const childCountBefore = parent.toReadOnly().children.length;
|
|
247
|
+
|
|
248
|
+
await pf.eventWait({
|
|
249
|
+
eci: parentEci,
|
|
250
|
+
domain: newChildRequest.domain,
|
|
251
|
+
name: newChildRequest.name,
|
|
252
|
+
data: { attrs: { name: name || "imported" } },
|
|
253
|
+
time: Date.now(),
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
const children = parent.toReadOnly().children;
|
|
257
|
+
if (children.length <= childCountBefore) {
|
|
258
|
+
throw new Error(
|
|
259
|
+
"wrangler new_child_request did not create a child (is io.picolabs.wrangler installed on the parent?)"
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
const familyEci = children[children.length - 1];
|
|
263
|
+
const child = pf.getPico(familyEci);
|
|
264
|
+
if (!child) {
|
|
265
|
+
throw new Error(`Failed to resolve child for family ECI ${familyEci}`);
|
|
266
|
+
}
|
|
267
|
+
return { familyEci, child };
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** Wrangler-backed child creation wired into ctx subtree import. */
|
|
271
|
+
export function wranglerSubtreeImportServices(
|
|
272
|
+
rsRegistry: RulesetRegistry
|
|
273
|
+
): Pick<RulesetStateServices, "createImportChild"> {
|
|
274
|
+
return {
|
|
275
|
+
createImportChild: (pf, parent, name, opts) =>
|
|
276
|
+
createImportChildViaWrangler(pf, parent, name, rsRegistry, opts),
|
|
277
|
+
};
|
|
278
|
+
}
|
package/src/uiChannelPolicies.ts
CHANGED
|
@@ -14,7 +14,12 @@ export const UI_CHANNEL_EVENT_POLICY: EventPolicy = {
|
|
|
14
14
|
{ domain: "engine_ui", name: "del_channel" },
|
|
15
15
|
{ domain: "engine_ui", name: "update_channel" },
|
|
16
16
|
{ domain: "engine_ui", name: "testing_eci" },
|
|
17
|
+
{ domain: "engine_ui", name: "testing_history_record" },
|
|
18
|
+
{ domain: "engine_ui", name: "testing_history_clear" },
|
|
19
|
+
{ domain: "engine_ui", name: "testing_saved_upsert" },
|
|
20
|
+
{ domain: "engine_ui", name: "testing_saved_delete" },
|
|
17
21
|
{ domain: "engine", name: "started" },
|
|
22
|
+
{ domain: "engine", name: "ruleset_set_changed" },
|
|
18
23
|
{ domain: "wrangler", name: "subscription" },
|
|
19
24
|
{ domain: "wrangler", name: "relationship" },
|
|
20
25
|
{ domain: "wrangler", name: "pending_subscription_approval" },
|
|
@@ -28,6 +33,11 @@ export const UI_CHANNEL_EVENT_POLICY: EventPolicy = {
|
|
|
28
33
|
{ domain: "wrangler", name: "set_public_intro" },
|
|
29
34
|
{ domain: "wrangler", name: "send_event_on_subs" },
|
|
30
35
|
{ domain: "wrangler", name: "send_event_on_relationships" },
|
|
36
|
+
{ domain: "wrangler", name: "child_deleted" },
|
|
37
|
+
{ domain: "wrangler", name: "new_child_request" },
|
|
38
|
+
{ domain: "wrangler", name: "new_child_created" },
|
|
39
|
+
{ domain: "wrangler", name: "install_ruleset_request" },
|
|
40
|
+
{ domain: "wrangler", name: "new_channel_request" },
|
|
31
41
|
],
|
|
32
42
|
deny: [],
|
|
33
43
|
};
|
|
@@ -36,11 +46,16 @@ export const UI_CHANNEL_EVENT_POLICY: EventPolicy = {
|
|
|
36
46
|
export const UI_CHANNEL_QUERY_POLICY: QueryPolicy = {
|
|
37
47
|
allow: [
|
|
38
48
|
{ rid: "*", name: "__testing" },
|
|
49
|
+
{ rid: "*", name: "__consoleEval" },
|
|
50
|
+
{ rid: "io.picolabs.wrangler", name: "rulesetSchema" },
|
|
51
|
+
{ rid: "io.picolabs.wrangler", name: "picoSchema" },
|
|
39
52
|
{ rid: "io.picolabs.pico-engine-ui", name: "uiECI" },
|
|
40
53
|
{ rid: "io.picolabs.pico-engine-ui", name: "box" },
|
|
41
54
|
{ rid: "io.picolabs.pico-engine-ui", name: "pico" },
|
|
42
55
|
{ rid: "io.picolabs.pico-engine-ui", name: "logs" },
|
|
43
56
|
{ rid: "io.picolabs.pico-engine-ui", name: "testingECI" },
|
|
57
|
+
{ rid: "io.picolabs.pico-engine-ui", name: "testingHistory" },
|
|
58
|
+
{ rid: "io.picolabs.pico-engine-ui", name: "testingSaved" },
|
|
44
59
|
{ rid: "io.picolabs.pico-engine-ui", name: "name" },
|
|
45
60
|
{ rid: "io.picolabs.subscription", name: "established" },
|
|
46
61
|
{ rid: "io.picolabs.subscription", name: "inbound" },
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/** Pinned XMLUI standalone runtime shipped under `public/xmlui/`. */
|
|
2
|
+
export const XMLUI_RUNTIME_VERSION = "0.12.7";
|
|
3
|
+
|
|
4
|
+
export const XMLUI_RUNTIME_PUBLIC_PATH = `/xmlui/${XMLUI_RUNTIME_VERSION}.js`;
|
|
5
|
+
|
|
6
|
+
/** XMLUI standalone always requests Main.xmlui.xs (and per-component .xmlui.xs). */
|
|
7
|
+
export const XMLUI_EMPTY_CODE_BEHIND = "var __pico_xmlui_codebehind = 0;\n";
|
|
8
|
+
|
|
9
|
+
export function isXmluiCodeBehindPath(relPath: string): boolean {
|
|
10
|
+
if (relPath === "Main.xmlui.xs") return true;
|
|
11
|
+
return /^components\/.+\.xmlui\.xs$/i.test(relPath);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Map a shared function name to the XMLUI component file name (Hello, ColorView, …). */
|
|
15
|
+
export function viewComponentFileName(fnName: string): string {
|
|
16
|
+
if (!fnName) return fnName;
|
|
17
|
+
return fnName.charAt(0).toUpperCase() + fnName.slice(1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function parseComponentXmluiPath(relPath: string): string | null {
|
|
21
|
+
const m = /^components\/(.+)\.xmlui$/i.exec(relPath);
|
|
22
|
+
return m ? m[1] : null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Client route segment (e.g. list, contact/abc) — not a static XMLUI asset. */
|
|
26
|
+
export function isXmluiSpaClientRoute(relPath: string): boolean {
|
|
27
|
+
const rel = relPath.replace(/^\/+/, "");
|
|
28
|
+
if (!rel || rel === "index.html") return false;
|
|
29
|
+
if (rel === "Main.xmlui" || rel === "config.json") return false;
|
|
30
|
+
if (isXmluiCodeBehindPath(rel)) return false;
|
|
31
|
+
if (parseComponentXmluiPath(rel)) return false;
|
|
32
|
+
const lastSegment = rel.split("/").pop() || "";
|
|
33
|
+
if (lastSegment.includes(".")) return false;
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface ChannelSchemaQuery {
|
|
38
|
+
rid: string;
|
|
39
|
+
name: string;
|
|
40
|
+
view?: unknown;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function viewQueryNameForComponent(
|
|
44
|
+
queries: ChannelSchemaQuery[] | undefined,
|
|
45
|
+
appRid: string,
|
|
46
|
+
componentName: string
|
|
47
|
+
): string | null {
|
|
48
|
+
if (!queries?.length) return null;
|
|
49
|
+
const hit = queries.find(
|
|
50
|
+
(q) =>
|
|
51
|
+
q.rid === appRid &&
|
|
52
|
+
q.view != null &&
|
|
53
|
+
viewComponentFileName(q.name) === componentName
|
|
54
|
+
);
|
|
55
|
+
return hit?.name ?? null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function contentTypeForUiPath(filePath: string): string {
|
|
59
|
+
const lower = filePath.toLowerCase();
|
|
60
|
+
if (lower.endsWith(".html")) return "text/html; charset=utf-8";
|
|
61
|
+
if (lower.endsWith(".xmlui")) return "application/xml; charset=utf-8";
|
|
62
|
+
if (lower.endsWith(".xs")) return "text/plain; charset=utf-8";
|
|
63
|
+
if (lower.endsWith(".json")) return "application/json; charset=utf-8";
|
|
64
|
+
if (lower.endsWith(".css")) return "text/css; charset=utf-8";
|
|
65
|
+
return "text/plain; charset=utf-8";
|
|
66
|
+
}
|