astro 2.9.1 → 2.9.3

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 (45) hide show
  1. package/astro-jsx.d.ts +1 -0
  2. package/components/ViewTransitions.astro +23 -0
  3. package/dist/assets/image-endpoint.d.ts +1 -1
  4. package/dist/assets/internal.js +2 -2
  5. package/dist/assets/services/service.d.ts +5 -5
  6. package/dist/assets/utils/index.d.ts +3 -0
  7. package/dist/assets/utils/index.js +8 -1
  8. package/dist/assets/vite-plugin-assets.js +0 -54
  9. package/dist/cli/load-settings.js +2 -1
  10. package/dist/config/index.js +1 -1
  11. package/dist/core/config/settings.d.ts +2 -2
  12. package/dist/core/config/settings.js +5 -5
  13. package/dist/core/constants.js +1 -1
  14. package/dist/core/dev/dev.js +1 -1
  15. package/dist/core/dev/restart.js +1 -1
  16. package/dist/core/messages.js +2 -2
  17. package/dist/core/render/result.js +4 -7
  18. package/dist/runtime/server/index.d.ts +1 -1
  19. package/dist/runtime/server/index.js +0 -6
  20. package/dist/runtime/server/jsx.js +4 -13
  21. package/dist/runtime/server/render/any.d.ts +2 -1
  22. package/dist/runtime/server/render/any.js +18 -22
  23. package/dist/runtime/server/render/astro/index.d.ts +1 -1
  24. package/dist/runtime/server/render/astro/index.js +1 -6
  25. package/dist/runtime/server/render/astro/instance.d.ts +3 -2
  26. package/dist/runtime/server/render/astro/instance.js +8 -4
  27. package/dist/runtime/server/render/astro/render-template.d.ts +2 -4
  28. package/dist/runtime/server/render/astro/render-template.js +8 -29
  29. package/dist/runtime/server/render/astro/render.js +4 -24
  30. package/dist/runtime/server/render/common.d.ts +17 -13
  31. package/dist/runtime/server/render/common.js +6 -21
  32. package/dist/runtime/server/render/component.d.ts +10 -4
  33. package/dist/runtime/server/render/component.js +131 -54
  34. package/dist/runtime/server/render/dom.d.ts +1 -1
  35. package/dist/runtime/server/render/index.d.ts +3 -3
  36. package/dist/runtime/server/render/index.js +6 -11
  37. package/dist/runtime/server/render/page.d.ts +2 -7
  38. package/dist/runtime/server/render/page.js +13 -62
  39. package/dist/runtime/server/render/slot.d.ts +2 -1
  40. package/dist/runtime/server/render/slot.js +23 -16
  41. package/dist/runtime/server/render/util.d.ts +0 -18
  42. package/dist/runtime/server/render/util.js +0 -101
  43. package/dist/vite-plugin-astro/compile.js +0 -1
  44. package/dist/vite-plugin-jsx/index.js +0 -1
  45. package/package.json +2 -2
@@ -1,5 +1,6 @@
1
1
  import { HTMLString, markHTMLString } from "../escape.js";
2
2
  import { renderChild } from "./any.js";
3
+ import { chunkToString } from "./common.js";
3
4
  const slotString = Symbol.for("astro:slot-string");
