Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
f7461421
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看板
提交
f7461421
编写于
3月 29, 2024
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: build
上级
565fdac5
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
1195 addition
and
103 deletion
+1195
-103
packages/uni-app-plus/dist/style.css
packages/uni-app-plus/dist/style.css
+1
-1
packages/uni-app-plus/dist/uni.x.runtime.esm.js
packages/uni-app-plus/dist/uni.x.runtime.esm.js
+101
-80
packages/uni-h5/dist-x/uni-h5.cjs.js
packages/uni-h5/dist-x/uni-h5.cjs.js
+535
-0
packages/uni-h5/dist-x/uni-h5.es.js
packages/uni-h5/dist-x/uni-h5.es.js
+557
-22
packages/uts/src/types.ts
packages/uts/src/types.ts
+1
-0
未找到文件。
packages/uni-app-plus/dist/style.css
浏览文件 @
f7461421
此差异已折叠。
点击以展开。
packages/uni-app-plus/dist/uni.x.runtime.esm.js
浏览文件 @
f7461421
import
{
normalizeStyles
,
addLeadingSlash
,
invokeArrayFns
,
LINEFEED
,
SCHEME_RE
,
DATA_RE
,
cacheStringFunction
,
parseQuery
,
Emitter
,
ON_UNHANDLE_REJECTION
,
ON_PAGE_NOT_FOUND
,
ON_ERROR
,
ON_SHOW
,
ON_HIDE
,
removeLeadingSlash
,
getLen
,
EventChannel
,
once
,
ON_UNLOAD
,
ON_READY
,
ON_PULL_DOWN_REFRESH
,
ON_REACH_BOTTOM
,
ON_RESIZE
,
parseUrl
,
ON_BACK_PRESS
,
ON_LAUNCH
}
from
"
@dcloudio/uni-shared
"
;
import
{
extend
,
isString
,
isPlainObject
,
isFunction
as
isFunction$1
,
isArray
,
isPromise
,
hasOwn
,
remove
,
capitalize
,
toTypeString
,
toRawType
,
parseStringStyle
}
from
"
@vue/shared
"
;
import
{
createVNode
,
render
,
injectHook
,
getCurrentInstance
,
defineComponent
,
warn
,
isInSSRComponentSetup
,
ref
,
watchEffect
,
computed
,
onMounted
,
camelize
,
onUnmounted
,
reactive
,
watch
,
nextTick
}
from
"
vue
"
;
import
{
createVNode
,
render
,
injectHook
,
getCurrentInstance
,
defineComponent
,
warn
,
isInSSRComponentSetup
,
ref
,
watchEffect
,
watch
,
computed
,
onMounted
,
camelize
,
onUnmounted
,
reactive
,
nextTick
}
from
"
vue
"
;
var
_wks
=
{
exports
:
{}
};
var
_shared
=
{
exports
:
{}
};
var
_core
=
{
exports
:
{}
};
...
...
@@ -1641,7 +1641,7 @@ function initScope(pageId, vm, pageInstance) {
{
Object
.
defineProperty
(
vm
,
"
$viewToTempFilePath
"
,
{
get
()
{
return
vm
.
$nativePage
.
viewToTempFilePath
;
return
vm
.
$nativePage
.
viewToTempFilePath
.
bind
(
vm
.
$nativePage
)
;
}
});
}
...
...
@@ -1680,38 +1680,6 @@ function getPageManager() {
}
var
ON_BACK_BUTTON
=
"
onBackButton
"
;
var
ON_POP_GESTURE
=
"
onPopGesture
"
;
function
loadFontFaceByStyles
(
styles2
,
global2
)
{
styles2
=
Array
.
isArray
(
styles2
)
?
styles2
:
[
styles2
];
var
fontFaceStyle
=
[];
styles2
.
forEach
((
style
)
=>
{
if
(
style
[
"
@FONT-FACE
"
])
{
fontFaceStyle
.
push
(...
style
[
"
@FONT-FACE
"
]);
}
});
if
(
fontFaceStyle
.
length
===
0
)
return
;
fontFaceStyle
.
forEach
((
style
)
=>
{
var
fontFamily
=
style
[
"
fontFamily
"
];
var
fontWeight
=
style
[
"
fontWeight
"
];
var
fontStyle
=
style
[
"
fontStyle
"
];
var
fontVariant
=
style
[
"
fontVariant
"
];
var
src
=
style
[
"
src
"
];
if
(
fontFamily
!=
null
&&
src
!=
null
)
{
loadFontFace
({
global
:
global2
,
family
:
fontFamily
,
source
:
src
,
desc
:
{
style
:
fontStyle
,
weight
:
fontWeight
,
variant
:
fontVariant
}
});
}
else
{
console
.
warn
(
"
loadFontFace: fail, font-family or src is null
"
);
}
});
}
function
parsePageStyle
(
route
)
{
var
style
=
/* @__PURE__ */
new
Map
();
var
routeMeta
=
route
.
meta
;
...
...
@@ -1730,7 +1698,7 @@ function parsePageStyle(route) {
});
if
(
Object
.
keys
(
navigationBar
).
length
)
{
style
.
set
(
"
navigationBar
"
,
navigationBar
);
if
(
navigationBar
.
navigationBarTextStyle
!==
"
custom
"
&&
!
routeMeta
.
isQuit
)
{
if
(
navigationBar
.
navigationBarTextStyle
!==
"
custom
"
&&
!
routeMeta
.
isQuit
&&
routeMeta
.
route
!==
__uniConfig
.
realEntryPagePath
)
{
navigationBar
[
"
navigationBarAutoBackButton
"
]
=
true
;
}
}
...
...
@@ -1746,6 +1714,7 @@ function registerPage(_ref, onCreated) {
nvuePageVm
,
eventChannel
}
=
_ref
;
var
delay
=
arguments
.
length
>
2
&&
arguments
[
2
]
!==
void
0
?
arguments
[
2
]
:
0
;
var
id2
=
genWebviewId
();
var
routeOptions
=
initRouteOptions
(
path
,
openType
);
var
pageStyle
=
parsePageStyle
(
routeOptions
);
...
...
@@ -1764,38 +1733,41 @@ function registerPage(_ref, onCreated) {
// TODO ThemeMode
"
light
"
);
var
page
=
createVuePage
(
id2
,
route
,
query
,
pageInstance
,
{},
nativePage
);
nativePage
.
addPageEventListener
(
ON_SHOW
,
(
_
)
=>
{
invokeHook
(
page
,
ON_SHOW
);
});
nativePage
.
addPageEventListener
(
ON_POP_GESTURE
,
function
(
e
)
{
uni
.
navigateBack
({
from
:
"
popGesture
"
,
fail
(
e2
)
{
if
(
e2
.
errMsg
.
endsWith
(
"
cancel
"
))
{
nativePage
.
show
();
function
fn
()
{
var
page
=
createVuePage
(
id2
,
route
,
query
,
pageInstance
,
{},
nativePage
);
nativePage
.
addPageEventListener
(
ON_SHOW
,
(
_
)
=>
{
invokeHook
(
page
,
ON_SHOW
);
});
nativePage
.
addPageEventListener
(
ON_POP_GESTURE
,
function
(
e
)
{
uni
.
navigateBack
({
from
:
"
popGesture
"
,
fail
(
e2
)
{
if
(
e2
.
errMsg
.
endsWith
(
"
cancel
"
))
{
nativePage
.
show
();
}
}
}
}
);
});
});
nativePage
.
addPageEventListener
(
ON_UNLOAD
,
(
_
)
=>
{
invokeHook
(
page
,
ON_UNLOAD
);
});
nativePage
.
addPageEventListener
(
ON_READY
,
(
_
)
=>
{
invokeHook
(
page
,
ON_READY
);
});
nativePage
.
addPageEventListener
(
ON_PULL_DOWN_REFRESH
,
(
_
)
=>
{
invokeHook
(
page
,
ON_PULL_DOWN_REFRESH
);
});
nativePage
.
addPageEventListener
(
ON_REACH_BOTTOM
,
(
_
)
=>
{
invokeHook
(
page
,
ON_REACH_BOTTOM
);
});
nativePage
.
addPageEventListener
(
ON_RESIZE
,
(
_
)
=>
{
invokeHook
(
page
,
ON_RESIZE
);
});
var
pageCSSStyle
=
page
.
$options
.
styles
;
if
(
pageCSSStyle
)
{
loadFontFaceByStyles
(
pageCSSStyle
,
false
);
nativePage
.
addPageEventListener
(
ON_UNLOAD
,
(
_
)
=>
{
invokeHook
(
page
,
ON_UNLOAD
);
});
nativePage
.
addPageEventListener
(
ON_READY
,
(
_
)
=>
{
invokeHook
(
page
,
ON_READY
);
});
nativePage
.
addPageEventListener
(
ON_PULL_DOWN_REFRESH
,
(
_
)
=>
{
invokeHook
(
page
,
ON_PULL_DOWN_REFRESH
);
});
nativePage
.
addPageEventListener
(
ON_REACH_BOTTOM
,
(
_
)
=>
{
invokeHook
(
page
,
ON_REACH_BOTTOM
);
});
nativePage
.
addPageEventListener
(
ON_RESIZE
,
(
_
)
=>
{
invokeHook
(
page
,
ON_RESIZE
);
});
}
if
(
delay
)
{
setTimeout
(
fn
,
delay
);
}
else
{
fn
();
}
return
nativePage
;
}
...
...
@@ -1873,13 +1845,18 @@ function _navigateTo(_ref2) {
setStatusBarStyle
();
});
}
var
page
=
registerPage
({
url
,
path
,
query
,
openType
:
"
navigateTo
"
,
eventChannel
},
noAnimation
?
void
0
:
callback
);
var
page
=
registerPage
(
{
url
,
path
,
query
,
openType
:
"
navigateTo
"
,
eventChannel
},
noAnimation
?
void
0
:
callback
,
// 有动画时延迟创建 vm
noAnimation
?
0
:
1
);
if
(
noAnimation
)
{
callback
(
page
);
}
...
...
@@ -3231,6 +3208,38 @@ function initGlobalEvent(app) {
return
true
;
});
}
function
loadFontFaceByStyles
(
styles2
,
global2
)
{
styles2
=
Array
.
isArray
(
styles2
)
?
styles2
:
[
styles2
];
var
fontFaceStyle
=
[];
styles2
.
forEach
((
style
)
=>
{
if
(
style
[
"
@FONT-FACE
"
])
{
fontFaceStyle
.
push
(...
style
[
"
@FONT-FACE
"
]);
}
});
if
(
fontFaceStyle
.
length
===
0
)
return
;
fontFaceStyle
.
forEach
((
style
)
=>
{
var
fontFamily
=
style
[
"
fontFamily
"
];
var
fontWeight
=
style
[
"
fontWeight
"
];
var
fontStyle
=
style
[
"
fontStyle
"
];
var
fontVariant
=
style
[
"
fontVariant
"
];
var
src
=
style
[
"
src
"
];
if
(
fontFamily
!=
null
&&
src
!=
null
)
{
loadFontFace
({
global
:
global2
,
family
:
fontFamily
,
source
:
src
,
desc
:
{
style
:
fontStyle
,
weight
:
fontWeight
,
variant
:
fontVariant
}
});
}
else
{
console
.
warn
(
"
loadFontFace: fail, font-family or src is null
"
);
}
});
}
function
initAppLaunch
(
appVm
)
{
injectAppHooks
(
appVm
.
$
);
var
{
...
...
@@ -3369,14 +3378,22 @@ function initEntryPagePath(app) {
var
url
=
debugInfo
.
get
(
"
url
"
);
if
(
url
&&
url
!=
__uniConfig
.
entryPagePath
)
{
__uniConfig
.
realEntryPagePath
=
__uniConfig
.
entryPagePath
;
__uniConfig
.
entryPagePath
=
url
;
var
[
path
,
query
]
=
url
.
split
(
"
?
"
);
__uniConfig
.
entryPagePath
=
path
;
if
(
query
)
{
__uniConfig
.
entryPageQuery
=
"
?
"
.
concat
(
query
);
}
return
;
}
}
if
(
__uniConfig
.
conditionUrl
)
{
__uniConfig
.
realEntryPagePath
=
__uniConfig
.
entryPagePath
;
var
conditionUrl
=
__uniConfig
.
conditionUrl
;
__uniConfig
.
entryPagePath
=
conditionUrl
;
var
[
_path
,
_query
]
=
conditionUrl
.
split
(
"
?
"
);
__uniConfig
.
entryPagePath
=
_path
;
if
(
_query
)
{
__uniConfig
.
entryPageQuery
=
"
?
"
.
concat
(
_query
);
}
}
}
function
converPx
(
value
)
{
...
...
@@ -3639,6 +3656,16 @@ const checkbox = /* @__PURE__ */ defineBuiltInComponent({
watchEffect
(()
=>
{
checkboxChecked
.
value
=
props
.
checked
;
});
watch
(()
=>
checkboxChecked
.
value
,
(
val
)
=>
{
var
ctx2
=
instance
===
null
||
instance
===
void
0
?
void
0
:
instance
.
proxy
;
if
(
!
ctx2
)
return
;
$dispatch
(
ctx2
,
"
CheckboxGroup
"
,
"
_changeHandler
"
,
{
name
:
checkboxValue
.
value
,
checked
:
checkboxChecked
.
value
,
setCheckboxChecked
});
});
watchEffect
(()
=>
{
checkboxValue
.
value
=
props
.
value
.
toString
();
});
...
...
@@ -3700,12 +3727,6 @@ const checkbox = /* @__PURE__ */ defineBuiltInComponent({
return
;
emit
(
"
click
"
,
$event
);
checkboxChecked
.
value
=
!
checkboxChecked
.
value
;
var
ctx2
=
instance
===
null
||
instance
===
void
0
?
void
0
:
instance
.
proxy
;
$dispatch
(
ctx2
,
"
CheckboxGroup
"
,
"
_changeHandler
"
,
{
name
:
checkboxValue
.
value
,
checked
:
checkboxChecked
.
value
,
setCheckboxChecked
});
};
return
()
=>
{
var
_slots$default
;
...
...
packages/uni-h5/dist-x/uni-h5.cjs.js
浏览文件 @
f7461421
...
...
@@ -11,6 +11,541 @@ const shared = require("@vue/shared");
const
uniShared
=
require
(
"
@dcloudio/uni-shared
"
);
const
uniI18n
=
require
(
"
@dcloudio/uni-i18n
"
);
const
vueRouter
=
require
(
"
vue-router
"
);
function
arrayPop
(
array
)
{
if
(
array
.
length
===
0
)
{
return
null
;
}
return
array
.
pop
();
}
function
arrayShift
(
array
)
{
if
(
array
.
length
===
0
)
{
return
null
;
}
return
array
.
shift
();
}
function
arrayFind
(
array
,
predicate
)
{
const
index2
=
array
.
findIndex
(
predicate
);
if
(
index2
<
0
)
{
return
null
;
}
return
array
[
index2
];
}
function
arrayFindLast
(
array
,
predicate
)
{
const
index2
=
array
.
findLastIndex
(
predicate
);
if
(
index2
<
0
)
{
return
null
;
}
return
array
[
index2
];
}
function
arrayAt
(
array
,
index2
)
{
if
(
index2
<
-
array
.
length
||
index2
>=
array
.
length
)
{
return
null
;
}
return
array
.
at
(
index2
);
}
var
IDENTIFIER
;
(
function
(
IDENTIFIER2
)
{
IDENTIFIER2
[
"
UTSJSONObject
"
]
=
"
UTSJSONObject
"
;
IDENTIFIER2
[
"
JSON
"
]
=
"
JSON
"
;
IDENTIFIER2
[
"
UTS
"
]
=
"
UTS
"
;
IDENTIFIER2
[
"
DEFINE_COMPONENT
"
]
=
"
defineComponent
"
;
IDENTIFIER2
[
"
VUE
"
]
=
"
vue
"
;
IDENTIFIER2
[
"
GLOBAL_THIS
"
]
=
"
globalThis
"
;
IDENTIFIER2
[
"
UTS_TYPE
"
]
=
"
UTSType
"
;
IDENTIFIER2
[
"
UTS_METADATA
"
]
=
"
$UTSMetadata$
"
;
IDENTIFIER2
[
"
TEMP_UTS_METADATA
"
]
=
"
$TempUTSMetadata$
"
;
IDENTIFIER2
[
"
JSON_FIELD
"
]
=
"
JSON_FIELD
"
;
})(
IDENTIFIER
||
(
IDENTIFIER
=
{}));
var
UTS_CLASS_METADATA_KIND
;
(
function
(
UTS_CLASS_METADATA_KIND2
)
{
UTS_CLASS_METADATA_KIND2
[
UTS_CLASS_METADATA_KIND2
[
"
CLASS
"
]
=
0
]
=
"
CLASS
"
;
UTS_CLASS_METADATA_KIND2
[
UTS_CLASS_METADATA_KIND2
[
"
INTERFACE
"
]
=
1
]
=
"
INTERFACE
"
;
UTS_CLASS_METADATA_KIND2
[
UTS_CLASS_METADATA_KIND2
[
"
TYPE
"
]
=
2
]
=
"
TYPE
"
;
})(
UTS_CLASS_METADATA_KIND
||
(
UTS_CLASS_METADATA_KIND
=
{}));
function
getType$1
(
val
)
{
return
Object
.
prototype
.
toString
.
call
(
val
).
slice
(
8
,
-
1
).
toLowerCase
();
}
function
isPlainObject
(
val
)
{
if
(
val
==
null
||
typeof
val
!==
"
object
"
)
{
return
false
;
}
const
proto
=
Object
.
getPrototypeOf
(
val
);
return
proto
===
Object
.
prototype
||
proto
===
null
;
}
class
UTSError
extends
Error
{
constructor
(
message
)
{
super
(
message
);
}
}
function
isUTSMetadata
(
metadata
)
{
return
!!
(
metadata
&&
metadata
.
kind
in
UTS_CLASS_METADATA_KIND
&&
metadata
.
interfaces
);
}
function
isNativeType
(
proto
)
{
return
!
proto
||
proto
===
Object
.
prototype
;
}
const
utsMetadataKey
=
IDENTIFIER
.
UTS_METADATA
;
function
getParentTypeList
(
type
)
{
const
metadata
=
utsMetadataKey
in
type
?
type
[
utsMetadataKey
]
:
{};
let
interfaces
=
[];
if
(
!
isUTSMetadata
(
metadata
))
{
interfaces
=
[];
}
else
{
interfaces
=
metadata
.
interfaces
||
[];
}
const
proto
=
Object
.
getPrototypeOf
(
type
);
if
(
!
isNativeType
(
proto
))
{
interfaces
.
push
(
proto
.
constructor
);
}
return
interfaces
;
}
function
isImplementationOf
(
leftType
,
rightType
,
visited
=
[])
{
if
(
isNativeType
(
leftType
))
{
return
false
;
}
if
(
leftType
===
rightType
)
{
return
true
;
}
visited
.
push
(
leftType
);
const
parentTypeList
=
getParentTypeList
(
leftType
);
return
parentTypeList
.
some
((
parentType
)
=>
{
if
(
visited
.
includes
(
parentType
))
{
return
false
;
}
return
isImplementationOf
(
parentType
,
rightType
,
visited
);
});
}
function
isInstanceOf
(
value
,
type
)
{
const
isNativeInstanceofType
=
value
instanceof
type
;
if
(
isNativeInstanceofType
||
typeof
value
!==
"
object
"
)
{
return
isNativeInstanceofType
;
}
const
proto
=
Object
.
getPrototypeOf
(
value
).
constructor
;
return
isImplementationOf
(
proto
,
type
);
}
function
isBaseType
(
type
)
{
return
type
===
Number
||
type
===
String
||
type
===
Boolean
;
}
function
isUnknownType
(
type
)
{
return
type
===
"
Unknown
"
;
}
function
isAnyType
(
type
)
{
return
type
===
"
Any
"
;
}
function
isUTSType
(
type
)
{
return
type
&&
type
.
prototype
&&
type
.
prototype
instanceof
UTSType
;
}
class
UTSType
{
static
get
$UTSMetadata$
(...
args
)
{
return
{
kind
:
UTS_CLASS_METADATA_KIND
.
TYPE
,
interfaces
:
[],
fields
:
{}
};
}
get
$UTSMetadata$
()
{
return
UTSType
.
get
$UTSMetadata$
();
}
// TODO 缓存withGenerics结果
static
withGenerics
(
parent
,
generics
,
isJSONParse
=
false
)
{
if
(
isJSONParse
)
{
const
illegalGeneric
=
generics
.
find
((
item
)
=>
!
(
item
===
Array
||
isBaseType
(
item
)
||
isUnknownType
(
item
)
||
isAnyType
(
item
)
||
item
===
UTSJSONObject
||
item
.
prototype
&&
item
.
prototype
instanceof
UTSType
));
if
(
illegalGeneric
)
{
throw
new
Error
(
"
Generic is not UTSType or Array or UTSJSONObject or base type, generic:
"
+
illegalGeneric
);
}
}
if
(
parent
===
Array
)
{
return
class
UTSArray
extends
UTSType
{
constructor
(
options
,
isJSONParse2
=
false
)
{
if
(
!
Array
.
isArray
(
options
))
{
throw
new
UTSError
(
`Failed to contruct type,
${
options
}
is not an array`
);
}
super
();
return
options
.
map
((
item
)
=>
{
return
item
==
null
?
null
:
isBaseType
(
generics
[
0
])
||
isUnknownType
(
generics
[
0
])
||
isAnyType
(
generics
[
0
])
?
item
:
generics
[
0
]
===
Array
?
new
Array
(...
item
)
:
new
generics
[
0
](
item
,
void
0
,
isJSONParse2
);
});
}
};
}
else
if
(
isUTSType
(
parent
))
{
return
class
VirtualClassWithGenerics
extends
parent
{
static
get
$UTSMetadata$
()
{
return
parent
.
get
$UTSMetadata$
(...
generics
);
}
constructor
(
options
,
metadata
=
VirtualClassWithGenerics
.
get
$UTSMetadata$
(),
isJSONParse2
=
false
)
{
super
(
options
,
metadata
,
isJSONParse2
);
}
};
}
else
{
return
parent
;
}
}
constructor
()
{
}
static
initProps
(
options
,
metadata
,
isJSONParse
=
false
)
{
const
obj
=
{};
if
(
!
metadata
.
fields
)
{
return
obj
;
}
for
(
const
key
in
metadata
.
fields
)
{
const
{
type
,
optional
,
jsonField
}
=
metadata
.
fields
[
key
];
const
realKey
=
isJSONParse
?
jsonField
||
key
:
key
;
if
(
options
[
realKey
]
==
null
)
{
if
(
optional
)
{
obj
[
key
]
=
null
;
continue
;
}
else
{
throw
new
UTSError
(
`Failed to contruct type, missing required property:
${
key
}
`
);
}
}
if
(
isUTSType
(
type
))
{
obj
[
key
]
=
new
type
(
options
[
realKey
],
void
0
,
isJSONParse
);
}
else
if
(
type
===
Array
)
{
if
(
!
Array
.
isArray
(
options
[
realKey
]))
{
throw
new
UTSError
(
`Failed to contruct type, property
${
key
}
is not an array`
);
}
obj
[
key
]
=
options
[
realKey
].
map
((
item
)
=>
{
return
item
==
null
?
null
:
item
;
});
}
else
{
obj
[
key
]
=
options
[
realKey
];
}
}
return
obj
;
}
}
const
OriginalJSON
=
JSON
;
function
parseObjectOrArray
(
object
,
utsType
)
{
const
objectType
=
getType$1
(
object
);
if
(
object
===
null
||
objectType
!==
"
object
"
&&
objectType
!==
"
array
"
)
{
return
object
;
}
if
(
utsType
||
utsType
===
UTSJSONObject
)
{
try
{
return
new
utsType
(
object
,
void
0
,
true
);
}
catch
(
error
)
{
console
.
error
(
error
);
return
null
;
}
}
if
(
objectType
===
"
array
"
)
{
return
object
.
map
((
value
)
=>
{
return
parseObjectOrArray
(
value
);
});
}
else
if
(
objectType
===
"
object
"
)
{
return
new
UTSJSONObject
(
object
);
}
return
object
;
}
const
UTSJSON
=
{
parse
:
(
text
,
reviver
,
utsType
)
=>
{
if
(
reviver
&&
(
isUTSType
(
reviver
)
||
reviver
===
UTSJSONObject
))
{
utsType
=
reviver
;
reviver
=
void
0
;
}
try
{
const
parseResult
=
OriginalJSON
.
parse
(
text
,
reviver
);
return
parseObjectOrArray
(
parseResult
,
utsType
);
}
catch
(
error
)
{
console
.
error
(
error
);
return
null
;
}
},
parseArray
(
text
,
utsType
)
{
try
{
const
parseResult
=
OriginalJSON
.
parse
(
text
);
if
(
Array
.
isArray
(
parseResult
))
{
return
parseObjectOrArray
(
parseResult
,
utsType
?
UTSType
.
withGenerics
(
Array
,
[
utsType
],
true
)
:
void
0
);
}
return
null
;
}
catch
(
error
)
{
console
.
error
(
error
);
return
null
;
}
},
parseObject
(
text
,
utsType
)
{
try
{
const
parseResult
=
OriginalJSON
.
parse
(
text
);
if
(
Array
.
isArray
(
parseResult
))
{
return
null
;
}
return
parseObjectOrArray
(
parseResult
,
utsType
);
}
catch
(
error
)
{
console
.
error
(
error
);
return
null
;
}
},
stringify
:
(
value
)
=>
{
return
OriginalJSON
.
stringify
(
value
);
}
};
function
mapGet
(
map
,
key
)
{
if
(
!
map
.
has
(
key
))
{
return
null
;
}
return
map
.
get
(
key
);
}
function
stringCodePointAt
(
str
,
pos
)
{
if
(
pos
<
0
||
pos
>=
str
.
length
)
{
return
null
;
}
return
str
.
codePointAt
(
pos
);
}
function
stringAt
(
str
,
pos
)
{
if
(
pos
<
-
str
.
length
||
pos
>=
str
.
length
)
{
return
null
;
}
return
str
.
at
(
pos
);
}
function
weakMapGet
(
map
,
key
)
{
if
(
!
map
.
has
(
key
))
{
return
null
;
}
return
map
.
get
(
key
);
}
const
UTS
=
{
arrayAt
,
arrayFind
,
arrayFindLast
,
arrayPop
,
arrayShift
,
isInstanceOf
,
UTSType
,
mapGet
,
stringAt
,
stringCodePointAt
,
weakMapGet
,
JSON
:
UTSJSON
};
let
UniError$1
=
class
UniError2
extends
Error
{
constructor
(
errSubject
,
errCode
,
errMsg
)
{
let
options
=
{};
if
(
errMsg
==
null
)
{
errMsg
=
errSubject
;
options
=
errCode
;
errCode
=
options
.
errCode
||
0
;
errSubject
=
options
.
errSubject
||
""
;
}
super
(
errMsg
);
this
.
name
=
"
UniError
"
;
this
.
errSubject
=
errSubject
;
this
.
errCode
=
errCode
;
this
.
errMsg
=
errMsg
;
}
toString
()
{
return
this
.
errMsg
;
}
toJSON
()
{
return
{
errSubject
:
this
.
errSubject
,
errCode
:
this
.
errCode
,
errMsg
:
this
.
errMsg
,
data
:
this
.
data
,
cause
:
this
.
cause
&&
typeof
this
.
cause
.
toJSON
===
"
function
"
?
this
.
cause
.
toJSON
()
:
this
.
cause
};
}
};
function
initUTSJSONObjectProperties
(
obj
)
{
const
propertyList
=
[
"
_resolveKeyPath
"
,
"
_getValue
"
,
"
toJSON
"
,
"
get
"
,
"
set
"
,
"
getAny
"
,
"
getString
"
,
"
getNumber
"
,
"
getBoolean
"
,
"
getJSON
"
,
"
getArray
"
,
"
toMap
"
,
"
forEach
"
];
const
propertyDescriptorMap
=
{};
for
(
let
i
=
0
;
i
<
propertyList
.
length
;
i
++
)
{
const
property
=
propertyList
[
i
];
propertyDescriptorMap
[
property
]
=
{
enumerable
:
false
,
value
:
obj
[
property
]
};
}
Object
.
defineProperties
(
obj
,
propertyDescriptorMap
);
}
let
UTSJSONObject$1
=
class
UTSJSONObject2
{
constructor
(
content
=
{})
{
for
(
const
key
in
content
)
{
if
(
Object
.
prototype
.
hasOwnProperty
.
call
(
content
,
key
))
{
const
value
=
content
[
key
];
if
(
isPlainObject
(
value
))
{
this
[
key
]
=
new
UTSJSONObject2
(
value
);
}
else
if
(
getType$1
(
value
)
===
"
array
"
)
{
this
[
key
]
=
value
.
map
((
item
)
=>
{
if
(
isPlainObject
(
item
))
{
return
new
UTSJSONObject2
(
item
);
}
else
{
return
item
;
}
});
}
else
{
this
[
key
]
=
value
;
}
}
}
initUTSJSONObjectProperties
(
this
);
}
_resolveKeyPath
(
keyPath
)
{
let
token
=
""
;
const
keyPathArr
=
[];
let
inOpenParentheses
=
false
;
for
(
let
i
=
0
;
i
<
keyPath
.
length
;
i
++
)
{
const
word
=
keyPath
[
i
];
switch
(
word
)
{
case
"
.
"
:
if
(
token
.
length
>
0
)
{
keyPathArr
.
push
(
token
);
token
=
""
;
}
break
;
case
"
[
"
:
{
inOpenParentheses
=
true
;
if
(
token
.
length
>
0
)
{
keyPathArr
.
push
(
token
);
token
=
""
;
}
break
;
}
case
"
]
"
:
if
(
inOpenParentheses
)
{
if
(
token
.
length
>
0
)
{
const
tokenFirstChar
=
token
[
0
];
const
tokenLastChar
=
token
[
token
.
length
-
1
];
if
(
tokenFirstChar
===
'
"
'
&&
tokenLastChar
===
'
"
'
||
tokenFirstChar
===
"
'
"
&&
tokenLastChar
===
"
'
"
||
tokenFirstChar
===
"
`
"
&&
tokenLastChar
===
"
`
"
)
{
if
(
token
.
length
>
2
)
{
token
=
token
.
slice
(
1
,
-
1
);
}
else
{
return
[];
}
}
else
if
(
!
/^
\d
+$/
.
test
(
token
))
{
return
[];
}
keyPathArr
.
push
(
token
);
token
=
""
;
}
else
{
return
[];
}
inOpenParentheses
=
false
;
}
else
{
return
[];
}
break
;
default
:
token
+=
word
;
break
;
}
if
(
i
===
keyPath
.
length
-
1
)
{
if
(
token
.
length
>
0
)
{
keyPathArr
.
push
(
token
);
token
=
""
;
}
}
}
return
keyPathArr
;
}
_getValue
(
keyPath
)
{
const
keyPathArr
=
this
.
_resolveKeyPath
(
keyPath
);
if
(
keyPathArr
.
length
===
0
)
{
return
null
;
}
let
value
=
this
;
for
(
let
i
=
0
;
i
<
keyPathArr
.
length
;
i
++
)
{
const
key
=
keyPathArr
[
i
];
if
(
value
instanceof
Object
)
{
value
=
value
[
key
];
}
else
{
return
null
;
}
}
return
value
;
}
get
(
key
)
{
return
this
.
_getValue
(
key
);
}
set
(
key
,
value
)
{
this
[
key
]
=
value
;
}
getAny
(
key
)
{
return
this
.
_getValue
(
key
);
}
getString
(
key
)
{
const
value
=
this
.
_getValue
(
key
);
if
(
typeof
value
===
"
string
"
)
{
return
value
;
}
else
{
return
null
;
}
}
getNumber
(
key
)
{
const
value
=
this
.
_getValue
(
key
);
if
(
typeof
value
===
"
number
"
)
{
return
value
;
}
else
{
return
null
;
}
}
getBoolean
(
key
)
{
const
boolean
=
this
.
_getValue
(
key
);
if
(
typeof
boolean
===
"
boolean
"
)
{
return
boolean
;
}
else
{
return
null
;
}
}
getJSON
(
key
)
{
let
value
=
this
.
_getValue
(
key
);
if
(
value
instanceof
Object
)
{
return
new
UTSJSONObject2
(
value
);
}
else
{
return
null
;
}
}
getArray
(
key
)
{
let
value
=
this
.
_getValue
(
key
);
if
(
value
instanceof
Array
)
{
return
value
;
}
else
{
return
null
;
}
}
toMap
()
{
let
map
=
/* @__PURE__ */
new
Map
();
for
(
let
key
in
this
)
{
map
.
set
(
key
,
this
[
key
]);
}
return
map
;
}
forEach
(
callback
)
{
for
(
let
key
in
this
)
{
callback
(
this
[
key
],
key
);
}
}
};
function
getGlobal
()
{
if
(
typeof
globalThis
!==
"
undefined
"
)
{
return
globalThis
;
}
if
(
typeof
self
!==
"
undefined
"
)
{
return
self
;
}
if
(
typeof
window
!==
"
undefined
"
)
{
return
window
;
}
if
(
typeof
global
!==
"
undefined
"
)
{
return
global
;
}
throw
new
Error
(
"
unable to locate global object
"
);
}
const
realGlobal
=
getGlobal
();
realGlobal
.
UTSJSONObject
=
UTSJSONObject$1
;
realGlobal
.
UniError
=
UniError$1
;
realGlobal
.
UTS
=
UTS
;
const
isEnableLocale
=
/* @__PURE__ */
uniShared
.
once
(
()
=>
typeof
__uniConfig
!==
"
undefined
"
&&
__uniConfig
.
locales
&&
!!
Object
.
keys
(
__uniConfig
.
locales
).
length
);
...
...
packages/uni-h5/dist-x/uni-h5.es.js
浏览文件 @
f7461421
此差异已折叠。
点击以展开。
packages/uts/src/types.ts
浏览文件 @
f7461421
...
...
@@ -42,6 +42,7 @@ export type UTSOutputOptions = {
extname
:
string
logFilename
?:
boolean
noColor
?:
boolean
public
?:
boolean
// only for swift
isX
?:
boolean
isApp
?:
boolean
isSingleThread
?:
boolean
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录