@nice-code/action 0.6.3 → 0.8.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.
Files changed (41) hide show
  1. package/build/devtools/browser/index.js +590 -1246
  2. package/build/devtools/server/index.js +7 -1
  3. package/build/index.js +1257 -972
  4. package/build/types/ActionRuntime/ActionRuntime.d.ts +23 -1
  5. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Transport.types.d.ts +6 -0
  6. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/WebSocketConnection.d.ts +2 -1
  7. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/secureWsChannel.d.ts +63 -0
  8. package/build/types/ActionRuntime/Handler/Server/ActionServerHandler.d.ts +64 -1
  9. package/build/types/ActionRuntime/Handler/Server/WsConnectionStateStore.d.ts +61 -0
  10. package/build/types/ActionRuntime/Handler/Server/createActionFetchHandler.d.ts +40 -0
  11. package/build/types/ActionRuntime/Handler/Server/createSecureActionServer.d.ts +71 -0
  12. package/build/types/devtools/browser/NiceActionDevtools.d.ts +1 -1
  13. package/build/types/devtools/browser/components/ActionErrorDisplay.d.ts +1 -1
  14. package/build/types/devtools/browser/components/CallStackSection.d.ts +1 -1
  15. package/build/types/devtools/browser/components/ChildDispatchChips.d.ts +1 -1
  16. package/build/types/devtools/browser/components/Chip.d.ts +1 -1
  17. package/build/types/devtools/browser/components/DetailSection.d.ts +1 -1
  18. package/build/types/devtools/browser/components/DomainChip.d.ts +1 -1
  19. package/build/types/devtools/browser/components/HandlerChips.d.ts +1 -1
  20. package/build/types/devtools/browser/components/Icon.d.ts +1 -1
  21. package/build/types/devtools/browser/components/MetaSection.d.ts +1 -1
  22. package/build/types/devtools/browser/components/NiceErrorDisplay.d.ts +2 -2
  23. package/build/types/devtools/browser/components/OriginChip.d.ts +1 -1
  24. package/build/types/devtools/browser/components/RoutingSection.d.ts +1 -1
  25. package/build/types/devtools/browser/components/RunningTimer.d.ts +2 -2
  26. package/build/types/devtools/browser/components/SectionLabel.d.ts +1 -4
  27. package/build/types/devtools/browser/components/StackTraceSection.d.ts +1 -1
  28. package/build/types/devtools/browser/components/Tooltip.d.ts +1 -24
  29. package/build/types/devtools/browser/components/action_detail/ActionDetailPanel.d.ts +1 -1
  30. package/build/types/devtools/browser/components/action_list/ActionEntryRow.d.ts +1 -1
  31. package/build/types/devtools/browser/components/action_list/ActionInputAndOutputChip.d.ts +1 -1
  32. package/build/types/devtools/browser/components/action_list/ActionList.d.ts +1 -1
  33. package/build/types/devtools/browser/components/action_list/IoTooltipContent.d.ts +1 -4
  34. package/build/types/devtools/browser/components/utils.d.ts +1 -3
  35. package/build/types/devtools/core/ActionDevtools.types.d.ts +1 -1
  36. package/build/types/devtools/core/ActionDevtoolsCore.d.ts +4 -1
  37. package/build/types/devtools/core/devtools_colors.d.ts +1 -26
  38. package/build/types/index.d.ts +5 -1
  39. package/package.json +33 -29
  40. package/build/types/devtools/browser/components/PanelChrome.d.ts +0 -41
  41. package/build/types/devtools/browser/devtools_dock.d.ts +0 -54
@@ -1,6 +1,7 @@
1
1
  import { type LucideIcon } from "lucide-react";
2
2
  import type { IDevtoolsActionEntry, TDevtoolsActionStatus } from "../../core/ActionDevtools.types";
3
3
  import { ESemanticThing } from "../../core/devtools_colors";
4
+ export { formatRelativeAge, formatTimestamp, safeStringify } from "nice-devtools-shared";
4
5
  export declare const STATUS_COLOR: Record<TDevtoolsActionStatus, string>;
