Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MuGuiLin
uni-app
提交
51427a3f
U
uni-app
项目概览
MuGuiLin
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
51427a3f
编写于
10月 17, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(uts): compiler
上级
8c465081
变更
20
展开全部
隐藏空白更改
内联
并排
Showing
20 changed file
with
167 addition
and
235 deletion
+167
-235
packages/uni-app-plus/dist/style.css
packages/uni-app-plus/dist/style.css
+1
-1
packages/uni-app-plus/dist/uni-app-view.umd.js
packages/uni-app-plus/dist/uni-app-view.umd.js
+1
-1
packages/uni-app-plus/src/view/components/video/index.tsx
packages/uni-app-plus/src/view/components/video/index.tsx
+2
-2
packages/uni-app-vite/src/nvue/plugins/mainJs.ts
packages/uni-app-vite/src/nvue/plugins/mainJs.ts
+3
-4
packages/uni-app-vite/src/vue/plugins/mainJs.ts
packages/uni-app-vite/src/vue/plugins/mainJs.ts
+2
-8
packages/uni-cli-shared/__tests__/uniExtApi.spec.ts
packages/uni-cli-shared/__tests__/uniExtApi.spec.ts
+76
-0
packages/uni-cli-shared/__tests__/uniModulesExports.spec.ts
packages/uni-cli-shared/__tests__/uniModulesExports.spec.ts
+0
-81
packages/uni-cli-shared/src/constants.ts
packages/uni-cli-shared/src/constants.ts
+0
-1
packages/uni-cli-shared/src/index.ts
packages/uni-cli-shared/src/index.ts
+2
-0
packages/uni-cli-shared/src/uni_modules.ts
packages/uni-cli-shared/src/uni_modules.ts
+56
-72
packages/uni-cli-shared/src/vite/plugins/index.ts
packages/uni-cli-shared/src/vite/plugins/index.ts
+0
-1
packages/uni-cli-shared/src/vite/plugins/inject.ts
packages/uni-cli-shared/src/vite/plugins/inject.ts
+3
-6
packages/uni-cli-shared/src/vite/plugins/uniModules.ts
packages/uni-cli-shared/src/vite/plugins/uniModules.ts
+0
-28
packages/uni-cli-shared/src/vite/utils/url.ts
packages/uni-cli-shared/src/vite/utils/url.ts
+1
-9
packages/uni-h5-vite/src/plugins/mainJs.ts
packages/uni-h5-vite/src/plugins/mainJs.ts
+1
-2
packages/uni-h5/dist/uni-h5.cjs.js
packages/uni-h5/dist/uni-h5.cjs.js
+5
-3
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+5
-3
packages/uni-mp-baidu/dist/uni.api.esm.js
packages/uni-mp-baidu/dist/uni.api.esm.js
+5
-1
packages/uni-mp-vite/src/plugins/mainJs.ts
packages/uni-mp-vite/src/plugins/mainJs.ts
+1
-2
packages/vite-plugin-uni/src/index.ts
packages/vite-plugin-uni/src/index.ts
+3
-10
未找到文件。
packages/uni-app-plus/dist/style.css
浏览文件 @
51427a3f
此差异已折叠。
点击以展开。
packages/uni-app-plus/dist/uni-app-view.umd.js
浏览文件 @
51427a3f
此差异已折叠。
点击以展开。
packages/uni-app-plus/src/view/components/video/index.tsx
浏览文件 @
51427a3f
...
...
@@ -137,8 +137,8 @@ const props = {
},
title
:
{
type
:
String
,
default
:
''
}
default
:
''
,
}
,
}
type
EventName
=
...
...
packages/uni-app-vite/src/nvue/plugins/mainJs.ts
浏览文件 @
51427a3f
...
...
@@ -2,7 +2,6 @@ import {
defineUniMainJsPlugin
,
MANIFEST_JSON_JS
,
PAGES_JSON_JS
,
UNI_MODULES_EXPORTS
,
}
from
'
@dcloudio/uni-cli-shared
'
import
{
APP_CSS_JS
}
from
'
./appCss
'
...
...
@@ -21,7 +20,7 @@ export function uniMainJsPlugin({
if
(
opts
.
filter
(
id
))
{
if
(
renderer
!==
'
native
'
)
{
return
{
code
:
`import './
${
PAGES_JSON_JS
}
';import
'
${
UNI_MODULES_EXPORTS
}
';import
('
${
APP_CSS_JS
}
').then(()=>{})`
,
code
:
`import './
${
PAGES_JSON_JS
}
';import('
${
APP_CSS_JS
}
').then(()=>{})`
,
map
:
{
mappings
:
''
},
}
}
...
...
@@ -31,13 +30,13 @@ export function uniMainJsPlugin({
:
createLegacyApp
(
code
)
return
{
code
:
`import './
${
MANIFEST_JSON_JS
}
';\nimport './
${
PAGES_JSON_JS
}
';\n
import '
${
UNI_MODULES_EXPORTS
}
';\n
`
+
`import './
${
MANIFEST_JSON_JS
}
';\nimport './
${
PAGES_JSON_JS
}
';\n`
+
code
,
map
:
{
mappings
:
''
},
}
}
return
{
code
:
`import './
${
PAGES_JSON_JS
}
';
import '
${
UNI_MODULES_EXPORTS
}
';
`
,
code
:
`import './
${
PAGES_JSON_JS
}
';`
,
map
:
{
mappings
:
''
},
}
}
...
...
packages/uni-app-vite/src/vue/plugins/mainJs.ts
浏览文件 @
51427a3f
import
{
defineUniMainJsPlugin
,
PAGES_JSON_JS
,
UNI_MODULES_EXPORTS
,
}
from
'
@dcloudio/uni-cli-shared
'
import
{
defineUniMainJsPlugin
,
PAGES_JSON_JS
}
from
'
@dcloudio/uni-cli-shared
'
export
function
uniMainJsPlugin
()
{
return
defineUniMainJsPlugin
((
opts
)
=>
{
...
...
@@ -15,9 +11,7 @@ export function uniMainJsPlugin() {
?
createApp
(
code
)
:
createLegacyApp
(
code
)
return
{
code
:
`import './
${
PAGES_JSON_JS
}
';import '
${
UNI_MODULES_EXPORTS
}
';`
+
code
,
code
:
`import './
${
PAGES_JSON_JS
}
';`
+
code
,
map
:
{
mappings
:
''
},
}
}
...
...
packages/uni-cli-shared/__tests__/uniExtApi.spec.ts
0 → 100644
浏览文件 @
51427a3f
import
{
parseInjects
}
from
'
../src/uni_modules
'
describe
(
'
uni_modules:uni-ext-api
'
,
()
=>
{
test
(
'
parseInjects
'
,
()
=>
{
expect
(
parseInjects
(
'
app
'
,
`@/uni_modules/uni-getbatteryinfo`
,
{
uni
:
'
getBatteryInfo
'
,
})
).
toEqual
({
'
uni.getBatteryInfo
'
:
'
@/uni_modules/uni-getbatteryinfo
'
,
})
expect
(
parseInjects
(
'
app
'
,
`@/uni_modules/uni-getbatteryinfo`
,
{
uni
:
[
'
getBatteryInfo
'
],
})
).
toEqual
({
'
uni.getBatteryInfo
'
:
[
'
@/uni_modules/uni-getbatteryinfo
'
,
'
getBatteryInfo
'
,
],
})
expect
(
parseInjects
(
'
app
'
,
`@/uni_modules/uni-location`
,
{
uni
:
[
'
openLocation
'
,
'
chooseLocation
'
],
})
).
toEqual
({
'
uni.openLocation
'
:
[
'
@/uni_modules/uni-location
'
,
'
openLocation
'
],
'
uni.chooseLocation
'
:
[
'
@/uni_modules/uni-location
'
,
'
chooseLocation
'
],
})
expect
(
parseInjects
(
'
app
'
,
`@/uni_modules/uni-capturescreen`
,
{
uni
:
{
onUserCaptureScreen
:
'
onCaptureScreen
'
,
offUserCaptureScreen
:
'
offUserCaptureScreen
'
,
},
})
).
toEqual
({
'
uni.onUserCaptureScreen
'
:
[
'
@/uni_modules/uni-capturescreen
'
,
'
onCaptureScreen
'
,
],
'
uni.offUserCaptureScreen
'
:
[
'
@/uni_modules/uni-capturescreen
'
,
'
offUserCaptureScreen
'
,
],
})
})
test
(
'
parseInjects with platform
'
,
()
=>
{
expect
(
parseInjects
(
'
web
'
,
`@/uni_modules/uni-getbatteryinfo`
,
{
uni
:
'
getBatteryInfo1
'
,
web
:
{
uni
:
'
getBatteryInfo
'
,
},
})
).
toEqual
({
'
uni.getBatteryInfo
'
:
'
@/uni_modules/uni-getbatteryinfo
'
,
})
expect
(
parseInjects
(
'
web
'
,
`@/uni_modules/uni-getbatteryinfo`
,
{
uni
:
'
getBatteryInfo1
'
,
web
:
false
,
})
).
toEqual
({})
expect
(
parseInjects
(
'
web
'
,
`@/uni_modules/uni-location`
,
{
uni
:
[
'
openLocation
'
],
web
:
{
uni
:
[
'
chooseLocation
'
],
},
})
).
toEqual
({
'
uni.chooseLocation
'
:
[
'
@/uni_modules/uni-location
'
,
'
chooseLocation
'
],
})
})
})
packages/uni-cli-shared/__tests__/uniModulesExports.spec.ts
已删除
100644 → 0
浏览文件 @
8c465081
import
{
parseExports
}
from
'
../src/uni_modules
'
describe
(
'
uni_modules:exports
'
,
()
=>
{
test
(
'
parseExports
'
,
()
=>
{
expect
(
parseExports
(
'
app
'
,
`@/uni_modules/uni-getbatteryinfo`
,
{
uni
:
'
getBatteryInfo
'
,
})
).
toEqual
([
[
"
import getBatteryInfo from '@/uni_modules/uni-getbatteryinfo'
"
],
[
'
uni.getBatteryInfo = getBatteryInfo
'
],
])
expect
(
parseExports
(
'
app
'
,
`@/uni_modules/uni-getbatteryinfo`
,
{
uni
:
[
'
getBatteryInfo
'
],
})
).
toEqual
([
[
"
import { getBatteryInfo } from '@/uni_modules/uni-getbatteryinfo'
"
],
[
'
uni.getBatteryInfo = getBatteryInfo
'
],
])
expect
(
parseExports
(
'
app
'
,
`@/uni_modules/uni-location`
,
{
uni
:
[
'
openLocation
'
,
'
chooseLocation
'
],
})
).
toEqual
([
[
"
import { openLocation, chooseLocation } from '@/uni_modules/uni-location'
"
,
],
[
'
uni.openLocation = openLocation
'
,
'
uni.chooseLocation = chooseLocation
'
,
],
])
expect
(
parseExports
(
'
app
'
,
`@/uni_modules/uni-capturescreen`
,
{
uni
:
{
onUserCaptureScreen
:
'
onCaptureScreen
'
,
offUserCaptureScreen
:
'
offUserCaptureScreen
'
,
},
})
).
toEqual
([
[
"
import { onCaptureScreen as onUserCaptureScreen, offUserCaptureScreen } from '@/uni_modules/uni-capturescreen'
"
,
],
[
'
uni.onUserCaptureScreen = onUserCaptureScreen
'
,
'
uni.offUserCaptureScreen = offUserCaptureScreen
'
,
],
])
})
test
(
'
parseExports with platform
'
,
()
=>
{
expect
(
parseExports
(
'
web
'
,
`@/uni_modules/uni-getbatteryinfo`
,
{
uni
:
'
getBatteryInfo1
'
,
web
:
{
uni
:
'
getBatteryInfo
'
,
},
})
).
toEqual
([
[
"
import getBatteryInfo from '@/uni_modules/uni-getbatteryinfo'
"
],
[
'
uni.getBatteryInfo = getBatteryInfo
'
],
])
expect
(
parseExports
(
'
web
'
,
`@/uni_modules/uni-getbatteryinfo`
,
{
uni
:
'
getBatteryInfo1
'
,
web
:
false
,
})
).
toEqual
([[],
[]])
expect
(
parseExports
(
'
web
'
,
`@/uni_modules/uni-location`
,
{
uni
:
[
'
openLocation
'
],
web
:
{
uni
:
[
'
chooseLocation
'
],
},
})
).
toEqual
([
[
"
import { chooseLocation } from '@/uni_modules/uni-location'
"
],
[
'
uni.chooseLocation = chooseLocation
'
],
])
})
})
packages/uni-cli-shared/src/constants.ts
浏览文件 @
51427a3f
...
...
@@ -17,7 +17,6 @@ export const extensions = [
'
.json
'
,
].
concat
(
EXTNAME_VUE
)
export
const
UNI_MODULES_EXPORTS
=
'
\
0uni-modules-exports
'
export
const
PAGES_JSON_JS
=
'
pages-json-js
'
export
const
MANIFEST_JSON_JS
=
'
manifest-json-js
'
export
const
JSON_JS_MAP
=
{
...
...
packages/uni-cli-shared/src/index.ts
浏览文件 @
51427a3f
...
...
@@ -21,6 +21,8 @@ export * from './resolve'
export
*
from
'
./scripts
'
export
*
from
'
./platform
'
export
{
parseUniExtApis
}
from
'
./uni_modules
'
export
{
M
}
from
'
./messages
'
export
*
from
'
./exports
'
...
...
packages/uni-cli-shared/src/uni_modules.ts
浏览文件 @
51427a3f
...
...
@@ -2,7 +2,7 @@ import path from 'path'
import
fs
from
'
fs-extra
'
import
{
recursive
}
from
'
merge
'
type
Define
=
string
|
string
[]
|
Record
<
string
,
string
>
type
Define
=
string
|
string
[]
|
Record
<
string
,
string
>
|
false
type
Defines
=
{
[
name
:
string
]:
Define
}
...
...
@@ -11,13 +11,13 @@ interface Exports {
[
name
:
string
]:
Define
|
Defines
|
false
}
export
function
genUniModulesExport
s
()
{
export
function
parseUniExtApi
s
()
{
const
uniModulesDir
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
uni_modules
'
)
if
(
!
fs
.
existsSync
(
uniModulesDir
))
{
return
''
return
{}
}
const
importCodes
:
string
[]
=
[]
const
assignCodes
:
string
[]
=
[]
const
injects
:
Injects
=
{}
fs
.
readdirSync
(
uniModulesDir
).
forEach
((
uniModuleDir
)
=>
{
// 必须以 uni- 开头
if
(
!
uniModuleDir
.
startsWith
(
'
uni-
'
))
{
...
...
@@ -27,60 +27,26 @@ export function genUniModulesExports() {
if
(
!
fs
.
existsSync
(
pkgPath
))
{
return
}
const
exports
=
JSON
.
parse
(
fs
.
readFileSync
(
pkgPath
,
'
utf8
'
))?.
uni_modules
?.
exports
as
Exports
|
undefined
const
exports
=
JSON
.
parse
(
fs
.
readFileSync
(
pkgPath
,
'
utf8
'
))?.
uni_modules
?.[
'
uni-ext-api
'
]
as
Exports
|
undefined
if
(
exports
)
{
const
[
exportsImportCodes
,
exportsAssignCodes
]
=
parseExports
(
process
.
env
.
UNI_PLATFORM
===
'
h5
'
?
'
web
'
:
process
.
env
.
UNI_PLATFORM
,
`@/uni_modules/
${
uniModuleDir
}
`
,
exports
Object
.
assign
(
injects
,
parseInjects
(
process
.
env
.
UNI_PLATFORM
===
'
h5
'
?
'
web
'
:
process
.
env
.
UNI_PLATFORM
,
`@/uni_modules/
${
uniModuleDir
}
`
,
exports
)
)
importCodes
.
push
(...
exportsImportCodes
)
assignCodes
.
push
(...
exportsAssignCodes
)
}
})
if
(
!
importCodes
.
length
)
{
return
''
}
return
`
${
importCodes
.
join
(
'
\n
'
)}
${
assignCodes
.
join
(
'
\n
'
)}
`
return
injects
}
export
function
parseExports
(
platform
:
UniApp
.
PLATFORM
,
source
:
string
,
exports
:
Exports
=
{}
):
[
string
[],
string
[]]
{
const
rootDefines
:
Defines
=
{}
Object
.
keys
(
exports
).
forEach
((
name
)
=>
{
if
(
name
.
startsWith
(
'
uni
'
))
{
rootDefines
[
name
]
=
exports
[
name
]
as
Define
}
})
const
platformDefines
=
exports
[
platform
]
as
false
|
Defines
// 该平台不支持
if
(
platformDefines
===
false
)
{
return
[[],
[]]
}
return
parseDefines
(
source
,
recursive
(
true
,
rootDefines
,
platformDefines
))
}
export
function
parseDefines
(
source
:
string
,
defines
:
Defines
=
{}
):
[
string
[],
string
[]]
{
const
importCodes
:
string
[]
=
[]
const
assignCodes
:
string
[]
=
[]
Object
.
keys
(
defines
).
forEach
((
name
)
=>
{
const
[
defineImportCodes
,
defineAssignCodes
]
=
parseDefine
(
source
,
name
,
defines
[
name
]
)
importCodes
.
push
(...
defineImportCodes
)
assignCodes
.
push
(...
defineAssignCodes
)
})
return
[
importCodes
,
assignCodes
]
type
Inject
=
string
|
string
[]
type
Injects
=
{
[
name
:
string
]:
string
|
string
[]
|
false
}
/**
* uni:'getBatteryInfo'
...
...
@@ -103,34 +69,52 @@ export function parseDefines(
* @param define
* @returns
*/
function
parseDefine
(
export
function
parseInjects
(
platform
:
UniApp
.
PLATFORM
,
source
:
string
,
exports
:
Exports
=
{}
)
{
let
rootDefines
:
Defines
=
{}
Object
.
keys
(
exports
).
forEach
((
name
)
=>
{
if
(
name
.
startsWith
(
'
uni
'
))
{
rootDefines
[
name
]
=
exports
[
name
]
as
Inject
}
})
const
platformDefines
=
exports
[
platform
]
as
false
|
Defines
// 该平台不支持
if
(
platformDefines
===
false
)
{
return
{}
}
if
(
platformDefines
)
{
rootDefines
=
recursive
(
true
,
rootDefines
,
platformDefines
)
}
const
injects
:
Injects
=
{}
for
(
const
key
in
rootDefines
)
{
Object
.
assign
(
injects
,
parseInject
(
source
,
'
uni
'
,
rootDefines
[
key
]))
}
return
injects
}
export
function
parseInject
(
source
:
string
,
globalObject
:
string
,
define
:
Define
)
:
[
string
[],
string
[]]
{
const
i
mportCodes
:
string
[]
=
[]
const
assignCodes
:
string
[]
=
[]
if
(
typeof
define
===
'
string
'
)
{
importCodes
.
push
(
`import
${
define
}
from '
${
source
}
'`
)
assignCodes
.
push
(
`
${
globalObject
}
.
${
define
}
=
${
define
}
`
)
)
{
const
i
njects
:
Injects
=
{}
if
(
define
===
false
)
{
}
else
if
(
typeof
define
===
'
string
'
)
{
// {'uni.getBatteryInfo' : '@dcloudio/uni-getbatteryinfo'}
injects
[
globalObject
+
'
.
'
+
define
]
=
source
}
else
if
(
Array
.
isArray
(
define
))
{
importCodes
.
push
(
`import {
${
define
.
join
(
'
,
'
)}
} from '
${
source
}
'`
)
// {'uni.getBatteryInfo' : ['@dcloudio/uni-getbatteryinfo','getBatteryInfo]}
define
.
forEach
((
d
)
=>
{
assignCodes
.
push
(
`
${
globalObject
}
.
${
d
}
=
${
d
}
`
)
injects
[
globalObject
+
'
.
'
+
d
]
=
[
source
,
d
]
})
}
else
{
const
keys
=
Object
.
keys
(
define
)
const
specifiers
:
string
[]
=
[]
keys
.
forEach
((
d
)
=>
{
if
(
d
!==
define
[
d
])
{
specifiers
.
push
(
`
${
define
[
d
]}
as
${
d
}
`
)
}
else
{
specifiers
.
push
(
d
)
}
assignCodes
.
push
(
`
${
globalObject
}
.
${
d
}
=
${
d
}
`
)
injects
[
globalObject
+
'
.
'
+
d
]
=
[
source
,
define
[
d
]]
})
importCodes
.
push
(
`import {
${
specifiers
.
join
(
'
,
'
)}
} from '
${
source
}
'`
)
}
return
[
importCodes
,
assignCodes
]
return
injects
}
packages/uni-cli-shared/src/vite/plugins/index.ts
浏览文件 @
51427a3f
...
...
@@ -5,7 +5,6 @@ export * from './mainJs'
export
*
from
'
./jsonJs
'
export
*
from
'
./console
'
export
*
from
'
./dynamicImportPolyfill
'
export
{
uniModulesExportsPlugin
}
from
'
./uniModules
'
export
{
assetPlugin
,
getAssetHash
}
from
'
./vitejs/plugins/asset
'
export
{
...
...
packages/uni-cli-shared/src/vite/plugins/inject.ts
浏览文件 @
51427a3f
...
...
@@ -23,7 +23,6 @@ import {
isJsFile
,
isAssignmentExpression
,
}
from
'
../utils
'
import
{
UNI_MODULES_EXPORTS
}
from
'
../../constants
'
interface
Scope
{
parent
:
Scope
...
...
@@ -84,11 +83,9 @@ export function uniViteInjectPlugin(
// 确保在 commonjs 之后,否则会混合 es6 module 与 cjs 的代码,导致 commonjs 失效
enforce
:
'
post
'
,
transform
(
code
,
id
)
{
// 硬编码支持了uni_modules_exports
if
(
id
!==
UNI_MODULES_EXPORTS
)
{
if
(
!
filter
(
id
))
return
null
if
(
!
isJsFile
(
id
))
return
null
}
if
(
!
filter
(
id
))
return
null
if
(
!
isJsFile
(
id
))
return
null
debugInjectTry
(
id
)
if
(
code
.
search
(
firstpass
)
===
-
1
)
return
null
if
(
sep
!==
'
/
'
)
id
=
id
.
split
(
sep
).
join
(
'
/
'
)
...
...
packages/uni-cli-shared/src/vite/plugins/uniModules.ts
已删除
100644 → 0
浏览文件 @
8c465081
import
type
{
Plugin
}
from
'
vite
'
import
{
UNI_MODULES_EXPORTS
}
from
'
../../constants
'
import
{
genUniModulesExports
}
from
'
../../uni_modules
'
export
function
uniModulesExportsPlugin
({
enable
,
}:
{
enable
:
boolean
}):
Plugin
{
return
{
name
:
'
uni:modules:exports
'
,
resolveId
(
id
)
{
if
(
id
===
UNI_MODULES_EXPORTS
)
{
return
UNI_MODULES_EXPORTS
}
},
load
(
id
)
{
if
(
id
!==
UNI_MODULES_EXPORTS
)
{
return
}
// 未启用
if
(
!
enable
)
{
return
''
}
return
genUniModulesExports
()
},
}
}
packages/uni-cli-shared/src/vite/utils/url.ts
浏览文件 @
51427a3f
import
path
from
'
path
'
import
{
EXTNAME_JS_RE
,
EXTNAME_VUE
,
UNI_MODULES_EXPORTS
,
}
from
'
../../constants
'
import
{
EXTNAME_JS_RE
,
EXTNAME_VUE
}
from
'
../../constants
'
export
interface
VueQuery
{
vue
?:
boolean
...
...
@@ -66,10 +62,6 @@ export const cleanUrl = (url: string) =>
url
.
replace
(
hashRE
,
''
).
replace
(
queryRE
,
''
)
export
function
isJsFile
(
id
:
string
)
{
// inject 使用了isJsFile 判断。uni_modules_exports 中注入使用了 uni,在小程序平台,inject 需要注入 uni 对象
if
(
id
===
UNI_MODULES_EXPORTS
)
{
return
true
}
const
{
filename
,
query
}
=
parseVueRequest
(
id
)
const
isJs
=
EXTNAME_JS_RE
.
test
(
filename
)
if
(
isJs
)
{
...
...
packages/uni-h5-vite/src/plugins/mainJs.ts
浏览文件 @
51427a3f
...
...
@@ -2,7 +2,6 @@ import {
defineUniMainJsPlugin
,
isSsr
,
PAGES_JSON_JS
,
UNI_MODULES_EXPORTS
,
}
from
'
@dcloudio/uni-cli-shared
'
import
{
isSSR
,
isSsrManifest
}
from
'
../utils
'
...
...
@@ -27,7 +26,7 @@ export function uniMainJsPlugin() {
?
createSSRServerApp
(
code
)
:
createSSRClientApp
(
code
)
}
code
=
`import './
${
PAGES_JSON_JS
}
';
import '
${
UNI_MODULES_EXPORTS
}
';
${
code
}
`
code
=
`import './
${
PAGES_JSON_JS
}
';
${
code
}
`
return
{
code
,
map
:
this
.
getCombinedSourcemap
(),
...
...
packages/uni-h5/dist/uni-h5.cjs.js
浏览文件 @
51427a3f
...
...
@@ -6718,8 +6718,10 @@ const useSwiperNavigation = (rootRef, props2, state, onSwiperDotClick, swiperCon
onMouseover
:
(
event
)
=>
navigationHover
(
event
,
"
over
"
),
onMouseout
:
(
event
)
=>
navigationHover
(
event
,
"
out
"
)
};
function
navigationClick
(
$event
,
type
)
{
function
navigationClick
(
$event
,
type
,
disabled
)
{
$event
.
stopPropagation
();
if
(
disabled
)
return
;
const
swiperItemLength
=
swiperContext
.
value
.
length
;
let
_current
=
state
.
current
;
switch
(
type
)
{
...
...
@@ -6790,12 +6792,12 @@ const useSwiperNavigation = (rootRef, props2, state, onSwiperDotClick, swiperCon
"
class
"
:
[
"
uni-swiper-navigation uni-swiper-navigation-prev
"
,
shared
.
extend
({
"
uni-swiper-navigation-disabled
"
:
prevDisabled
},
navigationClass
)],
"
onClick
"
:
(
e2
)
=>
navigationClick
(
e2
,
"
prev
"
)
"
onClick
"
:
(
e2
)
=>
navigationClick
(
e2
,
"
prev
"
,
prevDisabled
)
},
navigationAttr
),
[
createNavigationSVG
()],
16
,
[
"
onClick
"
]),
vue
.
createVNode
(
"
div
"
,
vue
.
mergeProps
({
"
class
"
:
[
"
uni-swiper-navigation uni-swiper-navigation-next
"
,
shared
.
extend
({
"
uni-swiper-navigation-disabled
"
:
nextDisabled
},
navigationClass
)],
"
onClick
"
:
(
e2
)
=>
navigationClick
(
e2
,
"
next
"
)
"
onClick
"
:
(
e2
)
=>
navigationClick
(
e2
,
"
next
"
,
nextDisabled
)
},
navigationAttr
),
[
createNavigationSVG
()],
16
,
[
"
onClick
"
])]);
}
return
null
;
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
51427a3f
...
...
@@ -14207,8 +14207,10 @@ const useSwiperNavigation = (rootRef, props2, state2, onSwiperDotClick, swiperCo
onMouseover: (event) => navigationHover(event, "over"),
onMouseout: (event) => navigationHover(event, "out")
};
function navigationClick($event, type) {
function navigationClick($event, type
, disabled
) {
$event.stopPropagation();
if (disabled)
return;
const swiperItemLength = swiperContext.value.length;
let _current = state2.current;
switch (type) {
...
...
@@ -14280,12 +14282,12 @@ const useSwiperNavigation = (rootRef, props2, state2, onSwiperDotClick, swiperCo
"class": ["uni-swiper-navigation uni-swiper-navigation-prev", extend({
"uni-swiper-navigation-disabled": prevDisabled
}, navigationClass)],
"onClick": (e2) => navigationClick(e2, "prev")
"onClick": (e2) => navigationClick(e2, "prev"
, prevDisabled
)
}, navigationAttr), [createNavigationSVG()], 16, ["onClick"]), createVNode("div", mergeProps({
"class": ["uni-swiper-navigation uni-swiper-navigation-next", extend({
"uni-swiper-navigation-disabled": nextDisabled
}, navigationClass)],
"onClick": (e2) => navigationClick(e2, "next")
"onClick": (e2) => navigationClick(e2, "next"
, nextDisabled
)
}, navigationAttr), [createNavigationSVG()], 16, ["onClick"])]);
}
return null;
...
...
packages/uni-mp-baidu/dist/uni.api.esm.js
浏览文件 @
51427a3f
...
...
@@ -1175,13 +1175,17 @@ function createIntersectionObserver(component, options) {
delete
options
.
observeAll
;
}
return
swan
.
createIntersectionObserver
(
component
,
options
);
}
function
createVideoContext
(
videoId
)
{
return
swan
.
createVideoContext
(
videoId
);
}
var
shims
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
getProvider
:
getProvider
,
requestPayment
:
requestPayment
,
createIntersectionObserver
:
createIntersectionObserver
createIntersectionObserver
:
createIntersectionObserver
,
createVideoContext
:
createVideoContext
});
function
createTodoMethod
(
contextName
,
methodName
)
{
...
...
packages/uni-mp-vite/src/plugins/mainJs.ts
浏览文件 @
51427a3f
...
...
@@ -3,7 +3,6 @@ import {
PAGES_JSON_JS
,
parseProgram
,
transformDynamicImports
,
UNI_MODULES_EXPORTS
,
updateMiniProgramGlobalComponents
,
withSourcemap
,
}
from
'
@dcloudio/uni-cli-shared
'
...
...
@@ -47,7 +46,7 @@ export function uniMainJsPlugin(
})
return
{
code
:
`import '\0plugin-vue:export-helper';import 'uni-mp-runtime';import './
${
PAGES_JSON_JS
}
';
import '
${
UNI_MODULES_EXPORTS
}
';
`
+
`import '\0plugin-vue:export-helper';import 'uni-mp-runtime';import './
${
PAGES_JSON_JS
}
';`
+
code
,
map
,
}
...
...
packages/vite-plugin-uni/src/index.ts
浏览文件 @
51427a3f
...
...
@@ -13,9 +13,9 @@ import {
emptyDir
,
initModuleAlias
,
initPreContext
,
parse
PagesJsonOnce
,
parse
UniExtApis
,
resolveSourceMapPath
,
uni
ModulesExports
Plugin
,
uni
ViteInject
Plugin
,
}
from
'
@dcloudio/uni-cli-shared
'
import
{
createConfig
}
from
'
./config
'
...
...
@@ -92,15 +92,8 @@ export default function uniPlugin(
initPreContext
(
options
.
platform
,
process
.
env
.
UNI_CUSTOM_CONTEXT
)
const
pagesJson
=
parsePagesJsonOnce
(
process
.
env
.
UNI_INPUT_DIR
,
process
.
env
.
UNI_PLATFORM
)
const
plugins
:
Plugin
[]
=
[
uniModulesExportsPlugin
({
enable
:
pagesJson
.
uni_modules
?.
exports
===
false
?
false
:
true
,
}),
uniViteInjectPlugin
(
'
uni:ext-api-inject
'
,
parseUniExtApis
()),
]
// 仅限 h5
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录