@shopify/cli-hydrogen 6.1.1 → 7.0.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.
- package/dist/commands/hydrogen/build.js +40 -78
- package/dist/commands/hydrogen/codegen.js +8 -3
- package/dist/commands/hydrogen/deploy.js +311 -21
- package/dist/commands/hydrogen/deploy.test.js +410 -0
- package/dist/commands/hydrogen/dev.js +30 -15
- package/dist/commands/hydrogen/init.js +1 -1
- package/dist/commands/hydrogen/init.test.js +155 -53
- package/dist/commands/hydrogen/link.js +5 -21
- package/dist/commands/hydrogen/link.test.js +10 -10
- package/dist/commands/hydrogen/preview.js +7 -6
- package/dist/commands/hydrogen/setup.js +17 -23
- package/dist/commands/hydrogen/setup.test.js +0 -1
- package/dist/commands/hydrogen/upgrade.js +15 -0
- package/dist/generator-templates/starter/.graphqlrc.yml +12 -1
- package/dist/generator-templates/starter/CHANGELOG.md +66 -0
- package/dist/generator-templates/starter/README.md +23 -0
- package/dist/generator-templates/starter/app/components/Cart.tsx +1 -1
- package/dist/generator-templates/starter/app/components/Header.tsx +5 -1
- package/dist/generator-templates/starter/app/components/Layout.tsx +1 -1
- package/dist/generator-templates/starter/app/components/Search.tsx +1 -1
- package/dist/generator-templates/starter/app/graphql/customer-account/CustomerAddressMutations.ts +61 -0
- package/dist/generator-templates/starter/app/graphql/customer-account/CustomerDetailsQuery.ts +39 -0
- package/dist/generator-templates/starter/app/graphql/customer-account/CustomerOrderQuery.ts +87 -0
- package/dist/generator-templates/starter/app/graphql/customer-account/CustomerOrdersQuery.ts +58 -0
- package/dist/generator-templates/starter/app/graphql/customer-account/CustomerUpdateMutation.ts +24 -0
- package/dist/generator-templates/starter/app/lib/fragments.ts +102 -0
- package/dist/generator-templates/starter/app/lib/session.ts +67 -0
- package/dist/generator-templates/starter/app/root.tsx +11 -45
- package/dist/generator-templates/starter/app/routes/account.$.tsx +8 -4
- package/dist/generator-templates/starter/app/routes/account._index.tsx +5 -0
- package/dist/generator-templates/starter/app/routes/account.addresses.tsx +215 -206
- package/dist/generator-templates/starter/app/routes/account.orders.$id.tsx +56 -163
- package/dist/generator-templates/starter/app/routes/account.orders._index.tsx +32 -109
- package/dist/generator-templates/starter/app/routes/account.profile.tsx +40 -180
- package/dist/generator-templates/starter/app/routes/account.tsx +20 -135
- package/dist/generator-templates/starter/app/routes/account_.authorize.tsx +5 -0
- package/dist/generator-templates/starter/app/routes/account_.login.tsx +3 -140
- package/dist/generator-templates/starter/app/routes/account_.logout.tsx +5 -24
- package/dist/generator-templates/starter/app/routes/cart.tsx +7 -5
- package/dist/generator-templates/starter/app/routes/collections.$handle.tsx +1 -1
- package/dist/generator-templates/starter/app/routes/products.$handle.tsx +2 -2
- package/dist/generator-templates/starter/app/routes/search.tsx +1 -1
- package/dist/generator-templates/starter/customer-accountapi.generated.d.ts +506 -0
- package/dist/generator-templates/starter/package.json +11 -11
- package/dist/generator-templates/starter/remix.config.js +4 -0
- package/dist/generator-templates/starter/remix.env.d.ts +8 -11
- package/dist/generator-templates/starter/server.ts +24 -167
- package/dist/generator-templates/starter/storefrontapi.generated.d.ts +104 -881
- package/dist/hooks/init.js +4 -4
- package/dist/lib/auth.js +5 -10
- package/dist/lib/build.js +6 -1
- package/dist/lib/bundle/analyzer.js +36 -26
- package/dist/lib/codegen.js +59 -26
- package/dist/lib/defer.js +12 -0
- package/dist/lib/file.js +55 -3
- package/dist/lib/flags.js +15 -8
- package/dist/lib/get-oxygen-deployment-data.test.js +4 -2
- package/dist/lib/graphiql-url.js +3 -0
- package/dist/lib/graphql/admin/client.test.js +2 -2
- package/dist/lib/graphql/admin/get-oxygen-data.js +1 -0
- package/dist/lib/log.js +31 -14
- package/dist/lib/mini-oxygen/assets.js +17 -1
- package/dist/lib/mini-oxygen/index.js +4 -5
- package/dist/lib/mini-oxygen/mini-oxygen.test.js +214 -0
- package/dist/lib/mini-oxygen/node.js +4 -2
- package/dist/lib/mini-oxygen/workerd-inspector-logs.js +2 -2
- package/dist/lib/mini-oxygen/workerd.js +27 -10
- package/dist/lib/missing-routes.js +6 -3
- package/dist/lib/onboarding/common.js +44 -12
- package/dist/lib/onboarding/local.js +26 -18
- package/dist/lib/onboarding/remote.js +50 -29
- package/dist/lib/request-events.js +65 -31
- package/dist/lib/setups/css/assets.js +1 -46
- package/dist/lib/setups/css/css-modules.js +3 -2
- package/dist/lib/setups/css/postcss.js +4 -2
- package/dist/lib/setups/css/tailwind.js +4 -2
- package/dist/lib/setups/css/vanilla-extract.js +3 -2
- package/dist/lib/setups/i18n/replacers.test.js +54 -38
- package/dist/lib/shell.js +1 -1
- package/dist/lib/template-diff.js +99 -0
- package/dist/lib/template-downloader.js +3 -2
- package/dist/lib/transpile/project.js +1 -1
- package/dist/virtual-routes/assets/debug-network.css +592 -0
- package/dist/virtual-routes/assets/favicon-dark.svg +20 -0
- package/dist/virtual-routes/components/FlameChartWrapper.jsx +8 -10
- package/dist/virtual-routes/components/IconClose.jsx +38 -0
- package/dist/virtual-routes/components/IconDiscard.jsx +44 -0
- package/dist/virtual-routes/components/RequestDetails.jsx +179 -0
- package/dist/virtual-routes/components/RequestTable.jsx +92 -0
- package/dist/virtual-routes/components/RequestWaterfall.jsx +151 -0
- package/dist/virtual-routes/lib/useDebugNetworkServer.jsx +176 -0
- package/dist/virtual-routes/routes/subrequest-profiler.jsx +243 -0
- package/oclif.manifest.json +54 -61
- package/package.json +15 -12
- package/dist/generator-templates/starter/app/routes/account_.activate.$id.$activationToken.tsx +0 -161
- package/dist/generator-templates/starter/app/routes/account_.recover.tsx +0 -129
- package/dist/generator-templates/starter/app/routes/account_.register.tsx +0 -207
- package/dist/generator-templates/starter/app/routes/account_.reset.$id.$resetToken.tsx +0 -136
- package/dist/virtual-routes/routes/debug-network.jsx +0 -289
- /package/dist/generator-templates/starter/app/{utils.ts → lib/variants.ts} +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="none">
|
|
2
|
+
<style>
|
|
3
|
+
.stroke {
|
|
4
|
+
stroke: #5c5f62;
|
|
5
|
+
}
|
|
6
|
+
.fill {
|
|
7
|
+
fill: #5c5f62;
|
|
8
|
+
}
|
|
9
|
+
</style>
|
|
10
|
+
<path
|
|
11
|
+
class="stroke"
|
|
12
|
+
fill-rule="evenodd"
|
|
13
|
+
d="M16.1 16.04 1 8.02 6.16 5.3l5.82 3.09 4.88-2.57-5.82-3.1L16.21 0l15.1 8.02-5.17 2.72-5.5-2.91-4.88 2.57 5.5 2.92-5.16 2.72Z"
|
|
14
|
+
/>
|
|
15
|
+
<path
|
|
16
|
+
class="fill"
|
|
17
|
+
fill-rule="evenodd"
|
|
18
|
+
d="M16.1 32 1 23.98l5.16-2.72 5.82 3.08 4.88-2.57-5.82-3.08 5.17-2.73 15.1 8.02-5.17 2.72-5.5-2.92-4.88 2.58 5.5 2.92L16.1 32Z"
|
|
19
|
+
/>
|
|
20
|
+
</svg>
|
|
@@ -8,7 +8,13 @@ const FlameChartWrapper = (props) => {
|
|
|
8
8
|
const flameChart = useRef(null);
|
|
9
9
|
useResizeObserver({
|
|
10
10
|
ref: boxRef,
|
|
11
|
-
onResize: ({ width = 0, height = 0 }) =>
|
|
11
|
+
onResize: ({ width = 0, height = 0 }) => {
|
|
12
|
+
if (props.onResize) {
|
|
13
|
+
props.onResize(flameChart.current, width, height);
|
|
14
|
+
} else {
|
|
15
|
+
flameChart.current?.resize(width, height - 3);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
12
18
|
});
|
|
13
19
|
const initialize = useCallback(() => {
|
|
14
20
|
const {
|
|
@@ -110,15 +116,7 @@ const FlameChartWrapper = (props) => {
|
|
|
110
116
|
}
|
|
111
117
|
};
|
|
112
118
|
}, [props.onSelect]);
|
|
113
|
-
return /* @__PURE__ */ jsx(
|
|
114
|
-
"div",
|
|
115
|
-
{
|
|
116
|
-
style: { height: `${props.height ? props.height : 300}px` },
|
|
117
|
-
className: props.className,
|
|
118
|
-
ref: setBoxRef,
|
|
119
|
-
children: /* @__PURE__ */ jsx("canvas", { ref: setCanvasRef })
|
|
120
|
-
}
|
|
121
|
-
);
|
|
119
|
+
return /* @__PURE__ */ jsx("div", { style: { height: `100%` }, className: props.className, ref: setBoxRef, children: /* @__PURE__ */ jsx("canvas", { ref: setCanvasRef }) });
|
|
122
120
|
};
|
|
123
121
|
export {
|
|
124
122
|
FlameChartWrapper
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
function IconClose(props) {
|
|
3
|
+
return /* @__PURE__ */ jsxs(
|
|
4
|
+
"svg",
|
|
5
|
+
{
|
|
6
|
+
width: "20px",
|
|
7
|
+
height: "20px",
|
|
8
|
+
...props,
|
|
9
|
+
stroke: props.stroke || "currentColor",
|
|
10
|
+
children: [
|
|
11
|
+
/* @__PURE__ */ jsx("title", { children: "Close" }),
|
|
12
|
+
/* @__PURE__ */ jsx(
|
|
13
|
+
"line",
|
|
14
|
+
{
|
|
15
|
+
x1: "4.44194",
|
|
16
|
+
y1: "4.30806",
|
|
17
|
+
x2: "15.7556",
|
|
18
|
+
y2: "15.6218",
|
|
19
|
+
strokeWidth: "1.25"
|
|
20
|
+
}
|
|
21
|
+
),
|
|
22
|
+
/* @__PURE__ */ jsx(
|
|
23
|
+
"line",
|
|
24
|
+
{
|
|
25
|
+
y1: "-0.625",
|
|
26
|
+
x2: "16",
|
|
27
|
+
y2: "-0.625",
|
|
28
|
+
transform: "matrix(-0.707107 0.707107 0.707107 0.707107 16 4.75)",
|
|
29
|
+
strokeWidth: "1.25"
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
IconClose
|
|
38
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
function IconDiscard(props) {
|
|
3
|
+
const fillColor = props.fill || "#333333";
|
|
4
|
+
return /* @__PURE__ */ jsxs(
|
|
5
|
+
"svg",
|
|
6
|
+
{
|
|
7
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
8
|
+
width: "20",
|
|
9
|
+
height: "20",
|
|
10
|
+
viewBox: "0 0 20 20",
|
|
11
|
+
fill: "none",
|
|
12
|
+
...props,
|
|
13
|
+
children: [
|
|
14
|
+
/* @__PURE__ */ jsx("title", { children: "Clear" }),
|
|
15
|
+
/* @__PURE__ */ jsx(
|
|
16
|
+
"path",
|
|
17
|
+
{
|
|
18
|
+
d: "M11.5 8.25C11.9142 8.25 12.25 8.58579 12.25 9V13.25C12.25 13.6642 11.9142 14 11.5 14C11.0858 14 10.75 13.6642 10.75 13.25V9C10.75 8.58579 11.0858 8.25 11.5 8.25Z",
|
|
19
|
+
fill: fillColor
|
|
20
|
+
}
|
|
21
|
+
),
|
|
22
|
+
/* @__PURE__ */ jsx(
|
|
23
|
+
"path",
|
|
24
|
+
{
|
|
25
|
+
d: "M9.25 9C9.25 8.58579 8.91421 8.25 8.5 8.25C8.08579 8.25 7.75 8.58579 7.75 9V13.25C7.75 13.6642 8.08579 14 8.5 14C8.91421 14 9.25 13.6642 9.25 13.25V9Z",
|
|
26
|
+
fill: fillColor
|
|
27
|
+
}
|
|
28
|
+
),
|
|
29
|
+
/* @__PURE__ */ jsx(
|
|
30
|
+
"path",
|
|
31
|
+
{
|
|
32
|
+
fillRule: "evenodd",
|
|
33
|
+
clipRule: "evenodd",
|
|
34
|
+
d: "M7.24994 5.25C7.24994 3.73122 8.48116 2.5 9.99994 2.5C11.5187 2.5 12.7499 3.73122 12.7499 5.25H15.75C16.1642 5.25 16.5 5.58579 16.5 6C16.5 6.41421 16.1642 6.75 15.75 6.75H14.9999L14.9998 12.2001C14.9998 13.8802 14.9997 14.7203 14.6728 15.362C14.3851 15.9265 13.9262 16.3854 13.3617 16.673C12.72 17 11.8799 17 10.1997 17H9.79999C8.11978 17 7.27968 17 6.63793 16.673C6.07343 16.3854 5.61448 15.9264 5.32687 15.3619C4.99989 14.7202 4.9999 13.8801 4.99994 12.1999L5.00005 6.75H4.25C3.83579 6.75 3.5 6.41421 3.5 6C3.5 5.58579 3.83579 5.25 4.25 5.25H7.24994ZM8.74994 5.25C8.74994 4.55964 9.30958 4 9.99994 4C10.6903 4 11.2499 4.55964 11.2499 5.25H8.74994ZM6.50007 6.75H13.4999L13.4998 12.2001C13.4998 13.0649 13.4986 13.6233 13.4639 14.0483C13.4305 14.4558 13.374 14.6068 13.3362 14.681C13.1924 14.9632 12.963 15.1927 12.6807 15.3365C12.6065 15.3743 12.4555 15.4308 12.048 15.4641C11.623 15.4988 11.0646 15.5 10.1997 15.5H9.79999C8.93513 15.5 8.37671 15.4988 7.95169 15.4641C7.54418 15.4308 7.3931 15.3743 7.31893 15.3365C7.03668 15.1927 6.80721 14.9632 6.6634 14.681C6.62561 14.6068 6.56909 14.4557 6.53581 14.0482C6.50109 13.6232 6.49994 13.0648 6.49995 12.1999L6.50007 6.75Z",
|
|
35
|
+
fill: fillColor
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
IconDiscard
|
|
44
|
+
};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef } from "react";
|
|
3
|
+
import { Link } from "@remix-run/react";
|
|
4
|
+
import { IconClose } from "./IconClose.jsx";
|
|
5
|
+
import _useResizeObserver from "use-resize-observer";
|
|
6
|
+
const useResizeObserver = _useResizeObserver;
|
|
7
|
+
const TABS = {
|
|
8
|
+
1: "General",
|
|
9
|
+
2: "Headers",
|
|
10
|
+
3: "Cache",
|
|
11
|
+
4: "Data"
|
|
12
|
+
};
|
|
13
|
+
function RequestDetails({
|
|
14
|
+
serverEvents,
|
|
15
|
+
activeEventId,
|
|
16
|
+
setActiveEventId
|
|
17
|
+
}) {
|
|
18
|
+
const [activeTab, setActiveTab] = useState(1);
|
|
19
|
+
if (!activeEventId) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const requestInfo = serverEvents.allRequests[activeEventId];
|
|
23
|
+
if (!requestInfo) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
function activeTabClass(tab) {
|
|
27
|
+
return activeTab === tab ? " active" : "";
|
|
28
|
+
}
|
|
29
|
+
function TabButton(key) {
|
|
30
|
+
return /* @__PURE__ */ jsx(
|
|
31
|
+
"div",
|
|
32
|
+
{
|
|
33
|
+
tabIndex: 0,
|
|
34
|
+
className: `tab${activeTabClass(key)}`,
|
|
35
|
+
onClick: () => setActiveTab(key),
|
|
36
|
+
onKeyUp: (event) => {
|
|
37
|
+
if (event.code === "Space")
|
|
38
|
+
setActiveTab(key);
|
|
39
|
+
},
|
|
40
|
+
children: TABS[key]
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
return /* @__PURE__ */ jsxs("div", { id: "request-detail", children: [
|
|
45
|
+
/* @__PURE__ */ jsxs("div", { id: "request-detail-header", children: [
|
|
46
|
+
/* @__PURE__ */ jsxs(TabButtonsBar, { children: [
|
|
47
|
+
TabButton(1),
|
|
48
|
+
!!requestInfo.responseInit?.headers && TabButton(2),
|
|
49
|
+
!!requestInfo.cache && TabButton(3),
|
|
50
|
+
!!requestInfo.responsePayload && TabButton(4)
|
|
51
|
+
] }),
|
|
52
|
+
/* @__PURE__ */ jsx("div", { id: "close-request-detail", children: /* @__PURE__ */ jsx(
|
|
53
|
+
"button",
|
|
54
|
+
{
|
|
55
|
+
className: "plain icon",
|
|
56
|
+
onClick: () => {
|
|
57
|
+
setActiveEventId(void 0);
|
|
58
|
+
},
|
|
59
|
+
children: /* @__PURE__ */ jsx(IconClose, {})
|
|
60
|
+
}
|
|
61
|
+
) })
|
|
62
|
+
] }),
|
|
63
|
+
/* @__PURE__ */ jsxs("div", { className: "tabPanels pad", children: [
|
|
64
|
+
/* @__PURE__ */ jsx("div", { id: "tab1-panel", className: `tabPanel${activeTabClass(1)}`, children: /* @__PURE__ */ jsxs("div", { className: "grid-layout", children: [
|
|
65
|
+
/* @__PURE__ */ jsx(DetailsRow, { rowName: "Name", value: requestInfo.displayName }),
|
|
66
|
+
/* @__PURE__ */ jsx(DetailsRow, { rowName: "Request URL", value: requestInfo.url }),
|
|
67
|
+
requestInfo.responseInit ? /* @__PURE__ */ jsx(
|
|
68
|
+
DetailsRow,
|
|
69
|
+
{
|
|
70
|
+
rowName: "Status",
|
|
71
|
+
value: `${requestInfo.responseInit?.status} ${requestInfo.responseInit?.statusText}`
|
|
72
|
+
}
|
|
73
|
+
) : null,
|
|
74
|
+
/* @__PURE__ */ jsx(
|
|
75
|
+
DetailsRow,
|
|
76
|
+
{
|
|
77
|
+
rowName: "GraphiQL",
|
|
78
|
+
value: requestInfo.graphiqlLink,
|
|
79
|
+
type: "url"
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
/* @__PURE__ */ jsx(
|
|
83
|
+
DetailsRow,
|
|
84
|
+
{
|
|
85
|
+
rowName: "Location",
|
|
86
|
+
text: requestInfo.stackLine,
|
|
87
|
+
value: requestInfo.stackLink,
|
|
88
|
+
type: "url"
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
] }) }),
|
|
92
|
+
!!requestInfo.responseInit?.headers && /* @__PURE__ */ jsx("div", { id: "tab2-panel", className: `tabPanel${activeTabClass(2)}`, children: /* @__PURE__ */ jsx("div", { className: "grid-layout", children: Object.entries(requestInfo.responseInit?.headers).map(
|
|
93
|
+
([key, value]) => /* @__PURE__ */ jsx(DetailsRow, { rowName: value[0], value: value[1] }, key)
|
|
94
|
+
) }) }),
|
|
95
|
+
!!requestInfo.cache && /* @__PURE__ */ jsx("div", { id: "tab3-panel", className: `tabPanel${activeTabClass(3)}`, children: /* @__PURE__ */ jsxs("div", { className: "grid-layout", children: [
|
|
96
|
+
/* @__PURE__ */ jsx(DetailsRow, { rowName: "Status", value: requestInfo.cache?.status }),
|
|
97
|
+
/* @__PURE__ */ jsx(
|
|
98
|
+
DetailsRow,
|
|
99
|
+
{
|
|
100
|
+
rowName: "Cache-Control",
|
|
101
|
+
value: requestInfo.cache?.strategy
|
|
102
|
+
}
|
|
103
|
+
),
|
|
104
|
+
/* @__PURE__ */ jsx(
|
|
105
|
+
DetailsRow,
|
|
106
|
+
{
|
|
107
|
+
rowName: "Cache Key",
|
|
108
|
+
value: requestInfo.cache?.key?.toString()
|
|
109
|
+
}
|
|
110
|
+
)
|
|
111
|
+
] }) }),
|
|
112
|
+
!!requestInfo.responsePayload && /* @__PURE__ */ jsx("div", { id: "tab4-panel", className: `tabPanel${activeTabClass(4)}`, children: /* @__PURE__ */ jsx("pre", { className: "code-json", children: JSON.stringify(requestInfo.responsePayload, void 0, 2) }) })
|
|
113
|
+
] })
|
|
114
|
+
] });
|
|
115
|
+
}
|
|
116
|
+
function TabButtonsBar({ children }) {
|
|
117
|
+
const [fadeClass, setFadeClass] = useState("");
|
|
118
|
+
const scrollBarRef = useRef(null);
|
|
119
|
+
useResizeObserver({
|
|
120
|
+
ref: scrollBarRef,
|
|
121
|
+
onResize: () => {
|
|
122
|
+
if (scrollBarRef.current) {
|
|
123
|
+
setFade(scrollBarRef.current);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
function setFade(target) {
|
|
128
|
+
if (target.scrollWidth === target.clientWidth) {
|
|
129
|
+
setFadeClass("");
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const scrollRange = target.scrollWidth - target.clientWidth;
|
|
133
|
+
if (target.scrollLeft > 10 && target.scrollLeft < scrollRange - 10) {
|
|
134
|
+
setFadeClass("fadeLeftRight");
|
|
135
|
+
} else if (target.scrollLeft <= 10) {
|
|
136
|
+
setFadeClass("fadeRight");
|
|
137
|
+
} else if (target.scrollLeft > scrollRange - 10) {
|
|
138
|
+
setFadeClass("fadeLeft");
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return /* @__PURE__ */ jsxs(
|
|
142
|
+
"div",
|
|
143
|
+
{
|
|
144
|
+
id: "tab-buttons-wrapper",
|
|
145
|
+
onResize: (event) => setFade(event.currentTarget),
|
|
146
|
+
children: [
|
|
147
|
+
/* @__PURE__ */ jsx(
|
|
148
|
+
"div",
|
|
149
|
+
{
|
|
150
|
+
id: "tabButtons",
|
|
151
|
+
ref: scrollBarRef,
|
|
152
|
+
className: "flex-row gap-tiny",
|
|
153
|
+
onScroll: (event) => setFade(event.currentTarget),
|
|
154
|
+
children
|
|
155
|
+
}
|
|
156
|
+
),
|
|
157
|
+
/* @__PURE__ */ jsx("div", { className: `fadCover ${fadeClass}` })
|
|
158
|
+
]
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
function DetailsRow({
|
|
163
|
+
rowName,
|
|
164
|
+
value,
|
|
165
|
+
text,
|
|
166
|
+
type = "string"
|
|
167
|
+
}) {
|
|
168
|
+
if (!rowName || !value) {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
172
|
+
/* @__PURE__ */ jsx("div", { className: "gridTitle", children: rowName }),
|
|
173
|
+
type === "url" && /* @__PURE__ */ jsx(Link, { target: "_blank", to: value, children: text ?? value }),
|
|
174
|
+
type === "string" && /* @__PURE__ */ jsx("div", { className: "word-break-all", children: text ?? value })
|
|
175
|
+
] });
|
|
176
|
+
}
|
|
177
|
+
export {
|
|
178
|
+
RequestDetails
|
|
179
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import {
|
|
4
|
+
buildRequestData
|
|
5
|
+
} from "../lib/useDebugNetworkServer.jsx";
|
|
6
|
+
function RequestTable({
|
|
7
|
+
serverEvents,
|
|
8
|
+
activeEventId,
|
|
9
|
+
setActiveEventId
|
|
10
|
+
}) {
|
|
11
|
+
let totalMainRequests = 0;
|
|
12
|
+
let totalSubRequest = 0;
|
|
13
|
+
const items = buildRequestData({
|
|
14
|
+
serverEvents,
|
|
15
|
+
buildMainRequest: (mainRequest, timing) => {
|
|
16
|
+
totalMainRequests++;
|
|
17
|
+
return {
|
|
18
|
+
id: mainRequest.id,
|
|
19
|
+
requestId: mainRequest.requestId,
|
|
20
|
+
url: mainRequest.url,
|
|
21
|
+
status: mainRequest.responseInit?.status ?? 0,
|
|
22
|
+
cacheStatus: mainRequest.cacheStatus,
|
|
23
|
+
duration: timing.responseEnd - timing.requestStart
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
buildSubRequest: (subRequest, timing) => {
|
|
27
|
+
if (serverEvents.hidePutRequests) {
|
|
28
|
+
subRequest.cacheStatus !== "PUT" && totalSubRequest++;
|
|
29
|
+
} else {
|
|
30
|
+
totalSubRequest++;
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
id: subRequest.id,
|
|
34
|
+
requestId: subRequest.requestId,
|
|
35
|
+
url: subRequest.displayName ?? subRequest.url,
|
|
36
|
+
status: subRequest.responseInit?.status ?? 0,
|
|
37
|
+
cacheStatus: subRequest.cacheStatus,
|
|
38
|
+
duration: timing.requestEnd - timing.requestStart
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (!serverEvents.preserveLog && activeEventId) {
|
|
44
|
+
const selectedItem = items.find((item) => item.id === activeEventId);
|
|
45
|
+
if (!selectedItem) {
|
|
46
|
+
setActiveEventId(void 0);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}, [serverEvents.preserveLog]);
|
|
50
|
+
return /* @__PURE__ */ jsx("div", { id: "request-table", children: /* @__PURE__ */ jsxs("div", { children: [
|
|
51
|
+
/* @__PURE__ */ jsxs("div", { id: "request-table__header", className: "grid-row", children: [
|
|
52
|
+
/* @__PURE__ */ jsx("div", { className: "grid-cell", children: "Name" }),
|
|
53
|
+
/* @__PURE__ */ jsx("div", { className: "grid-cell", children: "Cache" }),
|
|
54
|
+
/* @__PURE__ */ jsx("div", { className: "grid-cell", children: "Time" })
|
|
55
|
+
] }),
|
|
56
|
+
/* @__PURE__ */ jsx("div", { id: "request-table__content", children: items.map((row) => /* @__PURE__ */ jsxs(
|
|
57
|
+
"div",
|
|
58
|
+
{
|
|
59
|
+
id: `request-table__row-${row.id}`,
|
|
60
|
+
tabIndex: 0,
|
|
61
|
+
className: `grid-row${activeEventId === row.id ? " active" : ""}${row.status >= 400 ? " error" : ""}`,
|
|
62
|
+
onClick: () => setActiveEventId(row.id),
|
|
63
|
+
onKeyUp: (event) => {
|
|
64
|
+
if (event.code === "Space")
|
|
65
|
+
setActiveEventId(row.id);
|
|
66
|
+
},
|
|
67
|
+
children: [
|
|
68
|
+
/* @__PURE__ */ jsx("div", { className: "grid-cell", children: row.url }),
|
|
69
|
+
/* @__PURE__ */ jsx("div", { className: "grid-cell", children: row.cacheStatus }),
|
|
70
|
+
/* @__PURE__ */ jsxs("div", { className: "grid-cell", children: [
|
|
71
|
+
row.duration,
|
|
72
|
+
"ms"
|
|
73
|
+
] })
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
row.id
|
|
77
|
+
)) }),
|
|
78
|
+
/* @__PURE__ */ jsxs("div", { id: "request-table__footer", children: [
|
|
79
|
+
totalMainRequests,
|
|
80
|
+
" request",
|
|
81
|
+
totalMainRequests > 1 ? "s" : "",
|
|
82
|
+
" |",
|
|
83
|
+
" ",
|
|
84
|
+
totalSubRequest,
|
|
85
|
+
" sub request",
|
|
86
|
+
totalSubRequest > 1 ? "s" : ""
|
|
87
|
+
] })
|
|
88
|
+
] }) });
|
|
89
|
+
}
|
|
90
|
+
export {
|
|
91
|
+
RequestTable
|
|
92
|
+
};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { FlameChartWrapper } from "./FlameChartWrapper.jsx";
|
|
4
|
+
import {
|
|
5
|
+
buildRequestData
|
|
6
|
+
} from "../lib/useDebugNetworkServer.jsx";
|
|
7
|
+
const STYLE_FONT = "10px Inter, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Open Sans, Helvetica Neue, sans-serif";
|
|
8
|
+
let resizeTimeout;
|
|
9
|
+
function RequestWaterfall({
|
|
10
|
+
serverEvents,
|
|
11
|
+
config
|
|
12
|
+
}) {
|
|
13
|
+
const items = buildRequestData({
|
|
14
|
+
serverEvents,
|
|
15
|
+
buildMainRequest: (mainRequest, timing) => {
|
|
16
|
+
return {
|
|
17
|
+
name: mainRequest.url,
|
|
18
|
+
intervals: "mainRequest",
|
|
19
|
+
timing,
|
|
20
|
+
meta: [
|
|
21
|
+
{
|
|
22
|
+
name: "id",
|
|
23
|
+
value: mainRequest.id,
|
|
24
|
+
color: "black"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
buildSubRequest: (subRequest, timing) => {
|
|
30
|
+
return {
|
|
31
|
+
name: `${subRequest.cacheStatus} ${subRequest.displayName ?? subRequest.url}`.trim(),
|
|
32
|
+
intervals: "request",
|
|
33
|
+
timing,
|
|
34
|
+
meta: [
|
|
35
|
+
{
|
|
36
|
+
name: "id",
|
|
37
|
+
value: subRequest.id,
|
|
38
|
+
color: "black"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
const data = {
|
|
45
|
+
items: [
|
|
46
|
+
{
|
|
47
|
+
// Workaround a bug in flame-chart-js where the first item onSelect is not triggered
|
|
48
|
+
name: "padding-request",
|
|
49
|
+
intervals: "request",
|
|
50
|
+
timing: {
|
|
51
|
+
requestStart: 0,
|
|
52
|
+
responseStart: 0,
|
|
53
|
+
responseEnd: 0,
|
|
54
|
+
requestEnd: -1
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
...items
|
|
58
|
+
],
|
|
59
|
+
intervals: {
|
|
60
|
+
mainRequest: [
|
|
61
|
+
{
|
|
62
|
+
name: "server",
|
|
63
|
+
color: config.colors.server,
|
|
64
|
+
type: "block",
|
|
65
|
+
start: "requestStart",
|
|
66
|
+
end: "responseStart"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "streaming",
|
|
70
|
+
color: config.colors.streaming,
|
|
71
|
+
type: "block",
|
|
72
|
+
start: "responseStart",
|
|
73
|
+
end: "responseEnd"
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
request: [
|
|
77
|
+
{
|
|
78
|
+
name: "request",
|
|
79
|
+
color: config.colors.subRequest,
|
|
80
|
+
type: "block",
|
|
81
|
+
start: "requestStart",
|
|
82
|
+
end: "requestEnd"
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const onSelect = (data2) => {
|
|
88
|
+
const eventIdMeta = data2?.node?.meta?.filter(
|
|
89
|
+
(meta) => meta.name === "id"
|
|
90
|
+
)?.[0];
|
|
91
|
+
if (eventIdMeta) {
|
|
92
|
+
setTimeout(() => {
|
|
93
|
+
window.setActiveEventId && window.setActiveEventId(eventIdMeta.value);
|
|
94
|
+
document.querySelector(`#request-table__row-${eventIdMeta.value}`)?.scrollIntoView();
|
|
95
|
+
}, 0);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const settings = useMemo(
|
|
99
|
+
() => ({
|
|
100
|
+
options: {
|
|
101
|
+
tooltip: () => {
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
styles: {
|
|
105
|
+
main: {
|
|
106
|
+
blockHeight: 22,
|
|
107
|
+
font: STYLE_FONT,
|
|
108
|
+
tooltipShadowBlur: 1
|
|
109
|
+
},
|
|
110
|
+
timeframeSelectorPlugin: {
|
|
111
|
+
font: STYLE_FONT,
|
|
112
|
+
waterfallStrokeOpacity: 1,
|
|
113
|
+
waterfallFillOpacity: 0.1
|
|
114
|
+
},
|
|
115
|
+
timeGridPlugin: {
|
|
116
|
+
font: STYLE_FONT
|
|
117
|
+
},
|
|
118
|
+
waterfallPlugin: {
|
|
119
|
+
defaultHeight: 500
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}),
|
|
123
|
+
[]
|
|
124
|
+
);
|
|
125
|
+
return /* @__PURE__ */ jsx(
|
|
126
|
+
FlameChartWrapper,
|
|
127
|
+
{
|
|
128
|
+
waterfall: data,
|
|
129
|
+
onSelect,
|
|
130
|
+
settings,
|
|
131
|
+
onResize: (flameChart, width, height) => {
|
|
132
|
+
flameChart?.setSettings({
|
|
133
|
+
...settings,
|
|
134
|
+
styles: {
|
|
135
|
+
...settings.styles,
|
|
136
|
+
waterfallPlugin: {
|
|
137
|
+
defaultHeight: height
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
clearTimeout(resizeTimeout);
|
|
142
|
+
resizeTimeout = setTimeout(() => {
|
|
143
|
+
flameChart?.resize(width, height);
|
|
144
|
+
}, 50);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
export {
|
|
150
|
+
RequestWaterfall
|
|
151
|
+
};
|