@domyjs/reactive 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +240 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +30 -0
package/dist/index.d.ts
ADDED
@@ -0,0 +1,240 @@
|
|
1
|
+
/* eslint @typescript-eslint/no-this-alias: "off" */
|
2
|
+
type Listener = OnGetListener | OnSetListener;
|
3
|
+
type OnGetListener = {
|
4
|
+
type: "onGet";
|
5
|
+
fn: (props: {
|
6
|
+
reactiveVariable: ReactiveVariable;
|
7
|
+
path: string;
|
8
|
+
}) => void;
|
9
|
+
};
|
10
|
+
type OnSetListener = {
|
11
|
+
type: "onSet";
|
12
|
+
fn: (props: {
|
13
|
+
reactiveVariable: ReactiveVariable;
|
14
|
+
path: string;
|
15
|
+
prevValue: any;
|
16
|
+
newValue: any;
|
17
|
+
}) => void | Promise<void>;
|
18
|
+
};
|
19
|
+
/**
|
20
|
+
* Allow to create a DeepProxy to listen to any change into an object
|
21
|
+
* @author yoannchb-pro
|
22
|
+
*/
|
23
|
+
declare class ReactiveVariable {
|
24
|
+
private target;
|
25
|
+
name: string;
|
26
|
+
private proxy;
|
27
|
+
private onSetListeners;
|
28
|
+
private onGetListeners;
|
29
|
+
static IS_GLOBAL_LOCK: boolean;
|
30
|
+
constructor(target: any);
|
31
|
+
getProxy(): any;
|
32
|
+
/**
|
33
|
+
* Check if the current target is already a proxy
|
34
|
+
* @param target
|
35
|
+
* @returns
|
36
|
+
*/
|
37
|
+
static isReactive(target: any): boolean;
|
38
|
+
/**
|
39
|
+
* Check if the current target is a signal instead of a reactive
|
40
|
+
* @param target
|
41
|
+
* @returns
|
42
|
+
*/
|
43
|
+
static isSignal(target: any): boolean;
|
44
|
+
/**
|
45
|
+
* Check we should skip the reactivity on the current element
|
46
|
+
* @param target
|
47
|
+
* @returns
|
48
|
+
*/
|
49
|
+
static shouldBeSkip(target: any): boolean;
|
50
|
+
clearListeners(): void;
|
51
|
+
attachListener(l: Listener): () => void;
|
52
|
+
removeListener(l: Listener): void;
|
53
|
+
private canAttachProxy;
|
54
|
+
private isCollection;
|
55
|
+
private createCollectionHandler;
|
56
|
+
private createHandler;
|
57
|
+
private createProxy;
|
58
|
+
private callOnGetListeners;
|
59
|
+
private callOnSetListeners;
|
60
|
+
}
|
61
|
+
/**
|
62
|
+
* Attach a listener to all reactive variables
|
63
|
+
* @param listener
|
64
|
+
*
|
65
|
+
* @author yoannchb-pro
|
66
|
+
*/
|
67
|
+
declare function globalWatch(listener: Listener, tracking?: boolean): () => void;
|
68
|
+
/**
|
69
|
+
* Will return true if a obj is a signal/reactive
|
70
|
+
* @param obj
|
71
|
+
* @returns
|
72
|
+
*
|
73
|
+
* @author yoannchb-pro
|
74
|
+
*/
|
75
|
+
declare function isReactive(obj: any): boolean;
|
76
|
+
/**
|
77
|
+
* Will return true if the obj is a signal
|
78
|
+
* @param obj
|
79
|
+
* @returns
|
80
|
+
*
|
81
|
+
* @author yoannchb-pro
|
82
|
+
*/
|
83
|
+
declare function isSignal(obj: any): boolean;
|
84
|
+
type MatchingResult = {
|
85
|
+
isMatching: boolean;
|
86
|
+
params: Record<string, string>;
|
87
|
+
};
|
88
|
+
/**
|
89
|
+
* Check if a path match a certain rule
|
90
|
+
* Example:
|
91
|
+
* path: todos.0.isComplete
|
92
|
+
* reg: todos.*.isComplete or todos, todos.* or todos.*.*
|
93
|
+
* Will give true
|
94
|
+
* reg: todos.1.isComplete, todos.*.name, todos.*.*.id
|
95
|
+
* Will give false
|
96
|
+
* @param reg
|
97
|
+
* @param path
|
98
|
+
* @returns
|
99
|
+
*
|
100
|
+
* @author yoannchb-pro
|
101
|
+
*/
|
102
|
+
declare function matchPath(reg: string, path: string): MatchingResult;
|
103
|
+
/**
|
104
|
+
* Transform an object into a reactive object to listen to any change
|
105
|
+
* @param obj
|
106
|
+
* @returns
|
107
|
+
*
|
108
|
+
* @author yoannchb-pro
|
109
|
+
*/
|
110
|
+
declare function reactive<T>(obj: T): T;
|
111
|
+
/**
|
112
|
+
* Register a name for a reactive variable
|
113
|
+
* It allow us to have a correct path name
|
114
|
+
* Example of use case:
|
115
|
+
* cont count = signal(0);
|
116
|
+
* watch(({ path }) => console.log(path), [count]);
|
117
|
+
* count.value += 1;
|
118
|
+
*
|
119
|
+
* The path is going to be "value" instead of "count.value" because we don't know the variable name
|
120
|
+
* So to fixe that we just need to put registerName("count", count) after the variable declaration
|
121
|
+
* @param name
|
122
|
+
* @param obj
|
123
|
+
* @returns
|
124
|
+
*
|
125
|
+
* @author yoannchb-pro
|
126
|
+
*/
|
127
|
+
declare function registerName(name: string, obj: any): void;
|
128
|
+
/**
|
129
|
+
* Transform a primitive into a reactive object to listen to any change
|
130
|
+
* @param obj
|
131
|
+
* @returns
|
132
|
+
*
|
133
|
+
* @author yoannchb-pro
|
134
|
+
*/
|
135
|
+
declare function signal<T>(obj: T): {
|
136
|
+
value: T;
|
137
|
+
};
|
138
|
+
/**
|
139
|
+
* Attach a listener to some reactives variables
|
140
|
+
* @param listener
|
141
|
+
* @param effect
|
142
|
+
*
|
143
|
+
* @author yoannchb-pro
|
144
|
+
*/
|
145
|
+
declare function watch(listener: Listener, effect: () => any): () => void;
|
146
|
+
/**
|
147
|
+
* Allow us to lock every watcher if we need to do a set/get action on the object without calling the watcher
|
148
|
+
*
|
149
|
+
* @author yoannchb-pro
|
150
|
+
*/
|
151
|
+
declare function lockWatchers(): void;
|
152
|
+
/**
|
153
|
+
* Unlock every watchers
|
154
|
+
*
|
155
|
+
* @author yoannchb-pro
|
156
|
+
*/
|
157
|
+
declare function unlockWatchers(): void;
|
158
|
+
/**
|
159
|
+
* Will delete the reactivity of a data
|
160
|
+
* @param obj
|
161
|
+
* @returns
|
162
|
+
*
|
163
|
+
* @author yoannchb-pro
|
164
|
+
*/
|
165
|
+
declare function unReactive<T = any>(obj: T): T;
|
166
|
+
/**
|
167
|
+
* Skip the reactivity on an element we don't wanna listen to in a reactivity variable
|
168
|
+
* Example:
|
169
|
+
* const myElement = reactive({ el: skipReactive({ ... }), name: 'div' })
|
170
|
+
* @param obj
|
171
|
+
* @returns
|
172
|
+
*
|
173
|
+
* @author yoannchb-pro
|
174
|
+
*/
|
175
|
+
declare function skipReactive<T = any>(obj: T): T;
|
176
|
+
type Effect = () => any;
|
177
|
+
type UnEffect = () => void;
|
178
|
+
type WatchEffectOptions = {
|
179
|
+
noSelfUpdate?: boolean; // Avoid the effect to launch the function again
|
180
|
+
onDepChange?: (uneffect: UnEffect) => void;
|
181
|
+
};
|
182
|
+
/**
|
183
|
+
* Act like a watcher but get his dependencies it self by running one time the instance
|
184
|
+
* Example:
|
185
|
+
* const todo = reactive({ title: "Yoann", isCompleted: false });
|
186
|
+
* const uneffect = watchEffect(() => console.log(todo.title)); // Will display: "Yoann" when initialising
|
187
|
+
* todo.isCompleted = true; // Don't call the effect
|
188
|
+
* todo.title = "Pierre"; // Will call the effect and display "Pierre"
|
189
|
+
* @param effectFn
|
190
|
+
*
|
191
|
+
* @author yoannchb-pro
|
192
|
+
*/
|
193
|
+
declare function watchEffect(effect: Effect, opts?: WatchEffectOptions): UnEffect;
|
194
|
+
type Dep = {
|
195
|
+
type: "reactive_variable_creation";
|
196
|
+
reactiveVariable: ReactiveVariable;
|
197
|
+
clean: () => void;
|
198
|
+
} | {
|
199
|
+
type: "watcher" | "effect" | "global_watcher";
|
200
|
+
clean: () => void;
|
201
|
+
};
|
202
|
+
/**
|
203
|
+
* Allow us to track inside a function:
|
204
|
+
* - reactive variable (signal + reactive)
|
205
|
+
* - watcher
|
206
|
+
* - effects
|
207
|
+
* - global watchers
|
208
|
+
* @param fn
|
209
|
+
* @returns
|
210
|
+
*
|
211
|
+
* @author yoannchb-pro
|
212
|
+
*/
|
213
|
+
declare function trackDeps(fn: () => any): Dep[];
|
214
|
+
declare const isComputedSymbol: unique symbol;
|
215
|
+
/**
|
216
|
+
* Will return a boolean determining if an object is a computed value or not
|
217
|
+
* @param obj
|
218
|
+
* @returns
|
219
|
+
*
|
220
|
+
* @author yoannchb-pro
|
221
|
+
*/
|
222
|
+
declare function isComputed(obj: any): boolean;
|
223
|
+
/**
|
224
|
+
* Create a computed variable based on a signal
|
225
|
+
* Example:
|
226
|
+
* const count = signal(1);
|
227
|
+
* const doubleCount = computed(() => count.value * 2);
|
228
|
+
* console.log(doubleCount); // 2
|
229
|
+
* @param getter
|
230
|
+
* @param setter
|
231
|
+
* @returns
|
232
|
+
*
|
233
|
+
* @author yoannchb-pro
|
234
|
+
*/
|
235
|
+
declare function computed<T extends () => unknown, R extends ReturnType<T>>(getter: () => R, setter?: (newValue: R) => void): {
|
236
|
+
[isComputedSymbol]: boolean;
|
237
|
+
value: R;
|
238
|
+
};
|
239
|
+
|
240
|
+
export { computed, globalWatch, isComputed, isReactive, isSignal, lockWatchers, matchPath, reactive, registerName, signal, skipReactive, trackDeps, unReactive, unlockWatchers, watch, watchEffect };
|
package/dist/index.js
ADDED
@@ -0,0 +1,2 @@
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).reactive={})}(this,function(e){"use strict";const t=new Map,n=new Set;let r=null;function i(e,t=!0){n.add(e);const i=()=>function(e){n.has(e)&&n.delete(e)}(e);return r&&t&&r({type:"global_watcher",clean:i}),i}const s=Symbol(),o=Symbol(),a=Symbol();class c{constructor(e){this.target=e,this.name="",this.proxy=null,this.onSetListeners=new Set,this.onGetListeners=new Set}getProxy(){return this.proxy||(this.proxy=this.createProxy(this.target)),this.proxy}static isReactive(e){return!!(null==e?void 0:e[s])}static isSignal(e){return(null==e?void 0:e[o])&&"value"in e}static shouldBeSkip(e){return null==e?void 0:e[a]}clearListeners(){this.onGetListeners.clear(),this.onSetListeners.clear()}attachListener(e){return("onGet"===e.type?this.onGetListeners:this.onSetListeners).add(e.fn),()=>this.removeListener(e)}removeListener(e){("onGet"===e.type?this.onGetListeners:this.onSetListeners).delete(e.fn)}canAttachProxy(e){return null!==e&&"object"==typeof e&&!c.isReactive(e)&&!c.shouldBeSkip(e)}isCollection(e){return e instanceof Set||e instanceof WeakMap||e instanceof WeakSet||e instanceof Map}createCollectionHandler(e){const t=this;return{get(n,r,i){if("symbol"==typeof r)return Reflect.get(n,r,i);const s=Reflect.get(n,r,i),o=[...e,r];return"function"==typeof s?function(...i){let a,l;switch(r){case"add":n instanceof Set&&(a=new Set(n),l=new Set(n).add(i[0]));break;case"set":n instanceof Map&&(a=new Map(n),l=new Map(n).set(i[0],i[1]));break;case"delete":n instanceof Set?(a=new Set(n),l=new Set(n),l.delete(i[0])):n instanceof Map&&(a=new Map(n),l=new Map(n),l.delete(i[0]));break;case"clear":(n instanceof Set||n instanceof Map)&&(a=n instanceof Set?new Set(n):new Map(n),l=n instanceof Set?new Set:new Map)}const f=["add","set"].includes(r),u=i[i.length-1];f&&!c.isReactive(u)&&(i[i.length-1]=t.createProxy(u,o));const h=s.apply(n,i);return["add","set","delete","clear"].includes(r)&&t.callOnSetListeners(e,a,l),h}:(t.callOnGetListeners(o),s)}}}createHandler(e){const t=this;return{get(n,r,i){if("symbol"==typeof r)return Reflect.get(n,r,i);let s=Reflect.get(n,r,i);const o=[...e,r];return c.isReactive(s)||(s=t.createProxy(s,o),Reflect.set(n,r,s)),t.callOnGetListeners(o),s},set(n,r,i,s){if("symbol"==typeof r)return Reflect.set(n,r,i,s);const o=Reflect.get(n,r,s),a=[...e,r],c=Reflect.set(n,r,i,s);return c&&!(o===i)&&t.callOnSetListeners(a,o,i),c},deleteProperty(n,r){if("symbol"==typeof r)return Reflect.deleteProperty(n,r);const i=n[r],s=[...e,r],o=Reflect.deleteProperty(n,r);return o&&t.callOnSetListeners(s,i,void 0),o},has(n,r){const i=Reflect.has(n,r),s=[...e,r];return t.callOnGetListeners(s),i},ownKeys(n){const r=Reflect.ownKeys(n);return t.callOnGetListeners([...e]),r}}}createProxy(e,t=[]){if(!this.canAttachProxy(e))return e;const n=this.isCollection(e);return Object.defineProperty(e,s,{enumerable:!1,writable:!0,value:!0,configurable:!0}),new Proxy(e,n?this.createCollectionHandler(t):this.createHandler(t))}callOnGetListeners(e){if(c.IS_GLOBAL_LOCK)return;const t={path:this.name+e.join("."),reactiveVariable:this};for(const e of[...this.onGetListeners])e(t)}callOnSetListeners(e,t,n){if(c.IS_GLOBAL_LOCK)return;const r={path:this.name+e.join("."),prevValue:t,newValue:n,reactiveVariable:this};for(const e of[...this.onSetListeners])e(r)}}function l(e){return c.isReactive(e)}function f(e,t){const n={isMatching:!1,params:{}},r=e.split("."),i=t.split("."),s="length"===i[i.length-1],o={};for(let e=0;e<r.length;++e){if(!t[e])return n;const a=r[e].match(/\{\w+\}/);if("*"===r[e]||a){if(a){const t=a[0];o[t.substring(1,t.length-1)]=i[e]}}else if((e!==i.length-1||!s||isNaN(Number(r[e])))&&i[e]!==r[e])return n}return{isMatching:!0,params:o}}function u(e){if(!c.isReactive(e))return e;const n=t.get(e);return n?(n.clearListeners(),t.delete(e),e):e}function h(e){if(c.isReactive(e))return e;const i=new c(e),s=i.getProxy();function o(e){return t=>{for(const r of n)if(r.type===e)try{r.fn(t)}catch(e){console.error(e)}}}return t.set(s,i),i.attachListener({type:"onGet",fn:o("onGet")}),i.attachListener({type:"onSet",fn:o("onSet")}),r&&r({type:"reactive_variable_creation",reactiveVariable:i,clean:()=>u(i)}),s}c.IS_GLOBAL_LOCK=!1;let p=0;const y=Symbol();e.computed=function(e,t){return{[y]:!0,get value(){return e()},set value(e){if(!t)throw new Error('You are trying to modify the "value" property of a computed, but this computed have no setter setuped.');t(e)}}},e.globalWatch=i,e.isComputed=function(e){return!!(null==e?void 0:e[y])},e.isReactive=l,e.isSignal=function(e){return c.isSignal(e)},e.lockWatchers=function(){c.IS_GLOBAL_LOCK=!0},e.matchPath=f,e.reactive=h,e.registerName=function(e,n){for(const r of t.values())if(r.getProxy()===n)return void(r.name=e+".")},e.signal=function(e){const t={value:e};return Object.defineProperty(t,o,{enumerable:!1,writable:!1,value:!0,configurable:!0}),h(t)},e.skipReactive=function(e){return Object.defineProperty(e,a,{enumerable:!1,writable:!1,value:!0,configurable:!0}),e},e.trackDeps=function(e){const t=[];return r=e=>t.push(e),e(),r=null,t},e.unReactive=u,e.unlockWatchers=function(){c.IS_GLOBAL_LOCK=!1},e.watch=function(e,n){const s=[];function o(t,n){const r={type:e.type,fn:t=>{if(!n)return e.fn(t);f(n,t.path).isMatching&&e.fn(t)}},i=t.attachListener(r);s.push(i)}const a=i({type:"onGet",fn:({path:e,reactiveVariable:t})=>o(t,e)},!1),c=n();if(a(),Array.isArray(c)&&!l(c)){for(const e of c)if(l(e)){const n=t.get(e);n&&o(n)}}else if(l(c)){const e=t.get(c);e&&o(e)}const u=()=>{for(const e of s)e()};return r&&r({type:"watcher",clean:u}),u},e.watchEffect=function(e,t={}){++p;const n=new Set;function s(){for(const e of n)e();n.clear()}return function r(){s();const o=p,a=new Map;let c=!1;const l=i({type:"onGet",fn:({path:e,reactiveVariable:i})=>{if(o!==p)return;const l={type:"onSet",fn:n=>{if(c)return;f(n.path,e).isMatching&&(c=!0,t.onDepChange&&t.onDepChange(s),t.noSelfUpdate||r())}},u=a.get(i)||new Set;if(u.has(e))return;u.add(e),a.set(i,u);n.add(()=>i.removeListener(l)),i.attachListener(l)}},!1);try{e(),--p}finally{l()}}(),r&&r({type:"effect",clean:s}),s}});
|
2
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/core/data.ts","../src/core/trackDeps.ts","../src/core/globalWatch.ts","../src/core/ReactiveVariable.ts","../src/core/isReactive.ts","../src/core/matchPath.ts","../src/core/unReactive.ts","../src/core/reactive.ts","../src/core/watchEffect.ts","../src/core/computed.ts","../src/core/isSignal.ts","../src/core/lockWatchers.ts","../src/core/registerName.ts","../src/core/signal.ts","../src/core/skipReactivity.ts","../src/core/unlockWatchers.ts","../src/core/watch.ts"],"sourcesContent":["import type { Listener, ReactiveVariable } from './ReactiveVariable';\r\n\r\nexport const reactivesVariablesList = new Map<any, ReactiveVariable>();\r\nexport const globalListenersList = new Set<Listener>();\r\n","import { ReactiveVariable } from './ReactiveVariable';\r\n\r\ntype Dep =\r\n | {\r\n type: 'reactive_variable_creation';\r\n reactiveVariable: ReactiveVariable;\r\n clean: () => void;\r\n }\r\n | {\r\n type: 'watcher' | 'effect' | 'global_watcher';\r\n clean: () => void;\r\n };\r\n\r\nexport let trackCallback: ((dep: Dep) => void) | null = null;\r\n\r\n/**\r\n * Allow us to track inside a function:\r\n * - reactive variable (signal + reactive)\r\n * - watcher\r\n * - effects\r\n * - global watchers\r\n * @param fn\r\n * @returns\r\n *\r\n * @author yoannchb-pro\r\n */\r\nexport function trackDeps(fn: () => any): Dep[] {\r\n const deps: Dep[] = [];\r\n\r\n trackCallback = (dep: Dep) => deps.push(dep);\r\n\r\n // we execute the function so track deps\r\n fn();\r\n\r\n trackCallback = null;\r\n\r\n return deps;\r\n}\r\n","import { globalListenersList } from './data';\r\nimport { Listener } from './ReactiveVariable';\r\nimport { trackCallback } from './trackDeps';\r\n\r\n/**\r\n * Remove a global listener\r\n * @param listener\r\n *\r\n * @author yoannchb-pro\r\n */\r\nfunction removeGlobalWatch(listener: Listener) {\r\n if (globalListenersList.has(listener)) globalListenersList.delete(listener);\r\n}\r\n\r\n/**\r\n * Attach a listener to all reactive variables\r\n * @param listener\r\n *\r\n * @author yoannchb-pro\r\n */\r\nexport function globalWatch(listener: Listener, tracking = true) {\r\n globalListenersList.add(listener);\r\n const clean = () => removeGlobalWatch(listener);\r\n\r\n // Tracking global watch\r\n if (trackCallback && tracking) trackCallback({ type: 'global_watcher', clean });\r\n\r\n return clean;\r\n}\r\n","/* eslint @typescript-eslint/no-this-alias: \"off\" */\r\nexport type Listener = OnGetListener | OnSetListener;\r\nexport type OnGetListener = {\r\n type: 'onGet';\r\n fn: (props: { reactiveVariable: ReactiveVariable; path: string }) => void;\r\n};\r\nexport type OnSetListener = {\r\n type: 'onSet';\r\n fn: (props: {\r\n reactiveVariable: ReactiveVariable;\r\n path: string;\r\n prevValue: any;\r\n newValue: any;\r\n }) => void | Promise<void>;\r\n};\r\n\r\nexport const isProxySymbol = Symbol();\r\nexport const isSignalSymbol = Symbol();\r\nexport const skipReactivitySymbol = Symbol();\r\n\r\n/**\r\n * Allow to create a DeepProxy to listen to any change into an object\r\n * @author yoannchb-pro\r\n */\r\nexport class ReactiveVariable {\r\n public name = '';\r\n private proxy: any = null;\r\n\r\n private onSetListeners = new Set<OnSetListener['fn']>();\r\n private onGetListeners = new Set<OnGetListener['fn']>();\r\n\r\n public static IS_GLOBAL_LOCK = false;\r\n\r\n constructor(private target: any) {}\r\n\r\n public getProxy() {\r\n if (!this.proxy) this.proxy = this.createProxy(this.target);\r\n return this.proxy;\r\n }\r\n\r\n /**\r\n * Check if the current target is already a proxy\r\n * @param target\r\n * @returns\r\n */\r\n public static isReactive(target: any): boolean {\r\n return !!target?.[isProxySymbol];\r\n }\r\n\r\n /**\r\n * Check if the current target is a signal instead of a reactive\r\n * @param target\r\n * @returns\r\n */\r\n public static isSignal(target: any): boolean {\r\n return target?.[isSignalSymbol] && 'value' in target;\r\n }\r\n\r\n /**\r\n * Check we should skip the reactivity on the current element\r\n * @param target\r\n * @returns\r\n */\r\n public static shouldBeSkip(target: any): boolean {\r\n return target?.[skipReactivitySymbol];\r\n }\r\n\r\n public clearListeners() {\r\n this.onGetListeners.clear();\r\n this.onSetListeners.clear();\r\n }\r\n\r\n public attachListener(l: Listener) {\r\n const listeners = l.type === 'onGet' ? this.onGetListeners : this.onSetListeners;\r\n listeners.add(l.fn);\r\n return () => this.removeListener(l);\r\n }\r\n\r\n public removeListener(l: Listener) {\r\n const listeners = l.type === 'onGet' ? this.onGetListeners : this.onSetListeners;\r\n listeners.delete(l.fn);\r\n }\r\n\r\n private canAttachProxy(target: any) {\r\n return (\r\n target !== null &&\r\n typeof target === 'object' &&\r\n !ReactiveVariable.isReactive(target) &&\r\n !ReactiveVariable.shouldBeSkip(target)\r\n );\r\n }\r\n\r\n private isCollection(target: any) {\r\n return (\r\n target instanceof Set ||\r\n target instanceof WeakMap ||\r\n target instanceof WeakSet ||\r\n target instanceof Map\r\n );\r\n }\r\n\r\n private createCollectionHandler(path: string[]) {\r\n const ctx = this;\r\n const collectionHandler: ProxyHandler<any> = {\r\n get(target, property, receiver) {\r\n if (typeof property === 'symbol') {\r\n return Reflect.get(target, property, receiver);\r\n }\r\n\r\n const value = Reflect.get(target, property, receiver);\r\n const fullPath = [...path, property as string];\r\n\r\n if (typeof value === 'function') {\r\n return function (...args: any[]) {\r\n let prevValue, newValue;\r\n\r\n switch (property) {\r\n case 'add':\r\n if (target instanceof Set) {\r\n prevValue = new Set(target);\r\n newValue = new Set(target).add(args[0]);\r\n }\r\n break;\r\n case 'set':\r\n if (target instanceof Map) {\r\n prevValue = new Map(target);\r\n newValue = new Map(target).set(args[0], args[1]);\r\n }\r\n break;\r\n case 'delete':\r\n if (target instanceof Set) {\r\n prevValue = new Set(target);\r\n newValue = new Set(target);\r\n newValue.delete(args[0]);\r\n } else if (target instanceof Map) {\r\n prevValue = new Map(target);\r\n newValue = new Map(target);\r\n newValue.delete(args[0]);\r\n }\r\n break;\r\n case 'clear':\r\n if (target instanceof Set || target instanceof Map) {\r\n prevValue = target instanceof Set ? new Set(target) : new Map(target);\r\n newValue = target instanceof Set ? new Set() : new Map();\r\n }\r\n break;\r\n }\r\n\r\n // If the new value is not a proxy we declare a proxy for it\r\n const isNewObj = ['add', 'set'].includes(property as string);\r\n const obj = args[args.length - 1]; // In case of a set(key, obj) and add(obj)\r\n if (isNewObj && !ReactiveVariable.isReactive(obj)) {\r\n args[args.length - 1] = ctx.createProxy(obj, fullPath);\r\n }\r\n\r\n const result = value.apply(target, args);\r\n\r\n if (['add', 'set', 'delete', 'clear'].includes(property as string)) {\r\n ctx.callOnSetListeners(path, prevValue, newValue);\r\n }\r\n\r\n return result;\r\n };\r\n } else {\r\n ctx.callOnGetListeners(fullPath);\r\n return value;\r\n }\r\n }\r\n };\r\n return collectionHandler;\r\n }\r\n\r\n private createHandler(path: string[]) {\r\n const ctx = this;\r\n\r\n const handler: ProxyHandler<any> = {\r\n get(target, p, receiver) {\r\n if (typeof p === 'symbol') return Reflect.get(target, p, receiver);\r\n\r\n let value = Reflect.get(target, p, receiver);\r\n const fullPath = [...path, p as string];\r\n\r\n // Ensure the needed variable is reactive\r\n if (!ReactiveVariable.isReactive(value)) {\r\n value = ctx.createProxy(value, fullPath);\r\n Reflect.set(target, p, value);\r\n }\r\n\r\n ctx.callOnGetListeners(fullPath);\r\n return value;\r\n },\r\n\r\n set(target, p, newValue, receiver) {\r\n if (typeof p === 'symbol') return Reflect.set(target, p, newValue, receiver);\r\n\r\n const prevValue = Reflect.get(target, p, receiver);\r\n const fullPath = [...path, p as string];\r\n const result = Reflect.set(target, p, newValue, receiver);\r\n\r\n const isSameValue = prevValue === newValue;\r\n if (result && !isSameValue) ctx.callOnSetListeners(fullPath, prevValue, newValue);\r\n\r\n return result;\r\n },\r\n\r\n deleteProperty(target, p) {\r\n if (typeof p === 'symbol') return Reflect.deleteProperty(target, p);\r\n\r\n const prevValue = target[p];\r\n const fullPath = [...path, p as string];\r\n\r\n const result = Reflect.deleteProperty(target, p);\r\n if (result) ctx.callOnSetListeners(fullPath, prevValue, undefined);\r\n\r\n return result;\r\n },\r\n\r\n has(target, p) {\r\n const exists = Reflect.has(target, p);\r\n const fullPath = [...path, p as string];\r\n ctx.callOnGetListeners(fullPath);\r\n return exists;\r\n },\r\n\r\n ownKeys(target) {\r\n const keys = Reflect.ownKeys(target);\r\n ctx.callOnGetListeners([...path]);\r\n return keys;\r\n }\r\n };\r\n return handler;\r\n }\r\n\r\n private createProxy(target: any, path: string[] = []): any {\r\n if (!this.canAttachProxy(target)) return target;\r\n\r\n const isCollection = this.isCollection(target);\r\n\r\n Object.defineProperty(target, isProxySymbol, {\r\n enumerable: false,\r\n writable: true,\r\n value: true,\r\n configurable: true\r\n });\r\n\r\n return new Proxy(\r\n target,\r\n isCollection ? this.createCollectionHandler(path) : this.createHandler(path)\r\n );\r\n }\r\n\r\n private callOnGetListeners(path: string[]) {\r\n if (ReactiveVariable.IS_GLOBAL_LOCK) return;\r\n\r\n const params = {\r\n path: this.name + path.join('.'),\r\n reactiveVariable: this\r\n };\r\n\r\n for (const listener of [...this.onGetListeners]) {\r\n listener(params);\r\n }\r\n }\r\n\r\n private callOnSetListeners(path: string[], prevValue: any, newValue: any) {\r\n if (ReactiveVariable.IS_GLOBAL_LOCK) return;\r\n\r\n const params = {\r\n path: this.name + path.join('.'),\r\n prevValue,\r\n newValue,\r\n reactiveVariable: this\r\n };\r\n\r\n for (const listener of [...this.onSetListeners]) {\r\n listener(params);\r\n }\r\n }\r\n}\r\n","import { ReactiveVariable } from './ReactiveVariable';\r\n\r\n/**\r\n * Will return true if a obj is a signal/reactive\r\n * @param obj\r\n * @returns\r\n *\r\n * @author yoannchb-pro\r\n */\r\nexport function isReactive(obj: any) {\r\n return ReactiveVariable.isReactive(obj);\r\n}\r\n","type MatchingResult = { isMatching: boolean; params: Record<string, string> };\r\n\r\n/**\r\n * Check if a path match a certain rule\r\n * Example:\r\n * path: todos.0.isComplete\r\n * reg: todos.*.isComplete or todos, todos.* or todos.*.*\r\n * Will give true\r\n * reg: todos.1.isComplete, todos.*.name, todos.*.*.id\r\n * Will give false\r\n * @param reg\r\n * @param path\r\n * @returns\r\n *\r\n * @author yoannchb-pro\r\n */\r\nexport function matchPath(reg: string, path: string): MatchingResult {\r\n const defaultRes: MatchingResult = {\r\n isMatching: false,\r\n params: {}\r\n };\r\n\r\n const rules = reg.split('.');\r\n const paths = path.split('.');\r\n\r\n const isArrayLength = paths[paths.length - 1] === 'length';\r\n\r\n const params: Record<string, string> = {};\r\n\r\n for (let i = 0; i < rules.length; ++i) {\r\n if (!path[i]) return defaultRes;\r\n\r\n const isParam = rules[i].match(/\\{\\w+\\}/);\r\n if (rules[i] === '*' || isParam) {\r\n if (isParam) {\r\n const paramName = isParam[0];\r\n params[paramName.substring(1, paramName.length - 1)] = paths[i];\r\n }\r\n continue;\r\n }\r\n\r\n // We handle the case it's an array\r\n // For exemple we want value.0 to match value.length\r\n if (i === paths.length - 1 && isArrayLength && !isNaN(Number(rules[i]))) continue;\r\n\r\n if (paths[i] !== rules[i]) return defaultRes;\r\n }\r\n\r\n return { isMatching: true, params };\r\n}\r\n","import { reactivesVariablesList } from './data';\r\nimport { ReactiveVariable } from './ReactiveVariable';\r\n\r\n/**\r\n * Will delete the reactivity of a data\r\n * @param obj\r\n * @returns\r\n *\r\n * @author yoannchb-pro\r\n */\r\nexport function unReactive<T = any>(obj: T): T {\r\n if (!ReactiveVariable.isReactive(obj)) return obj;\r\n\r\n const reactiveInstance = reactivesVariablesList.get(obj);\r\n\r\n if (!reactiveInstance) return obj;\r\n\r\n reactiveInstance.clearListeners();\r\n reactivesVariablesList.delete(obj);\r\n\r\n return obj;\r\n}\r\n","import { globalListenersList, reactivesVariablesList } from './data';\r\nimport { Listener, OnGetListener, OnSetListener, ReactiveVariable } from './ReactiveVariable';\r\nimport { trackCallback } from './trackDeps';\r\nimport { unReactive } from './unReactive';\r\n\r\ntype GetListenerByType<T> = T extends 'onGet' ? OnGetListener : OnSetListener;\r\n\r\n/**\r\n * Transform an object into a reactive object to listen to any change\r\n * @param obj\r\n * @returns\r\n *\r\n * @author yoannchb-pro\r\n */\r\nexport function reactive<T>(obj: T): T {\r\n if (ReactiveVariable.isReactive(obj)) return obj;\r\n\r\n const reactiveVariable = new ReactiveVariable(obj);\r\n const proxy = reactiveVariable.getProxy();\r\n reactivesVariablesList.set(proxy, reactiveVariable);\r\n\r\n // We attach the global listener\r\n function createGlobalListener<T extends Listener['type']>(type: T): GetListenerByType<T>['fn'] {\r\n return (props: any) => {\r\n for (const globalListener of globalListenersList) {\r\n if (globalListener.type !== type) continue;\r\n\r\n try {\r\n globalListener.fn(props);\r\n } catch (err) {\r\n console.error(err);\r\n }\r\n }\r\n };\r\n }\r\n\r\n reactiveVariable.attachListener({\r\n type: 'onGet',\r\n fn: createGlobalListener('onGet')\r\n });\r\n reactiveVariable.attachListener({\r\n type: 'onSet',\r\n fn: createGlobalListener('onSet')\r\n });\r\n\r\n // Tracking the reactive creation\r\n if (trackCallback)\r\n trackCallback({\r\n type: 'reactive_variable_creation',\r\n reactiveVariable,\r\n clean: () => unReactive(reactiveVariable)\r\n });\r\n\r\n return proxy;\r\n}\r\n","import { globalWatch } from './globalWatch';\r\nimport { matchPath } from './matchPath';\r\nimport { OnSetListener } from './ReactiveVariable';\r\nimport { trackCallback } from './trackDeps';\r\n\r\ntype Effect = () => any;\r\ntype UnEffect = () => void;\r\ntype WatchEffectOptions = {\r\n noSelfUpdate?: boolean; // Avoid the effect to launch the function again\r\n onDepChange?: (uneffect: UnEffect) => void;\r\n};\r\n\r\nlet watchEffectDepth = 0;\r\n\r\n/**\r\n * Act like a watcher but get his dependencies it self by running one time the instance\r\n * Example:\r\n * const todo = reactive({ title: \"Yoann\", isCompleted: false });\r\n * const uneffect = watchEffect(() => console.log(todo.title)); // Will display: \"Yoann\" when initialising\r\n * todo.isCompleted = true; // Don't call the effect\r\n * todo.title = \"Pierre\"; // Will call the effect and display \"Pierre\"\r\n * @param effectFn\r\n *\r\n * @author yoannchb-pro\r\n */\r\nexport function watchEffect(effect: Effect, opts: WatchEffectOptions = {}): UnEffect {\r\n ++watchEffectDepth;\r\n\r\n const removeListenersSet = new Set<() => void>();\r\n\r\n function clean() {\r\n for (const removeListener of removeListenersSet) {\r\n removeListener();\r\n }\r\n removeListenersSet.clear();\r\n }\r\n\r\n function watchDeps() {\r\n clean(); // We remove the last dependencies to listen to the new ones\r\n\r\n const currentWatchEffectDepth = watchEffectDepth;\r\n const dependencyMap = new Map<any, Set<string>>();\r\n\r\n let listenerAlreadyMatched = false;\r\n const removeGlobalWatch = globalWatch(\r\n {\r\n type: 'onGet',\r\n fn: ({ path, reactiveVariable }) => {\r\n // If the currentwatch effect depth is not the same then it mean we have an effect in an effect\r\n // In this case we don't want to listen to the effect child deps\r\n if (currentWatchEffectDepth !== watchEffectDepth) return;\r\n\r\n const listener: OnSetListener = {\r\n type: 'onSet',\r\n fn: toWatch => {\r\n if (listenerAlreadyMatched) return;\r\n\r\n const matcher = matchPath(toWatch.path, path);\r\n if (matcher.isMatching) {\r\n listenerAlreadyMatched = true;\r\n if (opts.onDepChange) opts.onDepChange(clean);\r\n if (!opts.noSelfUpdate) watchDeps();\r\n }\r\n }\r\n };\r\n\r\n // We check the dep is not already registered\r\n const currentDeps = dependencyMap.get(reactiveVariable) || new Set<string>();\r\n if (currentDeps.has(path)) return;\r\n currentDeps.add(path);\r\n dependencyMap.set(reactiveVariable, currentDeps);\r\n\r\n // We attach the on set listener\r\n // We ensure we register the remove listener before adding it because attach listener car directly call the listener which can call clean\r\n const removeListener = () => reactiveVariable.removeListener(listener);\r\n removeListenersSet.add(removeListener);\r\n reactiveVariable.attachListener(listener);\r\n }\r\n },\r\n false\r\n );\r\n\r\n try {\r\n effect();\r\n --watchEffectDepth;\r\n } finally {\r\n removeGlobalWatch();\r\n }\r\n }\r\n\r\n watchDeps();\r\n\r\n if (trackCallback) trackCallback({ type: 'effect', clean });\r\n\r\n return clean;\r\n}\r\n","const isComputedSymbol = Symbol();\r\n\r\n/**\r\n * Will return a boolean determining if an object is a computed value or not\r\n * @param obj\r\n * @returns\r\n *\r\n * @author yoannchb-pro\r\n */\r\nexport function isComputed(obj: any) {\r\n return !!obj?.[isComputedSymbol];\r\n}\r\n\r\n/**\r\n * Create a computed variable based on a signal\r\n * Example:\r\n * const count = signal(1);\r\n * const doubleCount = computed(() => count.value * 2);\r\n * console.log(doubleCount); // 2\r\n * @param getter\r\n * @param setter\r\n * @returns\r\n *\r\n * @author yoannchb-pro\r\n */\r\nexport function computed<T extends () => unknown, R extends ReturnType<T>>(\r\n getter: () => R,\r\n setter?: (newValue: R) => void\r\n) {\r\n return {\r\n [isComputedSymbol]: true,\r\n get value(): R {\r\n return getter();\r\n },\r\n set value(newValue: R) {\r\n if (setter) setter(newValue);\r\n else\r\n throw new Error(\r\n 'You are trying to modify the \"value\" property of a computed, but this computed have no setter setuped.'\r\n );\r\n }\r\n };\r\n}\r\n","import { ReactiveVariable } from './ReactiveVariable';\r\n\r\n/**\r\n * Will return true if the obj is a signal\r\n * @param obj\r\n * @returns\r\n *\r\n * @author yoannchb-pro\r\n */\r\nexport function isSignal(obj: any) {\r\n return ReactiveVariable.isSignal(obj);\r\n}\r\n","import { ReactiveVariable } from './ReactiveVariable';\r\n\r\n/**\r\n * Allow us to lock every watcher if we need to do a set/get action on the object without calling the watcher\r\n *\r\n * @author yoannchb-pro\r\n */\r\nexport function lockWatchers() {\r\n ReactiveVariable.IS_GLOBAL_LOCK = true;\r\n}\r\n","import { reactivesVariablesList } from './data';\r\n\r\n/**\r\n * Register a name for a reactive variable\r\n * It allow us to have a correct path name\r\n * Example of use case:\r\n * cont count = signal(0);\r\n * watch(({ path }) => console.log(path), [count]);\r\n * count.value += 1;\r\n *\r\n * The path is going to be \"value\" instead of \"count.value\" because we don't know the variable name\r\n * So to fixe that we just need to put registerName(\"count\", count) after the variable declaration\r\n * @param name\r\n * @param obj\r\n * @returns\r\n *\r\n * @author yoannchb-pro\r\n */\r\nexport function registerName(name: string, obj: any) {\r\n for (const reactiveVariable of reactivesVariablesList.values()) {\r\n if (reactiveVariable.getProxy() === obj) {\r\n reactiveVariable.name = name + '.';\r\n return;\r\n }\r\n }\r\n}\r\n","import { reactive } from './reactive';\r\nimport { isSignalSymbol } from './ReactiveVariable';\r\n\r\n/**\r\n * Transform a primitive into a reactive object to listen to any change\r\n * @param obj\r\n * @returns\r\n *\r\n * @author yoannchb-pro\r\n */\r\nexport function signal<T>(obj: T): { value: T } {\r\n const sig = { value: obj };\r\n Object.defineProperty(sig, isSignalSymbol, {\r\n enumerable: false,\r\n writable: false,\r\n value: true,\r\n configurable: true\r\n });\r\n return reactive(sig);\r\n}\r\n","import { skipReactivitySymbol } from './ReactiveVariable';\r\n\r\n/**\r\n * Skip the reactivity on an element we don't wanna listen to in a reactivity variable\r\n * Example:\r\n * const myElement = reactive({ el: skipReactive({ ... }), name: 'div' })\r\n * @param obj\r\n * @returns\r\n *\r\n * @author yoannchb-pro\r\n */\r\nexport function skipReactive<T = any>(obj: T): T {\r\n Object.defineProperty(obj, skipReactivitySymbol, {\r\n enumerable: false,\r\n writable: false,\r\n value: true,\r\n configurable: true\r\n });\r\n return obj;\r\n}\r\n","import { ReactiveVariable } from './ReactiveVariable';\r\n\r\n/**\r\n * Unlock every watchers\r\n *\r\n * @author yoannchb-pro\r\n */\r\nexport function unlockWatchers() {\r\n ReactiveVariable.IS_GLOBAL_LOCK = false;\r\n}\r\n","import { reactivesVariablesList } from './data';\r\nimport { globalWatch } from './globalWatch';\r\nimport { isReactive } from './isReactive';\r\nimport { matchPath } from './matchPath';\r\nimport { Listener, ReactiveVariable } from './ReactiveVariable';\r\nimport { trackCallback } from './trackDeps';\r\n\r\n/**\r\n * Attach a listener to some reactives variables\r\n * @param listener\r\n * @param effect\r\n *\r\n * @author yoannchb-pro\r\n */\r\nexport function watch(listener: Listener, effect: () => any) {\r\n const removeWatcherLists: (() => void)[] = [];\r\n\r\n function registerListener(reactiveVariable: ReactiveVariable, path?: string) {\r\n const overideListener: Listener = {\r\n type: listener.type,\r\n fn: (props: Parameters<Listener['fn']>[0]) => {\r\n if (!path) return listener.fn(props as any);\r\n\r\n const matcher = matchPath(path, props.path);\r\n if (matcher.isMatching) {\r\n listener.fn(props as any);\r\n }\r\n }\r\n };\r\n\r\n const removeWatcher = reactiveVariable.attachListener(overideListener);\r\n removeWatcherLists.push(removeWatcher);\r\n }\r\n\r\n const removeEffect = globalWatch(\r\n {\r\n type: 'onGet',\r\n fn: ({ path, reactiveVariable }) => registerListener(reactiveVariable, path)\r\n },\r\n false\r\n );\r\n\r\n // We listen to deep property call\r\n // Example:\r\n // const todo = reactive({ title: \"Fork Domy On Github\", isCompleted: false })\r\n // watch(..., () => todo.title)\r\n const deps = effect();\r\n\r\n removeEffect();\r\n\r\n // In case we want to watch directly the signal or reactive without passing by the properties\r\n if (Array.isArray(deps) && !isReactive(deps)) {\r\n for (const dep of deps) {\r\n if (isReactive(dep)) {\r\n const reactiveVariable = reactivesVariablesList.get(dep);\r\n if (reactiveVariable) registerListener(reactiveVariable);\r\n }\r\n }\r\n } else if (isReactive(deps)) {\r\n const reactiveVariable = reactivesVariablesList.get(deps);\r\n if (reactiveVariable) registerListener(reactiveVariable);\r\n }\r\n\r\n const clean = () => {\r\n for (const removeWatcher of removeWatcherLists) {\r\n removeWatcher();\r\n }\r\n };\r\n\r\n // Tracking watcher creation\r\n if (trackCallback) trackCallback({ type: 'watcher', clean });\r\n\r\n return clean;\r\n}\r\n"],"names":["reactivesVariablesList","Map","globalListenersList","Set","trackCallback","globalWatch","listener","tracking","add","clean","has","delete","removeGlobalWatch","type","isProxySymbol","Symbol","isSignalSymbol","skipReactivitySymbol","ReactiveVariable","constructor","target","this","name","proxy","onSetListeners","onGetListeners","getProxy","createProxy","isReactive","isSignal","shouldBeSkip","clearListeners","clear","attachListener","l","fn","removeListener","canAttachProxy","isCollection","WeakMap","WeakSet","createCollectionHandler","path","ctx","get","property","receiver","Reflect","value","fullPath","args","prevValue","newValue","set","isNewObj","includes","obj","length","result","apply","callOnSetListeners","callOnGetListeners","createHandler","p","deleteProperty","undefined","exists","ownKeys","keys","Object","defineProperty","enumerable","writable","configurable","Proxy","IS_GLOBAL_LOCK","params","join","reactiveVariable","matchPath","reg","defaultRes","isMatching","rules","split","paths","isArrayLength","i","isParam","match","paramName","substring","isNaN","Number","unReactive","reactiveInstance","reactive","createGlobalListener","props","globalListener","err","console","error","watchEffectDepth","isComputedSymbol","getter","setter","Error","values","sig","deps","dep","push","effect","removeWatcherLists","registerListener","overideListener","removeWatcher","removeEffect","Array","isArray","opts","removeListenersSet","watchD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iB1C,eAAe9B,IAE7DwE,EAAiB7C,eAAe3B,MAGpC,GAGF,IACE2G,MACEV,UAEF3F,KAIJ+G,GAEIvH,GAAeA,EAAc,CAAES,KAAM,SAAUJ,UAE5CA,CACT"}
|
package/package.json
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
"name": "@domyjs/reactive",
|
3
|
+
"unpkg": "./dist/index.js",
|
4
|
+
"version": "1.0.0",
|
5
|
+
"description": "Domyjs reactive variable",
|
6
|
+
"types": "./dist/index.d.ts",
|
7
|
+
"files": [
|
8
|
+
"./dist",
|
9
|
+
"package.json",
|
10
|
+
"README.md"
|
11
|
+
],
|
12
|
+
"repository": {
|
13
|
+
"type": "git",
|
14
|
+
"url": "git+https://github.com/yoannchb-pro/domy.git"
|
15
|
+
},
|
16
|
+
"keywords": [
|
17
|
+
"types",
|
18
|
+
"domyjs",
|
19
|
+
"framework",
|
20
|
+
"typescript",
|
21
|
+
"javascript",
|
22
|
+
"reactive"
|
23
|
+
],
|
24
|
+
"author": "yoannchb",
|
25
|
+
"license": "MIT",
|
26
|
+
"bugs": {
|
27
|
+
"url": "https://github.com/yoannchb-pro/domy/issues"
|
28
|
+
},
|
29
|
+
"homepage": "https://github.com/domyjs/domy/tree/main/packages/reactive"
|
30
|
+
}
|