@nice-code/action 0.7.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.
Files changed (145) hide show
  1. package/build/ActionDevtoolsCore-B4s6aGvI.d.ts +79 -0
  2. package/build/ActionDevtoolsCore-BLeY_N-3.js +159 -0
  3. package/build/ActionDevtoolsCore-BLeY_N-3.js.map +1 -0
  4. package/build/ActionDevtoolsCore-Pg7ERO3L.d.ts +79 -0
  5. package/build/ActionDevtoolsCore-yfJ9tkvl.js +154 -0
  6. package/build/ActionDevtoolsCore-yfJ9tkvl.js.map +1 -0
  7. package/build/ActionPayload.types-BN-rXFBK.d.ts +2328 -0
  8. package/build/ActionPayload.types-D28ELKXC.d.ts +2328 -0
  9. package/build/RunningAction.types-C176rqHG.js +22 -0
  10. package/build/RunningAction.types-C176rqHG.js.map +1 -0
  11. package/build/RunningAction.types-DjCX1xp5.js +39 -0
  12. package/build/RunningAction.types-DjCX1xp5.js.map +1 -0
  13. package/build/devtools/browser/index.d.ts +17 -0
  14. package/build/devtools/browser/index.js +3775 -5814
  15. package/build/devtools/browser/index.js.map +1 -0
  16. package/build/devtools/server/index.d.ts +35 -0
  17. package/build/devtools/server/index.js +97 -255
  18. package/build/devtools/server/index.js.map +1 -0
  19. package/build/index.d.ts +2 -0
  20. package/build/index.js +3877 -3674
  21. package/build/index.js.map +1 -0
  22. package/build/react-query/index.d.ts +17 -0
  23. package/build/react-query/index.js +60 -60
  24. package/build/react-query/index.js.map +1 -0
  25. package/package.json +34 -29
  26. package/build/types/ActionDefinition/Action/Action.combined.types.d.ts +0 -37
  27. package/build/types/ActionDefinition/Action/ActionBase.d.ts +0 -14
  28. package/build/types/ActionDefinition/Action/ActionBase.types.d.ts +0 -24
  29. package/build/types/ActionDefinition/Action/Context/ActionContext.d.ts +0 -25
  30. package/build/types/ActionDefinition/Action/Context/ActionContext.types.d.ts +0 -35
  31. package/build/types/ActionDefinition/Action/Core/ActionCore.d.ts +0 -19
  32. package/build/types/ActionDefinition/Action/Core/ActionCore.types.d.ts +0 -10
  33. package/build/types/ActionDefinition/Action/Payload/ActionPayload.d.ts +0 -14
  34. package/build/types/ActionDefinition/Action/Payload/ActionPayload.types.d.ts +0 -110
  35. package/build/types/ActionDefinition/Action/Payload/ActionPayload_Progress.d.ts +0 -15
  36. package/build/types/ActionDefinition/Action/Payload/ActionPayload_Request.d.ts +0 -26
  37. package/build/types/ActionDefinition/Action/Payload/ActionPayload_Result.d.ts +0 -19
  38. package/build/types/ActionDefinition/Action/RunningAction.d.ts +0 -36
  39. package/build/types/ActionDefinition/Action/RunningAction.types.d.ts +0 -73
  40. package/build/types/ActionDefinition/Domain/ActionDomain.d.ts +0 -42
  41. package/build/types/ActionDefinition/Domain/ActionDomain.types.d.ts +0 -43
  42. package/build/types/ActionDefinition/Domain/ActionDomainBase.d.ts +0 -14
  43. package/build/types/ActionDefinition/Domain/ActionRootDomain.d.ts +0 -24
  44. package/build/types/ActionDefinition/Domain/helpers/createRootActionDomain.d.ts +0 -5
  45. package/build/types/ActionDefinition/Schema/ActionSchema.d.ts +0 -68
  46. package/build/types/ActionDefinition/Schema/ActionSchema.types.d.ts +0 -28
  47. package/build/types/ActionRuntime/ActionDomainManager.d.ts +0 -13
  48. package/build/types/ActionRuntime/ActionRuntime.d.ts +0 -56
  49. package/build/types/ActionRuntime/ActionRuntime.types.d.ts +0 -22
  50. package/build/types/ActionRuntime/ActionRuntimeManager.d.ts +0 -20
  51. package/build/types/ActionRuntime/Handler/ActionHandler.d.ts +0 -16
  52. package/build/types/ActionRuntime/Handler/ActionHandler.types.d.ts +0 -65
  53. package/build/types/ActionRuntime/Handler/ExternalClient/ActionExternalClientHandler.d.ts +0 -45
  54. package/build/types/ActionRuntime/Handler/ExternalClient/ActionExternalClientHandler.types.d.ts +0 -7
  55. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/ConnectionTransportManager.d.ts +0 -16
  56. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Custom/CustomConnection.d.ts +0 -7
  57. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Custom/CustomTransport.d.ts +0 -43
  58. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Custom/TransportCustom.types.d.ts +0 -11
  59. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Http/HttpConnection.d.ts +0 -8
  60. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Http/HttpTransport.d.ts +0 -26
  61. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Http/TransportHttp.types.d.ts +0 -16
  62. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Transport.d.ts +0 -27
  63. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Transport.types.d.ts +0 -125
  64. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/TransportConnection.d.ts +0 -27
  65. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/TransportWebSocket.types.d.ts +0 -41
  66. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/WebSocketConnection.d.ts +0 -33
  67. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/WebSocketTransport.d.ts +0 -60
  68. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/actionFrameCrypto.d.ts +0 -31
  69. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/actionWireCodec.d.ts +0 -41
  70. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/actionWsHandshake.d.ts +0 -187
  71. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/createBinaryWsAdapter.d.ts +0 -20
  72. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/createBinaryWsSessionFactory.d.ts +0 -31
  73. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/secureWsChannel.d.ts +0 -63
  74. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/ws_util.d.ts +0 -11
  75. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/err_nice_transport.d.ts +0 -36
  76. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/err_nice_transport_ws.d.ts +0 -18
  77. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/helpers/addTransportStatusMetadata.d.ts +0 -2
  78. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/helpers/createUnsetTransportResolvers.d.ts +0 -2
  79. package/build/types/ActionRuntime/Handler/ExternalClient/err_nice_external_client.d.ts +0 -5
  80. package/build/types/ActionRuntime/Handler/Local/ActionLocalHandler.d.ts +0 -55
  81. package/build/types/ActionRuntime/Handler/Local/ActionLocalHandler.types.d.ts +0 -7
  82. package/build/types/ActionRuntime/Handler/Server/ActionServerHandler.d.ts +0 -197
  83. package/build/types/ActionRuntime/Handler/Server/createSecureActionServer.d.ts +0 -71
  84. package/build/types/ActionRuntime/HandlerCallStack.d.ts +0 -3
  85. package/build/types/ActionRuntime/Routing/ActionRouter.d.ts +0 -55
  86. package/build/types/ActionRuntime/Routing/ActionRouter.types.d.ts +0 -20
  87. package/build/types/ActionRuntime/RuntimeCoordinate.d.ts +0 -58
  88. package/build/types/ActionRuntime/test/helpers/new_action_test_data.d.ts +0 -207
  89. package/build/types/ActionRuntime/utils/runtimeCoordinateToStringIds.d.ts +0 -2
  90. package/build/types/devtools/browser/NiceActionDevtools.d.ts +0 -14
  91. package/build/types/devtools/browser/components/ActionErrorDisplay.d.ts +0 -5
  92. package/build/types/devtools/browser/components/CallStackSection.d.ts +0 -8
  93. package/build/types/devtools/browser/components/ChildDispatchChips.d.ts +0 -6
  94. package/build/types/devtools/browser/components/Chip.d.ts +0 -22
  95. package/build/types/devtools/browser/components/DetailSection.d.ts +0 -5
  96. package/build/types/devtools/browser/components/DomainChip.d.ts +0 -8
  97. package/build/types/devtools/browser/components/HandlerChips.d.ts +0 -21
  98. package/build/types/devtools/browser/components/Icon.d.ts +0 -16
  99. package/build/types/devtools/browser/components/MetaSection.d.ts +0 -4
  100. package/build/types/devtools/browser/components/NiceErrorDisplay.d.ts +0 -19
  101. package/build/types/devtools/browser/components/OriginChip.d.ts +0 -15
  102. package/build/types/devtools/browser/components/PanelChrome.d.ts +0 -41
  103. package/build/types/devtools/browser/components/RoutingSection.d.ts +0 -5
  104. package/build/types/devtools/browser/components/RunningTimer.d.ts +0 -7
  105. package/build/types/devtools/browser/components/SectionLabel.d.ts +0 -4
  106. package/build/types/devtools/browser/components/StackTraceSection.d.ts +0 -9
  107. package/build/types/devtools/browser/components/Tooltip.d.ts +0 -24
  108. package/build/types/devtools/browser/components/action_detail/ActionDetailPanel.d.ts +0 -7
  109. package/build/types/devtools/browser/components/action_list/ActionEntryRow.d.ts +0 -14
  110. package/build/types/devtools/browser/components/action_list/ActionInputAndOutputChip.d.ts +0 -11
  111. package/build/types/devtools/browser/components/action_list/ActionList.d.ts +0 -10
  112. package/build/types/devtools/browser/components/action_list/IoTooltipContent.d.ts +0 -6
  113. package/build/types/devtools/browser/components/action_list/action_list.types.d.ts +0 -4
  114. package/build/types/devtools/browser/components/sourceMapResolver.d.ts +0 -6
  115. package/build/types/devtools/browser/components/utils.d.ts +0 -22
  116. package/build/types/devtools/browser/devtools_dock.d.ts +0 -54
  117. package/build/types/devtools/browser/devtools_storage.d.ts +0 -6
  118. package/build/types/devtools/browser/index.d.ts +0 -3
  119. package/build/types/devtools/browser/ui_util/size.d.ts +0 -6
  120. package/build/types/devtools/core/ActionDevtools.types.d.ts +0 -55
  121. package/build/types/devtools/core/ActionDevtoolsCore.d.ts +0 -14
  122. package/build/types/devtools/core/devtools_colors.d.ts +0 -63
  123. package/build/types/devtools/server/NiceActionServerDevtools.d.ts +0 -30
  124. package/build/types/devtools/server/index.d.ts +0 -3
  125. package/build/types/errors/err_nice_action.d.ts +0 -96
  126. package/build/types/index.d.ts +0 -41
  127. package/build/types/nice_action.static.d.ts +0 -3
  128. package/build/types/react-query/hooks/useActionMutation.d.ts +0 -10
  129. package/build/types/react-query/hooks/useActionQuery.d.ts +0 -17
  130. package/build/types/react-query/index.d.ts +0 -2
  131. package/build/types/utils/assertIsActionJson.d.ts +0 -2
  132. package/build/types/utils/decodeActionFrame.d.ts +0 -17
  133. package/build/types/utils/getAssumedRuntimeEnvironment.d.ts +0 -2
  134. package/build/types/utils/hashPayloadData.d.ts +0 -5
  135. package/build/types/utils/isActionPayload_Any_JsonObject.d.ts +0 -2
  136. package/build/types/utils/isActionPayload_Progress_JsonObject.d.ts +0 -2
  137. package/build/types/utils/isActionPayload_Request_JsonObject.d.ts +0 -2
  138. package/build/types/utils/isActionPayload_Result_JsonObject.d.ts +0 -2
  139. package/build/types/utils/isAction_Any_Instance.d.ts +0 -3
  140. package/build/types/utils/isAction_Any_JsonObject.d.ts +0 -2
  141. package/build/types/utils/isAction_Base_JsonObject.d.ts +0 -2
  142. package/build/types/utils/isAction_Context_JsonObject.d.ts +0 -2
  143. package/build/types/utils/isAction_Core_JsonObject.d.ts +0 -2
  144. package/build/types/utils/typescript/MaybePromise.d.ts +0 -1
  145. package/build/types/utils/wait.utils.d.ts +0 -13
