astro 2.4.5 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/astro-jsx.d.ts +5 -1
- package/dist/@types/astro.d.ts +130 -6
- package/dist/assets/generate.d.ts +22 -0
- package/dist/assets/generate.js +90 -0
- package/dist/assets/internal.d.ts +0 -21
- package/dist/assets/internal.js +0 -86
- package/dist/assets/vite-plugin-assets.js +5 -0
- package/dist/content/consts.d.ts +3 -1
- package/dist/content/consts.js +5 -1
- package/dist/content/runtime-assets.d.ts +1 -1
- package/dist/content/runtime.d.ts +61 -7
- package/dist/content/runtime.js +127 -4
- package/dist/content/template/virtual-mod.d.mts +4 -1
- package/dist/content/types-generator.js +172 -89
- package/dist/content/utils.d.ts +76 -23
- package/dist/content/utils.js +129 -65
- package/dist/content/vite-plugin-content-imports.js +110 -25
- package/dist/content/vite-plugin-content-virtual-mod.d.ts +4 -3
- package/dist/content/vite-plugin-content-virtual-mod.js +89 -45
- package/dist/core/app/common.js +2 -0
- package/dist/core/app/index.js +8 -6
- package/dist/core/app/types.d.ts +9 -2
- package/dist/core/build/generate.js +11 -11
- package/dist/core/build/graph.js +1 -1
- package/dist/core/build/index.d.ts +1 -1
- package/dist/core/build/plugins/index.js +2 -0
- package/dist/core/build/plugins/plugin-middleware.d.ts +8 -0
- package/dist/core/build/plugins/plugin-middleware.js +53 -0
- package/dist/core/build/plugins/plugin-pages.d.ts +0 -2
- package/dist/core/build/plugins/plugin-pages.js +9 -14
- package/dist/core/build/plugins/plugin-prerender.d.ts +0 -2
- package/dist/core/build/plugins/plugin-prerender.js +4 -3
- package/dist/core/build/plugins/plugin-ssr.d.ts +1 -4
- package/dist/core/build/plugins/plugin-ssr.js +15 -22
- package/dist/core/build/static-build.js +12 -7
- package/dist/core/build/types.d.ts +3 -1
- package/dist/core/client-directive/build.d.ts +4 -0
- package/dist/core/client-directive/build.js +28 -0
- package/dist/core/client-directive/default.d.ts +1 -0
- package/dist/core/client-directive/default.js +17 -0
- package/dist/core/client-directive/index.d.ts +2 -0
- package/dist/core/client-directive/index.js +6 -0
- package/dist/core/compile/compile.js +1 -0
- package/dist/core/config/config.js +6 -0
- package/dist/core/config/schema.d.ts +68 -12
- package/dist/core/config/schema.js +29 -3
- package/dist/core/config/settings.js +74 -2
- package/dist/core/config/vite-load.js +2 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/endpoint/dev/index.js +1 -1
- package/dist/core/endpoint/index.d.ts +1 -1
- package/dist/core/endpoint/index.js +16 -16
- package/dist/core/errors/errors-data.d.ts +55 -4
- package/dist/core/errors/errors-data.js +67 -7
- package/dist/core/errors/errors.d.ts +1 -0
- package/dist/core/errors/errors.js +5 -1
- package/dist/core/errors/index.d.ts +1 -1
- package/dist/core/errors/index.js +9 -1
- package/dist/core/errors/utils.d.ts +5 -0
- package/dist/core/errors/utils.js +14 -0
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/callMiddleware.d.ts +2 -1
- package/dist/core/middleware/callMiddleware.js +13 -3
- package/dist/core/render/core.js +1 -0
- package/dist/core/render/dev/environment.js +3 -1
- package/dist/core/render/dev/index.js +1 -1
- package/dist/core/render/environment.d.ts +1 -0
- package/dist/core/render/environment.js +2 -0
- package/dist/core/render/result.d.ts +1 -0
- package/dist/core/render/result.js +3 -2
- package/dist/core/routing/manifest/create.js +9 -2
- package/dist/core/routing/validation.js +6 -1
- package/dist/core/sync/index.js +11 -1
- package/dist/core/util.js +2 -1
- package/dist/integrations/index.js +29 -3
- package/dist/jsx/babel.js +1 -2
- package/dist/prerender/utils.d.ts +3 -0
- package/dist/prerender/utils.js +10 -0
- package/dist/runtime/client/idle.d.ts +3 -0
- package/dist/runtime/client/idle.js +6 -3
- package/dist/runtime/client/idle.prebuilt.d.ts +1 -1
- package/dist/runtime/client/idle.prebuilt.js +1 -1
- package/dist/runtime/client/load.d.ts +3 -0
- package/dist/runtime/client/load.js +7 -6
- package/dist/runtime/client/load.prebuilt.d.ts +1 -1
- package/dist/runtime/client/load.prebuilt.js +1 -1
- package/dist/runtime/client/media.d.ts +6 -0
- package/dist/runtime/client/media.js +6 -3
- package/dist/runtime/client/media.prebuilt.d.ts +1 -1
- package/dist/runtime/client/media.prebuilt.js +1 -1
- package/dist/runtime/client/only.d.ts +6 -0
- package/dist/runtime/client/only.js +7 -6
- package/dist/runtime/client/only.prebuilt.d.ts +1 -1
- package/dist/runtime/client/only.prebuilt.js +1 -1
- package/dist/runtime/client/visible.d.ts +8 -0
- package/dist/runtime/client/visible.js +9 -6
- package/dist/runtime/client/visible.prebuilt.d.ts +1 -1
- package/dist/runtime/client/visible.prebuilt.js +1 -1
- package/dist/runtime/server/astro-island.prebuilt.d.ts +1 -1
- package/dist/runtime/server/astro-island.prebuilt.js +1 -1
- package/dist/runtime/server/endpoint.js +1 -1
- package/dist/runtime/server/hydration.d.ts +1 -2
- package/dist/runtime/server/hydration.js +4 -9
- package/dist/runtime/server/render/astro/instance.js +1 -2
- package/dist/runtime/server/render/astro/render-template.d.ts +1 -1
- package/dist/runtime/server/render/astro/render-template.js +10 -2
- package/dist/runtime/server/render/common.js +1 -1
- package/dist/runtime/server/render/component.js +20 -6
- package/dist/runtime/server/render/page.js +5 -0
- package/dist/runtime/server/render/util.d.ts +12 -0
- package/dist/runtime/server/render/util.js +89 -1
- package/dist/runtime/server/scripts.d.ts +1 -2
- package/dist/runtime/server/scripts.js +13 -21
- package/dist/vite-plugin-astro-server/request.js +2 -1
- package/dist/vite-plugin-astro-server/route.js +4 -3
- package/dist/vite-plugin-jsx/index.js +1 -1
- package/dist/vite-plugin-scanner/index.js +6 -1
- package/dist/vite-plugin-scanner/scan.d.ts +1 -1
- package/dist/vite-plugin-scanner/scan.js +2 -2
- package/package.json +5 -3
- package/src/content/template/types.d.ts +108 -15
- package/src/content/template/virtual-mod.mjs +40 -16
- package/types.d.ts +6 -3
|
@@ -87,7 +87,7 @@ class Slots {
|
|
|
87
87
|
}
|
|
88
88
|
let renderMarkdown = null;
|
|
89
89
|
function createResult(args) {
|
|
90
|
-
const { markdown, params, pathname, renderers, request, resolve, locals } = args;
|
|
90
|
+
const { markdown, params, pathname, renderers, clientDirectives, request, resolve, locals } = args;
|
|
91
91
|
const url = new URL(request.url);
|
|
92
92
|
const headers = new Headers();
|
|
93
93
|
headers.set("Content-Type", "text/html");
|
|
@@ -187,7 +187,8 @@ function createResult(args) {
|
|
|
187
187
|
hasHydrationScript: false,
|
|
188
188
|
hasRenderedHead: false,
|
|
189
189
|
hasDirectives: /* @__PURE__ */ new Set(),
|
|
190
|
-
headInTree: false
|
|
190
|
+
headInTree: false,
|
|
191
|
+
clientDirectives
|
|
191
192
|
},
|
|
192
193
|
response
|
|
193
194
|
};
|
|
@@ -3,6 +3,7 @@ import { createRequire } from "module";
|
|
|
3
3
|
import path from "path";
|
|
4
4
|
import slash from "slash";
|
|
5
5
|
import { fileURLToPath } from "url";
|
|
6
|
+
import { isHybridOutput } from "../../../prerender/utils.js";
|
|
6
7
|
import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from "../../constants.js";
|
|
7
8
|
import { warn } from "../../logger/core.js";
|
|
8
9
|
import { removeLeadingForwardSlash } from "../../path.js";
|
|
@@ -142,6 +143,8 @@ function createRouteManifest({ settings, cwd, fsMod }, logging) {
|
|
|
142
143
|
]);
|
|
143
144
|
const validEndpointExtensions = /* @__PURE__ */ new Set([".js", ".ts"]);
|
|
144
145
|
const localFs = fsMod ?? nodeFs;
|
|
146
|
+
const isPrenderDefault = isHybridOutput(settings.config);
|
|
147
|
+
const foundInvalidFileExtensions = /* @__PURE__ */ new Set();
|
|
145
148
|
function walk(fs, dir, parentSegments, parentParams) {
|
|
146
149
|
let items = [];
|
|
147
150
|
fs.readdirSync(dir).forEach((basename) => {
|
|
@@ -157,6 +160,10 @@ function createRouteManifest({ settings, cwd, fsMod }, logging) {
|
|
|
157
160
|
return;
|
|
158
161
|
}
|
|
159
162
|
if (!isDir && !validPageExtensions.has(ext) && !validEndpointExtensions.has(ext)) {
|
|
163
|
+
if (!foundInvalidFileExtensions.has(ext)) {
|
|
164
|
+
foundInvalidFileExtensions.add(ext);
|
|
165
|
+
warn(logging, "astro", `Invalid file extension for Pages: ${ext}`);
|
|
166
|
+
}
|
|
160
167
|
return;
|
|
161
168
|
}
|
|
162
169
|
const segment = isDir ? basename : name;
|
|
@@ -226,7 +233,7 @@ function createRouteManifest({ settings, cwd, fsMod }, logging) {
|
|
|
226
233
|
component,
|
|
227
234
|
generate,
|
|
228
235
|
pathname: pathname || void 0,
|
|
229
|
-
prerender:
|
|
236
|
+
prerender: isPrenderDefault
|
|
230
237
|
});
|
|
231
238
|
}
|
|
232
239
|
});
|
|
@@ -280,7 +287,7 @@ This route collides with: "${collision.component}".`
|
|
|
280
287
|
component,
|
|
281
288
|
generate,
|
|
282
289
|
pathname: pathname || void 0,
|
|
283
|
-
prerender:
|
|
290
|
+
prerender: isPrenderDefault
|
|
284
291
|
});
|
|
285
292
|
});
|
|
286
293
|
return {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { bold } from "kleur/colors";
|
|
1
2
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
2
3
|
import { warn } from "../logger/core.js";
|
|
3
4
|
const VALID_PARAM_TYPES = ["string", "number", "undefined"];
|
|
@@ -18,7 +19,11 @@ function validateDynamicRouteModule(mod, {
|
|
|
18
19
|
route
|
|
19
20
|
}) {
|
|
20
21
|
if (ssr && mod.getStaticPaths && !mod.prerender) {
|
|
21
|
-
warn(
|
|
22
|
+
warn(
|
|
23
|
+
logging,
|
|
24
|
+
"getStaticPaths",
|
|
25
|
+
`getStaticPaths() in ${bold(route.component)} is ignored when "output: server" is set.`
|
|
26
|
+
);
|
|
22
27
|
}
|
|
23
28
|
if ((!ssr || mod.prerender) && !mod.getStaticPaths) {
|
|
24
29
|
throw new AstroError({
|
package/dist/core/sync/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { runHookConfigSetup } from "../../integrations/index.js";
|
|
|
7
7
|
import { setUpEnvTs } from "../../vite-plugin-inject-env-ts/index.js";
|
|
8
8
|
import { getTimeStat } from "../build/util.js";
|
|
9
9
|
import { createVite } from "../create-vite.js";
|
|
10
|
-
import { AstroError, AstroErrorData, createSafeError } from "../errors/index.js";
|
|
10
|
+
import { AstroError, AstroErrorData, createSafeError, isAstroError } from "../errors/index.js";
|
|
11
11
|
import { info } from "../logger/core.js";
|
|
12
12
|
import { printHelp } from "../messages.js";
|
|
13
13
|
async function syncCli(settings, { logging, fs, flags }) {
|
|
@@ -42,6 +42,13 @@ async function sync(settings, { logging, fs }) {
|
|
|
42
42
|
{ settings, logging, mode: "build", command: "build", fs }
|
|
43
43
|
)
|
|
44
44
|
);
|
|
45
|
+
const wsSend = tempViteServer.ws.send;
|
|
46
|
+
tempViteServer.ws.send = (payload) => {
|
|
47
|
+
if (payload.type === "error") {
|
|
48
|
+
throw payload.err;
|
|
49
|
+
}
|
|
50
|
+
return wsSend(payload);
|
|
51
|
+
};
|
|
45
52
|
try {
|
|
46
53
|
const contentTypesGenerator = await createContentTypesGenerator({
|
|
47
54
|
contentConfigObserver: globalContentConfigObserver,
|
|
@@ -65,6 +72,9 @@ async function sync(settings, { logging, fs }) {
|
|
|
65
72
|
}
|
|
66
73
|
} catch (e) {
|
|
67
74
|
const safeError = createSafeError(e);
|
|
75
|
+
if (isAstroError(e)) {
|
|
76
|
+
throw e;
|
|
77
|
+
}
|
|
68
78
|
throw new AstroError(
|
|
69
79
|
{
|
|
70
80
|
...AstroErrorData.GenerateContentTypesError,
|
package/dist/core/util.js
CHANGED
|
@@ -3,6 +3,7 @@ import path from "path";
|
|
|
3
3
|
import slash from "slash";
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
5
|
import { normalizePath } from "vite";
|
|
6
|
+
import { isHybridOutput } from "../prerender/utils.js";
|
|
6
7
|
import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from "./constants.js";
|
|
7
8
|
import { prependForwardSlash, removeTrailingForwardSlash } from "./path.js";
|
|
8
9
|
function isObject(value) {
|
|
@@ -103,7 +104,7 @@ function isEndpoint(file, settings) {
|
|
|
103
104
|
return !endsWithPageExt(file, settings);
|
|
104
105
|
}
|
|
105
106
|
function isModeServerWithNoAdapter(settings) {
|
|
106
|
-
return settings.config.output === "server" && !settings.adapter;
|
|
107
|
+
return (settings.config.output === "server" || isHybridOutput(settings.config)) && !settings.adapter;
|
|
107
108
|
}
|
|
108
109
|
function relativeToSrcDir(config, idOrUrl) {
|
|
109
110
|
let id;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { bold } from "kleur/colors";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { buildClientDirectiveEntrypoint } from "../core/client-directive/index.js";
|
|
4
5
|
import { mergeConfig } from "../core/config/config.js";
|
|
5
6
|
import { info } from "../core/logger/core.js";
|
|
7
|
+
import { isHybridOutput } from "../prerender/utils.js";
|
|
6
8
|
import { mdxContentEntryType } from "../vite-plugin-markdown/content-entry-type.js";
|
|
7
9
|
async function withTakingALongTimeMsg({
|
|
8
10
|
name,
|
|
@@ -29,6 +31,7 @@ async function runHookConfigSetup({
|
|
|
29
31
|
}
|
|
30
32
|
let updatedConfig = { ...settings.config };
|
|
31
33
|
let updatedSettings = { ...settings, config: updatedConfig };
|
|
34
|
+
let addedClientDirectives = /* @__PURE__ */ new Map();
|
|
32
35
|
for (const integration of settings.config.integrations) {
|
|
33
36
|
if ((_a = integration.hooks) == null ? void 0 : _a["astro:config:setup"]) {
|
|
34
37
|
let addPageExtension2 = function(...input) {
|
|
@@ -36,8 +39,10 @@ async function runHookConfigSetup({
|
|
|
36
39
|
updatedSettings.pageExtensions.push(...exts);
|
|
37
40
|
}, addContentEntryType2 = function(contentEntryType) {
|
|
38
41
|
updatedSettings.contentEntryTypes.push(contentEntryType);
|
|
42
|
+
}, addDataEntryType2 = function(dataEntryType) {
|
|
43
|
+
updatedSettings.dataEntryTypes.push(dataEntryType);
|
|
39
44
|
};
|
|
40
|
-
var addPageExtension = addPageExtension2, addContentEntryType = addContentEntryType2;
|
|
45
|
+
var addPageExtension = addPageExtension2, addContentEntryType = addContentEntryType2, addDataEntryType = addDataEntryType2;
|
|
41
46
|
const hooks = {
|
|
42
47
|
config: updatedConfig,
|
|
43
48
|
command,
|
|
@@ -62,6 +67,19 @@ async function runHookConfigSetup({
|
|
|
62
67
|
},
|
|
63
68
|
addWatchFile: (path) => {
|
|
64
69
|
updatedSettings.watchFiles.push(path instanceof URL ? fileURLToPath(path) : path);
|
|
70
|
+
},
|
|
71
|
+
addClientDirective: ({ name, entrypoint }) => {
|
|
72
|
+
if (!settings.config.experimental.customClientDirectives) {
|
|
73
|
+
throw new Error(
|
|
74
|
+
`The "${integration.name}" integration is trying to add the "${name}" client directive, but the \`experimental.customClientDirectives\` config is not enabled.`
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
if (updatedSettings.clientDirectives.has(name) || addedClientDirectives.has(name)) {
|
|
78
|
+
throw new Error(
|
|
79
|
+
`The "${integration.name}" integration is trying to add the "${name}" client directive, but it already exists.`
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
addedClientDirectives.set(name, buildClientDirectiveEntrypoint(name, entrypoint));
|
|
65
83
|
}
|
|
66
84
|
};
|
|
67
85
|
Object.defineProperty(hooks, "addPageExtension", {
|
|
@@ -74,6 +92,11 @@ async function runHookConfigSetup({
|
|
|
74
92
|
writable: false,
|
|
75
93
|
enumerable: false
|
|
76
94
|
});
|
|
95
|
+
Object.defineProperty(hooks, "addDataEntryType", {
|
|
96
|
+
value: addDataEntryType2,
|
|
97
|
+
writable: false,
|
|
98
|
+
enumerable: false
|
|
99
|
+
});
|
|
77
100
|
await withTakingALongTimeMsg({
|
|
78
101
|
name: integration.name,
|
|
79
102
|
hookResult: integration.hooks["astro:config:setup"](hooks),
|
|
@@ -82,6 +105,9 @@ async function runHookConfigSetup({
|
|
|
82
105
|
if (integration.name === "@astrojs/mdx" && !updatedSettings.contentEntryTypes.find((c) => c.extensions.includes(".mdx"))) {
|
|
83
106
|
addContentEntryType2(mdxContentEntryType);
|
|
84
107
|
}
|
|
108
|
+
for (const [name, compiled] of addedClientDirectives) {
|
|
109
|
+
updatedSettings.clientDirectives.set(name, await compiled);
|
|
110
|
+
}
|
|
85
111
|
}
|
|
86
112
|
}
|
|
87
113
|
updatedSettings.config = updatedConfig;
|
|
@@ -221,7 +247,7 @@ async function runHookBuildGenerated({
|
|
|
221
247
|
logging
|
|
222
248
|
}) {
|
|
223
249
|
var _a;
|
|
224
|
-
const dir = config.output === "server" ? buildConfig.client : config.outDir;
|
|
250
|
+
const dir = config.output === "server" || isHybridOutput(config) ? buildConfig.client : config.outDir;
|
|
225
251
|
for (const integration of config.integrations) {
|
|
226
252
|
if ((_a = integration == null ? void 0 : integration.hooks) == null ? void 0 : _a["astro:build:generated"]) {
|
|
227
253
|
await withTakingALongTimeMsg({
|
|
@@ -240,7 +266,7 @@ async function runHookBuildDone({
|
|
|
240
266
|
logging
|
|
241
267
|
}) {
|
|
242
268
|
var _a;
|
|
243
|
-
const dir = config.output === "server" ? buildConfig.client : config.outDir;
|
|
269
|
+
const dir = config.output === "server" || isHybridOutput(config) ? buildConfig.client : config.outDir;
|
|
244
270
|
await fs.promises.mkdir(dir, { recursive: true });
|
|
245
271
|
for (const integration of config.integrations) {
|
|
246
272
|
if ((_a = integration == null ? void 0 : integration.hooks) == null ? void 0 : _a["astro:build:done"]) {
|
package/dist/jsx/babel.js
CHANGED
|
@@ -2,7 +2,6 @@ import * as t from "@babel/types";
|
|
|
2
2
|
import { AstroErrorData } from "../core/errors/errors-data.js";
|
|
3
3
|
import { AstroError } from "../core/errors/errors.js";
|
|
4
4
|
import { resolvePath } from "../core/util.js";
|
|
5
|
-
import { HydrationDirectiveProps } from "../runtime/server/hydration.js";
|
|
6
5
|
const ClientOnlyPlaceholder = "astro-client-only";
|
|
7
6
|
function isComponent(tagName) {
|
|
8
7
|
return tagName[0] && tagName[0].toLowerCase() !== tagName[0] || tagName.includes(".") || /[^a-zA-Z]/.test(tagName[0]);
|
|
@@ -259,7 +258,7 @@ function astroJSX() {
|
|
|
259
258
|
for (const attr of parentNode.openingElement.attributes) {
|
|
260
259
|
if (t.isJSXAttribute(attr)) {
|
|
261
260
|
const name = jsxAttributeToString(attr);
|
|
262
|
-
if (
|
|
261
|
+
if (name.startsWith("client:")) {
|
|
263
262
|
console.warn(
|
|
264
263
|
`You are attempting to render <${displayName} ${name} />, but ${displayName} is an Astro component. Astro components do not render in the client and should not have a hydration directive. Please use a framework component for client rendering.`
|
|
265
264
|
);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
function isHybridMalconfigured(config) {
|
|
2
|
+
return config.experimental.hybridOutput ? config.output !== "hybrid" : config.output === "hybrid";
|
|
3
|
+
}
|
|
4
|
+
function isHybridOutput(config) {
|
|
5
|
+
return config.experimental.hybridOutput && config.output === "hybrid";
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
isHybridMalconfigured,
|
|
9
|
+
isHybridOutput
|
|
10
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
const idleDirective = (load) => {
|
|
2
2
|
const cb = async () => {
|
|
3
|
-
|
|
3
|
+
const hydrate = await load();
|
|
4
4
|
await hydrate();
|
|
5
5
|
};
|
|
6
6
|
if ("requestIdleCallback" in window) {
|
|
@@ -9,4 +9,7 @@
|
|
|
9
9
|
setTimeout(cb, 200);
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
var idle_default = idleDirective;
|
|
13
|
+
export {
|
|
14
|
+
idle_default as default
|
|
15
|
+
};
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* Do not edit this directly, but instead edit that file and rerun the prebuild
|
|
4
4
|
* to generate this file.
|
|
5
5
|
*/
|
|
6
|
-
declare const _default: "(
|
|
6
|
+
declare const _default: "(()=>{var i=t=>{let e=async()=>{await(await t())()};\"requestIdleCallback\"in window?window.requestIdleCallback(e):setTimeout(e,200)};(self.Astro||(self.Astro={})).idle=i;window.dispatchEvent(new Event(\"astro:idle\"));})();";
|
|
7
7
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var idle_prebuilt_default = `(
|
|
1
|
+
var idle_prebuilt_default = `(()=>{var i=t=>{let e=async()=>{await(await t())()};"requestIdleCallback"in window?window.requestIdleCallback(e):setTimeout(e,200)};(self.Astro||(self.Astro={})).idle=i;window.dispatchEvent(new Event("astro:idle"));})();`;
|
|
2
2
|
export {
|
|
3
3
|
idle_prebuilt_default as default
|
|
4
4
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const loadDirective = async (load) => {
|
|
2
|
+
const hydrate = await load();
|
|
3
|
+
await hydrate();
|
|
4
|
+
};
|
|
5
|
+
var load_default = loadDirective;
|
|
6
|
+
export {
|
|
7
|
+
load_default as default
|
|
6
8
|
};
|
|
7
|
-
window.dispatchEvent(new Event("astro:load"));
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* Do not edit this directly, but instead edit that file and rerun the prebuild
|
|
4
4
|
* to generate this file.
|
|
5
5
|
*/
|
|
6
|
-
declare const _default: "(
|
|
6
|
+
declare const _default: "(()=>{var e=async t=>{await(await t())()};(self.Astro||(self.Astro={})).load=e;window.dispatchEvent(new Event(\"astro:load\"));})();";
|
|
7
7
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var load_prebuilt_default = `(
|
|
1
|
+
var load_prebuilt_default = `(()=>{var e=async t=>{await(await t())()};(self.Astro||(self.Astro={})).load=e;window.dispatchEvent(new Event("astro:load"));})();`;
|
|
2
2
|
export {
|
|
3
3
|
load_prebuilt_default as default
|
|
4
4
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
const mediaDirective = (load, options) => {
|
|
2
2
|
const cb = async () => {
|
|
3
|
-
|
|
3
|
+
const hydrate = await load();
|
|
4
4
|
await hydrate();
|
|
5
5
|
};
|
|
6
6
|
if (options.value) {
|
|
@@ -12,4 +12,7 @@
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
|
-
|
|
15
|
+
var media_default = mediaDirective;
|
|
16
|
+
export {
|
|
17
|
+
media_default as default
|
|
18
|
+
};
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* Do not edit this directly, but instead edit that file and rerun the prebuild
|
|
4
4
|
* to generate this file.
|
|
5
5
|
*/
|
|
6
|
-
declare const _default: "(
|
|
6
|
+
declare const _default: "(()=>{var s=(i,t)=>{let a=async()=>{await(await i())()};if(t.value){let e=matchMedia(t.value);e.matches?a():e.addEventListener(\"change\",a,{once:!0})}};(self.Astro||(self.Astro={})).media=s;window.dispatchEvent(new Event(\"astro:media\"));})();";
|
|
7
7
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var media_prebuilt_default = `(
|
|
1
|
+
var media_prebuilt_default = `(()=>{var s=(i,t)=>{let a=async()=>{await(await i())()};if(t.value){let e=matchMedia(t.value);e.matches?a():e.addEventListener("change",a,{once:!0})}};(self.Astro||(self.Astro={})).media=s;window.dispatchEvent(new Event("astro:media"));})();`;
|
|
2
2
|
export {
|
|
3
3
|
media_prebuilt_default as default
|
|
4
4
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const onlyDirective = async (load) => {
|
|
2
|
+
const hydrate = await load();
|
|
3
|
+
await hydrate();
|
|
4
|
+
};
|
|
5
|
+
var only_default = onlyDirective;
|
|
6
|
+
export {
|
|
7
|
+
only_default as default
|
|
6
8
|
};
|
|
7
|
-
window.dispatchEvent(new Event("astro:only"));
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* Do not edit this directly, but instead edit that file and rerun the prebuild
|
|
4
4
|
* to generate this file.
|
|
5
5
|
*/
|
|
6
|
-
declare const _default: "(
|
|
6
|
+
declare const _default: "(()=>{var e=async t=>{await(await t())()};(self.Astro||(self.Astro={})).only=e;window.dispatchEvent(new Event(\"astro:only\"));})();";
|
|
7
7
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var only_prebuilt_default = `(
|
|
1
|
+
var only_prebuilt_default = `(()=>{var e=async t=>{await(await t())()};(self.Astro||(self.Astro={})).only=e;window.dispatchEvent(new Event("astro:only"));})();`;
|
|
2
2
|
export {
|
|
3
3
|
only_prebuilt_default as default
|
|
4
4
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ClientDirective } from '../../@types/astro';
|
|
2
|
+
/**
|
|
3
|
+
* Hydrate this component when one of it's children becomes visible
|
|
4
|
+
* We target the children because `astro-island` is set to `display: contents`
|
|
5
|
+
* which doesn't work with IntersectionObserver
|
|
6
|
+
*/
|
|
7
|
+
declare const visibleDirective: ClientDirective;
|
|
8
|
+
export default visibleDirective;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
const visibleDirective = (load, _options, el) => {
|
|
2
2
|
const cb = async () => {
|
|
3
|
-
|
|
3
|
+
const hydrate = await load();
|
|
4
4
|
await hydrate();
|
|
5
5
|
};
|
|
6
|
-
|
|
6
|
+
const io = new IntersectionObserver((entries) => {
|
|
7
7
|
for (const entry of entries) {
|
|
8
8
|
if (!entry.isIntersecting)
|
|
9
9
|
continue;
|
|
@@ -12,9 +12,12 @@
|
|
|
12
12
|
break;
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
|
-
for (let i = 0; i <
|
|
16
|
-
const child =
|
|
15
|
+
for (let i = 0; i < el.children.length; i++) {
|
|
16
|
+
const child = el.children[i];
|
|
17
17
|
io.observe(child);
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
var visible_default = visibleDirective;
|
|
21
|
+
export {
|
|
22
|
+
visible_default as default
|
|
23
|
+
};
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* Do not edit this directly, but instead edit that file and rerun the prebuild
|
|
4
4
|
* to generate this file.
|
|
5
5
|
*/
|
|
6
|
-
declare const _default: "(
|
|
6
|
+
declare const _default: "(()=>{var r=(s,c,i)=>{let o=async()=>{await(await s())()},n=new IntersectionObserver(e=>{for(let t of e)if(t.isIntersecting){n.disconnect(),o();break}});for(let e=0;e<i.children.length;e++){let t=i.children[e];n.observe(t)}};(self.Astro||(self.Astro={})).visible=r;window.dispatchEvent(new Event(\"astro:visible\"));})();";
|
|
7
7
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var visible_prebuilt_default = `(
|
|
1
|
+
var visible_prebuilt_default = `(()=>{var r=(s,c,i)=>{let o=async()=>{await(await s())()},n=new IntersectionObserver(e=>{for(let t of e)if(t.isIntersecting){n.disconnect(),o();break}});for(let e=0;e<i.children.length;e++){let t=i.children[e];n.observe(t)}};(self.Astro||(self.Astro={})).visible=r;window.dispatchEvent(new Event("astro:visible"));})();`;
|
|
2
2
|
export {
|
|
3
3
|
visible_prebuilt_default as default
|
|
4
4
|
};
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* Do not edit this directly, but instead edit that file and rerun the prebuild
|
|
4
4
|
* to generate this file.
|
|
5
5
|
*/
|
|
6
|
-
declare const _default: "var l;{
|
|
6
|
+
declare const _default: "(()=>{var l;{let c={0:t=>t,1:t=>JSON.parse(t,o),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,o)),5:t=>new Set(JSON.parse(t,o)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(JSON.parse(t)),9:t=>new Uint16Array(JSON.parse(t)),10:t=>new Uint32Array(JSON.parse(t))},o=(t,s)=>{if(t===\"\"||!Array.isArray(s))return s;let[e,n]=s;return e in c?c[e](n):void 0};customElements.get(\"astro-island\")||customElements.define(\"astro-island\",(l=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=()=>{if(!this.hydrator||this.parentElement&&this.parentElement.closest(\"astro-island[ssr]\"))return;let s=this.querySelectorAll(\"astro-slot\"),e={},n=this.querySelectorAll(\"template[data-astro-template]\");for(let r of n){let i=r.closest(this.tagName);!i||!i.isSameNode(this)||(e[r.getAttribute(\"data-astro-template\")||\"default\"]=r.innerHTML,r.remove())}for(let r of s){let i=r.closest(this.tagName);!i||!i.isSameNode(this)||(e[r.getAttribute(\"name\")||\"default\"]=r.innerHTML)}let a=this.hasAttribute(\"props\")?JSON.parse(this.getAttribute(\"props\"),o):{};this.hydrator(this)(this.Component,a,e,{client:this.getAttribute(\"client\")}),this.removeAttribute(\"ssr\"),window.removeEventListener(\"astro:hydrate\",this.hydrate),window.dispatchEvent(new CustomEvent(\"astro:hydrate\"))}}connectedCallback(){!this.hasAttribute(\"await-children\")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((s,e)=>{e.disconnect(),this.childrenConnectedCallback()}).observe(this,{childList:!0})}async childrenConnectedCallback(){window.addEventListener(\"astro:hydrate\",this.hydrate);let s=this.getAttribute(\"before-hydration-url\");s&&await import(s),this.start()}start(){let s=JSON.parse(this.getAttribute(\"opts\")),e=this.getAttribute(\"client\");if(Astro[e]===void 0){window.addEventListener(`astro:${e}`,()=>this.start(),{once:!0});return}Astro[e](async()=>{let n=this.getAttribute(\"renderer-url\"),[a,{default:r}]=await Promise.all([import(this.getAttribute(\"component-url\")),n?import(n):()=>()=>{}]),i=this.getAttribute(\"component-export\")||\"default\";if(!i.includes(\".\"))this.Component=a[i];else{this.Component=a;for(let d of i.split(\".\"))this.Component=this.Component[d]}return this.hydrator=r,this.hydrate},s,this)}attributeChangedCallback(){this.hydrator&&this.hydrate()}},l.observedAttributes=[\"props\"],l))}})();";
|
|
7
7
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var astro_island_prebuilt_default = `var l;{
|
|
1
|
+
var astro_island_prebuilt_default = `(()=>{var l;{let c={0:t=>t,1:t=>JSON.parse(t,o),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,o)),5:t=>new Set(JSON.parse(t,o)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(JSON.parse(t)),9:t=>new Uint16Array(JSON.parse(t)),10:t=>new Uint32Array(JSON.parse(t))},o=(t,s)=>{if(t===""||!Array.isArray(s))return s;let[e,n]=s;return e in c?c[e](n):void 0};customElements.get("astro-island")||customElements.define("astro-island",(l=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=()=>{if(!this.hydrator||this.parentElement&&this.parentElement.closest("astro-island[ssr]"))return;let s=this.querySelectorAll("astro-slot"),e={},n=this.querySelectorAll("template[data-astro-template]");for(let r of n){let i=r.closest(this.tagName);!i||!i.isSameNode(this)||(e[r.getAttribute("data-astro-template")||"default"]=r.innerHTML,r.remove())}for(let r of s){let i=r.closest(this.tagName);!i||!i.isSameNode(this)||(e[r.getAttribute("name")||"default"]=r.innerHTML)}let a=this.hasAttribute("props")?JSON.parse(this.getAttribute("props"),o):{};this.hydrator(this)(this.Component,a,e,{client:this.getAttribute("client")}),this.removeAttribute("ssr"),window.removeEventListener("astro:hydrate",this.hydrate),window.dispatchEvent(new CustomEvent("astro:hydrate"))}}connectedCallback(){!this.hasAttribute("await-children")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((s,e)=>{e.disconnect(),this.childrenConnectedCallback()}).observe(this,{childList:!0})}async childrenConnectedCallback(){window.addEventListener("astro:hydrate",this.hydrate);let s=this.getAttribute("before-hydration-url");s&&await import(s),this.start()}start(){let s=JSON.parse(this.getAttribute("opts")),e=this.getAttribute("client");if(Astro[e]===void 0){window.addEventListener(\`astro:\${e}\`,()=>this.start(),{once:!0});return}Astro[e](async()=>{let n=this.getAttribute("renderer-url"),[a,{default:r}]=await Promise.all([import(this.getAttribute("component-url")),n?import(n):()=>()=>{}]),i=this.getAttribute("component-export")||"default";if(!i.includes("."))this.Component=a[i];else{this.Component=a;for(let d of i.split("."))this.Component=this.Component[d]}return this.hydrator=r,this.hydrate},s,this)}attributeChangedCallback(){this.hydrator&&this.hydrate()}},l.observedAttributes=["props"],l))}})();`;
|
|
2
2
|
export {
|
|
3
3
|
astro_island_prebuilt_default as default
|
|
4
4
|
};
|
|
@@ -17,7 +17,7 @@ async function renderEndpoint(mod, context, ssr) {
|
|
|
17
17
|
const handler = getHandlerFromModule(mod, chosenMethod);
|
|
18
18
|
if (!ssr && ssr === false && chosenMethod && chosenMethod !== "get") {
|
|
19
19
|
console.warn(`
|
|
20
|
-
${chosenMethod} requests are not available when building a static site. Update your config to output: 'server' to handle ${chosenMethod} requests.`);
|
|
20
|
+
${chosenMethod} requests are not available when building a static site. Update your config to \`output: 'server'\` or \`output: 'hybrid'\` with an \`export const prerender = false\` to handle ${chosenMethod} requests.`);
|
|
21
21
|
}
|
|
22
22
|
if (!handler || typeof handler !== "function") {
|
|
23
23
|
let response = new Response(null, {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { AstroComponentMetadata, SSRElement, SSRLoadedRenderer, SSRResult } from '../../@types/astro';
|
|
2
|
-
export declare const HydrationDirectiveProps: Set<string>;
|
|
3
2
|
export interface HydrationMetadata {
|
|
4
3
|
directive: string;
|
|
5
4
|
value: string;
|
|
@@ -13,7 +12,7 @@ interface ExtractedProps {
|
|
|
13
12
|
hydration: HydrationMetadata | null;
|
|
14
13
|
props: Record<string | number | symbol, any>;
|
|
15
14
|
}
|
|
16
|
-
export declare function extractDirectives(
|
|
15
|
+
export declare function extractDirectives(inputProps: Record<string | number | symbol, any>, clientDirectives: SSRResult['_metadata']['clientDirectives']): ExtractedProps;
|
|
17
16
|
interface HydrateScriptOptions {
|
|
18
17
|
renderer: SSRLoadedRenderer;
|
|
19
18
|
result: SSRResult;
|
|
@@ -2,10 +2,7 @@ import { AstroError, AstroErrorData } from "../../core/errors/index.js";
|
|
|
2
2
|
import { escapeHTML } from "./escape.js";
|
|
3
3
|
import { serializeProps } from "./serialize.js";
|
|
4
4
|
import { serializeListValue } from "./util.js";
|
|
5
|
-
|
|
6
|
-
const HydrationDirectives = new Set(HydrationDirectivesRaw);
|
|
7
|
-
const HydrationDirectiveProps = new Set(HydrationDirectivesRaw.map((n) => `client:${n}`));
|
|
8
|
-
function extractDirectives(displayName, inputProps) {
|
|
5
|
+
function extractDirectives(inputProps, clientDirectives) {
|
|
9
6
|
let extracted = {
|
|
10
7
|
isPage: false,
|
|
11
8
|
hydration: null,
|
|
@@ -44,11 +41,10 @@ function extractDirectives(displayName, inputProps) {
|
|
|
44
41
|
default: {
|
|
45
42
|
extracted.hydration.directive = key.split(":")[1];
|
|
46
43
|
extracted.hydration.value = value;
|
|
47
|
-
if (!
|
|
44
|
+
if (!clientDirectives.has(extracted.hydration.directive)) {
|
|
45
|
+
const hydrationMethods = Array.from(clientDirectives.keys()).map((d) => `client:${d}`).join(", ");
|
|
48
46
|
throw new Error(
|
|
49
|
-
`Error: invalid hydration directive "${key}". Supported hydration methods: ${
|
|
50
|
-
HydrationDirectiveProps
|
|
51
|
-
).join(", ")}`
|
|
47
|
+
`Error: invalid hydration directive "${key}". Supported hydration methods: ${hydrationMethods}`
|
|
52
48
|
);
|
|
53
49
|
}
|
|
54
50
|
if (extracted.hydration.directive === "media" && typeof extracted.hydration.value !== "string") {
|
|
@@ -111,7 +107,6 @@ async function generateHydrateScript(scriptOptions, metadata) {
|
|
|
111
107
|
return island;
|
|
112
108
|
}
|
|
113
109
|
export {
|
|
114
|
-
HydrationDirectiveProps,
|
|
115
110
|
extractDirectives,
|
|
116
111
|
generateHydrateScript
|
|
117
112
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var _a;
|
|
2
|
-
import { HydrationDirectiveProps } from "../../hydration.js";
|
|
3
2
|
import { isPromise } from "../../util.js";
|
|
4
3
|
import { renderChild } from "../any.js";
|
|
5
4
|
import { isAPropagatingComponent } from "./factory.js";
|
|
@@ -40,7 +39,7 @@ _a = astroComponentInstanceSym;
|
|
|
40
39
|
function validateComponentProps(props, displayName) {
|
|
41
40
|
if (props != null) {
|
|
42
41
|
for (const prop of Object.keys(props)) {
|
|
43
|
-
if (
|
|
42
|
+
if (prop.startsWith("client:")) {
|
|
44
43
|
console.warn(
|
|
45
44
|
`You are attempting to render <${displayName} ${prop} />, but ${displayName} is an Astro component. Astro components do not render in the client and should not have a hydration directive. Please use a framework component for client rendering.`
|
|
46
45
|
);
|
|
@@ -7,7 +7,7 @@ export declare class RenderTemplateResult {
|
|
|
7
7
|
private expressions;
|
|
8
8
|
private error;
|
|
9
9
|
constructor(htmlParts: TemplateStringsArray, expressions: unknown[]);
|
|
10
|
-
[Symbol.asyncIterator](): AsyncGenerator<any, void,
|
|
10
|
+
[Symbol.asyncIterator](): AsyncGenerator<any, void, unknown>;
|
|
11
11
|
}
|
|
12
12
|
export declare function isRenderTemplateResult(obj: unknown): obj is RenderTemplateResult;
|
|
13
13
|
export declare function renderAstroTemplateResult(component: RenderTemplateResult): AsyncIterable<string | HTMLBytes | RenderInstruction>;
|