astro 1.2.8 → 1.3.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.
Files changed (50) hide show
  1. package/dist/@types/astro.d.ts +3 -0
  2. package/dist/cli/check/index.js +7 -2
  3. package/dist/cli/check/print.js +1 -2
  4. package/dist/cli/index.js +1 -1
  5. package/dist/core/build/generate.js +6 -0
  6. package/dist/core/build/index.js +9 -0
  7. package/dist/core/build/static-build.js +31 -11
  8. package/dist/core/config/schema.d.ts +12 -12
  9. package/dist/core/dev/index.js +7 -8
  10. package/dist/core/endpoint/index.js +1 -1
  11. package/dist/core/messages.d.ts +10 -6
  12. package/dist/core/messages.js +57 -32
  13. package/dist/core/path.d.ts +1 -0
  14. package/dist/core/path.js +4 -0
  15. package/dist/core/preview/index.js +8 -5
  16. package/dist/core/render/route-cache.js +1 -4
  17. package/dist/core/routing/params.js +1 -1
  18. package/dist/core/util.d.ts +1 -1
  19. package/dist/core/util.js +2 -2
  20. package/dist/integrations/index.d.ts +5 -0
  21. package/dist/integrations/index.js +18 -0
  22. package/dist/runtime/server/astro-global.js +1 -1
  23. package/dist/runtime/server/astro-island.js +4 -1
  24. package/dist/runtime/server/astro-island.prebuilt.d.ts +1 -1
  25. package/dist/runtime/server/astro-island.prebuilt.js +1 -1
  26. package/dist/runtime/server/endpoint.d.ts +1 -1
  27. package/dist/runtime/server/endpoint.js +5 -1
  28. package/dist/runtime/server/escape.d.ts +8 -1
  29. package/dist/runtime/server/escape.js +47 -4
  30. package/dist/runtime/server/hydration.js +3 -1
  31. package/dist/runtime/server/index.d.ts +1 -1
  32. package/dist/runtime/server/index.js +2 -1
  33. package/dist/runtime/server/jsx.js +4 -5
  34. package/dist/runtime/server/render/any.js +3 -1
  35. package/dist/runtime/server/render/astro.d.ts +3 -2
  36. package/dist/runtime/server/render/astro.js +4 -4
  37. package/dist/runtime/server/render/common.d.ts +12 -0
  38. package/dist/runtime/server/render/common.js +55 -0
  39. package/dist/runtime/server/render/component.d.ts +2 -1
  40. package/dist/runtime/server/render/page.js +22 -17
  41. package/dist/runtime/server/render/util.js +2 -2
  42. package/dist/runtime/server/response.js +1 -1
  43. package/dist/runtime/server/serialize.js +13 -1
  44. package/dist/runtime/server/util.d.ts +1 -0
  45. package/dist/runtime/server/util.js +4 -6
  46. package/dist/vite-plugin-astro/hmr.js +3 -2
  47. package/dist/vite-plugin-jsx/tag.js +52 -20
  48. package/dist/vite-plugin-markdown/index.js +6 -1
  49. package/dist/vite-plugin-utils/index.js +4 -1
  50. package/package.json +5 -4
@@ -36,27 +36,59 @@ function tagExportsWithRenderer({
36
36
  }
37
37
  }
38
38
  },
