wrec 0.20.2 → 0.20.3

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.
@@ -0,0 +1,4 @@
1
+ type LooseObject = Record<string, unknown>;
2
+ export declare function getPathValue(obj: LooseObject, path: string): any;
3
+ export declare function setPathValue(obj: LooseObject, path: string, value: unknown): void;
4
+ export {};
@@ -0,0 +1,13 @@
1
+ type LooseObject = Record<string, unknown>;
2
+ export type ProxyCallback = (keyPath: string, oldValue: unknown, newValue: unknown) => void;
3
+ /**
4
+ * Creates a recursive Proxy to monitor deep property changes,
5
+ * passing the dot-separated path to the callback.
6
+ * @param {Object} target object to proxy
7
+ * @param {ProxyCallback} callback function to call when any property changes
8
+ * @param {string} [path=''] current path prefix, used internally for recursion
9
+ * @returns {Proxy} deep proxy
10
+ */
11
+ export declare function createDeepProxy(target: LooseObject, callback: ProxyCallback, path?: string): LooseObject;
12
+ export declare function proxyToPlainObject(obj: LooseObject): LooseObject;
13
+ export {};
@@ -0,0 +1,20 @@
1
+ export type ChangeListener = {
2
+ changed: (statePath: string, componentProperty: string, newValue: unknown, oldValue: unknown, state: WrecState) => void;
3
+ };
4
+ type LooseObject = Record<string, unknown>;
5
+ export declare class WrecState {
6
+ #private;
7
+ static get(name: string): WrecState | undefined;
8
+ [key: string]: unknown;
9
+ constructor(name: string, persist: boolean, initial?: LooseObject);
10
+ /**
11
+ * @param listener - object that has a "changed" method
12
+ * @param map - map from state property paths to component properties
13
+ */
14
+ addListener(listener: ChangeListener, map?: Record<string, string>): void;
15
+ addProperty(propName: string, initialValue: unknown): void;
16
+ get id(): symbol;
17
+ log(): void;
18
+ removeListener(listener: ChangeListener): void;
19
+ }
20
+ export {};
package/dist/wrec.d.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  import { ChangeListener, WrecState } from './wrec-state';
2
+ import { getPathValue, setPathValue } from './paths';
3
+ export type { ChangeListener, WrecState };
4
+ export type { getPathValue, setPathValue };
2
5
  export declare function createElement(name: string, attributes: Record<string, string>, innerHTML: string): HTMLElement;
3
6
  export declare abstract class Wrec extends HTMLElement implements ChangeListener {
4
7
  #private;
@@ -38,4 +41,3 @@ export declare abstract class Wrec extends HTMLElement implements ChangeListener
38
41
  }
39
42
  export declare function css(strings: TemplateStringsArray, ...values: unknown[]): string;
40
43
  export declare function html(strings: TemplateStringsArray, ...values: unknown[]): string;
41
- export { WrecState } from './wrec-state';