@preact/signals 2.5.1 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @preact/signals
2
2
 
3
+ ## 2.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#836](https://github.com/preactjs/signals/pull/836) [`ac5032e`](https://github.com/preactjs/signals/commit/ac5032e63000cdb0bf84e20a1b44c161788a1607) Thanks [@JoviDeCroock](https://github.com/JoviDeCroock)! - Ensure that the `For` and `Show` component have display-names
8
+
9
+ ## 2.6.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#819](https://github.com/preactjs/signals/pull/819) [`8a8b0d1`](https://github.com/preactjs/signals/commit/8a8b0d109d324a5764289674e580e693683de04d) Thanks [@JoviDeCroock](https://github.com/JoviDeCroock)! - Remove the need for enter/exit component and track the effects normally
14
+
15
+ ### Patch Changes
16
+
17
+ - [#827](https://github.com/preactjs/signals/pull/827) [`f17889b`](https://github.com/preactjs/signals/commit/f17889b6d46448205d9485b8d5e691fbe05cd404) Thanks [@JoviDeCroock](https://github.com/JoviDeCroock)! - Add mangle entry for \_debugCallback
18
+
19
+ - Updated dependencies [[`f17889b`](https://github.com/preactjs/signals/commit/f17889b6d46448205d9485b8d5e691fbe05cd404)]:
20
+ - @preact/signals-core@1.12.2
21
+
3
22
  ## 2.5.1
4
23
 
5
24
  ### Patch Changes
package/dist/signals.js CHANGED
@@ -1 +1 @@
1
- var i,n,t,r=require("preact"),o=require("preact/hooks"),e=require("@preact/signals-core"),f="undefined"!=typeof window&&!!window.__PREACT_SIGNALS_DEVTOOLS__,u=[],a=[];e.effect(function(){i=this.N})();function c(i,n){r.options[i]=n.bind(null,r.options[i]||function(){})}function s(i){if(t)t();t=i&&i.S()}function v(i){var n=this,t=i.data,f=useSignal(t);f.value=t;var u=o.useMemo(function(){var i=n,t=n.__v;while(t=t.__)if(t.__c){t.__c.__$f|=4;break}var o=e.computed(function(){var i=f.value.value;return 0===i?0:!0===i?"":i||""}),u=e.computed(function(){return!Array.isArray(o.value)&&!r.isValidElement(o.value)}),a=e.effect(function(){this.N=y;if(u.value){var n=o.value;if(i.__v&&i.__v.__e&&3===i.__v.__e.nodeType)i.__v.__e.data=n}}),c=n.__$u.d;n.__$u.d=function(){a();c.call(this)};return[u,o]},[]),a=u[0],c=u[1];return a.value?c.peek():c.value}v.displayName="ReactiveTextNode";Object.defineProperties(e.Signal.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:v},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});c("__b",function(i,n){if(f&&"function"==typeof n.type)window.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();if("string"==typeof n.type){var t,r=n.props;for(var o in r)if("children"!==o){var u=r[o];if(u instanceof e.Signal){if(!t)n.__np=t={};t[o]=u;r[o]=u.peek()}}}i(n)});c("__r",function(i,t){if(f&&"function"==typeof t.type)window.__PREACT_SIGNALS_DEVTOOLS__.enterComponent(t);if(t.type!==r.Fragment){s();var o,u=t.__c;if(u){u.__$f&=-2;if(void 0===(o=u.__$u))u.__$u=o=function(i){var n;e.effect(function(){n=this});n.c=function(){u.__$f|=1;u.setState({})};return n}()}n=u;s(o)}i(t)});c("__e",function(i,t,r,o){if(f)window.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();s();n=void 0;i(t,r,o)});c("diffed",function(i,t){if(f&&"function"==typeof t.type)window.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();s();n=void 0;var r;if("string"==typeof t.type&&(r=t.__e)){var o=t.__np,e=t.props;if(o){var u=r.U;if(u)for(var a in u){var c=u[a];if(void 0!==c&&!(a in o)){c.d();u[a]=void 0}}else{u={};r.U=u}for(var v in o){var h=u[v],p=o[v];if(void 0===h){h=d(r,v,p,e);u[v]=h}else h.o(p,e)}}}i(t)});function d(i,n,t,r){var o=n in i&&void 0===i.ownerSVGElement,f=e.signal(t);return{o:function(i,n){f.value=i;r=n},d:e.effect(function(){this.N=y;var t=f.value.value;if(r[n]!==t){r[n]=t;if(o)i[n]=t;else if(null!=t&&(!1!==t||"-"===n[4]))i.setAttribute(n,t);else i.removeAttribute(n)}})}}c("unmount",function(i,n){if("string"==typeof n.type){var t=n.__e;if(t){var r=t.U;if(r){t.U=void 0;for(var o in r){var e=r[o];if(e)e.d()}}}}else{var f=n.__c;if(f){var u=f.__$u;if(u){f.__$u=void 0;u.d()}}}i(n)});c("__h",function(i,n,t,r){if(r<3||9===r)n.__$f|=2;i(n,t,r)});r.Component.prototype.shouldComponentUpdate=function(i,n){var t=this.__$u,r=t&&void 0!==t.s;for(var o in n)return!0;if(this.__f||"boolean"==typeof this.u&&!0===this.u){var e=2&this.__$f;if(!(r||e||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(r||4&this.__$f))return!0;if(3&this.__$f)return!0}for(var f in i)if("__source"!==f&&i[f]!==this.props[f])return!0;for(var u in this.props)if(!(u in i))return!0;return!1};function useSignal(i,n){return o.useState(function(){return e.signal(i,n)})[0]}var h="undefined"==typeof requestAnimationFrame?setTimeout:function(i){var n=function(){clearTimeout(t);cancelAnimationFrame(r);i()},t=setTimeout(n,35),r=requestAnimationFrame(n)},p=function(i){queueMicrotask(function(){queueMicrotask(i)})};function l(){e.batch(function(){var n;while(n=u.shift())i.call(n)})}function w(){if(1===u.push(this))(r.options.requestAnimationFrame||h)(l)}function _(){e.batch(function(){var n;while(n=a.shift())i.call(n)})}function y(){if(1===a.push(this))(r.options.requestAnimationFrame||p)(_)}exports.Signal=e.Signal;exports.batch=e.batch;exports.computed=e.computed;exports.effect=e.effect;exports.signal=e.signal;exports.untracked=e.untracked;exports.useComputed=function(i,t){var r=o.useRef(i);r.current=i;n.__$f|=4;return o.useMemo(function(){return e.computed(function(){return r.current()},t)},[])};exports.useSignal=useSignal;exports.useSignalEffect=function(i,n){var t=o.useRef(i);t.current=i;o.useEffect(function(){return e.effect(function(){this.N=w;return t.current()},n)},[])};//# sourceMappingURL=signals.js.map
1
+ var i,n,r,t=require("preact"),e=require("preact/hooks"),o=require("@preact/signals-core"),f="undefined"!=typeof window&&!!window.__PREACT_SIGNALS_DEVTOOLS__,u=[],a=[];o.effect(function(){i=this.N})();function c(i,n){t.options[i]=n.bind(null,t.options[i]||function(){})}function s(i){if(r)r();r=i&&i.S()}function v(i){var n=this,r=i.data,f=useSignal(r);f.value=r;var u=e.useMemo(function(){var i=n,r=n.__v;while(r=r.__)if(r.__c){r.__c.__$f|=4;break}var e=o.computed(function(){var i=f.value.value;return 0===i?0:!0===i?"":i||""}),u=o.computed(function(){return!Array.isArray(e.value)&&!t.isValidElement(e.value)}),a=o.effect(function(){this.N=x;if(u.value){var n=e.value;if(i.__v&&i.__v.__e&&3===i.__v.__e.nodeType)i.__v.__e.data=n}}),c=n.__$u.d;n.__$u.d=function(){a();c.call(this)};return[u,e]},[]),a=u[0],c=u[1];return a.value?c.peek():c.value}v.displayName="ReactiveTextNode";Object.defineProperties(o.Signal.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:v},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});c("__b",function(i,n){if("string"==typeof n.type){var r,t=n.props;for(var e in t)if("children"!==e){var f=t[e];if(f instanceof o.Signal){if(!r)n.__np=r={};r[e]=f;t[e]=f.peek()}}}i(n)});c("__r",function(i,r){if(r.type!==t.Fragment){s();var e,u=r.__c;if(u){u.__$f&=-2;if(void 0===(e=u.__$u))u.__$u=e=function(i,n){var r;o.effect(function(){r=this},{name:n});r.c=i;return r}(function(){var i;if(f)null==(i=e.y)||i.call(e);u.__$f|=1;u.setState({})},"function"==typeof r.type?r.type.displayName||r.type.name:"")}n=u;s(e)}i(r)});c("__e",function(i,r,t,e){s();n=void 0;i(r,t,e)});c("diffed",function(i,r){s();n=void 0;var t;if("string"==typeof r.type&&(t=r.__e)){var e=r.__np,o=r.props;if(e){var f=t.U;if(f)for(var u in f){var a=f[u];if(void 0!==a&&!(u in e)){a.d();f[u]=void 0}}else{f={};t.U=f}for(var c in e){var v=f[c],l=e[c];if(void 0===v){v=h(t,c,l,o);f[c]=v}else v.o(l,o)}}}i(r)});function h(i,n,r,t){var e=n in i&&void 0===i.ownerSVGElement,f=o.signal(r);return{o:function(i,n){f.value=i;t=n},d:o.effect(function(){this.N=x;var r=f.value.value;if(t[n]!==r){t[n]=r;if(e)i[n]=r;else if(null!=r&&(!1!==r||"-"===n[4]))i.setAttribute(n,r);else i.removeAttribute(n)}})}}c("unmount",function(i,n){if("string"==typeof n.type){var r=n.__e;if(r){var t=r.U;if(t){r.U=void 0;for(var e in t){var o=t[e];if(o)o.d()}}}}else{var f=n.__c;if(f){var u=f.__$u;if(u){f.__$u=void 0;u.d()}}}i(n)});c("__h",function(i,n,r,t){if(t<3||9===t)n.__$f|=2;i(n,r,t)});t.Component.prototype.shouldComponentUpdate=function(i,n){var r=this.__$u,t=r&&void 0!==r.s;for(var e in n)return!0;if(this.__f||"boolean"==typeof this.u&&!0===this.u){var o=2&this.__$f;if(!(t||o||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 f in i)if("__source"!==f&&i[f]!==this.props[f])return!0;for(var u in this.props)if(!(u in i))return!0;return!1};function useSignal(i,n){return e.useState(function(){return o.signal(i,n)})[0]}var l="undefined"==typeof requestAnimationFrame?setTimeout:function(i){var n=function(){clearTimeout(r);cancelAnimationFrame(t);i()},r=setTimeout(n,35),t=requestAnimationFrame(n)},d=function(i){queueMicrotask(function(){queueMicrotask(i)})};function p(){o.batch(function(){var n;while(n=u.shift())i.call(n)})}function _(){if(1===u.push(this))(t.options.requestAnimationFrame||l)(p)}function m(){o.batch(function(){var n;while(n=a.shift())i.call(n)})}function x(){if(1===a.push(this))(t.options.requestAnimationFrame||d)(m)}exports.Signal=o.Signal;exports.batch=o.batch;exports.computed=o.computed;exports.effect=o.effect;exports.signal=o.signal;exports.untracked=o.untracked;exports.useComputed=function(i,r){var t=e.useRef(i);t.current=i;n.__$f|=4;return e.useMemo(function(){return o.computed(function(){return t.current()},r)},[])};exports.useSignal=useSignal;exports.useSignalEffect=function(i,n){var r=e.useRef(i);r.current=i;e.useEffect(function(){return o.effect(function(){this.N=_;return r.current()},n)},[])};//# sourceMappingURL=signals.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"signals.js","sources":["../src/index.ts"],"sourcesContent":["import { options, Component, isValidElement, Fragment } from \"preact\";\nimport { useRef, useMemo, useEffect, useState } from \"preact/hooks\";\nimport {\n\tsignal,\n\tcomputed,\n\tbatch,\n\teffect,\n\tSignal,\n\ttype ReadonlySignal,\n\tuntracked,\n\tSignalOptions,\n\tEffectOptions,\n} from \"@preact/signals-core\";\nimport {\n\tVNode,\n\tOptionsTypes,\n\tHookFn,\n\tEffect,\n\tPropertyUpdater,\n\tAugmentedComponent,\n\tAugmentedElement as Element,\n} from \"./internal\";\n\nexport {\n\tsignal,\n\tcomputed,\n\tbatch,\n\teffect,\n\tSignal,\n\ttype ReadonlySignal,\n\tuntracked,\n};\n\nconst DEVTOOLS_ENABLED =\n\ttypeof window !== \"undefined\" && !!window.__PREACT_SIGNALS_DEVTOOLS__;\n\nconst HAS_PENDING_UPDATE = 1 << 0;\nconst HAS_HOOK_STATE = 1 << 1;\nconst HAS_COMPUTEDS = 1 << 2;\n\nlet oldNotify: (this: Effect) => void,\n\teffectsQueue: Array<Effect> = [],\n\tdomQueue: Array<Effect> = [];\n\n// Capture the original `Effect.prototype._notify` method so that we can install\n// custom `._notify`s for each different use-case but still call the original\n// implementation in the end. Dispose the temporary effect immediately afterwards.\neffect(function (this: Effect) {\n\toldNotify = this._notify;\n})();\n\n// Install a Preact options hook\nfunction hook<T extends OptionsTypes>(hookName: T, hookFn: HookFn<T>) {\n\t// @ts-ignore-next-line private options hooks usage\n\toptions[hookName] = hookFn.bind(null, options[hookName] || (() => {}));\n}\n\nlet currentComponent: AugmentedComponent | undefined;\nlet finishUpdate: (() => void) | undefined;\n\nfunction setCurrentUpdater(updater?: Effect) {\n\t// end tracking for the current update:\n\tif (finishUpdate) finishUpdate();\n\t// start tracking the new update:\n\tfinishUpdate = updater && updater._start();\n}\n\nfunction createUpdater(update: () => void) {\n\tlet updater!: Effect;\n\teffect(function (this: Effect) {\n\t\tupdater = this;\n\t});\n\tupdater._callback = update;\n\treturn updater;\n}\n\n/** @todo This may be needed for complex prop value detection. */\n// function isSignalValue(value: any): value is Signal {\n// \tif (typeof value !== \"object\" || value == null) return false;\n// \tif (value instanceof Signal) return true;\n// \t// @TODO: uncomment this when we land Reactive (ideally behind a brand check)\n// \t// for (let i in value) if (value[i] instanceof Signal) return true;\n// \treturn false;\n// }\n\n/**\n * A wrapper component that renders a Signal directly as a Text node.\n * @todo: in Preact 11, just decorate Signal with `type:null`\n */\nfunction SignalValue(this: AugmentedComponent, { data }: { data: Signal }) {\n\t// hasComputeds.add(this);\n\n\t// Store the props.data signal in another signal so that\n\t// passing a new signal reference re-runs the text computed:\n\tconst currentSignal = useSignal(data);\n\tcurrentSignal.value = data;\n\n\tconst [isText, s] = useMemo(() => {\n\t\tlet self = this;\n\t\t// mark the parent component as having computeds so it gets optimized\n\t\tlet v = this.__v;\n\t\twhile ((v = v.__!)) {\n\t\t\tif (v.__c) {\n\t\t\t\tv.__c._updateFlags |= HAS_COMPUTEDS;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tconst wrappedSignal = computed(() => {\n\t\t\tlet s = currentSignal.value.value;\n\t\t\treturn s === 0 ? 0 : s === true ? \"\" : s || \"\";\n\t\t});\n\n\t\tconst isText = computed(\n\t\t\t() =>\n\t\t\t\t!Array.isArray(wrappedSignal.value) &&\n\t\t\t\t!isValidElement(wrappedSignal.value)\n\t\t);\n\t\t// Update text nodes directly without rerendering when the new value\n\t\t// is also text.\n\t\tconst dispose = effect(function (this: Effect) {\n\t\t\tthis._notify = notifyDomUpdates;\n\n\t\t\t// Subscribe to wrappedSignal updates only when its values are text...\n\t\t\tif (isText.value) {\n\t\t\t\t// ...but regardless of `self.base`'s current value, as it can be\n\t\t\t\t// undefined before mounting or a non-text node. In both of those cases\n\t\t\t\t// the update gets handled by a full rerender.\n\t\t\t\tconst value = wrappedSignal.value;\n\t\t\t\tif (self.__v && self.__v.__e && self.__v.__e.nodeType === 3) {\n\t\t\t\t\t(self.__v.__e as Text).data = value;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// Piggyback this._updater's disposal to ensure that the text updater effect\n\t\t// above also gets disposed on unmount.\n\t\tconst oldDispose = this._updater!._dispose;\n\t\tthis._updater!._dispose = function () {\n\t\t\tdispose();\n\t\t\toldDispose.call(this);\n\t\t};\n\n\t\treturn [isText, wrappedSignal];\n\t}, []);\n\n\t// Rerender the component whenever `data.value` changes from a VNode\n\t// to another VNode, from text to a VNode, or from a VNode to text.\n\t// That is, everything else except text-to-text updates.\n\t//\n\t// This also ensures that the backing DOM node types gets updated to\n\t// text nodes and back when needed.\n\t//\n\t// For text-to-text updates, `.peek()` is used to skip full rerenders,\n\t// leaving them to the optimized path above.\n\treturn isText.value ? s.peek() : s.value;\n}\n\nSignalValue.displayName = \"ReactiveTextNode\";\n\nObject.defineProperties(Signal.prototype, {\n\tconstructor: { configurable: true, value: undefined },\n\ttype: { configurable: true, value: SignalValue },\n\tprops: {\n\t\tconfigurable: true,\n\t\tget() {\n\t\t\treturn { data: this };\n\t\t},\n\t},\n\t// Setting a VNode's _depth to 1 forces Preact to clone it before modifying:\n\t// https://github.com/preactjs/preact/blob/d7a433ee8463a7dc23a05111bb47de9ec729ad4d/src/diff/children.js#L77\n\t// @todo remove this for Preact 11\n\t__b: { configurable: true, value: 1 },\n});\n\n/** Inject low-level property/attribute bindings for Signals into Preact's diff */\nhook(OptionsTypes.DIFF, (old, vnode) => {\n\tif (DEVTOOLS_ENABLED && typeof vnode.type === \"function\") {\n\t\twindow.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();\n\t}\n\n\tif (typeof vnode.type === \"string\") {\n\t\tlet signalProps: Record<string, any> | undefined;\n\n\t\tlet props = vnode.props;\n\t\tfor (let i in props) {\n\t\t\tif (i === \"children\") continue;\n\n\t\t\tlet value = props[i];\n\t\t\tif (value instanceof Signal) {\n\t\t\t\tif (!signalProps) vnode.__np = signalProps = {};\n\t\t\t\tsignalProps[i] = value;\n\t\t\t\tprops[i] = value.peek();\n\t\t\t}\n\t\t}\n\t}\n\n\told(vnode);\n});\n\n/** Set up Updater before rendering a component */\nhook(OptionsTypes.RENDER, (old, vnode) => {\n\tif (DEVTOOLS_ENABLED && typeof vnode.type === \"function\") {\n\t\twindow.__PREACT_SIGNALS_DEVTOOLS__.enterComponent(vnode);\n\t}\n\n\t// Ignore the Fragment inserted by preact.createElement().\n\tif (vnode.type !== Fragment) {\n\t\tsetCurrentUpdater();\n\n\t\tlet updater;\n\n\t\tlet component = vnode.__c;\n\t\tif (component) {\n\t\t\tcomponent._updateFlags &= ~HAS_PENDING_UPDATE;\n\n\t\t\tupdater = component._updater;\n\t\t\tif (updater === undefined) {\n\t\t\t\tcomponent._updater = updater = createUpdater(() => {\n\t\t\t\t\tcomponent._updateFlags |= HAS_PENDING_UPDATE;\n\t\t\t\t\tcomponent.setState({});\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tcurrentComponent = component;\n\t\tsetCurrentUpdater(updater);\n\t}\n\n\told(vnode);\n});\n\n/** Finish current updater if a component errors */\nhook(OptionsTypes.CATCH_ERROR, (old, error, vnode, oldVNode) => {\n\tif (DEVTOOLS_ENABLED) {\n\t\twindow.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();\n\t}\n\n\tsetCurrentUpdater();\n\tcurrentComponent = undefined;\n\told(error, vnode, oldVNode);\n});\n\n/** Finish current updater after rendering any VNode */\nhook(OptionsTypes.DIFFED, (old, vnode) => {\n\tif (DEVTOOLS_ENABLED && typeof vnode.type === \"function\") {\n\t\twindow.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();\n\t}\n\n\tsetCurrentUpdater();\n\tcurrentComponent = undefined;\n\n\tlet dom: Element;\n\n\t// vnode._dom is undefined during string rendering,\n\t// so we use this to skip prop subscriptions during SSR.\n\tif (typeof vnode.type === \"string\" && (dom = vnode.__e as Element)) {\n\t\tlet props = vnode.__np;\n\t\tlet renderedProps = vnode.props;\n\t\tif (props) {\n\t\t\tlet updaters = dom._updaters;\n\t\t\tif (updaters) {\n\t\t\t\tfor (let prop in updaters) {\n\t\t\t\t\tlet updater = updaters[prop];\n\t\t\t\t\tif (updater !== undefined && !(prop in props)) {\n\t\t\t\t\t\tupdater._dispose();\n\t\t\t\t\t\t// @todo we could just always invoke _dispose() here\n\t\t\t\t\t\tupdaters[prop] = undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tupdaters = {};\n\t\t\t\tdom._updaters = updaters;\n\t\t\t}\n\t\t\tfor (let prop in props) {\n\t\t\t\tlet updater = updaters[prop];\n\t\t\t\tlet signal = props[prop];\n\t\t\t\tif (updater === undefined) {\n\t\t\t\t\tupdater = createPropUpdater(dom, prop, signal, renderedProps);\n\t\t\t\t\tupdaters[prop] = updater;\n\t\t\t\t} else {\n\t\t\t\t\tupdater._update(signal, renderedProps);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\told(vnode);\n});\n\nfunction createPropUpdater(\n\tdom: Element,\n\tprop: string,\n\tpropSignal: Signal,\n\tprops: Record<string, any>\n): PropertyUpdater {\n\tconst setAsProperty =\n\t\tprop in dom &&\n\t\t// SVG elements need to go through `setAttribute` because they\n\t\t// expect things like SVGAnimatedTransformList instead of strings.\n\t\t// @ts-ignore\n\t\tdom.ownerSVGElement === undefined;\n\n\tconst changeSignal = signal(propSignal);\n\treturn {\n\t\t_update: (newSignal: Signal, newProps: typeof props) => {\n\t\t\tchangeSignal.value = newSignal;\n\t\t\tprops = newProps;\n\t\t},\n\t\t_dispose: effect(function (this: Effect) {\n\t\t\tthis._notify = notifyDomUpdates;\n\t\t\tconst value = changeSignal.value.value;\n\t\t\t// If Preact just rendered this value, don't render it again:\n\t\t\tif (props[prop] === value) return;\n\t\t\tprops[prop] = value;\n\t\t\tif (setAsProperty) {\n\t\t\t\t// @ts-ignore-next-line silly\n\t\t\t\tdom[prop] = value;\n\t\t\t\t// Match Preact's attribute handling: data-* and aria-* attributes\n\t\t\t\t// https://github.com/preactjs/preact/blob/main/src/diff/props.js#L132\n\t\t\t} else if (value != null && (value !== false || prop[4] === \"-\")) {\n\t\t\t\tdom.setAttribute(prop, value);\n\t\t\t} else {\n\t\t\t\tdom.removeAttribute(prop);\n\t\t\t}\n\t\t}),\n\t};\n}\n\n/** Unsubscribe from Signals when unmounting components/vnodes */\nhook(OptionsTypes.UNMOUNT, (old, vnode: VNode) => {\n\tif (typeof vnode.type === \"string\") {\n\t\tlet dom = vnode.__e as Element | undefined;\n\t\t// vnode._dom is undefined during string rendering\n\t\tif (dom) {\n\t\t\tconst updaters = dom._updaters;\n\t\t\tif (updaters) {\n\t\t\t\tdom._updaters = undefined;\n\t\t\t\tfor (let prop in updaters) {\n\t\t\t\t\tlet updater = updaters[prop];\n\t\t\t\t\tif (updater) updater._dispose();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tlet component = vnode.__c;\n\t\tif (component) {\n\t\t\tconst updater = component._updater;\n\t\t\tif (updater) {\n\t\t\t\tcomponent._updater = undefined;\n\t\t\t\tupdater._dispose();\n\t\t\t}\n\t\t}\n\t}\n\told(vnode);\n});\n\n/** Mark components that use hook state so we can skip sCU optimization. */\nhook(OptionsTypes.HOOK, (old, component, index, type) => {\n\tif (type < 3 || type === 9)\n\t\t(component as AugmentedComponent)._updateFlags |= HAS_HOOK_STATE;\n\told(component, index, type);\n});\n\n/**\n * Auto-memoize components that use Signals/Computeds.\n * Note: Does _not_ optimize components that use hook/class state.\n */\nComponent.prototype.shouldComponentUpdate = function (\n\tthis: AugmentedComponent,\n\tprops,\n\tstate\n) {\n\t// @todo: Once preactjs/preact#3671 lands, this could just use `currentUpdater`:\n\tconst updater = this._updater;\n\tconst hasSignals = updater && updater._sources !== undefined;\n\n\t// If this is a component using state, rerender\n\t// @ts-ignore\n\tfor (let i in state) return true;\n\n\tif (this.__f || (typeof this.u == \"boolean\" && this.u === true)) {\n\t\tconst hasHooksState = this._updateFlags & HAS_HOOK_STATE;\n\t\t// if this component used no signals or computeds and no hooks state, update:\n\t\tif (!hasSignals && !hasHooksState && !(this._updateFlags & HAS_COMPUTEDS))\n\t\t\treturn true;\n\n\t\t// if there is a pending re-render triggered from Signals,\n\t\t// or if there is hooks state, update:\n\t\tif (this._updateFlags & HAS_PENDING_UPDATE) return true;\n\t} else {\n\t\t// if this component used no signals or computeds, update:\n\t\tif (!hasSignals && !(this._updateFlags & HAS_COMPUTEDS)) return true;\n\n\t\t// if there is a pending re-render triggered from Signals,\n\t\t// or if there is hooks state, update:\n\t\tif (this._updateFlags & (HAS_PENDING_UPDATE | HAS_HOOK_STATE)) return true;\n\t}\n\n\t// if any non-Signal props changed, update:\n\tfor (let i in props) {\n\t\tif (i !== \"__source\" && props[i] !== this.props[i]) return true;\n\t}\n\tfor (let i in this.props) if (!(i in props)) return true;\n\n\t// this is a purely Signal-driven component, don't update:\n\treturn false;\n};\n\nexport function useSignal<T>(value: T, options?: SignalOptions<T>): Signal<T>;\nexport function useSignal<T = undefined>(): Signal<T | undefined>;\nexport function useSignal<T>(value?: T, options?: SignalOptions<T>) {\n\treturn useState(() =>\n\t\tsignal<T | undefined>(value, options as SignalOptions)\n\t)[0];\n}\n\nexport function useComputed<T>(compute: () => T, options?: SignalOptions<T>) {\n\tconst $compute = useRef(compute);\n\t$compute.current = compute;\n\t(currentComponent as AugmentedComponent)._updateFlags |= HAS_COMPUTEDS;\n\treturn useMemo(() => computed<T>(() => $compute.current(), options), []);\n}\n\nfunction safeRaf(callback: () => void) {\n\tconst done = () => {\n\t\tclearTimeout(timeout);\n\t\tcancelAnimationFrame(raf);\n\t\tcallback();\n\t};\n\n\tconst timeout = setTimeout(done, 35);\n\tconst raf = requestAnimationFrame(done);\n}\n\nconst deferEffects =\n\ttypeof requestAnimationFrame === \"undefined\" ? setTimeout : safeRaf;\n\nconst deferDomUpdates = (cb: any) => {\n\tqueueMicrotask(() => {\n\t\tqueueMicrotask(cb);\n\t});\n};\n\nfunction flushEffects() {\n\tbatch(() => {\n\t\tlet inst: Effect | undefined;\n\t\twhile ((inst = effectsQueue.shift())) {\n\t\t\toldNotify.call(inst);\n\t\t}\n\t});\n}\n\nfunction notifyEffects(this: Effect) {\n\tif (effectsQueue.push(this) === 1) {\n\t\t(options.requestAnimationFrame || deferEffects)(flushEffects);\n\t}\n}\n\nfunction flushDomUpdates() {\n\tbatch(() => {\n\t\tlet inst: Effect | undefined;\n\t\twhile ((inst = domQueue.shift())) {\n\t\t\toldNotify.call(inst);\n\t\t}\n\t});\n}\n\nfunction notifyDomUpdates(this: Effect) {\n\tif (domQueue.push(this) === 1) {\n\t\t(options.requestAnimationFrame || deferDomUpdates)(flushDomUpdates);\n\t}\n}\n\nexport function useSignalEffect(\n\tcb: () => void | (() => void),\n\toptions?: EffectOptions\n) {\n\tconst callback = useRef(cb);\n\tcallback.current = cb;\n\n\tuseEffect(() => {\n\t\treturn effect(function (this: Effect) {\n\t\t\tthis._notify = notifyEffects;\n\t\t\treturn callback.current();\n\t\t}, options);\n\t}, []);\n}\n\n/**\n * @todo Determine which Reactive implementation we'll be using.\n * @internal\n */\n// export function useReactive<T extends object>(value: T): Reactive<T> {\n// \treturn useMemo(() => reactive<T>(value), []);\n// }\n\n/**\n * @internal\n * Update a Reactive's using the properties of an object or other Reactive.\n * Also works for Signals.\n * @example\n * // Update a Reactive with Object.assign()-like syntax:\n * const r = reactive({ name: \"Alice\" });\n * update(r, { name: \"Bob\" });\n * update(r, { age: 42 }); // property 'age' does not exist in type '{ name?: string }'\n * update(r, 2); // '2' has no properties in common with '{ name?: string }'\n * console.log(r.name.value); // \"Bob\"\n *\n * @example\n * // Update a Reactive with the properties of another Reactive:\n * const A = reactive({ name: \"Alice\" });\n * const B = reactive({ name: \"Bob\", age: 42 });\n * update(A, B);\n * console.log(`${A.name} is ${A.age}`); // \"Bob is 42\"\n *\n * @example\n * // Update a signal with assign()-like syntax:\n * const s = signal(42);\n * update(s, \"hi\"); // Argument type 'string' not assignable to type 'number'\n * update(s, {}); // Argument type '{}' not assignable to type 'number'\n * update(s, 43);\n * console.log(s.value); // 43\n *\n * @param obj The Reactive or Signal to be updated\n * @param update The value, Signal, object or Reactive to update `obj` to match\n * @param overwrite If `true`, any properties `obj` missing from `update` are set to `undefined`\n */\n/*\nexport function update<T extends SignalOrReactive>(\n\tobj: T,\n\tupdate: Partial<Unwrap<T>>,\n\toverwrite = false\n) {\n\tif (obj instanceof Signal) {\n\t\tobj.value = peekValue(update);\n\t} else {\n\t\tfor (let i in update) {\n\t\t\tif (i in obj) {\n\t\t\t\tobj[i].value = peekValue(update[i]);\n\t\t\t} else {\n\t\t\t\tlet sig = signal(peekValue(update[i]));\n\t\t\t\tsig[KEY] = i;\n\t\t\t\tobj[i] = sig;\n\t\t\t}\n\t\t}\n\t\tif (overwrite) {\n\t\t\tfor (let i in obj) {\n\t\t\t\tif (!(i in update)) {\n\t\t\t\t\tobj[i].value = undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n*/\n"],"names":["oldNotify","currentComponent","finishUpdate","DEVTOOLS_ENABLED","window","__PREACT_SIGNALS_DEVTOOLS__","effectsQueue","domQueue","effect","this","_notify","hook","hookName","hookFn","options","bind","setCurrentUpdater","updater","_start","SignalValue","_ref","_this","data","currentSignal","useSignal","value","_useMemo","useMemo","self","v","__v","__","__c","_updateFlags","wrappedSignal","computed","s","isText","Array","isArray","isValidElement","dispose","notifyDomUpdates","__e","nodeType","oldDispose","_updater","_dispose","call","peek","displayName","Object","defineProperties","Signal","prototype","constructor","configurable","undefined","type","props","get","__b","old","vnode","exitComponent","signalProps","i","__np","enterComponent","Fragment","component","update","_callback","setState","createUpdater","error","oldVNode","dom","renderedProps","updaters","_updaters","prop","signal","createPropUpdater","_update","propSignal","setAsProperty","ownerSVGElement","changeSignal","newSignal","newProps","setAttribute","removeAttribute","index","Component","shouldComponentUpdate","state","hasSignals","_sources","__f","u","hasHooksState","useState","deferEffects","requestAnimationFrame","setTimeout","callback","done","clearTimeout","timeout","cancelAnimationFrame","raf","deferDomUpdates","cb","queueMicrotask","flushEffects","batch","inst","shift","notifyEffects","push","flushDomUpdates","exports","signalsCore","untracked","useComputed","compute","$compute","useRef","current","useSignalEffect","useEffect"],"mappings":"IAwCIA,EAiBAC,EACAC,kFAzBEC,EACa,oBAAXC,UAA4BA,OAAOC,4BAO1CC,EAA8B,GAC9BC,EAA0B,GAK3BC,SAAO,WACNR,EAAYS,KAAKC,CAClB,EAFAF,GAKA,SAASG,EAA6BC,EAAaC,GAElDC,EAAOA,QAACF,GAAYC,EAAOE,KAAK,KAAMD,EAAOA,QAACF,IAAc,WAAO,EACpE,CAKA,SAASI,EAAkBC,GAE1B,GAAIf,EAAcA,IAElBA,EAAee,GAAWA,EAAQC,GACnC,CAwBA,SAASC,EAAWC,GAAqD,IAAAC,EAAAZ,KAAxBa,EAAIF,EAAJE,KAK1CC,EAAgBC,UAAUF,GAChCC,EAAcE,MAAQH,EAEtB,IAAAI,EAAoBC,EAAOA,QAAC,WAC3B,IAAIC,EAAOP,EAEPQ,EAAIR,EAAKS,IACb,MAAQD,EAAIA,EAAEE,GACb,GAAIF,EAAEG,IAAK,CACVH,EAAEG,IAAIC,MAjEY,EAkElB,KACD,CAGD,IAAMC,EAAgBC,WAAS,WAC9B,IAAIC,EAAIb,EAAcE,MAAMA,MAC5B,OAAa,IAANW,EAAU,GAAU,IAANA,EAAa,GAAKA,GAAK,EAC7C,GAEMC,EAASF,EAAAA,SACd,WACC,OAACG,MAAMC,QAAQL,EAAcT,SAC5Be,EAAAA,eAAeN,EAAcT,MAAM,GAIhCgB,EAAUjC,EAAMA,OAAC,WACtB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akH,KAAK/G,OACpBK,UAAQ0F,uBAAyBD,GAAcY,EAElD,CAEA,SAASM,IACRL,EAAKA,MAAC,WACL,IAAIC,EACJ,MAAQA,EAAO9G,EAAS+G,QACvBtH,EAAUgD,KAAKqE,EAEjB,EACD,CAEA,SAAS3E,IACR,GAA4B,IAAxBnC,EAASiH,KAAK/G,OAChBK,EAAOA,QAAC0F,uBAAyBQ,GAAiBS,EAErD,CAeAC,QAAArE,OAAAsE,EAAAtE,OAAAqE,QAAAN,MAAAO,EAAAP,MAAAM,QAAAvF,SAAAwF,EAAAxF,SAAAuF,QAAAlH,OAAAmH,EAAAnH,OAAAkH,QAAAxC,OAAAyC,EAAAzC,OAAAwC,QAAAE,UAAAD,EAAAC,UAAAF,QAAAG,YAtEgB,SAAeC,EAAkBhH,GAChD,IAAMiH,EAAWC,SAAOF,GACxBC,EAASE,QAAUH,EAClB7H,EAAwCgC,MA7XpB,EA8XrB,OAAON,EAAOA,QAAC,WAAA,OAAMQ,EAAQA,SAAI,WAAM,OAAA4F,EAASE,SAAS,EAAEnH,EAAQ,EAAE,GACtE,EAiEA4G,QAAAlG,UAAAA,UAAAkG,QAAAQ,gBAbgB,SACfjB,EACAnG,GAEA,IAAM4F,EAAWsB,EAAAA,OAAOf,GACxBP,EAASuB,QAAUhB,EAEnBkB,EAAAA,UAAU,WACT,OAAO3H,EAAAA,OAAO,WACbC,KAAKC,EAAU6G,EACf,OAAOb,EAASuB,SACjB,EAAGnH,EACJ,EAAG,GACJ"}
1
+ {"version":3,"file":"signals.js","sources":["../src/index.ts"],"sourcesContent":["import { options, Component, isValidElement, Fragment } from \"preact\";\nimport { useRef, useMemo, useEffect, useState } from \"preact/hooks\";\nimport {\n\tsignal,\n\tcomputed,\n\tbatch,\n\teffect,\n\tSignal,\n\ttype ReadonlySignal,\n\tuntracked,\n\tSignalOptions,\n\tEffectOptions,\n} from \"@preact/signals-core\";\nimport {\n\tVNode,\n\tOptionsTypes,\n\tHookFn,\n\tEffect,\n\tPropertyUpdater,\n\tAugmentedComponent,\n\tAugmentedElement as Element,\n} from \"./internal\";\n\nexport {\n\tsignal,\n\tcomputed,\n\tbatch,\n\teffect,\n\tSignal,\n\ttype ReadonlySignal,\n\tuntracked,\n};\n\nconst DEVTOOLS_ENABLED =\n\ttypeof window !== \"undefined\" && !!window.__PREACT_SIGNALS_DEVTOOLS__;\n\nconst HAS_PENDING_UPDATE = 1 << 0;\nconst HAS_HOOK_STATE = 1 << 1;\nconst HAS_COMPUTEDS = 1 << 2;\n\nlet oldNotify: (this: Effect) => void,\n\teffectsQueue: Array<Effect> = [],\n\tdomQueue: Array<Effect> = [];\n\n// Capture the original `Effect.prototype._notify` method so that we can install\n// custom `._notify`s for each different use-case but still call the original\n// implementation in the end. Dispose the temporary effect immediately afterwards.\neffect(function (this: Effect) {\n\toldNotify = this._notify;\n})();\n\n// Install a Preact options hook\nfunction hook<T extends OptionsTypes>(hookName: T, hookFn: HookFn<T>) {\n\t// @ts-ignore-next-line private options hooks usage\n\toptions[hookName] = hookFn.bind(null, options[hookName] || (() => {}));\n}\n\nlet currentComponent: AugmentedComponent | undefined;\nlet finishUpdate: (() => void) | undefined;\n\nfunction setCurrentUpdater(updater?: Effect) {\n\t// end tracking for the current update:\n\tif (finishUpdate) finishUpdate();\n\t// start tracking the new update:\n\tfinishUpdate = updater && updater._start();\n}\n\nfunction createUpdater(update: () => void, name: string) {\n\tlet updater!: Effect;\n\teffect(\n\t\tfunction (this: Effect) {\n\t\t\tupdater = this;\n\t\t},\n\t\t{ name }\n\t);\n\tupdater._callback = update;\n\treturn updater;\n}\n\n/** @todo This may be needed for complex prop value detection. */\n// function isSignalValue(value: any): value is Signal {\n// \tif (typeof value !== \"object\" || value == null) return false;\n// \tif (value instanceof Signal) return true;\n// \t// @TODO: uncomment this when we land Reactive (ideally behind a brand check)\n// \t// for (let i in value) if (value[i] instanceof Signal) return true;\n// \treturn false;\n// }\n\n/**\n * A wrapper component that renders a Signal directly as a Text node.\n * @todo: in Preact 11, just decorate Signal with `type:null`\n */\nfunction SignalValue(this: AugmentedComponent, { data }: { data: Signal }) {\n\t// hasComputeds.add(this);\n\n\t// Store the props.data signal in another signal so that\n\t// passing a new signal reference re-runs the text computed:\n\tconst currentSignal = useSignal(data);\n\tcurrentSignal.value = data;\n\n\tconst [isText, s] = useMemo(() => {\n\t\tlet self = this;\n\t\t// mark the parent component as having computeds so it gets optimized\n\t\tlet v = this.__v;\n\t\twhile ((v = v.__!)) {\n\t\t\tif (v.__c) {\n\t\t\t\tv.__c._updateFlags |= HAS_COMPUTEDS;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tconst wrappedSignal = computed(() => {\n\t\t\tlet s = currentSignal.value.value;\n\t\t\treturn s === 0 ? 0 : s === true ? \"\" : s || \"\";\n\t\t});\n\n\t\tconst isText = computed(\n\t\t\t() =>\n\t\t\t\t!Array.isArray(wrappedSignal.value) &&\n\t\t\t\t!isValidElement(wrappedSignal.value)\n\t\t);\n\t\t// Update text nodes directly without rerendering when the new value\n\t\t// is also text.\n\t\tconst dispose = effect(function (this: Effect) {\n\t\t\tthis._notify = notifyDomUpdates;\n\n\t\t\t// Subscribe to wrappedSignal updates only when its values are text...\n\t\t\tif (isText.value) {\n\t\t\t\t// ...but regardless of `self.base`'s current value, as it can be\n\t\t\t\t// undefined before mounting or a non-text node. In both of those cases\n\t\t\t\t// the update gets handled by a full rerender.\n\t\t\t\tconst value = wrappedSignal.value;\n\t\t\t\tif (self.__v && self.__v.__e && self.__v.__e.nodeType === 3) {\n\t\t\t\t\t(self.__v.__e as Text).data = value;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// Piggyback this._updater's disposal to ensure that the text updater effect\n\t\t// above also gets disposed on unmount.\n\t\tconst oldDispose = this._updater!._dispose;\n\t\tthis._updater!._dispose = function () {\n\t\t\tdispose();\n\t\t\toldDispose.call(this);\n\t\t};\n\n\t\treturn [isText, wrappedSignal];\n\t}, []);\n\n\t// Rerender the component whenever `data.value` changes from a VNode\n\t// to another VNode, from text to a VNode, or from a VNode to text.\n\t// That is, everything else except text-to-text updates.\n\t//\n\t// This also ensures that the backing DOM node types gets updated to\n\t// text nodes and back when needed.\n\t//\n\t// For text-to-text updates, `.peek()` is used to skip full rerenders,\n\t// leaving them to the optimized path above.\n\treturn isText.value ? s.peek() : s.value;\n}\n\nSignalValue.displayName = \"ReactiveTextNode\";\n\nObject.defineProperties(Signal.prototype, {\n\tconstructor: { configurable: true, value: undefined },\n\ttype: { configurable: true, value: SignalValue },\n\tprops: {\n\t\tconfigurable: true,\n\t\tget() {\n\t\t\treturn { data: this };\n\t\t},\n\t},\n\t// Setting a VNode's _depth to 1 forces Preact to clone it before modifying:\n\t// https://github.com/preactjs/preact/blob/d7a433ee8463a7dc23a05111bb47de9ec729ad4d/src/diff/children.js#L77\n\t// @todo remove this for Preact 11\n\t__b: { configurable: true, value: 1 },\n});\n\n/** Inject low-level property/attribute bindings for Signals into Preact's diff */\nhook(OptionsTypes.DIFF, (old, vnode) => {\n\tif (typeof vnode.type === \"string\") {\n\t\tlet signalProps: Record<string, any> | undefined;\n\n\t\tlet props = vnode.props;\n\t\tfor (let i in props) {\n\t\t\tif (i === \"children\") continue;\n\n\t\t\tlet value = props[i];\n\t\t\tif (value instanceof Signal) {\n\t\t\t\tif (!signalProps) vnode.__np = signalProps = {};\n\t\t\t\tsignalProps[i] = value;\n\t\t\t\tprops[i] = value.peek();\n\t\t\t}\n\t\t}\n\t}\n\n\told(vnode);\n});\n\n/** Set up Updater before rendering a component */\nhook(OptionsTypes.RENDER, (old, vnode) => {\n\t// Ignore the Fragment inserted by preact.createElement().\n\tif (vnode.type !== Fragment) {\n\t\tsetCurrentUpdater();\n\n\t\tlet updater: Effect | undefined;\n\n\t\tlet component = vnode.__c;\n\t\tif (component) {\n\t\t\tcomponent._updateFlags &= ~HAS_PENDING_UPDATE;\n\n\t\t\tupdater = component._updater;\n\t\t\tif (updater === undefined) {\n\t\t\t\tcomponent._updater = updater = createUpdater(\n\t\t\t\t\t() => {\n\t\t\t\t\t\tif (DEVTOOLS_ENABLED) updater!._debugCallback?.call(updater);\n\t\t\t\t\t\tcomponent._updateFlags |= HAS_PENDING_UPDATE;\n\t\t\t\t\t\tcomponent.setState({});\n\t\t\t\t\t},\n\t\t\t\t\ttypeof vnode.type === \"function\"\n\t\t\t\t\t\t? vnode.type.displayName || vnode.type.name\n\t\t\t\t\t\t: \"\"\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tcurrentComponent = component;\n\t\tsetCurrentUpdater(updater);\n\t}\n\n\told(vnode);\n});\n\n/** Finish current updater if a component errors */\nhook(OptionsTypes.CATCH_ERROR, (old, error, vnode, oldVNode) => {\n\tsetCurrentUpdater();\n\tcurrentComponent = undefined;\n\told(error, vnode, oldVNode);\n});\n\n/** Finish current updater after rendering any VNode */\nhook(OptionsTypes.DIFFED, (old, vnode) => {\n\tsetCurrentUpdater();\n\tcurrentComponent = undefined;\n\n\tlet dom: Element;\n\n\t// vnode._dom is undefined during string rendering,\n\t// so we use this to skip prop subscriptions during SSR.\n\tif (typeof vnode.type === \"string\" && (dom = vnode.__e as Element)) {\n\t\tlet props = vnode.__np;\n\t\tlet renderedProps = vnode.props;\n\t\tif (props) {\n\t\t\tlet updaters = dom._updaters;\n\t\t\tif (updaters) {\n\t\t\t\tfor (let prop in updaters) {\n\t\t\t\t\tlet updater = updaters[prop];\n\t\t\t\t\tif (updater !== undefined && !(prop in props)) {\n\t\t\t\t\t\tupdater._dispose();\n\t\t\t\t\t\t// @todo we could just always invoke _dispose() here\n\t\t\t\t\t\tupdaters[prop] = undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tupdaters = {};\n\t\t\t\tdom._updaters = updaters;\n\t\t\t}\n\t\t\tfor (let prop in props) {\n\t\t\t\tlet updater = updaters[prop];\n\t\t\t\tlet signal = props[prop];\n\t\t\t\tif (updater === undefined) {\n\t\t\t\t\tupdater = createPropUpdater(dom, prop, signal, renderedProps);\n\t\t\t\t\tupdaters[prop] = updater;\n\t\t\t\t} else {\n\t\t\t\t\tupdater._update(signal, renderedProps);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\told(vnode);\n});\n\nfunction createPropUpdater(\n\tdom: Element,\n\tprop: string,\n\tpropSignal: Signal,\n\tprops: Record<string, any>\n): PropertyUpdater {\n\tconst setAsProperty =\n\t\tprop in dom &&\n\t\t// SVG elements need to go through `setAttribute` because they\n\t\t// expect things like SVGAnimatedTransformList instead of strings.\n\t\t// @ts-ignore\n\t\tdom.ownerSVGElement === undefined;\n\n\tconst changeSignal = signal(propSignal);\n\treturn {\n\t\t_update: (newSignal: Signal, newProps: typeof props) => {\n\t\t\tchangeSignal.value = newSignal;\n\t\t\tprops = newProps;\n\t\t},\n\t\t_dispose: effect(function (this: Effect) {\n\t\t\tthis._notify = notifyDomUpdates;\n\t\t\tconst value = changeSignal.value.value;\n\t\t\t// If Preact just rendered this value, don't render it again:\n\t\t\tif (props[prop] === value) return;\n\t\t\tprops[prop] = value;\n\t\t\tif (setAsProperty) {\n\t\t\t\t// @ts-ignore-next-line silly\n\t\t\t\tdom[prop] = value;\n\t\t\t\t// Match Preact's attribute handling: data-* and aria-* attributes\n\t\t\t\t// https://github.com/preactjs/preact/blob/main/src/diff/props.js#L132\n\t\t\t} else if (value != null && (value !== false || prop[4] === \"-\")) {\n\t\t\t\tdom.setAttribute(prop, value);\n\t\t\t} else {\n\t\t\t\tdom.removeAttribute(prop);\n\t\t\t}\n\t\t}),\n\t};\n}\n\n/** Unsubscribe from Signals when unmounting components/vnodes */\nhook(OptionsTypes.UNMOUNT, (old, vnode: VNode) => {\n\tif (typeof vnode.type === \"string\") {\n\t\tlet dom = vnode.__e as Element | undefined;\n\t\t// vnode._dom is undefined during string rendering\n\t\tif (dom) {\n\t\t\tconst updaters = dom._updaters;\n\t\t\tif (updaters) {\n\t\t\t\tdom._updaters = undefined;\n\t\t\t\tfor (let prop in updaters) {\n\t\t\t\t\tlet updater = updaters[prop];\n\t\t\t\t\tif (updater) updater._dispose();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tlet component = vnode.__c;\n\t\tif (component) {\n\t\t\tconst updater = component._updater;\n\t\t\tif (updater) {\n\t\t\t\tcomponent._updater = undefined;\n\t\t\t\tupdater._dispose();\n\t\t\t}\n\t\t}\n\t}\n\told(vnode);\n});\n\n/** Mark components that use hook state so we can skip sCU optimization. */\nhook(OptionsTypes.HOOK, (old, component, index, type) => {\n\tif (type < 3 || type === 9)\n\t\t(component as AugmentedComponent)._updateFlags |= HAS_HOOK_STATE;\n\told(component, index, type);\n});\n\n/**\n * Auto-memoize components that use Signals/Computeds.\n * Note: Does _not_ optimize components that use hook/class state.\n */\nComponent.prototype.shouldComponentUpdate = function (\n\tthis: AugmentedComponent,\n\tprops,\n\tstate\n) {\n\t// @todo: Once preactjs/preact#3671 lands, this could just use `currentUpdater`:\n\tconst updater = this._updater;\n\tconst hasSignals = updater && updater._sources !== undefined;\n\n\t// If this is a component using state, rerender\n\t// @ts-ignore\n\tfor (let i in state) return true;\n\n\tif (this.__f || (typeof this.u == \"boolean\" && this.u === true)) {\n\t\tconst hasHooksState = this._updateFlags & HAS_HOOK_STATE;\n\t\t// if this component used no signals or computeds and no hooks state, update:\n\t\tif (!hasSignals && !hasHooksState && !(this._updateFlags & HAS_COMPUTEDS))\n\t\t\treturn true;\n\n\t\t// if there is a pending re-render triggered from Signals,\n\t\t// or if there is hooks state, update:\n\t\tif (this._updateFlags & HAS_PENDING_UPDATE) return true;\n\t} else {\n\t\t// if this component used no signals or computeds, update:\n\t\tif (!hasSignals && !(this._updateFlags & HAS_COMPUTEDS)) return true;\n\n\t\t// if there is a pending re-render triggered from Signals,\n\t\t// or if there is hooks state, update:\n\t\tif (this._updateFlags & (HAS_PENDING_UPDATE | HAS_HOOK_STATE)) return true;\n\t}\n\n\t// if any non-Signal props changed, update:\n\tfor (let i in props) {\n\t\tif (i !== \"__source\" && props[i] !== this.props[i]) return true;\n\t}\n\tfor (let i in this.props) if (!(i in props)) return true;\n\n\t// this is a purely Signal-driven component, don't update:\n\treturn false;\n};\n\nexport function useSignal<T>(value: T, options?: SignalOptions<T>): Signal<T>;\nexport function useSignal<T = undefined>(): Signal<T | undefined>;\nexport function useSignal<T>(value?: T, options?: SignalOptions<T>) {\n\treturn useState(() =>\n\t\tsignal<T | undefined>(value, options as SignalOptions)\n\t)[0];\n}\n\nexport function useComputed<T>(compute: () => T, options?: SignalOptions<T>) {\n\tconst $compute = useRef(compute);\n\t$compute.current = compute;\n\t(currentComponent as AugmentedComponent)._updateFlags |= HAS_COMPUTEDS;\n\treturn useMemo(() => computed<T>(() => $compute.current(), options), []);\n}\n\nfunction safeRaf(callback: () => void) {\n\tconst done = () => {\n\t\tclearTimeout(timeout);\n\t\tcancelAnimationFrame(raf);\n\t\tcallback();\n\t};\n\n\tconst timeout = setTimeout(done, 35);\n\tconst raf = requestAnimationFrame(done);\n}\n\nconst deferEffects =\n\ttypeof requestAnimationFrame === \"undefined\" ? setTimeout : safeRaf;\n\nconst deferDomUpdates = (cb: any) => {\n\tqueueMicrotask(() => {\n\t\tqueueMicrotask(cb);\n\t});\n};\n\nfunction flushEffects() {\n\tbatch(() => {\n\t\tlet inst: Effect | undefined;\n\t\twhile ((inst = effectsQueue.shift())) {\n\t\t\toldNotify.call(inst);\n\t\t}\n\t});\n}\n\nfunction notifyEffects(this: Effect) {\n\tif (effectsQueue.push(this) === 1) {\n\t\t(options.requestAnimationFrame || deferEffects)(flushEffects);\n\t}\n}\n\nfunction flushDomUpdates() {\n\tbatch(() => {\n\t\tlet inst: Effect | undefined;\n\t\twhile ((inst = domQueue.shift())) {\n\t\t\toldNotify.call(inst);\n\t\t}\n\t});\n}\n\nfunction notifyDomUpdates(this: Effect) {\n\tif (domQueue.push(this) === 1) {\n\t\t(options.requestAnimationFrame || deferDomUpdates)(flushDomUpdates);\n\t}\n}\n\nexport function useSignalEffect(\n\tcb: () => void | (() => void),\n\toptions?: EffectOptions\n) {\n\tconst callback = useRef(cb);\n\tcallback.current = cb;\n\n\tuseEffect(() => {\n\t\treturn effect(function (this: Effect) {\n\t\t\tthis._notify = notifyEffects;\n\t\t\treturn callback.current();\n\t\t}, options);\n\t}, []);\n}\n\n/**\n * @todo Determine which Reactive implementation we'll be using.\n * @internal\n */\n// export function useReactive<T extends object>(value: T): Reactive<T> {\n// \treturn useMemo(() => reactive<T>(value), []);\n// }\n\n/**\n * @internal\n * Update a Reactive's using the properties of an object or other Reactive.\n * Also works for Signals.\n * @example\n * // Update a Reactive with Object.assign()-like syntax:\n * const r = reactive({ name: \"Alice\" });\n * update(r, { name: \"Bob\" });\n * update(r, { age: 42 }); // property 'age' does not exist in type '{ name?: string }'\n * update(r, 2); // '2' has no properties in common with '{ name?: string }'\n * console.log(r.name.value); // \"Bob\"\n *\n * @example\n * // Update a Reactive with the properties of another Reactive:\n * const A = reactive({ name: \"Alice\" });\n * const B = reactive({ name: \"Bob\", age: 42 });\n * update(A, B);\n * console.log(`${A.name} is ${A.age}`); // \"Bob is 42\"\n *\n * @example\n * // Update a signal with assign()-like syntax:\n * const s = signal(42);\n * update(s, \"hi\"); // Argument type 'string' not assignable to type 'number'\n * update(s, {}); // Argument type '{}' not assignable to type 'number'\n * update(s, 43);\n * console.log(s.value); // 43\n *\n * @param obj The Reactive or Signal to be updated\n * @param update The value, Signal, object or Reactive to update `obj` to match\n * @param overwrite If `true`, any properties `obj` missing from `update` are set to `undefined`\n */\n/*\nexport function update<T extends SignalOrReactive>(\n\tobj: T,\n\tupdate: Partial<Unwrap<T>>,\n\toverwrite = false\n) {\n\tif (obj instanceof Signal) {\n\t\tobj.value = peekValue(update);\n\t} else {\n\t\tfor (let i in update) {\n\t\t\tif (i in obj) {\n\t\t\t\tobj[i].value = peekValue(update[i]);\n\t\t\t} else {\n\t\t\t\tlet sig = signal(peekValue(update[i]));\n\t\t\t\tsig[KEY] = i;\n\t\t\t\tobj[i] = sig;\n\t\t\t}\n\t\t}\n\t\tif (overwrite) {\n\t\t\tfor (let i in obj) {\n\t\t\t\tif (!(i in update)) {\n\t\t\t\t\tobj[i].value = undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n*/\n"],"names":["oldNotify","currentComponent","finishUpdate","DEVTOOLS_ENABLED","window","__PREACT_SIGNALS_DEVTOOLS__","effectsQueue","domQueue","effect","this","_notify","hook","hookName","hookFn","options","bind","setCurrentUpdater","updater","_start","SignalValue","_ref","_this","data","currentSignal","useSignal","value","_useMemo","useMemo","self","v","__v","__","__c","_updateFlags","wrappedSignal","computed","s","isText","Array","isArray","isValidElement","dispose","notifyDomUpdates","__e","nodeType","oldDispose","_updater","_dispose","call","peek","displayName","Object","defineProperties","Signal","prototype","constructor","configurable","undefined","type","props","get","__b","old","vnode","signalProps","i","__np","Fragment","component","update","name","_callback","createUpdater","_updater$_debugCallba","_debugCallback","setState","error","oldVNode","dom","renderedProps","updaters","_updaters","prop","signal","createPropUpdater","_update","propSignal","setAsProperty","ownerSVGElement","changeSignal","newSignal","newProps","setAttribute","removeAttribute","index","Component","shouldComponentUpdate","state","hasSignals","_sources","__f","u","hasHooksState","useState","deferEffects","requestAnimationFrame","setTimeout","callback","done","clearTimeout","timeout","cancelAnimationFrame","raf","deferDomUpdates","cb","queueMicrotask","flushEffects","batch","inst","shift","notifyEffects","push","flushDomUpdates","exports","signalsCore","untracked","useComputed","compute","$compute","useRef","current","useSignalEffect","useEffect"],"mappings":"IAwCIA,EAiBAC,EACAC,kFAzBEC,EACa,oBAAXC,UAA4BA,OAAOC,4BAO1CC,EAA8B,GAC9BC,EAA0B,GAK3BC,SAAO,WACNR,EAAYS,KAAKC,CAClB,EAFAF,GAKA,SAASG,EAA6BC,EAAaC,GAElDC,EAAOA,QAACF,GAAYC,EAAOE,KAAK,KAAMD,EAAOA,QAACF,IAAc,WAAS,EACtE,CAKA,SAASI,EAAkBC,GAE1B,GAAIf,EAAcA,IAElBA,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AQ,gBAbgB,SACfjB,EACApG,GAEA,IAAM6F,EAAWsB,EAAAA,OAAOf,GACxBP,EAASuB,QAAUhB,EAEnBkB,EAAAA,UAAU,WACT,OAAO5H,EAAAA,OAAO,WACbC,KAAKC,EAAU8G,EACf,OAAOb,EAASuB,SACjB,EAAGpH,EACJ,EAAG,GACJ"}
@@ -1 +1 @@
1
- !function(i,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("preact"),require("preact/hooks"),require("@preact/signals-core")):"function"==typeof define&&define.amd?define(["exports","preact","preact/hooks","@preact/signals-core"],n):n((i||self).preactSignals={},i.preact,i.preactHooks,i.preactSignalsCore)}(this,function(i,n,t,r){var e,f,o,u="undefined"!=typeof window&&!!window.__PREACT_SIGNALS_DEVTOOLS__,a=[],c=[];r.effect(function(){e=this.N})();function s(i,t){n.options[i]=t.bind(null,n.options[i]||function(){})}function v(i){if(o)o();o=i&&i.S()}function d(i){var e=this,f=i.data,o=useSignal(f);o.value=f;var u=t.useMemo(function(){var i=e,t=e.__v;while(t=t.__)if(t.__c){t.__c.__$f|=4;break}var f=r.computed(function(){var i=o.value.value;return 0===i?0:!0===i?"":i||""}),u=r.computed(function(){return!Array.isArray(f.value)&&!n.isValidElement(f.value)}),a=r.effect(function(){this.N=b;if(u.value){var n=f.value;if(i.__v&&i.__v.__e&&3===i.__v.__e.nodeType)i.__v.__e.data=n}}),c=e.__$u.d;e.__$u.d=function(){a();c.call(this)};return[u,f]},[]),a=u[0],c=u[1];return a.value?c.peek():c.value}d.displayName="ReactiveTextNode";Object.defineProperties(r.Signal.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:d},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});s("__b",function(i,n){if(u&&"function"==typeof n.type)window.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();if("string"==typeof n.type){var t,e=n.props;for(var f in e)if("children"!==f){var o=e[f];if(o instanceof r.Signal){if(!t)n.__np=t={};t[f]=o;e[f]=o.peek()}}}i(n)});s("__r",function(i,t){if(u&&"function"==typeof t.type)window.__PREACT_SIGNALS_DEVTOOLS__.enterComponent(t);if(t.type!==n.Fragment){v();var e,o=t.__c;if(o){o.__$f&=-2;if(void 0===(e=o.__$u))o.__$u=e=function(i){var n;r.effect(function(){n=this});n.c=function(){o.__$f|=1;o.setState({})};return n}()}f=o;v(e)}i(t)});s("__e",function(i,n,t,r){if(u)window.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();v();f=void 0;i(n,t,r)});s("diffed",function(i,n){if(u&&"function"==typeof n.type)window.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();v();f=void 0;var t;if("string"==typeof n.type&&(t=n.__e)){var r=n.__np,e=n.props;if(r){var o=t.U;if(o)for(var a in o){var c=o[a];if(void 0!==c&&!(a in r)){c.d();o[a]=void 0}}else{o={};t.U=o}for(var s in r){var d=o[s],h=r[s];if(void 0===d){d=l(t,s,h,e);o[s]=d}else d.o(h,e)}}}i(n)});function l(i,n,t,e){var f=n in i&&void 0===i.ownerSVGElement,o=r.signal(t);return{o:function(i,n){o.value=i;e=n},d:r.effect(function(){this.N=b;var t=o.value.value;if(e[n]!==t){e[n]=t;if(f)i[n]=t;else if(null!=t&&(!1!==t||"-"===n[4]))i.setAttribute(n,t);else i.removeAttribute(n)}})}}s("unmount",function(i,n){if("string"==typeof n.type){var t=n.__e;if(t){var r=t.U;if(r){t.U=void 0;for(var e in r){var f=r[e];if(f)f.d()}}}}else{var o=n.__c;if(o){var u=o.__$u;if(u){o.__$u=void 0;u.d()}}}i(n)});s("__h",function(i,n,t,r){if(r<3||9===r)n.__$f|=2;i(n,t,r)});n.Component.prototype.shouldComponentUpdate=function(i,n){var t=this.__$u,r=t&&void 0!==t.s;for(var e in n)return!0;if(this.__f||"boolean"==typeof this.u&&!0===this.u){var f=2&this.__$f;if(!(r||f||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(r||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 u in this.props)if(!(u in i))return!0;return!1};function useSignal(i,n){return t.useState(function(){return r.signal(i,n)})[0]}var h="undefined"==typeof requestAnimationFrame?setTimeout:function(i){var n=function(){clearTimeout(t);cancelAnimationFrame(r);i()},t=setTimeout(n,35),r=requestAnimationFrame(n)},p=function(i){queueMicrotask(function(){queueMicrotask(i)})};function w(){r.batch(function(){var i;while(i=a.shift())e.call(i)})}function y(){if(1===a.push(this))(n.options.requestAnimationFrame||h)(w)}function _(){r.batch(function(){var i;while(i=c.shift())e.call(i)})}function b(){if(1===c.push(this))(n.options.requestAnimationFrame||p)(_)}i.Signal=r.Signal;i.batch=r.batch;i.computed=r.computed;i.effect=r.effect;i.signal=r.signal;i.untracked=r.untracked;i.useComputed=function(i,n){var e=t.useRef(i);e.current=i;f.__$f|=4;return t.useMemo(function(){return r.computed(function(){return e.current()},n)},[])};i.useSignal=useSignal;i.useSignalEffect=function(i,n){var e=t.useRef(i);e.current=i;t.useEffect(function(){return r.effect(function(){this.N=y;return e.current()},n)},[])}});//# sourceMappingURL=signals.min.js.map
1
+ !function(i,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("preact"),require("preact/hooks"),require("@preact/signals-core")):"function"==typeof define&&define.amd?define(["exports","preact","preact/hooks","@preact/signals-core"],n):n((i||self).preactSignals={},i.preact,i.preactHooks,i.preactSignalsCore)}(this,function(i,n,t,r){var e,f,o,u="undefined"!=typeof window&&!!window.__PREACT_SIGNALS_DEVTOOLS__,a=[],c=[];r.effect(function(){e=this.N})();function s(i,t){n.options[i]=t.bind(null,n.options[i]||function(){})}function v(i){if(o)o();o=i&&i.S()}function l(i){var e=this,f=i.data,o=useSignal(f);o.value=f;var u=t.useMemo(function(){var i=e,t=e.__v;while(t=t.__)if(t.__c){t.__c.__$f|=4;break}var f=r.computed(function(){var i=o.value.value;return 0===i?0:!0===i?"":i||""}),u=r.computed(function(){return!Array.isArray(f.value)&&!n.isValidElement(f.value)}),a=r.effect(function(){this.N=g;if(u.value){var n=f.value;if(i.__v&&i.__v.__e&&3===i.__v.__e.nodeType)i.__v.__e.data=n}}),c=e.__$u.d;e.__$u.d=function(){a();c.call(this)};return[u,f]},[]),a=u[0],c=u[1];return a.value?c.peek():c.value}l.displayName="ReactiveTextNode";Object.defineProperties(r.Signal.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:l},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});s("__b",function(i,n){if("string"==typeof n.type){var t,e=n.props;for(var f in e)if("children"!==f){var o=e[f];if(o instanceof r.Signal){if(!t)n.__np=t={};t[f]=o;e[f]=o.peek()}}}i(n)});s("__r",function(i,t){if(t.type!==n.Fragment){v();var e,o=t.__c;if(o){o.__$f&=-2;if(void 0===(e=o.__$u))o.__$u=e=function(i,n){var t;r.effect(function(){t=this},{name:n});t.c=i;return t}(function(){var i;if(u)null==(i=e.y)||i.call(e);o.__$f|=1;o.setState({})},"function"==typeof t.type?t.type.displayName||t.type.name:"")}f=o;v(e)}i(t)});s("__e",function(i,n,t,r){v();f=void 0;i(n,t,r)});s("diffed",function(i,n){v();f=void 0;var t;if("string"==typeof n.type&&(t=n.__e)){var r=n.__np,e=n.props;if(r){var o=t.U;if(o)for(var u in o){var a=o[u];if(void 0!==a&&!(u in r)){a.d();o[u]=void 0}}else{o={};t.U=o}for(var c in r){var s=o[c],l=r[c];if(void 0===s){s=d(t,c,l,e);o[c]=s}else s.o(l,e)}}}i(n)});function d(i,n,t,e){var f=n in i&&void 0===i.ownerSVGElement,o=r.signal(t);return{o:function(i,n){o.value=i;e=n},d:r.effect(function(){this.N=g;var t=o.value.value;if(e[n]!==t){e[n]=t;if(f)i[n]=t;else if(null!=t&&(!1!==t||"-"===n[4]))i.setAttribute(n,t);else i.removeAttribute(n)}})}}s("unmount",function(i,n){if("string"==typeof n.type){var t=n.__e;if(t){var r=t.U;if(r){t.U=void 0;for(var e in r){var f=r[e];if(f)f.d()}}}}else{var o=n.__c;if(o){var u=o.__$u;if(u){o.__$u=void 0;u.d()}}}i(n)});s("__h",function(i,n,t,r){if(r<3||9===r)n.__$f|=2;i(n,t,r)});n.Component.prototype.shouldComponentUpdate=function(i,n){var t=this.__$u,r=t&&void 0!==t.s;for(var e in n)return!0;if(this.__f||"boolean"==typeof this.u&&!0===this.u){var f=2&this.__$f;if(!(r||f||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(r||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 u in this.props)if(!(u in i))return!0;return!1};function useSignal(i,n){return t.useState(function(){return r.signal(i,n)})[0]}var h="undefined"==typeof requestAnimationFrame?setTimeout:function(i){var n=function(){clearTimeout(t);cancelAnimationFrame(r);i()},t=setTimeout(n,35),r=requestAnimationFrame(n)},p=function(i){queueMicrotask(function(){queueMicrotask(i)})};function _(){r.batch(function(){var i;while(i=a.shift())e.call(i)})}function y(){if(1===a.push(this))(n.options.requestAnimationFrame||h)(_)}function b(){r.batch(function(){var i;while(i=c.shift())e.call(i)})}function g(){if(1===c.push(this))(n.options.requestAnimationFrame||p)(b)}i.Signal=r.Signal;i.batch=r.batch;i.computed=r.computed;i.effect=r.effect;i.signal=r.signal;i.untracked=r.untracked;i.useComputed=function(i,n){var e=t.useRef(i);e.current=i;f.__$f|=4;return t.useMemo(function(){return r.computed(function(){return e.current()},n)},[])};i.useSignal=useSignal;i.useSignalEffect=function(i,n){var e=t.useRef(i);e.current=i;t.useEffect(function(){return r.effect(function(){this.N=y;return e.current()},n)},[])}});//# sourceMappingURL=signals.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"signals.min.js","sources":["../src/index.ts"],"sourcesContent":["import { options, Component, isValidElement, Fragment } from \"preact\";\nimport { useRef, useMemo, useEffect, useState } from \"preact/hooks\";\nimport {\n\tsignal,\n\tcomputed,\n\tbatch,\n\teffect,\n\tSignal,\n\ttype ReadonlySignal,\n\tuntracked,\n\tSignalOptions,\n\tEffectOptions,\n} from \"@preact/signals-core\";\nimport {\n\tVNode,\n\tOptionsTypes,\n\tHookFn,\n\tEffect,\n\tPropertyUpdater,\n\tAugmentedComponent,\n\tAugmentedElement as Element,\n} from \"./internal\";\n\nexport {\n\tsignal,\n\tcomputed,\n\tbatch,\n\teffect,\n\tSignal,\n\ttype ReadonlySignal,\n\tuntracked,\n};\n\nconst DEVTOOLS_ENABLED =\n\ttypeof window !== \"undefined\" && !!window.__PREACT_SIGNALS_DEVTOOLS__;\n\nconst HAS_PENDING_UPDATE = 1 << 0;\nconst HAS_HOOK_STATE = 1 << 1;\nconst HAS_COMPUTEDS = 1 << 2;\n\nlet oldNotify: (this: Effect) => void,\n\teffectsQueue: Array<Effect> = [],\n\tdomQueue: Array<Effect> = [];\n\n// Capture the original `Effect.prototype._notify` method so that we can install\n// custom `._notify`s for each different use-case but still call the original\n// implementation in the end. Dispose the temporary effect immediately afterwards.\neffect(function (this: Effect) {\n\toldNotify = this._notify;\n})();\n\n// Install a Preact options hook\nfunction hook<T extends OptionsTypes>(hookName: T, hookFn: HookFn<T>) {\n\t// @ts-ignore-next-line private options hooks usage\n\toptions[hookName] = hookFn.bind(null, options[hookName] || (() => {}));\n}\n\nlet currentComponent: AugmentedComponent | undefined;\nlet finishUpdate: (() => void) | undefined;\n\nfunction setCurrentUpdater(updater?: Effect) {\n\t// end tracking for the current update:\n\tif (finishUpdate) finishUpdate();\n\t// start tracking the new update:\n\tfinishUpdate = updater && updater._start();\n}\n\nfunction createUpdater(update: () => void) {\n\tlet updater!: Effect;\n\teffect(function (this: Effect) {\n\t\tupdater = this;\n\t});\n\tupdater._callback = update;\n\treturn updater;\n}\n\n/** @todo This may be needed for complex prop value detection. */\n// function isSignalValue(value: any): value is Signal {\n// \tif (typeof value !== \"object\" || value == null) return false;\n// \tif (value instanceof Signal) return true;\n// \t// @TODO: uncomment this when we land Reactive (ideally behind a brand check)\n// \t// for (let i in value) if (value[i] instanceof Signal) return true;\n// \treturn false;\n// }\n\n/**\n * A wrapper component that renders a Signal directly as a Text node.\n * @todo: in Preact 11, just decorate Signal with `type:null`\n */\nfunction SignalValue(this: AugmentedComponent, { data }: { data: Signal }) {\n\t// hasComputeds.add(this);\n\n\t// Store the props.data signal in another signal so that\n\t// passing a new signal reference re-runs the text computed:\n\tconst currentSignal = useSignal(data);\n\tcurrentSignal.value = data;\n\n\tconst [isText, s] = useMemo(() => {\n\t\tlet self = this;\n\t\t// mark the parent component as having computeds so it gets optimized\n\t\tlet v = this.__v;\n\t\twhile ((v = v.__!)) {\n\t\t\tif (v.__c) {\n\t\t\t\tv.__c._updateFlags |= HAS_COMPUTEDS;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tconst wrappedSignal = computed(() => {\n\t\t\tlet s = currentSignal.value.value;\n\t\t\treturn s === 0 ? 0 : s === true ? \"\" : s || \"\";\n\t\t});\n\n\t\tconst isText = computed(\n\t\t\t() =>\n\t\t\t\t!Array.isArray(wrappedSignal.value) &&\n\t\t\t\t!isValidElement(wrappedSignal.value)\n\t\t);\n\t\t// Update text nodes directly without rerendering when the new value\n\t\t// is also text.\n\t\tconst dispose = effect(function (this: Effect) {\n\t\t\tthis._notify = notifyDomUpdates;\n\n\t\t\t// Subscribe to wrappedSignal updates only when its values are text...\n\t\t\tif (isText.value) {\n\t\t\t\t// ...but regardless of `self.base`'s current value, as it can be\n\t\t\t\t// undefined before mounting or a non-text node. In both of those cases\n\t\t\t\t// the update gets handled by a full rerender.\n\t\t\t\tconst value = wrappedSignal.value;\n\t\t\t\tif (self.__v && self.__v.__e && self.__v.__e.nodeType === 3) {\n\t\t\t\t\t(self.__v.__e as Text).data = value;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// Piggyback this._updater's disposal to ensure that the text updater effect\n\t\t// above also gets disposed on unmount.\n\t\tconst oldDispose = this._updater!._dispose;\n\t\tthis._updater!._dispose = function () {\n\t\t\tdispose();\n\t\t\toldDispose.call(this);\n\t\t};\n\n\t\treturn [isText, wrappedSignal];\n\t}, []);\n\n\t// Rerender the component whenever `data.value` changes from a VNode\n\t// to another VNode, from text to a VNode, or from a VNode to text.\n\t// That is, everything else except text-to-text updates.\n\t//\n\t// This also ensures that the backing DOM node types gets updated to\n\t// text nodes and back when needed.\n\t//\n\t// For text-to-text updates, `.peek()` is used to skip full rerenders,\n\t// leaving them to the optimized path above.\n\treturn isText.value ? s.peek() : s.value;\n}\n\nSignalValue.displayName = \"ReactiveTextNode\";\n\nObject.defineProperties(Signal.prototype, {\n\tconstructor: { configurable: true, value: undefined },\n\ttype: { configurable: true, value: SignalValue },\n\tprops: {\n\t\tconfigurable: true,\n\t\tget() {\n\t\t\treturn { data: this };\n\t\t},\n\t},\n\t// Setting a VNode's _depth to 1 forces Preact to clone it before modifying:\n\t// https://github.com/preactjs/preact/blob/d7a433ee8463a7dc23a05111bb47de9ec729ad4d/src/diff/children.js#L77\n\t// @todo remove this for Preact 11\n\t__b: { configurable: true, value: 1 },\n});\n\n/** Inject low-level property/attribute bindings for Signals into Preact's diff */\nhook(OptionsTypes.DIFF, (old, vnode) => {\n\tif (DEVTOOLS_ENABLED && typeof vnode.type === \"function\") {\n\t\twindow.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();\n\t}\n\n\tif (typeof vnode.type === \"string\") {\n\t\tlet signalProps: Record<string, any> | undefined;\n\n\t\tlet props = vnode.props;\n\t\tfor (let i in props) {\n\t\t\tif (i === \"children\") continue;\n\n\t\t\tlet value = props[i];\n\t\t\tif (value instanceof Signal) {\n\t\t\t\tif (!signalProps) vnode.__np = signalProps = {};\n\t\t\t\tsignalProps[i] = value;\n\t\t\t\tprops[i] = value.peek();\n\t\t\t}\n\t\t}\n\t}\n\n\told(vnode);\n});\n\n/** Set up Updater before rendering a component */\nhook(OptionsTypes.RENDER, (old, vnode) => {\n\tif (DEVTOOLS_ENABLED && typeof vnode.type === \"function\") {\n\t\twindow.__PREACT_SIGNALS_DEVTOOLS__.enterComponent(vnode);\n\t}\n\n\t// Ignore the Fragment inserted by preact.createElement().\n\tif (vnode.type !== Fragment) {\n\t\tsetCurrentUpdater();\n\n\t\tlet updater;\n\n\t\tlet component = vnode.__c;\n\t\tif (component) {\n\t\t\tcomponent._updateFlags &= ~HAS_PENDING_UPDATE;\n\n\t\t\tupdater = component._updater;\n\t\t\tif (updater === undefined) {\n\t\t\t\tcomponent._updater = updater = createUpdater(() => {\n\t\t\t\t\tcomponent._updateFlags |= HAS_PENDING_UPDATE;\n\t\t\t\t\tcomponent.setState({});\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tcurrentComponent = component;\n\t\tsetCurrentUpdater(updater);\n\t}\n\n\told(vnode);\n});\n\n/** Finish current updater if a component errors */\nhook(OptionsTypes.CATCH_ERROR, (old, error, vnode, oldVNode) => {\n\tif (DEVTOOLS_ENABLED) {\n\t\twindow.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();\n\t}\n\n\tsetCurrentUpdater();\n\tcurrentComponent = undefined;\n\told(error, vnode, oldVNode);\n});\n\n/** Finish current updater after rendering any VNode */\nhook(OptionsTypes.DIFFED, (old, vnode) => {\n\tif (DEVTOOLS_ENABLED && typeof vnode.type === \"function\") {\n\t\twindow.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();\n\t}\n\n\tsetCurrentUpdater();\n\tcurrentComponent = undefined;\n\n\tlet dom: Element;\n\n\t// vnode._dom is undefined during string rendering,\n\t// so we use this to skip prop subscriptions during SSR.\n\tif (typeof vnode.type === \"string\" && (dom = vnode.__e as Element)) {\n\t\tlet props = vnode.__np;\n\t\tlet renderedProps = vnode.props;\n\t\tif (props) {\n\t\t\tlet updaters = dom._updaters;\n\t\t\tif (updaters) {\n\t\t\t\tfor (let prop in updaters) {\n\t\t\t\t\tlet updater = updaters[prop];\n\t\t\t\t\tif (updater !== undefined && !(prop in props)) {\n\t\t\t\t\t\tupdater._dispose();\n\t\t\t\t\t\t// @todo we could just always invoke _dispose() here\n\t\t\t\t\t\tupdaters[prop] = undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tupdaters = {};\n\t\t\t\tdom._updaters = updaters;\n\t\t\t}\n\t\t\tfor (let prop in props) {\n\t\t\t\tlet updater = updaters[prop];\n\t\t\t\tlet signal = props[prop];\n\t\t\t\tif (updater === undefined) {\n\t\t\t\t\tupdater = createPropUpdater(dom, prop, signal, renderedProps);\n\t\t\t\t\tupdaters[prop] = updater;\n\t\t\t\t} else {\n\t\t\t\t\tupdater._update(signal, renderedProps);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\told(vnode);\n});\n\nfunction createPropUpdater(\n\tdom: Element,\n\tprop: string,\n\tpropSignal: Signal,\n\tprops: Record<string, any>\n): PropertyUpdater {\n\tconst setAsProperty =\n\t\tprop in dom &&\n\t\t// SVG elements need to go through `setAttribute` because they\n\t\t// expect things like SVGAnimatedTransformList instead of strings.\n\t\t// @ts-ignore\n\t\tdom.ownerSVGElement === undefined;\n\n\tconst changeSignal = signal(propSignal);\n\treturn {\n\t\t_update: (newSignal: Signal, newProps: typeof props) => {\n\t\t\tchangeSignal.value = newSignal;\n\t\t\tprops = newProps;\n\t\t},\n\t\t_dispose: effect(function (this: Effect) {\n\t\t\tthis._notify = notifyDomUpdates;\n\t\t\tconst value = changeSignal.value.value;\n\t\t\t// If Preact just rendered this value, don't render it again:\n\t\t\tif (props[prop] === value) return;\n\t\t\tprops[prop] = value;\n\t\t\tif (setAsProperty) {\n\t\t\t\t// @ts-ignore-next-line silly\n\t\t\t\tdom[prop] = value;\n\t\t\t\t// Match Preact's attribute handling: data-* and aria-* attributes\n\t\t\t\t// https://github.com/preactjs/preact/blob/main/src/diff/props.js#L132\n\t\t\t} else if (value != null && (value !== false || prop[4] === \"-\")) {\n\t\t\t\tdom.setAttribute(prop, value);\n\t\t\t} else {\n\t\t\t\tdom.removeAttribute(prop);\n\t\t\t}\n\t\t}),\n\t};\n}\n\n/** Unsubscribe from Signals when unmounting components/vnodes */\nhook(OptionsTypes.UNMOUNT, (old, vnode: VNode) => {\n\tif (typeof vnode.type === \"string\") {\n\t\tlet dom = vnode.__e as Element | undefined;\n\t\t// vnode._dom is undefined during string rendering\n\t\tif (dom) {\n\t\t\tconst updaters = dom._updaters;\n\t\t\tif (updaters) {\n\t\t\t\tdom._updaters = undefined;\n\t\t\t\tfor (let prop in updaters) {\n\t\t\t\t\tlet updater = updaters[prop];\n\t\t\t\t\tif (updater) updater._dispose();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tlet component = vnode.__c;\n\t\tif (component) {\n\t\t\tconst updater = component._updater;\n\t\t\tif (updater) {\n\t\t\t\tcomponent._updater = undefined;\n\t\t\t\tupdater._dispose();\n\t\t\t}\n\t\t}\n\t}\n\told(vnode);\n});\n\n/** Mark components that use hook state so we can skip sCU optimization. */\nhook(OptionsTypes.HOOK, (old, component, index, type) => {\n\tif (type < 3 || type === 9)\n\t\t(component as AugmentedComponent)._updateFlags |= HAS_HOOK_STATE;\n\told(component, index, type);\n});\n\n/**\n * Auto-memoize components that use Signals/Computeds.\n * Note: Does _not_ optimize components that use hook/class state.\n */\nComponent.prototype.shouldComponentUpdate = function (\n\tthis: AugmentedComponent,\n\tprops,\n\tstate\n) {\n\t// @todo: Once preactjs/preact#3671 lands, this could just use `currentUpdater`:\n\tconst updater = this._updater;\n\tconst hasSignals = updater && updater._sources !== undefined;\n\n\t// If this is a component using state, rerender\n\t// @ts-ignore\n\tfor (let i in state) return true;\n\n\tif (this.__f || (typeof this.u == \"boolean\" && this.u === true)) {\n\t\tconst hasHooksState = this._updateFlags & HAS_HOOK_STATE;\n\t\t// if this component used no signals or computeds and no hooks state, update:\n\t\tif (!hasSignals && !hasHooksState && !(this._updateFlags & HAS_COMPUTEDS))\n\t\t\treturn true;\n\n\t\t// if there is a pending re-render triggered from Signals,\n\t\t// or if there is hooks state, update:\n\t\tif (this._updateFlags & HAS_PENDING_UPDATE) return true;\n\t} else {\n\t\t// if this component used no signals or computeds, update:\n\t\tif (!hasSignals && !(this._updateFlags & HAS_COMPUTEDS)) return true;\n\n\t\t// if there is a pending re-render triggered from Signals,\n\t\t// or if there is hooks state, update:\n\t\tif (this._updateFlags & (HAS_PENDING_UPDATE | HAS_HOOK_STATE)) return true;\n\t}\n\n\t// if any non-Signal props changed, update:\n\tfor (let i in props) {\n\t\tif (i !== \"__source\" && props[i] !== this.props[i]) return true;\n\t}\n\tfor (let i in this.props) if (!(i in props)) return true;\n\n\t// this is a purely Signal-driven component, don't update:\n\treturn false;\n};\n\nexport function useSignal<T>(value: T, options?: SignalOptions<T>): Signal<T>;\nexport function useSignal<T = undefined>(): Signal<T | undefined>;\nexport function useSignal<T>(value?: T, options?: SignalOptions<T>) {\n\treturn useState(() =>\n\t\tsignal<T | undefined>(value, options as SignalOptions)\n\t)[0];\n}\n\nexport function useComputed<T>(compute: () => T, options?: SignalOptions<T>) {\n\tconst $compute = useRef(compute);\n\t$compute.current = compute;\n\t(currentComponent as AugmentedComponent)._updateFlags |= HAS_COMPUTEDS;\n\treturn useMemo(() => computed<T>(() => $compute.current(), options), []);\n}\n\nfunction safeRaf(callback: () => void) {\n\tconst done = () => {\n\t\tclearTimeout(timeout);\n\t\tcancelAnimationFrame(raf);\n\t\tcallback();\n\t};\n\n\tconst timeout = setTimeout(done, 35);\n\tconst raf = requestAnimationFrame(done);\n}\n\nconst deferEffects =\n\ttypeof requestAnimationFrame === \"undefined\" ? setTimeout : safeRaf;\n\nconst deferDomUpdates = (cb: any) => {\n\tqueueMicrotask(() => {\n\t\tqueueMicrotask(cb);\n\t});\n};\n\nfunction flushEffects() {\n\tbatch(() => {\n\t\tlet inst: Effect | undefined;\n\t\twhile ((inst = effectsQueue.shift())) {\n\t\t\toldNotify.call(inst);\n\t\t}\n\t});\n}\n\nfunction notifyEffects(this: Effect) {\n\tif (effectsQueue.push(this) === 1) {\n\t\t(options.requestAnimationFrame || deferEffects)(flushEffects);\n\t}\n}\n\nfunction flushDomUpdates() {\n\tbatch(() => {\n\t\tlet inst: Effect | undefined;\n\t\twhile ((inst = domQueue.shift())) {\n\t\t\toldNotify.call(inst);\n\t\t}\n\t});\n}\n\nfunction notifyDomUpdates(this: Effect) {\n\tif (domQueue.push(this) === 1) {\n\t\t(options.requestAnimationFrame || deferDomUpdates)(flushDomUpdates);\n\t}\n}\n\nexport function useSignalEffect(\n\tcb: () => void | (() => void),\n\toptions?: EffectOptions\n) {\n\tconst callback = useRef(cb);\n\tcallback.current = cb;\n\n\tuseEffect(() => {\n\t\treturn effect(function (this: Effect) {\n\t\t\tthis._notify = notifyEffects;\n\t\t\treturn callback.current();\n\t\t}, options);\n\t}, []);\n}\n\n/**\n * @todo Determine which Reactive implementation we'll be using.\n * @internal\n */\n// export function useReactive<T extends object>(value: T): Reactive<T> {\n// \treturn useMemo(() => reactive<T>(value), []);\n// }\n\n/**\n * @internal\n * Update a Reactive's using the properties of an object or other Reactive.\n * Also works for Signals.\n * @example\n * // Update a Reactive with Object.assign()-like syntax:\n * const r = reactive({ name: \"Alice\" });\n * update(r, { name: \"Bob\" });\n * update(r, { age: 42 }); // property 'age' does not exist in type '{ name?: string }'\n * update(r, 2); // '2' has no properties in common with '{ name?: string }'\n * console.log(r.name.value); // \"Bob\"\n *\n * @example\n * // Update a Reactive with the properties of another Reactive:\n * const A = reactive({ name: \"Alice\" });\n * const B = reactive({ name: \"Bob\", age: 42 });\n * update(A, B);\n * console.log(`${A.name} is ${A.age}`); // \"Bob is 42\"\n *\n * @example\n * // Update a signal with assign()-like syntax:\n * const s = signal(42);\n * update(s, \"hi\"); // Argument type 'string' not assignable to type 'number'\n * update(s, {}); // Argument type '{}' not assignable to type 'number'\n * update(s, 43);\n * console.log(s.value); // 43\n *\n * @param obj The Reactive or Signal to be updated\n * @param update The value, Signal, object or Reactive to update `obj` to match\n * @param overwrite If `true`, any properties `obj` missing from `update` are set to `undefined`\n */\n/*\nexport function update<T extends SignalOrReactive>(\n\tobj: T,\n\tupdate: Partial<Unwrap<T>>,\n\toverwrite = false\n) {\n\tif (obj instanceof Signal) {\n\t\tobj.value = peekValue(update);\n\t} else {\n\t\tfor (let i in update) {\n\t\t\tif (i in obj) {\n\t\t\t\tobj[i].value = peekValue(update[i]);\n\t\t\t} else {\n\t\t\t\tlet sig = signal(peekValue(update[i]));\n\t\t\t\tsig[KEY] = i;\n\t\t\t\tobj[i] = sig;\n\t\t\t}\n\t\t}\n\t\tif (overwrite) {\n\t\t\tfor (let i in obj) {\n\t\t\t\tif (!(i in update)) {\n\t\t\t\t\tobj[i].value = undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n*/\n"],"names":["oldNotify","currentComponent","finishUpdate","DEVTOOLS_ENABLED","window","__PREACT_SIGNALS_DEVTOOLS__","effectsQueue","domQueue","effect","this","_notify","hook","hookName","hookFn","options","bind","setCurrentUpdater","updater","_start","SignalValue","_ref","_this","data","currentSignal","useSignal","value","_useMemo","useMemo","self","v","__v","__","__c","_updateFlags","wrappedSignal","computed","s","isText","Array","isArray","isValidElement","dispose","notifyDomUpdates","__e","nodeType","oldDispose","_updater","_dispose","call","peek","displayName","Object","defineProperties","Signal","prototype","constructor","configurable","undefined","type","props","get","__b","old","vnode","exitComponent","signalProps","i","__np","enterComponent","Fragment","component","update","_callback","setState","createUpdater","error","oldVNode","dom","renderedProps","updaters","_updaters","prop","signal","createPropUpdater","_update","propSignal","setAsProperty","ownerSVGElement","changeSignal","newSignal","newProps","setAttribute","removeAttribute","index","Component","shouldComponentUpdate","state","hasSignals","_sources","__f","u","hasHooksState","useState","deferEffects","requestAnimationFrame","setTimeout","callback","done","clearTimeout","timeout","cancelAnimationFrame","raf","deferDomUpdates","cb","queueMicrotask","flushEffects","batch","inst","shift","notifyEffects","push","flushDomUpdates","exports","signalsCore","untracked","useComputed","compute","$compute","useRef","current","useSignalEffect","useEffect"],"mappings":"iZAiCA,IAOIA,EAiBAC,EACAC,EAzBEC,EACa,oBAAXC,UAA4BA,OAAO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AAAwC,EAAAE,UAAAD,EAAAC,UAAAF,EAAAG,YAtEgB,SAAeC,EAAkBhH,GAChD,IAAMiH,EAAWC,SAAOF,GACxBC,EAASE,QAAUH,EAClB7H,EAAwCgC,MA7XpB,EA8XrB,OAAON,EAAOA,QAAC,WAAA,OAAMQ,EAAQA,SAAI,WAAM,OAAA4F,EAASE,SAAS,EAAEnH,EAAQ,EAAE,GACtE,EAiEA4G,EAAAlG,UAAAA,UAAAkG,EAAAQ,gBAbgB,SACfjB,EACAnG,GAEA,IAAM4F,EAAWsB,EAAAA,OAAOf,GACxBP,EAASuB,QAAUhB,EAEnBkB,EAAAA,UAAU,WACT,OAAO3H,EAAAA,OAAO,WACbC,KAAKC,EAAU6G,EACf,OAAOb,EAASuB,SACjB,EAAGnH,EACJ,EAAG,GACJ,CAAA"}
1
+ {"version":3,"file":"signals.min.js","sources":["../src/index.ts"],"sourcesContent":["import { options, Component, isValidElement, Fragment } from \"preact\";\nimport { useRef, useMemo, useEffect, useState } from \"preact/hooks\";\nimport {\n\tsignal,\n\tcomputed,\n\tbatch,\n\teffect,\n\tSignal,\n\ttype ReadonlySignal,\n\tuntracked,\n\tSignalOptions,\n\tEffectOptions,\n} from \"@preact/signals-core\";\nimport {\n\tVNode,\n\tOptionsTypes,\n\tHookFn,\n\tEffect,\n\tPropertyUpdater,\n\tAugmentedComponent,\n\tAugmentedElement as Element,\n} from \"./internal\";\n\nexport {\n\tsignal,\n\tcomputed,\n\tbatch,\n\teffect,\n\tSignal,\n\ttype ReadonlySignal,\n\tuntracked,\n};\n\nconst DEVTOOLS_ENABLED =\n\ttypeof window !== \"undefined\" && !!window.__PREACT_SIGNALS_DEVTOOLS__;\n\nconst HAS_PENDING_UPDATE = 1 << 0;\nconst HAS_HOOK_STATE = 1 << 1;\nconst HAS_COMPUTEDS = 1 << 2;\n\nlet oldNotify: (this: Effect) => void,\n\teffectsQueue: Array<Effect> = [],\n\tdomQueue: Array<Effect> = [];\n\n// Capture the original `Effect.prototype._notify` method so that we can install\n// custom `._notify`s for each different use-case but still call the original\n// implementation in the end. Dispose the temporary effect immediately afterwards.\neffect(function (this: Effect) {\n\toldNotify = this._notify;\n})();\n\n// Install a Preact options hook\nfunction hook<T extends OptionsTypes>(hookName: T, hookFn: HookFn<T>) {\n\t// @ts-ignore-next-line private options hooks usage\n\toptions[hookName] = hookFn.bind(null, options[hookName] || (() => {}));\n}\n\nlet currentComponent: AugmentedComponent | undefined;\nlet finishUpdate: (() => void) | undefined;\n\nfunction setCurrentUpdater(updater?: Effect) {\n\t// end tracking for the current update:\n\tif (finishUpdate) finishUpdate();\n\t// start tracking the new update:\n\tfinishUpdate = updater && updater._start();\n}\n\nfunction createUpdater(update: () => void, name: string) {\n\tlet updater!: Effect;\n\teffect(\n\t\tfunction (this: Effect) {\n\t\t\tupdater = this;\n\t\t},\n\t\t{ name }\n\t);\n\tupdater._callback = update;\n\treturn updater;\n}\n\n/** @todo This may be needed for complex prop value detection. */\n// function isSignalValue(value: any): value is Signal {\n// \tif (typeof value !== \"object\" || value == null) return false;\n// \tif (value instanceof Signal) return true;\n// \t// @TODO: uncomment this when we land Reactive (ideally behind a brand check)\n// \t// for (let i in value) if (value[i] instanceof Signal) return true;\n// \treturn false;\n// }\n\n/**\n * A wrapper component that renders a Signal directly as a Text node.\n * @todo: in Preact 11, just decorate Signal with `type:null`\n */\nfunction SignalValue(this: AugmentedComponent, { data }: { data: Signal }) {\n\t// hasComputeds.add(this);\n\n\t// Store the props.data signal in another signal so that\n\t// passing a new signal reference re-runs the text computed:\n\tconst currentSignal = useSignal(data);\n\tcurrentSignal.value = data;\n\n\tconst [isText, s] = useMemo(() => {\n\t\tlet self = this;\n\t\t// mark the parent component as having computeds so it gets optimized\n\t\tlet v = this.__v;\n\t\twhile ((v = v.__!)) {\n\t\t\tif (v.__c) {\n\t\t\t\tv.__c._updateFlags |= HAS_COMPUTEDS;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tconst wrappedSignal = computed(() => {\n\t\t\tlet s = currentSignal.value.value;\n\t\t\treturn s === 0 ? 0 : s === true ? \"\" : s || \"\";\n\t\t});\n\n\t\tconst isText = computed(\n\t\t\t() =>\n\t\t\t\t!Array.isArray(wrappedSignal.value) &&\n\t\t\t\t!isValidElement(wrappedSignal.value)\n\t\t);\n\t\t// Update text nodes directly without rerendering when the new value\n\t\t// is also text.\n\t\tconst dispose = effect(function (this: Effect) {\n\t\t\tthis._notify = notifyDomUpdates;\n\n\t\t\t// Subscribe to wrappedSignal updates only when its values are text...\n\t\t\tif (isText.value) {\n\t\t\t\t// ...but regardless of `self.base`'s current value, as it can be\n\t\t\t\t// undefined before mounting or a non-text node. In both of those cases\n\t\t\t\t// the update gets handled by a full rerender.\n\t\t\t\tconst value = wrappedSignal.value;\n\t\t\t\tif (self.__v && self.__v.__e && self.__v.__e.nodeType === 3) {\n\t\t\t\t\t(self.__v.__e as Text).data = value;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// Piggyback this._updater's disposal to ensure that the text updater effect\n\t\t// above also gets disposed on unmount.\n\t\tconst oldDispose = this._updater!._dispose;\n\t\tthis._updater!._dispose = function () {\n\t\t\tdispose();\n\t\t\toldDispose.call(this);\n\t\t};\n\n\t\treturn [isText, wrappedSignal];\n\t}, []);\n\n\t// Rerender the component whenever `data.value` changes from a VNode\n\t// to another VNode, from text to a VNode, or from a VNode to text.\n\t// That is, everything else except text-to-text updates.\n\t//\n\t// This also ensures that the backing DOM node types gets updated to\n\t// text nodes and back when needed.\n\t//\n\t// For text-to-text updates, `.peek()` is used to skip full rerenders,\n\t// leaving them to the optimized path above.\n\treturn isText.value ? s.peek() : s.value;\n}\n\nSignalValue.displayName = \"ReactiveTextNode\";\n\nObject.defineProperties(Signal.prototype, {\n\tconstructor: { configurable: true, value: undefined },\n\ttype: { configurable: true, value: SignalValue },\n\tprops: {\n\t\tconfigurable: true,\n\t\tget() {\n\t\t\treturn { data: this };\n\t\t},\n\t},\n\t// Setting a VNode's _depth to 1 forces Preact to clone it before modifying:\n\t// https://github.com/preactjs/preact/blob/d7a433ee8463a7dc23a05111bb47de9ec729ad4d/src/diff/children.js#L77\n\t// @todo remove this for Preact 11\n\t__b: { configurable: true, value: 1 },\n});\n\n/** Inject low-level property/attribute bindings for Signals into Preact's diff */\nhook(OptionsTypes.DIFF, (old, vnode) => {\n\tif (typeof vnode.type === \"string\") {\n\t\tlet signalProps: Record<string, any> | undefined;\n\n\t\tlet props = vnode.props;\n\t\tfor (let i in props) {\n\t\t\tif (i === \"children\") continue;\n\n\t\t\tlet value = props[i];\n\t\t\tif (value instanceof Signal) {\n\t\t\t\tif (!signalProps) vnode.__np = signalProps = {};\n\t\t\t\tsignalProps[i] = value;\n\t\t\t\tprops[i] = value.peek();\n\t\t\t}\n\t\t}\n\t}\n\n\told(vnode);\n});\n\n/** Set up Updater before rendering a component */\nhook(OptionsTypes.RENDER, (old, vnode) => {\n\t// Ignore the Fragment inserted by preact.createElement().\n\tif (vnode.type !== Fragment) {\n\t\tsetCurrentUpdater();\n\n\t\tlet updater: Effect | undefined;\n\n\t\tlet component = vnode.__c;\n\t\tif (component) {\n\t\t\tcomponent._updateFlags &= ~HAS_PENDING_UPDATE;\n\n\t\t\tupdater = component._updater;\n\t\t\tif (updater === undefined) {\n\t\t\t\tcomponent._updater = updater = createUpdater(\n\t\t\t\t\t() => {\n\t\t\t\t\t\tif (DEVTOOLS_ENABLED) updater!._debugCallback?.call(updater);\n\t\t\t\t\t\tcomponent._updateFlags |= HAS_PENDING_UPDATE;\n\t\t\t\t\t\tcomponent.setState({});\n\t\t\t\t\t},\n\t\t\t\t\ttypeof vnode.type === \"function\"\n\t\t\t\t\t\t? vnode.type.displayName || vnode.type.name\n\t\t\t\t\t\t: \"\"\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tcurrentComponent = component;\n\t\tsetCurrentUpdater(updater);\n\t}\n\n\told(vnode);\n});\n\n/** Finish current updater if a component errors */\nhook(OptionsTypes.CATCH_ERROR, (old, error, vnode, oldVNode) => {\n\tsetCurrentUpdater();\n\tcurrentComponent = undefined;\n\told(error, vnode, oldVNode);\n});\n\n/** Finish current updater after rendering any VNode */\nhook(OptionsTypes.DIFFED, (old, vnode) => {\n\tsetCurrentUpdater();\n\tcurrentComponent = undefined;\n\n\tlet dom: Element;\n\n\t// vnode._dom is undefined during string rendering,\n\t// so we use this to skip prop subscriptions during SSR.\n\tif (typeof vnode.type === \"string\" && (dom = vnode.__e as Element)) {\n\t\tlet props = vnode.__np;\n\t\tlet renderedProps = vnode.props;\n\t\tif (props) {\n\t\t\tlet updaters = dom._updaters;\n\t\t\tif (updaters) {\n\t\t\t\tfor (let prop in updaters) {\n\t\t\t\t\tlet updater = updaters[prop];\n\t\t\t\t\tif (updater !== undefined && !(prop in props)) {\n\t\t\t\t\t\tupdater._dispose();\n\t\t\t\t\t\t// @todo we could just always invoke _dispose() here\n\t\t\t\t\t\tupdaters[prop] = undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tupdaters = {};\n\t\t\t\tdom._updaters = updaters;\n\t\t\t}\n\t\t\tfor (let prop in props) {\n\t\t\t\tlet updater = updaters[prop];\n\t\t\t\tlet signal = props[prop];\n\t\t\t\tif (updater === undefined) {\n\t\t\t\t\tupdater = createPropUpdater(dom, prop, signal, renderedProps);\n\t\t\t\t\tupdaters[prop] = updater;\n\t\t\t\t} else {\n\t\t\t\t\tupdater._update(signal, renderedProps);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\told(vnode);\n});\n\nfunction createPropUpdater(\n\tdom: Element,\n\tprop: string,\n\tpropSignal: Signal,\n\tprops: Record<string, any>\n): PropertyUpdater {\n\tconst setAsProperty =\n\t\tprop in dom &&\n\t\t// SVG elements need to go through `setAttribute` because they\n\t\t// expect things like SVGAnimatedTransformList instead of strings.\n\t\t// @ts-ignore\n\t\tdom.ownerSVGElement === undefined;\n\n\tconst changeSignal = signal(propSignal);\n\treturn {\n\t\t_update: (newSignal: Signal, newProps: typeof props) => {\n\t\t\tchangeSignal.value = newSignal;\n\t\t\tprops = newProps;\n\t\t},\n\t\t_dispose: effect(function (this: Effect) {\n\t\t\tthis._notify = notifyDomUpdates;\n\t\t\tconst value = changeSignal.value.value;\n\t\t\t// If Preact just rendered this value, don't render it again:\n\t\t\tif (props[prop] === value) return;\n\t\t\tprops[prop] = value;\n\t\t\tif (setAsProperty) {\n\t\t\t\t// @ts-ignore-next-line silly\n\t\t\t\tdom[prop] = value;\n\t\t\t\t// Match Preact's attribute handling: data-* and aria-* attributes\n\t\t\t\t// https://github.com/preactjs/preact/blob/main/src/diff/props.js#L132\n\t\t\t} else if (value != null && (value !== false || prop[4] === \"-\")) {\n\t\t\t\tdom.setAttribute(prop, value);\n\t\t\t} else {\n\t\t\t\tdom.removeAttribute(prop);\n\t\t\t}\n\t\t}),\n\t};\n}\n\n/** Unsubscribe from Signals when unmounting components/vnodes */\nhook(OptionsTypes.UNMOUNT, (old, vnode: VNode) => {\n\tif (typeof vnode.type === \"string\") {\n\t\tlet dom = vnode.__e as Element | undefined;\n\t\t// vnode._dom is undefined during string rendering\n\t\tif (dom) {\n\t\t\tconst updaters = dom._updaters;\n\t\t\tif (updaters) {\n\t\t\t\tdom._updaters = undefined;\n\t\t\t\tfor (let prop in updaters) {\n\t\t\t\t\tlet updater = updaters[prop];\n\t\t\t\t\tif (updater) updater._dispose();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tlet component = vnode.__c;\n\t\tif (component) {\n\t\t\tconst updater = component._updater;\n\t\t\tif (updater) {\n\t\t\t\tcomponent._updater = undefined;\n\t\t\t\tupdater._dispose();\n\t\t\t}\n\t\t}\n\t}\n\told(vnode);\n});\n\n/** Mark components that use hook state so we can skip sCU optimization. */\nhook(OptionsTypes.HOOK, (old, component, index, type) => {\n\tif (type < 3 || type === 9)\n\t\t(component as AugmentedComponent)._updateFlags |= HAS_HOOK_STATE;\n\told(component, index, type);\n});\n\n/**\n * Auto-memoize components that use Signals/Computeds.\n * Note: Does _not_ optimize components that use hook/class state.\n */\nComponent.prototype.shouldComponentUpdate = function (\n\tthis: AugmentedComponent,\n\tprops,\n\tstate\n) {\n\t// @todo: Once preactjs/preact#3671 lands, this could just use `currentUpdater`:\n\tconst updater = this._updater;\n\tconst hasSignals = updater && updater._sources !== undefined;\n\n\t// If this is a component using state, rerender\n\t// @ts-ignore\n\tfor (let i in state) return true;\n\n\tif (this.__f || (typeof this.u == \"boolean\" && this.u === true)) {\n\t\tconst hasHooksState = this._updateFlags & HAS_HOOK_STATE;\n\t\t// if this component used no signals or computeds and no hooks state, update:\n\t\tif (!hasSignals && !hasHooksState && !(this._updateFlags & HAS_COMPUTEDS))\n\t\t\treturn true;\n\n\t\t// if there is a pending re-render triggered from Signals,\n\t\t// or if there is hooks state, update:\n\t\tif (this._updateFlags & HAS_PENDING_UPDATE) return true;\n\t} else {\n\t\t// if this component used no signals or computeds, update:\n\t\tif (!hasSignals && !(this._updateFlags & HAS_COMPUTEDS)) return true;\n\n\t\t// if there is a pending re-render triggered from Signals,\n\t\t// or if there is hooks state, update:\n\t\tif (this._updateFlags & (HAS_PENDING_UPDATE | HAS_HOOK_STATE)) return true;\n\t}\n\n\t// if any non-Signal props changed, update:\n\tfor (let i in props) {\n\t\tif (i !== \"__source\" && props[i] !== this.props[i]) return true;\n\t}\n\tfor (let i in this.props) if (!(i in props)) return true;\n\n\t// this is a purely Signal-driven component, don't update:\n\treturn false;\n};\n\nexport function useSignal<T>(value: T, options?: SignalOptions<T>): Signal<T>;\nexport function useSignal<T = undefined>(): Signal<T | undefined>;\nexport function useSignal<T>(value?: T, options?: SignalOptions<T>) {\n\treturn useState(() =>\n\t\tsignal<T | undefined>(value, options as SignalOptions)\n\t)[0];\n}\n\nexport function useComputed<T>(compute: () => T, options?: SignalOptions<T>) {\n\tconst $compute = useRef(compute);\n\t$compute.current = compute;\n\t(currentComponent as AugmentedComponent)._updateFlags |= HAS_COMPUTEDS;\n\treturn useMemo(() => computed<T>(() => $compute.current(), options), []);\n}\n\nfunction safeRaf(callback: () => void) {\n\tconst done = () => {\n\t\tclearTimeout(timeout);\n\t\tcancelAnimationFrame(raf);\n\t\tcallback();\n\t};\n\n\tconst timeout = setTimeout(done, 35);\n\tconst raf = requestAnimationFrame(done);\n}\n\nconst deferEffects =\n\ttypeof requestAnimationFrame === \"undefined\" ? setTimeout : safeRaf;\n\nconst deferDomUpdates = (cb: any) => {\n\tqueueMicrotask(() => {\n\t\tqueueMicrotask(cb);\n\t});\n};\n\nfunction flushEffects() {\n\tbatch(() => {\n\t\tlet inst: Effect | undefined;\n\t\twhile ((inst = effectsQueue.shift())) {\n\t\t\toldNotify.call(inst);\n\t\t}\n\t});\n}\n\nfunction notifyEffects(this: Effect) {\n\tif (effectsQueue.push(this) === 1) {\n\t\t(options.requestAnimationFrame || deferEffects)(flushEffects);\n\t}\n}\n\nfunction flushDomUpdates() {\n\tbatch(() => {\n\t\tlet inst: Effect | undefined;\n\t\twhile ((inst = domQueue.shift())) {\n\t\t\toldNotify.call(inst);\n\t\t}\n\t});\n}\n\nfunction notifyDomUpdates(this: Effect) {\n\tif (domQueue.push(this) === 1) {\n\t\t(options.requestAnimationFrame || deferDomUpdates)(flushDomUpdates);\n\t}\n}\n\nexport function useSignalEffect(\n\tcb: () => void | (() => void),\n\toptions?: EffectOptions\n) {\n\tconst callback = useRef(cb);\n\tcallback.current = cb;\n\n\tuseEffect(() => {\n\t\treturn effect(function (this: Effect) {\n\t\t\tthis._notify = notifyEffects;\n\t\t\treturn callback.current();\n\t\t}, options);\n\t}, []);\n}\n\n/**\n * @todo Determine which Reactive implementation we'll be using.\n * @internal\n */\n// export function useReactive<T extends object>(value: T): Reactive<T> {\n// \treturn useMemo(() => reactive<T>(value), []);\n// }\n\n/**\n * @internal\n * Update a Reactive's using the properties of an object or other Reactive.\n * Also works for Signals.\n * @example\n * // Update a Reactive with Object.assign()-like syntax:\n * const r = reactive({ name: \"Alice\" });\n * update(r, { name: \"Bob\" });\n * update(r, { age: 42 }); // property 'age' does not exist in type '{ name?: string }'\n * update(r, 2); // '2' has no properties in common with '{ name?: string }'\n * console.log(r.name.value); // \"Bob\"\n *\n * @example\n * // Update a Reactive with the properties of another Reactive:\n * const A = reactive({ name: \"Alice\" });\n * const B = reactive({ name: \"Bob\", age: 42 });\n * update(A, B);\n * console.log(`${A.name} is ${A.age}`); // \"Bob is 42\"\n *\n * @example\n * // Update a signal with assign()-like syntax:\n * const s = signal(42);\n * update(s, \"hi\"); // Argument type 'string' not assignable to type 'number'\n * update(s, {}); // Argument type '{}' not assignable to type 'number'\n * update(s, 43);\n * console.log(s.value); // 43\n *\n * @param obj The Reactive or Signal to be updated\n * @param update The value, Signal, object or Reactive to update `obj` to match\n * @param overwrite If `true`, any properties `obj` missing from `update` are set to `undefined`\n */\n/*\nexport function update<T extends SignalOrReactive>(\n\tobj: T,\n\tupdate: Partial<Unwrap<T>>,\n\toverwrite = false\n) {\n\tif (obj instanceof Signal) {\n\t\tobj.value = peekValue(update);\n\t} else {\n\t\tfor (let i in update) {\n\t\t\tif (i in obj) {\n\t\t\t\tobj[i].value = peekValue(update[i]);\n\t\t\t} else {\n\t\t\t\tlet sig = signal(peekValue(update[i]));\n\t\t\t\tsig[KEY] = i;\n\t\t\t\tobj[i] = sig;\n\t\t\t}\n\t\t}\n\t\tif (overwrite) {\n\t\t\tfor (let i in obj) {\n\t\t\t\tif (!(i in update)) {\n\t\t\t\t\tobj[i].value = undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n*/\n"],"names":["oldNotify","currentComponent","finishUpdate","DEVTOOLS_ENABLED","window","__PREACT_SIGNALS_DEVTOOLS__","effectsQueue","domQueue","effect","this","_notify","hook","hookName","hookFn","options","bind","setCurrentUpdater","updater","_start","SignalValue","_ref","_this","data","currentSignal","useSignal","value","_useMemo","useMemo","self","v","__v","__","__c","_updateFlags","wrappedSignal","computed","s","isText","Array","isArray","isValidElement","dispose","notifyDomUpdates","__e","nodeType","oldDispose","_updater","_dispose","call","peek","displayName","Object","defineProperties","Signal","prototype","constructor","configurable","undefined","type","props","get","__b","old","vnode","signalProps","i","__np","Fragment","component","update","name","_callback","createUpdater","_updater$_debugCallba","_debugCallback","setState","error","oldVNode","dom","renderedProps","updaters","_updaters","prop","signal","createPropUpdater","_update","propSignal","setAsProperty","ownerSVGElement","changeSignal","newSignal","newProps","setAttribute","removeAttribute","index","Component","shouldComponentUpdate","state","hasSignals","_sources","__f","u","hasHooksState","useState","deferEffects","requestAnimationFrame","setTimeout","callback","done","clearTimeout","timeout","cancelAnimationFrame","raf","deferDomUpdates","cb","queueMicrotask","flushEffects","batch","inst","shift","notifyEffects","push","flushDomUpdates","exports","signalsCore","untracked","useComputed","compute","$compute","useRef","current","useSignalEffect","useEffect"],"mappings":"iZAiCA,IAOIA,EAiBAC,EACAC,EAzBEC,EACa,oBAAXC,UAA4BA,OAAOC,4BAO1CC,EAA8B,GAC9BC,EAA0B,GAK3BC,SAAO,WACNR,EAAYS,KAAKC,CAClB,EAFAF,GAKA,SAASG,EAA6BC,EAAaC,GAElDC,EAAOA,QAACF,GAAYC,EAAOE,KAAK,KAAMD,EAAOA,QAACF,IAAc,WAAS,EACtE,CAKA,SAASI,EAAkBC,GAE1B,GAAIf,EAAcA,IAElBA,EAAee,GAAWA,EAAQC,GACnC,CA2BA,SAASC,EAAWC,GAAqD,IAAAC,EAAAZ,KAAxBa,EAAIF,EAAJE,KAK1CC,EAAgBC,UAAUF,GAChCC,EAAcE,MAAQH,EAEtB,IAAAI,EAAoBC,EAAAA,QAAQ,WAC3B,IAAIC,EAAOP,EAEPQ,EAAIR,EAAKS,IACb,MAAQD,EAAIA,EAAEE,GACb,GAAIF,EAAEG,IAAK,CACVH,EAAEG,IAAIC,MApEY,EAqElB,KACD,CAGD,IAAMC,EAAgBC,WAAS,WAC9B,IAAIC,EAAIb,EAAcE,MAAMA,MAC5B,OAAa,IAANW,EAAU,GAAU,IAANA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,MAAQA,EAAOhH,EAAaiH,QAC3BvH,EAAUgD,KAAKsE,EAEjB,EACD,CAEA,SAASE,IACR,GAAgC,IAA5BlH,EAAamH,KAAKhH,OACpBK,EAAAA,QAAQ2F,uBAAyBD,GAAcY,EAElD,CAEA,SAASM,IACRL,QAAM,WACL,IAAIC,EACJ,MAAQA,EAAO/G,EAASgH,QACvBvH,EAAUgD,KAAKsE,EAEjB,EACD,CAEA,SAAS5E,IACR,GAA4B,IAAxBnC,EAASkH,KAAKhH,OAChBK,EAAOA,QAAC2F,uBAAyBQ,GAAiBS,EAErD,CAeAC,EAAAtE,OAAAuE,EAAAvE,OAAAsE,EAAAN,MAAAO,EAAAP,MAAAM,EAAAxF,SAAAyF,EAAAzF,SAAAwF,EAAAnH,OAAAoH,EAAApH,OAAAmH,EAAAxC,OAAAyC,EAAAzC,OAAAwC,EAAAE,UAAAD,EAAAC,UAAAF,EAAAG,YAtEgB,SAAeC,EAAkBjH,GAChD,IAAMkH,EAAWC,EAAMA,OAACF,GACxBC,EAASE,QAAUH,EAClB9H,EAAwCgC,MAtXpB,EAuXrB,OAAON,EAAOA,QAAC,WAAM,OAAAQ,EAAQA,SAAI,WAAM,OAAA6F,EAASE,SAAS,EAAEpH,EAAQ,EAAE,GACtE,EAiEA6G,EAAAnG,UAAAA,UAAAmG,EAAAQ,gBAbgB,SACfjB,EACApG,GAEA,IAAM6F,EAAWsB,EAAAA,OAAOf,GACxBP,EAASuB,QAAUhB,EAEnBkB,EAAAA,UAAU,WACT,OAAO5H,EAAAA,OAAO,WACbC,KAAKC,EAAU8G,EACf,OAAOb,EAASuB,SACjB,EAAGpH,EACJ,EAAG,GACJ,CAAA"}
package/dist/signals.mjs CHANGED
@@ -1 +1 @@
1
- import{Component as t,options as i,isValidElement as n,Fragment as e}from"preact";import{useMemo as o,useState as f,useRef as r,useEffect as u}from"preact/hooks";import{effect as s,Signal as c,computed as l,signal as a,batch as d}from"@preact/signals-core";export{Signal,batch,computed,effect,signal,untracked}from"@preact/signals-core";const h="undefined"!=typeof window&&!!window.__PREACT_SIGNALS_DEVTOOLS__;let p,m,v,w=[],_=[];s(function(){p=this.N})();function g(t,n){i[t]=n.bind(null,i[t]||(()=>{}))}function y(t){if(v)v();v=t&&t.S()}function b({data:t}){const i=useSignal(t);i.value=t;const[e,f]=o(()=>{let t=this,e=this.__v;while(e=e.__)if(e.__c){e.__c.__$f|=4;break}const o=l(()=>{let t=i.value.value;return 0===t?0:!0===t?"":t||""}),f=l(()=>!Array.isArray(o.value)&&!n(o.value)),r=s(function(){this.N=M;if(f.value){const i=o.value;if(t.__v&&t.__v.__e&&3===t.__v.__e.nodeType)t.__v.__e.data=i}}),u=this.__$u.d;this.__$u.d=function(){r();u.call(this)};return[f,o]},[]);return e.value?f.peek():f.value}b.displayName="ReactiveTextNode";Object.defineProperties(c.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:b},props:{configurable:!0,get(){return{data:this}}},__b:{configurable:!0,value:1}});g("__b",(t,i)=>{if(h&&"function"==typeof i.type)window.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();if("string"==typeof i.type){let t,n=i.props;for(let e in n){if("children"===e)continue;let o=n[e];if(o instanceof c){if(!t)i.__np=t={};t[e]=o;n[e]=o.peek()}}}t(i)});g("__r",(t,i)=>{if(h&&"function"==typeof i.type)window.__PREACT_SIGNALS_DEVTOOLS__.enterComponent(i);if(i.type!==e){y();let t,n=i.__c;if(n){n.__$f&=-2;t=n.__$u;if(void 0===t)n.__$u=t=function(t){let i;s(function(){i=this});i.c=()=>{n.__$f|=1;n.setState({})};return i}()}m=n;y(t)}t(i)});g("__e",(t,i,n,e)=>{if(h)window.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();y();m=void 0;t(i,n,e)});g("diffed",(t,i)=>{if(h&&"function"==typeof i.type)window.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();y();m=void 0;let n;if("string"==typeof i.type&&(n=i.__e)){let t=i.__np,e=i.props;if(t){let i=n.U;if(i)for(let n in i){let e=i[n];if(void 0!==e&&!(n in t)){e.d();i[n]=void 0}}else{i={};n.U=i}for(let o in t){let f=i[o],r=t[o];if(void 0===f){f=k(n,o,r,e);i[o]=f}else f.o(r,e)}}}t(i)});function k(t,i,n,e){const o=i in t&&void 0===t.ownerSVGElement,f=a(n);return{o:(t,i)=>{f.value=t;e=i},d:s(function(){this.N=M;const n=f.value.value;if(e[i]!==n){e[i]=n;if(o)t[i]=n;else if(null!=n&&(!1!==n||"-"===i[4]))t.setAttribute(i,n);else t.removeAttribute(i)}})}}g("unmount",(t,i)=>{if("string"==typeof i.type){let t=i.__e;if(t){const i=t.U;if(i){t.U=void 0;for(let t in i){let n=i[t];if(n)n.d()}}}}else{let t=i.__c;if(t){const i=t.__$u;if(i){t.__$u=void 0;i.d()}}}t(i)});g("__h",(t,i,n,e)=>{if(e<3||9===e)i.__$f|=2;t(i,n,e)});t.prototype.shouldComponentUpdate=function(t,i){const n=this.__$u,e=n&&void 0!==n.s;for(let t in i)return!0;if(this.__f||"boolean"==typeof this.u&&!0===this.u){const t=2&this.__$f;if(!(e||t||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(e||4&this.__$f))return!0;if(3&this.__$f)return!0}for(let i in t)if("__source"!==i&&t[i]!==this.props[i])return!0;for(let i in this.props)if(!(i in t))return!0;return!1};function useSignal(t,i){return f(()=>a(t,i))[0]}function useComputed(t,i){const n=r(t);n.current=t;m.__$f|=4;return o(()=>l(()=>n.current(),i),[])}const q="undefined"==typeof requestAnimationFrame?setTimeout:function(t){const i=()=>{clearTimeout(n);cancelAnimationFrame(e);t()},n=setTimeout(i,35),e=requestAnimationFrame(i)},A=t=>{queueMicrotask(()=>{queueMicrotask(t)})};function T(){d(()=>{let t;while(t=w.shift())p.call(t)})}function x(){if(1===w.push(this))(i.requestAnimationFrame||q)(T)}function F(){d(()=>{let t;while(t=_.shift())p.call(t)})}function M(){if(1===_.push(this))(i.requestAnimationFrame||A)(F)}function useSignalEffect(t,i){const n=r(t);n.current=t;u(()=>s(function(){this.N=x;return n.current()},i),[])}export{useComputed,useSignal,useSignalEffect};//# sourceMappingURL=signals.mjs.map
1
+ import{Component as t,options as i,isValidElement as e,Fragment as n}from"preact";import{useMemo as o,useState as f,useRef as r,useEffect as u}from"preact/hooks";import{effect as s,Signal as c,computed as l,signal as a,batch as h}from"@preact/signals-core";export{Signal,batch,computed,effect,signal,untracked}from"@preact/signals-core";const d="undefined"!=typeof window&&!!window.__PREACT_SIGNALS_DEVTOOLS__;let p,m,v,_=[],g=[];s(function(){p=this.N})();function b(t,e){i[t]=e.bind(null,i[t]||(()=>{}))}function y(t){if(v)v();v=t&&t.S()}function w({data:t}){const i=useSignal(t);i.value=t;const[n,f]=o(()=>{let t=this,n=this.__v;while(n=n.__)if(n.__c){n.__c.__$f|=4;break}const o=l(()=>{let t=i.value.value;return 0===t?0:!0===t?"":t||""}),f=l(()=>!Array.isArray(o.value)&&!e(o.value)),r=s(function(){this.N=M;if(f.value){const i=o.value;if(t.__v&&t.__v.__e&&3===t.__v.__e.nodeType)t.__v.__e.data=i}}),u=this.__$u.d;this.__$u.d=function(){r();u.call(this)};return[f,o]},[]);return n.value?f.peek():f.value}w.displayName="ReactiveTextNode";Object.defineProperties(c.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:w},props:{configurable:!0,get(){return{data:this}}},__b:{configurable:!0,value:1}});b("__b",(t,i)=>{if("string"==typeof i.type){let t,e=i.props;for(let n in e){if("children"===n)continue;let o=e[n];if(o instanceof c){if(!t)i.__np=t={};t[n]=o;e[n]=o.peek()}}}t(i)});b("__r",(t,i)=>{if(i.type!==n){y();let t,e=i.__c;if(e){e.__$f&=-2;t=e.__$u;if(void 0===t)e.__$u=t=function(t,i){let e;s(function(){e=this},{name:i});e.c=t;return e}(()=>{var i;if(d)null==(i=t.y)||i.call(t);e.__$f|=1;e.setState({})},"function"==typeof i.type?i.type.displayName||i.type.name:"")}m=e;y(t)}t(i)});b("__e",(t,i,e,n)=>{y();m=void 0;t(i,e,n)});b("diffed",(t,i)=>{y();m=void 0;let e;if("string"==typeof i.type&&(e=i.__e)){let t=i.__np,n=i.props;if(t){let i=e.U;if(i)for(let e in i){let n=i[e];if(void 0!==n&&!(e in t)){n.d();i[e]=void 0}}else{i={};e.U=i}for(let o in t){let f=i[o],r=t[o];if(void 0===f){f=k(e,o,r,n);i[o]=f}else f.o(r,n)}}}t(i)});function k(t,i,e,n){const o=i in t&&void 0===t.ownerSVGElement,f=a(e);return{o:(t,i)=>{f.value=t;n=i},d:s(function(){this.N=M;const e=f.value.value;if(n[i]!==e){n[i]=e;if(o)t[i]=e;else if(null!=e&&(!1!==e||"-"===i[4]))t.setAttribute(i,e);else t.removeAttribute(i)}})}}b("unmount",(t,i)=>{if("string"==typeof i.type){let t=i.__e;if(t){const i=t.U;if(i){t.U=void 0;for(let t in i){let e=i[t];if(e)e.d()}}}}else{let t=i.__c;if(t){const i=t.__$u;if(i){t.__$u=void 0;i.d()}}}t(i)});b("__h",(t,i,e,n)=>{if(n<3||9===n)i.__$f|=2;t(i,e,n)});t.prototype.shouldComponentUpdate=function(t,i){const e=this.__$u,n=e&&void 0!==e.s;for(let t in i)return!0;if(this.__f||"boolean"==typeof this.u&&!0===this.u){const t=2&this.__$f;if(!(n||t||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(n||4&this.__$f))return!0;if(3&this.__$f)return!0}for(let i in t)if("__source"!==i&&t[i]!==this.props[i])return!0;for(let i in this.props)if(!(i in t))return!0;return!1};function useSignal(t,i){return f(()=>a(t,i))[0]}function useComputed(t,i){const e=r(t);e.current=t;m.__$f|=4;return o(()=>l(()=>e.current(),i),[])}const q="undefined"==typeof requestAnimationFrame?setTimeout:function(t){const i=()=>{clearTimeout(e);cancelAnimationFrame(n);t()},e=setTimeout(i,35),n=requestAnimationFrame(i)},A=t=>{queueMicrotask(()=>{queueMicrotask(t)})};function T(){h(()=>{let t;while(t=_.shift())p.call(t)})}function x(){if(1===_.push(this))(i.requestAnimationFrame||q)(T)}function F(){h(()=>{let t;while(t=g.shift())p.call(t)})}function M(){if(1===g.push(this))(i.requestAnimationFrame||A)(F)}function useSignalEffect(t,i){const e=r(t);e.current=t;u(()=>s(function(){this.N=x;return e.current()},i),[])}export{useComputed,useSignal,useSignalEffect};//# sourceMappingURL=signals.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"signals.mjs","sources":["../src/index.ts"],"sourcesContent":["import { options, Component, isValidElement, Fragment } from \"preact\";\nimport { useRef, useMemo, useEffect, useState } from \"preact/hooks\";\nimport {\n\tsignal,\n\tcomputed,\n\tbatch,\n\teffect,\n\tSignal,\n\ttype ReadonlySignal,\n\tuntracked,\n\tSignalOptions,\n\tEffectOptions,\n} from \"@preact/signals-core\";\nimport {\n\tVNode,\n\tOptionsTypes,\n\tHookFn,\n\tEffect,\n\tPropertyUpdater,\n\tAugmentedComponent,\n\tAugmentedElement as Element,\n} from \"./internal\";\n\nexport {\n\tsignal,\n\tcomputed,\n\tbatch,\n\teffect,\n\tSignal,\n\ttype ReadonlySignal,\n\tuntracked,\n};\n\nconst DEVTOOLS_ENABLED =\n\ttypeof window !== \"undefined\" && !!window.__PREACT_SIGNALS_DEVTOOLS__;\n\nconst HAS_PENDING_UPDATE = 1 << 0;\nconst HAS_HOOK_STATE = 1 << 1;\nconst HAS_COMPUTEDS = 1 << 2;\n\nlet oldNotify: (this: Effect) => void,\n\teffectsQueue: Array<Effect> = [],\n\tdomQueue: Array<Effect> = [];\n\n// Capture the original `Effect.prototype._notify` method so that we can install\n// custom `._notify`s for each different use-case but still call the original\n// implementation in the end. Dispose the temporary effect immediately afterwards.\neffect(function (this: Effect) {\n\toldNotify = this._notify;\n})();\n\n// Install a Preact options hook\nfunction hook<T extends OptionsTypes>(hookName: T, hookFn: HookFn<T>) {\n\t// @ts-ignore-next-line private options hooks usage\n\toptions[hookName] = hookFn.bind(null, options[hookName] || (() => {}));\n}\n\nlet currentComponent: AugmentedComponent | undefined;\nlet finishUpdate: (() => void) | undefined;\n\nfunction setCurrentUpdater(updater?: Effect) {\n\t// end tracking for the current update:\n\tif (finishUpdate) finishUpdate();\n\t// start tracking the new update:\n\tfinishUpdate = updater && updater._start();\n}\n\nfunction createUpdater(update: () => void) {\n\tlet updater!: Effect;\n\teffect(function (this: Effect) {\n\t\tupdater = this;\n\t});\n\tupdater._callback = update;\n\treturn updater;\n}\n\n/** @todo This may be needed for complex prop value detection. */\n// function isSignalValue(value: any): value is Signal {\n// \tif (typeof value !== \"object\" || value == null) return false;\n// \tif (value instanceof Signal) return true;\n// \t// @TODO: uncomment this when we land Reactive (ideally behind a brand check)\n// \t// for (let i in value) if (value[i] instanceof Signal) return true;\n// \treturn false;\n// }\n\n/**\n * A wrapper component that renders a Signal directly as a Text node.\n * @todo: in Preact 11, just decorate Signal with `type:null`\n */\nfunction SignalValue(this: AugmentedComponent, { data }: { data: Signal }) {\n\t// hasComputeds.add(this);\n\n\t// Store the props.data signal in another signal so that\n\t// passing a new signal reference re-runs the text computed:\n\tconst currentSignal = useSignal(data);\n\tcurrentSignal.value = data;\n\n\tconst [isText, s] = useMemo(() => {\n\t\tlet self = this;\n\t\t// mark the parent component as having computeds so it gets optimized\n\t\tlet v = this.__v;\n\t\twhile ((v = v.__!)) {\n\t\t\tif (v.__c) {\n\t\t\t\tv.__c._updateFlags |= HAS_COMPUTEDS;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tconst wrappedSignal = computed(() => {\n\t\t\tlet s = currentSignal.value.value;\n\t\t\treturn s === 0 ? 0 : s === true ? \"\" : s || \"\";\n\t\t});\n\n\t\tconst isText = computed(\n\t\t\t() =>\n\t\t\t\t!Array.isArray(wrappedSignal.value) &&\n\t\t\t\t!isValidElement(wrappedSignal.value)\n\t\t);\n\t\t// Update text nodes directly without rerendering when the new value\n\t\t// is also text.\n\t\tconst dispose = effect(function (this: Effect) {\n\t\t\tthis._notify = notifyDomUpdates;\n\n\t\t\t// Subscribe to wrappedSignal updates only when its values are text...\n\t\t\tif (isText.value) {\n\t\t\t\t// ...but regardless of `self.base`'s current value, as it can be\n\t\t\t\t// undefined before mounting or a non-text node. In both of those cases\n\t\t\t\t// the update gets handled by a full rerender.\n\t\t\t\tconst value = wrappedSignal.value;\n\t\t\t\tif (self.__v && self.__v.__e && self.__v.__e.nodeType === 3) {\n\t\t\t\t\t(self.__v.__e as Text).data = value;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// Piggyback this._updater's disposal to ensure that the text updater effect\n\t\t// above also gets disposed on unmount.\n\t\tconst oldDispose = this._updater!._dispose;\n\t\tthis._updater!._dispose = function () {\n\t\t\tdispose();\n\t\t\toldDispose.call(this);\n\t\t};\n\n\t\treturn [isText, wrappedSignal];\n\t}, []);\n\n\t// Rerender the component whenever `data.value` changes from a VNode\n\t// to another VNode, from text to a VNode, or from a VNode to text.\n\t// That is, everything else except text-to-text updates.\n\t//\n\t// This also ensures that the backing DOM node types gets updated to\n\t// text nodes and back when needed.\n\t//\n\t// For text-to-text updates, `.peek()` is used to skip full rerenders,\n\t// leaving them to the optimized path above.\n\treturn isText.value ? s.peek() : s.value;\n}\n\nSignalValue.displayName = \"ReactiveTextNode\";\n\nObject.defineProperties(Signal.prototype, {\n\tconstructor: { configurable: true, value: undefined },\n\ttype: { configurable: true, value: SignalValue },\n\tprops: {\n\t\tconfigurable: true,\n\t\tget() {\n\t\t\treturn { data: this };\n\t\t},\n\t},\n\t// Setting a VNode's _depth to 1 forces Preact to clone it before modifying:\n\t// https://github.com/preactjs/preact/blob/d7a433ee8463a7dc23a05111bb47de9ec729ad4d/src/diff/children.js#L77\n\t// @todo remove this for Preact 11\n\t__b: { configurable: true, value: 1 },\n});\n\n/** Inject low-level property/attribute bindings for Signals into Preact's diff */\nhook(OptionsTypes.DIFF, (old, vnode) => {\n\tif (DEVTOOLS_ENABLED && typeof vnode.type === \"function\") {\n\t\twindow.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();\n\t}\n\n\tif (typeof vnode.type === \"string\") {\n\t\tlet signalProps: Record<string, any> | undefined;\n\n\t\tlet props = vnode.props;\n\t\tfor (let i in props) {\n\t\t\tif (i === \"children\") continue;\n\n\t\t\tlet value = props[i];\n\t\t\tif (value instanceof Signal) {\n\t\t\t\tif (!signalProps) vnode.__np = signalProps = {};\n\t\t\t\tsignalProps[i] = value;\n\t\t\t\tprops[i] = value.peek();\n\t\t\t}\n\t\t}\n\t}\n\n\told(vnode);\n});\n\n/** Set up Updater before rendering a component */\nhook(OptionsTypes.RENDER, (old, vnode) => {\n\tif (DEVTOOLS_ENABLED && typeof vnode.type === \"function\") {\n\t\twindow.__PREACT_SIGNALS_DEVTOOLS__.enterComponent(vnode);\n\t}\n\n\t// Ignore the Fragment inserted by preact.createElement().\n\tif (vnode.type !== Fragment) {\n\t\tsetCurrentUpdater();\n\n\t\tlet updater;\n\n\t\tlet component = vnode.__c;\n\t\tif (component) {\n\t\t\tcomponent._updateFlags &= ~HAS_PENDING_UPDATE;\n\n\t\t\tupdater = component._updater;\n\t\t\tif (updater === undefined) {\n\t\t\t\tcomponent._updater = updater = createUpdater(() => {\n\t\t\t\t\tcomponent._updateFlags |= HAS_PENDING_UPDATE;\n\t\t\t\t\tcomponent.setState({});\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tcurrentComponent = component;\n\t\tsetCurrentUpdater(updater);\n\t}\n\n\told(vnode);\n});\n\n/** Finish current updater if a component errors */\nhook(OptionsTypes.CATCH_ERROR, (old, error, vnode, oldVNode) => {\n\tif (DEVTOOLS_ENABLED) {\n\t\twindow.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();\n\t}\n\n\tsetCurrentUpdater();\n\tcurrentComponent = undefined;\n\told(error, vnode, oldVNode);\n});\n\n/** Finish current updater after rendering any VNode */\nhook(OptionsTypes.DIFFED, (old, vnode) => {\n\tif (DEVTOOLS_ENABLED && typeof vnode.type === \"function\") {\n\t\twindow.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();\n\t}\n\n\tsetCurrentUpdater();\n\tcurrentComponent = undefined;\n\n\tlet dom: Element;\n\n\t// vnode._dom is undefined during string rendering,\n\t// so we use this to skip prop subscriptions during SSR.\n\tif (typeof vnode.type === \"string\" && (dom = vnode.__e as Element)) {\n\t\tlet props = vnode.__np;\n\t\tlet renderedProps = vnode.props;\n\t\tif (props) {\n\t\t\tlet updaters = dom._updaters;\n\t\t\tif (updaters) {\n\t\t\t\tfor (let prop in updaters) {\n\t\t\t\t\tlet updater = updaters[prop];\n\t\t\t\t\tif (updater !== undefined && !(prop in props)) {\n\t\t\t\t\t\tupdater._dispose();\n\t\t\t\t\t\t// @todo we could just always invoke _dispose() here\n\t\t\t\t\t\tupdaters[prop] = undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tupdaters = {};\n\t\t\t\tdom._updaters = updaters;\n\t\t\t}\n\t\t\tfor (let prop in props) {\n\t\t\t\tlet updater = updaters[prop];\n\t\t\t\tlet signal = props[prop];\n\t\t\t\tif (updater === undefined) {\n\t\t\t\t\tupdater = createPropUpdater(dom, prop, signal, renderedProps);\n\t\t\t\t\tupdaters[prop] = updater;\n\t\t\t\t} else {\n\t\t\t\t\tupdater._update(signal, renderedProps);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\told(vnode);\n});\n\nfunction createPropUpdater(\n\tdom: Element,\n\tprop: string,\n\tpropSignal: Signal,\n\tprops: Record<string, any>\n): PropertyUpdater {\n\tconst setAsProperty =\n\t\tprop in dom &&\n\t\t// SVG elements need to go through `setAttribute` because they\n\t\t// expect things like SVGAnimatedTransformList instead of strings.\n\t\t// @ts-ignore\n\t\tdom.ownerSVGElement === undefined;\n\n\tconst changeSignal = signal(propSignal);\n\treturn {\n\t\t_update: (newSignal: Signal, newProps: typeof props) => {\n\t\t\tchangeSignal.value = newSignal;\n\t\t\tprops = newProps;\n\t\t},\n\t\t_dispose: effect(function (this: Effect) {\n\t\t\tthis._notify = notifyDomUpdates;\n\t\t\tconst value = changeSignal.value.value;\n\t\t\t// If Preact just rendered this value, don't render it again:\n\t\t\tif (props[prop] === value) return;\n\t\t\tprops[prop] = value;\n\t\t\tif (setAsProperty) {\n\t\t\t\t// @ts-ignore-next-line silly\n\t\t\t\tdom[prop] = value;\n\t\t\t\t// Match Preact's attribute handling: data-* and aria-* attributes\n\t\t\t\t// https://github.com/preactjs/preact/blob/main/src/diff/props.js#L132\n\t\t\t} else if (value != null && (value !== false || prop[4] === \"-\")) {\n\t\t\t\tdom.setAttribute(prop, value);\n\t\t\t} else {\n\t\t\t\tdom.removeAttribute(prop);\n\t\t\t}\n\t\t}),\n\t};\n}\n\n/** Unsubscribe from Signals when unmounting components/vnodes */\nhook(OptionsTypes.UNMOUNT, (old, vnode: VNode) => {\n\tif (typeof vnode.type === \"string\") {\n\t\tlet dom = vnode.__e as Element | undefined;\n\t\t// vnode._dom is undefined during string rendering\n\t\tif (dom) {\n\t\t\tconst updaters = dom._updaters;\n\t\t\tif (updaters) {\n\t\t\t\tdom._updaters = undefined;\n\t\t\t\tfor (let prop in updaters) {\n\t\t\t\t\tlet updater = updaters[prop];\n\t\t\t\t\tif (updater) updater._dispose();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tlet component = vnode.__c;\n\t\tif (component) {\n\t\t\tconst updater = component._updater;\n\t\t\tif (updater) {\n\t\t\t\tcomponent._updater = undefined;\n\t\t\t\tupdater._dispose();\n\t\t\t}\n\t\t}\n\t}\n\told(vnode);\n});\n\n/** Mark components that use hook state so we can skip sCU optimization. */\nhook(OptionsTypes.HOOK, (old, component, index, type) => {\n\tif (type < 3 || type === 9)\n\t\t(component as AugmentedComponent)._updateFlags |= HAS_HOOK_STATE;\n\told(component, index, type);\n});\n\n/**\n * Auto-memoize components that use Signals/Computeds.\n * Note: Does _not_ optimize components that use hook/class state.\n */\nComponent.prototype.shouldComponentUpdate = function (\n\tthis: AugmentedComponent,\n\tprops,\n\tstate\n) {\n\t// @todo: Once preactjs/preact#3671 lands, this could just use `currentUpdater`:\n\tconst updater = this._updater;\n\tconst hasSignals = updater && updater._sources !== undefined;\n\n\t// If this is a component using state, rerender\n\t// @ts-ignore\n\tfor (let i in state) return true;\n\n\tif (this.__f || (typeof this.u == \"boolean\" && this.u === true)) {\n\t\tconst hasHooksState = this._updateFlags & HAS_HOOK_STATE;\n\t\t// if this component used no signals or computeds and no hooks state, update:\n\t\tif (!hasSignals && !hasHooksState && !(this._updateFlags & HAS_COMPUTEDS))\n\t\t\treturn true;\n\n\t\t// if there is a pending re-render triggered from Signals,\n\t\t// or if there is hooks state, update:\n\t\tif (this._updateFlags & HAS_PENDING_UPDATE) return true;\n\t} else {\n\t\t// if this component used no signals or computeds, update:\n\t\tif (!hasSignals && !(this._updateFlags & HAS_COMPUTEDS)) return true;\n\n\t\t// if there is a pending re-render triggered from Signals,\n\t\t// or if there is hooks state, update:\n\t\tif (this._updateFlags & (HAS_PENDING_UPDATE | HAS_HOOK_STATE)) return true;\n\t}\n\n\t// if any non-Signal props changed, update:\n\tfor (let i in props) {\n\t\tif (i !== \"__source\" && props[i] !== this.props[i]) return true;\n\t}\n\tfor (let i in this.props) if (!(i in props)) return true;\n\n\t// this is a purely Signal-driven component, don't update:\n\treturn false;\n};\n\nexport function useSignal<T>(value: T, options?: SignalOptions<T>): Signal<T>;\nexport function useSignal<T = undefined>(): Signal<T | undefined>;\nexport function useSignal<T>(value?: T, options?: SignalOptions<T>) {\n\treturn useState(() =>\n\t\tsignal<T | undefined>(value, options as SignalOptions)\n\t)[0];\n}\n\nexport function useComputed<T>(compute: () => T, options?: SignalOptions<T>) {\n\tconst $compute = useRef(compute);\n\t$compute.current = compute;\n\t(currentComponent as AugmentedComponent)._updateFlags |= HAS_COMPUTEDS;\n\treturn useMemo(() => computed<T>(() => $compute.current(), options), []);\n}\n\nfunction safeRaf(callback: () => void) {\n\tconst done = () => {\n\t\tclearTimeout(timeout);\n\t\tcancelAnimationFrame(raf);\n\t\tcallback();\n\t};\n\n\tconst timeout = setTimeout(done, 35);\n\tconst raf = requestAnimationFrame(done);\n}\n\nconst deferEffects =\n\ttypeof requestAnimationFrame === \"undefined\" ? setTimeout : safeRaf;\n\nconst deferDomUpdates = (cb: any) => {\n\tqueueMicrotask(() => {\n\t\tqueueMicrotask(cb);\n\t});\n};\n\nfunction flushEffects() {\n\tbatch(() => {\n\t\tlet inst: Effect | undefined;\n\t\twhile ((inst = effectsQueue.shift())) {\n\t\t\toldNotify.call(inst);\n\t\t}\n\t});\n}\n\nfunction notifyEffects(this: Effect) {\n\tif (effectsQueue.push(this) === 1) {\n\t\t(options.requestAnimationFrame || deferEffects)(flushEffects);\n\t}\n}\n\nfunction flushDomUpdates() {\n\tbatch(() => {\n\t\tlet inst: Effect | undefined;\n\t\twhile ((inst = domQueue.shift())) {\n\t\t\toldNotify.call(inst);\n\t\t}\n\t});\n}\n\nfunction notifyDomUpdates(this: Effect) {\n\tif (domQueue.push(this) === 1) {\n\t\t(options.requestAnimationFrame || deferDomUpdates)(flushDomUpdates);\n\t}\n}\n\nexport function useSignalEffect(\n\tcb: () => void | (() => void),\n\toptions?: EffectOptions\n) {\n\tconst callback = useRef(cb);\n\tcallback.current = cb;\n\n\tuseEffect(() => {\n\t\treturn effect(function (this: Effect) {\n\t\t\tthis._notify = notifyEffects;\n\t\t\treturn callback.current();\n\t\t}, options);\n\t}, []);\n}\n\n/**\n * @todo Determine which Reactive implementation we'll be using.\n * @internal\n */\n// export function useReactive<T extends object>(value: T): Reactive<T> {\n// \treturn useMemo(() => reactive<T>(value), []);\n// }\n\n/**\n * @internal\n * Update a Reactive's using the properties of an object or other Reactive.\n * Also works for Signals.\n * @example\n * // Update a Reactive with Object.assign()-like syntax:\n * const r = reactive({ name: \"Alice\" });\n * update(r, { name: \"Bob\" });\n * update(r, { age: 42 }); // property 'age' does not exist in type '{ name?: string }'\n * update(r, 2); // '2' has no properties in common with '{ name?: string }'\n * console.log(r.name.value); // \"Bob\"\n *\n * @example\n * // Update a Reactive with the properties of another Reactive:\n * const A = reactive({ name: \"Alice\" });\n * const B = reactive({ name: \"Bob\", age: 42 });\n * update(A, B);\n * console.log(`${A.name} is ${A.age}`); // \"Bob is 42\"\n *\n * @example\n * // Update a signal with assign()-like syntax:\n * const s = signal(42);\n * update(s, \"hi\"); // Argument type 'string' not assignable to type 'number'\n * update(s, {}); // Argument type '{}' not assignable to type 'number'\n * update(s, 43);\n * console.log(s.value); // 43\n *\n * @param obj The Reactive or Signal to be updated\n * @param update The value, Signal, object or Reactive to update `obj` to match\n * @param overwrite If `true`, any properties `obj` missing from `update` are set to `undefined`\n */\n/*\nexport function update<T extends SignalOrReactive>(\n\tobj: T,\n\tupdate: Partial<Unwrap<T>>,\n\toverwrite = false\n) {\n\tif (obj instanceof Signal) {\n\t\tobj.value = peekValue(update);\n\t} else {\n\t\tfor (let i in update) {\n\t\t\tif (i in obj) {\n\t\t\t\tobj[i].value = peekValue(update[i]);\n\t\t\t} else {\n\t\t\t\tlet sig = signal(peekValue(update[i]));\n\t\t\t\tsig[KEY] = i;\n\t\t\t\tobj[i] = sig;\n\t\t\t}\n\t\t}\n\t\tif (overwrite) {\n\t\t\tfor (let i in obj) {\n\t\t\t\tif (!(i in update)) {\n\t\t\t\t\tobj[i].value = undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n*/\n"],"names":["DEVTOOLS_ENABLED","window","__PREACT_SIGNALS_DEVTOOLS__","oldNotify","currentComponent","finishUpdate","effectsQueue","domQueue","effect","this","_notify","hook","hookName","hookFn","options","bind","setCurrentUpdater","updater","_start","SignalValue","data","currentSignal","useSignal","value","isText","s","useMemo","self","v","__v","__","__c","_updateFlags","wrappedSignal","computed","Array","isArray","isValidElement","dispose","notifyDomUpdates","__e","nodeType","oldDispose","_updater","_dispose","call","peek","displayName","Object","defineProperties","Signal","prototype","constructor","configurable","undefined","type","props","get","__b","old","vnode","exitComponent","signalProps","i","__np","enterComponent","Fragment","component","update","_callback","setState","createUpdater","error","oldVNode","dom","renderedProps","updaters","_updaters","prop","signal","createPropUpdater","_update","propSignal","setAsProperty","ownerSVGElement","changeSignal","newSignal","newProps","setAttribute","removeAttribute","index","Component","shouldComponentUpdate","state","hasSignals","_sources","__f","u","hasHooksState","HAS_PENDING_UPDATE","useState","useComputed","compute","$compute","useRef","current","deferEffects","requestAnimationFrame","setTimeout","callback","done","clearTimeout","timeout","cancelAnimationFrame","raf","deferDomUpdates","cb","queueMicrotask","flushEffects","batch","inst","shift","notifyEffects","push","flushDomUpdates","useSignalEffect","useEffect"],"mappings":"iVAiCA,MAAMA,EACa,oBAAXC,UAA4BA,OAAOC,4BAM3C,IAAIC,EAiBAC,EACAC,EAjBHC,EAA8B,GAC9BC,EAA0B,GAK3BC,EAAO,WACNL,EAAYM,KAAKC,CAClB,EAFAF,GAKA,SAASG,EAA6BC,EAAaC,GAElDC,EAAQF,GAAYC,EAAOE,KAAK,KAAMD,EAAQF,UAAsB,GACrE,CAKA,SAASI,EAAkBC,GAE1B,GAAIZ,EAAcA,IAElBA,EAAeY,GAAWA,EAAQC,GACnC,CAwBA,SAASC,GAAsCC,KAAEA,IAKhD,MAAMC,EAAgBC,UAAUF,GAChCC,EAAcE,MAAQH,EAEtB,MAAOI,EAAQC,GAAKC,EAAQ,KAC3B,IAAIC,EAAOlB,KAEPmB,EAAInB,KAAKoB,IACb,MAAQD,EAAIA,EAAEE,GACb,GAAIF,EAAEG,IAAK,CACVH,EAAEG,IAAIC,MAjEY,EAkElB,KACD,CAGD,MAAMC,EAAgBC,EAAS,KAC9B,IAAIT,EAAIJ,EAAcE,MAAMA,MAC5B,OAAa,IAANE,EAAU,GAAU,IAANA,EAAa,GAAKA,GAAK,KAGvCD,EAASU,EACd,KACEC,MAAMC,QAAQH,EAAcV,SAC5Bc,EAAeJ,EAAcV,QAI1Be,EAAU9B,EAAO,WACtBC,KAAKC,EAAU6B,EAGf,GAAIf,EAAOD,MAAO,CAIjB,MAAMA,EAAQU,EAAcV,M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,IAA5BpH,EAAaqH,KAAKlH,OACpBK,EAAQ6F,uBAAyBD,GAAcY,EAElD,CAEA,SAASM,IACRL,EAAM,KACL,IAAIC,EACJ,MAAQA,EAAOjH,EAASkH,QACvBtH,EAAU0C,KAAK2E,EAChB,EAEF,CAEA,SAASjF,IACR,GAA4B,IAAxBhC,EAASoH,KAAKlH,OAChBK,EAAQ6F,uBAAyBQ,GAAiBS,EAErD,CAEgB,SAAAC,gBACfT,EACAtG,GAEA,MAAM+F,EAAWL,EAAOY,GACxBP,EAASJ,QAAUW,EAEnBU,EAAU,IACFtH,EAAO,WACbC,KAAKC,EAAUgH,EACf,OAAOb,EAASJ,SACjB,EAAG3F,GACD,GACJ,QAAAuF,YAAA/E,UAAAuG"}
1
+ {"version":3,"file":"signals.mjs","sources":["../src/index.ts"],"sourcesContent":["import { options, Component, isValidElement, Fragment } from \"preact\";\nimport { useRef, useMemo, useEffect, useState } from \"preact/hooks\";\nimport {\n\tsignal,\n\tcomputed,\n\tbatch,\n\teffect,\n\tSignal,\n\ttype ReadonlySignal,\n\tuntracked,\n\tSignalOptions,\n\tEffectOptions,\n} from \"@preact/signals-core\";\nimport {\n\tVNode,\n\tOptionsTypes,\n\tHookFn,\n\tEffect,\n\tPropertyUpdater,\n\tAugmentedComponent,\n\tAugmentedElement as Element,\n} from \"./internal\";\n\nexport {\n\tsignal,\n\tcomputed,\n\tbatch,\n\teffect,\n\tSignal,\n\ttype ReadonlySignal,\n\tuntracked,\n};\n\nconst DEVTOOLS_ENABLED =\n\ttypeof window !== \"undefined\" && !!window.__PREACT_SIGNALS_DEVTOOLS__;\n\nconst HAS_PENDING_UPDATE = 1 << 0;\nconst HAS_HOOK_STATE = 1 << 1;\nconst HAS_COMPUTEDS = 1 << 2;\n\nlet oldNotify: (this: Effect) => void,\n\teffectsQueue: Array<Effect> = [],\n\tdomQueue: Array<Effect> = [];\n\n// Capture the original `Effect.prototype._notify` method so that we can install\n// custom `._notify`s for each different use-case but still call the original\n// implementation in the end. Dispose the temporary effect immediately afterwards.\neffect(function (this: Effect) {\n\toldNotify = this._notify;\n})();\n\n// Install a Preact options hook\nfunction hook<T extends OptionsTypes>(hookName: T, hookFn: HookFn<T>) {\n\t// @ts-ignore-next-line private options hooks usage\n\toptions[hookName] = hookFn.bind(null, options[hookName] || (() => {}));\n}\n\nlet currentComponent: AugmentedComponent | undefined;\nlet finishUpdate: (() => void) | undefined;\n\nfunction setCurrentUpdater(updater?: Effect) {\n\t// end tracking for the current update:\n\tif (finishUpdate) finishUpdate();\n\t// start tracking the new update:\n\tfinishUpdate = updater && updater._start();\n}\n\nfunction createUpdater(update: () => void, name: string) {\n\tlet updater!: Effect;\n\teffect(\n\t\tfunction (this: Effect) {\n\t\t\tupdater = this;\n\t\t},\n\t\t{ name }\n\t);\n\tupdater._callback = update;\n\treturn updater;\n}\n\n/** @todo This may be needed for complex prop value detection. */\n// function isSignalValue(value: any): value is Signal {\n// \tif (typeof value !== \"object\" || value == null) return false;\n// \tif (value instanceof Signal) return true;\n// \t// @TODO: uncomment this when we land Reactive (ideally behind a brand check)\n// \t// for (let i in value) if (value[i] instanceof Signal) return true;\n// \treturn false;\n// }\n\n/**\n * A wrapper component that renders a Signal directly as a Text node.\n * @todo: in Preact 11, just decorate Signal with `type:null`\n */\nfunction SignalValue(this: AugmentedComponent, { data }: { data: Signal }) {\n\t// hasComputeds.add(this);\n\n\t// Store the props.data signal in another signal so that\n\t// passing a new signal reference re-runs the text computed:\n\tconst currentSignal = useSignal(data);\n\tcurrentSignal.value = data;\n\n\tconst [isText, s] = useMemo(() => {\n\t\tlet self = this;\n\t\t// mark the parent component as having computeds so it gets optimized\n\t\tlet v = this.__v;\n\t\twhile ((v = v.__!)) {\n\t\t\tif (v.__c) {\n\t\t\t\tv.__c._updateFlags |= HAS_COMPUTEDS;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tconst wrappedSignal = computed(() => {\n\t\t\tlet s = currentSignal.value.value;\n\t\t\treturn s === 0 ? 0 : s === true ? \"\" : s || \"\";\n\t\t});\n\n\t\tconst isText = computed(\n\t\t\t() =>\n\t\t\t\t!Array.isArray(wrappedSignal.value) &&\n\t\t\t\t!isValidElement(wrappedSignal.value)\n\t\t);\n\t\t// Update text nodes directly without rerendering when the new value\n\t\t// is also text.\n\t\tconst dispose = effect(function (this: Effect) {\n\t\t\tthis._notify = notifyDomUpdates;\n\n\t\t\t// Subscribe to wrappedSignal updates only when its values are text...\n\t\t\tif (isText.value) {\n\t\t\t\t// ...but regardless of `self.base`'s current value, as it can be\n\t\t\t\t// undefined before mounting or a non-text node. In both of those cases\n\t\t\t\t// the update gets handled by a full rerender.\n\t\t\t\tconst value = wrappedSignal.value;\n\t\t\t\tif (self.__v && self.__v.__e && self.__v.__e.nodeType === 3) {\n\t\t\t\t\t(self.__v.__e as Text).data = value;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// Piggyback this._updater's disposal to ensure that the text updater effect\n\t\t// above also gets disposed on unmount.\n\t\tconst oldDispose = this._updater!._dispose;\n\t\tthis._updater!._dispose = function () {\n\t\t\tdispose();\n\t\t\toldDispose.call(this);\n\t\t};\n\n\t\treturn [isText, wrappedSignal];\n\t}, []);\n\n\t// Rerender the component whenever `data.value` changes from a VNode\n\t// to another VNode, from text to a VNode, or from a VNode to text.\n\t// That is, everything else except text-to-text updates.\n\t//\n\t// This also ensures that the backing DOM node types gets updated to\n\t// text nodes and back when needed.\n\t//\n\t// For text-to-text updates, `.peek()` is used to skip full rerenders,\n\t// leaving them to the optimized path above.\n\treturn isText.value ? s.peek() : s.value;\n}\n\nSignalValue.displayName = \"ReactiveTextNode\";\n\nObject.defineProperties(Signal.prototype, {\n\tconstructor: { configurable: true, value: undefined },\n\ttype: { configurable: true, value: SignalValue },\n\tprops: {\n\t\tconfigurable: true,\n\t\tget() {\n\t\t\treturn { data: this };\n\t\t},\n\t},\n\t// Setting a VNode's _depth to 1 forces Preact to clone it before modifying:\n\t// https://github.com/preactjs/preact/blob/d7a433ee8463a7dc23a05111bb47de9ec729ad4d/src/diff/children.js#L77\n\t// @todo remove this for Preact 11\n\t__b: { configurable: true, value: 1 },\n});\n\n/** Inject low-level property/attribute bindings for Signals into Preact's diff */\nhook(OptionsTypes.DIFF, (old, vnode) => {\n\tif (typeof vnode.type === \"string\") {\n\t\tlet signalProps: Record<string, any> | undefined;\n\n\t\tlet props = vnode.props;\n\t\tfor (let i in props) {\n\t\t\tif (i === \"children\") continue;\n\n\t\t\tlet value = props[i];\n\t\t\tif (value instanceof Signal) {\n\t\t\t\tif (!signalProps) vnode.__np = signalProps = {};\n\t\t\t\tsignalProps[i] = value;\n\t\t\t\tprops[i] = value.peek();\n\t\t\t}\n\t\t}\n\t}\n\n\told(vnode);\n});\n\n/** Set up Updater before rendering a component */\nhook(OptionsTypes.RENDER, (old, vnode) => {\n\t// Ignore the Fragment inserted by preact.createElement().\n\tif (vnode.type !== Fragment) {\n\t\tsetCurrentUpdater();\n\n\t\tlet updater: Effect | undefined;\n\n\t\tlet component = vnode.__c;\n\t\tif (component) {\n\t\t\tcomponent._updateFlags &= ~HAS_PENDING_UPDATE;\n\n\t\t\tupdater = component._updater;\n\t\t\tif (updater === undefined) {\n\t\t\t\tcomponent._updater = updater = createUpdater(\n\t\t\t\t\t() => {\n\t\t\t\t\t\tif (DEVTOOLS_ENABLED) updater!._debugCallback?.call(updater);\n\t\t\t\t\t\tcomponent._updateFlags |= HAS_PENDING_UPDATE;\n\t\t\t\t\t\tcomponent.setState({});\n\t\t\t\t\t},\n\t\t\t\t\ttypeof vnode.type === \"function\"\n\t\t\t\t\t\t? vnode.type.displayName || vnode.type.name\n\t\t\t\t\t\t: \"\"\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tcurrentComponent = component;\n\t\tsetCurrentUpdater(updater);\n\t}\n\n\told(vnode);\n});\n\n/** Finish current updater if a component errors */\nhook(OptionsTypes.CATCH_ERROR, (old, error, vnode, oldVNode) => {\n\tsetCurrentUpdater();\n\tcurrentComponent = undefined;\n\told(error, vnode, oldVNode);\n});\n\n/** Finish current updater after rendering any VNode */\nhook(OptionsTypes.DIFFED, (old, vnode) => {\n\tsetCurrentUpdater();\n\tcurrentComponent = undefined;\n\n\tlet dom: Element;\n\n\t// vnode._dom is undefined during string rendering,\n\t// so we use this to skip prop subscriptions during SSR.\n\tif (typeof vnode.type === \"string\" && (dom = vnode.__e as Element)) {\n\t\tlet props = vnode.__np;\n\t\tlet renderedProps = vnode.props;\n\t\tif (props) {\n\t\t\tlet updaters = dom._updaters;\n\t\t\tif (updaters) {\n\t\t\t\tfor (let prop in updaters) {\n\t\t\t\t\tlet updater = updaters[prop];\n\t\t\t\t\tif (updater !== undefined && !(prop in props)) {\n\t\t\t\t\t\tupdater._dispose();\n\t\t\t\t\t\t// @todo we could just always invoke _dispose() here\n\t\t\t\t\t\tupdaters[prop] = undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tupdaters = {};\n\t\t\t\tdom._updaters = updaters;\n\t\t\t}\n\t\t\tfor (let prop in props) {\n\t\t\t\tlet updater = updaters[prop];\n\t\t\t\tlet signal = props[prop];\n\t\t\t\tif (updater === undefined) {\n\t\t\t\t\tupdater = createPropUpdater(dom, prop, signal, renderedProps);\n\t\t\t\t\tupdaters[prop] = updater;\n\t\t\t\t} else {\n\t\t\t\t\tupdater._update(signal, renderedProps);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\told(vnode);\n});\n\nfunction createPropUpdater(\n\tdom: Element,\n\tprop: string,\n\tpropSignal: Signal,\n\tprops: Record<string, any>\n): PropertyUpdater {\n\tconst setAsProperty =\n\t\tprop in dom &&\n\t\t// SVG elements need to go through `setAttribute` because they\n\t\t// expect things like SVGAnimatedTransformList instead of strings.\n\t\t// @ts-ignore\n\t\tdom.ownerSVGElement === undefined;\n\n\tconst changeSignal = signal(propSignal);\n\treturn {\n\t\t_update: (newSignal: Signal, newProps: typeof props) => {\n\t\t\tchangeSignal.value = newSignal;\n\t\t\tprops = newProps;\n\t\t},\n\t\t_dispose: effect(function (this: Effect) {\n\t\t\tthis._notify = notifyDomUpdates;\n\t\t\tconst value = changeSignal.value.value;\n\t\t\t// If Preact just rendered this value, don't render it again:\n\t\t\tif (props[prop] === value) return;\n\t\t\tprops[prop] = value;\n\t\t\tif (setAsProperty) {\n\t\t\t\t// @ts-ignore-next-line silly\n\t\t\t\tdom[prop] = value;\n\t\t\t\t// Match Preact's attribute handling: data-* and aria-* attributes\n\t\t\t\t// https://github.com/preactjs/preact/blob/main/src/diff/props.js#L132\n\t\t\t} else if (value != null && (value !== false || prop[4] === \"-\")) {\n\t\t\t\tdom.setAttribute(prop, value);\n\t\t\t} else {\n\t\t\t\tdom.removeAttribute(prop);\n\t\t\t}\n\t\t}),\n\t};\n}\n\n/** Unsubscribe from Signals when unmounting components/vnodes */\nhook(OptionsTypes.UNMOUNT, (old, vnode: VNode) => {\n\tif (typeof vnode.type === \"string\") {\n\t\tlet dom = vnode.__e as Element | undefined;\n\t\t// vnode._dom is undefined during string rendering\n\t\tif (dom) {\n\t\t\tconst updaters = dom._updaters;\n\t\t\tif (updaters) {\n\t\t\t\tdom._updaters = undefined;\n\t\t\t\tfor (let prop in updaters) {\n\t\t\t\t\tlet updater = updaters[prop];\n\t\t\t\t\tif (updater) updater._dispose();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tlet component = vnode.__c;\n\t\tif (component) {\n\t\t\tconst updater = component._updater;\n\t\t\tif (updater) {\n\t\t\t\tcomponent._updater = undefined;\n\t\t\t\tupdater._dispose();\n\t\t\t}\n\t\t}\n\t}\n\told(vnode);\n});\n\n/** Mark components that use hook state so we can skip sCU optimization. */\nhook(OptionsTypes.HOOK, (old, component, index, type) => {\n\tif (type < 3 || type === 9)\n\t\t(component as AugmentedComponent)._updateFlags |= HAS_HOOK_STATE;\n\told(component, index, type);\n});\n\n/**\n * Auto-memoize components that use Signals/Computeds.\n * Note: Does _not_ optimize components that use hook/class state.\n */\nComponent.prototype.shouldComponentUpdate = function (\n\tthis: AugmentedComponent,\n\tprops,\n\tstate\n) {\n\t// @todo: Once preactjs/preact#3671 lands, this could just use `currentUpdater`:\n\tconst updater = this._updater;\n\tconst hasSignals = updater && updater._sources !== undefined;\n\n\t// If this is a component using state, rerender\n\t// @ts-ignore\n\tfor (let i in state) return true;\n\n\tif (this.__f || (typeof this.u == \"boolean\" && this.u === true)) {\n\t\tconst hasHooksState = this._updateFlags & HAS_HOOK_STATE;\n\t\t// if this component used no signals or computeds and no hooks state, update:\n\t\tif (!hasSignals && !hasHooksState && !(this._updateFlags & HAS_COMPUTEDS))\n\t\t\treturn true;\n\n\t\t// if there is a pending re-render triggered from Signals,\n\t\t// or if there is hooks state, update:\n\t\tif (this._updateFlags & HAS_PENDING_UPDATE) return true;\n\t} else {\n\t\t// if this component used no signals or computeds, update:\n\t\tif (!hasSignals && !(this._updateFlags & HAS_COMPUTEDS)) return true;\n\n\t\t// if there is a pending re-render triggered from Signals,\n\t\t// or if there is hooks state, update:\n\t\tif (this._updateFlags & (HAS_PENDING_UPDATE | HAS_HOOK_STATE)) return true;\n\t}\n\n\t// if any non-Signal props changed, update:\n\tfor (let i in props) {\n\t\tif (i !== \"__source\" && props[i] !== this.props[i]) return true;\n\t}\n\tfor (let i in this.props) if (!(i in props)) return true;\n\n\t// this is a purely Signal-driven component, don't update:\n\treturn false;\n};\n\nexport function useSignal<T>(value: T, options?: SignalOptions<T>): Signal<T>;\nexport function useSignal<T = undefined>(): Signal<T | undefined>;\nexport function useSignal<T>(value?: T, options?: SignalOptions<T>) {\n\treturn useState(() =>\n\t\tsignal<T | undefined>(value, options as SignalOptions)\n\t)[0];\n}\n\nexport function useComputed<T>(compute: () => T, options?: SignalOptions<T>) {\n\tconst $compute = useRef(compute);\n\t$compute.current = compute;\n\t(currentComponent as AugmentedComponent)._updateFlags |= HAS_COMPUTEDS;\n\treturn useMemo(() => computed<T>(() => $compute.current(), options), []);\n}\n\nfunction safeRaf(callback: () => void) {\n\tconst done = () => {\n\t\tclearTimeout(timeout);\n\t\tcancelAnimationFrame(raf);\n\t\tcallback();\n\t};\n\n\tconst timeout = setTimeout(done, 35);\n\tconst raf = requestAnimationFrame(done);\n}\n\nconst deferEffects =\n\ttypeof requestAnimationFrame === \"undefined\" ? setTimeout : safeRaf;\n\nconst deferDomUpdates = (cb: any) => {\n\tqueueMicrotask(() => {\n\t\tqueueMicrotask(cb);\n\t});\n};\n\nfunction flushEffects() {\n\tbatch(() => {\n\t\tlet inst: Effect | undefined;\n\t\twhile ((inst = effectsQueue.shift())) {\n\t\t\toldNotify.call(inst);\n\t\t}\n\t});\n}\n\nfunction notifyEffects(this: Effect) {\n\tif (effectsQueue.push(this) === 1) {\n\t\t(options.requestAnimationFrame || deferEffects)(flushEffects);\n\t}\n}\n\nfunction flushDomUpdates() {\n\tbatch(() => {\n\t\tlet inst: Effect | undefined;\n\t\twhile ((inst = domQueue.shift())) {\n\t\t\toldNotify.call(inst);\n\t\t}\n\t});\n}\n\nfunction notifyDomUpdates(this: Effect) {\n\tif (domQueue.push(this) === 1) {\n\t\t(options.requestAnimationFrame || deferDomUpdates)(flushDomUpdates);\n\t}\n}\n\nexport function useSignalEffect(\n\tcb: () => void | (() => void),\n\toptions?: EffectOptions\n) {\n\tconst callback = useRef(cb);\n\tcallback.current = cb;\n\n\tuseEffect(() => {\n\t\treturn effect(function (this: Effect) {\n\t\t\tthis._notify = notifyEffects;\n\t\t\treturn callback.current();\n\t\t}, options);\n\t}, []);\n}\n\n/**\n * @todo Determine which Reactive implementation we'll be using.\n * @internal\n */\n// export function useReactive<T extends object>(value: T): Reactive<T> {\n// \treturn useMemo(() => reactive<T>(value), []);\n// }\n\n/**\n * @internal\n * Update a Reactive's using the properties of an object or other Reactive.\n * Also works for Signals.\n * @example\n * // Update a Reactive with Object.assign()-like syntax:\n * const r = reactive({ name: \"Alice\" });\n * update(r, { name: \"Bob\" });\n * update(r, { age: 42 }); // property 'age' does not exist in type '{ name?: string }'\n * update(r, 2); // '2' has no properties in common with '{ name?: string }'\n * console.log(r.name.value); // \"Bob\"\n *\n * @example\n * // Update a Reactive with the properties of another Reactive:\n * const A = reactive({ name: \"Alice\" });\n * const B = reactive({ name: \"Bob\", age: 42 });\n * update(A, B);\n * console.log(`${A.name} is ${A.age}`); // \"Bob is 42\"\n *\n * @example\n * // Update a signal with assign()-like syntax:\n * const s = signal(42);\n * update(s, \"hi\"); // Argument type 'string' not assignable to type 'number'\n * update(s, {}); // Argument type '{}' not assignable to type 'number'\n * update(s, 43);\n * console.log(s.value); // 43\n *\n * @param obj The Reactive or Signal to be updated\n * @param update The value, Signal, object or Reactive to update `obj` to match\n * @param overwrite If `true`, any properties `obj` missing from `update` are set to `undefined`\n */\n/*\nexport function update<T extends SignalOrReactive>(\n\tobj: T,\n\tupdate: Partial<Unwrap<T>>,\n\toverwrite = false\n) {\n\tif (obj instanceof Signal) {\n\t\tobj.value = peekValue(update);\n\t} else {\n\t\tfor (let i in update) {\n\t\t\tif (i in obj) {\n\t\t\t\tobj[i].value = peekValue(update[i]);\n\t\t\t} else {\n\t\t\t\tlet sig = signal(peekValue(update[i]));\n\t\t\t\tsig[KEY] = i;\n\t\t\t\tobj[i] = sig;\n\t\t\t}\n\t\t}\n\t\tif (overwrite) {\n\t\t\tfor (let i in obj) {\n\t\t\t\tif (!(i in update)) {\n\t\t\t\t\tobj[i].value = undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n*/\n"],"names":["DEVTOOLS_ENABLED","window","__PREACT_SIGNALS_DEVTOOLS__","oldNotify","currentComponent","finishUpdate","effectsQueue","domQueue","effect","this","_notify","hook","hookName","hookFn","options","bind","setCurrentUpdater","updater","_start","SignalValue","data","currentSignal","useSignal","value","isText","s","useMemo","self","v","__v","__","__c","_updateFlags","wrappedSignal","computed","Array","isArray","isValidElement","dispose","notifyDomUpdates","__e","nodeType","oldDispose","_updater","_dispose","call","peek","displayName","Object","defineProperties","Signal","prototype","constructor","configurable","undefined","type","props","get","__b","old","vnode","signalProps","i","__np","Fragment","component","update","name","_callback","createUpdater","_updater$_debugCallba","_debugCallback","setState","error","oldVNode","dom","renderedProps","updaters","_updaters","prop","signal","createPropUpdater","_update","propSignal","setAsProperty","ownerSVGElement","changeSignal","newSignal","newProps","setAttribute","removeAttribute","index","Component","shouldComponentUpdate","state","hasSignals","_sources","__f","u","hasHooksState","HAS_PENDING_UPDATE","useState","useComputed","compute","$compute","useRef","current","deferEffects","requestAnimationFrame","setTimeout","callback","done","clearTimeout","timeout","cancelAnimationFrame","raf","deferDomUpdates","cb","queueMicrotask","flushEffects","batch","inst","shift","notifyEffects","push","flushDomUpdates","useSignalEffect","useEffect"],"mappings":"iVAiCA,MAAMA,EACa,oBAAXC,UAA4BA,OAAOC,4BAM3C,IAAIC,EAiBAC,EACAC,EAjBHC,EAA8B,GAC9BC,EAA0B,GAK3BC,EAAO,WACNL,EAAYM,KAAKC,CAClB,EAFAF,GAKA,SAASG,EAA6BC,EAAaC,GAElDC,EAAQF,GAAYC,EAAOE,KAAK,KAAMD,EAAQF,IAAc,MAAQ,GACrE,CAKA,SAASI,EAAkBC,GAE1B,GAAIZ,EAAcA,IAElBA,EAAeY,GAAWA,EAAQC,GACnC,CA2BA,SAASC,GAAsCC,KAAEA,IAKhD,MAAMC,EAAgBC,UAAUF,GAChCC,EAAcE,MAAQH,EAEtB,MAAOI,EAAQC,GAAKC,EAAQ,KAC3B,IAAIC,EAAOlB,KAEPmB,EAAInB,KAAKoB,IACb,MAAQD,EAAIA,EAAEE,GACb,GAAIF,EAAEG,IAAK,CACVH,EAAEG,IAAIC,MApEY,EAqElB,KACD,CAGD,MAAMC,EAAgBC,EAAS,KAC9B,IAAIT,EAAIJ,EAAcE,MAAMA,MAC5B,OAAa,IAANE,EAAU,GAAU,IAANA,EAAa,GAAKA,GAAK,KAGvCD,EAASU,EACd,KACEC,MAAMC,QAAQH,EAAcV,SAC5Bc,EAAeJ,EAAcV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,GAAgC,IAA5BrH,EAAasH,KAAKnH,OACpBK,EAAQ8F,uBAAyBD,GAAcY,EAElD,CAEA,SAASM,IACRL,EAAM,KACL,IAAIC,EACJ,MAAQA,EAAOlH,EAASmH,QACvBvH,EAAU0C,KAAK4E,EAChB,EAEF,CAEA,SAASlF,IACR,GAA4B,IAAxBhC,EAASqH,KAAKnH,OAChBK,EAAQ8F,uBAAyBQ,GAAiBS,EAErD,CAEgB,SAAAC,gBACfT,EACAvG,GAEA,MAAMgG,EAAWL,EAAOY,GACxBP,EAASJ,QAAUW,EAEnBU,EAAU,IACFvH,EAAO,WACbC,KAAKC,EAAUiH,EACf,OAAOb,EAASJ,SACjB,EAAG5F,GACD,GACJ,QAAAwF,YAAAhF,UAAAwG"}
@@ -1 +1 @@
1
- import{Component as i,options as n,isValidElement as t,Fragment as r}from"preact";import{useMemo as f,useState as o,useRef as e,useEffect as u}from"preact/hooks";import{effect as a,Signal as c,computed as v,signal as s,batch as d}from"@preact/signals-core";export{Signal,batch,computed,effect,signal,untracked}from"@preact/signals-core";var h,l,p,m="undefined"!=typeof window&&!!window.__PREACT_SIGNALS_DEVTOOLS__,w=[],_=[];a(function(){h=this.N})();function g(i,t){n[i]=t.bind(null,n[i]||function(){})}function y(i){if(p)p();p=i&&i.S()}function b(i){var n=this,r=i.data,o=useSignal(r);o.value=r;var e=f(function(){var i=n,r=n.__v;while(r=r.__)if(r.__c){r.__c.__$f|=4;break}var f=v(function(){var i=o.value.value;return 0===i?0:!0===i?"":i||""}),e=v(function(){return!Array.isArray(f.value)&&!t(f.value)}),u=a(function(){this.N=M;if(e.value){var n=f.value;if(i.__v&&i.__v.__e&&3===i.__v.__e.nodeType)i.__v.__e.data=n}}),c=n.__$u.d;n.__$u.d=function(){u();c.call(this)};return[e,f]},[]),u=e[0],c=e[1];return u.value?c.peek():c.value}b.displayName="ReactiveTextNode";Object.defineProperties(c.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:b},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});g("__b",function(i,n){if(m&&"function"==typeof n.type)window.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();if("string"==typeof n.type){var t,r=n.props;for(var f in r)if("children"!==f){var o=r[f];if(o instanceof c){if(!t)n.__np=t={};t[f]=o;r[f]=o.peek()}}}i(n)});g("__r",function(i,n){if(m&&"function"==typeof n.type)window.__PREACT_SIGNALS_DEVTOOLS__.enterComponent(n);if(n.type!==r){y();var t,f=n.__c;if(f){f.__$f&=-2;if(void 0===(t=f.__$u))f.__$u=t=function(i){var n;a(function(){n=this});n.c=function(){f.__$f|=1;f.setState({})};return n}()}l=f;y(t)}i(n)});g("__e",function(i,n,t,r){if(m)window.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();y();l=void 0;i(n,t,r)});g("diffed",function(i,n){if(m&&"function"==typeof n.type)window.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();y();l=void 0;var t;if("string"==typeof n.type&&(t=n.__e)){var r=n.__np,f=n.props;if(r){var o=t.U;if(o)for(var e in o){var u=o[e];if(void 0!==u&&!(e in r)){u.d();o[e]=void 0}}else{o={};t.U=o}for(var a in r){var c=o[a],v=r[a];if(void 0===c){c=k(t,a,v,f);o[a]=c}else c.o(v,f)}}}i(n)});function k(i,n,t,r){var f=n in i&&void 0===i.ownerSVGElement,o=s(t);return{o:function(i,n){o.value=i;r=n},d:a(function(){this.N=M;var t=o.value.value;if(r[n]!==t){r[n]=t;if(f)i[n]=t;else if(null!=t&&(!1!==t||"-"===n[4]))i.setAttribute(n,t);else i.removeAttribute(n)}})}}g("unmount",function(i,n){if("string"==typeof n.type){var t=n.__e;if(t){var r=t.U;if(r){t.U=void 0;for(var f in r){var o=r[f];if(o)o.d()}}}}else{var e=n.__c;if(e){var u=e.__$u;if(u){e.__$u=void 0;u.d()}}}i(n)});g("__h",function(i,n,t,r){if(r<3||9===r)n.__$f|=2;i(n,t,r)});i.prototype.shouldComponentUpdate=function(i,n){var t=this.__$u,r=t&&void 0!==t.s;for(var f in n)return!0;if(this.__f||"boolean"==typeof this.u&&!0===this.u){var o=2&this.__$f;if(!(r||o||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(r||4&this.__$f))return!0;if(3&this.__$f)return!0}for(var e in i)if("__source"!==e&&i[e]!==this.props[e])return!0;for(var u in this.props)if(!(u in i))return!0;return!1};function useSignal(i,n){return o(function(){return s(i,n)})[0]}function useComputed(i,n){var t=e(i);t.current=i;l.__$f|=4;return f(function(){return v(function(){return t.current()},n)},[])}var q="undefined"==typeof requestAnimationFrame?setTimeout:function(i){var n=function(){clearTimeout(t);cancelAnimationFrame(r);i()},t=setTimeout(n,35),r=requestAnimationFrame(n)},A=function(i){queueMicrotask(function(){queueMicrotask(i)})};function T(){d(function(){var i;while(i=w.shift())h.call(i)})}function x(){if(1===w.push(this))(n.requestAnimationFrame||q)(T)}function F(){d(function(){var i;while(i=_.shift())h.call(i)})}function M(){if(1===_.push(this))(n.requestAnimationFrame||A)(F)}function useSignalEffect(i,n){var t=e(i);t.current=i;u(function(){return a(function(){this.N=x;return t.current()},n)},[])}export{useComputed,useSignal,useSignalEffect};//# sourceMappingURL=signals.module.js.map
1
+ import{Component as i,options as n,isValidElement as t,Fragment as r}from"preact";import{useMemo as f,useState as o,useRef as e,useEffect as u}from"preact/hooks";import{effect as a,Signal as c,computed as v,signal as s,batch as l}from"@preact/signals-core";export{Signal,batch,computed,effect,signal,untracked}from"@preact/signals-core";var h,d,p,m="undefined"!=typeof window&&!!window.__PREACT_SIGNALS_DEVTOOLS__,_=[],g=[];a(function(){h=this.N})();function b(i,t){n[i]=t.bind(null,n[i]||function(){})}function y(i){if(p)p();p=i&&i.S()}function w(i){var n=this,r=i.data,o=useSignal(r);o.value=r;var e=f(function(){var i=n,r=n.__v;while(r=r.__)if(r.__c){r.__c.__$f|=4;break}var f=v(function(){var i=o.value.value;return 0===i?0:!0===i?"":i||""}),e=v(function(){return!Array.isArray(f.value)&&!t(f.value)}),u=a(function(){this.N=M;if(e.value){var n=f.value;if(i.__v&&i.__v.__e&&3===i.__v.__e.nodeType)i.__v.__e.data=n}}),c=n.__$u.d;n.__$u.d=function(){u();c.call(this)};return[e,f]},[]),u=e[0],c=e[1];return u.value?c.peek():c.value}w.displayName="ReactiveTextNode";Object.defineProperties(c.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:w},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});b("__b",function(i,n){if("string"==typeof n.type){var t,r=n.props;for(var f in r)if("children"!==f){var o=r[f];if(o instanceof c){if(!t)n.__np=t={};t[f]=o;r[f]=o.peek()}}}i(n)});b("__r",function(i,n){if(n.type!==r){y();var t,f=n.__c;if(f){f.__$f&=-2;if(void 0===(t=f.__$u))f.__$u=t=function(i,n){var t;a(function(){t=this},{name:n});t.c=i;return t}(function(){var i;if(m)null==(i=t.y)||i.call(t);f.__$f|=1;f.setState({})},"function"==typeof n.type?n.type.displayName||n.type.name:"")}d=f;y(t)}i(n)});b("__e",function(i,n,t,r){y();d=void 0;i(n,t,r)});b("diffed",function(i,n){y();d=void 0;var t;if("string"==typeof n.type&&(t=n.__e)){var r=n.__np,f=n.props;if(r){var o=t.U;if(o)for(var e in o){var u=o[e];if(void 0!==u&&!(e in r)){u.d();o[e]=void 0}}else{o={};t.U=o}for(var a in r){var c=o[a],v=r[a];if(void 0===c){c=k(t,a,v,f);o[a]=c}else c.o(v,f)}}}i(n)});function k(i,n,t,r){var f=n in i&&void 0===i.ownerSVGElement,o=s(t);return{o:function(i,n){o.value=i;r=n},d:a(function(){this.N=M;var t=o.value.value;if(r[n]!==t){r[n]=t;if(f)i[n]=t;else if(null!=t&&(!1!==t||"-"===n[4]))i.setAttribute(n,t);else i.removeAttribute(n)}})}}b("unmount",function(i,n){if("string"==typeof n.type){var t=n.__e;if(t){var r=t.U;if(r){t.U=void 0;for(var f in r){var o=r[f];if(o)o.d()}}}}else{var e=n.__c;if(e){var u=e.__$u;if(u){e.__$u=void 0;u.d()}}}i(n)});b("__h",function(i,n,t,r){if(r<3||9===r)n.__$f|=2;i(n,t,r)});i.prototype.shouldComponentUpdate=function(i,n){var t=this.__$u,r=t&&void 0!==t.s;for(var f in n)return!0;if(this.__f||"boolean"==typeof this.u&&!0===this.u){var o=2&this.__$f;if(!(r||o||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(r||4&this.__$f))return!0;if(3&this.__$f)return!0}for(var e in i)if("__source"!==e&&i[e]!==this.props[e])return!0;for(var u in this.props)if(!(u in i))return!0;return!1};function useSignal(i,n){return o(function(){return s(i,n)})[0]}function useComputed(i,n){var t=e(i);t.current=i;d.__$f|=4;return f(function(){return v(function(){return t.current()},n)},[])}var q="undefined"==typeof requestAnimationFrame?setTimeout:function(i){var n=function(){clearTimeout(t);cancelAnimationFrame(r);i()},t=setTimeout(n,35),r=requestAnimationFrame(n)},A=function(i){queueMicrotask(function(){queueMicrotask(i)})};function T(){l(function(){var i;while(i=_.shift())h.call(i)})}function x(){if(1===_.push(this))(n.requestAnimationFrame||q)(T)}function F(){l(function(){var i;while(i=g.shift())h.call(i)})}function M(){if(1===g.push(this))(n.requestAnimationFrame||A)(F)}function useSignalEffect(i,n){var t=e(i);t.current=i;u(function(){return a(function(){this.N=x;return t.current()},n)},[])}export{useComputed,useSignal,useSignalEffect};//# sourceMappingURL=signals.module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"signals.module.js","sources":["../src/index.ts"],"sourcesContent":["import { options, Component, isValidElement, Fragment } from \"preact\";\nimport { useRef, useMemo, useEffect, useState } from \"preact/hooks\";\nimport {\n\tsignal,\n\tcomputed,\n\tbatch,\n\teffect,\n\tSignal,\n\ttype ReadonlySignal,\n\tuntracked,\n\tSignalOptions,\n\tEffectOptions,\n} from \"@preact/signals-core\";\nimport {\n\tVNode,\n\tOptionsTypes,\n\tHookFn,\n\tEffect,\n\tPropertyUpdater,\n\tAugmentedComponent,\n\tAugmentedElement as Element,\n} from \"./internal\";\n\nexport {\n\tsignal,\n\tcomputed,\n\tbatch,\n\teffect,\n\tSignal,\n\ttype ReadonlySignal,\n\tuntracked,\n};\n\nconst DEVTOOLS_ENABLED =\n\ttypeof window !== \"undefined\" && !!window.__PREACT_SIGNALS_DEVTOOLS__;\n\nconst HAS_PENDING_UPDATE = 1 << 0;\nconst HAS_HOOK_STATE = 1 << 1;\nconst HAS_COMPUTEDS = 1 << 2;\n\nlet oldNotify: (this: Effect) => void,\n\teffectsQueue: Array<Effect> = [],\n\tdomQueue: Array<Effect> = [];\n\n// Capture the original `Effect.prototype._notify` method so that we can install\n// custom `._notify`s for each different use-case but still call the original\n// implementation in the end. Dispose the temporary effect immediately afterwards.\neffect(function (this: Effect) {\n\toldNotify = this._notify;\n})();\n\n// Install a Preact options hook\nfunction hook<T extends OptionsTypes>(hookName: T, hookFn: HookFn<T>) {\n\t// @ts-ignore-next-line private options hooks usage\n\toptions[hookName] = hookFn.bind(null, options[hookName] || (() => {}));\n}\n\nlet currentComponent: AugmentedComponent | undefined;\nlet finishUpdate: (() => void) | undefined;\n\nfunction setCurrentUpdater(updater?: Effect) {\n\t// end tracking for the current update:\n\tif (finishUpdate) finishUpdate();\n\t// start tracking the new update:\n\tfinishUpdate = updater && updater._start();\n}\n\nfunction createUpdater(update: () => void) {\n\tlet updater!: Effect;\n\teffect(function (this: Effect) {\n\t\tupdater = this;\n\t});\n\tupdater._callback = update;\n\treturn updater;\n}\n\n/** @todo This may be needed for complex prop value detection. */\n// function isSignalValue(value: any): value is Signal {\n// \tif (typeof value !== \"object\" || value == null) return false;\n// \tif (value instanceof Signal) return true;\n// \t// @TODO: uncomment this when we land Reactive (ideally behind a brand check)\n// \t// for (let i in value) if (value[i] instanceof Signal) return true;\n// \treturn false;\n// }\n\n/**\n * A wrapper component that renders a Signal directly as a Text node.\n * @todo: in Preact 11, just decorate Signal with `type:null`\n */\nfunction SignalValue(this: AugmentedComponent, { data }: { data: Signal }) {\n\t// hasComputeds.add(this);\n\n\t// Store the props.data signal in another signal so that\n\t// passing a new signal reference re-runs the text computed:\n\tconst currentSignal = useSignal(data);\n\tcurrentSignal.value = data;\n\n\tconst [isText, s] = useMemo(() => {\n\t\tlet self = this;\n\t\t// mark the parent component as having computeds so it gets optimized\n\t\tlet v = this.__v;\n\t\twhile ((v = v.__!)) {\n\t\t\tif (v.__c) {\n\t\t\t\tv.__c._updateFlags |= HAS_COMPUTEDS;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tconst wrappedSignal = computed(() => {\n\t\t\tlet s = currentSignal.value.value;\n\t\t\treturn s === 0 ? 0 : s === true ? \"\" : s || \"\";\n\t\t});\n\n\t\tconst isText = computed(\n\t\t\t() =>\n\t\t\t\t!Array.isArray(wrappedSignal.value) &&\n\t\t\t\t!isValidElement(wrappedSignal.value)\n\t\t);\n\t\t// Update text nodes directly without rerendering when the new value\n\t\t// is also text.\n\t\tconst dispose = effect(function (this: Effect) {\n\t\t\tthis._notify = notifyDomUpdates;\n\n\t\t\t// Subscribe to wrappedSignal updates only when its values are text...\n\t\t\tif (isText.value) {\n\t\t\t\t// ...but regardless of `self.base`'s current value, as it can be\n\t\t\t\t// undefined before mounting or a non-text node. In both of those cases\n\t\t\t\t// the update gets handled by a full rerender.\n\t\t\t\tconst value = wrappedSignal.value;\n\t\t\t\tif (self.__v && self.__v.__e && self.__v.__e.nodeType === 3) {\n\t\t\t\t\t(self.__v.__e as Text).data = value;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// Piggyback this._updater's disposal to ensure that the text updater effect\n\t\t// above also gets disposed on unmount.\n\t\tconst oldDispose = this._updater!._dispose;\n\t\tthis._updater!._dispose = function () {\n\t\t\tdispose();\n\t\t\toldDispose.call(this);\n\t\t};\n\n\t\treturn [isText, wrappedSignal];\n\t}, []);\n\n\t// Rerender the component whenever `data.value` changes from a VNode\n\t// to another VNode, from text to a VNode, or from a VNode to text.\n\t// That is, everything else except text-to-text updates.\n\t//\n\t// This also ensures that the backing DOM node types gets updated to\n\t// text nodes and back when needed.\n\t//\n\t// For text-to-text updates, `.peek()` is used to skip full rerenders,\n\t// leaving them to the optimized path above.\n\treturn isText.value ? s.peek() : s.value;\n}\n\nSignalValue.displayName = \"ReactiveTextNode\";\n\nObject.defineProperties(Signal.prototype, {\n\tconstructor: { configurable: true, value: undefined },\n\ttype: { configurable: true, value: SignalValue },\n\tprops: {\n\t\tconfigurable: true,\n\t\tget() {\n\t\t\treturn { data: this };\n\t\t},\n\t},\n\t// Setting a VNode's _depth to 1 forces Preact to clone it before modifying:\n\t// https://github.com/preactjs/preact/blob/d7a433ee8463a7dc23a05111bb47de9ec729ad4d/src/diff/children.js#L77\n\t// @todo remove this for Preact 11\n\t__b: { configurable: true, value: 1 },\n});\n\n/** Inject low-level property/attribute bindings for Signals into Preact's diff */\nhook(OptionsTypes.DIFF, (old, vnode) => {\n\tif (DEVTOOLS_ENABLED && typeof vnode.type === \"function\") {\n\t\twindow.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();\n\t}\n\n\tif (typeof vnode.type === \"string\") {\n\t\tlet signalProps: Record<string, any> | undefined;\n\n\t\tlet props = vnode.props;\n\t\tfor (let i in props) {\n\t\t\tif (i === \"children\") continue;\n\n\t\t\tlet value = props[i];\n\t\t\tif (value instanceof Signal) {\n\t\t\t\tif (!signalProps) vnode.__np = signalProps = {};\n\t\t\t\tsignalProps[i] = value;\n\t\t\t\tprops[i] = value.peek();\n\t\t\t}\n\t\t}\n\t}\n\n\told(vnode);\n});\n\n/** Set up Updater before rendering a component */\nhook(OptionsTypes.RENDER, (old, vnode) => {\n\tif (DEVTOOLS_ENABLED && typeof vnode.type === \"function\") {\n\t\twindow.__PREACT_SIGNALS_DEVTOOLS__.enterComponent(vnode);\n\t}\n\n\t// Ignore the Fragment inserted by preact.createElement().\n\tif (vnode.type !== Fragment) {\n\t\tsetCurrentUpdater();\n\n\t\tlet updater;\n\n\t\tlet component = vnode.__c;\n\t\tif (component) {\n\t\t\tcomponent._updateFlags &= ~HAS_PENDING_UPDATE;\n\n\t\t\tupdater = component._updater;\n\t\t\tif (updater === undefined) {\n\t\t\t\tcomponent._updater = updater = createUpdater(() => {\n\t\t\t\t\tcomponent._updateFlags |= HAS_PENDING_UPDATE;\n\t\t\t\t\tcomponent.setState({});\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tcurrentComponent = component;\n\t\tsetCurrentUpdater(updater);\n\t}\n\n\told(vnode);\n});\n\n/** Finish current updater if a component errors */\nhook(OptionsTypes.CATCH_ERROR, (old, error, vnode, oldVNode) => {\n\tif (DEVTOOLS_ENABLED) {\n\t\twindow.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();\n\t}\n\n\tsetCurrentUpdater();\n\tcurrentComponent = undefined;\n\told(error, vnode, oldVNode);\n});\n\n/** Finish current updater after rendering any VNode */\nhook(OptionsTypes.DIFFED, (old, vnode) => {\n\tif (DEVTOOLS_ENABLED && typeof vnode.type === \"function\") {\n\t\twindow.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();\n\t}\n\n\tsetCurrentUpdater();\n\tcurrentComponent = undefined;\n\n\tlet dom: Element;\n\n\t// vnode._dom is undefined during string rendering,\n\t// so we use this to skip prop subscriptions during SSR.\n\tif (typeof vnode.type === \"string\" && (dom = vnode.__e as Element)) {\n\t\tlet props = vnode.__np;\n\t\tlet renderedProps = vnode.props;\n\t\tif (props) {\n\t\t\tlet updaters = dom._updaters;\n\t\t\tif (updaters) {\n\t\t\t\tfor (let prop in updaters) {\n\t\t\t\t\tlet updater = updaters[prop];\n\t\t\t\t\tif (updater !== undefined && !(prop in props)) {\n\t\t\t\t\t\tupdater._dispose();\n\t\t\t\t\t\t// @todo we could just always invoke _dispose() here\n\t\t\t\t\t\tupdaters[prop] = undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tupdaters = {};\n\t\t\t\tdom._updaters = updaters;\n\t\t\t}\n\t\t\tfor (let prop in props) {\n\t\t\t\tlet updater = updaters[prop];\n\t\t\t\tlet signal = props[prop];\n\t\t\t\tif (updater === undefined) {\n\t\t\t\t\tupdater = createPropUpdater(dom, prop, signal, renderedProps);\n\t\t\t\t\tupdaters[prop] = updater;\n\t\t\t\t} else {\n\t\t\t\t\tupdater._update(signal, renderedProps);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\told(vnode);\n});\n\nfunction createPropUpdater(\n\tdom: Element,\n\tprop: string,\n\tpropSignal: Signal,\n\tprops: Record<string, any>\n): PropertyUpdater {\n\tconst setAsProperty =\n\t\tprop in dom &&\n\t\t// SVG elements need to go through `setAttribute` because they\n\t\t// expect things like SVGAnimatedTransformList instead of strings.\n\t\t// @ts-ignore\n\t\tdom.ownerSVGElement === undefined;\n\n\tconst changeSignal = signal(propSignal);\n\treturn {\n\t\t_update: (newSignal: Signal, newProps: typeof props) => {\n\t\t\tchangeSignal.value = newSignal;\n\t\t\tprops = newProps;\n\t\t},\n\t\t_dispose: effect(function (this: Effect) {\n\t\t\tthis._notify = notifyDomUpdates;\n\t\t\tconst value = changeSignal.value.value;\n\t\t\t// If Preact just rendered this value, don't render it again:\n\t\t\tif (props[prop] === value) return;\n\t\t\tprops[prop] = value;\n\t\t\tif (setAsProperty) {\n\t\t\t\t// @ts-ignore-next-line silly\n\t\t\t\tdom[prop] = value;\n\t\t\t\t// Match Preact's attribute handling: data-* and aria-* attributes\n\t\t\t\t// https://github.com/preactjs/preact/blob/main/src/diff/props.js#L132\n\t\t\t} else if (value != null && (value !== false || prop[4] === \"-\")) {\n\t\t\t\tdom.setAttribute(prop, value);\n\t\t\t} else {\n\t\t\t\tdom.removeAttribute(prop);\n\t\t\t}\n\t\t}),\n\t};\n}\n\n/** Unsubscribe from Signals when unmounting components/vnodes */\nhook(OptionsTypes.UNMOUNT, (old, vnode: VNode) => {\n\tif (typeof vnode.type === \"string\") {\n\t\tlet dom = vnode.__e as Element | undefined;\n\t\t// vnode._dom is undefined during string rendering\n\t\tif (dom) {\n\t\t\tconst updaters = dom._updaters;\n\t\t\tif (updaters) {\n\t\t\t\tdom._updaters = undefined;\n\t\t\t\tfor (let prop in updaters) {\n\t\t\t\t\tlet updater = updaters[prop];\n\t\t\t\t\tif (updater) updater._dispose();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tlet component = vnode.__c;\n\t\tif (component) {\n\t\t\tconst updater = component._updater;\n\t\t\tif (updater) {\n\t\t\t\tcomponent._updater = undefined;\n\t\t\t\tupdater._dispose();\n\t\t\t}\n\t\t}\n\t}\n\told(vnode);\n});\n\n/** Mark components that use hook state so we can skip sCU optimization. */\nhook(OptionsTypes.HOOK, (old, component, index, type) => {\n\tif (type < 3 || type === 9)\n\t\t(component as AugmentedComponent)._updateFlags |= HAS_HOOK_STATE;\n\told(component, index, type);\n});\n\n/**\n * Auto-memoize components that use Signals/Computeds.\n * Note: Does _not_ optimize components that use hook/class state.\n */\nComponent.prototype.shouldComponentUpdate = function (\n\tthis: AugmentedComponent,\n\tprops,\n\tstate\n) {\n\t// @todo: Once preactjs/preact#3671 lands, this could just use `currentUpdater`:\n\tconst updater = this._updater;\n\tconst hasSignals = updater && updater._sources !== undefined;\n\n\t// If this is a component using state, rerender\n\t// @ts-ignore\n\tfor (let i in state) return true;\n\n\tif (this.__f || (typeof this.u == \"boolean\" && this.u === true)) {\n\t\tconst hasHooksState = this._updateFlags & HAS_HOOK_STATE;\n\t\t// if this component used no signals or computeds and no hooks state, update:\n\t\tif (!hasSignals && !hasHooksState && !(this._updateFlags & HAS_COMPUTEDS))\n\t\t\treturn true;\n\n\t\t// if there is a pending re-render triggered from Signals,\n\t\t// or if there is hooks state, update:\n\t\tif (this._updateFlags & HAS_PENDING_UPDATE) return true;\n\t} else {\n\t\t// if this component used no signals or computeds, update:\n\t\tif (!hasSignals && !(this._updateFlags & HAS_COMPUTEDS)) return true;\n\n\t\t// if there is a pending re-render triggered from Signals,\n\t\t// or if there is hooks state, update:\n\t\tif (this._updateFlags & (HAS_PENDING_UPDATE | HAS_HOOK_STATE)) return true;\n\t}\n\n\t// if any non-Signal props changed, update:\n\tfor (let i in props) {\n\t\tif (i !== \"__source\" && props[i] !== this.props[i]) return true;\n\t}\n\tfor (let i in this.props) if (!(i in props)) return true;\n\n\t// this is a purely Signal-driven component, don't update:\n\treturn false;\n};\n\nexport function useSignal<T>(value: T, options?: SignalOptions<T>): Signal<T>;\nexport function useSignal<T = undefined>(): Signal<T | undefined>;\nexport function useSignal<T>(value?: T, options?: SignalOptions<T>) {\n\treturn useState(() =>\n\t\tsignal<T | undefined>(value, options as SignalOptions)\n\t)[0];\n}\n\nexport function useComputed<T>(compute: () => T, options?: SignalOptions<T>) {\n\tconst $compute = useRef(compute);\n\t$compute.current = compute;\n\t(currentComponent as AugmentedComponent)._updateFlags |= HAS_COMPUTEDS;\n\treturn useMemo(() => computed<T>(() => $compute.current(), options), []);\n}\n\nfunction safeRaf(callback: () => void) {\n\tconst done = () => {\n\t\tclearTimeout(timeout);\n\t\tcancelAnimationFrame(raf);\n\t\tcallback();\n\t};\n\n\tconst timeout = setTimeout(done, 35);\n\tconst raf = requestAnimationFrame(done);\n}\n\nconst deferEffects =\n\ttypeof requestAnimationFrame === \"undefined\" ? setTimeout : safeRaf;\n\nconst deferDomUpdates = (cb: any) => {\n\tqueueMicrotask(() => {\n\t\tqueueMicrotask(cb);\n\t});\n};\n\nfunction flushEffects() {\n\tbatch(() => {\n\t\tlet inst: Effect | undefined;\n\t\twhile ((inst = effectsQueue.shift())) {\n\t\t\toldNotify.call(inst);\n\t\t}\n\t});\n}\n\nfunction notifyEffects(this: Effect) {\n\tif (effectsQueue.push(this) === 1) {\n\t\t(options.requestAnimationFrame || deferEffects)(flushEffects);\n\t}\n}\n\nfunction flushDomUpdates() {\n\tbatch(() => {\n\t\tlet inst: Effect | undefined;\n\t\twhile ((inst = domQueue.shift())) {\n\t\t\toldNotify.call(inst);\n\t\t}\n\t});\n}\n\nfunction notifyDomUpdates(this: Effect) {\n\tif (domQueue.push(this) === 1) {\n\t\t(options.requestAnimationFrame || deferDomUpdates)(flushDomUpdates);\n\t}\n}\n\nexport function useSignalEffect(\n\tcb: () => void | (() => void),\n\toptions?: EffectOptions\n) {\n\tconst callback = useRef(cb);\n\tcallback.current = cb;\n\n\tuseEffect(() => {\n\t\treturn effect(function (this: Effect) {\n\t\t\tthis._notify = notifyEffects;\n\t\t\treturn callback.current();\n\t\t}, options);\n\t}, []);\n}\n\n/**\n * @todo Determine which Reactive implementation we'll be using.\n * @internal\n */\n// export function useReactive<T extends object>(value: T): Reactive<T> {\n// \treturn useMemo(() => reactive<T>(value), []);\n// }\n\n/**\n * @internal\n * Update a Reactive's using the properties of an object or other Reactive.\n * Also works for Signals.\n * @example\n * // Update a Reactive with Object.assign()-like syntax:\n * const r = reactive({ name: \"Alice\" });\n * update(r, { name: \"Bob\" });\n * update(r, { age: 42 }); // property 'age' does not exist in type '{ name?: string }'\n * update(r, 2); // '2' has no properties in common with '{ name?: string }'\n * console.log(r.name.value); // \"Bob\"\n *\n * @example\n * // Update a Reactive with the properties of another Reactive:\n * const A = reactive({ name: \"Alice\" });\n * const B = reactive({ name: \"Bob\", age: 42 });\n * update(A, B);\n * console.log(`${A.name} is ${A.age}`); // \"Bob is 42\"\n *\n * @example\n * // Update a signal with assign()-like syntax:\n * const s = signal(42);\n * update(s, \"hi\"); // Argument type 'string' not assignable to type 'number'\n * update(s, {}); // Argument type '{}' not assignable to type 'number'\n * update(s, 43);\n * console.log(s.value); // 43\n *\n * @param obj The Reactive or Signal to be updated\n * @param update The value, Signal, object or Reactive to update `obj` to match\n * @param overwrite If `true`, any properties `obj` missing from `update` are set to `undefined`\n */\n/*\nexport function update<T extends SignalOrReactive>(\n\tobj: T,\n\tupdate: Partial<Unwrap<T>>,\n\toverwrite = false\n) {\n\tif (obj instanceof Signal) {\n\t\tobj.value = peekValue(update);\n\t} else {\n\t\tfor (let i in update) {\n\t\t\tif (i in obj) {\n\t\t\t\tobj[i].value = peekValue(update[i]);\n\t\t\t} else {\n\t\t\t\tlet sig = signal(peekValue(update[i]));\n\t\t\t\tsig[KEY] = i;\n\t\t\t\tobj[i] = sig;\n\t\t\t}\n\t\t}\n\t\tif (overwrite) {\n\t\t\tfor (let i in obj) {\n\t\t\t\tif (!(i in update)) {\n\t\t\t\t\tobj[i].value = undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n*/\n"],"names":["oldNotify","currentComponent","finishUpdate","DEVTOOLS_ENABLED","window","__PREACT_SIGNALS_DEVTOOLS__","effectsQueue","domQueue","effect","this","_notify","hook","hookName","hookFn","options","bind","setCurrentUpdater","updater","_start","SignalValue","_ref","_this","data","currentSignal","useSignal","value","_useMemo","useMemo","self","v","__v","__","__c","_updateFlags","wrappedSignal","computed","s","isText","Array","isArray","isValidElement","dispose","notifyDomUpdates","__e","nodeType","oldDispose","_updater","_dispose","call","peek","displayName","Object","defineProperties","Signal","prototype","constructor","configurable","undefined","type","props","get","__b","old","vnode","exitComponent","signalProps","i","__np","enterComponent","Fragment","component","update","_callback","setState","createUpdater","error","oldVNode","dom","renderedProps","updaters","_updaters","prop","signal","createPropUpdater","_update","propSignal","setAsProperty","ownerSVGElement","changeSignal","newSignal","newProps","setAttribute","removeAttribute","index","Component","shouldComponentUpdate","state","hasSignals","_sources","__f","u","hasHooksState","useState","useComputed","compute","$compute","useRef","current","deferEffects","requestAnimationFrame","setTimeout","callback","done","clearTimeout","timeout","cancelAnimationFrame","raf","deferDomUpdates","cb","queueMicrotask","flushEffects","batch","inst","shift","notifyEffects","push","flushDomUpdates","useSignalEffect","useEffect"],"mappings":"iVAiCA,IAOIA,EAiBAC,EACAC,EAzBEC,EACa,oBAAXC,UAA4BA,OAAOC,4BAO1CC,EAA8B,GAC9BC,EAA0B,GAK3BC,EAAO,WACNR,EAAYS,KAAKC,CAClB,EAFAF,GAKA,SAASG,EAA6BC,EAAaC,GAElDC,EAAQF,GAAYC,EAAOE,KAAK,KAAMD,EAAQF,IAAc,WAAO,EAC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js","sources":["../src/index.ts"],"sourcesContent":["import { options, Component, isValidElement, Fragment } from \"preact\";\nimport { useRef, useMemo, useEffect, useState } from \"preact/hooks\";\nimport {\n\tsignal,\n\tcomputed,\n\tbatch,\n\teffect,\n\tSignal,\n\ttype ReadonlySignal,\n\tuntracked,\n\tSignalOptions,\n\tEffectOptions,\n} from \"@preact/signals-core\";\nimport {\n\tVNode,\n\tOptionsTypes,\n\tHookFn,\n\tEffect,\n\tPropertyUpdater,\n\tAugmentedComponent,\n\tAugmentedElement as Element,\n} from \"./internal\";\n\nexport {\n\tsignal,\n\tcomputed,\n\tbatch,\n\teffect,\n\tSignal,\n\ttype ReadonlySignal,\n\tuntracked,\n};\n\nconst DEVTOOLS_ENABLED =\n\ttypeof window !== \"undefined\" && !!window.__PREACT_SIGNALS_DEVTOOLS__;\n\nconst HAS_PENDING_UPDATE = 1 << 0;\nconst HAS_HOOK_STATE = 1 << 1;\nconst HAS_COMPUTEDS = 1 << 2;\n\nlet oldNotify: (this: Effect) => void,\n\teffectsQueue: Array<Effect> = [],\n\tdomQueue: Array<Effect> = [];\n\n// Capture the original `Effect.prototype._notify` method so that we can install\n// custom `._notify`s for each different use-case but still call the original\n// implementation in the end. Dispose the temporary effect immediately afterwards.\neffect(function (this: Effect) {\n\toldNotify = this._notify;\n})();\n\n// Install a Preact options hook\nfunction hook<T extends OptionsTypes>(hookName: T, hookFn: HookFn<T>) {\n\t// @ts-ignore-next-line private options hooks usage\n\toptions[hookName] = hookFn.bind(null, options[hookName] || (() => {}));\n}\n\nlet currentComponent: AugmentedComponent | undefined;\nlet finishUpdate: (() => void) | undefined;\n\nfunction setCurrentUpdater(updater?: Effect) {\n\t// end tracking for the current update:\n\tif (finishUpdate) finishUpdate();\n\t// start tracking the new update:\n\tfinishUpdate = updater && updater._start();\n}\n\nfunction createUpdater(update: () => void, name: string) {\n\tlet updater!: Effect;\n\teffect(\n\t\tfunction (this: Effect) {\n\t\t\tupdater = this;\n\t\t},\n\t\t{ name }\n\t);\n\tupdater._callback = update;\n\treturn updater;\n}\n\n/** @todo This may be needed for complex prop value detection. */\n// function isSignalValue(value: any): value is Signal {\n// \tif (typeof value !== \"object\" || value == null) return false;\n// \tif (value instanceof Signal) return true;\n// \t// @TODO: uncomment this when we land Reactive (ideally behind a brand check)\n// \t// for (let i in value) if (value[i] instanceof Signal) return true;\n// \treturn false;\n// }\n\n/**\n * A wrapper component that renders a Signal directly as a Text node.\n * @todo: in Preact 11, just decorate Signal with `type:null`\n */\nfunction SignalValue(this: AugmentedComponent, { data }: { data: Signal }) {\n\t// hasComputeds.add(this);\n\n\t// Store the props.data signal in another signal so that\n\t// passing a new signal reference re-runs the text computed:\n\tconst currentSignal = useSignal(data);\n\tcurrentSignal.value = data;\n\n\tconst [isText, s] = useMemo(() => {\n\t\tlet self = this;\n\t\t// mark the parent component as having computeds so it gets optimized\n\t\tlet v = this.__v;\n\t\twhile ((v = v.__!)) {\n\t\t\tif (v.__c) {\n\t\t\t\tv.__c._updateFlags |= HAS_COMPUTEDS;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tconst wrappedSignal = computed(() => {\n\t\t\tlet s = currentSignal.value.value;\n\t\t\treturn s === 0 ? 0 : s === true ? \"\" : s || \"\";\n\t\t});\n\n\t\tconst isText = computed(\n\t\t\t() =>\n\t\t\t\t!Array.isArray(wrappedSignal.value) &&\n\t\t\t\t!isValidElement(wrappedSignal.value)\n\t\t);\n\t\t// Update text nodes directly without rerendering when the new value\n\t\t// is also text.\n\t\tconst dispose = effect(function (this: Effect) {\n\t\t\tthis._notify = notifyDomUpdates;\n\n\t\t\t// Subscribe to wrappedSignal updates only when its values are text...\n\t\t\tif (isText.value) {\n\t\t\t\t// ...but regardless of `self.base`'s current value, as it can be\n\t\t\t\t// undefined before mounting or a non-text node. In both of those cases\n\t\t\t\t// the update gets handled by a full rerender.\n\t\t\t\tconst value = wrappedSignal.value;\n\t\t\t\tif (self.__v && self.__v.__e && self.__v.__e.nodeType === 3) {\n\t\t\t\t\t(self.__v.__e as Text).data = value;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// Piggyback this._updater's disposal to ensure that the text updater effect\n\t\t// above also gets disposed on unmount.\n\t\tconst oldDispose = this._updater!._dispose;\n\t\tthis._updater!._dispose = function () {\n\t\t\tdispose();\n\t\t\toldDispose.call(this);\n\t\t};\n\n\t\treturn [isText, wrappedSignal];\n\t}, []);\n\n\t// Rerender the component whenever `data.value` changes from a VNode\n\t// to another VNode, from text to a VNode, or from a VNode to text.\n\t// That is, everything else except text-to-text updates.\n\t//\n\t// This also ensures that the backing DOM node types gets updated to\n\t// text nodes and back when needed.\n\t//\n\t// For text-to-text updates, `.peek()` is used to skip full rerenders,\n\t// leaving them to the optimized path above.\n\treturn isText.value ? s.peek() : s.value;\n}\n\nSignalValue.displayName = \"ReactiveTextNode\";\n\nObject.defineProperties(Signal.prototype, {\n\tconstructor: { configurable: true, value: undefined },\n\ttype: { configurable: true, value: SignalValue },\n\tprops: {\n\t\tconfigurable: true,\n\t\tget() {\n\t\t\treturn { data: this };\n\t\t},\n\t},\n\t// Setting a VNode's _depth to 1 forces Preact to clone it before modifying:\n\t// https://github.com/preactjs/preact/blob/d7a433ee8463a7dc23a05111bb47de9ec729ad4d/src/diff/children.js#L77\n\t// @todo remove this for Preact 11\n\t__b: { configurable: true, value: 1 },\n});\n\n/** Inject low-level property/attribute bindings for Signals into Preact's diff */\nhook(OptionsTypes.DIFF, (old, vnode) => {\n\tif (typeof vnode.type === \"string\") {\n\t\tlet signalProps: Record<string, any> | undefined;\n\n\t\tlet props = vnode.props;\n\t\tfor (let i in props) {\n\t\t\tif (i === \"children\") continue;\n\n\t\t\tlet value = props[i];\n\t\t\tif (value instanceof Signal) {\n\t\t\t\tif (!signalProps) vnode.__np = signalProps = {};\n\t\t\t\tsignalProps[i] = value;\n\t\t\t\tprops[i] = value.peek();\n\t\t\t}\n\t\t}\n\t}\n\n\told(vnode);\n});\n\n/** Set up Updater before rendering a component */\nhook(OptionsTypes.RENDER, (old, vnode) => {\n\t// Ignore the Fragment inserted by preact.createElement().\n\tif (vnode.type !== Fragment) {\n\t\tsetCurrentUpdater();\n\n\t\tlet updater: Effect | undefined;\n\n\t\tlet component = vnode.__c;\n\t\tif (component) {\n\t\t\tcomponent._updateFlags &= ~HAS_PENDING_UPDATE;\n\n\t\t\tupdater = component._updater;\n\t\t\tif (updater === undefined) {\n\t\t\t\tcomponent._updater = updater = createUpdater(\n\t\t\t\t\t() => {\n\t\t\t\t\t\tif (DEVTOOLS_ENABLED) updater!._debugCallback?.call(updater);\n\t\t\t\t\t\tcomponent._updateFlags |= HAS_PENDING_UPDATE;\n\t\t\t\t\t\tcomponent.setState({});\n\t\t\t\t\t},\n\t\t\t\t\ttypeof vnode.type === \"function\"\n\t\t\t\t\t\t? vnode.type.displayName || vnode.type.name\n\t\t\t\t\t\t: \"\"\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tcurrentComponent = component;\n\t\tsetCurrentUpdater(updater);\n\t}\n\n\told(vnode);\n});\n\n/** Finish current updater if a component errors */\nhook(OptionsTypes.CATCH_ERROR, (old, error, vnode, oldVNode) => {\n\tsetCurrentUpdater();\n\tcurrentComponent = undefined;\n\told(error, vnode, oldVNode);\n});\n\n/** Finish current updater after rendering any VNode */\nhook(OptionsTypes.DIFFED, (old, vnode) => {\n\tsetCurrentUpdater();\n\tcurrentComponent = undefined;\n\n\tlet dom: Element;\n\n\t// vnode._dom is undefined during string rendering,\n\t// so we use this to skip prop subscriptions during SSR.\n\tif (typeof vnode.type === \"string\" && (dom = vnode.__e as Element)) {\n\t\tlet props = vnode.__np;\n\t\tlet renderedProps = vnode.props;\n\t\tif (props) {\n\t\t\tlet updaters = dom._updaters;\n\t\t\tif (updaters) {\n\t\t\t\tfor (let prop in updaters) {\n\t\t\t\t\tlet updater = updaters[prop];\n\t\t\t\t\tif (updater !== undefined && !(prop in props)) {\n\t\t\t\t\t\tupdater._dispose();\n\t\t\t\t\t\t// @todo we could just always invoke _dispose() here\n\t\t\t\t\t\tupdaters[prop] = undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tupdaters = {};\n\t\t\t\tdom._updaters = updaters;\n\t\t\t}\n\t\t\tfor (let prop in props) {\n\t\t\t\tlet updater = updaters[prop];\n\t\t\t\tlet signal = props[prop];\n\t\t\t\tif (updater === undefined) {\n\t\t\t\t\tupdater = createPropUpdater(dom, prop, signal, renderedProps);\n\t\t\t\t\tupdaters[prop] = updater;\n\t\t\t\t} else {\n\t\t\t\t\tupdater._update(signal, renderedProps);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\told(vnode);\n});\n\nfunction createPropUpdater(\n\tdom: Element,\n\tprop: string,\n\tpropSignal: Signal,\n\tprops: Record<string, any>\n): PropertyUpdater {\n\tconst setAsProperty =\n\t\tprop in dom &&\n\t\t// SVG elements need to go through `setAttribute` because they\n\t\t// expect things like SVGAnimatedTransformList instead of strings.\n\t\t// @ts-ignore\n\t\tdom.ownerSVGElement === undefined;\n\n\tconst changeSignal = signal(propSignal);\n\treturn {\n\t\t_update: (newSignal: Signal, newProps: typeof props) => {\n\t\t\tchangeSignal.value = newSignal;\n\t\t\tprops = newProps;\n\t\t},\n\t\t_dispose: effect(function (this: Effect) {\n\t\t\tthis._notify = notifyDomUpdates;\n\t\t\tconst value = changeSignal.value.value;\n\t\t\t// If Preact just rendered this value, don't render it again:\n\t\t\tif (props[prop] === value) return;\n\t\t\tprops[prop] = value;\n\t\t\tif (setAsProperty) {\n\t\t\t\t// @ts-ignore-next-line silly\n\t\t\t\tdom[prop] = value;\n\t\t\t\t// Match Preact's attribute handling: data-* and aria-* attributes\n\t\t\t\t// https://github.com/preactjs/preact/blob/main/src/diff/props.js#L132\n\t\t\t} else if (value != null && (value !== false || prop[4] === \"-\")) {\n\t\t\t\tdom.setAttribute(prop, value);\n\t\t\t} else {\n\t\t\t\tdom.removeAttribute(prop);\n\t\t\t}\n\t\t}),\n\t};\n}\n\n/** Unsubscribe from Signals when unmounting components/vnodes */\nhook(OptionsTypes.UNMOUNT, (old, vnode: VNode) => {\n\tif (typeof vnode.type === \"string\") {\n\t\tlet dom = vnode.__e as Element | undefined;\n\t\t// vnode._dom is undefined during string rendering\n\t\tif (dom) {\n\t\t\tconst updaters = dom._updaters;\n\t\t\tif (updaters) {\n\t\t\t\tdom._updaters = undefined;\n\t\t\t\tfor (let prop in updaters) {\n\t\t\t\t\tlet updater = updaters[prop];\n\t\t\t\t\tif (updater) updater._dispose();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tlet component = vnode.__c;\n\t\tif (component) {\n\t\t\tconst updater = component._updater;\n\t\t\tif (updater) {\n\t\t\t\tcomponent._updater = undefined;\n\t\t\t\tupdater._dispose();\n\t\t\t}\n\t\t}\n\t}\n\told(vnode);\n});\n\n/** Mark components that use hook state so we can skip sCU optimization. */\nhook(OptionsTypes.HOOK, (old, component, index, type) => {\n\tif (type < 3 || type === 9)\n\t\t(component as AugmentedComponent)._updateFlags |= HAS_HOOK_STATE;\n\told(component, index, type);\n});\n\n/**\n * Auto-memoize components that use Signals/Computeds.\n * Note: Does _not_ optimize components that use hook/class state.\n */\nComponent.prototype.shouldComponentUpdate = function (\n\tthis: AugmentedComponent,\n\tprops,\n\tstate\n) {\n\t// @todo: Once preactjs/preact#3671 lands, this could just use `currentUpdater`:\n\tconst updater = this._updater;\n\tconst hasSignals = updater && updater._sources !== undefined;\n\n\t// If this is a component using state, rerender\n\t// @ts-ignore\n\tfor (let i in state) return true;\n\n\tif (this.__f || (typeof this.u == \"boolean\" && this.u === true)) {\n\t\tconst hasHooksState = this._updateFlags & HAS_HOOK_STATE;\n\t\t// if this component used no signals or computeds and no hooks state, update:\n\t\tif (!hasSignals && !hasHooksState && !(this._updateFlags & HAS_COMPUTEDS))\n\t\t\treturn true;\n\n\t\t// if there is a pending re-render triggered from Signals,\n\t\t// or if there is hooks state, update:\n\t\tif (this._updateFlags & HAS_PENDING_UPDATE) return true;\n\t} else {\n\t\t// if this component used no signals or computeds, update:\n\t\tif (!hasSignals && !(this._updateFlags & HAS_COMPUTEDS)) return true;\n\n\t\t// if there is a pending re-render triggered from Signals,\n\t\t// or if there is hooks state, update:\n\t\tif (this._updateFlags & (HAS_PENDING_UPDATE | HAS_HOOK_STATE)) return true;\n\t}\n\n\t// if any non-Signal props changed, update:\n\tfor (let i in props) {\n\t\tif (i !== \"__source\" && props[i] !== this.props[i]) return true;\n\t}\n\tfor (let i in this.props) if (!(i in props)) return true;\n\n\t// this is a purely Signal-driven component, don't update:\n\treturn false;\n};\n\nexport function useSignal<T>(value: T, options?: SignalOptions<T>): Signal<T>;\nexport function useSignal<T = undefined>(): Signal<T | undefined>;\nexport function useSignal<T>(value?: T, options?: SignalOptions<T>) {\n\treturn useState(() =>\n\t\tsignal<T | undefined>(value, options as SignalOptions)\n\t)[0];\n}\n\nexport function useComputed<T>(compute: () => T, options?: SignalOptions<T>) {\n\tconst $compute = useRef(compute);\n\t$compute.current = compute;\n\t(currentComponent as AugmentedComponent)._updateFlags |= HAS_COMPUTEDS;\n\treturn useMemo(() => computed<T>(() => $compute.current(), options), []);\n}\n\nfunction safeRaf(callback: () => void) {\n\tconst done = () => {\n\t\tclearTimeout(timeout);\n\t\tcancelAnimationFrame(raf);\n\t\tcallback();\n\t};\n\n\tconst timeout = setTimeout(done, 35);\n\tconst raf = requestAnimationFrame(done);\n}\n\nconst deferEffects =\n\ttypeof requestAnimationFrame === \"undefined\" ? setTimeout : safeRaf;\n\nconst deferDomUpdates = (cb: any) => {\n\tqueueMicrotask(() => {\n\t\tqueueMicrotask(cb);\n\t});\n};\n\nfunction flushEffects() {\n\tbatch(() => {\n\t\tlet inst: Effect | undefined;\n\t\twhile ((inst = effectsQueue.shift())) {\n\t\t\toldNotify.call(inst);\n\t\t}\n\t});\n}\n\nfunction notifyEffects(this: Effect) {\n\tif (effectsQueue.push(this) === 1) {\n\t\t(options.requestAnimationFrame || deferEffects)(flushEffects);\n\t}\n}\n\nfunction flushDomUpdates() {\n\tbatch(() => {\n\t\tlet inst: Effect | undefined;\n\t\twhile ((inst = domQueue.shift())) {\n\t\t\toldNotify.call(inst);\n\t\t}\n\t});\n}\n\nfunction notifyDomUpdates(this: Effect) {\n\tif (domQueue.push(this) === 1) {\n\t\t(options.requestAnimationFrame || deferDomUpdates)(flushDomUpdates);\n\t}\n}\n\nexport function useSignalEffect(\n\tcb: () => void | (() => void),\n\toptions?: EffectOptions\n) {\n\tconst callback = useRef(cb);\n\tcallback.current = cb;\n\n\tuseEffect(() => {\n\t\treturn effect(function (this: Effect) {\n\t\t\tthis._notify = notifyEffects;\n\t\t\treturn callback.current();\n\t\t}, options);\n\t}, []);\n}\n\n/**\n * @todo Determine which Reactive implementation we'll be using.\n * @internal\n */\n// export function useReactive<T extends object>(value: T): Reactive<T> {\n// \treturn useMemo(() => reactive<T>(value), []);\n// }\n\n/**\n * @internal\n * Update a Reactive's using the properties of an object or other Reactive.\n * Also works for Signals.\n * @example\n * // Update a Reactive with Object.assign()-like syntax:\n * const r = reactive({ name: \"Alice\" });\n * update(r, { name: \"Bob\" });\n * update(r, { age: 42 }); // property 'age' does not exist in type '{ name?: string }'\n * update(r, 2); // '2' has no properties in common with '{ name?: string }'\n * console.log(r.name.value); // \"Bob\"\n *\n * @example\n * // Update a Reactive with the properties of another Reactive:\n * const A = reactive({ name: \"Alice\" });\n * const B = reactive({ name: \"Bob\", age: 42 });\n * update(A, B);\n * console.log(`${A.name} is ${A.age}`); // \"Bob is 42\"\n *\n * @example\n * // Update a signal with assign()-like syntax:\n * const s = signal(42);\n * update(s, \"hi\"); // Argument type 'string' not assignable to type 'number'\n * update(s, {}); // Argument type '{}' not assignable to type 'number'\n * update(s, 43);\n * console.log(s.value); // 43\n *\n * @param obj The Reactive or Signal to be updated\n * @param update The value, Signal, object or Reactive to update `obj` to match\n * @param overwrite If `true`, any properties `obj` missing from `update` are set to `undefined`\n */\n/*\nexport function update<T extends SignalOrReactive>(\n\tobj: T,\n\tupdate: Partial<Unwrap<T>>,\n\toverwrite = false\n) {\n\tif (obj instanceof Signal) {\n\t\tobj.value = peekValue(update);\n\t} else {\n\t\tfor (let i in update) {\n\t\t\tif (i in obj) {\n\t\t\t\tobj[i].value = peekValue(update[i]);\n\t\t\t} else {\n\t\t\t\tlet sig = signal(peekValue(update[i]));\n\t\t\t\tsig[KEY] = i;\n\t\t\t\tobj[i] = sig;\n\t\t\t}\n\t\t}\n\t\tif (overwrite) {\n\t\t\tfor (let i in obj) {\n\t\t\t\tif (!(i in update)) {\n\t\t\t\t\tobj[i].value = undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n*/\n"],"names":["oldNotify","currentComponent","finishUpdate","DEVTOOLS_ENABLED","window","__PREACT_SIGNALS_DEVTOOLS__","effectsQueue","domQueue","effect","this","_notify","hook","hookName","hookFn","options","bind","setCurrentUpdater","updater","_start","SignalValue","_ref","_this","data","currentSignal","useSignal","value","_useMemo","useMemo","self","v","__v","__","__c","_updateFlags","wrappedSignal","computed","s","isText","Array","isArray","isValidElement","dispose","notifyDomUpdates","__e","nodeType","oldDispose","_updater","_dispose","call","peek","displayName","Object","defineProperties","Signal","prototype","constructor","configurable","undefined","type","props","get","__b","old","vnode","signalProps","i","__np","Fragment","component","update","name","_callback","createUpdater","_updater$_debugCallba","_debugCallback","setState","error","oldVNode","dom","renderedProps","updaters","_updaters","prop","signal","createPropUpdater","_update","propSignal","setAsProperty","ownerSVGElement","changeSignal","newSignal","newProps","setAttribute","removeAttribute","index","Component","shouldComponentUpdate","state","hasSignals","_sources","__f","u","hasHooksState","useState","useComputed","compute","$compute","useRef","current","deferEffects","requestAnimationFrame","setTimeout","callback","done","clearTimeout","timeout","cancelAnimationFrame","raf","deferDomUpdates","cb","queueMicrotask","flushEffects","batch","inst","shift","notifyEffects","push","flushDomUpdates","useSignalEffect","useEffect"],"mappings":"iVAiCA,IAOIA,EAiBAC,EACAC,E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zH,EAAO,WACbC,KAAKC,EAAUmH,EACf,OAAOb,EAASJ,SACjB,EAAG9F,EACJ,EAAG,GACJ,QAAA0F,YAAAhF,UAAAwG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@preact/signals",
3
- "version": "2.5.1",
3
+ "version": "2.6.1",
4
4
  "license": "MIT",
5
5
  "description": "Manage state with style in Preact",
6
6
  "keywords": [],
@@ -50,7 +50,7 @@
50
50
  "utils/src"
51
51
  ],
