@xmachines/play-solid 1.0.0-beta.32 → 1.0.0-beta.34
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 +107 -35
- package/dist/ActorProvider.js +91 -0
- package/dist/ActorProvider.js.map +1 -0
- package/dist/PlayRenderer.js +11 -61
- package/dist/PlayRenderer.js.map +1 -1
- package/dist/PlayUIProvider.js +35 -0
- package/dist/PlayUIProvider.js.map +1 -0
- package/dist/index.js +6 -4
- package/dist/node_modules/@json-render/core/dist/index.js +142 -49
- package/dist/node_modules/@json-render/core/dist/index.js.map +1 -1
- package/dist/node_modules/@json-render/solid/dist/index.js +321 -106
- package/dist/node_modules/@json-render/solid/dist/index.js.map +1 -1
- package/dist/useActor.js +4 -5
- package/dist/useActor.js.map +1 -1
- package/package.json +5 -4
|
@@ -185,41 +185,41 @@ function ue() {
|
|
|
185
185
|
return F += 1, `${Date.now()}-${F}`;
|
|
186
186
|
}
|
|
187
187
|
var de = 0, I = /* @__PURE__ */ new Set();
|
|
188
|
-
function
|
|
188
|
+
function fe() {
|
|
189
189
|
return de > 0;
|
|
190
190
|
}
|
|
191
|
-
function
|
|
191
|
+
function L(e) {
|
|
192
192
|
return I.add(e), () => {
|
|
193
193
|
I.delete(e);
|
|
194
194
|
};
|
|
195
195
|
}
|
|
196
|
-
var
|
|
196
|
+
var R = s({
|
|
197
197
|
title: l(),
|
|
198
198
|
message: l(),
|
|
199
199
|
confirmLabel: l().optional(),
|
|
200
200
|
cancelLabel: l().optional(),
|
|
201
201
|
variant: e(["default", "danger"]).optional()
|
|
202
|
-
}),
|
|
202
|
+
}), z = u([
|
|
203
203
|
s({ navigate: l() }),
|
|
204
204
|
s({ set: c(l(), d()) }),
|
|
205
205
|
s({ action: l() })
|
|
206
|
-
]),
|
|
206
|
+
]), B = u([s({ set: c(l(), d()) }), s({ action: l() })]);
|
|
207
207
|
s({
|
|
208
208
|
action: l(),
|
|
209
209
|
params: c(l(), f).optional(),
|
|
210
|
-
confirm:
|
|
211
|
-
onSuccess:
|
|
212
|
-
onError:
|
|
210
|
+
confirm: R.optional(),
|
|
211
|
+
onSuccess: z.optional(),
|
|
212
|
+
onError: B.optional(),
|
|
213
213
|
preventDefault: r().optional()
|
|
214
214
|
});
|
|
215
|
-
function
|
|
215
|
+
function V(e, t) {
|
|
216
216
|
let n = {};
|
|
217
217
|
if (e.params) for (let [r, i] of Object.entries(e.params)) n[r] = m(i, t);
|
|
218
218
|
let r = e.confirm;
|
|
219
219
|
return r &&= {
|
|
220
220
|
...r,
|
|
221
|
-
message:
|
|
222
|
-
title:
|
|
221
|
+
message: H(r.message, t),
|
|
222
|
+
title: H(r.title, t)
|
|
223
223
|
}, {
|
|
224
224
|
action: e.action,
|
|
225
225
|
params: n,
|
|
@@ -228,13 +228,13 @@ function H(e, t) {
|
|
|
228
228
|
onError: e.onError
|
|
229
229
|
};
|
|
230
230
|
}
|
|
231
|
-
function
|
|
231
|
+
function H(e, t) {
|
|
232
232
|
return e.replace(/\$\{([^}]+)\}/g, (e, n) => {
|
|
233
233
|
let r = m({ $state: n }, t);
|
|
234
234
|
return String(r ?? "");
|
|
235
235
|
});
|
|
236
236
|
}
|
|
237
|
-
async function
|
|
237
|
+
async function pe(e) {
|
|
238
238
|
let { action: t, handler: n, setState: r, navigate: i, executeAction: a } = e;
|
|
239
239
|
try {
|
|
240
240
|
if (await n(t.params), t.onSuccess) if ("navigate" in t.onSuccess && i) i(t.onSuccess.navigate);
|
|
@@ -259,11 +259,104 @@ s({
|
|
|
259
259
|
]).optional(),
|
|
260
260
|
enabled: v.optional()
|
|
261
261
|
});
|
|
262
|
-
var
|
|
263
|
-
|
|
264
|
-
|
|
262
|
+
var U = (e, t) => e === t?.other, me = {
|
|
263
|
+
required: (e) => e == null ? !1 : typeof e == "string" ? e.trim().length > 0 : Array.isArray(e) ? e.length > 0 : !0,
|
|
264
|
+
email: (e) => typeof e == "string" ? /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e) : !1,
|
|
265
|
+
minLength: (e, t) => {
|
|
266
|
+
if (typeof e != "string") return !1;
|
|
267
|
+
let n = t?.min;
|
|
268
|
+
return typeof n == "number" ? e.length >= n : !1;
|
|
269
|
+
},
|
|
270
|
+
maxLength: (e, t) => {
|
|
271
|
+
if (typeof e != "string") return !1;
|
|
272
|
+
let n = t?.max;
|
|
273
|
+
return typeof n == "number" ? e.length <= n : !1;
|
|
274
|
+
},
|
|
275
|
+
pattern: (e, t) => {
|
|
276
|
+
if (typeof e != "string") return !1;
|
|
277
|
+
let n = t?.pattern;
|
|
278
|
+
if (typeof n != "string") return !1;
|
|
279
|
+
try {
|
|
280
|
+
return new RegExp(n).test(e);
|
|
281
|
+
} catch {
|
|
282
|
+
return !1;
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
min: (e, t) => {
|
|
286
|
+
if (typeof e != "number") return !1;
|
|
287
|
+
let n = t?.min;
|
|
288
|
+
return typeof n == "number" ? e >= n : !1;
|
|
289
|
+
},
|
|
290
|
+
max: (e, t) => {
|
|
291
|
+
if (typeof e != "number") return !1;
|
|
292
|
+
let n = t?.max;
|
|
293
|
+
return typeof n == "number" ? e <= n : !1;
|
|
294
|
+
},
|
|
295
|
+
numeric: (e) => typeof e == "number" ? !isNaN(e) : typeof e == "string" ? !isNaN(parseFloat(e)) : !1,
|
|
296
|
+
url: (e) => {
|
|
297
|
+
if (typeof e != "string") return !1;
|
|
298
|
+
try {
|
|
299
|
+
return new URL(e), !0;
|
|
300
|
+
} catch {
|
|
301
|
+
return !1;
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
matches: U,
|
|
305
|
+
equalTo: U,
|
|
306
|
+
lessThan: (e, t) => {
|
|
307
|
+
let n = t?.other;
|
|
308
|
+
if (e == null || n == null || e === "" || n === "") return !1;
|
|
309
|
+
if (typeof e == "number" && typeof n == "number" || typeof e == "string" && typeof n == "string") return e < n;
|
|
310
|
+
let r = Number(e), i = Number(n);
|
|
311
|
+
return !isNaN(r) && !isNaN(i) ? r < i : !1;
|
|
312
|
+
},
|
|
313
|
+
greaterThan: (e, t) => {
|
|
314
|
+
let n = t?.other;
|
|
315
|
+
if (e == null || n == null || e === "" || n === "") return !1;
|
|
316
|
+
if (typeof e == "number" && typeof n == "number" || typeof e == "string" && typeof n == "string") return e > n;
|
|
317
|
+
let r = Number(e), i = Number(n);
|
|
318
|
+
return !isNaN(r) && !isNaN(i) ? r > i : !1;
|
|
319
|
+
},
|
|
320
|
+
requiredIf: (e, t) => t?.field ? e == null ? !1 : typeof e == "string" ? e.trim().length > 0 : Array.isArray(e) ? e.length > 0 : !0 : !0
|
|
321
|
+
};
|
|
322
|
+
function he(e, t) {
|
|
323
|
+
let { value: n, stateModel: r, customFunctions: i } = t, a = {};
|
|
324
|
+
if (e.args) for (let [t, n] of Object.entries(e.args)) a[t] = N(n, { stateModel: r });
|
|
325
|
+
let o = me[e.type] ?? i?.[e.type];
|
|
326
|
+
if (!o) return console.warn(`Unknown validation function: ${e.type}`), {
|
|
327
|
+
type: e.type,
|
|
328
|
+
valid: !0,
|
|
329
|
+
message: e.message
|
|
330
|
+
};
|
|
331
|
+
let s = o(n, a);
|
|
332
|
+
return {
|
|
333
|
+
type: e.type,
|
|
334
|
+
valid: s,
|
|
335
|
+
message: e.message
|
|
336
|
+
};
|
|
265
337
|
}
|
|
266
|
-
function
|
|
338
|
+
function ge(e, t) {
|
|
339
|
+
let n = [], r = [];
|
|
340
|
+
if (e.enabled && !E(e.enabled, { stateModel: t.stateModel })) return {
|
|
341
|
+
valid: !0,
|
|
342
|
+
errors: [],
|
|
343
|
+
checks: []
|
|
344
|
+
};
|
|
345
|
+
if (e.checks) for (let i of e.checks) {
|
|
346
|
+
let e = he(i, t);
|
|
347
|
+
n.push(e), e.valid || r.push(e.message);
|
|
348
|
+
}
|
|
349
|
+
return {
|
|
350
|
+
valid: r.length === 0,
|
|
351
|
+
errors: r,
|
|
352
|
+
checks: n
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
var _e = ["patch"];
|
|
356
|
+
function ve(e) {
|
|
357
|
+
return e?.modes?.length ? e.modes : _e;
|
|
358
|
+
}
|
|
359
|
+
function ye() {
|
|
267
360
|
return [
|
|
268
361
|
"PATCH MODE (RFC 6902 JSON Patch):",
|
|
269
362
|
"Output one JSON object per line. Each line is a patch operation.",
|
|
@@ -273,7 +366,7 @@ function he() {
|
|
|
273
366
|
"Only output patches for what needs to change."
|
|
274
367
|
].join("\n");
|
|
275
368
|
}
|
|
276
|
-
function
|
|
369
|
+
function be() {
|
|
277
370
|
return [
|
|
278
371
|
"MERGE MODE (RFC 7396 JSON Merge Patch):",
|
|
279
372
|
"Output a single JSON object on one line with __json_edit set to true.",
|
|
@@ -287,7 +380,7 @@ function ge() {
|
|
|
287
380
|
"{\"__json_edit\":true,\"elements\":{\"old-widget\":null}}"
|
|
288
381
|
].join("\n");
|
|
289
382
|
}
|
|
290
|
-
function
|
|
383
|
+
function xe() {
|
|
291
384
|
return [
|
|
292
385
|
"DIFF MODE (unified diff):",
|
|
293
386
|
"Output a unified diff inside a ```diff code fence.",
|
|
@@ -303,7 +396,7 @@ function _e() {
|
|
|
303
396
|
"```"
|
|
304
397
|
].join("\n");
|
|
305
398
|
}
|
|
306
|
-
function
|
|
399
|
+
function Se() {
|
|
307
400
|
return [
|
|
308
401
|
"PATCH MODE (RFC 6902 JSON Patch):",
|
|
309
402
|
"Output RFC 6902 JSON Patch lines inside a ```yaml-patch code fence.",
|
|
@@ -316,7 +409,7 @@ function ve() {
|
|
|
316
409
|
"```"
|
|
317
410
|
].join("\n");
|
|
318
411
|
}
|
|
319
|
-
function
|
|
412
|
+
function Ce() {
|
|
320
413
|
return [
|
|
321
414
|
"MERGE MODE (RFC 7396 JSON Merge Patch):",
|
|
322
415
|
"Output only the changed parts in a ```yaml-edit code fence.",
|
|
@@ -342,7 +435,7 @@ function ye() {
|
|
|
342
435
|
"```"
|
|
343
436
|
].join("\n");
|
|
344
437
|
}
|
|
345
|
-
function
|
|
438
|
+
function we() {
|
|
346
439
|
return [
|
|
347
440
|
"DIFF MODE (unified diff):",
|
|
348
441
|
"Output a unified diff inside a ```diff code fence.",
|
|
@@ -358,44 +451,44 @@ function be() {
|
|
|
358
451
|
"```"
|
|
359
452
|
].join("\n");
|
|
360
453
|
}
|
|
361
|
-
function
|
|
454
|
+
function Te(e) {
|
|
362
455
|
if (e.length === 1) return "";
|
|
363
456
|
let t = ["Choose the best edit strategy for the requested change:"];
|
|
364
457
|
return e.includes("patch") && t.push("- PATCH: best for precise, targeted single-field updates"), e.includes("merge") && t.push("- MERGE: best for structural changes (add/remove elements, reparent children, update multiple props at once)"), e.includes("diff") && t.push("- DIFF: best for small text-level changes when you can see the exact lines to change"), t.join("\n");
|
|
365
458
|
}
|
|
366
|
-
function
|
|
367
|
-
let n =
|
|
459
|
+
function Ee(e, t) {
|
|
460
|
+
let n = ve(e), r = [];
|
|
368
461
|
r.push("EDITING EXISTING SPECS:"), r.push("");
|
|
369
|
-
let i =
|
|
462
|
+
let i = Te(n);
|
|
370
463
|
i && (r.push(i), r.push(""));
|
|
371
464
|
for (let e of n) {
|
|
372
465
|
if (t === "json") switch (e) {
|
|
373
466
|
case "patch":
|
|
374
|
-
r.push(
|
|
467
|
+
r.push(ye());
|
|
375
468
|
break;
|
|
376
469
|
case "merge":
|
|
377
|
-
r.push(
|
|
470
|
+
r.push(be());
|
|
378
471
|
break;
|
|
379
472
|
case "diff":
|
|
380
|
-
r.push(
|
|
473
|
+
r.push(xe());
|
|
381
474
|
break;
|
|
382
475
|
}
|
|
383
476
|
else switch (e) {
|
|
384
477
|
case "patch":
|
|
385
|
-
r.push(
|
|
478
|
+
r.push(Se());
|
|
386
479
|
break;
|
|
387
480
|
case "merge":
|
|
388
|
-
r.push(
|
|
481
|
+
r.push(Ce());
|
|
389
482
|
break;
|
|
390
483
|
case "diff":
|
|
391
|
-
r.push(
|
|
484
|
+
r.push(we());
|
|
392
485
|
break;
|
|
393
486
|
}
|
|
394
487
|
r.push("");
|
|
395
488
|
}
|
|
396
489
|
return r.join("\n");
|
|
397
490
|
}
|
|
398
|
-
function
|
|
491
|
+
function De() {
|
|
399
492
|
return {
|
|
400
493
|
string: () => ({ kind: "string" }),
|
|
401
494
|
number: () => ({ kind: "number" }),
|
|
@@ -429,26 +522,26 @@ function Ce() {
|
|
|
429
522
|
optional: () => ({ optional: !0 })
|
|
430
523
|
};
|
|
431
524
|
}
|
|
432
|
-
function
|
|
525
|
+
function Oe(e, t) {
|
|
433
526
|
return {
|
|
434
|
-
definition: e(
|
|
527
|
+
definition: e(De()),
|
|
435
528
|
promptTemplate: t?.promptTemplate,
|
|
436
529
|
defaultRules: t?.defaultRules,
|
|
437
530
|
builtInActions: t?.builtInActions,
|
|
438
531
|
createCatalog(e) {
|
|
439
|
-
return
|
|
532
|
+
return ke(this, e);
|
|
440
533
|
}
|
|
441
534
|
};
|
|
442
535
|
}
|
|
443
|
-
function
|
|
444
|
-
let n = t.components, r = t.actions, i = n ? Object.keys(n) : [], a = r ? Object.keys(r) : [], o =
|
|
536
|
+
function ke(e, t) {
|
|
537
|
+
let n = t.components, r = t.actions, i = n ? Object.keys(n) : [], a = r ? Object.keys(r) : [], o = Ae(e.definition, t);
|
|
445
538
|
return {
|
|
446
539
|
schema: e,
|
|
447
540
|
data: t,
|
|
448
541
|
componentNames: i,
|
|
449
542
|
actionNames: a,
|
|
450
543
|
prompt(e = {}) {
|
|
451
|
-
return
|
|
544
|
+
return Me(this, e);
|
|
452
545
|
},
|
|
453
546
|
jsonSchema(e = {}) {
|
|
454
547
|
return $(o, e.strict ?? !1);
|
|
@@ -471,7 +564,7 @@ function Te(e, t) {
|
|
|
471
564
|
}
|
|
472
565
|
};
|
|
473
566
|
}
|
|
474
|
-
function
|
|
567
|
+
function Ae(e, t) {
|
|
475
568
|
return W(e.spec, t);
|
|
476
569
|
}
|
|
477
570
|
function W(i, u) {
|
|
@@ -494,29 +587,29 @@ function W(i, u) {
|
|
|
494
587
|
return c(l(), e);
|
|
495
588
|
}
|
|
496
589
|
case "ref": {
|
|
497
|
-
let t = i.inner, n =
|
|
590
|
+
let t = i.inner, n = je(t, u);
|
|
498
591
|
return n.length === 0 ? l() : n.length === 1 ? a(n[0]) : e(n);
|
|
499
592
|
}
|
|
500
593
|
case "propsOf": {
|
|
501
|
-
let e = i.inner, t =
|
|
594
|
+
let e = i.inner, t = G(e, u);
|
|
502
595
|
return t.length === 0 ? c(l(), d()) : t.length === 1 ? t[0] : c(l(), d());
|
|
503
596
|
}
|
|
504
597
|
default: return d();
|
|
505
598
|
}
|
|
506
599
|
}
|
|
507
|
-
function
|
|
600
|
+
function je(e, t) {
|
|
508
601
|
let n = e.split("."), r = { catalog: t };
|
|
509
602
|
for (let e of n) if (r && typeof r == "object") r = r[e];
|
|
510
603
|
else return [];
|
|
511
604
|
return r && typeof r == "object" ? Object.keys(r) : [];
|
|
512
605
|
}
|
|
513
|
-
function
|
|
606
|
+
function G(e, t) {
|
|
514
607
|
let n = e.split("."), r = { catalog: t };
|
|
515
608
|
for (let e of n) if (r && typeof r == "object") r = r[e];
|
|
516
609
|
else return [];
|
|
517
610
|
return r && typeof r == "object" ? Object.values(r).map((e) => e.props).filter((e) => e !== void 0) : [];
|
|
518
611
|
}
|
|
519
|
-
function
|
|
612
|
+
function Me(e, t) {
|
|
520
613
|
if (e.schema.promptTemplate) {
|
|
521
614
|
let n = {
|
|
522
615
|
catalog: e.data,
|
|
@@ -529,7 +622,7 @@ function G(e, t) {
|
|
|
529
622
|
}
|
|
530
623
|
let { system: n = "You are a UI generator that outputs JSON.", customRules: r = [], mode: i = "standalone" } = t, a = i === "chat" ? (console.warn("[json-render] mode \"chat\" is deprecated, use \"inline\" instead"), "inline") : i === "generate" ? (console.warn("[json-render] mode \"generate\" is deprecated, use \"standalone\" instead"), "standalone") : i, o = [];
|
|
531
624
|
o.push(n), o.push(""), a === "inline" ? (o.push("OUTPUT FORMAT (text + JSONL, RFC 6902 JSON Patch):"), o.push("You respond conversationally. When generating UI, first write a brief explanation (1-3 sentences), then output JSONL patch lines wrapped in a ```spec code fence."), o.push("The JSONL lines use RFC 6902 JSON Patch operations to build a UI tree. Always wrap them in a ```spec fence block:"), o.push(" ```spec"), o.push(" {\"op\":\"add\",\"path\":\"/root\",\"value\":\"main\"}"), o.push(" {\"op\":\"add\",\"path\":\"/elements/main\",\"value\":{\"type\":\"Card\",\"props\":{\"title\":\"Hello\"},\"children\":[]}}"), o.push(" ```"), o.push("If the user's message does not require a UI (e.g. a greeting or clarifying question), respond with text only — no JSONL.")) : (o.push("OUTPUT FORMAT (JSONL, RFC 6902 JSON Patch):"), o.push("Output JSONL (one JSON object per line) using RFC 6902 JSON Patch operations to build a UI tree.")), o.push("Each line is a JSON patch operation (add, remove, replace). Start with /root, then stream /elements and /state patches interleaved so the UI fills in progressively as it streams."), o.push(""), o.push("Example output (each line is a separate JSON object):"), o.push("");
|
|
532
|
-
let s = e.data.components, c = e.componentNames, l = c[0] || "Component", u = c.length > 1 ? c[1] : l, d = s?.[l], f = s?.[u], p = d ? K(d) : {}, m = f ? K(f) : {}, h = f?.props ?
|
|
625
|
+
let s = e.data.components, c = e.componentNames, l = c[0] || "Component", u = c.length > 1 ? c[1] : l, d = s?.[l], f = s?.[u], p = d ? K(d) : {}, m = f ? K(f) : {}, h = f?.props ? Ne(f.props) : null, g = h ? {
|
|
533
626
|
...m,
|
|
534
627
|
[h]: { $item: "title" }
|
|
535
628
|
} : m, _ = [
|
|
@@ -670,7 +763,7 @@ Note: state patches appear right after the elements that use them, so the UI fil
|
|
|
670
763
|
children: []
|
|
671
764
|
})}`), o.push(""), o.push("Use `watch` for cascading dependencies where changing one field should trigger side effects (loading data, resetting dependent fields, computing derived values)."), o.push("IMPORTANT: `watch` is a top-level field on the element (sibling of type/props/children), NOT inside props. Watchers only fire when the value changes, not on initial render."), o.push(""));
|
|
672
765
|
let w = t.editModes;
|
|
673
|
-
w && w.length > 0 && o.push(
|
|
766
|
+
w && w.length > 0 && o.push(Ee({ modes: w }, "json")), o.push("RULES:");
|
|
674
767
|
let T = a === "inline" ? [
|
|
675
768
|
"When generating UI, wrap all JSONL patches in a ```spec code fence - one JSON object per line inside the fence",
|
|
676
769
|
"Write a brief conversational response before any JSONL output",
|
|
@@ -754,7 +847,7 @@ function J(e) {
|
|
|
754
847
|
default: return "...";
|
|
755
848
|
}
|
|
756
849
|
}
|
|
757
|
-
function
|
|
850
|
+
function Ne(e) {
|
|
758
851
|
if (!e || !e._def) return null;
|
|
759
852
|
let t = e._def, n = Y(e);
|
|
760
853
|
if (n !== "ZodObject" && n !== "object") return null;
|
|
@@ -911,6 +1004,6 @@ function $(e, t = !1) {
|
|
|
911
1004
|
}
|
|
912
1005
|
}
|
|
913
1006
|
//#endregion
|
|
914
|
-
export {
|
|
1007
|
+
export { Oe as defineSchema, E as evaluateVisibility, pe as executeAction, fe as isDevtoolsActive, ue as nextActionDispatchId, ce as notifyActionDispatch, le as notifyActionSettle, V as resolveAction, se as resolveActionParam, oe as resolveBindings, ae as resolveElementProps, ge as runValidation, L as subscribeDevtoolsActive };
|
|
915
1008
|
|
|
916
1009
|
//# sourceMappingURL=index.js.map
|