@ms-cloudpack/overlay 0.16.112 → 0.17.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 (43) hide show
  1. package/dist/browser-esm/lib/index.js +113 -204
  2. package/dist/browser-esm/lib/index.js.map +4 -4
  3. package/dist/browser-esm/ori-output.json +81 -95
  4. package/dist/browser-esm/result.json +10 -10
  5. package/lib/components/CloudpackProvider/CloudpackProvider.d.ts +3 -2
  6. package/lib/components/CloudpackProvider/CloudpackProvider.d.ts.map +1 -1
  7. package/lib/components/CloudpackProvider/CloudpackProvider.js +2 -4
  8. package/lib/components/CloudpackProvider/CloudpackProvider.js.map +1 -1
  9. package/lib/components/CloudpackProvider/useStatus.d.ts.map +1 -1
  10. package/lib/components/CloudpackProvider/useStatus.js +12 -3
  11. package/lib/components/CloudpackProvider/useStatus.js.map +1 -1
  12. package/lib/components/CloudpackProvider/useStatusDetails.d.ts +52 -16
  13. package/lib/components/CloudpackProvider/useStatusDetails.d.ts.map +1 -1
  14. package/lib/components/CloudpackProvider/useStatusDetails.js +11 -2
  15. package/lib/components/CloudpackProvider/useStatusDetails.js.map +1 -1
  16. package/lib/components/ErrorDialog/ErrorDialog.js +1 -1
  17. package/lib/components/ErrorDialog/ErrorDialog.js.map +1 -1
  18. package/lib/components/ErrorDialog/PathError.js +2 -2
  19. package/lib/components/ErrorDialog/PathError.js.map +1 -1
  20. package/lib/components/ErrorDialog/useErrorEvents.js +1 -1
  21. package/lib/components/ErrorDialog/useErrorEvents.js.map +1 -1
  22. package/lib/components/StatusDialog/StatusDialog.js +1 -1
  23. package/lib/components/StatusDialog/StatusDialog.js.map +1 -1
  24. package/lib/components/StatusDialog/TaskList.d.ts.map +1 -1
  25. package/lib/components/StatusDialog/TaskList.js +10 -1
  26. package/lib/components/StatusDialog/TaskList.js.map +1 -1
  27. package/lib/components/StatusDialog/TaskResultItem.js +2 -2
  28. package/lib/components/StatusDialog/TaskResultItem.js.map +1 -1
  29. package/lib/components/StatusDialog/TaskStatus.d.ts +2 -2
  30. package/lib/components/StatusDialog/TaskStatus.d.ts.map +1 -1
  31. package/lib/components/StatusDialog/TaskStatus.js +39 -28
  32. package/lib/components/StatusDialog/TaskStatus.js.map +1 -1
  33. package/lib/hooks/usePageLoadTimeReporter.js +2 -2
  34. package/lib/hooks/usePageLoadTimeReporter.js.map +1 -1
  35. package/lib/index.js +27 -7
  36. package/lib/index.js.map +1 -1
  37. package/lib/tsdoc-metadata.json +1 -1
  38. package/package.json +4 -6
  39. package/lib/components/CloudpackProvider/createCloudpackClient.d.ts +0 -27
  40. package/lib/components/CloudpackProvider/createCloudpackClient.d.ts.map +0 -1
  41. package/lib/components/CloudpackProvider/createCloudpackClient.js +0 -163
  42. package/lib/components/CloudpackProvider/createCloudpackClient.js.map +0 -1
  43. /package/dist/ori/logs/{2fzjpE36IG3AsNggojXVqIpCnGK-logger.log → 2gDrbKHv6HJdsrJbtR1hpUGJy8u-logger.log} +0 -0
@@ -8,183 +8,24 @@ import React15 from "react";
8
8
  import ReactDOM from "react-dom";
9
9
 
10
10
  // packages/overlay/src/components/CloudpackProvider/CloudpackProvider.tsx
