@ms-cloudpack/overlay 0.17.12 → 0.17.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-esm/chunks/js/ErrorDialog-744DEKEI.js +74 -0
- package/dist/browser-esm/chunks/js/ErrorDialog-744DEKEI.js.map +7 -0
- package/dist/browser-esm/chunks/js/StatusDialog-J6LM3XZZ.js +316 -0
- package/dist/browser-esm/chunks/js/StatusDialog-J6LM3XZZ.js.map +7 -0
- package/dist/browser-esm/chunks/js/chunk-7KHMDJ6G.js +63 -0
- package/dist/browser-esm/chunks/js/chunk-7KHMDJ6G.js.map +7 -0
- package/dist/browser-esm/chunks/js/chunk-XOJFP5X6.js +416 -0
- package/dist/browser-esm/chunks/js/chunk-XOJFP5X6.js.map +7 -0
- package/dist/browser-esm/lib/index.js +52 -854
- package/dist/browser-esm/lib/index.js.map +4 -4
- package/dist/browser-esm/ori-output.json +305 -182
- package/dist/browser-esm/result.json +55 -4
- package/lib/components/ErrorDialog/ErrorDialog.d.ts +1 -0
- package/lib/components/ErrorDialog/ErrorDialog.d.ts.map +1 -1
- package/lib/components/ErrorDialog/ErrorDialog.js +1 -0
- package/lib/components/ErrorDialog/ErrorDialog.js.map +1 -1
- package/lib/components/StatusDialog/StatusDialog.d.ts +1 -0
- package/lib/components/StatusDialog/StatusDialog.d.ts.map +1 -1
- package/lib/components/StatusDialog/StatusDialog.js +1 -0
- package/lib/components/StatusDialog/StatusDialog.js.map +1 -1
- package/lib/components/StatusOverlay/StatusOverlay.d.ts.map +1 -1
- package/lib/components/StatusOverlay/StatusOverlay.js +4 -3
- package/lib/components/StatusOverlay/StatusOverlay.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Button,
|
|
3
|
+
Dialog,
|
|
4
|
+
TaskList_default,
|
|
5
|
+
TaskStatus_default,
|
|
6
|
+
chevrondown_20_inline_default,
|
|
7
|
+
error_24_inline_default
|
|
8
|
+
} from "./chunk-XOJFP5X6.js";
|
|
9
|
+
import {
|
|
10
|
+
useCloudpack
|
|
11
|
+
} from "./chunk-7KHMDJ6G.js";
|
|
12
|
+
import {
|
|
13
|
+
elementIds
|
|
14
|
+
} from "./chunk-PDWQRLCD.js";
|
|
15
|
+
|
|
16
|
+
// packages/overlay/src/components/ErrorDialog/ErrorDialog.tsx
|
|
17
|
+
import { default as React2 } from "react";
|
|
18
|
+
|
|
19
|
+
// packages/overlay/src/components/ErrorDialog/PathError.tsx
|
|
20
|
+
import React from "react";
|
|
21
|
+
import { default as cx } from "classnames";
|
|
22
|
+
function PathError(props) {
|
|
23
|
+
const [showContent, setshowContent] = React.useState(false);
|
|
24
|
+
const { packageName, importPath, issuerUrl, fixable } = props;
|
|
25
|
+
const cloudpack = useCloudpack();
|
|
26
|
+
const editConfig = () => {
|
|
27
|
+
void cloudpack.openConfigEditor.mutate();
|
|
28
|
+
};
|
|
29
|
+
const addOverride = () => {
|
|
30
|
+
void cloudpack.addPackageOverride.mutate({ packageName, importPath, issuerUrl });
|
|
31
|
+
};
|
|
32
|
+
return /* @__PURE__ */ React.createElement("div", { className: TaskStatus_default.root }, /* @__PURE__ */ React.createElement("div", { className: cx(TaskStatus_default.header, TaskStatus_default.error) }, /* @__PURE__ */ React.createElement(
|
|
33
|
+
"button",
|
|
34
|
+
{
|
|
35
|
+
className: TaskStatus_default.expandButton,
|
|
36
|
+
onClick: () => setshowContent(!showContent),
|
|
37
|
+
"aria-label": showContent ? `Minimize ${packageName}/${importPath}` : `Expand ${packageName}/${importPath}`
|
|
38
|
+
},
|
|
39
|
+
/* @__PURE__ */ React.createElement(
|
|
40
|
+
"img",
|
|
41
|
+
{
|
|
42
|
+
className: cx(TaskStatus_default.expandIcon, !showContent && TaskStatus_default.collapsed),
|
|
43
|
+
src: chevrondown_20_inline_default,
|
|
44
|
+
alt: "Chevron down icon"
|
|
45
|
+
}
|
|
46
|
+
)
|
|
47
|
+
), /* @__PURE__ */ React.createElement("img", { className: TaskStatus_default.errorIcon, src: error_24_inline_default, alt: "Error icon" }), /* @__PURE__ */ React.createElement("div", { className: TaskStatus_default.title }, `${packageName}/${importPath}`)), showContent && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: TaskStatus_default.commands }, fixable && /* @__PURE__ */ React.createElement(Button, { onClick: addOverride }, "Add override"), /* @__PURE__ */ React.createElement(Button, { onClick: editConfig }, "Edit config file")), /* @__PURE__ */ React.createElement("div", { className: TaskStatus_default.content }, /* @__PURE__ */ React.createElement("div", { className: TaskStatus_default.title }, "Details"), /* @__PURE__ */ React.createElement("div", { className: TaskStatus_default.nameValueArea }, /* @__PURE__ */ React.createElement("div", { className: TaskStatus_default.name }, "Problem"), /* @__PURE__ */ React.createElement("div", { className: TaskStatus_default.value }, importPath === "." ? `An unrecognized package "${packageName}" was imported.` : `Path "${importPath}" was imported from package "${packageName}" but was not recognized as an exported path.`)), /* @__PURE__ */ React.createElement("div", { className: TaskStatus_default.nameValueArea }, /* @__PURE__ */ React.createElement("div", { className: TaskStatus_default.name }, "Solution"), /* @__PURE__ */ React.createElement("div", { className: TaskStatus_default.value }, fixable ? `Remove the path from the import in your source. (Import from "${packageName}" rather than "${packageName}/${importPath}")` : importPath === "." ? `Make sure the package name is valid.` : `Import not found on package. Make sure the import path is valid.`)))));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// packages/overlay/src/components/ErrorDialog/ErrorDialog.tsx
|
|
51
|
+
function ErrorDialog({ unsupported }) {
|
|
52
|
+
const cloudpack = useCloudpack();
|
|
53
|
+
const reload = () => {
|
|
54
|
+
void cloudpack.restartAllTasks.mutate();
|
|
55
|
+
};
|
|
56
|
+
return /* @__PURE__ */ React2.createElement(
|
|
57
|
+
Dialog,
|
|
58
|
+
{
|
|
59
|
+
title: "Found unsupported paths in your project",
|
|
60
|
+
id: elementIds.errorDialogRoot,
|
|
61
|
+
style: "error",
|
|
62
|
+
commands: [
|
|
63
|
+
/* @__PURE__ */ React2.createElement(Button, { primary: true, onClick: reload, key: "1" }, "Restart all tasks")
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
/* @__PURE__ */ React2.createElement("div", { className: TaskList_default.root }, unsupported.map((data, index) => /* @__PURE__ */ React2.createElement(PathError, { ...data, key: index })))
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
var ErrorDialog_default = ErrorDialog;
|
|
70
|
+
export {
|
|
71
|
+
ErrorDialog,
|
|
72
|
+
ErrorDialog_default as default
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=ErrorDialog-744DEKEI.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/ErrorDialog/ErrorDialog.tsx", "../../../../src/components/ErrorDialog/PathError.tsx"],
|
|
4
|
+
"sourcesContent": ["import { default as React } from 'react';\nimport { Button } from '../Button/Button.js';\nimport { useCloudpack } from '../CloudpackProvider/CloudpackProvider.js';\nimport { PathError } from './PathError.js';\nimport styles from '../StatusDialog/TaskList.module.css';\nimport type { UnsupportedErrorEvent } from './useErrorEvents.js';\nimport { Dialog } from '../Dialog/Dialog.js';\nimport { elementIds } from '../../constants.js';\n\nexport interface ErrorDialogProps {\n unsupported: UnsupportedErrorEvent[];\n}\n\nexport function ErrorDialog({ unsupported }: ErrorDialogProps) {\n const cloudpack = useCloudpack();\n\n const reload = () => {\n void cloudpack.restartAllTasks.mutate();\n };\n\n return (\n <Dialog\n title=\"Found unsupported paths in your project\"\n id={elementIds.errorDialogRoot}\n style=\"error\"\n commands={[\n <Button primary onClick={reload} key=\"1\">\n Restart all tasks\n </Button>,\n ]}\n >\n <div className={styles.root}>\n {unsupported.map((data, index) => (\n <PathError {...data} key={index} />\n ))}\n </div>\n </Dialog>\n );\n}\n\nexport default ErrorDialog;\n", "import React from 'react';\nimport styles from '../StatusDialog/TaskStatus.module.css';\nimport ErrorIcon from '../../images/error-24.inline.svg';\nimport { default as cx } from 'classnames';\nimport ChevronDownIcon from '../../images/chevrondown-20.inline.svg';\nimport type { UnsupportedErrorEvent } from './useErrorEvents.js';\nimport { Button } from '../Button/Button.js';\nimport { useCloudpack } from '../CloudpackProvider/CloudpackProvider.js';\n\nexport function PathError(props: UnsupportedErrorEvent) {\n const [showContent, setshowContent] = React.useState<boolean>(false);\n const { packageName, importPath, issuerUrl, fixable } = props;\n const cloudpack = useCloudpack();\n\n const editConfig = () => {\n void cloudpack.openConfigEditor.mutate();\n };\n\n const addOverride = () => {\n void cloudpack.addPackageOverride.mutate({ packageName, importPath, issuerUrl });\n };\n\n return (\n <div className={styles.root}>\n <div className={cx(styles.header, styles.error)}>\n <button\n className={styles.expandButton}\n onClick={() => setshowContent(!showContent)}\n aria-label={showContent ? `Minimize ${packageName}/${importPath}` : `Expand ${packageName}/${importPath}`}\n >\n <img\n className={cx(styles.expandIcon, !showContent && styles.collapsed)}\n src={ChevronDownIcon}\n alt=\"Chevron down icon\"\n />\n </button>\n <img className={styles.errorIcon} src={ErrorIcon} alt=\"Error icon\" />\n <div className={styles.title}>{`${packageName}/${importPath}`}</div>\n </div>\n {showContent && (\n <>\n <div className={styles.commands}>\n {fixable && <Button onClick={addOverride}>Add override</Button>}\n <Button onClick={editConfig}>Edit config file</Button>\n </div>\n <div className={styles.content}>\n <div className={styles.title}>Details</div>\n\n <div className={styles.nameValueArea}>\n <div className={styles.name}>Problem</div>\n <div className={styles.value}>\n {importPath === '.'\n ? `An unrecognized package \"${packageName}\" was imported.`\n : `Path \"${importPath}\" was imported from package \"${packageName}\" but was not recognized as an exported path.`}\n </div>\n </div>\n <div className={styles.nameValueArea}>\n <div className={styles.name}>Solution</div>\n <div className={styles.value}>\n {fixable\n ? `Remove the path from the import in your source. (Import from \"${packageName}\" rather than \"${packageName}/${importPath}\")`\n : importPath === '.'\n ? `Make sure the package name is valid.`\n : `Import not found on package. Make sure the import path is valid.`}\n </div>\n </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O,SAAO,SAAO,GAErC,oCAAC,SAAI,WAAW,mBAAO,iBACrB,oCAAC,SAAI,WAAW,mBAAO,QAAM,SAAO,GACpC,oCAAC,SAAI,WAAW,mBAAO,SACpB,eAAe,MACZ,4BAA4B,WAAW,oBACvC,SAAS,UAAU,gCAAgC,WAAW,+CACpE,CACF,GACA,oCAAC,SAAI,WAAW,mBAAO,iBACrB,oCAAC,SAAI,WAAW,mBAAO,QAAM,UAAQ,GACrC,oCAAC,SAAI,WAAW,mBAAO,SACpB,UACG,iEAAiE,WAAW,kBAAkB,WAAW,IAAI,UAAU,OACvH,eAAe,MACb,yCACA,kEACR,CACF,CACF,CACF,CAEJ;AAEJ;;;AD1DO,SAAS,YAAY,EAAE,YAAY,GAAqB;AAC7D,QAAM,YAAY,aAAa;AAE/B,QAAM,SAAS,MAAM;AACnB,SAAK,UAAU,gBAAgB,OAAO;AAAA,EACxC;AAEA,SACE,gBAAAC,OAAA;AAAA,IAAC;AAAA;AAAA,MACC,OAAM;AAAA,MACN,IAAI,WAAW;AAAA,MACf,OAAM;AAAA,MACN,UAAU;AAAA,QACR,gBAAAA,OAAA,cAAC,UAAO,SAAO,MAAC,SAAS,QAAQ,KAAI,OAAI,mBAEzC;AAAA,MACF;AAAA;AAAA,IAEA,gBAAAA,OAAA,cAAC,SAAI,WAAW,iBAAO,QACpB,YAAY,IAAI,CAAC,MAAM,UACtB,gBAAAA,OAAA,cAAC,aAAW,GAAG,MAAM,KAAK,OAAO,CAClC,CACH;AAAA,EACF;AAEJ;AAEA,IAAO,sBAAQ;",
|
|
6
|
+
"names": ["React", "React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Button,
|
|
3
|
+
Dialog,
|
|
4
|
+
TaskList_default,
|
|
5
|
+
TaskStatus_default,
|
|
6
|
+
chevrondown_20_inline_default,
|
|
7
|
+
error_24_inline_default
|
|
8
|
+
} from "./chunk-XOJFP5X6.js";
|
|
9
|
+
import {
|
|
10
|
+
useCloudpack
|
|
11
|
+
} from "./chunk-7KHMDJ6G.js";
|
|
12
|
+
import {
|
|
13
|
+
elementIds
|
|
14
|
+
} from "./chunk-PDWQRLCD.js";
|
|
15
|
+
|
|
16
|
+
// packages/overlay/src/components/StatusDialog/StatusDialog.tsx
|
|
17
|
+
import React5, { useCallback } from "react";
|
|
18
|
+
|
|
19
|
+
// packages/overlay/src/components/StatusDialog/TaskList.tsx
|
|
20
|
+
import React3 from "react";
|
|
21
|
+
|
|
22
|
+
// packages/overlay/src/components/StatusDialog/TaskStatus.tsx
|
|
23
|
+
import React2 from "react";
|
|
24
|
+
|
|
25
|
+
// packages/overlay/src/components/StatusDialog/TaskResultItem.tsx
|
|
26
|
+
import React from "react";
|
|
27
|
+
|
|
28
|
+
// packages/overlay/src/components/StatusDialog/TaskResultItem.module.css
|
|
29
|
+
var compiledModule = `.FSsdmcQ-TaskResultItemmodule--root {
|
|
30
|
+
display: flex;
|
|
31
|
+
background: #f5f5f5;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.FSsdmcQ-TaskResultItemmodule--statusBar {
|
|
35
|
+
flex-shrink: 0;
|
|
36
|
+
border-radius: 4px;
|
|
37
|
+
width: 4px;
|
|
38
|
+
background: #aa0000;
|
|
39
|
+
box-shadow: 2px 0 4px 0 rgb(220 0 0 / 20%);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.FSsdmcQ-TaskResultItemmodule--content {
|
|
43
|
+
padding: 8px;
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-grow: 1;
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
flex-direction: column;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.FSsdmcQ-TaskResultItemmodule--titleArea {
|
|
51
|
+
display: flex;
|
|
52
|
+
align-items: center;
|
|
53
|
+
flex-direction: row;
|
|
54
|
+
gap: 4px;
|
|
55
|
+
padding: 4px 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.FSsdmcQ-TaskResultItemmodule--file {
|
|
59
|
+
display: inline-flex;
|
|
60
|
+
margin: 0;
|
|
61
|
+
padding: 0;
|
|
62
|
+
border: none;
|
|
63
|
+
background: inherit;
|
|
64
|
+
font-family: inherit;
|
|
65
|
+
flex-grow: 1;
|
|
66
|
+
font-weight: 500;
|
|
67
|
+
font-size: 14px;
|
|
68
|
+
flex-shrink: 0;
|
|
69
|
+
text-decoration: none;
|
|
70
|
+
color: #000;
|
|
71
|
+
cursor: pointer;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.FSsdmcQ-TaskResultItemmodule--file:hover {
|
|
75
|
+
text-decoration: underline;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.FSsdmcQ-TaskResultItemmodule--actionArea {
|
|
79
|
+
display: flex;
|
|
80
|
+
flex-direction: row;
|
|
81
|
+
gap: 8px;
|
|
82
|
+
flex-shrink: 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.FSsdmcQ-TaskResultItemmodule--text {
|
|
86
|
+
word-wrap: break-word;
|
|
87
|
+
color: #333;
|
|
88
|
+
}
|
|
89
|
+
`;
|
|
90
|
+
var s = document.createElement("style");
|
|
91
|
+
s.setAttribute("data-sourceFile", "packages/overlay/src/components/StatusDialog/TaskResultItem.module.css");
|
|
92
|
+
s.appendChild(document.createTextNode(compiledModule));
|
|
93
|
+
document.head.appendChild(s);
|
|
94
|
+
var actionArea = "FSsdmcQ-TaskResultItemmodule--actionArea";
|
|
95
|
+
var content = "FSsdmcQ-TaskResultItemmodule--content";
|
|
96
|
+
var file = "FSsdmcQ-TaskResultItemmodule--file";
|
|
97
|
+
var root = "FSsdmcQ-TaskResultItemmodule--root";
|
|
98
|
+
var statusBar = "FSsdmcQ-TaskResultItemmodule--statusBar";
|
|
99
|
+
var text = "FSsdmcQ-TaskResultItemmodule--text";
|
|
100
|
+
var titleArea = "FSsdmcQ-TaskResultItemmodule--titleArea";
|
|
101
|
+
var TaskResultItem_default = { actionArea, content, file, root, statusBar, text, titleArea };
|
|
102
|
+
|
|
103
|
+
// packages/overlay/src/components/StatusDialog/TaskResultItem.tsx
|
|
104
|
+
function TaskResultItem({ item, projectPath, index }) {
|
|
105
|
+
const cloudpack = useCloudpack();
|
|
106
|
+
const openSource = (ev) => {
|
|
107
|
+
if (item.location) {
|
|
108
|
+
void cloudpack.openCodeEditor.mutate({
|
|
109
|
+
rootPath: projectPath,
|
|
110
|
+
relativePath: item.location?.file,
|
|
111
|
+
line: item.location?.line,
|
|
112
|
+
column: item.location?.column
|
|
113
|
+
});
|
|
114
|
+
ev.preventDefault();
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const location = [item.location?.file || "(path unavailable)", item.location?.line, item.location?.column].filter(Boolean).join(":");
|
|
118
|
+
return /* @__PURE__ */ React.createElement("div", { className: TaskResultItem_default.root }, /* @__PURE__ */ React.createElement("div", { className: TaskResultItem_default.statusBar }), /* @__PURE__ */ React.createElement("div", { className: TaskResultItem_default.content }, /* @__PURE__ */ React.createElement("div", { className: TaskResultItem_default.titleArea }, /* @__PURE__ */ React.createElement("button", { onClick: openSource, className: TaskResultItem_default.file }, index, ". ", location)), /* @__PURE__ */ React.createElement("div", { className: TaskResultItem_default.text }, "[", item.source, "] ", item.text), /* @__PURE__ */ React.createElement("pre", { className: TaskResultItem_default.text }, JSON.stringify(item, null, 2))));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// packages/overlay/src/components/StatusDialog/TaskStatus.tsx
|
|
122
|
+
import { default as cx } from "classnames";
|
|
123
|
+
|
|
124
|
+
// packages/overlay/src/images/success-24.inline.svg
|
|
125
|
+
var success_24_inline_default = 'data:image/svg+xml,<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">%0A<path d="M12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2ZM15.2197 8.96967L10.75 13.4393L8.78033 11.4697C8.48744 11.1768 8.01256 11.1768 7.71967 11.4697C7.42678 11.7626 7.42678 12.2374 7.71967 12.5303L10.2197 15.0303C10.5126 15.3232 10.9874 15.3232 11.2803 15.0303L16.2803 10.0303C16.5732 9.73744 16.5732 9.26256 16.2803 8.96967C15.9874 8.67678 15.5126 8.67678 15.2197 8.96967Z" fill="%2300aa00"/>%0A</svg>%0A';
|
|
126
|
+
|
|
127
|
+
// packages/overlay/src/components/StatusDialog/TaskStatus.tsx
|
|
128
|
+
function getCompletion(task) {
|
|
129
|
+
if (task.status === "pending") {
|
|
130
|
+
return "Running";
|
|
131
|
+
}
|
|
132
|
+
return [
|
|
133
|
+
`Completed in ${task.durationMilliseconds}ms`,
|
|
134
|
+
task.errors?.length && `${task.errors.length} error${task.errors.length > 1 ? "s" : ""}`,
|
|
135
|
+
task.warnings?.length && `${task.warnings.length} warning${task.warnings.length > 1 ? "s" : ""}`
|
|
136
|
+
].filter(Boolean).join(", ");
|
|
137
|
+
}
|
|
138
|
+
function TaskStatus({ task }) {
|
|
139
|
+
const [isOpen, setIsOpen] = React2.useState(void 0);
|
|
140
|
+
const { name, warnings = [], errors = [] } = task;
|
|
141
|
+
const cloudpack = useCloudpack();
|
|
142
|
+
const showContent = isOpen === true || isOpen === void 0 && errors?.length > 0;
|
|
143
|
+
const { inputPath, outputPath } = task;
|
|
144
|
+
const open = (rootPath) => {
|
|
145
|
+
void cloudpack.openFilePath.mutate({
|
|
146
|
+
rootPath
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
const openPackage = () => {
|
|
150
|
+
if (!inputPath) {
|
|
151
|
+
console.error("No input path for task", task);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
void cloudpack.openCodeEditor.mutate({
|
|
155
|
+
rootPath: inputPath,
|
|
156
|
+
relativePath: "package.json"
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
const restartTask = () => {
|
|
160
|
+
if (!inputPath) {
|
|
161
|
+
console.error("No input path for task", task);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
void cloudpack.restartTask.mutate({ id: task.id, inputPath });
|
|
165
|
+
};
|
|
166
|
+
return /* @__PURE__ */ React2.createElement("div", { className: TaskStatus_default.root }, /* @__PURE__ */ React2.createElement("div", { className: getHeaderClassName(task) }, /* @__PURE__ */ React2.createElement(
|
|
167
|
+
"button",
|
|
168
|
+
{
|
|
169
|
+
className: TaskStatus_default.expandButton,
|
|
170
|
+
onClick: () => setIsOpen(!showContent),
|
|
171
|
+
"aria-label": showContent ? `Minimize ${name}` : `Expand ${name}`
|
|
172
|
+
},
|
|
173
|
+
/* @__PURE__ */ React2.createElement(
|
|
174
|
+
"img",
|
|
175
|
+
{
|
|
176
|
+
className: cx(TaskStatus_default.expandIcon, !showContent && TaskStatus_default.collapsed),
|
|
177
|
+
src: chevrondown_20_inline_default,
|
|
178
|
+
alt: "Chevron down icon"
|
|
179
|
+
}
|
|
180
|
+
)
|
|
181
|
+
), errors?.length === 0 && warnings?.length === 0 && /* @__PURE__ */ React2.createElement("img", { className: TaskStatus_default.errorIcon, src: success_24_inline_default, alt: "Success icon" }), errors?.length > 0 && /* @__PURE__ */ React2.createElement("img", { className: TaskStatus_default.errorIcon, src: error_24_inline_default, alt: "Error icon" }), /* @__PURE__ */ React2.createElement("div", { className: TaskStatus_default.title }, name), /* @__PURE__ */ React2.createElement("div", { className: TaskStatus_default.farArea }, getCompletion(task))), showContent && (inputPath ? /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("div", { className: TaskStatus_default.commands }, /* @__PURE__ */ React2.createElement(Button, { onClick: restartTask }, "Restart task")), /* @__PURE__ */ React2.createElement("div", { className: TaskStatus_default.content }, /* @__PURE__ */ React2.createElement("div", { className: TaskStatus_default.title }, "Details"), /* @__PURE__ */ React2.createElement("div", { className: TaskStatus_default.nameValueArea }, /* @__PURE__ */ React2.createElement("div", { className: TaskStatus_default.name }, "Input path"), /* @__PURE__ */ React2.createElement("div", { className: TaskStatus_default.value }, /* @__PURE__ */ React2.createElement("button", { className: TaskStatus_default.linkButton, onClick: () => open(inputPath) }, task.inputPath), /* @__PURE__ */ React2.createElement("button", { className: TaskStatus_default.linkButton, onClick: openPackage }, "(Package.json)"))), outputPath && /* @__PURE__ */ React2.createElement("div", { className: TaskStatus_default.nameValueArea }, /* @__PURE__ */ React2.createElement("div", { className: TaskStatus_default.name }, "Output path"), /* @__PURE__ */ React2.createElement("button", { className: TaskStatus_default.linkButton, onClick: () => open(outputPath) }, outputPath)), errors?.length > 0 && /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("div", { className: TaskStatus_default.title }, "Errors"), /* @__PURE__ */ React2.createElement("div", { className: TaskStatus_default.resultItems }, errors.map((error, index) => /* @__PURE__ */ React2.createElement(TaskResultItem, { key: index, item: error, projectPath: inputPath, index: index + 1 })))), warnings?.length > 0 && /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("div", { className: TaskStatus_default.title }, "Warnings"), /* @__PURE__ */ React2.createElement("div", { className: TaskStatus_default.resultItems }, warnings.map((warning, index) => /* @__PURE__ */ React2.createElement(TaskResultItem, { key: index, item: warning, projectPath: inputPath, index: index + 1 })))))) : /* @__PURE__ */ React2.createElement("div", { className: TaskStatus_default.content }, "No input path found for task. This is a Cloudpack bug. Please report it.")));
|
|
182
|
+
}
|
|
183
|
+
function getHeaderClassName(task) {
|
|
184
|
+
const { errors = [], warnings = [] } = task;
|
|
185
|
+
return cx(TaskStatus_default.header, {
|
|
186
|
+
[TaskStatus_default.success]: errors?.length === 0 && warnings?.length === 0,
|
|
187
|
+
[TaskStatus_default.warning]: errors?.length === 0 && warnings?.length > 0,
|
|
188
|
+
[TaskStatus_default.error]: errors?.length > 0
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// packages/overlay/src/components/CloudpackProvider/useStatusDetails.ts
|
|
193
|
+
import { useEffect, useState } from "react";
|
|
194
|
+
import { taskListSource } from "@ms-cloudpack/api-server/browser";
|
|
195
|
+
var useStatusDetails = () => {
|
|
196
|
+
const cloudpack = useCloudpack();
|
|
197
|
+
const [details, setDetails] = useState({ tasks: [] });
|
|
198
|
+
useEffect(() => {
|
|
199
|
+
const subscription = cloudpack?.onDataChanged.subscribe(taskListSource, {
|
|
200
|
+
onData: (data) => {
|
|
201
|
+
setDetails(data);
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
return () => {
|
|
205
|
+
subscription.unsubscribe();
|
|
206
|
+
};
|
|
207
|
+
}, [cloudpack]);
|
|
208
|
+
return details;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
// packages/overlay/src/components/StatusDialog/TaskList.tsx
|
|
212
|
+
function TaskList({ searchFilter, issuesOnly }) {
|
|
213
|
+
const details = useStatusDetails();
|
|
214
|
+
const tasks = (details.tasks || []).sort(sortTasks);
|
|
215
|
+
let filteredTasks = tasks;
|
|
216
|
+
if (searchFilter) {
|
|
217
|
+
searchFilter = searchFilter.toLowerCase();
|
|
218
|
+
filteredTasks = filteredTasks.filter(({ name }) => searchFilter && name?.toLowerCase().includes(searchFilter));
|
|
219
|
+
}
|
|
220
|
+
if (issuesOnly) {
|
|
221
|
+
filteredTasks = filteredTasks.filter(({ errors, warnings }) => errors?.length || warnings?.length);
|
|
222
|
+
}
|
|
223
|
+
return /* @__PURE__ */ React3.createElement("div", { className: TaskList_default.root }, filteredTasks.map((task) => /* @__PURE__ */ React3.createElement(TaskStatus, { key: task.name, task })));
|
|
224
|
+
}
|
|
225
|
+
function sortTasks(a, b) {
|
|
226
|
+
const aStatus = a.status === "pending" ? 1 : 0;
|
|
227
|
+
const bStatus = b.status === "pending" ? 1 : 0;
|
|
228
|
+
if (aStatus !== bStatus) {
|
|
229
|
+
return aStatus > bStatus ? -1 : 1;
|
|
230
|
+
}
|
|
231
|
+
const aErrors = a.errors?.length || 0;
|
|
232
|
+
const bErrors = b.errors?.length || 0;
|
|
233
|
+
if (aErrors !== bErrors) {
|
|
234
|
+
return aErrors > bErrors ? -1 : 1;
|
|
235
|
+
}
|
|
236
|
+
if (a.name === void 0 && b.name === void 0) {
|
|
237
|
+
return a.id < b.id ? -1 : 1;
|
|
238
|
+
} else if (a.name === void 0) {
|
|
239
|
+
return 1;
|
|
240
|
+
} else if (b.name === void 0) {
|
|
241
|
+
return -1;
|
|
242
|
+
}
|
|
243
|
+
return a.name < b.name ? -1 : 1;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// packages/overlay/src/components/StatusDialog/Searchbox.tsx
|
|
247
|
+
import React4 from "react";
|
|
248
|
+
|
|
249
|
+
// packages/overlay/src/components/StatusDialog/Searchbox.module.css
|
|
250
|
+
var compiledModule2 = `.aJeqJtva-Searchboxmodule--searchbox {
|
|
251
|
+
position: absolute;
|
|
252
|
+
font-size: 14px;
|
|
253
|
+
font-weight: 400;
|
|
254
|
+
box-shadow: none;
|
|
255
|
+
padding: 0px 4px;
|
|
256
|
+
box-sizing: border-box;
|
|
257
|
+
color: rgb(50, 49, 48);
|
|
258
|
+
background-color: rgb(255, 255, 255);
|
|
259
|
+
display: flex;
|
|
260
|
+
flex-flow: row nowrap;
|
|
261
|
+
align-items: stretch;
|
|
262
|
+
border-radius: 2px;
|
|
263
|
+
border: 1px solid rgb(96, 94, 92);
|
|
264
|
+
height: 32px;
|
|
265
|
+
min-width: 160px;
|
|
266
|
+
top: 52px;
|
|
267
|
+
right: 20px;
|
|
268
|
+
}
|
|
269
|
+
`;
|
|
270
|
+
var s2 = document.createElement("style");
|
|
271
|
+
s2.setAttribute("data-sourceFile", "packages/overlay/src/components/StatusDialog/Searchbox.module.css");
|
|
272
|
+
s2.appendChild(document.createTextNode(compiledModule2));
|
|
273
|
+
document.head.appendChild(s2);
|
|
274
|
+
var searchbox = "aJeqJtva-Searchboxmodule--searchbox";
|
|
275
|
+
var Searchbox_default = { searchbox };
|
|
276
|
+
|
|
277
|
+
// packages/overlay/src/components/StatusDialog/Searchbox.tsx
|
|
278
|
+
function Searchbox({ value, onChange }) {
|
|
279
|
+
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, typeof value === "string" && /* @__PURE__ */ React4.createElement("input", { type: "text", placeholder: "Search", className: Searchbox_default.searchbox, onChange, value }));
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// packages/overlay/src/components/StatusDialog/StatusDialog.tsx
|
|
283
|
+
function StatusDialog({ onClose }) {
|
|
284
|
+
const cloudpack = useCloudpack();
|
|
285
|
+
const [searchFilter, setSearchFilter] = React5.useState("");
|
|
286
|
+
const [issuesOnly, setIssuesOnly] = React5.useState(false);
|
|
287
|
+
const handleSearchChange = useCallback((event) => {
|
|
288
|
+
event.preventDefault();
|
|
289
|
+
setSearchFilter(event.target.value);
|
|
290
|
+
}, []);
|
|
291
|
+
const restartAllTasks = () => {
|
|
292
|
+
void cloudpack.restartAllTasks.mutate();
|
|
293
|
+
};
|
|
294
|
+
const toggleIssuesOnly = () => setIssuesOnly((value) => !value);
|
|
295
|
+
return /* @__PURE__ */ React5.createElement(
|
|
296
|
+
Dialog,
|
|
297
|
+
{
|
|
298
|
+
title: "Task results",
|
|
299
|
+
id: elementIds.statusDialogRoot,
|
|
300
|
+
draggable: true,
|
|
301
|
+
onClose,
|
|
302
|
+
commands: [
|
|
303
|
+
/* @__PURE__ */ React5.createElement(Button, { primary: true, onClick: restartAllTasks, key: "restart" }, "Restart all tasks"),
|
|
304
|
+
/* @__PURE__ */ React5.createElement(Button, { onClick: toggleIssuesOnly, key: "issues" }, issuesOnly ? "Show all tasks" : "Show tasks with issues")
|
|
305
|
+
]
|
|
306
|
+
},
|
|
307
|
+
/* @__PURE__ */ React5.createElement(Searchbox, { value: searchFilter, onChange: handleSearchChange }),
|
|
308
|
+
/* @__PURE__ */ React5.createElement(TaskList, { searchFilter, issuesOnly })
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
var StatusDialog_default = StatusDialog;
|
|
312
|
+
export {
|
|
313
|
+
StatusDialog,
|
|
314
|
+
StatusDialog_default as default
|
|
315
|
+
};
|
|
316
|
+
//# sourceMappingURL=StatusDialog-J6LM3XZZ.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/StatusDialog/StatusDialog.tsx", "../../../../src/components/StatusDialog/TaskList.tsx", "../../../../src/components/StatusDialog/TaskStatus.tsx", "../../../../src/components/StatusDialog/TaskResultItem.tsx", "../../../../src/components/StatusDialog/TaskResultItem.module.css", "../../../../src/components/CloudpackProvider/useStatusDetails.ts", "../../../../src/components/StatusDialog/Searchbox.tsx", "../../../../src/components/StatusDialog/Searchbox.module.css"],
|
|
4
|
+
"sourcesContent": ["import React, { useCallback } from 'react';\nimport { TaskList } from './TaskList.js';\nimport { useCloudpack } from '../CloudpackProvider/CloudpackProvider.js';\nimport { Button } from '../Button/Button.js';\nimport { Dialog } from '../Dialog/Dialog.js';\nimport { Searchbox } from './Searchbox.js';\nimport { elementIds } from '../../constants.js';\n\nexport interface StatusDialogProps {\n onClose: () => void;\n}\n\nexport function StatusDialog({ onClose }: StatusDialogProps) {\n const cloudpack = useCloudpack();\n const [searchFilter, setSearchFilter] = React.useState('');\n const [issuesOnly, setIssuesOnly] = React.useState(false);\n\n const handleSearchChange = useCallback((event: React.ChangeEvent<HTMLInputElement>) => {\n event.preventDefault();\n setSearchFilter(event.target.value);\n }, []);\n\n const restartAllTasks = () => {\n void cloudpack.restartAllTasks.mutate();\n };\n\n const toggleIssuesOnly = () => setIssuesOnly((value) => !value);\n\n return (\n <Dialog\n title=\"Task results\"\n id={elementIds.statusDialogRoot}\n draggable\n onClose={onClose}\n commands={[\n <Button primary onClick={restartAllTasks} key=\"restart\">\n Restart all tasks\n </Button>,\n <Button onClick={toggleIssuesOnly} key=\"issues\">\n {issuesOnly ? 'Show all tasks' : 'Show tasks with issues'}\n </Button>,\n ]}\n >\n <Searchbox value={searchFilter} onChange={handleSearchChange} />\n <TaskList searchFilter={searchFilter} issuesOnly={issuesOnly} />\n </Dialog>\n );\n}\n\nexport default StatusDialog;\n", "import React from 'react';\nimport { TaskStatus } from './TaskStatus.js';\nimport { useStatusDetails } from '../CloudpackProvider/useStatusDetails.js';\nimport styles from './TaskList.module.css';\nimport type { TaskDescription } from '@ms-cloudpack/api-server/browser';\n\nexport interface TaskListProps {\n searchFilter?: string;\n issuesOnly?: boolean;\n}\n\nexport function TaskList({ searchFilter, issuesOnly }: TaskListProps) {\n const details = useStatusDetails();\n const tasks = (details.tasks || []).sort(sortTasks);\n\n let filteredTasks = tasks;\n if (searchFilter) {\n searchFilter = searchFilter.toLowerCase();\n filteredTasks = filteredTasks.filter(({ name }) => searchFilter && name?.toLowerCase().includes(searchFilter));\n }\n if (issuesOnly) {\n filteredTasks = filteredTasks.filter(({ errors, warnings }) => errors?.length || warnings?.length);\n }\n\n return (\n <div className={styles.root}>\n {filteredTasks.map((task) => (\n <TaskStatus key={task.name} task={task} />\n ))}\n </div>\n );\n}\n\n/**\n * Really the server should be sorting. Get stuff out of the browser.\n */\nfunction sortTasks(a: TaskDescription, b: TaskDescription) {\n const aStatus = a.status === 'pending' ? 1 : 0;\n const bStatus = b.status === 'pending' ? 1 : 0;\n\n if (aStatus !== bStatus) {\n return aStatus > bStatus ? -1 : 1;\n }\n\n const aErrors = a.errors?.length || 0;\n const bErrors = b.errors?.length || 0;\n\n if (aErrors !== bErrors) {\n return aErrors > bErrors ? -1 : 1;\n }\n\n if (a.name === undefined && b.name === undefined) {\n return a.id < b.id ? -1 : 1;\n } else if (a.name === undefined) {\n return 1;\n } else if (b.name === undefined) {\n return -1;\n }\n\n return a.name < b.name ? -1 : 1;\n}\n", "import React from 'react';\nimport type { TaskDescription } from '@ms-cloudpack/api-server/browser';\nimport { TaskResultItem } from './TaskResultItem.js';\nimport styles from './TaskStatus.module.css';\nimport { default as cx } from 'classnames';\nimport ErrorIcon from '../../images/error-24.inline.svg';\nimport SuccessIcon from '../../images/success-24.inline.svg';\nimport ChevronDownIcon from '../../images/chevrondown-20.inline.svg';\nimport { useCloudpack } from '../CloudpackProvider/CloudpackProvider.js';\nimport { Button } from '../Button/Button.js';\n\nexport interface TaskStatusProps {\n task: TaskDescription;\n}\n\nfunction getCompletion(task: TaskDescription) {\n if (task.status === 'pending') {\n return 'Running';\n }\n return [\n `Completed in ${task.durationMilliseconds}ms`,\n task.errors?.length && `${task.errors.length} error${task.errors.length > 1 ? 's' : ''}`,\n task.warnings?.length && `${task.warnings.length} warning${task.warnings.length > 1 ? 's' : ''}`,\n ]\n .filter(Boolean)\n .join(', ');\n}\n\nexport function TaskStatus({ task }: TaskStatusProps) {\n const [isOpen, setIsOpen] = React.useState<boolean | undefined>(undefined);\n const { name, warnings = [], errors = [] } = task;\n const cloudpack = useCloudpack();\n const showContent = isOpen === true || (isOpen === undefined && errors?.length > 0);\n\n const { inputPath, outputPath } = task;\n\n const open = (rootPath: string) => {\n void cloudpack.openFilePath.mutate({\n rootPath,\n });\n };\n\n const openPackage = () => {\n if (!inputPath) {\n console.error('No input path for task', task);\n return;\n }\n void cloudpack.openCodeEditor.mutate({\n rootPath: inputPath,\n relativePath: 'package.json',\n });\n };\n\n const restartTask = () => {\n if (!inputPath) {\n console.error('No input path for task', task);\n return;\n }\n void cloudpack.restartTask.mutate({ id: task.id, inputPath });\n };\n\n return (\n <div className={styles.root}>\n <div className={getHeaderClassName(task)}>\n <button\n className={styles.expandButton}\n onClick={() => setIsOpen(!showContent)}\n aria-label={showContent ? `Minimize ${name}` : `Expand ${name}`}\n >\n <img\n className={cx(styles.expandIcon, !showContent && styles.collapsed)}\n src={ChevronDownIcon}\n alt=\"Chevron down icon\"\n />\n </button>\n {errors?.length === 0 && warnings?.length === 0 && (\n <img className={styles.errorIcon} src={SuccessIcon} alt=\"Success icon\" />\n )}\n {errors?.length > 0 && <img className={styles.errorIcon} src={ErrorIcon} alt=\"Error icon\" />}\n <div className={styles.title}>{name}</div>\n <div className={styles.farArea}>{getCompletion(task)}</div>\n </div>\n {showContent &&\n (inputPath ? (\n <>\n <div className={styles.commands}>\n <Button onClick={restartTask}>Restart task</Button>\n </div>\n <div className={styles.content}>\n <div className={styles.title}>Details</div>\n <div className={styles.nameValueArea}>\n <div className={styles.name}>Input path</div>\n <div className={styles.value}>\n <button className={styles.linkButton} onClick={() => open(inputPath)}>\n {task.inputPath}\n </button>\n\n <button className={styles.linkButton} onClick={openPackage}>\n (Package.json)\n </button>\n </div>\n </div>\n {outputPath && (\n <div className={styles.nameValueArea}>\n <div className={styles.name}>Output path</div>\n <button className={styles.linkButton} onClick={() => open(outputPath)}>\n {outputPath}\n </button>\n </div>\n )}\n {errors?.length > 0 && (\n <>\n <div className={styles.title}>Errors</div>\n <div className={styles.resultItems}>\n {errors.map((error, index) => (\n <TaskResultItem key={index} item={error} projectPath={inputPath} index={index + 1} />\n ))}\n </div>\n </>\n )}\n {warnings?.length > 0 && (\n <>\n <div className={styles.title}>Warnings</div>\n <div className={styles.resultItems}>\n {warnings.map((warning, index) => (\n <TaskResultItem key={index} item={warning} projectPath={inputPath} index={index + 1} />\n ))}\n </div>\n </>\n )}\n </div>\n </>\n ) : (\n <div className={styles.content}>No input path found for task. This is a Cloudpack bug. Please report it.</div>\n ))}\n </div>\n );\n}\n\nfunction getHeaderClassName(task: TaskDescription) {\n const { errors = [], warnings = [] } = task;\n return cx(styles.header, {\n [styles.success]: errors?.length === 0 && warnings?.length === 0,\n [styles.warning]: errors?.length === 0 && warnings?.length > 0,\n [styles.error]: errors?.length > 0,\n });\n}\n", "import type { BundleMessage } from '@ms-cloudpack/common-types';\nimport React from 'react';\nimport { useCloudpack } from '../CloudpackProvider/CloudpackProvider.js';\nimport styles from './TaskResultItem.module.css';\n\nexport interface TaskResultItemProps {\n item: BundleMessage;\n projectPath: string;\n index: number;\n}\n\nexport function TaskResultItem({ item, projectPath, index }: TaskResultItemProps) {\n const cloudpack = useCloudpack();\n\n const openSource = (ev: React.MouseEvent) => {\n if (item.location) {\n void cloudpack.openCodeEditor.mutate({\n rootPath: projectPath,\n relativePath: item.location?.file,\n line: item.location?.line,\n column: item.location?.column,\n });\n ev.preventDefault();\n }\n };\n\n const location = [item.location?.file || '(path unavailable)', item.location?.line, item.location?.column]\n .filter(Boolean)\n .join(':');\n\n return (\n <div className={styles.root}>\n <div className={styles.statusBar}></div>\n <div className={styles.content}>\n <div className={styles.titleArea}>\n <button onClick={openSource} className={styles.file}>\n {index}. {location}\n </button>\n </div>\n <div className={styles.text}>\n [{item.source}] {item.text}\n </div>\n <pre className={styles.text}>{JSON.stringify(item, null, 2)}</pre>\n </div>\n </div>\n );\n}\n", "// THIS FILE IS AUTO GENERATED FROM packages/overlay/src/components/StatusDialog/TaskResultItem.module.css\n\n\nlet compiledModule = `.FSsdmcQ-TaskResultItemmodule--root {\\n display: flex;\\n background: #f5f5f5;\\n}\\n\\n.FSsdmcQ-TaskResultItemmodule--statusBar {\\n flex-shrink: 0;\\n border-radius: 4px;\\n width: 4px;\\n background: #aa0000;\\n box-shadow: 2px 0 4px 0 rgb(220 0 0 / 20%);\\n}\\n\\n.FSsdmcQ-TaskResultItemmodule--content {\\n padding: 8px;\\n display: flex;\\n flex-grow: 1;\\n overflow: hidden;\\n flex-direction: column;\\n}\\n\\n.FSsdmcQ-TaskResultItemmodule--titleArea {\\n display: flex;\\n align-items: center;\\n flex-direction: row;\\n gap: 4px;\\n padding: 4px 0;\\n}\\n\\n.FSsdmcQ-TaskResultItemmodule--file {\\n display: inline-flex;\\n margin: 0;\\n padding: 0;\\n border: none;\\n background: inherit;\\n font-family: inherit;\\n flex-grow: 1;\\n font-weight: 500;\\n font-size: 14px;\\n flex-shrink: 0;\\n text-decoration: none;\\n color: #000;\\n cursor: pointer;\\n}\\n\\n.FSsdmcQ-TaskResultItemmodule--file:hover {\\n text-decoration: underline;\\n}\\n\\n.FSsdmcQ-TaskResultItemmodule--actionArea {\\n display: flex;\\n flex-direction: row;\\n gap: 8px;\\n flex-shrink: 0;\\n}\\n\\n.FSsdmcQ-TaskResultItemmodule--text {\\n word-wrap: break-word;\\n color: #333;\\n}\\n`;\nconst s = document.createElement('style');\ns.setAttribute('data-sourceFile', 'packages/overlay/src/components/StatusDialog/TaskResultItem.module.css');\ns.appendChild(document.createTextNode(compiledModule));\ndocument.head.appendChild(s)\nexport const actionArea = 'FSsdmcQ-TaskResultItemmodule--actionArea';\nexport const content = 'FSsdmcQ-TaskResultItemmodule--content';\nexport const file = 'FSsdmcQ-TaskResultItemmodule--file';\nexport const root = 'FSsdmcQ-TaskResultItemmodule--root';\nexport const statusBar = 'FSsdmcQ-TaskResultItemmodule--statusBar';\nexport const text = 'FSsdmcQ-TaskResultItemmodule--text';\nexport const titleArea = 'FSsdmcQ-TaskResultItemmodule--titleArea';\nexport default {actionArea, content, file, root, statusBar, text, titleArea}\n", "import { useEffect, useState } from 'react';\nimport { useCloudpack } from './CloudpackProvider.js';\nimport { taskListSource, type TaskList } from '@ms-cloudpack/api-server/browser';\n\nexport const useStatusDetails = () => {\n const cloudpack = useCloudpack();\n const [details, setDetails] = useState<TaskList>({ tasks: [] });\n\n useEffect(() => {\n const subscription = cloudpack?.onDataChanged.subscribe(taskListSource, {\n onData: (data) => {\n setDetails(data as TaskList);\n },\n });\n\n return () => {\n subscription.unsubscribe();\n };\n }, [cloudpack]);\n\n return details;\n};\n", "import React from 'react';\nimport styles from './Searchbox.module.css';\n\nexport interface SearchboxProps {\n value: string;\n onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;\n}\n\nexport function Searchbox({ value, onChange }: SearchboxProps) {\n return (\n <>\n {typeof value === 'string' && (\n <input type=\"text\" placeholder=\"Search\" className={styles.searchbox} onChange={onChange} value={value} />\n )}\n </>\n );\n}\n", "// THIS FILE IS AUTO GENERATED FROM packages/overlay/src/components/StatusDialog/Searchbox.module.css\n\n\nlet compiledModule = `.aJeqJtva-Searchboxmodule--searchbox {\\n position: absolute;\\n font-size: 14px;\\n font-weight: 400;\\n box-shadow: none;\\n padding: 0px 4px;\\n box-sizing: border-box;\\n color: rgb(50, 49, 48);\\n background-color: rgb(255, 255, 255);\\n display: flex;\\n flex-flow: row nowrap;\\n align-items: stretch;\\n border-radius: 2px;\\n border: 1px solid rgb(96, 94, 92);\\n height: 32px;\\n min-width: 160px;\\n top: 52px;\\n right: 20px;\\n}\\n`;\nconst s = document.createElement('style');\ns.setAttribute('data-sourceFile', 'packages/overlay/src/components/StatusDialog/Searchbox.module.css');\ns.appendChild(document.createTextNode(compiledModule));\ndocument.head.appendChild(s)\nexport const searchbox = 'aJeqJtva-Searchboxmodule--searchbox';\nexport default {searchbox}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA,OAAOA,UAAS,mBAAmB;;;ACAnC,OAAOC,YAAW;;;ACAlB,OAAOC,YAAW;;;ACClB,OAAO,WAAW;;;ACElB,IAAI,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACrB,IAAM,IAAI,SAAS,cAAc,OAAO;AACxC,EAAE,aAAa,mBAAmB,wEAAwE;AAC1G,EAAE,YAAY,SAAS,eAAe,cAAc,CAAC;AACrD,SAAS,KAAK,YAAY,CAAC;AACpB,IAAM,aAAa;AACnB,IAAM,UAAU;AAChB,IAAM,OAAO;AACb,IAAM,OAAO;AACb,IAAM,YAAY;AAClB,IAAM,OAAO;AACb,IAAM,YAAY;AACzB,IAAO,yBAAQ,EAAC,YAAY,SAAS,MA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B,KAAI,YACpC,aAAa,mBAAmB,wBACnC;AAAA,MACF;AAAA;AAAA,IAEA,gBAAAA,OAAA,cAAC,aAAU,OAAO,cAAc,UAAU,oBAAoB;AAAA,IAC9D,gBAAAA,OAAA,cAAC,YAAS,cAA4B,YAAwB;AAAA,EAChE;AAEJ;AAEA,IAAO,uBAAQ;",
|
|
6
|
+
"names": ["React", "React", "React", "React", "React", "React", "compiledModule", "s", "React", "React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// packages/overlay/src/components/CloudpackProvider/CloudpackProvider.tsx
|
|
2
|
+
import React, { createContext, useContext } from "react";
|
|
3
|
+
var CloudpackContext = createContext(null);
|
|
4
|
+
function CloudpackProvider({ client, children }) {
|
|
5
|
+
return /* @__PURE__ */ React.createElement(CloudpackContext.Provider, { value: client }, children);
|
|
6
|
+
}
|
|
7
|
+
var useCloudpack = () => useContext(CloudpackContext);
|
|
8
|
+
|
|
9
|
+
// packages/overlay/src/hooks/useDraggable.ts
|
|
10
|
+
import { useEffect, useState } from "react";
|
|
11
|
+
function useDraggable(options) {
|
|
12
|
+
const { enabled, containerElementRef, dragElementRef } = options;
|
|
13
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const moveTarget = containerElementRef?.current;
|
|
16
|
+
const dragTarget = dragElementRef?.current;
|
|
17
|
+
if (!enabled || !moveTarget || !dragTarget) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
let originalX = 0;
|
|
21
|
+
let originalY = 0;
|
|
22
|
+
let offset = { x: 0, y: 0 };
|
|
23
|
+
const onPointerMove = (event) => {
|
|
24
|
+
moveTarget.style.transform = `translate(${offset.x + event.clientX - originalX}px, ${offset.y + event.clientY - originalY}px)`;
|
|
25
|
+
};
|
|
26
|
+
const onPointerUp = (event) => {
|
|
27
|
+
setIsDragging(false);
|
|
28
|
+
offset = {
|
|
29
|
+
x: offset.x + event.clientX - originalX,
|
|
30
|
+
y: offset.y + event.clientY - originalY
|
|
31
|
+
};
|
|
32
|
+
dragTarget.releasePointerCapture(event.pointerId);
|
|
33
|
+
dragTarget.removeEventListener("pointerup", onPointerUp);
|
|
34
|
+
dragTarget.removeEventListener("pointermove", onPointerMove);
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
};
|
|
37
|
+
const onPointerDown = (event) => {
|
|
38
|
+
setIsDragging(true);
|
|
39
|
+
originalX = event.clientX;
|
|
40
|
+
originalY = event.clientY;
|
|
41
|
+
dragTarget.setPointerCapture(event.pointerId);
|
|
42
|
+
dragTarget.addEventListener("pointerup", onPointerUp);
|
|
43
|
+
dragTarget.addEventListener("pointermove", onPointerMove);
|
|
44
|
+
event.preventDefault();
|
|
45
|
+
};
|
|
46
|
+
dragTarget.addEventListener("pointerdown", onPointerDown);
|
|
47
|
+
return () => {
|
|
48
|
+
dragTarget.removeEventListener("pointerdown", onPointerDown);
|
|
49
|
+
dragTarget.removeEventListener("pointermove", onPointerMove);
|
|
50
|
+
dragTarget.removeEventListener("pointerup", onPointerUp);
|
|
51
|
+
};
|
|
52
|
+
}, [enabled, containerElementRef, dragElementRef]);
|
|
53
|
+
return {
|
|
54
|
+
isDragging
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
CloudpackProvider,
|
|
60
|
+
useCloudpack,
|
|
61
|
+
useDraggable
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=chunk-7KHMDJ6G.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/CloudpackProvider/CloudpackProvider.tsx", "../../../../src/hooks/useDraggable.ts"],
|
|
4
|
+
"sourcesContent": ["import React, { createContext, useContext } from 'react';\nimport { type CloudpackClient } from '@ms-cloudpack/api-server/browser';\n\nexport const CloudpackContext = createContext<CloudpackClient>(null as unknown as CloudpackClient);\n\nexport function CloudpackProvider({ client, children }: { client: CloudpackClient; children: React.ReactNode }) {\n return <CloudpackContext.Provider value={client}>{children}</CloudpackContext.Provider>;\n}\n\nexport const useCloudpack = () => useContext(CloudpackContext);\n", "import { type RefObject, useEffect, useState } from 'react';\n\n/**\n * Make an element draggable. Note that changing `enabled` or passing different ref objects\n * will trigger reconfiguring the event handlers, but changing `.current` will not.\n * @returns Whether the element is currently being dragged\n */\nexport function useDraggable(options: {\n /** Whether to enable dragging */\n enabled: boolean;\n /** Element that should be draggable */\n containerElementRef: RefObject<HTMLElement>;\n /** The drag handle element */\n dragElementRef: RefObject<HTMLElement>;\n}) {\n const { enabled, containerElementRef, dragElementRef } = options;\n\n const [isDragging, setIsDragging] = useState(false);\n\n useEffect(() => {\n const moveTarget = containerElementRef?.current;\n const dragTarget = dragElementRef?.current;\n\n if (!enabled || !moveTarget || !dragTarget) {\n return;\n }\n\n let originalX = 0;\n let originalY = 0;\n let offset = { x: 0, y: 0 };\n\n const onPointerMove = (event: PointerEvent) => {\n moveTarget.style.transform = `translate(${offset.x + event.clientX - originalX}px, ${\n offset.y + event.clientY - originalY\n }px)`;\n };\n\n const onPointerUp = (event: PointerEvent) => {\n setIsDragging(false);\n offset = {\n x: offset.x + event.clientX - originalX,\n y: offset.y + event.clientY - originalY,\n };\n\n dragTarget.releasePointerCapture(event.pointerId);\n dragTarget.removeEventListener('pointerup', onPointerUp);\n dragTarget.removeEventListener('pointermove', onPointerMove);\n\n event.preventDefault();\n };\n\n const onPointerDown = (event: PointerEvent) => {\n setIsDragging(true);\n originalX = event.clientX;\n originalY = event.clientY;\n dragTarget.setPointerCapture(event.pointerId);\n dragTarget.addEventListener('pointerup', onPointerUp);\n dragTarget.addEventListener('pointermove', onPointerMove);\n event.preventDefault();\n };\n\n dragTarget.addEventListener('pointerdown', onPointerDown);\n\n return () => {\n dragTarget.removeEventListener('pointerdown', onPointerDown);\n dragTarget.removeEventListener('pointermove', onPointerMove);\n dragTarget.removeEventListener('pointerup', onPointerUp);\n };\n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