rezor 0.0.0 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +13 -0
- package/dist/index.cjs.js +1208 -0
- package/dist/index.cjs.prod.js +7 -0
- package/dist/index.d.ts +100 -0
- package/dist/index.esm-bundler.js +1174 -0
- package/package.json +33 -8
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* rezor v0.0.1
|
|
3
|
+
* https://github.com/rezorjs/rezor
|
|
4
|
+
* (c) 2026-present Yang Mingshan
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
"use strict";let e=null;let t=null;let s=null;function n(){return t||s}function i(){return e||t||s}function o(e){return void 0===e.__hooks__&&(e.__hooks__={cursor:0,slots:[]}),e.__hooks__}function r(e){const t=e.__hooks__;void 0!==t&&(t.cursor=0)}function _(e){const t=e.__hooks__;void 0!==t&&(t.slots.length=t.cursor)}function c(e,t){return void 0!==e&&e.kind===t}function E(e,t){const s=e.__lifecycle__;void 0!==s&&t.forEach(e=>{void 0!==s[e]&&(s[e].cursor=0)})}function a(e,t){const s=e.__lifecycle__;void 0!==s&&t.forEach(e=>{void 0!==s[e]&&(s[e].handlers.length=s[e].cursor)})}function O(e,t,s){void 0===e.__lifecycle__&&(e.__lifecycle__={});const n=e.__lifecycle__;void 0===n[t]&&(n[t]={cursor:0,handlers:[]});const i=n[t];i.handlers[i.cursor]=s,i.cursor+=1}function l(e,t){const s=e.__lifecycle__;return void 0===s||void 0===s[t]?0:s[t].cursor}function h(e,t){const s=e.__lifecycle__;return void 0===s||void 0===s[t]?[]:s[t].handlers}const d=Object.assign;function u(e,t){const s={};return Object.keys(e).forEach(n=>{t.includes(n)||(s[n]=e[n])}),s}function N(e){return"function"==typeof e}function f(e,t){if(void 0===e||void 0===t)return!1;if(t.length!==e.length)return!1;for(let s=0;s<t.length;s++)if(!Object.is(t[s],e[s]))return!1;return!0}var A;!function(e){e[e.QUEUED=1]="QUEUED",e[e.DISPOSED=2]="DISPOSED"}(A||(A={}));const S=[];let T=[],p=null,R=null,D=0,v=0,I=0;const H=Promise.resolve();function m(e){P(e,S,D)&&(D++,R||(R=H.then(L)))}function P(e,t,s){const n=e.flags;return!(n&A.QUEUED)&&(e.flags=n|A.QUEUED,t[s]=e,!0)}function b(e){P(e,T,T.length)}function g(){if(T.length){p=T,T=[];try{for(;I<p.length;){const e=p[I++];e.flags&A.DISPOSED||(e.flags&=~A.QUEUED,e())}}finally{for(;I<p.length;)p[I++].flags&=~A.QUEUED;p=null,I=0}}}function L(){try{for(;v<D;){const e=S[v];S[v++]=void 0,e.flags&A.DISPOSED||(e.flags&=~A.QUEUED,e())}}finally{for(;v<D;)S[v].flags&=~A.QUEUED,S[v++]=void 0;v=0,D=0,R=null}}function C(e,t,s){const n=o(e),i=n.cursor;let r=n.slots[i];return c(r,"memo")?f(r.deps,s)||(r.value=t(),r.deps=s):(r={kind:"memo",value:t(),deps:s},n.slots[i]=r),n.cursor+=1,r.value}function U(e){e.subscribers.forEach(e=>{m(e)})}var M;!function(e){e.ON_LAUNCH="onLaunch",e.ON_SHOW="onShow",e.ON_HIDE="onHide",e.ON_ERROR="onError",e.ON_PAGE_NOT_FOUND="onPageNotFound",e.ON_UNHANDLED_REJECTION="onUnhandledRejection",e.ON_THEME_CHANGE="onThemeChange"}(M||(M={}));const x=[M.ON_SHOW,M.ON_HIDE,M.ON_ERROR,M.ON_PAGE_NOT_FOUND,M.ON_UNHANDLED_REJECTION,M.ON_THEME_CHANGE];function y(e,t){const s=e[t];return function(...e){h(this,t).forEach(t=>t(...e)),void 0!==s&&s.call(this,...e)}}var j;!function(e){e.ON_LOAD="onLoad",e.ON_SHOW="onShow",e.ON_READY="onReady",e.ON_HIDE="onHide",e.ON_UNLOAD="onUnload",e.ON_ROUTE_DONE="onRouteDone",e.ON_PULL_DOWN_REFRESH="onPullDownRefresh",e.ON_REACH_BOTTOM="onReachBottom",e.ON_PAGE_SCROLL="onPageScroll",e.ON_SHARE_APP_MESSAGE="onShareAppMessage",e.ON_SHARE_TIMELINE="onShareTimeline",e.ON_ADD_TO_FAVORITES="onAddToFavorites",e.ON_RESIZE="onResize",e.ON_TAB_ITEM_TAP="onTabItemTap",e.ON_SAVE_EXIT_STATE="onSaveExitState"}(j||(j={}));const k=[j.ON_SHOW,j.ON_HIDE,j.ON_ROUTE_DONE,j.ON_PULL_DOWN_REFRESH,j.ON_REACH_BOTTOM,j.ON_PAGE_SCROLL,j.ON_SHARE_APP_MESSAGE,j.ON_SHARE_TIMELINE,j.ON_ADD_TO_FAVORITES,j.ON_RESIZE,j.ON_TAB_ITEM_TAP,j.ON_SAVE_EXIT_STATE];function V(e,t){const s=e[t];return function(...e){h(this,t).forEach(t=>t(...e)),void 0!==s&&s.call(this,...e)}}function F(e,t){return function(...s){const[n]=h(this,e);return n?n(...s):t()}}var G;!function(e){e.ATTACHED="attached",e.READY="ready",e.MOVED="moved",e.DETACHED="detached",e.ERROR="error"}(G||(G={}));const B={[j.ON_SHOW]:"show",[j.ON_HIDE]:"hide",[j.ON_RESIZE]:"resize",[j.ON_ROUTE_DONE]:"routeDone"},W=[...k,G.MOVED,G.ERROR];function Q(e,t){return Z(t,e.lifetimes[t]||e[t])}function w(e,t){return Z(t,e.methods[t])}function X(e,t){return Z(t,e.pageLifetimes[B[t]])}function Z(e,t){return function(...s){h(this,e).forEach(e=>e(...s)),void 0!==t&&t.call(this,...s)}}function Y(e,t){return function(...s){const[n]=h(this,e);return n?n(...s):t()}}const J=ae(M.ON_SHOW),z=ae(M.ON_HIDE),q=ae(M.ON_ERROR),K=ae(M.ON_PAGE_NOT_FOUND),$=ae(M.ON_UNHANDLED_REJECTION),ee=ae(M.ON_THEME_CHANGE),te=Oe(j.ON_SHOW),se=Oe(j.ON_HIDE),ne=Oe(j.ON_ROUTE_DONE),ie=Oe(j.ON_PULL_DOWN_REFRESH),oe=Oe(j.ON_REACH_BOTTOM),re=Oe(j.ON_RESIZE),_e=Oe(j.ON_TAB_ITEM_TAP),ce=le(G.MOVED),Ee=le(G.ERROR);function ae(t){return s=>{e&&O(e,t,s)}}function Oe(e){return t=>{const s=n();s&&O(s,e,t)}}function le(e){return t=>{s&&O(s,e,t)}}exports.createApp=function(t){let s,n;if(N(t))s=t,n={};else{if(void 0===t.render)return void App(t);s=t.render,n=u(t,["render"])}const i=n[M.ON_LAUNCH];n[M.ON_LAUNCH]=function(t){this.__render__=()=>{e=this,r(this),E(this,x);try{const e=s(t);void 0!==e&&Object.keys(e).forEach(t=>{this[t]=e[t]})}finally{e=null}_(this),a(this,x)},this.__render__(),void 0!==i&&i.call(this,t)},n[M.ON_SHOW]=y(n,M.ON_SHOW),n[M.ON_HIDE]=y(n,M.ON_HIDE),n[M.ON_ERROR]=y(n,M.ON_ERROR),n[M.ON_PAGE_NOT_FOUND]=y(n,M.ON_PAGE_NOT_FOUND),n[M.ON_UNHANDLED_REJECTION]=y(n,M.ON_UNHANDLED_REJECTION),n[M.ON_THEME_CHANGE]=y(n,M.ON_THEME_CHANGE),App(n)},exports.createContext=function(e){return{defaultValue:e,currentValue:e,subscribers:new Set}},exports.defineComponent=function(e,t){let n,i;t=d({listenPageScroll:!1,canShareToOthers:!1,canShareToTimeline:!1},t);let c=null;if(N(e))n=e,i={};else{if(void 0===e.render)return Component(e);n=e.render,i=u(e,["render"]),i.properties&&(c=Object.keys(i.properties))}void 0===i.lifetimes&&(i.lifetimes={});const O=i.lifetimes[G.ATTACHED]||i[G.ATTACHED];i.lifetimes[G.ATTACHED]=function(){this.__props__={},c&&c.forEach(e=>{this.__props__[e]=this.data[e]});const e={is:this.is,id:this.id,dataset:this.dataset,exitState:this.exitState,router:this.router,pageRouter:this.pageRouter,renderer:this.renderer,triggerEvent:this.triggerEvent.bind(this),createSelectorQuery:this.createSelectorQuery.bind(this),createIntersectionObserver:this.createIntersectionObserver.bind(this),createMediaQueryObserver:this.createMediaQueryObserver.bind(this),selectComponent:this.selectComponent.bind(this),selectAllComponents:this.selectAllComponents.bind(this),selectOwnerComponent:this.selectOwnerComponent.bind(this),getRelationNodes:this.getRelationNodes.bind(this),getTabBar:this.getTabBar.bind(this),getPageId:this.getPageId.bind(this),animate:this.animate.bind(this),clearAnimation:this.clearAnimation.bind(this),getOpenerEventChannel:this.getOpenerEventChannel.bind(this),applyAnimatedStyle:this.applyAnimatedStyle.bind(this),clearAnimatedStyle:this.clearAnimatedStyle.bind(this),setUpdatePerformanceListener:this.setUpdatePerformanceListener.bind(this),getPassiveEvent:this.getPassiveEvent.bind(this),setPassiveEvent:this.setPassiveEvent.bind(this),setInitialRenderingCache:this.setInitialRenderingCache.bind(this),getAppBar:this.getAppBar&&this.getAppBar.bind(this)};this.__render__=()=>{s=this,r(this),E(this,W);try{const t=n(this.__props__,e);if(void 0!==t){let e;Object.keys(t).forEach(s=>{const n=t[s];N(n)?this[s]=n:Object.prototype.hasOwnProperty.call(this.data,s)&&Object.is(this.data[s],n)||(e=e||{},e[s]=n)}),void 0!==e&&this.setData(e,g)}}finally{s=null}_(this),a(this,W)},this.__render__(),void 0!==O&&O.call(this)};const l=i.lifetimes[G.READY]||i[G.READY];i.lifetimes[G.READY]=function(){g(),void 0!==l&&l.call(this)};const h=i.lifetimes[G.DETACHED]||i[G.DETACHED];return i.lifetimes[G.DETACHED]=function(){this.__render__.flags|=A.DISPOSED;o(this).slots.forEach(e=>{"effect"===e.kind?(e.job&&(e.job.flags|=A.DISPOSED,e.job=void 0),e.cleanup&&e.cleanup()):"context"===e.kind&&e.cleanup()}),void 0!==h&&h.call(this)},i.lifetimes[G.MOVED]=Q(i,G.MOVED),i.lifetimes[G.ERROR]=Q(i,G.ERROR),void 0===i.methods&&(i.methods={}),(i.methods[j.ON_PAGE_SCROLL]||t.listenPageScroll)&&(i.methods[j.ON_PAGE_SCROLL]=w(i,j.ON_PAGE_SCROLL),i.methods.__listenPageScroll__=()=>!0),void 0===i.methods[j.ON_SHARE_APP_MESSAGE]&&t.canShareToOthers&&(i.methods[j.ON_SHARE_APP_MESSAGE]=Y(j.ON_SHARE_APP_MESSAGE,()=>({})),i.methods.__isInjectedShareToOthersHook__=()=>!0),void 0===i.methods[j.ON_SHARE_TIMELINE]&&t.canShareToTimeline&&(i.methods[j.ON_SHARE_TIMELINE]=Y(j.ON_SHARE_TIMELINE,()=>({})),i.methods.__isInjectedShareToTimelineHook__=()=>!0),void 0===i.methods[j.ON_ADD_TO_FAVORITES]&&(i.methods[j.ON_ADD_TO_FAVORITES]=Y(j.ON_ADD_TO_FAVORITES,()=>({})),i.methods.__isInjectedFavoritesHook__=()=>!0),void 0===i.methods[j.ON_SAVE_EXIT_STATE]&&(i.methods[j.ON_SAVE_EXIT_STATE]=Y(j.ON_SAVE_EXIT_STATE,()=>({data:void 0})),i.methods.__isInjectedExitStateHook__=()=>!0),i.methods[j.ON_PULL_DOWN_REFRESH]=w(i,j.ON_PULL_DOWN_REFRESH),i.methods[j.ON_REACH_BOTTOM]=w(i,j.ON_REACH_BOTTOM),i.methods[j.ON_TAB_ITEM_TAP]=w(i,j.ON_TAB_ITEM_TAP),void 0===i.pageLifetimes&&(i.pageLifetimes={}),i.pageLifetimes[B[j.ON_SHOW]]=X(i,j.ON_SHOW),i.pageLifetimes[B[j.ON_HIDE]]=X(i,j.ON_HIDE),i.pageLifetimes[B[j.ON_RESIZE]]=X(i,j.ON_RESIZE),i.pageLifetimes[B[j.ON_ROUTE_DONE]]=X(i,j.ON_ROUTE_DONE),c&&(void 0===i.observers&&(i.observers={}),c.forEach(e=>{const t=i.observers[e];i.observers[e]=function(s){this.__props__&&(this.__props__=d({},this.__props__,{[e]:s})),this.__render__&&m(this.__render__),void 0!==t&&t.call(this,s)}})),Component(i)},exports.definePage=function(e,s){let n,i;if(s=d({listenPageScroll:!1,canShareToOthers:!1,canShareToTimeline:!1},s),N(e))n=e,i={};else{if(void 0===e.render)return void Page(e);n=e.render,i=u(e,["render"])}const c=i[j.ON_LOAD];i[j.ON_LOAD]=function(e){const s={is:this.is,route:this.route,options:this.options,exitState:this.exitState,router:this.router,pageRouter:this.pageRouter,renderer:this.renderer,createSelectorQuery:this.createSelectorQuery.bind(this),createIntersectionObserver:this.createIntersectionObserver.bind(this),createMediaQueryObserver:this.createMediaQueryObserver.bind(this),selectComponent:this.selectComponent.bind(this),selectAllComponents:this.selectAllComponents.bind(this),getTabBar:this.getTabBar.bind(this),getPageId:this.getPageId.bind(this),animate:this.animate.bind(this),clearAnimation:this.clearAnimation.bind(this),getOpenerEventChannel:this.getOpenerEventChannel.bind(this),applyAnimatedStyle:this.applyAnimatedStyle.bind(this),clearAnimatedStyle:this.clearAnimatedStyle.bind(this),setUpdatePerformanceListener:this.setUpdatePerformanceListener.bind(this),getPassiveEvent:this.getPassiveEvent.bind(this),setPassiveEvent:this.setPassiveEvent.bind(this),setInitialRenderingCache:this.setInitialRenderingCache.bind(this),getAppBar:this.getAppBar&&this.getAppBar.bind(this)};this.__render__=()=>{t=this,r(this),E(this,k);try{const t=n(e,s);if(void 0!==t){let e;Object.keys(t).forEach(s=>{const n=t[s];N(n)?this[s]=n:Object.prototype.hasOwnProperty.call(this.data,s)&&Object.is(this.data[s],n)||(e=e||{},e[s]=n)}),void 0!==e&&this.setData(e,g)}}finally{t=null}_(this),a(this,k)},this.__render__(),void 0!==c&&c.call(this,e)};const O=i[j.ON_READY];i[j.ON_READY]=function(){g(),void 0!==O&&O.call(this)};const l=i[j.ON_UNLOAD];i[j.ON_UNLOAD]=function(){this.__render__.flags|=A.DISPOSED;o(this).slots.forEach(e=>{"effect"===e.kind?(e.job&&(e.job.flags|=A.DISPOSED,e.job=void 0),e.cleanup&&e.cleanup()):"context"===e.kind&&e.cleanup()}),void 0!==l&&l.call(this)},(i[j.ON_PAGE_SCROLL]||s.listenPageScroll)&&(i[j.ON_PAGE_SCROLL]=V(i,j.ON_PAGE_SCROLL),i.__listenPageScroll__=()=>!0),void 0===i[j.ON_SHARE_APP_MESSAGE]&&s.canShareToOthers&&(i[j.ON_SHARE_APP_MESSAGE]=F(j.ON_SHARE_APP_MESSAGE,()=>({})),i.__isInjectedShareToOthersHook__=()=>!0),void 0===i[j.ON_SHARE_TIMELINE]&&s.canShareToTimeline&&(i[j.ON_SHARE_TIMELINE]=F(j.ON_SHARE_TIMELINE,()=>({})),i.__isInjectedShareToTimelineHook__=()=>!0),void 0===i[j.ON_ADD_TO_FAVORITES]&&(i[j.ON_ADD_TO_FAVORITES]=F(j.ON_ADD_TO_FAVORITES,()=>({})),i.__isInjectedFavoritesHook__=()=>!0),void 0===i[j.ON_SAVE_EXIT_STATE]&&(i[j.ON_SAVE_EXIT_STATE]=F(j.ON_SAVE_EXIT_STATE,()=>({data:void 0})),i.__isInjectedExitStateHook__=()=>!0),i[j.ON_SHOW]=V(i,j.ON_SHOW),i[j.ON_HIDE]=V(i,j.ON_HIDE),i[j.ON_ROUTE_DONE]=V(i,j.ON_ROUTE_DONE),i[j.ON_PULL_DOWN_REFRESH]=V(i,j.ON_PULL_DOWN_REFRESH),i[j.ON_REACH_BOTTOM]=V(i,j.ON_REACH_BOTTOM),i[j.ON_RESIZE]=V(i,j.ON_RESIZE),i[j.ON_TAB_ITEM_TAP]=V(i,j.ON_TAB_ITEM_TAP),Page(i)},exports.nextTick=function(e){const t=R||H;return e?t.then(e):t},exports.useAddToFavorites=e=>{const t=n();if(t&&t.__isInjectedFavoritesHook__){0===l(t,j.ON_ADD_TO_FAVORITES)&&O(t,j.ON_ADD_TO_FAVORITES,e)}},exports.useAppError=q,exports.useAppHide=z,exports.useAppShow=J,exports.useCallback=function(e,t){const s=i();return s?C(s,()=>e,t):e},exports.useContext=function(e,t){const s=i();if(s){const n=o(s),i=n.cursor;if(arguments.length>=2)return c(n.slots[i],"context")||(n.slots[i]={kind:"context",cleanup(){e.currentValue=e.defaultValue,U(e)}}),Object.is(e.currentValue,t)||(e.currentValue=t,U(e)),void(n.cursor+=1);const r=s.__render__;return c(n.slots[i],"context")||(n.slots[i]={kind:"context",cleanup(){e.subscribers.delete(r)}}),e.subscribers.add(r),n.cursor+=1,e.currentValue}return e.currentValue},exports.useEffect=function(e,t){const s=i();if(s){const n=o(s),i=n.cursor;let r=n.slots[i];if(c(r,"effect")){if(!f(r.deps,t)){r.deps=t;const s=()=>{r.job=void 0,r.cleanup&&r.cleanup(),r.cleanup=e()};r.job=s,b(s)}}else{r={kind:"effect",deps:t,cleanup:void 0},n.slots[i]=r;const s=()=>{r.job=void 0,r.cleanup=e()};r.job=s,b(s)}return void(n.cursor+=1)}},exports.useEffectEvent=function(e){const t=i();if(t){const s=o(t),n=s.cursor;let i=s.slots[n];return c(i,"effectEvent")?i.fn=e:(i={kind:"effectEvent",fn:e},s.slots[n]=i),s.cursor+=1,(...e)=>i.fn(...e)}return e},exports.useError=Ee,exports.useHide=se,exports.useMemo=function(e,t){const s=i();return s?C(s,e,t):e()},exports.useMove=ce,exports.usePageNotFound=K,exports.usePageScroll=e=>{const t=n();t&&t.__listenPageScroll__&&O(t,j.ON_PAGE_SCROLL,e)},exports.usePullDownRefresh=ie,exports.useReachBottom=oe,exports.useReducer=function(e,t,s){const n=()=>void 0===s?t:s(t),r=i();if(r){const t=o(r),s=t.cursor;let i=t.slots[s];if(!c(i,"state")){const o=t=>{const s=i.value,n=e(s,t);Object.is(s,n)||(i.value=n,m(r.__render__))};i={kind:"state",value:n(),setState:o},t.slots[s]=i}return t.cursor+=1,[i.value,i.setState]}return[n(),()=>{}]},exports.useRef=function(e){const t=i();if(t){const s=o(t),n=s.cursor;let i=s.slots[n];return c(i,"ref")||(i={kind:"ref",ref:{current:e}},s.slots[n]=i),s.cursor+=1,i.ref}return{current:e}},exports.useResize=re,exports.useRouteDone=ne,exports.useSaveExitState=e=>{const t=n();if(t&&t.__isInjectedExitStateHook__){0===l(t,j.ON_SAVE_EXIT_STATE)&&O(t,j.ON_SAVE_EXIT_STATE,e)}},exports.useShareAppMessage=e=>{const t=n();if(t&&t.__isInjectedShareToOthersHook__){0===l(t,j.ON_SHARE_APP_MESSAGE)&&O(t,j.ON_SHARE_APP_MESSAGE,e)}},exports.useShareTimeline=e=>{const t=n();if(t&&t.__isInjectedShareToTimelineHook__){0===l(t,j.ON_SHARE_TIMELINE)&&O(t,j.ON_SHARE_TIMELINE,e)}},exports.useShow=te,exports.useState=function(e){const t=()=>N(e)?e():e,s=i();if(s){const e=o(s),n=e.cursor;let i=e.slots[n];if(!c(i,"state")){const o=e=>{const t=i.value,n=N(e)?e(t):e;Object.is(t,n)||(i.value=n,m(s.__render__))};i={kind:"state",value:t(),setState:o},e.slots[n]=i}return e.cursor+=1,[i.value,i.setState]}return[t(),()=>{}]},exports.useTabItemTap=_e,exports.useThemeChange=ee,exports.useUnhandledRejection=$;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/// <reference types="miniprogram-api-typings" />
|
|
2
|
+
interface RefObject<T> {
|
|
3
|
+
current: T;
|
|
4
|
+
}
|
|
5
|
+
declare function useRef<T>(initialValue: T): RefObject<T>;
|
|
6
|
+
declare function useRef<T>(initialValue: T | null): RefObject<T | null>;
|
|
7
|
+
declare function useRef<T>(initialValue: T | undefined): RefObject<T | undefined>;
|
|
8
|
+
|
|
9
|
+
type Dispatch<A> = (value: A) => void;
|
|
10
|
+
type SetStateAction<S> = S | ((prevState: S) => S);
|
|
11
|
+
declare function useState<S>(initialState: S | (() => S)): [S, Dispatch<SetStateAction<S>>];
|
|
12
|
+
declare function useState<S = undefined>(): [
|
|
13
|
+
S | undefined,
|
|
14
|
+
Dispatch<SetStateAction<S | undefined>>
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
type EffectCallback = () => void | (() => void);
|
|
18
|
+
declare function useEffect(callback: EffectCallback, deps?: readonly unknown[]): void;
|
|
19
|
+
|
|
20
|
+
type ActionDispatch<A> = (action: A) => void;
|
|
21
|
+
declare function useReducer<S, A>(reducer: (prevState: S, action: A) => S, initialArg: S): [S, ActionDispatch<A>];
|
|
22
|
+
declare function useReducer<S, I, A>(reducer: (prevState: S, action: A) => S, initialArg: I, init: (i: I) => S): [S, ActionDispatch<A>];
|
|
23
|
+
|
|
24
|
+
declare function useMemo<T>(factory: () => T, deps: readonly unknown[]): T;
|
|
25
|
+
declare function useCallback<T extends Function>(callback: T, deps: readonly unknown[]): T;
|
|
26
|
+
|
|
27
|
+
declare function useEffectEvent<T extends (...args: any[]) => any>(callback: T): T;
|
|
28
|
+
|
|
29
|
+
interface Context<T> {
|
|
30
|
+
defaultValue: T;
|
|
31
|
+
currentValue: T;
|
|
32
|
+
subscribers: Set<Function>;
|
|
33
|
+
}
|
|
34
|
+
declare function createContext<T>(defaultValue: T): Context<T>;
|
|
35
|
+
declare function useContext<T>(context: Context<T>, value: T): void;
|
|
36
|
+
declare function useContext<T>(context: Context<T>): T;
|
|
37
|
+
|
|
38
|
+
declare function nextTick(): Promise<void>;
|
|
39
|
+
declare function nextTick<R>(fn: () => R | Promise<R>): Promise<R>;
|
|
40
|
+
|
|
41
|
+
type Bindings = Record<string, any> | void;
|
|
42
|
+
|
|
43
|
+
type AppRender = (this: void, options: WechatMiniprogram.App.LaunchShowOption) => Bindings;
|
|
44
|
+
type AppOptions<T extends WechatMiniprogram.IAnyObject> = {
|
|
45
|
+
render?: AppRender;
|
|
46
|
+
} & WechatMiniprogram.App.Options<T>;
|
|
47
|
+
declare function createApp(render: AppRender): void;
|
|
48
|
+
declare function createApp<T extends WechatMiniprogram.IAnyObject>(options: AppOptions<T>): void;
|
|
49
|
+
|
|
50
|
+
type Query = Record<string, string | undefined>;
|
|
51
|
+
type PageContext = WechatMiniprogram.Page.InstanceProperties & Omit<WechatMiniprogram.Page.InstanceMethods<Record<string, any>>, 'setData' | 'groupSetData' | 'hasBehavior' | 'triggerEvent' | 'selectOwnerComponent' | 'getRelationNodes'>;
|
|
52
|
+
type PageRender = (this: void, query: Query, context: PageContext) => Bindings;
|
|
53
|
+
type PageOptions<Data extends WechatMiniprogram.Page.DataOption, Custom extends WechatMiniprogram.Page.CustomOption> = {
|
|
54
|
+
render?: PageRender;
|
|
55
|
+
} & WechatMiniprogram.Page.Options<Data, Custom>;
|
|
56
|
+
interface Config {
|
|
57
|
+
listenPageScroll?: boolean;
|
|
58
|
+
canShareToOthers?: boolean;
|
|
59
|
+
canShareToTimeline?: boolean;
|
|
60
|
+
}
|
|
61
|
+
declare function definePage(render: PageRender, config?: Config): void;
|
|
62
|
+
declare function definePage<Data extends WechatMiniprogram.Page.DataOption, Custom extends WechatMiniprogram.Page.CustomOption>(options: PageOptions<Data, Custom>, config?: Config): void;
|
|
63
|
+
|
|
64
|
+
type ComponentContext = WechatMiniprogram.Component.InstanceProperties & Omit<WechatMiniprogram.Component.InstanceMethods<Record<string, any>>, 'setData' | 'groupSetData' | 'hasBehavior'>;
|
|
65
|
+
type ComponentRender<Props extends Record<string, any>> = (this: void, props: Readonly<Props>, context: ComponentContext) => Bindings;
|
|
66
|
+
type ComponentOptions<Props extends WechatMiniprogram.Component.PropertyOption, Data extends WechatMiniprogram.Component.DataOption, Methods extends WechatMiniprogram.Component.MethodOption, Behavior extends WechatMiniprogram.Component.BehaviorOption> = WechatMiniprogram.Component.Options<Data, Props, Methods, Behavior> & {
|
|
67
|
+
render?: ComponentRender<PropertyOptionToData<WechatMiniprogram.Component.FilterUnknownType<Props>>>;
|
|
68
|
+
};
|
|
69
|
+
/** * Temporary patch for https://github.com/wechat-miniprogram/api-typings/issues/97 ***/
|
|
70
|
+
type PropertyOptionToData<T extends WechatMiniprogram.Component.PropertyOption> = {
|
|
71
|
+
[Name in keyof T]: PropertyToData<T[Name]>;
|
|
72
|
+
};
|
|
73
|
+
type PropertyToData<T extends WechatMiniprogram.Component.AllProperty> = T extends WechatMiniprogram.Component.PropertyType ? WechatMiniprogram.Component.ValueType<T> : T extends WechatMiniprogram.Component.AllFullProperty ? T['optionalTypes'] extends OptionalTypes<infer Option> ? WechatMiniprogram.Component.FullPropertyToData<T> | WechatMiniprogram.Component.ValueType<Option> : WechatMiniprogram.Component.FullPropertyToData<T> : never;
|
|
74
|
+
type OptionalTypes<T extends WechatMiniprogram.Component.PropertyType> = T[];
|
|
75
|
+
declare function defineComponent(render: ComponentRender<{}>, config?: Config): string;
|
|
76
|
+
declare function defineComponent<Props extends WechatMiniprogram.Component.PropertyOption, Data extends WechatMiniprogram.Component.DataOption, Methods extends WechatMiniprogram.Component.MethodOption, Behavior extends WechatMiniprogram.Component.BehaviorOption>(options: ComponentOptions<Props, Data, Methods, Behavior>, config?: Config): string;
|
|
77
|
+
|
|
78
|
+
declare const useAppShow: (hook: (options: WechatMiniprogram.App.LaunchShowOption) => void) => void;
|
|
79
|
+
declare const useAppHide: (hook: () => void) => void;
|
|
80
|
+
declare const useAppError: (hook: (error: string) => void) => void;
|
|
81
|
+
declare const usePageNotFound: (hook: (options: WechatMiniprogram.App.PageNotFoundOption) => void) => void;
|
|
82
|
+
declare const useUnhandledRejection: (hook: (options: WechatMiniprogram.OnUnhandledRejectionListenerResult) => void) => void;
|
|
83
|
+
declare const useThemeChange: (hook: (options: WechatMiniprogram.OnThemeChangeListenerResult) => void) => void;
|
|
84
|
+
declare const useShow: (hook: () => void) => void;
|
|
85
|
+
declare const useHide: (hook: () => void) => void;
|
|
86
|
+
declare const useRouteDone: (hook: () => void) => void;
|
|
87
|
+
declare const usePullDownRefresh: (hook: () => void) => void;
|
|
88
|
+
declare const useReachBottom: (hook: () => void) => void;
|
|
89
|
+
declare const useResize: (hook: (resize: WechatMiniprogram.Page.IResizeOption) => void) => void;
|
|
90
|
+
declare const useTabItemTap: (hook: (tap: WechatMiniprogram.Page.ITabItemTapOption) => void) => void;
|
|
91
|
+
declare const usePageScroll: (hook: (scroll: WechatMiniprogram.Page.IPageScrollOption) => void) => void;
|
|
92
|
+
declare const useShareAppMessage: (hook: (share: WechatMiniprogram.Page.IShareAppMessageOption) => WechatMiniprogram.Page.ICustomShareContent | WechatMiniprogram.Page.IAsyncCustomShareContent | Promise<WechatMiniprogram.Page.ICustomShareContent> | void | Promise<void>) => void;
|
|
93
|
+
declare const useShareTimeline: (hook: () => WechatMiniprogram.Page.ICustomTimelineContent | void) => void;
|
|
94
|
+
declare const useAddToFavorites: (hook: (share: WechatMiniprogram.Page.IAddToFavoritesOption) => WechatMiniprogram.Page.IAddToFavoritesContent) => void;
|
|
95
|
+
declare const useSaveExitState: (hook: () => WechatMiniprogram.Page.ISaveExitState) => void;
|
|
96
|
+
declare const useMove: (hook: () => void) => void;
|
|
97
|
+
declare const useError: (hook: (error: Error) => void) => void;
|
|
98
|
+
|
|
99
|
+
export { createApp, createContext, defineComponent, definePage, nextTick, useAddToFavorites, useAppError, useAppHide, useAppShow, useCallback, useContext, useEffect, useEffectEvent, useError, useHide, useMemo, useMove, usePageNotFound, usePageScroll, usePullDownRefresh, useReachBottom, useReducer, useRef, useResize, useRouteDone, useSaveExitState, useShareAppMessage, useShareTimeline, useShow, useState, useTabItemTap, useThemeChange, useUnhandledRejection };
|
|
100
|
+
export type { ActionDispatch, AppOptions, AppRender, ComponentContext, ComponentOptions, ComponentRender, Config, Context, Dispatch, EffectCallback, PageContext, PageOptions, PageRender, Query, RefObject, SetStateAction };
|