@@ -0,0 +1,79 @@
1
+ import { Bn as IRuntimeCoordinate, _ as TActionProgress } from "./ActionPayload.types-D28ELKXC.js";
2
+ //#region ../nice-devtools-shared/src/components/PanelChrome.d.ts
3
+ /** Where a devtools panel is docked. */
4
+ type TDevtoolsPosition = "dock-bottom" | "dock-top" | "dock-left" | "dock-right";
5
+ //#endregion
6
+ //#region src/devtools/core/ActionDevtools.types.d.ts
7
+ type TDevtoolsActionStatus = "running" | "success" | "action-error" | "failed" | "aborted";
8
+ interface IDevtoolsRouteItem {
9
+ runtime: IRuntimeCoordinate;
10
+ handlerType: "local" | "external";
11
+ handlerClient?: {
12
+ envId: string;
13
+ perId?: string;
14
+ insId?: string;
15
+ };
16
+ /** Transport type string (e.g. "http", "ws", "custom"). */
17
+ transport?: string;
18
+ /** Short transport summary for chips (e.g. "POST /resolve_action"). */
19
+ transportSummary?: string;
20
+ /** Resolved endpoint (request URL / WebSocket URL), when available. */
21
+ transportUrl?: string;
22
+ time: number;
23
+ label?: string;
24
+ }
25
+ interface IDevtoolsActionMeta {
26
+ timeCreated: number;
27
+ originClient: {
28
+ envId: string;
29
+ perId?: string;
30
+ insId?: string;
31
+ };
32
+ routing: IDevtoolsRouteItem[];
33
+ }
34
+ interface IDevtoolsActionEntry {
35
+ cuid: string;
36
+ actionId: string;
37
+ domain: string;
38
+ allDomains: string[];
39
+ status: TDevtoolsActionStatus;
40
+ startTime: number;
41
+ endTime?: number;
42
+ input: unknown;
43
+ inputHash?: string;
44
+ output?: unknown;
45
+ outputHash?: string;
46
+ error?: unknown;
47
+ abortReason?: unknown;
48
+ progressUpdates: TActionProgress[];
49
+ meta: IDevtoolsActionMeta;
50
+ parentCuid?: string;
51
+ callSite?: string;
52
+ errorStack?: string;
53
+ }
54
+ type TDevtoolsListener = (entries: readonly IDevtoolsActionEntry[]) => void;
55
+ interface IDevtoolsObservableDomain {
56
+ domain: string;
57
+ addActionListener(listener: (update: any) => void): () => void;
58
+ }
59
+ //#endregion
60
+ //#region src/devtools/core/ActionDevtoolsCore.d.ts
61
+ interface IActionDevtoolsCoreOptions {
62
+ /** Max root entries to retain. Older entries (and their children) are evicted. */
63
+ maxEntries?: number;
64
+ }
65
+ declare class ActionDevtoolsCore {
66
+ private _entries;
67
+ private _listeners;
68
+ private readonly _maxEntries;
69
+ constructor(options?: IActionDevtoolsCoreOptions);
70
+ attachToDomain(domain: IDevtoolsObservableDomain): () => void;
71
+ getEntries(): readonly IDevtoolsActionEntry[];
72
+ subscribe(listener: TDevtoolsListener): () => void;
73
+ clear(): void;
74
+ private _updateEntry;
75
+ private _notify;
76
+ }
77
+ //#endregion
78
+ export { TDevtoolsActionStatus as a, IDevtoolsObservableDomain as i, IActionDevtoolsCoreOptions as n, TDevtoolsListener as o, IDevtoolsActionEntry as r, TDevtoolsPosition as s, ActionDevtoolsCore as t };
79
+ //# sourceMappingURL=ActionDevtoolsCore-B4s6aGvI.d.ts.map
@@ -0,0 +1,159 @@
1
+ require("./RunningAction.types-DjCX1xp5.js");
2
+ //#region src/devtools/core/ActionDevtoolsCore.ts
3
+ function serializeErrorForDisplay(error) {
4
+ if (error != null && typeof error === "object" && error.name === "NiceError" && typeof error.toJsonObject === "function") return error.toJsonObject();
5
+ return error;
6
+ }
7
+ function extractRouting(context) {
8
+ return (context?.routing ?? []).map((item) => {
9
+ const handler = item.handler;
10
+ const isExternal = handler?.type === "external";
11
+ return {
12
+ runtime: {
13
+ envId: item.runtime?.envId ?? "unknown",
14
+ perId: item.runtime?.perId,
15
+ insId: item.runtime?.insId
16
+ },
17
+ handlerType: isExternal ? "external" : "local",
18
+ handlerClient: isExternal && handler.client != null ? {
19
+ envId: handler.client.envId ?? "unknown",
20
+ perId: handler.client.perId,
21
+ insId: handler.client.insId
22
+ } : void 0,
23
+ transport: isExternal ? handler.transType : void 0,
24
+ transportSummary: isExternal ? handler.transInfo?.summary : void 0,
25
+ transportUrl: isExternal ? handler.transInfo?.url : void 0,
26
+ time: item.time
27
+ };
28
+ });
29
+ }
30
+ function extractMeta(context) {
31
+ return {
32
+ timeCreated: context?.timeCreated ?? Date.now(),
33
+ originClient: {
34
+ envId: context?.originClient?.envId ?? "unknown",
35
+ perId: context?.originClient?.perId,
36
+ insId: context?.originClient?.insId
37
+ },
38
+ routing: extractRouting(context)
39
+ };
40
+ }
41
+ var ActionDevtoolsCore = class {
42
+ _entries = [];
43
+ _listeners = /* @__PURE__ */ new Set();
44
+ _maxEntries;
45
+ constructor(options = {}) {
46
+ this._maxEntries = options.maxEntries ?? 500;
47
+ }
48
+ attachToDomain(domain) {
49
+ return domain.addActionListener((update) => {
50
+ const { runningAction, type, time } = update;
51
+ if (type === "started") {
52
+ const entry = {
53
+ cuid: runningAction.cuid,
54
+ actionId: runningAction.id,
55
+ domain: runningAction.domain,
56
+ allDomains: [...runningAction.allDomains],
57
+ status: "running",
58
+ startTime: time,
59
+ input: runningAction.state?.request?.input,
60
+ inputHash: runningAction.state?.request?.inputHash,
61
+ progressUpdates: [],
62
+ meta: extractMeta(runningAction.context),
63
+ parentCuid: runningAction.parentCuid,
64
+ callSite: runningAction.callSite
65
+ };
66
+ this._entries = [entry, ...this._entries];
67
+ if (this._entries.length > this._maxEntries) this._entries.length = this._maxEntries;
68
+ this._notify();
69
+ } else if (type === "progress") this._updateEntry(runningAction.cuid, (e) => ({
70
+ ...e,
71
+ progressUpdates: [...e.progressUpdates, update.progress]
72
+ }));
73
+ else if (type === "finished") this._updateEntry(runningAction.cuid, (e) => {
74
+ const responseRouting = extractRouting(update.response?.context);
75
+ const localRouting = extractRouting(runningAction.context);
76
+ const routing = responseRouting.length >= localRouting.length ? responseRouting : localRouting;
77
+ const base = {
78
+ ...e,
79
+ endTime: time,
80
+ meta: {
81
+ ...e.meta,
82
+ routing
83
+ }
84
+ };
85
+ const finishType = update.finishType;
86
+ if (finishType === "success") {
87
+ const result = update.response?.result;
88
+ const outputHash = update.response?.outputHash;
89
+ if (result != null && !result.ok) {
90
+ const rawError = result.error;
91
+ const errorStack = rawError instanceof Error ? rawError.stack : void 0;
92
+ return {
93
+ ...base,
94
+ status: "action-error",
95
+ outputHash,
96
+ error: serializeErrorForDisplay(rawError),
97
+ errorStack
98
+ };
99
+ }
100
+ return {
101
+ ...base,
102
+ status: "success",
103
+ output: result?.output,
104
+ outputHash
105
+ };
106
+ }
107
+ if (finishType === "failed") {
108
+ const rawError = update.error;
109
+ const errorStack = rawError instanceof Error ? rawError.stack : void 0;
110
+ return {
111
+ ...base,
112
+ status: "failed",
113
+ error: serializeErrorForDisplay(rawError),
114
+ errorStack
115
+ };
116
+ }
117
+ const abortReason = update.reason;
118
+ const errorStack = abortReason instanceof Error ? abortReason.stack : void 0;
119
+ return {
120
+ ...base,
121
+ status: "aborted",
122
+ abortReason: serializeErrorForDisplay(abortReason),
123
+ errorStack
124
+ };
125
+ });
126
+ });
127
+ }
128
+ getEntries() {
129
+ return this._entries;
130
+ }
131
+ subscribe(listener) {
132
+ this._listeners.add(listener);
133
+ listener(this._entries);
134
+ return () => {
135
+ this._listeners.delete(listener);
136
+ };
137
+ }
138
+ clear() {
139
+ this._entries = [];
140
+ this._notify();
141
+ }
142
+ _updateEntry(cuid, updater) {
143
+ this._entries = this._entries.map((e) => e.cuid === cuid ? updater(e) : e);
144
+ this._notify();
145
+ }
146
+ _notify() {
147
+ const snapshot = this._entries;
148
+ for (const listener of this._listeners) listener(snapshot);
149
+ }
150
+ };
151
+ //#endregion
152
+ Object.defineProperty(exports, "ActionDevtoolsCore", {
153
+ enumerable: true,
154
+ get: function() {
155
+ return ActionDevtoolsCore;
156
+ }
157
+ });
158
+
159
+ //# sourceMappingURL=ActionDevtoolsCore-BLeY_N-3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionDevtoolsCore-BLeY_N-3.js","names":[],"sources":["../src/devtools/core/ActionDevtoolsCore.ts"],"sourcesContent":["import {\r\n ERunningActionFinishedType,\r\n ERunningActionUpdateType,\r\n} from \"../../ActionDefinition/Action/RunningAction.types\";\r\nimport type {\r\n IDevtoolsActionEntry,\r\n IDevtoolsActionMeta,\r\n IDevtoolsObservableDomain,\r\n IDevtoolsRouteItem,\r\n TDevtoolsListener,\r\n} from \"./ActionDevtools.types\";\r\n\r\nexport interface IActionDevtoolsCoreOptions {\r\n /** Max root entries to retain. Older entries (and their children) are evicted. */\r\n maxEntries?: number;\r\n}\r\n\r\nfunction serializeErrorForDisplay(error: unknown): unknown {\r\n if (\r\n error != null &&\r\n typeof error === \"object\" &&\r\n (error as any).name === \"NiceError\" &&\r\n typeof (error as any).toJsonObject === \"function\"\r\n ) {\r\n return (error as any).toJsonObject();\r\n }\r\n return error;\r\n}\r\n\r\nfunction extractRouting(context: any): IDevtoolsRouteItem[] {\r\n return (context?.routing ?? []).map((item: any): IDevtoolsRouteItem => {\r\n const handler = item.handler;\r\n const isExternal = handler?.type === \"external\";\r\n return {\r\n runtime: {\r\n envId: item.runtime?.envId ?? \"unknown\",\r\n perId: item.runtime?.perId,\r\n insId: item.runtime?.insId,\r\n },\r\n handlerType: isExternal ? \"external\" : \"local\",\r\n handlerClient:\r\n isExternal && handler.client != null\r\n ? {\r\n envId: handler.client.envId ?? \"unknown\",\r\n perId: handler.client.perId,\r\n insId: handler.client.insId,\r\n }\r\n : undefined,\r\n transport: isExternal ? handler.transType : undefined,\r\n transportSummary: isExternal ? handler.transInfo?.summary : undefined,\r\n transportUrl: isExternal ? handler.transInfo?.url : undefined,\r\n time: item.time,\r\n };\r\n });\r\n}\r\n\r\nfunction extractMeta(context: any): IDevtoolsActionMeta {\r\n return {\r\n timeCreated: context?.timeCreated ?? Date.now(),\r\n originClient: {\r\n envId: context?.originClient?.envId ?? \"unknown\",\r\n perId: context?.originClient?.perId,\r\n insId: context?.originClient?.insId,\r\n },\r\n routing: extractRouting(context),\r\n };\r\n}\r\n\r\nexport class ActionDevtoolsCore {\r\n private _entries: IDevtoolsActionEntry[] = [];\r\n private _listeners: Set<TDevtoolsListener> = new Set();\r\n private readonly _maxEntries: number;\r\n\r\n constructor(options: IActionDevtoolsCoreOptions = {}) {\r\n this._maxEntries = options.maxEntries ?? 500;\r\n }\r\n\r\n attachToDomain(domain: IDevtoolsObservableDomain): () => void {\r\n return domain.addActionListener((update) => {\r\n const { runningAction, type, time } = update;\r\n\r\n if (type === ERunningActionUpdateType.started) {\r\n const entry: IDevtoolsActionEntry = {\r\n cuid: runningAction.cuid,\r\n actionId: runningAction.id,\r\n domain: runningAction.domain,\r\n allDomains: [...runningAction.allDomains],\r\n status: \"running\",\r\n startTime: time,\r\n input: runningAction.state?.request?.input,\r\n inputHash: runningAction.state?.request?.inputHash,\r\n progressUpdates: [],\r\n meta: extractMeta(runningAction.context),\r\n parentCuid: runningAction.parentCuid,\r\n callSite: runningAction.callSite,\r\n };\r\n this._entries = [entry, ...this._entries];\r\n // Bound retention: entries are newest-first, so the oldest fall off the tail.\r\n // Grouping already renders any child whose parent is gone as its own root, so\r\n // dropping an old parent never breaks the surviving children's display.\r\n if (this._entries.length > this._maxEntries) {\r\n this._entries.length = this._maxEntries;\r\n }\r\n this._notify();\r\n } else if (type === ERunningActionUpdateType.progress) {\r\n this._updateEntry(runningAction.cuid, (e) => ({\r\n ...e,\r\n progressUpdates: [...e.progressUpdates, update.progress],\r\n }));\r\n } else if (type === ERunningActionUpdateType.finished) {\r\n this._updateEntry(runningAction.cuid, (e) => {\r\n // On success the result payload's context may carry the full routing from the handling\r\n // runtime (including backend hops) — richer than the local context, which only has this\r\n // side's outgoing hops. Prefer it *only when it's actually richer*: the optimized binary\r\n // WS session strips routing from the wire and reconstructs an empty array, so an empty\r\n // response routing must never clobber the real local hops (otherwise the entry renders as\r\n // \"call\"/\"local\" instead of \"→ ws → backend\").\r\n const responseRouting = extractRouting((update as any).response?.context);\r\n const localRouting = extractRouting(runningAction.context);\r\n const routing =\r\n responseRouting.length >= localRouting.length ? responseRouting : localRouting;\r\n const base: IDevtoolsActionEntry = {\r\n ...e,\r\n endTime: time,\r\n meta: { ...e.meta, routing },\r\n };\r\n const finishType: string = update.finishType;\r\n\r\n if (finishType === ERunningActionFinishedType.success) {\r\n const result = update.response?.result;\r\n const outputHash: string | undefined = update.response?.outputHash;\r\n if (result != null && !result.ok) {\r\n const rawError = result.error;\r\n const errorStack = rawError instanceof Error ? rawError.stack : undefined;\r\n return {\r\n ...base,\r\n status: \"action-error\",\r\n outputHash,\r\n error: serializeErrorForDisplay(rawError),\r\n errorStack,\r\n };\r\n }\r\n return { ...base, status: \"success\", output: result?.output, outputHash };\r\n }\r\n if (finishType === ERunningActionFinishedType.failed) {\r\n const rawError = (update as any).error;\r\n const errorStack = rawError instanceof Error ? rawError.stack : undefined;\r\n return {\r\n ...base,\r\n status: \"failed\",\r\n error: serializeErrorForDisplay(rawError),\r\n errorStack,\r\n };\r\n }\r\n const abortReason = update.reason;\r\n const errorStack = abortReason instanceof Error ? abortReason.stack : undefined;\r\n return {\r\n ...base,\r\n status: \"aborted\",\r\n abortReason: serializeErrorForDisplay(abortReason),\r\n errorStack,\r\n };\r\n });\r\n }\r\n });\r\n }\r\n\r\n getEntries(): readonly IDevtoolsActionEntry[] {\r\n return this._entries;\r\n }\r\n\r\n subscribe(listener: TDevtoolsListener): () => void {\r\n this._listeners.add(listener);\r\n listener(this._entries);\r\n return () => {\r\n this._listeners.delete(listener);\r\n };\r\n }\r\n\r\n clear(): void {\r\n this._entries = [];\r\n this._notify();\r\n }\r\n\r\n private _updateEntry(\r\n cuid: string,\r\n updater: (entry: IDevtoolsActionEntry) => IDevtoolsActionEntry,\r\n ): void {\r\n this._entries = this._entries.map((e) => (e.cuid === cuid ? updater(e) : e));\r\n this._notify();\r\n }\r\n\r\n private _notify(): void {\r\n const snapshot = this._entries;\r\n for (const listener of this._listeners) listener(snapshot);\r\n }\r\n}\r\n"],"mappings":";;AAiBA,SAAS,yBAAyB,OAAyB;CACzD,IACE,SAAS,QACT,OAAO,UAAU,YAChB,MAAc,SAAS,eACxB,OAAQ,MAAc,iBAAiB,YAEvC,OAAQ,MAAc,aAAa;CAErC,OAAO;AACT;AAEA,SAAS,eAAe,SAAoC;CAC1D,QAAQ,SAAS,WAAW,CAAC,EAAA,CAAG,KAAK,SAAkC;EACrE,MAAM,UAAU,KAAK;EACrB,MAAM,aAAa,SAAS,SAAS;EACrC,OAAO;GACL,SAAS;IACP,OAAO,KAAK,SAAS,SAAS;IAC9B,OAAO,KAAK,SAAS;IACrB,OAAO,KAAK,SAAS;GACvB;GACA,aAAa,aAAa,aAAa;GACvC,eACE,cAAc,QAAQ,UAAU,OAC5B;IACE,OAAO,QAAQ,OAAO,SAAS;IAC/B,OAAO,QAAQ,OAAO;IACtB,OAAO,QAAQ,OAAO;GACxB,IACA,KAAA;GACN,WAAW,aAAa,QAAQ,YAAY,KAAA;GAC5C,kBAAkB,aAAa,QAAQ,WAAW,UAAU,KAAA;GAC5D,cAAc,aAAa,QAAQ,WAAW,MAAM,KAAA;GACpD,MAAM,KAAK;EACb;CACF,CAAC;AACH;A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AAM,YAAY,KAAK,YAAY,SAAS,QAAQ;CAC3D;AACF"}
@@ -0,0 +1,79 @@
1
+ import { Bn as IRuntimeCoordinate, _ as TActionProgress } from "./ActionPayload.types-BN-rXFBK.js";
2
+ //#region ../nice-devtools-shared/src/components/PanelChrome.d.ts
3
+ /** Where a devtools panel is docked. */
4
+ type TDevtoolsPosition = "dock-bottom" | "dock-top" | "dock-left" | "dock-right";
5
+ //#endregion
6
+ //#region src/devtools/core/ActionDevtools.types.d.ts
7
+ type TDevtoolsActionStatus = "running" | "success" | "action-error" | "failed" | "aborted";
8
+ interface IDevtoolsRouteItem {
9
+ runtime: IRuntimeCoordinate;
10
+ handlerType: "local" | "external";
11
+ handlerClient?: {
12
+ envId: string;
13
+ perId?: string;
14
+ insId?: string;
15
+ };
16
+ /** Transport type string (e.g. "http", "ws", "custom"). */
17
+ transport?: string;
18
+ /** Short transport summary for chips (e.g. "POST /resolve_action"). */
19
+ transportSummary?: string;
20
+ /** Resolved endpoint (request URL / WebSocket URL), when available. */
21
+ transportUrl?: string;
22
+ time: number;
23
+ label?: string;
24
+ }
25
+ interface IDevtoolsActionMeta {
26
+ timeCreated: number;
27
+ originClient: {
28
+ envId: string;
29
+ perId?: string;
30
+ insId?: string;
31
+ };
32
+ routing: IDevtoolsRouteItem[];
33
+ }
34
+ interface IDevtoolsActionEntry {
35
+ cuid: string;
36
+ actionId: string;
37
+ domain: string;
38
+ allDomains: string[];
39
+ status: TDevtoolsActionStatus;
40
+ startTime: number;
41
+ endTime?: number;
42
+ input: unknown;
43
+ inputHash?: string;
44
+ output?: unknown;
45
+ outputHash?: string;
46
+ error?: unknown;
47
+ abortReason?: unknown;
48
+ progressUpdates: TActionProgress[];
49
+ meta: IDevtoolsActionMeta;
50
+ parentCuid?: string;
51
+ callSite?: string;
52
+ errorStack?: string;
53
+ }
54
+ type TDevtoolsListener = (entries: readonly IDevtoolsActionEntry[]) => void;
55
+ interface IDevtoolsObservableDomain {
56
+ domain: string;
57
+ addActionListener(listener: (update: any) => void): () => void;
58
+ }
59
+ //#endregion
60
+ //#region src/devtools/core/ActionDevtoolsCore.d.ts
61
+ interface IActionDevtoolsCoreOptions {
62
+ /** Max root entries to retain. Older entries (and their children) are evicted. */
63
+ maxEntries?: number;
64
+ }
65
+ declare class ActionDevtoolsCore {
66
+ private _entries;
67
+ private _listeners;
68
+ private readonly _maxEntries;
69
+ constructor(options?: IActionDevtoolsCoreOptions);
70
+ attachToDomain(domain: IDevtoolsObservableDomain): () => void;
71
+ getEntries(): readonly IDevtoolsActionEntry[];
72
+ subscribe(listener: TDevtoolsListener): () => void;
73
+ clear(): void;
74
+ private _updateEntry;
75
+ private _notify;
76
+ }
77
+ //#endregion
78
+ export { TDevtoolsActionStatus as a, IDevtoolsObservableDomain as i, IActionDevtoolsCoreOptions as n, TDevtoolsListener as o, IDevtoolsActionEntry as r, TDevtoolsPosition as s, ActionDevtoolsCore as t };
79
+ //# sourceMappingURL=ActionDevtoolsCore-Pg7ERO3L.d.ts.map
@@ -0,0 +1,154 @@
1
+ import "./RunningAction.types-C176rqHG.js";
2
+ //#region src/devtools/core/ActionDevtoolsCore.ts
3
+ function serializeErrorForDisplay(error) {
4
+ if (error != null && typeof error === "object" && error.name === "NiceError" && typeof error.toJsonObject === "function") return error.toJsonObject();
5
+ return error;
6
+ }
7
+ function extractRouting(context) {
8
+ return (context?.routing ?? []).map((item) => {
9
+ const handler = item.handler;
10
+ const isExternal = handler?.type === "external";
11
+ return {
12
+ runtime: {
13
+ envId: item.runtime?.envId ?? "unknown",
14
+ perId: item.runtime?.perId,
15
+ insId: item.runtime?.insId
16
+ },
17
+ handlerType: isExternal ? "external" : "local",
18
+ handlerClient: isExternal && handler.client != null ? {
19
+ envId: handler.client.envId ?? "unknown",
20
+ perId: handler.client.perId,
21
+ insId: handler.client.insId
22
+ } : void 0,
23
+ transport: isExternal ? handler.transType : void 0,
24
+ transportSummary: isExternal ? handler.transInfo?.summary : void 0,
25
+ transportUrl: isExternal ? handler.transInfo?.url : void 0,
26
+ time: item.time
27
+ };
28
+ });
29
+ }
30
+ function extractMeta(context) {
31
+ return {
32
+ timeCreated: context?.timeCreated ?? Date.now(),
33
+ originClient: {
34
+ envId: context?.originClient?.envId ?? "unknown",
35
+ perId: context?.originClient?.perId,
36
+ insId: context?.originClient?.insId
37
+ },
38
+ routing: extractRouting(context)
39
+ };
40
+ }
41
+ var ActionDevtoolsCore = class {
42
+ _entries = [];
43
+ _listeners = /* @__PURE__ */ new Set();
44
+ _maxEntries;
45
+ constructor(options = {}) {
46
+ this._maxEntries = options.maxEntries ?? 500;
47
+ }
48
+ attachToDomain(domain) {
49
+ return domain.addActionListener((update) => {
50
+ const { runningAction, type, time } = update;
51
+ if (type === "started") {
52
+ const entry = {
53
+ cuid: runningAction.cuid,
54
+ actionId: runningAction.id,
55
+ domain: runningAction.domain,
56
+ allDomains: [...runningAction.allDomains],
57
+ status: "running",
58
+ startTime: time,
59
+ input: runningAction.state?.request?.input,
60
+ inputHash: runningAction.state?.request?.inputHash,
61
+ progressUpdates: [],
62
+ meta: extractMeta(runningAction.context),
63
+ parentCuid: runningAction.parentCuid,
64
+ callSite: runningAction.callSite
65
+ };
66
+ this._entries = [entry, ...this._entries];
67
+ if (this._entries.length > this._maxEntries) this._entries.length = this._maxEntries;
68
+ this._notify();
69
+ } else if (type === "progress") this._updateEntry(runningAction.cuid, (e) => ({
70
+ ...e,
71
+ progressUpdates: [...e.progressUpdates, update.progress]
72
+ }));
73
+ else if (type === "finished") this._updateEntry(runningAction.cuid, (e) => {
74
+ const responseRouting = extractRouting(update.response?.context);
75
+ const localRouting = extractRouting(runningAction.context);
76
+ const routing = responseRouting.length >= localRouting.length ? responseRouting : localRouting;
77
+ const base = {
78
+ ...e,
79
+ endTime: time,
80
+ meta: {
81
+ ...e.meta,
82
+ routing
83
+ }
84
+ };
85
+ const finishType = update.finishType;
86
+ if (finishType === "success") {
87
+ const result = update.response?.result;
88
+ const outputHash = update.response?.outputHash;
89
+ if (result != null && !result.ok) {
90
+ const rawError = result.error;
91
+ const errorStack = rawError instanceof Error ? rawError.stack : void 0;
92
+ return {
93
+ ...base,
94
+ status: "action-error",
95
+ outputHash,
96
+ error: serializeErrorForDisplay(rawError),
97
+ errorStack
98
+ };
99
+ }
100
+ return {
101
+ ...base,
102
+ status: "success",
103
+ output: result?.output,
104
+ outputHash
105
+ };
106
+ }
107
+ if (finishType === "failed") {
108
+ const rawError = update.error;
109
+ const errorStack = rawError instanceof Error ? rawError.stack : void 0;
110
+ return {
111
+ ...base,
112
+ status: "failed",
113
+ error: serializeErrorForDisplay(rawError),
114
+ errorStack
115
+ };
116
+ }
117
+ const abortReason = update.reason;
118
+ const errorStack = abortReason instanceof Error ? abortReason.stack : void 0;
119
+ return {
120
+ ...base,
121
+ status: "aborted",
122
+ abortReason: serializeErrorForDisplay(abortReason),
123
+ errorStack
124
+ };
125
+ });
126
+ });
127
+ }
128
+ getEntries() {
129
+ return this._entries;
130
+ }
131
+ subscribe(listener) {
132
+ this._listeners.add(listener);
133
+ listener(this._entries);
134
+ return () => {
135
+ this._listeners.delete(listener);
136
+ };
137
+ }
138
+ clear() {
139
+ this._entries = [];
140
+ this._notify();
141
+ }
142
+ _updateEntry(cuid, updater) {
143
+ this._entries = this._entries.map((e) => e.cuid === cuid ? updater(e) : e);
144
+ this._notify();
145
+ }
146
+ _notify() {
147
+ const snapshot = this._entries;
148
+ for (const listener of this._listeners) listener(snapshot);
149
+ }
150
+ };
151
+ //#endregion
152
+ export { ActionDevtoolsCore as t };
153
+
154
+ //# sourceMappingURL=ActionDevtoolsCore-yfJ9tkvl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionDevtoolsCore-yfJ9tkvl.js","names":[],"sources":["../src/devtools/core/ActionDevtoolsCore.ts"],"sourcesContent":["import {\r\n ERunningActionFinishedType,\r\n ERunningActionUpdateType,\r\n} from \"../../ActionDefinition/Action/RunningAction.types\";\r\nimport type {\r\n IDevtoolsActionEntry,\r\n IDevtoolsActionMeta,\r\n IDevtoolsObservableDomain,\r\n IDevtoolsRouteItem,\r\n TDevtoolsListener,\r\n} from \"./ActionDevtools.types\";\r\n\r\nexport interface IActionDevtoolsCoreOptions {\r\n /** Max root entries to retain. Older entries (and their children) are evicted. */\r\n maxEntries?: number;\r\n}\r\n\r\nfunction serializeErrorForDisplay(error: unknown): unknown {\r\n if (\r\n error != null &&\r\n typeof error === \"object\" &&\r\n (error as any).name === \"NiceError\" &&\r\n typeof (error as any).toJsonObject === \"function\"\r\n ) {\r\n return (error as any).toJsonObject();\r\n }\r\n return error;\r\n}\r\n\r\nfunction extractRouting(context: any): IDevtoolsRouteItem[] {\r\n return (context?.routing ?? []).map((item: any): IDevtoolsRouteItem => {\r\n const handler = item.handler;\r\n const isExternal = handler?.type === \"external\";\r\n return {\r\n runtime: {\r\n envId: item.runtime?.envId ?? \"unknown\",\r\n perId: item.runtime?.perId,\r\n insId: item.runtime?.insId,\r\n },\r\n handlerType: isExternal ? \"external\" : \"local\",\r\n handlerClient:\r\n isExternal && handler.client != null\r\n ? {\r\n envId: handler.client.envId ?? \"unknown\",\r\n perId: handler.client.perId,\r\n insId: handler.client.insId,\r\n }\r\n : undefined,\r\n transport: isExternal ? handler.transType : undefined,\r\n transportSummary: isExternal ? handler.transInfo?.summary : undefined,\r\n transportUrl: isExternal ? handler.transInfo?.url : undefined,\r\n time: item.time,\r\n };\r\n });\r\n}\r\n\r\nfunction extractMeta(context: any): IDevtoolsActionMeta {\r\n return {\r\n timeCreated: context?.timeCreated ?? Date.now(),\r\n originClient: {\r\n envId: context?.originClient?.envId ?? \"unknown\",\r\n perId: context?.originClient?.perId,\r\n insId: context?.originClient?.insId,\r\n },\r\n routing: extractRouting(context),\r\n };\r\n}\r\n\r\nexport class ActionDevtoolsCore {\r\n private _entries: IDevtoolsActionEntry[] = [];\r\n private _listeners: Set<TDevtoolsListener> = new Set();\r\n private readonly _maxEntries: number;\r\n\r\n constructor(options: IActionDevtoolsCoreOptions = {}) {\r\n this._maxEntries = options.maxEntries ?? 500;\r\n }\r\n\r\n attachToDomain(domain: IDevtoolsObservableDomain): () => void {\r\n return domain.addActionListener((update) => {\r\n const { runningAction, type, time } = update;\r\n\r\n if (type === ERunningActionUpdateType.started) {\r\n const entry: IDevtoolsActionEntry = {\r\n cuid: runningAction.cuid,\r\n actionId: runningAction.id,\r\n domain: runningAction.domain,\r\n allDomains: [...runningAction.allDomains],\r\n status: \"running\",\r\n startTime: time,\r\n input: runningAction.state?.request?.input,\r\n inputHash: runningAction.state?.request?.inputHash,\r\n progressUpdates: [],\r\n meta: extractMeta(runningAction.context),\r\n parentCuid: runningAction.parentCuid,\r\n callSite: runningAction.callSite,\r\n };\r\n this._entries = [entry, ...this._entries];\r\n // Bound retention: entries are newest-first, so the oldest fall off the tail.\r\n // Grouping already renders any child whose parent is gone as its own root, so\r\n // dropping an old parent never breaks the surviving children's display.\r\n if (this._entries.length > this._maxEntries) {\r\n this._entries.length = this._maxEntries;\r\n }\r\n this._notify();\r\n } else if (type === ERunningActionUpdateType.progress) {\r\n this._updateEntry(runningAction.cuid, (e) => ({\r\n ...e,\r\n progressUpdates: [...e.progressUpdates, update.progress],\r\n }));\r\n } else if (type === ERunningActionUpdateType.finished) {\r\n this._updateEntry(runningAction.cuid, (e) => {\r\n // On success the result payload's context may carry the full routing from the handling\r\n // runtime (including backend hops) — richer than the local context, which only has this\r\n // side's outgoing hops. Prefer it *only when it's actually richer*: the optimized binary\r\n // WS session strips routing from the wire and reconstructs an empty array, so an empty\r\n // response routing must never clobber the real local hops (otherwise the entry renders as\r\n // \"call\"/\"local\" instead of \"→ ws → backend\").\r\n const responseRouting = extractRouting((update as any).response?.context);\r\n const localRouting = extractRouting(runningAction.context);\r\n const routing =\r\n responseRouting.length >= localRouting.length ? responseRouting : localRouting;\r\n const base: IDevtoolsActionEntry = {\r\n ...e,\r\n endTime: time,\r\n meta: { ...e.meta, routing },\r\n };\r\n const finishType: string = update.finishType;\r\n\r\n if (finishType === ERunningActionFinishedType.success) {\r\n const result = update.response?.result;\r\n const outputHash: string | undefined = update.response?.outputHash;\r\n if (result != null && !result.ok) {\r\n const rawError = result.error;\r\n const errorStack = rawError instanceof Error ? rawError.stack : undefined;\r\n return {\r\n ...base,\r\n status: \"action-error\",\r\n outputHash,\r\n error: serializeErrorForDisplay(rawError),\r\n errorStack,\r\n };\r\n }\r\n return { ...base, status: \"success\", output: result?.output, outputHash };\r\n }\r\n if (finishType === ERunningActionFinishedType.failed) {\r\n const rawError = (update as any).error;\r\n const errorStack = rawError instanceof Error ? rawError.stack : undefined;\r\n return {\r\n ...base,\r\n status: \"failed\",\r\n error: serializeErrorForDisplay(rawError),\r\n errorStack,\r\n };\r\n }\r\n const abortReason = update.reason;\r\n const errorStack = abortReason instanceof Error ? abortReason.stack : undefined;\r\n return {\r\n ...base,\r\n status: \"aborted\",\r\n abortReason: serializeErrorForDisplay(abortReason),\r\n errorStack,\r\n };\r\n });\r\n }\r\n });\r\n }\r\n\r\n getEntries(): readonly IDevtoolsActionEntry[] {\r\n return this._entries;\r\n }\r\n\r\n subscribe(listener: TDevtoolsListener): () => void {\r\n this._listeners.add(listener);\r\n listener(this._entries);\r\n return () => {\r\n this._listeners.delete(listener);\r\n };\r\n }\r\n\r\n clear(): void {\r\n this._entries = [];\r\n this._notify();\r\n }\r\n\r\n private _updateEntry(\r\n cuid: string,\r\n updater: (entry: IDevtoolsActionEntry) => IDevtoolsActionEntry,\r\n ): void {\r\n this._entries = this._entries.map((e) => (e.cuid === cuid ? updater(e) : e));\r\n this._notify();\r\n }\r\n\r\n private _notify(): void {\r\n const snapshot = this._entries;\r\n for (const listener of this._listeners) listener(snapshot);\r\n }\r\n}\r\n"],"mappings":";;AAiBA,SAAS,yBAAyB,OAAyB;CACzD,IACE,SAAS,QACT,OAAO,UAAU,YAChB,MAAc,SAAS,eACxB,OAAQ,MAAc,iBAAiB,YAEvC,OAAQ,MAAc,aAAa;CAErC,OAAO;AACT;AAEA,SAAS,eAAe,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