@maverick-js/compiler
Advanced tools
Comparing version 0.34.0 to 0.35.0
@@ -1,3 +0,3 @@ | ||
import { TS_NODE, resolvePath, resolveConfigPaths, camelToKebabCase } from './chunks/chunk-FDW5IKT6.js'; | ||
import { setGlobalLogLevel, mapLogLevelStringToNumber, logStackTrace, clearTerminal, log, logTime, reportDiagnosticByNode, formatPluginName, normalizeLineBreaks, escapeQuotes } from './chunks/chunk-SEGPSIF6.js'; | ||
import { TS_NODE, resolvePath, resolveConfigPaths, escapeQuotes, camelToKebabCase } from './chunks/chunk-FDW5IKT6.js'; | ||
import { setGlobalLogLevel, mapLogLevelStringToNumber, logStackTrace, clearTerminal, log, logTime, reportDiagnosticByNode, formatPluginName, normalizeLineBreaks, escapeQuotes as escapeQuotes$1 } from './chunks/chunk-SEGPSIF6.js'; | ||
import { isArray, isUndefined, isNull } from './chunks/chunk-3M33KLBM.js'; | ||
@@ -49,3 +49,3 @@ import yargs from 'yargs'; | ||
const filePath = normalize(node.getSourceFile().fileName); | ||
const textPath = escapeQuotes(text); | ||
const textPath = escapeQuotes$1(text); | ||
return resolve(dirname(filePath), textPath); | ||
@@ -131,3 +131,3 @@ } | ||
} | ||
var TYPE_FORMAT_FLAGS = ts7.TypeFormatFlags.UseSingleQuotesForStringLiteralType | ts7.TypeFormatFlags.NoTruncation | ts7.TypeFormatFlags.InTypeAlias | ts7.TypeFormatFlags.InElementType; | ||
var TYPE_FORMAT_FLAGS = ts7.TypeFormatFlags.UseSingleQuotesForStringLiteralType | ts7.TypeFormatFlags.NoTruncation | ts7.TypeFormatFlags.InElementType; | ||
function serializeType(checker, type, flags) { | ||
@@ -156,3 +156,3 @@ return checker.typeToString(type, void 0, flags ?? TYPE_FORMAT_FLAGS); | ||
continue; | ||
const name = signature.name.getText(), docs = getDocs(checker, signature.name), doctags = getDocTags(signature), type = buildTypeMeta(checker, checker.getTypeOfSymbol(symbol)); | ||
const name = escapeQuotes(signature.name.getText()), docs = getDocs(checker, signature.name), doctags = getDocTags(signature), type = buildTypeMeta(checker, checker.getTypeOfSymbol(symbol)); | ||
let internal, required, deprecated, $default, optional = !!signature.questionToken, readonly = !!((_b = signature.modifiers) == null ? void 0 : _b.some( | ||
@@ -227,3 +227,3 @@ (mod) => mod.kind === ts7.SyntaxKind.ReadonlyKeyword | ||
continue; | ||
const name = signature.name.getText(), isTypeReference = signature.type && ts7.isTypeReferenceNode(signature.type) && ts7.isIdentifier(signature.type.typeName), declaration = isTypeReference ? getDeclaration(checker, signature.type.typeName) : void 0, docs = getDocs(checker, signature.name) ?? (isTypeReference ? getDocs(checker, signature.type.typeName) : void 0), doctags = getDocTags(signature) ?? (isTypeReference ? getDocTags(declaration) : void 0), type = buildTypeMeta(checker, checker.getTypeOfSymbol(symbol)); | ||
const name = escapeQuotes(signature.name.getText()), isTypeReference = signature.type && ts7.isTypeReferenceNode(signature.type) && ts7.isIdentifier(signature.type.typeName), declaration = isTypeReference ? getDeclaration(checker, signature.type.typeName) : void 0, docs = getDocs(checker, signature.name) ?? (isTypeReference ? getDocs(checker, signature.type.typeName) : void 0), doctags = getDocTags(signature) ?? (isTypeReference ? getDocTags(declaration) : void 0), type = buildTypeMeta(checker, checker.getTypeOfSymbol(symbol)); | ||
let internal, deprecated, bubbles, composed, cancellable; | ||
@@ -317,3 +317,3 @@ const detailType = signature.type ? checker.getPropertyOfType(checker.getTypeAtLocation(signature.type), "detail") : null, detail = detailType && ((_b = detailType.declarations) == null ? void 0 : _b[0]) ? serializeType( | ||
if (declaration && ts7.isPropertyAssignment(declaration)) { | ||
props.set(declaration.name.getText(), declaration); | ||
props.set(escapeQuotes(declaration.name.getText()), declaration); | ||
} | ||
@@ -331,10 +331,16 @@ } | ||
break; | ||
const extend = node.heritageClauses.find((c) => c.kind & ts7.SyntaxKind.ExtendsKeyword); | ||
const identifier = extend && ((_a = extend.types[0]) == null ? void 0 : _a.expression); | ||
if (!identifier || !ts7.isIdentifier(identifier)) | ||
for (const clause of node.heritageClauses) { | ||
const identifier = (_a = clause.types[0]) == null ? void 0 : _a.expression; | ||
if (!identifier || !ts7.isIdentifier(identifier)) { | ||
node = null; | ||
continue; | ||
} | ||
const declaration = getDeclaration(checker, identifier); | ||
if (!declaration || !ts7.isClassDeclaration(declaration)) { | ||
node = null; | ||
continue; | ||
} | ||
node = declaration; | ||
break; | ||
const declaration = getDeclaration(checker, identifier); | ||
if (!declaration || !ts7.isClassDeclaration(declaration)) | ||
break; | ||
node = declaration; | ||
} | ||
} | ||
@@ -419,3 +425,3 @@ return map; | ||
continue; | ||
const name = signature.name.getText(), type = checker.getTypeOfSymbol(symbol), valueNode = values == null ? void 0 : values.props.get(name), value = valueNode ? getValueNode(checker, valueNode.initializer) ?? valueNode : null; | ||
const name = escapeQuotes$1(signature.name.getText()), type = checker.getTypeOfSymbol(symbol), valueNode = values == null ? void 0 : values.props.get(name), value = valueNode ? getValueNode(checker, valueNode.initializer) ?? valueNode : null; | ||
let info = { | ||
@@ -437,3 +443,3 @@ type | ||
if (!attr || attr.kind !== ts7.SyntaxKind.FalseKeyword) { | ||
info.attribute = (attr == null ? void 0 : attr.kind) === ts7.SyntaxKind.StringLiteral ? escapeQuotes(attr.getText()) : camelToKebabCase(name); | ||
info.attribute = (attr == null ? void 0 : attr.kind) === ts7.SyntaxKind.StringLiteral ? escapeQuotes$1(attr.getText()) : camelToKebabCase(name); | ||
} | ||
@@ -446,3 +452,3 @@ if (reflect && reflect.kind !== ts7.SyntaxKind.FalseKeyword) { | ||
info.attribute = camelToKebabCase(name); | ||
info.value = value.getText(); | ||
info.value = ts7.isPropertyAssignment(value) ? value.initializer.getText() : value.getText(); | ||
} | ||
@@ -462,3 +468,3 @@ } else { | ||
const identifier = node == null ? void 0 : node.name, symbol = identifier ? checker.getSymbolAtLocation(identifier) : void 0, isGetAccessor = node && ts7.isGetAccessor(node), hasSetAccessor = node && ts7.isGetAccessor(node) ? !!(symbol == null ? void 0 : symbol.declarations.some(ts7.isSetAccessorDeclaration)) : void 0, docs = identifier ? getDocs(checker, identifier) : void 0, doctags = node ? getDocTags(node) : void 0, readonly = !!((_a = node == null ? void 0 : node.modifiers) == null ? void 0 : _a.some( | ||
(mode) => mode.kind & ts7.SyntaxKind.ReadonlyKeyword | ||
(mode) => mode.kind === ts7.SyntaxKind.ReadonlyKeyword | ||
)) || isGetAccessor && !hasSetAccessor || !hasSetAccessor && doctags && hasDocTag(doctags, "readonly"); | ||
@@ -506,4 +512,4 @@ let internal, deprecated, required, $default, attribute, reflect; | ||
continue; | ||
if (ts7.isPropertyDeclaration(declaration) || ts7.isGetAccessorDeclaration(declaration) || ts7.isSetAccessorDeclaration(declaration)) { | ||
const name = declaration.name.getText(); | ||
if (ts7.isPropertyDeclaration(declaration) || ts7.isGetAccessorDeclaration(declaration)) { | ||
const name = escapeQuotes(declaration.name.getText()); | ||
if (ignoreMember(name, declaration)) | ||
@@ -517,3 +523,3 @@ continue; | ||
} else if (ts7.isMethodDeclaration(declaration)) { | ||
const name = declaration.name.getText(); | ||
const name = escapeQuotes(declaration.name.getText()); | ||
if (ignoreMember(name, declaration)) | ||
@@ -532,2 +538,3 @@ continue; | ||
name: "state", | ||
docs: "This object contains the state of the component store when available.", | ||
type: store.record, | ||
@@ -539,2 +546,3 @@ readonly: true | ||
name: "subscribe", | ||
docs: "Enables subscribing to live updates of component store state.", | ||
parameters: [{ name: "callback", type: `(state: ${store.record}) => Maybe<Dispose>` }], | ||
@@ -551,6 +559,21 @@ signature: { type: `(callback: (state: ${store.record}) => Maybe<Dispose>) => Unsubscribe` }, | ||
} | ||
var ignore = /* @__PURE__ */ new Set(["el", "render", "destroy", "ts__api"]); | ||
var notPublicKind = ts7.SyntaxKind.ProtectedKeyword | ts7.SyntaxKind.PrivateKeyword; | ||
var validDecoratorName = /^prop|method$/; | ||
var ignoredNamed = /* @__PURE__ */ new Set(["instance", "render", "destroy", "ts__api"]); | ||
var decoratorWarnings = /* @__PURE__ */ new Set(); | ||
function ignoreMember(name, node) { | ||
return node.modifiers && node.modifiers.some((m) => m.kind & notPublicKind) || node.name.kind === ts7.SyntaxKind.PrivateIdentifier || name.startsWith("_") || ignore.has(name); | ||
const isPublic = (!node.modifiers || !node.modifiers.some( | ||
(m) => m.kind === ts7.SyntaxKind.ProtectedKeyword || m.kind === ts7.SyntaxKind.PrivateKeyword | ||
)) && node.name.kind !== ts7.SyntaxKind.PrivateIdentifier; | ||
const hasDecorator = isPublic && node.modifiers && node.modifiers.some( | ||
(modifier) => modifier.kind === ts7.SyntaxKind.Decorator && ts7.isIdentifier(modifier.expression) && validDecoratorName.test(modifier.expression.escapedText) | ||
); | ||
if (isPublic && !hasDecorator && !decoratorWarnings.has(node) && !name.startsWith("_") && !ignoredNamed.has(name)) { | ||
const isMethod = ts7.isMethodDeclaration(node); | ||
reportDiagnosticByNode( | ||
`Public ${isMethod ? "method" : "property"} \`${name}\` requires \`${isMethod ? "@method" : "@prop"}\` decorator`, | ||
node | ||
); | ||
decoratorWarnings.add(node); | ||
} | ||
return !isPublic || !hasDecorator; | ||
} | ||
@@ -673,4 +696,4 @@ function buildSlotsMeta(doctags) { | ||
const ts__api = apiSymbol && checker.getTypeOfSymbol(apiSymbol); | ||
if (ts__api && ts__api.flags & ts7.TypeFlags.Union) { | ||
const apiType = ts__api.types[1]; | ||
const apiType = ts__api && ts__api.flags & ts7.TypeFlags.Union ? ts__api.types[1] : ts__api; | ||
if (apiType) { | ||
if (apiType) { | ||
@@ -690,3 +713,3 @@ api.root = apiType; | ||
el = node2.members.find( | ||
(member) => ts7.isPropertyDeclaration(member) && member.kind & ts7.SyntaxKind.StaticKeyword && ts7.isIdentifier(member.name) && member.name.escapedText === "el" | ||
(member) => ts7.isPropertyDeclaration(member) && member.modifiers && member.modifiers.some((modifier) => modifier.kind === ts7.SyntaxKind.StaticKeyword) && ts7.isIdentifier(member.name) && member.name.escapedText === "el" | ||
); | ||
@@ -693,0 +716,0 @@ if (el) |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "0.34.0", | ||
"version": "0.35.0", | ||
"type": "module", | ||
@@ -8,0 +8,0 @@ "types": "dist/types/index.d.ts", |
Sorry, the diff of this file is not supported yet
274492
7334