@plitzi/sdk-shared 0.33.1 → 0.34.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 +64 -0
- package/dist/actions/cron.d.ts +34 -0
- package/dist/actions/cron.mjs +72 -0
- package/dist/actions/index.d.ts +6 -0
- package/dist/actions/index.mjs +5 -0
- package/dist/actions/triggerParams.d.ts +41 -0
- package/dist/actions/triggerParams.mjs +40 -0
- package/dist/actions/triggers.d.ts +29 -0
- package/dist/actions/triggers.mjs +4 -0
- package/dist/actions/validateDocument.d.ts +23 -0
- package/dist/actions/validateDocument.mjs +267 -0
- package/dist/auth/failureChannel.d.ts +9 -4
- package/dist/auth/failureChannel.mjs +3 -2
- package/dist/authoring/builder.d.ts +51 -0
- package/dist/authoring/builder.mjs +29 -0
- package/dist/authoring/declare.d.ts +64 -0
- package/dist/authoring/declare.mjs +4 -0
- package/dist/authoring/elementCallbacks.d.ts +13 -0
- package/dist/authoring/elementCallbacks.mjs +71 -0
- package/dist/authoring/index.d.ts +21 -0
- package/dist/authoring/index.mjs +6 -0
- package/dist/authoring/paramSpec.d.ts +51 -0
- package/dist/authoring/paramSpec.mjs +40 -0
- package/dist/authoring/spaceCallbacks.d.ts +10 -0
- package/dist/authoring/spaceCallbacks.mjs +51 -0
- package/dist/builder/contexts/BuilderContext.d.ts +2 -4
- package/dist/dataSource/getBindingsDetails.mjs +2 -2
- package/dist/dataSource/helpers/getSourceName.d.ts +1 -3
- package/dist/dataSource/helpers/getSourceName.mjs +1 -1
- package/dist/dataSource/index.d.ts +2 -0
- package/dist/dataSource/index.mjs +6 -5
- package/dist/dataSource/resolveVariables.d.ts +22 -0
- package/dist/dataSource/resolveVariables.mjs +16 -0
- package/dist/dataSource/utility/index.mjs +15 -13
- package/dist/dataSource/utility/not.d.ts +11 -0
- package/dist/dataSource/utility/not.mjs +15 -0
- package/dist/dataSource/utility/styleVariant.mjs +1 -1
- package/dist/devTools/debugCookie.d.ts +16 -0
- package/dist/devTools/debugCookie.mjs +7 -0
- package/dist/devTools/index.d.ts +6 -2
- package/dist/devTools/index.mjs +4 -2
- package/dist/devTools/interactionLog.d.ts +14 -0
- package/dist/devTools/interactionLog.mjs +4 -0
- package/dist/helpers/index.d.ts +2 -0
- package/dist/helpers/index.mjs +11 -9
- package/dist/helpers/reducerOrigin.d.ts +15 -0
- package/dist/helpers/reducerOrigin.mjs +4 -0
- package/dist/helpers/ruleEvaluator.d.ts +14 -0
- package/dist/helpers/ruleEvaluator.mjs +5 -0
- package/dist/helpers/twigWrapper/AST.d.ts +12 -1
- package/dist/helpers/twigWrapper/AST.mjs +0 -0
- package/dist/helpers/twigWrapper/Evaluator/Evaluator.mjs +7 -0
- package/dist/helpers/twigWrapper/Parser/Cursor.d.ts +7 -0
- package/dist/helpers/twigWrapper/Parser/Cursor.mjs +5 -0
- package/dist/helpers/twigWrapper/Parser/ExpressionParser.mjs +46 -8
- package/dist/helpers/twigWrapper/Parser/types.mjs +0 -0
- package/dist/helpers/twigWrapper/charClass.d.ts +7 -0
- package/dist/helpers/twigWrapper/charClass.mjs +16 -12
- package/dist/helpers/twigWrapper/tokens/tokenPatterns.mjs +2 -2
- package/dist/helpers/utils.d.ts +0 -2
- package/dist/helpers/utils.mjs +16 -19
- package/dist/hooks/index.d.ts +2 -1
- package/dist/hooks/index.mjs +4 -3
- package/dist/hooks/useFontHead.d.ts +3 -0
- package/dist/hooks/useFontHead.mjs +23 -0
- package/dist/hooks/usePlitziServiceContext.d.ts +3 -2
- package/dist/index.mjs +61 -45
- package/dist/navigation/index.d.ts +1 -1
- package/dist/navigation/index.mjs +2 -2
- package/dist/navigation/routes.d.ts +8 -0
- package/dist/navigation/routes.mjs +39 -39
- package/dist/network/graphql/builder/Mutations/Segment/SegmentAddMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Segment/SegmentAddTemplateMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Segment/SegmentUpdateMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentAddElementMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentCloneElementMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentMoveElementMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRemoveElementMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRenameElementMutation.d.ts +3 -0
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRenameElementMutation.mjs +9 -0
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementsMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceAddElementMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceAddTemplateMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceCloneElementMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceMoveElementMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceRemoveElementMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceRenameElementMutation.d.ts +5 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceRenameElementMutation.mjs +9 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateElementMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateElementsMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateSchemaMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceAddActionMutation.d.ts +8 -0
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceAddActionMutation.mjs +16 -0
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceRemoveActionMutation.d.ts +4 -0
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceRemoveActionMutation.mjs +16 -0
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceRunActionMutation.d.ts +4 -0
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceRunActionMutation.mjs +14 -0
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceUpdateActionMutation.d.ts +4 -0
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceUpdateActionMutation.mjs +16 -0
- package/dist/network/graphql/builder/Mutations/Space/pages/SpaceAddPageMutation.mjs +2 -3
- package/dist/network/graphql/builder/Mutations/Space/pages/SpaceUpdatePageMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Style/fonts/StyleAddFontMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Style/fonts/StyleAddFontMutation.mjs +11 -0
- package/dist/network/graphql/builder/Mutations/Style/fonts/StyleRemoveFontMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Style/fonts/StyleRemoveFontMutation.mjs +11 -0
- package/dist/network/graphql/builder/Mutations/Style/fonts/StyleUpdateFontMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Style/fonts/StyleUpdateFontMutation.mjs +11 -0
- package/dist/network/graphql/builder/Mutations/index.d.ts +24 -0
- package/dist/network/graphql/builder/Mutations/index.mjs +150 -132
- package/dist/network/graphql/builder/Queries/InitQuery.mjs +1 -2
- package/dist/network/graphql/builder/Queries/Segment/SegmentQuery.mjs +0 -1
- package/dist/network/graphql/builder/Queries/Segment/SegmentsQuery.mjs +0 -1
- package/dist/network/graphql/builder/Queries/Space/SpaceActionEventsQuery.d.ts +9 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceActionEventsQuery.mjs +30 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceActionTasksQuery.d.ts +6 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceActionTasksQuery.mjs +16 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceActionsQuery.d.ts +9 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceActionsQuery.mjs +25 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceCheckActionQuery.d.ts +6 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceCheckActionQuery.mjs +17 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceQuotaQuery.d.ts +30 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceQuotaQuery.mjs +40 -0
- package/dist/network/graphql/builder/Queries/index.d.ts +16 -0
- package/dist/network/graphql/builder/Queries/index.mjs +24 -14
- package/dist/network/graphql/sdk/Queries/InitQuery.d.ts +4 -0
- package/dist/network/graphql/sdk/Queries/InitQuery.mjs +5 -2
- package/dist/network/graphql/sdk/Queries/Segment/SegmentQuery.mjs +0 -1
- package/dist/network/graphql/sdk/Queries/Segment/SegmentsQuery.mjs +0 -1
- package/dist/network/spaceEvents.d.ts +20 -1
- package/dist/network/spaceEvents.mjs +89 -74
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.mjs +2 -1
- package/dist/schema/serverElements.d.ts +16 -0
- package/dist/schema/serverElements.mjs +18 -0
- package/dist/server/actions/useActionsSync.d.ts +10 -0
- package/dist/server/actions/useActionsSync.mjs +7 -0
- package/dist/server/index.d.ts +2 -1
- package/dist/server/index.mjs +5 -4
- package/dist/server/rsc/refreshRsc.d.ts +11 -1
- package/dist/server/rsc/refreshRsc.mjs +30 -12
- package/dist/server/rsc/useRscSync.mjs +20 -13
- package/dist/state/runtimeStatePersist.mjs +4 -3
- package/dist/store/actionRuns/actionRunsRecorder.d.ts +36 -0
- package/dist/store/actionRuns/actionRunsRecorder.mjs +39 -0
- package/dist/store/actionRuns/actionRunsStore.d.ts +16 -0
- package/dist/store/actionRuns/actionRunsStore.mjs +5 -0
- package/dist/store/actionRuns/index.d.ts +6 -0
- package/dist/store/actionRuns/index.mjs +4 -0
- package/dist/store/actionRuns/useActionRuns.d.ts +13 -0
- package/dist/store/actionRuns/useActionRuns.mjs +10 -0
- package/dist/store/index.d.ts +46 -45
- package/dist/store/index.mjs +6 -3
- package/dist/store/renderSettings.d.ts +3 -0
- package/dist/store/renderSettings.mjs +17 -5
- package/dist/store/tracing/tracingCollector.d.ts +1 -1
- package/dist/store/tracing/tracingCollector.mjs +37 -35
- package/dist/store/tracing/tracingStore.d.ts +13 -0
- package/dist/store/tracing/tracingStore.mjs +3 -3
- package/dist/style/fontAssets.d.ts +12 -0
- package/dist/style/fontAssets.mjs +18 -0
- package/dist/style/fontValidation.d.ts +8 -0
- package/dist/style/fontValidation.mjs +107 -0
- package/dist/style/fonts.d.ts +74 -0
- package/dist/style/fonts.mjs +198 -0
- package/dist/style/fontsFromCss.d.ts +27 -0
- package/dist/style/fontsFromCss.mjs +43 -0
- package/dist/style/index.d.ts +4 -0
- package/dist/style/index.mjs +5 -1
- package/dist/style/styleConstants.d.ts +2 -2
- package/dist/style/styleConstants.mjs +1 -0
- package/dist/theme/ThemeProvider.d.ts +36 -6
- package/dist/theme/ThemeProvider.mjs +49 -35
- package/dist/theme/ThemeScope.d.ts +16 -0
- package/dist/theme/ThemeScope.mjs +6 -0
- package/dist/theme/index.d.ts +7 -1
- package/dist/theme/index.mjs +6 -2
- package/dist/theme/themeCookie.d.ts +30 -0
- package/dist/theme/themeCookie.mjs +24 -0
- package/dist/theme/themeStore.d.ts +40 -0
- package/dist/theme/themeStore.mjs +17 -0
- package/dist/theme/useTheme.d.ts +29 -0
- package/dist/theme/useTheme.mjs +20 -0
- package/dist/types/ActionTypes.d.ts +396 -0
- package/dist/types/ActionTypes.mjs +0 -0
- package/dist/types/AuthTypes.d.ts +23 -2
- package/dist/types/BuilderTypes.d.ts +0 -12
- package/dist/types/CommonTypes.d.ts +13 -0
- package/dist/types/DevToolsTypes.d.ts +57 -14
- package/dist/types/EventBridgeTypes.d.ts +1 -1
- package/dist/types/InteractionTypes.d.ts +23 -3
- package/dist/types/PluginTypes.d.ts +0 -3
- package/dist/types/SchemaTypes.d.ts +29 -4
- package/dist/types/ServerTypes.d.ts +390 -46
- package/dist/types/SpaceTypes.d.ts +16 -0
- package/dist/types/StoreTypes.d.ts +181 -3
- package/dist/types/StyleTypes.d.ts +83 -4
- package/dist/types/TemplateTypes.d.ts +20 -0
- package/dist/types/TemplateTypes.mjs +0 -0
- package/dist/types/ThemeTypes.d.ts +28 -1
- package/dist/types/index.d.ts +2 -0
- package/eslint.config.mjs +2 -0
- package/package.json +244 -29
- package/vite.config.ts +27 -7
|
@@ -1,16 +1,34 @@
|
|
|
1
|
+
import { authFailureFromResponse as e, reportAuthFailure as t } from "../../auth/failureChannel.mjs";
|
|
2
|
+
import { hasServerElements as n } from "../../schema/serverElements.mjs";
|
|
3
|
+
import { getPaths as r, matchRoutePath as i } from "../../navigation/routes.mjs";
|
|
1
4
|
//#region src/server/rsc/refreshRsc.ts
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
var a = (e, t, n) => {
|
|
6
|
+
if (!e) return;
|
|
7
|
+
let a = e.pages.reduce((t, n) => (n in e.flat && (t[n] = e.flat[n]), t), {});
|
|
8
|
+
return i(r(a, e.pageFolders, n), t.split("?")[0], n).pageId;
|
|
9
|
+
}, o = (e) => `rsc.data.${e}`, s = () => typeof window > "u" ? "" : `${window.location.pathname}${window.location.search}`, c = async (r, i, c, l) => {
|
|
10
|
+
let { enabled: u, endpoint: d } = r.get("rsc") ?? {};
|
|
11
|
+
if (!u || !d || typeof window > "u") return;
|
|
12
|
+
let f = l ?? s(), p = r.get("schema"), m = r.get("runtime.sources.auth"), h = l ? a(p, l, !!m?.details) : r.get("navigation.currentPageId");
|
|
13
|
+
if (p && n(p, h)) try {
|
|
14
|
+
let n = new URLSearchParams({ location: f });
|
|
15
|
+
i?.length && n.set("ids", i.join(",")), Object.entries(c ?? {}).forEach(([e, t]) => n.set(e, t));
|
|
16
|
+
let a = await fetch(`${d}?${n.toString()}`, { headers: { Accept: "application/json" } });
|
|
17
|
+
if (!a.ok) {
|
|
18
|
+
let n = e(a.status, await a.json().catch(() => void 0));
|
|
19
|
+
n && t({
|
|
20
|
+
reason: n,
|
|
21
|
+
url: d
|
|
22
|
+
}), r.set("rsc.stale", !0);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
let { serverData: s } = await a.json();
|
|
26
|
+
r.batch(() => {
|
|
27
|
+
i?.length ? Object.entries(s ?? {}).forEach(([e, t]) => r.set(o(e), t)) : r.set("rsc.data", s ?? {}), r.set("rsc.loaded", !0), r.set("rsc.stale", !1), r.set("rsc.location", f);
|
|
12
28
|
});
|
|
13
|
-
} catch {
|
|
29
|
+
} catch {
|
|
30
|
+
r.set("rsc.stale", !0);
|
|
31
|
+
}
|
|
14
32
|
};
|
|
15
33
|
//#endregion
|
|
16
|
-
export {
|
|
34
|
+
export { s as currentRscLocation, c as default, c as refreshRsc, o as rscDataPath };
|
|
@@ -1,20 +1,27 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
import {
|
|
3
|
-
import { useEffect as
|
|
4
|
-
import { useStoreById as
|
|
1
|
+
import { useCommonStore as e, useCommonStoreSync as t } from "../../store/index.mjs";
|
|
2
|
+
import n, { currentRscLocation as r } from "./refreshRsc.mjs";
|
|
3
|
+
import { useEffect as i, useRef as a } from "react";
|
|
4
|
+
import { useStoreById as o } from "@plitzi/nexus/react";
|
|
5
5
|
//#region src/server/rsc/useRscSync.ts
|
|
6
|
-
var
|
|
7
|
-
let
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
var s = (s) => {
|
|
7
|
+
let c = o(), [l] = e("schema.rsc", { mode: "mount" }), [u] = e("runtime.sources.navigation"), { rscData: d, rscPath: f } = s ?? {}, p = (l?.enabled ?? !1) && !!f;
|
|
8
|
+
t(["rsc.enabled", "rsc.endpoint"], [p, f]), t([
|
|
9
|
+
"rsc.data",
|
|
10
|
+
"rsc.loaded",
|
|
11
|
+
"rsc.location"
|
|
12
|
+
], [
|
|
13
|
+
d?.serverData ?? {},
|
|
14
|
+
d !== void 0,
|
|
15
|
+
r()
|
|
16
|
+
], { mode: "mount" });
|
|
17
|
+
let m = JSON.stringify(u ?? {}), h = a(d === void 0 ? void 0 : m);
|
|
18
|
+
i(() => {
|
|
19
|
+
p && m !== h.current && (h.current = m, n(c));
|
|
12
20
|
}, [
|
|
13
|
-
f,
|
|
14
21
|
p,
|
|
15
22
|
m,
|
|
16
|
-
|
|
23
|
+
c
|
|
17
24
|
]);
|
|
18
25
|
};
|
|
19
26
|
//#endregion
|
|
20
|
-
export {
|
|
27
|
+
export { s as default };
|
|
@@ -3,9 +3,10 @@ import { persistMiddleware as e } from "@plitzi/nexus";
|
|
|
3
3
|
var t = (t) => e({
|
|
4
4
|
key: `plitzi_${t}_state`,
|
|
5
5
|
paths: ["runtime.state"],
|
|
6
|
-
storage: ({ schema: e }) => {
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
storage: ({ schema: e, render: t }) => {
|
|
7
|
+
if (t?.isHydrating && !t.hydrated) return !1;
|
|
8
|
+
let n = e?.settings;
|
|
9
|
+
return n?.keepState ? n.stateStorage === "sessionStorage" ? "session" : "local" : !1;
|
|
9
10
|
}
|
|
10
11
|
});
|
|
11
12
|
//#endregion
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ActionRunEntry } from '../../types';
|
|
2
|
+
/** Registered by whatever started the run, for as long as stopping it means anything. */
|
|
3
|
+
export declare const registerActionCanceller: (id: string, cancel: () => void) => void;
|
|
4
|
+
export declare const releaseActionCanceller: (id: string) => void;
|
|
5
|
+
/**
|
|
6
|
+
* Stops a run from outside the flow that started it — the dev-tools panel, today.
|
|
7
|
+
*
|
|
8
|
+
* It is deliberately the step's own canceller rather than a request built here: a run is stopped by aborting the
|
|
9
|
+
* request that carries it AND, when the server has already named it, by telling the server so. Which of those
|
|
10
|
+
* apply is something only the step knows.
|
|
11
|
+
*/
|
|
12
|
+
export declare const cancelActionRun: (id: string) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Records a run this page STARTED, the moment it is sent.
|
|
15
|
+
*
|
|
16
|
+
* Written when the request leaves rather than when it answers, because the interesting failures are the ones with
|
|
17
|
+
* no answer: a detached run whose response nobody awaits, a stream that never opens, a server that is not there.
|
|
18
|
+
* A record that only appeared on success would be missing exactly the runs somebody is looking for.
|
|
19
|
+
*/
|
|
20
|
+
export declare const recordActionRun: (entry: Omit<ActionRunEntry, "id" | "startedAt" | "status" | "progress">) => string;
|
|
21
|
+
/** How it ended, or what it reported on the way. Unknown ids are ignored: a swept-out run is not an error. */
|
|
22
|
+
export declare const updateActionRun: (id: string, patch: Partial<Omit<ActionRunEntry, "id">>) => void;
|
|
23
|
+
/**
|
|
24
|
+
* One chunk a streaming run emitted, kept in order beside the run it belongs to.
|
|
25
|
+
*
|
|
26
|
+
* Capped, and the OLDEST go. The server bounds its own SSE buffer at a megabyte for a peer that stopped reading;
|
|
27
|
+
* nothing bounded this side, so a stream that runs long — a model answering token by token, a job reporting every
|
|
28
|
+
* row — grew a panel's array without limit for as long as the tab stayed open. What a person scrolls back to is
|
|
29
|
+
* the end of a stream, so the end is what is kept.
|
|
30
|
+
*/
|
|
31
|
+
export declare const recordActionProgress: (id: string, chunk: unknown) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Empties the log. Live runs keep their cancellers: clearing the panel is tidying a VIEW, and taking away the only
|
|
34
|
+
* way to stop a run that is still going is not something a person asked for by pressing it.
|
|
35
|
+
*/
|
|
36
|
+
export declare const clearActionRuns: () => void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import e from "./actionRunsStore.mjs";
|
|
2
|
+
//#region src/store/actionRuns/actionRunsRecorder.ts
|
|
3
|
+
var t = 0, n = (t) => e.setState("runs", t), r = /* @__PURE__ */ new Map(), i = (e, t) => {
|
|
4
|
+
r.set(e, t);
|
|
5
|
+
}, a = (e) => {
|
|
6
|
+
r.delete(e);
|
|
7
|
+
}, o = (e) => {
|
|
8
|
+
r.get(e)?.();
|
|
9
|
+
}, s = (r) => {
|
|
10
|
+
t += 1;
|
|
11
|
+
let i = `run-${t}`;
|
|
12
|
+
return n([{
|
|
13
|
+
...r,
|
|
14
|
+
id: i,
|
|
15
|
+
status: "running",
|
|
16
|
+
startedAt: Date.now(),
|
|
17
|
+
progress: [],
|
|
18
|
+
cancellable: !0
|
|
19
|
+
}, ...e.getState().runs].slice(0, 100)), i;
|
|
20
|
+
}, c = (t, r) => {
|
|
21
|
+
let { runs: i } = e.getState();
|
|
22
|
+
i.some((e) => e.id === t) && n(i.map((e) => e.id === t ? {
|
|
23
|
+
...e,
|
|
24
|
+
...r
|
|
25
|
+
} : e));
|
|
26
|
+
}, l = (t, r) => {
|
|
27
|
+
let { runs: i } = e.getState();
|
|
28
|
+
n(i.map((e) => e.id === t ? {
|
|
29
|
+
...e,
|
|
30
|
+
progress: [...e.progress, r].slice(-500)
|
|
31
|
+
} : e));
|
|
32
|
+
}, u = () => {
|
|
33
|
+
let t = new Set(e.getState().runs.filter((e) => e.cancellable).map((e) => e.id));
|
|
34
|
+
[...r.keys()].forEach((e) => {
|
|
35
|
+
t.has(e) || r.delete(e);
|
|
36
|
+
}), n([]);
|
|
37
|
+
};
|
|
38
|
+
//#endregion
|
|
39
|
+
export { o as cancelActionRun, u as clearActionRuns, l as recordActionProgress, s as recordActionRun, i as registerActionCanceller, a as releaseActionCanceller, c as updateActionRun };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ActionRunsState } from '../../types';
|
|
2
|
+
/** Newest runs are kept; older ones drop off, so a page left open all day cannot grow unbounded. */
|
|
3
|
+
export declare const MAX_RUNS = 100;
|
|
4
|
+
/** Per run, and for the same reason: a long stream is a run whose progress array would otherwise never stop. */
|
|
5
|
+
export declare const MAX_PROGRESS_CHUNKS = 500;
|
|
6
|
+
export declare const createActionRunsState: () => ActionRunsState;
|
|
7
|
+
/**
|
|
8
|
+
* DEDICATED, isolated store — deliberately not part of the reactive `CommonState`.
|
|
9
|
+
*
|
|
10
|
+
* A run is developer-facing evidence, not page state: nothing an element renders should re-render because a
|
|
11
|
+
* server action reported progress, and a page that binds `{{ … }}` to anything here would be binding to the
|
|
12
|
+
* debugger. It follows the tracing store for exactly that reason, and for one more: the panel renders outside the
|
|
13
|
+
* app's provider tree and needs a store it can read without one.
|
|
14
|
+
*/
|
|
15
|
+
declare const actionRunsStore: import('@plitzi/nexus').StoreApi<ActionRunsState>;
|
|
16
|
+
export default actionRunsStore;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createStore as e } from "@plitzi/nexus";
|
|
2
|
+
//#region src/store/actionRuns/actionRunsStore.ts
|
|
3
|
+
var t = 100, n = 500, r = () => ({ runs: [] }), i = e(r(), { id: "action-runs" });
|
|
4
|
+
//#endregion
|
|
5
|
+
export { n as MAX_PROGRESS_CHUNKS, t as MAX_RUNS, r as createActionRunsState, i as default };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { default as actionRunsStore } from './actionRunsStore';
|
|
2
|
+
import { default as useActionRuns } from './useActionRuns';
|
|
3
|
+
export { MAX_RUNS, createActionRunsState } from './actionRunsStore';
|
|
4
|
+
export { cancelActionRun, clearActionRuns, recordActionProgress, recordActionRun, registerActionCanceller, releaseActionCanceller, updateActionRun } from './actionRunsRecorder';
|
|
5
|
+
export type { UseActionRunsReturn } from './useActionRuns';
|
|
6
|
+
export { actionRunsStore, useActionRuns };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import e, { MAX_RUNS as t, createActionRunsState as n } from "./actionRunsStore.mjs";
|
|
2
|
+
import { cancelActionRun as r, clearActionRuns as i, recordActionProgress as a, recordActionRun as o, registerActionCanceller as s, releaseActionCanceller as c, updateActionRun as l } from "./actionRunsRecorder.mjs";
|
|
3
|
+
import u from "./useActionRuns.mjs";
|
|
4
|
+
export { t as MAX_RUNS, e as actionRunsStore, r as cancelActionRun, i as clearActionRuns, n as createActionRunsState, a as recordActionProgress, o as recordActionRun, s as registerActionCanceller, c as releaseActionCanceller, l as updateActionRun, u as useActionRuns };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ActionRunsState } from '../../types';
|
|
2
|
+
export type UseActionRunsReturn = ActionRunsState & {
|
|
3
|
+
clear: () => void;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Reactive view of the runs this page has started.
|
|
7
|
+
*
|
|
8
|
+
* Recording is always on — a run that happened before the panel was opened is the one somebody is usually looking
|
|
9
|
+
* for — and this is a pure view over it. `getState` returns a stable snapshot between writes, which is what
|
|
10
|
+
* `useSyncExternalStore` needs.
|
|
11
|
+
*/
|
|
12
|
+
declare const useActionRuns: () => UseActionRunsReturn;
|
|
13
|
+
export default useActionRuns;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import e from "./actionRunsStore.mjs";
|
|
2
|
+
import { clearActionRuns as t } from "./actionRunsRecorder.mjs";
|
|
3
|
+
import { useSyncExternalStore as n } from "react";
|
|
4
|
+
//#region src/store/actionRuns/useActionRuns.ts
|
|
5
|
+
var r = () => ({
|
|
6
|
+
...n(e.subscribe, e.getState, e.getState),
|
|
7
|
+
clear: t
|
|
8
|
+
});
|
|
9
|
+
//#endregion
|
|
10
|
+
export { r as default };
|