astro 1.0.0-beta.44 → 1.0.0-beta.47

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.
Files changed (56) hide show
  1. package/dist/cli/index.js +8 -8
  2. package/dist/core/add/consts.js +2 -1
  3. package/dist/core/app/index.js +1 -1
  4. package/dist/core/build/index.js +2 -1
  5. package/dist/core/build/static-build.js +0 -1
  6. package/dist/core/config.js +1 -1
  7. package/dist/core/create-vite.js +0 -1
  8. package/dist/core/dev/index.js +1 -1
  9. package/dist/core/messages.js +3 -3
  10. package/dist/core/render/result.js +1 -0
  11. package/dist/core/routing/manifest/create.js +64 -13
  12. package/dist/core/routing/manifest/serialization.js +1 -0
  13. package/dist/integrations/index.js +22 -10
  14. package/dist/runtime/client/events.js +1 -5
  15. package/dist/runtime/client/hmr.js +3 -3
  16. package/dist/{@types/serialize-javascript.d.js → runtime/client/hydration-directives.d.js} +0 -0
  17. package/dist/runtime/client/idle.js +9 -43
  18. package/dist/runtime/client/idle.prebuilt.js +4 -0
  19. package/dist/runtime/client/load.js +5 -37
  20. package/dist/runtime/client/load.prebuilt.js +4 -0
  21. package/dist/runtime/client/media.js +11 -45
  22. package/dist/runtime/client/media.prebuilt.js +4 -0
  23. package/dist/runtime/client/only.js +5 -37
  24. package/dist/runtime/client/only.prebuilt.js +4 -0
  25. package/dist/runtime/client/visible.js +15 -55
  26. package/dist/runtime/client/visible.prebuilt.js +4 -0
  27. package/dist/runtime/server/astro-island.js +70 -0
  28. package/dist/runtime/server/astro-island.prebuilt.js +4 -0
  29. package/dist/runtime/server/hydration.js +23 -21
  30. package/dist/runtime/server/index.js +20 -5
  31. package/dist/runtime/server/metadata.js +0 -12
  32. package/dist/runtime/server/scripts.js +55 -0
  33. package/dist/runtime/server/serialize.js +57 -0
  34. package/dist/runtime/server/util.js +0 -4
  35. package/dist/types/@types/astro.d.ts +12 -5
  36. package/dist/types/core/add/consts.d.ts +1 -1
  37. package/dist/types/runtime/client/events.d.ts +0 -1
  38. package/dist/types/runtime/client/idle.d.ts +0 -6
  39. package/dist/types/runtime/client/idle.prebuilt.d.ts +7 -0
  40. package/dist/types/runtime/client/load.d.ts +0 -5
  41. package/dist/types/runtime/client/load.prebuilt.d.ts +7 -0
  42. package/dist/types/runtime/client/media.d.ts +0 -5
  43. package/dist/types/runtime/client/media.prebuilt.d.ts +7 -0
  44. package/dist/types/runtime/client/only.d.ts +0 -5
  45. package/dist/types/runtime/client/only.prebuilt.d.ts +7 -0
  46. package/dist/types/runtime/client/visible.d.ts +0 -7
  47. package/dist/types/runtime/client/visible.prebuilt.d.ts +7 -0
  48. package/dist/types/runtime/server/astro-island.d.ts +4 -0
  49. package/dist/types/runtime/server/astro-island.prebuilt.d.ts +7 -0
  50. package/dist/types/runtime/server/hydration.d.ts +0 -1
  51. package/dist/types/runtime/server/metadata.d.ts +0 -4
  52. package/dist/types/runtime/server/scripts.d.ts +6 -0
  53. package/dist/types/runtime/server/serialize.d.ts +1 -0
  54. package/dist/types/runtime/server/util.d.ts +0 -6
  55. package/dist/vite-plugin-build-css/index.js +1 -1
  56. package/package.json +5 -5
package/dist/cli/index.js CHANGED
@@ -40,7 +40,7 @@ function printAstroHelp() {
40
40
  });
41
41
  }
42
42
  async function printVersion() {
43
- const version = "1.0.0-beta.44";
43
+ const version = "1.0.0-beta.47";
44
44
  console.log();
45
45
  console.log(` ${colors.bgGreen(colors.black(` astro `))} ${colors.green(`v${version}`)}`);
46
46
  }
@@ -83,7 +83,7 @@ async function cli(args) {
83
83
  } else if (flags.silent) {
84
84
  logging.level = "silent";
85
85
  }
