rizzo-next
Version:
The next generation of Lonely Planet's style guide and pattern library.
1,398 lines (1,397 loc) • 116 kB
JSON
{
"type": "Program",
"start": 0,
"end": 2261,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 75,
"column": 0
}
},
"sourceType": "module",
"body": [
{
"type": "ImportDeclaration",
"start": 0,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 35
}
},
"specifiers": [
{
"type": "ImportSpecifier",
"start": 9,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 18
}
},
"imported": {
"type": "Identifier",
"start": 9,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 18
}
},
"name": "Component"
},
"local": {
"type": "Identifier",
"start": 9,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 18
}
},
"name": "Component"
}
}
],
"importKind": "value",
"source": {
"type": "Literal",
"start": 26,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 26
},
"end": {
"line": 1,
"column": 34
}
},
"value": "./bane",
"rawValue": "./bane",
"raw": "\"./bane\""
},
"trailingComments": [
{
"type": "Block",
"value": "*\n * Register components with Rizzo\n ",
"start": 37,
"end": 78,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 5,
"column": 3
}
},
"range": [
37,
78
]
}
]
},
{
"type": "ExportDefaultDeclaration",
"start": 79,
"end": 2260,
"loc": {
"start": {
"line": 6,
"column": 0
},
"end": {
"line": 74,
"column": 1
}
},
"declaration": {
"type": "ClassDeclaration",
"start": 94,
"end": 2260,
"loc": {
"start": {
"line": 6,
"column": 15
},
"end": {
"line": 74,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 100,
"end": 117,
"loc": {
"start": {
"line": 6,
"column": 21
},
"end": {
"line": 6,
"column": 38
}
},
"name": "ComponentRegistry",
"leadingComments": null
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 118,
"end": 2260,
"loc": {
"start": {
"line": 6,
"column": 39
},
"end": {
"line": 74,
"column": 1
}
},
"body": [
{
"type": "MethodDefinition",
"start": 229,
"end": 322,
"loc": {
"start": {
"line": 11,
"column": 2
},
"end": {
"line": 14,
"column": 3
}
},
"computed": false,
"key": {
"type": "Identifier",
"start": 229,
"end": 240,
"loc": {
"start": {
"line": 11,
"column": 2
},
"end": {
"line": 11,
"column": 13
}
},
"name": "constructor",
"leadingComments": null
},
"static": false,
"kind": "constructor",
"value": {
"type": "FunctionExpression",
"start": 240,
"end": 322,
"loc": {
"start": {
"line": 11,
"column": 13
},
"end": {
"line": 14,
"column": 3
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "AssignmentPattern",
"start": 241,
"end": 256,
"loc": {
"start": {
"line": 11,
"column": 14
},
"end": {
"line": 11,
"column": 29
}
},
"left": {
"type": "ObjectPattern",
"start": 241,
"end": 251,
"loc": {
"start": {
"line": 11,
"column": 14
},
"end": {
"line": 11,
"column": 24
}
},
"properties": [
{
"type": "Property",
"start": 243,
"end": 249,
"loc": {
"start": {
"line": 11,
"column": 16
},
"end": {
"line": 11,
"column": 22
}
},
"method": false,
"shorthand": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 243,
"end": 249,
"loc": {
"start": {
"line": 11,
"column": 16
},
"end": {
"line": 11,
"column": 22
}
},
"name": "logger"
},
"kind": "init",
"value": {
"type": "Identifier",
"start": 243,
"end": 249,
"loc": {
"start": {
"line": 11,
"column": 16
},
"end": {
"line": 11,
"column": 22
}
},
"name": "logger"
}
}
]
},
"right": {
"type": "ObjectExpression",
"start": 254,
"end": 256,
"loc": {
"start": {
"line": 11,
"column": 27
},
"end": {
"line": 11,
"column": 29
}
},
"properties": []
}
}
],
"body": {
"type": "BlockStatement",
"start": 258,
"end": 322,
"loc": {
"start": {
"line": 11,
"column": 31
},
"end": {
"line": 14,
"column": 3
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 264,
"end": 292,
"loc": {
"start": {
"line": 12,
"column": 4
},
"end": {
"line": 12,
"column": 32
}
},
"expression": {
"type": "AssignmentExpression",
"start": 264,
"end": 291,
"loc": {
"start": {
"line": 12,
"column": 4
},
"end": {
"line": 12,
"column": 31
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 264,
"end": 279,
"loc": {
"start": {
"line": 12,
"column": 4
},
"end": {
"line": 12,
"column": 19
}
},
"object": {
"type": "ThisExpression",
"start": 264,
"end": 268,
"loc": {
"start": {
"line": 12,
"column": 4
},
"end": {
"line": 12,
"column": 8
}
}
},
"property": {
"type": "Identifier",
"start": 269,
"end": 279,
"loc": {
"start": {
"line": 12,
"column": 9
},
"end": {
"line": 12,
"column": 19
}
},
"name": "components"
},
"computed": false
},
"right": {
"type": "NewExpression",
"start": 282,
"end": 291,
"loc": {
"start": {
"line": 12,
"column": 22
},
"end": {
"line": 12,
"column": 31
}
},
"callee": {
"type": "Identifier",
"start": 286,
"end": 289,
"loc": {
"start": {
"line": 12,
"column": 26
},
"end": {
"line": 12,
"column": 29
}
},
"name": "Map"
},
"arguments": []
}
}
},
{
"type": "ExpressionStatement",
"start": 297,
"end": 318,
"loc": {
"start": {
"line": 13,
"column": 4
},
"end": {
"line": 13,
"column": 25
}
},
"expression": {
"type": "AssignmentExpression",
"start": 297,
"end": 317,
"loc": {
"start": {
"line": 13,
"column": 4
},
"end": {
"line": 13,
"column": 24
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 297,
"end": 308,
"loc": {
"start": {
"line": 13,
"column": 4
},
"end": {
"line": 13,
"column": 15
}
},
"object": {
"type": "ThisExpression",
"start": 297,
"end": 301,
"loc": {
"start": {
"line": 13,
"column": 4
},
"end": {
"line": 13,
"column": 8
}
}
},
"property": {
"type": "Identifier",
"start": 302,
"end": 308,
"loc": {
"start": {
"line": 13,
"column": 9
},
"end": {
"line": 13,
"column": 15
}
},
"name": "logger"
},
"computed": false
},
"right": {
"type": "Identifier",
"start": 311,
"end": 317,
"loc": {
"start": {
"line": 13,
"column": 18
},
"end": {
"line": 13,
"column": 24
}
},
"name": "logger"
}
}
}
],
"trailingComments": null
},
"trailingComments": null
},
"leadingComments": [
{
"type": "Block",
"value": "*\n * Constructs the ComponentRegistry\n * @param {Logger} options.logger Instance of a logger\n ",
"start": 122,
"end": 226,
"loc": {
"start": {
"line": 7,
"column": 2
},
"end": {
"line": 10,
"column": 5
}
},
"range": [
122,
226
]
}
],
"trailingComments": [
{
"type": "Block",
"value": "*\n * Create an instance of a given component. \n * Will also register the component.\n * @param {Component} Component A constructor that extends `Component`\n * @param {[object]} options Options to pass to the constructor\n * @return {object} Instance of the component\n ",
"start": 325,
"end": 609,
"loc": {
"start": {
"line": 15,
"column": 2
},
"end": {
"line": 21,
"column": 5
}
},
"range": [
325,
609
]
}
]
},
{
"type": "MethodDefinition",
"start": 612,
"end": 1225,
"loc": {
"start": {
"line": 22,
"column": 2
},
"end": {
"line": 47,
"column": 3
}
},
"computed": false,
"key": {
"type": "Identifier",
"start": 612,
"end": 628,
"loc": {
"start": {
"line": 22,
"column": 2
},
"end": {
"line": 22,
"column": 18
}
},
"name": "createInstanceOf",
"leadingComments": null
},
"static": false,
"kind": "method",
"value": {
"type": "FunctionExpression",
"start": 628,
"end": 1225,
"loc": {
"start": {
"line": 22,
"column": 18
},
"end": {
"line": 47,
"column": 3
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 629,
"end": 638,
"loc": {
"start": {
"line": 22,
"column": 19
},
"end": {
"line": 22,
"column": 28
}
},
"name": "Component"
},
{
"type": "Identifier",
"start": 640,
"end": 647,
"loc": {
"start": {
"line": 22,
"column": 30
},
"end": {
"line": 22,
"column": 37
}
},
"name": "options"
}
],
"body": {
"type": "BlockStatement",
"start": 649,
"end": 1225,
"loc": {
"start": {
"line": 22,
"column": 39
},
"end": {
"line": 47,
"column": 3
}
},
"body": [
{
"type": "IfStatement",
"start": 728,
"end": 827,
"loc": {
"start": {
"line": 24,
"column": 4
},
"end": {
"line": 26,
"column": 5
}
},
"test": {
"type": "LogicalExpression",
"start": 732,
"end": 786,
"loc": {
"start": {
"line": 24,
"column": 8
},
"end": {
"line": 24,
"column": 62
}
},
"left": {
"type": "MemberExpression",
"start": 732,
"end": 746,
"loc": {
"start": {
"line": 24,
"column": 8
},
"end": {
"line": 24,
"column": 22
}
},
"object": {
"type": "Identifier",
"start": 732,
"end": 741,
"loc": {
"start": {
"line": 24,
"column": 8
},
"end": {
"line": 24,
"column": 17
}
},
"name": "Component",
"leadingComments": null
},
"property": {
"type": "Identifier",
"start": 742,
"end": 746,
"loc": {
"start": {
"line": 24,
"column": 18
},
"end": {
"line": 24,
"column": 22
}
},
"name": "name"
},
"computed": false,
"leadingComments": null
},
"operator": "&&",
"right": {
"type": "UnaryExpression",
"start": 750,
"end": 786,
"loc": {
"start": {
"line": 24,
"column": 26
},
"end": {
"line": 24,
"column": 62
}
},
"operator": "!",
"prefix": true,
"argument": {
"type": "CallExpression",
"start": 751,
"end": 786,
"loc": {
"start": {
"line": 24,
"column": 27
},
"end": {
"line": 24,
"column": 62
}
},
"callee": {
"type": "MemberExpression",
"start": 751,
"end": 770,
"loc": {
"start": {
"line": 24,
"column": 27
},
"end": {
"line": 24,
"column": 46
}
},
"object": {
"type": "MemberExpression",
"start": 751,
"end": 766,
"loc": {
"start": {
"line": 24,
"column": 27
},
"end": {
"line": 24,
"column": 42
}
},
"object": {
"type": "ThisExpression",
"start": 751,
"end": 755,
"loc": {
"start": {
"line": 24,
"column": 27
},
"end": {
"line": 24,
"column": 31
}
}
},
"property": {
"type": "Identifier",
"start": 756,
"end": 766,
"loc": {
"start": {
"line": 24,
"column": 32
},
"end": {
"line": 24,
"column": 42
}
},
"name": "components"
},
"computed": false
},
"property": {
"type": "Identifier",
"start": 767,
"end": 770,
"loc": {
"start": {
"line": 24,
"column": 43
},
"end": {
"line": 24,
"column": 46
}
},
"name": "has"
},
"computed": false
},
"arguments": [
{
"type": "MemberExpression",
"start": 771,
"end": 785,
"loc": {
"start": {
"line": 24,
"column": 47
},
"end": {
"line": 24,
"column": 61
}
},
"object": {
"type": "Identifier",
"start": 771,
"end": 780,
"loc": {
"start": {
"line": 24,
"column": 47
},
"end": {
"line": 24,
"column": 56
}
},
"name": "Component"
},
"property": {
"type": "Identifier",
"start": 781,
"end": 785,
"loc": {
"start": {
"line": 24,
"column": 57
},
"end": {
"line": 24,
"column": 61
}
},
"name": "name"
},
"computed": false
}
]
}
},
"leadingComments": null
},
"consequent": {
"type": "BlockStatement",
"start": 788,
"end": 827,
"loc": {
"start": {
"line": 24,
"column": 64
},
"end": {
"line": 26,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 796,
"end": 821,
"loc": {
"start": {
"line": 25,
"column": 6
},
"end": {
"line": 25,
"column": 31
}
},
"expression": {
"type": "CallExpression",
"start": 796,
"end": 820,
"loc": {
"start": {
"line": 25,
"column": 6
},
"end": {
"line": 25,
"column": 30
}
},
"callee": {
"type": "MemberExpression",
"start": 796,
"end": 809,
"loc": {
"start": {
"line": 25,
"column": 6
},
"end": {
"line": 25,
"column": 19
}
},
"object": {
"type": "ThisExpression",
"start": 796,
"end": 800,
"loc": {
"start": {
"line": 25,
"column": 6
},
"end": {
"line": 25,
"column": 10
}
}
},
"property": {
"type": "Identifier",
"start": 801,
"end": 809,
"loc": {
"start": {
"line": 25,
"column": 11
},
"end": {
"line": 25,
"column": 19
}
},
"name": "register"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 810,
"end": 819,
"loc": {
"start": {
"line": 25,
"column": 20
},
"end": {
"line": 25,
"column": 29
}
},
"name": "Component"
}
]
}
}
]
},
"alternate": null,
"leadingComments": [
{
"type": "CommentLine",
"value": " Function.name only supported in certain browsers, hence the check",
"start": 655,
"end": 723,
"loc": {
"start": {
"line": 23,
"column": 4
},
"end": {
"line": 23,
"column": 72
}
},
"range": [
655,
723
]
}
]
},
{
"type": "VariableDeclaration",
"start": 833,
"end": 885,
"loc": {
"start": {
"line": 28,
"column": 4
},
"end": {
"line": 28,
"column": 56
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 837,
"end": 884,
"loc": {
"start": {
"line": 28,
"column": 8
},
"end": {
"line": 28,
"column": 55
}
},
"id": {
"type": "Identifier",
"start": 837,
"end": 846,
"loc": {
"start": {
"line": 28,
"column": 8
},
"end": {
"line": 28,
"column": 17
}
},
"name": "instances"
},
"init": {
"type": "CallExpression",
"start": 849,
"end": 884,
"loc": {
"start": {
"line": 28,
"column": 20
},
"end": {
"line": 28,
"column": 55
}
},
"callee": {
"type": "MemberExpression",
"start": 849,
"end": 868,
"loc": {
"start": {
"line": 28,
"column": 20
},
"end": {
"line": 28,
"column": 39
}
},
"object": {
"type": "MemberExpression",
"start": 849,
"end": 864,
"loc": {
"start": {
"line": 28,
"column": 20
},
"end": {
"line": 28,
"column": 35
}
},
"object": {
"type": "ThisExpression",
"start": 849,
"end": 853,
"loc": {
"start": {
"line": 28,
"column": 20
},
"end": {
"line": 28,
"column": 24
}
}
},
"property": {
"type": "Identifier",
"start": 854,
"end": 864,
"loc": {
"start": {
"line": 28,
"column": 25
},
"end": {
"line": 28,
"column": 35
}
},
"name": "components"
},
"computed": false
},
"property": {
"type": "Identifier",
"start": 865,
"end": 868,
"loc": {
"start": {
"line": 28,
"column": 36
},
"end": {
"line": 28,
"column": 39
}
},
"name": "get"
},
"computed": false
},
"arguments": [
{
"type": "MemberExpression",
"start": 869,
"end": 883,
"loc": {
"start": {
"line": 28,
"column": 40
},
"end": {
"line": 28,
"column": 54
}
},
"object": {
"type": "Identifier",
"start": 869,
"end": 878,
"loc": {
"start": {
"line": 28,
"column": 40
},
"end": {
"line": 28,
"column": 49
}
},
"name": "Component"
},
"property": {
"type": "Identifier",
"start": 879,
"end": 883,
"loc": {
"start": {
"line": 28,
"column": 50
},
"end": {
"line": 28,
"column": 54
}
},
"name": "name"
},
"computed": false
}
]
}
}
],
"kind": "let"
},
{
"type": "VariableDeclaration",
"start": 891,
"end": 911,
"loc": {
"start": {
"line": 30,
"column": 4
},
"end": {
"line": 30,
"column": 24
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 895,
"end": 910,
"loc": {
"start": {
"line": 30,
"column": 8
},
"end": {
"line": 30,
"column": 23
}
},
"id": {
"type": "Identifier",
"start": 895,
"end": 903,
"loc": {
"start": {
"line": 30,
"column": 8
},
"end": {
"line": 30,
"column": 16
}
},
"name": "instance"
},
"init": {
"type": "Literal",
"start": 906,
"end": 910,
"loc": {
"start": {
"line": 30,
"column": 19
},
"end": {
"line": 30,
"column": 23
}
},
"value": null,
"rawValue": null,
"raw": "null"
}
}
],
"kind": "let"
},
{
"type": "TryStatement",
"start": 916,
"end": 1191,
"loc": {
"start": {
"line": 31,
"column": 4
},
"end": {
"line": 44,
"column": 5
}
},
"block": {
"type": "BlockStatement",
"start": 920,
"end": 1040,
"loc": {
"start": {
"line": 31,
"column": 8
},
"end": {
"line": 37,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 928,
"end": 962,
"loc": {
"start": {
"line": 32,
"column": 6
},
"end": {
"line": 32,
"column": 40
}
},
"expression": {
"type": "AssignmentExpression",
"start": 928,
"end": 961,
"loc": {
"start": {
"line": 32,
"column": 6
},
"end": {
"line": 32,