@kuma-ui/compiler
Advanced tools
Comparing version 0.0.0-dev-20231105161834 to 0.0.0-dev-20231112011326
@@ -27,3 +27,2 @@ "use strict"; | ||
var import_ts_morph4 = require("ts-morph"); | ||
var import_ts_pattern3 = require("ts-pattern"); | ||
@@ -50,23 +49,28 @@ // src/collector/decode.ts | ||
var import_ts_morph2 = require("ts-morph"); | ||
var import_ts_pattern = require("ts-pattern"); | ||
var handleJsxExpression = (node) => { | ||
return (0, import_ts_pattern.match)(node).when(import_ts_morph2.Node.isNumericLiteral, (num) => { | ||
return num.getLiteralValue(); | ||
}).when(import_ts_morph2.Node.isStringLiteral, (str) => { | ||
return str.getLiteralValue().trim(); | ||
}).when(import_ts_morph2.Node.isNoSubstitutionTemplateLiteral, (literal) => { | ||
return literal.getLiteralValue().trim(); | ||
}).when(import_ts_morph2.Node.isTrueLiteral, (bool) => { | ||
return bool.getLiteralValue(); | ||
}).when(import_ts_morph2.Node.isFalseLiteral, (bool) => { | ||
return bool.getLiteralValue(); | ||
}).when(import_ts_morph2.Node.isArrayLiteralExpression, (array) => { | ||
const arrayExpression = array.getElements().map((elm) => { | ||
if (import_ts_morph2.Node.isNumericLiteral(node)) { | ||
return node.getLiteralValue(); | ||
} | ||
if (import_ts_morph2.Node.isStringLiteral(node)) { | ||
return node.getLiteralValue().trim(); | ||
} | ||
if (import_ts_morph2.Node.isNoSubstitutionTemplateLiteral(node)) { | ||
return node.getLiteralValue().trim(); | ||
} | ||
if (import_ts_morph2.Node.isTrueLiteral(node)) { | ||
return node.getLiteralValue(); | ||
} | ||
if (import_ts_morph2.Node.isFalseLiteral(node)) { | ||
return node.getLiteralValue(); | ||
} | ||
if (import_ts_morph2.Node.isArrayLiteralExpression(node)) { | ||
const arrayExpression = node.getElements().map((elm) => { | ||
return handleJsxExpression(elm); | ||
}); | ||
return arrayExpression.includes(void 0) ? void 0 : arrayExpression; | ||
}).when(import_ts_morph2.Node.isBinaryExpression, (exp) => { | ||
const leftOperand = handleJsxExpression(exp.getLeft()); | ||
const rightOperand = handleJsxExpression(exp.getRight()); | ||
const operator = exp.getOperatorToken().getKind(); | ||
} | ||
if (import_ts_morph2.Node.isBinaryExpression(node)) { | ||
const leftOperand = handleJsxExpression(node.getLeft()); | ||
const rightOperand = handleJsxExpression(node.getRight()); | ||
const operator = node.getOperatorToken().getKind(); | ||
if (typeof leftOperand === "number" && typeof rightOperand === "number") { | ||
@@ -87,7 +91,10 @@ switch (operator) { | ||
return void 0; | ||
}).when(import_ts_morph2.Node.isObjectLiteralExpression, (obj) => { | ||
} | ||
if (import_ts_morph2.Node.isObjectLiteralExpression(node)) { | ||
return void 0; | ||
}).when(import_ts_morph2.Node.isCallExpression, (call) => { | ||
} | ||
if (import_ts_morph2.Node.isCallExpression(node)) { | ||
return void 0; | ||
}).otherwise(() => void 0); | ||
} | ||
return void 0; | ||
}; | ||
@@ -97,7 +104,6 @@ | ||
var import_ts_morph3 = require("ts-morph"); | ||
var import_ts_pattern2 = require("ts-pattern"); | ||
var extractPseudoAttribute = (jsxAttribute) => { | ||
const initializer = jsxAttribute.getInitializer(); | ||
return (0, import_ts_pattern2.match)(initializer).when(import_ts_morph3.Node.isJsxExpression, (initializer2) => { | ||
const expression = initializer2.getExpression(); | ||
if (import_ts_morph3.Node.isJsxExpression(initializer)) { | ||
const expression = initializer.getExpression(); | ||
if (!expression) | ||
@@ -107,8 +113,9 @@ return; | ||
return handlePseudoJsxExpression(decodedNode); | ||
}).otherwise(() => void 0); | ||
} | ||
return void 0; | ||
}; | ||
var handlePseudoJsxExpression = (node) => { | ||
return (0, import_ts_pattern2.match)(node).when(import_ts_morph3.Node.isObjectLiteralExpression, (obj) => { | ||
if (import_ts_morph3.Node.isObjectLiteralExpression(node)) { | ||
const objProps = {}; | ||
for (const prop of obj.getProperties()) { | ||
for (const prop of node.getProperties()) { | ||
if (import_ts_morph3.Node.isPropertyAssignment(prop)) { | ||
@@ -124,3 +131,4 @@ const initializer = prop.getInitializer(); | ||
return Object.values(objProps).includes(void 0) ? void 0 : objProps; | ||
}).otherwise(() => handleJsxExpression(node)); | ||
} | ||
return handleJsxExpression(node); | ||
}; | ||
@@ -150,7 +158,8 @@ | ||
const initializer = jsxAttribute.getInitializer(); | ||
return (0, import_ts_pattern3.match)(initializer).when(import_ts_morph4.Node.isStringLiteral, (initializer2) => { | ||
const value = initializer2.getLiteralText(); | ||
if (import_ts_morph4.Node.isStringLiteral(initializer)) { | ||
const value = initializer.getLiteralText(); | ||
return value; | ||
}).when(import_ts_morph4.Node.isJsxExpression, (initializer2) => { | ||
const expression = initializer2.getExpression(); | ||
} | ||
if (import_ts_morph4.Node.isJsxExpression(initializer)) { | ||
const expression = initializer.getExpression(); | ||
if (!expression) | ||
@@ -160,6 +169,7 @@ return; | ||
return handleJsxExpression(decodedNode); | ||
}).when( | ||
() => initializer === void 0, | ||
() => true | ||
).otherwise(() => void 0); | ||
} | ||
if (initializer === void 0) { | ||
return true; | ||
} | ||
return void 0; | ||
}; | ||
@@ -166,0 +176,0 @@ // Annotate the CommonJS export names for ESM import in node: |
@@ -27,23 +27,28 @@ "use strict"; | ||
var import_ts_morph = require("ts-morph"); | ||
var import_ts_pattern = require("ts-pattern"); | ||
var handleJsxExpression = (node) => { | ||
return (0, import_ts_pattern.match)(node).when(import_ts_morph.Node.isNumericLiteral, (num) => { | ||
return num.getLiteralValue(); | ||
}).when(import_ts_morph.Node.isStringLiteral, (str) => { | ||
return str.getLiteralValue().trim(); | ||
}).when(import_ts_morph.Node.isNoSubstitutionTemplateLiteral, (literal) => { | ||
return literal.getLiteralValue().trim(); | ||
}).when(import_ts_morph.Node.isTrueLiteral, (bool) => { | ||
return bool.getLiteralValue(); | ||
}).when(import_ts_morph.Node.isFalseLiteral, (bool) => { | ||
return bool.getLiteralValue(); | ||
}).when(import_ts_morph.Node.isArrayLiteralExpression, (array) => { | ||
const arrayExpression = array.getElements().map((elm) => { | ||
if (import_ts_morph.Node.isNumericLiteral(node)) { | ||
return node.getLiteralValue(); | ||
} | ||
if (import_ts_morph.Node.isStringLiteral(node)) { | ||
return node.getLiteralValue().trim(); | ||
} | ||
if (import_ts_morph.Node.isNoSubstitutionTemplateLiteral(node)) { | ||
return node.getLiteralValue().trim(); | ||
} | ||
if (import_ts_morph.Node.isTrueLiteral(node)) { | ||
return node.getLiteralValue(); | ||
} | ||
if (import_ts_morph.Node.isFalseLiteral(node)) { | ||
return node.getLiteralValue(); | ||
} | ||
if (import_ts_morph.Node.isArrayLiteralExpression(node)) { | ||
const arrayExpression = node.getElements().map((elm) => { | ||
return handleJsxExpression(elm); | ||
}); | ||
return arrayExpression.includes(void 0) ? void 0 : arrayExpression; | ||
}).when(import_ts_morph.Node.isBinaryExpression, (exp) => { | ||
const leftOperand = handleJsxExpression(exp.getLeft()); | ||
const rightOperand = handleJsxExpression(exp.getRight()); | ||
const operator = exp.getOperatorToken().getKind(); | ||
} | ||
if (import_ts_morph.Node.isBinaryExpression(node)) { | ||
const leftOperand = handleJsxExpression(node.getLeft()); | ||
const rightOperand = handleJsxExpression(node.getRight()); | ||
const operator = node.getOperatorToken().getKind(); | ||
if (typeof leftOperand === "number" && typeof rightOperand === "number") { | ||
@@ -64,7 +69,10 @@ switch (operator) { | ||
return void 0; | ||
}).when(import_ts_morph.Node.isObjectLiteralExpression, (obj) => { | ||
} | ||
if (import_ts_morph.Node.isObjectLiteralExpression(node)) { | ||
return void 0; | ||
}).when(import_ts_morph.Node.isCallExpression, (call) => { | ||
} | ||
if (import_ts_morph.Node.isCallExpression(node)) { | ||
return void 0; | ||
}).otherwise(() => void 0); | ||
} | ||
return void 0; | ||
}; | ||
@@ -71,0 +79,0 @@ // Annotate the CommonJS export names for ESM import in node: |
@@ -29,3 +29,2 @@ "use strict"; | ||
var import_ts_morph4 = require("ts-morph"); | ||
var import_ts_pattern3 = require("ts-pattern"); | ||
@@ -52,23 +51,28 @@ // src/collector/decode.ts | ||
var import_ts_morph2 = require("ts-morph"); | ||
var import_ts_pattern = require("ts-pattern"); | ||
var handleJsxExpression = (node) => { | ||
return (0, import_ts_pattern.match)(node).when(import_ts_morph2.Node.isNumericLiteral, (num) => { | ||
return num.getLiteralValue(); | ||
}).when(import_ts_morph2.Node.isStringLiteral, (str) => { | ||
return str.getLiteralValue().trim(); | ||
}).when(import_ts_morph2.Node.isNoSubstitutionTemplateLiteral, (literal) => { | ||
return literal.getLiteralValue().trim(); | ||
}).when(import_ts_morph2.Node.isTrueLiteral, (bool) => { | ||
return bool.getLiteralValue(); | ||
}).when(import_ts_morph2.Node.isFalseLiteral, (bool) => { | ||
return bool.getLiteralValue(); | ||
}).when(import_ts_morph2.Node.isArrayLiteralExpression, (array) => { | ||
const arrayExpression = array.getElements().map((elm) => { | ||
if (import_ts_morph2.Node.isNumericLiteral(node)) { | ||
return node.getLiteralValue(); | ||
} | ||
if (import_ts_morph2.Node.isStringLiteral(node)) { | ||
return node.getLiteralValue().trim(); | ||
} | ||
if (import_ts_morph2.Node.isNoSubstitutionTemplateLiteral(node)) { | ||
return node.getLiteralValue().trim(); | ||
} | ||
if (import_ts_morph2.Node.isTrueLiteral(node)) { | ||
return node.getLiteralValue(); | ||
} | ||
if (import_ts_morph2.Node.isFalseLiteral(node)) { | ||
return node.getLiteralValue(); | ||
} | ||
if (import_ts_morph2.Node.isArrayLiteralExpression(node)) { | ||
const arrayExpression = node.getElements().map((elm) => { | ||
return handleJsxExpression(elm); | ||
}); | ||
return arrayExpression.includes(void 0) ? void 0 : arrayExpression; | ||
}).when(import_ts_morph2.Node.isBinaryExpression, (exp) => { | ||
const leftOperand = handleJsxExpression(exp.getLeft()); | ||
const rightOperand = handleJsxExpression(exp.getRight()); | ||
const operator = exp.getOperatorToken().getKind(); | ||
} | ||
if (import_ts_morph2.Node.isBinaryExpression(node)) { | ||
const leftOperand = handleJsxExpression(node.getLeft()); | ||
const rightOperand = handleJsxExpression(node.getRight()); | ||
const operator = node.getOperatorToken().getKind(); | ||
if (typeof leftOperand === "number" && typeof rightOperand === "number") { | ||
@@ -89,7 +93,10 @@ switch (operator) { | ||
return void 0; | ||
}).when(import_ts_morph2.Node.isObjectLiteralExpression, (obj) => { | ||
} | ||
if (import_ts_morph2.Node.isObjectLiteralExpression(node)) { | ||
return void 0; | ||
}).when(import_ts_morph2.Node.isCallExpression, (call) => { | ||
} | ||
if (import_ts_morph2.Node.isCallExpression(node)) { | ||
return void 0; | ||
}).otherwise(() => void 0); | ||
} | ||
return void 0; | ||
}; | ||
@@ -99,7 +106,6 @@ | ||
var import_ts_morph3 = require("ts-morph"); | ||
var import_ts_pattern2 = require("ts-pattern"); | ||
var extractPseudoAttribute = (jsxAttribute) => { | ||
const initializer = jsxAttribute.getInitializer(); | ||
return (0, import_ts_pattern2.match)(initializer).when(import_ts_morph3.Node.isJsxExpression, (initializer2) => { | ||
const expression = initializer2.getExpression(); | ||
if (import_ts_morph3.Node.isJsxExpression(initializer)) { | ||
const expression = initializer.getExpression(); | ||
if (!expression) | ||
@@ -109,8 +115,9 @@ return; | ||
return handlePseudoJsxExpression(decodedNode); | ||
}).otherwise(() => void 0); | ||
} | ||
return void 0; | ||
}; | ||
var handlePseudoJsxExpression = (node) => { | ||
return (0, import_ts_pattern2.match)(node).when(import_ts_morph3.Node.isObjectLiteralExpression, (obj) => { | ||
if (import_ts_morph3.Node.isObjectLiteralExpression(node)) { | ||
const objProps = {}; | ||
for (const prop of obj.getProperties()) { | ||
for (const prop of node.getProperties()) { | ||
if (import_ts_morph3.Node.isPropertyAssignment(prop)) { | ||
@@ -126,3 +133,4 @@ const initializer = prop.getInitializer(); | ||
return Object.values(objProps).includes(void 0) ? void 0 : objProps; | ||
}).otherwise(() => handleJsxExpression(node)); | ||
} | ||
return handleJsxExpression(node); | ||
}; | ||
@@ -152,7 +160,8 @@ | ||
const initializer = jsxAttribute.getInitializer(); | ||
return (0, import_ts_pattern3.match)(initializer).when(import_ts_morph4.Node.isStringLiteral, (initializer2) => { | ||
const value = initializer2.getLiteralText(); | ||
if (import_ts_morph4.Node.isStringLiteral(initializer)) { | ||
const value = initializer.getLiteralText(); | ||
return value; | ||
}).when(import_ts_morph4.Node.isJsxExpression, (initializer2) => { | ||
const expression = initializer2.getExpression(); | ||
} | ||
if (import_ts_morph4.Node.isJsxExpression(initializer)) { | ||
const expression = initializer.getExpression(); | ||
if (!expression) | ||
@@ -162,6 +171,7 @@ return; | ||
return handleJsxExpression(decodedNode); | ||
}).when( | ||
() => initializer === void 0, | ||
() => true | ||
).otherwise(() => void 0); | ||
} | ||
if (initializer === void 0) { | ||
return true; | ||
} | ||
return void 0; | ||
}; | ||
@@ -168,0 +178,0 @@ // Annotate the CommonJS export names for ESM import in node: |
@@ -27,3 +27,2 @@ "use strict"; | ||
var import_ts_morph3 = require("ts-morph"); | ||
var import_ts_pattern2 = require("ts-pattern"); | ||
@@ -50,23 +49,28 @@ // src/collector/decode.ts | ||
var import_ts_morph2 = require("ts-morph"); | ||
var import_ts_pattern = require("ts-pattern"); | ||
var handleJsxExpression = (node) => { | ||
return (0, import_ts_pattern.match)(node).when(import_ts_morph2.Node.isNumericLiteral, (num) => { | ||
return num.getLiteralValue(); | ||
}).when(import_ts_morph2.Node.isStringLiteral, (str) => { | ||
return str.getLiteralValue().trim(); | ||
}).when(import_ts_morph2.Node.isNoSubstitutionTemplateLiteral, (literal) => { | ||
return literal.getLiteralValue().trim(); | ||
}).when(import_ts_morph2.Node.isTrueLiteral, (bool) => { | ||
return bool.getLiteralValue(); | ||
}).when(import_ts_morph2.Node.isFalseLiteral, (bool) => { | ||
return bool.getLiteralValue(); | ||
}).when(import_ts_morph2.Node.isArrayLiteralExpression, (array) => { | ||
const arrayExpression = array.getElements().map((elm) => { | ||
if (import_ts_morph2.Node.isNumericLiteral(node)) { | ||
return node.getLiteralValue(); | ||
} | ||
if (import_ts_morph2.Node.isStringLiteral(node)) { | ||
return node.getLiteralValue().trim(); | ||
} | ||
if (import_ts_morph2.Node.isNoSubstitutionTemplateLiteral(node)) { | ||
return node.getLiteralValue().trim(); | ||
} | ||
if (import_ts_morph2.Node.isTrueLiteral(node)) { | ||
return node.getLiteralValue(); | ||
} | ||
if (import_ts_morph2.Node.isFalseLiteral(node)) { | ||
return node.getLiteralValue(); | ||
} | ||
if (import_ts_morph2.Node.isArrayLiteralExpression(node)) { | ||
const arrayExpression = node.getElements().map((elm) => { | ||
return handleJsxExpression(elm); | ||
}); | ||
return arrayExpression.includes(void 0) ? void 0 : arrayExpression; | ||
}).when(import_ts_morph2.Node.isBinaryExpression, (exp) => { | ||
const leftOperand = handleJsxExpression(exp.getLeft()); | ||
const rightOperand = handleJsxExpression(exp.getRight()); | ||
const operator = exp.getOperatorToken().getKind(); | ||
} | ||
if (import_ts_morph2.Node.isBinaryExpression(node)) { | ||
const leftOperand = handleJsxExpression(node.getLeft()); | ||
const rightOperand = handleJsxExpression(node.getRight()); | ||
const operator = node.getOperatorToken().getKind(); | ||
if (typeof leftOperand === "number" && typeof rightOperand === "number") { | ||
@@ -87,7 +91,10 @@ switch (operator) { | ||
return void 0; | ||
}).when(import_ts_morph2.Node.isObjectLiteralExpression, (obj) => { | ||
} | ||
if (import_ts_morph2.Node.isObjectLiteralExpression(node)) { | ||
return void 0; | ||
}).when(import_ts_morph2.Node.isCallExpression, (call) => { | ||
} | ||
if (import_ts_morph2.Node.isCallExpression(node)) { | ||
return void 0; | ||
}).otherwise(() => void 0); | ||
} | ||
return void 0; | ||
}; | ||
@@ -98,4 +105,4 @@ | ||
const initializer = jsxAttribute.getInitializer(); | ||
return (0, import_ts_pattern2.match)(initializer).when(import_ts_morph3.Node.isJsxExpression, (initializer2) => { | ||
const expression = initializer2.getExpression(); | ||
if (import_ts_morph3.Node.isJsxExpression(initializer)) { | ||
const expression = initializer.getExpression(); | ||
if (!expression) | ||
@@ -105,8 +112,9 @@ return; | ||
return handlePseudoJsxExpression(decodedNode); | ||
}).otherwise(() => void 0); | ||
} | ||
return void 0; | ||
}; | ||
var handlePseudoJsxExpression = (node) => { | ||
return (0, import_ts_pattern2.match)(node).when(import_ts_morph3.Node.isObjectLiteralExpression, (obj) => { | ||
if (import_ts_morph3.Node.isObjectLiteralExpression(node)) { | ||
const objProps = {}; | ||
for (const prop of obj.getProperties()) { | ||
for (const prop of node.getProperties()) { | ||
if (import_ts_morph3.Node.isPropertyAssignment(prop)) { | ||
@@ -122,3 +130,4 @@ const initializer = prop.getInitializer(); | ||
return Object.values(objProps).includes(void 0) ? void 0 : objProps; | ||
}).otherwise(() => handleJsxExpression(node)); | ||
} | ||
return handleJsxExpression(node); | ||
}; | ||
@@ -125,0 +134,0 @@ // Annotate the CommonJS export names for ESM import in node: |
@@ -30,3 +30,2 @@ "use strict"; | ||
var import_ts_morph4 = require("ts-morph"); | ||
var import_ts_pattern3 = require("ts-pattern"); | ||
@@ -53,23 +52,28 @@ // src/collector/decode.ts | ||
var import_ts_morph2 = require("ts-morph"); | ||
var import_ts_pattern = require("ts-pattern"); | ||
var handleJsxExpression = (node) => { | ||
return (0, import_ts_pattern.match)(node).when(import_ts_morph2.Node.isNumericLiteral, (num) => { | ||
return num.getLiteralValue(); | ||
}).when(import_ts_morph2.Node.isStringLiteral, (str) => { | ||
return str.getLiteralValue().trim(); | ||
}).when(import_ts_morph2.Node.isNoSubstitutionTemplateLiteral, (literal) => { | ||
return literal.getLiteralValue().trim(); | ||
}).when(import_ts_morph2.Node.isTrueLiteral, (bool) => { | ||
return bool.getLiteralValue(); | ||
}).when(import_ts_morph2.Node.isFalseLiteral, (bool) => { | ||
return bool.getLiteralValue(); | ||
}).when(import_ts_morph2.Node.isArrayLiteralExpression, (array) => { | ||
const arrayExpression = array.getElements().map((elm) => { | ||
if (import_ts_morph2.Node.isNumericLiteral(node)) { | ||
return node.getLiteralValue(); | ||
} | ||
if (import_ts_morph2.Node.isStringLiteral(node)) { | ||
return node.getLiteralValue().trim(); | ||
} | ||
if (import_ts_morph2.Node.isNoSubstitutionTemplateLiteral(node)) { | ||
return node.getLiteralValue().trim(); | ||
} | ||
if (import_ts_morph2.Node.isTrueLiteral(node)) { | ||
return node.getLiteralValue(); | ||
} | ||
if (import_ts_morph2.Node.isFalseLiteral(node)) { | ||
return node.getLiteralValue(); | ||
} | ||
if (import_ts_morph2.Node.isArrayLiteralExpression(node)) { | ||
const arrayExpression = node.getElements().map((elm) => { | ||
return handleJsxExpression(elm); | ||
}); | ||
return arrayExpression.includes(void 0) ? void 0 : arrayExpression; | ||
}).when(import_ts_morph2.Node.isBinaryExpression, (exp) => { | ||
const leftOperand = handleJsxExpression(exp.getLeft()); | ||
const rightOperand = handleJsxExpression(exp.getRight()); | ||
const operator = exp.getOperatorToken().getKind(); | ||
} | ||
if (import_ts_morph2.Node.isBinaryExpression(node)) { | ||
const leftOperand = handleJsxExpression(node.getLeft()); | ||
const rightOperand = handleJsxExpression(node.getRight()); | ||
const operator = node.getOperatorToken().getKind(); | ||
if (typeof leftOperand === "number" && typeof rightOperand === "number") { | ||
@@ -90,7 +94,10 @@ switch (operator) { | ||
return void 0; | ||
}).when(import_ts_morph2.Node.isObjectLiteralExpression, (obj) => { | ||
} | ||
if (import_ts_morph2.Node.isObjectLiteralExpression(node)) { | ||
return void 0; | ||
}).when(import_ts_morph2.Node.isCallExpression, (call) => { | ||
} | ||
if (import_ts_morph2.Node.isCallExpression(node)) { | ||
return void 0; | ||
}).otherwise(() => void 0); | ||
} | ||
return void 0; | ||
}; | ||
@@ -100,7 +107,6 @@ | ||
var import_ts_morph3 = require("ts-morph"); | ||
var import_ts_pattern2 = require("ts-pattern"); | ||
var extractPseudoAttribute = (jsxAttribute) => { | ||
const initializer = jsxAttribute.getInitializer(); | ||
return (0, import_ts_pattern2.match)(initializer).when(import_ts_morph3.Node.isJsxExpression, (initializer2) => { | ||
const expression = initializer2.getExpression(); | ||
if (import_ts_morph3.Node.isJsxExpression(initializer)) { | ||
const expression = initializer.getExpression(); | ||
if (!expression) | ||
@@ -110,8 +116,9 @@ return; | ||
return handlePseudoJsxExpression(decodedNode); | ||
}).otherwise(() => void 0); | ||
} | ||
return void 0; | ||
}; | ||
var handlePseudoJsxExpression = (node) => { | ||
return (0, import_ts_pattern2.match)(node).when(import_ts_morph3.Node.isObjectLiteralExpression, (obj) => { | ||
if (import_ts_morph3.Node.isObjectLiteralExpression(node)) { | ||
const objProps = {}; | ||
for (const prop of obj.getProperties()) { | ||
for (const prop of node.getProperties()) { | ||
if (import_ts_morph3.Node.isPropertyAssignment(prop)) { | ||
@@ -127,3 +134,4 @@ const initializer = prop.getInitializer(); | ||
return Object.values(objProps).includes(void 0) ? void 0 : objProps; | ||
}).otherwise(() => handleJsxExpression(node)); | ||
} | ||
return handleJsxExpression(node); | ||
}; | ||
@@ -153,7 +161,8 @@ | ||
const initializer = jsxAttribute.getInitializer(); | ||
return (0, import_ts_pattern3.match)(initializer).when(import_ts_morph4.Node.isStringLiteral, (initializer2) => { | ||
const value = initializer2.getLiteralText(); | ||
if (import_ts_morph4.Node.isStringLiteral(initializer)) { | ||
const value = initializer.getLiteralText(); | ||
return value; | ||
}).when(import_ts_morph4.Node.isJsxExpression, (initializer2) => { | ||
const expression = initializer2.getExpression(); | ||
} | ||
if (import_ts_morph4.Node.isJsxExpression(initializer)) { | ||
const expression = initializer.getExpression(); | ||
if (!expression) | ||
@@ -163,6 +172,7 @@ return; | ||
return handleJsxExpression(decodedNode); | ||
}).when( | ||
() => initializer === void 0, | ||
() => true | ||
).otherwise(() => void 0); | ||
} | ||
if (initializer === void 0) { | ||
return true; | ||
} | ||
return void 0; | ||
}; | ||
@@ -169,0 +179,0 @@ |
@@ -32,3 +32,2 @@ "use strict"; | ||
var import_ts_morph4 = require("ts-morph"); | ||
var import_ts_pattern3 = require("ts-pattern"); | ||
@@ -55,23 +54,28 @@ // src/collector/decode.ts | ||
var import_ts_morph2 = require("ts-morph"); | ||
var import_ts_pattern = require("ts-pattern"); | ||
var handleJsxExpression = (node) => { | ||
return (0, import_ts_pattern.match)(node).when(import_ts_morph2.Node.isNumericLiteral, (num) => { | ||
return num.getLiteralValue(); | ||
}).when(import_ts_morph2.Node.isStringLiteral, (str) => { | ||
return str.getLiteralValue().trim(); | ||
}).when(import_ts_morph2.Node.isNoSubstitutionTemplateLiteral, (literal) => { | ||
return literal.getLiteralValue().trim(); | ||
}).when(import_ts_morph2.Node.isTrueLiteral, (bool) => { | ||
return bool.getLiteralValue(); | ||
}).when(import_ts_morph2.Node.isFalseLiteral, (bool) => { | ||
return bool.getLiteralValue(); | ||
}).when(import_ts_morph2.Node.isArrayLiteralExpression, (array) => { | ||
const arrayExpression = array.getElements().map((elm) => { | ||
if (import_ts_morph2.Node.isNumericLiteral(node)) { | ||
return node.getLiteralValue(); | ||
} | ||
if (import_ts_morph2.Node.isStringLiteral(node)) { | ||
return node.getLiteralValue().trim(); | ||
} | ||
if (import_ts_morph2.Node.isNoSubstitutionTemplateLiteral(node)) { | ||
return node.getLiteralValue().trim(); | ||
} | ||
if (import_ts_morph2.Node.isTrueLiteral(node)) { | ||
return node.getLiteralValue(); | ||
} | ||
if (import_ts_morph2.Node.isFalseLiteral(node)) { | ||
return node.getLiteralValue(); | ||
} | ||
if (import_ts_morph2.Node.isArrayLiteralExpression(node)) { | ||
const arrayExpression = node.getElements().map((elm) => { | ||
return handleJsxExpression(elm); | ||
}); | ||
return arrayExpression.includes(void 0) ? void 0 : arrayExpression; | ||
}).when(import_ts_morph2.Node.isBinaryExpression, (exp) => { | ||
const leftOperand = handleJsxExpression(exp.getLeft()); | ||
const rightOperand = handleJsxExpression(exp.getRight()); | ||
const operator = exp.getOperatorToken().getKind(); | ||
} | ||
if (import_ts_morph2.Node.isBinaryExpression(node)) { | ||
const leftOperand = handleJsxExpression(node.getLeft()); | ||
const rightOperand = handleJsxExpression(node.getRight()); | ||
const operator = node.getOperatorToken().getKind(); | ||
if (typeof leftOperand === "number" && typeof rightOperand === "number") { | ||
@@ -92,7 +96,10 @@ switch (operator) { | ||
return void 0; | ||
}).when(import_ts_morph2.Node.isObjectLiteralExpression, (obj) => { | ||
} | ||
if (import_ts_morph2.Node.isObjectLiteralExpression(node)) { | ||
return void 0; | ||
}).when(import_ts_morph2.Node.isCallExpression, (call) => { | ||
} | ||
if (import_ts_morph2.Node.isCallExpression(node)) { | ||
return void 0; | ||
}).otherwise(() => void 0); | ||
} | ||
return void 0; | ||
}; | ||
@@ -102,7 +109,6 @@ | ||
var import_ts_morph3 = require("ts-morph"); | ||
var import_ts_pattern2 = require("ts-pattern"); | ||
var extractPseudoAttribute = (jsxAttribute) => { | ||
const initializer = jsxAttribute.getInitializer(); | ||
return (0, import_ts_pattern2.match)(initializer).when(import_ts_morph3.Node.isJsxExpression, (initializer2) => { | ||
const expression = initializer2.getExpression(); | ||
if (import_ts_morph3.Node.isJsxExpression(initializer)) { | ||
const expression = initializer.getExpression(); | ||
if (!expression) | ||
@@ -112,8 +118,9 @@ return; | ||
return handlePseudoJsxExpression(decodedNode); | ||
}).otherwise(() => void 0); | ||
} | ||
return void 0; | ||
}; | ||
var handlePseudoJsxExpression = (node) => { | ||
return (0, import_ts_pattern2.match)(node).when(import_ts_morph3.Node.isObjectLiteralExpression, (obj) => { | ||
if (import_ts_morph3.Node.isObjectLiteralExpression(node)) { | ||
const objProps = {}; | ||
for (const prop of obj.getProperties()) { | ||
for (const prop of node.getProperties()) { | ||
if (import_ts_morph3.Node.isPropertyAssignment(prop)) { | ||
@@ -129,3 +136,4 @@ const initializer = prop.getInitializer(); | ||
return Object.values(objProps).includes(void 0) ? void 0 : objProps; | ||
}).otherwise(() => handleJsxExpression(node)); | ||
} | ||
return handleJsxExpression(node); | ||
}; | ||
@@ -155,7 +163,8 @@ | ||
const initializer = jsxAttribute.getInitializer(); | ||
return (0, import_ts_pattern3.match)(initializer).when(import_ts_morph4.Node.isStringLiteral, (initializer2) => { | ||
const value = initializer2.getLiteralText(); | ||
if (import_ts_morph4.Node.isStringLiteral(initializer)) { | ||
const value = initializer.getLiteralText(); | ||
return value; | ||
}).when(import_ts_morph4.Node.isJsxExpression, (initializer2) => { | ||
const expression = initializer2.getExpression(); | ||
} | ||
if (import_ts_morph4.Node.isJsxExpression(initializer)) { | ||
const expression = initializer.getExpression(); | ||
if (!expression) | ||
@@ -165,6 +174,7 @@ return; | ||
return handleJsxExpression(decodedNode); | ||
}).when( | ||
() => initializer === void 0, | ||
() => true | ||
).otherwise(() => void 0); | ||
} | ||
if (initializer === void 0) { | ||
return true; | ||
} | ||
return void 0; | ||
}; | ||
@@ -171,0 +181,0 @@ |
{ | ||
"name": "@kuma-ui/compiler", | ||
"version": "0.0.0-dev-20231105161834", | ||
"version": "0.0.0-dev-20231112011326", | ||
"description": "🐻 Kuma UI is a utility-first, zero-runtime CSS-in-JS library that offers an outstanding developer experience and optimized performance.", | ||
@@ -33,6 +33,5 @@ "repository": { | ||
"ts-morph": "^19.0.0", | ||
"ts-pattern": "^5.0.1", | ||
"@kuma-ui/core": "^0.0.0-dev-20231105161834", | ||
"@kuma-ui/core": "^0.0.0-dev-20231112011326", | ||
"@kuma-ui/sheet": "^1.3.0", | ||
"@kuma-ui/system": "^0.0.0-dev-20231105161834" | ||
"@kuma-ui/system": "^0.0.0-dev-20231112011326" | ||
}, | ||
@@ -39,0 +38,0 @@ "publishConfig": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4
2338
88979
- Removedts-pattern@^5.0.1
- Removedts-pattern@5.5.0(transitive)