mirror of
https://github.com/withastro/astro.git
synced 2025-02-17 22:44:24 -05:00
feat: unflag dev overlay (#9232)
* feat: unflag dev overlay * fix: oops * fix: check for both config existing * fix: don't use flag in e2e tests * Disable view transition tests * Disable more * even more --------- Co-authored-by: Matthew Phillips <matthew@skypack.dev>
This commit is contained in:
parent
8bfc205119
commit
34e96b141a
15 changed files with 88 additions and 33 deletions
|
@ -1,7 +1,12 @@
|
||||||
import { expect } from '@playwright/test';
|
import { expect } from '@playwright/test';
|
||||||
import { testFactory } from './test-utils.js';
|
import { testFactory } from './test-utils.js';
|
||||||
|
|
||||||
const test = testFactory({ root: './fixtures/astro-envs/' });
|
const test = testFactory({
|
||||||
|
root: './fixtures/astro-envs/',
|
||||||
|
devOverlay: {
|
||||||
|
enabled: false,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let devServer;
|
let devServer;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,9 @@ import { testFactory } from './test-utils.js';
|
||||||
|
|
||||||
const test = testFactory({
|
const test = testFactory({
|
||||||
root: './fixtures/css/',
|
root: './fixtures/css/',
|
||||||
|
devOverlay: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
let devServer;
|
let devServer;
|
||||||
|
|
|
@ -3,5 +3,8 @@ import preact from '@astrojs/preact'
|
||||||
|
|
||||||
// https://astro.build/config
|
// https://astro.build/config
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
integrations: [preact()]
|
integrations: [preact()],
|
||||||
|
devOverlay: {
|
||||||
|
enabled: false,
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,5 +5,8 @@ import vue from '@astrojs/vue';
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
site: 'http://example.com',
|
site: 'http://example.com',
|
||||||
base: '/blog',
|
base: '/blog',
|
||||||
|
devOverlay: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
integrations: [vue()],
|
integrations: [vue()],
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,7 +2,4 @@ import preact from '@astrojs/preact';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
integrations: [preact()],
|
integrations: [preact()],
|
||||||
experimental: {
|
|
||||||
devOverlay: true
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,4 +4,7 @@ import lit from '@astrojs/lit';
|
||||||
// https://astro.build/config
|
// https://astro.build/config
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
integrations: [lit()],
|
integrations: [lit()],
|
||||||
|
devOverlay: {
|
||||||
|
enabled: false,
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,5 +2,8 @@ import { defineConfig } from 'astro/config';
|
||||||
|
|
||||||
// https://astro.build/config
|
// https://astro.build/config
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
devOverlay: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
prefetch: true
|
prefetch: true
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,6 +9,9 @@ export default defineConfig({
|
||||||
configFile: fileURLToPath(new URL('./tailwind.config.js', import.meta.url)),
|
configFile: fileURLToPath(new URL('./tailwind.config.js', import.meta.url)),
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
devOverlay: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
vite: {
|
vite: {
|
||||||
build: {
|
build: {
|
||||||
assetsInlineLimit: 0,
|
assetsInlineLimit: 0,
|
||||||
|
|
|
@ -13,6 +13,9 @@ export default defineConfig({
|
||||||
'/redirect-two': '/two',
|
'/redirect-two': '/two',
|
||||||
'/redirect-external': 'http://example.com/',
|
'/redirect-external': 'http://example.com/',
|
||||||
},
|
},
|
||||||
|
devOverlay: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
vite: {
|
vite: {
|
||||||
build: {
|
build: {
|
||||||
assetsInlineLimit: 0,
|
assetsInlineLimit: 0,
|
||||||
|
|
|
@ -3,6 +3,9 @@ import { testFactory } from './test-utils.js';
|
||||||
|
|
||||||
const test = testFactory({
|
const test = testFactory({
|
||||||
root: './fixtures/hmr/',
|
root: './fixtures/hmr/',
|
||||||
|
devOverlay: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
let devServer;
|
let devServer;
|
||||||
|
|
|
@ -1154,6 +1154,34 @@ export interface AstroUserConfig {
|
||||||
remotePatterns?: Partial<RemotePattern>[];
|
remotePatterns?: Partial<RemotePattern>[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @docs
|
||||||
|
* @kind heading
|
||||||
|
* @name Dev Overlay Options
|
||||||
|
*/
|
||||||
|
devOverlay?: {
|
||||||
|
/**
|
||||||
|
* @docs
|
||||||
|
* @name devOverlay.enabled
|
||||||
|
* @type {boolean}
|
||||||
|
* @default `true`
|
||||||
|
* @description
|
||||||
|
* Whether to enable the dev overlay. This overlay allows you to inspect your page islands, see helpful audits on performance and accessibility, and more.
|
||||||
|
*
|
||||||
|
* This option is scoped to the entire project, to only disable the overlay for yourself, run `npm run astro preferences disable devOverlay`. To disable the overlay for all your Astro projects, run `npm run astro preferences disable devOverlay --global`.
|
||||||
|
*/
|
||||||
|
enabled: boolean;
|
||||||
|
/**
|
||||||
|
* @docs
|
||||||
|
* @name devOverlay.defaultState
|
||||||
|
* @type {'minimized' | 'expanded'}
|
||||||
|
* @default `minimized`
|
||||||
|
* @description
|
||||||
|
* Whether the dev overlay should be expanded or minimized by default.
|
||||||
|
*/
|
||||||
|
defaultState: 'minimized' | 'expanded';
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @docs
|
* @docs
|
||||||
* @kind heading
|
* @kind heading
|
||||||
|
@ -1379,25 +1407,6 @@ export interface AstroUserConfig {
|
||||||
*/
|
*/
|
||||||
optimizeHoistedScript?: boolean;
|
optimizeHoistedScript?: boolean;
|
||||||
|
|
||||||
/**
|
|
||||||
* @docs
|
|
||||||
* @name experimental.devOverlay
|
|
||||||
* @type {boolean}
|
|
||||||
* @default `false`
|
|
||||||
* @version 3.4.0
|
|
||||||
* @description
|
|
||||||
* Enable a dev overlay in development mode. This overlay allows you to inspect your page islands, see helpful audits on performance and accessibility, and more.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* {
|
|
||||||
* experimental: {
|
|
||||||
* devOverlay: true,
|
|
||||||
* },
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
devOverlay?: boolean;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @docs
|
* @docs
|
||||||
* @name experimental.i18n
|
* @name experimental.i18n
|
||||||
|
@ -2517,6 +2526,7 @@ export interface DevOverlayPlugin {
|
||||||
export type DevOverlayMetadata = Window &
|
export type DevOverlayMetadata = Window &
|
||||||
typeof globalThis & {
|
typeof globalThis & {
|
||||||
__astro_dev_overlay__: {
|
__astro_dev_overlay__: {
|
||||||
|
defaultState: AstroConfig['devOverlay']['defaultState'];
|
||||||
root: string;
|
root: string;
|
||||||
version: string;
|
version: string;
|
||||||
debugInfo: string;
|
debugInfo: string;
|
||||||
|
|
|
@ -46,7 +46,8 @@ export async function compile({
|
||||||
scopedStyleStrategy: astroConfig.scopedStyleStrategy,
|
scopedStyleStrategy: astroConfig.scopedStyleStrategy,
|
||||||
resultScopedSlot: true,
|
resultScopedSlot: true,
|
||||||
transitionsAnimationURL: 'astro/components/viewtransitions.css',
|
transitionsAnimationURL: 'astro/components/viewtransitions.css',
|
||||||
annotateSourceFile: !viteConfig.isProduction && astroConfig.experimental.devOverlay,
|
annotateSourceFile:
|
||||||
|
!viteConfig.isProduction && astroConfig.devOverlay && astroConfig.devOverlay.enabled,
|
||||||
preprocessStyle: createStylePreprocessor({
|
preprocessStyle: createStylePreprocessor({
|
||||||
filename,
|
filename,
|
||||||
viteConfig,
|
viteConfig,
|
||||||
|
|
|
@ -41,6 +41,10 @@ const ASTRO_CONFIG_DEFAULTS = {
|
||||||
image: {
|
image: {
|
||||||
service: { entrypoint: 'astro/assets/services/sharp', config: {} },
|
service: { entrypoint: 'astro/assets/services/sharp', config: {} },
|
||||||
},
|
},
|
||||||
|
devOverlay: {
|
||||||
|
enabled: true,
|
||||||
|
defaultState: 'minimized',
|
||||||
|
},
|
||||||
compressHTML: true,
|
compressHTML: true,
|
||||||
server: {
|
server: {
|
||||||
host: false,
|
host: false,
|
||||||
|
@ -54,7 +58,6 @@ const ASTRO_CONFIG_DEFAULTS = {
|
||||||
redirects: {},
|
redirects: {},
|
||||||
experimental: {
|
experimental: {
|
||||||
optimizeHoistedScript: false,
|
optimizeHoistedScript: false,
|
||||||
devOverlay: false,
|
|
||||||
contentCollectionCache: false,
|
contentCollectionCache: false,
|
||||||
},
|
},
|
||||||
} satisfies AstroUserConfig & { server: { open: boolean } };
|
} satisfies AstroUserConfig & { server: { open: boolean } };
|
||||||
|
@ -223,6 +226,14 @@ export const AstroConfigSchema = z.object({
|
||||||
.default([]),
|
.default([]),
|
||||||
})
|
})
|
||||||
.default(ASTRO_CONFIG_DEFAULTS.image),
|
.default(ASTRO_CONFIG_DEFAULTS.image),
|
||||||
|
devOverlay: z
|
||||||
|
.object({
|
||||||
|
enabled: z.boolean().default(ASTRO_CONFIG_DEFAULTS.devOverlay.enabled),
|
||||||
|
defaultState: z
|
||||||
|
.enum(['minimized', 'expanded'])
|
||||||
|
.default(ASTRO_CONFIG_DEFAULTS.devOverlay.defaultState),
|
||||||
|
})
|
||||||
|
.default(ASTRO_CONFIG_DEFAULTS.devOverlay),
|
||||||
markdown: z
|
markdown: z
|
||||||
.object({
|
.object({
|
||||||
syntaxHighlight: z
|
syntaxHighlight: z
|
||||||
|
@ -299,7 +310,6 @@ export const AstroConfigSchema = z.object({
|
||||||
.boolean()
|
.boolean()
|
||||||
.optional()
|
.optional()
|
||||||
.default(ASTRO_CONFIG_DEFAULTS.experimental.optimizeHoistedScript),
|
.default(ASTRO_CONFIG_DEFAULTS.experimental.optimizeHoistedScript),
|
||||||
devOverlay: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.devOverlay),
|
|
||||||
i18n: z.optional(
|
i18n: z.optional(
|
||||||
z
|
z
|
||||||
.object({
|
.object({
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
import type { DevOverlayPlugin as DevOverlayPluginDefinition } from '../../../@types/astro.js';
|
import type {
|
||||||
|
DevOverlayMetadata,
|
||||||
|
DevOverlayPlugin as DevOverlayPluginDefinition,
|
||||||
|
} from '../../../@types/astro.js';
|
||||||
import { settings } from './settings.js';
|
import { settings } from './settings.js';
|
||||||
import { getIconElement, isDefinedIcon, type Icon } from './ui-library/icons.js';
|
import { getIconElement, isDefinedIcon, type Icon } from './ui-library/icons.js';
|
||||||
|
|
||||||
|
@ -23,6 +26,7 @@ export class AstroDevOverlay extends HTMLElement {
|
||||||
plugins: DevOverlayPlugin[] = [];
|
plugins: DevOverlayPlugin[] = [];
|
||||||
HOVER_DELAY = 750;
|
HOVER_DELAY = 750;
|
||||||
hasBeenInitialized = false;
|
hasBeenInitialized = false;
|
||||||
|
// TODO: This should be dynamic based on the screen size or at least configurable, erika - 2023-11-29
|
||||||
customPluginsToShow = 3;
|
customPluginsToShow = 3;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -257,7 +261,12 @@ export class AstroDevOverlay extends HTMLElement {
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div id="dev-overlay">
|
<div id="dev-overlay"${
|
||||||
|
((window as DevOverlayMetadata)?.__astro_dev_overlay__?.defaultState ?? 'minimized') ===
|
||||||
|
'minimized'
|
||||||
|
? ' data-hidden '
|
||||||
|
: ''
|
||||||
|
}>
|
||||||
<div id="dev-bar">
|
<div id="dev-bar">
|
||||||
<div id="bar-container">
|
<div id="bar-container">
|
||||||
${this.plugins
|
${this.plugins
|
||||||
|
|
|
@ -12,8 +12,8 @@ import type {
|
||||||
import { getInfoOutput } from '../cli/info/index.js';
|
import { getInfoOutput } from '../cli/info/index.js';
|
||||||
import { ASTRO_VERSION } from '../core/constants.js';
|
import { ASTRO_VERSION } from '../core/constants.js';
|
||||||
import { AstroErrorData, isAstroError } from '../core/errors/index.js';
|
import { AstroErrorData, isAstroError } from '../core/errors/index.js';
|
||||||
import { sequence } from '../core/middleware/index.js';
|
|
||||||
import { req } from '../core/messages.js';
|
import { req } from '../core/messages.js';
|
||||||
|
import { sequence } from '../core/middleware/index.js';
|
||||||
import { loadMiddleware } from '../core/middleware/loadMiddleware.js';
|
import { loadMiddleware } from '../core/middleware/loadMiddleware.js';
|
||||||
import {
|
import {
|
||||||
createRenderContext,
|
createRenderContext,
|
||||||
|
@ -384,7 +384,7 @@ async function getScriptsAndStyles({ pipeline, filePath }: GetScriptsAndStylesPa
|
||||||
children: '',
|
children: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
if (settings.config.experimental.devOverlay) {
|
if (settings.config.devOverlay.enabled) {
|
||||||
scripts.add({
|
scripts.add({
|
||||||
props: {
|
props: {
|
||||||
type: 'module',
|
type: 'module',
|
||||||
|
@ -394,13 +394,12 @@ async function getScriptsAndStyles({ pipeline, filePath }: GetScriptsAndStylesPa
|
||||||
});
|
});
|
||||||
|
|
||||||
const additionalMetadata: DevOverlayMetadata['__astro_dev_overlay__'] = {
|
const additionalMetadata: DevOverlayMetadata['__astro_dev_overlay__'] = {
|
||||||
|
defaultState: settings.config.devOverlay.defaultState,
|
||||||
root: fileURLToPath(settings.config.root),
|
root: fileURLToPath(settings.config.root),
|
||||||
version: ASTRO_VERSION,
|
version: ASTRO_VERSION,
|
||||||
debugInfo: await getInfoOutput({ userConfig: settings.config, print: false }),
|
debugInfo: await getInfoOutput({ userConfig: settings.config, print: false }),
|
||||||
};
|
};
|
||||||
|
|
||||||
settings.config;
|
|
||||||
|
|
||||||
// Additional data for the dev overlay
|
// Additional data for the dev overlay
|
||||||
scripts.add({
|
scripts.add({
|
||||||
props: {},
|
props: {},
|
||||||
|
|
Loading…
Add table
Reference in a new issue