@madronejs/core 1.0.17 → 1.1.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/MadroneVue3-2XGQsm-S.cjs +1 -0
- package/dist/MadroneVue3-C5d5X6U2.js +557 -0
- package/dist/core.cjs +1 -0
- package/dist/core.js +75 -445
- package/dist/vue.cjs +1 -0
- package/dist/vue.js +6 -0
- package/package.json +29 -17
- package/types/auto.d.ts +93 -1
- package/types/decorate.d.ts +129 -14
- package/types/global.d.ts +141 -7
- package/types/integrations/MadroneState.d.ts +97 -16
- package/types/integrations/MadroneVue3.d.ts +64 -1
- package/types/integrations/vue.d.ts +42 -0
- package/types/interfaces.d.ts +162 -8
- package/types/reactivity/Computed.d.ts +46 -3
- package/types/reactivity/Observer.d.ts +92 -2
- package/types/reactivity/Reactive.d.ts +47 -7
- package/types/reactivity/Watcher.d.ts +55 -6
- package/types/reactivity/global.d.ts +68 -28
- package/types/reactivity/interfaces.d.ts +53 -11
- package/types/reactivity/typeHandlers.d.ts +9 -2
- package/types/util.d.ts +109 -15
- package/types/__spec__/decorateComputed.spec.d.ts +0 -2
- package/types/__spec__/decorateReactive.spec.d.ts +0 -2
- package/types/__spec__/examples.spec.d.ts +0 -2
- package/types/__spec__/merge.spec.d.ts +0 -2
- package/types/integrations/__spec__/madroneState.spec.d.ts +0 -2
- package/types/integrations/__spec__/testAccess.d.ts +0 -2
- package/types/integrations/__spec__/testAll.d.ts +0 -4
- package/types/integrations/__spec__/testAuto.d.ts +0 -2
- package/types/integrations/__spec__/testClass.d.ts +0 -2
- package/types/integrations/__spec__/testVue.d.ts +0 -2
- package/types/integrations/__spec__/vue3.spec.d.ts +0 -2
- package/types/reactivity/__spec__/observer.spec.d.ts +0 -2
- package/types/reactivity/__spec__/observer_array.spec.d.ts +0 -2
- package/types/reactivity/__spec__/observer_object.spec.d.ts +0 -2
- package/types/reactivity/__spec__/observer_set.xspec.d.ts +0 -2
- package/types/reactivity/__spec__/reactive.spec.d.ts +0 -2
- package/types/reactivity/__spec__/reactive_array.spec.d.ts +0 -2
- package/types/reactivity/__spec__/reactive_object.spec.d.ts +0 -2
- package/types/reactivity/__spec__/reactive_set.xspec.d.ts +0 -2
- package/types/reactivity/__spec__/watcher.spec.d.ts +0 -2
|
@@ -1,28 +1,70 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module reactivity/interfaces
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the low-level reactivity system.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Options passed to type handler hooks when reactive operations occur.
|
|
8
|
+
*
|
|
9
|
+
* @typeParam T - The type of the reactive target
|
|
10
|
+
*/
|
|
11
|
+
export type TypeHandlerOptions<T extends object = object> = {
|
|
12
|
+
/** Name for debugging */
|
|
2
13
|
name?: string;
|
|
14
|
+
/** Whether deep reactivity is enabled */
|
|
3
15
|
deep?: boolean;
|
|
4
|
-
receiver
|
|
16
|
+
/** The Proxy receiver */
|
|
17
|
+
receiver?: T;
|
|
18
|
+
/** The raw target object */
|
|
5
19
|
target?: T;
|
|
6
|
-
key
|
|
7
|
-
|
|
20
|
+
/** The property key being accessed/modified */
|
|
21
|
+
key?: PropertyKey;
|
|
22
|
+
/** The value being set */
|
|
23
|
+
value?: unknown;
|
|
24
|
+
/** Whether the operation changed the object's keys */
|
|
8
25
|
keysChanged?: boolean;
|
|
26
|
+
/** Whether the operation changed a value */
|
|
9
27
|
valueChanged?: boolean;
|
|
10
28
|
};
|
|
11
|
-
|
|
12
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Hook function called on reactive operations.
|
|
31
|
+
* @typeParam T - The type of the reactive target
|
|
32
|
+
*/
|
|
33
|
+
export type HandlerHookType<T extends object = object> = (options: TypeHandlerOptions<T>) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Hook function that determines if a value should be wrapped in a Proxy.
|
|
36
|
+
* @typeParam T - The type of the reactive target
|
|
37
|
+
*/
|
|
38
|
+
export type CheckProxyHookType<T extends object = object> = (options: {
|
|
13
39
|
target: T;
|
|
14
|
-
key:
|
|
15
|
-
value:
|
|
40
|
+
key: PropertyKey;
|
|
41
|
+
value: unknown;
|
|
16
42
|
}) => boolean;
|
|
17
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Collection of hooks for reactive Proxy handlers.
|
|
45
|
+
* @typeParam T - The type of the reactive target
|
|
46
|
+
*/
|
|
47
|
+
export type ReactiveHandlerHooks<T extends object = object> = {
|
|
48
|
+
/** Called when a property is read */
|
|
18
49
|
onGet: HandlerHookType<T>;
|
|
50
|
+
/** Called when a property is set */
|
|
19
51
|
onSet: HandlerHookType<T>;
|
|
52
|
+
/** Called when a property is deleted */
|
|
20
53
|
onDelete: HandlerHookType<T>;
|
|
54
|
+
/** Called when `in` operator or `has` trap is triggered */
|
|
21
55
|
onHas: HandlerHookType<T>;
|
|
56
|
+
/** Determines if a value should be wrapped in a reactive Proxy */
|
|
22
57
|
needsProxy: CheckProxyHookType<T>;
|
|
23
58
|
};
|
|
24
|
-
|
|
25
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Configuration options for creating reactive Proxies.
|
|
61
|
+
*
|
|
62
|
+
* @typeParam T - The type of the object being made reactive
|
|
63
|
+
*/
|
|
64
|
+
export type ReactiveOptions<T extends object = object> = {
|
|
65
|
+
/** Name for debugging purposes */
|
|
66
|
+
name?: string;
|
|
67
|
+
/** Whether to recursively make nested objects reactive (default: true) */
|
|
26
68
|
deep?: boolean;
|
|
27
69
|
} & Partial<ReactiveHandlerHooks<T>>;
|
|
28
70
|
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { ReactiveOptions } from './interfaces';
|
|
1
2
|
declare const _default: Readonly<{
|
|
2
3
|
object: (options: any) => {
|
|
3
4
|
get: (target: any, prop: any, receiver: any) => any;
|
|
4
|
-
set: (target: object, propertyKey: PropertyKey, value:
|
|
5
|
+
set: (target: object, propertyKey: PropertyKey, value: unknown) => boolean;
|
|
5
6
|
deleteProperty: (target: object, propertyKey: PropertyKey) => boolean;
|
|
6
7
|
has: (target: any, key: any) => boolean;
|
|
7
8
|
ownKeys: (target: any) => (string | symbol)[];
|
|
@@ -9,12 +10,18 @@ declare const _default: Readonly<{
|
|
|
9
10
|
};
|
|
10
11
|
array: (options: any) => {
|
|
11
12
|
get: (target: any, prop: any, receiver: any) => any;
|
|
12
|
-
set: (target: object, propertyKey: PropertyKey, value:
|
|
13
|
+
set: (target: object, propertyKey: PropertyKey, value: unknown) => boolean;
|
|
13
14
|
deleteProperty: (target: object, propertyKey: PropertyKey) => boolean;
|
|
14
15
|
has: (target: any, key: any) => boolean;
|
|
15
16
|
ownKeys: (target: any) => (string | symbol)[];
|
|
16
17
|
getPrototypeOf: (target: any) => any;
|
|
17
18
|
};
|
|
19
|
+
set: (options: ReactiveOptions) => {
|
|
20
|
+
get: (target: Set<unknown>, key: PropertyKey, receiver: object) => any;
|
|
21
|
+
};
|
|
22
|
+
map: (options: ReactiveOptions) => {
|
|
23
|
+
get: (target: Map<unknown, unknown>, key: PropertyKey, receiver: object) => any;
|
|
24
|
+
};
|
|
18
25
|
}>;
|
|
19
26
|
export default _default;
|
|
20
27
|
//# sourceMappingURL=typeHandlers.d.ts.map
|
package/types/util.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module util
|
|
3
|
+
*
|
|
4
|
+
* Utility functions for object composition and class mixins.
|
|
5
|
+
*
|
|
6
|
+
* These utilities support Madrone's composition-based architecture,
|
|
7
|
+
* allowing you to build complex objects from simpler pieces.
|
|
8
|
+
*/
|
|
1
9
|
type OptionalPropertyNames<T> = {
|
|
2
|
-
[K in keyof T]-?:
|
|
10
|
+
[K in keyof T]-?: object extends {
|
|
3
11
|
[P in K]: T[K];
|
|
4
12
|
} ? K : never;
|
|
5
13
|
}[keyof T];
|
|
@@ -9,24 +17,110 @@ type SpreadProperties<L, R, K extends keyof L & keyof R> = {
|
|
|
9
17
|
type Id<T> = T extends infer U ? {
|
|
10
18
|
[K in keyof U]: U[K];
|
|
11
19
|
} : never;
|
|
20
|
+
/**
|
|
21
|
+
* Type utility that merges two object types, with right-hand properties
|
|
22
|
+
* taking precedence over left-hand properties.
|
|
23
|
+
*
|
|
24
|
+
* @typeParam L - The left (base) type
|
|
25
|
+
* @typeParam R - The right (override) type
|
|
26
|
+
*/
|
|
12
27
|
export type SpreadTwo<L, R> = Id<Pick<L, Exclude<keyof L, keyof R>> & Pick<R, Exclude<keyof R, OptionalPropertyNames<R>>> & Pick<R, Exclude<OptionalPropertyNames<R>, keyof L>> & SpreadProperties<L, R, OptionalPropertyNames<R> & keyof L>>;
|
|
13
|
-
|
|
28
|
+
type ObjectOrFactory = object | ((...args: unknown[]) => object);
|
|
14
29
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
30
|
+
* Type utility that recursively merges an array of object types.
|
|
31
|
+
*
|
|
32
|
+
* Handles both plain objects and factory functions (whose return
|
|
33
|
+
* types are extracted and merged).
|
|
34
|
+
*
|
|
35
|
+
* @typeParam A - A tuple of object or factory types
|
|
18
36
|
*/
|
|
19
|
-
export
|
|
37
|
+
export type Spread<A extends readonly unknown[]> = A extends [infer L, ...infer R] ? SpreadTwo<L extends (...args: unknown[]) => infer RT ? RT : L, Spread<R>> : unknown;
|
|
20
38
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
39
|
+
* Merges multiple objects or factory functions into a single new object.
|
|
40
|
+
*
|
|
41
|
+
* Properties from later arguments override those from earlier ones.
|
|
42
|
+
* Factory functions are called and their return values are merged.
|
|
43
|
+
* All property descriptors (getters, setters, etc.) are preserved.
|
|
44
|
+
*
|
|
45
|
+
* @typeParam A - The types of objects/factories being merged
|
|
46
|
+
* @param types - Objects or factory functions to merge
|
|
47
|
+
* @returns A new object with all properties from all inputs
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* import { merge } from '@madronejs/core';
|
|
52
|
+
*
|
|
53
|
+
* const base = { name: 'base', value: 1 };
|
|
54
|
+
* const override = { value: 2, extra: true };
|
|
55
|
+
*
|
|
56
|
+
* const merged = merge(base, override);
|
|
57
|
+
* // { name: 'base', value: 2, extra: true }
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* // With factory functions
|
|
63
|
+
* const createTimestamp = () => ({ createdAt: Date.now() });
|
|
64
|
+
* const data = { name: 'item' };
|
|
65
|
+
*
|
|
66
|
+
* const result = merge(createTimestamp, data);
|
|
67
|
+
* // { createdAt: 1702345678901, name: 'item' }
|
|
68
|
+
* ```
|
|
24
69
|
*/
|
|
25
|
-
export declare function
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
70
|
+
export declare function merge<A extends ObjectOrFactory[]>(...types: [...A]): Spread<A>;
|
|
71
|
+
type Constructor = new (...args: unknown[]) => object;
|
|
72
|
+
/**
|
|
73
|
+
* Applies mixin classes to a base class by merging their prototypes.
|
|
74
|
+
*
|
|
75
|
+
* This function mutates the base class, copying all prototype properties
|
|
76
|
+
* from the mixin classes onto the base class prototype. Properties from
|
|
77
|
+
* the base class take precedence over mixin properties in case of conflicts.
|
|
78
|
+
*
|
|
79
|
+
* @param base - The base class to extend (will be mutated)
|
|
80
|
+
* @param mixins - Array of mixin classes whose prototypes will be merged in
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* import { applyClassMixins } from '@madronejs/core';
|
|
85
|
+
*
|
|
86
|
+
* class Timestamped {
|
|
87
|
+
* createdAt = Date.now();
|
|
88
|
+
* getAge() {
|
|
89
|
+
* return Date.now() - this.createdAt;
|
|
90
|
+
* }
|
|
91
|
+
* }
|
|
92
|
+
*
|
|
93
|
+
* class Serializable {
|
|
94
|
+
* toJSON() {
|
|
95
|
+
* return JSON.stringify(this);
|
|
96
|
+
* }
|
|
97
|
+
* }
|
|
98
|
+
*
|
|
99
|
+
* class Model {
|
|
100
|
+
* id: string;
|
|
101
|
+
* }
|
|
102
|
+
*
|
|
103
|
+
* // Add Timestamped and Serializable methods to Model
|
|
104
|
+
* applyClassMixins(Model, [Timestamped, Serializable]);
|
|
105
|
+
*
|
|
106
|
+
* const model = new Model();
|
|
107
|
+
* model.toJSON(); // Works!
|
|
108
|
+
* model.getAge(); // Works!
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export declare function applyClassMixins(base: Constructor, mixins: Constructor[]): void;
|
|
112
|
+
/**
|
|
113
|
+
* Creates a property descriptor map with default descriptor settings.
|
|
114
|
+
*
|
|
115
|
+
* Takes an object and returns its property descriptors with specified
|
|
116
|
+
* defaults applied. Useful for copying properties with consistent settings.
|
|
117
|
+
*
|
|
118
|
+
* @param obj - The source object
|
|
119
|
+
* @param defaults - Default descriptor values to apply
|
|
120
|
+
* @returns Property descriptor map with defaults applied
|
|
121
|
+
*
|
|
122
|
+
* @internal
|
|
123
|
+
*/
|
|
124
|
+
export declare function getDefaultDescriptors(obj: object, defaults?: Partial<PropertyDescriptor>): PropertyDescriptorMap;
|
|
31
125
|
export {};
|
|
32
126
|
//# sourceMappingURL=util.d.ts.map
|