1import { A as effect, z as untrack, G as render_effect, I as deep_read_state, J as safe_not_equal } from './index-CDZuCcOm.js'; 2 3/** @import { ActionPayload } from '#client' */ 4 5/** 6 * @template P 7 * @param {Element} dom 8 * @param {(dom: Element, value?: P) => ActionPayload<P>} action 9 * @param {() => P} [get_value] 10 * @returns {void} 11 */ 12function action(dom, action, get_value) { 13 effect(() => { 14 var payload = untrack(() => action(dom, get_value?.()) || {}); 15 16 if (get_value && payload?.update) { 17 var inited = false; 18 /** @type {P} */ 19 var prev = /** @type {any} */ ({}); // initialize with something so it's never equal on first run 20 21 render_effect(() => { 22 var value = get_value(); 23 24 // Action's update method is coarse-grained, i.e. when anything in the passed value changes, update. 25 // This works in legacy mode because of mutable_source being updated as a whole, but when using $state 26 // together with actions and mutation, it wouldn't notice the change without a deep read. 27 deep_read_state(value); 28 29 if (inited && safe_not_equal(prev, value)) { 30 prev = value; 31 /** @type {Function} */ (payload.update)(value); 32 } 33 }); 34 35 inited = true; 36 } 37 38 if (payload?.destroy) { 39 return () => /** @type {Function} */ (payload.destroy)(); 40 } 41 }); 42} 43 44export { action as a }; 45//# sourceMappingURL=actions-BTh6ZJJ8.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.