@jay-framework/compiler-jay-html 0.15.5 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.cts +29 -9
- package/dist/index.js +1799 -1688
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -1,601 +1,10 @@
|
|
|
1
|
-
import { JayImportedType, isObjectType as isObjectType$1, isImportedType, isRecursiveType, JayUnknown, RenderFragment, Imports, Import, WithValidations, isArrayType as isArrayType$1, isAtomicType, isPromiseType, isEnumType, hasRefs, GenerateTarget, JayTypeAlias, JayUnionType, mkRefsTree, JayComponentType, JayHTMLType, mkRef, equalJayTypes, getModeFileExtension, RuntimeMode, nestRefs, mergeRefsTrees, SourceFileFormat, JayEnumType, JayObjectType, JayArrayType, JayPromiseType, resolvePrimitiveType, JayRecursiveType, JAY_CONTRACT_EXTENSION as JAY_CONTRACT_EXTENSION$1, ImportsFor, JAY_FULLSTACK_COMPONENTS,
|
|
1
|
+
import { JayImportedType, isObjectType as isObjectType$1, isImportedType, isRecursiveType, JayUnknown, RenderFragment, Imports, Import, WithValidations, isArrayType as isArrayType$1, isAtomicType, isPromiseType, isEnumType, hasRefs, GenerateTarget, JayTypeAlias, JayUnionType, mkRefsTree, JayComponentType, JayHTMLType, mkRef, equalJayTypes, getModeFileExtension, RuntimeMode, nestRefs, mergeRefsTrees, SourceFileFormat, JayEnumType, JayObjectType, JayArrayType, JayPromiseType, resolvePrimitiveType, JayRecursiveType, JAY_CONTRACT_EXTENSION as JAY_CONTRACT_EXTENSION$1, ImportsFor, JAY_FULLSTACK_COMPONENTS, JayErrorType, JayOptionalType, JayRecordType, isOptionalType, isRecordType, resolvePluginComponent, resolvePluginManifest } from "@jay-framework/compiler-shared";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { getLogger } from "@jay-framework/logger";
|
|
4
4
|
import fs from "fs/promises";
|
|
5
5
|
import { analyzeExportedTypes } from "@jay-framework/compiler-analyze-exported-types";
|
|
6
6
|
import fs$1 from "fs";
|
|
7
7
|
import { createRequire } from "module";
|
|
8
|
-
var ContractTagType = /* @__PURE__ */ ((ContractTagType2) => {
|
|
9
|
-
ContractTagType2[ContractTagType2["data"] = 0] = "data";
|
|
10
|
-
ContractTagType2[ContractTagType2["interactive"] = 1] = "interactive";
|
|
11
|
-
ContractTagType2[ContractTagType2["variant"] = 2] = "variant";
|
|
12
|
-
ContractTagType2[ContractTagType2["subContract"] = 3] = "subContract";
|
|
13
|
-
return ContractTagType2;
|
|
14
|
-
})(ContractTagType || {});
|
|
15
|
-
const PHASE_ORDER = {
|
|
16
|
-
slow: 0,
|
|
17
|
-
fast: 1,
|
|
18
|
-
"fast+interactive": 2
|
|
19
|
-
};
|
|
20
|
-
const DEFAULT_PHASE = "slow";
|
|
21
|
-
function getEffectivePhase(tag, parentPhase) {
|
|
22
|
-
if (tag.type.includes(ContractTagType.interactive)) {
|
|
23
|
-
return "fast+interactive";
|
|
24
|
-
}
|
|
25
|
-
if (tag.phase) {
|
|
26
|
-
return tag.phase;
|
|
27
|
-
}
|
|
28
|
-
if (parentPhase) {
|
|
29
|
-
return parentPhase;
|
|
30
|
-
}
|
|
31
|
-
return DEFAULT_PHASE;
|
|
32
|
-
}
|
|
33
|
-
function isPhaseCompatible(childPhase, parentPhase) {
|
|
34
|
-
return PHASE_ORDER[childPhase] >= PHASE_ORDER[parentPhase];
|
|
35
|
-
}
|
|
36
|
-
function isTagInPhase(tag, targetPhase, parentPhase) {
|
|
37
|
-
if (tag.type.includes(ContractTagType.interactive) && !tag.dataType) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
const effectivePhase = getEffectivePhase(tag, parentPhase);
|
|
41
|
-
return effectivePhase === targetPhase;
|
|
42
|
-
}
|
|
43
|
-
function validateTagPhases(tag, parentPhase, tagPath = "") {
|
|
44
|
-
const validations = [];
|
|
45
|
-
const currentPath = tagPath ? `${tagPath}.${tag.tag}` : tag.tag;
|
|
46
|
-
const effectivePhase = getEffectivePhase(tag, parentPhase);
|
|
47
|
-
if (parentPhase && !isPhaseCompatible(effectivePhase, parentPhase)) {
|
|
48
|
-
validations.push(
|
|
49
|
-
`Tag [${currentPath}] has phase [${effectivePhase}] which is earlier than parent phase [${parentPhase}]. Child phases must be same or later than parent (slow < fast < fast+interactive)`
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
if (tag.type.includes(ContractTagType.subContract) && tag.tags) {
|
|
53
|
-
if (tag.repeated) {
|
|
54
|
-
tag.tags.forEach((childTag) => {
|
|
55
|
-
const childValidations = validateTagPhases(childTag, effectivePhase, currentPath);
|
|
56
|
-
validations.push(...childValidations);
|
|
57
|
-
});
|
|
58
|
-
} else {
|
|
59
|
-
tag.tags.forEach((childTag) => {
|
|
60
|
-
const childValidations = validateTagPhases(childTag, void 0, currentPath);
|
|
61
|
-
validations.push(...childValidations);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return validations;
|
|
66
|
-
}
|
|
67
|
-
function validateContractPhases(contract) {
|
|
68
|
-
const validations = [];
|
|
69
|
-
contract.tags.forEach((tag) => {
|
|
70
|
-
const tagValidations = validateTagPhases(tag);
|
|
71
|
-
validations.push(...tagValidations);
|
|
72
|
-
});
|
|
73
|
-
return validations;
|
|
74
|
-
}
|
|
75
|
-
function filterTagsByPhase(tags, targetPhase, parentPhase) {
|
|
76
|
-
const filteredTags = [];
|
|
77
|
-
for (const tag of tags) {
|
|
78
|
-
if (!isTagInPhase(tag, targetPhase, parentPhase)) {
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
const effectivePhase = getEffectivePhase(tag, parentPhase);
|
|
82
|
-
if (tag.type.includes(ContractTagType.subContract) && tag.tags) {
|
|
83
|
-
const filteredNestedTags = filterTagsByPhase(tag.tags, targetPhase, effectivePhase);
|
|
84
|
-
if (filteredNestedTags.length > 0) {
|
|
85
|
-
filteredTags.push({
|
|
86
|
-
...tag,
|
|
87
|
-
tags: filteredNestedTags
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
} else {
|
|
91
|
-
filteredTags.push(tag);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return filteredTags;
|
|
95
|
-
}
|
|
96
|
-
function createPhaseContract(contract, targetPhase) {
|
|
97
|
-
return {
|
|
98
|
-
...contract,
|
|
99
|
-
tags: filterTagsByPhase(contract.tags, targetPhase)
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
const JAY_CONTRACT_EXTENSION = ".jay-contract";
|
|
103
|
-
function loadLinkedContract(linkPath, baseContractDir, importResolver) {
|
|
104
|
-
const linkWithExtension = linkPath.endsWith(JAY_CONTRACT_EXTENSION) ? linkPath : linkPath + JAY_CONTRACT_EXTENSION;
|
|
105
|
-
try {
|
|
106
|
-
const absolutePath = importResolver.resolveLink(baseContractDir, linkWithExtension);
|
|
107
|
-
const contractResult = importResolver.loadContract(absolutePath);
|
|
108
|
-
return contractResult.val ?? null;
|
|
109
|
-
} catch {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
function getLinkedContractDir(linkPath, baseContractDir, importResolver) {
|
|
114
|
-
const linkWithExtension = linkPath.endsWith(JAY_CONTRACT_EXTENSION) ? linkPath : linkPath + JAY_CONTRACT_EXTENSION;
|
|
115
|
-
try {
|
|
116
|
-
const absolutePath = importResolver.resolveLink(baseContractDir, linkWithExtension);
|
|
117
|
-
return path.dirname(absolutePath);
|
|
118
|
-
} catch {
|
|
119
|
-
return baseContractDir;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
var __assign$3 = function() {
|
|
123
|
-
__assign$3 = Object.assign || function __assign2(t) {
|
|
124
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
125
|
-
s = arguments[i];
|
|
126
|
-
for (var p in s)
|
|
127
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
128
|
-
t[p] = s[p];
|
|
129
|
-
}
|
|
130
|
-
return t;
|
|
131
|
-
};
|
|
132
|
-
return __assign$3.apply(this, arguments);
|
|
133
|
-
};
|
|
134
|
-
typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
135
|
-
var e2 = new Error(message);
|
|
136
|
-
return e2.name = "SuppressedError", e2.error = error, e2.suppressed = suppressed, e2;
|
|
137
|
-
};
|
|
138
|
-
function lowerCase(str2) {
|
|
139
|
-
return str2.toLowerCase();
|
|
140
|
-
}
|
|
141
|
-
var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
|
|
142
|
-
var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
|
|
143
|
-
function noCase(input, options) {
|
|
144
|
-
if (options === void 0) {
|
|
145
|
-
options = {};
|
|
146
|
-
}
|
|
147
|
-
var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
|
|
148
|
-
var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
|
|
149
|
-
var start = 0;
|
|
150
|
-
var end = result.length;
|
|
151
|
-
while (result.charAt(start) === "\0")
|
|
152
|
-
start++;
|
|
153
|
-
while (result.charAt(end - 1) === "\0")
|
|
154
|
-
end--;
|
|
155
|
-
return result.slice(start, end).split("\0").map(transform).join(delimiter);
|
|
156
|
-
}
|
|
157
|
-
function replace(input, re, value) {
|
|
158
|
-
if (re instanceof RegExp)
|
|
159
|
-
return input.replace(re, value);
|
|
160
|
-
return re.reduce(function(input2, re2) {
|
|
161
|
-
return input2.replace(re2, value);
|
|
162
|
-
}, input);
|
|
163
|
-
}
|
|
164
|
-
function pascalCaseTransform(input, index) {
|
|
165
|
-
var firstChar = input.charAt(0);
|
|
166
|
-
var lowerChars = input.substr(1).toLowerCase();
|
|
167
|
-
if (index > 0 && firstChar >= "0" && firstChar <= "9") {
|
|
168
|
-
return "_" + firstChar + lowerChars;
|
|
169
|
-
}
|
|
170
|
-
return "" + firstChar.toUpperCase() + lowerChars;
|
|
171
|
-
}
|
|
172
|
-
function pascalCase(input, options) {
|
|
173
|
-
if (options === void 0) {
|
|
174
|
-
options = {};
|
|
175
|
-
}
|
|
176
|
-
return noCase(input, __assign$3({ delimiter: "", transform: pascalCaseTransform }, options));
|
|
177
|
-
}
|
|
178
|
-
function camelCaseTransform(input, index) {
|
|
179
|
-
if (index === 0)
|
|
180
|
-
return input.toLowerCase();
|
|
181
|
-
return pascalCaseTransform(input, index);
|
|
182
|
-
}
|
|
183
|
-
function camelCase$1(input, options) {
|
|
184
|
-
if (options === void 0) {
|
|
185
|
-
options = {};
|
|
186
|
-
}
|
|
187
|
-
return pascalCase(input, __assign$3({ transform: camelCaseTransform }, options));
|
|
188
|
-
}
|
|
189
|
-
function upperCaseFirst(input) {
|
|
190
|
-
return input.charAt(0).toUpperCase() + input.substr(1);
|
|
191
|
-
}
|
|
192
|
-
function capitalCaseTransform(input) {
|
|
193
|
-
return upperCaseFirst(input.toLowerCase());
|
|
194
|
-
}
|
|
195
|
-
function capitalCase(input, options) {
|
|
196
|
-
if (options === void 0) {
|
|
197
|
-
options = {};
|
|
198
|
-
}
|
|
199
|
-
return noCase(input, __assign$3({ delimiter: " ", transform: capitalCaseTransform }, options));
|
|
200
|
-
}
|
|
201
|
-
function camelCase(str2) {
|
|
202
|
-
let leadingUnderscores = 0;
|
|
203
|
-
for (const char of str2) {
|
|
204
|
-
if (char === "_") {
|
|
205
|
-
leadingUnderscores++;
|
|
206
|
-
} else {
|
|
207
|
-
break;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
if (leadingUnderscores === 0) {
|
|
211
|
-
return camelCase$1(str2);
|
|
212
|
-
}
|
|
213
|
-
const withoutLeadingUnderscores = str2.slice(leadingUnderscores);
|
|
214
|
-
const camelCased = camelCase$1(withoutLeadingUnderscores);
|
|
215
|
-
return "_".repeat(leadingUnderscores) + camelCased;
|
|
216
|
-
}
|
|
217
|
-
function shouldIncludeInPhase(propertyPhase, targetPhase) {
|
|
218
|
-
if (targetPhase === "slow") {
|
|
219
|
-
return propertyPhase === "slow";
|
|
220
|
-
} else if (targetPhase === "fast") {
|
|
221
|
-
return propertyPhase === "fast" || propertyPhase === "fast+interactive";
|
|
222
|
-
} else if (targetPhase === "fast+interactive") {
|
|
223
|
-
return propertyPhase === "fast+interactive";
|
|
224
|
-
}
|
|
225
|
-
return false;
|
|
226
|
-
}
|
|
227
|
-
function extractPropertyPathsAndArrays(tags, targetPhase, parentPath = [], parentPhase, parentTrackBy, linkedContext) {
|
|
228
|
-
const paths = [];
|
|
229
|
-
const arrays = [];
|
|
230
|
-
const asyncProps = [];
|
|
231
|
-
for (const tag of tags) {
|
|
232
|
-
if (tag.type.includes(ContractTagType.interactive) && !tag.dataType) {
|
|
233
|
-
continue;
|
|
234
|
-
}
|
|
235
|
-
const effectivePhase = getEffectivePhase(tag, parentPhase);
|
|
236
|
-
const propertyName = camelCase(tag.tag);
|
|
237
|
-
const currentPath = [...parentPath, propertyName];
|
|
238
|
-
const isArray = tag.repeated || false;
|
|
239
|
-
const isAsync = tag.async || false;
|
|
240
|
-
if (tag.type.includes(ContractTagType.subContract)) {
|
|
241
|
-
const isRecursiveLink2 = tag.link?.startsWith("$/");
|
|
242
|
-
if (isRecursiveLink2) {
|
|
243
|
-
if (shouldIncludeInPhase(effectivePhase, targetPhase)) {
|
|
244
|
-
paths.push({
|
|
245
|
-
path: parentPath,
|
|
246
|
-
propertyName
|
|
247
|
-
});
|
|
248
|
-
if (isArray) {
|
|
249
|
-
arrays.push({ path: currentPath.join(".") });
|
|
250
|
-
}
|
|
251
|
-
if (isAsync) {
|
|
252
|
-
asyncProps.push({ path: currentPath.join(".") });
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
} else {
|
|
256
|
-
let childTags = [];
|
|
257
|
-
let childLinkedContext = linkedContext;
|
|
258
|
-
if (tag.tags) {
|
|
259
|
-
childTags = tag.tags;
|
|
260
|
-
} else if (tag.link && linkedContext) {
|
|
261
|
-
const linkedContract = loadLinkedContract(
|
|
262
|
-
tag.link,
|
|
263
|
-
linkedContext.contractDir,
|
|
264
|
-
linkedContext.importResolver
|
|
265
|
-
);
|
|
266
|
-
if (linkedContract) {
|
|
267
|
-
childTags = linkedContract.tags;
|
|
268
|
-
childLinkedContext = {
|
|
269
|
-
importResolver: linkedContext.importResolver,
|
|
270
|
-
contractDir: getLinkedContractDir(
|
|
271
|
-
tag.link,
|
|
272
|
-
linkedContext.contractDir,
|
|
273
|
-
linkedContext.importResolver
|
|
274
|
-
)
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
if (childTags.length > 0) {
|
|
279
|
-
const trackByForChildren = isArray ? tag.trackBy : void 0;
|
|
280
|
-
const result = extractPropertyPathsAndArrays(
|
|
281
|
-
childTags,
|
|
282
|
-
targetPhase,
|
|
283
|
-
currentPath,
|
|
284
|
-
effectivePhase,
|
|
285
|
-
trackByForChildren,
|
|
286
|
-
childLinkedContext
|
|
287
|
-
);
|
|
288
|
-
const hasOnlyTrackBy = isArray && trackByForChildren && result.paths.length === 1 && result.paths[0].propertyName === camelCase(trackByForChildren);
|
|
289
|
-
if (result.paths.length > 0 && !hasOnlyTrackBy) {
|
|
290
|
-
paths.push(...result.paths);
|
|
291
|
-
arrays.push(...result.arrays);
|
|
292
|
-
asyncProps.push(...result.asyncProps);
|
|
293
|
-
if (isArray) {
|
|
294
|
-
arrays.push({ path: currentPath.join(".") });
|
|
295
|
-
}
|
|
296
|
-
if (isAsync) {
|
|
297
|
-
asyncProps.push({ path: currentPath.join(".") });
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
} else {
|
|
303
|
-
const isTrackByField = parentTrackBy === tag.tag;
|
|
304
|
-
if (shouldIncludeInPhase(effectivePhase, targetPhase) || isTrackByField) {
|
|
305
|
-
paths.push({
|
|
306
|
-
path: parentPath,
|
|
307
|
-
propertyName
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
return { paths, arrays, asyncProps };
|
|
313
|
-
}
|
|
314
|
-
function groupPathsByParent(paths) {
|
|
315
|
-
const grouped = /* @__PURE__ */ new Map();
|
|
316
|
-
for (const { path: path2, propertyName } of paths) {
|
|
317
|
-
const parentKey = path2.join(".");
|
|
318
|
-
if (!grouped.has(parentKey)) {
|
|
319
|
-
grouped.set(parentKey, []);
|
|
320
|
-
}
|
|
321
|
-
grouped.get(parentKey).push(propertyName);
|
|
322
|
-
}
|
|
323
|
-
return grouped;
|
|
324
|
-
}
|
|
325
|
-
function countTotalProperties(tags, targetPath, currentPath = [], linkedContext) {
|
|
326
|
-
let count = 0;
|
|
327
|
-
for (const tag of tags) {
|
|
328
|
-
if (tag.type.includes(ContractTagType.interactive) && !tag.dataType) {
|
|
329
|
-
continue;
|
|
330
|
-
}
|
|
331
|
-
const propertyName = camelCase(tag.tag);
|
|
332
|
-
const newPath = [...currentPath, propertyName];
|
|
333
|
-
const pathKey = newPath.join(".");
|
|
334
|
-
const targetKey = targetPath.join(".");
|
|
335
|
-
if (pathKey === targetKey && tag.type.includes(ContractTagType.subContract)) {
|
|
336
|
-
let childTags = [];
|
|
337
|
-
if (tag.tags) {
|
|
338
|
-
childTags = tag.tags;
|
|
339
|
-
} else if (tag.link && linkedContext && !tag.link.startsWith("$/")) {
|
|
340
|
-
const linkedContract = loadLinkedContract(
|
|
341
|
-
tag.link,
|
|
342
|
-
linkedContext.contractDir,
|
|
343
|
-
linkedContext.importResolver
|
|
344
|
-
);
|
|
345
|
-
if (linkedContract) {
|
|
346
|
-
childTags = linkedContract.tags;
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
for (const childTag of childTags) {
|
|
350
|
-
if (childTag.type.includes(ContractTagType.interactive) && !childTag.dataType) {
|
|
351
|
-
continue;
|
|
352
|
-
}
|
|
353
|
-
count++;
|
|
354
|
-
}
|
|
355
|
-
return count;
|
|
356
|
-
}
|
|
357
|
-
if (tag.type.includes(ContractTagType.subContract)) {
|
|
358
|
-
let childTags = [];
|
|
359
|
-
let childLinkedContext = linkedContext;
|
|
360
|
-
if (tag.tags) {
|
|
361
|
-
childTags = tag.tags;
|
|
362
|
-
} else if (tag.link && linkedContext && !tag.link.startsWith("$/")) {
|
|
363
|
-
const linkedContract = loadLinkedContract(
|
|
364
|
-
tag.link,
|
|
365
|
-
linkedContext.contractDir,
|
|
366
|
-
linkedContext.importResolver
|
|
367
|
-
);
|
|
368
|
-
if (linkedContract) {
|
|
369
|
-
childTags = linkedContract.tags;
|
|
370
|
-
childLinkedContext = {
|
|
371
|
-
importResolver: linkedContext.importResolver,
|
|
372
|
-
contractDir: getLinkedContractDir(
|
|
373
|
-
tag.link,
|
|
374
|
-
linkedContext.contractDir,
|
|
375
|
-
linkedContext.importResolver
|
|
376
|
-
)
|
|
377
|
-
};
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
if (childTags.length > 0) {
|
|
381
|
-
const result = countTotalProperties(
|
|
382
|
-
childTags,
|
|
383
|
-
targetPath,
|
|
384
|
-
newPath,
|
|
385
|
-
childLinkedContext
|
|
386
|
-
);
|
|
387
|
-
if (result > 0) {
|
|
388
|
-
return result;
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
return count;
|
|
394
|
-
}
|
|
395
|
-
function buildPathAccess(baseTypeName, path2, arrays, asyncProps, skipFinalArrayAccess = false) {
|
|
396
|
-
if (path2.length === 0) {
|
|
397
|
-
return baseTypeName;
|
|
398
|
-
}
|
|
399
|
-
let result = baseTypeName;
|
|
400
|
-
for (let i = 0; i < path2.length; i++) {
|
|
401
|
-
const segment = path2[i];
|
|
402
|
-
result += `['${segment}']`;
|
|
403
|
-
const pathUpToHere = path2.slice(0, i + 1).join(".");
|
|
404
|
-
const isArray = arrays.has(pathUpToHere);
|
|
405
|
-
const isAsync = asyncProps?.has(pathUpToHere);
|
|
406
|
-
const isFinalSegment = i === path2.length - 1;
|
|
407
|
-
const shouldSkip = isFinalSegment && (skipFinalArrayAccess || isArray && isAsync);
|
|
408
|
-
if (isArray && !shouldSkip) {
|
|
409
|
-
result += "[number]";
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
return result;
|
|
413
|
-
}
|
|
414
|
-
function isFullyIncluded(pathGroups, contractTags, currentPath, linkedContext) {
|
|
415
|
-
const currentKey = currentPath.join(".");
|
|
416
|
-
const properties = pathGroups.get(currentKey) || [];
|
|
417
|
-
const totalProps = countTotalProperties(contractTags, currentPath, [], linkedContext);
|
|
418
|
-
if (totalProps === 0) {
|
|
419
|
-
return false;
|
|
420
|
-
}
|
|
421
|
-
const childPropertyNames = /* @__PURE__ */ new Set();
|
|
422
|
-
const prefix = currentKey ? currentKey + "." : "";
|
|
423
|
-
for (const key of pathGroups.keys()) {
|
|
424
|
-
if (key.startsWith(prefix) && key !== currentKey) {
|
|
425
|
-
const remainingPath = key.slice(prefix.length);
|
|
426
|
-
const firstSegment = remainingPath.split(".")[0];
|
|
427
|
-
if (firstSegment) {
|
|
428
|
-
childPropertyNames.add(firstSegment);
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
const directProps = properties.filter((p) => !childPropertyNames.has(p));
|
|
433
|
-
if (directProps.length + childPropertyNames.size !== totalProps) {
|
|
434
|
-
return false;
|
|
435
|
-
}
|
|
436
|
-
for (const childName of childPropertyNames) {
|
|
437
|
-
const childPath = [...currentPath, childName];
|
|
438
|
-
if (!isFullyIncluded(pathGroups, contractTags, childPath, linkedContext)) {
|
|
439
|
-
return false;
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
return true;
|
|
443
|
-
}
|
|
444
|
-
function buildPickExpression(baseTypeName, pathGroups, arrays, asyncProps, contractTags, currentPath = [], linkedContext) {
|
|
445
|
-
const currentKey = currentPath.join(".");
|
|
446
|
-
const properties = pathGroups.get(currentKey) || [];
|
|
447
|
-
const childPropertyNames = /* @__PURE__ */ new Set();
|
|
448
|
-
for (const key of pathGroups.keys()) {
|
|
449
|
-
const prefix = currentKey ? currentKey + "." : "";
|
|
450
|
-
if (key.startsWith(prefix) && key !== currentKey) {
|
|
451
|
-
const remainingPath = key.slice(prefix.length);
|
|
452
|
-
const firstSegment = remainingPath.split(".")[0];
|
|
453
|
-
if (firstSegment) {
|
|
454
|
-
childPropertyNames.add(firstSegment);
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
const pickPart = [];
|
|
459
|
-
const nestedProperties = [];
|
|
460
|
-
const directProps = properties.filter((p) => !childPropertyNames.has(p));
|
|
461
|
-
if (directProps.length > 0) {
|
|
462
|
-
const pathAccess = buildPathAccess(baseTypeName, currentPath, arrays, asyncProps);
|
|
463
|
-
pickPart.push(`Pick<${pathAccess}, ${directProps.map((p) => `'${p}'`).join(" | ")}>`);
|
|
464
|
-
}
|
|
465
|
-
for (const childName of childPropertyNames) {
|
|
466
|
-
const childPath = [...currentPath, childName];
|
|
467
|
-
const childPathKey = childPath.join(".");
|
|
468
|
-
const isArray = arrays.has(childPathKey);
|
|
469
|
-
const isAsync = asyncProps.has(childPathKey);
|
|
470
|
-
const isChildFullyIncluded = isFullyIncluded(
|
|
471
|
-
pathGroups,
|
|
472
|
-
contractTags,
|
|
473
|
-
childPath,
|
|
474
|
-
linkedContext
|
|
475
|
-
);
|
|
476
|
-
const originalPathAccess = buildPathAccess(baseTypeName, childPath, arrays, asyncProps);
|
|
477
|
-
if (isChildFullyIncluded) {
|
|
478
|
-
let fullExpression;
|
|
479
|
-
const directTypeRef = originalPathAccess;
|
|
480
|
-
if (isAsync) {
|
|
481
|
-
if (isArray) {
|
|
482
|
-
fullExpression = `Promise<Array<Awaited<${directTypeRef}>[number]>>`;
|
|
483
|
-
} else {
|
|
484
|
-
fullExpression = directTypeRef;
|
|
485
|
-
}
|
|
486
|
-
} else if (isArray) {
|
|
487
|
-
fullExpression = `Array<${directTypeRef}>`;
|
|
488
|
-
} else {
|
|
489
|
-
fullExpression = directTypeRef;
|
|
490
|
-
}
|
|
491
|
-
nestedProperties.push(` ${childName}: ${fullExpression};`);
|
|
492
|
-
} else {
|
|
493
|
-
const childExpression = buildPickExpression(
|
|
494
|
-
baseTypeName,
|
|
495
|
-
pathGroups,
|
|
496
|
-
arrays,
|
|
497
|
-
asyncProps,
|
|
498
|
-
contractTags,
|
|
499
|
-
childPath,
|
|
500
|
-
linkedContext
|
|
501
|
-
);
|
|
502
|
-
if (childExpression) {
|
|
503
|
-
let fullExpression;
|
|
504
|
-
if (isAsync) {
|
|
505
|
-
if (isArray) {
|
|
506
|
-
const unwrappedArrayAccess = `Awaited<${originalPathAccess}>[number]`;
|
|
507
|
-
const unwrappedExpression = childExpression.replace(
|
|
508
|
-
originalPathAccess,
|
|
509
|
-
unwrappedArrayAccess
|
|
510
|
-
);
|
|
511
|
-
fullExpression = `Promise<Array<${unwrappedExpression}>>`;
|
|
512
|
-
} else {
|
|
513
|
-
const unwrappedAccess = `Awaited<${originalPathAccess}>`;
|
|
514
|
-
const unwrappedExpression = childExpression.replace(
|
|
515
|
-
originalPathAccess,
|
|
516
|
-
unwrappedAccess
|
|
517
|
-
);
|
|
518
|
-
fullExpression = `Promise<${unwrappedExpression}>`;
|
|
519
|
-
}
|
|
520
|
-
} else if (isArray) {
|
|
521
|
-
fullExpression = `Array<${childExpression}>`;
|
|
522
|
-
} else {
|
|
523
|
-
fullExpression = childExpression;
|
|
524
|
-
}
|
|
525
|
-
nestedProperties.push(` ${childName}: ${fullExpression};`);
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
if (pickPart.length === 0 && nestedProperties.length === 0) {
|
|
530
|
-
return "{}";
|
|
531
|
-
} else if (pickPart.length === 0) {
|
|
532
|
-
return `{
|
|
533
|
-
${nestedProperties.join("\n")}
|
|
534
|
-
}`;
|
|
535
|
-
} else if (nestedProperties.length === 0) {
|
|
536
|
-
return pickPart[0];
|
|
537
|
-
} else {
|
|
538
|
-
return `${pickPart[0]} & {
|
|
539
|
-
${nestedProperties.join("\n")}
|
|
540
|
-
}`;
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
function generatePhaseViewStateType(contract, phase, baseTypeName, importResolver, contractPath) {
|
|
544
|
-
const phaseName = phase === "fast+interactive" ? "Interactive" : pascalCase(phase);
|
|
545
|
-
const typeName = `${pascalCase(contract.name)}${phaseName}ViewState`;
|
|
546
|
-
const linkedContext = importResolver && contractPath ? {
|
|
547
|
-
importResolver,
|
|
548
|
-
contractDir: contractPath.includes("/") ? contractPath.substring(0, contractPath.lastIndexOf("/")) : "."
|
|
549
|
-
} : void 0;
|
|
550
|
-
const { paths, arrays, asyncProps } = extractPropertyPathsAndArrays(
|
|
551
|
-
contract.tags,
|
|
552
|
-
phase,
|
|
553
|
-
[],
|
|
554
|
-
void 0,
|
|
555
|
-
void 0,
|
|
556
|
-
linkedContext
|
|
557
|
-
);
|
|
558
|
-
if (paths.length === 0) {
|
|
559
|
-
return `export type ${typeName} = {};`;
|
|
560
|
-
}
|
|
561
|
-
const pathGroups = groupPathsByParent(paths);
|
|
562
|
-
const arraySet = new Set(arrays.map((a) => a.path));
|
|
563
|
-
const asyncSet = new Set(asyncProps.map((a) => a.path));
|
|
564
|
-
const pickExpression = buildPickExpression(
|
|
565
|
-
baseTypeName,
|
|
566
|
-
pathGroups,
|
|
567
|
-
arraySet,
|
|
568
|
-
asyncSet,
|
|
569
|
-
contract.tags,
|
|
570
|
-
[],
|
|
571
|
-
linkedContext
|
|
572
|
-
);
|
|
573
|
-
return `export type ${typeName} = ${pickExpression};`;
|
|
574
|
-
}
|
|
575
|
-
function generateAllPhaseViewStateTypes(contract, baseTypeName, importResolver, contractPath) {
|
|
576
|
-
const slowType = generatePhaseViewStateType(
|
|
577
|
-
contract,
|
|
578
|
-
"slow",
|
|
579
|
-
baseTypeName,
|
|
580
|
-
importResolver,
|
|
581
|
-
contractPath
|
|
582
|
-
);
|
|
583
|
-
const fastType = generatePhaseViewStateType(
|
|
584
|
-
contract,
|
|
585
|
-
"fast",
|
|
586
|
-
baseTypeName,
|
|
587
|
-
importResolver,
|
|
588
|
-
contractPath
|
|
589
|
-
);
|
|
590
|
-
const interactiveType = generatePhaseViewStateType(
|
|
591
|
-
contract,
|
|
592
|
-
"fast+interactive",
|
|
593
|
-
baseTypeName,
|
|
594
|
-
importResolver,
|
|
595
|
-
contractPath
|
|
596
|
-
);
|
|
597
|
-
return [slowType, fastType, interactiveType].join("\n\n");
|
|
598
|
-
}
|
|
599
8
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
600
9
|
function getDefaultExportFromCjs(x) {
|
|
601
10
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
@@ -1052,8 +461,8 @@ var __extends$2 = commonjsGlobal && commonjsGlobal.__extends || function() {
|
|
|
1052
461
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1053
462
|
};
|
|
1054
463
|
}();
|
|
1055
|
-
var __assign$
|
|
1056
|
-
__assign$
|
|
464
|
+
var __assign$3 = commonjsGlobal && commonjsGlobal.__assign || function() {
|
|
465
|
+
__assign$3 = Object.assign || function(t) {
|
|
1057
466
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1058
467
|
s = arguments[i];
|
|
1059
468
|
for (var p in s)
|
|
@@ -1062,7 +471,7 @@ var __assign$2 = commonjsGlobal && commonjsGlobal.__assign || function() {
|
|
|
1062
471
|
}
|
|
1063
472
|
return t;
|
|
1064
473
|
};
|
|
1065
|
-
return __assign$
|
|
474
|
+
return __assign$3.apply(this, arguments);
|
|
1066
475
|
};
|
|
1067
476
|
Object.defineProperty(node, "__esModule", { value: true });
|
|
1068
477
|
node.cloneNode = node.hasChildren = node.isDocument = node.isDirective = node.isComment = node.isText = node.isCDATA = node.isTag = node.Element = node.Document = node.CDATA = node.NodeWithChildren = node.ProcessingInstruction = node.Comment = node.Text = node.DataNode = node.Node = void 0;
|
|
@@ -1401,7 +810,7 @@ function cloneNode(node2, recursive) {
|
|
|
1401
810
|
result = new Comment(node2.data);
|
|
1402
811
|
} else if (isTag$1(node2)) {
|
|
1403
812
|
var children = recursive ? cloneChildren(node2.children) : [];
|
|
1404
|
-
var clone_1 = new Element(node2.name, __assign$
|
|
813
|
+
var clone_1 = new Element(node2.name, __assign$3({}, node2.attribs), children);
|
|
1405
814
|
children.forEach(function(child) {
|
|
1406
815
|
return child.parent = clone_1;
|
|
1407
816
|
});
|
|
@@ -1409,10 +818,10 @@ function cloneNode(node2, recursive) {
|
|
|
1409
818
|
clone_1.namespace = node2.namespace;
|
|
1410
819
|
}
|
|
1411
820
|
if (node2["x-attribsNamespace"]) {
|
|
1412
|
-
clone_1["x-attribsNamespace"] = __assign$
|
|
821
|
+
clone_1["x-attribsNamespace"] = __assign$3({}, node2["x-attribsNamespace"]);
|
|
1413
822
|
}
|
|
1414
823
|
if (node2["x-attribsPrefix"]) {
|
|
1415
|
-
clone_1["x-attribsPrefix"] = __assign$
|
|
824
|
+
clone_1["x-attribsPrefix"] = __assign$3({}, node2["x-attribsPrefix"]);
|
|
1416
825
|
}
|
|
1417
826
|
result = clone_1;
|
|
1418
827
|
} else if (isCDATA(node2)) {
|
|
@@ -2415,8 +1824,8 @@ foreignNames.attributeNames = new Map([
|
|
|
2415
1824
|
].map(function(val) {
|
|
2416
1825
|
return [val.toLowerCase(), val];
|
|
2417
1826
|
}));
|
|
2418
|
-
var __assign$
|
|
2419
|
-
__assign$
|
|
1827
|
+
var __assign$2 = commonjsGlobal && commonjsGlobal.__assign || function() {
|
|
1828
|
+
__assign$2 = Object.assign || function(t) {
|
|
2420
1829
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
2421
1830
|
s = arguments[i];
|
|
2422
1831
|
for (var p in s)
|
|
@@ -2425,7 +1834,7 @@ var __assign$1 = commonjsGlobal && commonjsGlobal.__assign || function() {
|
|
|
2425
1834
|
}
|
|
2426
1835
|
return t;
|
|
2427
1836
|
};
|
|
2428
|
-
return __assign$
|
|
1837
|
+
return __assign$2.apply(this, arguments);
|
|
2429
1838
|
};
|
|
2430
1839
|
var __createBinding$1 = commonjsGlobal && commonjsGlobal.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
2431
1840
|
if (k2 === void 0)
|
|
@@ -2564,11 +1973,11 @@ function renderTag(elem, opts) {
|
|
|
2564
1973
|
if (opts.xmlMode === "foreign") {
|
|
2565
1974
|
elem.name = (_a = foreignNames_js_1.elementNames.get(elem.name)) !== null && _a !== void 0 ? _a : elem.name;
|
|
2566
1975
|
if (elem.parent && foreignModeIntegrationPoints.has(elem.parent.name)) {
|
|
2567
|
-
opts = __assign$
|
|
1976
|
+
opts = __assign$2(__assign$2({}, opts), { xmlMode: false });
|
|
2568
1977
|
}
|
|
2569
1978
|
}
|
|
2570
1979
|
if (!opts.xmlMode && foreignElements.has(elem.name)) {
|
|
2571
|
-
opts = __assign$
|
|
1980
|
+
opts = __assign$2(__assign$2({}, opts), { xmlMode: "foreign" });
|
|
2572
1981
|
}
|
|
2573
1982
|
var tag = "<".concat(elem.name);
|
|
2574
1983
|
var attribs = formatAttributes(elem.attribs, opts);
|
|
@@ -5301,8 +4710,8 @@ var __extends = commonjsGlobal && commonjsGlobal.__extends || function() {
|
|
|
5301
4710
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
5302
4711
|
};
|
|
5303
4712
|
}();
|
|
5304
|
-
var __assign = commonjsGlobal && commonjsGlobal.__assign || function() {
|
|
5305
|
-
__assign = Object.assign || function(t) {
|
|
4713
|
+
var __assign$1 = commonjsGlobal && commonjsGlobal.__assign || function() {
|
|
4714
|
+
__assign$1 = Object.assign || function(t) {
|
|
5306
4715
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5307
4716
|
s = arguments[i];
|
|
5308
4717
|
for (var p in s)
|
|
@@ -5311,7 +4720,7 @@ var __assign = commonjsGlobal && commonjsGlobal.__assign || function() {
|
|
|
5311
4720
|
}
|
|
5312
4721
|
return t;
|
|
5313
4722
|
};
|
|
5314
|
-
return __assign.apply(this, arguments);
|
|
4723
|
+
return __assign$1.apply(this, arguments);
|
|
5315
4724
|
};
|
|
5316
4725
|
var __spreadArray = commonjsGlobal && commonjsGlobal.__spreadArray || function(to, from, pack) {
|
|
5317
4726
|
if (pack || arguments.length === 2)
|
|
@@ -5505,909 +4914,1658 @@ var HTMLElement = (
|
|
|
5505
4914
|
});
|
|
5506
4915
|
return this;
|
|
5507
4916
|
};
|
|
5508
|
-
Object.defineProperty(HTMLElement2.prototype, "tagName", {
|
|
5509
|
-
get: function() {
|
|
5510
|
-
return this.rawTagName ? this.rawTagName.toUpperCase() : this.rawTagName;
|
|
5511
|
-
},
|
|
5512
|
-
set: function(newname) {
|
|
5513
|
-
this.rawTagName = newname.toLowerCase();
|
|
5514
|
-
},
|
|
5515
|
-
enumerable: false,
|
|
5516
|
-
configurable: true
|
|
5517
|
-
});
|
|
5518
|
-
Object.defineProperty(HTMLElement2.prototype, "localName", {
|
|
5519
|
-
get: function() {
|
|
5520
|
-
return this.rawTagName.toLowerCase();
|
|
5521
|
-
},
|
|
5522
|
-
enumerable: false,
|
|
5523
|
-
configurable: true
|
|
5524
|
-
});
|
|
5525
|
-
Object.defineProperty(HTMLElement2.prototype, "isVoidElement", {
|
|
4917
|
+
Object.defineProperty(HTMLElement2.prototype, "tagName", {
|
|
4918
|
+
get: function() {
|
|
4919
|
+
return this.rawTagName ? this.rawTagName.toUpperCase() : this.rawTagName;
|
|
4920
|
+
},
|
|
4921
|
+
set: function(newname) {
|
|
4922
|
+
this.rawTagName = newname.toLowerCase();
|
|
4923
|
+
},
|
|
4924
|
+
enumerable: false,
|
|
4925
|
+
configurable: true
|
|
4926
|
+
});
|
|
4927
|
+
Object.defineProperty(HTMLElement2.prototype, "localName", {
|
|
4928
|
+
get: function() {
|
|
4929
|
+
return this.rawTagName.toLowerCase();
|
|
4930
|
+
},
|
|
4931
|
+
enumerable: false,
|
|
4932
|
+
configurable: true
|
|
4933
|
+
});
|
|
4934
|
+
Object.defineProperty(HTMLElement2.prototype, "isVoidElement", {
|
|
4935
|
+
get: function() {
|
|
4936
|
+
return this.voidTag.isVoidElement(this.localName);
|
|
4937
|
+
},
|
|
4938
|
+
enumerable: false,
|
|
4939
|
+
configurable: true
|
|
4940
|
+
});
|
|
4941
|
+
Object.defineProperty(HTMLElement2.prototype, "rawText", {
|
|
4942
|
+
/**
|
|
4943
|
+
* Get escpaed (as-it) text value of current node and its children.
|
|
4944
|
+
* @return {string} text content
|
|
4945
|
+
*/
|
|
4946
|
+
get: function() {
|
|
4947
|
+
if (/^br$/i.test(this.rawTagName)) {
|
|
4948
|
+
return "\n";
|
|
4949
|
+
}
|
|
4950
|
+
return this.childNodes.reduce(function(pre, cur) {
|
|
4951
|
+
return pre += cur.rawText;
|
|
4952
|
+
}, "");
|
|
4953
|
+
},
|
|
4954
|
+
enumerable: false,
|
|
4955
|
+
configurable: true
|
|
4956
|
+
});
|
|
4957
|
+
Object.defineProperty(HTMLElement2.prototype, "textContent", {
|
|
4958
|
+
get: function() {
|
|
4959
|
+
return decode(this.rawText);
|
|
4960
|
+
},
|
|
4961
|
+
set: function(val) {
|
|
4962
|
+
var content = [new text_1$1.default(val, this)];
|
|
4963
|
+
this.childNodes = content;
|
|
4964
|
+
},
|
|
4965
|
+
enumerable: false,
|
|
4966
|
+
configurable: true
|
|
4967
|
+
});
|
|
4968
|
+
Object.defineProperty(HTMLElement2.prototype, "text", {
|
|
4969
|
+
/**
|
|
4970
|
+
* Get unescaped text value of current node and its children.
|
|
4971
|
+
* @return {string} text content
|
|
4972
|
+
*/
|
|
4973
|
+
get: function() {
|
|
4974
|
+
return decode(this.rawText);
|
|
4975
|
+
},
|
|
4976
|
+
enumerable: false,
|
|
4977
|
+
configurable: true
|
|
4978
|
+
});
|
|
4979
|
+
Object.defineProperty(HTMLElement2.prototype, "structuredText", {
|
|
4980
|
+
/**
|
|
4981
|
+
* Get structured Text (with '\n' etc.)
|
|
4982
|
+
* @return {string} structured text
|
|
4983
|
+
*/
|
|
4984
|
+
get: function() {
|
|
4985
|
+
var currentBlock = [];
|
|
4986
|
+
var blocks = [currentBlock];
|
|
4987
|
+
function dfs(node2) {
|
|
4988
|
+
if (node2.nodeType === type_1$1.default.ELEMENT_NODE) {
|
|
4989
|
+
if (kBlockElements.has(node2.rawTagName)) {
|
|
4990
|
+
if (currentBlock.length > 0) {
|
|
4991
|
+
blocks.push(currentBlock = []);
|
|
4992
|
+
}
|
|
4993
|
+
node2.childNodes.forEach(dfs);
|
|
4994
|
+
if (currentBlock.length > 0) {
|
|
4995
|
+
blocks.push(currentBlock = []);
|
|
4996
|
+
}
|
|
4997
|
+
} else {
|
|
4998
|
+
node2.childNodes.forEach(dfs);
|
|
4999
|
+
}
|
|
5000
|
+
} else if (node2.nodeType === type_1$1.default.TEXT_NODE) {
|
|
5001
|
+
if (node2.isWhitespace) {
|
|
5002
|
+
currentBlock.prependWhitespace = true;
|
|
5003
|
+
} else {
|
|
5004
|
+
var text2 = node2.trimmedText;
|
|
5005
|
+
if (currentBlock.prependWhitespace) {
|
|
5006
|
+
text2 = " ".concat(text2);
|
|
5007
|
+
currentBlock.prependWhitespace = false;
|
|
5008
|
+
}
|
|
5009
|
+
currentBlock.push(text2);
|
|
5010
|
+
}
|
|
5011
|
+
}
|
|
5012
|
+
}
|
|
5013
|
+
dfs(this);
|
|
5014
|
+
return blocks.map(function(block) {
|
|
5015
|
+
return block.join("").replace(/\s{2,}/g, " ");
|
|
5016
|
+
}).join("\n").replace(/\s+$/, "");
|
|
5017
|
+
},
|
|
5018
|
+
enumerable: false,
|
|
5019
|
+
configurable: true
|
|
5020
|
+
});
|
|
5021
|
+
HTMLElement2.prototype.toString = function() {
|
|
5022
|
+
var tag = this.rawTagName;
|
|
5023
|
+
if (tag) {
|
|
5024
|
+
var attrs = this.rawAttrs ? " ".concat(this.rawAttrs) : "";
|
|
5025
|
+
return this.voidTag.formatNode(tag, attrs, this.innerHTML);
|
|
5026
|
+
}
|
|
5027
|
+
return this.innerHTML;
|
|
5028
|
+
};
|
|
5029
|
+
Object.defineProperty(HTMLElement2.prototype, "innerHTML", {
|
|
5030
|
+
get: function() {
|
|
5031
|
+
return this.childNodes.map(function(child) {
|
|
5032
|
+
return child.toString();
|
|
5033
|
+
}).join("");
|
|
5034
|
+
},
|
|
5035
|
+
set: function(content) {
|
|
5036
|
+
var r = parse$4(content, this._parseOptions);
|
|
5037
|
+
var nodes = r.childNodes.length ? r.childNodes : [new text_1$1.default(content, this)];
|
|
5038
|
+
resetParent(nodes, this);
|
|
5039
|
+
resetParent(this.childNodes, null);
|
|
5040
|
+
this.childNodes = nodes;
|
|
5041
|
+
},
|
|
5042
|
+
enumerable: false,
|
|
5043
|
+
configurable: true
|
|
5044
|
+
});
|
|
5045
|
+
HTMLElement2.prototype.set_content = function(content, options) {
|
|
5046
|
+
if (options === void 0) {
|
|
5047
|
+
options = {};
|
|
5048
|
+
}
|
|
5049
|
+
if (content instanceof node_1$1.default) {
|
|
5050
|
+
content = [content];
|
|
5051
|
+
} else if (typeof content == "string") {
|
|
5052
|
+
options = __assign$1(__assign$1({}, this._parseOptions), options);
|
|
5053
|
+
var r = parse$4(content, options);
|
|
5054
|
+
content = r.childNodes.length ? r.childNodes : [new text_1$1.default(r.innerHTML, this)];
|
|
5055
|
+
}
|
|
5056
|
+
resetParent(this.childNodes, null);
|
|
5057
|
+
resetParent(content, this);
|
|
5058
|
+
this.childNodes = content;
|
|
5059
|
+
return this;
|
|
5060
|
+
};
|
|
5061
|
+
HTMLElement2.prototype.replaceWith = function() {
|
|
5062
|
+
var _this = this;
|
|
5063
|
+
var nodes = [];
|
|
5064
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
5065
|
+
nodes[_i] = arguments[_i];
|
|
5066
|
+
}
|
|
5067
|
+
var parent = this.parentNode;
|
|
5068
|
+
var content = nodes.map(function(node2) {
|
|
5069
|
+
if (node2 instanceof node_1$1.default) {
|
|
5070
|
+
return [node2];
|
|
5071
|
+
} else if (typeof node2 == "string") {
|
|
5072
|
+
var r = parse$4(node2, _this._parseOptions);
|
|
5073
|
+
return r.childNodes.length ? r.childNodes : [new text_1$1.default(node2, _this)];
|
|
5074
|
+
}
|
|
5075
|
+
return [];
|
|
5076
|
+
}).flat();
|
|
5077
|
+
var idx = parent.childNodes.findIndex(function(child) {
|
|
5078
|
+
return child === _this;
|
|
5079
|
+
});
|
|
5080
|
+
resetParent([this], null);
|
|
5081
|
+
parent.childNodes = __spreadArray(__spreadArray(__spreadArray([], parent.childNodes.slice(0, idx), true), resetParent(content, parent), true), parent.childNodes.slice(idx + 1), true);
|
|
5082
|
+
return this;
|
|
5083
|
+
};
|
|
5084
|
+
Object.defineProperty(HTMLElement2.prototype, "outerHTML", {
|
|
5526
5085
|
get: function() {
|
|
5527
|
-
return this.
|
|
5086
|
+
return this.toString();
|
|
5528
5087
|
},
|
|
5529
5088
|
enumerable: false,
|
|
5530
5089
|
configurable: true
|
|
5531
5090
|
});
|
|
5532
|
-
|
|
5091
|
+
HTMLElement2.prototype.trimRight = function(pattern) {
|
|
5092
|
+
for (var i = 0; i < this.childNodes.length; i++) {
|
|
5093
|
+
var childNode = this.childNodes[i];
|
|
5094
|
+
if (childNode.nodeType === type_1$1.default.ELEMENT_NODE) {
|
|
5095
|
+
childNode.trimRight(pattern);
|
|
5096
|
+
} else {
|
|
5097
|
+
var index = childNode.rawText.search(pattern);
|
|
5098
|
+
if (index > -1) {
|
|
5099
|
+
childNode.rawText = childNode.rawText.substr(0, index);
|
|
5100
|
+
this.childNodes.length = i + 1;
|
|
5101
|
+
}
|
|
5102
|
+
}
|
|
5103
|
+
}
|
|
5104
|
+
return this;
|
|
5105
|
+
};
|
|
5106
|
+
Object.defineProperty(HTMLElement2.prototype, "structure", {
|
|
5533
5107
|
/**
|
|
5534
|
-
* Get
|
|
5535
|
-
* @return {string}
|
|
5108
|
+
* Get DOM structure
|
|
5109
|
+
* @return {string} structure
|
|
5536
5110
|
*/
|
|
5537
5111
|
get: function() {
|
|
5538
|
-
|
|
5539
|
-
|
|
5112
|
+
var res = [];
|
|
5113
|
+
var indention = 0;
|
|
5114
|
+
function write(str2) {
|
|
5115
|
+
res.push(" ".repeat(indention) + str2);
|
|
5540
5116
|
}
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5117
|
+
function dfs(node2) {
|
|
5118
|
+
var idStr = node2.id ? "#".concat(node2.id) : "";
|
|
5119
|
+
var classStr = node2.classList.length ? ".".concat(node2.classList.value.join(".")) : "";
|
|
5120
|
+
write("".concat(node2.rawTagName).concat(idStr).concat(classStr));
|
|
5121
|
+
indention++;
|
|
5122
|
+
node2.childNodes.forEach(function(childNode) {
|
|
5123
|
+
if (childNode.nodeType === type_1$1.default.ELEMENT_NODE) {
|
|
5124
|
+
dfs(childNode);
|
|
5125
|
+
} else if (childNode.nodeType === type_1$1.default.TEXT_NODE) {
|
|
5126
|
+
if (!childNode.isWhitespace) {
|
|
5127
|
+
write("#text");
|
|
5128
|
+
}
|
|
5129
|
+
}
|
|
5130
|
+
});
|
|
5131
|
+
indention--;
|
|
5132
|
+
}
|
|
5133
|
+
dfs(this);
|
|
5134
|
+
return res.join("\n");
|
|
5544
5135
|
},
|
|
5545
5136
|
enumerable: false,
|
|
5546
5137
|
configurable: true
|
|
5547
5138
|
});
|
|
5548
|
-
|
|
5139
|
+
HTMLElement2.prototype.removeWhitespace = function() {
|
|
5140
|
+
var _this = this;
|
|
5141
|
+
var o = 0;
|
|
5142
|
+
this.childNodes.forEach(function(node2) {
|
|
5143
|
+
if (node2.nodeType === type_1$1.default.TEXT_NODE) {
|
|
5144
|
+
if (node2.isWhitespace) {
|
|
5145
|
+
return;
|
|
5146
|
+
}
|
|
5147
|
+
node2.rawText = node2.trimmedRawText;
|
|
5148
|
+
} else if (node2.nodeType === type_1$1.default.ELEMENT_NODE) {
|
|
5149
|
+
node2.removeWhitespace();
|
|
5150
|
+
}
|
|
5151
|
+
_this.childNodes[o++] = node2;
|
|
5152
|
+
});
|
|
5153
|
+
this.childNodes.length = o;
|
|
5154
|
+
return this;
|
|
5155
|
+
};
|
|
5156
|
+
HTMLElement2.prototype.querySelectorAll = function(selector) {
|
|
5157
|
+
return (0, css_select_1.selectAll)(selector, this, {
|
|
5158
|
+
xmlMode: true,
|
|
5159
|
+
adapter: matcher_1.default
|
|
5160
|
+
});
|
|
5161
|
+
};
|
|
5162
|
+
HTMLElement2.prototype.querySelector = function(selector) {
|
|
5163
|
+
return (0, css_select_1.selectOne)(selector, this, {
|
|
5164
|
+
xmlMode: true,
|
|
5165
|
+
adapter: matcher_1.default
|
|
5166
|
+
});
|
|
5167
|
+
};
|
|
5168
|
+
HTMLElement2.prototype.getElementsByTagName = function(tagName) {
|
|
5169
|
+
var upperCasedTagName = tagName.toUpperCase();
|
|
5170
|
+
var re = [];
|
|
5171
|
+
var stack = [];
|
|
5172
|
+
var currentNodeReference = this;
|
|
5173
|
+
var index = 0;
|
|
5174
|
+
while (index !== void 0) {
|
|
5175
|
+
var child = void 0;
|
|
5176
|
+
do {
|
|
5177
|
+
child = currentNodeReference.childNodes[index++];
|
|
5178
|
+
} while (index < currentNodeReference.childNodes.length && child === void 0);
|
|
5179
|
+
if (child === void 0) {
|
|
5180
|
+
currentNodeReference = currentNodeReference.parentNode;
|
|
5181
|
+
index = stack.pop();
|
|
5182
|
+
continue;
|
|
5183
|
+
}
|
|
5184
|
+
if (child.nodeType === type_1$1.default.ELEMENT_NODE) {
|
|
5185
|
+
if (tagName === "*" || child.tagName === upperCasedTagName)
|
|
5186
|
+
re.push(child);
|
|
5187
|
+
if (child.childNodes.length > 0) {
|
|
5188
|
+
stack.push(index);
|
|
5189
|
+
currentNodeReference = child;
|
|
5190
|
+
index = 0;
|
|
5191
|
+
}
|
|
5192
|
+
}
|
|
5193
|
+
}
|
|
5194
|
+
return re;
|
|
5195
|
+
};
|
|
5196
|
+
HTMLElement2.prototype.getElementById = function(id) {
|
|
5197
|
+
var stack = [];
|
|
5198
|
+
var currentNodeReference = this;
|
|
5199
|
+
var index = 0;
|
|
5200
|
+
while (index !== void 0) {
|
|
5201
|
+
var child = void 0;
|
|
5202
|
+
do {
|
|
5203
|
+
child = currentNodeReference.childNodes[index++];
|
|
5204
|
+
} while (index < currentNodeReference.childNodes.length && child === void 0);
|
|
5205
|
+
if (child === void 0) {
|
|
5206
|
+
currentNodeReference = currentNodeReference.parentNode;
|
|
5207
|
+
index = stack.pop();
|
|
5208
|
+
continue;
|
|
5209
|
+
}
|
|
5210
|
+
if (child.nodeType === type_1$1.default.ELEMENT_NODE) {
|
|
5211
|
+
if (child.id === id) {
|
|
5212
|
+
return child;
|
|
5213
|
+
}
|
|
5214
|
+
if (child.childNodes.length > 0) {
|
|
5215
|
+
stack.push(index);
|
|
5216
|
+
currentNodeReference = child;
|
|
5217
|
+
index = 0;
|
|
5218
|
+
}
|
|
5219
|
+
}
|
|
5220
|
+
}
|
|
5221
|
+
return null;
|
|
5222
|
+
};
|
|
5223
|
+
HTMLElement2.prototype.closest = function(selector) {
|
|
5224
|
+
var mapChild = /* @__PURE__ */ new Map();
|
|
5225
|
+
var el = this;
|
|
5226
|
+
var old = null;
|
|
5227
|
+
function findOne2(test, elems) {
|
|
5228
|
+
var elem = null;
|
|
5229
|
+
for (var i = 0, l = elems.length; i < l && !elem; i++) {
|
|
5230
|
+
var el_1 = elems[i];
|
|
5231
|
+
if (test(el_1)) {
|
|
5232
|
+
elem = el_1;
|
|
5233
|
+
} else {
|
|
5234
|
+
var child = mapChild.get(el_1);
|
|
5235
|
+
if (child) {
|
|
5236
|
+
elem = findOne2(test, [child]);
|
|
5237
|
+
}
|
|
5238
|
+
}
|
|
5239
|
+
}
|
|
5240
|
+
return elem;
|
|
5241
|
+
}
|
|
5242
|
+
while (el) {
|
|
5243
|
+
mapChild.set(el, old);
|
|
5244
|
+
old = el;
|
|
5245
|
+
el = el.parentNode;
|
|
5246
|
+
}
|
|
5247
|
+
el = this;
|
|
5248
|
+
while (el) {
|
|
5249
|
+
var e2 = (0, css_select_1.selectOne)(selector, el, {
|
|
5250
|
+
xmlMode: true,
|
|
5251
|
+
adapter: __assign$1(__assign$1({}, matcher_1.default), { getChildren: function(node2) {
|
|
5252
|
+
var child = mapChild.get(node2);
|
|
5253
|
+
return child && [child];
|
|
5254
|
+
}, getSiblings: function(node2) {
|
|
5255
|
+
return [node2];
|
|
5256
|
+
}, findOne: findOne2, findAll: function() {
|
|
5257
|
+
return [];
|
|
5258
|
+
} })
|
|
5259
|
+
});
|
|
5260
|
+
if (e2) {
|
|
5261
|
+
return e2;
|
|
5262
|
+
}
|
|
5263
|
+
el = el.parentNode;
|
|
5264
|
+
}
|
|
5265
|
+
return null;
|
|
5266
|
+
};
|
|
5267
|
+
HTMLElement2.prototype.appendChild = function(node2) {
|
|
5268
|
+
node2.remove();
|
|
5269
|
+
this.childNodes.push(node2);
|
|
5270
|
+
node2.parentNode = this;
|
|
5271
|
+
return node2;
|
|
5272
|
+
};
|
|
5273
|
+
Object.defineProperty(HTMLElement2.prototype, "firstChild", {
|
|
5274
|
+
/**
|
|
5275
|
+
* Get first child node
|
|
5276
|
+
* @return {Node | undefined} first child node; or undefined if none
|
|
5277
|
+
*/
|
|
5549
5278
|
get: function() {
|
|
5550
|
-
return
|
|
5551
|
-
},
|
|
5552
|
-
set: function(val) {
|
|
5553
|
-
var content = [new text_1$1.default(val, this)];
|
|
5554
|
-
this.childNodes = content;
|
|
5279
|
+
return this.childNodes[0];
|
|
5555
5280
|
},
|
|
5556
5281
|
enumerable: false,
|
|
5557
5282
|
configurable: true
|
|
5558
5283
|
});
|
|
5559
|
-
Object.defineProperty(HTMLElement2.prototype, "
|
|
5284
|
+
Object.defineProperty(HTMLElement2.prototype, "lastChild", {
|
|
5560
5285
|
/**
|
|
5561
|
-
* Get
|
|
5562
|
-
* @return {
|
|
5286
|
+
* Get last child node
|
|
5287
|
+
* @return {Node | undefined} last child node; or undefined if none
|
|
5563
5288
|
*/
|
|
5564
5289
|
get: function() {
|
|
5565
|
-
return
|
|
5290
|
+
return (0, back_1.default)(this.childNodes);
|
|
5566
5291
|
},
|
|
5567
5292
|
enumerable: false,
|
|
5568
5293
|
configurable: true
|
|
5569
5294
|
});
|
|
5570
|
-
Object.defineProperty(HTMLElement2.prototype, "
|
|
5295
|
+
Object.defineProperty(HTMLElement2.prototype, "attrs", {
|
|
5571
5296
|
/**
|
|
5572
|
-
* Get
|
|
5573
|
-
* @
|
|
5297
|
+
* Get attributes
|
|
5298
|
+
* @access private
|
|
5299
|
+
* @return {Object} parsed and unescaped attributes
|
|
5574
5300
|
*/
|
|
5575
5301
|
get: function() {
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
function dfs(node2) {
|
|
5579
|
-
if (node2.nodeType === type_1$1.default.ELEMENT_NODE) {
|
|
5580
|
-
if (kBlockElements.has(node2.rawTagName)) {
|
|
5581
|
-
if (currentBlock.length > 0) {
|
|
5582
|
-
blocks.push(currentBlock = []);
|
|
5583
|
-
}
|
|
5584
|
-
node2.childNodes.forEach(dfs);
|
|
5585
|
-
if (currentBlock.length > 0) {
|
|
5586
|
-
blocks.push(currentBlock = []);
|
|
5587
|
-
}
|
|
5588
|
-
} else {
|
|
5589
|
-
node2.childNodes.forEach(dfs);
|
|
5590
|
-
}
|
|
5591
|
-
} else if (node2.nodeType === type_1$1.default.TEXT_NODE) {
|
|
5592
|
-
if (node2.isWhitespace) {
|
|
5593
|
-
currentBlock.prependWhitespace = true;
|
|
5594
|
-
} else {
|
|
5595
|
-
var text2 = node2.trimmedText;
|
|
5596
|
-
if (currentBlock.prependWhitespace) {
|
|
5597
|
-
text2 = " ".concat(text2);
|
|
5598
|
-
currentBlock.prependWhitespace = false;
|
|
5599
|
-
}
|
|
5600
|
-
currentBlock.push(text2);
|
|
5601
|
-
}
|
|
5602
|
-
}
|
|
5302
|
+
if (this._attrs) {
|
|
5303
|
+
return this._attrs;
|
|
5603
5304
|
}
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5305
|
+
this._attrs = {};
|
|
5306
|
+
var attrs = this.rawAttributes;
|
|
5307
|
+
for (var key in attrs) {
|
|
5308
|
+
var val = attrs[key] || "";
|
|
5309
|
+
this._attrs[key.toLowerCase()] = decode(val);
|
|
5310
|
+
}
|
|
5311
|
+
return this._attrs;
|
|
5608
5312
|
},
|
|
5609
5313
|
enumerable: false,
|
|
5610
5314
|
configurable: true
|
|
5611
5315
|
});
|
|
5612
|
-
HTMLElement2.prototype
|
|
5613
|
-
var tag = this.rawTagName;
|
|
5614
|
-
if (tag) {
|
|
5615
|
-
var attrs = this.rawAttrs ? " ".concat(this.rawAttrs) : "";
|
|
5616
|
-
return this.voidTag.formatNode(tag, attrs, this.innerHTML);
|
|
5617
|
-
}
|
|
5618
|
-
return this.innerHTML;
|
|
5619
|
-
};
|
|
5620
|
-
Object.defineProperty(HTMLElement2.prototype, "innerHTML", {
|
|
5316
|
+
Object.defineProperty(HTMLElement2.prototype, "attributes", {
|
|
5621
5317
|
get: function() {
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5318
|
+
var ret_attrs = {};
|
|
5319
|
+
var attrs = this.rawAttributes;
|
|
5320
|
+
for (var key in attrs) {
|
|
5321
|
+
var val = attrs[key] || "";
|
|
5322
|
+
ret_attrs[key] = decode(val);
|
|
5323
|
+
}
|
|
5324
|
+
return ret_attrs;
|
|
5625
5325
|
},
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5326
|
+
enumerable: false,
|
|
5327
|
+
configurable: true
|
|
5328
|
+
});
|
|
5329
|
+
Object.defineProperty(HTMLElement2.prototype, "rawAttributes", {
|
|
5330
|
+
/**
|
|
5331
|
+
* Get escaped (as-is) attributes
|
|
5332
|
+
* @return {Object} parsed attributes
|
|
5333
|
+
*/
|
|
5334
|
+
get: function() {
|
|
5335
|
+
if (this._rawAttrs) {
|
|
5336
|
+
return this._rawAttrs;
|
|
5337
|
+
}
|
|
5338
|
+
var attrs = {};
|
|
5339
|
+
if (this.rawAttrs) {
|
|
5340
|
+
var re = /([a-zA-Z()[\]#@$.?:][a-zA-Z0-9-_:()[\]#]*)(?:\s*=\s*((?:'[^']*')|(?:"[^"]*")|\S+))?/g;
|
|
5341
|
+
var match = void 0;
|
|
5342
|
+
while (match = re.exec(this.rawAttrs)) {
|
|
5343
|
+
var key = match[1];
|
|
5344
|
+
var val = match[2] || null;
|
|
5345
|
+
if (val && (val[0] === "'" || val[0] === '"'))
|
|
5346
|
+
val = val.slice(1, val.length - 1);
|
|
5347
|
+
attrs[key] = attrs[key] || val;
|
|
5348
|
+
}
|
|
5349
|
+
}
|
|
5350
|
+
this._rawAttrs = attrs;
|
|
5351
|
+
return attrs;
|
|
5632
5352
|
},
|
|
5633
5353
|
enumerable: false,
|
|
5634
5354
|
configurable: true
|
|
5635
5355
|
});
|
|
5636
|
-
HTMLElement2.prototype.
|
|
5637
|
-
|
|
5638
|
-
|
|
5356
|
+
HTMLElement2.prototype.removeAttribute = function(key) {
|
|
5357
|
+
var _this = this;
|
|
5358
|
+
var attrs = this.rawAttributes;
|
|
5359
|
+
delete attrs[key];
|
|
5360
|
+
if (this._attrs) {
|
|
5361
|
+
delete this._attrs[key];
|
|
5639
5362
|
}
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5363
|
+
this.rawAttrs = Object.keys(attrs).map(function(name) {
|
|
5364
|
+
var val = _this.quoteAttribute(attrs[name]);
|
|
5365
|
+
if (val === "null" || val === '""')
|
|
5366
|
+
return name;
|
|
5367
|
+
return "".concat(name, "=").concat(val);
|
|
5368
|
+
}).join(" ");
|
|
5369
|
+
if (key === "id") {
|
|
5370
|
+
this.id = "";
|
|
5646
5371
|
}
|
|
5647
|
-
resetParent(this.childNodes, null);
|
|
5648
|
-
resetParent(content, this);
|
|
5649
|
-
this.childNodes = content;
|
|
5650
5372
|
return this;
|
|
5651
5373
|
};
|
|
5652
|
-
HTMLElement2.prototype.
|
|
5374
|
+
HTMLElement2.prototype.hasAttribute = function(key) {
|
|
5375
|
+
return key.toLowerCase() in this.attrs;
|
|
5376
|
+
};
|
|
5377
|
+
HTMLElement2.prototype.getAttribute = function(key) {
|
|
5378
|
+
return this.attrs[key.toLowerCase()];
|
|
5379
|
+
};
|
|
5380
|
+
HTMLElement2.prototype.setAttribute = function(key, value) {
|
|
5653
5381
|
var _this = this;
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
nodes[_i] = arguments[_i];
|
|
5382
|
+
if (arguments.length < 2) {
|
|
5383
|
+
throw new Error("Failed to execute 'setAttribute' on 'Element'");
|
|
5657
5384
|
}
|
|
5658
|
-
var
|
|
5659
|
-
var
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
return r.childNodes.length ? r.childNodes : [new text_1$1.default(node2, _this)];
|
|
5385
|
+
var k2 = key.toLowerCase();
|
|
5386
|
+
var attrs = this.rawAttributes;
|
|
5387
|
+
for (var k in attrs) {
|
|
5388
|
+
if (k.toLowerCase() === k2) {
|
|
5389
|
+
key = k;
|
|
5390
|
+
break;
|
|
5665
5391
|
}
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
}
|
|
5671
|
-
|
|
5672
|
-
|
|
5392
|
+
}
|
|
5393
|
+
attrs[key] = String(value);
|
|
5394
|
+
if (this._attrs) {
|
|
5395
|
+
this._attrs[k2] = decode(attrs[key]);
|
|
5396
|
+
}
|
|
5397
|
+
this.rawAttrs = Object.keys(attrs).map(function(name) {
|
|
5398
|
+
var val = _this.quoteAttribute(attrs[name]);
|
|
5399
|
+
if (val === "null" || val === '""')
|
|
5400
|
+
return name;
|
|
5401
|
+
return "".concat(name, "=").concat(val);
|
|
5402
|
+
}).join(" ");
|
|
5403
|
+
if (key === "id") {
|
|
5404
|
+
this.id = value;
|
|
5405
|
+
}
|
|
5673
5406
|
return this;
|
|
5674
5407
|
};
|
|
5675
|
-
|
|
5408
|
+
HTMLElement2.prototype.setAttributes = function(attributes2) {
|
|
5409
|
+
var _this = this;
|
|
5410
|
+
if (this._attrs) {
|
|
5411
|
+
delete this._attrs;
|
|
5412
|
+
}
|
|
5413
|
+
if (this._rawAttrs) {
|
|
5414
|
+
delete this._rawAttrs;
|
|
5415
|
+
}
|
|
5416
|
+
this.rawAttrs = Object.keys(attributes2).map(function(name) {
|
|
5417
|
+
var val = attributes2[name];
|
|
5418
|
+
if (val === "null" || val === '""')
|
|
5419
|
+
return name;
|
|
5420
|
+
return "".concat(name, "=").concat(_this.quoteAttribute(String(val)));
|
|
5421
|
+
}).join(" ");
|
|
5422
|
+
return this;
|
|
5423
|
+
};
|
|
5424
|
+
HTMLElement2.prototype.insertAdjacentHTML = function(where, html2) {
|
|
5425
|
+
var _a, _b, _c;
|
|
5426
|
+
var _this = this;
|
|
5427
|
+
if (arguments.length < 2) {
|
|
5428
|
+
throw new Error("2 arguments required");
|
|
5429
|
+
}
|
|
5430
|
+
var p = parse$4(html2, this._parseOptions);
|
|
5431
|
+
if (where === "afterend") {
|
|
5432
|
+
var idx = this.parentNode.childNodes.findIndex(function(child) {
|
|
5433
|
+
return child === _this;
|
|
5434
|
+
});
|
|
5435
|
+
resetParent(p.childNodes, this.parentNode);
|
|
5436
|
+
(_a = this.parentNode.childNodes).splice.apply(_a, __spreadArray([idx + 1, 0], p.childNodes, false));
|
|
5437
|
+
} else if (where === "afterbegin") {
|
|
5438
|
+
resetParent(p.childNodes, this);
|
|
5439
|
+
(_b = this.childNodes).unshift.apply(_b, p.childNodes);
|
|
5440
|
+
} else if (where === "beforeend") {
|
|
5441
|
+
p.childNodes.forEach(function(n) {
|
|
5442
|
+
_this.appendChild(n);
|
|
5443
|
+
});
|
|
5444
|
+
} else if (where === "beforebegin") {
|
|
5445
|
+
var idx = this.parentNode.childNodes.findIndex(function(child) {
|
|
5446
|
+
return child === _this;
|
|
5447
|
+
});
|
|
5448
|
+
resetParent(p.childNodes, this.parentNode);
|
|
5449
|
+
(_c = this.parentNode.childNodes).splice.apply(_c, __spreadArray([idx, 0], p.childNodes, false));
|
|
5450
|
+
} else {
|
|
5451
|
+
throw new Error("The value provided ('".concat(where, "') is not one of 'beforebegin', 'afterbegin', 'beforeend', or 'afterend'"));
|
|
5452
|
+
}
|
|
5453
|
+
return this;
|
|
5454
|
+
};
|
|
5455
|
+
Object.defineProperty(HTMLElement2.prototype, "nextSibling", {
|
|
5676
5456
|
get: function() {
|
|
5677
|
-
|
|
5457
|
+
if (this.parentNode) {
|
|
5458
|
+
var children = this.parentNode.childNodes;
|
|
5459
|
+
var i = 0;
|
|
5460
|
+
while (i < children.length) {
|
|
5461
|
+
var child = children[i++];
|
|
5462
|
+
if (this === child)
|
|
5463
|
+
return children[i] || null;
|
|
5464
|
+
}
|
|
5465
|
+
return null;
|
|
5466
|
+
}
|
|
5678
5467
|
},
|
|
5679
5468
|
enumerable: false,
|
|
5680
5469
|
configurable: true
|
|
5681
5470
|
});
|
|
5682
|
-
HTMLElement2.prototype
|
|
5683
|
-
for (var i = 0; i < this.childNodes.length; i++) {
|
|
5684
|
-
var childNode = this.childNodes[i];
|
|
5685
|
-
if (childNode.nodeType === type_1$1.default.ELEMENT_NODE) {
|
|
5686
|
-
childNode.trimRight(pattern);
|
|
5687
|
-
} else {
|
|
5688
|
-
var index = childNode.rawText.search(pattern);
|
|
5689
|
-
if (index > -1) {
|
|
5690
|
-
childNode.rawText = childNode.rawText.substr(0, index);
|
|
5691
|
-
this.childNodes.length = i + 1;
|
|
5692
|
-
}
|
|
5693
|
-
}
|
|
5694
|
-
}
|
|
5695
|
-
return this;
|
|
5696
|
-
};
|
|
5697
|
-
Object.defineProperty(HTMLElement2.prototype, "structure", {
|
|
5698
|
-
/**
|
|
5699
|
-
* Get DOM structure
|
|
5700
|
-
* @return {string} structure
|
|
5701
|
-
*/
|
|
5471
|
+
Object.defineProperty(HTMLElement2.prototype, "nextElementSibling", {
|
|
5702
5472
|
get: function() {
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5712
|
-
indention++;
|
|
5713
|
-
node2.childNodes.forEach(function(childNode) {
|
|
5714
|
-
if (childNode.nodeType === type_1$1.default.ELEMENT_NODE) {
|
|
5715
|
-
dfs(childNode);
|
|
5716
|
-
} else if (childNode.nodeType === type_1$1.default.TEXT_NODE) {
|
|
5717
|
-
if (!childNode.isWhitespace) {
|
|
5718
|
-
write("#text");
|
|
5473
|
+
if (this.parentNode) {
|
|
5474
|
+
var children = this.parentNode.childNodes;
|
|
5475
|
+
var i = 0;
|
|
5476
|
+
var find2 = false;
|
|
5477
|
+
while (i < children.length) {
|
|
5478
|
+
var child = children[i++];
|
|
5479
|
+
if (find2) {
|
|
5480
|
+
if (child instanceof HTMLElement2) {
|
|
5481
|
+
return child || null;
|
|
5719
5482
|
}
|
|
5483
|
+
} else if (this === child) {
|
|
5484
|
+
find2 = true;
|
|
5720
5485
|
}
|
|
5721
|
-
}
|
|
5722
|
-
|
|
5486
|
+
}
|
|
5487
|
+
return null;
|
|
5488
|
+
}
|
|
5489
|
+
},
|
|
5490
|
+
enumerable: false,
|
|
5491
|
+
configurable: true
|
|
5492
|
+
});
|
|
5493
|
+
Object.defineProperty(HTMLElement2.prototype, "previousSibling", {
|
|
5494
|
+
get: function() {
|
|
5495
|
+
if (this.parentNode) {
|
|
5496
|
+
var children = this.parentNode.childNodes;
|
|
5497
|
+
var i = children.length;
|
|
5498
|
+
while (i > 0) {
|
|
5499
|
+
var child = children[--i];
|
|
5500
|
+
if (this === child)
|
|
5501
|
+
return children[i - 1] || null;
|
|
5502
|
+
}
|
|
5503
|
+
return null;
|
|
5723
5504
|
}
|
|
5724
|
-
dfs(this);
|
|
5725
|
-
return res.join("\n");
|
|
5726
5505
|
},
|
|
5727
5506
|
enumerable: false,
|
|
5728
5507
|
configurable: true
|
|
5729
5508
|
});
|
|
5730
|
-
HTMLElement2.prototype
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5509
|
+
Object.defineProperty(HTMLElement2.prototype, "previousElementSibling", {
|
|
5510
|
+
get: function() {
|
|
5511
|
+
if (this.parentNode) {
|
|
5512
|
+
var children = this.parentNode.childNodes;
|
|
5513
|
+
var i = children.length;
|
|
5514
|
+
var find2 = false;
|
|
5515
|
+
while (i > 0) {
|
|
5516
|
+
var child = children[--i];
|
|
5517
|
+
if (find2) {
|
|
5518
|
+
if (child instanceof HTMLElement2) {
|
|
5519
|
+
return child || null;
|
|
5520
|
+
}
|
|
5521
|
+
} else if (this === child) {
|
|
5522
|
+
find2 = true;
|
|
5523
|
+
}
|
|
5737
5524
|
}
|
|
5738
|
-
|
|
5739
|
-
} else if (node2.nodeType === type_1$1.default.ELEMENT_NODE) {
|
|
5740
|
-
node2.removeWhitespace();
|
|
5525
|
+
return null;
|
|
5741
5526
|
}
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
};
|
|
5753
|
-
HTMLElement2.prototype.
|
|
5754
|
-
return (
|
|
5755
|
-
xmlMode: true,
|
|
5756
|
-
adapter: matcher_1.default
|
|
5757
|
-
});
|
|
5527
|
+
},
|
|
5528
|
+
enumerable: false,
|
|
5529
|
+
configurable: true
|
|
5530
|
+
});
|
|
5531
|
+
Object.defineProperty(HTMLElement2.prototype, "classNames", {
|
|
5532
|
+
get: function() {
|
|
5533
|
+
return this.classList.toString();
|
|
5534
|
+
},
|
|
5535
|
+
enumerable: false,
|
|
5536
|
+
configurable: true
|
|
5537
|
+
});
|
|
5538
|
+
HTMLElement2.prototype.clone = function() {
|
|
5539
|
+
return parse$4(this.toString(), this._parseOptions).firstChild;
|
|
5758
5540
|
};
|
|
5759
|
-
HTMLElement2
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5541
|
+
return HTMLElement2;
|
|
5542
|
+
}(node_1$1.default)
|
|
5543
|
+
);
|
|
5544
|
+
html.default = HTMLElement;
|
|
5545
|
+
var kMarkupPattern = /<!--[\s\S]*?-->|<(\/?)([a-zA-Z][-.:0-9_a-zA-Z]*)((?:\s+[^>]*?(?:(?:'[^']*')|(?:"[^"]*"))?)*)\s*(\/?)>/g;
|
|
5546
|
+
var kAttributePattern = /(?:^|\s)(id|class)\s*=\s*((?:'[^']*')|(?:"[^"]*")|\S+)/gi;
|
|
5547
|
+
var kElementsClosedByOpening = {
|
|
5548
|
+
li: { li: true, LI: true },
|
|
5549
|
+
LI: { li: true, LI: true },
|
|
5550
|
+
p: { p: true, div: true, P: true, DIV: true },
|
|
5551
|
+
P: { p: true, div: true, P: true, DIV: true },
|
|
5552
|
+
b: { div: true, DIV: true },
|
|
5553
|
+
B: { div: true, DIV: true },
|
|
5554
|
+
td: { td: true, th: true, TD: true, TH: true },
|
|
5555
|
+
TD: { td: true, th: true, TD: true, TH: true },
|
|
5556
|
+
th: { td: true, th: true, TD: true, TH: true },
|
|
5557
|
+
TH: { td: true, th: true, TD: true, TH: true },
|
|
5558
|
+
h1: { h1: true, H1: true },
|
|
5559
|
+
H1: { h1: true, H1: true },
|
|
5560
|
+
h2: { h2: true, H2: true },
|
|
5561
|
+
H2: { h2: true, H2: true },
|
|
5562
|
+
h3: { h3: true, H3: true },
|
|
5563
|
+
H3: { h3: true, H3: true },
|
|
5564
|
+
h4: { h4: true, H4: true },
|
|
5565
|
+
H4: { h4: true, H4: true },
|
|
5566
|
+
h5: { h5: true, H5: true },
|
|
5567
|
+
H5: { h5: true, H5: true },
|
|
5568
|
+
h6: { h6: true, H6: true },
|
|
5569
|
+
H6: { h6: true, H6: true }
|
|
5570
|
+
};
|
|
5571
|
+
var kElementsClosedByClosing = {
|
|
5572
|
+
li: { ul: true, ol: true, UL: true, OL: true },
|
|
5573
|
+
LI: { ul: true, ol: true, UL: true, OL: true },
|
|
5574
|
+
a: { div: true, DIV: true },
|
|
5575
|
+
A: { div: true, DIV: true },
|
|
5576
|
+
b: { div: true, DIV: true },
|
|
5577
|
+
B: { div: true, DIV: true },
|
|
5578
|
+
i: { div: true, DIV: true },
|
|
5579
|
+
I: { div: true, DIV: true },
|
|
5580
|
+
p: { div: true, DIV: true },
|
|
5581
|
+
P: { div: true, DIV: true },
|
|
5582
|
+
td: { tr: true, table: true, TR: true, TABLE: true },
|
|
5583
|
+
TD: { tr: true, table: true, TR: true, TABLE: true },
|
|
5584
|
+
th: { tr: true, table: true, TR: true, TABLE: true },
|
|
5585
|
+
TH: { tr: true, table: true, TR: true, TABLE: true }
|
|
5586
|
+
};
|
|
5587
|
+
var frameflag = "documentfragmentcontainer";
|
|
5588
|
+
function base_parse(data, options) {
|
|
5589
|
+
var _a, _b;
|
|
5590
|
+
if (options === void 0) {
|
|
5591
|
+
options = {};
|
|
5592
|
+
}
|
|
5593
|
+
var voidTag2 = new void_tag_1.default((_a = options === null || options === void 0 ? void 0 : options.voidTag) === null || _a === void 0 ? void 0 : _a.closingSlash, (_b = options === null || options === void 0 ? void 0 : options.voidTag) === null || _b === void 0 ? void 0 : _b.tags);
|
|
5594
|
+
var elements = options.blockTextElements || {
|
|
5595
|
+
script: true,
|
|
5596
|
+
noscript: true,
|
|
5597
|
+
style: true,
|
|
5598
|
+
pre: true
|
|
5599
|
+
};
|
|
5600
|
+
var element_names = Object.keys(elements);
|
|
5601
|
+
var kBlockTextElements = element_names.map(function(it) {
|
|
5602
|
+
return new RegExp("^".concat(it, "$"), "i");
|
|
5603
|
+
});
|
|
5604
|
+
var kIgnoreElements = element_names.filter(function(it) {
|
|
5605
|
+
return Boolean(elements[it]);
|
|
5606
|
+
}).map(function(it) {
|
|
5607
|
+
return new RegExp("^".concat(it, "$"), "i");
|
|
5608
|
+
});
|
|
5609
|
+
function element_should_be_ignore(tag) {
|
|
5610
|
+
return kIgnoreElements.some(function(it) {
|
|
5611
|
+
return it.test(tag);
|
|
5612
|
+
});
|
|
5613
|
+
}
|
|
5614
|
+
function is_block_text_element(tag) {
|
|
5615
|
+
return kBlockTextElements.some(function(it) {
|
|
5616
|
+
return it.test(tag);
|
|
5617
|
+
});
|
|
5618
|
+
}
|
|
5619
|
+
var createRange = function(startPos, endPos) {
|
|
5620
|
+
return [startPos - frameFlagOffset, endPos - frameFlagOffset];
|
|
5621
|
+
};
|
|
5622
|
+
var root = new HTMLElement(null, {}, "", null, [0, data.length], voidTag2, options);
|
|
5623
|
+
var currentParent = root;
|
|
5624
|
+
var stack = [root];
|
|
5625
|
+
var lastTextPos = -1;
|
|
5626
|
+
var noNestedTagIndex = void 0;
|
|
5627
|
+
var match;
|
|
5628
|
+
data = "<".concat(frameflag, ">").concat(data, "</").concat(frameflag, ">");
|
|
5629
|
+
var lowerCaseTagName = options.lowerCaseTagName, fixNestedATags = options.fixNestedATags;
|
|
5630
|
+
var dataEndPos = data.length - (frameflag.length + 2);
|
|
5631
|
+
var frameFlagOffset = frameflag.length + 2;
|
|
5632
|
+
while (match = kMarkupPattern.exec(data)) {
|
|
5633
|
+
var matchText = match[0], leadingSlash = match[1], tagName = match[2], attributes2 = match[3], closingSlash = match[4];
|
|
5634
|
+
var matchLength = matchText.length;
|
|
5635
|
+
var tagStartPos = kMarkupPattern.lastIndex - matchLength;
|
|
5636
|
+
var tagEndPos = kMarkupPattern.lastIndex;
|
|
5637
|
+
if (lastTextPos > -1) {
|
|
5638
|
+
if (lastTextPos + matchLength < tagEndPos) {
|
|
5639
|
+
var text2 = data.substring(lastTextPos, tagStartPos);
|
|
5640
|
+
currentParent.appendChild(new text_1$1.default(text2, currentParent, createRange(lastTextPos, tagStartPos)));
|
|
5641
|
+
}
|
|
5642
|
+
}
|
|
5643
|
+
lastTextPos = kMarkupPattern.lastIndex;
|
|
5644
|
+
if (tagName === frameflag)
|
|
5645
|
+
continue;
|
|
5646
|
+
if (matchText[1] === "!") {
|
|
5647
|
+
if (options.comment) {
|
|
5648
|
+
var text2 = data.substring(tagStartPos + 4, tagEndPos - 3);
|
|
5649
|
+
currentParent.appendChild(new comment_1$1.default(text2, currentParent, createRange(tagStartPos, tagEndPos)));
|
|
5650
|
+
}
|
|
5651
|
+
continue;
|
|
5652
|
+
}
|
|
5653
|
+
if (lowerCaseTagName)
|
|
5654
|
+
tagName = tagName.toLowerCase();
|
|
5655
|
+
if (!leadingSlash) {
|
|
5656
|
+
var attrs = {};
|
|
5657
|
+
for (var attMatch = void 0; attMatch = kAttributePattern.exec(attributes2); ) {
|
|
5658
|
+
var key = attMatch[1], val = attMatch[2];
|
|
5659
|
+
var isQuoted = val[0] === "'" || val[0] === '"';
|
|
5660
|
+
attrs[key.toLowerCase()] = isQuoted ? val.slice(1, val.length - 1) : val;
|
|
5661
|
+
}
|
|
5662
|
+
var parentTagName = currentParent.rawTagName;
|
|
5663
|
+
if (!closingSlash && kElementsClosedByOpening[parentTagName]) {
|
|
5664
|
+
if (kElementsClosedByOpening[parentTagName][tagName]) {
|
|
5665
|
+
stack.pop();
|
|
5666
|
+
currentParent = (0, back_1.default)(stack);
|
|
5783
5667
|
}
|
|
5784
5668
|
}
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
var currentNodeReference = this;
|
|
5790
|
-
var index = 0;
|
|
5791
|
-
while (index !== void 0) {
|
|
5792
|
-
var child = void 0;
|
|
5793
|
-
do {
|
|
5794
|
-
child = currentNodeReference.childNodes[index++];
|
|
5795
|
-
} while (index < currentNodeReference.childNodes.length && child === void 0);
|
|
5796
|
-
if (child === void 0) {
|
|
5797
|
-
currentNodeReference = currentNodeReference.parentNode;
|
|
5798
|
-
index = stack.pop();
|
|
5799
|
-
continue;
|
|
5669
|
+
if (fixNestedATags && (tagName === "a" || tagName === "A")) {
|
|
5670
|
+
if (noNestedTagIndex !== void 0) {
|
|
5671
|
+
stack.splice(noNestedTagIndex);
|
|
5672
|
+
currentParent = (0, back_1.default)(stack);
|
|
5800
5673
|
}
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5674
|
+
noNestedTagIndex = stack.length;
|
|
5675
|
+
}
|
|
5676
|
+
var tagEndPos_1 = kMarkupPattern.lastIndex;
|
|
5677
|
+
var tagStartPos_1 = tagEndPos_1 - matchLength;
|
|
5678
|
+
currentParent = currentParent.appendChild(
|
|
5679
|
+
// Initialize range (end position updated later for closed tags)
|
|
5680
|
+
new HTMLElement(tagName, attrs, attributes2.slice(1), null, createRange(tagStartPos_1, tagEndPos_1), voidTag2, options)
|
|
5681
|
+
);
|
|
5682
|
+
stack.push(currentParent);
|
|
5683
|
+
if (is_block_text_element(tagName)) {
|
|
5684
|
+
var closeMarkup = "</".concat(tagName, ">");
|
|
5685
|
+
var closeIndex = lowerCaseTagName ? data.toLocaleLowerCase().indexOf(closeMarkup, kMarkupPattern.lastIndex) : data.indexOf(closeMarkup, kMarkupPattern.lastIndex);
|
|
5686
|
+
var textEndPos = closeIndex === -1 ? dataEndPos : closeIndex;
|
|
5687
|
+
if (element_should_be_ignore(tagName)) {
|
|
5688
|
+
var text2 = data.substring(tagEndPos_1, textEndPos);
|
|
5689
|
+
if (text2.length > 0 && /\S/.test(text2)) {
|
|
5690
|
+
currentParent.appendChild(new text_1$1.default(text2, currentParent, createRange(tagEndPos_1, textEndPos)));
|
|
5809
5691
|
}
|
|
5810
5692
|
}
|
|
5693
|
+
if (closeIndex === -1) {
|
|
5694
|
+
lastTextPos = kMarkupPattern.lastIndex = data.length + 1;
|
|
5695
|
+
} else {
|
|
5696
|
+
lastTextPos = kMarkupPattern.lastIndex = closeIndex + closeMarkup.length;
|
|
5697
|
+
leadingSlash = "/";
|
|
5698
|
+
}
|
|
5811
5699
|
}
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5700
|
+
}
|
|
5701
|
+
if (leadingSlash || closingSlash || voidTag2.isVoidElement(tagName)) {
|
|
5702
|
+
while (true) {
|
|
5703
|
+
if (noNestedTagIndex != null && (tagName === "a" || tagName === "A"))
|
|
5704
|
+
noNestedTagIndex = void 0;
|
|
5705
|
+
if (currentParent.rawTagName === tagName) {
|
|
5706
|
+
currentParent.range[1] = createRange(-1, Math.max(lastTextPos, tagEndPos))[1];
|
|
5707
|
+
stack.pop();
|
|
5708
|
+
currentParent = (0, back_1.default)(stack);
|
|
5709
|
+
break;
|
|
5710
|
+
} else {
|
|
5711
|
+
var parentTagName = currentParent.tagName;
|
|
5712
|
+
if (kElementsClosedByClosing[parentTagName]) {
|
|
5713
|
+
if (kElementsClosedByClosing[parentTagName][tagName]) {
|
|
5714
|
+
stack.pop();
|
|
5715
|
+
currentParent = (0, back_1.default)(stack);
|
|
5716
|
+
continue;
|
|
5828
5717
|
}
|
|
5829
5718
|
}
|
|
5719
|
+
break;
|
|
5830
5720
|
}
|
|
5831
|
-
return elem;
|
|
5832
|
-
}
|
|
5833
|
-
while (el) {
|
|
5834
|
-
mapChild.set(el, old);
|
|
5835
|
-
old = el;
|
|
5836
|
-
el = el.parentNode;
|
|
5837
|
-
}
|
|
5838
|
-
el = this;
|
|
5839
|
-
while (el) {
|
|
5840
|
-
var e2 = (0, css_select_1.selectOne)(selector, el, {
|
|
5841
|
-
xmlMode: true,
|
|
5842
|
-
adapter: __assign(__assign({}, matcher_1.default), { getChildren: function(node2) {
|
|
5843
|
-
var child = mapChild.get(node2);
|
|
5844
|
-
return child && [child];
|
|
5845
|
-
}, getSiblings: function(node2) {
|
|
5846
|
-
return [node2];
|
|
5847
|
-
}, findOne: findOne2, findAll: function() {
|
|
5848
|
-
return [];
|
|
5849
|
-
} })
|
|
5850
|
-
});
|
|
5851
|
-
if (e2) {
|
|
5852
|
-
return e2;
|
|
5853
|
-
}
|
|
5854
|
-
el = el.parentNode;
|
|
5855
5721
|
}
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
};
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
* @return {Node | undefined} last child node; or undefined if none
|
|
5879
|
-
*/
|
|
5880
|
-
get: function() {
|
|
5881
|
-
return (0, back_1.default)(this.childNodes);
|
|
5882
|
-
},
|
|
5883
|
-
enumerable: false,
|
|
5884
|
-
configurable: true
|
|
5885
|
-
});
|
|
5886
|
-
Object.defineProperty(HTMLElement2.prototype, "attrs", {
|
|
5887
|
-
/**
|
|
5888
|
-
* Get attributes
|
|
5889
|
-
* @access private
|
|
5890
|
-
* @return {Object} parsed and unescaped attributes
|
|
5891
|
-
*/
|
|
5892
|
-
get: function() {
|
|
5893
|
-
if (this._attrs) {
|
|
5894
|
-
return this._attrs;
|
|
5895
|
-
}
|
|
5896
|
-
this._attrs = {};
|
|
5897
|
-
var attrs = this.rawAttributes;
|
|
5898
|
-
for (var key in attrs) {
|
|
5899
|
-
var val = attrs[key] || "";
|
|
5900
|
-
this._attrs[key.toLowerCase()] = decode(val);
|
|
5901
|
-
}
|
|
5902
|
-
return this._attrs;
|
|
5903
|
-
},
|
|
5904
|
-
enumerable: false,
|
|
5905
|
-
configurable: true
|
|
5906
|
-
});
|
|
5907
|
-
Object.defineProperty(HTMLElement2.prototype, "attributes", {
|
|
5908
|
-
get: function() {
|
|
5909
|
-
var ret_attrs = {};
|
|
5910
|
-
var attrs = this.rawAttributes;
|
|
5911
|
-
for (var key in attrs) {
|
|
5912
|
-
var val = attrs[key] || "";
|
|
5913
|
-
ret_attrs[key] = decode(val);
|
|
5722
|
+
}
|
|
5723
|
+
}
|
|
5724
|
+
return stack;
|
|
5725
|
+
}
|
|
5726
|
+
html.base_parse = base_parse;
|
|
5727
|
+
function parse$4(data, options) {
|
|
5728
|
+
if (options === void 0) {
|
|
5729
|
+
options = {};
|
|
5730
|
+
}
|
|
5731
|
+
var stack = base_parse(data, options);
|
|
5732
|
+
var root = stack[0];
|
|
5733
|
+
var _loop_1 = function() {
|
|
5734
|
+
var last = stack.pop();
|
|
5735
|
+
var oneBefore = (0, back_1.default)(stack);
|
|
5736
|
+
if (last.parentNode && last.parentNode.parentNode) {
|
|
5737
|
+
if (last.parentNode === oneBefore && last.tagName === oneBefore.tagName) {
|
|
5738
|
+
if (options.parseNoneClosedTags !== true) {
|
|
5739
|
+
oneBefore.removeChild(last);
|
|
5740
|
+
last.childNodes.forEach(function(child) {
|
|
5741
|
+
oneBefore.parentNode.appendChild(child);
|
|
5742
|
+
});
|
|
5743
|
+
stack.pop();
|
|
5914
5744
|
}
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
/**
|
|
5922
|
-
* Get escaped (as-is) attributes
|
|
5923
|
-
* @return {Object} parsed attributes
|
|
5924
|
-
*/
|
|
5925
|
-
get: function() {
|
|
5926
|
-
if (this._rawAttrs) {
|
|
5927
|
-
return this._rawAttrs;
|
|
5745
|
+
} else {
|
|
5746
|
+
if (options.parseNoneClosedTags !== true) {
|
|
5747
|
+
oneBefore.removeChild(last);
|
|
5748
|
+
last.childNodes.forEach(function(child) {
|
|
5749
|
+
oneBefore.appendChild(child);
|
|
5750
|
+
});
|
|
5928
5751
|
}
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5752
|
+
}
|
|
5753
|
+
}
|
|
5754
|
+
};
|
|
5755
|
+
while (stack.length > 1) {
|
|
5756
|
+
_loop_1();
|
|
5757
|
+
}
|
|
5758
|
+
return root;
|
|
5759
|
+
}
|
|
5760
|
+
html.parse = parse$4;
|
|
5761
|
+
function resetParent(nodes, parent) {
|
|
5762
|
+
return nodes.map(function(node2) {
|
|
5763
|
+
node2.parentNode = parent;
|
|
5764
|
+
return node2;
|
|
5765
|
+
});
|
|
5766
|
+
}
|
|
5767
|
+
var parse$3 = {};
|
|
5768
|
+
(function(exports) {
|
|
5769
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5770
|
+
exports.default = void 0;
|
|
5771
|
+
var html_12 = html;
|
|
5772
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function() {
|
|
5773
|
+
return html_12.parse;
|
|
5774
|
+
} });
|
|
5775
|
+
})(parse$3);
|
|
5776
|
+
var valid$1 = {};
|
|
5777
|
+
Object.defineProperty(valid$1, "__esModule", { value: true });
|
|
5778
|
+
var html_1$1 = html;
|
|
5779
|
+
function valid(data, options) {
|
|
5780
|
+
if (options === void 0) {
|
|
5781
|
+
options = {};
|
|
5782
|
+
}
|
|
5783
|
+
var stack = (0, html_1$1.base_parse)(data, options);
|
|
5784
|
+
return Boolean(stack.length === 1);
|
|
5785
|
+
}
|
|
5786
|
+
valid$1.default = valid;
|
|
5787
|
+
var __importDefault$1 = commonjsGlobal && commonjsGlobal.__importDefault || function(mod) {
|
|
5788
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
5789
|
+
};
|
|
5790
|
+
Object.defineProperty(dist, "__esModule", { value: true });
|
|
5791
|
+
var NodeType = dist.NodeType = dist.TextNode = dist.Node = dist.valid = dist.CommentNode = dist.HTMLElement = parse_2 = dist.parse = void 0;
|
|
5792
|
+
var comment_1 = __importDefault$1(comment);
|
|
5793
|
+
dist.CommentNode = comment_1.default;
|
|
5794
|
+
var html_1 = __importDefault$1(html);
|
|
5795
|
+
dist.HTMLElement = html_1.default;
|
|
5796
|
+
var node_1 = __importDefault$1(node$1);
|
|
5797
|
+
dist.Node = node_1.default;
|
|
5798
|
+
var text_1 = __importDefault$1(text);
|
|
5799
|
+
dist.TextNode = text_1.default;
|
|
5800
|
+
var type_1 = __importDefault$1(type$1);
|
|
5801
|
+
NodeType = dist.NodeType = type_1.default;
|
|
5802
|
+
var parse_1 = __importDefault$1(parse$3);
|
|
5803
|
+
var valid_1 = __importDefault$1(valid$1);
|
|
5804
|
+
dist.valid = valid_1.default;
|
|
5805
|
+
function parse$2(data, options) {
|
|
5806
|
+
if (options === void 0) {
|
|
5807
|
+
options = {};
|
|
5808
|
+
}
|
|
5809
|
+
return (0, parse_1.default)(data, options);
|
|
5810
|
+
}
|
|
5811
|
+
dist.default = parse$2;
|
|
5812
|
+
var parse_2 = dist.parse = parse$2;
|
|
5813
|
+
parse$2.parse = parse_1.default;
|
|
5814
|
+
parse$2.HTMLElement = html_1.default;
|
|
5815
|
+
parse$2.CommentNode = comment_1.default;
|
|
5816
|
+
parse$2.valid = valid_1.default;
|
|
5817
|
+
parse$2.Node = node_1.default;
|
|
5818
|
+
parse$2.TextNode = text_1.default;
|
|
5819
|
+
parse$2.NodeType = type_1.default;
|
|
5820
|
+
const COORD_ATTR$1 = "jay-coordinate-base";
|
|
5821
|
+
const SCOPE_ATTR = "jay-scope";
|
|
5822
|
+
function assignCoordinatesToJayHtml(jayHtml, headlessContractNames) {
|
|
5823
|
+
const root = parse_2(jayHtml, {
|
|
5824
|
+
comment: true,
|
|
5825
|
+
blockTextElements: { script: true, style: true }
|
|
5826
|
+
});
|
|
5827
|
+
const body = root.querySelector("body");
|
|
5828
|
+
if (!body)
|
|
5829
|
+
return jayHtml;
|
|
5830
|
+
assignCoordinates(body, { headlessContractNames });
|
|
5831
|
+
return root.toString();
|
|
5832
|
+
}
|
|
5833
|
+
function nextScopeId(counter) {
|
|
5834
|
+
return `S${counter.next++}`;
|
|
5835
|
+
}
|
|
5836
|
+
function assignCoordinates(body, options) {
|
|
5837
|
+
if (!options._refCounters)
|
|
5838
|
+
options._refCounters = /* @__PURE__ */ new Map();
|
|
5839
|
+
const rootChildren = body.childNodes.filter(
|
|
5840
|
+
(n) => n.nodeType === NodeType.ELEMENT_NODE
|
|
5841
|
+
);
|
|
5842
|
+
if (rootChildren.length === 0)
|
|
5843
|
+
return { debugHtml: body.toString() };
|
|
5844
|
+
const counter = { next: 0 };
|
|
5845
|
+
const rootScopeId = nextScopeId(counter);
|
|
5846
|
+
const rootElement = rootChildren[0];
|
|
5847
|
+
const rootCoord = `${rootScopeId}/0`;
|
|
5848
|
+
rootElement.setAttribute(COORD_ATTR$1, rootCoord);
|
|
5849
|
+
walkChildren(rootElement, rootCoord, rootScopeId, options, counter);
|
|
5850
|
+
return { debugHtml: body.toString() };
|
|
5851
|
+
}
|
|
5852
|
+
function walkChildren(parent, parentCoord, scopeId, options, counter) {
|
|
5853
|
+
let childCounter = 0;
|
|
5854
|
+
for (const child of parent.childNodes) {
|
|
5855
|
+
if (child.nodeType !== NodeType.ELEMENT_NODE)
|
|
5856
|
+
continue;
|
|
5857
|
+
const element = child;
|
|
5858
|
+
const tagName = element.tagName?.toLowerCase();
|
|
5859
|
+
if (tagName?.startsWith("jay:")) {
|
|
5860
|
+
const contractName = tagName.substring(4);
|
|
5861
|
+
if (options.headlessContractNames.has(contractName)) {
|
|
5862
|
+
let ref = element.getAttribute("ref");
|
|
5863
|
+
if (!ref) {
|
|
5864
|
+
const idx = options._refCounters.get(contractName) ?? 0;
|
|
5865
|
+
options._refCounters.set(contractName, idx + 1);
|
|
5866
|
+
ref = `AR${idx}`;
|
|
5867
|
+
element.setAttribute("ref", ref);
|
|
5940
5868
|
}
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
if (this._attrs) {
|
|
5952
|
-
delete this._attrs[key];
|
|
5869
|
+
assignHeadlessInstance(
|
|
5870
|
+
element,
|
|
5871
|
+
contractName,
|
|
5872
|
+
ref,
|
|
5873
|
+
parentCoord,
|
|
5874
|
+
scopeId,
|
|
5875
|
+
options,
|
|
5876
|
+
counter
|
|
5877
|
+
);
|
|
5878
|
+
continue;
|
|
5953
5879
|
}
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5880
|
+
}
|
|
5881
|
+
const forEachAttr = element.getAttribute("forEach");
|
|
5882
|
+
if (forEachAttr) {
|
|
5883
|
+
const trackBy = element.getAttribute("trackBy");
|
|
5884
|
+
if (trackBy) {
|
|
5885
|
+
const coord2 = `${parentCoord}/${childCounter}`;
|
|
5886
|
+
element.setAttribute(COORD_ATTR$1, coord2);
|
|
5887
|
+
childCounter++;
|
|
5888
|
+
const itemScopeId = nextScopeId(counter);
|
|
5889
|
+
element.setAttribute(SCOPE_ATTR, itemScopeId);
|
|
5890
|
+
walkForEachChildren(element, itemScopeId, options, counter);
|
|
5891
|
+
continue;
|
|
5962
5892
|
}
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
|
|
5974
|
-
throw new Error("Failed to execute 'setAttribute' on 'Element'");
|
|
5893
|
+
}
|
|
5894
|
+
const slowForEachAttr = element.getAttribute("slowForEach");
|
|
5895
|
+
if (slowForEachAttr) {
|
|
5896
|
+
const jayTrackBy = element.getAttribute("jayTrackBy");
|
|
5897
|
+
if (jayTrackBy) {
|
|
5898
|
+
const itemScopeId = nextScopeId(counter);
|
|
5899
|
+
element.setAttribute(SCOPE_ATTR, itemScopeId);
|
|
5900
|
+
const itemCoord = `${itemScopeId}/0`;
|
|
5901
|
+
element.setAttribute(COORD_ATTR$1, itemCoord);
|
|
5902
|
+
walkChildren(element, itemCoord, itemScopeId, options, counter);
|
|
5903
|
+
continue;
|
|
5975
5904
|
}
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
|
|
5905
|
+
}
|
|
5906
|
+
const coord = `${parentCoord}/${childCounter}`;
|
|
5907
|
+
element.setAttribute(COORD_ATTR$1, coord);
|
|
5908
|
+
childCounter++;
|
|
5909
|
+
walkChildren(element, coord, scopeId, options, counter);
|
|
5910
|
+
}
|
|
5911
|
+
}
|
|
5912
|
+
function assignHeadlessInstance(element, contractName, ref, parentCoord, parentScopeId, options, counter) {
|
|
5913
|
+
const instanceCoord = `${parentCoord}/${contractName}:${ref}`;
|
|
5914
|
+
element.setAttribute(COORD_ATTR$1, instanceCoord);
|
|
5915
|
+
const childScopeId = nextScopeId(counter);
|
|
5916
|
+
element.setAttribute(SCOPE_ATTR, childScopeId);
|
|
5917
|
+
const significantChildren = element.childNodes.filter(
|
|
5918
|
+
(n) => n.nodeType === NodeType.ELEMENT_NODE || n.nodeType === NodeType.TEXT_NODE && (n.innerText || "").trim() !== ""
|
|
5919
|
+
);
|
|
5920
|
+
if (significantChildren.length > 1) {
|
|
5921
|
+
const wrapper = parse_2("<div></div>").querySelector("div");
|
|
5922
|
+
const children = [...element.childNodes];
|
|
5923
|
+
element.innerHTML = "";
|
|
5924
|
+
children.forEach((child) => wrapper.appendChild(child));
|
|
5925
|
+
element.appendChild(wrapper);
|
|
5926
|
+
}
|
|
5927
|
+
walkChildren(element, childScopeId, childScopeId, options, counter);
|
|
5928
|
+
}
|
|
5929
|
+
function walkForEachChildren(parent, itemScopeId, options, counter) {
|
|
5930
|
+
let childCounter = 0;
|
|
5931
|
+
for (const child of parent.childNodes) {
|
|
5932
|
+
if (child.nodeType !== NodeType.ELEMENT_NODE)
|
|
5933
|
+
continue;
|
|
5934
|
+
const element = child;
|
|
5935
|
+
const tagName = element.tagName?.toLowerCase();
|
|
5936
|
+
if (tagName?.startsWith("jay:")) {
|
|
5937
|
+
const contractName = tagName.substring(4);
|
|
5938
|
+
if (options.headlessContractNames.has(contractName)) {
|
|
5939
|
+
let ref = element.getAttribute("ref");
|
|
5940
|
+
if (!ref) {
|
|
5941
|
+
const counterKey = `forEach/${contractName}`;
|
|
5942
|
+
const idx = options._refCounters.get(counterKey) ?? 0;
|
|
5943
|
+
options._refCounters.set(counterKey, idx + 1);
|
|
5944
|
+
ref = `AR${idx}`;
|
|
5945
|
+
element.setAttribute("ref", ref);
|
|
5982
5946
|
}
|
|
5947
|
+
assignHeadlessInstance(
|
|
5948
|
+
element,
|
|
5949
|
+
contractName,
|
|
5950
|
+
ref,
|
|
5951
|
+
itemScopeId,
|
|
5952
|
+
itemScopeId,
|
|
5953
|
+
options,
|
|
5954
|
+
counter
|
|
5955
|
+
);
|
|
5956
|
+
continue;
|
|
5983
5957
|
}
|
|
5984
|
-
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
|
|
5988
|
-
|
|
5989
|
-
|
|
5990
|
-
|
|
5991
|
-
|
|
5992
|
-
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
}
|
|
5997
|
-
return this;
|
|
5998
|
-
};
|
|
5999
|
-
HTMLElement2.prototype.setAttributes = function(attributes2) {
|
|
6000
|
-
var _this = this;
|
|
6001
|
-
if (this._attrs) {
|
|
6002
|
-
delete this._attrs;
|
|
6003
|
-
}
|
|
6004
|
-
if (this._rawAttrs) {
|
|
6005
|
-
delete this._rawAttrs;
|
|
6006
|
-
}
|
|
6007
|
-
this.rawAttrs = Object.keys(attributes2).map(function(name) {
|
|
6008
|
-
var val = attributes2[name];
|
|
6009
|
-
if (val === "null" || val === '""')
|
|
6010
|
-
return name;
|
|
6011
|
-
return "".concat(name, "=").concat(_this.quoteAttribute(String(val)));
|
|
6012
|
-
}).join(" ");
|
|
6013
|
-
return this;
|
|
6014
|
-
};
|
|
6015
|
-
HTMLElement2.prototype.insertAdjacentHTML = function(where, html2) {
|
|
6016
|
-
var _a, _b, _c;
|
|
6017
|
-
var _this = this;
|
|
6018
|
-
if (arguments.length < 2) {
|
|
6019
|
-
throw new Error("2 arguments required");
|
|
5958
|
+
}
|
|
5959
|
+
const forEachAttr = element.getAttribute("forEach");
|
|
5960
|
+
if (forEachAttr) {
|
|
5961
|
+
const trackBy = element.getAttribute("trackBy");
|
|
5962
|
+
if (trackBy) {
|
|
5963
|
+
const coord2 = `${itemScopeId}/${childCounter}`;
|
|
5964
|
+
element.setAttribute(COORD_ATTR$1, coord2);
|
|
5965
|
+
childCounter++;
|
|
5966
|
+
const nestedItemScopeId = nextScopeId(counter);
|
|
5967
|
+
element.setAttribute(SCOPE_ATTR, nestedItemScopeId);
|
|
5968
|
+
walkForEachChildren(element, nestedItemScopeId, options, counter);
|
|
5969
|
+
continue;
|
|
6020
5970
|
}
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
5971
|
+
}
|
|
5972
|
+
const coord = `${itemScopeId}/${childCounter}`;
|
|
5973
|
+
element.setAttribute(COORD_ATTR$1, coord);
|
|
5974
|
+
childCounter++;
|
|
5975
|
+
walkChildren(element, coord, itemScopeId, options, counter);
|
|
5976
|
+
}
|
|
5977
|
+
}
|
|
5978
|
+
var ContractTagType = /* @__PURE__ */ ((ContractTagType2) => {
|
|
5979
|
+
ContractTagType2[ContractTagType2["data"] = 0] = "data";
|
|
5980
|
+
ContractTagType2[ContractTagType2["interactive"] = 1] = "interactive";
|
|
5981
|
+
ContractTagType2[ContractTagType2["variant"] = 2] = "variant";
|
|
5982
|
+
ContractTagType2[ContractTagType2["subContract"] = 3] = "subContract";
|
|
5983
|
+
return ContractTagType2;
|
|
5984
|
+
})(ContractTagType || {});
|
|
5985
|
+
const PHASE_ORDER = {
|
|
5986
|
+
slow: 0,
|
|
5987
|
+
fast: 1,
|
|
5988
|
+
"fast+interactive": 2
|
|
5989
|
+
};
|
|
5990
|
+
const DEFAULT_PHASE = "slow";
|
|
5991
|
+
function getEffectivePhase(tag, parentPhase) {
|
|
5992
|
+
if (tag.type.includes(ContractTagType.interactive)) {
|
|
5993
|
+
return "fast+interactive";
|
|
5994
|
+
}
|
|
5995
|
+
if (tag.phase) {
|
|
5996
|
+
return tag.phase;
|
|
5997
|
+
}
|
|
5998
|
+
if (parentPhase) {
|
|
5999
|
+
return parentPhase;
|
|
6000
|
+
}
|
|
6001
|
+
return DEFAULT_PHASE;
|
|
6002
|
+
}
|
|
6003
|
+
function isPhaseCompatible(childPhase, parentPhase) {
|
|
6004
|
+
return PHASE_ORDER[childPhase] >= PHASE_ORDER[parentPhase];
|
|
6005
|
+
}
|
|
6006
|
+
function isTagInPhase(tag, targetPhase, parentPhase) {
|
|
6007
|
+
if (tag.type.includes(ContractTagType.interactive) && !tag.dataType) {
|
|
6008
|
+
return false;
|
|
6009
|
+
}
|
|
6010
|
+
const effectivePhase = getEffectivePhase(tag, parentPhase);
|
|
6011
|
+
return effectivePhase === targetPhase;
|
|
6012
|
+
}
|
|
6013
|
+
function validateTagPhases(tag, parentPhase, tagPath = "") {
|
|
6014
|
+
const validations = [];
|
|
6015
|
+
const currentPath = tagPath ? `${tagPath}.${tag.tag}` : tag.tag;
|
|
6016
|
+
const effectivePhase = getEffectivePhase(tag, parentPhase);
|
|
6017
|
+
if (parentPhase && !isPhaseCompatible(effectivePhase, parentPhase)) {
|
|
6018
|
+
validations.push(
|
|
6019
|
+
`Tag [${currentPath}] has phase [${effectivePhase}] which is earlier than parent phase [${parentPhase}]. Child phases must be same or later than parent (slow < fast < fast+interactive)`
|
|
6020
|
+
);
|
|
6021
|
+
}
|
|
6022
|
+
if (tag.type.includes(ContractTagType.subContract) && tag.tags) {
|
|
6023
|
+
if (tag.repeated) {
|
|
6024
|
+
tag.tags.forEach((childTag) => {
|
|
6025
|
+
const childValidations = validateTagPhases(childTag, effectivePhase, currentPath);
|
|
6026
|
+
validations.push(...childValidations);
|
|
6027
|
+
});
|
|
6028
|
+
} else {
|
|
6029
|
+
tag.tags.forEach((childTag) => {
|
|
6030
|
+
const childValidations = validateTagPhases(childTag, void 0, currentPath);
|
|
6031
|
+
validations.push(...childValidations);
|
|
6032
|
+
});
|
|
6033
|
+
}
|
|
6034
|
+
}
|
|
6035
|
+
return validations;
|
|
6036
|
+
}
|
|
6037
|
+
function validateContractPhases(contract) {
|
|
6038
|
+
const validations = [];
|
|
6039
|
+
contract.tags.forEach((tag) => {
|
|
6040
|
+
const tagValidations = validateTagPhases(tag);
|
|
6041
|
+
validations.push(...tagValidations);
|
|
6042
|
+
});
|
|
6043
|
+
return validations;
|
|
6044
|
+
}
|
|
6045
|
+
function filterTagsByPhase(tags, targetPhase, parentPhase) {
|
|
6046
|
+
const filteredTags = [];
|
|
6047
|
+
for (const tag of tags) {
|
|
6048
|
+
if (!isTagInPhase(tag, targetPhase, parentPhase)) {
|
|
6049
|
+
continue;
|
|
6050
|
+
}
|
|
6051
|
+
const effectivePhase = getEffectivePhase(tag, parentPhase);
|
|
6052
|
+
if (tag.type.includes(ContractTagType.subContract) && tag.tags) {
|
|
6053
|
+
const filteredNestedTags = filterTagsByPhase(tag.tags, targetPhase, effectivePhase);
|
|
6054
|
+
if (filteredNestedTags.length > 0) {
|
|
6055
|
+
filteredTags.push({
|
|
6056
|
+
...tag,
|
|
6057
|
+
tags: filteredNestedTags
|
|
6038
6058
|
});
|
|
6039
|
-
resetParent(p.childNodes, this.parentNode);
|
|
6040
|
-
(_c = this.parentNode.childNodes).splice.apply(_c, __spreadArray([idx, 0], p.childNodes, false));
|
|
6041
|
-
} else {
|
|
6042
|
-
throw new Error("The value provided ('".concat(where, "') is not one of 'beforebegin', 'afterbegin', 'beforeend', or 'afterend'"));
|
|
6043
6059
|
}
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6060
|
+
} else {
|
|
6061
|
+
filteredTags.push(tag);
|
|
6062
|
+
}
|
|
6063
|
+
}
|
|
6064
|
+
return filteredTags;
|
|
6065
|
+
}
|
|
6066
|
+
function createPhaseContract(contract, targetPhase) {
|
|
6067
|
+
return {
|
|
6068
|
+
...contract,
|
|
6069
|
+
tags: filterTagsByPhase(contract.tags, targetPhase)
|
|
6070
|
+
};
|
|
6071
|
+
}
|
|
6072
|
+
const JAY_CONTRACT_EXTENSION = ".jay-contract";
|
|
6073
|
+
function loadLinkedContract(linkPath, baseContractDir, importResolver) {
|
|
6074
|
+
const linkWithExtension = linkPath.endsWith(JAY_CONTRACT_EXTENSION) ? linkPath : linkPath + JAY_CONTRACT_EXTENSION;
|
|
6075
|
+
try {
|
|
6076
|
+
const absolutePath = importResolver.resolveLink(baseContractDir, linkWithExtension);
|
|
6077
|
+
const contractResult = importResolver.loadContract(absolutePath);
|
|
6078
|
+
return contractResult.val ?? null;
|
|
6079
|
+
} catch {
|
|
6080
|
+
return null;
|
|
6081
|
+
}
|
|
6082
|
+
}
|
|
6083
|
+
function getLinkedContractDir(linkPath, baseContractDir, importResolver) {
|
|
6084
|
+
const linkWithExtension = linkPath.endsWith(JAY_CONTRACT_EXTENSION) ? linkPath : linkPath + JAY_CONTRACT_EXTENSION;
|
|
6085
|
+
try {
|
|
6086
|
+
const absolutePath = importResolver.resolveLink(baseContractDir, linkWithExtension);
|
|
6087
|
+
return path.dirname(absolutePath);
|
|
6088
|
+
} catch {
|
|
6089
|
+
return baseContractDir;
|
|
6090
|
+
}
|
|
6091
|
+
}
|
|
6092
|
+
var __assign = function() {
|
|
6093
|
+
__assign = Object.assign || function __assign2(t) {
|
|
6094
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6095
|
+
s = arguments[i];
|
|
6096
|
+
for (var p in s)
|
|
6097
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6098
|
+
t[p] = s[p];
|
|
6099
|
+
}
|
|
6100
|
+
return t;
|
|
6101
|
+
};
|
|
6102
|
+
return __assign.apply(this, arguments);
|
|
6103
|
+
};
|
|
6104
|
+
typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
6105
|
+
var e2 = new Error(message);
|
|
6106
|
+
return e2.name = "SuppressedError", e2.error = error, e2.suppressed = suppressed, e2;
|
|
6107
|
+
};
|
|
6108
|
+
function lowerCase(str2) {
|
|
6109
|
+
return str2.toLowerCase();
|
|
6110
|
+
}
|
|
6111
|
+
var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
|
|
6112
|
+
var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
|
|
6113
|
+
function noCase(input, options) {
|
|
6114
|
+
if (options === void 0) {
|
|
6115
|
+
options = {};
|
|
6116
|
+
}
|
|
6117
|
+
var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
|
|
6118
|
+
var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
|
|
6119
|
+
var start = 0;
|
|
6120
|
+
var end = result.length;
|
|
6121
|
+
while (result.charAt(start) === "\0")
|
|
6122
|
+
start++;
|
|
6123
|
+
while (result.charAt(end - 1) === "\0")
|
|
6124
|
+
end--;
|
|
6125
|
+
return result.slice(start, end).split("\0").map(transform).join(delimiter);
|
|
6126
|
+
}
|
|
6127
|
+
function replace(input, re, value) {
|
|
6128
|
+
if (re instanceof RegExp)
|
|
6129
|
+
return input.replace(re, value);
|
|
6130
|
+
return re.reduce(function(input2, re2) {
|
|
6131
|
+
return input2.replace(re2, value);
|
|
6132
|
+
}, input);
|
|
6133
|
+
}
|
|
6134
|
+
function pascalCaseTransform(input, index) {
|
|
6135
|
+
var firstChar = input.charAt(0);
|
|
6136
|
+
var lowerChars = input.substr(1).toLowerCase();
|
|
6137
|
+
if (index > 0 && firstChar >= "0" && firstChar <= "9") {
|
|
6138
|
+
return "_" + firstChar + lowerChars;
|
|
6139
|
+
}
|
|
6140
|
+
return "" + firstChar.toUpperCase() + lowerChars;
|
|
6141
|
+
}
|
|
6142
|
+
function pascalCase(input, options) {
|
|
6143
|
+
if (options === void 0) {
|
|
6144
|
+
options = {};
|
|
6145
|
+
}
|
|
6146
|
+
return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options));
|
|
6147
|
+
}
|
|
6148
|
+
function camelCaseTransform(input, index) {
|
|
6149
|
+
if (index === 0)
|
|
6150
|
+
return input.toLowerCase();
|
|
6151
|
+
return pascalCaseTransform(input, index);
|
|
6152
|
+
}
|
|
6153
|
+
function camelCase$1(input, options) {
|
|
6154
|
+
if (options === void 0) {
|
|
6155
|
+
options = {};
|
|
6156
|
+
}
|
|
6157
|
+
return pascalCase(input, __assign({ transform: camelCaseTransform }, options));
|
|
6158
|
+
}
|
|
6159
|
+
function upperCaseFirst(input) {
|
|
6160
|
+
return input.charAt(0).toUpperCase() + input.substr(1);
|
|
6161
|
+
}
|
|
6162
|
+
function capitalCaseTransform(input) {
|
|
6163
|
+
return upperCaseFirst(input.toLowerCase());
|
|
6164
|
+
}
|
|
6165
|
+
function capitalCase(input, options) {
|
|
6166
|
+
if (options === void 0) {
|
|
6167
|
+
options = {};
|
|
6168
|
+
}
|
|
6169
|
+
return noCase(input, __assign({ delimiter: " ", transform: capitalCaseTransform }, options));
|
|
6170
|
+
}
|
|
6171
|
+
function camelCase(str2) {
|
|
6172
|
+
let leadingUnderscores = 0;
|
|
6173
|
+
for (const char of str2) {
|
|
6174
|
+
if (char === "_") {
|
|
6175
|
+
leadingUnderscores++;
|
|
6176
|
+
} else {
|
|
6177
|
+
break;
|
|
6178
|
+
}
|
|
6179
|
+
}
|
|
6180
|
+
if (leadingUnderscores === 0) {
|
|
6181
|
+
return camelCase$1(str2);
|
|
6182
|
+
}
|
|
6183
|
+
const withoutLeadingUnderscores = str2.slice(leadingUnderscores);
|
|
6184
|
+
const camelCased = camelCase$1(withoutLeadingUnderscores);
|
|
6185
|
+
return "_".repeat(leadingUnderscores) + camelCased;
|
|
6186
|
+
}
|
|
6187
|
+
function shouldIncludeInPhase(propertyPhase, targetPhase) {
|
|
6188
|
+
if (targetPhase === "slow") {
|
|
6189
|
+
return propertyPhase === "slow";
|
|
6190
|
+
} else if (targetPhase === "fast") {
|
|
6191
|
+
return propertyPhase === "fast" || propertyPhase === "fast+interactive";
|
|
6192
|
+
} else if (targetPhase === "fast+interactive") {
|
|
6193
|
+
return propertyPhase === "fast+interactive";
|
|
6194
|
+
}
|
|
6195
|
+
return false;
|
|
6196
|
+
}
|
|
6197
|
+
function extractPropertyPathsAndArrays(tags, targetPhase, parentPath = [], parentPhase, parentTrackBy, linkedContext) {
|
|
6198
|
+
const paths = [];
|
|
6199
|
+
const arrays = [];
|
|
6200
|
+
const asyncProps = [];
|
|
6201
|
+
for (const tag of tags) {
|
|
6202
|
+
if (tag.type.includes(ContractTagType.interactive) && !tag.dataType) {
|
|
6203
|
+
continue;
|
|
6204
|
+
}
|
|
6205
|
+
const effectivePhase = getEffectivePhase(tag, parentPhase);
|
|
6206
|
+
const propertyName = camelCase(tag.tag);
|
|
6207
|
+
const currentPath = [...parentPath, propertyName];
|
|
6208
|
+
const isArray = tag.repeated || false;
|
|
6209
|
+
const isAsync = tag.async || false;
|
|
6210
|
+
if (tag.type.includes(ContractTagType.subContract)) {
|
|
6211
|
+
const isRecursiveLink2 = tag.link?.startsWith("$/");
|
|
6212
|
+
if (isRecursiveLink2) {
|
|
6213
|
+
if (shouldIncludeInPhase(effectivePhase, targetPhase)) {
|
|
6214
|
+
paths.push({
|
|
6215
|
+
path: parentPath,
|
|
6216
|
+
propertyName
|
|
6217
|
+
});
|
|
6218
|
+
if (isArray) {
|
|
6219
|
+
arrays.push({ path: currentPath.join(".") });
|
|
6055
6220
|
}
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
},
|
|
6059
|
-
enumerable: false,
|
|
6060
|
-
configurable: true
|
|
6061
|
-
});
|
|
6062
|
-
Object.defineProperty(HTMLElement2.prototype, "nextElementSibling", {
|
|
6063
|
-
get: function() {
|
|
6064
|
-
if (this.parentNode) {
|
|
6065
|
-
var children = this.parentNode.childNodes;
|
|
6066
|
-
var i = 0;
|
|
6067
|
-
var find2 = false;
|
|
6068
|
-
while (i < children.length) {
|
|
6069
|
-
var child = children[i++];
|
|
6070
|
-
if (find2) {
|
|
6071
|
-
if (child instanceof HTMLElement2) {
|
|
6072
|
-
return child || null;
|
|
6073
|
-
}
|
|
6074
|
-
} else if (this === child) {
|
|
6075
|
-
find2 = true;
|
|
6076
|
-
}
|
|
6221
|
+
if (isAsync) {
|
|
6222
|
+
asyncProps.push({ path: currentPath.join(".") });
|
|
6077
6223
|
}
|
|
6078
|
-
return null;
|
|
6079
6224
|
}
|
|
6080
|
-
}
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6225
|
+
} else {
|
|
6226
|
+
let childTags = [];
|
|
6227
|
+
let childLinkedContext = linkedContext;
|
|
6228
|
+
if (tag.tags) {
|
|
6229
|
+
childTags = tag.tags;
|
|
6230
|
+
} else if (tag.link && linkedContext) {
|
|
6231
|
+
const linkedContract = loadLinkedContract(
|
|
6232
|
+
tag.link,
|
|
6233
|
+
linkedContext.contractDir,
|
|
6234
|
+
linkedContext.importResolver
|
|
6235
|
+
);
|
|
6236
|
+
if (linkedContract) {
|
|
6237
|
+
childTags = linkedContract.tags;
|
|
6238
|
+
childLinkedContext = {
|
|
6239
|
+
importResolver: linkedContext.importResolver,
|
|
6240
|
+
contractDir: getLinkedContractDir(
|
|
6241
|
+
tag.link,
|
|
6242
|
+
linkedContext.contractDir,
|
|
6243
|
+
linkedContext.importResolver
|
|
6244
|
+
)
|
|
6245
|
+
};
|
|
6093
6246
|
}
|
|
6094
|
-
return null;
|
|
6095
6247
|
}
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6248
|
+
if (childTags.length > 0) {
|
|
6249
|
+
const trackByForChildren = isArray ? tag.trackBy : void 0;
|
|
6250
|
+
const result = extractPropertyPathsAndArrays(
|
|
6251
|
+
childTags,
|
|
6252
|
+
targetPhase,
|
|
6253
|
+
currentPath,
|
|
6254
|
+
effectivePhase,
|
|
6255
|
+
trackByForChildren,
|
|
6256
|
+
childLinkedContext
|
|
6257
|
+
);
|
|
6258
|
+
const hasOnlyTrackBy = isArray && trackByForChildren && result.paths.length === 1 && result.paths[0].propertyName === camelCase(trackByForChildren);
|
|
6259
|
+
if (result.paths.length > 0 && !hasOnlyTrackBy) {
|
|
6260
|
+
paths.push(...result.paths);
|
|
6261
|
+
arrays.push(...result.arrays);
|
|
6262
|
+
asyncProps.push(...result.asyncProps);
|
|
6263
|
+
if (isArray) {
|
|
6264
|
+
arrays.push({ path: currentPath.join(".") });
|
|
6265
|
+
}
|
|
6266
|
+
if (isAsync) {
|
|
6267
|
+
asyncProps.push({ path: currentPath.join(".") });
|
|
6114
6268
|
}
|
|
6115
6269
|
}
|
|
6116
|
-
return null;
|
|
6117
6270
|
}
|
|
6118
|
-
},
|
|
6119
|
-
enumerable: false,
|
|
6120
|
-
configurable: true
|
|
6121
|
-
});
|
|
6122
|
-
Object.defineProperty(HTMLElement2.prototype, "classNames", {
|
|
6123
|
-
get: function() {
|
|
6124
|
-
return this.classList.toString();
|
|
6125
|
-
},
|
|
6126
|
-
enumerable: false,
|
|
6127
|
-
configurable: true
|
|
6128
|
-
});
|
|
6129
|
-
HTMLElement2.prototype.clone = function() {
|
|
6130
|
-
return parse$4(this.toString(), this._parseOptions).firstChild;
|
|
6131
|
-
};
|
|
6132
|
-
return HTMLElement2;
|
|
6133
|
-
}(node_1$1.default)
|
|
6134
|
-
);
|
|
6135
|
-
html.default = HTMLElement;
|
|
6136
|
-
var kMarkupPattern = /<!--[\s\S]*?-->|<(\/?)([a-zA-Z][-.:0-9_a-zA-Z]*)((?:\s+[^>]*?(?:(?:'[^']*')|(?:"[^"]*"))?)*)\s*(\/?)>/g;
|
|
6137
|
-
var kAttributePattern = /(?:^|\s)(id|class)\s*=\s*((?:'[^']*')|(?:"[^"]*")|\S+)/gi;
|
|
6138
|
-
var kElementsClosedByOpening = {
|
|
6139
|
-
li: { li: true, LI: true },
|
|
6140
|
-
LI: { li: true, LI: true },
|
|
6141
|
-
p: { p: true, div: true, P: true, DIV: true },
|
|
6142
|
-
P: { p: true, div: true, P: true, DIV: true },
|
|
6143
|
-
b: { div: true, DIV: true },
|
|
6144
|
-
B: { div: true, DIV: true },
|
|
6145
|
-
td: { td: true, th: true, TD: true, TH: true },
|
|
6146
|
-
TD: { td: true, th: true, TD: true, TH: true },
|
|
6147
|
-
th: { td: true, th: true, TD: true, TH: true },
|
|
6148
|
-
TH: { td: true, th: true, TD: true, TH: true },
|
|
6149
|
-
h1: { h1: true, H1: true },
|
|
6150
|
-
H1: { h1: true, H1: true },
|
|
6151
|
-
h2: { h2: true, H2: true },
|
|
6152
|
-
H2: { h2: true, H2: true },
|
|
6153
|
-
h3: { h3: true, H3: true },
|
|
6154
|
-
H3: { h3: true, H3: true },
|
|
6155
|
-
h4: { h4: true, H4: true },
|
|
6156
|
-
H4: { h4: true, H4: true },
|
|
6157
|
-
h5: { h5: true, H5: true },
|
|
6158
|
-
H5: { h5: true, H5: true },
|
|
6159
|
-
h6: { h6: true, H6: true },
|
|
6160
|
-
H6: { h6: true, H6: true }
|
|
6161
|
-
};
|
|
6162
|
-
var kElementsClosedByClosing = {
|
|
6163
|
-
li: { ul: true, ol: true, UL: true, OL: true },
|
|
6164
|
-
LI: { ul: true, ol: true, UL: true, OL: true },
|
|
6165
|
-
a: { div: true, DIV: true },
|
|
6166
|
-
A: { div: true, DIV: true },
|
|
6167
|
-
b: { div: true, DIV: true },
|
|
6168
|
-
B: { div: true, DIV: true },
|
|
6169
|
-
i: { div: true, DIV: true },
|
|
6170
|
-
I: { div: true, DIV: true },
|
|
6171
|
-
p: { div: true, DIV: true },
|
|
6172
|
-
P: { div: true, DIV: true },
|
|
6173
|
-
td: { tr: true, table: true, TR: true, TABLE: true },
|
|
6174
|
-
TD: { tr: true, table: true, TR: true, TABLE: true },
|
|
6175
|
-
th: { tr: true, table: true, TR: true, TABLE: true },
|
|
6176
|
-
TH: { tr: true, table: true, TR: true, TABLE: true }
|
|
6177
|
-
};
|
|
6178
|
-
var frameflag = "documentfragmentcontainer";
|
|
6179
|
-
function base_parse(data, options) {
|
|
6180
|
-
var _a, _b;
|
|
6181
|
-
if (options === void 0) {
|
|
6182
|
-
options = {};
|
|
6183
|
-
}
|
|
6184
|
-
var voidTag2 = new void_tag_1.default((_a = options === null || options === void 0 ? void 0 : options.voidTag) === null || _a === void 0 ? void 0 : _a.closingSlash, (_b = options === null || options === void 0 ? void 0 : options.voidTag) === null || _b === void 0 ? void 0 : _b.tags);
|
|
6185
|
-
var elements = options.blockTextElements || {
|
|
6186
|
-
script: true,
|
|
6187
|
-
noscript: true,
|
|
6188
|
-
style: true,
|
|
6189
|
-
pre: true
|
|
6190
|
-
};
|
|
6191
|
-
var element_names = Object.keys(elements);
|
|
6192
|
-
var kBlockTextElements = element_names.map(function(it) {
|
|
6193
|
-
return new RegExp("^".concat(it, "$"), "i");
|
|
6194
|
-
});
|
|
6195
|
-
var kIgnoreElements = element_names.filter(function(it) {
|
|
6196
|
-
return Boolean(elements[it]);
|
|
6197
|
-
}).map(function(it) {
|
|
6198
|
-
return new RegExp("^".concat(it, "$"), "i");
|
|
6199
|
-
});
|
|
6200
|
-
function element_should_be_ignore(tag) {
|
|
6201
|
-
return kIgnoreElements.some(function(it) {
|
|
6202
|
-
return it.test(tag);
|
|
6203
|
-
});
|
|
6204
|
-
}
|
|
6205
|
-
function is_block_text_element(tag) {
|
|
6206
|
-
return kBlockTextElements.some(function(it) {
|
|
6207
|
-
return it.test(tag);
|
|
6208
|
-
});
|
|
6209
|
-
}
|
|
6210
|
-
var createRange = function(startPos, endPos) {
|
|
6211
|
-
return [startPos - frameFlagOffset, endPos - frameFlagOffset];
|
|
6212
|
-
};
|
|
6213
|
-
var root = new HTMLElement(null, {}, "", null, [0, data.length], voidTag2, options);
|
|
6214
|
-
var currentParent = root;
|
|
6215
|
-
var stack = [root];
|
|
6216
|
-
var lastTextPos = -1;
|
|
6217
|
-
var noNestedTagIndex = void 0;
|
|
6218
|
-
var match;
|
|
6219
|
-
data = "<".concat(frameflag, ">").concat(data, "</").concat(frameflag, ">");
|
|
6220
|
-
var lowerCaseTagName = options.lowerCaseTagName, fixNestedATags = options.fixNestedATags;
|
|
6221
|
-
var dataEndPos = data.length - (frameflag.length + 2);
|
|
6222
|
-
var frameFlagOffset = frameflag.length + 2;
|
|
6223
|
-
while (match = kMarkupPattern.exec(data)) {
|
|
6224
|
-
var matchText = match[0], leadingSlash = match[1], tagName = match[2], attributes2 = match[3], closingSlash = match[4];
|
|
6225
|
-
var matchLength = matchText.length;
|
|
6226
|
-
var tagStartPos = kMarkupPattern.lastIndex - matchLength;
|
|
6227
|
-
var tagEndPos = kMarkupPattern.lastIndex;
|
|
6228
|
-
if (lastTextPos > -1) {
|
|
6229
|
-
if (lastTextPos + matchLength < tagEndPos) {
|
|
6230
|
-
var text2 = data.substring(lastTextPos, tagStartPos);
|
|
6231
|
-
currentParent.appendChild(new text_1$1.default(text2, currentParent, createRange(lastTextPos, tagStartPos)));
|
|
6232
6271
|
}
|
|
6233
|
-
}
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
currentParent.appendChild(new comment_1$1.default(text2, currentParent, createRange(tagStartPos, tagEndPos)));
|
|
6272
|
+
} else {
|
|
6273
|
+
const isTrackByField = parentTrackBy === tag.tag;
|
|
6274
|
+
if (shouldIncludeInPhase(effectivePhase, targetPhase) || isTrackByField) {
|
|
6275
|
+
paths.push({
|
|
6276
|
+
path: parentPath,
|
|
6277
|
+
propertyName
|
|
6278
|
+
});
|
|
6241
6279
|
}
|
|
6280
|
+
}
|
|
6281
|
+
}
|
|
6282
|
+
return { paths, arrays, asyncProps };
|
|
6283
|
+
}
|
|
6284
|
+
function groupPathsByParent(paths) {
|
|
6285
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
6286
|
+
for (const { path: path2, propertyName } of paths) {
|
|
6287
|
+
const parentKey = path2.join(".");
|
|
6288
|
+
if (!grouped.has(parentKey)) {
|
|
6289
|
+
grouped.set(parentKey, []);
|
|
6290
|
+
}
|
|
6291
|
+
grouped.get(parentKey).push(propertyName);
|
|
6292
|
+
}
|
|
6293
|
+
return grouped;
|
|
6294
|
+
}
|
|
6295
|
+
function countTotalProperties(tags, targetPath, currentPath = [], linkedContext) {
|
|
6296
|
+
let count = 0;
|
|
6297
|
+
for (const tag of tags) {
|
|
6298
|
+
if (tag.type.includes(ContractTagType.interactive) && !tag.dataType) {
|
|
6242
6299
|
continue;
|
|
6243
6300
|
}
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
}
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6301
|
+
const propertyName = camelCase(tag.tag);
|
|
6302
|
+
const newPath = [...currentPath, propertyName];
|
|
6303
|
+
const pathKey = newPath.join(".");
|
|
6304
|
+
const targetKey = targetPath.join(".");
|
|
6305
|
+
if (pathKey === targetKey && tag.type.includes(ContractTagType.subContract)) {
|
|
6306
|
+
let childTags = [];
|
|
6307
|
+
if (tag.tags) {
|
|
6308
|
+
childTags = tag.tags;
|
|
6309
|
+
} else if (tag.link && linkedContext && !tag.link.startsWith("$/")) {
|
|
6310
|
+
const linkedContract = loadLinkedContract(
|
|
6311
|
+
tag.link,
|
|
6312
|
+
linkedContext.contractDir,
|
|
6313
|
+
linkedContext.importResolver
|
|
6314
|
+
);
|
|
6315
|
+
if (linkedContract) {
|
|
6316
|
+
childTags = linkedContract.tags;
|
|
6258
6317
|
}
|
|
6259
6318
|
}
|
|
6260
|
-
|
|
6261
|
-
if (
|
|
6262
|
-
|
|
6263
|
-
currentParent = (0, back_1.default)(stack);
|
|
6319
|
+
for (const childTag of childTags) {
|
|
6320
|
+
if (childTag.type.includes(ContractTagType.interactive) && !childTag.dataType) {
|
|
6321
|
+
continue;
|
|
6264
6322
|
}
|
|
6265
|
-
|
|
6323
|
+
count++;
|
|
6266
6324
|
}
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
)
|
|
6273
|
-
|
|
6274
|
-
if (
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6325
|
+
return count;
|
|
6326
|
+
}
|
|
6327
|
+
if (tag.type.includes(ContractTagType.subContract)) {
|
|
6328
|
+
let childTags = [];
|
|
6329
|
+
let childLinkedContext = linkedContext;
|
|
6330
|
+
if (tag.tags) {
|
|
6331
|
+
childTags = tag.tags;
|
|
6332
|
+
} else if (tag.link && linkedContext && !tag.link.startsWith("$/")) {
|
|
6333
|
+
const linkedContract = loadLinkedContract(
|
|
6334
|
+
tag.link,
|
|
6335
|
+
linkedContext.contractDir,
|
|
6336
|
+
linkedContext.importResolver
|
|
6337
|
+
);
|
|
6338
|
+
if (linkedContract) {
|
|
6339
|
+
childTags = linkedContract.tags;
|
|
6340
|
+
childLinkedContext = {
|
|
6341
|
+
importResolver: linkedContext.importResolver,
|
|
6342
|
+
contractDir: getLinkedContractDir(
|
|
6343
|
+
tag.link,
|
|
6344
|
+
linkedContext.contractDir,
|
|
6345
|
+
linkedContext.importResolver
|
|
6346
|
+
)
|
|
6347
|
+
};
|
|
6283
6348
|
}
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6349
|
+
}
|
|
6350
|
+
if (childTags.length > 0) {
|
|
6351
|
+
const result = countTotalProperties(
|
|
6352
|
+
childTags,
|
|
6353
|
+
targetPath,
|
|
6354
|
+
newPath,
|
|
6355
|
+
childLinkedContext
|
|
6356
|
+
);
|
|
6357
|
+
if (result > 0) {
|
|
6358
|
+
return result;
|
|
6289
6359
|
}
|
|
6290
6360
|
}
|
|
6291
6361
|
}
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6362
|
+
}
|
|
6363
|
+
return count;
|
|
6364
|
+
}
|
|
6365
|
+
function buildPathAccess(baseTypeName, path2, arrays, asyncProps, skipFinalArrayAccess = false) {
|
|
6366
|
+
if (path2.length === 0) {
|
|
6367
|
+
return baseTypeName;
|
|
6368
|
+
}
|
|
6369
|
+
let result = baseTypeName;
|
|
6370
|
+
for (let i = 0; i < path2.length; i++) {
|
|
6371
|
+
const segment = path2[i];
|
|
6372
|
+
result += `['${segment}']`;
|
|
6373
|
+
const pathUpToHere = path2.slice(0, i + 1).join(".");
|
|
6374
|
+
const isArray = arrays.has(pathUpToHere);
|
|
6375
|
+
const isAsync = asyncProps?.has(pathUpToHere);
|
|
6376
|
+
const isFinalSegment = i === path2.length - 1;
|
|
6377
|
+
const shouldSkip = isFinalSegment && (skipFinalArrayAccess || isArray && isAsync);
|
|
6378
|
+
if (isArray && !shouldSkip) {
|
|
6379
|
+
result += "[number]";
|
|
6380
|
+
}
|
|
6381
|
+
}
|
|
6382
|
+
return result;
|
|
6383
|
+
}
|
|
6384
|
+
function isFullyIncluded(pathGroups, contractTags, currentPath, linkedContext) {
|
|
6385
|
+
const currentKey = currentPath.join(".");
|
|
6386
|
+
const properties = pathGroups.get(currentKey) || [];
|
|
6387
|
+
const totalProps = countTotalProperties(contractTags, currentPath, [], linkedContext);
|
|
6388
|
+
if (totalProps === 0) {
|
|
6389
|
+
return false;
|
|
6390
|
+
}
|
|
6391
|
+
const childPropertyNames = /* @__PURE__ */ new Set();
|
|
6392
|
+
const prefix = currentKey ? currentKey + "." : "";
|
|
6393
|
+
for (const key of pathGroups.keys()) {
|
|
6394
|
+
if (key.startsWith(prefix) && key !== currentKey) {
|
|
6395
|
+
const remainingPath = key.slice(prefix.length);
|
|
6396
|
+
const firstSegment = remainingPath.split(".")[0];
|
|
6397
|
+
if (firstSegment) {
|
|
6398
|
+
childPropertyNames.add(firstSegment);
|
|
6312
6399
|
}
|
|
6313
6400
|
}
|
|
6314
6401
|
}
|
|
6315
|
-
|
|
6402
|
+
const directProps = properties.filter((p) => !childPropertyNames.has(p));
|
|
6403
|
+
if (directProps.length + childPropertyNames.size !== totalProps) {
|
|
6404
|
+
return false;
|
|
6405
|
+
}
|
|
6406
|
+
for (const childName of childPropertyNames) {
|
|
6407
|
+
const childPath = [...currentPath, childName];
|
|
6408
|
+
if (!isFullyIncluded(pathGroups, contractTags, childPath, linkedContext)) {
|
|
6409
|
+
return false;
|
|
6410
|
+
}
|
|
6411
|
+
}
|
|
6412
|
+
return true;
|
|
6316
6413
|
}
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6414
|
+
function buildPickExpression(baseTypeName, pathGroups, arrays, asyncProps, contractTags, currentPath = [], linkedContext) {
|
|
6415
|
+
const currentKey = currentPath.join(".");
|
|
6416
|
+
const properties = pathGroups.get(currentKey) || [];
|
|
6417
|
+
const childPropertyNames = /* @__PURE__ */ new Set();
|
|
6418
|
+
for (const key of pathGroups.keys()) {
|
|
6419
|
+
const prefix = currentKey ? currentKey + "." : "";
|
|
6420
|
+
if (key.startsWith(prefix) && key !== currentKey) {
|
|
6421
|
+
const remainingPath = key.slice(prefix.length);
|
|
6422
|
+
const firstSegment = remainingPath.split(".")[0];
|
|
6423
|
+
if (firstSegment) {
|
|
6424
|
+
childPropertyNames.add(firstSegment);
|
|
6425
|
+
}
|
|
6426
|
+
}
|
|
6321
6427
|
}
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6428
|
+
const pickPart = [];
|
|
6429
|
+
const nestedProperties = [];
|
|
6430
|
+
const directProps = properties.filter((p) => !childPropertyNames.has(p));
|
|
6431
|
+
if (directProps.length > 0) {
|
|
6432
|
+
const pathAccess = buildPathAccess(baseTypeName, currentPath, arrays, asyncProps);
|
|
6433
|
+
pickPart.push(`Pick<${pathAccess}, ${directProps.map((p) => `'${p}'`).join(" | ")}>`);
|
|
6434
|
+
}
|
|
6435
|
+
for (const childName of childPropertyNames) {
|
|
6436
|
+
const childPath = [...currentPath, childName];
|
|
6437
|
+
const childPathKey = childPath.join(".");
|
|
6438
|
+
const isArray = arrays.has(childPathKey);
|
|
6439
|
+
const isAsync = asyncProps.has(childPathKey);
|
|
6440
|
+
const isChildFullyIncluded = isFullyIncluded(
|
|
6441
|
+
pathGroups,
|
|
6442
|
+
contractTags,
|
|
6443
|
+
childPath,
|
|
6444
|
+
linkedContext
|
|
6445
|
+
);
|
|
6446
|
+
const originalPathAccess = buildPathAccess(baseTypeName, childPath, arrays, asyncProps);
|
|
6447
|
+
if (isChildFullyIncluded) {
|
|
6448
|
+
let fullExpression;
|
|
6449
|
+
const directTypeRef = originalPathAccess;
|
|
6450
|
+
if (isAsync) {
|
|
6451
|
+
if (isArray) {
|
|
6452
|
+
fullExpression = `Promise<Array<Awaited<${directTypeRef}>[number]>>`;
|
|
6453
|
+
} else {
|
|
6454
|
+
fullExpression = directTypeRef;
|
|
6335
6455
|
}
|
|
6456
|
+
} else if (isArray) {
|
|
6457
|
+
fullExpression = `Array<${directTypeRef}>`;
|
|
6336
6458
|
} else {
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6459
|
+
fullExpression = directTypeRef;
|
|
6460
|
+
}
|
|
6461
|
+
nestedProperties.push(` ${childName}: ${fullExpression};`);
|
|
6462
|
+
} else {
|
|
6463
|
+
const childExpression = buildPickExpression(
|
|
6464
|
+
baseTypeName,
|
|
6465
|
+
pathGroups,
|
|
6466
|
+
arrays,
|
|
6467
|
+
asyncProps,
|
|
6468
|
+
contractTags,
|
|
6469
|
+
childPath,
|
|
6470
|
+
linkedContext
|
|
6471
|
+
);
|
|
6472
|
+
if (childExpression) {
|
|
6473
|
+
let fullExpression;
|
|
6474
|
+
if (isAsync) {
|
|
6475
|
+
if (isArray) {
|
|
6476
|
+
const unwrappedArrayAccess = `Awaited<${originalPathAccess}>[number]`;
|
|
6477
|
+
const unwrappedExpression = childExpression.replace(
|
|
6478
|
+
originalPathAccess,
|
|
6479
|
+
unwrappedArrayAccess
|
|
6480
|
+
);
|
|
6481
|
+
fullExpression = `Promise<Array<${unwrappedExpression}>>`;
|
|
6482
|
+
} else {
|
|
6483
|
+
const unwrappedAccess = `Awaited<${originalPathAccess}>`;
|
|
6484
|
+
const unwrappedExpression = childExpression.replace(
|
|
6485
|
+
originalPathAccess,
|
|
6486
|
+
unwrappedAccess
|
|
6487
|
+
);
|
|
6488
|
+
fullExpression = `Promise<${unwrappedExpression}>`;
|
|
6489
|
+
}
|
|
6490
|
+
} else if (isArray) {
|
|
6491
|
+
fullExpression = `Array<${childExpression}>`;
|
|
6492
|
+
} else {
|
|
6493
|
+
fullExpression = childExpression;
|
|
6342
6494
|
}
|
|
6495
|
+
nestedProperties.push(` ${childName}: ${fullExpression};`);
|
|
6343
6496
|
}
|
|
6344
6497
|
}
|
|
6345
|
-
};
|
|
6346
|
-
while (stack.length > 1) {
|
|
6347
|
-
_loop_1();
|
|
6348
6498
|
}
|
|
6349
|
-
|
|
6350
|
-
}
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
}
|
|
6358
|
-
|
|
6359
|
-
(
|
|
6360
|
-
|
|
6361
|
-
exports.default = void 0;
|
|
6362
|
-
var html_12 = html;
|
|
6363
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function() {
|
|
6364
|
-
return html_12.parse;
|
|
6365
|
-
} });
|
|
6366
|
-
})(parse$3);
|
|
6367
|
-
var valid$1 = {};
|
|
6368
|
-
Object.defineProperty(valid$1, "__esModule", { value: true });
|
|
6369
|
-
var html_1$1 = html;
|
|
6370
|
-
function valid(data, options) {
|
|
6371
|
-
if (options === void 0) {
|
|
6372
|
-
options = {};
|
|
6499
|
+
if (pickPart.length === 0 && nestedProperties.length === 0) {
|
|
6500
|
+
return "{}";
|
|
6501
|
+
} else if (pickPart.length === 0) {
|
|
6502
|
+
return `{
|
|
6503
|
+
${nestedProperties.join("\n")}
|
|
6504
|
+
}`;
|
|
6505
|
+
} else if (nestedProperties.length === 0) {
|
|
6506
|
+
return pickPart[0];
|
|
6507
|
+
} else {
|
|
6508
|
+
return `${pickPart[0]} & {
|
|
6509
|
+
${nestedProperties.join("\n")}
|
|
6510
|
+
}`;
|
|
6373
6511
|
}
|
|
6374
|
-
var stack = (0, html_1$1.base_parse)(data, options);
|
|
6375
|
-
return Boolean(stack.length === 1);
|
|
6376
6512
|
}
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
var valid_1 = __importDefault$1(valid$1);
|
|
6395
|
-
dist.valid = valid_1.default;
|
|
6396
|
-
function parse$2(data, options) {
|
|
6397
|
-
if (options === void 0) {
|
|
6398
|
-
options = {};
|
|
6513
|
+
function generatePhaseViewStateType(contract, phase, baseTypeName, importResolver, contractPath) {
|
|
6514
|
+
const phaseName = phase === "fast+interactive" ? "Interactive" : pascalCase(phase);
|
|
6515
|
+
const typeName = `${pascalCase(contract.name)}${phaseName}ViewState`;
|
|
6516
|
+
const linkedContext = importResolver && contractPath ? {
|
|
6517
|
+
importResolver,
|
|
6518
|
+
contractDir: contractPath.includes("/") ? contractPath.substring(0, contractPath.lastIndexOf("/")) : "."
|
|
6519
|
+
} : void 0;
|
|
6520
|
+
const { paths, arrays, asyncProps } = extractPropertyPathsAndArrays(
|
|
6521
|
+
contract.tags,
|
|
6522
|
+
phase,
|
|
6523
|
+
[],
|
|
6524
|
+
void 0,
|
|
6525
|
+
void 0,
|
|
6526
|
+
linkedContext
|
|
6527
|
+
);
|
|
6528
|
+
if (paths.length === 0) {
|
|
6529
|
+
return `export type ${typeName} = {};`;
|
|
6399
6530
|
}
|
|
6400
|
-
|
|
6531
|
+
const pathGroups = groupPathsByParent(paths);
|
|
6532
|
+
const arraySet = new Set(arrays.map((a) => a.path));
|
|
6533
|
+
const asyncSet = new Set(asyncProps.map((a) => a.path));
|
|
6534
|
+
const pickExpression = buildPickExpression(
|
|
6535
|
+
baseTypeName,
|
|
6536
|
+
pathGroups,
|
|
6537
|
+
arraySet,
|
|
6538
|
+
asyncSet,
|
|
6539
|
+
contract.tags,
|
|
6540
|
+
[],
|
|
6541
|
+
linkedContext
|
|
6542
|
+
);
|
|
6543
|
+
return `export type ${typeName} = ${pickExpression};`;
|
|
6544
|
+
}
|
|
6545
|
+
function generateAllPhaseViewStateTypes(contract, baseTypeName, importResolver, contractPath) {
|
|
6546
|
+
const slowType = generatePhaseViewStateType(
|
|
6547
|
+
contract,
|
|
6548
|
+
"slow",
|
|
6549
|
+
baseTypeName,
|
|
6550
|
+
importResolver,
|
|
6551
|
+
contractPath
|
|
6552
|
+
);
|
|
6553
|
+
const fastType = generatePhaseViewStateType(
|
|
6554
|
+
contract,
|
|
6555
|
+
"fast",
|
|
6556
|
+
baseTypeName,
|
|
6557
|
+
importResolver,
|
|
6558
|
+
contractPath
|
|
6559
|
+
);
|
|
6560
|
+
const interactiveType = generatePhaseViewStateType(
|
|
6561
|
+
contract,
|
|
6562
|
+
"fast+interactive",
|
|
6563
|
+
baseTypeName,
|
|
6564
|
+
importResolver,
|
|
6565
|
+
contractPath
|
|
6566
|
+
);
|
|
6567
|
+
return [slowType, fastType, interactiveType].join("\n\n");
|
|
6401
6568
|
}
|
|
6402
|
-
dist.default = parse$2;
|
|
6403
|
-
var parse_2 = dist.parse = parse$2;
|
|
6404
|
-
parse$2.parse = parse_1.default;
|
|
6405
|
-
parse$2.HTMLElement = html_1.default;
|
|
6406
|
-
parse$2.CommentNode = comment_1.default;
|
|
6407
|
-
parse$2.valid = valid_1.default;
|
|
6408
|
-
parse$2.Node = node_1.default;
|
|
6409
|
-
parse$2.TextNode = text_1.default;
|
|
6410
|
-
parse$2.NodeType = type_1.default;
|
|
6411
6569
|
function peg$subclass(child, parent) {
|
|
6412
6570
|
function ctor() {
|
|
6413
6571
|
this.constructor = child;
|
|
@@ -13345,7 +13503,7 @@ function extractComponentName(tagName) {
|
|
|
13345
13503
|
function getComponentName(tagName, importedSymbols, headlessContractNames) {
|
|
13346
13504
|
if (hasJayPrefix(tagName)) {
|
|
13347
13505
|
const componentName = extractComponentName(tagName);
|
|
13348
|
-
if (headlessContractNames?.has(componentName)) {
|
|
13506
|
+
if (headlessContractNames?.has(componentName.toLowerCase())) {
|
|
13349
13507
|
return { name: componentName, kind: "headless-instance" };
|
|
13350
13508
|
}
|
|
13351
13509
|
if (importedSymbols.has(componentName)) {
|
|
@@ -14201,6 +14359,9 @@ function filterContentNodes(childNodes, onlyIfMultiple = false) {
|
|
|
14201
14359
|
function textEscape$1(s) {
|
|
14202
14360
|
return s.replace(/'/g, "\\'");
|
|
14203
14361
|
}
|
|
14362
|
+
function escapeForJsString(s) {
|
|
14363
|
+
return s.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/\n/g, "\\n").replace(/\r/g, "\\r");
|
|
14364
|
+
}
|
|
14204
14365
|
const PROPERTY = 1;
|
|
14205
14366
|
const BOOLEAN_ATTRIBUTE = 3;
|
|
14206
14367
|
const propertyMapping = {
|
|
@@ -14243,6 +14404,7 @@ const DIRECTIVE_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
|
14243
14404
|
"jayindex",
|
|
14244
14405
|
"jaytrackby",
|
|
14245
14406
|
"jay-coordinate-base",
|
|
14407
|
+
"jay-scope",
|
|
14246
14408
|
AsyncDirectiveTypes.loading.directive,
|
|
14247
14409
|
AsyncDirectiveTypes.resolved.directive,
|
|
14248
14410
|
AsyncDirectiveTypes.rejected.directive
|
|
@@ -14296,7 +14458,8 @@ function isValidationError(result) {
|
|
|
14296
14458
|
return result instanceof RenderFragment;
|
|
14297
14459
|
}
|
|
14298
14460
|
function resolveHeadlessImport(contractName, headlessImports) {
|
|
14299
|
-
const
|
|
14461
|
+
const lowerName = contractName.toLowerCase();
|
|
14462
|
+
const headlessImport = headlessImports.find((h) => h.contractName === lowerName);
|
|
14300
14463
|
if (!headlessImport) {
|
|
14301
14464
|
return new RenderFragment("", Imports.none(), [
|
|
14302
14465
|
`No headless import found for contract "${contractName}"`
|
|
@@ -14305,15 +14468,17 @@ function resolveHeadlessImport(contractName, headlessImports) {
|
|
|
14305
14468
|
return headlessImport;
|
|
14306
14469
|
}
|
|
14307
14470
|
function extractHeadlessCoordinate(element, contractName) {
|
|
14308
|
-
const instanceCoord = element.getAttribute(COORD_ATTR
|
|
14471
|
+
const instanceCoord = element.getAttribute(COORD_ATTR);
|
|
14309
14472
|
if (!instanceCoord) {
|
|
14310
14473
|
return new RenderFragment("", Imports.none(), [
|
|
14311
14474
|
`Headless instance <jay:${contractName}> missing jay-coordinate-base — run assignCoordinates first`
|
|
14312
14475
|
]);
|
|
14313
14476
|
}
|
|
14314
14477
|
const coordSegments = instanceCoord.split("/");
|
|
14315
|
-
const
|
|
14316
|
-
|
|
14478
|
+
const lowerName = contractName.toLowerCase();
|
|
14479
|
+
const coordinateSuffix = coordSegments.find((s) => s.startsWith(lowerName + ":")) || `${lowerName}:0`;
|
|
14480
|
+
const childScopeId = element.getAttribute("jay-scope") || void 0;
|
|
14481
|
+
return { instanceCoord, coordSegments, coordinateSuffix, childScopeId };
|
|
14317
14482
|
}
|
|
14318
14483
|
function buildContractRefMap(refsTree) {
|
|
14319
14484
|
const result = /* @__PURE__ */ new Map();
|
|
@@ -14337,7 +14502,7 @@ function buildContractRefMap(refsTree) {
|
|
|
14337
14502
|
walk(refsTree);
|
|
14338
14503
|
return result;
|
|
14339
14504
|
}
|
|
14340
|
-
const COORD_ATTR
|
|
14505
|
+
const COORD_ATTR = "jay-coordinate-base";
|
|
14341
14506
|
function expandContractType(renderedElement, baseName) {
|
|
14342
14507
|
const contractPattern = new RegExp(
|
|
14343
14508
|
`export type ${baseName}Contract = JayContract<([^,]+), ${baseName}ElementRefs>;`,
|
|
@@ -14541,144 +14706,6 @@ ${renderedRefsManager}
|
|
|
14541
14706
|
renderedBridge.refs
|
|
14542
14707
|
);
|
|
14543
14708
|
}
|
|
14544
|
-
const COORD_ATTR = "jay-coordinate-base";
|
|
14545
|
-
function assignCoordinatesToJayHtml(jayHtml, headlessContractNames) {
|
|
14546
|
-
const root = parse_2(jayHtml, {
|
|
14547
|
-
comment: true,
|
|
14548
|
-
blockTextElements: { script: true, style: true }
|
|
14549
|
-
});
|
|
14550
|
-
const body = root.querySelector("body");
|
|
14551
|
-
if (!body)
|
|
14552
|
-
return jayHtml;
|
|
14553
|
-
assignCoordinates(body, { headlessContractNames });
|
|
14554
|
-
return root.toString();
|
|
14555
|
-
}
|
|
14556
|
-
function newScope() {
|
|
14557
|
-
return { childCounter: 0 };
|
|
14558
|
-
}
|
|
14559
|
-
function assignCoordinates(body, options) {
|
|
14560
|
-
if (!options._refCounters)
|
|
14561
|
-
options._refCounters = /* @__PURE__ */ new Map();
|
|
14562
|
-
const rootChildren = body.childNodes.filter(
|
|
14563
|
-
(n) => n.nodeType === NodeType.ELEMENT_NODE
|
|
14564
|
-
);
|
|
14565
|
-
if (rootChildren.length === 0)
|
|
14566
|
-
return { debugHtml: body.toString() };
|
|
14567
|
-
const rootElement = rootChildren[0];
|
|
14568
|
-
rootElement.setAttribute(COORD_ATTR, "0");
|
|
14569
|
-
walkChildren(rootElement, "0", options, newScope());
|
|
14570
|
-
return { debugHtml: body.toString() };
|
|
14571
|
-
}
|
|
14572
|
-
function walkChildren(parent, parentCoord, options, scope, slowForEachPrefix = "") {
|
|
14573
|
-
for (const child of parent.childNodes) {
|
|
14574
|
-
if (child.nodeType !== NodeType.ELEMENT_NODE)
|
|
14575
|
-
continue;
|
|
14576
|
-
const element = child;
|
|
14577
|
-
const tagName = element.tagName?.toLowerCase();
|
|
14578
|
-
if (tagName?.startsWith("jay:")) {
|
|
14579
|
-
const contractName = tagName.substring(4);
|
|
14580
|
-
if (options.headlessContractNames.has(contractName)) {
|
|
14581
|
-
let ref = element.getAttribute("ref");
|
|
14582
|
-
if (!ref) {
|
|
14583
|
-
const idx = options._refCounters.get(contractName) ?? 0;
|
|
14584
|
-
options._refCounters.set(contractName, idx + 1);
|
|
14585
|
-
ref = `AR${idx}`;
|
|
14586
|
-
element.setAttribute("ref", ref);
|
|
14587
|
-
}
|
|
14588
|
-
assignHeadlessInstance(
|
|
14589
|
-
element,
|
|
14590
|
-
contractName,
|
|
14591
|
-
ref,
|
|
14592
|
-
parentCoord,
|
|
14593
|
-
options,
|
|
14594
|
-
slowForEachPrefix
|
|
14595
|
-
);
|
|
14596
|
-
continue;
|
|
14597
|
-
}
|
|
14598
|
-
}
|
|
14599
|
-
const forEachAttr = element.getAttribute("forEach");
|
|
14600
|
-
if (forEachAttr) {
|
|
14601
|
-
const trackBy = element.getAttribute("trackBy");
|
|
14602
|
-
if (trackBy) {
|
|
14603
|
-
const coord2 = `${parentCoord}/${scope.childCounter}`;
|
|
14604
|
-
element.setAttribute(COORD_ATTR, coord2);
|
|
14605
|
-
scope.childCounter++;
|
|
14606
|
-
walkForEachChildren(element, `$${trackBy}`, options, slowForEachPrefix);
|
|
14607
|
-
continue;
|
|
14608
|
-
}
|
|
14609
|
-
}
|
|
14610
|
-
const slowForEachAttr = element.getAttribute("slowForEach");
|
|
14611
|
-
if (slowForEachAttr) {
|
|
14612
|
-
const jayTrackBy = element.getAttribute("jayTrackBy");
|
|
14613
|
-
if (jayTrackBy) {
|
|
14614
|
-
const coord2 = slowForEachPrefix ? `${slowForEachPrefix}/${jayTrackBy}` : jayTrackBy;
|
|
14615
|
-
element.setAttribute(COORD_ATTR, coord2);
|
|
14616
|
-
walkChildren(element, coord2, options, newScope(), coord2);
|
|
14617
|
-
continue;
|
|
14618
|
-
}
|
|
14619
|
-
}
|
|
14620
|
-
const coord = `${parentCoord}/${scope.childCounter}`;
|
|
14621
|
-
element.setAttribute(COORD_ATTR, coord);
|
|
14622
|
-
scope.childCounter++;
|
|
14623
|
-
walkChildren(element, coord, options, newScope(), slowForEachPrefix);
|
|
14624
|
-
}
|
|
14625
|
-
}
|
|
14626
|
-
function assignHeadlessInstance(element, contractName, ref, parentCoord, options, slowForEachPrefix = "") {
|
|
14627
|
-
const instanceCoord = `${parentCoord}/${contractName}:${ref}`;
|
|
14628
|
-
element.setAttribute(COORD_ATTR, instanceCoord);
|
|
14629
|
-
const significantChildren = element.childNodes.filter(
|
|
14630
|
-
(n) => n.nodeType === NodeType.ELEMENT_NODE || n.nodeType === NodeType.TEXT_NODE && (n.innerText || "").trim() !== ""
|
|
14631
|
-
);
|
|
14632
|
-
if (significantChildren.length > 1) {
|
|
14633
|
-
const wrapper = parse_2("<div></div>").querySelector("div");
|
|
14634
|
-
const children = [...element.childNodes];
|
|
14635
|
-
element.innerHTML = "";
|
|
14636
|
-
children.forEach((child) => wrapper.appendChild(child));
|
|
14637
|
-
element.appendChild(wrapper);
|
|
14638
|
-
}
|
|
14639
|
-
walkChildren(element, instanceCoord, options, newScope(), slowForEachPrefix);
|
|
14640
|
-
}
|
|
14641
|
-
function walkForEachChildren(parent, itemPrefix, options, slowForEachPrefix = "") {
|
|
14642
|
-
const scope = newScope();
|
|
14643
|
-
for (const child of parent.childNodes) {
|
|
14644
|
-
if (child.nodeType !== NodeType.ELEMENT_NODE)
|
|
14645
|
-
continue;
|
|
14646
|
-
const element = child;
|
|
14647
|
-
const tagName = element.tagName?.toLowerCase();
|
|
14648
|
-
if (tagName?.startsWith("jay:")) {
|
|
14649
|
-
const contractName = tagName.substring(4);
|
|
14650
|
-
if (options.headlessContractNames.has(contractName)) {
|
|
14651
|
-
let ref = element.getAttribute("ref");
|
|
14652
|
-
if (!ref) {
|
|
14653
|
-
const counterKey = `forEach/${contractName}`;
|
|
14654
|
-
const idx = options._refCounters.get(counterKey) ?? 0;
|
|
14655
|
-
options._refCounters.set(counterKey, idx + 1);
|
|
14656
|
-
ref = `AR${idx}`;
|
|
14657
|
-
element.setAttribute("ref", ref);
|
|
14658
|
-
}
|
|
14659
|
-
const instanceCoord = itemPrefix ? `${itemPrefix}/${contractName}:${ref}` : `${contractName}:${ref}`;
|
|
14660
|
-
element.setAttribute(COORD_ATTR, instanceCoord);
|
|
14661
|
-
walkChildren(element, instanceCoord, options, newScope(), slowForEachPrefix);
|
|
14662
|
-
continue;
|
|
14663
|
-
}
|
|
14664
|
-
}
|
|
14665
|
-
const forEachAttr = element.getAttribute("forEach");
|
|
14666
|
-
if (forEachAttr) {
|
|
14667
|
-
const trackBy = element.getAttribute("trackBy");
|
|
14668
|
-
if (trackBy) {
|
|
14669
|
-
const coord2 = itemPrefix ? `${itemPrefix}/${scope.childCounter}` : `${scope.childCounter}`;
|
|
14670
|
-
element.setAttribute(COORD_ATTR, coord2);
|
|
14671
|
-
scope.childCounter++;
|
|
14672
|
-
walkForEachChildren(element, null, options, slowForEachPrefix);
|
|
14673
|
-
continue;
|
|
14674
|
-
}
|
|
14675
|
-
}
|
|
14676
|
-
const coord = itemPrefix ? `${itemPrefix}/${scope.childCounter}` : `${scope.childCounter}`;
|
|
14677
|
-
element.setAttribute(COORD_ATTR, coord);
|
|
14678
|
-
scope.childCounter++;
|
|
14679
|
-
walkChildren(element, coord, options, newScope(), slowForEachPrefix);
|
|
14680
|
-
}
|
|
14681
|
-
}
|
|
14682
14709
|
/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */
|
|
14683
14710
|
function isNothing(subject) {
|
|
14684
14711
|
return typeof subject === "undefined" || subject === null;
|
|
@@ -18234,6 +18261,10 @@ function injectHeadfullFSTemplates(html2, sourceDir, importResolver) {
|
|
|
18234
18261
|
const body = root.querySelector("body");
|
|
18235
18262
|
if (!body)
|
|
18236
18263
|
return html2;
|
|
18264
|
+
injectHeadfullFSTemplatesRecursive(fsElements, body, sourceDir, importResolver, /* @__PURE__ */ new Set());
|
|
18265
|
+
return root.toString();
|
|
18266
|
+
}
|
|
18267
|
+
function injectHeadfullFSTemplatesRecursive(fsElements, body, sourceDir, importResolver, visited) {
|
|
18237
18268
|
for (const element of fsElements) {
|
|
18238
18269
|
const src = element.getAttribute("src");
|
|
18239
18270
|
const rawNames = element.getAttribute("names");
|
|
@@ -18243,13 +18274,28 @@ function injectHeadfullFSTemplates(html2, sourceDir, importResolver) {
|
|
|
18243
18274
|
if (names.length === 0)
|
|
18244
18275
|
continue;
|
|
18245
18276
|
const contractName = (names[0].as || names[0].name).toLowerCase();
|
|
18246
|
-
const
|
|
18247
|
-
if (
|
|
18277
|
+
const resolvedSrc = path.resolve(sourceDir, src);
|
|
18278
|
+
if (visited.has(resolvedSrc))
|
|
18279
|
+
continue;
|
|
18280
|
+
visited.add(resolvedSrc);
|
|
18281
|
+
const jayHtmlResult = importResolver.readJayHtml(sourceDir, src);
|
|
18282
|
+
if (!jayHtmlResult)
|
|
18248
18283
|
continue;
|
|
18249
|
-
const jayHtmlRoot = parse_2(
|
|
18284
|
+
const jayHtmlRoot = parse_2(jayHtmlResult.content);
|
|
18250
18285
|
const jayHtmlBody = jayHtmlRoot.querySelector("body");
|
|
18251
18286
|
if (!jayHtmlBody)
|
|
18252
18287
|
continue;
|
|
18288
|
+
const nestedHeadfullElements = jayHtmlRoot.querySelectorAll('script[type="application/jay-headfull"]').filter((el) => el.getAttribute("contract"));
|
|
18289
|
+
if (nestedHeadfullElements.length > 0) {
|
|
18290
|
+
const childDir = jayHtmlResult.componentDir;
|
|
18291
|
+
injectHeadfullFSTemplatesRecursive(
|
|
18292
|
+
nestedHeadfullElements,
|
|
18293
|
+
jayHtmlBody,
|
|
18294
|
+
childDir,
|
|
18295
|
+
importResolver,
|
|
18296
|
+
visited
|
|
18297
|
+
);
|
|
18298
|
+
}
|
|
18253
18299
|
const jayTags = body.querySelectorAll("*").filter((el) => el.tagName?.toLowerCase() === `jay:${contractName}`);
|
|
18254
18300
|
for (const jayTag of jayTags) {
|
|
18255
18301
|
if (!jayTag.innerHTML.trim()) {
|
|
@@ -18257,12 +18303,12 @@ function injectHeadfullFSTemplates(html2, sourceDir, importResolver) {
|
|
|
18257
18303
|
}
|
|
18258
18304
|
}
|
|
18259
18305
|
}
|
|
18260
|
-
return root.toString();
|
|
18261
18306
|
}
|
|
18262
|
-
async function parseHeadfullFSImports(elements, validations, filePath, importResolver, body, projectRoot) {
|
|
18307
|
+
async function parseHeadfullFSImports(elements, validations, filePath, importResolver, body, projectRoot, visited = /* @__PURE__ */ new Set(), sourceDir) {
|
|
18263
18308
|
const headlessImports = [];
|
|
18264
18309
|
const cssParts = [];
|
|
18265
18310
|
const linkedCssFiles = [];
|
|
18311
|
+
const linkedComponentFiles = [];
|
|
18266
18312
|
for (const element of elements) {
|
|
18267
18313
|
const src = element.getAttribute("src");
|
|
18268
18314
|
const contractAttr = element.getAttribute("contract");
|
|
@@ -18287,7 +18333,37 @@ async function parseHeadfullFSImports(elements, validations, filePath, importRes
|
|
|
18287
18333
|
}
|
|
18288
18334
|
const componentExportName = names[0].name;
|
|
18289
18335
|
const contractName = (names[0].as || componentExportName).toLowerCase();
|
|
18290
|
-
|
|
18336
|
+
const resolvedSrc = path.resolve(filePath, src);
|
|
18337
|
+
if (visited.has(resolvedSrc)) {
|
|
18338
|
+
validations.push(
|
|
18339
|
+
`Circular headfull FS import detected: ${src} has already been processed`
|
|
18340
|
+
);
|
|
18341
|
+
continue;
|
|
18342
|
+
}
|
|
18343
|
+
visited.add(resolvedSrc);
|
|
18344
|
+
const resolveDir = sourceDir || filePath;
|
|
18345
|
+
let jayHtmlResult = importResolver.readJayHtml(resolveDir, src);
|
|
18346
|
+
let moduleResolveDir = resolveDir;
|
|
18347
|
+
if (jayHtmlResult === null && resolveDir !== filePath) {
|
|
18348
|
+
jayHtmlResult = importResolver.readJayHtml(filePath, src);
|
|
18349
|
+
if (jayHtmlResult !== null) {
|
|
18350
|
+
moduleResolveDir = filePath;
|
|
18351
|
+
}
|
|
18352
|
+
}
|
|
18353
|
+
if (jayHtmlResult === null && projectRoot && projectRoot !== filePath && projectRoot !== resolveDir) {
|
|
18354
|
+
jayHtmlResult = importResolver.readJayHtml(projectRoot, src);
|
|
18355
|
+
if (jayHtmlResult !== null) {
|
|
18356
|
+
moduleResolveDir = projectRoot;
|
|
18357
|
+
}
|
|
18358
|
+
}
|
|
18359
|
+
if (jayHtmlResult === null) {
|
|
18360
|
+
validations.push(
|
|
18361
|
+
`jay-html file not found for headfull FS component ${src} (expected ${src}.jay-html)`
|
|
18362
|
+
);
|
|
18363
|
+
continue;
|
|
18364
|
+
}
|
|
18365
|
+
linkedComponentFiles.push(jayHtmlResult.filePath);
|
|
18366
|
+
let contractPath = path.resolve(resolveDir, contractAttr);
|
|
18291
18367
|
let loadedContract;
|
|
18292
18368
|
try {
|
|
18293
18369
|
const contractResult = importResolver.loadContract(contractPath);
|
|
@@ -18297,6 +18373,7 @@ async function parseHeadfullFSImports(elements, validations, filePath, importRes
|
|
|
18297
18373
|
}
|
|
18298
18374
|
loadedContract = contractResult.val;
|
|
18299
18375
|
} catch (e2) {
|
|
18376
|
+
let resolved = false;
|
|
18300
18377
|
if (projectRoot && projectRoot !== filePath) {
|
|
18301
18378
|
try {
|
|
18302
18379
|
contractPath = path.resolve(projectRoot, contractAttr);
|
|
@@ -18306,36 +18383,37 @@ async function parseHeadfullFSImports(elements, validations, filePath, importRes
|
|
|
18306
18383
|
continue;
|
|
18307
18384
|
}
|
|
18308
18385
|
loadedContract = fallbackResult.val;
|
|
18309
|
-
|
|
18386
|
+
resolved = true;
|
|
18387
|
+
} catch {
|
|
18388
|
+
}
|
|
18389
|
+
}
|
|
18390
|
+
if (!resolved) {
|
|
18391
|
+
try {
|
|
18392
|
+
contractPath = path.resolve(
|
|
18393
|
+
jayHtmlResult.componentDir,
|
|
18394
|
+
path.basename(contractAttr)
|
|
18395
|
+
);
|
|
18396
|
+
const fallbackResult = importResolver.loadContract(contractPath);
|
|
18397
|
+
validations.push(...fallbackResult.validations);
|
|
18398
|
+
if (!fallbackResult.val) {
|
|
18399
|
+
continue;
|
|
18400
|
+
}
|
|
18401
|
+
loadedContract = fallbackResult.val;
|
|
18402
|
+
} catch (e3) {
|
|
18310
18403
|
validations.push(
|
|
18311
|
-
`Failed to load contract for headfull FS component ${src}: ${
|
|
18404
|
+
`Failed to load contract for headfull FS component ${src}: ${e3.message}`
|
|
18312
18405
|
);
|
|
18313
18406
|
continue;
|
|
18314
18407
|
}
|
|
18315
|
-
} else {
|
|
18316
|
-
validations.push(
|
|
18317
|
-
`Failed to load contract for headfull FS component ${src}: ${e2.message}`
|
|
18318
|
-
);
|
|
18319
|
-
continue;
|
|
18320
18408
|
}
|
|
18321
18409
|
}
|
|
18322
|
-
|
|
18323
|
-
if (jayHtmlContent === null && projectRoot && projectRoot !== filePath) {
|
|
18324
|
-
jayHtmlContent = importResolver.readJayHtml(projectRoot, src);
|
|
18325
|
-
}
|
|
18326
|
-
if (jayHtmlContent === null) {
|
|
18327
|
-
validations.push(
|
|
18328
|
-
`jay-html file not found for headfull FS component ${src} (expected ${src}.jay-html)`
|
|
18329
|
-
);
|
|
18330
|
-
continue;
|
|
18331
|
-
}
|
|
18332
|
-
const jayHtmlRoot = parse_2(jayHtmlContent);
|
|
18410
|
+
const jayHtmlRoot = parse_2(jayHtmlResult.content);
|
|
18333
18411
|
const jayHtmlBody = jayHtmlRoot.querySelector("body");
|
|
18334
18412
|
if (!jayHtmlBody) {
|
|
18335
18413
|
validations.push(`headfull FS component ${src} jay-html must have a body tag`);
|
|
18336
18414
|
continue;
|
|
18337
18415
|
}
|
|
18338
|
-
const componentDir =
|
|
18416
|
+
const componentDir = jayHtmlResult.componentDir;
|
|
18339
18417
|
const componentCssResult = await extractCss(jayHtmlRoot, componentDir);
|
|
18340
18418
|
validations.push(...componentCssResult.validations);
|
|
18341
18419
|
if (componentCssResult.val?.css) {
|
|
@@ -18344,6 +18422,55 @@ async function parseHeadfullFSImports(elements, validations, filePath, importRes
|
|
|
18344
18422
|
if (componentCssResult.val?.linkedCssFiles) {
|
|
18345
18423
|
linkedCssFiles.push(...componentCssResult.val.linkedCssFiles);
|
|
18346
18424
|
}
|
|
18425
|
+
const nestedHeadlessElements = jayHtmlRoot.querySelectorAll(
|
|
18426
|
+
'script[type="application/jay-headless"]'
|
|
18427
|
+
);
|
|
18428
|
+
if (nestedHeadlessElements.length > 0) {
|
|
18429
|
+
const nestedHeadless = await parseHeadlessImports(
|
|
18430
|
+
nestedHeadlessElements,
|
|
18431
|
+
validations,
|
|
18432
|
+
filePath,
|
|
18433
|
+
importResolver,
|
|
18434
|
+
projectRoot
|
|
18435
|
+
);
|
|
18436
|
+
headlessImports.push(...nestedHeadless);
|
|
18437
|
+
}
|
|
18438
|
+
const nestedHeadfullFSElements = jayHtmlRoot.querySelectorAll('script[type="application/jay-headfull"]').filter((el) => el.getAttribute("contract"));
|
|
18439
|
+
if (nestedHeadfullFSElements.length > 0) {
|
|
18440
|
+
for (const nestedEl of nestedHeadfullFSElements) {
|
|
18441
|
+
const nestedSrc = nestedEl.getAttribute("src");
|
|
18442
|
+
if (nestedSrc) {
|
|
18443
|
+
const absoluteSrc = path.resolve(componentDir, nestedSrc);
|
|
18444
|
+
let relativeSrc = path.relative(filePath, absoluteSrc);
|
|
18445
|
+
if (!relativeSrc.startsWith("."))
|
|
18446
|
+
relativeSrc = "./" + relativeSrc;
|
|
18447
|
+
nestedEl.setAttribute("src", relativeSrc);
|
|
18448
|
+
}
|
|
18449
|
+
const nestedContract = nestedEl.getAttribute("contract");
|
|
18450
|
+
if (nestedContract) {
|
|
18451
|
+
const absoluteContract = path.resolve(componentDir, nestedContract);
|
|
18452
|
+
let relativeContract = path.relative(filePath, absoluteContract);
|
|
18453
|
+
if (!relativeContract.startsWith("."))
|
|
18454
|
+
relativeContract = "./" + relativeContract;
|
|
18455
|
+
nestedEl.setAttribute("contract", relativeContract);
|
|
18456
|
+
}
|
|
18457
|
+
}
|
|
18458
|
+
const nestedResult = await parseHeadfullFSImports(
|
|
18459
|
+
nestedHeadfullFSElements,
|
|
18460
|
+
validations,
|
|
18461
|
+
filePath,
|
|
18462
|
+
importResolver,
|
|
18463
|
+
jayHtmlBody,
|
|
18464
|
+
projectRoot,
|
|
18465
|
+
visited
|
|
18466
|
+
);
|
|
18467
|
+
headlessImports.push(...nestedResult.headlessImports);
|
|
18468
|
+
if (nestedResult.css) {
|
|
18469
|
+
cssParts.push(nestedResult.css);
|
|
18470
|
+
}
|
|
18471
|
+
linkedCssFiles.push(...nestedResult.linkedCssFiles);
|
|
18472
|
+
linkedComponentFiles.push(...nestedResult.linkedComponentFiles);
|
|
18473
|
+
}
|
|
18347
18474
|
const jayTags = body.querySelectorAll("*").filter((el) => el.tagName?.toLowerCase() === `jay:${contractName}`);
|
|
18348
18475
|
for (const jayTag of jayTags) {
|
|
18349
18476
|
const existingContent = jayTag.innerHTML.trim();
|
|
@@ -18413,7 +18540,6 @@ async function parseHeadfullFSImports(elements, validations, filePath, importRes
|
|
|
18413
18540
|
}))
|
|
18414
18541
|
}));
|
|
18415
18542
|
const contractLinks = [contractLink, ...enumImportLinks];
|
|
18416
|
-
const moduleResolveDir = projectRoot && projectRoot !== filePath ? projectRoot : filePath;
|
|
18417
18543
|
let relativeModule = path.relative(
|
|
18418
18544
|
filePath,
|
|
18419
18545
|
importResolver.resolveLink(moduleResolveDir, src)
|
|
@@ -18449,7 +18575,8 @@ async function parseHeadfullFSImports(elements, validations, filePath, importRes
|
|
|
18449
18575
|
return {
|
|
18450
18576
|
headlessImports,
|
|
18451
18577
|
css: cssParts.length > 0 ? cssParts.join("\n\n") : void 0,
|
|
18452
|
-
linkedCssFiles
|
|
18578
|
+
linkedCssFiles,
|
|
18579
|
+
linkedComponentFiles
|
|
18453
18580
|
};
|
|
18454
18581
|
}
|
|
18455
18582
|
function normalizeFilename(filename) {
|
|
@@ -18541,7 +18668,7 @@ function extractTrackByMaps(pageContract, headlessImports) {
|
|
|
18541
18668
|
}
|
|
18542
18669
|
return { serverTrackByMap, clientTrackByMap };
|
|
18543
18670
|
}
|
|
18544
|
-
async function parseJayFile(html2, filename, filePath, options, linkedContractResolver, projectRoot) {
|
|
18671
|
+
async function parseJayFile(html2, filename, filePath, options, linkedContractResolver, projectRoot, sourceDir) {
|
|
18545
18672
|
const normalizedFileName = normalizeFilename(filename);
|
|
18546
18673
|
const baseElementName = capitalCase(normalizedFileName, { delimiter: "" });
|
|
18547
18674
|
const root = parse_2(html2);
|
|
@@ -18572,7 +18699,10 @@ async function parseJayFile(html2, filename, filePath, options, linkedContractRe
|
|
|
18572
18699
|
filePath,
|
|
18573
18700
|
linkedContractResolver,
|
|
18574
18701
|
body,
|
|
18575
|
-
projectRoot
|
|
18702
|
+
projectRoot,
|
|
18703
|
+
void 0,
|
|
18704
|
+
// visited
|
|
18705
|
+
sourceDir
|
|
18576
18706
|
);
|
|
18577
18707
|
const headlessImports = await parseHeadlessImports(
|
|
18578
18708
|
root.querySelectorAll('script[type="application/jay-headless"]'),
|
|
@@ -18617,6 +18747,7 @@ async function parseJayFile(html2, filename, filePath, options, linkedContractRe
|
|
|
18617
18747
|
if (headfullFSResult.linkedCssFiles.length > 0) {
|
|
18618
18748
|
allLinkedCssFiles = [...allLinkedCssFiles, ...headfullFSResult.linkedCssFiles];
|
|
18619
18749
|
}
|
|
18750
|
+
const allLinkedComponentFiles = headfullFSResult.linkedComponentFiles;
|
|
18620
18751
|
const { serverTrackByMap, clientTrackByMap } = extractTrackByMaps(
|
|
18621
18752
|
jayYaml.parsedContract,
|
|
18622
18753
|
allHeadlessImports
|
|
@@ -18633,6 +18764,7 @@ async function parseJayFile(html2, filename, filePath, options, linkedContractRe
|
|
|
18633
18764
|
headLinks,
|
|
18634
18765
|
css,
|
|
18635
18766
|
linkedCssFiles: allLinkedCssFiles.length > 0 ? allLinkedCssFiles : void 0,
|
|
18767
|
+
linkedComponentFiles: allLinkedComponentFiles.length > 0 ? allLinkedComponentFiles : void 0,
|
|
18636
18768
|
filename: normalizedFileName,
|
|
18637
18769
|
contract: jayYaml.parsedContract,
|
|
18638
18770
|
contractRef: jayYaml.contractRef,
|
|
@@ -19342,6 +19474,9 @@ function parseContract(contractYaml, fileName) {
|
|
|
19342
19474
|
}
|
|
19343
19475
|
const contract = {
|
|
19344
19476
|
name: parsedYaml.name,
|
|
19477
|
+
...typeof parsedYaml.description === "string" && {
|
|
19478
|
+
description: parsedYaml.description
|
|
19479
|
+
},
|
|
19345
19480
|
tags: parsedTags,
|
|
19346
19481
|
...parsedProps && parsedProps.length > 0 && { props: parsedProps },
|
|
19347
19482
|
...parsedParams && parsedParams.length > 0 && { params: parsedParams }
|
|
@@ -19471,7 +19606,7 @@ function renderHydrateElement(element, context) {
|
|
|
19471
19606
|
context.interactivePaths
|
|
19472
19607
|
);
|
|
19473
19608
|
const renderedCondition = parseCondition(condition, context.variables);
|
|
19474
|
-
const coordinate = element.getAttribute(COORD_ATTR
|
|
19609
|
+
const coordinate = element.getAttribute(COORD_ATTR) || "0";
|
|
19475
19610
|
const childContent = renderHydrateElementContent(
|
|
19476
19611
|
element,
|
|
19477
19612
|
context,
|
|
@@ -19501,11 +19636,13 @@ function renderHydrateElement(element, context) {
|
|
|
19501
19636
|
);
|
|
19502
19637
|
const createElementFunc = needDynamicElement ? "de" : "e";
|
|
19503
19638
|
const createElementImport = needDynamicElement ? Import.dynamicElement : Import.element;
|
|
19504
|
-
const
|
|
19639
|
+
const createRef = renderElementRef$1(element, createRenderContext);
|
|
19640
|
+
const createRefSuffix = createRef.rendered ? `, ${createRef.rendered}` : "";
|
|
19641
|
+
const createBody = `() => ${createElementFunc}('${element.rawTagName}', ${createAttributes.rendered}, [${createChildren.rendered}]${createRefSuffix})`;
|
|
19505
19642
|
return new RenderFragment(
|
|
19506
19643
|
`${context.indent.firstLine}hydrateConditional(${renderedCondition.rendered}, ${adoptBody},
|
|
19507
19644
|
${context.indent.firstLine} ${createBody})`,
|
|
19508
|
-
Imports.for(Import.hydrateConditional).plus(createElementImport).plus(renderedCondition.imports).plus(childContent.imports).plus(createChildren.imports).plus(createAttributes.imports),
|
|
19645
|
+
Imports.for(Import.hydrateConditional).plus(createElementImport).plus(renderedCondition.imports).plus(childContent.imports).plus(createChildren.imports).plus(createAttributes.imports).plus(createRef.imports),
|
|
19509
19646
|
[
|
|
19510
19647
|
...renderedCondition.validations,
|
|
19511
19648
|
...childContent.validations,
|
|
@@ -19527,15 +19664,14 @@ ${context.indent.firstLine} ${createBody})`,
|
|
|
19527
19664
|
const forEachFragment = forEachAccessor.render().map((_) => `(${paramName}: ${paramType}) => ${_}`);
|
|
19528
19665
|
const preAdoptRefNameGenerator = context.refNameGenerator.clone();
|
|
19529
19666
|
const itemChildNodes = filterContentNodes(element.childNodes);
|
|
19530
|
-
|
|
19667
|
+
`${forEachVariables.currentVar}.${trackBy}`;
|
|
19531
19668
|
const itemContext = {
|
|
19532
19669
|
...context,
|
|
19533
19670
|
variables: forEachVariables,
|
|
19534
19671
|
indent: indent.child().child(),
|
|
19535
19672
|
dynamicRef: true,
|
|
19536
19673
|
// Refs inside forEach are collection refs
|
|
19537
|
-
insideFastForEach: true
|
|
19538
|
-
varMappings: { ...context.varMappings, [trackBy]: trackByExpr }
|
|
19674
|
+
insideFastForEach: true
|
|
19539
19675
|
};
|
|
19540
19676
|
const itemRenderCtx = buildRenderContext(itemContext);
|
|
19541
19677
|
const itemAttrs = renderDynamicAttributes(element, itemRenderCtx);
|
|
@@ -19594,12 +19730,13 @@ ${context.indent.firstLine} ${createBody})`,
|
|
|
19594
19730
|
}
|
|
19595
19731
|
}
|
|
19596
19732
|
}
|
|
19733
|
+
const itemRootCoord2 = element.getAttribute(COORD_ATTR) || "";
|
|
19597
19734
|
const refSuffix = itemRefFragment.rendered ? `, ${itemRefFragment.rendered}` : "";
|
|
19598
19735
|
const childrenArr = childParts.length ? `[
|
|
19599
19736
|
${childParts.join(",\n")},
|
|
19600
19737
|
${indent.firstLine} ]` : "[]";
|
|
19601
19738
|
adoptBody = `() => [
|
|
19602
|
-
${indent.firstLine} adoptDynamicElement("", ${itemAttrs.rendered}, ${childrenArr}${refSuffix}),
|
|
19739
|
+
${indent.firstLine} adoptDynamicElement("${itemRootCoord2}", ${itemAttrs.rendered}, ${childrenArr}${refSuffix}),
|
|
19603
19740
|
${indent.firstLine} ]`;
|
|
19604
19741
|
itemContent = new RenderFragment(
|
|
19605
19742
|
"",
|
|
@@ -19613,12 +19750,13 @@ ${indent.firstLine} ]`;
|
|
|
19613
19750
|
",\n"
|
|
19614
19751
|
);
|
|
19615
19752
|
if (needsItemAdoption) {
|
|
19753
|
+
const itemRootCoord = element.getAttribute(COORD_ATTR) || "";
|
|
19616
19754
|
const refSuffix = itemRefFragment.rendered ? `, ${itemRefFragment.rendered}` : "";
|
|
19617
19755
|
const childrenArr = itemContent.rendered.trim() ? `[
|
|
19618
19756
|
${itemContent.rendered},
|
|
19619
19757
|
${indent.firstLine} ]` : "[]";
|
|
19620
19758
|
adoptBody = `() => [
|
|
19621
|
-
${indent.firstLine} adoptElement("", ${itemAttrs.rendered}, ${childrenArr}${refSuffix}),
|
|
19759
|
+
${indent.firstLine} adoptElement("${itemRootCoord}", ${itemAttrs.rendered}, ${childrenArr}${refSuffix}),
|
|
19622
19760
|
${indent.firstLine} ]`;
|
|
19623
19761
|
} else {
|
|
19624
19762
|
adoptBody = itemContent.rendered.trim() ? `() => [
|
|
@@ -19661,8 +19799,9 @@ ${indent.firstLine} }`;
|
|
|
19661
19799
|
if (needsItemAdoption && !itemHasInteractiveChildren) {
|
|
19662
19800
|
allImports = allImports.plus(Import.adoptElement);
|
|
19663
19801
|
}
|
|
19802
|
+
const itemRootCoordForEach = element.getAttribute(COORD_ATTR) || "0";
|
|
19664
19803
|
const hydrateForEachFragment = new RenderFragment(
|
|
19665
|
-
`${indent.firstLine}hydrateForEach(${forEachFragment.rendered}, '${trackBy}',
|
|
19804
|
+
`${indent.firstLine}hydrateForEach(${forEachFragment.rendered}, '${trackBy}', '${itemRootCoordForEach}',
|
|
19666
19805
|
${indent.firstLine} ${adoptBody},
|
|
19667
19806
|
${indent.firstLine} ${createBody},
|
|
19668
19807
|
${indent.firstLine})`,
|
|
@@ -19693,14 +19832,12 @@ ${indent.firstLine})`,
|
|
|
19693
19832
|
const itemTypeName = slowForEachVariables.currentType.name;
|
|
19694
19833
|
const paramName = arrayAccessor.rootVar;
|
|
19695
19834
|
const getItemsFragment = arrayAccessor.render().map((_) => `(${paramName}: ${parentTypeName}) => ${_}`);
|
|
19696
|
-
const accumulatedJayTrackBy = context.slowForEachJayTrackBy ? `${context.slowForEachJayTrackBy}/${jayTrackBy}` : jayTrackBy;
|
|
19697
19835
|
const itemContext = {
|
|
19698
19836
|
...context,
|
|
19699
19837
|
variables: slowForEachVariables,
|
|
19700
19838
|
indent: indent.child().child(),
|
|
19701
19839
|
dynamicRef: true,
|
|
19702
|
-
insideSlowForEach: true
|
|
19703
|
-
slowForEachJayTrackBy: accumulatedJayTrackBy
|
|
19840
|
+
insideSlowForEach: true
|
|
19704
19841
|
};
|
|
19705
19842
|
buildRenderContext(itemContext);
|
|
19706
19843
|
const itemChildNodes = filterContentNodes(element.childNodes);
|
|
@@ -19741,13 +19878,15 @@ ${indent.firstLine})`,
|
|
|
19741
19878
|
}
|
|
19742
19879
|
}
|
|
19743
19880
|
const childrenArr = childParts.join(",\n");
|
|
19744
|
-
|
|
19881
|
+
const itemCoord = element.getAttribute(COORD_ATTR) || "";
|
|
19882
|
+
callbackBody = `adoptDynamicElement('${itemCoord}', {}, [
|
|
19745
19883
|
${childrenArr},
|
|
19746
19884
|
${indent.firstLine} ])`;
|
|
19747
19885
|
callbackImports = callbackImports.plus(Import.adoptDynamicElement);
|
|
19748
19886
|
} else {
|
|
19887
|
+
const itemCoord = element.getAttribute(COORD_ATTR) || "";
|
|
19749
19888
|
const childrenArr = nonEmptyChildren.map((f) => f.rendered).join(",\n");
|
|
19750
|
-
callbackBody = `adoptElement('', {}, [
|
|
19889
|
+
callbackBody = `adoptElement('${itemCoord}', {}, [
|
|
19751
19890
|
${childrenArr},
|
|
19752
19891
|
${indent.firstLine} ])`;
|
|
19753
19892
|
for (const f of nonEmptyChildren) {
|
|
@@ -19809,16 +19948,13 @@ function renderHydrateHeadlessInstance(element, context, renderContext, contract
|
|
|
19809
19948
|
const coordResult = extractHeadlessCoordinate(element, contractName);
|
|
19810
19949
|
if (isValidationError(coordResult))
|
|
19811
19950
|
return coordResult;
|
|
19812
|
-
const { instanceCoord, coordSegments, coordinateSuffix } = coordResult;
|
|
19951
|
+
const { instanceCoord, coordSegments, coordinateSuffix, childScopeId } = coordResult;
|
|
19813
19952
|
const isInsideForEach = context.insideFastForEach;
|
|
19814
19953
|
let coordinateKey2;
|
|
19815
19954
|
if (isInsideForEach) {
|
|
19816
19955
|
coordinateKey2 = void 0;
|
|
19817
|
-
} else if (context.insideSlowForEach) {
|
|
19818
|
-
const prefix = coordSegments[0];
|
|
19819
|
-
coordinateKey2 = computeInstanceKey(coordinateSuffix, "slowForEach", prefix);
|
|
19820
19956
|
} else {
|
|
19821
|
-
coordinateKey2 =
|
|
19957
|
+
coordinateKey2 = instanceCoord;
|
|
19822
19958
|
}
|
|
19823
19959
|
const componentVariables = new Variables(headlessImport.rootType);
|
|
19824
19960
|
const childNodes = filterContentNodes(element.childNodes);
|
|
@@ -19836,10 +19972,10 @@ function renderHydrateHeadlessInstance(element, context, renderContext, contract
|
|
|
19836
19972
|
importedRefNameToRef: instanceRefMap,
|
|
19837
19973
|
dynamicRef: false,
|
|
19838
19974
|
insideFastForEach: false,
|
|
19839
|
-
|
|
19840
|
-
|
|
19841
|
-
|
|
19842
|
-
|
|
19975
|
+
// Pass headless contract names and imports through so nested headless instances
|
|
19976
|
+
// inside headfull FS component templates can be detected (DL#123)
|
|
19977
|
+
headlessContractNames: context.headlessContractNames,
|
|
19978
|
+
headlessImports: context.headlessImports,
|
|
19843
19979
|
interactivePaths: buildInteractivePaths(headlessImport.contract)
|
|
19844
19980
|
};
|
|
19845
19981
|
const adoptRenderContext = buildRenderContext(adoptItemContext);
|
|
@@ -19854,6 +19990,7 @@ function renderHydrateHeadlessInstance(element, context, renderContext, contract
|
|
|
19854
19990
|
// forceAdopt
|
|
19855
19991
|
);
|
|
19856
19992
|
} else {
|
|
19993
|
+
const wrapperCoord = childScopeId ? `${childScopeId}/0` : "0";
|
|
19857
19994
|
const adoptChildContext = {
|
|
19858
19995
|
...adoptItemContext
|
|
19859
19996
|
};
|
|
@@ -19862,7 +19999,7 @@ function renderHydrateHeadlessInstance(element, context, renderContext, contract
|
|
|
19862
19999
|
",\n"
|
|
19863
20000
|
);
|
|
19864
20001
|
adoptInlineBody = new RenderFragment(
|
|
19865
|
-
`${adoptChildIndent.firstLine}adoptElement("
|
|
20002
|
+
`${adoptChildIndent.firstLine}adoptElement("${wrapperCoord}", {}, [
|
|
19866
20003
|
${adoptChildren.rendered}
|
|
19867
20004
|
${adoptChildIndent.firstLine}])`,
|
|
19868
20005
|
adoptChildren.imports.plus(Import.adoptElement),
|
|
@@ -19923,8 +20060,10 @@ ${adoptInlineBody.rendered}
|
|
|
19923
20060
|
dynamicRef: false,
|
|
19924
20061
|
isInsideGuard: true,
|
|
19925
20062
|
insideFastForEach: false,
|
|
19926
|
-
|
|
19927
|
-
|
|
20063
|
+
// Pass headless contract names and imports through so nested headless instances
|
|
20064
|
+
// inside headfull FS component templates can be detected (DL#123)
|
|
20065
|
+
headlessContractNames: renderContext.headlessContractNames,
|
|
20066
|
+
headlessImports: renderContext.headlessImports,
|
|
19928
20067
|
coordinatePrefix: [],
|
|
19929
20068
|
coordinateCounters: /* @__PURE__ */ new Map()
|
|
19930
20069
|
};
|
|
@@ -20003,10 +20142,10 @@ const ${createComponentSymbol} = makeHeadlessInstanceComponent(
|
|
|
20003
20142
|
);
|
|
20004
20143
|
if (renderedRef.rendered !== "")
|
|
20005
20144
|
renderedRef = renderedRef.map((_) => ", " + _);
|
|
20006
|
-
const
|
|
20145
|
+
const scopeRootCoord = childScopeId ? `'${childScopeId}/0'` : "undefined";
|
|
20007
20146
|
if (ifCondition) {
|
|
20008
20147
|
const renderedCondition = parseCondition(ifCondition, context.variables);
|
|
20009
|
-
const adoptCall = `() => childCompHydrate(${adoptComponentSymbol}, ${getProps}, ${
|
|
20148
|
+
const adoptCall = `() => childCompHydrate(${adoptComponentSymbol}, ${getProps}, ${scopeRootCoord}${renderedRef.rendered})`;
|
|
20010
20149
|
const createCall = `() => childComp(${createComponentSymbol}, ${getProps}${renderedRef.rendered})`;
|
|
20011
20150
|
const callExpr = `${context.indent.firstLine}hydrateConditional(${renderedCondition.rendered}, ${adoptCall},
|
|
20012
20151
|
${context.indent.firstLine} ${createCall})`;
|
|
@@ -20022,7 +20161,7 @@ ${context.indent.firstLine} ${createCall})`;
|
|
|
20022
20161
|
);
|
|
20023
20162
|
}
|
|
20024
20163
|
return new RenderFragment(
|
|
20025
|
-
`${context.indent.firstLine}childCompHydrate(${adoptComponentSymbol}, ${getProps}, ${
|
|
20164
|
+
`${context.indent.firstLine}childCompHydrate(${adoptComponentSymbol}, ${getProps}, ${scopeRootCoord}${renderedRef.rendered})`,
|
|
20026
20165
|
Imports.for(Import.childCompHydrate).plus(propsGetterAndRefs.imports).plus(renderedRef.imports),
|
|
20027
20166
|
[
|
|
20028
20167
|
...propsGetterAndRefs.validations,
|
|
@@ -20077,22 +20216,7 @@ function renderHydrateElementContent(element, context, renderContext, coordinate
|
|
|
20077
20216
|
",\n"
|
|
20078
20217
|
);
|
|
20079
20218
|
}
|
|
20080
|
-
const
|
|
20081
|
-
let coordinate = coordTemplate || coordinateOverride || "0";
|
|
20082
|
-
if (context.instanceCoordPrefix && coordTemplate?.startsWith(context.instanceCoordPrefix + "/")) {
|
|
20083
|
-
coordinate = coordTemplate.slice(context.instanceCoordPrefix.length + 1);
|
|
20084
|
-
}
|
|
20085
|
-
if (context.insideFastForEach && coordinate.startsWith("$")) {
|
|
20086
|
-
const slashIndex = coordinate.indexOf("/");
|
|
20087
|
-
coordinate = slashIndex >= 0 ? coordinate.slice(slashIndex + 1) : "0";
|
|
20088
|
-
}
|
|
20089
|
-
if (context.slowForEachJayTrackBy && coordTemplate) {
|
|
20090
|
-
if (coordinate === context.slowForEachJayTrackBy) {
|
|
20091
|
-
coordinate = "";
|
|
20092
|
-
} else if (coordinate.startsWith(context.slowForEachJayTrackBy + "/")) {
|
|
20093
|
-
coordinate = coordinate.slice(context.slowForEachJayTrackBy.length + 1);
|
|
20094
|
-
}
|
|
20095
|
-
}
|
|
20219
|
+
const coordinate = element.getAttribute(COORD_ATTR) || coordinateOverride || "0";
|
|
20096
20220
|
const renderedRef = renderElementRef$1(element, renderContext);
|
|
20097
20221
|
if (hasInteractiveChildren) {
|
|
20098
20222
|
const childParts = [];
|
|
@@ -20182,12 +20306,23 @@ function renderHydrateElementContent(element, context, renderContext, coordinate
|
|
|
20182
20306
|
}
|
|
20183
20307
|
if (textFragment && !hasDynamicAttrs) {
|
|
20184
20308
|
const accessor = textFragment.rendered.replace(/^dt\(/, "").replace(/\)$/, "");
|
|
20185
|
-
|
|
20309
|
+
if (refName) {
|
|
20310
|
+
const refSuffix2 = renderedRef.rendered ? `, ${renderedRef.rendered}` : "";
|
|
20311
|
+
return new RenderFragment(
|
|
20312
|
+
`${indent.firstLine}adoptElement("${coordinate}", ${attributes2.rendered}, [adoptText("${coordinate}", ${accessor})]${refSuffix2})`,
|
|
20313
|
+
Imports.for(Import.adoptElement).plus(Import.adoptText).plus(textFragment.imports.minus(Import.dynamicText)).plus(renderedRef.imports).plus(attributes2.imports),
|
|
20314
|
+
[
|
|
20315
|
+
...textFragment.validations,
|
|
20316
|
+
...renderedRef.validations,
|
|
20317
|
+
...attributes2.validations
|
|
20318
|
+
],
|
|
20319
|
+
renderedRef.refs
|
|
20320
|
+
);
|
|
20321
|
+
}
|
|
20186
20322
|
return new RenderFragment(
|
|
20187
|
-
`${indent.firstLine}adoptText("${coordinate}", ${accessor}
|
|
20188
|
-
Imports.for(Import.adoptText).plus(textFragment.imports.minus(Import.dynamicText))
|
|
20189
|
-
[...textFragment.validations
|
|
20190
|
-
renderedRef.refs
|
|
20323
|
+
`${indent.firstLine}adoptText("${coordinate}", ${accessor})`,
|
|
20324
|
+
Imports.for(Import.adoptText).plus(textFragment.imports.minus(Import.dynamicText)),
|
|
20325
|
+
[...textFragment.validations]
|
|
20191
20326
|
);
|
|
20192
20327
|
}
|
|
20193
20328
|
if (hasDynamicAttrs) {
|
|
@@ -20255,7 +20390,6 @@ function renderHydrate(types2, body, importStatements, elementType, preRenderTyp
|
|
|
20255
20390
|
headlessInstanceCounter: { count: 0 },
|
|
20256
20391
|
insideFastForEach: false,
|
|
20257
20392
|
insideSlowForEach: false,
|
|
20258
|
-
varMappings: {},
|
|
20259
20393
|
interactivePaths: buildInteractivePaths(contract)
|
|
20260
20394
|
};
|
|
20261
20395
|
const rootElement = ensureSingleChildElement(body);
|
|
@@ -20468,7 +20602,7 @@ function renderChildCompProps$1(element, { variables }, contractProps) {
|
|
|
20468
20602
|
Object.keys(attributes2).forEach((attrName) => {
|
|
20469
20603
|
let attrCanonical = attrName.toLowerCase();
|
|
20470
20604
|
let attrKey = attrName.match(attributesRequiresQuotes$1) ? `"${attrName}"` : attrName;
|
|
20471
|
-
if (attrCanonical === "if" || attrCanonical === "foreach" || attrCanonical === "trackby" || attrCanonical === "jay-coordinate-base")
|
|
20605
|
+
if (attrCanonical === "if" || attrCanonical === "foreach" || attrCanonical === "trackby" || attrCanonical === "jay-coordinate-base" || attrCanonical === "jay-scope")
|
|
20472
20606
|
return;
|
|
20473
20607
|
if (attrCanonical === "props") {
|
|
20474
20608
|
isPropsDirectAssignment = true;
|
|
@@ -20742,8 +20876,9 @@ ${indent.curr}return ${childElement.rendered}}, '${trackBy}')`,
|
|
|
20742
20876
|
recursiveRegions: [],
|
|
20743
20877
|
isInsideGuard: false,
|
|
20744
20878
|
insideFastForEach: false,
|
|
20745
|
-
//
|
|
20746
|
-
|
|
20879
|
+
// Pass headless contract names through so nested headless instances
|
|
20880
|
+
// inside headfull FS component templates can be detected (DL#123)
|
|
20881
|
+
headlessContractNames: newContext.headlessContractNames
|
|
20747
20882
|
};
|
|
20748
20883
|
const renderedChildren = childNodes.map((_) => renderNode(_, childContext)).reduce(
|
|
20749
20884
|
(prev, current) => RenderFragment.merge(prev, current, ",\n"),
|
|
@@ -20779,7 +20914,8 @@ ${renderedChildren.rendered}
|
|
|
20779
20914
|
}
|
|
20780
20915
|
const isInsideForEach = newContext.insideFastForEach;
|
|
20781
20916
|
const coordinateSuffix = `${contractName}:${coordinateRef}`;
|
|
20782
|
-
const
|
|
20917
|
+
const instanceCoordBase = htmlElement.getAttribute("jay-coordinate-base");
|
|
20918
|
+
const coordinateKey2 = isInsideForEach ? void 0 : instanceCoordBase || [...newContext.coordinatePrefix, coordinateSuffix].join("/");
|
|
20783
20919
|
const renderFnCode = `
|
|
20784
20920
|
// Inline template for headless component: ${contractName} #${idx}
|
|
20785
20921
|
type ${elementType} = JayElement<${interactiveViewStateType}, ${refsTypeName}>;
|
|
@@ -21106,6 +21242,7 @@ function renderFunctionImplementation$1(types2, rootBodyElement, importStatement
|
|
|
21106
21242
|
const { importedSymbols, importedSandboxedSymbols } = processImportedComponents(importStatements);
|
|
21107
21243
|
const importedRefNameToRef = processImportedHeadless(headlessImports);
|
|
21108
21244
|
const headlessContractNames = new Set(headlessImports.map((h) => h.contractName));
|
|
21245
|
+
assignCoordinates(rootBodyElement, { headlessContractNames });
|
|
21109
21246
|
const rootElement = ensureSingleChildElement(rootBodyElement);
|
|
21110
21247
|
let renderedRoot;
|
|
21111
21248
|
const usedComponentImports = /* @__PURE__ */ new Set();
|
|
@@ -22094,28 +22231,16 @@ ${indent.firstLine}}`,
|
|
|
22094
22231
|
const arrayExpr = forEachAccessor.render().rendered;
|
|
22095
22232
|
const itemIndent = new Indent(indent.curr + " ");
|
|
22096
22233
|
const trackByExpr = `${forEachVariables.currentVar}.${trackBy}`;
|
|
22097
|
-
const slowPrefix = context.slowForEachCoordPrefix ? `'${context.slowForEachCoordPrefix}'` : void 0;
|
|
22098
|
-
const ancestorPrefix = context.forEachAccumulatedPrefix ?? slowPrefix;
|
|
22099
|
-
const currentTrackByPrefix = `escapeAttr(String(${trackByExpr}))`;
|
|
22100
|
-
const accumulatedPrefix = ancestorPrefix ? `${ancestorPrefix} + '/' + ${currentTrackByPrefix}` : currentTrackByPrefix;
|
|
22101
22234
|
const itemContext = {
|
|
22102
22235
|
...context,
|
|
22103
22236
|
variables: forEachVariables,
|
|
22104
22237
|
indent: itemIndent,
|
|
22105
22238
|
varMappings: { ...context.varMappings, [trackBy]: trackByExpr },
|
|
22106
|
-
insideForEach: true
|
|
22107
|
-
forEachAccumulatedPrefix: accumulatedPrefix,
|
|
22108
|
-
forEachAncestorPrefix: ancestorPrefix,
|
|
22109
|
-
slowForEachCoordPrefix: void 0
|
|
22110
|
-
// consumed by ancestorPrefix computation
|
|
22239
|
+
insideForEach: true
|
|
22111
22240
|
};
|
|
22112
22241
|
const openTag = renderServerOpenTag(element, itemContext, null);
|
|
22113
|
-
const
|
|
22114
|
-
const coordinateW = w(
|
|
22115
|
-
itemIndent,
|
|
22116
|
-
`' jay-coordinate="' + ${itemRootCoordExpr} + '">'`,
|
|
22117
|
-
Imports.for(Import.escapeAttr)
|
|
22118
|
-
);
|
|
22242
|
+
const itemCoord = element.getAttribute(COORD_ATTR);
|
|
22243
|
+
const coordinateW = itemCoord ? w(itemIndent, `' jay-coordinate="${itemCoord}">'`) : w(itemIndent, `'>'`);
|
|
22119
22244
|
const childNodes = filterContentNodes(element.childNodes);
|
|
22120
22245
|
const children = mergeServerFragments(
|
|
22121
22246
|
childNodes.map((child) => renderServerNode(child, itemContext))
|
|
@@ -22140,13 +22265,11 @@ ${indent.firstLine}}`,
|
|
|
22140
22265
|
const { accessor: arrayAccessor, childVariables: slowForEachVariables } = slowValidated;
|
|
22141
22266
|
const arrayExpr = arrayAccessor.render().rendered;
|
|
22142
22267
|
const itemVar = slowForEachVariables.currentVar;
|
|
22143
|
-
const slowCoordPrefix = context.slowForEachCoordPrefix ? `${context.slowForEachCoordPrefix}/${jayTrackBy}` : jayTrackBy;
|
|
22144
22268
|
const itemContext = {
|
|
22145
22269
|
...context,
|
|
22146
22270
|
variables: slowForEachVariables,
|
|
22147
22271
|
indent,
|
|
22148
|
-
insideSlowForEach: true
|
|
22149
|
-
slowForEachCoordPrefix: slowCoordPrefix
|
|
22272
|
+
insideSlowForEach: true
|
|
22150
22273
|
};
|
|
22151
22274
|
const childContent = renderServerElementContent(element, itemContext, {
|
|
22152
22275
|
isRoot: true
|
|
@@ -22158,8 +22281,7 @@ ${indent.firstLine}}`,
|
|
|
22158
22281
|
...context,
|
|
22159
22282
|
variables: slowForEachVariables,
|
|
22160
22283
|
indent: itemIndent,
|
|
22161
|
-
insideSlowForEach: true
|
|
22162
|
-
slowForEachCoordPrefix: slowCoordPrefix
|
|
22284
|
+
insideSlowForEach: true
|
|
22163
22285
|
};
|
|
22164
22286
|
const indentedContent = renderServerElementContent(element, indentedContext, {
|
|
22165
22287
|
isRoot: true
|
|
@@ -22195,11 +22317,8 @@ function renderServerHeadlessInstance(element, context, contractName) {
|
|
|
22195
22317
|
const trackByKeys = Object.keys(context.varMappings);
|
|
22196
22318
|
const trackByExpr = trackByKeys.length > 0 ? context.varMappings[trackByKeys[trackByKeys.length - 1]] : "undefined";
|
|
22197
22319
|
instanceKeyExpr = `String(${trackByExpr}) + ',${coordinateSuffix}'`;
|
|
22198
|
-
} else if (context.insideSlowForEach) {
|
|
22199
|
-
const prefix = coordSegments[0];
|
|
22200
|
-
instanceKeyExpr = `'${computeInstanceKey(coordinateSuffix, "slowForEach", prefix)}'`;
|
|
22201
22320
|
} else {
|
|
22202
|
-
instanceKeyExpr = `'${
|
|
22321
|
+
instanceKeyExpr = `'${instanceCoord}'`;
|
|
22203
22322
|
}
|
|
22204
22323
|
const ifCondition = element.attributes.if;
|
|
22205
22324
|
const componentVariables = new Variables(headlessImport.rootType, void 0, 0, varName);
|
|
@@ -22214,8 +22333,9 @@ function renderServerHeadlessInstance(element, context, contractName) {
|
|
|
22214
22333
|
...context,
|
|
22215
22334
|
variables: componentVariables,
|
|
22216
22335
|
indent: bodyIndent,
|
|
22217
|
-
//
|
|
22218
|
-
|
|
22336
|
+
// Pass headless contract names through so nested headless instances
|
|
22337
|
+
// inside headfull FS component templates can be detected (DL#123)
|
|
22338
|
+
headlessContractNames: context.headlessContractNames,
|
|
22219
22339
|
interactivePaths: buildInteractivePaths(headlessImport.contract)
|
|
22220
22340
|
};
|
|
22221
22341
|
const renderedChildren = mergeServerFragments(
|
|
@@ -22294,7 +22414,7 @@ function renderServerAttributes(element, context) {
|
|
|
22294
22414
|
)
|
|
22295
22415
|
);
|
|
22296
22416
|
} else {
|
|
22297
|
-
const escaped = attrValue
|
|
22417
|
+
const escaped = escapeForJsString(attrValue);
|
|
22298
22418
|
parts.push(w(indent, `' ${attrCanonical}="${escaped}"'`));
|
|
22299
22419
|
}
|
|
22300
22420
|
} else if (attrCanonical === "class") {
|
|
@@ -22309,7 +22429,7 @@ function renderServerAttributes(element, context) {
|
|
|
22309
22429
|
)
|
|
22310
22430
|
);
|
|
22311
22431
|
} else {
|
|
22312
|
-
const escaped = attrValue
|
|
22432
|
+
const escaped = escapeForJsString(attrValue);
|
|
22313
22433
|
parts.push(w(indent, `' class="${escaped}"'`));
|
|
22314
22434
|
}
|
|
22315
22435
|
} else if (attrCanonical === "style") {
|
|
@@ -22326,7 +22446,7 @@ function renderServerAttributes(element, context) {
|
|
|
22326
22446
|
)
|
|
22327
22447
|
);
|
|
22328
22448
|
} else {
|
|
22329
|
-
const escaped = attrValue
|
|
22449
|
+
const escaped = escapeForJsString(attrValue);
|
|
22330
22450
|
parts.push(w(indent, `' style="${escaped}"'`));
|
|
22331
22451
|
}
|
|
22332
22452
|
} else {
|
|
@@ -22343,7 +22463,7 @@ function renderServerAttributes(element, context) {
|
|
|
22343
22463
|
)
|
|
22344
22464
|
);
|
|
22345
22465
|
} else {
|
|
22346
|
-
const escaped = attrValue
|
|
22466
|
+
const escaped = escapeForJsString(attrValue);
|
|
22347
22467
|
parts.push(w(indent, `' ${attrCanonical}="${escaped}"'`));
|
|
22348
22468
|
}
|
|
22349
22469
|
}
|
|
@@ -22425,7 +22545,7 @@ function renderServerElementAsString(element, context, overrideCoordinate) {
|
|
|
22425
22545
|
}
|
|
22426
22546
|
}
|
|
22427
22547
|
const needsCoordinate = overrideCoordinate !== void 0 || dynamicTextFragment !== null || refName !== null || hasDynamicAttributeBindings(element, variables) || hasInteractiveChildElements(childNodes) || hasMixedContentDynamicText(childNodes);
|
|
22428
|
-
const coordTemplate = element.getAttribute(COORD_ATTR
|
|
22548
|
+
const coordTemplate = element.getAttribute(COORD_ATTR);
|
|
22429
22549
|
const coordinate = coordTemplate || (needsCoordinate ? overrideCoordinate || null : null);
|
|
22430
22550
|
const isVoid = voidElements.has(element.rawTagName.toLowerCase());
|
|
22431
22551
|
const closeTag = isVoid ? " />" : ">";
|
|
@@ -22492,7 +22612,7 @@ function renderServerAttributesAsString(element, context) {
|
|
|
22492
22612
|
)
|
|
22493
22613
|
);
|
|
22494
22614
|
} else {
|
|
22495
|
-
const escaped = attrValue
|
|
22615
|
+
const escaped = escapeForJsString(attrValue);
|
|
22496
22616
|
parts.push(new RenderFragment(`' ${attrCanonical}="${escaped}"'`));
|
|
22497
22617
|
}
|
|
22498
22618
|
} else if (attrCanonical === "class") {
|
|
@@ -22506,7 +22626,7 @@ function renderServerAttributesAsString(element, context) {
|
|
|
22506
22626
|
)
|
|
22507
22627
|
);
|
|
22508
22628
|
} else {
|
|
22509
|
-
const escaped = attrValue
|
|
22629
|
+
const escaped = escapeForJsString(attrValue);
|
|
22510
22630
|
parts.push(new RenderFragment(`' class="${escaped}"'`));
|
|
22511
22631
|
}
|
|
22512
22632
|
} else if (attrCanonical === "style") {
|
|
@@ -22522,7 +22642,7 @@ function renderServerAttributesAsString(element, context) {
|
|
|
22522
22642
|
)
|
|
22523
22643
|
);
|
|
22524
22644
|
} else {
|
|
22525
|
-
const escaped = attrValue
|
|
22645
|
+
const escaped = escapeForJsString(attrValue);
|
|
22526
22646
|
parts.push(new RenderFragment(`' style="${escaped}"'`));
|
|
22527
22647
|
}
|
|
22528
22648
|
} else {
|
|
@@ -22538,7 +22658,7 @@ function renderServerAttributesAsString(element, context) {
|
|
|
22538
22658
|
)
|
|
22539
22659
|
);
|
|
22540
22660
|
} else {
|
|
22541
|
-
const escaped = attrValue
|
|
22661
|
+
const escaped = escapeForJsString(attrValue);
|
|
22542
22662
|
parts.push(new RenderFragment(`' ${attrCanonical}="${escaped}"'`));
|
|
22543
22663
|
}
|
|
22544
22664
|
}
|
|
@@ -22610,7 +22730,7 @@ function renderServerElementContent(element, context, options) {
|
|
|
22610
22730
|
}
|
|
22611
22731
|
const refName = element.attributes.ref ? camelCase(element.attributes.ref) : null;
|
|
22612
22732
|
const needsCoordinate = options?.isRoot === true || isConditional(element) && conditionIsInteractive(element.getAttribute("if"), context.interactivePaths) || dynamicTextFragment !== null || refName !== null || hasDynamicAttributeBindings(element, variables) || hasInteractiveChildElements(childNodes) || hasMixedContentDynamicTextInteractive(childNodes, context.interactivePaths);
|
|
22613
|
-
const coordTemplate = needsCoordinate ? element.getAttribute(COORD_ATTR
|
|
22733
|
+
const coordTemplate = needsCoordinate ? element.getAttribute(COORD_ATTR) : null;
|
|
22614
22734
|
const isVoid = voidElements.has(element.rawTagName.toLowerCase());
|
|
22615
22735
|
const closeTag = isVoid ? " />" : ">";
|
|
22616
22736
|
const parts = [];
|
|
@@ -22620,38 +22740,7 @@ function renderServerElementContent(element, context, options) {
|
|
|
22620
22740
|
parts.push(attrs);
|
|
22621
22741
|
}
|
|
22622
22742
|
if (coordTemplate !== null) {
|
|
22623
|
-
|
|
22624
|
-
if (context.forEachAccumulatedPrefix) {
|
|
22625
|
-
parts.push(
|
|
22626
|
-
w(
|
|
22627
|
-
indent,
|
|
22628
|
-
`' jay-coordinate="' + ${context.forEachAccumulatedPrefix} + '/${coordTemplate}"${closeTag}'`,
|
|
22629
|
-
Imports.for(Import.escapeAttr)
|
|
22630
|
-
)
|
|
22631
|
-
);
|
|
22632
|
-
} else {
|
|
22633
|
-
parts.push(w(indent, `' jay-coordinate="${coordTemplate}"${closeTag}'`));
|
|
22634
|
-
}
|
|
22635
|
-
} else {
|
|
22636
|
-
const coordExpr = compileCoordinateExpr(coordTemplate, context.varMappings);
|
|
22637
|
-
if (context.forEachAncestorPrefix) {
|
|
22638
|
-
parts.push(
|
|
22639
|
-
w(
|
|
22640
|
-
indent,
|
|
22641
|
-
`' jay-coordinate="' + ${context.forEachAncestorPrefix} + '/' + ${coordExpr} + '"${closeTag}'`,
|
|
22642
|
-
Imports.for(Import.escapeAttr)
|
|
22643
|
-
)
|
|
22644
|
-
);
|
|
22645
|
-
} else {
|
|
22646
|
-
parts.push(
|
|
22647
|
-
w(
|
|
22648
|
-
indent,
|
|
22649
|
-
`' jay-coordinate="' + ${coordExpr} + '"${closeTag}'`,
|
|
22650
|
-
Imports.for(Import.escapeAttr)
|
|
22651
|
-
)
|
|
22652
|
-
);
|
|
22653
|
-
}
|
|
22654
|
-
}
|
|
22743
|
+
parts.push(w(indent, `' jay-coordinate="${coordTemplate}"${closeTag}'`));
|
|
22655
22744
|
} else {
|
|
22656
22745
|
parts.push(w(indent, `'${closeTag}'`));
|
|
22657
22746
|
}
|
|
@@ -29593,7 +29682,18 @@ const JAY_IMPORT_RESOLVER = {
|
|
|
29593
29682
|
const resolvedPath = src.startsWith(".") ? path.resolve(importingModuleDir, src) : src;
|
|
29594
29683
|
const jayHtmlPath = resolvedPath + ".jay-html";
|
|
29595
29684
|
try {
|
|
29596
|
-
|
|
29685
|
+
const content = fs$1.readFileSync(jayHtmlPath, "utf-8");
|
|
29686
|
+
return { content, componentDir: path.dirname(jayHtmlPath), filePath: jayHtmlPath };
|
|
29687
|
+
} catch {
|
|
29688
|
+
}
|
|
29689
|
+
const dirJayHtmlPath = path.resolve(resolvedPath, path.basename(resolvedPath)) + ".jay-html";
|
|
29690
|
+
try {
|
|
29691
|
+
const content = fs$1.readFileSync(dirJayHtmlPath, "utf-8");
|
|
29692
|
+
return {
|
|
29693
|
+
content,
|
|
29694
|
+
componentDir: path.dirname(dirJayHtmlPath),
|
|
29695
|
+
filePath: dirJayHtmlPath
|
|
29696
|
+
};
|
|
29597
29697
|
} catch {
|
|
29598
29698
|
return null;
|
|
29599
29699
|
}
|
|
@@ -29936,16 +30036,17 @@ function discoverHeadlessInstances(preRenderedJayHtml) {
|
|
|
29936
30036
|
if (!insidePreservedForEach) {
|
|
29937
30037
|
const hasUnresolvedProps = Object.values(props).some((v) => hasBindings(v));
|
|
29938
30038
|
if (!hasUnresolvedProps) {
|
|
29939
|
-
const prefix = buildCoordinatePrefix(element);
|
|
29940
30039
|
let ref = element.getAttribute("ref");
|
|
29941
30040
|
if (!ref) {
|
|
30041
|
+
const prefix = buildCoordinatePrefix(element);
|
|
29942
30042
|
const counterKey = [...prefix, contractName].join("/");
|
|
29943
30043
|
const localIndex = coordinateCounters.get(counterKey) ?? 0;
|
|
29944
30044
|
coordinateCounters.set(counterKey, localIndex + 1);
|
|
29945
30045
|
ref = `AR${localIndex}`;
|
|
29946
30046
|
element.setAttribute("ref", ref);
|
|
29947
30047
|
}
|
|
29948
|
-
const
|
|
30048
|
+
const coordBase = element.getAttribute("jay-coordinate-base");
|
|
30049
|
+
const coordinate = coordBase ? coordBase.split("/") : [...buildCoordinatePrefix(element), `${contractName}:${ref}`];
|
|
29949
30050
|
instances.push({
|
|
29950
30051
|
contractName,
|
|
29951
30052
|
props,
|
|
@@ -29971,6 +30072,11 @@ function discoverHeadlessInstances(preRenderedJayHtml) {
|
|
|
29971
30072
|
});
|
|
29972
30073
|
}
|
|
29973
30074
|
}
|
|
30075
|
+
for (const child of element.childNodes) {
|
|
30076
|
+
if (child.nodeType === NodeType.ELEMENT_NODE) {
|
|
30077
|
+
walk(child, insidePreservedForEach, forEachContexts);
|
|
30078
|
+
}
|
|
30079
|
+
}
|
|
29974
30080
|
return;
|
|
29975
30081
|
}
|
|
29976
30082
|
const updatedForEachContexts = hasForEach && forEachAttr && trackByAttr ? [...forEachContexts, { forEachPath: forEachAttr, trackBy: trackByAttr }] : forEachContexts;
|
|
@@ -30044,6 +30150,11 @@ function resolveHeadlessInstances(preRenderedJayHtml, instanceData, importResolv
|
|
|
30044
30150
|
}
|
|
30045
30151
|
}
|
|
30046
30152
|
}
|
|
30153
|
+
for (const child of element.childNodes) {
|
|
30154
|
+
if (child.nodeType === NodeType.ELEMENT_NODE) {
|
|
30155
|
+
walkAndResolve(child, insidePreservedForEach || hasForEach);
|
|
30156
|
+
}
|
|
30157
|
+
}
|
|
30047
30158
|
return;
|
|
30048
30159
|
}
|
|
30049
30160
|
for (const child of element.childNodes) {
|