regor 1.6.6 → 1.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/dist/regor.d.ts +18 -1
- package/dist/regor.es2015.cjs.js +135 -33
- package/dist/regor.es2015.cjs.prod.js +3 -3
- package/dist/regor.es2015.esm.js +135 -33
- package/dist/regor.es2015.esm.prod.js +3 -3
- package/dist/regor.es2015.iife.js +135 -33
- package/dist/regor.es2015.iife.prod.js +3 -3
- package/dist/regor.es2019.cjs.js +135 -33
- package/dist/regor.es2019.cjs.prod.js +3 -3
- package/dist/regor.es2019.esm.js +135 -33
- package/dist/regor.es2019.esm.prod.js +3 -3
- package/dist/regor.es2019.iife.js +135 -33
- package/dist/regor.es2019.iife.prod.js +3 -3
- package/dist/regor.es2022.cjs.js +134 -32
- package/dist/regor.es2022.cjs.prod.js +3 -3
- package/dist/regor.es2022.esm.js +134 -32
- package/dist/regor.es2022.esm.prod.js +3 -3
- package/dist/regor.es2022.iife.js +134 -32
- package/dist/regor.es2022.iife.prod.js +3 -3
- package/package.json +2 -2
package/dist/regor.es2022.cjs.js
CHANGED
|
@@ -4169,7 +4169,7 @@ var isDeepRef = (value) => {
|
|
|
4169
4169
|
};
|
|
4170
4170
|
|
|
4171
4171
|
// src/reactivity/ref.ts
|
|
4172
|
-
|
|
4172
|
+
function ref(value) {
|
|
4173
4173
|
if (isRaw(value)) return value;
|
|
4174
4174
|
let result;
|
|
4175
4175
|
if (isRef(value)) {
|
|
@@ -4200,7 +4200,7 @@ var ref = (value) => {
|
|
|
4200
4200
|
value[key] = ref(val);
|
|
4201
4201
|
}
|
|
4202
4202
|
return result;
|
|
4203
|
-
}
|
|
4203
|
+
}
|
|
4204
4204
|
|
|
4205
4205
|
// src/app/RegorConfig.ts
|
|
4206
4206
|
var RegorConfig = class _RegorConfig {
|
|
@@ -6188,19 +6188,50 @@ var parseTagNameRange = (tagText, isClosing) => {
|
|
|
6188
6188
|
while (i < tagText.length && (tagText[i] === " " || tagText[i] === "\n")) ++i;
|
|
6189
6189
|
if (i >= tagText.length || !isNameChar(tagText[i])) return null;
|
|
6190
6190
|
const start = i;
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
6191
|
+
let hasUppercase = false;
|
|
6192
|
+
while (i < tagText.length && isNameChar(tagText[i])) {
|
|
6193
|
+
const c = tagText.charCodeAt(i);
|
|
6194
|
+
if (c >= 65 && c <= 90) {
|
|
6195
|
+
hasUppercase = true;
|
|
6196
|
+
}
|
|
6197
|
+
++i;
|
|
6198
|
+
}
|
|
6199
|
+
return { start, end: i, hasUppercase };
|
|
6200
|
+
};
|
|
6201
|
+
var isTableScopeTag = (tagName) => {
|
|
6202
|
+
switch (tagName) {
|
|
6203
|
+
case "table":
|
|
6204
|
+
case "thead":
|
|
6205
|
+
case "tbody":
|
|
6206
|
+
case "tfoot":
|
|
6207
|
+
return true;
|
|
6208
|
+
default:
|
|
6209
|
+
return false;
|
|
6210
|
+
}
|
|
6211
|
+
};
|
|
6212
|
+
var isRowParentTag = (tagName) => {
|
|
6213
|
+
switch (tagName) {
|
|
6214
|
+
case "thead":
|
|
6215
|
+
case "tbody":
|
|
6216
|
+
case "tfoot":
|
|
6217
|
+
return true;
|
|
6218
|
+
default:
|
|
6219
|
+
return false;
|
|
6220
|
+
}
|
|
6221
|
+
};
|
|
6222
|
+
var isTableDirectAllowed = (tagName) => {
|
|
6223
|
+
switch (tagName) {
|
|
6224
|
+
case "caption":
|
|
6225
|
+
case "colgroup":
|
|
6226
|
+
case "thead":
|
|
6227
|
+
case "tbody":
|
|
6228
|
+
case "tfoot":
|
|
6229
|
+
case "tr":
|
|
6230
|
+
return true;
|
|
6231
|
+
default:
|
|
6232
|
+
return false;
|
|
6233
|
+
}
|
|
6234
|
+
};
|
|
6204
6235
|
var voidElements = /* @__PURE__ */ new Set([
|
|
6205
6236
|
"area",
|
|
6206
6237
|
"base",
|
|
@@ -6217,11 +6248,61 @@ var voidElements = /* @__PURE__ */ new Set([
|
|
|
6217
6248
|
"track",
|
|
6218
6249
|
"wbr"
|
|
6219
6250
|
]);
|
|
6251
|
+
var getTableAliasHost = (tagName) => {
|
|
6252
|
+
switch (tagName) {
|
|
6253
|
+
case "caption":
|
|
6254
|
+
return "captionx";
|
|
6255
|
+
case "thead":
|
|
6256
|
+
return "theadx";
|
|
6257
|
+
case "tbody":
|
|
6258
|
+
return "tbodyx";
|
|
6259
|
+
case "tfoot":
|
|
6260
|
+
return "tfootx";
|
|
6261
|
+
case "tr":
|
|
6262
|
+
return "trx";
|
|
6263
|
+
case "td":
|
|
6264
|
+
return "tdx";
|
|
6265
|
+
case "th":
|
|
6266
|
+
return "thx";
|
|
6267
|
+
case "colgroup":
|
|
6268
|
+
return "colgroupx";
|
|
6269
|
+
case "col":
|
|
6270
|
+
return "colx";
|
|
6271
|
+
default:
|
|
6272
|
+
return null;
|
|
6273
|
+
}
|
|
6274
|
+
};
|
|
6275
|
+
var getTableAliasTag = (host) => {
|
|
6276
|
+
switch (host) {
|
|
6277
|
+
case "captionx":
|
|
6278
|
+
return "caption";
|
|
6279
|
+
case "theadx":
|
|
6280
|
+
return "thead";
|
|
6281
|
+
case "tbodyx":
|
|
6282
|
+
return "tbody";
|
|
6283
|
+
case "tfootx":
|
|
6284
|
+
return "tfoot";
|
|
6285
|
+
case "trx":
|
|
6286
|
+
return "tr";
|
|
6287
|
+
case "tdx":
|
|
6288
|
+
return "td";
|
|
6289
|
+
case "thx":
|
|
6290
|
+
return "th";
|
|
6291
|
+
case "colgroupx":
|
|
6292
|
+
return "colgroup";
|
|
6293
|
+
case "colx":
|
|
6294
|
+
return "col";
|
|
6295
|
+
default:
|
|
6296
|
+
return void 0;
|
|
6297
|
+
}
|
|
6298
|
+
};
|
|
6299
|
+
var closeTag = (tagText, tagName) => `${tagText}</${tagName}>`;
|
|
6220
6300
|
var expandSelfClosingTag = (tagText, tagName) => `${tagText.slice(0, tagText.length - 2)}></${tagName}>`;
|
|
6221
6301
|
var preprocess = (template) => {
|
|
6222
6302
|
let i = 0;
|
|
6223
6303
|
const out = [];
|
|
6224
6304
|
const stack = [];
|
|
6305
|
+
const ignoredClosingTags = [];
|
|
6225
6306
|
let tableScopeDepth = 0;
|
|
6226
6307
|
while (i < template.length) {
|
|
6227
6308
|
const lt = template.indexOf("<", i);
|
|
@@ -6260,12 +6341,21 @@ var preprocess = (template) => {
|
|
|
6260
6341
|
continue;
|
|
6261
6342
|
}
|
|
6262
6343
|
const tagName = rawTag.slice(range.start, range.end);
|
|
6344
|
+
const nativeTagName = range.hasUppercase ? "" : tagName;
|
|
6263
6345
|
if (isClosing) {
|
|
6346
|
+
const ignoredClosing = ignoredClosingTags[ignoredClosingTags.length - 1];
|
|
6347
|
+
if (ignoredClosing?.tagName === tagName) {
|
|
6348
|
+
ignoredClosingTags.pop();
|
|
6349
|
+
if (ignoredClosing.emit) out.push(rawTag);
|
|
6350
|
+
i = tagEnd + 1;
|
|
6351
|
+
continue;
|
|
6352
|
+
}
|
|
6264
6353
|
const top = stack[stack.length - 1];
|
|
6265
6354
|
if (top) {
|
|
6266
6355
|
stack.pop();
|
|
6267
6356
|
out.push(top.replacementHost ? `</${top.replacementHost}>` : rawTag);
|
|
6268
|
-
if (
|
|
6357
|
+
if (!top.isTableAlias && isTableScopeTag(top.effectiveTag))
|
|
6358
|
+
--tableScopeDepth;
|
|
6269
6359
|
} else {
|
|
6270
6360
|
out.push(rawTag);
|
|
6271
6361
|
}
|
|
@@ -6276,35 +6366,47 @@ var preprocess = (template) => {
|
|
|
6276
6366
|
const parent = stack[stack.length - 1];
|
|
6277
6367
|
let replacementHost = null;
|
|
6278
6368
|
if (tableScopeDepth === 0) {
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
} else if (rowParentTags.has(parent?.effectiveTag ?? "")) {
|
|
6283
|
-
replacementHost = tagName === "tr" ? null : "tr";
|
|
6369
|
+
replacementHost = getTableAliasHost(nativeTagName);
|
|
6370
|
+
} else if (isRowParentTag(parent?.effectiveTag ?? "")) {
|
|
6371
|
+
replacementHost = nativeTagName === "tr" ? null : "tr";
|
|
6284
6372
|
} else if (parent?.effectiveTag === "table") {
|
|
6285
|
-
replacementHost =
|
|
6373
|
+
replacementHost = isTableDirectAllowed(nativeTagName) ? null : "tr";
|
|
6286
6374
|
} else if (parent?.effectiveTag === "tr") {
|
|
6287
|
-
replacementHost =
|
|
6288
|
-
}
|
|
6289
|
-
|
|
6375
|
+
replacementHost = nativeTagName === "td" || nativeTagName === "th" ? null : "td";
|
|
6376
|
+
} else if (parent?.effectiveTag === "colgroup") {
|
|
6377
|
+
replacementHost = nativeTagName === "col" ? null : "col";
|
|
6378
|
+
}
|
|
6379
|
+
const aliasTag = getTableAliasTag(replacementHost);
|
|
6380
|
+
const isTableAlias = aliasTag !== void 0;
|
|
6381
|
+
const shouldExpandSelfClosing = selfClosing && !voidElements.has(replacementHost || nativeTagName);
|
|
6382
|
+
const shouldCloseVoidAlias = !!replacementHost && aliasTag === nativeTagName && voidElements.has(nativeTagName);
|
|
6383
|
+
const shouldIgnoreClosingTag = !selfClosing && !!replacementHost && voidElements.has(replacementHost) && !shouldCloseVoidAlias;
|
|
6384
|
+
const shouldIgnoreNativeVoidClosingTag = !selfClosing && !replacementHost && voidElements.has(nativeTagName);
|
|
6290
6385
|
if (replacementHost) {
|
|
6291
|
-
const
|
|
6292
|
-
const rewrittenTag = `${rawTag.slice(0, range.start)}${replacementHost} is="${isAlias ? `r-${tagName}` : `regor:${tagName}`}"${rawTag.slice(range.end)}`;
|
|
6386
|
+
const rewrittenTag = `${rawTag.slice(0, range.start)}${replacementHost} is="${aliasTag ? `r-${aliasTag}` : `regor:${tagName}`}"${rawTag.slice(range.end)}`;
|
|
6293
6387
|
out.push(
|
|
6294
|
-
shouldExpandSelfClosing ? expandSelfClosingTag(rewrittenTag, replacementHost) : rewrittenTag
|
|
6388
|
+
shouldExpandSelfClosing ? expandSelfClosingTag(rewrittenTag, replacementHost) : shouldCloseVoidAlias ? closeTag(rewrittenTag, replacementHost) : rewrittenTag
|
|
6295
6389
|
);
|
|
6296
6390
|
} else {
|
|
6297
6391
|
out.push(
|
|
6298
6392
|
shouldExpandSelfClosing ? expandSelfClosingTag(rawTag, tagName) : rawTag
|
|
6299
6393
|
);
|
|
6300
6394
|
}
|
|
6301
|
-
if (
|
|
6302
|
-
|
|
6395
|
+
if (shouldIgnoreClosingTag) {
|
|
6396
|
+
ignoredClosingTags.push({ tagName, emit: false });
|
|
6397
|
+
} else if (shouldCloseVoidAlias && !selfClosing) {
|
|
6398
|
+
ignoredClosingTags.push({ tagName, emit: false });
|
|
6399
|
+
} else if (shouldIgnoreNativeVoidClosingTag) {
|
|
6400
|
+
ignoredClosingTags.push({ tagName, emit: true });
|
|
6401
|
+
}
|
|
6402
|
+
if (!selfClosing && !shouldCloseVoidAlias && !shouldIgnoreClosingTag && !shouldIgnoreNativeVoidClosingTag && !voidElements.has(replacementHost ?? nativeTagName)) {
|
|
6403
|
+
const effectiveTag = aliasTag ?? replacementHost ?? (nativeTagName || tagName);
|
|
6303
6404
|
stack.push({
|
|
6304
6405
|
replacementHost,
|
|
6305
|
-
effectiveTag
|
|
6406
|
+
effectiveTag,
|
|
6407
|
+
isTableAlias
|
|
6306
6408
|
});
|
|
6307
|
-
if (
|
|
6409
|
+
if (!isTableAlias && isTableScopeTag(effectiveTag)) ++tableScopeDepth;
|
|
6308
6410
|
}
|
|
6309
6411
|
i = tagEnd + 1;
|
|
6310
6412
|
}
|