UNPKG

svelte-parse

Version:

An increidbly relaxed svelte-parser

741 lines (740 loc) 15.5 kB
{ "type": "root", "children": [ { "type": "svelteScript", "tagName": "script", "properties": [], "selfClosing": false, "children": [ { "type": "text", "value": "\n\timport { beforeUpdate } from \"svelte\";\n\timport Summary from \"./Summary.svelte\";\n\n\tconst PAGE_SIZE = 20;\n\n\texport let page;\n\n\tlet items;\n\tlet offset;\n\n\t$: fetch(`https://node-hnapi.herokuapp.com/news?page=${page}`)\n\t\t.then(r => r.json())\n\t\t.then(data => {\n\t\t\titems = data;\n\t\t\toffset = PAGE_SIZE * (page - 1);\n\t\t\twindow.scrollTo(0, 0);\n\t\t});\n", "position": { "start": { "line": 1, "column": 9, "offset": 8 }, "end": { "line": 19, "column": 1, "offset": 350 } } } ], "position": { "start": { "line": 1, "column": 1, "offset": 0 }, "end": { "line": 19, "column": 10, "offset": 359 } } }, { "type": "text", "value": "\n\n", "position": { "start": { "line": 19, "column": 10, "offset": 359 }, "end": { "line": 21, "column": 1, "offset": 361 } } }, { "type": "svelteStyle", "tagName": "style", "properties": [], "selfClosing": false, "children": [ { "type": "text", "value": "\n\ta {\n\t\tpadding: 2em;\n\t\tdisplay: block;\n\t}\n\n\t.loading {\n\t\topacity: 0;\n\t\tanimation: 0.4s 0.8s forwards fade-in;\n\t}\n\n\t@keyframes fade-in {\n\t\tfrom { opacity: 0; }\n\t\tto { opacity: 1; }\n\t}\n", "position": { "start": { "line": 21, "column": 8, "offset": 368 }, "end": { "line": 36, "column": 1, "offset": 552 } } } ], "position": { "start": { "line": 21, "column": 1, "offset": 361 }, "end": { "line": 36, "column": 9, "offset": 560 } } }, { "type": "text", "value": "\n\n", "position": { "start": { "line": 36, "column": 9, "offset": 560 }, "end": { "line": 38, "column": 1, "offset": 562 } } }, { "type": "svelteBranchingBlock", "name": "if", "branches": [ { "type": "svelteBranch", "name": "if", "expression": { "type": "svelteExpression", "value": "items", "position": { "start": { "line": 38, "column": 6, "offset": 567 }, "end": { "line": 38, "column": 11, "offset": 572 } } }, "children": [ { "type": "text", "value": "\n\t", "position": { "start": { "line": 38, "column": 12, "offset": 573 }, "end": { "line": 39, "column": 2, "offset": 575 } } }, { "type": "svelteBranchingBlock", "name": "each", "branches": [ { "type": "svelteBranch", "name": "each", "expression": { "type": "svelteExpression", "value": "items as item, i", "position": { "start": { "line": 39, "column": 9, "offset": 582 }, "end": { "line": 39, "column": 25, "offset": 598 } } }, "children": [ { "type": "text", "value": "\n\t\t", "position": { "start": { "line": 39, "column": 26, "offset": 599 }, "end": { "line": 40, "column": 3, "offset": 602 } } }, { "type": "svelteComponent", "tagName": "Summary", "properties": [ { "type": "svelteProperty", "name": "item", "value": [ { "type": "svelteDynamicContent", "expression": { "type": "svelteExpression", "value": "item", "position": { "start": { "line": 40, "column": 13, "offset": 612 }, "end": { "line": 40, "column": 17, "offset": 616 } } }, "position": { "start": { "line": 40, "column": 12, "offset": 611 }, "end": { "line": 40, "column": 17, "offset": 616 } } } ], "modifiers": [], "shorthand": "expression", "position": { "start": { "line": 40, "column": 12, "offset": 611 }, "end": { "line": 40, "column": 17, "offset": 616 } } }, { "type": "svelteProperty", "name": "i", "value": [ { "type": "svelteDynamicContent", "expression": { "type": "svelteExpression", "value": "i", "position": { "start": { "line": 40, "column": 20, "offset": 619 }, "end": { "line": 40, "column": 21, "offset": 620 } } }, "position": { "start": { "line": 40, "column": 19, "offset": 618 }, "end": { "line": 40, "column": 21, "offset": 620 } } } ], "modifiers": [], "shorthand": "expression", "position": { "start": { "line": 40, "column": 19, "offset": 618 }, "end": { "line": 40, "column": 21, "offset": 620 } } }, { "type": "svelteProperty", "name": "offset", "value": [ { "type": "svelteDynamicContent", "expression": { "type": "svelteExpression", "value": "offset", "position": { "start": { "line": 40, "column": 24, "offset": 623 }, "end": { "line": 40, "column": 30, "offset": 629 } } }, "position": { "start": { "line": 40, "column": 23, "offset": 622 }, "end": { "line": 40, "column": 30, "offset": 629 } } } ], "modifiers": [], "shorthand": "expression", "position": { "start": { "line": 40, "column": 23, "offset": 622 }, "end": { "line": 40, "column": 30, "offset": 629 } } } ], "selfClosing": true, "children": [], "position": { "start": { "line": 40, "column": 3, "offset": 602 }, "end": { "line": 40, "column": 33, "offset": 632 } } }, { "type": "text", "value": "\n\t", "position": { "start": { "line": 40, "column": 33, "offset": 632 }, "end": { "line": 41, "column": 2, "offset": 634 } } } ], "position": { "start": { "line": 39, "column": 2, "offset": 575 }, "end": { "line": 41, "column": 2, "offset": 634 } } } ], "position": { "start": { "line": 39, "column": 2, "offset": 575 }, "end": { "line": 41, "column": 9, "offset": 641 } } }, { "type": "text", "value": "\n\n\t", "position": { "start": { "line": 41, "column": 9, "offset": 641 }, "end": { "line": 43, "column": 2, "offset": 644 } } }, { "type": "svelteElement", "tagName": "a", "properties": [ { "type": "svelteProperty", "name": "href", "value": [ { "type": "text", "value": "#/top/", "position": { "start": { "line": 43, "column": 11, "offset": 653 }, "end": { "line": 43, "column": 17, "offset": 659 } } }, { "type": "svelteDynamicContent", "position": { "start": { "line": 43, "column": 17, "offset": 659 }, "end": { "line": 43, "column": 27, "offset": 669 } }, "expression": { "type": "svelteExpression", "value": "page + 1", "position": { "start": { "line": 43, "column": 18, "offset": 660 }, "end": { "line": 43, "column": 26, "offset": 668 } } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 43, "column": 5, "offset": 647 }, "end": { "line": 43, "column": 28, "offset": 670 } } } ], "selfClosing": false, "children": [ { "type": "text", "value": "page ", "position": { "start": { "line": 43, "column": 29, "offset": 671 }, "end": { "line": 43, "column": 34, "offset": 676 } } }, { "type": "svelteDynamicContent", "position": { "start": { "line": 43, "column": 34, "offset": 676 }, "end": { "line": 43, "column": 44, "offset": 686 } }, "expression": { "type": "svelteExpression", "value": "page + 1", "position": { "start": { "line": 43, "column": 35, "offset": 677 }, "end": { "line": 43, "column": 43, "offset": 685 } } } } ], "position": { "start": { "line": 43, "column": 2, "offset": 644 }, "end": { "line": 43, "column": 48, "offset": 690 } } }, { "type": "text", "value": "\n", "position": { "start": { "line": 43, "column": 48, "offset": 690 }, "end": { "line": 44, "column": 1, "offset": 691 } } } ], "position": { "start": { "line": 38, "column": 1, "offset": 562 }, "end": { "line": 44, "column": 1, "offset": 691 } } }, { "type": "svelteBranch", "name": "else", "expression": { "type": "svelteExpression", "value": "" }, "children": [ { "type": "text", "value": "\n\t", "position": { "start": { "line": 44, "column": 8, "offset": 698 }, "end": { "line": 45, "column": 2, "offset": 700 } } }, { "type": "svelteElement", "tagName": "p", "properties": [ { "type": "svelteProperty", "name": "class", "value": [ { "type": "text", "value": "loading", "position": { "start": { "line": 45, "column": 12, "offset": 710 }, "end": { "line": 45, "column": 20, "offset": 718 } } } ], "modifiers": [], "shorthand": "none", "position": { "start": { "line": 45, "column": 5, "offset": 703 }, "end": { "line": 45, "column": 20, "offset": 718 } } } ], "selfClosing": false, "children": [ { "type": "text", "value": "loading...", "position": { "start": { "line": 45, "column": 21, "offset": 719 }, "end": { "line": 45, "column": 31, "offset": 729 } } } ], "position": { "start": { "line": 45, "column": 2, "offset": 700 }, "end": { "line": 45, "column": 35, "offset": 733 } } }, { "type": "text", "value": "\n", "position": { "start": { "line": 45, "column": 35, "offset": 733 }, "end": { "line": 46, "column": 1, "offset": 734 } } } ], "position": { "start": { "line": 44, "column": 1, "offset": 691 }, "end": { "line": 46, "column": 1, "offset": 734 } } } ], "position": { "start": { "line": 38, "column": 1, "offset": 562 }, "end": { "line": 46, "column": 6, "offset": 739 } } } ], "position": { "start": { "column": 1, "line": 1, "offset": 0 }, "end": { "line": 46, "column": 6, "offset": 739 } } }