|
1 /******/ var __webpack_modules__ = ({ |
|
2 |
|
3 /***/ 380: |
|
4 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { |
|
5 |
|
6 |
|
7 // EXPORTS |
|
8 __webpack_require__.d(__webpack_exports__, { |
|
9 zj: () => (/* reexport */ getConfig), |
|
10 SD: () => (/* reexport */ getContext), |
|
11 V6: () => (/* reexport */ getElement), |
|
12 $K: () => (/* reexport */ getServerContext), |
|
13 vT: () => (/* reexport */ getServerState), |
|
14 jb: () => (/* binding */ privateApis), |
|
15 yT: () => (/* reexport */ splitTask), |
|
16 M_: () => (/* reexport */ store), |
|
17 hb: () => (/* reexport */ useCallback), |
|
18 vJ: () => (/* reexport */ useEffect), |
|
19 ip: () => (/* reexport */ useInit), |
|
20 Nf: () => (/* reexport */ useLayoutEffect), |
|
21 Kr: () => (/* reexport */ useMemo), |
|
22 li: () => (/* reexport */ A), |
|
23 J0: () => (/* reexport */ d), |
|
24 FH: () => (/* reexport */ useWatch), |
|
25 v4: () => (/* reexport */ withScope), |
|
26 mh: () => (/* reexport */ withSyncEvent) |
|
27 }); |
|
28 |
|
29 // EXTERNAL MODULE: ./node_modules/preact/dist/preact.module.js |
|
30 var preact_module = __webpack_require__(622); |
|
31 ;// ./node_modules/preact/hooks/dist/hooks.module.js |
|
32 var hooks_module_t,r,hooks_module_u,i,hooks_module_o=0,hooks_module_f=[],hooks_module_c=preact_module/* options */.fF,e=hooks_module_c.__b,a=hooks_module_c.__r,v=hooks_module_c.diffed,l=hooks_module_c.__c,m=hooks_module_c.unmount,s=hooks_module_c.__;function p(n,t){hooks_module_c.__h&&hooks_module_c.__h(r,n,hooks_module_o||t),hooks_module_o=0;var u=r.__H||(r.__H={__:[],__h:[]});return n>=u.__.length&&u.__.push({}),u.__[n]}function d(n){return hooks_module_o=1,h(D,n)}function h(n,u,i){var o=p(hooks_module_t++,2);if(o.t=n,!o.__c&&(o.__=[i?i(u):D(void 0,u),function(n){var t=o.__N?o.__N[0]:o.__[0],r=o.t(t,n);t!==r&&(o.__N=[r,o.__[1]],o.__c.setState({}))}],o.__c=r,!r.__f)){var f=function(n,t,r){if(!o.__c.__H)return!0;var u=o.__c.__H.__.filter(function(n){return!!n.__c});if(u.every(function(n){return!n.__N}))return!c||c.call(this,n,t,r);var i=o.__c.props!==n;return u.forEach(function(n){if(n.__N){var t=n.__[0];n.__=n.__N,n.__N=void 0,t!==n.__[0]&&(i=!0)}}),c&&c.call(this,n,t,r)||i};r.__f=!0;var c=r.shouldComponentUpdate,e=r.componentWillUpdate;r.componentWillUpdate=function(n,t,r){if(this.__e){var u=c;c=void 0,f(n,t,r),c=u}e&&e.call(this,n,t,r)},r.shouldComponentUpdate=f}return o.__N||o.__}function y(n,u){var i=p(hooks_module_t++,3);!hooks_module_c.__s&&C(i.__H,u)&&(i.__=n,i.u=u,r.__H.__h.push(i))}function _(n,u){var i=p(hooks_module_t++,4);!hooks_module_c.__s&&C(i.__H,u)&&(i.__=n,i.u=u,r.__h.push(i))}function A(n){return hooks_module_o=5,T(function(){return{current:n}},[])}function F(n,t,r){hooks_module_o=6,_(function(){if("function"==typeof n){var r=n(t());return function(){n(null),r&&"function"==typeof r&&r()}}if(n)return n.current=t(),function(){return n.current=null}},null==r?r:r.concat(n))}function T(n,r){var u=p(hooks_module_t++,7);return C(u.__H,r)&&(u.__=n(),u.__H=r,u.__h=n),u.__}function q(n,t){return hooks_module_o=8,T(function(){return n},t)}function x(n){var u=r.context[n.__c],i=p(hooks_module_t++,9);return i.c=n,u?(null==i.__&&(i.__=!0,u.sub(r)),u.props.value):n.__}function P(n,t){hooks_module_c.useDebugValue&&hooks_module_c.useDebugValue(t?t(n):n)}function b(n){var u=p(hooks_module_t++,10),i=d();return u.__=n,r.componentDidCatch||(r.componentDidCatch=function(n,t){u.__&&u.__(n,t),i[1](n)}),[i[0],function(){i[1](void 0)}]}function g(){var n=p(hooks_module_t++,11);if(!n.__){for(var u=r.__v;null!==u&&!u.__m&&null!==u.__;)u=u.__;var i=u.__m||(u.__m=[0,0]);n.__="P"+i[0]+"-"+i[1]++}return n.__}function j(){for(var n;n=hooks_module_f.shift();)if(n.__P&&n.__H)try{n.__H.__h.forEach(z),n.__H.__h.forEach(B),n.__H.__h=[]}catch(t){n.__H.__h=[],hooks_module_c.__e(t,n.__v)}}hooks_module_c.__b=function(n){r=null,e&&e(n)},hooks_module_c.__=function(n,t){n&&t.__k&&t.__k.__m&&(n.__m=t.__k.__m),s&&s(n,t)},hooks_module_c.__r=function(n){a&&a(n),hooks_module_t=0;var i=(r=n.__c).__H;i&&(hooks_module_u===r?(i.__h=[],r.__h=[],i.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(i.__h.forEach(z),i.__h.forEach(B),i.__h=[],hooks_module_t=0)),hooks_module_u=r},hooks_module_c.diffed=function(n){v&&v(n);var t=n.__c;t&&t.__H&&(t.__H.__h.length&&(1!==hooks_module_f.push(t)&&i===hooks_module_c.requestAnimationFrame||((i=hooks_module_c.requestAnimationFrame)||w)(j)),t.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),hooks_module_u=r=null},hooks_module_c.__c=function(n,t){t.some(function(n){try{n.__h.forEach(z),n.__h=n.__h.filter(function(n){return!n.__||B(n)})}catch(r){t.some(function(n){n.__h&&(n.__h=[])}),t=[],hooks_module_c.__e(r,n.__v)}}),l&&l(n,t)},hooks_module_c.unmount=function(n){m&&m(n);var t,r=n.__c;r&&r.__H&&(r.__H.__.forEach(function(n){try{z(n)}catch(n){t=n}}),r.__H=void 0,t&&hooks_module_c.__e(t,r.__v))};var k="function"==typeof requestAnimationFrame;function w(n){var t,r=function(){clearTimeout(u),k&&cancelAnimationFrame(t),setTimeout(n)},u=setTimeout(r,100);k&&(t=requestAnimationFrame(r))}function z(n){var t=r,u=n.__c;"function"==typeof u&&(n.__c=void 0,u()),r=t}function B(n){var t=r;n.__c=n.__(),r=t}function C(n,t){return!n||n.length!==t.length||t.some(function(t,r){return t!==n[r]})}function D(n,t){return"function"==typeof t?t(n):t} |
|
33 |
|
34 ;// ./node_modules/@preact/signals-core/dist/signals-core.module.js |
|
35 var signals_core_module_i=Symbol.for("preact-signals");function signals_core_module_t(){if(!(signals_core_module_s>1)){var i,t=!1;while(void 0!==signals_core_module_h){var r=signals_core_module_h;signals_core_module_h=void 0;signals_core_module_f++;while(void 0!==r){var o=r.o;r.o=void 0;r.f&=-3;if(!(8&r.f)&&signals_core_module_c(r))try{r.c()}catch(r){if(!t){i=r;t=!0}}r=o}}signals_core_module_f=0;signals_core_module_s--;if(t)throw i}else signals_core_module_s--}function signals_core_module_r(i){if(signals_core_module_s>0)return i();signals_core_module_s++;try{return i()}finally{signals_core_module_t()}}var signals_core_module_o=void 0;function n(i){var t=signals_core_module_o;signals_core_module_o=void 0;try{return i()}finally{signals_core_module_o=t}}var signals_core_module_h=void 0,signals_core_module_s=0,signals_core_module_f=0,signals_core_module_v=0;function signals_core_module_e(i){if(void 0!==signals_core_module_o){var t=i.n;if(void 0===t||t.t!==signals_core_module_o){t={i:0,S:i,p:signals_core_module_o.s,n:void 0,t:signals_core_module_o,e:void 0,x:void 0,r:t};if(void 0!==signals_core_module_o.s)signals_core_module_o.s.n=t;signals_core_module_o.s=t;i.n=t;if(32&signals_core_module_o.f)i.S(t);return t}else if(-1===t.i){t.i=0;if(void 0!==t.n){t.n.p=t.p;if(void 0!==t.p)t.p.n=t.n;t.p=signals_core_module_o.s;t.n=void 0;signals_core_module_o.s.n=t;signals_core_module_o.s=t}return t}}}function signals_core_module_u(i){this.v=i;this.i=0;this.n=void 0;this.t=void 0}signals_core_module_u.prototype.brand=signals_core_module_i;signals_core_module_u.prototype.h=function(){return!0};signals_core_module_u.prototype.S=function(i){if(this.t!==i&&void 0===i.e){i.x=this.t;if(void 0!==this.t)this.t.e=i;this.t=i}};signals_core_module_u.prototype.U=function(i){if(void 0!==this.t){var t=i.e,r=i.x;if(void 0!==t){t.x=r;i.e=void 0}if(void 0!==r){r.e=t;i.x=void 0}if(i===this.t)this.t=r}};signals_core_module_u.prototype.subscribe=function(i){var t=this;return E(function(){var r=t.value,n=signals_core_module_o;signals_core_module_o=void 0;try{i(r)}finally{signals_core_module_o=n}})};signals_core_module_u.prototype.valueOf=function(){return this.value};signals_core_module_u.prototype.toString=function(){return this.value+""};signals_core_module_u.prototype.toJSON=function(){return this.value};signals_core_module_u.prototype.peek=function(){var i=signals_core_module_o;signals_core_module_o=void 0;try{return this.value}finally{signals_core_module_o=i}};Object.defineProperty(signals_core_module_u.prototype,"value",{get:function(){var i=signals_core_module_e(this);if(void 0!==i)i.i=this.i;return this.v},set:function(i){if(i!==this.v){if(signals_core_module_f>100)throw new Error("Cycle detected");this.v=i;this.i++;signals_core_module_v++;signals_core_module_s++;try{for(var r=this.t;void 0!==r;r=r.x)r.t.N()}finally{signals_core_module_t()}}}});function signals_core_module_d(i){return new signals_core_module_u(i)}function signals_core_module_c(i){for(var t=i.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function signals_core_module_a(i){for(var t=i.s;void 0!==t;t=t.n){var r=t.S.n;if(void 0!==r)t.r=r;t.S.n=t;t.i=-1;if(void 0===t.n){i.s=t;break}}}function signals_core_module_l(i){var t=i.s,r=void 0;while(void 0!==t){var o=t.p;if(-1===t.i){t.S.U(t);if(void 0!==o)o.n=t.n;if(void 0!==t.n)t.n.p=o}else r=t;t.S.n=t.r;if(void 0!==t.r)t.r=void 0;t=o}i.s=r}function signals_core_module_y(i){signals_core_module_u.call(this,void 0);this.x=i;this.s=void 0;this.g=signals_core_module_v-1;this.f=4}(signals_core_module_y.prototype=new signals_core_module_u).h=function(){this.f&=-3;if(1&this.f)return!1;if(32==(36&this.f))return!0;this.f&=-5;if(this.g===signals_core_module_v)return!0;this.g=signals_core_module_v;this.f|=1;if(this.i>0&&!signals_core_module_c(this)){this.f&=-2;return!0}var i=signals_core_module_o;try{signals_core_module_a(this);signals_core_module_o=this;var t=this.x();if(16&this.f||this.v!==t||0===this.i){this.v=t;this.f&=-17;this.i++}}catch(i){this.v=i;this.f|=16;this.i++}signals_core_module_o=i;signals_core_module_l(this);this.f&=-2;return!0};signals_core_module_y.prototype.S=function(i){if(void 0===this.t){this.f|=36;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t)}signals_core_module_u.prototype.S.call(this,i)};signals_core_module_y.prototype.U=function(i){if(void 0!==this.t){signals_core_module_u.prototype.U.call(this,i);if(void 0===this.t){this.f&=-33;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t)}}};signals_core_module_y.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var i=this.t;void 0!==i;i=i.x)i.t.N()}};Object.defineProperty(signals_core_module_y.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var i=signals_core_module_e(this);this.h();if(void 0!==i)i.i=this.i;if(16&this.f)throw this.v;return this.v}});function signals_core_module_w(i){return new signals_core_module_y(i)}function signals_core_module_(i){var r=i.u;i.u=void 0;if("function"==typeof r){signals_core_module_s++;var n=signals_core_module_o;signals_core_module_o=void 0;try{r()}catch(t){i.f&=-2;i.f|=8;signals_core_module_g(i);throw t}finally{signals_core_module_o=n;signals_core_module_t()}}}function signals_core_module_g(i){for(var t=i.s;void 0!==t;t=t.n)t.S.U(t);i.x=void 0;i.s=void 0;signals_core_module_(i)}function signals_core_module_p(i){if(signals_core_module_o!==this)throw new Error("Out-of-order effect");signals_core_module_l(this);signals_core_module_o=i;this.f&=-2;if(8&this.f)signals_core_module_g(this);signals_core_module_t()}function signals_core_module_b(i){this.x=i;this.u=void 0;this.s=void 0;this.o=void 0;this.f=32}signals_core_module_b.prototype.c=function(){var i=this.S();try{if(8&this.f)return;if(void 0===this.x)return;var t=this.x();if("function"==typeof t)this.u=t}finally{i()}};signals_core_module_b.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1;this.f&=-9;signals_core_module_(this);signals_core_module_a(this);signals_core_module_s++;var i=signals_core_module_o;signals_core_module_o=this;return signals_core_module_p.bind(this,i)};signals_core_module_b.prototype.N=function(){if(!(2&this.f)){this.f|=2;this.o=signals_core_module_h;signals_core_module_h=this}};signals_core_module_b.prototype.d=function(){this.f|=8;if(!(1&this.f))signals_core_module_g(this)};function E(i){var t=new signals_core_module_b(i);try{t.c()}catch(i){t.d();throw i}return t.d.bind(t)} |
|
36 ;// ./node_modules/@preact/signals/dist/signals.module.js |
|
37 var signals_module_v,signals_module_s;function signals_module_l(i,n){preact_module/* options */.fF[i]=n.bind(null,preact_module/* options */.fF[i]||function(){})}function signals_module_d(i){if(signals_module_s)signals_module_s();signals_module_s=i&&i.S()}function signals_module_h(i){var r=this,f=i.data,o=useSignal(f);o.value=f;var e=T(function(){var i=r.__v;while(i=i.__)if(i.__c){i.__c.__$f|=4;break}r.__$u.c=function(){var i,t=r.__$u.S(),f=e.value;t();if((0,preact_module/* isValidElement */.zO)(f)||3!==(null==(i=r.base)?void 0:i.nodeType)){r.__$f|=1;r.setState({})}else r.base.data=f};return signals_core_module_w(function(){var i=o.value.value;return 0===i?0:!0===i?"":i||""})},[]);return e.value}signals_module_h.displayName="_st";Object.defineProperties(signals_core_module_u.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:signals_module_h},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});signals_module_l("__b",function(i,r){if("string"==typeof r.type){var n,t=r.props;for(var f in t)if("children"!==f){var o=t[f];if(o instanceof signals_core_module_u){if(!n)r.__np=n={};n[f]=o;t[f]=o.peek()}}}i(r)});signals_module_l("__r",function(i,r){signals_module_d();var n,t=r.__c;if(t){t.__$f&=-2;if(void 0===(n=t.__$u))t.__$u=n=function(i){var r;E(function(){r=this});r.c=function(){t.__$f|=1;t.setState({})};return r}()}signals_module_v=t;signals_module_d(n);i(r)});signals_module_l("__e",function(i,r,n,t){signals_module_d();signals_module_v=void 0;i(r,n,t)});signals_module_l("diffed",function(i,r){signals_module_d();signals_module_v=void 0;var n;if("string"==typeof r.type&&(n=r.__e)){var t=r.__np,f=r.props;if(t){var o=n.U;if(o)for(var e in o){var u=o[e];if(void 0!==u&&!(e in t)){u.d();o[e]=void 0}}else n.U=o={};for(var a in t){var c=o[a],s=t[a];if(void 0===c){c=signals_module_p(n,a,s,f);o[a]=c}else c.o(s,f)}}}i(r)});function signals_module_p(i,r,n,t){var f=r in i&&void 0===i.ownerSVGElement,o=signals_core_module_d(n);return{o:function(i,r){o.value=i;t=r},d:E(function(){var n=o.value.value;if(t[r]!==n){t[r]=n;if(f)i[r]=n;else if(n)i.setAttribute(r,n);else i.removeAttribute(r)}})}}signals_module_l("unmount",function(i,r){if("string"==typeof r.type){var n=r.__e;if(n){var t=n.U;if(t){n.U=void 0;for(var f in t){var o=t[f];if(o)o.d()}}}}else{var e=r.__c;if(e){var u=e.__$u;if(u){e.__$u=void 0;u.d()}}}i(r)});signals_module_l("__h",function(i,r,n,t){if(t<3||9===t)r.__$f|=2;i(r,n,t)});preact_module/* Component */.uA.prototype.shouldComponentUpdate=function(i,r){var n=this.__$u,t=n&&void 0!==n.s;for(var f in r)return!0;if(this.__f||"boolean"==typeof this.u&&!0===this.u){if(!(t||2&this.__$f||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(t||4&this.__$f))return!0;if(3&this.__$f)return!0}for(var o in i)if("__source"!==o&&i[o]!==this.props[o])return!0;for(var e in this.props)if(!(e in i))return!0;return!1};function useSignal(i){return T(function(){return signals_core_module_d(i)},[])}function useComputed(i){var r=f(i);r.current=i;signals_module_v.__$f|=4;return t(function(){return u(function(){return r.current()})},[])}function useSignalEffect(i){var r=f(i);r.current=i;o(function(){return c(function(){return r.current()})},[])} |
|
38 ;// ./node_modules/@wordpress/interactivity/build-module/namespaces.js |
|
39 const namespaceStack = []; |
|
40 const getNamespace = () => namespaceStack.slice(-1)[0]; |
|
41 const setNamespace = namespace => { |
|
42 namespaceStack.push(namespace); |
|
43 }; |
|
44 const resetNamespace = () => { |
|
45 namespaceStack.pop(); |
|
46 }; |
|
47 |
|
48 ;// ./node_modules/@wordpress/interactivity/build-module/scopes.js |
|
49 /** |
|
50 * External dependencies |
|
51 */ |
|
52 |
|
53 /** |
|
54 * Internal dependencies |
|
55 */ |
|
56 |
|
57 // Store stacks for the current scope and the default namespaces and export APIs |
|
58 // to interact with them. |
|
59 const scopeStack = []; |
|
60 const getScope = () => scopeStack.slice(-1)[0]; |
|
61 const setScope = scope => { |
|
62 scopeStack.push(scope); |
|
63 }; |
|
64 const resetScope = () => { |
|
65 scopeStack.pop(); |
|
66 }; |
|
67 |
|
68 // Wrap the element props to prevent modifications. |
|
69 const immutableMap = new WeakMap(); |
|
70 const immutableError = () => { |
|
71 throw new Error('Please use `data-wp-bind` to modify the attributes of an element.'); |
|
72 }; |
|
73 const immutableHandlers = { |
|
74 get(target, key, receiver) { |
|
75 const value = Reflect.get(target, key, receiver); |
|
76 return !!value && typeof value === 'object' ? deepImmutable(value) : value; |
|
77 }, |
|
78 set: immutableError, |
|
79 deleteProperty: immutableError |
|
80 }; |
|
81 const deepImmutable = target => { |
|
82 if (!immutableMap.has(target)) { |
|
83 immutableMap.set(target, new Proxy(target, immutableHandlers)); |
|
84 } |
|
85 return immutableMap.get(target); |
|
86 }; |
|
87 |
|
88 /** |
|
89 * Retrieves the context inherited by the element evaluating a function from the |
|
90 * store. The returned value depends on the element and the namespace where the |
|
91 * function calling `getContext()` exists. |
|
92 * |
|
93 * @param namespace Store namespace. By default, the namespace where the calling |
|
94 * function exists is used. |
|
95 * @return The context content. |
|
96 */ |
|
97 const getContext = namespace => { |
|
98 const scope = getScope(); |
|
99 if (true) { |
|
100 if (!scope) { |
|
101 throw Error('Cannot call `getContext()` when there is no scope. If you are using an async function, please consider using a generator instead. If you are using some sort of async callbacks, like `setTimeout`, please wrap the callback with `withScope(callback)`.'); |
|
102 } |
|
103 } |
|
104 return scope.context[namespace || getNamespace()]; |
|
105 }; |
|
106 |
|
107 /** |
|
108 * Retrieves a representation of the element where a function from the store |
|
109 * is being evaluated. Such representation is read-only, and contains a |
|
110 * reference to the DOM element, its props and a local reactive state. |
|
111 * |
|
112 * @return Element representation. |
|
113 */ |
|
114 const getElement = () => { |
|
115 const scope = getScope(); |
|
116 if (true) { |
|
117 if (!scope) { |
|
118 throw Error('Cannot call `getElement()` when there is no scope. If you are using an async function, please consider using a generator instead. If you are using some sort of async callbacks, like `setTimeout`, please wrap the callback with `withScope(callback)`.'); |
|
119 } |
|
120 } |
|
121 const { |
|
122 ref, |
|
123 attributes |
|
124 } = scope; |
|
125 return Object.freeze({ |
|
126 ref: ref.current, |
|
127 attributes: deepImmutable(attributes) |
|
128 }); |
|
129 }; |
|
130 |
|
131 /** |
|
132 * Retrieves the part of the inherited context defined and updated from the |
|
133 * server. |
|
134 * |
|
135 * The object returned is read-only, and includes the context defined in PHP |
|
136 * with `wp_interactivity_data_wp_context()`, including the corresponding |
|
137 * inherited properties. When `actions.navigate()` is called, this object is |
|
138 * updated to reflect the changes in the new visited page, without affecting the |
|
139 * context returned by `getContext()`. Directives can subscribe to those changes |
|
140 * to update the context if needed. |
|
141 * |
|
142 * @example |
|
143 * ```js |
|
144 * store('...', { |
|
145 * callbacks: { |
|
146 * updateServerContext() { |
|
147 * const context = getContext(); |
|
148 * const serverContext = getServerContext(); |
|
149 * // Override some property with the new value that came from the server. |
|
150 * context.overridableProp = serverContext.overridableProp; |
|
151 * }, |
|
152 * }, |
|
153 * }); |
|
154 * ``` |
|
155 * |
|
156 * @param namespace Store namespace. By default, the namespace where the calling |
|
157 * function exists is used. |
|
158 * @return The server context content. |
|
159 */ |
|
160 const getServerContext = namespace => { |
|
161 const scope = getScope(); |
|
162 if (true) { |
|
163 if (!scope) { |
|
164 throw Error('Cannot call `getServerContext()` when there is no scope. If you are using an async function, please consider using a generator instead. If you are using some sort of async callbacks, like `setTimeout`, please wrap the callback with `withScope(callback)`.'); |
|
165 } |
|
166 } |
|
167 return scope.serverContext[namespace || getNamespace()]; |
|
168 }; |
|
169 |
|
170 ;// ./node_modules/@wordpress/interactivity/build-module/utils.js |
|
171 /** |
|
172 * External dependencies |
|
173 */ |
|
174 |
|
175 |
|
176 |
|
177 /** |
|
178 * Internal dependencies |
|
179 */ |
|
180 |
|
181 |
|
182 /** |
|
183 * Executes a callback function after the next frame is rendered. |
|
184 * |
|
185 * @param callback The callback function to be executed. |
|
186 * @return A promise that resolves after the callback function is executed. |
|
187 */ |
|
188 const afterNextFrame = callback => { |
|
189 return new Promise(resolve => { |
|
190 const done = () => { |
|
191 clearTimeout(timeout); |
|
192 window.cancelAnimationFrame(raf); |
|
193 setTimeout(() => { |
|
194 callback(); |
|
195 resolve(); |
|
196 }); |
|
197 }; |
|
198 const timeout = setTimeout(done, 100); |
|
199 const raf = window.requestAnimationFrame(done); |
|
200 }); |
|
201 }; |
|
202 |
|
203 /** |
|
204 * Returns a promise that resolves after yielding to main. |
|
205 * |
|
206 * @return Promise<void> |
|
207 */ |
|
208 const splitTask = typeof window.scheduler?.yield === 'function' ? window.scheduler.yield.bind(window.scheduler) : () => { |
|
209 return new Promise(resolve => { |
|
210 setTimeout(resolve, 0); |
|
211 }); |
|
212 }; |
|
213 |
|
214 /** |
|
215 * Creates a Flusher object that can be used to flush computed values and notify listeners. |
|
216 * |
|
217 * Using the mangled properties: |
|
218 * this.c: this._callback |
|
219 * this.x: this._compute |
|
220 * https://github.com/preactjs/signals/blob/main/mangle.json |
|
221 * |
|
222 * @param compute The function that computes the value to be flushed. |
|
223 * @param notify The function that notifies listeners when the value is flushed. |
|
224 * @return The Flusher object with `flush` and `dispose` properties. |
|
225 */ |
|
226 function createFlusher(compute, notify) { |
|
227 let flush = () => undefined; |
|
228 const dispose = E(function () { |
|
229 flush = this.c.bind(this); |
|
230 this.x = compute; |
|
231 this.c = notify; |
|
232 return compute(); |
|
233 }); |
|
234 return { |
|
235 flush, |
|
236 dispose |
|
237 }; |
|
238 } |
|
239 |
|
240 /** |
|
241 * Custom hook that executes a callback function whenever a signal is triggered. |
|
242 * Version of `useSignalEffect` with a `useEffect`-like execution. This hook |
|
243 * implementation comes from this PR, but we added short-cirtuiting to avoid |
|
244 * infinite loops: https://github.com/preactjs/signals/pull/290 |
|
245 * |
|
246 * @param callback The callback function to be executed. |
|
247 */ |
|
248 function utils_useSignalEffect(callback) { |
|
249 y(() => { |
|
250 let eff = null; |
|
251 let isExecuting = false; |
|
252 const notify = async () => { |
|
253 if (eff && !isExecuting) { |
|
254 isExecuting = true; |
|
255 await afterNextFrame(eff.flush); |
|
256 isExecuting = false; |
|
257 } |
|
258 }; |
|
259 eff = createFlusher(callback, notify); |
|
260 return eff.dispose; |
|
261 }, []); |
|
262 } |
|
263 |
|
264 /** |
|
265 * Returns the passed function wrapped with the current scope so it is |
|
266 * accessible whenever the function runs. This is primarily to make the scope |
|
267 * available inside hook callbacks. |
|
268 * |
|
269 * Asynchronous functions should use generators that yield promises instead of awaiting them. |
|
270 * See the documentation for details: https://developer.wordpress.org/block-editor/reference-guides/packages/packages-interactivity/packages-interactivity-api-reference/#the-store |
|
271 * |
|
272 * @param func The passed function. |
|
273 * @return The wrapped function. |
|
274 */ |
|
275 |
|
276 function withScope(func) { |
|
277 const scope = getScope(); |
|
278 const ns = getNamespace(); |
|
279 let wrapped; |
|
280 if (func?.constructor?.name === 'GeneratorFunction') { |
|
281 wrapped = async (...args) => { |
|
282 const gen = func(...args); |
|
283 let value; |
|
284 let it; |
|
285 while (true) { |
|
286 setNamespace(ns); |
|
287 setScope(scope); |
|
288 try { |
|
289 it = gen.next(value); |
|
290 } finally { |
|
291 resetScope(); |
|
292 resetNamespace(); |
|
293 } |
|
294 try { |
|
295 value = await it.value; |
|
296 } catch (e) { |
|
297 setNamespace(ns); |
|
298 setScope(scope); |
|
299 gen.throw(e); |
|
300 } finally { |
|
301 resetScope(); |
|
302 resetNamespace(); |
|
303 } |
|
304 if (it.done) { |
|
305 break; |
|
306 } |
|
307 } |
|
308 return value; |
|
309 }; |
|
310 } else { |
|
311 wrapped = (...args) => { |
|
312 setNamespace(ns); |
|
313 setScope(scope); |
|
314 try { |
|
315 return func(...args); |
|
316 } finally { |
|
317 resetNamespace(); |
|
318 resetScope(); |
|
319 } |
|
320 }; |
|
321 } |
|
322 |
|
323 // If function was annotated via `withSyncEvent()`, maintain the annotation. |
|
324 const syncAware = func; |
|
325 if (syncAware.sync) { |
|
326 const syncAwareWrapped = wrapped; |
|
327 syncAwareWrapped.sync = true; |
|
328 return syncAwareWrapped; |
|
329 } |
|
330 return wrapped; |
|
331 } |
|
332 |
|
333 /** |
|
334 * Accepts a function that contains imperative code which runs whenever any of |
|
335 * the accessed _reactive_ properties (e.g., values from the global state or the |
|
336 * context) is modified. |
|
337 * |
|
338 * This hook makes the element's scope available so functions like |
|
339 * `getElement()` and `getContext()` can be used inside the passed callback. |
|
340 * |
|
341 * @param callback The hook callback. |
|
342 */ |
|
343 function useWatch(callback) { |
|
344 utils_useSignalEffect(withScope(callback)); |
|
345 } |
|
346 |
|
347 /** |
|
348 * Accepts a function that contains imperative code which runs only after the |
|
349 * element's first render, mainly useful for initialization logic. |
|
350 * |
|
351 * This hook makes the element's scope available so functions like |
|
352 * `getElement()` and `getContext()` can be used inside the passed callback. |
|
353 * |
|
354 * @param callback The hook callback. |
|
355 */ |
|
356 function useInit(callback) { |
|
357 y(withScope(callback), []); |
|
358 } |
|
359 |
|
360 /** |
|
361 * Accepts a function that contains imperative, possibly effectful code. The |
|
362 * effects run after browser paint, without blocking it. |
|
363 * |
|
364 * This hook is equivalent to Preact's `useEffect` and makes the element's scope |
|
365 * available so functions like `getElement()` and `getContext()` can be used |
|
366 * inside the passed callback. |
|
367 * |
|
368 * @param callback Imperative function that can return a cleanup |
|
369 * function. |
|
370 * @param inputs If present, effect will only activate if the |
|
371 * values in the list change (using `===`). |
|
372 */ |
|
373 function useEffect(callback, inputs) { |
|
374 y(withScope(callback), inputs); |
|
375 } |
|
376 |
|
377 /** |
|
378 * Accepts a function that contains imperative, possibly effectful code. Use |
|
379 * this to read layout from the DOM and synchronously re-render. |
|
380 * |
|
381 * This hook is equivalent to Preact's `useLayoutEffect` and makes the element's |
|
382 * scope available so functions like `getElement()` and `getContext()` can be |
|
383 * used inside the passed callback. |
|
384 * |
|
385 * @param callback Imperative function that can return a cleanup |
|
386 * function. |
|
387 * @param inputs If present, effect will only activate if the |
|
388 * values in the list change (using `===`). |
|
389 */ |
|
390 function useLayoutEffect(callback, inputs) { |
|
391 _(withScope(callback), inputs); |
|
392 } |
|
393 |
|
394 /** |
|
395 * Returns a memoized version of the callback that only changes if one of the |
|
396 * inputs has changed (using `===`). |
|
397 * |
|
398 * This hook is equivalent to Preact's `useCallback` and makes the element's |
|
399 * scope available so functions like `getElement()` and `getContext()` can be |
|
400 * used inside the passed callback. |
|
401 * |
|
402 * @param callback Callback function. |
|
403 * @param inputs If present, the callback will only be updated if the |
|
404 * values in the list change (using `===`). |
|
405 * |
|
406 * @return The callback function. |
|
407 */ |
|
408 function useCallback(callback, inputs) { |
|
409 return q(withScope(callback), inputs); |
|
410 } |
|
411 |
|
412 /** |
|
413 * Pass a factory function and an array of inputs. `useMemo` will only recompute |
|
414 * the memoized value when one of the inputs has changed. |
|
415 * |
|
416 * This hook is equivalent to Preact's `useMemo` and makes the element's scope |
|
417 * available so functions like `getElement()` and `getContext()` can be used |
|
418 * inside the passed factory function. |
|
419 * |
|
420 * @param factory Factory function that returns that value for memoization. |
|
421 * @param inputs If present, the factory will only be run to recompute if |
|
422 * the values in the list change (using `===`). |
|
423 * |
|
424 * @return The memoized value. |
|
425 */ |
|
426 function useMemo(factory, inputs) { |
|
427 return T(withScope(factory), inputs); |
|
428 } |
|
429 |
|
430 /** |
|
431 * Creates a root fragment by replacing a node or an array of nodes in a parent element. |
|
432 * For wrapperless hydration. |
|
433 * See https://gist.github.com/developit/f4c67a2ede71dc2fab7f357f39cff28c |
|
434 * |
|
435 * @param parent The parent element where the nodes will be replaced. |
|
436 * @param replaceNode The node or array of nodes to replace in the parent element. |
|
437 * @return The created root fragment. |
|
438 */ |
|
439 const createRootFragment = (parent, replaceNode) => { |
|
440 replaceNode = [].concat(replaceNode); |
|
441 const sibling = replaceNode[replaceNode.length - 1].nextSibling; |
|
442 function insert(child, root) { |
|
443 parent.insertBefore(child, root || sibling); |
|
444 } |
|
445 return parent.__k = { |
|
446 nodeType: 1, |
|
447 parentNode: parent, |
|
448 firstChild: replaceNode[0], |
|
449 childNodes: replaceNode, |
|
450 insertBefore: insert, |
|
451 appendChild: insert, |
|
452 removeChild(c) { |
|
453 parent.removeChild(c); |
|
454 } |
|
455 }; |
|
456 }; |
|
457 |
|
458 /** |
|
459 * Transforms a kebab-case string to camelCase. |
|
460 * |
|
461 * @param str The kebab-case string to transform to camelCase. |
|
462 * @return The transformed camelCase string. |
|
463 */ |
|
464 function kebabToCamelCase(str) { |
|
465 return str.replace(/^-+|-+$/g, '').toLowerCase().replace(/-([a-z])/g, function (_match, group1) { |
|
466 return group1.toUpperCase(); |
|
467 }); |
|
468 } |
|
469 const logged = new Set(); |
|
470 |
|
471 /** |
|
472 * Shows a warning with `message` if environment is not `production`. |
|
473 * |
|
474 * Based on the `@wordpress/warning` package. |
|
475 * |
|
476 * @param message Message to show in the warning. |
|
477 */ |
|
478 const warn = message => { |
|
479 if (true) { |
|
480 if (logged.has(message)) { |
|
481 return; |
|
482 } |
|
483 |
|
484 // eslint-disable-next-line no-console |
|
485 console.warn(message); |
|
486 |
|
487 // Throwing an error and catching it immediately to improve debugging |
|
488 // A consumer can use 'pause on caught exceptions' |
|
489 try { |
|
490 throw Error(message); |
|
491 } catch (e) { |
|
492 // Do nothing. |
|
493 } |
|
494 logged.add(message); |
|
495 } |
|
496 }; |
|
497 |
|
498 /** |
|
499 * Checks if the passed `candidate` is a plain object with just the `Object` |
|
500 * prototype. |
|
501 * |
|
502 * @param candidate The item to check. |
|
503 * @return Whether `candidate` is a plain object. |
|
504 */ |
|
505 const isPlainObject = candidate => Boolean(candidate && typeof candidate === 'object' && candidate.constructor === Object); |
|
506 |
|
507 /** |
|
508 * Indicates that the passed `callback` requires synchronous access to the event object. |
|
509 * |
|
510 * @param callback The event callback. |
|
511 * @return Altered event callback. |
|
512 */ |
|
513 function withSyncEvent(callback) { |
|
514 const syncAware = callback; |
|
515 syncAware.sync = true; |
|
516 return syncAware; |
|
517 } |
|
518 |
|
519 ;// ./node_modules/@wordpress/interactivity/build-module/proxies/registry.js |
|
520 /** |
|
521 * Proxies for each object. |
|
522 */ |
|
523 const objToProxy = new WeakMap(); |
|
524 const proxyToObj = new WeakMap(); |
|
525 |
|
526 /** |
|
527 * Namespaces for each created proxy. |
|
528 */ |
|
529 const proxyToNs = new WeakMap(); |
|
530 |
|
531 /** |
|
532 * Object types that can be proxied. |
|
533 */ |
|
534 const supported = new Set([Object, Array]); |
|
535 |
|
536 /** |
|
537 * Returns a proxy to the passed object with the given handlers, assigning the |
|
538 * specified namespace to it. If a proxy for the passed object was created |
|
539 * before, that proxy is returned. |
|
540 * |
|
541 * @param namespace The namespace that will be associated to this proxy. |
|
542 * @param obj The object to proxify. |
|
543 * @param handlers Handlers that the proxy will use. |
|
544 * |
|
545 * @throws Error if the object cannot be proxified. Use {@link shouldProxy} to |
|
546 * check if a proxy can be created for a specific object. |
|
547 * |
|
548 * @return The created proxy. |
|
549 */ |
|
550 const createProxy = (namespace, obj, handlers) => { |
|
551 if (!shouldProxy(obj)) { |
|
552 throw Error('This object cannot be proxified.'); |
|
553 } |
|
554 if (!objToProxy.has(obj)) { |
|
555 const proxy = new Proxy(obj, handlers); |
|
556 objToProxy.set(obj, proxy); |
|
557 proxyToObj.set(proxy, obj); |
|
558 proxyToNs.set(proxy, namespace); |
|
559 } |
|
560 return objToProxy.get(obj); |
|
561 }; |
|
562 |
|
563 /** |
|
564 * Returns the proxy for the given object. If there is no associated proxy, the |
|
565 * function returns `undefined`. |
|
566 * |
|
567 * @param obj Object from which to know the proxy. |
|
568 * @return Associated proxy or `undefined`. |
|
569 */ |
|
570 const getProxyFromObject = obj => objToProxy.get(obj); |
|
571 |
|
572 /** |
|
573 * Gets the namespace associated with the given proxy. |
|
574 * |
|
575 * Proxies have a namespace assigned upon creation. See {@link createProxy}. |
|
576 * |
|
577 * @param proxy Proxy. |
|
578 * @return Namespace. |
|
579 */ |
|
580 const getNamespaceFromProxy = proxy => proxyToNs.get(proxy); |
|
581 |
|
582 /** |
|
583 * Checks if a given object can be proxied. |
|
584 * |
|
585 * @param candidate Object to know whether it can be proxied. |
|
586 * @return True if the passed instance can be proxied. |
|
587 */ |
|
588 const shouldProxy = candidate => { |
|
589 if (typeof candidate !== 'object' || candidate === null) { |
|
590 return false; |
|
591 } |
|
592 return !proxyToNs.has(candidate) && supported.has(candidate.constructor); |
|
593 }; |
|
594 |
|
595 /** |
|
596 * Returns the target object for the passed proxy. If the passed object is not a registered proxy, the |
|
597 * function returns `undefined`. |
|
598 * |
|
599 * @param proxy Proxy from which to know the target. |
|
600 * @return The target object or `undefined`. |
|
601 */ |
|
602 const getObjectFromProxy = proxy => proxyToObj.get(proxy); |
|
603 |
|
604 ;// ./node_modules/@wordpress/interactivity/build-module/proxies/signals.js |
|
605 /** |
|
606 * External dependencies |
|
607 */ |
|
608 |
|
609 |
|
610 /** |
|
611 * Internal dependencies |
|
612 */ |
|
613 |
|
614 |
|
615 |
|
616 |
|
617 |
|
618 /** |
|
619 * Identifier for property computeds not associated to any scope. |
|
620 */ |
|
621 const NO_SCOPE = {}; |
|
622 |
|
623 /** |
|
624 * Structure that manages reactivity for a property in a state object. It uses |
|
625 * signals to keep track of property value or getter modifications. |
|
626 */ |
|
627 class PropSignal { |
|
628 /** |
|
629 * Proxy that holds the property this PropSignal is associated with. |
|
630 */ |
|
631 |
|
632 /** |
|
633 * Relation of computeds by scope. These computeds are read-only signals |
|
634 * that depend on whether the property is a value or a getter and, |
|
635 * therefore, can return different values depending on the scope in which |
|
636 * the getter is accessed. |
|
637 */ |
|
638 |
|
639 /** |
|
640 * Signal with the value assigned to the related property. |
|
641 */ |
|
642 |
|
643 /** |
|
644 * Signal with the getter assigned to the related property. |
|
645 */ |
|
646 |
|
647 /** |
|
648 * Structure that manages reactivity for a property in a state object, using |
|
649 * signals to keep track of property value or getter modifications. |
|
650 * |
|
651 * @param owner Proxy that holds the property this instance is associated |
|
652 * with. |
|
653 */ |
|
654 constructor(owner) { |
|
655 this.owner = owner; |
|
656 this.computedsByScope = new WeakMap(); |
|
657 } |
|
658 |
|
659 /** |
|
660 * Changes the internal value. If a getter was set before, it is set to |
|
661 * `undefined`. |
|
662 * |
|
663 * @param value New value. |
|
664 */ |
|
665 setValue(value) { |
|
666 this.update({ |
|
667 value |
|
668 }); |
|
669 } |
|
670 |
|
671 /** |
|
672 * Changes the internal getter. If a value was set before, it is set to |
|
673 * `undefined`. |
|
674 * |
|
675 * @param getter New getter. |
|
676 */ |
|
677 setGetter(getter) { |
|
678 this.update({ |
|
679 get: getter |
|
680 }); |
|
681 } |
|
682 |
|
683 /** |
|
684 * Returns the computed that holds the result of evaluating the prop in the |
|
685 * current scope. |
|
686 * |
|
687 * These computeds are read-only signals that depend on whether the property |
|
688 * is a value or a getter and, therefore, can return different values |
|
689 * depending on the scope in which the getter is accessed. |
|
690 * |
|
691 * @return Computed that depends on the scope. |
|
692 */ |
|
693 getComputed() { |
|
694 const scope = getScope() || NO_SCOPE; |
|
695 if (!this.valueSignal && !this.getterSignal) { |
|
696 this.update({}); |
|
697 } |
|
698 if (!this.computedsByScope.has(scope)) { |
|
699 const callback = () => { |
|
700 const getter = this.getterSignal?.value; |
|
701 return getter ? getter.call(this.owner) : this.valueSignal?.value; |
|
702 }; |
|
703 setNamespace(getNamespaceFromProxy(this.owner)); |
|
704 this.computedsByScope.set(scope, signals_core_module_w(withScope(callback))); |
|
705 resetNamespace(); |
|
706 } |
|
707 return this.computedsByScope.get(scope); |
|
708 } |
|
709 |
|
710 /** |
|
711 * Update the internal signals for the value and the getter of the |
|
712 * corresponding prop. |
|
713 * |
|
714 * @param param0 |
|
715 * @param param0.get New getter. |
|
716 * @param param0.value New value. |
|
717 */ |
|
718 update({ |
|
719 get, |
|
720 value |
|
721 }) { |
|
722 if (!this.valueSignal) { |
|
723 this.valueSignal = signals_core_module_d(value); |
|
724 this.getterSignal = signals_core_module_d(get); |
|
725 } else if (value !== this.valueSignal.peek() || get !== this.getterSignal.peek()) { |
|
726 signals_core_module_r(() => { |
|
727 this.valueSignal.value = value; |
|
728 this.getterSignal.value = get; |
|
729 }); |
|
730 } |
|
731 } |
|
732 } |
|
733 |
|
734 ;// ./node_modules/@wordpress/interactivity/build-module/proxies/state.js |
|
735 /** |
|
736 * External dependencies |
|
737 */ |
|
738 |
|
739 |
|
740 /** |
|
741 * Internal dependencies |
|
742 */ |
|
743 |
|
744 |
|
745 |
|
746 |
|
747 |
|
748 /** |
|
749 * Set of built-in symbols. |
|
750 */ |
|
751 const wellKnownSymbols = new Set(Object.getOwnPropertyNames(Symbol).map(key => Symbol[key]).filter(value => typeof value === 'symbol')); |
|
752 |
|
753 /** |
|
754 * Relates each proxy with a map of {@link PropSignal} instances, representing |
|
755 * the proxy's accessed properties. |
|
756 */ |
|
757 const proxyToProps = new WeakMap(); |
|
758 |
|
759 /** |
|
760 * Checks whether a {@link PropSignal | `PropSignal`} instance exists for the |
|
761 * given property in the passed proxy. |
|
762 * |
|
763 * @param proxy Proxy of a state object or array. |
|
764 * @param key The property key. |
|
765 * @return `true` when it exists; false otherwise. |
|
766 */ |
|
767 const hasPropSignal = (proxy, key) => proxyToProps.has(proxy) && proxyToProps.get(proxy).has(key); |
|
768 const readOnlyProxies = new WeakSet(); |
|
769 |
|
770 /** |
|
771 * Returns the {@link PropSignal | `PropSignal`} instance associated with the |
|
772 * specified prop in the passed proxy. |
|
773 * |
|
774 * The `PropSignal` instance is generated if it doesn't exist yet, using the |
|
775 * `initial` parameter to initialize the internal signals. |
|
776 * |
|
777 * @param proxy Proxy of a state object or array. |
|
778 * @param key The property key. |
|
779 * @param initial Initial data for the `PropSignal` instance. |
|
780 * @return The `PropSignal` instance. |
|
781 */ |
|
782 const getPropSignal = (proxy, key, initial) => { |
|
783 if (!proxyToProps.has(proxy)) { |
|
784 proxyToProps.set(proxy, new Map()); |
|
785 } |
|
786 key = typeof key === 'number' ? `${key}` : key; |
|
787 const props = proxyToProps.get(proxy); |
|
788 if (!props.has(key)) { |
|
789 const ns = getNamespaceFromProxy(proxy); |
|
790 const prop = new PropSignal(proxy); |
|
791 props.set(key, prop); |
|
792 if (initial) { |
|
793 const { |
|
794 get, |
|
795 value |
|
796 } = initial; |
|
797 if (get) { |
|
798 prop.setGetter(get); |
|
799 } else { |
|
800 const readOnly = readOnlyProxies.has(proxy); |
|
801 prop.setValue(shouldProxy(value) ? proxifyState(ns, value, { |
|
802 readOnly |
|
803 }) : value); |
|
804 } |
|
805 } |
|
806 } |
|
807 return props.get(key); |
|
808 }; |
|
809 |
|
810 /** |
|
811 * Relates each proxied object (i.e., the original object) with a signal that |
|
812 * tracks changes in the number of properties. |
|
813 */ |
|
814 const objToIterable = new WeakMap(); |
|
815 |
|
816 /** |
|
817 * When this flag is `true`, it avoids any signal subscription, overriding state |
|
818 * props' "reactive" behavior. |
|
819 */ |
|
820 let peeking = false; |
|
821 |
|
822 /** |
|
823 * Handlers for reactive objects and arrays in the state. |
|
824 */ |
|
825 const stateHandlers = { |
|
826 get(target, key, receiver) { |
|
827 /* |
|
828 * The property should not be reactive for the following cases: |
|
829 * 1. While using the `peek` function to read the property. |
|
830 * 2. The property exists but comes from the Object or Array prototypes. |
|
831 * 3. The property key is a known symbol. |
|
832 */ |
|
833 if (peeking || !target.hasOwnProperty(key) && key in target || typeof key === 'symbol' && wellKnownSymbols.has(key)) { |
|
834 return Reflect.get(target, key, receiver); |
|
835 } |
|
836 |
|
837 // At this point, the property should be reactive. |
|
838 const desc = Object.getOwnPropertyDescriptor(target, key); |
|
839 const prop = getPropSignal(receiver, key, desc); |
|
840 const result = prop.getComputed().value; |
|
841 |
|
842 /* |
|
843 * Check if the property is a synchronous function. If it is, set the |
|
844 * default namespace. Synchronous functions always run in the proper scope, |
|
845 * which is set by the Directives component. |
|
846 */ |
|
847 if (typeof result === 'function') { |
|
848 const ns = getNamespaceFromProxy(receiver); |
|
849 return (...args) => { |
|
850 setNamespace(ns); |
|
851 try { |
|
852 return result.call(receiver, ...args); |
|
853 } finally { |
|
854 resetNamespace(); |
|
855 } |
|
856 }; |
|
857 } |
|
858 return result; |
|
859 }, |
|
860 set(target, key, value, receiver) { |
|
861 if (readOnlyProxies.has(receiver)) { |
|
862 return false; |
|
863 } |
|
864 setNamespace(getNamespaceFromProxy(receiver)); |
|
865 try { |
|
866 return Reflect.set(target, key, value, receiver); |
|
867 } finally { |
|
868 resetNamespace(); |
|
869 } |
|
870 }, |
|
871 defineProperty(target, key, desc) { |
|
872 if (readOnlyProxies.has(getProxyFromObject(target))) { |
|
873 return false; |
|
874 } |
|
875 const isNew = !(key in target); |
|
876 const result = Reflect.defineProperty(target, key, desc); |
|
877 if (result) { |
|
878 const receiver = getProxyFromObject(target); |
|
879 const prop = getPropSignal(receiver, key); |
|
880 const { |
|
881 get, |
|
882 value |
|
883 } = desc; |
|
884 if (get) { |
|
885 prop.setGetter(get); |
|
886 } else { |
|
887 const ns = getNamespaceFromProxy(receiver); |
|
888 prop.setValue(shouldProxy(value) ? proxifyState(ns, value) : value); |
|
889 } |
|
890 if (isNew && objToIterable.has(target)) { |
|
891 objToIterable.get(target).value++; |
|
892 } |
|
893 |
|
894 /* |
|
895 * Modify the `length` property value only if the related |
|
896 * `PropSignal` exists, which means that there are subscriptions to |
|
897 * this property. |
|
898 */ |
|
899 if (Array.isArray(target) && proxyToProps.get(receiver)?.has('length')) { |
|
900 const length = getPropSignal(receiver, 'length'); |
|
901 length.setValue(target.length); |
|
902 } |
|
903 } |
|
904 return result; |
|
905 }, |
|
906 deleteProperty(target, key) { |
|
907 if (readOnlyProxies.has(getProxyFromObject(target))) { |
|
908 return false; |
|
909 } |
|
910 const result = Reflect.deleteProperty(target, key); |
|
911 if (result) { |
|
912 const prop = getPropSignal(getProxyFromObject(target), key); |
|
913 prop.setValue(undefined); |
|
914 if (objToIterable.has(target)) { |
|
915 objToIterable.get(target).value++; |
|
916 } |
|
917 } |
|
918 return result; |
|
919 }, |
|
920 ownKeys(target) { |
|
921 if (!objToIterable.has(target)) { |
|
922 objToIterable.set(target, signals_core_module_d(0)); |
|
923 } |
|
924 /* |
|
925 *This subscribes to the signal while preventing the minifier from |
|
926 * deleting this line in production. |
|
927 */ |
|
928 objToIterable._ = objToIterable.get(target).value; |
|
929 return Reflect.ownKeys(target); |
|
930 } |
|
931 }; |
|
932 |
|
933 /** |
|
934 * Returns the proxy associated with the given state object, creating it if it |
|
935 * does not exist. |
|
936 * |
|
937 * @param namespace The namespace that will be associated to this proxy. |
|
938 * @param obj The object to proxify. |
|
939 * @param options Options. |
|
940 * @param options.readOnly Read-only. |
|
941 * |
|
942 * @throws Error if the object cannot be proxified. Use {@link shouldProxy} to |
|
943 * check if a proxy can be created for a specific object. |
|
944 * |
|
945 * @return The associated proxy. |
|
946 */ |
|
947 const proxifyState = (namespace, obj, options) => { |
|
948 const proxy = createProxy(namespace, obj, stateHandlers); |
|
949 if (options?.readOnly) { |
|
950 readOnlyProxies.add(proxy); |
|
951 } |
|
952 return proxy; |
|
953 }; |
|
954 |
|
955 /** |
|
956 * Reads the value of the specified property without subscribing to it. |
|
957 * |
|
958 * @param obj The object to read the property from. |
|
959 * @param key The property key. |
|
960 * @return The property value. |
|
961 */ |
|
962 const peek = (obj, key) => { |
|
963 peeking = true; |
|
964 try { |
|
965 return obj[key]; |
|
966 } finally { |
|
967 peeking = false; |
|
968 } |
|
969 }; |
|
970 |
|
971 /** |
|
972 * Internal recursive implementation for {@link deepMerge | `deepMerge`}. |
|
973 * |
|
974 * @param target The target object. |
|
975 * @param source The source object containing new values and props. |
|
976 * @param override Whether existing props should be overwritten or not (`true` |
|
977 * by default). |
|
978 */ |
|
979 const deepMergeRecursive = (target, source, override = true) => { |
|
980 // If target is not a plain object and the source is, we don't need to merge |
|
981 // them because the source will be used as the new value of the target. |
|
982 if (!(isPlainObject(target) && isPlainObject(source))) { |
|
983 return; |
|
984 } |
|
985 let hasNewKeys = false; |
|
986 for (const key in source) { |
|
987 const isNew = !(key in target); |
|
988 hasNewKeys = hasNewKeys || isNew; |
|
989 const desc = Object.getOwnPropertyDescriptor(source, key); |
|
990 const proxy = getProxyFromObject(target); |
|
991 const propSignal = !!proxy && hasPropSignal(proxy, key) && getPropSignal(proxy, key); |
|
992 |
|
993 // Handle getters and setters |
|
994 if (typeof desc.get === 'function' || typeof desc.set === 'function') { |
|
995 if (override || isNew) { |
|
996 // Because we are setting a getter or setter, we need to use |
|
997 // Object.defineProperty to define the property on the target object. |
|
998 Object.defineProperty(target, key, { |
|
999 ...desc, |
|
1000 configurable: true, |
|
1001 enumerable: true |
|
1002 }); |
|
1003 // Update the getter in the property signal if it exists |
|
1004 if (desc.get && propSignal) { |
|
1005 propSignal.setGetter(desc.get); |
|
1006 } |
|
1007 } |
|
1008 |
|
1009 // Handle nested objects |
|
1010 } else if (isPlainObject(source[key])) { |
|
1011 const targetValue = Object.getOwnPropertyDescriptor(target, key)?.value; |
|
1012 if (isNew || override && !isPlainObject(targetValue)) { |
|
1013 // Create a new object if the property is new or needs to be overridden |
|
1014 target[key] = {}; |
|
1015 if (propSignal) { |
|
1016 // Create a new proxified state for the nested object |
|
1017 const ns = getNamespaceFromProxy(proxy); |
|
1018 propSignal.setValue(proxifyState(ns, target[key])); |
|
1019 } |
|
1020 deepMergeRecursive(target[key], source[key], override); |
|
1021 } |
|
1022 // Both target and source are plain objects, merge them recursively |
|
1023 else if (isPlainObject(targetValue)) { |
|
1024 deepMergeRecursive(target[key], source[key], override); |
|
1025 } |
|
1026 |
|
1027 // Handle primitive values and non-plain objects |
|
1028 } else if (override || isNew) { |
|
1029 Object.defineProperty(target, key, desc); |
|
1030 if (propSignal) { |
|
1031 const { |
|
1032 value |
|
1033 } = desc; |
|
1034 const ns = getNamespaceFromProxy(proxy); |
|
1035 // Proxify the value if necessary before setting it in the signal |
|
1036 propSignal.setValue(shouldProxy(value) ? proxifyState(ns, value) : value); |
|
1037 } |
|
1038 } |
|
1039 } |
|
1040 if (hasNewKeys && objToIterable.has(target)) { |
|
1041 objToIterable.get(target).value++; |
|
1042 } |
|
1043 }; |
|
1044 |
|
1045 /** |
|
1046 * Recursively update prop values inside the passed `target` and nested plain |
|
1047 * objects, using the values present in `source`. References to plain objects |
|
1048 * are kept, only updating props containing primitives or arrays. Arrays are |
|
1049 * replaced instead of merged or concatenated. |
|
1050 * |
|
1051 * If the `override` parameter is set to `false`, then all values in `target` |
|
1052 * are preserved, and only new properties from `source` are added. |
|
1053 * |
|
1054 * @param target The target object. |
|
1055 * @param source The source object containing new values and props. |
|
1056 * @param override Whether existing props should be overwritten or not (`true` |
|
1057 * by default). |
|
1058 */ |
|
1059 const deepMerge = (target, source, override = true) => signals_core_module_r(() => deepMergeRecursive(getObjectFromProxy(target) || target, source, override)); |
|
1060 |
|
1061 ;// ./node_modules/@wordpress/interactivity/build-module/proxies/store.js |
|
1062 /** |
|
1063 * Internal dependencies |
|
1064 */ |
|
1065 |
|
1066 /** |
|
1067 * External dependencies |
|
1068 */ |
|
1069 |
|
1070 |
|
1071 |
|
1072 /** |
|
1073 * Identifies the store proxies handling the root objects of each store. |
|
1074 */ |
|
1075 const storeRoots = new WeakSet(); |
|
1076 |
|
1077 /** |
|
1078 * Handlers for store proxies. |
|
1079 */ |
|
1080 const storeHandlers = { |
|
1081 get: (target, key, receiver) => { |
|
1082 const result = Reflect.get(target, key); |
|
1083 const ns = getNamespaceFromProxy(receiver); |
|
1084 |
|
1085 /* |
|
1086 * Check if the proxy is the store root and no key with that name exist. In |
|
1087 * that case, return an empty object for the requested key. |
|
1088 */ |
|
1089 if (typeof result === 'undefined' && storeRoots.has(receiver)) { |
|
1090 const obj = {}; |
|
1091 Reflect.set(target, key, obj); |
|
1092 return proxifyStore(ns, obj, false); |
|
1093 } |
|
1094 |
|
1095 /* |
|
1096 * Check if the property is a function. If it is, add the store |
|
1097 * namespace to the stack and wrap the function with the current scope. |
|
1098 * The `withScope` util handles both synchronous functions and generator |
|
1099 * functions. |
|
1100 */ |
|
1101 if (typeof result === 'function') { |
|
1102 setNamespace(ns); |
|
1103 const scoped = withScope(result); |
|
1104 resetNamespace(); |
|
1105 return scoped; |
|
1106 } |
|
1107 |
|
1108 // Check if the property is an object. If it is, proxyify it. |
|
1109 if (isPlainObject(result) && shouldProxy(result)) { |
|
1110 return proxifyStore(ns, result, false); |
|
1111 } |
|
1112 return result; |
|
1113 } |
|
1114 }; |
|
1115 |
|
1116 /** |
|
1117 * Returns the proxy associated with the given store object, creating it if it |
|
1118 * does not exist. |
|
1119 * |
|
1120 * @param namespace The namespace that will be associated to this proxy. |
|
1121 * @param obj The object to proxify. |
|
1122 * |
|
1123 * @param isRoot Whether the passed object is the store root object. |
|
1124 * @throws Error if the object cannot be proxified. Use {@link shouldProxy} to |
|
1125 * check if a proxy can be created for a specific object. |
|
1126 * |
|
1127 * @return The associated proxy. |
|
1128 */ |
|
1129 const proxifyStore = (namespace, obj, isRoot = true) => { |
|
1130 const proxy = createProxy(namespace, obj, storeHandlers); |
|
1131 if (proxy && isRoot) { |
|
1132 storeRoots.add(proxy); |
|
1133 } |
|
1134 return proxy; |
|
1135 }; |
|
1136 |
|
1137 ;// ./node_modules/@wordpress/interactivity/build-module/proxies/context.js |
|
1138 const contextObjectToProxy = new WeakMap(); |
|
1139 const contextObjectToFallback = new WeakMap(); |
|
1140 const contextProxies = new WeakSet(); |
|
1141 const descriptor = Reflect.getOwnPropertyDescriptor; |
|
1142 |
|
1143 // TODO: Use the proxy registry to avoid multiple proxies on the same object. |
|
1144 const contextHandlers = { |
|
1145 get: (target, key) => { |
|
1146 const fallback = contextObjectToFallback.get(target); |
|
1147 // Always subscribe to prop changes in the current context. |
|
1148 const currentProp = target[key]; |
|
1149 |
|
1150 /* |
|
1151 * Return the value from `target` if it exists, or from `fallback` |
|
1152 * otherwise. This way, in the case the property doesn't exist either in |
|
1153 * `target` or `fallback`, it also subscribes to changes in the parent |
|
1154 * context. |
|
1155 */ |
|
1156 return key in target ? currentProp : fallback[key]; |
|
1157 }, |
|
1158 set: (target, key, value) => { |
|
1159 const fallback = contextObjectToFallback.get(target); |
|
1160 |
|
1161 // If the property exists in the current context, modify it. Otherwise, |
|
1162 // add it to the current context. |
|
1163 const obj = key in target || !(key in fallback) ? target : fallback; |
|
1164 obj[key] = value; |
|
1165 return true; |
|
1166 }, |
|
1167 ownKeys: target => [...new Set([...Object.keys(contextObjectToFallback.get(target)), ...Object.keys(target)])], |
|
1168 getOwnPropertyDescriptor: (target, key) => descriptor(target, key) || descriptor(contextObjectToFallback.get(target), key), |
|
1169 has: (target, key) => Reflect.has(target, key) || Reflect.has(contextObjectToFallback.get(target), key) |
|
1170 }; |
|
1171 |
|
1172 /** |
|
1173 * Wrap a context object with a proxy to reproduce the context stack. The proxy |
|
1174 * uses the passed `inherited` context as a fallback to look up for properties |
|
1175 * that don't exist in the given context. Also, updated properties are modified |
|
1176 * where they are defined, or added to the main context when they don't exist. |
|
1177 * |
|
1178 * @param current Current context. |
|
1179 * @param inherited Inherited context, used as fallback. |
|
1180 * |
|
1181 * @return The wrapped context object. |
|
1182 */ |
|
1183 const proxifyContext = (current, inherited = {}) => { |
|
1184 if (contextProxies.has(current)) { |
|
1185 throw Error('This object cannot be proxified.'); |
|
1186 } |
|
1187 // Update the fallback object reference when it changes. |
|
1188 contextObjectToFallback.set(current, inherited); |
|
1189 if (!contextObjectToProxy.has(current)) { |
|
1190 const proxy = new Proxy(current, contextHandlers); |
|
1191 contextObjectToProxy.set(current, proxy); |
|
1192 contextProxies.add(proxy); |
|
1193 } |
|
1194 return contextObjectToProxy.get(current); |
|
1195 }; |
|
1196 |
|
1197 ;// ./node_modules/@wordpress/interactivity/build-module/proxies/index.js |
|
1198 /** |
|
1199 * Internal dependencies |
|
1200 */ |
|
1201 |
|
1202 |
|
1203 |
|
1204 |
|
1205 ;// ./node_modules/@wordpress/interactivity/build-module/store.js |
|
1206 /** |
|
1207 * Internal dependencies |
|
1208 */ |
|
1209 |
|
1210 /** |
|
1211 * External dependencies |
|
1212 */ |
|
1213 |
|
1214 |
|
1215 const stores = new Map(); |
|
1216 const rawStores = new Map(); |
|
1217 const storeLocks = new Map(); |
|
1218 const storeConfigs = new Map(); |
|
1219 const serverStates = new Map(); |
|
1220 |
|
1221 /** |
|
1222 * Get the defined config for the store with the passed namespace. |
|
1223 * |
|
1224 * @param namespace Store's namespace from which to retrieve the config. |
|
1225 * @return Defined config for the given namespace. |
|
1226 */ |
|
1227 const getConfig = namespace => storeConfigs.get(namespace || getNamespace()) || {}; |
|
1228 |
|
1229 /** |
|
1230 * Get the part of the state defined and updated from the server. |
|
1231 * |
|
1232 * The object returned is read-only, and includes the state defined in PHP with |
|
1233 * `wp_interactivity_state()`. When using `actions.navigate()`, this object is |
|
1234 * updated to reflect the changes in its properties, without affecting the state |
|
1235 * returned by `store()`. Directives can subscribe to those changes to update |
|
1236 * the state if needed. |
|
1237 * |
|
1238 * @example |
|
1239 * ```js |
|
1240 * const { state } = store('myStore', { |
|
1241 * callbacks: { |
|
1242 * updateServerState() { |
|
1243 * const serverState = getServerState(); |
|
1244 * // Override some property with the new value that came from the server. |
|
1245 * state.overridableProp = serverState.overridableProp; |
|
1246 * }, |
|
1247 * }, |
|
1248 * }); |
|
1249 * ``` |
|
1250 * |
|
1251 * @param namespace Store's namespace from which to retrieve the server state. |
|
1252 * @return The server state for the given namespace. |
|
1253 */ |
|
1254 const getServerState = namespace => { |
|
1255 const ns = namespace || getNamespace(); |
|
1256 if (!serverStates.has(ns)) { |
|
1257 serverStates.set(ns, proxifyState(ns, {}, { |
|
1258 readOnly: true |
|
1259 })); |
|
1260 } |
|
1261 return serverStates.get(ns); |
|
1262 }; |
|
1263 const universalUnlock = 'I acknowledge that using a private store means my plugin will inevitably break on the next store release.'; |
|
1264 |
|
1265 /** |
|
1266 * Extends the Interactivity API global store adding the passed properties to |
|
1267 * the given namespace. It also returns stable references to the namespace |
|
1268 * content. |
|
1269 * |
|
1270 * These props typically consist of `state`, which is the reactive part of the |
|
1271 * store ― which means that any directive referencing a state property will be |
|
1272 * re-rendered anytime it changes ― and function properties like `actions` and |
|
1273 * `callbacks`, mostly used for event handlers. These props can then be |
|
1274 * referenced by any directive to make the HTML interactive. |
|
1275 * |
|
1276 * @example |
|
1277 * ```js |
|
1278 * const { state } = store( 'counter', { |
|
1279 * state: { |
|
1280 * value: 0, |
|
1281 * get double() { return state.value * 2; }, |
|
1282 * }, |
|
1283 * actions: { |
|
1284 * increment() { |
|
1285 * state.value += 1; |
|
1286 * }, |
|
1287 * }, |
|
1288 * } ); |
|
1289 * ``` |
|
1290 * |
|
1291 * The code from the example above allows blocks to subscribe and interact with |
|
1292 * the store by using directives in the HTML, e.g.: |
|
1293 * |
|
1294 * ```html |
|
1295 * <div data-wp-interactive="counter"> |
|
1296 * <button |
|
1297 * data-wp-text="state.double" |
|
1298 * data-wp-on--click="actions.increment" |
|
1299 * > |
|
1300 * 0 |
|
1301 * </button> |
|
1302 * </div> |
|
1303 * ``` |
|
1304 * @param namespace The store namespace to interact with. |
|
1305 * @param storePart Properties to add to the store namespace. |
|
1306 * @param options Options for the given namespace. |
|
1307 * |
|
1308 * @return A reference to the namespace content. |
|
1309 */ |
|
1310 |
|
1311 // Overload for when the types are inferred. |
|
1312 |
|
1313 // Overload for when types are passed via generics and they contain state. |
|
1314 |
|
1315 // Overload for when types are passed via generics and they don't contain state. |
|
1316 |
|
1317 // Overload for when types are divided into multiple parts. |
|
1318 |
|
1319 function store(namespace, { |
|
1320 state = {}, |
|
1321 ...block |
|
1322 } = {}, { |
|
1323 lock = false |
|
1324 } = {}) { |
|
1325 if (!stores.has(namespace)) { |
|
1326 // Lock the store if the passed lock is different from the universal |
|
1327 // unlock. Once the lock is set (either false, true, or a given string), |
|
1328 // it cannot change. |
|
1329 if (lock !== universalUnlock) { |
|
1330 storeLocks.set(namespace, lock); |
|
1331 } |
|
1332 const rawStore = { |
|
1333 state: proxifyState(namespace, isPlainObject(state) ? state : {}), |
|
1334 ...block |
|
1335 }; |
|
1336 const proxifiedStore = proxifyStore(namespace, rawStore); |
|
1337 rawStores.set(namespace, rawStore); |
|
1338 stores.set(namespace, proxifiedStore); |
|
1339 } else { |
|
1340 // Lock the store if it wasn't locked yet and the passed lock is |
|
1341 // different from the universal unlock. If no lock is given, the store |
|
1342 // will be public and won't accept any lock from now on. |
|
1343 if (lock !== universalUnlock && !storeLocks.has(namespace)) { |
|
1344 storeLocks.set(namespace, lock); |
|
1345 } else { |
|
1346 const storeLock = storeLocks.get(namespace); |
|
1347 const isLockValid = lock === universalUnlock || lock !== true && lock === storeLock; |
|
1348 if (!isLockValid) { |
|
1349 if (!storeLock) { |
|
1350 throw Error('Cannot lock a public store'); |
|
1351 } else { |
|
1352 throw Error('Cannot unlock a private store with an invalid lock code'); |
|
1353 } |
|
1354 } |
|
1355 } |
|
1356 const target = rawStores.get(namespace); |
|
1357 deepMerge(target, block); |
|
1358 deepMerge(target.state, state); |
|
1359 } |
|
1360 return stores.get(namespace); |
|
1361 } |
|
1362 const parseServerData = (dom = document) => { |
|
1363 var _dom$getElementById; |
|
1364 const jsonDataScriptTag = // Preferred Script Module data passing form |
|
1365 (_dom$getElementById = dom.getElementById('wp-script-module-data-@wordpress/interactivity')) !== null && _dom$getElementById !== void 0 ? _dom$getElementById : |
|
1366 // Legacy form |
|
1367 dom.getElementById('wp-interactivity-data'); |
|
1368 if (jsonDataScriptTag?.textContent) { |
|
1369 try { |
|
1370 return JSON.parse(jsonDataScriptTag.textContent); |
|
1371 } catch {} |
|
1372 } |
|
1373 return {}; |
|
1374 }; |
|
1375 const populateServerData = data => { |
|
1376 if (isPlainObject(data?.state)) { |
|
1377 Object.entries(data.state).forEach(([namespace, state]) => { |
|
1378 const st = store(namespace, {}, { |
|
1379 lock: universalUnlock |
|
1380 }); |
|
1381 deepMerge(st.state, state, false); |
|
1382 deepMerge(getServerState(namespace), state); |
|
1383 }); |
|
1384 } |
|
1385 if (isPlainObject(data?.config)) { |
|
1386 Object.entries(data.config).forEach(([namespace, config]) => { |
|
1387 storeConfigs.set(namespace, config); |
|
1388 }); |
|
1389 } |
|
1390 }; |
|
1391 |
|
1392 // Parse and populate the initial state and config. |
|
1393 const data = parseServerData(); |
|
1394 populateServerData(data); |
|
1395 |
|
1396 ;// ./node_modules/@wordpress/interactivity/build-module/hooks.js |
|
1397 // eslint-disable-next-line eslint-comments/disable-enable-pair |
|
1398 /* eslint-disable react-hooks/exhaustive-deps */ |
|
1399 |
|
1400 /** |
|
1401 * External dependencies |
|
1402 */ |
|
1403 |
|
1404 |
|
1405 /** |
|
1406 * Internal dependencies |
|
1407 */ |
|
1408 |
|
1409 |
|
1410 |
|
1411 function isNonDefaultDirectiveSuffix(entry) { |
|
1412 return entry.suffix !== null; |
|
1413 } |
|
1414 function isDefaultDirectiveSuffix(entry) { |
|
1415 return entry.suffix === null; |
|
1416 } |
|
1417 // Main context. |
|
1418 const context = (0,preact_module/* createContext */.q6)({ |
|
1419 client: {}, |
|
1420 server: {} |
|
1421 }); |
|
1422 |
|
1423 // WordPress Directives. |
|
1424 const directiveCallbacks = {}; |
|
1425 const directivePriorities = {}; |
|
1426 |
|
1427 /** |
|
1428 * Register a new directive type in the Interactivity API runtime. |
|
1429 * |
|
1430 * @example |
|
1431 * ```js |
|
1432 * directive( |
|
1433 * 'alert', // Name without the `data-wp-` prefix. |
|
1434 * ( { directives: { alert }, element, evaluate } ) => { |
|
1435 * const defaultEntry = alert.find( isDefaultDirectiveSuffix ); |
|
1436 * element.props.onclick = () => { alert( evaluate( defaultEntry ) ); } |
|
1437 * } |
|
1438 * ) |
|
1439 * ``` |
|
1440 * |
|
1441 * The previous code registers a custom directive type for displaying an alert |
|
1442 * message whenever an element using it is clicked. The message text is obtained |
|
1443 * from the store under the inherited namespace, using `evaluate`. |
|
1444 * |
|
1445 * When the HTML is processed by the Interactivity API, any element containing |
|
1446 * the `data-wp-alert` directive will have the `onclick` event handler, e.g., |
|
1447 * |
|
1448 * ```html |
|
1449 * <div data-wp-interactive="messages"> |
|
1450 * <button data-wp-alert="state.alert">Click me!</button> |
|
1451 * </div> |
|
1452 * ``` |
|
1453 * Note that, in the previous example, the directive callback gets the path |
|
1454 * value (`state.alert`) from the directive entry with suffix `null`. A |
|
1455 * custom suffix can also be specified by appending `--` to the directive |
|
1456 * attribute, followed by the suffix, like in the following HTML snippet: |
|
1457 * |
|
1458 * ```html |
|
1459 * <div data-wp-interactive="myblock"> |
|
1460 * <button |
|
1461 * data-wp-color--text="state.text" |
|
1462 * data-wp-color--background="state.background" |
|
1463 * >Click me!</button> |
|
1464 * </div> |
|
1465 * ``` |
|
1466 * |
|
1467 * This could be an hypothetical implementation of the custom directive used in |
|
1468 * the snippet above. |
|
1469 * |
|
1470 * @example |
|
1471 * ```js |
|
1472 * directive( |
|
1473 * 'color', // Name without prefix and suffix. |
|
1474 * ( { directives: { color: colors }, ref, evaluate } ) => |
|
1475 * colors.forEach( ( color ) => { |
|
1476 * if ( color.suffix = 'text' ) { |
|
1477 * ref.style.setProperty( |
|
1478 * 'color', |
|
1479 * evaluate( color.text ) |
|
1480 * ); |
|
1481 * } |
|
1482 * if ( color.suffix = 'background' ) { |
|
1483 * ref.style.setProperty( |
|
1484 * 'background-color', |
|
1485 * evaluate( color.background ) |
|
1486 * ); |
|
1487 * } |
|
1488 * } ); |
|
1489 * } |
|
1490 * ) |
|
1491 * ``` |
|
1492 * |
|
1493 * @param name Directive name, without the `data-wp-` prefix. |
|
1494 * @param callback Function that runs the directive logic. |
|
1495 * @param options Options object. |
|
1496 * @param options.priority Option to control the directive execution order. The |
|
1497 * lesser, the highest priority. Default is `10`. |
|
1498 */ |
|
1499 const directive = (name, callback, { |
|
1500 priority = 10 |
|
1501 } = {}) => { |
|
1502 directiveCallbacks[name] = callback; |
|
1503 directivePriorities[name] = priority; |
|
1504 }; |
|
1505 |
|
1506 // Resolve the path to some property of the store object. |
|
1507 const resolve = (path, namespace) => { |
|
1508 if (!namespace) { |
|
1509 warn(`Namespace missing for "${path}". The value for that path won't be resolved.`); |
|
1510 return; |
|
1511 } |
|
1512 let resolvedStore = stores.get(namespace); |
|
1513 if (typeof resolvedStore === 'undefined') { |
|
1514 resolvedStore = store(namespace, {}, { |
|
1515 lock: universalUnlock |
|
1516 }); |
|
1517 } |
|
1518 const current = { |
|
1519 ...resolvedStore, |
|
1520 context: getScope().context[namespace] |
|
1521 }; |
|
1522 try { |
|
1523 // TODO: Support lazy/dynamically initialized stores |
|
1524 return path.split('.').reduce((acc, key) => acc[key], current); |
|
1525 } catch (e) {} |
|
1526 }; |
|
1527 |
|
1528 // Generate the evaluate function. |
|
1529 const getEvaluate = ({ |
|
1530 scope |
|
1531 }) => |
|
1532 // TODO: When removing the temporarily remaining `value( ...args )` call below, remove the `...args` parameter too. |
|
1533 (entry, ...args) => { |
|
1534 let { |
|
1535 value: path, |
|
1536 namespace |
|
1537 } = entry; |
|
1538 if (typeof path !== 'string') { |
|
1539 throw new Error('The `value` prop should be a string path'); |
|
1540 } |
|
1541 // If path starts with !, remove it and save a flag. |
|
1542 const hasNegationOperator = path[0] === '!' && !!(path = path.slice(1)); |
|
1543 setScope(scope); |
|
1544 const value = resolve(path, namespace); |
|
1545 // Functions are returned without invoking them. |
|
1546 if (typeof value === 'function') { |
|
1547 // Except if they have a negation operator present, for backward compatibility. |
|
1548 // This pattern is strongly discouraged and deprecated, and it will be removed in a near future release. |
|
1549 // TODO: Remove this condition to effectively ignore negation operator when provided with a function. |
|
1550 if (hasNegationOperator) { |
|
1551 warn('Using a function with a negation operator is deprecated and will stop working in WordPress 6.9. Please use derived state instead.'); |
|
1552 const functionResult = !value(...args); |
|
1553 resetScope(); |
|
1554 return functionResult; |
|
1555 } |
|
1556 // Reset scope before return and wrap the function so it will still run within the correct scope. |
|
1557 resetScope(); |
|
1558 return (...functionArgs) => { |
|
1559 setScope(scope); |
|
1560 const functionResult = value(...functionArgs); |
|
1561 resetScope(); |
|
1562 return functionResult; |
|
1563 }; |
|
1564 } |
|
1565 const result = value; |
|
1566 resetScope(); |
|
1567 return hasNegationOperator ? !result : result; |
|
1568 }; |
|
1569 |
|
1570 // Separate directives by priority. The resulting array contains objects |
|
1571 // of directives grouped by same priority, and sorted in ascending order. |
|
1572 const getPriorityLevels = directives => { |
|
1573 const byPriority = Object.keys(directives).reduce((obj, name) => { |
|
1574 if (directiveCallbacks[name]) { |
|
1575 const priority = directivePriorities[name]; |
|
1576 (obj[priority] = obj[priority] || []).push(name); |
|
1577 } |
|
1578 return obj; |
|
1579 }, {}); |
|
1580 return Object.entries(byPriority).sort(([p1], [p2]) => parseInt(p1) - parseInt(p2)).map(([, arr]) => arr); |
|
1581 }; |
|
1582 |
|
1583 // Component that wraps each priority level of directives of an element. |
|
1584 const Directives = ({ |
|
1585 directives, |
|
1586 priorityLevels: [currentPriorityLevel, ...nextPriorityLevels], |
|
1587 element, |
|
1588 originalProps, |
|
1589 previousScope |
|
1590 }) => { |
|
1591 // Initialize the scope of this element. These scopes are different per each |
|
1592 // level because each level has a different context, but they share the same |
|
1593 // element ref, state and props. |
|
1594 const scope = A({}).current; |
|
1595 scope.evaluate = q(getEvaluate({ |
|
1596 scope |
|
1597 }), []); |
|
1598 const { |
|
1599 client, |
|
1600 server |
|
1601 } = x(context); |
|
1602 scope.context = client; |
|
1603 scope.serverContext = server; |
|
1604 /* eslint-disable react-hooks/rules-of-hooks */ |
|
1605 scope.ref = previousScope?.ref || A(null); |
|
1606 /* eslint-enable react-hooks/rules-of-hooks */ |
|
1607 |
|
1608 // Create a fresh copy of the vnode element and add the props to the scope, |
|
1609 // named as attributes (HTML Attributes). |
|
1610 element = (0,preact_module/* cloneElement */.Ob)(element, { |
|
1611 ref: scope.ref |
|
1612 }); |
|
1613 scope.attributes = element.props; |
|
1614 |
|
1615 // Recursively render the wrapper for the next priority level. |
|
1616 const children = nextPriorityLevels.length > 0 ? (0,preact_module.h)(Directives, { |
|
1617 directives, |
|
1618 priorityLevels: nextPriorityLevels, |
|
1619 element, |
|
1620 originalProps, |
|
1621 previousScope: scope |
|
1622 }) : element; |
|
1623 const props = { |
|
1624 ...originalProps, |
|
1625 children |
|
1626 }; |
|
1627 const directiveArgs = { |
|
1628 directives, |
|
1629 props, |
|
1630 element, |
|
1631 context, |
|
1632 evaluate: scope.evaluate |
|
1633 }; |
|
1634 setScope(scope); |
|
1635 for (const directiveName of currentPriorityLevel) { |
|
1636 const wrapper = directiveCallbacks[directiveName]?.(directiveArgs); |
|
1637 if (wrapper !== undefined) { |
|
1638 props.children = wrapper; |
|
1639 } |
|
1640 } |
|
1641 resetScope(); |
|
1642 return props.children; |
|
1643 }; |
|
1644 |
|
1645 // Preact Options Hook called each time a vnode is created. |
|
1646 const old = preact_module/* options */.fF.vnode; |
|
1647 preact_module/* options */.fF.vnode = vnode => { |
|
1648 if (vnode.props.__directives) { |
|
1649 const props = vnode.props; |
|
1650 const directives = props.__directives; |
|
1651 if (directives.key) { |
|
1652 vnode.key = directives.key.find(isDefaultDirectiveSuffix).value; |
|
1653 } |
|
1654 delete props.__directives; |
|
1655 const priorityLevels = getPriorityLevels(directives); |
|
1656 if (priorityLevels.length > 0) { |
|
1657 vnode.props = { |
|
1658 directives, |
|
1659 priorityLevels, |
|
1660 originalProps: props, |
|
1661 type: vnode.type, |
|
1662 element: (0,preact_module.h)(vnode.type, props), |
|
1663 top: true |
|
1664 }; |
|
1665 vnode.type = Directives; |
|
1666 } |
|
1667 } |
|
1668 if (old) { |
|
1669 old(vnode); |
|
1670 } |
|
1671 }; |
|
1672 |
|
1673 ;// ./node_modules/@wordpress/interactivity/build-module/directives.js |
|
1674 // eslint-disable-next-line eslint-comments/disable-enable-pair |
|
1675 /* eslint-disable react-hooks/exhaustive-deps */ |
|
1676 |
|
1677 /** |
|
1678 * External dependencies |
|
1679 */ |
|
1680 |
|
1681 |
|
1682 |
|
1683 /** |
|
1684 * Internal dependencies |
|
1685 */ |
|
1686 |
|
1687 |
|
1688 |
|
1689 |
|
1690 |
|
1691 /** |
|
1692 * Recursively clone the passed object. |
|
1693 * |
|
1694 * @param source Source object. |
|
1695 * @return Cloned object. |
|
1696 */ |
|
1697 function deepClone(source) { |
|
1698 if (isPlainObject(source)) { |
|
1699 return Object.fromEntries(Object.entries(source).map(([key, value]) => [key, deepClone(value)])); |
|
1700 } |
|
1701 if (Array.isArray(source)) { |
|
1702 return source.map(i => deepClone(i)); |
|
1703 } |
|
1704 return source; |
|
1705 } |
|
1706 |
|
1707 /** |
|
1708 * Wraps event object to warn about access of synchronous properties and methods. |
|
1709 * |
|
1710 * For all store actions attached to an event listener the event object is proxied via this function, unless the action |
|
1711 * uses the `withSyncEvent()` utility to indicate that it requires synchronous access to the event object. |
|
1712 * |
|
1713 * At the moment, the proxied event only emits warnings when synchronous properties or methods are being accessed. In |
|
1714 * the future this will be changed and result in an error. The current temporary behavior allows implementers to update |
|
1715 * their relevant actions to use `withSyncEvent()`. |
|
1716 * |
|
1717 * For additional context, see https://github.com/WordPress/gutenberg/issues/64944. |
|
1718 * |
|
1719 * @param event Event object. |
|
1720 * @return Proxied event object. |
|
1721 */ |
|
1722 function wrapEventAsync(event) { |
|
1723 const handler = { |
|
1724 get(target, prop, receiver) { |
|
1725 const value = target[prop]; |
|
1726 switch (prop) { |
|
1727 case 'currentTarget': |
|
1728 warn(`Accessing the synchronous event.${prop} property in a store action without wrapping it in withSyncEvent() is deprecated and will stop working in WordPress 6.9. Please wrap the store action in withSyncEvent().`); |
|
1729 break; |
|
1730 case 'preventDefault': |
|
1731 case 'stopImmediatePropagation': |
|
1732 case 'stopPropagation': |
|
1733 warn(`Using the synchronous event.${prop}() function in a store action without wrapping it in withSyncEvent() is deprecated and will stop working in WordPress 6.9. Please wrap the store action in withSyncEvent().`); |
|
1734 break; |
|
1735 } |
|
1736 if (value instanceof Function) { |
|
1737 return function (...args) { |
|
1738 return value.apply(this === receiver ? target : this, args); |
|
1739 }; |
|
1740 } |
|
1741 return value; |
|
1742 } |
|
1743 }; |
|
1744 return new Proxy(event, handler); |
|
1745 } |
|
1746 const newRule = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g; |
|
1747 const ruleClean = /\/\*[^]*?\*\/| +/g; |
|
1748 const ruleNewline = /\n+/g; |
|
1749 const empty = ' '; |
|
1750 |
|
1751 /** |
|
1752 * Convert a css style string into a object. |
|
1753 * |
|
1754 * Made by Cristian Bote (@cristianbote) for Goober. |
|
1755 * https://unpkg.com/browse/goober@2.1.13/src/core/astish.js |
|
1756 * |
|
1757 * @param val CSS string. |
|
1758 * @return CSS object. |
|
1759 */ |
|
1760 const cssStringToObject = val => { |
|
1761 const tree = [{}]; |
|
1762 let block, left; |
|
1763 while (block = newRule.exec(val.replace(ruleClean, ''))) { |
|
1764 if (block[4]) { |
|
1765 tree.shift(); |
|
1766 } else if (block[3]) { |
|
1767 left = block[3].replace(ruleNewline, empty).trim(); |
|
1768 tree.unshift(tree[0][left] = tree[0][left] || {}); |
|
1769 } else { |
|
1770 tree[0][block[1]] = block[2].replace(ruleNewline, empty).trim(); |
|
1771 } |
|
1772 } |
|
1773 return tree[0]; |
|
1774 }; |
|
1775 |
|
1776 /** |
|
1777 * Creates a directive that adds an event listener to the global window or |
|
1778 * document object. |
|
1779 * |
|
1780 * @param type 'window' or 'document' |
|
1781 */ |
|
1782 const getGlobalEventDirective = type => { |
|
1783 return ({ |
|
1784 directives, |
|
1785 evaluate |
|
1786 }) => { |
|
1787 directives[`on-${type}`].filter(isNonDefaultDirectiveSuffix).forEach(entry => { |
|
1788 const eventName = entry.suffix.split('--', 1)[0]; |
|
1789 useInit(() => { |
|
1790 const cb = event => { |
|
1791 const result = evaluate(entry); |
|
1792 if (typeof result === 'function') { |
|
1793 if (!result?.sync) { |
|
1794 event = wrapEventAsync(event); |
|
1795 } |
|
1796 result(event); |
|
1797 } |
|
1798 }; |
|
1799 const globalVar = type === 'window' ? window : document; |
|
1800 globalVar.addEventListener(eventName, cb); |
|
1801 return () => globalVar.removeEventListener(eventName, cb); |
|
1802 }); |
|
1803 }); |
|
1804 }; |
|
1805 }; |
|
1806 |
|
1807 /** |
|
1808 * Creates a directive that adds an async event listener to the global window or |
|
1809 * document object. |
|
1810 * |
|
1811 * @param type 'window' or 'document' |
|
1812 */ |
|
1813 const getGlobalAsyncEventDirective = type => { |
|
1814 return ({ |
|
1815 directives, |
|
1816 evaluate |
|
1817 }) => { |
|
1818 directives[`on-async-${type}`].filter(isNonDefaultDirectiveSuffix).forEach(entry => { |
|
1819 const eventName = entry.suffix.split('--', 1)[0]; |
|
1820 useInit(() => { |
|
1821 const cb = async event => { |
|
1822 await splitTask(); |
|
1823 const result = evaluate(entry); |
|
1824 if (typeof result === 'function') { |
|
1825 result(event); |
|
1826 } |
|
1827 }; |
|
1828 const globalVar = type === 'window' ? window : document; |
|
1829 globalVar.addEventListener(eventName, cb, { |
|
1830 passive: true |
|
1831 }); |
|
1832 return () => globalVar.removeEventListener(eventName, cb); |
|
1833 }); |
|
1834 }); |
|
1835 }; |
|
1836 }; |
|
1837 /* harmony default export */ const directives = (() => { |
|
1838 // data-wp-context |
|
1839 directive('context', ({ |
|
1840 directives: { |
|
1841 context |
|
1842 }, |
|
1843 props: { |
|
1844 children |
|
1845 }, |
|
1846 context: inheritedContext |
|
1847 }) => { |
|
1848 const { |
|
1849 Provider |
|
1850 } = inheritedContext; |
|
1851 const defaultEntry = context.find(isDefaultDirectiveSuffix); |
|
1852 const { |
|
1853 client: inheritedClient, |
|
1854 server: inheritedServer |
|
1855 } = x(inheritedContext); |
|
1856 const ns = defaultEntry.namespace; |
|
1857 const client = A(proxifyState(ns, {})); |
|
1858 const server = A(proxifyState(ns, {}, { |
|
1859 readOnly: true |
|
1860 })); |
|
1861 |
|
1862 // No change should be made if `defaultEntry` does not exist. |
|
1863 const contextStack = T(() => { |
|
1864 const result = { |
|
1865 client: { |
|
1866 ...inheritedClient |
|
1867 }, |
|
1868 server: { |
|
1869 ...inheritedServer |
|
1870 } |
|
1871 }; |
|
1872 if (defaultEntry) { |
|
1873 const { |
|
1874 namespace, |
|
1875 value |
|
1876 } = defaultEntry; |
|
1877 // Check that the value is a JSON object. Send a console warning if not. |
|
1878 if (!isPlainObject(value)) { |
|
1879 warn(`The value of data-wp-context in "${namespace}" store must be a valid stringified JSON object.`); |
|
1880 } |
|
1881 deepMerge(client.current, deepClone(value), false); |
|
1882 deepMerge(server.current, deepClone(value)); |
|
1883 result.client[namespace] = proxifyContext(client.current, inheritedClient[namespace]); |
|
1884 result.server[namespace] = proxifyContext(server.current, inheritedServer[namespace]); |
|
1885 } |
|
1886 return result; |
|
1887 }, [defaultEntry, inheritedClient, inheritedServer]); |
|
1888 return (0,preact_module.h)(Provider, { |
|
1889 value: contextStack |
|
1890 }, children); |
|
1891 }, { |
|
1892 priority: 5 |
|
1893 }); |
|
1894 |
|
1895 // data-wp-watch--[name] |
|
1896 directive('watch', ({ |
|
1897 directives: { |
|
1898 watch |
|
1899 }, |
|
1900 evaluate |
|
1901 }) => { |
|
1902 watch.forEach(entry => { |
|
1903 useWatch(() => { |
|
1904 let start; |
|
1905 if (false) {} |
|
1906 let result = evaluate(entry); |
|
1907 if (typeof result === 'function') { |
|
1908 result = result(); |
|
1909 } |
|
1910 if (false) {} |
|
1911 return result; |
|
1912 }); |
|
1913 }); |
|
1914 }); |
|
1915 |
|
1916 // data-wp-init--[name] |
|
1917 directive('init', ({ |
|
1918 directives: { |
|
1919 init |
|
1920 }, |
|
1921 evaluate |
|
1922 }) => { |
|
1923 init.forEach(entry => { |
|
1924 // TODO: Replace with useEffect to prevent unneeded scopes. |
|
1925 useInit(() => { |
|
1926 let start; |
|
1927 if (false) {} |
|
1928 let result = evaluate(entry); |
|
1929 if (typeof result === 'function') { |
|
1930 result = result(); |
|
1931 } |
|
1932 if (false) {} |
|
1933 return result; |
|
1934 }); |
|
1935 }); |
|
1936 }); |
|
1937 |
|
1938 // data-wp-on--[event] |
|
1939 directive('on', ({ |
|
1940 directives: { |
|
1941 on |
|
1942 }, |
|
1943 element, |
|
1944 evaluate |
|
1945 }) => { |
|
1946 const events = new Map(); |
|
1947 on.filter(isNonDefaultDirectiveSuffix).forEach(entry => { |
|
1948 const event = entry.suffix.split('--')[0]; |
|
1949 if (!events.has(event)) { |
|
1950 events.set(event, new Set()); |
|
1951 } |
|
1952 events.get(event).add(entry); |
|
1953 }); |
|
1954 events.forEach((entries, eventType) => { |
|
1955 const existingHandler = element.props[`on${eventType}`]; |
|
1956 element.props[`on${eventType}`] = event => { |
|
1957 entries.forEach(entry => { |
|
1958 if (existingHandler) { |
|
1959 existingHandler(event); |
|
1960 } |
|
1961 let start; |
|
1962 if (false) {} |
|
1963 const result = evaluate(entry); |
|
1964 if (typeof result === 'function') { |
|
1965 if (!result?.sync) { |
|
1966 event = wrapEventAsync(event); |
|
1967 } |
|
1968 result(event); |
|
1969 } |
|
1970 if (false) {} |
|
1971 }); |
|
1972 }; |
|
1973 }); |
|
1974 }); |
|
1975 |
|
1976 // data-wp-on-async--[event] |
|
1977 directive('on-async', ({ |
|
1978 directives: { |
|
1979 'on-async': onAsync |
|
1980 }, |
|
1981 element, |
|
1982 evaluate |
|
1983 }) => { |
|
1984 const events = new Map(); |
|
1985 onAsync.filter(isNonDefaultDirectiveSuffix).forEach(entry => { |
|
1986 const event = entry.suffix.split('--')[0]; |
|
1987 if (!events.has(event)) { |
|
1988 events.set(event, new Set()); |
|
1989 } |
|
1990 events.get(event).add(entry); |
|
1991 }); |
|
1992 events.forEach((entries, eventType) => { |
|
1993 const existingHandler = element.props[`on${eventType}`]; |
|
1994 element.props[`on${eventType}`] = event => { |
|
1995 if (existingHandler) { |
|
1996 existingHandler(event); |
|
1997 } |
|
1998 entries.forEach(async entry => { |
|
1999 await splitTask(); |
|
2000 const result = evaluate(entry); |
|
2001 if (typeof result === 'function') { |
|
2002 result(event); |
|
2003 } |
|
2004 }); |
|
2005 }; |
|
2006 }); |
|
2007 }); |
|
2008 |
|
2009 // data-wp-on-window--[event] |
|
2010 directive('on-window', getGlobalEventDirective('window')); |
|
2011 // data-wp-on-document--[event] |
|
2012 directive('on-document', getGlobalEventDirective('document')); |
|
2013 |
|
2014 // data-wp-on-async-window--[event] |
|
2015 directive('on-async-window', getGlobalAsyncEventDirective('window')); |
|
2016 // data-wp-on-async-document--[event] |
|
2017 directive('on-async-document', getGlobalAsyncEventDirective('document')); |
|
2018 |
|
2019 // data-wp-class--[classname] |
|
2020 directive('class', ({ |
|
2021 directives: { |
|
2022 class: classNames |
|
2023 }, |
|
2024 element, |
|
2025 evaluate |
|
2026 }) => { |
|
2027 classNames.filter(isNonDefaultDirectiveSuffix).forEach(entry => { |
|
2028 const className = entry.suffix; |
|
2029 let result = evaluate(entry); |
|
2030 if (typeof result === 'function') { |
|
2031 result = result(); |
|
2032 } |
|
2033 const currentClass = element.props.class || ''; |
|
2034 const classFinder = new RegExp(`(^|\\s)${className}(\\s|$)`, 'g'); |
|
2035 if (!result) { |
|
2036 element.props.class = currentClass.replace(classFinder, ' ').trim(); |
|
2037 } else if (!classFinder.test(currentClass)) { |
|
2038 element.props.class = currentClass ? `${currentClass} ${className}` : className; |
|
2039 } |
|
2040 useInit(() => { |
|
2041 /* |
|
2042 * This seems necessary because Preact doesn't change the class |
|
2043 * names on the hydration, so we have to do it manually. It doesn't |
|
2044 * need deps because it only needs to do it the first time. |
|
2045 */ |
|
2046 if (!result) { |
|
2047 element.ref.current.classList.remove(className); |
|
2048 } else { |
|
2049 element.ref.current.classList.add(className); |
|
2050 } |
|
2051 }); |
|
2052 }); |
|
2053 }); |
|
2054 |
|
2055 // data-wp-style--[style-prop] |
|
2056 directive('style', ({ |
|
2057 directives: { |
|
2058 style |
|
2059 }, |
|
2060 element, |
|
2061 evaluate |
|
2062 }) => { |
|
2063 style.filter(isNonDefaultDirectiveSuffix).forEach(entry => { |
|
2064 const styleProp = entry.suffix; |
|
2065 let result = evaluate(entry); |
|
2066 if (typeof result === 'function') { |
|
2067 result = result(); |
|
2068 } |
|
2069 element.props.style = element.props.style || {}; |
|
2070 if (typeof element.props.style === 'string') { |
|
2071 element.props.style = cssStringToObject(element.props.style); |
|
2072 } |
|
2073 if (!result) { |
|
2074 delete element.props.style[styleProp]; |
|
2075 } else { |
|
2076 element.props.style[styleProp] = result; |
|
2077 } |
|
2078 useInit(() => { |
|
2079 /* |
|
2080 * This seems necessary because Preact doesn't change the styles on |
|
2081 * the hydration, so we have to do it manually. It doesn't need deps |
|
2082 * because it only needs to do it the first time. |
|
2083 */ |
|
2084 if (!result) { |
|
2085 element.ref.current.style.removeProperty(styleProp); |
|
2086 } else { |
|
2087 element.ref.current.style[styleProp] = result; |
|
2088 } |
|
2089 }); |
|
2090 }); |
|
2091 }); |
|
2092 |
|
2093 // data-wp-bind--[attribute] |
|
2094 directive('bind', ({ |
|
2095 directives: { |
|
2096 bind |
|
2097 }, |
|
2098 element, |
|
2099 evaluate |
|
2100 }) => { |
|
2101 bind.filter(isNonDefaultDirectiveSuffix).forEach(entry => { |
|
2102 const attribute = entry.suffix; |
|
2103 let result = evaluate(entry); |
|
2104 if (typeof result === 'function') { |
|
2105 result = result(); |
|
2106 } |
|
2107 element.props[attribute] = result; |
|
2108 |
|
2109 /* |
|
2110 * This is necessary because Preact doesn't change the attributes on the |
|
2111 * hydration, so we have to do it manually. It only needs to do it the |
|
2112 * first time. After that, Preact will handle the changes. |
|
2113 */ |
|
2114 useInit(() => { |
|
2115 const el = element.ref.current; |
|
2116 |
|
2117 /* |
|
2118 * We set the value directly to the corresponding HTMLElement instance |
|
2119 * property excluding the following special cases. We follow Preact's |
|
2120 * logic: https://github.com/preactjs/preact/blob/ea49f7a0f9d1ff2c98c0bdd66aa0cbc583055246/src/diff/props.js#L110-L129 |
|
2121 */ |
|
2122 if (attribute === 'style') { |
|
2123 if (typeof result === 'string') { |
|
2124 el.style.cssText = result; |
|
2125 } |
|
2126 return; |
|
2127 } else if (attribute !== 'width' && attribute !== 'height' && attribute !== 'href' && attribute !== 'list' && attribute !== 'form' && |
|
2128 /* |
|
2129 * The value for `tabindex` follows the parsing rules for an |
|
2130 * integer. If that fails, or if the attribute isn't present, then |
|
2131 * the browsers should "follow platform conventions to determine if |
|
2132 * the element should be considered as a focusable area", |
|
2133 * practically meaning that most elements get a default of `-1` (not |
|
2134 * focusable), but several also get a default of `0` (focusable in |
|
2135 * order after all elements with a positive `tabindex` value). |
|
2136 * |
|
2137 * @see https://html.spec.whatwg.org/#tabindex-value |
|
2138 */ |
|
2139 attribute !== 'tabIndex' && attribute !== 'download' && attribute !== 'rowSpan' && attribute !== 'colSpan' && attribute !== 'role' && attribute in el) { |
|
2140 try { |
|
2141 el[attribute] = result === null || result === undefined ? '' : result; |
|
2142 return; |
|
2143 } catch (err) {} |
|
2144 } |
|
2145 /* |
|
2146 * aria- and data- attributes have no boolean representation. |
|
2147 * A `false` value is different from the attribute not being |
|
2148 * present, so we can't remove it. |
|
2149 * We follow Preact's logic: https://github.com/preactjs/preact/blob/ea49f7a0f9d1ff2c98c0bdd66aa0cbc583055246/src/diff/props.js#L131C24-L136 |
|
2150 */ |
|
2151 if (result !== null && result !== undefined && (result !== false || attribute[4] === '-')) { |
|
2152 el.setAttribute(attribute, result); |
|
2153 } else { |
|
2154 el.removeAttribute(attribute); |
|
2155 } |
|
2156 }); |
|
2157 }); |
|
2158 }); |
|
2159 |
|
2160 // data-wp-ignore |
|
2161 directive('ignore', ({ |
|
2162 element: { |
|
2163 type: Type, |
|
2164 props: { |
|
2165 innerHTML, |
|
2166 ...rest |
|
2167 } |
|
2168 } |
|
2169 }) => { |
|
2170 // Preserve the initial inner HTML. |
|
2171 const cached = T(() => innerHTML, []); |
|
2172 return (0,preact_module.h)(Type, { |
|
2173 dangerouslySetInnerHTML: { |
|
2174 __html: cached |
|
2175 }, |
|
2176 ...rest |
|
2177 }); |
|
2178 }); |
|
2179 |
|
2180 // data-wp-text |
|
2181 directive('text', ({ |
|
2182 directives: { |
|
2183 text |
|
2184 }, |
|
2185 element, |
|
2186 evaluate |
|
2187 }) => { |
|
2188 const entry = text.find(isDefaultDirectiveSuffix); |
|
2189 if (!entry) { |
|
2190 element.props.children = null; |
|
2191 return; |
|
2192 } |
|
2193 try { |
|
2194 let result = evaluate(entry); |
|
2195 if (typeof result === 'function') { |
|
2196 result = result(); |
|
2197 } |
|
2198 element.props.children = typeof result === 'object' ? null : result.toString(); |
|
2199 } catch (e) { |
|
2200 element.props.children = null; |
|
2201 } |
|
2202 }); |
|
2203 |
|
2204 // data-wp-run |
|
2205 directive('run', ({ |
|
2206 directives: { |
|
2207 run |
|
2208 }, |
|
2209 evaluate |
|
2210 }) => { |
|
2211 run.forEach(entry => { |
|
2212 let result = evaluate(entry); |
|
2213 if (typeof result === 'function') { |
|
2214 result = result(); |
|
2215 } |
|
2216 return result; |
|
2217 }); |
|
2218 }); |
|
2219 |
|
2220 // data-wp-each--[item] |
|
2221 directive('each', ({ |
|
2222 directives: { |
|
2223 each, |
|
2224 'each-key': eachKey |
|
2225 }, |
|
2226 context: inheritedContext, |
|
2227 element, |
|
2228 evaluate |
|
2229 }) => { |
|
2230 if (element.type !== 'template') { |
|
2231 return; |
|
2232 } |
|
2233 const { |
|
2234 Provider |
|
2235 } = inheritedContext; |
|
2236 const inheritedValue = x(inheritedContext); |
|
2237 const [entry] = each; |
|
2238 const { |
|
2239 namespace |
|
2240 } = entry; |
|
2241 let iterable = evaluate(entry); |
|
2242 if (typeof iterable === 'function') { |
|
2243 iterable = iterable(); |
|
2244 } |
|
2245 if (typeof iterable?.[Symbol.iterator] !== 'function') { |
|
2246 return; |
|
2247 } |
|
2248 const itemProp = isNonDefaultDirectiveSuffix(entry) ? kebabToCamelCase(entry.suffix) : 'item'; |
|
2249 const result = []; |
|
2250 for (const item of iterable) { |
|
2251 const itemContext = proxifyContext(proxifyState(namespace, {}), inheritedValue.client[namespace]); |
|
2252 const mergedContext = { |
|
2253 client: { |
|
2254 ...inheritedValue.client, |
|
2255 [namespace]: itemContext |
|
2256 }, |
|
2257 server: { |
|
2258 ...inheritedValue.server |
|
2259 } |
|
2260 }; |
|
2261 |
|
2262 // Set the item after proxifying the context. |
|
2263 mergedContext.client[namespace][itemProp] = item; |
|
2264 const scope = { |
|
2265 ...getScope(), |
|
2266 context: mergedContext.client, |
|
2267 serverContext: mergedContext.server |
|
2268 }; |
|
2269 const key = eachKey ? getEvaluate({ |
|
2270 scope |
|
2271 })(eachKey[0]) : item; |
|
2272 result.push((0,preact_module.h)(Provider, { |
|
2273 value: mergedContext, |
|
2274 key |
|
2275 }, element.props.content)); |
|
2276 } |
|
2277 return result; |
|
2278 }, { |
|
2279 priority: 20 |
|
2280 }); |
|
2281 directive('each-child', () => null, { |
|
2282 priority: 1 |
|
2283 }); |
|
2284 }); |
|
2285 |
|
2286 ;// ./node_modules/@wordpress/interactivity/build-module/constants.js |
|
2287 const directivePrefix = 'wp'; |
|
2288 |
|
2289 ;// ./node_modules/@wordpress/interactivity/build-module/vdom.js |
|
2290 /** |
|
2291 * External dependencies |
|
2292 */ |
|
2293 |
|
2294 /** |
|
2295 * Internal dependencies |
|
2296 */ |
|
2297 |
|
2298 |
|
2299 const ignoreAttr = `data-${directivePrefix}-ignore`; |
|
2300 const islandAttr = `data-${directivePrefix}-interactive`; |
|
2301 const fullPrefix = `data-${directivePrefix}-`; |
|
2302 const namespaces = []; |
|
2303 const currentNamespace = () => { |
|
2304 var _namespaces; |
|
2305 return (_namespaces = namespaces[namespaces.length - 1]) !== null && _namespaces !== void 0 ? _namespaces : null; |
|
2306 }; |
|
2307 const isObject = item => Boolean(item && typeof item === 'object' && item.constructor === Object); |
|
2308 |
|
2309 // Regular expression for directive parsing. |
|
2310 const directiveParser = new RegExp(`^data-${directivePrefix}-` + |
|
2311 // ${p} must be a prefix string, like 'wp'. |
|
2312 // Match alphanumeric characters including hyphen-separated |
|
2313 // segments. It excludes underscore intentionally to prevent confusion. |
|
2314 // E.g., "custom-directive". |
|
2315 '([a-z0-9]+(?:-[a-z0-9]+)*)' + |
|
2316 // (Optional) Match '--' followed by any alphanumeric characters. It |
|
2317 // excludes underscore intentionally to prevent confusion, but it can |
|
2318 // contain multiple hyphens. E.g., "--custom-prefix--with-more-info". |
|
2319 '(?:--([a-z0-9_-]+))?$', 'i' // Case insensitive. |
|
2320 ); |
|
2321 |
|
2322 // Regular expression for reference parsing. It can contain a namespace before |
|
2323 // the reference, separated by `::`, like `some-namespace::state.somePath`. |
|
2324 // Namespaces can contain any alphanumeric characters, hyphens, underscores or |
|
2325 // forward slashes. References don't have any restrictions. |
|
2326 const nsPathRegExp = /^([\w_\/-]+)::(.+)$/; |
|
2327 const hydratedIslands = new WeakSet(); |
|
2328 |
|
2329 /** |
|
2330 * Recursive function that transforms a DOM tree into vDOM. |
|
2331 * |
|
2332 * @param root The root element or node to start traversing on. |
|
2333 * @return The resulting vDOM tree. |
|
2334 */ |
|
2335 function toVdom(root) { |
|
2336 const treeWalker = document.createTreeWalker(root, 205 // TEXT + CDATA_SECTION + COMMENT + PROCESSING_INSTRUCTION + ELEMENT |
|
2337 ); |
|
2338 function walk(node) { |
|
2339 const { |
|
2340 nodeType |
|
2341 } = node; |
|
2342 |
|
2343 // TEXT_NODE (3) |
|
2344 if (nodeType === 3) { |
|
2345 return [node.data]; |
|
2346 } |
|
2347 |
|
2348 // CDATA_SECTION_NODE (4) |
|
2349 if (nodeType === 4) { |
|
2350 var _nodeValue; |
|
2351 const next = treeWalker.nextSibling(); |
|
2352 node.replaceWith(new window.Text((_nodeValue = node.nodeValue) !== null && _nodeValue !== void 0 ? _nodeValue : '')); |
|
2353 return [node.nodeValue, next]; |
|
2354 } |
|
2355 |
|
2356 // COMMENT_NODE (8) || PROCESSING_INSTRUCTION_NODE (7) |
|
2357 if (nodeType === 8 || nodeType === 7) { |
|
2358 const next = treeWalker.nextSibling(); |
|
2359 node.remove(); |
|
2360 return [null, next]; |
|
2361 } |
|
2362 const elementNode = node; |
|
2363 const { |
|
2364 attributes |
|
2365 } = elementNode; |
|
2366 const localName = elementNode.localName; |
|
2367 const props = {}; |
|
2368 const children = []; |
|
2369 const directives = []; |
|
2370 let ignore = false; |
|
2371 let island = false; |
|
2372 for (let i = 0; i < attributes.length; i++) { |
|
2373 const attributeName = attributes[i].name; |
|
2374 const attributeValue = attributes[i].value; |
|
2375 if (attributeName[fullPrefix.length] && attributeName.slice(0, fullPrefix.length) === fullPrefix) { |
|
2376 if (attributeName === ignoreAttr) { |
|
2377 ignore = true; |
|
2378 } else { |
|
2379 var _regexResult$, _regexResult$2; |
|
2380 const regexResult = nsPathRegExp.exec(attributeValue); |
|
2381 const namespace = (_regexResult$ = regexResult?.[1]) !== null && _regexResult$ !== void 0 ? _regexResult$ : null; |
|
2382 let value = (_regexResult$2 = regexResult?.[2]) !== null && _regexResult$2 !== void 0 ? _regexResult$2 : attributeValue; |
|
2383 try { |
|
2384 const parsedValue = JSON.parse(value); |
|
2385 value = isObject(parsedValue) ? parsedValue : value; |
|
2386 } catch {} |
|
2387 if (attributeName === islandAttr) { |
|
2388 island = true; |
|
2389 const islandNamespace = |
|
2390 // eslint-disable-next-line no-nested-ternary |
|
2391 typeof value === 'string' ? value : typeof value?.namespace === 'string' ? value.namespace : null; |
|
2392 namespaces.push(islandNamespace); |
|
2393 } else { |
|
2394 directives.push([attributeName, namespace, value]); |
|
2395 } |
|
2396 } |
|
2397 } else if (attributeName === 'ref') { |
|
2398 continue; |
|
2399 } |
|
2400 props[attributeName] = attributeValue; |
|
2401 } |
|
2402 if (ignore && !island) { |
|
2403 return [(0,preact_module.h)(localName, { |
|
2404 ...props, |
|
2405 innerHTML: elementNode.innerHTML, |
|
2406 __directives: { |
|
2407 ignore: true |
|
2408 } |
|
2409 })]; |
|
2410 } |
|
2411 if (island) { |
|
2412 hydratedIslands.add(elementNode); |
|
2413 } |
|
2414 if (directives.length) { |
|
2415 props.__directives = directives.reduce((obj, [name, ns, value]) => { |
|
2416 const directiveMatch = directiveParser.exec(name); |
|
2417 if (directiveMatch === null) { |
|
2418 warn(`Found malformed directive name: ${name}.`); |
|
2419 return obj; |
|
2420 } |
|
2421 const prefix = directiveMatch[1] || ''; |
|
2422 const suffix = directiveMatch[2] || null; |
|
2423 obj[prefix] = obj[prefix] || []; |
|
2424 obj[prefix].push({ |
|
2425 namespace: ns !== null && ns !== void 0 ? ns : currentNamespace(), |
|
2426 value: value, |
|
2427 suffix |
|
2428 }); |
|
2429 return obj; |
|
2430 }, {}); |
|
2431 } |
|
2432 if (localName === 'template') { |
|
2433 props.content = [...elementNode.content.childNodes].map(childNode => toVdom(childNode)); |
|
2434 } else { |
|
2435 let child = treeWalker.firstChild(); |
|
2436 if (child) { |
|
2437 while (child) { |
|
2438 const [vnode, nextChild] = walk(child); |
|
2439 if (vnode) { |
|
2440 children.push(vnode); |
|
2441 } |
|
2442 child = nextChild || treeWalker.nextSibling(); |
|
2443 } |
|
2444 treeWalker.parentNode(); |
|
2445 } |
|
2446 } |
|
2447 |
|
2448 // Restore previous namespace. |
|
2449 if (island) { |
|
2450 namespaces.pop(); |
|
2451 } |
|
2452 return [(0,preact_module.h)(localName, props, children)]; |
|
2453 } |
|
2454 return walk(treeWalker.currentNode); |
|
2455 } |
|
2456 |
|
2457 ;// ./node_modules/@wordpress/interactivity/build-module/init.js |
|
2458 /** |
|
2459 * External dependencies |
|
2460 */ |
|
2461 |
|
2462 /** |
|
2463 * Internal dependencies |
|
2464 */ |
|
2465 |
|
2466 |
|
2467 |
|
2468 |
|
2469 // Keep the same root fragment for each interactive region node. |
|
2470 const regionRootFragments = new WeakMap(); |
|
2471 const getRegionRootFragment = region => { |
|
2472 if (!region.parentElement) { |
|
2473 throw Error('The passed region should be an element with a parent.'); |
|
2474 } |
|
2475 if (!regionRootFragments.has(region)) { |
|
2476 regionRootFragments.set(region, createRootFragment(region.parentElement, region)); |
|
2477 } |
|
2478 return regionRootFragments.get(region); |
|
2479 }; |
|
2480 |
|
2481 // Initial vDOM regions associated with its DOM element. |
|
2482 const initialVdom = new WeakMap(); |
|
2483 |
|
2484 // Initialize the router with the initial DOM. |
|
2485 const init = async () => { |
|
2486 const nodes = document.querySelectorAll(`[data-${directivePrefix}-interactive]`); |
|
2487 |
|
2488 /* |
|
2489 * This `await` with setTimeout is required to apparently ensure that the interactive blocks have their stores |
|
2490 * fully initialized prior to hydrating the blocks. If this is not present, then an error occurs, for example: |
|
2491 * > view.js:46 Uncaught (in promise) ReferenceError: Cannot access 'state' before initialization |
|
2492 * This occurs when splitTask() is implemented with scheduler.yield() as opposed to setTimeout(), as with the former |
|
2493 * split tasks are added to the front of the task queue whereas with the latter they are added to the end of the queue. |
|
2494 */ |
|
2495 await new Promise(resolve => { |
|
2496 setTimeout(resolve, 0); |
|
2497 }); |
|
2498 for (const node of nodes) { |
|
2499 if (!hydratedIslands.has(node)) { |
|
2500 await splitTask(); |
|
2501 const fragment = getRegionRootFragment(node); |
|
2502 const vdom = toVdom(node); |
|
2503 initialVdom.set(node, vdom); |
|
2504 await splitTask(); |
|
2505 (0,preact_module/* hydrate */.Qv)(vdom, fragment); |
|
2506 } |
|
2507 } |
|
2508 }; |
|
2509 |
|
2510 ;// ./node_modules/@wordpress/interactivity/build-module/index.js |
|
2511 /** |
|
2512 * External dependencies |
|
2513 */ |
|
2514 |
|
2515 |
|
2516 |
|
2517 /** |
|
2518 * Internal dependencies |
|
2519 */ |
|
2520 |
|
2521 |
|
2522 |
|
2523 |
|
2524 |
|
2525 |
|
2526 |
|
2527 |
|
2528 |
|
2529 |
|
2530 |
|
2531 |
|
2532 const requiredConsent = 'I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress.'; |
|
2533 const privateApis = lock => { |
|
2534 if (lock === requiredConsent) { |
|
2535 return { |
|
2536 directivePrefix: directivePrefix, |
|
2537 getRegionRootFragment: getRegionRootFragment, |
|
2538 initialVdom: initialVdom, |
|
2539 toVdom: toVdom, |
|
2540 directive: directive, |
|
2541 getNamespace: getNamespace, |
|
2542 h: preact_module.h, |
|
2543 cloneElement: preact_module/* cloneElement */.Ob, |
|
2544 render: preact_module/* render */.XX, |
|
2545 proxifyState: proxifyState, |
|
2546 parseServerData: parseServerData, |
|
2547 populateServerData: populateServerData, |
|
2548 batch: signals_core_module_r |
|
2549 }; |
|
2550 } |
|
2551 throw new Error('Forbidden access.'); |
|
2552 }; |
|
2553 directives(); |
|
2554 init(); |
|
2555 |
|
2556 |
|
2557 /***/ }), |
|
2558 |
|
2559 /***/ 622: |
|
2560 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { |
|
2561 |
|
2562 /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
|
2563 /* harmony export */ FK: () => (/* binding */ k), |
|
2564 /* harmony export */ Ob: () => (/* binding */ J), |
|
2565 /* harmony export */ Qv: () => (/* binding */ G), |
|
2566 /* harmony export */ XX: () => (/* binding */ E), |
|
2567 /* harmony export */ fF: () => (/* binding */ l), |
|
2568 /* harmony export */ h: () => (/* binding */ _), |
|
2569 /* harmony export */ q6: () => (/* binding */ K), |
|
2570 /* harmony export */ uA: () => (/* binding */ x), |
|
2571 /* harmony export */ zO: () => (/* binding */ u) |
|
2572 /* harmony export */ }); |
|
2573 /* unused harmony exports createElement, createRef, toChildArray */ |
|
2574 var n,l,t,u,i,r,o,e,f,c,s,a,h,p={},v=[],y=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,d=Array.isArray;function w(n,l){for(var t in l)n[t]=l[t];return n}function g(n){n&&n.parentNode&&n.parentNode.removeChild(n)}function _(l,t,u){var i,r,o,e={};for(o in t)"key"==o?i=t[o]:"ref"==o?r=t[o]:e[o]=t[o];if(arguments.length>2&&(e.children=arguments.length>3?n.call(arguments,2):u),"function"==typeof l&&null!=l.defaultProps)for(o in l.defaultProps)void 0===e[o]&&(e[o]=l.defaultProps[o]);return m(l,e,i,r,null)}function m(n,u,i,r,o){var e={type:n,props:u,key:i,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==o?++t:o,__i:-1,__u:0};return null==o&&null!=l.vnode&&l.vnode(e),e}function b(){return{current:null}}function k(n){return n.children}function x(n,l){this.props=n,this.context=l}function S(n,l){if(null==l)return n.__?S(n.__,n.__i+1):null;for(var t;l<n.__k.length;l++)if(null!=(t=n.__k[l])&&null!=t.__e)return t.__e;return"function"==typeof n.type?S(n):null}function C(n){var l,t;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(t=n.__k[l])&&null!=t.__e){n.__e=n.__c.base=t.__e;break}return C(n)}}function M(n){(!n.__d&&(n.__d=!0)&&i.push(n)&&!$.__r++||r!==l.debounceRendering)&&((r=l.debounceRendering)||o)($)}function $(){for(var n,t,u,r,o,f,c,s=1;i.length;)i.length>s&&i.sort(e),n=i.shift(),s=i.length,n.__d&&(u=void 0,o=(r=(t=n).__v).__e,f=[],c=[],t.__P&&((u=w({},r)).__v=r.__v+1,l.vnode&&l.vnode(u),O(t.__P,u,r,t.__n,t.__P.namespaceURI,32&r.__u?[o]:null,f,null==o?S(r):o,!!(32&r.__u),c),u.__v=r.__v,u.__.__k[u.__i]=u,z(f,u,c),u.__e!=o&&C(u)));$.__r=0}function I(n,l,t,u,i,r,o,e,f,c,s){var a,h,y,d,w,g,_=u&&u.__k||v,m=l.length;for(f=P(t,l,_,f,m),a=0;a<m;a++)null!=(y=t.__k[a])&&(h=-1===y.__i?p:_[y.__i]||p,y.__i=a,g=O(n,y,h,i,r,o,e,f,c,s),d=y.__e,y.ref&&h.ref!=y.ref&&(h.ref&&q(h.ref,null,y),s.push(y.ref,y.__c||d,y)),null==w&&null!=d&&(w=d),4&y.__u||h.__k===y.__k?f=A(y,f,n):"function"==typeof y.type&&void 0!==g?f=g:d&&(f=d.nextSibling),y.__u&=-7);return t.__e=w,f}function P(n,l,t,u,i){var r,o,e,f,c,s=t.length,a=s,h=0;for(n.__k=new Array(i),r=0;r<i;r++)null!=(o=l[r])&&"boolean"!=typeof o&&"function"!=typeof o?(f=r+h,(o=n.__k[r]="string"==typeof o||"number"==typeof o||"bigint"==typeof o||o.constructor==String?m(null,o,null,null,null):d(o)?m(k,{children:o},null,null,null):void 0===o.constructor&&o.__b>0?m(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):o).__=n,o.__b=n.__b+1,e=null,-1!==(c=o.__i=L(o,t,f,a))&&(a--,(e=t[c])&&(e.__u|=2)),null==e||null===e.__v?(-1==c&&(i>s?h--:i<s&&h++),"function"!=typeof o.type&&(o.__u|=4)):c!=f&&(c==f-1?h--:c==f+1?h++:(c>f?h--:h++,o.__u|=4))):n.__k[r]=null;if(a)for(r=0;r<s;r++)null!=(e=t[r])&&0==(2&e.__u)&&(e.__e==u&&(u=S(e)),B(e,e));return u}function A(n,l,t){var u,i;if("function"==typeof n.type){for(u=n.__k,i=0;u&&i<u.length;i++)u[i]&&(u[i].__=n,l=A(u[i],l,t));return l}n.__e!=l&&(l&&n.type&&!t.contains(l)&&(l=S(n)),t.insertBefore(n.__e,l||null),l=n.__e);do{l=l&&l.nextSibling}while(null!=l&&8==l.nodeType);return l}function H(n,l){return l=l||[],null==n||"boolean"==typeof n||(d(n)?n.some(function(n){H(n,l)}):l.push(n)),l}function L(n,l,t,u){var i,r,o=n.key,e=n.type,f=l[t];if(null===f&&null==n.key||f&&o==f.key&&e===f.type&&0==(2&f.__u))return t;if(u>(null!=f&&0==(2&f.__u)?1:0))for(i=t-1,r=t+1;i>=0||r<l.length;){if(i>=0){if((f=l[i])&&0==(2&f.__u)&&o==f.key&&e===f.type)return i;i--}if(r<l.length){if((f=l[r])&&0==(2&f.__u)&&o==f.key&&e===f.type)return r;r++}}return-1}function T(n,l,t){"-"==l[0]?n.setProperty(l,null==t?"":t):n[l]=null==t?"":"number"!=typeof t||y.test(l)?t:t+"px"}function j(n,l,t,u,i){var r;n:if("style"==l)if("string"==typeof t)n.style.cssText=t;else{if("string"==typeof u&&(n.style.cssText=u=""),u)for(l in u)t&&l in t||T(n.style,l,"");if(t)for(l in t)u&&t[l]===u[l]||T(n.style,l,t[l])}else if("o"==l[0]&&"n"==l[1])r=l!=(l=l.replace(f,"$1")),l=l.toLowerCase()in n||"onFocusOut"==l||"onFocusIn"==l?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+r]=t,t?u?t.t=u.t:(t.t=c,n.addEventListener(l,r?a:s,r)):n.removeEventListener(l,r?a:s,r);else{if("http://www.w3.org/2000/svg"==i)l=l.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=l&&"height"!=l&&"href"!=l&&"list"!=l&&"form"!=l&&"tabIndex"!=l&&"download"!=l&&"rowSpan"!=l&&"colSpan"!=l&&"role"!=l&&"popover"!=l&&l in n)try{n[l]=null==t?"":t;break n}catch(n){}"function"==typeof t||(null==t||!1===t&&"-"!=l[4]?n.removeAttribute(l):n.setAttribute(l,"popover"==l&&1==t?"":t))}}function F(n){return function(t){if(this.l){var u=this.l[t.type+n];if(null==t.u)t.u=c++;else if(t.u<u.t)return;return u(l.event?l.event(t):t)}}}function O(n,t,u,i,r,o,e,f,c,s){var a,h,p,v,y,_,m,b,S,C,M,$,P,A,H,L,T,j=t.type;if(void 0!==t.constructor)return null;128&u.__u&&(c=!!(32&u.__u),o=[f=t.__e=u.__e]),(a=l.__b)&&a(t);n:if("function"==typeof j)try{if(b=t.props,S="prototype"in j&&j.prototype.render,C=(a=j.contextType)&&i[a.__c],M=a?C?C.props.value:a.__:i,u.__c?m=(h=t.__c=u.__c).__=h.__E:(S?t.__c=h=new j(b,M):(t.__c=h=new x(b,M),h.constructor=j,h.render=D),C&&C.sub(h),h.props=b,h.state||(h.state={}),h.context=M,h.__n=i,p=h.__d=!0,h.__h=[],h._sb=[]),S&&null==h.__s&&(h.__s=h.state),S&&null!=j.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=w({},h.__s)),w(h.__s,j.getDerivedStateFromProps(b,h.__s))),v=h.props,y=h.state,h.__v=t,p)S&&null==j.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),S&&null!=h.componentDidMount&&h.__h.push(h.componentDidMount);else{if(S&&null==j.getDerivedStateFromProps&&b!==v&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(b,M),!h.__e&&(null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(b,h.__s,M)||t.__v==u.__v)){for(t.__v!=u.__v&&(h.props=b,h.state=h.__s,h.__d=!1),t.__e=u.__e,t.__k=u.__k,t.__k.some(function(n){n&&(n.__=t)}),$=0;$<h._sb.length;$++)h.__h.push(h._sb[$]);h._sb=[],h.__h.length&&e.push(h);break n}null!=h.componentWillUpdate&&h.componentWillUpdate(b,h.__s,M),S&&null!=h.componentDidUpdate&&h.__h.push(function(){h.componentDidUpdate(v,y,_)})}if(h.context=M,h.props=b,h.__P=n,h.__e=!1,P=l.__r,A=0,S){for(h.state=h.__s,h.__d=!1,P&&P(t),a=h.render(h.props,h.state,h.context),H=0;H<h._sb.length;H++)h.__h.push(h._sb[H]);h._sb=[]}else do{h.__d=!1,P&&P(t),a=h.render(h.props,h.state,h.context),h.state=h.__s}while(h.__d&&++A<25);h.state=h.__s,null!=h.getChildContext&&(i=w(w({},i),h.getChildContext())),S&&!p&&null!=h.getSnapshotBeforeUpdate&&(_=h.getSnapshotBeforeUpdate(v,y)),L=a,null!=a&&a.type===k&&null==a.key&&(L=N(a.props.children)),f=I(n,d(L)?L:[L],t,u,i,r,o,e,f,c,s),h.base=t.__e,t.__u&=-161,h.__h.length&&e.push(h),m&&(h.__E=h.__=null)}catch(n){if(t.__v=null,c||null!=o)if(n.then){for(t.__u|=c?160:128;f&&8==f.nodeType&&f.nextSibling;)f=f.nextSibling;o[o.indexOf(f)]=null,t.__e=f}else for(T=o.length;T--;)g(o[T]);else t.__e=u.__e,t.__k=u.__k;l.__e(n,t,u)}else null==o&&t.__v==u.__v?(t.__k=u.__k,t.__e=u.__e):f=t.__e=V(u.__e,t,u,i,r,o,e,c,s);return(a=l.diffed)&&a(t),128&t.__u?void 0:f}function z(n,t,u){for(var i=0;i<u.length;i++)q(u[i],u[++i],u[++i]);l.__c&&l.__c(t,n),n.some(function(t){try{n=t.__h,t.__h=[],n.some(function(n){n.call(t)})}catch(n){l.__e(n,t.__v)}})}function N(n){return"object"!=typeof n||null==n?n:d(n)?n.map(N):w({},n)}function V(t,u,i,r,o,e,f,c,s){var a,h,v,y,w,_,m,b=i.props,k=u.props,x=u.type;if("svg"==x?o="http://www.w3.org/2000/svg":"math"==x?o="http://www.w3.org/1998/Math/MathML":o||(o="http://www.w3.org/1999/xhtml"),null!=e)for(a=0;a<e.length;a++)if((w=e[a])&&"setAttribute"in w==!!x&&(x?w.localName==x:3==w.nodeType)){t=w,e[a]=null;break}if(null==t){if(null==x)return document.createTextNode(k);t=document.createElementNS(o,x,k.is&&k),c&&(l.__m&&l.__m(u,e),c=!1),e=null}if(null===x)b===k||c&&t.data===k||(t.data=k);else{if(e=e&&n.call(t.childNodes),b=i.props||p,!c&&null!=e)for(b={},a=0;a<t.attributes.length;a++)b[(w=t.attributes[a]).name]=w.value;for(a in b)if(w=b[a],"children"==a);else if("dangerouslySetInnerHTML"==a)v=w;else if(!(a in k)){if("value"==a&&"defaultValue"in k||"checked"==a&&"defaultChecked"in k)continue;j(t,a,null,w,o)}for(a in k)w=k[a],"children"==a?y=w:"dangerouslySetInnerHTML"==a?h=w:"value"==a?_=w:"checked"==a?m=w:c&&"function"!=typeof w||b[a]===w||j(t,a,w,b[a],o);if(h)c||v&&(h.__html===v.__html||h.__html===t.innerHTML)||(t.innerHTML=h.__html),u.__k=[];else if(v&&(t.innerHTML=""),I("template"===u.type?t.content:t,d(y)?y:[y],u,i,r,"foreignObject"==x?"http://www.w3.org/1999/xhtml":o,e,f,e?e[0]:i.__k&&S(i,0),c,s),null!=e)for(a=e.length;a--;)g(e[a]);c||(a="value","progress"==x&&null==_?t.removeAttribute("value"):void 0!==_&&(_!==t[a]||"progress"==x&&!_||"option"==x&&_!==b[a])&&j(t,a,_,b[a],o),a="checked",void 0!==m&&m!==t[a]&&j(t,a,m,b[a],o))}return t}function q(n,t,u){try{if("function"==typeof n){var i="function"==typeof n.__u;i&&n.__u(),i&&null==t||(n.__u=n(t))}else n.current=t}catch(n){l.__e(n,u)}}function B(n,t,u){var i,r;if(l.unmount&&l.unmount(n),(i=n.ref)&&(i.current&&i.current!==n.__e||q(i,null,t)),null!=(i=n.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(n){l.__e(n,t)}i.base=i.__P=null}if(i=n.__k)for(r=0;r<i.length;r++)i[r]&&B(i[r],t,u||"function"!=typeof n.type);u||g(n.__e),n.__c=n.__=n.__e=void 0}function D(n,l,t){return this.constructor(n,t)}function E(t,u,i){var r,o,e,f;u==document&&(u=document.documentElement),l.__&&l.__(t,u),o=(r="function"==typeof i)?null:i&&i.__k||u.__k,e=[],f=[],O(u,t=(!r&&i||u).__k=_(k,null,[t]),o||p,p,u.namespaceURI,!r&&i?[i]:o?null:u.firstChild?n.call(u.childNodes):null,e,!r&&i?i:o?o.__e:u.firstChild,r,f),z(e,t,f)}function G(n,l){E(n,l,G)}function J(l,t,u){var i,r,o,e,f=w({},l.props);for(o in l.type&&l.type.defaultProps&&(e=l.type.defaultProps),t)"key"==o?i=t[o]:"ref"==o?r=t[o]:f[o]=void 0===t[o]&&void 0!==e?e[o]:t[o];return arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):u),m(l.type,f,i||l.key,r||l.ref,null)}function K(n){function l(n){var t,u;return this.getChildContext||(t=new Set,(u={})[l.__c]=this,this.getChildContext=function(){return u},this.componentWillUnmount=function(){t=null},this.shouldComponentUpdate=function(n){this.props.value!==n.value&&t.forEach(function(n){n.__e=!0,M(n)})},this.sub=function(n){t.add(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){t&&t.delete(n),l&&l.call(n)}}),n.children}return l.__c="__cC"+h++,l.__=n,l.Provider=l.__l=(l.Consumer=function(n,l){return n.children(l)}).contextType=l,l}n=v.slice,l={__e:function(n,l,t,u){for(var i,r,o;l=l.__;)if((i=l.__c)&&!i.__)try{if((r=i.constructor)&&null!=r.getDerivedStateFromError&&(i.setState(r.getDerivedStateFromError(n)),o=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(n,u||{}),o=i.__d),o)return i.__E=i}catch(l){n=l}throw n}},t=0,u=function(n){return null!=n&&null==n.constructor},x.prototype.setState=function(n,l){var t;t=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=w({},this.state),"function"==typeof n&&(n=n(w({},t),this.props)),n&&w(t,n),null!=n&&this.__v&&(l&&this._sb.push(l),M(this))},x.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),M(this))},x.prototype.render=k,i=[],o="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,e=function(n,l){return n.__v.__b-l.__v.__b},$.__r=0,f=/(PointerCapture)$|Capture$/i,c=0,s=F(!1),a=F(!0),h=0; |
|
2575 |
|
2576 |
|
2577 /***/ }) |
|
2578 |
|
2579 /******/ }); |
|
2580 /************************************************************************/ |
|
2581 /******/ // The module cache |
|
2582 /******/ var __webpack_module_cache__ = {}; |
|
2583 /******/ |
|
2584 /******/ // The require function |
|
2585 /******/ function __webpack_require__(moduleId) { |
|
2586 /******/ // Check if module is in cache |
|
2587 /******/ var cachedModule = __webpack_module_cache__[moduleId]; |
|
2588 /******/ if (cachedModule !== undefined) { |
|
2589 /******/ return cachedModule.exports; |
|
2590 /******/ } |
|
2591 /******/ // Create a new module (and put it into the cache) |
|
2592 /******/ var module = __webpack_module_cache__[moduleId] = { |
|
2593 /******/ // no module.id needed |
|
2594 /******/ // no module.loaded needed |
|
2595 /******/ exports: {} |
|
2596 /******/ }; |
|
2597 /******/ |
|
2598 /******/ // Execute the module function |
|
2599 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); |
|
2600 /******/ |
|
2601 /******/ // Return the exports of the module |
|
2602 /******/ return module.exports; |
|
2603 /******/ } |
|
2604 /******/ |
|
2605 /************************************************************************/ |
|
2606 /******/ /* webpack/runtime/define property getters */ |
|
2607 /******/ (() => { |
|
2608 /******/ // define getter functions for harmony exports |
|
2609 /******/ __webpack_require__.d = (exports, definition) => { |
|
2610 /******/ for(var key in definition) { |
|
2611 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
|
2612 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
|
2613 /******/ } |
|
2614 /******/ } |
|
2615 /******/ }; |
|
2616 /******/ })(); |
|
2617 /******/ |
|
2618 /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
|
2619 /******/ (() => { |
|
2620 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) |
|
2621 /******/ })(); |
|
2622 /******/ |
|
2623 /************************************************************************/ |
|
2624 var __webpack_exports__ = {}; |
|
2625 |
|
2626 // EXPORTS |
|
2627 __webpack_require__.d(__webpack_exports__, { |
|
2628 zj: () => (/* reexport */ debug_build_module/* getConfig */.zj), |
|
2629 SD: () => (/* reexport */ debug_build_module/* getContext */.SD), |
|
2630 V6: () => (/* reexport */ debug_build_module/* getElement */.V6), |
|
2631 $K: () => (/* reexport */ debug_build_module/* getServerContext */.$K), |
|
2632 vT: () => (/* reexport */ debug_build_module/* getServerState */.vT), |
|
2633 jb: () => (/* reexport */ debug_build_module/* privateApis */.jb), |
|
2634 yT: () => (/* reexport */ debug_build_module/* splitTask */.yT), |
|
2635 M_: () => (/* reexport */ debug_build_module/* store */.M_), |
|
2636 hb: () => (/* reexport */ debug_build_module/* useCallback */.hb), |
|
2637 vJ: () => (/* reexport */ debug_build_module/* useEffect */.vJ), |
|
2638 ip: () => (/* reexport */ debug_build_module/* useInit */.ip), |
|
2639 Nf: () => (/* reexport */ debug_build_module/* useLayoutEffect */.Nf), |
|
2640 Kr: () => (/* reexport */ debug_build_module/* useMemo */.Kr), |
|
2641 li: () => (/* reexport */ debug_build_module/* useRef */.li), |
|
2642 J0: () => (/* reexport */ debug_build_module/* useState */.J0), |
|
2643 FH: () => (/* reexport */ debug_build_module/* useWatch */.FH), |
|
2644 v4: () => (/* reexport */ debug_build_module/* withScope */.v4), |
|
2645 mh: () => (/* reexport */ debug_build_module/* withSyncEvent */.mh) |
|
2646 }); |
|
2647 |
|
2648 // EXTERNAL MODULE: ./node_modules/preact/dist/preact.module.js |
|
2649 var debug_preact_module = __webpack_require__(622); |
|
2650 ;// ./node_modules/preact/devtools/dist/devtools.module.js |
|
2651 var debug_i;function debug_t(o,e){return n.__a&&n.__a(e),o}null!=(debug_i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0)&&debug_i.__PREACT_DEVTOOLS__&&debug_i.__PREACT_DEVTOOLS__.attachPreact("10.26.4",debug_preact_module/* options */.fF,{Fragment:debug_preact_module/* Fragment */.FK,Component:debug_preact_module/* Component */.uA}); |
|
2652 |
|
2653 ;// ./node_modules/preact/debug/dist/debug.module.js |
|
2654 var debug_debug_module_t={};function debug_r(){debug_debug_module_t={}}function debug_a(e){return e.type===debug_preact_module/* Fragment */.FK?"Fragment":"function"==typeof e.type?e.type.displayName||e.type.name:"string"==typeof e.type?e.type:"#text"}var debug_debug_module_i=[],debug_s=[];function debug_c(){return debug_debug_module_i.length>0?debug_debug_module_i[debug_debug_module_i.length-1]:null}var debug_l=!0;function debug_u(e){return"function"==typeof e.type&&e.type!=debug_preact_module/* Fragment */.FK}function debug_f(n){for(var e=[n],o=n;null!=o.__o;)e.push(o.__o),o=o.__o;return e.reduce(function(n,e){n+=" in "+debug_a(e);var o=e.__source;return o?n+=" (at "+o.fileName+":"+o.lineNumber+")":debug_l&&console.warn("Add @babel/plugin-transform-react-jsx-source to get a more detailed component stack. Note that you should not add it to production builds of your App for bundle size reasons."),debug_l=!1,n+"\n"},"")}var debug_d="function"==typeof WeakMap;function debug_p(n){var e=[];return n.__k?(n.__k.forEach(function(n){n&&"function"==typeof n.type?e.push.apply(e,debug_p(n)):n&&"string"==typeof n.type&&e.push(n.type)}),e):e}function debug_h(n){return n?"function"==typeof n.type?null==n.__?null!=n.__e&&null!=n.__e.parentNode?n.__e.parentNode.localName:"":debug_h(n.__):n.type:""}var debug_v=debug_preact_module/* Component */.uA.prototype.setState;function debug_y(n){return"table"===n||"tfoot"===n||"tbody"===n||"thead"===n||"td"===n||"tr"===n||"th"===n}debug_preact_module/* Component */.uA.prototype.setState=function(n,e){return null==this.__v&&null==this.state&&console.warn('Calling "this.setState" inside the constructor of a component is a no-op and might be a bug in your application. Instead, set "this.state = {}" directly.\n\n'+debug_f(debug_c())),debug_v.call(this,n,e)};var debug_m=/^(address|article|aside|blockquote|details|div|dl|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hgroup|hr|main|menu|nav|ol|p|pre|search|section|table|ul)$/,debug_b=debug_preact_module/* Component */.uA.prototype.forceUpdate;function debug_w(n){var e=n.props,o=debug_a(n),t="";for(var r in e)if(e.hasOwnProperty(r)&&"children"!==r){var i=e[r];"function"==typeof i&&(i="function "+(i.displayName||i.name)+"() {}"),i=Object(i)!==i||i.toString?i+"":Object.prototype.toString.call(i),t+=" "+r+"="+JSON.stringify(i)}var s=e.children;return"<"+o+t+(s&&s.length?">..</"+o+">":" />")}debug_preact_module/* Component */.uA.prototype.forceUpdate=function(n){return null==this.__v?console.warn('Calling "this.forceUpdate" inside the constructor of a component is a no-op and might be a bug in your application.\n\n'+debug_f(debug_c())):null==this.__P&&console.warn('Can\'t call "this.forceUpdate" on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.\n\n'+debug_f(this.__v)),debug_b.call(this,n)},debug_preact_module/* options */.fF.__m=function(n,e){var o=n.type,t=e.map(function(n){return n&&n.localName}).filter(Boolean);console.error('Expected a DOM node of type "'+o+'" but found "'+t.join(", ")+"\" as available DOM-node(s), this is caused by the SSR'd HTML containing different DOM-nodes compared to the hydrated one.\n\n"+debug_f(n))},function(){!function(){var n=debug_preact_module/* options */.fF.__b,o=debug_preact_module/* options */.fF.diffed,t=debug_preact_module/* options */.fF.__,r=debug_preact_module/* options */.fF.vnode,a=debug_preact_module/* options */.fF.__r;debug_preact_module/* options */.fF.diffed=function(n){debug_u(n)&&debug_s.pop(),debug_debug_module_i.pop(),o&&o(n)},debug_preact_module/* options */.fF.__b=function(e){debug_u(e)&&debug_debug_module_i.push(e),n&&n(e)},debug_preact_module/* options */.fF.__=function(n,e){debug_s=[],t&&t(n,e)},debug_preact_module/* options */.fF.vnode=function(n){n.__o=debug_s.length>0?debug_s[debug_s.length-1]:null,r&&r(n)},debug_preact_module/* options */.fF.__r=function(n){debug_u(n)&&debug_s.push(n),a&&a(n)}}();var n=!1,o=debug_preact_module/* options */.fF.__b,r=debug_preact_module/* options */.fF.diffed,c=debug_preact_module/* options */.fF.vnode,l=debug_preact_module/* options */.fF.__r,v=debug_preact_module/* options */.fF.__e,b=debug_preact_module/* options */.fF.__,g=debug_preact_module/* options */.fF.__h,E=debug_d?{useEffect:new WeakMap,useLayoutEffect:new WeakMap,lazyPropTypes:new WeakMap}:null,k=[];debug_preact_module/* options */.fF.__e=function(n,e,o,t){if(e&&e.__c&&"function"==typeof n.then){var r=n;n=new Error("Missing Suspense. The throwing component was: "+debug_a(e));for(var i=e;i;i=i.__)if(i.__c&&i.__c.__c){n=r;break}if(n instanceof Error)throw n}try{(t=t||{}).componentStack=debug_f(e),v(n,e,o,t),"function"!=typeof n.then&&setTimeout(function(){throw n})}catch(n){throw n}},debug_preact_module/* options */.fF.__=function(n,e){if(!e)throw new Error("Undefined parent passed to render(), this is the second argument.\nCheck if the element is available in the DOM/has the correct id.");var o;switch(e.nodeType){case 1:case 11:case 9:o=!0;break;default:o=!1}if(!o){var t=debug_a(n);throw new Error("Expected a valid HTML node as a second argument to render.\tReceived "+e+" instead: render(<"+t+" />, "+e+");")}b&&b(n,e)},debug_preact_module/* options */.fF.__b=function(e){var r=e.type;if(n=!0,void 0===r)throw new Error("Undefined component passed to createElement()\n\nYou likely forgot to export your component or might have mixed up default and named imports"+debug_w(e)+"\n\n"+debug_f(e));if(null!=r&&"object"==typeof r){if(void 0!==r.__k&&void 0!==r.__e)throw new Error("Invalid type passed to createElement(): "+r+"\n\nDid you accidentally pass a JSX literal as JSX twice?\n\n let My"+debug_a(e)+" = "+debug_w(r)+";\n let vnode = <My"+debug_a(e)+" />;\n\nThis usually happens when you export a JSX literal and not the component.\n\n"+debug_f(e));throw new Error("Invalid type passed to createElement(): "+(Array.isArray(r)?"array":r))}if(void 0!==e.ref&&"function"!=typeof e.ref&&"object"!=typeof e.ref&&!("$$typeof"in e))throw new Error('Component\'s "ref" property should be a function, or an object created by createRef(), but got ['+typeof e.ref+"] instead\n"+debug_w(e)+"\n\n"+debug_f(e));if("string"==typeof e.type)for(var i in e.props)if("o"===i[0]&&"n"===i[1]&&"function"!=typeof e.props[i]&&null!=e.props[i])throw new Error("Component's \""+i+'" property should be a function, but got ['+typeof e.props[i]+"] instead\n"+debug_w(e)+"\n\n"+debug_f(e));if("function"==typeof e.type&&e.type.propTypes){if("Lazy"===e.type.displayName&&E&&!E.lazyPropTypes.has(e.type)){var s="PropTypes are not supported on lazy(). Use propTypes on the wrapped component itself. ";try{var c=e.type();E.lazyPropTypes.set(e.type,!0),console.warn(s+"Component wrapped in lazy() is "+debug_a(c))}catch(n){console.warn(s+"We will log the wrapped component's name once it is loaded.")}}var l=e.props;e.type.__f&&delete(l=function(n,e){for(var o in e)n[o]=e[o];return n}({},l)).ref,function(n,e,o,r,a){Object.keys(n).forEach(function(o){var i;try{i=n[o](e,o,r,"prop",null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(n){i=n}i&&!(i.message in debug_debug_module_t)&&(debug_debug_module_t[i.message]=!0,console.error("Failed prop type: "+i.message+(a&&"\n"+a()||"")))})}(e.type.propTypes,l,0,debug_a(e),function(){return debug_f(e)})}o&&o(e)};var T,_=0;debug_preact_module/* options */.fF.__r=function(e){l&&l(e),n=!0;var o=e.__c;if(o===T?_++:_=1,_>=25)throw new Error("Too many re-renders. This is limited to prevent an infinite loop which may lock up your browser. The component causing this is: "+debug_a(e));T=o},debug_preact_module/* options */.fF.__h=function(e,o,t){if(!e||!n)throw new Error("Hook can only be invoked from render methods.");g&&g(e,o,t)};var O=function(n,e){return{get:function(){var o="get"+n+e;k&&k.indexOf(o)<0&&(k.push(o),console.warn("getting vnode."+n+" is deprecated, "+e))},set:function(){var o="set"+n+e;k&&k.indexOf(o)<0&&(k.push(o),console.warn("setting vnode."+n+" is not allowed, "+e))}}},I={nodeName:O("nodeName","use vnode.type"),attributes:O("attributes","use vnode.props"),children:O("children","use vnode.props.children")},M=Object.create({},I);debug_preact_module/* options */.fF.vnode=function(n){var e=n.props;if(null!==n.type&&null!=e&&("__source"in e||"__self"in e)){var o=n.props={};for(var t in e){var r=e[t];"__source"===t?n.__source=r:"__self"===t?n.__self=r:o[t]=r}}n.__proto__=M,c&&c(n)},debug_preact_module/* options */.fF.diffed=function(e){var o,t=e.type,i=e.__;if(e.__k&&e.__k.forEach(function(n){if("object"==typeof n&&n&&void 0===n.type){var o=Object.keys(n).join(",");throw new Error("Objects are not valid as a child. Encountered an object with the keys {"+o+"}.\n\n"+debug_f(e))}}),e.__c===T&&(_=0),"string"==typeof t&&(debug_y(t)||"p"===t||"a"===t||"button"===t)){var s=debug_h(i);if(""!==s&&debug_y(t))"table"===t&&"td"!==s&&debug_y(s)?console.error("Improper nesting of table. Your <table> should not have a table-node parent."+debug_w(e)+"\n\n"+debug_f(e)):"thead"!==t&&"tfoot"!==t&&"tbody"!==t||"table"===s?"tr"===t&&"thead"!==s&&"tfoot"!==s&&"tbody"!==s?console.error("Improper nesting of table. Your <tr> should have a <thead/tbody/tfoot> parent."+debug_w(e)+"\n\n"+debug_f(e)):"td"===t&&"tr"!==s?console.error("Improper nesting of table. Your <td> should have a <tr> parent."+debug_w(e)+"\n\n"+debug_f(e)):"th"===t&&"tr"!==s&&console.error("Improper nesting of table. Your <th> should have a <tr>."+debug_w(e)+"\n\n"+debug_f(e)):console.error("Improper nesting of table. Your <thead/tbody/tfoot> should have a <table> parent."+debug_w(e)+"\n\n"+debug_f(e));else if("p"===t){var c=debug_p(e).filter(function(n){return debug_m.test(n)});c.length&&console.error("Improper nesting of paragraph. Your <p> should not have "+c.join(", ")+" as child-elements."+debug_w(e)+"\n\n"+debug_f(e))}else"a"!==t&&"button"!==t||-1!==debug_p(e).indexOf(t)&&console.error("Improper nesting of interactive content. Your <"+t+"> should not have other "+("a"===t?"anchor":"button")+" tags as child-elements."+debug_w(e)+"\n\n"+debug_f(e))}if(n=!1,r&&r(e),null!=e.__k)for(var l=[],u=0;u<e.__k.length;u++){var d=e.__k[u];if(d&&null!=d.key){var v=d.key;if(-1!==l.indexOf(v)){console.error('Following component has two or more children with the same key attribute: "'+v+'". This may cause glitches and misbehavior in rendering process. Component: \n\n'+debug_w(e)+"\n\n"+debug_f(e));break}l.push(v)}}if(null!=e.__c&&null!=e.__c.__H){var b=e.__c.__H.__;if(b)for(var g=0;g<b.length;g+=1){var E=b[g];if(E.__H)for(var k=0;k<E.__H.length;k++)if((o=E.__H[k])!=o){var O=debug_a(e);console.warn("Invalid argument passed to hook. Hooks should not be called with NaN in the dependency array. Hook index "+g+" in component "+O+" was called with NaN.")}}}}}(); |
|
2655 |
|
2656 // EXTERNAL MODULE: ./node_modules/@wordpress/interactivity/build-module/index.js + 18 modules |
|
2657 var debug_build_module = __webpack_require__(380); |
|
2658 ;// ./node_modules/@wordpress/interactivity/build-module/debug.js |
|
2659 /** |
|
2660 * External dependencies |
|
2661 */ |
|
2662 |
|
2663 |
|
2664 |
|
2665 var __webpack_exports__getConfig = __webpack_exports__.zj; |
|
2666 var __webpack_exports__getContext = __webpack_exports__.SD; |
|
2667 var __webpack_exports__getElement = __webpack_exports__.V6; |
|
2668 var __webpack_exports__getServerContext = __webpack_exports__.$K; |
|
2669 var __webpack_exports__getServerState = __webpack_exports__.vT; |
|
2670 var __webpack_exports__privateApis = __webpack_exports__.jb; |
|
2671 var __webpack_exports__splitTask = __webpack_exports__.yT; |
|
2672 var __webpack_exports__store = __webpack_exports__.M_; |
|
2673 var __webpack_exports__useCallback = __webpack_exports__.hb; |
|
2674 var __webpack_exports__useEffect = __webpack_exports__.vJ; |
|
2675 var __webpack_exports__useInit = __webpack_exports__.ip; |
|
2676 var __webpack_exports__useLayoutEffect = __webpack_exports__.Nf; |
|
2677 var __webpack_exports__useMemo = __webpack_exports__.Kr; |
|
2678 var __webpack_exports__useRef = __webpack_exports__.li; |
|
2679 var __webpack_exports__useState = __webpack_exports__.J0; |
|
2680 var __webpack_exports__useWatch = __webpack_exports__.FH; |
|
2681 var __webpack_exports__withScope = __webpack_exports__.v4; |
|
2682 var __webpack_exports__withSyncEvent = __webpack_exports__.mh; |
|
2683 export { __webpack_exports__getConfig as getConfig, __webpack_exports__getContext as getContext, __webpack_exports__getElement as getElement, __webpack_exports__getServerContext as getServerContext, __webpack_exports__getServerState as getServerState, __webpack_exports__privateApis as privateApis, __webpack_exports__splitTask as splitTask, __webpack_exports__store as store, __webpack_exports__useCallback as useCallback, __webpack_exports__useEffect as useEffect, __webpack_exports__useInit as useInit, __webpack_exports__useLayoutEffect as useLayoutEffect, __webpack_exports__useMemo as useMemo, __webpack_exports__useRef as useRef, __webpack_exports__useState as useState, __webpack_exports__useWatch as useWatch, __webpack_exports__withScope as withScope, __webpack_exports__withSyncEvent as withSyncEvent }; |