@glint/template 1.4.1-unstable.c9300e5 → 1.4.1-unstable.d17c1f1
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/-private/dsl/elements.d.ts +4274 -0
- package/-private/dsl/emit.d.ts +38 -14
- package/-private/dsl/lib.dom.augmentation.d.ts +637 -0
- package/-private/dsl/types.d.ts +26 -6
- package/package.json +17 -3
package/-private/dsl/emit.d.ts
CHANGED
|
@@ -9,7 +9,12 @@ import {
|
|
|
9
9
|
TemplateContext,
|
|
10
10
|
NamedArgs,
|
|
11
11
|
} from '../integration';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
AttributesForElement,
|
|
14
|
+
ElementForTagName,
|
|
15
|
+
MathMlElementForTagName,
|
|
16
|
+
SVGElementForTagName,
|
|
17
|
+
} from './types';
|
|
13
18
|
|
|
14
19
|
/**
|
|
15
20
|
* Used during emit to denote an object literal that corresponds
|
|
@@ -38,15 +43,29 @@ export declare function emitContent(value: ContentValue): void;
|
|
|
38
43
|
*
|
|
39
44
|
* Would produce code like:
|
|
40
45
|
*
|
|
41
|
-
* emitElement('div', (
|
|
42
|
-
* applySplattributes(
|
|
43
|
-
* applyAttributes(
|
|
44
|
-
* applyModifier(
|
|
46
|
+
* emitElement('div', (__glintY__) => {
|
|
47
|
+
* applySplattributes(__glintRef__.element, __glintY__.element);
|
|
48
|
+
* applyAttributes(__glintY__.element, { class: 'hello' });
|
|
49
|
+
* applyModifier(__glintY__.element, resolve(on)({}, 'click', this.clicked));
|
|
45
50
|
* });
|
|
46
51
|
*/
|
|
47
|
-
export declare function emitElement<Name extends
|
|
52
|
+
export declare function emitElement<Name extends keyof HTMLElementTagNameMap | 'math' | 'svg'>(
|
|
53
|
+
name: Name,
|
|
54
|
+
): {
|
|
55
|
+
element: Name extends 'math'
|
|
56
|
+
? MathMlElementForTagName<'math'>
|
|
57
|
+
: Name extends 'svg'
|
|
58
|
+
? SVGElementForTagName<'svg'>
|
|
59
|
+
: ElementForTagName<Name>;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export declare function emitSVGElement<Name extends keyof SVGElementTagNameMap>(
|
|
63
|
+
name: Name,
|
|
64
|
+
): { element: SVGElementForTagName<Name> };
|
|
65
|
+
|
|
66
|
+
export declare function emitMathMlElement<Name extends keyof MathMLElementTagNameMap>(
|
|
48
67
|
name: Name,
|
|
49
|
-
): { element:
|
|
68
|
+
): { element: MathMlElementForTagName<Name> };
|
|
50
69
|
|
|
51
70
|
/*
|
|
52
71
|
* Emits the given value as an entity that expects to receive blocks
|
|
@@ -60,8 +79,8 @@ export declare function emitElement<Name extends string>(
|
|
|
60
79
|
* This form of invocation is the only one in a template that may have
|
|
61
80
|
* blocks bound to it. The final line above would produce code like:
|
|
62
81
|
*
|
|
63
|
-
* emitComponent(resolve(Value)({ foo: bar })), (
|
|
64
|
-
* applyModifier(
|
|
82
|
+
* emitComponent(resolve(Value)({ foo: bar })), (__glintY__) => {
|
|
83
|
+
* applyModifier(__glintY__.element, resolve(baz)({}));
|
|
65
84
|
* });
|
|
66
85
|
*/
|
|
67
86
|
export declare function emitComponent<T extends ComponentReturn<any, any>>(
|
|
@@ -81,7 +100,9 @@ export declare function emitComponent<T extends ComponentReturn<any, any>>(
|
|
|
81
100
|
export declare function templateExpression<
|
|
82
101
|
Signature extends AnyFunction = () => ComponentReturn<{}>,
|
|
83
102
|
Context extends AnyContext = TemplateContext<void, {}, {}, void>,
|
|
84
|
-
>(
|
|
103
|
+
>(
|
|
104
|
+
f: (__glintRef__: Context, __glintDSL__: never) => void,
|
|
105
|
+
): new () => InvokableInstance<Signature> & HasContext<Context>;
|
|
85
106
|
|
|
86
107
|
/*
|
|
87
108
|
* Wraps a template body that's backed by a known value (typically a class), either
|
|
@@ -98,7 +119,7 @@ export declare function templateExpression<
|
|
|
98
119
|
*/
|
|
99
120
|
export declare function templateForBackingValue<Args extends unknown[], Context extends AnyContext>(
|
|
100
121
|
backingValue: abstract new (...args: Args) => HasContext<Context>,
|
|
101
|
-
body: (
|
|
122
|
+
body: (__glintRef__: Context, __glintDSL__: never) => void,
|
|
102
123
|
): abstract new () => unknown;
|
|
103
124
|
|
|
104
125
|
/*
|
|
@@ -108,10 +129,10 @@ export declare function templateForBackingValue<Args extends unknown[], Context
|
|
|
108
129
|
*
|
|
109
130
|
* Is equivalent to:
|
|
110
131
|
*
|
|
111
|
-
* yieldToBlock(
|
|
132
|
+
* yieldToBlock(__glintRef__, 'name')(foo, bar);
|
|
112
133
|
*/
|
|
113
134
|
export declare function yieldToBlock<Context extends AnyContext, K extends keyof Context['blocks']>(
|
|
114
|
-
|
|
135
|
+
__glintRef__: Context,
|
|
115
136
|
to: K,
|
|
116
137
|
): (...values: NonNullable<Context['blocks'][K]>) => void;
|
|
117
138
|
|
|
@@ -133,7 +154,10 @@ export declare function applySplattributes<
|
|
|
133
154
|
* <div foo={{bar}}></div>
|
|
134
155
|
* <AnotherComponent foo={{bar}} />
|
|
135
156
|
*/
|
|
136
|
-
export declare function applyAttributes
|
|
157
|
+
export declare function applyAttributes<T extends Element>(
|
|
158
|
+
element: T,
|
|
159
|
+
attrs: Partial<AttributesForElement<T>>,
|
|
160
|
+
): void;
|
|
137
161
|
|
|
138
162
|
/*
|
|
139
163
|
* Applies a modifier to an element or component.
|