@alloy-js/core 0.16.0 → 0.18.0-dev.2
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/CHANGELOG.md +15 -0
- package/dist/src/binder.d.ts +19 -235
- package/dist/src/binder.d.ts.map +1 -1
- package/dist/src/binder.js +85 -386
- package/dist/src/code.d.ts +1 -1
- package/dist/src/code.d.ts.map +1 -1
- package/dist/src/components/Block.d.ts +1 -1
- package/dist/src/components/Block.d.ts.map +1 -1
- package/dist/src/components/Block.js +3 -1
- package/dist/src/components/Declaration.d.ts +2 -2
- package/dist/src/components/Declaration.d.ts.map +1 -1
- package/dist/src/components/Declaration.js +6 -5
- package/dist/src/components/For.d.ts +1 -1
- package/dist/src/components/For.d.ts.map +1 -1
- package/dist/src/components/For.js +1 -1
- package/dist/src/components/Indent.d.ts +1 -1
- package/dist/src/components/Indent.d.ts.map +1 -1
- package/dist/src/components/List.d.ts +1 -1
- package/dist/src/components/List.d.ts.map +1 -1
- package/dist/src/components/List.js +3 -1
- package/dist/src/components/MemberDeclaration.d.ts +3 -3
- package/dist/src/components/MemberDeclaration.d.ts.map +1 -1
- package/dist/src/components/MemberDeclaration.js +4 -4
- package/dist/src/components/MemberScope.d.ts +2 -2
- package/dist/src/components/MemberScope.d.ts.map +1 -1
- package/dist/src/components/MemberScope.js +0 -2
- package/dist/src/components/Output.d.ts +1 -1
- package/dist/src/components/Output.d.ts.map +1 -1
- package/dist/src/components/Output.js +1 -1
- package/dist/src/components/Prose.d.ts +1 -1
- package/dist/src/components/Prose.d.ts.map +1 -1
- package/dist/src/components/ReferenceOrContent.d.ts +1 -1
- package/dist/src/components/ReferenceOrContent.d.ts.map +1 -1
- package/dist/src/components/Scope.d.ts +2 -2
- package/dist/src/components/Scope.d.ts.map +1 -1
- package/dist/src/components/Scope.js +3 -6
- package/dist/src/components/Show.d.ts +1 -1
- package/dist/src/components/Show.d.ts.map +1 -1
- package/dist/src/components/SourceDirectory.d.ts +1 -1
- package/dist/src/components/SourceDirectory.d.ts.map +1 -1
- package/dist/src/components/SourceDirectory.js +1 -1
- package/dist/src/components/SourceFile.d.ts +1 -1
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +1 -1
- package/dist/src/components/StatementList.d.ts +1 -1
- package/dist/src/components/StatementList.d.ts.map +1 -1
- package/dist/src/components/StatementList.js +1 -1
- package/dist/src/components/Switch.d.ts +2 -2
- package/dist/src/components/Switch.d.ts.map +1 -1
- package/dist/src/components/Switch.js +2 -1
- package/dist/src/components/Wrap.d.ts +1 -1
- package/dist/src/components/Wrap.d.ts.map +1 -1
- package/dist/src/context/assignment.d.ts +1 -1
- package/dist/src/context/assignment.d.ts.map +1 -1
- package/dist/src/context/binder.d.ts +3 -3
- package/dist/src/context/binder.d.ts.map +1 -1
- package/dist/src/context/declaration.d.ts +1 -1
- package/dist/src/context/declaration.d.ts.map +1 -1
- package/dist/src/context/member-declaration.d.ts +1 -1
- package/dist/src/context/member-declaration.d.ts.map +1 -1
- package/dist/src/context/member-declaration.js +0 -1
- package/dist/src/context/member-scope.d.ts +1 -1
- package/dist/src/context/member-scope.d.ts.map +1 -1
- package/dist/src/context/name-policy.d.ts +1 -1
- package/dist/src/context/name-policy.d.ts.map +1 -1
- package/dist/src/context/scope.d.ts +1 -1
- package/dist/src/context/scope.d.ts.map +1 -1
- package/dist/src/context/source-directory.d.ts +1 -1
- package/dist/src/context/source-directory.d.ts.map +1 -1
- package/dist/src/context/source-file.d.ts +2 -2
- package/dist/src/context/source-file.d.ts.map +1 -1
- package/dist/src/context.d.ts +2 -2
- package/dist/src/context.d.ts.map +1 -1
- package/dist/src/context.js +1 -1
- package/dist/src/debug.d.ts +1 -0
- package/dist/src/debug.d.ts.map +1 -1
- package/dist/src/debug.js +4 -1
- package/dist/src/index.d.ts +8 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +8 -2
- package/dist/src/jsx-runtime.d.ts +4 -272
- package/dist/src/jsx-runtime.d.ts.map +1 -1
- package/dist/src/jsx-runtime.js +3 -315
- package/dist/src/props-combinators.d.ts +19 -0
- package/dist/src/props-combinators.d.ts.map +1 -0
- package/dist/src/props-combinators.js +108 -0
- package/dist/src/reactive-union-set.d.ts +29 -0
- package/dist/src/reactive-union-set.d.ts.map +1 -0
- package/dist/src/reactive-union-set.js +183 -0
- package/dist/src/reactivity.d.ts +75 -0
- package/dist/src/reactivity.d.ts.map +1 -0
- package/dist/src/reactivity.js +141 -0
- package/dist/src/refkey.d.ts +36 -0
- package/dist/src/refkey.d.ts.map +1 -1
- package/dist/src/refkey.js +40 -0
- package/dist/src/render.d.ts +5 -1
- package/dist/src/render.d.ts.map +1 -1
- package/dist/src/render.js +68 -15
- package/dist/src/runtime/component.d.ts +24 -0
- package/dist/src/runtime/component.d.ts.map +1 -0
- package/dist/src/runtime/component.js +19 -0
- package/dist/src/runtime/intrinsic.d.ts +168 -0
- package/dist/src/runtime/intrinsic.d.ts.map +1 -0
- package/dist/src/runtime/intrinsic.js +11 -0
- package/dist/src/scheduler.d.ts +2 -2
- package/dist/src/scheduler.d.ts.map +1 -1
- package/dist/src/scheduler.js +27 -6
- package/dist/src/slot.d.ts +2 -2
- package/dist/src/slot.d.ts.map +1 -1
- package/dist/src/slot.js +1 -1
- package/dist/src/stc.d.ts +1 -1
- package/dist/src/stc.d.ts.map +1 -1
- package/dist/src/sti.d.ts +7 -6
- package/dist/src/sti.d.ts.map +1 -1
- package/dist/src/sti.js +1 -1
- package/dist/src/symbols/flags.d.ts +70 -0
- package/dist/src/symbols/flags.d.ts.map +1 -0
- package/dist/src/symbols/flags.js +72 -0
- package/dist/src/symbols/index.d.ts +7 -0
- package/dist/src/symbols/index.d.ts.map +1 -0
- package/dist/src/symbols/index.js +6 -0
- package/dist/src/symbols/output-scope.d.ts +94 -0
- package/dist/src/symbols/output-scope.d.ts.map +1 -0
- package/dist/src/symbols/output-scope.js +222 -0
- package/dist/src/symbols/output-symbol.d.ts +89 -0
- package/dist/src/symbols/output-symbol.d.ts.map +1 -0
- package/dist/src/symbols/output-symbol.js +333 -0
- package/dist/src/symbols/symbol-flow.d.ts +13 -0
- package/dist/src/symbols/symbol-flow.d.ts.map +1 -0
- package/dist/src/symbols/symbol-flow.js +74 -0
- package/dist/src/symbols/symbol-slot.d.ts +12 -0
- package/dist/src/symbols/symbol-slot.d.ts.map +1 -0
- package/dist/src/symbols/symbol-slot.js +36 -0
- package/dist/src/symbols/symbol-table.d.ts +14 -0
- package/dist/src/symbols/symbol-table.d.ts.map +1 -0
- package/dist/src/symbols/symbol-table.js +42 -0
- package/dist/src/tap.d.ts +3 -2
- package/dist/src/tap.d.ts.map +1 -1
- package/dist/src/tracer.d.ts +238 -0
- package/dist/src/tracer.d.ts.map +1 -0
- package/dist/src/tracer.js +496 -0
- package/dist/src/tsdoc-metadata.json +1 -1
- package/dist/src/utils.d.ts +4 -3
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +2 -1
- package/dist/test/components/slot.test.js +5 -7
- package/dist/test/props-with-defaults.test.js +1 -1
- package/dist/test/reactive-union-set.test.d.ts +2 -0
- package/dist/test/reactive-union-set.test.d.ts.map +1 -0
- package/dist/test/reactive-union-set.test.js +170 -0
- package/dist/test/reactivity/cleanup.test.js +2 -1
- package/dist/test/reactivity/memo.test.js +1 -1
- package/dist/test/reactivity/untrack.test.js +1 -1
- package/dist/test/rendering/memoization.test.js +2 -1
- package/dist/test/split-props.test.js +1 -1
- package/dist/test/symbols/output-scope.test.d.ts +2 -0
- package/dist/test/symbols/output-scope.test.d.ts.map +1 -0
- package/dist/test/symbols/output-scope.test.js +343 -0
- package/dist/test/symbols/output-symbol.test.d.ts +2 -0
- package/dist/test/symbols/output-symbol.test.d.ts.map +1 -0
- package/dist/test/symbols/output-symbol.test.js +447 -0
- package/dist/test/symbols/resolution.test.d.ts +2 -0
- package/dist/test/symbols/resolution.test.d.ts.map +1 -0
- package/dist/test/symbols/resolution.test.js +141 -0
- package/dist/test/symbols/utils.d.ts +25 -0
- package/dist/test/symbols/utils.d.ts.map +1 -0
- package/dist/test/symbols/utils.js +47 -0
- package/dist/testing/extend-expect.d.ts +15 -0
- package/dist/testing/extend-expect.d.ts.map +1 -1
- package/dist/testing/extend-expect.js +2 -1
- package/dist/testing/render.d.ts +1 -1
- package/dist/testing/render.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +28 -24
- package/src/binder.ts +146 -672
- package/src/code.ts +1 -1
- package/src/components/Block.tsx +4 -1
- package/src/components/Declaration.tsx +8 -7
- package/src/components/For.tsx +2 -1
- package/src/components/Indent.tsx +1 -1
- package/src/components/List.tsx +3 -1
- package/src/components/MemberDeclaration.tsx +7 -6
- package/src/components/MemberScope.tsx +2 -5
- package/src/components/Output.tsx +2 -1
- package/src/components/Prose.tsx +1 -1
- package/src/components/ReferenceOrContent.tsx +1 -1
- package/src/components/Scope.tsx +3 -7
- package/src/components/Show.tsx +1 -1
- package/src/components/SourceDirectory.tsx +2 -1
- package/src/components/SourceFile.tsx +2 -1
- package/src/components/StatementList.tsx +2 -1
- package/src/components/Switch.tsx +2 -1
- package/src/components/Wrap.tsx +1 -1
- package/src/context/assignment.ts +1 -1
- package/src/context/binder.ts +3 -3
- package/src/context/declaration.ts +1 -1
- package/src/context/member-declaration.ts +1 -1
- package/src/context/member-scope.ts +1 -1
- package/src/context/name-policy.ts +1 -1
- package/src/context/scope.ts +1 -1
- package/src/context/source-directory.ts +1 -1
- package/src/context/source-file.ts +2 -2
- package/src/context.ts +3 -7
- package/src/debug.ts +5 -1
- package/src/index.ts +15 -1
- package/src/jsx-runtime.ts +15 -674
- package/src/props-combinators.ts +148 -0
- package/src/reactive-union-set.ts +238 -0
- package/src/reactivity.ts +230 -0
- package/src/refkey.ts +40 -0
- package/src/render.ts +97 -26
- package/src/runtime/component.ts +67 -0
- package/src/runtime/intrinsic.ts +199 -0
- package/src/scheduler.ts +31 -6
- package/src/slot.ts +3 -4
- package/src/stc.ts +2 -2
- package/src/sti.ts +11 -11
- package/src/symbols/flags.ts +82 -0
- package/src/symbols/index.ts +6 -0
- package/src/symbols/output-scope.ts +296 -0
- package/src/symbols/output-symbol.ts +459 -0
- package/src/symbols/symbol-flow.ts +100 -0
- package/src/symbols/symbol-slot.tsx +48 -0
- package/src/symbols/symbol-table.ts +72 -0
- package/src/tap.ts +3 -2
- package/src/tracer.ts +474 -0
- package/src/utils.tsx +7 -5
- package/temp/api.json +7446 -5133
- package/test/components/slot.test.tsx +8 -11
- package/test/props-with-defaults.test.ts +1 -1
- package/test/reactive-union-set.test.tsx +191 -0
- package/test/reactivity/cleanup.test.tsx +2 -1
- package/test/reactivity/memo.test.tsx +1 -1
- package/test/reactivity/untrack.test.ts +1 -1
- package/test/rendering/basic.test.tsx +1 -1
- package/test/rendering/memoization.test.tsx +1 -1
- package/test/split-props.test.ts +1 -1
- package/test/symbols/output-scope.test.ts +300 -0
- package/test/symbols/output-symbol.test.ts +456 -0
- package/test/symbols/resolution.test.ts +170 -0
- package/test/symbols/utils.ts +93 -0
- package/test/utils.test.tsx +1 -1
- package/testing/extend-expect.ts +16 -0
- package/testing/render.ts +1 -2
- package/LICENSE +0 -7
- package/dist/test/symbols.test.d.ts +0 -2
- package/dist/test/symbols.test.d.ts.map +0 -1
- package/dist/test/symbols.test.js +0 -884
- package/test/symbols.test.ts +0 -1006
|
@@ -1,229 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { RenderedTextTree } from "./render.js";
|
|
4
|
-
export interface Disposable {
|
|
5
|
-
(): void;
|
|
6
|
-
}
|
|
7
|
-
export interface Context {
|
|
8
|
-
disposables: Disposable[];
|
|
9
|
-
owner: Context | null;
|
|
10
|
-
context?: Record<symbol, unknown>;
|
|
11
|
-
meta?: Record<string, any>;
|
|
12
|
-
/**
|
|
13
|
-
* A cache of RenderTextTree nodes created within this context,
|
|
14
|
-
* indexed by the component or function which created them.
|
|
15
|
-
*/
|
|
16
|
-
elementCache: ElementCache;
|
|
17
|
-
/**
|
|
18
|
-
* When this context was created by a component, this will
|
|
19
|
-
* be the component that created it.
|
|
20
|
-
*/
|
|
21
|
-
componentOwner?: ComponentCreator<unknown>;
|
|
22
|
-
}
|
|
23
|
-
export declare function getContext(): Context | null;
|
|
24
|
-
export declare function getElementCache(): ElementCache;
|
|
25
|
-
export type ElementCacheKey = ComponentCreator | (() => unknown) | CustomContext;
|
|
26
|
-
export type ElementCache = Map<ElementCacheKey, RenderedTextTree>;
|
|
27
|
-
export interface RootOptions {
|
|
28
|
-
componentOwner?: ComponentCreator<any>;
|
|
29
|
-
}
|
|
30
|
-
export declare function root<T>(fn: (d: Disposable) => T, options?: RootOptions): T;
|
|
31
|
-
export declare function untrack<T>(fn: () => T): T;
|
|
32
|
-
export declare function memo<T>(fn: () => T, equal?: boolean): () => T;
|
|
33
|
-
export declare function effect<T>(fn: (prev?: T) => T, current?: T): void;
|
|
34
|
-
/**
|
|
35
|
-
* Register a cleanup function which is called when the current reactive scope
|
|
36
|
-
* is recalculated or disposed. This is useful to clean up any side effects
|
|
37
|
-
* created in the reactive scope.
|
|
38
|
-
*
|
|
39
|
-
* @remarks
|
|
40
|
-
*
|
|
41
|
-
* When onCleanup is called inside a component definition, the provided function
|
|
42
|
-
* is called when the component is removed from the tree. This can be useful to
|
|
43
|
-
* clean up any side effects created as a result of rendering the component. For
|
|
44
|
-
* example, if rendering a component creates a symbol, `onCleanup` can be used
|
|
45
|
-
* to remove the symbol when the component is removed from the tree.
|
|
46
|
-
*
|
|
47
|
-
* When onCleanup is called inside a memo or effect, the function is called when
|
|
48
|
-
* the effect is refreshed (e.g. when a memo or computed recalculates) or
|
|
49
|
-
* disposed (e.g. it is no longer needed because it is attached to a component
|
|
50
|
-
* which was removed).
|
|
51
|
-
*/
|
|
52
|
-
export declare function onCleanup(fn: Disposable): void;
|
|
53
|
-
/**
|
|
54
|
-
* Create a custom reactive context for the children returned by
|
|
55
|
-
* the provided context.
|
|
56
|
-
*/
|
|
57
|
-
export interface CustomContext {
|
|
58
|
-
[CUSTOM_CONTEXT_SYM]: true;
|
|
59
|
-
useCustomContext: (useCb: CustomContextChildrenCallback) => void;
|
|
60
|
-
}
|
|
61
|
-
export type CustomContextChildrenCallback = (child: Children) => void;
|
|
62
|
-
declare const CUSTOM_CONTEXT_SYM: unique symbol;
|
|
63
|
-
export declare function createCustomContext(useCallback: (useChildren: CustomContextChildrenCallback) => void): CustomContext;
|
|
64
|
-
export declare function isCustomContext(child: Children): child is CustomContext;
|
|
65
|
-
export type Child = string | boolean | number | undefined | null | void | (() => Children) | Ref | Refkey | CustomContext | IntrinsicElement;
|
|
66
|
-
export type Children = Child | Children[];
|
|
67
|
-
export type Props = Record<string, any>;
|
|
68
|
-
export interface ComponentDefinition<TProps = Props> {
|
|
69
|
-
(props: TProps): Children;
|
|
70
|
-
}
|
|
71
|
-
export interface Component<TProps = Props> {
|
|
72
|
-
(props: TProps): Children;
|
|
73
|
-
tag?: symbol;
|
|
74
|
-
}
|
|
75
|
-
export interface ComponentCreator<TProps = Props> {
|
|
76
|
-
component: Component<TProps>;
|
|
77
|
-
(): Children;
|
|
78
|
-
props: TProps;
|
|
79
|
-
tag?: symbol;
|
|
80
|
-
}
|
|
81
|
-
export declare function pushStack(component: Component<any>, props: Props): void;
|
|
82
|
-
export declare function popStack(): void;
|
|
83
|
-
export declare function printRenderStack(): void;
|
|
84
|
-
export declare function isComponentCreator<TProps = any>(item: unknown, component?: Component<TProps>): item is ComponentCreator<TProps>;
|
|
1
|
+
import type { Children, Component, ComponentDefinition, IntrinsicElements as CoreIntrinsicElements } from "@alloy-js/core";
|
|
2
|
+
export { createComponent, createIntrinsic, memo, mergeProps, type Children, } from "@alloy-js/core";
|
|
85
3
|
/**
|
|
86
4
|
* This namespace is predominantly for interop with React tooling in VSCode
|
|
87
5
|
* and controls the type of JSX elements, components, and the like.
|
|
88
6
|
*/
|
|
89
7
|
export declare namespace JSX {
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Attempt to render the children on a single line if possible. If a group
|
|
93
|
-
* contains `<breakParent />` or a hard line, or if the group exceeds the
|
|
94
|
-
* print width, all linebreaks in the group will be broken.
|
|
95
|
-
*/
|
|
96
|
-
group: {
|
|
97
|
-
shouldBreak?: boolean;
|
|
98
|
-
id?: symbol;
|
|
99
|
-
children: Children;
|
|
100
|
-
};
|
|
101
|
-
/**
|
|
102
|
-
* A regular line break. This will break if the line exceeds the print
|
|
103
|
-
* width, otherwise it will be a space.
|
|
104
|
-
*/
|
|
105
|
-
line: {};
|
|
106
|
-
/**
|
|
107
|
-
* A regular line break. This will break if the line exceeds the print
|
|
108
|
-
* width, otherwise it will be a space.
|
|
109
|
-
*/
|
|
110
|
-
br: {};
|
|
111
|
-
/**
|
|
112
|
-
* A hard line break. This is a line that will always break, even if the
|
|
113
|
-
* group does not exceed print width.
|
|
114
|
-
*/
|
|
115
|
-
hardline: {};
|
|
116
|
-
/**
|
|
117
|
-
* A hard line break. This is a line that will always break, even if the
|
|
118
|
-
* group does not exceed print width.
|
|
119
|
-
*/
|
|
120
|
-
hbr: {};
|
|
121
|
-
/**
|
|
122
|
-
* A soft line break. This will break if the line exceeds the print width,
|
|
123
|
-
* otherwise it will be be nothing.
|
|
124
|
-
*/
|
|
125
|
-
softline: {};
|
|
126
|
-
/**
|
|
127
|
-
* A soft line break. This will break if the line exceeds the print width,
|
|
128
|
-
* otherwise it will be be nothing.
|
|
129
|
-
*/
|
|
130
|
-
sbr: {};
|
|
131
|
-
/**
|
|
132
|
-
* A literal line break. This will always break, even if the group does not
|
|
133
|
-
* exceed print width. The new line will ignore indentation.
|
|
134
|
-
*/
|
|
135
|
-
literalline: {};
|
|
136
|
-
/**
|
|
137
|
-
* A literal line break. This will always break, even if the group does not
|
|
138
|
-
* exceed print width. The new line will ignore indentation.
|
|
139
|
-
*/
|
|
140
|
-
lbr: {};
|
|
141
|
-
/**
|
|
142
|
-
* Increase the indentation level of the children of this component.
|
|
143
|
-
* Indentation is determined by the print options provided to the Output
|
|
144
|
-
* component or source file.
|
|
145
|
-
*/
|
|
146
|
-
indent: {
|
|
147
|
-
children: Children;
|
|
148
|
-
};
|
|
149
|
-
/**
|
|
150
|
-
* Indent the children of this component if the group specified by `groupId`
|
|
151
|
-
* is broken (or not broken if `negate` is passed). The specified group must
|
|
152
|
-
* already be printed.
|
|
153
|
-
*/
|
|
154
|
-
indentIfBreak: {
|
|
155
|
-
children: Children;
|
|
156
|
-
groupId: symbol;
|
|
157
|
-
negate?: boolean;
|
|
158
|
-
};
|
|
159
|
-
/**
|
|
160
|
-
* Similar to `group`, but will only place a line break before the last
|
|
161
|
-
* segment to exceed the print width. This is useful for formatting
|
|
162
|
-
* paragraphs of text where breaks are inserted prior to words which would
|
|
163
|
-
* otherwise exceed the print width.
|
|
164
|
-
*/
|
|
165
|
-
fill: {
|
|
166
|
-
children: Children;
|
|
167
|
-
};
|
|
168
|
-
/**
|
|
169
|
-
* Force the parent group to break.
|
|
170
|
-
*/
|
|
171
|
-
breakParent: {};
|
|
172
|
-
/**
|
|
173
|
-
* Print children if the current group or already printed group specified by
|
|
174
|
-
* `groupId` is broken. Otherwise, `flatContents` is printed instead.
|
|
175
|
-
*/
|
|
176
|
-
ifBreak: {
|
|
177
|
-
children: Children;
|
|
178
|
-
flatContents?: Children;
|
|
179
|
-
groupId?: symbol;
|
|
180
|
-
};
|
|
181
|
-
/**
|
|
182
|
-
* Print this content at the end of the line. Useful for things like line
|
|
183
|
-
* comments.
|
|
184
|
-
*/
|
|
185
|
-
lineSuffix: {
|
|
186
|
-
children: Children;
|
|
187
|
-
};
|
|
188
|
-
/**
|
|
189
|
-
* Force any line suffixes to print at this point.
|
|
190
|
-
*/
|
|
191
|
-
lineSuffixBoundary: {};
|
|
192
|
-
/**
|
|
193
|
-
* Decrease the indentation level of the children of this component.
|
|
194
|
-
* Indentation is determined by the print options provided to the Output
|
|
195
|
-
* component or source file.
|
|
196
|
-
*/
|
|
197
|
-
dedent: {
|
|
198
|
-
children: Children;
|
|
199
|
-
};
|
|
200
|
-
/**
|
|
201
|
-
* Indent the children of this component by either the number of characters
|
|
202
|
-
* indicated by the `width` prop, or by the provided string indicated by the
|
|
203
|
-
* `string` prop.
|
|
204
|
-
*/
|
|
205
|
-
align: {
|
|
206
|
-
children: Children;
|
|
207
|
-
width: number;
|
|
208
|
-
} | {
|
|
209
|
-
children: Children;
|
|
210
|
-
string: string;
|
|
211
|
-
};
|
|
212
|
-
/**
|
|
213
|
-
* Mark the current indentation level as "root" for the purposes of literal
|
|
214
|
-
* line breaks and `dedentToRoot`.
|
|
215
|
-
*/
|
|
216
|
-
markAsRoot: {
|
|
217
|
-
children: Children;
|
|
218
|
-
};
|
|
219
|
-
/**
|
|
220
|
-
* Decrease the indentation level to the root level specified by
|
|
221
|
-
* `<markAsRoot />`, or else to no indentation.
|
|
222
|
-
*/
|
|
223
|
-
dedentToRoot: {
|
|
224
|
-
children: Children;
|
|
225
|
-
};
|
|
226
|
-
}
|
|
8
|
+
type IntrinsicElements = CoreIntrinsicElements;
|
|
227
9
|
type ElementType = string | ComponentDefinition<any>;
|
|
228
10
|
type Element = Children;
|
|
229
11
|
interface ElementChildrenAttribute {
|
|
@@ -233,56 +15,6 @@ export declare namespace JSX {
|
|
|
233
15
|
props: {};
|
|
234
16
|
}
|
|
235
17
|
}
|
|
236
|
-
export declare function jsx(type: Component<any>, props: Record<string, unknown>): ComponentCreator<Record<string, unknown>>;
|
|
18
|
+
export declare function jsx(type: Component<any>, props: Record<string, unknown>): import("@alloy-js/core").ComponentCreator<Record<string, unknown>>;
|
|
237
19
|
export declare const jsxs: typeof jsx;
|
|
238
|
-
export declare function createComponent<TProps extends Props = Props>(C: Component<TProps>, props: TProps): ComponentCreator<TProps>;
|
|
239
|
-
export declare function taggedComponent<TProps = Props>(tag: symbol, component: Component<TProps>): Component<TProps> & Required<Pick<Component<TProps>, "tag">>;
|
|
240
|
-
export declare const intrinsicElementKey: unique symbol;
|
|
241
|
-
export type IndentIntrinsicElement = IntrinsicElementBase<"indent">;
|
|
242
|
-
export type IndentIfBreakIntrinsicElement = IntrinsicElementBase<"indentIfBreak">;
|
|
243
|
-
export type BrIntrinsicElement = IntrinsicElementBase<"br">;
|
|
244
|
-
export type LineIntrinsicElement = IntrinsicElementBase<"line">;
|
|
245
|
-
export type HbrIntrinsicElement = IntrinsicElementBase<"hbr">;
|
|
246
|
-
export type HardlineIntrinsicElement = IntrinsicElementBase<"hardline">;
|
|
247
|
-
export type SbrIntrinsicElement = IntrinsicElementBase<"sbr">;
|
|
248
|
-
export type SoftlineIntrinsicElement = IntrinsicElementBase<"softline">;
|
|
249
|
-
export type GroupIntrinsicElement = IntrinsicElementBase<"group">;
|
|
250
|
-
export type AlignIntrinsicElement = IntrinsicElementBase<"align">;
|
|
251
|
-
export type FillIntrinsicElement = IntrinsicElementBase<"fill">;
|
|
252
|
-
export type BreakParentIntrinsicElement = IntrinsicElementBase<"breakParent">;
|
|
253
|
-
export type LineSuffixIntrinsicElement = IntrinsicElementBase<"lineSuffix">;
|
|
254
|
-
export type LineSuffixBoundaryIntrinsicElement = IntrinsicElementBase<"lineSuffixBoundary">;
|
|
255
|
-
export type DedentIntrinsicElement = IntrinsicElementBase<"dedent">;
|
|
256
|
-
export type DedentToRootIntrinsicElement = IntrinsicElementBase<"dedentToRoot">;
|
|
257
|
-
export type MarkAsRootIntrinsicElement = IntrinsicElementBase<"markAsRoot">;
|
|
258
|
-
export type LiterallineIntrinsicElement = IntrinsicElementBase<"literalline">;
|
|
259
|
-
export type LbrIntrinsicElement = IntrinsicElementBase<"lbr">;
|
|
260
|
-
export type IfBreakIntrinsicElement = IntrinsicElementBase<"ifBreak">;
|
|
261
|
-
export type IntrinsicElement = IndentIntrinsicElement | IndentIfBreakIntrinsicElement | BrIntrinsicElement | LineIntrinsicElement | HbrIntrinsicElement | HardlineIntrinsicElement | SbrIntrinsicElement | SoftlineIntrinsicElement | GroupIntrinsicElement | AlignIntrinsicElement | FillIntrinsicElement | BreakParentIntrinsicElement | LineSuffixIntrinsicElement | LineSuffixBoundaryIntrinsicElement | DedentIntrinsicElement | LiterallineIntrinsicElement | LbrIntrinsicElement | DedentToRootIntrinsicElement | MarkAsRootIntrinsicElement | IfBreakIntrinsicElement;
|
|
262
|
-
export interface IntrinsicElementBase<TKey extends keyof JSX.IntrinsicElements = keyof JSX.IntrinsicElements> {
|
|
263
|
-
[intrinsicElementKey]: true;
|
|
264
|
-
name: TKey;
|
|
265
|
-
props: JSX.IntrinsicElements[TKey];
|
|
266
|
-
}
|
|
267
|
-
export declare function createIntrinsic<TKey extends keyof JSX.IntrinsicElements>(name: TKey, props: JSX.IntrinsicElements[TKey]): IntrinsicElementBase<TKey>;
|
|
268
|
-
export declare function isIntrinsicElement(type: unknown): type is IntrinsicElement;
|
|
269
|
-
export declare function mergeProps<T, U>(source: T, source1: U): T & U;
|
|
270
|
-
export declare function mergeProps<T, U, V>(source: T, source1: U, source2: V): T & U & V;
|
|
271
|
-
export declare function mergeProps<T, U, V, W>(source: T, source1: U, source2: V, source3: W): T & U & V & W;
|
|
272
|
-
export type SplitProps<T, K extends (readonly (keyof T)[])[]> = [
|
|
273
|
-
...{
|
|
274
|
-
[P in keyof K]: P extends `${number}` ? Pick<T, Extract<K[P], readonly (keyof T)[]>[number]> : never;
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
[P in keyof T as Exclude<P, K[number][number]>]: T[P];
|
|
278
|
-
}
|
|
279
|
-
];
|
|
280
|
-
export declare function splitProps<T extends Record<any, any>, K extends [readonly (keyof T)[], ...(readonly (keyof T)[])[]]>(props: T, ...keys: K): SplitProps<T, K>;
|
|
281
|
-
/**
|
|
282
|
-
* Applies default values to a props object. Reactive props are handled properly
|
|
283
|
-
* by ensuring that their value is not accessed by `defaultProps`, avoiding any
|
|
284
|
-
* unintended side effects.
|
|
285
|
-
*/
|
|
286
|
-
export declare function defaultProps<T extends {}>(props: T, defaults: Partial<T>): T;
|
|
287
|
-
export {};
|
|
288
20
|
//# sourceMappingURL=jsx-runtime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-runtime.d.ts","sourceRoot":"","sources":["../../src/jsx-runtime.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"jsx-runtime.d.ts","sourceRoot":"","sources":["../../src/jsx-runtime.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,QAAQ,EACR,SAAS,EACT,mBAAmB,EACnB,iBAAiB,IAAI,qBAAqB,EAC3C,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,eAAe,EACf,eAAe,EACf,IAAI,EACJ,UAAU,EACV,KAAK,QAAQ,GACd,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AAEH,yBAAiB,GAAG,CAAC;IACnB,KAAY,iBAAiB,GAAG,qBAAqB,CAAC;IACtD,KAAY,WAAW,GAAG,MAAM,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;IAC5D,KAAY,OAAO,GAAG,QAAQ,CAAC;IAC/B,UAAiB,wBAAwB;QACvC,QAAQ,EAAE,EAAE,CAAC;KACd;IACD,UAAiB,yBAAyB;QACxC,KAAK,EAAE,EAAE,CAAC;KACX;CACF;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,sEAEvE;AAED,eAAO,MAAM,IAAI,YAAM,CAAC"}
|
package/dist/src/jsx-runtime.js
CHANGED
|
@@ -1,187 +1,8 @@
|
|
|
1
1
|
// Much of the implementations in this file are inspired by vuerx-js
|
|
2
2
|
// See: https://github.com/ryansolid/vuerx-jsx.
|
|
3
|
-
import { computed, isReactive, pauseTracking, proxyRefs, resetTracking, shallowRef, stop, toRefs, effect as vueEffect } from "@vue/reactivity";
|
|
4
|
-
import { scheduler } from "./scheduler.js";
|
|
5
|
-
if (globalThis.ALLOY) {
|
|
6
|
-
throw new Error("Multiple versions of the JSX Runtime have been loaded. This will likely cause undesirable behavior.");
|
|
7
|
-
}
|
|
8
|
-
globalThis.ALLOY = true;
|
|
9
|
-
let globalContext = null;
|
|
10
|
-
export function getContext() {
|
|
11
|
-
return globalContext;
|
|
12
|
-
}
|
|
13
|
-
export function getElementCache() {
|
|
14
|
-
return getContext().elementCache;
|
|
15
|
-
}
|
|
16
|
-
export function root(fn, options) {
|
|
17
|
-
const context = {
|
|
18
|
-
componentOwner: options?.componentOwner,
|
|
19
|
-
disposables: [],
|
|
20
|
-
owner: globalContext,
|
|
21
|
-
context: {},
|
|
22
|
-
elementCache: new Map()
|
|
23
|
-
};
|
|
24
|
-
globalContext = context;
|
|
25
|
-
let ret;
|
|
26
|
-
try {
|
|
27
|
-
ret = untrack(() => fn(() => {
|
|
28
|
-
for (const d of context.disposables) {
|
|
29
|
-
d();
|
|
30
|
-
}
|
|
31
|
-
}));
|
|
32
|
-
} finally {
|
|
33
|
-
globalContext = globalContext.owner;
|
|
34
|
-
}
|
|
35
|
-
return ret;
|
|
36
|
-
}
|
|
37
|
-
export function untrack(fn) {
|
|
38
|
-
pauseTracking();
|
|
39
|
-
const v = fn();
|
|
40
|
-
resetTracking();
|
|
41
|
-
return v;
|
|
42
|
-
}
|
|
43
|
-
export function memo(fn, equal) {
|
|
44
|
-
const o = shallowRef();
|
|
45
|
-
effect(prev => {
|
|
46
|
-
const res = fn();
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
48
|
-
(!equal || prev !== res) && (o.value = res);
|
|
49
|
-
return res;
|
|
50
|
-
}, undefined);
|
|
51
|
-
return () => o.value;
|
|
52
|
-
}
|
|
53
|
-
export function effect(fn, current) {
|
|
54
|
-
const context = {
|
|
55
|
-
context: {},
|
|
56
|
-
disposables: [],
|
|
57
|
-
owner: globalContext,
|
|
58
|
-
elementCache: new Map()
|
|
59
|
-
};
|
|
60
|
-
const cleanupFn = final => {
|
|
61
|
-
const d = context.disposables;
|
|
62
|
-
context.disposables = [];
|
|
63
|
-
for (let k = 0, len = d.length; k < len; k++) d[k]();
|
|
64
|
-
|
|
65
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
66
|
-
final && stop(runner);
|
|
67
|
-
};
|
|
68
|
-
onCleanup(() => cleanupFn(true));
|
|
69
|
-
const runner = vueEffect(() => {
|
|
70
|
-
cleanupFn(false);
|
|
71
|
-
const oldContext = globalContext;
|
|
72
|
-
globalContext = context;
|
|
73
|
-
try {
|
|
74
|
-
current = fn(current);
|
|
75
|
-
} finally {
|
|
76
|
-
globalContext = oldContext;
|
|
77
|
-
}
|
|
78
|
-
}, {
|
|
79
|
-
scheduler: scheduler(() => runner)
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
// allow recursive effects (recursive option does nothing, possible bug)
|
|
83
|
-
runner.effect.flags |= 1 << 5;
|
|
84
|
-
}
|
|
85
3
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
* is recalculated or disposed. This is useful to clean up any side effects
|
|
89
|
-
* created in the reactive scope.
|
|
90
|
-
*
|
|
91
|
-
* @remarks
|
|
92
|
-
*
|
|
93
|
-
* When onCleanup is called inside a component definition, the provided function
|
|
94
|
-
* is called when the component is removed from the tree. This can be useful to
|
|
95
|
-
* clean up any side effects created as a result of rendering the component. For
|
|
96
|
-
* example, if rendering a component creates a symbol, `onCleanup` can be used
|
|
97
|
-
* to remove the symbol when the component is removed from the tree.
|
|
98
|
-
*
|
|
99
|
-
* When onCleanup is called inside a memo or effect, the function is called when
|
|
100
|
-
* the effect is refreshed (e.g. when a memo or computed recalculates) or
|
|
101
|
-
* disposed (e.g. it is no longer needed because it is attached to a component
|
|
102
|
-
* which was removed).
|
|
103
|
-
*/
|
|
104
|
-
export function onCleanup(fn) {
|
|
105
|
-
if (globalContext != null) {
|
|
106
|
-
globalContext.disposables.push(fn);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Create a custom reactive context for the children returned by
|
|
112
|
-
* the provided context.
|
|
113
|
-
*/
|
|
114
|
-
|
|
115
|
-
const CUSTOM_CONTEXT_SYM = Symbol();
|
|
116
|
-
export function createCustomContext(useCallback) {
|
|
117
|
-
return {
|
|
118
|
-
[CUSTOM_CONTEXT_SYM]: true,
|
|
119
|
-
useCustomContext(useCb) {
|
|
120
|
-
useCallback(useCb);
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
export function isCustomContext(child) {
|
|
125
|
-
return typeof child === "object" && child !== null && Object.hasOwn(child, CUSTOM_CONTEXT_SYM);
|
|
126
|
-
}
|
|
127
|
-
// debugging utilities
|
|
128
|
-
const renderStack = [];
|
|
129
|
-
export function pushStack(component, props) {
|
|
130
|
-
if (!shouldDebug()) return;
|
|
131
|
-
renderStack.push({
|
|
132
|
-
component,
|
|
133
|
-
props
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
export function popStack() {
|
|
137
|
-
if (!shouldDebug()) return;
|
|
138
|
-
renderStack.pop();
|
|
139
|
-
}
|
|
140
|
-
export function printRenderStack() {
|
|
141
|
-
if (!shouldDebug()) return;
|
|
142
|
-
|
|
143
|
-
// eslint-disable-next-line no-console
|
|
144
|
-
console.error("Error rendering:");
|
|
145
|
-
for (let i = renderStack.length - 1; i >= 0; i--) {
|
|
146
|
-
const {
|
|
147
|
-
component,
|
|
148
|
-
props
|
|
149
|
-
} = renderStack[i];
|
|
150
|
-
// eslint-disable-next-line no-console
|
|
151
|
-
console.error(` at ${component.name}(${inspectProps(props)})`);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
function inspectProps(props) {
|
|
155
|
-
return JSON.stringify(Object.fromEntries(Object.entries(props).map(([key, value]) => {
|
|
156
|
-
let safeValue;
|
|
157
|
-
switch (typeof value) {
|
|
158
|
-
case "string":
|
|
159
|
-
case "number":
|
|
160
|
-
case "boolean":
|
|
161
|
-
safeValue = value;
|
|
162
|
-
break;
|
|
163
|
-
case "undefined":
|
|
164
|
-
safeValue = "undefined";
|
|
165
|
-
break;
|
|
166
|
-
case "object":
|
|
167
|
-
safeValue = value ? "{...}" : null;
|
|
168
|
-
break;
|
|
169
|
-
case "function":
|
|
170
|
-
safeValue = "function";
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
173
|
-
return [key, safeValue];
|
|
174
|
-
})));
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// These can be removed with a smarter transform that encodes the information we
|
|
178
|
-
// need in the compiled JSX output.
|
|
179
|
-
export function isComponentCreator(item, component) {
|
|
180
|
-
if (!component) {
|
|
181
|
-
return typeof item === "function" && item.component;
|
|
182
|
-
}
|
|
183
|
-
return typeof item === "function" && item.component === component;
|
|
184
|
-
}
|
|
4
|
+
import { createComponent } from "@alloy-js/core";
|
|
5
|
+
export { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core";
|
|
185
6
|
|
|
186
7
|
/**
|
|
187
8
|
* This namespace is predominantly for interop with React tooling in VSCode
|
|
@@ -192,137 +13,4 @@ export let JSX;
|
|
|
192
13
|
export function jsx(type, props) {
|
|
193
14
|
return createComponent(type, props);
|
|
194
15
|
}
|
|
195
|
-
export const jsxs = jsx;
|
|
196
|
-
export function createComponent(C, props) {
|
|
197
|
-
const creator = () => /* */C(props);
|
|
198
|
-
creator.props = props;
|
|
199
|
-
creator.component = C;
|
|
200
|
-
if (C.tag) {
|
|
201
|
-
creator.tag = C.tag;
|
|
202
|
-
}
|
|
203
|
-
return creator;
|
|
204
|
-
}
|
|
205
|
-
export function taggedComponent(tag, component) {
|
|
206
|
-
component.tag = tag;
|
|
207
|
-
return component;
|
|
208
|
-
}
|
|
209
|
-
export const intrinsicElementKey = Symbol();
|
|
210
|
-
export function createIntrinsic(name, props) {
|
|
211
|
-
return {
|
|
212
|
-
[intrinsicElementKey]: true,
|
|
213
|
-
name,
|
|
214
|
-
props
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
export function isIntrinsicElement(type) {
|
|
218
|
-
return typeof type === "object" && type !== null && intrinsicElementKey in type;
|
|
219
|
-
}
|
|
220
|
-
export function mergeProps(...sources) {
|
|
221
|
-
const target = {};
|
|
222
|
-
for (let i = 0; i < sources.length; i++) {
|
|
223
|
-
let source = sources[i];
|
|
224
|
-
if (typeof source === "function") source = source();
|
|
225
|
-
if (source) {
|
|
226
|
-
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
227
|
-
for (const key in descriptors) {
|
|
228
|
-
if (key in target) continue;
|
|
229
|
-
Object.defineProperty(target, key, {
|
|
230
|
-
enumerable: true,
|
|
231
|
-
get() {
|
|
232
|
-
for (let i = sources.length - 1; i >= 0; i--) {
|
|
233
|
-
let s = sources[i];
|
|
234
|
-
if (typeof s === "function") s = s();
|
|
235
|
-
const v = (s || {})[key];
|
|
236
|
-
if (v !== undefined) return v;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
return target;
|
|
244
|
-
}
|
|
245
|
-
export function splitProps(props, ...keys) {
|
|
246
|
-
if (isReactive(props)) {
|
|
247
|
-
const refs = untrack(() => toRefs(props));
|
|
248
|
-
const remainingKeys = new Set(Object.keys(refs));
|
|
249
|
-
const result = keys.map(keySet => {
|
|
250
|
-
const resultSet = {};
|
|
251
|
-
for (const key of keySet) {
|
|
252
|
-
resultSet[key] = refs[key];
|
|
253
|
-
remainingKeys.delete(key);
|
|
254
|
-
}
|
|
255
|
-
return proxyRefs(resultSet);
|
|
256
|
-
});
|
|
257
|
-
const remaining = {};
|
|
258
|
-
for (const key of remainingKeys) {
|
|
259
|
-
remaining[key] = refs[key];
|
|
260
|
-
}
|
|
261
|
-
return [...result, proxyRefs(remaining)];
|
|
262
|
-
}
|
|
263
|
-
const descriptors = Object.getOwnPropertyDescriptors(props);
|
|
264
|
-
const remainingKeys = new Set(Object.keys(descriptors));
|
|
265
|
-
const result = keys.map(keySet => {
|
|
266
|
-
const resultSet = {};
|
|
267
|
-
for (const key of keySet) {
|
|
268
|
-
if (key in descriptors) {
|
|
269
|
-
Object.defineProperty(resultSet, key, descriptors[key]);
|
|
270
|
-
remainingKeys.delete(key);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
return resultSet;
|
|
274
|
-
});
|
|
275
|
-
const remaining = {};
|
|
276
|
-
for (const key of remainingKeys) {
|
|
277
|
-
Object.defineProperty(remaining, key, descriptors[key]);
|
|
278
|
-
}
|
|
279
|
-
return [...result, remaining];
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* Applies default values to a props object. Reactive props are handled properly
|
|
284
|
-
* by ensuring that their value is not accessed by `defaultProps`, avoiding any
|
|
285
|
-
* unintended side effects.
|
|
286
|
-
*/
|
|
287
|
-
export function defaultProps(props, defaults) {
|
|
288
|
-
if (isReactive(props)) {
|
|
289
|
-
const refs = untrack(() => toRefs(props));
|
|
290
|
-
for (const key in defaults) {
|
|
291
|
-
const originalRef = refs[key];
|
|
292
|
-
refs[key] = computed(() => originalRef.value === undefined ? defaults[key] : originalRef.value);
|
|
293
|
-
}
|
|
294
|
-
return proxyRefs(refs);
|
|
295
|
-
}
|
|
296
|
-
const withDefaults = {};
|
|
297
|
-
const copied = new Set();
|
|
298
|
-
for (const key in defaults) {
|
|
299
|
-
copied.add(key);
|
|
300
|
-
const desc = Object.getOwnPropertyDescriptor(props, key);
|
|
301
|
-
if (!desc) {
|
|
302
|
-
withDefaults[key] = defaults[key];
|
|
303
|
-
continue;
|
|
304
|
-
}
|
|
305
|
-
if (desc.get) {
|
|
306
|
-
const originalGet = desc.get;
|
|
307
|
-
desc.get = function () {
|
|
308
|
-
const value = originalGet.call(this);
|
|
309
|
-
return value === undefined ? defaults[key] : value;
|
|
310
|
-
};
|
|
311
|
-
Object.defineProperty(withDefaults, key, desc);
|
|
312
|
-
} else {
|
|
313
|
-
desc.value = desc.value === undefined ? defaults[key] : desc.value;
|
|
314
|
-
Object.defineProperty(withDefaults, key, desc);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
const descriptors = Object.getOwnPropertyDescriptors(props);
|
|
318
|
-
for (const key in descriptors) {
|
|
319
|
-
if (copied.has(key)) {
|
|
320
|
-
continue;
|
|
321
|
-
}
|
|
322
|
-
Object.defineProperty(withDefaults, key, descriptors[key]);
|
|
323
|
-
}
|
|
324
|
-
return withDefaults;
|
|
325
|
-
}
|
|
326
|
-
function shouldDebug() {
|
|
327
|
-
return typeof process !== "undefined" && !!process.env?.ALLOY_DEBUG;
|
|
328
|
-
}
|
|
16
|
+
export const jsxs = jsx;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare function mergeProps<T, U>(source: T, source1: U): T & U;
|
|
2
|
+
export declare function mergeProps<T, U, V>(source: T, source1: U, source2: V): T & U & V;
|
|
3
|
+
export declare function mergeProps<T, U, V, W>(source: T, source1: U, source2: V, source3: W): T & U & V & W;
|
|
4
|
+
export type SplitProps<T, K extends (readonly (keyof T)[])[]> = [
|
|
5
|
+
...{
|
|
6
|
+
[P in keyof K]: P extends `${number}` ? Pick<T, Extract<K[P], readonly (keyof T)[]>[number]> : never;
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
[P in keyof T as Exclude<P, K[number][number]>]: T[P];
|
|
10
|
+
}
|
|
11
|
+
];
|
|
12
|
+
export declare function splitProps<T extends Record<any, any>, K extends [readonly (keyof T)[], ...(readonly (keyof T)[])[]]>(props: T, ...keys: K): SplitProps<T, K>;
|
|
13
|
+
/**
|
|
14
|
+
* Applies default values to a props object. Reactive props are handled properly
|
|
15
|
+
* by ensuring that their value is not accessed by `defaultProps`, avoiding any
|
|
16
|
+
* unintended side effects.
|
|
17
|
+
*/
|
|
18
|
+
export declare function defaultProps<T extends {}>(props: T, defaults: Partial<T>): T;
|
|
19
|
+
//# sourceMappingURL=props-combinators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props-combinators.d.ts","sourceRoot":"","sources":["../../src/props-combinators.ts"],"names":[],"mappings":"AAGA,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC/D,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAChC,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,CAAC,EACV,OAAO,EAAE,CAAC,GACT,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACb,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EACnC,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,CAAC,EACV,OAAO,EAAE,CAAC,EACV,OAAO,EAAE,CAAC,GACT,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AA2BjB,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI;IAC9D,GAAG;SACA,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,SAAS,GAAG,MAAM,EAAE,GACnC,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GACpD,KAAK;KACR;IACD;SAAG,CAAC,IAAI,MAAM,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KAAE;CAC1D,CAAC;AAEF,wBAAgB,UAAU,CACxB,CAAC,SAAS,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAC1B,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAC7D,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAyCxC;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CA8C5E"}
|