UNPKG

rizzo-next

Version:

The next generation of Lonely Planet's style guide and pattern library.

1,141 lines 52.8 kB
{ "type": "Program", "start": 0, "end": 1518, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 57, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 47, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 47 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 7, "end": 17, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 17 } }, "local": { "type": "Identifier", "start": 7, "end": 17, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 17 } }, "name": "trackEvent" } } ], "importKind": "value", "source": { "type": "Literal", "start": 23, "end": 46, "loc": { "start": { "line": 1, "column": 23 }, "end": { "line": 1, "column": 46 } }, "value": "../events/track_event", "rawValue": "../events/track_event", "raw": "\"../events/track_event\"" }, "trailingComments": [ { "type": "Block", "value": "*\n * Use when you need to track a method call w/ the `trackEvent` utility.\n * The value returned will be passed as `data` to `trackEvent`.\n * If a function is used for the `trackingFn`, it must return an object w/ a `name`, and optional `data`\n * @param {Function|String} trackingFn Either a function to build up the event data or a string event name.\n * @param {Object} [options] An opject of options\n * @return {Function} The decorator function\n * @example <caption>String Tracking</caption>\n *\n * class Foo {\n * @track(\"Button Clicked\")\n * buttonClicked() {\n * // ...\n * return { some: \"data\" };\n * }\n * }\n * @example <caption>Function</caption>\n *\n * import FooTracker from \"./foo.tracker\";\n * \n * class Foo {\n * @track(FooTracker.clicked)\n * buttonClicked() {\n * // ...\n * return { some: \"data\" };\n * }\n * }\n *\n * // foo.tracker.js\n *\n * export default function clicked(data) {\n * // data = { some: \"data\" } \n * data.otherData = \"other data\";\n * \n * return { \n * name: \"Button Clicked\",\n * data\n * };\n * }\n * \n ", "start": 49, "end": 1117, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 43, "column": 3 } }, "range": [ 49, 1117 ] } ] }, { "type": "ExportDefaultDeclaration", "start": 1118, "end": 1517, "loc": { "start": { "line": 44, "column": 0 }, "end": { "line": 56, "column": 1 } }, "declaration": { "type": "FunctionDeclaration", "start": 1133, "end": 1517, "loc": { "start": { "line": 44, "column": 15 }, "end": { "line": 56, "column": 1 } }, "id": { "type": "Identifier", "start": 1142, "end": 1147, "loc": { "start": { "line": 44, "column": 24 }, "end": { "line": 44, "column": 29 } }, "name": "track", "leadingComments": null }, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 1148, "end": 1158, "loc": { "start": { "line": 44, "column": 30 }, "end": { "line": 44, "column": 40 } }, "name": "trackingFn" }, { "type": "Identifier", "start": 1160, "end": 1167, "loc": { "start": { "line": 44, "column": 42 }, "end": { "line": 44, "column": 49 } }, "name": "options" } ], "body": { "type": "BlockStatement", "start": 1169, "end": 1517, "loc": { "start": { "line": 44, "column": 51 }, "end": { "line": 56, "column": 1 } }, "body": [ { "type": "ReturnStatement", "start": 1173, "end": 1515, "loc": { "start": { "line": 45, "column": 2 }, "end": { "line": 55, "column": 4 } }, "argument": { "type": "FunctionExpression", "start": 1180, "end": 1514, "loc": { "start": { "line": 45, "column": 9 }, "end": { "line": 55, "column": 3 } }, "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 1189, "end": 1195, "loc": { "start": { "line": 45, "column": 18 }, "end": { "line": 45, "column": 24 } }, "name": "target" }, { "type": "Identifier", "start": 1197, "end": 1201, "loc": { "start": { "line": 45, "column": 26 }, "end": { "line": 45, "column": 30 } }, "name": "name" }, { "type": "Identifier", "start": 1203, "end": 1213, "loc": { "start": { "line": 45, "column": 32 }, "end": { "line": 45, "column": 42 } }, "name": "descriptor" } ], "body": { "type": "BlockStatement", "start": 1215, "end": 1514, "loc": { "start": { "line": 45, "column": 44 }, "end": { "line": 55, "column": 3 } }, "body": [ { "type": "VariableDeclaration", "start": 1221, "end": 1249, "loc": { "start": { "line": 46, "column": 4 }, "end": { "line": 46, "column": 32 } }, "declarations": [ { "type": "VariableDeclarator", "start": 1227, "end": 1248, "loc": { "start": { "line": 46, "column": 10 }, "end": { "line": 46, "column": 31 } }, "id": { "type": "Identifier", "start": 1227, "end": 1229, "loc": { "start": { "line": 46, "column": 10 }, "end": { "line": 46, "column": 12 } }, "name": "fn" }, "init": { "type": "MemberExpression", "start": 1232, "end": 1248, "loc": { "start": { "line": 46, "column": 15 }, "end": { "line": 46, "column": 31 } }, "object": { "type": "Identifier", "start": 1232, "end": 1242, "loc": { "start": { "line": 46, "column": 15 }, "end": { "line": 46, "column": 25 } }, "name": "descriptor" }, "property": { "type": "Identifier", "start": 1243, "end": 1248, "loc": { "start": { "line": 46, "column": 26 }, "end": { "line": 46, "column": 31 } }, "name": "value" }, "computed": false } } ], "kind": "const" }, { "type": "ExpressionStatement", "start": 1255, "end": 1510, "loc": { "start": { "line": 48, "column": 4 }, "end": { "line": 54, "column": 6 } }, "expression": { "type": "AssignmentExpression", "start": 1255, "end": 1509, "loc": { "start": { "line": 48, "column": 4 }, "end": { "line": 54, "column": 5 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1255, "end": 1271, "loc": { "start": { "line": 48, "column": 4 }, "end": { "line": 48, "column": 20 } }, "object": { "type": "Identifier", "start": 1255, "end": 1265, "loc": { "start": { "line": 48, "column": 4 }, "end": { "line": 48, "column": 14 } }, "name": "descriptor" }, "property": { "type": "Identifier", "start": 1266, "end": 1271, "loc": { "start": { "line": 48, "column": 15 }, "end": { "line": 48, "column": 20 } }, "name": "value" }, "computed": false }, "right": { "type": "FunctionExpression", "start": 1274, "end": 1509, "loc": { "start": { "line": 48, "column": 23 }, "end": { "line": 54, "column": 5 } }, "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 1285, "end": 1509, "loc": { "start": { "line": 48, "column": 34 }, "end": { "line": 54, "column": 5 } }, "body": [ { "type": "VariableDeclaration", "start": 1293, "end": 1331, "loc": { "start": { "line": 49, "column": 6 }, "end": { "line": 49, "column": 44 } }, "declarations": [ { "type": "VariableDeclarator", "start": 1297, "end": 1330, "loc": { "start": { "line": 49, "column": 10 }, "end": { "line": 49, "column": 43 } }, "id": { "type": "Identifier", "start": 1297, "end": 1302, "loc": { "start": { "line": 49, "column": 10 }, "end": { "line": 49, "column": 15 } }, "name": "value" }, "init": { "type": "CallExpression", "start": 1305, "end": 1330, "loc": { "start": { "line": 49, "column": 18 }, "end": { "line": 49, "column": 43 } }, "callee": { "type": "MemberExpression", "start": 1305, "end": 1313, "loc": { "start": { "line": 49, "column": 18 }, "end": { "line": 49, "column": 26 } }, "object": { "type": "Identifier", "start": 1305, "end": 1307, "loc": { "start": { "line": 49, "column": 18 }, "end": { "line": 49, "column": 20 } }, "name": "fn" }, "property": { "type": "Identifier", "start": 1308, "end": 1313, "loc": { "start": { "line": 49, "column": 21 }, "end": { "line": 49, "column": 26 } }, "name": "apply" }, "computed": false }, "arguments": [ { "type": "ThisExpression", "start": 1314, "end": 1318, "loc": { "start": { "line": 49, "column": 27 }, "end": { "line": 49, "column": 31 } } }, { "type": "Identifier", "start": 1320, "end": 1329, "loc": { "start": { "line": 49, "column": 33 }, "end": { "line": 49, "column": 42 } }, "name": "arguments" } ] } } ], "kind": "let" }, { "type": "ExpressionStatement", "start": 1345, "end": 1482, "loc": { "start": { "line": 51, "column": 6 }, "end": { "line": 51, "column": 143 } }, "expression": { "type": "CallExpression", "start": 1345, "end": 1481, "loc": { "start": { "line": 51, "column": 6 }, "end": { "line": 51, "column": 142 } }, "callee": { "type": "Identifier", "start": 1345, "end": 1355, "loc": { "start": { "line": 51, "column": 6 }, "end": { "line": 51, "column": 16 } }, "name": "trackEvent" }, "arguments": [ { "type": "ConditionalExpression", "start": 1356, "end": 1480, "loc": { "start": { "line": 51, "column": 17 }, "end": { "line": 51, "column": 141 } }, "test": { "type": "BinaryExpression", "start": 1356, "end": 1386, "loc": { "start": { "line": 51, "column": 17 }, "end": { "line": 51, "column": 47 } }, "left": { "type": "UnaryExpression", "start": 1356, "end": 1373, "loc": { "start": { "line": 51, "column": 17 }, "end": { "line": 51, "column": 34 } }, "operator": "typeof", "prefix": true, "argument": { "type": "Identifier", "start": 1363, "end": 1373, "loc": { "start": { "line": 51, "column": 24 }, "end": { "line": 51, "column": 34 } }, "name": "trackingFn" } }, "operator": "===", "right": { "type": "Literal", "start": 1378, "end": 1386, "loc": { "start": { "line": 51, "column": 39 }, "end": { "line": 51, "column": 47 } }, "value": "string", "rawValue": "string", "raw": "\"string\"" } }, "consequent": { "type": "CallExpression", "start": 1389, "end": 1446, "loc": { "start": { "line": 51, "column": 50 }, "end": { "line": 51, "column": 107 } }, "callee": { "type": "MemberExpression", "start": 1389, "end": 1402, "loc": { "start": { "line": 51, "column": 50 }, "end": { "line": 51, "column": 63 } }, "object": { "type": "Identifier", "start": 1389, "end": 1395, "loc": { "start": { "line": 51, "column": 50 }, "end": { "line": 51, "column": 56 } }, "name": "Object" }, "property": { "type": "Identifier", "start": 1396, "end": 1402, "loc": { "start": { "line": 51, "column": 57 }, "end": { "line": 51, "column": 63 } }, "name": "assign" }, "computed": false }, "arguments": [ { "type": "ObjectExpression", "start": 1403, "end": 1436, "loc": { "start": { "line": 51, "column": 64 }, "end": { "line": 51, "column": 97 } }, "properties": [ { "type": "Property", "start": 1405, "end": 1421, "loc": { "start": { "line": 51, "column": 66 }, "end": { "line": 51, "column": 82 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 1405, "end": 1409, "loc": { "start": { "line": 51, "column": 66 }, "end": { "line": 51, "column": 70 } }, "name": "name" }, "value": { "type": "Identifier", "start": 1411, "end": 1421, "loc": { "start": { "line": 51, "column": 72 }, "end": { "line": 51, "column": 82 } }, "name": "trackingFn" }, "kind": "init" }, { "type": "Property", "start": 1423, "end": 1434, "loc": { "start": { "line": 51, "column": 84 }, "end": { "line": 51, "column": 95 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 1423, "end": 1427, "loc": { "start": { "line": 51, "column": 84 }, "end": { "line": 51, "column": 88 } }, "name": "data" }, "value": { "type": "Identifier", "start": 1429, "end": 1434, "loc": { "start": { "line": 51, "column": 90 }, "end": { "line": 51, "column": 95 } }, "name": "value" }, "kind": "init" } ] }, { "type": "Identifier", "start": 1438, "end": 1445, "loc": { "start": { "line": 51, "column": 99 }, "end": { "line": 51, "column": 106 } }, "name": "options" } ] }, "alternate": { "type": "CallExpression", "start": 1449, "end": 1480, "loc": { "start": { "line": 51, "column": 110 }, "end": { "line": 51, "column": 141 } }, "callee": { "type": "MemberExpression", "start": 1449, "end": 1465, "loc": { "start": { "line": 51, "column": 110 }, "end": { "line": 51, "column": 126 } }, "object": { "type": "Identifier", "start": 1449, "end": 1459, "loc": { "start": { "line": 51, "column": 110 }, "end": { "line": 51, "column": 120 } }, "name": "trackingFn" }, "property": { "type": "Identifier", "start": 1460, "end": 1465, "loc": { "start": { "line": 51, "column": 121 }, "end": { "line": 51, "column": 126 } }, "name": "apply" }, "computed": false }, "arguments": [ { "type": "ThisExpression", "start": 1466, "end": 1470, "loc": { "start": { "line": 51, "column": 127 }, "end": { "line": 51, "column": 131 } } }, { "type": "ArrayExpression", "start": 1472, "end": 1479, "loc": { "start": { "line": 51, "column": 133 }, "end": { "line": 51, "column": 140 } }, "elements": [ { "type": "Identifier", "start": 1473, "end": 1478, "loc": { "start": { "line": 51, "column": 134 }, "end": { "line": 51, "column": 139 } }, "name": "value" } ] } ] } } ] } }, { "type": "ReturnStatement", "start": 1490, "end": 1503, "loc": { "start": { "line": 53, "column": 6 }, "end": { "line": 53, "column": 19 } }, "argument": { "type": "Identifier", "start": 1497, "end": 1502, "loc": { "start": { "line": 53, "column": 13 }, "end": { "line": 53, "column": 18 } }, "name": "value" } } ] } } } } ] } } } ] }, "leadingComments": [ { "type": "Block", "value": "*\n * Use when you need to track a method call w/ the `trackEvent` utility.\n * The value returned will be passed as `data` to `trackEvent`.\n * If a function is used for the `trackingFn`, it must return an object w/ a `name`, and optional `data`\n * @param {Function|String} trackingFn Either a function to build up the event dat