astro 3.3.4 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/astro.d.ts +34 -0
- package/dist/assets/build/generate.d.ts +20 -16
- package/dist/assets/build/generate.js +125 -72
- package/dist/assets/types.d.ts +5 -4
- package/dist/assets/vite-plugin-assets.js +15 -7
- package/dist/cli/add/babel.d.ts +1 -1
- package/dist/core/build/generate.js +21 -33
- package/dist/core/config/schema.d.ts +14 -0
- package/dist/core/config/schema.js +4 -2
- package/dist/core/config/settings.js +1 -0
- package/dist/core/constants.js +1 -1
- package/dist/core/create-vite.js +3 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/render/core.js +1 -0
- package/dist/core/render/result.d.ts +1 -0
- package/dist/core/render/result.js +1 -0
- package/dist/integrations/index.js +3 -10
- package/dist/runtime/client/dev-overlay/overlay.d.ts +1 -0
- package/dist/runtime/client/dev-overlay/overlay.js +446 -0
- package/dist/runtime/client/dev-overlay/plugins/astro.d.ts +7 -0
- package/dist/runtime/client/dev-overlay/plugins/astro.js +66 -0
- package/dist/runtime/client/dev-overlay/plugins/audit.d.ts +7 -0
- package/dist/runtime/client/dev-overlay/plugins/audit.js +75 -0
- package/dist/runtime/client/dev-overlay/plugins/utils/highlight.d.ts +5 -0
- package/dist/runtime/client/dev-overlay/plugins/utils/highlight.js +39 -0
- package/dist/runtime/client/dev-overlay/plugins/xray.d.ts +7 -0
- package/dist/runtime/client/dev-overlay/plugins/xray.js +75 -0
- package/dist/runtime/client/dev-overlay/ui-library/card.d.ts +9 -0
- package/dist/runtime/client/dev-overlay/ui-library/card.js +67 -0
- package/dist/runtime/client/dev-overlay/ui-library/highlight.d.ts +7 -0
- package/dist/runtime/client/dev-overlay/ui-library/highlight.js +60 -0
- package/dist/runtime/client/dev-overlay/ui-library/icons.d.ts +10 -0
- package/dist/runtime/client/dev-overlay/ui-library/icons.js +21 -0
- package/dist/runtime/client/dev-overlay/ui-library/tooltip.d.ts +16 -0
- package/dist/runtime/client/dev-overlay/ui-library/tooltip.js +132 -0
- package/dist/runtime/client/dev-overlay/ui-library/window.d.ts +9 -0
- package/dist/runtime/client/dev-overlay/ui-library/window.js +70 -0
- package/dist/runtime/server/render/astro/render.js +2 -2
- package/dist/runtime/server/render/common.js +2 -2
- package/dist/runtime/server/render/component.js +1 -1
- package/dist/type-utils.d.ts +1 -0
- package/dist/vite-plugin-astro-server/route.js +17 -1
- package/dist/vite-plugin-dev-overlay/vite-plugin-dev-overlay.d.ts +3 -0
- package/dist/vite-plugin-dev-overlay/vite-plugin-dev-overlay.js +24 -0
- package/package.json +2 -1
package/dist/core/create-vite.js
CHANGED
|
@@ -13,6 +13,7 @@ import astroPostprocessVitePlugin from "../vite-plugin-astro-postprocess/index.j
|
|
|
13
13
|
import { vitePluginAstroServer } from "../vite-plugin-astro-server/index.js";
|
|
14
14
|
import astroVitePlugin from "../vite-plugin-astro/index.js";
|
|
15
15
|
import configAliasVitePlugin from "../vite-plugin-config-alias/index.js";
|
|
16
|
+
import astroDevOverlay from "../vite-plugin-dev-overlay/vite-plugin-dev-overlay.js";
|
|
16
17
|
import envVitePlugin from "../vite-plugin-env/index.js";
|
|
17
18
|
import astroHeadPlugin from "../vite-plugin-head/index.js";
|
|
18
19
|
import htmlVitePlugin from "../vite-plugin-html/index.js";
|
|
@@ -105,7 +106,8 @@ async function createVite(commandConfig, { settings, logger, mode, command, fs =
|
|
|
105
106
|
astroContentAssetPropagationPlugin({ mode, settings }),
|
|
106
107
|
vitePluginSSRManifest(),
|
|
107
108
|
astroAssetsPlugin({ settings, logger, mode }),
|
|
108
|
-
astroTransitions()
|
|
109
|
+
astroTransitions(),
|
|
110
|
+
astroDevOverlay({ settings, logger })
|
|
109
111
|
],
|
|
110
112
|
publicDir: fileURLToPath(settings.config.publicDir),
|
|
111
113
|
root: fileURLToPath(settings.config.root),
|
package/dist/core/dev/dev.js
CHANGED
|
@@ -20,7 +20,7 @@ async function dev(inlineConfig) {
|
|
|
20
20
|
base: restart.container.settings.config.base
|
|
21
21
|
})
|
|
22
22
|
);
|
|
23
|
-
const currentVersion = "3.
|
|
23
|
+
const currentVersion = "3.4.0";
|
|
24
24
|
if (currentVersion.includes("-")) {
|
|
25
25
|
logger.warn(null, msg.prerelease({ currentVersion }));
|
|
26
26
|
}
|
package/dist/core/messages.js
CHANGED
|
@@ -50,7 +50,7 @@ function serverStart({
|
|
|
50
50
|
base,
|
|
51
51
|
isRestart = false
|
|
52
52
|
}) {
|
|
53
|
-
const version = "3.
|
|
53
|
+
const version = "3.4.0";
|
|
54
54
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
55
55
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
56
56
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -235,7 +235,7 @@ function printHelp({
|
|
|
235
235
|
message.push(
|
|
236
236
|
linebreak(),
|
|
237
237
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
238
|
-
`v${"3.
|
|
238
|
+
`v${"3.4.0"}`
|
|
239
239
|
)} ${headline}`
|
|
240
240
|
);
|
|
241
241
|
}
|
package/dist/core/render/core.js
CHANGED
|
@@ -29,6 +29,7 @@ async function renderPage({ mod, renderContext, env, cookies }) {
|
|
|
29
29
|
clientDirectives: env.clientDirectives,
|
|
30
30
|
compressHTML: env.compressHTML,
|
|
31
31
|
request: renderContext.request,
|
|
32
|
+
partial: !!mod.partial,
|
|
32
33
|
site: env.site,
|
|
33
34
|
scripts: renderContext.scripts,
|
|
34
35
|
ssr: env.ssr,
|
|
@@ -96,6 +96,7 @@ function createResult(args) {
|
|
|
96
96
|
renderers: args.renderers,
|
|
97
97
|
clientDirectives: args.clientDirectives,
|
|
98
98
|
compressHTML: args.compressHTML,
|
|
99
|
+
partial: args.partial,
|
|
99
100
|
pathname: args.pathname,
|
|
100
101
|
cookies,
|
|
101
102
|
/** This function returns the `Astro` faux-global */
|
|
@@ -83,6 +83,9 @@ async function runHookConfigSetup({
|
|
|
83
83
|
addWatchFile: (path) => {
|
|
84
84
|
updatedSettings.watchFiles.push(path instanceof URL ? fileURLToPath(path) : path);
|
|
85
85
|
},
|
|
86
|
+
addDevOverlayPlugin: (entrypoint) => {
|
|
87
|
+
updatedSettings.devOverlayPlugins.push(entrypoint);
|
|
88
|
+
},
|
|
86
89
|
addClientDirective: ({ name, entrypoint }) => {
|
|
87
90
|
if (updatedSettings.clientDirectives.has(name) || addedClientDirectives.has(name)) {
|
|
88
91
|
throw new Error(
|
|
@@ -160,16 +163,6 @@ async function runHookConfigDone({
|
|
|
160
163
|
);
|
|
161
164
|
}
|
|
162
165
|
}
|
|
163
|
-
if (!validationResult.assets) {
|
|
164
|
-
logger.warn(
|
|
165
|
-
"astro",
|
|
166
|
-
`The selected adapter ${adapter.name} does not support image optimization. To allow your project to build with the original, unoptimized images, the image service has been automatically switched to the 'noop' option. See https://docs.astro.build/en/reference/configuration-reference/#imageservice`
|
|
167
|
-
);
|
|
168
|
-
settings.config.image.service = {
|
|
169
|
-
entrypoint: "astro/assets/services/noop",
|
|
170
|
-
config: {}
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
166
|
}
|
|
174
167
|
settings.adapter = adapter;
|
|
175
168
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
import { loadDevOverlayPlugins } from "astro:dev-overlay";
|
|
2
|
+
import astroDevToolPlugin from "./plugins/astro.js";
|
|
3
|
+
import astroAuditPlugin from "./plugins/audit.js";
|
|
4
|
+
import astroXrayPlugin from "./plugins/xray.js";
|
|
5
|
+
import { DevOverlayCard } from "./ui-library/card.js";
|
|
6
|
+
import { DevOverlayHighlight } from "./ui-library/highlight.js";
|
|
7
|
+
import { getIconElement, isDefinedIcon } from "./ui-library/icons.js";
|
|
8
|
+
import { DevOverlayTooltip } from "./ui-library/tooltip.js";
|
|
9
|
+
import { DevOverlayWindow } from "./ui-library/window.js";
|
|
10
|
+
document.addEventListener("DOMContentLoaded", async () => {
|
|
11
|
+
const WS_EVENT_NAME = "astro-dev-overlay";
|
|
12
|
+
const HOVER_DELAY = 750;
|
|
13
|
+
const builtinPlugins = [
|
|
14
|
+
astroDevToolPlugin,
|
|
15
|
+
astroXrayPlugin,
|
|
16
|
+
astroAuditPlugin
|
|
17
|
+
].map((plugin) => ({
|
|
18
|
+
...plugin,
|
|
19
|
+
active: false,
|
|
20
|
+
status: "loading",
|
|
21
|
+
eventTarget: new EventTarget()
|
|
22
|
+
}));
|
|
23
|
+
const customPluginsImports = await loadDevOverlayPlugins();
|
|
24
|
+
const customPlugins = [];
|
|
25
|
+
customPlugins.push(
|
|
26
|
+
...customPluginsImports.map((plugin) => ({
|
|
27
|
+
...plugin,
|
|
28
|
+
active: false,
|
|
29
|
+
status: "loading",
|
|
30
|
+
eventTarget: new EventTarget()
|
|
31
|
+
}))
|
|
32
|
+
);
|
|
33
|
+
const plugins = [...builtinPlugins, ...customPlugins];
|
|
34
|
+
for (const plugin of plugins) {
|
|
35
|
+
plugin.eventTarget.addEventListener("plugin-notification", (evt) => {
|
|
36
|
+
const target = overlay.shadowRoot?.querySelector(`[data-plugin-id="${plugin.id}"]`);
|
|
37
|
+
if (!target)
|
|
38
|
+
return;
|
|
39
|
+
let newState = true;
|
|
40
|
+
if (evt instanceof CustomEvent) {
|
|
41
|
+
newState = evt.detail.state ?? true;
|
|
42
|
+
}
|
|
43
|
+
target.querySelector(".notification")?.toggleAttribute("data-active", newState);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
class AstroDevOverlay extends HTMLElement {
|
|
47
|
+
shadowRoot;
|
|
48
|
+
hoverTimeout;
|
|
49
|
+
isHidden = () => this.devOverlay?.hasAttribute("data-hidden") ?? true;
|
|
50
|
+
devOverlay;
|
|
51
|
+
constructor() {
|
|
52
|
+
super();
|
|
53
|
+
this.shadowRoot = this.attachShadow({ mode: "closed" });
|
|
54
|
+
}
|
|
55
|
+
// connect component
|
|
56
|
+
async connectedCallback() {
|
|
57
|
+
this.shadowRoot.innerHTML = `
|
|
58
|
+
<style>
|
|
59
|
+
#dev-overlay {
|
|
60
|
+
position: fixed;
|
|
61
|
+
bottom: 7.5%;
|
|
62
|
+
left: calc(50% + 32px);
|
|
63
|
+
transform: translate(-50%, 0%);
|
|
64
|
+
z-index: 999999;
|
|
65
|
+
display: flex;
|
|
66
|
+
gap: 8px;
|
|
67
|
+
align-items: center;
|
|
68
|
+
transition: bottom 0.2s ease-in-out;
|
|
69
|
+
pointer-events: none;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
#dev-overlay[data-hidden] {
|
|
73
|
+
bottom: -40px;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
#dev-overlay[data-hidden]:hover, #dev-overlay[data-hidden]:focus-within {
|
|
77
|
+
bottom: -35px;
|
|
78
|
+
cursor: pointer;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
#dev-overlay[data-hidden] #minimize-button {
|
|
82
|
+
visibility: hidden;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
#dev-bar {
|
|
86
|
+
height: 56px;
|
|
87
|
+
overflow: hidden;
|
|
88
|
+
pointer-events: auto;
|
|
89
|
+
|
|
90
|
+
background: linear-gradient(180deg, #13151A 0%, rgba(19, 21, 26, 0.88) 100%);
|
|
91
|
+
box-shadow: 0px 0px 0px 0px #13151A4D;
|
|
92
|
+
border: 1px solid #343841;
|
|
93
|
+
border-radius: 9999px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
#dev-bar .item {
|
|
97
|
+
display: flex;
|
|
98
|
+
justify-content: center;
|
|
99
|
+
align-items: center;
|
|
100
|
+
width: 64px;
|
|
101
|
+
border: 0;
|
|
102
|
+
background: transparent;
|
|
103
|
+
color: white;
|
|
104
|
+
font-family: system-ui, sans-serif;
|
|
105
|
+
font-size: 1rem;
|
|
106
|
+
line-height: 1.2;
|
|
107
|
+
white-space: nowrap;
|
|
108
|
+
text-decoration: none;
|
|
109
|
+
padding: 0;
|
|
110
|
+
margin: 0;
|
|
111
|
+
overflow: hidden;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
#dev-bar #bar-container .item:hover, #dev-bar #bar-container .item:focus {
|
|
115
|
+
background: rgba(27, 30, 36, 1);
|
|
116
|
+
cursor: pointer;
|
|
117
|
+
outline-offset: -3px;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
#dev-bar .item:first-of-type {
|
|
121
|
+
border-top-left-radius: 9999px;
|
|
122
|
+
border-bottom-left-radius: 9999px;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
#dev-bar .item:last-of-type {
|
|
126
|
+
border-top-right-radius: 9999px;
|
|
127
|
+
border-bottom-right-radius: 9999px;
|
|
128
|
+
}
|
|
129
|
+
#dev-bar #bar-container .item.active {
|
|
130
|
+
background: rgba(71, 78, 94, 1);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
#dev-bar #bar-container .item.active .notification {
|
|
134
|
+
border-color: rgba(71, 78, 94, 1);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
#dev-bar .item .icon {
|
|
138
|
+
position: relative;
|
|
139
|
+
max-width: 24px;
|
|
140
|
+
max-height: 24px;
|
|
141
|
+
user-select: none;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
#dev-bar .item svg {
|
|
145
|
+
width: 24px;
|
|
146
|
+
height: 24px;
|
|
147
|
+
display: block;
|
|
148
|
+
margin: auto;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
#dev-bar .item .notification {
|
|
152
|
+
display: none;
|
|
153
|
+
position: absolute;
|
|
154
|
+
top: -2px;
|
|
155
|
+
right: 0;
|
|
156
|
+
width: 8px;
|
|
157
|
+
height: 8px;
|
|
158
|
+
border-radius: 9999px;
|
|
159
|
+
border: 1px solid rgba(19, 21, 26, 1);
|
|
160
|
+
background: #B33E66;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
#dev-bar .item .notification[data-active] {
|
|
164
|
+
display: block;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
#dev-bar #bar-container {
|
|
168
|
+
height: 100%;
|
|
169
|
+
display: flex;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
#dev-bar .separator {
|
|
173
|
+
background: rgba(52, 56, 65, 1);
|
|
174
|
+
width: 1px;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
astro-overlay-plugin-canvas {
|
|
178
|
+
position: absolute;
|
|
179
|
+
top: 0;
|
|
180
|
+
left: 0;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
astro-overlay-plugin-canvas:not([data-active]) {
|
|
184
|
+
display: none;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
#minimize-button {
|
|
188
|
+
width: 32px;
|
|
189
|
+
height: 32px;
|
|
190
|
+
background: rgba(255, 255, 255, 0.75);
|
|
191
|
+
border-radius: 9999px;
|
|
192
|
+
display: flex;
|
|
193
|
+
justify-content: center;
|
|
194
|
+
align-items: center;
|
|
195
|
+
opacity: 0;
|
|
196
|
+
transition: opacity 0.2s ease-in-out;
|
|
197
|
+
pointer-events: auto;
|
|
198
|
+
border: 0;
|
|
199
|
+
color: white;
|
|
200
|
+
font-family: system-ui, sans-serif;
|
|
201
|
+
font-size: 1rem;
|
|
202
|
+
line-height: 1.2;
|
|
203
|
+
white-space: nowrap;
|
|
204
|
+
text-decoration: none;
|
|
205
|
+
padding: 0;
|
|
206
|
+
margin: 0;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
#minimize-button:hover, #minimize-button:focus {
|
|
210
|
+
cursor: pointer;
|
|
211
|
+
background: rgba(255, 255, 255, 0.90);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
#minimize-button svg {
|
|
215
|
+
width: 16px;
|
|
216
|
+
height: 16px;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.sr-only {
|
|
220
|
+
position: absolute;
|
|
221
|
+
width: 1px;
|
|
222
|
+
height: 1px;
|
|
223
|
+
padding: 0;
|
|
224
|
+
margin: -1px;
|
|
225
|
+
overflow: hidden;
|
|
226
|
+
clip: rect(0, 0, 0, 0);
|
|
227
|
+
white-space: nowrap;
|
|
228
|
+
border-width: 0;
|
|
229
|
+
}
|
|
230
|
+
</style>
|
|
231
|
+
|
|
232
|
+
<div id="dev-overlay">
|
|
233
|
+
<div id="dev-bar">
|
|
234
|
+
<div id="bar-container">
|
|
235
|
+
${builtinPlugins.map((plugin) => this.getPluginTemplate(plugin)).join("")}
|
|
236
|
+
<div class="separator"></div>
|
|
237
|
+
${customPlugins.map((plugin) => this.getPluginTemplate(plugin)).join("")}
|
|
238
|
+
</div>
|
|
239
|
+
</div>
|
|
240
|
+
<button id="minimize-button">${getIconElement("arrow-down")?.outerHTML}</button>
|
|
241
|
+
</div>`;
|
|
242
|
+
this.devOverlay = this.shadowRoot.querySelector("#dev-overlay");
|
|
243
|
+
this.attachEvents();
|
|
244
|
+
if ("requestIdleCallback" in window) {
|
|
245
|
+
window.requestIdleCallback(async () => {
|
|
246
|
+
await this.initAllPlugins();
|
|
247
|
+
});
|
|
248
|
+
} else {
|
|
249
|
+
setTimeout(async () => {
|
|
250
|
+
await this.initAllPlugins();
|
|
251
|
+
}, 200);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
attachEvents() {
|
|
255
|
+
const items = this.shadowRoot.querySelectorAll(".item");
|
|
256
|
+
items.forEach((item) => {
|
|
257
|
+
item.addEventListener("click", async (e) => {
|
|
258
|
+
const target = e.currentTarget;
|
|
259
|
+
if (!target || !(target instanceof HTMLElement))
|
|
260
|
+
return;
|
|
261
|
+
const id = target.dataset.pluginId;
|
|
262
|
+
if (!id)
|
|
263
|
+
return;
|
|
264
|
+
const plugin = this.getPluginById(id);
|
|
265
|
+
if (!plugin)
|
|
266
|
+
return;
|
|
267
|
+
if (plugin.status === "loading") {
|
|
268
|
+
await this.initPlugin(plugin);
|
|
269
|
+
}
|
|
270
|
+
this.togglePluginStatus(plugin);
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
const minimizeButton = this.shadowRoot.querySelector("#minimize-button");
|
|
274
|
+
if (minimizeButton && this.devOverlay) {
|
|
275
|
+
minimizeButton.addEventListener("click", () => {
|
|
276
|
+
this.toggleOverlay(false);
|
|
277
|
+
this.toggleMinimizeButton(false);
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
const devBar = this.shadowRoot.querySelector("#dev-bar");
|
|
281
|
+
if (devBar) {
|
|
282
|
+
["mouseenter", "focusin"].forEach((event) => {
|
|
283
|
+
devBar.addEventListener(event, () => {
|
|
284
|
+
if (this.hoverTimeout) {
|
|
285
|
+
window.clearTimeout(this.hoverTimeout);
|
|
286
|
+
}
|
|
287
|
+
if (this.isHidden()) {
|
|
288
|
+
this.hoverTimeout = window.setTimeout(() => {
|
|
289
|
+
this.toggleOverlay(true);
|
|
290
|
+
}, HOVER_DELAY);
|
|
291
|
+
} else {
|
|
292
|
+
this.hoverTimeout = window.setTimeout(() => {
|
|
293
|
+
this.toggleMinimizeButton(true);
|
|
294
|
+
}, HOVER_DELAY);
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
devBar.addEventListener("mouseleave", () => {
|
|
299
|
+
if (this.hoverTimeout) {
|
|
300
|
+
window.clearTimeout(this.hoverTimeout);
|
|
301
|
+
}
|
|
302
|
+
if (!this.isHidden()) {
|
|
303
|
+
this.hoverTimeout = window.setTimeout(() => {
|
|
304
|
+
this.toggleMinimizeButton(false);
|
|
305
|
+
}, HOVER_DELAY);
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
devBar.addEventListener("click", () => {
|
|
309
|
+
if (!this.isHidden())
|
|
310
|
+
return;
|
|
311
|
+
this.toggleOverlay(true);
|
|
312
|
+
});
|
|
313
|
+
devBar.addEventListener("keyup", (event) => {
|
|
314
|
+
if (event.code === "Space" || event.code === "Enter") {
|
|
315
|
+
if (!this.isHidden())
|
|
316
|
+
return;
|
|
317
|
+
this.toggleOverlay(true);
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
async initAllPlugins() {
|
|
323
|
+
await Promise.all(
|
|
324
|
+
plugins.filter((plugin) => plugin.status === "loading").map((plugin) => this.initPlugin(plugin))
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
async initPlugin(plugin) {
|
|
328
|
+
if (plugin.status === "ready")
|
|
329
|
+
return;
|
|
330
|
+
const shadowRoot = this.getPluginCanvasById(plugin.id).shadowRoot;
|
|
331
|
+
try {
|
|
332
|
+
console.info(`Initing plugin ${plugin.id}`);
|
|
333
|
+
await plugin.init?.(shadowRoot, plugin.eventTarget);
|
|
334
|
+
plugin.status = "ready";
|
|
335
|
+
if (import.meta.hot) {
|
|
336
|
+
import.meta.hot.send(`${WS_EVENT_NAME}:${plugin.id}:init`);
|
|
337
|
+
}
|
|
338
|
+
} catch (e) {
|
|
339
|
+
console.error(`Failed to init plugin ${plugin.id}, error: ${e}`);
|
|
340
|
+
plugin.status = "error";
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
getPluginTemplate(plugin) {
|
|
344
|
+
return `<button class="item" data-plugin-id="${plugin.id}">
|
|
345
|
+
<div class="icon">${this.getPluginIcon(plugin.icon)}<div class="notification"></div></div>
|
|
346
|
+
<span class="sr-only">${plugin.name}</span>
|
|
347
|
+
</button>`;
|
|
348
|
+
}
|
|
349
|
+
getPluginIcon(icon) {
|
|
350
|
+
if (isDefinedIcon(icon)) {
|
|
351
|
+
return getIconElement(icon)?.outerHTML;
|
|
352
|
+
}
|
|
353
|
+
return icon;
|
|
354
|
+
}
|
|
355
|
+
getPluginById(id) {
|
|
356
|
+
return plugins.find((plugin) => plugin.id === id);
|
|
357
|
+
}
|
|
358
|
+
getPluginCanvasById(id) {
|
|
359
|
+
return this.shadowRoot.querySelector(`astro-overlay-plugin-canvas[data-plugin-id="${id}"]`);
|
|
360
|
+
}
|
|
361
|
+
togglePluginStatus(plugin, status) {
|
|
362
|
+
plugin.active = status ?? !plugin.active;
|
|
363
|
+
const target = this.shadowRoot.querySelector(`[data-plugin-id="${plugin.id}"]`);
|
|
364
|
+
if (!target)
|
|
365
|
+
return;
|
|
366
|
+
target.classList.toggle("active", plugin.active);
|
|
367
|
+
this.getPluginCanvasById(plugin.id)?.toggleAttribute("data-active", plugin.active);
|
|
368
|
+
plugin.eventTarget.dispatchEvent(
|
|
369
|
+
new CustomEvent("plugin-toggle", {
|
|
370
|
+
detail: {
|
|
371
|
+
state: plugin.active,
|
|
372
|
+
plugin
|
|
373
|
+
}
|
|
374
|
+
})
|
|
375
|
+
);
|
|
376
|
+
if (import.meta.hot) {
|
|
377
|
+
import.meta.hot.send(`${WS_EVENT_NAME}:${plugin.id}:toggle`, { state: plugin.active });
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
toggleMinimizeButton(newStatus) {
|
|
381
|
+
const minimizeButton = this.shadowRoot.querySelector("#minimize-button");
|
|
382
|
+
if (!minimizeButton)
|
|
383
|
+
return;
|
|
384
|
+
if (newStatus !== void 0) {
|
|
385
|
+
if (newStatus === true) {
|
|
386
|
+
minimizeButton.removeAttribute("inert");
|
|
387
|
+
minimizeButton.style.opacity = "1";
|
|
388
|
+
} else {
|
|
389
|
+
minimizeButton.setAttribute("inert", "");
|
|
390
|
+
minimizeButton.style.opacity = "0";
|
|
391
|
+
}
|
|
392
|
+
} else {
|
|
393
|
+
minimizeButton.toggleAttribute("inert");
|
|
394
|
+
minimizeButton.style.opacity = minimizeButton.hasAttribute("inert") ? "0" : "1";
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
toggleOverlay(newStatus) {
|
|
398
|
+
const barContainer = this.shadowRoot.querySelector("#bar-container");
|
|
399
|
+
const devBar = this.shadowRoot.querySelector("#dev-bar");
|
|
400
|
+
if (newStatus !== void 0) {
|
|
401
|
+
if (newStatus === true) {
|
|
402
|
+
this.devOverlay?.removeAttribute("data-hidden");
|
|
403
|
+
barContainer?.removeAttribute("inert");
|
|
404
|
+
devBar?.removeAttribute("tabindex");
|
|
405
|
+
} else {
|
|
406
|
+
this.devOverlay?.setAttribute("data-hidden", "");
|
|
407
|
+
barContainer?.setAttribute("inert", "");
|
|
408
|
+
devBar?.setAttribute("tabindex", "0");
|
|
409
|
+
}
|
|
410
|
+
} else {
|
|
411
|
+
this.devOverlay?.toggleAttribute("data-hidden");
|
|
412
|
+
barContainer?.toggleAttribute("inert");
|
|
413
|
+
if (this.isHidden()) {
|
|
414
|
+
devBar?.setAttribute("tabindex", "0");
|
|
415
|
+
} else {
|
|
416
|
+
devBar?.removeAttribute("tabindex");
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
class DevOverlayCanvas extends HTMLElement {
|
|
422
|
+
shadowRoot;
|
|
423
|
+
constructor() {
|
|
424
|
+
super();
|
|
425
|
+
this.shadowRoot = this.attachShadow({ mode: "closed" });
|
|
426
|
+
}
|
|
427
|
+
// connect component
|
|
428
|
+
async connectedCallback() {
|
|
429
|
+
this.shadowRoot.innerHTML = ``;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
customElements.define("astro-dev-overlay", AstroDevOverlay);
|
|
433
|
+
customElements.define("astro-overlay-window", DevOverlayWindow);
|
|
434
|
+
customElements.define("astro-overlay-plugin-canvas", DevOverlayCanvas);
|
|
435
|
+
customElements.define("astro-overlay-tooltip", DevOverlayTooltip);
|
|
436
|
+
customElements.define("astro-overlay-highlight", DevOverlayHighlight);
|
|
437
|
+
customElements.define("astro-overlay-card", DevOverlayCard);
|
|
438
|
+
const overlay = document.createElement("astro-dev-overlay");
|
|
439
|
+
overlay.style.zIndex = "999999";
|
|
440
|
+
document.body.append(overlay);
|
|
441
|
+
plugins.forEach((plugin) => {
|
|
442
|
+
const pluginCanvas = document.createElement("astro-overlay-plugin-canvas");
|
|
443
|
+
pluginCanvas.dataset.pluginId = plugin.id;
|
|
444
|
+
overlay.shadowRoot?.append(pluginCanvas);
|
|
445
|
+
});
|
|
446
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
var astro_default = {
|
|
2
|
+
id: "astro",
|
|
3
|
+
name: "Astro",
|
|
4
|
+
icon: "astro:logo",
|
|
5
|
+
init(canvas) {
|
|
6
|
+
const astroWindow = document.createElement("astro-overlay-window");
|
|
7
|
+
astroWindow.windowTitle = "Astro";
|
|
8
|
+
astroWindow.windowIcon = "astro:logo";
|
|
9
|
+
astroWindow.innerHTML = `
|
|
10
|
+
<style>
|
|
11
|
+
#buttons-container {
|
|
12
|
+
display: flex;
|
|
13
|
+
gap: 16px;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
#buttons-container astro-overlay-card {
|
|
18
|
+
flex: 1;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
footer {
|
|
22
|
+
display: flex;
|
|
23
|
+
justify-content: center;
|
|
24
|
+
gap: 24px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
footer a {
|
|
28
|
+
color: rgba(145, 152, 173, 1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
footer a:hover {
|
|
32
|
+
color: rgba(204, 206, 216, 1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
#main-container {
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
justify-content: space-between;
|
|
39
|
+
height: 100%;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
p {
|
|
43
|
+
margin-top: 0;
|
|
44
|
+
}
|
|
45
|
+
</style>
|
|
46
|
+
|
|
47
|
+
<div id="main-container">
|
|
48
|
+
<div>
|
|
49
|
+
<p>Welcome to Astro!</p>
|
|
50
|
+
<div id="buttons-container">
|
|
51
|
+
<astro-overlay-card icon="astro:logo" link="https://github.com/withastro/astro/issues/new/choose">Report an issue</astro-overlay-card>
|
|
52
|
+
<astro-overlay-card icon="astro:logo" link="https://docs.astro.build/en/getting-started/">View Astro Docs</astro-overlay-card>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
<footer>
|
|
56
|
+
<a href="https://discord.gg/astro" target="_blank">Join the Astro Discord</a>
|
|
57
|
+
<a href="https://astro.build" target="_blank">Visit Astro.build</a>
|
|
58
|
+
</footer>
|
|
59
|
+
</div>
|
|
60
|
+
`;
|
|
61
|
+
canvas.append(astroWindow);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
export {
|
|
65
|
+
astro_default as default
|
|
66
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
icon: "<svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 16\"><path fill=\"#fff\" d=\"M.6 2A1.1 1.1 0 0 1 1.7.9h16.6a1.1 1.1 0 1 1 0 2.2H1.6A1.1 1.1 0 0 1 .8 2Zm1.1 7.1h6a1.1 1.1 0 0 0 0-2.2h-6a1.1 1.1 0 0 0 0 2.2ZM9.3 13H1.8a1.1 1.1 0 1 0 0 2.2h7.5a1.1 1.1 0 1 0 0-2.2Zm11.3 1.9a1.1 1.1 0 0 1-1.5 0l-1.7-1.7a4.1 4.1 0 1 1 1.6-1.6l1.6 1.7a1.1 1.1 0 0 1 0 1.6Zm-5.3-3.4a1.9 1.9 0 1 0 0-3.8 1.9 1.9 0 0 0 0 3.8Z\"/></svg>";
|
|
5
|
+
init(canvas: ShadowRoot, eventTarget: EventTarget): void;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|