@xmachines/json-render-solid 0.21.0-xm.1 → 0.21.0-xm.3
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 +31 -0
- package/dist/{chunk-ZTWTJIEL.mjs → chunk-4IHHL4OE.mjs} +3 -1
- package/dist/chunk-4IHHL4OE.mjs.map +1 -0
- package/dist/index.d.mts +26 -2
- package/dist/index.d.ts +26 -2
- package/dist/index.js +267 -172
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +280 -187
- package/dist/index.mjs.map +1 -1
- package/dist/schema.d.mts +10 -0
- package/dist/schema.d.ts +10 -0
- package/dist/schema.js +2 -0
- package/dist/schema.js.map +1 -1
- package/dist/schema.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-ZTWTJIEL.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -491,12 +491,18 @@ function ActionProvider(props) {
|
|
|
491
491
|
set,
|
|
492
492
|
getSnapshot
|
|
493
493
|
} = useStateStore();
|
|
494
|
+
const writeTogether = (updates) => {
|
|
495
|
+
(0, import_solid_js4.batch)(() => {
|
|
496
|
+
for (const [path, value] of Object.entries(updates)) set(path, value);
|
|
497
|
+
});
|
|
498
|
+
};
|
|
494
499
|
const validation = useOptionalValidation();
|
|
495
|
-
const [
|
|
500
|
+
const [registered, setRegistered] = (0, import_solid_js4.createSignal)({});
|
|
501
|
+
const handlers = (0, import_solid_js4.createMemo)(() => (0, import_core4.mergeActionHandlers)(props.handlers ?? {}, registered()));
|
|
496
502
|
const [loadingActions, setLoadingActions] = (0, import_solid_js4.createSignal)(/* @__PURE__ */ new Set());
|
|
497
503
|
const [pendingConfirmation, setPendingConfirmation] = (0, import_solid_js4.createSignal)(null);
|
|
498
504
|
const registerHandler = (name, handler) => {
|
|
499
|
-
|
|
505
|
+
setRegistered((prev) => ({
|
|
500
506
|
...prev,
|
|
501
507
|
[name]: handler
|
|
502
508
|
}));
|
|
@@ -516,6 +522,35 @@ function ActionProvider(props) {
|
|
|
516
522
|
let __cancelled = false;
|
|
517
523
|
let __confirmMs = void 0;
|
|
518
524
|
try {
|
|
525
|
+
const handler = handlers()[resolved.action];
|
|
526
|
+
if (!handler && !(0, import_core4.isBuiltInAction)(resolved.action)) {
|
|
527
|
+
console.warn(`No handler registered for action: ${resolved.action}`);
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
if (resolved.confirm) {
|
|
531
|
+
pendingConfirmation()?.reject();
|
|
532
|
+
const confirmOpenedAt = Date.now();
|
|
533
|
+
const confirmed = await new Promise((res) => {
|
|
534
|
+
setPendingConfirmation({
|
|
535
|
+
action: resolved,
|
|
536
|
+
handler,
|
|
537
|
+
resolve: () => {
|
|
538
|
+
setPendingConfirmation(null);
|
|
539
|
+
res(true);
|
|
540
|
+
},
|
|
541
|
+
reject: () => {
|
|
542
|
+
setPendingConfirmation(null);
|
|
543
|
+
res(false);
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
});
|
|
547
|
+
__confirmMs = Date.now() - confirmOpenedAt;
|
|
548
|
+
if (!confirmed) {
|
|
549
|
+
__ok = false;
|
|
550
|
+
__cancelled = true;
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
519
554
|
if (resolved.action === "setState" && resolved.params) {
|
|
520
555
|
const statePath = resolved.params.statePath;
|
|
521
556
|
const value = resolved.params.value;
|
|
@@ -530,10 +565,14 @@ function ActionProvider(props) {
|
|
|
530
565
|
if (statePath) {
|
|
531
566
|
const resolvedValue = deepResolveValue(rawValue, get);
|
|
532
567
|
const arr = get(statePath) ?? [];
|
|
533
|
-
set(statePath, [...arr, resolvedValue]);
|
|
534
568
|
const clearStatePath = resolved.params.clearStatePath;
|
|
535
569
|
if (clearStatePath) {
|
|
536
|
-
|
|
570
|
+
writeTogether({
|
|
571
|
+
[statePath]: [...arr, resolvedValue],
|
|
572
|
+
[clearStatePath]: ""
|
|
573
|
+
});
|
|
574
|
+
} else {
|
|
575
|
+
set(statePath, [...arr, resolvedValue]);
|
|
537
576
|
}
|
|
538
577
|
}
|
|
539
578
|
return;
|
|
@@ -552,12 +591,10 @@ function ActionProvider(props) {
|
|
|
552
591
|
if (screen) {
|
|
553
592
|
const currentScreen = get("/currentScreen");
|
|
554
593
|
const navStack = get("/navStack") ?? [];
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
}
|
|
560
|
-
set("/currentScreen", screen);
|
|
594
|
+
writeTogether({
|
|
595
|
+
"/navStack": [...navStack, currentScreen ? currentScreen : ""],
|
|
596
|
+
"/currentScreen": screen
|
|
597
|
+
});
|
|
561
598
|
}
|
|
562
599
|
return;
|
|
563
600
|
}
|
|
@@ -565,12 +602,10 @@ function ActionProvider(props) {
|
|
|
565
602
|
const navStack = get("/navStack") ?? [];
|
|
566
603
|
if (navStack.length > 0) {
|
|
567
604
|
const previousScreen = navStack[navStack.length - 1];
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
}
|
|
572
|
-
set("/currentScreen", void 0);
|
|
573
|
-
}
|
|
605
|
+
writeTogether({
|
|
606
|
+
"/navStack": navStack.slice(0, -1),
|
|
607
|
+
"/currentScreen": previousScreen ? previousScreen : void 0
|
|
608
|
+
});
|
|
574
609
|
}
|
|
575
610
|
return;
|
|
576
611
|
}
|
|
@@ -594,41 +629,14 @@ function ActionProvider(props) {
|
|
|
594
629
|
});
|
|
595
630
|
return;
|
|
596
631
|
}
|
|
597
|
-
|
|
598
|
-
if (!handler) {
|
|
599
|
-
console.warn(`No handler registered for action: ${resolved.action}`);
|
|
600
|
-
return;
|
|
601
|
-
}
|
|
602
|
-
if (resolved.confirm) {
|
|
603
|
-
pendingConfirmation()?.reject();
|
|
604
|
-
const confirmOpenedAt = Date.now();
|
|
605
|
-
const confirmed = await new Promise((res) => {
|
|
606
|
-
setPendingConfirmation({
|
|
607
|
-
action: resolved,
|
|
608
|
-
handler,
|
|
609
|
-
resolve: () => {
|
|
610
|
-
setPendingConfirmation(null);
|
|
611
|
-
res(true);
|
|
612
|
-
},
|
|
613
|
-
reject: () => {
|
|
614
|
-
setPendingConfirmation(null);
|
|
615
|
-
res(false);
|
|
616
|
-
}
|
|
617
|
-
});
|
|
618
|
-
});
|
|
619
|
-
__confirmMs = Date.now() - confirmOpenedAt;
|
|
620
|
-
if (!confirmed) {
|
|
621
|
-
__ok = false;
|
|
622
|
-
__cancelled = true;
|
|
623
|
-
return;
|
|
624
|
-
}
|
|
625
|
-
}
|
|
632
|
+
if (!handler) return;
|
|
626
633
|
setLoadingActions((prev) => new Set(prev).add(resolved.action));
|
|
627
634
|
try {
|
|
628
635
|
await (0, import_core4.executeAction)({
|
|
629
636
|
action: resolved,
|
|
630
637
|
handler,
|
|
631
638
|
setState: set,
|
|
639
|
+
updateState: writeTogether,
|
|
632
640
|
navigate: props.navigate,
|
|
633
641
|
executeAction: async (binding2) => {
|
|
634
642
|
await execute(binding2);
|
|
@@ -727,12 +735,19 @@ var import_solid_js5 = require("solid-js");
|
|
|
727
735
|
var RepeatScopeContext = (0, import_solid_js5.createContext)(null);
|
|
728
736
|
function RepeatScopeProvider(props) {
|
|
729
737
|
return (0, import_web12.createComponent)(RepeatScopeContext.Provider, {
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
738
|
+
value: {
|
|
739
|
+
// Getters, and not copies: a row that stays on the screen shows the
|
|
740
|
+
// item and the index of now, so a consumer that reads the scope in a
|
|
741
|
+
// tracked computation follows them.
|
|
742
|
+
get item() {
|
|
743
|
+
return props.item;
|
|
744
|
+
},
|
|
745
|
+
get index() {
|
|
746
|
+
return props.index;
|
|
747
|
+
},
|
|
748
|
+
get basePath() {
|
|
749
|
+
return props.basePath;
|
|
750
|
+
}
|
|
736
751
|
},
|
|
737
752
|
get children() {
|
|
738
753
|
return props.children;
|
|
@@ -760,6 +775,7 @@ var schema = (0, import_core5.defineSchema)(
|
|
|
760
775
|
props: s.propsOf("catalog.components"),
|
|
761
776
|
/** Child element keys (flat reference) */
|
|
762
777
|
children: s.array(s.string()),
|
|
778
|
+
slots: { ...s.record(s.array(s.string())), ...s.optional() },
|
|
763
779
|
/** Visibility condition */
|
|
764
780
|
visible: { ...s.any(), ...s.optional() },
|
|
765
781
|
/** Repeat children from a state array */
|
|
@@ -813,6 +829,7 @@ var schema = (0, import_core5.defineSchema)(
|
|
|
813
829
|
"CRITICAL INTEGRITY CHECK: Before outputting ANY element that references children, you MUST have already output (or will output) each child as its own element. If an element has children: ['a', 'b'], then elements 'a' and 'b' MUST exist. A missing child element causes that entire branch of the UI to be invisible.",
|
|
814
830
|
"SELF-CHECK: After generating all elements, mentally walk the tree from root. Every key in every children array must resolve to a defined element. If you find a gap, output the missing element immediately.",
|
|
815
831
|
'REQUIRED FIELDS: Every element MUST include a "children" array. Leaf elements (text, badges, inputs, images) use an empty array: "children": []. Omitting "children" fails validation.',
|
|
832
|
+
'NAMED SLOTS: Use "children" for the default slot. For other slots declared by the component, use a top-level "slots" object that maps each slot name to child element keys, for example {"slots":{"header":["heading"],"footer":["actions"]}}. Never use "slots.default". Every referenced key must exist.',
|
|
816
833
|
// Field placement
|
|
817
834
|
'CRITICAL: The "visible" field goes on the ELEMENT object, NOT inside "props". Correct: {"type":"<ComponentName>","props":{},"visible":{"$state":"/tab","eq":"home"},"children":[...]}.',
|
|
818
835
|
'CRITICAL: The "on" field goes on the ELEMENT object, NOT inside "props". Use on.press, on.change, on.submit etc. NEVER put action/actionParams inside props.',
|
|
@@ -842,11 +859,12 @@ var import_solid_js6 = require("solid-js");
|
|
|
842
859
|
var import_core6 = require("@xmachines/json-render-core");
|
|
843
860
|
var _tmpl$2 = /* @__PURE__ */ (0, import_web13.template)(`<span style=display:contents>`);
|
|
844
861
|
function reportRenderError(registry, elementType, error) {
|
|
845
|
-
const onRenderError = registry
|
|
846
|
-
if (
|
|
862
|
+
const onRenderError = (0, import_core6.getRenderErrorHandler)(registry);
|
|
863
|
+
if (onRenderError !== void 0) {
|
|
847
864
|
onRenderError(error, elementType);
|
|
848
865
|
return;
|
|
849
866
|
}
|
|
867
|
+
(0, import_core6.warnUnusedRenderErrorHandler)(registry);
|
|
850
868
|
console.error(`[json-render] Rendering error in <${elementType}>:`, error);
|
|
851
869
|
}
|
|
852
870
|
var EMPTY_FUNCTIONS = {};
|
|
@@ -910,23 +928,17 @@ function ElementRenderer(props) {
|
|
|
910
928
|
const binding = onBindings?.[eventName];
|
|
911
929
|
if (!binding) return;
|
|
912
930
|
const actionBindings = Array.isArray(binding) ? binding : [binding];
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
};
|
|
922
|
-
const resolved = {};
|
|
923
|
-
for (const [key, val] of Object.entries(b.params)) {
|
|
924
|
-
resolved[key] = (0, import_core6.resolveActionParam)(val, liveCtx);
|
|
931
|
+
let action = "";
|
|
932
|
+
try {
|
|
933
|
+
for (const b of actionBindings) {
|
|
934
|
+
action = b.action;
|
|
935
|
+
await execute((0, import_core6.resolveBindingParams)(b, {
|
|
936
|
+
...fullCtx(),
|
|
937
|
+
stateModel: getSnapshot()
|
|
938
|
+
}));
|
|
925
939
|
}
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
params: resolved
|
|
929
|
-
});
|
|
940
|
+
} catch (err) {
|
|
941
|
+
(0, import_core6.reportActionError)((0, import_core6.getRenderErrorHandler)(props.registry), err, action, "event");
|
|
930
942
|
}
|
|
931
943
|
};
|
|
932
944
|
const on = (eventName) => {
|
|
@@ -948,42 +960,35 @@ function ElementRenderer(props) {
|
|
|
948
960
|
bound: true
|
|
949
961
|
};
|
|
950
962
|
};
|
|
963
|
+
let stableWatched;
|
|
964
|
+
const watchedValues = (0, import_solid_js6.createMemo)(() => {
|
|
965
|
+
const cfg = props.element.watch;
|
|
966
|
+
stableWatched = cfg ? (0, import_core6.readWatchedValues)(cfg, stateStore.state, stableWatched) : void 0;
|
|
967
|
+
return stableWatched;
|
|
968
|
+
});
|
|
969
|
+
let previousWatched = (0, import_solid_js6.untrack)(watchedValues);
|
|
951
970
|
(0, import_solid_js6.createEffect)(() => {
|
|
952
|
-
const
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
const
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
for (const path of paths) {
|
|
960
|
-
if (!changedPaths.has(path)) continue;
|
|
961
|
-
const binding = watchConfig[path];
|
|
962
|
-
if (!binding) continue;
|
|
963
|
-
const bindings = Array.isArray(binding) ? binding : [binding];
|
|
964
|
-
for (const b of bindings) {
|
|
965
|
-
if (!b.params) {
|
|
966
|
-
await execute(b);
|
|
967
|
-
continue;
|
|
968
|
-
}
|
|
969
|
-
const liveCtx = {
|
|
970
|
-
...fullCtx(),
|
|
971
|
-
stateModel: getSnapshot()
|
|
972
|
-
};
|
|
973
|
-
const resolved = {};
|
|
974
|
-
for (const [key, val] of Object.entries(b.params)) {
|
|
975
|
-
resolved[key] = (0, import_core6.resolveActionParam)(val, liveCtx);
|
|
976
|
-
}
|
|
977
|
-
await execute({
|
|
978
|
-
...b,
|
|
979
|
-
params: resolved
|
|
980
|
-
});
|
|
981
|
-
}
|
|
982
|
-
}
|
|
983
|
-
})().catch(console.error);
|
|
984
|
-
});
|
|
971
|
+
const current = watchedValues();
|
|
972
|
+
const prev = previousWatched;
|
|
973
|
+
previousWatched = current;
|
|
974
|
+
const paths = (0, import_core6.changedWatchPaths)(current, prev);
|
|
975
|
+
const watchConfig = (0, import_solid_js6.untrack)(() => props.element.watch);
|
|
976
|
+
if (!watchConfig || paths.length === 0) return;
|
|
977
|
+
let cancelled = false;
|
|
985
978
|
(0, import_solid_js6.onCleanup)(() => {
|
|
986
|
-
|
|
979
|
+
cancelled = true;
|
|
980
|
+
});
|
|
981
|
+
(0, import_solid_js6.untrack)(() => {
|
|
982
|
+
let action = "";
|
|
983
|
+
void (0, import_core6.runWatchBindings)(watchConfig, paths, async (b) => {
|
|
984
|
+
action = b.action;
|
|
985
|
+
await execute((0, import_core6.resolveBindingParams)(b, {
|
|
986
|
+
...fullCtx(),
|
|
987
|
+
stateModel: getSnapshot()
|
|
988
|
+
}));
|
|
989
|
+
}, () => cancelled).catch((err) => {
|
|
990
|
+
(0, import_core6.reportActionError)((0, import_core6.getRenderErrorHandler)(props.registry), err, action, "watch");
|
|
991
|
+
});
|
|
987
992
|
});
|
|
988
993
|
});
|
|
989
994
|
const elementBindings = (0, import_solid_js6.createMemo)(() => {
|
|
@@ -1004,8 +1009,13 @@ function ElementRenderer(props) {
|
|
|
1004
1009
|
},
|
|
1005
1010
|
get children() {
|
|
1006
1011
|
return (0, import_web18.createComponent)(import_solid_js6.ErrorBoundary, {
|
|
1007
|
-
fallback: (err) => {
|
|
1012
|
+
fallback: (err, reset) => {
|
|
1008
1013
|
reportRenderError(props.registry, props.element.type, err);
|
|
1014
|
+
const subtree = () => (0, import_core6.elementSubtreeJson)(props.spec, props.elementKey, props.element);
|
|
1015
|
+
const failed = (0, import_solid_js6.untrack)(subtree);
|
|
1016
|
+
(0, import_solid_js6.createEffect)(() => {
|
|
1017
|
+
if (subtree() !== failed) reset();
|
|
1018
|
+
});
|
|
1009
1019
|
return null;
|
|
1010
1020
|
},
|
|
1011
1021
|
get children() {
|
|
@@ -1044,39 +1054,25 @@ function ElementRenderer(props) {
|
|
|
1044
1054
|
}
|
|
1045
1055
|
function ElementRendererContent(props) {
|
|
1046
1056
|
const devtoolsActive = useDevtoolsActive();
|
|
1047
|
-
const Comp = () => props.registry
|
|
1057
|
+
const Comp = () => (0, import_core6.getRegistryComponent)(props.registry, props.resolvedElement.type) ?? props.fallback;
|
|
1048
1058
|
return (0, import_web18.createComponent)(import_solid_js6.Show, {
|
|
1049
1059
|
get when() {
|
|
1050
1060
|
return Comp();
|
|
1051
1061
|
},
|
|
1062
|
+
keyed: true,
|
|
1052
1063
|
get fallback() {
|
|
1053
1064
|
console.warn(`No renderer for component type: ${props.resolvedElement.type}`);
|
|
1054
1065
|
return null;
|
|
1055
1066
|
},
|
|
1056
|
-
children: (
|
|
1057
|
-
const
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
return props.spec;
|
|
1064
|
-
},
|
|
1065
|
-
get registry() {
|
|
1066
|
-
return props.registry;
|
|
1067
|
-
},
|
|
1068
|
-
get loading() {
|
|
1069
|
-
return props.loading;
|
|
1070
|
-
},
|
|
1071
|
-
get fallback() {
|
|
1072
|
-
return props.fallback;
|
|
1073
|
-
},
|
|
1074
|
-
get itemFilter() {
|
|
1075
|
-
return props.itemFilter;
|
|
1076
|
-
}
|
|
1077
|
-
}) : (0, import_web18.createComponent)(import_solid_js6.For, {
|
|
1067
|
+
children: (Component) => {
|
|
1068
|
+
const elementSlots = (0, import_solid_js6.createMemo)(() => props.resolvedElement.slots);
|
|
1069
|
+
(0, import_solid_js6.createRenderEffect)(() => {
|
|
1070
|
+
const slotEntries = elementSlots();
|
|
1071
|
+
(0, import_solid_js6.untrack)(() => (0, import_core6.warnElementSlots)(props.registry, props.resolvedElement.type, slotEntries));
|
|
1072
|
+
});
|
|
1073
|
+
const renderChildKeys = (childKeys, slotName) => (0, import_web18.createComponent)(import_solid_js6.For, {
|
|
1078
1074
|
get each() {
|
|
1079
|
-
return
|
|
1075
|
+
return childKeys();
|
|
1080
1076
|
},
|
|
1081
1077
|
children: (childKey) => {
|
|
1082
1078
|
const childElement = () => props.spec.elements[childKey];
|
|
@@ -1086,7 +1082,9 @@ function ElementRendererContent(props) {
|
|
|
1086
1082
|
},
|
|
1087
1083
|
get fallback() {
|
|
1088
1084
|
if (!props.loading) {
|
|
1089
|
-
|
|
1085
|
+
const type = (0, import_solid_js6.untrack)(() => props.resolvedElement.type);
|
|
1086
|
+
const location = slotName ? `in slot "${slotName}" of "${type}"` : `as child of "${type}"`;
|
|
1087
|
+
console.warn(`[json-render] Missing element "${childKey}" referenced ${location}. This element will not render.`);
|
|
1090
1088
|
}
|
|
1091
1089
|
return null;
|
|
1092
1090
|
},
|
|
@@ -1111,6 +1109,99 @@ function ElementRendererContent(props) {
|
|
|
1111
1109
|
});
|
|
1112
1110
|
}
|
|
1113
1111
|
});
|
|
1112
|
+
const owner = (0, import_solid_js6.getOwner)();
|
|
1113
|
+
const once = (make) => {
|
|
1114
|
+
const contents = /* @__PURE__ */ new Map();
|
|
1115
|
+
return () => {
|
|
1116
|
+
const reader = (0, import_solid_js6.getOwner)();
|
|
1117
|
+
let content = contents.get(reader);
|
|
1118
|
+
if (content === void 0) {
|
|
1119
|
+
let dispose = () => {
|
|
1120
|
+
};
|
|
1121
|
+
const value = (0, import_solid_js6.createRoot)((disposeRoot) => {
|
|
1122
|
+
dispose = disposeRoot;
|
|
1123
|
+
return make();
|
|
1124
|
+
}, reader ?? owner);
|
|
1125
|
+
const made = {
|
|
1126
|
+
value,
|
|
1127
|
+
dispose,
|
|
1128
|
+
leaving: false
|
|
1129
|
+
};
|
|
1130
|
+
contents.set(reader, made);
|
|
1131
|
+
(0, import_solid_js6.runWithOwner)(owner, () => (0, import_solid_js6.onCleanup)(() => {
|
|
1132
|
+
contents.delete(reader);
|
|
1133
|
+
made.dispose();
|
|
1134
|
+
}));
|
|
1135
|
+
content = made;
|
|
1136
|
+
}
|
|
1137
|
+
content.leaving = false;
|
|
1138
|
+
if (reader !== null && reader !== owner) {
|
|
1139
|
+
const read = content;
|
|
1140
|
+
(0, import_solid_js6.onCleanup)(() => {
|
|
1141
|
+
read.leaving = true;
|
|
1142
|
+
queueMicrotask(() => {
|
|
1143
|
+
if (!read.leaving || contents.get(reader) !== read) return;
|
|
1144
|
+
contents.delete(reader);
|
|
1145
|
+
read.dispose();
|
|
1146
|
+
});
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1149
|
+
return content.value;
|
|
1150
|
+
};
|
|
1151
|
+
};
|
|
1152
|
+
const children = once(() => (0, import_web18.createComponent)(import_solid_js6.Show, {
|
|
1153
|
+
get when() {
|
|
1154
|
+
return props.resolvedElement.repeat;
|
|
1155
|
+
},
|
|
1156
|
+
get fallback() {
|
|
1157
|
+
return renderChildKeys(() => props.resolvedElement.children ?? []);
|
|
1158
|
+
},
|
|
1159
|
+
get children() {
|
|
1160
|
+
return (0, import_web18.createComponent)(RepeatChildren, {
|
|
1161
|
+
get element() {
|
|
1162
|
+
return props.resolvedElement;
|
|
1163
|
+
},
|
|
1164
|
+
get spec() {
|
|
1165
|
+
return props.spec;
|
|
1166
|
+
},
|
|
1167
|
+
get registry() {
|
|
1168
|
+
return props.registry;
|
|
1169
|
+
},
|
|
1170
|
+
get loading() {
|
|
1171
|
+
return props.loading;
|
|
1172
|
+
},
|
|
1173
|
+
get fallback() {
|
|
1174
|
+
return props.fallback;
|
|
1175
|
+
},
|
|
1176
|
+
get itemFilter() {
|
|
1177
|
+
return props.itemFilter;
|
|
1178
|
+
}
|
|
1179
|
+
});
|
|
1180
|
+
}
|
|
1181
|
+
}));
|
|
1182
|
+
const slotContent = /* @__PURE__ */ new Map();
|
|
1183
|
+
const slotOf = (slotName) => {
|
|
1184
|
+
let content = slotContent.get(slotName);
|
|
1185
|
+
if (!content) {
|
|
1186
|
+
content = once(() => renderChildKeys(() => props.resolvedElement.slots?.[slotName] ?? [], slotName));
|
|
1187
|
+
slotContent.set(slotName, content);
|
|
1188
|
+
}
|
|
1189
|
+
return content();
|
|
1190
|
+
};
|
|
1191
|
+
const slots = () => {
|
|
1192
|
+
const slotEntries = props.resolvedElement.slots;
|
|
1193
|
+
if (!slotEntries) return void 0;
|
|
1194
|
+
const slotNames = Object.keys(slotEntries).filter((slotName) => slotName !== "default");
|
|
1195
|
+
if (slotNames.length === 0) return void 0;
|
|
1196
|
+
const result = {};
|
|
1197
|
+
for (const slotName of slotNames) {
|
|
1198
|
+
Object.defineProperty(result, slotName, {
|
|
1199
|
+
enumerable: true,
|
|
1200
|
+
get: () => slotOf(slotName)
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
return result;
|
|
1204
|
+
};
|
|
1114
1205
|
const rendered = (0, import_web18.createComponent)(Component, {
|
|
1115
1206
|
get element() {
|
|
1116
1207
|
return props.resolvedElement;
|
|
@@ -1127,6 +1218,9 @@ function ElementRendererContent(props) {
|
|
|
1127
1218
|
get loading() {
|
|
1128
1219
|
return props.loading;
|
|
1129
1220
|
},
|
|
1221
|
+
get slots() {
|
|
1222
|
+
return slots();
|
|
1223
|
+
},
|
|
1130
1224
|
get children() {
|
|
1131
1225
|
return children();
|
|
1132
1226
|
}
|
|
@@ -1169,23 +1263,44 @@ function RepeatChildren(props) {
|
|
|
1169
1263
|
repeatItem: itemValue,
|
|
1170
1264
|
repeatIndex: index
|
|
1171
1265
|
}));
|
|
1266
|
+
const keyed = (0, import_solid_js6.createMemo)(() => {
|
|
1267
|
+
const r = repeat();
|
|
1268
|
+
const path = statePath();
|
|
1269
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
1270
|
+
const keys = [];
|
|
1271
|
+
for (const entry of entries()) {
|
|
1272
|
+
const {
|
|
1273
|
+
itemValue,
|
|
1274
|
+
index
|
|
1275
|
+
} = entry;
|
|
1276
|
+
const itemKey = r.key && typeof itemValue === "object" && itemValue !== null ? String(itemValue[r.key] ?? "") : "";
|
|
1277
|
+
const key = JSON.stringify([path, index, itemKey]);
|
|
1278
|
+
byKey.set(key, entry);
|
|
1279
|
+
keys.push(key);
|
|
1280
|
+
}
|
|
1281
|
+
return {
|
|
1282
|
+
keys,
|
|
1283
|
+
byKey
|
|
1284
|
+
};
|
|
1285
|
+
});
|
|
1172
1286
|
return (0, import_web18.createComponent)(import_solid_js6.For, {
|
|
1173
1287
|
get each() {
|
|
1174
|
-
return
|
|
1288
|
+
return keyed().keys;
|
|
1175
1289
|
},
|
|
1176
|
-
children: ({
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
const
|
|
1181
|
-
const r = repeat();
|
|
1182
|
-
return r.key && typeof itemValue === "object" && itemValue !== null ? String(itemValue[r.key] ?? index) : String(index);
|
|
1183
|
-
};
|
|
1290
|
+
children: (key) => {
|
|
1291
|
+
const entry = (0, import_solid_js6.createMemo)(() => keyed().byKey.get(key), void 0, {
|
|
1292
|
+
equals: (a, b) => a?.itemValue === b?.itemValue
|
|
1293
|
+
});
|
|
1294
|
+
const index = () => entry()?.index ?? 0;
|
|
1184
1295
|
return (0, import_web18.createComponent)(RepeatScopeProvider, {
|
|
1185
|
-
item
|
|
1186
|
-
|
|
1296
|
+
get item() {
|
|
1297
|
+
return entry()?.itemValue;
|
|
1298
|
+
},
|
|
1299
|
+
get index() {
|
|
1300
|
+
return index();
|
|
1301
|
+
},
|
|
1187
1302
|
get basePath() {
|
|
1188
|
-
return (0, import_core6.resolveRepeatItemStatePath)(statePath(), index);
|
|
1303
|
+
return (0, import_core6.resolveRepeatItemStatePath)(statePath(), index());
|
|
1189
1304
|
},
|
|
1190
1305
|
get children() {
|
|
1191
1306
|
return (0, import_web18.createComponent)(import_solid_js6.For, {
|
|
@@ -1208,6 +1323,7 @@ function RepeatChildren(props) {
|
|
|
1208
1323
|
get element() {
|
|
1209
1324
|
return el();
|
|
1210
1325
|
},
|
|
1326
|
+
elementKey: childKey,
|
|
1211
1327
|
get spec() {
|
|
1212
1328
|
return props.spec;
|
|
1213
1329
|
},
|
|
@@ -1235,18 +1351,7 @@ function Renderer(props) {
|
|
|
1235
1351
|
if (!spec || !spec.root) return void 0;
|
|
1236
1352
|
return spec.elements[spec.root];
|
|
1237
1353
|
});
|
|
1238
|
-
const rendererRegistry = (0, import_solid_js6.createMemo)(() =>
|
|
1239
|
-
if (!props.onRenderError) return props.registry;
|
|
1240
|
-
const next = {
|
|
1241
|
-
...props.registry
|
|
1242
|
-
};
|
|
1243
|
-
Object.defineProperty(next, "onRenderError", {
|
|
1244
|
-
value: props.onRenderError,
|
|
1245
|
-
enumerable: false,
|
|
1246
|
-
configurable: true
|
|
1247
|
-
});
|
|
1248
|
-
return next;
|
|
1249
|
-
});
|
|
1354
|
+
const rendererRegistry = (0, import_solid_js6.createMemo)(() => props.onRenderError ? (0, import_core6.withRenderErrorHandler)(props.registry, props.onRenderError) : props.registry);
|
|
1250
1355
|
return (0, import_web18.createComponent)(import_solid_js6.Show, {
|
|
1251
1356
|
get when() {
|
|
1252
1357
|
return rootElement();
|
|
@@ -1344,8 +1449,8 @@ function ConfirmationDialogManager() {
|
|
|
1344
1449
|
})
|
|
1345
1450
|
});
|
|
1346
1451
|
}
|
|
1347
|
-
function defineRegistry(
|
|
1348
|
-
const registry =
|
|
1452
|
+
function defineRegistry(catalog, options) {
|
|
1453
|
+
const registry = (0, import_core6.createComponentRegistry)(options.components);
|
|
1349
1454
|
if (options.components) {
|
|
1350
1455
|
for (const [name, componentFn] of Object.entries(options.components)) {
|
|
1351
1456
|
registry[name] = (renderProps) => {
|
|
@@ -1356,6 +1461,9 @@ function defineRegistry(_catalog, options) {
|
|
|
1356
1461
|
get children() {
|
|
1357
1462
|
return renderProps.children;
|
|
1358
1463
|
},
|
|
1464
|
+
get slots() {
|
|
1465
|
+
return renderProps.slots;
|
|
1466
|
+
},
|
|
1359
1467
|
emit: renderProps.emit,
|
|
1360
1468
|
on: renderProps.on,
|
|
1361
1469
|
get bindings() {
|
|
@@ -1368,6 +1476,7 @@ function defineRegistry(_catalog, options) {
|
|
|
1368
1476
|
};
|
|
1369
1477
|
}
|
|
1370
1478
|
}
|
|
1479
|
+
(0, import_core6.setCatalogSlotMetadata)(registry, catalog);
|
|
1371
1480
|
const actionMap = options.actions ? Object.entries(options.actions) : [];
|
|
1372
1481
|
const handlers = (getSetState, getState) => {
|
|
1373
1482
|
const result = {};
|
|
@@ -1391,11 +1500,7 @@ function defineRegistry(_catalog, options) {
|
|
|
1391
1500
|
}
|
|
1392
1501
|
};
|
|
1393
1502
|
if (options.onRenderError) {
|
|
1394
|
-
|
|
1395
|
-
value: options.onRenderError,
|
|
1396
|
-
enumerable: false,
|
|
1397
|
-
configurable: true
|
|
1398
|
-
});
|
|
1503
|
+
(0, import_core6.setRenderErrorHandler)(registry, options.onRenderError);
|
|
1399
1504
|
}
|
|
1400
1505
|
return {
|
|
1401
1506
|
registry,
|
|
@@ -1405,20 +1510,10 @@ function defineRegistry(_catalog, options) {
|
|
|
1405
1510
|
}
|
|
1406
1511
|
function createRenderer(catalog, components) {
|
|
1407
1512
|
const registry = components;
|
|
1513
|
+
(0, import_core6.setCatalogSlotMetadata)(registry, catalog);
|
|
1408
1514
|
return function CatalogRenderer(props) {
|
|
1409
1515
|
const directiveRegistry = (0, import_solid_js6.createMemo)(() => props.directives ? (0, import_core6.createDirectiveRegistry)(props.directives) : void 0);
|
|
1410
|
-
const rendererRegistry = (0, import_solid_js6.createMemo)(() =>
|
|
1411
|
-
if (!props.onRenderError) return registry;
|
|
1412
|
-
const next = {
|
|
1413
|
-
...registry
|
|
1414
|
-
};
|
|
1415
|
-
Object.defineProperty(next, "onRenderError", {
|
|
1416
|
-
value: props.onRenderError,
|
|
1417
|
-
enumerable: false,
|
|
1418
|
-
configurable: true
|
|
1419
|
-
});
|
|
1420
|
-
return next;
|
|
1421
|
-
});
|
|
1516
|
+
const rendererRegistry = (0, import_solid_js6.createMemo)(() => props.onRenderError ? (0, import_core6.withRenderErrorHandler)(registry, props.onRenderError) : registry);
|
|
1422
1517
|
const actionHandlers = () => props.onAction ? new Proxy({}, {
|
|
1423
1518
|
get: (_target, prop) => {
|
|
1424
1519
|
return (params) => props.onAction(prop, params);
|