rezor 0.0.1 → 0.0.2

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.0.1
2
+ * rezor v0.0.2
3
3
  * https://github.com/rezorjs/rezor
4
4
  * (c) 2026-present Yang Mingshan
5
5
  * @license MIT
@@ -298,43 +298,6 @@ function useState(initialState) {
298
298
  return [getState(), () => { }];
299
299
  }
300
300
 
301
- function useEffect(callback, deps) {
302
- const currentInstance = getCurrentInstanceAll();
303
- if (currentInstance) {
304
- const store = getHooksStore(currentInstance);
305
- const index = store.cursor;
306
- let effectSlot = store.slots[index];
307
- if (!isHookKind(effectSlot, 'effect')) {
308
- effectSlot = { kind: 'effect', deps, cleanup: undefined };
309
- store.slots[index] = effectSlot;
310
- const job = () => {
311
- effectSlot.job = undefined;
312
- effectSlot.cleanup = callback();
313
- };
314
- effectSlot.job = job;
315
- queuePostFlushCb(job);
316
- }
317
- else if (!areHookDepsEqual(effectSlot.deps, deps)) {
318
- effectSlot.deps = deps;
319
- const job = () => {
320
- effectSlot.job = undefined;
321
- if (effectSlot.cleanup) {
322
- effectSlot.cleanup();
323
- }
324
- effectSlot.cleanup = callback();
325
- };
326
- effectSlot.job = job;
327
- queuePostFlushCb(job);
328
- }
329
- store.cursor += 1;
330
- return;
331
- }
332
- /* istanbul ignore else -- @preserve */
333
- {
334
- console.warn('useEffect() hook can only be called during execution of render().');
335
- }
336
- }
337
-
338
301
  function useReducer(reducer, initialArg, init) {
339
302
  const getState = () => init === undefined ? initialArg : init(initialArg);
340
303
  const currentInstance = getCurrentInstanceAll();
@@ -430,11 +393,63 @@ function useEffectEvent(callback) {
430
393
  return callback;
431
394
  }
432
395
 
396
+ function effectImpl(currentInstance, queue, callback, deps) {
397
+ const store = getHooksStore(currentInstance);
398
+ const index = store.cursor;
399
+ let effectSlot = store.slots[index];
400
+ if (!isHookKind(effectSlot, 'effect')) {
401
+ effectSlot = { kind: 'effect', deps, cleanup: undefined };
402
+ store.slots[index] = effectSlot;
403
+ const job = () => {
404
+ effectSlot.job = undefined;
405
+ effectSlot.cleanup = callback();
406
+ };
407
+ effectSlot.job = job;
408
+ queue(job);
409
+ }
410
+ else if (!areHookDepsEqual(effectSlot.deps, deps)) {
411
+ effectSlot.deps = deps;
412
+ const job = () => {
413
+ effectSlot.job = undefined;
414
+ if (effectSlot.cleanup) {
415
+ effectSlot.cleanup();
416
+ }
417
+ effectSlot.cleanup = callback();
418
+ };
419
+ effectSlot.job = job;
420
+ queue(job);
421
+ }
422
+ store.cursor += 1;
423
+ }
424
+ function useEffect(callback, deps) {
425
+ const currentInstance = getCurrentInstanceAll();
426
+ if (currentInstance) {
427
+ effectImpl(currentInstance, queuePostFlushCb, callback, deps);
428
+ return;
429
+ }
430
+ /* istanbul ignore else -- @preserve */
431
+ {
432
+ console.warn('useEffect() hook can only be called during execution of render().');
433
+ }
434
+ }
435
+ function useRenderEffect(callback, deps) {
436
+ const currentInstance = getCurrentInstanceAll();
437
+ if (currentInstance) {
438
+ effectImpl(currentInstance, queueJob, callback, deps);
439
+ return;
440
+ }
441
+ /* istanbul ignore else -- @preserve */
442
+ {
443
+ console.warn('useRenderEffect() hook can only be called during execution of render().');
444
+ }
445
+ }
446
+
433
447
  function createContext(defaultValue) {
434
448
  return {
435
449
  defaultValue,
436
450
  currentValue: defaultValue,
437
451
  subscribers: new Set(),
452
+ provider: null,
438
453
  };
439
454
  }
440
455
  function notifyContextSubscribers(context) {
@@ -450,14 +465,30 @@ function useContext(context, value) {
450
465
  if (arguments.length >= 2) {
451
466
  // Provider
452
467
  if (!isHookKind(store.slots[index], 'context')) {
468
+ // It maybe invalid now, but become valid in a later render.
469
+ // So we need to reserve a slot for it and add cleanup logic.
453
470
  store.slots[index] = {
454
471
  kind: 'context',
455
- cleanup() {
456
- context.currentValue = context.defaultValue;
457
- notifyContextSubscribers(context);
472
+ cleanup: () => {
473
+ if (context.provider === currentInstance) {
474
+ context.provider = null;
475
+ if (!Object.is(context.currentValue, context.defaultValue)) {
476
+ context.currentValue = context.defaultValue;
477
+ notifyContextSubscribers(context);
478
+ }
479
+ }
458
480
  },
459
481
  };
460
482
  }
483
+ if (context.provider !== null && context.provider !== currentInstance) {
484
+ /* istanbul ignore else -- @preserve */
485
+ {
486
+ console.warn('useContext() does not support multiple providers for the same context at the same time.');
487
+ }
488
+ store.cursor += 1;
489
+ return;
490
+ }
491
+ context.provider = currentInstance;
461
492
  if (!Object.is(context.currentValue, value)) {
462
493
  context.currentValue = value;
463
494
  notifyContextSubscribers(context);
@@ -1196,6 +1227,7 @@ exports.usePullDownRefresh = usePullDownRefresh;
1196
1227
  exports.useReachBottom = useReachBottom;
1197
1228
  exports.useReducer = useReducer;
1198
1229
  exports.useRef = useRef;
1230
+ exports.useRenderEffect = useRenderEffect;
1199
1231
  exports.useResize = useResize;
1200
1232
  exports.useRouteDone = useRouteDone;
1201
1233
  exports.useSaveExitState = useSaveExitState;
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * rezor v0.0.1
2
+ * rezor v0.0.2
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 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=$;
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 u=Object.assign;function d(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,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,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(;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,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,t,s,n){const i=o(e),r=i.cursor;let _=i.slots[r];if(c(_,"effect")){if(!f(_.deps,n)){_.deps=n;const e=()=>{_.job=void 0,_.cleanup&&_.cleanup(),_.cleanup=s()};_.job=e,t(e)}}else{_={kind:"effect",deps:n,cleanup:void 0},i.slots[r]=_;const e=()=>{_.job=void 0,_.cleanup=s()};_.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 s=e[t];return function(...e){h(this,t).forEach(t=>t(...e)),void 0!==s&&s.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 s=e[t];return function(...e){h(this,t).forEach(t=>t(...e)),void 0!==s&&s.call(this,...e)}}function G(e,t){return function(...s){const[n]=h(this,e);return n?n(...s):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(...s){h(this,e).forEach(e=>e(...s)),void 0!==t&&t.call(this,...s)}}function J(e,t){return function(...s){const[n]=h(this,e);return n?n(...s):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),se=le(k.ON_SHOW),ne=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=he(B.MOVED),ae=he(B.ERROR);function Oe(t){return s=>{e&&O(e,t,s)}}function le(e){return t=>{const s=n();s&&O(s,e,t)}}function he(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=d(t,["render"])}const i=n[M.ON_LAUNCH];n[M.ON_LAUNCH]=function(t){this.__render__=()=>{e=this,r(this),E(this,y);try{const e=s(t);void 0!==e&&Object.keys(e).forEach(t=>{this[t]=e[t]})}finally{e=null}_(this),a(this,y)},this.__render__(),void 0!==i&&i.call(this,t)},n[M.ON_SHOW]=j(n,M.ON_SHOW),n[M.ON_HIDE]=j(n,M.ON_HIDE),n[M.ON_ERROR]=j(n,M.ON_ERROR),n[M.ON_PAGE_NOT_FOUND]=j(n,M.ON_PAGE_NOT_FOUND),n[M.ON_UNHANDLED_REJECTION]=j(n,M.ON_UNHANDLED_REJECTION),n[M.ON_THEME_CHANGE]=j(n,M.ON_THEME_CHANGE),App(n)},exports.createContext=function(e){return{defaultValue:e,currentValue:e,subscribers:new Set,provider:null}},exports.defineComponent=function(e,t){let n,i;t=u({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=d(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__=()=>{s=this,r(this),E(this,Q);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,Q)},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 h=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!==h&&h.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(s){this.__props__&&(this.__props__=u({},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=u({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=d(e,["render"])}const c=i[k.ON_LOAD];i[k.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,V);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,V)},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]||s.listenPageScroll)&&(i[k.ON_PAGE_SCROLL]=F(i,k.ON_PAGE_SCROLL),i.__listenPageScroll__=()=>!0),void 0===i[k.ON_SHARE_APP_MESSAGE]&&s.canShareToOthers&&(i[k.ON_SHARE_APP_MESSAGE]=G(k.ON_SHARE_APP_MESSAGE,()=>({})),i.__isInjectedShareToOthersHook__=()=>!0),void 0===i[k.ON_SHARE_TIMELINE]&&s.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=n();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 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.provider===s&&(e.provider=null,Object.is(e.currentValue,e.defaultValue)||(e.currentValue=e.defaultValue,x(e)))}}),null!==e.provider&&e.provider!==s||(e.provider=s,Object.is(e.currentValue,t)||(e.currentValue=t,x(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();s&&U(s,b,e,t)},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=ae,exports.useHide=ne,exports.useMemo=function(e,t){const s=i();return s?C(s,e,t):e()},exports.useMove=Ee,exports.usePageNotFound=$,exports.usePageScroll=e=>{const t=n();t&&t.__listenPageScroll__&&O(t,k.ON_PAGE_SCROLL,e)},exports.usePullDownRefresh=oe,exports.useReachBottom=re,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.useRenderEffect=function(e,t){const s=i();s&&U(s,m,e,t)},exports.useResize=_e,exports.useRouteDone=ie,exports.useSaveExitState=e=>{const t=n();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=n();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=n();if(t&&t.__isInjectedShareToTimelineHook__){0===l(t,k.ON_SHARE_TIMELINE)&&O(t,k.ON_SHARE_TIMELINE,e)}},exports.useShow=se,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=ce,exports.useThemeChange=te,exports.useUnhandledRejection=ee;
package/dist/index.d.ts CHANGED
@@ -14,9 +14,6 @@ declare function useState<S = undefined>(): [
14
14
  Dispatch<SetStateAction<S | undefined>>
15
15
  ];
16
16
 
17
- type EffectCallback = () => void | (() => void);
18
- declare function useEffect(callback: EffectCallback, deps?: readonly unknown[]): void;
19
-
20
17
  type ActionDispatch<A> = (action: A) => void;
21
18
  declare function useReducer<S, A>(reducer: (prevState: S, action: A) => S, initialArg: S): [S, ActionDispatch<A>];
22
19
  declare function useReducer<S, I, A>(reducer: (prevState: S, action: A) => S, initialArg: I, init: (i: I) => S): [S, ActionDispatch<A>];
@@ -26,20 +23,42 @@ declare function useCallback<T extends Function>(callback: T, deps: readonly unk
26
23
 
27
24
  declare function useEffectEvent<T extends (...args: any[]) => any>(callback: T): T;
28
25
 
26
+ type EffectCallback = () => void | (() => void);
27
+ declare function useEffect(callback: EffectCallback, deps?: readonly unknown[]): void;
28
+ declare function useRenderEffect(callback: EffectCallback, deps?: readonly unknown[]): void;
29
+
30
+ type Bindings = Record<string, any> | void;
31
+ type AppInstance = Record<string, any>;
32
+ type PageInstance = WechatMiniprogram.Page.InstanceProperties & WechatMiniprogram.Page.InstanceMethods<Record<string, unknown>> & {
33
+ [key: string]: any;
34
+ __isInjectedShareToOthersHook__?: () => true;
35
+ __isInjectedShareToTimelineHook__?: () => true;
36
+ __isInjectedFavoritesHook__?: () => true;
37
+ __isInjectedExitStateHook__?: () => true;
38
+ __listenPageScroll__?: () => true;
39
+ };
40
+ type ComponentInstance = WechatMiniprogram.Component.InstanceProperties & WechatMiniprogram.Component.InstanceMethods<Record<string, unknown>> & {
41
+ [key: string]: any;
42
+ __isInjectedShareToOthersHook__?: () => true;
43
+ __isInjectedShareToTimelineHook__?: () => true;
44
+ __isInjectedFavoritesHook__?: () => true;
45
+ __isInjectedExitStateHook__?: () => true;
46
+ __listenPageScroll__?: () => true;
47
+ };
48
+
29
49
  interface Context<T> {
30
50
  defaultValue: T;
31
51
  currentValue: T;
32
52
  subscribers: Set<Function>;
53
+ provider: AppInstance | PageInstance | ComponentInstance | null;
33
54
  }
34
55
  declare function createContext<T>(defaultValue: T): Context<T>;
35
- declare function useContext<T>(context: Context<T>, value: T): void;
56
+ declare function useContext<T>(context: Context<T>, value: NoInfer<T>): void;
36
57
  declare function useContext<T>(context: Context<T>): T;
37
58
 
38
59
  declare function nextTick(): Promise<void>;
39
60
  declare function nextTick<R>(fn: () => R | Promise<R>): Promise<R>;
40
61
 
41
- type Bindings = Record<string, any> | void;
42
-
43
62
  type AppRender = (this: void, options: WechatMiniprogram.App.LaunchShowOption) => Bindings;
44
63
  type AppOptions<T extends WechatMiniprogram.IAnyObject> = {
45
64
  render?: AppRender;
@@ -96,5 +115,5 @@ declare const useSaveExitState: (hook: () => WechatMiniprogram.Page.ISaveExitSta
96
115
  declare const useMove: (hook: () => void) => void;
97
116
  declare const useError: (hook: (error: Error) => void) => void;
98
117
 
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 };
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 };
100
119
  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.0.1
2
+ * rezor v0.0.2
3
3
  * https://github.com/rezorjs/rezor
4
4
  * (c) 2026-present Yang Mingshan
5
5
  * @license MIT
@@ -296,43 +296,6 @@ function useState(initialState) {
296
296
  return [getState(), () => { }];
297
297
  }
298
298
 
299
- function useEffect(callback, deps) {
300
- const currentInstance = getCurrentInstanceAll();
301
- if (currentInstance) {
302
- const store = getHooksStore(currentInstance);
303
- const index = store.cursor;
304
- let effectSlot = store.slots[index];
305
- if (!isHookKind(effectSlot, 'effect')) {
306
- effectSlot = { kind: 'effect', deps, cleanup: undefined };
307
- store.slots[index] = effectSlot;
308
- const job = () => {
309
- effectSlot.job = undefined;
310
- effectSlot.cleanup = callback();
311
- };
312
- effectSlot.job = job;
313
- queuePostFlushCb(job);
314
- }
315
- else if (!areHookDepsEqual(effectSlot.deps, deps)) {
316
- effectSlot.deps = deps;
317
- const job = () => {
318
- effectSlot.job = undefined;
319
- if (effectSlot.cleanup) {
320
- effectSlot.cleanup();
321
- }
322
- effectSlot.cleanup = callback();
323
- };
324
- effectSlot.job = job;
325
- queuePostFlushCb(job);
326
- }
327
- store.cursor += 1;
328
- return;
329
- }
330
- /* istanbul ignore else -- @preserve */
331
- if ((process.env.NODE_ENV !== 'production')) {
332
- console.warn('useEffect() hook can only be called during execution of render().');
333
- }
334
- }
335
-
336
299
  function useReducer(reducer, initialArg, init) {
337
300
  const getState = () => init === undefined ? initialArg : init(initialArg);
338
301
  const currentInstance = getCurrentInstanceAll();
@@ -428,11 +391,63 @@ function useEffectEvent(callback) {
428
391
  return callback;
429
392
  }
430
393
 
394
+ function effectImpl(currentInstance, queue, callback, deps) {
395
+ const store = getHooksStore(currentInstance);
396
+ const index = store.cursor;
397
+ let effectSlot = store.slots[index];
398
+ if (!isHookKind(effectSlot, 'effect')) {
399
+ effectSlot = { kind: 'effect', deps, cleanup: undefined };
400
+ store.slots[index] = effectSlot;
401
+ const job = () => {
402
+ effectSlot.job = undefined;
403
+ effectSlot.cleanup = callback();
404
+ };
405
+ effectSlot.job = job;
406
+ queue(job);
407
+ }
408
+ else if (!areHookDepsEqual(effectSlot.deps, deps)) {
409
+ effectSlot.deps = deps;
410
+ const job = () => {
411
+ effectSlot.job = undefined;
412
+ if (effectSlot.cleanup) {
413
+ effectSlot.cleanup();
414
+ }
415
+ effectSlot.cleanup = callback();
416
+ };
417
+ effectSlot.job = job;
418
+ queue(job);
419
+ }
420
+ store.cursor += 1;
421
+ }
422
+ function useEffect(callback, deps) {
423
+ const currentInstance = getCurrentInstanceAll();
424
+ if (currentInstance) {
425
+ effectImpl(currentInstance, queuePostFlushCb, callback, deps);
426
+ return;
427
+ }
428
+ /* istanbul ignore else -- @preserve */
429
+ if ((process.env.NODE_ENV !== 'production')) {
430
+ console.warn('useEffect() hook can only be called during execution of render().');
431
+ }
432
+ }
433
+ function useRenderEffect(callback, deps) {
434
+ const currentInstance = getCurrentInstanceAll();
435
+ if (currentInstance) {
436
+ effectImpl(currentInstance, queueJob, callback, deps);
437
+ return;
438
+ }
439
+ /* istanbul ignore else -- @preserve */
440
+ if ((process.env.NODE_ENV !== 'production')) {
441
+ console.warn('useRenderEffect() hook can only be called during execution of render().');
442
+ }
443
+ }
444
+
431
445
  function createContext(defaultValue) {
432
446
  return {
433
447
  defaultValue,
434
448
  currentValue: defaultValue,
435
449
  subscribers: new Set(),
450
+ provider: null,
436
451
  };
437
452
  }
438
453
  function notifyContextSubscribers(context) {
@@ -448,14 +463,30 @@ function useContext(context, value) {
448
463
  if (arguments.length >= 2) {
449
464
  // Provider
450
465
  if (!isHookKind(store.slots[index], 'context')) {
466
+ // It maybe invalid now, but become valid in a later render.
467
+ // So we need to reserve a slot for it and add cleanup logic.
451
468
  store.slots[index] = {
452
469
  kind: 'context',
453
- cleanup() {
454
- context.currentValue = context.defaultValue;
455
- notifyContextSubscribers(context);
470
+ cleanup: () => {
471
+ if (context.provider === currentInstance) {
472
+ context.provider = null;
473
+ if (!Object.is(context.currentValue, context.defaultValue)) {
474
+ context.currentValue = context.defaultValue;
475
+ notifyContextSubscribers(context);
476
+ }
477
+ }
456
478
  },
457
479
  };
458
480
  }
481
+ if (context.provider !== null && context.provider !== currentInstance) {
482
+ /* istanbul ignore else -- @preserve */
483
+ if ((process.env.NODE_ENV !== 'production')) {
484
+ console.warn('useContext() does not support multiple providers for the same context at the same time.');
485
+ }
486
+ store.cursor += 1;
487
+ return;
488
+ }
489
+ context.provider = currentInstance;
459
490
  if (!Object.is(context.currentValue, value)) {
460
491
  context.currentValue = value;
461
492
  notifyContextSubscribers(context);
@@ -1171,4 +1202,4 @@ function createComponentHook(lifecycle) {
1171
1202
  };
1172
1203
  }
1173
1204
 
1174
- 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 };
1205
+ 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rezor",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "拥有原生性能的 React 小程序框架。",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm-bundler.js",