diff --git a/dist/Effectful.d.ts.map b/dist/Effectful.d.ts.map index 999ccd9..25b1a7e 100644 --- a/dist/Effectful.d.ts.map +++ b/dist/Effectful.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"Effectful.d.ts","sourceRoot":"","sources":["../src/Effectful.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,KAAK,EAA8D,MAAM,UAAU,CAAA;AAChG,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAA;AAChE,OAAO,EAAwB,KAAK,MAAM,EAAC,MAAM,4BAA4B,CAAA;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,cAAc,EAAE,IAAI,EAAE,CAAC;;;QAIzD;;;;;;;;;;;;;;;;;WAiBG;yBACc,MAAM,IAAI;QAQ3B;;WAEG;;kCAUgB,MAAM,IAAI;;uBAoBrB,KAAK,GAAG,IAAI;yBACV,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI;kCAEV,MAAM,IAAI;;;MA0B9B;;;;QAvFC;;;;;;;;;;;;;;;;;WAiBG;;QASH;;WAEG;;;;;;;;;;;;AA6DL;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,OAAQ,SAAQ,YAAmB;CAAG"} \ No newline at end of file +{"version":3,"file":"Effectful.d.ts","sourceRoot":"","sources":["../src/Effectful.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,KAAK,EAA8D,MAAM,UAAU,CAAA;AAChG,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAA;AAChE,OAAO,EAAwB,KAAK,MAAM,EAAC,MAAM,4BAA4B,CAAA;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,cAAc,EAAE,IAAI,EAAE,CAAC;;;QAIzD;;;;;;;;;;;;;;;;;WAiBG;yBACc,MAAM,IAAI;QAQ3B;;WAEG;;kCAUgB,MAAM,IAAI;;uBAoBrB,KAAK,GAAG,IAAI;yBACV,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI;kCAEV,MAAM,IAAI;;;MA0B9B;;;;QAvFC;;;;;;;;;;;;;;;;;WAiBG;+BACoB,IAAI;QAQ3B;;WAEG;;wCAUsB,IAAI;;uBAoBrB,KAAK,GAAG,IAAI;gCACH,IAAI;wCAEI,IAAI;;;;;;AA4B/B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,OAAQ,SAAQ,YAAmB;CAAG"} \ No newline at end of file diff --git a/dist/Effectful.js.map b/dist/Effectful.js.map index 281781e..50334cf 100644 --- a/dist/Effectful.js.map +++ b/dist/Effectful.js.map @@ -1 +1 @@ -{"version":3,"file":"Effectful.js","names":["createEffect","onCleanup","createRoot","getOwner","runWithOwner","createStoppableEffect","Effectful","Base","effects","Set","fn","method","createEffect1","queueMicrotask","createEffect2","stopEffects","stopEffects1","stopEffects2","#createEffect1","effect","add","delete","#stopEffects1","stop","owner","dispose","#createEffect2","#stopEffects2","Effects"],"sources":["../src/Effectful.ts"],"sourcesContent":["import {type Owner, createEffect, onCleanup, createRoot, getOwner, runWithOwner} from 'solid-js'\nimport type {AnyConstructor} from 'lowclass/dist/Constructor.js'\nimport {createStoppableEffect, type Effect} from './createStoppableEffect.js'\n\n/**\n * @class Effectful -\n *\n * `mixin`\n *\n * Create Solid.js effects using `this.createEffect(fn)` and easily stop them\n * all by calling `this.stopEffects()`.\n *\n * Example:\n *\n * ```js\n * import {reactive, signal} from 'classy-solid'\n * import {foo} from 'somewhere'\n * import {bar} from 'elsewhere'\n *\n * class MyClass extends Effectful(BaseClass) {\n * constructor() {\n * super()\n *\n * // Log `foo` and `bar` any time either of them change.\n * this.createEffect(() => {\n * console.log('foo, bar:', foo(), bar())\n * })\n *\n * // Log only `bar` any time it changes.\n * this.createEffect(() => {\n * console.log('bar:', bar())\n * })\n * }\n *\n * dispose() {\n * // Later, stop both of the effects.\n * this.stopEffects()\n * }\n * }\n * ```\n */\nexport function Effectful(Base: T) {\n\treturn class Effectful extends Base {\n\t\t#effects = new Set()\n\n\t\t/**\n\t\t * Create a Solid.js effect. The difference from regular\n\t\t * `createEffect()` is that `this` tracks the effects created, so that\n\t\t * they can all be stopped with `this.stopEffects()`.\n\t\t *\n\t\t * Effects can also be stopped or resumed individually:\n\t\t *\n\t\t * ```js\n\t\t * const effect1 = this.createEffect(() => {...})\n\t\t * const effect2 = this.createEffect(() => {...})\n\t\t *\n\t\t * // ...later\n\t\t * effect1.stop()\n\t\t *\n\t\t * // ...later\n\t\t * effect1.resume()\n\t\t * ```\n\t\t */\n\t\tcreateEffect(fn: () => void) {\n\t\t\tlet method = 4\n\t\t\tif (method === 1) this.#createEffect1(fn) // not working, bugs out when inside a Solid render() root, effects stop re-running. https://discord.com/channels/722131463138705510/751355413701591120/1188246668466991134\n\t\t\tif (method === 2) createRoot(() => this.#createEffect1(fn)) // works without nesting, but leaks stopped effects until the parent owner is cleaned up (will never clean up if the parent is running for lifetime of the app).\n\t\t\tif (method === 3) queueMicrotask(() => this.#createEffect1(fn)) // works without nesting, without leaks\n\t\t\tif (method === 4) this.#createEffect2(fn) // works with nesting, without leaks\n\t\t}\n\n\t\t/**\n\t\t * Stop all of the effects that were created.\n\t\t */\n\t\tstopEffects() {\n\t\t\tlet method = 2\n\t\t\tif (method === 1) this.#stopEffects1()\n\t\t\tif (method === 2) this.#stopEffects2()\n\t\t}\n\n\t\t// Method 1 //////////////////////////////////////////\n\t\t// Works fine when not in a parent context, or else currently leaks or has the above mentioned bug while a parent exists.\n\n\t\t#createEffect1(fn: () => void) {\n\t\t\tlet effect: Effect | null = null\n\n\t\t\teffect = createStoppableEffect(() => {\n\t\t\t\tif (effect) this.#effects.add(effect)\n\t\t\t\t// nest the user's effect so that if it re-runs a lot it is not deleting/adding from/to our #effects Set a lot.\n\t\t\t\tcreateEffect(fn)\n\t\t\t\tonCleanup(() => this.#effects.delete(effect!))\n\t\t\t})\n\n\t\t\tthis.#effects.add(effect)\n\t\t}\n\n\t\t#stopEffects1() {\n\t\t\tfor (const effect of this.#effects) effect.stop()\n\t\t}\n\n\t\t// Method 2 //////////////////////////////////////////\n\t\t// Works, with nesting, no leaks.\n\n\t\t#owner: Owner | null = null\n\t\t#dispose: (() => void) | null = null\n\n\t\t#createEffect2(fn: () => void) {\n\t\t\tif (!this.#owner) {\n\t\t\t\tcreateRoot(dispose => {\n\t\t\t\t\tthis.#owner = getOwner()\n\t\t\t\t\tthis.#dispose = dispose\n\t\t\t\t\tthis.#createEffect2(fn)\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\tlet owner = getOwner()\n\t\t\t\twhile (owner && owner !== this.#owner) owner = owner?.owner ?? null\n\n\t\t\t\t// this.#owner found in the parents of current owner therefore,\n\t\t\t\t// run with current nested owner like a regular solid\n\t\t\t\t// createEffect()\n\t\t\t\tif (owner === this.#owner) return createEffect(fn)\n\n\t\t\t\t// this.#owner wasn't found on the parent owners\n\t\t\t\t// run with this.#owner\n\t\t\t\trunWithOwner(this.#owner, () => createEffect(fn))\n\t\t\t}\n\t\t}\n\n\t\t#stopEffects2() {\n\t\t\tthis.#dispose?.()\n\t\t}\n\t}\n}\n\n/**\n * Shortcut for instantiating or extending directly instead of using the mixin.\n * F.e.\n *\n * ```js\n * class Car extends Effects {\n * start() {\n * this.createEffect(() => {...})\n * this.createEffect(() => {...})\n * }\n * stop() {\n * this.stopEffects()\n * }\n * }\n *\n * const specialEffects = new Effects()\n * specialEffects.createEffect(() => {})\n * // ...later\n * specialEffects.stopEffects()\n * ```\n */\nexport class Effects extends Effectful(class {}) {}\n"],"mappings":"AAAA,SAAoBA,YAAY,EAAEC,SAAS,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,YAAY,QAAO,UAAU;AAEhG,SAAQC,qBAAqB,QAAoB,4BAA4B;;AAE7E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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ACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMG,OAAO,SAAStB,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"Effectful.js","names":["createEffect","onCleanup","createRoot","getOwner","runWithOwner","createStoppableEffect","Effectful","Base","effects","Set","fn","method","createEffect1","queueMicrotask","createEffect2","stopEffects","stopEffects1","stopEffects2","#createEffect1","effect","add","delete","#stopEffects1","stop","owner","dispose","#createEffect2","#stopEffects2","Effects"],"sources":["../src/Effectful.ts"],"sourcesContent":["import {type Owner, createEffect, onCleanup, createRoot, getOwner, runWithOwner} from 'solid-js'\nimport type {AnyConstructor} from 'lowclass/dist/Constructor.js'\nimport {createStoppableEffect, type Effect} from './createStoppableEffect.js'\n\n/**\n * @class Effectful -\n *\n * `mixin`\n *\n * Create Solid.js effects using `this.createEffect(fn)` and easily stop them\n * all by calling `this.stopEffects()`.\n *\n * Example:\n *\n * ```js\n * import {reactive, signal} from 'classy-solid'\n * import {foo} from 'somewhere'\n * import {bar} from 'elsewhere'\n *\n * class MyClass extends Effectful(BaseClass) {\n * constructor() {\n * super()\n *\n * // Log `foo` and `bar` any time either of them change.\n * this.createEffect(() => {\n * console.log('foo, bar:', foo(), bar())\n * })\n *\n * // Log only `bar` any time it changes.\n * this.createEffect(() => {\n * console.log('bar:', bar())\n * })\n * }\n *\n * dispose() {\n * // Later, stop both of the effects.\n * this.stopEffects()\n * }\n * }\n * ```\n */\nexport function Effectful(Base: T) {\n\treturn class Effectful extends Base {\n\t\t#effects = new Set()\n\n\t\t/**\n\t\t * Create a Solid.js effect. The difference from regular\n\t\t * `createEffect()` is that `this` tracks the effects created, so that\n\t\t * they can all be stopped with `this.stopEffects()`.\n\t\t *\n\t\t * Effects can also be stopped or resumed individually:\n\t\t *\n\t\t * ```js\n\t\t * const effect1 = this.createEffect(() => {...})\n\t\t * const effect2 = this.createEffect(() => {...})\n\t\t *\n\t\t * // ...later\n\t\t * effect1.stop()\n\t\t *\n\t\t * // ...later\n\t\t * effect1.resume()\n\t\t * ```\n\t\t */\n\t\tcreateEffect(fn: () => void) {\n\t\t\tlet method = 4\n\t\t\tif (method === 1) this.#createEffect1(fn) // not working, bugs out when inside a Solid render() root, effects stop re-running. https://discord.com/channels/722131463138705510/751355413701591120/1188246668466991134\n\t\t\tif (method === 2) createRoot(() => this.#createEffect1(fn)) // works without nesting, but leaks stopped effects until the parent owner is cleaned up (will never clean up if the parent is running for lifetime of the app).\n\t\t\tif (method === 3) queueMicrotask(() => this.#createEffect1(fn)) // works without nesting, without leaks\n\t\t\tif (method === 4) this.#createEffect2(fn) // works with nesting, without leaks\n\t\t}\n\n\t\t/**\n\t\t * Stop all of the effects that were created.\n\t\t */\n\t\tstopEffects() {\n\t\t\tlet method = 2\n\t\t\tif (method === 1) this.#stopEffects1()\n\t\t\tif (method === 2) this.#stopEffects2()\n\t\t}\n\n\t\t// Method 1 //////////////////////////////////////////\n\t\t// Works fine when not in a parent context, or else currently leaks or has the above mentioned bug while a parent exists.\n\n\t\t#createEffect1(fn: () => void) {\n\t\t\tlet effect: Effect | null = null\n\n\t\t\teffect = createStoppableEffect(() => {\n\t\t\t\tif (effect) this.#effects.add(effect)\n\t\t\t\t// nest the user's effect so that if it re-runs a lot it is not deleting/adding from/to our #effects Set a lot.\n\t\t\t\tcreateEffect(fn)\n\t\t\t\tonCleanup(() => this.#effects.delete(effect!))\n\t\t\t})\n\n\t\t\tthis.#effects.add(effect)\n\t\t}\n\n\t\t#stopEffects1() {\n\t\t\tfor (const effect of this.#effects) effect.stop()\n\t\t}\n\n\t\t// Method 2 //////////////////////////////////////////\n\t\t// Works, with nesting, no leaks.\n\n\t\t#owner: Owner | null = null\n\t\t#dispose: (() => void) | null = null\n\n\t\t#createEffect2(fn: () => void) {\n\t\t\tif (!this.#owner) {\n\t\t\t\tcreateRoot(dispose => {\n\t\t\t\t\tthis.#owner = getOwner()\n\t\t\t\t\tthis.#dispose = dispose\n\t\t\t\t\tthis.#createEffect2(fn)\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\tlet owner = getOwner()\n\t\t\t\twhile (owner && owner !== this.#owner) owner = owner?.owner ?? null\n\n\t\t\t\t// this.#owner found in the parents of current owner therefore,\n\t\t\t\t// run with current nested owner like a regular solid\n\t\t\t\t// createEffect()\n\t\t\t\tif (owner === this.#owner) return createEffect(fn)\n\n\t\t\t\t// this.#owner wasn't found on the parent owners\n\t\t\t\t// run with this.#owner\n\t\t\t\trunWithOwner(this.#owner, () => createEffect(fn))\n\t\t\t}\n\t\t}\n\n\t\t#stopEffects2() {\n\t\t\tthis.#dispose?.()\n\t\t}\n\t}\n}\n\n/**\n * Shortcut for instantiating or extending directly instead of using the mixin.\n * F.e.\n *\n * ```js\n * class Car extends Effects {\n * start() {\n * this.createEffect(() => {...})\n * this.createEffect(() => {...})\n * }\n * stop() {\n * this.stopEffects()\n * }\n * }\n *\n * const specialEffects = new Effects()\n * specialEffects.createEffect(() => {})\n * // ...later\n * specialEffects.stopEffects()\n * ```\n */\nexport class Effects extends Effectful(class {}) {}\n"],"mappings":"AAAA,SAAoBA,YAAY,EAAEC,SAAS,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,YAAY,QAAO,UAAU;AAEhG,SAAQC,qBAAqB,QAAoB,4BAA4B;;AAE7E;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,OAAO,SAASC,SAASA,CAA2BC,IAAO,EAAE;EAC5D,OAAO,MAAMD,SAAS,SAASC,IAAI,CAAC;IACnC,CAACC,OAAO,GAAG,IAAIC,GAAG,CAAS,CAAC;;IAE5B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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,CAACI,IAAI,CAAC,CAAC;IAClD;;IAEA;IACA;;IAEA,CAACC,KAAK,GAAiB,IAAI;IAC3B,CAACC,OAAO,GAAwB,IAAI;IAEpC,CAACX,aAAaY,CAAChB,EAAc,EAAE;MAC9B,IAAI,CAAC,IAAI,CAAC,CAACc,KAAK,EAAE;QACjBtB,UAAU,CAACuB,OAAO,IAAI;UACrB,IAAI,CAAC,CAACD,KAAK,GAAGrB,QAAQ,CAAC,CAAC;UACxB,IAAI,CAAC,CAACsB,OAAO,GAAGA,OAAO;UACvB,IAAI,CAAC,CAACX,aAAa,CAACJ,EAAE,CAAC;QACxB,CAAC,CAAC;MACH,CAAC,MAAM;QACN,IAAIc,KAAK,GAAGrB,QAAQ,CAAC,CAAC;QACtB,OAAOqB,KAAK,IAAIA,KAAK,KAAK,IAAI,CAAC,CAACA,KAAK,EAAEA,KAAK,GAAGA,KAAK,EAAEA,KAAK,IAAI,IAAI;;QAEnE;QACA;QACA;QACA,IAAIA,KAAK,KAAK,IAAI,CAAC,CAACA,KAAK,EAAE,OAAOxB,YAAY,CAACU,EAAE,CAAC;;QAElD;QACA;QACAN,YAAY,CAAC,IAAI,CAAC,CAACoB,KAAK,EAAE,MAAMxB,YAAY,CAACU,EAAE,CAAC,CAAC;MAClD;IACD;IAEA,CAACO,YAAYU,CAAA,EAAG;MACf,IAAI,CAAC,CAACF,OAAO,GAAG,CAAC;IAClB;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMG,OAAO,SAAStB,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC","ignoreList":[]} \ No newline at end of file diff --git a/dist/component.js.map b/dist/component.js.map index 31faf2d..c1d05f7 100644 --- a/dist/component.js.map +++ b/dist/component.js.map @@ -1 +1 @@ -{"version":3,"file":"component.js","names":["Constructor","onMount","createEffect","onCleanup","$TRACK","createMemo","component","Base","context","kind","Error","Class","props","instance","keys","Object","equals","prev","next","length","i","l","prop","template"],"sources":["../src/component.ts"],"sourcesContent":["import {Constructor} from 'lowclass/dist/Constructor.js'\nimport {onMount, createEffect, onCleanup, type JSX, $TRACK, createMemo} from 'solid-js'\n\n// https://github.com/ryansolid/dom-expressions/pull/122\n\ninterface PossibleComponent {\n\tonMount?(): void\n\tonCleanup?(): void\n\ttemplate?(props: Record): JSX.Element\n}\ninterface PossiblyReactiveConstructor {}\n\n/**\n * A decorator for using classes as Solid components.\n *\n * Example:\n *\n * ```js\n * ⁣@component\n * ⁣@reactive\n * class MyComp {\n * ⁣@signal last = 'none'\n *\n * onMount() {\n * console.log('mounted')\n * }\n *\n * template(props) {\n * // here we use `props` passed in, or the signal on `this` which is also\n * // treated as a prop\n * return

Hello, my name is {props.first} {this.last}

\n * }\n * }\n *\n * render(() => )\n * ```\n */\nexport function component(Base: T, context?: DecoratorContext): any {\n\tif (typeof Base !== 'function' || (context && context.kind !== 'class'))\n\t\tthrow new Error('The @component decorator should only be used on a class.')\n\n\tconst Class = Constructor(Base)\n\n\treturn function (props: Record): JSX.Element {\n\t\tconst instance = new Class()\n\n\t\tconst keys = createMemo(\n\t\t\t() => {\n\t\t\t\tprops[$TRACK]\n\t\t\t\treturn Object.keys(props)\n\t\t\t},\n\t\t\t[],\n\t\t\t{\n\t\t\t\tequals(prev, next) {\n\t\t\t\t\tif (prev.length !== next.length) return false\n\t\t\t\t\tfor (let i = 0, l = prev.length; i < l; i += 1) if (prev[i] !== next[i]) return false\n\t\t\t\t\treturn true\n\t\t\t\t},\n\t\t\t},\n\t\t)\n\n\t\tcreateEffect(() => {\n\t\t\tfor (const prop of keys()) {\n\t\t\t\tcreateEffect(() => {\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tinstance[prop] = props[prop]\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\n\t\tif (instance.onMount) onMount(() => instance.onMount?.())\n\t\tif (instance.onCleanup) onCleanup(() => instance.onCleanup?.())\n\n\t\treturn instance.template?.(props) ?? null\n\t}\n}\n\ndeclare module 'solid-js' {\n\tnamespace JSX {\n\t\t// Tells JSX what properties class components should have.\n\t\tinterface ElementClass {\n\t\t\ttemplate?(props: Record): JSX.Element\n\t\t}\n\n\t\t// Tells JSX where to look up prop types on class components.\n\t\tinterface ElementAttributesProperty {\n\t\t\tPropTypes: {}\n\t\t}\n\t}\n}\n\nexport type Props = Pick & {\n\tchildren?: JSX.Element\n}\n"],"mappings":"AAAA,SAAQA,WAAW,QAAO,8BAA8B;AACxD,SAAQC,OAAO,EAAEC,YAAY,EAAEC,SAAS,EAAYC,MAAM,EAAEC,UAAU,QAAO,UAAU;;AAEvF;;AASA;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,SAASA,CAAwBC,IAAO,EAAEC,OAA0B,EAAO;EAC1F,IAAI,OAAOD,IAAI,KAAK,UAAU,IAAKC,OAAO,IAAIA,OAAO,CAACC,IAAI,KAAK,OAAQ,EACtE,MAAM,IAAIC,KAAK,CAAC,0DAA0D,CAAC;EAE5E,MAAMC,KAAK,GAAGX,WAAW,CAAiDO,IAAI,CAAC;EAE/E,OAAO,UAAUK,KAAuC,EAAe;IACtE,MAAMC,QAAQ,GAAG,IAAIF,KAAK,CAAC,CAAC;IAE5B,MAAMG,IAAI,GAAGT,UAAU,CACtB,MAAM;MACLO,KAAK,CAACR,MAAM,CAAC;MACb,OAAOW,MAAM,CAACD,IAAI,CAACF,KAAK,CAAC;IAC1B,CAAC,EACD,EAAE,EACF;MACCI,MAAMA,CAACC,IAAI,EAAEC,IAAI,EAAE;QAClB,IAAID,IAAI,CAACE,MAAM,KAAKD,IAAI,CAACC,MAAM,EAAE,OAAO,KAAK;QAC7C,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAGJ,IAAI,CAACE,MAAM,EAAEC,CAAC,GAAGC,CAAC,EAAED,CAAC,IAAI,CAAC,EAAE,IAAIH,IAAI,CAACG,CAAC,CAAC,KAAKF,IAAI,CAACE,CAAC,CAAC,EAAE,OAAO,KAAK;QACrF,OAAO,IAAI;MACZ;IACD,CACD,CAAC;IAEDlB,YAAY,CAAC,MAAM;MAClB,KAAK,MAAMoB,IAAI,IAAIR,IAAI,CAAC,CAAC,EAAE;QAC1BZ,YAAY,CAAC,MAAM;UAClB;UACAW,QAAQ,CAACS,IAAI,CAAC,GAAGV,KAAK,CAACU,IAAI,CAAC;QAC7B,CAAC,CAAC;MACH;IACD,CAAC,CAAC;IAEF,IAAIT,QAAQ,CAACZ,OAAO,EAAEA,OAAO,CAAC,MAAMY,QAAQ,CAACZ,OAAO,GAAG,CAAC,CAAC;IACzD,IAAIY,QAAQ,CAACV,SAAS,EAAEA,SAAS,CAAC,MAAMU,QAAQ,CAACV,SAAS,GAAG,CAAC,CAAC;IAE/D,OAAOU,QAAQ,CAACU,QAAQ,GAAGX,KAAK,CAAC,IAAI,IAAI;EAC1C,CAAC;AACF"} \ No newline at end of file +{"version":3,"file":"component.js","names":["Constructor","onMount","createEffect","onCleanup","$TRACK","createMemo","component","Base","context","kind","Error","Class","props","instance","keys","Object","equals","prev","next","length","i","l","prop","template"],"sources":["../src/component.ts"],"sourcesContent":["import {Constructor} from 'lowclass/dist/Constructor.js'\nimport {onMount, createEffect, onCleanup, type JSX, $TRACK, createMemo} from 'solid-js'\n\n// https://github.com/ryansolid/dom-expressions/pull/122\n\ninterface PossibleComponent {\n\tonMount?(): void\n\tonCleanup?(): void\n\ttemplate?(props: Record): JSX.Element\n}\ninterface PossiblyReactiveConstructor {}\n\n/**\n * A decorator for using classes as Solid components.\n *\n * Example:\n *\n * ```js\n * ⁣@component\n * ⁣@reactive\n * class MyComp {\n * ⁣@signal last = 'none'\n *\n * onMount() {\n * console.log('mounted')\n * }\n *\n * template(props) {\n * // here we use `props` passed in, or the signal on `this` which is also\n * // treated as a prop\n * return

Hello, my name is {props.first} {this.last}

\n * }\n * }\n *\n * render(() => )\n * ```\n */\nexport function component(Base: T, context?: DecoratorContext): any {\n\tif (typeof Base !== 'function' || (context && context.kind !== 'class'))\n\t\tthrow new Error('The @component decorator should only be used on a class.')\n\n\tconst Class = Constructor(Base)\n\n\treturn function (props: Record): JSX.Element {\n\t\tconst instance = new Class()\n\n\t\tconst keys = createMemo(\n\t\t\t() => {\n\t\t\t\tprops[$TRACK]\n\t\t\t\treturn Object.keys(props)\n\t\t\t},\n\t\t\t[],\n\t\t\t{\n\t\t\t\tequals(prev, next) {\n\t\t\t\t\tif (prev.length !== next.length) return false\n\t\t\t\t\tfor (let i = 0, l = prev.length; i < l; i += 1) if (prev[i] !== next[i]) return false\n\t\t\t\t\treturn true\n\t\t\t\t},\n\t\t\t},\n\t\t)\n\n\t\tcreateEffect(() => {\n\t\t\tfor (const prop of keys()) {\n\t\t\t\tcreateEffect(() => {\n\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\tinstance[prop] = props[prop]\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\n\t\tif (instance.onMount) onMount(() => instance.onMount?.())\n\t\tif (instance.onCleanup) onCleanup(() => instance.onCleanup?.())\n\n\t\treturn instance.template?.(props) ?? null\n\t}\n}\n\ndeclare module 'solid-js' {\n\tnamespace JSX {\n\t\t// Tells JSX what properties class components should have.\n\t\tinterface ElementClass {\n\t\t\ttemplate?(props: Record): JSX.Element\n\t\t}\n\n\t\t// Tells JSX where to look up prop types on class components.\n\t\tinterface ElementAttributesProperty {\n\t\t\tPropTypes: {}\n\t\t}\n\t}\n}\n\nexport type Props = Pick & {\n\tchildren?: JSX.Element\n}\n"],"mappings":"AAAA,SAAQA,WAAW,QAAO,8BAA8B;AACxD,SAAQC,OAAO,EAAEC,YAAY,EAAEC,SAAS,EAAYC,MAAM,EAAEC,UAAU,QAAO,UAAU;;AAEvF;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;A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,CAACZ,OAAO,GAAG,CAAC,CAAC;IACzD,IAAIY,QAAQ,CAACV,SAAS,EAAEA,SAAS,CAAC,MAAMU,QAAQ,CAACV,SAAS,GAAG,CAAC,CAAC;IAE/D,OAAOU,QAAQ,CAACU,QAAQ,GAAGX,KAAK,CAAC,IAAI,IAAI;EAC1C,CAAC;AACF","ignoreList":[]} \ No newline at end of file diff --git a/dist/createDeferredEffect.d.ts.map b/dist/createDeferredEffect.d.ts.map index 47da4f0..0adeae0 100644 --- a/dist/createDeferredEffect.d.ts.map +++ b/dist/createDeferredEffect.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"createDeferredEffect.d.ts","sourceRoot":"","sources":["../src/createDeferredEffect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,YAAY,IAAI,aAAa,EAAE,YAAY,EAAoC,MAAM,UAAU,CAAA;AAevG,eAAO,IAAI,YAAY,sBAgCG,CAAA;AAM1B,eAAO,MAAM,oBAAoB,qBA0CR,CAAA"} \ No newline at end of file +{"version":3,"file":"createDeferredEffect.d.ts","sourceRoot":"","sources":["../src/createDeferredEffect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,YAAY,IAAI,aAAa,EAAE,YAAY,EAAoC,MAAM,UAAU,CAAA;AAevG,eAAO,IAAI,YAAY,EAgCjB,OAAO,aAAa,CAAA;AAM1B,eAAO,MAAM,oBAAoB,EA0C3B,OAAO,YAAY,CAAA"} \ No newline at end of file diff --git a/dist/createDeferredEffect.js.map b/dist/createDeferredEffect.js.map index 09c9b42..943318f 100644 --- a/dist/createDeferredEffect.js.map +++ b/dist/createDeferredEffect.js.map @@ -1 +1 @@ -{"version":3,"file":"createDeferredEffect.js","names":["createSignal","_createSignal","createEffect","onCleanup","getOwner","runWithOwner","effectQueue","Set","runningEffects","effectDeps","Map","currentEffect","value","options","_get","_set","get","deps","set","add","v","fn","dep","delete","effectTaskIsScheduled","createDeferredEffect","initial","prev","clear","owner","queueMicrotask","runEffects"],"sources":["../src/createDeferredEffect.ts"],"sourcesContent":["// TODO switch to non-dep-tracking non-queue-modifying deferred signals, because those do not break with regular effects.\n\nimport {createSignal as _createSignal, createEffect, onCleanup, getOwner, runWithOwner} from 'solid-js'\n\nimport type {EffectFunction} from 'solid-js/types/reactive/signal'\n\nconst effectQueue: Set> = new Set()\nlet runningEffects = false\n\n// map of effects to dependencies\nconst effectDeps = new Map, Set<(v: any) => any>>()\nlet currentEffect: EffectFunction = () => {}\n\n// Override createSignal in order to implement custom tracking of effect\n// dependencies, so that when signals change, we are aware which dependenct\n// effects need to be moved to the end of the effect queue while running\n// deferred effects in a microtask.\nexport let createSignal = ((value, options) => {\n\tlet [_get, _set] = _createSignal(value, options)\n\n\tconst get = (() => {\n\t\tif (!runningEffects) return _get()\n\n\t\tlet deps = effectDeps.get(currentEffect)\n\t\tif (!deps) effectDeps.set(currentEffect, (deps = new Set()))\n\t\tdeps.add(_set)\n\n\t\treturn _get()\n\t}) as typeof _get\n\n\tconst set = (v => {\n\t\tif (!runningEffects) return _set(v as any)\n\n\t\t// This is inefficient, for proof of concept, unable to use Solid\n\t\t// internals on the outside.\n\t\tfor (const [fn, deps] of effectDeps) {\n\t\t\tfor (const dep of deps) {\n\t\t\t\tif (dep === _set) {\n\t\t\t\t\t// move to the end\n\t\t\t\t\teffectQueue.delete(fn)\n\t\t\t\t\teffectQueue.add(fn)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn _set(v as any)\n\t}) as typeof _set\n\n\treturn [get, set]\n}) as typeof _createSignal\n\nlet effectTaskIsScheduled = false\n\n// TODO Option so the first run is deferred instead of immediate? This already\n// happens outside of a root.\nexport const createDeferredEffect = ((fn, value, options) => {\n\tlet initial = true\n\n\tcreateEffect(\n\t\t(prev: any) => {\n\t\t\tif (initial) {\n\t\t\t\tinitial = false\n\n\t\t\t\tcurrentEffect = fn\n\t\t\t\teffectDeps.get(fn)?.clear() // clear to track deps, or else it won't track new deps based on code branching\n\t\t\t\tfn(prev)\n\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\teffectQueue.add(fn) // add, or move to the end, of the queue. TODO This is probably redundant now, but I haven't tested yet.\n\n\t\t\t// If we're currently running the queue, return because fn will run\n\t\t\t// again at the end of the queue iteration due to our overriden\n\t\t\t// createSignal moving it to the end.\n\t\t\tif (runningEffects) return\n\n\t\t\tif (effectTaskIsScheduled) return\n\n\t\t\teffectTaskIsScheduled = true\n\n\t\t\tconst owner = getOwner()\n\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tif (owner) runWithOwner(owner, runEffects)\n\t\t\t\telse runEffects()\n\t\t\t})\n\t\t},\n\t\tvalue,\n\t\toptions,\n\t)\n\n\tgetOwner() &&\n\t\tonCleanup(() => {\n\t\t\teffectDeps.delete(fn)\n\t\t\teffectQueue.delete(fn)\n\t\t})\n}) as typeof createEffect\n\nfunction runEffects() {\n\trunningEffects = true\n\n\tfor (const fn of effectQueue) {\n\t\teffectQueue.delete(fn) // TODO This is probably redundant now, but I haven't tested yet.\n\t\tcreateDeferredEffect(fn)\n\t}\n\n\trunningEffects = false\n\teffectTaskIsScheduled = false\n}\n"],"mappings":"AAAA;;AAEA,SAAQA,YAAY,IAAIC,aAAa,EAAEC,YAAY,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,YAAY,QAAO,UAAU;AAIvG,MAAMC,WAAqC,GAAG,IAAIC,GAAG,CAAC,CAAC;AACvD,IAAIC,cAAc,GAAG,KAAK;;AAE1B;AACA,MAAMC,UAAU,GAAG,IAAIC,GAAG,CAA4C,CAAC;AACvE,IAAIC,aAAkC,GAAGA,CAAA,KAAM,CAAC,CAAC;;AAEjD;AACA;AACA;AACA;AACA,OAAO,IAAIX,YAAY,GAAIA,CAACY,KAAK,EAAEC,OAAO,KAAK;EAC9C,IAAI,CAACC,IAAI,EAAEC,IAAI,CAAC,GAAGd,aAAa,CAACW,KAAK,EAAEC,OAAO,CAAC;EAEhD,MAAMG,GAAG,GAAIA,CAAA,KAAM;IAClB,IAAI,CAACR,cAAc,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A,IAAIb,cAAc,EAAE;IAEpB,IAAIgB,qBAAqB,EAAE;IAE3BA,qBAAqB,GAAG,IAAI;IAE5B,MAAMK,KAAK,GAAGzB,QAAQ,CAAC,CAAC;IAExB0B,cAAc,CAAC,MAAM;MACpB,IAAID,KAAK,EAAExB,YAAY,CAACwB,KAAK,EAAEE,UAAU,CAAC,MACrCA,UAAU,CAAC,CAAC;IAClB,CAAC,CAAC;EACH,CAAC,EACDnB,KAAK,EACLC,OACD,CAAC;EAEDT,QAAQ,CAAC,CAAC,IACTD,SAAS,CAAC,MAAM;IACfM,UAAU,CAACc,MAAM,CAACF,EAAE,CAAC;IACrBf,WAAW,CAACiB,MAAM,CAACF,EAAE,CAAC;EACvB,CAAC,CAAC;AACJ,CAAyB;AAEzB,SAASU,UAAUA,CAAA,EAAG;EACrBvB,cAAc,GAAG,IAAI;EAErB,KAAK,MAAMa,EAAE,IAAIf,WAAW,EAAE;IAC7BA,WAAW,CAACiB,MAAM,CAACF,EAAE,CAAC,EAAC;IACvBI,oBAAoB,CAACJ,EAAE,CAAC;EACzB;EAEAb,cAAc,GAAG,KAAK;EACtBgB,qBAAqB,GAAG,KAAK;AAC9B"} \ No newline at end of file +{"version":3,"file":"createDeferredEffect.js","names":["createSignal","_createSignal","createEffect","onCleanup","getOwner","runWithOwner","effectQueue","Set","runningEffects","effectDeps","Map","currentEffect","value","options","_get","_set","get","deps","set","add","v","fn","dep","delete","effectTaskIsScheduled","createDeferredEffect","initial","prev","clear","owner","queueMicrotask","runEffects"],"sources":["../src/createDeferredEffect.ts"],"sourcesContent":["// TODO switch to non-dep-tracking non-queue-modifying deferred signals, because those do not break with regular effects.\n\nimport {createSignal as _createSignal, createEffect, onCleanup, getOwner, runWithOwner} from 'solid-js'\n\nimport type {EffectFunction} from 'solid-js/types/reactive/signal'\n\nconst effectQueue: Set> = new Set()\nlet runningEffects = false\n\n// map of effects to dependencies\nconst effectDeps = new Map, Set<(v: any) => any>>()\nlet currentEffect: EffectFunction = () => {}\n\n// Override createSignal in order to implement custom tracking of effect\n// dependencies, so that when signals change, we are aware which dependenct\n// effects need to be moved to the end of the effect queue while running\n// deferred effects in a microtask.\nexport let createSignal = ((value, options) => {\n\tlet [_get, _set] = _createSignal(value, options)\n\n\tconst get = (() => {\n\t\tif (!runningEffects) return _get()\n\n\t\tlet deps = effectDeps.get(currentEffect)\n\t\tif (!deps) effectDeps.set(currentEffect, (deps = new Set()))\n\t\tdeps.add(_set)\n\n\t\treturn _get()\n\t}) as typeof _get\n\n\tconst set = (v => {\n\t\tif (!runningEffects) return _set(v as any)\n\n\t\t// This is inefficient, for proof of concept, unable to use Solid\n\t\t// internals on the outside.\n\t\tfor (const [fn, deps] of effectDeps) {\n\t\t\tfor (const dep of deps) {\n\t\t\t\tif (dep === _set) {\n\t\t\t\t\t// move to the end\n\t\t\t\t\teffectQueue.delete(fn)\n\t\t\t\t\teffectQueue.add(fn)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn _set(v as any)\n\t}) as typeof _set\n\n\treturn [get, set]\n}) as typeof _createSignal\n\nlet effectTaskIsScheduled = false\n\n// TODO Option so the first run is deferred instead of immediate? This already\n// happens outside of a root.\nexport const createDeferredEffect = ((fn, value, options) => {\n\tlet initial = true\n\n\tcreateEffect(\n\t\t(prev: any) => {\n\t\t\tif (initial) {\n\t\t\t\tinitial = false\n\n\t\t\t\tcurrentEffect = fn\n\t\t\t\teffectDeps.get(fn)?.clear() // clear to track deps, or else it won't track new deps based on code branching\n\t\t\t\tfn(prev)\n\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\teffectQueue.add(fn) // add, or move to the end, of the queue. TODO This is probably redundant now, but I haven't tested yet.\n\n\t\t\t// If we're currently running the queue, return because fn will run\n\t\t\t// again at the end of the queue iteration due to our overriden\n\t\t\t// createSignal moving it to the end.\n\t\t\tif (runningEffects) return\n\n\t\t\tif (effectTaskIsScheduled) return\n\n\t\t\teffectTaskIsScheduled = true\n\n\t\t\tconst owner = getOwner()\n\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tif (owner) runWithOwner(owner, runEffects)\n\t\t\t\telse runEffects()\n\t\t\t})\n\t\t},\n\t\tvalue,\n\t\toptions,\n\t)\n\n\tgetOwner() &&\n\t\tonCleanup(() => {\n\t\t\teffectDeps.delete(fn)\n\t\t\teffectQueue.delete(fn)\n\t\t})\n}) as typeof createEffect\n\nfunction runEffects() {\n\trunningEffects = true\n\n\tfor (const fn of effectQueue) {\n\t\teffectQueue.delete(fn) // TODO This is probably redundant now, but I haven't tested yet.\n\t\tcreateDeferredEffect(fn)\n\t}\n\n\trunningEffects = false\n\teffectTaskIsScheduled = false\n}\n"],"mappings":"AAAA;;AAEA,SAAQA,YAAY,IAAIC,aAAa,EAAEC,YAAY,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,YAAY,QAAO,UAAU;AAIvG,MAAMC,WAAqC,GAAG,IAAIC,GAAG,CAAC,CAAC;AACvD,IAAIC,cAAc,GAAG,KAAK;;AAE1B;AACA,MAAMC,UAAU,GAAG,IAAIC,GAAG,CAA4C,CAAC;AACvE,IAAIC,aAAkC,GAAGA,CAAA,KAAM,CAAC,CAAC;;AAEjD;AACA;AACA;AACA;AACA,OAAO,IAAIX,YAAY,GAAIA,CAACY,KAAK,EAAEC,OAAO,KAAK;EAC9C,IAAI,CAACC,IAAI,EAAEC,IAAI,CAAC,GAAGd,aAAa,CAACW,KAAK,EAAEC,OAAO,CAAC;EAEhD,MAAMG,GAAG,GAAIA,CAAA,KAAM;IAClB,IAAI,CAACR,cAAc,EAAE,OAAOM,IAAI,CAAC,CAAC;IAElC,IAAIG,IAAI,GAAGR,UAAU,CAACO,GAAG,CAACL,aAAa,CAAC;IACxC,IAAI,CAACM,IAAI,EAAER,UAAU,CAACS,GAAG,CAACP,aAAa,EAAGM,IAAI,GAAG,IAAIV,GAAG,CAAC,CAAE,CAAC;IAC5DU,IAAI,CAACE,GAAG,CAACJ,IAAI,CAAC;IAEd,OAAOD,IAAI,CAA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EACDnB,KAAK,EACLC,OACD,CAAC;EAEDT,QAAQ,CAAC,CAAC,IACTD,SAAS,CAAC,MAAM;IACfM,UAAU,CAACc,MAAM,CAACF,EAAE,CAAC;IACrBf,WAAW,CAACiB,MAAM,CAACF,EAAE,CAAC;EACvB,CAAC,CAAC;AACJ,CAAyB;AAEzB,SAASU,UAAUA,CAAA,EAAG;EACrBvB,cAAc,GAAG,IAAI;EAErB,KAAK,MAAMa,EAAE,IAAIf,WAAW,EAAE;IAC7BA,WAAW,CAACiB,MAAM,CAACF,EAAE,CAAC,EAAC;IACvBI,oBAAoB,CAACJ,EAAE,CAAC;EACzB;EAEAb,cAAc,GAAG,KAAK;EACtBgB,qBAAqB,GAAG,KAAK;AAC9B","ignoreList":[]} \ No newline at end of file diff --git a/dist/createSignalFunction.js b/dist/createSignalFunction.js index 17ee32f..2ffc263 100644 --- a/dist/createSignalFunction.js +++ b/dist/createSignalFunction.js @@ -9,6 +9,7 @@ import { createSignal } from 'solid-js'; * signal just like a Setter does. */ // FIXME broke in 1.7.9 + /** * Create a Solid signal wrapped as a single function that gets the value when * no arguments are passed in, and sets the value when an argument is passed in. @@ -56,6 +57,7 @@ import { createSignal } from 'solid-js'; * * See also `createSignalObject` for another pattern. */ + export function createSignalFunction(value, options) { const [get, set] = createSignal(value, options); return function (value) { diff --git a/dist/createSignalFunction.js.map b/dist/createSignalFunction.js.map index 03bdb28..6c0c2e3 100644 --- a/dist/createSignalFunction.js.map +++ b/dist/createSignalFunction.js.map @@ -1 +1 @@ -{"version":3,"file":"createSignalFunction.js","names":["createSignal","createSignalFunction","value","options","get","set","arguments","length"],"sources":["../src/createSignalFunction.ts"],"sourcesContent":["// FIXME Solid 1.7.9+ requires a TypeScript update, so classy-solid code is made\n// un-typesafe until we update.\n\n// import {createSignal} from './createDeferredEffect.js'\nimport {createSignal} from 'solid-js'\nimport type {Setter} from 'solid-js'\nimport type {SignalOptions} from 'solid-js/types/reactive/signal'\n\n/**\n * A single function that with no args passed reads a signal, otherwise sets a\n * signal just like a Setter does.\n */\nexport type SignalFunction = {(): T} & Setter // FIXME broke in 1.7.9\n\n/**\n * Create a Solid signal wrapped as a single function that gets the value when\n * no arguments are passed in, and sets the value when an argument is passed in.\n * Good for alternative usage patterns, such as when read/write segregation is\n * not needed.\n *\n * ```js\n * let count = createSignalFunction(0) // create it with default value\n * count(1) // set the value\n * count(count() + 1) // increment\n * let currentValue = count() // read the current value\n * ```\n *\n * This is more convenient for class properties than using `createSignal`. With `createSignal`:\n *\n * ```js\n * class Foo {\n * count = createSignal(0)\n *\n * increment() {\n * // difficult to read\n * this.count[1](this.count[0]() + 1)\n *\n * // also:\n * this.count[1](c => c + 1)\n * }\n * }\n * ```\n *\n * With `createSignalFunction`:\n *\n * ```js\n * class Foo {\n * count = createSignalFunction(0)\n *\n * increment() {\n * // Easier to read\n * this.count(this.count() + 1)\n *\n * // also:\n * this.count(c => c + 1)\n * }\n * }\n * ```\n *\n * See also `createSignalObject` for another pattern.\n */\nexport function createSignalFunction(): SignalFunction\nexport function createSignalFunction(value: T, options?: SignalOptions): SignalFunction\nexport function createSignalFunction(value?: T, options?: SignalOptions): SignalFunction {\n\tconst [get, set] = createSignal(value as T, options)\n\n\treturn function (value) {\n\t\tif (arguments.length === 0) return get()\n\t\treturn set(\n\t\t\t// @ts-ignore FIXME its ok, value is defined (even if `undefined`)\n\t\t\tvalue,\n\t\t)\n\t} as SignalFunction\n}\n"],"mappings":"AAAA;AACA;;AAEA;AACA,SAAQA,YAAY,QAAO,UAAU;;AAIrC;AACA;AACA;AACA;AACoD;AAEpD;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;AAGA,OAAO,SAASC,oBAAoBA,CAAIC,KAAS,EAAEC,OAA0B,EAAqB;EACjG,MAAM,CAACC,GAAG,EAAEC,GAAG,CAAC,GAAGL,YAAY,CAAIE,KAAK,EAAOC,OAAO,CAAC;EAEvD,OAAO,UAAUD,KAAK,EAAE;IACvB,IAAII,SAAS,CAACC,MAAM,KAAK,CAAC,EAAE,OAAOH,GAAG,CAAC,CAAC;IACxC,OAAOC,GAAG;IACT;IACAH,KACD,CAAC;EACF,CAAC;AACF"} \ No newline at end of file +{"version":3,"file":"createSignalFunction.js","names":["createSignal","createSignalFunction","value","options","get","set","arguments","length"],"sources":["../src/createSignalFunction.ts"],"sourcesContent":["// FIXME Solid 1.7.9+ requires a TypeScript update, so classy-solid code is made\n// un-typesafe until we update.\n\n// import {createSignal} from './createDeferredEffect.js'\nimport {createSignal} from 'solid-js'\nimport type {Setter} from 'solid-js'\nimport type {SignalOptions} from 'solid-js/types/reactive/signal'\n\n/**\n * A single function that with no args passed reads a signal, otherwise sets a\n * signal just like a Setter does.\n */\nexport type SignalFunction = {(): T} & Setter // FIXME broke in 1.7.9\n\n/**\n * Create a Solid signal wrapped as a single function that gets the value when\n * no arguments are passed in, and sets the value when an argument is passed in.\n * Good for alternative usage patterns, such as when read/write segregation is\n * not needed.\n *\n * ```js\n * let count = createSignalFunction(0) // create it with default value\n * count(1) // set the value\n * count(count() + 1) // increment\n * let currentValue = count() // read the current value\n * ```\n *\n * This is more convenient for class properties than using `createSignal`. With `createSignal`:\n *\n * ```js\n * class Foo {\n * count = createSignal(0)\n *\n * increment() {\n * // difficult to read\n * this.count[1](this.count[0]() + 1)\n *\n * // also:\n * this.count[1](c => c + 1)\n * }\n * }\n * ```\n *\n * With `createSignalFunction`:\n *\n * ```js\n * class Foo {\n * count = createSignalFunction(0)\n *\n * increment() {\n * // Easier to read\n * this.count(this.count() + 1)\n *\n * // also:\n * this.count(c => c + 1)\n * }\n * }\n * ```\n *\n * See also `createSignalObject` for another pattern.\n */\nexport function createSignalFunction(): SignalFunction\nexport function createSignalFunction(value: T, options?: SignalOptions): SignalFunction\nexport function createSignalFunction(value?: T, options?: SignalOptions): SignalFunction {\n\tconst [get, set] = createSignal(value as T, options)\n\n\treturn function (value) {\n\t\tif (arguments.length === 0) return get()\n\t\treturn set(\n\t\t\t// @ts-ignore FIXME its ok, value is defined (even if `undefined`)\n\t\t\tvalue,\n\t\t)\n\t} as SignalFunction\n}\n"],"mappings":"AAAA;AACA;;AAEA;AACA,SAAQA,YAAY,QAAO,UAAU;;AAIrC;AACA;AACA;AACA;AACoD;;AAEpD;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;;AAGA,OAAO,SAASC,oBAAoBA,CAAIC,KAAS,EAAEC,OAA0B,EAAqB;EACjG,MAAM,CAACC,GAAG,EAAEC,GAAG,CAAC,GAAGL,YAAY,CAAIE,KAAK,EAAOC,OAAO,CAAC;EAEvD,OAAO,UAAUD,KAAK,EAAE;IACvB,IAAII,SAAS,CAACC,MAAM,KAAK,CAAC,EAAE,OAAOH,GAAG,CAAC,CAAC;IACxC,OAAOC,GAAG;IACT;IACAH,KACD,CAAC;EACF,CAAC;AACF","ignoreList":[]} \ No newline at end of file diff --git a/dist/createSignalObject.js.map b/dist/createSignalObject.js.map index 74bc83e..14ac6fa 100644 --- a/dist/createSignalObject.js.map +++ b/dist/createSignalObject.js.map @@ -1 +1 @@ -{"version":3,"file":"createSignalObject.js","names":["createSignal","createSignalObject","value","options","get","set"],"sources":["../src/createSignalObject.ts"],"sourcesContent":["import {createSignal} from './createDeferredEffect.js'\nimport type {SignalOptions} from 'solid-js/types/reactive/signal'\nimport type {Signal} from 'solid-js/types/reactive/signal'\n\n/**\n * A signal represented as an object with .get and .set methods.\n */\nexport interface SignalObject {\n\t/** Gets the signal value. */\n\tget: Signal[0]\n\t/** Sets the signal value. */\n\t// set: Signal[1] // FIXME broke in Solid 1.7.9\n\tset: (v: T | ((prev: T) => T)) => T\n}\n\n/**\n * Create a Solid signal wrapped in the form of an object with `.get` and `.set`\n * methods for alternative usage patterns.\n *\n * ```js\n * let count = createSignalObject(0) // count starts at 0\n * count.set(1) // set the value of count to 1\n * count.set(count.get() + 1) // add 1\n * let currentValue = count.get() // read the current value\n * ```\n *\n * This is more convenient for class properties than using `createSignal`. With `createSignal`:\n *\n * ```js\n * class Foo {\n * count = createSignal(0)\n *\n * increment() {\n * // difficult to read\n * this.count[1](this.count[0]() + 1)\n *\n * // also:\n * this.count[1](c => c + 1)\n * }\n * }\n * ```\n *\n * With `createSignalObject`:\n *\n * ```js\n * class Foo {\n * count = createSignalObject(0)\n *\n * increment() {\n * // Easier to read\n * this.count.set(this.count.get() + 1)\n *\n * // also:\n * this.count.set(c => c + 1)\n * }\n * }\n * ```\n *\n * See also `createSignalFunction` for another pattern.\n */\nexport function createSignalObject(): SignalObject\nexport function createSignalObject(value: T, options?: SignalOptions): SignalObject\nexport function createSignalObject(value?: T, options?: SignalOptions): SignalObject {\n\tconst [get, set] = createSignal(value as T, options)\n\treturn {get, set}\n}\n"],"mappings":"AAAA,SAAQA,YAAY,QAAO,2BAA2B;;AAItD;AACA;AACA;;AASA;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;;AAGA,OAAO,SAASC,kBAAkBA,CAAIC,KAAS,EAAEC,OAA0B,EAAmB;EAC7F,MAAM,CAACC,GAAG,EAAEC,GAAG,CAAC,GAAGL,YAAY,CAAIE,KAAK,EAAOC,OAAO,CAAC;EACvD,OAAO;IAACC,GAAG;IAAEC;EAAG,CAAC;AAClB"} \ No newline at end of file +{"version":3,"file":"createSignalObject.js","names":["createSignal","createSignalObject","value","options","get","set"],"sources":["../src/createSignalObject.ts"],"sourcesContent":["import {createSignal} from './createDeferredEffect.js'\nimport type {SignalOptions} from 'solid-js/types/reactive/signal'\nimport type {Signal} from 'solid-js/types/reactive/signal'\n\n/**\n * A signal represented as an object with .get and .set methods.\n */\nexport interface SignalObject {\n\t/** Gets the signal value. */\n\tget: Signal[0]\n\t/** Sets the signal value. */\n\t// set: Signal[1] // FIXME broke in Solid 1.7.9\n\tset: (v: T | ((prev: T) => T)) => T\n}\n\n/**\n * Create a Solid signal wrapped in the form of an object with `.get` and `.set`\n * methods for alternative usage patterns.\n *\n * ```js\n * let count = createSignalObject(0) // count starts at 0\n * count.set(1) // set the value of count to 1\n * count.set(count.get() + 1) // add 1\n * let currentValue = count.get() // read the current value\n * ```\n *\n * This is more convenient for class properties than using `createSignal`. With `createSignal`:\n *\n * ```js\n * class Foo {\n * count = createSignal(0)\n *\n * increment() {\n * // difficult to read\n * this.count[1](this.count[0]() + 1)\n *\n * // also:\n * this.count[1](c => c + 1)\n * }\n * }\n * ```\n *\n * With `createSignalObject`:\n *\n * ```js\n * class Foo {\n * count = createSignalObject(0)\n *\n * increment() {\n * // Easier to read\n * this.count.set(this.count.get() + 1)\n *\n * // also:\n * this.count.set(c => c + 1)\n * }\n * }\n * ```\n *\n * See also `createSignalFunction` for another pattern.\n */\nexport function createSignalObject(): SignalObject\nexport function createSignalObject(value: T, options?: SignalOptions): SignalObject\nexport function createSignalObject(value?: T, options?: SignalOptions): SignalObject {\n\tconst [get, set] = createSignal(value as T, options)\n\treturn {get, set}\n}\n"],"mappings":"AAAA,SAAQA,YAAY,QAAO,2BAA2B;;AAItD;AACA;AACA;;AASA;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;;AAGA,OAAO,SAASC,kBAAkBA,CAAIC,KAAS,EAAEC,OAA0B,EAAmB;EAC7F,MAAM,CAACC,GAAG,EAAEC,GAAG,CAAC,GAAGL,YAAY,CAAIE,KAAK,EAAOC,OAAO,CAAC;EACvD,OAAO;IAACC,GAAG;IAAEC;EAAG,CAAC;AAClB","ignoreList":[]} \ No newline at end of file diff --git a/dist/createStoppableEffect.js.map b/dist/createStoppableEffect.js.map index cbde95c..b0ef244 100644 --- a/dist/createStoppableEffect.js.map +++ b/dist/createStoppableEffect.js.map @@ -1 +1 @@ -{"version":3,"file":"createStoppableEffect.js","names":["createEffect","createSignal","createStoppableEffect","fn","running","setRunning","stop","resume"],"sources":["../src/createStoppableEffect.ts"],"sourcesContent":["import {createEffect, createSignal} from 'solid-js'\n\nexport type Effect = {stop: () => void; resume: () => void}\n\n/**\n * NOTE: Experimental\n *\n * Create a stoppable effect.\n *\n * ```js\n * const effect = createStoppableEffect(() => {...})\n *\n * // ...later, stop the effect from running again.\n * effect.stop()\n * ```\n *\n * Note, this is experimental because when inside of a parent reactive context\n * that is long-lived (f.e. for life time of the app), each new effect created\n * with this and subsequently stopped will stick around and not be GC'd until\n * the parent context is cleaned up (which could be never).\n *\n * Stopped effects will currently only be GC'd freely when they are created\n * outside of a reactive context.\n */\nexport function createStoppableEffect(fn: () => void): Effect {\n\tconst [running, setRunning] = createSignal(true)\n\tcreateEffect(() => running() && fn())\n\treturn {stop: () => setRunning(false), resume: () => setRunning(true)}\n}\n"],"mappings":"AAAA,SAAQA,YAAY,EAAEC,YAAY,QAAO,UAAU;AAInD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CAACC,EAAc,EAAU;EAC7D,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGJ,YAAY,CAAC,IAAI,CAAC;EAChDD,YAAY,CAAC,MAAMI,OAAO,CAAC,CAAC,IAAID,EAAE,CAAC,CAAC,CAAC;EACrC,OAAO;IAACG,IAAI,EAAEA,CAAA,KAAMD,UAAU,CAAC,KAAK,CAAC;IAAEE,MAAM,EAAEA,CAAA,KAAMF,UAAU,CAAC,IAAI;EAAC,CAAC;AACvE"} \ No newline at end of file +{"version":3,"file":"createStoppableEffect.js","names":["createEffect","createSignal","createStoppableEffect","fn","running","setRunning","stop","resume"],"sources":["../src/createStoppableEffect.ts"],"sourcesContent":["import {createEffect, createSignal} from 'solid-js'\n\nexport type Effect = {stop: () => void; resume: () => void}\n\n/**\n * NOTE: Experimental\n *\n * Create a stoppable effect.\n *\n * ```js\n * const effect = createStoppableEffect(() => {...})\n *\n * // ...later, stop the effect from running again.\n * effect.stop()\n * ```\n *\n * Note, this is experimental because when inside of a parent reactive context\n * that is long-lived (f.e. for life time of the app), each new effect created\n * with this and subsequently stopped will stick around and not be GC'd until\n * the parent context is cleaned up (which could be never).\n *\n * Stopped effects will currently only be GC'd freely when they are created\n * outside of a reactive context.\n */\nexport function createStoppableEffect(fn: () => void): Effect {\n\tconst [running, setRunning] = createSignal(true)\n\tcreateEffect(() => running() && fn())\n\treturn {stop: () => setRunning(false), resume: () => setRunning(true)}\n}\n"],"mappings":"AAAA,SAAQA,YAAY,EAAEC,YAAY,QAAO,UAAU;AAInD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CAACC,EAAc,EAAU;EAC7D,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGJ,YAAY,CAAC,IAAI,CAAC;EAChDD,YAAY,CAAC,MAAMI,OAAO,CAAC,CAAC,IAAID,EAAE,CAAC,CAAC,CAAC;EACrC,OAAO;IAACG,IAAI,EAAEA,CAAA,KAAMD,UAAU,CAAC,KAAK,CAAC;IAAEE,MAAM,EAAEA,CAAA,KAAMF,UAAU,CAAC,IAAI;EAAC,CAAC;AACvE","ignoreList":[]} \ No newline at end of file diff --git a/dist/createSyncedSignals.js.map b/dist/createSyncedSignals.js.map index 7b56b6b..e64f0c9 100644 --- a/dist/createSyncedSignals.js.map +++ b/dist/createSyncedSignals.js.map @@ -1 +1 @@ -{"version":3,"file":"createSyncedSignals.js","names":["createSignal","syncSignals","createSyncedSignals","initialValue"],"sources":["../src/createSyncedSignals.ts"],"sourcesContent":["import {createSignal} from 'solid-js'\nimport {syncSignals} from './syncSignals.js'\n\n/**\n * Useful as a shorthand for:\n *\n * ```js\n * const [[foo, setFoo], [bar, setBar]] = syncSignals(...createSignal(0), ...createSignal(0))\n * ```\n *\n * Example:\n *\n * ```js\n * const [[foo, setFoo], [bar, setBar]] = createSyncedSignals(0)\n * ```\n */\nexport function createSyncedSignals(initialValue: T) {\n\treturn syncSignals(\n\t\t...(createSignal(initialValue) as [() => T, (v: T) => void]),\n\t\t...(createSignal(initialValue) as [() => T, (v: T) => void]),\n\t)\n}\n"],"mappings":"AAAA,SAAQA,YAAY,QAAO,UAAU;AACrC,SAAQC,WAAW,QAAO,kBAAkB;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAAIC,YAAe,EAAE;EACvD,OAAOF,WAAW,CACjB,GAAID,YAAY,CAACG,YAAY,CAA+B,EAC5D,GAAIH,YAAY,CAACG,YAAY,CAC9B,CAAC;AACF"} \ No newline at end of file +{"version":3,"file":"createSyncedSignals.js","names":["createSignal","syncSignals","createSyncedSignals","initialValue"],"sources":["../src/createSyncedSignals.ts"],"sourcesContent":["import {createSignal} from 'solid-js'\nimport {syncSignals} from './syncSignals.js'\n\n/**\n * Useful as a shorthand for:\n *\n * ```js\n * const [[foo, setFoo], [bar, setBar]] = syncSignals(...createSignal(0), ...createSignal(0))\n * ```\n *\n * Example:\n *\n * ```js\n * const [[foo, setFoo], [bar, setBar]] = createSyncedSignals(0)\n * ```\n */\nexport function createSyncedSignals(initialValue: T) {\n\treturn syncSignals(\n\t\t...(createSignal(initialValue) as [() => T, (v: T) => void]),\n\t\t...(createSignal(initialValue) as [() => T, (v: T) => void]),\n\t)\n}\n"],"mappings":"AAAA,SAAQA,YAAY,QAAO,UAAU;AACrC,SAAQC,WAAW,QAAO,kBAAkB;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAAIC,YAAe,EAAE;EACvD,OAAOF,WAAW,CACjB,GAAID,YAAY,CAACG,YAAY,CAA+B,EAC5D,GAAIH,YAAY,CAACG,YAAY,CAC9B,CAAC;AACF","ignoreList":[]} \ No newline at end of file diff --git a/dist/decorators/index.js.map b/dist/decorators/index.js.map index b010ea4..7119363 100644 --- a/dist/decorators/index.js.map +++ b/dist/decorators/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","names":[],"sources":["../../src/decorators/index.ts"],"sourcesContent":["// export * from './memo.js'\nexport * from './reactive.js'\nexport * from './signal.js'\n"],"mappings":"AAAA;AACA,cAAc,eAAe;AAC7B,cAAc,aAAa"} \ No newline at end of file +{"version":3,"file":"index.js","names":[],"sources":["../../src/decorators/index.ts"],"sourcesContent":["// export * from './memo.js'\nexport * from './reactive.js'\nexport * from './signal.js'\n"],"mappings":"AAAA;AACA,cAAc,eAAe;AAC7B,cAAc,aAAa","ignoreList":[]} \ No newline at end of file diff --git a/dist/decorators/memo.js.map b/dist/decorators/memo.js.map index 38b6a6f..0730bc0 100644 --- a/dist/decorators/memo.js.map +++ b/dist/decorators/memo.js.map @@ -1 +1 @@ -{"version":3,"file":"memo.js","names":[],"sources":["../../src/decorators/memo.ts"],"sourcesContent":["// TODO\n\nexport {}\n"],"mappings":"AAAA;;AAEA"} \ No newline at end of file +{"version":3,"file":"memo.js","names":[],"sources":["../../src/decorators/memo.ts"],"sourcesContent":["// TODO\n\nexport {}\n"],"mappings":"AAAA;;AAEA","ignoreList":[]} \ No newline at end of file diff --git a/dist/decorators/reactive.js.map b/dist/decorators/reactive.js.map index 812856d..e8d5b01 100644 --- a/dist/decorators/reactive.js.map +++ b/dist/decorators/reactive.js.map @@ -1 +1 @@ -{"version":3,"file":"reactive.js","names":["getListener","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","prop","initialValue","call","Error","toString","override"],"sources":["../../src/decorators/reactive.ts"],"sourcesContent":["import type {AnyConstructor} from 'lowclass/dist/Constructor.js'\nimport {getListener, 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\tfor (const [prop, {initialValue}] of signalProps) {\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 Error(\n\t\t\t\t\t\t`Property \"${prop.toString()}\" 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 \"${prop.toString()}\" property decorated with \\`@signal\\`?`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\t// For now at least, we always override like class fields with\n\t\t\t\t// [[Define]] semantics. Perhaps when @signal is used on a\n\t\t\t\t// getter/setter, we should not override in that case, but patch\n\t\t\t\t// the prototype getter/setter (that'll be a bit of work to\n\t\t\t\t// implement though).\n\t\t\t\tconst override = true\n\n\t\t\t\tcreateSignalAccessor(instance, prop as Exclude, initialValue, override)\n\t\t\t}\n\n\t\t\treturn instance\n\t\t}\n\t}\n\n\treturn ReactiveDecorator\n}\n"],"mappings":"AACA,SAAQA,WAAW,EAAEC,OAAO,QAAO,UAAU;AAC7C,SAAQC,MAAM,EAAEC,mBAAmB,EAAEC,qBAAqB,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AACoB,IAAI,CAACZ,KAAK,CAACN,SAAS,EAAEgB,IAAI,CAAC,CAAC,EAAE;UACzF,MAAM,IAAIG,KAAK,CACb,aAAYH,IAAI,CAACI,QAAQ,CAAC,CAAE,uJAAsJJ,IAAI,CAACI,QAAQ,CAAC,CAAE,wCACpM,CAAC;QACF;;QAEA;QACA;QACA;QACA;QACA;QACA,MAAMC,QAAQ,GAAG,IAAI;QAErBxB,oBAAoB,CAACc,QAAQ,EAAEK,IAAI,EAA8CC,YAAY,EAAEI,QAAQ,CAAC;MACzG;MAEA,OAAOV,QAAQ;IAChB;EACD;EAEA,OAAOH,iBAAiB;AACzB"} \ No newline at end of file +{"version":3,"file":"reactive.js","names":["getListener","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","prop","initialValue","call","Error","toString","override"],"sources":["../../src/decorators/reactive.ts"],"sourcesContent":["import type {AnyConstructor} from 'lowclass/dist/Constructor.js'\nimport {getListener, 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\tfor (const [prop, {initialValue}] of signalProps) {\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 Error(\n\t\t\t\t\t\t`Property \"${prop.toString()}\" 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 \"${prop.toString()}\" property decorated with \\`@signal\\`?`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\t// For now at least, we always override like class fields with\n\t\t\t\t// [[Define]] semantics. Perhaps when @signal is used on a\n\t\t\t\t// getter/setter, we should not override in that case, but patch\n\t\t\t\t// the prototype getter/setter (that'll be a bit of work to\n\t\t\t\t// implement though).\n\t\t\t\tconst override = true\n\n\t\t\t\tcreateSignalAccessor(instance, prop as Exclude, initialValue, override)\n\t\t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C,KAAK,MAAM,CAACK,IAAI,EAAE;QAACC;MAAY,CAAC,CAAC,IAAIV,WAAW,EAAE;QACjD;QACA,IAAI,EAAET,cAAc,CAACoB,IAAI,CAACP,QAAQ,EAAEK,IAAI,CAAC,IAAIlB,cAAc,CAACoB,IAAI,CAACZ,KAAK,CAACN,SAAS,EAAEgB,IAAI,CAAC,CAAC,EAAE;UACzF,MAAM,IAAIG,KAAK,CACd,aAAaH,IAAI,CAACI,QAAQ,CAAC,CAAC,uJAAuJJ,IAAI,CAACI,QAAQ,CAAC,CAAC,wCACnM,CAAC;QACF;;QAEA;QACA;QACA;QACA;QACA;QACA,MAAMC,QAAQ,GAAG,IAAI;QAErBxB,oBAAoB,CAACc,QAAQ,EAAEK,IAAI,EAA8CC,YAAY,EAAEI,QAAQ,CAAC;MACzG;MAEA,OAAOV,QAAQ;IAChB;EACD;EAEA,OAAOH,iBAAiB;AACzB","ignoreList":[]} \ No newline at end of file diff --git a/dist/decorators/signal.js.map b/dist/decorators/signal.js.map index 476ac51..added4a 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})\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})\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,0C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;;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;MACC,gDAA+CqB,KAAK,CAACC,IAAI,CAACX,KAAK,CAACY,IAAI,CAAC,CAAC,CAAC,CAACC,IAAI,CAC5E,IACD,CAAE,gHACH,CAAC;IACF;EACD,CAAC,CAAC;AACH"} \ No newline at end of file +{"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})\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})\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;EAClFJ,gBAAgB,GAAG,IAAIC,GAAG,CAAoB,CAAC;AAChD;AAEA,SAASQ,iBAAiBA,CAACC,OAAyB,EAA0C;EAC7F,OAAO,CAAC,EAAE,SAAS,IAAIA,OAAO,CAAC;AAChC;;AAEA;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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AgDqB,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 diff --git a/dist/decorators/types.js.map b/dist/decorators/types.js.map index fe0c4d2..cceaea1 100644 --- a/dist/decorators/types.js.map +++ b/dist/decorators/types.js.map @@ -1 +1 @@ -{"version":3,"file":"types.js","names":[],"sources":["../../src/decorators/types.ts"],"sourcesContent":["import type {Constructor} from 'lowclass/dist/Constructor.js'\n\nexport type DecoratedValue = Constructor | Function | ClassAccessorDecoratorTarget | undefined\n\nexport type PropKey = string | symbol\n\n// If we add options for `@signal` later (f.e. `@signal({equals: false})`),\n// those options can go in here too.\nexport interface PropSpec {\n\tinitialValue: unknown\n}\n"],"mappings":""} \ No newline at end of file +{"version":3,"file":"types.js","names":[],"sources":["../../src/decorators/types.ts"],"sourcesContent":["import type {Constructor} from 'lowclass/dist/Constructor.js'\n\nexport type DecoratedValue = Constructor | Function | ClassAccessorDecoratorTarget | undefined\n\nexport type PropKey = string | symbol\n\n// If we add options for `@signal` later (f.e. `@signal({equals: false})`),\n// those options can go in here too.\nexport interface PropSpec {\n\tinitialValue: unknown\n}\n"],"mappings":"","ignoreList":[]} \ No newline at end of file diff --git a/dist/example.js b/dist/example.js index bfa84c8..f63f7bf 100644 --- a/dist/example.js +++ b/dist/example.js @@ -1,18 +1,8 @@ var _initClass, _init_yoo, _initClass2, _init_foo, _initProto, _initClass3, _init_bar, _initProto2, _Foo2; -function createAddInitializerMethod(e, t) { return function (r) { assertNotFinished(t, "addInitializer"), assertCallable(r, "An initializer"), e.push(r); }; } -function assertInstanceIfPrivate(e, t) { if (!e(t)) throw new TypeError("Attempted to access private element on non-instance"); } -function memberDec(e, t, r, a, n, i, s, o, c, l, u) { var f; switch (i) { case 1: f = "accessor"; break; case 2: f = "method"; break; case 3: f = "getter"; break; case 4: f = "setter"; break; default: f = "field"; } var d, p, h = { kind: f, name: o ? "#" + r : r, static: s, private: o, metadata: u }, v = { v: !1 }; if (0 !== i && (h.addInitializer = createAddInitializerMethod(n, v)), o || 0 !== i && 2 !== i) { if (2 === i) d = function (e) { return assertInstanceIfPrivate(l, e), a.value; };else { var y = 0 === i || 1 === i; (y || 3 === i) && (d = o ? function (e) { return assertInstanceIfPrivate(l, e), a.get.call(e); } : function (e) { return a.get.call(e); }), (y || 4 === i) && (p = o ? function (e, t) { assertInstanceIfPrivate(l, e), a.set.call(e, t); } : function (e, t) { a.set.call(e, t); }); } } else d = function (e) { return e[r]; }, 0 === i && (p = function (e, t) { e[r] = t; }); var m = o ? l.bind() : function (e) { return r in e; }; h.access = d && p ? { get: d, set: p, has: m } : d ? { get: d, has: m } : { set: p, has: m }; try { return e.call(t, c, h); } finally { v.v = !0; } } -function assertNotFinished(e, t) { if (e.v) throw new Error("attempted to call " + t + " after decoration was finished"); } -function assertCallable(e, t) { if ("function" != typeof e) throw new TypeError(t + " must be a function"); } -function assertValidReturnValue(e, t) { var r = typeof t; if (1 === e) { if ("object" !== r || null === t) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0"); void 0 !== t.get && assertCallable(t.get, "accessor.get"), void 0 !== t.set && assertCallable(t.set, "accessor.set"), void 0 !== t.init && assertCallable(t.init, "accessor.init"); } else if ("function" !== r) { var a; throw a = 0 === e ? "field" : 5 === e ? "class" : "method", new TypeError(a + " decorators must return a function or void 0"); } } -function curryThis1(e) { return function () { return e(this); }; } -function curryThis2(e) { return function (t) { e(this, t); }; } -function applyMemberDec(e, t, r, a, n, i, s, o, c, l, u) { var f, d, p, h, v, y, m = r[0]; a || Array.isArray(m) || (m = [m]), o ? f = 0 === i || 1 === i ? { get: curryThis1(r[3]), set: curryThis2(r[4]) } : 3 === i ? { get: r[3] } : 4 === i ? { set: r[3] } : { value: r[3] } : 0 !== i && (f = Object.getOwnPropertyDescriptor(t, n)), 1 === i ? p = { get: f.get, set: f.set } : 2 === i ? p = f.value : 3 === i ? p = f.get : 4 === i && (p = f.set); for (var g = a ? 2 : 1, b = m.length - 1; b >= 0; b -= g) { var I; if (void 0 !== (h = memberDec(m[b], a ? m[b - 1] : void 0, n, f, c, i, s, o, p, l, u))) assertValidReturnValue(i, h), 0 === i ? I = h : 1 === i ? (I = h.init, v = h.get || p.get, y = h.set || p.set, p = { get: v, set: y }) : p = h, void 0 !== I && (void 0 === d ? d = I : "function" == typeof d ? d = [d, I] : d.push(I)); } if (0 === i || 1 === i) { if (void 0 === d) d = function (e, t) { return t; };else if ("function" != typeof d) { var w = d; d = function (e, t) { for (var r = t, a = w.length - 1; a >= 0; a--) r = w[a].call(e, r); return r; }; } else { var M = d; d = function (e, t) { return M.call(e, t); }; } e.push(d); } 0 !== i && (1 === i ? (f.get = p.get, f.set = p.set) : 2 === i ? f.value = p : 3 === i ? f.get = p : 4 === i && (f.set = p), o ? 1 === i ? (e.push(function (e, t) { return p.get.call(e, t); }), e.push(function (e, t) { return p.set.call(e, t); })) : 2 === i ? e.push(p) : e.push(function (e, t) { return p.call(e, t); }) : Object.defineProperty(t, n, f)); } -function applyMemberDecs(e, t, r, a) { for (var n, i, s, o = [], c = new Map(), l = new Map(), u = 0; u < t.length; u++) { var f = t[u]; if (Array.isArray(f)) { var d, p, h = f[1], v = f[2], y = f.length > 3, m = 16 & h, g = !!(8 & h), b = r; if (h &= 7, g ? (d = e, 0 !== h && (p = i = i || []), y && !s && (s = function (t) { return _checkInRHS(t) === e; }), b = s) : (d = e.prototype, 0 !== h && (p = n = n || [])), 0 !== h && !y) { var I = g ? l : c, w = I.get(v) || 0; if (!0 === w || 3 === w && 4 !== h || 4 === w && 3 !== h) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + v); I.set(v, !(!w && h > 2) || h); } applyMemberDec(o, d, f, m, v, h, g, y, p, b, a); } } return pushInitializers(o, n), pushInitializers(o, i), o; } -function pushInitializers(e, t) { t && e.push(function (e) { for (var r = 0; r < t.length; r++) t[r].call(e); return e; }); } -function applyClassDecs(e, t, r, a) { if (t.length) { for (var n = [], i = e, s = e.name, o = r ? 2 : 1, c = t.length - 1; c >= 0; c -= o) { var l = { v: !1 }; try { var u = t[c].call(r ? t[c - 1] : void 0, i, { kind: "class", name: s, addInitializer: createAddInitializerMethod(n, l), metadata: a }); } finally { l.v = !0; } void 0 !== u && (assertValidReturnValue(5, u), i = u); } return [defineMetadata(i, a), function () { for (var e = 0; e < n.length; e++) n[e].call(i); }]; } } -function defineMetadata(e, t) { return Object.defineProperty(e, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: t }); } -function _applyDecs(e, t, r, a, n, i) { if (arguments.length >= 6) var s = i[Symbol.metadata || Symbol.for("Symbol.metadata")]; var o = Object.create(void 0 === s ? null : s), c = applyMemberDecs(e, t, n, o); return r.length || defineMetadata(e, o), { e: c, get c() { return applyClassDecs(e, r, a, o); } }; } +function _applyDecs(e, t, r, n, o, a) { function i(e, t, r) { return function (n, o) { return r && r(n), e[t].call(n, o); }; } function c(e, t) { for (var r = 0; r < e.length; r++) e[r].call(t); return t; } function s(e, t, r, n) { if ("function" != typeof e && (n || void 0 !== e)) throw new TypeError(t + " must " + (r || "be") + " a function" + (n ? "" : " or undefined")); return e; } function applyDec(e, t, r, n, o, a, c, u, l, f, p, d, h) { function m(e) { if (!h(e)) throw new TypeError("Attempted to access private element on non-instance"); } var y, v = t[0], g = t[3], b = !u; if (!b) { r || Array.isArray(v) || (v = [v]); var w = {}, S = [], A = 3 === o ? "get" : 4 === o || d ? "set" : "value"; f ? (p || d ? w = { get: _setFunctionName(function () { return g(this); }, n, "get"), set: function (e) { t[4](this, e); } } : w[A] = g, p || _setFunctionName(w[A], n, 2 === o ? "" : A)) : p || (w = Object.getOwnPropertyDescriptor(e, n)); } for (var P = e, j = v.length - 1; j >= 0; j -= r ? 2 : 1) { var D = v[j], E = r ? v[j - 1] : void 0, I = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: n, metadata: a, addInitializer: function (e, t) { if (e.v) throw Error("attempted to call addInitializer after decoration was finished"); s(t, "An initializer", "be", !0), c.push(t); }.bind(null, I) }; try { if (b) (y = s(D.call(E, P, O), "class decorators", "return")) && (P = y);else { var k, F; O.static = l, O.private = f, f ? 2 === o ? k = function (e) { return m(e), w.value; } : (o < 4 && (k = i(w, "get", m)), 3 !== o && (F = i(w, "set", m))) : (k = function (e) { return e[n]; }, (o < 2 || 4 === o) && (F = function (e, t) { e[n] = t; })); var N = O.access = { has: f ? h.bind() : function (e) { return n in e; } }; if (k && (N.get = k), F && (N.set = F), P = D.call(E, d ? { get: w.get, set: w.set } : w[A], O), d) { if ("object" == typeof P && P) (y = s(P.get, "accessor.get")) && (w.get = y), (y = s(P.set, "accessor.set")) && (w.set = y), (y = s(P.init, "accessor.init")) && S.push(y);else if (void 0 !== P) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0"); } else s(P, (p ? "field" : "method") + " decorators", "return") && (p ? S.push(P) : w[A] = P); } } finally { I.v = !0; } } return (p || d) && u.push(function (e, t) { for (var r = S.length - 1; r >= 0; r--) t = S[r].call(e, t); return t; }), p || b || (f ? d ? u.push(i(w, "get"), i(w, "set")) : u.push(2 === o ? w[A] : i.call.bind(w[A])) : Object.defineProperty(e, n, w)), P; } function u(e, t) { return Object.defineProperty(e, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: t }); } if (arguments.length >= 6) var l = a[Symbol.metadata || Symbol.for("Symbol.metadata")]; var f = Object.create(null == l ? null : l), p = function (e, t, r, n) { var o, a, i = [], s = function (t) { return _checkInRHS(t) === e; }, u = new Map(); function l(e) { e && i.push(c.bind(null, e)); } for (var f = 0; f < t.length; f++) { var p = t[f]; if (Array.isArray(p)) { var d = p[1], h = p[2], m = p.length > 3, y = 16 & d, v = !!(8 & d), g = 0 == (d &= 7), b = h + "/" + v; if (!g && !m) { var w = u.get(b); if (!0 === w || 3 === w && 4 !== d || 4 === w && 3 !== d) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h); u.set(b, !(d > 2) || d); } applyDec(v ? e : e.prototype, p, y, m ? "#" + h : _toPropertyKey(h), d, n, v ? a = a || [] : o = o || [], i, v, m, g, 1 === d, v && m ? s : r); } } return l(o), l(a), i; }(e, t, o, f); return r.length || u(e, f), { e: p, get c() { var t = []; return r.length && [u(applyDec(e, [r], n, e.name, 5, f, t), f), c.bind(null, t, e)]; } }; } +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } +function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } +function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; } function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; } import { signal, reactive } from './index.js'; import { createEffect } from 'solid-js'; diff --git a/dist/example.js.map b/dist/example.js.map index d8cc57d..538709b 100644 --- a/dist/example.js.map +++ b/dist/example.js.map @@ -1 +1 @@ -{"version":3,"file":"example.js","names":["signal","reactive","createEffect","_Other","Other","e","_init_yoo","c","_initClass","_applyDecs","yoo","_Foo","Foo","_init_foo","_initProto","_initClass2","foo","lorem","v","_Bar","Bar","_Foo2","_init_bar","_initProto2","_initClass3","bar","baz","constructor","console","log","b","setInterval"],"sources":["../src/example.ts"],"sourcesContent":["import {signal, reactive} from './index.js'\nimport {createEffect} from 'solid-js'\n\n@reactive\nclass Other {\n\t@signal yoo = 'hoo'\n}\n\nnew Other()\n\n@reactive\nclass Foo {\n\t@signal foo = 123\n\n\t@signal get lorem() {\n\t\treturn 123\n\t}\n\tset lorem(v) {\n\t\tv\n\t}\n}\n\n@reactive\nclass Bar extends Foo {\n\t@signal bar = 456\n\n\t#baz = 789\n\n\t@signal\n\tget baz() {\n\t\treturn this.#baz\n\t}\n\tset baz(v) {\n\t\tthis.#baz = v\n\t}\n\n\tconstructor() {\n\t\tsuper()\n\n\t\tconsole.log('Bar')\n\t}\n}\n\nexport {Foo}\n\nconst b = new Bar()\n\ncreateEffect(() => {\n\tconsole.log('b.foo:', b.foo)\n})\n\ncreateEffect(() => {\n\tconsole.log('b.lorem:', b.lorem)\n})\n\ncreateEffect(() => {\n\tconsole.log('b.bar:', b.bar)\n})\n\ncreateEffect(() => {\n\tconsole.log('b.baz:', b.baz)\n})\n\nsetInterval(() => {\n\tconsole.log('---')\n\tb.foo++\n\tb.bar++\n\tb.baz++\n\tb.lorem++\n}, 1000)\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAQA,MAAM,EAAEC,QAAQ,QAAO,YAAY;AAC3C,SAAQC,YAAY,QAAO,UAAU;AAAA,IAAAC,MAAA;AAErC,MAAAC,KAAA,CACY;EAAA;IAAA;MAAAC,CAAA,GAAAC,SAAA;MAAAC,CAAA,GAAAJ,MAAA,EAAAK,UAAA;IAAA,IAAAC,UAAA,SACVT,MAAM,eAFPC,QAAQ;EAAA;EAEAS,GAAG,GAAAJ,SAAA,OAAG,KAAK;EAAA;IAAAE,UAAA;EAAA;AACpB;AAEA,IAAIJ,MAAK,CAAC,CAAC;AAAA,IAAAO,IAAA;AAEX,MAAAC,GAAA,CACU;EAAA;IAAA;MAAAP,CAAA,GAAAQ,SAAA,EAAAC,UAAA;MAAAP,CAAA,GAAAI,IAAA,EAAAI,WAAA;IAAA,IAAAN,UAAA,SAGRT,MAAM,gBAFNA,MAAM,eAFPC,QAAQ;EAAA;EAEAe,GAAG,IAAAF,UAAA,QAAAD,SAAA,OAAG,GAAG;EAE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AAG,CAAC,QAAQ,EAAEC,CAAC,CAACJ,GAAG,CAAC;AAC7B,CAAC,CAAC;AAEFK,WAAW,CAAC,MAAM;EACjBH,OAAO,CAACC,GAAG,CAAC,KAAK,CAAC;EAClBC,CAAC,CAACd,GAAG,EAAE;EACPc,CAAC,CAACL,GAAG,EAAE;EACPK,CAAC,CAACJ,GAAG,EAAE;EACPI,CAAC,CAACb,KAAK,EAAE;AACV,CAAC,EAAE,IAAI,CAAC"} \ No newline at end of file +{"version":3,"file":"example.js","names":["signal","reactive","createEffect","_Other","Other","e","_init_yoo","c","_initClass","_applyDecs","yoo","_Foo","Foo","_init_foo","_initProto","_initClass2","foo","lorem","v","_Bar","Bar","_Foo2","_init_bar","_initProto2","_initClass3","bar","baz","constructor","console","log","b","setInterval"],"sources":["../src/example.ts"],"sourcesContent":["import {signal, reactive} from './index.js'\nimport {createEffect} from 'solid-js'\n\n@reactive\nclass Other {\n\t@signal yoo = 'hoo'\n}\n\nnew Other()\n\n@reactive\nclass Foo {\n\t@signal foo = 123\n\n\t@signal get lorem() {\n\t\treturn 123\n\t}\n\tset lorem(v) {\n\t\tv\n\t}\n}\n\n@reactive\nclass Bar extends Foo {\n\t@signal bar = 456\n\n\t#baz = 789\n\n\t@signal\n\tget baz() {\n\t\treturn this.#baz\n\t}\n\tset baz(v) {\n\t\tthis.#baz = v\n\t}\n\n\tconstructor() {\n\t\tsuper()\n\n\t\tconsole.log('Bar')\n\t}\n}\n\nexport {Foo}\n\nconst b = new Bar()\n\ncreateEffect(() => {\n\tconsole.log('b.foo:', b.foo)\n})\n\ncreateEffect(() => {\n\tconsole.log('b.lorem:', b.lorem)\n})\n\ncreateEffect(() => {\n\tconsole.log('b.bar:', b.bar)\n})\n\ncreateEffect(() => {\n\tconsole.log('b.baz:', b.baz)\n})\n\nsetInterval(() => {\n\tconsole.log('---')\n\tb.foo++\n\tb.bar++\n\tb.baz++\n\tb.lorem++\n}, 1000)\n"],"mappings":";;;;;;AAAA,SAAQA,M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AAWA,CAAA,EAAG;IACb,KAAK,CAAC,CAAC;IAEPC,OAAO,CAACC,GAAG,CAAC,KAAK,CAAC;EACnB;EAAC;IAAAL,WAAA;EAAA;AACF;AAEA,SAAQZ,IAAG,IAAHA,GAAG;AAEX,MAAMkB,CAAC,GAAG,IAAIV,IAAG,CAAC,CAAC;AAEnBlB,YAAY,CAAC,MAAM;EAClB0B,OAAO,CAACC,GAAG,CAAC,QAAQ,EAAEC,CAAC,CAACd,GAAG,CAAC;AAC7B,CAAC,CAAC;AAEFd,YAAY,CAAC,MAAM;EAClB0B,OAAO,CAACC,GAAG,CAAC,UAAU,EAAEC,CAAC,CAACb,KAAK,CAAC;AACjC,CAAC,CAAC;AAEFf,YAAY,CAAC,MAAM;EAClB0B,OAAO,CAACC,GAAG,CAAC,QAAQ,EAAEC,CAAC,CAACL,GAAG,CAAC;AAC7B,CAAC,CAAC;AAEFvB,YAAY,CAAC,MAAM;EAClB0B,OAAO,CAACC,GAAG,CAAC,QAAQ,EAAEC,CAAC,CAACJ,GAAG,CAAC;AAC7B,CAAC,CAAC;AAEFK,WAAW,CAAC,MAAM;EACjBH,OAAO,CAACC,GAAG,CAAC,KAAK,CAAC;EAClBC,CAAC,CAACd,GAAG,EAAE;EACPc,CAAC,CAACL,GAAG,EAAE;EACPK,CAAC,CAACJ,GAAG,EAAE;EACPI,CAAC,CAACb,KAAK,EAAE;AACV,CAAC,EAAE,IAAI,CAAC","ignoreList":[]} \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map index 2972178..59a87fd 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","names":["version"],"sources":["../src/index.ts"],"sourcesContent":["export * from './Effectful.js'\nexport * from './component.js'\nexport * from './createDeferredEffect.js'\nexport * from './createSignalFunction.js'\nexport * from './createSignalObject.js'\nexport * from './createStoppableEffect.js'\nexport * from './createSyncedSignals.js'\nexport * from './signalify.js'\nexport * from './syncSignals.js'\n\nexport * from './decorators/index.js'\n\nexport const version = '0.3.8'\n"],"mappings":"AAAA,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB;AAC9B,cAAc,2BAA2B;AACzC,cAAc,2BAA2B;AACzC,cAAc,yBAAyB;AACvC,cAAc,4BAA4B;AAC1C,cAAc,0BAA0B;AACxC,cAAc,gBAAgB;AAC9B,cAAc,kBAAkB;AAEhC,cAAc,uBAAuB;AAErC,OAAO,MAAMA,OAAO,GAAG,OAAO"} \ No newline at end of file +{"version":3,"file":"index.js","names":["version"],"sources":["../src/index.ts"],"sourcesContent":["export * from './Effectful.js'\nexport * from './component.js'\nexport * from './createDeferredEffect.js'\nexport * from './createSignalFunction.js'\nexport * from './createSignalObject.js'\nexport * from './createStoppableEffect.js'\nexport * from './createSyncedSignals.js'\nexport * from './signalify.js'\nexport * from './syncSignals.js'\n\nexport * from './decorators/index.js'\n\nexport const version = '0.3.8'\n"],"mappings":"AAAA,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB;AAC9B,cAAc,2BAA2B;AACzC,cAAc,2BAA2B;AACzC,cAAc,yBAAyB;AACvC,cAAc,4BAA4B;AAC1C,cAAc,0BAA0B;AACxC,cAAc,gBAAgB;AAC9B,cAAc,kBAAkB;AAEhC,cAAc,uBAAuB;AAErC,OAAO,MAAMA,OAAO,GAAG,OAAO","ignoreList":[]} \ No newline at end of file diff --git a/dist/index.test.js b/dist/index.test.js index b0daf8f..9820b87 100644 --- a/dist/index.test.js +++ b/dist/index.test.js @@ -1,17 +1,7 @@ -function createAddInitializerMethod(e, t) { return function (r) { assertNotFinished(t, "addInitializer"), assertCallable(r, "An initializer"), e.push(r); }; } -function assertInstanceIfPrivate(e, t) { if (!e(t)) throw new TypeError("Attempted to access private element on non-instance"); } -function memberDec(e, t, r, a, n, i, s, o, c, l, u) { var f; switch (i) { case 1: f = "accessor"; break; case 2: f = "method"; break; case 3: f = "getter"; break; case 4: f = "setter"; break; default: f = "field"; } var d, p, h = { kind: f, name: o ? "#" + r : r, static: s, private: o, metadata: u }, v = { v: !1 }; if (0 !== i && (h.addInitializer = createAddInitializerMethod(n, v)), o || 0 !== i && 2 !== i) { if (2 === i) d = function (e) { return assertInstanceIfPrivate(l, e), a.value; };else { var y = 0 === i || 1 === i; (y || 3 === i) && (d = o ? function (e) { return assertInstanceIfPrivate(l, e), a.get.call(e); } : function (e) { return a.get.call(e); }), (y || 4 === i) && (p = o ? function (e, t) { assertInstanceIfPrivate(l, e), a.set.call(e, t); } : function (e, t) { a.set.call(e, t); }); } } else d = function (e) { return e[r]; }, 0 === i && (p = function (e, t) { e[r] = t; }); var m = o ? l.bind() : function (e) { return r in e; }; h.access = d && p ? { get: d, set: p, has: m } : d ? { get: d, has: m } : { set: p, has: m }; try { return e.call(t, c, h); } finally { v.v = !0; } } -function assertNotFinished(e, t) { if (e.v) throw new Error("attempted to call " + t + " after decoration was finished"); } -function assertCallable(e, t) { if ("function" != typeof e) throw new TypeError(t + " must be a function"); } -function assertValidReturnValue(e, t) { var r = typeof t; if (1 === e) { if ("object" !== r || null === t) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0"); void 0 !== t.get && assertCallable(t.get, "accessor.get"), void 0 !== t.set && assertCallable(t.set, "accessor.set"), void 0 !== t.init && assertCallable(t.init, "accessor.init"); } else if ("function" !== r) { var a; throw a = 0 === e ? "field" : 5 === e ? "class" : "method", new TypeError(a + " decorators must return a function or void 0"); } } -function curryThis1(e) { return function () { return e(this); }; } -function curryThis2(e) { return function (t) { e(this, t); }; } -function applyMemberDec(e, t, r, a, n, i, s, o, c, l, u) { var f, d, p, h, v, y, m = r[0]; a || Array.isArray(m) || (m = [m]), o ? f = 0 === i || 1 === i ? { get: curryThis1(r[3]), set: curryThis2(r[4]) } : 3 === i ? { get: r[3] } : 4 === i ? { set: r[3] } : { value: r[3] } : 0 !== i && (f = Object.getOwnPropertyDescriptor(t, n)), 1 === i ? p = { get: f.get, set: f.set } : 2 === i ? p = f.value : 3 === i ? p = f.get : 4 === i && (p = f.set); for (var g = a ? 2 : 1, b = m.length - 1; b >= 0; b -= g) { var I; if (void 0 !== (h = memberDec(m[b], a ? m[b - 1] : void 0, n, f, c, i, s, o, p, l, u))) assertValidReturnValue(i, h), 0 === i ? I = h : 1 === i ? (I = h.init, v = h.get || p.get, y = h.set || p.set, p = { get: v, set: y }) : p = h, void 0 !== I && (void 0 === d ? d = I : "function" == typeof d ? d = [d, I] : d.push(I)); } if (0 === i || 1 === i) { if (void 0 === d) d = function (e, t) { return t; };else if ("function" != typeof d) { var w = d; d = function (e, t) { for (var r = t, a = w.length - 1; a >= 0; a--) r = w[a].call(e, r); return r; }; } else { var M = d; d = function (e, t) { return M.call(e, t); }; } e.push(d); } 0 !== i && (1 === i ? (f.get = p.get, f.set = p.set) : 2 === i ? f.value = p : 3 === i ? f.get = p : 4 === i && (f.set = p), o ? 1 === i ? (e.push(function (e, t) { return p.get.call(e, t); }), e.push(function (e, t) { return p.set.call(e, t); })) : 2 === i ? e.push(p) : e.push(function (e, t) { return p.call(e, t); }) : Object.defineProperty(t, n, f)); } -function applyMemberDecs(e, t, r, a) { for (var n, i, s, o = [], c = new Map(), l = new Map(), u = 0; u < t.length; u++) { var f = t[u]; if (Array.isArray(f)) { var d, p, h = f[1], v = f[2], y = f.length > 3, m = 16 & h, g = !!(8 & h), b = r; if (h &= 7, g ? (d = e, 0 !== h && (p = i = i || []), y && !s && (s = function (t) { return _checkInRHS(t) === e; }), b = s) : (d = e.prototype, 0 !== h && (p = n = n || [])), 0 !== h && !y) { var I = g ? l : c, w = I.get(v) || 0; if (!0 === w || 3 === w && 4 !== h || 4 === w && 3 !== h) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + v); I.set(v, !(!w && h > 2) || h); } applyMemberDec(o, d, f, m, v, h, g, y, p, b, a); } } return pushInitializers(o, n), pushInitializers(o, i), o; } -function pushInitializers(e, t) { t && e.push(function (e) { for (var r = 0; r < t.length; r++) t[r].call(e); return e; }); } -function applyClassDecs(e, t, r, a) { if (t.length) { for (var n = [], i = e, s = e.name, o = r ? 2 : 1, c = t.length - 1; c >= 0; c -= o) { var l = { v: !1 }; try { var u = t[c].call(r ? t[c - 1] : void 0, i, { kind: "class", name: s, addInitializer: createAddInitializerMethod(n, l), metadata: a }); } finally { l.v = !0; } void 0 !== u && (assertValidReturnValue(5, u), i = u); } return [defineMetadata(i, a), function () { for (var e = 0; e < n.length; e++) n[e].call(i); }]; } } -function defineMetadata(e, t) { return Object.defineProperty(e, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: t }); } -function _applyDecs(e, t, r, a, n, i) { if (arguments.length >= 6) var s = i[Symbol.metadata || Symbol.for("Symbol.metadata")]; var o = Object.create(void 0 === s ? null : s), c = applyMemberDecs(e, t, n, o); return r.length || defineMetadata(e, o), { e: c, get c() { return applyClassDecs(e, r, a, o); } }; } +function _applyDecs(e, t, r, n, o, a) { function i(e, t, r) { return function (n, o) { return r && r(n), e[t].call(n, o); }; } function c(e, t) { for (var r = 0; r < e.length; r++) e[r].call(t); return t; } function s(e, t, r, n) { if ("function" != typeof e && (n || void 0 !== e)) throw new TypeError(t + " must " + (r || "be") + " a function" + (n ? "" : " or undefined")); return e; } function applyDec(e, t, r, n, o, a, c, u, l, f, p, d, h) { function m(e) { if (!h(e)) throw new TypeError("Attempted to access private element on non-instance"); } var y, v = t[0], g = t[3], b = !u; if (!b) { r || Array.isArray(v) || (v = [v]); var w = {}, S = [], A = 3 === o ? "get" : 4 === o || d ? "set" : "value"; f ? (p || d ? w = { get: _setFunctionName(function () { return g(this); }, n, "get"), set: function (e) { t[4](this, e); } } : w[A] = g, p || _setFunctionName(w[A], n, 2 === o ? "" : A)) : p || (w = Object.getOwnPropertyDescriptor(e, n)); } for (var P = e, j = v.length - 1; j >= 0; j -= r ? 2 : 1) { var D = v[j], E = r ? v[j - 1] : void 0, I = {}, O = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: n, metadata: a, addInitializer: function (e, t) { if (e.v) throw Error("attempted to call addInitializer after decoration was finished"); s(t, "An initializer", "be", !0), c.push(t); }.bind(null, I) }; try { if (b) (y = s(D.call(E, P, O), "class decorators", "return")) && (P = y);else { var k, F; O.static = l, O.private = f, f ? 2 === o ? k = function (e) { return m(e), w.value; } : (o < 4 && (k = i(w, "get", m)), 3 !== o && (F = i(w, "set", m))) : (k = function (e) { return e[n]; }, (o < 2 || 4 === o) && (F = function (e, t) { e[n] = t; })); var N = O.access = { has: f ? h.bind() : function (e) { return n in e; } }; if (k && (N.get = k), F && (N.set = F), P = D.call(E, d ? { get: w.get, set: w.set } : w[A], O), d) { if ("object" == typeof P && P) (y = s(P.get, "accessor.get")) && (w.get = y), (y = s(P.set, "accessor.set")) && (w.set = y), (y = s(P.init, "accessor.init")) && S.push(y);else if (void 0 !== P) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0"); } else s(P, (p ? "field" : "method") + " decorators", "return") && (p ? S.push(P) : w[A] = P); } } finally { I.v = !0; } } return (p || d) && u.push(function (e, t) { for (var r = S.length - 1; r >= 0; r--) t = S[r].call(e, t); return t; }), p || b || (f ? d ? u.push(i(w, "get"), i(w, "set")) : u.push(2 === o ? w[A] : i.call.bind(w[A])) : Object.defineProperty(e, n, w)), P; } function u(e, t) { return Object.defineProperty(e, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: t }); } if (arguments.length >= 6) var l = a[Symbol.metadata || Symbol.for("Symbol.metadata")]; var f = Object.create(null == l ? null : l), p = function (e, t, r, n) { var o, a, i = [], s = function (t) { return _checkInRHS(t) === e; }, u = new Map(); function l(e) { e && i.push(c.bind(null, e)); } for (var f = 0; f < t.length; f++) { var p = t[f]; if (Array.isArray(p)) { var d = p[1], h = p[2], m = p.length > 3, y = 16 & d, v = !!(8 & d), g = 0 == (d &= 7), b = h + "/" + v; if (!g && !m) { var w = u.get(b); if (!0 === w || 3 === w && 4 !== d || 4 === w && 3 !== d) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h); u.set(b, !(d > 2) || d); } applyDec(v ? e : e.prototype, p, y, m ? "#" + h : _toPropertyKey(h), d, n, v ? a = a || [] : o = o || [], i, v, m, g, 1 === d, v && m ? s : r); } } return l(o), l(a), i; }(e, t, o, f); return r.length || u(e, f), { e: p, get c() { var t = []; return r.length && [u(applyDec(e, [r], n, e.name, 5, f, t), f), c.bind(null, t, e)]; } }; } +function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } +function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } +function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; } function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; } import { createComputed, createEffect, createRoot, createSignal, untrack } from 'solid-js'; import { createMutable } from 'solid-js/store'; @@ -21,6 +11,7 @@ import { createSignalObject, reactive, signalify, createSignalFunction, signal, // TODO move type def to @lume/cli, map @types/jest's `expect` type into the // global env. + describe('classy-solid', () => { describe('createSignalObject()', () => { it('has gettable and settable values via .get and .set methods', async () => { @@ -400,7 +391,6 @@ describe('classy-solid', () => { // expect(err.message).toContain('Did you forget') }); - it('works with function values', () => { var _initClass7, _init_do; let _Doer; @@ -452,7 +442,6 @@ describe('classy-solid', () => { // callstack size error (infinite loop) does not happen. }); }); - it('show that signalify causes constructor to be reactive when used manually instead of decorators', () => { class Foo { amount = 3; @@ -468,7 +457,6 @@ describe('classy-solid', () => { this.double = this.amount * 2; // this tracks access of .amount } } - let count = 0; let b; createEffect(() => { diff --git a/dist/index.test.js.map b/dist/index.test.js.map index cfe66e0..9b00f5f 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","_initClass2","_init_colors2","_initProto2","_initClass3","_init_colors3","_Butterfly3","_Butterfly2","_SubButterfly","SubButterfly","_initClass4","_initClass5","_init_colors4","_initProto3","_Insect2","_Insect","Insect","constructor","double","_Butterfly4","arg","b2","prototype","_init_foo","_initClass6","_init_bar","Foo","_Bar","Bar","bar","toThrow","_initClass7","_init_do","_Doer","Doer","do","doer","newFunc","obj","console","log","amount","_initClass8","_init_amount","_initClass9","_init_double","_Foo2","_Foo","_Bar2","noLoop","not","_initClass10","onMountCalled","onCleanupCalled","_CoolComp","CoolComp","onMount","onCleanup","template","props","root","document","createElement","body","append","dispose","textContent","remove","_initProto4","args","_initClass11","_init_foo2","_init_bar2","_CoolComp2","a","setA","xit","_initClass12","_init_foo3","_init_bar3","_CoolComp3","o","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, and signalify', () => {\n\t\tit('makes class properties reactive, using class and property/accessor decorators', () => {\n\t\t\t@reactive\n\t\t\tclass Butterfly {\n\t\t\t\t@signal colors = 3\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\t\t\t}\n\n\t\t\tconst b = new Butterfly()\n\n\t\t\ttestButterflyProps(b)\n\t\t})\n\n\t\tit('maintains reactivity in subclass overridden fields', async () => {\n\t\t\t@reactive\n\t\t\tclass Butterfly {\n\t\t\t\t@signal colors = 3\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\t\t\t}\n\n\t\t\t@reactive\n\t\t\tclass SubButterfly extends Butterfly {\n\t\t\t\t@signal override colors = 123\n\t\t\t}\n\n\t\t\tconst b = new SubButterfly()\n\n\t\t\ttestButterflyProps(b, 123)\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\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('makes class properties reactive, not using any decorators, specified in the constructor', () => {\n\t\t\tclass Butterfly {\n\t\t\t\tcolors = 3\n\t\t\t\t_wingSize = 2\n\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() {\n\t\t\t\t\tsignalify(this, 'colors', 'wingSize')\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst b = new Butterfly()\n\n\t\t\ttestButterflyProps(b)\n\n\t\t\t// quick type check:\n\t\t\tconst b2 = new Butterfly()\n\t\t\tsignalify(\n\t\t\t\tb2,\n\t\t\t\t'colors',\n\t\t\t\t'wingSize',\n\t\t\t\t// @ts-expect-error \"foo\" is not a property on Butterfly\n\t\t\t\t'foo',\n\t\t\t)\n\t\t})\n\n\t\tit('makes class properties reactive, with signalify in the constructor', () => {\n\t\t\tclass Butterfly {\n\t\t\t\tcolors: number\n\t\t\t\t_wingSize: number\n\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() {\n\t\t\t\t\tthis.colors = 3\n\t\t\t\t\tthis._wingSize = 2\n\n\t\t\t\t\tsignalify(this, 'colors', 'wingSize')\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst b = new Butterfly()\n\n\t\t\ttestButterflyProps(b)\n\t\t})\n\n\t\tit('works with a function-style class, with signalify in the constructor', () => {\n\t\t\tfunction Butterfly() {\n\t\t\t\t// @ts-ignore\n\t\t\t\tthis.colors = 3\n\t\t\t\t// @ts-ignore\n\t\t\t\tthis._wingSize = 2\n\n\t\t\t\t// @ts-ignore no type checking for ES5-style classes.\n\t\t\t\tsignalify(this, 'colors', 'wingSize')\n\t\t\t}\n\n\t\t\tButterfly.prototype = {\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\t\t\t}\n\n\t\t\t// @ts-ignore\n\t\t\tconst b = new Butterfly()\n\t\t\ttestButterflyProps(b)\n\t\t})\n\n\t\tit('works with a function-style class, with properties on the prototype, and signalify in constructor', () => {\n\t\t\tfunction Butterfly() {\n\t\t\t\t// @ts-ignore no type checking for ES5-style classes.\n\t\t\t\tsignalify(this, 'colors', 'wingSize')\n\t\t\t}\n\n\t\t\tButterfly.prototype = {\n\t\t\t\tcolors: 3,\n\t\t\t\t_wingSize: 2,\n\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\t\t\t}\n\n\t\t\t// @ts-ignore no type checking for ES5-style classes.\n\t\t\tconst b = new Butterfly()\n\t\t\ttestButterflyProps(b)\n\t\t})\n\n\t\tit('can be used on a function-style class, with properties on the prototype, and signalify on the prototype', () => {\n\t\t\tfunction Butterfly() {}\n\n\t\t\tButterfly.prototype = {\n\t\t\t\tcolors: 3,\n\t\t\t\t_wingSize: 2,\n\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\t\t\t}\n\n\t\t\tsignalify(Butterfly.prototype, 'colors', 'wingSize')\n\n\t\t\t// @ts-ignore no type checking for ES5-style classes.\n\t\t\tconst b = new Butterfly()\n\t\t\ttestButterflyProps(b)\n\t\t})\n\n\t\tit('can be used on a function-style class, with properties in the constructor, and signalify on the prototype', () => {\n\t\t\tfunction Butterfly() {\n\t\t\t\t// @ts-ignore\n\t\t\t\tthis.colors = 3\n\t\t\t\t// @ts-ignore\n\t\t\t\tthis._wingSize = 2\n\t\t\t}\n\n\t\t\tButterfly.prototype = {\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\t\t\t}\n\n\t\t\tsignalify(Butterfly.prototype, 'colors', 'wingSize')\n\n\t\t\t// @ts-ignore\n\t\t\tconst b = new Butterfly()\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\tdescribe('signalify', () => {\n\t\t\tit('is not tracked inside of an effect to prevent loops', () => {\n\t\t\t\t// Library author provides obj\n\t\t\t\tconst obj = {n: 123}\n\t\t\t\tsignalify(obj, 'n') // library author might signalify obj.n\n\n\t\t\t\t// User code:\n\t\t\t\tcreateEffect(() => {\n\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\tsignalify(obj, 'n')\n\n\t\t\t\t\tobj.n = 123 // does not make an infinite loop\n\n\t\t\t\t\t// A deeper effect will be reading the property.\n\t\t\t\t\tcreateEffect(() => {\n\t\t\t\t\t\tconsole.log(obj.n)\n\t\t\t\t\t})\n\t\t\t\t})\n\n\t\t\t\t// No expectations in this test, the test passes if a maximum\n\t\t\t\t// callstack size error (infinite loop) does not happen.\n\t\t\t})\n\t\t})\n\n\t\tit('show that signalify causes constructor to be reactive when used manually instead of decorators', () => {\n\t\t\tclass Foo {\n\t\t\t\tamount = 3\n\n\t\t\t\tconstructor() {\n\t\t\t\t\tsignalify(this, 'amount')\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tclass Bar extends Foo {\n\t\t\t\tdouble = 0\n\n\t\t\t\tconstructor() {\n\t\t\t\t\tsuper()\n\t\t\t\t\tsignalify(this, 'double')\n\t\t\t\t\tthis.double = this.amount * 2 // this tracks access of .amount\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet count = 0\n\t\t\tlet b!: Bar\n\n\t\t\tcreateEffect(() => {\n\t\t\t\tb = new Bar() // tracks .amount\n\t\t\t\tcount++\n\t\t\t})\n\n\t\t\texpect(count).toBe(1)\n\n\t\t\tb.amount = 4 // triggers\n\n\t\t\texpect(count).toBe(2)\n\t\t})\n\n\t\tit('show how to manually untrack constructors when not using decorators', () => {\n\t\t\tclass Foo {\n\t\t\t\tamount = 3\n\n\t\t\t\tconstructor() {\n\t\t\t\t\tsignalify(this, 'amount')\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tclass Bar extends Foo {\n\t\t\t\tdouble = 0\n\n\t\t\t\tconstructor() {\n\t\t\t\t\tsuper()\n\t\t\t\t\tsignalify(this, 'double')\n\n\t\t\t\t\tuntrack(() => {\n\t\t\t\t\t\tthis.double = this.amount * 2\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet count = 0\n\t\t\tlet b!: Bar\n\n\t\t\tcreateEffect(() => {\n\t\t\t\tb = new Bar() // does not track .amount\n\t\t\t\tcount++\n\t\t\t})\n\n\t\t\texpect(count).toBe(1)\n\n\t\t\tb.amount = 4 // will not trigger\n\n\t\t\texpect(count).toBe(1)\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('@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\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,MAAM;IACtCC,EAAE,CAAC,4DAA4D,EAAE,YAAY;MAC5E,MAAMC,GAAG,GAAGT,kBAAkB,CAAC,CAAC,CAAC;;MAEjC;MACAS,GAAG,CAACC,GAAG,CAAC,CAAC,CAAC;MACV;MACAC,MAAM,CAACF,GAAG,CAACG,GAAG,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,CAAC,CAAC;;MAEzB;MACA,MAAMC,SAAS,GAAGL,GAAG,CAACC,GAAG,CAACD,GAAG,CAACG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;MACxCD,MAAM,CAACF,GAAG,CAACG,GAAG,CAAC,CAAC,CAAC,CAACC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A6B,GAAGP,aAAa,CAAC,CAAC;EACrDO,IAAI;AACL"} \ 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","count","foo","runCount","stop","_stop","Promise","resolve","_initClass","_init_colors","_initProto","_Butterfly","Butterfly","e","c","_applyDecs","colors","_wingSize","wingSize","s","b","testButterflyProps","_initClass2","_init_colors2","_initProto2","_initClass3","_init_colors3","_Butterfly3","_Butterfly2","_SubButterfly","SubButterfly","_initClass4","_initClass5","_init_colors4","_initProto3","_Insect2","_Insect","Insect","constructor","double","_Butterfly4","arg","b2","prototype","_init_foo","_initClass6","_init_bar","Foo","_Bar","Bar","bar","toThrow","_initClass7","_init_do","_Doer","Doer","do","doer","newFunc","obj","console","log","amount","_initClass8","_init_amount","_initClass9","_init_double","_Foo2","_Foo","_Bar2","noLoop","not","_initClass10","onMountCalled","onCleanupCalled","_CoolComp","CoolComp","onMount","onCleanup","template","props","root","document","createElement","body","append","dispose","textContent","remove","_initProto4","args","_initClass11","_init_foo2","_init_bar2","_CoolComp2","a","setA","xit","_initClass12","_init_foo3","_init_bar3","_CoolComp3","o","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, and signalify', () => {\n\t\tit('makes class properties reactive, using class and property/accessor decorators', () => {\n\t\t\t@reactive\n\t\t\tclass Butterfly {\n\t\t\t\t@signal colors = 3\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\t\t\t}\n\n\t\t\tconst b = new Butterfly()\n\n\t\t\ttestButterflyProps(b)\n\t\t})\n\n\t\tit('maintains reactivity in subclass overridden fields', async () => {\n\t\t\t@reactive\n\t\t\tclass Butterfly {\n\t\t\t\t@signal colors = 3\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\t\t\t}\n\n\t\t\t@reactive\n\t\t\tclass SubButterfly extends Butterfly {\n\t\t\t\t@signal override colors = 123\n\t\t\t}\n\n\t\t\tconst b = new SubButterfly()\n\n\t\t\ttestButterflyProps(b, 123)\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\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('makes class properties reactive, not using any decorators, specified in the constructor', () => {\n\t\t\tclass Butterfly {\n\t\t\t\tcolors = 3\n\t\t\t\t_wingSize = 2\n\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() {\n\t\t\t\t\tsignalify(this, 'colors', 'wingSize')\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst b = new Butterfly()\n\n\t\t\ttestButterflyProps(b)\n\n\t\t\t// quick type check:\n\t\t\tconst b2 = new Butterfly()\n\t\t\tsignalify(\n\t\t\t\tb2,\n\t\t\t\t'colors',\n\t\t\t\t'wingSize',\n\t\t\t\t// @ts-expect-error \"foo\" is not a property on Butterfly\n\t\t\t\t'foo',\n\t\t\t)\n\t\t})\n\n\t\tit('makes class properties reactive, with signalify in the constructor', () => {\n\t\t\tclass Butterfly {\n\t\t\t\tcolors: number\n\t\t\t\t_wingSize: number\n\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() {\n\t\t\t\t\tthis.colors = 3\n\t\t\t\t\tthis._wingSize = 2\n\n\t\t\t\t\tsignalify(this, 'colors', 'wingSize')\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst b = new Butterfly()\n\n\t\t\ttestButterflyProps(b)\n\t\t})\n\n\t\tit('works with a function-style class, with signalify in the constructor', () => {\n\t\t\tfunction Butterfly() {\n\t\t\t\t// @ts-ignore\n\t\t\t\tthis.colors = 3\n\t\t\t\t// @ts-ignore\n\t\t\t\tthis._wingSize = 2\n\n\t\t\t\t// @ts-ignore no type checking for ES5-style classes.\n\t\t\t\tsignalify(this, 'colors', 'wingSize')\n\t\t\t}\n\n\t\t\tButterfly.prototype = {\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\t\t\t}\n\n\t\t\t// @ts-ignore\n\t\t\tconst b = new Butterfly()\n\t\t\ttestButterflyProps(b)\n\t\t})\n\n\t\tit('works with a function-style class, with properties on the prototype, and signalify in constructor', () => {\n\t\t\tfunction Butterfly() {\n\t\t\t\t// @ts-ignore no type checking for ES5-style classes.\n\t\t\t\tsignalify(this, 'colors', 'wingSize')\n\t\t\t}\n\n\t\t\tButterfly.prototype = {\n\t\t\t\tcolors: 3,\n\t\t\t\t_wingSize: 2,\n\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\t\t\t}\n\n\t\t\t// @ts-ignore no type checking for ES5-style classes.\n\t\t\tconst b = new Butterfly()\n\t\t\ttestButterflyProps(b)\n\t\t})\n\n\t\tit('can be used on a function-style class, with properties on the prototype, and signalify on the prototype', () => {\n\t\t\tfunction Butterfly() {}\n\n\t\t\tButterfly.prototype = {\n\t\t\t\tcolors: 3,\n\t\t\t\t_wingSize: 2,\n\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\t\t\t}\n\n\t\t\tsignalify(Butterfly.prototype, 'colors', 'wingSize')\n\n\t\t\t// @ts-ignore no type checking for ES5-style classes.\n\t\t\tconst b = new Butterfly()\n\t\t\ttestButterflyProps(b)\n\t\t})\n\n\t\tit('can be used on a function-style class, with properties in the constructor, and signalify on the prototype', () => {\n\t\t\tfunction Butterfly() {\n\t\t\t\t// @ts-ignore\n\t\t\t\tthis.colors = 3\n\t\t\t\t// @ts-ignore\n\t\t\t\tthis._wingSize = 2\n\t\t\t}\n\n\t\t\tButterfly.prototype = {\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\t\t\t}\n\n\t\t\tsignalify(Butterfly.prototype, 'colors', 'wingSize')\n\n\t\t\t// @ts-ignore\n\t\t\tconst b = new Butterfly()\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\tdescribe('signalify', () => {\n\t\t\tit('is not tracked inside of an effect to prevent loops', () => {\n\t\t\t\t// Library author provides obj\n\t\t\t\tconst obj = {n: 123}\n\t\t\t\tsignalify(obj, 'n') // library author might signalify obj.n\n\n\t\t\t\t// User code:\n\t\t\t\tcreateEffect(() => {\n\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\tsignalify(obj, 'n')\n\n\t\t\t\t\tobj.n = 123 // does not make an infinite loop\n\n\t\t\t\t\t// A deeper effect will be reading the property.\n\t\t\t\t\tcreateEffect(() => {\n\t\t\t\t\t\tconsole.log(obj.n)\n\t\t\t\t\t})\n\t\t\t\t})\n\n\t\t\t\t// No expectations in this test, the test passes if a maximum\n\t\t\t\t// callstack size error (infinite loop) does not happen.\n\t\t\t})\n\t\t})\n\n\t\tit('show that signalify causes constructor to be reactive when used manually instead of decorators', () => {\n\t\t\tclass Foo {\n\t\t\t\tamount = 3\n\n\t\t\t\tconstructor() {\n\t\t\t\t\tsignalify(this, 'amount')\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tclass Bar extends Foo {\n\t\t\t\tdouble = 0\n\n\t\t\t\tconstructor() {\n\t\t\t\t\tsuper()\n\t\t\t\t\tsignalify(this, 'double')\n\t\t\t\t\tthis.double = this.amount * 2 // this tracks access of .amount\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet count = 0\n\t\t\tlet b!: Bar\n\n\t\t\tcreateEffect(() => {\n\t\t\t\tb = new Bar() // tracks .amount\n\t\t\t\tcount++\n\t\t\t})\n\n\t\t\texpect(count).toBe(1)\n\n\t\t\tb.amount = 4 // triggers\n\n\t\t\texpect(count).toBe(2)\n\t\t})\n\n\t\tit('show how to manually untrack constructors when not using decorators', () => {\n\t\t\tclass Foo {\n\t\t\t\tamount = 3\n\n\t\t\t\tconstructor() {\n\t\t\t\t\tsignalify(this, 'amount')\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tclass Bar extends Foo {\n\t\t\t\tdouble = 0\n\n\t\t\t\tconstructor() {\n\t\t\t\t\tsuper()\n\t\t\t\t\tsignalify(this, 'double')\n\n\t\t\t\t\tuntrack(() => {\n\t\t\t\t\t\tthis.double = this.amount * 2\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet count = 0\n\t\t\tlet b!: Bar\n\n\t\t\tcreateEffect(() => {\n\t\t\t\tb = new Bar() // does not track .amount\n\t\t\t\tcount++\n\t\t\t})\n\n\t\t\texpect(count).toBe(1)\n\n\t\t\tb.amount = 4 // will not trigger\n\n\t\t\texpect(count).toBe(1)\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('@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\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,MAAM;IACtCC,EAAE,CAAC,4DAA4D,EAAE,YAAY;MAC5E,MAAMC,GAAG,GAAGT,kBAAkB,CAAC,CAAC,CAAC;;MAEjC;MACAS,GAAG,CAACC,GAAG,CAAC,CAAC,CAAC;MACV;MACAC,MAAM,CAACF,GAAG,CAACG,GAAG,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,CAAC,CAAC;;MAEzB;MACA,MAAMC,SAAS,GAAGL,GAAG,CAACC,GAAG,CAACD,GAAG,CAACG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;MACxCD,MAAM,CAACF,GAAG,CAACG,GAAG,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,CAAC,CAAC;MACzBF,MAAM,CAACG,SAAS,CAAC,CAACD,IAAI,CAAC,CAAC,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--git a/dist/signalify.js b/dist/signalify.js index f92f48e..709feda 100644 --- a/dist/signalify.js +++ b/dist/signalify.js @@ -160,7 +160,6 @@ override = false) { } : function () { return s[0](); // read }, - set: originalSet ? function (newValue) { originalSet.call(this, newValue); trackPropSetAtLeastOnce(this, prop); diff --git a/dist/signalify.js.map b/dist/signalify.js.map index fbeab3c..b4b1c14 100644 --- a/dist/signalify.js.map +++ b/dist/signalify.js.map @@ -1 +1 @@ -{"version":3,"file":"signalify.js","names":["getInheritedDescriptor","createSignal","$PROXY","untrack","signalifiedProps","WeakMap","signalify","obj","props","_props","length","Object","keys","concat","getOwnPropertySymbols","prop","createSignalAccessor","gotCreateSignalAccessor","getCreateSignalAccessor","Error","propsSetAtLeastOnce","__isPropSetAtLeastOnce","instance","get","has","trackPropSetAtLeastOnce","set","Set","add","isSignalGetter","WeakSet","initialVal","override","proxy","descriptor","originalGet","originalSet","console","warn","toString","value","writable","s","equals","configurable","enumerable","call","newValue","defineProperty"],"sources":["../src/signalify.ts"],"sourcesContent":["import {getInheritedDescriptor} from 'lowclass/dist/getInheritedDescriptor.js'\nimport {createSignal, $PROXY, untrack} from 'solid-js'\nimport type {PropKey, PropSpec} from './decorators/types.js'\n\nconst signalifiedProps = new WeakMap>()\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, ...props: (keyof T)[]): T\nexport function signalify(obj: T): T\nexport function signalify(obj: Obj, ...props: [] | [Map] | PropertyKey[]) {\n\t// We cast from PropertyKey[] to PropKey[] because numbers can't actually be keys, only string | symbol.\n\tconst _props = props.length\n\t\t? (props as PropKey[])\n\t\t: (Object.keys(obj) as PropKey[]).concat(Object.getOwnPropertySymbols(obj))\n\n\tfor (const prop of _props) createSignalAccessor(obj, prop)\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(\n\tobj: T,\n\tprop: Exclude,\n\t// Untrack here to be extra safe this doesn't count as a dependency and\n\t// cause a reactivity loop.\n\tinitialVal: unknown = untrack(() => obj[prop]),\n\t// If an object already has a particular signalified property, override it\n\t// with a new one anyway (useful for maintaining consistency with class\n\t// inheritance where class fields always override fields from base classes\n\t// due to their [[Define]] semantics). False is a good default for signalify()\n\t// usage where someone is augmenting an existing object, but true is more\n\t// useful with usage of @signal on class fields.\n\t//\n\t// Note that if @signal were to specify this as false, it would cause\n\t// @signal-decorated subclass fields to override base class\n\t// @signal-decorated fields with a new value descriptor but without\n\t// signalifiying the field, effectively disabling reactivity, which is a bug\n\t// (a field decorated with @signal *must* be reactive). The test named\n\t// \"maintains reactivity in subclass overridden fields\" was added to ensure\n\t// that the subclass use case works.\n\toverride = false,\n): void {\n\tif (!override && signalifiedProps.get(obj)?.has(prop)) return\n\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\n\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\t// Even if override is true, if we have a signal accessor, there's no\n\t\t// need to replace it with another signal accessor. We only need to\n\t\t// override when the current descriptor is not a signal accessor.\n\t\t// TODO this needs tests.\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) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`The \\`@signal\\` decorator was used on an accessor named \"${prop.toString()}\" which had a getter or a setter, but not both. Reactivity on accessors works only when accessors have both get and set. In this case the decorator does not do anything.`,\n\t\t\t\t)\n\t\t\t\treturn\n\t\t\t}\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) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`The \\`@signal\\` decorator was used on a property named \"${prop.toString()}\" that is not writable. Reactivity is not enabled for non-writable properties.`,\n\t\t\t\t)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tdelete descriptor.value\n\t\t\tdelete descriptor.writable\n\t\t}\n\t}\n\n\tconst s = createSignal(initialVal, {equals: false})\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: T): unknown {\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: any): unknown {\n\t\t\t\t\treturn s[0]() // read\n\t\t\t },\n\t\tset: originalSet\n\t\t\t? function (this: any, 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\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: any, newValue: unknown) {\n\t\t\t\t\ttrackPropSetAtLeastOnce(this, prop)\n\n\t\t\t\t\t// write\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\tif (!signalifiedProps.has(obj)) signalifiedProps.set(obj, new Set())\n\tsignalifiedProps.get(obj)!.add(prop)\n}\n\ntype Obj = Record\n"],"mappings":"AAAA,SAAQA,sBAAsB,QAAO,yCAAyC;AAC9E,SAAQC,YAAY,EAAEC,MAAM,EAAEC,OAAO,QAAO,UAAU;AAGtD,MAAMC,gBAAgB,GAAG,IAAIC,OAAO,CAA+B,CAAC;;AAEpE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,CAACM,UAAU,CAACX,GAAI,CAAC;EAEnCZ,MAAM,CAACqC,cAAc,CAACzC,GAAG,EAAEQ,IAAI,EAAEmB,UAAU,CAAC;EAE5C,IAAI,CAAC9B,gBAAgB,CAACoB,GAAG,CAACjB,GAAG,CAAC,EAAEH,gBAAgB,CAACsB,GAAG,CAACnB,GAAG,EAAE,IAAIoB,GAAG,CAAC,CAAC,CAAC;EACpEvB,gBAAgB,CAACmB,GAAG,CAAChB,GAAG,CAAC,CAAEqB,GAAG,CAACb,IAAI,CAAC;AACrC"} \ No newline at end of file +{"version":3,"file":"signalify.js","names":["getInheritedDescriptor","createSignal","$PROXY","untrack","signalifiedProps","WeakMap","signalify","obj","props","_props","length","Object","keys","concat","getOwnPropertySymbols","prop","createSignalAccessor","gotCreateSignalAccessor","getCreateSignalAccessor","Error","propsSetAtLeastOnce","__isPropSetAtLeastOnce","instance","get","has","trackPropSetAtLeastOnce","set","Set","add","isSignalGetter","WeakSet","initialVal","override","proxy","descriptor","originalGet","originalSet","console","warn","toString","value","writable","s","equals","configurable","enumerable","call","newValue","defineProperty"],"sources":["../src/signalify.ts"],"sourcesContent":["import {getInheritedDescriptor} from 'lowclass/dist/getInheritedDescriptor.js'\nimport {createSignal, $PROXY, untrack} from 'solid-js'\nimport type {PropKey, PropSpec} from './decorators/types.js'\n\nconst signalifiedProps = new WeakMap>()\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, ...props: (keyof T)[]): T\nexport function signalify(obj: T): T\nexport function signalify(obj: Obj, ...props: [] | [Map] | PropertyKey[]) {\n\t// We cast from PropertyKey[] to PropKey[] because numbers can't actually be keys, only string | symbol.\n\tconst _props = props.length\n\t\t? (props as PropKey[])\n\t\t: (Object.keys(obj) as PropKey[]).concat(Object.getOwnPropertySymbols(obj))\n\n\tfor (const prop of _props) createSignalAccessor(obj, prop)\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(\n\tobj: T,\n\tprop: Exclude,\n\t// Untrack here to be extra safe this doesn't count as a dependency and\n\t// cause a reactivity loop.\n\tinitialVal: unknown = untrack(() => obj[prop]),\n\t// If an object already has a particular signalified property, override it\n\t// with a new one anyway (useful for maintaining consistency with class\n\t// inheritance where class fields always override fields from base classes\n\t// due to their [[Define]] semantics). False is a good default for signalify()\n\t// usage where someone is augmenting an existing object, but true is more\n\t// useful with usage of @signal on class fields.\n\t//\n\t// Note that if @signal were to specify this as false, it would cause\n\t// @signal-decorated subclass fields to override base class\n\t// @signal-decorated fields with a new value descriptor but without\n\t// signalifiying the field, effectively disabling reactivity, which is a bug\n\t// (a field decorated with @signal *must* be reactive). The test named\n\t// \"maintains reactivity in subclass overridden fields\" was added to ensure\n\t// that the subclass use case works.\n\toverride = false,\n): void {\n\tif (!override && signalifiedProps.get(obj)?.has(prop)) return\n\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\n\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\t// Even if override is true, if we have a signal accessor, there's no\n\t\t// need to replace it with another signal accessor. We only need to\n\t\t// override when the current descriptor is not a signal accessor.\n\t\t// TODO this needs tests.\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) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`The \\`@signal\\` decorator was used on an accessor named \"${prop.toString()}\" which had a getter or a setter, but not both. Reactivity on accessors works only when accessors have both get and set. In this case the decorator does not do anything.`,\n\t\t\t\t)\n\t\t\t\treturn\n\t\t\t}\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) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`The \\`@signal\\` decorator was used on a property named \"${prop.toString()}\" that is not writable. Reactivity is not enabled for non-writable properties.`,\n\t\t\t\t)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tdelete descriptor.value\n\t\t\tdelete descriptor.writable\n\t\t}\n\t}\n\n\tconst s = createSignal(initialVal, {equals: false})\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: T): unknown {\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: any): unknown {\n\t\t\t\t\treturn s[0]() // read\n\t\t\t },\n\t\tset: originalSet\n\t\t\t? function (this: any, 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\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: any, newValue: unknown) {\n\t\t\t\t\ttrackPropSetAtLeastOnce(this, prop)\n\n\t\t\t\t\t// write\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\tif (!signalifiedProps.has(obj)) signalifiedProps.set(obj, new Set())\n\tsignalifiedProps.get(obj)!.add(prop)\n}\n\ntype Obj = Record\n"],"mappings":"AAAA,SAAQA,sBAAsB,QAAO,yCAAyC;AAC9E,SAAQC,YAAY,EAAEC,MAAM,EAAEC,OAAO,QAA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,CAAC,CAACK,QAAQ,CAAC;IACnB;EACJ,CAAC;EAEDlB,cAAc,CAACD,GAAG,CAACM,UAAU,CAACX,GAAI,CAAC;EAEnCZ,MAAM,CAACqC,cAAc,CAACzC,GAAG,EAAEQ,IAAI,EAAEmB,UAAU,CAAC;EAE5C,IAAI,CAAC9B,gBAAgB,CAACoB,GAAG,CAACjB,GAAG,CAAC,EAAEH,gBAAgB,CAACsB,GAAG,CAACnB,GAAG,EAAE,IAAIoB,GAAG,CAAC,CAAC,CAAC;EACpEvB,gBAAgB,CAACmB,GAAG,CAAChB,GAAG,CAAC,CAAEqB,GAAG,CAACb,IAAI,CAAC;AACrC","ignoreList":[]} \ No newline at end of file diff --git a/dist/syncSignals.js.map b/dist/syncSignals.js.map index c35a678..1074d73 100644 --- a/dist/syncSignals.js.map +++ b/dist/syncSignals.js.map @@ -1 +1 @@ -{"version":3,"file":"syncSignals.js","names":["createComputed","syncSignals","getterA","setterA","getterB","setterB","settingB","settingA","_a","_b"],"sources":["../src/syncSignals.ts"],"sourcesContent":["import {createComputed} from 'solid-js'\n\n/**\n * Syncs two signals together so that setting one signal's value updates the\n * other, and vice versa, without an infinite loop.\n *\n * Example:\n *\n * ```js\n * const [foo, setFoo] = createSignal(0)\n * const [bar, setBar] = createSignal(0)\n *\n * syncSignals(foo, setFoo, bar, setBar)\n *\n * createEffect(() => console.log(foo(), bar()))\n *\n * setFoo(1) // logs \"1 1\"\n * setBar(2) // logs \"2 2\"\n * ```\n *\n * It returns the getters/setters, so it is possible to also create the signals\n * and sync them at once:\n *\n * ```js\n * const [[foo, setFoo], [bar, setBar]] = syncSignals(...createSignal(0), ...createSignal(0))\n *\n * createEffect(() => console.log(foo(), bar()))\n *\n * setFoo(1) // logs \"1 1\"\n * setBar(2) // logs \"2 2\"\n * ```\n */\nexport function syncSignals(\n\tgetterA: () => T,\n\tsetterA: (value: T) => void,\n\tgetterB: () => T,\n\tsetterB: (value: T) => void,\n) {\n\tlet settingB = false\n\tlet settingA = false\n\n\tcreateComputed(\n\t\t// @ts-ignore not all code paths return\n\t\t() => {\n\t\t\tconst _a = getterA()\n\t\t\tif (settingA) return (settingA = false)\n\t\t\tsettingB = true\n\t\t\tsetterB(_a)\n\t\t},\n\t)\n\n\tcreateComputed(\n\t\t// @ts-ignore not all code paths return\n\t\t() => {\n\t\t\tconst _b = getterB()\n\t\t\tif (settingB) return (settingB = false)\n\t\t\tsettingA = true\n\t\t\tsetterA(_b)\n\t\t},\n\t)\n\n\treturn [[getterA, setterA] as const, [getterB, setterB] as const] as const\n}\n"],"mappings":"AAAA,SAAQA,cAAc,QAAO,UAAU;;AAEvC;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,WAAWA,CAC1BC,OAAgB,EAChBC,OAA2B,EAC3BC,OAAgB,EAChBC,OAA2B,EAC1B;EACD,IAAIC,QAAQ,GAAG,KAAK;EACpB,IAAIC,QAAQ,GAAG,KAAK;EAEpBP,cAAc;EACb;EACA,MAAM;IACL,MAAMQ,EAAE,GAAGN,OAAO,CAAC,CAAC;IACpB,IAAIK,QAAQ,EAAE,OAAQA,QAAQ,GAAG,KAAK;IACtCD,QAAQ,GAAG,IAAI;IACfD,OAAO,CAACG,EAAE,CAAC;EACZ,CACD,CAAC;EAEDR,cAAc;EACb;EACA,MAAM;IACL,MAAMS,EAAE,GAAGL,OAAO,CAAC,CAAC;IACpB,IAAIE,QAAQ,EAAE,OAAQA,QAAQ,GAAG,KAAK;IACtCC,QAAQ,GAAG,IAAI;IACfJ,OAAO,CAACM,EAAE,CAAC;EACZ,CACD,CAAC;EAED,OAAO,CAAC,CAACP,OAAO,EAAEC,OAAO,CAAC,EAAW,CAACC,OAAO,EAAEC,OAAO,CAAC,CAAU;AAClE"} \ No newline at end of file +{"version":3,"file":"syncSignals.js","names":["createComputed","syncSignals","getterA","setterA","getterB","setterB","settingB","settingA","_a","_b"],"sources":["../src/syncSignals.ts"],"sourcesContent":["import {createComputed} from 'solid-js'\n\n/**\n * Syncs two signals together so that setting one signal's value updates the\n * other, and vice versa, without an infinite loop.\n *\n * Example:\n *\n * ```js\n * const [foo, setFoo] = createSignal(0)\n * const [bar, setBar] = createSignal(0)\n *\n * syncSignals(foo, setFoo, bar, setBar)\n *\n * createEffect(() => console.log(foo(), bar()))\n *\n * setFoo(1) // logs \"1 1\"\n * setBar(2) // logs \"2 2\"\n * ```\n *\n * It returns the getters/setters, so it is possible to also create the signals\n * and sync them at once:\n *\n * ```js\n * const [[foo, setFoo], [bar, setBar]] = syncSignals(...createSignal(0), ...createSignal(0))\n *\n * createEffect(() => console.log(foo(), bar()))\n *\n * setFoo(1) // logs \"1 1\"\n * setBar(2) // logs \"2 2\"\n * ```\n */\nexport function syncSignals(\n\tgetterA: () => T,\n\tsetterA: (value: T) => void,\n\tgetterB: () => T,\n\tsetterB: (value: T) => void,\n) {\n\tlet settingB = false\n\tlet settingA = false\n\n\tcreateComputed(\n\t\t// @ts-ignore not all code paths return\n\t\t() => {\n\t\t\tconst _a = getterA()\n\t\t\tif (settingA) return (settingA = false)\n\t\t\tsettingB = true\n\t\t\tsetterB(_a)\n\t\t},\n\t)\n\n\tcreateComputed(\n\t\t// @ts-ignore not all code paths return\n\t\t() => {\n\t\t\tconst _b = getterB()\n\t\t\tif (settingB) return (settingB = false)\n\t\t\tsettingA = true\n\t\t\tsetterA(_b)\n\t\t},\n\t)\n\n\treturn [[getterA, setterA] as const, [getterB, setterB] as const] as const\n}\n"],"mappings":"AAAA,SAAQA,cAAc,QAAO,UAAU;;AAEvC;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,WAAWA,CAC1BC,OAAgB,EAChBC,OAA2B,EAC3BC,OAAgB,EAChBC,OAA2B,EAC1B;EACD,IAAIC,QAAQ,GAAG,KAAK;EACpB,IAAIC,QAAQ,GAAG,KAAK;EAEpBP,cAAc;EACb;EACA,MAAM;IACL,MAAMQ,EAAE,GAAGN,OAAO,CAAC,CAAC;IACpB,IAAIK,QAAQ,EAAE,OAAQA,QAAQ,GAAG,KAAK;IACtCD,QAAQ,GAAG,IAAI;IACfD,OAAO,CAACG,EAAE,CAAC;EACZ,CACD,CAAC;EAEDR,cAAc;EACb;EACA,MAAM;IACL,MAAMS,EAAE,GAAGL,OAAO,CAAC,CAAC;IACpB,IAAIE,QAAQ,EAAE,OAAQA,QAAQ,GAAG,KAAK;IACtCC,QAAQ,GAAG,IAAI;IACfJ,OAAO,CAACM,EAAE,CAAC;EACZ,CACD,CAAC;EAED,OAAO,CAAC,CAACP,OAAO,EAAEC,OAAO,CAAC,EAAW,CAACC,OAAO,EAAEC,OAAO,CAAC,CAAU;AAClE","ignoreList":[]} \ No newline at end of file