4
5
  class SlotString extends HTMLString {
5
6
  constructor(content, instructions) {
@@ -12,29 +13,35 @@ slotString;
12
13
  function isSlotString(str) {
13
14
  return !!str[slotString];
14
15
  }
15
- async function* renderSlot(result, slotted, fallback) {
16
- if (slotted) {
17
- let iterator = renderChild(typeof slotted === "function" ? slotted(result) : slotted);
18
- yield* iterator;
19
- }
20
- if (fallback && !slotted) {
21
- yield* renderSlot(result, fallback);
16
+ function renderSlot(result, slotted, fallback) {
17
+ if (!slotted && fallback) {
18
+ return renderSlot(result, fallback);
22
19
  }
20
+ return {
21
+ async render(destination) {
22
+ await renderChild(destination, typeof slotted === "function" ? slotted(result) : slotted);
23
+ }
24
+ };
23
25
  }
24
26
  async function renderSlotToString(result, slotted, fallback) {
25
27
  let content = "";
26
28
  let instructions = null;
27
- let iterator = renderSlot(result, slotted, fallback);
28
- for await (const chunk of iterator) {
29
- if (typeof chunk.type === "string") {
30
- if (instructions === null) {
31
- instructions = [];
29
+ const temporaryDestination = {
30
+ write(chunk) {
31
+ if (chunk instanceof Response)
32
+ return;
33
+ if (typeof chunk === "object" && "type" in chunk && typeof chunk.type === "string") {
34
+ if (instructions === null) {
35
+ instructions = [];
36
+ }
37
+ instructions.push(chunk);
38
+ } else {
39
+ content += chunkToString(result, chunk);
32
40
  }
33
- instructions.push(chunk);
34
- } else {
35
- content += chunk;
36
41
  }
37
- }
42
+ };
43
+ const renderInstance = renderSlot(result, slotted, fallback);
44
+ await renderInstance.render(temporaryDestination);
38
45
  return markHTMLString(new SlotString(content, instructions));
39
46
  }
40
47
  async function renderSlots(result, slots = {}) {
@@ -6,21 +6,3 @@ export declare function formatList(values: string[]): string;
6
6
  export declare function addAttribute(value: any, key: string, shouldEscape?: boolean): any;
7
7
  export declare function internalSpreadAttributes(values: Record<any, any>, shouldEscape?: boolean): any;
8
8
  export declare function renderElement(name: string, { props: _props, children }: SSRElement, shouldEscape?: boolean): string;
9
- /**
10
- * This will take an array of async iterables and start buffering them eagerly.
11
- * To avoid useless buffering, it will only start buffering the next tick, so the
12
- * first sync iterables won't be buffered.
13
- */
14
- export declare function bufferIterators<T>(iterators: AsyncIterable<T>[]): AsyncIterable<T>[];
15
- export declare class EagerAsyncIterableIterator {
16
- #private;
17
- constructor(iterable: AsyncIterable<any>);
18
- /**
19
- * Starts to eagerly fetch the inner iterator and cache the results.
20
- * Note: This might not be called after next() has been called once, e.g. the iterator is started
21
- */
22
- buffer(): Promise<void>;
23
- next(): Promise<IteratorResult<any, any>>;
24
- isStarted(): boolean;
25
- [Symbol.asyncIterator](): this;
26
- }
@@ -103,109 +103,8 @@ function renderElement(name, { props: _props, children = "" }, shouldEscape = tr
103
103
  }
104
104
  return `<${name}${internalSpreadAttributes(props, shouldEscape)}>${children}</${name}>`;
105
105
  }
106
- const iteratorQueue = [];
107
- function queueIteratorBuffers(iterators) {
108
- if (iteratorQueue.length === 0) {
109
- setTimeout(() => {
110
- iteratorQueue.forEach((its) => its.forEach((it) => !it.isStarted() && it.buffer()));
111
- iteratorQueue.length = 0;
112
- });
113
- }
114
- iteratorQueue.push(iterators);
115
- }
116
- function bufferIterators(iterators) {
117
- const eagerIterators = iterators.map((it) => new EagerAsyncIterableIterator(it));
118
- queueIteratorBuffers(eagerIterators);
119
- return eagerIterators;
120
- }
121
- class EagerAsyncIterableIterator {
122
- #iterable;
123
- #queue = new Queue();
124
- #error = void 0;
125
- #next;
126
- /**
127
- * Whether the proxy is running in buffering or pass-through mode
128
- */
129
- #isBuffering = false;
130
- #gen = void 0;
131
- #isStarted = false;
132
- constructor(iterable) {
133
- this.#iterable = iterable;
134
- }
135
- /**
136
- * Starts to eagerly fetch the inner iterator and cache the results.
137
- * Note: This might not be called after next() has been called once, e.g. the iterator is started
138
- */
139
- async buffer() {
140
- if (this.#gen) {
141
- throw new Error("Cannot not switch from non-buffer to buffer mode");
142
- }
143
- this.#isBuffering = true;
144
- this.#isStarted = true;
145
- this.#gen = this.#iterable[Symbol.asyncIterator]();
146
- let value = void 0;
147
- do {
148
- this.#next = this.#gen.next();
149
- try {
150
- value = await this.#next;
151
- this.#queue.push(value);
152
- } catch (e) {
153
- this.#error = e;
154
- }
155
- } while (value && !value.done);
156
- }
157
- async next() {
158
- if (this.#error) {
159
- throw this.#error;
160
- }
161
- if (!this.#isBuffering) {
162
- if (!this.#gen) {
163
- this.#isStarted = true;
164
- this.#gen = this.#iterable[Symbol.asyncIterator]();
165
- }
166
- return await this.#gen.next();
167
- }
168
- if (!this.#queue.isEmpty()) {
169
- return this.#queue.shift();
170
- }
171
- await this.#next;
172
- return this.#queue.shift();
173
- }
174
- isStarted() {
175
- return this.#isStarted;
176
- }
177
- [Symbol.asyncIterator]() {
178
- return this;
179
- }
180
- }
181
- class Queue {
182
- constructor() {
183
- this.head = void 0;
184
- this.tail = void 0;
185
- }
186
- push(item) {
187
- if (this.head === void 0) {
188
- this.head = { item };
189
- this.tail = this.head;
190
- } else {
191
- this.tail.next = { item };
192
- this.tail = this.tail.next;
193
- }
194
- }
195
- isEmpty() {
196
- return this.head === void 0;
197
- }
198
- shift() {
199
- var _a, _b;
200
- const val = (_a = this.head) == null ? void 0 : _a.item;
201
- this.head = (_b = this.head) == null ? void 0 : _b.next;
202
- return val;
203
- }
204
- }
205
106
  export {
206
- EagerAsyncIterableIterator,
207
107
  addAttribute,
208
- bufferIterators,
209
108
  defineScriptVars,
210
109
  formatList,
211
110
  internalSpreadAttributes,
@@ -17,7 +17,6 @@ async function cachedFullCompilation({
17
17
  tsconfigRaw: {
18
18
  compilerOptions: {
19
19
  // Ensure client:only imports are treeshaken
20
- // @ts-expect-error anticipate esbuild 0.18 feature
21
20
  verbatimModuleSyntax: false,
22
21
  importsNotUsedAsValues: "remove"
23
22
  }
@@ -121,7 +121,6 @@ function jsx({ settings, logging }) {
121
121
  tsconfigRaw: {
122
122
  compilerOptions: {
123
123
  // Ensure client:only imports are treeshaken
124
- // @ts-expect-error anticipate esbuild 0.18 feature
125
124
  verbatimModuleSyntax: false,
126
125
  importsNotUsedAsValues: "remove"
127
126
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "2.9.1",
3
+ "version": "2.9.3",
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",
@@ -155,7 +155,7 @@
155
155
  "typescript": "*",
156
156
  "unist-util-visit": "^4.1.2",
157
157
  "vfile": "^5.3.7",
158
- "vite": "^4.3.9",
158
+ "vite": "^4.4.6",
159
159
  "vitefu": "^0.2.4",
160
160
  "which-pm": "^2.0.0",
161
161
  "yargs-parser": "^21.1.1",