From 505c0c0696b58cb68def29be5527c48d041ad1c3 Mon Sep 17 00:00:00 2001 From: Joe Pea Date: Wed, 25 Sep 2024 01:54:43 -0700 Subject: [PATCH] Improvements for the `@signal` decorator: - add the ability to finalize `@signal` fields without a class decorator by defining a `@signal #finalize` field after all fields are defined - refactor `@signal` on getters/setters to work without a class decorator (add support for `#private` getters/setters, but now requires the `@signal` decorator to be placed on both the getter and the setter, otherwise it won't work and an error will be shown in console) - add support for public and `#private` auto accessors --- dist/decorators/reactive.d.ts.map | 2 +- dist/decorators/reactive.js | 23 +-- dist/decorators/reactive.js.map | 2 +- dist/decorators/signal.d.ts | 22 +-- dist/decorators/signal.d.ts.map | 2 +- dist/decorators/signal.js | 159 +++++++++++------- dist/decorators/signal.js.map | 2 +- dist/index.test.js | 261 +++++++++++++++++++++++------- dist/index.test.js.map | 2 +- dist/signalify.d.ts | 10 +- dist/signalify.d.ts.map | 2 +- dist/signalify.js | 77 ++++----- dist/signalify.js.map | 2 +- src/decorators/reactive.ts | 29 +--- src/decorators/signal.ts | 185 +++++++++++++++------ src/index.test.ts | 174 +++++++++++++++++--- src/signalify.ts | 85 ++++------ 17 files changed, 676 insertions(+), 363 deletions(-) diff --git a/dist/decorators/reactive.d.ts.map b/dist/decorators/reactive.d.ts.map index 2688b82..a853d2e 100644 --- a/dist/decorators/reactive.d.ts.map +++ b/dist/decorators/reactive.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"reactive.d.ts","sourceRoot":"","sources":["../../src/decorators/reactive.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAA;AAahE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,qBAAqB,GAAG,SAAS,GAAG,GAAG,CA+D/F"} \ No newline at end of file +{"version":3,"file":"reactive.d.ts","sourceRoot":"","sources":["../../src/decorators/reactive.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAA;AAOhE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,qBAAqB,GAAG,SAAS,GAAG,GAAG,CAkD/F"} \ No newline at end of file diff --git a/dist/decorators/reactive.js b/dist/decorators/reactive.js index 0512115..e1df740 100644 --- a/dist/decorators/reactive.js +++ b/dist/decorators/reactive.js @@ -1,12 +1,6 @@ import { getListener, $PROXY, untrack } from 'solid-js'; -import { getKey, getPropsToSignalify, resetPropsToSignalify } from './signal.js'; -import { getCreateSignalAccessor } from '../signalify.js'; - -/** - * Access key for classy-solid private internal APIs. - */ -const accessKey = getKey(); -const createSignalAccessor = getCreateSignalAccessor(); +import { __propsToSignalify, __resetPropsToSignalify } from './signal.js'; +import { __createSignalAccessor } from '../signalify.js'; const hasOwnProperty = Object.prototype.hasOwnProperty; /** @@ -39,7 +33,6 @@ export function reactive(value, context) { // context may be undefined when unsing reactive() without decorators if (typeof value !== 'function' || context && context.kind !== 'class') throw new TypeError('The @reactive decorator is only for use on classes.'); const Class = value; - const signalProps = getPropsToSignalify(accessKey); // For the current class decorated with @reactive, we reset the map, so that // for the next class decorated with @reactive we track only that next @@ -48,7 +41,8 @@ export function reactive(value, context) { // // In the future maybe we can use decorator metadata for this // (https://github.com/tc39/proposal-decorator-metadata)? - resetPropsToSignalify(accessKey); + const signalProps = __propsToSignalify; // grab the current value before we reset it. + __resetPropsToSignalify(); class ReactiveDecorator extends Class { constructor(...args) { let instance; @@ -67,18 +61,11 @@ export function reactive(value, context) { const proxy = instance[$PROXY]; if (proxy) return instance; for (const [prop, propSpec] of signalProps) { - const kind = propSpec.kind; let initialValue = propSpec.initialValue; // @prod-prune if (!(hasOwnProperty.call(instance, prop) || hasOwnProperty.call(Class.prototype, prop))) throw new PropNotFoundError(prop); - const isAccessor = kind === 'getter' || kind === 'setter'; - if (isAccessor) { - const desc = Object.getOwnPropertyDescriptor(Class.prototype, prop); - initialValue = desc.get.call(instance); - // Note, if the kind was field, then the initializer already defined the initialValue. - } - createSignalAccessor(isAccessor ? Class.prototype : instance, prop, initialValue); + __createSignalAccessor(instance, prop, initialValue); } return instance; } diff --git a/dist/decorators/reactive.js.map b/dist/decorators/reactive.js.map index 5daa687..2ea9818 100644 --- a/dist/decorators/reactive.js.map +++ b/dist/decorators/reactive.js.map @@ -1 +1 @@ -{"version":3,"file":"reactive.js","names":["getListener","$PROXY","untrack","getKey","getPropsToSignalify","resetPropsToSignalify","getCreateSignalAccessor","accessKey","createSignalAccessor","hasOwnProperty","Object","prototype","reactive","value","context","kind","TypeError","Class","signalProps","ReactiveDecorator","constructor","args","instance","Reflect","construct","new","target","proxy","prop","propSpec","initialValue","call","PropNotFoundError","isAccessor","desc","getOwnPropertyDescriptor","get","Error","String"],"sources":["../../src/decorators/reactive.ts"],"sourcesContent":["import type {AnyConstructor} from 'lowclass/dist/Constructor.js'\nimport {getListener, $PROXY, untrack} from 'solid-js'\nimport {getKey, getPropsToSignalify, resetPropsToSignalify} from './signal.js'\nimport {getCreateSignalAccessor} from '../signalify.js'\n\n/**\n * Access key for classy-solid private internal APIs.\n */\nconst accessKey = getKey()\n\nconst createSignalAccessor = getCreateSignalAccessor()\nconst hasOwnProperty = Object.prototype.hasOwnProperty\n\n/**\n * A decorator that makes a class reactive, allowing it have properties\n * decorated with `@signal` to make those properties reactive Solid signals.\n *\n * Example:\n *\n * ```js\n * import {reactive, signal} from 'classy-solid'\n * import {createEffect} from 'solid-js'\n *\n * ⁣@reactive\n * class Counter {\n * ⁣@signal count = 0\n *\n * constructor() {\n * setInterval(() => this.count++, 1000)\n * }\n * }\n *\n * const counter = new Counter\n *\n * createEffect(() => {\n * console.log('count:', counter.count)\n * })\n * ```\n */\nexport function reactive(value: AnyConstructor, context: ClassDecoratorContext | undefined): any {\n\t// context may be undefined when unsing reactive() without decorators\n\tif (typeof value !== 'function' || (context && context.kind !== 'class'))\n\t\tthrow new TypeError('The @reactive decorator is only for use on classes.')\n\n\tconst Class = value\n\tconst signalProps = getPropsToSignalify(accessKey)\n\n\t// For the current class decorated with @reactive, we reset the map, so that\n\t// for the next class decorated with @reactive we track only that next\n\t// class's properties that were decorated with @signal. We do this because\n\t// field decorators do not have access to the class or its prototype.\n\t//\n\t// In the future maybe we can use decorator metadata for this\n\t// (https://github.com/tc39/proposal-decorator-metadata)?\n\tresetPropsToSignalify(accessKey)\n\n\tclass ReactiveDecorator extends Class {\n\t\tconstructor(...args: any[]) {\n\t\t\tlet instance!: ReactiveDecorator\n\n\t\t\t// Ensure that if we're in an effect that `new`ing a class does not\n\t\t\t// track signal reads, otherwise we'll get into an infinite loop. If\n\t\t\t// someone want to trigger an effect based on properties of the\n\t\t\t// `new`ed instance, they can explicitly read the properties\n\t\t\t// themselves in the effect, making their intent clear.\n\t\t\tif (getListener()) untrack(() => (instance = Reflect.construct(Class, args, new.target))) // super()\n\t\t\telse super(...args), (instance = this)\n\n\t\t\t// Special case for Solid proxies: if the object is already a solid proxy,\n\t\t\t// all properties are already reactive, no need to signalify.\n\t\t\t// @ts-expect-error special indexed access\n\t\t\tconst proxy = instance[$PROXY] as T\n\t\t\tif (proxy) return instance\n\n\t\t\tfor (const [prop, propSpec] of signalProps) {\n\t\t\t\tconst kind = propSpec.kind\n\t\t\t\tlet initialValue = propSpec.initialValue\n\n\t\t\t\t// @prod-prune\n\t\t\t\tif (!(hasOwnProperty.call(instance, prop) || hasOwnProperty.call(Class.prototype, prop)))\n\t\t\t\t\tthrow new PropNotFoundError(prop)\n\n\t\t\t\tconst isAccessor = kind === 'getter' || kind === 'setter'\n\n\t\t\t\tif (isAccessor) {\n\t\t\t\t\tconst desc = Object.getOwnPropertyDescriptor(Class.prototype, prop)!\n\t\t\t\t\tinitialValue = desc.get!.call(instance)\n\t\t\t\t\t// Note, if the kind was field, then the initializer already defined the initialValue.\n\t\t\t\t}\n\n\t\t\t\tcreateSignalAccessor(\n\t\t\t\t\tisAccessor ? Class.prototype : instance,\n\t\t\t\t\tprop as Exclude,\n\t\t\t\t\tinitialValue,\n\t\t\t\t)\n\t\t\t}\n\n\t\t\treturn instance\n\t\t}\n\t}\n\n\treturn ReactiveDecorator\n}\n\nclass PropNotFoundError extends Error {\n\tconstructor(prop: PropertyKey) {\n\t\tsuper(\n\t\t\t`Property \"${String(\n\t\t\t\tprop,\n\t\t\t)}\" not found on instance of class decorated with \\`@reactive\\`. Did you forget to use the \\`@reactive\\` decorator on one of your classes that has a \"${String(\n\t\t\t\tprop,\n\t\t\t)}\" property decorated with \\`@signal\\`?`,\n\t\t)\n\t}\n}\n"],"mappings":"AACA,SAAQA,WAAW,EAAEC,MAAM,EAAEC,OAAO,QAAO,UAAU;AACrD,SAAQC,MAAM,EAAEC,mBAAmB,EAAEC,qBAAqB,QAAO,aAAa;AAC9E,SAAQC,uBAAuB,QAAO,iBAAiB;;AAEvD;AACA;AACA;AACA,MAAMC,SAAS,GAAGJ,MAAM,CAAC,CAAC;AAE1B,MAAMK,oBAAoB,GAAGF,uBAAuB,CAAC,CAAC;AACtD,MAAMG,cAAc,GAAGC,MAAM,CAACC,SAAS,CAACF,cAAc;;AAEtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,QAAQA,CAACC,KAAqB,EAAEC,OAA0C,EAAO;EAChG;EACA,IAAI,OAAOD,KAAK,KAAK,UAAU,IAAKC,OAAO,IAAIA,OAAO,CAACC,IAAI,KAAK,OAAQ,EACvE,MAAM,IAAIC,SAAS,CAAC,qDAAqD,CAAC;EAE3E,MAAMC,KAAK,GAAGJ,KAAK;EACnB,MAAMK,WAAW,GAAGd,mBAAmB,CAACG,SAAS,CAAC;;EAElD;EACA;EACA;EACA;EACA;EACA;EACA;EACAF,qBAAqB,CAACE,SAAS,CA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QAAQ;IAChB;EACD;EAEA,OAAOH,iBAAiB;AACzB;AAEA,MAAMa,iBAAiB,SAASK,KAAK,CAAC;EACrCjB,WAAWA,CAACQ,IAAiB,EAAE;IAC9B,KAAK,CACJ,aAAaU,MAAM,CAClBV,IACD,CAAC,uJAAuJU,MAAM,CAC7JV,IACD,CAAC,wCACF,CAAC;EACF;AACD","ignoreList":[]} \ No newline at end of file +{"version":3,"file":"reactive.js","names":["getListener","$PROXY","untrack","__propsToSignalify","__resetPropsToSignalify","__createSignalAccessor","hasOwnProperty","Object","prototype","reactive","value","context","kind","TypeError","Class","signalProps","ReactiveDecorator","constructor","args","instance","Reflect","construct","new","target","proxy","prop","propSpec","initialValue","call","PropNotFoundError","Error","String"],"sources":["../../src/decorators/reactive.ts"],"sourcesContent":["import type {AnyConstructor} from 'lowclass/dist/Constructor.js'\nimport {getListener, $PROXY, untrack} from 'solid-js'\nimport {__propsToSignalify, __resetPropsToSignalify} from './signal.js'\nimport {__createSignalAccessor} from '../signalify.js'\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty\n\n/**\n * A decorator that makes a class reactive, allowing it have properties\n * decorated with `@signal` to make those properties reactive Solid signals.\n *\n * Example:\n *\n * ```js\n * import {reactive, signal} from 'classy-solid'\n * import {createEffect} from 'solid-js'\n *\n * ⁣@reactive\n * class Counter {\n * ⁣@signal count = 0\n *\n * constructor() {\n * setInterval(() => this.count++, 1000)\n * }\n * }\n *\n * const counter = new Counter\n *\n * createEffect(() => {\n * console.log('count:', counter.count)\n * })\n * ```\n */\nexport function reactive(value: AnyConstructor, context: ClassDecoratorContext | undefined): any {\n\t// context may be undefined when unsing reactive() without decorators\n\tif (typeof value !== 'function' || (context && context.kind !== 'class'))\n\t\tthrow new TypeError('The @reactive decorator is only for use on classes.')\n\n\tconst Class = value\n\n\t// For the current class decorated with @reactive, we reset the map, so that\n\t// for the next class decorated with @reactive we track only that next\n\t// class's properties that were decorated with @signal. We do this because\n\t// field decorators do not have access to the class or its prototype.\n\t//\n\t// In the future maybe we can use decorator metadata for this\n\t// (https://github.com/tc39/proposal-decorator-metadata)?\n\tconst signalProps = __propsToSignalify // grab the current value before we reset it.\n\t__resetPropsToSignalify()\n\n\tclass ReactiveDecorator extends Class {\n\t\tconstructor(...args: any[]) {\n\t\t\tlet instance!: ReactiveDecorator\n\n\t\t\t// Ensure that if we're in an effect that `new`ing a class does not\n\t\t\t// track signal reads, otherwise we'll get into an infinite loop. If\n\t\t\t// someone want to trigger an effect based on properties of the\n\t\t\t// `new`ed instance, they can explicitly read the properties\n\t\t\t// themselves in the effect, making their intent clear.\n\t\t\tif (getListener()) untrack(() => (instance = Reflect.construct(Class, args, new.target))) // super()\n\t\t\telse super(...args), (instance = this)\n\n\t\t\t// Special case for Solid proxies: if the object is already a solid proxy,\n\t\t\t// all properties are already reactive, no need to signalify.\n\t\t\t// @ts-expect-error special indexed access\n\t\t\tconst proxy = instance[$PROXY] as T\n\t\t\tif (proxy) return instance\n\n\t\t\tfor (const [prop, propSpec] of signalProps) {\n\t\t\t\tlet initialValue = propSpec.initialValue\n\n\t\t\t\t// @prod-prune\n\t\t\t\tif (!(hasOwnProperty.call(instance, prop) || hasOwnProperty.call(Class.prototype, prop)))\n\t\t\t\t\tthrow new PropNotFoundError(prop)\n\n\t\t\t\t__createSignalAccessor(instance, prop as Exclude, initialValue)\n\t\t\t}\n\n\t\t\treturn instance\n\t\t}\n\t}\n\n\treturn ReactiveDecorator\n}\n\nclass PropNotFoundError extends Error {\n\tconstructor(prop: PropertyKey) {\n\t\tsuper(\n\t\t\t`Property \"${String(\n\t\t\t\tprop,\n\t\t\t)}\" not found on instance of class decorated with \\`@reactive\\`. Did you forget to use the \\`@reactive\\` decorator on one of your classes that has a \"${String(\n\t\t\t\tprop,\n\t\t\t)}\" property decorated with \\`@signal\\`?`,\n\t\t)\n\t}\n}\n"],"mappings":"AACA,SAAQA,WAAW,EAAEC,MAAM,EAAEC,OAAO,QAAO,UAAU;AACrD,SAAQC,kBAAkB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,EAAEM,IAAI,CAAC,IAAInB,cAAc,CAACsB,IAAI,CAACd,KAAK,CAACN,SAAS,EAAEiB,IAAI,CAAC,CAAC,EACvF,MAAM,IAAII,iBAAiB,CAACJ,IAAI,CAAC;QAElCpB,sBAAsB,CAACc,QAAQ,EAAEM,IAAI,EAA8CE,YAAY,CAAC;MACjG;MAEA,OAAOR,QAAQ;IAChB;EACD;EAEA,OAAOH,iBAAiB;AACzB;AAEA,MAAMa,iBAAiB,SAASC,KAAK,CAAC;EACrCb,WAAWA,CAACQ,IAAiB,EAAE;IAC9B,KAAK,CACJ,aAAaM,MAAM,CAClBN,IACD,CAAC,uJAAuJM,MAAM,CAC7JN,IACD,CAAC,wCACF,CAAC;EACF;AACD","ignoreList":[]} \ No newline at end of file diff --git a/dist/decorators/signal.d.ts b/dist/decorators/signal.d.ts index 4217bf1..0bc06ec 100644 --- a/dist/decorators/signal.d.ts +++ b/dist/decorators/signal.d.ts @@ -1,22 +1,6 @@ import type { PropKey, PropSpec } from './types.js'; -/** - * Provides a key for accessing internal APIs. If any other module tries to get - * this, an error will be thrown, and signal and reactive decorators will not - * work. - */ -export declare function getKey(): symbol; -/** - * This function provides propsToSignalify to only one external module - * (reactive.ts). The purpose of this is to keep the API private for reactive.ts - * only, otherwise an error will be thrown that breaks signal/reactive - * functionality. - */ -export declare function getPropsToSignalify(key: symbol): Map; -/** - * Only the module that first gets the key can call this function (it should be - * reactive.ts) - */ -export declare function resetPropsToSignalify(key: symbol): void; +export declare let __propsToSignalify: Map; +export declare function __resetPropsToSignalify(): void; /** * @decorator * Decorate properties of a class with `@signal` to back them with Solid @@ -47,5 +31,5 @@ export declare function resetPropsToSignalify(key: symbol): void; * }) * ``` */ -export declare function signal(_: unknown, context: ClassFieldDecoratorContext | ClassGetterDecoratorContext | ClassSetterDecoratorContext): any; +export declare function signal(value: unknown, context: ClassFieldDecoratorContext | ClassGetterDecoratorContext | ClassSetterDecoratorContext | ClassAccessorDecoratorContext): any; //# sourceMappingURL=signal.d.ts.map \ No newline at end of file diff --git a/dist/decorators/signal.d.ts.map b/dist/decorators/signal.d.ts.map index 774a59f..1447dd4 100644 --- a/dist/decorators/signal.d.ts.map +++ b/dist/decorators/signal.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"signal.d.ts","sourceRoot":"","sources":["../../src/decorators/signal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAA;AAKjD;;;;GAIG;AACH,wBAAgB,MAAM,WAIrB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,0BAG9C;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,QAGhD;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,MAAM,CACrB,CAAC,EAAE,OAAO,EACV,OAAO,EAAE,0BAA0B,GAAG,2BAA2B,GAAG,2BAA2B,GAC7F,GAAG,CAyBL"} \ No newline at end of file +{"version":3,"file":"signal.d.ts","sourceRoot":"","sources":["../../src/decorators/signal.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAA;AAGjD,eAAO,IAAI,kBAAkB,wBAA+B,CAAA;AAE5D,wBAAgB,uBAAuB,SAEtC;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,MAAM,CACrB,KAAK,EAAE,OAAO,EACd,OAAO,EACJ,0BAA0B,GAC1B,2BAA2B,GAC3B,2BAA2B,GAC3B,6BAA6B,GAC9B,GAAG,CAqGL"} \ No newline at end of file diff --git a/dist/decorators/signal.js b/dist/decorators/signal.js index 9fad74d..a393a67 100644 --- a/dist/decorators/signal.js +++ b/dist/decorators/signal.js @@ -1,40 +1,10 @@ -let propsToSignalify = new Map(); -let accessKey = null; - -/** - * Provides a key for accessing internal APIs. If any other module tries to get - * this, an error will be thrown, and signal and reactive decorators will not - * work. - */ -export function getKey() { - if (accessKey) throw new Error('Attempted use of classy-solid internals.'); - accessKey = Symbol(); - return accessKey; +import { $PROXY } from 'solid-js'; +import { __getSignal, __trackPropSetAtLeastOnce, __createSignalAccessor } from '../signalify.js'; +export let __propsToSignalify = new Map(); +export function __resetPropsToSignalify() { + __propsToSignalify = new Map(); } - -/** - * This function provides propsToSignalify to only one external module - * (reactive.ts). The purpose of this is to keep the API private for reactive.ts - * only, otherwise an error will be thrown that breaks signal/reactive - * functionality. - */ -export function getPropsToSignalify(key) { - if (key !== accessKey) throw new Error('Attempted use of classy-solid internals.'); - return propsToSignalify; -} - -/** - * Only the module that first gets the key can call this function (it should be - * reactive.ts) - */ -export function resetPropsToSignalify(key) { - if (key !== accessKey) throw new Error('Attempted use of classy-solid internals.'); - propsToSignalify = new Map(); -} -function isMemberDecorator(context) { - return !!('private' in context); -} - +const Undefined = Symbol(); /** * @decorator * Decorate properties of a class with `@signal` to back them with Solid @@ -65,36 +35,102 @@ function isMemberDecorator(context) { * }) * ``` */ -export function signal(_, context) { +export function signal(value, context) { const { kind, - name + name, + metadata } = context; - const props = propsToSignalify; - if (isMemberDecorator(context)) { - if (context.private) throw new Error('@signal is not supported on private fields yet.'); - if (context.static) throw new Error('@signal is not supported on static fields yet.'); - } + const props = __propsToSignalify; + if (context.static) throw new Error('@signal is not supported on static fields yet.'); + + // @prod-prune + queueReactiveDecoratorChecker(props); if (kind === 'field') { - props.set(name, { + if (context.private && name !== '#finalize') throw new Error('@signal is not supported on private fields yet.'); + if (name === '#finalize') __propsToSignalify = new Map(); // reset + else props.set(name, { initialValue: undefined, kind }); return function (initialValue) { + if (name === '#finalize') { + // Special case for Solid proxies: if the object is already a solid proxy, + // all properties are already reactive, no need to signalify. + // @ts-expect-error special indexed access + const proxy = this[$PROXY]; + if (proxy) return this; + for (const [prop, propSpec] of props) { + let initialValue = propSpec.initialValue; + + // @prod-prune + if (!Object.hasOwn(this, prop)) + // continue + throw new PropNotFoundError(prop); + __createSignalAccessor(this, prop, initialValue); + // CONTINUE testing this way of finalizing signal fields + } + return; + } props.get(name).initialValue = initialValue; return initialValue; }; + } else if (kind === 'accessor') { + const { + get, + set + } = value; + const signalStorage = new WeakMap(); + let initialValue = undefined; + return { + init: function (initialVal) { + initialValue = initialVal; + return initialVal; + }, + get: function () { + __getSignal(this, signalStorage, initialValue)(); + return get.call(this); + }, + set: function (newValue) { + set.call(this, newValue); + __trackPropSetAtLeastOnce(this, name); // not needed anymore? test it + + const s = __getSignal(this, signalStorage, initialValue); + s(typeof newValue === 'function' ? () => newValue : newValue); + } + }; } else if (kind === 'getter' || kind === 'setter') { - props.set(name, { - initialValue: undefined, - kind - }); - } else { - throw new Error('The @signal decorator is only for use on fields, getters, and setters. Auto accessor support is coming next if there is demand for it.'); - } + const getOrSet = value; + const initialValue = Undefined; + if (!Object.hasOwn(metadata, 'signalStoragesPerProp')) metadata.signalStoragesPerProp = {}; + const signalsStorages = metadata.signalStoragesPerProp; + let signalStorage = signalsStorages[name]; + if (!signalStorage) signalsStorages[name] = signalStorage = new WeakMap(); + if (!Object.hasOwn(metadata, 'getterSetterPairs')) metadata.getterSetterPairs = {}; + const pairs = metadata.getterSetterPairs; - // @prod-prune - queueReactiveDecoratorChecker(props); + // Show a helpful error in case someone forgets to decorate both a getter and setter. + queueMicrotask(() => { + if (pairs[name] !== 2) throw new MissingDecoratorError(name); + }); + if (kind === 'getter') { + pairs[name] ??= 0; + pairs[name]++; + return function () { + __getSignal(this, signalStorage, initialValue)(); + return getOrSet.call(this); + }; + } else { + pairs[name] ??= 0; + pairs[name]++; + return function (newValue) { + getOrSet.call(this, newValue); + __trackPropSetAtLeastOnce(this, name); + const s = __getSignal(this, signalStorage, initialValue); + s(typeof newValue === 'function' ? () => newValue : newValue); + }; + } + } else throw new InvalidDecorationError(); } let checkerQueued = false; @@ -114,11 +150,26 @@ function queueReactiveDecoratorChecker(props) { // If the refs are still equal, it means @reactive did not run (forgot // to decorate a class that uses @signal with @reactive). - if (props === propsToSignalify) { + if (props === __propsToSignalify) { throw new Error( // Array.from(map.keys()) instead of [...map.keys()] because it breaks in Oculus browser. `Stray @signal-decorated properties detected: ${Array.from(props.keys()).join(', ')}. Did you forget to use the \`@reactive\` decorator on a class that has properties decorated with \`@signal\`?`); } }); } +class PropNotFoundError extends Error { + constructor(prop) { + super(`Property "${String(prop)}" not found on instance of class decorated with \`@reactive\`. Did you forget to use the \`@reactive\` decorator on one of your classes that has a "${String(prop)}" property decorated with \`@signal\`?`); + } +} +class MissingDecoratorError extends Error { + constructor(prop) { + super(`Missing @signal decorator on setter or getter for property "${String(prop)}". The @signal decorator will only work on a getter/setter pair with *both* getter and setter decorated with @signal.`); + } +} +class InvalidDecorationError extends Error { + constructor() { + super('The @signal decorator is only for use on fields, getters, setters, and auto accessors.'); + } +} //# sourceMappingURL=signal.js.map \ No newline at end of file diff --git a/dist/decorators/signal.js.map b/dist/decorators/signal.js.map index 79e024a..dff4d84 100644 --- a/dist/decorators/signal.js.map +++ b/dist/decorators/signal.js.map @@ -1 +1 @@ -{"version":3,"file":"signal.js","names":["propsToSignalify","Map","accessKey","getKey","Error","Symbol","getPropsToSignalify","key","resetPropsToSignalify","isMemberDecorator","context","signal","_","kind","name","props","private","static","set","initialValue","undefined","get","queueReactiveDecoratorChecker","checkerQueued","queueMicrotask","Array","from","keys","join"],"sources":["../../src/decorators/signal.ts"],"sourcesContent":["import type {PropKey, PropSpec} from './types.js'\n\nlet propsToSignalify = new Map()\nlet accessKey: symbol | null = null\n\n/**\n * Provides a key for accessing internal APIs. If any other module tries to get\n * this, an error will be thrown, and signal and reactive decorators will not\n * work.\n */\nexport function getKey() {\n\tif (accessKey) throw new Error('Attempted use of classy-solid internals.')\n\taccessKey = Symbol()\n\treturn accessKey\n}\n\n/**\n * This function provides propsToSignalify to only one external module\n * (reactive.ts). The purpose of this is to keep the API private for reactive.ts\n * only, otherwise an error will be thrown that breaks signal/reactive\n * functionality.\n */\nexport function getPropsToSignalify(key: symbol) {\n\tif (key !== accessKey) throw new Error('Attempted use of classy-solid internals.')\n\treturn propsToSignalify\n}\n\n/**\n * Only the module that first gets the key can call this function (it should be\n * reactive.ts)\n */\nexport function resetPropsToSignalify(key: symbol) {\n\tif (key !== accessKey) throw new Error('Attempted use of classy-solid internals.')\n\tpropsToSignalify = new Map()\n}\n\nfunction isMemberDecorator(context: DecoratorContext): context is ClassMemberDecoratorContext {\n\treturn !!('private' in context)\n}\n\n/**\n * @decorator\n * Decorate properties of a class with `@signal` to back them with Solid\n * signals, making them reactive. Don't forget that the class in which `@signal`\n * is used must be decorated with `@reactive`.\n *\n * Related: See the Solid.js `createSignal` API for creating signals.\n *\n * Example:\n *\n * ```js\n * import {reactive, signal} from 'classy-solid'\n * import {createEffect} from 'solid-js'\n *\n * ⁣@reactive\n * class Counter {\n * ⁣@signal count = 0\n *\n * constructor() {\n * setInterval(() => this.count++, 1000)\n * }\n * }\n *\n * const counter = new Counter\n *\n * createEffect(() => {\n * console.log('count:', counter.count)\n * })\n * ```\n */\nexport function signal(\n\t_: unknown,\n\tcontext: ClassFieldDecoratorContext | ClassGetterDecoratorContext | ClassSetterDecoratorContext,\n): any {\n\tconst {kind, name} = context\n\tconst props = propsToSignalify\n\n\tif (isMemberDecorator(context)) {\n\t\tif (context.private) throw new Error('@signal is not supported on private fields yet.')\n\t\tif (context.static) throw new Error('@signal is not supported on static fields yet.')\n\t}\n\n\tif (kind === 'field') {\n\t\tprops.set(name, {initialValue: undefined, kind})\n\t\treturn function (this: object, initialValue: unknown) {\n\t\t\tprops.get(name)!.initialValue = initialValue\n\t\t\treturn initialValue\n\t\t}\n\t} else if (kind === 'getter' || kind === 'setter') {\n\t\tprops.set(name, {initialValue: undefined, kind})\n\t} else {\n\t\tthrow new Error(\n\t\t\t'The @signal decorator is only for use on fields, getters, and setters. Auto accessor support is coming next if there is demand for it.',\n\t\t)\n\t}\n\n\t// @prod-prune\n\tqueueReactiveDecoratorChecker(props)\n}\n\nlet checkerQueued = false\n\n/**\n * This throws an error in some cases of an end dev forgetting to decorate a\n * class with `@reactive` if they used `@signal` on that class's fields.\n *\n * This doesn't work all the time, only when the very last class decorated is\n * missing @reactive, but something is better than nothing. There's another\n * similar check performed in the `@reactive` decorator.\n */\nfunction queueReactiveDecoratorChecker(props: Map) {\n\tif (checkerQueued) return\n\tcheckerQueued = true\n\n\tqueueMicrotask(() => {\n\t\tcheckerQueued = false\n\n\t\t// If the refs are still equal, it means @reactive did not run (forgot\n\t\t// to decorate a class that uses @signal with @reactive).\n\t\tif (props === propsToSignalify) {\n\t\t\tthrow new Error(\n\t\t\t\t// Array.from(map.keys()) instead of [...map.keys()] because it breaks in Oculus browser.\n\t\t\t\t`Stray @signal-decorated properties detected: ${Array.from(props.keys()).join(\n\t\t\t\t\t', ',\n\t\t\t\t)}. Did you forget to use the \\`@reactive\\` decorator on a class that has properties decorated with \\`@signal\\`?`,\n\t\t\t)\n\t\t}\n\t})\n}\n"],"mappings":"AAEA,IAAIA,gBAAgB,GAAG,IAAIC,GAAG,CAAoB,CAAC;AACnD,IAAIC,SAAwB,GAAG,IAAI;;AAEnC;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,MAAMA,CAAA,EAAG;EACxB,IAAID,SAAS,EAAE,MAAM,IAAIE,KAAK,CAAC,0CAA0C,CAAC;EAC1EF,SAAS,GAAGG,MAAM,CAAC,CAAC;EACpB,OAAOH,SAAS;AACjB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,mBAAmBA,CAACC,GAAW,EAAE;EAChD,IAAIA,GAAG,KAAKL,SAAS,EAAE,MAAM,IAAIE,KAAK,CAAC,0CAA0C,CAAC;EAClF,OAAOJ,gBAAgB;AACxB;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASQ,qBAAqBA,CAACD,GAAW,EAAE;EAClD,IAAIA,GAAG,KAAKL,SAAS,EAAE,MAAM,IAAIE,KAAK,CAAC,0CAA0C,CAAC;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GAAG,KAAK;;AAEzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASD,6BAA6BA,CAACP,KAA6B,EAAE;EACrE,IAAIQ,aAAa,EAAE;EACnBA,aAAa,GAAG,IAAI;EAEpBC,cAAc,CAAC,MAAM;IACpBD,aAAa,GAAG,KAAK;;IAErB;IACA;IACA,IAAIR,KAAK,KAAKf,gBAAgB,EAAE;MAC/B,MAAM,IAAII,KAAK;MACd;MACA,gDAAgDqB,KAAK,CAACC,IAAI,CAACX,KAAK,CAACY,IAAI,CAAC,CAAC,CAAC,CAACC,IAAI,CAC5E,IACD,CAAC,gHACF,CAAC;IACF;EACD,CAAC,CAAC;AACH","ignoreList":[]} \ No newline at end of file +{"version":3,"file":"signal.js","names":["$PROXY","__getSignal","__trackPropSetAtLeastOnce","__createSignalAccessor","__propsToSignalify","Map","__resetPropsToSignalify","Undefined","Symbol","signal","value","context","kind","name","metadata","props","static","Error","queueReactiveDecoratorChecker","private","set","initialValue","undefined","proxy","prop","propSpec","Object","hasOwn","PropNotFoundError","get","signalStorage","WeakMap","init","initialVal","call","newValue","s","getOrSet","signalStoragesPerProp","signalsStorages","getterSetterPairs","pairs","queueMicrotask","MissingDecoratorError","InvalidDecorationError","checkerQueued","Array","from","keys","join","constructor","String"],"sources":["../../src/decorators/signal.ts"],"sourcesContent":["import {$PROXY} from 'solid-js'\nimport {__getSignal, __trackPropSetAtLeastOnce, __createSignalAccessor} from '../signalify.js'\nimport type {PropKey, PropSpec} from './types.js'\nimport type {SignalFunction} from '../createSignalFunction.js'\n\nexport let __propsToSignalify = new Map()\n\nexport function __resetPropsToSignalify() {\n\t__propsToSignalify = new Map()\n}\n\nconst Undefined = Symbol()\n\ntype SignalStorages = Record> | undefined>\n\n/**\n * @decorator\n * Decorate properties of a class with `@signal` to back them with Solid\n * signals, making them reactive. Don't forget that the class in which `@signal`\n * is used must be decorated with `@reactive`.\n *\n * Related: See the Solid.js `createSignal` API for creating signals.\n *\n * Example:\n *\n * ```js\n * import {reactive, signal} from 'classy-solid'\n * import {createEffect} from 'solid-js'\n *\n * ⁣@reactive\n * class Counter {\n * ⁣@signal count = 0\n *\n * constructor() {\n * setInterval(() => this.count++, 1000)\n * }\n * }\n *\n * const counter = new Counter\n *\n * createEffect(() => {\n * console.log('count:', counter.count)\n * })\n * ```\n */\nexport function signal(\n\tvalue: unknown,\n\tcontext:\n\t\t| ClassFieldDecoratorContext\n\t\t| ClassGetterDecoratorContext\n\t\t| ClassSetterDecoratorContext\n\t\t| ClassAccessorDecoratorContext,\n): any {\n\tconst {kind, name, metadata} = context\n\tconst props = __propsToSignalify\n\n\tif (context.static) throw new Error('@signal is not supported on static fields yet.')\n\n\t// @prod-prune\n\tqueueReactiveDecoratorChecker(props)\n\n\tif (kind === 'field') {\n\t\tif (context.private && name !== '#finalize') throw new Error('@signal is not supported on private fields yet.')\n\n\t\tif (name === '#finalize') __propsToSignalify = new Map() // reset\n\t\telse props.set(name, {initialValue: undefined, kind})\n\n\t\treturn function (this: object, initialValue: unknown) {\n\t\t\tif (name === '#finalize') {\n\t\t\t\t// Special case for Solid proxies: if the object is already a solid proxy,\n\t\t\t\t// all properties are already reactive, no need to signalify.\n\t\t\t\t// @ts-expect-error special indexed access\n\t\t\t\tconst proxy = this[$PROXY] as T\n\t\t\t\tif (proxy) return this\n\n\t\t\t\tfor (const [prop, propSpec] of props) {\n\t\t\t\t\tlet initialValue = propSpec.initialValue\n\n\t\t\t\t\t// @prod-prune\n\t\t\t\t\tif (!Object.hasOwn(this, prop))\n\t\t\t\t\t\t// continue\n\t\t\t\t\t\tthrow new PropNotFoundError(prop)\n\n\t\t\t\t\t__createSignalAccessor(this as any, prop, initialValue)\n\t\t\t\t\t// CONTINUE testing this way of finalizing signal fields\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tprops.get(name)!.initialValue = initialValue\n\t\t\treturn initialValue\n\t\t}\n\t} else if (kind === 'accessor') {\n\t\tconst {get, set} = value as {get: () => unknown; set: (v: unknown) => void}\n\t\tconst signalStorage = new WeakMap>()\n\t\tlet initialValue: unknown = undefined\n\n\t\treturn {\n\t\t\tinit: function (this: object, initialVal: unknown) {\n\t\t\t\tinitialValue = initialVal\n\t\t\t\treturn initialVal\n\t\t\t},\n\t\t\tget: function (this: object): unknown {\n\t\t\t\t__getSignal(this, signalStorage, initialValue)()\n\t\t\t\treturn get.call(this)\n\t\t\t},\n\t\t\tset: function (this: object, newValue: unknown) {\n\t\t\t\tset.call(this, newValue)\n\t\t\t\t__trackPropSetAtLeastOnce(this, name) // not needed anymore? test it\n\n\t\t\t\tconst s = __getSignal(this, signalStorage, initialValue)\n\t\t\t\ts(typeof newValue === 'function' ? () => newValue : newValue)\n\t\t\t},\n\t\t}\n\t} else if (kind === 'getter' || kind === 'setter') {\n\t\tconst getOrSet = value as Function\n\t\tconst initialValue = Undefined\n\n\t\tif (!Object.hasOwn(metadata, 'signalStoragesPerProp')) metadata.signalStoragesPerProp = {}\n\t\tconst signalsStorages = metadata.signalStoragesPerProp as SignalStorages\n\n\t\tlet signalStorage = signalsStorages[name]\n\t\tif (!signalStorage) signalsStorages[name] = signalStorage = new WeakMap>()\n\n\t\tif (!Object.hasOwn(metadata, 'getterSetterPairs')) metadata.getterSetterPairs = {}\n\t\tconst pairs = metadata.getterSetterPairs as {[key: PropKey]: 0 | 1 | 2}\n\n\t\t// Show a helpful error in case someone forgets to decorate both a getter and setter.\n\t\tqueueMicrotask(() => {\n\t\t\tif (pairs[name] !== 2) throw new MissingDecoratorError(name)\n\t\t})\n\n\t\tif (kind === 'getter') {\n\t\t\tpairs[name] ??= 0\n\t\t\tpairs[name]++\n\n\t\t\treturn function (this: object): unknown {\n\t\t\t\t__getSignal(this, signalStorage, initialValue)()\n\t\t\t\treturn getOrSet.call(this)\n\t\t\t}\n\t\t} else {\n\t\t\tpairs[name] ??= 0\n\t\t\tpairs[name]++\n\n\t\t\treturn function (this: object, newValue: unknown) {\n\t\t\t\tgetOrSet.call(this, newValue)\n\t\t\t\t__trackPropSetAtLeastOnce(this, name)\n\n\t\t\t\tconst s = __getSignal(this, signalStorage, initialValue)\n\t\t\t\ts(typeof newValue === 'function' ? () => newValue : newValue)\n\t\t\t}\n\t\t}\n\t} else throw new InvalidDecorationError()\n}\n\nlet checkerQueued = false\n\n/**\n * This throws an error in some cases of an end dev forgetting to decorate a\n * class with `@reactive` if they used `@signal` on that class's fields.\n *\n * This doesn't work all the time, only when the very last class decorated is\n * missing @reactive, but something is better than nothing. There's another\n * similar check performed in the `@reactive` decorator.\n */\nfunction queueReactiveDecoratorChecker(props: Map) {\n\tif (checkerQueued) return\n\tcheckerQueued = true\n\n\tqueueMicrotask(() => {\n\t\tcheckerQueued = false\n\n\t\t// If the refs are still equal, it means @reactive did not run (forgot\n\t\t// to decorate a class that uses @signal with @reactive).\n\t\tif (props === __propsToSignalify) {\n\t\t\tthrow new Error(\n\t\t\t\t// Array.from(map.keys()) instead of [...map.keys()] because it breaks in Oculus browser.\n\t\t\t\t`Stray @signal-decorated properties detected: ${Array.from(props.keys()).join(\n\t\t\t\t\t', ',\n\t\t\t\t)}. Did you forget to use the \\`@reactive\\` decorator on a class that has properties decorated with \\`@signal\\`?`,\n\t\t\t)\n\t\t}\n\t})\n}\n\nclass PropNotFoundError extends Error {\n\tconstructor(prop: PropertyKey) {\n\t\tsuper(\n\t\t\t`Property \"${String(\n\t\t\t\tprop,\n\t\t\t)}\" not found on instance of class decorated with \\`@reactive\\`. Did you forget to use the \\`@reactive\\` decorator on one of your classes that has a \"${String(\n\t\t\t\tprop,\n\t\t\t)}\" property decorated with \\`@signal\\`?`,\n\t\t)\n\t}\n}\n\nclass MissingDecoratorError extends Error {\n\tconstructor(prop: PropertyKey) {\n\t\tsuper(\n\t\t\t`Missing @signal decorator on setter or getter for property \"${String(\n\t\t\t\tprop,\n\t\t\t)}\". The @signal decorator will only work on a getter/setter pair with *both* getter and setter decorated with @signal.`,\n\t\t)\n\t}\n}\n\nclass InvalidDecorationError extends Error {\n\tconstructor() {\n\t\tsuper('The @signal decorator is only for use on fields, getters, setters, and auto accessors.')\n\t}\n}\n"],"mappings":"AAAA,SAAQA,MAAM,QAAO,UAAU;AAC/B,SAAQC,WAAW,EAAEC,yBAAyB,EAAEC,sBAAsB,QAAO,iBAAiB;AAI9F,OAAO,IAAIC,kBAAkB,GAAG,IAAIC,GAAG,CAAoB,CAAC;AAE5D,OAAO,SAASC,uBAAuBA,CAAA,EAAG;EACzCF,kBAAkB,GAAG,IAAIC,GAAG,CAAoB,CAAC;AAClD;AAEA,MAAME,SAAS,GAAGC,MAAM,CAAC,CAAC;AAI1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,MAAMA,CACrBC,KAAc,EACdC,OAIgC,EAC1B;EACN,MAAM;IAACC,IAAI;IAAEC,IAAI;IAAEC;EAAQ,CAAC,GAAGH,OAAO;EACtC,MAAMI,KAAK,GAAGX,kBAAkB;EAEhC,IAAIO,OAAO,CAACK,MAAM,EAAE,MAAM,IAAIC,KAAK,CAAC,gDAAgD,CAAC;;EAErF;EACAC,6BAA6B,CAACH,KAAK,CAAC;EAEpC,IAAIH,IAAI,KAAK,OAAO,EAAE;IACrB,IAAID,OAAO,CAACQ,OAAO,IAAIN,IAAI,KAAK,WAAW,EAAE,MAAM,IAAII,KAAK,CAAC,iDAAiD,CAAC;IAE/G,IAAIJ,IAAI,KAAK,WAAW,EAAET,kBAAkB,GAAG,IAAIC,GAAG,CAAoB,CAAC,EAAC;IAAA,KACvEU,KAAK,CAACK,GAAG,CAACP,IAAI,EAAE;MAACQ,YAAY,EAAEC,SAAS;MAAEV;IAAI,CAAC,CAAC;IAErD,OAAO,UAAwBS,YAAqB,EAAE;MACrD,IAAIR,IAAI,KAAK,WAAW,EAAE;QACzB;QACA;QACA;QACA,MAAM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C;EACF;AACD;AAEA,MAAMoB,sBAAsB,SAAS3B,KAAK,CAAC;EAC1CiC,WAAWA,CAAA,EAAG;IACb,KAAK,CAAC,wFAAwF,CAAC;EAChG;AACD","ignoreList":[]} \ No newline at end of file diff --git a/dist/index.test.js b/dist/index.test.js index 33de2ac..e04655a 100644 --- a/dist/index.test.js +++ b/dist/index.test.js @@ -14,7 +14,7 @@ import { createSignalObject, reactive, signalify, createSignalFunction, signal, describe('classy-solid', () => { describe('createSignalObject()', () => { - it('has gettable and settable values via .get and .set methods', async () => { + it('has gettable and settable values via .get and .set methods', () => { const num = createSignalObject(0); // Set the variable's value by passing a value in. @@ -33,7 +33,7 @@ describe('classy-solid', () => { }); }); describe('createSignalFunction()', () => { - it('has gettable and settable values via a single overloaded function', async () => { + it('has gettable and settable values via a single overloaded function', () => { const num = createSignalFunction(0); // Set the variable's value by passing a value in. @@ -50,6 +50,14 @@ describe('classy-solid', () => { num(n => n + 1); expect(num()).toBe(3); }); + it('works with function values', () => { + const f1 = () => 123; + const func = createSignalFunction(f1); + expect(func()).toBe(f1); + const f2 = () => 456; + func(() => f2); + expect(func()).toBe(f2); + }); }); describe('createDeferredEffect()', () => { it('works', async () => { @@ -112,34 +120,174 @@ describe('classy-solid', () => { }); }); describe('@reactive, @signal', () => { - var _initClass, _init_colors, _initProto; + var _initClass, _init_colors, _initProto, _init_colors2, _init_wingSize, _init_finalize, _init_colors3, _init_finalize2, _initProto2, _init_colors4, _init_wingSize2, _init_finalize3, _initProto3, _initClass2, _init_colors5, _init_wingSize3, _initProto4, _init_colors6, _get_colors, _set_colors, _initProto5, _call_colors, _call_colors2, _initProto6; let _Butterfly; class Butterfly { static { ({ e: [_init_colors, _initProto], c: [_Butterfly, _initClass] - } = _applyDecs(this, [[signal, 3, "wingSize"], [signal, 0, "colors"]], [reactive])); + } = _applyDecs(this, [[signal, 3, "wingSize"], [signal, 4, "wingSize"], [signal, 0, "colors"]], [reactive])); } colors = (_initProto(this), _init_colors(this, 3)); - _wingSize = 2; + #wingSize = 2; get wingSize() { - return this._wingSize; + return this.#wingSize; } set wingSize(s) { - this._wingSize = s; + this.#wingSize = s; } static { _initClass(); } } - it('makes class fields reactive, using class and field/accessor decorators', () => { + it('makes class fields reactive, using class and field/getter/setter decorators', () => { const b = new _Butterfly(); testButterflyProps(b); }); + + // @reactive + class Butterfly2 { + static { + [_init_colors2, _init_wingSize, _init_finalize] = _applyDecs(this, [[signal, 0, "colors"], [signal, 0, "wingSize"], [signal, 0, "finalize", o => o.#finalize, (o, v) => o.#finalize = v]], [], 0, _ => #finalize in _).e; + } + colors = _init_colors2(this, 3); + wingSize = _init_wingSize(this, 2); + // @ts-ignore + #finalize = _init_finalize(this); + } + it('makes class fields reactive, using field decorators without class decorator', () => { + const b = new Butterfly2(); + testButterflyProps(b); + }); + class Butterfly3 { + static { + [_init_colors3, _init_finalize2, _initProto2] = _applyDecs(this, [[signal, 3, "wingSize"], [signal, 4, "wingSize"], [signal, 0, "colors"], [signal, 0, "finalize", o => o.#finalize, (o, v) => o.#finalize = v]], [], 0, _ => #finalize in _).e; + } + colors = (_initProto2(this), _init_colors3(this, 3)); + #wingSize = 2; + get wingSize() { + return this.#wingSize; + } + set wingSize(s) { + this.#wingSize = s; + } + + // @ts-ignore + #finalize = _init_finalize2(this); + } + it('makes class fields reactive, using field/getter/setter decorators without class decorator', () => { + const b = new Butterfly3(); + testButterflyProps(b); + }); + class Butterfly4 { + static { + [_init_wingSize2, _init_colors4, _init_finalize3, _initProto3] = _applyDecs(this, [[signal, 1, "wingSize"], [signal, 0, "colors"], [signal, 0, "finalize", o => o.#finalize, (o, v) => o.#finalize = v]], [], 0, _ => #finalize in _).e; + } + colors = (_initProto3(this), _init_colors4(this, 3)); + #A = _init_wingSize2(this, 2); // @ts-ignore + get wingSize() { + return this.#A; + } + set wingSize(v) { + this.#A = v; + } + #finalize = _init_finalize3(this); + } + it('makes class fields reactive, using field/accessor decorators without class decorator', () => { + const b = new Butterfly4(); + testButterflyProps(b); + }); + let _Butterfly2; + class Butterfly5 { + static { + ({ + e: [_init_wingSize3, _init_colors5, _initProto4], + c: [_Butterfly2, _initClass2] + } = _applyDecs(this, [[signal, 1, "wingSize"], [signal, 0, "colors"]], [reactive])); + } + colors = (_initProto4(this), _init_colors5(this, 3)); + #A = _init_wingSize3(this, 2); + get wingSize() { + return this.#A; + } + set wingSize(v) { + this.#A = v; + } + static { + _initClass2(); + } + } + it('makes class fields reactive, using field/accessor decorators with class decorator', () => { + const b = new _Butterfly2(); + testButterflyProps(b); + }); + class Butterfly6 { + static { + [_init_colors6, _get_colors, _set_colors, _initProto5] = _applyDecs(this, [[signal, 1, "colors", o => o.#A, (o, v) => o.#A = v]], [], 0, _ => #colors in _).e; + } + #A = (_initProto5(this), _init_colors6(this, 3)); + set #colors(v) { + _set_colors(this, v); + } + get #colors() { + return _get_colors(this); + } + getColors() { + return this.#colors; + } + setColors(v) { + return this.#colors = v; + } + } + it('makes private class auto accessor reactive', () => { + const b = new Butterfly6(); + testPrivate(b); + }); + class Butterfly7 { + static { + [_call_colors, _call_colors2, _initProto6] = _applyDecs(this, [[signal, 3, "colors", function () { + return this.#_colors; + }], [signal, 4, "colors", function (v) { + this.#_colors = v; + }]], [], 0, _ => #_colors in _).e; + } + constructor(...args) { + _initProto6(this); + } + #_colors = 3; + get #colors() { + return _call_colors(this); + } + set #colors(v) { + _call_colors2(this, v); + } + getColors() { + return this.#colors; + } + setColors(v) { + return this.#colors = v; + } + } + it('makes private class getter/setter accessors reactive', () => { + const b = new Butterfly7(); + testPrivate(b); + }); + function testPrivate(b) { + let count = 0; + createEffect(() => { + b.getColors(); + count++; + }); + expect(b.getColors()).toBe(3); + expect(count).toBe(1); + b.setColors(5); + expect(b.getColors()).toBe(5); + expect(count).toBe(2); + } const ensure = it; ensure('overridden fields work as expected', async () => { - var _initClass2, _init_colors2; + var _initClass3, _init_colors7; class Mid extends _Butterfly { colors = 0; } @@ -152,13 +300,13 @@ describe('classy-solid', () => { class SubButterfly extends Mid { static { ({ - e: [_init_colors2], - c: [_SubButterfly, _initClass2] + e: [_init_colors7], + c: [_SubButterfly, _initClass3] } = _applyDecs(this, [[signal, 0, "colors"]], [reactive], 0, void 0, Mid)); } - colors = _init_colors2(this, 123); + colors = _init_colors7(this, 123); static { - _initClass2(); + _initClass3(); } } @@ -189,49 +337,49 @@ describe('classy-solid', () => { expect(count).toBe(reactive ? 2 : 1); } it('does not prevent superclass constructor from receiving subclass constructor args', () => { - var _initClass3, _initClass4, _init_colors3, _initProto2, _Insect2; + var _initClass4, _initClass5, _init_colors8, _initProto7, _Insect2; let _Insect; class Insect { static { - [_Insect, _initClass3] = _applyDecs(this, [], [reactive]).c; + [_Insect, _initClass4] = _applyDecs(this, [], [reactive]).c; } constructor(double) { this.double = double; } static { - _initClass3(); + _initClass4(); } } - let _Butterfly2; + let _Butterfly3; class Butterfly extends (_Insect2 = _Insect) { static { ({ - e: [_init_colors3, _initProto2], - c: [_Butterfly2, _initClass4] - } = _applyDecs(this, [[signal, 3, "wingSize"], [signal, 0, "colors"]], [reactive], 0, void 0, _Insect2)); + e: [_init_colors8, _initProto7], + c: [_Butterfly3, _initClass5] + } = _applyDecs(this, [[signal, 3, "wingSize"], [signal, 4, "wingSize"], [signal, 0, "colors"]], [reactive], 0, void 0, _Insect2)); } - colors = (_initProto2(this), _init_colors3(this, 3)); - _wingSize = 2; + colors = (_initProto7(this), _init_colors8(this, 3)); + #wingSize = 2; get wingSize() { - return this._wingSize; + return this.#wingSize; } set wingSize(s) { - this._wingSize = s; + this.#wingSize = s; } constructor(arg) { super(arg * 2); } static { - _initClass4(); + _initClass5(); } } - const b = new _Butterfly2(4); + const b = new _Butterfly3(4); expect(b.double).toBe(8); testButterflyProps(b); }); it('throws an error when @signal is used without @reactive', async () => { expect(() => { - var _init_foo, _initClass5, _init_bar; + var _init_foo, _initClass6, _init_bar; // user forgot to use @reactive here class Foo { static { @@ -245,12 +393,12 @@ describe('classy-solid', () => { static { ({ e: [_init_bar], - c: [_Bar, _initClass5] + c: [_Bar, _initClass6] } = _applyDecs(this, [[signal, 0, "bar"]], [reactive])); } bar = _init_bar(this, 123); static { - _initClass5(); + _initClass6(); } } new _Bar(); @@ -283,7 +431,7 @@ describe('classy-solid', () => { // expect(err.message).toContain('Did you forget') }); it('works with function values', () => { - var _initClass6, _init_do; + var _initClass7, _init_do; let _Doer; // This test ensures that functions are handled propertly, because // if passed without being wrapped to a signal setter it will be @@ -294,12 +442,12 @@ describe('classy-solid', () => { static { ({ e: [_init_do], - c: [_Doer, _initClass6] + c: [_Doer, _initClass7] } = _applyDecs(this, [[signal, 0, "do"]], [reactive])); } do = _init_do(this, null); static { - _initClass6(); + _initClass7(); } } const doer = new _Doer(); @@ -310,18 +458,18 @@ describe('classy-solid', () => { expect(doer.do()).toBe(123); }); it('automatically does not track reactivity in constructors when using decorators', () => { - var _initClass7, _init_amount, _initClass8, _init_double, _Foo2; + var _initClass8, _init_amount, _initClass9, _init_double, _Foo2; let _Foo; class Foo { static { ({ e: [_init_amount], - c: [_Foo, _initClass7] + c: [_Foo, _initClass8] } = _applyDecs(this, [[signal, 0, "amount"]], [reactive])); } amount = _init_amount(this, 3); static { - _initClass7(); + _initClass8(); } } let _Bar2; @@ -329,7 +477,7 @@ describe('classy-solid', () => { static { ({ e: [_init_double], - c: [_Bar2, _initClass8] + c: [_Bar2, _initClass9] } = _applyDecs(this, [[signal, 0, "double"]], [reactive], 0, void 0, _Foo2)); } double = _init_double(this, 0); @@ -338,7 +486,7 @@ describe('classy-solid', () => { this.double = this.amount * 2; // this read of .amount should not be tracked } static { - _initClass8(); + _initClass9(); } } let b; @@ -422,12 +570,12 @@ describe('classy-solid', () => { it('makes class fields reactive, not using any decorators', () => { class Butterfly { colors = 3; - _wingSize = 2; + #wingSize = 2; get wingSize() { - return this._wingSize; + return this.#wingSize; } set wingSize(s) { - this._wingSize = s; + this.#wingSize = s; } constructor() { signalify(this, 'colors', 'wingSize'); @@ -443,15 +591,16 @@ describe('classy-solid', () => { }); it('makes constructor properties reactive, not using any decorators', () => { class Butterfly { + #wingSize; get wingSize() { - return this._wingSize; + return this.#wingSize; } set wingSize(s) { - this._wingSize = s; + this.#wingSize = s; } constructor() { this.colors = 3; - this._wingSize = 2; + this.#wingSize = 2; signalify(this, 'colors', 'wingSize'); } } @@ -637,13 +786,13 @@ describe('classy-solid', () => { }); describe('@component', () => { it('allows to define a class using class syntax', () => { - var _initClass9; + var _initClass10; let onMountCalled = false; let onCleanupCalled = false; let _CoolComp; class CoolComp { static { - [_CoolComp, _initClass9] = _applyDecs(this, [], [component]).c; + [_CoolComp, _initClass10] = _applyDecs(this, [], [component]).c; } onMount() { onMountCalled = true; @@ -656,7 +805,7 @@ describe('classy-solid', () => { return html`
hello classes!
`; } static { - _initClass9(); + _initClass10(); } } const root = document.createElement('div'); @@ -671,13 +820,13 @@ describe('classy-solid', () => { // throws on non-class use expect(() => { - var _initProto3; + var _initProto8; class CoolComp { static { - [_initProto3] = _applyDecs(this, [[component, 2, "onMount"]], []).e; + [_initProto8] = _applyDecs(this, [[component, 2, "onMount"]], []).e; } constructor(...args) { - _initProto3(this); + _initProto8(this); } // @ts-ignore onMount() {} @@ -686,13 +835,13 @@ describe('classy-solid', () => { }).toThrow('component decorator should only be used on a class'); }); it('works in tandem with @reactive and @signal for reactivity', async () => { - var _initClass10, _init_foo2, _init_bar2; + var _initClass11, _init_foo2, _init_bar2; let _CoolComp2; class CoolComp { static { ({ e: [_init_foo2, _init_bar2], - c: [_CoolComp2, _initClass10] + c: [_CoolComp2, _initClass11] } = _applyDecs(this, [[signal, 0, "foo"], [signal, 0, "bar"]], [component, reactive])); } foo = _init_foo2(this, 0); @@ -701,7 +850,7 @@ describe('classy-solid', () => { return html`
foo: ${() => this.foo}, bar: ${() => this.bar}
`; } static { - _initClass10(); + _initClass11(); } } const root = document.createElement('div'); @@ -752,13 +901,13 @@ describe('classy-solid', () => { // FIXME not working, the spread doesn't seem to do anything. xit('works with reactive spreads', async () => { - var _initClass11, _init_foo3, _init_bar3; + var _initClass12, _init_foo3, _init_bar3; let _CoolComp3; class CoolComp { static { ({ e: [_init_foo3, _init_bar3], - c: [_CoolComp3, _initClass11] + c: [_CoolComp3, _initClass12] } = _applyDecs(this, [[signal, 0, "foo"], [signal, 0, "bar"]], [component, reactive])); } foo = _init_foo3(this, 0); @@ -767,7 +916,7 @@ describe('classy-solid', () => { return html`
foo: ${() => this.foo}, bar: ${() => this.bar}
`; } static { - _initClass11(); + _initClass12(); } } const root = document.createElement('div'); @@ -802,14 +951,12 @@ function testButterflyProps(b, initialColors = 3) { }); expect(b.colors).toBe(initialColors, 'initial colors value'); expect(b.wingSize).toBe(2, 'initial wingSize value'); - expect(b._wingSize).toBe(2, 'ensure the original accessor works'); expect(count).toBe(1, 'Should be reactive'); b.colors++; expect(b.colors).toBe(initialColors + 1, 'incremented colors value'); expect(count).toBe(2, 'Should be reactive'); b.wingSize++; expect(b.wingSize).toBe(3, 'incremented wingSize value'); - expect(b._wingSize).toBe(3, 'ensure the original accessor works'); expect(count).toBe(3, 'Should be reactive'); } diff --git a/dist/index.test.js.map b/dist/index.test.js.map index f9cbc8a..746bb27 100644 --- a/dist/index.test.js.map +++ b/dist/index.test.js.map @@ -1 +1 @@ -{"version":3,"file":"index.test.js","names":["createComputed","createEffect","createRoot","createSignal","untrack","createMutable","render","html","createSignalObject","reactive","signalify","createSignalFunction","signal","createDeferredEffect","component","describe","it","num","set","expect","get","toBe","setResult","n","count","foo","runCount","stop","_stop","Promise","resolve","_initClass","_init_colors","_initProto","_Butterfly","Butterfly","e","c","_applyDecs","colors","_wingSize","wingSize","s","b","testButterflyProps","ensure","_initClass2","_init_colors2","Mid","b0","testProp","Object","getOwnPropertyDescriptor","call","_SubButterfly","SubButterfly","m","value","SubSubButterfly","b2","o","k","startVal","newVal","_initClass3","_initClass4","_init_colors3","_initProto2","_Insect2","_Insect","Insect","constructor","double","_Butterfly2","arg","_init_foo","_initClass5","_init_bar","Foo","_Bar","Bar","bar","toThrow","_initClass6","_init_do","_Doer","Doer","do","doer","newFunc","_initClass7","_init_amount","_initClass8","_init_double","_Foo2","_Foo","amount","_Bar2","noLoop","not","obj","obj2","butterfly","test","signalifyInitially","console","log","prototype","a","name","assign","create","countA","countB","_initClass9","onMountCalled","onCleanupCalled","_CoolComp","CoolComp","onMount","onCleanup","template","props","root","document","createElement","body","append","dispose","textContent","remove","_initProto3","args","_initClass10","_init_foo2","_init_bar2","_CoolComp2","setA","xit","_initClass11","_init_foo3","_init_bar3","_CoolComp3","initialColors","n1","num3","n3","undefined","num4","bool","b1","bool2","n4","func","fn","n5","func2","fn2","n6","stringOrFunc1","sf1","sf2","sf3","sf6","sf7","sf8","stringOrFunc2","sf9","sf10","sf11","sf12","sf13","sf14","sf15"],"sources":["../src/index.test.ts"],"sourcesContent":["import {createComputed, createEffect, createRoot, createSignal, untrack} from 'solid-js'\nimport {createMutable} from 'solid-js/store'\nimport {render} from 'solid-js/web'\nimport html from 'solid-js/html'\nimport {\n\tcreateSignalObject,\n\treactive,\n\tsignalify,\n\tcreateSignalFunction,\n\tsignal,\n\tcreateDeferredEffect,\n\tcomponent,\n} from './index.js'\n\n// TODO move type def to @lume/cli, map @types/jest's `expect` type into the\n// global env.\ndeclare global {\n\tfunction expect(...args: any[]): any\n}\n\ndescribe('classy-solid', () => {\n\tdescribe('createSignalObject()', () => {\n\t\tit('has gettable and settable values via .get and .set methods', async () => {\n\t\t\tconst num = createSignalObject(0)\n\n\t\t\t// Set the variable's value by passing a value in.\n\t\t\tnum.set(1)\n\t\t\t// Read the variable's value by calling it with no args.\n\t\t\texpect(num.get()).toBe(1)\n\n\t\t\t// increment example:\n\t\t\tconst setResult = num.set(num.get() + 1)\n\t\t\texpect(num.get()).toBe(2)\n\t\t\texpect(setResult).toBe(2)\n\n\t\t\t// Set with a function that accepts the previous value and returns the next value.\n\t\t\tnum.set(n => n + 1)\n\t\t\texpect(num.get()).toBe(3)\n\t\t})\n\t})\n\n\tdescribe('createSignalFunction()', () => {\n\t\tit('has gettable and settable values via a single overloaded function', async () => {\n\t\t\tconst num = createSignalFunction(0)\n\n\t\t\t// Set the variable's value by passing a value in.\n\t\t\tnum(1)\n\t\t\t// Read the variable's value by calling it with no args.\n\t\t\texpect(num()).toBe(1)\n\n\t\t\t// increment example:\n\t\t\tconst setResult = num(num() + 1)\n\t\t\texpect(num()).toBe(2)\n\t\t\texpect(setResult).toBe(2)\n\n\t\t\t// Set with a function that accepts the previous value and returns the next value.\n\t\t\tnum(n => n + 1)\n\t\t\texpect(num()).toBe(3)\n\t\t})\n\t})\n\n\tdescribe('createDeferredEffect()', () => {\n\t\tit('works', async () => {\n\t\t\tconst count = createSignalFunction(0)\n\t\t\tconst foo = createSignalFunction(0)\n\n\t\t\tlet runCount = 0\n\n\t\t\tconst stop = (() => {\n\t\t\t\tlet stop!: () => void\n\n\t\t\t\tcreateRoot(_stop => {\n\t\t\t\t\tstop = _stop\n\n\t\t\t\t\t// Runs once initially after the current root context just\n\t\t\t\t\t// like createEffect, then any time it re-runs due to a\n\t\t\t\t\t// change in a dependency, the re-run will be deferred in\n\t\t\t\t\t// the next microtask and will run only once (not once per\n\t\t\t\t\t// signal that changed)\n\t\t\t\t\tcreateDeferredEffect(() => {\n\t\t\t\t\t\tcount()\n\t\t\t\t\t\tfoo()\n\t\t\t\t\t\trunCount++\n\t\t\t\t\t})\n\t\t\t\t})\n\n\t\t\t\treturn stop\n\t\t\t})()\n\n\t\t\t// Queues the effect to run in the next microtask\n\t\t\tcount(1)\n\t\t\tcount(2)\n\t\t\tfoo(3)\n\n\t\t\t// Still 1 because the deferred effect didn't run yet, it will in the next microtask.\n\t\t\texpect(runCount).toBe(1)\n\n\t\t\tawait Promise.resolve()\n\n\t\t\t// It ran only once in the previous microtask (batched), not once per signal write.\n\t\t\texpect(runCount).toBe(2)\n\n\t\t\tcount(3)\n\t\t\tcount(4)\n\t\t\tfoo(5)\n\n\t\t\texpect(runCount).toBe(2)\n\n\t\t\tawait Promise.resolve()\n\n\t\t\texpect(runCount).toBe(3)\n\n\t\t\t// Stops the effect from re-running. It can now be garbage collected.\n\t\t\tstop()\n\n\t\t\tcount(3)\n\t\t\tcount(4)\n\t\t\tfoo(5)\n\n\t\t\texpect(runCount).toBe(3)\n\n\t\t\tawait Promise.resolve()\n\n\t\t\t// Still the same because it was stopped, so it didn't run in the\n\t\t\t// macrotask prior to the await.\n\t\t\texpect(runCount).toBe(3)\n\n\t\t\t// Double check just in case (the wrong implementation would make it\n\t\t\t// skip two microtasks before running).\n\t\t\tawait Promise.resolve()\n\t\t\texpect(runCount).toBe(3)\n\t\t})\n\t})\n\n\tdescribe('@reactive, @signal', () => {\n\t\t@reactive\n\t\tclass Butterfly {\n\t\t\t@signal colors = 3\n\n\t\t\t_wingSize = 2\n\n\t\t\t@signal\n\t\t\tget wingSize() {\n\t\t\t\treturn this._wingSize\n\t\t\t}\n\t\t\tset wingSize(s: number) {\n\t\t\t\tthis._wingSize = s\n\t\t\t}\n\t\t}\n\n\t\tit('makes class fields reactive, using class and field/accessor decorators', () => {\n\t\t\tconst b = new Butterfly()\n\n\t\t\ttestButterflyProps(b)\n\t\t})\n\n\t\tconst ensure = it\n\n\t\tensure('overridden fields work as expected', async () => {\n\t\t\tclass Mid extends Butterfly {\n\t\t\t\toverride colors = 0\n\t\t\t}\n\n\t\t\t// ensure subclass did not interfere with functionality of base class\n\t\t\tconst b0 = new Butterfly()\n\t\t\ttestProp(b0, 'colors', 3, 4, true)\n\t\t\texpect(Object.getOwnPropertyDescriptor(b0, 'colors')?.get?.call(b0) === 4).toBe(true) // accessor descriptor\n\n\t\t\t@reactive\n\t\t\tclass SubButterfly extends Mid {\n\t\t\t\t@signal override colors = 123\n\t\t\t}\n\n\t\t\t// ensure subclass did not interfere with functionality of base class\n\t\t\tconst m = new Mid()\n\t\t\ttestProp(m, 'colors', 0, 1, false)\n\t\t\texpect(Object.getOwnPropertyDescriptor(m, 'colors')?.value === 1).toBe(true) // value descriptor\n\n\t\t\tclass SubSubButterfly extends SubButterfly {\n\t\t\t\toverride colors = 456\n\t\t\t}\n\n\t\t\tconst b = new SubButterfly()\n\t\t\ttestButterflyProps(b, 123)\n\n\t\t\tconst b2 = new SubSubButterfly()\n\n\t\t\ttestProp(b2, 'colors', 456, 654, false)\n\t\t})\n\n\t\tfunction testProp(o: T, k: keyof T, startVal: any, newVal: any, reactive = true) {\n\t\t\tlet count = 0\n\n\t\t\tcreateEffect(() => {\n\t\t\t\to[k]\n\t\t\t\tcount++\n\t\t\t})\n\n\t\t\texpect(o[k]).toBe(startVal)\n\t\t\texpect(count).toBe(1)\n\n\t\t\to[k] = newVal // should not be a signal, should not trigger\n\n\t\t\texpect(o[k]).toBe(newVal)\n\t\t\texpect(count).toBe(reactive ? 2 : 1)\n\t\t}\n\n\t\tit('does not prevent superclass constructor from receiving subclass constructor args', () => {\n\t\t\t@reactive\n\t\t\tclass Insect {\n\t\t\t\tconstructor(public double: number) {}\n\t\t\t}\n\n\t\t\t@reactive\n\t\t\tclass Butterfly extends Insect {\n\t\t\t\t@signal colors = 3\n\n\t\t\t\t_wingSize = 2\n\n\t\t\t\t@signal\n\t\t\t\tget wingSize() {\n\t\t\t\t\treturn this._wingSize\n\t\t\t\t}\n\t\t\t\tset wingSize(s: number) {\n\t\t\t\t\tthis._wingSize = s\n\t\t\t\t}\n\n\t\t\t\tconstructor(arg: number) {\n\t\t\t\t\tsuper(arg * 2)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst b = new Butterfly(4)\n\n\t\t\texpect(b.double).toBe(8)\n\t\t\ttestButterflyProps(b)\n\t\t})\n\n\t\tit('throws an error when @signal is used without @reactive', async () => {\n\t\t\texpect(() => {\n\t\t\t\t// user forgot to use @reactive here\n\t\t\t\tclass Foo {\n\t\t\t\t\t@signal foo = 'hoo'\n\t\t\t\t}\n\n\t\t\t\tFoo\n\n\t\t\t\t@reactive\n\t\t\t\tclass Bar {\n\t\t\t\t\t@signal bar = 123\n\t\t\t\t}\n\n\t\t\t\tnew Bar()\n\t\t\t}).toThrow('Did you forget')\n\n\t\t\t// TODO how to check for an error thrown from a microtask?\n\t\t\t// (window.addEventListener('error') seems not to work)\n\t\t\t//\n\t\t\t// It just won't work, the error seems to never fire here in the\n\t\t\t// tests, but it works fine when testing manually in Chrome.\n\n\t\t\t// const errPromise = new Promise(r => window.addEventListener('error', e => r(e), {once: true}))\n\n\t\t\t// @reactive\n\t\t\t// class Foo {\n\t\t\t// \t@signal foo = 'hoo'\n\t\t\t// }\n\n\t\t\t// Foo\n\n\t\t\t// // user forgot to use @reactive here\n\t\t\t// class Bar {\n\t\t\t// \t@signal bar = 123\n\t\t\t// }\n\n\t\t\t// Bar\n\n\t\t\t// const err = await errPromise\n\n\t\t\t// expect(err.message).toContain('Did you forget')\n\t\t})\n\n\t\tit('works with function values', () => {\n\t\t\t// This test ensures that functions are handled propertly, because\n\t\t\t// if passed without being wrapped to a signal setter it will be\n\t\t\t// called immediately with the previous value and be expected to\n\t\t\t// return a new value, instead of being set as the actual new value.\n\n\t\t\t@reactive\n\t\t\tclass Doer {\n\t\t\t\t@signal do: (() => unknown) | null = null\n\t\t\t}\n\n\t\t\tconst doer = new Doer()\n\n\t\t\texpect(doer.do).toBe(null)\n\n\t\t\tconst newFunc = () => 123\n\t\t\tdoer.do = newFunc\n\n\t\t\texpect(doer.do).toBe(newFunc)\n\t\t\texpect(doer.do()).toBe(123)\n\t\t})\n\n\t\tit('automatically does not track reactivity in constructors when using decorators', () => {\n\t\t\t@reactive\n\t\t\tclass Foo {\n\t\t\t\t@signal amount = 3\n\t\t\t}\n\n\t\t\t@reactive\n\t\t\tclass Bar extends Foo {\n\t\t\t\t@signal double = 0\n\n\t\t\t\tconstructor() {\n\t\t\t\t\tsuper()\n\t\t\t\t\tthis.double = this.amount * 2 // this read of .amount should not be tracked\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet b: Bar\n\t\t\tlet count = 0\n\n\t\t\tfunction noLoop() {\n\t\t\t\tcreateEffect(() => {\n\t\t\t\t\tb = new Bar() // this should not track\n\t\t\t\t\tcount++\n\t\t\t\t})\n\t\t\t}\n\n\t\t\texpect(noLoop).not.toThrow()\n\n\t\t\tconst b2 = b!\n\n\t\t\tb!.amount = 4 // hence this should not trigger\n\n\t\t\t// If the effect ran only once initially, not when setting b.colors,\n\t\t\t// then both variables should reference the same instance\n\t\t\texpect(count).toBe(1)\n\t\t\texpect(b!).toBe(b2)\n\t\t})\n\t})\n\n\tdescribe('signalify()', () => {\n\t\tit('returns the same object that was passed in', () => {\n\t\t\tlet obj = {n: 123}\n\t\t\tlet obj2 = signalify(obj, 'n')\n\t\t\texpect(obj).toBe(obj2)\n\n\t\t\tobj = createMutable({n: 123})\n\t\t\tobj2 = signalify(obj, 'n')\n\t\t\texpect(obj).toBe(obj2)\n\t\t})\n\n\t\tdescribe('making objects reactive with signalify()', () => {\n\t\t\tit('', () => {\n\t\t\t\tconst butterfly = {\n\t\t\t\t\tcolors: 3,\n\n\t\t\t\t\t_wingSize: 2,\n\n\t\t\t\t\tget wingSize() {\n\t\t\t\t\t\treturn this._wingSize\n\t\t\t\t\t},\n\t\t\t\t\tset wingSize(s: number) {\n\t\t\t\t\t\tthis._wingSize = s\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\tconst b = signalify(butterfly, 'colors', 'wingSize')\n\n\t\t\t\ttestButterflyProps(b)\n\n\t\t\t\t// quick type check:\n\t\t\t\t// @ts-expect-error \"foo\" is not a property on butterfly\n\t\t\t\tsignalify(butterfly, 'colors', 'wingSize', 'foo')\n\t\t\t})\n\n\t\t\tit('is not tracked inside of an effect to prevent loops', () => {\n\t\t\t\ttest(true)\n\t\t\t\ttest(false)\n\n\t\t\t\tfunction test(signalifyInitially: boolean) {\n\t\t\t\t\t// Library author provides obj\n\t\t\t\t\tconst obj = {n: 123}\n\t\t\t\t\tif (signalifyInitially) signalify(obj, 'n') // library author might signalify obj.n\n\n\t\t\t\t\t// User code:\n\t\t\t\t\tcreateEffect(() => {\n\t\t\t\t\t\t// o.n may or may not already be signalified, user does not know, but they want to be sure they can react to its changes.\n\t\t\t\t\t\tsignalify(obj, 'n')\n\n\t\t\t\t\t\tobj.n = 123 // does not make an infinite loop\n\n\t\t\t\t\t\t// A deeper effect will be reading the property.\n\t\t\t\t\t\tcreateEffect(() => {\n\t\t\t\t\t\t\tconsole.log(obj.n)\n\t\t\t\t\t\t})\n\t\t\t\t\t})\n\n\t\t\t\t\t// No expectations in this test, the test passes if a maximum\n\t\t\t\t\t// callstack size error (infinite loop) does not happen.\n\t\t\t\t}\n\t\t\t})\n\t\t})\n\n\t\tdescribe('making reactive classes with signalify instead of with decorators', () => {\n\t\t\tit('makes class fields reactive, not using any decorators', () => {\n\t\t\t\tclass Butterfly {\n\t\t\t\t\tcolors = 3\n\n\t\t\t\t\t_wingSize = 2\n\n\t\t\t\t\tget wingSize() {\n\t\t\t\t\t\treturn this._wingSize\n\t\t\t\t\t}\n\t\t\t\t\tset wingSize(s: number) {\n\t\t\t\t\t\tthis._wingSize = s\n\t\t\t\t\t}\n\n\t\t\t\t\tconstructor() {\n\t\t\t\t\t\tsignalify(this, 'colors', 'wingSize')\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst b = new Butterfly()\n\n\t\t\t\ttestButterflyProps(b)\n\n\t\t\t\t// quick type check:\n\t\t\t\tconst b2 = new Butterfly()\n\t\t\t\t// @ts-expect-error \"foo\" is not a property on Butterfly\n\t\t\t\tsignalify(b2, 'colors', 'wingSize', 'foo')\n\t\t\t})\n\n\t\t\tit('makes constructor properties reactive, not using any decorators', () => {\n\t\t\t\tclass Butterfly {\n\t\t\t\t\tdeclare colors: number\n\n\t\t\t\t\tdeclare _wingSize: number\n\n\t\t\t\t\tget wingSize() {\n\t\t\t\t\t\treturn this._wingSize\n\t\t\t\t\t}\n\t\t\t\t\tset wingSize(s: number) {\n\t\t\t\t\t\tthis._wingSize = s\n\t\t\t\t\t}\n\n\t\t\t\t\tconstructor() {\n\t\t\t\t\t\tthis.colors = 3\n\t\t\t\t\t\tthis._wingSize = 2\n\n\t\t\t\t\t\tsignalify(this, 'colors', 'wingSize')\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst b = new Butterfly()\n\n\t\t\t\ttestButterflyProps(b)\n\t\t\t})\n\n\t\t\tit('works with a function-style class, with signalify in the constructor', () => {\n\t\t\t\tfunction Butterfly() {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tthis.colors = 3\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tthis._wingSize = 2\n\n\t\t\t\t\t// @ts-ignore no type checking for ES5-style classes.\n\t\t\t\t\tsignalify(this, 'colors', 'wingSize')\n\t\t\t\t}\n\n\t\t\t\tButterfly.prototype = {\n\t\t\t\t\tget wingSize() {\n\t\t\t\t\t\treturn this._wingSize\n\t\t\t\t\t},\n\t\t\t\t\tset wingSize(s: number) {\n\t\t\t\t\t\tthis._wingSize = s\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\t// @ts-ignore\n\t\t\t\tconst b = new Butterfly()\n\t\t\t\ttestButterflyProps(b)\n\t\t\t})\n\n\t\t\tit('works with a function-style class, with properties on the prototype, and signalify in constructor', () => {\n\t\t\t\tfunction Butterfly() {\n\t\t\t\t\t// @ts-ignore no type checking for ES5-style classes.\n\t\t\t\t\tsignalify(this, 'colors', 'wingSize')\n\t\t\t\t}\n\n\t\t\t\tButterfly.prototype = {\n\t\t\t\t\tcolors: 3,\n\t\t\t\t\t_wingSize: 2,\n\n\t\t\t\t\tget wingSize() {\n\t\t\t\t\t\treturn this._wingSize\n\t\t\t\t\t},\n\t\t\t\t\tset wingSize(s: number) {\n\t\t\t\t\t\tthis._wingSize = s\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\t// @ts-ignore no type checking for ES5-style classes.\n\t\t\t\tconst b = new Butterfly()\n\t\t\t\ttestButterflyProps(b)\n\t\t\t})\n\n\t\t\tit('can be used on a function-style class, with properties on the prototype, and signalify on the prototype', () => {\n\t\t\t\tfunction Butterfly() {}\n\n\t\t\t\tButterfly.prototype = {\n\t\t\t\t\tcolors: 3,\n\t\t\t\t\t_wingSize: 2,\n\n\t\t\t\t\tget wingSize() {\n\t\t\t\t\t\treturn this._wingSize\n\t\t\t\t\t},\n\t\t\t\t\tset wingSize(s: number) {\n\t\t\t\t\t\tthis._wingSize = s\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\tsignalify(Butterfly.prototype, 'colors', 'wingSize')\n\n\t\t\t\t// @ts-ignore no type checking for ES5-style classes.\n\t\t\t\tconst b = new Butterfly()\n\t\t\t\ttestButterflyProps(b)\n\t\t\t})\n\n\t\t\tit('can be used on a function-style class, with properties in the constructor, and signalify on the prototype', () => {\n\t\t\t\tfunction Butterfly() {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tthis.colors = 3\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tthis._wingSize = 2\n\t\t\t\t}\n\n\t\t\t\tButterfly.prototype = {\n\t\t\t\t\tget wingSize() {\n\t\t\t\t\t\treturn this._wingSize\n\t\t\t\t\t},\n\t\t\t\t\tset wingSize(s: number) {\n\t\t\t\t\t\tthis._wingSize = s\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\tsignalify(Butterfly.prototype, 'colors', 'wingSize')\n\n\t\t\t\t// @ts-ignore\n\t\t\t\tconst b = new Butterfly()\n\t\t\t\ttestButterflyProps(b)\n\t\t\t})\n\n\t\t\tit('show that signalify causes constructor to be reactive when used manually instead of decorators', () => {\n\t\t\t\tclass Foo {\n\t\t\t\t\tamount = 3\n\n\t\t\t\t\tconstructor() {\n\t\t\t\t\t\tsignalify(this, 'amount')\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tclass Bar extends Foo {\n\t\t\t\t\tdouble = 0\n\n\t\t\t\t\tconstructor() {\n\t\t\t\t\t\tsuper()\n\t\t\t\t\t\tsignalify(this, 'double')\n\t\t\t\t\t\tthis.double = this.amount * 2 // this tracks access of .amount\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlet count = 0\n\t\t\t\tlet b!: Bar\n\n\t\t\t\tcreateEffect(() => {\n\t\t\t\t\tb = new Bar() // tracks .amount\n\t\t\t\t\tcount++\n\t\t\t\t})\n\n\t\t\t\texpect(count).toBe(1)\n\n\t\t\t\tb.amount = 4 // triggers\n\n\t\t\t\texpect(count).toBe(2)\n\t\t\t})\n\n\t\t\tit('show how to manually untrack constructors when not using decorators', () => {\n\t\t\t\tclass Foo {\n\t\t\t\t\tamount = 3\n\n\t\t\t\t\tconstructor() {\n\t\t\t\t\t\tsignalify(this, 'amount')\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tclass Bar extends Foo {\n\t\t\t\t\tdouble = 0\n\n\t\t\t\t\tconstructor() {\n\t\t\t\t\t\tsuper()\n\t\t\t\t\t\tsignalify(this, 'double')\n\n\t\t\t\t\t\tuntrack(() => {\n\t\t\t\t\t\t\tthis.double = this.amount * 2\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlet count = 0\n\t\t\t\tlet b!: Bar\n\n\t\t\t\tcreateEffect(() => {\n\t\t\t\t\tb = new Bar() // does not track .amount\n\t\t\t\t\tcount++\n\t\t\t\t})\n\n\t\t\t\texpect(count).toBe(1)\n\n\t\t\t\tb.amount = 4 // will not trigger\n\n\t\t\t\texpect(count).toBe(1)\n\t\t\t})\n\t\t})\n\n\t\tit('creates signal storage per descriptor+object pair, not per descriptor', () => {\n\t\t\t// This ensures we don't accidentally share a signal with multiple\n\t\t\t// objects. For example, we don't want a single signal per descriptor\n\t\t\t// because if the descriptor is on a prototype object, then that single\n\t\t\t// signal will erroneously be used by all objects extending from that\n\t\t\t// prototype.\n\n\t\t\tconst a = signalify({foo: 0, name: 'a'}, 'foo')\n\t\t\tconst b = Object.assign(Object.create(a) as typeof a, {name: 'b'})\n\n\t\t\texpect(a.foo).toBe(0)\n\t\t\texpect(b.foo).toBe(0)\n\n\t\t\tlet countA = 0\n\n\t\t\tcreateEffect(() => {\n\t\t\t\ta.foo\n\t\t\t\tcountA++\n\t\t\t})\n\n\t\t\tlet countB = 0\n\n\t\t\tcreateEffect(() => {\n\t\t\t\tb.foo\n\t\t\t\tcountB++\n\t\t\t})\n\n\t\t\texpect(countA).toBe(1)\n\t\t\texpect(countB).toBe(1)\n\n\t\t\ta.foo++\n\n\t\t\texpect(a.foo).toBe(1)\n\t\t\texpect(countA).toBe(2)\n\n\t\t\t// ensure that updating a's foo property did not update b's foo\n\t\t\t// property or trigger b's effect, despite that the property is\n\t\t\t// defined in a single location on the prototype.\n\t\t\t// @ts-ignore\n\t\t\texpect(b.foo).toBe(0)\n\t\t\texpect(countB).toBe(1)\n\t\t})\n\t})\n\n\tdescribe('@component', () => {\n\t\tit('allows to define a class using class syntax', () => {\n\t\t\tlet onMountCalled = false\n\t\t\tlet onCleanupCalled = false\n\n\t\t\t@component\n\t\t\tclass CoolComp {\n\t\t\t\tonMount() {\n\t\t\t\t\tonMountCalled = true\n\t\t\t\t}\n\n\t\t\t\tonCleanup() {\n\t\t\t\t\tonCleanupCalled = true\n\t\t\t\t}\n\n\t\t\t\ttemplate(props: any) {\n\t\t\t\t\texpect(props.foo).toBe(123)\n\t\t\t\t\treturn html`
hello classes!
`\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst root = document.createElement('div')\n\t\t\tdocument.body.append(root)\n\n\t\t\tconst dispose = render(() => html`<${CoolComp} foo=${123} />`, root)\n\n\t\t\texpect(root.textContent).toBe('hello classes!')\n\t\t\texpect(onMountCalled).toBe(true)\n\t\t\texpect(onCleanupCalled).toBe(false)\n\n\t\t\tdispose()\n\t\t\troot.remove()\n\n\t\t\texpect(onCleanupCalled).toBe(true)\n\n\t\t\t// throws on non-class use\n\t\t\texpect(() => {\n\t\t\t\tclass CoolComp {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t@component\n\t\t\t\t\tonMount() {}\n\t\t\t\t}\n\t\t\t\tCoolComp\n\t\t\t}).toThrow('component decorator should only be used on a class')\n\t\t})\n\n\t\tit('works in tandem with @reactive and @signal for reactivity', async () => {\n\t\t\t@component\n\t\t\t@reactive\n\t\t\tclass CoolComp {\n\t\t\t\t@signal foo = 0\n\t\t\t\t@signal bar = 0\n\n\t\t\t\ttemplate() {\n\t\t\t\t\treturn html`
foo: ${() => this.foo}, bar: ${() => this.bar}
`\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst root = document.createElement('div')\n\t\t\tdocument.body.append(root)\n\n\t\t\tconst [a, setA] = createSignal(1)\n\t\t\tconst b = createSignalFunction(2)\n\n\t\t\t// FIXME Why do we need `() => b()` instead of just `b` here? Does `html`\n\t\t\t// check the `length` of the function and do something based on\n\t\t\t// that? Or does it get passed to a @signal property's setter and\n\t\t\t// receives the previous value?\n\t\t\tconst dispose = render(() => html`<${CoolComp} foo=${a} bar=${() => b()} />`, root)\n\n\t\t\texpect(root.textContent).toBe('foo: 1, bar: 2')\n\n\t\t\tsetA(3)\n\t\t\tb(4)\n\n\t\t\texpect(root.textContent).toBe('foo: 3, bar: 4')\n\n\t\t\tdispose()\n\t\t\troot.remove()\n\t\t})\n\n\t\tit('works without decorators', () => {\n\t\t\tconst CoolComp = component(\n\t\t\t\tclass CoolComp {\n\t\t\t\t\tfoo = 0\n\t\t\t\t\tbar = 0\n\n\t\t\t\t\tconstructor() {\n\t\t\t\t\t\tsignalify(this)\n\t\t\t\t\t}\n\n\t\t\t\t\ttemplate() {\n\t\t\t\t\t\treturn html`
foo: ${() => this.foo}, bar: ${() => this.bar}
`\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t)\n\n\t\t\tconst root = document.createElement('div')\n\t\t\tdocument.body.append(root)\n\n\t\t\tconst [a, setA] = createSignal(1)\n\t\t\tconst b = createSignalFunction(2)\n\n\t\t\t// FIXME Why do we need `() => b()` instead of just `b` here? Does `html`\n\t\t\t// check the `length` of the function and do something based on\n\t\t\t// that? Or does it get passed to a @signal property's setter and\n\t\t\t// receives the previous value?\n\t\t\tconst dispose = render(() => html`<${CoolComp} foo=${a} bar=${() => b()} />`, root)\n\n\t\t\texpect(root.textContent).toBe('foo: 1, bar: 2')\n\n\t\t\tsetA(3)\n\t\t\tb(4)\n\n\t\t\texpect(root.textContent).toBe('foo: 3, bar: 4')\n\n\t\t\tdispose()\n\t\t\troot.remove()\n\t\t})\n\n\t\t// FIXME not working, the spread doesn't seem to do anything.\n\t\txit('works with reactive spreads', async () => {\n\t\t\t@component\n\t\t\t@reactive\n\t\t\tclass CoolComp {\n\t\t\t\t@signal foo = 0\n\t\t\t\t@signal bar = 0\n\n\t\t\t\ttemplate() {\n\t\t\t\t\treturn html`
foo: ${() => this.foo}, bar: ${() => this.bar}
`\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst root = document.createElement('div')\n\t\t\tdocument.body.append(root)\n\n\t\t\tlet o = createMutable({o: {foo: 123}})\n\n\t\t\t// neither of these work\n\t\t\t// const dispose = render(() => html`<${CoolComp} ...${() => o.o} />`, root)\n\t\t\tconst dispose = render(() => html`<${CoolComp} ...${o.o} />`, root)\n\n\t\t\texpect(root.textContent).toBe('foo: 123, bar: 0')\n\n\t\t\to.o = {bar: 456}\n\n\t\t\texpect(root.textContent).toBe('foo: 123, bar: 456')\n\n\t\t\tdispose()\n\t\t\troot.remove()\n\t\t})\n\t})\n})\n\nfunction testButterflyProps(b: {colors: number; wingSize: number; _wingSize: number}, initialColors = 3) {\n\tlet count = 0\n\n\tcreateRoot(() => {\n\t\tcreateComputed(() => {\n\t\t\tb.colors\n\t\t\tb.wingSize\n\t\t\tcount++\n\t\t})\n\t})\n\n\texpect(b.colors).toBe(initialColors, 'initial colors value')\n\texpect(b.wingSize).toBe(2, 'initial wingSize value')\n\texpect(b._wingSize).toBe(2, 'ensure the original accessor works')\n\texpect(count).toBe(1, 'Should be reactive')\n\n\tb.colors++\n\n\texpect(b.colors).toBe(initialColors + 1, 'incremented colors value')\n\texpect(count).toBe(2, 'Should be reactive')\n\n\tb.wingSize++\n\n\texpect(b.wingSize).toBe(3, 'incremented wingSize value')\n\texpect(b._wingSize).toBe(3, 'ensure the original accessor works')\n\texpect(count).toBe(3, 'Should be reactive')\n}\n\n//////////////////////////////////////////////////////////////////////////\n// createSignalObject type tests ///////////////////////////////////////\n//////////////////////////////////////////////////////////////////////////\n\n{\n\tconst num = createSignalObject(1)\n\tlet n1: number = num.get()\n\tn1\n\tnum.set(123)\n\tnum.set(n => (n1 = n + 1))\n\t// @ts-expect-error Expected 1 arguments, but got 0. ts(2554)\n\tnum.set()\n\n\tconst num3 = createSignalObject()\n\t// @ts-expect-error Type 'undefined' is not assignable to type 'number'. ts(2322)\n\tlet n3: number = num3.get()\n\tnum3.set(123)\n\tnum3.set(undefined) // ok, accepts undefined\n\t// @ts-expect-error Object is possibly 'undefined'. ts(2532) (the `n` value)\n\tnum3.set(n => (n3 = n + 1))\n\t// num3.set() // ok, accepts undefined // FIXME broke in Solid 1.7.9\n\n\t// @ts-expect-error Argument of type 'boolean' is not assignable to parameter of type 'number'. ts(2345)\n\tconst num4 = createSignalObject(true)\n\n\tconst bool = createSignalObject(true)\n\tlet b1: boolean = bool.get()\n\tb1\n\tbool.set(false)\n\tbool.set(b => (b1 = !b))\n\t// @ts-expect-error Expected 1 arguments, but got 0. ts(2554)\n\tbool.set()\n\n\tconst bool2 = createSignalObject()\n\t// @ts-expect-error Type 'undefined' is not assignable to type 'number'. ts(2322)\n\tlet n4: boolean = bool2.get()\n\tbool2.set(false)\n\tbool2.set(undefined) // ok, accepts undefined\n\tbool2.set(n => (n4 = !n)) // ok because undefined is being converted to boolean\n\t// @ts-expect-error Type 'boolean | undefined' is not assignable to type 'boolean'. ts(2322)\n\tbool2.set(n => (n4 = n))\n\t// bool2.set() // ok, accepts undefined // FIXME try Solid 1.7.9\n\n\tconst func = createSignalObject(() => 1)\n\t// @ts-expect-error 1 is not assignable to function (no overload matches)\n\tfunc.set(() => 1)\n\tfunc.set(() => (): 1 => 1) // ok, set the value to a function\n\tconst fn: () => 1 = func.get() // ok, returns function value\n\tfn\n\tconst n5: 1 = func.get()()\n\tn5\n\n\tconst func2 = createSignalObject<() => number>(() => 1)\n\t// @FIXME-ts-expect-error number is not assignable to function (no overload matches)\n\tfunc2.set(() => 1) // FIXME should be a type error. Try Solid 1.7.9\n\tfunc2.set(() => () => 1) // ok, set the value to a function\n\tconst fn2: () => number = func2.get() // ok, returns function value\n\tfn2\n\tconst n6: number = func2.get()()\n\tn6\n\n\tconst stringOrFunc1 = createSignalObject<(() => number) | string>('')\n\t// @FIXME-ts-expect-error number not assignable to string | (()=>number) | undefined\n\tstringOrFunc1.set(() => 1) // FIXME should be a type error. Try Solid 1.7.9\n\t// @ts-expect-error FIXME try Solid 1.7.9\n\tconst sf1: () => number = stringOrFunc1.set(() => () => 1)\n\tsf1\n\t// @ts-expect-error FIXME try Solid 1.7.9\n\tconst sf2: string = stringOrFunc1.set('oh yeah')\n\tsf2\n\t// @ts-expect-error FIXME try Solid 1.7.9\n\tconst sf3: string = stringOrFunc1.set(() => 'oh yeah')\n\tsf3\n\t// @ts-expect-error cannot set signal to undefined\n\tstringOrFunc1.set()\n\t// @ts-expect-error cannot set signal to undefined\n\tstringOrFunc1.set(undefined)\n\t// @ts-expect-error return value might be string\n\tconst sf6: () => number = stringOrFunc1.get()\n\tsf6\n\tconst sf7: (() => number) | string | undefined = stringOrFunc1.get()\n\tsf7\n\tconst sf8: (() => number) | string = stringOrFunc1.get()\n\tsf8\n\n\tconst stringOrFunc2 = createSignalObject<(() => number) | string>()\n\t// @FIXME-ts-expect-error number not assignable to string | (()=>number) | undefined\n\tstringOrFunc2.set(() => 1) // FIXME should be a type error. Try Solid 1.7.9\n\t// @ts-expect-error FIXME try Solid 1.7.9\n\tconst sf9: () => number = stringOrFunc2.set(() => () => 1)\n\tsf9\n\t// @ts-expect-error FIXME try Solid 1.7.9\n\tconst sf10: string = stringOrFunc2.set('oh yeah')\n\tsf10\n\t// @ts-expect-error FIXME try Solid 1.7.9\n\tconst sf11: string = stringOrFunc2.set(() => 'oh yeah')\n\tsf11\n\t// @ts-expect-error FIXME try Solid 1.7.9\n\tconst sf12: undefined = stringOrFunc2.set()\n\tsf12\n\t// @ts-expect-error FIXME try Solid 1.7.9\n\tconst sf13: undefined = stringOrFunc2.set(undefined)\n\tsf13\n\tconst sf14: (() => number) | string | undefined = stringOrFunc2.get()\n\tsf14\n\t// @ts-expect-error return value might be undefined\n\tconst sf15: (() => number) | string = stringOrFunc2.get()\n\tsf15\n}\n\n//////////////////////////////////////////////////////////////////////////\n// createSignalFunction type tests ///////////////////////////////////////\n//////////////////////////////////////////////////////////////////////////\n\n{\n\tconst num = createSignalFunction(1)\n\tlet n1: number = num()\n\tn1\n\tnum(123)\n\tnum(n => (n1 = n + 1))\n\tnum()\n\n\tconst num3 = createSignalFunction()\n\t// @ts-expect-error Type 'undefined' is not assignable to type 'number'. ts(2322)\n\tlet n3: number = num3()\n\tnum3(123)\n\tnum3(undefined) // ok, accepts undefined\n\t// @ts-expect-error Object is possibly 'undefined'. ts(2532) (the `n` value)\n\tnum3(n => (n3 = n + 1))\n\tnum3() // ok, getter\n\n\t// @ts-expect-error Argument of type 'boolean' is not assignable to parameter of type 'number'. ts(2345)\n\tconst num4 = createSignalFunction(true)\n\n\tconst bool = createSignalFunction(true)\n\tlet b1: boolean = bool()\n\tb1\n\tbool(false)\n\tbool(b => (b1 = !b))\n\tbool()\n\n\tconst bool2 = createSignalFunction()\n\t// @ts-expect-error Type 'undefined' is not assignable to type 'number'. ts(2322)\n\tlet n4: boolean = bool2()\n\tbool2(false)\n\tbool2(undefined) // ok, accepts undefined\n\tbool2(n => (n4 = !n)) // ok because undefined is being converted to boolean\n\t// @ts-expect-error Type 'boolean | undefined' is not assignable to type 'boolean'. ts(2322)\n\tbool2(n => (n4 = n))\n\tbool2() // ok, accepts undefined\n\n\tconst func = createSignalFunction(() => 1)\n\t// @ts-expect-error 1 is not assignable to function (no overload matches)\n\tfunc(() => 1)\n\tfunc(() => (): 1 => 1) // ok, set the value to a function\n\tconst fn: () => 1 = func() // ok, returns function value\n\tfn\n\tconst n5: 1 = func()()\n\tn5\n\n\tconst func2 = createSignalFunction<() => number>(() => 1)\n\t// @ts-expect-error number is not assignable to function (no overload matches)\n\tfunc2(() => 1)\n\tfunc2(() => () => 1) // ok, set the value to a function\n\tconst fn2: () => number = func2() // ok, returns function value\n\tfn2\n\tconst n6: number = func2()()\n\tn6\n\n\tconst stringOrFunc1 = createSignalFunction<(() => number) | string>('')\n\t// @ts-expect-error number not assignable to string | (()=>number) | undefined\n\tstringOrFunc1(() => 1)\n\tconst sf1: () => number = stringOrFunc1(() => () => 1)\n\tsf1\n\tconst sf2: string = stringOrFunc1('oh yeah')\n\tsf2\n\tconst sf3: string = stringOrFunc1(() => 'oh yeah')\n\tsf3\n\tstringOrFunc1() // ok, getter\n\t// @ts-expect-error cannot set signal to undefined\n\tstringOrFunc1(undefined)\n\t// @ts-expect-error return value might be string\n\tconst sf6: () => number = stringOrFunc1()\n\tsf6\n\tconst sf7: (() => number) | string | undefined = stringOrFunc1()\n\tsf7\n\tconst sf8: (() => number) | string = stringOrFunc1()\n\tsf8\n\n\tconst stringOrFunc2 = createSignalFunction<(() => number) | string>()\n\t// @ts-expect-error number not assignable to string | (()=>number) | undefined\n\tstringOrFunc2(() => 1)\n\tconst sf9: () => number = stringOrFunc2(() => () => 1)\n\tsf9\n\tconst sf10: string = stringOrFunc2('oh yeah')\n\tsf10\n\tconst sf11: string = stringOrFunc2(() => 'oh yeah')\n\tsf11\n\t// @ts-expect-error 'string | (() => number) | undefined' is not assignable to type 'undefined'.\n\tconst sf12: undefined = stringOrFunc2()\n\tsf12\n\tconst sf13: undefined = stringOrFunc2(undefined)\n\tsf13\n\tconst sf14: (() => number) | string | undefined = stringOrFunc2()\n\tsf14\n\t// @ts-expect-error return value might be undefined\n\tconst sf15: (() => number) | string = stringOrFunc2()\n\tsf15\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CAAC;EAChEK,GAAG;EACH,MAAMC,GAA4B,GAAGN,aAAa,CAAC,CAAC;EACpDM,GAAG;EAEH,MAAMC,aAAa,GAAG3J,oBAAoB,CAA0B,CAAC;EACrE;EACA2J,aAAa,CAAC,MAAM,CAAC,CAAC;EACtB,MAAMC,GAAiB,GAAGD,aAAa,CAAC,MAAM,MAAM,CAAC,CAAC;EACtDC,GAAG;EACH,MAAMC,IAAY,GAAGF,aAAa,CAAC,SAAS,CAAC;EAC7CE,IAAI;EACJ,MAAMC,IAAY,GAAGH,aAAa,CAAC,MAAM,SAAS,CAAC;EACnDG,IAAI;EACJ;EACA,MAAMC,IAAe,GAAGJ,aAAa,CAAC,CAAC;EACvCI,IAAI;EACJ,MAAMC,IAAe,GAAGL,aAAa,CAACnB,SAAS,CAAC;EAChDwB,IAAI;EACJ,MAAMC,IAAyC,GAAGN,aAAa,CAAC,CAAC;EACjEM,IAAI;EACJ;EACA,MAAMC,IAA6B,GAAGP,aAAa,CAAC,CAAC;EACrDO,IAAI;AACL","ignoreList":[]} \ No newline at end of file +{"version":3,"file":"index.test.js","names":["createComputed","createEffect","createRoot","createSignal","untrack","createMutable","render","html","createSignalObject","reactive","signalify","createSignalFunction","signal","createDeferredEffect","component","describe","it","num","set","expect","get","toBe","setResult","n","f1","func","f2","count","foo","runCount","stop","_stop","Promise","resolve","_initClass","_init_colors","_initProto","_init_colors2","_init_wingSize","_init_finalize","_init_colors3","_init_finalize2","_initProto2","_init_colors4","_init_wingSize2","_init_finalize3","_initProto3","_initClass2","_init_colors5","_init_wingSize3","_initProto4","_init_colors6","_get_colors","_set_colors","_initProto5","_call_colors","_call_colors2","_initProto6","_Butterfly","Butterfly","e","c","_applyDecs","colors","wingSize","s","b","testButterflyProps","Butterfly2","o","finalize","v","_","Butterfly3","Butterfly4","A","_Butterfly2","Butterfly5","Butterfly6","#colors","getColors","setColors","testPrivate","Butterfly7","_colors","constructor","args","ensure","_initClass3","_init_colors7","Mid","b0","testProp","Object","getOwnPropertyDescriptor","call","_SubButterfly","SubButterfly","m","value","SubSubButterfly","b2","k","startVal","newVal","_initClass4","_initClass5","_init_colors8","_initProto7","_Insect2","_Insect","Insect","double","_Butterfly3","arg","_init_foo","_initClass6","_init_bar","Foo","_Bar","Bar","bar","toThrow","_initClass7","_init_do","_Doer","Doer","do","doer","newFunc","_initClass8","_init_amount","_initClass9","_init_double","_Foo2","_Foo","amount","_Bar2","noLoop","not","obj","obj2","butterfly","_wingSize","test","signalifyInitially","console","log","prototype","a","name","assign","create","countA","countB","_initClass10","onMountCalled","onCleanupCalled","_CoolComp","CoolComp","onMount","onCleanup","template","props","root","document","createElement","body","append","dispose","textContent","remove","_initProto8","_initClass11","_init_foo2","_init_bar2","_CoolComp2","setA","xit","_initClass12","_init_foo3","_init_bar3","_CoolComp3","initialColors","n1","num3","n3","undefined","num4","bool","b1","bool2","n4","fn","n5","func2","fn2","n6","stringOrFunc1","sf1","sf2","sf3","sf6","sf7","sf8","stringOrFunc2","sf9","sf10","sf11","sf12","sf13","sf14","sf15"],"sources":["../src/index.test.ts"],"sourcesContent":["import {createComputed, createEffect, createRoot, createSignal, untrack} from 'solid-js'\nimport {createMutable} from 'solid-js/store'\nimport {render} from 'solid-js/web'\nimport html from 'solid-js/html'\nimport {\n\tcreateSignalObject,\n\treactive,\n\tsignalify,\n\tcreateSignalFunction,\n\tsignal,\n\tcreateDeferredEffect,\n\tcomponent,\n} from './index.js'\n\n// TODO move type def to @lume/cli, map @types/jest's `expect` type into the\n// global env.\ndeclare global {\n\tfunction expect(...args: any[]): any\n}\n\ndescribe('classy-solid', () => {\n\tdescribe('createSignalObject()', () => {\n\t\tit('has gettable and settable values via .get and .set methods', () => {\n\t\t\tconst num = createSignalObject(0)\n\n\t\t\t// Set the variable's value by passing a value in.\n\t\t\tnum.set(1)\n\t\t\t// Read the variable's value by calling it with no args.\n\t\t\texpect(num.get()).toBe(1)\n\n\t\t\t// increment example:\n\t\t\tconst setResult = num.set(num.get() + 1)\n\t\t\texpect(num.get()).toBe(2)\n\t\t\texpect(setResult).toBe(2)\n\n\t\t\t// Set with a function that accepts the previous value and returns the next value.\n\t\t\tnum.set(n => n + 1)\n\t\t\texpect(num.get()).toBe(3)\n\t\t})\n\t})\n\n\tdescribe('createSignalFunction()', () => {\n\t\tit('has gettable and settable values via a single overloaded function', () => {\n\t\t\tconst num = createSignalFunction(0)\n\n\t\t\t// Set the variable's value by passing a value in.\n\t\t\tnum(1)\n\t\t\t// Read the variable's value by calling it with no args.\n\t\t\texpect(num()).toBe(1)\n\n\t\t\t// increment example:\n\t\t\tconst setResult = num(num() + 1)\n\t\t\texpect(num()).toBe(2)\n\t\t\texpect(setResult).toBe(2)\n\n\t\t\t// Set with a function that accepts the previous value and returns the next value.\n\t\t\tnum(n => n + 1)\n\t\t\texpect(num()).toBe(3)\n\t\t})\n\n\t\tit('works with function values', () => {\n\t\t\tconst f1 = () => 123\n\t\t\tconst func = createSignalFunction(f1)\n\n\t\t\texpect(func()).toBe(f1)\n\n\t\t\tconst f2 = () => 456\n\t\t\tfunc(() => f2)\n\n\t\t\texpect(func()).toBe(f2)\n\t\t})\n\t})\n\n\tdescribe('createDeferredEffect()', () => {\n\t\tit('works', async () => {\n\t\t\tconst count = createSignalFunction(0)\n\t\t\tconst foo = createSignalFunction(0)\n\n\t\t\tlet runCount = 0\n\n\t\t\tconst stop = (() => {\n\t\t\t\tlet stop!: () => void\n\n\t\t\t\tcreateRoot(_stop => {\n\t\t\t\t\tstop = _stop\n\n\t\t\t\t\t// Runs once initially after the current root context just\n\t\t\t\t\t// like createEffect, then any time it re-runs due to a\n\t\t\t\t\t// change in a dependency, the re-run will be deferred in\n\t\t\t\t\t// the next microtask and will run only once (not once per\n\t\t\t\t\t// signal that changed)\n\t\t\t\t\tcreateDeferredEffect(() => {\n\t\t\t\t\t\tcount()\n\t\t\t\t\t\tfoo()\n\t\t\t\t\t\trunCount++\n\t\t\t\t\t})\n\t\t\t\t})\n\n\t\t\t\treturn stop\n\t\t\t})()\n\n\t\t\t// Queues the effect to run in the next microtask\n\t\t\tcount(1)\n\t\t\tcount(2)\n\t\t\tfoo(3)\n\n\t\t\t// Still 1 because the deferred effect didn't run yet, it will in the next microtask.\n\t\t\texpect(runCount).toBe(1)\n\n\t\t\tawait Promise.resolve()\n\n\t\t\t// It ran only once in the previous microtask (batched), not once per signal write.\n\t\t\texpect(runCount).toBe(2)\n\n\t\t\tcount(3)\n\t\t\tcount(4)\n\t\t\tfoo(5)\n\n\t\t\texpect(runCount).toBe(2)\n\n\t\t\tawait Promise.resolve()\n\n\t\t\texpect(runCount).toBe(3)\n\n\t\t\t// Stops the effect from re-running. It can now be garbage collected.\n\t\t\tstop()\n\n\t\t\tcount(3)\n\t\t\tcount(4)\n\t\t\tfoo(5)\n\n\t\t\texpect(runCount).toBe(3)\n\n\t\t\tawait Promise.resolve()\n\n\t\t\t// Still the same because it was stopped, so it didn't run in the\n\t\t\t// macrotask prior to the await.\n\t\t\texpect(runCount).toBe(3)\n\n\t\t\t// Double check just in case (the wrong implementation would make it\n\t\t\t// skip two microtasks before running).\n\t\t\tawait Promise.resolve()\n\t\t\texpect(runCount).toBe(3)\n\t\t})\n\t})\n\n\tdescribe('@reactive, @signal', () => {\n\t\t@reactive\n\t\tclass Butterfly {\n\t\t\t@signal colors = 3\n\n\t\t\t#wingSize = 2\n\n\t\t\t@signal get wingSize() {\n\t\t\t\treturn this.#wingSize\n\t\t\t}\n\t\t\t@signal set wingSize(s: number) {\n\t\t\t\tthis.#wingSize = s\n\t\t\t}\n\t\t}\n\n\t\tit('makes class fields reactive, using class and field/getter/setter decorators', () => {\n\t\t\tconst b = new Butterfly()\n\n\t\t\ttestButterflyProps(b)\n\t\t})\n\n\t\t// @reactive\n\t\tclass Butterfly2 {\n\t\t\t@signal colors = 3\n\t\t\t@signal wingSize = 2\n\t\t\t// @ts-ignore\n\t\t\t@signal #finalize\n\t\t}\n\n\t\tit('makes class fields reactive, using field decorators without class decorator', () => {\n\t\t\tconst b = new Butterfly2()\n\n\t\t\ttestButterflyProps(b)\n\t\t})\n\n\t\tclass Butterfly3 {\n\t\t\t@signal colors = 3\n\n\t\t\t#wingSize = 2\n\n\t\t\t@signal get wingSize() {\n\t\t\t\treturn this.#wingSize\n\t\t\t}\n\t\t\t@signal set wingSize(s: number) {\n\t\t\t\tthis.#wingSize = s\n\t\t\t}\n\n\t\t\t// @ts-ignore\n\t\t\t@signal #finalize\n\t\t}\n\n\t\tit('makes class fields reactive, using field/getter/setter decorators without class decorator', () => {\n\t\t\tconst b = new Butterfly3()\n\n\t\t\ttestButterflyProps(b)\n\t\t})\n\n\t\tclass Butterfly4 {\n\t\t\t@signal colors = 3\n\t\t\t@signal accessor wingSize = 2\n\t\t\t// @ts-ignore\n\t\t\t@signal #finalize\n\t\t}\n\n\t\tit('makes class fields reactive, using field/accessor decorators without class decorator', () => {\n\t\t\tconst b = new Butterfly4()\n\n\t\t\ttestButterflyProps(b)\n\t\t})\n\n\t\t@reactive\n\t\tclass Butterfly5 {\n\t\t\t@signal colors = 3\n\t\t\t@signal accessor wingSize = 2\n\t\t}\n\n\t\tit('makes class fields reactive, using field/accessor decorators with class decorator', () => {\n\t\t\tconst b = new Butterfly5()\n\n\t\t\ttestButterflyProps(b)\n\t\t})\n\n\t\tclass Butterfly6 {\n\t\t\t@signal accessor #colors = 3\n\n\t\t\tgetColors() {\n\t\t\t\treturn this.#colors\n\t\t\t}\n\t\t\tsetColors(v: number) {\n\t\t\t\treturn (this.#colors = v)\n\t\t\t}\n\t\t}\n\n\t\tit('makes private class auto accessor reactive', () => {\n\t\t\tconst b = new Butterfly6()\n\t\t\ttestPrivate(b)\n\t\t})\n\n\t\tclass Butterfly7 {\n\t\t\t#_colors = 3\n\n\t\t\t@signal get #colors() {\n\t\t\t\treturn this.#_colors\n\t\t\t}\n\t\t\t@signal set #colors(v: number) {\n\t\t\t\tthis.#_colors = v\n\t\t\t}\n\n\t\t\tgetColors() {\n\t\t\t\treturn this.#colors\n\t\t\t}\n\t\t\tsetColors(v: number) {\n\t\t\t\treturn (this.#colors = v)\n\t\t\t}\n\t\t}\n\n\t\tit('makes private class getter/setter accessors reactive', () => {\n\t\t\tconst b = new Butterfly7()\n\t\t\ttestPrivate(b)\n\t\t})\n\n\t\tfunction testPrivate(b: Pick) {\n\t\t\tlet count = 0\n\n\t\t\tcreateEffect(() => {\n\t\t\t\tb.getColors()\n\t\t\t\tcount++\n\t\t\t})\n\n\t\t\texpect(b.getColors()).toBe(3)\n\t\t\texpect(count).toBe(1)\n\n\t\t\tb.setColors(5)\n\t\t\texpect(b.getColors()).toBe(5)\n\t\t\texpect(count).toBe(2)\n\t\t}\n\n\t\tconst ensure = it\n\n\t\tensure('overridden fields work as expected', async () => {\n\t\t\tclass Mid extends Butterfly {\n\t\t\t\toverride colors = 0\n\t\t\t}\n\n\t\t\t// ensure subclass did not interfere with functionality of base class\n\t\t\tconst b0 = new Butterfly()\n\t\t\ttestProp(b0, 'colors', 3, 4, true)\n\t\t\texpect(Object.getOwnPropertyDescriptor(b0, 'colors')?.get?.call(b0) === 4).toBe(true) // accessor descriptor\n\n\t\t\t@reactive\n\t\t\tclass SubButterfly extends Mid {\n\t\t\t\t@signal override colors = 123\n\t\t\t}\n\n\t\t\t// ensure subclass did not interfere with functionality of base class\n\t\t\tconst m = new Mid()\n\t\t\ttestProp(m, 'colors', 0, 1, false)\n\t\t\texpect(Object.getOwnPropertyDescriptor(m, 'colors')?.value === 1).toBe(true) // value descriptor\n\n\t\t\tclass SubSubButterfly extends SubButterfly {\n\t\t\t\toverride colors = 456\n\t\t\t}\n\n\t\t\tconst b = new SubButterfly()\n\t\t\ttestButterflyProps(b, 123)\n\n\t\t\tconst b2 = new SubSubButterfly()\n\n\t\t\ttestProp(b2, 'colors', 456, 654, false)\n\t\t})\n\n\t\tfunction testProp(o: T, k: keyof T, startVal: any, newVal: any, reactive = true) {\n\t\t\tlet count = 0\n\n\t\t\tcreateEffect(() => {\n\t\t\t\to[k]\n\t\t\t\tcount++\n\t\t\t})\n\n\t\t\texpect(o[k]).toBe(startVal)\n\t\t\texpect(count).toBe(1)\n\n\t\t\to[k] = newVal // should not be a signal, should not trigger\n\n\t\t\texpect(o[k]).toBe(newVal)\n\t\t\texpect(count).toBe(reactive ? 2 : 1)\n\t\t}\n\n\t\tit('does not prevent superclass constructor from receiving subclass constructor args', () => {\n\t\t\t@reactive\n\t\t\tclass Insect {\n\t\t\t\tconstructor(public double: number) {}\n\t\t\t}\n\n\t\t\t@reactive\n\t\t\tclass Butterfly extends Insect {\n\t\t\t\t@signal colors = 3\n\n\t\t\t\t#wingSize = 2\n\n\t\t\t\t@signal get wingSize() {\n\t\t\t\t\treturn this.#wingSize\n\t\t\t\t}\n\t\t\t\t@signal set wingSize(s: number) {\n\t\t\t\t\tthis.#wingSize = s\n\t\t\t\t}\n\n\t\t\t\tconstructor(arg: number) {\n\t\t\t\t\tsuper(arg * 2)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst b = new Butterfly(4)\n\n\t\t\texpect(b.double).toBe(8)\n\t\t\ttestButterflyProps(b)\n\t\t})\n\n\t\tit('throws an error when @signal is used without @reactive', async () => {\n\t\t\texpect(() => {\n\t\t\t\t// user forgot to use @reactive here\n\t\t\t\tclass Foo {\n\t\t\t\t\t@signal foo = 'hoo'\n\t\t\t\t}\n\n\t\t\t\tFoo\n\n\t\t\t\t@reactive\n\t\t\t\tclass Bar {\n\t\t\t\t\t@signal bar = 123\n\t\t\t\t}\n\n\t\t\t\tnew Bar()\n\t\t\t}).toThrow('Did you forget')\n\n\t\t\t// TODO how to check for an error thrown from a microtask?\n\t\t\t// (window.addEventListener('error') seems not to work)\n\t\t\t//\n\t\t\t// It just won't work, the error seems to never fire here in the\n\t\t\t// tests, but it works fine when testing manually in Chrome.\n\n\t\t\t// const errPromise = new Promise(r => window.addEventListener('error', e => r(e), {once: true}))\n\n\t\t\t// @reactive\n\t\t\t// class Foo {\n\t\t\t// \t@signal foo = 'hoo'\n\t\t\t// }\n\n\t\t\t// Foo\n\n\t\t\t// // user forgot to use @reactive here\n\t\t\t// class Bar {\n\t\t\t// \t@signal bar = 123\n\t\t\t// }\n\n\t\t\t// Bar\n\n\t\t\t// const err = await errPromise\n\n\t\t\t// expect(err.message).toContain('Did you forget')\n\t\t})\n\n\t\tit('works with function values', () => {\n\t\t\t// This test ensures that functions are handled propertly, because\n\t\t\t// if passed without being wrapped to a signal setter it will be\n\t\t\t// called immediately with the previous value and be expected to\n\t\t\t// return a new value, instead of being set as the actual new value.\n\n\t\t\t@reactive\n\t\t\tclass Doer {\n\t\t\t\t@signal do: (() => unknown) | null = null\n\t\t\t}\n\n\t\t\tconst doer = new Doer()\n\n\t\t\texpect(doer.do).toBe(null)\n\n\t\t\tconst newFunc = () => 123\n\t\t\tdoer.do = newFunc\n\n\t\t\texpect(doer.do).toBe(newFunc)\n\t\t\texpect(doer.do()).toBe(123)\n\t\t})\n\n\t\tit('automatically does not track reactivity in constructors when using decorators', () => {\n\t\t\t@reactive\n\t\t\tclass Foo {\n\t\t\t\t@signal amount = 3\n\t\t\t}\n\n\t\t\t@reactive\n\t\t\tclass Bar extends Foo {\n\t\t\t\t@signal double = 0\n\n\t\t\t\tconstructor() {\n\t\t\t\t\tsuper()\n\t\t\t\t\tthis.double = this.amount * 2 // this read of .amount should not be tracked\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet b: Bar\n\t\t\tlet count = 0\n\n\t\t\tfunction noLoop() {\n\t\t\t\tcreateEffect(() => {\n\t\t\t\t\tb = new Bar() // this should not track\n\t\t\t\t\tcount++\n\t\t\t\t})\n\t\t\t}\n\n\t\t\texpect(noLoop).not.toThrow()\n\n\t\t\tconst b2 = b!\n\n\t\t\tb!.amount = 4 // hence this should not trigger\n\n\t\t\t// If the effect ran only once initially, not when setting b.colors,\n\t\t\t// then both variables should reference the same instance\n\t\t\texpect(count).toBe(1)\n\t\t\texpect(b!).toBe(b2)\n\t\t})\n\t})\n\n\tdescribe('signalify()', () => {\n\t\tit('returns the same object that was passed in', () => {\n\t\t\tlet obj = {n: 123}\n\t\t\tlet obj2 = signalify(obj, 'n')\n\t\t\texpect(obj).toBe(obj2)\n\n\t\t\tobj = createMutable({n: 123})\n\t\t\tobj2 = signalify(obj, 'n')\n\t\t\texpect(obj).toBe(obj2)\n\t\t})\n\n\t\tdescribe('making objects reactive with signalify()', () => {\n\t\t\tit('', () => {\n\t\t\t\tconst butterfly = {\n\t\t\t\t\tcolors: 3,\n\n\t\t\t\t\t_wingSize: 2,\n\n\t\t\t\t\tget wingSize() {\n\t\t\t\t\t\treturn this._wingSize\n\t\t\t\t\t},\n\t\t\t\t\tset wingSize(s: number) {\n\t\t\t\t\t\tthis._wingSize = s\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\tconst b = signalify(butterfly, 'colors', 'wingSize')\n\n\t\t\t\ttestButterflyProps(b)\n\n\t\t\t\t// quick type check:\n\t\t\t\t// @ts-expect-error \"foo\" is not a property on butterfly\n\t\t\t\tsignalify(butterfly, 'colors', 'wingSize', 'foo')\n\t\t\t})\n\n\t\t\tit('is not tracked inside of an effect to prevent loops', () => {\n\t\t\t\ttest(true)\n\t\t\t\ttest(false)\n\n\t\t\t\tfunction test(signalifyInitially: boolean) {\n\t\t\t\t\t// Library author provides obj\n\t\t\t\t\tconst obj = {n: 123}\n\t\t\t\t\tif (signalifyInitially) signalify(obj, 'n') // library author might signalify obj.n\n\n\t\t\t\t\t// User code:\n\t\t\t\t\tcreateEffect(() => {\n\t\t\t\t\t\t// o.n may or may not already be signalified, user does not know, but they want to be sure they can react to its changes.\n\t\t\t\t\t\tsignalify(obj, 'n')\n\n\t\t\t\t\t\tobj.n = 123 // does not make an infinite loop\n\n\t\t\t\t\t\t// A deeper effect will be reading the property.\n\t\t\t\t\t\tcreateEffect(() => {\n\t\t\t\t\t\t\tconsole.log(obj.n)\n\t\t\t\t\t\t})\n\t\t\t\t\t})\n\n\t\t\t\t\t// No expectations in this test, the test passes if a maximum\n\t\t\t\t\t// callstack size error (infinite loop) does not happen.\n\t\t\t\t}\n\t\t\t})\n\t\t})\n\n\t\tdescribe('making reactive classes with signalify instead of with decorators', () => {\n\t\t\tit('makes class fields reactive, not using any decorators', () => {\n\t\t\t\tclass Butterfly {\n\t\t\t\t\tcolors = 3\n\n\t\t\t\t\t#wingSize = 2\n\n\t\t\t\t\tget wingSize() {\n\t\t\t\t\t\treturn this.#wingSize\n\t\t\t\t\t}\n\t\t\t\t\tset wingSize(s: number) {\n\t\t\t\t\t\tthis.#wingSize = s\n\t\t\t\t\t}\n\n\t\t\t\t\tconstructor() {\n\t\t\t\t\t\tsignalify(this, 'colors', 'wingSize')\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst b = new Butterfly()\n\n\t\t\t\ttestButterflyProps(b)\n\n\t\t\t\t// quick type check:\n\t\t\t\tconst b2 = new Butterfly()\n\t\t\t\t// @ts-expect-error \"foo\" is not a property on Butterfly\n\t\t\t\tsignalify(b2, 'colors', 'wingSize', 'foo')\n\t\t\t})\n\n\t\t\tit('makes constructor properties reactive, not using any decorators', () => {\n\t\t\t\tclass Butterfly {\n\t\t\t\t\tdeclare colors: number\n\n\t\t\t\t\t#wingSize: number\n\n\t\t\t\t\tget wingSize() {\n\t\t\t\t\t\treturn this.#wingSize\n\t\t\t\t\t}\n\t\t\t\t\tset wingSize(s: number) {\n\t\t\t\t\t\tthis.#wingSize = s\n\t\t\t\t\t}\n\n\t\t\t\t\tconstructor() {\n\t\t\t\t\t\tthis.colors = 3\n\t\t\t\t\t\tthis.#wingSize = 2\n\n\t\t\t\t\t\tsignalify(this, 'colors', 'wingSize')\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst b = new Butterfly()\n\n\t\t\t\ttestButterflyProps(b)\n\t\t\t})\n\n\t\t\tit('works with a function-style class, with signalify in the constructor', () => {\n\t\t\t\tfunction Butterfly() {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tthis.colors = 3\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tthis._wingSize = 2\n\n\t\t\t\t\t// @ts-ignore no type checking for ES5-style classes.\n\t\t\t\t\tsignalify(this, 'colors', 'wingSize')\n\t\t\t\t}\n\n\t\t\t\tButterfly.prototype = {\n\t\t\t\t\tget wingSize() {\n\t\t\t\t\t\treturn this._wingSize\n\t\t\t\t\t},\n\t\t\t\t\tset wingSize(s: number) {\n\t\t\t\t\t\tthis._wingSize = s\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\t// @ts-ignore\n\t\t\t\tconst b = new Butterfly()\n\t\t\t\ttestButterflyProps(b)\n\t\t\t})\n\n\t\t\tit('works with a function-style class, with properties on the prototype, and signalify in constructor', () => {\n\t\t\t\tfunction Butterfly() {\n\t\t\t\t\t// @ts-ignore no type checking for ES5-style classes.\n\t\t\t\t\tsignalify(this, 'colors', 'wingSize')\n\t\t\t\t}\n\n\t\t\t\tButterfly.prototype = {\n\t\t\t\t\tcolors: 3,\n\t\t\t\t\t_wingSize: 2,\n\n\t\t\t\t\tget wingSize() {\n\t\t\t\t\t\treturn this._wingSize\n\t\t\t\t\t},\n\t\t\t\t\tset wingSize(s: number) {\n\t\t\t\t\t\tthis._wingSize = s\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\t// @ts-ignore no type checking for ES5-style classes.\n\t\t\t\tconst b = new Butterfly()\n\t\t\t\ttestButterflyProps(b)\n\t\t\t})\n\n\t\t\tit('can be used on a function-style class, with properties on the prototype, and signalify on the prototype', () => {\n\t\t\t\tfunction Butterfly() {}\n\n\t\t\t\tButterfly.prototype = {\n\t\t\t\t\tcolors: 3,\n\t\t\t\t\t_wingSize: 2,\n\n\t\t\t\t\tget wingSize() {\n\t\t\t\t\t\treturn this._wingSize\n\t\t\t\t\t},\n\t\t\t\t\tset wingSize(s: number) {\n\t\t\t\t\t\tthis._wingSize = s\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\tsignalify(Butterfly.prototype, 'colors', 'wingSize')\n\n\t\t\t\t// @ts-ignore no type checking for ES5-style classes.\n\t\t\t\tconst b = new Butterfly()\n\t\t\t\ttestButterflyProps(b)\n\t\t\t})\n\n\t\t\tit('can be used on a function-style class, with properties in the constructor, and signalify on the prototype', () => {\n\t\t\t\tfunction Butterfly() {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tthis.colors = 3\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tthis._wingSize = 2\n\t\t\t\t}\n\n\t\t\t\tButterfly.prototype = {\n\t\t\t\t\tget wingSize() {\n\t\t\t\t\t\treturn this._wingSize\n\t\t\t\t\t},\n\t\t\t\t\tset wingSize(s: number) {\n\t\t\t\t\t\tthis._wingSize = s\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\tsignalify(Butterfly.prototype, 'colors', 'wingSize')\n\n\t\t\t\t// @ts-ignore\n\t\t\t\tconst b = new Butterfly()\n\t\t\t\ttestButterflyProps(b)\n\t\t\t})\n\n\t\t\tit('show that signalify causes constructor to be reactive when used manually instead of decorators', () => {\n\t\t\t\tclass Foo {\n\t\t\t\t\tamount = 3\n\n\t\t\t\t\tconstructor() {\n\t\t\t\t\t\tsignalify(this, 'amount')\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tclass Bar extends Foo {\n\t\t\t\t\tdouble = 0\n\n\t\t\t\t\tconstructor() {\n\t\t\t\t\t\tsuper()\n\t\t\t\t\t\tsignalify(this, 'double')\n\t\t\t\t\t\tthis.double = this.amount * 2 // this tracks access of .amount\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlet count = 0\n\t\t\t\tlet b!: Bar\n\n\t\t\t\tcreateEffect(() => {\n\t\t\t\t\tb = new Bar() // tracks .amount\n\t\t\t\t\tcount++\n\t\t\t\t})\n\n\t\t\t\texpect(count).toBe(1)\n\n\t\t\t\tb.amount = 4 // triggers\n\n\t\t\t\texpect(count).toBe(2)\n\t\t\t})\n\n\t\t\tit('show how to manually untrack constructors when not using decorators', () => {\n\t\t\t\tclass Foo {\n\t\t\t\t\tamount = 3\n\n\t\t\t\t\tconstructor() {\n\t\t\t\t\t\tsignalify(this, 'amount')\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tclass Bar extends Foo {\n\t\t\t\t\tdouble = 0\n\n\t\t\t\t\tconstructor() {\n\t\t\t\t\t\tsuper()\n\t\t\t\t\t\tsignalify(this, 'double')\n\n\t\t\t\t\t\tuntrack(() => {\n\t\t\t\t\t\t\tthis.double = this.amount * 2\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlet count = 0\n\t\t\t\tlet b!: Bar\n\n\t\t\t\tcreateEffect(() => {\n\t\t\t\t\tb = new Bar() // does not track .amount\n\t\t\t\t\tcount++\n\t\t\t\t})\n\n\t\t\t\texpect(count).toBe(1)\n\n\t\t\t\tb.amount = 4 // will not trigger\n\n\t\t\t\texpect(count).toBe(1)\n\t\t\t})\n\t\t})\n\n\t\tit('creates signal storage per descriptor+object pair, not per descriptor', () => {\n\t\t\t// This ensures we don't accidentally share a signal with multiple\n\t\t\t// objects. For example, we don't want a single signal per descriptor\n\t\t\t// because if the descriptor is on a prototype object, then that single\n\t\t\t// signal will erroneously be used by all objects extending from that\n\t\t\t// prototype.\n\n\t\t\tconst a = signalify({foo: 0, name: 'a'}, 'foo')\n\t\t\tconst b = Object.assign(Object.create(a) as typeof a, {name: 'b'})\n\n\t\t\texpect(a.foo).toBe(0)\n\t\t\texpect(b.foo).toBe(0)\n\n\t\t\tlet countA = 0\n\n\t\t\tcreateEffect(() => {\n\t\t\t\ta.foo\n\t\t\t\tcountA++\n\t\t\t})\n\n\t\t\tlet countB = 0\n\n\t\t\tcreateEffect(() => {\n\t\t\t\tb.foo\n\t\t\t\tcountB++\n\t\t\t})\n\n\t\t\texpect(countA).toBe(1)\n\t\t\texpect(countB).toBe(1)\n\n\t\t\ta.foo++\n\n\t\t\texpect(a.foo).toBe(1)\n\t\t\texpect(countA).toBe(2)\n\n\t\t\t// ensure that updating a's foo property did not update b's foo\n\t\t\t// property or trigger b's effect, despite that the property is\n\t\t\t// defined in a single location on the prototype.\n\t\t\t// @ts-ignore\n\t\t\texpect(b.foo).toBe(0)\n\t\t\texpect(countB).toBe(1)\n\t\t})\n\t})\n\n\tdescribe('@component', () => {\n\t\tit('allows to define a class using class syntax', () => {\n\t\t\tlet onMountCalled = false\n\t\t\tlet onCleanupCalled = false\n\n\t\t\t@component\n\t\t\tclass CoolComp {\n\t\t\t\tonMount() {\n\t\t\t\t\tonMountCalled = true\n\t\t\t\t}\n\n\t\t\t\tonCleanup() {\n\t\t\t\t\tonCleanupCalled = true\n\t\t\t\t}\n\n\t\t\t\ttemplate(props: any) {\n\t\t\t\t\texpect(props.foo).toBe(123)\n\t\t\t\t\treturn html`
hello classes!
`\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst root = document.createElement('div')\n\t\t\tdocument.body.append(root)\n\n\t\t\tconst dispose = render(() => html`<${CoolComp} foo=${123} />`, root)\n\n\t\t\texpect(root.textContent).toBe('hello classes!')\n\t\t\texpect(onMountCalled).toBe(true)\n\t\t\texpect(onCleanupCalled).toBe(false)\n\n\t\t\tdispose()\n\t\t\troot.remove()\n\n\t\t\texpect(onCleanupCalled).toBe(true)\n\n\t\t\t// throws on non-class use\n\t\t\texpect(() => {\n\t\t\t\tclass CoolComp {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t@component\n\t\t\t\t\tonMount() {}\n\t\t\t\t}\n\t\t\t\tCoolComp\n\t\t\t}).toThrow('component decorator should only be used on a class')\n\t\t})\n\n\t\tit('works in tandem with @reactive and @signal for reactivity', async () => {\n\t\t\t@component\n\t\t\t@reactive\n\t\t\tclass CoolComp {\n\t\t\t\t@signal foo = 0\n\t\t\t\t@signal bar = 0\n\n\t\t\t\ttemplate() {\n\t\t\t\t\treturn html`
foo: ${() => this.foo}, bar: ${() => this.bar}
`\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst root = document.createElement('div')\n\t\t\tdocument.body.append(root)\n\n\t\t\tconst [a, setA] = createSignal(1)\n\t\t\tconst b = createSignalFunction(2)\n\n\t\t\t// FIXME Why do we need `() => b()` instead of just `b` here? Does `html`\n\t\t\t// check the `length` of the function and do something based on\n\t\t\t// that? Or does it get passed to a @signal property's setter and\n\t\t\t// receives the previous value?\n\t\t\tconst dispose = render(() => html`<${CoolComp} foo=${a} bar=${() => b()} />`, root)\n\n\t\t\texpect(root.textContent).toBe('foo: 1, bar: 2')\n\n\t\t\tsetA(3)\n\t\t\tb(4)\n\n\t\t\texpect(root.textContent).toBe('foo: 3, bar: 4')\n\n\t\t\tdispose()\n\t\t\troot.remove()\n\t\t})\n\n\t\tit('works without decorators', () => {\n\t\t\tconst CoolComp = component(\n\t\t\t\tclass CoolComp {\n\t\t\t\t\tfoo = 0\n\t\t\t\t\tbar = 0\n\n\t\t\t\t\tconstructor() {\n\t\t\t\t\t\tsignalify(this)\n\t\t\t\t\t}\n\n\t\t\t\t\ttemplate() {\n\t\t\t\t\t\treturn html`
foo: ${() => this.foo}, bar: ${() => this.bar}
`\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t)\n\n\t\t\tconst root = document.createElement('div')\n\t\t\tdocument.body.append(root)\n\n\t\t\tconst [a, setA] = createSignal(1)\n\t\t\tconst b = createSignalFunction(2)\n\n\t\t\t// FIXME Why do we need `() => b()` instead of just `b` here? Does `html`\n\t\t\t// check the `length` of the function and do something based on\n\t\t\t// that? Or does it get passed to a @signal property's setter and\n\t\t\t// receives the previous value?\n\t\t\tconst dispose = render(() => html`<${CoolComp} foo=${a} bar=${() => b()} />`, root)\n\n\t\t\texpect(root.textContent).toBe('foo: 1, bar: 2')\n\n\t\t\tsetA(3)\n\t\t\tb(4)\n\n\t\t\texpect(root.textContent).toBe('foo: 3, bar: 4')\n\n\t\t\tdispose()\n\t\t\troot.remove()\n\t\t})\n\n\t\t// FIXME not working, the spread doesn't seem to do anything.\n\t\txit('works with reactive spreads', async () => {\n\t\t\t@component\n\t\t\t@reactive\n\t\t\tclass CoolComp {\n\t\t\t\t@signal foo = 0\n\t\t\t\t@signal bar = 0\n\n\t\t\t\ttemplate() {\n\t\t\t\t\treturn html`
foo: ${() => this.foo}, bar: ${() => this.bar}
`\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst root = document.createElement('div')\n\t\t\tdocument.body.append(root)\n\n\t\t\tlet o = createMutable({o: {foo: 123}})\n\n\t\t\t// neither of these work\n\t\t\t// const dispose = render(() => html`<${CoolComp} ...${() => o.o} />`, root)\n\t\t\tconst dispose = render(() => html`<${CoolComp} ...${o.o} />`, root)\n\n\t\t\texpect(root.textContent).toBe('foo: 123, bar: 0')\n\n\t\t\to.o = {bar: 456}\n\n\t\t\texpect(root.textContent).toBe('foo: 123, bar: 456')\n\n\t\t\tdispose()\n\t\t\troot.remove()\n\t\t})\n\t})\n})\n\nfunction testButterflyProps(b: {colors: number; wingSize: number}, initialColors = 3) {\n\tlet count = 0\n\n\tcreateRoot(() => {\n\t\tcreateComputed(() => {\n\t\t\tb.colors\n\t\t\tb.wingSize\n\t\t\tcount++\n\t\t})\n\t})\n\n\texpect(b.colors).toBe(initialColors, 'initial colors value')\n\texpect(b.wingSize).toBe(2, 'initial wingSize value')\n\texpect(count).toBe(1, 'Should be reactive')\n\n\tb.colors++\n\n\texpect(b.colors).toBe(initialColors + 1, 'incremented colors value')\n\texpect(count).toBe(2, 'Should be reactive')\n\n\tb.wingSize++\n\n\texpect(b.wingSize).toBe(3, 'incremented wingSize value')\n\texpect(count).toBe(3, 'Should be reactive')\n}\n\n//////////////////////////////////////////////////////////////////////////\n// createSignalObject type tests ///////////////////////////////////////\n//////////////////////////////////////////////////////////////////////////\n\n{\n\tconst num = createSignalObject(1)\n\tlet n1: number = num.get()\n\tn1\n\tnum.set(123)\n\tnum.set(n => (n1 = n + 1))\n\t// @ts-expect-error Expected 1 arguments, but got 0. ts(2554)\n\tnum.set()\n\n\tconst num3 = createSignalObject()\n\t// @ts-expect-error Type 'undefined' is not assignable to type 'number'. ts(2322)\n\tlet n3: number = num3.get()\n\tnum3.set(123)\n\tnum3.set(undefined) // ok, accepts undefined\n\t// @ts-expect-error Object is possibly 'undefined'. ts(2532) (the `n` value)\n\tnum3.set(n => (n3 = n + 1))\n\t// num3.set() // ok, accepts undefined // FIXME broke in Solid 1.7.9\n\n\t// @ts-expect-error Argument of type 'boolean' is not assignable to parameter of type 'number'. ts(2345)\n\tconst num4 = createSignalObject(true)\n\n\tconst bool = createSignalObject(true)\n\tlet b1: boolean = bool.get()\n\tb1\n\tbool.set(false)\n\tbool.set(b => (b1 = !b))\n\t// @ts-expect-error Expected 1 arguments, but got 0. ts(2554)\n\tbool.set()\n\n\tconst bool2 = createSignalObject()\n\t// @ts-expect-error Type 'undefined' is not assignable to type 'number'. ts(2322)\n\tlet n4: boolean = bool2.get()\n\tbool2.set(false)\n\tbool2.set(undefined) // ok, accepts undefined\n\tbool2.set(n => (n4 = !n)) // ok because undefined is being converted to boolean\n\t// @ts-expect-error Type 'boolean | undefined' is not assignable to type 'boolean'. ts(2322)\n\tbool2.set(n => (n4 = n))\n\t// bool2.set() // ok, accepts undefined // FIXME try Solid 1.7.9\n\n\tconst func = createSignalObject(() => 1)\n\t// @ts-expect-error 1 is not assignable to function (no overload matches)\n\tfunc.set(() => 1)\n\tfunc.set(() => (): 1 => 1) // ok, set the value to a function\n\tconst fn: () => 1 = func.get() // ok, returns function value\n\tfn\n\tconst n5: 1 = func.get()()\n\tn5\n\n\tconst func2 = createSignalObject<() => number>(() => 1)\n\t// @FIXME-ts-expect-error number is not assignable to function (no overload matches)\n\tfunc2.set(() => 1) // FIXME should be a type error. Try Solid 1.7.9\n\tfunc2.set(() => () => 1) // ok, set the value to a function\n\tconst fn2: () => number = func2.get() // ok, returns function value\n\tfn2\n\tconst n6: number = func2.get()()\n\tn6\n\n\tconst stringOrFunc1 = createSignalObject<(() => number) | string>('')\n\t// @FIXME-ts-expect-error number not assignable to string | (()=>number) | undefined\n\tstringOrFunc1.set(() => 1) // FIXME should be a type error. Try Solid 1.7.9\n\t// @ts-expect-error FIXME try Solid 1.7.9\n\tconst sf1: () => number = stringOrFunc1.set(() => () => 1)\n\tsf1\n\t// @ts-expect-error FIXME try Solid 1.7.9\n\tconst sf2: string = stringOrFunc1.set('oh yeah')\n\tsf2\n\t// @ts-expect-error FIXME try Solid 1.7.9\n\tconst sf3: string = stringOrFunc1.set(() => 'oh yeah')\n\tsf3\n\t// @ts-expect-error cannot set signal to undefined\n\tstringOrFunc1.set()\n\t// @ts-expect-error cannot set signal to undefined\n\tstringOrFunc1.set(undefined)\n\t// @ts-expect-error return value might be string\n\tconst sf6: () => number = stringOrFunc1.get()\n\tsf6\n\tconst sf7: (() => number) | string | undefined = stringOrFunc1.get()\n\tsf7\n\tconst sf8: (() => number) | string = stringOrFunc1.get()\n\tsf8\n\n\tconst stringOrFunc2 = createSignalObject<(() => number) | string>()\n\t// @FIXME-ts-expect-error number not assignable to string | (()=>number) | undefined\n\tstringOrFunc2.set(() => 1) // FIXME should be a type error. Try Solid 1.7.9\n\t// @ts-expect-error FIXME try Solid 1.7.9\n\tconst sf9: () => number = stringOrFunc2.set(() => () => 1)\n\tsf9\n\t// @ts-expect-error FIXME try Solid 1.7.9\n\tconst sf10: string = stringOrFunc2.set('oh yeah')\n\tsf10\n\t// @ts-expect-error FIXME try Solid 1.7.9\n\tconst sf11: string = stringOrFunc2.set(() => 'oh yeah')\n\tsf11\n\t// @ts-expect-error FIXME try Solid 1.7.9\n\tconst sf12: undefined = stringOrFunc2.set()\n\tsf12\n\t// @ts-expect-error FIXME try Solid 1.7.9\n\tconst sf13: undefined = stringOrFunc2.set(undefined)\n\tsf13\n\tconst sf14: (() => number) | string | undefined = stringOrFunc2.get()\n\tsf14\n\t// @ts-expect-error return value might be undefined\n\tconst sf15: (() => number) | string = stringOrFunc2.get()\n\tsf15\n}\n\n//////////////////////////////////////////////////////////////////////////\n// createSignalFunction type tests ///////////////////////////////////////\n//////////////////////////////////////////////////////////////////////////\n\n{\n\tconst num = createSignalFunction(1)\n\tlet n1: number = num()\n\tn1\n\tnum(123)\n\tnum(n => (n1 = n + 1))\n\tnum()\n\n\tconst num3 = createSignalFunction()\n\t// @ts-expect-error Type 'undefined' is not assignable to type 'number'. ts(2322)\n\tlet n3: number = num3()\n\tnum3(123)\n\tnum3(undefined) // ok, accepts undefined\n\t// @ts-expect-error Object is possibly 'undefined'. ts(2532) (the `n` value)\n\tnum3(n => (n3 = n + 1))\n\tnum3() // ok, getter\n\n\t// @ts-expect-error Argument of type 'boolean' is not assignable to parameter of type 'number'. ts(2345)\n\tconst num4 = createSignalFunction(true)\n\n\tconst bool = createSignalFunction(true)\n\tlet b1: boolean = bool()\n\tb1\n\tbool(false)\n\tbool(b => (b1 = !b))\n\tbool()\n\n\tconst bool2 = createSignalFunction()\n\t// @ts-expect-error Type 'undefined' is not assignable to type 'number'. ts(2322)\n\tlet n4: boolean = bool2()\n\tbool2(false)\n\tbool2(undefined) // ok, accepts undefined\n\tbool2(n => (n4 = !n)) // ok because undefined is being converted to boolean\n\t// @ts-expect-error Type 'boolean | undefined' is not assignable to type 'boolean'. ts(2322)\n\tbool2(n => (n4 = n))\n\tbool2() // ok, accepts undefined\n\n\tconst func = createSignalFunction(() => 1)\n\t// @ts-expect-error 1 is not assignable to function (no overload matches)\n\tfunc(() => 1)\n\tfunc(() => (): 1 => 1) // ok, set the value to a function\n\tconst fn: () => 1 = func() // ok, returns function value\n\tfn\n\tconst n5: 1 = func()()\n\tn5\n\n\tconst func2 = createSignalFunction<() => number>(() => 1)\n\t// @ts-expect-error number is not assignable to function (no overload matches)\n\tfunc2(() => 1)\n\tfunc2(() => () => 1) // ok, set the value to a function\n\tconst fn2: () => number = func2() // ok, returns function value\n\tfn2\n\tconst n6: number = func2()()\n\tn6\n\n\tconst stringOrFunc1 = createSignalFunction<(() => number) | string>('')\n\t// @ts-expect-error number not assignable to string | (()=>number) | undefined\n\tstringOrFunc1(() => 1)\n\tconst sf1: () => number = stringOrFunc1(() => () => 1)\n\tsf1\n\tconst sf2: string = stringOrFunc1('oh yeah')\n\tsf2\n\tconst sf3: string = stringOrFunc1(() => 'oh yeah')\n\tsf3\n\tstringOrFunc1() // ok, getter\n\t// @ts-expect-error cannot set signal to undefined\n\tstringOrFunc1(undefined)\n\t// @ts-expect-error return value might be string\n\tconst sf6: () => number = stringOrFunc1()\n\tsf6\n\tconst sf7: (() => number) | string | undefined = stringOrFunc1()\n\tsf7\n\tconst sf8: (() => number) | string = stringOrFunc1()\n\tsf8\n\n\tconst stringOrFunc2 = createSignalFunction<(() => number) | string>()\n\t// @ts-expect-error number not assignable to string | (()=>number) | undefined\n\tstringOrFunc2(() => 1)\n\tconst sf9: () => number = stringOrFunc2(() => () => 1)\n\tsf9\n\tconst sf10: string = stringOrFunc2('oh yeah')\n\tsf10\n\tconst sf11: string = stringOrFunc2(() => 'oh yeah')\n\tsf11\n\t// @ts-expect-error 'string | (() => number) | undefined' is not assignable to type 'undefined'.\n\tconst sf12: undefined = stringOrFunc2()\n\tsf12\n\tconst sf13: undefined = stringOrFunc2(undefined)\n\tsf13\n\tconst sf14: (() => number) | string | undefined = stringOrFunc2()\n\tsf14\n\t// @ts-expect-error return value might be undefined\n\tconst sf15: (() => number) | string = stringOrFunc2()\n\tsf15\n}\n"],"mappings":";;;;;AAAA,SAAQA,cAAc,EAAEC,YAAY,EAAEC,UAAU,EAAEC,YAAY,EAAEC,OAAO,QAAO,UAAU;AACxF,SAAQC,aAAa,QAAO,gBAAgB;AAC5C,SAAQC,MAAM,QAAO,cAAc;AACnC,OAAOC,IAAI,MAAM,eAAe;AAChC,SACCC,kBAAkB,EAClBC,QAAQ,EACRC,SAAS,EACTC,oBAAoB,EACpBC,MAAM,EACNC,oBAAoB,EACpBC,SAAS,QACH,YAAY;;AAEnB;AACA;;AAKAC,QAAQ,CAAC,cAAc,EAAE,MAAM;EAC9BA,QAAQ,CAAC,sBAAsB,EAAE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EACtDC,GAAG;EACH,MAAMC,GAAW,GAAGF,aAAa,CAAC,SAAS,CAAC;EAC5CE,GAAG;EACH,MAAMC,GAAW,GAAGH,aAAa,CAAC,MAAM,SAAS,CAAC;EAClDG,GAAG;EACHH,aAAa,CAAC,CAAC,EAAC;EAChB;EACAA,aAAa,CAACX,SAAS,CAAC;EACxB;EACA,MAAMe,GAAiB,GAAGJ,aAAa,CAAC,CAAC;EACzCI,GAAG;EACH,MAAMC,GAAwC,GAAGL,aAAa,CAAC,CAAC;EAChEK,GAAG;EACH,MAAMC,GAA4B,GAAGN,aAAa,CAAC,CAAC;EACpDM,GAAG;EAEH,MAAMC,aAAa,GAAGlM,oBAAoB,CAA0B,CAAC;EACrE;EACAkM,aAAa,CAAC,MAAM,CAAC,CAAC;EACtB,MAAMC,GAAiB,GAAGD,aAAa,CAAC,MAAM,MAAM,CAAC,CAAC;EACtDC,GAAG;EACH,MAAMC,IAAY,GAAGF,aAAa,CAAC,SAAS,CAAC;EAC7CE,IAAI;EACJ,MAAMC,IAAY,GAAGH,aAAa,CAAC,MAAM,SAAS,CAAC;EACnDG,IAAI;EACJ;EACA,MAAMC,IAAe,GAAGJ,aAAa,CAAC,CAAC;EACvCI,IAAI;EACJ,MAAMC,IAAe,GAAGL,aAAa,CAAClB,SAAS,CAAC;EAChDuB,IAAI;EACJ,MAAMC,IAAyC,GAAGN,aAAa,CAAC,CAAC;EACjEM,IAAI;EACJ;EACA,MAAMC,IAA6B,GAAGP,aAAa,CAAC,CAAC;EACrDO,IAAI;AACL","ignoreList":[]} \ No newline at end of file diff --git a/dist/signalify.d.ts b/dist/signalify.d.ts index 36bca7c..e8b4b8a 100644 --- a/dist/signalify.d.ts +++ b/dist/signalify.d.ts @@ -1,3 +1,4 @@ +import { type SignalFunction } from './createSignalFunction.js'; /** * Convert properties on an object into Solid signal-backed properties. * @@ -50,11 +51,8 @@ export declare function signalify(obj: T): T; export declare function signalify(obj: T, ...props: (keyof T)[]): T; export declare function signalify(obj: T, ...props: [key: keyof T, initialValue: unknown][]): T; -/** - * This ensures that `createSignalAccessor` is kept internal to classy-solid only. - */ -export declare function getCreateSignalAccessor(): typeof createSignalAccessor; export declare function __isPropSetAtLeastOnce(instance: object, prop: string | symbol): boolean; -declare function createSignalAccessor(obj: T, prop: Exclude, initialVal: unknown): void; -export {}; +export declare function __trackPropSetAtLeastOnce(instance: object, prop: string | symbol): void; +export declare function __createSignalAccessor(obj: T, prop: Exclude, initialVal: unknown): void; +export declare function __getSignal(obj: object, storage: WeakMap>, initialVal: unknown): SignalFunction; //# sourceMappingURL=signalify.d.ts.map \ No newline at end of file diff --git a/dist/signalify.d.ts.map b/dist/signalify.d.ts.map index 79550f3..dfc17a6 100644 --- a/dist/signalify.d.ts.map +++ b/dist/signalify.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"signalify.d.ts","sourceRoot":"","sources":["../src/signalify.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AACzE,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;AAC7E,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,GAAG,CAAC,CAAA;AA0BzG;;GAEG;AACH,wBAAgB,uBAAuB,gCAItC;AASD,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,WAE7E;AASD,iBAAS,oBAAoB,CAA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cAAc,CAAC,OAAO,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,2BAI9G"} \ No newline at end of file diff --git a/dist/signalify.js b/dist/signalify.js index 59bcd77..2251651 100644 --- a/dist/signalify.js +++ b/dist/signalify.js @@ -1,5 +1,6 @@ import { getInheritedDescriptor } from 'lowclass/dist/getInheritedDescriptor.js'; -import { createSignal, $PROXY, untrack } from 'solid-js'; +import { $PROXY, untrack } from 'solid-js'; +import { createSignalFunction } from './createSignalFunction.js'; /** * Convert properties on an object into Solid signal-backed properties. @@ -66,20 +67,10 @@ export function signalify(obj, ...props) { // We cast from PropertyKey to PropKey because keys can't actually be number, only string | symbol. const _prop = isTuple ? prop[0] : prop; const initialValue = isTuple ? prop[1] : untrack(() => obj[_prop]); - createSignalAccessor(obj, _prop, initialValue); + __createSignalAccessor(obj, _prop, initialValue); } return obj; } -let gotCreateSignalAccessor = false; - -/** - * This ensures that `createSignalAccessor` is kept internal to classy-solid only. - */ -export function getCreateSignalAccessor() { - if (gotCreateSignalAccessor) throw new Error('Export "createSignalAccessor" is internal to classy-solid only.'); - gotCreateSignalAccessor = true; - return createSignalAccessor; -} // propsSetAtLeastOnce is a Set that tracks which reactive properties have been // set at least once. @@ -91,72 +82,60 @@ const propsSetAtLeastOnce = new WeakMap(); export function __isPropSetAtLeastOnce(instance, prop) { return !!propsSetAtLeastOnce.get(instance)?.has(prop); } -function trackPropSetAtLeastOnce(instance, prop) { +export function __trackPropSetAtLeastOnce(instance, prop) { if (!propsSetAtLeastOnce.has(instance)) propsSetAtLeastOnce.set(instance, new Set()); propsSetAtLeastOnce.get(instance).add(prop); } const isSignalGetter = new WeakSet(); -function createSignalAccessor(obj, prop, initialVal) { +export function __createSignalAccessor(obj, prop, initialVal) { let descriptor = getInheritedDescriptor(obj, prop); let originalGet; let originalSet; + const isAccessor = !!(descriptor?.get || descriptor?.set); if (descriptor) { originalGet = descriptor.get; originalSet = descriptor.set; if (originalGet && isSignalGetter.has(originalGet)) return; - if (originalGet || originalSet) { - // reactivity requires both - if (!originalGet || !originalSet) return warnNotReadWrite(prop); - delete descriptor.get; - delete descriptor.set; - } else { + // reactivity requires both + if (isAccessor && !(originalGet && originalSet)) return warnNotReadWrite(prop); + if (!isAccessor) { + // no need to make a signal that can't be written to + if (!descriptor.writable) return warnNotWritable(prop); + // If there was a value descriptor, trust it as the source of truth // for initialVal. For example, if the user class modifies the value // after the initializer, it will have a different value than what // we tracked from the initializer. initialVal = descriptor.value; - - // if it isn't writable, we don't need to make a reactive variable because - // the value won't change - if (!descriptor.writable) return warnNotWritable(prop); - delete descriptor.value; - delete descriptor.writable; } } const signalStorage = new WeakMap(); - descriptor = { + const newDescriptor = { configurable: true, - enumerable: true, - ...descriptor, - get: originalGet ? function () { - const s = getSignal(this, signalStorage, initialVal); - s[0](); // read + enumerable: descriptor?.enumerable, + get: isAccessor ? function () { + __getSignal(this, signalStorage, initialVal)(); return originalGet.call(this); } : function () { - const s = getSignal(this, signalStorage, initialVal); - return s[0](); // read + return __getSignal(this, signalStorage, initialVal)(); }, - set: originalSet ? function (newValue) { + set: isAccessor ? function (newValue) { originalSet.call(this, newValue); - trackPropSetAtLeastOnce(this, prop); - - // write - const s = getSignal(this, signalStorage, initialVal); - if (typeof newValue === 'function') s[1](() => newValue);else s[1](newValue); + __trackPropSetAtLeastOnce(this, prop); + const s = __getSignal(this, signalStorage, initialVal); + s(typeof newValue === 'function' ? () => newValue : newValue); } : function (newValue) { - trackPropSetAtLeastOnce(this, prop); - - // write - const s = getSignal(this, signalStorage, initialVal); - if (typeof newValue === 'function') s[1](() => newValue);else s[1](newValue); + __trackPropSetAtLeastOnce(this, prop); + const s = __getSignal(this, signalStorage, initialVal); + s(typeof newValue === 'function' ? () => newValue : newValue); } }; - isSignalGetter.add(descriptor.get); - Object.defineProperty(obj, prop, descriptor); + isSignalGetter.add(newDescriptor.get); + Object.defineProperty(obj, prop, newDescriptor); } -function getSignal(obj, storage, initialVal) { +export function __getSignal(obj, storage, initialVal) { let s = storage.get(obj); - if (!s) storage.set(obj, s = createSignal(initialVal, { + if (!s) storage.set(obj, s = createSignalFunction(initialVal, { equals: false })); return s; diff --git a/dist/signalify.js.map b/dist/signalify.js.map index 22c6dd2..ae82a72 100644 --- a/dist/signalify.js.map +++ b/dist/signalify.js.map @@ -1 +1 @@ -{"version":3,"file":"signalify.js","names":["getInheritedDescriptor","createSignal","$PROXY","untrack","signalify","obj","props","proxy","_props","length","Object","keys","concat","getOwnPropertySymbols","prop","isTuple","Array","isArray","_prop","initialValue","createSignalAccessor","gotCreateSignalAccessor","getCreateSignalAccessor","Error","propsSetAtLeastOnce","WeakMap","__isPropSetAtLeastOnce","instance","get","has","trackPropSetAtLeastOnce","set","Set","add","isSignalGetter","WeakSet","initialVal","descriptor","originalGet","originalSet","warnNotReadWrite","value","writable","warnNotWritable","signalStorage","configurable","enumerable","s","getSignal","call","newValue","defineProperty","storage","equals","console","warn","String"],"sources":["../src/signalify.ts"],"sourcesContent":["import {getInheritedDescriptor} from 'lowclass/dist/getInheritedDescriptor.js'\nimport {createSignal, $PROXY, untrack, type Signal} from 'solid-js'\nimport type {PropKey} from './decorators/types.js'\n\ntype AnyObject = Record\n\n/**\n * Convert properties on an object into Solid signal-backed properties.\n *\n * There are two ways to use this: either by defining which properties to\n * convert to signal-backed properties by providing an array as property names\n * in the second arg, which is useful on plain objects, or by passing in `this`\n * and `this.constructor` within the `constructor` of a class that has\n * properties decorated with `@signal`.\n *\n * Example with a class:\n *\n * ```js\n * import {signalify} from 'classy-solid'\n * import {createEffect} from 'solid-js'\n *\n * class Counter {\n * count = 0\n *\n * constructor() {\n * signalify(this, 'count')\n * setInterval(() => this.count++, 1000)\n * }\n * }\n *\n * const counter = new Counter\n *\n * createEffect(() => {\n * console.log('count:', counter.count)\n * })\n * ```\n *\n * Example with a plain object:\n *\n * ```js\n * import {signalify} from 'classy-solid'\n * import {createEffect} from 'solid-js'\n *\n * const counter = {\n * count: 0\n * }\n *\n * signalify(counter, 'count')\n * setInterval(() => counter.count++, 1000)\n *\n * createEffect(() => {\n * console.log('count:', counter.count)\n * })\n * ```\n */\nexport function signalify(obj: T): T\nexport function signalify(obj: T, ...props: (keyof T)[]): T\nexport function signalify(obj: T, ...props: [key: keyof T, initialValue: unknown][]): T\nexport function signalify(obj: AnyObject, ...props: [key: PropertyKey, initialValue: unknown][] | PropertyKey[]) {\n\t// Special case for Solid proxies: if the object is already a solid proxy,\n\t// all properties are already reactive, no need to signalify.\n\t// @ts-expect-error special indexed access\n\tconst proxy = obj[$PROXY] as T\n\tif (proxy) return obj\n\n\tconst _props = props.length ? props : (Object.keys(obj) as PropKey[]).concat(Object.getOwnPropertySymbols(obj))\n\n\t// Use `untrack` here to be extra safe the initial value doesn't count as a\n\t// dependency and cause a reactivity loop.\n\tfor (const prop of _props) {\n\t\tconst isTuple = Array.isArray(prop)\n\t\t// We cast from PropertyKey to PropKey because keys can't actually be number, only string | symbol.\n\t\tconst _prop = (isTuple ? prop[0] : prop) as PropKey\n\t\tconst initialValue = isTuple ? prop[1] : untrack(() => obj[_prop])\n\n\t\tcreateSignalAccessor(obj, _prop, initialValue)\n\t}\n\n\treturn obj\n}\n\nlet gotCreateSignalAccessor = false\n\n/**\n * This ensures that `createSignalAccessor` is kept internal to classy-solid only.\n */\nexport function getCreateSignalAccessor() {\n\tif (gotCreateSignalAccessor) throw new Error('Export \"createSignalAccessor\" is internal to classy-solid only.')\n\tgotCreateSignalAccessor = true\n\treturn createSignalAccessor\n}\n\n// propsSetAtLeastOnce is a Set that tracks which reactive properties have been\n// set at least once.\nconst propsSetAtLeastOnce = new WeakMap>()\n\n// @lume/element uses this to detect if a reactive prop has been set, and if so\n// will not overwrite the value with any pre-existing value from custom element\n// pre-upgrade.\nexport function __isPropSetAtLeastOnce(instance: object, prop: string | symbol) {\n\treturn !!propsSetAtLeastOnce.get(instance)?.has(prop)\n}\n\nfunction trackPropSetAtLeastOnce(instance: object, prop: string | symbol) {\n\tif (!propsSetAtLeastOnce.has(instance)) propsSetAtLeastOnce.set(instance, new Set())\n\tpropsSetAtLeastOnce.get(instance)!.add(prop)\n}\n\nconst isSignalGetter = new WeakSet()\n\nfunction createSignalAccessor(obj: T, prop: Exclude, initialVal: unknown): void {\n\tlet descriptor: PropertyDescriptor | undefined = getInheritedDescriptor(obj, prop)\n\n\tlet originalGet: (() => any) | undefined\n\tlet originalSet: ((v: any) => void) | undefined\n\n\tif (descriptor) {\n\t\toriginalGet = descriptor.get\n\t\toriginalSet = descriptor.set\n\n\t\tif (originalGet && isSignalGetter.has(originalGet)) return\n\n\t\tif (originalGet || originalSet) {\n\t\t\t// reactivity requires both\n\t\t\tif (!originalGet || !originalSet) return warnNotReadWrite(prop)\n\n\t\t\tdelete descriptor.get\n\t\t\tdelete descriptor.set\n\t\t} else {\n\t\t\t// If there was a value descriptor, trust it as the source of truth\n\t\t\t// for initialVal. For example, if the user class modifies the value\n\t\t\t// after the initializer, it will have a different value than what\n\t\t\t// we tracked from the initializer.\n\t\t\tinitialVal = descriptor.value\n\n\t\t\t// if it isn't writable, we don't need to make a reactive variable because\n\t\t\t// the value won't change\n\t\t\tif (!descriptor.writable) return warnNotWritable(prop)\n\n\t\t\tdelete descriptor.value\n\t\t\tdelete descriptor.writable\n\t\t}\n\t}\n\n\tconst signalStorage = new WeakMap>()\n\n\tdescriptor = {\n\t\tconfigurable: true,\n\t\tenumerable: true,\n\t\t...descriptor,\n\t\tget: originalGet\n\t\t\t? function (this: object): unknown {\n\t\t\t\t\tconst s = getSignal(this, signalStorage, initialVal)\n\t\t\t\t\ts[0]() // read\n\t\t\t\t\treturn originalGet!.call(this)\n\t\t\t }\n\t\t\t: function (this: object): unknown {\n\t\t\t\t\tconst s = getSignal(this, signalStorage, initialVal)\n\t\t\t\t\treturn s[0]() // read\n\t\t\t },\n\t\tset: originalSet\n\t\t\t? function (this: object, newValue: unknown) {\n\t\t\t\t\toriginalSet!.call(this, newValue)\n\n\t\t\t\t\ttrackPropSetAtLeastOnce(this, prop)\n\n\t\t\t\t\t// write\n\t\t\t\t\tconst s = getSignal(this, signalStorage, initialVal)\n\t\t\t\t\tif (typeof newValue === 'function') s[1](() => newValue)\n\t\t\t\t\telse s[1](newValue)\n\t\t\t }\n\t\t\t: function (this: object, newValue: unknown) {\n\t\t\t\t\ttrackPropSetAtLeastOnce(this, prop)\n\n\t\t\t\t\t// write\n\t\t\t\t\tconst s = getSignal(this, signalStorage, initialVal)\n\t\t\t\t\tif (typeof newValue === 'function') s[1](() => newValue)\n\t\t\t\t\telse s[1](newValue)\n\t\t\t },\n\t}\n\n\tisSignalGetter.add(descriptor.get!)\n\n\tObject.defineProperty(obj, prop, descriptor)\n}\n\nfunction getSignal(obj: object, storage: WeakMap>, initialVal: unknown) {\n\tlet s = storage.get(obj)\n\tif (!s) storage.set(obj, (s = createSignal(initialVal, {equals: false})))\n\treturn s\n}\n\nfunction warnNotReadWrite(prop: PropertyKey) {\n\tconsole.warn(\n\t\t`Cannot signalify property named \"${String(\n\t\t\tprop,\n\t\t)}\" which had a getter or a setter, but not both. Reactivity on accessors works only when accessors have both get and set. Skipped.`,\n\t)\n}\n\nfunction warnNotWritable(prop: PropertyKey) {\n\tconsole.warn(\n\t\t`The \\`@signal\\` decorator was used on a property named \"${String(\n\t\t\tprop,\n\t\t)}\" that is not writable. Reactivity is not enabled for non-writable properties.`,\n\t)\n}\n"],"mappings":"AAAA,SAAQA,sBAAsB,QAAO,yCAAyC;AAC9E,SAAQC,YAAY,EAAEC,MAAM,EAAEC,OAAO,QAAoB,UAAU;;AAKnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAO,SAASC,SAASA,CAACC,GAAc,EAAE,GAAG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W,SAASA,CAAC3C,GAAW,EAAE+C,OAAyC,EAAEhB,UAAmB,EAAE;EAC/F,IAAIW,CAAC,GAAGK,OAAO,CAACxB,GAAG,CAACvB,GAAG,CAAC;EACxB,IAAI,CAAC0C,CAAC,EAAEK,OAAO,CAACrB,GAAG,CAAC1B,GAAG,EAAG0C,CAAC,GAAG9C,YAAY,CAACmC,UAAU,EAAE;IAACiB,MAAM,EAAE;EAAK,CAAC,CAAE,CAAC;EACzE,OAAON,CAAC;AACT;AAEA,SAASP,gBAAgBA,CAAC1B,IAAiB,EAAE;EAC5CwC,OAAO,CAACC,IAAI,CACX,oCAAoCC,MAAM,CACzC1C,IACD,CAAC,mIACF,CAAC;AACF;AAEA,SAAS6B,eAAeA,CAAC7B,IAAiB,EAAE;EAC3CwC,OAAO,CAACC,IAAI,CACX,2DAA2DC,MAAM,CAChE1C,IACD,CAAC,gFACF,CAAC;AACF","ignoreList":[]} \ No newline at end of file +{"version":3,"file":"signalify.js","names":["getInheritedDescriptor","$PROXY","untrack","createSignalFunction","signalify","obj","props","proxy","_props","length","Object","keys","concat","getOwnPropertySymbols","prop","isTuple","Array","isArray","_prop","initialValue","__createSignalAccessor","propsSetAtLeastOnce","WeakMap","__isPropSetAtLeastOnce","instance","get","has","__trackPropSetAtLeastOnce","set","Set","add","isSignalGetter","WeakSet","initialVal","descriptor","originalGet","originalSet","isAccessor","warnNotReadWrite","writable","warnNotWritable","value","signalStorage","newDescriptor","configurable","enumerable","__getSignal","call","newValue","s","defineProperty","storage","equals","console","warn","String"],"sources":["../src/signalify.ts"],"sourcesContent":["import {getInheritedDescriptor} from 'lowclass/dist/getInheritedDescriptor.js'\nimport {$PROXY, untrack} from 'solid-js'\nimport type {PropKey} from './decorators/types.js'\nimport {createSignalFunction, type SignalFunction} from './createSignalFunction.js'\n\ntype AnyObject = Record\n\n/**\n * Convert properties on an object into Solid signal-backed properties.\n *\n * There are two ways to use this: either by defining which properties to\n * convert to signal-backed properties by providing an array as property names\n * in the second arg, which is useful on plain objects, or by passing in `this`\n * and `this.constructor` within the `constructor` of a class that has\n * properties decorated with `@signal`.\n *\n * Example with a class:\n *\n * ```js\n * import {signalify} from 'classy-solid'\n * import {createEffect} from 'solid-js'\n *\n * class Counter {\n * count = 0\n *\n * constructor() {\n * signalify(this, 'count')\n * setInterval(() => this.count++, 1000)\n * }\n * }\n *\n * const counter = new Counter\n *\n * createEffect(() => {\n * console.log('count:', counter.count)\n * })\n * ```\n *\n * Example with a plain object:\n *\n * ```js\n * import {signalify} from 'classy-solid'\n * import {createEffect} from 'solid-js'\n *\n * const counter = {\n * count: 0\n * }\n *\n * signalify(counter, 'count')\n * setInterval(() => counter.count++, 1000)\n *\n * createEffect(() => {\n * console.log('count:', counter.count)\n * })\n * ```\n */\nexport function signalify(obj: T): T\nexport function signalify(obj: T, ...props: (keyof T)[]): T\nexport function signalify(obj: T, ...props: [key: keyof T, initialValue: unknown][]): T\nexport function signalify(obj: AnyObject, ...props: [key: PropertyKey, initialValue: unknown][] | PropertyKey[]) {\n\t// Special case for Solid proxies: if the object is already a solid proxy,\n\t// all properties are already reactive, no need to signalify.\n\t// @ts-expect-error special indexed access\n\tconst proxy = obj[$PROXY] as T\n\tif (proxy) return obj\n\n\tconst _props = props.length ? props : (Object.keys(obj) as PropKey[]).concat(Object.getOwnPropertySymbols(obj))\n\n\t// Use `untrack` here to be extra safe the initial value doesn't count as a\n\t// dependency and cause a reactivity loop.\n\tfor (const prop of _props) {\n\t\tconst isTuple = Array.isArray(prop)\n\t\t// We cast from PropertyKey to PropKey because keys can't actually be number, only string | symbol.\n\t\tconst _prop = (isTuple ? prop[0] : prop) as PropKey\n\t\tconst initialValue = isTuple ? prop[1] : untrack(() => obj[_prop])\n\n\t\t__createSignalAccessor(obj, _prop, initialValue)\n\t}\n\n\treturn obj\n}\n\n// propsSetAtLeastOnce is a Set that tracks which reactive properties have been\n// set at least once.\nconst propsSetAtLeastOnce = new WeakMap>()\n\n// @lume/element uses this to detect if a reactive prop has been set, and if so\n// will not overwrite the value with any pre-existing value from custom element\n// pre-upgrade.\nexport function __isPropSetAtLeastOnce(instance: object, prop: string | symbol) {\n\treturn !!propsSetAtLeastOnce.get(instance)?.has(prop)\n}\n\nexport function __trackPropSetAtLeastOnce(instance: object, prop: string | symbol) {\n\tif (!propsSetAtLeastOnce.has(instance)) propsSetAtLeastOnce.set(instance, new Set())\n\tpropsSetAtLeastOnce.get(instance)!.add(prop)\n}\n\nconst isSignalGetter = new WeakSet()\n\nexport function __createSignalAccessor(\n\tobj: T,\n\tprop: Exclude,\n\tinitialVal: unknown,\n): void {\n\tlet descriptor: PropertyDescriptor | undefined = getInheritedDescriptor(obj, prop)\n\n\tlet originalGet: (() => any) | undefined\n\tlet originalSet: ((v: any) => void) | undefined\n\tconst isAccessor = !!(descriptor?.get || descriptor?.set)\n\n\tif (descriptor) {\n\t\toriginalGet = descriptor.get\n\t\toriginalSet = descriptor.set\n\n\t\tif (originalGet && isSignalGetter.has(originalGet)) return\n\t\t// reactivity requires both\n\t\tif (isAccessor && !(originalGet && originalSet)) return warnNotReadWrite(prop)\n\n\t\tif (!isAccessor) {\n\t\t\t// no need to make a signal that can't be written to\n\t\t\tif (!descriptor.writable) return warnNotWritable(prop)\n\n\t\t\t// If there was a value descriptor, trust it as the source of truth\n\t\t\t// for initialVal. For example, if the user class modifies the value\n\t\t\t// after the initializer, it will have a different value than what\n\t\t\t// we tracked from the initializer.\n\t\t\tinitialVal = descriptor.value\n\t\t}\n\t}\n\n\tconst signalStorage = new WeakMap>()\n\n\tconst newDescriptor = {\n\t\tconfigurable: true,\n\t\tenumerable: descriptor?.enumerable,\n\t\tget: isAccessor\n\t\t\t? function (this: object): unknown {\n\t\t\t\t\t__getSignal(this, signalStorage, initialVal)()\n\t\t\t\t\treturn originalGet!.call(this)\n\t\t\t }\n\t\t\t: function (this: object): unknown {\n\t\t\t\t\treturn __getSignal(this, signalStorage, initialVal)()\n\t\t\t },\n\t\tset: isAccessor\n\t\t\t? function (this: object, newValue: unknown) {\n\t\t\t\t\toriginalSet!.call(this, newValue)\n\t\t\t\t\t__trackPropSetAtLeastOnce(this, prop)\n\n\t\t\t\t\tconst s = __getSignal(this, signalStorage, initialVal)\n\t\t\t\t\ts(typeof newValue === 'function' ? () => newValue : newValue)\n\t\t\t }\n\t\t\t: function (this: object, newValue: unknown) {\n\t\t\t\t\t__trackPropSetAtLeastOnce(this, prop)\n\n\t\t\t\t\tconst s = __getSignal(this, signalStorage, initialVal)\n\t\t\t\t\ts(typeof newValue === 'function' ? () => newValue : newValue)\n\t\t\t },\n\t}\n\n\tisSignalGetter.add(newDescriptor.get!)\n\n\tObject.defineProperty(obj, prop, newDescriptor)\n}\n\nexport function __getSignal(obj: object, storage: WeakMap>, initialVal: unknown) {\n\tlet s = storage.get(obj)\n\tif (!s) storage.set(obj, (s = createSignalFunction(initialVal, {equals: false})))\n\treturn s\n}\n\nfunction warnNotReadWrite(prop: PropertyKey) {\n\tconsole.warn(\n\t\t`Cannot signalify property named \"${String(\n\t\t\tprop,\n\t\t)}\" which had a getter or a setter, but not both. Reactivity on accessors works only when accessors have both get and set. Skipped.`,\n\t)\n}\n\nfunction warnNotWritable(prop: PropertyKey) {\n\tconsole.warn(\n\t\t`The \\`@signal\\` decorator was used on a property named \"${String(\n\t\t\tprop,\n\t\t)}\" that is not writable. Reactivity is not enabled for non-writable properties.`,\n\t)\n}\n"],"mappings":"AAAA,SAAQA,sBAAsB,QAAO,yCAAyC;AAC9E,SAAQC,MAAM,EAAEC,OAAO,QAAO,UAAU;AAExC,SAAQC,oBAAoB,QAA4B,2BAA2B;;AAInF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A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SAAS0B,eAAeA,CAAC1B,IAAiB,EAAE;EAC3CuC,OAAO,CAACC,IAAI,CACX,2DAA2DC,MAAM,CAChEzC,IACD,CAAC,gFACF,CAAC;AACF","ignoreList":[]} \ No newline at end of file diff --git a/src/decorators/reactive.ts b/src/decorators/reactive.ts index d0853f8..b0e9ce5 100644 --- a/src/decorators/reactive.ts +++ b/src/decorators/reactive.ts @@ -1,14 +1,8 @@ import type {AnyConstructor} from 'lowclass/dist/Constructor.js' import {getListener, $PROXY, untrack} from 'solid-js' -import {getKey, getPropsToSignalify, resetPropsToSignalify} from './signal.js' -import {getCreateSignalAccessor} from '../signalify.js' +import {__propsToSignalify, __resetPropsToSignalify} from './signal.js' +import {__createSignalAccessor} from '../signalify.js' -/** - * Access key for classy-solid private internal APIs. - */ -const accessKey = getKey() - -const createSignalAccessor = getCreateSignalAccessor() const hasOwnProperty = Object.prototype.hasOwnProperty /** @@ -43,7 +37,6 @@ export function reactive(value: AnyConstructor, context: ClassDecoratorContext | throw new TypeError('The @reactive decorator is only for use on classes.') const Class = value - const signalProps = getPropsToSignalify(accessKey) // For the current class decorated with @reactive, we reset the map, so that // for the next class decorated with @reactive we track only that next @@ -52,7 +45,8 @@ export function reactive(value: AnyConstructor, context: ClassDecoratorContext | // // In the future maybe we can use decorator metadata for this // (https://github.com/tc39/proposal-decorator-metadata)? - resetPropsToSignalify(accessKey) + const signalProps = __propsToSignalify // grab the current value before we reset it. + __resetPropsToSignalify() class ReactiveDecorator extends Class { constructor(...args: any[]) { @@ -73,26 +67,13 @@ export function reactive(value: AnyConstructor, context: ClassDecoratorContext | if (proxy) return instance for (const [prop, propSpec] of signalProps) { - const kind = propSpec.kind let initialValue = propSpec.initialValue // @prod-prune if (!(hasOwnProperty.call(instance, prop) || hasOwnProperty.call(Class.prototype, prop))) throw new PropNotFoundError(prop) - const isAccessor = kind === 'getter' || kind === 'setter' - - if (isAccessor) { - const desc = Object.getOwnPropertyDescriptor(Class.prototype, prop)! - initialValue = desc.get!.call(instance) - // Note, if the kind was field, then the initializer already defined the initialValue. - } - - createSignalAccessor( - isAccessor ? Class.prototype : instance, - prop as Exclude, - initialValue, - ) + __createSignalAccessor(instance, prop as Exclude, initialValue) } return instance diff --git a/src/decorators/signal.ts b/src/decorators/signal.ts index aa351a2..a8effd7 100644 --- a/src/decorators/signal.ts +++ b/src/decorators/signal.ts @@ -1,42 +1,17 @@ +import {$PROXY} from 'solid-js' +import {__getSignal, __trackPropSetAtLeastOnce, __createSignalAccessor} from '../signalify.js' import type {PropKey, PropSpec} from './types.js' +import type {SignalFunction} from '../createSignalFunction.js' -let propsToSignalify = new Map() -let accessKey: symbol | null = null +export let __propsToSignalify = new Map() -/** - * Provides a key for accessing internal APIs. If any other module tries to get - * this, an error will be thrown, and signal and reactive decorators will not - * work. - */ -export function getKey() { - if (accessKey) throw new Error('Attempted use of classy-solid internals.') - accessKey = Symbol() - return accessKey -} - -/** - * This function provides propsToSignalify to only one external module - * (reactive.ts). The purpose of this is to keep the API private for reactive.ts - * only, otherwise an error will be thrown that breaks signal/reactive - * functionality. - */ -export function getPropsToSignalify(key: symbol) { - if (key !== accessKey) throw new Error('Attempted use of classy-solid internals.') - return propsToSignalify +export function __resetPropsToSignalify() { + __propsToSignalify = new Map() } -/** - * Only the module that first gets the key can call this function (it should be - * reactive.ts) - */ -export function resetPropsToSignalify(key: symbol) { - if (key !== accessKey) throw new Error('Attempted use of classy-solid internals.') - propsToSignalify = new Map() -} +const Undefined = Symbol() -function isMemberDecorator(context: DecoratorContext): context is ClassMemberDecoratorContext { - return !!('private' in context) -} +type SignalStorages = Record> | undefined> /** * @decorator @@ -69,33 +44,113 @@ function isMemberDecorator(context: DecoratorContext): context is ClassMemberDec * ``` */ export function signal( - _: unknown, - context: ClassFieldDecoratorContext | ClassGetterDecoratorContext | ClassSetterDecoratorContext, + value: unknown, + context: + | ClassFieldDecoratorContext + | ClassGetterDecoratorContext + | ClassSetterDecoratorContext + | ClassAccessorDecoratorContext, ): any { - const {kind, name} = context - const props = propsToSignalify + const {kind, name, metadata} = context + const props = __propsToSignalify - if (isMemberDecorator(context)) { - if (context.private) throw new Error('@signal is not supported on private fields yet.') - if (context.static) throw new Error('@signal is not supported on static fields yet.') - } + if (context.static) throw new Error('@signal is not supported on static fields yet.') + + // @prod-prune + queueReactiveDecoratorChecker(props) if (kind === 'field') { - props.set(name, {initialValue: undefined, kind}) + if (context.private && name !== '#finalize') throw new Error('@signal is not supported on private fields yet.') + + if (name === '#finalize') __propsToSignalify = new Map() // reset + else props.set(name, {initialValue: undefined, kind}) + return function (this: object, initialValue: unknown) { + if (name === '#finalize') { + // Special case for Solid proxies: if the object is already a solid proxy, + // all properties are already reactive, no need to signalify. + // @ts-expect-error special indexed access + const proxy = this[$PROXY] as T + if (proxy) return this + + for (const [prop, propSpec] of props) { + let initialValue = propSpec.initialValue + + // @prod-prune + if (!Object.hasOwn(this, prop)) + // continue + throw new PropNotFoundError(prop) + + __createSignalAccessor(this as any, prop, initialValue) + // CONTINUE testing this way of finalizing signal fields + } + return + } + props.get(name)!.initialValue = initialValue return initialValue } + } else if (kind === 'accessor') { + const {get, set} = value as {get: () => unknown; set: (v: unknown) => void} + const signalStorage = new WeakMap>() + let initialValue: unknown = undefined + + return { + init: function (this: object, initialVal: unknown) { + initialValue = initialVal + return initialVal + }, + get: function (this: object): unknown { + __getSignal(this, signalStorage, initialValue)() + return get.call(this) + }, + set: function (this: object, newValue: unknown) { + set.call(this, newValue) + __trackPropSetAtLeastOnce(this, name) // not needed anymore? test it + + const s = __getSignal(this, signalStorage, initialValue) + s(typeof newValue === 'function' ? () => newValue : newValue) + }, + } } else if (kind === 'getter' || kind === 'setter') { - props.set(name, {initialValue: undefined, kind}) - } else { - throw new Error( - 'The @signal decorator is only for use on fields, getters, and setters. Auto accessor support is coming next if there is demand for it.', - ) - } + const getOrSet = value as Function + const initialValue = Undefined - // @prod-prune - queueReactiveDecoratorChecker(props) + if (!Object.hasOwn(metadata, 'signalStoragesPerProp')) metadata.signalStoragesPerProp = {} + const signalsStorages = metadata.signalStoragesPerProp as SignalStorages + + let signalStorage = signalsStorages[name] + if (!signalStorage) signalsStorages[name] = signalStorage = new WeakMap>() + + if (!Object.hasOwn(metadata, 'getterSetterPairs')) metadata.getterSetterPairs = {} + const pairs = metadata.getterSetterPairs as {[key: PropKey]: 0 | 1 | 2} + + // Show a helpful error in case someone forgets to decorate both a getter and setter. + queueMicrotask(() => { + if (pairs[name] !== 2) throw new MissingDecoratorError(name) + }) + + if (kind === 'getter') { + pairs[name] ??= 0 + pairs[name]++ + + return function (this: object): unknown { + __getSignal(this, signalStorage, initialValue)() + return getOrSet.call(this) + } + } else { + pairs[name] ??= 0 + pairs[name]++ + + return function (this: object, newValue: unknown) { + getOrSet.call(this, newValue) + __trackPropSetAtLeastOnce(this, name) + + const s = __getSignal(this, signalStorage, initialValue) + s(typeof newValue === 'function' ? () => newValue : newValue) + } + } + } else throw new InvalidDecorationError() } let checkerQueued = false @@ -117,7 +172,7 @@ function queueReactiveDecoratorChecker(props: Map) { // If the refs are still equal, it means @reactive did not run (forgot // to decorate a class that uses @signal with @reactive). - if (props === propsToSignalify) { + if (props === __propsToSignalify) { throw new Error( // Array.from(map.keys()) instead of [...map.keys()] because it breaks in Oculus browser. `Stray @signal-decorated properties detected: ${Array.from(props.keys()).join( @@ -127,3 +182,31 @@ function queueReactiveDecoratorChecker(props: Map) { } }) } + +class PropNotFoundError extends Error { + constructor(prop: PropertyKey) { + super( + `Property "${String( + prop, + )}" not found on instance of class decorated with \`@reactive\`. Did you forget to use the \`@reactive\` decorator on one of your classes that has a "${String( + prop, + )}" property decorated with \`@signal\`?`, + ) + } +} + +class MissingDecoratorError extends Error { + constructor(prop: PropertyKey) { + super( + `Missing @signal decorator on setter or getter for property "${String( + prop, + )}". The @signal decorator will only work on a getter/setter pair with *both* getter and setter decorated with @signal.`, + ) + } +} + +class InvalidDecorationError extends Error { + constructor() { + super('The @signal decorator is only for use on fields, getters, setters, and auto accessors.') + } +} diff --git a/src/index.test.ts b/src/index.test.ts index 121839e..082463f 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -20,7 +20,7 @@ declare global { describe('classy-solid', () => { describe('createSignalObject()', () => { - it('has gettable and settable values via .get and .set methods', async () => { + it('has gettable and settable values via .get and .set methods', () => { const num = createSignalObject(0) // Set the variable's value by passing a value in. @@ -40,7 +40,7 @@ describe('classy-solid', () => { }) describe('createSignalFunction()', () => { - it('has gettable and settable values via a single overloaded function', async () => { + it('has gettable and settable values via a single overloaded function', () => { const num = createSignalFunction(0) // Set the variable's value by passing a value in. @@ -57,6 +57,18 @@ describe('classy-solid', () => { num(n => n + 1) expect(num()).toBe(3) }) + + it('works with function values', () => { + const f1 = () => 123 + const func = createSignalFunction(f1) + + expect(func()).toBe(f1) + + const f2 = () => 456 + func(() => f2) + + expect(func()).toBe(f2) + }) }) describe('createDeferredEffect()', () => { @@ -137,23 +149,138 @@ describe('classy-solid', () => { class Butterfly { @signal colors = 3 - _wingSize = 2 + #wingSize = 2 - @signal - get wingSize() { - return this._wingSize + @signal get wingSize() { + return this.#wingSize } - set wingSize(s: number) { - this._wingSize = s + @signal set wingSize(s: number) { + this.#wingSize = s } } - it('makes class fields reactive, using class and field/accessor decorators', () => { + it('makes class fields reactive, using class and field/getter/setter decorators', () => { const b = new Butterfly() testButterflyProps(b) }) + // @reactive + class Butterfly2 { + @signal colors = 3 + @signal wingSize = 2 + // @ts-ignore + @signal #finalize + } + + it('makes class fields reactive, using field decorators without class decorator', () => { + const b = new Butterfly2() + + testButterflyProps(b) + }) + + class Butterfly3 { + @signal colors = 3 + + #wingSize = 2 + + @signal get wingSize() { + return this.#wingSize + } + @signal set wingSize(s: number) { + this.#wingSize = s + } + + // @ts-ignore + @signal #finalize + } + + it('makes class fields reactive, using field/getter/setter decorators without class decorator', () => { + const b = new Butterfly3() + + testButterflyProps(b) + }) + + class Butterfly4 { + @signal colors = 3 + @signal accessor wingSize = 2 + // @ts-ignore + @signal #finalize + } + + it('makes class fields reactive, using field/accessor decorators without class decorator', () => { + const b = new Butterfly4() + + testButterflyProps(b) + }) + + @reactive + class Butterfly5 { + @signal colors = 3 + @signal accessor wingSize = 2 + } + + it('makes class fields reactive, using field/accessor decorators with class decorator', () => { + const b = new Butterfly5() + + testButterflyProps(b) + }) + + class Butterfly6 { + @signal accessor #colors = 3 + + getColors() { + return this.#colors + } + setColors(v: number) { + return (this.#colors = v) + } + } + + it('makes private class auto accessor reactive', () => { + const b = new Butterfly6() + testPrivate(b) + }) + + class Butterfly7 { + #_colors = 3 + + @signal get #colors() { + return this.#_colors + } + @signal set #colors(v: number) { + this.#_colors = v + } + + getColors() { + return this.#colors + } + setColors(v: number) { + return (this.#colors = v) + } + } + + it('makes private class getter/setter accessors reactive', () => { + const b = new Butterfly7() + testPrivate(b) + }) + + function testPrivate(b: Pick) { + let count = 0 + + createEffect(() => { + b.getColors() + count++ + }) + + expect(b.getColors()).toBe(3) + expect(count).toBe(1) + + b.setColors(5) + expect(b.getColors()).toBe(5) + expect(count).toBe(2) + } + const ensure = it ensure('overridden fields work as expected', async () => { @@ -215,14 +342,13 @@ describe('classy-solid', () => { class Butterfly extends Insect { @signal colors = 3 - _wingSize = 2 + #wingSize = 2 - @signal - get wingSize() { - return this._wingSize + @signal get wingSize() { + return this.#wingSize } - set wingSize(s: number) { - this._wingSize = s + @signal set wingSize(s: number) { + this.#wingSize = s } constructor(arg: number) { @@ -409,13 +535,13 @@ describe('classy-solid', () => { class Butterfly { colors = 3 - _wingSize = 2 + #wingSize = 2 get wingSize() { - return this._wingSize + return this.#wingSize } set wingSize(s: number) { - this._wingSize = s + this.#wingSize = s } constructor() { @@ -437,18 +563,18 @@ describe('classy-solid', () => { class Butterfly { declare colors: number - declare _wingSize: number + #wingSize: number get wingSize() { - return this._wingSize + return this.#wingSize } set wingSize(s: number) { - this._wingSize = s + this.#wingSize = s } constructor() { this.colors = 3 - this._wingSize = 2 + this.#wingSize = 2 signalify(this, 'colors', 'wingSize') } @@ -823,7 +949,7 @@ describe('classy-solid', () => { }) }) -function testButterflyProps(b: {colors: number; wingSize: number; _wingSize: number}, initialColors = 3) { +function testButterflyProps(b: {colors: number; wingSize: number}, initialColors = 3) { let count = 0 createRoot(() => { @@ -836,7 +962,6 @@ function testButterflyProps(b: {colors: number; wingSize: number; _wingSize: num expect(b.colors).toBe(initialColors, 'initial colors value') expect(b.wingSize).toBe(2, 'initial wingSize value') - expect(b._wingSize).toBe(2, 'ensure the original accessor works') expect(count).toBe(1, 'Should be reactive') b.colors++ @@ -847,7 +972,6 @@ function testButterflyProps(b: {colors: number; wingSize: number; _wingSize: num b.wingSize++ expect(b.wingSize).toBe(3, 'incremented wingSize value') - expect(b._wingSize).toBe(3, 'ensure the original accessor works') expect(count).toBe(3, 'Should be reactive') } diff --git a/src/signalify.ts b/src/signalify.ts index fe76078..3891148 100644 --- a/src/signalify.ts +++ b/src/signalify.ts @@ -1,6 +1,7 @@ import {getInheritedDescriptor} from 'lowclass/dist/getInheritedDescriptor.js' -import {createSignal, $PROXY, untrack, type Signal} from 'solid-js' +import {$PROXY, untrack} from 'solid-js' import type {PropKey} from './decorators/types.js' +import {createSignalFunction, type SignalFunction} from './createSignalFunction.js' type AnyObject = Record @@ -73,23 +74,12 @@ export function signalify(obj: AnyObject, ...props: [key: PropertyKey, initialVa const _prop = (isTuple ? prop[0] : prop) as PropKey const initialValue = isTuple ? prop[1] : untrack(() => obj[_prop]) - createSignalAccessor(obj, _prop, initialValue) + __createSignalAccessor(obj, _prop, initialValue) } return obj } -let gotCreateSignalAccessor = false - -/** - * This ensures that `createSignalAccessor` is kept internal to classy-solid only. - */ -export function getCreateSignalAccessor() { - if (gotCreateSignalAccessor) throw new Error('Export "createSignalAccessor" is internal to classy-solid only.') - gotCreateSignalAccessor = true - return createSignalAccessor -} - // propsSetAtLeastOnce is a Set that tracks which reactive properties have been // set at least once. const propsSetAtLeastOnce = new WeakMap>() @@ -101,92 +91,81 @@ export function __isPropSetAtLeastOnce(instance: object, prop: string | symbol) return !!propsSetAtLeastOnce.get(instance)?.has(prop) } -function trackPropSetAtLeastOnce(instance: object, prop: string | symbol) { +export function __trackPropSetAtLeastOnce(instance: object, prop: string | symbol) { if (!propsSetAtLeastOnce.has(instance)) propsSetAtLeastOnce.set(instance, new Set()) propsSetAtLeastOnce.get(instance)!.add(prop) } const isSignalGetter = new WeakSet() -function createSignalAccessor(obj: T, prop: Exclude, initialVal: unknown): void { +export function __createSignalAccessor( + obj: T, + prop: Exclude, + initialVal: unknown, +): void { let descriptor: PropertyDescriptor | undefined = getInheritedDescriptor(obj, prop) let originalGet: (() => any) | undefined let originalSet: ((v: any) => void) | undefined + const isAccessor = !!(descriptor?.get || descriptor?.set) if (descriptor) { originalGet = descriptor.get originalSet = descriptor.set if (originalGet && isSignalGetter.has(originalGet)) return + // reactivity requires both + if (isAccessor && !(originalGet && originalSet)) return warnNotReadWrite(prop) - if (originalGet || originalSet) { - // reactivity requires both - if (!originalGet || !originalSet) return warnNotReadWrite(prop) + if (!isAccessor) { + // no need to make a signal that can't be written to + if (!descriptor.writable) return warnNotWritable(prop) - delete descriptor.get - delete descriptor.set - } else { // If there was a value descriptor, trust it as the source of truth // for initialVal. For example, if the user class modifies the value // after the initializer, it will have a different value than what // we tracked from the initializer. initialVal = descriptor.value - - // if it isn't writable, we don't need to make a reactive variable because - // the value won't change - if (!descriptor.writable) return warnNotWritable(prop) - - delete descriptor.value - delete descriptor.writable } } - const signalStorage = new WeakMap>() + const signalStorage = new WeakMap>() - descriptor = { + const newDescriptor = { configurable: true, - enumerable: true, - ...descriptor, - get: originalGet + enumerable: descriptor?.enumerable, + get: isAccessor ? function (this: object): unknown { - const s = getSignal(this, signalStorage, initialVal) - s[0]() // read + __getSignal(this, signalStorage, initialVal)() return originalGet!.call(this) } : function (this: object): unknown { - const s = getSignal(this, signalStorage, initialVal) - return s[0]() // read + return __getSignal(this, signalStorage, initialVal)() }, - set: originalSet + set: isAccessor ? function (this: object, newValue: unknown) { originalSet!.call(this, newValue) + __trackPropSetAtLeastOnce(this, prop) - trackPropSetAtLeastOnce(this, prop) - - // write - const s = getSignal(this, signalStorage, initialVal) - if (typeof newValue === 'function') s[1](() => newValue) - else s[1](newValue) + const s = __getSignal(this, signalStorage, initialVal) + s(typeof newValue === 'function' ? () => newValue : newValue) } : function (this: object, newValue: unknown) { - trackPropSetAtLeastOnce(this, prop) + __trackPropSetAtLeastOnce(this, prop) - // write - const s = getSignal(this, signalStorage, initialVal) - if (typeof newValue === 'function') s[1](() => newValue) - else s[1](newValue) + const s = __getSignal(this, signalStorage, initialVal) + s(typeof newValue === 'function' ? () => newValue : newValue) }, } - isSignalGetter.add(descriptor.get!) + isSignalGetter.add(newDescriptor.get!) - Object.defineProperty(obj, prop, descriptor) + Object.defineProperty(obj, prop, newDescriptor) } -function getSignal(obj: object, storage: WeakMap>, initialVal: unknown) { +export function __getSignal(obj: object, storage: WeakMap>, initialVal: unknown) { let s = storage.get(obj) - if (!s) storage.set(obj, (s = createSignal(initialVal, {equals: false}))) + if (!s) storage.set(obj, (s = createSignalFunction(initialVal, {equals: false}))) return s }