astro 0.20.9 → 0.21.0-next.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.
Files changed (220) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +3 -2
  3. package/astro.js +5 -4
  4. package/components/Code.astro +6 -6
  5. package/components/Debug.astro +25 -277
  6. package/components/Markdown.astro +18 -11
  7. package/dist/@types/{astro.js → astro-core.js} +0 -0
  8. package/dist/@types/{compiler.js → astro-runtime.js} +0 -0
  9. package/dist/cli/check.js +94 -0
  10. package/dist/cli/index.js +166 -0
  11. package/dist/core/build/index.js +186 -0
  12. package/dist/core/build/stats.js +93 -0
  13. package/dist/core/config.js +66 -0
  14. package/dist/core/create-vite.js +73 -0
  15. package/dist/core/dev/index.js +257 -0
  16. package/dist/core/dev/messages.js +35 -0
  17. package/dist/core/dev/template/error.js +48 -0
  18. package/dist/core/dev/util.js +11 -0
  19. package/dist/core/logger.js +141 -0
  20. package/dist/core/preview/index.js +47 -0
  21. package/dist/core/ssr/css.js +34 -0
  22. package/dist/core/ssr/html.js +78 -0
  23. package/dist/core/ssr/index.js +173 -0
  24. package/dist/{build → core/ssr}/paginate.js +1 -1
  25. package/dist/core/ssr/routing.js +251 -0
  26. package/dist/{build → core/ssr}/rss.js +15 -13
  27. package/dist/core/ssr/sitemap.js +15 -0
  28. package/dist/core/util.js +69 -0
  29. package/dist/core/vite.js +6 -0
  30. package/dist/runtime/client/hmr.js +27 -0
  31. package/dist/{frontend/hydrate → runtime/client}/idle.js +1 -1
  32. package/dist/{frontend/hydrate → runtime/client}/load.js +1 -1
  33. package/dist/{frontend/hydrate → runtime/client}/media.js +1 -1
  34. package/dist/{frontend/hydrate → runtime/client}/only.js +1 -1
  35. package/dist/{frontend/hydrate → runtime/client}/visible.js +1 -1
  36. package/dist/runtime/server/index.js +356 -0
  37. package/dist/runtime/server/metadata.js +52 -0
  38. package/dist/types/@types/astro-core.d.ts +310 -0
  39. package/dist/types/@types/astro-runtime.d.ts +52 -0
  40. package/dist/types/cli/check.d.ts +3 -0
  41. package/dist/types/{cli.d.ts → cli/index.d.ts} +0 -0
  42. package/dist/types/core/build/index.d.ts +8 -0
  43. package/dist/types/core/build/stats.d.ts +31 -0
  44. package/dist/types/{config.d.ts → core/config.d.ts} +27 -22
  45. package/dist/types/core/create-vite.d.ts +18 -0
  46. package/dist/types/core/dev/index.d.ts +43 -0
  47. package/dist/types/core/dev/messages.d.ts +26 -0
  48. package/dist/types/core/dev/template/error.d.ts +9 -0
  49. package/dist/types/core/dev/util.d.ts +2 -0
  50. package/dist/types/{logger.d.ts → core/logger.d.ts} +3 -0
  51. package/dist/types/core/preview/index.d.ts +16 -0
  52. package/dist/types/core/ssr/css.d.ts +5 -0
  53. package/dist/types/core/ssr/html.d.ts +3 -0
  54. package/dist/types/core/ssr/index.d.ts +26 -0
  55. package/dist/types/{build → core/ssr}/paginate.d.ts +1 -1
  56. package/dist/types/core/ssr/routing.d.ts +19 -0
  57. package/dist/types/{build → core/ssr}/rss.d.ts +6 -5
  58. package/dist/types/core/ssr/sitemap.d.ts +2 -0
  59. package/dist/types/core/util.d.ts +13 -0
  60. package/dist/types/core/vite.d.ts +2 -0
  61. package/dist/types/{frontend/__astro_config.d.ts → runtime/client/hmr.d.ts} +0 -0
  62. package/dist/types/{frontend/hydrate → runtime/client}/idle.d.ts +1 -1
  63. package/dist/types/{frontend/hydrate → runtime/client}/load.d.ts +1 -1
  64. package/dist/types/{frontend/hydrate → runtime/client}/media.d.ts +1 -1
  65. package/dist/types/{frontend/hydrate → runtime/client}/only.d.ts +1 -1
  66. package/dist/types/{frontend/hydrate → runtime/client}/visible.d.ts +1 -1
  67. package/dist/types/runtime/server/index.d.ts +26 -0
  68. package/dist/types/runtime/server/metadata.d.ts +21 -0
  69. package/dist/types/vite-plugin-astro/index.d.ts +10 -0
  70. package/dist/types/vite-plugin-astro/styles.d.ts +14 -0
  71. package/dist/types/vite-plugin-astro-postprocess/index.d.ts +9 -0
  72. package/dist/types/vite-plugin-fetch/index.d.ts +2 -0
  73. package/dist/types/vite-plugin-jsx/index.d.ts +10 -0
  74. package/dist/types/vite-plugin-markdown/index.d.ts +10 -0
  75. package/dist/vite-plugin-astro/index.js +86 -0
  76. package/dist/vite-plugin-astro/styles.js +21 -0
  77. package/dist/vite-plugin-astro-postprocess/index.js +54 -0
  78. package/dist/vite-plugin-fetch/index.js +52 -0
  79. package/dist/vite-plugin-jsx/index.js +161 -0
  80. package/dist/vite-plugin-markdown/index.js +73 -0
  81. package/package.json +63 -68
  82. package/vendor/vite/LICENSE.md +2150 -0
  83. package/vendor/vite/client.d.ts +204 -0
  84. package/vendor/vite/dist/client/client.mjs +553 -0
  85. package/vendor/vite/dist/client/client.mjs.map +1 -0
  86. package/vendor/vite/dist/client/env.mjs +30 -0
  87. package/vendor/vite/dist/client/env.mjs.map +1 -0
  88. package/vendor/vite/dist/node/chunks/dep-34d2edc0.js +29182 -0
  89. package/vendor/vite/dist/node/chunks/dep-34d2edc0.js.map +1 -0
  90. package/vendor/vite/dist/node/chunks/dep-35df7f96.js +92083 -0
  91. package/vendor/vite/dist/node/chunks/dep-35df7f96.js.map +1 -0
  92. package/vendor/vite/dist/node/chunks/dep-a5b4350d.js +8734 -0
  93. package/vendor/vite/dist/node/chunks/dep-a5b4350d.js.map +1 -0
  94. package/vendor/vite/dist/node/chunks/dep-ac1b4bf9.js +531 -0
  95. package/vendor/vite/dist/node/chunks/dep-ac1b4bf9.js.map +1 -0
  96. package/vendor/vite/dist/node/chunks/dep-dab866a6.js +11404 -0
  97. package/vendor/vite/dist/node/chunks/dep-dab866a6.js.map +1 -0
  98. package/vendor/vite/dist/node/chunks/dep-e39b05d6.js +746 -0
  99. package/vendor/vite/dist/node/chunks/dep-e39b05d6.js.map +1 -0
  100. package/vendor/vite/dist/node/cli.js +803 -0
  101. package/vendor/vite/dist/node/cli.js.map +1 -0
  102. package/vendor/vite/dist/node/index.d.ts +2580 -0
  103. package/vendor/vite/dist/node/index.js +52 -0
  104. package/vendor/vite/dist/node/index.js.map +1 -0
  105. package/vendor/vite/dist/node/terser.js +31356 -0
  106. package/vendor/vite/package.json +139 -0
  107. package/vendor/vite/types/alias.d.ts +59 -0
  108. package/vendor/vite/types/anymatch.d.ts +5 -0
  109. package/vendor/vite/types/chokidar.d.ts +218 -0
  110. package/vendor/vite/types/commonjs.d.ts +162 -0
  111. package/vendor/vite/types/connect.d.ts +111 -0
  112. package/vendor/vite/types/customEvent.d.ts +5 -0
  113. package/vendor/vite/types/dynamicImportVars.d.ts +17 -0
  114. package/vendor/vite/types/hmrPayload.d.ts +57 -0
  115. package/vendor/vite/types/http-proxy.d.ts +242 -0
  116. package/vendor/vite/types/importMeta.d.ts +69 -0
  117. package/vendor/vite/types/package.json +3 -0
  118. package/vendor/vite/types/shims.d.ts +110 -0
  119. package/vendor/vite/types/terser.d.ts +209 -0
  120. package/vendor/vite/types/ws.d.ts +532 -0
  121. package/dist/@types/config.js +0 -1
  122. package/dist/@types/estree-walker.d.js +0 -1
  123. package/dist/@types/hydrate.js +0 -1
  124. package/dist/@types/micromark-extension-gfm.d.js +0 -1
  125. package/dist/@types/micromark.js +0 -1
  126. package/dist/@types/postcss-icss-keyframes.d.js +0 -1
  127. package/dist/@types/public.js +0 -6
  128. package/dist/@types/resolve.d.js +0 -1
  129. package/dist/@types/tailwind.d.js +0 -1
  130. package/dist/@types/transformer.js +0 -1
  131. package/dist/ast.js +0 -26
  132. package/dist/build/bundle/css.js +0 -108
  133. package/dist/build/bundle/js.js +0 -198
  134. package/dist/build/page.js +0 -61
  135. package/dist/build/sitemap.js +0 -24
  136. package/dist/build/stats.js +0 -72
  137. package/dist/build/util.js +0 -64
  138. package/dist/build.js +0 -283
  139. package/dist/cli.js +0 -136
  140. package/dist/compiler/codegen/index.js +0 -796
  141. package/dist/compiler/codegen/interfaces.js +0 -1
  142. package/dist/compiler/codegen/utils.js +0 -28
  143. package/dist/compiler/index.js +0 -226
  144. package/dist/compiler/transform/doctype.js +0 -34
  145. package/dist/compiler/transform/head.js +0 -264
  146. package/dist/compiler/transform/index.js +0 -74
  147. package/dist/compiler/transform/module-scripts.js +0 -44
  148. package/dist/compiler/transform/postcss-scoped-styles/index.js +0 -106
  149. package/dist/compiler/transform/prism.js +0 -132
  150. package/dist/compiler/transform/styles.js +0 -235
  151. package/dist/compiler/transform/util/end-of-head.js +0 -84
  152. package/dist/compiler/utils.js +0 -66
  153. package/dist/config.js +0 -64
  154. package/dist/config_manager.js +0 -129
  155. package/dist/dev.js +0 -99
  156. package/dist/external.js +0 -20
  157. package/dist/frontend/500.astro +0 -128
  158. package/dist/frontend/__astro_config.js +0 -2
  159. package/dist/internal/__astro_component.js +0 -205
  160. package/dist/internal/__astro_hoisted_scripts.js +0 -19
  161. package/dist/internal/__astro_slot.js +0 -19
  162. package/dist/internal/element-registry.js +0 -55
  163. package/dist/internal/fetch-content.js +0 -35
  164. package/dist/internal/h.js +0 -57
  165. package/dist/internal/renderer-html.js +0 -11
  166. package/dist/logger.js +0 -121
  167. package/dist/manifest/create.js +0 -202
  168. package/dist/node_builtins.js +0 -8
  169. package/dist/preview.js +0 -33
  170. package/dist/reload.js +0 -19
  171. package/dist/runtime.js +0 -337
  172. package/dist/snowpack-logger.js +0 -12
  173. package/dist/types/@types/astro.d.ts +0 -169
  174. package/dist/types/@types/compiler.d.ts +0 -9
  175. package/dist/types/@types/config.d.ts +0 -84
  176. package/dist/types/@types/hydrate.d.ts +0 -4
  177. package/dist/types/@types/micromark.d.ts +0 -12
  178. package/dist/types/@types/public.d.ts +0 -1
  179. package/dist/types/@types/transformer.d.ts +0 -23
  180. package/dist/types/ast.d.ts +0 -7
  181. package/dist/types/build/bundle/css.d.ts +0 -22
  182. package/dist/types/build/bundle/js.d.ts +0 -21
  183. package/dist/types/build/page.d.ts +0 -25
  184. package/dist/types/build/sitemap.d.ts +0 -3
  185. package/dist/types/build/stats.d.ts +0 -23
  186. package/dist/types/build/util.d.ts +0 -21
  187. package/dist/types/build.d.ts +0 -10
  188. package/dist/types/compiler/codegen/index.d.ts +0 -18
  189. package/dist/types/compiler/codegen/interfaces.d.ts +0 -9
  190. package/dist/types/compiler/codegen/utils.d.ts +0 -9
  191. package/dist/types/compiler/index.d.ts +0 -32
  192. package/dist/types/compiler/transform/doctype.d.ts +0 -6
  193. package/dist/types/compiler/transform/head.d.ts +0 -3
  194. package/dist/types/compiler/transform/index.d.ts +0 -9
  195. package/dist/types/compiler/transform/module-scripts.d.ts +0 -8
  196. package/dist/types/compiler/transform/postcss-scoped-styles/index.d.ts +0 -16
  197. package/dist/types/compiler/transform/prism.d.ts +0 -5
  198. package/dist/types/compiler/transform/styles.d.ts +0 -24
  199. package/dist/types/compiler/transform/util/end-of-head.d.ts +0 -19
  200. package/dist/types/compiler/utils.d.ts +0 -22
  201. package/dist/types/config_manager.d.ts +0 -43
  202. package/dist/types/dev.d.ts +0 -3
  203. package/dist/types/external.d.ts +0 -2
  204. package/dist/types/internal/__astro_component.d.ts +0 -11
  205. package/dist/types/internal/__astro_hoisted_scripts.d.ts +0 -12
  206. package/dist/types/internal/__astro_slot.d.ts +0 -10
  207. package/dist/types/internal/element-registry.d.ts +0 -14
  208. package/dist/types/internal/fetch-content.d.ts +0 -6
  209. package/dist/types/internal/h.d.ts +0 -8
  210. package/dist/types/internal/renderer-html.d.ts +0 -4
  211. package/dist/types/manifest/create.d.ts +0 -5
  212. package/dist/types/node_builtins.d.ts +0 -2
  213. package/dist/types/preview.d.ts +0 -5
  214. package/dist/types/reload.d.ts +0 -1
  215. package/dist/types/runtime.d.ts +0 -64
  216. package/dist/types/snowpack-logger.d.ts +0 -2
  217. package/dist/types/util.d.ts +0 -15
  218. package/dist/util.js +0 -49
  219. package/snowpack-plugin-jsx.cjs +0 -190
  220. package/snowpack-plugin.cjs +0 -69
