Skip to content

Commit

Permalink
Merge branch 'main' into feat/hybrid-unflag
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re authored Jun 2, 2023
2 parents d9e4e6f + c64dfdd commit 45c706c
Show file tree
Hide file tree
Showing 35 changed files with 234 additions and 71 deletions.
5 changes: 0 additions & 5 deletions .changeset/many-cats-fry.md

This file was deleted.

7 changes: 0 additions & 7 deletions .changeset/smart-moles-double.md

This file was deleted.

23 changes: 11 additions & 12 deletions .github/workflows/check-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check if there is already a block on this PR
id: set-blocks
id: blocked
uses: actions/github-script@v6
env:
issue_number: ${{ github.event.number }}
Expand All @@ -23,31 +23,31 @@ jobs:
repo: context.repo.repo,
pull_number: process.env.issue_number,
});
console.log(reviews);
for (const review of reviews) {
if (review.user.id === 41898282 && review.state === 'CHANGES_REQUESTED') {
return 'block';
if (review.user.login === 'github-actions[bot]' && review.state === 'CHANGES_REQUESTED') {
return 'true'
}
}
return '';
return 'false'
result-encoding: string

- uses: actions/checkout@v3
if: steps.set-blocks.outputs.blocks == ''
if: steps.blocked.outputs.result != 'true'
with:
fetch-depth: 0

- name: Get changed files in the .changeset folder
id: changed-files
uses: tj-actions/changed-files@v35
if: steps.set-blocks.outputs.blocks == ''
if: steps.blocked.outputs.result != 'true'
with:
files: |
.changeset/**/*.md
- name: Check if any changesets contain minor changes
id: find-blockers
if: steps.set-blocks.outputs.blocks == ''
id: minor
if: steps.blocked.outputs.result != 'true'
run: |
echo "Checking for changesets marked as minor"
echo '::set-output name=found::false'
Expand All @@ -60,7 +60,7 @@ jobs:
- name: Add label
uses: actions/github-script@v6
if: steps.find-blockers.outputs.found == 'true'
if: steps.minor.outputs.found == 'true'
env:
issue_number: ${{ github.event.number }}
with:
Expand All @@ -74,7 +74,7 @@ jobs:
- name: Change PR Status
uses: actions/github-script@v6
if: steps.find-blockers.outputs.found == 'true'
if: steps.minor.outputs.found == 'true'
env:
issue_number: ${{ github.event.number }}
with:
Expand All @@ -86,4 +86,3 @@ jobs:
event: 'REQUEST_CHANGES',
body: 'This PR is blocked because it contains a `minor` changeset. A reviewer will merge this at the next release if approved.'
});
16 changes: 16 additions & 0 deletions packages/astro/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# astro

## 2.5.7

### Patch Changes

