@nice-code/action 0.2.18 → 0.2.19

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/build/index.js CHANGED
@@ -603,6 +603,7 @@ var EErrId_NiceAction;
603
603
  EErrId_NiceAction2["wire_not_action_data"] = "wire_not_action_data";
604
604
  EErrId_NiceAction2["client_runtime_already_registered"] = "client_runtime_already_registered";
605
605
  EErrId_NiceAction2["client_runtime_not_registered"] = "client_runtime_not_registered";
606
+ EErrId_NiceAction2["runtime_reset"] = "runtime_reset";
606
607
  EErrId_NiceAction2["no_client_runtimes_registered"] = "no_client_runtimes_registered";
607
608
  EErrId_NiceAction2["action_input_validation_failed"] = "action_input_validation_failed";
608
609
  EErrId_NiceAction2["action_input_validation_promise"] = "action_input_validation_promise";
@@ -643,6 +644,9 @@ var err_nice_action = err_nice.createChildDomain({
643
644
  ["wire_not_action_data" /* wire_not_action_data */]: err({
644
645
  message: () => `Cannot handle wire for action: expected an object with a "domain" property of type string, a "form" property of "${"data" /* data */}" and a "type" property of "${"request" /* request */}", "${"progress" /* progress */}" or "${"result" /* result */}".`
645
646
  }),
647
+ ["runtime_reset" /* runtime_reset */]: err({
648
+ message: () => `Runtime has been reset.`
649
+ }),
646
650
  ["client_runtime_already_registered" /* client_runtime_already_registered */]: err({
647
651
  message: ({ context, client }) => `Environment is already registered${context?.domain ? ` on domain "${context.domain}"` : ""} for client [${client.stringId}]. Each client specifier (exact match on all properties) may only be registered once.`
648
652
  }),
@@ -1079,6 +1083,14 @@ class ActionRuntime {
1079
1083
  }
1080
1084
  return bestScore > 0 ? bestHandler : undefined;
1081
1085
  }
1086
+ resetRuntime() {
1087
+ for (const ra of this._pendingRunningActions.values()) {
1088
+ ra._abort(err_nice_action.fromId("runtime_reset" /* runtime_reset */));
1089
+ }
1090
+ for (const handler of this._registeredExternalHandlers) {
1091
+ handler.clearTransportCache();
1092
+ }
1093
+ }
1082
1094
  _trySetupReturnDispatch(runningAction) {
1083
1095
  const originClient = runningAction.context.originClient;
1084
1096
  if (originClient.envId === UNSET_RUNTIME_ENV_ID || originClient.isSameFor(this._coordinate).id) {
@@ -2312,7 +2324,12 @@ class ActionExternalClientHandler extends ActionHandler {
2312
2324
  handler: this.toHandlerRouteItem(transport),
2313
2325
  time: Date.now()
2314
2326
  });
2315
- const runningAction = new RunningAction({ context: action.context, request: action, parentCuid, callSite });
2327
+ const runningAction = new RunningAction({
2328
+ context: action.context,
2329
+ request: action,
2330
+ parentCuid,
2331
+ callSite
2332
+ });
2316
2333
  localRuntime.registerRunningAction(runningAction);
2317
2334
  const routeActionParams = {
2318
2335
  action,
@@ -2362,6 +2379,9 @@ class ActionExternalClientHandler extends ActionHandler {
2362
2379
  transType: transport.type
2363
2380
  };
2364
2381
  }
2382
+ clearTransportCache() {
2383
+ this._transportCache.clear();
2384
+ }
2365
2385
  }
2366
2386
  var createExternalClientHandler = (config) => {
2367
2387
  return new ActionExternalClientHandler(config);
@@ -51,5 +51,6 @@ export declare class ActionRuntime {
51
51
  * Returns `undefined` if no handler matches (score > 0 required, i.e. at least id must match).
52
52
  */
53
53
  getReturnHandlerForOrigin(originClient: RuntimeCoordinate): ActionExternalClientHandler | undefined;
54
+ resetRuntime(): void;
54
55
  private _trySetupReturnDispatch;
55
56
  }
@@ -38,5 +38,6 @@ export declare class ActionExternalClientHandler extends ActionHandler<EActionHa
38
38
  }): Promise<boolean>;
39
39
  toJsonObject(): IActionHandler_ExternalClient_Json;
40
40
  toHandlerRouteItem(transport: Transport): IActionRouteItemHandler;
41
+ clearTransportCache(): void;
41
42
  }
42
43
  export declare const createExternalClientHandler: (config: IActionExternalClientRequestHandlerConfig) => ActionExternalClientHandler;