52
52
  "dependencies": {
53
- "@preact/signals-core": "^1.12.0"
53
+ "@preact/signals-core": "^1.12.2"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "preact": ">= 10.25.0 || >=11.0.0-0"
package/src/index.ts CHANGED
@@ -65,11 +65,14 @@ function setCurrentUpdater(updater?: Effect) {
65
65
  finishUpdate = updater && updater._start();
66
66
  }
67
67
 
68
- function createUpdater(update: () => void) {
68
+ function createUpdater(update: () => void, name: string) {
69
69
  let updater!: Effect;
70
- effect(function (this: Effect) {
71
- updater = this;
72
- });
70
+ effect(
71
+ function (this: Effect) {
72
+ updater = this;
73
+ },
74
+ { name }
75
+ );
73
76
  updater._callback = update;
74
77
  return updater;
75
78
  }
@@ -175,10 +178,6 @@ Object.defineProperties(Signal.prototype, {
175
178
 
176
179
  /** Inject low-level property/attribute bindings for Signals into Preact's diff */
177
180
  hook(OptionsTypes.DIFF, (old, vnode) => {
178
- if (DEVTOOLS_ENABLED && typeof vnode.type === "function") {
179
- window.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();
180
- }
181
-
182
181
  if (typeof vnode.type === "string") {
183
182
  let signalProps: Record<string, any> | undefined;
184
183
 
@@ -200,15 +199,11 @@ hook(OptionsTypes.DIFF, (old, vnode) => {
200
199
 
201
200
  /** Set up Updater before rendering a component */
202
201
  hook(OptionsTypes.RENDER, (old, vnode) => {
203
- if (DEVTOOLS_ENABLED && typeof vnode.type === "function") {
204
- window.__PREACT_SIGNALS_DEVTOOLS__.enterComponent(vnode);
205
- }
206
-
207
202
  // Ignore the Fragment inserted by preact.createElement().
208
203
  if (vnode.type !== Fragment) {
209
204
  setCurrentUpdater();
210
205
 
211
- let updater;
206
+ let updater: Effect | undefined;
212
207
 
213
208
  let component = vnode.__c;
214
209
  if (component) {
@@ -216,10 +211,16 @@ hook(OptionsTypes.RENDER, (old, vnode) => {
216
211
 
217
212
  updater = component._updater;
218
213
  if (updater === undefined) {
219
- component._updater = updater = createUpdater(() => {
220
- component._updateFlags |= HAS_PENDING_UPDATE;
221
- component.setState({});
222
- });
214
+ component._updater = updater = createUpdater(
215
+ () => {
216
+ if (DEVTOOLS_ENABLED) updater!._debugCallback?.call(updater);
217
+ component._updateFlags |= HAS_PENDING_UPDATE;
218
+ component.setState({});
219
+ },
220
+ typeof vnode.type === "function"
221
+ ? vnode.type.displayName || vnode.type.name
222
+ : ""
223
+ );
223
224
  }
224
225
  }
225
226
 
@@ -232,10 +233,6 @@ hook(OptionsTypes.RENDER, (old, vnode) => {
232
233
 
233
234
  /** Finish current updater if a component errors */
234
235
  hook(OptionsTypes.CATCH_ERROR, (old, error, vnode, oldVNode) => {
235
- if (DEVTOOLS_ENABLED) {
236
- window.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();
237
- }
238
-
239
236
  setCurrentUpdater();
240
237
  currentComponent = undefined;
241
238
  old(error, vnode, oldVNode);
@@ -243,10 +240,6 @@ hook(OptionsTypes.CATCH_ERROR, (old, error, vnode, oldVNode) => {
243
240
 
244
241
  /** Finish current updater after rendering any VNode */
245
242
  hook(OptionsTypes.DIFFED, (old, vnode) => {
246
- if (DEVTOOLS_ENABLED && typeof vnode.type === "function") {
247
- window.__PREACT_SIGNALS_DEVTOOLS__.exitComponent();
248
- }
249
-
250
243
  setCurrentUpdater();
251
244
  currentComponent = undefined;
252
245
 
package/src/internal.d.ts CHANGED
@@ -3,6 +3,7 @@ import { Signal } from "@preact/signals-core";
3
3
  import type { SignalsDevToolsAPI } from "../../debug/src/devtools";
4
4
 
5
5
  export interface Effect {
6
+ _debugCallback?: () => void;
6
7
  _sources: object | undefined;
7
8
  _start(): () => void;
8
9
  _notify: () => void;
@@ -6,12 +6,18 @@ interface ShowProps<T = boolean> {
6
6
  children: ComponentChildren | ((value: NonNullable<T>) => ComponentChildren);
7
7
  }
8
8
  export declare function Show<T = boolean>(props: ShowProps<T>): ComponentChildren | null;
9
+ export declare namespace Show {
10
+ var displayName: string;
11
+ }
9
12
  interface ForProps<T> {
10
13
  each: Signal<Array<T>> | ReadonlySignal<Array<T>> | (() => Signal<Array<T>> | ReadonlySignal<Array<T>>);
11
14
  fallback?: ComponentChildren;
12
15
  children: (value: T, index: number) => ComponentChildren;
13
16
  }
14
17
  export declare function For<T>(props: ForProps<T>): ComponentChildren | null;
18
+ export declare namespace For {
19
+ var displayName: string;
20
+ }
15
21
  export declare function useLiveSignal<T>(value: T): Signal<T>;
16
22
  export declare function useSignalRef<T>(value: T): Signal<T> & {
17
23
  current: T;
@@ -1 +1 @@
1
- var n=require("@preact/signals"),r=require("preact"),t=require("preact/hooks"),e=function(n){return"function"==typeof n.children?n.children(n.v,n.i):n.children},u={configurable:!0,get:function(){return this.value},set:function(n){this.value=n}};exports.For=function(n){var u=t.useMemo(function(){return new Map},[]),i=("function"==typeof n.each?n.each():n.each).value;if(!i.length)return n.fallback||null;var o=new Set(u.keys()),c=i.map(function(t,i){o.delete(t);if(!u.has(t)){var c=r.createElement(e,{v:t,i:i,children:n.children});u.set(t,c);return c}return u.get(t)});o.forEach(function(n){u.delete(n)});return r.createElement(r.Fragment,null,c)};exports.Show=function(n){var t="function"==typeof n.when?n.when():n.when.value;if(!t)return n.fallback||null;else return r.createElement(e,{v:t,children:n.children})};exports.useLiveSignal=function(r){var t=n.useSignal(r);if(t.peek()!==r)t.value=r;return t};exports.useSignalRef=function(r){var t=n.useSignal(r);if(!("current"in t))Object.defineProperty(t,"current",u);return t};//# sourceMappingURL=utils.js.map
1
+ var r=require("@preact/signals"),n=require("preact"),t=require("preact/hooks"),e=function(r){return"function"==typeof r.children?r.children(r.v,r.i):r.children};e.displayName="Item";function u(r){var t="function"==typeof r.when?r.when():r.when.value;if(!t)return r.fallback||null;else return n.createElement(e,{v:t,children:r.children})}u.displayName="Show";function i(r){var u=t.useMemo(function(){return new Map},[]),i=("function"==typeof r.each?r.each():r.each).value;if(!i.length)return r.fallback||null;var o=new Set(u.keys()),c=i.map(function(t,i){o.delete(t);if(!u.has(t)){var c=n.createElement(e,{v:t,i:i,children:r.children});u.set(t,c);return c}return u.get(t)});o.forEach(function(r){u.delete(r)});return n.createElement(n.Fragment,null,c)}i.displayName="For";var o={configurable:!0,get:function(){return this.value},set:function(r){this.value=r}};exports.For=i;exports.Show=u;exports.useLiveSignal=function(n){var t=r.useSignal(n);if(t.peek()!==n)t.value=n;return t};exports.useSignalRef=function(n){var t=r.useSignal(n);if(!("current"in t))Object.defineProperty(t,"current",o);return t};//# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../src/index.tsx"],"sourcesContent":["import { ReadonlySignal, Signal } from \"@preact/signals-core\";\nimport { useSignal } from \"@preact/signals\";\nimport { Fragment, createElement, ComponentChildren } from \"preact\";\nimport { useMemo } from \"preact/hooks\";\n\ninterface ShowProps<T = boolean> {\n\twhen: Signal<T> | ReadonlySignal<T> | (() => T);\n\tfallback?: ComponentChildren;\n\tchildren: ComponentChildren | ((value: NonNullable<T>) => ComponentChildren);\n}\n\nconst Item = (props: any) => {\n\treturn typeof props.children === \"function\"\n\t\t? props.children(props.v, props.i)\n\t\t: props.children;\n};\n\nexport function Show<T = boolean>(\n\tprops: ShowProps<T>\n): ComponentChildren | null {\n\tconst value =\n\t\ttypeof props.when === \"function\" ? props.when() : props.when.value;\n\tif (!value) return props.fallback || null;\n\treturn <Item v={value} children={props.children} />;\n}\n\ninterface ForProps<T> {\n\teach:\n\t\t| Signal<Array<T>>\n\t\t| ReadonlySignal<Array<T>>\n\t\t| (() => Signal<Array<T>> | ReadonlySignal<Array<T>>);\n\tfallback?: ComponentChildren;\n\tchildren: (value: T, index: number) => ComponentChildren;\n}\n\nexport function For<T>(props: ForProps<T>): ComponentChildren | null {\n\tconst cache = useMemo(() => new Map(), []);\n\tlet list = (\n\t\t(typeof props.each === \"function\" ? props.each() : props.each) as Signal<\n\t\t\tArray<T>\n\t\t>\n\t).value;\n\n\tif (!list.length) return props.fallback || null;\n\n\tconst removed = new Set(cache.keys());\n\n\tconst items = list.map((value, key) => {\n\t\tremoved.delete(value);\n\t\tif (!cache.has(value)) {\n\t\t\tconst result = <Item v={value} i={key} children={props.children} />;\n\t\t\tcache.set(value, result);\n\t\t\treturn result;\n\t\t}\n\t\treturn cache.get(value);\n\t});\n\n\tremoved.forEach(value => {\n\t\tcache.delete(value);\n\t});\n\n\treturn createElement(Fragment, null, items);\n}\n\nexport function useLiveSignal<T>(value: T): Signal<T> {\n\tconst s = useSignal(value);\n\tif (s.peek() !== value) s.value = value;\n\treturn s;\n}\n\nexport function useSignalRef<T>(value: T): Signal<T> & { current: T } {\n\tconst ref = useSignal(value) as Signal<T> & { current: T };\n\tif (!(\"current\" in ref))\n\t\tObject.defineProperty(ref, \"current\", refSignalProto);\n\treturn ref;\n}\nconst refSignalProto = {\n\tconfigurable: true,\n\tget(this: Signal) {\n\t\treturn this.value;\n\t},\n\tset(this: Signal, v: any) {\n\t\tthis.value = v;\n\t},\n};\n"],"names":["signals","require","preact","hooks","Item","props","children","v","i","refSignalProto","configurable","get","this","value","set","exports","For","cache","useMemo","Map","list","each","length","fallback","removed","Set","keys","items","map","key","has","result","createElement","forEach","Fragment","Show","when","useLiveSignal","s","useSignal","peek","useSignalRef","ref","Object","defineProperty"],"mappings":"AAWA,IAAAA,EAAAC,QAAA,mBAAAC,EAAAD,QAAA,UAAAE,EAAAF,QAAA,gBAAMG,EAAO,SAACC,GACb,MAAiC,mBAAnBA,EAAMC,SACjBD,EAAMC,SAASD,EAAME,EAAGF,EAAMG,GAC9BH,EAAMC,QACV,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AAWjC,GACvC,OAAOiC,CACR"}
1
+ {"version":3,"file":"utils.js","sources":["../src/index.tsx"],"sourcesContent":["import { ReadonlySignal, Signal } from \"@preact/signals-core\";\nimport { useSignal } from \"@preact/signals\";\nimport { Fragment, createElement, ComponentChildren } from \"preact\";\nimport { useMemo } from \"preact/hooks\";\n\ninterface ShowProps<T = boolean> {\n\twhen: Signal<T> | ReadonlySignal<T> | (() => T);\n\tfallback?: ComponentChildren;\n\tchildren: ComponentChildren | ((value: NonNullable<T>) => ComponentChildren);\n}\n\nconst Item = (props: any) => {\n\treturn typeof props.children === \"function\"\n\t\t? props.children(props.v, props.i)\n\t\t: props.children;\n};\n\nItem.displayName = \"Item\";\n\nexport function Show<T = boolean>(\n\tprops: ShowProps<T>\n): ComponentChildren | null {\n\tconst value =\n\t\ttypeof props.when === \"function\" ? props.when() : props.when.value;\n\tif (!value) return props.fallback || null;\n\treturn <Item v={value} children={props.children} />;\n}\n\nShow.displayName = \"Show\";\n\ninterface ForProps<T> {\n\teach:\n\t\t| Signal<Array<T>>\n\t\t| ReadonlySignal<Array<T>>\n\t\t| (() => Signal<Array<T>> | ReadonlySignal<Array<T>>);\n\tfallback?: ComponentChildren;\n\tchildren: (value: T, index: number) => ComponentChildren;\n}\n\nexport function For<T>(props: ForProps<T>): ComponentChildren | null {\n\tconst cache = useMemo(() => new Map(), []);\n\tlet list = (\n\t\t(typeof props.each === \"function\" ? props.each() : props.each) as Signal<\n\t\t\tArray<T>\n\t\t>\n\t).value;\n\n\tif (!list.length) return props.fallback || null;\n\n\tconst removed = new Set(cache.keys());\n\n\tconst items = list.map((value, key) => {\n\t\tremoved.delete(value);\n\t\tif (!cache.has(value)) {\n\t\t\tconst result = <Item v={value} i={key} children={props.children} />;\n\t\t\tcache.set(value, result);\n\t\t\treturn result;\n\t\t}\n\t\treturn cache.get(value);\n\t});\n\n\tremoved.forEach(value => {\n\t\tcache.delete(value);\n\t});\n\n\treturn createElement(Fragment, null, items);\n}\n\nFor.displayName = \"For\";\n\nexport function useLiveSignal<T>(value: T): Signal<T> {\n\tconst s = useSignal(value);\n\tif (s.peek() !== value) s.value = value;\n\treturn s;\n}\n\nexport function useSignalRef<T>(value: T): Signal<T> & { current: T } {\n\tconst ref = useSignal(value) as Signal<T> & { current: T };\n\tif (!(\"current\" in ref))\n\t\tObject.defineProperty(ref, \"current\", refSignalProto);\n\treturn ref;\n}\nconst refSignalProto = {\n\tconfigurable: true,\n\tget(this: Signal) {\n\t\treturn this.value;\n\t},\n\tset(this: Signal, v: any) {\n\t\tthis.value = v;\n\t},\n};\n"],"names":["Item","props","children","v","i","displayName","Show","value","when","fallback","createElement","For","cache","useMemo","Map","list","each","length","removed","Set","keys","items","map","key","has","result","set","get","forEach","Fragment","refSignalProto","configurable","this","exports","useLiveSignal","s","useSignal","peek","useSignalRef","ref","Object","defineProperty"],"mappings":"+EAWMA,EAAO,SAACC,GACb,MAAiC,mBAAnBA,EAAMC,SACjBD,EAAMC,SAASD,EAAME,EAAGF,EAAMG,GAC9BH,EAAMC,QACV,EAEAF,EAAKK,YAAc,OAEH,SAAAC,EACfL,GAEA,IAAMM,EACiB,mBAAfN,EAAMO,KAAsBP,EAAMO,OAASP,EAAMO,KAAKD,MAC9D,IAAKA,EAAO,OAAON,EAAMQ,UAAY,UACrC,OAAOC,gBAACV,EAAK,CAAAG,EAAGI,EAAOL,SAAUD,EAAMC,UACxC,CAEAI,EAAKD,YAAc,OAWb,SAAUM,EAAOV,GACtB,IAAMW,EAAQC,EAAAA,QAAQ,WAAA,OAAU,IAAAC,GAAK,EAAE,IACnCC,GACoB,mBAAfd,EAAMe,KAAsBf,EAAMe,OAASf,EAAMe,MAGxDT,MAEF,IAAKQ,EAAKE,OAAQ,OAAOhB,EAAMQ,UAAY,KAE3C,IAAMS,EAAU,IAAIC,IAAIP,EAAMQ,QAExBC,EAAQN,EAAKO,IAAI,SAACf,EAAOgB,GAC9BL,SAAeX,GACf,IAAKK,EAAMY,IAAIjB,GAAQ,CACtB,IAAMkB,EAASf,EAAAA,cAACV,EAAK,CAAAG,EAAGI,EAAOH,EAAGmB,EAAKrB,SAAUD,EAAMC,WACvDU,EAAMc,IAAInB,EAAOkB,GACjB,OAAOA,CACR,CACA,OAAOb,EAAMe,IAAIpB,EAClB,GAEAW,EAAQU,QAAQ,SAAArB,GACfK,EAAY,OAACL,EACd,GAEA,OAAOG,EAAaA,cAACmB,WAAU,KAAMR,EACtC,CAEAV,EAAIN,YAAc,MAclB,IAAMyB,EAAiB,CACtBC,cAAc,EACdJ,eACC,YAAYpB,KACb,EACAmB,IAAG,SAAevB,GACjB6B,KAAKzB,MAAQJ,CACd,GACA8B,QAAAtB,IAAAA,EAAAsB,QAAA3B,KAAAA,EAAA2B,QAAAC,cApBe,SAAiB3B,GAChC,IAAM4B,EAAIC,EAASA,UAAC7B,GACpB,GAAI4B,EAAEE,SAAW9B,EAAO4B,EAAE5B,MAAQA,EAClC,OAAO4B,CACR,EAgBCF,QAAAK,aAdK,SAA0B/B,GAC/B,IAAMgC,EAAMH,EAAAA,UAAU7B,GACtB,KAAM,YAAagC,GAClBC,OAAOC,eAAeF,EAAK,UAAWT,GACvC,OAAOS,CACR"}
@@ -1 +1 @@
1
- !function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@preact/signals"),require("preact"),require("preact/hooks")):"function"==typeof define&&define.amd?define(["exports","@preact/signals","preact","preact/hooks"],e):e((n||self).preactSignalsutils={},n.signals,n.preact,n.preactHooks)}(this,function(n,e,t,r){var i=function(n){return"function"==typeof n.children?n.children(n.v,n.i):n.children},u={configurable:!0,get:function(){return this.value},set:function(n){this.value=n}};n.For=function(n){var e=r.useMemo(function(){return new Map},[]),u=("function"==typeof n.each?n.each():n.each).value;if(!u.length)return n.fallback||null;var f=new Set(e.keys()),o=u.map(function(r,u){f.delete(r);if(!e.has(r)){var o=t.createElement(i,{v:r,i:u,children:n.children});e.set(r,o);return o}return e.get(r)});f.forEach(function(n){e.delete(n)});return t.createElement(t.Fragment,null,o)};n.Show=function(n){var e="function"==typeof n.when?n.when():n.when.value;if(!e)return n.fallback||null;else return t.createElement(i,{v:e,children:n.children})};n.useLiveSignal=function(n){var t=e.useSignal(n);if(t.peek()!==n)t.value=n;return t};n.useSignalRef=function(n){var t=e.useSignal(n);if(!("current"in t))Object.defineProperty(t,"current",u);return t}});//# sourceMappingURL=utils.min.js.map
1
+ !function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@preact/signals"),require("preact"),require("preact/hooks")):"function"==typeof define&&define.amd?define(["exports","@preact/signals","preact","preact/hooks"],e):e((n||self).preactSignalsutils={},n.signals,n.preact,n.preactHooks)}(this,function(n,e,t,r){var i=function(n){return"function"==typeof n.children?n.children(n.v,n.i):n.children};i.displayName="Item";function u(n){var e="function"==typeof n.when?n.when():n.when.value;if(!e)return n.fallback||null;else return t.createElement(i,{v:e,children:n.children})}u.displayName="Show";function o(n){var e=r.useMemo(function(){return new Map},[]),u=("function"==typeof n.each?n.each():n.each).value;if(!u.length)return n.fallback||null;var o=new Set(e.keys()),f=u.map(function(r,u){o.delete(r);if(!e.has(r)){var f=t.createElement(i,{v:r,i:u,children:n.children});e.set(r,f);return f}return e.get(r)});o.forEach(function(n){e.delete(n)});return t.createElement(t.Fragment,null,f)}o.displayName="For";var f={configurable:!0,get:function(){return this.value},set:function(n){this.value=n}};n.For=o;n.Show=u;n.useLiveSignal=function(n){var t=e.useSignal(n);if(t.peek()!==n)t.value=n;return t};n.useSignalRef=function(n){var t=e.useSignal(n);if(!("current"in t))Object.defineProperty(t,"current",f);return t}});//# sourceMappingURL=utils.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.min.js","sources":["../src/index.tsx"],"sourcesContent":["import { ReadonlySignal, Signal } from \"@preact/signals-core\";\nimport { useSignal } from \"@preact/signals\";\nimport { Fragment, createElement, ComponentChildren } from \"preact\";\nimport { useMemo } from \"preact/hooks\";\n\ninterface ShowProps<T = boolean> {\n\twhen: Signal<T> | ReadonlySignal<T> | (() => T);\n\tfallback?: ComponentChildren;\n\tchildren: ComponentChildren | ((value: NonNullable<T>) => ComponentChildren);\n}\n\nconst Item = (props: any) => {\n\treturn typeof props.children === \"function\"\n\t\t? props.children(props.v, props.i)\n\t\t: props.children;\n};\n\nexport function Show<T = boolean>(\n\tprops: ShowProps<T>\n): ComponentChildren | null {\n\tconst value =\n\t\ttypeof props.when === \"function\" ? props.when() : props.when.value;\n\tif (!value) return props.fallback || null;\n\treturn <Item v={value} children={props.children} />;\n}\n\ninterface ForProps<T> {\n\teach:\n\t\t| Signal<Array<T>>\n\t\t| ReadonlySignal<Array<T>>\n\t\t| (() => Signal<Array<T>> | ReadonlySignal<Array<T>>);\n\tfallback?: ComponentChildren;\n\tchildren: (value: T, index: number) => ComponentChildren;\n}\n\nexport function For<T>(props: ForProps<T>): ComponentChildren | null {\n\tconst cache = useMemo(() => new Map(), []);\n\tlet list = (\n\t\t(typeof props.each === \"function\" ? props.each() : props.each) as Signal<\n\t\t\tArray<T>\n\t\t>\n\t).value;\n\n\tif (!list.length) return props.fallback || null;\n\n\tconst removed = new Set(cache.keys());\n\n\tconst items = list.map((value, key) => {\n\t\tremoved.delete(value);\n\t\tif (!cache.has(value)) {\n\t\t\tconst result = <Item v={value} i={key} children={props.children} />;\n\t\t\tcache.set(value, result);\n\t\t\treturn result;\n\t\t}\n\t\treturn cache.get(value);\n\t});\n\n\tremoved.forEach(value => {\n\t\tcache.delete(value);\n\t});\n\n\treturn createElement(Fragment, null, items);\n}\n\nexport function useLiveSignal<T>(value: T): Signal<T> {\n\tconst s = useSignal(value);\n\tif (s.peek() !== value) s.value = value;\n\treturn s;\n}\n\nexport function useSignalRef<T>(value: T): Signal<T> & { current: T } {\n\tconst ref = useSignal(value) as Signal<T> & { current: T };\n\tif (!(\"current\" in ref))\n\t\tObject.defineProperty(ref, \"current\", refSignalProto);\n\treturn ref;\n}\nconst refSignalProto = {\n\tconfigurable: true,\n\tget(this: Signal) {\n\t\treturn this.value;\n\t},\n\tset(this: Signal, v: any) {\n\t\tthis.value = v;\n\t},\n};\n"],"names":["g","f","exports","module","require","define","amd","globalThis","self","preactSignalsutils","signals","preact","preactHooks","this","hooks","Item","props","children","v","i","refSignalProto","configurable","get","value","set","For","cache","useMemo","Map","list","each","length","fallback","removed","Set","keys","items","map","key","has","result","createElement","forEach","Fragment","Show","when","useLiveSignal","s","useSignal","peek","useSignalRef","ref","Object","defineProperty"],"mappings":"CAWA,SAAAA,EAAAC,GAAA,iBAAAC,SAAA,oBAAAC,OAAAF,EAAAC,QAAAE,QAAA,mBAAAA,QAAA,UAAAA,QAAA,iBAAA,mBAAAC,QAAAA,OAAAC,IAAAD,OAAA,CAAA,UAAA,kBAAA,SAAA,gBAAAJ,GAAAA,GAAAD,EAAA,oBAAAO,WAAAA,WAAAP,GAAAQ,MAAAC,mBAAA,CAAA,EAAAT,EAAAU,QAAAV,EAAAW,OAAAX,EAAAY,YAAA,CAAA,CAAAC,KAAA,SAAAX,EAAAQ,EAAAC,EAAAG,GAAA,IAAMC,EAAO,SAACC,GACb,MAAiC,mBAAnBA,EAAMC,SACjBD,EAAMC,SAASD,EAAME,EAAGF,EAAMG,GAC9BH,EAAMC,QACV,EA6DMG,EAAiB,CACtBC,cAAc,EACdC,IAAA,WACC,OAAOT,KAAKU,KACb,EACAC,IAAA,SAAkBN,GACjBL,KAAKU,MAAQL,CACd,GACAhB,EAAAuB,IAjDe,SAAOT,GACtB,IAAMU,EAAQC,EAAAA,QAAQ,WAAM,OAAA,IAAIC,GAAK,EAAE,IACnCC,GACoB,mBAAfb,EAAMc,KAAsBd,EAAMc,OAASd,EAAMc,MAGxDP,MAEF,IAAKM,EAAKE,OAAQ,OAAOf,EAAMgB,UAAY,KAE3C,IAAMC,EAAU,IAAIC,IAAIR,EAAMS,QAExBC,EAAQP,EAAKQ,IAAI,SAACd,EAAOe,GAC9BL,SAAeV,GACf,IAAKG,EAAMa,IAAIhB,GAAQ,CACtB,IAAMiB,EAASC,gBAAC1B,EAAK,CAAAG,EAAGK,EAAOJ,EAAGmB,EAAKrB,SAAUD,EAAMC,WACvDS,EAAMF,IAAID,EAAOiB,GACjB,OAAOA,CACR,CACA,OAAOd,EAAMJ,IAAIC,EAClB,GAEAU,EAAQS,QAAQ,SAAAnB,GACfG,EAAY,OAACH,EACd,GAEA,OAAOkB,EAAAA,cAAcE,EAAQA,SAAE,KAAMP,EACtC,EAsBClC,EAAA0C,cAlEA5B,GAEA,IAAMO,EACiB,mBAAfP,EAAM6B,KAAsB7B,EAAM6B,OAAS7B,EAAM6B,KAAKtB,MAC9D,IAAKA,EAAO,OAAOP,EAAMgB,UAAY,UACrC,OAAOS,EAAAA,cAAC1B,EAAK,CAAAG,EAAGK,EAAON,SAAUD,EAAMC,UACxC,EA4DCf,EAAA4C,cApBe,SAAiBvB,GAChC,IAAMwB,EAAIC,EAAAA,UAAUzB,GACpB,GAAIwB,EAAEE,SAAW1B,EAAOwB,EAAExB,MAAQA,EAClC,OAAOwB,CACR,EAgBC7C,EAAAgD,aAde,SAAgB3B,GAC/B,IAAM4B,EAAMH,EAAAA,UAAUzB,GACtB,KAAM,YAAa4B,GAClBC,OAAOC,eAAeF,EAAK,UAAW/B,GACvC,OAAO+B,CACR,CASC"}
1
+ {"version":3,"file":"utils.min.js","sources":["../src/index.tsx"],"sourcesContent":["import { ReadonlySignal, Signal } from \"@preact/signals-core\";\nimport { useSignal } from \"@preact/signals\";\nimport { Fragment, createElement, ComponentChildren } from \"preact\";\nimport { useMemo } from \"preact/hooks\";\n\ninterface ShowProps<T = boolean> {\n\twhen: Signal<T> | ReadonlySignal<T> | (() => T);\n\tfallback?: ComponentChildren;\n\tchildren: ComponentChildren | ((value: NonNullable<T>) => ComponentChildren);\n}\n\nconst Item = (props: any) => {\n\treturn typeof props.children === \"function\"\n\t\t? props.children(props.v, props.i)\n\t\t: props.children;\n};\n\nItem.displayName = \"Item\";\n\nexport function Show<T = boolean>(\n\tprops: ShowProps<T>\n): ComponentChildren | null {\n\tconst value =\n\t\ttypeof props.when === \"function\" ? props.when() : props.when.value;\n\tif (!value) return props.fallback || null;\n\treturn <Item v={value} children={props.children} />;\n}\n\nShow.displayName = \"Show\";\n\ninterface ForProps<T> {\n\teach:\n\t\t| Signal<Array<T>>\n\t\t| ReadonlySignal<Array<T>>\n\t\t| (() => Signal<Array<T>> | ReadonlySignal<Array<T>>);\n\tfallback?: ComponentChildren;\n\tchildren: (value: T, index: number) => ComponentChildren;\n}\n\nexport function For<T>(props: ForProps<T>): ComponentChildren | null {\n\tconst cache = useMemo(() => new Map(), []);\n\tlet list = (\n\t\t(typeof props.each === \"function\" ? props.each() : props.each) as Signal<\n\t\t\tArray<T>\n\t\t>\n\t).value;\n\n\tif (!list.length) return props.fallback || null;\n\n\tconst removed = new Set(cache.keys());\n\n\tconst items = list.map((value, key) => {\n\t\tremoved.delete(value);\n\t\tif (!cache.has(value)) {\n\t\t\tconst result = <Item v={value} i={key} children={props.children} />;\n\t\t\tcache.set(value, result);\n\t\t\treturn result;\n\t\t}\n\t\treturn cache.get(value);\n\t});\n\n\tremoved.forEach(value => {\n\t\tcache.delete(value);\n\t});\n\n\treturn createElement(Fragment, null, items);\n}\n\nFor.displayName = \"For\";\n\nexport function useLiveSignal<T>(value: T): Signal<T> {\n\tconst s = useSignal(value);\n\tif (s.peek() !== value) s.value = value;\n\treturn s;\n}\n\nexport function useSignalRef<T>(value: T): Signal<T> & { current: T } {\n\tconst ref = useSignal(value) as Signal<T> & { current: T };\n\tif (!(\"current\" in ref))\n\t\tObject.defineProperty(ref, \"current\", refSignalProto);\n\treturn ref;\n}\nconst refSignalProto = {\n\tconfigurable: true,\n\tget(this: Signal) {\n\t\treturn this.value;\n\t},\n\tset(this: Signal, v: any) {\n\t\tthis.value = v;\n\t},\n};\n"],"names":["Item","props","children","v","i","displayName","Show","value","when","fallback","createElement","For","cache","useMemo","Map","list","each","length","removed","Set","keys","items","map","key","has","result","set","get","forEach","Fragment","refSignalProto","configurable","this","exports","useLi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ChC,IAAM4B,EAAIC,EAASA,UAAC7B,GACpB,GAAI4B,EAAEE,SAAW9B,EAAO4B,EAAE5B,MAAQA,EAClC,OAAO4B,CACR,EAgBCF,EAAAK,aAdK,SAA0B/B,GAC/B,IAAMgC,EAAMH,EAAAA,UAAU7B,GACtB,KAAM,YAAagC,GAClBC,OAAOC,eAAeF,EAAK,UAAWT,GACvC,OAAOS,CACR,CASC"}
@@ -1 +1 @@
1
- import{useSignal}from"@preact/signals";import{createElement as n,Fragment as t}from"preact";import{useMemo as r}from"preact/hooks";const e=n=>"function"==typeof n.children?n.children(n.v,n.i):n.children;function o(t){const r="function"==typeof t.when?t.when():t.when.value;if(!r)return t.fallback||null;else return n(e,{v:r,children:t.children})}function c(o){const c=r(()=>new Map,[]);let i=("function"==typeof o.each?o.each():o.each).value;if(!i.length)return o.fallback||null;const u=new Set(c.keys()),f=i.map((t,r)=>{u.delete(t);if(!c.has(t)){const i=n(e,{v:t,i:r,children:o.children});c.set(t,i);return i}return c.get(t)});u.forEach(n=>{c.delete(n)});return n(t,null,f)}function i(n){const t=useSignal(n);if(t.peek()!==n)t.value=n;return t}function u(n){const t=useSignal(n);if(!("current"in t))Object.defineProperty(t,"current",f);return t}const f={configurable:!0,get(){return this.value},set(n){this.value=n}};export{c as For,o as Show,i as useLiveSignal,u as useSignalRef};//# sourceMappingURL=utils.mjs.map
1
+ import{useSignal}from"@preact/signals";import{createElement as t,Fragment as n}from"preact";import{useMemo as r}from"preact/hooks";const e=t=>"function"==typeof t.children?t.children(t.v,t.i):t.children;e.displayName="Item";function o(n){const r="function"==typeof n.when?n.when():n.when.value;if(!r)return n.fallback||null;else return t(e,{v:r,children:n.children})}o.displayName="Show";function c(o){const c=r(()=>new Map,[]);let i=("function"==typeof o.each?o.each():o.each).value;if(!i.length)return o.fallback||null;const u=new Set(c.keys()),f=i.map((n,r)=>{u.delete(n);if(!c.has(n)){const i=t(e,{v:n,i:r,children:o.children});c.set(n,i);return i}return c.get(n)});u.forEach(t=>{c.delete(t)});return t(n,null,f)}c.displayName="For";function i(t){const n=useSignal(t);if(n.peek()!==t)n.value=t;return n}function u(t){const n=useSignal(t);if(!("current"in n))Object.defineProperty(n,"current",f);return n}const f={configurable:!0,get(){return this.value},set(t){this.value=t}};export{c as For,o as Show,i as useLiveSignal,u as useSignalRef};//# sourceMappingURL=utils.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","sources":["../src/index.tsx"],"sourcesContent":["import { ReadonlySignal, Signal } from \"@preact/signals-core\";\nimport { useSignal } from \"@preact/signals\";\nimport { Fragment, createElement, ComponentChildren } from \"preact\";\nimport { useMemo } from \"preact/hooks\";\n\ninterface ShowProps<T = boolean> {\n\twhen: Signal<T> | ReadonlySignal<T> | (() => T);\n\tfallback?: ComponentChildren;\n\tchildren: ComponentChildren | ((value: NonNullable<T>) => ComponentChildren);\n}\n\nconst Item = (props: any) => {\n\treturn typeof props.children === \"function\"\n\t\t? props.children(props.v, props.i)\n\t\t: props.children;\n};\n\nexport function Show<T = boolean>(\n\tprops: ShowProps<T>\n): ComponentChildren | null {\n\tconst value =\n\t\ttypeof props.when === \"function\" ? props.when() : props.when.value;\n\tif (!value) return props.fallback || null;\n\treturn <Item v={value} children={props.children} />;\n}\n\ninterface ForProps<T> {\n\teach:\n\t\t| Signal<Array<T>>\n\t\t| ReadonlySignal<Array<T>>\n\t\t| (() => Signal<Array<T>> | ReadonlySignal<Array<T>>);\n\tfallback?: ComponentChildren;\n\tchildren: (value: T, index: number) => ComponentChildren;\n}\n\nexport function For<T>(props: ForProps<T>): ComponentChildren | null {\n\tconst cache = useMemo(() => new Map(), []);\n\tlet list = (\n\t\t(typeof props.each === \"function\" ? props.each() : props.each) as Signal<\n\t\t\tArray<T>\n\t\t>\n\t).value;\n\n\tif (!list.length) return props.fallback || null;\n\n\tconst removed = new Set(cache.keys());\n\n\tconst items = list.map((value, key) => {\n\t\tremoved.delete(value);\n\t\tif (!cache.has(value)) {\n\t\t\tconst result = <Item v={value} i={key} children={props.children} />;\n\t\t\tcache.set(value, result);\n\t\t\treturn result;\n\t\t}\n\t\treturn cache.get(value);\n\t});\n\n\tremoved.forEach(value => {\n\t\tcache.delete(value);\n\t});\n\n\treturn createElement(Fragment, null, items);\n}\n\nexport function useLiveSignal<T>(value: T): Signal<T> {\n\tconst s = useSignal(value);\n\tif (s.peek() !== value) s.value = value;\n\treturn s;\n}\n\nexport function useSignalRef<T>(value: T): Signal<T> & { current: T } {\n\tconst ref = useSignal(value) as Signal<T> & { current: T };\n\tif (!(\"current\" in ref))\n\t\tObject.defineProperty(ref, \"current\", refSignalProto);\n\treturn ref;\n}\nconst refSignalProto = {\n\tconfigurable: true,\n\tget(this: Signal) {\n\t\treturn this.value;\n\t},\n\tset(this: Signal, v: any) {\n\t\tthis.value = v;\n\t},\n};\n"],"names":["useSignal","createElement","Fragment","useMemo","Item","props","children","v","i","Show","value","when","fallback","For","cache","Map","list","each","length","removed","Set","keys","items","map","key","delete","has","result","set","get","forEach","useLiveSignal","s","peek","useSignalRef","ref","Object","defineProperty","refSignalProto","configurable","this"],"mappings":"OAWAA,cAAA,0CAAAC,cAAAC,MAAA,2BAAAC,MAAA,eAAA,MAAMC,EAAQC,GACoB,mBAAnBA,EAAMC,SACjBD,EAAMC,SAASD,EAAME,EAAGF,EAAMG,GAC9BH,EAAMC,kBAGMG,EACfJ,GAEA,MAAMK,EACiB,mBAAfL,EAAMM,KAAsBN,EAAMM,OAASN,EAAMM,KAAKD,MAC9D,IAAKA,EAAO,OAAOL,EAAMO,UAAY,UACrC,OAAOX,EAACG,EAAK,CAAAG,EAAGG,EAAOJ,SAAUD,EAAMC,UACxC,UAWgBO,EAAOR,GACtB,MAAMS,EAAQX,EAAQ,IAAM,IAAIY,IAAO,IACvC,IAAIC,GACoB,mBAAfX,EAAMY,KAAsBZ,EAAMY,OAASZ,EAAMY,MAGxDP,MAEF,IAAKM,EAAKE,OAAQ,OAAOb,EAAMO,UAAY,KAE3C,MAAMO,EAAU,IAAIC,IAAIN,EAAMO,QAExBC,EAAQN,EAAKO,IAAI,CAACb,EAAOc,KAC9BL,EAAQM,OAAOf,GACf,IAAKI,EAAMY,IAAIhB,GAAQ,CACtB,MAAMiB,EAAS1B,EAACG,EAAK,CAAAG,EAAGG,EAAOF,EAAGgB,EAAKlB,SAAUD,EAAMC,WACvDQ,EAAMc,IAAIlB,EAAOiB,GACjB,OAAOA,CACR,CACA,OAAOb,EAAMe,IAAInB,EAAK,GAGvBS,EAAQW,QAAQpB,IACfI,EAAMW,OAAOf,EACd,GAEA,OAAOT,EAAcC,EAAU,KAAMoB,EACtC,CAEM,SAAUS,EAAiBrB,GAChC,MAAMsB,EAAIhC,UAAUU,GACpB,GAAIsB,EAAEC,SAAWvB,EAAOsB,EAAEtB,MAAQA,EAClC,OAAOsB,CACR,UAEgBE,EAAgBxB,GAC/B,MAAMyB,EAAMnC,UAAUU,GACtB,KAAM,YAAayB,GAClBC,OAAOC,eAAeF,EAAK,UAAWG,GACvC,OAAOH,CACR,CACA,MAAMG,EAAiB,CACtBC,cAAc,EACdV,MACC,OAAOW,KAAK9B,KACb,EACAkB,IAAkBrB,GACjBiC,KAAK9B,MAAQH,CACd,UACAM,SAAAJ,UAAAsB,mBAAAG"}
1
+ {"version":3,"file":"utils.mjs","sources":["../src/index.tsx"],"sourcesContent":["import { ReadonlySignal, Signal } from \"@preact/signals-core\";\nimport { useSignal } from \"@preact/signals\";\nimport { Fragment, createElement, ComponentChildren } from \"preact\";\nimport { useMemo } from \"preact/hooks\";\n\ninterface ShowProps<T = boolean> {\n\twhen: Signal<T> | ReadonlySignal<T> | (() => T);\n\tfallback?: ComponentChildren;\n\tchildren: ComponentChildren | ((value: NonNullable<T>) => ComponentChildren);\n}\n\nconst Item = (props: any) => {\n\treturn typeof props.children === \"function\"\n\t\t? props.children(props.v, props.i)\n\t\t: props.children;\n};\n\nItem.displayName = \"Item\";\n\nexport function Show<T = boolean>(\n\tprops: ShowProps<T>\n): ComponentChildren | null {\n\tconst value =\n\t\ttypeof props.when === \"function\" ? props.when() : props.when.value;\n\tif (!value) return props.fallback || null;\n\treturn <Item v={value} children={props.children} />;\n}\n\nShow.displayName = \"Show\";\n\ninterface ForProps<T> {\n\teach:\n\t\t| Signal<Array<T>>\n\t\t| ReadonlySignal<Array<T>>\n\t\t| (() => Signal<Array<T>> | ReadonlySignal<Array<T>>);\n\tfallback?: ComponentChildren;\n\tchildren: (value: T, index: number) => ComponentChildren;\n}\n\nexport function For<T>(props: ForProps<T>): ComponentChildren | null {\n\tconst cache = useMemo(() => new Map(), []);\n\tlet list = (\n\t\t(typeof props.each === \"function\" ? props.each() : props.each) as Signal<\n\t\t\tArray<T>\n\t\t>\n\t).value;\n\n\tif (!list.length) return props.fallback || null;\n\n\tconst removed = new Set(cache.keys());\n\n\tconst items = list.map((value, key) => {\n\t\tremoved.delete(value);\n\t\tif (!cache.has(value)) {\n\t\t\tconst result = <Item v={value} i={key} children={props.children} />;\n\t\t\tcache.set(value, result);\n\t\t\treturn result;\n\t\t}\n\t\treturn cache.get(value);\n\t});\n\n\tremoved.forEach(value => {\n\t\tcache.delete(value);\n\t});\n\n\treturn createElement(Fragment, null, items);\n}\n\nFor.displayName = \"For\";\n\nexport function useLiveSignal<T>(value: T): Signal<T> {\n\tconst s = useSignal(value);\n\tif (s.peek() !== value) s.value = value;\n\treturn s;\n}\n\nexport function useSignalRef<T>(value: T): Signal<T> & { current: T } {\n\tconst ref = useSignal(value) as Signal<T> & { current: T };\n\tif (!(\"current\" in ref))\n\t\tObject.defineProperty(ref, \"current\", refSignalProto);\n\treturn ref;\n}\nconst refSignalProto = {\n\tconfigurable: true,\n\tget(this: Signal) {\n\t\treturn this.value;\n\t},\n\tset(this: Signal, v: any) {\n\t\tthis.value = v;\n\t},\n};\n"],"names":["useSignal","createElement","Fragment","useMemo","Item","props","children","v","i","displayName","Show","value","when","fallback","For","cache","Map","list","each","length","removed","Set","keys","items","map","key","delete","has","result","set","get","forEach","useLiveSignal","s","pe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ACtB,KAAM,YAAayB,GAClBC,OAAOC,eAAeF,EAAK,UAAWG,GACvC,OAAOH,CACR,CACA,MAAMG,EAAiB,CACtBC,cAAc,EACdV,MACC,OAAWW,KAAC9B,KACb,EACAkB,IAAkBtB,GACjBkC,KAAK9B,MAAQJ,CACd,UACAO,SAAAJ,UAAAsB,mBAAAG"}
@@ -1 +1 @@
1
- import{useSignal}from"@preact/signals";import{createElement as n,Fragment as r}from"preact";import{useMemo as t}from"preact/hooks";var e=function(n){return"function"==typeof n.children?n.children(n.v,n.i):n.children};function u(r){var t="function"==typeof r.when?r.when():r.when.value;if(!t)return r.fallback||null;else return n(e,{v:t,children:r.children})}function i(u){var i=t(function(){return new Map},[]),o=("function"==typeof u.each?u.each():u.each).value;if(!o.length)return u.fallback||null;var f=new Set(i.keys()),c=o.map(function(r,t){f.delete(r);if(!i.has(r)){var o=n(e,{v:r,i:t,children:u.children});i.set(r,o);return o}return i.get(r)});f.forEach(function(n){i.delete(n)});return n(r,null,c)}function o(n){var r=useSignal(n);if(r.peek()!==n)r.value=n;return r}function f(n){var r=useSignal(n);if(!("current"in r))Object.defineProperty(r,"current",c);return r}var c={configurable:!0,get:function(){return this.value},set:function(n){this.value=n}};export{i as For,u as Show,o as useLiveSignal,f as useSignalRef};//# sourceMappingURL=utils.module.js.map
1
+ import{useSignal}from"@preact/signals";import{createElement as n,Fragment as r}from"preact";import{useMemo as t}from"preact/hooks";var e=function(n){return"function"==typeof n.children?n.children(n.v,n.i):n.children};e.displayName="Item";function u(r){var t="function"==typeof r.when?r.when():r.when.value;if(!t)return r.fallback||null;else return n(e,{v:t,children:r.children})}u.displayName="Show";function i(u){var i=t(function(){return new Map},[]),o=("function"==typeof u.each?u.each():u.each).value;if(!o.length)return u.fallback||null;var f=new Set(i.keys()),c=o.map(function(r,t){f.delete(r);if(!i.has(r)){var o=n(e,{v:r,i:t,children:u.children});i.set(r,o);return o}return i.get(r)});f.forEach(function(n){i.delete(n)});return n(r,null,c)}i.displayName="For";function o(n){var r=useSignal(n);if(r.peek()!==n)r.value=n;return r}function f(n){var r=useSignal(n);if(!("current"in r))Object.defineProperty(r,"current",c);return r}var c={configurable:!0,get:function(){return this.value},set:function(n){this.value=n}};export{i as For,u as Show,o as useLiveSignal,f as useSignalRef};//# sourceMappingURL=utils.module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.module.js","sources":["../src/index.tsx"],"sourcesContent":["import { ReadonlySignal, Signal } from \"@preact/signals-core\";\nimport { useSignal } from \"@preact/signals\";\nimport { Fragment, createElement, ComponentChildren } from \"preact\";\nimport { useMemo } from \"preact/hooks\";\n\ninterface ShowProps<T = boolean> {\n\twhen: Signal<T> | ReadonlySignal<T> | (() => T);\n\tfallback?: ComponentChildren;\n\tchildren: ComponentChildren | ((value: NonNullable<T>) => ComponentChildren);\n}\n\nconst Item = (props: any) => {\n\treturn typeof props.children === \"function\"\n\t\t? props.children(props.v, props.i)\n\t\t: props.children;\n};\n\nexport function Show<T = boolean>(\n\tprops: ShowProps<T>\n): ComponentChildren | null {\n\tconst value =\n\t\ttypeof props.when === \"function\" ? props.when() : props.when.value;\n\tif (!value) return props.fallback || null;\n\treturn <Item v={value} children={props.children} />;\n}\n\ninterface ForProps<T> {\n\teach:\n\t\t| Signal<Array<T>>\n\t\t| ReadonlySignal<Array<T>>\n\t\t| (() => Signal<Array<T>> | ReadonlySignal<Array<T>>);\n\tfallback?: ComponentChildren;\n\tchildren: (value: T, index: number) => ComponentChildren;\n}\n\nexport function For<T>(props: ForProps<T>): ComponentChildren | null {\n\tconst cache = useMemo(() => new Map(), []);\n\tlet list = (\n\t\t(typeof props.each === \"function\" ? props.each() : props.each) as Signal<\n\t\t\tArray<T>\n\t\t>\n\t).value;\n\n\tif (!list.length) return props.fallback || null;\n\n\tconst removed = new Set(cache.keys());\n\n\tconst items = list.map((value, key) => {\n\t\tremoved.delete(value);\n\t\tif (!cache.has(value)) {\n\t\t\tconst result = <Item v={value} i={key} children={props.children} />;\n\t\t\tcache.set(value, result);\n\t\t\treturn result;\n\t\t}\n\t\treturn cache.get(value);\n\t});\n\n\tremoved.forEach(value => {\n\t\tcache.delete(value);\n\t});\n\n\treturn createElement(Fragment, null, items);\n}\n\nexport function useLiveSignal<T>(value: T): Signal<T> {\n\tconst s = useSignal(value);\n\tif (s.peek() !== value) s.value = value;\n\treturn s;\n}\n\nexport function useSignalRef<T>(value: T): Signal<T> & { current: T } {\n\tconst ref = useSignal(value) as Signal<T> & { current: T };\n\tif (!(\"current\" in ref))\n\t\tObject.defineProperty(ref, \"current\", refSignalProto);\n\treturn ref;\n}\nconst refSignalProto = {\n\tconfigurable: true,\n\tget(this: Signal) {\n\t\treturn this.value;\n\t},\n\tset(this: Signal, v: any) {\n\t\tthis.value = v;\n\t},\n};\n"],"names":["useSignal","createElement","Fragment","useMemo","Item","props","children","v","i","Show","value","when","fallback","For","cache","Map","list","each","length","removed","Set","keys","items","map","key","has","result","set","get","forEach","useLiveSignal","s","peek","useSignalRef","ref","Object","defineProperty","refSignalProto","configurable","this"],"mappings":"OAWAA,cAAA,0CAAAC,cAAAC,MAAA,2BAAAC,MAAA,eAAA,IAAMC,EAAO,SAACC,GACb,MAAiC,mBAAnBA,EAAMC,SACjBD,EAAMC,SAASD,EAAME,EAAGF,EAAMG,GAC9BH,EAAMC,QACV,WAEgBG,EACfJ,GAEA,IAAMK,EACiB,mBAAfL,EAAMM,KAAsBN,EAAMM,OAASN,EAAMM,KAAKD,MAC9D,IAAKA,EAAO,OAAOL,EAAMO,UAAY,UACrC,OAAOX,EAACG,EAAK,CAAAG,EAAGG,EAAOJ,SAAUD,EAAMC,UACxC,CAWgB,SAAAO,EAAOR,GACtB,IAAMS,EAAQX,EAAQ,WAAM,OAAA,IAAIY,GAAK,EAAE,IACnCC,GACoB,mBAAfX,EAAMY,KAAsBZ,EAAMY,OAASZ,EAAMY,MAGxDP,MAEF,IAAKM,EAAKE,OAAQ,OAAOb,EAAMO,UAAY,KAE3C,IAAMO,EAAU,IAAIC,IAAIN,EAAMO,QAExBC,EAAQN,EAAKO,IAAI,SAACb,EAAOc,GAC9BL,SAAeT,GACf,IAAKI,EAAMW,IAAIf,GAAQ,CACtB,IAAMgB,EAASzB,EAACG,EAAK,CAAAG,EAAGG,EAAOF,EAAGgB,EAAKlB,SAAUD,EAAMC,WACvDQ,EAAMa,IAAIjB,EAAOgB,GACjB,OAAOA,CACR,CACA,OAAOZ,EAAMc,IAAIlB,EAClB,GAEAS,EAAQU,QAAQ,SAAAnB,GACfI,EAAY,OAACJ,EACd,GAEA,OAAOT,EAAcC,EAAU,KAAMoB,EACtC,CAEgB,SAAAQ,EAAiBpB,GAChC,IAAMqB,EAAI/B,UAAUU,GACpB,GAAIqB,EAAEC,SAAWtB,EAAOqB,EAAErB,MAAQA,EAClC,OAAOqB,CACR,CAEgB,SAAAE,EAAgBvB,GAC/B,IAAMwB,EAAMlC,UAAUU,GACtB,KAAM,YAAawB,GAClBC,OAAOC,eAAeF,EAAK,UAAWG,GACvC,OAAOH,CACR,CACA,IAAMG,EAAiB,CACtBC,cAAc,EACdV,IAAA,WACC,OAAOW,KAAK7B,KACb,EACAiB,IAAA,SAAkBpB,GACjBgC,KAAK7B,MAAQH,CACd,UACAM,SAAAJ,UAAAqB,mBAAAG"}
1
+ {"version":3,"file":"utils.module.js","sources":["../src/index.tsx"],"sourcesContent":["import { ReadonlySignal, Signal } from \"@preact/signals-core\";\nimport { useSignal } from \"@preact/signals\";\nimport { Fragment, createElement, ComponentChildren } from \"preact\";\nimport { useMemo } from \"preact/hooks\";\n\ninterface ShowProps<T = boolean> {\n\twhen: Signal<T> | ReadonlySignal<T> | (() => T);\n\tfallback?: ComponentChildren;\n\tchildren: ComponentChildren | ((value: NonNullable<T>) => ComponentChildren);\n}\n\nconst Item = (props: any) => {\n\treturn typeof props.children === \"function\"\n\t\t? props.children(props.v, props.i)\n\t\t: props.children;\n};\n\nItem.displayName = \"Item\";\n\nexport function Show<T = boolean>(\n\tprops: ShowProps<T>\n): ComponentChildren | null {\n\tconst value =\n\t\ttypeof props.when === \"function\" ? props.when() : props.when.value;\n\tif (!value) return props.fallback || null;\n\treturn <Item v={value} children={props.children} />;\n}\n\nShow.displayName = \"Show\";\n\ninterface ForProps<T> {\n\teach:\n\t\t| Signal<Array<T>>\n\t\t| ReadonlySignal<Array<T>>\n\t\t| (() => Signal<Array<T>> | ReadonlySignal<Array<T>>);\n\tfallback?: ComponentChildren;\n\tchildren: (value: T, index: number) => ComponentChildren;\n}\n\nexport function For<T>(props: ForProps<T>): ComponentChildren | null {\n\tconst cache = useMemo(() => new Map(), []);\n\tlet list = (\n\t\t(typeof props.each === \"function\" ? props.each() : props.each) as Signal<\n\t\t\tArray<T>\n\t\t>\n\t).value;\n\n\tif (!list.length) return props.fallback || null;\n\n\tconst removed = new Set(cache.keys());\n\n\tconst items = list.map((value, key) => {\n\t\tremoved.delete(value);\n\t\tif (!cache.has(value)) {\n\t\t\tconst result = <Item v={value} i={key} children={props.children} />;\n\t\t\tcache.set(value, result);\n\t\t\treturn result;\n\t\t}\n\t\treturn cache.get(value);\n\t});\n\n\tremoved.forEach(value => {\n\t\tcache.delete(value);\n\t});\n\n\treturn createElement(Fragment, null, items);\n}\n\nFor.displayName = \"For\";\n\nexport function useLiveSignal<T>(value: T): Signal<T> {\n\tconst s = useSignal(value);\n\tif (s.peek() !== value) s.value = value;\n\treturn s;\n}\n\nexport function useSignalRef<T>(value: T): Signal<T> & { current: T } {\n\tconst ref = useSignal(value) as Signal<T> & { current: T };\n\tif (!(\"current\" in ref))\n\t\tObject.defineProperty(ref, \"current\", refSignalProto);\n\treturn ref;\n}\nconst refSignalProto = {\n\tconfigurable: true,\n\tget(this: Signal) {\n\t\treturn this.value;\n\t},\n\tset(this: Signal, v: any) {\n\t\tthis.value = v;\n\t},\n};\n"],"names":["Item","props","children","v","i","displayName","Show","value","when","fallback","createElement","For","cache","useMemo","Map","list","each","length","removed","Set","keys","items","map","key","has","result","set","get","forEach","Fragment","useLiveSignal","s","useSignal","peek","useSignalRef","ref","Object","defineProperty","refSignalProto","configurable","this"],"mappings":"mIAWA,IAAMA,EAAO,SAACC,GACb,MAAiC,mBAAnBA,EAAMC,SACjBD,EAAMC,SAASD,EAAME,EAAGF,EAAMG,GAC9BH,EAAMC,QACV,EAEAF,EAAKK,YAAc,OAEH,SAAAC,EACfL,GAEA,IAAMM,EACiB,mBAAfN,EAAMO,KAAsBP,EAAMO,OAASP,EAAMO,KAAKD,MAC9D,IAAKA,EAAO,OAAON,EAAMQ,UAAY,UACrC,OAAOC,EAACV,EAAK,CAAAG,EAAGI,EAAOL,SAAUD,EAAMC,UACxC,CAEAI,EAAKD,YAAc,OAWb,SAAUM,EAAOV,GACtB,IAAMW,EAAQC,EAAQ,WAAA,OAAU,IAAAC,GAAK,EAAE,IACnCC,GACoB,mBAAfd,EAAMe,KAAsBf,EAAMe,OAASf,EAAMe,MAGxDT,MAEF,IAAKQ,EAAKE,OAAQ,OAAOhB,EAAMQ,UAAY,KAE3C,IAAMS,EAAU,IAAIC,IAAIP,EAAMQ,QAExBC,EAAQN,EAAKO,IAAI,SAACf,EAAOgB,GAC9BL,SAAeX,GACf,IAAKK,EAAMY,IAAIjB,GAAQ,CACtB,IAAMkB,EAASf,EAACV,EAAK,CAAAG,EAAGI,EAAOH,EAAGmB,EAAKrB,SAAUD,EAAMC,WACvDU,EAAMc,IAAInB,EAAOkB,GACjB,OAAOA,CACR,CACA,OAAOb,EAAMe,IAAIpB,EAClB,GAEAW,EAAQU,QAAQ,SAAArB,GACfK,EAAY,OAACL,EACd,GAEA,OAAOG,EAAcmB,EAAU,KAAMR,EACtC,CAEAV,EAAIN,YAAc,MAEF,SAAAyB,EAAiBvB,GAChC,IAAMwB,EAAIC,UAAUzB,GACpB,GAAIwB,EAAEE,SAAW1B,EAAOwB,EAAExB,MAAQA,EAClC,OAAOwB,CACR,CAEM,SAAUG,EAAgB3B,GAC/B,IAAM4B,EAAMH,UAAUzB,GACtB,KAAM,YAAa4B,GAClBC,OAAOC,eAAeF,EAAK,UAAWG,GACvC,OAAOH,CACR,CACA,IAAMG,EAAiB,CACtBC,cAAc,EACdZ,eACC,YAAYpB,KACb,EACAmB,IAAG,SAAevB,GACjBqC,KAAKjC,MAAQJ,CACd,UACAQ,SAAAL,UAAAwB,mBAAAI"}
@@ -18,7 +18,7 @@
18
18
  }
19
19
  },
20
20
  "dependencies": {
21
- "@preact/signals-core": "workspace:^1.3.0"
21
+ "@preact/signals-core": "workspace:^1.12.2"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "@preact/signals": "workspace:*",
@@ -15,6 +15,8 @@ const Item = (props: any) => {
15
15
  : props.children;
16
16
  };
17
17
 
18
+ Item.displayName = "Item";
19
+
18
20
  export function Show<T = boolean>(
19
21
  props: ShowProps<T>
20
22
  ): ComponentChildren | null {
@@ -24,6 +26,8 @@ export function Show<T = boolean>(
24
26
  return <Item v={value} children={props.children} />;
25
27
  }
26
28
 
29
+ Show.displayName = "Show";
30
+
27
31
  interface ForProps<T> {
28
32
  each:
29
33
  | Signal<Array<T>>
@@ -62,6 +66,8 @@ export function For<T>(props: ForProps<T>): ComponentChildren | null {
62
66
  return createElement(Fragment, null, items);
63
67
  }
64
68
 
69
+ For.displayName = "For";
70
+
65
71
  export function useLiveSignal<T>(value: T): Signal<T> {
66
72
  const s = useSignal(value);
67
73
  if (s.peek() !== value) s.value = value;