mirror of
https://gitee.com/openharmony/third_party_typescript
synced 2024-11-27 00:51:12 +00:00
improve kit import in tsc
Issue: https://gitee.com/openharmony/third_party_typescript/issues/IAF34F Test: tsc tests Signed-off-by: xucheng46 <xucheng46@huawei.com> Change-Id: Id9f19298b8cca42e5227315605e0dd19dcca0db1
This commit is contained in:
parent
e650cbf98f
commit
563cf495d9
198
lib/tsc.js
198
lib/tsc.js
@ -11744,7 +11744,8 @@ var ts;
|
||||
}
|
||||
ts.getLiteralText = getLiteralText;
|
||||
function canUseOriginalText(node, flags) {
|
||||
if (nodeIsSynthesized(node) || !node.parent || (flags & 4 && node.isUnterminated)) {
|
||||
if (nodeIsSynthesized(node) || !node.parent || (flags & 4 && node.isUnterminated) ||
|
||||
(node.flags & -2147483648)) {
|
||||
return false;
|
||||
}
|
||||
if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512) {
|
||||
@ -26675,9 +26676,17 @@ var ts;
|
||||
sourceFlags = contextFlags;
|
||||
nextToken();
|
||||
var statements = parseList(0, parseStatement);
|
||||
var markedkitImportRanges = new Array();
|
||||
var sdkPath = ts.getSdkPath(sourceFileCompilerOptions);
|
||||
statements = (!!sourceFileCompilerOptions.noTransformedKitInParser || !sdkPath || parseDiagnostics.length) ?
|
||||
statements :
|
||||
createNodeArray(ts.processKit(factory, statements, sdkPath, markedkitImportRanges, inEtsContext()), statements.pos);
|
||||
ts.Debug.assert(token() === 1);
|
||||
var endOfFileToken = addJSDocComment(parseTokenNode());
|
||||
var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags, setExternalModuleIndicator);
|
||||
if (markedkitImportRanges.length > 0) {
|
||||
sourceFile.markedKitImportRange = markedkitImportRanges;
|
||||
}
|
||||
processCommentPragmas(sourceFile, sourceText);
|
||||
processPragmasIntoFields(sourceFile, reportPragmaDiagnostic);
|
||||
sourceFile.commentDirectives = scanner.getCommentDirectives();
|
||||
@ -39280,6 +39289,191 @@ var ts;
|
||||
return (ts.isIdentifier(nameExpr) && nameExpr.escapedText.toString() === 'Sendable');
|
||||
}
|
||||
ts.isSendableFunctionOrType = isSendableFunctionOrType;
|
||||
var JSON_SUFFIX = ".json";
|
||||
var KIT_PREFIX = '@kit.';
|
||||
var DEFAULT_KEYWORD = 'default';
|
||||
var ETS_DECLARATION = '.d.ets';
|
||||
var OHOS_KIT_CONFIG_PATH = './openharmony/ets/build-tools/ets-loader/kit_configs';
|
||||
var HMS_KIT_CONFIG_PATH = './hms/ets/build-tools/ets-loader/kit_configs';
|
||||
var kitJsonCache = new ts.Map();
|
||||
function getSdkPath(compilerOptions) {
|
||||
return compilerOptions.etsLoaderPath ? ts.resolvePath(compilerOptions.etsLoaderPath, '../../../..') : undefined;
|
||||
}
|
||||
ts.getSdkPath = getSdkPath;
|
||||
function getKitJsonObject(name, sdkPath) {
|
||||
if (kitJsonCache === null || kitJsonCache === void 0 ? void 0 : kitJsonCache.has(name)) {
|
||||
return kitJsonCache.get(name);
|
||||
}
|
||||
var ohosJsonPath = ts.resolvePath(sdkPath, OHOS_KIT_CONFIG_PATH, "./".concat(name).concat(JSON_SUFFIX));
|
||||
var hmsJsonPath = ts.resolvePath(sdkPath, HMS_KIT_CONFIG_PATH, "./".concat(name).concat(JSON_SUFFIX));
|
||||
var fileInfo = ts.sys.fileExists(ohosJsonPath) ? ts.sys.readFile(ohosJsonPath, 'utf-8') :
|
||||
ts.sys.fileExists(hmsJsonPath) ? ts.sys.readFile(hmsJsonPath, 'utf-8') :
|
||||
undefined;
|
||||
if (!fileInfo) {
|
||||
kitJsonCache === null || kitJsonCache === void 0 ? void 0 : kitJsonCache.set(name, undefined);
|
||||
return undefined;
|
||||
}
|
||||
var obj = JSON.parse(fileInfo);
|
||||
kitJsonCache === null || kitJsonCache === void 0 ? void 0 : kitJsonCache.set(name, obj);
|
||||
return obj;
|
||||
}
|
||||
function cleanKitJsonCache() {
|
||||
kitJsonCache === null || kitJsonCache === void 0 ? void 0 : kitJsonCache.clear();
|
||||
}
|
||||
ts.cleanKitJsonCache = cleanKitJsonCache;
|
||||
function setVirtualNode(node, start, end) {
|
||||
if (start === void 0) { start = 0; }
|
||||
if (end === void 0) { end = 0; }
|
||||
node.virtual = true;
|
||||
ts.setTextRangePosEnd(node, start, end);
|
||||
return node;
|
||||
}
|
||||
function setNoOriginalText(node) {
|
||||
node.flags |= -2147483648;
|
||||
return node;
|
||||
}
|
||||
function createNameImportDeclaration(factory, isType, name, source, oldStatement) {
|
||||
var oldModuleSpecifier = oldStatement.moduleSpecifier;
|
||||
var oldImportClause = oldStatement.importClause;
|
||||
var newModuleSpecifier = setNoOriginalText(setVirtualNode(factory.createStringLiteral(source), oldModuleSpecifier.pos, oldModuleSpecifier.end));
|
||||
var newImportClause = setVirtualNode(factory.createImportClause(isType, name, undefined), oldImportClause.pos, oldImportClause.end);
|
||||
var newImportDeclaration = setVirtualNode(factory.createImportDeclaration(undefined, newImportClause, newModuleSpecifier), oldStatement.pos, oldStatement.end);
|
||||
return newImportDeclaration;
|
||||
}
|
||||
function createBindingImportDeclaration(factory, isType, propname, name, source, oldStatement) {
|
||||
var oldModuleSpecifier = oldStatement.moduleSpecifier;
|
||||
var oldImportClause = oldStatement.importClause;
|
||||
var newModuleSpecifier = setNoOriginalText(setVirtualNode(factory.createStringLiteral(source), oldModuleSpecifier.pos, oldModuleSpecifier.end));
|
||||
var newPropertyName = setNoOriginalText(setVirtualNode(factory.createIdentifier(propname), name.pos, name.end));
|
||||
var newImportSpecific = setVirtualNode(factory.createImportSpecifier(false, newPropertyName, name), oldImportClause.pos, oldImportClause.end);
|
||||
var newNamedBindings = setVirtualNode(factory.createNamedImports([newImportSpecific]), oldImportClause.pos, oldImportClause.end);
|
||||
var newImportClause = setVirtualNode(factory.createImportClause(isType, undefined, newNamedBindings), oldImportClause.pos, oldImportClause.end);
|
||||
var newImportDeclaration = setVirtualNode(factory.createImportDeclaration(undefined, newImportClause, newModuleSpecifier), oldStatement.pos, oldStatement.end);
|
||||
return newImportDeclaration;
|
||||
}
|
||||
function createImportDeclarationForKit(factory, isType, name, symbol, oldStatement) {
|
||||
var source = symbol.source.replace(/\.d.[e]?ts$/, '');
|
||||
var binding = symbol.bindings;
|
||||
if (binding === DEFAULT_KEYWORD) {
|
||||
return createNameImportDeclaration(factory, isType, name, source, oldStatement);
|
||||
}
|
||||
return createBindingImportDeclaration(factory, isType, binding, name, source, oldStatement);
|
||||
}
|
||||
function markKitImport(statement, markedkitImportRanges) {
|
||||
markedkitImportRanges.push({ pos: statement.pos, end: statement.end });
|
||||
}
|
||||
function isInMarkedKitImport(sourceFile, pos, end) {
|
||||
var _a;
|
||||
return !!((_a = sourceFile.markedKitImportRange) === null || _a === void 0 ? void 0 : _a.some(function (range) {
|
||||
return (range.pos <= pos) && (end <= range.end);
|
||||
}));
|
||||
}
|
||||
ts.isInMarkedKitImport = isInMarkedKitImport;
|
||||
function excludeStatementForKitImport(statement) {
|
||||
if (!ts.isImportDeclaration(statement) ||
|
||||
!statement.importClause ||
|
||||
statement.importClause.isLazy ||
|
||||
(statement.importClause.namedBindings && ts.isNamespaceImport(statement.importClause.namedBindings)) ||
|
||||
!ts.isStringLiteral(statement.moduleSpecifier) || statement.illegalDecorators ||
|
||||
!statement.moduleSpecifier.text.startsWith(KIT_PREFIX) ||
|
||||
statement.modifiers ||
|
||||
statement.assertClause) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
var whiteListForErrorSymbol = [
|
||||
{ kitName: '@kit.CoreFileKit', symbolName: 'DfsListeners' },
|
||||
{ kitName: '@kit.NetworkKit', symbolName: 'VpnExtensionContext' },
|
||||
{ kitName: '@kit.ArkUI', symbolName: 'CustomContentDialog' },
|
||||
];
|
||||
var whiteListForTsWarning = [
|
||||
{ kitName: '@kit.ConnectivityKit', symbolName: 'socket' },
|
||||
];
|
||||
var whiteListForTsFile = new ts.Set([
|
||||
'@kit.AccountKit', '@kit.MapKit', '@kit.Penkit', '@kit.ScenarioFusionKit',
|
||||
'@kit.ServiceCollaborationKit', '@kit.SpeechKit', '@kit.VisionKit',
|
||||
]);
|
||||
function InWhiteList(moduleSpecifierText, importName, inEtsContext) {
|
||||
if (whiteListForErrorSymbol.some(function (info) { return (info.kitName === moduleSpecifierText && info.symbolName === importName); })) {
|
||||
return true;
|
||||
}
|
||||
if (!inEtsContext &&
|
||||
whiteListForTsWarning.some(function (info) { return (info.kitName === moduleSpecifierText && info.symbolName === importName); })) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function processKitStatementSuccess(factory, statement, jsonObject, inEtsContext, newImportStatements) {
|
||||
var importClause = statement.importClause;
|
||||
var moduleSpecifierText = statement.moduleSpecifier.text;
|
||||
var kitSymbol = jsonObject === null || jsonObject === void 0 ? void 0 : jsonObject.symbols;
|
||||
if (!kitSymbol) {
|
||||
return false;
|
||||
}
|
||||
var isType = importClause.isTypeOnly;
|
||||
if (importClause.name) {
|
||||
var symbol = kitSymbol[DEFAULT_KEYWORD];
|
||||
if (!symbol || (!inEtsContext && symbol.source.endsWith(ETS_DECLARATION))) {
|
||||
return false;
|
||||
}
|
||||
newImportStatements.push(createImportDeclarationForKit(factory, isType, importClause.name, symbol, statement));
|
||||
}
|
||||
if (importClause.namedBindings) {
|
||||
var hasError_1 = false;
|
||||
importClause.namedBindings.elements.forEach(function (element) {
|
||||
if (hasError_1) {
|
||||
return;
|
||||
}
|
||||
var importName = ts.unescapeLeadingUnderscores(element.propertyName ? element.propertyName.escapedText : element.name.escapedText);
|
||||
var aliasName = element.name;
|
||||
if (InWhiteList(moduleSpecifierText, importName, inEtsContext)) {
|
||||
hasError_1 = true;
|
||||
return;
|
||||
}
|
||||
var symbol = kitSymbol[importName];
|
||||
if (!symbol || !aliasName ||
|
||||
(!inEtsContext && symbol.source.endsWith(ETS_DECLARATION)) ||
|
||||
(isType && element.isTypeOnly)) {
|
||||
hasError_1 = true;
|
||||
return;
|
||||
}
|
||||
newImportStatements.push(createImportDeclarationForKit(factory, isType || element.isTypeOnly, aliasName, symbol, statement));
|
||||
});
|
||||
if (hasError_1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function processKit(factory, statements, sdkPath, markedkitImportRanges, inEtsContext) {
|
||||
var list = [];
|
||||
var skipRestStatements = false;
|
||||
statements.forEach(function (statement) {
|
||||
if (!skipRestStatements && inEtsContext && !ts.isImportDeclaration(statement)) {
|
||||
skipRestStatements = true;
|
||||
}
|
||||
if (skipRestStatements || excludeStatementForKitImport(statement)) {
|
||||
list.push(statement);
|
||||
return;
|
||||
}
|
||||
var moduleSpecifierText = statement.moduleSpecifier.text;
|
||||
if (!inEtsContext && whiteListForTsFile.has(moduleSpecifierText)) {
|
||||
list.push(statement);
|
||||
return;
|
||||
}
|
||||
var jsonObject = getKitJsonObject(moduleSpecifierText, sdkPath);
|
||||
var newImportStatements = new Array();
|
||||
if (!processKitStatementSuccess(factory, statement, jsonObject, inEtsContext, newImportStatements)) {
|
||||
list.push(statement);
|
||||
return;
|
||||
}
|
||||
list.push.apply(list, newImportStatements);
|
||||
markKitImport(statement, markedkitImportRanges);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
ts.processKit = processKit;
|
||||
})(ts || (ts = {}));
|
||||
var ts;
|
||||
(function (ts) {
|
||||
@ -100002,7 +100196,7 @@ var ts;
|
||||
return getTextOfNode(node.textSourceNode, includeTrivia);
|
||||
}
|
||||
var sourceFile = currentSourceFile;
|
||||
var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node);
|
||||
var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node) && !(node.flags & -2147483648);
|
||||
if (ts.isMemberName(node)) {
|
||||
if (!canUseSourceFile || ts.getSourceFileOfNode(node) !== ts.getOriginalNode(sourceFile)) {
|
||||
return ts.idText(node);
|
||||
|
219
lib/tsserver.js
219
lib/tsserver.js
@ -4627,6 +4627,7 @@ var ts;
|
||||
/* @internal */ NodeFlags[NodeFlags["TypeCached"] = 134217728] = "TypeCached";
|
||||
/* @internal */ NodeFlags[NodeFlags["Deprecated"] = 268435456] = "Deprecated";
|
||||
NodeFlags[NodeFlags["EtsContext"] = 1073741824] = "EtsContext";
|
||||
/* @internal */ NodeFlags[NodeFlags["NoOriginalText"] = -2147483648] = "NoOriginalText";
|
||||
NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped";
|
||||
NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 768] = "ReachabilityCheckFlags";
|
||||
NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 2816] = "ReachabilityAndEmitFlags";
|
||||
@ -15339,7 +15340,8 @@ var ts;
|
||||
}
|
||||
ts.getLiteralText = getLiteralText;
|
||||
function canUseOriginalText(node, flags) {
|
||||
if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated)) {
|
||||
if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated) ||
|
||||
(node.flags & -2147483648 /* NodeFlags.NoOriginalText */)) {
|
||||
return false;
|
||||
}
|
||||
if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* TokenFlags.ContainsSeparator */) {
|
||||
@ -32963,9 +32965,17 @@ var ts;
|
||||
// Prime the scanner.
|
||||
nextToken();
|
||||
var statements = parseList(0 /* ParsingContext.SourceElements */, parseStatement);
|
||||
var markedkitImportRanges = new Array();
|
||||
var sdkPath = ts.getSdkPath(sourceFileCompilerOptions);
|
||||
statements = (!!sourceFileCompilerOptions.noTransformedKitInParser || !sdkPath || parseDiagnostics.length) ?
|
||||
statements :
|
||||
createNodeArray(ts.processKit(factory, statements, sdkPath, markedkitImportRanges, inEtsContext()), statements.pos);
|
||||
ts.Debug.assert(token() === 1 /* SyntaxKind.EndOfFileToken */);
|
||||
var endOfFileToken = addJSDocComment(parseTokenNode());
|
||||
var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags, setExternalModuleIndicator);
|
||||
if (markedkitImportRanges.length > 0) {
|
||||
sourceFile.markedKitImportRange = markedkitImportRanges;
|
||||
}
|
||||
// A member of ReadonlyArray<T> isn't assignable to a member of T[] (and prevents a direct cast) - but this is where we set up those members so they can be readonly in the future
|
||||
processCommentPragmas(sourceFile, sourceText);
|
||||
processPragmasIntoFields(sourceFile, reportPragmaDiagnostic);
|
||||
@ -47691,6 +47701,201 @@ var ts;
|
||||
return (ts.isIdentifier(nameExpr) && nameExpr.escapedText.toString() === 'Sendable');
|
||||
}
|
||||
ts.isSendableFunctionOrType = isSendableFunctionOrType;
|
||||
var JSON_SUFFIX = ".json";
|
||||
var KIT_PREFIX = '@kit.';
|
||||
var DEFAULT_KEYWORD = 'default';
|
||||
var ETS_DECLARATION = '.d.ets';
|
||||
var OHOS_KIT_CONFIG_PATH = './openharmony/ets/build-tools/ets-loader/kit_configs';
|
||||
var HMS_KIT_CONFIG_PATH = './hms/ets/build-tools/ets-loader/kit_configs';
|
||||
var kitJsonCache = new ts.Map();
|
||||
/* @internal */
|
||||
function getSdkPath(compilerOptions) {
|
||||
return compilerOptions.etsLoaderPath ? ts.resolvePath(compilerOptions.etsLoaderPath, '../../../..') : undefined;
|
||||
}
|
||||
ts.getSdkPath = getSdkPath;
|
||||
function getKitJsonObject(name, sdkPath) {
|
||||
if (kitJsonCache === null || kitJsonCache === void 0 ? void 0 : kitJsonCache.has(name)) {
|
||||
return kitJsonCache.get(name);
|
||||
}
|
||||
var ohosJsonPath = ts.resolvePath(sdkPath, OHOS_KIT_CONFIG_PATH, "./".concat(name).concat(JSON_SUFFIX));
|
||||
var hmsJsonPath = ts.resolvePath(sdkPath, HMS_KIT_CONFIG_PATH, "./".concat(name).concat(JSON_SUFFIX));
|
||||
var fileInfo = ts.sys.fileExists(ohosJsonPath) ? ts.sys.readFile(ohosJsonPath, 'utf-8') :
|
||||
ts.sys.fileExists(hmsJsonPath) ? ts.sys.readFile(hmsJsonPath, 'utf-8') :
|
||||
undefined;
|
||||
if (!fileInfo) {
|
||||
kitJsonCache === null || kitJsonCache === void 0 ? void 0 : kitJsonCache.set(name, undefined);
|
||||
return undefined;
|
||||
}
|
||||
var obj = JSON.parse(fileInfo);
|
||||
kitJsonCache === null || kitJsonCache === void 0 ? void 0 : kitJsonCache.set(name, obj);
|
||||
return obj;
|
||||
}
|
||||
function cleanKitJsonCache() {
|
||||
kitJsonCache === null || kitJsonCache === void 0 ? void 0 : kitJsonCache.clear();
|
||||
}
|
||||
ts.cleanKitJsonCache = cleanKitJsonCache;
|
||||
function setVirtualNode(node, start, end) {
|
||||
if (start === void 0) { start = 0; }
|
||||
if (end === void 0) { end = 0; }
|
||||
node.virtual = true;
|
||||
ts.setTextRangePosEnd(node, start, end);
|
||||
return node;
|
||||
}
|
||||
function setNoOriginalText(node) {
|
||||
node.flags |= -2147483648 /* NodeFlags.NoOriginalText */;
|
||||
return node;
|
||||
}
|
||||
function createNameImportDeclaration(factory, isType, name, source, oldStatement) {
|
||||
var oldModuleSpecifier = oldStatement.moduleSpecifier;
|
||||
var oldImportClause = oldStatement.importClause; // shouldn't be undefined
|
||||
var newModuleSpecifier = setNoOriginalText(setVirtualNode(factory.createStringLiteral(source), oldModuleSpecifier.pos, oldModuleSpecifier.end));
|
||||
var newImportClause = setVirtualNode(factory.createImportClause(isType, name, undefined), oldImportClause.pos, oldImportClause.end);
|
||||
var newImportDeclaration = setVirtualNode(factory.createImportDeclaration(undefined, newImportClause, newModuleSpecifier), oldStatement.pos, oldStatement.end);
|
||||
return newImportDeclaration;
|
||||
}
|
||||
function createBindingImportDeclaration(factory, isType, propname, name, source, oldStatement) {
|
||||
var oldModuleSpecifier = oldStatement.moduleSpecifier;
|
||||
var oldImportClause = oldStatement.importClause; // shouldn't be undefined
|
||||
var newModuleSpecifier = setNoOriginalText(setVirtualNode(factory.createStringLiteral(source), oldModuleSpecifier.pos, oldModuleSpecifier.end));
|
||||
var newPropertyName = setNoOriginalText(setVirtualNode(factory.createIdentifier(propname), name.pos, name.end));
|
||||
var newImportSpecific = setVirtualNode(factory.createImportSpecifier(false, newPropertyName, name), oldImportClause.pos, oldImportClause.end);
|
||||
var newNamedBindings = setVirtualNode(factory.createNamedImports([newImportSpecific]), oldImportClause.pos, oldImportClause.end);
|
||||
var newImportClause = setVirtualNode(factory.createImportClause(isType, undefined, newNamedBindings), oldImportClause.pos, oldImportClause.end);
|
||||
var newImportDeclaration = setVirtualNode(factory.createImportDeclaration(undefined, newImportClause, newModuleSpecifier), oldStatement.pos, oldStatement.end);
|
||||
return newImportDeclaration;
|
||||
}
|
||||
function createImportDeclarationForKit(factory, isType, name, symbol, oldStatement) {
|
||||
var source = symbol.source.replace(/\.d.[e]?ts$/, '');
|
||||
var binding = symbol.bindings;
|
||||
if (binding === DEFAULT_KEYWORD) {
|
||||
return createNameImportDeclaration(factory, isType, name, source, oldStatement);
|
||||
}
|
||||
return createBindingImportDeclaration(factory, isType, binding, name, source, oldStatement);
|
||||
}
|
||||
function markKitImport(statement, markedkitImportRanges) {
|
||||
markedkitImportRanges.push({ pos: statement.pos, end: statement.end });
|
||||
}
|
||||
/* @internal */
|
||||
function isInMarkedKitImport(sourceFile, pos, end) {
|
||||
var _a;
|
||||
return !!((_a = sourceFile.markedKitImportRange) === null || _a === void 0 ? void 0 : _a.some(function (range) {
|
||||
return (range.pos <= pos) && (end <= range.end);
|
||||
}));
|
||||
}
|
||||
ts.isInMarkedKitImport = isInMarkedKitImport;
|
||||
function excludeStatementForKitImport(statement) {
|
||||
if (!ts.isImportDeclaration(statement) || // check is ImportDeclaration
|
||||
!statement.importClause || // exclude import 'mode'
|
||||
statement.importClause.isLazy || // exclude import lazy, it may report error
|
||||
(statement.importClause.namedBindings && ts.isNamespaceImport(statement.importClause.namedBindings)) || // exclude namespace import
|
||||
!ts.isStringLiteral(statement.moduleSpecifier) || statement.illegalDecorators || // exclude if may has error
|
||||
!statement.moduleSpecifier.text.startsWith(KIT_PREFIX) || // is not kit import
|
||||
statement.modifiers || // exclude if has modifiers
|
||||
statement.assertClause) { // not support assertClause
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// This symbols have error in kit files, so add it in white list and don't change
|
||||
var whiteListForErrorSymbol = [
|
||||
{ kitName: '@kit.CoreFileKit', symbolName: 'DfsListeners' },
|
||||
{ kitName: '@kit.NetworkKit', symbolName: 'VpnExtensionContext' },
|
||||
{ kitName: '@kit.ArkUI', symbolName: 'CustomContentDialog' },
|
||||
];
|
||||
// This symbol will clause new warning in ts files
|
||||
var whiteListForTsWarning = [
|
||||
{ kitName: '@kit.ConnectivityKit', symbolName: 'socket' },
|
||||
];
|
||||
// This files import the symbol from ets file, so we won't change them in ts files
|
||||
var whiteListForTsFile = new ts.Set([
|
||||
'@kit.AccountKit', '@kit.MapKit', '@kit.Penkit', '@kit.ScenarioFusionKit',
|
||||
'@kit.ServiceCollaborationKit', '@kit.SpeechKit', '@kit.VisionKit',
|
||||
]);
|
||||
function InWhiteList(moduleSpecifierText, importName, inEtsContext) {
|
||||
if (whiteListForErrorSymbol.some(function (info) { return (info.kitName === moduleSpecifierText && info.symbolName === importName); })) {
|
||||
return true;
|
||||
}
|
||||
if (!inEtsContext &&
|
||||
whiteListForTsWarning.some(function (info) { return (info.kitName === moduleSpecifierText && info.symbolName === importName); })) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function processKitStatementSuccess(factory, statement, jsonObject, inEtsContext, newImportStatements) {
|
||||
var importClause = statement.importClause;
|
||||
var moduleSpecifierText = statement.moduleSpecifier.text;
|
||||
var kitSymbol = jsonObject === null || jsonObject === void 0 ? void 0 : jsonObject.symbols;
|
||||
if (!kitSymbol) {
|
||||
return false;
|
||||
}
|
||||
var isType = importClause.isTypeOnly;
|
||||
if (importClause.name) {
|
||||
var symbol = kitSymbol[DEFAULT_KEYWORD];
|
||||
// has error when import ets declaration in ts file
|
||||
if (!symbol || (!inEtsContext && symbol.source.endsWith(ETS_DECLARATION))) {
|
||||
return false;
|
||||
}
|
||||
newImportStatements.push(createImportDeclarationForKit(factory, isType, importClause.name, symbol, statement));
|
||||
}
|
||||
if (importClause.namedBindings) {
|
||||
var hasError_1 = false;
|
||||
importClause.namedBindings.elements.forEach(function (element) {
|
||||
if (hasError_1) {
|
||||
return;
|
||||
}
|
||||
var importName = ts.unescapeLeadingUnderscores(element.propertyName ? element.propertyName.escapedText : element.name.escapedText);
|
||||
var aliasName = element.name;
|
||||
if (InWhiteList(moduleSpecifierText, importName, inEtsContext)) {
|
||||
hasError_1 = true;
|
||||
return;
|
||||
}
|
||||
var symbol = kitSymbol[importName];
|
||||
if (!symbol || !aliasName ||
|
||||
// has error when import ets declaration in ts file
|
||||
(!inEtsContext && symbol.source.endsWith(ETS_DECLARATION)) ||
|
||||
// can not have duplicate type
|
||||
(isType && element.isTypeOnly)) {
|
||||
hasError_1 = true;
|
||||
return;
|
||||
}
|
||||
newImportStatements.push(createImportDeclarationForKit(factory, isType || element.isTypeOnly, aliasName, symbol, statement));
|
||||
});
|
||||
if (hasError_1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/* @internal */
|
||||
function processKit(factory, statements, sdkPath, markedkitImportRanges, inEtsContext) {
|
||||
var list = [];
|
||||
var skipRestStatements = false;
|
||||
statements.forEach(function (statement) {
|
||||
// ArkTS don't allow import declaration after other statements
|
||||
if (!skipRestStatements && inEtsContext && !ts.isImportDeclaration(statement)) {
|
||||
skipRestStatements = true;
|
||||
}
|
||||
if (skipRestStatements || excludeStatementForKitImport(statement)) {
|
||||
list.push(statement);
|
||||
return;
|
||||
}
|
||||
var moduleSpecifierText = statement.moduleSpecifier.text;
|
||||
if (!inEtsContext && whiteListForTsFile.has(moduleSpecifierText)) {
|
||||
list.push(statement);
|
||||
return;
|
||||
}
|
||||
var jsonObject = getKitJsonObject(moduleSpecifierText, sdkPath);
|
||||
var newImportStatements = new Array();
|
||||
if (!processKitStatementSuccess(factory, statement, jsonObject, inEtsContext, newImportStatements)) {
|
||||
list.push(statement);
|
||||
return;
|
||||
}
|
||||
list.push.apply(list, newImportStatements);
|
||||
markKitImport(statement, markedkitImportRanges);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
ts.processKit = processKit;
|
||||
})(ts || (ts = {}));
|
||||
/* @internal */
|
||||
var ts;
|
||||
@ -120631,7 +120836,7 @@ var ts;
|
||||
return getTextOfNode(node.textSourceNode, includeTrivia);
|
||||
}
|
||||
var sourceFile = currentSourceFile; // const needed for control flow
|
||||
var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node);
|
||||
var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node) && !(node.flags & -2147483648 /* NodeFlags.NoOriginalText */);
|
||||
if (ts.isMemberName(node)) {
|
||||
if (!canUseSourceFile || ts.getSourceFileOfNode(node) !== ts.getOriginalNode(sourceFile)) {
|
||||
return ts.idText(node);
|
||||
@ -172118,11 +172323,13 @@ var ts;
|
||||
while (pos < end) {
|
||||
var token = ts.scanner.scan();
|
||||
var textPos = ts.scanner.getTextPos();
|
||||
if (textPos <= end) {
|
||||
if (token === 79 /* SyntaxKind.Identifier */) {
|
||||
ts.Debug.fail("Did not expect ".concat(ts.Debug.formatSyntaxKind(parent.kind), " to have an Identifier in its trivia"));
|
||||
if (!ts.isSourceFile(parent) || !ts.isInMarkedKitImport(parent, pos, textPos)) {
|
||||
if (textPos <= end) {
|
||||
if (token === 79 /* SyntaxKind.Identifier */) {
|
||||
ts.Debug.fail("Did not expect ".concat(ts.Debug.formatSyntaxKind(parent.kind), " to have an Identifier in its trivia"));
|
||||
}
|
||||
nodes.push(createNode(token, pos, textPos, parent));
|
||||
}
|
||||
nodes.push(createNode(token, pos, textPos, parent));
|
||||
}
|
||||
pos = textPos;
|
||||
if (token === 1 /* SyntaxKind.EndOfFileToken */) {
|
||||
|
2
lib/tsserverlibrary.d.ts
vendored
2
lib/tsserverlibrary.d.ts
vendored
@ -3200,6 +3200,7 @@ declare namespace ts {
|
||||
skipPathsInKeyForCompilationSettings?: boolean;
|
||||
compatibleSdkVersion?: number;
|
||||
compatibleSdkVersionStage?: string;
|
||||
noTransformedKitInParser?: boolean;
|
||||
[option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined;
|
||||
etsAnnotationsEnable?: boolean;
|
||||
}
|
||||
@ -5475,6 +5476,7 @@ declare namespace ts {
|
||||
function transformTypeExportImportAndConstEnumInTypeScript(context: TransformationContext): (node: SourceFile) => SourceFile;
|
||||
function hasTsNoCheckOrTsIgnoreFlag(node: SourceFile): boolean;
|
||||
function createObfTextSingleLineWriter(): EmitTextWriter;
|
||||
function cleanKitJsonCache(): void;
|
||||
}
|
||||
declare namespace ts {
|
||||
/**
|
||||
|
@ -4626,6 +4626,7 @@ var ts;
|
||||
/* @internal */ NodeFlags[NodeFlags["TypeCached"] = 134217728] = "TypeCached";
|
||||
/* @internal */ NodeFlags[NodeFlags["Deprecated"] = 268435456] = "Deprecated";
|
||||
NodeFlags[NodeFlags["EtsContext"] = 1073741824] = "EtsContext";
|
||||
/* @internal */ NodeFlags[NodeFlags["NoOriginalText"] = -2147483648] = "NoOriginalText";
|
||||
NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped";
|
||||
NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 768] = "ReachabilityCheckFlags";
|
||||
NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 2816] = "ReachabilityAndEmitFlags";
|
||||
@ -15338,7 +15339,8 @@ var ts;
|
||||
}
|
||||
ts.getLiteralText = getLiteralText;
|
||||
function canUseOriginalText(node, flags) {
|
||||
if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated)) {
|
||||
if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated) ||
|
||||
(node.flags & -2147483648 /* NodeFlags.NoOriginalText */)) {
|
||||
return false;
|
||||
}
|
||||
if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* TokenFlags.ContainsSeparator */) {
|
||||
@ -32962,9 +32964,17 @@ var ts;
|
||||
// Prime the scanner.
|
||||
nextToken();
|
||||
var statements = parseList(0 /* ParsingContext.SourceElements */, parseStatement);
|
||||
var markedkitImportRanges = new Array();
|
||||
var sdkPath = ts.getSdkPath(sourceFileCompilerOptions);
|
||||
statements = (!!sourceFileCompilerOptions.noTransformedKitInParser || !sdkPath || parseDiagnostics.length) ?
|
||||
statements :
|
||||
createNodeArray(ts.processKit(factory, statements, sdkPath, markedkitImportRanges, inEtsContext()), statements.pos);
|
||||
ts.Debug.assert(token() === 1 /* SyntaxKind.EndOfFileToken */);
|
||||
var endOfFileToken = addJSDocComment(parseTokenNode());
|
||||
var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags, setExternalModuleIndicator);
|
||||
if (markedkitImportRanges.length > 0) {
|
||||
sourceFile.markedKitImportRange = markedkitImportRanges;
|
||||
}
|
||||
// A member of ReadonlyArray<T> isn't assignable to a member of T[] (and prevents a direct cast) - but this is where we set up those members so they can be readonly in the future
|
||||
processCommentPragmas(sourceFile, sourceText);
|
||||
processPragmasIntoFields(sourceFile, reportPragmaDiagnostic);
|
||||
@ -47690,6 +47700,201 @@ var ts;
|
||||
return (ts.isIdentifier(nameExpr) && nameExpr.escapedText.toString() === 'Sendable');
|
||||
}
|
||||
ts.isSendableFunctionOrType = isSendableFunctionOrType;
|
||||
var JSON_SUFFIX = ".json";
|
||||
var KIT_PREFIX = '@kit.';
|
||||
var DEFAULT_KEYWORD = 'default';
|
||||
var ETS_DECLARATION = '.d.ets';
|
||||
var OHOS_KIT_CONFIG_PATH = './openharmony/ets/build-tools/ets-loader/kit_configs';
|
||||
var HMS_KIT_CONFIG_PATH = './hms/ets/build-tools/ets-loader/kit_configs';
|
||||
var kitJsonCache = new ts.Map();
|
||||
/* @internal */
|
||||
function getSdkPath(compilerOptions) {
|
||||
return compilerOptions.etsLoaderPath ? ts.resolvePath(compilerOptions.etsLoaderPath, '../../../..') : undefined;
|
||||
}
|
||||
ts.getSdkPath = getSdkPath;
|
||||
function getKitJsonObject(name, sdkPath) {
|
||||
if (kitJsonCache === null || kitJsonCache === void 0 ? void 0 : kitJsonCache.has(name)) {
|
||||
return kitJsonCache.get(name);
|
||||
}
|
||||
var ohosJsonPath = ts.resolvePath(sdkPath, OHOS_KIT_CONFIG_PATH, "./".concat(name).concat(JSON_SUFFIX));
|
||||
var hmsJsonPath = ts.resolvePath(sdkPath, HMS_KIT_CONFIG_PATH, "./".concat(name).concat(JSON_SUFFIX));
|
||||
var fileInfo = ts.sys.fileExists(ohosJsonPath) ? ts.sys.readFile(ohosJsonPath, 'utf-8') :
|
||||
ts.sys.fileExists(hmsJsonPath) ? ts.sys.readFile(hmsJsonPath, 'utf-8') :
|
||||
undefined;
|
||||
if (!fileInfo) {
|
||||
kitJsonCache === null || kitJsonCache === void 0 ? void 0 : kitJsonCache.set(name, undefined);
|
||||
return undefined;
|
||||
}
|
||||
var obj = JSON.parse(fileInfo);
|
||||
kitJsonCache === null || kitJsonCache === void 0 ? void 0 : kitJsonCache.set(name, obj);
|
||||
return obj;
|
||||
}
|
||||
function cleanKitJsonCache() {
|
||||
kitJsonCache === null || kitJsonCache === void 0 ? void 0 : kitJsonCache.clear();
|
||||
}
|
||||
ts.cleanKitJsonCache = cleanKitJsonCache;
|
||||
function setVirtualNode(node, start, end) {
|
||||
if (start === void 0) { start = 0; }
|
||||
if (end === void 0) { end = 0; }
|
||||
node.virtual = true;
|
||||
ts.setTextRangePosEnd(node, start, end);
|
||||
return node;
|
||||
}
|
||||
function setNoOriginalText(node) {
|
||||
node.flags |= -2147483648 /* NodeFlags.NoOriginalText */;
|
||||
return node;
|
||||
}
|
||||
function createNameImportDeclaration(factory, isType, name, source, oldStatement) {
|
||||
var oldModuleSpecifier = oldStatement.moduleSpecifier;
|
||||
var oldImportClause = oldStatement.importClause; // shouldn't be undefined
|
||||
var newModuleSpecifier = setNoOriginalText(setVirtualNode(factory.createStringLiteral(source), oldModuleSpecifier.pos, oldModuleSpecifier.end));
|
||||
var newImportClause = setVirtualNode(factory.createImportClause(isType, name, undefined), oldImportClause.pos, oldImportClause.end);
|
||||
var newImportDeclaration = setVirtualNode(factory.createImportDeclaration(undefined, newImportClause, newModuleSpecifier), oldStatement.pos, oldStatement.end);
|
||||
return newImportDeclaration;
|
||||
}
|
||||
function createBindingImportDeclaration(factory, isType, propname, name, source, oldStatement) {
|
||||
var oldModuleSpecifier = oldStatement.moduleSpecifier;
|
||||
var oldImportClause = oldStatement.importClause; // shouldn't be undefined
|
||||
var newModuleSpecifier = setNoOriginalText(setVirtualNode(factory.createStringLiteral(source), oldModuleSpecifier.pos, oldModuleSpecifier.end));
|
||||
var newPropertyName = setNoOriginalText(setVirtualNode(factory.createIdentifier(propname), name.pos, name.end));
|
||||
var newImportSpecific = setVirtualNode(factory.createImportSpecifier(false, newPropertyName, name), oldImportClause.pos, oldImportClause.end);
|
||||
var newNamedBindings = setVirtualNode(factory.createNamedImports([newImportSpecific]), oldImportClause.pos, oldImportClause.end);
|
||||
var newImportClause = setVirtualNode(factory.createImportClause(isType, undefined, newNamedBindings), oldImportClause.pos, oldImportClause.end);
|
||||
var newImportDeclaration = setVirtualNode(factory.createImportDeclaration(undefined, newImportClause, newModuleSpecifier), oldStatement.pos, oldStatement.end);
|
||||
return newImportDeclaration;
|
||||
}
|
||||
function createImportDeclarationForKit(factory, isType, name, symbol, oldStatement) {
|
||||
var source = symbol.source.replace(/\.d.[e]?ts$/, '');
|
||||
var binding = symbol.bindings;
|
||||
if (binding === DEFAULT_KEYWORD) {
|
||||
return createNameImportDeclaration(factory, isType, name, source, oldStatement);
|
||||
}
|
||||
return createBindingImportDeclaration(factory, isType, binding, name, source, oldStatement);
|
||||
}
|
||||
function markKitImport(statement, markedkitImportRanges) {
|
||||
markedkitImportRanges.push({ pos: statement.pos, end: statement.end });
|
||||
}
|
||||
/* @internal */
|
||||
function isInMarkedKitImport(sourceFile, pos, end) {
|
||||
var _a;
|
||||
return !!((_a = sourceFile.markedKitImportRange) === null || _a === void 0 ? void 0 : _a.some(function (range) {
|
||||
return (range.pos <= pos) && (end <= range.end);
|
||||
}));
|
||||
}
|
||||
ts.isInMarkedKitImport = isInMarkedKitImport;
|
||||
function excludeStatementForKitImport(statement) {
|
||||
if (!ts.isImportDeclaration(statement) || // check is ImportDeclaration
|
||||
!statement.importClause || // exclude import 'mode'
|
||||
statement.importClause.isLazy || // exclude import lazy, it may report error
|
||||
(statement.importClause.namedBindings && ts.isNamespaceImport(statement.importClause.namedBindings)) || // exclude namespace import
|
||||
!ts.isStringLiteral(statement.moduleSpecifier) || statement.illegalDecorators || // exclude if may has error
|
||||
!statement.moduleSpecifier.text.startsWith(KIT_PREFIX) || // is not kit import
|
||||
statement.modifiers || // exclude if has modifiers
|
||||
statement.assertClause) { // not support assertClause
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// This symbols have error in kit files, so add it in white list and don't change
|
||||
var whiteListForErrorSymbol = [
|
||||
{ kitName: '@kit.CoreFileKit', symbolName: 'DfsListeners' },
|
||||
{ kitName: '@kit.NetworkKit', symbolName: 'VpnExtensionContext' },
|
||||
{ kitName: '@kit.ArkUI', symbolName: 'CustomContentDialog' },
|
||||
];
|
||||
// This symbol will clause new warning in ts files
|
||||
var whiteListForTsWarning = [
|
||||
{ kitName: '@kit.ConnectivityKit', symbolName: 'socket' },
|
||||
];
|
||||
// This files import the symbol from ets file, so we won't change them in ts files
|
||||
var whiteListForTsFile = new ts.Set([
|
||||
'@kit.AccountKit', '@kit.MapKit', '@kit.Penkit', '@kit.ScenarioFusionKit',
|
||||
'@kit.ServiceCollaborationKit', '@kit.SpeechKit', '@kit.VisionKit',
|
||||
]);
|
||||
function InWhiteList(moduleSpecifierText, importName, inEtsContext) {
|
||||
if (whiteListForErrorSymbol.some(function (info) { return (info.kitName === moduleSpecifierText && info.symbolName === importName); })) {
|
||||
return true;
|
||||
}
|
||||
if (!inEtsContext &&
|
||||
whiteListForTsWarning.some(function (info) { return (info.kitName === moduleSpecifierText && info.symbolName === importName); })) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function processKitStatementSuccess(factory, statement, jsonObject, inEtsContext, newImportStatements) {
|
||||
var importClause = statement.importClause;
|
||||
var moduleSpecifierText = statement.moduleSpecifier.text;
|
||||
var kitSymbol = jsonObject === null || jsonObject === void 0 ? void 0 : jsonObject.symbols;
|
||||
if (!kitSymbol) {
|
||||
return false;
|
||||
}
|
||||
var isType = importClause.isTypeOnly;
|
||||
if (importClause.name) {
|
||||
var symbol = kitSymbol[DEFAULT_KEYWORD];
|
||||
// has error when import ets declaration in ts file
|
||||
if (!symbol || (!inEtsContext && symbol.source.endsWith(ETS_DECLARATION))) {
|
||||
return false;
|
||||
}
|
||||
newImportStatements.push(createImportDeclarationForKit(factory, isType, importClause.name, symbol, statement));
|
||||
}
|
||||
if (importClause.namedBindings) {
|
||||
var hasError_1 = false;
|
||||
importClause.namedBindings.elements.forEach(function (element) {
|
||||
if (hasError_1) {
|
||||
return;
|
||||
}
|
||||
var importName = ts.unescapeLeadingUnderscores(element.propertyName ? element.propertyName.escapedText : element.name.escapedText);
|
||||
var aliasName = element.name;
|
||||
if (InWhiteList(moduleSpecifierText, importName, inEtsContext)) {
|
||||
hasError_1 = true;
|
||||
return;
|
||||
}
|
||||
var symbol = kitSymbol[importName];
|
||||
if (!symbol || !aliasName ||
|
||||
// has error when import ets declaration in ts file
|
||||
(!inEtsContext && symbol.source.endsWith(ETS_DECLARATION)) ||
|
||||
// can not have duplicate type
|
||||
(isType && element.isTypeOnly)) {
|
||||
hasError_1 = true;
|
||||
return;
|
||||
}
|
||||
newImportStatements.push(createImportDeclarationForKit(factory, isType || element.isTypeOnly, aliasName, symbol, statement));
|
||||
});
|
||||
if (hasError_1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/* @internal */
|
||||
function processKit(factory, statements, sdkPath, markedkitImportRanges, inEtsContext) {
|
||||
var list = [];
|
||||
var skipRestStatements = false;
|
||||
statements.forEach(function (statement) {
|
||||
// ArkTS don't allow import declaration after other statements
|
||||
if (!skipRestStatements && inEtsContext && !ts.isImportDeclaration(statement)) {
|
||||
skipRestStatements = true;
|
||||
}
|
||||
if (skipRestStatements || excludeStatementForKitImport(statement)) {
|
||||
list.push(statement);
|
||||
return;
|
||||
}
|
||||
var moduleSpecifierText = statement.moduleSpecifier.text;
|
||||
if (!inEtsContext && whiteListForTsFile.has(moduleSpecifierText)) {
|
||||
list.push(statement);
|
||||
return;
|
||||
}
|
||||
var jsonObject = getKitJsonObject(moduleSpecifierText, sdkPath);
|
||||
var newImportStatements = new Array();
|
||||
if (!processKitStatementSuccess(factory, statement, jsonObject, inEtsContext, newImportStatements)) {
|
||||
list.push(statement);
|
||||
return;
|
||||
}
|
||||
list.push.apply(list, newImportStatements);
|
||||
markKitImport(statement, markedkitImportRanges);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
ts.processKit = processKit;
|
||||
})(ts || (ts = {}));
|
||||
/* @internal */
|
||||
var ts;
|
||||
@ -120630,7 +120835,7 @@ var ts;
|
||||
return getTextOfNode(node.textSourceNode, includeTrivia);
|
||||
}
|
||||
var sourceFile = currentSourceFile; // const needed for control flow
|
||||
var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node);
|
||||
var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node) && !(node.flags & -2147483648 /* NodeFlags.NoOriginalText */);
|
||||
if (ts.isMemberName(node)) {
|
||||
if (!canUseSourceFile || ts.getSourceFileOfNode(node) !== ts.getOriginalNode(sourceFile)) {
|
||||
return ts.idText(node);
|
||||
@ -172537,11 +172742,13 @@ var ts;
|
||||
while (pos < end) {
|
||||
var token = ts.scanner.scan();
|
||||
var textPos = ts.scanner.getTextPos();
|
||||
if (textPos <= end) {
|
||||
if (token === 79 /* SyntaxKind.Identifier */) {
|
||||
ts.Debug.fail("Did not expect ".concat(ts.Debug.formatSyntaxKind(parent.kind), " to have an Identifier in its trivia"));
|
||||
if (!ts.isSourceFile(parent) || !ts.isInMarkedKitImport(parent, pos, textPos)) {
|
||||
if (textPos <= end) {
|
||||
if (token === 79 /* SyntaxKind.Identifier */) {
|
||||
ts.Debug.fail("Did not expect ".concat(ts.Debug.formatSyntaxKind(parent.kind), " to have an Identifier in its trivia"));
|
||||
}
|
||||
nodes.push(createNode(token, pos, textPos, parent));
|
||||
}
|
||||
nodes.push(createNode(token, pos, textPos, parent));
|
||||
}
|
||||
pos = textPos;
|
||||
if (token === 1 /* SyntaxKind.EndOfFileToken */) {
|
||||
|
2
lib/typescript.d.ts
vendored
2
lib/typescript.d.ts
vendored
@ -3200,6 +3200,7 @@ declare namespace ts {
|
||||
skipPathsInKeyForCompilationSettings?: boolean;
|
||||
compatibleSdkVersion?: number;
|
||||
compatibleSdkVersionStage?: string;
|
||||
noTransformedKitInParser?: boolean;
|
||||
[option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined;
|
||||
etsAnnotationsEnable?: boolean;
|
||||
}
|
||||
@ -5475,6 +5476,7 @@ declare namespace ts {
|
||||
function transformTypeExportImportAndConstEnumInTypeScript(context: TransformationContext): (node: SourceFile) => SourceFile;
|
||||
function hasTsNoCheckOrTsIgnoreFlag(node: SourceFile): boolean;
|
||||
function createObfTextSingleLineWriter(): EmitTextWriter;
|
||||
function cleanKitJsonCache(): void;
|
||||
}
|
||||
declare namespace ts {
|
||||
/**
|
||||
|
@ -4617,6 +4617,7 @@ var ts;
|
||||
/* @internal */ NodeFlags[NodeFlags["TypeCached"] = 134217728] = "TypeCached";
|
||||
/* @internal */ NodeFlags[NodeFlags["Deprecated"] = 268435456] = "Deprecated";
|
||||
NodeFlags[NodeFlags["EtsContext"] = 1073741824] = "EtsContext";
|
||||
/* @internal */ NodeFlags[NodeFlags["NoOriginalText"] = -2147483648] = "NoOriginalText";
|
||||
NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped";
|
||||
NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 768] = "ReachabilityCheckFlags";
|
||||
NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 2816] = "ReachabilityAndEmitFlags";
|
||||
@ -15329,7 +15330,8 @@ var ts;
|
||||
}
|
||||
ts.getLiteralText = getLiteralText;
|
||||
function canUseOriginalText(node, flags) {
|
||||
if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated)) {
|
||||
if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated) ||
|
||||
(node.flags & -2147483648 /* NodeFlags.NoOriginalText */)) {
|
||||
return false;
|
||||
}
|
||||
if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* TokenFlags.ContainsSeparator */) {
|
||||
@ -32953,9 +32955,17 @@ var ts;
|
||||
// Prime the scanner.
|
||||
nextToken();
|
||||
var statements = parseList(0 /* ParsingContext.SourceElements */, parseStatement);
|
||||
var markedkitImportRanges = new Array();
|
||||
var sdkPath = ts.getSdkPath(sourceFileCompilerOptions);
|
||||
statements = (!!sourceFileCompilerOptions.noTransformedKitInParser || !sdkPath || parseDiagnostics.length) ?
|
||||
statements :
|
||||
createNodeArray(ts.processKit(factory, statements, sdkPath, markedkitImportRanges, inEtsContext()), statements.pos);
|
||||
ts.Debug.assert(token() === 1 /* SyntaxKind.EndOfFileToken */);
|
||||
var endOfFileToken = addJSDocComment(parseTokenNode());
|
||||
var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags, setExternalModuleIndicator);
|
||||
if (markedkitImportRanges.length > 0) {
|
||||
sourceFile.markedKitImportRange = markedkitImportRanges;
|
||||
}
|
||||
// A member of ReadonlyArray<T> isn't assignable to a member of T[] (and prevents a direct cast) - but this is where we set up those members so they can be readonly in the future
|
||||
processCommentPragmas(sourceFile, sourceText);
|
||||
processPragmasIntoFields(sourceFile, reportPragmaDiagnostic);
|
||||
@ -47681,6 +47691,201 @@ var ts;
|
||||
return (ts.isIdentifier(nameExpr) && nameExpr.escapedText.toString() === 'Sendable');
|
||||
}
|
||||
ts.isSendableFunctionOrType = isSendableFunctionOrType;
|
||||
var JSON_SUFFIX = ".json";
|
||||
var KIT_PREFIX = '@kit.';
|
||||
var DEFAULT_KEYWORD = 'default';
|
||||
var ETS_DECLARATION = '.d.ets';
|
||||
var OHOS_KIT_CONFIG_PATH = './openharmony/ets/build-tools/ets-loader/kit_configs';
|
||||
var HMS_KIT_CONFIG_PATH = './hms/ets/build-tools/ets-loader/kit_configs';
|
||||
var kitJsonCache = new ts.Map();
|
||||
/* @internal */
|
||||
function getSdkPath(compilerOptions) {
|
||||
return compilerOptions.etsLoaderPath ? ts.resolvePath(compilerOptions.etsLoaderPath, '../../../..') : undefined;
|
||||
}
|
||||
ts.getSdkPath = getSdkPath;
|
||||
function getKitJsonObject(name, sdkPath) {
|
||||
if (kitJsonCache === null || kitJsonCache === void 0 ? void 0 : kitJsonCache.has(name)) {
|
||||
return kitJsonCache.get(name);
|
||||
}
|
||||
var ohosJsonPath = ts.resolvePath(sdkPath, OHOS_KIT_CONFIG_PATH, "./".concat(name).concat(JSON_SUFFIX));
|
||||
var hmsJsonPath = ts.resolvePath(sdkPath, HMS_KIT_CONFIG_PATH, "./".concat(name).concat(JSON_SUFFIX));
|
||||
var fileInfo = ts.sys.fileExists(ohosJsonPath) ? ts.sys.readFile(ohosJsonPath, 'utf-8') :
|
||||
ts.sys.fileExists(hmsJsonPath) ? ts.sys.readFile(hmsJsonPath, 'utf-8') :
|
||||
undefined;
|
||||
if (!fileInfo) {
|
||||
kitJsonCache === null || kitJsonCache === void 0 ? void 0 : kitJsonCache.set(name, undefined);
|
||||
return undefined;
|
||||
}
|
||||
var obj = JSON.parse(fileInfo);
|
||||
kitJsonCache === null || kitJsonCache === void 0 ? void 0 : kitJsonCache.set(name, obj);
|
||||
return obj;
|
||||
}
|
||||
function cleanKitJsonCache() {
|
||||
kitJsonCache === null || kitJsonCache === void 0 ? void 0 : kitJsonCache.clear();
|
||||
}
|
||||
ts.cleanKitJsonCache = cleanKitJsonCache;
|
||||
function setVirtualNode(node, start, end) {
|
||||
if (start === void 0) { start = 0; }
|
||||
if (end === void 0) { end = 0; }
|
||||
node.virtual = true;
|
||||
ts.setTextRangePosEnd(node, start, end);
|
||||
return node;
|
||||
}
|
||||
function setNoOriginalText(node) {
|
||||
node.flags |= -2147483648 /* NodeFlags.NoOriginalText */;
|
||||
return node;
|
||||
}
|
||||
function createNameImportDeclaration(factory, isType, name, source, oldStatement) {
|
||||
var oldModuleSpecifier = oldStatement.moduleSpecifier;
|
||||
var oldImportClause = oldStatement.importClause; // shouldn't be undefined
|
||||
var newModuleSpecifier = setNoOriginalText(setVirtualNode(factory.createStringLiteral(source), oldModuleSpecifier.pos, oldModuleSpecifier.end));
|
||||
var newImportClause = setVirtualNode(factory.createImportClause(isType, name, undefined), oldImportClause.pos, oldImportClause.end);
|
||||
var newImportDeclaration = setVirtualNode(factory.createImportDeclaration(undefined, newImportClause, newModuleSpecifier), oldStatement.pos, oldStatement.end);
|
||||
return newImportDeclaration;
|
||||
}
|
||||
function createBindingImportDeclaration(factory, isType, propname, name, source, oldStatement) {
|
||||
var oldModuleSpecifier = oldStatement.moduleSpecifier;
|
||||
var oldImportClause = oldStatement.importClause; // shouldn't be undefined
|
||||
var newModuleSpecifier = setNoOriginalText(setVirtualNode(factory.createStringLiteral(source), oldModuleSpecifier.pos, oldModuleSpecifier.end));
|
||||
var newPropertyName = setNoOriginalText(setVirtualNode(factory.createIdentifier(propname), name.pos, name.end));
|
||||
var newImportSpecific = setVirtualNode(factory.createImportSpecifier(false, newPropertyName, name), oldImportClause.pos, oldImportClause.end);
|
||||
var newNamedBindings = setVirtualNode(factory.createNamedImports([newImportSpecific]), oldImportClause.pos, oldImportClause.end);
|
||||
var newImportClause = setVirtualNode(factory.createImportClause(isType, undefined, newNamedBindings), oldImportClause.pos, oldImportClause.end);
|
||||
var newImportDeclaration = setVirtualNode(factory.createImportDeclaration(undefined, newImportClause, newModuleSpecifier), oldStatement.pos, oldStatement.end);
|
||||
return newImportDeclaration;
|
||||
}
|
||||
function createImportDeclarationForKit(factory, isType, name, symbol, oldStatement) {
|
||||
var source = symbol.source.replace(/\.d.[e]?ts$/, '');
|
||||
var binding = symbol.bindings;
|
||||
if (binding === DEFAULT_KEYWORD) {
|
||||
return createNameImportDeclaration(factory, isType, name, source, oldStatement);
|
||||
}
|
||||
return createBindingImportDeclaration(factory, isType, binding, name, source, oldStatement);
|
||||
}
|
||||
function markKitImport(statement, markedkitImportRanges) {
|
||||
markedkitImportRanges.push({ pos: statement.pos, end: statement.end });
|
||||
}
|
||||
/* @internal */
|
||||
function isInMarkedKitImport(sourceFile, pos, end) {
|
||||
var _a;
|
||||
return !!((_a = sourceFile.markedKitImportRange) === null || _a === void 0 ? void 0 : _a.some(function (range) {
|
||||
return (range.pos <= pos) && (end <= range.end);
|
||||
}));
|
||||
}
|
||||
ts.isInMarkedKitImport = isInMarkedKitImport;
|
||||
function excludeStatementForKitImport(statement) {
|
||||
if (!ts.isImportDeclaration(statement) || // check is ImportDeclaration
|
||||
!statement.importClause || // exclude import 'mode'
|
||||
statement.importClause.isLazy || // exclude import lazy, it may report error
|
||||
(statement.importClause.namedBindings && ts.isNamespaceImport(statement.importClause.namedBindings)) || // exclude namespace import
|
||||
!ts.isStringLiteral(statement.moduleSpecifier) || statement.illegalDecorators || // exclude if may has error
|
||||
!statement.moduleSpecifier.text.startsWith(KIT_PREFIX) || // is not kit import
|
||||
statement.modifiers || // exclude if has modifiers
|
||||
statement.assertClause) { // not support assertClause
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// This symbols have error in kit files, so add it in white list and don't change
|
||||
var whiteListForErrorSymbol = [
|
||||
{ kitName: '@kit.CoreFileKit', symbolName: 'DfsListeners' },
|
||||
{ kitName: '@kit.NetworkKit', symbolName: 'VpnExtensionContext' },
|
||||
{ kitName: '@kit.ArkUI', symbolName: 'CustomContentDialog' },
|
||||
];
|
||||
// This symbol will clause new warning in ts files
|
||||
var whiteListForTsWarning = [
|
||||
{ kitName: '@kit.ConnectivityKit', symbolName: 'socket' },
|
||||
];
|
||||
// This files import the symbol from ets file, so we won't change them in ts files
|
||||
var whiteListForTsFile = new ts.Set([
|
||||
'@kit.AccountKit', '@kit.MapKit', '@kit.Penkit', '@kit.ScenarioFusionKit',
|
||||
'@kit.ServiceCollaborationKit', '@kit.SpeechKit', '@kit.VisionKit',
|
||||
]);
|
||||
function InWhiteList(moduleSpecifierText, importName, inEtsContext) {
|
||||
if (whiteListForErrorSymbol.some(function (info) { return (info.kitName === moduleSpecifierText && info.symbolName === importName); })) {
|
||||
return true;
|
||||
}
|
||||
if (!inEtsContext &&
|
||||
whiteListForTsWarning.some(function (info) { return (info.kitName === moduleSpecifierText && info.symbolName === importName); })) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function processKitStatementSuccess(factory, statement, jsonObject, inEtsContext, newImportStatements) {
|
||||
var importClause = statement.importClause;
|
||||
var moduleSpecifierText = statement.moduleSpecifier.text;
|
||||
var kitSymbol = jsonObject === null || jsonObject === void 0 ? void 0 : jsonObject.symbols;
|
||||
if (!kitSymbol) {
|
||||
return false;
|
||||
}
|
||||
var isType = importClause.isTypeOnly;
|
||||
if (importClause.name) {
|
||||
var symbol = kitSymbol[DEFAULT_KEYWORD];
|
||||
// has error when import ets declaration in ts file
|
||||
if (!symbol || (!inEtsContext && symbol.source.endsWith(ETS_DECLARATION))) {
|
||||
return false;
|
||||
}
|
||||
newImportStatements.push(createImportDeclarationForKit(factory, isType, importClause.name, symbol, statement));
|
||||
}
|
||||
if (importClause.namedBindings) {
|
||||
var hasError_1 = false;
|
||||
importClause.namedBindings.elements.forEach(function (element) {
|
||||
if (hasError_1) {
|
||||
return;
|
||||
}
|
||||
var importName = ts.unescapeLeadingUnderscores(element.propertyName ? element.propertyName.escapedText : element.name.escapedText);
|
||||
var aliasName = element.name;
|
||||
if (InWhiteList(moduleSpecifierText, importName, inEtsContext)) {
|
||||
hasError_1 = true;
|
||||
return;
|
||||
}
|
||||
var symbol = kitSymbol[importName];
|
||||
if (!symbol || !aliasName ||
|
||||
// has error when import ets declaration in ts file
|
||||
(!inEtsContext && symbol.source.endsWith(ETS_DECLARATION)) ||
|
||||
// can not have duplicate type
|
||||
(isType && element.isTypeOnly)) {
|
||||
hasError_1 = true;
|
||||
return;
|
||||
}
|
||||
newImportStatements.push(createImportDeclarationForKit(factory, isType || element.isTypeOnly, aliasName, symbol, statement));
|
||||
});
|
||||
if (hasError_1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/* @internal */
|
||||
function processKit(factory, statements, sdkPath, markedkitImportRanges, inEtsContext) {
|
||||
var list = [];
|
||||
var skipRestStatements = false;
|
||||
statements.forEach(function (statement) {
|
||||
// ArkTS don't allow import declaration after other statements
|
||||
if (!skipRestStatements && inEtsContext && !ts.isImportDeclaration(statement)) {
|
||||
skipRestStatements = true;
|
||||
}
|
||||
if (skipRestStatements || excludeStatementForKitImport(statement)) {
|
||||
list.push(statement);
|
||||
return;
|
||||
}
|
||||
var moduleSpecifierText = statement.moduleSpecifier.text;
|
||||
if (!inEtsContext && whiteListForTsFile.has(moduleSpecifierText)) {
|
||||
list.push(statement);
|
||||
return;
|
||||
}
|
||||
var jsonObject = getKitJsonObject(moduleSpecifierText, sdkPath);
|
||||
var newImportStatements = new Array();
|
||||
if (!processKitStatementSuccess(factory, statement, jsonObject, inEtsContext, newImportStatements)) {
|
||||
list.push(statement);
|
||||
return;
|
||||
}
|
||||
list.push.apply(list, newImportStatements);
|
||||
markKitImport(statement, markedkitImportRanges);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
ts.processKit = processKit;
|
||||
})(ts || (ts = {}));
|
||||
/* @internal */
|
||||
var ts;
|
||||
@ -120621,7 +120826,7 @@ var ts;
|
||||
return getTextOfNode(node.textSourceNode, includeTrivia);
|
||||
}
|
||||
var sourceFile = currentSourceFile; // const needed for control flow
|
||||
var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node);
|
||||
var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node) && !(node.flags & -2147483648 /* NodeFlags.NoOriginalText */);
|
||||
if (ts.isMemberName(node)) {
|
||||
if (!canUseSourceFile || ts.getSourceFileOfNode(node) !== ts.getOriginalNode(sourceFile)) {
|
||||
return ts.idText(node);
|
||||
@ -172528,11 +172733,13 @@ var ts;
|
||||
while (pos < end) {
|
||||
var token = ts.scanner.scan();
|
||||
var textPos = ts.scanner.getTextPos();
|
||||
if (textPos <= end) {
|
||||
if (token === 79 /* SyntaxKind.Identifier */) {
|
||||
ts.Debug.fail("Did not expect ".concat(ts.Debug.formatSyntaxKind(parent.kind), " to have an Identifier in its trivia"));
|
||||
if (!ts.isSourceFile(parent) || !ts.isInMarkedKitImport(parent, pos, textPos)) {
|
||||
if (textPos <= end) {
|
||||
if (token === 79 /* SyntaxKind.Identifier */) {
|
||||
ts.Debug.fail("Did not expect ".concat(ts.Debug.formatSyntaxKind(parent.kind), " to have an Identifier in its trivia"));
|
||||
}
|
||||
nodes.push(createNode(token, pos, textPos, parent));
|
||||
}
|
||||
nodes.push(createNode(token, pos, textPos, parent));
|
||||
}
|
||||
pos = textPos;
|
||||
if (token === 1 /* SyntaxKind.EndOfFileToken */) {
|
||||
|
2
lib/typescriptServices.d.ts
vendored
2
lib/typescriptServices.d.ts
vendored
@ -3200,6 +3200,7 @@ declare namespace ts {
|
||||
skipPathsInKeyForCompilationSettings?: boolean;
|
||||
compatibleSdkVersion?: number;
|
||||
compatibleSdkVersionStage?: string;
|
||||
noTransformedKitInParser?: boolean;
|
||||
[option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined;
|
||||
etsAnnotationsEnable?: boolean;
|
||||
}
|
||||
@ -5475,6 +5476,7 @@ declare namespace ts {
|
||||
function transformTypeExportImportAndConstEnumInTypeScript(context: TransformationContext): (node: SourceFile) => SourceFile;
|
||||
function hasTsNoCheckOrTsIgnoreFlag(node: SourceFile): boolean;
|
||||
function createObfTextSingleLineWriter(): EmitTextWriter;
|
||||
function cleanKitJsonCache(): void;
|
||||
}
|
||||
declare namespace ts {
|
||||
/**
|
||||
|
@ -4617,6 +4617,7 @@ var ts;
|
||||
/* @internal */ NodeFlags[NodeFlags["TypeCached"] = 134217728] = "TypeCached";
|
||||
/* @internal */ NodeFlags[NodeFlags["Deprecated"] = 268435456] = "Deprecated";
|
||||
NodeFlags[NodeFlags["EtsContext"] = 1073741824] = "EtsContext";
|
||||
/* @internal */ NodeFlags[NodeFlags["NoOriginalText"] = -2147483648] = "NoOriginalText";
|
||||
NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped";
|
||||
NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 768] = "ReachabilityCheckFlags";
|
||||
NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 2816] = "ReachabilityAndEmitFlags";
|
||||
@ -15329,7 +15330,8 @@ var ts;
|
||||
}
|
||||
ts.getLiteralText = getLiteralText;
|
||||
function canUseOriginalText(node, flags) {
|
||||
if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated)) {
|
||||
if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated) ||
|
||||
(node.flags & -2147483648 /* NodeFlags.NoOriginalText */)) {
|
||||
return false;
|
||||
}
|
||||
if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* TokenFlags.ContainsSeparator */) {
|
||||
@ -32953,9 +32955,17 @@ var ts;
|
||||
// Prime the scanner.
|
||||
nextToken();
|
||||
var statements = parseList(0 /* ParsingContext.SourceElements */, parseStatement);
|
||||
var markedkitImportRanges = new Array();
|
||||
var sdkPath = ts.getSdkPath(sourceFileCompilerOptions);
|
||||
statements = (!!sourceFileCompilerOptions.noTransformedKitInParser || !sdkPath || parseDiagnostics.length) ?
|
||||
statements :
|
||||
createNodeArray(ts.processKit(factory, statements, sdkPath, markedkitImportRanges, inEtsContext()), statements.pos);
|
||||
ts.Debug.assert(token() === 1 /* SyntaxKind.EndOfFileToken */);
|
||||
var endOfFileToken = addJSDocComment(parseTokenNode());
|
||||
var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags, setExternalModuleIndicator);
|
||||
if (markedkitImportRanges.length > 0) {
|
||||
sourceFile.markedKitImportRange = markedkitImportRanges;
|
||||
}
|
||||
// A member of ReadonlyArray<T> isn't assignable to a member of T[] (and prevents a direct cast) - but this is where we set up those members so they can be readonly in the future
|
||||
processCommentPragmas(sourceFile, sourceText);
|
||||
processPragmasIntoFields(sourceFile, reportPragmaDiagnostic);
|
||||
@ -47681,6 +47691,201 @@ var ts;
|
||||
return (ts.isIdentifier(nameExpr) && nameExpr.escapedText.toString() === 'Sendable');
|
||||
}
|
||||
ts.isSendableFunctionOrType = isSendableFunctionOrType;
|
||||
var JSON_SUFFIX = ".json";
|
||||
var KIT_PREFIX = '@kit.';
|
||||
var DEFAULT_KEYWORD = 'default';
|
||||
var ETS_DECLARATION = '.d.ets';
|
||||
var OHOS_KIT_CONFIG_PATH = './openharmony/ets/build-tools/ets-loader/kit_configs';
|
||||
var HMS_KIT_CONFIG_PATH = './hms/ets/build-tools/ets-loader/kit_configs';
|
||||
var kitJsonCache = new ts.Map();
|
||||
/* @internal */
|
||||
function getSdkPath(compilerOptions) {
|
||||
return compilerOptions.etsLoaderPath ? ts.resolvePath(compilerOptions.etsLoaderPath, '../../../..') : undefined;
|
||||
}
|
||||
ts.getSdkPath = getSdkPath;
|
||||
function getKitJsonObject(name, sdkPath) {
|
||||
if (kitJsonCache === null || kitJsonCache === void 0 ? void 0 : kitJsonCache.has(name)) {
|
||||
return kitJsonCache.get(name);
|
||||
}
|
||||
var ohosJsonPath = ts.resolvePath(sdkPath, OHOS_KIT_CONFIG_PATH, "./".concat(name).concat(JSON_SUFFIX));
|
||||
var hmsJsonPath = ts.resolvePath(sdkPath, HMS_KIT_CONFIG_PATH, "./".concat(name).concat(JSON_SUFFIX));
|
||||
var fileInfo = ts.sys.fileExists(ohosJsonPath) ? ts.sys.readFile(ohosJsonPath, 'utf-8') :
|
||||
ts.sys.fileExists(hmsJsonPath) ? ts.sys.readFile(hmsJsonPath, 'utf-8') :
|
||||
undefined;
|
||||
if (!fileInfo) {
|
||||
kitJsonCache === null || kitJsonCache === void 0 ? void 0 : kitJsonCache.set(name, undefined);
|
||||
return undefined;
|
||||
}
|
||||
var obj = JSON.parse(fileInfo);
|
||||
kitJsonCache === null || kitJsonCache === void 0 ? void 0 : kitJsonCache.set(name, obj);
|
||||
return obj;
|
||||
}
|
||||
function cleanKitJsonCache() {
|
||||
kitJsonCache === null || kitJsonCache === void 0 ? void 0 : kitJsonCache.clear();
|
||||
}
|
||||
ts.cleanKitJsonCache = cleanKitJsonCache;
|
||||
function setVirtualNode(node, start, end) {
|
||||
if (start === void 0) { start = 0; }
|
||||
if (end === void 0) { end = 0; }
|
||||
node.virtual = true;
|
||||
ts.setTextRangePosEnd(node, start, end);
|
||||
return node;
|
||||
}
|
||||
function setNoOriginalText(node) {
|
||||
node.flags |= -2147483648 /* NodeFlags.NoOriginalText */;
|
||||
return node;
|
||||
}
|
||||
function createNameImportDeclaration(factory, isType, name, source, oldStatement) {
|
||||
var oldModuleSpecifier = oldStatement.moduleSpecifier;
|
||||
var oldImportClause = oldStatement.importClause; // shouldn't be undefined
|
||||
var newModuleSpecifier = setNoOriginalText(setVirtualNode(factory.createStringLiteral(source), oldModuleSpecifier.pos, oldModuleSpecifier.end));
|
||||
var newImportClause = setVirtualNode(factory.createImportClause(isType, name, undefined), oldImportClause.pos, oldImportClause.end);
|
||||
var newImportDeclaration = setVirtualNode(factory.createImportDeclaration(undefined, newImportClause, newModuleSpecifier), oldStatement.pos, oldStatement.end);
|
||||
return newImportDeclaration;
|
||||
}
|
||||
function createBindingImportDeclaration(factory, isType, propname, name, source, oldStatement) {
|
||||
var oldModuleSpecifier = oldStatement.moduleSpecifier;
|
||||
var oldImportClause = oldStatement.importClause; // shouldn't be undefined
|
||||
var newModuleSpecifier = setNoOriginalText(setVirtualNode(factory.createStringLiteral(source), oldModuleSpecifier.pos, oldModuleSpecifier.end));
|
||||
var newPropertyName = setNoOriginalText(setVirtualNode(factory.createIdentifier(propname), name.pos, name.end));
|
||||
var newImportSpecific = setVirtualNode(factory.createImportSpecifier(false, newPropertyName, name), oldImportClause.pos, oldImportClause.end);
|
||||
var newNamedBindings = setVirtualNode(factory.createNamedImports([newImportSpecific]), oldImportClause.pos, oldImportClause.end);
|
||||
var newImportClause = setVirtualNode(factory.createImportClause(isType, undefined, newNamedBindings), oldImportClause.pos, oldImportClause.end);
|
||||
var newImportDeclaration = setVirtualNode(factory.createImportDeclaration(undefined, newImportClause, newModuleSpecifier), oldStatement.pos, oldStatement.end);
|
||||
return newImportDeclaration;
|
||||
}
|
||||
function createImportDeclarationForKit(factory, isType, name, symbol, oldStatement) {
|
||||
var source = symbol.source.replace(/\.d.[e]?ts$/, '');
|
||||
var binding = symbol.bindings;
|
||||
if (binding === DEFAULT_KEYWORD) {
|
||||
return createNameImportDeclaration(factory, isType, name, source, oldStatement);
|
||||
}
|
||||
return createBindingImportDeclaration(factory, isType, binding, name, source, oldStatement);
|
||||
}
|
||||
function markKitImport(statement, markedkitImportRanges) {
|
||||
markedkitImportRanges.push({ pos: statement.pos, end: statement.end });
|
||||
}
|
||||
/* @internal */
|
||||
function isInMarkedKitImport(sourceFile, pos, end) {
|
||||
var _a;
|
||||
return !!((_a = sourceFile.markedKitImportRange) === null || _a === void 0 ? void 0 : _a.some(function (range) {
|
||||
return (range.pos <= pos) && (end <= range.end);
|
||||
}));
|
||||
}
|
||||
ts.isInMarkedKitImport = isInMarkedKitImport;
|
||||
function excludeStatementForKitImport(statement) {
|
||||
if (!ts.isImportDeclaration(statement) || // check is ImportDeclaration
|
||||
!statement.importClause || // exclude import 'mode'
|
||||
statement.importClause.isLazy || // exclude import lazy, it may report error
|
||||
(statement.importClause.namedBindings && ts.isNamespaceImport(statement.importClause.namedBindings)) || // exclude namespace import
|
||||
!ts.isStringLiteral(statement.moduleSpecifier) || statement.illegalDecorators || // exclude if may has error
|
||||
!statement.moduleSpecifier.text.startsWith(KIT_PREFIX) || // is not kit import
|
||||
statement.modifiers || // exclude if has modifiers
|
||||
statement.assertClause) { // not support assertClause
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// This symbols have error in kit files, so add it in white list and don't change
|
||||
var whiteListForErrorSymbol = [
|
||||
{ kitName: '@kit.CoreFileKit', symbolName: 'DfsListeners' },
|
||||
{ kitName: '@kit.NetworkKit', symbolName: 'VpnExtensionContext' },
|
||||
{ kitName: '@kit.ArkUI', symbolName: 'CustomContentDialog' },
|
||||
];
|
||||
// This symbol will clause new warning in ts files
|
||||
var whiteListForTsWarning = [
|
||||
{ kitName: '@kit.ConnectivityKit', symbolName: 'socket' },
|
||||
];
|
||||
// This files import the symbol from ets file, so we won't change them in ts files
|
||||
var whiteListForTsFile = new ts.Set([
|
||||
'@kit.AccountKit', '@kit.MapKit', '@kit.Penkit', '@kit.ScenarioFusionKit',
|
||||
'@kit.ServiceCollaborationKit', '@kit.SpeechKit', '@kit.VisionKit',
|
||||
]);
|
||||
function InWhiteList(moduleSpecifierText, importName, inEtsContext) {
|
||||
if (whiteListForErrorSymbol.some(function (info) { return (info.kitName === moduleSpecifierText && info.symbolName === importName); })) {
|
||||
return true;
|
||||
}
|
||||
if (!inEtsContext &&
|
||||
whiteListForTsWarning.some(function (info) { return (info.kitName === moduleSpecifierText && info.symbolName === importName); })) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function processKitStatementSuccess(factory, statement, jsonObject, inEtsContext, newImportStatements) {
|
||||
var importClause = statement.importClause;
|
||||
var moduleSpecifierText = statement.moduleSpecifier.text;
|
||||
var kitSymbol = jsonObject === null || jsonObject === void 0 ? void 0 : jsonObject.symbols;
|
||||
if (!kitSymbol) {
|
||||
return false;
|
||||
}
|
||||
var isType = importClause.isTypeOnly;
|
||||
if (importClause.name) {
|
||||
var symbol = kitSymbol[DEFAULT_KEYWORD];
|
||||
// has error when import ets declaration in ts file
|
||||
if (!symbol || (!inEtsContext && symbol.source.endsWith(ETS_DECLARATION))) {
|
||||
return false;
|
||||
}
|
||||
newImportStatements.push(createImportDeclarationForKit(factory, isType, importClause.name, symbol, statement));
|
||||
}
|
||||
if (importClause.namedBindings) {
|
||||
var hasError_1 = false;
|
||||
importClause.namedBindings.elements.forEach(function (element) {
|
||||
if (hasError_1) {
|
||||
return;
|
||||
}
|
||||
var importName = ts.unescapeLeadingUnderscores(element.propertyName ? element.propertyName.escapedText : element.name.escapedText);
|
||||
var aliasName = element.name;
|
||||
if (InWhiteList(moduleSpecifierText, importName, inEtsContext)) {
|
||||
hasError_1 = true;
|
||||
return;
|
||||
}
|
||||
var symbol = kitSymbol[importName];
|
||||
if (!symbol || !aliasName ||
|
||||
// has error when import ets declaration in ts file
|
||||
(!inEtsContext && symbol.source.endsWith(ETS_DECLARATION)) ||
|
||||
// can not have duplicate type
|
||||
(isType && element.isTypeOnly)) {
|
||||
hasError_1 = true;
|
||||
return;
|
||||
}
|
||||
newImportStatements.push(createImportDeclarationForKit(factory, isType || element.isTypeOnly, aliasName, symbol, statement));
|
||||
});
|
||||
if (hasError_1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/* @internal */
|
||||
function processKit(factory, statements, sdkPath, markedkitImportRanges, inEtsContext) {
|
||||
var list = [];
|
||||
var skipRestStatements = false;
|
||||
statements.forEach(function (statement) {
|
||||
// ArkTS don't allow import declaration after other statements
|
||||
if (!skipRestStatements && inEtsContext && !ts.isImportDeclaration(statement)) {
|
||||
skipRestStatements = true;
|
||||
}
|
||||
if (skipRestStatements || excludeStatementForKitImport(statement)) {
|
||||
list.push(statement);
|
||||
return;
|
||||
}
|
||||
var moduleSpecifierText = statement.moduleSpecifier.text;
|
||||
if (!inEtsContext && whiteListForTsFile.has(moduleSpecifierText)) {
|
||||
list.push(statement);
|
||||
return;
|
||||
}
|
||||
var jsonObject = getKitJsonObject(moduleSpecifierText, sdkPath);
|
||||
var newImportStatements = new Array();
|
||||
if (!processKitStatementSuccess(factory, statement, jsonObject, inEtsContext, newImportStatements)) {
|
||||
list.push(statement);
|
||||
return;
|
||||
}
|
||||
list.push.apply(list, newImportStatements);
|
||||
markKitImport(statement, markedkitImportRanges);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
ts.processKit = processKit;
|
||||
})(ts || (ts = {}));
|
||||
/* @internal */
|
||||
var ts;
|
||||
@ -120621,7 +120826,7 @@ var ts;
|
||||
return getTextOfNode(node.textSourceNode, includeTrivia);
|
||||
}
|
||||
var sourceFile = currentSourceFile; // const needed for control flow
|
||||
var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node);
|
||||
var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node) && !(node.flags & -2147483648 /* NodeFlags.NoOriginalText */);
|
||||
if (ts.isMemberName(node)) {
|
||||
if (!canUseSourceFile || ts.getSourceFileOfNode(node) !== ts.getOriginalNode(sourceFile)) {
|
||||
return ts.idText(node);
|
||||
@ -172528,11 +172733,13 @@ var ts;
|
||||
while (pos < end) {
|
||||
var token = ts.scanner.scan();
|
||||
var textPos = ts.scanner.getTextPos();
|
||||
if (textPos <= end) {
|
||||
if (token === 79 /* SyntaxKind.Identifier */) {
|
||||
ts.Debug.fail("Did not expect ".concat(ts.Debug.formatSyntaxKind(parent.kind), " to have an Identifier in its trivia"));
|
||||
if (!ts.isSourceFile(parent) || !ts.isInMarkedKitImport(parent, pos, textPos)) {
|
||||
if (textPos <= end) {
|
||||
if (token === 79 /* SyntaxKind.Identifier */) {
|
||||
ts.Debug.fail("Did not expect ".concat(ts.Debug.formatSyntaxKind(parent.kind), " to have an Identifier in its trivia"));
|
||||
}
|
||||
nodes.push(createNode(token, pos, textPos, parent));
|
||||
}
|
||||
nodes.push(createNode(token, pos, textPos, parent));
|
||||
}
|
||||
pos = textPos;
|
||||
if (token === 1 /* SyntaxKind.EndOfFileToken */) {
|
||||
|
@ -4607,6 +4607,7 @@ var ts;
|
||||
/* @internal */ NodeFlags[NodeFlags["TypeCached"] = 134217728] = "TypeCached";
|
||||
/* @internal */ NodeFlags[NodeFlags["Deprecated"] = 268435456] = "Deprecated";
|
||||
NodeFlags[NodeFlags["EtsContext"] = 1073741824] = "EtsContext";
|
||||
/* @internal */ NodeFlags[NodeFlags["NoOriginalText"] = -2147483648] = "NoOriginalText";
|
||||
NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped";
|
||||
NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 768] = "ReachabilityCheckFlags";
|
||||
NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 2816] = "ReachabilityAndEmitFlags";
|
||||
@ -15319,7 +15320,8 @@ var ts;
|
||||
}
|
||||
ts.getLiteralText = getLiteralText;
|
||||
function canUseOriginalText(node, flags) {
|
||||
if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated)) {
|
||||
if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated) ||
|
||||
(node.flags & -2147483648 /* NodeFlags.NoOriginalText */)) {
|
||||
return false;
|
||||
}
|
||||
if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* TokenFlags.ContainsSeparator */) {
|
||||
@ -32943,9 +32945,17 @@ var ts;
|
||||
// Prime the scanner.
|
||||
nextToken();
|
||||
var statements = parseList(0 /* ParsingContext.SourceElements */, parseStatement);
|
||||
var markedkitImportRanges = new Array();
|
||||
var sdkPath = ts.getSdkPath(sourceFileCompilerOptions);
|
||||
statements = (!!sourceFileCompilerOptions.noTransformedKitInParser || !sdkPath || parseDiagnostics.length) ?
|
||||
statements :
|
||||
createNodeArray(ts.processKit(factory, statements, sdkPath, markedkitImportRanges, inEtsContext()), statements.pos);
|
||||
ts.Debug.assert(token() === 1 /* SyntaxKind.EndOfFileToken */);
|
||||
var endOfFileToken = addJSDocComment(parseTokenNode());
|
||||
var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags, setExternalModuleIndicator);
|
||||
if (markedkitImportRanges.length > 0) {
|
||||
sourceFile.markedKitImportRange = markedkitImportRanges;
|
||||
}
|
||||
// A member of ReadonlyArray<T> isn't assignable to a member of T[] (and prevents a direct cast) - but this is where we set up those members so they can be readonly in the future
|
||||
processCommentPragmas(sourceFile, sourceText);
|
||||
processPragmasIntoFields(sourceFile, reportPragmaDiagnostic);
|
||||
@ -47671,6 +47681,201 @@ var ts;
|
||||
return (ts.isIdentifier(nameExpr) && nameExpr.escapedText.toString() === 'Sendable');
|
||||
}
|
||||
ts.isSendableFunctionOrType = isSendableFunctionOrType;
|
||||
var JSON_SUFFIX = ".json";
|
||||
var KIT_PREFIX = '@kit.';
|
||||
var DEFAULT_KEYWORD = 'default';
|
||||
var ETS_DECLARATION = '.d.ets';
|
||||
var OHOS_KIT_CONFIG_PATH = './openharmony/ets/build-tools/ets-loader/kit_configs';
|
||||
var HMS_KIT_CONFIG_PATH = './hms/ets/build-tools/ets-loader/kit_configs';
|
||||
var kitJsonCache = new ts.Map();
|
||||
/* @internal */
|
||||
function getSdkPath(compilerOptions) {
|
||||
return compilerOptions.etsLoaderPath ? ts.resolvePath(compilerOptions.etsLoaderPath, '../../../..') : undefined;
|
||||
}
|
||||
ts.getSdkPath = getSdkPath;
|
||||
function getKitJsonObject(name, sdkPath) {
|
||||
if (kitJsonCache === null || kitJsonCache === void 0 ? void 0 : kitJsonCache.has(name)) {
|
||||
return kitJsonCache.get(name);
|
||||
}
|
||||
var ohosJsonPath = ts.resolvePath(sdkPath, OHOS_KIT_CONFIG_PATH, "./".concat(name).concat(JSON_SUFFIX));
|
||||
var hmsJsonPath = ts.resolvePath(sdkPath, HMS_KIT_CONFIG_PATH, "./".concat(name).concat(JSON_SUFFIX));
|
||||
var fileInfo = ts.sys.fileExists(ohosJsonPath) ? ts.sys.readFile(ohosJsonPath, 'utf-8') :
|
||||
ts.sys.fileExists(hmsJsonPath) ? ts.sys.readFile(hmsJsonPath, 'utf-8') :
|
||||
undefined;
|
||||
if (!fileInfo) {
|
||||
kitJsonCache === null || kitJsonCache === void 0 ? void 0 : kitJsonCache.set(name, undefined);
|
||||
return undefined;
|
||||
}
|
||||
var obj = JSON.parse(fileInfo);
|
||||
kitJsonCache === null || kitJsonCache === void 0 ? void 0 : kitJsonCache.set(name, obj);
|
||||
return obj;
|
||||
}
|
||||
function cleanKitJsonCache() {
|
||||
kitJsonCache === null || kitJsonCache === void 0 ? void 0 : kitJsonCache.clear();
|
||||
}
|
||||
ts.cleanKitJsonCache = cleanKitJsonCache;
|
||||
function setVirtualNode(node, start, end) {
|
||||
if (start === void 0) { start = 0; }
|
||||
if (end === void 0) { end = 0; }
|
||||
node.virtual = true;
|
||||
ts.setTextRangePosEnd(node, start, end);
|
||||
return node;
|
||||
}
|
||||
function setNoOriginalText(node) {
|
||||
node.flags |= -2147483648 /* NodeFlags.NoOriginalText */;
|
||||
return node;
|
||||
}
|
||||
function createNameImportDeclaration(factory, isType, name, source, oldStatement) {
|
||||
var oldModuleSpecifier = oldStatement.moduleSpecifier;
|
||||
var oldImportClause = oldStatement.importClause; // shouldn't be undefined
|
||||
var newModuleSpecifier = setNoOriginalText(setVirtualNode(factory.createStringLiteral(source), oldModuleSpecifier.pos, oldModuleSpecifier.end));
|
||||
var newImportClause = setVirtualNode(factory.createImportClause(isType, name, undefined), oldImportClause.pos, oldImportClause.end);
|
||||
var newImportDeclaration = setVirtualNode(factory.createImportDeclaration(undefined, newImportClause, newModuleSpecifier), oldStatement.pos, oldStatement.end);
|
||||
return newImportDeclaration;
|
||||
}
|
||||
function createBindingImportDeclaration(factory, isType, propname, name, source, oldStatement) {
|
||||
var oldModuleSpecifier = oldStatement.moduleSpecifier;
|
||||
var oldImportClause = oldStatement.importClause; // shouldn't be undefined
|
||||
var newModuleSpecifier = setNoOriginalText(setVirtualNode(factory.createStringLiteral(source), oldModuleSpecifier.pos, oldModuleSpecifier.end));
|
||||
var newPropertyName = setNoOriginalText(setVirtualNode(factory.createIdentifier(propname), name.pos, name.end));
|
||||
var newImportSpecific = setVirtualNode(factory.createImportSpecifier(false, newPropertyName, name), oldImportClause.pos, oldImportClause.end);
|
||||
var newNamedBindings = setVirtualNode(factory.createNamedImports([newImportSpecific]), oldImportClause.pos, oldImportClause.end);
|
||||
var newImportClause = setVirtualNode(factory.createImportClause(isType, undefined, newNamedBindings), oldImportClause.pos, oldImportClause.end);
|
||||
var newImportDeclaration = setVirtualNode(factory.createImportDeclaration(undefined, newImportClause, newModuleSpecifier), oldStatement.pos, oldStatement.end);
|
||||
return newImportDeclaration;
|
||||
}
|
||||
function createImportDeclarationForKit(factory, isType, name, symbol, oldStatement) {
|
||||
var source = symbol.source.replace(/\.d.[e]?ts$/, '');
|
||||
var binding = symbol.bindings;
|
||||
if (binding === DEFAULT_KEYWORD) {
|
||||
return createNameImportDeclaration(factory, isType, name, source, oldStatement);
|
||||
}
|
||||
return createBindingImportDeclaration(factory, isType, binding, name, source, oldStatement);
|
||||
}
|
||||
function markKitImport(statement, markedkitImportRanges) {
|
||||
markedkitImportRanges.push({ pos: statement.pos, end: statement.end });
|
||||
}
|
||||
/* @internal */
|
||||
function isInMarkedKitImport(sourceFile, pos, end) {
|
||||
var _a;
|
||||
return !!((_a = sourceFile.markedKitImportRange) === null || _a === void 0 ? void 0 : _a.some(function (range) {
|
||||
return (range.pos <= pos) && (end <= range.end);
|
||||
}));
|
||||
}
|
||||
ts.isInMarkedKitImport = isInMarkedKitImport;
|
||||
function excludeStatementForKitImport(statement) {
|
||||
if (!ts.isImportDeclaration(statement) || // check is ImportDeclaration
|
||||
!statement.importClause || // exclude import 'mode'
|
||||
statement.importClause.isLazy || // exclude import lazy, it may report error
|
||||
(statement.importClause.namedBindings && ts.isNamespaceImport(statement.importClause.namedBindings)) || // exclude namespace import
|
||||
!ts.isStringLiteral(statement.moduleSpecifier) || statement.illegalDecorators || // exclude if may has error
|
||||
!statement.moduleSpecifier.text.startsWith(KIT_PREFIX) || // is not kit import
|
||||
statement.modifiers || // exclude if has modifiers
|
||||
statement.assertClause) { // not support assertClause
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// This symbols have error in kit files, so add it in white list and don't change
|
||||
var whiteListForErrorSymbol = [
|
||||
{ kitName: '@kit.CoreFileKit', symbolName: 'DfsListeners' },
|
||||
{ kitName: '@kit.NetworkKit', symbolName: 'VpnExtensionContext' },
|
||||
{ kitName: '@kit.ArkUI', symbolName: 'CustomContentDialog' },
|
||||
];
|
||||
// This symbol will clause new warning in ts files
|
||||
var whiteListForTsWarning = [
|
||||
{ kitName: '@kit.ConnectivityKit', symbolName: 'socket' },
|
||||
];
|
||||
// This files import the symbol from ets file, so we won't change them in ts files
|
||||
var whiteListForTsFile = new ts.Set([
|
||||
'@kit.AccountKit', '@kit.MapKit', '@kit.Penkit', '@kit.ScenarioFusionKit',
|
||||
'@kit.ServiceCollaborationKit', '@kit.SpeechKit', '@kit.VisionKit',
|
||||
]);
|
||||
function InWhiteList(moduleSpecifierText, importName, inEtsContext) {
|
||||
if (whiteListForErrorSymbol.some(function (info) { return (info.kitName === moduleSpecifierText && info.symbolName === importName); })) {
|
||||
return true;
|
||||
}
|
||||
if (!inEtsContext &&
|
||||
whiteListForTsWarning.some(function (info) { return (info.kitName === moduleSpecifierText && info.symbolName === importName); })) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function processKitStatementSuccess(factory, statement, jsonObject, inEtsContext, newImportStatements) {
|
||||
var importClause = statement.importClause;
|
||||
var moduleSpecifierText = statement.moduleSpecifier.text;
|
||||
var kitSymbol = jsonObject === null || jsonObject === void 0 ? void 0 : jsonObject.symbols;
|
||||
if (!kitSymbol) {
|
||||
return false;
|
||||
}
|
||||
var isType = importClause.isTypeOnly;
|
||||
if (importClause.name) {
|
||||
var symbol = kitSymbol[DEFAULT_KEYWORD];
|
||||
// has error when import ets declaration in ts file
|
||||
if (!symbol || (!inEtsContext && symbol.source.endsWith(ETS_DECLARATION))) {
|
||||
return false;
|
||||
}
|
||||
newImportStatements.push(createImportDeclarationForKit(factory, isType, importClause.name, symbol, statement));
|
||||
}
|
||||
if (importClause.namedBindings) {
|
||||
var hasError_1 = false;
|
||||
importClause.namedBindings.elements.forEach(function (element) {
|
||||
if (hasError_1) {
|
||||
return;
|
||||
}
|
||||
var importName = ts.unescapeLeadingUnderscores(element.propertyName ? element.propertyName.escapedText : element.name.escapedText);
|
||||
var aliasName = element.name;
|
||||
if (InWhiteList(moduleSpecifierText, importName, inEtsContext)) {
|
||||
hasError_1 = true;
|
||||
return;
|
||||
}
|
||||
var symbol = kitSymbol[importName];
|
||||
if (!symbol || !aliasName ||
|
||||
// has error when import ets declaration in ts file
|
||||
(!inEtsContext && symbol.source.endsWith(ETS_DECLARATION)) ||
|
||||
// can not have duplicate type
|
||||
(isType && element.isTypeOnly)) {
|
||||
hasError_1 = true;
|
||||
return;
|
||||
}
|
||||
newImportStatements.push(createImportDeclarationForKit(factory, isType || element.isTypeOnly, aliasName, symbol, statement));
|
||||
});
|
||||
if (hasError_1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/* @internal */
|
||||
function processKit(factory, statements, sdkPath, markedkitImportRanges, inEtsContext) {
|
||||
var list = [];
|
||||
var skipRestStatements = false;
|
||||
statements.forEach(function (statement) {
|
||||
// ArkTS don't allow import declaration after other statements
|
||||
if (!skipRestStatements && inEtsContext && !ts.isImportDeclaration(statement)) {
|
||||
skipRestStatements = true;
|
||||
}
|
||||
if (skipRestStatements || excludeStatementForKitImport(statement)) {
|
||||
list.push(statement);
|
||||
return;
|
||||
}
|
||||
var moduleSpecifierText = statement.moduleSpecifier.text;
|
||||
if (!inEtsContext && whiteListForTsFile.has(moduleSpecifierText)) {
|
||||
list.push(statement);
|
||||
return;
|
||||
}
|
||||
var jsonObject = getKitJsonObject(moduleSpecifierText, sdkPath);
|
||||
var newImportStatements = new Array();
|
||||
if (!processKitStatementSuccess(factory, statement, jsonObject, inEtsContext, newImportStatements)) {
|
||||
list.push(statement);
|
||||
return;
|
||||
}
|
||||
list.push.apply(list, newImportStatements);
|
||||
markKitImport(statement, markedkitImportRanges);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
ts.processKit = processKit;
|
||||
})(ts || (ts = {}));
|
||||
/* @internal */
|
||||
var ts;
|
||||
@ -120611,7 +120816,7 @@ var ts;
|
||||
return getTextOfNode(node.textSourceNode, includeTrivia);
|
||||
}
|
||||
var sourceFile = currentSourceFile; // const needed for control flow
|
||||
var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node);
|
||||
var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node) && !(node.flags & -2147483648 /* NodeFlags.NoOriginalText */);
|
||||
if (ts.isMemberName(node)) {
|
||||
if (!canUseSourceFile || ts.getSourceFileOfNode(node) !== ts.getOriginalNode(sourceFile)) {
|
||||
return ts.idText(node);
|
||||
|
@ -5058,7 +5058,7 @@ namespace ts {
|
||||
return getTextOfNode(node.textSourceNode, includeTrivia);
|
||||
}
|
||||
const sourceFile = currentSourceFile; // const needed for control flow
|
||||
const canUseSourceFile = !!sourceFile && !!node.parent && !nodeIsSynthesized(node);
|
||||
const canUseSourceFile = !!sourceFile && !!node.parent && !nodeIsSynthesized(node) && !(node.flags & NodeFlags.NoOriginalText);
|
||||
if (isMemberName(node)) {
|
||||
if (!canUseSourceFile || getSourceFileOfNode(node) !== getOriginalNode(sourceFile)) {
|
||||
return idText(node);
|
||||
|
@ -1037,4 +1037,253 @@ namespace ts {
|
||||
const nameExpr = illegalDecorators[0].expression;
|
||||
return (isIdentifier(nameExpr) && nameExpr.escapedText.toString() === 'Sendable');
|
||||
}
|
||||
|
||||
const JSON_SUFFIX = ".json";
|
||||
const KIT_PREFIX = '@kit.';
|
||||
const DEFAULT_KEYWORD = 'default';
|
||||
const ETS_DECLARATION = '.d.ets'
|
||||
const OHOS_KIT_CONFIG_PATH = './openharmony/ets/build-tools/ets-loader/kit_configs';
|
||||
const HMS_KIT_CONFIG_PATH = './hms/ets/build-tools/ets-loader/kit_configs';
|
||||
|
||||
interface KitSymbolInfo {
|
||||
source: string,
|
||||
bindings: string,
|
||||
}
|
||||
|
||||
interface KitJsonInfo {
|
||||
symbols: {
|
||||
[symbol: string]: KitSymbolInfo,
|
||||
}
|
||||
}
|
||||
|
||||
const kitJsonCache = new Map<string, KitJsonInfo | undefined>();
|
||||
|
||||
/* @internal */
|
||||
export function getSdkPath(compilerOptions: CompilerOptions): string | undefined {
|
||||
return compilerOptions.etsLoaderPath ? resolvePath(compilerOptions.etsLoaderPath, '../../../..') : undefined;
|
||||
}
|
||||
|
||||
function getKitJsonObject(name: string, sdkPath: string): KitJsonInfo | undefined {
|
||||
if (kitJsonCache?.has(name)) {
|
||||
return kitJsonCache.get(name);
|
||||
}
|
||||
const ohosJsonPath = resolvePath(sdkPath, OHOS_KIT_CONFIG_PATH, `./${name}${JSON_SUFFIX}`);
|
||||
const hmsJsonPath = resolvePath(sdkPath, HMS_KIT_CONFIG_PATH, `./${name}${JSON_SUFFIX}`);
|
||||
|
||||
let fileInfo: string | undefined =
|
||||
ts.sys.fileExists(ohosJsonPath) ? ts.sys.readFile(ohosJsonPath, 'utf-8') :
|
||||
ts.sys.fileExists(hmsJsonPath) ? ts.sys.readFile(hmsJsonPath, 'utf-8') :
|
||||
undefined;
|
||||
if (!fileInfo) {
|
||||
kitJsonCache?.set(name, undefined);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const obj = JSON.parse(fileInfo) as KitJsonInfo;
|
||||
kitJsonCache?.set(name, obj);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
export function cleanKitJsonCache(): void {
|
||||
kitJsonCache?.clear();
|
||||
}
|
||||
|
||||
function setVirtualNode<T extends Node>(node: T, start: number = 0, end: number = 0): T {
|
||||
node.virtual = true;
|
||||
setTextRangePosEnd(node, start, end);
|
||||
return node;
|
||||
}
|
||||
|
||||
function setNoOriginalText<T extends Node>(node: T): T {
|
||||
(node as Mutable<T>).flags |= NodeFlags.NoOriginalText;
|
||||
return node;
|
||||
}
|
||||
|
||||
function createNameImportDeclaration(factory: NodeFactory, isType: boolean, name: Identifier, source: string,
|
||||
oldStatement: ImportDeclaration): ImportDeclaration {
|
||||
const oldModuleSpecifier = oldStatement.moduleSpecifier;
|
||||
const oldImportClause = oldStatement.importClause!; // shouldn't be undefined
|
||||
const newModuleSpecifier = setNoOriginalText(setVirtualNode(factory.createStringLiteral(source), oldModuleSpecifier.pos, oldModuleSpecifier.end));
|
||||
const newImportClause = setVirtualNode(factory.createImportClause(isType, name, undefined), oldImportClause.pos, oldImportClause.end);
|
||||
const newImportDeclaration = setVirtualNode(
|
||||
factory.createImportDeclaration(undefined, newImportClause, newModuleSpecifier), oldStatement.pos, oldStatement.end);
|
||||
return newImportDeclaration;
|
||||
}
|
||||
|
||||
function createBindingImportDeclaration(factory: NodeFactory, isType: boolean, propname: string, name: Identifier, source: string,
|
||||
oldStatement: ImportDeclaration): ImportDeclaration {
|
||||
const oldModuleSpecifier = oldStatement.moduleSpecifier;
|
||||
const oldImportClause = oldStatement.importClause!; // shouldn't be undefined
|
||||
const newModuleSpecifier = setNoOriginalText(setVirtualNode(factory.createStringLiteral(source), oldModuleSpecifier.pos, oldModuleSpecifier.end));
|
||||
const newPropertyName = setNoOriginalText(setVirtualNode(factory.createIdentifier(propname), name.pos, name.end));
|
||||
const newImportSpecific = setVirtualNode(factory.createImportSpecifier(false, newPropertyName, name), oldImportClause.pos, oldImportClause.end);
|
||||
const newNamedBindings = setVirtualNode(factory.createNamedImports([newImportSpecific]), oldImportClause.pos, oldImportClause.end);
|
||||
const newImportClause = setVirtualNode(factory.createImportClause(isType, undefined, newNamedBindings), oldImportClause.pos, oldImportClause.end);
|
||||
const newImportDeclaration = setVirtualNode(
|
||||
factory.createImportDeclaration(undefined, newImportClause, newModuleSpecifier), oldStatement.pos, oldStatement.end);
|
||||
return newImportDeclaration;
|
||||
}
|
||||
|
||||
function createImportDeclarationForKit(factory: NodeFactory, isType: boolean, name: Identifier, symbol: KitSymbolInfo,
|
||||
oldStatement: ImportDeclaration): ImportDeclaration {
|
||||
const source = symbol.source.replace(/\.d.[e]?ts$/, '');
|
||||
const binding = symbol.bindings;
|
||||
if (binding === DEFAULT_KEYWORD) {
|
||||
return createNameImportDeclaration(factory, isType, name, source, oldStatement);
|
||||
}
|
||||
return createBindingImportDeclaration(factory, isType, binding, name, source, oldStatement);
|
||||
}
|
||||
|
||||
function markKitImport(statement : Statement, markedkitImportRanges: Array<TextRange>): void {
|
||||
markedkitImportRanges.push({ pos: statement.pos, end: statement.end });
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function isInMarkedKitImport(sourceFile: SourceFile, pos: number, end: number): boolean {
|
||||
return !!sourceFile.markedKitImportRange?.some(
|
||||
range => {
|
||||
return (range.pos <= pos) && (end <= range.end);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function excludeStatementForKitImport(statement: Statement): boolean {
|
||||
if (!isImportDeclaration(statement) || // check is ImportDeclaration
|
||||
!statement.importClause || // exclude import 'mode'
|
||||
statement.importClause.isLazy || // exclude import lazy, it may report error
|
||||
(statement.importClause.namedBindings && ts.isNamespaceImport(statement.importClause.namedBindings)) || // exclude namespace import
|
||||
!isStringLiteral(statement.moduleSpecifier) || statement.illegalDecorators || // exclude if may has error
|
||||
!statement.moduleSpecifier.text.startsWith(KIT_PREFIX) || // is not kit import
|
||||
statement.modifiers || // exclude if has modifiers
|
||||
statement.assertClause) { // not support assertClause
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
interface WhiteListInfo {
|
||||
kitName: string;
|
||||
symbolName: string;
|
||||
}
|
||||
// This symbols have error in kit files, so add it in white list and don't change
|
||||
const whiteListForErrorSymbol: WhiteListInfo[] = [
|
||||
{ kitName: '@kit.CoreFileKit', symbolName: 'DfsListeners' },
|
||||
{ kitName: '@kit.NetworkKit', symbolName: 'VpnExtensionContext' },
|
||||
{ kitName: '@kit.ArkUI', symbolName: 'CustomContentDialog' },
|
||||
];
|
||||
|
||||
// This symbol will clause new warning in ts files
|
||||
const whiteListForTsWarning: WhiteListInfo[] = [
|
||||
{ kitName: '@kit.ConnectivityKit', symbolName: 'socket' },
|
||||
];
|
||||
|
||||
// This files import the symbol from ets file, so we won't change them in ts files
|
||||
const whiteListForTsFile: Set<string> = new Set([
|
||||
'@kit.AccountKit', '@kit.MapKit', '@kit.Penkit', '@kit.ScenarioFusionKit',
|
||||
'@kit.ServiceCollaborationKit', '@kit.SpeechKit', '@kit.VisionKit',
|
||||
]);
|
||||
|
||||
function InWhiteList(moduleSpecifierText: string, importName: string, inEtsContext: boolean): boolean {
|
||||
if (whiteListForErrorSymbol.some(info => (info.kitName === moduleSpecifierText && info.symbolName === importName))) {
|
||||
return true;
|
||||
}
|
||||
if (!inEtsContext &&
|
||||
whiteListForTsWarning.some(info => (info.kitName === moduleSpecifierText && info.symbolName === importName))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function processKitStatementSuccess(factory: NodeFactory, statement: ImportDeclaration, jsonObject: KitJsonInfo | undefined, inEtsContext: boolean,
|
||||
newImportStatements: Array<ImportDeclaration>): boolean {
|
||||
const importClause = statement.importClause!;
|
||||
const moduleSpecifierText = (statement.moduleSpecifier as StringLiteral).text;
|
||||
const kitSymbol = jsonObject?.symbols;
|
||||
if (!kitSymbol) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const isType = importClause.isTypeOnly;
|
||||
if (importClause.name) {
|
||||
const symbol = kitSymbol[DEFAULT_KEYWORD];
|
||||
// has error when import ets declaration in ts file
|
||||
if (!symbol || (!inEtsContext && symbol.source.endsWith(ETS_DECLARATION))) {
|
||||
return false;
|
||||
}
|
||||
newImportStatements.push(createImportDeclarationForKit(factory, isType, importClause.name, symbol, statement));
|
||||
}
|
||||
|
||||
if (importClause.namedBindings) {
|
||||
let hasError = false;
|
||||
(importClause.namedBindings as NamedImports).elements.forEach(
|
||||
element => {
|
||||
if (hasError) {
|
||||
return;
|
||||
}
|
||||
const importName = unescapeLeadingUnderscores(element.propertyName ? element.propertyName.escapedText : element.name.escapedText);
|
||||
const aliasName = element.name;
|
||||
|
||||
if (InWhiteList(moduleSpecifierText, importName, inEtsContext)) {
|
||||
hasError = true;
|
||||
return;
|
||||
}
|
||||
|
||||
const symbol = kitSymbol[importName];
|
||||
if (!symbol || !aliasName ||
|
||||
// has error when import ets declaration in ts file
|
||||
(!inEtsContext && symbol.source.endsWith(ETS_DECLARATION)) ||
|
||||
// can not have duplicate type
|
||||
(isType && element.isTypeOnly)) {
|
||||
hasError = true;
|
||||
return;
|
||||
}
|
||||
|
||||
newImportStatements.push(
|
||||
createImportDeclarationForKit(factory, isType || element.isTypeOnly, aliasName, symbol, statement));
|
||||
}
|
||||
);
|
||||
if (hasError) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function processKit(factory: NodeFactory, statements: NodeArray<Statement>, sdkPath: string,
|
||||
markedkitImportRanges: Array<TextRange>, inEtsContext: boolean): Statement[] {
|
||||
const list: Statement[] = [];
|
||||
let skipRestStatements = false;
|
||||
statements.forEach(
|
||||
statement => {
|
||||
// ArkTS don't allow import declaration after other statements
|
||||
if (!skipRestStatements && inEtsContext && !isImportDeclaration(statement)) {
|
||||
skipRestStatements = true;
|
||||
}
|
||||
if (skipRestStatements || excludeStatementForKitImport(statement)) {
|
||||
list.push(statement);
|
||||
return;
|
||||
}
|
||||
|
||||
const moduleSpecifierText = ((statement as ImportDeclaration).moduleSpecifier as StringLiteral).text;
|
||||
if (!inEtsContext && whiteListForTsFile.has(moduleSpecifierText)) {
|
||||
list.push(statement);
|
||||
return;
|
||||
}
|
||||
|
||||
const jsonObject = getKitJsonObject(moduleSpecifierText, sdkPath);
|
||||
const newImportStatements = new Array<ImportDeclaration>();
|
||||
|
||||
if (!processKitStatementSuccess(factory, statement as ImportDeclaration, jsonObject, inEtsContext, newImportStatements)) {
|
||||
list.push(statement);
|
||||
return;
|
||||
}
|
||||
|
||||
list.push(...newImportStatements);
|
||||
markKitImport(statement, markedkitImportRanges);
|
||||
}
|
||||
)
|
||||
return list;
|
||||
}
|
||||
}
|
@ -1397,11 +1397,19 @@ namespace ts {
|
||||
// Prime the scanner.
|
||||
nextToken();
|
||||
|
||||
const statements = parseList(ParsingContext.SourceElements, parseStatement);
|
||||
let statements = parseList(ParsingContext.SourceElements, parseStatement);
|
||||
const markedkitImportRanges = new Array<TextRange>();
|
||||
const sdkPath = getSdkPath(sourceFileCompilerOptions);
|
||||
statements = (!!sourceFileCompilerOptions.noTransformedKitInParser || !sdkPath || parseDiagnostics.length) ?
|
||||
statements :
|
||||
createNodeArray(processKit(factory, statements, sdkPath, markedkitImportRanges, inEtsContext()), statements.pos);
|
||||
Debug.assert(token() === SyntaxKind.EndOfFileToken);
|
||||
const endOfFileToken = addJSDocComment(parseTokenNode<EndOfFileToken>());
|
||||
|
||||
const sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags, setExternalModuleIndicator);
|
||||
if (markedkitImportRanges.length > 0) {
|
||||
sourceFile.markedKitImportRange = markedkitImportRanges;
|
||||
}
|
||||
|
||||
// A member of ReadonlyArray<T> isn't assignable to a member of T[] (and prevents a direct cast) - but this is where we set up those members so they can be readonly in the future
|
||||
processCommentPragmas(sourceFile as {} as PragmaContext, sourceText);
|
||||
|
@ -803,6 +803,7 @@ namespace ts {
|
||||
/* @internal */ Deprecated = 1 << 28, // If has '@deprecated' JSDoc tag
|
||||
|
||||
EtsContext = 1 << 30, // If context was parsed as a Struct
|
||||
/* @internal */ NoOriginalText = 1 << 31, // If don't has original text in source file
|
||||
|
||||
BlockScoped = Let | Const,
|
||||
|
||||
@ -4173,6 +4174,8 @@ namespace ts {
|
||||
|
||||
/* @internal */ exportedModulesFromDeclarationEmit?: ExportedModulesFromDeclarationEmit;
|
||||
/* @internal */ endFlowNode?: FlowNode;
|
||||
|
||||
/* @internal */ markedKitImportRange?: Array<TextRange>;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@ -6808,6 +6811,7 @@ namespace ts {
|
||||
skipPathsInKeyForCompilationSettings?: boolean;
|
||||
compatibleSdkVersion?: number;
|
||||
compatibleSdkVersionStage?: string;
|
||||
noTransformedKitInParser?: boolean;
|
||||
[option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined;
|
||||
etsAnnotationsEnable?: boolean;
|
||||
}
|
||||
|
@ -748,7 +748,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
function canUseOriginalText(node: LiteralLikeNode, flags: GetLiteralTextFlags): boolean {
|
||||
if (nodeIsSynthesized(node) || !node.parent || (flags & GetLiteralTextFlags.TerminateUnterminatedLiterals && node.isUnterminated)) {
|
||||
if (nodeIsSynthesized(node) || !node.parent || (flags & GetLiteralTextFlags.TerminateUnterminatedLiterals && node.isUnterminated) ||
|
||||
(node.flags & NodeFlags.NoOriginalText)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -184,11 +184,13 @@ namespace ts {
|
||||
while (pos < end) {
|
||||
const token = scanner.scan();
|
||||
const textPos = scanner.getTextPos();
|
||||
if (textPos <= end) {
|
||||
if (token === SyntaxKind.Identifier) {
|
||||
Debug.fail(`Did not expect ${Debug.formatSyntaxKind(parent.kind)} to have an Identifier in its trivia`);
|
||||
if (!isSourceFile(parent) || !isInMarkedKitImport(parent, pos, textPos)) {
|
||||
if (textPos <= end) {
|
||||
if (token === SyntaxKind.Identifier) {
|
||||
Debug.fail(`Did not expect ${Debug.formatSyntaxKind(parent.kind)} to have an Identifier in its trivia`);
|
||||
}
|
||||
nodes.push(createNode(token, pos, textPos, parent));
|
||||
}
|
||||
nodes.push(createNode(token, pos, textPos, parent));
|
||||
}
|
||||
pos = textPos;
|
||||
if (token === SyntaxKind.EndOfFileToken) {
|
||||
|
@ -3200,6 +3200,7 @@ declare namespace ts {
|
||||
skipPathsInKeyForCompilationSettings?: boolean;
|
||||
compatibleSdkVersion?: number;
|
||||
compatibleSdkVersionStage?: string;
|
||||
noTransformedKitInParser?: boolean;
|
||||
[option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined;
|
||||
etsAnnotationsEnable?: boolean;
|
||||
}
|
||||
@ -5475,6 +5476,7 @@ declare namespace ts {
|
||||
function transformTypeExportImportAndConstEnumInTypeScript(context: TransformationContext): (node: SourceFile) => SourceFile;
|
||||
function hasTsNoCheckOrTsIgnoreFlag(node: SourceFile): boolean;
|
||||
function createObfTextSingleLineWriter(): EmitTextWriter;
|
||||
function cleanKitJsonCache(): void;
|
||||
}
|
||||
declare namespace ts {
|
||||
/**
|
||||
|
@ -3200,6 +3200,7 @@ declare namespace ts {
|
||||
skipPathsInKeyForCompilationSettings?: boolean;
|
||||
compatibleSdkVersion?: number;
|
||||
compatibleSdkVersionStage?: string;
|
||||
noTransformedKitInParser?: boolean;
|
||||
[option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined;
|
||||
etsAnnotationsEnable?: boolean;
|
||||
}
|
||||
@ -5475,6 +5476,7 @@ declare namespace ts {
|
||||
function transformTypeExportImportAndConstEnumInTypeScript(context: TransformationContext): (node: SourceFile) => SourceFile;
|
||||
function hasTsNoCheckOrTsIgnoreFlag(node: SourceFile): boolean;
|
||||
function createObfTextSingleLineWriter(): EmitTextWriter;
|
||||
function cleanKitJsonCache(): void;
|
||||
}
|
||||
declare namespace ts {
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user