@marko/compiler 5.20.6 → 5.20.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,65 +0,0 @@
1
- "use strict";exports.__esModule = true;exports.default = void 0;var _babelUtils = require("@marko/babel-utils");
2
- var t = _interopRequireWildcard(require("../../babel-types"));function _getRequireWildcardCache(nodeInterop) {if (typeof WeakMap !== "function") return null;var cacheBabelInterop = new WeakMap();var cacheNodeInterop = new WeakMap();return (_getRequireWildcardCache = function (nodeInterop) {return nodeInterop ? cacheNodeInterop : cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj, nodeInterop) {if (!nodeInterop && obj && obj.__esModule) {return obj;}if (obj === null || typeof obj !== "object" && typeof obj !== "function") {return { default: obj };}var cache = _getRequireWildcardCache(nodeInterop);if (cache && cache.has(obj)) {return cache.get(obj);}var newObj = {};var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var key in obj) {if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;if (desc && (desc.get || desc.set)) {Object.defineProperty(newObj, key, desc);} else {newObj[key] = obj[key];}}}newObj.default = obj;if (cache) {cache.set(obj, newObj);}return newObj;}var _default =
3
-
4
- (file, shorthands, attributes) => {
5
- if (!shorthands) {
6
- return attributes;
7
- }
8
-
9
- const classAttr = attributes.find(({ name }) => name === "class");
10
- const classParts = shorthands.map(({ rawParts }) => {
11
- const nodes = rawParts.map((part) =>
12
- part.expression ?
13
- (0, _babelUtils.parseExpression)(file, part.expression, part.pos) :
14
- (0, _babelUtils.withLoc)(file, t.stringLiteral(part.text), part.pos, part.endPos));
15
-
16
-
17
- if (nodes.length === 1) {
18
- return nodes[0];
19
- }
20
-
21
- return nodes.reduce((a, b) => t.binaryExpression("+", a, b));
22
- });
23
-
24
- let shorthandNode;
25
- if (classParts.length === 1) {
26
- shorthandNode = classParts[0];
27
- } else if (classParts.every((node) => t.isStringLiteral(node))) {
28
- const combinedStartPos = shorthands[0].rawParts[0].pos;
29
- const lastParts = shorthands[shorthands.length - 1].rawParts;
30
- const combinedEndPos = lastParts[lastParts.length - 1].endPos;
31
- shorthandNode = (0, _babelUtils.withLoc)(
32
- file,
33
- t.stringLiteral(classParts.map((node) => node.value).join(" ")),
34
- combinedStartPos,
35
- combinedEndPos);
36
-
37
- } else {
38
- shorthandNode = t.arrayExpression(classParts);
39
- }
40
-
41
- if (classAttr) {
42
- if (t.isArrayExpression(classAttr.value)) {
43
- if (t.isArrayExpression(shorthandNode)) {
44
- classAttr.value.elements.push(...shorthandNode.elements);
45
- } else {
46
- classAttr.value.elements.push(shorthandNode);
47
- }
48
- } else if (
49
- t.isStringLiteral(classAttr.value) &&
50
- t.isStringLiteral(shorthandNode))
51
- {
52
- classAttr.value.value = `${shorthandNode.value} ${classAttr.value.value}`;
53
- } else if (t.isArrayExpression(shorthandNode)) {
54
- shorthandNode.elements.push(classAttr.value);
55
- classAttr.value = shorthandNode;
56
- } else {
57
- classAttr.value = t.arrayExpression([shorthandNode, classAttr.value]);
58
- }
59
- } else {
60
- attributes.push(t.markoAttribute("class", shorthandNode));
61
- }
62
-
63
- return attributes;
64
- };exports.default = _default;
65
- //# sourceMappingURL=parse-classname-shorthand.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/babel-plugin/util/parse-classname-shorthand.js"],"names":["file","shorthands","attributes","classAttr","find","name","classParts","map","rawParts","nodes","part","expression","pos","t","stringLiteral","text","endPos","length","reduce","a","b","binaryExpression","shorthandNode","every","node","isStringLiteral","combinedStartPos","lastParts","combinedEndPos","value","join","arrayExpression","isArrayExpression","elements","push","markoAttribute"],"mappings":"gEAAA;AACA,8D;;AAEe,CAACA,IAAD,EAAOC,UAAP,EAAmBC,UAAnB,KAAkC;AAC/C,MAAI,CAACD,UAAL,EAAiB;AACf,WAAOC,UAAP;AACD;;AAED,QAAMC,SAAS,GAAG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AC0B,KAAV,GAAkBP,aAAlB;AACD,KAHM,MAGA;AACLnB,MAAAA,SAAS,CAAC0B,KAAV,GAAkBhB,CAAC,CAACkB,eAAF,CAAkB,CAACT,aAAD,EAAgBnB,SAAS,CAAC0B,KAA1B,CAAlB,CAAlB;AACD;AACF,GAlBD,MAkBO;AACL3B,IAAAA,UAAU,CAACgC,IAAX,CAAgBrB,CAAC,CAACsB,cAAF,CAAiB,OAAjB,EAA0Bb,aAA1B,CAAhB;AACD;;AAED,SAAOpB,UAAP;AACD,C","sourcesContent":["import { withLoc, parseExpression } from \"@marko/babel-utils\";\nimport * as t from \"../../babel-types\";\n\nexport default (file, shorthands, attributes) => {\n if (!shorthands) {\n return attributes;\n }\n\n const classAttr = attributes.find(({ name }) => name === \"class\");\n const classParts = shorthands.map(({ rawParts }) => {\n const nodes = rawParts.map(part =>\n part.expression\n ? parseExpression(file, part.expression, part.pos)\n : withLoc(file, t.stringLiteral(part.text), part.pos, part.endPos)\n );\n\n if (nodes.length === 1) {\n return nodes[0];\n }\n\n return nodes.reduce((a, b) => t.binaryExpression(\"+\", a, b));\n });\n\n let shorthandNode;\n if (classParts.length === 1) {\n shorthandNode = classParts[0];\n } else if (classParts.every(node => t.isStringLiteral(node))) {\n const combinedStartPos = shorthands[0].rawParts[0].pos;\n const lastParts = shorthands[shorthands.length - 1].rawParts;\n const combinedEndPos = lastParts[lastParts.length - 1].endPos;\n shorthandNode = withLoc(\n file,\n t.stringLiteral(classParts.map(node => node.value).join(\" \")),\n combinedStartPos,\n combinedEndPos\n );\n } else {\n shorthandNode = t.arrayExpression(classParts);\n }\n\n if (classAttr) {\n if (t.isArrayExpression(classAttr.value)) {\n if (t.isArrayExpression(shorthandNode)) {\n classAttr.value.elements.push(...shorthandNode.elements);\n } else {\n classAttr.value.elements.push(shorthandNode);\n }\n } else if (\n t.isStringLiteral(classAttr.value) &&\n t.isStringLiteral(shorthandNode)\n ) {\n classAttr.value.value = `${shorthandNode.value} ${classAttr.value.value}`;\n } else if (t.isArrayExpression(shorthandNode)) {\n shorthandNode.elements.push(classAttr.value);\n classAttr.value = shorthandNode;\n } else {\n classAttr.value = t.arrayExpression([shorthandNode, classAttr.value]);\n }\n } else {\n attributes.push(t.markoAttribute(\"class\", shorthandNode));\n }\n\n return attributes;\n};\n"],"file":"parse-classname-shorthand.js"}
@@ -1,34 +0,0 @@
1
- "use strict";exports.__esModule = true;exports.default = void 0;var _babelUtils = require("@marko/babel-utils");
2
- var t = _interopRequireWildcard(require("../../babel-types"));function _getRequireWildcardCache(nodeInterop) {if (typeof WeakMap !== "function") return null;var cacheBabelInterop = new WeakMap();var cacheNodeInterop = new WeakMap();return (_getRequireWildcardCache = function (nodeInterop) {return nodeInterop ? cacheNodeInterop : cacheBabelInterop;})(nodeInterop);}function _interopRequireWildcard(obj, nodeInterop) {if (!nodeInterop && obj && obj.__esModule) {return obj;}if (obj === null || typeof obj !== "object" && typeof obj !== "function") {return { default: obj };}var cache = _getRequireWildcardCache(nodeInterop);if (cache && cache.has(obj)) {return cache.get(obj);}var newObj = {};var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var key in obj) {if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;if (desc && (desc.get || desc.set)) {Object.defineProperty(newObj, key, desc);} else {newObj[key] = obj[key];}}}newObj.default = obj;if (cache) {cache.set(obj, newObj);}return newObj;}var _default =
3
-
4
- (file, shorthand, attributes) => {
5
- if (!shorthand) {
6
- return attributes;
7
- }
8
-
9
- const idAttr = attributes.find(({ name }) => name === "id");
10
- if (idAttr) {
11
- throw file.buildCodeFrameError(
12
- idAttr,
13
- "Cannot have shorthand id and id attribute.");
14
-
15
- }
16
-
17
- const idParts = shorthand.rawParts.map((part) =>
18
- part.expression ?
19
- (0, _babelUtils.parseExpression)(file, part.expression, part.pos) :
20
- (0, _babelUtils.withLoc)(file, t.stringLiteral(part.text), part.pos, part.endPos));
21
-
22
-
23
- attributes.push(
24
- t.markoAttribute(
25
- "id",
26
- idParts.length === 1 ?
27
- idParts[0] :
28
- idParts.reduce((a, b) => t.binaryExpression("+", a, b))));
29
-
30
-
31
-
32
- return attributes;
33
- };exports.default = _default;
34
- //# sourceMappingURL=parse-id-shorthand.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/babel-plugin/util/parse-id-shorthand.js"],"names":["file","shorthand","attributes","idAttr","find","name","buildCodeFrameError","idParts","rawParts","map","part","expression","pos","t","stringLiteral","text","endPos","push","markoAttribute","length","reduce","a","b","binaryExpression"],"mappings":"gEAAA;AACA,8D;;AAEe,CAACA,IAAD,EAAOC,SAAP,EAAkBC,UAAlB,KAAiC;AAC9C,MAAI,CAACD,SAAL,EAAgB;AACd,WAAOC,UAAP;AACD;;AAED,QAAMC,MAAM,GAAGD,UAAU,CAACE,IAAX,CAAgB,CAAC,EAAEC,IAAF,EAAD,KAAcA,IAAI,KAAK,IAAvC,CAAf;AACA,MAAIF,MAAJ,EAAY;AACV,UAAMH,IAAI,CAACM,mBAAL;AACJH,IAAAA,MADI;AAEJ,gDAFI,CAAN;;AAID;;AAED,QAAMI,OAAO,GAAGN,SAAS,CAACO,QAAV,CAAmBC,GAAnB,CAAuB,CAAAC,IAAI;AACzCA,EAAAA,IAAI,CAACC,UAAL;AACI,mCAAgBX,IAAhB,EAAsBU,IAAI,CAACC,UAA3B,EAAuCD,IAAI,CAACE,GAA5C,CADJ;AAEI,2BAAQZ,IAAR,EAAca,CAAC,CAACC,aAAF,CAAgBJ,IAAI,CAACK,IAArB,CAAd,EAA0CL,IAAI,CAACE,GAA/C,EAAoDF,IAAI,CAACM,MAAzD,CAHU,CAAhB;;;AAMAd,EAAAA,UAAU,CAACe,IAAX;AACEJ,EAAAA,CAAC,CAACK,cAAF;AACE,MADF;AAEEX,EAAAA,OAAO,CAACY,MAAR,KAAmB,CAAnB;AACIZ,EAAAA,OAAO,CAAC,CAAD,CADX;AAEIA,EAAAA,OAAO,CAACa,MAAR,CAAe,CAACC,CAAD,EAAIC,CAAJ,KAAUT,CAAC,CAACU,gBAAF,CAAmB,GAAnB,EAAwBF,CAAxB,EAA2BC,CAA3B,CAAzB,CAJN,CADF;;;;AASA,SAAOpB,UAAP;AACD,C","sourcesContent":["import { withLoc, parseExpression } from \"@marko/babel-utils\";\nimport * as t from \"../../babel-types\";\n\nexport default (file, shorthand, attributes) => {\n if (!shorthand) {\n return attributes;\n }\n\n const idAttr = attributes.find(({ name }) => name === \"id\");\n if (idAttr) {\n throw file.buildCodeFrameError(\n idAttr,\n \"Cannot have shorthand id and id attribute.\"\n );\n }\n\n const idParts = shorthand.rawParts.map(part =>\n part.expression\n ? parseExpression(file, part.expression, part.pos)\n : withLoc(file, t.stringLiteral(part.text), part.pos, part.endPos)\n );\n\n attributes.push(\n t.markoAttribute(\n \"id\",\n idParts.length === 1\n ? idParts[0]\n : idParts.reduce((a, b) => t.binaryExpression(\"+\", a, b))\n )\n );\n\n return attributes;\n};\n"],"file":"parse-id-shorthand.js"}
@@ -1,10 +0,0 @@
1
- "use strict";exports.__esModule = true;exports.default = void 0;var _babelUtils = require("@marko/babel-utils");var _default =
2
-
3
- (file, details) => {
4
- if (details) {
5
- return (0, _babelUtils.parseExpression)(file, `(${details.value})=>{}`, details.pos).params;
6
- }
7
-
8
- return [];
9
- };exports.default = _default;
10
- //# sourceMappingURL=parse-params.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/babel-plugin/util/parse-params.js"],"names":["file","details","value","pos","params"],"mappings":"gEAAA,gD;;AAEe,CAACA,IAAD,EAAOC,OAAP,KAAmB;AAChC,MAAIA,OAAJ,EAAa;AACX,WAAO,iCAAgBD,IAAhB,EAAuB,IAAGC,OAAO,CAACC,KAAM,OAAxC,EAAgDD,OAAO,CAACE,GAAxD,EAA6DC,MAApE;AACD;;AAED,SAAO,EAAP;AACD,C","sourcesContent":["import { parseExpression } from \"@marko/babel-utils\";\n\nexport default (file, details) => {\n if (details) {\n return parseExpression(file, `(${details.value})=>{}`, details.pos).params;\n }\n\n return [];\n};\n"],"file":"parse-params.js"}
@@ -1,8 +0,0 @@
1
- "use strict";exports.__esModule = true;exports.default = void 0;var _babelUtils = require("@marko/babel-utils");var _default =
2
-
3
- (file, details) => {
4
- if (details) {
5
- return (0, _babelUtils.parseExpression)(file, `${details.value}=1`, details.pos + 1).left;
6
- }
7
- };exports.default = _default;
8
- //# sourceMappingURL=parse-var.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/babel-plugin/util/parse-var.js"],"names":["file","details","value","pos","left"],"mappings":"gEAAA,gD;;AAEe,CAACA,IAAD,EAAOC,OAAP,KAAmB;AAChC,MAAIA,OAAJ,EAAa;AACX,WAAO,iCAAgBD,IAAhB,EAAuB,GAAEC,OAAO,CAACC,KAAM,IAAvC,EAA4CD,OAAO,CAACE,GAAR,GAAc,CAA1D,EAA6DC,IAApE;AACD;AACF,C","sourcesContent":["import { parseExpression } from \"@marko/babel-utils\";\n\nexport default (file, details) => {\n if (details) {\n return parseExpression(file, `${details.value}=1`, details.pos + 1).left;\n }\n};\n"],"file":"parse-var.js"}