@jay-framework/compiler-jay-html 0.15.5 → 0.15.6
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 +1906 -1798
- 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)
|
|
@@ -5372,1042 +4781,1791 @@ var DOMTokenList = (
|
|
|
5372
4781
|
if (valuesInit === void 0) {
|
|
5373
4782
|
valuesInit = [];
|
|
5374
4783
|
}
|
|
5375
|
-
if (afterUpdate === void 0) {
|
|
5376
|
-
afterUpdate = function() {
|
|
5377
|
-
return null;
|
|
5378
|
-
};
|
|
4784
|
+
if (afterUpdate === void 0) {
|
|
4785
|
+
afterUpdate = function() {
|
|
4786
|
+
return null;
|
|
4787
|
+
};
|
|
4788
|
+
}
|
|
4789
|
+
this._set = new Set(valuesInit);
|
|
4790
|
+
this._afterUpdate = afterUpdate;
|
|
4791
|
+
}
|
|
4792
|
+
DOMTokenList2.prototype._validate = function(c) {
|
|
4793
|
+
if (/\s/.test(c)) {
|
|
4794
|
+
throw new Error("DOMException in DOMTokenList.add: The token '".concat(c, "' contains HTML space characters, which are not valid in tokens."));
|
|
4795
|
+
}
|
|
4796
|
+
};
|
|
4797
|
+
DOMTokenList2.prototype.add = function(c) {
|
|
4798
|
+
this._validate(c);
|
|
4799
|
+
this._set.add(c);
|
|
4800
|
+
this._afterUpdate(this);
|
|
4801
|
+
};
|
|
4802
|
+
DOMTokenList2.prototype.replace = function(c1, c2) {
|
|
4803
|
+
this._validate(c2);
|
|
4804
|
+
this._set.delete(c1);
|
|
4805
|
+
this._set.add(c2);
|
|
4806
|
+
this._afterUpdate(this);
|
|
4807
|
+
};
|
|
4808
|
+
DOMTokenList2.prototype.remove = function(c) {
|
|
4809
|
+
this._set.delete(c) && this._afterUpdate(this);
|
|
4810
|
+
};
|
|
4811
|
+
DOMTokenList2.prototype.toggle = function(c) {
|
|
4812
|
+
this._validate(c);
|
|
4813
|
+
if (this._set.has(c))
|
|
4814
|
+
this._set.delete(c);
|
|
4815
|
+
else
|
|
4816
|
+
this._set.add(c);
|
|
4817
|
+
this._afterUpdate(this);
|
|
4818
|
+
};
|
|
4819
|
+
DOMTokenList2.prototype.contains = function(c) {
|
|
4820
|
+
return this._set.has(c);
|
|
4821
|
+
};
|
|
4822
|
+
Object.defineProperty(DOMTokenList2.prototype, "length", {
|
|
4823
|
+
get: function() {
|
|
4824
|
+
return this._set.size;
|
|
4825
|
+
},
|
|
4826
|
+
enumerable: false,
|
|
4827
|
+
configurable: true
|
|
4828
|
+
});
|
|
4829
|
+
DOMTokenList2.prototype.values = function() {
|
|
4830
|
+
return this._set.values();
|
|
4831
|
+
};
|
|
4832
|
+
Object.defineProperty(DOMTokenList2.prototype, "value", {
|
|
4833
|
+
get: function() {
|
|
4834
|
+
return Array.from(this._set.values());
|
|
4835
|
+
},
|
|
4836
|
+
enumerable: false,
|
|
4837
|
+
configurable: true
|
|
4838
|
+
});
|
|
4839
|
+
DOMTokenList2.prototype.toString = function() {
|
|
4840
|
+
return Array.from(this._set.values()).join(" ");
|
|
4841
|
+
};
|
|
4842
|
+
return DOMTokenList2;
|
|
4843
|
+
}()
|
|
4844
|
+
);
|
|
4845
|
+
var HTMLElement = (
|
|
4846
|
+
/** @class */
|
|
4847
|
+
function(_super) {
|
|
4848
|
+
__extends(HTMLElement2, _super);
|
|
4849
|
+
function HTMLElement2(tagName, keyAttrs, rawAttrs, parentNode, range, voidTag2, _parseOptions) {
|
|
4850
|
+
if (rawAttrs === void 0) {
|
|
4851
|
+
rawAttrs = "";
|
|
4852
|
+
}
|
|
4853
|
+
if (parentNode === void 0) {
|
|
4854
|
+
parentNode = null;
|
|
4855
|
+
}
|
|
4856
|
+
if (voidTag2 === void 0) {
|
|
4857
|
+
voidTag2 = new void_tag_1.default();
|
|
4858
|
+
}
|
|
4859
|
+
if (_parseOptions === void 0) {
|
|
4860
|
+
_parseOptions = {};
|
|
4861
|
+
}
|
|
4862
|
+
var _this = _super.call(this, parentNode, range) || this;
|
|
4863
|
+
_this.rawAttrs = rawAttrs;
|
|
4864
|
+
_this.voidTag = voidTag2;
|
|
4865
|
+
_this.nodeType = type_1$1.default.ELEMENT_NODE;
|
|
4866
|
+
_this.rawTagName = tagName;
|
|
4867
|
+
_this.rawAttrs = rawAttrs || "";
|
|
4868
|
+
_this.id = keyAttrs.id || "";
|
|
4869
|
+
_this.childNodes = [];
|
|
4870
|
+
_this._parseOptions = _parseOptions;
|
|
4871
|
+
_this.classList = new DOMTokenList(
|
|
4872
|
+
keyAttrs.class ? keyAttrs.class.split(/\s+/) : [],
|
|
4873
|
+
function(classList) {
|
|
4874
|
+
return _this.setAttribute("class", classList.toString());
|
|
4875
|
+
}
|
|
4876
|
+
// eslint-disable-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
|
4877
|
+
);
|
|
4878
|
+
if (keyAttrs.id) {
|
|
4879
|
+
if (!rawAttrs) {
|
|
4880
|
+
_this.rawAttrs = 'id="'.concat(keyAttrs.id, '"');
|
|
4881
|
+
}
|
|
4882
|
+
}
|
|
4883
|
+
if (keyAttrs.class) {
|
|
4884
|
+
if (!rawAttrs) {
|
|
4885
|
+
var cls = 'class="'.concat(_this.classList.toString(), '"');
|
|
4886
|
+
if (_this.rawAttrs) {
|
|
4887
|
+
_this.rawAttrs += " ".concat(cls);
|
|
4888
|
+
} else {
|
|
4889
|
+
_this.rawAttrs = cls;
|
|
4890
|
+
}
|
|
4891
|
+
}
|
|
4892
|
+
}
|
|
4893
|
+
return _this;
|
|
4894
|
+
}
|
|
4895
|
+
HTMLElement2.prototype.quoteAttribute = function(attr) {
|
|
4896
|
+
if (attr == null) {
|
|
4897
|
+
return "null";
|
|
4898
|
+
}
|
|
4899
|
+
return JSON.stringify(attr.replace(/"/g, """)).replace(/\\t/g, " ").replace(/\\n/g, "\n").replace(/\\r/g, "\r").replace(/\\/g, "");
|
|
4900
|
+
};
|
|
4901
|
+
HTMLElement2.prototype.removeChild = function(node2) {
|
|
4902
|
+
this.childNodes = this.childNodes.filter(function(child) {
|
|
4903
|
+
return child !== node2;
|
|
4904
|
+
});
|
|
4905
|
+
return this;
|
|
4906
|
+
};
|
|
4907
|
+
HTMLElement2.prototype.exchangeChild = function(oldNode, newNode) {
|
|
4908
|
+
var children = this.childNodes;
|
|
4909
|
+
this.childNodes = children.map(function(child) {
|
|
4910
|
+
if (child === oldNode) {
|
|
4911
|
+
return newNode;
|
|
4912
|
+
}
|
|
4913
|
+
return child;
|
|
4914
|
+
});
|
|
4915
|
+
return this;
|
|
4916
|
+
};
|
|
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 = {};
|
|
5379
5048
|
}
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
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)];
|
|
5386
5055
|
}
|
|
5056
|
+
resetParent(this.childNodes, null);
|
|
5057
|
+
resetParent(content, this);
|
|
5058
|
+
this.childNodes = content;
|
|
5059
|
+
return this;
|
|
5387
5060
|
};
|
|
5388
|
-
|
|
5389
|
-
this
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
this.
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
DOMTokenList2.prototype.contains = function(c) {
|
|
5411
|
-
return this._set.has(c);
|
|
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;
|
|
5412
5083
|
};
|
|
5413
|
-
Object.defineProperty(
|
|
5084
|
+
Object.defineProperty(HTMLElement2.prototype, "outerHTML", {
|
|
5414
5085
|
get: function() {
|
|
5415
|
-
return this.
|
|
5086
|
+
return this.toString();
|
|
5416
5087
|
},
|
|
5417
5088
|
enumerable: false,
|
|
5418
5089
|
configurable: true
|
|
5419
5090
|
});
|
|
5420
|
-
|
|
5421
|
-
|
|
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;
|
|
5422
5105
|
};
|
|
5423
|
-
Object.defineProperty(
|
|
5106
|
+
Object.defineProperty(HTMLElement2.prototype, "structure", {
|
|
5107
|
+
/**
|
|
5108
|
+
* Get DOM structure
|
|
5109
|
+
* @return {string} structure
|
|
5110
|
+
*/
|
|
5424
5111
|
get: function() {
|
|
5425
|
-
|
|
5112
|
+
var res = [];
|
|
5113
|
+
var indention = 0;
|
|
5114
|
+
function write(str2) {
|
|
5115
|
+
res.push(" ".repeat(indention) + str2);
|
|
5116
|
+
}
|
|
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");
|
|
5426
5135
|
},
|
|
5427
5136
|
enumerable: false,
|
|
5428
5137
|
configurable: true
|
|
5429
5138
|
});
|
|
5430
|
-
|
|
5431
|
-
|
|
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
|
+
});
|
|
5432
5161
|
};
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5440
|
-
|
|
5441
|
-
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5448
|
-
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
|
|
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
|
+
}
|
|
5452
5193
|
}
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
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;
|
|
5466
5209
|
}
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
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
|
+
}
|
|
5472
5219
|
}
|
|
5473
5220
|
}
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
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;
|
|
5479
5233
|
} else {
|
|
5480
|
-
|
|
5234
|
+
var child = mapChild.get(el_1);
|
|
5235
|
+
if (child) {
|
|
5236
|
+
elem = findOne2(test, [child]);
|
|
5237
|
+
}
|
|
5481
5238
|
}
|
|
5482
5239
|
}
|
|
5240
|
+
return elem;
|
|
5483
5241
|
}
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
return "null";
|
|
5242
|
+
while (el) {
|
|
5243
|
+
mapChild.set(el, old);
|
|
5244
|
+
old = el;
|
|
5245
|
+
el = el.parentNode;
|
|
5489
5246
|
}
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
|
|
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;
|
|
5503
5262
|
}
|
|
5504
|
-
|
|
5505
|
-
}
|
|
5506
|
-
return
|
|
5263
|
+
el = el.parentNode;
|
|
5264
|
+
}
|
|
5265
|
+
return null;
|
|
5507
5266
|
};
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
|
|
5513
|
-
|
|
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", {
|
|
5526
|
-
get: function() {
|
|
5527
|
-
return this.voidTag.isVoidElement(this.localName);
|
|
5528
|
-
},
|
|
5529
|
-
enumerable: false,
|
|
5530
|
-
configurable: true
|
|
5531
|
-
});
|
|
5532
|
-
Object.defineProperty(HTMLElement2.prototype, "rawText", {
|
|
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", {
|
|
5533
5274
|
/**
|
|
5534
|
-
* Get
|
|
5535
|
-
* @return {
|
|
5275
|
+
* Get first child node
|
|
5276
|
+
* @return {Node | undefined} first child node; or undefined if none
|
|
5536
5277
|
*/
|
|
5537
5278
|
get: function() {
|
|
5538
|
-
|
|
5539
|
-
return "\n";
|
|
5540
|
-
}
|
|
5541
|
-
return this.childNodes.reduce(function(pre, cur) {
|
|
5542
|
-
return pre += cur.rawText;
|
|
5543
|
-
}, "");
|
|
5544
|
-
},
|
|
5545
|
-
enumerable: false,
|
|
5546
|
-
configurable: true
|
|
5547
|
-
});
|
|
5548
|
-
Object.defineProperty(HTMLElement2.prototype, "textContent", {
|
|
5549
|
-
get: function() {
|
|
5550
|
-
return decode(this.rawText);
|
|
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
|
-
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
|
-
}
|
|
5301
|
+
get: function() {
|
|
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
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
}
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
var children = this.parentNode.childNodes;
|
|
6088
|
-
var i = children.length;
|
|
6089
|
-
while (i > 0) {
|
|
6090
|
-
var child = children[--i];
|
|
6091
|
-
if (this === child)
|
|
6092
|
-
return children[i - 1] || null;
|
|
6093
|
-
}
|
|
6094
|
-
return null;
|
|
6095
|
-
}
|
|
6096
|
-
},
|
|
6097
|
-
enumerable: false,
|
|
6098
|
-
configurable: true
|
|
6099
|
-
});
|
|
6100
|
-
Object.defineProperty(HTMLElement2.prototype, "previousElementSibling", {
|
|
6101
|
-
get: function() {
|
|
6102
|
-
if (this.parentNode) {
|
|
6103
|
-
var children = this.parentNode.childNodes;
|
|
6104
|
-
var i = children.length;
|
|
6105
|
-
var find2 = false;
|
|
6106
|
-
while (i > 0) {
|
|
6107
|
-
var child = children[--i];
|
|
6108
|
-
if (find2) {
|
|
6109
|
-
if (child instanceof HTMLElement2) {
|
|
6110
|
-
return child || null;
|
|
6111
|
-
}
|
|
6112
|
-
} else if (this === child) {
|
|
6113
|
-
find2 = true;
|
|
6114
|
-
}
|
|
6115
|
-
}
|
|
6116
|
-
return null;
|
|
6117
|
-
}
|
|
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 }
|
|
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);
|
|
6161
6103
|
};
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
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 }
|
|
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;
|
|
6177
6107
|
};
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
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) {
|
|
6181
6114
|
if (options === void 0) {
|
|
6182
6115
|
options = {};
|
|
6183
6116
|
}
|
|
6184
|
-
var
|
|
6185
|
-
var
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
return
|
|
6197
|
-
|
|
6198
|
-
return
|
|
6199
|
-
});
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
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 = {};
|
|
6204
6156
|
}
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
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 = {};
|
|
6209
6168
|
}
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
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
|
-
}
|
|
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;
|
|
6233
6178
|
}
|
|
6234
|
-
|
|
6235
|
-
|
|
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) {
|
|
6236
6203
|
continue;
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
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(".") });
|
|
6220
|
+
}
|
|
6221
|
+
if (isAsync) {
|
|
6222
|
+
asyncProps.push({ path: currentPath.join(".") });
|
|
6223
|
+
}
|
|
6224
|
+
}
|
|
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
|
+
};
|
|
6246
|
+
}
|
|
6247
|
+
}
|
|
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(".") });
|
|
6268
|
+
}
|
|
6269
|
+
}
|
|
6270
|
+
}
|
|
6271
|
+
}
|
|
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)) {
|
|
@@ -14243,6 +14401,7 @@ const DIRECTIVE_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
|
14243
14401
|
"jayindex",
|
|
14244
14402
|
"jaytrackby",
|
|
14245
14403
|
"jay-coordinate-base",
|
|
14404
|
+
"jay-scope",
|
|
14246
14405
|
AsyncDirectiveTypes.loading.directive,
|
|
14247
14406
|
AsyncDirectiveTypes.resolved.directive,
|
|
14248
14407
|
AsyncDirectiveTypes.rejected.directive
|
|
@@ -14296,7 +14455,8 @@ function isValidationError(result) {
|
|
|
14296
14455
|
return result instanceof RenderFragment;
|
|
14297
14456
|
}
|
|
14298
14457
|
function resolveHeadlessImport(contractName, headlessImports) {
|
|
14299
|
-
const
|
|
14458
|
+
const lowerName = contractName.toLowerCase();
|
|
14459
|
+
const headlessImport = headlessImports.find((h) => h.contractName === lowerName);
|
|
14300
14460
|
if (!headlessImport) {
|
|
14301
14461
|
return new RenderFragment("", Imports.none(), [
|
|
14302
14462
|
`No headless import found for contract "${contractName}"`
|
|
@@ -14305,15 +14465,17 @@ function resolveHeadlessImport(contractName, headlessImports) {
|
|
|
14305
14465
|
return headlessImport;
|
|
14306
14466
|
}
|
|
14307
14467
|
function extractHeadlessCoordinate(element, contractName) {
|
|
14308
|
-
const instanceCoord = element.getAttribute(COORD_ATTR
|
|
14468
|
+
const instanceCoord = element.getAttribute(COORD_ATTR);
|
|
14309
14469
|
if (!instanceCoord) {
|
|
14310
14470
|
return new RenderFragment("", Imports.none(), [
|
|
14311
14471
|
`Headless instance <jay:${contractName}> missing jay-coordinate-base — run assignCoordinates first`
|
|
14312
14472
|
]);
|
|
14313
14473
|
}
|
|
14314
14474
|
const coordSegments = instanceCoord.split("/");
|
|
14315
|
-
const
|
|
14316
|
-
|
|
14475
|
+
const lowerName = contractName.toLowerCase();
|
|
14476
|
+
const coordinateSuffix = coordSegments.find((s) => s.startsWith(lowerName + ":")) || `${lowerName}:0`;
|
|
14477
|
+
const childScopeId = element.getAttribute("jay-scope") || void 0;
|
|
14478
|
+
return { instanceCoord, coordSegments, coordinateSuffix, childScopeId };
|
|
14317
14479
|
}
|
|
14318
14480
|
function buildContractRefMap(refsTree) {
|
|
14319
14481
|
const result = /* @__PURE__ */ new Map();
|
|
@@ -14337,7 +14499,7 @@ function buildContractRefMap(refsTree) {
|
|
|
14337
14499
|
walk(refsTree);
|
|
14338
14500
|
return result;
|
|
14339
14501
|
}
|
|
14340
|
-
const COORD_ATTR
|
|
14502
|
+
const COORD_ATTR = "jay-coordinate-base";
|
|
14341
14503
|
function expandContractType(renderedElement, baseName) {
|
|
14342
14504
|
const contractPattern = new RegExp(
|
|
14343
14505
|
`export type ${baseName}Contract = JayContract<([^,]+), ${baseName}ElementRefs>;`,
|
|
@@ -14541,144 +14703,6 @@ ${renderedRefsManager}
|
|
|
14541
14703
|
renderedBridge.refs
|
|
14542
14704
|
);
|
|
14543
14705
|
}
|
|
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
14706
|
/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */
|
|
14683
14707
|
function isNothing(subject) {
|
|
14684
14708
|
return typeof subject === "undefined" || subject === null;
|
|
@@ -18234,6 +18258,10 @@ function injectHeadfullFSTemplates(html2, sourceDir, importResolver) {
|
|
|
18234
18258
|
const body = root.querySelector("body");
|
|
18235
18259
|
if (!body)
|
|
18236
18260
|
return html2;
|
|
18261
|
+
injectHeadfullFSTemplatesRecursive(fsElements, body, sourceDir, importResolver, /* @__PURE__ */ new Set());
|
|
18262
|
+
return root.toString();
|
|
18263
|
+
}
|
|
18264
|
+
function injectHeadfullFSTemplatesRecursive(fsElements, body, sourceDir, importResolver, visited) {
|
|
18237
18265
|
for (const element of fsElements) {
|
|
18238
18266
|
const src = element.getAttribute("src");
|
|
18239
18267
|
const rawNames = element.getAttribute("names");
|
|
@@ -18243,13 +18271,28 @@ function injectHeadfullFSTemplates(html2, sourceDir, importResolver) {
|
|
|
18243
18271
|
if (names.length === 0)
|
|
18244
18272
|
continue;
|
|
18245
18273
|
const contractName = (names[0].as || names[0].name).toLowerCase();
|
|
18246
|
-
const
|
|
18247
|
-
if (
|
|
18274
|
+
const resolvedSrc = path.resolve(sourceDir, src);
|
|
18275
|
+
if (visited.has(resolvedSrc))
|
|
18276
|
+
continue;
|
|
18277
|
+
visited.add(resolvedSrc);
|
|
18278
|
+
const jayHtmlResult = importResolver.readJayHtml(sourceDir, src);
|
|
18279
|
+
if (!jayHtmlResult)
|
|
18248
18280
|
continue;
|
|
18249
|
-
const jayHtmlRoot = parse_2(
|
|
18281
|
+
const jayHtmlRoot = parse_2(jayHtmlResult.content);
|
|
18250
18282
|
const jayHtmlBody = jayHtmlRoot.querySelector("body");
|
|
18251
18283
|
if (!jayHtmlBody)
|
|
18252
18284
|
continue;
|
|
18285
|
+
const nestedHeadfullElements = jayHtmlRoot.querySelectorAll('script[type="application/jay-headfull"]').filter((el) => el.getAttribute("contract"));
|
|
18286
|
+
if (nestedHeadfullElements.length > 0) {
|
|
18287
|
+
const childDir = jayHtmlResult.componentDir;
|
|
18288
|
+
injectHeadfullFSTemplatesRecursive(
|
|
18289
|
+
nestedHeadfullElements,
|
|
18290
|
+
jayHtmlBody,
|
|
18291
|
+
childDir,
|
|
18292
|
+
importResolver,
|
|
18293
|
+
visited
|
|
18294
|
+
);
|
|
18295
|
+
}
|
|
18253
18296
|
const jayTags = body.querySelectorAll("*").filter((el) => el.tagName?.toLowerCase() === `jay:${contractName}`);
|
|
18254
18297
|
for (const jayTag of jayTags) {
|
|
18255
18298
|
if (!jayTag.innerHTML.trim()) {
|
|
@@ -18257,12 +18300,12 @@ function injectHeadfullFSTemplates(html2, sourceDir, importResolver) {
|
|
|
18257
18300
|
}
|
|
18258
18301
|
}
|
|
18259
18302
|
}
|
|
18260
|
-
return root.toString();
|
|
18261
18303
|
}
|
|
18262
|
-
async function parseHeadfullFSImports(elements, validations, filePath, importResolver, body, projectRoot) {
|
|
18304
|
+
async function parseHeadfullFSImports(elements, validations, filePath, importResolver, body, projectRoot, visited = /* @__PURE__ */ new Set(), sourceDir) {
|
|
18263
18305
|
const headlessImports = [];
|
|
18264
18306
|
const cssParts = [];
|
|
18265
18307
|
const linkedCssFiles = [];
|
|
18308
|
+
const linkedComponentFiles = [];
|
|
18266
18309
|
for (const element of elements) {
|
|
18267
18310
|
const src = element.getAttribute("src");
|
|
18268
18311
|
const contractAttr = element.getAttribute("contract");
|
|
@@ -18287,7 +18330,37 @@ async function parseHeadfullFSImports(elements, validations, filePath, importRes
|
|
|
18287
18330
|
}
|
|
18288
18331
|
const componentExportName = names[0].name;
|
|
18289
18332
|
const contractName = (names[0].as || componentExportName).toLowerCase();
|
|
18290
|
-
|
|
18333
|
+
const resolvedSrc = path.resolve(filePath, src);
|
|
18334
|
+
if (visited.has(resolvedSrc)) {
|
|
18335
|
+
validations.push(
|
|
18336
|
+
`Circular headfull FS import detected: ${src} has already been processed`
|
|
18337
|
+
);
|
|
18338
|
+
continue;
|
|
18339
|
+
}
|
|
18340
|
+
visited.add(resolvedSrc);
|
|
18341
|
+
const resolveDir = sourceDir || filePath;
|
|
18342
|
+
let jayHtmlResult = importResolver.readJayHtml(resolveDir, src);
|
|
18343
|
+
let moduleResolveDir = resolveDir;
|
|
18344
|
+
if (jayHtmlResult === null && resolveDir !== filePath) {
|
|
18345
|
+
jayHtmlResult = importResolver.readJayHtml(filePath, src);
|
|
18346
|
+
if (jayHtmlResult !== null) {
|
|
18347
|
+
moduleResolveDir = filePath;
|
|
18348
|
+
}
|
|
18349
|
+
}
|
|
18350
|
+
if (jayHtmlResult === null && projectRoot && projectRoot !== filePath && projectRoot !== resolveDir) {
|
|
18351
|
+
jayHtmlResult = importResolver.readJayHtml(projectRoot, src);
|
|
18352
|
+
if (jayHtmlResult !== null) {
|
|
18353
|
+
moduleResolveDir = projectRoot;
|
|
18354
|
+
}
|
|
18355
|
+
}
|
|
18356
|
+
if (jayHtmlResult === null) {
|
|
18357
|
+
validations.push(
|
|
18358
|
+
`jay-html file not found for headfull FS component ${src} (expected ${src}.jay-html)`
|
|
18359
|
+
);
|
|
18360
|
+
continue;
|
|
18361
|
+
}
|
|
18362
|
+
linkedComponentFiles.push(jayHtmlResult.filePath);
|
|
18363
|
+
let contractPath = path.resolve(resolveDir, contractAttr);
|
|
18291
18364
|
let loadedContract;
|
|
18292
18365
|
try {
|
|
18293
18366
|
const contractResult = importResolver.loadContract(contractPath);
|
|
@@ -18297,6 +18370,7 @@ async function parseHeadfullFSImports(elements, validations, filePath, importRes
|
|
|
18297
18370
|
}
|
|
18298
18371
|
loadedContract = contractResult.val;
|
|
18299
18372
|
} catch (e2) {
|
|
18373
|
+
let resolved = false;
|
|
18300
18374
|
if (projectRoot && projectRoot !== filePath) {
|
|
18301
18375
|
try {
|
|
18302
18376
|
contractPath = path.resolve(projectRoot, contractAttr);
|
|
@@ -18306,36 +18380,37 @@ async function parseHeadfullFSImports(elements, validations, filePath, importRes
|
|
|
18306
18380
|
continue;
|
|
18307
18381
|
}
|
|
18308
18382
|
loadedContract = fallbackResult.val;
|
|
18309
|
-
|
|
18383
|
+
resolved = true;
|
|
18384
|
+
} catch {
|
|
18385
|
+
}
|
|
18386
|
+
}
|
|
18387
|
+
if (!resolved) {
|
|
18388
|
+
try {
|
|
18389
|
+
contractPath = path.resolve(
|
|
18390
|
+
jayHtmlResult.componentDir,
|
|
18391
|
+
path.basename(contractAttr)
|
|
18392
|
+
);
|
|
18393
|
+
const fallbackResult = importResolver.loadContract(contractPath);
|
|
18394
|
+
validations.push(...fallbackResult.validations);
|
|
18395
|
+
if (!fallbackResult.val) {
|
|
18396
|
+
continue;
|
|
18397
|
+
}
|
|
18398
|
+
loadedContract = fallbackResult.val;
|
|
18399
|
+
} catch (e3) {
|
|
18310
18400
|
validations.push(
|
|
18311
|
-
`Failed to load contract for headfull FS component ${src}: ${
|
|
18401
|
+
`Failed to load contract for headfull FS component ${src}: ${e3.message}`
|
|
18312
18402
|
);
|
|
18313
18403
|
continue;
|
|
18314
18404
|
}
|
|
18315
|
-
} else {
|
|
18316
|
-
validations.push(
|
|
18317
|
-
`Failed to load contract for headfull FS component ${src}: ${e2.message}`
|
|
18318
|
-
);
|
|
18319
|
-
continue;
|
|
18320
18405
|
}
|
|
18321
18406
|
}
|
|
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);
|
|
18407
|
+
const jayHtmlRoot = parse_2(jayHtmlResult.content);
|
|
18333
18408
|
const jayHtmlBody = jayHtmlRoot.querySelector("body");
|
|
18334
18409
|
if (!jayHtmlBody) {
|
|
18335
18410
|
validations.push(`headfull FS component ${src} jay-html must have a body tag`);
|
|
18336
18411
|
continue;
|
|
18337
18412
|
}
|
|
18338
|
-
const componentDir =
|
|
18413
|
+
const componentDir = jayHtmlResult.componentDir;
|
|
18339
18414
|
const componentCssResult = await extractCss(jayHtmlRoot, componentDir);
|
|
18340
18415
|
validations.push(...componentCssResult.validations);
|
|
18341
18416
|
if (componentCssResult.val?.css) {
|
|
@@ -18344,6 +18419,55 @@ async function parseHeadfullFSImports(elements, validations, filePath, importRes
|
|
|
18344
18419
|
if (componentCssResult.val?.linkedCssFiles) {
|
|
18345
18420
|
linkedCssFiles.push(...componentCssResult.val.linkedCssFiles);
|
|
18346
18421
|
}
|
|
18422
|
+
const nestedHeadlessElements = jayHtmlRoot.querySelectorAll(
|
|
18423
|
+
'script[type="application/jay-headless"]'
|
|
18424
|
+
);
|
|
18425
|
+
if (nestedHeadlessElements.length > 0) {
|
|
18426
|
+
const nestedHeadless = await parseHeadlessImports(
|
|
18427
|
+
nestedHeadlessElements,
|
|
18428
|
+
validations,
|
|
18429
|
+
filePath,
|
|
18430
|
+
importResolver,
|
|
18431
|
+
projectRoot
|
|
18432
|
+
);
|
|
18433
|
+
headlessImports.push(...nestedHeadless);
|
|
18434
|
+
}
|
|
18435
|
+
const nestedHeadfullFSElements = jayHtmlRoot.querySelectorAll('script[type="application/jay-headfull"]').filter((el) => el.getAttribute("contract"));
|
|
18436
|
+
if (nestedHeadfullFSElements.length > 0) {
|
|
18437
|
+
for (const nestedEl of nestedHeadfullFSElements) {
|
|
18438
|
+
const nestedSrc = nestedEl.getAttribute("src");
|
|
18439
|
+
if (nestedSrc) {
|
|
18440
|
+
const absoluteSrc = path.resolve(componentDir, nestedSrc);
|
|
18441
|
+
let relativeSrc = path.relative(filePath, absoluteSrc);
|
|
18442
|
+
if (!relativeSrc.startsWith("."))
|
|
18443
|
+
relativeSrc = "./" + relativeSrc;
|
|
18444
|
+
nestedEl.setAttribute("src", relativeSrc);
|
|
18445
|
+
}
|
|
18446
|
+
const nestedContract = nestedEl.getAttribute("contract");
|
|
18447
|
+
if (nestedContract) {
|
|
18448
|
+
const absoluteContract = path.resolve(componentDir, nestedContract);
|
|
18449
|
+
let relativeContract = path.relative(filePath, absoluteContract);
|
|
18450
|
+
if (!relativeContract.startsWith("."))
|
|
18451
|
+
relativeContract = "./" + relativeContract;
|
|
18452
|
+
nestedEl.setAttribute("contract", relativeContract);
|
|
18453
|
+
}
|
|
18454
|
+
}
|
|
18455
|
+
const nestedResult = await parseHeadfullFSImports(
|
|
18456
|
+
nestedHeadfullFSElements,
|
|
18457
|
+
validations,
|
|
18458
|
+
filePath,
|
|
18459
|
+
importResolver,
|
|
18460
|
+
jayHtmlBody,
|
|
18461
|
+
projectRoot,
|
|
18462
|
+
visited
|
|
18463
|
+
);
|
|
18464
|
+
headlessImports.push(...nestedResult.headlessImports);
|
|
18465
|
+
if (nestedResult.css) {
|
|
18466
|
+
cssParts.push(nestedResult.css);
|
|
18467
|
+
}
|
|
18468
|
+
linkedCssFiles.push(...nestedResult.linkedCssFiles);
|
|
18469
|
+
linkedComponentFiles.push(...nestedResult.linkedComponentFiles);
|
|
18470
|
+
}
|
|
18347
18471
|
const jayTags = body.querySelectorAll("*").filter((el) => el.tagName?.toLowerCase() === `jay:${contractName}`);
|
|
18348
18472
|
for (const jayTag of jayTags) {
|
|
18349
18473
|
const existingContent = jayTag.innerHTML.trim();
|
|
@@ -18413,7 +18537,6 @@ async function parseHeadfullFSImports(elements, validations, filePath, importRes
|
|
|
18413
18537
|
}))
|
|
18414
18538
|
}));
|
|
18415
18539
|
const contractLinks = [contractLink, ...enumImportLinks];
|
|
18416
|
-
const moduleResolveDir = projectRoot && projectRoot !== filePath ? projectRoot : filePath;
|
|
18417
18540
|
let relativeModule = path.relative(
|
|
18418
18541
|
filePath,
|
|
18419
18542
|
importResolver.resolveLink(moduleResolveDir, src)
|
|
@@ -18449,7 +18572,8 @@ async function parseHeadfullFSImports(elements, validations, filePath, importRes
|
|
|
18449
18572
|
return {
|
|
18450
18573
|
headlessImports,
|
|
18451
18574
|
css: cssParts.length > 0 ? cssParts.join("\n\n") : void 0,
|
|
18452
|
-
linkedCssFiles
|
|
18575
|
+
linkedCssFiles,
|
|
18576
|
+
linkedComponentFiles
|
|
18453
18577
|
};
|
|
18454
18578
|
}
|
|
18455
18579
|
function normalizeFilename(filename) {
|
|
@@ -18541,7 +18665,7 @@ function extractTrackByMaps(pageContract, headlessImports) {
|
|
|
18541
18665
|
}
|
|
18542
18666
|
return { serverTrackByMap, clientTrackByMap };
|
|
18543
18667
|
}
|
|
18544
|
-
async function parseJayFile(html2, filename, filePath, options, linkedContractResolver, projectRoot) {
|
|
18668
|
+
async function parseJayFile(html2, filename, filePath, options, linkedContractResolver, projectRoot, sourceDir) {
|
|
18545
18669
|
const normalizedFileName = normalizeFilename(filename);
|
|
18546
18670
|
const baseElementName = capitalCase(normalizedFileName, { delimiter: "" });
|
|
18547
18671
|
const root = parse_2(html2);
|
|
@@ -18572,7 +18696,10 @@ async function parseJayFile(html2, filename, filePath, options, linkedContractRe
|
|
|
18572
18696
|
filePath,
|
|
18573
18697
|
linkedContractResolver,
|
|
18574
18698
|
body,
|
|
18575
|
-
projectRoot
|
|
18699
|
+
projectRoot,
|
|
18700
|
+
void 0,
|
|
18701
|
+
// visited
|
|
18702
|
+
sourceDir
|
|
18576
18703
|
);
|
|
18577
18704
|
const headlessImports = await parseHeadlessImports(
|
|
18578
18705
|
root.querySelectorAll('script[type="application/jay-headless"]'),
|
|
@@ -18617,6 +18744,7 @@ async function parseJayFile(html2, filename, filePath, options, linkedContractRe
|
|
|
18617
18744
|
if (headfullFSResult.linkedCssFiles.length > 0) {
|
|
18618
18745
|
allLinkedCssFiles = [...allLinkedCssFiles, ...headfullFSResult.linkedCssFiles];
|
|
18619
18746
|
}
|
|
18747
|
+
const allLinkedComponentFiles = headfullFSResult.linkedComponentFiles;
|
|
18620
18748
|
const { serverTrackByMap, clientTrackByMap } = extractTrackByMaps(
|
|
18621
18749
|
jayYaml.parsedContract,
|
|
18622
18750
|
allHeadlessImports
|
|
@@ -18633,6 +18761,7 @@ async function parseJayFile(html2, filename, filePath, options, linkedContractRe
|
|
|
18633
18761
|
headLinks,
|
|
18634
18762
|
css,
|
|
18635
18763
|
linkedCssFiles: allLinkedCssFiles.length > 0 ? allLinkedCssFiles : void 0,
|
|
18764
|
+
linkedComponentFiles: allLinkedComponentFiles.length > 0 ? allLinkedComponentFiles : void 0,
|
|
18636
18765
|
filename: normalizedFileName,
|
|
18637
18766
|
contract: jayYaml.parsedContract,
|
|
18638
18767
|
contractRef: jayYaml.contractRef,
|
|
@@ -19342,6 +19471,9 @@ function parseContract(contractYaml, fileName) {
|
|
|
19342
19471
|
}
|
|
19343
19472
|
const contract = {
|
|
19344
19473
|
name: parsedYaml.name,
|
|
19474
|
+
...typeof parsedYaml.description === "string" && {
|
|
19475
|
+
description: parsedYaml.description
|
|
19476
|
+
},
|
|
19345
19477
|
tags: parsedTags,
|
|
19346
19478
|
...parsedProps && parsedProps.length > 0 && { props: parsedProps },
|
|
19347
19479
|
...parsedParams && parsedParams.length > 0 && { params: parsedParams }
|
|
@@ -19471,7 +19603,7 @@ function renderHydrateElement(element, context) {
|
|
|
19471
19603
|
context.interactivePaths
|
|
19472
19604
|
);
|
|
19473
19605
|
const renderedCondition = parseCondition(condition, context.variables);
|
|
19474
|
-
const coordinate = element.getAttribute(COORD_ATTR
|
|
19606
|
+
const coordinate = element.getAttribute(COORD_ATTR) || "0";
|
|
19475
19607
|
const childContent = renderHydrateElementContent(
|
|
19476
19608
|
element,
|
|
19477
19609
|
context,
|
|
@@ -19501,11 +19633,13 @@ function renderHydrateElement(element, context) {
|
|
|
19501
19633
|
);
|
|
19502
19634
|
const createElementFunc = needDynamicElement ? "de" : "e";
|
|
19503
19635
|
const createElementImport = needDynamicElement ? Import.dynamicElement : Import.element;
|
|
19504
|
-
const
|
|
19636
|
+
const createRef = renderElementRef$1(element, createRenderContext);
|
|
19637
|
+
const createRefSuffix = createRef.rendered ? `, ${createRef.rendered}` : "";
|
|
19638
|
+
const createBody = `() => ${createElementFunc}('${element.rawTagName}', ${createAttributes.rendered}, [${createChildren.rendered}]${createRefSuffix})`;
|
|
19505
19639
|
return new RenderFragment(
|
|
19506
19640
|
`${context.indent.firstLine}hydrateConditional(${renderedCondition.rendered}, ${adoptBody},
|
|
19507
19641
|
${context.indent.firstLine} ${createBody})`,
|
|
19508
|
-
Imports.for(Import.hydrateConditional).plus(createElementImport).plus(renderedCondition.imports).plus(childContent.imports).plus(createChildren.imports).plus(createAttributes.imports),
|
|
19642
|
+
Imports.for(Import.hydrateConditional).plus(createElementImport).plus(renderedCondition.imports).plus(childContent.imports).plus(createChildren.imports).plus(createAttributes.imports).plus(createRef.imports),
|
|
19509
19643
|
[
|
|
19510
19644
|
...renderedCondition.validations,
|
|
19511
19645
|
...childContent.validations,
|
|
@@ -19527,15 +19661,14 @@ ${context.indent.firstLine} ${createBody})`,
|
|
|
19527
19661
|
const forEachFragment = forEachAccessor.render().map((_) => `(${paramName}: ${paramType}) => ${_}`);
|
|
19528
19662
|
const preAdoptRefNameGenerator = context.refNameGenerator.clone();
|
|
19529
19663
|
const itemChildNodes = filterContentNodes(element.childNodes);
|
|
19530
|
-
|
|
19664
|
+
`${forEachVariables.currentVar}.${trackBy}`;
|
|
19531
19665
|
const itemContext = {
|
|
19532
19666
|
...context,
|
|
19533
19667
|
variables: forEachVariables,
|
|
19534
19668
|
indent: indent.child().child(),
|
|
19535
19669
|
dynamicRef: true,
|
|
19536
19670
|
// Refs inside forEach are collection refs
|
|
19537
|
-
insideFastForEach: true
|
|
19538
|
-
varMappings: { ...context.varMappings, [trackBy]: trackByExpr }
|
|
19671
|
+
insideFastForEach: true
|
|
19539
19672
|
};
|
|
19540
19673
|
const itemRenderCtx = buildRenderContext(itemContext);
|
|
19541
19674
|
const itemAttrs = renderDynamicAttributes(element, itemRenderCtx);
|
|
@@ -19594,12 +19727,13 @@ ${context.indent.firstLine} ${createBody})`,
|
|
|
19594
19727
|
}
|
|
19595
19728
|
}
|
|
19596
19729
|
}
|
|
19730
|
+
const itemRootCoord2 = element.getAttribute(COORD_ATTR) || "";
|
|
19597
19731
|
const refSuffix = itemRefFragment.rendered ? `, ${itemRefFragment.rendered}` : "";
|
|
19598
19732
|
const childrenArr = childParts.length ? `[
|
|
19599
19733
|
${childParts.join(",\n")},
|
|
19600
19734
|
${indent.firstLine} ]` : "[]";
|
|
19601
19735
|
adoptBody = `() => [
|
|
19602
|
-
${indent.firstLine} adoptDynamicElement("", ${itemAttrs.rendered}, ${childrenArr}${refSuffix}),
|
|
19736
|
+
${indent.firstLine} adoptDynamicElement("${itemRootCoord2}", ${itemAttrs.rendered}, ${childrenArr}${refSuffix}),
|
|
19603
19737
|
${indent.firstLine} ]`;
|
|
19604
19738
|
itemContent = new RenderFragment(
|
|
19605
19739
|
"",
|
|
@@ -19613,12 +19747,13 @@ ${indent.firstLine} ]`;
|
|
|
19613
19747
|
",\n"
|
|
19614
19748
|
);
|
|
19615
19749
|
if (needsItemAdoption) {
|
|
19750
|
+
const itemRootCoord = element.getAttribute(COORD_ATTR) || "";
|
|
19616
19751
|
const refSuffix = itemRefFragment.rendered ? `, ${itemRefFragment.rendered}` : "";
|
|
19617
19752
|
const childrenArr = itemContent.rendered.trim() ? `[
|
|
19618
19753
|
${itemContent.rendered},
|
|
19619
19754
|
${indent.firstLine} ]` : "[]";
|
|
19620
19755
|
adoptBody = `() => [
|
|
19621
|
-
${indent.firstLine} adoptElement("", ${itemAttrs.rendered}, ${childrenArr}${refSuffix}),
|
|
19756
|
+
${indent.firstLine} adoptElement("${itemRootCoord}", ${itemAttrs.rendered}, ${childrenArr}${refSuffix}),
|
|
19622
19757
|
${indent.firstLine} ]`;
|
|
19623
19758
|
} else {
|
|
19624
19759
|
adoptBody = itemContent.rendered.trim() ? `() => [
|
|
@@ -19661,8 +19796,9 @@ ${indent.firstLine} }`;
|
|
|
19661
19796
|
if (needsItemAdoption && !itemHasInteractiveChildren) {
|
|
19662
19797
|
allImports = allImports.plus(Import.adoptElement);
|
|
19663
19798
|
}
|
|
19799
|
+
const itemRootCoordForEach = element.getAttribute(COORD_ATTR) || "0";
|
|
19664
19800
|
const hydrateForEachFragment = new RenderFragment(
|
|
19665
|
-
`${indent.firstLine}hydrateForEach(${forEachFragment.rendered}, '${trackBy}',
|
|
19801
|
+
`${indent.firstLine}hydrateForEach(${forEachFragment.rendered}, '${trackBy}', '${itemRootCoordForEach}',
|
|
19666
19802
|
${indent.firstLine} ${adoptBody},
|
|
19667
19803
|
${indent.firstLine} ${createBody},
|
|
19668
19804
|
${indent.firstLine})`,
|
|
@@ -19693,14 +19829,12 @@ ${indent.firstLine})`,
|
|
|
19693
19829
|
const itemTypeName = slowForEachVariables.currentType.name;
|
|
19694
19830
|
const paramName = arrayAccessor.rootVar;
|
|
19695
19831
|
const getItemsFragment = arrayAccessor.render().map((_) => `(${paramName}: ${parentTypeName}) => ${_}`);
|
|
19696
|
-
const accumulatedJayTrackBy = context.slowForEachJayTrackBy ? `${context.slowForEachJayTrackBy}/${jayTrackBy}` : jayTrackBy;
|
|
19697
19832
|
const itemContext = {
|
|
19698
19833
|
...context,
|
|
19699
19834
|
variables: slowForEachVariables,
|
|
19700
19835
|
indent: indent.child().child(),
|
|
19701
19836
|
dynamicRef: true,
|
|
19702
|
-
insideSlowForEach: true
|
|
19703
|
-
slowForEachJayTrackBy: accumulatedJayTrackBy
|
|
19837
|
+
insideSlowForEach: true
|
|
19704
19838
|
};
|
|
19705
19839
|
buildRenderContext(itemContext);
|
|
19706
19840
|
const itemChildNodes = filterContentNodes(element.childNodes);
|
|
@@ -19741,13 +19875,15 @@ ${indent.firstLine})`,
|
|
|
19741
19875
|
}
|
|
19742
19876
|
}
|
|
19743
19877
|
const childrenArr = childParts.join(",\n");
|
|
19744
|
-
|
|
19878
|
+
const itemCoord = element.getAttribute(COORD_ATTR) || "";
|
|
19879
|
+
callbackBody = `adoptDynamicElement('${itemCoord}', {}, [
|
|
19745
19880
|
${childrenArr},
|
|
19746
19881
|
${indent.firstLine} ])`;
|
|
19747
19882
|
callbackImports = callbackImports.plus(Import.adoptDynamicElement);
|
|
19748
19883
|
} else {
|
|
19884
|
+
const itemCoord = element.getAttribute(COORD_ATTR) || "";
|
|
19749
19885
|
const childrenArr = nonEmptyChildren.map((f) => f.rendered).join(",\n");
|
|
19750
|
-
callbackBody = `adoptElement('', {}, [
|
|
19886
|
+
callbackBody = `adoptElement('${itemCoord}', {}, [
|
|
19751
19887
|
${childrenArr},
|
|
19752
19888
|
${indent.firstLine} ])`;
|
|
19753
19889
|
for (const f of nonEmptyChildren) {
|
|
@@ -19809,16 +19945,13 @@ function renderHydrateHeadlessInstance(element, context, renderContext, contract
|
|
|
19809
19945
|
const coordResult = extractHeadlessCoordinate(element, contractName);
|
|
19810
19946
|
if (isValidationError(coordResult))
|
|
19811
19947
|
return coordResult;
|
|
19812
|
-
const { instanceCoord, coordSegments, coordinateSuffix } = coordResult;
|
|
19948
|
+
const { instanceCoord, coordSegments, coordinateSuffix, childScopeId } = coordResult;
|
|
19813
19949
|
const isInsideForEach = context.insideFastForEach;
|
|
19814
19950
|
let coordinateKey2;
|
|
19815
19951
|
if (isInsideForEach) {
|
|
19816
19952
|
coordinateKey2 = void 0;
|
|
19817
|
-
} else if (context.insideSlowForEach) {
|
|
19818
|
-
const prefix = coordSegments[0];
|
|
19819
|
-
coordinateKey2 = computeInstanceKey(coordinateSuffix, "slowForEach", prefix);
|
|
19820
19953
|
} else {
|
|
19821
|
-
coordinateKey2 =
|
|
19954
|
+
coordinateKey2 = instanceCoord;
|
|
19822
19955
|
}
|
|
19823
19956
|
const componentVariables = new Variables(headlessImport.rootType);
|
|
19824
19957
|
const childNodes = filterContentNodes(element.childNodes);
|
|
@@ -19836,10 +19969,10 @@ function renderHydrateHeadlessInstance(element, context, renderContext, contract
|
|
|
19836
19969
|
importedRefNameToRef: instanceRefMap,
|
|
19837
19970
|
dynamicRef: false,
|
|
19838
19971
|
insideFastForEach: false,
|
|
19839
|
-
|
|
19840
|
-
|
|
19841
|
-
|
|
19842
|
-
|
|
19972
|
+
// Pass headless contract names and imports through so nested headless instances
|
|
19973
|
+
// inside headfull FS component templates can be detected (DL#123)
|
|
19974
|
+
headlessContractNames: context.headlessContractNames,
|
|
19975
|
+
headlessImports: context.headlessImports,
|
|
19843
19976
|
interactivePaths: buildInteractivePaths(headlessImport.contract)
|
|
19844
19977
|
};
|
|
19845
19978
|
const adoptRenderContext = buildRenderContext(adoptItemContext);
|
|
@@ -19854,6 +19987,7 @@ function renderHydrateHeadlessInstance(element, context, renderContext, contract
|
|
|
19854
19987
|
// forceAdopt
|
|
19855
19988
|
);
|
|
19856
19989
|
} else {
|
|
19990
|
+
const wrapperCoord = childScopeId ? `${childScopeId}/0` : "0";
|
|
19857
19991
|
const adoptChildContext = {
|
|
19858
19992
|
...adoptItemContext
|
|
19859
19993
|
};
|
|
@@ -19862,7 +19996,7 @@ function renderHydrateHeadlessInstance(element, context, renderContext, contract
|
|
|
19862
19996
|
",\n"
|
|
19863
19997
|
);
|
|
19864
19998
|
adoptInlineBody = new RenderFragment(
|
|
19865
|
-
`${adoptChildIndent.firstLine}adoptElement("
|
|
19999
|
+
`${adoptChildIndent.firstLine}adoptElement("${wrapperCoord}", {}, [
|
|
19866
20000
|
${adoptChildren.rendered}
|
|
19867
20001
|
${adoptChildIndent.firstLine}])`,
|
|
19868
20002
|
adoptChildren.imports.plus(Import.adoptElement),
|
|
@@ -19923,8 +20057,10 @@ ${adoptInlineBody.rendered}
|
|
|
19923
20057
|
dynamicRef: false,
|
|
19924
20058
|
isInsideGuard: true,
|
|
19925
20059
|
insideFastForEach: false,
|
|
19926
|
-
|
|
19927
|
-
|
|
20060
|
+
// Pass headless contract names and imports through so nested headless instances
|
|
20061
|
+
// inside headfull FS component templates can be detected (DL#123)
|
|
20062
|
+
headlessContractNames: renderContext.headlessContractNames,
|
|
20063
|
+
headlessImports: renderContext.headlessImports,
|
|
19928
20064
|
coordinatePrefix: [],
|
|
19929
20065
|
coordinateCounters: /* @__PURE__ */ new Map()
|
|
19930
20066
|
};
|
|
@@ -20003,10 +20139,10 @@ const ${createComponentSymbol} = makeHeadlessInstanceComponent(
|
|
|
20003
20139
|
);
|
|
20004
20140
|
if (renderedRef.rendered !== "")
|
|
20005
20141
|
renderedRef = renderedRef.map((_) => ", " + _);
|
|
20006
|
-
const
|
|
20142
|
+
const scopeRootCoord = childScopeId ? `'${childScopeId}/0'` : "undefined";
|
|
20007
20143
|
if (ifCondition) {
|
|
20008
20144
|
const renderedCondition = parseCondition(ifCondition, context.variables);
|
|
20009
|
-
const adoptCall = `() => childCompHydrate(${adoptComponentSymbol}, ${getProps}, ${
|
|
20145
|
+
const adoptCall = `() => childCompHydrate(${adoptComponentSymbol}, ${getProps}, ${scopeRootCoord}${renderedRef.rendered})`;
|
|
20010
20146
|
const createCall = `() => childComp(${createComponentSymbol}, ${getProps}${renderedRef.rendered})`;
|
|
20011
20147
|
const callExpr = `${context.indent.firstLine}hydrateConditional(${renderedCondition.rendered}, ${adoptCall},
|
|
20012
20148
|
${context.indent.firstLine} ${createCall})`;
|
|
@@ -20022,7 +20158,7 @@ ${context.indent.firstLine} ${createCall})`;
|
|
|
20022
20158
|
);
|
|
20023
20159
|
}
|
|
20024
20160
|
return new RenderFragment(
|
|
20025
|
-
`${context.indent.firstLine}childCompHydrate(${adoptComponentSymbol}, ${getProps}, ${
|
|
20161
|
+
`${context.indent.firstLine}childCompHydrate(${adoptComponentSymbol}, ${getProps}, ${scopeRootCoord}${renderedRef.rendered})`,
|
|
20026
20162
|
Imports.for(Import.childCompHydrate).plus(propsGetterAndRefs.imports).plus(renderedRef.imports),
|
|
20027
20163
|
[
|
|
20028
20164
|
...propsGetterAndRefs.validations,
|
|
@@ -20077,22 +20213,7 @@ function renderHydrateElementContent(element, context, renderContext, coordinate
|
|
|
20077
20213
|
",\n"
|
|
20078
20214
|
);
|
|
20079
20215
|
}
|
|
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
|
-
}
|
|
20216
|
+
const coordinate = element.getAttribute(COORD_ATTR) || coordinateOverride || "0";
|
|
20096
20217
|
const renderedRef = renderElementRef$1(element, renderContext);
|
|
20097
20218
|
if (hasInteractiveChildren) {
|
|
20098
20219
|
const childParts = [];
|
|
@@ -20182,12 +20303,23 @@ function renderHydrateElementContent(element, context, renderContext, coordinate
|
|
|
20182
20303
|
}
|
|
20183
20304
|
if (textFragment && !hasDynamicAttrs) {
|
|
20184
20305
|
const accessor = textFragment.rendered.replace(/^dt\(/, "").replace(/\)$/, "");
|
|
20185
|
-
|
|
20306
|
+
if (refName) {
|
|
20307
|
+
const refSuffix2 = renderedRef.rendered ? `, ${renderedRef.rendered}` : "";
|
|
20308
|
+
return new RenderFragment(
|
|
20309
|
+
`${indent.firstLine}adoptElement("${coordinate}", ${attributes2.rendered}, [adoptText("${coordinate}", ${accessor})]${refSuffix2})`,
|
|
20310
|
+
Imports.for(Import.adoptElement).plus(Import.adoptText).plus(textFragment.imports.minus(Import.dynamicText)).plus(renderedRef.imports).plus(attributes2.imports),
|
|
20311
|
+
[
|
|
20312
|
+
...textFragment.validations,
|
|
20313
|
+
...renderedRef.validations,
|
|
20314
|
+
...attributes2.validations
|
|
20315
|
+
],
|
|
20316
|
+
renderedRef.refs
|
|
20317
|
+
);
|
|
20318
|
+
}
|
|
20186
20319
|
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
|
|
20320
|
+
`${indent.firstLine}adoptText("${coordinate}", ${accessor})`,
|
|
20321
|
+
Imports.for(Import.adoptText).plus(textFragment.imports.minus(Import.dynamicText)),
|
|
20322
|
+
[...textFragment.validations]
|
|
20191
20323
|
);
|
|
20192
20324
|
}
|
|
20193
20325
|
if (hasDynamicAttrs) {
|
|
@@ -20255,7 +20387,6 @@ function renderHydrate(types2, body, importStatements, elementType, preRenderTyp
|
|
|
20255
20387
|
headlessInstanceCounter: { count: 0 },
|
|
20256
20388
|
insideFastForEach: false,
|
|
20257
20389
|
insideSlowForEach: false,
|
|
20258
|
-
varMappings: {},
|
|
20259
20390
|
interactivePaths: buildInteractivePaths(contract)
|
|
20260
20391
|
};
|
|
20261
20392
|
const rootElement = ensureSingleChildElement(body);
|
|
@@ -20468,7 +20599,7 @@ function renderChildCompProps$1(element, { variables }, contractProps) {
|
|
|
20468
20599
|
Object.keys(attributes2).forEach((attrName) => {
|
|
20469
20600
|
let attrCanonical = attrName.toLowerCase();
|
|
20470
20601
|
let attrKey = attrName.match(attributesRequiresQuotes$1) ? `"${attrName}"` : attrName;
|
|
20471
|
-
if (attrCanonical === "if" || attrCanonical === "foreach" || attrCanonical === "trackby" || attrCanonical === "jay-coordinate-base")
|
|
20602
|
+
if (attrCanonical === "if" || attrCanonical === "foreach" || attrCanonical === "trackby" || attrCanonical === "jay-coordinate-base" || attrCanonical === "jay-scope")
|
|
20472
20603
|
return;
|
|
20473
20604
|
if (attrCanonical === "props") {
|
|
20474
20605
|
isPropsDirectAssignment = true;
|
|
@@ -20742,8 +20873,9 @@ ${indent.curr}return ${childElement.rendered}}, '${trackBy}')`,
|
|
|
20742
20873
|
recursiveRegions: [],
|
|
20743
20874
|
isInsideGuard: false,
|
|
20744
20875
|
insideFastForEach: false,
|
|
20745
|
-
//
|
|
20746
|
-
|
|
20876
|
+
// Pass headless contract names through so nested headless instances
|
|
20877
|
+
// inside headfull FS component templates can be detected (DL#123)
|
|
20878
|
+
headlessContractNames: newContext.headlessContractNames
|
|
20747
20879
|
};
|
|
20748
20880
|
const renderedChildren = childNodes.map((_) => renderNode(_, childContext)).reduce(
|
|
20749
20881
|
(prev, current) => RenderFragment.merge(prev, current, ",\n"),
|
|
@@ -20779,7 +20911,8 @@ ${renderedChildren.rendered}
|
|
|
20779
20911
|
}
|
|
20780
20912
|
const isInsideForEach = newContext.insideFastForEach;
|
|
20781
20913
|
const coordinateSuffix = `${contractName}:${coordinateRef}`;
|
|
20782
|
-
const
|
|
20914
|
+
const instanceCoordBase = htmlElement.getAttribute("jay-coordinate-base");
|
|
20915
|
+
const coordinateKey2 = isInsideForEach ? void 0 : instanceCoordBase || [...newContext.coordinatePrefix, coordinateSuffix].join("/");
|
|
20783
20916
|
const renderFnCode = `
|
|
20784
20917
|
// Inline template for headless component: ${contractName} #${idx}
|
|
20785
20918
|
type ${elementType} = JayElement<${interactiveViewStateType}, ${refsTypeName}>;
|
|
@@ -21106,6 +21239,7 @@ function renderFunctionImplementation$1(types2, rootBodyElement, importStatement
|
|
|
21106
21239
|
const { importedSymbols, importedSandboxedSymbols } = processImportedComponents(importStatements);
|
|
21107
21240
|
const importedRefNameToRef = processImportedHeadless(headlessImports);
|
|
21108
21241
|
const headlessContractNames = new Set(headlessImports.map((h) => h.contractName));
|
|
21242
|
+
assignCoordinates(rootBodyElement, { headlessContractNames });
|
|
21109
21243
|
const rootElement = ensureSingleChildElement(rootBodyElement);
|
|
21110
21244
|
let renderedRoot;
|
|
21111
21245
|
const usedComponentImports = /* @__PURE__ */ new Set();
|
|
@@ -22094,28 +22228,16 @@ ${indent.firstLine}}`,
|
|
|
22094
22228
|
const arrayExpr = forEachAccessor.render().rendered;
|
|
22095
22229
|
const itemIndent = new Indent(indent.curr + " ");
|
|
22096
22230
|
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
22231
|
const itemContext = {
|
|
22102
22232
|
...context,
|
|
22103
22233
|
variables: forEachVariables,
|
|
22104
22234
|
indent: itemIndent,
|
|
22105
22235
|
varMappings: { ...context.varMappings, [trackBy]: trackByExpr },
|
|
22106
|
-
insideForEach: true
|
|
22107
|
-
forEachAccumulatedPrefix: accumulatedPrefix,
|
|
22108
|
-
forEachAncestorPrefix: ancestorPrefix,
|
|
22109
|
-
slowForEachCoordPrefix: void 0
|
|
22110
|
-
// consumed by ancestorPrefix computation
|
|
22236
|
+
insideForEach: true
|
|
22111
22237
|
};
|
|
22112
22238
|
const openTag = renderServerOpenTag(element, itemContext, null);
|
|
22113
|
-
const
|
|
22114
|
-
const coordinateW = w(
|
|
22115
|
-
itemIndent,
|
|
22116
|
-
`' jay-coordinate="' + ${itemRootCoordExpr} + '">'`,
|
|
22117
|
-
Imports.for(Import.escapeAttr)
|
|
22118
|
-
);
|
|
22239
|
+
const itemCoord = element.getAttribute(COORD_ATTR);
|
|
22240
|
+
const coordinateW = itemCoord ? w(itemIndent, `' jay-coordinate="${itemCoord}">'`) : w(itemIndent, `'>'`);
|
|
22119
22241
|
const childNodes = filterContentNodes(element.childNodes);
|
|
22120
22242
|
const children = mergeServerFragments(
|
|
22121
22243
|
childNodes.map((child) => renderServerNode(child, itemContext))
|
|
@@ -22140,13 +22262,11 @@ ${indent.firstLine}}`,
|
|
|
22140
22262
|
const { accessor: arrayAccessor, childVariables: slowForEachVariables } = slowValidated;
|
|
22141
22263
|
const arrayExpr = arrayAccessor.render().rendered;
|
|
22142
22264
|
const itemVar = slowForEachVariables.currentVar;
|
|
22143
|
-
const slowCoordPrefix = context.slowForEachCoordPrefix ? `${context.slowForEachCoordPrefix}/${jayTrackBy}` : jayTrackBy;
|
|
22144
22265
|
const itemContext = {
|
|
22145
22266
|
...context,
|
|
22146
22267
|
variables: slowForEachVariables,
|
|
22147
22268
|
indent,
|
|
22148
|
-
insideSlowForEach: true
|
|
22149
|
-
slowForEachCoordPrefix: slowCoordPrefix
|
|
22269
|
+
insideSlowForEach: true
|
|
22150
22270
|
};
|
|
22151
22271
|
const childContent = renderServerElementContent(element, itemContext, {
|
|
22152
22272
|
isRoot: true
|
|
@@ -22158,8 +22278,7 @@ ${indent.firstLine}}`,
|
|
|
22158
22278
|
...context,
|
|
22159
22279
|
variables: slowForEachVariables,
|
|
22160
22280
|
indent: itemIndent,
|
|
22161
|
-
insideSlowForEach: true
|
|
22162
|
-
slowForEachCoordPrefix: slowCoordPrefix
|
|
22281
|
+
insideSlowForEach: true
|
|
22163
22282
|
};
|
|
22164
22283
|
const indentedContent = renderServerElementContent(element, indentedContext, {
|
|
22165
22284
|
isRoot: true
|
|
@@ -22195,11 +22314,8 @@ function renderServerHeadlessInstance(element, context, contractName) {
|
|
|
22195
22314
|
const trackByKeys = Object.keys(context.varMappings);
|
|
22196
22315
|
const trackByExpr = trackByKeys.length > 0 ? context.varMappings[trackByKeys[trackByKeys.length - 1]] : "undefined";
|
|
22197
22316
|
instanceKeyExpr = `String(${trackByExpr}) + ',${coordinateSuffix}'`;
|
|
22198
|
-
} else if (context.insideSlowForEach) {
|
|
22199
|
-
const prefix = coordSegments[0];
|
|
22200
|
-
instanceKeyExpr = `'${computeInstanceKey(coordinateSuffix, "slowForEach", prefix)}'`;
|
|
22201
22317
|
} else {
|
|
22202
|
-
instanceKeyExpr = `'${
|
|
22318
|
+
instanceKeyExpr = `'${instanceCoord}'`;
|
|
22203
22319
|
}
|
|
22204
22320
|
const ifCondition = element.attributes.if;
|
|
22205
22321
|
const componentVariables = new Variables(headlessImport.rootType, void 0, 0, varName);
|
|
@@ -22214,8 +22330,9 @@ function renderServerHeadlessInstance(element, context, contractName) {
|
|
|
22214
22330
|
...context,
|
|
22215
22331
|
variables: componentVariables,
|
|
22216
22332
|
indent: bodyIndent,
|
|
22217
|
-
//
|
|
22218
|
-
|
|
22333
|
+
// Pass headless contract names through so nested headless instances
|
|
22334
|
+
// inside headfull FS component templates can be detected (DL#123)
|
|
22335
|
+
headlessContractNames: context.headlessContractNames,
|
|
22219
22336
|
interactivePaths: buildInteractivePaths(headlessImport.contract)
|
|
22220
22337
|
};
|
|
22221
22338
|
const renderedChildren = mergeServerFragments(
|
|
@@ -22425,7 +22542,7 @@ function renderServerElementAsString(element, context, overrideCoordinate) {
|
|
|
22425
22542
|
}
|
|
22426
22543
|
}
|
|
22427
22544
|
const needsCoordinate = overrideCoordinate !== void 0 || dynamicTextFragment !== null || refName !== null || hasDynamicAttributeBindings(element, variables) || hasInteractiveChildElements(childNodes) || hasMixedContentDynamicText(childNodes);
|
|
22428
|
-
const coordTemplate = element.getAttribute(COORD_ATTR
|
|
22545
|
+
const coordTemplate = element.getAttribute(COORD_ATTR);
|
|
22429
22546
|
const coordinate = coordTemplate || (needsCoordinate ? overrideCoordinate || null : null);
|
|
22430
22547
|
const isVoid = voidElements.has(element.rawTagName.toLowerCase());
|
|
22431
22548
|
const closeTag = isVoid ? " />" : ">";
|
|
@@ -22610,7 +22727,7 @@ function renderServerElementContent(element, context, options) {
|
|
|
22610
22727
|
}
|
|
22611
22728
|
const refName = element.attributes.ref ? camelCase(element.attributes.ref) : null;
|
|
22612
22729
|
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
|
|
22730
|
+
const coordTemplate = needsCoordinate ? element.getAttribute(COORD_ATTR) : null;
|
|
22614
22731
|
const isVoid = voidElements.has(element.rawTagName.toLowerCase());
|
|
22615
22732
|
const closeTag = isVoid ? " />" : ">";
|
|
22616
22733
|
const parts = [];
|
|
@@ -22620,38 +22737,7 @@ function renderServerElementContent(element, context, options) {
|
|
|
22620
22737
|
parts.push(attrs);
|
|
22621
22738
|
}
|
|
22622
22739
|
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
|
-
}
|
|
22740
|
+
parts.push(w(indent, `' jay-coordinate="${coordTemplate}"${closeTag}'`));
|
|
22655
22741
|
} else {
|
|
22656
22742
|
parts.push(w(indent, `'${closeTag}'`));
|
|
22657
22743
|
}
|
|
@@ -29593,7 +29679,18 @@ const JAY_IMPORT_RESOLVER = {
|
|
|
29593
29679
|
const resolvedPath = src.startsWith(".") ? path.resolve(importingModuleDir, src) : src;
|
|
29594
29680
|
const jayHtmlPath = resolvedPath + ".jay-html";
|
|
29595
29681
|
try {
|
|
29596
|
-
|
|
29682
|
+
const content = fs$1.readFileSync(jayHtmlPath, "utf-8");
|
|
29683
|
+
return { content, componentDir: path.dirname(jayHtmlPath), filePath: jayHtmlPath };
|
|
29684
|
+
} catch {
|
|
29685
|
+
}
|
|
29686
|
+
const dirJayHtmlPath = path.resolve(resolvedPath, path.basename(resolvedPath)) + ".jay-html";
|
|
29687
|
+
try {
|
|
29688
|
+
const content = fs$1.readFileSync(dirJayHtmlPath, "utf-8");
|
|
29689
|
+
return {
|
|
29690
|
+
content,
|
|
29691
|
+
componentDir: path.dirname(dirJayHtmlPath),
|
|
29692
|
+
filePath: dirJayHtmlPath
|
|
29693
|
+
};
|
|
29597
29694
|
} catch {
|
|
29598
29695
|
return null;
|
|
29599
29696
|
}
|
|
@@ -29936,16 +30033,17 @@ function discoverHeadlessInstances(preRenderedJayHtml) {
|
|
|
29936
30033
|
if (!insidePreservedForEach) {
|
|
29937
30034
|
const hasUnresolvedProps = Object.values(props).some((v) => hasBindings(v));
|
|
29938
30035
|
if (!hasUnresolvedProps) {
|
|
29939
|
-
const prefix = buildCoordinatePrefix(element);
|
|
29940
30036
|
let ref = element.getAttribute("ref");
|
|
29941
30037
|
if (!ref) {
|
|
30038
|
+
const prefix = buildCoordinatePrefix(element);
|
|
29942
30039
|
const counterKey = [...prefix, contractName].join("/");
|
|
29943
30040
|
const localIndex = coordinateCounters.get(counterKey) ?? 0;
|
|
29944
30041
|
coordinateCounters.set(counterKey, localIndex + 1);
|
|
29945
30042
|
ref = `AR${localIndex}`;
|
|
29946
30043
|
element.setAttribute("ref", ref);
|
|
29947
30044
|
}
|
|
29948
|
-
const
|
|
30045
|
+
const coordBase = element.getAttribute("jay-coordinate-base");
|
|
30046
|
+
const coordinate = coordBase ? coordBase.split("/") : [...buildCoordinatePrefix(element), `${contractName}:${ref}`];
|
|
29949
30047
|
instances.push({
|
|
29950
30048
|
contractName,
|
|
29951
30049
|
props,
|
|
@@ -29971,6 +30069,11 @@ function discoverHeadlessInstances(preRenderedJayHtml) {
|
|
|
29971
30069
|
});
|
|
29972
30070
|
}
|
|
29973
30071
|
}
|
|
30072
|
+
for (const child of element.childNodes) {
|
|
30073
|
+
if (child.nodeType === NodeType.ELEMENT_NODE) {
|
|
30074
|
+
walk(child, insidePreservedForEach, forEachContexts);
|
|
30075
|
+
}
|
|
30076
|
+
}
|
|
29974
30077
|
return;
|
|
29975
30078
|
}
|
|
29976
30079
|
const updatedForEachContexts = hasForEach && forEachAttr && trackByAttr ? [...forEachContexts, { forEachPath: forEachAttr, trackBy: trackByAttr }] : forEachContexts;
|
|
@@ -30044,6 +30147,11 @@ function resolveHeadlessInstances(preRenderedJayHtml, instanceData, importResolv
|
|
|
30044
30147
|
}
|
|
30045
30148
|
}
|
|
30046
30149
|
}
|
|
30150
|
+
for (const child of element.childNodes) {
|
|
30151
|
+
if (child.nodeType === NodeType.ELEMENT_NODE) {
|
|
30152
|
+
walkAndResolve(child, insidePreservedForEach || hasForEach);
|
|
30153
|
+
}
|
|
30154
|
+
}
|
|
30047
30155
|
return;
|
|
30048
30156
|
}
|
|
30049
30157
|
for (const child of element.childNodes) {
|