@astrojs/compiler 1.4.2 → 1.5.1

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 (53) hide show
  1. package/{astro.wasm → dist/astro.wasm} +0 -0
  2. package/dist/browser/index.cjs +2 -0
  3. package/dist/browser/index.d.ts +11 -0
  4. package/dist/browser/index.js +1 -0
  5. package/dist/browser/utils.cjs +3 -0
  6. package/{browser → dist/browser}/utils.d.ts +10 -7
  7. package/dist/browser/utils.js +3 -0
  8. package/dist/browser/wasm_exec.cjs +2 -0
  9. package/{node → dist/browser}/wasm_exec.d.ts +3 -1
  10. package/dist/browser/wasm_exec.js +1 -0
  11. package/dist/chunk-GFDH6LQW.js +1 -0
  12. package/dist/chunk-XZNZIE5X.js +2 -0
  13. package/dist/node/index.cjs +1 -0
  14. package/dist/node/index.d.ts +12 -0
  15. package/dist/node/index.js +1 -0
  16. package/dist/node/sync.cjs +1 -0
  17. package/dist/node/sync.d.ts +16 -0
  18. package/dist/node/sync.js +1 -0
  19. package/dist/node/utils.cjs +3 -0
  20. package/{node → dist/node}/utils.d.ts +10 -7
  21. package/dist/node/utils.js +3 -0
  22. package/dist/node/wasm_exec.cjs +1 -0
  23. package/{browser → dist/node}/wasm_exec.d.ts +3 -1
  24. package/dist/node/wasm_exec.js +1 -0
  25. package/dist/shared/ast.cjs +1 -0
  26. package/dist/shared/ast.d.ts +73 -0
  27. package/dist/shared/ast.js +0 -0
  28. package/dist/shared/diagnostics.cjs +1 -0
  29. package/{shared → dist/shared}/diagnostics.d.ts +3 -1
  30. package/dist/shared/diagnostics.js +1 -0
  31. package/dist/shared/types.cjs +1 -0
  32. package/{shared → dist/shared}/types.d.ts +26 -24
  33. package/dist/shared/types.js +1 -0
  34. package/package.json +29 -15
  35. package/sync.d.ts +1 -1
  36. package/types.d.ts +1 -1
  37. package/utils.d.ts +1 -1
  38. package/CHANGELOG.md +0 -1284
  39. package/browser/index.d.ts +0 -6
  40. package/browser/index.js +0 -67
  41. package/browser/utils.js +0 -116
  42. package/browser/wasm_exec.js +0 -559
  43. package/node/index.d.ts +0 -7
  44. package/node/index.js +0 -75
  45. package/node/sync.cjs +0 -542
  46. package/node/sync.cts +0 -72
  47. package/node/sync.d.cts +0 -12
  48. package/node/utils.js +0 -116
  49. package/node/wasm_exec.js +0 -453
  50. package/shared/ast.d.ts +0 -71
  51. package/shared/ast.js +0 -1
  52. package/shared/diagnostics.js +0 -1
  53. package/shared/types.js +0 -10
