1 | /**
|
2 | * A free variable is resolved according to a resolution rule:
|
3 | *
|
4 | * 1. Strict resolution
|
5 | * 2. Namespaced resolution
|
6 | * 3. Fallback resolution
|
7 | */
|
8 | import { GetContextualFreeOp } from '@glimmer/interfaces';
|
9 | /**
|
10 | * Strict resolution is used:
|
11 | *
|
12 | * 1. in a strict mode template
|
13 | * 2. in an unambiguous invocation with dot paths
|
14 | */
|
15 | export declare class StrictResolution {
|
16 | resolution(): GetContextualFreeOp;
|
17 | serialize(): SerializedResolution;
|
18 | readonly isAngleBracket = false;
|
19 | }
|
20 | export declare const STRICT_RESOLUTION: StrictResolution;
|
21 | /**
|
22 | * A `LooseModeResolution` includes:
|
23 | *
|
24 | * - 0 or more namespaces to resolve the variable in
|
25 | * - optional fallback behavior
|
26 | *
|
27 | * In practice, there are a limited number of possible combinations of these degrees of freedom,
|
28 | * and they are captured by the `Ambiguity` union below.
|
29 | */
|
30 | export declare class LooseModeResolution {
|
31 | readonly ambiguity: Ambiguity;
|
32 | readonly isAngleBracket: boolean;
|
33 | /**
|
34 | * Namespaced resolution is used in an unambiguous syntax position:
|
35 | *
|
36 | * 1. `(sexp)` (namespace: `Helper`)
|
37 | * 2. `{{#block}}` (namespace: `Component`)
|
38 | * 3. `<a {{modifier}}>` (namespace: `Modifier`)
|
39 | * 4. `<Component />` (namespace: `Component`)
|
40 | *
|
41 | * @see {NamespacedAmbiguity}
|
42 | */
|
43 | static namespaced(namespace: FreeVarNamespace, isAngleBracket?: boolean): LooseModeResolution;
|
44 | /**
|
45 | * Fallback resolution is used when no namespaced resolutions are possible, but fallback
|
46 | * resolution is still allowed.
|
47 | *
|
48 | * ```hbs
|
49 | * {{x.y}}
|
50 | * ```
|
51 | *
|
52 | * @see {FallbackAmbiguity}
|
53 | */
|
54 | static fallback(): LooseModeResolution;
|
55 | /**
|
56 | * Append resolution is used when the variable should be resolved in both the `component` and
|
57 | * `helper` namespaces. Fallback resolution is optional.
|
58 | *
|
59 | * ```hbs
|
60 | * {{x}}
|
61 | * ```
|
62 | *
|
63 | * ^ `x` should be resolved in the `component` and `helper` namespaces with fallback resolution.
|
64 | *
|
65 | * ```hbs
|
66 | * {{x y}}
|
67 | * ```
|
68 | *
|
69 | * ^ `x` should be resolved in the `component` and `helper` namespaces without fallback
|
70 | * resolution.
|
71 | *
|
72 | * @see {ComponentOrHelperAmbiguity}
|
73 | */
|
74 | static append({ invoke }: {
|
75 | invoke: boolean;
|
76 | }): LooseModeResolution;
|
77 | /**
|
78 | * Trusting append resolution is used when the variable should be resolved in both the `component` and
|
79 | * `helper` namespaces. Fallback resolution is optional.
|
80 | *
|
81 | * ```hbs
|
82 | * {{{x}}}
|
83 | * ```
|
84 | *
|
85 | * ^ `x` should be resolved in the `component` and `helper` namespaces with fallback resolution.
|
86 | *
|
87 | * ```hbs
|
88 | * {{{x y}}}
|
89 | * ```
|
90 | *
|
91 | * ^ `x` should be resolved in the `component` and `helper` namespaces without fallback
|
92 | * resolution.
|
93 | *
|
94 | * @see {HelperAmbiguity}
|
95 | */
|
96 | static trustingAppend({ invoke }: {
|
97 | invoke: boolean;
|
98 | }): LooseModeResolution;
|
99 | /**
|
100 | * Attribute resolution is used when the variable should be resolved as a `helper` with fallback
|
101 | * resolution.
|
102 | *
|
103 | * ```hbs
|
104 | * <a href={{x}} />
|
105 | * <a href="{{x}}.html" />
|
106 | * ```
|
107 | *
|
108 | * ^ resolved in the `helper` namespace with fallback
|
109 | *
|
110 | * @see {HelperAmbiguity}
|
111 | */
|
112 | static attr(): LooseModeResolution;
|
113 | constructor(ambiguity: Ambiguity, isAngleBracket?: boolean);
|
114 | resolution(): GetContextualFreeOp;
|
115 | serialize(): SerializedResolution;
|
116 | }
|
117 | export declare const ARGUMENT_RESOLUTION: LooseModeResolution;
|
118 | export declare const enum FreeVarNamespace {
|
119 | Helper = "Helper",
|
120 | Modifier = "Modifier",
|
121 | Component = "Component"
|
122 | }
|
123 | /**
|
124 | * A `ComponentOrHelperAmbiguity` might be a component or a helper, with an optional fallback
|
125 | *
|
126 | * ```hbs
|
127 | * {{x}}
|
128 | * ```
|
129 | *
|
130 | * ^ `x` is resolved in the `component` and `helper` namespaces, with fallback
|
131 | *
|
132 | * ```hbs
|
133 | * {{x y}}
|
134 | * ```
|
135 | *
|
136 | * ^ `x` is resolved in the `component` and `helper` namespaces, without fallback
|
137 | */
|
138 | declare type ComponentOrHelperAmbiguity = {
|
139 | namespaces: [FreeVarNamespace.Component, FreeVarNamespace.Helper];
|
140 | fallback: boolean;
|
141 | };
|
142 | /**
|
143 | * A `HelperAmbiguity` must be a helper, but it has fallback. If it didn't have fallback, it would
|
144 | * be a `NamespacedAmbiguity`.
|
145 | *
|
146 | * ```hbs
|
147 | * <a href={{x}} />
|
148 | * <a href="{{x}}.html" />
|
149 | * ```
|
150 | *
|
151 | * ^ `x` is resolved in the `helper` namespace with fallback
|
152 | */
|
153 | declare type HelperAmbiguity = {
|
154 | namespaces: [FreeVarNamespace.Helper];
|
155 | fallback: boolean;
|
156 | };
|
157 | /**
|
158 | * A `NamespacedAmbiguity` must be resolved in a particular namespace, without fallback.
|
159 | *
|
160 | * ```hbs
|
161 | * <X />
|
162 | * ```
|
163 | *
|
164 | * ^ `X` is resolved in the `component` namespace without fallback
|
165 | *
|
166 | * ```hbs
|
167 | * (x)
|
168 | * ```
|
169 | *
|
170 | * ^ `x` is resolved in the `helper` namespace without fallback
|
171 | *
|
172 | * ```hbs
|
173 | * <a {{x}} />
|
174 | * ```
|
175 | *
|
176 | * ^ `x` is resolved in the `modifier` namespace without fallback
|
177 | */
|
178 | declare type NamespacedAmbiguity = {
|
179 | namespaces: [FreeVarNamespace.Component | FreeVarNamespace.Helper | FreeVarNamespace.Modifier];
|
180 | fallback: false;
|
181 | };
|
182 | declare type FallbackAmbiguity = {
|
183 | namespaces: [];
|
184 | fallback: true;
|
185 | };
|
186 | declare type Ambiguity = ComponentOrHelperAmbiguity | HelperAmbiguity | NamespacedAmbiguity | FallbackAmbiguity;
|
187 | export declare type FreeVarResolution = StrictResolution | LooseModeResolution;
|
188 | declare const enum SerializedAmbiguity {
|
189 | Append = "Append",
|
190 | Attr = "Attr",
|
191 | Invoke = "Invoke"
|
192 | }
|
193 | export declare type SerializedResolution = 'Strict' | 'Loose' | ['ns', FreeVarNamespace] | ['ambiguous', SerializedAmbiguity];
|
194 | export declare function loadResolution(resolution: SerializedResolution): FreeVarResolution;
|
195 | export {};
|
196 | //# sourceMappingURL=resolution.d.ts.map |
\ | No newline at end of file |