@@ -1,5 +1,6 @@
1
1
  import { ESize } from "../ui_util/size";
2
- export declare function DomainChip({ subtle, domain, allDomains, size, }: {
2
+ export declare function DomainChip({ compact, subtle, domain, allDomains, size, }: {
3
+ compact?: boolean;
3
4
  subtle?: boolean;
4
5
  domain: string;
5
6
  allDomains: string[];
@@ -1,7 +1,9 @@
1
- export declare function countUserFrames(stack: string | undefined): number;
2
- export declare function StackTraceSection({ label, stack, color, minFrameCount, }: {
1
+ import type { IRuntimeCoordinate } from "../../../ActionRuntime/RuntimeCoordinate";
2
+ export declare function countUserFrames(_runtime: IRuntimeCoordinate, stack: string | undefined): number;
3
+ export declare function StackTraceSection({ label, stack, color, runtime, minFrameCount, }: {
3
4
  label: string;
4
5
  stack: string | undefined;
6
+ runtime: IRuntimeCoordinate;
5
7
  color?: string;
6
8
  minFrameCount?: number;
7
9
  }): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,6 @@
1
+ import type { TRuntimeCoordinateEnvId } from "../../ActionRuntime/RuntimeCoordinate";
2
+ interface TBrowserDevtoolsTypedStorage {
3
+ runtimeToProjectFilePath: Record<TRuntimeCoordinateEnvId, string>;
4
+ }
5
+ export declare const devtools_storage: import("@nice-code/util").ITypedStorage<TBrowserDevtoolsTypedStorage>;
6
+ export {};
@@ -1,12 +1,9 @@
1
1
  import type { TActionProgress } from "../../ActionDefinition/Action/Payload/ActionPayload.types";
2
+ import type { IRuntimeCoordinate } from "../../ActionRuntime/RuntimeCoordinate";
2
3
  export type TDevtoolsActionStatus = "running" | "success" | "action-error" | "failed" | "aborted";
3
4
  export type TDevtoolsPosition = "bottom-right" | "bottom-left" | "top-right" | "top-left" | "dock-bottom" | "dock-top" | "dock-left" | "dock-right";
4
5
  export interface IDevtoolsRouteItem {
5
- runtime: {
6
- envId: string;
7
- perId?: string;
8
- insId?: string;
9
- };
6
+ runtime: IRuntimeCoordinate;
10
7
  handlerType: "local" | "external";
11
8
  handlerClient?: {
12
9
  envId: string;
@@ -13,6 +13,7 @@ export declare enum EErrId_NiceAction {
13
13
  wire_not_action_data = "wire_not_action_data",
14
14
  client_runtime_already_registered = "client_runtime_already_registered",
15
15
  client_runtime_not_registered = "client_runtime_not_registered",
16
+ runtime_reset = "runtime_reset",
16
17
  no_client_runtimes_registered = "no_client_runtimes_registered",
17
18
  action_input_validation_failed = "action_input_validation_failed",
18
19
  action_input_validation_promise = "action_input_validation_promise",
@@ -61,6 +62,7 @@ export declare const err_nice_action: import("@nice-code/error").NiceErrorDomain
61
62
  actionState: string | undefined;
62
63
  }, import("@nice-code/error").JSONSerializableValue>;
63
64
  wire_not_action_data: import("@nice-code/error").INiceErrorIdMetadata<any, import("@nice-code/error").JSONSerializableValue>;
65
+ runtime_reset: import("@nice-code/error").INiceErrorIdMetadata<any, import("@nice-code/error").JSONSerializableValue>;
64
66
  client_runtime_already_registered: import("@nice-code/error").INiceErrorIdMetadata<{
65
67
  context?: IActionRuntimeManagerContext;
66
68
  client: RuntimeCoordinate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice-code/action",
3
- "version": "0.2.18",
3
+ "version": "0.2.19",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {
@@ -44,8 +44,9 @@
44
44
  "build-types": "tsc --project tsconfig.build.json"
45
45
  },
46
46
  "dependencies": {
47
- "@nice-code/common-errors": "0.2.18",
48
- "@nice-code/error": "0.2.18",
47
+ "@nice-code/common-errors": "0.2.19",
48
+ "@nice-code/error": "0.2.19",
49
+ "@nice-code/util": "0.2.19",
49
50
  "@standard-schema/spec": "^1.1.0",
50
51
  "@tanstack/react-virtual": "^3.13.26",
51
52
  "http-status-codes": "^2.3.0",