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.esm.js
CHANGED
|
@@ -4099,7 +4099,7 @@ var isDeepRef = (value) => {
|
|
|
4099
4099
|
};
|
|
4100
4100
|
|
|
4101
4101
|
// src/reactivity/ref.ts
|
|
4102
|
-
|
|
4102
|
+
function ref(value) {
|
|
4103
4103
|
if (isRaw(value)) return value;
|
|
4104
4104
|
let result;
|
|
4105
4105
|
if (isRef(value)) {
|
|
@@ -4130,7 +4130,7 @@ var ref = (value) => {
|
|
|
4130
4130
|
value[key] = ref(val);
|
|
4131
4131
|
}
|
|
4132
4132
|
return result;
|
|
4133
|
-
}
|
|
4133
|
+
}
|
|
4134
4134
|
|
|
4135
4135
|
// src/app/RegorConfig.ts
|
|
4136
4136
|
var RegorConfig = class _RegorConfig {
|
|
@@ -6118,19 +6118,50 @@ var parseTagNameRange = (tagText, isClosing) => {
|
|
|
6118
6118
|
while (i < tagText.length && (tagText[i] === " " || tagText[i] === "\n")) ++i;
|
|
6119
6119
|
if (i >= tagText.length || !isNameChar(tagText[i])) return null;
|
|
6120
6120
|
const start = i;
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6121
|
+
let hasUppercase = false;
|
|
6122
|
+
while (i < tagText.length && isNameChar(tagText[i])) {
|
|
6123
|
+
const c = tagText.charCodeAt(i);
|
|
6124
|
+
if (c >= 65 && c <= 90) {
|
|
6125
|
+
hasUppercase = true;
|
|
6126
|
+
}
|
|
6127
|
+
++i;
|
|
6128
|
+
}
|
|
6129
|
+
return { start, end: i, hasUppercase };
|
|
6130
|
+
};
|
|
6131
|
+
var isTableScopeTag = (tagName) => {
|
|
6132
|
+
switch (tagName) {
|
|
6133
|
+
case "table":
|
|
6134
|
+
case "thead":
|
|
6135
|
+
case "tbody":
|
|
6136
|
+
case "tfoot":
|
|
6137
|
+
return true;
|
|
6138
|
+
default:
|
|
6139
|
+
return false;
|
|
6140
|
+
}
|
|
6141
|
+
};
|
|
6142
|
+
var isRowParentTag = (tagName) => {
|
|
6143
|
+
switch (tagName) {
|
|
6144
|
+
case "thead":
|
|
6145
|
+
case "tbody":
|
|
6146
|
+
case "tfoot":
|
|
6147
|
+
return true;
|
|
6148
|
+
default:
|
|
6149
|
+
return false;
|
|
6150
|
+
}
|
|
6151
|
+
};
|
|
6152
|
+
var isTableDirectAllowed = (tagName) => {
|
|
6153
|
+
switch (tagName) {
|
|
6154
|
+
case "caption":
|
|
6155
|
+
case "colgroup":
|
|
6156
|
+
case "thead":
|
|
6157
|
+
case "tbody":
|
|
6158
|
+
case "tfoot":
|
|
6159
|
+
case "tr":
|
|
6160
|
+
return true;
|
|
6161
|
+
default:
|
|
6162
|
+
return false;
|
|
6163
|
+
}
|
|
6164
|
+
};
|
|
6134
6165
|
var voidElements = /* @__PURE__ */ new Set([
|
|
6135
6166
|
"area",
|
|
6136
6167
|
"base",
|
|
@@ -6147,11 +6178,61 @@ var voidElements = /* @__PURE__ */ new Set([
|
|
|
6147
6178
|
"track",
|
|
6148
6179
|
"wbr"
|
|
6149
6180
|
]);
|
|
6181
|
+
var getTableAliasHost = (tagName) => {
|
|
6182
|
+
switch (tagName) {
|
|
6183
|
+
case "caption":
|
|
6184
|
+
return "captionx";
|
|
6185
|
+
case "thead":
|
|
6186
|
+
return "theadx";
|
|
6187
|
+
case "tbody":
|
|
6188
|
+
return "tbodyx";
|
|
6189
|
+
case "tfoot":
|
|
6190
|
+
return "tfootx";
|
|
6191
|
+
case "tr":
|
|
6192
|
+
return "trx";
|
|
6193
|
+
case "td":
|
|
6194
|
+
return "tdx";
|
|
6195
|
+
case "th":
|
|
6196
|
+
return "thx";
|
|
6197
|
+
case "colgroup":
|
|
6198
|
+
return "colgroupx";
|
|
6199
|
+
case "col":
|
|
6200
|
+
return "colx";
|
|
6201
|
+
default:
|
|
6202
|
+
return null;
|
|
6203
|
+
}
|
|
6204
|
+
};
|
|
6205
|
+
var getTableAliasTag = (host) => {
|
|
6206
|
+
switch (host) {
|
|
6207
|
+
case "captionx":
|
|
6208
|
+
return "caption";
|
|
6209
|
+
case "theadx":
|
|
6210
|
+
return "thead";
|
|
6211
|
+
case "tbodyx":
|
|
6212
|
+
return "tbody";
|
|
6213
|
+
case "tfootx":
|
|
6214
|
+
return "tfoot";
|
|
6215
|
+
case "trx":
|
|
6216
|
+
return "tr";
|
|
6217
|
+
case "tdx":
|
|
6218
|
+
return "td";
|
|
6219
|
+
case "thx":
|
|
6220
|
+
return "th";
|
|
6221
|
+
case "colgroupx":
|
|
6222
|
+
return "colgroup";
|
|
6223
|
+
case "colx":
|
|
6224
|
+
return "col";
|
|
6225
|
+
default:
|
|
6226
|
+
return void 0;
|
|
6227
|
+
}
|
|
6228
|
+
};
|
|
6229
|
+
var closeTag = (tagText, tagName) => `${tagText}</${tagName}>`;
|
|
6150
6230
|
var expandSelfClosingTag = (tagText, tagName) => `${tagText.slice(0, tagText.length - 2)}></${tagName}>`;
|
|
6151
6231
|
var preprocess = (template) => {
|
|
6152
6232
|
let i = 0;
|
|
6153
6233
|
const out = [];
|
|
6154
6234
|
const stack = [];
|
|
6235
|
+
const ignoredClosingTags = [];
|
|
6155
6236
|
let tableScopeDepth = 0;
|
|
6156
6237
|
while (i < template.length) {
|
|
6157
6238
|
const lt = template.indexOf("<", i);
|
|
@@ -6190,12 +6271,21 @@ var preprocess = (template) => {
|
|
|
6190
6271
|
continue;
|
|
6191
6272
|
}
|
|
6192
6273
|
const tagName = rawTag.slice(range.start, range.end);
|
|
6274
|
+
const nativeTagName = range.hasUppercase ? "" : tagName;
|
|
6193
6275
|
if (isClosing) {
|
|
6276
|
+
const ignoredClosing = ignoredClosingTags[ignoredClosingTags.length - 1];
|
|
6277
|
+
if (ignoredClosing?.tagName === tagName) {
|
|
6278
|
+
ignoredClosingTags.pop();
|
|
6279
|
+
if (ignoredClosing.emit) out.push(rawTag);
|
|
6280
|
+
i = tagEnd + 1;
|
|
6281
|
+
continue;
|
|
6282
|
+
}
|
|
6194
6283
|
const top = stack[stack.length - 1];
|
|
6195
6284
|
if (top) {
|
|
6196
6285
|
stack.pop();
|
|
6197
6286
|
out.push(top.replacementHost ? `</${top.replacementHost}>` : rawTag);
|
|
6198
|
-
if (
|
|
6287
|
+
if (!top.isTableAlias && isTableScopeTag(top.effectiveTag))
|
|
6288
|
+
--tableScopeDepth;
|
|
6199
6289
|
} else {
|
|
6200
6290
|
out.push(rawTag);
|
|
6201
6291
|
}
|
|
@@ -6206,35 +6296,47 @@ var preprocess = (template) => {
|
|
|
6206
6296
|
const parent = stack[stack.length - 1];
|
|
6207
6297
|
let replacementHost = null;
|
|
6208
6298
|
if (tableScopeDepth === 0) {
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
} else if (rowParentTags.has(parent?.effectiveTag ?? "")) {
|
|
6213
|
-
replacementHost = tagName === "tr" ? null : "tr";
|
|
6299
|
+
replacementHost = getTableAliasHost(nativeTagName);
|
|
6300
|
+
} else if (isRowParentTag(parent?.effectiveTag ?? "")) {
|
|
6301
|
+
replacementHost = nativeTagName === "tr" ? null : "tr";
|
|
6214
6302
|
} else if (parent?.effectiveTag === "table") {
|
|
6215
|
-
replacementHost =
|
|
6303
|
+
replacementHost = isTableDirectAllowed(nativeTagName) ? null : "tr";
|
|
6216
6304
|
} else if (parent?.effectiveTag === "tr") {
|
|
6217
|
-
replacementHost =
|
|
6218
|
-
}
|
|
6219
|
-
|
|
6305
|
+
replacementHost = nativeTagName === "td" || nativeTagName === "th" ? null : "td";
|
|
6306
|
+
} else if (parent?.effectiveTag === "colgroup") {
|
|
6307
|
+
replacementHost = nativeTagName === "col" ? null : "col";
|
|
6308
|
+
}
|
|
6309
|
+
const aliasTag = getTableAliasTag(replacementHost);
|
|
6310
|
+
const isTableAlias = aliasTag !== void 0;
|
|
6311
|
+
const shouldExpandSelfClosing = selfClosing && !voidElements.has(replacementHost || nativeTagName);
|
|
6312
|
+
const shouldCloseVoidAlias = !!replacementHost && aliasTag === nativeTagName && voidElements.has(nativeTagName);
|
|
6313
|
+
const shouldIgnoreClosingTag = !selfClosing && !!replacementHost && voidElements.has(replacementHost) && !shouldCloseVoidAlias;
|
|
6314
|
+
const shouldIgnoreNativeVoidClosingTag = !selfClosing && !replacementHost && voidElements.has(nativeTagName);
|
|
6220
6315
|
if (replacementHost) {
|
|
6221
|
-
const
|
|
6222
|
-
const rewrittenTag = `${rawTag.slice(0, range.start)}${replacementHost} is="${isAlias ? `r-${tagName}` : `regor:${tagName}`}"${rawTag.slice(range.end)}`;
|
|
6316
|
+
const rewrittenTag = `${rawTag.slice(0, range.start)}${replacementHost} is="${aliasTag ? `r-${aliasTag}` : `regor:${tagName}`}"${rawTag.slice(range.end)}`;
|
|
6223
6317
|
out.push(
|
|
6224
|
-
shouldExpandSelfClosing ? expandSelfClosingTag(rewrittenTag, replacementHost) : rewrittenTag
|
|
6318
|
+
shouldExpandSelfClosing ? expandSelfClosingTag(rewrittenTag, replacementHost) : shouldCloseVoidAlias ? closeTag(rewrittenTag, replacementHost) : rewrittenTag
|
|
6225
6319
|
);
|
|
6226
6320
|
} else {
|
|
6227
6321
|
out.push(
|
|
6228
6322
|
shouldExpandSelfClosing ? expandSelfClosingTag(rawTag, tagName) : rawTag
|
|
6229
6323
|
);
|
|
6230
6324
|
}
|
|
6231
|
-
if (
|
|
6232
|
-
|
|
6325
|
+
if (shouldIgnoreClosingTag) {
|
|
6326
|
+
ignoredClosingTags.push({ tagName, emit: false });
|
|
6327
|
+
} else if (shouldCloseVoidAlias && !selfClosing) {
|
|
6328
|
+
ignoredClosingTags.push({ tagName, emit: false });
|
|
6329
|
+
} else if (shouldIgnoreNativeVoidClosingTag) {
|
|
6330
|
+
ignoredClosingTags.push({ tagName, emit: true });
|
|
6331
|
+
}
|
|
6332
|
+
if (!selfClosing && !shouldCloseVoidAlias && !shouldIgnoreClosingTag && !shouldIgnoreNativeVoidClosingTag && !voidElements.has(replacementHost ?? nativeTagName)) {
|
|
6333
|
+
const effectiveTag = aliasTag ?? replacementHost ?? (nativeTagName || tagName);
|
|
6233
6334
|
stack.push({
|
|
6234
6335
|
replacementHost,
|
|
6235
|
-
effectiveTag
|
|
6336
|
+
effectiveTag,
|
|
6337
|
+
isTableAlias
|
|
6236
6338
|
});
|
|
6237
|
-
if (
|
|
6339
|
+
if (!isTableAlias && isTableScopeTag(effectiveTag)) ++tableScopeDepth;
|
|
6238
6340
|
}
|
|
6239
6341
|
i = tagEnd + 1;
|
|
6240
6342
|
}
|