提交 c13bf9e1 编写于 作者: fxy060608's avatar fxy060608

wip(x-android): tsc

上级 1c457380
......@@ -20,7 +20,7 @@ export function resolveDefineCode(
return componentType === 'app'
? `defineApp`
: componentType === 'page'
? `definePage`
? `defineComponent` //`definePage`
: `defineComponent`
}
......
......@@ -476,6 +476,18 @@ function setUTSJSONObjectValue(obj, key, value) {
}
}
let UTSJSONObject$1 = class UTSJSONObject {
static keys(obj) {
return Object.keys(obj);
}
static assign(target, ...sources) {
for (let i = 0; i < sources.length; i++) {
const source = sources[i];
for (let key in source) {
target[key] = source[key];
}
}
return target;
}
constructor(content = {}) {
if (content instanceof Map) {
content.forEach((value, key) => {
......
import "@dcloudio/virtual-modules/hbuilderx-language-services/builtin-dts/uts-types/common/index.d.ts"
// import "@dcloudio/virtual-modules/hbuilderx-language-services/builtin-dts/uts-types/app-android/index.d.ts"
import "@dcloudio/virtual-modules/hbuilderx-language-services/builtin-dts/common/HBuilderX.d.ts"
import "@dcloudio/virtual-modules/hbuilderx-language-services/builtin-dts/uniappx/node_modules/@dcloudio/uni-app-x/types/index.d.ts"
import "@dcloudio/virtual-modules/hbuilderx-language-services/builtin-dts/uniappx/node_modules/@vue/global.d.ts"
import { defineComponent as defineComponentOrigin } from '@vue/runtime-core'
declare global {
type UniPageMeta = import('./runtime-types').UniPageMeta
type UniPageRoute = import('./runtime-types').UniPageRoute
const __uniConfig: import('./runtime-types').UniConfig
const defineComponent: typeof defineComponentOrigin
const __uniConfig: UniConfig
const __uniRoutes: UniPageRoute[]
const padStyleMapOf: import('./runtime-types').PadStyleMapOf
function utsMapOf(obj: Record<string, any>): Map<string, any | null>
function utsMapOf<K, V>(obj: Array<Array<any>>): Map<string, any | null>
function padStyleMapOf(style: Map<string, any>): Map<string, Map<string, any>>
declare class UTSSourceMapPosition<
type UniPageMeta = {
isQuit: boolean
}
type UniPageRoute = {
path: string
component: any
meta: UniPageMeta
style: Map<string, any>
needLogin?: boolean | null
}
type UniConfigOnReadyCallback = () => void
type UniConfig = {
realEntryPagePath: string
entryPagePath: string
globalStyle: Map<string, any>
tabBar: Map<string, any> | null
conditionUrl: string
uniIdRouter: Map<string, any>
themeConfig: Map<string, Map<string, any>>
_ready: boolean
callbacks: UniConfigOnReadyCallback[]
onReady(callback: UniConfigOnReadyCallback): void
get ready(): boolean
set ready(value: boolean)
}
class UTSSourceMapPosition<
name = string,
fileName = string,
line = number,
......
/// <reference types="@dcloudio/uni-app-x/types/native-global" />
import { CreateVueComponent } from '@vue/runtime-core';
declare function padStyleMapOf(style: Map<string, any>): Map<string, Map<string, any>>;
type UniConfigOnReadyCallback = () => void;
declare class UniConfig$1 {
realEntryPagePath: string;
entryPagePath: string;
globalStyle: Map<string, any>;
tabBar: Map<string, any> | null;
conditionUrl: string;
uniIdRouter: Map<string, any>;
themeConfig: Map<string, Map<string, any>>;
_ready: boolean;
callbacks: UniConfigOnReadyCallback[];
onReady(callback: UniConfigOnReadyCallback): void;
get ready(): boolean;
set ready(value: boolean);
}
type UniPageMeta$1 = {
isQuit: boolean;
};
type UniPageRoute$1 = {
path: string;
component: CreateVueComponent;
meta: UniPageMeta$1;
style: Map<string, any>;
needLogin?: boolean | null;
};
export type UniPageRoute = UniPageRoute$1;
export type UniPageMeta = UniPageMeta$1;
export type UniConfig = UniConfig$1;
export type PadStyleMapOf = typeof padStyleMapOf;
import fs from 'fs-extra'
import path from 'path'
import { extend } from '@vue/shared'
import type {
CompilerOptions,
SemanticDiagnosticsBuilderProgram,
......@@ -10,7 +9,6 @@ import {
SourceMapConsumer,
SourceMapGenerator,
} from 'source-map-js'
import { createBasicUtsOptions } from '../utils/options'
import { isInHBuilderX, normalizePath } from '../../shared'
export interface UTS2KotlinOptions {
......@@ -18,6 +16,7 @@ export interface UTS2KotlinOptions {
inputDir: string
cacheDir: string
outputDir: string
hxLanguageServiceDir?: string
tsconfig?: string
rootFiles?: string[]
compilerOptions?: CompilerOptions
......@@ -34,41 +33,68 @@ export function runUTS2Kotlin(
): {
watcher?: WatchProgramHelper
} {
const { /* check, noCache, */ tsconfig, typescript, tsconfigOverride } =
createBasicUtsOptions(options.inputDir)
const kotlinTypesPath = path.resolve(__dirname, '../../../lib/kotlin/types')
const rootFiles: string[] = [path.resolve(kotlinTypesPath, 'global.d.ts')]
;['env.d.ts', 'shim-uni.d.ts', 'shim-dom.d.ts', 'global.d.ts'].forEach(
(file) => {
rootFiles.push(path.resolve(__dirname, '../../../lib/tsconfig', file))
}
)
rootFiles.push(path.resolve(options.inputDir, 'main.uts.ts'))
const pluginPath = isInHBuilderX()
? process.env.UNI_HBUILDERX_PLUGINS
: path.resolve(process.cwd(), '../')
const nodeModulesPath = path.resolve(
const hbxLanguageServicePath = path.resolve(
pluginPath,
'hbuilderx-language-services/builtin-dts/uniappx/node_modules'
'hbuilderx-language-services/builtin-dts'
)
const kotlinTypesPath = path.resolve(__dirname, '../../../lib/kotlin/types')
const rootFiles: string[] = [
path.resolve(kotlinTypesPath, 'global.d.ts'),
path.resolve(kotlinTypesPath, 'env.d.ts'),
path.resolve(hbxLanguageServicePath, 'uts-types/common/index.d.ts'),
//path.resolve(hbxLanguageServicePath, 'uts-types/app-android/index.d.ts'),
path.resolve(hbxLanguageServicePath, 'common/HBuilderX.d.ts'),
path.resolve(
hbxLanguageServicePath,
'uniappx/node_modules/@dcloudio/uni-app-x/types/index.d.ts'
),
path.resolve(
hbxLanguageServicePath,
'uniappx/node_modules/@vue/global.d.ts'
),
]
rootFiles.push(path.resolve(options.inputDir, 'main.uts.ts'))
const vueRuntimeDts = [
path.resolve(nodeModulesPath, '@vue/runtime-core/index.d.ts'),
path.resolve(
hbxLanguageServicePath,
'uniappx/node_modules/@vue/runtime-core/index.d.ts'
),
]
extend(tsconfigOverride.compilerOptions.paths, {
'@dcloudio/uni-runtime': [
path.resolve(
kotlinTypesPath,
'@dcloudio/uni-runtime/dist/uni-runtime.d.ts'
),
],
'@vue/reactivity': [
path.resolve(nodeModulesPath, '@vue/reactivity/dist/reactivity.d.ts'),
],
'@vue/runtime-core': vueRuntimeDts,
vue: vueRuntimeDts,
})
const typescript = require('../../../lib/typescript')
const compilerOptions: CompilerOptions = {
rootDir: options.inputDir,
baseUrl: options.inputDir,
outDir: options.outputDir,
noLib: true,
noImplicitAny: false,
useDefineForClassFields: false,
sourceMap: process.env.NODE_ENV === 'development',
inlineSources: true,
noEmitOnError: false,
typeRoots: [],
paths: {
'@dcloudio/uni-runtime': [
path.resolve(
kotlinTypesPath,
'@dcloudio/uni-runtime/dist/uni-runtime.d.ts'
),
],
'@vue/reactivity': [
path.resolve(
hbxLanguageServicePath,
'uniappx/node_modules/@vue/reactivity/dist/reactivity.d.ts'
),
],
'@vue/runtime-core': vueRuntimeDts,
vue: vueRuntimeDts,
},
}
type RunDevOptions = Required<
UTS2KotlinOptions & {
......@@ -88,13 +114,9 @@ export function runUTS2Kotlin(
typescript,
inputDir: options.inputDir,
cacheDir: options.cacheDir,
tsconfig,
rootFiles,
compilerOptions: extend(tsconfigOverride.compilerOptions, {
outDir: options.outputDir,
inlineSources: true,
lib: [],
}),
hxLanguageServiceDir: hbxLanguageServicePath,
compilerOptions,
normalizeFileName: options.normalizeFileName,
sourceMapCallback: (fileName, text, writeFile) => {
const relativeFileName = normalizePath(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册