11
- import React, { createContext, useState, useContext } from "react";
12
-
13
- // packages/overlay/src/components/CloudpackProvider/getCookies.ts
14
- function getCookies() {
15
- return document.cookie.split(";").map((s9) => s9.split("=")).reduce((current, nextValue) => {
16
- const name2 = nextValue[0]?.trim();
17
- const value3 = decodeURIComponent(nextValue[1]?.trim());
18
- if (name2 && value3) {
19
- current[name2] = value3;
20
- }
21
- return current;
22
- }, {});
23
- }
24
-
25
- // packages/overlay/src/components/CloudpackProvider/createCloudpackClient.ts
26
- import { createDataBus } from "@ms-cloudpack/data-bus";
27
- function createCloudpackClient() {
28
- const cookies = getCookies();
29
- const bus = createDataBus();
30
- let subCounter = 0;
31
- const subIds = {};
32
- bus.addProvider({
33
- path: [],
34
- onActivate: ({ path }) => {
35
- const id = subCounter++;
36
- subIds[path.join("/")] = id;
37
- sendMessage({ type: "subscribe", data: { path, id } });
38
- },
39
- onDeactivate: ({ path }) => {
40
- const pathString = path.join("/");
41
- const id = subIds[pathString];
42
- delete subIds[pathString];
43
- sendMessage({ type: "unsubscribe", data: { path, id } });
44
- }
45
- });
46
- const enqueuedMessages = [];
47
- const sessionId = cookies[cookieNames.sessionId];
48
- const apiUrl = cookies[cookieNames.apiUrl];
49
- const currentSequence = cookies[cookieNames.sessionSequence];
50
- let socket;
51
- let idCount = 0;
52
- function openConnection() {
53
- if (apiUrl && sessionId) {
54
- const newSocket = new WebSocket(apiUrl);
55
- newSocket.onopen = () => {
56
- console.log("socket opened");
57
- socket = newSocket;
58
- socket.onmessage = onMessageReceived;
59
- socket.onclose = () => {
60
- socket = void 0;
61
- };
62
- for (const message of enqueuedMessages) {
63
- socket.send(message);
64
- }
65
- enqueuedMessages.length = 0;
66
- };
67
- }
68
- }
69
- function sendMessage(options) {
70
- const { type, requestId, data } = options;
71
- const message = JSON.stringify({ type, requestId, data });
72
- if (socket) {
73
- socket.send(message);
74
- } else {
75
- enqueuedMessages.push(message);
76
- }
77
- }
78
- const activeRequests = {};
79
- function sendRequest(options) {
80
- const { type, data } = options;
81
- const requestId = `${idCount++}`;
82
- return new Promise((resolve, reject) => {
83
- const timeoutId = setTimeout(() => {
84
- if (activeRequests[requestId]) {
85
- reject(new Error("Request timed out."));
86
- }
87
- }, 1e4);
88
- activeRequests[requestId] = {
89
- resolve: (resultData) => {
90
- delete activeRequests[requestId];
91
- clearTimeout(timeoutId);
92
- resolve(resultData);
93
- },
94
- reject: (error3) => {
95
- delete activeRequests[requestId];
96
- clearTimeout(timeoutId);
97
- reject(error3);
98
- }
99
- };
100
- sendMessage({ type, requestId, data });
101
- });
102
- }
103
- function onMessageReceived(message) {
104
- const response = JSON.parse(message.data);
105
- const requestId = response.requestId;
106
- if (requestId !== void 0) {
107
- activeRequests[requestId].resolve(response.data);
108
- return;
109
- }
110
- switch (response.type) {
111
- case "notify": {
112
- const { path, data } = response;
113
- bus.publish(path, data);
114
- break;
115
- }
116
- case "reload": {
117
- window.location.reload();
118
- break;
119
- }
120
- case "sequence": {
121
- const { sequence } = response;
122
- if (Number(sequence) > Number(currentSequence)) {
123
- window.location.reload();
124
- }
125
- break;
126
- }
127
- }
128
- }
129
- openConnection();
130
- const client = {
131
- dispose: () => {
132
- socket?.close();
133
- socket = void 0;
134
- },
135
- getValue: (path) => {
136
- return bus.getData(path);
137
- },
138
- open: (options) => {
139
- sendMessage({ type: "open", data: options });
140
- },
141
- openSource: (options) => {
142
- sendMessage({ type: "openSource", data: options });
143
- },
144
- subscribe: (path, callback) => {
145
- return bus.subscribe(path, callback);
146
- },
147
- editConfig: () => {
148
- sendMessage({ type: "editConfig", data: {} });
149
- },
150
- addOverride: (options) => {
151
- sendMessage({ type: "addOverride", data: options });
152
- },
153
- restartTask: (options) => {
154
- sendMessage({ type: "restartTask", data: options });
155
- },
156
- restartAllTasks: () => {
157
- sendMessage({ type: "restartAllTasks", data: {} });
158
- },
159
- validateOverride: (options) => {
160
- return sendRequest({ type: "validateOverride", data: options });
161
- },
162
- reportMetric: (options) => {
163
- sendMessage({ type: "reportMetric", data: options });
164
- }
165
- };
166
- return client;
167
- }
168
-
169
- // packages/overlay/src/components/CloudpackProvider/CloudpackProvider.tsx
11
+ import React, { createContext, useContext } from "react";
170
12
  var CloudpackContext = createContext(null);