package/node/utils.js DELETED
@@ -1,116 +0,0 @@
1
- function guard(type) {
2
- return (node) => node.type === type;
3
- }
4
- export const is = {
5
- parent(node) {
6
- return Array.isArray(node.children);
7
- },
8
- literal(node) {
9
- return typeof node.value === 'string';
10
- },
11
- tag(node) {
12
- return node.type === 'element' || node.type === 'custom-element' || node.type === 'component' || node.type === 'fragment';
13
- },
14
- whitespace(node) {
15
- return node.type === 'text' && node.value.trim().length === 0;
16
- },
17
- root: guard('root'),
18
- element: guard('element'),
19
- customElement: guard('custom-element'),
20
- component: guard('component'),
21
- fragment: guard('fragment'),
22
- expression: guard('expression'),
23
- text: guard('text'),
24
- doctype: guard('doctype'),
25
- comment: guard('comment'),
26
- frontmatter: guard('frontmatter'),
27
- };
28
- class Walker {
29
- constructor(callback) {
30
- this.callback = callback;
31
- }
32
- async visit(node, parent, index) {
33
- await this.callback(node, parent, index);
34
- if (is.parent(node)) {
35
- let promises = [];
36
- for (let i = 0; i < node.children.length; i++) {
37
- const child = node.children[i];
38
- promises.push(this.callback(child, node, i));
39
- }
40
- await Promise.all(promises);
41
- }
42
- }
43
- }
44
- export function walk(node, callback) {
45
- const walker = new Walker(callback);
46
- walker.visit(node);
47
- }
48
- function serializeAttributes(node) {
49
- let output = '';
50
- for (const attr of node.attributes) {
51
- output += ' ';
52
- switch (attr.kind) {
53
- case 'empty': {
54
- output += `${attr.name}`;
55
- break;
56
- }
57
- case 'expression': {
58
- output += `${attr.name}={${attr.value}}`;
59
- break;
60
- }
61
- case 'quoted': {
62
- output += `${attr.name}="${attr.value}"`;
63
- break;
64
- }
65
- case 'template-literal': {
66
- output += `${attr.name}=\`${attr.value}\``;
67
- break;
68
- }
69
- case 'shorthand': {
70
- output += `{${attr.name}}`;
71
- break;
72
- }
73
- case 'spread': {
74
- output += `{...${attr.name}}`;
75
- break;
76
- }
77
- }
78
- }
79
- return output;
80
- }
81
- export function serialize(root, opts = { selfClose: true }) {
82
- let output = '';
83
- function visitor(node) {
84
- if (is.root(node)) {
85
- node.children.forEach((child) => visitor(child));
86
- }
87
- else if (is.frontmatter(node)) {
88
- output += `---${node.value}---\n\n`;
89
- }
90
- else if (is.comment(node)) {
91
- output += `<!--${node.value}-->`;
92
- }
93
- else if (is.expression(node)) {
94
- output += `{`;
95
- node.children.forEach((child) => visitor(child));
96
- output += `}`;
97
- }
98
- else if (is.literal(node)) {
99
- output += node.value;
100
- }
101
- else if (is.tag(node)) {
102
- output += `<${node.name}`;
103
- output += serializeAttributes(node);
104
- if (node.children.length == 0 && opts.selfClose) {
105
- output += ` />`;
106
- }
107
- else {
108
- output += '>';
109
- node.children.forEach((child) => visitor(child));
110
- output += `</${node.name}>`;
111
- }
112
- }
113
- }
114
- visitor(root);
115
- return output;
116
- }
package/node/wasm_exec.js DELETED
@@ -1,453 +0,0 @@
1
- /* eslint-disable */
2
- // @ts-nocheck
3
- // Copyright 2018 The Go Authors. All rights reserved.
4
- // Use of this source code is governed by a BSD-style
5
- // license that can be found in the LICENSE file.
6
- //
7
- // This file has been modified for use by Astro.
8
- import fs from 'fs';
9
- import crypto from 'crypto';
10
- import { TextEncoder, TextDecoder } from 'util';
11
- if (!globalThis.fs) {
12
- Object.defineProperty(globalThis, 'fs', {
13
- value: fs,
14
- });
15
- }
16
- if (!globalThis.process) {
17
- Object.defineProperties(globalThis, 'process', {
18
- value: process,
19
- });
20
- }
21
- if (!globalThis.crypto) {
22
- Object.defineProperty(globalThis, 'crypto', {
23
- value: crypto.webcrypto
24
- ? crypto.webcrypto
25
- : {
26
- getRandomValues(b) {
27
- return crypto.randomFillSync(b);
28
- },
29
- },
30
- });
31
- }
32
- if (!globalThis.performance) {
33
- Object.defineProperty(globalThis, 'performance', {
34
- value: {
35
- now() {
36
- const [sec, nsec] = process.hrtime();
37
- return sec * 1000 + nsec / 1000000;
38
- },
39
- },
40
- });
41
- }
42
- // End of polyfills for common API.
43
- const encoder = new TextEncoder('utf-8');
44
- const decoder = new TextDecoder('utf-8');
45
- var logLine = [];
46
- export default class Go {
47
- constructor() {
48
- this.argv = ['js'];
49
- this.env = {};
50
- this.exit = (code) => {
51
- if (code !== 0) {
52
- console.warn('exit code:', code);
53
- }
54
- };
55
- this._exitPromise = new Promise((resolve) => {
56
- this._resolveExitPromise = resolve;
57
- });
58
- this._pendingEvent = null;
59
- this._scheduledTimeouts = new Map();
60
- this._nextCallbackTimeoutID = 1;
61
- const setInt64 = (addr, v) => {
62
- this.mem.setUint32(addr + 0, v, true);
63
- this.mem.setUint32(addr + 4, Math.floor(v / 4294967296), true);
64
- };
65
- const getInt64 = (addr) => {
66
- const low = this.mem.getUint32(addr + 0, true);
67
- const high = this.mem.getInt32(addr + 4, true);
68
- return low + high * 4294967296;
69
- };
70
- const loadValue = (addr) => {
71
- const f = this.mem.getFloat64(addr, true);
72
- if (f === 0) {
73
- return undefined;
74
- }
75
- if (!isNaN(f)) {
76
- return f;
77
- }
78
- const id = this.mem.getUint32(addr, true);
79
- return this._values[id];
80
- };
81
- const storeValue = (addr, v) => {
82
- const nanHead = 0x7ff80000;
83
- if (typeof v === 'number' && v !== 0) {
84
- if (isNaN(v)) {
85
- this.mem.setUint32(addr + 4, nanHead, true);
86
- this.mem.setUint32(addr, 0, true);
87
- return;
88
- }
89
- this.mem.setFloat64(addr, v, true);
90
- return;
91
- }
92
- if (v === undefined) {
93
- this.mem.setFloat64(addr, 0, true);
94
- return;
95
- }
96
- let id = this._ids.get(v);
97
- if (id === undefined) {
98
- id = this._idPool.pop();
99
- if (id === undefined) {
100
- id = this._values.length;
101
- }
102
- this._values[id] = v;
103
- this._goRefCounts[id] = 0;
104
- this._ids.set(v, id);
105
- }
106
- this._goRefCounts[id]++;
107
- let typeFlag = 0;
108
- switch (typeof v) {
109
- case 'object':
110
- if (v !== null) {
111
- typeFlag = 1;
112
- }
113
- break;
114
- case 'string':
115
- typeFlag = 2;
116
- break;
117
- case 'symbol':
118
- typeFlag = 3;
119
- break;
120
- case 'function':
121
- typeFlag = 4;
122
- break;
123
- }
124
- this.mem.setUint32(addr + 4, nanHead | typeFlag, true);
125
- this.mem.setUint32(addr, id, true);
126
- };
127
- const loadSlice = (addr) => {
128
- const array = getInt64(addr + 0);
129
- const len = getInt64(addr + 8);
130
- return new Uint8Array(this._inst.exports.mem.buffer, array, len);
131
- };
132
- const loadSliceOfValues = (addr) => {
133
- const array = getInt64(addr + 0);
134
- const len = getInt64(addr + 8);
135
- const a = new Array(len);
136
- for (let i = 0; i < len; i++) {
137
- a[i] = loadValue(array + i * 8);
138
- }
139
- return a;
140
- };
141
- const loadString = (addr) => {
142
- const saddr = getInt64(addr + 0);
143
- const len = getInt64(addr + 8);
144
- return decoder.decode(new DataView(this._inst.exports.mem.buffer, saddr, len));
145
- };
146
- const timeOrigin = Date.now() - performance.now();
147
- this.importObject = {
148
- go: {
149
- // Go's SP does not change as long as no Go code is running. Some operations (e.g. calls, getters and setters)
150
- // may synchronously trigger a Go event handler. This makes Go code get executed in the middle of the imported
151
- // function. A goroutine can switch to a new stack if the current stack is too small (see morestack function).
152
- // This changes the SP, thus we have to update the SP used by the imported function.
153
- // func wasmExit(code int32)
154
- 'runtime.wasmExit': (sp) => {
155
- sp >>>= 0;
156
- const code = this.mem.getInt32(sp + 8, true);
157
- this.exited = true;
158
- delete this._inst;
159
- delete this._values;
160
- delete this._goRefCounts;
161
- delete this._ids;
162
- delete this._idPool;
163
- this.exit(code);
164
- },
165
- // func wasmWrite(fd uintptr, p unsafe.Pointer, n int32)
166
- 'runtime.wasmWrite': (sp) => {
167
- sp >>>= 0;
168
- const fd = getInt64(sp + 8);
169
- const p = getInt64(sp + 16);
170
- const n = this.mem.getInt32(sp + 24, true);
171
- fs.writeSync(fd, new Uint8Array(this._inst.exports.mem.buffer, p, n));
172
- },
173
- // func resetMemoryDataView()
174
- 'runtime.resetMemoryDataView': (sp) => {
175
- sp >>>= 0;
176
- this.mem = new DataView(this._inst.exports.mem.buffer);
177
- },
178
- // func nanotime1() int64
179
- 'runtime.nanotime1': (sp) => {
180
- sp >>>= 0;
181
- setInt64(sp + 8, (timeOrigin + performance.now()) * 1000000);
182
- },
183
- // func walltime() (sec int64, nsec int32)
184
- 'runtime.walltime': (sp) => {
185
- sp >>>= 0;
186
- const msec = new Date().getTime();
187
- setInt64(sp + 8, msec / 1000);
188
- this.mem.setInt32(sp + 16, (msec % 1000) * 1000000, true);
189
- },
190
- // func scheduleTimeoutEvent(delay int64) int32
191
- 'runtime.scheduleTimeoutEvent': (sp) => {
192
- sp >>>= 0;
193
- const id = this._nextCallbackTimeoutID;
194
- this._nextCallbackTimeoutID++;
195
- this._scheduledTimeouts.set(id, setTimeout(() => {
196
- this._resume();
197
- while (this._scheduledTimeouts.has(id)) {
198
- // for some reason Go failed to register the timeout event, log and try again
199
- // (temporary workaround for https://github.com/golang/go/issues/28975)
200
- console.warn('scheduleTimeoutEvent: missed timeout event');
201
- this._resume();
202
- }
203
- }, getInt64(sp + 8) + 1 // setTimeout has been seen to fire up to 1 millisecond early
204
- ));
205
- this.mem.setInt32(sp + 16, id, true);
206
- },
207
- // func clearTimeoutEvent(id int32)
208
- 'runtime.clearTimeoutEvent': (sp) => {
209
- sp >>>= 0;
210
- const id = this.mem.getInt32(sp + 8, true);
211
- clearTimeout(this._scheduledTimeouts.get(id));
212
- this._scheduledTimeouts.delete(id);
213
- },
214
- // func getRandomData(r []byte)
215
- 'runtime.getRandomData': (sp) => {
216
- sp >>>= 0;
217
- globalThis.crypto.getRandomValues(loadSlice(sp + 8));
218
- },
219
- // func finalizeRef(v ref)
220
- 'syscall/js.finalizeRef': (sp) => {
221
- sp >>>= 0;
222
- const id = this.mem.getUint32(sp + 8, true);
223
- this._goRefCounts[id]--;
224
- if (this._goRefCounts[id] === 0) {
225
- const v = this._values[id];
226
- this._values[id] = null;
227
- this._ids.delete(v);
228
- this._idPool.push(id);
229
- }
230
- },
231
- // func stringVal(value string) ref
232
- 'syscall/js.stringVal': (sp) => {
233
- sp >>>= 0;
234
- storeValue(sp + 24, loadString(sp + 8));
235
- },
236
- // func valueGet(v ref, p string) ref
237
- 'syscall/js.valueGet': (sp) => {
238
- sp >>>= 0;
239
- const result = Reflect.get(loadValue(sp + 8), loadString(sp + 16));
240
- sp = this._inst.exports.getsp() >>> 0; // see comment above
241
- storeValue(sp + 32, result);
242
- },
243
- // func valueSet(v ref, p string, x ref)
244
- 'syscall/js.valueSet': (sp) => {
245
- sp >>>= 0;
246
- Reflect.set(loadValue(sp + 8), loadString(sp + 16), loadValue(sp + 32));
247
- },
248
- // func valueDelete(v ref, p string)
249
- 'syscall/js.valueDelete': (sp) => {
250
- sp >>>= 0;
251
- Reflect.deleteProperty(loadValue(sp + 8), loadString(sp + 16));
252
- },
253
- // func valueIndex(v ref, i int) ref
254
- 'syscall/js.valueIndex': (sp) => {
255
- sp >>>= 0;
256
- storeValue(sp + 24, Reflect.get(loadValue(sp + 8), getInt64(sp + 16)));
257
- },
258
- // valueSetIndex(v ref, i int, x ref)
259
- 'syscall/js.valueSetIndex': (sp) => {
260
- sp >>>= 0;
261
- Reflect.set(loadValue(sp + 8), getInt64(sp + 16), loadValue(sp + 24));
262
- },
263
- // func valueCall(v ref, m string, args []ref) (ref, bool)
264
- 'syscall/js.valueCall': (sp) => {
265
- sp >>>= 0;
266
- try {
267
- const v = loadValue(sp + 8);
268
- const m = Reflect.get(v, loadString(sp + 16));
269
- const args = loadSliceOfValues(sp + 32);
270
- const result = Reflect.apply(m, v, args);
271
- sp = this._inst.exports.getsp() >>> 0; // see comment above
272
- storeValue(sp + 56, result);
273
- this.mem.setUint8(sp + 64, 1);
274
- }
275
- catch (err) {
276
- sp = this._inst.exports.getsp() >>> 0; // see comment above
277
- storeValue(sp + 56, err);
278
- this.mem.setUint8(sp + 64, 0);
279
- }
280
- },
281
- // func valueInvoke(v ref, args []ref) (ref, bool)
282
- 'syscall/js.valueInvoke': (sp) => {
283
- sp >>>= 0;
284
- try {
285
- const v = loadValue(sp + 8);
286
- const args = loadSliceOfValues(sp + 16);
287
- const result = Reflect.apply(v, undefined, args);
288
- sp = this._inst.exports.getsp() >>> 0; // see comment above
289
- storeValue(sp + 40, result);
290
- this.mem.setUint8(sp + 48, 1);
291
- }
292
- catch (err) {
293
- sp = this._inst.exports.getsp() >>> 0; // see comment above
294
- storeValue(sp + 40, err);
295
- this.mem.setUint8(sp + 48, 0);
296
- }
297
- },
298
- // func valueNew(v ref, args []ref) (ref, bool)
299
- 'syscall/js.valueNew': (sp) => {
300
- sp >>>= 0;
301
- try {
302
- const v = loadValue(sp + 8);
303
- const args = loadSliceOfValues(sp + 16);
304
- const result = Reflect.construct(v, args);
305
- sp = this._inst.exports.getsp() >>> 0; // see comment above
306
- storeValue(sp + 40, result);
307
- this.mem.setUint8(sp + 48, 1);
308
- }
309
- catch (err) {
310
- sp = this._inst.exports.getsp() >>> 0; // see comment above
311
- storeValue(sp + 40, err);
312
- this.mem.setUint8(sp + 48, 0);
313
- }
314
- },
315
- // func valueLength(v ref) int
316
- 'syscall/js.valueLength': (sp) => {
317
- sp >>>= 0;
318
- setInt64(sp + 16, parseInt(loadValue(sp + 8).length));
319
- },
320
- // valuePrepareString(v ref) (ref, int)
321
- 'syscall/js.valuePrepareString': (sp) => {
322
- sp >>>= 0;
323
- const str = encoder.encode(String(loadValue(sp + 8)));
324
- storeValue(sp + 16, str);
325
- setInt64(sp + 24, str.length);
326
- },
327
- // valueLoadString(v ref, b []byte)
328
- 'syscall/js.valueLoadString': (sp) => {
329
- sp >>>= 0;
330
- const str = loadValue(sp + 8);
331
- loadSlice(sp + 16).set(str);
332
- },
333
- // func valueInstanceOf(v ref, t ref) bool
334
- 'syscall/js.valueInstanceOf': (sp) => {
335
- sp >>>= 0;
336
- this.mem.setUint8(sp + 24, loadValue(sp + 8) instanceof loadValue(sp + 16) ? 1 : 0);
337
- },
338
- // func copyBytesToGo(dst []byte, src ref) (int, bool)
339
- 'syscall/js.copyBytesToGo': (sp) => {
340
- sp >>>= 0;
341
- const dst = loadSlice(sp + 8);
342
- const src = loadValue(sp + 32);
343
- if (!(src instanceof Uint8Array || src instanceof Uint8ClampedArray)) {
344
- this.mem.setUint8(sp + 48, 0);
345
- return;
346
- }
347
- const toCopy = src.subarray(0, dst.length);
348
- dst.set(toCopy);
349
- setInt64(sp + 40, toCopy.length);
350
- this.mem.setUint8(sp + 48, 1);
351
- },
352
- // func copyBytesToJS(dst ref, src []byte) (int, bool)
353
- 'syscall/js.copyBytesToJS': (sp) => {
354
- sp >>>= 0;
355
- const dst = loadValue(sp + 8);
356
- const src = loadSlice(sp + 16);
357
- if (!(dst instanceof Uint8Array || dst instanceof Uint8ClampedArray)) {
358
- this.mem.setUint8(sp + 48, 0);
359
- return;
360
- }
361
- const toCopy = src.subarray(0, dst.length);
362
- dst.set(toCopy);
363
- setInt64(sp + 40, toCopy.length);
364
- this.mem.setUint8(sp + 48, 1);
365
- },
366
- debug: (value) => {
367
- console.log(value);
368
- },
369
- },
370
- };
371
- }
372
- async run(instance) {
373
- if (!(instance instanceof WebAssembly.Instance)) {
374
- throw new Error('Go.run: WebAssembly.Instance expected');
375
- }
376
- this._inst = instance;
377
- this.mem = new DataView(this._inst.exports.mem.buffer);
378
- this._values = [
379
- // JS values that Go currently has references to, indexed by reference id
380
- NaN,
381
- 0,
382
- null,
383
- true,
384
- false,
385
- globalThis,
386
- this,
387
- ];
388
- this._goRefCounts = new Array(this._values.length).fill(Infinity); // number of references that Go has to a JS value, indexed by reference id
389
- this._ids = new Map([
390
- // mapping from JS values to reference ids
391
- [0, 1],
392
- [null, 2],
393
- [true, 3],
394
- [false, 4],
395
- [globalThis, 5],
396
- [this, 6],
397
- ]);
398
- this._idPool = []; // unused ids that have been garbage collected
399
- this.exited = false; // whether the Go program has exited
400
- // Pass command line arguments and environment variables to WebAssembly by writing them to the linear memory.
401
- let offset = 4096;
402
- const strPtr = (str) => {
403
- const ptr = offset;
404
- const bytes = encoder.encode(str + '\0');
405
- new Uint8Array(this.mem.buffer, offset, bytes.length).set(bytes);
406
- offset += bytes.length;
407
- if (offset % 8 !== 0) {
408
- offset += 8 - (offset % 8);
409
- }
410
- return ptr;
411
- };
412
- const argc = this.argv.length;
413
- const argvPtrs = [];
414
- this.argv.forEach((arg) => {
415
- argvPtrs.push(strPtr(arg));
416
- });
417
- argvPtrs.push(0);
418
- const keys = Object.keys(this.env).sort();
419
- keys.forEach((key) => {
420
- argvPtrs.push(strPtr(`${key}=${this.env[key]}`));
421
- });
422
- argvPtrs.push(0);
423
- const argv = offset;
424
- argvPtrs.forEach((ptr) => {
425
- this.mem.setUint32(offset, ptr, true);
426
- this.mem.setUint32(offset + 4, 0, true);
427
- offset += 8;
428
- });
429
- this._inst.exports.run(argc, argv);
430
- if (this.exited) {
431
- this._resolveExitPromise();
432
- }
433
- await this._exitPromise;
434
- }
435
- _resume() {
436
- if (this.exited) {
437
- throw new Error('Go program has already exited');
438
- }
439
- this._inst.exports.resume();
440
- if (this.exited) {
441
- this._resolveExitPromise();
442
- }
443
- }
444
- _makeFuncWrapper(id) {
445
- const go = this;
446
- return function () {
447
- const event = { id: id, this: this, args: arguments };
448
- go._pendingEvent = event;
449
- go._resume();
450
- return event.result;
451
- };
452
- }
453
- }
package/shared/ast.d.ts DELETED
@@ -1,71 +0,0 @@
1
- export type ParentNode = RootNode | ElementNode | ComponentNode | CustomElementNode | FragmentNode | ExpressionNode;
2
- export type LiteralNode = TextNode | DoctypeNode | CommentNode | FrontmatterNode;
3
- export type Node = RootNode | ElementNode | ComponentNode | CustomElementNode | FragmentNode | ExpressionNode | TextNode | FrontmatterNode | DoctypeNode | CommentNode;
4
- export interface Position {
5
- start: Point;
6
- end?: Point;
7
- }
8
- export interface Point {
9
- /** 1-based line number */
10
- line: number;
11
- /** 1-based column number, per-line */
12
- column: number;
13
- /** 0-based byte offset */
14
- offset: number;
15
- }
16
- export interface BaseNode {
17
- type: string;
18
- position?: Position;
19
- }
20
- export interface ParentLikeNode extends BaseNode {
21
- type: 'element' | 'component' | 'custom-element' | 'fragment' | 'expression' | 'root';
22
- children: Node[];
23
- }
24
- export interface ValueNode extends BaseNode {
25
- value: string;
26
- }
27
- export interface RootNode extends ParentLikeNode {
28
- type: 'root';
29
- }
30
- export interface AttributeNode extends BaseNode {
31
- type: 'attribute';
32
- kind: 'quoted' | 'empty' | 'expression' | 'spread' | 'shorthand' | 'template-literal';
33
- name: string;
34
- value: string;
35
- }
36
- export interface TextNode extends ValueNode {
37
- type: 'text';
38
- }
39
- export interface ElementNode extends ParentLikeNode {
40
- type: 'element';
41
- name: string;
42
- attributes: AttributeNode[];
43
- }
44
- export interface FragmentNode extends ParentLikeNode {
45
- type: 'fragment';
46
- name: string;
47
- attributes: AttributeNode[];
48
- }
49
- export interface ComponentNode extends ParentLikeNode {
50
- type: 'component';
51
- name: string;
52
- attributes: AttributeNode[];
53
- }
54
- export interface CustomElementNode extends ParentLikeNode {
55
- type: 'custom-element';
56
- name: string;
57
- attributes: AttributeNode[];
58
- }
59
- export type TagLikeNode = ElementNode | FragmentNode | ComponentNode | CustomElementNode;
60
- export interface DoctypeNode extends ValueNode {
61
- type: 'doctype';
62
- }
63
- export interface CommentNode extends ValueNode {
64
- type: 'comment';
65
- }
66
- export interface FrontmatterNode extends ValueNode {
67
- type: 'frontmatter';
68
- }
69
- export interface ExpressionNode extends ParentLikeNode {
70
- type: 'expression';
71
- }
package/shared/ast.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
package/shared/types.js DELETED
@@ -1,10 +0,0 @@
1
- export * from './ast';
2
- export * from './diagnostics';
3
- // eslint-disable-next-line no-shadow
4
- export var DiagnosticSeverity;
5
- (function (DiagnosticSeverity) {
6
- DiagnosticSeverity[DiagnosticSeverity["Error"] = 1] = "Error";
7
- DiagnosticSeverity[DiagnosticSeverity["Warning"] = 2] = "Warning";
8
- DiagnosticSeverity[DiagnosticSeverity["Information"] = 3] = "Information";
9
- DiagnosticSeverity[DiagnosticSeverity["Hint"] = 4] = "Hint";
10
- })(DiagnosticSeverity || (DiagnosticSeverity = {}));