regor 1.6.5 → 1.6.7

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.
@@ -244,7 +244,7 @@ var Regor = (() => {
244
244
 
245
245
  // src/reactivity/isRef.ts
246
246
  var isRef = (value) => {
247
- return value != null && value[srefSymbol] === 1;
247
+ return value != null && value[srefSymbol] > 0;
248
248
  };
249
249
 
250
250
  // src/app/propValidators.ts
@@ -1100,6 +1100,8 @@ var Regor = (() => {
1100
1100
  configurable: false
1101
1101
  };
1102
1102
  var defineRefValue = (result, isReadOnly) => {
1103
+ ;
1104
+ result[srefSymbol] = isReadOnly ? 2 : 1;
1103
1105
  Object.defineProperty(
1104
1106
  result,
1105
1107
  "value",
@@ -1237,9 +1239,24 @@ var Regor = (() => {
1237
1239
  };
1238
1240
 
1239
1241
  // src/reactivity/entangle.ts
1242
+ var isReadonly = (value) => value[srefSymbol] === 2;
1240
1243
  var entangle = (r1, r2) => {
1241
1244
  if (r1 === r2) return () => {
1242
1245
  };
1246
+ const r1Readonly = isReadonly(r1);
1247
+ const r2Readonly = isReadonly(r2);
1248
+ if (r1Readonly && r2Readonly) return () => {
1249
+ };
1250
+ if (r1Readonly) {
1251
+ const stop = observe(r1, () => r2(r1()));
1252
+ r2(r1());
1253
+ return stop;
1254
+ }
1255
+ if (r2Readonly) {
1256
+ const stop = observe(r2, () => r1(r2()));
1257
+ r1(r2());
1258
+ return stop;
1259
+ }
1243
1260
  const stop1 = observe(r1, (v) => r2(v));
1244
1261
  const stop2 = observe(r2, (v) => r1(v));
1245
1262
  r2(r1());
@@ -1502,7 +1519,6 @@ var Regor = (() => {
1502
1519
  }
1503
1520
  return refObj._value;
1504
1521
  };
1505
- srefFunction[srefSymbol] = 1;
1506
1522
  defineRefValue(srefFunction, false);
1507
1523
  if (isProxy) attachProxyHandle(value);
1508
1524
  return srefFunction;
@@ -2263,7 +2279,7 @@ var Regor = (() => {
2263
2279
  // src/reactivity/unref.ts
2264
2280
  var unref = (value) => {
2265
2281
  const anyValue = value;
2266
- return anyValue != null && anyValue[srefSymbol] === 1 ? anyValue() : anyValue;
2282
+ return anyValue != null && anyValue[srefSymbol] > 0 ? anyValue() : anyValue;
2267
2283
  };
2268
2284
 
2269
2285
  // src/directives/html.ts
@@ -6225,19 +6241,50 @@ var Regor = (() => {
6225
6241
  while (i < tagText.length && (tagText[i] === " " || tagText[i] === "\n")) ++i;
6226
6242
  if (i >= tagText.length || !isNameChar(tagText[i])) return null;
6227
6243
  const start = i;
6228
- while (i < tagText.length && isNameChar(tagText[i])) ++i;
6229
- return { start, end: i };
6230
- };
6231
- var tableScopeTags = /* @__PURE__ */ new Set(["table", "thead", "tbody", "tfoot"]);
6232
- var rowParentTags = /* @__PURE__ */ new Set(["thead", "tbody", "tfoot"]);
6233
- var tableDirectAllowed = /* @__PURE__ */ new Set([
6234
- "caption",
6235
- "colgroup",
6236
- "thead",
6237
- "tbody",
6238
- "tfoot",
6239
- "tr"
6240
- ]);
6244
+ let hasUppercase = false;
6245
+ while (i < tagText.length && isNameChar(tagText[i])) {
6246
+ const c = tagText.charCodeAt(i);
6247
+ if (c >= 65 && c <= 90) {
6248
+ hasUppercase = true;
6249
+ }
6250
+ ++i;
6251
+ }
6252
+ return { start, end: i, hasUppercase };
6253
+ };
6254
+ var isTableScopeTag = (tagName) => {
6255
+ switch (tagName) {
6256
+ case "table":
6257
+ case "thead":
6258
+ case "tbody":
6259
+ case "tfoot":
6260
+ return true;
6261
+ default:
6262
+ return false;
6263
+ }
6264
+ };
6265
+ var isRowParentTag = (tagName) => {
6266
+ switch (tagName) {
6267
+ case "thead":
6268
+ case "tbody":
6269
+ case "tfoot":
6270
+ return true;
6271
+ default:
6272
+ return false;
6273
+ }
6274
+ };
6275
+ var isTableDirectAllowed = (tagName) => {
6276
+ switch (tagName) {
6277
+ case "caption":
6278
+ case "colgroup":
6279
+ case "thead":
6280
+ case "tbody":
6281
+ case "tfoot":
6282
+ case "tr":
6283
+ return true;
6284
+ default:
6285
+ return false;
6286
+ }
6287
+ };
6241
6288
  var voidElements = /* @__PURE__ */ new Set([
6242
6289
  "area",
6243
6290
  "base",
@@ -6254,12 +6301,62 @@ var Regor = (() => {
6254
6301
  "track",
6255
6302
  "wbr"
6256
6303
  ]);
6304
+ var getTableAliasHost = (tagName) => {
6305
+ switch (tagName) {
6306
+ case "caption":
6307
+ return "captionx";
6308
+ case "thead":
6309
+ return "theadx";
6310
+ case "tbody":
6311
+ return "tbodyx";
6312
+ case "tfoot":
6313
+ return "tfootx";
6314
+ case "tr":
6315
+ return "trx";
6316
+ case "td":
6317
+ return "tdx";
6318
+ case "th":
6319
+ return "thx";
6320
+ case "colgroup":
6321
+ return "colgroupx";
6322
+ case "col":
6323
+ return "colx";
6324
+ default:
6325
+ return null;
6326
+ }
6327
+ };
6328
+ var getTableAliasTag = (host) => {
6329
+ switch (host) {
6330
+ case "captionx":
6331
+ return "caption";
6332
+ case "theadx":
6333
+ return "thead";
6334
+ case "tbodyx":
6335
+ return "tbody";
6336
+ case "tfootx":
6337
+ return "tfoot";
6338
+ case "trx":
6339
+ return "tr";
6340
+ case "tdx":
6341
+ return "td";
6342
+ case "thx":
6343
+ return "th";
6344
+ case "colgroupx":
6345
+ return "colgroup";
6346
+ case "colx":
6347
+ return "col";
6348
+ default:
6349
+ return void 0;
6350
+ }
6351
+ };
6352
+ var closeTag = (tagText, tagName) => `${tagText}</${tagName}>`;
6257
6353
  var expandSelfClosingTag = (tagText, tagName) => `${tagText.slice(0, tagText.length - 2)}></${tagName}>`;
6258
6354
  var preprocess = (template) => {
6259
- var _a;
6355
+ var _a, _b;
6260
6356
  let i = 0;
6261
6357
  const out = [];
6262
6358
  const stack = [];
6359
+ const ignoredClosingTags = [];
6263
6360
  let tableScopeDepth = 0;
6264
6361
  while (i < template.length) {
6265
6362
  const lt = template.indexOf("<", i);
@@ -6298,12 +6395,21 @@ var Regor = (() => {
6298
6395
  continue;
6299
6396
  }
6300
6397
  const tagName = rawTag.slice(range.start, range.end);
6398
+ const nativeTagName = range.hasUppercase ? "" : tagName;
6301
6399
  if (isClosing) {
6400
+ const ignoredClosing = ignoredClosingTags[ignoredClosingTags.length - 1];
6401
+ if ((ignoredClosing == null ? void 0 : ignoredClosing.tagName) === tagName) {
6402
+ ignoredClosingTags.pop();
6403
+ if (ignoredClosing.emit) out.push(rawTag);
6404
+ i = tagEnd + 1;
6405
+ continue;
6406
+ }
6302
6407
  const top = stack[stack.length - 1];
6303
6408
  if (top) {
6304
6409
  stack.pop();
6305
6410
  out.push(top.replacementHost ? `</${top.replacementHost}>` : rawTag);
6306
- if (tableScopeTags.has(top.effectiveTag)) --tableScopeDepth;
6411
+ if (!top.isTableAlias && isTableScopeTag(top.effectiveTag))
6412
+ --tableScopeDepth;
6307
6413
  } else {
6308
6414
  out.push(rawTag);
6309
6415
  }
@@ -6314,35 +6420,47 @@ var Regor = (() => {
6314
6420
  const parent = stack[stack.length - 1];
6315
6421
  let replacementHost = null;
6316
6422
  if (tableScopeDepth === 0) {
6317
- if (tagName === "tr") replacementHost = "trx";
6318
- else if (tagName === "td") replacementHost = "tdx";
6319
- else if (tagName === "th") replacementHost = "thx";
6320
- } else if (rowParentTags.has((_a = parent == null ? void 0 : parent.effectiveTag) != null ? _a : "")) {
6321
- replacementHost = tagName === "tr" ? null : "tr";
6423
+ replacementHost = getTableAliasHost(nativeTagName);
6424
+ } else if (isRowParentTag((_a = parent == null ? void 0 : parent.effectiveTag) != null ? _a : "")) {
6425
+ replacementHost = nativeTagName === "tr" ? null : "tr";
6322
6426
  } else if ((parent == null ? void 0 : parent.effectiveTag) === "table") {
6323
- replacementHost = tableDirectAllowed.has(tagName) ? null : "tr";
6427
+ replacementHost = isTableDirectAllowed(nativeTagName) ? null : "tr";
6324
6428
  } else if ((parent == null ? void 0 : parent.effectiveTag) === "tr") {
6325
- replacementHost = tagName === "td" || tagName === "th" ? null : "td";
6326
- }
6327
- const shouldExpandSelfClosing = selfClosing && !voidElements.has(replacementHost || tagName);
6429
+ replacementHost = nativeTagName === "td" || nativeTagName === "th" ? null : "td";
6430
+ } else if ((parent == null ? void 0 : parent.effectiveTag) === "colgroup") {
6431
+ replacementHost = nativeTagName === "col" ? null : "col";
6432
+ }
6433
+ const aliasTag = getTableAliasTag(replacementHost);
6434
+ const isTableAlias = aliasTag !== void 0;
6435
+ const shouldExpandSelfClosing = selfClosing && !voidElements.has(replacementHost || nativeTagName);
6436
+ const shouldCloseVoidAlias = !!replacementHost && aliasTag === nativeTagName && voidElements.has(nativeTagName);
6437
+ const shouldIgnoreClosingTag = !selfClosing && !!replacementHost && voidElements.has(replacementHost) && !shouldCloseVoidAlias;
6438
+ const shouldIgnoreNativeVoidClosingTag = !selfClosing && !replacementHost && voidElements.has(nativeTagName);
6328
6439
  if (replacementHost) {
6329
- const isAlias = replacementHost === "trx" || replacementHost === "tdx" || replacementHost === "thx";
6330
- const rewrittenTag = `${rawTag.slice(0, range.start)}${replacementHost} is="${isAlias ? `r-${tagName}` : `regor:${tagName}`}"${rawTag.slice(range.end)}`;
6440
+ const rewrittenTag = `${rawTag.slice(0, range.start)}${replacementHost} is="${aliasTag ? `r-${aliasTag}` : `regor:${tagName}`}"${rawTag.slice(range.end)}`;
6331
6441
  out.push(
6332
- shouldExpandSelfClosing ? expandSelfClosingTag(rewrittenTag, replacementHost) : rewrittenTag
6442
+ shouldExpandSelfClosing ? expandSelfClosingTag(rewrittenTag, replacementHost) : shouldCloseVoidAlias ? closeTag(rewrittenTag, replacementHost) : rewrittenTag
6333
6443
  );
6334
6444
  } else {
6335
6445
  out.push(
6336
6446
  shouldExpandSelfClosing ? expandSelfClosingTag(rawTag, tagName) : rawTag
6337
6447
  );
6338
6448
  }
6339
- if (!selfClosing) {
6340
- const effectiveTag = replacementHost === "trx" ? "tr" : replacementHost === "tdx" ? "td" : replacementHost === "thx" ? "th" : replacementHost || tagName;
6449
+ if (shouldIgnoreClosingTag) {
6450
+ ignoredClosingTags.push({ tagName, emit: false });
6451
+ } else if (shouldCloseVoidAlias && !selfClosing) {
6452
+ ignoredClosingTags.push({ tagName, emit: false });
6453
+ } else if (shouldIgnoreNativeVoidClosingTag) {
6454
+ ignoredClosingTags.push({ tagName, emit: true });
6455
+ }
6456
+ if (!selfClosing && !shouldCloseVoidAlias && !shouldIgnoreClosingTag && !shouldIgnoreNativeVoidClosingTag && !voidElements.has(replacementHost != null ? replacementHost : nativeTagName)) {
6457
+ const effectiveTag = (_b = aliasTag != null ? aliasTag : replacementHost) != null ? _b : nativeTagName || tagName;
6341
6458
  stack.push({
6342
6459
  replacementHost,
6343
- effectiveTag
6460
+ effectiveTag,
6461
+ isTableAlias
6344
6462
  });
6345
- if (tableScopeTags.has(effectiveTag)) ++tableScopeDepth;
6463
+ if (!isTableAlias && isTableScopeTag(effectiveTag)) ++tableScopeDepth;
6346
6464
  }
6347
6465
  i = tagEnd + 1;
6348
6466
  }