171
- function CloudpackProvider({ children }) {
172
- const [client] = useState(createCloudpackClient);
13
+ function CloudpackProvider({ client, children }) {
173
14
  return /* @__PURE__ */ React.createElement(CloudpackContext.Provider, { value: client }, children);
174
15
  }
175
16
  var useCloudpack = () => useContext(CloudpackContext);
176
17
 
177
18
  // packages/overlay/src/components/StatusOverlay/StatusOverlay.tsx
178
- import React13, { useCallback as useCallback3, useState as useState7, useRef as useRef3 } from "react";
19
+ import React13, { useCallback as useCallback3, useState as useState6, useRef as useRef3 } from "react";
179
20
 
180
21
  // packages/overlay/src/components/StatusBadge/StatusBadge.tsx
181
- import React2, { useCallback, useRef, useState as useState4 } from "react";
22
+ import React2, { useCallback, useRef, useState as useState3 } from "react";
182
23
 
183
24
  // packages/overlay/src/hooks/useDraggable.ts
184
- import { useEffect, useState as useState2 } from "react";
25
+ import { useEffect, useState } from "react";
185
26
  function useDraggable(options) {
186
27
  const { enabled, containerElementRef, dragElementRef } = options;
187
- const [isDragging, setIsDragging] = useState2(false);
28
+ const [isDragging, setIsDragging] = useState(false);
188
29
  useEffect(() => {
189
30
  const moveTarget = containerElementRef?.current;
190
31
  const dragTarget = dragElementRef?.current;
@@ -386,7 +227,7 @@ var StatusBadge_module_default = { badge, building, button, chevron, collapsed,
386
227
  import { default as cx } from "classnames";
387
228
 
388
229
  // packages/overlay/src/components/CloudpackProvider/useStatus.ts
389
- import { useEffect as useEffect2, useState as useState3 } from "react";
230
+ import { useEffect as useEffect2, useState as useState2 } from "react";
390
231
  import { taskStatsSource } from "@ms-cloudpack/api-server/browser";
391
232
  var defaultStatus = {
392
233
  status: "unknown",
@@ -396,9 +237,18 @@ var defaultStatus = {
396
237
  totalWarnings: 0
397
238
  };
398
239
  var useStatus = () => {
399
- const service = useCloudpack();
400
- const [status, setStatus] = useState3(() => service?.getValue(taskStatsSource) || defaultStatus);
401
- useEffect2(() => service?.subscribe(taskStatsSource, setStatus), [service]);
240
+ const cloudpack = useCloudpack();
241
+ const [status, setStatus] = useState2(defaultStatus);
242
+ useEffect2(() => {
243
+ const subscription = cloudpack?.onDataChanged.subscribe(taskStatsSource, {
244
+ onData: (data) => {
245
+ setStatus(data);
246
+ }
247
+ });
248
+ return () => {
249
+ subscription.unsubscribe();
250
+ };
251
+ }, [cloudpack]);
402
252
  return status;
403
253
  };
404
254
 
@@ -408,7 +258,7 @@ function StatusBadge({ inline: inline2, onExpand, pageLoadTime }) {
408
258
  const rootElementRef = useRef(null);
409
259
  const dragElementRef = useRef(null);
410
260
  const status = useStatus();
411
- const [isCollapsed, setIsCollapsed] = useState4(!!localStorage.getItem(badgeStatusKey));
261
+ const [isCollapsed, setIsCollapsed] = useState3(!!localStorage.getItem(badgeStatusKey));
412
262
  const shouldRender = status.status !== "unknown";
413
263
  const toggleBadgeVisibility = useCallback(() => {
414
264
  const newCollapsedState = !isCollapsed;
@@ -569,10 +419,10 @@ var TaskResultItem_module_default = { actionArea, content, file, root, statusBar
569
419
 
570
420
  // packages/overlay/src/components/StatusDialog/TaskResultItem.tsx
571
421
  function TaskResultItem({ item, projectPath, index }) {
572
- const service = useCloudpack();
422
+ const cloudpack = useCloudpack();
573
423
  const openSource = (ev) => {
574
424
  if (item.location) {
575
- service.openSource({
425
+ void cloudpack.openCodeEditor.mutate({
576
426
  rootPath: projectPath,
577
427
  relativePath: item.location?.file,
578
428
  line: item.location?.line,
@@ -859,22 +709,31 @@ function getCompletion(task) {
859
709
  }
860
710
  function TaskStatus({ task }) {
861
711
  const [isOpen, setIsOpen] = React5.useState(void 0);
862
- const { name: name2, warnings, errors } = task;
712
+ const { name: name2, warnings = [], errors = [] } = task;
863
713
  const cloudpack = useCloudpack();
864
- const showContent = isOpen === true || isOpen === void 0 && task.errors?.length > 0;
714
+ const showContent = isOpen === true || isOpen === void 0 && errors?.length > 0;
715
+ const inputPath = task.inputPath;
865
716
  const open = (rootPath) => {
866
- cloudpack.open({
717
+ void cloudpack.openFilePath.mutate({
867
718
  rootPath
868
719
  });
869
720
  };
870
721
  const openPackage = () => {
871
- cloudpack.openSource({
872
- rootPath: task.inputPath,
722
+ if (!inputPath) {
723
+ console.error("No input path for task", task);
724
+ return;
725
+ }
726
+ void cloudpack.openCodeEditor.mutate({
727
+ rootPath: inputPath,
873
728
  relativePath: "package.json"
874
729
  });
875
730
  };
876
731
  const restartTask = () => {
877
- cloudpack.restartTask({ id: task.id, inputPath: task.inputPath });
732
+ if (!inputPath) {
733
+ console.error("No input path for task", task);
734
+ return;
735
+ }
736
+ void cloudpack.restartTask.mutate({ id: task.id, inputPath });
878
737
  };
879
738
  return /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.root }, /* @__PURE__ */ React5.createElement("div", { className: getHeaderClassName(task) }, /* @__PURE__ */ React5.createElement(
880
739
  "button",
@@ -891,23 +750,33 @@ function TaskStatus({ task }) {
891
750
  alt: "Chevron down icon"
892
751
  }
893
752
  )
894
- ), errors?.length === 0 && warnings?.length === 0 && /* @__PURE__ */ React5.createElement("img", { className: TaskStatus_module_default.errorIcon, src: success_24_inline_default, alt: "Success icon" }), errors?.length > 0 && /* @__PURE__ */ React5.createElement("img", { className: TaskStatus_module_default.errorIcon, src: error_24_inline_default, alt: "Error icon" }), /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.title }, name2), /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.farArea }, getCompletion(task))), showContent && /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.commands }, /* @__PURE__ */ React5.createElement(Button, { onClick: restartTask }, "Restart task")), /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.content }, /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.title }, "Details"), /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.nameValueArea }, /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.name }, "Input path"), /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.value }, /* @__PURE__ */ React5.createElement("button", { className: TaskStatus_module_default.linkButton, onClick: () => open(task.inputPath) }, task.inputPath), /* @__PURE__ */ React5.createElement("button", { className: TaskStatus_module_default.linkButton, onClick: openPackage }, "(Package.json)"))), /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.nameValueArea }, /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.name }, "Output path"), /* @__PURE__ */ React5.createElement("button", { className: TaskStatus_module_default.linkButton, onClick: () => open(task.outputPath) }, task.outputPath)), errors?.length > 0 && /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.title }, "Errors"), /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.resultItems }, errors.map((error3, index) => /* @__PURE__ */ React5.createElement(TaskResultItem, { key: index, item: error3, projectPath: task.inputPath, index: index + 1 })))), warnings?.length > 0 && /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.title }, "Warnings"), /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.resultItems }, warnings.map((warning3, index) => /* @__PURE__ */ React5.createElement(TaskResultItem, { key: index, item: warning3, projectPath: task.inputPath, index: index + 1 })))))));
753
+ ), errors?.length === 0 && warnings?.length === 0 && /* @__PURE__ */ React5.createElement("img", { className: TaskStatus_module_default.errorIcon, src: success_24_inline_default, alt: "Success icon" }), errors?.length > 0 && /* @__PURE__ */ React5.createElement("img", { className: TaskStatus_module_default.errorIcon, src: error_24_inline_default, alt: "Error icon" }), /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.title }, name2), /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.farArea }, getCompletion(task))), showContent && (inputPath ? /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.commands }, /* @__PURE__ */ React5.createElement(Button, { onClick: restartTask }, "Restart task")), /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.content }, /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.title }, "Details"), /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.nameValueArea }, /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.name }, "Input path"), /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.value }, /* @__PURE__ */ React5.createElement("button", { className: TaskStatus_module_default.linkButton, onClick: () => open(inputPath) }, task.inputPath), /* @__PURE__ */ React5.createElement("button", { className: TaskStatus_module_default.linkButton, onClick: openPackage }, "(Package.json)"))), /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.nameValueArea }, /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.name }, "Output path"), /* @__PURE__ */ React5.createElement("button", { className: TaskStatus_module_default.linkButton, onClick: () => open(inputPath) }, task.outputPath)), errors?.length > 0 && /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.title }, "Errors"), /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.resultItems }, errors.map((error3, index) => /* @__PURE__ */ React5.createElement(TaskResultItem, { key: index, item: error3, projectPath: inputPath, index: index + 1 })))), warnings?.length > 0 && /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.title }, "Warnings"), /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.resultItems }, warnings.map((warning3, index) => /* @__PURE__ */ React5.createElement(TaskResultItem, { key: index, item: warning3, projectPath: inputPath, index: index + 1 })))))) : /* @__PURE__ */ React5.createElement("div", { className: TaskStatus_module_default.content }, "No input path found for task. This is a Cloudpack bug. Please report it.")));
895
754
  }
