From b890991c29366502fc5290883862402fd7fe134b Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 1 Jan 2025 14:54:11 +0200 Subject: [PATCH] Apply https://github.com/preactjs/signals/pull/638 until there is a new release --- patches/@preact+signals-react+2.3.0.patch | 190 ++++++++++++++++++++++ scripts/prepare/index.ts | 3 + 2 files changed, 193 insertions(+) create mode 100644 patches/@preact+signals-react+2.3.0.patch diff --git a/patches/@preact+signals-react+2.3.0.patch b/patches/@preact+signals-react+2.3.0.patch new file mode 100644 index 0000000000..dfd3858c44 --- /dev/null +++ b/patches/@preact+signals-react+2.3.0.patch @@ -0,0 +1,190 @@ +diff --git a/node_modules/@preact/signals-react/package.json b/node_modules/@preact/signals-react/package.json +index 3646c62..47774cd 100644 +--- a/node_modules/@preact/signals-react/package.json ++++ b/node_modules/@preact/signals-react/package.json +@@ -37,14 +37,7 @@ + "import": "./runtime/dist/runtime.mjs", + "require": "./runtime/dist/runtime.js" + }, +- "./runtime/package.json": "./runtime/package.json", +- "./auto": { +- "types": "./auto/dist/index.d.ts", +- "browser": "./auto/dist/auto.module.js", +- "import": "./auto/dist/auto.mjs", +- "require": "./auto/dist/auto.js" +- }, +- "./auto/package.json": "./auto/package.json" ++ "./runtime/package.json": "./runtime/package.json" + }, + "mangle": "../../mangle.json", + "files": [ +@@ -53,15 +46,15 @@ + "runtime/dist", + "runtime/src", + "runtime/package.json", +- "auto/dist", +- "auto/src", +- "auto/package.json", + "CHANGELOG.md", + "LICENSE", + "README.md" + ], ++ "scripts": { ++ "prepublishOnly": "cd ../.. && pnpm build:react-runtime && pnpm build:react" ++ }, + "dependencies": { +- "@preact/signals-core": "^1.7.0", ++ "@preact/signals-core": "workspace:^1.7.0", + "use-sync-external-store": "^1.2.0" + }, + "peerDependencies": { +@@ -77,6 +70,5 @@ + }, + "publishConfig": { + "provenance": true +- }, +- "scripts": {} ++ } + } +diff --git a/node_modules/@preact/signals-react/runtime/dist/index.d.ts b/node_modules/@preact/signals-react/runtime/dist/index.d.ts +index 424346a..1acce78 100644 +--- a/node_modules/@preact/signals-react/runtime/dist/index.d.ts ++++ b/node_modules/@preact/signals-react/runtime/dist/index.d.ts +@@ -1,5 +1,4 @@ + import { Signal, ReadonlySignal } from "@preact/signals-core"; +-export { installAutoSignalTracking } from "./auto"; + export declare function wrapJsx(jsx: T): T; + declare const symDispose: unique symbol; + interface Effect { +@@ -61,3 +60,4 @@ export declare function useSignal(value: T): Signal; + export declare function useSignal(): Signal; + export declare function useComputed(compute: () => T): ReadonlySignal; + export declare function useSignalEffect(cb: () => void | (() => void)): void; ++export {}; +diff --git a/node_modules/@preact/signals-react/runtime/dist/runtime.js b/node_modules/@preact/signals-react/runtime/dist/runtime.js +index bf7b40f..1801953 100644 +--- a/node_modules/@preact/signals-react/runtime/dist/runtime.js ++++ b/node_modules/@preact/signals-react/runtime/dist/runtime.js +@@ -1 +1 @@ +-var n=require("@preact/signals-core"),e=require("react"),r=require("use-sync-external-store/shim/index.js"),t=require("react/jsx-runtime"),i=require("react/jsx-dev-runtime");function u(n){return n&&"object"==typeof n&&"default"in n?n.default:n}var o=/*#__PURE__*/u(e),f=/*#__PURE__*/u(t),c=/*#__PURE__*/u(i),a=!1,s=null,l=!1,v=null,p=new Map;function d(n){if(!n)return 1;var e,r=p.get(n);if(void 0!==r)return r;var t=n.useCallback.toString();if(n.useReducer===n.useEffect)e=1;else if(n.useEffect===n.useImperativeHandle)e=32;else if(/Invalid/.test(t))e=2;else if(/updateCallback/.test(t)||/\[0\]/.test(t)&&/\[1\]/.test(t)){var i=n.useReducer.toString();if(/rerenderReducer/.test(i)||/return\s*\[\w+,/.test(i))e=16;else e=8}else e=4;p.set(n,e);return e}var b=e.version.split(".").map(Number),g=[],m=Symbol.for(b[0]>=19?"react.transitional.element":"react.element"),h=function(){};function y(e){if("function"!=typeof e)return e;else return function(r,t){if("string"==typeof r&&t)for(var i in t){var u=t[i];if("children"!==i&&u instanceof n.Signal)t[i]=u.value}return e.call.apply(e,[e,r,t].concat([].slice.call(arguments,2)))}}var x,_=Symbol.dispose||Symbol.for("Symbol.dispose");function j(n,e){var r=e.effect.S();x=e;return w.bind(e,n,r)}function w(n,e){e();x=n}var S,q,k=((S={u:0,effect:{s:void 0,c:function(){},S:function(){return h},d:function(){}},subscribe:function(){return h},getSnapshot:function(){return 0},S:function(){},f:function(){}})[_]=function(){},S),B=Promise.prototype.then.bind(Promise.resolve());function N(){if(!q)q=B(O)}function O(){var n;q=void 0;null==(n=x)||n.f()}var P="undefined"!=typeof window?e.useLayoutEffect:e.useEffect;function R(t){if(void 0===t)t=0;N();var i=e.useRef();if(null==i.current)i.current=function(e){var r,t,i,u,o=0,f=n.effect(function(){t=this});t.c=function(){o=o+1|0;if(u)u()};return(r={u:e,effect:t,subscribe:function(n){u=n;return function(){o=o+1|0;u=void 0;f()}},getSnapshot:function(){return o},S:function(){if(null!=x){var n=x.u,e=this.u;if(0==n&&0==e||0==n&&1==e){x.f();i=j(void 0,this)}else if(1==n&&0==e||2==n&&0==e);else i=j(x,this)}else i=j(void 0,this)},f:function(){var n=i;i=void 0;null==n||n()}})[_]=function(){this.f()},r}(t);var u=i.current;r.useSyncExternalStore(u.subscribe,u.getSnapshot,u.getSnapshot);u.S();if(0===t)P(O);return u}Object.defineProperties(n.Signal.prototype,{$$typeof:{configurable:!0,value:m},type:{configurable:!0,value:function(n){var e=n.data,r=R(1);try{return e.value}finally{r.f()}}},props:{configurable:!0,get:function(){return{data:this}}},ref:{configurable:!0,value:null}});exports._useSignalsImplementation=R;exports.ensureFinalCleanup=N;exports.installAutoSignalTracking=function(){if(e.version.split(".").map(Number)[0]>=19)throw new Error("Automatic signals tracking is not supported in React 19 and later, try the Babel plugin instead https://github.com/preactjs/signals/tree/main/packages/react-transform#signals-react-transform.");!function(){a=!0;Object.defineProperty(e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher,"current",{get:function(){return v},set:function(n){if(!l){var e=d(v),r=d(n);v=n;if(function(n,e){if(1&n&&28&e)return!0;else if(2&n||2&e)return!1;else return!1}(e,r)){l=!0;s=R(1);l=!1}else if(function(n,e){return Boolean(28&n&&16&e)}(e,r)){var t;null==(t=s)||t.f();l=!0;s=R(1);l=!1}else if(function(n,e){return Boolean(28&n&&1&e)}(e,r)){var i;null==(i=s)||i.f();s=null}}else v=n}})}();!function(){var n=f,e=c;o.createElement=y(o.createElement);e.jsx&&(e.jsx=y(e.jsx));n.jsx&&(n.jsx=y(n.jsx));e.jsxs&&(e.jsxs=y(e.jsxs));n.jsxs&&(n.jsxs=y(n.jsxs));e.jsxDEV&&(e.jsxDEV=y(e.jsxDEV));n.jsxDEV&&(n.jsxDEV=y(n.jsxDEV))}()};exports.useComputed=function(r){var t=e.useRef(r);t.current=r;return e.useMemo(function(){return n.computed(function(){return t.current()})},g)};exports.useSignal=function(r){return e.useMemo(function(){return n.signal(r)},g)};exports.useSignalEffect=function(r){var t=e.useRef(r);t.current=r;e.useEffect(function(){return n.effect(function(){return t.current()})},g)};exports.useSignals=function(n){if(a)return k;else return R(n)};exports.wrapJsx=y;//# sourceMappingURL=runtime.js.map ++var n,r=require("@preact/signals-core"),t=require("react"),e=require("use-sync-external-store/shim/index.js"),i=t.version.split(".").map(Number),u=[],o=Symbol.for(i[0]>=19?"react.transitional.element":"react.element"),f=Symbol.dispose||Symbol.for("Symbol.dispose");function c(r,t){var e=t.effect.S();n=t;return s.bind(t,r,e)}function s(r,t){t();n=r}var a,l=Promise.prototype.then.bind(Promise.resolve());function v(){if(!a)a=l(p)}function p(){var r;a=void 0;null==(r=n)||r.f()}var d="undefined"!=typeof window?t.useLayoutEffect:t.useEffect;function b(i){if(void 0===i)i=0;v();var u=t.useRef();if(null==u.current)u.current=function(t){var e,i,u,o,s=0,a=r.effect(function(){i=this});i.c=function(){s=s+1|0;if(o)o()};return(e={u:t,effect:i,subscribe:function(n){o=n;return function(){s=s+1|0;o=void 0;a()}},getSnapshot:function(){return s},S:function(){if(null!=n){var r=n.u,t=this.u;if(0==r&&0==t||0==r&&1==t){n.f();u=c(void 0,this)}else if(1==r&&0==t||2==r&&0==t);else u=c(n,this)}else u=c(void 0,this)},f:function(){var n=u;u=void 0;null==n||n()}})[f]=function(){this.f()},e}(i);var o=u.current;e.useSyncExternalStore(o.subscribe,o.getSnapshot,o.getSnapshot);o.S();if(0===i)d(p);return o}Object.defineProperties(r.Signal.prototype,{$$typeof:{configurable:!0,value:o},type:{configurable:!0,value:function(n){var r=n.data,t=b(1);try{return r.value}finally{t.f()}}},props:{configurable:!0,get:function(){return{data:this}}},ref:{configurable:!0,value:null}});exports._useSignalsImplementation=b;exports.ensureFinalCleanup=v;exports.useComputed=function(n){var e=t.useRef(n);e.current=n;return t.useMemo(function(){return r.computed(function(){return e.current()})},u)};exports.useSignal=function(n){return t.useMemo(function(){return r.signal(n)},u)};exports.useSignalEffect=function(n){var e=t.useRef(n);e.current=n;t.useEffect(function(){return r.effect(function(){return e.current()})},u)};exports.useSignals=function(n){return b(n)};exports.wrapJsx=function(n){if("function"!=typeof n)return n;else return function(t,e){if("string"==typeof t&&e)for(var i in e){var u=e[i];if("children"!==i&&u instanceof r.Signal)e[i]=u.value}return n.call.apply(n,[n,t,e].concat([].slice.call(arguments,2)))}};//# sourceMappingURL=runtime.js.map +diff --git a/node_modules/@preact/signals-react/runtime/dist/runtime.js.map b/node_modules/@preact/signals-react/runtime/dist/runtime.js.map +index 7b36368..93027d9 100644 +--- a/node_modules/@preact/signals-react/runtime/dist/runtime.js.map ++++ b/node_modules/@preact/signals-react/runtime/dist/runtime.js.map +@@ -1 +1 @@ +-{"version":3,"file":"runtime.js","sources":["../src/auto.ts","../src/index.ts"],"sourcesContent":["import {\n\t// @ts-ignore-next-line\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED as ReactInternals,\n\tversion as reactVersion,\n} from \"react\";\nimport React from \"react\";\nimport jsxRuntime from \"react/jsx-runtime\";\nimport jsxRuntimeDev from \"react/jsx-dev-runtime\";\nimport { EffectStore, wrapJsx, _useSignalsImplementation } from \"./index\";\n\nexport interface ReactDispatcher {\n\tuseRef: typeof React.useRef;\n\tuseCallback: typeof React.useCallback;\n\tuseReducer: typeof React.useReducer;\n\tuseSyncExternalStore: typeof React.useSyncExternalStore;\n\tuseEffect: typeof React.useEffect;\n\tuseImperativeHandle: typeof React.useImperativeHandle;\n}\n\n// In order for signals to work in React, we need to observe what signals a\n// component uses while rendering. To do this, we need to know when a component\n// is rendering. To do this, we watch the transition of the\n// ReactCurrentDispatcher to know when a component is rerendering.\n//\n// To track when we are entering and exiting a component render (i.e. before and\n// after React renders a component), we track how the dispatcher changes.\n// Outside of a component rendering, the dispatcher is set to an instance that\n// errors or warns when any hooks are called. This behavior is prevents hooks\n// from being used outside of components. Right before React renders a\n// component, the dispatcher is set to an instance that doesn't warn or error\n// and contains the implementations of all hooks. Right after React finishes\n// rendering a component, the dispatcher is set to the erroring one again. This\n// erroring dispatcher is called the `ContextOnlyDispatcher` in React's source.\n//\n// So, we watch the getter and setter on `ReactCurrentDispatcher.current` to\n// monitor the changes to the current ReactDispatcher. When the dispatcher\n// changes from the ContextOnlyDispatcher to a \"valid\" dispatcher, we assume we\n// are entering a component render. At this point, we setup our\n// auto-subscriptions for any signals used in the component. We do this by\n// creating an Signal effect and manually starting the Signal effect. We use\n// `useSyncExternalStore` to trigger rerenders on the component when any signals\n// it uses changes.\n//\n// When the dispatcher changes from a valid dispatcher back to the\n// ContextOnlyDispatcher, we assume we are exiting a component render. At this\n// point we stop the effect.\n//\n// Some additional complexities to be aware of:\n// - If a component calls `setState` while rendering, React will re-render the\n// component immediately. Before triggering the re-render, React will change\n// the dispatcher to the HooksDispatcherOnRerender. When we transition to this\n// rerendering adapter, we need to re-trigger our hooks to keep the order of\n// hooks the same for every render of a component.\n//\n// - In development, useReducer, useState, and useMemo change the dispatcher to\n// a different warning dispatcher (not ContextOnlyDispatcher) before invoking\n// the reducer and resets it right after.\n//\n// The useSyncExternalStore shim will use some of these hooks when we invoke\n// it while entering a component render. We need to prevent this dispatcher\n// change caused by these hooks from re-triggering our entering logic (it\n// would cause an infinite loop if we did not). We do this by using a lock to\n// prevent the setter from running while we are in the setter.\n//\n// When a Component's function body invokes useReducer, useState, or useMemo,\n// this change in dispatcher should not signal that we are entering or exiting\n// a component render. We ignore this change by detecting these dispatchers as\n// different from ContextOnlyDispatcher and other valid dispatchers.\n//\n// - The `use` hook will change the dispatcher to from a valid update dispatcher\n// to a valid mount dispatcher in some cases. Similarly to useReducer\n// mentioned above, we should not signal that we are exiting a component\n// during this change. Because these other valid dispatchers do not pass the\n// ContextOnlyDispatcher check, they do not affect our logic.\n//\n// - When server rendering, React does not change the dispatcher before and\n// after each component render. It sets it once for before the first render\n// and once for after the last render. This means that we will not be able to\n// detect when we are entering or exiting a component render. This is fine\n// because we don't need to detect this for server rendering. A component\n// can't trigger async rerenders in SSR so we don't need to track signals.\n//\n// If a component updates a signal value while rendering during SSR, we will\n// not rerender the component because the signal value will synchronously\n// change so all reads of the signal further down the tree will see the new\n// value.\n\n/*\nBelow is a state machine definition for transitions between the various\ndispatchers in React's prod build. (It does not include dev time warning\ndispatchers which are just always ignored).\n\nENTER and EXIT suffixes indicates whether this ReactCurrentDispatcher transition\nsignals we are entering or exiting a component render, or if it doesn't signal a\nchange in the component rendering lifecyle (NOOP).\n\n```js\n// Paste this into https://stately.ai/viz to visualize the state machine.\nimport { createMachine } from \"xstate\";\n\n// ENTER, EXIT, NOOP suffixes indicates whether this ReactCurrentDispatcher\n// transition signals we are entering or exiting a component render, or\n// if it doesn't signal a change in the component rendering lifecyle (NOOP).\n\nconst dispatcherMachinePROD = createMachine({\n\tid: \"ReactCurrentDispatcher_PROD\",\n\tinitial: \"null\",\n\tstates: {\n\t\tnull: {\n\t\t\ton: {\n\t\t\t\tpushDispatcher: \"ContextOnlyDispatcher\",\n\t\t\t},\n\t\t},\n\t\tContextOnlyDispatcher: {\n\t\t\ton: {\n\t\t\t\trenderWithHooks_Mount_ENTER: \"HooksDispatcherOnMount\",\n\t\t\t\trenderWithHooks_Update_ENTER: \"HooksDispatcherOnUpdate\",\n\t\t\t\tpushDispatcher_NOOP: \"ContextOnlyDispatcher\",\n\t\t\t\tpopDispatcher_NOOP: \"ContextOnlyDispatcher\",\n\t\t\t},\n\t\t},\n\t\tHooksDispatcherOnMount: {\n\t\t\ton: {\n\t\t\t\trenderWithHooksAgain_ENTER: \"HooksDispatcherOnRerender\",\n\t\t\t\tresetHooksAfterThrow_EXIT: \"ContextOnlyDispatcher\",\n\t\t\t\tfinishRenderingHooks_EXIT: \"ContextOnlyDispatcher\",\n\t\t\t},\n\t\t},\n\t\tHooksDispatcherOnUpdate: {\n\t\t\ton: {\n\t\t\t\trenderWithHooksAgain_ENTER: \"HooksDispatcherOnRerender\",\n\t\t\t\tresetHooksAfterThrow_EXIT: \"ContextOnlyDispatcher\",\n\t\t\t\tfinishRenderingHooks_EXIT: \"ContextOnlyDispatcher\",\n\t\t\t\tuse_ResumeSuspensedMount_NOOP: \"HooksDispatcherOnMount\",\n\t\t\t},\n\t\t},\n\t\tHooksDispatcherOnRerender: {\n\t\t\ton: {\n\t\t\t\trenderWithHooksAgain_ENTER: \"HooksDispatcherOnRerender\",\n\t\t\t\tresetHooksAfterThrow_EXIT: \"ContextOnlyDispatcher\",\n\t\t\t\tfinishRenderingHooks_EXIT: \"ContextOnlyDispatcher\",\n\t\t\t},\n\t\t},\n\t},\n});\n```\n*/\n\nexport let isAutoSignalTrackingInstalled = false;\n\nlet store: EffectStore | null = null;\nlet lock = false;\nlet currentDispatcher: ReactDispatcher | null = null;\n\nfunction installCurrentDispatcherHook() {\n\tisAutoSignalTrackingInstalled = true;\n\n\tObject.defineProperty(ReactInternals.ReactCurrentDispatcher, \"current\", {\n\t\tget() {\n\t\t\treturn currentDispatcher;\n\t\t},\n\t\tset(nextDispatcher: ReactDispatcher) {\n\t\t\tif (lock) {\n\t\t\t\tcurrentDispatcher = nextDispatcher;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst currentDispatcherType = getDispatcherType(currentDispatcher);\n\t\t\tconst nextDispatcherType = getDispatcherType(nextDispatcher);\n\n\t\t\t// Update the current dispatcher now so the hooks inside of the\n\t\t\t// useSyncExternalStore shim get the right dispatcher.\n\t\t\tcurrentDispatcher = nextDispatcher;\n\t\t\tif (\n\t\t\t\tisEnteringComponentRender(currentDispatcherType, nextDispatcherType)\n\t\t\t) {\n\t\t\t\tlock = true;\n\t\t\t\tstore = _useSignalsImplementation(1);\n\t\t\t\tlock = false;\n\t\t\t} else if (\n\t\t\t\tisRestartingComponentRender(currentDispatcherType, nextDispatcherType)\n\t\t\t) {\n\t\t\t\tstore?.f();\n\t\t\t\tlock = true;\n\t\t\t\tstore = _useSignalsImplementation(1);\n\t\t\t\tlock = false;\n\t\t\t} else if (\n\t\t\t\tisExitingComponentRender(currentDispatcherType, nextDispatcherType)\n\t\t\t) {\n\t\t\t\tstore?.f();\n\t\t\t\tstore = null;\n\t\t\t}\n\t\t},\n\t});\n}\n\ntype DispatcherType = number;\nconst ContextOnlyDispatcherType = 1 << 0;\nconst WarningDispatcherType = 1 << 1;\nconst MountDispatcherType = 1 << 2;\nconst UpdateDispatcherType = 1 << 3;\nconst RerenderDispatcherType = 1 << 4;\nconst ServerDispatcherType = 1 << 5;\nconst BrowserClientDispatcherType =\n\tMountDispatcherType | UpdateDispatcherType | RerenderDispatcherType;\n\nconst dispatcherTypeCache = new Map();\nfunction getDispatcherType(dispatcher: ReactDispatcher | null): DispatcherType {\n\t// Treat null the same as the ContextOnlyDispatcher.\n\tif (!dispatcher) return ContextOnlyDispatcherType;\n\n\tconst cached = dispatcherTypeCache.get(dispatcher);\n\tif (cached !== undefined) return cached;\n\n\t// The ContextOnlyDispatcher sets all the hook implementations to a function\n\t// that takes no arguments and throws and error. This dispatcher is the only\n\t// dispatcher where useReducer and useEffect will have the same\n\t// implementation.\n\tlet type: DispatcherType;\n\tconst useCallbackImpl = dispatcher.useCallback.toString();\n\tif (dispatcher.useReducer === dispatcher.useEffect) {\n\t\ttype = ContextOnlyDispatcherType;\n\n\t\t// @ts-expect-error When server rendering, useEffect and useImperativeHandle\n\t\t// are both set to noop functions and so have the same implementation.\n\t} else if (dispatcher.useEffect === dispatcher.useImperativeHandle) {\n\t\ttype = ServerDispatcherType;\n\t} else if (/Invalid/.test(useCallbackImpl)) {\n\t\t// We first check for warning dispatchers because they would also pass some\n\t\t// of the checks below.\n\t\ttype = WarningDispatcherType;\n\t} else if (\n\t\t// The development mount dispatcher invokes a function called\n\t\t// `mountCallback` whereas the development update/re-render dispatcher\n\t\t// invokes a function called `updateCallback`. Use that difference to\n\t\t// determine if we are in a mount or update-like dispatcher in development.\n\t\t// The production mount dispatcher defines an array of the form [callback,\n\t\t// deps] whereas update/re-render dispatchers read the array using array\n\t\t// indices (e.g. `[0]` and `[1]`). Use those differences to determine if we\n\t\t// are in a mount or update-like dispatcher in production.\n\t\t/updateCallback/.test(useCallbackImpl) ||\n\t\t(/\\[0\\]/.test(useCallbackImpl) && /\\[1\\]/.test(useCallbackImpl))\n\t) {\n\t\t// The update and rerender dispatchers have different implementations for\n\t\t// useReducer. We'll check it's implementation to determine if this is the\n\t\t// rerender or update dispatcher.\n\t\tlet useReducerImpl = dispatcher.useReducer.toString();\n\t\tif (\n\t\t\t// The development rerender dispatcher invokes a function called\n\t\t\t// `rerenderReducer` whereas the update dispatcher invokes a function\n\t\t\t// called `updateReducer`. The production rerender dispatcher returns an\n\t\t\t// array of the form `[state, dispatch]` whereas the update dispatcher\n\t\t\t// returns an array of `[fiber.memoizedState, dispatch]` so we check the\n\t\t\t// return statement in the implementation of useReducer to differentiate\n\t\t\t// between the two.\n\t\t\t/rerenderReducer/.test(useReducerImpl) ||\n\t\t\t/return\\s*\\[\\w+,/.test(useReducerImpl)\n\t\t) {\n\t\t\ttype = RerenderDispatcherType;\n\t\t} else {\n\t\t\ttype = UpdateDispatcherType;\n\t\t}\n\t} else {\n\t\ttype = MountDispatcherType;\n\t}\n\n\tdispatcherTypeCache.set(dispatcher, type);\n\treturn type;\n}\n\nfunction isEnteringComponentRender(\n\tcurrentDispatcherType: DispatcherType,\n\tnextDispatcherType: DispatcherType\n): boolean {\n\tif (\n\t\tcurrentDispatcherType & ContextOnlyDispatcherType &&\n\t\tnextDispatcherType & BrowserClientDispatcherType\n\t) {\n\t\t// ## Mount or update (ContextOnlyDispatcher -> ValidDispatcher (Mount or Update))\n\t\t//\n\t\t// If the current dispatcher is the ContextOnlyDispatcher and the next\n\t\t// dispatcher is a valid dispatcher, we are entering a component render.\n\t\treturn true;\n\t} else if (\n\t\tcurrentDispatcherType & WarningDispatcherType ||\n\t\tnextDispatcherType & WarningDispatcherType\n\t) {\n\t\t// ## Warning dispatcher\n\t\t//\n\t\t// If the current dispatcher or next dispatcher is an warning dispatcher,\n\t\t// we are not entering a component render. The current warning dispatchers\n\t\t// are used to warn when hooks are nested improperly and do not indicate\n\t\t// entering a new component render.\n\t\treturn false;\n\t} else {\n\t\t// ## Resuming suspended mount edge case (Update -> Mount)\n\t\t//\n\t\t// If we are transitioning from the update dispatcher to the mount\n\t\t// dispatcher, then this component is using the `use` hook and is resuming\n\t\t// from a mount. We should not re-invoke our hooks in this situation since\n\t\t// we are not entering a new component render, but instead continuing a\n\t\t// previous render.\n\t\t//\n\t\t// ## Other transitions\n\t\t//\n\t\t// For example, Mount -> Mount, Update -> Update, Mount -> Update, any\n\t\t// transition in and out of invalid dispatchers.\n\t\t//\n\t\t// There is no known transition for the following transitions so we default\n\t\t// to not triggering a re-enter of the component.\n\t\t// - HooksDispatcherOnMount -> HooksDispatcherOnMount\n\t\t// - HooksDispatcherOnMount -> HooksDispatcherOnUpdate\n\t\t// - HooksDispatcherOnUpdate -> HooksDispatcherOnUpdate\n\t\treturn false;\n\t}\n}\n\nfunction isRestartingComponentRender(\n\tcurrentDispatcherType: DispatcherType,\n\tnextDispatcherType: DispatcherType\n): boolean {\n\t// A transition from a valid browser dispatcher into the rerender dispatcher\n\t// is the restart of a component render, so we should end the current\n\t// component effect and re-invoke our hooks. Details below.\n\t//\n\t// ## In-place rerendering (e.g. Mount -> Rerender)\n\t//\n\t// If we are transitioning from the mount, update, or rerender dispatcher to\n\t// the rerender dispatcher (e.g. HooksDispatcherOnMount to\n\t// HooksDispatcherOnRerender), then this component is rerendering due to\n\t// calling setState inside of its function body. We are re-entering a\n\t// component's render method and so we should re-invoke our hooks.\n\n\treturn Boolean(\n\t\tcurrentDispatcherType & BrowserClientDispatcherType &&\n\t\t\tnextDispatcherType & RerenderDispatcherType\n\t);\n}\n\n/**\n * We are exiting a component render if the current dispatcher is a valid\n * dispatcher and the next dispatcher is the ContextOnlyDispatcher.\n */\nfunction isExitingComponentRender(\n\tcurrentDispatcherType: DispatcherType,\n\tnextDispatcherType: DispatcherType\n): boolean {\n\treturn Boolean(\n\t\tcurrentDispatcherType & BrowserClientDispatcherType &&\n\t\t\tnextDispatcherType & ContextOnlyDispatcherType\n\t);\n}\n\ninterface JsxRuntimeModule {\n\tjsx?(type: any, ...rest: any[]): unknown;\n\tjsxs?(type: any, ...rest: any[]): unknown;\n\tjsxDEV?(type: any, ...rest: any[]): unknown;\n}\n\nexport function installJSXHooks() {\n\tconst JsxPro: JsxRuntimeModule = jsxRuntime;\n\tconst JsxDev: JsxRuntimeModule = jsxRuntimeDev;\n\n\t/**\n\t * createElement _may_ be called by jsx runtime as a fallback in certain cases,\n\t * so we need to wrap it regardless.\n\t *\n\t * The jsx exports depend on the `NODE_ENV` var to ensure the users' bundler doesn't\n\t * include both, so one of them will be set with `undefined` values.\n\t */\n\tReact.createElement = wrapJsx(React.createElement);\n\tJsxDev.jsx && /* */ (JsxDev.jsx = wrapJsx(JsxDev.jsx));\n\tJsxPro.jsx && /* */ (JsxPro.jsx = wrapJsx(JsxPro.jsx));\n\tJsxDev.jsxs && /* */ (JsxDev.jsxs = wrapJsx(JsxDev.jsxs));\n\tJsxPro.jsxs && /* */ (JsxPro.jsxs = wrapJsx(JsxPro.jsxs));\n\tJsxDev.jsxDEV && /**/ (JsxDev.jsxDEV = wrapJsx(JsxDev.jsxDEV));\n\tJsxPro.jsxDEV && /**/ (JsxPro.jsxDEV = wrapJsx(JsxPro.jsxDEV));\n}\n\nexport function installAutoSignalTracking() {\n\tconst [major] = reactVersion.split(\".\").map(Number);\n\tif (major >= 19) {\n\t\tthrow new Error(\n\t\t\t\"Automatic signals tracking is not supported in React 19 and later, try the Babel plugin instead https://github.com/preactjs/signals/tree/main/packages/react-transform#signals-react-transform.\"\n\t\t);\n\t}\n\tinstallCurrentDispatcherHook();\n\tinstallJSXHooks();\n}\n","import {\n\tsignal,\n\tcomputed,\n\teffect,\n\tSignal,\n\tReadonlySignal,\n} from \"@preact/signals-core\";\nimport {\n\tuseRef,\n\tuseMemo,\n\tuseEffect,\n\tuseLayoutEffect,\n\tversion as reactVersion,\n} from \"react\";\nimport { useSyncExternalStore } from \"use-sync-external-store/shim/index.js\";\nimport { isAutoSignalTrackingInstalled } from \"./auto\";\n\nexport { installAutoSignalTracking } from \"./auto\";\n\nconst [major] = reactVersion.split(\".\").map(Number);\nconst Empty = [] as const;\n// V19 https://github.com/facebook/react/blob/346c7d4c43a0717302d446da9e7423a8e28d8996/packages/shared/ReactSymbols.js#L15\n// V18 https://github.com/facebook/react/blob/346c7d4c43a0717302d446da9e7423a8e28d8996/packages/shared/ReactSymbols.js#L15\nconst ReactElemType = Symbol.for(\n\tmajor >= 19 ? \"react.transitional.element\" : \"react.element\"\n);\n\nconst noop = () => {};\n\nexport function wrapJsx(jsx: T): T {\n\tif (typeof jsx !== \"function\") return jsx;\n\n\treturn function (type: any, props: any, ...rest: any[]) {\n\t\tif (typeof type === \"string\" && props) {\n\t\t\tfor (let i in props) {\n\t\t\t\tlet v = props[i];\n\t\t\t\tif (i !== \"children\" && v instanceof Signal) {\n\t\t\t\t\tprops[i] = v.value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn jsx.call(jsx, type, props, ...rest);\n\t} as any as T;\n}\n\nconst symDispose: unique symbol =\n\t(Symbol as any).dispose || Symbol.for(\"Symbol.dispose\");\n\ninterface Effect {\n\t_sources: object | undefined;\n\t_start(): () => void;\n\t_callback(): void;\n\t_dispose(): void;\n}\n\n/**\n * Use this flag to represent a bare `useSignals` call that doesn't manually\n * close its effect store and relies on auto-closing when the next useSignals is\n * called or after a microtask\n */\nconst UNMANAGED = 0;\n/**\n * Use this flag to represent a `useSignals` call that is manually closed by a\n * try/finally block in a component's render method. This is the default usage\n * that the react-transform plugin uses.\n */\nconst MANAGED_COMPONENT = 1;\n/**\n * Use this flag to represent a `useSignals` call that is manually closed by a\n * try/finally block in a hook body. This is the default usage that the\n * react-transform plugin uses.\n */\nconst MANAGED_HOOK = 2;\n\n/**\n * An enum defining how this store is used. See the documentation for each enum\n * member for more details.\n * @see {@link UNMANAGED}\n * @see {@link MANAGED_COMPONENT}\n * @see {@link MANAGED_HOOK}\n */\ntype EffectStoreUsage =\n\t| typeof UNMANAGED\n\t| typeof MANAGED_COMPONENT\n\t| typeof MANAGED_HOOK;\n\nexport interface EffectStore {\n\t/**\n\t * An enum defining how this hook is used and whether it is invoked in a\n\t * component's body or hook body. See the comment on `EffectStoreUsage` for\n\t * more details.\n\t */\n\treadonly _usage: EffectStoreUsage;\n\treadonly effect: Effect;\n\tsubscribe(onStoreChange: () => void): () => void;\n\tgetSnapshot(): number;\n\t/** startEffect - begin tracking signals used in this component */\n\t_start(): void;\n\t/** finishEffect - stop tracking the signals used in this component */\n\tf(): void;\n\t[symDispose](): void;\n}\n\nlet currentStore: EffectStore | undefined;\n\nfunction startComponentEffect(\n\tprevStore: EffectStore | undefined,\n\tnextStore: EffectStore\n) {\n\tconst endEffect = nextStore.effect._start();\n\tcurrentStore = nextStore;\n\n\treturn finishComponentEffect.bind(nextStore, prevStore, endEffect);\n}\n\nfunction finishComponentEffect(\n\tthis: EffectStore,\n\tprevStore: EffectStore | undefined,\n\tendEffect: () => void\n) {\n\tendEffect();\n\tcurrentStore = prevStore;\n}\n\n/**\n * A redux-like store whose store value is a positive 32bit integer (a\n * 'version').\n *\n * React subscribes to this store and gets a snapshot of the current 'version',\n * whenever the 'version' changes, we tell React it's time to update the\n * component (call 'onStoreChange').\n *\n * How we achieve this is by creating a binding with an 'effect', when the\n * `effect._callback' is called, we update our store version and tell React to\n * re-render the component ([1] We don't really care when/how React does it).\n *\n * [1]\n * @see https://react.dev/reference/react/useSyncExternalStore\n * @see\n * https://github.com/reactjs/rfcs/blob/main/text/0214-use-sync-external-store.md\n *\n * @param _usage An enum defining how this hook is used and whether it is\n * invoked in a component's body or hook body. See the comment on\n * `EffectStoreUsage` for more details.\n */\nfunction createEffectStore(_usage: EffectStoreUsage): EffectStore {\n\tlet effectInstance!: Effect;\n\tlet endEffect: (() => void) | undefined;\n\tlet version = 0;\n\tlet onChangeNotifyReact: (() => void) | undefined;\n\n\tlet unsubscribe = effect(function (this: Effect) {\n\t\teffectInstance = this;\n\t});\n\teffectInstance._callback = function () {\n\t\tversion = (version + 1) | 0;\n\t\tif (onChangeNotifyReact) onChangeNotifyReact();\n\t};\n\n\treturn {\n\t\t_usage,\n\t\teffect: effectInstance,\n\t\tsubscribe(onStoreChange) {\n\t\t\tonChangeNotifyReact = onStoreChange;\n\n\t\t\treturn function () {\n\t\t\t\t/**\n\t\t\t\t * Rotate to next version when unsubscribing to ensure that components are re-run\n\t\t\t\t * when subscribing again.\n\t\t\t\t *\n\t\t\t\t * In StrictMode, 'memo'-ed components seem to keep a stale snapshot version, so\n\t\t\t\t * don't re-run after subscribing again if the version is the same as last time.\n\t\t\t\t *\n\t\t\t\t * Because we unsubscribe from the effect, the version may not change. We simply\n\t\t\t\t * set a new initial version in case of stale snapshots here.\n\t\t\t\t */\n\t\t\t\tversion = (version + 1) | 0;\n\t\t\t\tonChangeNotifyReact = undefined;\n\t\t\t\tunsubscribe();\n\t\t\t};\n\t\t},\n\t\tgetSnapshot() {\n\t\t\treturn version;\n\t\t},\n\t\t_start() {\n\t\t\t// In general, we want to support two kinds of usages of useSignals:\n\t\t\t//\n\t\t\t// A) Managed: calling useSignals in a component or hook body wrapped in a\n\t\t\t// try/finally (like what the react-transform plugin does)\n\t\t\t//\n\t\t\t// B) Unmanaged: Calling useSignals directly without wrapping in a\n\t\t\t// try/finally\n\t\t\t//\n\t\t\t// For managed, we finish the effect in the finally block of the component\n\t\t\t// or hook body. For unmanaged, we finish the effect in the next\n\t\t\t// useSignals call or after a microtask.\n\t\t\t//\n\t\t\t// There are different tradeoffs which each approach. With managed, using\n\t\t\t// a try/finally ensures that only signals used in the component or hook\n\t\t\t// body are tracked. However, signals accessed in render props are missed\n\t\t\t// because the render prop is invoked in another component that may or may\n\t\t\t// not realize it is rendering signals accessed in the render prop it is\n\t\t\t// given.\n\t\t\t//\n\t\t\t// The other approach is \"unmanaged\": to call useSignals directly without\n\t\t\t// wrapping in a try/finally. This approach is easier to manually write in\n\t\t\t// situations where a build step isn't available but does open up the\n\t\t\t// possibility of catching signals accessed in other code before the\n\t\t\t// effect is closed (e.g. in a layout effect). Most situations where this\n\t\t\t// could happen are generally consider bad patterns or bugs. For example,\n\t\t\t// using a signal in a component and not having a call to `useSignals`\n\t\t\t// would be an bug. Or using a signal in `useLayoutEffect` is generally\n\t\t\t// not recommended since that layout effect won't update when the signals'\n\t\t\t// value change.\n\t\t\t//\n\t\t\t// To support both approaches, we need to track how each invocation of\n\t\t\t// useSignals is used, so we can properly transition between different\n\t\t\t// kinds of usages.\n\t\t\t//\n\t\t\t// The following table shows the different scenarios and how we should\n\t\t\t// handle them.\n\t\t\t//\n\t\t\t// Key:\n\t\t\t// 0 = UNMANAGED\n\t\t\t// 1 = MANAGED_COMPONENT\n\t\t\t// 2 = MANAGED_HOOK\n\t\t\t//\n\t\t\t// Pattern:\n\t\t\t// prev store usage -> this store usage: action to take\n\t\t\t//\n\t\t\t// - 0 -> 0: finish previous effect (unknown to unknown)\n\t\t\t//\n\t\t\t// We don't know how the previous effect was used, so we need to finish\n\t\t\t// it before starting the next effect.\n\t\t\t//\n\t\t\t// - 0 -> 1: finish previous effect\n\t\t\t//\n\t\t\t// Assume previous invocation was another component or hook from another\n\t\t\t// component. Nested component renders (renderToStaticMarkup within a\n\t\t\t// component's render) won't be supported with bare useSignals calls.\n\t\t\t//\n\t\t\t// - 0 -> 2: capture & restore\n\t\t\t//\n\t\t\t// Previous invocation could be a component or a hook. Either way,\n\t\t\t// restore it after our invocation so that it can continue to capture\n\t\t\t// any signals after we exit.\n\t\t\t//\n\t\t\t// - 1 -> 0: Do nothing. Signals already captured by current effect store\n\t\t\t// - 1 -> 1: capture & restore (e.g. component calls renderToStaticMarkup)\n\t\t\t// - 1 -> 2: capture & restore (e.g. hook)\n\t\t\t//\n\t\t\t// - 2 -> 0: Do nothing. Signals already captured by current effect store\n\t\t\t// - 2 -> 1: capture & restore (e.g. hook calls renderToStaticMarkup)\n\t\t\t// - 2 -> 2: capture & restore (e.g. nested hook calls)\n\n\t\t\tif (currentStore == undefined) {\n\t\t\t\tendEffect = startComponentEffect(undefined, this);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst prevUsage = currentStore._usage;\n\t\t\tconst thisUsage = this._usage;\n\n\t\t\tif (\n\t\t\t\t(prevUsage == UNMANAGED && thisUsage == UNMANAGED) || // 0 -> 0\n\t\t\t\t(prevUsage == UNMANAGED && thisUsage == MANAGED_COMPONENT) // 0 -> 1\n\t\t\t) {\n\t\t\t\t// finish previous effect\n\t\t\t\tcurrentStore.f();\n\t\t\t\tendEffect = startComponentEffect(undefined, this);\n\t\t\t} else if (\n\t\t\t\t(prevUsage == MANAGED_COMPONENT && thisUsage == UNMANAGED) || // 1 -> 0\n\t\t\t\t(prevUsage == MANAGED_HOOK && thisUsage == UNMANAGED) // 2 -> 0\n\t\t\t) {\n\t\t\t\t// Do nothing since it'll be captured by current effect store\n\t\t\t} else {\n\t\t\t\t// nested scenarios, so capture and restore the previous effect store\n\t\t\t\tendEffect = startComponentEffect(currentStore, this);\n\t\t\t}\n\t\t},\n\t\tf() {\n\t\t\tconst end = endEffect;\n\t\t\tendEffect = undefined;\n\t\t\tend?.();\n\t\t},\n\t\t[symDispose]() {\n\t\t\tthis.f();\n\t\t},\n\t};\n}\n\nfunction createEmptyEffectStore(): EffectStore {\n\treturn {\n\t\t_usage: UNMANAGED,\n\t\teffect: {\n\t\t\t_sources: undefined,\n\t\t\t_callback() {},\n\t\t\t_start() {\n\t\t\t\treturn noop;\n\t\t\t},\n\t\t\t_dispose() {},\n\t\t},\n\t\tsubscribe() {\n\t\t\treturn noop;\n\t\t},\n\t\tgetSnapshot() {\n\t\t\treturn 0;\n\t\t},\n\t\t_start() {},\n\t\tf() {},\n\t\t[symDispose]() {},\n\t};\n}\n\nconst emptyEffectStore = createEmptyEffectStore();\n\nconst _queueMicroTask = Promise.prototype.then.bind(Promise.resolve());\n\nlet finalCleanup: Promise | undefined;\nexport function ensureFinalCleanup() {\n\tif (!finalCleanup) {\n\t\tfinalCleanup = _queueMicroTask(cleanupTrailingStore);\n\t}\n}\nfunction cleanupTrailingStore() {\n\tfinalCleanup = undefined;\n\tcurrentStore?.f();\n}\n\nconst useIsomorphicLayoutEffect =\n\ttypeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n\n/**\n * Custom hook to create the effect to track signals used during render and\n * subscribe to changes to rerender the component when the signals change.\n */\nexport function _useSignalsImplementation(\n\t_usage: EffectStoreUsage = UNMANAGED\n): EffectStore {\n\tensureFinalCleanup();\n\n\tconst storeRef = useRef();\n\tif (storeRef.current == null) {\n\t\tstoreRef.current = createEffectStore(_usage);\n\t}\n\n\tconst store = storeRef.current;\n\tuseSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot);\n\tstore._start();\n\t// note: _usage is a constant here, so conditional is okay\n\tif (_usage === UNMANAGED) useIsomorphicLayoutEffect(cleanupTrailingStore);\n\n\treturn store;\n}\n\n/**\n * A wrapper component that renders a Signal's value directly as a Text node or JSX.\n */\nfunction SignalValue({ data }: { data: Signal }) {\n\tconst store = _useSignalsImplementation(1);\n\ttry {\n\t\treturn data.value;\n\t} finally {\n\t\tstore.f();\n\t}\n}\n\n// Decorate Signals so React renders them as components.\nObject.defineProperties(Signal.prototype, {\n\t$$typeof: { configurable: true, value: ReactElemType },\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\tref: { configurable: true, value: null },\n});\n\nexport function useSignals(usage?: EffectStoreUsage): EffectStore {\n\tif (isAutoSignalTrackingInstalled) return emptyEffectStore;\n\treturn _useSignalsImplementation(usage);\n}\n\nexport function useSignal(value: T): Signal;\nexport function useSignal(): Signal;\nexport function useSignal(value?: T) {\n\treturn useMemo(() => signal(value), Empty);\n}\n\nexport function useComputed(compute: () => T): ReadonlySignal {\n\tconst $compute = useRef(compute);\n\t$compute.current = compute;\n\treturn useMemo(() => computed(() => $compute.current()), Empty);\n}\n\nexport function useSignalEffect(cb: () => void | (() => void)) {\n\tconst callback = useRef(cb);\n\tcallback.current = cb;\n\n\tuseEffect(() => {\n\t\treturn effect(function (this: Effect) {\n\t\t\treturn callback.current();\n\t\t});\n\t}, Empty);\n}\n"],"names":["signalsCore","require","React","index_js","jsxRuntime","jsxRuntimeDev","_interopDefaultLegacy","e","default","React__default","jsxRuntime__default","jsxRuntimeDev__default","isAutoSignalTrackingInstalled","store","lock","currentDispatcher","dispatcherTypeCache","Map","getDispatcherType","dispatcher","type","cached","get","undefined","useCallbackImpl","useCallback","toString","useReducer","useEffect","useImperativeHandle","test","useReducerImpl","set","_reactVersion$split$m","reactVersion","split","map","Number","Empty","ReactElemType","Symbol","noop","wrapJsx","jsx","props","i","v","Signal","value","call","apply","concat","slice","arguments","currentStore","symDispose","dispose","startComponentEffect","prevStore","nextStore","endEffect","effect","_start","finishComponentEffect","bind","_ref2","finalCleanup","emptyEffectStore","_usage","_sources","_callback","_dispose","subscribe","getSnapshot","f","_queueMicroTask","Promise","prototype","then","resolve","ensureFinalCleanup","cleanupTrailingStore","_currentStore","useIsomorphicLayoutEffect","window","useLayoutEffect","_useSignalsImplementation","storeRef","useRef","current","_ref","effectInstance","onChangeNotifyReact","version","unsubscribe","this","onStoreChange","prevUsage","thisUsage","end","createEffectStore","useSyncExternalStore","Object","defineProperties","$$typeof","configurable","_ref3","data","ref","exports","installAutoSignalTracking","Error","defineProperty","ReactInternals","__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED","ReactCurrentDispatcher","nextDispatcher","currentDispatcherType","nextDispatcherType","MountDispatcherType","isEnteringComponentRender","Boolean","isRestartingComponentRender","_store","isExitingComponentRender","_store2","installCurrentDispatcherHook","JsxPro","JsxDev","createElement","jsxs","jsxDEV","installJSXHooks","useComputed","compute","$compute","useMemo","computed","useSignal","signal","useSignalEffect","cb","callback","useSignals","usage"],"mappings":"AAqJW,IAAAA,EAAAC,QAAA,wBAAAC,EAAAD,QAAA,SAAAE,EAAAF,QAAA,yCAAAG,EAAAH,QAAA,qBAAAI,EAAAJ,QAAA,yBAAA,SAAAK,EAAAC,GAAA,OAAAA,GAAA,iBAAAA,GAAA,YAAAA,EAAAA,EAAAC,QAAAD,CAAA,CAAA,IAAAE,eAAAH,EAAAJ,GAAAQ,eAAAJ,EAAAF,GAAAO,eAAAL,EAAAD,GAAAO,GAAgC,EAEvCC,EAA4B,KAC5BC,GAAO,EACPC,EAA4C,KAsD1CC,EAAsB,IAAIC,IAChC,SAASC,EAAkBC,GAE1B,IAAKA,EAAY,OAZgB,EAcjC,IAOIC,EAPEC,EAASL,EAAoBM,IAAIH,GACvC,QAAeI,IAAXF,EAAsB,OAAOA,EAOjC,IAAMG,EAAkBL,EAAWM,YAAYC,WAC/C,GAAIP,EAAWQ,aAAeR,EAAWS,UACxCR,EAxBgC,UA4BtBD,EAAWS,YAAcT,EAAWU,oBAC9CT,EAxB2B,QAyBjB,GAAA,UAAUU,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5B,OAAOwF,EAAOA,QAAC,WAAA,OAAMG,EAAAA,OAAsB3F,EAAM,EAAEV,EACpD,EAiBAuE,QAAA+B,gBATgB,SAAgBC,GAC/B,IAAMC,EAAWtD,EAAAA,OAAOqD,GACxBC,EAASrD,QAAUoD,EAEnBjH,EAAAA,UAAU,WACT,OAAOiC,EAAMA,OAAC,WACb,OAAOiF,EAASrD,SACjB,EACD,EAAGnD,EACJ,EAAAuE,QAAAkC,WA1BM,SAAqBC,GAC1B,GAAIpI,EAA+B,OAAOuD,OAC1C,OAAOmB,EAA0B0D,EAClC,EAuBAnC,QAAAnE,QAAAA"} +\ No newline at end of file ++{"version":3,"file":"runtime.js","sources":["../src/index.ts"],"sourcesContent":["import {\n\tsignal,\n\tcomputed,\n\teffect,\n\tSignal,\n\tReadonlySignal,\n} from \"@preact/signals-core\";\nimport {\n\tuseRef,\n\tuseMemo,\n\tuseEffect,\n\tuseLayoutEffect,\n\tversion as reactVersion,\n} from \"react\";\nimport { useSyncExternalStore } from \"use-sync-external-store/shim/index.js\";\n\nconst [major] = reactVersion.split(\".\").map(Number);\nconst Empty = [] as const;\n// V19 https://github.com/facebook/react/blob/346c7d4c43a0717302d446da9e7423a8e28d8996/packages/shared/ReactSymbols.js#L15\n// V18 https://github.com/facebook/react/blob/346c7d4c43a0717302d446da9e7423a8e28d8996/packages/shared/ReactSymbols.js#L15\nconst ReactElemType = Symbol.for(\n\tmajor >= 19 ? \"react.transitional.element\" : \"react.element\"\n);\n\nexport function wrapJsx(jsx: T): T {\n\tif (typeof jsx !== \"function\") return jsx;\n\n\treturn function (type: any, props: any, ...rest: any[]) {\n\t\tif (typeof type === \"string\" && props) {\n\t\t\tfor (let i in props) {\n\t\t\t\tlet v = props[i];\n\t\t\t\tif (i !== \"children\" && v instanceof Signal) {\n\t\t\t\t\tprops[i] = v.value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn jsx.call(jsx, type, props, ...rest);\n\t} as any as T;\n}\n\nconst symDispose: unique symbol =\n\t(Symbol as any).dispose || Symbol.for(\"Symbol.dispose\");\n\ninterface Effect {\n\t_sources: object | undefined;\n\t_start(): () => void;\n\t_callback(): void;\n\t_dispose(): void;\n}\n\n/**\n * Use this flag to represent a bare `useSignals` call that doesn't manually\n * close its effect store and relies on auto-closing when the next useSignals is\n * called or after a microtask\n */\nconst UNMANAGED = 0;\n/**\n * Use this flag to represent a `useSignals` call that is manually closed by a\n * try/finally block in a component's render method. This is the default usage\n * that the react-transform plugin uses.\n */\nconst MANAGED_COMPONENT = 1;\n/**\n * Use this flag to represent a `useSignals` call that is manually closed by a\n * try/finally block in a hook body. This is the default usage that the\n * react-transform plugin uses.\n */\nconst MANAGED_HOOK = 2;\n\n/**\n * An enum defining how this store is used. See the documentation for each enum\n * member for more details.\n * @see {@link UNMANAGED}\n * @see {@link MANAGED_COMPONENT}\n * @see {@link MANAGED_HOOK}\n */\ntype EffectStoreUsage =\n\t| typeof UNMANAGED\n\t| typeof MANAGED_COMPONENT\n\t| typeof MANAGED_HOOK;\n\nexport interface EffectStore {\n\t/**\n\t * An enum defining how this hook is used and whether it is invoked in a\n\t * component's body or hook body. See the comment on `EffectStoreUsage` for\n\t * more details.\n\t */\n\treadonly _usage: EffectStoreUsage;\n\treadonly effect: Effect;\n\tsubscribe(onStoreChange: () => void): () => void;\n\tgetSnapshot(): number;\n\t/** startEffect - begin tracking signals used in this component */\n\t_start(): void;\n\t/** finishEffect - stop tracking the signals used in this component */\n\tf(): void;\n\t[symDispose](): void;\n}\n\nlet currentStore: EffectStore | undefined;\n\nfunction startComponentEffect(\n\tprevStore: EffectStore | undefined,\n\tnextStore: EffectStore\n) {\n\tconst endEffect = nextStore.effect._start();\n\tcurrentStore = nextStore;\n\n\treturn finishComponentEffect.bind(nextStore, prevStore, endEffect);\n}\n\nfunction finishComponentEffect(\n\tthis: EffectStore,\n\tprevStore: EffectStore | undefined,\n\tendEffect: () => void\n) {\n\tendEffect();\n\tcurrentStore = prevStore;\n}\n\n/**\n * A redux-like store whose store value is a positive 32bit integer (a\n * 'version').\n *\n * React subscribes to this store and gets a snapshot of the current 'version',\n * whenever the 'version' changes, we tell React it's time to update the\n * component (call 'onStoreChange').\n *\n * How we achieve this is by creating a binding with an 'effect', when the\n * `effect._callback' is called, we update our store version and tell React to\n * re-render the component ([1] We don't really care when/how React does it).\n *\n * [1]\n * @see https://react.dev/reference/react/useSyncExternalStore\n * @see\n * https://github.com/reactjs/rfcs/blob/main/text/0214-use-sync-external-store.md\n *\n * @param _usage An enum defining how this hook is used and whether it is\n * invoked in a component's body or hook body. See the comment on\n * `EffectStoreUsage` for more details.\n */\nfunction createEffectStore(_usage: EffectStoreUsage): EffectStore {\n\tlet effectInstance!: Effect;\n\tlet endEffect: (() => void) | undefined;\n\tlet version = 0;\n\tlet onChangeNotifyReact: (() => void) | undefined;\n\n\tlet unsubscribe = effect(function (this: Effect) {\n\t\teffectInstance = this;\n\t});\n\teffectInstance._callback = function () {\n\t\tversion = (version + 1) | 0;\n\t\tif (onChangeNotifyReact) onChangeNotifyReact();\n\t};\n\n\treturn {\n\t\t_usage,\n\t\teffect: effectInstance,\n\t\tsubscribe(onStoreChange) {\n\t\t\tonChangeNotifyReact = onStoreChange;\n\n\t\t\treturn function () {\n\t\t\t\t/**\n\t\t\t\t * Rotate to next version when unsubscribing to ensure that components are re-run\n\t\t\t\t * when subscribing again.\n\t\t\t\t *\n\t\t\t\t * In StrictMode, 'memo'-ed components seem to keep a stale snapshot version, so\n\t\t\t\t * don't re-run after subscribing again if the version is the same as last time.\n\t\t\t\t *\n\t\t\t\t * Because we unsubscribe from the effect, the version may not change. We simply\n\t\t\t\t * set a new initial version in case of stale snapshots here.\n\t\t\t\t */\n\t\t\t\tversion = (version + 1) | 0;\n\t\t\t\tonChangeNotifyReact = undefined;\n\t\t\t\tunsubscribe();\n\t\t\t};\n\t\t},\n\t\tgetSnapshot() {\n\t\t\treturn version;\n\t\t},\n\t\t_start() {\n\t\t\t// In general, we want to support two kinds of usages of useSignals:\n\t\t\t//\n\t\t\t// A) Managed: calling useSignals in a component or hook body wrapped in a\n\t\t\t// try/finally (like what the react-transform plugin does)\n\t\t\t//\n\t\t\t// B) Unmanaged: Calling useSignals directly without wrapping in a\n\t\t\t// try/finally\n\t\t\t//\n\t\t\t// For managed, we finish the effect in the finally block of the component\n\t\t\t// or hook body. For unmanaged, we finish the effect in the next\n\t\t\t// useSignals call or after a microtask.\n\t\t\t//\n\t\t\t// There are different tradeoffs which each approach. With managed, using\n\t\t\t// a try/finally ensures that only signals used in the component or hook\n\t\t\t// body are tracked. However, signals accessed in render props are missed\n\t\t\t// because the render prop is invoked in another component that may or may\n\t\t\t// not realize it is rendering signals accessed in the render prop it is\n\t\t\t// given.\n\t\t\t//\n\t\t\t// The other approach is \"unmanaged\": to call useSignals directly without\n\t\t\t// wrapping in a try/finally. This approach is easier to manually write in\n\t\t\t// situations where a build step isn't available but does open up the\n\t\t\t// possibility of catching signals accessed in other code before the\n\t\t\t// effect is closed (e.g. in a layout effect). Most situations where this\n\t\t\t// could happen are generally consider bad patterns or bugs. For example,\n\t\t\t// using a signal in a component and not having a call to `useSignals`\n\t\t\t// would be an bug. Or using a signal in `useLayoutEffect` is generally\n\t\t\t// not recommended since that layout effect won't update when the signals'\n\t\t\t// value change.\n\t\t\t//\n\t\t\t// To support both approaches, we need to track how each invocation of\n\t\t\t// useSignals is used, so we can properly transition between different\n\t\t\t// kinds of usages.\n\t\t\t//\n\t\t\t// The following table shows the different scenarios and how we should\n\t\t\t// handle them.\n\t\t\t//\n\t\t\t// Key:\n\t\t\t// 0 = UNMANAGED\n\t\t\t// 1 = MANAGED_COMPONENT\n\t\t\t// 2 = MANAGED_HOOK\n\t\t\t//\n\t\t\t// Pattern:\n\t\t\t// prev store usage -> this store usage: action to take\n\t\t\t//\n\t\t\t// - 0 -> 0: finish previous effect (unknown to unknown)\n\t\t\t//\n\t\t\t// We don't know how the previous effect was used, so we need to finish\n\t\t\t// it before starting the next effect.\n\t\t\t//\n\t\t\t// - 0 -> 1: finish previous effect\n\t\t\t//\n\t\t\t// Assume previous invocation was another component or hook from another\n\t\t\t// component. Nested component renders (renderToStaticMarkup within a\n\t\t\t// component's render) won't be supported with bare useSignals calls.\n\t\t\t//\n\t\t\t// - 0 -> 2: capture & restore\n\t\t\t//\n\t\t\t// Previous invocation could be a component or a hook. Either way,\n\t\t\t// restore it after our invocation so that it can continue to capture\n\t\t\t// any signals after we exit.\n\t\t\t//\n\t\t\t// - 1 -> 0: Do nothing. Signals already captured by current effect store\n\t\t\t// - 1 -> 1: capture & restore (e.g. component calls renderToStaticMarkup)\n\t\t\t// - 1 -> 2: capture & restore (e.g. hook)\n\t\t\t//\n\t\t\t// - 2 -> 0: Do nothing. Signals already captured by current effect store\n\t\t\t// - 2 -> 1: capture & restore (e.g. hook calls renderToStaticMarkup)\n\t\t\t// - 2 -> 2: capture & restore (e.g. nested hook calls)\n\n\t\t\tif (currentStore == undefined) {\n\t\t\t\tendEffect = startComponentEffect(undefined, this);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst prevUsage = currentStore._usage;\n\t\t\tconst thisUsage = this._usage;\n\n\t\t\tif (\n\t\t\t\t(prevUsage == UNMANAGED && thisUsage == UNMANAGED) || // 0 -> 0\n\t\t\t\t(prevUsage == UNMANAGED && thisUsage == MANAGED_COMPONENT) // 0 -> 1\n\t\t\t) {\n\t\t\t\t// finish previous effect\n\t\t\t\tcurrentStore.f();\n\t\t\t\tendEffect = startComponentEffect(undefined, this);\n\t\t\t} else if (\n\t\t\t\t(prevUsage == MANAGED_COMPONENT && thisUsage == UNMANAGED) || // 1 -> 0\n\t\t\t\t(prevUsage == MANAGED_HOOK && thisUsage == UNMANAGED) // 2 -> 0\n\t\t\t) {\n\t\t\t\t// Do nothing since it'll be captured by current effect store\n\t\t\t} else {\n\t\t\t\t// nested scenarios, so capture and restore the previous effect store\n\t\t\t\tendEffect = startComponentEffect(currentStore, this);\n\t\t\t}\n\t\t},\n\t\tf() {\n\t\t\tconst end = endEffect;\n\t\t\tendEffect = undefined;\n\t\t\tend?.();\n\t\t},\n\t\t[symDispose]() {\n\t\t\tthis.f();\n\t\t},\n\t};\n}\n\nconst _queueMicroTask = Promise.prototype.then.bind(Promise.resolve());\n\nlet finalCleanup: Promise | undefined;\nexport function ensureFinalCleanup() {\n\tif (!finalCleanup) {\n\t\tfinalCleanup = _queueMicroTask(cleanupTrailingStore);\n\t}\n}\nfunction cleanupTrailingStore() {\n\tfinalCleanup = undefined;\n\tcurrentStore?.f();\n}\n\nconst useIsomorphicLayoutEffect =\n\ttypeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n\n/**\n * Custom hook to create the effect to track signals used during render and\n * subscribe to changes to rerender the component when the signals change.\n */\nexport function _useSignalsImplementation(\n\t_usage: EffectStoreUsage = UNMANAGED\n): EffectStore {\n\tensureFinalCleanup();\n\n\tconst storeRef = useRef();\n\tif (storeRef.current == null) {\n\t\tstoreRef.current = createEffectStore(_usage);\n\t}\n\n\tconst store = storeRef.current;\n\tuseSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot);\n\tstore._start();\n\t// note: _usage is a constant here, so conditional is okay\n\tif (_usage === UNMANAGED) useIsomorphicLayoutEffect(cleanupTrailingStore);\n\n\treturn store;\n}\n\n/**\n * A wrapper component that renders a Signal's value directly as a Text node or JSX.\n */\nfunction SignalValue({ data }: { data: Signal }) {\n\tconst store = _useSignalsImplementation(1);\n\ttry {\n\t\treturn data.value;\n\t} finally {\n\t\tstore.f();\n\t}\n}\n\n// Decorate Signals so React renders them as components.\nObject.defineProperties(Signal.prototype, {\n\t$$typeof: { configurable: true, value: ReactElemType },\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\tref: { configurable: true, value: null },\n});\n\nexport function useSignals(usage?: EffectStoreUsage): EffectStore {\n\treturn _useSignalsImplementation(usage);\n}\n\nexport function useSignal(value: T): Signal;\nexport function useSignal(): Signal;\nexport function useSignal(value?: T) {\n\treturn useMemo(() => signal(value), Empty);\n}\n\nexport function useComputed(compute: () => T): ReadonlySignal {\n\tconst $compute = useRef(compute);\n\t$compute.current = compute;\n\treturn useMemo(() => computed(() => $compute.current()), Empty);\n}\n\nexport function useSignalEffect(cb: () => void | (() => void)) {\n\tconst callback = useRef(cb);\n\tcallback.current = cb;\n\n\tuseEffect(() => {\n\t\treturn effect(function (this: Effect) {\n\t\t\treturn callback.current();\n\t\t});\n\t}, Empty);\n}\n"],"names":["currentStore","_reactVersion$split$m","reactVersion","version","split","map","Number","Empty","ReactElemType","Symbol","symDispose","dispose","startComponentEffect","prevStore","nextStore","endEffect","effect","_start","finishComponentEffect","bind","finalCleanup","_queueMicroTask","Promise","prototype","then","resolve","ensureFinalCleanup","cleanupTrailingStore","_currentStore","undefined","f","useIsomorphicLayoutEffect","window","useLayoutEffect","useEffect","_useSignalsImplementation","_usage","storeRef","useRef","current","_ref","effectInstance","onChangeNotifyReact","unsubscribe","this","_callback","subscribe","onStoreChange","getSnapshot","prevUsage","thisUsage","end","createEffectStore","store","useSyncExternalStore","Object","defineProperties","Signal","$$typeof","configurable","value","type","_ref2","data","props","get","ref","exports","useComputed","compute","$compute","useMemo","computed","useSignal","signal","useSignalEffect","cb","callback","useSignals","usage","wrapJsx","jsx","i","v","call","apply","concat","slice","arguments"],"mappings":"IAmGIA,0GAnFJC,EAAgBC,EAAYC,QAACC,MAAM,KAAKC,IAAIC,QACtCC,EAAQ,GAGRC,EAAgBC,OAAM,IAJhBR,EACZ,IAIU,GAAK,6BAA+B,iBAoBxCS,EACJD,OAAeE,SAAWF,OAAM,IAAK,kBA2DvC,SAASG,EACRC,EACAC,GAEA,IAAMC,EAAYD,EAAUE,OAAOC,IACnCjB,EAAec,EAEf,OAAOI,EAAsBC,KAAKL,EAAWD,EAAWE,EACzD,CAEA,SAASG,EAERL,EACAE,GAEAA,IACAf,EAAea,CAChB,CAyKA,IAEI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AARA,EAAoB,OAAOA,OAEtC,OAAiBpB,SAAAA,EAAWG,GAC3B,GAAoB,iBAATH,GAAqBG,EAC/B,IAAK,IAAIkB,KAAKlB,EAAO,CACpB,IAAImB,EAAInB,EAAMkB,GACd,GAAU,aAANA,GAAoBC,aAAa1B,EAAAA,OACpCO,EAAMkB,GAAKC,EAAEvB,KAEd,CAGF,OAAOqB,EAAIG,KAAIC,MAARJ,EAASA,CAAAA,EAAKpB,EAAMG,GAAKsB,OAAAC,GAAAA,MAAAH,KAAAI,cACjC,CACD"} +\ No newline at end of file +diff --git a/node_modules/@preact/signals-react/runtime/dist/runtime.min.js b/node_modules/@preact/signals-react/runtime/dist/runtime.min.js +index 5c81ddc..173005a 100644 +--- a/node_modules/@preact/signals-react/runtime/dist/runtime.min.js ++++ b/node_modules/@preact/signals-react/runtime/dist/runtime.min.js +@@ -1 +1 @@ +-!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@preact/signals-core"),require("react"),require("use-sync-external-store/shim/index.js"),require("react/jsx-runtime"),require("react/jsx-dev-runtime")):"function"==typeof define&&define.amd?define(["exports","@preact/signals-core","react","use-sync-external-store/shim/index.js","react/jsx-runtime","react/jsx-dev-runtime"],e):e((n||self).reactSignalsRuntime={},n.preactSignalsCore,n.react,n.index_js,n.jsxRuntime,n.jsxRuntimeDev)}(this,function(n,e,t,r,i,u){function o(n){return n&&"object"==typeof n&&"default"in n?n.default:n}var f=/*#__PURE__*/o(t),c=/*#__PURE__*/o(i),a=/*#__PURE__*/o(u),s=!1,l=null,v=!1,d=null,p=new Map;function b(n){if(!n)return 1;var e,t=p.get(n);if(void 0!==t)return t;var r=n.useCallback.toString();if(n.useReducer===n.useEffect)e=1;else if(n.useEffect===n.useImperativeHandle)e=32;else if(/Invalid/.test(r))e=2;else if(/updateCallback/.test(r)||/\[0\]/.test(r)&&/\[1\]/.test(r)){var i=n.useReducer.toString();if(/rerenderReducer/.test(i)||/return\s*\[\w+,/.test(i))e=16;else e=8}else e=4;p.set(n,e);return e}var g=t.version.split(".").map(Number),m=[],h=Symbol.for(g[0]>=19?"react.transitional.element":"react.element"),y=function(){};function j(n){if("function"!=typeof n)return n;else return function(t,r){if("string"==typeof t&&r)for(var i in r){var u=r[i];if("children"!==i&&u instanceof e.Signal)r[i]=u.value}return n.call.apply(n,[n,t,r].concat([].slice.call(arguments,2)))}}var x,_=Symbol.dispose||Symbol.for("Symbol.dispose");function w(n,e){var t=e.effect.S();x=e;return S.bind(e,n,t)}function S(n,e){e();x=n}var q,k,B=((q={u:0,effect:{s:void 0,c:function(){},S:function(){return y},d:function(){}},subscribe:function(){return y},getSnapshot:function(){return 0},S:function(){},f:function(){}})[_]=function(){},q),N=Promise.prototype.then.bind(Promise.resolve());function O(){if(!k)k=N(P)}function P(){var n;k=void 0;null==(n=x)||n.f()}var R="undefined"!=typeof window?t.useLayoutEffect:t.useEffect;function T(n){if(void 0===n)n=0;O();var i=t.useRef();if(null==i.current)i.current=function(n){var t,r,i,u,o=0,f=e.effect(function(){r=this});r.c=function(){o=o+1|0;if(u)u()};return(t={u:n,effect:r,subscribe:function(n){u=n;return function(){o=o+1|0;u=void 0;f()}},getSnapshot:function(){return o},S:function(){if(null!=x){var n=x.u,e=this.u;if(0==n&&0==e||0==n&&1==e){x.f();i=w(void 0,this)}else if(1==n&&0==e||2==n&&0==e);else i=w(x,this)}else i=w(void 0,this)},f:function(){var n=i;i=void 0;null==n||n()}})[_]=function(){this.f()},t}(n);var u=i.current;r.useSyncExternalStore(u.subscribe,u.getSnapshot,u.getSnapshot);u.S();if(0===n)R(P);return u}Object.defineProperties(e.Signal.prototype,{$$typeof:{configurable:!0,value:h},type:{configurable:!0,value:function(n){var e=n.data,t=T(1);try{return e.value}finally{t.f()}}},props:{configurable:!0,get:function(){return{data:this}}},ref:{configurable:!0,value:null}});n.o=T;n.ensureFinalCleanup=O;n.installAutoSignalTracking=function(){if(t.version.split(".").map(Number)[0]>=19)throw new Error("Automatic signals tracking is not supported in React 19 and later, try the Babel plugin instead https://github.com/preactjs/signals/tree/main/packages/react-transform#signals-react-transform.");!function(){s=!0;Object.defineProperty(t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher,"current",{get:function(){return d},set:function(n){if(!v){var e=b(d),t=b(n);d=n;if(function(n,e){if(1&n&&28&e)return!0;else if(2&n||2&e)return!1;else return!1}(e,t)){v=!0;l=T(1);v=!1}else if(function(n,e){return Boolean(28&n&&16&e)}(e,t)){var r;null==(r=l)||r.f();v=!0;l=T(1);v=!1}else if(function(n,e){return Boolean(28&n&&1&e)}(e,t)){var i;null==(i=l)||i.f();l=null}}else d=n}})}();!function(){var n=c,e=a;f.createElement=j(f.createElement);e.jsx&&(e.jsx=j(e.jsx));n.jsx&&(n.jsx=j(n.jsx));e.jsxs&&(e.jsxs=j(e.jsxs));n.jsxs&&(n.jsxs=j(n.jsxs));e.jsxDEV&&(e.jsxDEV=j(e.jsxDEV));n.jsxDEV&&(n.jsxDEV=j(n.jsxDEV))}()};n.useComputed=function(n){var r=t.useRef(n);r.current=n;return t.useMemo(function(){return e.computed(function(){return r.current()})},m)};n.useSignal=function(n){return t.useMemo(function(){return e.signal(n)},m)};n.useSignalEffect=function(n){var r=t.useRef(n);r.current=n;t.useEffect(function(){return e.effect(function(){return r.current()})},m)};n.useSignals=function(n){if(s)return B;else return T(n)};n.wrapJsx=j});//# sourceMappingURL=runtime.min.js.map ++!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@preact/signals-core"),require("react"),require("use-sync-external-store/shim/index.js")):"function"==typeof define&&define.amd?define(["exports","@preact/signals-core","react","use-sync-external-store/shim/index.js"],e):e((n||self).reactSignalsRuntime={},n.preactSignalsCore,n.react,n.index_js)}(this,function(n,e,t,i){var r,o=t.version.split(".").map(Number),u=[],f=Symbol.for(o[0]>=19?"react.transitional.element":"react.element"),c=Symbol.dispose||Symbol.for("Symbol.dispose");function s(n,e){var t=e.effect.S();r=e;return a.bind(e,n,t)}function a(n,e){e();r=n}var l,v=Promise.prototype.then.bind(Promise.resolve());function d(){if(!l)l=v(p)}function p(){var n;l=void 0;null==(n=r)||n.f()}var y="undefined"!=typeof window?t.useLayoutEffect:t.useEffect;function b(n){if(void 0===n)n=0;d();var o=t.useRef();if(null==o.current)o.current=function(n){var t,i,o,u,f=0,a=e.effect(function(){i=this});i.c=function(){f=f+1|0;if(u)u()};return(t={o:n,effect:i,subscribe:function(n){u=n;return function(){f=f+1|0;u=void 0;a()}},getSnapshot:function(){return f},S:function(){if(null!=r){var n=r.o,e=this.o;if(0==n&&0==e||0==n&&1==e){r.f();o=s(void 0,this)}else if(1==n&&0==e||2==n&&0==e);else o=s(r,this)}else o=s(void 0,this)},f:function(){var n=o;o=void 0;null==n||n()}})[c]=function(){this.f()},t}(n);var u=o.current;i.useSyncExternalStore(u.subscribe,u.getSnapshot,u.getSnapshot);u.S();if(0===n)y(p);return u}Object.defineProperties(e.Signal.prototype,{$$typeof:{configurable:!0,value:f},type:{configurable:!0,value:function(n){var e=n.data,t=b(1);try{return e.value}finally{t.f()}}},props:{configurable:!0,get:function(){return{data:this}}},ref:{configurable:!0,value:null}});n.u=b;n.ensureFinalCleanup=d;n.useComputed=function(n){var i=t.useRef(n);i.current=n;return t.useMemo(function(){return e.computed(function(){return i.current()})},u)};n.useSignal=function(n){return t.useMemo(function(){return e.signal(n)},u)};n.useSignalEffect=function(n){var i=t.useRef(n);i.current=n;t.useEffect(function(){return e.effect(function(){return i.current()})},u)};n.useSignals=function(n){return b(n)};n.wrapJsx=function(n){if("function"!=typeof n)return n;else return function(t,i){if("string"==typeof t&&i)for(var r in i){var o=i[r];if("children"!==r&&o instanceof e.Signal)i[r]=o.value}return n.call.apply(n,[n,t,i].concat([].slice.call(arguments,2)))}}});//# sourceMappingURL=runtime.min.js.map +diff --git a/node_modules/@preact/signals-react/runtime/dist/runtime.min.js.map b/node_modules/@preact/signals-react/runtime/dist/runtime.min.js.map +index 00af5dc..39f81e9 100644 +--- a/node_modules/@preact/signals-react/runtime/dist/runtime.min.js.map ++++ b/node_modules/@preact/signals-react/runtime/dist/runtime.min.js.map +@@ -1 +1 @@ +-{"version":3,"file":"runtime.min.js","sources":["../src/auto.ts","../src/index.ts"],"sourcesContent":["import {\n\t// @ts-ignore-next-line\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED as ReactInternals,\n\tversion as reactVersion,\n} from \"react\";\nimport React from \"react\";\nimport jsxRuntime from \"react/jsx-runtime\";\nimport jsxRuntimeDev from \"react/jsx-dev-runtime\";\nimport { EffectStore, wrapJsx, _useSignalsImplementation } from \"./index\";\n\nexport interface ReactDispatcher {\n\tuseRef: typeof React.useRef;\n\tuseCallback: typeof React.useCallback;\n\tuseReducer: typeof React.useReducer;\n\tuseSyncExternalStore: typeof React.useSyncExternalStore;\n\tuseEffect: typeof React.useEffect;\n\tuseImperativeHandle: typeof React.useImperativeHandle;\n}\n\n// In order for signals to work in React, we need to observe what signals a\n// component uses while rendering. To do this, we need to know when a component\n// is rendering. To do this, we watch the transition of the\n// ReactCurrentDispatcher to know when a component is rerendering.\n//\n// To track when we are entering and exiting a component render (i.e. before and\n// after React renders a component), we track how the dispatcher changes.\n// Outside of a component rendering, the dispatcher is set to an instance that\n// errors or warns when any hooks are called. This behavior is prevents hooks\n// from being used outside of components. Right before React renders a\n// component, the dispatcher is set to an instance that doesn't warn or error\n// and contains the implementations of all hooks. Right after React finishes\n// rendering a component, the dispatcher is set to the erroring one again. This\n// erroring dispatcher is called the `ContextOnlyDispatcher` in React's source.\n//\n// So, we watch the getter and setter on `ReactCurrentDispatcher.current` to\n// monitor the changes to the current ReactDispatcher. When the dispatcher\n// changes from the ContextOnlyDispatcher to a \"valid\" dispatcher, we assume we\n// are entering a component render. At this point, we setup our\n// auto-subscriptions for any signals used in the component. We do this by\n// creating an Signal effect and manually starting the Signal effect. We use\n// `useSyncExternalStore` to trigger rerenders on the component when any signals\n// it uses changes.\n//\n// When the dispatcher changes from a valid dispatcher back to the\n// ContextOnlyDispatcher, we assume we are exiting a component render. At this\n// point we stop the effect.\n//\n// Some additional complexities to be aware of:\n// - If a component calls `setState` while rendering, React will re-render the\n// component immediately. Before triggering the re-render, React will change\n// the dispatcher to the HooksDispatcherOnRerender. When we transition to this\n// rerendering adapter, we need to re-trigger our hooks to keep the order of\n// hooks the same for every render of a component.\n//\n// - In development, useReducer, useState, and useMemo change the dispatcher to\n// a different warning dispatcher (not ContextOnlyDispatcher) before invoking\n// the reducer and resets it right after.\n//\n// The useSyncExternalStore shim will use some of these hooks when we invoke\n// it while entering a component render. We need to prevent this dispatcher\n// change caused by these hooks from re-triggering our entering logic (it\n// would cause an infinite loop if we did not). We do this by using a lock to\n// prevent the setter from running while we are in the setter.\n//\n// When a Component's function body invokes useReducer, useState, or useMemo,\n// this change in dispatcher should not signal that we are entering or exiting\n// a component render. We ignore this change by detecting these dispatchers as\n// different from ContextOnlyDispatcher and other valid dispatchers.\n//\n// - The `use` hook will change the dispatcher to from a valid update dispatcher\n// to a valid mount dispatcher in some cases. Similarly to useReducer\n// mentioned above, we should not signal that we are exiting a component\n// during this change. Because these other valid dispatchers do not pass the\n// ContextOnlyDispatcher check, they do not affect our logic.\n//\n// - When server rendering, React does not change the dispatcher before and\n// after each component render. It sets it once for before the first render\n// and once for after the last render. This means that we will not be able to\n// detect when we are entering or exiting a component render. This is fine\n// because we don't need to detect this for server rendering. A component\n// can't trigger async rerenders in SSR so we don't need to track signals.\n//\n// If a component updates a signal value while rendering during SSR, we will\n// not rerender the component because the signal value will synchronously\n// change so all reads of the signal further down the tree will see the new\n// value.\n\n/*\nBelow is a state machine definition for transitions between the various\ndispatchers in React's prod build. (It does not include dev time warning\ndispatchers which are just always ignored).\n\nENTER and EXIT suffixes indicates whether this ReactCurrentDispatcher transition\nsignals we are entering or exiting a component render, or if it doesn't signal a\nchange in the component rendering lifecyle (NOOP).\n\n```js\n// Paste this into https://stately.ai/viz to visualize the state machine.\nimport { createMachine } from \"xstate\";\n\n// ENTER, EXIT, NOOP suffixes indicates whether this ReactCurrentDispatcher\n// transition signals we are entering or exiting a component render, or\n// if it doesn't signal a change in the component rendering lifecyle (NOOP).\n\nconst dispatcherMachinePROD = createMachine({\n\tid: \"ReactCurrentDispatcher_PROD\",\n\tinitial: \"null\",\n\tstates: {\n\t\tnull: {\n\t\t\ton: {\n\t\t\t\tpushDispatcher: \"ContextOnlyDispatcher\",\n\t\t\t},\n\t\t},\n\t\tContextOnlyDispatcher: {\n\t\t\ton: {\n\t\t\t\trenderWithHooks_Mount_ENTER: \"HooksDispatcherOnMount\",\n\t\t\t\trenderWithHooks_Update_ENTER: \"HooksDispatcherOnUpdate\",\n\t\t\t\tpushDispatcher_NOOP: \"ContextOnlyDispatcher\",\n\t\t\t\tpopDispatcher_NOOP: \"ContextOnlyDispatcher\",\n\t\t\t},\n\t\t},\n\t\tHooksDispatcherOnMount: {\n\t\t\ton: {\n\t\t\t\trenderWithHooksAgain_ENTER: \"HooksDispatcherOnRerender\",\n\t\t\t\tresetHooksAfterThrow_EXIT: \"ContextOnlyDispatcher\",\n\t\t\t\tfinishRenderingHooks_EXIT: \"ContextOnlyDispatcher\",\n\t\t\t},\n\t\t},\n\t\tHooksDispatcherOnUpdate: {\n\t\t\ton: {\n\t\t\t\trenderWithHooksAgain_ENTER: \"HooksDispatcherOnRerender\",\n\t\t\t\tresetHooksAfterThrow_EXIT: \"ContextOnlyDispatcher\",\n\t\t\t\tfinishRenderingHooks_EXIT: \"ContextOnlyDispatcher\",\n\t\t\t\tuse_ResumeSuspensedMount_NOOP: \"HooksDispatcherOnMount\",\n\t\t\t},\n\t\t},\n\t\tHooksDispatcherOnRerender: {\n\t\t\ton: {\n\t\t\t\trenderWithHooksAgain_ENTER: \"HooksDispatcherOnRerender\",\n\t\t\t\tresetHooksAfterThrow_EXIT: \"ContextOnlyDispatcher\",\n\t\t\t\tfinishRenderingHooks_EXIT: \"ContextOnlyDispatcher\",\n\t\t\t},\n\t\t},\n\t},\n});\n```\n*/\n\nexport let isAutoSignalTrackingInstalled = false;\n\nlet store: EffectStore | null = null;\nlet lock = false;\nlet currentDispatcher: ReactDispatcher | null = null;\n\nfunction installCurrentDispatcherHook() {\n\tisAutoSignalTrackingInstalled = true;\n\n\tObject.defineProperty(ReactInternals.ReactCurrentDispatcher, \"current\", {\n\t\tget() {\n\t\t\treturn currentDispatcher;\n\t\t},\n\t\tset(nextDispatcher: ReactDispatcher) {\n\t\t\tif (lock) {\n\t\t\t\tcurrentDispatcher = nextDispatcher;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst currentDispatcherType = getDispatcherType(currentDispatcher);\n\t\t\tconst nextDispatcherType = getDispatcherType(nextDispatcher);\n\n\t\t\t// Update the current dispatcher now so the hooks inside of the\n\t\t\t// useSyncExternalStore shim get the right dispatcher.\n\t\t\tcurrentDispatcher = nextDispatcher;\n\t\t\tif (\n\t\t\t\tisEnteringComponentRender(currentDispatcherType, nextDispatcherType)\n\t\t\t) {\n\t\t\t\tlock = true;\n\t\t\t\tstore = _useSignalsImplementation(1);\n\t\t\t\tlock = false;\n\t\t\t} else if (\n\t\t\t\tisRestartingComponentRender(currentDispatcherType, nextDispatcherType)\n\t\t\t) {\n\t\t\t\tstore?.f();\n\t\t\t\tlock = true;\n\t\t\t\tstore = _useSignalsImplementation(1);\n\t\t\t\tlock = false;\n\t\t\t} else if (\n\t\t\t\tisExitingComponentRender(currentDispatcherType, nextDispatcherType)\n\t\t\t) {\n\t\t\t\tstore?.f();\n\t\t\t\tstore = null;\n\t\t\t}\n\t\t},\n\t});\n}\n\ntype DispatcherType = number;\nconst ContextOnlyDispatcherType = 1 << 0;\nconst WarningDispatcherType = 1 << 1;\nconst MountDispatcherType = 1 << 2;\nconst UpdateDispatcherType = 1 << 3;\nconst RerenderDispatcherType = 1 << 4;\nconst ServerDispatcherType = 1 << 5;\nconst BrowserClientDispatcherType =\n\tMountDispatcherType | UpdateDispatcherType | RerenderDispatcherType;\n\nconst dispatcherTypeCache = new Map();\nfunction getDispatcherType(dispatcher: ReactDispatcher | null): DispatcherType {\n\t// Treat null the same as the ContextOnlyDispatcher.\n\tif (!dispatcher) return ContextOnlyDispatcherType;\n\n\tconst cached = dispatcherTypeCache.get(dispatcher);\n\tif (cached !== undefined) return cached;\n\n\t// The ContextOnlyDispatcher sets all the hook implementations to a function\n\t// that takes no arguments and throws and error. This dispatcher is the only\n\t// dispatcher where useReducer and useEffect will have the same\n\t// implementation.\n\tlet type: DispatcherType;\n\tconst useCallbackImpl = dispatcher.useCallback.toString();\n\tif (dispatcher.useReducer === dispatcher.useEffect) {\n\t\ttype = ContextOnlyDispatcherType;\n\n\t\t// @ts-expect-error When server rendering, useEffect and useImperativeHandle\n\t\t// are both set to noop functions and so have the same implementation.\n\t} else if (dispatcher.useEffect === dispatcher.useImperativeHandle) {\n\t\ttype = ServerDispatcherType;\n\t} else if (/Invalid/.test(useCallbackImpl)) {\n\t\t// We first check for warning dispatchers because they would also pass some\n\t\t// of the checks below.\n\t\ttype = WarningDispatcherType;\n\t} else if (\n\t\t// The development mount dispatcher invokes a function called\n\t\t// `mountCallback` whereas the development update/re-render dispatcher\n\t\t// invokes a function called `updateCallback`. Use that difference to\n\t\t// determine if we are in a mount or update-like dispatcher in development.\n\t\t// The production mount dispatcher defines an array of the form [callback,\n\t\t// deps] whereas update/re-render dispatchers read the array using array\n\t\t// indices (e.g. `[0]` and `[1]`). Use those differences to determine if we\n\t\t// are in a mount or update-like dispatcher in production.\n\t\t/updateCallback/.test(useCallbackImpl) ||\n\t\t(/\\[0\\]/.test(useCallbackImpl) && /\\[1\\]/.test(useCallbackImpl))\n\t) {\n\t\t// The update and rerender dispatchers have different implementations for\n\t\t// useReducer. We'll check it's implementation to determine if this is the\n\t\t// rerender or update dispatcher.\n\t\tlet useReducerImpl = dispatcher.useReducer.toString();\n\t\tif (\n\t\t\t// The development rerender dispatcher invokes a function called\n\t\t\t// `rerenderReducer` whereas the update dispatcher invokes a function\n\t\t\t// called `updateReducer`. The production rerender dispatcher returns an\n\t\t\t// array of the form `[state, dispatch]` whereas the update dispatcher\n\t\t\t// returns an array of `[fiber.memoizedState, dispatch]` so we check the\n\t\t\t// return statement in the implementation of useReducer to differentiate\n\t\t\t// between the two.\n\t\t\t/rerenderReducer/.test(useReducerImpl) ||\n\t\t\t/return\\s*\\[\\w+,/.test(useReducerImpl)\n\t\t) {\n\t\t\ttype = RerenderDispatcherType;\n\t\t} else {\n\t\t\ttype = UpdateDispatcherType;\n\t\t}\n\t} else {\n\t\ttype = MountDispatcherType;\n\t}\n\n\tdispatcherTypeCache.set(dispatcher, type);\n\treturn type;\n}\n\nfunction isEnteringComponentRender(\n\tcurrentDispatcherType: DispatcherType,\n\tnextDispatcherType: DispatcherType\n): boolean {\n\tif (\n\t\tcurrentDispatcherType & ContextOnlyDispatcherType &&\n\t\tnextDispatcherType & BrowserClientDispatcherType\n\t) {\n\t\t// ## Mount or update (ContextOnlyDispatcher -> ValidDispatcher (Mount or Update))\n\t\t//\n\t\t// If the current dispatcher is the ContextOnlyDispatcher and the next\n\t\t// dispatcher is a valid dispatcher, we are entering a component render.\n\t\treturn true;\n\t} else if (\n\t\tcurrentDispatcherType & WarningDispatcherType ||\n\t\tnextDispatcherType & WarningDispatcherType\n\t) {\n\t\t// ## Warning dispatcher\n\t\t//\n\t\t// If the current dispatcher or next dispatcher is an warning dispatcher,\n\t\t// we are not entering a component render. The current warning dispatchers\n\t\t// are used to warn when hooks are nested improperly and do not indicate\n\t\t// entering a new component render.\n\t\treturn false;\n\t} else {\n\t\t// ## Resuming suspended mount edge case (Update -> Mount)\n\t\t//\n\t\t// If we are transitioning from the update dispatcher to the mount\n\t\t// dispatcher, then this component is using the `use` hook and is resuming\n\t\t// from a mount. We should not re-invoke our hooks in this situation since\n\t\t// we are not entering a new component render, but instead continuing a\n\t\t// previous render.\n\t\t//\n\t\t// ## Other transitions\n\t\t//\n\t\t// For example, Mount -> Mount, Update -> Update, Mount -> Update, any\n\t\t// transition in and out of invalid dispatchers.\n\t\t//\n\t\t// There is no known transition for the following transitions so we default\n\t\t// to not triggering a re-enter of the component.\n\t\t// - HooksDispatcherOnMount -> HooksDispatcherOnMount\n\t\t// - HooksDispatcherOnMount -> HooksDispatcherOnUpdate\n\t\t// - HooksDispatcherOnUpdate -> HooksDispatcherOnUpdate\n\t\treturn false;\n\t}\n}\n\nfunction isRestartingComponentRender(\n\tcurrentDispatcherType: DispatcherType,\n\tnextDispatcherType: DispatcherType\n): boolean {\n\t// A transition from a valid browser dispatcher into the rerender dispatcher\n\t// is the restart of a component render, so we should end the current\n\t// component effect and re-invoke our hooks. Details below.\n\t//\n\t// ## In-place rerendering (e.g. Mount -> Rerender)\n\t//\n\t// If we are transitioning from the mount, update, or rerender dispatcher to\n\t// the rerender dispatcher (e.g. HooksDispatcherOnMount to\n\t// HooksDispatcherOnRerender), then this component is rerendering due to\n\t// calling setState inside of its function body. We are re-entering a\n\t// component's render method and so we should re-invoke our hooks.\n\n\treturn Boolean(\n\t\tcurrentDispatcherType & BrowserClientDispatcherType &&\n\t\t\tnextDispatcherType & RerenderDispatcherType\n\t);\n}\n\n/**\n * We are exiting a component render if the current dispatcher is a valid\n * dispatcher and the next dispatcher is the ContextOnlyDispatcher.\n */\nfunction isExitingComponentRender(\n\tcurrentDispatcherType: DispatcherType,\n\tnextDispatcherType: DispatcherType\n): boolean {\n\treturn Boolean(\n\t\tcurrentDispatcherType & BrowserClientDispatcherType &&\n\t\t\tnextDispatcherType & ContextOnlyDispatcherType\n\t);\n}\n\ninterface JsxRuntimeModule {\n\tjsx?(type: any, ...rest: any[]): unknown;\n\tjsxs?(type: any, ...rest: any[]): unknown;\n\tjsxDEV?(type: any, ...rest: any[]): unknown;\n}\n\nexport function installJSXHooks() {\n\tconst JsxPro: JsxRuntimeModule = jsxRuntime;\n\tconst JsxDev: JsxRuntimeModule = jsxRuntimeDev;\n\n\t/**\n\t * createElement _may_ be called by jsx runtime as a fallback in certain cases,\n\t * so we need to wrap it regardless.\n\t *\n\t * The jsx exports depend on the `NODE_ENV` var to ensure the users' bundler doesn't\n\t * include both, so one of them will be set with `undefined` values.\n\t */\n\tReact.createElement = wrapJsx(React.createElement);\n\tJsxDev.jsx && /* */ (JsxDev.jsx = wrapJsx(JsxDev.jsx));\n\tJsxPro.jsx && /* */ (JsxPro.jsx = wrapJsx(JsxPro.jsx));\n\tJsxDev.jsxs && /* */ (JsxDev.jsxs = wrapJsx(JsxDev.jsxs));\n\tJsxPro.jsxs && /* */ (JsxPro.jsxs = wrapJsx(JsxPro.jsxs));\n\tJsxDev.jsxDEV && /**/ (JsxDev.jsxDEV = wrapJsx(JsxDev.jsxDEV));\n\tJsxPro.jsxDEV && /**/ (JsxPro.jsxDEV = wrapJsx(JsxPro.jsxDEV));\n}\n\nexport function installAutoSignalTracking() {\n\tconst [major] = reactVersion.split(\".\").map(Number);\n\tif (major >= 19) {\n\t\tthrow new Error(\n\t\t\t\"Automatic signals tracking is not supported in React 19 and later, try the Babel plugin instead https://github.com/preactjs/signals/tree/main/packages/react-transform#signals-react-transform.\"\n\t\t);\n\t}\n\tinstallCurrentDispatcherHook();\n\tinstallJSXHooks();\n}\n","import {\n\tsignal,\n\tcomputed,\n\teffect,\n\tSignal,\n\tReadonlySignal,\n} from \"@preact/signals-core\";\nimport {\n\tuseRef,\n\tuseMemo,\n\tuseEffect,\n\tuseLayoutEffect,\n\tversion as reactVersion,\n} from \"react\";\nimport { useSyncExternalStore } from \"use-sync-external-store/shim/index.js\";\nimport { isAutoSignalTrackingInstalled } from \"./auto\";\n\nexport { installAutoSignalTracking } from \"./auto\";\n\nconst [major] = reactVersion.split(\".\").map(Number);\nconst Empty = [] as const;\n// V19 https://github.com/facebook/react/blob/346c7d4c43a0717302d446da9e7423a8e28d8996/packages/shared/ReactSymbols.js#L15\n// V18 https://github.com/facebook/react/blob/346c7d4c43a0717302d446da9e7423a8e28d8996/packages/shared/ReactSymbols.js#L15\nconst ReactElemType = Symbol.for(\n\tmajor >= 19 ? \"react.transitional.element\" : \"react.element\"\n);\n\nconst noop = () => {};\n\nexport function wrapJsx(jsx: T): T {\n\tif (typeof jsx !== \"function\") return jsx;\n\n\treturn function (type: any, props: any, ...rest: any[]) {\n\t\tif (typeof type === \"string\" && props) {\n\t\t\tfor (let i in props) {\n\t\t\t\tlet v = props[i];\n\t\t\t\tif (i !== \"children\" && v instanceof Signal) {\n\t\t\t\t\tprops[i] = v.value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn jsx.call(jsx, type, props, ...rest);\n\t} as any as T;\n}\n\nconst symDispose: unique symbol =\n\t(Symbol as any).dispose || Symbol.for(\"Symbol.dispose\");\n\ninterface Effect {\n\t_sources: object | undefined;\n\t_start(): () => void;\n\t_callback(): void;\n\t_dispose(): void;\n}\n\n/**\n * Use this flag to represent a bare `useSignals` call that doesn't manually\n * close its effect store and relies on auto-closing when the next useSignals is\n * called or after a microtask\n */\nconst UNMANAGED = 0;\n/**\n * Use this flag to represent a `useSignals` call that is manually closed by a\n * try/finally block in a component's render method. This is the default usage\n * that the react-transform plugin uses.\n */\nconst MANAGED_COMPONENT = 1;\n/**\n * Use this flag to represent a `useSignals` call that is manually closed by a\n * try/finally block in a hook body. This is the default usage that the\n * react-transform plugin uses.\n */\nconst MANAGED_HOOK = 2;\n\n/**\n * An enum defining how this store is used. See the documentation for each enum\n * member for more details.\n * @see {@link UNMANAGED}\n * @see {@link MANAGED_COMPONENT}\n * @see {@link MANAGED_HOOK}\n */\ntype EffectStoreUsage =\n\t| typeof UNMANAGED\n\t| typeof MANAGED_COMPONENT\n\t| typeof MANAGED_HOOK;\n\nexport interface EffectStore {\n\t/**\n\t * An enum defining how this hook is used and whether it is invoked in a\n\t * component's body or hook body. See the comment on `EffectStoreUsage` for\n\t * more details.\n\t */\n\treadonly _usage: EffectStoreUsage;\n\treadonly effect: Effect;\n\tsubscribe(onStoreChange: () => void): () => void;\n\tgetSnapshot(): number;\n\t/** startEffect - begin tracking signals used in this component */\n\t_start(): void;\n\t/** finishEffect - stop tracking the signals used in this component */\n\tf(): void;\n\t[symDispose](): void;\n}\n\nlet currentStore: EffectStore | undefined;\n\nfunction startComponentEffect(\n\tprevStore: EffectStore | undefined,\n\tnextStore: EffectStore\n) {\n\tconst endEffect = nextStore.effect._start();\n\tcurrentStore = nextStore;\n\n\treturn finishComponentEffect.bind(nextStore, prevStore, endEffect);\n}\n\nfunction finishComponentEffect(\n\tthis: EffectStore,\n\tprevStore: EffectStore | undefined,\n\tendEffect: () => void\n) {\n\tendEffect();\n\tcurrentStore = prevStore;\n}\n\n/**\n * A redux-like store whose store value is a positive 32bit integer (a\n * 'version').\n *\n * React subscribes to this store and gets a snapshot of the current 'version',\n * whenever the 'version' changes, we tell React it's time to update the\n * component (call 'onStoreChange').\n *\n * How we achieve this is by creating a binding with an 'effect', when the\n * `effect._callback' is called, we update our store version and tell React to\n * re-render the component ([1] We don't really care when/how React does it).\n *\n * [1]\n * @see https://react.dev/reference/react/useSyncExternalStore\n * @see\n * https://github.com/reactjs/rfcs/blob/main/text/0214-use-sync-external-store.md\n *\n * @param _usage An enum defining how this hook is used and whether it is\n * invoked in a component's body or hook body. See the comment on\n * `EffectStoreUsage` for more details.\n */\nfunction createEffectStore(_usage: EffectStoreUsage): EffectStore {\n\tlet effectInstance!: Effect;\n\tlet endEffect: (() => void) | undefined;\n\tlet version = 0;\n\tlet onChangeNotifyReact: (() => void) | undefined;\n\n\tlet unsubscribe = effect(function (this: Effect) {\n\t\teffectInstance = this;\n\t});\n\teffectInstance._callback = function () {\n\t\tversion = (version + 1) | 0;\n\t\tif (onChangeNotifyReact) onChangeNotifyReact();\n\t};\n\n\treturn {\n\t\t_usage,\n\t\teffect: effectInstance,\n\t\tsubscribe(onStoreChange) {\n\t\t\tonChangeNotifyReact = onStoreChange;\n\n\t\t\treturn function () {\n\t\t\t\t/**\n\t\t\t\t * Rotate to next version when unsubscribing to ensure that components are re-run\n\t\t\t\t * when subscribing again.\n\t\t\t\t *\n\t\t\t\t * In StrictMode, 'memo'-ed components seem to keep a stale snapshot version, so\n\t\t\t\t * don't re-run after subscribing again if the version is the same as last time.\n\t\t\t\t *\n\t\t\t\t * Because we unsubscribe from the effect, the version may not change. We simply\n\t\t\t\t * set a new initial version in case of stale snapshots here.\n\t\t\t\t */\n\t\t\t\tversion = (version + 1) | 0;\n\t\t\t\tonChangeNotifyReact = undefined;\n\t\t\t\tunsubscribe();\n\t\t\t};\n\t\t},\n\t\tgetSnapshot() {\n\t\t\treturn version;\n\t\t},\n\t\t_start() {\n\t\t\t// In general, we want to support two kinds of usages of useSignals:\n\t\t\t//\n\t\t\t// A) Managed: calling useSignals in a component or hook body wrapped in a\n\t\t\t// try/finally (like what the react-transform plugin does)\n\t\t\t//\n\t\t\t// B) Unmanaged: Calling useSignals directly without wrapping in a\n\t\t\t// try/finally\n\t\t\t//\n\t\t\t// For managed, we finish the effect in the finally block of the component\n\t\t\t// or hook body. For unmanaged, we finish the effect in the next\n\t\t\t// useSignals call or after a microtask.\n\t\t\t//\n\t\t\t// There are different tradeoffs which each approach. With managed, using\n\t\t\t// a try/finally ensures that only signals used in the component or hook\n\t\t\t// body are tracked. However, signals accessed in render props are missed\n\t\t\t// because the render prop is invoked in another component that may or may\n\t\t\t// not realize it is rendering signals accessed in the render prop it is\n\t\t\t// given.\n\t\t\t//\n\t\t\t// The other approach is \"unmanaged\": to call useSignals directly without\n\t\t\t// wrapping in a try/finally. This approach is easier to manually write in\n\t\t\t// situations where a build step isn't available but does open up the\n\t\t\t// possibility of catching signals accessed in other code before the\n\t\t\t// effect is closed (e.g. in a layout effect). Most situations where this\n\t\t\t// could happen are generally consider bad patterns or bugs. For example,\n\t\t\t// using a signal in a component and not having a call to `useSignals`\n\t\t\t// would be an bug. Or using a signal in `useLayoutEffect` is generally\n\t\t\t// not recommended since that layout effect won't update when the signals'\n\t\t\t// value change.\n\t\t\t//\n\t\t\t// To support both approaches, we need to track how each invocation of\n\t\t\t// useSignals is used, so we can properly transition between different\n\t\t\t// kinds of usages.\n\t\t\t//\n\t\t\t// The following table shows the different scenarios and how we should\n\t\t\t// handle them.\n\t\t\t//\n\t\t\t// Key:\n\t\t\t// 0 = UNMANAGED\n\t\t\t// 1 = MANAGED_COMPONENT\n\t\t\t// 2 = MANAGED_HOOK\n\t\t\t//\n\t\t\t// Pattern:\n\t\t\t// prev store usage -> this store usage: action to take\n\t\t\t//\n\t\t\t// - 0 -> 0: finish previous effect (unknown to unknown)\n\t\t\t//\n\t\t\t// We don't know how the previous effect was used, so we need to finish\n\t\t\t// it before starting the next effect.\n\t\t\t//\n\t\t\t// - 0 -> 1: finish previous effect\n\t\t\t//\n\t\t\t// Assume previous invocation was another component or hook from another\n\t\t\t// component. Nested component renders (renderToStaticMarkup within a\n\t\t\t// component's render) won't be supported with bare useSignals calls.\n\t\t\t//\n\t\t\t// - 0 -> 2: capture & restore\n\t\t\t//\n\t\t\t// Previous invocation could be a component or a hook. Either way,\n\t\t\t// restore it after our invocation so that it can continue to capture\n\t\t\t// any signals after we exit.\n\t\t\t//\n\t\t\t// - 1 -> 0: Do nothing. Signals already captured by current effect store\n\t\t\t// - 1 -> 1: capture & restore (e.g. component calls renderToStaticMarkup)\n\t\t\t// - 1 -> 2: capture & restore (e.g. hook)\n\t\t\t//\n\t\t\t// - 2 -> 0: Do nothing. Signals already captured by current effect store\n\t\t\t// - 2 -> 1: capture & restore (e.g. hook calls renderToStaticMarkup)\n\t\t\t// - 2 -> 2: capture & restore (e.g. nested hook calls)\n\n\t\t\tif (currentStore == undefined) {\n\t\t\t\tendEffect = startComponentEffect(undefined, this);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst prevUsage = currentStore._usage;\n\t\t\tconst thisUsage = this._usage;\n\n\t\t\tif (\n\t\t\t\t(prevUsage == UNMANAGED && thisUsage == UNMANAGED) || // 0 -> 0\n\t\t\t\t(prevUsage == UNMANAGED && thisUsage == MANAGED_COMPONENT) // 0 -> 1\n\t\t\t) {\n\t\t\t\t// finish previous effect\n\t\t\t\tcurrentStore.f();\n\t\t\t\tendEffect = startComponentEffect(undefined, this);\n\t\t\t} else if (\n\t\t\t\t(prevUsage == MANAGED_COMPONENT && thisUsage == UNMANAGED) || // 1 -> 0\n\t\t\t\t(prevUsage == MANAGED_HOOK && thisUsage == UNMANAGED) // 2 -> 0\n\t\t\t) {\n\t\t\t\t// Do nothing since it'll be captured by current effect store\n\t\t\t} else {\n\t\t\t\t// nested scenarios, so capture and restore the previous effect store\n\t\t\t\tendEffect = startComponentEffect(currentStore, this);\n\t\t\t}\n\t\t},\n\t\tf() {\n\t\t\tconst end = endEffect;\n\t\t\tendEffect = undefined;\n\t\t\tend?.();\n\t\t},\n\t\t[symDispose]() {\n\t\t\tthis.f();\n\t\t},\n\t};\n}\n\nfunction createEmptyEffectStore(): EffectStore {\n\treturn {\n\t\t_usage: UNMANAGED,\n\t\teffect: {\n\t\t\t_sources: undefined,\n\t\t\t_callback() {},\n\t\t\t_start() {\n\t\t\t\treturn noop;\n\t\t\t},\n\t\t\t_dispose() {},\n\t\t},\n\t\tsubscribe() {\n\t\t\treturn noop;\n\t\t},\n\t\tgetSnapshot() {\n\t\t\treturn 0;\n\t\t},\n\t\t_start() {},\n\t\tf() {},\n\t\t[symDispose]() {},\n\t};\n}\n\nconst emptyEffectStore = createEmptyEffectStore();\n\nconst _queueMicroTask = Promise.prototype.then.bind(Promise.resolve());\n\nlet finalCleanup: Promise | undefined;\nexport function ensureFinalCleanup() {\n\tif (!finalCleanup) {\n\t\tfinalCleanup = _queueMicroTask(cleanupTrailingStore);\n\t}\n}\nfunction cleanupTrailingStore() {\n\tfinalCleanup = undefined;\n\tcurrentStore?.f();\n}\n\nconst useIsomorphicLayoutEffect =\n\ttypeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n\n/**\n * Custom hook to create the effect to track signals used during render and\n * subscribe to changes to rerender the component when the signals change.\n */\nexport function _useSignalsImplementation(\n\t_usage: EffectStoreUsage = UNMANAGED\n): EffectStore {\n\tensureFinalCleanup();\n\n\tconst storeRef = useRef();\n\tif (storeRef.current == null) {\n\t\tstoreRef.current = createEffectStore(_usage);\n\t}\n\n\tconst store = storeRef.current;\n\tuseSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot);\n\tstore._start();\n\t// note: _usage is a constant here, so conditional is okay\n\tif (_usage === UNMANAGED) useIsomorphicLayoutEffect(cleanupTrailingStore);\n\n\treturn store;\n}\n\n/**\n * A wrapper component that renders a Signal's value directly as a Text node or JSX.\n */\nfunction SignalValue({ data }: { data: Signal }) {\n\tconst store = _useSignalsImplementation(1);\n\ttry {\n\t\treturn data.value;\n\t} finally {\n\t\tstore.f();\n\t}\n}\n\n// Decorate Signals so React renders them as components.\nObject.defineProperties(Signal.prototype, {\n\t$$typeof: { configurable: true, value: ReactElemType },\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\tref: { configurable: true, value: null },\n});\n\nexport function useSignals(usage?: EffectStoreUsage): EffectStore {\n\tif (isAutoSignalTrackingInstalled) return emptyEffectStore;\n\treturn _useSignalsImplementation(usage);\n}\n\nexport function useSignal(value: T): Signal;\nexport function useSignal(): Signal;\nexport function useSignal(value?: T) {\n\treturn useMemo(() => signal(value), Empty);\n}\n\nexport function useComputed(compute: () => T): ReadonlySignal {\n\tconst $compute = useRef(compute);\n\t$compute.current = compute;\n\treturn useMemo(() => computed(() => $compute.current()), Empty);\n}\n\nexport function useSignalEffect(cb: () => void | (() => void)) {\n\tconst callback = useRef(cb);\n\tcallback.current = cb;\n\n\tuseEffect(() => {\n\t\treturn effect(function (this: Effect) {\n\t\t\treturn callback.current();\n\t\t});\n\t}, Empty);\n}\n"],"names":["g","f","exports","module","require","define","amd","globalThis","self","reactSignalsRuntime","preactSignalsCore","react","index_js","jsxRuntime","jsxRuntimeDev","this","signalsCore","React","_interopDefaultLegacy","e","default","React__default","jsxRuntime__default","jsxRuntimeDev__default","isAutoSignalTrackingInstalled","store","lock","currentDispatcher","dispatcherTypeCache","Map","getDispatcherType","dispatcher","type","cached","get","undefined","useCallbackImpl","useCallback","toString","useReducer","useEffect","useImperativeHandle","test","useReducerImpl","set","_reactVersion$split$m","reactVersion","split","map","Number","Empty","ReactElemType","Symbol","noop","wrapJsx","jsx","props","i","v","Signal","value","call","apply","concat","slice","arguments","currentStore","symDispose","dispose","startComponentEffect","prevStore","nextStore","endEffect","effect","_start","finishComponentEffect","bind","_ref2","finalCleanup","emptyEffectStore","_usage","_sources","_callback","_dispose","subscribe","getSnapshot","_queueMicroTask","Promise","prototype","then","resolve","ensureFinalCleanup","cleanupTrailingStore","_currentStore","useIsomorphicLayoutEffect","window","useLayoutEffect","_useSignalsImplementation","storeRef","useRef","current","_ref","effectInstance","onChangeNotifyReact","version","unsubscribe","onStoreChange","prevUsage","thisUsage","end","createEffectStore","useSyncExternalStore","Object","defineProperties","$$typeof","configurable","_ref3","data","ref","installAutoSignalTracking","Error","defineProperty","ReactInternals","__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED","ReactCurrentDispatcher","nextDispatcher","currentDispatcherType","nextDispatcherType","MountDispatcherType","isEnteringComponentRender","Boolean","isRestartingComponentRender","_store","isExitingComponentRender","_store2","installCurrentDispatcherHook","JsxPro","JsxDev","createElement","jsxs","jsxDEV","installJSXHooks","useComputed","compute","$compute","useMemo","computed","useSignal","signal","useSignalEffect","cb","callback","useSignals","usage"],"mappings":"CAqJW,SAAAA,EAAAC,GAAA,iBAAAC,SAAA,oBAAAC,OAAAF,EAAAC,QAAAE,QAAA,wBAAAA,QAAA,SAAAA,QAAA,yCAAAA,QAAA,qBAAAA,QAAA,0BAAA,mBAAAC,QAAAA,OAAAC,IAAAD,OAAA,CAAA,UAAA,uBAAA,QAAA,wCAAA,oBAAA,yBAAAJ,GAAAA,GAAAD,EAAA,oBA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,CA1BA,MAFAE,EAAoBkG,CA6BtB,GAEF,CAgMCU,IA3Be,WACf,IAAMC,EAA2B3H,EAC3B4H,EAA2B3H,EASjCG,EAAMyH,cAAgBpF,EAAQrC,EAAMyH,eACpCD,EAAOlF,MAAgBkF,EAAOlF,IAAMD,EAAQmF,EAAOlF,MACnDiF,EAAOjF,MAAgBiF,EAAOjF,IAAMD,EAAQkF,EAAOjF,MACnDkF,EAAOE,OAAgBF,EAAOE,KAAOrF,EAAQmF,EAAOE,OACpDH,EAAOG,OAAgBH,EAAOG,KAAOrF,EAAQkF,EAAOG,OACpDF,EAAOG,SAAgBH,EAAOG,OAAStF,EAAQmF,EAAOG,SACtDJ,EAAOI,SAAgBJ,EAAOI,OAAStF,EAAQkF,EAAOI,QACvD,CAUCC,EACD,ECkBA3I,EAAA4I,YAfgB,SAAeC,GAC9B,IAAMC,EAAW7C,EAAAA,OAAO4C,GACxBC,EAAS5C,QAAU2C,EACnB,OAAOE,EAAAA,QAAQ,WAAA,OAAMC,EAAAA,SAAY,WAAA,OAAMF,EAAS5C,SAAS,EAAC,EAAElD,EAC7D,EAWAhD,EAAAiJ,UAnBM,SAAuBvF,GAC5B,OAAOqF,EAAOA,QAAC,WAAA,OAAMG,EAAAA,OAAsBxF,EAAM,EAAEV,EACpD,EAiBAhD,EAAAmJ,gBATgB,SAAgBC,GAC/B,IAAMC,EAAWpD,EAAAA,OAAOmD,GACxBC,EAASnD,QAAUkD,EAEnB9G,EAAAA,UAAU,WACT,OAAOiC,EAAMA,OAAC,WACb,OAAO8E,EAASnD,SACjB,EACD,EAAGlD,EACJ,EAAAhD,EAAAsJ,WA1BM,SAAqBC,GAC1B,GAAIjI,EAA+B,OAAOuD,OAC1C,OAAOkB,EAA0BwD,EAClC,EAuBAvJ,EAAAoD,QAAAA,CAAA"} +\ No newline at end of file ++{"version":3,"file":"runtime.min.js","sources":["../src/index.ts"],"sourcesContent":["import {\n\tsignal,\n\tcomputed,\n\teffect,\n\tSignal,\n\tReadonlySignal,\n} from \"@preact/signals-core\";\nimport {\n\tuseRef,\n\tuseMemo,\n\tuseEffect,\n\tuseLayoutEffect,\n\tversion as reactVersion,\n} from \"react\";\nimport { useSyncExternalStore } from \"use-sync-external-store/shim/index.js\";\n\nconst [major] = reactVersion.split(\".\").map(Number);\nconst Empty = [] as const;\n// V19 https://github.com/facebook/react/blob/346c7d4c43a0717302d446da9e7423a8e28d8996/packages/shared/ReactSymbols.js#L15\n// V18 https://github.com/facebook/react/blob/346c7d4c43a0717302d446da9e7423a8e28d8996/packages/shared/ReactSymbols.js#L15\nconst ReactElemType = Symbol.for(\n\tmajor >= 19 ? \"react.transitional.element\" : \"react.element\"\n);\n\nexport function wrapJsx(jsx: T): T {\n\tif (typeof jsx !== \"function\") return jsx;\n\n\treturn function (type: any, props: any, ...rest: any[]) {\n\t\tif (typeof type === \"string\" && props) {\n\t\t\tfor (let i in props) {\n\t\t\t\tlet v = props[i];\n\t\t\t\tif (i !== \"children\" && v instanceof Signal) {\n\t\t\t\t\tprops[i] = v.value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn jsx.call(jsx, type, props, ...rest);\n\t} as any as T;\n}\n\nconst symDispose: unique symbol =\n\t(Symbol as any).dispose || Symbol.for(\"Symbol.dispose\");\n\ninterface Effect {\n\t_sources: object | undefined;\n\t_start(): () => void;\n\t_callback(): void;\n\t_dispose(): void;\n}\n\n/**\n * Use this flag to represent a bare `useSignals` call that doesn't manually\n * close its effect store and relies on auto-closing when the next useSignals is\n * called or after a microtask\n */\nconst UNMANAGED = 0;\n/**\n * Use this flag to represent a `useSignals` call that is manually closed by a\n * try/finally block in a component's render method. This is the default usage\n * that the react-transform plugin uses.\n */\nconst MANAGED_COMPONENT = 1;\n/**\n * Use this flag to represent a `useSignals` call that is manually closed by a\n * try/finally block in a hook body. This is the default usage that the\n * react-transform plugin uses.\n */\nconst MANAGED_HOOK = 2;\n\n/**\n * An enum defining how this store is used. See the documentation for each enum\n * member for more details.\n * @see {@link UNMANAGED}\n * @see {@link MANAGED_COMPONENT}\n * @see {@link MANAGED_HOOK}\n */\ntype EffectStoreUsage =\n\t| typeof UNMANAGED\n\t| typeof MANAGED_COMPONENT\n\t| typeof MANAGED_HOOK;\n\nexport interface EffectStore {\n\t/**\n\t * An enum defining how this hook is used and whether it is invoked in a\n\t * component's body or hook body. See the comment on `EffectStoreUsage` for\n\t * more details.\n\t */\n\treadonly _usage: EffectStoreUsage;\n\treadonly effect: Effect;\n\tsubscribe(onStoreChange: () => void): () => void;\n\tgetSnapshot(): number;\n\t/** startEffect - begin tracking signals used in this component */\n\t_start(): void;\n\t/** finishEffect - stop tracking the signals used in this component */\n\tf(): void;\n\t[symDispose](): void;\n}\n\nlet currentStore: EffectStore | undefined;\n\nfunction startComponentEffect(\n\tprevStore: EffectStore | undefined,\n\tnextStore: EffectStore\n) {\n\tconst endEffect = nextStore.effect._start();\n\tcurrentStore = nextStore;\n\n\treturn finishComponentEffect.bind(nextStore, prevStore, endEffect);\n}\n\nfunction finishComponentEffect(\n\tthis: EffectStore,\n\tprevStore: EffectStore | undefined,\n\tendEffect: () => void\n) {\n\tendEffect();\n\tcurrentStore = prevStore;\n}\n\n/**\n * A redux-like store whose store value is a positive 32bit integer (a\n * 'version').\n *\n * React subscribes to this store and gets a snapshot of the current 'version',\n * whenever the 'version' changes, we tell React it's time to update the\n * component (call 'onStoreChange').\n *\n * How we achieve this is by creating a binding with an 'effect', when the\n * `effect._callback' is called, we update our store version and tell React to\n * re-render the component ([1] We don't really care when/how React does it).\n *\n * [1]\n * @see https://react.dev/reference/react/useSyncExternalStore\n * @see\n * https://github.com/reactjs/rfcs/blob/main/text/0214-use-sync-external-store.md\n *\n * @param _usage An enum defining how this hook is used and whether it is\n * invoked in a component's body or hook body. See the comment on\n * `EffectStoreUsage` for more details.\n */\nfunction createEffectStore(_usage: EffectStoreUsage): EffectStore {\n\tlet effectInstance!: Effect;\n\tlet endEffect: (() => void) | undefined;\n\tlet version = 0;\n\tlet onChangeNotifyReact: (() => void) | undefined;\n\n\tlet unsubscribe = effect(function (this: Effect) {\n\t\teffectInstance = this;\n\t});\n\teffectInstance._callback = function () {\n\t\tversion = (version + 1) | 0;\n\t\tif (onChangeNotifyReact) onChangeNotifyReact();\n\t};\n\n\treturn {\n\t\t_usage,\n\t\teffect: effectInstance,\n\t\tsubscribe(onStoreChange) {\n\t\t\tonChangeNotifyReact = onStoreChange;\n\n\t\t\treturn function () {\n\t\t\t\t/**\n\t\t\t\t * Rotate to next version when unsubscribing to ensure that components are re-run\n\t\t\t\t * when subscribing again.\n\t\t\t\t *\n\t\t\t\t * In StrictMode, 'memo'-ed components seem to keep a stale snapshot version, so\n\t\t\t\t * don't re-run after subscribing again if the version is the same as last time.\n\t\t\t\t *\n\t\t\t\t * Because we unsubscribe from the effect, the version may not change. We simply\n\t\t\t\t * set a new initial version in case of stale snapshots here.\n\t\t\t\t */\n\t\t\t\tversion = (version + 1) | 0;\n\t\t\t\tonChangeNotifyReact = undefined;\n\t\t\t\tunsubscribe();\n\t\t\t};\n\t\t},\n\t\tgetSnapshot() {\n\t\t\treturn version;\n\t\t},\n\t\t_start() {\n\t\t\t// In general, we want to support two kinds of usages of useSignals:\n\t\t\t//\n\t\t\t// A) Managed: calling useSignals in a component or hook body wrapped in a\n\t\t\t// try/finally (like what the react-transform plugin does)\n\t\t\t//\n\t\t\t// B) Unmanaged: Calling useSignals directly without wrapping in a\n\t\t\t// try/finally\n\t\t\t//\n\t\t\t// For managed, we finish the effect in the finally block of the component\n\t\t\t// or hook body. For unmanaged, we finish the effect in the next\n\t\t\t// useSignals call or after a microtask.\n\t\t\t//\n\t\t\t// There are different tradeoffs which each approach. With managed, using\n\t\t\t// a try/finally ensures that only signals used in the component or hook\n\t\t\t// body are tracked. However, signals accessed in render props are missed\n\t\t\t// because the render prop is invoked in another component that may or may\n\t\t\t// not realize it is rendering signals accessed in the render prop it is\n\t\t\t// given.\n\t\t\t//\n\t\t\t// The other approach is \"unmanaged\": to call useSignals directly without\n\t\t\t// wrapping in a try/finally. This approach is easier to manually write in\n\t\t\t// situations where a build step isn't available but does open up the\n\t\t\t// possibility of catching signals accessed in other code before the\n\t\t\t// effect is closed (e.g. in a layout effect). Most situations where this\n\t\t\t// could happen are generally consider bad patterns or bugs. For example,\n\t\t\t// using a signal in a component and not having a call to `useSignals`\n\t\t\t// would be an bug. Or using a signal in `useLayoutEffect` is generally\n\t\t\t// not recommended since that layout effect won't update when the signals'\n\t\t\t// value change.\n\t\t\t//\n\t\t\t// To support both approaches, we need to track how each invocation of\n\t\t\t// useSignals is used, so we can properly transition between different\n\t\t\t// kinds of usages.\n\t\t\t//\n\t\t\t// The following table shows the different scenarios and how we should\n\t\t\t// handle them.\n\t\t\t//\n\t\t\t// Key:\n\t\t\t// 0 = UNMANAGED\n\t\t\t// 1 = MANAGED_COMPONENT\n\t\t\t// 2 = MANAGED_HOOK\n\t\t\t//\n\t\t\t// Pattern:\n\t\t\t// prev store usage -> this store usage: action to take\n\t\t\t//\n\t\t\t// - 0 -> 0: finish previous effect (unknown to unknown)\n\t\t\t//\n\t\t\t// We don't know how the previous effect was used, so we need to finish\n\t\t\t// it before starting the next effect.\n\t\t\t//\n\t\t\t// - 0 -> 1: finish previous effect\n\t\t\t//\n\t\t\t// Assume previous invocation was another component or hook from another\n\t\t\t// component. Nested component renders (renderToStaticMarkup within a\n\t\t\t// component's render) won't be supported with bare useSignals calls.\n\t\t\t//\n\t\t\t// - 0 -> 2: capture & restore\n\t\t\t//\n\t\t\t// Previous invocation could be a component or a hook. Either way,\n\t\t\t// restore it after our invocation so that it can continue to capture\n\t\t\t// any signals after we exit.\n\t\t\t//\n\t\t\t// - 1 -> 0: Do nothing. Signals already captured by current effect store\n\t\t\t// - 1 -> 1: capture & restore (e.g. component calls renderToStaticMarkup)\n\t\t\t// - 1 -> 2: capture & restore (e.g. hook)\n\t\t\t//\n\t\t\t// - 2 -> 0: Do nothing. Signals already captured by current effect store\n\t\t\t// - 2 -> 1: capture & restore (e.g. hook calls renderToStaticMarkup)\n\t\t\t// - 2 -> 2: capture & restore (e.g. nested hook calls)\n\n\t\t\tif (currentStore == undefined) {\n\t\t\t\tendEffect = startComponentEffect(undefined, this);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst prevUsage = currentStore._usage;\n\t\t\tconst thisUsage = this._usage;\n\n\t\t\tif (\n\t\t\t\t(prevUsage == UNMANAGED && thisUsage == UNMANAGED) || // 0 -> 0\n\t\t\t\t(prevUsage == UNMANAGED && thisUsage == MANAGED_COMPONENT) // 0 -> 1\n\t\t\t) {\n\t\t\t\t// finish previous effect\n\t\t\t\tcurrentStore.f();\n\t\t\t\tendEffect = startComponentEffect(undefined, this);\n\t\t\t} else if (\n\t\t\t\t(prevUsage == MANAGED_COMPONENT && thisUsage == UNMANAGED) || // 1 -> 0\n\t\t\t\t(prevUsage == MANAGED_HOOK && thisUsage == UNMANAGED) // 2 -> 0\n\t\t\t) {\n\t\t\t\t// Do nothing since it'll be captured by current effect store\n\t\t\t} else {\n\t\t\t\t// nested scenarios, so capture and restore the previous effect store\n\t\t\t\tendEffect = startComponentEffect(currentStore, this);\n\t\t\t}\n\t\t},\n\t\tf() {\n\t\t\tconst end = endEffect;\n\t\t\tendEffect = undefined;\n\t\t\tend?.();\n\t\t},\n\t\t[symDispose]() {\n\t\t\tthis.f();\n\t\t},\n\t};\n}\n\nconst _queueMicroTask = Promise.prototype.then.bind(Promise.resolve());\n\nlet finalCleanup: Promise | undefined;\nexport function ensureFinalCleanup() {\n\tif (!finalCleanup) {\n\t\tfinalCleanup = _queueMicroTask(cleanupTrailingStore);\n\t}\n}\nfunction cleanupTrailingStore() {\n\tfinalCleanup = undefined;\n\tcurrentStore?.f();\n}\n\nconst useIsomorphicLayoutEffect =\n\ttypeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n\n/**\n * Custom hook to create the effect to track signals used during render and\n * subscribe to changes to rerender the component when the signals change.\n */\nexport function _useSignalsImplementation(\n\t_usage: EffectStoreUsage = UNMANAGED\n): EffectStore {\n\tensureFinalCleanup();\n\n\tconst storeRef = useRef();\n\tif (storeRef.current == null) {\n\t\tstoreRef.current = createEffectStore(_usage);\n\t}\n\n\tconst store = storeRef.current;\n\tuseSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot);\n\tstore._start();\n\t// note: _usage is a constant here, so conditional is okay\n\tif (_usage === UNMANAGED) useIsomorphicLayoutEffect(cleanupTrailingStore);\n\n\treturn store;\n}\n\n/**\n * A wrapper component that renders a Signal's value directly as a Text node or JSX.\n */\nfunction SignalValue({ data }: { data: Signal }) {\n\tconst store = _useSignalsImplementation(1);\n\ttry {\n\t\treturn data.value;\n\t} finally {\n\t\tstore.f();\n\t}\n}\n\n// Decorate Signals so React renders them as components.\nObject.defineProperties(Signal.prototype, {\n\t$$typeof: { configurable: true, value: ReactElemType },\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\tref: { configurable: true, value: null },\n});\n\nexport function useSignals(usage?: EffectStoreUsage): EffectStore {\n\treturn _useSignalsImplementation(usage);\n}\n\nexport function useSignal(value: T): Signal;\nexport function useSignal(): Signal;\nexport function useSignal(value?: T) {\n\treturn useMemo(() => signal(value), Empty);\n}\n\nexport function useComputed(compute: () => T): ReadonlySignal {\n\tconst $compute = useRef(compute);\n\t$compute.current = compute;\n\treturn useMemo(() => computed(() => $compute.current()), Empty);\n}\n\nexport function useSignalEffect(cb: () => void | (() => void)) {\n\tconst callback = useRef(cb);\n\tcallback.current = cb;\n\n\tuseEffect(() => {\n\t\treturn effect(function (this: Effect) {\n\t\t\treturn callback.current();\n\t\t});\n\t}, Empty);\n}\n"],"names":["currentStore","_reactVersion$split$m","reactVersion","version","split","map","Number","Empty","ReactElemType","Symbol","symDispose","dispose","startComponentEffect","prevStore","nextStore","endEffect","effect","_start","finishComponentEffect","bind","finalCleanup","_queueMicroTask","Promise","prototype","then","resolve","ensureFinalCleanup","cleanupTrailingStore","_currentStore","undefined","f","useIsomorphicLayoutEffect","window","useLayoutEffect","useEffect","_useSignalsImplementation","_usage","storeRef","useRef","current","_ref","effectInstance","onChangeNotifyReact","unsubscribe","this","_callback","subscribe","onStoreChange","getSnapshot","prevUsage","thisUsage","end","createEffectStore","store","useSyncExternalStore","Object","defineProperties","Signal","$$typeof","configurable","value","type","_ref2","data","props","get","ref","exports","useComputed","compute","$compute","useMemo","computed","useSignal","signal","useSignalEffect","cb","callback","useSignals","usage","wrapJsx","jsx","i","v","call","apply","concat","slice","arguments"],"mappings":"mcAgBA,IAmFIA,EAnFJC,EAAgBC,EAAYC,QAACC,MAAM,KAAKC,IAAIC,QACtCC,EAAQ,GAGRC,EAAgBC,OAAM,IAJhBR,EACZ,IAIU,GAAK,6BAA+B,iBAoBxCS,EACJD,OAAeE,SAAWF,OAAM,IAAK,kBA2DvC,SAASG,EACRC,EACAC,GAEA,IAAMC,EAAYD,EAAUE,OAAOC,IACnCjB,EAAec,EAEf,OAAOI,EAAsBC,KAAKL,EAAWD,EAAWE,EACzD,CAEA,SAASG,EAERL,EACAE,GAEAA,IACAf,EAAea,CAChB,CAyKA,IAEIO,EAFEC,EAAkBC,QAAQC,UAAUC,KAAKL,KAAKG,QAAQG,oBAG5CC,IACf,IAAKN,EACJA,EAAeC,EAAgBM,EAEjC,CACA,SAASA,IAAoBC,IAAAA,EAC5BR,OAAeS,EACfD,OAAAA,EAAA5B,IAAA4B,EAAcE,GACf,CAEA,IAAMC,EACa,oBAAXC,OAAyBC,kBAAkBC,EAAAA,UAMnC,SAAAC,EACfC,GAAoC,QAApC,IAAAA,EAAAA,EA5PiB,EA8PjBV,IAEA,IAAMW,EAAWC,EAAMA,SACvB,GAAwB,MAApBD,EAASE,QACZF,EAASE,QA7KX,SAA2BH,GAAwBI,IAAAA,EAC9CC,EACA1B,EAEA2B,EADAvC,EAAU,EAGVwC,EAAc3B,EAAMA,OAAC,WACxByB,EAAiBG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ACNL,cAAc,EACdM,IAAG,WACF,MAAO,CAAEF,KAAMnB,KAChB,GAEDsB,IAAK,CAAEP,cAAc,EAAMC,MAAO,QA4BnCO,EAAAhC,EAAAA,EAAAgC,EAAAzC,mBAAAA,EAAAyC,EAAAC,YAfgB,SAAeC,GAC9B,IAAMC,EAAWhC,EAAMA,OAAC+B,GACxBC,EAAS/B,QAAU8B,EACnB,OAAOE,EAAAA,QAAQ,WAAA,OAAMC,EAAAA,SAAY,WAAA,OAAMF,EAAS/B,SAAS,EAAC,EAAEhC,EAC7D,EAWA4D,EAAAM,UAnBgB,SAAab,GAC5B,OAAOW,EAAAA,QAAQ,WAAA,OAAMG,EAAAA,OAAsBd,EAAM,EAAErD,EACpD,EAiBA4D,EAAAQ,gBATgB,SAAgBC,GAC/B,IAAMC,EAAWvC,EAAAA,OAAOsC,GACxBC,EAAStC,QAAUqC,EAEnB1C,YAAU,WACT,OAAOlB,EAAMA,OAAC,WACb,OAAO6D,EAAStC,SACjB,EACD,EAAGhC,EACJ,EAAA4D,EAAAW,WAzBgB,SAAWC,GAC1B,OAAO5C,EAA0B4C,EAClC,EAuBAZ,EAAAa,QAhWM,SAAqBC,GAC1B,GAAmB,mBAARA,EAAoB,OAAOA,OAEtC,OAAiBpB,SAAAA,EAAWG,GAC3B,GAAoB,iBAATH,GAAqBG,EAC/B,IAAK,IAAIkB,KAAKlB,EAAO,CACpB,IAAImB,EAAInB,EAAMkB,GACd,GAAU,aAANA,GAAoBC,aAAa1B,EAAAA,OACpCO,EAAMkB,GAAKC,EAAEvB,KAEd,CAGF,OAAOqB,EAAIG,KAAIC,MAARJ,EAASA,CAAAA,EAAKpB,EAAMG,GAAKsB,OAAAC,GAAAA,MAAAH,KAAAI,cACjC,CACD,CAiVA"} +\ No newline at end of file +diff --git a/node_modules/@preact/signals-react/runtime/dist/runtime.mjs b/node_modules/@preact/signals-react/runtime/dist/runtime.mjs +index e6e611b..b14be48 100644 +--- a/node_modules/@preact/signals-react/runtime/dist/runtime.mjs ++++ b/node_modules/@preact/signals-react/runtime/dist/runtime.mjs +@@ -1 +1 @@ +-import{Signal as t,signal as n,computed as e,effect as r}from"@preact/signals-core";import i,{version as o,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED as s,useRef as u,useMemo as c,useEffect as f,useLayoutEffect as l}from"react";import{useSyncExternalStore as a}from"use-sync-external-store/shim/index.js";import m from"react/jsx-runtime";import p from"react/jsx-dev-runtime";let d=!1,b=null,g=!1,h=null;const v=new Map;function y(t){if(!t)return 1;const n=v.get(t);if(void 0!==n)return n;let e;const r=t.useCallback.toString();if(t.useReducer===t.useEffect)e=1;else if(t.useEffect===t.useImperativeHandle)e=32;else if(/Invalid/.test(r))e=2;else if(/updateCallback/.test(r)||/\[0\]/.test(r)&&/\[1\]/.test(r)){let n=t.useReducer.toString();if(/rerenderReducer/.test(n)||/return\s*\[\w+,/.test(n))e=16;else e=8}else e=4;v.set(t,e);return e}function _(){const[t]=o.split(".").map(Number);if(t>=19)throw new Error("Automatic signals tracking is not supported in React 19 and later, try the Babel plugin instead https://github.com/preactjs/signals/tree/main/packages/react-transform#signals-react-transform.");!function(){d=!0;Object.defineProperty(s.ReactCurrentDispatcher,"current",{get:()=>h,set(t){if(g){h=t;return}const n=y(h),e=y(t);h=t;if(function(t,n){if(1&t&&28&n)return!0;else if(2&t||2&n)return!1;else return!1}(n,e)){g=!0;b=M(1);g=!1}else if(function(t,n){return Boolean(28&t&&16&n)}(n,e)){var r;null==(r=b)||r.f();g=!0;b=M(1);g=!1}else if(function(t,n){return Boolean(28&t&&1&n)}(n,e)){var i;null==(i=b)||i.f();b=null}}})}();!function(){const t=m,n=p;i.createElement=k(i.createElement);n.jsx&&(n.jsx=k(n.jsx));t.jsx&&(t.jsx=k(t.jsx));n.jsxs&&(n.jsxs=k(n.jsxs));t.jsxs&&(t.jsxs=k(t.jsxs));n.jsxDEV&&(n.jsxDEV=k(n.jsxDEV));t.jsxDEV&&(t.jsxDEV=k(t.jsxDEV))}()}const[j]=o.split(".").map(Number),w=[],S=Symbol.for(j>=19?"react.transitional.element":"react.element"),x=()=>{};function k(n){if("function"!=typeof n)return n;else return function(e,r,...i){if("string"==typeof e&&r)for(let n in r){let e=r[n];if("children"!==n&&e instanceof t)r[n]=e.value}return n.call(n,e,r,...i)}}const B=Symbol.dispose||Symbol.for("Symbol.dispose");let N;function O(t,n){const e=n.effect.S();N=n;return P.bind(n,t,e)}function P(t,n){n();N=t}const R={o:0,effect:{s:void 0,c(){},S:()=>x,d(){}},subscribe:()=>x,getSnapshot:()=>0,S(){},f(){},[B](){}},$=Promise.prototype.then.bind(Promise.resolve());let A;function C(){if(!A)A=$(E)}function E(){var t;A=void 0;null==(t=N)||t.f()}const I="undefined"!=typeof window?l:f;function M(t=0){C();const n=u();if(null==n.current)n.current=function(t){let n,e,i,o=0,s=r(function(){n=this});n.c=function(){o=o+1|0;if(i)i()};return{o:t,effect:n,subscribe(t){i=t;return function(){o=o+1|0;i=void 0;s()}},getSnapshot:()=>o,S(){if(null==N){e=O(void 0,this);return}const t=N.o,n=this.o;if(0==t&&0==n||0==t&&1==n){N.f();e=O(void 0,this)}else if(1==t&&0==n||2==t&&0==n);else e=O(N,this)},f(){const t=e;e=void 0;null==t||t()},[B](){this.f()}}}(t);const e=n.current;a(e.subscribe,e.getSnapshot,e.getSnapshot);e.S();if(0===t)I(E);return e}Object.defineProperties(t.prototype,{$$typeof:{configurable:!0,value:S},type:{configurable:!0,value:function({data:t}){const n=M(1);try{return t.value}finally{n.f()}}},props:{configurable:!0,get(){return{data:this}}},ref:{configurable:!0,value:null}});function q(t){if(d)return R;else return M(t)}function useSignal(t){return c(()=>n(t),w)}function useComputed(t){const n=u(t);n.current=t;return c(()=>e(()=>n.current()),w)}function useSignalEffect(t){const n=u(t);n.current=t;f(()=>r(function(){return n.current()}),w)}export{M as _useSignalsImplementation,C as ensureFinalCleanup,_ as installAutoSignalTracking,useComputed,useSignal,useSignalEffect,q as useSignals,k as wrapJsx};//# sourceMappingURL=runtime.mjs.map ++import{Signal as n,signal as t,computed as e,effect as o}from"@preact/signals-core";import{version as i,useRef as r,useMemo as u,useEffect as f,useLayoutEffect as c}from"react";import{useSyncExternalStore as s}from"use-sync-external-store/shim/index.js";const[l]=i.split(".").map(Number),a=[],m=Symbol.for(l>=19?"react.transitional.element":"react.element");function p(t){if("function"!=typeof t)return t;else return function(e,o,...i){if("string"==typeof e&&o)for(let t in o){let e=o[t];if("children"!==t&&e instanceof n)o[t]=e.value}return t.call(t,e,o,...i)}}const d=Symbol.dispose||Symbol.for("Symbol.dispose");let b;function y(n,t){const e=t.effect.S();b=t;return h.bind(t,n,e)}function h(n,t){t();b=n}const g=Promise.prototype.then.bind(Promise.resolve());let v;function S(){if(!v)v=g(x)}function x(){var n;v=void 0;null==(n=b)||n.f()}const j="undefined"!=typeof window?c:f;function w(n=0){S();const t=r();if(null==t.current)t.current=function(n){let t,e,i,r=0,u=o(function(){t=this});t.c=function(){r=r+1|0;if(i)i()};return{o:n,effect:t,subscribe(n){i=n;return function(){r=r+1|0;i=void 0;u()}},getSnapshot:()=>r,S(){if(null==b){e=y(void 0,this);return}const n=b.o,t=this.o;if(0==n&&0==t||0==n&&1==t){b.f();e=y(void 0,this)}else if(1==n&&0==t||2==n&&0==t);else e=y(b,this)},f(){const n=e;e=void 0;null==n||n()},[d](){this.f()}}}(n);const e=t.current;s(e.subscribe,e.getSnapshot,e.getSnapshot);e.S();if(0===n)j(x);return e}Object.defineProperties(n.prototype,{$$typeof:{configurable:!0,value:m},type:{configurable:!0,value:function({data:n}){const t=w(1);try{return n.value}finally{t.f()}}},props:{configurable:!0,get(){return{data:this}}},ref:{configurable:!0,value:null}});function P(n){return w(n)}function useSignal(n){return u(()=>t(n),a)}function useComputed(n){const t=r(n);t.current=n;return u(()=>e(()=>t.current()),a)}function useSignalEffect(n){const t=r(n);t.current=n;f(()=>o(function(){return t.current()}),a)}export{w as _useSignalsImplementation,S as ensureFinalCleanup,useComputed,useSignal,useSignalEffect,P as useSignals,p as wrapJsx};//# sourceMappingURL=runtime.mjs.map +diff --git a/node_modules/@preact/signals-react/runtime/dist/runtime.mjs.map b/node_modules/@preact/signals-react/runtime/dist/runtime.mjs.map +index d0a2f16..9237b53 100644 +--- a/node_modules/@preact/signals-react/runtime/dist/runtime.mjs.map ++++ b/node_modules/@preact/signals-react/runtime/dist/runtime.mjs.map +@@ -1 +1 @@ +-{"version":3,"file":"runtime.mjs","sources":["../src/auto.ts","../src/index.ts"],"sourcesContent":["import {\n\t// @ts-ignore-next-line\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED as ReactInternals,\n\tversion as reactVersion,\n} from \"react\";\nimport React from \"react\";\nimport jsxRuntime from \"react/jsx-runtime\";\nimport jsxRuntimeDev from \"react/jsx-dev-runtime\";\nimport { EffectStore, wrapJsx, _useSignalsImplementation } from \"./index\";\n\nexport interface ReactDispatcher {\n\tuseRef: typeof React.useRef;\n\tuseCallback: typeof React.useCallback;\n\tuseReducer: typeof React.useReducer;\n\tuseSyncExternalStore: typeof React.useSyncExternalStore;\n\tuseEffect: typeof React.useEffect;\n\tuseImperativeHandle: typeof React.useImperativeHandle;\n}\n\n// In order for signals to work in React, we need to observe what signals a\n// component uses while rendering. To do this, we need to know when a component\n// is rendering. To do this, we watch the transition of the\n// ReactCurrentDispatcher to know when a component is rerendering.\n//\n// To track when we are entering and exiting a component render (i.e. before and\n// after React renders a component), we track how the dispatcher changes.\n// Outside of a component rendering, the dispatcher is set to an instance that\n// errors or warns when any hooks are called. This behavior is prevents hooks\n// from being used outside of components. Right before React renders a\n// component, the dispatcher is set to an instance that doesn't warn or error\n// and contains the implementations of all hooks. Right after React finishes\n// rendering a component, the dispatcher is set to the erroring one again. This\n// erroring dispatcher is called the `ContextOnlyDispatcher` in React's source.\n//\n// So, we watch the getter and setter on `ReactCurrentDispatcher.current` to\n// monitor the changes to the current ReactDispatcher. When the dispatcher\n// changes from the ContextOnlyDispatcher to a \"valid\" dispatcher, we assume we\n// are entering a component render. At this point, we setup our\n// auto-subscriptions for any signals used in the component. We do this by\n// creating an Signal effect and manually starting the Signal effect. We use\n// `useSyncExternalStore` to trigger rerenders on the component when any signals\n// it uses changes.\n//\n// When the dispatcher changes from a valid dispatcher back to the\n// ContextOnlyDispatcher, we assume we are exiting a component render. At this\n// point we stop the effect.\n//\n// Some additional complexities to be aware of:\n// - If a component calls `setState` while rendering, React will re-render the\n// component immediately. Before triggering the re-render, React will change\n// the dispatcher to the HooksDispatcherOnRerender. When we transition to this\n// rerendering adapter, we need to re-trigger our hooks to keep the order of\n// hooks the same for every render of a component.\n//\n// - In development, useReducer, useState, and useMemo change the dispatcher to\n// a different warning dispatcher (not ContextOnlyDispatcher) before invoking\n// the reducer and resets it right after.\n//\n// The useSyncExternalStore shim will use some of these hooks when we invoke\n// it while entering a component render. We need to prevent this dispatcher\n// change caused by these hooks from re-triggering our entering logic (it\n// would cause an infinite loop if we did not). We do this by using a lock to\n// prevent the setter from running while we are in the setter.\n//\n// When a Component's function body invokes useReducer, useState, or useMemo,\n// this change in dispatcher should not signal that we are entering or exiting\n// a component render. We ignore this change by detecting these dispatchers as\n// different from ContextOnlyDispatcher and other valid dispatchers.\n//\n// - The `use` hook will change the dispatcher to from a valid update dispatcher\n// to a valid mount dispatcher in some cases. Similarly to useReducer\n// mentioned above, we should not signal that we are exiting a component\n// during this change. Because these other valid dispatchers do not pass the\n// ContextOnlyDispatcher check, they do not affect our logic.\n//\n// - When server rendering, React does not change the dispatcher before and\n// after each component render. It sets it once for before the first render\n// and once for after the last render. This means that we will not be able to\n// detect when we are entering or exiting a component render. This is fine\n// because we don't need to detect this for server rendering. A component\n// can't trigger async rerenders in SSR so we don't need to track signals.\n//\n// If a component updates a signal value while rendering during SSR, we will\n// not rerender the component because the signal value will synchronously\n// change so all reads of the signal further down the tree will see the new\n// value.\n\n/*\nBelow is a state machine definition for transitions between the various\ndispatchers in React's prod build. (It does not include dev time warning\ndispatchers which are just always ignored).\n\nENTER and EXIT suffixes indicates whether this ReactCurrentDispatcher transition\nsignals we are entering or exiting a component render, or if it doesn't signal a\nchange in the component rendering lifecyle (NOOP).\n\n```js\n// Paste this into https://stately.ai/viz to visualize the state machine.\nimport { createMachine } from \"xstate\";\n\n// ENTER, EXIT, NOOP suffixes indicates whether this ReactCurrentDispatcher\n// transition signals we are entering or exiting a component render, or\n// if it doesn't signal a change in the component rendering lifecyle (NOOP).\n\nconst dispatcherMachinePROD = createMachine({\n\tid: \"ReactCurrentDispatcher_PROD\",\n\tinitial: \"null\",\n\tstates: {\n\t\tnull: {\n\t\t\ton: {\n\t\t\t\tpushDispatcher: \"ContextOnlyDispatcher\",\n\t\t\t},\n\t\t},\n\t\tContextOnlyDispatcher: {\n\t\t\ton: {\n\t\t\t\trenderWithHooks_Mount_ENTER: \"HooksDispatcherOnMount\",\n\t\t\t\trenderWithHooks_Update_ENTER: \"HooksDispatcherOnUpdate\",\n\t\t\t\tpushDispatcher_NOOP: \"ContextOnlyDispatcher\",\n\t\t\t\tpopDispatcher_NOOP: \"ContextOnlyDispatcher\",\n\t\t\t},\n\t\t},\n\t\tHooksDispatcherOnMount: {\n\t\t\ton: {\n\t\t\t\trenderWithHooksAgain_ENTER: \"HooksDispatcherOnRerender\",\n\t\t\t\tresetHooksAfterThrow_EXIT: \"ContextOnlyDispatcher\",\n\t\t\t\tfinishRenderingHooks_EXIT: \"ContextOnlyDispatcher\",\n\t\t\t},\n\t\t},\n\t\tHooksDispatcherOnUpdate: {\n\t\t\ton: {\n\t\t\t\trenderWithHooksAgain_ENTER: \"HooksDispatcherOnRerender\",\n\t\t\t\tresetHooksAfterThrow_EXIT: \"ContextOnlyDispatcher\",\n\t\t\t\tfinishRenderingHooks_EXIT: \"ContextOnlyDispatcher\",\n\t\t\t\tuse_ResumeSuspensedMount_NOOP: \"HooksDispatcherOnMount\",\n\t\t\t},\n\t\t},\n\t\tHooksDispatcherOnRerender: {\n\t\t\ton: {\n\t\t\t\trenderWithHooksAgain_ENTER: \"HooksDispatcherOnRerender\",\n\t\t\t\tresetHooksAfterThrow_EXIT: \"ContextOnlyDispatcher\",\n\t\t\t\tfinishRenderingHooks_EXIT: \"ContextOnlyDispatcher\",\n\t\t\t},\n\t\t},\n\t},\n});\n```\n*/\n\nexport let isAutoSignalTrackingInstalled = false;\n\nlet store: EffectStore | null = null;\nlet lock = false;\nlet currentDispatcher: ReactDispatcher | null = null;\n\nfunction installCurrentDispatcherHook() {\n\tisAutoSignalTrackingInstalled = true;\n\n\tObject.defineProperty(ReactInternals.ReactCurrentDispatcher, \"current\", {\n\t\tget() {\n\t\t\treturn currentDispatcher;\n\t\t},\n\t\tset(nextDispatcher: ReactDispatcher) {\n\t\t\tif (lock) {\n\t\t\t\tcurrentDispatcher = nextDispatcher;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst currentDispatcherType = getDispatcherType(currentDispatcher);\n\t\t\tconst nextDispatcherType = getDispatcherType(nextDispatcher);\n\n\t\t\t// Update the current dispatcher now so the hooks inside of the\n\t\t\t// useSyncExternalStore shim get the right dispatcher.\n\t\t\tcurrentDispatcher = nextDispatcher;\n\t\t\tif (\n\t\t\t\tisEnteringComponentRender(currentDispatcherType, nextDispatcherType)\n\t\t\t) {\n\t\t\t\tlock = true;\n\t\t\t\tstore = _useSignalsImplementation(1);\n\t\t\t\tlock = false;\n\t\t\t} else if (\n\t\t\t\tisRestartingComponentRender(currentDispatcherType, nextDispatcherType)\n\t\t\t) {\n\t\t\t\tstore?.f();\n\t\t\t\tlock = true;\n\t\t\t\tstore = _useSignalsImplementation(1);\n\t\t\t\tlock = false;\n\t\t\t} else if (\n\t\t\t\tisExitingComponentRender(currentDispatcherType, nextDispatcherType)\n\t\t\t) {\n\t\t\t\tstore?.f();\n\t\t\t\tstore = null;\n\t\t\t}\n\t\t},\n\t});\n}\n\ntype DispatcherType = number;\nconst ContextOnlyDispatcherType = 1 << 0;\nconst WarningDispatcherType = 1 << 1;\nconst MountDispatcherType = 1 << 2;\nconst UpdateDispatcherType = 1 << 3;\nconst RerenderDispatcherType = 1 << 4;\nconst ServerDispatcherType = 1 << 5;\nconst BrowserClientDispatcherType =\n\tMountDispatcherType | UpdateDispatcherType | RerenderDispatcherType;\n\nconst dispatcherTypeCache = new Map();\nfunction getDispatcherType(dispatcher: ReactDispatcher | null): DispatcherType {\n\t// Treat null the same as the ContextOnlyDispatcher.\n\tif (!dispatcher) return ContextOnlyDispatcherType;\n\n\tconst cached = dispatcherTypeCache.get(dispatcher);\n\tif (cached !== undefined) return cached;\n\n\t// The ContextOnlyDispatcher sets all the hook implementations to a function\n\t// that takes no arguments and throws and error. This dispatcher is the only\n\t// dispatcher where useReducer and useEffect will have the same\n\t// implementation.\n\tlet type: DispatcherType;\n\tconst useCallbackImpl = dispatcher.useCallback.toString();\n\tif (dispatcher.useReducer === dispatcher.useEffect) {\n\t\ttype = ContextOnlyDispatcherType;\n\n\t\t// @ts-expect-error When server rendering, useEffect and useImperativeHandle\n\t\t// are both set to noop functions and so have the same implementation.\n\t} else if (dispatcher.useEffect === dispatcher.useImperativeHandle) {\n\t\ttype = ServerDispatcherType;\n\t} else if (/Invalid/.test(useCallbackImpl)) {\n\t\t// We first check for warning dispatchers because they would also pass some\n\t\t// of the checks below.\n\t\ttype = WarningDispatcherType;\n\t} else if (\n\t\t// The development mount dispatcher invokes a function called\n\t\t// `mountCallback` whereas the development update/re-render dispatcher\n\t\t// invokes a function called `updateCallback`. Use that difference to\n\t\t// determine if we are in a mount or update-like dispatcher in development.\n\t\t// The production mount dispatcher defines an array of the form [callback,\n\t\t// deps] whereas update/re-render dispatchers read the array using array\n\t\t// indices (e.g. `[0]` and `[1]`). Use those differences to determine if we\n\t\t// are in a mount or update-like dispatcher in production.\n\t\t/updateCallback/.test(useCallbackImpl) ||\n\t\t(/\\[0\\]/.test(useCallbackImpl) && /\\[1\\]/.test(useCallbackImpl))\n\t) {\n\t\t// The update and rerender dispatchers have different implementations for\n\t\t// useReducer. We'll check it's implementation to determine if this is the\n\t\t// rerender or update dispatcher.\n\t\tlet useReducerImpl = dispatcher.useReducer.toString();\n\t\tif (\n\t\t\t// The development rerender dispatcher invokes a function called\n\t\t\t// `rerenderReducer` whereas the update dispatcher invokes a function\n\t\t\t// called `updateReducer`. The production rerender dispatcher returns an\n\t\t\t// array of the form `[state, dispatch]` whereas the update dispatcher\n\t\t\t// returns an array of `[fiber.memoizedState, dispatch]` so we check the\n\t\t\t// return statement in the implementation of useReducer to differentiate\n\t\t\t// between the two.\n\t\t\t/rerenderReducer/.test(useReducerImpl) ||\n\t\t\t/return\\s*\\[\\w+,/.test(useReducerImpl)\n\t\t) {\n\t\t\ttype = RerenderDispatcherType;\n\t\t} else {\n\t\t\ttype = UpdateDispatcherType;\n\t\t}\n\t} else {\n\t\ttype = MountDispatcherType;\n\t}\n\n\tdispatcherTypeCache.set(dispatcher, type);\n\treturn type;\n}\n\nfunction isEnteringComponentRender(\n\tcurrentDispatcherType: DispatcherType,\n\tnextDispatcherType: DispatcherType\n): boolean {\n\tif (\n\t\tcurrentDispatcherType & ContextOnlyDispatcherType &&\n\t\tnextDispatcherType & BrowserClientDispatcherType\n\t) {\n\t\t// ## Mount or update (ContextOnlyDispatcher -> ValidDispatcher (Mount or Update))\n\t\t//\n\t\t// If the current dispatcher is the ContextOnlyDispatcher and the next\n\t\t// dispatcher is a valid dispatcher, we are entering a component render.\n\t\treturn true;\n\t} else if (\n\t\tcurrentDispatcherType & WarningDispatcherType ||\n\t\tnextDispatcherType & WarningDispatcherType\n\t) {\n\t\t// ## Warning dispatcher\n\t\t//\n\t\t// If the current dispatcher or next dispatcher is an warning dispatcher,\n\t\t// we are not entering a component render. The current warning dispatchers\n\t\t// are used to warn when hooks are nested improperly and do not indicate\n\t\t// entering a new component render.\n\t\treturn false;\n\t} else {\n\t\t// ## Resuming suspended mount edge case (Update -> Mount)\n\t\t//\n\t\t// If we are transitioning from the update dispatcher to the mount\n\t\t// dispatcher, then this component is using the `use` hook and is resuming\n\t\t// from a mount. We should not re-invoke our hooks in this situation since\n\t\t// we are not entering a new component render, but instead continuing a\n\t\t// previous render.\n\t\t//\n\t\t// ## Other transitions\n\t\t//\n\t\t// For example, Mount -> Mount, Update -> Update, Mount -> Update, any\n\t\t// transition in and out of invalid dispatchers.\n\t\t//\n\t\t// There is no known transition for the following transitions so we default\n\t\t// to not triggering a re-enter of the component.\n\t\t// - HooksDispatcherOnMount -> HooksDispatcherOnMount\n\t\t// - HooksDispatcherOnMount -> HooksDispatcherOnUpdate\n\t\t// - HooksDispatcherOnUpdate -> HooksDispatcherOnUpdate\n\t\treturn false;\n\t}\n}\n\nfunction isRestartingComponentRender(\n\tcurrentDispatcherType: DispatcherType,\n\tnextDispatcherType: DispatcherType\n): boolean {\n\t// A transition from a valid browser dispatcher into the rerender dispatcher\n\t// is the restart of a component render, so we should end the current\n\t// component effect and re-invoke our hooks. Details below.\n\t//\n\t// ## In-place rerendering (e.g. Mount -> Rerender)\n\t//\n\t// If we are transitioning from the mount, update, or rerender dispatcher to\n\t// the rerender dispatcher (e.g. HooksDispatcherOnMount to\n\t// HooksDispatcherOnRerender), then this component is rerendering due to\n\t// calling setState inside of its function body. We are re-entering a\n\t// component's render method and so we should re-invoke our hooks.\n\n\treturn Boolean(\n\t\tcurrentDispatcherType & BrowserClientDispatcherType &&\n\t\t\tnextDispatcherType & RerenderDispatcherType\n\t);\n}\n\n/**\n * We are exiting a component render if the current dispatcher is a valid\n * dispatcher and the next dispatcher is the ContextOnlyDispatcher.\n */\nfunction isExitingComponentRender(\n\tcurrentDispatcherType: DispatcherType,\n\tnextDispatcherType: DispatcherType\n): boolean {\n\treturn Boolean(\n\t\tcurrentDispatcherType & BrowserClientDispatcherType &&\n\t\t\tnextDispatcherType & ContextOnlyDispatcherType\n\t);\n}\n\ninterface JsxRuntimeModule {\n\tjsx?(type: any, ...rest: any[]): unknown;\n\tjsxs?(type: any, ...rest: any[]): unknown;\n\tjsxDEV?(type: any, ...rest: any[]): unknown;\n}\n\nexport function installJSXHooks() {\n\tconst JsxPro: JsxRuntimeModule = jsxRuntime;\n\tconst JsxDev: JsxRuntimeModule = jsxRuntimeDev;\n\n\t/**\n\t * createElement _may_ be called by jsx runtime as a fallback in certain cases,\n\t * so we need to wrap it regardless.\n\t *\n\t * The jsx exports depend on the `NODE_ENV` var to ensure the users' bundler doesn't\n\t * include both, so one of them will be set with `undefined` values.\n\t */\n\tReact.createElement = wrapJsx(React.createElement);\n\tJsxDev.jsx && /* */ (JsxDev.jsx = wrapJsx(JsxDev.jsx));\n\tJsxPro.jsx && /* */ (JsxPro.jsx = wrapJsx(JsxPro.jsx));\n\tJsxDev.jsxs && /* */ (JsxDev.jsxs = wrapJsx(JsxDev.jsxs));\n\tJsxPro.jsxs && /* */ (JsxPro.jsxs = wrapJsx(JsxPro.jsxs));\n\tJsxDev.jsxDEV && /**/ (JsxDev.jsxDEV = wrapJsx(JsxDev.jsxDEV));\n\tJsxPro.jsxDEV && /**/ (JsxPro.jsxDEV = wrapJsx(JsxPro.jsxDEV));\n}\n\nexport function installAutoSignalTracking() {\n\tconst [major] = reactVersion.split(\".\").map(Number);\n\tif (major >= 19) {\n\t\tthrow new Error(\n\t\t\t\"Automatic signals tracking is not supported in React 19 and later, try the Babel plugin instead https://github.com/preactjs/signals/tree/main/packages/react-transform#signals-react-transform.\"\n\t\t);\n\t}\n\tinstallCurrentDispatcherHook();\n\tinstallJSXHooks();\n}\n","import {\n\tsignal,\n\tcomputed,\n\teffect,\n\tSignal,\n\tReadonlySignal,\n} from \"@preact/signals-core\";\nimport {\n\tuseRef,\n\tuseMemo,\n\tuseEffect,\n\tuseLayoutEffect,\n\tversion as reactVersion,\n} from \"react\";\nimport { useSyncExternalStore } from \"use-sync-external-store/shim/index.js\";\nimport { isAutoSignalTrackingInstalled } from \"./auto\";\n\nexport { installAutoSignalTracking } from \"./auto\";\n\nconst [major] = reactVersion.split(\".\").map(Number);\nconst Empty = [] as const;\n// V19 https://github.com/facebook/react/blob/346c7d4c43a0717302d446da9e7423a8e28d8996/packages/shared/ReactSymbols.js#L15\n// V18 https://github.com/facebook/react/blob/346c7d4c43a0717302d446da9e7423a8e28d8996/packages/shared/ReactSymbols.js#L15\nconst ReactElemType = Symbol.for(\n\tmajor >= 19 ? \"react.transitional.element\" : \"react.element\"\n);\n\nconst noop = () => {};\n\nexport function wrapJsx(jsx: T): T {\n\tif (typeof jsx !== \"function\") return jsx;\n\n\treturn function (type: any, props: any, ...rest: any[]) {\n\t\tif (typeof type === \"string\" && props) {\n\t\t\tfor (let i in props) {\n\t\t\t\tlet v = props[i];\n\t\t\t\tif (i !== \"children\" && v instanceof Signal) {\n\t\t\t\t\tprops[i] = v.value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn jsx.call(jsx, type, props, ...rest);\n\t} as any as T;\n}\n\nconst symDispose: unique symbol =\n\t(Symbol as any).dispose || Symbol.for(\"Symbol.dispose\");\n\ninterface Effect {\n\t_sources: object | undefined;\n\t_start(): () => void;\n\t_callback(): void;\n\t_dispose(): void;\n}\n\n/**\n * Use this flag to represent a bare `useSignals` call that doesn't manually\n * close its effect store and relies on auto-closing when the next useSignals is\n * called or after a microtask\n */\nconst UNMANAGED = 0;\n/**\n * Use this flag to represent a `useSignals` call that is manually closed by a\n * try/finally block in a component's render method. This is the default usage\n * that the react-transform plugin uses.\n */\nconst MANAGED_COMPONENT = 1;\n/**\n * Use this flag to represent a `useSignals` call that is manually closed by a\n * try/finally block in a hook body. This is the default usage that the\n * react-transform plugin uses.\n */\nconst MANAGED_HOOK = 2;\n\n/**\n * An enum defining how this store is used. See the documentation for each enum\n * member for more details.\n * @see {@link UNMANAGED}\n * @see {@link MANAGED_COMPONENT}\n * @see {@link MANAGED_HOOK}\n */\ntype EffectStoreUsage =\n\t| typeof UNMANAGED\n\t| typeof MANAGED_COMPONENT\n\t| typeof MANAGED_HOOK;\n\nexport interface EffectStore {\n\t/**\n\t * An enum defining how this hook is used and whether it is invoked in a\n\t * component's body or hook body. See the comment on `EffectStoreUsage` for\n\t * more details.\n\t */\n\treadonly _usage: EffectStoreUsage;\n\treadonly effect: Effect;\n\tsubscribe(onStoreChange: () => void): () => void;\n\tgetSnapshot(): number;\n\t/** startEffect - begin tracking signals used in this component */\n\t_start(): void;\n\t/** finishEffect - stop tracking the signals used in this component */\n\tf(): void;\n\t[symDispose](): void;\n}\n\nlet currentStore: EffectStore | undefined;\n\nfunction startComponentEffect(\n\tprevStore: EffectStore | undefined,\n\tnextStore: EffectStore\n) {\n\tconst endEffect = nextStore.effect._start();\n\tcurrentStore = nextStore;\n\n\treturn finishComponentEffect.bind(nextStore, prevStore, endEffect);\n}\n\nfunction finishComponentEffect(\n\tthis: EffectStore,\n\tprevStore: EffectStore | undefined,\n\tendEffect: () => void\n) {\n\tendEffect();\n\tcurrentStore = prevStore;\n}\n\n/**\n * A redux-like store whose store value is a positive 32bit integer (a\n * 'version').\n *\n * React subscribes to this store and gets a snapshot of the current 'version',\n * whenever the 'version' changes, we tell React it's time to update the\n * component (call 'onStoreChange').\n *\n * How we achieve this is by creating a binding with an 'effect', when the\n * `effect._callback' is called, we update our store version and tell React to\n * re-render the component ([1] We don't really care when/how React does it).\n *\n * [1]\n * @see https://react.dev/reference/react/useSyncExternalStore\n * @see\n * https://github.com/reactjs/rfcs/blob/main/text/0214-use-sync-external-store.md\n *\n * @param _usage An enum defining how this hook is used and whether it is\n * invoked in a component's body or hook body. See the comment on\n * `EffectStoreUsage` for more details.\n */\nfunction createEffectStore(_usage: EffectStoreUsage): EffectStore {\n\tlet effectInstance!: Effect;\n\tlet endEffect: (() => void) | undefined;\n\tlet version = 0;\n\tlet onChangeNotifyReact: (() => void) | undefined;\n\n\tlet unsubscribe = effect(function (this: Effect) {\n\t\teffectInstance = this;\n\t});\n\teffectInstance._callback = function () {\n\t\tversion = (version + 1) | 0;\n\t\tif (onChangeNotifyReact) onChangeNotifyReact();\n\t};\n\n\treturn {\n\t\t_usage,\n\t\teffect: effectInstance,\n\t\tsubscribe(onStoreChange) {\n\t\t\tonChangeNotifyReact = onStoreChange;\n\n\t\t\treturn function () {\n\t\t\t\t/**\n\t\t\t\t * Rotate to next version when unsubscribing to ensure that components are re-run\n\t\t\t\t * when subscribing again.\n\t\t\t\t *\n\t\t\t\t * In StrictMode, 'memo'-ed components seem to keep a stale snapshot version, so\n\t\t\t\t * don't re-run after subscribing again if the version is the same as last time.\n\t\t\t\t *\n\t\t\t\t * Because we unsubscribe from the effect, the version may not change. We simply\n\t\t\t\t * set a new initial version in case of stale snapshots here.\n\t\t\t\t */\n\t\t\t\tversion = (version + 1) | 0;\n\t\t\t\tonChangeNotifyReact = undefined;\n\t\t\t\tunsubscribe();\n\t\t\t};\n\t\t},\n\t\tgetSnapshot() {\n\t\t\treturn version;\n\t\t},\n\t\t_start() {\n\t\t\t// In general, we want to support two kinds of usages of useSignals:\n\t\t\t//\n\t\t\t// A) Managed: calling useSignals in a component or hook body wrapped in a\n\t\t\t// try/finally (like what the react-transform plugin does)\n\t\t\t//\n\t\t\t// B) Unmanaged: Calling useSignals directly without wrapping in a\n\t\t\t// try/finally\n\t\t\t//\n\t\t\t// For managed, we finish the effect in the finally block of the component\n\t\t\t// or hook body. For unmanaged, we finish the effect in the next\n\t\t\t// useSignals call or after a microtask.\n\t\t\t//\n\t\t\t// There are different tradeoffs which each approach. With managed, using\n\t\t\t// a try/finally ensures that only signals used in the component or hook\n\t\t\t// body are tracked. However, signals accessed in render props are missed\n\t\t\t// because the render prop is invoked in another component that may or may\n\t\t\t// not realize it is rendering signals accessed in the render prop it is\n\t\t\t// given.\n\t\t\t//\n\t\t\t// The other approach is \"unmanaged\": to call useSignals directly without\n\t\t\t// wrapping in a try/finally. This approach is easier to manually write in\n\t\t\t// situations where a build step isn't available but does open up the\n\t\t\t// possibility of catching signals accessed in other code before the\n\t\t\t// effect is closed (e.g. in a layout effect). Most situations where this\n\t\t\t// could happen are generally consider bad patterns or bugs. For example,\n\t\t\t// using a signal in a component and not having a call to `useSignals`\n\t\t\t// would be an bug. Or using a signal in `useLayoutEffect` is generally\n\t\t\t// not recommended since that layout effect won't update when the signals'\n\t\t\t// value change.\n\t\t\t//\n\t\t\t// To support both approaches, we need to track how each invocation of\n\t\t\t// useSignals is used, so we can properly transition between different\n\t\t\t// kinds of usages.\n\t\t\t//\n\t\t\t// The following table shows the different scenarios and how we should\n\t\t\t// handle them.\n\t\t\t//\n\t\t\t// Key:\n\t\t\t// 0 = UNMANAGED\n\t\t\t// 1 = MANAGED_COMPONENT\n\t\t\t// 2 = MANAGED_HOOK\n\t\t\t//\n\t\t\t// Pattern:\n\t\t\t// prev store usage -> this store usage: action to take\n\t\t\t//\n\t\t\t// - 0 -> 0: finish previous effect (unknown to unknown)\n\t\t\t//\n\t\t\t// We don't know how the previous effect was used, so we need to finish\n\t\t\t// it before starting the next effect.\n\t\t\t//\n\t\t\t// - 0 -> 1: finish previous effect\n\t\t\t//\n\t\t\t// Assume previous invocation was another component or hook from another\n\t\t\t// component. Nested component renders (renderToStaticMarkup within a\n\t\t\t// component's render) won't be supported with bare useSignals calls.\n\t\t\t//\n\t\t\t// - 0 -> 2: capture & restore\n\t\t\t//\n\t\t\t// Previous invocation could be a component or a hook. Either way,\n\t\t\t// restore it after our invocation so that it can continue to capture\n\t\t\t// any signals after we exit.\n\t\t\t//\n\t\t\t// - 1 -> 0: Do nothing. Signals already captured by current effect store\n\t\t\t// - 1 -> 1: capture & restore (e.g. component calls renderToStaticMarkup)\n\t\t\t// - 1 -> 2: capture & restore (e.g. hook)\n\t\t\t//\n\t\t\t// - 2 -> 0: Do nothing. Signals already captured by current effect store\n\t\t\t// - 2 -> 1: capture & restore (e.g. hook calls renderToStaticMarkup)\n\t\t\t// - 2 -> 2: capture & restore (e.g. nested hook calls)\n\n\t\t\tif (currentStore == undefined) {\n\t\t\t\tendEffect = startComponentEffect(undefined, this);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst prevUsage = currentStore._usage;\n\t\t\tconst thisUsage = this._usage;\n\n\t\t\tif (\n\t\t\t\t(prevUsage == UNMANAGED && thisUsage == UNMANAGED) || // 0 -> 0\n\t\t\t\t(prevUsage == UNMANAGED && thisUsage == MANAGED_COMPONENT) // 0 -> 1\n\t\t\t) {\n\t\t\t\t// finish previous effect\n\t\t\t\tcurrentStore.f();\n\t\t\t\tendEffect = startComponentEffect(undefined, this);\n\t\t\t} else if (\n\t\t\t\t(prevUsage == MANAGED_COMPONENT && thisUsage == UNMANAGED) || // 1 -> 0\n\t\t\t\t(prevUsage == MANAGED_HOOK && thisUsage == UNMANAGED) // 2 -> 0\n\t\t\t) {\n\t\t\t\t// Do nothing since it'll be captured by current effect store\n\t\t\t} else {\n\t\t\t\t// nested scenarios, so capture and restore the previous effect store\n\t\t\t\tendEffect = startComponentEffect(currentStore, this);\n\t\t\t}\n\t\t},\n\t\tf() {\n\t\t\tconst end = endEffect;\n\t\t\tendEffect = undefined;\n\t\t\tend?.();\n\t\t},\n\t\t[symDispose]() {\n\t\t\tthis.f();\n\t\t},\n\t};\n}\n\nfunction createEmptyEffectStore(): EffectStore {\n\treturn {\n\t\t_usage: UNMANAGED,\n\t\teffect: {\n\t\t\t_sources: undefined,\n\t\t\t_callback() {},\n\t\t\t_start() {\n\t\t\t\treturn noop;\n\t\t\t},\n\t\t\t_dispose() {},\n\t\t},\n\t\tsubscribe() {\n\t\t\treturn noop;\n\t\t},\n\t\tgetSnapshot() {\n\t\t\treturn 0;\n\t\t},\n\t\t_start() {},\n\t\tf() {},\n\t\t[symDispose]() {},\n\t};\n}\n\nconst emptyEffectStore = createEmptyEffectStore();\n\nconst _queueMicroTask = Promise.prototype.then.bind(Promise.resolve());\n\nlet finalCleanup: Promise | undefined;\nexport function ensureFinalCleanup() {\n\tif (!finalCleanup) {\n\t\tfinalCleanup = _queueMicroTask(cleanupTrailingStore);\n\t}\n}\nfunction cleanupTrailingStore() {\n\tfinalCleanup = undefined;\n\tcurrentStore?.f();\n}\n\nconst useIsomorphicLayoutEffect =\n\ttypeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n\n/**\n * Custom hook to create the effect to track signals used during render and\n * subscribe to changes to rerender the component when the signals change.\n */\nexport function _useSignalsImplementation(\n\t_usage: EffectStoreUsage = UNMANAGED\n): EffectStore {\n\tensureFinalCleanup();\n\n\tconst storeRef = useRef();\n\tif (storeRef.current == null) {\n\t\tstoreRef.current = createEffectStore(_usage);\n\t}\n\n\tconst store = storeRef.current;\n\tuseSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot);\n\tstore._start();\n\t// note: _usage is a constant here, so conditional is okay\n\tif (_usage === UNMANAGED) useIsomorphicLayoutEffect(cleanupTrailingStore);\n\n\treturn store;\n}\n\n/**\n * A wrapper component that renders a Signal's value directly as a Text node or JSX.\n */\nfunction SignalValue({ data }: { data: Signal }) {\n\tconst store = _useSignalsImplementation(1);\n\ttry {\n\t\treturn data.value;\n\t} finally {\n\t\tstore.f();\n\t}\n}\n\n// Decorate Signals so React renders them as components.\nObject.defineProperties(Signal.prototype, {\n\t$$typeof: { configurable: true, value: ReactElemType },\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\tref: { configurable: true, value: null },\n});\n\nexport function useSignals(usage?: EffectStoreUsage): EffectStore {\n\tif (isAutoSignalTrackingInstalled) return emptyEffectStore;\n\treturn _useSignalsImplementation(usage);\n}\n\nexport function useSignal(value: T): Signal;\nexport function useSignal(): Signal;\nexport function useSignal(value?: T) {\n\treturn useMemo(() => signal(value), Empty);\n}\n\nexport function useComputed(compute: () => T): ReadonlySignal {\n\tconst $compute = useRef(compute);\n\t$compute.current = compute;\n\treturn useMemo(() => computed(() => $compute.current()), Empty);\n}\n\nexport function useSignalEffect(cb: () => void | (() => void)) {\n\tconst callback = useRef(cb);\n\tcallback.current = cb;\n\n\tuseEffect(() => {\n\t\treturn effect(function (this: Effect) {\n\t\t\treturn callback.current();\n\t\t});\n\t}, Empty);\n}\n"],"names":["Signal","signal","computed","effect","React","version","__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED","useRef","useMemo","useEffect","useLayoutEffect","useSyncExternalStore","jsxRuntime","jsxRuntimeDev","isAutoSignalTrackingInstalled","store","lock","currentDispatcher","dispatcherTypeCache","Map","getDispatcherType","dispatcher","cached","get","undefined","type","useCallbackImpl","useCallback","toString","useReducer","useImperativeHandle","test","useReducerImpl","set","installAutoSignalTracking","major","reactVersion","split","map","Number","Error","Object","defineProperty","ReactInternals","ReactCurrentDispatcher","nextDispatcher","currentDispatcherType","nextDispatcherType","MountDispatcherType","isEnteringComponentRender","_useSignalsImplementation","isRestartingComponentRender","Boolean","_store","f","isExitingComponentRender","_store2","installCurrentDispatcherHook","JsxPro","JsxDev","createElement","wrapJsx","jsx","jsxs","jsxDEV","installJSXHooks","Empty","ReactElemType","Symbol","for","noop","props","rest","i","v","value","call","symDispose","dispose","currentStore","startComponentEffect","prevStore","nextStore","endEffect","_start","finishComponentEffect","bind","emptyEffectStore","_usage","_sources","_callback","_dispose","subscribe","getSnapshot","_queueMicroTask","Promise","prototype","then","resolve","finalCleanup","ensureFinalCleanup","cleanupTrailingStore","_currentStore","useIsomorphicLayoutEffect","window","storeRef","current","effectInstance","onChangeNotifyReact","unsubscribe","this","onStoreChange","prevUsage","thisUsage","end","createEffectStore","defineProperties","$$typeof","configurable","data","ref","useSignals","usage","useSignal","useComputed","compute","$compute","useSignalEffect","cb","callback"],"mappings":"iBAqJWA,YAAAC,cAAAC,YAAAC,MAAA,8BAAAC,cAAAC,wDAAAC,YAAAC,aAAAC,eAAAC,qBAAAC,MAAA,uCAAAC,MAAA,+CAAAC,MAAA,2BAAAC,MAAA,wBAAA,IAAAC,GAAgC,EAEvCC,EAA4B,KAC5BC,GAAO,EACPC,EAA4C,KA6ChD,MASMC,EAAsB,IAAIC,IAChC,SAASC,EAAk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,EAASvB,QAAUsB,EAEnBvH,EAAU,IACFN,EAAO,WACb,OAAO8H,EAASvB,SACjB,GACExC,EACJ,QAAAhB,+BAAAkD,wBAAAlE,+BAAA0F,YAAAD,UAAAI,gBAAAN,gBAAA5D"} +\ No newline at end of file ++{"version":3,"file":"runtime.mjs","sources":["../src/index.ts"],"sourcesContent":["import {\n\tsignal,\n\tcomputed,\n\teffect,\n\tSignal,\n\tReadonlySignal,\n} from \"@preact/signals-core\";\nimport {\n\tuseRef,\n\tuseMemo,\n\tuseEffect,\n\tuseLayoutEffect,\n\tversion as reactVersion,\n} from \"react\";\nimport { useSyncExternalStore } from \"use-sync-external-store/shim/index.js\";\n\nconst [major] = reactVersion.split(\".\").map(Number);\nconst Empty = [] as const;\n// V19 https://github.com/facebook/react/blob/346c7d4c43a0717302d446da9e7423a8e28d8996/packages/shared/ReactSymbols.js#L15\n// V18 https://github.com/facebook/react/blob/346c7d4c43a0717302d446da9e7423a8e28d8996/packages/shared/ReactSymbols.js#L15\nconst ReactElemType = Symbol.for(\n\tmajor >= 19 ? \"react.transitional.element\" : \"react.element\"\n);\n\nexport function wrapJsx(jsx: T): T {\n\tif (typeof jsx !== \"function\") return jsx;\n\n\treturn function (type: any, props: any, ...rest: any[]) {\n\t\tif (typeof type === \"string\" && props) {\n\t\t\tfor (let i in props) {\n\t\t\t\tlet v = props[i];\n\t\t\t\tif (i !== \"children\" && v instanceof Signal) {\n\t\t\t\t\tprops[i] = v.value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn jsx.call(jsx, type, props, ...rest);\n\t} as any as T;\n}\n\nconst symDispose: unique symbol =\n\t(Symbol as any).dispose || Symbol.for(\"Symbol.dispose\");\n\ninterface Effect {\n\t_sources: object | undefined;\n\t_start(): () => void;\n\t_callback(): void;\n\t_dispose(): void;\n}\n\n/**\n * Use this flag to represent a bare `useSignals` call that doesn't manually\n * close its effect store and relies on auto-closing when the next useSignals is\n * called or after a microtask\n */\nconst UNMANAGED = 0;\n/**\n * Use this flag to represent a `useSignals` call that is manually closed by a\n * try/finally block in a component's render method. This is the default usage\n * that the react-transform plugin uses.\n */\nconst MANAGED_COMPONENT = 1;\n/**\n * Use this flag to represent a `useSignals` call that is manually closed by a\n * try/finally block in a hook body. This is the default usage that the\n * react-transform plugin uses.\n */\nconst MANAGED_HOOK = 2;\n\n/**\n * An enum defining how this store is used. See the documentation for each enum\n * member for more details.\n * @see {@link UNMANAGED}\n * @see {@link MANAGED_COMPONENT}\n * @see {@link MANAGED_HOOK}\n */\ntype EffectStoreUsage =\n\t| typeof UNMANAGED\n\t| typeof MANAGED_COMPONENT\n\t| typeof MANAGED_HOOK;\n\nexport interface EffectStore {\n\t/**\n\t * An enum defining how this hook is used and whether it is invoked in a\n\t * component's body or hook body. See the comment on `EffectStoreUsage` for\n\t * more details.\n\t */\n\treadonly _usage: EffectStoreUsage;\n\treadonly effect: Effect;\n\tsubscribe(onStoreChange: () => void): () => void;\n\tgetSnapshot(): number;\n\t/** startEffect - begin tracking signals used in this component */\n\t_start(): void;\n\t/** finishEffect - stop tracking the signals used in this component */\n\tf(): void;\n\t[symDispose](): void;\n}\n\nlet currentStore: EffectStore | undefined;\n\nfunction startComponentEffect(\n\tprevStore: EffectStore | undefined,\n\tnextStore: EffectStore\n) {\n\tconst endEffect = nextStore.effect._start();\n\tcurrentStore = nextStore;\n\n\treturn finishComponentEffect.bind(nextStore, prevStore, endEffect);\n}\n\nfunction finishComponentEffect(\n\tthis: EffectStore,\n\tprevStore: EffectStore | undefined,\n\tendEffect: () => void\n) {\n\tendEffect();\n\tcurrentStore = prevStore;\n}\n\n/**\n * A redux-like store whose store value is a positive 32bit integer (a\n * 'version').\n *\n * React subscribes to this store and gets a snapshot of the current 'version',\n * whenever the 'version' changes, we tell React it's time to update the\n * component (call 'onStoreChange').\n *\n * How we achieve this is by creating a binding with an 'effect', when the\n * `effect._callback' is called, we update our store version and tell React to\n * re-render the component ([1] We don't really care when/how React does it).\n *\n * [1]\n * @see https://react.dev/reference/react/useSyncExternalStore\n * @see\n * https://github.com/reactjs/rfcs/blob/main/text/0214-use-sync-external-store.md\n *\n * @param _usage An enum defining how this hook is used and whether it is\n * invoked in a component's body or hook body. See the comment on\n * `EffectStoreUsage` for more details.\n */\nfunction createEffectStore(_usage: EffectStoreUsage): EffectStore {\n\tlet effectInstance!: Effect;\n\tlet endEffect: (() => void) | undefined;\n\tlet version = 0;\n\tlet onChangeNotifyReact: (() => void) | undefined;\n\n\tlet unsubscribe = effect(function (this: Effect) {\n\t\teffectInstance = this;\n\t});\n\teffectInstance._callback = function () {\n\t\tversion = (version + 1) | 0;\n\t\tif (onChangeNotifyReact) onChangeNotifyReact();\n\t};\n\n\treturn {\n\t\t_usage,\n\t\teffect: effectInstance,\n\t\tsubscribe(onStoreChange) {\n\t\t\tonChangeNotifyReact = onStoreChange;\n\n\t\t\treturn function () {\n\t\t\t\t/**\n\t\t\t\t * Rotate to next version when unsubscribing to ensure that components are re-run\n\t\t\t\t * when subscribing again.\n\t\t\t\t *\n\t\t\t\t * In StrictMode, 'memo'-ed components seem to keep a stale snapshot version, so\n\t\t\t\t * don't re-run after subscribing again if the version is the same as last time.\n\t\t\t\t *\n\t\t\t\t * Because we unsubscribe from the effect, the version may not change. We simply\n\t\t\t\t * set a new initial version in case of stale snapshots here.\n\t\t\t\t */\n\t\t\t\tversion = (version + 1) | 0;\n\t\t\t\tonChangeNotifyReact = undefined;\n\t\t\t\tunsubscribe();\n\t\t\t};\n\t\t},\n\t\tgetSnapshot() {\n\t\t\treturn version;\n\t\t},\n\t\t_start() {\n\t\t\t// In general, we want to support two kinds of usages of useSignals:\n\t\t\t//\n\t\t\t// A) Managed: calling useSignals in a component or hook body wrapped in a\n\t\t\t// try/finally (like what the react-transform plugin does)\n\t\t\t//\n\t\t\t// B) Unmanaged: Calling useSignals directly without wrapping in a\n\t\t\t// try/finally\n\t\t\t//\n\t\t\t// For managed, we finish the effect in the finally block of the component\n\t\t\t// or hook body. For unmanaged, we finish the effect in the next\n\t\t\t// useSignals call or after a microtask.\n\t\t\t//\n\t\t\t// There are different tradeoffs which each approach. With managed, using\n\t\t\t// a try/finally ensures that only signals used in the component or hook\n\t\t\t// body are tracked. However, signals accessed in render props are missed\n\t\t\t// because the render prop is invoked in another component that may or may\n\t\t\t// not realize it is rendering signals accessed in the render prop it is\n\t\t\t// given.\n\t\t\t//\n\t\t\t// The other approach is \"unmanaged\": to call useSignals directly without\n\t\t\t// wrapping in a try/finally. This approach is easier to manually write in\n\t\t\t// situations where a build step isn't available but does open up the\n\t\t\t// possibility of catching signals accessed in other code before the\n\t\t\t// effect is closed (e.g. in a layout effect). Most situations where this\n\t\t\t// could happen are generally consider bad patterns or bugs. For example,\n\t\t\t// using a signal in a component and not having a call to `useSignals`\n\t\t\t// would be an bug. Or using a signal in `useLayoutEffect` is generally\n\t\t\t// not recommended since that layout effect won't update when the signals'\n\t\t\t// value change.\n\t\t\t//\n\t\t\t// To support both approaches, we need to track how each invocation of\n\t\t\t// useSignals is used, so we can properly transition between different\n\t\t\t// kinds of usages.\n\t\t\t//\n\t\t\t// The following table shows the different scenarios and how we should\n\t\t\t// handle them.\n\t\t\t//\n\t\t\t// Key:\n\t\t\t// 0 = UNMANAGED\n\t\t\t// 1 = MANAGED_COMPONENT\n\t\t\t// 2 = MANAGED_HOOK\n\t\t\t//\n\t\t\t// Pattern:\n\t\t\t// prev store usage -> this store usage: action to take\n\t\t\t//\n\t\t\t// - 0 -> 0: finish previous effect (unknown to unknown)\n\t\t\t//\n\t\t\t// We don't know how the previous effect was used, so we need to finish\n\t\t\t// it before starting the next effect.\n\t\t\t//\n\t\t\t// - 0 -> 1: finish previous effect\n\t\t\t//\n\t\t\t// Assume previous invocation was another component or hook from another\n\t\t\t// component. Nested component renders (renderToStaticMarkup within a\n\t\t\t// component's render) won't be supported with bare useSignals calls.\n\t\t\t//\n\t\t\t// - 0 -> 2: capture & restore\n\t\t\t//\n\t\t\t// Previous invocation could be a component or a hook. Either way,\n\t\t\t// restore it after our invocation so that it can continue to capture\n\t\t\t// any signals after we exit.\n\t\t\t//\n\t\t\t// - 1 -> 0: Do nothing. Signals already captured by current effect store\n\t\t\t// - 1 -> 1: capture & restore (e.g. component calls renderToStaticMarkup)\n\t\t\t// - 1 -> 2: capture & restore (e.g. hook)\n\t\t\t//\n\t\t\t// - 2 -> 0: Do nothing. Signals already captured by current effect store\n\t\t\t// - 2 -> 1: capture & restore (e.g. hook calls renderToStaticMarkup)\n\t\t\t// - 2 -> 2: capture & restore (e.g. nested hook calls)\n\n\t\t\tif (currentStore == undefined) {\n\t\t\t\tendEffect = startComponentEffect(undefined, this);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst prevUsage = currentStore._usage;\n\t\t\tconst thisUsage = this._usage;\n\n\t\t\tif (\n\t\t\t\t(prevUsage == UNMANAGED && thisUsage == UNMANAGED) || // 0 -> 0\n\t\t\t\t(prevUsage == UNMANAGED && thisUsage == MANAGED_COMPONENT) // 0 -> 1\n\t\t\t) {\n\t\t\t\t// finish previous effect\n\t\t\t\tcurrentStore.f();\n\t\t\t\tendEffect = startComponentEffect(undefined, this);\n\t\t\t} else if (\n\t\t\t\t(prevUsage == MANAGED_COMPONENT && thisUsage == UNMANAGED) || // 1 -> 0\n\t\t\t\t(prevUsage == MANAGED_HOOK && thisUsage == UNMANAGED) // 2 -> 0\n\t\t\t) {\n\t\t\t\t// Do nothing since it'll be captured by current effect store\n\t\t\t} else {\n\t\t\t\t// nested scenarios, so capture and restore the previous effect store\n\t\t\t\tendEffect = startComponentEffect(currentStore, this);\n\t\t\t}\n\t\t},\n\t\tf() {\n\t\t\tconst end = endEffect;\n\t\t\tendEffect = undefined;\n\t\t\tend?.();\n\t\t},\n\t\t[symDispose]() {\n\t\t\tthis.f();\n\t\t},\n\t};\n}\n\nconst _queueMicroTask = Promise.prototype.then.bind(Promise.resolve());\n\nlet finalCleanup: Promise | undefined;\nexport function ensureFinalCleanup() {\n\tif (!finalCleanup) {\n\t\tfinalCleanup = _queueMicroTask(cleanupTrailingStore);\n\t}\n}\nfunction cleanupTrailingStore() {\n\tfinalCleanup = undefined;\n\tcurrentStore?.f();\n}\n\nconst useIsomorphicLayoutEffect =\n\ttypeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n\n/**\n * Custom hook to create the effect to track signals used during render and\n * subscribe to changes to rerender the component when the signals change.\n */\nexport function _useSignalsImplementation(\n\t_usage: EffectStoreUsage = UNMANAGED\n): EffectStore {\n\tensureFinalCleanup();\n\n\tconst storeRef = useRef();\n\tif (storeRef.current == null) {\n\t\tstoreRef.current = createEffectStore(_usage);\n\t}\n\n\tconst store = storeRef.current;\n\tuseSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot);\n\tstore._start();\n\t// note: _usage is a constant here, so conditional is okay\n\tif (_usage === UNMANAGED) useIsomorphicLayoutEffect(cleanupTrailingStore);\n\n\treturn store;\n}\n\n/**\n * A wrapper component that renders a Signal's value directly as a Text node or JSX.\n */\nfunction SignalValue({ data }: { data: Signal }) {\n\tconst store = _useSignalsImplementation(1);\n\ttry {\n\t\treturn data.value;\n\t} finally {\n\t\tstore.f();\n\t}\n}\n\n// Decorate Signals so React renders them as components.\nObject.defineProperties(Signal.prototype, {\n\t$$typeof: { configurable: true, value: ReactElemType },\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\tref: { configurable: true, value: null },\n});\n\nexport function useSignals(usage?: EffectStoreUsage): EffectStore {\n\treturn _useSignalsImplementation(usage);\n}\n\nexport function useSignal(value: T): Signal;\nexport function useSignal(): Signal;\nexport function useSignal(value?: T) {\n\treturn useMemo(() => signal(value), Empty);\n}\n\nexport function useComputed(compute: () => T): ReadonlySignal {\n\tconst $compute = useRef(compute);\n\t$compute.current = compute;\n\treturn useMemo(() => computed(() => $compute.current()), Empty);\n}\n\nexport function useSignalEffect(cb: () => void | (() => void)) {\n\tconst callback = useRef(cb);\n\tcallback.current = cb;\n\n\tuseEffect(() => {\n\t\treturn effect(function (this: Effect) {\n\t\t\treturn callback.current();\n\t\t});\n\t}, Empty);\n}\n"],"names":["major","reactVersion","split","map","Number","Empty","ReactElemType","Symbol","for","wrapJsx","jsx","type","props","rest","i","v","Signal","value","call","symDispose","dispose","currentStore","startComponentEffect","prevStore","nextStore","endEffect","effect","_start","finishComponentEffect","bind","_queueMicroTask","Promise","prototype","then","resolve","finalCleanup","ensureFinalCleanup","cleanupTrailingStore","_currentStore","undefined","f","useIsomorphicLayoutEffect","window","useLayoutEffect","useEffect","_useSignalsImplementation","_usage","storeRef","useRef","current","effectInstance","onChangeNotifyReact","version","unsubscribe","this","_callback","subscribe","onStoreChange","getSnapshot","prevUsage","thisUsage","end","createEffectStore","store","useSyncExternalStore","Object","defineProperties","$$typeof","configurable","data","get","ref","useSignals","usage","useSignal","useMemo","signal","useComputed","compute","$compute","computed","useSignalEffect","cb","callback"],"mappings":"8PAgBA,MAAOA,GAASC,EAAaC,MAAM,KAAKC,IAAIC,QACtCC,EAAQ,GAGRC,EAAgBC,OAAOC,IAC5BR,GAAS,GAAK,6BAA+B,iBAG9B,SAAAS,EAAWC,GAC1B,GAAmB,mBAARA,EAAoB,OAAOA,OAEtC,OAAiBC,SAAAA,EAAWC,KAAeC,GAC1C,GAAoB,iBAATF,GAAqBC,EAC/B,IAAK,IAAIE,KAAKF,EAAO,CACpB,IAAIG,EAAIH,EAAME,GACd,GAAU,aAANA,GAAoBC,aAAaC,EACpCJ,EAAME,GAAKC,EAAEE,KAEd,CAGF,OAAOP,EAAIQ,KAAKR,EAAKC,EAAMC,KAAUC,EACtC,CACD,CAEA,MAAMM,EACJZ,OAAea,SAAWb,OAAOC,IAAI,kBAyDvC,IAAIa,EAEJ,SAASC,EACRC,EACAC,GAEA,MAAMC,EAAYD,EAAUE,OAAOC,IACnCN,EAAeG,EAEf,OAAOI,EAAsBC,KAAKL,EAAWD,EAAWE,EACzD,CAEA,SA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AAQhB,EAASE,QACvBe,EAAqBD,EAAMP,UAAWO,EAAML,YAAaK,EAAML,aAC/DK,EAAMpC,IAEN,GAzQiB,IAyQbmB,EAAsBL,EAA0BJ,GAEpD,OAAO0B,CACR,CAeAE,OAAOC,iBAAiBlD,EAAOgB,UAAW,CACzCmC,SAAU,CAAEC,cAAc,EAAMnD,MAAOX,GACvCK,KAAM,CAAEyD,cAAc,EAAMnD,MAZ7B,UAAqBoD,KAAEA,IACtB,MAAMN,EAAQlB,EAA0B,GACxC,IACC,OAAOwB,EAAKpD,KAGZ,CAFA,QACA8C,EAAMvB,GACN,CACF,GAMC5B,MAAO,CACNwD,cAAc,EACdE,MACC,MAAO,CAAED,KAAMf,KAChB,GAEDiB,IAAK,CAAEH,cAAc,EAAMnD,MAAO,QAGnB,SAAAuD,EAAWC,GAC1B,OAAO5B,EAA0B4B,EAClC,CAIM,SAAUC,UAAazD,GAC5B,OAAO0D,EAAQ,IAAMC,EAAsB3D,GAAQZ,EACpD,CAEM,SAAUwE,YAAeC,GAC9B,MAAMC,EAAW/B,EAAO8B,GACxBC,EAAS9B,QAAU6B,EACnB,OAAOH,EAAQ,IAAMK,EAAY,IAAMD,EAAS9B,WAAY5C,EAC7D,CAEgB,SAAA4E,gBAAgBC,GAC/B,MAAMC,EAAWnC,EAAOkC,GACxBC,EAASlC,QAAUiC,EAEnBtC,EAAU,IACFlB,EAAO,WACb,OAAOyD,EAASlC,SACjB,GACE5C,EACJ,QAAAwC,+BAAAT,wBAAAyC,YAAAH,UAAAO,gBAAAT,gBAAA/D"} +\ No newline at end of file +diff --git a/node_modules/@preact/signals-react/runtime/dist/runtime.module.js b/node_modules/@preact/signals-react/runtime/dist/runtime.module.js +index 2ef30c0..90b972c 100644 +--- a/node_modules/@preact/signals-react/runtime/dist/runtime.module.js ++++ b/node_modules/@preact/signals-react/runtime/dist/runtime.module.js +@@ -1 +1 @@ +-import{Signal as n,signal as r,computed as t,effect as e}from"@preact/signals-core";import i,{version as u,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED as o,useRef as f,useMemo as c,useEffect as a,useLayoutEffect as s}from"react";import{useSyncExternalStore as l}from"use-sync-external-store/shim/index.js";import v from"react/jsx-runtime";import m from"react/jsx-dev-runtime";var p=!1,d=null,b=!1,g=null,h=new Map;function y(n){if(!n)return 1;var r,t=h.get(n);if(void 0!==t)return t;var e=n.useCallback.toString();if(n.useReducer===n.useEffect)r=1;else if(n.useEffect===n.useImperativeHandle)r=32;else if(/Invalid/.test(e))r=2;else if(/updateCallback/.test(e)||/\[0\]/.test(e)&&/\[1\]/.test(e)){var i=n.useReducer.toString();if(/rerenderReducer/.test(i)||/return\s*\[\w+,/.test(i))r=16;else r=8}else r=4;h.set(n,r);return r}function _(){if(u.split(".").map(Number)[0]>=19)throw new Error("Automatic signals tracking is not supported in React 19 and later, try the Babel plugin instead https://github.com/preactjs/signals/tree/main/packages/react-transform#signals-react-transform.");!function(){p=!0;Object.defineProperty(o.ReactCurrentDispatcher,"current",{get:function(){return g},set:function(n){if(!b){var r=y(g),t=y(n);g=n;if(function(n,r){if(1&n&&28&r)return!0;else if(2&n||2&r)return!1;else return!1}(r,t)){b=!0;d=q(1);b=!1}else if(function(n,r){return Boolean(28&n&&16&r)}(r,t)){var e;null==(e=d)||e.f();b=!0;d=q(1);b=!1}else if(function(n,r){return Boolean(28&n&&1&r)}(r,t)){var i;null==(i=d)||i.f();d=null}}else g=n}})}();!function(){var n=v,r=m;i.createElement=k(i.createElement);r.jsx&&(r.jsx=k(r.jsx));n.jsx&&(n.jsx=k(n.jsx));r.jsxs&&(r.jsxs=k(r.jsxs));n.jsxs&&(n.jsxs=k(n.jsxs));r.jsxDEV&&(r.jsxDEV=k(r.jsxDEV));n.jsxDEV&&(n.jsxDEV=k(n.jsxDEV))}()}var j=u.split(".").map(Number),w=[],S=Symbol.for(j[0]>=19?"react.transitional.element":"react.element"),x=function(){};function k(r){if("function"!=typeof r)return r;else return function(t,e){if("string"==typeof t&&e)for(var i in e){var u=e[i];if("children"!==i&&u instanceof n)e[i]=u.value}return r.call.apply(r,[r,t,e].concat([].slice.call(arguments,2)))}}var B,N=Symbol.dispose||Symbol.for("Symbol.dispose");function O(n,r){var t=r.effect.S();B=r;return P.bind(r,n,t)}function P(n,r){r();B=n}var R,$,A=((R={u:0,effect:{s:void 0,c:function(){},S:function(){return x},d:function(){}},subscribe:function(){return x},getSnapshot:function(){return 0},S:function(){},f:function(){}})[N]=function(){},R),C=Promise.prototype.then.bind(Promise.resolve());function E(){if(!$)$=C(I)}function I(){var n;$=void 0;null==(n=B)||n.f()}var M="undefined"!=typeof window?s:a;function q(n){if(void 0===n)n=0;E();var r=f();if(null==r.current)r.current=function(n){var r,t,i,u,o=0,f=e(function(){t=this});t.c=function(){o=o+1|0;if(u)u()};return(r={u:n,effect:t,subscribe:function(n){u=n;return function(){o=o+1|0;u=void 0;f()}},getSnapshot:function(){return o},S:function(){if(null!=B){var n=B.u,r=this.u;if(0==n&&0==r||0==n&&1==r){B.f();i=O(void 0,this)}else if(1==n&&0==r||2==n&&0==r);else i=O(B,this)}else i=O(void 0,this)},f:function(){var n=i;i=void 0;null==n||n()}})[N]=function(){this.f()},r}(n);var t=r.current;l(t.subscribe,t.getSnapshot,t.getSnapshot);t.S();if(0===n)M(I);return t}Object.defineProperties(n.prototype,{$$typeof:{configurable:!0,value:S},type:{configurable:!0,value:function(n){var r=n.data,t=q(1);try{return r.value}finally{t.f()}}},props:{configurable:!0,get:function(){return{data:this}}},ref:{configurable:!0,value:null}});function z(n){if(p)return A;else return q(n)}function useSignal(n){return c(function(){return r(n)},w)}function useComputed(n){var r=f(n);r.current=n;return c(function(){return t(function(){return r.current()})},w)}function useSignalEffect(n){var r=f(n);r.current=n;a(function(){return e(function(){return r.current()})},w)}export{q as _useSignalsImplementation,E as ensureFinalCleanup,_ as installAutoSignalTracking,useComputed,useSignal,useSignalEffect,z as useSignals,k as wrapJsx};//# sourceMappingURL=runtime.module.js.map ++import{Signal as n,signal as t,computed as r,effect as i}from"@preact/signals-core";import{version as e,useRef as o,useMemo as u,useEffect as f,useLayoutEffect as c}from"react";import{useSyncExternalStore as a}from"use-sync-external-store/shim/index.js";var l=e.split(".").map(Number),s=[],v=Symbol.for(l[0]>=19?"react.transitional.element":"react.element");function m(t){if("function"!=typeof t)return t;else return function(r,i){if("string"==typeof r&&i)for(var e in i){var o=i[e];if("children"!==e&&o instanceof n)i[e]=o.value}return t.call.apply(t,[t,r,i].concat([].slice.call(arguments,2)))}}var p,d=Symbol.dispose||Symbol.for("Symbol.dispose");function b(n,t){var r=t.effect.S();p=t;return y.bind(t,n,r)}function y(n,t){t();p=n}var h,g=Promise.prototype.then.bind(Promise.resolve());function S(){if(!h)h=g(x)}function x(){var n;h=void 0;null==(n=p)||n.f()}var j="undefined"!=typeof window?c:f;function w(n){if(void 0===n)n=0;S();var t=o();if(null==t.current)t.current=function(n){var t,r,e,o,u=0,f=i(function(){r=this});r.c=function(){u=u+1|0;if(o)o()};return(t={o:n,effect:r,subscribe:function(n){o=n;return function(){u=u+1|0;o=void 0;f()}},getSnapshot:function(){return u},S:function(){if(null!=p){var n=p.o,t=this.o;if(0==n&&0==t||0==n&&1==t){p.f();e=b(void 0,this)}else if(1==n&&0==t||2==n&&0==t);else e=b(p,this)}else e=b(void 0,this)},f:function(){var n=e;e=void 0;null==n||n()}})[d]=function(){this.f()},t}(n);var r=t.current;a(r.subscribe,r.getSnapshot,r.getSnapshot);r.S();if(0===n)j(x);return r}Object.defineProperties(n.prototype,{$$typeof:{configurable:!0,value:v},type:{configurable:!0,value:function(n){var t=n.data,r=w(1);try{return t.value}finally{r.f()}}},props:{configurable:!0,get:function(){return{data:this}}},ref:{configurable:!0,value:null}});function P(n){return w(n)}function useSignal(n){return u(function(){return t(n)},s)}function useComputed(n){var t=o(n);t.current=n;return u(function(){return r(function(){return t.current()})},s)}function useSignalEffect(n){var t=o(n);t.current=n;f(function(){return i(function(){return t.current()})},s)}export{w as _useSignalsImplementation,S as ensureFinalCleanup,useComputed,useSignal,useSignalEffect,P as useSignals,m as wrapJsx};//# sourceMappingURL=runtime.module.js.map +diff --git a/node_modules/@preact/signals-react/runtime/dist/runtime.module.js.map b/node_modules/@preact/signals-react/runtime/dist/runtime.module.js.map +index 4fe5294..d18d4c2 100644 +--- a/node_modules/@preact/signals-react/runtime/dist/runtime.module.js.map ++++ b/node_modules/@preact/signals-react/runtime/dist/runtime.module.js.map +@@ -1 +1 @@ +-{"version":3,"file":"runtime.module.js","sources":["../src/auto.ts","../src/index.ts"],"sourcesContent":["import {\n\t// @ts-ignore-next-line\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED as ReactInternals,\n\tversion as reactVersion,\n} from \"react\";\nimport React from \"react\";\nimport jsxRuntime from \"react/jsx-runtime\";\nimport jsxRuntimeDev from \"react/jsx-dev-runtime\";\nimport { EffectStore, wrapJsx, _useSignalsImplementation } from \"./index\";\n\nexport interface ReactDispatcher {\n\tuseRef: typeof React.useRef;\n\tuseCallback: typeof React.useCallback;\n\tuseReducer: typeof React.useReducer;\n\tuseSyncExternalStore: typeof React.useSyncExternalStore;\n\tuseEffect: typeof React.useEffect;\n\tuseImperativeHandle: typeof React.useImperativeHandle;\n}\n\n// In order for signals to work in React, we need to observe what signals a\n// component uses while rendering. To do this, we need to know when a component\n// is rendering. To do this, we watch the transition of the\n// ReactCurrentDispatcher to know when a component is rerendering.\n//\n// To track when we are entering and exiting a component render (i.e. before and\n// after React renders a component), we track how the dispatcher changes.\n// Outside of a component rendering, the dispatcher is set to an instance that\n// errors or warns when any hooks are called. This behavior is prevents hooks\n// from being used outside of components. Right before React renders a\n// component, the dispatcher is set to an instance that doesn't warn or error\n// and contains the implementations of all hooks. Right after React finishes\n// rendering a component, the dispatcher is set to the erroring one again. This\n// erroring dispatcher is called the `ContextOnlyDispatcher` in React's source.\n//\n// So, we watch the getter and setter on `ReactCurrentDispatcher.current` to\n// monitor the changes to the current ReactDispatcher. When the dispatcher\n// changes from the ContextOnlyDispatcher to a \"valid\" dispatcher, we assume we\n// are entering a component render. At this point, we setup our\n// auto-subscriptions for any signals used in the component. We do this by\n// creating an Signal effect and manually starting the Signal effect. We use\n// `useSyncExternalStore` to trigger rerenders on the component when any signals\n// it uses changes.\n//\n// When the dispatcher changes from a valid dispatcher back to the\n// ContextOnlyDispatcher, we assume we are exiting a component render. At this\n// point we stop the effect.\n//\n// Some additional complexities to be aware of:\n// - If a component calls `setState` while rendering, React will re-render the\n// component immediately. Before triggering the re-render, React will change\n// the dispatcher to the HooksDispatcherOnRerender. When we transition to this\n// rerendering adapter, we need to re-trigger our hooks to keep the order of\n// hooks the same for every render of a component.\n//\n// - In development, useReducer, useState, and useMemo change the dispatcher to\n// a different warning dispatcher (not ContextOnlyDispatcher) before invoking\n// the reducer and resets it right after.\n//\n// The useSyncExternalStore shim will use some of these hooks when we invoke\n// it while entering a component render. We need to prevent this dispatcher\n// change caused by these hooks from re-triggering our entering logic (it\n// would cause an infinite loop if we did not). We do this by using a lock to\n// prevent the setter from running while we are in the setter.\n//\n// When a Component's function body invokes useReducer, useState, or useMemo,\n// this change in dispatcher should not signal that we are entering or exiting\n// a component render. We ignore this change by detecting these dispatchers as\n// different from ContextOnlyDispatcher and other valid dispatchers.\n//\n// - The `use` hook will change the dispatcher to from a valid update dispatcher\n// to a valid mount dispatcher in some cases. Similarly to useReducer\n// mentioned above, we should not signal that we are exiting a component\n// during this change. Because these other valid dispatchers do not pass the\n// ContextOnlyDispatcher check, they do not affect our logic.\n//\n// - When server rendering, React does not change the dispatcher before and\n// after each component render. It sets it once for before the first render\n// and once for after the last render. This means that we will not be able to\n// detect when we are entering or exiting a component render. This is fine\n// because we don't need to detect this for server rendering. A component\n// can't trigger async rerenders in SSR so we don't need to track signals.\n//\n// If a component updates a signal value while rendering during SSR, we will\n// not rerender the component because the signal value will synchronously\n// change so all reads of the signal further down the tree will see the new\n// value.\n\n/*\nBelow is a state machine definition for transitions between the various\ndispatchers in React's prod build. (It does not include dev time warning\ndispatchers which are just always ignored).\n\nENTER and EXIT suffixes indicates whether this ReactCurrentDispatcher transition\nsignals we are entering or exiting a component render, or if it doesn't signal a\nchange in the component rendering lifecyle (NOOP).\n\n```js\n// Paste this into https://stately.ai/viz to visualize the state machine.\nimport { createMachine } from \"xstate\";\n\n// ENTER, EXIT, NOOP suffixes indicates whether this ReactCurrentDispatcher\n// transition signals we are entering or exiting a component render, or\n// if it doesn't signal a change in the component rendering lifecyle (NOOP).\n\nconst dispatcherMachinePROD = createMachine({\n\tid: \"ReactCurrentDispatcher_PROD\",\n\tinitial: \"null\",\n\tstates: {\n\t\tnull: {\n\t\t\ton: {\n\t\t\t\tpushDispatcher: \"ContextOnlyDispatcher\",\n\t\t\t},\n\t\t},\n\t\tContextOnlyDispatcher: {\n\t\t\ton: {\n\t\t\t\trenderWithHooks_Mount_ENTER: \"HooksDispatcherOnMount\",\n\t\t\t\trenderWithHooks_Update_ENTER: \"HooksDispatcherOnUpdate\",\n\t\t\t\tpushDispatcher_NOOP: \"ContextOnlyDispatcher\",\n\t\t\t\tpopDispatcher_NOOP: \"ContextOnlyDispatcher\",\n\t\t\t},\n\t\t},\n\t\tHooksDispatcherOnMount: {\n\t\t\ton: {\n\t\t\t\trenderWithHooksAgain_ENTER: \"HooksDispatcherOnRerender\",\n\t\t\t\tresetHooksAfterThrow_EXIT: \"ContextOnlyDispatcher\",\n\t\t\t\tfinishRenderingHooks_EXIT: \"ContextOnlyDispatcher\",\n\t\t\t},\n\t\t},\n\t\tHooksDispatcherOnUpdate: {\n\t\t\ton: {\n\t\t\t\trenderWithHooksAgain_ENTER: \"HooksDispatcherOnRerender\",\n\t\t\t\tresetHooksAfterThrow_EXIT: \"ContextOnlyDispatcher\",\n\t\t\t\tfinishRenderingHooks_EXIT: \"ContextOnlyDispatcher\",\n\t\t\t\tuse_ResumeSuspensedMount_NOOP: \"HooksDispatcherOnMount\",\n\t\t\t},\n\t\t},\n\t\tHooksDispatcherOnRerender: {\n\t\t\ton: {\n\t\t\t\trenderWithHooksAgain_ENTER: \"HooksDispatcherOnRerender\",\n\t\t\t\tresetHooksAfterThrow_EXIT: \"ContextOnlyDispatcher\",\n\t\t\t\tfinishRenderingHooks_EXIT: \"ContextOnlyDispatcher\",\n\t\t\t},\n\t\t},\n\t},\n});\n```\n*/\n\nexport let isAutoSignalTrackingInstalled = false;\n\nlet store: EffectStore | null = null;\nlet lock = false;\nlet currentDispatcher: ReactDispatcher | null = null;\n\nfunction installCurrentDispatcherHook() {\n\tisAutoSignalTrackingInstalled = true;\n\n\tObject.defineProperty(ReactInternals.ReactCurrentDispatcher, \"current\", {\n\t\tget() {\n\t\t\treturn currentDispatcher;\n\t\t},\n\t\tset(nextDispatcher: ReactDispatcher) {\n\t\t\tif (lock) {\n\t\t\t\tcurrentDispatcher = nextDispatcher;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst currentDispatcherType = getDispatcherType(currentDispatcher);\n\t\t\tconst nextDispatcherType = getDispatcherType(nextDispatcher);\n\n\t\t\t// Update the current dispatcher now so the hooks inside of the\n\t\t\t// useSyncExternalStore shim get the right dispatcher.\n\t\t\tcurrentDispatcher = nextDispatcher;\n\t\t\tif (\n\t\t\t\tisEnteringComponentRender(currentDispatcherType, nextDispatcherType)\n\t\t\t) {\n\t\t\t\tlock = true;\n\t\t\t\tstore = _useSignalsImplementation(1);\n\t\t\t\tlock = false;\n\t\t\t} else if (\n\t\t\t\tisRestartingComponentRender(currentDispatcherType, nextDispatcherType)\n\t\t\t) {\n\t\t\t\tstore?.f();\n\t\t\t\tlock = true;\n\t\t\t\tstore = _useSignalsImplementation(1);\n\t\t\t\tlock = false;\n\t\t\t} else if (\n\t\t\t\tisExitingComponentRender(currentDispatcherType, nextDispatcherType)\n\t\t\t) {\n\t\t\t\tstore?.f();\n\t\t\t\tstore = null;\n\t\t\t}\n\t\t},\n\t});\n}\n\ntype DispatcherType = number;\nconst ContextOnlyDispatcherType = 1 << 0;\nconst WarningDispatcherType = 1 << 1;\nconst MountDispatcherType = 1 << 2;\nconst UpdateDispatcherType = 1 << 3;\nconst RerenderDispatcherType = 1 << 4;\nconst ServerDispatcherType = 1 << 5;\nconst BrowserClientDispatcherType =\n\tMountDispatcherType | UpdateDispatcherType | RerenderDispatcherType;\n\nconst dispatcherTypeCache = new Map();\nfunction getDispatcherType(dispatcher: ReactDispatcher | null): DispatcherType {\n\t// Treat null the same as the ContextOnlyDispatcher.\n\tif (!dispatcher) return ContextOnlyDispatcherType;\n\n\tconst cached = dispatcherTypeCache.get(dispatcher);\n\tif (cached !== undefined) return cached;\n\n\t// The ContextOnlyDispatcher sets all the hook implementations to a function\n\t// that takes no arguments and throws and error. This dispatcher is the only\n\t// dispatcher where useReducer and useEffect will have the same\n\t// implementation.\n\tlet type: DispatcherType;\n\tconst useCallbackImpl = dispatcher.useCallback.toString();\n\tif (dispatcher.useReducer === dispatcher.useEffect) {\n\t\ttype = ContextOnlyDispatcherType;\n\n\t\t// @ts-expect-error When server rendering, useEffect and useImperativeHandle\n\t\t// are both set to noop functions and so have the same implementation.\n\t} else if (dispatcher.useEffect === dispatcher.useImperativeHandle) {\n\t\ttype = ServerDispatcherType;\n\t} else if (/Invalid/.test(useCallbackImpl)) {\n\t\t// We first check for warning dispatchers because they would also pass some\n\t\t// of the checks below.\n\t\ttype = WarningDispatcherType;\n\t} else if (\n\t\t// The development mount dispatcher invokes a function called\n\t\t// `mountCallback` whereas the development update/re-render dispatcher\n\t\t// invokes a function called `updateCallback`. Use that difference to\n\t\t// determine if we are in a mount or update-like dispatcher in development.\n\t\t// The production mount dispatcher defines an array of the form [callback,\n\t\t// deps] whereas update/re-render dispatchers read the array using array\n\t\t// indices (e.g. `[0]` and `[1]`). Use those differences to determine if we\n\t\t// are in a mount or update-like dispatcher in production.\n\t\t/updateCallback/.test(useCallbackImpl) ||\n\t\t(/\\[0\\]/.test(useCallbackImpl) && /\\[1\\]/.test(useCallbackImpl))\n\t) {\n\t\t// The update and rerender dispatchers have different implementations for\n\t\t// useReducer. We'll check it's implementation to determine if this is the\n\t\t// rerender or update dispatcher.\n\t\tlet useReducerImpl = dispatcher.useReducer.toString();\n\t\tif (\n\t\t\t// The development rerender dispatcher invokes a function called\n\t\t\t// `rerenderReducer` whereas the update dispatcher invokes a function\n\t\t\t// called `updateReducer`. The production rerender dispatcher returns an\n\t\t\t// array of the form `[state, dispatch]` whereas the update dispatcher\n\t\t\t// returns an array of `[fiber.memoizedState, dispatch]` so we check the\n\t\t\t// return statement in the implementation of useReducer to differentiate\n\t\t\t// between the two.\n\t\t\t/rerenderReducer/.test(useReducerImpl) ||\n\t\t\t/return\\s*\\[\\w+,/.test(useReducerImpl)\n\t\t) {\n\t\t\ttype = RerenderDispatcherType;\n\t\t} else {\n\t\t\ttype = UpdateDispatcherType;\n\t\t}\n\t} else {\n\t\ttype = MountDispatcherType;\n\t}\n\n\tdispatcherTypeCache.set(dispatcher, type);\n\treturn type;\n}\n\nfunction isEnteringComponentRender(\n\tcurrentDispatcherType: DispatcherType,\n\tnextDispatcherType: DispatcherType\n): boolean {\n\tif (\n\t\tcurrentDispatcherType & ContextOnlyDispatcherType &&\n\t\tnextDispatcherType & BrowserClientDispatcherType\n\t) {\n\t\t// ## Mount or update (ContextOnlyDispatcher -> ValidDispatcher (Mount or Update))\n\t\t//\n\t\t// If the current dispatcher is the ContextOnlyDispatcher and the next\n\t\t// dispatcher is a valid dispatcher, we are entering a component render.\n\t\treturn true;\n\t} else if (\n\t\tcurrentDispatcherType & WarningDispatcherType ||\n\t\tnextDispatcherType & WarningDispatcherType\n\t) {\n\t\t// ## Warning dispatcher\n\t\t//\n\t\t// If the current dispatcher or next dispatcher is an warning dispatcher,\n\t\t// we are not entering a component render. The current warning dispatchers\n\t\t// are used to warn when hooks are nested improperly and do not indicate\n\t\t// entering a new component render.\n\t\treturn false;\n\t} else {\n\t\t// ## Resuming suspended mount edge case (Update -> Mount)\n\t\t//\n\t\t// If we are transitioning from the update dispatcher to the mount\n\t\t// dispatcher, then this component is using the `use` hook and is resuming\n\t\t// from a mount. We should not re-invoke our hooks in this situation since\n\t\t// we are not entering a new component render, but instead continuing a\n\t\t// previous render.\n\t\t//\n\t\t// ## Other transitions\n\t\t//\n\t\t// For example, Mount -> Mount, Update -> Update, Mount -> Update, any\n\t\t// transition in and out of invalid dispatchers.\n\t\t//\n\t\t// There is no known transition for the following transitions so we default\n\t\t// to not triggering a re-enter of the component.\n\t\t// - HooksDispatcherOnMount -> HooksDispatcherOnMount\n\t\t// - HooksDispatcherOnMount -> HooksDispatcherOnUpdate\n\t\t// - HooksDispatcherOnUpdate -> HooksDispatcherOnUpdate\n\t\treturn false;\n\t}\n}\n\nfunction isRestartingComponentRender(\n\tcurrentDispatcherType: DispatcherType,\n\tnextDispatcherType: DispatcherType\n): boolean {\n\t// A transition from a valid browser dispatcher into the rerender dispatcher\n\t// is the restart of a component render, so we should end the current\n\t// component effect and re-invoke our hooks. Details below.\n\t//\n\t// ## In-place rerendering (e.g. Mount -> Rerender)\n\t//\n\t// If we are transitioning from the mount, update, or rerender dispatcher to\n\t// the rerender dispatcher (e.g. HooksDispatcherOnMount to\n\t// HooksDispatcherOnRerender), then this component is rerendering due to\n\t// calling setState inside of its function body. We are re-entering a\n\t// component's render method and so we should re-invoke our hooks.\n\n\treturn Boolean(\n\t\tcurrentDispatcherType & BrowserClientDispatcherType &&\n\t\t\tnextDispatcherType & RerenderDispatcherType\n\t);\n}\n\n/**\n * We are exiting a component render if the current dispatcher is a valid\n * dispatcher and the next dispatcher is the ContextOnlyDispatcher.\n */\nfunction isExitingComponentRender(\n\tcurrentDispatcherType: DispatcherType,\n\tnextDispatcherType: DispatcherType\n): boolean {\n\treturn Boolean(\n\t\tcurrentDispatcherType & BrowserClientDispatcherType &&\n\t\t\tnextDispatcherType & ContextOnlyDispatcherType\n\t);\n}\n\ninterface JsxRuntimeModule {\n\tjsx?(type: any, ...rest: any[]): unknown;\n\tjsxs?(type: any, ...rest: any[]): unknown;\n\tjsxDEV?(type: any, ...rest: any[]): unknown;\n}\n\nexport function installJSXHooks() {\n\tconst JsxPro: JsxRuntimeModule = jsxRuntime;\n\tconst JsxDev: JsxRuntimeModule = jsxRuntimeDev;\n\n\t/**\n\t * createElement _may_ be called by jsx runtime as a fallback in certain cases,\n\t * so we need to wrap it regardless.\n\t *\n\t * The jsx exports depend on the `NODE_ENV` var to ensure the users' bundler doesn't\n\t * include both, so one of them will be set with `undefined` values.\n\t */\n\tReact.createElement = wrapJsx(React.createElement);\n\tJsxDev.jsx && /* */ (JsxDev.jsx = wrapJsx(JsxDev.jsx));\n\tJsxPro.jsx && /* */ (JsxPro.jsx = wrapJsx(JsxPro.jsx));\n\tJsxDev.jsxs && /* */ (JsxDev.jsxs = wrapJsx(JsxDev.jsxs));\n\tJsxPro.jsxs && /* */ (JsxPro.jsxs = wrapJsx(JsxPro.jsxs));\n\tJsxDev.jsxDEV && /**/ (JsxDev.jsxDEV = wrapJsx(JsxDev.jsxDEV));\n\tJsxPro.jsxDEV && /**/ (JsxPro.jsxDEV = wrapJsx(JsxPro.jsxDEV));\n}\n\nexport function installAutoSignalTracking() {\n\tconst [major] = reactVersion.split(\".\").map(Number);\n\tif (major >= 19) {\n\t\tthrow new Error(\n\t\t\t\"Automatic signals tracking is not supported in React 19 and later, try the Babel plugin instead https://github.com/preactjs/signals/tree/main/packages/react-transform#signals-react-transform.\"\n\t\t);\n\t}\n\tinstallCurrentDispatcherHook();\n\tinstallJSXHooks();\n}\n","import {\n\tsignal,\n\tcomputed,\n\teffect,\n\tSignal,\n\tReadonlySignal,\n} from \"@preact/signals-core\";\nimport {\n\tuseRef,\n\tuseMemo,\n\tuseEffect,\n\tuseLayoutEffect,\n\tversion as reactVersion,\n} from \"react\";\nimport { useSyncExternalStore } from \"use-sync-external-store/shim/index.js\";\nimport { isAutoSignalTrackingInstalled } from \"./auto\";\n\nexport { installAutoSignalTracking } from \"./auto\";\n\nconst [major] = reactVersion.split(\".\").map(Number);\nconst Empty = [] as const;\n// V19 https://github.com/facebook/react/blob/346c7d4c43a0717302d446da9e7423a8e28d8996/packages/shared/ReactSymbols.js#L15\n// V18 https://github.com/facebook/react/blob/346c7d4c43a0717302d446da9e7423a8e28d8996/packages/shared/ReactSymbols.js#L15\nconst ReactElemType = Symbol.for(\n\tmajor >= 19 ? \"react.transitional.element\" : \"react.element\"\n);\n\nconst noop = () => {};\n\nexport function wrapJsx(jsx: T): T {\n\tif (typeof jsx !== \"function\") return jsx;\n\n\treturn function (type: any, props: any, ...rest: any[]) {\n\t\tif (typeof type === \"string\" && props) {\n\t\t\tfor (let i in props) {\n\t\t\t\tlet v = props[i];\n\t\t\t\tif (i !== \"children\" && v instanceof Signal) {\n\t\t\t\t\tprops[i] = v.value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn jsx.call(jsx, type, props, ...rest);\n\t} as any as T;\n}\n\nconst symDispose: unique symbol =\n\t(Symbol as any).dispose || Symbol.for(\"Symbol.dispose\");\n\ninterface Effect {\n\t_sources: object | undefined;\n\t_start(): () => void;\n\t_callback(): void;\n\t_dispose(): void;\n}\n\n/**\n * Use this flag to represent a bare `useSignals` call that doesn't manually\n * close its effect store and relies on auto-closing when the next useSignals is\n * called or after a microtask\n */\nconst UNMANAGED = 0;\n/**\n * Use this flag to represent a `useSignals` call that is manually closed by a\n * try/finally block in a component's render method. This is the default usage\n * that the react-transform plugin uses.\n */\nconst MANAGED_COMPONENT = 1;\n/**\n * Use this flag to represent a `useSignals` call that is manually closed by a\n * try/finally block in a hook body. This is the default usage that the\n * react-transform plugin uses.\n */\nconst MANAGED_HOOK = 2;\n\n/**\n * An enum defining how this store is used. See the documentation for each enum\n * member for more details.\n * @see {@link UNMANAGED}\n * @see {@link MANAGED_COMPONENT}\n * @see {@link MANAGED_HOOK}\n */\ntype EffectStoreUsage =\n\t| typeof UNMANAGED\n\t| typeof MANAGED_COMPONENT\n\t| typeof MANAGED_HOOK;\n\nexport interface EffectStore {\n\t/**\n\t * An enum defining how this hook is used and whether it is invoked in a\n\t * component's body or hook body. See the comment on `EffectStoreUsage` for\n\t * more details.\n\t */\n\treadonly _usage: EffectStoreUsage;\n\treadonly effect: Effect;\n\tsubscribe(onStoreChange: () => void): () => void;\n\tgetSnapshot(): number;\n\t/** startEffect - begin tracking signals used in this component */\n\t_start(): void;\n\t/** finishEffect - stop tracking the signals used in this component */\n\tf(): void;\n\t[symDispose](): void;\n}\n\nlet currentStore: EffectStore | undefined;\n\nfunction startComponentEffect(\n\tprevStore: EffectStore | undefined,\n\tnextStore: EffectStore\n) {\n\tconst endEffect = nextStore.effect._start();\n\tcurrentStore = nextStore;\n\n\treturn finishComponentEffect.bind(nextStore, prevStore, endEffect);\n}\n\nfunction finishComponentEffect(\n\tthis: EffectStore,\n\tprevStore: EffectStore | undefined,\n\tendEffect: () => void\n) {\n\tendEffect();\n\tcurrentStore = prevStore;\n}\n\n/**\n * A redux-like store whose store value is a positive 32bit integer (a\n * 'version').\n *\n * React subscribes to this store and gets a snapshot of the current 'version',\n * whenever the 'version' changes, we tell React it's time to update the\n * component (call 'onStoreChange').\n *\n * How we achieve this is by creating a binding with an 'effect', when the\n * `effect._callback' is called, we update our store version and tell React to\n * re-render the component ([1] We don't really care when/how React does it).\n *\n * [1]\n * @see https://react.dev/reference/react/useSyncExternalStore\n * @see\n * https://github.com/reactjs/rfcs/blob/main/text/0214-use-sync-external-store.md\n *\n * @param _usage An enum defining how this hook is used and whether it is\n * invoked in a component's body or hook body. See the comment on\n * `EffectStoreUsage` for more details.\n */\nfunction createEffectStore(_usage: EffectStoreUsage): EffectStore {\n\tlet effectInstance!: Effect;\n\tlet endEffect: (() => void) | undefined;\n\tlet version = 0;\n\tlet onChangeNotifyReact: (() => void) | undefined;\n\n\tlet unsubscribe = effect(function (this: Effect) {\n\t\teffectInstance = this;\n\t});\n\teffectInstance._callback = function () {\n\t\tversion = (version + 1) | 0;\n\t\tif (onChangeNotifyReact) onChangeNotifyReact();\n\t};\n\n\treturn {\n\t\t_usage,\n\t\teffect: effectInstance,\n\t\tsubscribe(onStoreChange) {\n\t\t\tonChangeNotifyReact = onStoreChange;\n\n\t\t\treturn function () {\n\t\t\t\t/**\n\t\t\t\t * Rotate to next version when unsubscribing to ensure that components are re-run\n\t\t\t\t * when subscribing again.\n\t\t\t\t *\n\t\t\t\t * In StrictMode, 'memo'-ed components seem to keep a stale snapshot version, so\n\t\t\t\t * don't re-run after subscribing again if the version is the same as last time.\n\t\t\t\t *\n\t\t\t\t * Because we unsubscribe from the effect, the version may not change. We simply\n\t\t\t\t * set a new initial version in case of stale snapshots here.\n\t\t\t\t */\n\t\t\t\tversion = (version + 1) | 0;\n\t\t\t\tonChangeNotifyReact = undefined;\n\t\t\t\tunsubscribe();\n\t\t\t};\n\t\t},\n\t\tgetSnapshot() {\n\t\t\treturn version;\n\t\t},\n\t\t_start() {\n\t\t\t// In general, we want to support two kinds of usages of useSignals:\n\t\t\t//\n\t\t\t// A) Managed: calling useSignals in a component or hook body wrapped in a\n\t\t\t// try/finally (like what the react-transform plugin does)\n\t\t\t//\n\t\t\t// B) Unmanaged: Calling useSignals directly without wrapping in a\n\t\t\t// try/finally\n\t\t\t//\n\t\t\t// For managed, we finish the effect in the finally block of the component\n\t\t\t// or hook body. For unmanaged, we finish the effect in the next\n\t\t\t// useSignals call or after a microtask.\n\t\t\t//\n\t\t\t// There are different tradeoffs which each approach. With managed, using\n\t\t\t// a try/finally ensures that only signals used in the component or hook\n\t\t\t// body are tracked. However, signals accessed in render props are missed\n\t\t\t// because the render prop is invoked in another component that may or may\n\t\t\t// not realize it is rendering signals accessed in the render prop it is\n\t\t\t// given.\n\t\t\t//\n\t\t\t// The other approach is \"unmanaged\": to call useSignals directly without\n\t\t\t// wrapping in a try/finally. This approach is easier to manually write in\n\t\t\t// situations where a build step isn't available but does open up the\n\t\t\t// possibility of catching signals accessed in other code before the\n\t\t\t// effect is closed (e.g. in a layout effect). Most situations where this\n\t\t\t// could happen are generally consider bad patterns or bugs. For example,\n\t\t\t// using a signal in a component and not having a call to `useSignals`\n\t\t\t// would be an bug. Or using a signal in `useLayoutEffect` is generally\n\t\t\t// not recommended since that layout effect won't update when the signals'\n\t\t\t// value change.\n\t\t\t//\n\t\t\t// To support both approaches, we need to track how each invocation of\n\t\t\t// useSignals is used, so we can properly transition between different\n\t\t\t// kinds of usages.\n\t\t\t//\n\t\t\t// The following table shows the different scenarios and how we should\n\t\t\t// handle them.\n\t\t\t//\n\t\t\t// Key:\n\t\t\t// 0 = UNMANAGED\n\t\t\t// 1 = MANAGED_COMPONENT\n\t\t\t// 2 = MANAGED_HOOK\n\t\t\t//\n\t\t\t// Pattern:\n\t\t\t// prev store usage -> this store usage: action to take\n\t\t\t//\n\t\t\t// - 0 -> 0: finish previous effect (unknown to unknown)\n\t\t\t//\n\t\t\t// We don't know how the previous effect was used, so we need to finish\n\t\t\t// it before starting the next effect.\n\t\t\t//\n\t\t\t// - 0 -> 1: finish previous effect\n\t\t\t//\n\t\t\t// Assume previous invocation was another component or hook from another\n\t\t\t// component. Nested component renders (renderToStaticMarkup within a\n\t\t\t// component's render) won't be supported with bare useSignals calls.\n\t\t\t//\n\t\t\t// - 0 -> 2: capture & restore\n\t\t\t//\n\t\t\t// Previous invocation could be a component or a hook. Either way,\n\t\t\t// restore it after our invocation so that it can continue to capture\n\t\t\t// any signals after we exit.\n\t\t\t//\n\t\t\t// - 1 -> 0: Do nothing. Signals already captured by current effect store\n\t\t\t// - 1 -> 1: capture & restore (e.g. component calls renderToStaticMarkup)\n\t\t\t// - 1 -> 2: capture & restore (e.g. hook)\n\t\t\t//\n\t\t\t// - 2 -> 0: Do nothing. Signals already captured by current effect store\n\t\t\t// - 2 -> 1: capture & restore (e.g. hook calls renderToStaticMarkup)\n\t\t\t// - 2 -> 2: capture & restore (e.g. nested hook calls)\n\n\t\t\tif (currentStore == undefined) {\n\t\t\t\tendEffect = startComponentEffect(undefined, this);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst prevUsage = currentStore._usage;\n\t\t\tconst thisUsage = this._usage;\n\n\t\t\tif (\n\t\t\t\t(prevUsage == UNMANAGED && thisUsage == UNMANAGED) || // 0 -> 0\n\t\t\t\t(prevUsage == UNMANAGED && thisUsage == MANAGED_COMPONENT) // 0 -> 1\n\t\t\t) {\n\t\t\t\t// finish previous effect\n\t\t\t\tcurrentStore.f();\n\t\t\t\tendEffect = startComponentEffect(undefined, this);\n\t\t\t} else if (\n\t\t\t\t(prevUsage == MANAGED_COMPONENT && thisUsage == UNMANAGED) || // 1 -> 0\n\t\t\t\t(prevUsage == MANAGED_HOOK && thisUsage == UNMANAGED) // 2 -> 0\n\t\t\t) {\n\t\t\t\t// Do nothing since it'll be captured by current effect store\n\t\t\t} else {\n\t\t\t\t// nested scenarios, so capture and restore the previous effect store\n\t\t\t\tendEffect = startComponentEffect(currentStore, this);\n\t\t\t}\n\t\t},\n\t\tf() {\n\t\t\tconst end = endEffect;\n\t\t\tendEffect = undefined;\n\t\t\tend?.();\n\t\t},\n\t\t[symDispose]() {\n\t\t\tthis.f();\n\t\t},\n\t};\n}\n\nfunction createEmptyEffectStore(): EffectStore {\n\treturn {\n\t\t_usage: UNMANAGED,\n\t\teffect: {\n\t\t\t_sources: undefined,\n\t\t\t_callback() {},\n\t\t\t_start() {\n\t\t\t\treturn noop;\n\t\t\t},\n\t\t\t_dispose() {},\n\t\t},\n\t\tsubscribe() {\n\t\t\treturn noop;\n\t\t},\n\t\tgetSnapshot() {\n\t\t\treturn 0;\n\t\t},\n\t\t_start() {},\n\t\tf() {},\n\t\t[symDispose]() {},\n\t};\n}\n\nconst emptyEffectStore = createEmptyEffectStore();\n\nconst _queueMicroTask = Promise.prototype.then.bind(Promise.resolve());\n\nlet finalCleanup: Promise | undefined;\nexport function ensureFinalCleanup() {\n\tif (!finalCleanup) {\n\t\tfinalCleanup = _queueMicroTask(cleanupTrailingStore);\n\t}\n}\nfunction cleanupTrailingStore() {\n\tfinalCleanup = undefined;\n\tcurrentStore?.f();\n}\n\nconst useIsomorphicLayoutEffect =\n\ttypeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n\n/**\n * Custom hook to create the effect to track signals used during render and\n * subscribe to changes to rerender the component when the signals change.\n */\nexport function _useSignalsImplementation(\n\t_usage: EffectStoreUsage = UNMANAGED\n): EffectStore {\n\tensureFinalCleanup();\n\n\tconst storeRef = useRef();\n\tif (storeRef.current == null) {\n\t\tstoreRef.current = createEffectStore(_usage);\n\t}\n\n\tconst store = storeRef.current;\n\tuseSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot);\n\tstore._start();\n\t// note: _usage is a constant here, so conditional is okay\n\tif (_usage === UNMANAGED) useIsomorphicLayoutEffect(cleanupTrailingStore);\n\n\treturn store;\n}\n\n/**\n * A wrapper component that renders a Signal's value directly as a Text node or JSX.\n */\nfunction SignalValue({ data }: { data: Signal }) {\n\tconst store = _useSignalsImplementation(1);\n\ttry {\n\t\treturn data.value;\n\t} finally {\n\t\tstore.f();\n\t}\n}\n\n// Decorate Signals so React renders them as components.\nObject.defineProperties(Signal.prototype, {\n\t$$typeof: { configurable: true, value: ReactElemType },\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\tref: { configurable: true, value: null },\n});\n\nexport function useSignals(usage?: EffectStoreUsage): EffectStore {\n\tif (isAutoSignalTrackingInstalled) return emptyEffectStore;\n\treturn _useSignalsImplementation(usage);\n}\n\nexport function useSignal(value: T): Signal;\nexport function useSignal(): Signal;\nexport function useSignal(value?: T) {\n\treturn useMemo(() => signal(value), Empty);\n}\n\nexport function useComputed(compute: () => T): ReadonlySignal {\n\tconst $compute = useRef(compute);\n\t$compute.current = compute;\n\treturn useMemo(() => computed(() => $compute.current()), Empty);\n}\n\nexport function useSignalEffect(cb: () => void | (() => void)) {\n\tconst callback = useRef(cb);\n\tcallback.current = cb;\n\n\tuseEffect(() => {\n\t\treturn effect(function (this: Effect) {\n\t\t\treturn callback.current();\n\t\t});\n\t}, Empty);\n}\n"],"names":["Signal","signal","computed","effect","React","version","__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED","useRef","useMemo","useEffect","useLayoutEffect","useSyncExternalStore","jsxRuntime","jsxRuntimeDev","isAutoSignalTrackingInstalled","store","lock","currentDispatcher","dispatcherTypeCache","Map","getDispatcherType","dispatcher","type","cached","get","undefined","useCallbackImpl","useCallback","toString","useReducer","useImperativeHandle","test","useReducerImpl","set","installAutoSignalTracking","reactVersion","split","map","Number","Error","Object","defineProperty","ReactInternals","ReactCurrentDispatcher","nextDispatcher","currentDispatcherType","nextDispatcherType","MountDispatcherType","isEnteringComponentRender","_useSignalsImplementation","Boolean","isRestartingComponentRender","_store","f","isExitingComponentRender","_store2","installCurrentDispatcherHook","JsxPro","JsxDev","createElement","wrapJsx","jsx","jsxs","jsxDEV","installJSXHooks","_reactVersion$split$m","Empty","ReactElemType","Symbol","noop","props","i","v","value","call","apply","concat","slice","arguments","currentStore","symDispose","dispose","startComponentEffect","prevStore","nextStore","endEffect","_start","finishComponentEffect","bind","_ref2","finalCleanup","emptyEffectStore","_usage","_sources","_callback","_dispose","subscribe","getSnapshot","_queueMicroTask","Promise","prototype","then","resolve","ensureFinalCleanup","cleanupTrailingStore","_currentStore","useIsomorphicLayoutEffect","window","storeRef","current","_ref","effectInstance","onChangeNotifyReact","unsubscribe","this","onStoreChange","prevUsage","thisUsage","end","createEffectStore","defineProperties","$$typeof","configurable","_ref3","data","ref","useSignals","usage","useSignal","useComputed","compute","$compute","useSignalEffect","cb","callback"],"mappings":"iBAqJWA,YAAAC,cAAAC,YAAAC,MAAA,8BAAAC,cAAAC,wDAAAC,YAAAC,aAAAC,eAAAC,qBAAAC,MAAA,uCAAAC,MAAA,+CAAAC,MAAA,2BAAAC,MAAA,wBAAA,IAAAC,GAAgC,EAEvCC,EAA4B,KAC5BC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O6E,OAC1C,OAAO1C,EAA0B8E,EAClC,CAIM,SAAUC,UAAavD,GAC5B,OAAOjE,EAAQ,WAAA,OAAMP,EAAsBwE,EAAM,EAAEP,EACpD,CAEgB,SAAA+D,YAAeC,GAC9B,IAAMC,EAAW5H,EAAO2H,GACxBC,EAAStB,QAAUqB,EACnB,OAAO1H,EAAQ,WAAA,OAAMN,EAAY,WAAA,OAAMiI,EAAStB,SAAS,EAAC,EAAE3C,EAC7D,CAEgB,SAAAkE,gBAAgBC,GAC/B,IAAMC,EAAW/H,EAAO8H,GACxBC,EAASzB,QAAUwB,EAEnB5H,EAAU,WACT,OAAON,EAAO,WACb,OAAOmI,EAASzB,SACjB,EACD,EAAG3C,EACJ,QAAAjB,+BAAAsD,wBAAArE,+BAAA+F,YAAAD,UAAAI,gBAAAN,gBAAAlE"} +\ No newline at end of file ++{"version":3,"file":"runtime.module.js","sources":["../src/index.ts"],"sourcesContent":["import {\n\tsignal,\n\tcomputed,\n\teffect,\n\tSignal,\n\tReadonlySignal,\n} from \"@preact/signals-core\";\nimport {\n\tuseRef,\n\tuseMemo,\n\tuseEffect,\n\tuseLayoutEffect,\n\tversion as reactVersion,\n} from \"react\";\nimport { useSyncExternalStore } from \"use-sync-external-store/shim/index.js\";\n\nconst [major] = reactVersion.split(\".\").map(Number);\nconst Empty = [] as const;\n// V19 https://github.com/facebook/react/blob/346c7d4c43a0717302d446da9e7423a8e28d8996/packages/shared/ReactSymbols.js#L15\n// V18 https://github.com/facebook/react/blob/346c7d4c43a0717302d446da9e7423a8e28d8996/packages/shared/ReactSymbols.js#L15\nconst ReactElemType = Symbol.for(\n\tmajor >= 19 ? \"react.transitional.element\" : \"react.element\"\n);\n\nexport function wrapJsx(jsx: T): T {\n\tif (typeof jsx !== \"function\") return jsx;\n\n\treturn function (type: any, props: any, ...rest: any[]) {\n\t\tif (typeof type === \"string\" && props) {\n\t\t\tfor (let i in props) {\n\t\t\t\tlet v = props[i];\n\t\t\t\tif (i !== \"children\" && v instanceof Signal) {\n\t\t\t\t\tprops[i] = v.value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn jsx.call(jsx, type, props, ...rest);\n\t} as any as T;\n}\n\nconst symDispose: unique symbol =\n\t(Symbol as any).dispose || Symbol.for(\"Symbol.dispose\");\n\ninterface Effect {\n\t_sources: object | undefined;\n\t_start(): () => void;\n\t_callback(): void;\n\t_dispose(): void;\n}\n\n/**\n * Use this flag to represent a bare `useSignals` call that doesn't manually\n * close its effect store and relies on auto-closing when the next useSignals is\n * called or after a microtask\n */\nconst UNMANAGED = 0;\n/**\n * Use this flag to represent a `useSignals` call that is manually closed by a\n * try/finally block in a component's render method. This is the default usage\n * that the react-transform plugin uses.\n */\nconst MANAGED_COMPONENT = 1;\n/**\n * Use this flag to represent a `useSignals` call that is manually closed by a\n * try/finally block in a hook body. This is the default usage that the\n * react-transform plugin uses.\n */\nconst MANAGED_HOOK = 2;\n\n/**\n * An enum defining how this store is used. See the documentation for each enum\n * member for more details.\n * @see {@link UNMANAGED}\n * @see {@link MANAGED_COMPONENT}\n * @see {@link MANAGED_HOOK}\n */\ntype EffectStoreUsage =\n\t| typeof UNMANAGED\n\t| typeof MANAGED_COMPONENT\n\t| typeof MANAGED_HOOK;\n\nexport interface EffectStore {\n\t/**\n\t * An enum defining how this hook is used and whether it is invoked in a\n\t * component's body or hook body. See the comment on `EffectStoreUsage` for\n\t * more details.\n\t */\n\treadonly _usage: EffectStoreUsage;\n\treadonly effect: Effect;\n\tsubscribe(onStoreChange: () => void): () => void;\n\tgetSnapshot(): number;\n\t/** startEffect - begin tracking signals used in this component */\n\t_start(): void;\n\t/** finishEffect - stop tracking the signals used in this component */\n\tf(): void;\n\t[symDispose](): void;\n}\n\nlet currentStore: EffectStore | undefined;\n\nfunction startComponentEffect(\n\tprevStore: EffectStore | undefined,\n\tnextStore: EffectStore\n) {\n\tconst endEffect = nextStore.effect._start();\n\tcurrentStore = nextStore;\n\n\treturn finishComponentEffect.bind(nextStore, prevStore, endEffect);\n}\n\nfunction finishComponentEffect(\n\tthis: EffectStore,\n\tprevStore: EffectStore | undefined,\n\tendEffect: () => void\n) {\n\tendEffect();\n\tcurrentStore = prevStore;\n}\n\n/**\n * A redux-like store whose store value is a positive 32bit integer (a\n * 'version').\n *\n * React subscribes to this store and gets a snapshot of the current 'version',\n * whenever the 'version' changes, we tell React it's time to update the\n * component (call 'onStoreChange').\n *\n * How we achieve this is by creating a binding with an 'effect', when the\n * `effect._callback' is called, we update our store version and tell React to\n * re-render the component ([1] We don't really care when/how React does it).\n *\n * [1]\n * @see https://react.dev/reference/react/useSyncExternalStore\n * @see\n * https://github.com/reactjs/rfcs/blob/main/text/0214-use-sync-external-store.md\n *\n * @param _usage An enum defining how this hook is used and whether it is\n * invoked in a component's body or hook body. See the comment on\n * `EffectStoreUsage` for more details.\n */\nfunction createEffectStore(_usage: EffectStoreUsage): EffectStore {\n\tlet effectInstance!: Effect;\n\tlet endEffect: (() => void) | undefined;\n\tlet version = 0;\n\tlet onChangeNotifyReact: (() => void) | undefined;\n\n\tlet unsubscribe = effect(function (this: Effect) {\n\t\teffectInstance = this;\n\t});\n\teffectInstance._callback = function () {\n\t\tversion = (version + 1) | 0;\n\t\tif (onChangeNotifyReact) onChangeNotifyReact();\n\t};\n\n\treturn {\n\t\t_usage,\n\t\teffect: effectInstance,\n\t\tsubscribe(onStoreChange) {\n\t\t\tonChangeNotifyReact = onStoreChange;\n\n\t\t\treturn function () {\n\t\t\t\t/**\n\t\t\t\t * Rotate to next version when unsubscribing to ensure that components are re-run\n\t\t\t\t * when subscribing again.\n\t\t\t\t *\n\t\t\t\t * In StrictMode, 'memo'-ed components seem to keep a stale snapshot version, so\n\t\t\t\t * don't re-run after subscribing again if the version is the same as last time.\n\t\t\t\t *\n\t\t\t\t * Because we unsubscribe from the effect, the version may not change. We simply\n\t\t\t\t * set a new initial version in case of stale snapshots here.\n\t\t\t\t */\n\t\t\t\tversion = (version + 1) | 0;\n\t\t\t\tonChangeNotifyReact = undefined;\n\t\t\t\tunsubscribe();\n\t\t\t};\n\t\t},\n\t\tgetSnapshot() {\n\t\t\treturn version;\n\t\t},\n\t\t_start() {\n\t\t\t// In general, we want to support two kinds of usages of useSignals:\n\t\t\t//\n\t\t\t// A) Managed: calling useSignals in a component or hook body wrapped in a\n\t\t\t// try/finally (like what the react-transform plugin does)\n\t\t\t//\n\t\t\t// B) Unmanaged: Calling useSignals directly without wrapping in a\n\t\t\t// try/finally\n\t\t\t//\n\t\t\t// For managed, we finish the effect in the finally block of the component\n\t\t\t// or hook body. For unmanaged, we finish the effect in the next\n\t\t\t// useSignals call or after a microtask.\n\t\t\t//\n\t\t\t// There are different tradeoffs which each approach. With managed, using\n\t\t\t// a try/finally ensures that only signals used in the component or hook\n\t\t\t// body are tracked. However, signals accessed in render props are missed\n\t\t\t// because the render prop is invoked in another component that may or may\n\t\t\t// not realize it is rendering signals accessed in the render prop it is\n\t\t\t// given.\n\t\t\t//\n\t\t\t// The other approach is \"unmanaged\": to call useSignals directly without\n\t\t\t// wrapping in a try/finally. This approach is easier to manually write in\n\t\t\t// situations where a build step isn't available but does open up the\n\t\t\t// possibility of catching signals accessed in other code before the\n\t\t\t// effect is closed (e.g. in a layout effect). Most situations where this\n\t\t\t// could happen are generally consider bad patterns or bugs. For example,\n\t\t\t// using a signal in a component and not having a call to `useSignals`\n\t\t\t// would be an bug. Or using a signal in `useLayoutEffect` is generally\n\t\t\t// not recommended since that layout effect won't update when the signals'\n\t\t\t// value change.\n\t\t\t//\n\t\t\t// To support both approaches, we need to track how each invocation of\n\t\t\t// useSignals is used, so we can properly transition between different\n\t\t\t// kinds of usages.\n\t\t\t//\n\t\t\t// The following table shows the different scenarios and how we should\n\t\t\t// handle them.\n\t\t\t//\n\t\t\t// Key:\n\t\t\t// 0 = UNMANAGED\n\t\t\t// 1 = MANAGED_COMPONENT\n\t\t\t// 2 = MANAGED_HOOK\n\t\t\t//\n\t\t\t// Pattern:\n\t\t\t// prev store usage -> this store usage: action to take\n\t\t\t//\n\t\t\t// - 0 -> 0: finish previous effect (unknown to unknown)\n\t\t\t//\n\t\t\t// We don't know how the previous effect was used, so we need to finish\n\t\t\t// it before starting the next effect.\n\t\t\t//\n\t\t\t// - 0 -> 1: finish previous effect\n\t\t\t//\n\t\t\t// Assume previous invocation was another component or hook from another\n\t\t\t// component. Nested component renders (renderToStaticMarkup within a\n\t\t\t// component's render) won't be supported with bare useSignals calls.\n\t\t\t//\n\t\t\t// - 0 -> 2: capture & restore\n\t\t\t//\n\t\t\t// Previous invocation could be a component or a hook. Either way,\n\t\t\t// restore it after our invocation so that it can continue to capture\n\t\t\t// any signals after we exit.\n\t\t\t//\n\t\t\t// - 1 -> 0: Do nothing. Signals already captured by current effect store\n\t\t\t// - 1 -> 1: capture & restore (e.g. component calls renderToStaticMarkup)\n\t\t\t// - 1 -> 2: capture & restore (e.g. hook)\n\t\t\t//\n\t\t\t// - 2 -> 0: Do nothing. Signals already captured by current effect store\n\t\t\t// - 2 -> 1: capture & restore (e.g. hook calls renderToStaticMarkup)\n\t\t\t// - 2 -> 2: capture & restore (e.g. nested hook calls)\n\n\t\t\tif (currentStore == undefined) {\n\t\t\t\tendEffect = startComponentEffect(undefined, this);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst prevUsage = currentStore._usage;\n\t\t\tconst thisUsage = this._usage;\n\n\t\t\tif (\n\t\t\t\t(prevUsage == UNMANAGED && thisUsage == UNMANAGED) || // 0 -> 0\n\t\t\t\t(prevUsage == UNMANAGED && thisUsage == MANAGED_COMPONENT) // 0 -> 1\n\t\t\t) {\n\t\t\t\t// finish previous effect\n\t\t\t\tcurrentStore.f();\n\t\t\t\tendEffect = startComponentEffect(undefined, this);\n\t\t\t} else if (\n\t\t\t\t(prevUsage == MANAGED_COMPONENT && thisUsage == UNMANAGED) || // 1 -> 0\n\t\t\t\t(prevUsage == MANAGED_HOOK && thisUsage == UNMANAGED) // 2 -> 0\n\t\t\t) {\n\t\t\t\t// Do nothing since it'll be captured by current effect store\n\t\t\t} else {\n\t\t\t\t// nested scenarios, so capture and restore the previous effect store\n\t\t\t\tendEffect = startComponentEffect(currentStore, this);\n\t\t\t}\n\t\t},\n\t\tf() {\n\t\t\tconst end = endEffect;\n\t\t\tendEffect = undefined;\n\t\t\tend?.();\n\t\t},\n\t\t[symDispose]() {\n\t\t\tthis.f();\n\t\t},\n\t};\n}\n\nconst _queueMicroTask = Promise.prototype.then.bind(Promise.resolve());\n\nlet finalCleanup: Promise | undefined;\nexport function ensureFinalCleanup() {\n\tif (!finalCleanup) {\n\t\tfinalCleanup = _queueMicroTask(cleanupTrailingStore);\n\t}\n}\nfunction cleanupTrailingStore() {\n\tfinalCleanup = undefined;\n\tcurrentStore?.f();\n}\n\nconst useIsomorphicLayoutEffect =\n\ttypeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n\n/**\n * Custom hook to create the effect to track signals used during render and\n * subscribe to changes to rerender the component when the signals change.\n */\nexport function _useSignalsImplementation(\n\t_usage: EffectStoreUsage = UNMANAGED\n): EffectStore {\n\tensureFinalCleanup();\n\n\tconst storeRef = useRef();\n\tif (storeRef.current == null) {\n\t\tstoreRef.current = createEffectStore(_usage);\n\t}\n\n\tconst store = storeRef.current;\n\tuseSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot);\n\tstore._start();\n\t// note: _usage is a constant here, so conditional is okay\n\tif (_usage === UNMANAGED) useIsomorphicLayoutEffect(cleanupTrailingStore);\n\n\treturn store;\n}\n\n/**\n * A wrapper component that renders a Signal's value directly as a Text node or JSX.\n */\nfunction SignalValue({ data }: { data: Signal }) {\n\tconst store = _useSignalsImplementation(1);\n\ttry {\n\t\treturn data.value;\n\t} finally {\n\t\tstore.f();\n\t}\n}\n\n// Decorate Signals so React renders them as components.\nObject.defineProperties(Signal.prototype, {\n\t$$typeof: { configurable: true, value: ReactElemType },\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\tref: { configurable: true, value: null },\n});\n\nexport function useSignals(usage?: EffectStoreUsage): EffectStore {\n\treturn _useSignalsImplementation(usage);\n}\n\nexport function useSignal(value: T): Signal;\nexport function useSignal(): Signal;\nexport function useSignal(value?: T) {\n\treturn useMemo(() => signal(value), Empty);\n}\n\nexport function useComputed(compute: () => T): ReadonlySignal {\n\tconst $compute = useRef(compute);\n\t$compute.current = compute;\n\treturn useMemo(() => computed(() => $compute.current()), Empty);\n}\n\nexport function useSignalEffect(cb: () => void | (() => void)) {\n\tconst callback = useRef(cb);\n\tcallback.current = cb;\n\n\tuseEffect(() => {\n\t\treturn effect(function (this: Effect) {\n\t\t\treturn callback.current();\n\t\t});\n\t}, Empty);\n}\n"],"names":["_reactVersion$split$m","reactVersion","split","map","Number","Empty","ReactElemType","Symbol","wrapJsx","jsx","type","props","i","v","Signal","value","call","apply","concat","slice","arguments","currentStore","symDispose","dispose","startComponentEffect","prevStore","nextStore","endEffect","effect","_start","finishComponentEffect","bind","finalCleanup","_queueMicroTask","Promise","prototype","then","resolve","ensureFinalCleanup","cleanupTrailingStore","_currentStore","undefined","f","useIsomorphicLayoutEffect","window","useLayoutEffect","useEffect","_useSignalsImplementation","_usage","storeRef","useRef","current","_ref","effectInstance","onChangeNotifyReact","version","unsubscribe","this","_callback","subscribe","onStoreChange","getSnapshot","prevUsage","thisUsage","end","createEffectStore","store","useSyncExternalStore","Object","defineProperties","$$typeof","configurable","_ref2","data","get","ref","useSignals","usage","useSignal","useMemo","signal","useComputed","compute","$compute","computed","useSignalEffect","cb","callback"],"mappings":"8PAgBA,IAAAA,EAAgBC,EAAaC,MAAM,KAAKC,IAAIC,QACtCC,EAAQ,GAGRC,EAAgBC,OAAM,IAJhBP,EACZ,IAIU,GAAK,6BAA+B,iBAGxC,SAAUQ,EAAWC,GAC1B,GAAmB,mBAARA,EAAoB,OAAOA,OAEtC,OAAiBC,SAAAA,EAAWC,GAC3B,GAAoB,iBAATD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gC,GACxBC,EAAShC,QAAU+B,EACnB,OAAOH,EAAQ,WAAA,OAAMK,EAAY,WAAA,OAAMD,EAAShC,SAAS,EAAC,EAAE9C,EAC7D,CAEgB,SAAAgF,gBAAgBC,GAC/B,IAAMC,EAAWrC,EAAOoC,GACxBC,EAASpC,QAAUmC,EAEnBxC,EAAU,WACT,OAAOlB,EAAO,WACb,OAAO2D,EAASpC,SACjB,EACD,EAAG9C,EACJ,QAAA0C,+BAAAT,wBAAA2C,YAAAH,UAAAO,gBAAAT,gBAAApE"} +\ No newline at end of file +diff --git a/node_modules/@preact/signals-react/runtime/src/index.ts b/node_modules/@preact/signals-react/runtime/src/index.ts +index a06d283..1dd85d5 100644 +--- a/node_modules/@preact/signals-react/runtime/src/index.ts ++++ b/node_modules/@preact/signals-react/runtime/src/index.ts +@@ -13,9 +13,6 @@ import { + version as reactVersion, + } from "react"; + import { useSyncExternalStore } from "use-sync-external-store/shim/index.js"; +-import { isAutoSignalTrackingInstalled } from "./auto"; +- +-export { installAutoSignalTracking } from "./auto"; + + const [major] = reactVersion.split(".").map(Number); + const Empty = [] as const; +@@ -25,8 +22,6 @@ const ReactElemType = Symbol.for( + major >= 19 ? "react.transitional.element" : "react.element" + ); + +-const noop = () => {}; +- + export function wrapJsx(jsx: T): T { + if (typeof jsx !== "function") return jsx; + +@@ -290,31 +285,6 @@ function createEffectStore(_usage: EffectStoreUsage): EffectStore { + }; + } + +-function createEmptyEffectStore(): EffectStore { +- return { +- _usage: UNMANAGED, +- effect: { +- _sources: undefined, +- _callback() {}, +- _start() { +- return noop; +- }, +- _dispose() {}, +- }, +- subscribe() { +- return noop; +- }, +- getSnapshot() { +- return 0; +- }, +- _start() {}, +- f() {}, +- [symDispose]() {}, +- }; +-} +- +-const emptyEffectStore = createEmptyEffectStore(); +- + const _queueMicroTask = Promise.prototype.then.bind(Promise.resolve()); + + let finalCleanup: Promise | undefined; +@@ -380,7 +350,6 @@ Object.defineProperties(Signal.prototype, { + }); + + export function useSignals(usage?: EffectStoreUsage): EffectStore { +- if (isAutoSignalTrackingInstalled) return emptyEffectStore; + return _useSignalsImplementation(usage); + } + diff --git a/scripts/prepare/index.ts b/scripts/prepare/index.ts index f54bfe4157..1251bf8daf 100644 --- a/scripts/prepare/index.ts +++ b/scripts/prepare/index.ts @@ -71,3 +71,6 @@ const workspaceArg = `--workspace=@vaadin/hilla-react-crud`; // Workaround: doing "npm uninstall" first, the package.json in the workspace is not updated otherwise await run('npm', ['uninstall', reactComponentsPackageName, workspaceArg, '--save']); await run('npm', ['install', reactComponentsSpec, workspaceArg, '--save', '--save-exact']); + +# Patch preact signals +await run('npx', ['patch-package']);