package/CHANGELOG.md CHANGED
@@ -1,5 +1,56 @@
1
1
  # astro
2
2
 
3
+ ## 0.21.0-next.0
4
+
5
+ ### Minor Changes
6
+
7
+ - d84bfe71: Astro 0.21 Beta release! This introduces the new version of Astro that includes:
8
+
9
+ - A new, faster, Go-based compiler
10
+ - A runtime backed by Vite, with faster dev experience
11
+ - New features
12
+
13
+ See more at https://astro.build/blog/astro-021-preview/
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [d84bfe71]
18
+ - Updated dependencies [d84bfe71]
19
+ - Updated dependencies [d84bfe71]
20
+ - @astrojs/prism@0.3.0-next.0
21
+ - @astrojs/markdown-remark@0.4.0-next.0
22
+ - @astrojs/renderer-preact@0.3.0-next.0
23
+ - @astrojs/renderer-react@0.3.0-next.0
24
+ - @astrojs/renderer-svelte@0.2.0-next.0
25
+ - @astrojs/renderer-vue@0.2.0-next.0
26
+
27
+ ## 0.20.12
28
+
29
+ ### Patch Changes
30
+
31
+ - Updated dependencies [31d06880]
32
+ - @astrojs/renderer-vue@0.1.9
33
+
34
+ ## 0.20.11
35
+
36
+ ### Patch Changes
37
+
38
+ - 6813106a: Improve getStaticPaths memoization to successfully store values in the cache
39
+
40
+ ## 0.20.10
41
+
42
+ ### Patch Changes
43
+
44
+ - dbd2f507: Adds the `astro check` command
45
+
46
+ This adds a new command, `astro check` which runs diagnostics on a project. The same diagnostics run within the Astro VSCode plugin! Just run:
47
+
48
+ ```shell
49
+ astro check
50
+ ```
51
+
52
+ Which works a lot like `tsc` and will give you error messages, if any were found. We recommend adding this to your CI setup to prevent errors from being merged.
53
+
3
54
  ## 0.20.9