5
6
  export declare const STATUS_THING: Record<TDevtoolsActionStatus, ESemanticThing>;
6
7
  export declare const STATUS_SYMBOL: Record<TDevtoolsActionStatus, string>;
@@ -16,7 +17,4 @@ export declare function getInboundOrigin(entry: IDevtoolsActionEntry): {
16
17
  perId?: string;
17
18
  insId?: string;
18
19
  } | null;
19
- export declare function safeStringify(value: unknown, indent?: number): string;
20
- export declare function formatRelativeAge(ms: number): string;
21
20
  export declare function formatDuration(entry: IDevtoolsActionEntry): string | null;
22
- export declare function formatTimestamp(startTime: number): string;
@@ -1,7 +1,7 @@
1
1
  import type { TActionProgress } from "../../ActionDefinition/Action/Payload/ActionPayload.types";
2
2
  import type { IRuntimeCoordinate } from "../../ActionRuntime/RuntimeCoordinate";
3
+ export type { TDevtoolsPosition } from "nice-devtools-shared";
3
4
  export type TDevtoolsActionStatus = "running" | "success" | "action-error" | "failed" | "aborted";
4
- export type TDevtoolsPosition = "dock-bottom" | "dock-top" | "dock-left" | "dock-right";
5
5
  export interface IDevtoolsRouteItem {
6
6
  runtime: IRuntimeCoordinate;
7
7
  handlerType: "local" | "external";
@@ -1,10 +1,13 @@
1
1
  import type { IDevtoolsActionEntry, IDevtoolsObservableDomain, TDevtoolsListener } from "./ActionDevtools.types";
2
2
  export interface IActionDevtoolsCoreOptions {
3
+ /** Max root entries to retain. Older entries (and their children) are evicted. */
4
+ maxEntries?: number;
3
5
  }
4
6
  export declare class ActionDevtoolsCore {
5
7
  private _entries;
6
8
  private _listeners;
7
- constructor(_options?: IActionDevtoolsCoreOptions);
9
+ private readonly _maxEntries;
10
+ constructor(options?: IActionDevtoolsCoreOptions);
8
11
  attachToDomain(domain: IDevtoolsObservableDomain): () => void;
9
12
  getEntries(): readonly IDevtoolsActionEntry[];
10
13
  subscribe(listener: TDevtoolsListener): () => void;
@@ -1,39 +1,14 @@
1
1
  import type { IChipColorEntry } from "../browser/components/Chip";
2
- export declare const DEVTOOL_COLOR_SEMANTIC_ERROR = "#FF5C5C";
3
- export declare const DEVTOOL_COLOR_SEMANTIC_SUCCESS = "#A3E635";
4
- export declare const DEVTOOL_COLOR_SEMANTIC_SYSTEM = "#38BDF8";
5
- export declare const DEVTOOL_COLOR_SEMANTIC_WARNING = "#FB923C";
6
- export declare const DEVTOOL_COLOR_SEMANTIC_METADATA = "#A1A1AA";
2
+ export { DEVTOOL_COLOR_SEMANTIC_ERROR, DEVTOOL_COLOR_SEMANTIC_METADATA, DEVTOOL_COLOR_SEMANTIC_SUCCESS, DEVTOOL_COLOR_SEMANTIC_SYSTEM, DEVTOOL_COLOR_SEMANTIC_WARNING, DEVTOOL_COLOR_TEXT_EMPHASIS, DEVTOOL_COLOR_TEXT_FAINT, DEVTOOL_COLOR_TEXT_MUTED, DEVTOOL_COLOR_TEXT_SECONDARY, DEVTOOL_DETAIL_BASE_BACKGROUND, DEVTOOL_DETAIL_HEADER_BACKGROUND, DEVTOOL_ERROR_BACKGROUND, DEVTOOL_JSON_KEY, DEVTOOL_JSON_KEYWORD, DEVTOOL_JSON_NUMBER, DEVTOOL_JSON_PUNCTUATION, DEVTOOL_JSON_STRING, DEVTOOL_LIST_BASE_BACKGROUND, DEVTOOL_LIST_SELECTED_BACKGROUND, DEVTOOL_PANEL_BORDER, DEVTOOL_PANEL_DIVIDER_BORDER, DEVTOOL_SECTION_BACKGROUND, DEVTOOL_SECTION_STRING_BACKGROUND, DEVTOOL_TOOLTIP_BACKGROUND, DEVTOOL_TOOLTIP_BORDER, DEVTOOL_TOOLTIP_TITLE_BACKGROUND, DEVTOOL_TOOLTIP_TITLE_BOTTOM_BORDER, MONO_FONT, SANS_FONT, } from "nice-devtools-shared";
7
3
  export declare const DEVTOOL_COLOR_HANDLER_LOCAL_TEXT = "#34bb89";
8
4
  export declare const DEVTOOL_COLOR_HANDLER_LOCAL_BORDER = "#144427";
9
5
  export declare const DEVTOOL_COLOR_HANDLER_EXTERNAL_TEXT = "#cfa12a";
10
6
  export declare const DEVTOOL_COLOR_HANDLER_EXTERNAL_BORDER = "#723917";
11
- export declare const DEVTOOL_COLOR_TEXT_EMPHASIS = "#f1f5f9";
12
- export declare const DEVTOOL_COLOR_TEXT_SECONDARY = "#cbd5e1";
13
- export declare const DEVTOOL_COLOR_TEXT_MUTED = "#64748b";
14
- export declare const DEVTOOL_COLOR_TEXT_FAINT = "#334155";
15
- export declare const DEVTOOL_LIST_BASE_BACKGROUND = "#0f172a";
16
7
  export declare const DEVTOOL_LIST_HEADER_SELECTED_BACKGROUND = "#1d2942";
17
8
  export declare const DEVTOOL_LIST_GROUP_DIVIDER = "#101109";
18
- export declare const DEVTOOL_DETAIL_BASE_BACKGROUND = "#0d1729";
19
- export declare const DEVTOOL_DETAIL_HEADER_BACKGROUND = "#131f35";
20
- export declare const DEVTOOL_SECTION_BACKGROUND = "#1e293b";
21
- export declare const DEVTOOL_SECTION_STRING_BACKGROUND = "#0d131f";
22
9
  export declare const DEVTOOL_STACK_TRACE_BACKGROUND = "#040a13";
23
- export declare const DEVTOOL_PANEL_BORDER = "#1e293b";
24
- export declare const DEVTOOL_PANEL_DIVIDER_BORDER = "#1d3352";
25
- export declare const DEVTOOL_ERROR_BACKGROUND = "#1e0a0a";
26
10
  export declare const DEVTOOL_ERROR_BADGE_BACKGROUND = "#2d0f0f";
27
- export declare const DEVTOOL_TOOLTIP_BACKGROUND = "#0c1526";
28
- export declare const DEVTOOL_TOOLTIP_TITLE_BACKGROUND = "#101b2e";
29
- export declare const DEVTOOL_TOOLTIP_TITLE_BOTTOM_BORDER = "#211f5f";
30
- export declare const DEVTOOL_TOOLTIP_BORDER = "#312e81";
31
11
  export declare const DEVTOOL_COLOR_CALL_STACK_DIVIDER = "#0a1120";
32
- export declare const DEVTOOL_JSON_KEY = "#a5b4fc";
33
- export declare const DEVTOOL_JSON_STRING = "#fbbf24";
34
- export declare const DEVTOOL_JSON_NUMBER = "#34d399";
35
- export declare const DEVTOOL_JSON_KEYWORD = "#a78bfa";
36
- export declare const DEVTOOL_JSON_PUNCTUATION = "#475569";
37
12
  export declare const DEVTOOL_STACK_FRAME_USER_NUMBER = "#64748b";
38
13
  export declare const DEVTOOL_STACK_FRAME_USER_FUNCTION = "#e2e8f0";
39
14
  export declare const DEVTOOL_STACK_FRAME_USER_FOLDER = "#596b83";
@@ -26,10 +26,14 @@ export { createActionFrameCrypto, type IActionFrameCrypto, type IActionFrameCryp
26
26
  export { createClientHandshake, createInMemoryTofuVerifyKeyResolver, createServerHandshake, createStorageTofuVerifyKeyResolver, decodeHandshakeMessage, EHandshakeMessageType, ESecurityLevel, encodeHandshakeMessage, type IClientHandshakeConfig, type IClientVerifyKeyResolveInput, type IClientVerifyKeyResolver, type IHandshakeEncryptionKeyMaterial, type IHandshakeResult, type IServerHandshakeConfig, runtimeLinkId, type THandshakeMessage, } from "./ActionRuntime/Handler/ExternalClient/Transport/WebSocket/actionWsHandshake";
27
27
  export { createBinaryWsAdapter } from "./ActionRuntime/Handler/ExternalClient/Transport/WebSocket/createBinaryWsAdapter";
28
28
  export { createBinaryWsSessionFactory, type IBinaryWsSessionOptions, } from "./ActionRuntime/Handler/ExternalClient/Transport/WebSocket/createBinaryWsSessionFactory";
29
+ export { createSecureWebSocketTransport, defineSecureWsChannel, type ISecureWebSocketTransportOptions, type ISecureWsChannel, } from "./ActionRuntime/Handler/ExternalClient/Transport/WebSocket/secureWsChannel";
29
30
  export type { IActionTransportDef_Ws, IActionTransportInitialized_Ws, IActionTransportReadyData_Ws, } from "./ActionRuntime/Handler/ExternalClient/Transport/WebSocket/TransportWebSocket.types";
30
31
  export { type IWebSocketTransportAdvancedOptions, type IWebSocketTransportSocketOptions, type TWebSocketTransportOptions, WebSocketTransport, } from "./ActionRuntime/Handler/ExternalClient/Transport/WebSocket/WebSocketTransport";
31
32
  export { ActionLocalHandler, createLocalHandler, } from "./ActionRuntime/Handler/Local/ActionLocalHandler";
32
- export { ActionServerHandler, createServerHandler, type IActionServerConnectionBinding, type IActionServerHandlerOptions, type TActionChannelFormatMessage, type TActionConnectionEncoding, } from "./ActionRuntime/Handler/Server/ActionServerHandler";
33
+ export { ActionServerHandler, createServerHandler, type IActionServerConnectionBinding, type IActionServerHandlerOptions, type TActionChannelFormatMessage, type TActionConnectionEncoding, type TServerConnectionCaseFn, } from "./ActionRuntime/Handler/Server/ActionServerHandler";
34
+ export { createActionFetchHandler, type IActionFetchHandlerOptions, } from "./ActionRuntime/Handler/Server/createActionFetchHandler";
35
+ export { createHibernatableWsServerAdapter, createSecureActionServerHandler, type IHibernatableWsServerAdapter, type IHibernatableWsServerAdapterOptions, type ISecureActionServerHandlerOptions, } from "./ActionRuntime/Handler/Server/createSecureActionServer";
36
+ export { type IConnectionAttachment, type IWsConnectionStateStoreOptions, WsConnectionStateStore, } from "./ActionRuntime/Handler/Server/WsConnectionStateStore";
33
37
  export * from "./ActionRuntime/RuntimeCoordinate";
34
38
  export { EErrId_NiceAction, err_nice_action } from "./errors/err_nice_action";
35
39
  export { decodeActionFrame, type IActionFrameDecoder } from "./utils/decodeActionFrame";
package/package.json CHANGED
@@ -1,28 +1,26 @@
1
1
  {
2
2
  "name": "@nice-code/action",
3
- "version": "0.6.3",
4
- "private": false,
5
- "type": "module",
3
+ "version": "0.8.0",
6
4
  "exports": {
7
5
  ".": {
8
6
  "source": "./src/index.ts",
9
- "types": "./build/types/index.d.ts",
10
- "import": "./build/index.js"
11
- },
12
- "./react-query": {
13
- "source": "./src/react-query/index.ts",
14
- "types": "./build/types/react-query/index.d.ts",
15
- "import": "./build/react-query/index.js"
7
+ "import": "./build/index.js",
8
+ "types": "./build/types/index.d.ts"
16
9
  },
17
10
  "./devtools/browser": {
18
11
  "source": "./src/devtools/browser/index.ts",
19
- "types": "./build/types/devtools/browser/index.d.ts",
20
- "import": "./build/devtools/browser/index.js"
12
+ "import": "./build/devtools/browser/index.js",
13
+ "types": "./build/types/devtools/browser/index.d.ts"
21
14
  },
22
15
  "./devtools/server": {
23
16
  "source": "./src/devtools/server/index.ts",
24
- "types": "./build/types/devtools/server/index.d.ts",
25
- "import": "./build/devtools/server/index.js"
17
+ "import": "./build/devtools/server/index.js",
18
+ "types": "./build/types/devtools/server/index.d.ts"
19
+ },
20
+ "./react-query": {
21
+ "source": "./src/react-query/index.ts",
22
+ "import": "./build/react-query/index.js",
23
+ "types": "./build/types/react-query/index.d.ts"
26
24
  }
27
25
  },
28
26
  "files": [
@@ -30,40 +28,46 @@
30
28
  "package.json",
31
29
  "README.md"
32
30
  ],
31
+ "peerDependencies": {
32
+ "@tanstack/react-query": "^5.100.3",
33
+ "react": ">=19",
34
+ "react-dom": ">=19",
35
+ "valibot": "^1.3.1"
36
+ },
37
+ "private": false,
33
38
  "publishConfig": {
34
39
  "access": "public"
35
40
  },
36
41
  "scripts": {
42
+ "build": "bun run clean-build && bun run build.ts && bun run build-types",
43
+ "build-types": "tsc --project tsconfig.build.json",
44
+ "build-watch": "bun run clean-build && bun run build.ts --watch && bun run build-types --watch",
45
+ "clean-build": "bunx rimraf build",
37
46
  "type-check": "bunx tsc --noEmit",
38
47
  "type-check-watch": "bunx tsc --noEmit --watch",
39
- "clean-build": "bunx rimraf build",
40
48
  "vitest": "vitest --typecheck",
41
- "vitest-agent": "vitest --typecheck --reporter=agent",
42
- "build": "bun run clean-build && bun run build.ts && bun run build-types",
43
- "build-watch": "bun run clean-build && bun run build.ts --watch && bun run build-types --watch",
44
- "build-types": "tsc --project tsconfig.build.json"
49
+ "vitest-agent": "vitest --typecheck --reporter=agent"
45
50
  },
51
+ "type": "module",
46
52
  "dependencies": {
47
- "@nice-code/common-errors": "0.6.3",
48
- "@nice-code/error": "0.6.3",
49
- "@nice-code/util": "0.6.3",
53
+ "@nice-code/common-errors": "0.8.0",
54
+ "@nice-code/error": "0.8.0",
55
+ "@nice-code/util": "0.8.0",
50
56
  "@standard-schema/spec": "^1.1.0",
51
57
  "@tanstack/react-virtual": "^3.13.26",
52
58
  "http-status-codes": "^2.3.0",
53
59
  "lucide-react": "1.17.0",
60
+ "msgpackr": "2.0.4",
54
61
  "nanoid": "^5.1.9",
62
+ "nice-devtools-shared": "0.8.0",
55
63
  "source-map-js": "^1.2.1",
56
- "std-env": "^4.1.0",
57
- "msgpackr": "2.0.4"
64
+ "std-env": "^4.1.0"
58
65
  },
59
66
  "devDependencies": {
60
67
  "@tanstack/react-query": "^5.100.3",
61
68
  "@types/react": "^19.0.0",
62
- "msw": "^2.13.6"
63
- },
64
- "peerDependencies": {
65
- "@tanstack/react-query": "^5.100.3",
66
- "react": ">=19",
69
+ "@types/react-dom": "^19.0.0",
70
+ "msw": "^2.13.6",
67
71
  "valibot": "^1.3.1"
68
72
  }
69
73
  }
@@ -1,41 +0,0 @@
1
- import type { TDevtoolsPosition } from "../../core/ActionDevtools.types";
2
- export interface IDevtoolsLauncherItem {
3
- id: string;
4
- label: string;
5
- icon: string;
6
- badge?: string;
7
- onOpen: () => void;
8
- }
9
- export type TDockSide = "top" | "bottom" | "left" | "right";
10
- export declare function getDockSide(pos: TDevtoolsPosition): TDockSide;
11
- export declare function PanelHeader({ position, onPositionChange, onClose, onClear, openOthers, }: {
12
- position: TDevtoolsPosition;
13
- onPositionChange: (p: TDevtoolsPosition) => void;
14
- onClose: () => void;
15
- onClear?: () => void;
16
- openOthers?: IDevtoolsLauncherItem[];
17
- }): import("react/jsx-runtime").JSX.Element;
18
- export declare function ResizeHandle({ dockSide, dockedSize, onChange, }: {
19
- dockSide: TDockSide;
20
- dockedSize: number;
21
- onChange: (size: number) => void;
22
- }): import("react/jsx-runtime").JSX.Element;
23
- /**
24
- * Draggable divider between the list and the detail pane. `horizontal` refers to
25
- * the split axis: a row layout (dock top/bottom) splits horizontally and drags
26
- * left/right; a column layout (dock left/right) splits vertically. The reported
27
- * ratio is the fraction of the container the *detail* pane should occupy.
28
- */
29
- export declare function SplitHandle({ horizontal, onRatioChange, }: {
30
- horizontal: boolean;
31
- onRatioChange: (ratio: number) => void;
32
- }): import("react/jsx-runtime").JSX.Element;
33
- /**
34
- * The combined, page-wide launcher shown while every devtool is collapsed — one
35
- * grouped pill with a segment per registered devtool, so the buttons never
36
- * overlap or hide behind each other. Rendered by the coordinator's "primary"
37
- * devtool only.
38
- */
39
- export declare function DevtoolsLauncher({ items }: {
40
- items: IDevtoolsLauncherItem[];
41
- }): import("react/jsx-runtime").JSX.Element;
@@ -1,54 +0,0 @@
1
- export type TDockSide = "top" | "bottom" | "left" | "right";
2
- /** A handle to one registered devtool, used to render launch controls. */
3
- export interface IDockDevtoolRef {
4
- id: string;
5
- label: string;
6
- icon: string;
7
- badge?: string;
8
- onOpen: () => void;
9
- }
10
- /** The live, syncable part of a devtool's registration. */
11
- export interface IDockDevtoolSync {
12
- side: TDockSide;
13
- size: number;
14
- open: boolean;
15
- badge?: string;
16
- }
17
- export interface IDockDevtoolInput extends IDockDevtoolSync {
18
- id: string;
19
- label: string;
20
- icon: string;
21
- onOpen: () => void;
22
- }
23
- export interface IDockView {
24
- /** Offset (px) from the docked edge — stacks open panels on the same side. */
25
- dockOffset: number;
26
- /**
27
- * True when this panel shares its dock side with another open panel (stacked
28
- * either nearer or further from the edge). Stacked panels square off all their
29
- * corners so they sit flush as one continuous block — only a panel alone on
30
- * its side keeps its rounded, page-facing corners.
31
- */
32
- stacked: boolean;
33
- /** Is any devtool on the page currently open? */
34
- anyOpen: boolean;
35
- /** First-registered devtool — the one that renders the combined launcher. */
36
- isPrimary: boolean;
37
- /** Every registered devtool, for the combined launcher. */
38
- devtools: IDockDevtoolRef[];
39
- /** Closed devtools other than this one, for an open panel's header. */
40
- otherClosed: IDockDevtoolRef[];
41
- }
42
- export interface IDevtoolsDockCoordinator {
43
- version: number;
44
- register(panel: IDockDevtoolInput): () => void;
45
- update(id: string, next: IDockDevtoolSync): void;
46
- getView(id: string): IDockView;
47
- subscribe(listener: () => void): () => void;
48
- }
49
- /**
50
- * Returns the page-wide dock coordinator, installing it on `window` the first
51
- * time it is requested. On the server (no `window`) a throwaway instance is
52
- * returned so callers can use it unconditionally.
53
- */
54
- export declare function getDevtoolsDockCoordinator(): IDevtoolsDockCoordinator;