regor 1.1.8 → 1.2.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/regor.d.ts +30 -32
- package/dist/regor.es2015.cjs.js +3873 -3877
- package/dist/regor.es2015.cjs.prod.js +3 -3
- package/dist/regor.es2015.esm.js +3873 -3877
- package/dist/regor.es2015.esm.prod.js +3 -3
- package/dist/regor.es2015.iife.js +3873 -3877
- package/dist/regor.es2015.iife.prod.js +3 -3
- package/dist/regor.es2019.cjs.js +3873 -3877
- package/dist/regor.es2019.cjs.prod.js +3 -3
- package/dist/regor.es2019.esm.js +3873 -3877
- package/dist/regor.es2019.esm.prod.js +3 -3
- package/dist/regor.es2019.iife.js +3873 -3877
- package/dist/regor.es2019.iife.prod.js +3 -3
- package/dist/regor.es2022.cjs.js +3627 -3634
- package/dist/regor.es2022.cjs.prod.js +3 -3
- package/dist/regor.es2022.esm.js +3627 -3634
- package/dist/regor.es2022.esm.prod.js +3 -3
- package/dist/regor.es2022.iife.js +3627 -3634
- package/dist/regor.es2022.iife.prod.js +3 -3
- package/package.json +14 -5
package/dist/regor.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
-
export declare class ComponentHead<
|
|
4
|
-
props:
|
|
3
|
+
export declare class ComponentHead<TContext = IRegorContext> {
|
|
4
|
+
props: TContext;
|
|
5
5
|
start: Comment;
|
|
6
6
|
end: Comment;
|
|
7
7
|
ctx: IRegorContext[];
|
|
@@ -10,7 +10,7 @@ export declare class ComponentHead<TProps = Record<any, any>> {
|
|
|
10
10
|
autoProps: boolean;
|
|
11
11
|
/** When both autoProps and entangle are enabled,
|
|
12
12
|
* the refs defined in the component context (without using head.props)
|
|
13
|
-
* become entangled with the head.props refs. (parent[ref]
|
|
13
|
+
* become entangled with the head.props refs. (parent[ref] `<==>` component[ref])
|
|
14
14
|
* This means that changes to parent[ref] reflect in component[ref], and vice versa.
|
|
15
15
|
* Disable this flag to isolate refs created within the component context.
|
|
16
16
|
* Default: true */
|
|
@@ -20,18 +20,18 @@ export declare class ComponentHead<TProps = Record<any, any>> {
|
|
|
20
20
|
enableSwitch: boolean;
|
|
21
21
|
/** A callback invoked after auto props get assigned to the component context. */
|
|
22
22
|
onAutoPropsAssigned?: () => void;
|
|
23
|
-
constructor(props:
|
|
23
|
+
constructor(props: TContext, element: Element, ctx: IRegorContext[], start: Comment, end: Comment);
|
|
24
24
|
/** use arrow syntax to be called without using head.emit.bind(head) in Binder.ts. */
|
|
25
|
-
emit: (event: string, args: Record<
|
|
25
|
+
emit: (event: string, args: Record<string, unknown>) => void;
|
|
26
26
|
unmount(): void;
|
|
27
27
|
}
|
|
28
28
|
export declare class RegorConfig {
|
|
29
29
|
static getDefault(): RegorConfig;
|
|
30
30
|
forGrowThreshold: number;
|
|
31
|
-
globalContext: Record<string,
|
|
31
|
+
globalContext: Record<string, unknown>;
|
|
32
32
|
useInterpolation: boolean;
|
|
33
|
-
constructor(globalContext?: Record<
|
|
34
|
-
addComponent<
|
|
33
|
+
constructor(globalContext?: Record<string, unknown>);
|
|
34
|
+
addComponent<TContext = IRegorContext>(...components: Array<Component<TContext>>): void;
|
|
35
35
|
setDirectives(prefix: string): void;
|
|
36
36
|
updateDirectives(updater: (directiveMap: Record<string, Directive>, builtInNames: Record<string, string>) => void): void;
|
|
37
37
|
}
|
|
@@ -76,8 +76,8 @@ export type FlattenRef<TRef> = TRef extends Array<infer V1> ? Array<FlattenRef<V
|
|
|
76
76
|
export type Flat<TValueType> = Equals<RefParam<TValueType>, FlattenRef<TValueType>> extends true ? RefParam<TValueType> : FlattenRef<TValueType>;
|
|
77
77
|
export type ObserveCallback<TValueType> = (newValue: TValueType, eventSource?: any) => void;
|
|
78
78
|
export type StopObserving = () => void;
|
|
79
|
-
export declare interface IRegorContext extends Record<
|
|
80
|
-
components?: Record<string, Component
|
|
79
|
+
export declare interface IRegorContext extends Record<string, unknown> {
|
|
80
|
+
components?: Record<string, Component>;
|
|
81
81
|
mounted?: () => void;
|
|
82
82
|
unmounted?: () => void;
|
|
83
83
|
}
|
|
@@ -97,14 +97,14 @@ export interface Directive {
|
|
|
97
97
|
}
|
|
98
98
|
export interface BindData {
|
|
99
99
|
unbinders: Unbinder[];
|
|
100
|
-
data: Record<
|
|
100
|
+
data: Record<string, unknown>;
|
|
101
101
|
}
|
|
102
102
|
export type Unbinder = () => void;
|
|
103
103
|
export interface ParseResult {
|
|
104
104
|
value: SRef<unknown[]>;
|
|
105
105
|
stop: StopObserving;
|
|
106
106
|
refs: Array<AnyRef | undefined>;
|
|
107
|
-
context: Record<
|
|
107
|
+
context: Record<string, unknown>;
|
|
108
108
|
}
|
|
109
109
|
export type OnCleanup = (cleanup: () => void) => void;
|
|
110
110
|
export interface JSONTemplate {
|
|
@@ -166,16 +166,16 @@ export interface App<TRegorContext extends IRegorContext> {
|
|
|
166
166
|
/**
|
|
167
167
|
* Represents a component in the Regor framework.
|
|
168
168
|
*
|
|
169
|
-
* @typeparam
|
|
169
|
+
* @typeparam TContext - The type of context accepted by the component.
|
|
170
170
|
*/
|
|
171
|
-
export interface Component<
|
|
171
|
+
export interface Component<TContext = IRegorContext> {
|
|
172
172
|
/**
|
|
173
173
|
* A function that returns the Regor context associated with the component.
|
|
174
174
|
*
|
|
175
175
|
* @param head - Provides information on component mount.
|
|
176
|
-
* @returns The
|
|
176
|
+
* @returns The component context.
|
|
177
177
|
*/
|
|
178
|
-
context: (head: ComponentHead<
|
|
178
|
+
context: (head: ComponentHead<TContext>) => TContext;
|
|
179
179
|
/**
|
|
180
180
|
* The template for the component.
|
|
181
181
|
*/
|
|
@@ -196,18 +196,18 @@ export interface Component<TProps = Record<any, any>> {
|
|
|
196
196
|
}
|
|
197
197
|
export type OnMounted = () => void;
|
|
198
198
|
export type OnUnmounted = () => void;
|
|
199
|
-
export interface CreateComponentOptions {
|
|
199
|
+
export interface CreateComponentOptions<TContext = IRegorContext> {
|
|
200
200
|
useInterpolation?: boolean;
|
|
201
201
|
config?: RegorConfig;
|
|
202
202
|
/**
|
|
203
203
|
* A function that defines the Regor context for the component.
|
|
204
204
|
*/
|
|
205
|
-
context?: (head: ComponentHead<
|
|
205
|
+
context?: (head: ComponentHead<TContext>) => TContext;
|
|
206
206
|
inheritAttrs?: boolean;
|
|
207
207
|
/**
|
|
208
208
|
* Notes on component props:
|
|
209
209
|
* The props defined in the props list can be used with :foo or r-bind:foo syntax.
|
|
210
|
-
*
|
|
210
|
+
* `<MyComponent :prop-kebab-1="1" r-bind:prop-kebab-2="x ? 1 : 0" :props="{ propFoo3: true, propFoo4: x ? 'a' : 'b' }></MyComponent>`
|
|
211
211
|
* It is required to define prop-kebab-1 and prop-kebab-2 in the props list camelized.
|
|
212
212
|
* It is not required to define propFoo3 and propFoo4 in the props list because it uses :props binding. :props binding enables binding to any property of component regardless it is explicitly defined in props list.
|
|
213
213
|
*/
|
|
@@ -221,15 +221,19 @@ export interface Scope<TRegorContext> {
|
|
|
221
221
|
context: TRegorContext;
|
|
222
222
|
unmount: () => void;
|
|
223
223
|
[ScopeSymbol]: true;
|
|
224
|
+
[key: string]: unknown;
|
|
224
225
|
}
|
|
225
226
|
export declare const createApp: <TRegorContext extends IRegorContext>(context: TRegorContext | Scope<TRegorContext>, template?: Template | string, config?: RegorConfig) => App<TRegorContext>;
|
|
226
|
-
export declare const createComponent: <
|
|
227
|
+
export declare const createComponent: <TContext = IRegorContext>(template: Template | string, options?: CreateComponentOptions<TContext> | string[]) => Component<TContext>;
|
|
227
228
|
export declare const toFragment: (json: JSONTemplate | JSONTemplate[], isSVG?: boolean, config?: RegorConfig) => DocumentFragment;
|
|
228
229
|
export declare const toJsonTemplate: (node: Element | Element[]) => JSONTemplate | JSONTemplate[];
|
|
229
230
|
export declare const addUnbinder: (node: Node, unbinder: Unbinder) => void;
|
|
230
231
|
export declare const getBindData: (node: any) => BindData;
|
|
231
232
|
export declare const removeNode: (node: ChildNode) => void;
|
|
232
233
|
export declare const unbind: (node: Node) => void;
|
|
234
|
+
export declare const onMounted: (onMounted: OnMounted) => void;
|
|
235
|
+
export declare const onUnmounted: (onUnmounted: OnUnmounted, noThrow?: boolean) => void;
|
|
236
|
+
export declare const useScope: <TRegorContext extends IRegorContext>(context: () => TRegorContext) => Scope<TRegorContext>;
|
|
233
237
|
export declare const computed: <TReturnType>(compute: () => TReturnType) => ComputedRef<UnwrapRef<TReturnType>>;
|
|
234
238
|
export declare const computeMany: <TReturnType>(sources: AnyRef[], compute: (...values: any[]) => TReturnType) => ComputedRef<UnwrapRef<TReturnType>>;
|
|
235
239
|
export declare const computeRef: <TValueType extends AnyRef, TReturnType>(source: TValueType, compute: (value: UnwrapRef<TValueType>) => TReturnType) => ComputedRef<UnwrapRef<TReturnType>>;
|
|
@@ -239,6 +243,9 @@ export declare const collectRefs: <TReturnType>(action: () => TReturnType) => {
|
|
|
239
243
|
value: TReturnType;
|
|
240
244
|
refs: AnyRef[];
|
|
241
245
|
};
|
|
246
|
+
export declare const warningHandler: {
|
|
247
|
+
warning: (...data: any[]) => void;
|
|
248
|
+
};
|
|
242
249
|
export declare const flatten: <TValueType>(reference: TValueType | Ref<TValueType> | SRef<TValueType> | ComputedRef<TValueType>) => Flat<TValueType>;
|
|
243
250
|
export declare const isRaw: (value: any) => boolean;
|
|
244
251
|
export type Raw<TValueType> = TValueType & RawMarker;
|
|
@@ -252,6 +259,7 @@ export declare const observerCount: <TValueType extends AnyRef>(source: TValueTy
|
|
|
252
259
|
export declare const batch: (updater: () => void) => void;
|
|
253
260
|
export declare const startBatch: () => void;
|
|
254
261
|
export declare const endBatch: () => void;
|
|
262
|
+
export declare const entangle: (r1: AnyRef, r2: AnyRef) => StopObserving;
|
|
255
263
|
export declare const isDeepRef: (value: unknown) => value is AnyRef;
|
|
256
264
|
export declare const isRef: (value: unknown) => value is AnyRef;
|
|
257
265
|
export declare const pause: <TValueType extends AnyRef>(source: TValueType) => void;
|
|
@@ -274,7 +282,7 @@ export declare const pause: <TValueType extends AnyRef>(source: TValueType) => v
|
|
|
274
282
|
* @param value - Any value to be converted into a ref object.
|
|
275
283
|
* @returns A ref object representing the input value and its nested properties.
|
|
276
284
|
*/
|
|
277
|
-
export declare const ref: <TValueType>(value?: TValueType | RefContent<TValueType> |
|
|
285
|
+
export declare const ref: <TValueType>(value?: TValueType | RefContent<TValueType> | (TValueType extends Ref<infer V1> ? Ref<RefParam<V1>> : never) | (TValueType extends SRef<infer V2> ? SRef<UnwrapRef<V2>> : never) | RefParam<TValueType> | (TValueType extends Array<infer V1> ? V1[] : never) | null) => IsNull<TValueType> extends true ? Ref<unknown> : Ref<RefParam<TValueType>>;
|
|
278
286
|
export declare const resume: <TValueType extends AnyRef>(source: TValueType) => void;
|
|
279
287
|
/**
|
|
280
288
|
* Converts the given value to an sref object and returns the sref.
|
|
@@ -295,18 +303,8 @@ export declare const resume: <TValueType extends AnyRef>(source: TValueType) =>
|
|
|
295
303
|
* @param value - Any value to be converted into an sref object.
|
|
296
304
|
* @returns An sref object representing the input value.
|
|
297
305
|
*/
|
|
298
|
-
export declare const sref: <TValueType>(value?: TValueType | (TValueType extends SRef<infer V2> ? SRef<UnwrapRef<V2>> : never) | (TValueType extends
|
|
306
|
+
export declare const sref: <TValueType>(value?: TValueType | (TValueType extends SRef<infer V2> ? SRef<UnwrapRef<V2>> : never) | (TValueType extends Array<infer V1> ? V1[] : never) | null) => IsNull<TValueType> extends true ? SRef<unknown> : SRef<SRefContent<TValueType>>;
|
|
299
307
|
export declare const trigger: <TValueType extends AnyRef>(source: TValueType, eventSource?: any, isRecursive?: boolean) => void;
|
|
300
308
|
export declare const unref: <TValueType>(value: TValueType) => UnwrapRef<TValueType>;
|
|
301
|
-
export declare const entangle: (r1: AnyRef, r2: AnyRef) => StopObserving;
|
|
302
|
-
export declare const useScope: <TRegorContext extends IRegorContext>(context: () => TRegorContext) => Scope<TRegorContext>;
|
|
303
|
-
export declare const onMounted: (onMounted: OnMounted) => void;
|
|
304
|
-
export declare const onUnmounted: (onUnmounted: OnUnmounted, noThrow?: boolean) => void;
|
|
305
|
-
export declare const warningHandler: {
|
|
306
|
-
warning: {
|
|
307
|
-
(...data: any[]): void;
|
|
308
|
-
(message?: any, ...optionalParams: any[]): void;
|
|
309
|
-
};
|
|
310
|
-
};
|
|
311
309
|
|
|
312
310
|
export {};
|