@ascribed/astro 0.1.1 → 0.1.2-next.2
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/README.md +6 -2
- package/dist/attributes.d.ts +17 -0
- package/dist/attributes.js +93 -5
- package/dist/attributes.js.map +1 -1
- package/dist/dev.d.ts +24 -1
- package/dist/dev.js +69 -9
- package/dist/dev.js.map +1 -1
- package/dist/index.d.ts +13 -0
- package/dist/index.js +84 -9
- package/dist/index.js.map +1 -1
- package/dist/rehype.d.ts +1 -1
- package/dist/rehype.js +19 -5
- package/dist/rehype.js.map +1 -1
- package/dist/review/devfile.d.ts +21 -0
- package/dist/review/devfile.js +39 -0
- package/dist/review/devfile.js.map +1 -0
- package/dist/review/diff.d.ts +21 -0
- package/dist/review/diff.js +47 -0
- package/dist/review/diff.js.map +1 -0
- package/dist/review/github.d.ts +19 -0
- package/dist/review/github.js +73 -0
- package/dist/review/github.js.map +1 -0
- package/dist/review/protocol.d.ts +98 -0
- package/dist/review/protocol.js +14 -0
- package/dist/review/protocol.js.map +1 -0
- package/dist/review/routes.d.ts +13 -0
- package/dist/review/routes.js +92 -0
- package/dist/review/routes.js.map +1 -0
- package/dist/review/server.d.ts +100 -0
- package/dist/review/server.js +336 -0
- package/dist/review/server.js.map +1 -0
- package/dist/run.d.ts +14 -1
- package/dist/run.js +19 -3
- package/dist/run.js.map +1 -1
- package/dist/satteri.d.ts +1 -1
- package/dist/satteri.js +22 -5
- package/dist/satteri.js.map +1 -1
- package/dist/toolbar/app.d.ts +2 -0
- package/dist/toolbar/app.js +951 -0
- package/dist/toolbar/app.js.map +1 -0
- package/dist/toolbar/page.d.ts +40 -0
- package/dist/toolbar/page.js +120 -0
- package/dist/toolbar/page.js.map +1 -0
- package/dist/toolbar/style.d.ts +1 -0
- package/dist/toolbar/style.js +250 -0
- package/dist/toolbar/style.js.map +1 -0
- package/dist/toolbar/text.d.ts +49 -0
- package/dist/toolbar/text.js +114 -0
- package/dist/toolbar/text.js.map +1 -0
- package/package.json +6 -3
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
// Review in the site preview, on the dev server's side: everything the
|
|
2
|
+
// toolbar app asks for, answered over Astro's dev toolbar channel. Every
|
|
3
|
+
// `git`, `ascribe`, and `gh` call happens here; the page gets the changes and
|
|
4
|
+
// the threads, never a token. There are no HTTP routes: any page open in the
|
|
5
|
+
// same browser could call a route on localhost, while the toolbar's channel
|
|
6
|
+
// takes only clients that have the dev server's token (`channelProblem`).
|
|
7
|
+
//
|
|
8
|
+
// Nothing runs until the reviewer turns the app on. Then the server opens
|
|
9
|
+
// the pull request's review (when the GitHub CLI finds one), compares the
|
|
10
|
+
// build with the pull request's base (or the default branch), and compares
|
|
11
|
+
// again after each rebuild.
|
|
12
|
+
import path from "node:path";
|
|
13
|
+
import { messageOf } from "./github.js";
|
|
14
|
+
import { CHANGED_EVENT, REQUEST_EVENT, RESULT_EVENT, } from "./protocol.js";
|
|
15
|
+
import { normalizeRoute } from "./routes.js";
|
|
16
|
+
/** The overlay's requests, which go to the session. */
|
|
17
|
+
const OVERLAY = new Set([
|
|
18
|
+
"load",
|
|
19
|
+
"commentTarget",
|
|
20
|
+
"comment",
|
|
21
|
+
"reply",
|
|
22
|
+
"allThreads",
|
|
23
|
+
"resolve",
|
|
24
|
+
"submit",
|
|
25
|
+
"discard",
|
|
26
|
+
]);
|
|
27
|
+
export class ReviewServer {
|
|
28
|
+
options;
|
|
29
|
+
on = false;
|
|
30
|
+
problem;
|
|
31
|
+
connection;
|
|
32
|
+
connecting;
|
|
33
|
+
diffed;
|
|
34
|
+
diffing;
|
|
35
|
+
stale = false;
|
|
36
|
+
timer;
|
|
37
|
+
routes;
|
|
38
|
+
/** The page each overlay last read, by content path: comments are made on it. */
|
|
39
|
+
pages = new Map();
|
|
40
|
+
/** How long the last comparison took, in milliseconds. */
|
|
41
|
+
lastDiffMs;
|
|
42
|
+
constructor(options) {
|
|
43
|
+
this.options = options;
|
|
44
|
+
this.problem = options.channelProblem;
|
|
45
|
+
options.channel.on(REQUEST_EVENT, (data, client) => {
|
|
46
|
+
void this.receive(data, client);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The address the dev server listens on, once it does: one other machines
|
|
51
|
+
* can reach turns comments off, as `server.host` does.
|
|
52
|
+
*/
|
|
53
|
+
listening(address) {
|
|
54
|
+
if (this.problem !== undefined || isLoopback(address))
|
|
55
|
+
return;
|
|
56
|
+
this.problem = NETWORK_PROBLEM;
|
|
57
|
+
this.connection = undefined;
|
|
58
|
+
this.connecting = undefined;
|
|
59
|
+
}
|
|
60
|
+
/** Whether review is on: then the dev server's builds write JSON output too. */
|
|
61
|
+
get active() {
|
|
62
|
+
return this.on;
|
|
63
|
+
}
|
|
64
|
+
/** The dev server rebuilt: compare again soon, and read the routes again when asked. */
|
|
65
|
+
rebuilt() {
|
|
66
|
+
if (!this.on)
|
|
67
|
+
return;
|
|
68
|
+
this.stale = true;
|
|
69
|
+
this.routes = undefined;
|
|
70
|
+
if (this.timer)
|
|
71
|
+
clearTimeout(this.timer);
|
|
72
|
+
this.timer = setTimeout(() => {
|
|
73
|
+
this.timer = undefined;
|
|
74
|
+
void this.changes();
|
|
75
|
+
}, this.options.debounceMs ?? 150);
|
|
76
|
+
}
|
|
77
|
+
/** The dev server stopped. */
|
|
78
|
+
dispose() {
|
|
79
|
+
if (this.timer)
|
|
80
|
+
clearTimeout(this.timer);
|
|
81
|
+
this.on = false;
|
|
82
|
+
}
|
|
83
|
+
async receive(data, client) {
|
|
84
|
+
const request = data;
|
|
85
|
+
if (typeof request?.id !== "number" || typeof request.method !== "string")
|
|
86
|
+
return;
|
|
87
|
+
const params = typeof request.params === "object" && request.params !== null ? request.params : {};
|
|
88
|
+
const tab = typeof request.tab === "string" ? request.tab : "";
|
|
89
|
+
const answer = { tab, id: request.id };
|
|
90
|
+
try {
|
|
91
|
+
answer.result = await this.handle(request.method, params, tab);
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
const code = error.code;
|
|
95
|
+
answer.error =
|
|
96
|
+
typeof code === "string"
|
|
97
|
+
? { message: messageOf(error), code }
|
|
98
|
+
: { message: messageOf(error) };
|
|
99
|
+
}
|
|
100
|
+
if (typeof client?.send === "function")
|
|
101
|
+
client.send(RESULT_EVENT, answer);
|
|
102
|
+
else
|
|
103
|
+
this.options.channel.send(RESULT_EVENT, answer);
|
|
104
|
+
}
|
|
105
|
+
/** Answers one request. Rejects with a sentence to show. */
|
|
106
|
+
async handle(method, params, tab = "") {
|
|
107
|
+
switch (method) {
|
|
108
|
+
case "status":
|
|
109
|
+
return { on: this.on };
|
|
110
|
+
case "start":
|
|
111
|
+
await this.start();
|
|
112
|
+
return { on: true };
|
|
113
|
+
case "stop":
|
|
114
|
+
this.stop();
|
|
115
|
+
this.changed(tab);
|
|
116
|
+
return { on: false };
|
|
117
|
+
case "page":
|
|
118
|
+
return this.pageView(params);
|
|
119
|
+
case "refresh":
|
|
120
|
+
await this.refresh();
|
|
121
|
+
this.changed(tab);
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
if (!OVERLAY.has(method))
|
|
125
|
+
throw new Error(`Unknown request: ${method}.`);
|
|
126
|
+
const connection = this.on ? await this.connected() : undefined;
|
|
127
|
+
if (connection?.state !== "on")
|
|
128
|
+
throw new Error("Review comments aren't on.");
|
|
129
|
+
const github = await import("@ascribed/review/github");
|
|
130
|
+
const pagePath = typeof params["path"] === "string" ? params["path"] : undefined;
|
|
131
|
+
const answer = await github.answerRequest({
|
|
132
|
+
session: connection.session,
|
|
133
|
+
page: pagePath === undefined ? undefined : { build: this.options.build, path: pagePath },
|
|
134
|
+
lastPage: pagePath === undefined ? undefined : this.pages.get(pagePath),
|
|
135
|
+
changedPages: async () => {
|
|
136
|
+
const changes = await this.changes();
|
|
137
|
+
return "result" in changes ? changes.result.pages : [];
|
|
138
|
+
},
|
|
139
|
+
}, method, params);
|
|
140
|
+
if (answer.page)
|
|
141
|
+
this.pages.set(answer.page.path, answer.page);
|
|
142
|
+
if (answer.changed)
|
|
143
|
+
this.changed(tab);
|
|
144
|
+
return answer.result;
|
|
145
|
+
}
|
|
146
|
+
async start() {
|
|
147
|
+
if (this.on)
|
|
148
|
+
return;
|
|
149
|
+
this.on = true;
|
|
150
|
+
this.stale = true;
|
|
151
|
+
this.routes = undefined;
|
|
152
|
+
this.connection = undefined;
|
|
153
|
+
const started = Date.now();
|
|
154
|
+
// The routes come from the JSON output, which the next builds write too.
|
|
155
|
+
const routes = this.options.writeRoutes().catch((error) => {
|
|
156
|
+
this.options.logger.warn(`couldn't write the routes for review: ${messageOf(error)}`);
|
|
157
|
+
});
|
|
158
|
+
await this.connected();
|
|
159
|
+
const changes = await this.changes();
|
|
160
|
+
await routes;
|
|
161
|
+
if ("result" in changes) {
|
|
162
|
+
const base = changes.result.base;
|
|
163
|
+
this.options.logger.info(`review: compared "${this.options.build}" with ${base.requested} in ${this.lastDiffMs ?? 0} ms (started in ${Date.now() - started} ms)`);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
this.options.logger.warn(`review: ${changes.error}`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
stop() {
|
|
170
|
+
this.on = false;
|
|
171
|
+
this.connection = undefined;
|
|
172
|
+
this.connecting = undefined;
|
|
173
|
+
this.diffed = undefined;
|
|
174
|
+
this.routes = undefined;
|
|
175
|
+
this.pages.clear();
|
|
176
|
+
if (this.timer)
|
|
177
|
+
clearTimeout(this.timer);
|
|
178
|
+
this.timer = undefined;
|
|
179
|
+
}
|
|
180
|
+
async refresh() {
|
|
181
|
+
if (!this.on)
|
|
182
|
+
return;
|
|
183
|
+
const connection = await this.connected();
|
|
184
|
+
if (connection.state === "on")
|
|
185
|
+
await connection.session.refresh();
|
|
186
|
+
else
|
|
187
|
+
this.connection = undefined;
|
|
188
|
+
// A pull request found now changes the base.
|
|
189
|
+
await this.connected();
|
|
190
|
+
this.stale = true;
|
|
191
|
+
await this.changes();
|
|
192
|
+
}
|
|
193
|
+
/** The pull request's review, opened once while review is on. */
|
|
194
|
+
connected() {
|
|
195
|
+
if (this.connection)
|
|
196
|
+
return Promise.resolve(this.connection);
|
|
197
|
+
if (this.problem !== undefined) {
|
|
198
|
+
this.connection = {
|
|
199
|
+
state: "unprotected",
|
|
200
|
+
message: `Showing changes only. Comments are off because ${this.problem}.`,
|
|
201
|
+
};
|
|
202
|
+
return Promise.resolve(this.connection);
|
|
203
|
+
}
|
|
204
|
+
this.connecting ??= this.options
|
|
205
|
+
.connect()
|
|
206
|
+
.catch((error) => ({ state: "error", message: messageOf(error) }))
|
|
207
|
+
.then((connection) => {
|
|
208
|
+
this.connecting = undefined;
|
|
209
|
+
// The server turned out to listen on the network meanwhile.
|
|
210
|
+
if (this.problem !== undefined)
|
|
211
|
+
return this.connected();
|
|
212
|
+
if (this.on)
|
|
213
|
+
this.connection = connection;
|
|
214
|
+
return connection;
|
|
215
|
+
});
|
|
216
|
+
return this.connecting;
|
|
217
|
+
}
|
|
218
|
+
/** The build's changes, compared again first if a rebuild made them stale. */
|
|
219
|
+
async changes() {
|
|
220
|
+
while (this.diffing)
|
|
221
|
+
await this.diffing;
|
|
222
|
+
if (this.stale || this.diffed === undefined) {
|
|
223
|
+
this.stale = false;
|
|
224
|
+
this.diffing = this.compare().finally(() => {
|
|
225
|
+
this.diffing = undefined;
|
|
226
|
+
});
|
|
227
|
+
await this.diffing;
|
|
228
|
+
}
|
|
229
|
+
return this.diffed ?? { error: "Review is off." };
|
|
230
|
+
}
|
|
231
|
+
async compare() {
|
|
232
|
+
const connection = await this.connected();
|
|
233
|
+
const base = connection.state === "on" ? connection.base : undefined;
|
|
234
|
+
const started = Date.now();
|
|
235
|
+
try {
|
|
236
|
+
this.diffed = { result: await this.options.diff(base) };
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
this.diffed = { error: messageOf(error) };
|
|
240
|
+
}
|
|
241
|
+
this.lastDiffMs = Date.now() - started;
|
|
242
|
+
}
|
|
243
|
+
async pageView(params) {
|
|
244
|
+
if (!this.on)
|
|
245
|
+
throw new Error("Review is off.");
|
|
246
|
+
const route = normalizeRoute(typeof params["route"] === "string" ? params["route"] : "/");
|
|
247
|
+
const fromPage = typeof params["path"] === "string" ? params["path"] : null;
|
|
248
|
+
this.routes ??= this.options.readRoutes().catch(() => new Map());
|
|
249
|
+
const [changes, connection, routes] = await Promise.all([
|
|
250
|
+
this.changes(),
|
|
251
|
+
this.connected(),
|
|
252
|
+
this.routes,
|
|
253
|
+
]);
|
|
254
|
+
const pages = "result" in changes ? changes.result.pages : [];
|
|
255
|
+
const shown = pages.filter((p) => p.status !== "removed");
|
|
256
|
+
let page = shown.find((p) => normalizeRoute(p.route) === route) ?? null;
|
|
257
|
+
const pagePath = page?.path ?? fromPage ?? routes.get(route)?.path ?? null;
|
|
258
|
+
if (page === null && pagePath !== null)
|
|
259
|
+
page = shown.find((p) => p.path === pagePath) ?? null;
|
|
260
|
+
return {
|
|
261
|
+
kind: pagePath === null ? "not-page" : "page",
|
|
262
|
+
path: pagePath,
|
|
263
|
+
page,
|
|
264
|
+
base: "result" in changes ? changes.result.base : null,
|
|
265
|
+
problem: "error" in changes ? changes.error : null,
|
|
266
|
+
errors: "result" in changes ? changes.result.errors : 0,
|
|
267
|
+
threads: threadsState(connection),
|
|
268
|
+
changedPages: pages.map((p) => listed(p, routes.get(normalizeRoute(p.route))?.title ?? null)),
|
|
269
|
+
contentRoot: this.options.contentRoot,
|
|
270
|
+
separator: path.sep,
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
/** Tells every page the threads or the changes changed; `from` is the page that did it. */
|
|
274
|
+
changed(from) {
|
|
275
|
+
this.options.channel.send(CHANGED_EVENT, { from });
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/** A changed page as the list shows it: without its changes, with its title. */
|
|
279
|
+
function listed(page, title) {
|
|
280
|
+
return {
|
|
281
|
+
title,
|
|
282
|
+
path: page.path,
|
|
283
|
+
route: page.route,
|
|
284
|
+
status: page.status,
|
|
285
|
+
own_file_changed: page.own_file_changed,
|
|
286
|
+
because: page.because,
|
|
287
|
+
page_changed: page.page_changed,
|
|
288
|
+
counts: page.counts,
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
/** What the page shows about the threads. */
|
|
292
|
+
function threadsState(connection) {
|
|
293
|
+
if (connection.state !== "on")
|
|
294
|
+
return connection;
|
|
295
|
+
const pr = connection.session.pullRequest;
|
|
296
|
+
return {
|
|
297
|
+
state: "on",
|
|
298
|
+
pullRequest: { number: pr.number, url: pr.url, baseRefName: pr.baseRefName },
|
|
299
|
+
local: connection.local,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Why someone other than the developer could use the dev server's toolbar
|
|
304
|
+
* channel, or `undefined` when they can't. Vite takes a browser's connection
|
|
305
|
+
* only with the token in its client script, which the page's own origin can
|
|
306
|
+
* read and, by default, only localhost origins can fetch. These settings undo
|
|
307
|
+
* that, and a server listening on the network gives its pages, token and all,
|
|
308
|
+
* to anyone who can reach it.
|
|
309
|
+
*/
|
|
310
|
+
export function channelProblem(config) {
|
|
311
|
+
const pages = "other web pages could talk to this dev server";
|
|
312
|
+
if (config.legacy?.skipWebSocketTokenCheck === true) {
|
|
313
|
+
return `${pages}: \`legacy.skipWebSocketTokenCheck\` is on`;
|
|
314
|
+
}
|
|
315
|
+
if (config.server.allowedHosts === true)
|
|
316
|
+
return `${pages}: \`server.allowedHosts\` is \`true\``;
|
|
317
|
+
const cors = config.server.cors;
|
|
318
|
+
const origin = typeof cors === "object" && cors !== null ? cors.origin : undefined;
|
|
319
|
+
if (cors === true || origin === true || origin === "*") {
|
|
320
|
+
return `${pages}: \`server.cors\` lets any origin read its pages`;
|
|
321
|
+
}
|
|
322
|
+
if (!isLoopback(config.server.host))
|
|
323
|
+
return NETWORK_PROBLEM;
|
|
324
|
+
return undefined;
|
|
325
|
+
}
|
|
326
|
+
const NETWORK_PROBLEM = "the dev server is listening on the network (`--host`), so anyone who can reach it could comment as you";
|
|
327
|
+
/** Whether Vite's `server.host`, or the address the server listens on, keeps the server on this machine: unset, `false`, or a loopback name. */
|
|
328
|
+
export function isLoopback(host) {
|
|
329
|
+
if (host === undefined || host === false)
|
|
330
|
+
return true;
|
|
331
|
+
if (typeof host !== "string")
|
|
332
|
+
return false;
|
|
333
|
+
const name = host.toLowerCase().replace(/^\[(.*)\]$/, "$1");
|
|
334
|
+
return name === "localhost" || name === "::1" || /^127(\.\d{1,3}){3}$/.test(name);
|
|
335
|
+
}
|
|
336
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/review/server.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yEAAyE;AACzE,8EAA8E;AAC9E,6EAA6E;AAC7E,4EAA4E;AAC5E,0EAA0E;AAC1E,EAAE;AACF,0EAA0E;AAC1E,0EAA0E;AAC1E,2EAA2E;AAC3E,4BAA4B;AAC5B,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EAAE,SAAS,EAAmB,MAAM,aAAa,CAAC;AACzD,OAAO,EACL,aAAa,EACb,aAAa,EACb,YAAY,GAQb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAmB,MAAM,aAAa,CAAC;AAqC9D,uDAAuD;AACvD,MAAM,OAAO,GAAwB,IAAI,GAAG,CAAgB;IAC1D,MAAM;IACN,eAAe;IACf,SAAS;IACT,OAAO;IACP,YAAY;IACZ,SAAS;IACT,QAAQ;IACR,SAAS;CACV,CAAC,CAAC;AAEH,MAAM,OAAO,YAAY;IAeM,OAAO;IAd5B,EAAE,GAAG,KAAK,CAAC;IACX,OAAO,CAAqB;IAC5B,UAAU,CAAyB;IACnC,UAAU,CAAkC;IAC5C,MAAM,CAAyD;IAC/D,OAAO,CAA4B;IACnC,KAAK,GAAG,K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IAAI,KAAK,IAAI,CAAC,CAAC,CAAE,IAA6B,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IAChG,IAAI,IAAI,KAAK,IAAI,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;QACvD,OAAO,GAAG,KAAK,kDAAkD,CAAC;IACpE,CAAC;IACD,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;QAAE,OAAO,eAAe,CAAC;IAC5D,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,eAAe,GACnB,wGAAwG,CAAC;AAE3G,gJAAgJ;AAChJ,MAAM,UAAU,UAAU,CAAC,IAAa;IACtC,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,KAAK;QAAE,OAAO,IAAI,CAAC;IACtD,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IAC5D,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,KAAK,IAAI,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACpF,CAAC"}
|
package/dist/run.d.ts
CHANGED
|
@@ -6,7 +6,16 @@ export interface BuildResult {
|
|
|
6
6
|
summary: string;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Whether an Astro command builds with source anchors, given the integration's
|
|
10
|
+
* `anchors` option: `"dev"` means in `astro dev` only, so `astro build` has
|
|
11
|
+
* them only when it is `true`. Review in the site preview (`review`) needs
|
|
12
|
+
* them in `astro dev`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function anchorsFor(anchors: boolean | "dev" | undefined, command: string, review?: boolean): boolean;
|
|
15
|
+
/** Whether an Astro command has review in the site preview, given the `review` option. */
|
|
16
|
+
export declare function reviewFor(review: boolean | undefined, command: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Builds one build's outputs, the site output by default. Rejects, with the compiler's report as the
|
|
10
19
|
* message, if the build has errors: the Astro build fails with them.
|
|
11
20
|
*/
|
|
12
21
|
export declare function runBuild(options: {
|
|
@@ -14,4 +23,8 @@ export declare function runBuild(options: {
|
|
|
14
23
|
configPath: string;
|
|
15
24
|
build: string;
|
|
16
25
|
cwd: string;
|
|
26
|
+
/** Write source anchors (`--anchors`). */
|
|
27
|
+
anchors?: boolean;
|
|
28
|
+
/** The outputs to write. Default: `["site"]`. */
|
|
29
|
+
outputs?: readonly ("site" | "json")[];
|
|
17
30
|
}): Promise<BuildResult>;
|
package/dist/run.js
CHANGED
|
@@ -1,14 +1,28 @@
|
|
|
1
|
-
// Running `ascribe build
|
|
1
|
+
// Running `ascribe build` for the configured build: its site output, and
|
|
2
|
+
// its JSON output while review is on.
|
|
2
3
|
import { execFile } from "node:child_process";
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* Whether an Astro command builds with source anchors, given the integration's
|
|
6
|
+
* `anchors` option: `"dev"` means in `astro dev` only, so `astro build` has
|
|
7
|
+
* them only when it is `true`. Review in the site preview (`review`) needs
|
|
8
|
+
* them in `astro dev`.
|
|
9
|
+
*/
|
|
10
|
+
export function anchorsFor(anchors, command, review = false) {
|
|
11
|
+
return anchors === true || (command === "dev" && (anchors === "dev" || review));
|
|
12
|
+
}
|
|
13
|
+
/** Whether an Astro command has review in the site preview, given the `review` option. */
|
|
14
|
+
export function reviewFor(review, command) {
|
|
15
|
+
return command === "dev" && review !== false;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Builds one build's outputs, the site output by default. Rejects, with the compiler's report as the
|
|
5
19
|
* message, if the build has errors: the Astro build fails with them.
|
|
6
20
|
*/
|
|
7
21
|
export function runBuild(options) {
|
|
8
22
|
const args = [
|
|
9
23
|
"build",
|
|
10
24
|
"--emit",
|
|
11
|
-
"site",
|
|
25
|
+
(options.outputs ?? ["site"]).join(","),
|
|
12
26
|
"--build",
|
|
13
27
|
options.build,
|
|
14
28
|
"--config",
|
|
@@ -16,6 +30,8 @@ export function runBuild(options) {
|
|
|
16
30
|
"--color",
|
|
17
31
|
"never",
|
|
18
32
|
];
|
|
33
|
+
if (options.anchors === true)
|
|
34
|
+
args.push("--anchors");
|
|
19
35
|
return new Promise((resolve, reject) => {
|
|
20
36
|
execFile(options.binary, args, { cwd: options.cwd, maxBuffer: 64 * 1024 * 1024 }, (error, stdout, stderr) => {
|
|
21
37
|
if (error !== null) {
|
package/dist/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,sCAAsC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAU9C;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CACxB,OAAoC,EACpC,OAAe,EACf,MAAM,GAAG,KAAK;IAEd,OAAO,OAAO,KAAK,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,IAAI,CAAC,OAAO,KAAK,KAAK,IAAI,MAAM,CAAC,CAAC,CAAC;AAClF,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,SAAS,CAAC,MAA2B,EAAE,OAAe;IACpE,OAAO,OAAO,KAAK,KAAK,IAAI,MAAM,KAAK,KAAK,CAAC;AAC/C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,OASxB;IACC,MAAM,IAAI,GAAG;QACX,OAAO;QACP,QAAQ;QACR,CAAC,OAAO,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QACvC,SAAS;QACT,OAAO,CAAC,KAAK;QACb,UAAU;QACV,OAAO,CAAC,UAAU;QAClB,SAAS;QACT,OAAO;KACR,CAAC;IACF,IAAI,OAAO,CAAC,OAAO,KAAK,IAAI;QAAE,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACrD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,QAAQ,CACN,OAAO,CAAC,MAAM,EACd,IAAI,EACJ,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI,EAAE,EACjD,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;YACxB,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBACnB,MAAM,MAAM,GAAG,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;gBAC3C,MAAM,CACJ,IAAI,KAAK,CACP,2BAA2B,OAAO,CAAC,KAAK,YAAY,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,MAAM,EAAE,EAAE,EAC3G,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CACF,CAAC;gBACF,OAAO;YACT,CAAC;YACD,OAAO,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAClE,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/satteri.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HastVisitorInstance } from "satteri";
|
|
2
|
-
/** Applies the site output's attribute markers (`ascribe-attributes`). */
|
|
2
|
+
/** Applies the site output's attribute markers (`ascribe-attributes`) and source anchors. */
|
|
3
3
|
export declare function satteriAscribeAttributes(): HastVisitorInstance & {
|
|
4
4
|
name: string;
|
|
5
5
|
};
|
package/dist/satteri.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
// The attribute marker as a Sätteri hast plugin, for Astro
|
|
2
|
-
// markdown processor (`@astrojs/markdown-satteri`).
|
|
1
|
+
// The attribute marker and source anchors as a Sätteri hast plugin, for Astro
|
|
2
|
+
// 7.3's default markdown processor (`@astrojs/markdown-satteri`).
|
|
3
3
|
//
|
|
4
4
|
// Astro runs that processor's hast plugins in this order: highlighting, the
|
|
5
5
|
// user's plugins, its image marker (which reads an `<img>`'s properties), and
|
|
6
6
|
// its heading ids (which keeps an id a heading already has). A user plugin
|
|
7
7
|
// therefore runs before both, and sees a marker as two `raw` nodes, as the
|
|
8
|
-
// unified processor's plugin does
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
// unified processor's plugin does, and an anchor comment as a `raw` node. The
|
|
9
|
+
// rules are `findEdits`'s and `findAnchors`'s.
|
|
10
|
+
import { findAnchors, findEdits, toProperty } from "./attributes.js";
|
|
11
|
+
/** Applies the site output's attribute markers (`ascribe-attributes`) and source anchors. */
|
|
11
12
|
export function satteriAscribeAttributes() {
|
|
12
13
|
return {
|
|
13
14
|
name: "ascribe-attributes",
|
|
@@ -27,6 +28,22 @@ export function satteriAscribeAttributes() {
|
|
|
27
28
|
ctx.replaceNode(node, { type: "text", value });
|
|
28
29
|
}
|
|
29
30
|
}
|
|
31
|
+
for (const anchor of findAnchors(root)) {
|
|
32
|
+
for (const { node, attributes } of anchor.targets) {
|
|
33
|
+
for (const attribute of attributes) {
|
|
34
|
+
const [name, value] = toProperty(attribute);
|
|
35
|
+
ctx.setProperty(node, name, value);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (anchor.replace) {
|
|
39
|
+
ctx.replaceNode(anchor.replace.node, {
|
|
40
|
+
type: "raw",
|
|
41
|
+
value: anchor.replace.value,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
for (const node of anchor.remove)
|
|
45
|
+
ctx.removeNode(node);
|
|
46
|
+
}
|
|
30
47
|
},
|
|
31
48
|
};
|
|
32
49
|
}
|
package/dist/satteri.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"satteri.js","sourceRoot":"","sources":["../src/satteri.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"satteri.js","sourceRoot":"","sources":["../src/satteri.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,kEAAkE;AAClE,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,2EAA2E;AAC3E,2EAA2E;AAC3E,8EAA8E;AAC9E,+CAA+C;AAG/C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAiB,MAAM,iBAAiB,CAAC;AAEpF,6FAA6F;AAC7F,MAAM,UAAU,wBAAwB;IACtC,OAAO;QACL,IAAI,EAAE,oBAAoB;QAC1B,MAAM,CAAC,IAAI,EAAE,GAAG;YACd,KAAK,MAAM,IAAI,IAAI,SAAS,CAAC,IAAgB,CAAC,EAAE,CAAC;gBAC/C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAgC,CAAC;gBACrD,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;oBACxC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;oBAC5C,GAAG,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;gBACvC,CAAC;gBACD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM;oBAAE,GAAG,CAAC,UAAU,CAAC,IAA8B,CAAC,CAAC;gBAC/E,KAAK,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;oBACxC,IAAI,KAAK,KAAK,EAAE;wBAAE,GAAG,CAAC,UAAU,CAAC,IAA8B,CAAC,CAAC;;wBAC5D,GAAG,CAAC,WAAW,CAAC,IAA8B,EAAE,EAAE,IAAI,EAAE,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