Skip to content

Commit 5a74a8f

Browse files
committed
feat: support glass-easel chaining api
1 parent 1bc4a86 commit 5a74a8f

11 files changed

Lines changed: 2384 additions & 28 deletions

test/component.glass-easel.test.ts

Lines changed: 572 additions & 0 deletions
Large diffs are not rendered by default.

types/wx/index.d.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ SOFTWARE.
2626
/// <reference path="./lib.wx.cloud.d.ts" />
2727
/// <reference path="./lib.wx.canvas.d.ts" />
2828
/// <reference path="./lib.wx.component.d.ts" />
29+
/// <reference path="./lib.wx.glass-easel.d.ts" />
2930
/// <reference path="./lib.wx.behavior.d.ts" />
3031
/// <reference path="./lib.wx.event.d.ts" />
3132
/// <reference path="./lib.wx.wasm.d.ts" />
33+
/// <reference path="./lib.wx.skyline.d.ts" />
3234

3335
declare namespace WechatMiniprogram {
3436
type IAnyObject = Record<string, any>
@@ -68,12 +70,6 @@ declare namespace WechatMiniprogram {
6870
type AnalyserNode = any
6971
type WebGLTexture = any
7072
type WebGLRenderingContext = any
71-
72-
// TODO: fill worklet type
73-
type WorkletFunction = (...args: any) => any
74-
type AnimationObject = any
75-
type SharedValue<T = any> = T
76-
type DerivedValue<T = any> = T
7773
}
7874

7975
declare let console: WechatMiniprogram.Console

types/wx/lib.wx.api.d.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3854,9 +3854,9 @@ ctx.draw()
38543854
/** 抬头类型
38553855
*
38563856
* 可选值:
3857-
* - 0: 单位;
3858-
* - 1: 个人; */
3859-
type: 0 | 1
3857+
* - '0': 单位;
3858+
* - '1': 个人; */
3859+
type: '0' | '1'
38603860
}
38613861
interface ChooseLicensePlateOption {
38623862
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
@@ -4618,19 +4618,19 @@ ctx.draw()
46184618
/** 返回上一级,效果同 `wx.navigateBack`,仅可用于 `worklet` 函数内 */
46194619
didPop: (...args: any[]) => any
46204620
/** 动画控制器,影响推入页面的进入和退出过渡效果 */
4621-
primaryAnimation: SharedValue<number>
4621+
primaryAnimation: Skyline.SharedValue<number>
46224622
/** 动画控制器状态 */
4623-
primaryAnimationStatus: SharedValue<number>
4623+
primaryAnimationStatus: Skyline.SharedValue<number>
46244624
/** 动画控制器,影响栈顶页面的推出过渡效果 */
4625-
secondaryAnimation: SharedValue<number>
4625+
secondaryAnimation: Skyline.SharedValue<number>
46264626
/** 动画控制器状态 */
4627-
secondaryAnimationStatus: SharedValue<number>
4627+
secondaryAnimationStatus: Skyline.SharedValue<number>
46284628
/** 手势开始控制路由,与共享元素动画有关 */
46294629
startUserGesture: (...args: any[]) => any
46304630
/** 手势不再控制路由,与 `startUserGesture` 成对调用 */
46314631
stopUserGesture: (...args: any[]) => any
46324632
/** 当前路由进度由手势控制 */
4633-
userGestureInProgress: SharedValue<number>
4633+
userGestureInProgress: Skyline.SharedValue<number>
46344634
}
46354635
/** 弹幕内容 */
46364636
interface Danmu {
@@ -10885,7 +10885,7 @@ NFCAdapter.offDiscovered(listener) // 需传入与监听时同一个的函数对
1088510885
success?: RequestSubscribeMessageSuccessCallback
1088610886
}
1088710887
interface RequestSubscribeMessageSuccessCallbackResult {
10888-
/** [TEMPLATE_ID]是动态的键,即模板id,值包括'accept'、'reject'、'ban'、'filter'。'accept'表示用户同意订阅该条id对应的模板消息,'reject'表示用户拒绝订阅该条id对应的模板消息,'ban'表示已被后台封禁,'filter'表示该模板因为模板标题同名被后台过滤。例如 { errMsg: "requestSubscribeMessage:ok", zun-LzcQyW-edafCVvzPkK4de2Rllr1fFpw2A_x0oXE: "accept"} 表示用户同意订阅zun-LzcQyW-edafCVvzPkK4de2Rllr1fFpw2A_x0oXE这条消息 */
10888+
/** [TEMPLATE_ID]是动态的键,即模板id,值包括'accept'、'reject'、'ban'、'filter'、'acceptWithAlert'、'acceptWithAudio'。'accept'表示用户同意订阅该条id对应的模板消息,'reject'表示用户拒绝订阅该条id对应的模板消息,'ban'表示已被后台封禁,'filter'表示该模板因为模板标题同名被后台过滤,'acceptWithAlert' 表示用户接收消息并打开提醒, 'acceptWithAudio' 表示用户接收订阅消息并开启了语音提醒, 'acceptWithForcePush' 表示用户接收订阅消息并开启了推送提醒。例如 { errMsg: "requestSubscribeMessage:ok", zun-LzcQyW-edafCVvzPkK4de2Rllr1fFpw2A_x0oXE: "accept"} 表示用户同意订阅zun-LzcQyW-edafCVvzPkK4de2Rllr1fFpw2A_x0oXE这条消息 */
1088910889
[TEMPLATE_ID: string]: string
1089010890
/** 接口调用成功时errMsg值为'requestSubscribeMessage:ok' */
1089110891
errMsg: string
@@ -21745,7 +21745,7 @@ Page({
2174521745
options: DecayOption,
2174621746
/** 动画完成回调。动画被取消时,返回 fasle,正常完成时返回 true。 */
2174721747
callback: (...args: any[]) => any
21748-
): AnimationObject
21748+
): Skyline.AnimationObject
2174921749
/** [AnimationObject worklet.delay(number delayMS, AnimationObject delayedAnimation)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/combine-animation/worklet.delay.html)
2175021750
*
2175121751
* 在插件中使用:不支持
@@ -21755,32 +21755,32 @@ Page({
2175521755
/** 动画开始前等待的时间,单位:毫秒。 */
2175621756
delayMS: number,
2175721757
/** 动画对象。 */
21758-
delayedAnimation: AnimationObject
21759-
): AnimationObject
21758+
delayedAnimation: Skyline.AnimationObject
21759+
): Skyline.AnimationObject
2176021760
/** [AnimationObject worklet.repeat(AnimationObject animation, number numberOfReps, boolean reverse, function callback)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/combine-animation/worklet.repeat.html)
2176121761
*
2176221762
* 在插件中使用:不支持
2176321763
*
2176421764
* 重复执行动画。 */
2176521765
repeat(
2176621766
/** 动画对象 */
21767-
animation: AnimationObject,
21767+
animation: Skyline.AnimationObject,
2176821768
/** 重复次数。为负值时一直循环,直到被取消动画。 */
2176921769
numberOfReps?: number,
2177021770
/** 反向运行动画,每周期结束动画由尾到头运行。该字段仅对 timing 和 spring 返回的动画对象生效。 */
2177121771
reverse?: boolean,
2177221772
/** 动画完成回调。动画被取消时,返回 fasle,正常完成时返回 true。 */
2177321773
callback?: (...args: any[]) => any
21774-
): AnimationObject
21774+
): Skyline.AnimationObject
2177521775
/** [AnimationObject worklet.sequence(AnimationObject animationN)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/combine-animation/worklet.sequence.html)
2177621776
*
2177721777
* 在插件中使用:不支持
2177821778
*
2177921779
* 组合动画序列,依次执行传入的动画。 */
2178021780
sequence(
2178121781
/** 动画对象 */
21782-
animationN: AnimationObject
21783-
): AnimationObject
21782+
animationN: Skyline.AnimationObject
21783+
): Skyline.AnimationObject
2178421784
/** [AnimationObject worklet.spring(number|string toValue, Object options, function callback)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.spring.html)
2178521785
*
2178621786
* 在插件中使用:不支持
@@ -21793,7 +21793,7 @@ Page({
2179321793
options: SpringOption,
2179421794
/** 动画完成回调。动画被取消时,返回 fasle,正常完成时返回 true。 */
2179521795
callback: (...args: any[]) => any
21796-
): AnimationObject
21796+
): Skyline.AnimationObject
2179721797
/** [AnimationObject worklet.timing(number toValue, Object options, function callback)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.timing.html)
2179821798
*
2179921799
* 在插件中使用:不支持
@@ -21806,16 +21806,16 @@ Page({
2180621806
options: TimingOption,
2180721807
/** 动画完成回调。动画被取消时,返回 fasle,正常完成时返回 true。 */
2180821808
callback: (...args: any[]) => any
21809-
): AnimationObject
21809+
): Skyline.AnimationObject
2181021810
/** [DerivedValue worklet.derived(WorkletFunction updaterWorklet)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/base/worklet.derived.html)
2181121811
*
2181221812
* 在插件中使用:不支持
2181321813
*
2181421814
* 衍生值 `DerivedValue`,可基于已有的 `SharedValue` 生成其它共享变量。 */
2181521815
derived(
2181621816
/** worklet 函数类型,该函数被立即执行,返回值作为 DerivedValue 的初始值。当函数内捕获的 SharedValue 类型值发生变化时,updaterWorklet 被驱动执行,返回值用于更新 DerivedValue。可类比 computed 计算属性进行理解。 */
21817-
updaterWorklet: WorkletFunction
21818-
): DerivedValue
21817+
updaterWorklet: Skyline.WorkletFunction
21818+
): Skyline.DerivedValue<any>
2181921819
/** [SharedValue worklet.shared(any initialValue)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/base/worklet.shared.html)
2182021820
*
2182121821
* 在插件中使用:不支持
@@ -21824,7 +21824,7 @@ Page({
2182421824
shared(
2182521825
/** 初始值,可通过 `.value` 属性进行读取和修改。类型可以是 `number | string | bool | null | undefined | Object | Array | Function`。 */
2182621826
initialValue: any
21827-
): SharedValue
21827+
): Skyline.SharedValue<any>
2182821828
/** [function worklet.runOnJS(function fn)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/tool-function/worklet.runOnJS.html)
2182921829
*
2183021830
* 在插件中使用:不支持
@@ -21851,7 +21851,7 @@ Page({
2185121851
* 取消由 `SharedValue` 驱动的动画。 */
2185221852
cancelAnimation(
2185321853
/** 共享变量。 */
21854-
SharedValue: SharedValue
21854+
SharedValue: Skyline.SharedValue<any>
2185521855
): void
2185621856
/** [worklet.scrollViewContext.scrollTo(Object object)](https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/base/worklet.scrollViewContext.scrollTo.html)
2185721857
*

types/wx/lib.wx.behavior.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ declare namespace WechatMiniprogram.Behavior {
6060
>(
6161
options: Options<TData, TProperty, TMethod, TBehavior, TCustomInstanceProperty>
6262
): Identifier<TData, TProperty, TMethod, TBehavior>
63+
(): GlassEasel.Behavior.Builder
64+
trait: GlassEasel.TraitBehavior.Constructor
6365
}
6466

6567
type DataOption = Component.DataOption

types/wx/lib.wx.component.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ declare namespace WechatMiniprogram.Component {
101101
TIsPage
102102
>
103103
): Identifier<TData, TProperty, TMethod>
104+
(): GlassEasel.Component.Builder
104105
}
105106
type DataOption = Record<string, any>
106107
type PropertyOption = Record<string, AllProperty>

0 commit comments

Comments
 (0)