Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
3f9211c2
U
uni-app
项目概览
DCloud
/
uni-app
14 天 前同步成功
通知
751
Star
38709
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
8
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
8
Issue
8
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
3f9211c2
编写于
12月 20, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(uts): components
上级
0ab8f9b8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
77 addition
and
4 deletion
+77
-4
packages/uni-cli-shared/lib/pages.js
packages/uni-cli-shared/lib/pages.js
+11
-2
packages/uni-cli-shared/lib/uts/uts.js
packages/uni-cli-shared/lib/uts/uts.js
+64
-1
packages/uni-cli-shared/package.json
packages/uni-cli-shared/package.json
+2
-1
未找到文件。
packages/uni-cli-shared/lib/pages.js
浏览文件 @
3f9211c2
...
...
@@ -425,6 +425,16 @@ function initAutoComponents () {
function
initAutoImportScanComponents
()
{
const
components
=
initAutoComponents
()
const
{
initUTSComponents
}
=
require
(
'
./uts/uts.js
'
)
initUTSComponents
(
process
.
env
.
UNI_INPUT_DIR
,
process
.
env
.
UNI_PLATFORM
).
forEach
((
item
)
=>
{
components
[
item
.
pattern
.
source
]
=
item
.
replacement
.
replace
(
'
\
0
'
,
''
).
replace
(
'
?uts-proxy
'
,
'
/package.json?uts-proxy
'
)
})
if
(
process
.
env
.
UNI_PLATFORM
===
'
quickapp-native
'
)
{
if
(
!
uniQuickAppAutoImportScanComponents
)
{
uniQuickAppAutoImportScanComponents
=
getAutoComponentsByDir
(
...
...
@@ -463,8 +473,7 @@ function initAutoImportComponents (easycom = {}) {
}
initBuiltInEasycom
(
BUILT_IN_EASYCOMS
,
usingAutoImportComponents
)
// 目前仅 mp-weixin 内置支持 page-meta 等组件
if
(
process
.
env
.
UNI_PLATFORM
===
'
mp-weixin
'
)
{
}
else
if
(
process
.
env
.
UNI_PLATFORM
===
'
mp-alipay
'
)
{
if
(
process
.
env
.
UNI_PLATFORM
===
'
mp-weixin
'
)
{}
else
if
(
process
.
env
.
UNI_PLATFORM
===
'
mp-alipay
'
)
{
initBuiltInEasycom
(
BUILT_IN_COMPONENTS_ALIPAY
,
usingAutoImportComponents
)
}
else
{
initBuiltInEasycom
(
BUILT_IN_COMPONENTS
,
usingAutoImportComponents
)
...
...
packages/uni-cli-shared/lib/uts/uts.js
浏览文件 @
3f9211c2
...
...
@@ -3,9 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return
(
mod
&&
mod
.
__esModule
)
?
mod
:
{
"
default
"
:
mod
};
};
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
exports
.
resolveUTSCompiler
=
exports
.
resolveUtsModule
=
exports
.
resolveUtsAppModule
=
void
0
;
exports
.
initUTSComponents
=
exports
.
resolveUTSCompiler
=
exports
.
resolveUtsModule
=
exports
.
resolveUtsAppModule
=
void
0
;
const
fs_1
=
__importDefault
(
require
(
"
fs
"
));
const
path_1
=
__importDefault
(
require
(
"
path
"
));
const
fast_glob_1
=
__importDefault
(
require
(
"
fast-glob
"
));
const
hbx_1
=
require
(
"
./hbx
"
);
const
utils_1
=
require
(
"
./utils
"
);
/**
...
...
@@ -99,3 +100,65 @@ function resolveUTSCompiler() {
return
require
(
compilerPath
);
}
exports
.
resolveUTSCompiler
=
resolveUTSCompiler
;
function
initUTSComponents
(
inputDir
,
platform
)
{
const
components
=
[];
if
(
platform
!==
'
app
'
&&
platform
!==
'
app-plus
'
)
{
return
components
;
}
const
easycomsObj
=
Object
.
create
(
null
);
const
dirs
=
resolveUTSComponentDirs
(
inputDir
);
dirs
.
forEach
((
dir
)
=>
{
const
is_uni_modules_utssdk
=
dir
.
endsWith
(
'
utssdk
'
);
const
is_ussdk
=
!
is_uni_modules_utssdk
&&
path_1
.
default
.
dirname
(
dir
).
endsWith
(
'
utssdk
'
);
if
(
is_uni_modules_utssdk
||
is_ussdk
)
{
fast_glob_1
.
default
.
sync
(
'
**/*.vue
'
,
{
cwd
:
dir
,
absolute
:
true
,
})
.
forEach
((
file
)
=>
{
let
name
=
parseVueComponentName
(
file
);
if
(
!
name
)
{
if
(
file
.
endsWith
(
'
index.vue
'
))
{
name
=
path_1
.
default
.
basename
(
is_uni_modules_utssdk
?
path_1
.
default
.
dirname
(
dir
)
:
dir
);
}
}
if
(
name
)
{
const
importDir
=
(
0
,
utils_1
.
normalizePath
)(
is_uni_modules_utssdk
?
path_1
.
default
.
dirname
(
dir
)
:
dir
);
easycomsObj
[
`^
${
name
}
$`
]
=
`\0
${
importDir
}
?uts-proxy`
;
}
});
}
});
Object
.
keys
(
easycomsObj
).
forEach
((
name
)
=>
{
components
.
push
({
pattern
:
new
RegExp
(
name
),
replacement
:
easycomsObj
[
name
],
});
});
return
components
;
}
exports
.
initUTSComponents
=
initUTSComponents
;
function
resolveUTSComponentDirs
(
inputDir
)
{
const
utssdkDir
=
path_1
.
default
.
resolve
(
inputDir
,
'
utssdk
'
);
const
uniModulesDir
=
path_1
.
default
.
resolve
(
inputDir
,
'
uni_modules
'
);
return
fast_glob_1
.
default
.
sync
(
'
*
'
,
{
cwd
:
utssdkDir
,
absolute
:
true
,
onlyDirectories
:
true
,
})
.
concat
(
fast_glob_1
.
default
.
sync
(
'
*/utssdk
'
,
{
cwd
:
uniModulesDir
,
absolute
:
true
,
onlyDirectories
:
true
,
}));
}
const
nameRE
=
/name
\s
*:
\s
*
[
'|"
](
.*
)[
'|"
]
/
;
function
parseVueComponentName
(
file
)
{
const
content
=
fs_1
.
default
.
readFileSync
(
file
,
'
utf8
'
);
const
matches
=
content
.
match
(
nameRE
);
if
(
matches
)
{
return
matches
[
1
];
}
}
packages/uni-cli-shared/package.json
浏览文件 @
3f9211c2
...
...
@@ -19,7 +19,8 @@
"author"
:
"fxy060608"
,
"license"
:
"Apache-2.0"
,
"dependencies"
:
{
"escape-string-regexp"
:
"^4.0.0"
,
"escape-string-regexp"
:
"^4.0.0"
,
"fast-glob"
:
"^3.2.11"
,
"glob-escape"
:
"^0.0.2"
,
"hash-sum"
:
"^1.0.2"
,
"postcss-urlrewrite"
:
"^0.2.2"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录