896
755
  function getHeaderClassName(task) {
756
+ const { errors = [], warnings = [] } = task;
897
757
  return cx2(TaskStatus_module_default.header, {
898
- [TaskStatus_module_default.success]: task.errors?.length === 0 && task.warnings?.length === 0,
899
- [TaskStatus_module_default.warning]: task.errors?.length === 0 && task.warnings?.length > 0,
900
- [TaskStatus_module_default.error]: task.errors?.length > 0
758
+ [TaskStatus_module_default.success]: errors?.length === 0 && warnings?.length === 0,
759
+ [TaskStatus_module_default.warning]: errors?.length === 0 && warnings?.length > 0,
760
+ [TaskStatus_module_default.error]: errors?.length > 0
901
761
  });
902
762
  }
903
763
 
904
764
  // packages/overlay/src/components/CloudpackProvider/useStatusDetails.ts
905
- import { useEffect as useEffect3, useState as useState5 } from "react";
765
+ import { useEffect as useEffect3, useState as useState4 } from "react";
906
766
  import { taskListSource } from "@ms-cloudpack/api-server/browser";
907
767
  var useStatusDetails = () => {
908
- const service = useCloudpack();
909
- const [details, setDetails] = useState5({ tasks: [] });
910
- useEffect3(() => service?.subscribe(taskListSource, setDetails), [service]);
768
+ const cloudpack = useCloudpack();
769
+ const [details, setDetails] = useState4({ tasks: [] });
770
+ useEffect3(() => {
771
+ const subscription = cloudpack?.onDataChanged.subscribe(taskListSource, {
772
+ onData: (data) => {
773
+ setDetails(data);
774
+ }
775
+ });
776
+ return () => {
777
+ subscription.unsubscribe();
778
+ };
779
+ }, [cloudpack]);
911
780
  return details;
912
781
  };