86
- const telemetry = new AstroTelemetry({ version: "1.0.0-beta.44" });
86
+ const telemetry = new AstroTelemetry({ version: "1.0.0-beta.47" });
87
87
  if (cmd === "telemetry") {
88
88
  try {
89
89
  const subcommand = (_a = flags._[3]) == null ? void 0 : _a.toString();
@@ -97,7 +97,7 @@ async function cli(args) {
97
97
  try {
98
98
  const packages = flags._.slice(3);
99
99
  telemetry.record(event.eventCliSession({
100
- astroVersion: "1.0.0-beta.44",
100
+ astroVersion: "1.0.0-beta.47",
101
101
  cliCommand: "add"
102
102
  }));
103
103
  return await add(packages, { cwd: root, flags, logging, telemetry });
@@ -108,7 +108,7 @@ async function cli(args) {
108
108
  case "dev": {
109
109
  try {
110
110
  const { astroConfig, userConfig } = await openConfig({ cwd: root, flags, cmd });
111
- telemetry.record(event.eventCliSession({ astroVersion: "1.0.0-beta.44", cliCommand: "dev" }, userConfig, flags));
111
+ telemetry.record(event.eventCliSession({ astroVersion: "1.0.0-beta.47", cliCommand: "dev" }, userConfig, flags));
112
112
  await devServer(astroConfig, { logging, telemetry });
113
113
  return await new Promise(() => {
114
114
  });
@@ -119,7 +119,7 @@ async function cli(args) {
119
119
  case "build": {
120
120
  try {
121
121
  const { astroConfig, userConfig } = await openConfig({ cwd: root, flags, cmd });
122
- telemetry.record(event.eventCliSession({ astroVersion: "1.0.0-beta.44", cliCommand: "build" }, userConfig, flags));
122
+ telemetry.record(event.eventCliSession({ astroVersion: "1.0.0-beta.47", cliCommand: "build" }, userConfig, flags));
123
123
  return await build(astroConfig, { logging, telemetry });
124
124
  } catch (err) {
125
125
  return throwAndExit(err);
@@ -127,14 +127,14 @@ async function cli(args) {
127
127
  }
128
128
  case "check": {
129
129
  const { astroConfig, userConfig } = await openConfig({ cwd: root, flags, cmd });
130
- telemetry.record(event.eventCliSession({ astroVersion: "1.0.0-beta.44", cliCommand: "check" }, userConfig, flags));
130
+ telemetry.record(event.eventCliSession({ astroVersion: "1.0.0-beta.47", cliCommand: "check" }, userConfig, flags));
131
131
  const ret = await check(astroConfig);
132
132
  return process.exit(ret);
133
133
  }
134
134
  case "preview": {
135
135
  try {
136
136
  const { astroConfig, userConfig } = await openConfig({ cwd: root, flags, cmd });
137
- telemetry.record(event.eventCliSession({ astroVersion: "1.0.0-beta.44", cliCommand: "preview" }, userConfig, flags));
137
+ telemetry.record(event.eventCliSession({ astroVersion: "1.0.0-beta.47", cliCommand: "preview" }, userConfig, flags));
138
138
  const server = await preview(astroConfig, { logging, telemetry });
139
139
  return await server.closed();
140
140
  } catch (err) {
@@ -144,7 +144,7 @@ async function cli(args) {
144
144
  case "docs": {
145
145
  try {
146
146
  await telemetry.record(event.eventCliSession({
147
- astroVersion: "1.0.0-beta.44",
147
+ astroVersion: "1.0.0-beta.47",
148
148
  cliCommand: "docs"
149
149
  }));
150
150
  return await openInBrowser("https://docs.astro.build/");
@@ -19,7 +19,8 @@ const ALIASES = /* @__PURE__ */ new Map([
19
19
  const CONFIG_STUB = `import { defineConfig } from 'astro/config';
20
20
 
21
21
  export default defineConfig({});`;
22
- const TAILWIND_CONFIG_STUB = `module.exports = {
22
+ const TAILWIND_CONFIG_STUB = `/** @type {import('tailwindcss').Config} */
23
+ module.exports = {
23
24
  content: ['./src/**/*.{astro,html,js,jsx,md,svelte,ts,tsx,vue}'],
24
25
  theme: {
25
26
  extend: {},
@@ -92,7 +92,7 @@ renderPage_fn = async function(request, routeData, mod) {
92
92
  const renderers = manifest.renderers;
93
93
  const info = __privateGet(this, _routeDataToRouteInfo).get(routeData);
94
94
  const links = createLinkStylesheetElementSet(info.links, manifest.site);
95
- const filteredScripts = info.scripts.filter((script) => typeof script !== "string" && (script == null ? void 0 : script.stage) !== "head-inline");
95
+ const filteredScripts = info.scripts.filter((script) => typeof script === "string" || (script == null ? void 0 : script.stage) !== "head-inline");
96
96
  const scripts = createModuleScriptElementWithSrcSet(filteredScripts, manifest.site);
97
97
  for (const script of info.scripts) {
98
98
  if (typeof script !== "string" && script.stage === "head-inline") {
@@ -33,7 +33,7 @@ class AstroBuilder {
33
33
  this.logging = options.logging;
34
34
  this.routeCache = new RouteCache(this.logging);
35
35
  this.origin = config.site ? new URL(config.site).origin : `http://localhost:${config.server.port}`;
36
- this.manifest = createRouteManifest({ config }, this.logging);
36
+ this.manifest = { routes: [] };
37
37
  this.timer = {};
38
38
  }
39
39
  async setup() {
@@ -42,6 +42,7 @@ class AstroBuilder {
42
42
  this.timer.init = performance.now();
43
43
  this.timer.viteStart = performance.now();
44
44
  this.config = await runHookConfigSetup({ config: this.config, command: "build" });
45
+ this.manifest = createRouteManifest({ config: this.config }, this.logging);
45
46
  const viteConfig = await createVite({
46
47
  mode: this.mode,
47
48
  server: {
@@ -60,7 +60,6 @@ async function staticBuild(opts) {
60
60
  const topLevelImports = /* @__PURE__ */ new Set([
61
61
  ...metadata.hydratedComponentPaths(),
62
62
  ...clientOnlys,
63
- ...metadata.hydrationDirectiveSpecifiers(),
64
63
  ...renderers.filter((renderer) => !!renderer.clientEntrypoint).map((renderer) => renderer.clientEntrypoint)
65
64
  ]);
66
65
  const hoistedScripts = new Set(metadata.hoistedScriptPaths());
@@ -205,7 +205,7 @@ See https://astro.build/config for more information.`);
205
205
  }).optional().default({})
206
206
  });
207
207
  const result = __spreadProps(__spreadValues({}, await AstroConfigRelativeSchema.parseAsync(userConfig)), {
208
- _ctx: { scripts: [], renderers: [], adapter: void 0 }
208
+ _ctx: { scripts: [], renderers: [], injectedRoutes: [], adapter: void 0 }
209
209
  });
210
210
  if (!((_a = result.experimental) == null ? void 0 : _a.integrations) && !result.integrations.every((int) => int.name.startsWith("@astrojs/"))) {
211
211
  throw new Error([
@@ -16,7 +16,6 @@ const ALWAYS_EXTERNAL = /* @__PURE__ */ new Set([
16
16
  "@sveltejs/vite-plugin-svelte",
17
17
  "micromark-util-events-to-acorn",
18
18
  "@astrojs/markdown-remark",
19
- "serialize-javascript",
20
19
  "node-fetch",
21
20
  "prismjs",
22
21
  "shiki",
@@ -47,7 +47,7 @@ async function dev(config, options) {
47
47
  site,
48
48
  https: !!((_a = viteConfig.server) == null ? void 0 : _a.https)
49
49
  }));
50
- const currentVersion = "1.0.0-beta.44";
50
+ const currentVersion = "1.0.0-beta.47";
51
51
  if (currentVersion.includes("-")) {
52
52
  warn(options.logging, null, msg.prerelease({ currentVersion }));
53
53
  }
@@ -47,7 +47,7 @@ function devStart({
47
47
  https,
48
48
  site
49
49
  }) {
50
- const version = "1.0.0-beta.44";
50
+ const version = "1.0.0-beta.47";
51
51
  const rootPath = site ? site.pathname : "/";
52
52
  const localPrefix = `${dim("\u2503")} Local `;
53
53
  const networkPrefix = `${dim("\u2503")} Network `;
@@ -60,7 +60,7 @@ function devStart({
60
60
  if (networkLogging === "host-to-expose") {
61
61
  network = `${networkPrefix}${dim("use --host to expose")}`;
62
62
  } else if (networkLogging === "visible") {
63
- const ipv4Networks = Object.values(os.networkInterfaces()).flatMap((networkInterface) => networkInterface ?? []).filter((networkInterface) => (networkInterface == null ? void 0 : networkInterface.address) && (networkInterface == null ? void 0 : networkInterface.family) === "IPv4");
63
+ const ipv4Networks = Object.values(os.networkInterfaces()).flatMap((networkInterface) => networkInterface ?? []).filter((networkInterface) => (networkInterface == null ? void 0 : networkInterface.address) && (networkInterface == null ? void 0 : networkInterface.family) === (Number(process.version.substring(1, 5)) < 18.1 ? "IPv4" : 4));
64
64
  for (let { address } of ipv4Networks) {
65
65
  if (address.includes("127.0.0.1")) {
66
66
  const displayAddress = address.replace("127.0.0.1", localAddress);
@@ -207,7 +207,7 @@ function printHelp({
207
207
  };
208
208
  let message = [];
209
209
  if (headline) {
210
- message.push(linebreak(), ` ${bgGreen(black(` ${commandName} `))} ${green(`v${"1.0.0-beta.44"}`)} ${headline}`);
210
+ message.push(linebreak(), ` ${bgGreen(black(` ${commandName} `))} ${green(`v${"1.0.0-beta.47"}`)} ${headline}`);
211
211
  }
212
212
  if (usage) {
213
213
  message.push(linebreak(), ` ${green(commandName)} ${bold(usage)}`);
@@ -190,6 +190,7 @@ ${extra}`);
190
190
  },
191
191
  resolve,
192
192
  _metadata: {
193
+ needsHydrationStyles: false,
193
194
  renderers,
194
195
  pathname
195
196
  },
@@ -1,10 +1,12 @@
1
1
  import fs from "fs";
2
+ import { createRequire } from "module";
2
3
  import path from "path";
3
4
  import slash from "slash";
4
5
  import { fileURLToPath } from "url";
5
6
  import { warn } from "../../logger/core.js";
6
7
  import { resolvePages } from "../../util.js";
7
8
  import { getRouteGenerator } from "./generator.js";
9
+ const require2 = createRequire(import.meta.url);
8
10
  function countOccurrences(needle, haystack) {
9
11
  let count = 0;
10
12
  for (let i = 0; i < haystack.length; i += 1) {
@@ -54,6 +56,22 @@ function isSpread(str) {
54
56
  const spreadPattern = /\[\.{3}/g;
55
57
  return spreadPattern.test(str);
56
58
  }
59
+ function validateSegment(segment, file = "") {
60
+ if (!file)
61
+ file = segment;
62
+ if (/^\$/.test(segment)) {
63
+ throw new Error(`Invalid route ${file} \u2014 Astro's Collections API has been replaced by dynamic route params.`);
64
+ }
65
+ if (/\]\[/.test(segment)) {
66
+ throw new Error(`Invalid route ${file} \u2014 parameters must be separated`);
67
+ }
68
+ if (countOccurrences("[", segment) !== countOccurrences("]", segment)) {
69
+ throw new Error(`Invalid route ${file} \u2014 brackets are unbalanced`);
70
+ }
71
+ if (/.+\[\.\.\.[^\]]+\]/.test(segment) || /\[\.\.\.[^\]]+\].+/.test(segment)) {
72
+ throw new Error(`Invalid route ${file} \u2014 rest parameter must be a standalone segment`);
73
+ }
74
+ }
57
75
  function comparator(a, b) {
58
76
  if (a.isIndex !== b.isIndex) {
59
77
  if (a.isIndex)
@@ -86,6 +104,7 @@ function comparator(a, b) {
86
104
  return a.file < b.file ? -1 : 1;
87
105
  }
88
106
  function createRouteManifest({ config, cwd }, logging) {
107
+ var _a, _b, _c, _d;
89
108
  const components = [];
90
109
  const routes = [];
91
110
  const validPageExtensions = /* @__PURE__ */ new Set([".astro", ".md"]);
@@ -108,18 +127,7 @@ function createRouteManifest({ config, cwd }, logging) {
108
127
  return;
109
128
  }
110
129
  const segment = isDir ? basename : name;
111
- if (/^\$/.test(segment)) {
112
- throw new Error(`Invalid route ${file} \u2014 Astro's Collections API has been replaced by dynamic route params.`);
113
- }
114
- if (/\]\[/.test(segment)) {
115
- throw new Error(`Invalid route ${file} \u2014 parameters must be separated`);
116
- }
117
- if (countOccurrences("[", segment) !== countOccurrences("]", segment)) {
118
- throw new Error(`Invalid route ${file} \u2014 brackets are unbalanced`);
119
- }
120
- if (/.+\[\.\.\.[^\]]+\]/.test(segment) || /\[\.\.\.[^\]]+\].+/.test(segment)) {
121
- throw new Error(`Invalid route ${file} \u2014 rest parameter must be a standalone segment`);
122
- }
130
+ validateSegment(segment, file);
123
131
  const parts = getParts(segment, file);
124
132
  const isIndex = isDir ? false : basename.startsWith("index.");
125
133
  const routeSuffix = basename.slice(basename.indexOf("."), -ext.length);
@@ -175,7 +183,9 @@ function createRouteManifest({ config, cwd }, logging) {
175
183
  const pattern = getPattern(segments, trailingSlash);
176
184
  const generate = getRouteGenerator(segments, trailingSlash);
177
185
  const pathname = segments.every((segment) => segment.length === 1 && !segment[0].dynamic) ? `/${segments.map((segment) => segment[0].content).join("/")}` : null;
186
+ const route = `/${segments.map(([{ dynamic, content }]) => dynamic ? `[${content}]` : content).join("/")}`.toLowerCase();
178
187
  routes.push({
188
+ route,
179
189
  type: item.isPage ? "page" : "endpoint",
180
190
  pattern,
181
191
  segments,
@@ -190,10 +200,51 @@ function createRouteManifest({ config, cwd }, logging) {
190
200
  const pages = resolvePages(config);
191
201
  if (fs.existsSync(pages)) {
192
202
  walk(fileURLToPath(pages), [], []);
193
- } else {
203
+ } else if (((_b = (_a = config == null ? void 0 : config._ctx) == null ? void 0 : _a.injectedRoutes) == null ? void 0 : _b.length) === 0) {
194
204
  const pagesDirRootRelative = pages.href.slice(config.root.href.length);
195
205
  warn(logging, "astro", `Missing pages directory: ${pagesDirRootRelative}`);
196
206
  }
207
+ (_d = (_c = config == null ? void 0 : config._ctx) == null ? void 0 : _c.injectedRoutes) == null ? void 0 : _d.forEach(({ pattern: name, entryPoint }) => {
208
+ const resolved = require2.resolve(entryPoint, { paths: [cwd || fileURLToPath(config.root)] });
209
+ const component = slash(path.relative(cwd || fileURLToPath(config.root), resolved));
210
+ const isDynamic = (str) => (str == null ? void 0 : str[0]) === "[";
211
+ const normalize = (str) => str == null ? void 0 : str.substring(1, (str == null ? void 0 : str.length) - 1);
212
+ const segments = name.split(path.sep).filter(Boolean).map((s) => {
213
+ validateSegment(s);
214
+ const dynamic = isDynamic(s);
215
+ const content = dynamic ? normalize(s) : s;
216
+ return [
217
+ {
218
+ content,
219
+ dynamic,
220
+ spread: isSpread(s)
221
+ }
222
+ ];
223
+ });
224
+ const type = resolved.endsWith(".astro") ? "page" : "endpoint";
225
+ const isPage = type === "page";
226
+ const trailingSlash = isPage ? config.trailingSlash : "never";
227
+ const pattern = getPattern(segments, trailingSlash);
228
+ const generate = getRouteGenerator(segments, trailingSlash);
229
+ const pathname = segments.every((segment) => segment.length === 1 && !segment[0].dynamic) ? `/${segments.map((segment) => segment[0].content).join("/")}` : null;
230
+ const params = segments.flat().filter((p) => p.dynamic).map((p) => p.content);
231
+ const route = `/${segments.map(([{ dynamic, content }]) => dynamic ? `[${content}]` : content).join("/")}`.toLowerCase();
232
+ const collision = routes.find(({ route: r }) => r === route);
233
+ if (collision) {
234
+ throw new Error(`An integration attempted to inject a route that is already used in your project: "${route}" at "${component}".
235
+ This route collides with: "${collision.component}".`);
236
+ }
237
+ routes.push({
238
+ type,
239
+ route,
240
+ pattern,
241
+ segments,
242
+ params,
243
+ component,
244
+ generate,
245
+ pathname: pathname || void 0
246
+ });
247
+ });
197
248
  return {
198
249
  routes
199
250
  };
@@ -27,6 +27,7 @@ function serializeRouteData(routeData, trailingSlash) {
27
27
  }
28
28
  function deserializeRouteData(rawRouteData) {
29
29
  return {
30
+ route: rawRouteData.route,
30
31
  type: rawRouteData.type,
31
32
  pattern: new RegExp(rawRouteData.pattern),
32
33
  params: rawRouteData.params,
@@ -21,12 +21,13 @@ async function runHookConfigSetup({
21
21
  config: _config,
22
22
  command
23
23
  }) {
24
+ var _a;
24
25
  if (_config.adapter) {
25
26
  _config.integrations.push(_config.adapter);
26
27
  }
27
28
  let updatedConfig = __spreadValues({}, _config);
28
29
  for (const integration of _config.integrations) {
29
- if (integration.hooks["astro:config:setup"]) {
30
+ if ((_a = integration == null ? void 0 : integration.hooks) == null ? void 0 : _a["astro:config:setup"]) {
30
31
  await integration.hooks["astro:config:setup"]({
31
32
  config: updatedConfig,
32
33
  command,
@@ -38,6 +39,9 @@ async function runHookConfigSetup({
38
39
  },
39
40
  updateConfig: (newConfig) => {
40
41
  updatedConfig = mergeConfig(updatedConfig, newConfig);
42
+ },
43
+ injectRoute: (injectRoute) => {
44
+ updatedConfig._ctx.injectedRoutes.push(injectRoute);
41
45
  }
42
46
  });
43
47
  }
@@ -45,8 +49,9 @@ async function runHookConfigSetup({
45
49
  return updatedConfig;
46
50
  }
47
51
  async function runHookConfigDone({ config }) {
52
+ var _a, _b;
48
53
  for (const integration of config.integrations) {
49
- if (integration.hooks["astro:config:done"]) {
54
+ if ((_a = integration == null ? void 0 : integration.hooks) == null ? void 0 : _a["astro:config:done"]) {
50
55
  await integration.hooks["astro:config:done"]({
51
56
  config,
52
57
  setAdapter(adapter) {
@@ -61,7 +66,7 @@ async function runHookConfigDone({ config }) {
61
66
  if (!config._ctx.adapter) {
62
67
  const integration = ssgAdapter();
63
68
  config.integrations.push(integration);
64
- if (integration.hooks["astro:config:done"]) {
69
+ if ((_b = integration == null ? void 0 : integration.hooks) == null ? void 0 : _b["astro:config:done"]) {
65
70
  await integration.hooks["astro:config:done"]({
66
71
  config,
67
72
  setAdapter(adapter) {
@@ -75,8 +80,9 @@ async function runHookServerSetup({
75
80
  config,
76
81
  server
77
82
  }) {
83
+ var _a;
78
84
  for (const integration of config.integrations) {
79
- if (integration.hooks["astro:server:setup"]) {
85
+ if ((_a = integration == null ? void 0 : integration.hooks) == null ? void 0 : _a["astro:server:setup"]) {
80
86
  await integration.hooks["astro:server:setup"]({ server });
81
87
  }
82
88
  }
@@ -85,15 +91,17 @@ async function runHookServerStart({
85
91
  config,
86
92
  address
87
93
  }) {
94
+ var _a;
88
95
  for (const integration of config.integrations) {
89
- if (integration.hooks["astro:server:start"]) {
96
+ if ((_a = integration == null ? void 0 : integration.hooks) == null ? void 0 : _a["astro:server:start"]) {
90
97
  await integration.hooks["astro:server:start"]({ address });
91
98
  }
92
99
  }
93
100
  }
94
101
  async function runHookServerDone({ config }) {
102
+ var _a;
95
103
  for (const integration of config.integrations) {
96
- if (integration.hooks["astro:server:done"]) {
104
+ if ((_a = integration == null ? void 0 : integration.hooks) == null ? void 0 : _a["astro:server:done"]) {
97
105
  await integration.hooks["astro:server:done"]();
98
106
  }
99
107
  }
@@ -102,8 +110,9 @@ async function runHookBuildStart({
102
110
  config,
103
111
  buildConfig
104
112
  }) {
113
+ var _a;
105
114
  for (const integration of config.integrations) {
106
- if (integration.hooks["astro:build:start"]) {
115
+ if ((_a = integration == null ? void 0 : integration.hooks) == null ? void 0 : _a["astro:build:start"]) {
107
116
  await integration.hooks["astro:build:start"]({ buildConfig });
108
117
  }
109
118
  }
@@ -114,8 +123,9 @@ async function runHookBuildSetup({
114
123
  pages,
115
124
  target
116
125
  }) {
126
+ var _a;
117
127
  for (const integration of config.integrations) {
118
- if (integration.hooks["astro:build:setup"]) {
128
+ if ((_a = integration == null ? void 0 : integration.hooks) == null ? void 0 : _a["astro:build:setup"]) {
119
129
  await integration.hooks["astro:build:setup"]({
120
130
  vite,
121
131
  pages,
@@ -131,8 +141,9 @@ async function runHookBuildSsr({
131
141
  config,
132
142
  manifest
133
143
  }) {
144
+ var _a;
134
145
  for (const integration of config.integrations) {
135
- if (integration.hooks["astro:build:ssr"]) {
146
+ if ((_a = integration == null ? void 0 : integration.hooks) == null ? void 0 : _a["astro:build:ssr"]) {
136
147
  await integration.hooks["astro:build:ssr"]({ manifest });
137
148
  }
138
149
  }
@@ -143,9 +154,10 @@ async function runHookBuildDone({
143
154
  pages,
144
155
  routes
145
156
  }) {
157
+ var _a;
146
158
  const dir = isBuildingToSSR(config) ? buildConfig.client : config.outDir;
147
159
  for (const integration of config.integrations) {
148
- if (integration.hooks["astro:build:done"]) {
160
+ if ((_a = integration == null ? void 0 : integration.hooks) == null ? void 0 : _a["astro:build:done"]) {
149
161
  await integration.hooks["astro:build:done"]({
150
162
  pages: pages.map((p) => ({ pathname: p })),
151
163
  dir,
@@ -8,11 +8,8 @@ function debounce(cb, wait = 20) {
8
8
  return callable;
9
9
  }
10
10
  const notify = debounce(() => {
11
- if (document.querySelector("astro-root[ssr]")) {
12
- window.dispatchEvent(new CustomEvent(HYDRATE_KEY));
13
- }
11
+ window.dispatchEvent(new CustomEvent(HYDRATE_KEY));
14
12
  });
15
- const listen = (cb) => window.addEventListener(HYDRATE_KEY, cb, { once: true });
16
13
  if (!window[HYDRATE_KEY]) {
17
14
  if ("MutationObserver" in window) {
18
15
  new MutationObserver(notify).observe(document.body, { subtree: true, childList: true });
@@ -20,6 +17,5 @@ if (!window[HYDRATE_KEY]) {
20
17
  window[HYDRATE_KEY] = true;
21
18
  }
22
19
  export {
23
- listen,
24
20
  notify
25
21
  };
@@ -8,9 +8,9 @@ if (import.meta.hot) {
8
8
  for (const style of sheetsMap.values()) {
9
9
  doc.head.appendChild(style);
10
10
  }
11
- for (const root of doc.querySelectorAll("astro-root")) {
11
+ for (const root of doc.querySelectorAll("astro-island")) {
12
12
  const uid = root.getAttribute("uid");
13
- const current = document.querySelector(`astro-root[uid="${uid}"]`);
13
+ const current = document.querySelector(`astro-island[uid="${uid}"]`);
14
14
  if (current) {
15
15
  current.setAttribute("data-persist", "");
16
16
  root.replaceWith(current);
@@ -21,7 +21,7 @@ if (import.meta.hot) {
21
21
  doc.head.appendChild(style.cloneNode(true));
22
22
  }
23
23
  return diff(document, doc).then(() => {
24
- for (const root of document.querySelectorAll("astro-root[data-persist]")) {
24
+ for (const root of document.querySelectorAll("astro-island[data-persist]")) {
25
25
  root.removeAttribute("data-persist");
26
26
  }
27
27
  for (const style of document.querySelectorAll("style[type='text/css'][data-persist]")) {
@@ -1,45 +1,11 @@
1
- import { listen, notify } from "./events";
2
- async function onIdle(astroId, options, getHydrateCallback) {
3
- let innerHTML = null;
4
- let hydrate;
5
- async function idle() {
6
- listen(idle);
7
- const cb = async () => {
8
- var _a;
9
- const roots = document.querySelectorAll(`astro-root[ssr][uid="${astroId}"]`);
10
- if (roots.length === 0)
11
- return;
12
- if (typeof innerHTML !== "string") {
13
- let fragment = roots[0].querySelector(`astro-fragment`);
14
- if (fragment == null && roots[0].hasAttribute("tmpl")) {
15
- let template = roots[0].querySelector(`template[data-astro-template]`);
16
- if (template) {
17
- innerHTML = template.innerHTML;
18
- template.remove();
19
- }
20
- } else if (fragment) {
21
- innerHTML = fragment.innerHTML;
22
- }
23
- }
24
- if (!hydrate) {
25
- hydrate = await getHydrateCallback();
26
- }
27
- for (const root of roots) {
28
- if ((_a = root.parentElement) == null ? void 0 : _a.closest("astro-root[ssr]"))
29
- continue;
30
- await hydrate(root, innerHTML);
31
- root.removeAttribute("ssr");
32
- }
33
- notify();
34
- };
35
- if ("requestIdleCallback" in window) {
36
- window.requestIdleCallback(cb);
37
- } else {
38
- setTimeout(cb, 200);
39
- }
1
+ (self.Astro = self.Astro || {}).idle = (getHydrateCallback) => {
2
+ const cb = async () => {
3
+ let hydrate = await getHydrateCallback();
4
+ await hydrate();
5
+ };
6
+ if ("requestIdleCallback" in window) {
7
+ window.requestIdleCallback(cb);
8
+ } else {
9
+ setTimeout(cb, 200);
40
10
  }
41
- idle();
42
- }
43
- export {
44
- onIdle as default
45
11
  };
@@ -0,0 +1,4 @@
1
+ var idle_prebuilt_default = `(self.Astro=self.Astro||{}).idle=a=>{const e=async()=>{await(await a())()};"requestIdleCallback"in window?window.requestIdleCallback(e):setTimeout(e,200)};`;
2
+ export {
3
+ idle_prebuilt_default as default
4
+ };
@@ -1,38 +1,6 @@
1
- import { listen, notify } from "./events";
2
- async function onLoad(astroId, options, getHydrateCallback) {
3
- let innerHTML = null;
4
- let hydrate;
5
- async function load() {
6
- var _a;
7
- listen(load);
8
- const roots = document.querySelectorAll(`astro-root[ssr][uid="${astroId}"]`);
9
- if (roots.length === 0)
10
- return;
11
- if (typeof innerHTML !== "string") {
12
- let fragment = roots[0].querySelector(`astro-fragment`);
13
- if (fragment == null && roots[0].hasAttribute("tmpl")) {
14
- let template = roots[0].querySelector(`template[data-astro-template]`);
15
- if (template) {
16
- innerHTML = template.innerHTML;
17
- template.remove();
18
- }
19
- } else if (fragment) {
20
- innerHTML = fragment.innerHTML;
21
- }
22
- }
23
- if (!hydrate) {
24
- hydrate = await getHydrateCallback();
25
- }
26
- for (const root of roots) {
27
- if ((_a = root.parentElement) == null ? void 0 : _a.closest("astro-root[ssr]"))
28
- continue;
29
- await hydrate(root, innerHTML);
30
- root.removeAttribute("ssr");
31
- }
32
- notify();
33
- }
34
- load();
35
- }
36
- export {
37
- onLoad as default
1
+ (self.Astro = self.Astro || {}).load = (getHydrateCallback) => {
2
+ (async () => {
3
+ let hydrate = await getHydrateCallback();
4
+ await hydrate();
5
+ })();
38
6
  };
@@ -0,0 +1,4 @@
1
+ var load_prebuilt_default = `(self.Astro=self.Astro||{}).load=a=>{(async()=>await(await a())())()};`;
2
+ export {
3
+ load_prebuilt_default as default
4
+ };
@@ -1,48 +1,14 @@
1
- import { listen, notify } from "./events";
2
- async function onMedia(astroId, options, getHydrateCallback) {
3
- let innerHTML = null;
4
- let hydrate;
5
- async function media() {
6
- listen(media);
7
- const cb = async () => {
8
- var _a;
9
- const roots = document.querySelectorAll(`astro-root[ssr][uid="${astroId}"]`);
10
- if (roots.length === 0)
11
- return;
12
- if (typeof innerHTML !== "string") {
13
- let fragment = roots[0].querySelector(`astro-fragment`);
14
- if (fragment == null && roots[0].hasAttribute("tmpl")) {
15
- let template = roots[0].querySelector(`template[data-astro-template]`);
16
- if (template) {
17
- innerHTML = template.innerHTML;
18
- template.remove();
19
- }
20
- } else if (fragment) {
21
- innerHTML = fragment.innerHTML;
22
- }
23
- }
24
- if (!hydrate) {
25
- hydrate = await getHydrateCallback();
26
- }
27
- for (const root of roots) {
28
- if ((_a = root.parentElement) == null ? void 0 : _a.closest("astro-root[ssr]"))
29
- continue;
30
- await hydrate(root, innerHTML);
31
- root.removeAttribute("ssr");
32
- }
33
- notify();
34
- };
35
- if (options.value) {
36
- const mql = matchMedia(options.value);
37
- if (mql.matches) {
38
- cb();
39
- } else {
40
- mql.addEventListener("change", cb, { once: true });
41
- }
1
+ (self.Astro = self.Astro || {}).media = (getHydrateCallback, options) => {
2
+ const cb = async () => {
3
+ let hydrate = await getHydrateCallback();
4
+ await hydrate();
5
+ };
6
+ if (options.value) {
7
+ const mql = matchMedia(options.value);
8
+ if (mql.matches) {
9
+ cb();
10
+ } else {
11
+ mql.addEventListener("change", cb, { once: true });
42
12
  }
43
13
  }
44
- media();
45
- }
46
- export {
47
- onMedia as default
48
14
  };
@@ -0,0 +1,4 @@
1
+ var media_prebuilt_default = `(self.Astro=self.Astro||{}).media=(s,a)=>{const t=async()=>{await(await s())()};if(a.value){const e=matchMedia(a.value);e.matches?t():e.addEventListener("change",t,{once:!0})}};`;
2
+ export {
3
+ media_prebuilt_default as default
4
+ };