4
55
 
5
56
  ### Patch Changes
package/README.md CHANGED
@@ -31,7 +31,8 @@ You can sponsor Astro's development on [Open Collective][oc]. Astro is generousl
31
31
  <table>
32
32
  <tbody>
33
33
  <tr>
34
- <td align="center"><a href="https://www.netlify.com/" target="_blank"><img width="147" height="40" src="./.github/assets/netlify.svg" alt="Netlify" /></a></td>
34
+ <td align="center"><a href="https://www.netlify.com/" target="_blank"><img width="147" height="40" src="https://raw.githubusercontent.com/snowpackjs/astro/main/.github/assets/netlify.svg" alt="Netlify" /></a></td>
35
+ <td align="center"><a href="https://www.vercel.com/" target="_blank"><img width="150" height="34" src="https://raw.githubusercontent.com/snowpackjs/astro/main/.github/assets/vercel.svg" alt="Vercel" /></a></td>
35
36
  </tr>
36
37
  </tbody>
37
38
  </table>
@@ -41,7 +42,7 @@ You can sponsor Astro's development on [Open Collective][oc]. Astro is generousl
41
42
  <table>
42
43
  <tbody>
43
44
  <tr>
44
- <td align="center"><a href="https://sentry.io" target="_blank"><img width="147" height="40" src="./.github/assets/sentry.svg" alt="Sentry" /></a></td>
45
+ <td align="center"><a href="https://sentry.io" target="_blank"><img width="147" height="40" src="https://raw.githubusercontent.com/snowpackjs/astro/main/.github/assets/sentry.svg" alt="Sentry" /></a></td>
45
46
  </tr>