913
782
 
@@ -937,7 +806,7 @@ function TaskList({ searchFilter, issuesOnly }) {
937
806
  let filteredTasks = tasks;
938
807
  if (searchFilter) {
939
808
  searchFilter = searchFilter.toLowerCase();
940
- filteredTasks = filteredTasks.filter(({ name: name2 }) => searchFilter && name2.toLowerCase().includes(searchFilter));
809
+ filteredTasks = filteredTasks.filter(({ name: name2 }) => searchFilter && name2?.toLowerCase().includes(searchFilter));
941
810
  }
942
811
  if (issuesOnly) {
943
812
  filteredTasks = filteredTasks.filter(({ errors, warnings }) => errors?.length || warnings?.length);
@@ -955,6 +824,13 @@ function sortTasks(a, b) {
955
824
  if (aErrors !== bErrors) {
956
825
  return aErrors > bErrors ? -1 : 1;
957
826
  }
827
+ if (a.name === void 0 && b.name === void 0) {
828
+ return a.id < b.id ? -1 : 1;
829
+ } else if (a.name === void 0) {
830
+ return 1;
831
+ } else if (b.name === void 0) {
832
+ return -1;
833
+ }
958
834
  return a.name < b.name ? -1 : 1;
959
835
  }
960
836
 
@@ -1133,7 +1009,7 @@ function StatusDialog({ onClose }) {
1133
1009
  setSearchFilter(event.target.value);
1134
1010
  }, []);
1135
1011
  const restartAllTasks = () => {
1136
- cloudpack.restartAllTasks();
1012
+ void cloudpack.restartAllTasks.mutate();
1137
1013
  };
1138
1014
  const toggleIssuesOnly = () => setIssuesOnly((value3) => !value3);
1139
1015
  return /* @__PURE__ */ React9.createElement(
@@ -1164,10 +1040,10 @@ function PathError(props) {
1164
1040
  const { packageName, importPath, issuerUrl, fixable } = props;
1165
1041
  const cloudpack = useCloudpack();
1166
1042
  const editConfig = () => {
1167
- cloudpack.editConfig();
1043
+ void cloudpack.openConfigEditor.mutate();
1168
1044
  };
1169
1045
  const addOverride = () => {
1170
- cloudpack.addOverride({ packageName, importPath, issuerUrl });
1046
+ void cloudpack.addPackageOverride.mutate({ packageName, importPath, issuerUrl });
1171
1047
  };
1172
1048
  return /* @__PURE__ */ React10.createElement("div", { className: TaskStatus_module_default.root }, /* @__PURE__ */ React10.createElement("div", { className: cx3(TaskStatus_module_default.header, TaskStatus_module_default.error) }, /* @__PURE__ */ React10.createElement(
1173
1049
  "button",
@@ -1191,7 +1067,7 @@ function PathError(props) {
1191
1067
  function ErrorDialog({ unsupported }) {
1192
1068
  const cloudpack = useCloudpack();
1193
1069
  const reload = () => {
1194
- cloudpack.restartAllTasks();
1070
+ void cloudpack.restartAllTasks.mutate();
1195
1071
  };
1196
1072
  return /* @__PURE__ */ React11.createElement(
1197
1073
  Dialog,
@@ -1208,7 +1084,7 @@ function ErrorDialog({ unsupported }) {
1208
1084
  }
1209
1085
 
1210
1086
  // packages/overlay/src/components/ErrorDialog/useErrorEvents.ts
1211
- import { useEffect as useEffect4, useState as useState6 } from "react";
1087
+ import { useEffect as useEffect4, useState as useState5 } from "react";
1212
1088
  import { parseImportString } from "@ms-cloudpack/path-string-parsing";
1213
1089
  var reasonIsRecord = (event) => {
1214
1090
  return typeof event.reason === "object" && !Array.isArray(event.reason) && event.reason !== null;
@@ -1217,7 +1093,7 @@ var hasMessage = (event) => {
1217
1093
  return reasonIsRecord(event) && typeof event.reason.message === "string";
1218
1094
  };
1219
1095
  var useErrorEvents = () => {
1220
- const [errorEvents, setErrorEvents] = useState6({ unsupported: [] });
1096
+ const [errorEvents, setErrorEvents] = useState5({ unsupported: [] });
1221
1097
  const cloudpack = useCloudpack();
1222
1098
  useEffect4(() => {
1223
1099
  const handleUnsupportedError = (message, issuerUrl) => {
@@ -1228,7 +1104,7 @@ var useErrorEvents = () => {
1228
1104
  const { packageName } = importString;
1229
1105
  const importPath = importString.importPath.replace(/^\.\//, "");
1230
1106
  (async () => {
1231
- const { fixable } = await cloudpack.validateOverride({ packageName, importPath, issuerUrl });
1107
+ const { fixable } = await cloudpack.validatePackageOverride.query({ packageName, importPath, issuerUrl });
1232
1108
  setErrorEvents((prev) => ({
1233
1109
  ...prev,
1234
1110
  unsupported: [...prev.unsupported, { packageName, importPath, issuerUrl, fixable }]
@@ -1265,8 +1141,8 @@ function usePageLoadTimeReporter() {
1265
1141
  const { getPageLoadTime, getBrowserCacheRatio } = window.__cloudpack;
1266
1142
  const newPageLoadTime = await getPageLoadTime();
1267
1143
  setPageLoadTime(newPageLoadTime);
1268
- cloudpack.reportMetric({ metric: "PAGE_LOAD_TIME", value: newPageLoadTime });
1269
- cloudpack.reportMetric({ metric: "BROWSER_CACHE_RATIO", value: getBrowserCacheRatio() });
1144
+ await cloudpack.reportMetric.mutate({ metric: "PAGE_LOAD_TIME", value: newPageLoadTime });
1145
+ await cloudpack.reportMetric.mutate({ metric: "BROWSER_CACHE_RATIO", value: getBrowserCacheRatio() });
1270
1146
  }
1271
1147
  void reportPageLoadTime();
1272
1148
  }, [cloudpack]);
@@ -1276,7 +1152,7 @@ function usePageLoadTimeReporter() {
1276
1152
  // packages/overlay/src/components/StatusOverlay/StatusOverlay.tsx
1277
1153
  function StatusOverlay() {
1278
1154
  const pageLoadTime = usePageLoadTimeReporter();
1279
- const [isExpanded, setIsExpanded] = useState7(false);
1155
+ const [isExpanded, setIsExpanded] = useState6(false);
1280
1156
  const status = useStatus();
1281
1157
  const prevStatus = useRef3();
1282
1158
  const { unsupported } = useErrorEvents();
@@ -1326,11 +1202,44 @@ function ThemeProvider({ children }) {
1326
1202
  }
1327
1203
 
1328
1204
  // packages/overlay/src/index.tsx
1329
- var rootDiv = document.createElement("div");
1330
- rootDiv.id = elementIds.root;
1331
- ReactDOM.render(
1332
- /* @__PURE__ */ React15.createElement(ThemeProvider, null, /* @__PURE__ */ React15.createElement(CloudpackProvider, null, /* @__PURE__ */ React15.createElement(StatusOverlay, null))),
1333
- rootDiv
1334
- );
1335
- document.body.appendChild(rootDiv);
1205
+ import { createCloudpackClient, reloadCountSource } from "@ms-cloudpack/api-server/browser";
1206
+
1207
+ // packages/overlay/src/components/CloudpackProvider/getCookies.ts
1208
+ function getCookies() {
1209
+ return document.cookie.split(";").map((s9) => s9.split("=")).reduce((current, nextValue) => {
1210
+ const name2 = nextValue[0]?.trim();
1211
+ const value3 = decodeURIComponent(nextValue[1]?.trim());
1212
+ if (name2 && value3) {
1213
+ current[name2] = value3;
1214
+ }
1215
+ return current;
1216
+ }, {});
1217
+ }
1218
+
1219
+ // packages/overlay/src/index.tsx
1220
+ async function start() {
1221
+ const cookies = getCookies();
1222
+ const sessionId = cookies[cookieNames.sessionId];
1223
+ const apiUrl = cookies[cookieNames.apiUrl];
1224
+ const currentSequence = cookies[cookieNames.sessionSequence];
1225
+ const client = await createCloudpackClient({ url: apiUrl });
1226
+ if (sessionId === await client.getSessionId.query()) {
1227
+ console.log("[Cloudpack] socket opened");
1228
+ }
1229
+ client.onDataChanged.subscribe(reloadCountSource, {
1230
+ onData: (data) => {
1231
+ if (Number(data) > Number(currentSequence)) {
1232
+ window.location.reload();
1233
+ }
1234
+ }
1235
+ });
1236
+ const rootDiv = document.createElement("div");
1237
+ rootDiv.id = elementIds.root;
1238
+ ReactDOM.render(
1239
+ /* @__PURE__ */ React15.createElement(ThemeProvider, null, /* @__PURE__ */ React15.createElement(CloudpackProvider, { client }, /* @__PURE__ */ React15.createElement(StatusOverlay, null))),
1240
+ rootDiv
1241
+ );
1242
+ document.body.appendChild(rootDiv);
1243
+ }
1244
+ void start();
1336
1245
  //# sourceMappingURL=index.js.map