@ms-cloudpack/overlay 0.10.1 → 0.11.1

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 (27) hide show
  1. package/CHANGELOG.json +59 -1
  2. package/CHANGELOG.md +24 -2
  3. package/dist/lib/index.js +200 -89
  4. package/dist/ori-output.json +2 -2
  5. package/lib/components/CloudpackProvider/createCloudpackClient.d.ts +12 -2
  6. package/lib/components/CloudpackProvider/createCloudpackClient.js +48 -11
  7. package/lib/components/CloudpackProvider/createCloudpackClient.js.map +1 -1
  8. package/lib/components/Dialog/Dialog.js +3 -3
  9. package/lib/components/Dialog/Dialog.js.map +1 -1
  10. package/lib/components/ErrorDialog/PathError.js +5 -3
  11. package/lib/components/ErrorDialog/PathError.js.map +1 -1
  12. package/lib/components/ErrorDialog/useErrorEvents.d.ts +6 -1
  13. package/lib/components/ErrorDialog/useErrorEvents.js +38 -14
  14. package/lib/components/ErrorDialog/useErrorEvents.js.map +1 -1
  15. package/lib/components/StatusDialog/Searchbox.d.ts +6 -0
  16. package/lib/components/StatusDialog/Searchbox.js +6 -0
  17. package/lib/components/StatusDialog/Searchbox.js.map +1 -0
  18. package/lib/components/StatusDialog/StatusDialog.js +9 -2
  19. package/lib/components/StatusDialog/StatusDialog.js.map +1 -1
  20. package/lib/components/StatusDialog/TaskList.d.ts +3 -1
  21. package/lib/components/StatusDialog/TaskList.js +5 -2
  22. package/lib/components/StatusDialog/TaskList.js.map +1 -1
  23. package/lib/components/StatusDialog/TaskStatus.js +3 -3
  24. package/lib/components/StatusDialog/TaskStatus.js.map +1 -1
  25. package/lib/components/StatusOverlay/StatusOverlay.js +12 -13
  26. package/lib/components/StatusOverlay/StatusOverlay.js.map +1 -1
  27. package/package.json +7 -2
package/CHANGELOG.json CHANGED
@@ -2,7 +2,65 @@
2
2
  "name": "@ms-cloudpack/overlay",