46
47
  </tbody>
47
48
  </table>
package/astro.js CHANGED
@@ -7,12 +7,13 @@
7
7
  // Assume ESM to start, and then call `require()` below once CJS is confirmed.
8
8
  // Needed for Stackblitz: https://github.com/stackblitz/webcontainer-core/issues/281
9
9
 
10
- const CI_INTRUCTIONS = {
10
+ const CI_INSTRUCTIONS = {
11
11
  NETLIFY: 'https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript',
12
12
  GITHUB_ACTIONS: 'https://docs.github.com/en/actions/guides/building-and-testing-nodejs#specifying-the-nodejs-version',
13
13
  VERCEL: 'https://vercel.com/docs/runtimes#official-runtimes/node-js/node-js-version',
14
14
  };
15
15
 
16
+ /** `astro *` */
16
17
  async function main() {
17
18
  // Check for ESM support.
18
19
  // Load the "supports-esm" package in an way that works in both ESM & CJS.
@@ -29,7 +30,7 @@ async function main() {
29
30
 
30
31
  // Preflight check complete. Enjoy! ✨
31
32
  if (supportsESM) {
32
- return import('./dist/cli.js')
33
+ return import('./dist/cli/index.js')
33
34
  .then(({ cli }) => cli(process.argv))
34
35
  .catch((error) => {
35
36
  console.error(error);
@@ -80,8 +81,8 @@ Please upgrade Node.js to a supported version: "${engines}"\n`);
80
81
  }
81
82
  console.log(`${ci.name} CI Environment Detected!\nAdditional steps may be needed to set your Node.js version:`);
82
83
  console.log(`Documentation: https://docs.astro.build/guides/deploy`);
83
- if (CI_INTRUCTIONS[platform]) {
84
- console.log(`${ci.name} Documentation: ${CI_INTRUCTIONS[platform]}`);
84
+ if (CI_INSTRUCTIONS[platform]) {
85
+ console.log(`${ci.name} Documentation: ${CI_INSTRUCTIONS[platform]}`);
85
86
  }
86
87
  console.log(``);
87
88
  }
@@ -4,14 +4,14 @@ import shiki from 'shiki';
4
4
  export interface Props {
5
5
  /** The code to highlight. Required. */
6
6
  code: string;
7
- /**
8
- * The language of your code. Defaults to "plaintext".
9
- * Supports all languages listed here: https://github.com/shikijs/shiki/blob/main/docs/themes.md
7
+ /**
8
+ * The language of your code. Defaults to "plaintext".
9
+ * Supports all languages listed here: https://github.com/shikijs/shiki/blob/main/docs/themes.md
10
10
  */
11
11
  lang?: string;
12
- /**
12
+ /**
13
13
  * The styling theme. Defaults to "github-dark".
14
- * Supports all themes listed here: https://github.com/shikijs/shiki/blob/main/docs/themes.md
14
+ * Supports all themes listed here: https://github.com/shikijs/shiki/blob/main/docs/themes.md
15
15
  * Instructions for loading a custom theme: https://github.com/shikijs/shiki/blob/main/docs/themes.md#loading-theme
16
16
  */
17
17
  theme?: string;
@@ -45,6 +45,6 @@ function repairShikiTheme(html: string): string {
45
45
 
46
46
  const highlighter = await shiki.getHighlighter({theme});
47
47
  const _html = highlighter.codeToHtml(code, lang);
48
- html = repairShikiTheme(_html);
48
+ const html = repairShikiTheme(_html);
49
49
  ---
50
50
  {html}
@@ -1,144 +1,6 @@
1
1
  ---
2
2
  const key = Object.keys(Astro.props)[0];
3
3
  const value = Astro.props[key];
4
-
5
- const getType = (node: unknown) => {
6
- if (Array.isArray(node)) return 'array';
7
- if (node === null) return 'null';
8
- if (typeof node === 'object') {
9
- if ((node as any).then) return 'promise';
10
- }
11
- return typeof node;
12
- };
13
-
14
- const getSummary = (node: any, key: string, className: string) => {
15
- const type = getType(node);
16
- let value;
17
- let open;
18
- let close;
19
-
20
- if (type === 'function') {
21
- return <>
22
- {(key || !key && key === 0) && <><span class={`${className} key`}>{key}</span><span class={`${className} sep`}>:</span></>}
23
- <span class={`${className} value value-function`}>{node.name}<span class={`${className} punc`}>()</span></span>
24
- </>
25
- }
26
-
27
- if (type === 'promise') {
28
- return <>
29
- {(key || !key && key === 0) && <><span class={`${className} key`}>{key}</span><span class={`${className} sep`}>:</span></>}
30
- <span class={`${className} value value-promise`}>Promise</span>
31
- </>
32
- }
33
-
34
- if (type === 'array') {
35
- value = node.length;
36
- open = <><span class={`${className} none`}>Array</span>{'['}</>;
37
- close = ']';
38
- } else if (type === 'object') {
39
- const keys = Object.keys(node);
40
- if (keys.length === 0) {
41
- value = 'Empty';
42
- } else if (keys.length > 3) {
43
- value = '…';
44
- } else {
45
- value = keys.slice(0, 3).join(',');
46
- }
47
- open = '{';
48
- close = '}';
49
- };
50
-
51
- return <>
52
- {key && <><span class={`${className} key`}>{key}</span>: </>}
53
- {open && <span class={`${className} punc`}>{open}</span>}
54
- <span class={`${className} hide`}>
55
- <span class={`${className} len`}>{value}</span>
56
- {close && <span class={`${className} punc`}>{close}</span>}
57
- </span>
58
- </>;
59
- };
60
-
61
- const Details = ({ node, key, children, class: className }) => {
62
- const type = getType(node);
63
- const props = {};
64
-
65
- if (type === 'array' || type === 'object') {
66
- props['data-char'] = type === 'array' ? ']' : '}'
67
- props.open = !key && type === 'object' ? '' : undefined;
68
- }
69
-
70
- return (
71
- <details {...props} class={className}>
72
- <Summary node={node} key={key} class={className} />
73
- {children}
74
- </details>
75
- );
76
- }
77
-
78
- const Summary = ({ node, key, class: className }) => {
79
- return (
80
- <summary class={className}>{getSummary(node, key, className)}</summary>
81
- );
82
- }
83
-
84
- const Empty = Symbol('Empty');
85
-
86
- const KeyValue = ({ key, value, dim, class: className }) => {
87
- let type = key === '__proto__' ? 'prototype' : getType(value);
88
- if (type === 'null') {
89
- value = 'null';
90
- } else if (type === 'undefined') {
91
- value = 'undefined';
92
- } else if (value === Empty) {
93
- type = 'empty';
94
- value = 'Empty';
95
- } else {
96
- value = JSON.stringify(value);
97
- }
98
-
99
- return (
100
- <div class={`${className} line`}>
101
- {(key || !key && key === 0) && <><span class={`${className} key ${dim ? 'key-dim' : ''}`.trim()}>{key}</span><span class={`${className} sep`}>:</span></>}
102
- <span class={`${className} value value-${type}`}>
103
- {value}
104
- </span>
105
- </div>
106
- )
107
- }
108
-
109
- const Node = ({ node, key, class: className, ...props }) => {
110
- const type = getType(node);
111
- className = className.replace(/debug-value/g, '');
112
-
113
- if (type === 'array' || type === 'object') {
114
- let children = [];
115
- if (type === 'array' && node.length > 0 && Object.entries(node).length === 0) {
116
- children = Array.from({ length: node.length }, (_, key) => <Node node={Empty} key={key} class={className} />);
117
- } else {
118
- children = Object.entries(node).map(([key, value]) => <Node node={value} key={key} class={className} />);
119
- }
120
- return (
121
- <Details node={node} key={key} children={children} class={className} />
122
- );
123
- } else if (type === 'function') {
124
- return (
125
- <Details node={node} key={key} class={className} children={
126
- <>
127
- <KeyValue key="name" value={node.name} dim={true} class={className} />
128
- <KeyValue key="__proto__" value="Function" dim={true} class={className} />
129
- </>
130
- }/>
131
- );
132
- } else if (type === 'promise') {
133
- return (
134
- <Details node={node} key={key} class={className} children={
135
- <KeyValue key="__proto__" value="Promise" dim={true} />
136
- } />
137
- );
138
- }
139
-
140
- return <KeyValue key={key} value={node} class={className} />;
141
- }
142
4
  ---
143
5
 
144
6
  <div class="debug">
@@ -146,21 +8,32 @@ const Node = ({ node, key, class: className, ...props }) => {
146
8
  <h2 class="debug-title"><span class="debug-label">Debug</span> <span class="debug-name">"{key}"</span></h2>
147
9
  </div>
148
10
 
149
- <main>
150
- <Node node={value} class="debug-value" />
151
- </main>
11
+ <pre>{JSON.stringify(value, null, 2)}</pre>
152
12
  </div>
153
13
 
154
- <style lang="scss">
155
- .debug-header {
156
- background: #FF1639;
14
+ <style>
15
+ .debug {
16
+ font-size: 14px;
17
+ padding: 1rem 1.5rem;
18
+ background: white;
19
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
20
+ }
21
+
22
+ .debug-header, pre {
157
23
  margin: -1rem -1.5rem 1rem;
158
24
  padding: 0.25rem 0.75rem;
159
25
  }
160
26
 
27
+ .debug-header {
28
+ background: #FF1639;
29
+ border-radius: 4px;
30
+ border-bottom-left-radius: 0;
31
+ border-bottom-right-radius: 0;
32
+ }
33
+
161
34
  .debug-title {
162
35
  font-size: 1em;
163
- color: #fff;
36
+ color: white;
164
37
  margin: 0.5em 0;
165
38
  }
166
39
 
@@ -170,137 +43,12 @@ const Node = ({ node, key, class: className, ...props }) => {
170
43
  margin-right: 0.75em;
171
44
  }
172
45
 
173
- .debug {
174
- all: initial;
175
- display: flex;
176
- flex-direction: column;
177
- padding: 1rem 1.5rem;
178
- overflow-y: hidden;
179
- overflow-x: auto;
180
- border: 1px solid #FFCFD6;
181
-
182
- background: #FFF;
183
- font-family: Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace;
184
- font-size: 0.8rem;
185
- line-height: 1.44;
186
- color: #6b7280;
187
- white-space: pre;
188
-
189
- }
190
-
191
- details[open] > summary span.hide {
192
- visibility: hidden;
193
- }
194
-
195
- details[open] > summary span.none {
196
- display: none;
197
- }
198
-
199
- details > details {
200
- padding-left: 1em;
201
- }
202
-
203
- .line {
204
- padding-left: 1.125em;
205
- }
206
-
207
- details[open]::after {
208
- content: attr(data-char);
209
- }
210
-
211
- .sep {
212
- margin-right: 0.25em;
213
- }
214
-
215
-
216
- details > summary {
217
- cursor: pointer;
218
- }
219
-
220
- details:hover > summary::before,
221
- details:focus > summary::before {
222
- transform: translate(0.25em, -0.25em);
223
- }
224
-
225
- details > summary::before {
226
- content: '';
227
- background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M13 8L2.60769 14L2.6077 2L13 8Z' fill='%236B7280' /%3E%3C/svg%3E%0A");
228
- background-size: 1em;
229
-
230
- display: inline-flex;
231
- font-size: 0.5em;
232
- width: 1em;
233
- height: 1em;
234
- margin-right: 1.25em;
235
- margin-left: -2em;
236
- transform: translate(0, -0.25em);
237
- line-height: 1em;
238
- transition: transform 120ms ease-in;
239
- }
240
-
241
- details[open] > summary::before {
242
- transform: translate(0.25em, -0.25em) rotate(90deg);
243
- }
244
-
245
- .debug :global(::marker) {
246
- content: '';
247
- width: 0;
248
- visibility: hidden;
249
- }
250
-
251
- .key {
252
- color: #882de7;
253
- }
254
-
255
- .key-dim {
256
- color: #B881F1;
257
- }
258
-
259
- .len {
260
- color: #B881F1;
261
- }
262
-
263
- details:hover > summary,
264
- details:focus > summary,
265
- details:hover > summary .punc,
266
- details:focus > summary .punc,
267
- details:hover[open]::after,
268
- details:focus[open]::after {
269
- color: #000012;
270
- }
271
-
272
- details:hover > summary .len,
273
- details:focus > summary .len {
274
- color: #882DE7;
275
- }
276
-
277
- .punc {
278
- color: #6b7280;
279
- }
280
-
281
- .value-string {
282
- color: #17c083;
283
- }
284
-
285
- .value-function::before {
286
- content: 'ƒ ';
287
- color: #3894ff;
288
- }
289
- .value-function {
290
- color: #5076f9;
291
- }
292
-
293
- .value-number {
294
- color: #ff5d01;
295
- }
296
-
297
- .value-null,
298
- .value-undefined {
299
- color: #9ca3af;
300
- }
301
-
302
- main > .line {
303
- margin-left: -0.75em;
304
- padding-left: 0;
46
+ pre {
47
+ border: 1px solid #eee;
48
+ padding: 1rem 0.75rem;
49
+ border-radius: 4px;
50
+ border-top-left-radius: 0;
51
+ border-top-right-radius: 0;
52
+ font-size: 14px;
305
53
  }
306
54
  </style>
@@ -1,32 +1,39 @@
1
1
  ---
2
- import { renderMarkdown } from '@astrojs/markdown-support';
3
-
4
2
  export interface Props {
5
3
  content?: string;
6
4
  }
7
5
 
6
+ const dedent = (str: string) => str.split('\n').map(ln => ln.trimStart()).join('\n');
7
+
8
8
  // Internal props that should not be part of the external interface.
9
9
  interface InternalProps extends Props {
10
10
  $scope: string;
11
11
  }
12
12
 
13
- const { content, $scope } = Astro.props as InternalProps;
13
+ let { content, class: className } = Astro.props as InternalProps;
14
14
  let html = null;
15
+ let htmlContent = '';
16
+
17
+ const { privateRenderMarkdownDoNotUse: renderMarkdown } = (Astro as any);
18
+
19
+ // If no content prop provided, use the slot.
20
+ if (!content) {
21
+ const { privateRenderSlotDoNotUse: renderSlot } = (Astro as any);
22
+ content = await renderSlot('default');
23
+ if (content.trim().length > 0) {
24
+ content = dedent(content);
25
+ }
26
+ }
15
27
 
16
- // This flow is only triggered if a user passes `<Markdown content={content} />`
17
28
  if (content) {
18
- const { content: htmlContent } = await renderMarkdown(content, {
29
+ htmlContent = await renderMarkdown(content, {
19
30
  mode: 'md',
20
31
  $: {
21
- scopedClassName: $scope
32
+ scopedClassName: className
22
33
  }
23
34
  });
24
- html = htmlContent;
25
35
  }
26
36
 
27
- /*
28
- If we have rendered `html` for `content`, render that
29
- Otherwise, just render the slotted content
30
- */
37
+ html = htmlContent;
31
38
  ---
32
39
  {html ? html : <slot />}
File without changes
File without changes
@@ -0,0 +1,94 @@
1
+ import {AstroCheck, DiagnosticSeverity} from "@astrojs/language-server";
2
+ import {bold, black, bgWhite, red, cyan, yellow} from "kleur/colors";
3
+ import glob from "fast-glob";
4
+ import * as path from "path";
5
+ import {pathToFileURL} from "url";
6
+ import * as fs from "fs";
7
+ async function openAllDocuments(workspaceUri, filePathsToIgnore, checker) {
8
+ const files = await glob("**/*.astro", {
9
+ cwd: workspaceUri.pathname,
10
+ ignore: ["node_modules/**"].concat(filePathsToIgnore.map((ignore) => `${ignore}/**`))
11
+ });
12
+ const absFilePaths = files.map((f) => path.resolve(workspaceUri.pathname, f));
13
+ for (const absFilePath of absFilePaths) {
14
+ const text = fs.readFileSync(absFilePath, "utf-8");
15
+ checker.upsertDocument({
16
+ uri: pathToFileURL(absFilePath).toString(),
17
+ text
18
+ });
19
+ }
20
+ }
21
+ function offsetAt({line, character}, text) {
22
+ let i = 0;
23
+ let l = 0;
24
+ let c = 0;
25
+ while (i < text.length) {
26
+ if (l === line && c === character) {
27
+ break;
28
+ }
29
+ let char = text[i];
30
+ switch (char) {
31
+ case "\n": {
32
+ l++;
33
+ c = 0;
34
+ break;
35
+ }
36
+ default: {
37
+ c++;
38
+ break;
39
+ }
40
+ }
41
+ i++;
42
+ }
43
+ return i;
44
+ }
45
+ function pad(str, len) {
46
+ return Array.from({length: len}, () => str).join("");
47
+ }
48
+ async function run() {
49
+ }
50
+ async function check(astroConfig) {
51
+ const root = astroConfig.projectRoot;
52
+ let checker = new AstroCheck(root.toString());
53
+ await openAllDocuments(root, [], checker);
54
+ let diagnostics = await checker.getDiagnostics();
55
+ let result = {
56
+ errors: 0,
57
+ warnings: 0
58
+ };
59
+ diagnostics.forEach((diag) => {
60
+ diag.diagnostics.forEach((d) => {
61
+ switch (d.severity) {
62
+ case DiagnosticSeverity.Error: {
63
+ console.error(`${bold(cyan(path.relative(root.pathname, diag.filePath)))}:${bold(yellow(d.range.start.line))}:${bold(yellow(d.range.start.character))} - ${d.message}`);
64
+ let startOffset = offsetAt({line: d.range.start.line, character: 0}, diag.text);
65
+ let endOffset = offsetAt({line: d.range.start.line + 1, character: 0}, diag.text);
66
+ let str = diag.text.substring(startOffset, endOffset - 1);
67
+ const lineNumStr = d.range.start.line.toString();
68
+ const lineNumLen = lineNumStr.length;
69
+ console.error(`${bgWhite(black(lineNumStr))} ${str}`);
70
+ let tildes = pad("~", d.range.end.character - d.range.start.character);
71
+ let spaces = pad(" ", d.range.start.character + lineNumLen - 1);
72
+ console.error(` ${spaces}${bold(red(tildes))}
73
+ `);
74
+ result.errors++;
75
+ break;
76
+ }
77
+ case DiagnosticSeverity.Warning: {
78
+ result.warnings++;
79
+ break;
80
+ }
81
+ }
82
+ });
83
+ });
84
+ if (result.errors) {
85
+ console.error(`Found ${result.errors} errors.`);
86
+ }
87
+ const exitCode = result.errors ? 1 : 0;
88
+ return exitCode;
89
+ }
90
+ export {
91
+ check,
92
+ run
93
+ };
94
+ //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vc3JjL2NsaS9jaGVjay50cyJdLAogICJtYXBwaW5ncyI6ICJBQUNBO0FBR0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUVBLGdDQUFnQyxjQUFtQixtQkFBNkIsU0FBcUI7QUFDbkcsUUFBTSxRQUFRLE1BQU0sS0FBSyxjQUFjO0FBQUEsSUFDckMsS0FBSyxhQUFhO0FBQUEsSUFDbEIsUUFBUSxDQUFDLG1CQUFtQixPQUFPLGtCQUFrQixJQUFJLENBQUMsV0FBVyxHQUFHO0FBQUE7QUFFMUUsUUFBTSxlQUFlLE1BQU0sSUFBSSxDQUFDLE1BQU0sS0FBSyxRQUFRLGFBQWEsVUFBVTtBQUUxRSxhQUFXLGVBQWUsY0FBYztBQUN0QyxVQUFNLE9BQU8sR0FBRyxhQUFhLGFBQWE7QUFDMUMsWUFBUSxlQUFlO0FBQUEsTUFDckIsS0FBSyxjQUFjLGFBQWE7QUFBQSxNQUNoQztBQUFBO0FBQUE7QUFBQTtBQVVOLGtCQUFrQixDQUFFLE1BQU0sWUFBa0QsTUFBYztBQUN4RixNQUFJLElBQUk7QUFDUixNQUFJLElBQUk7QUFDUixNQUFJLElBQUk7QUFDUixTQUFPLElBQUksS0FBSyxRQUFRO0FBQ3RCLFFBQUksTUFBTSxRQUFRLE1BQU0sV0FBVztBQUNqQztBQUFBO0FBR0YsUUFBSSxPQUFPLEtBQUs7QUFDaEIsWUFBUTtBQUFBLFdBQ0QsTUFBTTtBQUNUO0FBQ0EsWUFBSTtBQUNKO0FBQUE7QUFBQSxlQUVPO0FBQ1A7QUFDQTtBQUFBO0FBQUE7QUFJSjtBQUFBO0FBR0YsU0FBTztBQUFBO0FBR1QsYUFBYSxLQUFhLEtBQWE7QUFDckMsU0FBTyxNQUFNLEtBQUssQ0FBRSxRQUFRLE1BQU8sTUFBTSxLQUFLLEtBQUs7QUFBQTtBQUdyRCxxQkFBNEI7QUFBQTtBQUU1QixxQkFBNEIsYUFBMEI7QUFDcEQsUUFBTSxPQUFPLFlBQVk7QUFDekIsTUFBSSxVQUFVLElBQUksV0FBVyxLQUFLO0FBQ2xDLFFBQU0saUJBQWlCLE1BQU0sSUFBSTtBQUVqQyxNQUFJLGNBQWMsTUFBTSxRQUFRO0FBRWhDLE1BQUksU0FBaUI7QUFBQSxJQUNuQixRQUFRO0FBQUEsSUFDUixVQUFVO0FBQUE7QUFHWixjQUFZLFFBQVEsQ0FBQyxTQUFTO0FBQzVCLFNBQUssWUFBWSxRQUFRLENBQUMsTUFBTTtBQUM5QixjQUFRLEVBQUU7QUFBQSxhQUNILG1CQUFtQixPQUFPO0FBQzdCLGtCQUFRLE1BQU0sR0FBRyxLQUFLLEtBQUssS0FBSyxTQUFTLEtBQUssVUFBVSxLQUFLLGVBQWUsS0FBSyxPQUFPLEVBQUUsTUFBTSxNQUFNLFVBQVUsS0FBSyxPQUFPLEVBQUUsTUFBTSxNQUFNLGlCQUFpQixFQUFFO0FBQzdKLGNBQUksY0FBYyxTQUFTLENBQUUsTUFBTSxFQUFFLE1BQU0sTUFBTSxNQUFNLFdBQVcsSUFBSyxLQUFLO0FBQzVFLGNBQUksWUFBWSxTQUFTLENBQUUsTUFBTSxFQUFFLE1BQU0sTUFBTSxPQUFPLEdBQUcsV0FBVyxJQUFLLEtBQUs7QUFDOUUsY0FBSSxNQUFNLEtBQUssS0FBSyxVQUFVLGFBQWEsWUFBWTtBQUN2RCxnQkFBTSxhQUFhLEVBQUUsTUFBTSxNQUFNLEtBQUs7QUFDdEMsZ0JBQU0sYUFBYSxXQUFXO0FBQzlCLGtCQUFRLE1BQU0sR0FBRyxRQUFRLE1BQU0saUJBQWlCO0FBQ2hELGNBQUksU0FBUyxJQUFJLEtBQUssRUFBRSxNQUFNLElBQUksWUFBWSxFQUFFLE1BQU0sTUFBTTtBQUM1RCxjQUFJLFNBQVMsSUFBSSxLQUFLLEVBQUUsTUFBTSxNQUFNLFlBQVksYUFBYTtBQUM3RCxrQkFBUSxNQUFNLE1BQU0sU0FBUyxLQUFLLElBQUk7QUFBQTtBQUN0QyxpQkFBTztBQUNQO0FBQUE7QUFBQSxhQUVHLG1CQUFtQixTQUFTO0FBQy9CLGlCQUFPO0FBQ1A7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQU1SLE1BQUksT0FBTyxRQUFRO0FBQ2pCLFlBQVEsTUFBTSxTQUFTLE9BQU87QUFBQTtBQUdoQyxRQUFNLFdBQVcsT0FBTyxTQUFTLElBQUk7QUFDckMsU0FBTztBQUFBOyIsCiAgIm5hbWVzIjogW10KfQo=