@ai-matrx/kit 0.8.0 → 0.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/CHANGELOG.md +96 -0
- package/README.md +11 -4
- package/dist/confirm-opener.cjs.map +1 -1
- package/dist/confirm-opener.d.cts +6 -5
- package/dist/confirm-opener.d.ts +6 -5
- package/dist/confirm-opener.js.map +1 -1
- package/dist/index.cjs +53 -334
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +75 -356
- package/dist/index.js.map +1 -1
- package/package.json +4 -16
- package/dist/confirm.cjs +0 -353
- package/dist/confirm.cjs.map +0 -1
- package/dist/confirm.d.cts +0 -139
- package/dist/confirm.d.ts +0 -139
- package/dist/confirm.js +0 -321
- package/dist/confirm.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -2,7 +2,6 @@ export { AutosaveStatus, UseAutosaveResult, useAutosave } from './autosave.cjs';
|
|
|
2
2
|
export { BeginRequest, useLatestRequest } from './latest-request.cjs';
|
|
3
3
|
export { ClipboardNotifyKind, UseClipboardOptions, UseClipboardResult, useClipboard } from './clipboard.cjs';
|
|
4
4
|
export { DraftSource, LocalDraft, LocalDraftInput, captureDrafts, discardDraft, getDraft, getDraftsVersion, listDrafts, registerDraftSource, subscribeDrafts, useDurableDraft } from './drafts.cjs';
|
|
5
|
-
export { ConfirmDialog, ConfirmDialogHost, ConfirmDialogProps, ConfirmOptions, confirm } from './confirm.cjs';
|
|
6
5
|
export { CapturedToastInfo, CreateMatrxToastOptions, MatrxToast, SonnerLikeToast, ToastData, ToastMessage, createMatrxToast } from './toast.cjs';
|
|
7
6
|
export { FlushState, IdlePriority, IdleRegistration, UnregisterFn, getSchedulerState, onFlushComplete, registerIdleTask, resetScheduler, useIdleGate, useIdleReady, useIdleRegister, useIdleTask, whenPageIdle } from './idle-scheduler.cjs';
|
|
8
7
|
export { MirroredUrlStateOptions, SetUrlStateOptions, UrlHistoryMode, UrlStateCodec, UrlStateRouter, booleanUrlCodec, commitUrlParams, enumUrlCodec, historyModeForParamChange, jsonUrlCodec, positiveIntegerUrlCodec, setUrlStateRouter, stringUrlCodec, useMirroredUrlState, useUrlSearchParams, useUrlState } from './url-state.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ export { AutosaveStatus, UseAutosaveResult, useAutosave } from './autosave.js';
|
|
|
2
2
|
export { BeginRequest, useLatestRequest } from './latest-request.js';
|
|
3
3
|
export { ClipboardNotifyKind, UseClipboardOptions, UseClipboardResult, useClipboard } from './clipboard.js';
|
|
4
4
|
export { DraftSource, LocalDraft, LocalDraftInput, captureDrafts, discardDraft, getDraft, getDraftsVersion, listDrafts, registerDraftSource, subscribeDrafts, useDurableDraft } from './drafts.js';
|
|
5
|
-
export { ConfirmDialog, ConfirmDialogHost, ConfirmDialogProps, ConfirmOptions, confirm } from './confirm.js';
|
|
6
5
|
export { CapturedToastInfo, CreateMatrxToastOptions, MatrxToast, SonnerLikeToast, ToastData, ToastMessage, createMatrxToast } from './toast.js';
|
|
7
6
|
export { FlushState, IdlePriority, IdleRegistration, UnregisterFn, getSchedulerState, onFlushComplete, registerIdleTask, resetScheduler, useIdleGate, useIdleReady, useIdleRegister, useIdleTask, whenPageIdle } from './idle-scheduler.js';
|
|
8
7
|
export { MirroredUrlStateOptions, SetUrlStateOptions, UrlHistoryMode, UrlStateCodec, UrlStateRouter, booleanUrlCodec, commitUrlParams, enumUrlCodec, historyModeForParamChange, jsonUrlCodec, positiveIntegerUrlCodec, setUrlStateRouter, stringUrlCodec, useMirroredUrlState, useUrlSearchParams, useUrlState } from './url-state.js';
|
package/dist/index.js
CHANGED
|
@@ -796,320 +796,6 @@ function isLocalDraft(value) {
|
|
|
796
796
|
return typeof d.key === "string" && typeof d.namespace === "string" && typeof d.entityId === "string" && typeof d.content === "string" && typeof d.capturedAt === "number";
|
|
797
797
|
}
|
|
798
798
|
|
|
799
|
-
// src/confirm/opener.ts
|
|
800
|
-
var STATE_SLOT = /* @__PURE__ */ Symbol.for("ai-matrx.kit.confirm-opener-state");
|
|
801
|
-
function getState() {
|
|
802
|
-
const holder = globalThis;
|
|
803
|
-
let state = holder[STATE_SLOT];
|
|
804
|
-
if (!state) {
|
|
805
|
-
state = { host: null, queue: [] };
|
|
806
|
-
holder[STATE_SLOT] = state;
|
|
807
|
-
}
|
|
808
|
-
return state;
|
|
809
|
-
}
|
|
810
|
-
function _registerHost(controller) {
|
|
811
|
-
const state = getState();
|
|
812
|
-
state.host = controller;
|
|
813
|
-
while (state.queue.length > 0) {
|
|
814
|
-
const next = state.queue.shift();
|
|
815
|
-
controller.show(next.opts, next.resolve);
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
function _unregisterHost(controller) {
|
|
819
|
-
const state = getState();
|
|
820
|
-
if (state.host === controller) state.host = null;
|
|
821
|
-
}
|
|
822
|
-
function confirm(opts) {
|
|
823
|
-
return new Promise((resolve) => {
|
|
824
|
-
const state = getState();
|
|
825
|
-
if (state.host) {
|
|
826
|
-
state.host.show(opts, resolve);
|
|
827
|
-
} else {
|
|
828
|
-
state.queue.push({ opts, resolve });
|
|
829
|
-
}
|
|
830
|
-
});
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
// src/confirm/host.tsx
|
|
834
|
-
import * as React3 from "react";
|
|
835
|
-
|
|
836
|
-
// src/confirm/cn.ts
|
|
837
|
-
import { twMerge } from "tailwind-merge";
|
|
838
|
-
function cn(...values) {
|
|
839
|
-
return twMerge(values.filter(Boolean).join(" "));
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
// src/confirm/alert-dialog.tsx
|
|
843
|
-
import * as React2 from "react";
|
|
844
|
-
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
|
|
845
|
-
|
|
846
|
-
// src/react-tree.ts
|
|
847
|
-
import * as React from "react";
|
|
848
|
-
var REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal");
|
|
849
|
-
function treeContainsComponent(node, Component) {
|
|
850
|
-
if (node == null || typeof node === "boolean") return false;
|
|
851
|
-
if (Array.isArray(node)) {
|
|
852
|
-
return node.some((child) => treeContainsComponent(child, Component));
|
|
853
|
-
}
|
|
854
|
-
if (React.isValidElement(node)) {
|
|
855
|
-
if (node.type === Component) return true;
|
|
856
|
-
const props = node.props;
|
|
857
|
-
return props.children != null ? treeContainsComponent(props.children, Component) : false;
|
|
858
|
-
}
|
|
859
|
-
if (typeof node === "string" || typeof node === "number") return false;
|
|
860
|
-
if (typeof node === "object" && node.$$typeof === REACT_PORTAL_TYPE) {
|
|
861
|
-
return treeContainsComponent(
|
|
862
|
-
node.children,
|
|
863
|
-
Component
|
|
864
|
-
);
|
|
865
|
-
}
|
|
866
|
-
if (typeof node === "object" && Symbol.iterator in node) {
|
|
867
|
-
return Array.from(node).some(
|
|
868
|
-
(child) => treeContainsComponent(child, Component)
|
|
869
|
-
);
|
|
870
|
-
}
|
|
871
|
-
const runtimeProcess = globalThis.process;
|
|
872
|
-
if (runtimeProcess?.env?.NODE_ENV !== "production") {
|
|
873
|
-
const keys = typeof node === "object" ? ` with keys {${Object.keys(node).join(", ")}}` : "";
|
|
874
|
-
console.error(
|
|
875
|
-
`[treeContainsComponent] A non-renderable value${keys} is being passed as a React child. React will throw 'Objects are not valid as a React child' at the real render site. Stringify it (e.g. JSON.stringify) before rendering.`,
|
|
876
|
-
node
|
|
877
|
-
);
|
|
878
|
-
}
|
|
879
|
-
return false;
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
// src/confirm/alert-dialog.tsx
|
|
883
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
884
|
-
var buttonBase = "inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-0 disabled:pointer-events-none disabled:opacity-50 active:scale-[0.98] [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 h-9 px-4 py-2";
|
|
885
|
-
var buttonDefault = "bg-primary text-primary-foreground shadow-sm hover:bg-primary/90";
|
|
886
|
-
var buttonOutline = "border border-border bg-card shadow-sm hover:bg-accent hover:text-accent-foreground";
|
|
887
|
-
var AlertDialog = AlertDialogPrimitive.Root;
|
|
888
|
-
var AlertDialogPortal = AlertDialogPrimitive.Portal;
|
|
889
|
-
var AlertDialogOverlay = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
890
|
-
AlertDialogPrimitive.Overlay,
|
|
891
|
-
{
|
|
892
|
-
className: cn(
|
|
893
|
-
"fixed inset-0 z-[10000] bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
894
|
-
className
|
|
895
|
-
),
|
|
896
|
-
...props,
|
|
897
|
-
ref
|
|
898
|
-
}
|
|
899
|
-
));
|
|
900
|
-
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
|
|
901
|
-
var AlertDialogContentPrimitive = React2.forwardRef(({ ...props }, ref) => /* @__PURE__ */ jsx(AlertDialogPrimitive.Content, { ...props, ref, "aria-modal": "true" }));
|
|
902
|
-
AlertDialogContentPrimitive.displayName = "AlertDialogContentPrimitive";
|
|
903
|
-
var AlertDialogDescription = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
904
|
-
AlertDialogPrimitive.Description,
|
|
905
|
-
{
|
|
906
|
-
ref,
|
|
907
|
-
className: cn("text-sm text-muted-foreground", className),
|
|
908
|
-
...props
|
|
909
|
-
}
|
|
910
|
-
));
|
|
911
|
-
AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName;
|
|
912
|
-
var AlertDialogContent = React2.forwardRef(({ className, children, container, ...props }, ref) => {
|
|
913
|
-
const hasDescription = treeContainsComponent(children, AlertDialogDescription) || treeContainsComponent(children, AlertDialogPrimitive.Description);
|
|
914
|
-
return /* @__PURE__ */ jsxs(AlertDialogPortal, { container: container ?? void 0, children: [
|
|
915
|
-
/* @__PURE__ */ jsx(AlertDialogOverlay, {}),
|
|
916
|
-
/* @__PURE__ */ jsxs(
|
|
917
|
-
AlertDialogContentPrimitive,
|
|
918
|
-
{
|
|
919
|
-
ref,
|
|
920
|
-
className: cn(
|
|
921
|
-
"fixed left-[50%] top-[50%] z-[10000] grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
|
922
|
-
className
|
|
923
|
-
),
|
|
924
|
-
...props,
|
|
925
|
-
children: [
|
|
926
|
-
!hasDescription && /* @__PURE__ */ jsx(AlertDialogPrimitive.Description, { className: "sr-only", children: "Please confirm the action described in this dialog." }),
|
|
927
|
-
children
|
|
928
|
-
]
|
|
929
|
-
}
|
|
930
|
-
)
|
|
931
|
-
] });
|
|
932
|
-
});
|
|
933
|
-
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
|
|
934
|
-
var AlertDialogHeader = ({
|
|
935
|
-
className,
|
|
936
|
-
...props
|
|
937
|
-
}) => /* @__PURE__ */ jsx(
|
|
938
|
-
"div",
|
|
939
|
-
{
|
|
940
|
-
className: cn(
|
|
941
|
-
"flex flex-col space-y-2 text-center sm:text-left",
|
|
942
|
-
className
|
|
943
|
-
),
|
|
944
|
-
...props
|
|
945
|
-
}
|
|
946
|
-
);
|
|
947
|
-
AlertDialogHeader.displayName = "AlertDialogHeader";
|
|
948
|
-
var AlertDialogFooter = ({
|
|
949
|
-
className,
|
|
950
|
-
...props
|
|
951
|
-
}) => /* @__PURE__ */ jsx(
|
|
952
|
-
"div",
|
|
953
|
-
{
|
|
954
|
-
className: cn(
|
|
955
|
-
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
956
|
-
className
|
|
957
|
-
),
|
|
958
|
-
...props
|
|
959
|
-
}
|
|
960
|
-
);
|
|
961
|
-
AlertDialogFooter.displayName = "AlertDialogFooter";
|
|
962
|
-
var AlertDialogTitle = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
963
|
-
AlertDialogPrimitive.Title,
|
|
964
|
-
{
|
|
965
|
-
ref,
|
|
966
|
-
className: cn("text-lg font-semibold", className),
|
|
967
|
-
...props
|
|
968
|
-
}
|
|
969
|
-
));
|
|
970
|
-
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
|
|
971
|
-
var AlertDialogAction = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
972
|
-
AlertDialogPrimitive.Action,
|
|
973
|
-
{
|
|
974
|
-
ref,
|
|
975
|
-
className: cn(buttonBase, buttonDefault, className),
|
|
976
|
-
...props
|
|
977
|
-
}
|
|
978
|
-
));
|
|
979
|
-
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
|
|
980
|
-
var AlertDialogCancel = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
981
|
-
AlertDialogPrimitive.Cancel,
|
|
982
|
-
{
|
|
983
|
-
ref,
|
|
984
|
-
className: cn(buttonBase, buttonOutline, "mt-2 sm:mt-0", className),
|
|
985
|
-
...props
|
|
986
|
-
}
|
|
987
|
-
));
|
|
988
|
-
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
|
|
989
|
-
|
|
990
|
-
// src/confirm/confirm-dialog.tsx
|
|
991
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
992
|
-
function SpinnerIcon({ className }) {
|
|
993
|
-
return /* @__PURE__ */ jsx2(
|
|
994
|
-
"svg",
|
|
995
|
-
{
|
|
996
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
997
|
-
width: 24,
|
|
998
|
-
height: 24,
|
|
999
|
-
viewBox: "0 0 24 24",
|
|
1000
|
-
fill: "none",
|
|
1001
|
-
stroke: "currentColor",
|
|
1002
|
-
strokeWidth: 2,
|
|
1003
|
-
strokeLinecap: "round",
|
|
1004
|
-
strokeLinejoin: "round",
|
|
1005
|
-
"aria-hidden": "true",
|
|
1006
|
-
className,
|
|
1007
|
-
children: /* @__PURE__ */ jsx2("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" })
|
|
1008
|
-
}
|
|
1009
|
-
);
|
|
1010
|
-
}
|
|
1011
|
-
function ConfirmDialog({
|
|
1012
|
-
open,
|
|
1013
|
-
onOpenChange,
|
|
1014
|
-
title,
|
|
1015
|
-
description,
|
|
1016
|
-
content,
|
|
1017
|
-
contentClassName,
|
|
1018
|
-
confirmLabel = "Confirm",
|
|
1019
|
-
cancelLabel = "Cancel",
|
|
1020
|
-
variant = "default",
|
|
1021
|
-
busy = false,
|
|
1022
|
-
confirmDisabled = false,
|
|
1023
|
-
portalContainer,
|
|
1024
|
-
onConfirm
|
|
1025
|
-
}) {
|
|
1026
|
-
return /* @__PURE__ */ jsx2(AlertDialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs2(
|
|
1027
|
-
AlertDialogContent,
|
|
1028
|
-
{
|
|
1029
|
-
className: contentClassName,
|
|
1030
|
-
container: portalContainer ?? void 0,
|
|
1031
|
-
children: [
|
|
1032
|
-
/* @__PURE__ */ jsxs2(AlertDialogHeader, { children: [
|
|
1033
|
-
/* @__PURE__ */ jsx2(AlertDialogTitle, { children: title }),
|
|
1034
|
-
description ? /* @__PURE__ */ jsx2(AlertDialogDescription, { children: description }) : null
|
|
1035
|
-
] }),
|
|
1036
|
-
content ?? null,
|
|
1037
|
-
/* @__PURE__ */ jsxs2(AlertDialogFooter, { children: [
|
|
1038
|
-
cancelLabel === null ? null : /* @__PURE__ */ jsx2(AlertDialogCancel, { className: "max-lg:min-h-11", disabled: busy, children: cancelLabel }),
|
|
1039
|
-
/* @__PURE__ */ jsxs2(
|
|
1040
|
-
AlertDialogAction,
|
|
1041
|
-
{
|
|
1042
|
-
disabled: busy || confirmDisabled,
|
|
1043
|
-
onClick: (event) => {
|
|
1044
|
-
event.preventDefault();
|
|
1045
|
-
void onConfirm();
|
|
1046
|
-
},
|
|
1047
|
-
className: cn(
|
|
1048
|
-
"max-lg:min-h-11",
|
|
1049
|
-
variant === "destructive" && "bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
|
1050
|
-
),
|
|
1051
|
-
children: [
|
|
1052
|
-
busy ? /* @__PURE__ */ jsx2(SpinnerIcon, { className: "mr-2 h-4 w-4 animate-spin" }) : null,
|
|
1053
|
-
confirmLabel
|
|
1054
|
-
]
|
|
1055
|
-
}
|
|
1056
|
-
)
|
|
1057
|
-
] })
|
|
1058
|
-
]
|
|
1059
|
-
}
|
|
1060
|
-
) });
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1063
|
-
// src/confirm/host.tsx
|
|
1064
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
1065
|
-
function ConfirmDialogHost() {
|
|
1066
|
-
const [active, setActive] = React3.useState(null);
|
|
1067
|
-
const [tick, setTick] = React3.useState(0);
|
|
1068
|
-
const queueRef = React3.useRef([]);
|
|
1069
|
-
React3.useEffect(() => {
|
|
1070
|
-
const controller = {
|
|
1071
|
-
show: (opts, resolve) => {
|
|
1072
|
-
queueRef.current.push({ opts, resolve });
|
|
1073
|
-
setTick((n) => n + 1);
|
|
1074
|
-
}
|
|
1075
|
-
};
|
|
1076
|
-
_registerHost(controller);
|
|
1077
|
-
return () => _unregisterHost(controller);
|
|
1078
|
-
}, []);
|
|
1079
|
-
React3.useEffect(() => {
|
|
1080
|
-
if (active === null && queueRef.current.length > 0) {
|
|
1081
|
-
setActive(queueRef.current.shift());
|
|
1082
|
-
}
|
|
1083
|
-
}, [active, tick]);
|
|
1084
|
-
const handleConfirm = React3.useCallback(() => {
|
|
1085
|
-
if (!active) return;
|
|
1086
|
-
active.resolve(true);
|
|
1087
|
-
setActive(null);
|
|
1088
|
-
}, [active]);
|
|
1089
|
-
const handleOpenChange = React3.useCallback(
|
|
1090
|
-
(open) => {
|
|
1091
|
-
if (!open && active) {
|
|
1092
|
-
active.resolve(false);
|
|
1093
|
-
setActive(null);
|
|
1094
|
-
}
|
|
1095
|
-
},
|
|
1096
|
-
[active]
|
|
1097
|
-
);
|
|
1098
|
-
return /* @__PURE__ */ jsx3(
|
|
1099
|
-
ConfirmDialog,
|
|
1100
|
-
{
|
|
1101
|
-
open: !!active,
|
|
1102
|
-
onOpenChange: handleOpenChange,
|
|
1103
|
-
title: active?.opts.title ?? "",
|
|
1104
|
-
description: active?.opts.description,
|
|
1105
|
-
confirmLabel: active?.opts.confirmLabel,
|
|
1106
|
-
cancelLabel: active?.opts.cancelLabel,
|
|
1107
|
-
variant: active?.opts.variant,
|
|
1108
|
-
onConfirm: handleConfirm
|
|
1109
|
-
}
|
|
1110
|
-
);
|
|
1111
|
-
}
|
|
1112
|
-
|
|
1113
799
|
// src/toast.ts
|
|
1114
800
|
function messageText(message, data) {
|
|
1115
801
|
const description = data && typeof data.description === "string" ? data.description : "";
|
|
@@ -1160,13 +846,13 @@ function createMatrxToast({
|
|
|
1160
846
|
}
|
|
1161
847
|
|
|
1162
848
|
// src/invalidation.ts
|
|
1163
|
-
var
|
|
849
|
+
var STATE_SLOT = /* @__PURE__ */ Symbol.for("ai-matrx.kit.invalidation-registry");
|
|
1164
850
|
function getCallbacks() {
|
|
1165
851
|
const holder = globalThis;
|
|
1166
|
-
let state = holder[
|
|
852
|
+
let state = holder[STATE_SLOT];
|
|
1167
853
|
if (!state) {
|
|
1168
854
|
state = /* @__PURE__ */ new Map();
|
|
1169
|
-
holder[
|
|
855
|
+
holder[STATE_SLOT] = state;
|
|
1170
856
|
}
|
|
1171
857
|
return state;
|
|
1172
858
|
}
|
|
@@ -1620,10 +1306,10 @@ function formatJsonText(text, options) {
|
|
|
1620
1306
|
}
|
|
1621
1307
|
|
|
1622
1308
|
// src/idle-scheduler/scheduler.ts
|
|
1623
|
-
var
|
|
1624
|
-
function
|
|
1309
|
+
var STATE_SLOT2 = /* @__PURE__ */ Symbol.for("ai-matrx.kit.idle-scheduler-state");
|
|
1310
|
+
function getState() {
|
|
1625
1311
|
const holder = globalThis;
|
|
1626
|
-
let state = holder[
|
|
1312
|
+
let state = holder[STATE_SLOT2];
|
|
1627
1313
|
if (!state) {
|
|
1628
1314
|
state = {
|
|
1629
1315
|
queue: /* @__PURE__ */ new Map(),
|
|
@@ -1631,7 +1317,7 @@ function getState2() {
|
|
|
1631
1317
|
cleanupFns: [],
|
|
1632
1318
|
flushListeners: /* @__PURE__ */ new Set()
|
|
1633
1319
|
};
|
|
1634
|
-
holder[
|
|
1320
|
+
holder[STATE_SLOT2] = state;
|
|
1635
1321
|
if (typeof window !== "undefined") {
|
|
1636
1322
|
window.__idleSched = getSchedulerState;
|
|
1637
1323
|
}
|
|
@@ -1639,7 +1325,7 @@ function getState2() {
|
|
|
1639
1325
|
return state;
|
|
1640
1326
|
}
|
|
1641
1327
|
function registerIdleTask(key, priority, callback) {
|
|
1642
|
-
const state =
|
|
1328
|
+
const state = getState();
|
|
1643
1329
|
if (state.flushState === "done") {
|
|
1644
1330
|
scheduleImmediate(callback);
|
|
1645
1331
|
return () => {
|
|
@@ -1654,7 +1340,7 @@ function registerIdleTask(key, priority, callback) {
|
|
|
1654
1340
|
};
|
|
1655
1341
|
}
|
|
1656
1342
|
function onFlushComplete(listener) {
|
|
1657
|
-
const state =
|
|
1343
|
+
const state = getState();
|
|
1658
1344
|
if (state.flushState === "done") {
|
|
1659
1345
|
queueMicrotask(listener);
|
|
1660
1346
|
return () => {
|
|
@@ -1687,7 +1373,7 @@ function whenPageIdle(signal) {
|
|
|
1687
1373
|
});
|
|
1688
1374
|
}
|
|
1689
1375
|
function getSchedulerState() {
|
|
1690
|
-
const state =
|
|
1376
|
+
const state = getState();
|
|
1691
1377
|
return {
|
|
1692
1378
|
flushState: state.flushState,
|
|
1693
1379
|
pendingCount: state.queue.size,
|
|
@@ -1695,7 +1381,7 @@ function getSchedulerState() {
|
|
|
1695
1381
|
};
|
|
1696
1382
|
}
|
|
1697
1383
|
function resetScheduler() {
|
|
1698
|
-
const state =
|
|
1384
|
+
const state = getState();
|
|
1699
1385
|
state.cleanupFns.forEach((fn) => fn());
|
|
1700
1386
|
state.cleanupFns = [];
|
|
1701
1387
|
state.queue.clear();
|
|
@@ -1799,11 +1485,11 @@ function scheduleImmediate(callback) {
|
|
|
1799
1485
|
}
|
|
1800
1486
|
|
|
1801
1487
|
// src/idle-scheduler/hooks.ts
|
|
1802
|
-
import { useEffect as
|
|
1488
|
+
import { useEffect as useEffect3, useRef as useRef4, useState as useState4, useCallback as useCallback3 } from "react";
|
|
1803
1489
|
function useIdleTask(key, priority, callback) {
|
|
1804
|
-
const callbackRef =
|
|
1490
|
+
const callbackRef = useRef4(callback);
|
|
1805
1491
|
callbackRef.current = callback;
|
|
1806
|
-
|
|
1492
|
+
useEffect3(() => {
|
|
1807
1493
|
const unregister = registerIdleTask(key, priority, () => {
|
|
1808
1494
|
return callbackRef.current();
|
|
1809
1495
|
});
|
|
@@ -1811,8 +1497,8 @@ function useIdleTask(key, priority, callback) {
|
|
|
1811
1497
|
}, [key, priority]);
|
|
1812
1498
|
}
|
|
1813
1499
|
function useIdleReady() {
|
|
1814
|
-
const [ready, setReady] =
|
|
1815
|
-
|
|
1500
|
+
const [ready, setReady] = useState4(false);
|
|
1501
|
+
useEffect3(() => {
|
|
1816
1502
|
const unsubscribe = onFlushComplete(() => {
|
|
1817
1503
|
setReady(true);
|
|
1818
1504
|
});
|
|
@@ -1821,10 +1507,10 @@ function useIdleReady() {
|
|
|
1821
1507
|
return ready;
|
|
1822
1508
|
}
|
|
1823
1509
|
function useIdleGate(key, priority, callback) {
|
|
1824
|
-
const [ready, setReady] =
|
|
1825
|
-
const callbackRef =
|
|
1510
|
+
const [ready, setReady] = useState4(false);
|
|
1511
|
+
const callbackRef = useRef4(callback);
|
|
1826
1512
|
callbackRef.current = callback;
|
|
1827
|
-
|
|
1513
|
+
useEffect3(() => {
|
|
1828
1514
|
const unregister = registerIdleTask(key, priority, async () => {
|
|
1829
1515
|
await callbackRef.current();
|
|
1830
1516
|
setReady(true);
|
|
@@ -1834,15 +1520,15 @@ function useIdleGate(key, priority, callback) {
|
|
|
1834
1520
|
return { ready };
|
|
1835
1521
|
}
|
|
1836
1522
|
function useIdleRegister() {
|
|
1837
|
-
const unregisterRefs =
|
|
1838
|
-
|
|
1523
|
+
const unregisterRefs = useRef4(/* @__PURE__ */ new Map());
|
|
1524
|
+
useEffect3(() => {
|
|
1839
1525
|
const refs = unregisterRefs.current;
|
|
1840
1526
|
return () => {
|
|
1841
1527
|
refs.forEach((unregister) => unregister());
|
|
1842
1528
|
refs.clear();
|
|
1843
1529
|
};
|
|
1844
1530
|
}, []);
|
|
1845
|
-
return
|
|
1531
|
+
return useCallback3(
|
|
1846
1532
|
(key, priority, callback) => {
|
|
1847
1533
|
unregisterRefs.current.get(key)?.();
|
|
1848
1534
|
const unregister = registerIdleTask(key, priority, callback);
|
|
@@ -1854,11 +1540,11 @@ function useIdleRegister() {
|
|
|
1854
1540
|
|
|
1855
1541
|
// src/url-state.ts
|
|
1856
1542
|
import {
|
|
1857
|
-
useCallback as
|
|
1858
|
-
useEffect as
|
|
1543
|
+
useCallback as useCallback4,
|
|
1544
|
+
useEffect as useEffect4,
|
|
1859
1545
|
useMemo,
|
|
1860
|
-
useRef as
|
|
1861
|
-
useState as
|
|
1546
|
+
useRef as useRef5,
|
|
1547
|
+
useState as useState5,
|
|
1862
1548
|
useSyncExternalStore
|
|
1863
1549
|
} from "react";
|
|
1864
1550
|
var URL_STATE_EVENT = "matrx:url-state";
|
|
@@ -1991,14 +1677,14 @@ function jsonUrlCodec(defaultValue, isValid) {
|
|
|
1991
1677
|
function useMirroredUrlState(options) {
|
|
1992
1678
|
const { parse, toParams, isSame, textKeys = [], resetKey } = options;
|
|
1993
1679
|
const params = useUrlSearchParams();
|
|
1994
|
-
const optionsRef =
|
|
1680
|
+
const optionsRef = useRef5(options);
|
|
1995
1681
|
optionsRef.current = options;
|
|
1996
|
-
const [value, setValue] =
|
|
1682
|
+
const [value, setValue] = useState5(
|
|
1997
1683
|
() => parse(
|
|
1998
1684
|
typeof window === "undefined" ? new URLSearchParams() : new URLSearchParams(currentLocation().search)
|
|
1999
1685
|
)
|
|
2000
1686
|
);
|
|
2001
|
-
|
|
1687
|
+
useEffect4(() => {
|
|
2002
1688
|
if (typeof window === "undefined") return;
|
|
2003
1689
|
const current = new URLSearchParams(currentLocation().search);
|
|
2004
1690
|
const patch = optionsRef.current.toParams(value);
|
|
@@ -2010,14 +1696,14 @@ function useMirroredUrlState(options) {
|
|
|
2010
1696
|
if (next.toString() === current.toString()) return;
|
|
2011
1697
|
commitUrlParams(patch, historyModeForParamChange(current, next, textKeys));
|
|
2012
1698
|
}, [value]);
|
|
2013
|
-
|
|
1699
|
+
useEffect4(() => {
|
|
2014
1700
|
const fromUrl = optionsRef.current.parse(
|
|
2015
1701
|
new URLSearchParams(currentLocation().search)
|
|
2016
1702
|
);
|
|
2017
1703
|
setValue((prev) => optionsRef.current.isSame(prev, fromUrl) ? prev : fromUrl);
|
|
2018
1704
|
}, [params]);
|
|
2019
|
-
const previousResetKey =
|
|
2020
|
-
|
|
1705
|
+
const previousResetKey = useRef5(resetKey);
|
|
1706
|
+
useEffect4(() => {
|
|
2021
1707
|
const previous = previousResetKey.current;
|
|
2022
1708
|
previousResetKey.current = resetKey;
|
|
2023
1709
|
if (previous === resetKey) return;
|
|
@@ -2027,7 +1713,7 @@ function useMirroredUrlState(options) {
|
|
|
2027
1713
|
setValue(cleared);
|
|
2028
1714
|
commitUrlParams(optionsRef.current.toParams(cleared), "replace");
|
|
2029
1715
|
}, [resetKey]);
|
|
2030
|
-
const update =
|
|
1716
|
+
const update = useCallback4((updater) => {
|
|
2031
1717
|
setValue(
|
|
2032
1718
|
(prev) => typeof updater === "function" ? updater(prev) : updater
|
|
2033
1719
|
);
|
|
@@ -2162,25 +1848,25 @@ var FeatureStore = class extends PublicStoreManager {
|
|
|
2162
1848
|
};
|
|
2163
1849
|
|
|
2164
1850
|
// src/idb-store/singleton.ts
|
|
2165
|
-
var
|
|
2166
|
-
function
|
|
1851
|
+
var STATE_SLOT3 = /* @__PURE__ */ Symbol.for("ai-matrx.kit.idb-store-state");
|
|
1852
|
+
function getState2() {
|
|
2167
1853
|
const holder = globalThis;
|
|
2168
|
-
let state = holder[
|
|
1854
|
+
let state = holder[STATE_SLOT3];
|
|
2169
1855
|
if (!state) {
|
|
2170
1856
|
state = { instances: /* @__PURE__ */ new Map() };
|
|
2171
|
-
holder[
|
|
1857
|
+
holder[STATE_SLOT3] = state;
|
|
2172
1858
|
}
|
|
2173
1859
|
return state;
|
|
2174
1860
|
}
|
|
2175
1861
|
function getIdbStoreSingleton(key, create) {
|
|
2176
|
-
const state =
|
|
1862
|
+
const state = getState2();
|
|
2177
1863
|
if (!state.instances.has(key)) {
|
|
2178
1864
|
state.instances.set(key, create());
|
|
2179
1865
|
}
|
|
2180
1866
|
return state.instances.get(key);
|
|
2181
1867
|
}
|
|
2182
1868
|
function _resetIdbStoreSingletons() {
|
|
2183
|
-
|
|
1869
|
+
getState2().instances.clear();
|
|
2184
1870
|
}
|
|
2185
1871
|
|
|
2186
1872
|
// src/color-util/lab-delta.ts
|
|
@@ -2926,6 +2612,42 @@ function createColorNormalizer({ isValid }) {
|
|
|
2926
2612
|
};
|
|
2927
2613
|
}
|
|
2928
2614
|
|
|
2615
|
+
// src/react-tree.ts
|
|
2616
|
+
import * as React from "react";
|
|
2617
|
+
var REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal");
|
|
2618
|
+
function treeContainsComponent(node, Component) {
|
|
2619
|
+
if (node == null || typeof node === "boolean") return false;
|
|
2620
|
+
if (Array.isArray(node)) {
|
|
2621
|
+
return node.some((child) => treeContainsComponent(child, Component));
|
|
2622
|
+
}
|
|
2623
|
+
if (React.isValidElement(node)) {
|
|
2624
|
+
if (node.type === Component) return true;
|
|
2625
|
+
const props = node.props;
|
|
2626
|
+
return props.children != null ? treeContainsComponent(props.children, Component) : false;
|
|
2627
|
+
}
|
|
2628
|
+
if (typeof node === "string" || typeof node === "number") return false;
|
|
2629
|
+
if (typeof node === "object" && node.$$typeof === REACT_PORTAL_TYPE) {
|
|
2630
|
+
return treeContainsComponent(
|
|
2631
|
+
node.children,
|
|
2632
|
+
Component
|
|
2633
|
+
);
|
|
2634
|
+
}
|
|
2635
|
+
if (typeof node === "object" && Symbol.iterator in node) {
|
|
2636
|
+
return Array.from(node).some(
|
|
2637
|
+
(child) => treeContainsComponent(child, Component)
|
|
2638
|
+
);
|
|
2639
|
+
}
|
|
2640
|
+
const runtimeProcess = globalThis.process;
|
|
2641
|
+
if (runtimeProcess?.env?.NODE_ENV !== "production") {
|
|
2642
|
+
const keys = typeof node === "object" ? ` with keys {${Object.keys(node).join(", ")}}` : "";
|
|
2643
|
+
console.error(
|
|
2644
|
+
`[treeContainsComponent] A non-renderable value${keys} is being passed as a React child. React will throw 'Objects are not valid as a React child' at the real render site. Stringify it (e.g. JSON.stringify) before rendering.`,
|
|
2645
|
+
node
|
|
2646
|
+
);
|
|
2647
|
+
}
|
|
2648
|
+
return false;
|
|
2649
|
+
}
|
|
2650
|
+
|
|
2929
2651
|
// src/qr.ts
|
|
2930
2652
|
var MAX_EDGE = 1600;
|
|
2931
2653
|
function nativeDetector() {
|
|
@@ -2998,8 +2720,6 @@ async function decodeQrFromImageFile(file) {
|
|
|
2998
2720
|
}
|
|
2999
2721
|
}
|
|
3000
2722
|
export {
|
|
3001
|
-
ConfirmDialog,
|
|
3002
|
-
ConfirmDialogHost,
|
|
3003
2723
|
DBStoreManager,
|
|
3004
2724
|
DEFAULT_JSON_INDENT,
|
|
3005
2725
|
DEFAULT_JSON_WIDTH,
|
|
@@ -3011,7 +2731,6 @@ export {
|
|
|
3011
2731
|
captureDrafts,
|
|
3012
2732
|
commitUrlParams,
|
|
3013
2733
|
computeSearchScore,
|
|
3014
|
-
confirm,
|
|
3015
2734
|
createColorNormalizer,
|
|
3016
2735
|
createFormatter,
|
|
3017
2736
|
createMatrxToast,
|