astro 4.7.1 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.d.ts +1 -0
- package/content-module.template.mjs +2 -0
- package/dist/@types/astro.d.ts +219 -3
- package/dist/actions/consts.d.ts +3 -0
- package/dist/actions/consts.js +8 -0
- package/dist/actions/index.d.ts +2 -0
- package/dist/actions/index.js +72 -0
- package/dist/actions/runtime/middleware.d.ts +7 -0
- package/dist/actions/runtime/middleware.js +38 -0
- package/dist/actions/runtime/route.d.ts +2 -0
- package/dist/actions/runtime/route.js +37 -0
- package/dist/actions/runtime/store.d.ts +6 -0
- package/dist/actions/runtime/store.js +18 -0
- package/dist/actions/runtime/utils.d.ts +4 -0
- package/dist/actions/runtime/utils.js +23 -0
- package/dist/actions/runtime/virtual/client.d.ts +4 -0
- package/dist/actions/runtime/virtual/client.js +20 -0
- package/dist/actions/runtime/virtual/server.d.ts +21 -0
- package/dist/actions/runtime/virtual/server.js +98 -0
- package/dist/actions/runtime/virtual/shared.d.ts +37 -0
- package/dist/actions/runtime/virtual/shared.js +104 -0
- package/dist/actions/utils.d.ts +2 -0
- package/dist/actions/utils.js +18 -0
- package/dist/assets/build/generate.js +1 -1
- package/dist/assets/internal.js +1 -2
- package/dist/assets/services/service.js +2 -4
- package/dist/assets/services/sharp.js +2 -4
- package/dist/assets/services/squoosh.js +2 -4
- package/dist/assets/services/vendor/squoosh/avif/avif_node_dec.js +34 -68
- package/dist/assets/services/vendor/squoosh/avif/avif_node_enc.js +39 -78
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.js +32 -64
- package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.js +32 -64
- package/dist/assets/services/vendor/squoosh/png/squoosh_png.js +2 -4
- package/dist/assets/services/vendor/squoosh/webp/webp_node_dec.js +29 -58
- package/dist/assets/services/vendor/squoosh/webp/webp_node_enc.js +29 -58
- package/dist/assets/utils/getAssetsPrefix.js +2 -4
- package/dist/assets/utils/remotePattern.js +1 -2
- package/dist/assets/utils/remoteProbe.js +1 -2
- package/dist/assets/utils/vendor/image-size/types/cur.js +1 -2
- package/dist/assets/utils/vendor/image-size/types/icns.js +1 -2
- package/dist/assets/utils/vendor/image-size/types/ico.js +2 -4
- package/dist/assets/utils/vendor/image-size/types/jp2.js +2 -4
- package/dist/assets/utils/vendor/image-size/types/utils.js +4 -8
- package/dist/assets/vite-plugin-assets.js +1 -1
- package/dist/cli/add/babel.d.ts +1 -1
- package/dist/cli/add/imports.js +4 -8
- package/dist/cli/add/index.js +23 -46
- package/dist/cli/add/wrapper.js +1 -2
- package/dist/cli/index.js +1 -2
- package/dist/cli/info/index.js +1 -2
- package/dist/cli/install-package.js +3 -6
- package/dist/cli/throw-and-exit.js +1 -2
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +2 -2
- package/dist/content/index.d.ts +1 -1
- package/dist/content/index.js +1 -7
- package/dist/content/runtime.d.ts +2 -1
- package/dist/content/runtime.js +11 -20
- package/dist/content/server-listeners.js +5 -10
- package/dist/content/types-generator.js +5 -10
- package/dist/content/utils.d.ts +0 -4
- package/dist/content/utils.js +4 -15
- package/dist/content/vite-plugin-content-assets.d.ts +1 -1
- package/dist/content/vite-plugin-content-assets.js +14 -47
- package/dist/content/vite-plugin-content-imports.js +6 -11
- package/dist/content/vite-plugin-content-virtual-mod.js +7 -14
- package/dist/core/app/index.js +11 -46
- package/dist/core/app/node.js +4 -3
- package/dist/core/app/pipeline.d.ts +7 -2
- package/dist/core/app/pipeline.js +70 -2
- package/dist/core/app/types.d.ts +1 -0
- package/dist/core/base-pipeline.d.ts +16 -1
- package/dist/core/build/generate.js +15 -61
- package/dist/core/build/index.js +2 -4
- package/dist/core/build/internal.d.ts +39 -9
- package/dist/core/build/internal.js +43 -54
- package/dist/core/build/page-data.js +6 -6
- package/dist/core/build/pipeline.d.ts +7 -3
- package/dist/core/build/pipeline.js +134 -23
- package/dist/core/build/plugins/plugin-analyzer.js +11 -32
- package/dist/core/build/plugins/plugin-content.d.ts +1 -0
- package/dist/core/build/plugins/plugin-content.js +34 -32
- package/dist/core/build/plugins/plugin-css.js +23 -51
- package/dist/core/build/plugins/plugin-manifest.js +7 -8
- package/dist/core/build/plugins/plugin-pages.d.ts +0 -1
- package/dist/core/build/plugins/plugin-pages.js +10 -12
- package/dist/core/build/plugins/plugin-ssr.js +15 -13
- package/dist/core/build/plugins/util.d.ts +26 -11
- package/dist/core/build/plugins/util.js +22 -6
- package/dist/core/build/static-build.js +30 -25
- package/dist/core/build/types.d.ts +6 -6
- package/dist/core/client-directive/build.js +1 -2
- package/dist/core/config/config.js +2 -7
- package/dist/core/config/logging.js +1 -2
- package/dist/core/config/schema.d.ts +92 -60
- package/dist/core/config/schema.js +6 -2
- package/dist/core/config/settings.js +1 -2
- package/dist/core/config/timer.js +4 -8
- package/dist/core/constants.js +1 -1
- package/dist/core/cookies/cookies.js +3 -6
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/dev/restart.js +1 -2
- package/dist/core/errors/errors-data.d.ts +24 -0
- package/dist/core/errors/errors-data.js +13 -2
- package/dist/core/errors/errors.js +1 -2
- package/dist/core/errors/overlay.js +1 -2
- package/dist/core/errors/printer.js +2 -4
- package/dist/core/errors/zod-error-map.js +2 -4
- package/dist/core/fs/index.js +2 -4
- package/dist/core/logger/vite.js +9 -18
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/callMiddleware.d.ts +3 -2
- package/dist/core/middleware/callMiddleware.js +13 -3
- package/dist/core/middleware/index.js +12 -8
- package/dist/core/middleware/sequence.js +22 -4
- package/dist/core/module-loader/vite.js +1 -2
- package/dist/core/render/params-and-props.js +2 -4
- package/dist/core/render/slots.js +4 -8
- package/dist/core/render-context.d.ts +15 -5
- package/dist/core/render-context.js +134 -28
- package/dist/core/request.js +1 -2
- package/dist/core/routing/manifest/create.js +3 -6
- package/dist/core/sync/index.js +10 -3
- package/dist/core/util.d.ts +2 -0
- package/dist/core/util.js +18 -19
- package/dist/i18n/index.js +2 -4
- package/dist/i18n/middleware.js +1 -2
- package/dist/i18n/utils.js +1 -2
- package/dist/i18n/vite-plugin-i18n.js +1 -2
- package/dist/integrations/hooks.js +5 -1
- package/dist/jsx/babel.d.ts +3 -0
- package/dist/jsx/babel.js +9 -18
- package/dist/jsx/rehype.d.ts +11 -0
- package/dist/jsx/rehype.js +197 -0
- package/dist/jsx/server.js +20 -14
- package/dist/jsx/transform-options.d.ts +3 -0
- package/dist/jsx-runtime/index.js +8 -16
- package/dist/preferences/index.js +3 -6
- package/dist/preferences/store.js +3 -6
- package/dist/prefetch/index.js +8 -16
- package/dist/prefetch/vite-plugin-prefetch.js +2 -4
- package/dist/prerender/metadata.js +1 -2
- package/dist/prerender/routing.js +1 -1
- package/dist/prerender/utils.d.ts +0 -1
- package/dist/prerender/utils.js +2 -5
- package/dist/runtime/client/dev-toolbar/apps/astro.js +5 -10
- package/dist/runtime/client/dev-toolbar/apps/audit/index.js +5 -10
- package/dist/runtime/client/dev-toolbar/apps/audit/rules/a11y.js +45 -90
- package/dist/runtime/client/dev-toolbar/apps/audit/rules/index.js +1 -2
- package/dist/runtime/client/dev-toolbar/apps/audit/rules/perf.js +16 -32
- package/dist/runtime/client/dev-toolbar/apps/audit/ui/audit-list-window.js +2 -4
- package/dist/runtime/client/dev-toolbar/apps/audit/ui/audit-ui.js +3 -6
- package/dist/runtime/client/dev-toolbar/apps/utils/highlight.js +1 -2
- package/dist/runtime/client/dev-toolbar/apps/utils/window.js +4 -8
- package/dist/runtime/client/dev-toolbar/entrypoint.js +8 -11
- package/dist/runtime/client/dev-toolbar/helpers.js +2 -4
- package/dist/runtime/client/dev-toolbar/toolbar.js +11 -22
- package/dist/runtime/client/dev-toolbar/ui-library/badge.js +1 -2
- package/dist/runtime/client/dev-toolbar/ui-library/button.d.ts +5 -0
- package/dist/runtime/client/dev-toolbar/ui-library/button.js +26 -5
- package/dist/runtime/client/dev-toolbar/ui-library/index.d.ts +1 -0
- package/dist/runtime/client/dev-toolbar/ui-library/index.js +2 -0
- package/dist/runtime/client/dev-toolbar/ui-library/radio-checkbox.d.ts +13 -0
- package/dist/runtime/client/dev-toolbar/ui-library/radio-checkbox.js +109 -0
- package/dist/runtime/client/visible.js +1 -2
- package/dist/runtime/server/astro-component.js +2 -4
- package/dist/runtime/server/astro-island.js +7 -14
- package/dist/runtime/server/astro-island.prebuilt-dev.d.ts +1 -1
- package/dist/runtime/server/astro-island.prebuilt-dev.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/index.js +3 -6
- package/dist/runtime/server/jsx.js +1 -2
- package/dist/runtime/server/render/any.js +1 -2
- package/dist/runtime/server/render/astro/instance.js +1 -2
- package/dist/runtime/server/render/astro/render.js +5 -10
- package/dist/runtime/server/render/component.js +6 -11
- package/dist/runtime/server/render/dom.js +1 -2
- package/dist/runtime/server/render/page.js +1 -2
- package/dist/runtime/server/render/script.js +1 -2
- package/dist/runtime/server/render/slot.js +1 -2
- package/dist/runtime/server/render/tags.js +2 -4
- package/dist/runtime/server/render/util.js +2 -4
- package/dist/runtime/server/shorthash.js +1 -2
- package/dist/runtime/server/transition.js +4 -8
- package/dist/runtime/server/util.js +1 -2
- package/dist/transitions/events.d.ts +3 -3
- package/dist/transitions/events.js +5 -4
- package/dist/transitions/router.js +22 -113
- package/dist/transitions/swap-functions.d.ts +12 -0
- package/dist/transitions/swap-functions.js +105 -0
- package/dist/vite-plugin-astro/compile.js +1 -2
- package/dist/vite-plugin-astro/hmr.js +5 -10
- package/dist/vite-plugin-astro/index.js +2 -4
- package/dist/vite-plugin-astro-server/pipeline.d.ts +8 -3
- package/dist/vite-plugin-astro-server/pipeline.js +59 -11
- package/dist/vite-plugin-astro-server/plugin.js +6 -6
- package/dist/vite-plugin-astro-server/response.js +1 -2
- package/dist/vite-plugin-astro-server/route.js +36 -42
- package/dist/vite-plugin-astro-server/vite.js +1 -2
- package/dist/vite-plugin-config-alias/index.js +7 -14
- package/dist/vite-plugin-head/index.js +3 -6
- package/dist/vite-plugin-html/index.js +1 -2
- package/dist/vite-plugin-html/transform/escape.js +2 -4
- package/dist/vite-plugin-html/transform/slots.js +1 -2
- package/dist/vite-plugin-html/transform/utils.js +1 -2
- package/dist/vite-plugin-inject-env-ts/index.js +37 -11
- package/dist/vite-plugin-integrations-container/index.js +3 -6
- package/dist/vite-plugin-load-fallback/index.js +1 -2
- package/dist/vite-plugin-markdown/index.js +1 -2
- package/dist/vite-plugin-mdx/index.d.ts +3 -0
- package/dist/vite-plugin-mdx/tag.d.ts +2 -0
- package/dist/vite-plugin-mdx/tag.js +3 -6
- package/dist/vite-plugin-mdx/transform-jsx.d.ts +3 -0
- package/dist/vite-plugin-mdx/transform-jsx.js +1 -2
- package/dist/vite-plugin-scanner/index.js +4 -6
- package/dist/vite-plugin-scanner/scan.js +2 -4
- package/dist/vite-plugin-scripts/page-ssr.js +3 -6
- package/package.json +18 -14
- package/templates/actions.mjs +61 -0
- package/types/actions.d.ts +3 -0
- package/types/content.d.ts +2 -2
|
@@ -5,8 +5,7 @@ const CUR = {
|
|
|
5
5
|
validate(input) {
|
|
6
6
|
const reserved = readUInt16LE(input, 0);
|
|
7
7
|
const imageCount = readUInt16LE(input, 4);
|
|
8
|
-
if (reserved !== 0 || imageCount === 0)
|
|
9
|
-
return false;
|
|
8
|
+
if (reserved !== 0 || imageCount === 0) return false;
|
|
10
9
|
const imageType = readUInt16LE(input, 2);
|
|
11
10
|
return imageType === TYPE_CURSOR;
|
|
12
11
|
},
|
|
@@ -64,8 +64,7 @@ const ICNS = {
|
|
|
64
64
|
let imageHeader = readImageHeader(input, imageOffset);
|
|
65
65
|
let imageSize = getImageSize(imageHeader[0]);
|
|
66
66
|
imageOffset += imageHeader[1];
|
|
67
|
-
if (imageOffset === fileLength)
|
|
68
|
-
return imageSize;
|
|
67
|
+
if (imageOffset === fileLength) return imageSize;
|
|
69
68
|
const result = {
|
|
70
69
|
height: imageSize.height,
|
|
71
70
|
images: [imageSize],
|
|
@@ -17,16 +17,14 @@ const ICO = {
|
|
|
17
17
|
validate(input) {
|
|
18
18
|
const reserved = readUInt16LE(input, 0);
|
|
19
19
|
const imageCount = readUInt16LE(input, 4);
|
|
20
|
-
if (reserved !== 0 || imageCount === 0)
|
|
21
|
-
return false;
|
|
20
|
+
if (reserved !== 0 || imageCount === 0) return false;
|
|
22
21
|
const imageType = readUInt16LE(input, 2);
|
|
23
22
|
return imageType === TYPE_ICON;
|
|
24
23
|
},
|
|
25
24
|
calculate(input) {
|
|
26
25
|
const nbImages = readUInt16LE(input, 4);
|
|
27
26
|
const imageSize = getImageSize(input, 0);
|
|
28
|
-
if (nbImages === 1)
|
|
29
|
-
return imageSize;
|
|
27
|
+
if (nbImages === 1) return imageSize;
|
|
30
28
|
const imgs = [imageSize];
|
|
31
29
|
for (let imageIndex = 1; imageIndex < nbImages; imageIndex += 1) {
|
|
32
30
|
imgs.push(getImageSize(input, imageIndex));
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { readUInt32BE, findBox } from "./utils.js";
|
|
2
2
|
const JP2 = {
|
|
3
3
|
validate(input) {
|
|
4
|
-
if (readUInt32BE(input, 4) !== 1783636e3 || readUInt32BE(input, 0) < 1)
|
|
5
|
-
return false;
|
|
4
|
+
if (readUInt32BE(input, 4) !== 1783636e3 || readUInt32BE(input, 0) < 1) return false;
|
|
6
5
|
const ftypBox = findBox(input, "ftyp", 0);
|
|
7
|
-
if (!ftypBox)
|
|
8
|
-
return false;
|
|
6
|
+
if (!ftypBox) return false;
|
|
9
7
|
return readUInt32BE(input, ftypBox.offset + 4) === 1718909296;
|
|
10
8
|
},
|
|
11
9
|
calculate(input) {
|
|
@@ -24,11 +24,9 @@ function readUInt(input, bits, offset, isBigEndian) {
|
|
|
24
24
|
return methods[methodName](input, offset);
|
|
25
25
|
}
|
|
26
26
|
function readBox(buffer, offset) {
|
|
27
|
-
if (buffer.length - offset < 4)
|
|
28
|
-
return;
|
|
27
|
+
if (buffer.length - offset < 4) return;
|
|
29
28
|
const boxSize = readUInt32BE(buffer, offset);
|
|
30
|
-
if (buffer.length - offset < boxSize)
|
|
31
|
-
return;
|
|
29
|
+
if (buffer.length - offset < boxSize) return;
|
|
32
30
|
return {
|
|
33
31
|
name: toUTF8String(buffer, 4 + offset, 8 + offset),
|
|
34
32
|
offset,
|
|
@@ -38,10 +36,8 @@ function readBox(buffer, offset) {
|
|
|
38
36
|
function findBox(buffer, boxName, offset) {
|
|
39
37
|
while (offset < buffer.length) {
|
|
40
38
|
const box = readBox(buffer, offset);
|
|
41
|
-
if (!box)
|
|
42
|
-
|
|
43
|
-
if (box.name === boxName)
|
|
44
|
-
return box;
|
|
39
|
+
if (!box) break;
|
|
40
|
+
if (box.name === boxName) return box;
|
|
45
41
|
offset += box.size;
|
|
46
42
|
}
|
|
47
43
|
}
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
removeBase,
|
|
11
11
|
removeQueryString
|
|
12
12
|
} from "../core/path.js";
|
|
13
|
-
import { isServerLikeOutput } from "../
|
|
13
|
+
import { isServerLikeOutput } from "../core/util.js";
|
|
14
14
|
import { VALID_INPUT_FORMATS, VIRTUAL_MODULE_ID, VIRTUAL_SERVICE_ID } from "./consts.js";
|
|
15
15
|
import { emitESMImage } from "./utils/emitAsset.js";
|
|
16
16
|
import { getAssetsPrefix } from "./utils/getAssetsPrefix.js";
|
package/dist/cli/add/babel.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare const visit: {
|
|
|
11
11
|
node: (node: traverse.Node, opts: traverse.TraverseOptions<traverse.Node>, scope?: traverse.Scope | undefined, state?: any, path?: traverse.NodePath<traverse.Node> | undefined, skipKeys?: Record<string, boolean> | undefined) => void;
|
|
12
12
|
clearNode: (node: traverse.Node, opts?: traverse.RemovePropertiesOptions | undefined) => void;
|
|
13
13
|
removeProperties: (tree: traverse.Node, opts?: traverse.RemovePropertiesOptions | undefined) => traverse.Node;
|
|
14
|
-
hasType: (tree: traverse.Node, type: "CatchClause" | "ClassBody" | "Identifier" | "Program" | "SpreadElement" | "Super" | "SwitchCase" | "TemplateElement" | "VariableDeclarator" | "ArrayExpression" | "ArrowFunctionExpression" | "AssignmentExpression" | "AwaitExpression" | "BinaryExpression" | "CallExpression" | "ClassExpression" | "ConditionalExpression" | "FunctionExpression" | "ImportExpression" | "LogicalExpression" | "MemberExpression" | "MetaProperty" | "NewExpression" | "ObjectExpression" | "SequenceExpression" | "TaggedTemplateExpression" | "TemplateLiteral" | "ThisExpression" | "UnaryExpression" | "UpdateExpression" | "YieldExpression" | "ClassDeclaration" | "FunctionDeclaration" | "ImportDeclaration" | "ExportNamedDeclaration" | "ExportDefaultDeclaration" | "ExportAllDeclaration" | "ImportSpecifier" | "ImportDefaultSpecifier" | "ImportNamespaceSpecifier" | "ExportSpecifier" | "ObjectPattern" | "ArrayPattern" | "RestElement" | "AssignmentPattern" | "ExpressionStatement" | "BlockStatement" | "StaticBlock" | "EmptyStatement" | "DebuggerStatement" | "WithStatement" | "ReturnStatement" | "LabeledStatement" | "BreakStatement" | "ContinueStatement" | "IfStatement" | "SwitchStatement" | "ThrowStatement" | "TryStatement" | "WhileStatement" | "DoWhileStatement" | "ForStatement" | "ForInStatement" | "ForOfStatement" | "VariableDeclaration" | "File" | "
|
|
14
|
+
hasType: (tree: traverse.Node, type: "CatchClause" | "ClassBody" | "Identifier" | "Program" | "SpreadElement" | "Super" | "SwitchCase" | "TemplateElement" | "VariableDeclarator" | "JSXIdentifier" | "JSXNamespacedName" | "JSXMemberExpression" | "JSXEmptyExpression" | "JSXExpressionContainer" | "JSXSpreadAttribute" | "JSXAttribute" | "JSXOpeningElement" | "JSXOpeningFragment" | "JSXClosingElement" | "JSXClosingFragment" | "JSXElement" | "JSXFragment" | "JSXText" | "ArrayExpression" | "ArrowFunctionExpression" | "AssignmentExpression" | "AwaitExpression" | "BinaryExpression" | "CallExpression" | "ClassExpression" | "ConditionalExpression" | "FunctionExpression" | "ImportExpression" | "LogicalExpression" | "MemberExpression" | "MetaProperty" | "NewExpression" | "ObjectExpression" | "SequenceExpression" | "TaggedTemplateExpression" | "TemplateLiteral" | "ThisExpression" | "UnaryExpression" | "UpdateExpression" | "YieldExpression" | "ClassDeclaration" | "FunctionDeclaration" | "ImportDeclaration" | "ExportNamedDeclaration" | "ExportDefaultDeclaration" | "ExportAllDeclaration" | "ImportSpecifier" | "ImportDefaultSpecifier" | "ImportNamespaceSpecifier" | "ExportSpecifier" | "ObjectPattern" | "ArrayPattern" | "RestElement" | "AssignmentPattern" | "ExpressionStatement" | "BlockStatement" | "StaticBlock" | "EmptyStatement" | "DebuggerStatement" | "WithStatement" | "ReturnStatement" | "LabeledStatement" | "BreakStatement" | "ContinueStatement" | "IfStatement" | "SwitchStatement" | "ThrowStatement" | "TryStatement" | "WhileStatement" | "DoWhileStatement" | "ForStatement" | "ForInStatement" | "ForOfStatement" | "VariableDeclaration" | "File" | "AnyTypeAnnotation" | "ArgumentPlaceholder" | "ArrayTypeAnnotation" | "BigIntLiteral" | "BindExpression" | "BooleanLiteral" | "BooleanLiteralTypeAnnotation" | "BooleanTypeAnnotation" | "ClassAccessorProperty" | "ClassImplements" | "ClassMethod" | "ClassPrivateMethod" | "ClassPrivateProperty" | "ClassProperty" | "DecimalLiteral" | "DeclareClass" | "DeclareExportAllDeclaration" | "DeclareExportDeclaration" | "DeclareFunction" | "DeclareInterface" | "DeclareModule" | "DeclareModuleExports" | "DeclareOpaqueType" | "DeclareTypeAlias" | "DeclareVariable" | "DeclaredPredicate" | "Decorator" | "Directive" | "DirectiveLiteral" | "DoExpression" | "EmptyTypeAnnotation" | "EnumBooleanBody" | "EnumBooleanMember" | "EnumDeclaration" | "EnumDefaultedMember" | "EnumNumberBody" | "EnumNumberMember" | "EnumStringBody" | "EnumStringMember" | "EnumSymbolBody" | "ExistsTypeAnnotation" | "ExportDefaultSpecifier" | "ExportNamespaceSpecifier" | "FunctionTypeAnnotation" | "FunctionTypeParam" | "GenericTypeAnnotation" | "Import" | "ImportAttribute" | "IndexedAccessType" | "InferredPredicate" | "InterfaceDeclaration" | "InterfaceExtends" | "InterfaceTypeAnnotation" | "InterpreterDirective" | "IntersectionTypeAnnotation" | "JSXSpreadChild" | "MixedTypeAnnotation" | "ModuleExpression" | "Noop" | "NullLiteral" | "NullLiteralTypeAnnotation" | "NullableTypeAnnotation" | "NumberLiteral" | "NumberLiteralTypeAnnotation" | "NumberTypeAnnotation" | "NumericLiteral" | "ObjectMethod" | "ObjectProperty" | "ObjectTypeAnnotation" | "ObjectTypeCallProperty" | "ObjectTypeIndexer" | "ObjectTypeInternalSlot" | "ObjectTypeProperty" | "ObjectTypeSpreadProperty" | "OpaqueType" | "OptionalCallExpression" | "OptionalIndexedAccessType" | "OptionalMemberExpression" | "ParenthesizedExpression" | "PipelineBareFunction" | "PipelinePrimaryTopicReference" | "PipelineTopicExpression" | "Placeholder" | "PrivateName" | "QualifiedTypeIdentifier" | "RecordExpression" | "RegExpLiteral" | "RegexLiteral" | "RestProperty" | "SpreadProperty" | "StringLiteral" | "StringLiteralTypeAnnotation" | "StringTypeAnnotation" | "SymbolTypeAnnotation" | "TSAnyKeyword" | "TSArrayType" | "TSAsExpression" | "TSBigIntKeyword" | "TSBooleanKeyword" | "TSCallSignatureDeclaration" | "TSConditionalType" | "TSConstructSignatureDeclaration" | "TSConstructorType" | "TSDeclareFunction" | "TSDeclareMethod" | "TSEnumDeclaration" | "TSEnumMember" | "TSExportAssignment" | "TSExpressionWithTypeArguments" | "TSExternalModuleReference" | "TSFunctionType" | "TSImportEqualsDeclaration" | "TSImportType" | "TSIndexSignature" | "TSIndexedAccessType" | "TSInferType" | "TSInstantiationExpression" | "TSInterfaceBody" | "TSInterfaceDeclaration" | "TSIntersectionType" | "TSIntrinsicKeyword" | "TSLiteralType" | "TSMappedType" | "TSMethodSignature" | "TSModuleBlock" | "TSModuleDeclaration" | "TSNamedTupleMember" | "TSNamespaceExportDeclaration" | "TSNeverKeyword" | "TSNonNullExpression" | "TSNullKeyword" | "TSNumberKeyword" | "TSObjectKeyword" | "TSOptionalType" | "TSParameterProperty" | "TSParenthesizedType" | "TSPropertySignature" | "TSQualifiedName" | "TSRestType" | "TSSatisfiesExpression" | "TSStringKeyword" | "TSSymbolKeyword" | "TSThisType" | "TSTupleType" | "TSTypeAliasDeclaration" | "TSTypeAnnotation" | "TSTypeAssertion" | "TSTypeLiteral" | "TSTypeOperator" | "TSTypeParameter" | "TSTypeParameterDeclaration" | "TSTypeParameterInstantiation" | "TSTypePredicate" | "TSTypeQuery" | "TSTypeReference" | "TSUndefinedKeyword" | "TSUnionType" | "TSUnknownKeyword" | "TSVoidKeyword" | "ThisTypeAnnotation" | "TopicReference" | "TupleExpression" | "TupleTypeAnnotation" | "TypeAlias" | "TypeAnnotation" | "TypeCastExpression" | "TypeParameter" | "TypeParameterDeclaration" | "TypeParameterInstantiation" | "TypeofTypeAnnotation" | "UnionTypeAnnotation" | "V8IntrinsicIdentifier" | "Variance" | "VoidTypeAnnotation", denylistTypes?: string[] | undefined) => boolean;
|
|
15
15
|
cache: typeof traverse.cache;
|
|
16
16
|
};
|
|
17
17
|
export { t };
|
package/dist/cli/add/imports.js
CHANGED
|
@@ -6,8 +6,7 @@ function ensureImport(root, importDeclaration) {
|
|
|
6
6
|
if (path.node.source.value === importDeclaration.source.value) {
|
|
7
7
|
path.node.specifiers.forEach(
|
|
8
8
|
(specifier) => specifiersToFind.forEach((specifierToFind, i) => {
|
|
9
|
-
if (specifier.type !== specifierToFind.type)
|
|
10
|
-
return;
|
|
9
|
+
if (specifier.type !== specifierToFind.type) return;
|
|
11
10
|
if (specifier.local.name === specifierToFind.local.name) {
|
|
12
11
|
specifiersToFind.splice(i, 1);
|
|
13
12
|
}
|
|
@@ -16,16 +15,13 @@ function ensureImport(root, importDeclaration) {
|
|
|
16
15
|
}
|
|
17
16
|
}
|
|
18
17
|
});
|
|
19
|
-
if (specifiersToFind.length === 0)
|
|
20
|
-
return;
|
|
18
|
+
if (specifiersToFind.length === 0) return;
|
|
21
19
|
visit(root, {
|
|
22
20
|
Program(path) {
|
|
23
21
|
const declaration = t.importDeclaration(specifiersToFind, importDeclaration.source);
|
|
24
22
|
const latestImport = path.get("body").filter((statement) => statement.isImportDeclaration()).pop();
|
|
25
|
-
if (latestImport)
|
|
26
|
-
|
|
27
|
-
else
|
|
28
|
-
path.unshiftContainer("body", declaration);
|
|
23
|
+
if (latestImport) latestImport.insertAfter(declaration);
|
|
24
|
+
else path.unshiftContainer("body", declaration);
|
|
29
25
|
}
|
|
30
26
|
});
|
|
31
27
|
}
|
package/dist/cli/add/index.js
CHANGED
|
@@ -349,8 +349,7 @@ function isAdapter(integration) {
|
|
|
349
349
|
async function parseAstroConfig(configURL) {
|
|
350
350
|
const source = await fs.readFile(fileURLToPath(configURL), { encoding: "utf-8" });
|
|
351
351
|
const result = parse(source);
|
|
352
|
-
if (!result)
|
|
353
|
-
throw new Error("Unknown error parsing astro config");
|
|
352
|
+
if (!result) throw new Error("Unknown error parsing astro config");
|
|
354
353
|
if (result.errors.length > 0)
|
|
355
354
|
throw new Error("Error parsing astro config: " + JSON.stringify(result.errors));
|
|
356
355
|
return result;
|
|
@@ -379,21 +378,16 @@ async function addIntegration(ast, integration) {
|
|
|
379
378
|
visit(ast, {
|
|
380
379
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
381
380
|
ExportDefaultDeclaration(path2) {
|
|
382
|
-
if (!t.isCallExpression(path2.node.declaration))
|
|
383
|
-
return;
|
|
381
|
+
if (!t.isCallExpression(path2.node.declaration)) return;
|
|
384
382
|
const configObject = path2.node.declaration.arguments[0];
|
|
385
|
-
if (!t.isObjectExpression(configObject))
|
|
386
|
-
return;
|
|
383
|
+
if (!t.isObjectExpression(configObject)) return;
|
|
387
384
|
let integrationsProp = configObject.properties.find((prop) => {
|
|
388
|
-
if (prop.type !== "ObjectProperty")
|
|
389
|
-
return false;
|
|
385
|
+
if (prop.type !== "ObjectProperty") return false;
|
|
390
386
|
if (prop.key.type === "Identifier") {
|
|
391
|
-
if (prop.key.name === "integrations")
|
|
392
|
-
return true;
|
|
387
|
+
if (prop.key.name === "integrations") return true;
|
|
393
388
|
}
|
|
394
389
|
if (prop.key.type === "StringLiteral") {
|
|
395
|
-
if (prop.key.value === "integrations")
|
|
396
|
-
return true;
|
|
390
|
+
if (prop.key.value === "integrations") return true;
|
|
397
391
|
}
|
|
398
392
|
return false;
|
|
399
393
|
});
|
|
@@ -409,8 +403,7 @@ async function addIntegration(ast, integration) {
|
|
|
409
403
|
const existingIntegrationCall = integrationsProp.value.elements.find(
|
|
410
404
|
(expr) => t.isCallExpression(expr) && t.isIdentifier(expr.callee) && expr.callee.name === integrationId.name
|
|
411
405
|
);
|
|
412
|
-
if (existingIntegrationCall)
|
|
413
|
-
return;
|
|
406
|
+
if (existingIntegrationCall) return;
|
|
414
407
|
integrationsProp.value.elements.push(integrationCall);
|
|
415
408
|
}
|
|
416
409
|
});
|
|
@@ -424,21 +417,16 @@ async function setAdapter(ast, adapter, exportName) {
|
|
|
424
417
|
visit(ast, {
|
|
425
418
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
426
419
|
ExportDefaultDeclaration(path2) {
|
|
427
|
-
if (!t.isCallExpression(path2.node.declaration))
|
|
428
|
-
return;
|
|
420
|
+
if (!t.isCallExpression(path2.node.declaration)) return;
|
|
429
421
|
const configObject = path2.node.declaration.arguments[0];
|
|
430
|
-
if (!t.isObjectExpression(configObject))
|
|
431
|
-
return;
|
|
422
|
+
if (!t.isObjectExpression(configObject)) return;
|
|
432
423
|
let outputProp = configObject.properties.find((prop) => {
|
|
433
|
-
if (prop.type !== "ObjectProperty")
|
|
434
|
-
return false;
|
|
424
|
+
if (prop.type !== "ObjectProperty") return false;
|
|
435
425
|
if (prop.key.type === "Identifier") {
|
|
436
|
-
if (prop.key.name === "output")
|
|
437
|
-
return true;
|
|
426
|
+
if (prop.key.name === "output") return true;
|
|
438
427
|
}
|
|
439
428
|
if (prop.key.type === "StringLiteral") {
|
|
440
|
-
if (prop.key.value === "output")
|
|
441
|
-
return true;
|
|
429
|
+
if (prop.key.value === "output") return true;
|
|
442
430
|
}
|
|
443
431
|
return false;
|
|
444
432
|
});
|
|
@@ -448,15 +436,12 @@ async function setAdapter(ast, adapter, exportName) {
|
|
|
448
436
|
);
|
|
449
437
|
}
|
|
450
438
|
let adapterProp = configObject.properties.find((prop) => {
|
|
451
|
-
if (prop.type !== "ObjectProperty")
|
|
452
|
-
return false;
|
|
439
|
+
if (prop.type !== "ObjectProperty") return false;
|
|
453
440
|
if (prop.key.type === "Identifier") {
|
|
454
|
-
if (prop.key.name === "adapter")
|
|
455
|
-
return true;
|
|
441
|
+
if (prop.key.name === "adapter") return true;
|
|
456
442
|
}
|
|
457
443
|
if (prop.key.type === "StringLiteral") {
|
|
458
|
-
if (prop.key.value === "adapter")
|
|
459
|
-
return true;
|
|
444
|
+
if (prop.key.value === "adapter") return true;
|
|
460
445
|
}
|
|
461
446
|
return false;
|
|
462
447
|
});
|
|
@@ -553,8 +538,7 @@ async function getInstallIntegrationsCommand({
|
|
|
553
538
|
}) {
|
|
554
539
|
const pm = await preferredPM(cwd);
|
|
555
540
|
logger.debug("add", `package manager: ${JSON.stringify(pm)}`);
|
|
556
|
-
if (!pm)
|
|
557
|
-
return null;
|
|
541
|
+
if (!pm) return null;
|
|
558
542
|
const dependencies = await convertIntegrationsToInstallSpecifiers(integrations);
|
|
559
543
|
switch (pm.name) {
|
|
560
544
|
case "npm":
|
|
@@ -583,8 +567,7 @@ async function convertIntegrationsToInstallSpecifiers(integrations) {
|
|
|
583
567
|
}
|
|
584
568
|
async function resolveRangeToInstallSpecifier(name, range) {
|
|
585
569
|
const versions = await fetchPackageVersions(name);
|
|
586
|
-
if (versions instanceof Error)
|
|
587
|
-
return name;
|
|
570
|
+
if (versions instanceof Error) return name;
|
|
588
571
|
const stableVersions = versions.filter((v) => !v.includes("-"));
|
|
589
572
|
const maxStable = maxSatisfying(stableVersions, range);
|
|
590
573
|
return `${name}@^${maxStable}`;
|
|
@@ -606,11 +589,9 @@ async function tryToInstallIntegrations({
|
|
|
606
589
|
}) {
|
|
607
590
|
const installCommand = await getInstallIntegrationsCommand({ integrations, cwd, logger });
|
|
608
591
|
const inheritedFlags = Object.entries(flags).map(([flag]) => {
|
|
609
|
-
if (flag == "_")
|
|
610
|
-
return;
|
|
592
|
+
if (flag == "_") return;
|
|
611
593
|
if (INHERITED_FLAGS.has(flag)) {
|
|
612
|
-
if (flag.length === 1)
|
|
613
|
-
return `-${flag}`;
|
|
594
|
+
if (flag.length === 1) return `-${flag}`;
|
|
614
595
|
return `--${flag}`;
|
|
615
596
|
}
|
|
616
597
|
}).filter(Boolean).flat();
|
|
@@ -840,8 +821,7 @@ ${message}`
|
|
|
840
821
|
}
|
|
841
822
|
function parseIntegrationName(spec) {
|
|
842
823
|
const result = parseNpmName(spec);
|
|
843
|
-
if (!result)
|
|
844
|
-
return;
|
|
824
|
+
if (!result) return;
|
|
845
825
|
let { scope, name } = result;
|
|
846
826
|
let tag = "latest";
|
|
847
827
|
if (scope) {
|
|
@@ -855,8 +835,7 @@ function parseIntegrationName(spec) {
|
|
|
855
835
|
return { scope, name, tag };
|
|
856
836
|
}
|
|
857
837
|
async function askToContinue({ flags }) {
|
|
858
|
-
if (flags.yes || flags.y)
|
|
859
|
-
return true;
|
|
838
|
+
if (flags.yes || flags.y) return true;
|
|
860
839
|
const response = await prompts({
|
|
861
840
|
type: "confirm",
|
|
862
841
|
name: "askToContinue",
|
|
@@ -869,11 +848,9 @@ function getDiffContent(input, output) {
|
|
|
869
848
|
let changes = [];
|
|
870
849
|
for (const change of diffWords(input, output)) {
|
|
871
850
|
let lines = change.value.trim().split("\n").slice(0, change.count);
|
|
872
|
-
if (lines.length === 0)
|
|
873
|
-
continue;
|
|
851
|
+
if (lines.length === 0) continue;
|
|
874
852
|
if (change.added) {
|
|
875
|
-
if (!change.value.trim())
|
|
876
|
-
continue;
|
|
853
|
+
if (!change.value.trim()) continue;
|
|
877
854
|
changes.push(change.value);
|
|
878
855
|
}
|
|
879
856
|
}
|
package/dist/cli/add/wrapper.js
CHANGED
|
@@ -2,8 +2,7 @@ import { t, visit } from "./babel.js";
|
|
|
2
2
|
function wrapDefaultExport(ast, functionIdentifier) {
|
|
3
3
|
visit(ast, {
|
|
4
4
|
ExportDefaultDeclaration(path) {
|
|
5
|
-
if (!t.isExpression(path.node.declaration))
|
|
6
|
-
return;
|
|
5
|
+
if (!t.isExpression(path.node.declaration)) return;
|
|
7
6
|
if (t.isCallExpression(path.node.declaration) && t.isIdentifier(path.node.declaration.callee) && path.node.declaration.callee.name === functionIdentifier.name)
|
|
8
7
|
return;
|
|
9
8
|
path.node.declaration = t.callExpression(functionIdentifier, [path.node.declaration]);
|
package/dist/cli/index.js
CHANGED
package/dist/cli/info/index.js
CHANGED
|
@@ -25,8 +25,7 @@ async function getPackage(packageName, logger, options, otherDeps = []) {
|
|
|
25
25
|
const packageImport = await import(packageName);
|
|
26
26
|
return packageImport;
|
|
27
27
|
} catch (e) {
|
|
28
|
-
if (options.optional)
|
|
29
|
-
return void 0;
|
|
28
|
+
if (options.optional) return void 0;
|
|
30
29
|
let message = `To continue, Astro requires the following dependency to be installed: ${bold(
|
|
31
30
|
packageName
|
|
32
31
|
)}.`;
|
|
@@ -178,15 +177,13 @@ async function fetchPackageVersions(packageName) {
|
|
|
178
177
|
}
|
|
179
178
|
let _registry;
|
|
180
179
|
async function getRegistry() {
|
|
181
|
-
if (_registry)
|
|
182
|
-
return _registry;
|
|
180
|
+
if (_registry) return _registry;
|
|
183
181
|
const fallback = "https://registry.npmjs.org";
|
|
184
182
|
const packageManager = (await preferredPM(process.cwd()))?.name || "npm";
|
|
185
183
|
try {
|
|
186
184
|
const { stdout } = await execa(packageManager, ["config", "get", "registry"]);
|
|
187
185
|
_registry = stdout?.trim()?.replace(/\/$/, "") || fallback;
|
|
188
|
-
if (!new URL(_registry).host)
|
|
189
|
-
_registry = fallback;
|
|
186
|
+
if (!new URL(_registry).host) _registry = fallback;
|
|
190
187
|
} catch (e) {
|
|
191
188
|
_registry = fallback;
|
|
192
189
|
}
|
|
@@ -5,8 +5,7 @@ import { debug } from "../core/logger/core.js";
|
|
|
5
5
|
import { formatErrorMessage } from "../core/messages.js";
|
|
6
6
|
import { eventError, telemetry } from "../events/index.js";
|
|
7
7
|
async function throwAndExit(cmd, err) {
|
|
8
|
-
if (isAstroConfigZodError(err))
|
|
9
|
-
return;
|
|
8
|
+
if (isAstroConfigZodError(err)) return;
|
|
10
9
|
let telemetryPromise;
|
|
11
10
|
let errorMessage;
|
|
12
11
|
function exitWithErrorMessage() {
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { UserConfig } from 'vite';
|
|
2
|
-
import type { AstroUserConfig } from '../@types/astro.js';
|
|
2
|
+
import type { AstroInlineConfig, AstroUserConfig } from '../@types/astro.js';
|
|
3
3
|
export declare function defineConfig(config: AstroUserConfig): AstroUserConfig;
|
|
4
|
-
export declare function getViteConfig(inlineConfig: UserConfig): ({ mode, command }: {
|
|
4
|
+
export declare function getViteConfig(inlineConfig: UserConfig, inlineAstroConfig?: AstroInlineConfig): ({ mode, command }: {
|
|
5
5
|
mode: string;
|
|
6
6
|
command: 'serve' | 'build';
|
|
7
7
|
}) => Promise<Record<string, any>>;
|
package/dist/config/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Logger } from "../core/logger/core.js";
|
|
|
2
2
|
function defineConfig(config) {
|
|
3
3
|
return config;
|
|
4
4
|
}
|
|
5
|
-
function getViteConfig(inlineConfig) {
|
|
5
|
+
function getViteConfig(inlineConfig, inlineAstroConfig = {}) {
|
|
6
6
|
return async ({ mode, command }) => {
|
|
7
7
|
const cmd = command === "serve" ? "dev" : command;
|
|
8
8
|
const [
|
|
@@ -26,7 +26,7 @@ function getViteConfig(inlineConfig) {
|
|
|
26
26
|
dest: nodeLogDestination,
|
|
27
27
|
level: "info"
|
|
28
28
|
});
|
|
29
|
-
const { astroConfig: config } = await resolveConfig(
|
|
29
|
+
const { astroConfig: config } = await resolveConfig(inlineAstroConfig, cmd);
|
|
30
30
|
let settings = await createSettings(config, inlineConfig.root);
|
|
31
31
|
settings = await runHookConfigSetup({ settings, command: cmd, logger });
|
|
32
32
|
const viteConfig = await createVite(
|
package/dist/content/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { CONTENT_FLAG, PROPAGATED_ASSET_FLAG } from './consts.js';
|
|
2
2
|
export { attachContentServerListeners } from './server-listeners.js';
|
|
3
3
|
export { createContentTypesGenerator } from './types-generator.js';
|
|
4
|
-
export { contentObservable, getContentPaths,
|
|
4
|
+
export { contentObservable, getContentPaths, hasAssetPropagationFlag } from './utils.js';
|
|
5
5
|
export { astroContentAssetPropagationPlugin } from './vite-plugin-content-assets.js';
|
|
6
6
|
export { astroContentImportPlugin } from './vite-plugin-content-imports.js';
|
|
7
7
|
export { astroContentVirtualModPlugin } from './vite-plugin-content-virtual-mod.js';
|
package/dist/content/index.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { CONTENT_FLAG, PROPAGATED_ASSET_FLAG } from "./consts.js";
|
|
2
2
|
import { attachContentServerListeners } from "./server-listeners.js";
|
|
3
3
|
import { createContentTypesGenerator } from "./types-generator.js";
|
|
4
|
-
import {
|
|
5
|
-
contentObservable,
|
|
6
|
-
getContentPaths,
|
|
7
|
-
getDotAstroTypeReference,
|
|
8
|
-
hasAssetPropagationFlag
|
|
9
|
-
} from "./utils.js";
|
|
4
|
+
import { contentObservable, getContentPaths, hasAssetPropagationFlag } from "./utils.js";
|
|
10
5
|
import { astroContentAssetPropagationPlugin } from "./vite-plugin-content-assets.js";
|
|
11
6
|
import { astroContentImportPlugin } from "./vite-plugin-content-imports.js";
|
|
12
7
|
import { astroContentVirtualModPlugin } from "./vite-plugin-content-virtual-mod.js";
|
|
@@ -20,6 +15,5 @@ export {
|
|
|
20
15
|
contentObservable,
|
|
21
16
|
createContentTypesGenerator,
|
|
22
17
|
getContentPaths,
|
|
23
|
-
getDotAstroTypeReference,
|
|
24
18
|
hasAssetPropagationFlag
|
|
25
19
|
};
|
|
@@ -10,10 +10,11 @@ export declare function createCollectionToGlobResultMap({ globResult, contentDir
|
|
|
10
10
|
globResult: GlobResult;
|
|
11
11
|
contentDir: string;
|
|
12
12
|
}): CollectionToEntryMap;
|
|
13
|
-
export declare function createGetCollection({ contentCollectionToEntryMap, dataCollectionToEntryMap, getRenderEntryImport, }: {
|
|
13
|
+
export declare function createGetCollection({ contentCollectionToEntryMap, dataCollectionToEntryMap, getRenderEntryImport, cacheEntriesByCollection, }: {
|
|
14
14
|
contentCollectionToEntryMap: CollectionToEntryMap;
|
|
15
15
|
dataCollectionToEntryMap: CollectionToEntryMap;
|
|
16
16
|
getRenderEntryImport: GetEntryImport;
|
|
17
|
+
cacheEntriesByCollection: Map<string, any[]>;
|
|
17
18
|
}): (collection: string, filter?: (entry: any) => unknown) => Promise<any[]>;
|
|
18
19
|
export declare function createGetEntryBySlug({ getEntryImport, getRenderEntryImport, }: {
|
|
19
20
|
getEntryImport: GetEntryImport;
|
package/dist/content/runtime.js
CHANGED
|
@@ -12,8 +12,7 @@ import {
|
|
|
12
12
|
unescapeHTML
|
|
13
13
|
} from "../runtime/server/index.js";
|
|
14
14
|
function defineCollection(config) {
|
|
15
|
-
if (!config.type)
|
|
16
|
-
config.type = "content";
|
|
15
|
+
if (!config.type) config.type = "content";
|
|
17
16
|
return config;
|
|
18
17
|
}
|
|
19
18
|
function createCollectionToGlobResultMap({
|
|
@@ -24,19 +23,18 @@ function createCollectionToGlobResultMap({
|
|
|
24
23
|
for (const key in globResult) {
|
|
25
24
|
const keyRelativeToContentDir = key.replace(new RegExp(`^${contentDir}`), "");
|
|
26
25
|
const segments = keyRelativeToContentDir.split("/");
|
|
27
|
-
if (segments.length <= 1)
|
|
28
|
-
continue;
|
|
26
|
+
if (segments.length <= 1) continue;
|
|
29
27
|
const collection = segments[0];
|
|
30
28
|
collectionToGlobResultMap[collection] ??= {};
|
|
31
29
|
collectionToGlobResultMap[collection][key] = globResult[key];
|
|
32
30
|
}
|
|
33
31
|
return collectionToGlobResultMap;
|
|
34
32
|
}
|
|
35
|
-
const cacheEntriesByCollection = /* @__PURE__ */ new Map();
|
|
36
33
|
function createGetCollection({
|
|
37
34
|
contentCollectionToEntryMap,
|
|
38
35
|
dataCollectionToEntryMap,
|
|
39
|
-
getRenderEntryImport
|
|
36
|
+
getRenderEntryImport,
|
|
37
|
+
cacheEntriesByCollection
|
|
40
38
|
}) {
|
|
41
39
|
return async function getCollection(collection, filter) {
|
|
42
40
|
let type;
|
|
@@ -100,8 +98,7 @@ function createGetEntryBySlug({
|
|
|
100
98
|
}) {
|
|
101
99
|
return async function getEntryBySlug(collection, slug) {
|
|
102
100
|
const entryImport = await getEntryImport(collection, slug);
|
|
103
|
-
if (typeof entryImport !== "function")
|
|
104
|
-
return void 0;
|
|
101
|
+
if (typeof entryImport !== "function") return void 0;
|
|
105
102
|
const entry = await entryImport();
|
|
106
103
|
return {
|
|
107
104
|
id: entry.id,
|
|
@@ -122,8 +119,7 @@ function createGetEntryBySlug({
|
|
|
122
119
|
function createGetDataEntryById({ getEntryImport }) {
|
|
123
120
|
return async function getDataEntryById(collection, id) {
|
|
124
121
|
const lazyImport = await getEntryImport(collection, id);
|
|
125
|
-
if (!lazyImport)
|
|
126
|
-
throw new Error(`Entry ${collection} \u2192 ${id} was not found.`);
|
|
122
|
+
if (!lazyImport) throw new Error(`Entry ${collection} \u2192 ${id} was not found.`);
|
|
127
123
|
const entry = await lazyImport();
|
|
128
124
|
return {
|
|
129
125
|
id: entry.id,
|
|
@@ -151,8 +147,7 @@ function createGetEntry({
|
|
|
151
147
|
lookupId = "id" in collectionOrLookupObject ? collectionOrLookupObject.id : collectionOrLookupObject.slug;
|
|
152
148
|
}
|
|
153
149
|
const entryImport = await getEntryImport(collection, lookupId);
|
|
154
|
-
if (typeof entryImport !== "function")
|
|
155
|
-
return void 0;
|
|
150
|
+
if (typeof entryImport !== "function") return void 0;
|
|
156
151
|
const entry = await entryImport();
|
|
157
152
|
if (entry._internal.type === "content") {
|
|
158
153
|
return {
|
|
@@ -193,19 +188,15 @@ async function render({
|
|
|
193
188
|
...AstroErrorData.UnknownContentCollectionError,
|
|
194
189
|
message: `Unexpected error while rendering ${String(collection)} \u2192 ${String(id)}.`
|
|
195
190
|
});
|
|
196
|
-
if (typeof renderEntryImport !== "function")
|
|
197
|
-
throw UnexpectedRenderError;
|
|
191
|
+
if (typeof renderEntryImport !== "function") throw UnexpectedRenderError;
|
|
198
192
|
const baseMod = await renderEntryImport();
|
|
199
|
-
if (baseMod == null || typeof baseMod !== "object")
|
|
200
|
-
throw UnexpectedRenderError;
|
|
193
|
+
if (baseMod == null || typeof baseMod !== "object") throw UnexpectedRenderError;
|
|
201
194
|
const { default: defaultMod } = baseMod;
|
|
202
195
|
if (isPropagatedAssetsModule(defaultMod)) {
|
|
203
196
|
const { collectedStyles, collectedLinks, collectedScripts, getMod } = defaultMod;
|
|
204
|
-
if (typeof getMod !== "function")
|
|
205
|
-
throw UnexpectedRenderError;
|
|
197
|
+
if (typeof getMod !== "function") throw UnexpectedRenderError;
|
|
206
198
|
const propagationMod = await getMod();
|
|
207
|
-
if (propagationMod == null || typeof propagationMod !== "object")
|
|
208
|
-
throw UnexpectedRenderError;
|
|
199
|
+
if (propagationMod == null || typeof propagationMod !== "object") throw UnexpectedRenderError;
|
|
209
200
|
const Content = createComponent({
|
|
210
201
|
factory(result, baseProps, slots) {
|
|
211
202
|
let styles = "", links = "", scripts = "";
|
|
@@ -20,8 +20,7 @@ async function attachContentServerListeners({
|
|
|
20
20
|
)} for changes`
|
|
21
21
|
);
|
|
22
22
|
const maybeTsConfigStats = await getTSConfigStatsWhenAllowJsFalse({ contentPaths, settings });
|
|
23
|
-
if (maybeTsConfigStats)
|
|
24
|
-
warnAllowJsIsFalse({ ...maybeTsConfigStats, logger });
|
|
23
|
+
if (maybeTsConfigStats) warnAllowJsIsFalse({ ...maybeTsConfigStats, logger });
|
|
25
24
|
await attachListeners();
|
|
26
25
|
} else {
|
|
27
26
|
viteServer.watcher.on("addDir", contentDirListener);
|
|
@@ -86,18 +85,14 @@ async function getTSConfigStatsWhenAllowJsFalse({
|
|
|
86
85
|
const isContentConfigJsFile = [".js", ".mjs"].some(
|
|
87
86
|
(ext) => contentPaths.config.url.pathname.endsWith(ext)
|
|
88
87
|
);
|
|
89
|
-
if (!isContentConfigJsFile)
|
|
90
|
-
return;
|
|
88
|
+
if (!isContentConfigJsFile) return;
|
|
91
89
|
const inputConfig = await loadTSConfig(fileURLToPath(settings.config.root));
|
|
92
|
-
if (typeof inputConfig === "string")
|
|
93
|
-
return;
|
|
90
|
+
if (typeof inputConfig === "string") return;
|
|
94
91
|
const tsConfigFileName = inputConfig.tsconfigFile.split(path.sep).pop();
|
|
95
|
-
if (!tsConfigFileName)
|
|
96
|
-
return;
|
|
92
|
+
if (!tsConfigFileName) return;
|
|
97
93
|
const contentConfigFileName = contentPaths.config.url.pathname.split(path.sep).pop();
|
|
98
94
|
const allowJSOption = inputConfig.tsconfig.compilerOptions?.allowJs;
|
|
99
|
-
if (allowJSOption)
|
|
100
|
-
return;
|
|
95
|
+
if (allowJSOption) return;
|
|
101
96
|
return { tsConfigFileName, contentConfigFileName };
|
|
102
97
|
}
|
|
103
98
|
export {
|
|
@@ -52,8 +52,7 @@ async function createContentTypesGenerator({
|
|
|
52
52
|
for (const entry of globResult) {
|
|
53
53
|
const fullPath = path.join(fileURLToPath(contentPaths.contentDir), entry.path);
|
|
54
54
|
const entryURL = pathToFileURL(fullPath);
|
|
55
|
-
if (entryURL.href.startsWith(contentPaths.config.url.href))
|
|
56
|
-
continue;
|
|
55
|
+
if (entryURL.href.startsWith(contentPaths.config.url.href)) continue;
|
|
57
56
|
if (entry.dirent.isFile()) {
|
|
58
57
|
events.push({ name: "add", entry: entryURL });
|
|
59
58
|
} else if (entry.dirent.isDirectory()) {
|
|
@@ -70,8 +69,7 @@ async function createContentTypesGenerator({
|
|
|
70
69
|
);
|
|
71
70
|
const collectionKey2 = JSON.stringify(collection2);
|
|
72
71
|
const isCollectionEvent = collection2.split("/").length === 1;
|
|
73
|
-
if (!isCollectionEvent)
|
|
74
|
-
return { shouldGenerateTypes: false };
|
|
72
|
+
if (!isCollectionEvent) return { shouldGenerateTypes: false };
|
|
75
73
|
switch (event.name) {
|
|
76
74
|
case "addDir":
|
|
77
75
|
collectionEntryMap[JSON.stringify(collection2)] = {
|
|
@@ -153,8 +151,7 @@ async function createContentTypesGenerator({
|
|
|
153
151
|
}
|
|
154
152
|
}
|
|
155
153
|
const contentEntryType = contentEntryConfigByExt.get(path.extname(event.entry.pathname));
|
|
156
|
-
if (!contentEntryType)
|
|
157
|
-
return { shouldGenerateTypes: false };
|
|
154
|
+
if (!contentEntryType) return { shouldGenerateTypes: false };
|
|
158
155
|
const { id, slug: generatedSlug } = getContentEntryIdAndSlug({
|
|
159
156
|
entry,
|
|
160
157
|
contentDir,
|
|
@@ -224,8 +221,7 @@ async function createContentTypesGenerator({
|
|
|
224
221
|
entry: pathToFileURL(rawEvent.entry),
|
|
225
222
|
name: rawEvent.name
|
|
226
223
|
};
|
|
227
|
-
if (!event.entry.pathname.startsWith(contentPaths.contentDir.pathname))
|
|
228
|
-
return;
|
|
224
|
+
if (!event.entry.pathname.startsWith(contentPaths.contentDir.pathname)) return;
|
|
229
225
|
events.push(event);
|
|
230
226
|
debounceTimeout && clearTimeout(debounceTimeout);
|
|
231
227
|
const runEventsSafe = async () => {
|
|
@@ -267,8 +263,7 @@ async function createContentTypesGenerator({
|
|
|
267
263
|
}
|
|
268
264
|
function invalidateVirtualMod(viteServer) {
|
|
269
265
|
const virtualMod = viteServer.moduleGraph.getModuleById("\0" + VIRTUAL_MODULE_ID);
|
|
270
|
-
if (!virtualMod)
|
|
271
|
-
return;
|
|
266
|
+
if (!virtualMod) return;
|
|
272
267
|
viteServer.moduleGraph.invalidateModule(virtualMod);
|
|
273
268
|
}
|
|
274
269
|
function normalizeConfigPath(from, to) {
|