@ai-matrx/content-ir-react 0.13.17 → 0.14.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/CHANGELOG.md +24 -0
- package/dist/{directive-host-Bl-ZgJWp.d.cts → directive-host-DLp5QFI2.d.cts} +34 -1
- package/dist/{directive-host-Bl-ZgJWp.d.ts → directive-host-DLp5QFI2.d.ts} +34 -1
- package/dist/directives.cjs +80 -4
- package/dist/directives.cjs.map +1 -1
- package/dist/directives.d.cts +1 -1
- package/dist/directives.d.ts +1 -1
- package/dist/directives.js +80 -4
- package/dist/directives.js.map +1 -1
- package/dist/{host-types-BgROpyjE.d.cts → host-types-BpmKg07p.d.cts} +1 -1
- package/dist/{host-types-Cz-1pGHz.d.ts → host-types-DHKFg06S.d.ts} +1 -1
- package/dist/host.cjs.map +1 -1
- package/dist/host.d.cts +3 -3
- package/dist/host.d.ts +3 -3
- package/dist/host.js.map +1 -1
- package/dist/index.cjs +80 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +80 -4
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +80 -4
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +80 -4
- package/dist/react.js.map +1 -1
- package/dist/{route-DxK1SoPh.d.cts → route-Bf-kciHw.d.cts} +34 -1
- package/dist/{route-JGZfl2nL.d.ts → route-ymqupVjr.d.ts} +34 -1
- package/dist/route.d.cts +1 -1
- package/dist/route.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { C as ComponentResolutionSource, a as ComponentResolution, b as ContentIrErrorReporter } from './component-resolution.types-DLO2w-0n.cjs';
|
|
2
2
|
export { c as ComponentRole, d as ContentIrErrorReport, J as JsonObject, K as KindComponentRow, S as SystemComponentEntry, e as consoleErrorReporter } from './component-resolution.types-DLO2w-0n.cjs';
|
|
3
|
-
import { C as ContentIrHost, K as KindRouteEnv, a as KindDefinitionSource } from './route-
|
|
4
|
-
export { b as ContentIrRenderSeams, D as DB_KIND_COMPONENT_KEY, c as DIRECTIVE_BLOCK_TYPE, d as DirectiveApplyResult, e as
|
|
3
|
+
import { C as ContentIrHost, K as KindRouteEnv, a as KindDefinitionSource } from './route-Bf-kciHw.cjs';
|
|
4
|
+
export { b as ContentIrRenderSeams, D as DB_KIND_COMPONENT_KEY, c as DIRECTIVE_BLOCK_TYPE, d as DirectiveApplyResult, e as DirectiveApplyState, f as DirectiveAskRequest, g as DirectiveCopyProps, h as DirectiveHost, i as DirectiveHostProvider, j as DirectiveHostProviderProps, k as DirectiveOpenItemOptions, l as DirectiveRecordProps, m as DirectiveRecordRef, G as GENERIC_STRUCTURED_COMPONENT_KEY, n as GenericFallbackReason, I as IR_PROVISIONAL_KEY, o as IR_ROUTE_KEY, p as IrRenderBlock, q as IrRoutableBlock, r as IrRouteMarker, s as KindRouteBinding, t as KindRouteOptions, P as PartialRenderOptions, u as ProvisionalKindRender, S as StructuredValueRenderProps, v as SupersededKindRender, w as applyIrKindRoute, x as createKindRouteBinding, y as envelopeFromPartialKind, z as isPartialReadyKind, A as isProvisionalBlock, B as kindServerDataFromStoredValue, E as markKindPartialUnsafe, F as readIrRouteMarker, H as resetPartialUnsafeKinds, J as resetSourcelessDbRowReports, L as resolveAnnouncedKindLoading, M as resolveProvisionalKindRender, N as resolveSupersededKindRender, O as routeEnvOf, Q as useDirectiveHost } from './route-Bf-kciHw.cjs';
|
|
5
5
|
import * as react from 'react';
|
|
6
6
|
import react__default, { ReactNode, ComponentType } from 'react';
|
|
7
7
|
export { ComponentResolver, ComponentResolverOptions } from './resolver.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { C as ComponentResolutionSource, a as ComponentResolution, b as ContentIrErrorReporter } from './component-resolution.types-DLO2w-0n.js';
|
|
2
2
|
export { c as ComponentRole, d as ContentIrErrorReport, J as JsonObject, K as KindComponentRow, S as SystemComponentEntry, e as consoleErrorReporter } from './component-resolution.types-DLO2w-0n.js';
|
|
3
|
-
import { C as ContentIrHost, K as KindRouteEnv, a as KindDefinitionSource } from './route-
|
|
4
|
-
export { b as ContentIrRenderSeams, D as DB_KIND_COMPONENT_KEY, c as DIRECTIVE_BLOCK_TYPE, d as DirectiveApplyResult, e as
|
|
3
|
+
import { C as ContentIrHost, K as KindRouteEnv, a as KindDefinitionSource } from './route-ymqupVjr.js';
|
|
4
|
+
export { b as ContentIrRenderSeams, D as DB_KIND_COMPONENT_KEY, c as DIRECTIVE_BLOCK_TYPE, d as DirectiveApplyResult, e as DirectiveApplyState, f as DirectiveAskRequest, g as DirectiveCopyProps, h as DirectiveHost, i as DirectiveHostProvider, j as DirectiveHostProviderProps, k as DirectiveOpenItemOptions, l as DirectiveRecordProps, m as DirectiveRecordRef, G as GENERIC_STRUCTURED_COMPONENT_KEY, n as GenericFallbackReason, I as IR_PROVISIONAL_KEY, o as IR_ROUTE_KEY, p as IrRenderBlock, q as IrRoutableBlock, r as IrRouteMarker, s as KindRouteBinding, t as KindRouteOptions, P as PartialRenderOptions, u as ProvisionalKindRender, S as StructuredValueRenderProps, v as SupersededKindRender, w as applyIrKindRoute, x as createKindRouteBinding, y as envelopeFromPartialKind, z as isPartialReadyKind, A as isProvisionalBlock, B as kindServerDataFromStoredValue, E as markKindPartialUnsafe, F as readIrRouteMarker, H as resetPartialUnsafeKinds, J as resetSourcelessDbRowReports, L as resolveAnnouncedKindLoading, M as resolveProvisionalKindRender, N as resolveSupersededKindRender, O as routeEnvOf, Q as useDirectiveHost } from './route-ymqupVjr.js';
|
|
5
5
|
import * as react from 'react';
|
|
6
6
|
import react__default, { ReactNode, ComponentType } from 'react';
|
|
7
7
|
export { ComponentResolver, ComponentResolverOptions } from './resolver.js';
|
package/dist/index.js
CHANGED
|
@@ -893,6 +893,8 @@ function classIcon(directiveClass, noun) {
|
|
|
893
893
|
|
|
894
894
|
// directives/ApplyDirectiveButton.tsx
|
|
895
895
|
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
896
|
+
var FINISH_POLL_MS = 2e3;
|
|
897
|
+
var FINISH_POLLS_MAX = 30;
|
|
896
898
|
function ApplyDirectiveButton({
|
|
897
899
|
directive,
|
|
898
900
|
label = "Apply",
|
|
@@ -900,9 +902,58 @@ function ApplyDirectiveButton({
|
|
|
900
902
|
onApplied
|
|
901
903
|
}) {
|
|
902
904
|
const host = useDirectiveHost();
|
|
903
|
-
const
|
|
905
|
+
const items = directive.items;
|
|
906
|
+
const readsLedger = !!host.applyState && !!host.confirm && directive.parsed.executes && items.length > 0;
|
|
907
|
+
const [state, setState] = useState(
|
|
908
|
+
readsLedger ? { status: "checking" } : { status: "idle" }
|
|
909
|
+
);
|
|
904
910
|
const [elapsed, setElapsed] = useState(0);
|
|
905
911
|
const startedAt = useRef(null);
|
|
912
|
+
const nounText = nounLabel(directive.noun, host.nouns);
|
|
913
|
+
const shellKey = readsLedger ? JSON.stringify([directive.slug, items]) : "";
|
|
914
|
+
const read = host.applyState;
|
|
915
|
+
const report = host.reportError;
|
|
916
|
+
useEffect(() => {
|
|
917
|
+
if (!shellKey || !read) return;
|
|
918
|
+
const [slug, shellItems] = JSON.parse(shellKey);
|
|
919
|
+
let live = true;
|
|
920
|
+
let polls = 0;
|
|
921
|
+
let timer = null;
|
|
922
|
+
const ask = () => {
|
|
923
|
+
read({ __kind: slug, items: shellItems }).then((answer) => {
|
|
924
|
+
if (!live) return;
|
|
925
|
+
if (answer.state === "applied") {
|
|
926
|
+
setState(
|
|
927
|
+
(prev) => prev.status === "checking" || prev.status === "finishing" ? {
|
|
928
|
+
status: "applied",
|
|
929
|
+
applied: shellItems.length,
|
|
930
|
+
failed: 0,
|
|
931
|
+
message: answer.message?.trim() ? answer.message.trim() : null,
|
|
932
|
+
records: answer.records ?? []
|
|
933
|
+
} : prev
|
|
934
|
+
);
|
|
935
|
+
} else if (answer.state === "in_flight" && polls < FINISH_POLLS_MAX) {
|
|
936
|
+
polls += 1;
|
|
937
|
+
setState((prev) => prev.status === "checking" || prev.status === "finishing" ? { status: "finishing" } : prev);
|
|
938
|
+
timer = setTimeout(ask, FINISH_POLL_MS);
|
|
939
|
+
} else {
|
|
940
|
+
setState((prev) => prev.status === "checking" || prev.status === "finishing" ? { status: "idle" } : prev);
|
|
941
|
+
}
|
|
942
|
+
}).catch((error) => {
|
|
943
|
+
if (!live) return;
|
|
944
|
+
const why = error instanceof Error && error.message ? error.message : String(error);
|
|
945
|
+
(report ?? console.error)(
|
|
946
|
+
`[kind-directives] Could not read whether ${slug} was already applied: ${why}`
|
|
947
|
+
);
|
|
948
|
+
setState((prev) => prev.status === "checking" || prev.status === "finishing" ? { status: "idle" } : prev);
|
|
949
|
+
});
|
|
950
|
+
};
|
|
951
|
+
ask();
|
|
952
|
+
return () => {
|
|
953
|
+
live = false;
|
|
954
|
+
if (timer) clearTimeout(timer);
|
|
955
|
+
};
|
|
956
|
+
}, [shellKey, read, report]);
|
|
906
957
|
useEffect(() => {
|
|
907
958
|
if (state.status !== "applying") return;
|
|
908
959
|
startedAt.current = Date.now();
|
|
@@ -915,7 +966,6 @@ function ApplyDirectiveButton({
|
|
|
915
966
|
if (!directive.parsed.executes) return null;
|
|
916
967
|
const confirm = host.confirm;
|
|
917
968
|
if (!confirm) return null;
|
|
918
|
-
const items = directive.items;
|
|
919
969
|
async function handleApply() {
|
|
920
970
|
if (!confirm) return;
|
|
921
971
|
if (host.ask) {
|
|
@@ -925,7 +975,7 @@ function ApplyDirectiveButton({
|
|
|
925
975
|
ok = await host.ask({
|
|
926
976
|
directive,
|
|
927
977
|
items,
|
|
928
|
-
nounLabel:
|
|
978
|
+
nounLabel: nounText
|
|
929
979
|
});
|
|
930
980
|
} catch (error) {
|
|
931
981
|
setState({
|
|
@@ -961,7 +1011,7 @@ function ApplyDirectiveButton({
|
|
|
961
1011
|
if (state.status === "applied") {
|
|
962
1012
|
const bad = state.failed > 0;
|
|
963
1013
|
const trashed = directive.directiveClass === "delete";
|
|
964
|
-
const label2 =
|
|
1014
|
+
const label2 = nounText;
|
|
965
1015
|
const records = host.renderRecord ? state.records : [];
|
|
966
1016
|
return /* @__PURE__ */ jsxs2(
|
|
967
1017
|
"span",
|
|
@@ -984,6 +1034,32 @@ function ApplyDirectiveButton({
|
|
|
984
1034
|
}
|
|
985
1035
|
);
|
|
986
1036
|
}
|
|
1037
|
+
if (state.status === "checking") {
|
|
1038
|
+
return /* @__PURE__ */ jsx4(
|
|
1039
|
+
"span",
|
|
1040
|
+
{
|
|
1041
|
+
className: "inline-flex h-6 w-6 items-center justify-center text-muted-foreground",
|
|
1042
|
+
role: "status",
|
|
1043
|
+
"aria-label": "Checking whether this already ran",
|
|
1044
|
+
"data-apply-state": "checking",
|
|
1045
|
+
children: /* @__PURE__ */ jsx4(LoaderIcon, { className: "h-3.5 w-3.5 animate-spin" })
|
|
1046
|
+
}
|
|
1047
|
+
);
|
|
1048
|
+
}
|
|
1049
|
+
if (state.status === "finishing") {
|
|
1050
|
+
return /* @__PURE__ */ jsxs2(
|
|
1051
|
+
"span",
|
|
1052
|
+
{
|
|
1053
|
+
className: "inline-flex items-center gap-1 text-xs text-muted-foreground",
|
|
1054
|
+
role: "status",
|
|
1055
|
+
"data-apply-state": "finishing",
|
|
1056
|
+
children: [
|
|
1057
|
+
/* @__PURE__ */ jsx4(LoaderIcon, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
1058
|
+
"Finishing\u2026"
|
|
1059
|
+
]
|
|
1060
|
+
}
|
|
1061
|
+
);
|
|
1062
|
+
}
|
|
987
1063
|
return /* @__PURE__ */ jsxs2("span", { className: "inline-flex items-center gap-2", children: [
|
|
988
1064
|
/* @__PURE__ */ jsxs2(
|
|
989
1065
|
"button",
|