Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qianlong66
uni-app
提交
96a868a4
U
uni-app
项目概览
qianlong66
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
96a868a4
编写于
8月 04, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(app): ios promise.then
上级
3a646ffb
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
169 addition
and
353 deletion
+169
-353
packages/uni-app-vite/dist/plugin/configResolved.js
packages/uni-app-vite/dist/plugin/configResolved.js
+6
-11
packages/uni-app-vite/src/plugin/configResolved.ts
packages/uni-app-vite/src/plugin/configResolved.ts
+10
-12
packages/uni-app-vite/src/plugin/uni.ts
packages/uni-app-vite/src/plugin/uni.ts
+0
-4
packages/uni-app-vue/dist/service.runtime.esm.js
packages/uni-app-vue/dist/service.runtime.esm.js
+10
-2
packages/uni-app-vue/lib/service.runtime.esm.js
packages/uni-app-vue/lib/service.runtime.esm.js
+8
-1
packages/uni-cli-nvue/dist/webpack/config/plugins/provide.js
packages/uni-cli-nvue/dist/webpack/config/plugins/provide.js
+8
-3
packages/uni-cli-shared/src/vite/index.ts
packages/uni-cli-shared/src/vite/index.ts
+1
-2
packages/uni-cli-shared/src/vite/plugins/vitejs/plugins/asset.ts
...s/uni-cli-shared/src/vite/plugins/vitejs/plugins/asset.ts
+16
-167
packages/uni-cli-shared/src/vite/utils/plugin.ts
packages/uni-cli-shared/src/vite/utils/plugin.ts
+10
-5
packages/uni-h5-vite/dist/handleHotUpdate/index.js
packages/uni-h5-vite/dist/handleHotUpdate/index.js
+55
-68
packages/uni-h5-vite/dist/index.js
packages/uni-h5-vite/dist/index.js
+0
-18
packages/uni-h5-vite/dist/plugins/cssScoped.js
packages/uni-h5-vite/dist/plugins/cssScoped.js
+3
-12
packages/uni-h5-vite/dist/plugins/manifestJson.js
packages/uni-h5-vite/dist/plugins/manifestJson.js
+2
-2
packages/uni-h5-vite/dist/transformIndexHtml/index.js
packages/uni-h5-vite/dist/transformIndexHtml/index.js
+4
-15
packages/uni-h5-vite/src/index.ts
packages/uni-h5-vite/src/index.ts
+0
-18
packages/uni-vue/src/componentOptions.ts
packages/uni-vue/src/componentOptions.ts
+6
-2
packages/vite-plugin-uni/src/vue/options.ts
packages/vite-plugin-uni/src/vue/options.ts
+29
-10
tsconfig.node.json
tsconfig.node.json
+1
-1
未找到文件。
packages/uni-app-vite/dist/plugin/configResolved.js
浏览文件 @
96a868a4
...
...
@@ -3,16 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports
.
configResolved
=
void
0
;
const
uni_cli_shared_1
=
require
(
"
@dcloudio/uni-cli-shared
"
);
const
configResolved
=
(
config
)
=>
{
if
(
process
.
env
.
UNI_APP_CODE_SPLITING
)
{
initCodeSpliting
(
config
);
}
else
{
// 移除 vite 内置的 css post 处理,交由 @dcloudio/uni-cli-shared 的 uniCssPlugin 实现
uni_cli_shared_1
.
removePlugins
([
'
vite:asset
'
,
'
vite:css-post
'
],
config
);
}
// 移除 vite 内置的 css post 处理,交由 @dcloudio/uni-cli-shared 的 uniCssPlugin 实现
uni_cli_shared_1
.
removePlugins
([
'
vite:css-post
'
],
config
);
// removePlugins('vite:import-analysis', config)
// injectCssPlugin(config)
// injectCssPostPlugin(config)
// injectAssetPlugin(config)
};
exports
.
configResolved
=
configResolved
;
function
initCodeSpliting
(
config
)
{
uni_cli_shared_1
.
removePlugins
(
'
vite:import-analysis
'
,
config
);
uni_cli_shared_1
.
injectAssetAndCssPlugins
(
config
);
}
packages/uni-app-vite/src/plugin/configResolved.ts
浏览文件 @
96a868a4
import
{
Plugin
,
ResolvedConfig
}
from
'
vite
'
import
{
Plugin
}
from
'
vite
'
import
{
removePlugins
,
injectAssetAndCssPlugins
,
// injectAssetPlugin,
// injectCssPlugin,
// injectCssPostPlugin,
}
from
'
@dcloudio/uni-cli-shared
'
export
const
configResolved
:
Plugin
[
'
configResolved
'
]
=
(
config
)
=>
{
if
(
process
.
env
.
UNI_APP_CODE_SPLITING
)
{
initCodeSpliting
(
config
as
ResolvedConfig
)
}
else
{
// 移除 vite 内置的 css post 处理,交由 @dcloudio/uni-cli-shared 的 uniCssPlugin 实现
removePlugins
([
'
vite:css-post
'
],
config
)
}
}
// 移除 vite 内置的 css post 处理,交由 @dcloudio/uni-cli-shared 的 uniCssPlugin 实现
removePlugins
([
'
vite:css-post
'
],
config
)
function
initCodeSpliting
(
config
:
ResolvedConfig
)
{
removePlugins
(
'
vite:import-analysis
'
,
config
)
injectAssetAndCssPlugins
(
config
)
// removePlugins('vite:import-analysis', config)
// injectCssPlugin(config)
// injectCssPostPlugin(config)
// injectAssetPlugin(config)
}
packages/uni-app-vite/src/plugin/uni.ts
浏览文件 @
96a868a4
...
...
@@ -12,8 +12,4 @@ export const uniOptions: UniVitePlugin['uni'] = {
transformEvent
:
{
tap
:
'
click
'
,
},
transformAssetUrls
:
{
base
:
'
/
'
,
tags
:
{},
},
}
packages/uni-app-vue/dist/service.runtime.esm.js
浏览文件 @
96a868a4
...
...
@@ -2307,8 +2307,16 @@ export default function vueFactory(exports) {
var
preFlushIndex
=
0
;
var
pendingPostFlushCbs
=
[];
var
activePostFlushCbs
=
null
;
var
postFlushIndex
=
0
;
var
resolvedPromise
=
Promise
.
resolve
();
var
postFlushIndex
=
0
;
// fixed by xxxxxx iOS
var
iOSPromise
=
{
then
(
callback
)
{
setTimeout
(()
=>
callback
(),
0
);
}
};
var
isIOS
=
plus
.
os
.
name
===
'
iOS
'
;
var
resolvedPromise
=
isIOS
?
iOSPromise
:
Promise
.
resolve
();
var
currentFlushPromise
=
null
;
var
currentPreFlushParentJob
=
null
;
var
RECURSION_LIMIT
=
100
;
...
...
packages/uni-app-vue/lib/service.runtime.esm.js
浏览文件 @
96a868a4
...
...
@@ -1374,7 +1374,14 @@ let preFlushIndex = 0;
const
pendingPostFlushCbs
=
[];
let
activePostFlushCbs
=
null
;
let
postFlushIndex
=
0
;
const
resolvedPromise
=
Promise
.
resolve
();
// fixed by xxxxxx iOS
const
iOSPromise
=
{
then
(
callback
)
{
setTimeout
(()
=>
callback
(),
0
);
}
};
const
isIOS
=
plus
.
os
.
name
===
'
iOS
'
;
const
resolvedPromise
=
isIOS
?
iOSPromise
:
Promise
.
resolve
();
let
currentFlushPromise
=
null
;
let
currentPreFlushParentJob
=
null
;
const
RECURSION_LIMIT
=
100
;
...
...
packages/uni-cli-nvue/dist/webpack/config/plugins/provide.js
浏览文件 @
96a868a4
...
...
@@ -5,12 +5,17 @@ const webpack_1 = require("webpack");
const
uni_cli_shared_1
=
require
(
"
@dcloudio/uni-cli-shared
"
);
const
utils_1
=
require
(
"
../../../utils
"
);
function
createProvidePlugin
()
{
return
new
webpack_1
.
ProvidePlugin
(
Object
.
assign
({
uniCloud
:
[
return
new
webpack_1
.
ProvidePlugin
({
uniCloud
:
[
require
.
resolve
(
'
@dcloudio/uni-cloud/dist/uni-cloud.es.js
'
),
'
default
'
,
],
'
uni.getCurrentSubNVue
'
:
[
utils_1
.
resolveLib
(
'
get-current-sub-nvue.js
'
),
'
default
'
],
'
uni.requireNativePlugin
'
:
[
],
'
uni.getCurrentSubNVue
'
:
[
utils_1
.
resolveLib
(
'
get-current-sub-nvue.js
'
),
'
default
'
],
'
uni.requireNativePlugin
'
:
[
utils_1
.
resolveLib
(
'
require-native-plugin.js
'
),
'
default
'
,
]
},
uni_cli_shared_1
.
initProvide
()));
],
...
uni_cli_shared_1
.
initProvide
(),
});
}
exports
.
createProvidePlugin
=
createProvidePlugin
;
packages/uni-cli-shared/src/vite/index.ts
浏览文件 @
96a868a4
import
{
Plugin
}
from
'
vite
'
import
{
ParserOptions
}
from
'
@vue/compiler-core
'
import
{
CompilerOptions
,
SFCTemplateCompileOptions
}
from
'
@vue/compiler-sfc
'
import
{
CompilerOptions
}
from
'
@vue/compiler-sfc
'
export
interface
UniVitePlugin
extends
Plugin
{
uni
?:
{
compilerOptions
?:
{
...
...
@@ -9,7 +9,6 @@ export interface UniVitePlugin extends Plugin {
directiveTransforms
?:
CompilerOptions
[
'
directiveTransforms
'
]
}
transformEvent
?:
Record
<
string
,
string
>
transformAssetUrls
?:
SFCTemplateCompileOptions
[
'
transformAssetUrls
'
]
}
}
...
...
packages/uni-cli-shared/src/vite/plugins/vitejs/plugins/asset.ts
浏览文件 @
96a868a4
import
path
from
'
path
'
import
{
parse
as
parseUrl
}
from
'
url
'
import
fs
,
{
promises
as
fsp
}
from
'
fs
'
import
mime
from
'
mime/lite
'
import
{
Plugin
}
from
'
../plugin
'
import
{
ResolvedConfig
}
from
'
../config
'
import
{
cleanUrl
}
from
'
../utils
'
import
{
FS_PREFIX
}
from
'
../constants
'
import
{
OutputOptions
,
PluginContext
,
RenderedChunk
}
from
'
rollup
'
import
{
PluginContext
,
RenderedChunk
}
from
'
rollup
'
import
MagicString
from
'
magic-string
'
import
{
createHash
}
from
'
crypto
'
...
...
@@ -107,20 +105,6 @@ export function assetPlugin(config: ResolvedConfig): Plugin {
return
null
}
},
generateBundle
(
_
,
bundle
)
{
// do not emit assets for SSR build
if
(
config
.
command
===
'
build
'
&&
config
.
build
.
ssr
)
{
for
(
const
file
in
bundle
)
{
if
(
bundle
[
file
].
type
===
'
asset
'
&&
!
file
.
includes
(
'
ssr-manifest.json
'
)
)
{
delete
bundle
[
file
]
}
}
}
},
}
}
...
...
@@ -154,28 +138,8 @@ export function fileToUrl(
id
:
string
,
config
:
ResolvedConfig
,
ctx
:
PluginContext
):
string
|
Promise
<
string
>
{
if
(
config
.
command
===
'
serve
'
)
{
return
fileToDevUrl
(
id
,
config
)
}
else
{
return
fileToBuiltUrl
(
id
,
config
,
ctx
)
}
}
function
fileToDevUrl
(
id
:
string
,
config
:
ResolvedConfig
)
{
let
rtn
:
string
if
(
checkPublicFile
(
id
,
config
))
{
// in public dir, keep the url as-is
rtn
=
id
}
else
if
(
id
.
startsWith
(
config
.
root
))
{
// in project root, infer short public path
rtn
=
'
/
'
+
path
.
posix
.
relative
(
config
.
root
,
id
)
}
else
{
// outside of project root, use absolute fs path
// (this is special handled by the serve static middleware
rtn
=
path
.
posix
.
join
(
FS_PREFIX
+
id
)
}
return
config
.
base
+
rtn
.
replace
(
/^
\/
/
,
''
)
):
string
{
return
fileToBuiltUrl
(
id
,
config
,
ctx
)
}
export
function
getAssetFilename
(
...
...
@@ -184,97 +148,19 @@ export function getAssetFilename(
):
string
|
undefined
{
return
assetHashToFilenameMap
.
get
(
config
)?.
get
(
hash
)
}
/**
* converts the source filepath of the asset to the output filename based on the assetFileNames option. \
* this function imitates the behavior of rollup.js. \
* https://rollupjs.org/guide/en/#outputassetfilenames
*
* @example
* ```ts
* const content = Buffer.from('text');
* const fileName = assetFileNamesToFileName(
* 'assets/[name].[hash][extname]',
* '/path/to/file.txt',
* getAssetHash(content),
* content
* )
* // fileName: 'assets/file.982d9e3e.txt'
* ```
*
* @param assetFileNames filename pattern. e.g. `'assets/[name].[hash][extname]'`
* @param file filepath of the asset
* @param contentHash hash of the asset. used for `'[hash]'` placeholder
* @param content content of the asset. passed to `assetFileNames` if `assetFileNames` is a function
* @returns output filename
*/
export
function
assetFileNamesToFileName
(
assetFileNames
:
Exclude
<
OutputOptions
[
'
assetFileNames
'
],
undefined
>
,
file
:
string
,
contentHash
:
string
,
content
:
string
|
Buffer
):
string
{
const
basename
=
path
.
basename
(
file
)
// placeholders for `assetFileNames`
// `hash` is slightly different from the rollup's one
const
extname
=
path
.
extname
(
basename
)
const
ext
=
extname
.
substr
(
1
)
const
name
=
basename
.
slice
(
0
,
-
extname
.
length
)
const
hash
=
contentHash
if
(
typeof
assetFileNames
===
'
function
'
)
{
assetFileNames
=
assetFileNames
({
name
:
file
,
source
:
content
,
type
:
'
asset
'
,
})
if
(
typeof
assetFileNames
!==
'
string
'
)
{
throw
new
TypeError
(
'
assetFileNames must return a string
'
)
}
}
else
if
(
typeof
assetFileNames
!==
'
string
'
)
{
throw
new
TypeError
(
'
assetFileNames must be a string or a function
'
)
}
const
fileName
=
assetFileNames
.
replace
(
/
\[\w
+
\]
/g
,
(
placeholder
:
string
):
string
=>
{
switch
(
placeholder
)
{
case
'
[ext]
'
:
return
ext
case
'
[extname]
'
:
return
extname
case
'
[hash]
'
:
return
hash
case
'
[name]
'
:
return
name
}
throw
new
Error
(
`invalid placeholder
${
placeholder
}
in assetFileNames "
${
assetFileNames
}
"`
)
}
)
return
fileName
}
/**
* Register an asset to be emitted as part of the bundle (if necessary)
* and returns the resolved public URL
*/
async
function
fileToBuiltUrl
(
function
fileToBuiltUrl
(
id
:
string
,
config
:
ResolvedConfig
,
pluginContext
:
PluginContext
,
skipPublicCheck
=
false
):
Promise
<
string
>
{
):
string
{
if
(
!
skipPublicCheck
&&
checkPublicFile
(
id
,
config
))
{
return
config
.
base
+
id
.
slice
(
1
)
}
const
cache
=
assetCache
.
get
(
config
)
!
const
cached
=
cache
.
get
(
id
)
if
(
cached
)
{
...
...
@@ -282,56 +168,19 @@ async function fileToBuiltUrl(
}
const
file
=
cleanUrl
(
id
)
const
content
=
await
fsp
.
readFile
(
file
)
const
content
=
fs
.
readFileSync
(
file
)
let
url
:
string
if
(
config
.
build
.
lib
||
(
!
file
.
endsWith
(
'
.svg
'
)
&&
content
.
length
<
Number
(
config
.
build
.
assetsInlineLimit
))
)
{
// base64 inlined as a string
url
=
`data:
${
mime
.
getType
(
file
)}
;base64,
${
content
.
toString
(
'
base64
'
)}
`
}
else
{
// emit as asset
// rollup supports `import.meta.ROLLUP_FILE_URL_*`, but it generates code
// that uses runtime url sniffing and it can be verbose when targeting
// non-module format. It also fails to cascade the asset content change
// into the chunk's hash, so we have to do our own content hashing here.
// https://bundlers.tooling.report/hashing/asset-cascade/
// https://github.com/rollup/rollup/issues/3415
const
map
=
assetHashToFilenameMap
.
get
(
config
)
!
const
contentHash
=
getAssetHash
(
content
)
const
{
search
,
hash
}
=
parseUrl
(
id
)
const
postfix
=
(
search
||
''
)
+
(
hash
||
''
)
const
output
=
config
.
build
?.
rollupOptions
?.
output
const
assetFileNames
=
(
output
&&
!
Array
.
isArray
(
output
)
?
output
.
assetFileNames
:
undefined
)
??
// defaults to '<assetsDir>/[name].[hash][extname]'
// slightly different from rollup's one ('assets/[name]-[hash][extname]')
path
.
posix
.
join
(
config
.
build
.
assetsDir
,
'
[name].[hash][extname]
'
)
const
fileName
=
assetFileNamesToFileName
(
assetFileNames
,
file
,
contentHash
,
content
)
if
(
!
map
.
has
(
contentHash
))
{
map
.
set
(
contentHash
,
fileName
)
}
const
emittedSet
=
emittedHashMap
.
get
(
config
)
!
if
(
!
emittedSet
.
has
(
contentHash
))
{
pluginContext
.
emitFile
({
fileName
,
type
:
'
asset
'
,
source
:
content
,
})
emittedSet
.
add
(
contentHash
)
}
url
=
`__VITE_ASSET__
${
contentHash
}
__
${
postfix
?
`$_
${
postfix
}
__`
:
``
}
`
const
map
=
assetHashToFilenameMap
.
get
(
config
)
!
const
contentHash
=
getAssetHash
(
content
)
const
{
search
,
hash
}
=
parseUrl
(
id
)
const
postfix
=
(
search
||
''
)
+
(
hash
||
''
)
const
fileName
=
'
/
'
+
path
.
posix
.
relative
(
process
.
env
.
UNI_INPUT_DIR
,
id
)
if
(
!
map
.
has
(
contentHash
))
{
map
.
set
(
contentHash
,
fileName
)
}
url
=
`__VITE_ASSET__
${
contentHash
}
__
${
postfix
?
`$_
${
postfix
}
__`
:
``
}
`
cache
.
set
(
id
,
url
)
return
url
}
...
...
@@ -340,12 +189,12 @@ export function getAssetHash(content: Buffer): string {
return
createHash
(
'
sha256
'
).
update
(
content
).
digest
(
'
hex
'
).
slice
(
0
,
8
)
}
export
async
function
urlToBuiltUrl
(
export
function
urlToBuiltUrl
(
url
:
string
,
importer
:
string
,
config
:
ResolvedConfig
,
pluginContext
:
PluginContext
):
Promise
<
string
>
{
):
string
{
if
(
checkPublicFile
(
url
,
config
))
{
return
config
.
base
+
url
.
slice
(
1
)
}
...
...
packages/uni-cli-shared/src/vite/utils/plugin.ts
浏览文件 @
96a868a4
...
...
@@ -9,11 +9,16 @@ export interface UniViteFilterPluginOptions {
filter
:
(
id
:
string
)
=>
boolean
}
export
function
injectAssetAndCssPlugins
(
config
:
ResolvedConfig
)
{
replacePlugins
(
[
assetPlugin
(
config
),
cssPlugin
(
config
),
cssPostPlugin
(
config
)],
config
)
export
function
injectAssetPlugin
(
config
:
ResolvedConfig
)
{
replacePlugins
([
assetPlugin
(
config
)],
config
)
}
export
function
injectCssPlugin
(
config
:
ResolvedConfig
)
{
replacePlugins
([
cssPlugin
(
config
)],
config
)
}
export
function
injectCssPostPlugin
(
config
:
ResolvedConfig
)
{
replacePlugins
([
cssPostPlugin
(
config
)],
config
)
}
export
function
replacePlugins
(
plugins
:
Plugin
[],
config
:
ResolvedConfig
)
{
...
...
packages/uni-h5-vite/dist/handleHotUpdate/index.js
浏览文件 @
96a868a4
"
use strict
"
;
var
__awaiter
=
(
this
&&
this
.
__awaiter
)
||
function
(
thisArg
,
_arguments
,
P
,
generator
)
{
function
adopt
(
value
)
{
return
value
instanceof
P
?
value
:
new
P
(
function
(
resolve
)
{
resolve
(
value
);
});
}
return
new
(
P
||
(
P
=
Promise
))(
function
(
resolve
,
reject
)
{
function
fulfilled
(
value
)
{
try
{
step
(
generator
.
next
(
value
));
}
catch
(
e
)
{
reject
(
e
);
}
}
function
rejected
(
value
)
{
try
{
step
(
generator
[
"
throw
"
](
value
));
}
catch
(
e
)
{
reject
(
e
);
}
}
function
step
(
result
)
{
result
.
done
?
resolve
(
result
.
value
)
:
adopt
(
result
.
value
).
then
(
fulfilled
,
rejected
);
}
step
((
generator
=
generator
.
apply
(
thisArg
,
_arguments
||
[])).
next
());
});
};
var
__importDefault
=
(
this
&&
this
.
__importDefault
)
||
function
(
mod
)
{
return
(
mod
&&
mod
.
__esModule
)
?
mod
:
{
"
default
"
:
mod
};
};
...
...
@@ -19,71 +10,67 @@ const shared_1 = require("@vue/shared");
const
uni_cli_shared_1
=
require
(
"
@dcloudio/uni-cli-shared
"
);
const
utils_1
=
require
(
"
../utils
"
);
const
debugHmr
=
debug_1
.
default
(
'
vite:uni:hmr
'
);
function
invalidate
(
file
,
moduleGraph
)
{
return
__awaiter
(
this
,
void
0
,
void
0
,
function
*
()
{
const
mods
=
yield
moduleGraph
.
getModulesByFile
(
uni_cli_shared_1
.
normalizePath
(
file
));
if
(
mods
&&
mods
.
size
)
{
;
[...
mods
].
forEach
((
mod
)
=>
{
debugHmr
(
'
invalidate
'
,
mod
.
id
);
moduleGraph
.
invalidateModule
(
mod
);
});
}
});
async
function
invalidate
(
file
,
moduleGraph
)
{
const
mods
=
await
moduleGraph
.
getModulesByFile
(
uni_cli_shared_1
.
normalizePath
(
file
));
if
(
mods
&&
mods
.
size
)
{
;
[...
mods
].
forEach
((
mod
)
=>
{
debugHmr
(
'
invalidate
'
,
mod
.
id
);
moduleGraph
.
invalidateModule
(
mod
);
});
}
}
let
invalidateFiles
;
function
createHandleHotUpdate
()
{
return
function
({
file
,
server
})
{
return
__awaiter
(
this
,
void
0
,
void
0
,
function
*
()
{
const
inputDir
=
process
.
env
.
UNI_INPUT_DIR
;
const
platform
=
process
.
env
.
UNI_PLATFORM
;
if
(
!
invalidateFiles
)
{
invalidateFiles
=
[
path_1
.
default
.
resolve
(
inputDir
,
'
pages.json.js
'
),
path_1
.
default
.
resolve
(
inputDir
,
'
manifest.json.js
'
),
require
.
resolve
(
'
@dcloudio/uni-h5/dist/uni-h5.es.js
'
),
];
try
{
invalidateFiles
.
push
(
require
.
resolve
(
'
vite/dist/client/env.mjs
'
));
}
catch
(
e
)
{
}
}
// TODO 目前简单处理,当pages.json,manifest.json发生变化,就直接刷新,理想情况下,应该区分变化的内容,仅必要时做整页面刷新
const
isPagesJson
=
file
.
endsWith
(
'
pages.json
'
);
const
isManifestJson
=
file
.
endsWith
(
'
manifest.json
'
);
if
(
!
isPagesJson
&&
!
isManifestJson
)
{
return
;
}
debugHmr
(
file
);
const
pagesJson
=
uni_cli_shared_1
.
parsePagesJson
(
inputDir
,
platform
);
// 更新define
const
{
define
,
server
:
{
middlewareMode
},
}
=
server
.
config
;
shared_1
.
extend
(
define
,
utils_1
.
initFeatures
({
inputDir
,
command
:
'
serve
'
,
platform
,
pagesJson
,
manifestJson
:
uni_cli_shared_1
.
parseManifestJson
(
inputDir
),
ssr
:
!!
middlewareMode
,
}));
debugHmr
(
'
define
'
,
define
);
if
(
isPagesJson
)
{
const
easycom
=
pagesJson
.
easycom
||
{};
const
{
options
,
refresh
}
=
uni_cli_shared_1
.
initEasycomsOnce
(
inputDir
,
platform
);
if
(
!
equal
({
autoscan
:
easycom
.
autoscan
,
custom
:
easycom
.
custom
},
{
autoscan
:
options
.
autoscan
,
custom
:
options
.
custom
}))
{
refresh
();
}
return
async
function
({
file
,
server
})
{
const
inputDir
=
process
.
env
.
UNI_INPUT_DIR
;
const
platform
=
process
.
env
.
UNI_PLATFORM
;
if
(
!
invalidateFiles
)
{
invalidateFiles
=
[
path_1
.
default
.
resolve
(
inputDir
,
'
pages.json.js
'
),
path_1
.
default
.
resolve
(
inputDir
,
'
manifest.json.js
'
),
require
.
resolve
(
'
@dcloudio/uni-h5/dist/uni-h5.es.js
'
),
];
try
{
invalidateFiles
.
push
(
require
.
resolve
(
'
vite/dist/client/env.mjs
'
));
}
// 当pages.json,manifest.json发生变化时,作废pages.json.js缓存
for
(
const
file
of
invalidateFiles
)
{
yield
invalidate
(
file
,
server
.
moduleGraph
);
catch
(
e
)
{
}
}
// TODO 目前简单处理,当pages.json,manifest.json发生变化,就直接刷新,理想情况下,应该区分变化的内容,仅必要时做整页面刷新
const
isPagesJson
=
file
.
endsWith
(
'
pages.json
'
);
const
isManifestJson
=
file
.
endsWith
(
'
manifest.json
'
);
if
(
!
isPagesJson
&&
!
isManifestJson
)
{
return
;
}
debugHmr
(
file
);
const
pagesJson
=
uni_cli_shared_1
.
parsePagesJson
(
inputDir
,
platform
);
// 更新define
const
{
define
,
server
:
{
middlewareMode
},
}
=
server
.
config
;
shared_1
.
extend
(
define
,
utils_1
.
initFeatures
({
inputDir
,
command
:
'
serve
'
,
platform
,
pagesJson
,
manifestJson
:
uni_cli_shared_1
.
parseManifestJson
(
inputDir
),
ssr
:
!!
middlewareMode
,
}));
debugHmr
(
'
define
'
,
define
);
if
(
isPagesJson
)
{
const
easycom
=
pagesJson
.
easycom
||
{};
const
{
options
,
refresh
}
=
uni_cli_shared_1
.
initEasycomsOnce
(
inputDir
,
platform
);
if
(
!
equal
({
autoscan
:
easycom
.
autoscan
,
custom
:
easycom
.
custom
},
{
autoscan
:
options
.
autoscan
,
custom
:
options
.
custom
}))
{
refresh
();
}
server
.
ws
.
send
({
type
:
'
full-reload
'
,
path
:
'
*
'
,
});
return
[];
}
// 当pages.json,manifest.json发生变化时,作废pages.json.js缓存
for
(
const
file
of
invalidateFiles
)
{
await
invalidate
(
file
,
server
.
moduleGraph
);
}
server
.
ws
.
send
({
type
:
'
full-reload
'
,
path
:
'
*
'
,
});
return
[];
};
}
exports
.
createHandleHotUpdate
=
createHandleHotUpdate
;
...
...
packages/uni-h5-vite/dist/index.js
浏览文件 @
96a868a4
...
...
@@ -24,24 +24,6 @@ const UniH5Plugin = {
transformEvent
:
{
tap
:
'
click
'
,
},
transformAssetUrls
:
{
base
:
'
/
'
,
tags
:
{
audio
:
[
'
src
'
],
video
:
[
'
src
'
,
'
poster
'
],
img
:
[
'
src
'
],
image
:
[
'
src
'
],
'
cover-image
'
:
[
'
src
'
],
// h5
'
v-uni-audio
'
:
[
'
src
'
],
'
v-uni-video
'
:
[
'
src
'
,
'
poster
'
],
'
v-uni-image
'
:
[
'
src
'
],
'
v-uni-cover-image
'
:
[
'
src
'
],
// nvue
'
u-image
'
:
[
'
src
'
],
'
u-video
'
:
[
'
src
'
,
'
poster
'
],
},
},
},
config
(
config
,
env
)
{
if
(
uni_cli_shared_1
.
isInHBuilderX
())
{
...
...
packages/uni-h5-vite/dist/plugins/cssScoped.js
浏览文件 @
96a868a4
"
use strict
"
;
var
__awaiter
=
(
this
&&
this
.
__awaiter
)
||
function
(
thisArg
,
_arguments
,
P
,
generator
)
{
function
adopt
(
value
)
{
return
value
instanceof
P
?
value
:
new
P
(
function
(
resolve
)
{
resolve
(
value
);
});
}
return
new
(
P
||
(
P
=
Promise
))(
function
(
resolve
,
reject
)
{
function
fulfilled
(
value
)
{
try
{
step
(
generator
.
next
(
value
));
}
catch
(
e
)
{
reject
(
e
);
}
}
function
rejected
(
value
)
{
try
{
step
(
generator
[
"
throw
"
](
value
));
}
catch
(
e
)
{
reject
(
e
);
}
}
function
step
(
result
)
{
result
.
done
?
resolve
(
result
.
value
)
:
adopt
(
result
.
value
).
then
(
fulfilled
,
rejected
);
}
step
((
generator
=
generator
.
apply
(
thisArg
,
_arguments
||
[])).
next
());
});
};
var
__importDefault
=
(
this
&&
this
.
__importDefault
)
||
function
(
mod
)
{
return
(
mod
&&
mod
.
__esModule
)
?
mod
:
{
"
default
"
:
mod
};
};
...
...
@@ -53,10 +44,10 @@ function uniCssScopedPlugin() {
}
debugScoped
(
'
hmr
'
,
ctx
.
file
);
const
oldRead
=
ctx
.
read
;
ctx
.
read
=
()
=>
__awaiter
(
this
,
void
0
,
void
0
,
function
*
()
{
const
code
=
yield
oldRead
();
ctx
.
read
=
async
()
=>
{
const
code
=
await
oldRead
();
return
addScoped
(
code
);
}
)
;
};
},
};
}
...
...
packages/uni-h5-vite/dist/plugins/manifestJson.js
浏览文件 @
96a868a4
...
...
@@ -26,11 +26,11 @@ function uniManifestJsonPlugin() {
const
manifest
=
uni_cli_shared_1
.
parseJson
(
code
);
const
{
debug
,
h5
}
=
manifest
;
const
appid
=
(
manifest
.
appid
||
''
).
replace
(
'
__UNI__
'
,
''
);
const
router
=
Object
.
assign
(
Object
.
assign
({},
defaultRouter
),
((
h5
&&
h5
.
router
)
||
{}))
;
const
router
=
{
...
defaultRouter
,
...((
h5
&&
h5
.
router
)
||
{})
}
;
if
(
!
router
.
base
)
{
router
.
base
=
'
/
'
;
}
const
async
=
Object
.
assign
(
Object
.
assign
({},
defaultAsync
),
((
h5
&&
h5
.
async
)
||
{}))
;
const
async
=
{
...
defaultAsync
,
...((
h5
&&
h5
.
async
)
||
{})
}
;
const
networkTimeout
=
uni_cli_shared_1
.
normalizeNetworkTimeout
(
manifest
.
networkTimeout
);
const
sdkConfigs
=
(
h5
&&
h5
.
sdkConfigs
)
||
{};
const
qqMapKey
=
(
sdkConfigs
.
maps
&&
...
...
packages/uni-h5-vite/dist/transformIndexHtml/index.js
浏览文件 @
96a868a4
"
use strict
"
;
var
__awaiter
=
(
this
&&
this
.
__awaiter
)
||
function
(
thisArg
,
_arguments
,
P
,
generator
)
{
function
adopt
(
value
)
{
return
value
instanceof
P
?
value
:
new
P
(
function
(
resolve
)
{
resolve
(
value
);
});
}
return
new
(
P
||
(
P
=
Promise
))(
function
(
resolve
,
reject
)
{
function
fulfilled
(
value
)
{
try
{
step
(
generator
.
next
(
value
));
}
catch
(
e
)
{
reject
(
e
);
}
}
function
rejected
(
value
)
{
try
{
step
(
generator
[
"
throw
"
](
value
));
}
catch
(
e
)
{
reject
(
e
);
}
}
function
step
(
result
)
{
result
.
done
?
resolve
(
result
.
value
)
:
adopt
(
result
.
value
).
then
(
fulfilled
,
rejected
);
}
step
((
generator
=
generator
.
apply
(
thisArg
,
_arguments
||
[])).
next
());
});
};
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
exports
.
createTransformIndexHtml
=
void
0
;
const
dist_1
=
require
(
"
../../../uni-cli-shared/dist
"
);
function
createTransformIndexHtml
()
{
return
function
(
html
)
{
return
async
function
(
html
)
{
var
_a
;
return
__awaiter
(
this
,
void
0
,
void
0
,
function
*
()
{
const
manifestJson
=
dist_1
.
parseManifestJsonOnce
(
process
.
env
.
UNI_INPUT_DIR
);
const
title
=
((
_a
=
manifestJson
.
h5
)
===
null
||
_a
===
void
0
?
void
0
:
_a
.
title
)
||
manifestJson
.
name
||
''
;
return
html
.
replace
(
/<title>
(
.*
?)
<
\/
title>/
,
`<title>
${
title
}
</title>`
);
});
const
manifestJson
=
dist_1
.
parseManifestJsonOnce
(
process
.
env
.
UNI_INPUT_DIR
);
const
title
=
((
_a
=
manifestJson
.
h5
)
===
null
||
_a
===
void
0
?
void
0
:
_a
.
title
)
||
manifestJson
.
name
||
''
;
return
html
.
replace
(
/<title>
(
.*
?)
<
\/
title>/
,
`<title>
${
title
}
</title>`
);
};
}
exports
.
createTransformIndexHtml
=
createTransformIndexHtml
;
packages/uni-h5-vite/src/index.ts
浏览文件 @
96a868a4
...
...
@@ -21,24 +21,6 @@ const UniH5Plugin: UniVitePlugin = {
transformEvent
:
{
tap
:
'
click
'
,
},
transformAssetUrls
:
{
base
:
'
/
'
,
tags
:
{
audio
:
[
'
src
'
],
video
:
[
'
src
'
,
'
poster
'
],
img
:
[
'
src
'
],
image
:
[
'
src
'
],
'
cover-image
'
:
[
'
src
'
],
// h5
'
v-uni-audio
'
:
[
'
src
'
],
'
v-uni-video
'
:
[
'
src
'
,
'
poster
'
],
'
v-uni-image
'
:
[
'
src
'
],
'
v-uni-cover-image
'
:
[
'
src
'
],
// nvue
'
u-image
'
:
[
'
src
'
],
'
u-video
'
:
[
'
src
'
,
'
poster
'
],
},
},
},
config
(
config
,
env
)
{
if
(
isInHBuilderX
())
{
...
...
packages/uni-vue/src/componentOptions.ts
浏览文件 @
96a868a4
...
...
@@ -29,7 +29,11 @@ export function applyOptions(
}
})
if
(
__PLATFORM__
===
'
app
'
&&
mpType
===
'
page
'
)
{
invokeHook
(
publicThis
,
ON_LOAD
,
instance
.
attrs
.
__pageQuery
)
invokeHook
(
publicThis
,
ON_SHOW
)
try
{
invokeHook
(
publicThis
,
ON_LOAD
,
instance
.
attrs
.
__pageQuery
)
invokeHook
(
publicThis
,
ON_SHOW
)
}
catch
(
e
)
{
console
.
error
(
e
.
message
+
'
\n
'
+
e
.
stack
)
}
}
}
packages/vite-plugin-uni/src/vue/options.ts
浏览文件 @
96a868a4
...
...
@@ -14,6 +14,29 @@ import { transformMatchMedia } from './transforms/transformMatchMedia'
import
{
createTransformEvent
}
from
'
./transforms/transformEvent
'
// import { transformContext } from './transforms/transformContext'
function
createUniVueTransformAssetUrls
(
base
:
string
):
SFCTemplateCompileOptions
[
'
transformAssetUrls
'
]
{
return
{
base
,
tags
:
{
audio
:
[
'
src
'
],
video
:
[
'
src
'
,
'
poster
'
],
img
:
[
'
src
'
],
image
:
[
'
src
'
],
'
cover-image
'
:
[
'
src
'
],
// h5
'
v-uni-audio
'
:
[
'
src
'
],
'
v-uni-video
'
:
[
'
src
'
,
'
poster
'
],
'
v-uni-image
'
:
[
'
src
'
],
'
v-uni-cover-image
'
:
[
'
src
'
],
// nvue
'
u-image
'
:
[
'
src
'
],
'
u-video
'
:
[
'
src
'
,
'
poster
'
],
},
}
}
export
function
initPluginVueOptions
(
options
:
VitePluginUniResolvedOptions
,
UniVitePlugins
:
UniVitePlugin
[]
...
...
@@ -29,15 +52,18 @@ export function initPluginVueOptions(
const
templateOptions
=
vueOptions
.
template
||
(
vueOptions
.
template
=
{})
let
transformAssetUrls
:
SFCTemplateCompileOptions
[
'
transformAssetUrls
'
]
templateOptions
.
transformAssetUrls
=
createUniVueTransformAssetUrls
(
options
.
base
)
let
isCompilerNativeTag
:
ParserOptions
[
'
isNativeTag
'
]
=
isNativeTag
let
isCompilerCustomElement
:
ParserOptions
[
'
isCustomElement
'
]
=
isCustomElement
let
directiveTransforms
:
CompilerOptions
[
'
directiveTransforms
'
]
UniVitePlugins
.
forEach
((
{
uni
}
)
=>
{
const
compilerOptions
=
uni
?.
compilerOptions
UniVitePlugins
.
forEach
((
plugin
)
=>
{
const
compilerOptions
=
plugin
.
uni
?.
compilerOptions
if
(
compilerOptions
)
{
if
(
compilerOptions
.
isNativeTag
)
{
isCompilerNativeTag
=
compilerOptions
.
isNativeTag
...
...
@@ -48,21 +74,14 @@ export function initPluginVueOptions(
if
(
compilerOptions
.
directiveTransforms
)
{
directiveTransforms
=
compilerOptions
.
directiveTransforms
}
if
(
uni
!
.
transformAssetUrls
)
{
transformAssetUrls
=
uni
!
.
transformAssetUrls
}
}
})
const
compilerOptions
=
templateOptions
.
compilerOptions
||
(
templateOptions
.
compilerOptions
=
{})
compilerOptions
.
isNativeTag
=
isCompilerNativeTag
if
(
!
compilerOptions
.
nodeTransforms
)
{
compilerOptions
.
nodeTransforms
=
[]
}
if
(
transformAssetUrls
)
{
templateOptions
.
transformAssetUrls
=
transformAssetUrls
}
const
compatConfig
=
parseCompatConfigOnce
(
options
.
inputDir
)
...
...
tsconfig.node.json
浏览文件 @
96a868a4
{
"compilerOptions"
:
{
"target"
:
"es201
5
"
,
"target"
:
"es201
8
"
,
"moduleResolution"
:
"node"
,
"strict"
:
true
,
"declaration"
:
false
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录