astro 4.1.1 → 4.1.3
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/components/ViewTransitions.astro +6 -1
- package/dist/@types/astro.d.ts +26 -25
- package/dist/assets/internal.js +3 -2
- package/dist/assets/services/noop.js +1 -4
- package/dist/assets/types.d.ts +1 -1
- package/dist/assets/utils/emitAsset.js +1 -1
- package/dist/assets/utils/proxy.d.ts +2 -1
- package/dist/assets/utils/proxy.js +5 -1
- package/dist/assets/vite-plugin-assets.js +21 -14
- package/dist/content/runtime-assets.d.ts +1 -1
- package/dist/content/runtime-assets.js +1 -1
- package/dist/content/vite-plugin-content-imports.js +5 -5
- package/dist/core/config/vite-load.js +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/cookies/cookies.d.ts +5 -0
- package/dist/core/cookies/cookies.js +17 -0
- package/dist/core/cookies/response.d.ts +1 -1
- package/dist/core/cookies/response.js +2 -1
- package/dist/core/create-vite.js +9 -4
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/dev/utils.js +1 -1
- package/dist/core/errors/errors-data.d.ts +43 -25
- package/dist/core/errors/errors-data.js +32 -33
- package/dist/core/messages.js +2 -2
- package/dist/core/redirects/helpers.js +2 -2
- package/dist/core/routing/manifest/create.js +22 -1
- package/dist/core/sync/index.js +1 -1
- package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/astro.js +3 -3
- package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/audit/index.js +4 -4
- package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/settings.js +7 -7
- package/dist/runtime/client/dev-toolbar/apps/utils/highlight.d.ts +8 -0
- package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/utils/window.d.ts +1 -1
- package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/xray.js +5 -5
- package/dist/runtime/client/{dev-overlay → dev-toolbar}/entrypoint.js +64 -68
- package/dist/runtime/client/{dev-overlay → dev-toolbar}/settings.d.ts +2 -2
- package/dist/runtime/client/{dev-overlay → dev-toolbar}/settings.js +10 -5
- package/dist/runtime/client/dev-toolbar/toolbar.d.ts +45 -0
- package/dist/runtime/client/{dev-overlay/overlay.js → dev-toolbar/toolbar.js} +99 -103
- package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/badge.d.ts +1 -1
- package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/badge.js +2 -2
- package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/button.d.ts +1 -1
- package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/button.js +3 -2
- package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/card.d.ts +1 -1
- package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/card.js +2 -2
- package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/highlight.d.ts +1 -1
- package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/highlight.js +2 -2
- package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/icon.d.ts +1 -1
- package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/icon.js +2 -2
- package/dist/runtime/client/dev-toolbar/ui-library/index.d.ts +8 -0
- package/dist/runtime/client/dev-toolbar/ui-library/index.js +18 -0
- package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/toggle.d.ts +1 -1
- package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/toggle.js +2 -2
- package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/tooltip.d.ts +3 -3
- package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/tooltip.js +2 -2
- package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/window.d.ts +1 -1
- package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/window.js +3 -3
- package/dist/transitions/router.js +4 -1
- package/dist/vite-plugin-astro/index.js +12 -2
- package/dist/vite-plugin-astro-server/route.js +7 -4
- package/dist/vite-plugin-config-alias/index.js +3 -0
- package/dist/{vite-plugin-dev-overlay/vite-plugin-dev-overlay.d.ts → vite-plugin-dev-toolbar/vite-plugin-dev-toolbar.d.ts} +1 -1
- package/dist/{vite-plugin-dev-overlay/vite-plugin-dev-overlay.js → vite-plugin-dev-toolbar/vite-plugin-dev-toolbar.js} +5 -5
- package/dist/vite-plugin-env/index.d.ts +1 -1
- package/dist/vite-plugin-env/index.js +81 -43
- package/dist/vite-plugin-markdown/index.js +3 -3
- package/dist/vite-plugin-utils/index.d.ts +0 -6
- package/dist/vite-plugin-utils/index.js +0 -4
- package/package.json +2 -2
- package/dist/runtime/client/dev-overlay/overlay.d.ts +0 -45
- package/dist/runtime/client/dev-overlay/plugins/utils/highlight.d.ts +0 -8
- package/dist/runtime/client/dev-overlay/ui-library/index.d.ts +0 -8
- package/dist/runtime/client/dev-overlay/ui-library/index.js +0 -18
- /package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/astro.d.ts +0 -0
- /package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/audit/a11y.d.ts +0 -0
- /package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/audit/a11y.js +0 -0
- /package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/audit/index.d.ts +0 -0
- /package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/settings.d.ts +0 -0
- /package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/utils/highlight.js +0 -0
- /package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/utils/icons.d.ts +0 -0
- /package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/utils/icons.js +0 -0
- /package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/utils/window.js +0 -0
- /package/dist/runtime/client/{dev-overlay/plugins → dev-toolbar/apps}/xray.d.ts +0 -0
- /package/dist/runtime/client/{dev-overlay → dev-toolbar}/entrypoint.d.ts +0 -0
- /package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/icons.d.ts +0 -0
- /package/dist/runtime/client/{dev-overlay → dev-toolbar}/ui-library/icons.js +0 -0
|
@@ -125,7 +125,7 @@ const NoMatchingImport = {
|
|
|
125
125
|
const InvalidPrerenderExport = {
|
|
126
126
|
name: "InvalidPrerenderExport",
|
|
127
127
|
title: "Invalid prerender export.",
|
|
128
|
-
message
|
|
128
|
+
message(prefix, suffix, isHydridOuput) {
|
|
129
129
|
const defaultExpectedValue = isHydridOuput ? "false" : "true";
|
|
130
130
|
let msg = `A \`prerender\` export has been detected, but its value cannot be statically analyzed.`;
|
|
131
131
|
if (prefix !== "const")
|
|
@@ -308,6 +308,30 @@ const FailedToFindPageMapSSR = {
|
|
|
308
308
|
title: "Astro couldn't find the correct page to render",
|
|
309
309
|
message: "Astro couldn't find the correct page to render, probably because it wasn't correctly mapped for SSR usage. This is an internal error. Please file an issue."
|
|
310
310
|
};
|
|
311
|
+
const MissingLocale = {
|
|
312
|
+
name: "MissingLocaleError",
|
|
313
|
+
title: "The provided locale does not exist.",
|
|
314
|
+
message: (locale) => `The locale/path \`${locale}\` does not exist in the configured \`i18n.locales\`.`
|
|
315
|
+
};
|
|
316
|
+
const MissingIndexForInternationalization = {
|
|
317
|
+
name: "MissingIndexForInternationalizationError",
|
|
318
|
+
title: "Index page not found.",
|
|
319
|
+
message: (src) => `Astro couldn't find the index URL. This index page is required to create a redirect from the index URL to the index URL of the default locale.
|
|
320
|
+
Create an index page in \`${src}\``
|
|
321
|
+
};
|
|
322
|
+
const CantRenderPage = {
|
|
323
|
+
name: "CantRenderPage",
|
|
324
|
+
title: "Astro can't render the route.",
|
|
325
|
+
message: "Astro cannot find any content to render for this route. There is no file or redirect associated with this route.",
|
|
326
|
+
hint: "If you expect to find a route here, this may be an Astro bug. Please file an issue/restart the dev server"
|
|
327
|
+
};
|
|
328
|
+
const UnhandledRejection = {
|
|
329
|
+
name: "UnhandledRejection",
|
|
330
|
+
title: "Unhandled rejection",
|
|
331
|
+
message: (stack) => `Astro detected an unhandled rejection. Here's the stack trace:
|
|
332
|
+
${stack}`,
|
|
333
|
+
hint: "Make sure your promises all have an `await` or a `.catch()` handler."
|
|
334
|
+
};
|
|
311
335
|
const UnknownCSSError = {
|
|
312
336
|
name: "UnknownCSSError",
|
|
313
337
|
title: "Unknown CSS Error."
|
|
@@ -368,7 +392,7 @@ const UnknownContentCollectionError = {
|
|
|
368
392
|
const InvalidContentEntryFrontmatterError = {
|
|
369
393
|
name: "InvalidContentEntryFrontmatterError",
|
|
370
394
|
title: "Content entry frontmatter does not match schema.",
|
|
371
|
-
message
|
|
395
|
+
message(collection, entryId, error) {
|
|
372
396
|
return [
|
|
373
397
|
`**${String(collection)} \u2192 ${String(
|
|
374
398
|
entryId
|
|
@@ -381,7 +405,7 @@ const InvalidContentEntryFrontmatterError = {
|
|
|
381
405
|
const InvalidContentEntrySlugError = {
|
|
382
406
|
name: "InvalidContentEntrySlugError",
|
|
383
407
|
title: "Invalid content entry slug.",
|
|
384
|
-
message
|
|
408
|
+
message(collection, entryId) {
|
|
385
409
|
return `${String(collection)} \u2192 ${String(
|
|
386
410
|
entryId
|
|
387
411
|
)} has an invalid slug. \`slug\` must be a string.`;
|
|
@@ -403,22 +427,18 @@ const CollectionDoesNotExistError = {
|
|
|
403
427
|
const MixedContentDataCollectionError = {
|
|
404
428
|
name: "MixedContentDataCollectionError",
|
|
405
429
|
title: "Content and data cannot be in same collection.",
|
|
406
|
-
message: (
|
|
407
|
-
return `**${collection}** contains a mix of content and data entries. All entries must be of the same type.`;
|
|
408
|
-
},
|
|
430
|
+
message: (collectionName) => `**${collectionName}** contains a mix of content and data entries. All entries must be of the same type.`,
|
|
409
431
|
hint: "Store data entries in a new collection separate from your content collection."
|
|
410
432
|
};
|
|
411
433
|
const ContentCollectionTypeMismatchError = {
|
|
412
434
|
name: "ContentCollectionTypeMismatchError",
|
|
413
435
|
title: "Collection contains entries of a different type.",
|
|
414
|
-
message: (collection, expectedType, actualType) => {
|
|
415
|
-
return `${collection} contains ${expectedType} entries, but is configured as a ${actualType} collection.`;
|
|
416
|
-
}
|
|
436
|
+
message: (collection, expectedType, actualType) => `${collection} contains ${expectedType} entries, but is configured as a ${actualType} collection.`
|
|
417
437
|
};
|
|
418
438
|
const DataCollectionEntryParseError = {
|
|
419
439
|
name: "DataCollectionEntryParseError",
|
|
420
440
|
title: "Data collection entry failed to parse.",
|
|
421
|
-
message
|
|
441
|
+
message(entryId, errorMessage) {
|
|
422
442
|
return `**${entryId}** failed to parse: ${errorMessage}`;
|
|
423
443
|
},
|
|
424
444
|
hint: "Ensure your data entry is an object with valid JSON (for `.json` entries) or YAML (for `.yaml` entries)."
|
|
@@ -426,7 +446,7 @@ const DataCollectionEntryParseError = {
|
|
|
426
446
|
const DuplicateContentEntrySlugError = {
|
|
427
447
|
name: "DuplicateContentEntrySlugError",
|
|
428
448
|
title: "Duplicate content entry slug.",
|
|
429
|
-
message
|
|
449
|
+
message(collection, slug, preExisting, alsoFound) {
|
|
430
450
|
return `**${collection}** contains multiple entries with the same slug: \`${slug}\`. Slugs must be unique.
|
|
431
451
|
|
|
432
452
|
Entries:
|
|
@@ -441,29 +461,7 @@ const UnsupportedConfigTransformError = {
|
|
|
441
461
|
Full error: ${parseError}`,
|
|
442
462
|
hint: "See the devalue library for all supported types: https://github.com/rich-harris/devalue"
|
|
443
463
|
};
|
|
444
|
-
const MissingLocale = {
|
|
445
|
-
name: "MissingLocaleError",
|
|
446
|
-
title: "The provided locale does not exist.",
|
|
447
|
-
message: (locale) => {
|
|
448
|
-
return `The locale/path \`${locale}\` does not exist in the configured \`i18n.locales\`.`;
|
|
449
|
-
}
|
|
450
|
-
};
|
|
451
|
-
const CantRenderPage = {
|
|
452
|
-
name: "CantRenderPage",
|
|
453
|
-
title: "Astro can't render the route.",
|
|
454
|
-
message: "Astro cannot find any content to render for this route. There is no file or redirect associated with this route.",
|
|
455
|
-
hint: "If you expect to find a route here, this may be an Astro bug. Please file an issue/restart the dev server"
|
|
456
|
-
};
|
|
457
464
|
const UnknownError = { name: "UnknownError", title: "Unknown Error." };
|
|
458
|
-
const UnhandledRejection = {
|
|
459
|
-
name: "UnhandledRejection",
|
|
460
|
-
title: "Unhandled rejection",
|
|
461
|
-
message: (stack) => {
|
|
462
|
-
return `Astro detected an unhandled rejection. Here's the stack trace:
|
|
463
|
-
${stack}`;
|
|
464
|
-
},
|
|
465
|
-
hint: "Make sure your promises all have an `await` or a `.catch()` handler."
|
|
466
|
-
};
|
|
467
465
|
export {
|
|
468
466
|
AstroGlobNoMatch,
|
|
469
467
|
AstroGlobUsedOutside,
|
|
@@ -510,6 +508,7 @@ export {
|
|
|
510
508
|
MiddlewareNoDataOrNextCalled,
|
|
511
509
|
MiddlewareNotAResponse,
|
|
512
510
|
MissingImageDimension,
|
|
511
|
+
MissingIndexForInternationalization,
|
|
513
512
|
MissingLocale,
|
|
514
513
|
MissingMediaQueryDirective,
|
|
515
514
|
MissingSharp,
|
package/dist/core/messages.js
CHANGED
|
@@ -36,7 +36,7 @@ function serverStart({
|
|
|
36
36
|
host,
|
|
37
37
|
base
|
|
38
38
|
}) {
|
|
39
|
-
const version = "4.1.
|
|
39
|
+
const version = "4.1.3";
|
|
40
40
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
41
41
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
42
42
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -258,7 +258,7 @@ function printHelp({
|
|
|
258
258
|
message.push(
|
|
259
259
|
linebreak(),
|
|
260
260
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
261
|
-
`v${"4.1.
|
|
261
|
+
`v${"4.1.3"}`
|
|
262
262
|
)} ${headline}`
|
|
263
263
|
);
|
|
264
264
|
}
|
|
@@ -24,8 +24,8 @@ function redirectRouteGenerate(redirectRoute, data) {
|
|
|
24
24
|
}
|
|
25
25
|
function redirectRouteStatus(redirectRoute, method = "GET") {
|
|
26
26
|
const routeData = redirectRoute.redirectRoute;
|
|
27
|
-
if (typeof
|
|
28
|
-
return
|
|
27
|
+
if (routeData && typeof redirectRoute.redirect === "object") {
|
|
28
|
+
return redirectRoute.redirect.status;
|
|
29
29
|
} else if (method !== "GET") {
|
|
30
30
|
return 308;
|
|
31
31
|
}
|
|
@@ -8,6 +8,8 @@ import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from "../../constants.js";
|
|
|
8
8
|
import { removeLeadingForwardSlash, slash } from "../../path.js";
|
|
9
9
|
import { resolvePages } from "../../util.js";
|
|
10
10
|
import { getRouteGenerator } from "./generator.js";
|
|
11
|
+
import { AstroError } from "../../errors/index.js";
|
|
12
|
+
import { MissingIndexForInternationalization } from "../../errors/errors-data.js";
|
|
11
13
|
const require2 = createRequire(import.meta.url);
|
|
12
14
|
function countOccurrences(needle, haystack) {
|
|
13
15
|
let count = 0;
|
|
@@ -333,7 +335,13 @@ This route collides with: "${collision.component}".`
|
|
|
333
335
|
pathname: pathname || void 0,
|
|
334
336
|
prerender: false,
|
|
335
337
|
redirect: to,
|
|
336
|
-
redirectRoute: routes.find((r) =>
|
|
338
|
+
redirectRoute: routes.find((r) => {
|
|
339
|
+
if (typeof to === "object") {
|
|
340
|
+
return r.route === to.destination;
|
|
341
|
+
} else {
|
|
342
|
+
return r.route === to;
|
|
343
|
+
}
|
|
344
|
+
}),
|
|
337
345
|
fallbackRoutes: []
|
|
338
346
|
};
|
|
339
347
|
const lastSegmentIsDynamic = (r) => !!r.segments.at(-1)?.at(-1)?.dynamic;
|
|
@@ -356,6 +364,19 @@ This route collides with: "${collision.component}".`
|
|
|
356
364
|
});
|
|
357
365
|
const i18n = settings.config.i18n;
|
|
358
366
|
if (i18n) {
|
|
367
|
+
if (i18n.routing === "prefix-always") {
|
|
368
|
+
let index = routes.find((route) => route.route === "/");
|
|
369
|
+
if (!index) {
|
|
370
|
+
let relativePath = path.relative(
|
|
371
|
+
fileURLToPath(settings.config.root),
|
|
372
|
+
fileURLToPath(new URL("pages", settings.config.srcDir))
|
|
373
|
+
);
|
|
374
|
+
throw new AstroError({
|
|
375
|
+
...MissingIndexForInternationalization,
|
|
376
|
+
message: MissingIndexForInternationalization.message(relativePath)
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
}
|
|
359
380
|
const routesByLocale = /* @__PURE__ */ new Map();
|
|
360
381
|
const setRoutes = new Set(routes.filter((route) => route.type === "page"));
|
|
361
382
|
const filteredLocales = i18n.locales.filter((loc) => {
|
package/dist/core/sync/index.js
CHANGED
|
@@ -34,7 +34,7 @@ async function syncInternal(settings, { logger, fs }) {
|
|
|
34
34
|
const tempViteServer = await createServer(
|
|
35
35
|
await createVite(
|
|
36
36
|
{
|
|
37
|
-
server: { middlewareMode: true, hmr: false, watch:
|
|
37
|
+
server: { middlewareMode: true, hmr: false, watch: null },
|
|
38
38
|
optimizeDeps: { disabled: true },
|
|
39
39
|
ssr: { external: [] },
|
|
40
40
|
logLevel: "silent"
|
|
@@ -10,7 +10,7 @@ var astro_default = {
|
|
|
10
10
|
async init(canvas, eventTarget) {
|
|
11
11
|
createCanvas();
|
|
12
12
|
document.addEventListener("astro:after-swap", createCanvas);
|
|
13
|
-
eventTarget.addEventListener("
|
|
13
|
+
eventTarget.addEventListener("app-toggled", async (event) => {
|
|
14
14
|
resetDebugButton();
|
|
15
15
|
if (!(event instanceof CustomEvent))
|
|
16
16
|
return;
|
|
@@ -291,7 +291,7 @@ var astro_default = {
|
|
|
291
291
|
<header>
|
|
292
292
|
<section>
|
|
293
293
|
${astroLogo}
|
|
294
|
-
<astro-dev-toolbar-badge badge-style="gray" size="large">${window.
|
|
294
|
+
<astro-dev-toolbar-badge badge-style="gray" size="large">${window.__astro_dev_toolbar__.version}</astro-dev-toolbar-badge>
|
|
295
295
|
</section>
|
|
296
296
|
<astro-dev-toolbar-button id="copy-debug-button">Copy debug info <astro-dev-toolbar-icon icon="copy" /></astro-dev-toolbar-button>
|
|
297
297
|
</header>
|
|
@@ -321,7 +321,7 @@ var astro_default = {
|
|
|
321
321
|
const copyDebugButton = windowComponent.querySelector("#copy-debug-button");
|
|
322
322
|
copyDebugButton?.addEventListener("click", () => {
|
|
323
323
|
navigator.clipboard.writeText(
|
|
324
|
-
"```\n" + window.
|
|
324
|
+
"```\n" + window.__astro_dev_toolbar__.debugInfo + "\n```"
|
|
325
325
|
);
|
|
326
326
|
copyDebugButton.textContent = "Copied to clipboard!";
|
|
327
327
|
setTimeout(() => {
|
|
@@ -37,14 +37,14 @@ var audit_default = {
|
|
|
37
37
|
if (target.closest("astro-dev-toolbar"))
|
|
38
38
|
return;
|
|
39
39
|
eventTarget.dispatchEvent(
|
|
40
|
-
new CustomEvent("toggle-
|
|
40
|
+
new CustomEvent("toggle-app", {
|
|
41
41
|
detail: {
|
|
42
42
|
state: false
|
|
43
43
|
}
|
|
44
44
|
})
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
|
-
eventTarget.addEventListener("
|
|
47
|
+
eventTarget.addEventListener("app-toggled", (event) => {
|
|
48
48
|
if (event.detail.state === true) {
|
|
49
49
|
document.addEventListener("click", onPageClick, true);
|
|
50
50
|
} else {
|
|
@@ -132,7 +132,7 @@ var audit_default = {
|
|
|
132
132
|
function refreshLintPositions() {
|
|
133
133
|
const noAuditBlock = canvas.getElementById("no-audit");
|
|
134
134
|
if (noAuditBlock) {
|
|
135
|
-
const devOverlayRect = document.querySelector("astro-dev-toolbar")?.shadowRoot.querySelector("#dev-
|
|
135
|
+
const devOverlayRect = document.querySelector("astro-dev-toolbar")?.shadowRoot.querySelector("#dev-toolbar-root")?.getBoundingClientRect();
|
|
136
136
|
noAuditBlock.style.top = `${(devOverlayRect?.top ?? 0) - (devOverlayRect?.height ?? 0) - 16}px`;
|
|
137
137
|
}
|
|
138
138
|
audits.forEach(({ highlightElement, auditedElement }) => {
|
|
@@ -178,7 +178,7 @@ var audit_default = {
|
|
|
178
178
|
const elementFileWithPosition = elementFile + (elementPosition ? ":" + elementPosition : "");
|
|
179
179
|
tooltip.sections.push({
|
|
180
180
|
content: elementFileWithPosition.slice(
|
|
181
|
-
window.
|
|
181
|
+
window.__astro_dev_toolbar__.root.length - 1
|
|
182
182
|
// We want to keep the final slash, so minus one.
|
|
183
183
|
),
|
|
184
184
|
clickDescription: "Click to go to file",
|
|
@@ -5,22 +5,22 @@ const settingsRows = [
|
|
|
5
5
|
name: "Disable notifications",
|
|
6
6
|
description: "Hide notification badges in the toolbar.",
|
|
7
7
|
input: "checkbox",
|
|
8
|
-
settingKey: "
|
|
8
|
+
settingKey: "disableAppNotification",
|
|
9
9
|
changeEvent: (evt) => {
|
|
10
10
|
if (evt.currentTarget instanceof HTMLInputElement) {
|
|
11
|
-
const
|
|
12
|
-
if (
|
|
13
|
-
|
|
11
|
+
const devToolbar = document.querySelector("astro-dev-toolbar");
|
|
12
|
+
if (devToolbar) {
|
|
13
|
+
devToolbar.setNotificationVisible(!evt.currentTarget.checked);
|
|
14
14
|
}
|
|
15
|
-
settings.updateSetting("
|
|
15
|
+
settings.updateSetting("disableAppNotification", evt.currentTarget.checked);
|
|
16
16
|
const action = evt.currentTarget.checked ? "disabled" : "enabled";
|
|
17
|
-
settings.log(`
|
|
17
|
+
settings.log(`App notification badges ${action}`);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
name: "Verbose logging",
|
|
23
|
-
description: "Logs dev
|
|
23
|
+
description: "Logs dev toolbar events in the browser console.",
|
|
24
24
|
input: "checkbox",
|
|
25
25
|
settingKey: "verbose",
|
|
26
26
|
changeEvent: (evt) => {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DevToolbarHighlight } from '../../ui-library/highlight.js';
|
|
2
|
+
import type { Icon } from '../../ui-library/icons.js';
|
|
3
|
+
export declare function createHighlight(rect: DOMRect, icon?: Icon): DevToolbarHighlight;
|
|
4
|
+
export declare function getElementsPositionInDocument(el: Element): {
|
|
5
|
+
isFixed: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function positionHighlight(highlight: DevToolbarHighlight, rect: DOMRect): void;
|
|
8
|
+
export declare function attachTooltipToHighlight(highlight: DevToolbarHighlight, tooltip: HTMLElement, originalElement: Element): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function createWindowElement(content: string): import("../../ui-library/window.js").
|
|
1
|
+
export declare function createWindowElement(content: string): import("../../ui-library/window.js").DevToolbarWindow;
|
|
@@ -26,14 +26,14 @@ var xray_default = {
|
|
|
26
26
|
event.preventDefault();
|
|
27
27
|
event.stopPropagation();
|
|
28
28
|
eventTarget.dispatchEvent(
|
|
29
|
-
new CustomEvent("toggle-
|
|
29
|
+
new CustomEvent("toggle-app", {
|
|
30
30
|
detail: {
|
|
31
31
|
state: false
|
|
32
32
|
}
|
|
33
33
|
})
|
|
34
34
|
);
|
|
35
35
|
}
|
|
36
|
-
eventTarget.addEventListener("
|
|
36
|
+
eventTarget.addEventListener("app-toggled", (event) => {
|
|
37
37
|
if (event.detail.state === true) {
|
|
38
38
|
document.addEventListener("click", onPageClick, true);
|
|
39
39
|
} else {
|
|
@@ -52,7 +52,7 @@ var xray_default = {
|
|
|
52
52
|
header {
|
|
53
53
|
display: flex;
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
h1 {
|
|
57
57
|
display: flex;
|
|
58
58
|
align-items: center;
|
|
@@ -62,7 +62,7 @@ var xray_default = {
|
|
|
62
62
|
margin: 0;
|
|
63
63
|
font-size: 22px;
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
astro-dev-toolbar-icon {
|
|
67
67
|
width: 1em;
|
|
68
68
|
height: 1em;
|
|
@@ -142,7 +142,7 @@ var xray_default = {
|
|
|
142
142
|
async clickAction() {
|
|
143
143
|
await fetch(
|
|
144
144
|
"/__open-in-editor?file=" + encodeURIComponent(
|
|
145
|
-
window.
|
|
145
|
+
window.__astro_dev_toolbar__.root + islandComponentPath.slice(1)
|
|
146
146
|
)
|
|
147
147
|
);
|
|
148
148
|
}
|
|
@@ -1,60 +1,60 @@
|
|
|
1
1
|
import { settings } from "./settings.js";
|
|
2
|
-
import {
|
|
2
|
+
import { loadDevToolbarApps } from "astro:dev-toolbar";
|
|
3
3
|
let overlay;
|
|
4
4
|
document.addEventListener("DOMContentLoaded", async () => {
|
|
5
5
|
const [
|
|
6
|
-
|
|
7
|
-
{ default:
|
|
8
|
-
{ default:
|
|
9
|
-
{ default:
|
|
10
|
-
{ default:
|
|
11
|
-
{
|
|
6
|
+
customAppsDefinitions,
|
|
7
|
+
{ default: astroDevToolApp },
|
|
8
|
+
{ default: astroAuditApp },
|
|
9
|
+
{ default: astroXrayApp },
|
|
10
|
+
{ default: astroSettingsApp },
|
|
11
|
+
{ AstroDevToolbar, DevToolbarCanvas, getAppIcon },
|
|
12
12
|
{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
DevToolbarCard,
|
|
14
|
+
DevToolbarHighlight,
|
|
15
|
+
DevToolbarTooltip,
|
|
16
|
+
DevToolbarWindow,
|
|
17
|
+
DevToolbarToggle,
|
|
18
|
+
DevToolbarButton,
|
|
19
|
+
DevToolbarBadge,
|
|
20
|
+
DevToolbarIcon
|
|
21
21
|
}
|
|
22
22
|
] = await Promise.all([
|
|
23
|
-
|
|
24
|
-
import("./
|
|
25
|
-
import("./
|
|
26
|
-
import("./
|
|
27
|
-
import("./
|
|
28
|
-
import("./
|
|
23
|
+
loadDevToolbarApps(),
|
|
24
|
+
import("./apps/astro.js"),
|
|
25
|
+
import("./apps/audit/index.js"),
|
|
26
|
+
import("./apps/xray.js"),
|
|
27
|
+
import("./apps/settings.js"),
|
|
28
|
+
import("./toolbar.js"),
|
|
29
29
|
import("./ui-library/index.js")
|
|
30
30
|
]);
|
|
31
|
-
customElements.define("astro-dev-toolbar",
|
|
32
|
-
customElements.define("astro-dev-toolbar-window",
|
|
33
|
-
customElements.define("astro-dev-toolbar-
|
|
34
|
-
customElements.define("astro-dev-toolbar-tooltip",
|
|
35
|
-
customElements.define("astro-dev-toolbar-highlight",
|
|
36
|
-
customElements.define("astro-dev-toolbar-card",
|
|
37
|
-
customElements.define("astro-dev-toolbar-toggle",
|
|
38
|
-
customElements.define("astro-dev-toolbar-button",
|
|
39
|
-
customElements.define("astro-dev-toolbar-badge",
|
|
40
|
-
customElements.define("astro-dev-toolbar-icon",
|
|
31
|
+
customElements.define("astro-dev-toolbar", AstroDevToolbar);
|
|
32
|
+
customElements.define("astro-dev-toolbar-window", DevToolbarWindow);
|
|
33
|
+
customElements.define("astro-dev-toolbar-app-canvas", DevToolbarCanvas);
|
|
34
|
+
customElements.define("astro-dev-toolbar-tooltip", DevToolbarTooltip);
|
|
35
|
+
customElements.define("astro-dev-toolbar-highlight", DevToolbarHighlight);
|
|
36
|
+
customElements.define("astro-dev-toolbar-card", DevToolbarCard);
|
|
37
|
+
customElements.define("astro-dev-toolbar-toggle", DevToolbarToggle);
|
|
38
|
+
customElements.define("astro-dev-toolbar-button", DevToolbarButton);
|
|
39
|
+
customElements.define("astro-dev-toolbar-badge", DevToolbarBadge);
|
|
40
|
+
customElements.define("astro-dev-toolbar-icon", DevToolbarIcon);
|
|
41
41
|
const deprecated = (Parent) => class extends Parent {
|
|
42
42
|
};
|
|
43
|
-
customElements.define("astro-dev-overlay", deprecated(
|
|
44
|
-
customElements.define("astro-dev-overlay-window", deprecated(
|
|
45
|
-
customElements.define("astro-dev-overlay-plugin-canvas", deprecated(
|
|
46
|
-
customElements.define("astro-dev-overlay-tooltip", deprecated(
|
|
47
|
-
customElements.define("astro-dev-overlay-highlight", deprecated(
|
|
48
|
-
customElements.define("astro-dev-overlay-card", deprecated(
|
|
49
|
-
customElements.define("astro-dev-overlay-toggle", deprecated(
|
|
50
|
-
customElements.define("astro-dev-overlay-button", deprecated(
|
|
51
|
-
customElements.define("astro-dev-overlay-badge", deprecated(
|
|
52
|
-
customElements.define("astro-dev-overlay-icon", deprecated(
|
|
43
|
+
customElements.define("astro-dev-overlay", deprecated(AstroDevToolbar));
|
|
44
|
+
customElements.define("astro-dev-overlay-window", deprecated(DevToolbarWindow));
|
|
45
|
+
customElements.define("astro-dev-overlay-plugin-canvas", deprecated(DevToolbarCanvas));
|
|
46
|
+
customElements.define("astro-dev-overlay-tooltip", deprecated(DevToolbarTooltip));
|
|
47
|
+
customElements.define("astro-dev-overlay-highlight", deprecated(DevToolbarHighlight));
|
|
48
|
+
customElements.define("astro-dev-overlay-card", deprecated(DevToolbarCard));
|
|
49
|
+
customElements.define("astro-dev-overlay-toggle", deprecated(DevToolbarToggle));
|
|
50
|
+
customElements.define("astro-dev-overlay-button", deprecated(DevToolbarButton));
|
|
51
|
+
customElements.define("astro-dev-overlay-badge", deprecated(DevToolbarBadge));
|
|
52
|
+
customElements.define("astro-dev-overlay-icon", deprecated(DevToolbarIcon));
|
|
53
53
|
overlay = document.createElement("astro-dev-toolbar");
|
|
54
|
-
const
|
|
54
|
+
const prepareApp = (appDefinition, builtIn) => {
|
|
55
55
|
const eventTarget = new EventTarget();
|
|
56
|
-
const
|
|
57
|
-
...
|
|
56
|
+
const app = {
|
|
57
|
+
...appDefinition,
|
|
58
58
|
builtIn,
|
|
59
59
|
active: false,
|
|
60
60
|
status: "loading",
|
|
@@ -62,14 +62,14 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
62
62
|
eventTarget
|
|
63
63
|
};
|
|
64
64
|
eventTarget.addEventListener("toggle-notification", (evt) => {
|
|
65
|
-
const target = overlay.shadowRoot?.querySelector(`[data-
|
|
65
|
+
const target = overlay.shadowRoot?.querySelector(`[data-app-id="${app.id}"]`);
|
|
66
66
|
if (!target)
|
|
67
67
|
return;
|
|
68
68
|
let newState = true;
|
|
69
69
|
if (evt instanceof CustomEvent) {
|
|
70
70
|
newState = evt.detail.state ?? true;
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
app.notification.state = newState;
|
|
73
73
|
target.querySelector(".notification")?.toggleAttribute("data-active", newState);
|
|
74
74
|
});
|
|
75
75
|
const onToggleApp = async (evt) => {
|
|
@@ -77,18 +77,18 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
77
77
|
if (evt instanceof CustomEvent) {
|
|
78
78
|
newState = evt.detail.state ?? true;
|
|
79
79
|
}
|
|
80
|
-
await overlay.
|
|
80
|
+
await overlay.setAppStatus(app, newState);
|
|
81
81
|
};
|
|
82
82
|
eventTarget.addEventListener("toggle-app", onToggleApp);
|
|
83
83
|
eventTarget.addEventListener("toggle-plugin", onToggleApp);
|
|
84
|
-
return
|
|
84
|
+
return app;
|
|
85
85
|
};
|
|
86
|
-
const
|
|
86
|
+
const astroMoreApp = {
|
|
87
87
|
id: "astro:more",
|
|
88
88
|
name: "More",
|
|
89
89
|
icon: "dots-three",
|
|
90
90
|
init(canvas, eventTarget) {
|
|
91
|
-
const
|
|
91
|
+
const hiddenApps = apps.filter((p) => !p.builtIn).slice(overlay.customAppsToShow);
|
|
92
92
|
createDropdown();
|
|
93
93
|
document.addEventListener("astro:after-swap", createDropdown);
|
|
94
94
|
function createDropdown() {
|
|
@@ -165,35 +165,35 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
165
165
|
canvas.append(style);
|
|
166
166
|
const dropdown = document.createElement("div");
|
|
167
167
|
dropdown.id = "dropdown";
|
|
168
|
-
dropdown.toggleAttribute("data-no-notification", settings.config.
|
|
169
|
-
for (const
|
|
168
|
+
dropdown.toggleAttribute("data-no-notification", settings.config.disableAppNotification);
|
|
169
|
+
for (const app of hiddenApps) {
|
|
170
170
|
const buttonContainer = document.createElement("div");
|
|
171
171
|
buttonContainer.classList.add("item");
|
|
172
172
|
const button = document.createElement("button");
|
|
173
|
-
button.setAttribute("data-
|
|
173
|
+
button.setAttribute("data-app-id", app.id);
|
|
174
174
|
const iconContainer = document.createElement("div");
|
|
175
175
|
const iconElement = document.createElement("template");
|
|
176
|
-
iconElement.innerHTML =
|
|
176
|
+
iconElement.innerHTML = getAppIcon(app.icon);
|
|
177
177
|
iconContainer.append(iconElement.content.cloneNode(true));
|
|
178
178
|
const notification = document.createElement("div");
|
|
179
179
|
notification.classList.add("notification");
|
|
180
180
|
iconContainer.append(notification);
|
|
181
181
|
iconContainer.classList.add("icon");
|
|
182
182
|
button.append(iconContainer);
|
|
183
|
-
button.append(document.createTextNode(
|
|
183
|
+
button.append(document.createTextNode(app.name));
|
|
184
184
|
button.addEventListener("click", () => {
|
|
185
|
-
overlay.
|
|
185
|
+
overlay.toggleAppStatus(app);
|
|
186
186
|
});
|
|
187
187
|
buttonContainer.append(button);
|
|
188
188
|
dropdown.append(buttonContainer);
|
|
189
|
-
|
|
189
|
+
app.eventTarget.addEventListener("toggle-notification", (evt) => {
|
|
190
190
|
if (!(evt instanceof CustomEvent))
|
|
191
191
|
return;
|
|
192
192
|
notification.toggleAttribute("data-active", evt.detail.state ?? true);
|
|
193
193
|
eventTarget.dispatchEvent(
|
|
194
194
|
new CustomEvent("toggle-notification", {
|
|
195
195
|
detail: {
|
|
196
|
-
state:
|
|
196
|
+
state: hiddenApps.some((p) => p.notification.state === true)
|
|
197
197
|
}
|
|
198
198
|
})
|
|
199
199
|
);
|
|
@@ -203,17 +203,13 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
};
|
|
206
|
-
const
|
|
207
|
-
...[
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
astroSettingsPlugin,
|
|
212
|
-
astromorePlugin
|
|
213
|
-
].map((pluginDef) => preparePlugin(pluginDef, true)),
|
|
214
|
-
...customPluginsDefinitions.map((pluginDef) => preparePlugin(pluginDef, false))
|
|
206
|
+
const apps = [
|
|
207
|
+
...[astroDevToolApp, astroXrayApp, astroAuditApp, astroSettingsApp, astroMoreApp].map(
|
|
208
|
+
(appDef) => prepareApp(appDef, true)
|
|
209
|
+
),
|
|
210
|
+
...customAppsDefinitions.map((appDef) => prepareApp(appDef, false))
|
|
215
211
|
];
|
|
216
|
-
overlay.
|
|
212
|
+
overlay.apps = apps;
|
|
217
213
|
document.body.append(overlay);
|
|
218
214
|
document.addEventListener("astro:after-swap", () => {
|
|
219
215
|
document.body.append(overlay);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export interface Settings {
|
|
2
|
-
|
|
2
|
+
disableAppNotification: boolean;
|
|
3
3
|
verbose: boolean;
|
|
4
4
|
}
|
|
5
5
|
export declare const defaultSettings: {
|
|
6
|
-
|
|
6
|
+
disableAppNotification: false;
|
|
7
7
|
verbose: false;
|
|
8
8
|
};
|
|
9
9
|
export declare const settings: {
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
const defaultSettings = {
|
|
2
|
-
|
|
2
|
+
disableAppNotification: false,
|
|
3
3
|
verbose: false
|
|
4
4
|
};
|
|
5
5
|
const settings = getSettings();
|
|
6
6
|
function getSettings() {
|
|
7
7
|
let _settings = { ...defaultSettings };
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const toolbarSettings = localStorage.getItem("astro:dev-toolbar:settings");
|
|
9
|
+
const oldSettings = localStorage.getItem("astro:dev-overlay:settings");
|
|
10
|
+
if (oldSettings && !toolbarSettings) {
|
|
11
|
+
localStorage.setItem("astro:dev-toolbar:settings", oldSettings);
|
|
12
|
+
localStorage.removeItem("astro:dev-overlay:settings");
|
|
13
|
+
}
|
|
14
|
+
if (toolbarSettings) {
|
|
15
|
+
_settings = { ..._settings, ...JSON.parse(toolbarSettings) };
|
|
11
16
|
}
|
|
12
17
|
function updateSetting(key, value) {
|
|
13
18
|
_settings[key] = value;
|
|
14
|
-
localStorage.setItem("astro:dev-
|
|
19
|
+
localStorage.setItem("astro:dev-toolbar:settings", JSON.stringify(_settings));
|
|
15
20
|
}
|
|
16
21
|
function log(message) {
|
|
17
22
|
console.log(
|