fg-dynamic-component 2.0.0 → 4.0.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/README.md +164 -4
- package/fesm2022/fg-dynamic-component.mjs +2496 -459
- package/fesm2022/fg-dynamic-component.mjs.map +1 -1
- package/package.json +6 -4
- package/types/fg-dynamic-component.d.ts +395 -110
|
@@ -1,465 +1,2502 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import {
|
|
3
|
-
import { FormControlDirective,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, ElementRef, Injector, Renderer2, ViewContainerRef, computed, inject, input, isDevMode, model, viewChild, viewChildren } from "@angular/core";
|
|
3
|
+
import { FormControl, FormControlDirective, FormGroup, NG_VALUE_ACCESSOR, NgControl, Validators } from "@angular/forms";
|
|
4
|
+
const MAX_SOURCE_LENGTH = 2e3;
|
|
5
|
+
const MAX_TOKENS = 4e3;
|
|
6
|
+
const MAX_PARSE_DEPTH = 80;
|
|
7
|
+
const MAX_EVALUATION_STEPS = 2e4;
|
|
8
|
+
const MAX_EVALUATION_DEPTH = 80;
|
|
9
|
+
const MAX_STRING_LENGTH = 1e5;
|
|
10
|
+
const MAX_REPEAT_COUNT = 1e4;
|
|
11
|
+
const FORBIDDEN_PROPERTIES = /* @__PURE__ */ new Set([
|
|
12
|
+
"__proto__",
|
|
13
|
+
"prototype",
|
|
14
|
+
"constructor",
|
|
15
|
+
"caller",
|
|
16
|
+
"callee",
|
|
17
|
+
"arguments",
|
|
18
|
+
"__defineGetter__",
|
|
19
|
+
"__defineSetter__",
|
|
20
|
+
"__lookupGetter__",
|
|
21
|
+
"__lookupSetter__",
|
|
22
|
+
"call",
|
|
23
|
+
"apply",
|
|
24
|
+
"bind",
|
|
25
|
+
"window",
|
|
26
|
+
"self",
|
|
27
|
+
"globalThis",
|
|
28
|
+
"global",
|
|
29
|
+
"top",
|
|
30
|
+
"parent",
|
|
31
|
+
"frames",
|
|
32
|
+
"opener",
|
|
33
|
+
"document",
|
|
34
|
+
"ownerDocument",
|
|
35
|
+
"defaultView",
|
|
36
|
+
"contentWindow",
|
|
37
|
+
"contentDocument",
|
|
38
|
+
"location",
|
|
39
|
+
"cookie",
|
|
40
|
+
"localStorage",
|
|
41
|
+
"sessionStorage",
|
|
42
|
+
"indexedDB",
|
|
43
|
+
"navigator",
|
|
44
|
+
"history",
|
|
45
|
+
"screen",
|
|
46
|
+
"fetch",
|
|
47
|
+
"XMLHttpRequest",
|
|
48
|
+
"WebSocket",
|
|
49
|
+
"Worker",
|
|
50
|
+
"importScripts",
|
|
51
|
+
"postMessage",
|
|
52
|
+
"sendBeacon",
|
|
53
|
+
"setTimeout",
|
|
54
|
+
"setInterval",
|
|
55
|
+
"setImmediate",
|
|
56
|
+
"requestAnimationFrame",
|
|
57
|
+
"open",
|
|
58
|
+
"close",
|
|
59
|
+
"write",
|
|
60
|
+
"writeln",
|
|
61
|
+
"innerHTML",
|
|
62
|
+
"outerHTML",
|
|
63
|
+
"insertAdjacentHTML",
|
|
64
|
+
"eval",
|
|
65
|
+
"Function"
|
|
66
|
+
]);
|
|
67
|
+
const SAFE_NATIVE_METHODS = /* @__PURE__ */ new Set([
|
|
68
|
+
Array.prototype.at,
|
|
69
|
+
Array.prototype.concat,
|
|
70
|
+
Array.prototype.entries,
|
|
71
|
+
Array.prototype.every,
|
|
72
|
+
Array.prototype.filter,
|
|
73
|
+
Array.prototype.find,
|
|
74
|
+
Array.prototype.findIndex,
|
|
75
|
+
Array.prototype.flat,
|
|
76
|
+
Array.prototype.flatMap,
|
|
77
|
+
Array.prototype.forEach,
|
|
78
|
+
Array.prototype.includes,
|
|
79
|
+
Array.prototype.indexOf,
|
|
80
|
+
Array.prototype.join,
|
|
81
|
+
Array.prototype.keys,
|
|
82
|
+
Array.prototype.lastIndexOf,
|
|
83
|
+
Array.prototype.map,
|
|
84
|
+
Array.prototype.reduce,
|
|
85
|
+
Array.prototype.reduceRight,
|
|
86
|
+
Array.prototype.slice,
|
|
87
|
+
Array.prototype.some,
|
|
88
|
+
Array.prototype.toLocaleString,
|
|
89
|
+
Array.prototype.toString,
|
|
90
|
+
Array.prototype.values,
|
|
91
|
+
String.prototype.at,
|
|
92
|
+
String.prototype.charAt,
|
|
93
|
+
String.prototype.charCodeAt,
|
|
94
|
+
String.prototype.codePointAt,
|
|
95
|
+
String.prototype.concat,
|
|
96
|
+
String.prototype.endsWith,
|
|
97
|
+
String.prototype.includes,
|
|
98
|
+
String.prototype.indexOf,
|
|
99
|
+
String.prototype.lastIndexOf,
|
|
100
|
+
String.prototype.localeCompare,
|
|
101
|
+
String.prototype.normalize,
|
|
102
|
+
String.prototype.padEnd,
|
|
103
|
+
String.prototype.padStart,
|
|
104
|
+
String.prototype.repeat,
|
|
105
|
+
String.prototype.replace,
|
|
106
|
+
String.prototype.replaceAll,
|
|
107
|
+
String.prototype.slice,
|
|
108
|
+
String.prototype.split,
|
|
109
|
+
String.prototype.startsWith,
|
|
110
|
+
String.prototype.substring,
|
|
111
|
+
String.prototype.substr,
|
|
112
|
+
String.prototype.toLocaleLowerCase,
|
|
113
|
+
String.prototype.toLocaleUpperCase,
|
|
114
|
+
String.prototype.toLowerCase,
|
|
115
|
+
String.prototype.toString,
|
|
116
|
+
String.prototype.toUpperCase,
|
|
117
|
+
String.prototype.trim,
|
|
118
|
+
String.prototype.trimEnd,
|
|
119
|
+
String.prototype.trimStart,
|
|
120
|
+
String.prototype.valueOf,
|
|
121
|
+
Number.prototype.toExponential,
|
|
122
|
+
Number.prototype.toFixed,
|
|
123
|
+
Number.prototype.toLocaleString,
|
|
124
|
+
Number.prototype.toPrecision,
|
|
125
|
+
Number.prototype.toString,
|
|
126
|
+
Number.prototype.valueOf,
|
|
127
|
+
Boolean.prototype.toString,
|
|
128
|
+
Boolean.prototype.valueOf,
|
|
129
|
+
BigInt.prototype.toString,
|
|
130
|
+
BigInt.prototype.valueOf,
|
|
131
|
+
Date.prototype.getDate,
|
|
132
|
+
Date.prototype.getDay,
|
|
133
|
+
Date.prototype.getFullYear,
|
|
134
|
+
Date.prototype.getHours,
|
|
135
|
+
Date.prototype.getMilliseconds,
|
|
136
|
+
Date.prototype.getMinutes,
|
|
137
|
+
Date.prototype.getMonth,
|
|
138
|
+
Date.prototype.getSeconds,
|
|
139
|
+
Date.prototype.getTime,
|
|
140
|
+
Date.prototype.getUTCDate,
|
|
141
|
+
Date.prototype.getUTCFullYear,
|
|
142
|
+
Date.prototype.toISOString,
|
|
143
|
+
Date.prototype.toJSON,
|
|
144
|
+
Date.prototype.toLocaleDateString,
|
|
145
|
+
Date.prototype.toLocaleString,
|
|
146
|
+
Date.prototype.toLocaleTimeString,
|
|
147
|
+
Date.prototype.toString,
|
|
148
|
+
Date.prototype.valueOf,
|
|
149
|
+
Object.prototype.hasOwnProperty,
|
|
150
|
+
Object.prototype.isPrototypeOf,
|
|
151
|
+
Object.prototype.propertyIsEnumerable,
|
|
152
|
+
Object.prototype.toLocaleString,
|
|
153
|
+
Object.prototype.toString,
|
|
154
|
+
Object.prototype.valueOf
|
|
155
|
+
]);
|
|
156
|
+
const INTERPRETER_FUNCTIONS = /* @__PURE__ */ new WeakSet();
|
|
157
|
+
const HOST_OBJECT_TAGS = /* @__PURE__ */ new Set([
|
|
158
|
+
"Window",
|
|
159
|
+
"global",
|
|
160
|
+
"globalThis",
|
|
161
|
+
"Document",
|
|
162
|
+
"HTMLDocument",
|
|
163
|
+
"XMLDocument",
|
|
164
|
+
"DocumentFragment",
|
|
165
|
+
"DocumentType",
|
|
166
|
+
"Node",
|
|
167
|
+
"NodeList",
|
|
168
|
+
"HTMLCollection",
|
|
169
|
+
"NamedNodeMap",
|
|
170
|
+
"Element",
|
|
171
|
+
"Event",
|
|
172
|
+
"EventTarget",
|
|
173
|
+
"CustomEvent",
|
|
174
|
+
"MouseEvent",
|
|
175
|
+
"KeyboardEvent",
|
|
176
|
+
"PointerEvent",
|
|
177
|
+
"FocusEvent",
|
|
178
|
+
"InputEvent",
|
|
179
|
+
"Storage",
|
|
180
|
+
"Location",
|
|
181
|
+
"History",
|
|
182
|
+
"Navigator",
|
|
183
|
+
"Screen",
|
|
184
|
+
"XMLHttpRequest",
|
|
185
|
+
"WebSocket",
|
|
186
|
+
"Worker",
|
|
187
|
+
"MessagePort",
|
|
188
|
+
"MessageChannel",
|
|
189
|
+
"File",
|
|
190
|
+
"FileList",
|
|
191
|
+
"FileReader",
|
|
192
|
+
"Blob",
|
|
193
|
+
"FormData",
|
|
194
|
+
"URL",
|
|
195
|
+
"URLSearchParams",
|
|
196
|
+
"MutationObserver",
|
|
197
|
+
"IntersectionObserver",
|
|
198
|
+
"ResizeObserver",
|
|
199
|
+
"Performance"
|
|
200
|
+
]);
|
|
201
|
+
function isHostObject(value) {
|
|
202
|
+
if (value == null || typeof value !== "object" && typeof value !== "function") return false;
|
|
203
|
+
if (value === globalThis) return true;
|
|
204
|
+
try {
|
|
205
|
+
const tag = Object.prototype.toString.call(value).slice(8, -1);
|
|
206
|
+
if (HOST_OBJECT_TAGS.has(tag)) return true;
|
|
207
|
+
if (/(?:Element|Event|Document|Node|Observer|Collection|List|Map)$/.test(tag) && tag !== "Map" && tag !== "WeakMap" && tag !== "Set" && tag !== "WeakSet") return true;
|
|
208
|
+
} catch {
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
return false;
|
|
18
212
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
213
|
+
function isNativeFunction(value) {
|
|
214
|
+
return typeof value === "function" && SAFE_NATIVE_METHODS.has(value);
|
|
215
|
+
}
|
|
216
|
+
function isInterpreterFunction(value) {
|
|
217
|
+
return typeof value === "function" && INTERPRETER_FUNCTIONS.has(value);
|
|
218
|
+
}
|
|
219
|
+
function assertSafeValue(value) {
|
|
220
|
+
if (isHostObject(value)) fail("Access to host objects is not allowed.");
|
|
221
|
+
return value;
|
|
222
|
+
}
|
|
223
|
+
const PUNCTUATORS = [
|
|
224
|
+
"===",
|
|
225
|
+
"!==",
|
|
226
|
+
"**",
|
|
227
|
+
"==",
|
|
228
|
+
"!=",
|
|
229
|
+
"<=",
|
|
230
|
+
">=",
|
|
231
|
+
"&&",
|
|
232
|
+
"||",
|
|
233
|
+
"??",
|
|
234
|
+
"?.",
|
|
235
|
+
"...",
|
|
236
|
+
"=>",
|
|
237
|
+
"+",
|
|
238
|
+
"-",
|
|
239
|
+
"*",
|
|
240
|
+
"/",
|
|
241
|
+
"%",
|
|
242
|
+
"<",
|
|
243
|
+
">",
|
|
244
|
+
"!",
|
|
245
|
+
"?",
|
|
246
|
+
":",
|
|
247
|
+
".",
|
|
248
|
+
",",
|
|
249
|
+
"(",
|
|
250
|
+
")",
|
|
251
|
+
"[",
|
|
252
|
+
"]",
|
|
253
|
+
"{",
|
|
254
|
+
"}",
|
|
255
|
+
";"
|
|
256
|
+
];
|
|
257
|
+
var FGDynamicExpressionError = class extends Error {
|
|
258
|
+
constructor(message) {
|
|
259
|
+
super(message);
|
|
260
|
+
this.name = "FGDynamicExpressionError";
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
function fail(message) {
|
|
264
|
+
throw new FGDynamicExpressionError(message);
|
|
265
|
+
}
|
|
266
|
+
function isPunctuator(token, value) {
|
|
267
|
+
return token.type === "punctuator" && token.value === value;
|
|
268
|
+
}
|
|
269
|
+
function isIdentifier(token, value) {
|
|
270
|
+
return token.type === "identifier" && token.value === value;
|
|
271
|
+
}
|
|
272
|
+
function tokenize(source) {
|
|
273
|
+
const tokens = [];
|
|
274
|
+
let index = 0;
|
|
275
|
+
while (index < source.length) {
|
|
276
|
+
const character = source[index];
|
|
277
|
+
if (/\s/.test(character)) {
|
|
278
|
+
index++;
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
if (character === "\"" || character === "'") {
|
|
282
|
+
const quote = character;
|
|
283
|
+
let value = "";
|
|
284
|
+
let cursor = index + 1;
|
|
285
|
+
let closed = false;
|
|
286
|
+
while (cursor < source.length) {
|
|
287
|
+
const current = source[cursor];
|
|
288
|
+
if (current === quote) {
|
|
289
|
+
cursor++;
|
|
290
|
+
closed = true;
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
if (current === "\\") {
|
|
294
|
+
const escaped = source[cursor + 1];
|
|
295
|
+
if (escaped === void 0) fail("Unterminated string literal.");
|
|
296
|
+
switch (escaped) {
|
|
297
|
+
case "n":
|
|
298
|
+
value += "\n";
|
|
299
|
+
break;
|
|
300
|
+
case "r":
|
|
301
|
+
value += "\r";
|
|
302
|
+
break;
|
|
303
|
+
case "t":
|
|
304
|
+
value += " ";
|
|
305
|
+
break;
|
|
306
|
+
case "b":
|
|
307
|
+
value += "\b";
|
|
308
|
+
break;
|
|
309
|
+
case "f":
|
|
310
|
+
value += "\f";
|
|
311
|
+
break;
|
|
312
|
+
case "v":
|
|
313
|
+
value += "\v";
|
|
314
|
+
break;
|
|
315
|
+
case "0":
|
|
316
|
+
value += "\0";
|
|
317
|
+
break;
|
|
318
|
+
case "u": {
|
|
319
|
+
const hex = source.slice(cursor + 2, cursor + 6);
|
|
320
|
+
if (!/^[0-9a-fA-F]{4}$/.test(hex)) fail("Invalid unicode escape sequence.");
|
|
321
|
+
value += String.fromCharCode(parseInt(hex, 16));
|
|
322
|
+
cursor += 4;
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
default: value += escaped;
|
|
326
|
+
}
|
|
327
|
+
cursor += 2;
|
|
328
|
+
continue;
|
|
329
|
+
}
|
|
330
|
+
value += current;
|
|
331
|
+
cursor++;
|
|
332
|
+
}
|
|
333
|
+
if (!closed) fail("Unterminated string literal.");
|
|
334
|
+
tokens.push({
|
|
335
|
+
type: "string",
|
|
336
|
+
value,
|
|
337
|
+
position: index
|
|
338
|
+
});
|
|
339
|
+
index = cursor;
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
if (/[0-9]/.test(character) || character === "." && /[0-9]/.test(source[index + 1] ?? "")) {
|
|
343
|
+
const match = /^(?:0[xX][0-9a-fA-F]+|(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)/.exec(source.slice(index));
|
|
344
|
+
if (!match) fail("Invalid number literal.");
|
|
345
|
+
const raw = match[0];
|
|
346
|
+
const numeric = Number(raw);
|
|
347
|
+
if (!Number.isFinite(numeric)) fail("Number literal is not finite.");
|
|
348
|
+
tokens.push({
|
|
349
|
+
type: "number",
|
|
350
|
+
value: raw,
|
|
351
|
+
position: index
|
|
352
|
+
});
|
|
353
|
+
index += raw.length;
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
if (/[A-Za-z_$]/.test(character)) {
|
|
357
|
+
const match = /^[A-Za-z_$][A-Za-z0-9_$]*/.exec(source.slice(index));
|
|
358
|
+
if (!match) fail("Invalid identifier.");
|
|
359
|
+
tokens.push({
|
|
360
|
+
type: "identifier",
|
|
361
|
+
value: match[0],
|
|
362
|
+
position: index
|
|
363
|
+
});
|
|
364
|
+
index += match[0].length;
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
const punctuator = PUNCTUATORS.find((candidate) => source.startsWith(candidate, index));
|
|
368
|
+
if (!punctuator) fail("Unexpected character in expression.");
|
|
369
|
+
tokens.push({
|
|
370
|
+
type: "punctuator",
|
|
371
|
+
value: punctuator,
|
|
372
|
+
position: index
|
|
373
|
+
});
|
|
374
|
+
index += punctuator.length;
|
|
375
|
+
}
|
|
376
|
+
tokens.push({
|
|
377
|
+
type: "eof",
|
|
378
|
+
value: "",
|
|
379
|
+
position: source.length
|
|
380
|
+
});
|
|
381
|
+
if (tokens.length > MAX_TOKENS) fail("Expression is too complex.");
|
|
382
|
+
return tokens;
|
|
383
|
+
}
|
|
384
|
+
var ExpressionParser = class {
|
|
385
|
+
constructor(tokens) {
|
|
386
|
+
this.index = 0;
|
|
387
|
+
this.depth = 0;
|
|
388
|
+
this.tokens = tokens;
|
|
389
|
+
}
|
|
390
|
+
parse() {
|
|
391
|
+
const expression = this.parseExpression();
|
|
392
|
+
if (this.current().type !== "eof") fail("Unexpected token after expression.");
|
|
393
|
+
return expression;
|
|
394
|
+
}
|
|
395
|
+
current() {
|
|
396
|
+
return this.tokens[this.index];
|
|
397
|
+
}
|
|
398
|
+
peek(offset = 1) {
|
|
399
|
+
return this.tokens[this.index + offset];
|
|
400
|
+
}
|
|
401
|
+
advance() {
|
|
402
|
+
const token = this.tokens[this.index];
|
|
403
|
+
if (token.type !== "eof") this.index++;
|
|
404
|
+
return token;
|
|
405
|
+
}
|
|
406
|
+
matchPunctuator(value) {
|
|
407
|
+
if (isPunctuator(this.current(), value)) {
|
|
408
|
+
this.advance();
|
|
409
|
+
return true;
|
|
410
|
+
}
|
|
411
|
+
return false;
|
|
412
|
+
}
|
|
413
|
+
expectPunctuator(value) {
|
|
414
|
+
if (!this.matchPunctuator(value)) fail(`Expected "${value}".`);
|
|
415
|
+
}
|
|
416
|
+
enter() {
|
|
417
|
+
this.depth++;
|
|
418
|
+
if (this.depth > MAX_PARSE_DEPTH) fail("Expression is nested too deeply.");
|
|
419
|
+
}
|
|
420
|
+
leave() {
|
|
421
|
+
this.depth--;
|
|
422
|
+
}
|
|
423
|
+
parseExpression() {
|
|
424
|
+
this.enter();
|
|
425
|
+
try {
|
|
426
|
+
return this.parseAssignment();
|
|
427
|
+
} finally {
|
|
428
|
+
this.leave();
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
parseAssignment() {
|
|
432
|
+
if (this.isArrowStart()) return this.parseArrow();
|
|
433
|
+
return this.parseConditional();
|
|
434
|
+
}
|
|
435
|
+
isArrowStart() {
|
|
436
|
+
const token = this.current();
|
|
437
|
+
if (token.type === "identifier" && this.peek()?.value === "=>") return true;
|
|
438
|
+
if (!isPunctuator(token, "(")) return false;
|
|
439
|
+
let nesting = 0;
|
|
440
|
+
for (let cursor = this.index; cursor < this.tokens.length; cursor++) {
|
|
441
|
+
const candidate = this.tokens[cursor];
|
|
442
|
+
if (candidate.type !== "punctuator") continue;
|
|
443
|
+
if (candidate.value === "(") nesting++;
|
|
444
|
+
else if (candidate.value === ")") {
|
|
445
|
+
nesting--;
|
|
446
|
+
if (nesting === 0) return this.tokens[cursor + 1]?.value === "=>";
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
return false;
|
|
450
|
+
}
|
|
451
|
+
parseArrow() {
|
|
452
|
+
const params = [];
|
|
453
|
+
if (this.current().type === "identifier") params.push(this.advance().value);
|
|
454
|
+
else {
|
|
455
|
+
this.expectPunctuator("(");
|
|
456
|
+
if (!isPunctuator(this.current(), ")")) do {
|
|
457
|
+
if (isPunctuator(this.current(), ")")) break;
|
|
458
|
+
const parameter = this.advance();
|
|
459
|
+
if (parameter.type !== "identifier") fail("Arrow function parameters must be identifiers.");
|
|
460
|
+
if (FORBIDDEN_PROPERTIES.has(parameter.value)) fail("Forbidden arrow function parameter name.");
|
|
461
|
+
params.push(parameter.value);
|
|
462
|
+
} while (this.matchPunctuator(","));
|
|
463
|
+
this.expectPunctuator(")");
|
|
464
|
+
}
|
|
465
|
+
this.expectPunctuator("=>");
|
|
466
|
+
if (this.matchPunctuator("{")) {
|
|
467
|
+
while (this.matchPunctuator(";"));
|
|
468
|
+
if (!isIdentifier(this.current(), "return")) fail("Arrow function blocks must contain a return statement.");
|
|
469
|
+
this.advance();
|
|
470
|
+
const value = this.parseExpression();
|
|
471
|
+
this.matchPunctuator(";");
|
|
472
|
+
this.expectPunctuator("}");
|
|
473
|
+
return {
|
|
474
|
+
type: "Arrow",
|
|
475
|
+
params,
|
|
476
|
+
body: value,
|
|
477
|
+
block: true
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
return {
|
|
481
|
+
type: "Arrow",
|
|
482
|
+
params,
|
|
483
|
+
body: this.parseExpression(),
|
|
484
|
+
block: false
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
parseConditional() {
|
|
488
|
+
const test = this.parseNullish();
|
|
489
|
+
if (this.matchPunctuator("?")) {
|
|
490
|
+
const consequent = this.parseAssignment();
|
|
491
|
+
this.expectPunctuator(":");
|
|
492
|
+
return {
|
|
493
|
+
type: "Conditional",
|
|
494
|
+
test,
|
|
495
|
+
consequent,
|
|
496
|
+
alternate: this.parseAssignment()
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
return test;
|
|
500
|
+
}
|
|
501
|
+
parseNullish() {
|
|
502
|
+
let left = this.parseLogicalOr();
|
|
503
|
+
while (this.matchPunctuator("??")) {
|
|
504
|
+
const right = this.parseLogicalOr();
|
|
505
|
+
left = {
|
|
506
|
+
type: "Logical",
|
|
507
|
+
operator: "??",
|
|
508
|
+
left,
|
|
509
|
+
right
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
return left;
|
|
513
|
+
}
|
|
514
|
+
parseLogicalOr() {
|
|
515
|
+
let left = this.parseLogicalAnd();
|
|
516
|
+
while (this.matchPunctuator("||")) {
|
|
517
|
+
const right = this.parseLogicalAnd();
|
|
518
|
+
left = {
|
|
519
|
+
type: "Logical",
|
|
520
|
+
operator: "||",
|
|
521
|
+
left,
|
|
522
|
+
right
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
return left;
|
|
526
|
+
}
|
|
527
|
+
parseLogicalAnd() {
|
|
528
|
+
let left = this.parseEquality();
|
|
529
|
+
while (this.matchPunctuator("&&")) {
|
|
530
|
+
const right = this.parseEquality();
|
|
531
|
+
left = {
|
|
532
|
+
type: "Logical",
|
|
533
|
+
operator: "&&",
|
|
534
|
+
left,
|
|
535
|
+
right
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
return left;
|
|
539
|
+
}
|
|
540
|
+
parseEquality() {
|
|
541
|
+
let left = this.parseRelational();
|
|
542
|
+
while (isPunctuator(this.current(), "===") || isPunctuator(this.current(), "!==") || isPunctuator(this.current(), "==") || isPunctuator(this.current(), "!=")) {
|
|
543
|
+
const operator = this.advance().value;
|
|
544
|
+
const right = this.parseRelational();
|
|
545
|
+
left = {
|
|
546
|
+
type: "Binary",
|
|
547
|
+
operator,
|
|
548
|
+
left,
|
|
549
|
+
right
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
return left;
|
|
553
|
+
}
|
|
554
|
+
parseRelational() {
|
|
555
|
+
let left = this.parseAdditive();
|
|
556
|
+
while (isPunctuator(this.current(), "<") || isPunctuator(this.current(), ">") || isPunctuator(this.current(), "<=") || isPunctuator(this.current(), ">=")) {
|
|
557
|
+
const operator = this.advance().value;
|
|
558
|
+
const right = this.parseAdditive();
|
|
559
|
+
left = {
|
|
560
|
+
type: "Binary",
|
|
561
|
+
operator,
|
|
562
|
+
left,
|
|
563
|
+
right
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
return left;
|
|
567
|
+
}
|
|
568
|
+
parseAdditive() {
|
|
569
|
+
let left = this.parseMultiplicative();
|
|
570
|
+
while (isPunctuator(this.current(), "+") || isPunctuator(this.current(), "-")) {
|
|
571
|
+
const operator = this.advance().value;
|
|
572
|
+
const right = this.parseMultiplicative();
|
|
573
|
+
left = {
|
|
574
|
+
type: "Binary",
|
|
575
|
+
operator,
|
|
576
|
+
left,
|
|
577
|
+
right
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
return left;
|
|
581
|
+
}
|
|
582
|
+
parseMultiplicative() {
|
|
583
|
+
let left = this.parseExponent();
|
|
584
|
+
while (isPunctuator(this.current(), "*") || isPunctuator(this.current(), "/") || isPunctuator(this.current(), "%")) {
|
|
585
|
+
const operator = this.advance().value;
|
|
586
|
+
const right = this.parseExponent();
|
|
587
|
+
left = {
|
|
588
|
+
type: "Binary",
|
|
589
|
+
operator,
|
|
590
|
+
left,
|
|
591
|
+
right
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
return left;
|
|
595
|
+
}
|
|
596
|
+
parseExponent() {
|
|
597
|
+
const left = this.parseUnary();
|
|
598
|
+
if (this.matchPunctuator("**")) {
|
|
599
|
+
this.enter();
|
|
600
|
+
try {
|
|
601
|
+
return {
|
|
602
|
+
type: "Binary",
|
|
603
|
+
operator: "**",
|
|
604
|
+
left,
|
|
605
|
+
right: this.parseExponent()
|
|
606
|
+
};
|
|
607
|
+
} finally {
|
|
608
|
+
this.leave();
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
return left;
|
|
612
|
+
}
|
|
613
|
+
parseUnary() {
|
|
614
|
+
if (isPunctuator(this.current(), "!") || isPunctuator(this.current(), "-") || isPunctuator(this.current(), "+")) {
|
|
615
|
+
this.enter();
|
|
616
|
+
try {
|
|
617
|
+
return {
|
|
618
|
+
type: "Unary",
|
|
619
|
+
operator: this.advance().value,
|
|
620
|
+
argument: this.parseUnary()
|
|
621
|
+
};
|
|
622
|
+
} finally {
|
|
623
|
+
this.leave();
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
if (isIdentifier(this.current(), "typeof")) {
|
|
627
|
+
this.enter();
|
|
628
|
+
try {
|
|
629
|
+
this.advance();
|
|
630
|
+
return {
|
|
631
|
+
type: "Unary",
|
|
632
|
+
operator: "typeof",
|
|
633
|
+
argument: this.parseUnary()
|
|
634
|
+
};
|
|
635
|
+
} finally {
|
|
636
|
+
this.leave();
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
return this.parsePostfix();
|
|
640
|
+
}
|
|
641
|
+
parsePostfix() {
|
|
642
|
+
let node = this.parsePrimary();
|
|
643
|
+
for (;;) {
|
|
644
|
+
if (this.matchPunctuator(".")) {
|
|
645
|
+
const property = this.advance();
|
|
646
|
+
if (property.type !== "identifier") fail("Expected a property name.");
|
|
647
|
+
node = {
|
|
648
|
+
type: "Member",
|
|
649
|
+
object: node,
|
|
650
|
+
property: {
|
|
651
|
+
type: "Literal",
|
|
652
|
+
value: property.value
|
|
653
|
+
},
|
|
654
|
+
computed: false,
|
|
655
|
+
optional: false
|
|
656
|
+
};
|
|
657
|
+
continue;
|
|
658
|
+
}
|
|
659
|
+
if (this.matchPunctuator("?.")) {
|
|
660
|
+
if (this.matchPunctuator("(")) node = {
|
|
661
|
+
type: "Call",
|
|
662
|
+
callee: node,
|
|
663
|
+
args: this.parseArguments(),
|
|
664
|
+
optional: true
|
|
665
|
+
};
|
|
666
|
+
else if (this.matchPunctuator("[")) {
|
|
667
|
+
const property = this.parseExpression();
|
|
668
|
+
this.expectPunctuator("]");
|
|
669
|
+
node = {
|
|
670
|
+
type: "Member",
|
|
671
|
+
object: node,
|
|
672
|
+
property,
|
|
673
|
+
computed: true,
|
|
674
|
+
optional: true
|
|
675
|
+
};
|
|
676
|
+
} else {
|
|
677
|
+
const property = this.advance();
|
|
678
|
+
if (property.type !== "identifier") fail("Expected a property name.");
|
|
679
|
+
node = {
|
|
680
|
+
type: "Member",
|
|
681
|
+
object: node,
|
|
682
|
+
property: {
|
|
683
|
+
type: "Literal",
|
|
684
|
+
value: property.value
|
|
685
|
+
},
|
|
686
|
+
computed: false,
|
|
687
|
+
optional: true
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
continue;
|
|
691
|
+
}
|
|
692
|
+
if (this.matchPunctuator("[")) {
|
|
693
|
+
const property = this.parseExpression();
|
|
694
|
+
this.expectPunctuator("]");
|
|
695
|
+
node = {
|
|
696
|
+
type: "Member",
|
|
697
|
+
object: node,
|
|
698
|
+
property,
|
|
699
|
+
computed: true,
|
|
700
|
+
optional: false
|
|
701
|
+
};
|
|
702
|
+
continue;
|
|
703
|
+
}
|
|
704
|
+
if (this.matchPunctuator("(")) {
|
|
705
|
+
node = {
|
|
706
|
+
type: "Call",
|
|
707
|
+
callee: node,
|
|
708
|
+
args: this.parseArguments(),
|
|
709
|
+
optional: false
|
|
710
|
+
};
|
|
711
|
+
continue;
|
|
712
|
+
}
|
|
713
|
+
break;
|
|
714
|
+
}
|
|
715
|
+
return node;
|
|
716
|
+
}
|
|
717
|
+
parseArguments() {
|
|
718
|
+
this.enter();
|
|
719
|
+
try {
|
|
720
|
+
const args = [];
|
|
721
|
+
if (!isPunctuator(this.current(), ")")) do {
|
|
722
|
+
if (isPunctuator(this.current(), ")")) break;
|
|
723
|
+
const spread = this.matchPunctuator("...");
|
|
724
|
+
args.push({
|
|
725
|
+
spread,
|
|
726
|
+
value: this.parseAssignment()
|
|
727
|
+
});
|
|
728
|
+
} while (this.matchPunctuator(","));
|
|
729
|
+
this.expectPunctuator(")");
|
|
730
|
+
return args;
|
|
731
|
+
} finally {
|
|
732
|
+
this.leave();
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
parsePrimary() {
|
|
736
|
+
const token = this.current();
|
|
737
|
+
if (token.type === "number") {
|
|
738
|
+
this.advance();
|
|
739
|
+
return {
|
|
740
|
+
type: "Literal",
|
|
741
|
+
value: Number(token.value)
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
if (token.type === "string") {
|
|
745
|
+
this.advance();
|
|
746
|
+
return {
|
|
747
|
+
type: "Literal",
|
|
748
|
+
value: token.value
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
if (token.type === "identifier") {
|
|
752
|
+
this.advance();
|
|
753
|
+
switch (token.value) {
|
|
754
|
+
case "true": return {
|
|
755
|
+
type: "Literal",
|
|
756
|
+
value: true
|
|
757
|
+
};
|
|
758
|
+
case "false": return {
|
|
759
|
+
type: "Literal",
|
|
760
|
+
value: false
|
|
761
|
+
};
|
|
762
|
+
case "null": return {
|
|
763
|
+
type: "Literal",
|
|
764
|
+
value: null
|
|
765
|
+
};
|
|
766
|
+
case "undefined": return {
|
|
767
|
+
type: "Literal",
|
|
768
|
+
value: void 0
|
|
769
|
+
};
|
|
770
|
+
case "NaN": return {
|
|
771
|
+
type: "Literal",
|
|
772
|
+
value: NaN
|
|
773
|
+
};
|
|
774
|
+
case "Infinity": return {
|
|
775
|
+
type: "Literal",
|
|
776
|
+
value: Infinity
|
|
777
|
+
};
|
|
778
|
+
default: return {
|
|
779
|
+
type: "Identifier",
|
|
780
|
+
name: token.value
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
if (this.matchPunctuator("(")) {
|
|
785
|
+
const expression = this.parseExpression();
|
|
786
|
+
this.expectPunctuator(")");
|
|
787
|
+
return expression;
|
|
788
|
+
}
|
|
789
|
+
if (this.matchPunctuator("[")) return this.parseArray();
|
|
790
|
+
if (this.matchPunctuator("{")) return this.parseObject();
|
|
791
|
+
return fail("Unexpected token in expression.");
|
|
792
|
+
}
|
|
793
|
+
parseArray() {
|
|
794
|
+
this.enter();
|
|
795
|
+
try {
|
|
796
|
+
const elements = [];
|
|
797
|
+
if (!isPunctuator(this.current(), "]")) do {
|
|
798
|
+
if (isPunctuator(this.current(), "]")) break;
|
|
799
|
+
const spread = this.matchPunctuator("...");
|
|
800
|
+
elements.push({
|
|
801
|
+
spread,
|
|
802
|
+
value: this.parseAssignment()
|
|
803
|
+
});
|
|
804
|
+
} while (this.matchPunctuator(","));
|
|
805
|
+
this.expectPunctuator("]");
|
|
806
|
+
return {
|
|
807
|
+
type: "Array",
|
|
808
|
+
elements
|
|
809
|
+
};
|
|
810
|
+
} finally {
|
|
811
|
+
this.leave();
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
parseObject() {
|
|
815
|
+
this.enter();
|
|
816
|
+
try {
|
|
817
|
+
const properties = [];
|
|
818
|
+
if (!isPunctuator(this.current(), "}")) do {
|
|
819
|
+
if (isPunctuator(this.current(), "}")) break;
|
|
820
|
+
if (this.matchPunctuator("...")) {
|
|
821
|
+
properties.push({
|
|
822
|
+
spread: true,
|
|
823
|
+
value: this.parseAssignment(),
|
|
824
|
+
computed: false
|
|
825
|
+
});
|
|
826
|
+
continue;
|
|
827
|
+
}
|
|
828
|
+
let key;
|
|
829
|
+
let computed = false;
|
|
830
|
+
if (this.matchPunctuator("[")) {
|
|
831
|
+
key = this.parseExpression();
|
|
832
|
+
this.expectPunctuator("]");
|
|
833
|
+
computed = true;
|
|
834
|
+
} else {
|
|
835
|
+
const keyToken = this.advance();
|
|
836
|
+
if (keyToken.type === "identifier" || keyToken.type === "string") key = {
|
|
837
|
+
type: "Literal",
|
|
838
|
+
value: keyToken.value
|
|
839
|
+
};
|
|
840
|
+
else if (keyToken.type === "number") key = {
|
|
841
|
+
type: "Literal",
|
|
842
|
+
value: String(Number(keyToken.value))
|
|
843
|
+
};
|
|
844
|
+
else return fail("Invalid object key.");
|
|
845
|
+
}
|
|
846
|
+
this.expectPunctuator(":");
|
|
847
|
+
const value = this.parseAssignment();
|
|
848
|
+
properties.push({
|
|
849
|
+
spread: false,
|
|
850
|
+
key,
|
|
851
|
+
value,
|
|
852
|
+
computed
|
|
853
|
+
});
|
|
854
|
+
} while (this.matchPunctuator(","));
|
|
855
|
+
this.expectPunctuator("}");
|
|
856
|
+
return {
|
|
857
|
+
type: "Object",
|
|
858
|
+
properties
|
|
859
|
+
};
|
|
860
|
+
} finally {
|
|
861
|
+
this.leave();
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
function assertSafeProperty(property) {
|
|
866
|
+
if (FORBIDDEN_PROPERTIES.has(property)) fail("Access to a forbidden property was blocked.");
|
|
867
|
+
}
|
|
868
|
+
function isMethodAllowed(name, options) {
|
|
869
|
+
if (options?.allowCustomMethods === true) return true;
|
|
870
|
+
return Array.isArray(options?.allowedMethods) && options.allowedMethods.includes(name);
|
|
871
|
+
}
|
|
872
|
+
function defineSafeProperty(target, key, value) {
|
|
873
|
+
assertSafeProperty(key);
|
|
874
|
+
Object.defineProperty(target, key, {
|
|
875
|
+
value,
|
|
876
|
+
writable: true,
|
|
877
|
+
enumerable: true,
|
|
878
|
+
configurable: true
|
|
879
|
+
});
|
|
880
|
+
}
|
|
881
|
+
function readMember(target, key, optional, options) {
|
|
882
|
+
if (typeof key !== "string" && typeof key !== "number") fail("Property keys must be strings or numbers.");
|
|
883
|
+
const property = String(key);
|
|
884
|
+
assertSafeProperty(property);
|
|
885
|
+
if (target == null) {
|
|
886
|
+
if (optional) return;
|
|
887
|
+
fail("Cannot read properties of null or undefined.");
|
|
888
|
+
}
|
|
889
|
+
if (isHostObject(target)) fail("Access to host objects is not allowed.");
|
|
890
|
+
const object = Object(target);
|
|
891
|
+
const descriptor = Object.getOwnPropertyDescriptor(object, property);
|
|
892
|
+
if (descriptor) {
|
|
893
|
+
if (!("value" in descriptor)) fail("Access to accessor properties is not allowed.");
|
|
894
|
+
const value = descriptor.value;
|
|
895
|
+
if (typeof value === "function" && !isNativeFunction(value) && !isInterpreterFunction(value) && !isMethodAllowed(property, options)) fail("Access to custom methods is not allowed.");
|
|
896
|
+
return assertSafeValue(value);
|
|
897
|
+
}
|
|
898
|
+
let prototype = Object.getPrototypeOf(object);
|
|
899
|
+
while (prototype) {
|
|
900
|
+
const inheritedDescriptor = Object.getOwnPropertyDescriptor(prototype, property);
|
|
901
|
+
if (inheritedDescriptor) {
|
|
902
|
+
if (!("value" in inheritedDescriptor)) fail("Access to inherited accessor properties is not allowed.");
|
|
903
|
+
const inherited = inheritedDescriptor.value;
|
|
904
|
+
if (typeof inherited === "function") {
|
|
905
|
+
if (isNativeFunction(inherited) || isInterpreterFunction(inherited) || isMethodAllowed(property, options)) return inherited;
|
|
906
|
+
fail("Access to custom methods is not allowed.");
|
|
907
|
+
}
|
|
908
|
+
fail("Access to inherited properties is not allowed.");
|
|
909
|
+
}
|
|
910
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
function spreadValues(value) {
|
|
914
|
+
if (Array.isArray(value)) return value.slice();
|
|
915
|
+
if (typeof value === "string") {
|
|
916
|
+
if (value.length > MAX_STRING_LENGTH) fail("Spread value is too large.");
|
|
917
|
+
return value.split("");
|
|
918
|
+
}
|
|
919
|
+
return fail("Spread is only supported for arrays and strings.");
|
|
920
|
+
}
|
|
921
|
+
function isPrimitive(value) {
|
|
922
|
+
return value == null || typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint";
|
|
923
|
+
}
|
|
924
|
+
function primitiveAdd(left, right) {
|
|
925
|
+
if (!isPrimitive(left) || !isPrimitive(right)) fail("Arithmetic on objects is not allowed.");
|
|
926
|
+
return left + right;
|
|
927
|
+
}
|
|
928
|
+
function numericOperation(operator, left, right) {
|
|
929
|
+
if (typeof left !== "number" || typeof right !== "number") fail(`Operator "${operator}" only supports numbers.`);
|
|
930
|
+
switch (operator) {
|
|
931
|
+
case "-": return left - right;
|
|
932
|
+
case "*": return left * right;
|
|
933
|
+
case "/": return left / right;
|
|
934
|
+
case "%": return left % right;
|
|
935
|
+
case "**": return left ** right;
|
|
936
|
+
default: return fail(`Unsupported arithmetic operator "${operator}".`);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
function looseEquals(left, right) {
|
|
940
|
+
if (!isPrimitive(left) || !isPrimitive(right)) fail("Loose equality is only supported for primitive values.");
|
|
941
|
+
return left == right;
|
|
942
|
+
}
|
|
943
|
+
function compareValues(operator, left, right) {
|
|
944
|
+
if (!isPrimitive(left) || !isPrimitive(right)) fail("Comparison is only supported for primitive values.");
|
|
945
|
+
switch (operator) {
|
|
946
|
+
case "<": return left < right;
|
|
947
|
+
case ">": return left > right;
|
|
948
|
+
case "<=": return left <= right;
|
|
949
|
+
case ">=": return left >= right;
|
|
950
|
+
default: return fail(`Unsupported comparison operator "${operator}".`);
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
function evaluateNode(node, environment, state, options) {
|
|
954
|
+
state.steps++;
|
|
955
|
+
state.depth++;
|
|
956
|
+
if (state.steps > MAX_EVALUATION_STEPS) {
|
|
957
|
+
state.depth--;
|
|
958
|
+
return fail("Expression is too complex.");
|
|
959
|
+
}
|
|
960
|
+
if (state.depth > MAX_EVALUATION_DEPTH) {
|
|
961
|
+
state.depth--;
|
|
962
|
+
return fail("Expression is nested too deeply.");
|
|
963
|
+
}
|
|
964
|
+
try {
|
|
965
|
+
switch (node.type) {
|
|
966
|
+
case "Literal": return node.value;
|
|
967
|
+
case "Identifier":
|
|
968
|
+
if (!environment.has(node.name)) return fail(`Unknown identifier "${node.name}".`);
|
|
969
|
+
return assertSafeValue(environment.get(node.name));
|
|
970
|
+
case "Member": return readMember(evaluateNode(node.object, environment, state, options), evaluateNode(node.property, environment, state, options), node.optional, options);
|
|
971
|
+
case "Call": {
|
|
972
|
+
let fn;
|
|
973
|
+
let thisArg;
|
|
974
|
+
let methodName;
|
|
975
|
+
if (node.callee.type === "Member") {
|
|
976
|
+
const object = evaluateNode(node.callee.object, environment, state, options);
|
|
977
|
+
const key = evaluateNode(node.callee.property, environment, state, options);
|
|
978
|
+
fn = readMember(object, key, node.callee.optional, options);
|
|
979
|
+
thisArg = object;
|
|
980
|
+
methodName = String(key);
|
|
981
|
+
} else fn = evaluateNode(node.callee, environment, state, options);
|
|
982
|
+
if (fn == null && node.optional) return;
|
|
983
|
+
if (typeof fn !== "function") {
|
|
984
|
+
if (node.optional) return;
|
|
985
|
+
return fail("Attempted to call a non-function value.");
|
|
986
|
+
}
|
|
987
|
+
if (fn === Function || fn === eval) return fail("Calling global constructors is not allowed.");
|
|
988
|
+
if (node.callee.type === "Member") {
|
|
989
|
+
if (!isNativeFunction(fn) && !isInterpreterFunction(fn) && !isMethodAllowed(methodName ?? "", options)) return fail("Calling custom methods is not allowed.");
|
|
990
|
+
} else if (!(node.callee.type === "Identifier" && node.callee.name === "$vm") && !isInterpreterFunction(fn) && !isMethodAllowed("", options)) return fail("Calling custom functions is not allowed.");
|
|
991
|
+
const args = [];
|
|
992
|
+
for (const argument of node.args) {
|
|
993
|
+
const value = evaluateNode(argument.value, environment, state, options);
|
|
994
|
+
if (argument.spread) args.push(...spreadValues(value));
|
|
995
|
+
else args.push(value);
|
|
996
|
+
}
|
|
997
|
+
if (fn === String.prototype.repeat) {
|
|
998
|
+
const count = args[0];
|
|
999
|
+
const source = String(thisArg ?? "");
|
|
1000
|
+
if (typeof count !== "number" || !Number.isFinite(count) || count < 0 || count > MAX_REPEAT_COUNT || source.length * count > MAX_STRING_LENGTH) return fail("String repetition is too large.");
|
|
1001
|
+
}
|
|
1002
|
+
if (fn === String.prototype.padStart || fn === String.prototype.padEnd) {
|
|
1003
|
+
const targetLength = args[0];
|
|
1004
|
+
if (typeof targetLength === "number" && targetLength > MAX_STRING_LENGTH) return fail("String padding is too large.");
|
|
1005
|
+
}
|
|
1006
|
+
if (fn === Array.prototype.join && Array.isArray(thisArg) && thisArg.length > MAX_STRING_LENGTH) return fail("Array join is too large.");
|
|
1007
|
+
const result = fn.apply(thisArg, args);
|
|
1008
|
+
if (typeof result === "string" && result.length > MAX_STRING_LENGTH) return fail("Expression result is too large.");
|
|
1009
|
+
return assertSafeValue(result);
|
|
1010
|
+
}
|
|
1011
|
+
case "Unary": {
|
|
1012
|
+
const argument = evaluateNode(node.argument, environment, state, options);
|
|
1013
|
+
switch (node.operator) {
|
|
1014
|
+
case "!": return !argument;
|
|
1015
|
+
case "typeof": return typeof argument;
|
|
1016
|
+
case "-":
|
|
1017
|
+
if (typeof argument !== "number" && typeof argument !== "bigint") return fail("Unary \"-\" only supports numbers.");
|
|
1018
|
+
return -argument;
|
|
1019
|
+
case "+":
|
|
1020
|
+
if (typeof argument !== "number") return fail("Unary \"+\" only supports numbers.");
|
|
1021
|
+
return +argument;
|
|
1022
|
+
default: return fail(`Unsupported unary operator "${node.operator}".`);
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
case "Binary": {
|
|
1026
|
+
const left = evaluateNode(node.left, environment, state, options);
|
|
1027
|
+
const right = evaluateNode(node.right, environment, state, options);
|
|
1028
|
+
switch (node.operator) {
|
|
1029
|
+
case "===": return left === right;
|
|
1030
|
+
case "!==": return left !== right;
|
|
1031
|
+
case "==": return looseEquals(left, right);
|
|
1032
|
+
case "!=": return !looseEquals(left, right);
|
|
1033
|
+
case "+": return primitiveAdd(left, right);
|
|
1034
|
+
case "-":
|
|
1035
|
+
case "*":
|
|
1036
|
+
case "/":
|
|
1037
|
+
case "%":
|
|
1038
|
+
case "**": return numericOperation(node.operator, left, right);
|
|
1039
|
+
case "<":
|
|
1040
|
+
case ">":
|
|
1041
|
+
case "<=":
|
|
1042
|
+
case ">=": return compareValues(node.operator, left, right);
|
|
1043
|
+
default: return fail(`Unsupported binary operator "${node.operator}".`);
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
case "Logical": {
|
|
1047
|
+
const left = evaluateNode(node.left, environment, state, options);
|
|
1048
|
+
switch (node.operator) {
|
|
1049
|
+
case "&&": return left ? evaluateNode(node.right, environment, state, options) : left;
|
|
1050
|
+
case "||": return left ? left : evaluateNode(node.right, environment, state, options);
|
|
1051
|
+
case "??": return left == null ? evaluateNode(node.right, environment, state, options) : left;
|
|
1052
|
+
default: return fail(`Unsupported logical operator "${node.operator}".`);
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
case "Conditional": return evaluateNode(node.test, environment, state, options) ? evaluateNode(node.consequent, environment, state, options) : evaluateNode(node.alternate, environment, state, options);
|
|
1056
|
+
case "Array": {
|
|
1057
|
+
const values = [];
|
|
1058
|
+
for (const element of node.elements) {
|
|
1059
|
+
const value = evaluateNode(element.value, environment, state, options);
|
|
1060
|
+
if (element.spread) values.push(...spreadValues(value));
|
|
1061
|
+
else values.push(value);
|
|
1062
|
+
}
|
|
1063
|
+
return values;
|
|
1064
|
+
}
|
|
1065
|
+
case "Object": {
|
|
1066
|
+
const result = {};
|
|
1067
|
+
for (const property of node.properties) {
|
|
1068
|
+
if (property.spread) {
|
|
1069
|
+
const source = evaluateNode(property.value, environment, state, options);
|
|
1070
|
+
if (source == null || typeof source !== "object") return fail("Object spread is only supported for objects.");
|
|
1071
|
+
for (const key of Object.keys(source)) {
|
|
1072
|
+
const descriptor = Object.getOwnPropertyDescriptor(source, key);
|
|
1073
|
+
if (descriptor && "value" in descriptor) defineSafeProperty(result, key, descriptor.value);
|
|
1074
|
+
}
|
|
1075
|
+
continue;
|
|
1076
|
+
}
|
|
1077
|
+
if (!property.key) return fail("Invalid object property.");
|
|
1078
|
+
const key = property.computed ? evaluateNode(property.key, environment, state, options) : property.key.value;
|
|
1079
|
+
if (typeof key !== "string" && typeof key !== "number") return fail("Object keys must be strings or numbers.");
|
|
1080
|
+
defineSafeProperty(result, String(key), evaluateNode(property.value, environment, state, options));
|
|
1081
|
+
}
|
|
1082
|
+
return result;
|
|
1083
|
+
}
|
|
1084
|
+
case "Arrow": {
|
|
1085
|
+
const params = node.params;
|
|
1086
|
+
const body = node.body;
|
|
1087
|
+
const closure = new Map(environment);
|
|
1088
|
+
const arrowFunction = function evaluateArrowFunction(...args) {
|
|
1089
|
+
const local = new Map(closure);
|
|
1090
|
+
params.forEach((parameter, index) => {
|
|
1091
|
+
local.set(parameter, args[index]);
|
|
1092
|
+
});
|
|
1093
|
+
return evaluateNode(body, local, state, options);
|
|
1094
|
+
};
|
|
1095
|
+
INTERPRETER_FUNCTIONS.add(arrowFunction);
|
|
1096
|
+
return arrowFunction;
|
|
1097
|
+
}
|
|
1098
|
+
default: return fail("Unsupported expression node.");
|
|
1099
|
+
}
|
|
1100
|
+
} finally {
|
|
1101
|
+
state.depth--;
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
function evaluateSafeExpression(source, variables = {}, options) {
|
|
1105
|
+
if (typeof source !== "string") fail("Expression must be a string.");
|
|
1106
|
+
if (source.length === 0) fail("Expression is empty.");
|
|
1107
|
+
if (source.length > MAX_SOURCE_LENGTH) fail("Expression is too long.");
|
|
1108
|
+
const ast = new ExpressionParser(tokenize(source)).parse();
|
|
1109
|
+
const environment = /* @__PURE__ */ new Map();
|
|
1110
|
+
for (const [key, value] of Object.entries(variables)) environment.set(key, value);
|
|
1111
|
+
return assertSafeValue(evaluateNode(ast, environment, {
|
|
1112
|
+
steps: 0,
|
|
1113
|
+
depth: 0
|
|
1114
|
+
}, options));
|
|
1115
|
+
}
|
|
1116
|
+
const FORBIDDEN_PATH_SEGMENTS = /* @__PURE__ */ new Set([
|
|
1117
|
+
"__proto__",
|
|
1118
|
+
"prototype",
|
|
1119
|
+
"constructor"
|
|
1120
|
+
]);
|
|
1121
|
+
const MAX_PATH_DEPTH = 32;
|
|
1122
|
+
const MAX_PATH_SEGMENT_LENGTH = 128;
|
|
1123
|
+
const MAX_CONFIGURATION_ITEMS = 1e3;
|
|
1124
|
+
const MAX_CONFIGURATION_DEPTH = 32;
|
|
1125
|
+
const MAX_TOTAL_CONFIGURATION_NODES = 2e3;
|
|
1126
|
+
const MAX_CONFIGURATION_KEYS = 100;
|
|
1127
|
+
const MAX_CONFIGURATION_KEY_LENGTH = 128;
|
|
1128
|
+
const MAX_ATTRIBUTE_NAME_LENGTH = 128;
|
|
1129
|
+
const MAX_ATTRIBUTE_VALUE_LENGTH = 8192;
|
|
1130
|
+
const MAX_PATTERN_LENGTH = 512;
|
|
1131
|
+
const MAX_PATTERN_INPUT_LENGTH = 1024;
|
|
1132
|
+
const ALLOWED_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
1133
|
+
"class",
|
|
1134
|
+
"id",
|
|
1135
|
+
"name",
|
|
1136
|
+
"role",
|
|
1137
|
+
"title",
|
|
1138
|
+
"tabindex",
|
|
1139
|
+
"hidden",
|
|
1140
|
+
"dir",
|
|
1141
|
+
"lang",
|
|
1142
|
+
"disabled",
|
|
1143
|
+
"readonly",
|
|
1144
|
+
"required",
|
|
1145
|
+
"placeholder",
|
|
1146
|
+
"autocomplete",
|
|
1147
|
+
"spellcheck",
|
|
1148
|
+
"min",
|
|
1149
|
+
"max",
|
|
1150
|
+
"minlength",
|
|
1151
|
+
"maxlength",
|
|
1152
|
+
"pattern",
|
|
1153
|
+
"email",
|
|
1154
|
+
"step",
|
|
1155
|
+
"multiple",
|
|
1156
|
+
"checked",
|
|
1157
|
+
"selected",
|
|
1158
|
+
"for",
|
|
1159
|
+
"href",
|
|
1160
|
+
"src"
|
|
1161
|
+
]);
|
|
1162
|
+
const URL_ATTRIBUTES = /* @__PURE__ */ new Set(["href", "src"]);
|
|
1163
|
+
const STRICT_DISALLOWED_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
1164
|
+
"id",
|
|
1165
|
+
"class",
|
|
1166
|
+
"for",
|
|
1167
|
+
"href",
|
|
1168
|
+
"src"
|
|
1169
|
+
]);
|
|
1170
|
+
const BOOLEAN_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
1171
|
+
"hidden",
|
|
1172
|
+
"disabled",
|
|
1173
|
+
"readonly",
|
|
1174
|
+
"required",
|
|
1175
|
+
"checked",
|
|
1176
|
+
"selected",
|
|
1177
|
+
"multiple"
|
|
1178
|
+
]);
|
|
1179
|
+
var FGDynamicRegistry = class {
|
|
1180
|
+
constructor() {
|
|
1181
|
+
this._components = /* @__PURE__ */ new Map();
|
|
1182
|
+
}
|
|
1183
|
+
register(name, type) {
|
|
1184
|
+
if (typeof name === "string" && name.length > 0 && type) this._components.set(name, type);
|
|
1185
|
+
}
|
|
1186
|
+
get(name) {
|
|
1187
|
+
return typeof name === "string" ? this._components.get(name) : void 0;
|
|
1188
|
+
}
|
|
1189
|
+
has(name) {
|
|
1190
|
+
return typeof name === "string" && this._components.has(name);
|
|
1191
|
+
}
|
|
1192
|
+
unregister(name) {
|
|
1193
|
+
return this._components.delete(name);
|
|
1194
|
+
}
|
|
1195
|
+
clear() {
|
|
1196
|
+
this._components.clear();
|
|
1197
|
+
}
|
|
1198
|
+
get names() {
|
|
1199
|
+
return Array.from(this._components.keys());
|
|
1200
|
+
}
|
|
1201
|
+
};
|
|
1202
|
+
var FGDynamicService = class FGDynamicService {
|
|
1203
|
+
static {
|
|
1204
|
+
this._defaultRegistry = new FGDynamicRegistry();
|
|
1205
|
+
}
|
|
1206
|
+
static get registry() {
|
|
1207
|
+
return FGDynamicService._defaultRegistry;
|
|
1208
|
+
}
|
|
1209
|
+
static createRegistry() {
|
|
1210
|
+
return new FGDynamicRegistry();
|
|
1211
|
+
}
|
|
1212
|
+
static registerComponent(name, type) {
|
|
1213
|
+
FGDynamicService._defaultRegistry.register(name, type);
|
|
1214
|
+
}
|
|
1215
|
+
static getComponent(name) {
|
|
1216
|
+
return FGDynamicService._defaultRegistry.get(name);
|
|
1217
|
+
}
|
|
1218
|
+
static hasComponent(name) {
|
|
1219
|
+
return FGDynamicService._defaultRegistry.has(name);
|
|
1220
|
+
}
|
|
1221
|
+
static unregisterComponent(name) {
|
|
1222
|
+
return FGDynamicService._defaultRegistry.unregister(name);
|
|
1223
|
+
}
|
|
1224
|
+
static clearRegistry() {
|
|
1225
|
+
FGDynamicService._defaultRegistry.clear();
|
|
1226
|
+
}
|
|
1227
|
+
};
|
|
1228
|
+
var FGDynamicComponent = class FGDynamicComponent {
|
|
1229
|
+
constructor() {
|
|
1230
|
+
this.configuration = input.required(...ngDevMode ? [{ debugName: "configuration" }] : /* istanbul ignore next */ []);
|
|
1231
|
+
this.viewModel = model(...ngDevMode ? [void 0, { debugName: "viewModel" }] : /* istanbul ignore next */ []);
|
|
1232
|
+
this.formGroup = input(...ngDevMode ? [void 0, { debugName: "formGroup" }] : /* istanbul ignore next */ []);
|
|
1233
|
+
this.registry = input(FGDynamicService.registry, ...ngDevMode ? [{ debugName: "registry" }] : /* istanbul ignore next */ []);
|
|
1234
|
+
this.expressionPolicy = input({}, ...ngDevMode ? [{ debugName: "expressionPolicy" }] : /* istanbul ignore next */ []);
|
|
1235
|
+
this.formControlPolicy = input({}, ...ngDevMode ? [{ debugName: "formControlPolicy" }] : /* istanbul ignore next */ []);
|
|
1236
|
+
this.typePolicy = input({}, ...ngDevMode ? [{ debugName: "typePolicy" }] : /* istanbul ignore next */ []);
|
|
1237
|
+
this.attributePolicy = input({}, ...ngDevMode ? [{ debugName: "attributePolicy" }] : /* istanbul ignore next */ []);
|
|
1238
|
+
this.depth = input(0, ...ngDevMode ? [{ debugName: "depth" }] : /* istanbul ignore next */ []);
|
|
1239
|
+
this.items = computed(() => {
|
|
1240
|
+
if (this.depth() >= MAX_CONFIGURATION_DEPTH) return [];
|
|
1241
|
+
const configuration = this.configuration();
|
|
1242
|
+
if (!this.validateConfiguration(configuration)) return [];
|
|
1243
|
+
const items = configuration && typeof configuration === "object" && !Array.isArray(configuration) ? configuration.items : void 0;
|
|
1244
|
+
if (!Array.isArray(items)) return [];
|
|
1245
|
+
return items.filter((item) => item != null && typeof item === "object" && !Array.isArray(item)).slice(0, MAX_CONFIGURATION_ITEMS);
|
|
1246
|
+
}, ...ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []);
|
|
1247
|
+
this._viewContainerRef = viewChild.required("viewContainer", {
|
|
1248
|
+
...ngDevMode ? { debugName: "_viewContainerRef" } : /* istanbul ignore next */ {},
|
|
1249
|
+
read: ViewContainerRef
|
|
1250
|
+
});
|
|
1251
|
+
this._dynamicItems = viewChildren("dynamicItem", {
|
|
1252
|
+
...ngDevMode ? { debugName: "_dynamicItems" } : /* istanbul ignore next */ {},
|
|
1253
|
+
read: ElementRef
|
|
1254
|
+
});
|
|
1255
|
+
this._renderer = inject(Renderer2);
|
|
1256
|
+
this._outputsSubscriptions = [];
|
|
1257
|
+
this._managedValidatorFns = [];
|
|
1258
|
+
this._injector = inject(Injector);
|
|
1259
|
+
this._ngOnChangesCounter = 0;
|
|
1260
|
+
this._ownsFormControl = false;
|
|
1261
|
+
this._createdFormGroups = [];
|
|
1262
|
+
this._disabledManaged = false;
|
|
1263
|
+
this._appliedAttributes = /* @__PURE__ */ new Set();
|
|
1264
|
+
this._appliedInputs = /* @__PURE__ */ new Set();
|
|
1265
|
+
}
|
|
1266
|
+
async ngOnChanges(changes) {
|
|
1267
|
+
const counter = ++this._ngOnChangesCounter;
|
|
1268
|
+
try {
|
|
1269
|
+
const configuration = this.configuration();
|
|
1270
|
+
if (configuration != null && (typeof configuration !== "object" || Array.isArray(configuration))) {
|
|
1271
|
+
this.logError("Invalid configuration: expected an object.");
|
|
1272
|
+
this.clearResolvedComponent(counter);
|
|
1273
|
+
return;
|
|
1274
|
+
}
|
|
1275
|
+
if (!this.validateConfiguration(configuration)) {
|
|
1276
|
+
this.logError("Invalid configuration: it exceeds the structural limits.");
|
|
1277
|
+
this.clearResolvedComponent(counter);
|
|
1278
|
+
return;
|
|
1279
|
+
}
|
|
1280
|
+
await this.loadComponentAsync(counter);
|
|
1281
|
+
if (counter !== this._ngOnChangesCounter) return;
|
|
1282
|
+
const items = this.items();
|
|
1283
|
+
const itemsSignature = items.length > 0 ? `${items.length}:${items.map((item, index) => `${index}:${item?.type}`).join("|")}` : "";
|
|
1284
|
+
if (this._componentRef && this._lastProjectedItemsSignature !== itemsSignature) {
|
|
1285
|
+
this.cleanup();
|
|
1286
|
+
this._lastProjectedItemsSignature = itemsSignature;
|
|
1287
|
+
} else if (!this._componentRef) this._lastProjectedItemsSignature = itemsSignature;
|
|
1288
|
+
this.rewireFormIfNeeded();
|
|
1289
|
+
this.createComponent();
|
|
1290
|
+
if (counter !== this._ngOnChangesCounter) return;
|
|
1291
|
+
this.setInputs();
|
|
1292
|
+
this.setFormControlStatus();
|
|
1293
|
+
this.setFormControlValidators();
|
|
1294
|
+
this.setAttributes();
|
|
1295
|
+
this.handleOutputsIfChanged();
|
|
1296
|
+
if (this._componentRef?.changeDetectorRef) this._componentRef.changeDetectorRef.markForCheck();
|
|
1297
|
+
} catch (error) {
|
|
1298
|
+
if (counter === this._ngOnChangesCounter) {
|
|
1299
|
+
this.logError("Error during component initialization.", error);
|
|
1300
|
+
this.clearResolvedComponent(counter);
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
clearResolvedComponent(counter) {
|
|
1305
|
+
if (counter !== this._ngOnChangesCounter) return;
|
|
1306
|
+
this._component = void 0;
|
|
1307
|
+
if (this._componentRef) this.cleanup();
|
|
1308
|
+
}
|
|
1309
|
+
validateConfiguration(configuration) {
|
|
1310
|
+
if (configuration == null) return true;
|
|
1311
|
+
const stats = this.collectConfigurationStats(configuration);
|
|
1312
|
+
if (!stats) return false;
|
|
1313
|
+
return this.depth() + stats.maxDepth <= MAX_CONFIGURATION_DEPTH && stats.nodes <= MAX_TOTAL_CONFIGURATION_NODES;
|
|
1314
|
+
}
|
|
1315
|
+
collectConfigurationStats(configuration) {
|
|
1316
|
+
const stack = [{
|
|
1317
|
+
item: configuration,
|
|
1318
|
+
depth: 0
|
|
1319
|
+
}];
|
|
1320
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
1321
|
+
let nodes = 0;
|
|
1322
|
+
let maxDepth = 0;
|
|
1323
|
+
while (stack.length > 0) {
|
|
1324
|
+
const current = stack.pop();
|
|
1325
|
+
const item = current.item;
|
|
1326
|
+
if (item == null || typeof item !== "object" || Array.isArray(item)) return null;
|
|
1327
|
+
if (seen.has(item)) return null;
|
|
1328
|
+
seen.add(item);
|
|
1329
|
+
nodes++;
|
|
1330
|
+
if (nodes > MAX_TOTAL_CONFIGURATION_NODES || current.depth > MAX_CONFIGURATION_DEPTH) return null;
|
|
1331
|
+
if (current.depth > maxDepth) maxDepth = current.depth;
|
|
1332
|
+
for (const field of [
|
|
1333
|
+
"inputs",
|
|
1334
|
+
"attributes",
|
|
1335
|
+
"outputs"
|
|
1336
|
+
]) {
|
|
1337
|
+
const map = item[field];
|
|
1338
|
+
if (map == null) continue;
|
|
1339
|
+
if (typeof map !== "object" || Array.isArray(map)) return null;
|
|
1340
|
+
const keys = Object.keys(map);
|
|
1341
|
+
if (keys.length > MAX_CONFIGURATION_KEYS) return null;
|
|
1342
|
+
if (keys.some((key) => key.length > MAX_CONFIGURATION_KEY_LENGTH || FORBIDDEN_PATH_SEGMENTS.has(key.toLowerCase()))) return null;
|
|
1343
|
+
}
|
|
1344
|
+
const items = item["items"];
|
|
1345
|
+
if (items == null) continue;
|
|
1346
|
+
if (!Array.isArray(items) || items.length > MAX_CONFIGURATION_ITEMS) return null;
|
|
1347
|
+
for (const child of items) stack.push({
|
|
1348
|
+
item: child,
|
|
1349
|
+
depth: current.depth + 1
|
|
1350
|
+
});
|
|
1351
|
+
}
|
|
1352
|
+
return {
|
|
1353
|
+
nodes,
|
|
1354
|
+
maxDepth
|
|
1355
|
+
};
|
|
1356
|
+
}
|
|
1357
|
+
async loadComponentAsync(counter) {
|
|
1358
|
+
const configurationType = this.configuration()?.type;
|
|
1359
|
+
if (configurationType == null) {
|
|
1360
|
+
this.clearResolvedComponent(counter);
|
|
1361
|
+
return;
|
|
1362
|
+
}
|
|
1363
|
+
if (this.typePolicy()?.requireScopedRegistry === true && this.isUsingGlobalRegistry()) {
|
|
1364
|
+
this.logWarning("A scoped registry is required by typePolicy but only the global registry is available.");
|
|
1365
|
+
this.clearResolvedComponent(counter);
|
|
1366
|
+
return;
|
|
1367
|
+
}
|
|
1368
|
+
let candidate;
|
|
1369
|
+
if (typeof configurationType === "string") {
|
|
1370
|
+
candidate = this.getRegistry().get(configurationType);
|
|
1371
|
+
if (candidate == null) {
|
|
1372
|
+
this.logWarning(`Component type "${configurationType}" not found in the registry.`);
|
|
1373
|
+
this.clearResolvedComponent(counter);
|
|
1374
|
+
return;
|
|
1375
|
+
}
|
|
1376
|
+
} else candidate = configurationType;
|
|
1377
|
+
if (!this.isCandidateAllowed(candidate)) {
|
|
1378
|
+
this.logWarning("Component type was rejected by typePolicy (function/promise types are disabled).");
|
|
1379
|
+
this.clearResolvedComponent(counter);
|
|
1380
|
+
return;
|
|
1381
|
+
}
|
|
1382
|
+
try {
|
|
1383
|
+
const resolved = this.resolveCandidate(candidate);
|
|
1384
|
+
const resolvedType = this.isPromiseLike(resolved) ? await resolved : resolved;
|
|
1385
|
+
if (counter !== this._ngOnChangesCounter) return;
|
|
1386
|
+
if (!resolvedType) {
|
|
1387
|
+
this.clearResolvedComponent(counter);
|
|
1388
|
+
return;
|
|
1389
|
+
}
|
|
1390
|
+
if (this._component !== resolvedType) {
|
|
1391
|
+
this.cleanup();
|
|
1392
|
+
this._component = resolvedType;
|
|
1393
|
+
}
|
|
1394
|
+
} catch (error) {
|
|
1395
|
+
if (counter !== this._ngOnChangesCounter) return;
|
|
1396
|
+
this.logError("Unable to resolve the dynamic component type.", error);
|
|
1397
|
+
this.clearResolvedComponent(counter);
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
isPromiseLike(value) {
|
|
1401
|
+
return value != null && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
|
|
1402
|
+
}
|
|
1403
|
+
resolveCandidate(candidate) {
|
|
1404
|
+
if (candidate == null) return;
|
|
1405
|
+
if (this.isPromiseLike(candidate)) return Promise.resolve(candidate).then((resolved) => this.toComponentType(resolved));
|
|
1406
|
+
if (typeof candidate === "function") {
|
|
1407
|
+
if (this.isAngularComponentType(candidate)) return candidate;
|
|
1408
|
+
if (candidate.length > 0) return candidate;
|
|
1409
|
+
const result = candidate();
|
|
1410
|
+
if (this.isPromiseLike(result)) return Promise.resolve(result).then((resolved) => this.toComponentType(resolved));
|
|
1411
|
+
return this.toComponentType(result);
|
|
1412
|
+
}
|
|
1413
|
+
this.logWarning("Invalid component type in configuration.");
|
|
1414
|
+
}
|
|
1415
|
+
toComponentType(resolved) {
|
|
1416
|
+
if (typeof resolved === "function") return resolved;
|
|
1417
|
+
this.logWarning("Component loader did not resolve to a component type.");
|
|
1418
|
+
}
|
|
1419
|
+
isAngularComponentType(candidate) {
|
|
1420
|
+
const metadata = candidate;
|
|
1421
|
+
return Boolean(metadata["ɵcmp"] || metadata["ɵdir"] || metadata["ɵpipe"] || metadata["ɵfac"] || metadata["ngComponentDef"] || metadata["ngDirectiveDef"]);
|
|
1422
|
+
}
|
|
1423
|
+
isCandidateAllowed(candidate) {
|
|
1424
|
+
if (candidate == null) return false;
|
|
1425
|
+
if (this.typePolicy()?.allowFunctionTypes === true) return true;
|
|
1426
|
+
return typeof candidate === "function" && this.isAngularComponentType(candidate);
|
|
1427
|
+
}
|
|
1428
|
+
isUsingGlobalRegistry() {
|
|
1429
|
+
const registry = this.registry();
|
|
1430
|
+
return registry == null || registry === FGDynamicService.registry;
|
|
1431
|
+
}
|
|
1432
|
+
getRegistry() {
|
|
1433
|
+
return this.registry() ?? FGDynamicService.registry;
|
|
1434
|
+
}
|
|
1435
|
+
createComponent() {
|
|
1436
|
+
if (this._componentRef && this._component !== this._componentRef.componentType) this.cleanup();
|
|
1437
|
+
if (this._component && !this._componentRef && this._viewContainerRef()) {
|
|
1438
|
+
let injector = void 0;
|
|
1439
|
+
const formGroup = this.formGroup();
|
|
1440
|
+
const controlName = this.resolveFormControlName();
|
|
1441
|
+
if (formGroup && controlName) {
|
|
1442
|
+
this._formControlDirective = new FormControlDirective(null, null, null, null);
|
|
1443
|
+
injector = Injector.create({
|
|
1444
|
+
providers: [{
|
|
1445
|
+
provide: NgControl,
|
|
1446
|
+
useValue: this._formControlDirective
|
|
1447
|
+
}],
|
|
1448
|
+
parent: this._injector
|
|
1449
|
+
});
|
|
1450
|
+
}
|
|
1451
|
+
const dynamicItems = this._dynamicItems();
|
|
1452
|
+
this._componentRef = this._viewContainerRef().createComponent(this._component, {
|
|
1453
|
+
projectableNodes: dynamicItems && dynamicItems.length > 0 ? [dynamicItems.map((e) => e.nativeElement)] : void 0,
|
|
1454
|
+
injector
|
|
1455
|
+
});
|
|
1456
|
+
if (this._componentRef?.changeDetectorRef) this._componentRef.changeDetectorRef.markForCheck();
|
|
1457
|
+
this.handleOutputs();
|
|
1458
|
+
this.wireFormControl();
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
handleOutputs() {
|
|
1462
|
+
if (this._outputsSubscriptions && this._outputsSubscriptions.length > 0) {
|
|
1463
|
+
this._outputsSubscriptions.forEach((s) => {
|
|
1464
|
+
try {
|
|
1465
|
+
s.unsubscribe();
|
|
1466
|
+
} catch (e) {}
|
|
1467
|
+
});
|
|
1468
|
+
this._outputsSubscriptions = [];
|
|
1469
|
+
}
|
|
1470
|
+
const outputs = this.configuration()?.outputs;
|
|
1471
|
+
this._currentOutputsConfig = outputs ? { ...outputs } : void 0;
|
|
1472
|
+
if (outputs && typeof outputs === "object" && this._componentRef?.instance) {
|
|
1473
|
+
const instance = this._componentRef.instance;
|
|
1474
|
+
for (const outputName of Object.keys(outputs)) {
|
|
1475
|
+
const emitter = instance[outputName];
|
|
1476
|
+
if (!this.isOutputEmitter(emitter)) continue;
|
|
1477
|
+
const subscription = emitter.subscribe(($event) => {
|
|
1478
|
+
try {
|
|
1479
|
+
const expr = outputs[outputName];
|
|
1480
|
+
const viewModelValue = this.getViewModelValue();
|
|
1481
|
+
const result = typeof expr === "string" ? this.evaluateExpression(expr, viewModelValue, $event, true) : expr;
|
|
1482
|
+
if (typeof result === "function") result.call(viewModelValue, $event);
|
|
1483
|
+
} catch (error) {
|
|
1484
|
+
this.logError("Error handling output.", error);
|
|
1485
|
+
}
|
|
1486
|
+
});
|
|
1487
|
+
if (subscription && typeof subscription.unsubscribe === "function") this._outputsSubscriptions.push(subscription);
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
isOutputEmitter(value) {
|
|
1492
|
+
if (value == null) return false;
|
|
1493
|
+
const emitter = value;
|
|
1494
|
+
return typeof emitter["subscribe"] === "function" && typeof emitter["emit"] === "function";
|
|
1495
|
+
}
|
|
1496
|
+
handleOutputsIfChanged() {
|
|
1497
|
+
const outputs = this.configuration()?.outputs;
|
|
1498
|
+
const current = this._currentOutputsConfig;
|
|
1499
|
+
if (!outputs && !current) return;
|
|
1500
|
+
if (!outputs || !current) {
|
|
1501
|
+
this.handleOutputs();
|
|
1502
|
+
return;
|
|
1503
|
+
}
|
|
1504
|
+
const currentKeys = Object.keys(current).sort();
|
|
1505
|
+
const newKeys = Object.keys(outputs).sort();
|
|
1506
|
+
if (currentKeys.length !== newKeys.length) {
|
|
1507
|
+
this.handleOutputs();
|
|
1508
|
+
return;
|
|
1509
|
+
}
|
|
1510
|
+
for (let i = 0; i < currentKeys.length; i++) if (currentKeys[i] !== newKeys[i] || current[currentKeys[i]] !== outputs[newKeys[i]]) {
|
|
1511
|
+
this.handleOutputs();
|
|
1512
|
+
return;
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
resolveFormControlName() {
|
|
1516
|
+
const attributes = this.configuration()?.attributes;
|
|
1517
|
+
if (!attributes || !Object.hasOwn(attributes, "name")) return;
|
|
1518
|
+
const nameAttr = attributes["name"];
|
|
1519
|
+
if (nameAttr == null) return;
|
|
1520
|
+
const viewModelValue = this.getViewModelValue();
|
|
1521
|
+
if (viewModelValue == null) return;
|
|
1522
|
+
const name = this.evaluateExpression(nameAttr, viewModelValue);
|
|
1523
|
+
if (typeof name !== "string" || name.length === 0) return;
|
|
1524
|
+
if (!this.isSafePath(name)) {
|
|
1525
|
+
this.logWarning("Unsafe form control name was ignored.");
|
|
1526
|
+
return;
|
|
1527
|
+
}
|
|
1528
|
+
const allowedNames = this.formControlPolicy()?.allowedControlNames;
|
|
1529
|
+
if (allowedNames !== void 0 && (!Array.isArray(allowedNames) || !allowedNames.includes(name))) {
|
|
1530
|
+
this.logWarning("Form control name was rejected by formControlPolicy.");
|
|
1531
|
+
return;
|
|
1532
|
+
}
|
|
1533
|
+
return name;
|
|
1534
|
+
}
|
|
1535
|
+
rewireFormIfNeeded() {
|
|
1536
|
+
if (!this._componentRef) return;
|
|
1537
|
+
const formGroup = this.formGroup();
|
|
1538
|
+
const controlName = this.resolveFormControlName();
|
|
1539
|
+
const desiredGroup = formGroup && controlName ? formGroup : void 0;
|
|
1540
|
+
if (this._wiredFormGroup !== desiredGroup || this._wiredControlName !== controlName) this.cleanup();
|
|
1541
|
+
}
|
|
1542
|
+
wireFormControl() {
|
|
1543
|
+
const formGroup = this.formGroup();
|
|
1544
|
+
const name = this.resolveFormControlName();
|
|
1545
|
+
if (!formGroup || !name) {
|
|
1546
|
+
this._wiredFormGroup = void 0;
|
|
1547
|
+
this._wiredControlName = void 0;
|
|
1548
|
+
return;
|
|
1549
|
+
}
|
|
1550
|
+
const path = this.parsePath(name);
|
|
1551
|
+
if (!path) {
|
|
1552
|
+
this._wiredFormGroup = void 0;
|
|
1553
|
+
this._wiredControlName = void 0;
|
|
1554
|
+
return;
|
|
1555
|
+
}
|
|
1556
|
+
const parent = this.ensureFormGroupPath(formGroup, path.slice(0, -1));
|
|
1557
|
+
if (!parent) {
|
|
1558
|
+
this._wiredFormGroup = void 0;
|
|
1559
|
+
this._wiredControlName = void 0;
|
|
1560
|
+
return;
|
|
1561
|
+
}
|
|
1562
|
+
const key = path[path.length - 1];
|
|
1563
|
+
const existing = parent.get(key);
|
|
1564
|
+
if (existing) {
|
|
1565
|
+
if (this.formControlPolicy()?.allowExistingControls !== true) {
|
|
1566
|
+
this.logWarning("A form control with the requested name already exists; reuse is disabled by formControlPolicy.");
|
|
1567
|
+
this._wiredFormGroup = void 0;
|
|
1568
|
+
this._wiredControlName = void 0;
|
|
1569
|
+
return;
|
|
1570
|
+
}
|
|
1571
|
+
if (!(existing instanceof FormControl)) {
|
|
1572
|
+
this.logWarning("A form control with the requested name already exists and is not a FormControl.");
|
|
1573
|
+
this._wiredFormGroup = void 0;
|
|
1574
|
+
this._wiredControlName = void 0;
|
|
1575
|
+
return;
|
|
1576
|
+
}
|
|
1577
|
+
this.logWarning("A form control with the requested name already exists; reusing it.");
|
|
1578
|
+
this._formControl = existing;
|
|
1579
|
+
this._ownsFormControl = false;
|
|
1580
|
+
} else {
|
|
1581
|
+
const control = new FormControl(this.getModelPropertyValue(this.getViewModelValue(), name, null));
|
|
1582
|
+
try {
|
|
1583
|
+
parent.addControl(key, control);
|
|
1584
|
+
this._formControl = control;
|
|
1585
|
+
this._ownsFormControl = true;
|
|
1586
|
+
} catch (error) {
|
|
1587
|
+
this.logError("Error adding form control.", error);
|
|
1588
|
+
return;
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
this._formControlContainer = parent;
|
|
1592
|
+
this._formControlKey = key;
|
|
1593
|
+
this._wiredFormGroup = formGroup;
|
|
1594
|
+
this._wiredControlName = name;
|
|
1595
|
+
this._disabledBeforeManagement = this._formControl.disabled;
|
|
1596
|
+
this.attachFormControlDirective();
|
|
1597
|
+
this.bindFormControlValueChanges(name);
|
|
1598
|
+
}
|
|
1599
|
+
ensureFormGroupPath(root, segments) {
|
|
1600
|
+
let current = root;
|
|
1601
|
+
for (const segment of segments) {
|
|
1602
|
+
const existing = current.get(segment);
|
|
1603
|
+
if (existing == null) {
|
|
1604
|
+
const group = new FormGroup({});
|
|
1605
|
+
try {
|
|
1606
|
+
current.addControl(segment, group);
|
|
1607
|
+
} catch (error) {
|
|
1608
|
+
this.logError("Error creating nested form group.", error);
|
|
1609
|
+
return null;
|
|
1610
|
+
}
|
|
1611
|
+
this._createdFormGroups.push({
|
|
1612
|
+
parent: current,
|
|
1613
|
+
key: segment,
|
|
1614
|
+
group
|
|
1615
|
+
});
|
|
1616
|
+
current = group;
|
|
1617
|
+
} else if (existing instanceof FormGroup) {
|
|
1618
|
+
if (this.formControlPolicy()?.allowExistingControls !== true) {
|
|
1619
|
+
this.logWarning(`Cannot reuse existing nested form group "${segment}" because formControlPolicy disables it.`);
|
|
1620
|
+
return null;
|
|
1621
|
+
}
|
|
1622
|
+
current = existing;
|
|
1623
|
+
} else {
|
|
1624
|
+
this.logWarning(`Cannot create nested form group "${segment}" because a different control already exists.`);
|
|
1625
|
+
return null;
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
return current;
|
|
1629
|
+
}
|
|
1630
|
+
bindFormControlValueChanges(name) {
|
|
1631
|
+
if (this._formControlSubscription) try {
|
|
1632
|
+
this._formControlSubscription.unsubscribe();
|
|
1633
|
+
} catch (e) {}
|
|
1634
|
+
this._formControlSubscription = this._formControl.valueChanges.subscribe((value) => {
|
|
1635
|
+
const currentModel = this.getViewModelValue();
|
|
1636
|
+
if (currentModel == null) return;
|
|
1637
|
+
const viewModel = this.cloneForMutation(currentModel);
|
|
1638
|
+
this.setModelPropertyValue(viewModel, name, value);
|
|
1639
|
+
try {
|
|
1640
|
+
this.viewModel.set(viewModel);
|
|
1641
|
+
if (this._componentRef?.changeDetectorRef) this._componentRef.changeDetectorRef.markForCheck();
|
|
1642
|
+
} catch (error) {
|
|
1643
|
+
this.logError("Error updating view model.", error);
|
|
1644
|
+
}
|
|
1645
|
+
});
|
|
1646
|
+
}
|
|
1647
|
+
cloneForMutation(value, seen = /* @__PURE__ */ new WeakMap()) {
|
|
1648
|
+
if (value == null || typeof value !== "object") return value;
|
|
1649
|
+
const source = value;
|
|
1650
|
+
if (seen.has(source)) return seen.get(source);
|
|
1651
|
+
if (Array.isArray(value)) {
|
|
1652
|
+
const copy = [];
|
|
1653
|
+
seen.set(source, copy);
|
|
1654
|
+
for (const item of value) copy.push(this.cloneForMutation(item, seen));
|
|
1655
|
+
return copy;
|
|
1656
|
+
}
|
|
1657
|
+
const prototype = Object.getPrototypeOf(value);
|
|
1658
|
+
if (prototype === Object.prototype || prototype === null) {
|
|
1659
|
+
const copy = {};
|
|
1660
|
+
seen.set(source, copy);
|
|
1661
|
+
for (const key of Object.keys(value)) this.defineOwn(copy, key, this.cloneForMutation(value[key], seen));
|
|
1662
|
+
return copy;
|
|
1663
|
+
}
|
|
1664
|
+
return value;
|
|
1665
|
+
}
|
|
1666
|
+
setControlDisabled(disabled) {
|
|
1667
|
+
if (!this._formControl) return;
|
|
1668
|
+
try {
|
|
1669
|
+
if (disabled && this._formControl.enabled) this._formControl.disable({
|
|
1670
|
+
onlySelf: true,
|
|
1671
|
+
emitEvent: false
|
|
1672
|
+
});
|
|
1673
|
+
else if (!disabled && this._formControl.disabled) this._formControl.enable({
|
|
1674
|
+
onlySelf: true,
|
|
1675
|
+
emitEvent: false
|
|
1676
|
+
});
|
|
1677
|
+
} catch (error) {
|
|
1678
|
+
this.logError("Error updating form control status.", error);
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
restoreManagedDisabledState() {
|
|
1682
|
+
if (!this._formControl || !this._disabledManaged) return;
|
|
1683
|
+
this.setControlDisabled(this._disabledBeforeManagement === true);
|
|
1684
|
+
this._disabledManaged = false;
|
|
1685
|
+
this._disabledBeforeManagement = void 0;
|
|
1686
|
+
}
|
|
1687
|
+
setFormControlStatus() {
|
|
1688
|
+
if (!this._formControl) return;
|
|
1689
|
+
const attributes = this.configuration()?.attributes;
|
|
1690
|
+
if (!attributes || !Object.hasOwn(attributes, "disabled")) {
|
|
1691
|
+
this.restoreManagedDisabledState();
|
|
1692
|
+
return;
|
|
1693
|
+
}
|
|
1694
|
+
const disabledAttr = attributes["disabled"];
|
|
1695
|
+
const evaluated = this.evaluateExpression(disabledAttr, this.getViewModelValue());
|
|
1696
|
+
if (this.isUnresolvedExpression(disabledAttr, evaluated)) return;
|
|
1697
|
+
const shouldDisable = this.toBoolean(evaluated);
|
|
1698
|
+
if (!this._disabledManaged) {
|
|
1699
|
+
this._disabledBeforeManagement = this._formControl.disabled;
|
|
1700
|
+
this._disabledManaged = true;
|
|
1701
|
+
}
|
|
1702
|
+
this.setControlDisabled(shouldDisable);
|
|
1703
|
+
}
|
|
1704
|
+
setFormControlValidators() {
|
|
1705
|
+
if (!this._formControl) return;
|
|
1706
|
+
if (this._managedValidatorFns.length > 0) {
|
|
1707
|
+
try {
|
|
1708
|
+
this._formControl.removeValidators(this._managedValidatorFns);
|
|
1709
|
+
} catch (error) {
|
|
1710
|
+
this.logError("Error removing managed validators.", error);
|
|
1711
|
+
}
|
|
1712
|
+
this._managedValidatorFns = [];
|
|
1713
|
+
try {
|
|
1714
|
+
this._formControl.updateValueAndValidity({
|
|
1715
|
+
onlySelf: true,
|
|
1716
|
+
emitEvent: false
|
|
1717
|
+
});
|
|
1718
|
+
} catch (error) {
|
|
1719
|
+
this.logError("Error updating form control validity.", error);
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
const attributes = this.configuration()?.attributes;
|
|
1723
|
+
if (attributes && Object.keys(attributes).length > 0 && this._componentRef?.location?.nativeElement) {
|
|
1724
|
+
const validators = [];
|
|
1725
|
+
if (Object.hasOwn(attributes, "min")) {
|
|
1726
|
+
const { value: min, unresolved } = this.evaluateAttribute(attributes, "min");
|
|
1727
|
+
if (!unresolved && typeof min === "number" && !isNaN(min)) validators.push(Validators.min(min));
|
|
1728
|
+
}
|
|
1729
|
+
if (Object.hasOwn(attributes, "max")) {
|
|
1730
|
+
const { value: max, unresolved } = this.evaluateAttribute(attributes, "max");
|
|
1731
|
+
if (!unresolved && typeof max === "number" && !isNaN(max)) validators.push(Validators.max(max));
|
|
1732
|
+
}
|
|
1733
|
+
if (Object.hasOwn(attributes, "required")) {
|
|
1734
|
+
const { value: required, unresolved } = this.evaluateAttribute(attributes, "required");
|
|
1735
|
+
if (!unresolved && required === true) validators.push(Validators.required);
|
|
1736
|
+
}
|
|
1737
|
+
if (Object.hasOwn(attributes, "email")) {
|
|
1738
|
+
const { value: email, unresolved } = this.evaluateAttribute(attributes, "email");
|
|
1739
|
+
if (!unresolved && email === true) validators.push(Validators.email);
|
|
1740
|
+
}
|
|
1741
|
+
if (Object.hasOwn(attributes, "maxlength")) {
|
|
1742
|
+
const { value: maxLength, unresolved } = this.evaluateAttribute(attributes, "maxlength");
|
|
1743
|
+
if (!unresolved && typeof maxLength === "number" && !isNaN(maxLength) && maxLength >= 0) validators.push(Validators.maxLength(maxLength));
|
|
1744
|
+
}
|
|
1745
|
+
if (Object.hasOwn(attributes, "minlength")) {
|
|
1746
|
+
const { value: minLength, unresolved } = this.evaluateAttribute(attributes, "minlength");
|
|
1747
|
+
if (!unresolved && typeof minLength === "number" && !isNaN(minLength) && minLength >= 0) validators.push(Validators.minLength(minLength));
|
|
1748
|
+
}
|
|
1749
|
+
if (Object.hasOwn(attributes, "pattern")) {
|
|
1750
|
+
const { value: pattern, unresolved } = this.evaluateAttribute(attributes, "pattern");
|
|
1751
|
+
const patternValidator = unresolved ? null : this.createPatternValidator(pattern);
|
|
1752
|
+
if (patternValidator) validators.push(patternValidator);
|
|
1753
|
+
}
|
|
1754
|
+
if (validators.length > 0) {
|
|
1755
|
+
this._managedValidatorFns = validators;
|
|
1756
|
+
try {
|
|
1757
|
+
this._formControl.addValidators(this._managedValidatorFns);
|
|
1758
|
+
} catch (error) {
|
|
1759
|
+
this.logError("Error adding managed validators.", error);
|
|
1760
|
+
}
|
|
1761
|
+
} else this._managedValidatorFns = [];
|
|
1762
|
+
try {
|
|
1763
|
+
this._formControl.updateValueAndValidity({
|
|
1764
|
+
onlySelf: true,
|
|
1765
|
+
emitEvent: false
|
|
1766
|
+
});
|
|
1767
|
+
} catch (error) {
|
|
1768
|
+
this.logError("Error updating form control validity.", error);
|
|
1769
|
+
}
|
|
1770
|
+
} else this._managedValidatorFns = [];
|
|
1771
|
+
}
|
|
1772
|
+
createPatternValidator(pattern) {
|
|
1773
|
+
let regex;
|
|
1774
|
+
if (typeof pattern === "string") {
|
|
1775
|
+
if (pattern.length === 0 || pattern.length > MAX_PATTERN_LENGTH) {
|
|
1776
|
+
this.logWarning("Pattern validator was ignored because its source is empty or too long.");
|
|
1777
|
+
return null;
|
|
1778
|
+
}
|
|
1779
|
+
if (this.isUnsafeRegex(pattern)) {
|
|
1780
|
+
this.logWarning("Pattern validator was ignored because the expression is potentially unsafe.");
|
|
1781
|
+
return null;
|
|
1782
|
+
}
|
|
1783
|
+
try {
|
|
1784
|
+
const anchored = (pattern.startsWith("^") ? "" : "^") + pattern + (pattern.endsWith("$") ? "" : "$");
|
|
1785
|
+
regex = new RegExp(anchored);
|
|
1786
|
+
} catch (error) {
|
|
1787
|
+
this.logError("Pattern validator was ignored because the expression is invalid.", error);
|
|
1788
|
+
return null;
|
|
1789
|
+
}
|
|
1790
|
+
} else if (pattern instanceof RegExp) {
|
|
1791
|
+
if (pattern.source.length > MAX_PATTERN_LENGTH || this.isUnsafeRegex(pattern.source)) {
|
|
1792
|
+
this.logWarning("Pattern validator was ignored because the expression is potentially unsafe.");
|
|
1793
|
+
return null;
|
|
1794
|
+
}
|
|
1795
|
+
try {
|
|
1796
|
+
regex = new RegExp(pattern.source, pattern.flags.replace(/[gy]/g, ""));
|
|
1797
|
+
} catch (error) {
|
|
1798
|
+
this.logError("Pattern validator was ignored because the expression is invalid.", error);
|
|
1799
|
+
return null;
|
|
1800
|
+
}
|
|
1801
|
+
} else return null;
|
|
1802
|
+
const baseValidator = Validators.pattern(regex);
|
|
1803
|
+
return (control) => {
|
|
1804
|
+
const value = control.value;
|
|
1805
|
+
if (value == null) return baseValidator(control);
|
|
1806
|
+
if (typeof value !== "string" && typeof value !== "number") return { pattern: { requiredPattern: regex.toString() } };
|
|
1807
|
+
if (typeof value === "string" && value.length > MAX_PATTERN_INPUT_LENGTH) return { pattern: { requiredPattern: regex.toString() } };
|
|
1808
|
+
return baseValidator(control);
|
|
1809
|
+
};
|
|
1810
|
+
}
|
|
1811
|
+
isUnsafeRegex(source) {
|
|
1812
|
+
if (source.length > MAX_PATTERN_LENGTH) return true;
|
|
1813
|
+
const stack = [{
|
|
1814
|
+
hasQuantifier: false,
|
|
1815
|
+
hasAlternation: false
|
|
1816
|
+
}];
|
|
1817
|
+
let inCharacterClass = false;
|
|
1818
|
+
const isQuantifierAt = (index) => {
|
|
1819
|
+
const character = source[index];
|
|
1820
|
+
if (character === "+" || character === "*") return true;
|
|
1821
|
+
if (character !== "{") return false;
|
|
1822
|
+
const match = /^\{\d+(?:,\d*)?\}/.exec(source.slice(index));
|
|
1823
|
+
if (!match) return false;
|
|
1824
|
+
const bounds = /^\{(\d+)(?:,(\d*))?\}/.exec(match[0]);
|
|
1825
|
+
if (bounds) {
|
|
1826
|
+
const upper = bounds[2] === void 0 || bounds[2] === "" ? Infinity : Number(bounds[2]);
|
|
1827
|
+
if (Number.isFinite(upper) && upper > 1e4) return true;
|
|
1828
|
+
}
|
|
1829
|
+
return true;
|
|
1830
|
+
};
|
|
1831
|
+
for (let index = 0; index < source.length; index++) {
|
|
1832
|
+
const character = source[index];
|
|
1833
|
+
if (character === "\\") {
|
|
1834
|
+
const next = source[index + 1];
|
|
1835
|
+
if (next && /[1-9]/.test(next)) {
|
|
1836
|
+
let cursor = index + 2;
|
|
1837
|
+
while (cursor < source.length && /\d/.test(source[cursor])) cursor++;
|
|
1838
|
+
if (isQuantifierAt(cursor)) return true;
|
|
1839
|
+
}
|
|
1840
|
+
index++;
|
|
1841
|
+
continue;
|
|
1842
|
+
}
|
|
1843
|
+
if (inCharacterClass) {
|
|
1844
|
+
if (character === "]") inCharacterClass = false;
|
|
1845
|
+
continue;
|
|
1846
|
+
}
|
|
1847
|
+
if (character === "[") {
|
|
1848
|
+
inCharacterClass = true;
|
|
1849
|
+
continue;
|
|
1850
|
+
}
|
|
1851
|
+
if (character === "(") {
|
|
1852
|
+
stack.push({
|
|
1853
|
+
hasQuantifier: false,
|
|
1854
|
+
hasAlternation: false
|
|
1855
|
+
});
|
|
1856
|
+
if (source[index + 1] === "?") index++;
|
|
1857
|
+
continue;
|
|
1858
|
+
}
|
|
1859
|
+
if (character === ")") {
|
|
1860
|
+
const group = stack.pop();
|
|
1861
|
+
if (group) {
|
|
1862
|
+
const quantified = isQuantifierAt(index + 1);
|
|
1863
|
+
if (quantified && (group.hasQuantifier || group.hasAlternation)) return true;
|
|
1864
|
+
const parent = stack[stack.length - 1];
|
|
1865
|
+
if (parent) {
|
|
1866
|
+
if (quantified || group.hasQuantifier) parent.hasQuantifier = true;
|
|
1867
|
+
if (group.hasAlternation) parent.hasAlternation = true;
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
continue;
|
|
1871
|
+
}
|
|
1872
|
+
if (character === "|") {
|
|
1873
|
+
stack[stack.length - 1].hasAlternation = true;
|
|
1874
|
+
continue;
|
|
1875
|
+
}
|
|
1876
|
+
if (character === "+" || character === "*" || character === "{" || character === "?") {
|
|
1877
|
+
if (character === "?" && source[index - 1] === "(") continue;
|
|
1878
|
+
if (character === "{" && !/^\{\d+(?:,\d*)?\}/.test(source.slice(index))) continue;
|
|
1879
|
+
if (character === "{" && isQuantifierAt(index)) {
|
|
1880
|
+
const bounds = /^\{(\d+)(?:,(\d*))?\}/.exec(source.slice(index));
|
|
1881
|
+
const upper = bounds && bounds[2] !== void 0 && bounds[2] !== "" ? Number(bounds[2]) : Infinity;
|
|
1882
|
+
if (Number.isFinite(upper) && upper > 1e4) return true;
|
|
1883
|
+
}
|
|
1884
|
+
stack[stack.length - 1].hasQuantifier = true;
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
return false;
|
|
1888
|
+
}
|
|
1889
|
+
attachFormControlDirective() {
|
|
1890
|
+
if (this._formControlDirective && this._componentRef?.injector && this._formControl) try {
|
|
1891
|
+
const valueAccessors = this._componentRef.injector.get(NG_VALUE_ACCESSOR, null);
|
|
1892
|
+
this._formControlDirective.valueAccessor = Array.isArray(valueAccessors) && valueAccessors.length > 0 ? valueAccessors[0] : null;
|
|
1893
|
+
this._formControlDirective.form = this._formControl;
|
|
1894
|
+
this._formControlDirective.ngOnChanges({ form: {
|
|
1895
|
+
firstChange: true,
|
|
1896
|
+
currentValue: this._formControl,
|
|
1897
|
+
previousValue: void 0,
|
|
1898
|
+
isFirstChange: () => true
|
|
1899
|
+
} });
|
|
1900
|
+
} catch (error) {
|
|
1901
|
+
this.logError("Error attaching form control directive.", error);
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
parsePath(property) {
|
|
1905
|
+
if (property == null) return null;
|
|
1906
|
+
let pathArray = null;
|
|
1907
|
+
if (Array.isArray(property)) pathArray = property.filter((segment) => segment != null && segment !== "").map((segment) => String(segment));
|
|
1908
|
+
else if (typeof property === "string") pathArray = this.parseStringPath(property);
|
|
1909
|
+
if (!pathArray || pathArray.length === 0 || pathArray.length > MAX_PATH_DEPTH) return null;
|
|
1910
|
+
for (const segment of pathArray) {
|
|
1911
|
+
if (segment.length === 0 || segment.length > MAX_PATH_SEGMENT_LENGTH) return null;
|
|
1912
|
+
if (FORBIDDEN_PATH_SEGMENTS.has(segment.toLowerCase())) return null;
|
|
1913
|
+
}
|
|
1914
|
+
return pathArray;
|
|
1915
|
+
}
|
|
1916
|
+
parseStringPath(property) {
|
|
1917
|
+
const source = property.trim();
|
|
1918
|
+
if (source.length === 0) return null;
|
|
1919
|
+
const segments = [];
|
|
1920
|
+
let index = 0;
|
|
1921
|
+
let expectingSegment = true;
|
|
1922
|
+
while (index < source.length) {
|
|
1923
|
+
const character = source[index];
|
|
1924
|
+
if (character === ".") {
|
|
1925
|
+
if (expectingSegment) return null;
|
|
1926
|
+
expectingSegment = true;
|
|
1927
|
+
index++;
|
|
1928
|
+
continue;
|
|
1929
|
+
}
|
|
1930
|
+
if (character === "[") {
|
|
1931
|
+
index++;
|
|
1932
|
+
let value = "";
|
|
1933
|
+
if (source[index] === "\"" || source[index] === "'") {
|
|
1934
|
+
const quote = source[index];
|
|
1935
|
+
index++;
|
|
1936
|
+
let closed = false;
|
|
1937
|
+
while (index < source.length) {
|
|
1938
|
+
const current = source[index];
|
|
1939
|
+
if (current === "\\") {
|
|
1940
|
+
if (index + 1 >= source.length) return null;
|
|
1941
|
+
value += source[index + 1];
|
|
1942
|
+
index += 2;
|
|
1943
|
+
continue;
|
|
1944
|
+
}
|
|
1945
|
+
if (current === quote) {
|
|
1946
|
+
index++;
|
|
1947
|
+
closed = true;
|
|
1948
|
+
break;
|
|
1949
|
+
}
|
|
1950
|
+
value += current;
|
|
1951
|
+
index++;
|
|
1952
|
+
}
|
|
1953
|
+
if (!closed) return null;
|
|
1954
|
+
} else {
|
|
1955
|
+
const start = index;
|
|
1956
|
+
while (index < source.length && source[index] !== "]") {
|
|
1957
|
+
if (source[index] === "[" || source[index] === ".") return null;
|
|
1958
|
+
value += source[index];
|
|
1959
|
+
index++;
|
|
1960
|
+
}
|
|
1961
|
+
if (index === start) return null;
|
|
1962
|
+
value = value.trim();
|
|
1963
|
+
}
|
|
1964
|
+
if (source[index] !== "]" || value.length === 0) return null;
|
|
1965
|
+
index++;
|
|
1966
|
+
segments.push(value);
|
|
1967
|
+
expectingSegment = false;
|
|
1968
|
+
continue;
|
|
1969
|
+
}
|
|
1970
|
+
if (!expectingSegment) return null;
|
|
1971
|
+
let value = "";
|
|
1972
|
+
while (index < source.length && source[index] !== "." && source[index] !== "[") {
|
|
1973
|
+
value += source[index];
|
|
1974
|
+
index++;
|
|
1975
|
+
}
|
|
1976
|
+
if (value.length === 0) return null;
|
|
1977
|
+
segments.push(value);
|
|
1978
|
+
expectingSegment = false;
|
|
1979
|
+
}
|
|
1980
|
+
if (expectingSegment) return null;
|
|
1981
|
+
return segments;
|
|
1982
|
+
}
|
|
1983
|
+
isSafePath(property) {
|
|
1984
|
+
return this.parsePath(property) !== null;
|
|
1985
|
+
}
|
|
1986
|
+
defineOwn(target, key, value) {
|
|
1987
|
+
Object.defineProperty(target, key, {
|
|
1988
|
+
value,
|
|
1989
|
+
writable: true,
|
|
1990
|
+
enumerable: true,
|
|
1991
|
+
configurable: true
|
|
1992
|
+
});
|
|
1993
|
+
}
|
|
1994
|
+
isMutableContainer(value) {
|
|
1995
|
+
if (value == null || typeof value !== "object") return false;
|
|
1996
|
+
if (Array.isArray(value)) return true;
|
|
1997
|
+
const prototype = Object.getPrototypeOf(value);
|
|
1998
|
+
return prototype === Object.prototype || prototype === null;
|
|
1999
|
+
}
|
|
2000
|
+
getModelPropertyValue(model, property, defaultValue) {
|
|
2001
|
+
if (model == null) return defaultValue;
|
|
2002
|
+
const pathArray = this.parsePath(property);
|
|
2003
|
+
if (!pathArray) return defaultValue;
|
|
2004
|
+
try {
|
|
2005
|
+
let current = model;
|
|
2006
|
+
for (const key of pathArray) {
|
|
2007
|
+
if (current == null) return defaultValue;
|
|
2008
|
+
const container = Object(current);
|
|
2009
|
+
if (!Object.hasOwn(container, key)) return defaultValue;
|
|
2010
|
+
current = container[key];
|
|
2011
|
+
}
|
|
2012
|
+
return current != null ? current : defaultValue;
|
|
2013
|
+
} catch {
|
|
2014
|
+
return defaultValue;
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
setModelPropertyValue(model, property, value) {
|
|
2018
|
+
if (model == null) return;
|
|
2019
|
+
const pathArray = this.parsePath(property);
|
|
2020
|
+
if (!pathArray) return;
|
|
2021
|
+
try {
|
|
2022
|
+
let current = model;
|
|
2023
|
+
for (let index = 0; index < pathArray.length; index++) {
|
|
2024
|
+
const key = pathArray[index];
|
|
2025
|
+
const isLast = index === pathArray.length - 1;
|
|
2026
|
+
if (!this.isMutableContainer(current)) return;
|
|
2027
|
+
if (isLast) {
|
|
2028
|
+
this.defineOwn(current, key, value);
|
|
2029
|
+
return;
|
|
2030
|
+
}
|
|
2031
|
+
const isNumericKey = /^\d+$/.test(key);
|
|
2032
|
+
const existing = Object.hasOwn(current, key) ? current[key] : void 0;
|
|
2033
|
+
if (existing == null) {
|
|
2034
|
+
const next = isNumericKey ? [] : {};
|
|
2035
|
+
this.defineOwn(current, key, next);
|
|
2036
|
+
current = next;
|
|
2037
|
+
} else if (isNumericKey && !Array.isArray(existing)) {
|
|
2038
|
+
if (existing !== null && typeof existing === "object") current = existing;
|
|
2039
|
+
else return;
|
|
2040
|
+
} else if (!isNumericKey && typeof existing !== "object") {
|
|
2041
|
+
const next = {};
|
|
2042
|
+
this.defineOwn(current, key, next);
|
|
2043
|
+
current = next;
|
|
2044
|
+
} else current = existing;
|
|
2045
|
+
}
|
|
2046
|
+
} catch (error) {
|
|
2047
|
+
this.logError("Error setting model property value.", error);
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
setInputs() {
|
|
2051
|
+
if (!this._componentRef) return;
|
|
2052
|
+
const inputs = this.configuration()?.inputs;
|
|
2053
|
+
const currentNames = inputs && typeof inputs === "object" ? Object.keys(inputs) : [];
|
|
2054
|
+
for (const inputName of Array.from(this._appliedInputs)) if (!currentNames.includes(inputName)) {
|
|
2055
|
+
try {
|
|
2056
|
+
this._componentRef.setInput(inputName, void 0);
|
|
2057
|
+
} catch (error) {
|
|
2058
|
+
this.logError(`Error resetting dynamic input "${inputName}".`, error);
|
|
2059
|
+
}
|
|
2060
|
+
this._appliedInputs.delete(inputName);
|
|
2061
|
+
}
|
|
2062
|
+
if (!inputs || typeof inputs !== "object") return;
|
|
2063
|
+
for (const inputName of currentNames) try {
|
|
2064
|
+
this._componentRef.setInput(inputName, this.evaluateExpression(inputs[inputName], this.getViewModelValue()));
|
|
2065
|
+
this._appliedInputs.add(inputName);
|
|
2066
|
+
} catch (error) {
|
|
2067
|
+
this.logError(`Error setting dynamic input "${inputName}".`, error);
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
setAttributes() {
|
|
2071
|
+
const attributes = this.configuration()?.attributes;
|
|
2072
|
+
const element = this._componentRef?.location?.nativeElement;
|
|
2073
|
+
if (!element) return;
|
|
2074
|
+
const currentNames = attributes && typeof attributes === "object" ? Object.keys(attributes) : [];
|
|
2075
|
+
for (const attributeName of Array.from(this._appliedAttributes)) if (!currentNames.includes(attributeName) || !this.isAllowedAttribute(attributeName)) {
|
|
2076
|
+
this._renderer.removeAttribute(element, attributeName);
|
|
2077
|
+
this._appliedAttributes.delete(attributeName);
|
|
2078
|
+
}
|
|
2079
|
+
if (!attributes || typeof attributes !== "object") return;
|
|
2080
|
+
for (const attributeName of currentNames) {
|
|
2081
|
+
if (!this.isAllowedAttribute(attributeName)) {
|
|
2082
|
+
this.logWarning(`Attribute "${attributeName}" is not allowed and was skipped.`);
|
|
2083
|
+
continue;
|
|
2084
|
+
}
|
|
2085
|
+
try {
|
|
2086
|
+
const rawValue = attributes[attributeName];
|
|
2087
|
+
const value = this.evaluateExpression(rawValue, this.getViewModelValue());
|
|
2088
|
+
if (this.isUnresolvedExpression(rawValue, value)) continue;
|
|
2089
|
+
const lower = attributeName.toLowerCase();
|
|
2090
|
+
if (BOOLEAN_ATTRIBUTES.has(lower)) {
|
|
2091
|
+
if (!this.toBoolean(value)) {
|
|
2092
|
+
this._renderer.removeAttribute(element, attributeName);
|
|
2093
|
+
this._appliedAttributes.delete(attributeName);
|
|
2094
|
+
} else if (element.getAttribute(attributeName) !== "") {
|
|
2095
|
+
this._renderer.setAttribute(element, attributeName, "");
|
|
2096
|
+
this._appliedAttributes.add(attributeName);
|
|
2097
|
+
} else this._appliedAttributes.add(attributeName);
|
|
2098
|
+
continue;
|
|
2099
|
+
}
|
|
2100
|
+
const stringValue = this.attributeValueToString(value);
|
|
2101
|
+
if (stringValue === void 0) continue;
|
|
2102
|
+
if (stringValue === null) {
|
|
2103
|
+
this._renderer.removeAttribute(element, attributeName);
|
|
2104
|
+
this._appliedAttributes.delete(attributeName);
|
|
2105
|
+
continue;
|
|
2106
|
+
}
|
|
2107
|
+
if (URL_ATTRIBUTES.has(lower) && !this.isSafeUrl(stringValue)) {
|
|
2108
|
+
this.logWarning(`Unsafe URL for attribute "${attributeName}" was ignored.`);
|
|
2109
|
+
continue;
|
|
2110
|
+
}
|
|
2111
|
+
if (element.getAttribute(attributeName) !== stringValue) this._renderer.setAttribute(element, attributeName, stringValue);
|
|
2112
|
+
this._appliedAttributes.add(attributeName);
|
|
2113
|
+
} catch (error) {
|
|
2114
|
+
this.logError(`Error setting dynamic attribute "${attributeName}".`, error);
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
isAllowedAttribute(name) {
|
|
2119
|
+
if (typeof name !== "string" || name.length === 0 || name.length > MAX_ATTRIBUTE_NAME_LENGTH) return false;
|
|
2120
|
+
const lower = name.toLowerCase();
|
|
2121
|
+
if (lower.startsWith("on")) return false;
|
|
2122
|
+
if (!/^[a-z][a-z0-9_.-]*$/i.test(name)) return false;
|
|
2123
|
+
if (this.attributePolicy()?.strict === true && STRICT_DISALLOWED_ATTRIBUTES.has(lower)) return false;
|
|
2124
|
+
if (lower.startsWith("data-") || lower.startsWith("aria-")) return true;
|
|
2125
|
+
return ALLOWED_ATTRIBUTES.has(lower);
|
|
2126
|
+
}
|
|
2127
|
+
attributeValueToString(value) {
|
|
2128
|
+
if (value == null) return null;
|
|
2129
|
+
const type = typeof value;
|
|
2130
|
+
if (type !== "string" && type !== "number" && type !== "boolean" && type !== "bigint") {
|
|
2131
|
+
this.logWarning("Non-primitive attribute values are ignored.");
|
|
2132
|
+
return;
|
|
2133
|
+
}
|
|
2134
|
+
const stringValue = String(value);
|
|
2135
|
+
if (stringValue.length > MAX_ATTRIBUTE_VALUE_LENGTH) {
|
|
2136
|
+
this.logWarning("Attribute value is too long and was ignored.");
|
|
2137
|
+
return;
|
|
2138
|
+
}
|
|
2139
|
+
return stringValue;
|
|
2140
|
+
}
|
|
2141
|
+
isSafeUrl(value) {
|
|
2142
|
+
const normalized = value.replace(/[\u0000-\u0020\u007f]/g, "").toLowerCase();
|
|
2143
|
+
if (normalized.length === 0) return true;
|
|
2144
|
+
const scheme = /^([a-z][a-z0-9+.-]*):/.exec(normalized);
|
|
2145
|
+
if (!scheme) return true;
|
|
2146
|
+
return scheme[1] === "http" || scheme[1] === "https" || scheme[1] === "mailto" || scheme[1] === "tel";
|
|
2147
|
+
}
|
|
2148
|
+
evaluateAttribute(attributes, name) {
|
|
2149
|
+
const raw = attributes[name];
|
|
2150
|
+
const value = this.evaluateExpression(raw, this.getViewModelValue());
|
|
2151
|
+
return {
|
|
2152
|
+
value,
|
|
2153
|
+
unresolved: this.isUnresolvedExpression(raw, value)
|
|
2154
|
+
};
|
|
2155
|
+
}
|
|
2156
|
+
isUnresolvedExpression(source, result) {
|
|
2157
|
+
return typeof source === "string" && result === source && (source.includes("$vm") || source.includes("$event") || source.includes("$ev"));
|
|
2158
|
+
}
|
|
2159
|
+
toBoolean(value) {
|
|
2160
|
+
if (typeof value === "boolean") return value;
|
|
2161
|
+
if (typeof value === "number") return value !== 0 && !Number.isNaN(value);
|
|
2162
|
+
if (typeof value === "string") {
|
|
2163
|
+
const normalized = value.trim().toLowerCase();
|
|
2164
|
+
return normalized !== "" && normalized !== "false" && normalized !== "0" && normalized !== "null" && normalized !== "undefined";
|
|
2165
|
+
}
|
|
2166
|
+
return value != null;
|
|
2167
|
+
}
|
|
2168
|
+
evaluateExpression(value, viewModelValue, eventParam, hasEventContext = false) {
|
|
2169
|
+
if (typeof value !== "string") return value;
|
|
2170
|
+
const hasVm = value.includes("$vm");
|
|
2171
|
+
const hasEvent = value.includes("$event") || value.includes("$ev");
|
|
2172
|
+
if (!hasVm && !hasEvent) return value;
|
|
2173
|
+
if (hasVm && viewModelValue == null) return value;
|
|
2174
|
+
if (hasEvent && !hasEventContext) return value;
|
|
2175
|
+
try {
|
|
2176
|
+
const policy = this.expressionPolicy() ?? {};
|
|
2177
|
+
const allowedMethods = new Set(Array.isArray(policy.allowedMethods) ? policy.allowedMethods : []);
|
|
2178
|
+
const $vm = () => this.getViewModelValue();
|
|
2179
|
+
if (policy.allowViewModelMutation === true) {
|
|
2180
|
+
$vm.set = (nextValue) => {
|
|
2181
|
+
this.viewModel.set(nextValue);
|
|
2182
|
+
};
|
|
2183
|
+
$vm.update = (updateFn) => {
|
|
2184
|
+
this.viewModel.update(updateFn);
|
|
2185
|
+
};
|
|
2186
|
+
allowedMethods.add("set");
|
|
2187
|
+
allowedMethods.add("update");
|
|
2188
|
+
}
|
|
2189
|
+
return evaluateSafeExpression(value, {
|
|
2190
|
+
$vm,
|
|
2191
|
+
$event: eventParam,
|
|
2192
|
+
$ev: eventParam
|
|
2193
|
+
}, {
|
|
2194
|
+
allowCustomMethods: policy.allowCustomMethods === true,
|
|
2195
|
+
allowedMethods: Array.from(allowedMethods)
|
|
2196
|
+
});
|
|
2197
|
+
} catch {
|
|
2198
|
+
this.logWarning("Expression could not be evaluated safely and was ignored.");
|
|
2199
|
+
return;
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
getViewModelValue() {
|
|
2203
|
+
const model = this.viewModel;
|
|
2204
|
+
return typeof model === "function" ? model() : model;
|
|
2205
|
+
}
|
|
2206
|
+
logWarning(message) {
|
|
2207
|
+
if (isDevMode()) console.warn(`[fg-dynamic] ${message}`);
|
|
2208
|
+
}
|
|
2209
|
+
logError(message, error) {
|
|
2210
|
+
if (!isDevMode()) return;
|
|
2211
|
+
const detail = error instanceof Error ? ` (${error.name})` : "";
|
|
2212
|
+
console.error(`[fg-dynamic] ${message}${detail}`);
|
|
2213
|
+
}
|
|
2214
|
+
cleanup() {
|
|
2215
|
+
if (this._outputsSubscriptions) this._outputsSubscriptions.forEach((s) => {
|
|
2216
|
+
try {
|
|
2217
|
+
s.unsubscribe();
|
|
2218
|
+
} catch (e) {}
|
|
2219
|
+
});
|
|
2220
|
+
this._outputsSubscriptions = [];
|
|
2221
|
+
this._currentOutputsConfig = void 0;
|
|
2222
|
+
if (this._formControlSubscription) try {
|
|
2223
|
+
this._formControlSubscription.unsubscribe();
|
|
2224
|
+
} catch (e) {}
|
|
2225
|
+
this._formControlSubscription = void 0;
|
|
2226
|
+
this.restoreManagedDisabledState();
|
|
2227
|
+
if (this._formControlDirective) try {
|
|
2228
|
+
this._formControlDirective.ngOnDestroy();
|
|
2229
|
+
} catch (e) {}
|
|
2230
|
+
this._formControlDirective = void 0;
|
|
2231
|
+
if (this._ownsFormControl && this._formControl && this._formControlContainer && this._formControlKey) try {
|
|
2232
|
+
if (this._formControlContainer.get(this._formControlKey) === this._formControl) this._formControlContainer.removeControl(this._formControlKey);
|
|
2233
|
+
} catch (e) {}
|
|
2234
|
+
for (let index = this._createdFormGroups.length - 1; index >= 0; index--) {
|
|
2235
|
+
const { parent, key, group } = this._createdFormGroups[index];
|
|
2236
|
+
try {
|
|
2237
|
+
if (parent.get(key) === group && Object.keys(group.controls).length === 0) parent.removeControl(key);
|
|
2238
|
+
} catch (e) {}
|
|
2239
|
+
}
|
|
2240
|
+
this._createdFormGroups = [];
|
|
2241
|
+
this._formControl = void 0;
|
|
2242
|
+
this._formControlContainer = void 0;
|
|
2243
|
+
this._formControlKey = void 0;
|
|
2244
|
+
this._ownsFormControl = false;
|
|
2245
|
+
this._disabledManaged = false;
|
|
2246
|
+
this._disabledBeforeManagement = void 0;
|
|
2247
|
+
this._wiredFormGroup = void 0;
|
|
2248
|
+
this._wiredControlName = void 0;
|
|
2249
|
+
this._managedValidatorFns = [];
|
|
2250
|
+
this._appliedAttributes.clear();
|
|
2251
|
+
this._appliedInputs.clear();
|
|
2252
|
+
if (this._componentRef) try {
|
|
2253
|
+
this._componentRef.destroy();
|
|
2254
|
+
} catch (e) {}
|
|
2255
|
+
this._componentRef = void 0;
|
|
2256
|
+
}
|
|
2257
|
+
ngOnDestroy() {
|
|
2258
|
+
this.cleanup();
|
|
2259
|
+
}
|
|
2260
|
+
static {
|
|
2261
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
2262
|
+
minVersion: "12.0.0",
|
|
2263
|
+
version: "22.2.3",
|
|
2264
|
+
ngImport: i0,
|
|
2265
|
+
type: FGDynamicComponent,
|
|
2266
|
+
deps: [],
|
|
2267
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
2268
|
+
});
|
|
2269
|
+
}
|
|
2270
|
+
static {
|
|
2271
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
2272
|
+
minVersion: "17.0.0",
|
|
2273
|
+
version: "22.2.3",
|
|
2274
|
+
type: FGDynamicComponent,
|
|
2275
|
+
isStandalone: true,
|
|
2276
|
+
selector: "fg-dynamic",
|
|
2277
|
+
inputs: {
|
|
2278
|
+
configuration: {
|
|
2279
|
+
classPropertyName: "configuration",
|
|
2280
|
+
publicName: "configuration",
|
|
2281
|
+
isSignal: true,
|
|
2282
|
+
isRequired: true,
|
|
2283
|
+
transformFunction: null
|
|
2284
|
+
},
|
|
2285
|
+
viewModel: {
|
|
2286
|
+
classPropertyName: "viewModel",
|
|
2287
|
+
publicName: "viewModel",
|
|
2288
|
+
isSignal: true,
|
|
2289
|
+
isRequired: false,
|
|
2290
|
+
transformFunction: null
|
|
2291
|
+
},
|
|
2292
|
+
formGroup: {
|
|
2293
|
+
classPropertyName: "formGroup",
|
|
2294
|
+
publicName: "formGroup",
|
|
2295
|
+
isSignal: true,
|
|
2296
|
+
isRequired: false,
|
|
2297
|
+
transformFunction: null
|
|
2298
|
+
},
|
|
2299
|
+
registry: {
|
|
2300
|
+
classPropertyName: "registry",
|
|
2301
|
+
publicName: "registry",
|
|
2302
|
+
isSignal: true,
|
|
2303
|
+
isRequired: false,
|
|
2304
|
+
transformFunction: null
|
|
2305
|
+
},
|
|
2306
|
+
expressionPolicy: {
|
|
2307
|
+
classPropertyName: "expressionPolicy",
|
|
2308
|
+
publicName: "expressionPolicy",
|
|
2309
|
+
isSignal: true,
|
|
2310
|
+
isRequired: false,
|
|
2311
|
+
transformFunction: null
|
|
2312
|
+
},
|
|
2313
|
+
formControlPolicy: {
|
|
2314
|
+
classPropertyName: "formControlPolicy",
|
|
2315
|
+
publicName: "formControlPolicy",
|
|
2316
|
+
isSignal: true,
|
|
2317
|
+
isRequired: false,
|
|
2318
|
+
transformFunction: null
|
|
2319
|
+
},
|
|
2320
|
+
typePolicy: {
|
|
2321
|
+
classPropertyName: "typePolicy",
|
|
2322
|
+
publicName: "typePolicy",
|
|
2323
|
+
isSignal: true,
|
|
2324
|
+
isRequired: false,
|
|
2325
|
+
transformFunction: null
|
|
2326
|
+
},
|
|
2327
|
+
attributePolicy: {
|
|
2328
|
+
classPropertyName: "attributePolicy",
|
|
2329
|
+
publicName: "attributePolicy",
|
|
2330
|
+
isSignal: true,
|
|
2331
|
+
isRequired: false,
|
|
2332
|
+
transformFunction: null
|
|
2333
|
+
},
|
|
2334
|
+
depth: {
|
|
2335
|
+
classPropertyName: "depth",
|
|
2336
|
+
publicName: "depth",
|
|
2337
|
+
isSignal: true,
|
|
2338
|
+
isRequired: false,
|
|
2339
|
+
transformFunction: null
|
|
2340
|
+
}
|
|
2341
|
+
},
|
|
2342
|
+
outputs: { viewModel: "viewModelChange" },
|
|
2343
|
+
viewQueries: [{
|
|
2344
|
+
propertyName: "_viewContainerRef",
|
|
2345
|
+
first: true,
|
|
2346
|
+
predicate: ["viewContainer"],
|
|
2347
|
+
descendants: true,
|
|
2348
|
+
read: ViewContainerRef,
|
|
2349
|
+
isSignal: true
|
|
2350
|
+
}, {
|
|
2351
|
+
propertyName: "_dynamicItems",
|
|
2352
|
+
predicate: ["dynamicItem"],
|
|
2353
|
+
descendants: true,
|
|
2354
|
+
read: ElementRef,
|
|
2355
|
+
isSignal: true
|
|
2356
|
+
}],
|
|
2357
|
+
usesOnChanges: true,
|
|
2358
|
+
ngImport: i0,
|
|
2359
|
+
template: `
|
|
436
2360
|
<ng-container #viewContainer></ng-container>
|
|
437
|
-
@for (item of
|
|
438
|
-
<fg-dynamic #dynamicItem [configuration]="item" [(viewModel)]="viewModel" [formGroup]="formGroup()" />
|
|
2361
|
+
@for (item of items(); track $index) {
|
|
2362
|
+
<fg-dynamic #dynamicItem [configuration]="item" [(viewModel)]="viewModel" [formGroup]="formGroup()" [registry]="registry()" [expressionPolicy]="expressionPolicy()" [formControlPolicy]="formControlPolicy()" [typePolicy]="typePolicy()" [attributePolicy]="attributePolicy()" [depth]="depth() + 1" />
|
|
439
2363
|
}
|
|
440
|
-
`,
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
2364
|
+
`,
|
|
2365
|
+
isInline: true,
|
|
2366
|
+
styles: [":host{display:contents}\n"],
|
|
2367
|
+
dependencies: [{
|
|
2368
|
+
kind: "component",
|
|
2369
|
+
type: FGDynamicComponent,
|
|
2370
|
+
selector: "fg-dynamic",
|
|
2371
|
+
inputs: [
|
|
2372
|
+
"configuration",
|
|
2373
|
+
"viewModel",
|
|
2374
|
+
"formGroup",
|
|
2375
|
+
"registry",
|
|
2376
|
+
"expressionPolicy",
|
|
2377
|
+
"formControlPolicy",
|
|
2378
|
+
"typePolicy",
|
|
2379
|
+
"attributePolicy",
|
|
2380
|
+
"depth"
|
|
2381
|
+
],
|
|
2382
|
+
outputs: ["viewModelChange"]
|
|
2383
|
+
}],
|
|
2384
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
2385
|
+
});
|
|
2386
|
+
}
|
|
2387
|
+
};
|
|
2388
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
2389
|
+
minVersion: "12.0.0",
|
|
2390
|
+
version: "22.2.3",
|
|
2391
|
+
ngImport: i0,
|
|
2392
|
+
type: FGDynamicComponent,
|
|
2393
|
+
decorators: [{
|
|
2394
|
+
type: Component,
|
|
2395
|
+
args: [{
|
|
2396
|
+
selector: "fg-dynamic",
|
|
2397
|
+
template: `
|
|
445
2398
|
<ng-container #viewContainer></ng-container>
|
|
446
|
-
@for (item of
|
|
447
|
-
<fg-dynamic #dynamicItem [configuration]="item" [(viewModel)]="viewModel" [formGroup]="formGroup()" />
|
|
2399
|
+
@for (item of items(); track $index) {
|
|
2400
|
+
<fg-dynamic #dynamicItem [configuration]="item" [(viewModel)]="viewModel" [formGroup]="formGroup()" [registry]="registry()" [expressionPolicy]="expressionPolicy()" [formControlPolicy]="formControlPolicy()" [typePolicy]="typePolicy()" [attributePolicy]="attributePolicy()" [depth]="depth() + 1" />
|
|
448
2401
|
}
|
|
449
|
-
`,
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
2402
|
+
`,
|
|
2403
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2404
|
+
standalone: true,
|
|
2405
|
+
styles: [":host{display:contents}\n"]
|
|
2406
|
+
}]
|
|
2407
|
+
}],
|
|
2408
|
+
propDecorators: {
|
|
2409
|
+
configuration: [{
|
|
2410
|
+
type: i0.Input,
|
|
2411
|
+
args: [{
|
|
2412
|
+
isSignal: true,
|
|
2413
|
+
alias: "configuration",
|
|
2414
|
+
required: true
|
|
2415
|
+
}]
|
|
2416
|
+
}],
|
|
2417
|
+
viewModel: [{
|
|
2418
|
+
type: i0.Input,
|
|
2419
|
+
args: [{
|
|
2420
|
+
isSignal: true,
|
|
2421
|
+
alias: "viewModel",
|
|
2422
|
+
required: false
|
|
2423
|
+
}]
|
|
2424
|
+
}, {
|
|
2425
|
+
type: i0.Output,
|
|
2426
|
+
args: ["viewModelChange"]
|
|
2427
|
+
}],
|
|
2428
|
+
formGroup: [{
|
|
2429
|
+
type: i0.Input,
|
|
2430
|
+
args: [{
|
|
2431
|
+
isSignal: true,
|
|
2432
|
+
alias: "formGroup",
|
|
2433
|
+
required: false
|
|
2434
|
+
}]
|
|
2435
|
+
}],
|
|
2436
|
+
registry: [{
|
|
2437
|
+
type: i0.Input,
|
|
2438
|
+
args: [{
|
|
2439
|
+
isSignal: true,
|
|
2440
|
+
alias: "registry",
|
|
2441
|
+
required: false
|
|
2442
|
+
}]
|
|
2443
|
+
}],
|
|
2444
|
+
expressionPolicy: [{
|
|
2445
|
+
type: i0.Input,
|
|
2446
|
+
args: [{
|
|
2447
|
+
isSignal: true,
|
|
2448
|
+
alias: "expressionPolicy",
|
|
2449
|
+
required: false
|
|
2450
|
+
}]
|
|
2451
|
+
}],
|
|
2452
|
+
formControlPolicy: [{
|
|
2453
|
+
type: i0.Input,
|
|
2454
|
+
args: [{
|
|
2455
|
+
isSignal: true,
|
|
2456
|
+
alias: "formControlPolicy",
|
|
2457
|
+
required: false
|
|
2458
|
+
}]
|
|
2459
|
+
}],
|
|
2460
|
+
typePolicy: [{
|
|
2461
|
+
type: i0.Input,
|
|
2462
|
+
args: [{
|
|
2463
|
+
isSignal: true,
|
|
2464
|
+
alias: "typePolicy",
|
|
2465
|
+
required: false
|
|
2466
|
+
}]
|
|
2467
|
+
}],
|
|
2468
|
+
attributePolicy: [{
|
|
2469
|
+
type: i0.Input,
|
|
2470
|
+
args: [{
|
|
2471
|
+
isSignal: true,
|
|
2472
|
+
alias: "attributePolicy",
|
|
2473
|
+
required: false
|
|
2474
|
+
}]
|
|
2475
|
+
}],
|
|
2476
|
+
depth: [{
|
|
2477
|
+
type: i0.Input,
|
|
2478
|
+
args: [{
|
|
2479
|
+
isSignal: true,
|
|
2480
|
+
alias: "depth",
|
|
2481
|
+
required: false
|
|
2482
|
+
}]
|
|
2483
|
+
}],
|
|
2484
|
+
_viewContainerRef: [{
|
|
2485
|
+
type: i0.ViewChild,
|
|
2486
|
+
args: ["viewContainer", {
|
|
2487
|
+
read: ViewContainerRef,
|
|
2488
|
+
isSignal: true
|
|
2489
|
+
}]
|
|
2490
|
+
}],
|
|
2491
|
+
_dynamicItems: [{
|
|
2492
|
+
type: i0.ViewChildren,
|
|
2493
|
+
args: ["dynamicItem", {
|
|
2494
|
+
read: ElementRef,
|
|
2495
|
+
isSignal: true
|
|
2496
|
+
}]
|
|
2497
|
+
}]
|
|
2498
|
+
}
|
|
2499
|
+
});
|
|
2500
|
+
export { FGDynamicComponent, FGDynamicRegistry, FGDynamicService };
|
|
463
2501
|
|
|
464
|
-
|
|
465
|
-
//# sourceMappingURL=fg-dynamic-component.mjs.map
|
|
2502
|
+
//# sourceMappingURL=fg-dynamic-component.mjs.map
|