39
- ExportDeclaration(path, state) {
40
- var _a, _b;
41
- const node = path.node;
42
- if (node.exportKind === "type")
43
- return;
44
- if (node.type === "ExportAllDeclaration")
45
- return;
46
- if (node.type === "ExportNamedDeclaration") {
47
- if (t.isFunctionDeclaration(node.declaration)) {
48
- if ((_a = node.declaration.id) == null ? void 0 : _a.name) {
49
- const id = node.declaration.id.name;
50
- const tags = state.get("astro:tags") ?? [];
51
- state.set("astro:tags", [...tags, id]);
52
- }
39
+ ExportDeclaration: {
40
+ enter(path) {
41
+ var _a, _b, _c;
42
+ const node = path.node;
43
+ if (node.type !== "ExportDefaultDeclaration")
44
+ return;
45
+ if (((_a = node.declaration) == null ? void 0 : _a.type) === "ArrowFunctionExpression") {
46
+ const uidIdentifier = path.scope.generateUidIdentifier("_arrow_function");
47
+ path.insertBefore(
48
+ t.variableDeclaration("const", [
49
+ t.variableDeclarator(uidIdentifier, node.declaration)
50
+ ])
51
+ );
52
+ node.declaration = uidIdentifier;
53
+ } else if (((_b = node.declaration) == null ? void 0 : _b.type) === "FunctionDeclaration" && !((_c = node.declaration.id) == null ? void 0 : _c.name)) {
54
+ const uidIdentifier = path.scope.generateUidIdentifier("_function");
55
+ node.declaration.id = uidIdentifier;
53
56
  }
54
- } else if (node.type === "ExportDefaultDeclaration") {
55
- if (t.isFunctionDeclaration(node.declaration)) {
56
- if ((_b = node.declaration.id) == null ? void 0 : _b.name) {
57
- const id = node.declaration.id.name;
58
- const tags = state.get("astro:tags") ?? [];
59
- state.set("astro:tags", [...tags, id]);
57
+ },
58
+ exit(path, state) {
59
+ var _a, _b, _c;
60
+ const node = path.node;
61
+ if (node.exportKind === "type")
62
+ return;
63
+ if (node.type === "ExportAllDeclaration")
64
+ return;
65
+ const addTag = (id) => {
66
+ const tags = state.get("astro:tags") ?? [];
67
+ state.set("astro:tags", [...tags, id]);
68
+ };
69
+ if (node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration") {
70
+ if (t.isIdentifier(node.declaration)) {
71
+ addTag(node.declaration.name);
72
+ } else if (t.isFunctionDeclaration(node.declaration) && ((_a = node.declaration.id) == null ? void 0 : _a.name)) {
73
+ addTag(node.declaration.id.name);
74
+ } else if (t.isVariableDeclaration(node.declaration)) {
75
+ (_b = node.declaration.declarations) == null ? void 0 : _b.forEach((declaration) => {
76
+ if (t.isArrowFunctionExpression(declaration.init) && t.isIdentifier(declaration.id)) {
77
+ addTag(declaration.id.name);
78
+ }
79
+ });
80
+ } else if (t.isObjectExpression(node.declaration)) {
81
+ (_c = node.declaration.properties) == null ? void 0 : _c.forEach((property) => {
82
+ if (t.isProperty(property) && t.isIdentifier(property.key)) {
83
+ addTag(property.key.name);
84
+ }
85
+ });
86
+ } else if (t.isExportNamedDeclaration(node)) {
87
+ node.specifiers.forEach((specifier) => {
88
+ if (t.isExportSpecifier(specifier) && t.isIdentifier(specifier.exported)) {
89
+ addTag(specifier.local.name);
90
+ }
91
+ });
60
92
  }
61
93
  }
62
94
  }
@@ -1,6 +1,8 @@
1
1
  import { renderMarkdown } from "@astrojs/markdown-remark";
2
2
  import fs from "fs";
3
3
  import matter from "gray-matter";
4
+ import { fileURLToPath } from "node:url";
5
+ import { normalizePath } from "vite";
4
6
  import { collectErrorMetadata } from "../core/errors.js";
5
7
  import { warn } from "../core/logger/core.js";
6
8
  import { getFileInfo, safelyGetAstroData } from "../vite-plugin-utils/index.js";
@@ -12,6 +14,9 @@ function safeMatter(source, id) {
12
14
  throw collectErrorMetadata(e);
13
15
  }
14
16
  }
17
+ const astroJsxRuntimeModulePath = normalizePath(
18
+ fileURLToPath(new URL("../jsx-runtime/index.js", import.meta.url))
19
+ );
15
20
  function markdown({ settings, logging }) {
16
21
  return {
17
22
  enforce: "pre",
@@ -42,7 +47,7 @@ function markdown({ settings, logging }) {
42
47
  );
43
48
  }
44
49
  const code = escapeViteEnvReferences(`
45
- import { Fragment, jsx as h } from 'astro/jsx-runtime';
50
+ import { Fragment, jsx as h } from '${astroJsxRuntimeModulePath}';
46
51
  ${layout ? `import Layout from ${JSON.stringify(layout)};` : ""}
47
52
 
48
53
  const html = ${JSON.stringify(html)};
@@ -1,4 +1,4 @@
1
- import { appendForwardSlash } from "../core/path.js";
1
+ import { appendExtension, appendForwardSlash } from "../core/path.js";
2
2
  function getFileInfo(id, config) {
3
3
  const sitePathname = appendForwardSlash(
4
4
  config.site ? new URL(config.base, config.site).pathname : config.base
@@ -8,6 +8,9 @@ function getFileInfo(id, config) {
8
8
  if (fileUrl && config.trailingSlash === "always") {
9
9
  fileUrl = appendForwardSlash(fileUrl);
10
10
  }
11
+ if (fileUrl && config.build.format === "file") {
12
+ fileUrl = appendExtension(fileUrl, "html");
13
+ }
11
14
  return { fileId, fileUrl };
12
15
  }
13
16
  function isValidAstroData(obj) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "1.2.8",
3
+ "version": "1.3.1",
4
4
  "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
5
5
  "type": "module",
6
6
  "author": "withastro",
@@ -83,10 +83,10 @@
83
83
  ],
84
84
  "dependencies": {
85
85
  "@astrojs/compiler": "^0.24.0",
86
- "@astrojs/language-server": "^0.23.0",
86
+ "@astrojs/language-server": "^0.26.2",
87
87
  "@astrojs/markdown-remark": "^1.1.2",
88
88
  "@astrojs/telemetry": "^1.0.0",
89
- "@astrojs/webapi": "^1.0.0",
89
+ "@astrojs/webapi": "^1.1.0",
90
90
  "@babel/core": "^7.18.2",
91
91
  "@babel/generator": "^7.18.2",
92
92
  "@babel/parser": "^7.18.4",
@@ -134,6 +134,7 @@
134
134
  "strip-ansi": "^7.0.1",
135
135
  "supports-esm": "^1.0.0",
136
136
  "tsconfig-resolver": "^3.0.1",
137
+ "typescript": "*",
137
138
  "unist-util-visit": "^4.1.0",
138
139
  "vfile": "^5.3.2",
139
140
  "vite": "~3.1.3",
@@ -160,7 +161,7 @@
160
161
  "@types/send": "^0.17.1",
161
162
  "@types/unist": "^2.0.6",
162
163
  "ast-types": "^0.14.2",
163
- "astro-scripts": "0.0.7",
164
+ "astro-scripts": "0.0.8",
164
165
  "chai": "^4.3.6",
165
166
  "cheerio": "^1.0.0-rc.11",
166
167
  "mocha": "^9.2.2",