- [#7215](https://github.com/withastro/astro/pull/7215) [`6e27f2f6d`](https://github.com/withastro/astro/commit/6e27f2f6dbd52f980c487e875faf1b066f65cffd) Thanks [@bmenant](https://github.com/bmenant)! - Node adapter fallbacks to `:authority` http2 pseudo-header when `host` is nullish.

- [#7233](https://github.com/withastro/astro/pull/7233) [`96ae37eb0`](https://github.com/withastro/astro/commit/96ae37eb09f7406f40fba93e14b2a26ccd46640c) Thanks [@bluwy](https://github.com/bluwy)! - Fix `getViteConfig` and Vitest setup with content collections

- [#7136](https://github.com/withastro/astro/pull/7136) [`fea306936`](https://github.com/withastro/astro/commit/fea30693609cc517d8660972151f4d12a0dd4e82) Thanks [@johannesspohr](https://github.com/johannesspohr)! - Render arrays of components in parallel

- [#7257](https://github.com/withastro/astro/pull/7257) [`5156c4f90`](https://github.com/withastro/astro/commit/5156c4f90e0922f62d25fa0c82bbefae39f4c2b6) Thanks [@thiti-y](https://github.com/thiti-y)! - fix: build fail upon have 'process.env' in \*.md file.

- [#7268](https://github.com/withastro/astro/pull/7268) [`9e7366567`](https://github.com/withastro/astro/commit/9e7366567e2b83d46a46db35e74ad508d1978039) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Fix: ignore `.json` files within content collection directories starting with an `_` underscore.

- [#7185](https://github.com/withastro/astro/pull/7185) [`339529fc8`](https://github.com/withastro/astro/commit/339529fc820bac2d514b63198ecf54a1d88c0917) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Bring back improved style and script handling across content collection files. This addresses bugs found in a previous release to `@astrojs/markdoc`.

## 2.5.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "astro",
"version": "2.5.6",
"version": "2.5.7",
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
"type": "module",
"author": "withastro",
Expand Down
8 changes: 8 additions & 0 deletions packages/astro/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,21 @@ export function getViteConfig(inlineConfig: UserConfig) {

// Use dynamic import to avoid pulling in deps unless used
const [
fs,
{ mergeConfig },
{ nodeLogDestination },
{ openConfig, createSettings },
{ createVite },
{ runHookConfigSetup, runHookConfigDone },
{ astroContentListenPlugin },
] = await Promise.all([
import('fs'),
import('vite'),
import('../core/logger/node.js'),
import('../core/config/index.js'),
import('../core/create-vite.js'),
import('../integrations/index.js'),
import('./vite-plugin-content-listen.js'),
]);
const logging: LogOptions = {
dest: nodeLogDestination,
Expand All @@ -39,6 +43,10 @@ export function getViteConfig(inlineConfig: UserConfig) {
const viteConfig = await createVite(
{
mode,
plugins: [
// Initialize the content listener
astroContentListenPlugin({ settings, logging, fs }),
],
},
{ settings, logging: logging, mode }
);
Expand Down
41 changes: 41 additions & 0 deletions packages/astro/src/config/vite-plugin-content-listen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import type fsMod from 'node:fs';
import type { Plugin, ViteDevServer } from 'vite';
import type { AstroSettings } from '../@types/astro';
import { attachContentServerListeners } from '../content/server-listeners.js';
import type { LogOptions } from '../core/logger/core.js';

/**
* Listen for Astro content directory changes and generate types.
*
* This is a separate plugin for `getViteConfig` as the `attachContentServerListeners` API
* needs to be called at different times in `astro dev` and `getViteConfig`. For `astro dev`,
* it needs to be called after the Astro server is started (packages/astro/src/core/dev/dev.ts).
* For `getViteConfig`, it needs to be called after the Vite server is started.
*/
export function astroContentListenPlugin({
settings,
logging,
fs,
}: {
settings: AstroSettings;
logging: LogOptions;
fs: typeof fsMod;
}): Plugin {
let server: ViteDevServer;

return {
name: 'astro:content-listen',
apply: 'serve',
configureServer(_server) {
server = _server;
},
async buildStart() {
await attachContentServerListeners({
fs: fs,
settings,
logging,
viteServer: server,
});
},
};
}
24 changes: 18 additions & 6 deletions packages/astro/src/content/vite-plugin-content-virtual-mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,21 @@ export function astroContentVirtualModPlugin({
)
.replace('@@CONTENT_DIR@@', relContentDir)
.replace(
'@@CONTENT_ENTRY_GLOB_PATH@@',
// [!_] = ignore files starting with "_"
`${relContentDir}**/[!_]*${getExtGlob(contentEntryExts)}`
"'@@CONTENT_ENTRY_GLOB_PATH@@'",
JSON.stringify(globWithUnderscoresIgnored(relContentDir, contentEntryExts))
)
.replace('@@DATA_ENTRY_GLOB_PATH@@', `${relContentDir}**/[!_]*${getExtGlob(dataEntryExts)}`)
.replace(
'@@RENDER_ENTRY_GLOB_PATH@@',
`${relContentDir}**/*${getExtGlob(/** Note: data collections excluded */ contentEntryExts)}`
"'@@DATA_ENTRY_GLOB_PATH@@'",
JSON.stringify(globWithUnderscoresIgnored(relContentDir, dataEntryExts))
)
.replace(
"'@@RENDER_ENTRY_GLOB_PATH@@'",
JSON.stringify(
globWithUnderscoresIgnored(
relContentDir,
/** Note: data collections excluded */ contentEntryExts
)
)
);

const astroContentVirtualModuleId = '\0' + VIRTUAL_MODULE_ID;
Expand Down Expand Up @@ -189,3 +196,8 @@ const UnexpectedLookupMapError = new AstroError({
...AstroErrorData.UnknownContentCollectionError,
message: `Unexpected error while parsing content entry IDs and slugs.`,
});

function globWithUnderscoresIgnored(relContentDir: string, exts: string[]): string[] {
const extGlob = getExtGlob(exts);
return [`${relContentDir}/**/*${extGlob}`, `!**/_*/**${extGlob}`, `!**/_*${extGlob}`];
}
7 changes: 4 additions & 3 deletions packages/astro/src/core/app/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ function createRequestFromNodeRequest(req: NodeIncomingMessage, body?: Uint8Arra
req.socket instanceof TLSSocket || req.headers['x-forwarded-proto'] === 'https'
? 'https'
: 'http';
let url = `${protocol}://${req.headers.host}${req.url}`;
let rawHeaders = req.headers as Record<string, any>;
const hostname = req.headers.host || req.headers[':authority'];
const url = `${protocol}://${hostname}${req.url}`;
const rawHeaders = req.headers as Record<string, any>;
const entries = Object.entries(rawHeaders);
const method = req.method || 'GET';
let request = new Request(url, {
const request = new Request(url, {
method,
headers: new Headers(entries),
body: ['HEAD', 'GET'].includes(method) ? null : body,
Expand Down
6 changes: 4 additions & 2 deletions packages/astro/src/runtime/server/render/any.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
renderAstroTemplateResult,
} from './astro/index.js';
import { SlotString } from './slot.js';
import { bufferIterators } from './util.js';

export async function* renderChild(child: any): AsyncIterable<any> {
child = await child;
Expand All @@ -16,8 +17,9 @@ export async function* renderChild(child: any): AsyncIterable<any> {
} else if (isHTMLString(child)) {
yield child;
} else if (Array.isArray(child)) {
for (const value of child) {
yield markHTMLString(await renderChild(value));
const bufferedIterators = bufferIterators(child.map((c) => renderChild(c)));
for (const value of bufferedIterators) {
yield markHTMLString(await value);
}
} else if (typeof child === 'function') {
// Special: If a child is a function, call it automatically.
Expand Down
18 changes: 5 additions & 13 deletions packages/astro/src/runtime/server/render/astro/render-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { RenderInstruction } from '../types';
import { HTMLBytes, markHTMLString } from '../../escape.js';
import { isPromise } from '../../util.js';
import { renderChild } from '../any.js';
import { EagerAsyncIterableIterator } from '../util.js';
import { bufferIterators } from '../util.js';

const renderTemplateResultSym = Symbol.for('astro.renderTemplateResult');

Expand Down Expand Up @@ -36,23 +36,15 @@ export class RenderTemplateResult {
async *[Symbol.asyncIterator]() {
const { htmlParts, expressions } = this;

let iterables: Array<EagerAsyncIterableIterator> = [];
// all async iterators start running in non-buffered mode to avoid useless caching
for (let i = 0; i < htmlParts.length; i++) {
iterables.push(new EagerAsyncIterableIterator(renderChild(expressions[i])));
}
// once the execution of the next for loop is suspended due to an async component,
// this timeout triggers and we start buffering the other iterators
setTimeout(() => {
// buffer all iterators that haven't started yet
iterables.forEach((it) => !it.isStarted() && it.buffer());
}, 0);
let iterables = bufferIterators(expressions.map((e) => renderChild(e)));
for (let i = 0; i < htmlParts.length; i++) {
const html = htmlParts[i];
const iterable = iterables[i];

yield markHTMLString(html);
yield* iterable;
if (iterable) {
yield* iterable;
}
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions packages/astro/src/runtime/server/render/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,23 @@ export function renderElement(
return `<${name}${internalSpreadAttributes(props, shouldEscape)}>${children}</${name}>`;
}

/**
* This will take an array of async iterables and start buffering them eagerly.
* To avoid useless buffering, it will only start buffering the next tick, so the
* first sync iterables won't be buffered.
*/
export function bufferIterators<T>(iterators: AsyncIterable<T>[]): AsyncIterable<T>[] {
// all async iterators start running in non-buffered mode to avoid useless caching
const eagerIterators = iterators.map((it) => new EagerAsyncIterableIterator(it));
// once the execution of the next for loop is suspended due to an async component,
// this timeout triggers and we start buffering the other iterators
setTimeout(() => {
// buffer all iterators that haven't started yet
eagerIterators.forEach((it) => !it.isStarted() && it.buffer());
}, 0);
return eagerIterators;
}

// This wrapper around an AsyncIterable can eagerly consume its values, so that
// its values are ready to yield out ASAP. This is used for list-like usage of
// Astro components, so that we don't have to wait on earlier components to run
Expand Down
4 changes: 3 additions & 1 deletion packages/astro/src/vite-plugin-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import { viteID } from '../core/util.js';
* in our JS representation of modules like Markdown
*/
export function escapeViteEnvReferences(code: string) {
return code.replace(/import\.meta\.env/g, 'import\\u002Emeta.env');
return code
.replace(/import\.meta\.env/g, 'import\\u002Emeta.env')
.replace(/process\.env/g, 'process\\u002Eenv');
}

export function getFileInfo(id: string, config: AstroConfig) {
Expand Down
3 changes: 2 additions & 1 deletion packages/astro/test/fixtures/parallel/src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
import Delayed from '../components/Delayed.astro'
import Delayed from '../components/Delayed.astro';
---

<Delayed ms={30} />
<Delayed ms={20} />
<Delayed ms={40} />
<Delayed ms={10} />
{[<Delayed ms={30} />, <Delayed ms={20} />, <Delayed ms={40} />, <Delayed ms={10} />]}
2 changes: 1 addition & 1 deletion packages/integrations/cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"tiny-glob": "^0.2.9"
},
"peerDependencies": {
"astro": "workspace:^2.5.6"
"astro": "workspace:^2.5.7"
},
"devDependencies": {
"astro": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/deno/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"esbuild": "^0.15.18"
},
"peerDependencies": {
"astro": "workspace:^2.5.6"
"astro": "workspace:^2.5.7"
},
"devDependencies": {
"astro": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"vite": "^4.3.1"
},
"peerDependencies": {
"astro": "workspace:^2.5.6",
"astro": "workspace:^2.5.7",
"sharp": ">=0.31.0"
},
"peerDependenciesMeta": {
Expand Down
11 changes: 11 additions & 0 deletions packages/integrations/markdoc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @astrojs/markdoc

## 0.3.1

### Patch Changes

- [#7224](https://github.com/withastro/astro/pull/7224) [`563293c5d`](https://github.com/withastro/astro/commit/563293c5d67e2bf13b9c735581969a0341861b44) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Allow HTML comments `<!--like this-->` in Markdoc files.

- [#7185](https://github.com/withastro/astro/pull/7185) [`339529fc8`](https://github.com/withastro/astro/commit/339529fc820bac2d514b63198ecf54a1d88c0917) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Bring back improved style and script handling across content collection files. This addresses bugs found in a previous release to `@astrojs/markdoc`.

- Updated dependencies [[`6e27f2f6d`](https://github.com/withastro/astro/commit/6e27f2f6dbd52f980c487e875faf1b066f65cffd), [`96ae37eb0`](https://github.com/withastro/astro/commit/96ae37eb09f7406f40fba93e14b2a26ccd46640c), [`fea306936`](https://github.com/withastro/astro/commit/fea30693609cc517d8660972151f4d12a0dd4e82), [`5156c4f90`](https://github.com/withastro/astro/commit/5156c4f90e0922f62d25fa0c82bbefae39f4c2b6), [`9e7366567`](https://github.com/withastro/astro/commit/9e7366567e2b83d46a46db35e74ad508d1978039), [`339529fc8`](https://github.com/withastro/astro/commit/339529fc820bac2d514b63198ecf54a1d88c0917)]:
- astro@2.5.7

## 0.3.0

### Minor Changes
Expand Down
Loading

0 comments on commit 45c706c

Please sign in to comment.