svelte-parse
Version:
An increidbly relaxed svelte-parser
740 lines (739 loc) • 13.5 kB
JSON
{
"type": "root",
"children": [
{
"type": "svelteScript",
"tagName": "script",
"properties": [],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n import Button from '@sveltekit/ui/Button';\n import Checkbox from '@sveltekit/ui/Checkbox';\n\n let isChecked = true;\n let isDisabled = true;\n \n let Label;\n $: {\n Label = isChecked ? 'Checked' : 'Unchecked';\n Label += `-${isDisabled ? 'Disabled' : 'Enabled'}`;\n }\n",
"position": {
"start": {
"line": 1,
"column": 9,
"offset": 8
},
"end": {
"line": 13,
"column": 1,
"offset": 289
}
}
}
],
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 13,
"column": 10,
"offset": 298
}
}
},
{
"type": "text",
"value": "\n\n",
"position": {
"start": {
"line": 13,
"column": 10,
"offset": 298
},
"end": {
"line": 15,
"column": 1,
"offset": 300
}
}
},
{
"type": "svelteStyle",
"tagName": "style",
"properties": [],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n .disabled {\n color: rgba(0, 0, 0, .25);\n }\n\n label {\n display: flex;\n align-items: center;\n cursor: pointer;\n }\n\n span {\n padding-left: 8px;\n }\n",
"position": {
"start": {
"line": 15,
"column": 8,
"offset": 307
},
"end": {
"line": 29,
"column": 1,
"offset": 474
}
}
}
],
"position": {
"start": {
"line": 15,
"column": 1,
"offset": 300
},
"end": {
"line": 29,
"column": 9,
"offset": 482
}
}
},
{
"type": "text",
"value": "\n\n",
"position": {
"start": {
"line": 29,
"column": 9,
"offset": 482
},
"end": {
"line": 31,
"column": 1,
"offset": 484
}
}
},
{
"type": "svelteElement",
"tagName": "label",
"properties": [
{
"type": "svelteProperty",
"name": "class",
"value": [
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 31,
"column": 15,
"offset": 498
},
"end": {
"line": 31,
"column": 45,
"offset": 528
}
},
"expression": {
"type": "svelteExpression",
"value": "isDisabled ? 'disabled' : ''",
"position": {
"start": {
"line": 31,
"column": 16,
"offset": 499
},
"end": {
"line": 31,
"column": 44,
"offset": 527
}
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 31,
"column": 8,
"offset": 491
},
"end": {
"line": 31,
"column": 46,
"offset": 529
}
}
}
],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n ",
"position": {
"start": {
"line": 31,
"column": 47,
"offset": 530
},
"end": {
"line": 32,
"column": 3,
"offset": 533
}
}
},
{
"type": "svelteComponent",
"tagName": "Checkbox",
"properties": [
{
"type": "svelteDirective",
"name": "bind",
"value": [],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 32,
"column": 13,
"offset": 543
},
"end": {
"line": 32,
"column": 27,
"offset": 557
}
},
"specifier": "isChecked"
},
{
"type": "svelteProperty",
"name": "isDisabled",
"value": [
{
"type": "svelteDynamicContent",
"expression": {
"type": "svelteExpression",
"value": "isDisabled",
"position": {
"start": {
"line": 32,
"column": 29,
"offset": 559
},
"end": {
"line": 32,
"column": 39,
"offset": 569
}
}
},
"position": {
"start": {
"line": 32,
"column": 28,
"offset": 558
},
"end": {
"line": 32,
"column": 39,
"offset": 569
}
}
}
],
"modifiers": [],
"shorthand": "expression",
"position": {
"start": {
"line": 32,
"column": 28,
"offset": 558
},
"end": {
"line": 32,
"column": 39,
"offset": 569
}
}
}
],
"selfClosing": true,
"children": [],
"position": {
"start": {
"line": 32,
"column": 3,
"offset": 533
},
"end": {
"line": 32,
"column": 43,
"offset": 573
}
}
},
{
"type": "text",
"value": "\n ",
"position": {
"start": {
"line": 32,
"column": 43,
"offset": 573
},
"end": {
"line": 33,
"column": 3,
"offset": 576
}
}
},
{
"type": "svelteElement",
"tagName": "span",
"properties": [],
"selfClosing": false,
"children": [
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 33,
"column": 9,
"offset": 582
},
"end": {
"line": 33,
"column": 16,
"offset": 589
}
},
"expression": {
"type": "svelteExpression",
"value": "Label",
"position": {
"start": {
"line": 33,
"column": 10,
"offset": 583
},
"end": {
"line": 33,
"column": 15,
"offset": 588
}
}
}
}
],
"position": {
"start": {
"line": 33,
"column": 3,
"offset": 576
},
"end": {
"line": 33,
"column": 23,
"offset": 596
}
}
},
{
"type": "text",
"value": "\n",
"position": {
"start": {
"line": 33,
"column": 23,
"offset": 596
},
"end": {
"line": 34,
"column": 1,
"offset": 597
}
}
}
],
"position": {
"start": {
"line": 31,
"column": 1,
"offset": 484
},
"end": {
"line": 34,
"column": 9,
"offset": 605
}
}
},
{
"type": "text",
"value": "\n\n",
"position": {
"start": {
"line": 34,
"column": 9,
"offset": 605
},
"end": {
"line": 36,
"column": 1,
"offset": 607
}
}
},
{
"type": "svelteElement",
"tagName": "p",
"properties": [],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n ",
"position": {
"start": {
"line": 36,
"column": 4,
"offset": 610
},
"end": {
"line": 37,
"column": 3,
"offset": 613
}
}
},
{
"type": "svelteComponent",
"tagName": "Button",
"properties": [
{
"type": "svelteDirective",
"name": "on",
"value": [
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 37,
"column": 21,
"offset": 631
},
"end": {
"line": 37,
"column": 52,
"offset": 662
}
},
"expression": {
"type": "svelteExpression",
"value": "() => isChecked = !isChecked ",
"position": {
"start": {
"line": 37,
"column": 22,
"offset": 632
},
"end": {
"line": 37,
"column": 51,
"offset": 661
}
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 37,
"column": 11,
"offset": 621
},
"end": {
"line": 37,
"column": 53,
"offset": 663
}
},
"specifier": "click"
}
],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n ",
"position": {
"start": {
"line": 37,
"column": 54,
"offset": 664
},
"end": {
"line": 38,
"column": 5,
"offset": 669
}
}
},
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 38,
"column": 5,
"offset": 669
},
"end": {
"line": 38,
"column": 38,
"offset": 702
}
},
"expression": {
"type": "svelteExpression",
"value": "isChecked ? 'Uncheck' : 'Check'",
"position": {
"start": {
"line": 38,
"column": 6,
"offset": 670
},
"end": {
"line": 38,
"column": 37,
"offset": 701
}
}
}
},
{
"type": "text",
"value": "\n ",
"position": {
"start": {
"line": 38,
"column": 38,
"offset": 702
},
"end": {
"line": 39,
"column": 3,
"offset": 705
}
}
}
],
"position": {
"start": {
"line": 37,
"column": 3,
"offset": 613
},
"end": {
"line": 39,
"column": 12,
"offset": 714
}
}
},
{
"type": "text",
"value": "\n\n ",
"position": {
"start": {
"line": 39,
"column": 12,
"offset": 714
},
"end": {
"line": 41,
"column": 3,
"offset": 718
}
}
},
{
"type": "svelteComponent",
"tagName": "Button",
"properties": [
{
"type": "svelteDirective",
"name": "on",
"value": [
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 41,
"column": 21,
"offset": 736
},
"end": {
"line": 41,
"column": 54,
"offset": 769
}
},
"expression": {
"type": "svelteExpression",
"value": "() => isDisabled = !isDisabled ",
"position": {
"start": {
"line": 41,
"column": 22,
"offset": 737
},
"end": {
"line": 41,
"column": 53,
"offset": 768
}
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 41,
"column": 11,
"offset": 726
},
"end": {
"line": 41,
"column": 55,
"offset": 770
}
},
"specifier": "click"
}
],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n ",
"position": {
"start": {
"line": 41,
"column": 56,
"offset": 771
},
"end": {
"line": 42,
"column": 5,
"offset": 776
}
}
},
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 42,
"column": 5,
"offset": 776
},
"end": {
"line": 42,
"column": 40,
"offset": 811
}
},
"expression": {
"type": "svelteExpression",
"value": "isDisabled ? 'Enable' : 'Disable'",
"position": {
"start": {
"line": 42,
"column": 6,
"offset": 777
},
"end": {
"line": 42,
"column": 39,
"offset": 810
}
}
}
},
{
"type": "text",
"value": "\n ",
"position": {
"start": {
"line": 42,
"column": 40,
"offset": 811
},
"end": {
"line": 43,
"column": 3,
"offset": 814
}
}
}
],
"position": {
"start": {
"line": 41,
"column": 3,
"offset": 718
},
"end": {
"line": 43,
"column": 12,
"offset": 823
}
}
},
{
"type": "text",
"value": "\n",
"position": {
"start": {
"line": 43,
"column": 12,
"offset": 823
},
"end": {
"line": 44,
"column": 1,
"offset": 824
}
}
}
],
"position": {
"start": {
"line": 36,
"column": 1,
"offset": 607
},
"end": {
"line": 44,
"column": 5,
"offset": 828
}
}
}
],
"position": {
"start": {
"column": 1,
"line": 1,
"offset": 0
},
"end": {
"line": 44,
"column": 5,
"offset": 828
}
}
}