rezor 0.1.1 → 0.2.0

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/dist/index.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * rezor v0.1.1
2
+ * rezor v0.2.0
3
3
  * https://github.com/rezorjs/rezor
4
4
  * (c) 2026-present Yang Mingshan
5
5
  * @license MIT
@@ -136,6 +136,9 @@ function exclude(obj, keys) {
136
136
  });
137
137
  return ret;
138
138
  }
139
+ function hasOwn(val, key) {
140
+ return Object.prototype.hasOwnProperty.call(val, key);
141
+ }
139
142
  function isFunction(x) {
140
143
  return typeof x === 'function';
141
144
  }
@@ -691,12 +694,11 @@ function definePage(optionsOrRender, config) {
691
694
  let data;
692
695
  Object.keys(bindings).forEach((key) => {
693
696
  const value = bindings[key];
694
- if (isFunction(value)) {
697
+ if (isFunction(value) && !value.__data__) {
695
698
  this[key] = value;
696
699
  return;
697
700
  }
698
- if (!Object.prototype.hasOwnProperty.call(this.data, key) ||
699
- !Object.is(this.data[key], value)) {
701
+ if (!hasOwn(this.data, key) || !Object.is(this.data[key], value)) {
700
702
  data = data || {};
701
703
  data[key] = value;
702
704
  }
@@ -897,12 +899,11 @@ function defineComponent(optionsOrRender, config) {
897
899
  let data;
898
900
  Object.keys(bindings).forEach((key) => {
899
901
  const value = bindings[key];
900
- if (isFunction(value)) {
902
+ if (isFunction(value) && !value.__data__) {
901
903
  this[key] = value;
902
904
  return;
903
905
  }
904
- if (!Object.prototype.hasOwnProperty.call(this.data, key) ||
905
- !Object.is(this.data[key], value)) {
906
+ if (!hasOwn(this.data, key) || !Object.is(this.data[key], value)) {
906
907
  data = data || {};
907
908
  data[key] = value;
908
909
  }
@@ -1209,10 +1210,23 @@ function createComponentHook(lifecycle) {
1209
1210
  };
1210
1211
  }
1211
1212
 
1213
+ function markData(fn) {
1214
+ // @ts-expect-error
1215
+ if (fn.__data__) {
1216
+ return fn;
1217
+ }
1218
+ // Wrap instead of mutating `fn` so the original stays usable as a method
1219
+ // elsewhere — mutation would route it through setData everywhere it's bound.
1220
+ const marked = (...args) => fn(...args);
1221
+ marked.__data__ = true;
1222
+ return marked;
1223
+ }
1224
+
1212
1225
  exports.createApp = createApp;
1213
1226
  exports.createContext = createContext;
1214
1227
  exports.defineComponent = defineComponent;
1215
1228
  exports.definePage = definePage;
1229
+ exports.markData = markData;
1216
1230
  exports.nextTick = nextTick;
1217
1231
  exports.useAddToFavorites = useAddToFavorites;
1218
1232
  exports.useAppError = useAppError;
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * rezor v0.1.1
2
+ * rezor v0.2.0
3
3
  * https://github.com/rezorjs/rezor
4
4
  * (c) 2026-present Yang Mingshan
5
5
  * @license MIT
6
6
  */
7
- "use strict";let e=null;let t=null;let n=null;function s(){return t||n}function i(){return e||t||n}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 n=e.__lifecycle__;void 0!==n&&t.forEach(e=>{void 0!==n[e]&&(n[e].cursor=0)})}function a(e,t){const n=e.__lifecycle__;void 0!==n&&t.forEach(e=>{void 0!==n[e]&&(n[e].handlers.length=n[e].cursor)})}function O(e,t,n){void 0===e.__lifecycle__&&(e.__lifecycle__={});const s=e.__lifecycle__;void 0===s[t]&&(s[t]={cursor:0,handlers:[]});const i=s[t];i.handlers[i.cursor]=n,i.cursor+=1}function l(e,t){const n=e.__lifecycle__;return void 0===n||void 0===n[t]?0:n[t].cursor}function d(e,t){const n=e.__lifecycle__;return void 0===n||void 0===n[t]?[]:n[t].handlers}const u=Object.assign;function h(e,t){const n={};return Object.keys(e).forEach(s=>{t.includes(s)||(n[s]=e[s])}),n}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 n=0;n<t.length;n++)if(!Object.is(t[n],e[n]))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,v=0,D=0,I=0;const H=Promise.resolve();function m(e){P(e,S,v)&&(v++,R||(R=H.then(L)))}function P(e,t,n){const s=e.flags;return!(s&A.QUEUED)&&(e.flags=s|A.QUEUED,t[n]=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(;D<v;){const e=S[D];S[D++]=void 0,e.flags&A.DISPOSED||(e.flags&=~A.QUEUED,e())}}finally{for(;D<v;)S[D].flags&=~A.QUEUED,S[D++]=void 0;D=0,v=0,R=null}}function C(e,t,n){const s=o(e),i=s.cursor;let r=s.slots[i];return c(r,"memo")?f(r.deps,n)||(r.value=t(),r.deps=n):(r={kind:"memo",value:t(),deps:n},s.slots[i]=r),s.cursor+=1,r.value}function U(e,t,n,s){const i=o(e),r=i.cursor;let _=i.slots[r];if(c(_,"effect")){if(!f(_.deps,s)){_.deps=s;const e=()=>{_.job=void 0,_.cleanup&&_.cleanup(),_.cleanup=n()};_.job=e,t(e)}}else{_={kind:"effect",deps:s,cleanup:void 0},i.slots[r]=_;const e=()=>{_.job=void 0,_.cleanup=n()};_.job=e,t(e)}i.cursor+=1}function x(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 y=[M.ON_SHOW,M.ON_HIDE,M.ON_ERROR,M.ON_PAGE_NOT_FOUND,M.ON_UNHANDLED_REJECTION,M.ON_THEME_CHANGE];function j(e,t){const n=e[t];return function(...e){d(this,t).forEach(t=>t(...e)),void 0!==n&&n.call(this,...e)}}var k;!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"}(k||(k={}));const V=[k.ON_SHOW,k.ON_HIDE,k.ON_ROUTE_DONE,k.ON_PULL_DOWN_REFRESH,k.ON_REACH_BOTTOM,k.ON_PAGE_SCROLL,k.ON_SHARE_APP_MESSAGE,k.ON_SHARE_TIMELINE,k.ON_ADD_TO_FAVORITES,k.ON_RESIZE,k.ON_TAB_ITEM_TAP,k.ON_SAVE_EXIT_STATE];function F(e,t){const n=e[t];return function(...e){d(this,t).forEach(t=>t(...e)),void 0!==n&&n.call(this,...e)}}function G(e,t){return function(...n){const[s]=d(this,e);return s?s(...n):t()}}var B;!function(e){e.ATTACHED="attached",e.READY="ready",e.MOVED="moved",e.DETACHED="detached",e.ERROR="error"}(B||(B={}));const W={[k.ON_SHOW]:"show",[k.ON_HIDE]:"hide",[k.ON_RESIZE]:"resize",[k.ON_ROUTE_DONE]:"routeDone"},Q=[...V,B.MOVED,B.ERROR];function w(e,t){return Y(t,e.lifetimes[t]||e[t])}function X(e,t){return Y(t,e.methods[t])}function Z(e,t){return Y(t,e.pageLifetimes[W[t]])}function Y(e,t){return function(...n){d(this,e).forEach(e=>e(...n)),void 0!==t&&t.call(this,...n)}}function J(e,t){return function(...n){const[s]=d(this,e);return s?s(...n):t()}}const z=Oe(M.ON_SHOW),q=Oe(M.ON_HIDE),K=Oe(M.ON_ERROR),$=Oe(M.ON_PAGE_NOT_FOUND),ee=Oe(M.ON_UNHANDLED_REJECTION),te=Oe(M.ON_THEME_CHANGE),ne=le(k.ON_SHOW),se=le(k.ON_HIDE),ie=le(k.ON_ROUTE_DONE),oe=le(k.ON_PULL_DOWN_REFRESH),re=le(k.ON_REACH_BOTTOM),_e=le(k.ON_RESIZE),ce=le(k.ON_TAB_ITEM_TAP),Ee=de(B.MOVED),ae=de(B.ERROR);function Oe(t){return n=>{e&&O(e,t,n)}}function le(e){return t=>{const n=s();n&&O(n,e,t)}}function de(e){return t=>{n&&O(n,e,t)}}exports.createApp=function(t){let n,s;if(N(t))n=t,s={};else{if(void 0===t.render)return void App(t);n=t.render,s=h(t,["render"])}const i=s[M.ON_LAUNCH];s[M.ON_LAUNCH]=function(t){this.__render__=()=>{let s;e=this,r(this),E(this,y);try{s=n(t)}finally{e=null}_(this),a(this,y),void 0!==s&&Object.keys(s).forEach(e=>{this[e]=s[e]})},this.__render__(),void 0!==i&&i.call(this,t)},s[M.ON_SHOW]=j(s,M.ON_SHOW),s[M.ON_HIDE]=j(s,M.ON_HIDE),s[M.ON_ERROR]=j(s,M.ON_ERROR),s[M.ON_PAGE_NOT_FOUND]=j(s,M.ON_PAGE_NOT_FOUND),s[M.ON_UNHANDLED_REJECTION]=j(s,M.ON_UNHANDLED_REJECTION),s[M.ON_THEME_CHANGE]=j(s,M.ON_THEME_CHANGE),App(s)},exports.createContext=function(e){return{defaultValue:e,currentValue:e,subscribers:new Set,provider:null}},exports.defineComponent=function(e,t){let s,i;t=u({listenPageScroll:!1,canShareToOthers:!1,canShareToTimeline:!1},t);let c=null;if(N(e))s=e,i={};else{if(void 0===e.render)return Component(e);s=e.render,i=h(e,["render"]),i.properties&&(c=Object.keys(i.properties))}void 0===i.lifetimes&&(i.lifetimes={});const O=i.lifetimes[B.ATTACHED]||i[B.ATTACHED];i.lifetimes[B.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__=()=>{let t;n=this,r(this),E(this,Q);try{t=s(this.__props__,e)}finally{n=null}if(_(this),a(this,Q),void 0!==t){let e;Object.keys(t).forEach(n=>{const s=t[n];N(s)?this[n]=s:Object.prototype.hasOwnProperty.call(this.data,n)&&Object.is(this.data[n],s)||(e=e||{},e[n]=s)}),void 0!==e&&this.setData(e,g)}},this.__render__(),void 0!==O&&O.call(this)};const l=i.lifetimes[B.READY]||i[B.READY];i.lifetimes[B.READY]=function(){g(),void 0!==l&&l.call(this)};const d=i.lifetimes[B.DETACHED]||i[B.DETACHED];return i.lifetimes[B.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!==d&&d.call(this)},i.lifetimes[B.MOVED]=w(i,B.MOVED),i.lifetimes[B.ERROR]=w(i,B.ERROR),void 0===i.methods&&(i.methods={}),(i.methods[k.ON_PAGE_SCROLL]||t.listenPageScroll)&&(i.methods[k.ON_PAGE_SCROLL]=X(i,k.ON_PAGE_SCROLL),i.methods.__listenPageScroll__=()=>!0),void 0===i.methods[k.ON_SHARE_APP_MESSAGE]&&t.canShareToOthers&&(i.methods[k.ON_SHARE_APP_MESSAGE]=J(k.ON_SHARE_APP_MESSAGE,()=>({})),i.methods.__isInjectedShareToOthersHook__=()=>!0),void 0===i.methods[k.ON_SHARE_TIMELINE]&&t.canShareToTimeline&&(i.methods[k.ON_SHARE_TIMELINE]=J(k.ON_SHARE_TIMELINE,()=>({})),i.methods.__isInjectedShareToTimelineHook__=()=>!0),void 0===i.methods[k.ON_ADD_TO_FAVORITES]&&(i.methods[k.ON_ADD_TO_FAVORITES]=J(k.ON_ADD_TO_FAVORITES,()=>({})),i.methods.__isInjectedFavoritesHook__=()=>!0),void 0===i.methods[k.ON_SAVE_EXIT_STATE]&&(i.methods[k.ON_SAVE_EXIT_STATE]=J(k.ON_SAVE_EXIT_STATE,()=>({data:void 0})),i.methods.__isInjectedExitStateHook__=()=>!0),i.methods[k.ON_PULL_DOWN_REFRESH]=X(i,k.ON_PULL_DOWN_REFRESH),i.methods[k.ON_REACH_BOTTOM]=X(i,k.ON_REACH_BOTTOM),i.methods[k.ON_TAB_ITEM_TAP]=X(i,k.ON_TAB_ITEM_TAP),void 0===i.pageLifetimes&&(i.pageLifetimes={}),i.pageLifetimes[W[k.ON_SHOW]]=Z(i,k.ON_SHOW),i.pageLifetimes[W[k.ON_HIDE]]=Z(i,k.ON_HIDE),i.pageLifetimes[W[k.ON_RESIZE]]=Z(i,k.ON_RESIZE),i.pageLifetimes[W[k.ON_ROUTE_DONE]]=Z(i,k.ON_ROUTE_DONE),c&&(void 0===i.observers&&(i.observers={}),c.forEach(e=>{const t=i.observers[e];i.observers[e]=function(n){this.__props__&&(this.__props__=u({},this.__props__,{[e]:n})),this.__render__&&m(this.__render__),void 0!==t&&t.call(this,n)}})),Component(i)},exports.definePage=function(e,n){let s,i;if(n=u({listenPageScroll:!1,canShareToOthers:!1,canShareToTimeline:!1},n),N(e))s=e,i={};else{if(void 0===e.render)return void Page(e);s=e.render,i=h(e,["render"])}const c=i[k.ON_LOAD];i[k.ON_LOAD]=function(e){const n={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__=()=>{let i;t=this,r(this),E(this,V);try{i=s(e,n)}finally{t=null}if(_(this),a(this,V),void 0!==i){let e;Object.keys(i).forEach(t=>{const n=i[t];N(n)?this[t]=n:Object.prototype.hasOwnProperty.call(this.data,t)&&Object.is(this.data[t],n)||(e=e||{},e[t]=n)}),void 0!==e&&this.setData(e,g)}},this.__render__(),void 0!==c&&c.call(this,e)};const O=i[k.ON_READY];i[k.ON_READY]=function(){g(),void 0!==O&&O.call(this)};const l=i[k.ON_UNLOAD];i[k.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[k.ON_PAGE_SCROLL]||n.listenPageScroll)&&(i[k.ON_PAGE_SCROLL]=F(i,k.ON_PAGE_SCROLL),i.__listenPageScroll__=()=>!0),void 0===i[k.ON_SHARE_APP_MESSAGE]&&n.canShareToOthers&&(i[k.ON_SHARE_APP_MESSAGE]=G(k.ON_SHARE_APP_MESSAGE,()=>({})),i.__isInjectedShareToOthersHook__=()=>!0),void 0===i[k.ON_SHARE_TIMELINE]&&n.canShareToTimeline&&(i[k.ON_SHARE_TIMELINE]=G(k.ON_SHARE_TIMELINE,()=>({})),i.__isInjectedShareToTimelineHook__=()=>!0),void 0===i[k.ON_ADD_TO_FAVORITES]&&(i[k.ON_ADD_TO_FAVORITES]=G(k.ON_ADD_TO_FAVORITES,()=>({})),i.__isInjectedFavoritesHook__=()=>!0),void 0===i[k.ON_SAVE_EXIT_STATE]&&(i[k.ON_SAVE_EXIT_STATE]=G(k.ON_SAVE_EXIT_STATE,()=>({data:void 0})),i.__isInjectedExitStateHook__=()=>!0),i[k.ON_SHOW]=F(i,k.ON_SHOW),i[k.ON_HIDE]=F(i,k.ON_HIDE),i[k.ON_ROUTE_DONE]=F(i,k.ON_ROUTE_DONE),i[k.ON_PULL_DOWN_REFRESH]=F(i,k.ON_PULL_DOWN_REFRESH),i[k.ON_REACH_BOTTOM]=F(i,k.ON_REACH_BOTTOM),i[k.ON_RESIZE]=F(i,k.ON_RESIZE),i[k.ON_TAB_ITEM_TAP]=F(i,k.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=s();if(t&&t.__isInjectedFavoritesHook__){0===l(t,k.ON_ADD_TO_FAVORITES)&&O(t,k.ON_ADD_TO_FAVORITES,e)}},exports.useAppError=K,exports.useAppHide=q,exports.useAppShow=z,exports.useCallback=function(e,t){const n=i();return n?C(n,()=>e,t):e},exports.useContext=function(e,t){const n=i();if(n){const s=o(n),i=s.cursor;if(arguments.length>=2)return c(s.slots[i],"context")||(s.slots[i]={kind:"context",cleanup:()=>{e.provider===n&&(e.provider=null,Object.is(e.currentValue,e.defaultValue)||(e.currentValue=e.defaultValue,x(e)))}}),null!==e.provider&&e.provider!==n||(e.provider=n,Object.is(e.currentValue,t)||(e.currentValue=t,x(e))),void(s.cursor+=1);const r=n.__render__;return c(s.slots[i],"context")||(s.slots[i]={kind:"context",cleanup(){e.subscribers.delete(r)}}),e.subscribers.add(r),s.cursor+=1,e.currentValue}return e.currentValue},exports.useEffect=function(e,t){const n=i();n&&U(n,b,e,t)},exports.useEffectEvent=function(e){const t=i();if(t){const n=o(t),s=n.cursor;let i=n.slots[s];return c(i,"effectEvent")?i.fn=e:(i={kind:"effectEvent",fn:e},n.slots[s]=i),n.cursor+=1,(...e)=>i.fn(...e)}return e},exports.useError=ae,exports.useHide=se,exports.useMemo=function(e,t){const n=i();return n?C(n,e,t):e()},exports.useMove=Ee,exports.usePageNotFound=$,exports.usePageScroll=e=>{const t=s();t&&t.__listenPageScroll__&&O(t,k.ON_PAGE_SCROLL,e)},exports.usePullDownRefresh=oe,exports.useReachBottom=re,exports.useReducer=function(e,t,n){const s=()=>void 0===n?t:n(t),r=i();if(r){const t=o(r),n=t.cursor;let i=t.slots[n];if(c(i,"reducer"))i.reducer=e;else{const o=e=>{const t=i.value,n=i.reducer(t,e);Object.is(t,n)||(i.value=n,m(r.__render__))};i={kind:"reducer",value:s(),reducer:e,dispatch:o},t.slots[n]=i}return t.cursor+=1,[i.value,i.dispatch]}return[s(),()=>{}]},exports.useRef=function(e){const t=i();if(t){const n=o(t),s=n.cursor;let i=n.slots[s];return c(i,"ref")||(i={kind:"ref",ref:{current:e}},n.slots[s]=i),n.cursor+=1,i.ref}return{current:e}},exports.useRenderEffect=function(e,t){const n=i();n&&U(n,m,e,t)},exports.useResize=_e,exports.useRouteDone=ie,exports.useSaveExitState=e=>{const t=s();if(t&&t.__isInjectedExitStateHook__){0===l(t,k.ON_SAVE_EXIT_STATE)&&O(t,k.ON_SAVE_EXIT_STATE,e)}},exports.useShareAppMessage=e=>{const t=s();if(t&&t.__isInjectedShareToOthersHook__){0===l(t,k.ON_SHARE_APP_MESSAGE)&&O(t,k.ON_SHARE_APP_MESSAGE,e)}},exports.useShareTimeline=e=>{const t=s();if(t&&t.__isInjectedShareToTimelineHook__){0===l(t,k.ON_SHARE_TIMELINE)&&O(t,k.ON_SHARE_TIMELINE,e)}},exports.useShow=ne,exports.useState=function(e){const t=()=>N(e)?e():e,n=i();if(n){const e=o(n),s=e.cursor;let i=e.slots[s];if(!c(i,"state")){const o=e=>{const t=i.value,s=N(e)?e(t):e;Object.is(t,s)||(i.value=s,m(n.__render__))};i={kind:"state",value:t(),setState:o},e.slots[s]=i}return e.cursor+=1,[i.value,i.setState]}return[t(),()=>{}]},exports.useTabItemTap=ce,exports.useThemeChange=te,exports.useUnhandledRejection=ee;
7
+ "use strict";let e=null;let t=null;let n=null;function s(){return t||n}function i(){return e||t||n}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 a(e,t){const n=e.__lifecycle__;void 0!==n&&t.forEach(e=>{void 0!==n[e]&&(n[e].cursor=0)})}function E(e,t){const n=e.__lifecycle__;void 0!==n&&t.forEach(e=>{void 0!==n[e]&&(n[e].handlers.length=n[e].cursor)})}function O(e,t,n){void 0===e.__lifecycle__&&(e.__lifecycle__={});const s=e.__lifecycle__;void 0===s[t]&&(s[t]={cursor:0,handlers:[]});const i=s[t];i.handlers[i.cursor]=n,i.cursor+=1}function l(e,t){const n=e.__lifecycle__;return void 0===n||void 0===n[t]?0:n[t].cursor}function d(e,t){const n=e.__lifecycle__;return void 0===n||void 0===n[t]?[]:n[t].handlers}const u=Object.assign;function h(e,t){const n={};return Object.keys(e).forEach(s=>{t.includes(s)||(n[s]=e[s])}),n}function N(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function f(e){return"function"==typeof e}function A(e,t){if(void 0===e||void 0===t)return!1;if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!Object.is(t[n],e[n]))return!1;return!0}var S;!function(e){e[e.QUEUED=1]="QUEUED",e[e.DISPOSED=2]="DISPOSED"}(S||(S={}));const T=[];let p=[],R=null,v=null,D=0,I=0,H=0;const m=Promise.resolve();function P(e){b(e,T,D)&&(D++,v||(v=m.then(C)))}function b(e,t,n){const s=e.flags;return!(s&S.QUEUED)&&(e.flags=s|S.QUEUED,t[n]=e,!0)}function g(e){b(e,p,p.length)}function L(){if(p.length){R=p,p=[];try{for(;H<R.length;){const e=R[H++];e.flags&S.DISPOSED||(e.flags&=~S.QUEUED,e())}}finally{for(;H<R.length;)R[H++].flags&=~S.QUEUED;R=null,H=0}}}function C(){try{for(;I<D;){const e=T[I];T[I++]=void 0,e.flags&S.DISPOSED||(e.flags&=~S.QUEUED,e())}}finally{for(;I<D;)T[I].flags&=~S.QUEUED,T[I++]=void 0;I=0,D=0,v=null}}function U(e,t,n){const s=o(e),i=s.cursor;let r=s.slots[i];return c(r,"memo")?A(r.deps,n)||(r.value=t(),r.deps=n):(r={kind:"memo",value:t(),deps:n},s.slots[i]=r),s.cursor+=1,r.value}function x(e,t,n,s){const i=o(e),r=i.cursor;let _=i.slots[r];if(c(_,"effect")){if(!A(_.deps,s)){_.deps=s;const e=()=>{_.job=void 0,_.cleanup&&_.cleanup(),_.cleanup=n()};_.job=e,t(e)}}else{_={kind:"effect",deps:s,cleanup:void 0},i.slots[r]=_;const e=()=>{_.job=void 0,_.cleanup=n()};_.job=e,t(e)}i.cursor+=1}function M(e){e.subscribers.forEach(e=>{P(e)})}var y;!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"}(y||(y={}));const j=[y.ON_SHOW,y.ON_HIDE,y.ON_ERROR,y.ON_PAGE_NOT_FOUND,y.ON_UNHANDLED_REJECTION,y.ON_THEME_CHANGE];function k(e,t){const n=e[t];return function(...e){d(this,t).forEach(t=>t(...e)),void 0!==n&&n.call(this,...e)}}var V;!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"}(V||(V={}));const F=[V.ON_SHOW,V.ON_HIDE,V.ON_ROUTE_DONE,V.ON_PULL_DOWN_REFRESH,V.ON_REACH_BOTTOM,V.ON_PAGE_SCROLL,V.ON_SHARE_APP_MESSAGE,V.ON_SHARE_TIMELINE,V.ON_ADD_TO_FAVORITES,V.ON_RESIZE,V.ON_TAB_ITEM_TAP,V.ON_SAVE_EXIT_STATE];function G(e,t){const n=e[t];return function(...e){d(this,t).forEach(t=>t(...e)),void 0!==n&&n.call(this,...e)}}function B(e,t){return function(...n){const[s]=d(this,e);return s?s(...n):t()}}var W;!function(e){e.ATTACHED="attached",e.READY="ready",e.MOVED="moved",e.DETACHED="detached",e.ERROR="error"}(W||(W={}));const Q={[V.ON_SHOW]:"show",[V.ON_HIDE]:"hide",[V.ON_RESIZE]:"resize",[V.ON_ROUTE_DONE]:"routeDone"},w=[...F,W.MOVED,W.ERROR];function X(e,t){return J(t,e.lifetimes[t]||e[t])}function Z(e,t){return J(t,e.methods[t])}function Y(e,t){return J(t,e.pageLifetimes[Q[t]])}function J(e,t){return function(...n){d(this,e).forEach(e=>e(...n)),void 0!==t&&t.call(this,...n)}}function z(e,t){return function(...n){const[s]=d(this,e);return s?s(...n):t()}}const q=le(y.ON_SHOW),K=le(y.ON_HIDE),$=le(y.ON_ERROR),ee=le(y.ON_PAGE_NOT_FOUND),te=le(y.ON_UNHANDLED_REJECTION),ne=le(y.ON_THEME_CHANGE),se=de(V.ON_SHOW),ie=de(V.ON_HIDE),oe=de(V.ON_ROUTE_DONE),re=de(V.ON_PULL_DOWN_REFRESH),_e=de(V.ON_REACH_BOTTOM),ce=de(V.ON_RESIZE),ae=de(V.ON_TAB_ITEM_TAP),Ee=ue(W.MOVED),Oe=ue(W.ERROR);function le(t){return n=>{e&&O(e,t,n)}}function de(e){return t=>{const n=s();n&&O(n,e,t)}}function ue(e){return t=>{n&&O(n,e,t)}}exports.createApp=function(t){let n,s;if(f(t))n=t,s={};else{if(void 0===t.render)return void App(t);n=t.render,s=h(t,["render"])}const i=s[y.ON_LAUNCH];s[y.ON_LAUNCH]=function(t){this.__render__=()=>{let s;e=this,r(this),a(this,j);try{s=n(t)}finally{e=null}_(this),E(this,j),void 0!==s&&Object.keys(s).forEach(e=>{this[e]=s[e]})},this.__render__(),void 0!==i&&i.call(this,t)},s[y.ON_SHOW]=k(s,y.ON_SHOW),s[y.ON_HIDE]=k(s,y.ON_HIDE),s[y.ON_ERROR]=k(s,y.ON_ERROR),s[y.ON_PAGE_NOT_FOUND]=k(s,y.ON_PAGE_NOT_FOUND),s[y.ON_UNHANDLED_REJECTION]=k(s,y.ON_UNHANDLED_REJECTION),s[y.ON_THEME_CHANGE]=k(s,y.ON_THEME_CHANGE),App(s)},exports.createContext=function(e){return{defaultValue:e,currentValue:e,subscribers:new Set,provider:null}},exports.defineComponent=function(e,t){let s,i;t=u({listenPageScroll:!1,canShareToOthers:!1,canShareToTimeline:!1},t);let c=null;if(f(e))s=e,i={};else{if(void 0===e.render)return Component(e);s=e.render,i=h(e,["render"]),i.properties&&(c=Object.keys(i.properties))}void 0===i.lifetimes&&(i.lifetimes={});const O=i.lifetimes[W.ATTACHED]||i[W.ATTACHED];i.lifetimes[W.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__=()=>{let t;n=this,r(this),a(this,w);try{t=s(this.__props__,e)}finally{n=null}if(_(this),E(this,w),void 0!==t){let e;Object.keys(t).forEach(n=>{const s=t[n];!f(s)||s.__data__?N(this.data,n)&&Object.is(this.data[n],s)||(e=e||{},e[n]=s):this[n]=s}),void 0!==e&&this.setData(e,L)}},this.__render__(),void 0!==O&&O.call(this)};const l=i.lifetimes[W.READY]||i[W.READY];i.lifetimes[W.READY]=function(){L(),void 0!==l&&l.call(this)};const d=i.lifetimes[W.DETACHED]||i[W.DETACHED];return i.lifetimes[W.DETACHED]=function(){this.__render__.flags|=S.DISPOSED;o(this).slots.forEach(e=>{"effect"===e.kind?(e.job&&(e.job.flags|=S.DISPOSED,e.job=void 0),e.cleanup&&e.cleanup()):"context"===e.kind&&e.cleanup()}),void 0!==d&&d.call(this)},i.lifetimes[W.MOVED]=X(i,W.MOVED),i.lifetimes[W.ERROR]=X(i,W.ERROR),void 0===i.methods&&(i.methods={}),(i.methods[V.ON_PAGE_SCROLL]||t.listenPageScroll)&&(i.methods[V.ON_PAGE_SCROLL]=Z(i,V.ON_PAGE_SCROLL),i.methods.__listenPageScroll__=()=>!0),void 0===i.methods[V.ON_SHARE_APP_MESSAGE]&&t.canShareToOthers&&(i.methods[V.ON_SHARE_APP_MESSAGE]=z(V.ON_SHARE_APP_MESSAGE,()=>({})),i.methods.__isInjectedShareToOthersHook__=()=>!0),void 0===i.methods[V.ON_SHARE_TIMELINE]&&t.canShareToTimeline&&(i.methods[V.ON_SHARE_TIMELINE]=z(V.ON_SHARE_TIMELINE,()=>({})),i.methods.__isInjectedShareToTimelineHook__=()=>!0),void 0===i.methods[V.ON_ADD_TO_FAVORITES]&&(i.methods[V.ON_ADD_TO_FAVORITES]=z(V.ON_ADD_TO_FAVORITES,()=>({})),i.methods.__isInjectedFavoritesHook__=()=>!0),void 0===i.methods[V.ON_SAVE_EXIT_STATE]&&(i.methods[V.ON_SAVE_EXIT_STATE]=z(V.ON_SAVE_EXIT_STATE,()=>({data:void 0})),i.methods.__isInjectedExitStateHook__=()=>!0),i.methods[V.ON_PULL_DOWN_REFRESH]=Z(i,V.ON_PULL_DOWN_REFRESH),i.methods[V.ON_REACH_BOTTOM]=Z(i,V.ON_REACH_BOTTOM),i.methods[V.ON_TAB_ITEM_TAP]=Z(i,V.ON_TAB_ITEM_TAP),void 0===i.pageLifetimes&&(i.pageLifetimes={}),i.pageLifetimes[Q[V.ON_SHOW]]=Y(i,V.ON_SHOW),i.pageLifetimes[Q[V.ON_HIDE]]=Y(i,V.ON_HIDE),i.pageLifetimes[Q[V.ON_RESIZE]]=Y(i,V.ON_RESIZE),i.pageLifetimes[Q[V.ON_ROUTE_DONE]]=Y(i,V.ON_ROUTE_DONE),c&&(void 0===i.observers&&(i.observers={}),c.forEach(e=>{const t=i.observers[e];i.observers[e]=function(n){this.__props__&&(this.__props__=u({},this.__props__,{[e]:n})),this.__render__&&P(this.__render__),void 0!==t&&t.call(this,n)}})),Component(i)},exports.definePage=function(e,n){let s,i;if(n=u({listenPageScroll:!1,canShareToOthers:!1,canShareToTimeline:!1},n),f(e))s=e,i={};else{if(void 0===e.render)return void Page(e);s=e.render,i=h(e,["render"])}const c=i[V.ON_LOAD];i[V.ON_LOAD]=function(e){const n={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__=()=>{let i;t=this,r(this),a(this,F);try{i=s(e,n)}finally{t=null}if(_(this),E(this,F),void 0!==i){let e;Object.keys(i).forEach(t=>{const n=i[t];!f(n)||n.__data__?N(this.data,t)&&Object.is(this.data[t],n)||(e=e||{},e[t]=n):this[t]=n}),void 0!==e&&this.setData(e,L)}},this.__render__(),void 0!==c&&c.call(this,e)};const O=i[V.ON_READY];i[V.ON_READY]=function(){L(),void 0!==O&&O.call(this)};const l=i[V.ON_UNLOAD];i[V.ON_UNLOAD]=function(){this.__render__.flags|=S.DISPOSED;o(this).slots.forEach(e=>{"effect"===e.kind?(e.job&&(e.job.flags|=S.DISPOSED,e.job=void 0),e.cleanup&&e.cleanup()):"context"===e.kind&&e.cleanup()}),void 0!==l&&l.call(this)},(i[V.ON_PAGE_SCROLL]||n.listenPageScroll)&&(i[V.ON_PAGE_SCROLL]=G(i,V.ON_PAGE_SCROLL),i.__listenPageScroll__=()=>!0),void 0===i[V.ON_SHARE_APP_MESSAGE]&&n.canShareToOthers&&(i[V.ON_SHARE_APP_MESSAGE]=B(V.ON_SHARE_APP_MESSAGE,()=>({})),i.__isInjectedShareToOthersHook__=()=>!0),void 0===i[V.ON_SHARE_TIMELINE]&&n.canShareToTimeline&&(i[V.ON_SHARE_TIMELINE]=B(V.ON_SHARE_TIMELINE,()=>({})),i.__isInjectedShareToTimelineHook__=()=>!0),void 0===i[V.ON_ADD_TO_FAVORITES]&&(i[V.ON_ADD_TO_FAVORITES]=B(V.ON_ADD_TO_FAVORITES,()=>({})),i.__isInjectedFavoritesHook__=()=>!0),void 0===i[V.ON_SAVE_EXIT_STATE]&&(i[V.ON_SAVE_EXIT_STATE]=B(V.ON_SAVE_EXIT_STATE,()=>({data:void 0})),i.__isInjectedExitStateHook__=()=>!0),i[V.ON_SHOW]=G(i,V.ON_SHOW),i[V.ON_HIDE]=G(i,V.ON_HIDE),i[V.ON_ROUTE_DONE]=G(i,V.ON_ROUTE_DONE),i[V.ON_PULL_DOWN_REFRESH]=G(i,V.ON_PULL_DOWN_REFRESH),i[V.ON_REACH_BOTTOM]=G(i,V.ON_REACH_BOTTOM),i[V.ON_RESIZE]=G(i,V.ON_RESIZE),i[V.ON_TAB_ITEM_TAP]=G(i,V.ON_TAB_ITEM_TAP),Page(i)},exports.markData=function(e){if(e.__data__)return e;const t=(...t)=>e(...t);return t.__data__=!0,t},exports.nextTick=function(e){const t=v||m;return e?t.then(e):t},exports.useAddToFavorites=e=>{const t=s();if(t&&t.__isInjectedFavoritesHook__){0===l(t,V.ON_ADD_TO_FAVORITES)&&O(t,V.ON_ADD_TO_FAVORITES,e)}},exports.useAppError=$,exports.useAppHide=K,exports.useAppShow=q,exports.useCallback=function(e,t){const n=i();return n?U(n,()=>e,t):e},exports.useContext=function(e,t){const n=i();if(n){const s=o(n),i=s.cursor;if(arguments.length>=2)return c(s.slots[i],"context")||(s.slots[i]={kind:"context",cleanup:()=>{e.provider===n&&(e.provider=null,Object.is(e.currentValue,e.defaultValue)||(e.currentValue=e.defaultValue,M(e)))}}),null!==e.provider&&e.provider!==n||(e.provider=n,Object.is(e.currentValue,t)||(e.currentValue=t,M(e))),void(s.cursor+=1);const r=n.__render__;return c(s.slots[i],"context")||(s.slots[i]={kind:"context",cleanup(){e.subscribers.delete(r)}}),e.subscribers.add(r),s.cursor+=1,e.currentValue}return e.currentValue},exports.useEffect=function(e,t){const n=i();n&&x(n,g,e,t)},exports.useEffectEvent=function(e){const t=i();if(t){const n=o(t),s=n.cursor;let i=n.slots[s];return c(i,"effectEvent")?i.fn=e:(i={kind:"effectEvent",fn:e},n.slots[s]=i),n.cursor+=1,(...e)=>i.fn(...e)}return e},exports.useError=Oe,exports.useHide=ie,exports.useMemo=function(e,t){const n=i();return n?U(n,e,t):e()},exports.useMove=Ee,exports.usePageNotFound=ee,exports.usePageScroll=e=>{const t=s();t&&t.__listenPageScroll__&&O(t,V.ON_PAGE_SCROLL,e)},exports.usePullDownRefresh=re,exports.useReachBottom=_e,exports.useReducer=function(e,t,n){const s=()=>void 0===n?t:n(t),r=i();if(r){const t=o(r),n=t.cursor;let i=t.slots[n];if(c(i,"reducer"))i.reducer=e;else{const o=e=>{const t=i.value,n=i.reducer(t,e);Object.is(t,n)||(i.value=n,P(r.__render__))};i={kind:"reducer",value:s(),reducer:e,dispatch:o},t.slots[n]=i}return t.cursor+=1,[i.value,i.dispatch]}return[s(),()=>{}]},exports.useRef=function(e){const t=i();if(t){const n=o(t),s=n.cursor;let i=n.slots[s];return c(i,"ref")||(i={kind:"ref",ref:{current:e}},n.slots[s]=i),n.cursor+=1,i.ref}return{current:e}},exports.useRenderEffect=function(e,t){const n=i();n&&x(n,P,e,t)},exports.useResize=ce,exports.useRouteDone=oe,exports.useSaveExitState=e=>{const t=s();if(t&&t.__isInjectedExitStateHook__){0===l(t,V.ON_SAVE_EXIT_STATE)&&O(t,V.ON_SAVE_EXIT_STATE,e)}},exports.useShareAppMessage=e=>{const t=s();if(t&&t.__isInjectedShareToOthersHook__){0===l(t,V.ON_SHARE_APP_MESSAGE)&&O(t,V.ON_SHARE_APP_MESSAGE,e)}},exports.useShareTimeline=e=>{const t=s();if(t&&t.__isInjectedShareToTimelineHook__){0===l(t,V.ON_SHARE_TIMELINE)&&O(t,V.ON_SHARE_TIMELINE,e)}},exports.useShow=se,exports.useState=function(e){const t=()=>f(e)?e():e,n=i();if(n){const e=o(n),s=e.cursor;let i=e.slots[s];if(!c(i,"state")){const o=e=>{const t=i.value,s=f(e)?e(t):e;Object.is(t,s)||(i.value=s,P(n.__render__))};i={kind:"state",value:t(),setState:o},e.slots[s]=i}return e.cursor+=1,[i.value,i.setState]}return[t(),()=>{}]},exports.useTabItemTap=ae,exports.useThemeChange=ne,exports.useUnhandledRejection=te;
package/dist/index.d.ts CHANGED
@@ -115,5 +115,7 @@ declare const useSaveExitState: (hook: () => WechatMiniprogram.Page.ISaveExitSta
115
115
  declare const useMove: (hook: () => void) => void;
116
116
  declare const useError: (hook: (error: Error) => void) => void;
117
117
 
118
- export { createApp, createContext, defineComponent, definePage, nextTick, useAddToFavorites, useAppError, useAppHide, useAppShow, useCallback, useContext, useEffect, useEffectEvent, useError, useHide, useMemo, useMove, usePageNotFound, usePageScroll, usePullDownRefresh, useReachBottom, useReducer, useRef, useRenderEffect, useResize, useRouteDone, useSaveExitState, useShareAppMessage, useShareTimeline, useShow, useState, useTabItemTap, useThemeChange, useUnhandledRejection };
118
+ declare function markData<T extends Function>(fn: T): T;
119
+
120
+ export { createApp, createContext, defineComponent, definePage, markData, nextTick, useAddToFavorites, useAppError, useAppHide, useAppShow, useCallback, useContext, useEffect, useEffectEvent, useError, useHide, useMemo, useMove, usePageNotFound, usePageScroll, usePullDownRefresh, useReachBottom, useReducer, useRef, useRenderEffect, useResize, useRouteDone, useSaveExitState, useShareAppMessage, useShareTimeline, useShow, useState, useTabItemTap, useThemeChange, useUnhandledRejection };
119
121
  export type { ActionDispatch, AppOptions, AppRender, ComponentContext, ComponentOptions, ComponentRender, Config, Context, Dispatch, EffectCallback, PageContext, PageOptions, PageRender, Query, RefObject, SetStateAction };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * rezor v0.1.1
2
+ * rezor v0.2.0
3
3
  * https://github.com/rezorjs/rezor
4
4
  * (c) 2026-present Yang Mingshan
5
5
  * @license MIT
@@ -134,6 +134,9 @@ function exclude(obj, keys) {
134
134
  });
135
135
  return ret;
136
136
  }
137
+ function hasOwn(val, key) {
138
+ return Object.prototype.hasOwnProperty.call(val, key);
139
+ }
137
140
  function isFunction(x) {
138
141
  return typeof x === 'function';
139
142
  }
@@ -689,12 +692,11 @@ function definePage(optionsOrRender, config) {
689
692
  let data;
690
693
  Object.keys(bindings).forEach((key) => {
691
694
  const value = bindings[key];
692
- if (isFunction(value)) {
695
+ if (isFunction(value) && !value.__data__) {
693
696
  this[key] = value;
694
697
  return;
695
698
  }
696
- if (!Object.prototype.hasOwnProperty.call(this.data, key) ||
697
- !Object.is(this.data[key], value)) {
699
+ if (!hasOwn(this.data, key) || !Object.is(this.data[key], value)) {
698
700
  data = data || {};
699
701
  data[key] = value;
700
702
  }
@@ -895,12 +897,11 @@ function defineComponent(optionsOrRender, config) {
895
897
  let data;
896
898
  Object.keys(bindings).forEach((key) => {
897
899
  const value = bindings[key];
898
- if (isFunction(value)) {
900
+ if (isFunction(value) && !value.__data__) {
899
901
  this[key] = value;
900
902
  return;
901
903
  }
902
- if (!Object.prototype.hasOwnProperty.call(this.data, key) ||
903
- !Object.is(this.data[key], value)) {
904
+ if (!hasOwn(this.data, key) || !Object.is(this.data[key], value)) {
904
905
  data = data || {};
905
906
  data[key] = value;
906
907
  }
@@ -1207,4 +1208,16 @@ function createComponentHook(lifecycle) {
1207
1208
  };
1208
1209
  }
1209
1210
 
1210
- export { createApp, createContext, defineComponent, definePage, nextTick, useAddToFavorites, useAppError, useAppHide, useAppShow, useCallback, useContext, useEffect, useEffectEvent, useError, useHide, useMemo, useMove, usePageNotFound, usePageScroll, usePullDownRefresh, useReachBottom, useReducer, useRef, useRenderEffect, useResize, useRouteDone, useSaveExitState, useShareAppMessage, useShareTimeline, useShow, useState, useTabItemTap, useThemeChange, useUnhandledRejection };
1211
+ function markData(fn) {
1212
+ // @ts-expect-error
1213
+ if (fn.__data__) {
1214
+ return fn;
1215
+ }
1216
+ // Wrap instead of mutating `fn` so the original stays usable as a method
1217
+ // elsewhere — mutation would route it through setData everywhere it's bound.
1218
+ const marked = (...args) => fn(...args);
1219
+ marked.__data__ = true;
1220
+ return marked;
1221
+ }
1222
+
1223
+ export { createApp, createContext, defineComponent, definePage, markData, nextTick, useAddToFavorites, useAppError, useAppHide, useAppShow, useCallback, useContext, useEffect, useEffectEvent, useError, useHide, useMemo, useMove, usePageNotFound, usePageScroll, usePullDownRefresh, useReachBottom, useReducer, useRef, useRenderEffect, useResize, useRouteDone, useSaveExitState, useShareAppMessage, useShareTimeline, useShow, useState, useTabItemTap, useThemeChange, useUnhandledRejection };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rezor",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "拥有原生性能的 React 小程序框架。",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm-bundler.js",