astro 7.0.0-alpha.2 → 7.0.0-beta.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.
- package/dist/assets/fonts/core/collect-font-data.js +1 -0
- package/dist/assets/fonts/types.d.ts +1 -0
- package/dist/cli/add/index.js +0 -44
- package/dist/cli/dev/background.js +1 -1
- package/dist/cli/dev/index.js +1 -1
- package/dist/cli/flags.js +4 -6
- package/dist/cli/help/index.js +1 -2
- package/dist/cli/index.js +1 -15
- package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/container/index.js +1 -4
- package/dist/content/content-layer.js +3 -3
- package/dist/core/app/base.d.ts +1 -1
- package/dist/core/app/base.js +7 -9
- package/dist/core/app/dev/pipeline.js +0 -9
- package/dist/core/app/manifest.d.ts +0 -2
- package/dist/core/app/manifest.js +0 -8
- package/dist/core/app/types.d.ts +1 -8
- package/dist/core/base-pipeline.d.ts +3 -9
- package/dist/core/base-pipeline.js +4 -23
- package/dist/core/build/app.d.ts +0 -2
- package/dist/core/build/app.js +0 -5
- package/dist/core/build/generate.js +0 -14
- package/dist/core/build/pipeline.js +0 -9
- package/dist/core/build/plugins/plugin-manifest.js +4 -9
- package/dist/core/config/config.js +3 -2
- package/dist/core/config/schemas/base.d.ts +6 -19
- package/dist/core/config/schemas/base.js +8 -24
- package/dist/core/config/schemas/relative.d.ts +15 -36
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/fetch/fetch-state.js +0 -14
- package/dist/core/fetch/types.d.ts +1 -1
- package/dist/core/fetch/vite-plugin.js +4 -6
- package/dist/core/hono/index.d.ts +1 -0
- package/dist/core/hono/index.js +1 -0
- package/dist/core/logger/impls/node.js +0 -1
- package/dist/core/logger/load.js +3 -2
- package/dist/core/messages/runtime.js +1 -1
- package/dist/core/middleware/index.js +8 -1
- package/dist/manifest/serialized.js +4 -5
- package/dist/runtime/server/index.d.ts +1 -1
- package/dist/runtime/server/index.js +4 -0
- package/dist/runtime/server/render/astro/render-template.d.ts +1 -1
- package/dist/runtime/server/render/astro/render.d.ts +0 -4
- package/dist/runtime/server/render/astro/render.js +76 -68
- package/dist/runtime/server/render/index.d.ts +1 -0
- package/dist/runtime/server/render/index.js +2 -0
- package/dist/runtime/server/render/page.js +9 -44
- package/dist/runtime/server/render/streaming.d.ts +23 -0
- package/dist/runtime/server/render/streaming.js +238 -0
- package/dist/runtime/server/render/util.js +1 -1
- package/dist/types/public/config.d.ts +58 -121
- package/dist/types/public/context.d.ts +1 -1
- package/dist/types/public/internal.d.ts +0 -15
- package/dist/vite-plugin-app/app.js +1 -1
- package/dist/vite-plugin-app/pipeline.js +0 -9
- package/package.json +1 -1
- package/dist/cli/db/index.d.ts +0 -4
- package/dist/cli/db/index.js +0 -25
- package/dist/runtime/server/html-string-cache.d.ts +0 -48
- package/dist/runtime/server/html-string-cache.js +0 -119
- package/dist/runtime/server/render/queue/builder.d.ts +0 -14
- package/dist/runtime/server/render/queue/builder.js +0 -182
- package/dist/runtime/server/render/queue/jsx-builder.d.ts +0 -33
- package/dist/runtime/server/render/queue/jsx-builder.js +0 -146
- package/dist/runtime/server/render/queue/pool.d.ts +0 -123
- package/dist/runtime/server/render/queue/pool.js +0 -203
- package/dist/runtime/server/render/queue/renderer.d.ts +0 -12
- package/dist/runtime/server/render/queue/renderer.js +0 -103
- package/dist/runtime/server/render/queue/types.d.ts +0 -81
- package/dist/runtime/server/render/queue/types.js +0 -0
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { queuePoolSize } from "../../../../core/app/manifest.js";
|
|
2
|
-
class NodePool {
|
|
3
|
-
textPool = [];
|
|
4
|
-
htmlStringPool = [];
|
|
5
|
-
componentPool = [];
|
|
6
|
-
instructionPool = [];
|
|
7
|
-
maxSize;
|
|
8
|
-
enableStats;
|
|
9
|
-
stats = {
|
|
10
|
-
acquireFromPool: 0,
|
|
11
|
-
acquireNew: 0,
|
|
12
|
-
released: 0,
|
|
13
|
-
releasedDropped: 0
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Creates a new object pool for queue nodes.
|
|
17
|
-
*
|
|
18
|
-
* @param maxSize - Maximum number of nodes to keep in the pool (default: 1000).
|
|
19
|
-
* The cap is shared across all typed sub-pools.
|
|
20
|
-
* @param enableStats - Enable statistics tracking (default: false for performance)
|
|
21
|
-
*/
|
|
22
|
-
constructor(maxSize = 1e3, enableStats = false) {
|
|
23
|
-
this.maxSize = maxSize;
|
|
24
|
-
this.enableStats = enableStats;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Acquires a queue node from the pool or creates a new one if the pool is empty.
|
|
28
|
-
* Pops from the type-specific sub-pool to reuse an existing object when available.
|
|
29
|
-
*
|
|
30
|
-
* @param type - The type of queue node to acquire
|
|
31
|
-
* @param content - Optional content to set on the node (for text or html-string types)
|
|
32
|
-
* @returns A queue node ready to be populated with data
|
|
33
|
-
*/
|
|
34
|
-
acquire(type, content) {
|
|
35
|
-
const pooledNode = this.popFromTypedPool(type);
|
|
36
|
-
if (pooledNode) {
|
|
37
|
-
if (this.enableStats) {
|
|
38
|
-
this.stats.acquireFromPool = this.stats.acquireFromPool + 1;
|
|
39
|
-
}
|
|
40
|
-
this.resetNodeContent(pooledNode, type, content);
|
|
41
|
-
return pooledNode;
|
|
42
|
-
}
|
|
43
|
-
if (this.enableStats) {
|
|
44
|
-
this.stats.acquireNew = this.stats.acquireNew + 1;
|
|
45
|
-
}
|
|
46
|
-
return this.createNode(type, content);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Creates a new node of the specified type with the given content.
|
|
50
|
-
* Helper method to reduce branching in acquire().
|
|
51
|
-
*/
|
|
52
|
-
createNode(type, content = "") {
|
|
53
|
-
switch (type) {
|
|
54
|
-
case "text":
|
|
55
|
-
return { type: "text", content };
|
|
56
|
-
case "html-string":
|
|
57
|
-
return { type: "html-string", html: content };
|
|
58
|
-
case "component":
|
|
59
|
-
return { type: "component", instance: void 0 };
|
|
60
|
-
case "instruction":
|
|
61
|
-
return { type: "instruction", instruction: void 0 };
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Pops a node from the type-specific sub-pool.
|
|
66
|
-
* Returns undefined if the sub-pool for the requested type is empty.
|
|
67
|
-
*/
|
|
68
|
-
popFromTypedPool(type) {
|
|
69
|
-
switch (type) {
|
|
70
|
-
case "text":
|
|
71
|
-
return this.textPool.pop();
|
|
72
|
-
case "html-string":
|
|
73
|
-
return this.htmlStringPool.pop();
|
|
74
|
-
case "component":
|
|
75
|
-
return this.componentPool.pop();
|
|
76
|
-
case "instruction":
|
|
77
|
-
return this.instructionPool.pop();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Resets the content/value field on a reused pooled node.
|
|
82
|
-
* The type discriminant is already correct since we pop from the matching sub-pool.
|
|
83
|
-
*/
|
|
84
|
-
resetNodeContent(node, type, content) {
|
|
85
|
-
switch (type) {
|
|
86
|
-
case "text":
|
|
87
|
-
node.content = content ?? "";
|
|
88
|
-
break;
|
|
89
|
-
case "html-string":
|
|
90
|
-
node.html = content ?? "";
|
|
91
|
-
break;
|
|
92
|
-
case "component":
|
|
93
|
-
node.instance = void 0;
|
|
94
|
-
break;
|
|
95
|
-
case "instruction":
|
|
96
|
-
node.instruction = void 0;
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Returns the total number of nodes across all typed sub-pools.
|
|
102
|
-
*/
|
|
103
|
-
totalPoolSize() {
|
|
104
|
-
return this.textPool.length + this.htmlStringPool.length + this.componentPool.length + this.instructionPool.length;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Releases a queue node back to the pool for reuse.
|
|
108
|
-
* If the pool is at max capacity, the node is discarded (will be GC'd).
|
|
109
|
-
*
|
|
110
|
-
* @param node - The node to release back to the pool
|
|
111
|
-
*/
|
|
112
|
-
release(node) {
|
|
113
|
-
if (this.totalPoolSize() >= this.maxSize) {
|
|
114
|
-
if (this.enableStats) {
|
|
115
|
-
this.stats.releasedDropped = this.stats.releasedDropped + 1;
|
|
116
|
-
}
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
switch (node.type) {
|
|
120
|
-
case "text":
|
|
121
|
-
node.content = "";
|
|
122
|
-
this.textPool.push(node);
|
|
123
|
-
break;
|
|
124
|
-
case "html-string":
|
|
125
|
-
node.html = "";
|
|
126
|
-
this.htmlStringPool.push(node);
|
|
127
|
-
break;
|
|
128
|
-
case "component":
|
|
129
|
-
node.instance = void 0;
|
|
130
|
-
this.componentPool.push(node);
|
|
131
|
-
break;
|
|
132
|
-
case "instruction":
|
|
133
|
-
node.instruction = void 0;
|
|
134
|
-
this.instructionPool.push(node);
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
if (this.enableStats) {
|
|
138
|
-
this.stats.released = this.stats.released + 1;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Releases all nodes in an array back to the pool.
|
|
143
|
-
* This is a convenience method for releasing multiple nodes at once.
|
|
144
|
-
*
|
|
145
|
-
* @param nodes - Array of nodes to release
|
|
146
|
-
*/
|
|
147
|
-
releaseAll(nodes) {
|
|
148
|
-
for (const node of nodes) {
|
|
149
|
-
this.release(node);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Clears all typed sub-pools, discarding all cached nodes.
|
|
154
|
-
* This can be useful if you want to free memory after a large render.
|
|
155
|
-
*/
|
|
156
|
-
clear() {
|
|
157
|
-
this.textPool.length = 0;
|
|
158
|
-
this.htmlStringPool.length = 0;
|
|
159
|
-
this.componentPool.length = 0;
|
|
160
|
-
this.instructionPool.length = 0;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Gets the current total number of nodes across all typed sub-pools.
|
|
164
|
-
* Useful for monitoring pool usage and tuning maxSize.
|
|
165
|
-
*
|
|
166
|
-
* @returns Number of nodes currently available in the pool
|
|
167
|
-
*/
|
|
168
|
-
size() {
|
|
169
|
-
return this.totalPoolSize();
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Gets pool statistics for debugging.
|
|
173
|
-
*
|
|
174
|
-
* @returns Pool usage statistics including computed metrics
|
|
175
|
-
*/
|
|
176
|
-
getStats() {
|
|
177
|
-
return {
|
|
178
|
-
...this.stats,
|
|
179
|
-
poolSize: this.totalPoolSize(),
|
|
180
|
-
maxSize: this.maxSize,
|
|
181
|
-
hitRate: this.stats.acquireFromPool + this.stats.acquireNew > 0 ? this.stats.acquireFromPool / (this.stats.acquireFromPool + this.stats.acquireNew) * 100 : 0
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Resets pool statistics.
|
|
186
|
-
*/
|
|
187
|
-
resetStats() {
|
|
188
|
-
this.stats = {
|
|
189
|
-
acquireFromPool: 0,
|
|
190
|
-
acquireNew: 0,
|
|
191
|
-
released: 0,
|
|
192
|
-
releasedDropped: 0
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
function newNodePool(config) {
|
|
197
|
-
const poolSize = queuePoolSize(config);
|
|
198
|
-
return new NodePool(poolSize);
|
|
199
|
-
}
|
|
200
|
-
export {
|
|
201
|
-
NodePool,
|
|
202
|
-
newNodePool
|
|
203
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type RenderDestination } from '../common.js';
|
|
2
|
-
import type { RenderQueue } from './types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Renders a queue of nodes to a destination.
|
|
5
|
-
* This function processes nodes sequentially with batching optimization.
|
|
6
|
-
* Consecutive batchable nodes (text, HTML-string, simple elements) are
|
|
7
|
-
* combined into a single write to reduce overhead.
|
|
8
|
-
*
|
|
9
|
-
* @param queue - The render queue to process
|
|
10
|
-
* @param destination - Where to write the output
|
|
11
|
-
*/
|
|
12
|
-
export declare function renderQueue(queue: RenderQueue, destination: RenderDestination): Promise<void>;
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { markHTMLString, escapeHTML } from "../../escape.js";
|
|
2
|
-
import { chunkToString } from "../common.js";
|
|
3
|
-
async function renderQueue(queue, destination) {
|
|
4
|
-
const result = queue.result;
|
|
5
|
-
const pool = queue.pool;
|
|
6
|
-
const cache = queue.htmlStringCache;
|
|
7
|
-
let batchBuffer = "";
|
|
8
|
-
let i = 0;
|
|
9
|
-
while (i < queue.nodes.length) {
|
|
10
|
-
const node = queue.nodes[i];
|
|
11
|
-
try {
|
|
12
|
-
if (canBatch(node)) {
|
|
13
|
-
const batchStart = i;
|
|
14
|
-
while (i < queue.nodes.length && canBatch(queue.nodes[i])) {
|
|
15
|
-
batchBuffer += renderNodeToString(queue.nodes[i]);
|
|
16
|
-
i = i + 1;
|
|
17
|
-
}
|
|
18
|
-
if (batchBuffer) {
|
|
19
|
-
const htmlString = cache ? cache.getOrCreate(batchBuffer) : markHTMLString(batchBuffer);
|
|
20
|
-
destination.write(htmlString);
|
|
21
|
-
batchBuffer = "";
|
|
22
|
-
}
|
|
23
|
-
if (pool) {
|
|
24
|
-
for (let j = batchStart; j < i; j++) {
|
|
25
|
-
pool.release(queue.nodes[j]);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
} else {
|
|
29
|
-
await renderNode(node, destination, result);
|
|
30
|
-
if (pool) {
|
|
31
|
-
pool.release(node);
|
|
32
|
-
}
|
|
33
|
-
i = i + 1;
|
|
34
|
-
}
|
|
35
|
-
} catch (error) {
|
|
36
|
-
throw error;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
if (batchBuffer) {
|
|
40
|
-
const htmlString = cache ? cache.getOrCreate(batchBuffer) : markHTMLString(batchBuffer);
|
|
41
|
-
destination.write(htmlString);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function canBatch(node) {
|
|
45
|
-
return node.type === "text" || node.type === "html-string";
|
|
46
|
-
}
|
|
47
|
-
function renderNodeToString(node) {
|
|
48
|
-
switch (node.type) {
|
|
49
|
-
case "text":
|
|
50
|
-
return node.content ? escapeHTML(node.content) : "";
|
|
51
|
-
case "html-string":
|
|
52
|
-
return node.html || "";
|
|
53
|
-
case "component":
|
|
54
|
-
case "instruction": {
|
|
55
|
-
return "";
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
async function renderNode(node, destination, result) {
|
|
60
|
-
const cache = result._experimentalQueuedRendering?.htmlStringCache;
|
|
61
|
-
switch (node.type) {
|
|
62
|
-
case "text": {
|
|
63
|
-
if (node.content) {
|
|
64
|
-
const escaped = escapeHTML(node.content);
|
|
65
|
-
const htmlString = cache ? cache.getOrCreate(escaped) : markHTMLString(escaped);
|
|
66
|
-
destination.write(htmlString);
|
|
67
|
-
}
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
case "html-string": {
|
|
71
|
-
if (node.html) {
|
|
72
|
-
const htmlString = cache ? cache.getOrCreate(node.html) : markHTMLString(node.html);
|
|
73
|
-
destination.write(htmlString);
|
|
74
|
-
}
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
case "instruction": {
|
|
78
|
-
if (node.instruction) {
|
|
79
|
-
destination.write(node.instruction);
|
|
80
|
-
}
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
case "component": {
|
|
84
|
-
if (node.instance) {
|
|
85
|
-
let componentHtml = "";
|
|
86
|
-
const componentDestination = {
|
|
87
|
-
write(chunk) {
|
|
88
|
-
if (chunk instanceof Response) return;
|
|
89
|
-
componentHtml += chunkToString(result, chunk);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
await node.instance.render(componentDestination);
|
|
93
|
-
if (componentHtml) {
|
|
94
|
-
destination.write(componentHtml);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
export {
|
|
102
|
-
renderQueue
|
|
103
|
-
};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import type { SSRResult } from '../../../../types/public/internal.js';
|
|
2
|
-
import type { AstroComponentInstance } from '../astro/instance.js';
|
|
3
|
-
import type { RenderInstruction } from '../instruction.js';
|
|
4
|
-
import type { ServerIslandComponent } from '../server-islands.js';
|
|
5
|
-
import type { NodePool } from './pool.js';
|
|
6
|
-
import type { HTMLStringCache } from '../../html-string-cache.js';
|
|
7
|
-
/**
|
|
8
|
-
* Text node containing plain text content that will be HTML-escaped during rendering
|
|
9
|
-
*/
|
|
10
|
-
export interface TextNode {
|
|
11
|
-
type: 'text';
|
|
12
|
-
content: string;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* HTML string node containing pre-rendered HTML markup that is already safe
|
|
16
|
-
*/
|
|
17
|
-
export interface HtmlStringNode {
|
|
18
|
-
type: 'html-string';
|
|
19
|
-
html: string;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Component node containing an Astro component instance to be rendered
|
|
23
|
-
*/
|
|
24
|
-
export interface ComponentNode {
|
|
25
|
-
type: 'component';
|
|
26
|
-
instance: AstroComponentInstance | ServerIslandComponent;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Instruction node containing rendering instructions (head content, hydration scripts, etc.)
|
|
30
|
-
*/
|
|
31
|
-
export interface InstructionNode {
|
|
32
|
-
type: 'instruction';
|
|
33
|
-
instruction: RenderInstruction;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Discriminated union of all queue node types.
|
|
37
|
-
* TypeScript will narrow the type based on the 'type' field.
|
|
38
|
-
*/
|
|
39
|
-
export type QueueNode = TextNode | HtmlStringNode | ComponentNode | InstructionNode;
|
|
40
|
-
/**
|
|
41
|
-
* The render queue containing all nodes to be rendered
|
|
42
|
-
*/
|
|
43
|
-
export interface RenderQueue {
|
|
44
|
-
/**
|
|
45
|
-
* All nodes in rendering order (after reversing the built queue)
|
|
46
|
-
*/
|
|
47
|
-
nodes: QueueNode[];
|
|
48
|
-
/**
|
|
49
|
-
* SSRResult context
|
|
50
|
-
*/
|
|
51
|
-
result: SSRResult;
|
|
52
|
-
/**
|
|
53
|
-
* Object pool instance used for node acquisition
|
|
54
|
-
*/
|
|
55
|
-
pool?: NodePool;
|
|
56
|
-
/**
|
|
57
|
-
* HTMLString cache instance for reducing memory allocations
|
|
58
|
-
*/
|
|
59
|
-
htmlStringCache?: HTMLStringCache;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Stack item used during queue building (internal use only)
|
|
63
|
-
*/
|
|
64
|
-
export interface StackItem {
|
|
65
|
-
/**
|
|
66
|
-
* The value to process
|
|
67
|
-
*/
|
|
68
|
-
node: any;
|
|
69
|
-
/**
|
|
70
|
-
* Parent queue node (tracked but not used during rendering)
|
|
71
|
-
*/
|
|
72
|
-
parent: QueueNode | null;
|
|
73
|
-
/**
|
|
74
|
-
* Additional metadata passed through the stack (component props, slots, displayName)
|
|
75
|
-
*/
|
|
76
|
-
metadata?: {
|
|
77
|
-
displayName?: string;
|
|
78
|
-
props?: Record<string, any>;
|
|
79
|
-
slots?: any;
|
|
80
|
-
};
|
|
81
|
-
}
|
|
File without changes
|