astro 1.0.0-beta.5 → 1.0.0-beta.6

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/LICENSE ADDED
@@ -0,0 +1,34 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Fred K. Schott
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+
24
+ """
25
+ This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/sveltejs/kit repository:
26
+
27
+ Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors)
28
+
29
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
30
+
31
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
32
+
33
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34
+ """
@@ -204,11 +204,11 @@ async function copyFiles(fromFolder, toFolder) {
204
204
  const files = await glob("**/*", {
205
205
  cwd: fileURLToPath(fromFolder)
206
206
  });
207
- await fs.promises.mkdir(toFolder, { recursive: true });
208
207
  await Promise.all(files.map(async (filename) => {
209
208
  const from = new URL(filename, fromFolder);
210
209
  const to = new URL(filename, toFolder);
211
- return fs.promises.copyFile(from, to);
210
+ const lastFolder = new URL("./", to);
211
+ return fs.promises.mkdir(lastFolder, { recursive: true }).then(() => fs.promises.copyFile(from, to));
212
212
  }));
213
213
  }
214
214
  async function ssrMoveAssets(opts) {
@@ -62,21 +62,107 @@ export interface BuildConfig {
62
62
  staticMode: boolean | undefined;
63
63
  }
64
64
  /**
65
- * Astro.* available in all components
66
- * Docs: https://docs.astro.build/reference/api-reference/#astro-global
65
+ * Astro global available in all contexts in .astro files
66
+ *
67
+ * [Astro reference](https://docs.astro.build/reference/api-reference/#astro-global)
67
68
  */
68
69
  export interface AstroGlobal extends AstroGlobalPartial {
69
- /** get the current canonical URL */
70
+ /** Canonical URL of the current page. If the [site](https://docs.astro.build/en/reference/configuration-reference/#site) config option is set, its origin will be the origin of this URL.
71
+ *
72
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astrocanonicalurl)
73
+ */
70
74
  canonicalURL: URL;
71
- /** get page params (dynamic pages only) */
75
+ /** Parameters passed to a dynamic page generated using [getStaticPaths](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
76
+ *
77
+ * Example usage:
78
+ * ```astro
79
+ * ---
80
+ * export async function getStaticPaths() {
81
+ * return [
82
+ * { params: { id: '1' } },
83
+ * ];
84
+ * }
85
+ *
86
+ * const { id } = Astro.params;
87
+ * ---
88
+ * <h1>{id}</h1>
89
+ * ```
90
+ *
91
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#params)
92
+ */
72
93
  params: Params;
73
- /** set props for this astro component (along with default values) */
94
+ /** List of props passed to this component
95
+ *
96
+ * A common way to get specific props is through [destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment), ex:
97
+ * ```typescript
98
+ * const { name } = Astro.props
99
+ * ```
100
+ *
101
+ * [Astro reference](https://docs.astro.build/en/core-concepts/astro-components/#component-props)
102
+ */
74
103
  props: Record<string, number | string | any>;
75
- /** get information about this page */
104
+ /** Information about the current request. This is a standard [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) object
105
+ *
106
+ * For example, to get a URL object of the current URL, you can use:
107
+ * ```typescript
108
+ * const url = new URL(Astro.request.url);
109
+ * ```
110
+ *
111
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astrorequest)
112
+ */
76
113
  request: Request;
77
- /** see if slots are used */
114
+ /** Redirect to another page (**SSR Only**)
115
+ *
116
+ * Example usage:
117
+ * ```typescript
118
+ * if(!isLoggedIn) {
119
+ * return Astro.redirect('/login');
120
+ * }
121
+ * ```
122
+ *
123
+ * [Astro reference](https://docs.astro.build/en/guides/server-side-rendering/#astroredirect)
124
+ */
125
+ redirect(path: string): Response;
126
+ /**
127
+ * The <Astro.self /> element allows a component to reference itself recursively.
128
+ *
129
+ * [Astro reference](https://docs.astro.build/en/guides/server-side-rendering/#astroself)
130
+ */
131
+ self: AstroComponentFactory;
132
+ /** Utility functions for modifying an Astro component’s slotted children
133
+ *
134
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots)
135
+ */
78
136
  slots: Record<string, true | undefined> & {
137
+ /**
138
+ * Check whether content for this slot name exists
139
+ *
140
+ * Example usage:
141
+ * ```typescript
142
+ * if (Astro.slots.has('default')) {
143
+ * // Do something...
144
+ * }
145
+ * ```
146
+ *
147
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots)
148
+ */
79
149
  has(slotName: string): boolean;
150
+ /**
151
+ * Asychronously renders this slot and returns HTML
152
+ *
153
+ * Example usage:
154
+ * ```astro
155
+ * ---
156
+ * let html: string = '';
157
+ * if (Astro.slots.has('default')) {
158
+ * html = await Astro.slots.render('default')
159
+ * }
160
+ * ---
161
+ * <Fragment set:html={html} />
162
+ * ```
163
+ *
164
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots)
165
+ */
80
166
  render(slotName: string, args?: any[]): Promise<string>;
81
167
  };
82
168
  }
@@ -84,12 +170,29 @@ export interface AstroGlobalPartial {
84
170
  /**
85
171
  * @deprecated since version 0.24. See the {@link https://astro.build/deprecated/resolve upgrade guide} for more details.
86
172
  */
87
- resolve: (path: string) => string;
88
- /** @deprecated Use `Astro.glob()` instead. */
173
+ resolve(path: string): string;
174
+ /** @deprecated since version 0.26. Use [Astro.glob()](https://docs.astro.build/en/reference/api-reference/#astroglob) instead. */
89
175
  fetchContent(globStr: string): Promise<any[]>;
176
+ /**
177
+ * Fetch local files into your static site setup
178
+ *
179
+ * Example usage:
180
+ * ```typescript
181
+ * const posts = await Astro.glob('../pages/post/*.md');
182
+ * ```
183
+ *
184
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroglob)
185
+ */
90
186
  glob(globStr: `${any}.astro`): Promise<ComponentInstance[]>;
91
187
  glob<T extends Record<string, any>>(globStr: `${any}.md`): Promise<MarkdownInstance<T>[]>;
92
188
  glob<T extends Record<string, any>>(globStr: string): Promise<T[]>;
189
+ /**
190
+ * Returns a [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) object built from the [site](https://docs.astro.build/en/reference/configuration-reference/#site) config option
191
+ *
192
+ * If `site` is undefined, the URL object will instead be built from `localhost`
193
+ *
194
+ * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astrosite)
195
+ */
93
196
  site: URL;
94
197
  }
95
198
  declare type ServerConfig = {
package/env.d.ts CHANGED
@@ -4,8 +4,9 @@ type Astro = import('astro').AstroGlobal;
4
4
 
5
5
  // We duplicate the description here because editors won't show the JSDoc comment from the imported type (but will for its properties, ex: Astro.request will show the AstroGlobal.request description)
6
6
  /**
7
- * Astro.* available in all components
8
- * Docs: https://docs.astro.build/reference/api-reference/#astro-global
7
+ * Astro global available in all contexts in .astro files
8
+ *
9
+ * [Astro documentation](https://docs.astro.build/reference/api-reference/#astro-global)
9
10
  */
10
11
  declare const Astro: Readonly<Astro>;
11
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "1.0.0-beta.5",
3
+ "version": "1.0.0-beta.6",
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",
@@ -65,25 +65,16 @@
65
65
  "README.md",
66
66
  "vendor"
67
67
  ],
68
- "scripts": {
69
- "build": "astro-scripts build \"src/**/*.ts\" && tsc",
70
- "build:ci": "astro-scripts build \"src/**/*.ts\"",
71
- "dev": "astro-scripts dev \"src/**/*.ts\"",
72
- "postbuild": "astro-scripts copy \"src/**/*.astro\"",
73
- "benchmark": "node test/benchmark/dev.bench.js && node test/benchmark/build.bench.js",
74
- "test": "mocha --exit --timeout 20000 --ignore **/lit-element.test.js && mocha --timeout 20000 **/lit-element.test.js",
75
- "test:match": "mocha --timeout 20000 -g"
76
- },
77
68
  "dependencies": {
78
69
  "@astrojs/compiler": "^0.14.1",
79
- "@astrojs/language-server": "^0.13.3",
70
+ "@astrojs/language-server": "^0.13.4",
80
71
  "@astrojs/markdown-remark": "^0.8.1",
81
72
  "@astrojs/prism": "0.4.1",
82
73
  "@astrojs/webapi": "^0.11.0",
83
- "@babel/core": "^7.17.8",
84
- "@babel/generator": "^7.17.7",
85
- "@babel/parser": "^7.17.8",
86
- "@babel/traverse": "^7.17.3",
74
+ "@babel/core": "^7.17.9",
75
+ "@babel/generator": "^7.17.9",
76
+ "@babel/parser": "^7.17.9",
77
+ "@babel/traverse": "^7.17.9",
87
78
  "@proload/core": "^0.2.2",
88
79
  "@proload/plugin-tsm": "^0.1.1",
89
80
  "@web/parse5-utils": "^1.3.0",
@@ -94,8 +85,8 @@
94
85
  "debug": "^4.3.4",
95
86
  "diff": "^5.0.0",
96
87
  "eol": "^0.9.1",
97
- "es-module-lexer": "^0.10.4",
98
- "esbuild": "0.14.25",
88
+ "es-module-lexer": "^0.10.5",
89
+ "esbuild": "^0.14.34",
99
90
  "estree-walker": "^3.0.1",
100
91
  "execa": "^6.1.0",
101
92
  "fast-glob": "^3.2.11",
@@ -120,7 +111,7 @@
120
111
  "rehype-slug": "^5.0.1",
121
112
  "resolve": "^1.22.0",
122
113
  "rollup": "^2.70.1",
123
- "semver": "^7.3.5",
114
+ "semver": "^7.3.6",
124
115
  "serialize-javascript": "^6.0.0",
125
116
  "shiki": "^0.10.1",
126
117
  "shorthash": "^0.0.2",
@@ -134,7 +125,7 @@
134
125
  "tsconfig-resolver": "^3.0.1",
135
126
  "vite": "^2.9.1",
136
127
  "yargs-parser": "^21.0.1",
137
- "zod": "^3.14.3"
128
+ "zod": "^3.14.4"
138
129
  },
139
130
  "devDependencies": {
140
131
  "@babel/types": "^7.17.0",
@@ -152,19 +143,29 @@
152
143
  "@types/mocha": "^9.1.0",
153
144
  "@types/parse5": "^6.0.3",
154
145
  "@types/path-browserify": "^1.0.0",
155
- "@types/prettier": "^2.4.4",
146
+ "@types/prettier": "^2.6.0",
156
147
  "@types/resolve": "^1.20.1",
157
148
  "@types/rimraf": "^3.0.2",
158
149
  "@types/send": "^0.17.1",
159
150
  "@types/yargs-parser": "^21.0.0",
160
- "astro-scripts": "workspace:*",
151
+ "astro-scripts": "0.0.2",
161
152
  "chai": "^4.3.6",
162
153
  "cheerio": "^1.0.0-rc.10",
163
154
  "mocha": "^9.2.2",
164
- "sass": "^1.49.11"
155
+ "sass": "^1.50.0"
165
156
  },
166
157
  "engines": {
167
158
  "node": "^14.15.0 || >=16.0.0",
168
159
  "npm": ">=6.14.0"
169
- }
170
- }
160
+ },
161
+ "scripts": {
162
+ "build": "astro-scripts build \"src/**/*.ts\" && tsc",
163
+ "build:ci": "astro-scripts build \"src/**/*.ts\"",
164
+ "dev": "astro-scripts dev \"src/**/*.ts\"",
165
+ "postbuild": "astro-scripts copy \"src/**/*.astro\"",
166
+ "benchmark": "node test/benchmark/dev.bench.js && node test/benchmark/build.bench.js",
167
+ "test": "mocha --exit --timeout 20000 --ignore **/lit-element.test.js && mocha --timeout 20000 **/lit-element.test.js",
168
+ "test:match": "mocha --timeout 20000 -g"
169
+ },
170
+ "readme": "<a href=\"https://astro.build\">\n <img src=\"https://raw.githubusercontent.com/withastro/astro/main/assets/social/banner.svg\" />\n</a>\n\n<div center>\n\n**Astro** is a new kind of static site builder for the modern web&mdash;powerful developer experience meets lightweight output.\n\n</div>\n\n### [🚀 Read the launch post →](https://astro.build/blog/introducing-astro)\n\n### [📚 Learn Astro →](https://docs.astro.build/en/getting-started/)\n\n## Project Status\n\n⚠️ **Astro is still beta software&mdash;missing features and bugs are to be expected!** We are quickly working our way towards a stable, production-ready v1.0 release, but we are still finalizing some of Astro's APIs.\n\nThat being said, there are quite a few Astro sites in production already. We're incredibly grateful to everyone who has made an early bet on Astro!\n\n## Quick Start\n\n<table>\n <tbody>\n <tr>\n <td>\n <img width=\"441\" height=\"1px\">\n <strong>👾 Online</strong>\n </td>\n <td>\n <img width=\"441\" height=\"1px\">\n <strong>📦 Local</strong>\n </td>\n </tr>\n <tr>\n<td>\n\nTry Astro in your browser!\n\n[Launch astro.new →](https://astro.new)\n\n</td>\n<td>\n\nGet started with Astro using our interactive CLI!\n\n```bash\nnpm init astro my-astro-project\n```\n\n</td>\n </tr>\n </tbody>\n</table>\n\n## Sponsors\n\nYou can sponsor Astro's development on [Open Collective](https://opencollective.com/astrodotbuild). Astro is generously supported by the following companies and individuals:\n\n### Platinum Sponsors\n\n<table>\n <tbody>\n <tr>\n <td align=\"center\"><a href=\"https://www.netlify.com/#gh-light-mode-only\" target=\"_blank\"><img width=\"147\" height=\"40\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/netlify.svg#gh-light-mode-only\" alt=\"Netlify\" /></a><a href=\"https://www.netlify.com/#gh-dark-mode-only\" target=\"_blank\"><img width=\"147\" height=\"40\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/netlify-dark.svg#gh-dark-mode-only\" alt=\"Netlify\" />\n </a></td>\n <td align=\"center\"><a href=\"https://www.vercel.com/#gh-light-mode-only\" target=\"_blank\"><img width=\"150\" height=\"34\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/vercel.svg#gh-light-mode-only\" alt=\"Vercel\" /></a><a href=\"https://www.vercel.com/#gh-dark-mode-only\"><img width=\"150\" height=\"34\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/vercel-dark.svg#gh-dark-mode-only\" alt=\"Vercel\" />\n </a></td>\n </tr>\n </tbody>\n</table>\n\n### Gold Sponsors\n\n<table>\n <tbody>\n <tr>\n <td align=\"center\">\n <a href=\"https://divRIOTS.com#gh-light-mode-only\" target=\"_blank\">\n <img width=\"150\" height=\"40\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/divriots.svg#gh-light-mode-only\" alt=\"‹div›RIOTS\" />\n </a>\n <a href=\"https://divRIOTS.com#gh-dark-mode-only\" target=\"_blank\">\n <img width=\"150\" height=\"40\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/divriots-dark.svg#gh-dark-mode-only\" alt=\"‹div›RIOTS\" />\n </a>\n </td>\n <td align=\"center\">\n <a href=\"https://stackupdigital.co.uk/#gh-light-mode-only\" target=\"_blank\">\n <img width=\"162\" height=\"40\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/stackup.svg#gh-light-mode-only\" alt=\"StackUp Digital\" />\n </a>\n <a href=\"https://stackupdigital.co.uk/#gh-dark-mode-only\" target=\"_blank\">\n <img width=\"130\" height=\"32\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/stackup-dark.svg#gh-dark-mode-only\" alt=\"StackUp Digital\" />\n </a>\n </td>\n </tr>\n </tbody>\n</table>\n\n### Sponsors\n\n<table>\n <tbody>\n <tr>\n <td align=\"center\"><a href=\"https://sentry.io\" target=\"_blank\"><img width=\"147\" height=\"40\" src=\"https://raw.githubusercontent.com/withastro/astro/main/.github/assets/sentry.svg\" alt=\"Sentry\" /></a></td><td align=\"center\"><a href=\"https://qoddi.com\" target=\"_blank\"><img width=\"147\" height=\"40\" src=\"https://devcenter.qoddi.com/wp-content/uploads/2021/11/blog-transparent-logo-1.png\" alt=\"Qoddi App Platform\" /></a></td>\n </tr>\n </tbody>\n</table>\n"
171
+ }