svelte-parse
Version:
An increidbly relaxed svelte-parser
771 lines (770 loc) • 13.8 kB
JSON
{
"type": "root",
"children": [
{
"type": "svelteScript",
"tagName": "script",
"properties": [],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n\timport { longpress } from './longpress.js';\n\n\tlet pressed = false;\n\tlet duration = 2000;\n",
"position": {
"start": {
"line": 1,
"column": 9,
"offset": 8
},
"end": {
"line": 6,
"column": 1,
"offset": 99
}
}
}
],
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 6,
"column": 10,
"offset": 108
}
}
},
{
"type": "text",
"value": "\n\n",
"position": {
"start": {
"line": 6,
"column": 10,
"offset": 108
},
"end": {
"line": 8,
"column": 1,
"offset": 110
}
}
},
{
"type": "svelteElement",
"tagName": "label",
"properties": [],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n\t",
"position": {
"start": {
"line": 8,
"column": 8,
"offset": 117
},
"end": {
"line": 9,
"column": 2,
"offset": 119
}
}
},
{
"type": "svelteElement",
"tagName": "input",
"properties": [
{
"type": "svelteProperty",
"name": "type",
"value": [
{
"type": "text",
"value": "range",
"position": {
"start": {
"line": 9,
"column": 14,
"offset": 131
},
"end": {
"line": 9,
"column": 19,
"offset": 136
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 9,
"column": 9,
"offset": 126
},
"end": {
"line": 9,
"column": 19,
"offset": 136
}
}
},
{
"type": "svelteDirective",
"name": "bind",
"value": [
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 9,
"column": 31,
"offset": 148
},
"end": {
"line": 9,
"column": 41,
"offset": 158
}
},
"expression": {
"type": "svelteExpression",
"value": "duration",
"position": {
"start": {
"line": 9,
"column": 32,
"offset": 149
},
"end": {
"line": 9,
"column": 40,
"offset": 157
}
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 9,
"column": 20,
"offset": 137
},
"end": {
"line": 9,
"column": 41,
"offset": 158
}
},
"specifier": "value"
},
{
"type": "svelteProperty",
"name": "max",
"value": [
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 9,
"column": 46,
"offset": 163
},
"end": {
"line": 9,
"column": 52,
"offset": 169
}
},
"expression": {
"type": "svelteExpression",
"value": "2000",
"position": {
"start": {
"line": 9,
"column": 47,
"offset": 164
},
"end": {
"line": 9,
"column": 51,
"offset": 168
}
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 9,
"column": 42,
"offset": 159
},
"end": {
"line": 9,
"column": 52,
"offset": 169
}
}
},
{
"type": "svelteProperty",
"name": "step",
"value": [
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 9,
"column": 58,
"offset": 175
},
"end": {
"line": 9,
"column": 63,
"offset": 180
}
},
"expression": {
"type": "svelteExpression",
"value": "100",
"position": {
"start": {
"line": 9,
"column": 59,
"offset": 176
},
"end": {
"line": 9,
"column": 62,
"offset": 179
}
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 9,
"column": 53,
"offset": 170
},
"end": {
"line": 9,
"column": 63,
"offset": 180
}
}
}
],
"selfClosing": true,
"children": [],
"position": {
"start": {
"line": 9,
"column": 2,
"offset": 119
},
"end": {
"line": 9,
"column": 64,
"offset": 181
}
}
},
{
"type": "text",
"value": "\n\t",
"position": {
"start": {
"line": 9,
"column": 64,
"offset": 181
},
"end": {
"line": 10,
"column": 2,
"offset": 183
}
}
},
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 10,
"column": 2,
"offset": 183
},
"end": {
"line": 10,
"column": 12,
"offset": 193
}
},
"expression": {
"type": "svelteExpression",
"value": "duration",
"position": {
"start": {
"line": 10,
"column": 3,
"offset": 184
},
"end": {
"line": 10,
"column": 11,
"offset": 192
}
}
}
},
{
"type": "text",
"value": "ms\n",
"position": {
"start": {
"line": 10,
"column": 12,
"offset": 193
},
"end": {
"line": 11,
"column": 1,
"offset": 196
}
}
}
],
"position": {
"start": {
"line": 8,
"column": 1,
"offset": 110
},
"end": {
"line": 11,
"column": 9,
"offset": 204
}
}
},
{
"type": "text",
"value": "\n\n",
"position": {
"start": {
"line": 11,
"column": 9,
"offset": 204
},
"end": {
"line": 13,
"column": 1,
"offset": 206
}
}
},
{
"type": "svelteElement",
"tagName": "button",
"properties": [
{
"type": "svelteDirective",
"name": "use",
"value": [
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 13,
"column": 23,
"offset": 228
},
"end": {
"line": 13,
"column": 33,
"offset": 238
}
},
"expression": {
"type": "svelteExpression",
"value": "duration",
"position": {
"start": {
"line": 13,
"column": 24,
"offset": 229
},
"end": {
"line": 13,
"column": 32,
"offset": 237
}
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 13,
"column": 9,
"offset": 214
},
"end": {
"line": 13,
"column": 33,
"offset": 238
}
},
"specifier": "longpress"
},
{
"type": "svelteDirective",
"name": "on",
"value": [
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 14,
"column": 16,
"offset": 254
},
"end": {
"line": 14,
"column": 38,
"offset": 276
}
},
"expression": {
"type": "svelteExpression",
"value": "() => pressed = true",
"position": {
"start": {
"line": 14,
"column": 17,
"offset": 255
},
"end": {
"line": 14,
"column": 37,
"offset": 275
}
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 14,
"column": 2,
"offset": 240
},
"end": {
"line": 14,
"column": 39,
"offset": 277
}
},
"specifier": "longpress"
},
{
"type": "svelteDirective",
"name": "on",
"value": [
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 15,
"column": 17,
"offset": 294
},
"end": {
"line": 15,
"column": 40,
"offset": 317
}
},
"expression": {
"type": "svelteExpression",
"value": "() => pressed = false",
"position": {
"start": {
"line": 15,
"column": 18,
"offset": 295
},
"end": {
"line": 15,
"column": 39,
"offset": 316
}
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 15,
"column": 2,
"offset": 279
},
"end": {
"line": 15,
"column": 41,
"offset": 318
}
},
"specifier": "mouseenter"
}
],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "press and hold",
"position": {
"start": {
"line": 16,
"column": 2,
"offset": 320
},
"end": {
"line": 16,
"column": 16,
"offset": 334
}
}
}
],
"position": {
"start": {
"line": 13,
"column": 1,
"offset": 206
},
"end": {
"line": 16,
"column": 25,
"offset": 343
}
}
},
{
"type": "text",
"value": "\n\n",
"position": {
"start": {
"line": 16,
"column": 25,
"offset": 343
},
"end": {
"line": 18,
"column": 1,
"offset": 345
}
}
},
{
"type": "svelteBranchingBlock",
"name": "if",
"branches": [
{
"type": "svelteBranch",
"name": "if",
"expression": {
"type": "svelteExpression",
"value": "pressed",
"position": {
"start": {
"line": 18,
"column": 6,
"offset": 350
},
"end": {
"line": 18,
"column": 13,
"offset": 357
}
}
},
"children": [
{
"type": "text",
"value": "\n\t",
"position": {
"start": {
"line": 18,
"column": 14,
"offset": 358
},
"end": {
"line": 19,
"column": 2,
"offset": 360
}
}
},
{
"type": "svelteElement",
"tagName": "p",
"properties": [],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "congratulations, you pressed and held for ",
"position": {
"start": {
"line": 19,
"column": 5,
"offset": 363
},
"end": {
"line": 19,
"column": 47,
"offset": 405
}
}
},
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 19,
"column": 47,
"offset": 405
},
"end": {
"line": 19,
"column": 57,
"offset": 415
}
},
"expression": {
"type": "svelteExpression",
"value": "duration",
"position": {
"start": {
"line": 19,
"column": 48,
"offset": 406
},
"end": {
"line": 19,
"column": 56,
"offset": 414
}
}
}
},
{
"type": "text",
"value": "ms",
"position": {
"start": {
"line": 19,
"column": 57,
"offset": 415
},
"end": {
"line": 19,
"column": 59,
"offset": 417
}
}
}
],
"position": {
"start": {
"line": 19,
"column": 2,
"offset": 360
},
"end": {
"line": 19,
"column": 63,
"offset": 421
}
}
},
{
"type": "text",
"value": "\n",
"position": {
"start": {
"line": 19,
"column": 63,
"offset": 421
},
"end": {
"line": 20,
"column": 1,
"offset": 422
}
}
}
],
"position": {
"start": {
"line": 18,
"column": 1,
"offset": 345
},
"end": {
"line": 20,
"column": 1,
"offset": 422
}
}
}
],
"position": {
"start": {
"line": 18,
"column": 1,
"offset": 345
},
"end": {
"line": 20,
"column": 6,
"offset": 427
}
}
}
],
"position": {
"start": {
"column": 1,
"line": 1,
"offset": 0
},
"end": {
"line": 20,
"column": 6,
"offset": 427
}
}
}