3
3
  "entries": [
4
4
  {
5
- "date": "Wed, 23 Nov 2022 08:09:52 GMT",
5
+ "date": "Sat, 03 Dec 2022 08:10:22 GMT",
6
+ "tag": "@ms-cloudpack/overlay_v0.11.1",
7
+ "version": "0.11.1",
8
+ "comments": {
9
+ "none": [
10
+ {
11
+ "author": "dake.3601@gmail.com",
12
+ "package": "@ms-cloudpack/overlay",
13
+ "commit": "9fae6cbdb788baac8236abc9eb44eb1d3296b7e0",
14
+ "comment": "Updated beachball config to disallow major bumps"
15
+ }
16
+ ],
17
+ "patch": [
18
+ {
19
+ "author": "elcraig@microsoft.com",
20
+ "package": "@ms-cloudpack/overlay",
21
+ "commit": "d22dff84546bf87d94a59fac03695df0ce231de9",
22
+ "comment": "Minor React pattern fixes and status badge styling improvements"
23
+ }
24
+ ]
25
+ }
26
+ },
27
+ {
28
+ "date": "Thu, 01 Dec 2022 08:10:47 GMT",
29
+ "tag": "@ms-cloudpack/overlay_v0.11.0",
30
+ "version": "0.11.0",
31
+ "comments": {
32
+ "minor": [
33
+ {
34
+ "author": "dake.3601@gmail.com",
35
+ "package": "@ms-cloudpack/overlay",
36
+ "commit": "c1fb917cde92231a591861419d0e99a5d02011ce",
37
+ "comment": "Added search box for tasks"
38
+ }
39
+ ],
40
+ "patch": [
41
+ {
42
+ "author": "dake.3601@gmail.com",
43
+ "package": "@ms-cloudpack/overlay",
44
+ "commit": "77a0d57071c07b131cf391b9c876bf9307511110",
45
+ "comment": "Added handling for promise rejection event."
46
+ },
47
+ {
48
+ "author": "dake.3601@gmail.com",
49
+ "package": "@ms-cloudpack/overlay",
50
+ "commit": "0281a406e564d378b22e14e5c209cfba12b08e98",
51
+ "comment": "Added valdiation request for unsupported paths."
52
+ },
53
+ {
54
+ "author": "dake.3601@gmail.com",
55
+ "package": "@ms-cloudpack/overlay",
56
+ "commit": "16d2ca58373fa04b9bdc901783d0095a3e3c5036",
57
+ "comment": "Single task cache busting"
58
+ }
59
+ ]
60
+ }
61
+ },
62
+ {
63
+ "date": "Wed, 23 Nov 2022 08:10:05 GMT",
6
64
  "tag": "@ms-cloudpack/overlay_v0.10.1",
7
65
  "version": "0.10.1",
8
66
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,34 @@
1
1
  # Change Log - @ms-cloudpack/overlay
2
2
 
3
- This log was last generated on Wed, 23 Nov 2022 08:09:52 GMT and should not be manually modified.
3
+ This log was last generated on Sat, 03 Dec 2022 08:10:22 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 0.11.1
8
+
9
+ Sat, 03 Dec 2022 08:10:22 GMT
10
+
11
+ ### Patches
12
+
13
+ - Minor React pattern fixes and status badge styling improvements (elcraig@microsoft.com)
14
+
15
+ ## 0.11.0
16
+
17
+ Thu, 01 Dec 2022 08:10:47 GMT
18
+
19
+ ### Minor changes
20
+
21
+ - Added search box for tasks (dake.3601@gmail.com)
22
+
23
+ ### Patches
24
+
25
+ - Added handling for promise rejection event. (dake.3601@gmail.com)
26
+ - Added valdiation request for unsupported paths. (dake.3601@gmail.com)
27
+ - Single task cache busting (dake.3601@gmail.com)
28
+
7
29
  ## 0.10.1
8
30
 
9
- Wed, 23 Nov 2022 08:09:52 GMT
31
+ Wed, 23 Nov 2022 08:10:05 GMT
10
32
 
11
33
  ### Patches
12
34
 
package/dist/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/index.tsx
2
- import React13 from "react";
2
+ import React14 from "react";
3
3
  import ReactDOM from "react-dom";
4
4
 
5
5
  // src/components/CloudpackProvider/CloudpackProvider.tsx
@@ -7,7 +7,7 @@ import React, { createContext, useState, useContext } from "react";
7
7
 
8
8
  // src/components/CloudpackProvider/getCookies.ts
9
9
  function getCookies() {
10
- return document.cookie.split(";").map((s8) => s8.split("=")).reduce((current, nextValue) => {
10
+ return document.cookie.split(";").map((s9) => s9.split("=")).reduce((current, nextValue) => {
11
11
  const name2 = nextValue[0]?.trim();
12
12
  const value3 = decodeURIComponent(nextValue[1]?.trim());
13
13
  if (name2 && value3) {
@@ -29,13 +29,13 @@ function createCloudpackClient() {
29
29
  onActivate: ({ path }) => {
30
30
  const id = subCounter++;
31
31
  subIds[path.join("/")] = id;
32
- sendMessage("subscribe", { path, id });
32
+ sendMessage({ type: "subscribe", data: { path, id } });
33
33
  },
34
34
  onDeactivate: ({ path }) => {
35
35
  const pathString = path.join("/");
36
36
  const id = subIds[pathString];
37
37
  delete subIds[pathString];
38
- sendMessage("unsubscribe", { path, id });
38
+ sendMessage({ type: "unsubscribe", data: { path, id } });
39
39
  }
40
40
  });
41
41
  const enqueuedMessages = [];
@@ -43,6 +43,7 @@ function createCloudpackClient() {
43
43
  const apiUrl = cookies["cloudpack-api-url"];
44
44
  const currentSequence = cookies["cloudpack-session-sequence"];
45
45
  let socket;
46
+ let idCount = 0;
46
47
  function openConnection() {
47
48
  if (apiUrl && sessionId) {
48
49
  const newSocket = new WebSocket(apiUrl);
@@ -66,16 +67,45 @@ function createCloudpackClient() {
66
67
  socket = void 0;
67
68
  }
68
69
  }
69
- function sendMessage(type, data) {
70
- const message = JSON.stringify({ type, data });
70
+ function sendMessage({ type, requestId, data }) {
71
+ const message = JSON.stringify({ type, requestId, data });
71
72
  if (socket) {
72
73
  socket.send(message);
73
74
  } else {
74
75
  enqueuedMessages.push(message);
75
76
  }
76
77
  }
78
+ const activeRequests = {};
79
+ function sendRequest({ type, data }) {
80
+ const requestId = `${idCount++}`;
81
+ return new Promise((resolve, reject) => {
82
+ const timeoutId = setTimeout(() => {
83
+ if (activeRequests[requestId]) {
84
+ reject(new Error("Request timed out."));
85
+ }
86
+ }, 1e4);
87
+ activeRequests[requestId] = {
88
+ resolve: (data2) => {
89
+ delete activeRequests[requestId];
90
+ clearTimeout(timeoutId);
91
+ resolve(data2);
92
+ },
93
+ reject: (error3) => {
94
+ delete activeRequests[requestId];
95
+ clearTimeout(timeoutId);
96
+ reject(error3);
97
+ }
98
+ };
99
+ sendMessage({ type, requestId, data });
100
+ });
101
+ }
77
102
  function onMessageReceived(message) {
78
103
  const response = JSON.parse(message.data);
104
+ const requestId = response.requestId;
105
+ if (requestId !== void 0) {
106
+ activeRequests[requestId].resolve(response.data);
107
+ return;
108
+ }
79
109
  switch (response.type) {
80
110
  case "notify": {
81
111
  const { path, data } = response;
@@ -104,22 +134,25 @@ function createCloudpackClient() {
104
134
  return bus.getData(sessionPath);
105
135
  }
106
136
  function openSource(options) {
107
- sendMessage("openSource", options);
137
+ sendMessage({ type: "openSource", data: options });
108
138
  }
109
139
  function open(options) {
110
- sendMessage("open", options);
140
+ sendMessage({ type: "open", data: options });
111
141
  }
112
142
  function editConfig() {
113
- sendMessage("editConfig", {});
143
+ sendMessage({ type: "editConfig", data: {} });
114
144
  }
115
145
  function addOverride(options) {
116
- sendMessage("addOverride", options);
146
+ sendMessage({ type: "addOverride", data: options });
147
+ }
148
+ function validateOverride(options) {
149
+ return sendRequest({ type: "validateOverride", data: options });
117
150
  }
118
151
  function restartAllTasks() {
119
- sendMessage("restartAllTasks", {});
152
+ sendMessage({ type: "restartAllTasks", data: {} });
120
153
  }
121
- function restartTask(id) {
122
- sendMessage("restartTask", { id });
154
+ function restartTask(options) {
155
+ sendMessage({ type: "restartTask", data: options });
123
156
  }
124
157
  openConnection();
125
158
  return {
@@ -131,7 +164,8 @@ function createCloudpackClient() {
131
164
  editConfig,
132
165
  addOverride,
133
166
  restartTask,
134
- restartAllTasks
167
+ restartAllTasks,
168
+ validateOverride
135
169
  };
136
170
  }
137
171
 
@@ -146,7 +180,7 @@ function CloudpackProvider({ children }) {
146
180
  var useCloudpack = () => useContext(CloudpackContext);
147
181
 
148
182
  // src/components/StatusOverlay/StatusOverlay.tsx
149
- import React11, { useCallback, useState as useState6, useRef as useRef3 } from "react";
183
+ import React12, { useCallback as useCallback2, useState as useState6, useRef as useRef3 } from "react";
150
184
 
151
185
  // src/components/StatusBadge/StatusBadge.tsx
152
186
  import React2, { useRef } from "react";
@@ -220,6 +254,7 @@ var compiledModule = `.mOWPxtXY-StatusBadgemodulecssfixedOverlay {
220
254
  height: 100%;
221
255
  width: 12px;
222
256
  cursor: move;
257
+ margin-right: -4px;
223
258
  }
224
259
 
225
260
  .mOWPxtXY-StatusBadgemodulecssgrip {
@@ -234,13 +269,12 @@ var compiledModule = `.mOWPxtXY-StatusBadgemodulecssfixedOverlay {
234
269
  }
235
270
 
236
271
  .mOWPxtXY-StatusBadgemodulecssbadge {
237
- cursor: default;
238
272
  position: absolute;
239
273
  bottom: 4px;
240
274
  right: 4px;
241
275
  font-size: 12px;
242
276
  display: inline-flex;
243
- gap: 4px;
277
+ gap: 8px;
244
278
  background: #dddddd;
245
279
  box-shadow: 0 0 12px -6px rgba(0, 0, 0, 0.75);
246
280
  border: 1px solid #999999;
@@ -250,7 +284,8 @@ var compiledModule = `.mOWPxtXY-StatusBadgemodulecssfixedOverlay {
250
284
  justify-content: center;
251
285
  align-items: center;
252
286
  box-sizing: border-box;
253
- padding: 2px;
287
+ padding: 3px;
288
+ padding-right: 8px;
254
289
 
255
290
  transition: background-color 0.2s ease-in-out;
256
291
  }
@@ -263,6 +298,7 @@ var compiledModule = `.mOWPxtXY-StatusBadgemodulecssfixedOverlay {
263
298
  top: auto;
264
299
  left: auto;
265
300
  box-shadow: none;
301
+ padding-left: 8px;
266
302
  }
267
303
 
268
304
  .mOWPxtXY-StatusBadgemodulecssbuilding {
@@ -286,6 +322,7 @@ var compiledModule = `.mOWPxtXY-StatusBadgemodulecssfixedOverlay {
286
322
  }
287
323
 
288
324
  .mOWPxtXY-StatusBadgemodulecssbutton {
325
+ cursor: pointer;
289
326
  background: inherit;
290
327
  border: none;
291
328
  border-radius: 3px;
@@ -417,7 +454,7 @@ function getStatsString(status) {
417
454
  }
418
455
 
419
456
  // src/components/StatusDialog/StatusDialog.tsx
420
- import React8 from "react";
457
+ import React9, { useCallback } from "react";
421
458
 
422
459
  // src/components/StatusDialog/TaskList.tsx
423
460
  import React6 from "react";
@@ -831,8 +868,8 @@ function TaskStatus({ task }) {
831
868
  column: 0
832
869
  });
833
870
  };
834
- const restartTask = (id) => {
835
- cloudpack.restartTask(id);
871
+ const restartTask = () => {
872
+ cloudpack.restartTask({ id: task.id, inputPath: task.inputPath });
836
873
  };
837
874
  return /* @__PURE__ */ React5.createElement("div", {
838
875
  className: TaskStatus_module_default.root
@@ -861,7 +898,7 @@ function TaskStatus({ task }) {
861
898
  }, getCompletion(task))), showContent && /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("div", {
862
899
  className: TaskStatus_module_default.commands
863
900
  }, /* @__PURE__ */ React5.createElement(Button, {
864
- onClick: () => restartTask(task.id)
901
+ onClick: restartTask
865
902
  }, "Restart task")), /* @__PURE__ */ React5.createElement("div", {
866
903
  className: TaskStatus_module_default.content
867
904
  }, /* @__PURE__ */ React5.createElement("div", {
@@ -942,13 +979,14 @@ var root3 = "lTlVbGXBQHs-TaskListmodulecssroot";
942
979
  var TaskList_module_default = { root: root3 };
943
980
 
944
981
  // src/components/StatusDialog/TaskList.tsx
945
- function TaskList() {
982
+ function TaskList({ searchFilter }) {
946
983
  const details = useStatusDetails();
947
984
  const tasks = (details.tasks || []).sort(sortTasks);
985
+ searchFilter = searchFilter?.toLowerCase();
948
986
  return /* @__PURE__ */ React6.createElement("div", {
949
987
  className: TaskList_module_default.root
950
- }, tasks.map((task, index) => /* @__PURE__ */ React6.createElement(TaskStatus, {
951
- key: index,
988
+ }, tasks.filter(({ name: name2 }) => !searchFilter || name2.toLowerCase().includes(searchFilter)).map((task) => /* @__PURE__ */ React6.createElement(TaskStatus, {
989
+ key: task.name,
952
990
  task
953
991
  })));
954
992
  }
@@ -1090,47 +1128,99 @@ function Dialog({ title: title3, style, draggable, onClose, commands: commands3,
1090
1128
  ref: draggableTargetRef,
1091
1129
  className: Dialog_module_default.title,
1092
1130
  style: { color: colorAccent, cursor: cursorDraggable }
1093
- }, title3), !!onClose && /* @__PURE__ */ React7.createElement("button", {
1131
+ }, title3), onClose && /* @__PURE__ */ React7.createElement("button", {
1094
1132
  className: Dialog_module_default.closeButton,
1095
1133
  onClick: onClose,
1096
1134
  "aria-label": "Minimize overlay"
1097
1135
  }, /* @__PURE__ */ React7.createElement("img", {
1098
1136
  src: dismiss_16_filled_inline_default,
1099
- alt: "Close icon"
1100
- }))), !!commands3 && /* @__PURE__ */ React7.createElement("div", {
1137
+ alt: ""
1138
+ }))), commands3 && /* @__PURE__ */ React7.createElement("div", {
1101
1139
  className: Dialog_module_default.commands
1102
1140
  }, ...commands3), children));
1103
1141
  }
1104
1142
 
1143
+ // src/components/StatusDialog/Searchbox.tsx
1144
+ import React8 from "react";
1145
+
1146
+ // src/components/StatusDialog/Searchbox.module.css
1147
+ var compiledModule7 = `.QFosMXkA-Searchboxmodulecsssearchbox {
1148
+ position: absolute;
1149
+ font-size: 14px;
1150
+ font-weight: 400;
1151
+ box-shadow: none;
1152
+ padding: 0px 4px;
1153
+ box-sizing: border-box;
1154
+ color: rgb(50, 49, 48);
1155
+ background-color: rgb(255, 255, 255);
1156
+ display: flex;
1157
+ flex-flow: row nowrap;
1158
+ align-items: stretch;
1159
+ border-radius: 2px;
1160
+ border: 1px solid rgb(96, 94, 92);
1161
+ height: 32px;
1162
+ min-width: 160px;
1163
+ top: 52px;
1164
+ right: 20px;
1165
+ }
1166
+ `;
1167
+ var s7 = document.createElement("style");
1168
+ s7.setAttribute("data-sourceFile", "src/components/StatusDialog/Searchbox.module.css");
1169
+ s7.appendChild(document.createTextNode(compiledModule7));
1170
+ document.head.appendChild(s7);
1171
+ var searchbox = "QFosMXkA-Searchboxmodulecsssearchbox";
1172
+ var Searchbox_module_default = { searchbox };
1173
+
1174
+ // src/components/StatusDialog/Searchbox.tsx
1175
+ function Searchbox({ value: value3, onChange }) {
1176
+ return /* @__PURE__ */ React8.createElement(React8.Fragment, null, typeof value3 === "string" && /* @__PURE__ */ React8.createElement("input", {
1177
+ type: "text",
1178
+ placeholder: "Search",
1179
+ className: Searchbox_module_default.searchbox,
1180
+ onChange,
1181
+ value: value3
1182
+ }));
1183
+ }
1184
+
1105
1185
  // src/components/StatusDialog/StatusDialog.tsx
1106
1186
  function StatusDialog({ onClose }) {
1107
1187
  const cloudpack = useCloudpack();
1188
+ const [searchFilter, setSearchFilter] = React9.useState("");
1189
+ const handleSearchChange = useCallback((event) => {
1190
+ event.preventDefault();
1191
+ setSearchFilter(event.target.value);
1192
+ }, []);
1108
1193
  const restartAllTasks = () => {
1109
1194
  cloudpack.restartAllTasks();
1110
1195
  };
1111
- return /* @__PURE__ */ React8.createElement(Dialog, {
1196
+ return /* @__PURE__ */ React9.createElement(Dialog, {
1112
1197
  title: "Task results",
1113
1198
  draggable: true,
1114
1199
  onClose,
1115
1200
  commands: [
1116
- /* @__PURE__ */ React8.createElement(Button, {
1201
+ /* @__PURE__ */ React9.createElement(Button, {
1117
1202
  primary: true,
1118
1203
  onClick: restartAllTasks,
1119
1204
  key: "1"
1120
1205
  }, "Restart all tasks")
1121
1206
  ]
1122
- }, /* @__PURE__ */ React8.createElement(TaskList, null));
1207
+ }, /* @__PURE__ */ React9.createElement(Searchbox, {
1208
+ value: searchFilter,
1209
+ onChange: handleSearchChange
1210
+ }), /* @__PURE__ */ React9.createElement(TaskList, {
1211
+ searchFilter
1212
+ }));
1123
1213
  }
1124
1214
 
1125
1215
  // src/components/ErrorDialog/ErrorDialog.tsx
1126
- import { default as React10 } from "react";
1216
+ import { default as React11 } from "react";
1127
1217
 
1128
1218
  // src/components/ErrorDialog/PathError.tsx
1129
- import React9 from "react";
1219
+ import React10 from "react";
1130
1220
  import { default as cx3 } from "classnames";
1131
1221
  function PathError(props) {
1132
- const [showContent, setshowContent] = React9.useState(false);
1133
- const { packageName, importPath, filename } = props;
1222
+ const [showContent, setshowContent] = React10.useState(false);
1223
+ const { packageName, importPath, filename, fixable } = props;
1134
1224
  const cloudpack = useCloudpack();
1135
1225
  const editConfig = () => {
1136
1226
  cloudpack.editConfig();
@@ -1138,47 +1228,47 @@ function PathError(props) {
1138
1228
  const addOverride = () => {
1139
1229
  cloudpack.addOverride({ packageName, importPath, filename });
1140
1230
  };
1141
- return /* @__PURE__ */ React9.createElement("div", {
1231
+ return /* @__PURE__ */ React10.createElement("div", {
1142
1232
  className: TaskStatus_module_default.root
1143
- }, /* @__PURE__ */ React9.createElement("div", {
1233
+ }, /* @__PURE__ */ React10.createElement("div", {
1144
1234
  className: cx3(TaskStatus_module_default.header, TaskStatus_module_default.error)
1145
- }, /* @__PURE__ */ React9.createElement("button", {
1235
+ }, /* @__PURE__ */ React10.createElement("button", {
1146
1236
  className: TaskStatus_module_default.expandButton,
1147
1237
  onClick: () => setshowContent(!showContent),
1148
1238
  "aria-label": showContent ? `Minimize ${packageName}/${importPath}` : `Expand ${packageName}/${importPath}`
1149
- }, /* @__PURE__ */ React9.createElement("img", {
1239
+ }, /* @__PURE__ */ React10.createElement("img", {
1150
1240
  className: cx3(TaskStatus_module_default.expandIcon, !showContent && TaskStatus_module_default.collapsed),
1151
1241
  src: chevrondown_20_inline_default,
1152
1242
  alt: "Chevron down icon"
1153
- })), /* @__PURE__ */ React9.createElement("img", {
1243
+ })), /* @__PURE__ */ React10.createElement("img", {
1154
1244
  className: TaskStatus_module_default.errorIcon,
1155
1245
  src: error_24_inline_default,
1156
1246
  alt: "Error icon"
1157
- }), /* @__PURE__ */ React9.createElement("div", {
1247
+ }), /* @__PURE__ */ React10.createElement("div", {
1158
1248
  className: TaskStatus_module_default.title
1159
- }, `${packageName}/${importPath}`)), showContent && /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement("div", {
1249
+ }, `${packageName}/${importPath}`)), showContent && /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement("div", {
1160
1250
  className: TaskStatus_module_default.commands
1161
- }, /* @__PURE__ */ React9.createElement(Button, {
1251
+ }, fixable && /* @__PURE__ */ React10.createElement(Button, {
1162
1252
  onClick: addOverride
1163
- }, "Add override"), /* @__PURE__ */ React9.createElement(Button, {
1253
+ }, "Add override"), /* @__PURE__ */ React10.createElement(Button, {
1164
1254
  onClick: editConfig
1165
- }, "Edit config file")), /* @__PURE__ */ React9.createElement("div", {
1255
+ }, "Edit config file")), /* @__PURE__ */ React10.createElement("div", {
1166
1256
  className: TaskStatus_module_default.content
1167
- }, /* @__PURE__ */ React9.createElement("div", {
1257
+ }, /* @__PURE__ */ React10.createElement("div", {
1168
1258
  className: TaskStatus_module_default.title
1169
- }, "Details"), /* @__PURE__ */ React9.createElement("div", {
1259
+ }, "Details"), /* @__PURE__ */ React10.createElement("div", {
1170
1260
  className: TaskStatus_module_default.nameValueArea
1171
- }, /* @__PURE__ */ React9.createElement("div", {
1261
+ }, /* @__PURE__ */ React10.createElement("div", {
1172
1262
  className: TaskStatus_module_default.name
1173
- }, "Problem"), /* @__PURE__ */ React9.createElement("div", {
1263
+ }, "Problem"), /* @__PURE__ */ React10.createElement("div", {
1174
1264
  className: TaskStatus_module_default.value
1175
- }, `A deep import package name: "${packageName}" was imported, but was unrecognized as an exported entry path: "${importPath}".`)), /* @__PURE__ */ React9.createElement("div", {
1265
+ }, `A deep import package name: "${packageName}" was imported, but was unrecognized as an exported entry path: "${importPath}".`)), /* @__PURE__ */ React10.createElement("div", {
1176
1266
  className: TaskStatus_module_default.nameValueArea
1177
- }, /* @__PURE__ */ React9.createElement("div", {
1267
+ }, /* @__PURE__ */ React10.createElement("div", {
1178
1268
  className: TaskStatus_module_default.name
1179
- }, "Solution"), /* @__PURE__ */ React9.createElement("div", {
1269
+ }, "Solution"), /* @__PURE__ */ React10.createElement("div", {
1180
1270
  className: TaskStatus_module_default.value
1181
- }, `Remove the path from the import in your source. (Import from "${packageName}" rather than "${packageName}/${importPath}")`)))));
1271
+ }, fixable ? `Remove the path from the import in your source. (Import from "${packageName}" rather than "${packageName}/${importPath}")` : `Import not found on package. Make sure the import path is valid.`)))));
1182
1272
  }
1183
1273
 
1184
1274
  // src/components/ErrorDialog/ErrorDialog.tsx
@@ -1187,19 +1277,19 @@ function ErrorDialog({ unsupported }) {
1187
1277
  const reload = () => {
1188
1278
  cloudpack.restartAllTasks();
1189
1279
  };
1190
- return /* @__PURE__ */ React10.createElement(Dialog, {
1280
+ return /* @__PURE__ */ React11.createElement(Dialog, {
1191
1281
  title: "Found unsupported paths in your project",
1192
1282
  style: "error",
1193
1283
  commands: [
1194
- /* @__PURE__ */ React10.createElement(Button, {
1284
+ /* @__PURE__ */ React11.createElement(Button, {
1195
1285
  primary: true,
1196
1286
  onClick: reload,
1197
1287
  key: "1"
1198
1288
  }, "Restart all tasks")
1199
1289
  ]
1200
- }, /* @__PURE__ */ React10.createElement("div", {
1290
+ }, /* @__PURE__ */ React11.createElement("div", {
1201
1291
  className: TaskList_module_default.root
1202
- }, unsupported.map((data, index) => /* @__PURE__ */ React10.createElement(PathError, {
1292
+ }, unsupported.map((data, index) => /* @__PURE__ */ React11.createElement(PathError, {
1203
1293
  ...data,
1204
1294
  key: index
1205
1295
  }))));
@@ -1208,12 +1298,19 @@ function ErrorDialog({ unsupported }) {
1208
1298
  // src/components/ErrorDialog/useErrorEvents.ts
1209
1299
  import { useEffect as useEffect4, useState as useState5 } from "react";
1210
1300
  import { parseImportString } from "@ms-cloudpack/path-string-parsing";
1301
+ var reasonIsRecord = (event) => {
1302
+ return typeof event.reason === "object" && !Array.isArray(event.reason) && event.reason !== null;
1303
+ };
1304
+ var hasMessage = (event) => {
1305
+ return reasonIsRecord(event) && typeof event.reason.message === "string";
1306
+ };
1211
1307
  var useErrorEvents = () => {
1212
- const [events, setEvents] = useState5({ unsupported: [] });
1308
+ const [errorEvents, setErrorEvents] = useState5({ unsupported: [] });
1309
+ const cloudpack = useCloudpack();
1213
1310
  useEffect4(() => {
1214
- const handleError = (event) => {
1311
+ const handleUnsupportedError = (message, filename) => {
1215
1312
  const errorRegex = /[Mm]odule specifier,? ['"](.*?)['"]/;
1216
- const match = event.message.match(errorRegex);
1313
+ const match = message.match(errorRegex);
1217
1314
  if (match) {
1218
1315
  const importString = parseImportString(match[1]);
1219
1316
  const { packageName = "" } = importString;
@@ -1223,64 +1320,78 @@ var useErrorEvents = () => {
1223
1320
  } else if (importPath.startsWith("./")) {
1224
1321
  importPath = importPath.slice(2);
1225
1322
  }
1226
- setEvents((prevEvents) => ({
1227
- ...prevEvents,
1228
- unsupported: [...prevEvents.unsupported, { packageName, importPath, filename: event.filename }]
1229
- }));
1323
+ (async () => {
1324
+ const { fixable } = await cloudpack.validateOverride({ packageName, importPath, filename });
1325
+ setErrorEvents((prev) => ({
1326
+ ...prev,
1327
+ unsupported: [...prev.unsupported, { packageName, importPath, filename, fixable }]
1328
+ }));
1329
+ })().catch(() => {
1330
+ });
1230
1331
  }
1231
1332
  };
1232
- window.uncaughtErrors = window.uncaughtErrors || { errors: [], unregister: () => void 0 };
1233
1333
  window.uncaughtErrors.unregister();
1234
- window.addEventListener("error", handleError);
1334
+ window.addEventListener("error", (event) => {
1335
+ handleUnsupportedError(event.message, event.filename);
1336
+ });
1235
1337
  for (const error3 of window.uncaughtErrors.errors) {
1236
- handleError(error3);
1338
+ handleUnsupportedError(error3.message, error3.filename);
1237
1339
  }
1238
- }, []);
1239
- return events;
1340
+ window.uncaughtRejections.unregister();
1341
+ window.addEventListener("unhandledrejection", (event) => {
1342
+ hasMessage(event) && handleUnsupportedError(event.reason.message);
1343
+ });
1344
+ for (const error3 of window.uncaughtRejections.errors) {
1345
+ hasMessage(error3) && handleUnsupportedError(error3.reason.message);
1346
+ }
1347
+ }, [cloudpack]);
1348
+ return errorEvents;
1240
1349
  };
1241
1350
 
1242
1351
  // src/components/StatusOverlay/StatusOverlay.tsx
1243
1352
  function StatusOverlay() {
1244
1353
  const [isExpanded, setIsExpanded] = useState6(false);
1245
1354
  const status = useStatus();
1246
- const internal = useRef3();
1355
+ const prevStatus = useRef3();
1247
1356
  const { unsupported } = useErrorEvents();
1248
- if (isExpanded === false && internal.current?.status !== "idle" && status.status === "idle" && internal.current?.totalErrors != status.totalErrors) {
1249
- setIsExpanded(true);
1250
- }
1251
- internal.current = status;
1252
- const toggleMinimized = useCallback(() => {
1357
+ React12.useEffect(() => {
1358
+ if (!isExpanded && prevStatus.current?.status !== "idle" && status.status === "idle" && (prevStatus.current?.totalErrors || 0) !== (status.totalErrors || 0)) {
1359
+ setIsExpanded(true);
1360
+ }
1361
+ prevStatus.current = status;
1362
+ }, [status, isExpanded]);
1363
+ const toggleMinimized = useCallback2(() => {
1253
1364
  console.log(`Toggling minimized state to ${!isExpanded}`);
1254
1365
  setIsExpanded(!isExpanded);
1255
- }, [isExpanded, setIsExpanded]);
1256
- return /* @__PURE__ */ React11.createElement("div", null, !!unsupported.length && /* @__PURE__ */ React11.createElement(ErrorDialog, {
1366
+ }, [isExpanded]);
1367
+ return unsupported.length ? /* @__PURE__ */ React12.createElement(ErrorDialog, {
1257
1368
  unsupported
1258
- }), !unsupported.length && !isExpanded && /* @__PURE__ */ React11.createElement(StatusBadge, {
1259
- onExpand: toggleMinimized
1260
- }), !unsupported.length && isExpanded && /* @__PURE__ */ React11.createElement(StatusDialog, {
1369
+ }) : isExpanded ? /* @__PURE__ */ React12.createElement(StatusDialog, {
1261
1370
  onClose: toggleMinimized
1262
- }));
1371
+ }) : /* @__PURE__ */ React12.createElement(StatusBadge, {
1372
+ onExpand: toggleMinimized
1373
+ });
1263
1374
  }
1264
1375
 
1265
1376
  // src/components/ThemeProvider/ThemeProvider.tsx
1266
- import React12 from "react";
1377
+ import React13 from "react";
1267
1378
 
1268
1379
  // src/components/ThemeProvider/ThemeProvider.module.css
1269
- var compiledModule7 = `.xwrpHYTQE-ThemeProvidermodulecssroot {
1380
+ var compiledModule8 = `.xwrpHYTQE-ThemeProvidermodulecssroot {
1270
1381
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans',
1271
1382
  'Droid Sans', 'Helvetica Neue', sans-serif;
1272
1383
  }
1273
1384
  `;
1274
- var s7 = document.createElement("style");
1275
- s7.setAttribute("data-sourceFile", "src/components/ThemeProvider/ThemeProvider.module.css");
1276
- s7.appendChild(document.createTextNode(compiledModule7));
1277
- document.head.appendChild(s7);
1385
+ var s8 = document.createElement("style");
1386
+ s8.setAttribute("data-sourceFile", "src/components/ThemeProvider/ThemeProvider.module.css");
1387
+ s8.appendChild(document.createTextNode(compiledModule8));
1388
+ document.head.appendChild(s8);
1278
1389
  var root4 = "xwrpHYTQE-ThemeProvidermodulecssroot";
1279
1390
  var ThemeProvider_module_default = { root: root4 };
1280
1391
 
1281
1392
  // src/components/ThemeProvider/ThemeProvider.tsx
1282
1393
  function ThemeProvider({ children }) {
1283
- return /* @__PURE__ */ React12.createElement("div", {
1394
+ return /* @__PURE__ */ React13.createElement("div", {
1284
1395
  className: ThemeProvider_module_default.root
1285
1396
  }, children);
1286
1397
  }
@@ -1288,7 +1399,7 @@ function ThemeProvider({ children }) {
1288
1399
  // src/index.tsx
1289
1400
  var rootDiv = document.createElement("div");
1290
1401
  ReactDOM.render(
1291
- /* @__PURE__ */ React13.createElement(ThemeProvider, null, /* @__PURE__ */ React13.createElement(CloudpackProvider, null, /* @__PURE__ */ React13.createElement(StatusOverlay, null))),
1402
+ /* @__PURE__ */ React14.createElement(ThemeProvider, null, /* @__PURE__ */ React14.createElement(CloudpackProvider, null, /* @__PURE__ */ React14.createElement(StatusOverlay, null))),
1292
1403
  rootDiv
1293
1404
  );
1294
1405
  document.body.appendChild(rootDiv);