@astrojs/compiler 0.0.0-win-20221104182032

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.
@@ -0,0 +1,71 @@
1
+ export declare type ParentNode = RootNode | ElementNode | ComponentNode | CustomElementNode | FragmentNode | ExpressionNode;
2
+ export declare type LiteralNode = TextNode | DoctypeNode | CommentNode | FrontmatterNode;
3
+ export declare 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 declare 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 ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ export declare const enum DiagnosticCode {
2
+ ERROR = 1000,
3
+ ERROR_UNTERMINATED_JS_COMMENT = 1001,
4
+ ERROR_FRAGMENT_SHORTHAND_ATTRS = 1002,
5
+ ERROR_UNMATCHED_IMPORT = 1003,
6
+ ERROR_UNSUPPORTED_SLOT_ATTRIBUTE = 1004,
7
+ WARNING = 2000,
8
+ WARNING_UNTERMINATED_HTML_COMMENT = 2001,
9
+ WARNING_UNCLOSED_HTML_TAG = 2002,
10
+ WARNING_DEPRECATED_DIRECTIVE = 2003,
11
+ WARNING_IGNORED_DIRECTIVE = 2004,
12
+ WARNING_UNSUPPORTED_EXPRESSION = 2005,
13
+ WARNING_SET_WITH_CHILDREN = 2006,
14
+ INFO = 3000,
15
+ HINT = 4000
16
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,102 @@
1
+ import { RootNode } from './ast';
2
+ import { DiagnosticCode } from './diagnostics';
3
+ export * from './ast';
4
+ export * from './diagnostics';
5
+ export interface PreprocessorResult {
6
+ code: string;
7
+ map?: string;
8
+ }
9
+ export interface PreprocessorError {
10
+ error: string;
11
+ }
12
+ export interface ParseOptions {
13
+ position?: boolean;
14
+ }
15
+ export declare enum DiagnosticSeverity {
16
+ Error = 1,
17
+ Warning = 2,
18
+ Information = 3,
19
+ Hint = 4
20
+ }
21
+ export interface DiagnosticMessage {
22
+ severity: DiagnosticSeverity;
23
+ code: DiagnosticCode;
24
+ location: DiagnosticLocation;
25
+ hint?: string;
26
+ text: string;
27
+ }
28
+ export interface DiagnosticLocation {
29
+ file: string;
30
+ line: number;
31
+ column: number;
32
+ length: number;
33
+ }
34
+ export interface TransformOptions {
35
+ internalURL?: string;
36
+ site?: string;
37
+ sourcefile?: string;
38
+ pathname?: string;
39
+ moduleId?: string;
40
+ sourcemap?: boolean | 'inline' | 'external' | 'both';
41
+ compact?: boolean;
42
+ /**
43
+ * @deprecated "as" has been removed and no longer has any effect!
44
+ */
45
+ as?: 'document' | 'fragment';
46
+ projectRoot?: string;
47
+ resolvePath?: (specifier: string) => Promise<string>;
48
+ preprocessStyle?: (content: string, attrs: Record<string, string>) => null | Promise<PreprocessorResult | PreprocessorError>;
49
+ experimentalStaticExtraction?: boolean;
50
+ }
51
+ export declare type HoistedScript = {
52
+ type: string;
53
+ } & ({
54
+ type: 'external';
55
+ src: string;
56
+ } | {
57
+ type: 'inline';
58
+ code: string;
59
+ map: string;
60
+ });
61
+ export interface HydratedComponent {
62
+ exportName: string;
63
+ specifier: string;
64
+ resolvedPath: string;
65
+ }
66
+ export interface TransformResult {
67
+ code: string;
68
+ map: string;
69
+ scope: string;
70
+ styleError: string[];
71
+ diagnostics: DiagnosticMessage[];
72
+ css: string[];
73
+ scripts: HoistedScript[];
74
+ hydratedComponents: HydratedComponent[];
75
+ clientOnlyComponents: HydratedComponent[];
76
+ }
77
+ export interface SourceMap {
78
+ file: string;
79
+ mappings: string;
80
+ names: string[];
81
+ sources: string[];
82
+ sourcesContent: string[];
83
+ version: number;
84
+ }
85
+ export interface TSXResult {
86
+ code: string;
87
+ map: SourceMap;
88
+ diagnostics: DiagnosticMessage[];
89
+ }
90
+ export interface ParseResult {
91
+ ast: RootNode;
92
+ diagnostics: DiagnosticMessage[];
93
+ }
94
+ export declare function transform(input: string, options?: TransformOptions): Promise<TransformResult>;
95
+ export declare function parse(input: string, options?: ParseOptions): Promise<ParseResult>;
96
+ export declare function convertToTSX(input: string, options?: {
97
+ sourcefile?: string;
98
+ }): Promise<TSXResult>;
99
+ export declare function initialize(options: InitializeOptions): Promise<void>;
100
+ export interface InitializeOptions {
101
+ wasmURL?: string;
102
+ }
@@ -0,0 +1,10 @@
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 = {}));
package/sourcemap.mjs ADDED
@@ -0,0 +1,143 @@
1
+ import fs from 'fs/promises';
2
+ import { transform } from '@astrojs/compiler';
3
+
4
+ const fixture = `---
5
+ import CartItems from './CartItems.astro';
6
+
7
+ export interface Props {
8
+ greeting?: string;
9
+ }
10
+
11
+ const { greeting = "world" } = Astro.props;
12
+ ---
13
+
14
+ <section id="cart-drawer"
15
+ x-data="initCartDrawer"
16
+ @private-content-loaded.window="getData(event.detail.data)"
17
+ @toggle-cart.window="open=true;"
18
+ @keydown.window.escape="open=false"
19
+ >
20
+ <template x-if="cart && cart.summary_count">
21
+ <div role="dialog"
22
+ aria-labelledby="cart-drawer-title"
23
+ aria-modal="true"
24
+ @click.outside="open = false"
25
+ class="fixed inset-y-0 right-0 z-30 flex max-w-full">
26
+ <div class="backdrop"
27
+ x-show="open"
28
+ x-transition:enter="ease-in-out duration-500"
29
+ x-transition:enter-start="opacity-0"
30
+ x-transition:enter-end="opacity-100"
31
+ x-transition:leave="ease-in-out duration-500"
32
+ x-transition:leave-start="opacity-100"
33
+ x-transition:leave-end="opacity-0"
34
+ @click="open = false"
35
+ aria-label="Close panel">
36
+ </div>
37
+ <div class="relative w-screen max-w-md shadow-2xl"
38
+ x-show="open"
39
+ x-transition:enter="transform transition ease-in-out duration-500 sm:duration-700"
40
+ x-transition:enter-start="translate-x-full"
41
+ x-transition:enter-end="translate-x-0"
42
+ x-transition:leave="transform transition ease-in-out duration-500 sm:duration-700"
43
+ x-transition:leave-start="translate-x-0"
44
+ x-transition:leave-end="translate-x-full"
45
+ >
46
+ <div
47
+ x-show="open"
48
+ x-transition:enter="ease-in-out duration-500"
49
+ x-transition:enter-start="opacity-0"
50
+ x-transition:enter-end="opacity-100"
51
+ x-transition:leave="ease-in-out duration-500"
52
+ x-transition:leave-start="opacity-100"
53
+ x-transition:leave-end="opacity-0" class="absolute top-0 right-0 flex p-2 mt-2"
54
+ >
55
+ <button @click="open = false;" aria-label="Close panel"
56
+ class="p-2 text-gray-300 transition duration-150 ease-in-out hover:text-black">
57
+ <svg class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
58
+ <path stroke-linecap="round" stroke-linejoin="round"
59
+ stroke-width="2" d="M6 18L18 6M6 6l12 12">
60
+ </path>
61
+ </svg>
62
+ </button>
63
+ </div>
64
+ <div class="flex flex-col h-full py-6 space-y-6 bg-white shadow-xl">
65
+ <header class="px-4 sm:px-6">
66
+ <h2 id="cart-drawer-title" class="text-lg font-medium leading-7 text-gray-900">My Cart</h2>
67
+ </header>
68
+ <div class="relative grid gap-6 px-4 py-6 overflow-y-auto bg-white border-b
69
+ sm:gap-8 sm:px-6 border-container">
70
+ <template x-for="item in cartItems">
71
+
72
+
73
+ <!-- <CartItems/> -->
74
+ <div class="flex items-start p-3 -m-3 space-x-4 transition duration-150
75
+ ease-in-out rounded-lg hover:bg-gray-100">
76
+ <a :href="item.product_url" class="w-1/4">
77
+ <img
78
+ :src="item.product_image.src"
79
+ :width="item.product_image.width"
80
+ :height="item.product_image.height"
81
+ loading="lazy"
82
+ />
83
+ </a>
84
+ <div class="w-3/4 space-y-2">
85
+ <div>
86
+ <p class="text-xl">
87
+ <span x-html="item.qty"></span> x <span x-html="item.product_name"></span>
88
+ </p>
89
+ <p class="text-sm"><span x-html="item.product_sku"/></p>
90
+ </div>
91
+ <template x-for="option in item.options">
92
+ <div class="pt-2">
93
+ <p class="font-semibold" x-text="option.label + ':'"></p>
94
+ <p class="text-secondary" x-html="option.value"></p>
95
+ </div>
96
+ </template>
97
+ <p><span x-html="item.product_price"></span></p>
98
+ <div class="pt-4">
99
+ <a :href="item.configure_url"
100
+ x-show="item.product_type !== 'grouped'"
101
+ class="inline-flex p-2 mr-2 btn btn-primary">
102
+ <svg fill="none" viewBox="0 0 24 24" stroke="currentColor"
103
+ size="16" class="w-5 h-5">
104
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
105
+ d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536
106
+ 3.536L6.5 21.036H3v-3.572L16.732 3.732z">
107
+ </path>
108
+ </svg>
109
+ </a>
110
+ </div>
111
+ </div>
112
+ </div>
113
+
114
+
115
+
116
+ </template>
117
+ </div>
118
+ <div class="relative grid gap-6 px-4 py-6 bg-white sm:gap-8 sm:px-6">
119
+ <div class="w-full p-3 -m-3 space-x-4 transition duration-150 ease-in-out rounded-lg
120
+ hover:bg-gray-100">
121
+ <p>Subtotal: <span x-html="cart.subtotal"></span></p>
122
+ </div>
123
+ <div class="w-full p-3 -m-3 space-x-4 transition duration-150 ease-in-out rounded-lg hover:bg-gray-100">
124
+ <a @click.prevent.stop="$dispatch('toggle-authentication',
125
+ {url: 'checkout'});"
126
+ href="checkout"
127
+ class="inline-flex btn btn-primary">
128
+ Checkout
129
+ </a>
130
+ <span>or</span>
131
+ <a href="checkout/cart"
132
+ class="underline">
133
+ View and Edit Cart
134
+ </a>
135
+ </div>
136
+ </div>
137
+ </div>
138
+ </div>
139
+ </template>
140
+ </section>`;
141
+
142
+ const { code } = await transform(fixture, { sourcemap: 'inline', experimentalStaticExtraction: true, sourcefile: 'index.astro' });
143
+ await fs.writeFile(new URL('./sourcemap.astro.js', import.meta.url), code, 'utf8');
package/types.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './shared/types';
package/utils.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './node/utils';