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.
@@ -281,7 +281,7 @@ var Regor = (() => {
281
281
 
282
282
  // src/reactivity/isRef.ts
283
283
  var isRef = (value) => {
284
- return value != null && value[srefSymbol] === 1;
284
+ return value != null && value[srefSymbol] > 0;
285
285
  };
286
286
 
287
287
  // src/app/propValidators.ts
@@ -1137,6 +1137,8 @@ var Regor = (() => {
1137
1137
  configurable: false
1138
1138
  };
1139
1139
  var defineRefValue = (result, isReadOnly) => {
1140
+ ;
1141
+ result[srefSymbol] = isReadOnly ? 2 : 1;
1140
1142
  Object.defineProperty(
1141
1143
  result,
1142
1144
  "value",
@@ -1274,9 +1276,24 @@ var Regor = (() => {
1274
1276
  };
1275
1277
 
1276
1278
  // src/reactivity/entangle.ts
1279
+ var isReadonly = (value) => value[srefSymbol] === 2;
1277
1280
  var entangle = (r1, r2) => {
1278
1281
  if (r1 === r2) return () => {
1279
1282
  };
1283
+ const r1Readonly = isReadonly(r1);
1284
+ const r2Readonly = isReadonly(r2);
1285
+ if (r1Readonly && r2Readonly) return () => {
1286
+ };
1287
+ if (r1Readonly) {
1288
+ const stop = observe(r1, () => r2(r1()));
1289
+ r2(r1());
1290
+ return stop;
1291
+ }
1292
+ if (r2Readonly) {
1293
+ const stop = observe(r2, () => r1(r2()));
1294
+ r1(r2());
1295
+ return stop;
1296
+ }
1280
1297
  const stop1 = observe(r1, (v) => r2(v));
1281
1298
  const stop2 = observe(r2, (v) => r1(v));
1282
1299
  r2(r1());
@@ -1539,7 +1556,6 @@ var Regor = (() => {
1539
1556
  }
1540
1557
  return refObj._value;
1541
1558
  };
1542
- srefFunction[srefSymbol] = 1;
1543
1559
  defineRefValue(srefFunction, false);
1544
1560
  if (isProxy) attachProxyHandle(value);
1545
1561
  return srefFunction;
@@ -2300,7 +2316,7 @@ var Regor = (() => {
2300
2316
  // src/reactivity/unref.ts
2301
2317
  var unref = (value) => {
2302
2318
  const anyValue = value;
2303
- return anyValue != null && anyValue[srefSymbol] === 1 ? anyValue() : anyValue;
2319
+ return anyValue != null && anyValue[srefSymbol] > 0 ? anyValue() : anyValue;
2304
2320
  };
2305
2321
 
2306
2322
  // src/directives/html.ts
@@ -6262,19 +6278,50 @@ var Regor = (() => {
6262
6278
  while (i < tagText.length && (tagText[i] === " " || tagText[i] === "\n")) ++i;
6263
6279
  if (i >= tagText.length || !isNameChar(tagText[i])) return null;
6264
6280
  const start = i;
6265
- while (i < tagText.length && isNameChar(tagText[i])) ++i;
6266
- return { start, end: i };
6267
- };
6268
- var tableScopeTags = /* @__PURE__ */ new Set(["table", "thead", "tbody", "tfoot"]);
6269
- var rowParentTags = /* @__PURE__ */ new Set(["thead", "tbody", "tfoot"]);
6270
- var tableDirectAllowed = /* @__PURE__ */ new Set([
6271
- "caption",
6272
- "colgroup",
6273
- "thead",
6274
- "tbody",
6275
- "tfoot",
6276
- "tr"
6277
- ]);
6281
+ let hasUppercase = false;
6282
+ while (i < tagText.length && isNameChar(tagText[i])) {
6283
+ const c = tagText.charCodeAt(i);
6284
+ if (c >= 65 && c <= 90) {
6285
+ hasUppercase = true;
6286
+ }
6287
+ ++i;
6288
+ }
6289
+ return { start, end: i, hasUppercase };
6290
+ };
6291
+ var isTableScopeTag = (tagName) => {
6292
+ switch (tagName) {
6293
+ case "table":
6294
+ case "thead":
6295
+ case "tbody":
6296
+ case "tfoot":
6297
+ return true;
6298
+ default:
6299
+ return false;
6300
+ }
6301
+ };
6302
+ var isRowParentTag = (tagName) => {
6303
+ switch (tagName) {
6304
+ case "thead":
6305
+ case "tbody":
6306
+ case "tfoot":
6307
+ return true;
6308
+ default:
6309
+ return false;
6310
+ }
6311
+ };
6312
+ var isTableDirectAllowed = (tagName) => {
6313
+ switch (tagName) {
6314
+ case "caption":
6315
+ case "colgroup":
6316
+ case "thead":
6317
+ case "tbody":
6318
+ case "tfoot":
6319
+ case "tr":
6320
+ return true;
6321
+ default:
6322
+ return false;
6323
+ }
6324
+ };
6278
6325
  var voidElements = /* @__PURE__ */ new Set([
6279
6326
  "area",
6280
6327
  "base",
@@ -6291,12 +6338,62 @@ var Regor = (() => {
6291
6338
  "track",
6292
6339
  "wbr"
6293
6340
  ]);
6341
+ var getTableAliasHost = (tagName) => {
6342
+ switch (tagName) {
6343
+ case "caption":
6344
+ return "captionx";
6345
+ case "thead":
6346
+ return "theadx";
6347
+ case "tbody":
6348
+ return "tbodyx";
6349
+ case "tfoot":
6350
+ return "tfootx";
6351
+ case "tr":
6352
+ return "trx";
6353
+ case "td":
6354
+ return "tdx";
6355
+ case "th":
6356
+ return "thx";
6357
+ case "colgroup":
6358
+ return "colgroupx";
6359
+ case "col":
6360
+ return "colx";
6361
+ default:
6362
+ return null;
6363
+ }
6364
+ };
6365
+ var getTableAliasTag = (host) => {
6366
+ switch (host) {
6367
+ case "captionx":
6368
+ return "caption";
6369
+ case "theadx":
6370
+ return "thead";
6371
+ case "tbodyx":
6372
+ return "tbody";
6373
+ case "tfootx":
6374
+ return "tfoot";
6375
+ case "trx":
6376
+ return "tr";
6377
+ case "tdx":
6378
+ return "td";
6379
+ case "thx":
6380
+ return "th";
6381
+ case "colgroupx":
6382
+ return "colgroup";
6383
+ case "colx":
6384
+ return "col";
6385
+ default:
6386
+ return void 0;
6387
+ }
6388
+ };
6389
+ var closeTag = (tagText, tagName) => `${tagText}</${tagName}>`;
6294
6390
  var expandSelfClosingTag = (tagText, tagName) => `${tagText.slice(0, tagText.length - 2)}></${tagName}>`;
6295
6391
  var preprocess = (template) => {
6296
- var _a;
6392
+ var _a, _b;
6297
6393
  let i = 0;
6298
6394
  const out = [];
6299
6395
  const stack = [];
6396
+ const ignoredClosingTags = [];
6300
6397
  let tableScopeDepth = 0;
6301
6398
  while (i < template.length) {
6302
6399
  const lt = template.indexOf("<", i);
@@ -6335,12 +6432,21 @@ var Regor = (() => {
6335
6432
  continue;
6336
6433
  }
6337
6434
  const tagName = rawTag.slice(range.start, range.end);
6435
+ const nativeTagName = range.hasUppercase ? "" : tagName;
6338
6436
  if (isClosing) {
6437
+ const ignoredClosing = ignoredClosingTags[ignoredClosingTags.length - 1];
6438
+ if ((ignoredClosing == null ? void 0 : ignoredClosing.tagName) === tagName) {
6439
+ ignoredClosingTags.pop();
6440
+ if (ignoredClosing.emit) out.push(rawTag);
6441
+ i = tagEnd + 1;
6442
+ continue;
6443
+ }
6339
6444
  const top = stack[stack.length - 1];
6340
6445
  if (top) {
6341
6446
  stack.pop();
6342
6447
  out.push(top.replacementHost ? `</${top.replacementHost}>` : rawTag);
6343
- if (tableScopeTags.has(top.effectiveTag)) --tableScopeDepth;
6448
+ if (!top.isTableAlias && isTableScopeTag(top.effectiveTag))
6449
+ --tableScopeDepth;
6344
6450
  } else {
6345
6451
  out.push(rawTag);
6346
6452
  }
@@ -6351,35 +6457,47 @@ var Regor = (() => {
6351
6457
  const parent = stack[stack.length - 1];
6352
6458
  let replacementHost = null;
6353
6459
  if (tableScopeDepth === 0) {
6354
- if (tagName === "tr") replacementHost = "trx";
6355
- else if (tagName === "td") replacementHost = "tdx";
6356
- else if (tagName === "th") replacementHost = "thx";
6357
- } else if (rowParentTags.has((_a = parent == null ? void 0 : parent.effectiveTag) != null ? _a : "")) {
6358
- replacementHost = tagName === "tr" ? null : "tr";
6460
+ replacementHost = getTableAliasHost(nativeTagName);
6461
+ } else if (isRowParentTag((_a = parent == null ? void 0 : parent.effectiveTag) != null ? _a : "")) {
6462
+ replacementHost = nativeTagName === "tr" ? null : "tr";
6359
6463
  } else if ((parent == null ? void 0 : parent.effectiveTag) === "table") {
6360
- replacementHost = tableDirectAllowed.has(tagName) ? null : "tr";
6464
+ replacementHost = isTableDirectAllowed(nativeTagName) ? null : "tr";
6361
6465
  } else if ((parent == null ? void 0 : parent.effectiveTag) === "tr") {
6362
- replacementHost = tagName === "td" || tagName === "th" ? null : "td";
6363
- }
6364
- const shouldExpandSelfClosing = selfClosing && !voidElements.has(replacementHost || tagName);
6466
+ replacementHost = nativeTagName === "td" || nativeTagName === "th" ? null : "td";
6467
+ } else if ((parent == null ? void 0 : parent.effectiveTag) === "colgroup") {
6468
+ replacementHost = nativeTagName === "col" ? null : "col";
6469
+ }
6470
+ const aliasTag = getTableAliasTag(replacementHost);
6471
+ const isTableAlias = aliasTag !== void 0;
6472
+ const shouldExpandSelfClosing = selfClosing && !voidElements.has(replacementHost || nativeTagName);
6473
+ const shouldCloseVoidAlias = !!replacementHost && aliasTag === nativeTagName && voidElements.has(nativeTagName);
6474
+ const shouldIgnoreClosingTag = !selfClosing && !!replacementHost && voidElements.has(replacementHost) && !shouldCloseVoidAlias;
6475
+ const shouldIgnoreNativeVoidClosingTag = !selfClosing && !replacementHost && voidElements.has(nativeTagName);
6365
6476
  if (replacementHost) {
6366
- const isAlias = replacementHost === "trx" || replacementHost === "tdx" || replacementHost === "thx";
6367
- const rewrittenTag = `${rawTag.slice(0, range.start)}${replacementHost} is="${isAlias ? `r-${tagName}` : `regor:${tagName}`}"${rawTag.slice(range.end)}`;
6477
+ const rewrittenTag = `${rawTag.slice(0, range.start)}${replacementHost} is="${aliasTag ? `r-${aliasTag}` : `regor:${tagName}`}"${rawTag.slice(range.end)}`;
6368
6478
  out.push(
6369
- shouldExpandSelfClosing ? expandSelfClosingTag(rewrittenTag, replacementHost) : rewrittenTag
6479
+ shouldExpandSelfClosing ? expandSelfClosingTag(rewrittenTag, replacementHost) : shouldCloseVoidAlias ? closeTag(rewrittenTag, replacementHost) : rewrittenTag
6370
6480
  );
6371
6481
  } else {
6372
6482
  out.push(
6373
6483
  shouldExpandSelfClosing ? expandSelfClosingTag(rawTag, tagName) : rawTag
6374
6484
  );
6375
6485
  }
6376
- if (!selfClosing) {
6377
- const effectiveTag = replacementHost === "trx" ? "tr" : replacementHost === "tdx" ? "td" : replacementHost === "thx" ? "th" : replacementHost || tagName;
6486
+ if (shouldIgnoreClosingTag) {
6487
+ ignoredClosingTags.push({ tagName, emit: false });
6488
+ } else if (shouldCloseVoidAlias && !selfClosing) {
6489
+ ignoredClosingTags.push({ tagName, emit: false });
6490
+ } else if (shouldIgnoreNativeVoidClosingTag) {
6491
+ ignoredClosingTags.push({ tagName, emit: true });
6492
+ }
6493
+ if (!selfClosing && !shouldCloseVoidAlias && !shouldIgnoreClosingTag && !shouldIgnoreNativeVoidClosingTag && !voidElements.has(replacementHost != null ? replacementHost : nativeTagName)) {
6494
+ const effectiveTag = (_b = aliasTag != null ? aliasTag : replacementHost) != null ? _b : nativeTagName || tagName;
6378
6495
  stack.push({
6379
6496
  replacementHost,
6380
- effectiveTag
6497
+ effectiveTag,
6498
+ isTableAlias
6381
6499
  });
6382
- if (tableScopeTags.has(effectiveTag)) ++tableScopeDepth;
6500
+ if (!isTableAlias && isTableScopeTag(effectiveTag)) ++tableScopeDepth;
6383
6501
  }
6384
6502
  i = tagEnd + 1;
6385
6503
  }