svelte-parse
Version:
An increidbly relaxed svelte-parser
432 lines (431 loc) • 7.85 kB
JSON
{
"type": "root",
"children": [
{
"type": "svelteScript",
"tagName": "script",
"properties": [],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n\tlet user = { loggedIn: false };\n\n\tfunction toggle() {\n\t\tuser.loggedIn = !user.loggedIn;\n\t}\n",
"position": {
"start": {
"line": 1,
"column": 9,
"offset": 8
},
"end": {
"line": 7,
"column": 1,
"offset": 101
}
}
}
],
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 7,
"column": 10,
"offset": 110
}
}
},
{
"type": "text",
"value": "\n\n",
"position": {
"start": {
"line": 7,
"column": 10,
"offset": 110
},
"end": {
"line": 9,
"column": 1,
"offset": 112
}
}
},
{
"type": "svelteBranchingBlock",
"name": "if",
"branches": [
{
"type": "svelteBranch",
"name": "if",
"expression": {
"type": "svelteExpression",
"value": "user.loggedIn",
"position": {
"start": {
"line": 9,
"column": 6,
"offset": 117
},
"end": {
"line": 9,
"column": 19,
"offset": 130
}
}
},
"children": [
{
"type": "text",
"value": "\n\t",
"position": {
"start": {
"line": 9,
"column": 20,
"offset": 131
},
"end": {
"line": 10,
"column": 2,
"offset": 133
}
}
},
{
"type": "svelteElement",
"tagName": "button",
"properties": [
{
"type": "svelteDirective",
"name": "on",
"value": [
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 10,
"column": 19,
"offset": 150
},
"end": {
"line": 10,
"column": 27,
"offset": 158
}
},
"expression": {
"type": "svelteExpression",
"value": "toggle",
"position": {
"start": {
"line": 10,
"column": 20,
"offset": 151
},
"end": {
"line": 10,
"column": 26,
"offset": 157
}
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 10,
"column": 10,
"offset": 141
},
"end": {
"line": 10,
"column": 27,
"offset": 158
}
},
"specifier": "click"
}
],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n\t\tLog out\n\t",
"position": {
"start": {
"line": 10,
"column": 28,
"offset": 159
},
"end": {
"line": 12,
"column": 2,
"offset": 171
}
}
}
],
"position": {
"start": {
"line": 10,
"column": 2,
"offset": 133
},
"end": {
"line": 12,
"column": 11,
"offset": 180
}
}
},
{
"type": "text",
"value": "\n",
"position": {
"start": {
"line": 12,
"column": 11,
"offset": 180
},
"end": {
"line": 13,
"column": 1,
"offset": 181
}
}
}
],
"position": {
"start": {
"line": 9,
"column": 1,
"offset": 112
},
"end": {
"line": 13,
"column": 1,
"offset": 181
}
}
}
],
"position": {
"start": {
"line": 9,
"column": 1,
"offset": 112
},
"end": {
"line": 13,
"column": 6,
"offset": 186
}
}
},
{
"type": "text",
"value": "\n\n",
"position": {
"start": {
"line": 13,
"column": 6,
"offset": 186
},
"end": {
"line": 15,
"column": 1,
"offset": 188
}
}
},
{
"type": "svelteBranchingBlock",
"name": "if",
"branches": [
{
"type": "svelteBranch",
"name": "if",
"expression": {
"type": "svelteExpression",
"value": "!user.loggedIn",
"position": {
"start": {
"line": 15,
"column": 6,
"offset": 193
},
"end": {
"line": 15,
"column": 20,
"offset": 207
}
}
},
"children": [
{
"type": "text",
"value": "\n\t",
"position": {
"start": {
"line": 15,
"column": 21,
"offset": 208
},
"end": {
"line": 16,
"column": 2,
"offset": 210
}
}
},
{
"type": "svelteElement",
"tagName": "button",
"properties": [
{
"type": "svelteDirective",
"name": "on",
"value": [
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 16,
"column": 19,
"offset": 227
},
"end": {
"line": 16,
"column": 27,
"offset": 235
}
},
"expression": {
"type": "svelteExpression",
"value": "toggle",
"position": {
"start": {
"line": 16,
"column": 20,
"offset": 228
},
"end": {
"line": 16,
"column": 26,
"offset": 234
}
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 16,
"column": 10,
"offset": 218
},
"end": {
"line": 16,
"column": 27,
"offset": 235
}
},
"specifier": "click"
}
],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n\t\tLog in\n\t",
"position": {
"start": {
"line": 16,
"column": 28,
"offset": 236
},
"end": {
"line": 18,
"column": 2,
"offset": 247
}
}
}
],
"position": {
"start": {
"line": 16,
"column": 2,
"offset": 210
},
"end": {
"line": 18,
"column": 11,
"offset": 256
}
}
},
{
"type": "text",
"value": "\n",
"position": {
"start": {
"line": 18,
"column": 11,
"offset": 256
},
"end": {
"line": 19,
"column": 1,
"offset": 257
}
}
}
],
"position": {
"start": {
"line": 15,
"column": 1,
"offset": 188
},
"end": {
"line": 19,
"column": 1,
"offset": 257
}
}
}
],
"position": {
"start": {
"line": 15,
"column": 1,
"offset": 188
},
"end": {
"line": 19,
"column": 6,
"offset": 262
}
}
}
],
"position": {
"start": {
"column": 1,
"line": 1,
"offset": 0
},
"end": {
"line": 19,
"column": 6,
"offset": 262
}
}
}