UNPKG

@eastsideco/escshopify

Version:

WIP JS library for Shopify, containing a variety of useful functionality.

1,510 lines (1,509 loc) 125 kB
{ "type": "File", "start": 0, "end": 836, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 42, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 836, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 42, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 24, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 24 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 7, "end": 10, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 10 } }, "local": { "type": "Identifier", "start": 7, "end": 10, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 10 }, "identifierName": "Log" }, "name": "Log" } } ], "source": { "type": "StringLiteral", "start": 16, "end": 23, "loc": { "start": { "line": 1, "column": 16 }, "end": { "line": 1, "column": 23 } }, "extra": { "rawValue": "./Log", "raw": "'./Log'" }, "value": "./Log" }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * General-purpose utilties.\n ", "start": 26, "end": 62, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 5, "column": 3 } } } ] }, { "type": "Identifier", "start": 63, "end": 785, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 37, "column": 1 } }, "id": { "type": "Identifier", "start": 69, "end": 81, "loc": { "start": { "line": 6, "column": 6 }, "end": { "line": 6, "column": 18 }, "identifierName": "GeneralUtils" }, "name": "GeneralUtils", "leadingComments": null }, "superClass": null, "body": { "type": "ClassBody", "start": 82, "end": 785, "loc": { "start": { "line": 6, "column": 19 }, "end": { "line": 37, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 88, "end": 177, "loc": { "start": { "line": 7, "column": 4 }, "end": { "line": 10, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 88, "end": 99, "loc": { "start": { "line": 7, "column": 4 }, "end": { "line": 7, "column": 15 }, "identifierName": "constructor" }, "name": "constructor" }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 102, "end": 177, "loc": { "start": { "line": 7, "column": 18 }, "end": { "line": 10, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 156, "end": 171, "loc": { "start": { "line": 9, "column": 8 }, "end": { "line": 9, "column": 23 } }, "expression": { "type": "AssignmentExpression", "start": 156, "end": 170, "loc": { "start": { "line": 9, "column": 8 }, "end": { "line": 9, "column": 22 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 156, "end": 164, "loc": { "start": { "line": 9, "column": 8 }, "end": { "line": 9, "column": 16 } }, "object": { "type": "ThisExpression", "start": 156, "end": 160, "loc": { "start": { "line": 9, "column": 8 }, "end": { "line": 9, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 161, "end": 164, "loc": { "start": { "line": 9, "column": 13 }, "end": { "line": 9, "column": 16 }, "identifierName": "Log" }, "name": "Log" }, "computed": false, "leadingComments": null }, "right": { "type": "Identifier", "start": 167, "end": 170, "loc": { "start": { "line": 9, "column": 19 }, "end": { "line": 9, "column": 22 }, "identifierName": "Log" }, "name": "Log" }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* @type {src/utils/Log.js~Log} ", "start": 112, "end": 147, "loc": { "start": { "line": 8, "column": 8 }, "end": { "line": 8, "column": 43 } } } ] } ], "directives": [], "trailingComments": null }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Executes the given callback on DOMContentLoaded.\n * @param {function(): void} callback\n ", "start": 184, "end": 290, "loc": { "start": { "line": 13, "column": 4 }, "end": { "line": 16, "column": 6 } } } ] }, { "type": "ClassMethod", "start": 295, "end": 528, "loc": { "start": { "line": 17, "column": 4 }, "end": { "line": 25, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 295, "end": 301, "loc": { "start": { "line": 17, "column": 4 }, "end": { "line": 17, "column": 10 }, "identifierName": "onLoad" }, "name": "onLoad", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 302, "end": 310, "loc": { "start": { "line": 17, "column": 11 }, "end": { "line": 17, "column": 19 }, "identifierName": "callback" }, "name": "callback" } ], "body": { "type": "BlockStatement", "start": 312, "end": 528, "loc": { "start": { "line": 17, "column": 21 }, "end": { "line": 25, "column": 5 } }, "body": [ { "type": "IfStatement", "start": 322, "end": 522, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 24, "column": 9 } }, "test": { "type": "BinaryExpression", "start": 326, "end": 358, "loc": { "start": { "line": 18, "column": 12 }, "end": { "line": 18, "column": 44 } }, "left": { "type": "MemberExpression", "start": 326, "end": 345, "loc": { "start": { "line": 18, "column": 12 }, "end": { "line": 18, "column": 31 } }, "object": { "type": "Identifier", "start": 326, "end": 334, "loc": { "start": { "line": 18, "column": 12 }, "end": { "line": 18, "column": 20 }, "identifierName": "document" }, "name": "document" }, "property": { "type": "Identifier", "start": 335, "end": 345, "loc": { "start": { "line": 18, "column": 21 }, "end": { "line": 18, "column": 31 }, "identifierName": "readyState" }, "name": "readyState" }, "computed": false }, "operator": "!=", "right": { "type": "StringLiteral", "start": 349, "end": 358, "loc": { "start": { "line": 18, "column": 35 }, "end": { "line": 18, "column": 44 } }, "extra": { "rawValue": "loading", "raw": "'loading'" }, "value": "loading" } }, "consequent": { "type": "BlockStatement", "start": 360, "end": 395, "loc": { "start": { "line": 18, "column": 46 }, "end": { "line": 20, "column": 9 } }, "body": [ { "type": "ExpressionStatement", "start": 374, "end": 385, "loc": { "start": { "line": 19, "column": 12 }, "end": { "line": 19, "column": 23 } }, "expression": { "type": "CallExpression", "start": 374, "end": 384, "loc": { "start": { "line": 19, "column": 12 }, "end": { "line": 19, "column": 22 } }, "callee": { "type": "Identifier", "start": 374, "end": 382, "loc": { "start": { "line": 19, "column": 12 }, "end": { "line": 19, "column": 20 }, "identifierName": "callback" }, "name": "callback" }, "arguments": [] } } ], "directives": [] }, "alternate": { "type": "BlockStatement", "start": 401, "end": 522, "loc": { "start": { "line": 20, "column": 15 }, "end": { "line": 24, "column": 9 } }, "body": [ { "type": "ExpressionStatement", "start": 415, "end": 512, "loc": { "start": { "line": 21, "column": 12 }, "end": { "line": 23, "column": 15 } }, "expression": { "type": "CallExpression", "start": 415, "end": 511, "loc": { "start": { "line": 21, "column": 12 }, "end": { "line": 23, "column": 14 } }, "callee": { "type": "MemberExpression", "start": 415, "end": 440, "loc": { "start": { "line": 21, "column": 12 }, "end": { "line": 21, "column": 37 } }, "object": { "type": "Identifier", "start": 415, "end": 423, "loc": { "start": { "line": 21, "column": 12 }, "end": { "line": 21, "column": 20 }, "identifierName": "document" }, "name": "document" }, "property": { "type": "Identifier", "start": 424, "end": 440, "loc": { "start": { "line": 21, "column": 21 }, "end": { "line": 21, "column": 37 }, "identifierName": "addEventListener" }, "name": "addEventListener" }, "computed": false }, "arguments": [ { "type": "StringLiteral", "start": 441, "end": 459, "loc": { "start": { "line": 21, "column": 38 }, "end": { "line": 21, "column": 56 } }, "extra": { "rawValue": "DOMContentLoaded", "raw": "'DOMContentLoaded'" }, "value": "DOMContentLoaded" }, { "type": "ArrowFunctionExpression", "start": 461, "end": 510, "loc": { "start": { "line": 21, "column": 58 }, "end": { "line": 23, "column": 13 } }, "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 467, "end": 510, "loc": { "start": { "line": 21, "column": 64 }, "end": { "line": 23, "column": 13 } }, "body": [ { "type": "ExpressionStatement", "start": 485, "end": 496, "loc": { "start": { "line": 22, "column": 16 }, "end": { "line": 22, "column": 27 } }, "expression": { "type": "CallExpression", "start": 485, "end": 495, "loc": { "start": { "line": 22, "column": 16 }, "end": { "line": 22, "column": 26 } }, "callee": { "type": "Identifier", "start": 485, "end": 493, "loc": { "start": { "line": 22, "column": 16 }, "end": { "line": 22, "column": 24 }, "identifierName": "callback" }, "name": "callback" }, "arguments": [] } } ], "directives": [] } } ] } } ], "directives": [] } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Executes the given callback on DOMContentLoaded.\n * @param {function(): void} callback\n ", "start": 184, "end": 290, "loc": { "start": { "line": 13, "column": 4 }, "end": { "line": 16, "column": 6 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Create a unique key suitable for storing in localStorage, etc.\n * @param {String}\tnamespace\n * @param {String}\tkey\n * @return {String}\n ", "start": 535, "end": 700, "loc": { "start": { "line": 28, "column": 4 }, "end": { "line": 33, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 705, "end": 783, "loc": { "start": { "line": 34, "column": 4 }, "end": { "line": 36, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 705, "end": 719, "loc": { "start": { "line": 34, "column": 4 }, "end": { "line": 34, "column": 18 }, "identifierName": "safeStorageKey" }, "name": "safeStorageKey", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 720, "end": 729, "loc": { "start": { "line": 34, "column": 19 }, "end": { "line": 34, "column": 28 }, "identifierName": "namespace" }, "name": "namespace" }, { "type": "Identifier", "start": 731, "end": 734, "loc": { "start": { "line": 34, "column": 30 }, "end": { "line": 34, "column": 33 }, "identifierName": "key" }, "name": "key" } ], "body": { "type": "BlockStatement", "start": 736, "end": 783, "loc": { "start": { "line": 34, "column": 35 }, "end": { "line": 36, "column": 5 } }, "body": [ { "type": "ReturnStatement", "start": 746, "end": 777, "loc": { "start": { "line": 35, "column": 8 }, "end": { "line": 35, "column": 39 } }, "argument": { "type": "BinaryExpression", "start": 753, "end": 776, "loc": { "start": { "line": 35, "column": 15 }, "end": { "line": 35, "column": 38 } }, "left": { "type": "BinaryExpression", "start": 753, "end": 772, "loc": { "start": { "line": 35, "column": 15 }, "end": { "line": 35, "column": 34 } }, "left": { "type": "BinaryExpression", "start": 753, "end": 767, "loc": { "start": { "line": 35, "column": 15 }, "end": { "line": 35, "column": 29 } }, "left": { "type": "StringLiteral", "start": 753, "end": 757, "loc": { "start": { "line": 35, "column": 15 }, "end": { "line": 35, "column": 19 } }, "extra": { "rawValue": "__", "raw": "'__'" }, "value": "__" }, "operator": "+", "right": { "type": "Identifier", "start": 758, "end": 767, "loc": { "start": { "line": 35, "column": 20 }, "end": { "line": 35, "column": 29 }, "identifierName": "namespace" }, "name": "namespace" } }, "operator": "+", "right": { "type": "StringLiteral", "start": 768, "end": 772, "loc": { "start": { "line": 35, "column": 30 }, "end": { "line": 35, "column": 34 } }, "extra": { "rawValue": "__", "raw": "'__'" }, "value": "__" } }, "operator": "+", "right": { "type": "Identifier", "start": 773, "end": 776, "loc": { "start": { "line": 35, "column": 35 }, "end": { "line": 35, "column": 38 }, "identifierName": "key" }, "name": "key" } } } ], "directives": [] }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Create a unique key suitable for storing in localStorage, etc.\n * @param {String}\tnamespace\n * @param {String}\tkey\n * @return {String}\n ", "start": 535, "end": 700, "loc": { "start": { "line": 28, "column": 4 }, "end": { "line": 33, "column": 7 } } } ] } ], "trailingComments": null }, "leadingComments": [], "trailingComments": [], "name": "_" }, { "type": "Identifier", "start": 803, "end": 835, "loc": { "start": { "line": 41, "column": 0 }, "end": { "line": 41, "column": 32 } }, "declaration": { "type": "NewExpression", "start": 818, "end": 834, "loc": { "start": { "line": 41, "column": 15 }, "end": { "line": 41, "column": 31 } }, "callee": { "type": "Identifier", "start": 822, "end": 834, "loc": { "start": { "line": 41, "column": 19 }, "end": { "line": 41, "column": 31 }, "identifierName": "GeneralUtils" }, "name": "GeneralUtils" }, "arguments": [], "leadingComments": null }, "leadingComments": [], "name": "_", "trailingComments": [] }, { "type": "ExportDefaultDeclaration", "start": 803, "end": 835, "loc": { "start": { "line": 41, "column": 0 }, "end": { "line": 41, "column": 32 } }, "declaration": { "type": "ClassDeclaration", "start": 63, "end": 785, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 37, "column": 1 } }, "id": { "type": "Identifier", "start": 69, "end": 81, "loc": { "start": { "line": 6, "column": 6 }, "end": { "line": 6, "column": 18 }, "identifierName": "GeneralUtils" }, "name": "GeneralUtils", "leadingComments": null }, "superClass": null, "body": { "type": "ClassBody", "start": 82, "end": 785, "loc": { "start": { "line": 6, "column": 19 }, "end": { "line": 37, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 88, "end": 177, "loc": { "start": { "line": 7, "column": 4 }, "end": { "line": 10, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 88, "end": 99, "loc": { "start": { "line": 7, "column": 4 }, "end": { "line": 7, "column": 15 }, "identifierName": "constructor" }, "name": "constructor" }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 102, "end": 177, "loc": { "start": { "line": 7, "column": 18 }, "end": { "line": 10, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 156, "end": 171, "loc": { "start": { "line": 9, "column": 8 }, "end": { "line": 9, "column": 23 } }, "expression": { "type": "AssignmentExpression", "start": 156, "end": 170, "loc": { "start": { "line": 9, "column": 8 }, "end": { "line": 9, "column": 22 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 156, "end": 164, "loc": { "start": { "line": 9, "column": 8 }, "end": { "line": 9, "column": 16 } }, "object": { "type": "ThisExpression", "start": 156, "end": 160, "loc": { "start": { "line": 9, "column": 8 }, "end": { "line": 9, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 161, "end": 164, "loc": { "start": { "line": 9, "column": 13 }, "end": { "line": 9, "column": 16 }, "identifierName": "Log" }, "name": "Log" }, "computed": false, "leadingComments": null }, "right": { "type": "Identifier", "start": 167, "end": 170, "loc": { "start": { "line": 9, "column": 19 }, "end": { "line": 9, "column": 22 }, "identifierName": "Log" }, "name": "Log" }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* @type {src/utils/Log.js~Log} ", "start": 112, "end": 147, "loc": { "start": { "line": 8, "column": 8 }, "end": { "line": 8, "column": 43 } } } ] } ], "directives": [], "trailingComments": null }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Executes the given callback on DOMContentLoaded.\n * @param {function(): void} callback\n ", "start": 184, "end": 290, "loc": { "start": { "line": 13, "column": 4 }, "end": { "line": 16, "column": 6 } } } ] }, { "type": "ClassMethod", "start": 295, "end": 528, "loc": { "start": { "line": 17, "column": 4 }, "end": { "line": 25, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 295, "end": 301, "loc": { "start": { "line": 17, "column": 4 }, "end": { "line": 17, "column": 10 }, "identifierName": "onLoad" }, "name": "onLoad", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 302, "end": 310, "loc": { "start": { "line": 17, "column": 11 }, "end": { "line": 17, "column": 19 }, "identifierName": "callback" }, "name": "callback" } ], "body": { "type": "BlockStatement", "start": 312, "end": 528, "loc": { "start": { "line": 17, "column": 21 }, "end": { "line": 25, "column": 5 } }, "body": [ { "type": "IfStatement", "start": 322, "end": 522, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 24, "column": 9 } }, "test": { "type": "BinaryExpression", "start": 326, "end": 358, "loc": { "start": { "line": 18, "column": 12 }, "end": { "line": 18, "column": 44