akanjs 3.3.0-rc.79 → 3.3.0-rc.80
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/fetch/client/fetchHandle.ts +3 -1
- package/package.json +1 -1
- package/server/routeElementComposer.tsx +8 -1
- package/store/agent/ScreenSettle.ts +3 -1
- package/store/agent/StoreSurfaceSource.ts +21 -7
- package/store/agentic/AgentNavigate.ts +20 -0
- package/store/agentic/index.ts +1 -0
- package/store/index.ts +2 -0
- package/types/store/agentic/AgentNavigate.d.ts +10 -0
- package/types/store/agentic/index.d.ts +1 -0
- package/types/store/index.d.ts +1 -1
- package/webkit/RenderLayer.tsx +7 -0
|
@@ -44,10 +44,12 @@ export class FetchHandle {
|
|
|
44
44
|
|
|
45
45
|
static #streamed(field: unknown): unknown {
|
|
46
46
|
if (!(field instanceof Promise)) return field;
|
|
47
|
-
|
|
47
|
+
const streamed = field.catch((reason: unknown) => {
|
|
48
48
|
StreamedRead.mark(reason);
|
|
49
49
|
throw reason;
|
|
50
50
|
});
|
|
51
|
+
void streamed.catch(() => undefined);
|
|
52
|
+
return streamed;
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
/** The awaited shape's fields stay lazy for the same reason the handle's do: a caller reads one, not all. */
|
package/package.json
CHANGED
|
@@ -602,6 +602,13 @@ export class RouteElementComposer {
|
|
|
602
602
|
if (!Loading) continue;
|
|
603
603
|
element = Loading({ params, children: element } as never) as ReactNode;
|
|
604
604
|
}
|
|
605
|
-
return
|
|
605
|
+
if (element === null) return null;
|
|
606
|
+
|
|
607
|
+
return (
|
|
608
|
+
<>
|
|
609
|
+
{element}
|
|
610
|
+
<template data-akan-loading="" />
|
|
611
|
+
</>
|
|
612
|
+
);
|
|
606
613
|
}
|
|
607
614
|
}
|
|
@@ -51,7 +51,9 @@ export class ScreenSettle {
|
|
|
51
51
|
|
|
52
52
|
static #loading(body: HTMLElement) {
|
|
53
53
|
for (const mark of body.querySelectorAll("template[data-akan-loading]")) {
|
|
54
|
-
|
|
54
|
+
let holder = mark.parentElement;
|
|
55
|
+
while (holder && holder !== body && getComputedStyle(holder).display === "contents")
|
|
56
|
+
holder = holder.parentElement;
|
|
55
57
|
if (!holder || holder.closest('[hidden], [aria-hidden="true"], [inert]')) continue;
|
|
56
58
|
if (typeof holder.checkVisibility !== "function" || holder.checkVisibility()) return true;
|
|
57
59
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { csrLocation, isNotFoundView, router } from "akanjs/client";
|
|
2
2
|
import { AgenticSurface, type SurfaceSource, type ToolEntry, ToolReturn } from "../../vendor/use-agentic";
|
|
3
3
|
import { InlineToken } from "../../common/inlineToken";
|
|
4
|
+
import { AgentNavigate } from "../agentic/AgentNavigate";
|
|
4
5
|
import { AgentBridge } from "./AgentBridge";
|
|
5
6
|
import { ScreenFlash } from "./ScreenFlash";
|
|
6
7
|
import { ScreenImage } from "./ScreenImage";
|
|
@@ -44,7 +45,12 @@ export class StoreSurfaceSource implements SurfaceSource {
|
|
|
44
45
|
return {
|
|
45
46
|
name: "navigate",
|
|
46
47
|
taint: "exempt",
|
|
47
|
-
description
|
|
48
|
+
get description() {
|
|
49
|
+
return (
|
|
50
|
+
AgentNavigate.options.description ??
|
|
51
|
+
"Navigate this page to an internal path of this app, such as one a link on this screen points to."
|
|
52
|
+
);
|
|
53
|
+
},
|
|
48
54
|
parameters: {
|
|
49
55
|
type: "object",
|
|
50
56
|
properties: { path: { type: "string" } },
|
|
@@ -58,19 +64,23 @@ export class StoreSurfaceSource implements SurfaceSource {
|
|
|
58
64
|
: "path must be an internal path starting with /.",
|
|
59
65
|
run: async (args) => {
|
|
60
66
|
const path = String(args.path);
|
|
67
|
+
|
|
68
|
+
const linkedBefore = ScreenTarget.linkedRoutes();
|
|
61
69
|
try {
|
|
62
70
|
router.push(path);
|
|
63
71
|
await router.navigation();
|
|
64
72
|
} catch (error) {
|
|
65
73
|
if (StoreSurfaceSource.#isKept(error)) throw new Error(StoreSurfaceSource.#kept);
|
|
66
|
-
throw new Error(
|
|
74
|
+
throw new Error(
|
|
75
|
+
`There is no route at ${path}, so the page did not move. ${StoreSurfaceSource.#linked(linkedBefore)}`,
|
|
76
|
+
);
|
|
67
77
|
}
|
|
68
78
|
|
|
69
79
|
await StoreSurfaceSource.#settled();
|
|
70
80
|
if (isNotFoundView()) {
|
|
71
81
|
const left = await StoreSurfaceSource.#leaveNotFound();
|
|
72
82
|
throw new Error(
|
|
73
|
-
`There is no route at ${path}, so ${left ? "the page went back" : "the page shows the app's not-found page"}. ${StoreSurfaceSource.#linked()}`,
|
|
83
|
+
`There is no route at ${path}, so ${left ? "the page went back" : "the page shows the app's not-found page"}. ${StoreSurfaceSource.#linked(left ? linkedBefore : [])}`,
|
|
74
84
|
);
|
|
75
85
|
}
|
|
76
86
|
const landed = StoreSurfaceSource.#redirected(path);
|
|
@@ -80,8 +90,12 @@ export class StoreSurfaceSource implements SurfaceSource {
|
|
|
80
90
|
}
|
|
81
91
|
|
|
82
92
|
static async #settled() {
|
|
83
|
-
|
|
84
|
-
|
|
93
|
+
const settled = async () => {
|
|
94
|
+
await ScreenSettle.wait({ appearMs: 800, timeoutMs: 5000 });
|
|
95
|
+
if (await ScreenSettle.loaded({ timeoutMs: 5000 })) await ScreenSettle.wait({ timeoutMs: 2000 });
|
|
96
|
+
};
|
|
97
|
+
const { settle } = AgentNavigate.options;
|
|
98
|
+
await (settle ? settle(settled) : settled());
|
|
85
99
|
}
|
|
86
100
|
|
|
87
101
|
static async #leaveNotFound(): Promise<boolean> {
|
|
@@ -105,8 +119,8 @@ export class StoreSurfaceSource implements SurfaceSource {
|
|
|
105
119
|
return error instanceof Error && error.name === "NavigationRefused";
|
|
106
120
|
}
|
|
107
121
|
|
|
108
|
-
static #linked() {
|
|
109
|
-
const routes = ScreenTarget.linkedRoutes();
|
|
122
|
+
static #linked(before: string[] = []) {
|
|
123
|
+
const routes = before.length ? before : ScreenTarget.linkedRoutes();
|
|
110
124
|
return routes.length
|
|
111
125
|
? `Paths this screen links to: ${routes.join(", ")}. Navigate to one of those rather than composing a path.`
|
|
112
126
|
: "Call readScreen — it prints each link on this screen with its own path — and navigate to one of those.";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface AgentNavigateOptions {
|
|
2
|
+
description?: string;
|
|
3
|
+
/** How `navigate` and `goBack` wait for the page they land on; `settled` is the runtime's own wait. */
|
|
4
|
+
settle?: (settled: () => Promise<void>) => Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const OPTIONS_KEY = Symbol.for("akanjs.store.agentNavigate");
|
|
8
|
+
|
|
9
|
+
/** App-wide settings of the runtime's `navigate` and `goBack`, read at every call. */
|
|
10
|
+
export class AgentNavigate {
|
|
11
|
+
static get options(): AgentNavigateOptions {
|
|
12
|
+
const holder = globalThis as typeof globalThis & { [OPTIONS_KEY]?: AgentNavigateOptions };
|
|
13
|
+
return holder[OPTIONS_KEY] ?? {};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static set(options: AgentNavigateOptions) {
|
|
17
|
+
const holder = globalThis as typeof globalThis & { [OPTIONS_KEY]?: AgentNavigateOptions };
|
|
18
|
+
holder[OPTIONS_KEY] = { ...AgentNavigate.options, ...options };
|
|
19
|
+
}
|
|
20
|
+
}
|
package/store/agentic/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
export { AgentAbort, AgentProgress, type AgentProgressStep, ToolReturn } from "../../vendor/use-agentic";
|
|
3
3
|
export * from "./AgentConfirm";
|
|
4
|
+
export * from "./AgentNavigate";
|
|
4
5
|
export * from "./AgentValue";
|
|
5
6
|
export * from "./attachAgentic";
|
|
6
7
|
export * from "./formFieldsReexport";
|
package/store/index.ts
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface AgentNavigateOptions {
|
|
2
|
+
description?: string;
|
|
3
|
+
/** How `navigate` and `goBack` wait for the page they land on; `settled` is the runtime's own wait. */
|
|
4
|
+
settle?: (settled: () => Promise<void>) => Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
/** App-wide settings of the runtime's `navigate` and `goBack`, read at every call. */
|
|
7
|
+
export declare class AgentNavigate {
|
|
8
|
+
static get options(): AgentNavigateOptions;
|
|
9
|
+
static set(options: AgentNavigateOptions): void;
|
|
10
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { AgentAbort, AgentProgress, type AgentProgressStep, ToolReturn } from "../../vendor/use-agentic.d.ts";
|
|
2
2
|
export * from "./AgentConfirm.d.ts";
|
|
3
|
+
export * from "./AgentNavigate.d.ts";
|
|
3
4
|
export * from "./AgentValue.d.ts";
|
|
4
5
|
export * from "./attachAgentic.d.ts";
|
|
5
6
|
export * from "./formFieldsReexport.d.ts";
|
package/types/store/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { type DefaultAction, makeActions, makeFormSetter, type SliceAction } from "./action.d.ts";
|
|
2
2
|
export type { CreateOption, EditOption, ErrorReportOption, NewOption } from "./actionOption.d.ts";
|
|
3
3
|
export { type ActionOwner, type ActionTag, actionTagOf, tagAction } from "./actionTag.d.ts";
|
|
4
|
-
export { AgentAbort, AgentConfirm, type AgentConfirmPolicy, type AgentFieldType, AgentProgress, type AgentProgressStep, type AgentReferenceInput, AgentValue, type AgentValueOf, attachAgentic, type FieldToolOptions, type FileFieldSource, type FormFieldRef, FormFields, type RelationFieldSource, type StAgentic, StExposeBuilder, StExposeDraft, type StExposeMeta, StStateBuilder, StStateDraft, type StStateMeta, type StToolArgOption, type StToolArgType, StToolBuilder, type StToolCardControl, StToolDraft, type StToolMeta, ToolReturn, useAgentReference, useFieldTool, useFileFieldTool, useFormTools, useRelationFieldTool, } from "./agentic.d.ts";
|
|
4
|
+
export { AgentAbort, AgentConfirm, type AgentConfirmPolicy, type AgentFieldType, AgentNavigate, type AgentNavigateOptions, AgentProgress, type AgentProgressStep, type AgentReferenceInput, AgentValue, type AgentValueOf, attachAgentic, type FieldToolOptions, type FileFieldSource, type FormFieldRef, FormFields, type RelationFieldSource, type StAgentic, StExposeBuilder, StExposeDraft, type StExposeMeta, StStateBuilder, StStateDraft, type StStateMeta, type StToolArgOption, type StToolArgType, StToolBuilder, type StToolCardControl, StToolDraft, type StToolMeta, ToolReturn, useAgentReference, useFieldTool, useFileFieldTool, useFormTools, useRelationFieldTool, } from "./agentic.d.ts";
|
|
5
5
|
export { type BaseSearchParamsState, BaseStore, base, RootStore, st } from "./baseSt.d.ts";
|
|
6
6
|
export { AgentBridge, AgentContext, AgentCursor, AgentPrompts, AgentVisual, type AgentVisualOption, databaseStateModelTypes, ensureStoreSurface, ScreenFlash, ScreenImage, type ScreenImageView, ScreenReader, type ScreenReadOptions, ScreenSettle, type ScreenSettleOptions, ScreenTarget, type SerializedStoreState, StoreCatalogue, type StoreSurface, StoreSurfaceSource, } from "./deprecatedAgent.d.ts";
|
|
7
7
|
export { databaseStateNames, formSetterNames } from "./deprecatedNames.d.ts";
|
package/webkit/RenderLayer.tsx
CHANGED
|
@@ -85,6 +85,13 @@ export const RenderLayer = memo((props: RenderLayerProps) => {
|
|
|
85
85
|
|
|
86
86
|
const mayAsk = activity !== "hidden" && activity !== "prev";
|
|
87
87
|
useEffect(() => (guardKey ? CsrGuards.hold(guardKey) : undefined), [guardKey]);
|
|
88
|
+
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (renderedRef.current) renderedRef.current.owned = true;
|
|
91
|
+
return () => {
|
|
92
|
+
if (renderedRef.current) renderedRef.current.owned = false;
|
|
93
|
+
};
|
|
94
|
+
}, []);
|
|
88
95
|
|
|
89
96
|
useEffect(() => {
|
|
90
97
|
const rendered = renderedRef.current;
|