classy-solid
Advanced tools
Comparing version 0.4.2 to 0.4.3
import { $PROXY } from 'solid-js'; | ||
import { __getSignal, __trackPropSetAtLeastOnce, __createSignalAccessor } from '../signals/signalify.js'; | ||
import { __getSignal, __trackPropSetAtLeastOnce, __createSignalAccessor, isSignalGetter } from '../signals/signalify.js'; | ||
export let __propsToSignalify = new Map(); | ||
@@ -67,7 +67,4 @@ export function __resetPropsToSignalify() { | ||
// @prod-prune | ||
if (!Object.hasOwn(this, prop)) | ||
// continue | ||
throw new PropNotFoundError(prop); | ||
if (!Object.hasOwn(this, prop)) throw new PropNotFoundError(prop); | ||
__createSignalAccessor(this, prop, initialValue); | ||
// CONTINUE testing this way of finalizing signal fields | ||
} | ||
@@ -86,3 +83,3 @@ return; | ||
let initialValue = undefined; | ||
return { | ||
const newValue = { | ||
init: function (initialVal) { | ||
@@ -104,2 +101,4 @@ initialValue = initialVal; | ||
}; | ||
isSignalGetter.add(newValue.get); | ||
return newValue; | ||
} else if (kind === 'getter' || kind === 'setter') { | ||
@@ -122,6 +121,8 @@ const getOrSet = value; | ||
pairs[name]++; | ||
return function () { | ||
const newGetter = function () { | ||
__getSignal(this, signalStorage, initialValue)(); | ||
return getOrSet.call(this); | ||
}; | ||
isSignalGetter.add(newGetter); | ||
return newGetter; | ||
} else { | ||
@@ -128,0 +129,0 @@ pairs[name] ??= 0; |
@@ -5,3 +5,3 @@ export * from './decorators/index.js'; | ||
export * from './signals/index.js'; | ||
export declare const version = "0.4.2"; | ||
export declare const version = "0.4.3"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -5,3 +5,3 @@ export * from './decorators/index.js'; | ||
export * from './signals/index.js'; | ||
export const version = '0.4.2'; | ||
export const version = '0.4.3'; | ||
//# sourceMappingURL=index.js.map |
@@ -56,4 +56,5 @@ import { type SignalFunction } from './createSignalFunction.js'; | ||
export declare function __trackPropSetAtLeastOnce(instance: object, prop: string | symbol): void; | ||
export declare const isSignalGetter: WeakSet<Function>; | ||
export declare function __createSignalAccessor<T extends object>(obj: T, prop: Exclude<keyof T, number>, initialVal: unknown): void; | ||
export declare function __getSignal(obj: object, storage: WeakMap<object, SignalFunction<unknown>>, initialVal: unknown): SignalFunction<unknown>; | ||
//# sourceMappingURL=signalify.d.ts.map |
@@ -89,3 +89,3 @@ import { getInheritedDescriptor } from 'lowclass/dist/getInheritedDescriptor.js'; | ||
} | ||
const isSignalGetter = new WeakSet(); | ||
export const isSignalGetter = new WeakSet(); | ||
export function __createSignalAccessor(obj, prop, initialVal) { | ||
@@ -92,0 +92,0 @@ let descriptor = getInheritedDescriptor(obj, prop); |
{ | ||
"name": "classy-solid", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"description": "Solid.js reactivity patterns for classes, and class components.", | ||
@@ -44,3 +44,3 @@ "info": "The `classy-solid` package gives you a `@signal` decorator to make reactive class properties, an `@component` decorator to use classes as Solid components, and some other APIs to simplify usage of reactive patterns in classes. It is still early, more features and changes to come!", | ||
"devDependencies": { | ||
"@lume/cli": "^0.13.0", | ||
"@lume/cli": "^0.14.0", | ||
"five-server": "^0.3.1", | ||
@@ -47,0 +47,0 @@ "prettier": "3.0.3", |
import {$PROXY} from 'solid-js' | ||
import {__getSignal, __trackPropSetAtLeastOnce, __createSignalAccessor} from '../signals/signalify.js' | ||
import {__getSignal, __trackPropSetAtLeastOnce, __createSignalAccessor, isSignalGetter} from '../signals/signalify.js' | ||
import type {PropKey, PropSpec} from './types.js' | ||
@@ -80,8 +80,5 @@ import type {SignalFunction} from '../signals/createSignalFunction.js' | ||
// @prod-prune | ||
if (!Object.hasOwn(this, prop)) | ||
// continue | ||
throw new PropNotFoundError(prop) | ||
if (!Object.hasOwn(this, prop)) throw new PropNotFoundError(prop) | ||
__createSignalAccessor(this as any, prop, initialValue) | ||
// CONTINUE testing this way of finalizing signal fields | ||
} | ||
@@ -99,3 +96,3 @@ return | ||
return { | ||
const newValue = { | ||
init: function (this: object, initialVal: unknown) { | ||
@@ -117,2 +114,6 @@ initialValue = initialVal | ||
} | ||
isSignalGetter.add(newValue.get) | ||
return newValue | ||
} else if (kind === 'getter' || kind === 'setter') { | ||
@@ -140,6 +141,10 @@ const getOrSet = value as Function | ||
return function (this: object): unknown { | ||
const newGetter = function (this: object): unknown { | ||
__getSignal(this, signalStorage, initialValue)() | ||
return getOrSet.call(this) | ||
} | ||
isSignalGetter.add(newGetter) | ||
return newGetter | ||
} else { | ||
@@ -146,0 +151,0 @@ pairs[name] ??= 0 |
@@ -6,2 +6,2 @@ export * from './decorators/index.js' | ||
export const version = '0.4.2' | ||
export const version = '0.4.3' |
@@ -99,3 +99,3 @@ import {getInheritedDescriptor} from 'lowclass/dist/getInheritedDescriptor.js' | ||
const isSignalGetter = new WeakSet<Function>() | ||
export const isSignalGetter = new WeakSet<Function>() | ||
@@ -102,0 +102,0 @@ export function __createSignalAccessor<T extends object>( |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
181120
2573