rezor 0.0.2 → 0.1.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 +13 -13
- package/dist/index.cjs.prod.js +2 -2
- package/dist/index.esm-bundler.js +13 -13
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* rezor v0.0
|
|
2
|
+
* rezor v0.1.0
|
|
3
3
|
* https://github.com/rezorjs/rezor
|
|
4
4
|
* (c) 2026-present Yang Mingshan
|
|
5
5
|
* @license MIT
|
|
@@ -304,26 +304,25 @@ function useReducer(reducer, initialArg, init) {
|
|
|
304
304
|
if (currentInstance) {
|
|
305
305
|
const store = getHooksStore(currentInstance);
|
|
306
306
|
const index = store.cursor;
|
|
307
|
-
let
|
|
308
|
-
if (!isHookKind(
|
|
307
|
+
let reducerSlot = store.slots[index];
|
|
308
|
+
if (!isHookKind(reducerSlot, 'reducer')) {
|
|
309
309
|
const dispatch = (action) => {
|
|
310
|
-
const prevState =
|
|
311
|
-
const nextState = reducer(prevState, action);
|
|
310
|
+
const prevState = reducerSlot.value;
|
|
311
|
+
const nextState = reducerSlot.reducer(prevState, action);
|
|
312
312
|
if (Object.is(prevState, nextState)) {
|
|
313
313
|
return;
|
|
314
314
|
}
|
|
315
|
-
|
|
315
|
+
reducerSlot.value = nextState;
|
|
316
316
|
queueJob(currentInstance.__render__);
|
|
317
317
|
};
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
store.slots[index] = stateSlot;
|
|
318
|
+
reducerSlot = { kind: 'reducer', value: getState(), reducer, dispatch };
|
|
319
|
+
store.slots[index] = reducerSlot;
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
reducerSlot.reducer = reducer;
|
|
324
323
|
}
|
|
325
324
|
store.cursor += 1;
|
|
326
|
-
return [
|
|
325
|
+
return [reducerSlot.value, reducerSlot.dispatch];
|
|
327
326
|
}
|
|
328
327
|
/* istanbul ignore else -- @preserve */
|
|
329
328
|
{
|
|
@@ -384,6 +383,7 @@ function useEffectEvent(callback) {
|
|
|
384
383
|
effectEventSlot.fn = callback;
|
|
385
384
|
}
|
|
386
385
|
store.cursor += 1;
|
|
386
|
+
// https://react.dev/reference/react/useEffectEvent#why-are-effect-events-not-stable
|
|
387
387
|
return ((...args) => effectEventSlot.fn(...args));
|
|
388
388
|
}
|
|
389
389
|
/* istanbul ignore else -- @preserve */
|
package/dist/index.cjs.prod.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* rezor v0.0
|
|
2
|
+
* rezor v0.1.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 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;
|
|
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__=()=>{e=this,r(this),E(this,y);try{const e=n(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)},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__=()=>{n=this,r(this),E(this,Q);try{const t=s(this.__props__,e);if(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)}}finally{n=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 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__=()=>{t=this,r(this),E(this,V);try{const t=s(e,n);if(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)}}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]||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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* rezor v0.0
|
|
2
|
+
* rezor v0.1.0
|
|
3
3
|
* https://github.com/rezorjs/rezor
|
|
4
4
|
* (c) 2026-present Yang Mingshan
|
|
5
5
|
* @license MIT
|
|
@@ -302,26 +302,25 @@ function useReducer(reducer, initialArg, init) {
|
|
|
302
302
|
if (currentInstance) {
|
|
303
303
|
const store = getHooksStore(currentInstance);
|
|
304
304
|
const index = store.cursor;
|
|
305
|
-
let
|
|
306
|
-
if (!isHookKind(
|
|
305
|
+
let reducerSlot = store.slots[index];
|
|
306
|
+
if (!isHookKind(reducerSlot, 'reducer')) {
|
|
307
307
|
const dispatch = (action) => {
|
|
308
|
-
const prevState =
|
|
309
|
-
const nextState = reducer(prevState, action);
|
|
308
|
+
const prevState = reducerSlot.value;
|
|
309
|
+
const nextState = reducerSlot.reducer(prevState, action);
|
|
310
310
|
if (Object.is(prevState, nextState)) {
|
|
311
311
|
return;
|
|
312
312
|
}
|
|
313
|
-
|
|
313
|
+
reducerSlot.value = nextState;
|
|
314
314
|
queueJob(currentInstance.__render__);
|
|
315
315
|
};
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
store.slots[index] = stateSlot;
|
|
316
|
+
reducerSlot = { kind: 'reducer', value: getState(), reducer, dispatch };
|
|
317
|
+
store.slots[index] = reducerSlot;
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
reducerSlot.reducer = reducer;
|
|
322
321
|
}
|
|
323
322
|
store.cursor += 1;
|
|
324
|
-
return [
|
|
323
|
+
return [reducerSlot.value, reducerSlot.dispatch];
|
|
325
324
|
}
|
|
326
325
|
/* istanbul ignore else -- @preserve */
|
|
327
326
|
if ((process.env.NODE_ENV !== 'production')) {
|
|
@@ -382,6 +381,7 @@ function useEffectEvent(callback) {
|
|
|
382
381
|
effectEventSlot.fn = callback;
|
|
383
382
|
}
|
|
384
383
|
store.cursor += 1;
|
|
384
|
+
// https://react.dev/reference/react/useEffectEvent#why-are-effect-events-not-stable
|
|
385
385
|
return ((...args) => effectEventSlot.fn(...args));
|
|
386
386
|
}
|
|
387
387
|
/* istanbul ignore else -- @preserve */
|