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.
@@ -214,7 +214,7 @@ var rawSymbol = Symbol("raw");
214
214
 
215
215
  // src/reactivity/isRef.ts
216
216
  var isRef = (value) => {
217
- return value != null && value[srefSymbol] === 1;
217
+ return value != null && value[srefSymbol] > 0;
218
218
  };
219
219
 
220
220
  // src/app/propValidators.ts
@@ -1070,6 +1070,8 @@ var readonlyRefValueDescriptor = {
1070
1070
  configurable: false
1071
1071
  };
1072
1072
  var defineRefValue = (result, isReadOnly) => {
1073
+ ;
1074
+ result[srefSymbol] = isReadOnly ? 2 : 1;
1073
1075
  Object.defineProperty(
1074
1076
  result,
1075
1077
  "value",
@@ -1207,9 +1209,24 @@ var observe = (source, observer, init, trackUnmount = true) => {
1207
1209
  };
1208
1210
 
1209
1211
  // src/reactivity/entangle.ts
1212
+ var isReadonly = (value) => value[srefSymbol] === 2;
1210
1213
  var entangle = (r1, r2) => {
1211
1214
  if (r1 === r2) return () => {
1212
1215
  };
1216
+ const r1Readonly = isReadonly(r1);
1217
+ const r2Readonly = isReadonly(r2);
1218
+ if (r1Readonly && r2Readonly) return () => {
1219
+ };
1220
+ if (r1Readonly) {
1221
+ const stop = observe(r1, () => r2(r1()));
1222
+ r2(r1());
1223
+ return stop;
1224
+ }
1225
+ if (r2Readonly) {
1226
+ const stop = observe(r2, () => r1(r2()));
1227
+ r1(r2());
1228
+ return stop;
1229
+ }
1213
1230
  const stop1 = observe(r1, (v) => r2(v));
1214
1231
  const stop2 = observe(r2, (v) => r1(v));
1215
1232
  r2(r1());
@@ -1472,7 +1489,6 @@ var sref = (value) => {
1472
1489
  }
1473
1490
  return refObj._value;
1474
1491
  };
1475
- srefFunction[srefSymbol] = 1;
1476
1492
  defineRefValue(srefFunction, false);
1477
1493
  if (isProxy) attachProxyHandle(value);
1478
1494
  return srefFunction;
@@ -2233,7 +2249,7 @@ var DynamicBinder = class {
2233
2249
  // src/reactivity/unref.ts
2234
2250
  var unref = (value) => {
2235
2251
  const anyValue = value;
2236
- return anyValue != null && anyValue[srefSymbol] === 1 ? anyValue() : anyValue;
2252
+ return anyValue != null && anyValue[srefSymbol] > 0 ? anyValue() : anyValue;
2237
2253
  };
2238
2254
 
2239
2255
  // src/directives/html.ts
@@ -6195,19 +6211,50 @@ var parseTagNameRange = (tagText, isClosing) => {
6195
6211
  while (i < tagText.length && (tagText[i] === " " || tagText[i] === "\n")) ++i;
6196
6212
  if (i >= tagText.length || !isNameChar(tagText[i])) return null;
6197
6213
  const start = i;
6198
- while (i < tagText.length && isNameChar(tagText[i])) ++i;
6199
- return { start, end: i };
6200
- };
6201
- var tableScopeTags = /* @__PURE__ */ new Set(["table", "thead", "tbody", "tfoot"]);
6202
- var rowParentTags = /* @__PURE__ */ new Set(["thead", "tbody", "tfoot"]);
6203
- var tableDirectAllowed = /* @__PURE__ */ new Set([
6204
- "caption",
6205
- "colgroup",
6206
- "thead",
6207
- "tbody",
6208
- "tfoot",
6209
- "tr"
6210
- ]);
6214
+ let hasUppercase = false;
6215
+ while (i < tagText.length && isNameChar(tagText[i])) {
6216
+ const c = tagText.charCodeAt(i);
6217
+ if (c >= 65 && c <= 90) {
6218
+ hasUppercase = true;
6219
+ }
6220
+ ++i;
6221
+ }
6222
+ return { start, end: i, hasUppercase };
6223
+ };
6224
+ var isTableScopeTag = (tagName) => {
6225
+ switch (tagName) {
6226
+ case "table":
6227
+ case "thead":
6228
+ case "tbody":
6229
+ case "tfoot":
6230
+ return true;
6231
+ default:
6232
+ return false;
6233
+ }
6234
+ };
6235
+ var isRowParentTag = (tagName) => {
6236
+ switch (tagName) {
6237
+ case "thead":
6238
+ case "tbody":
6239
+ case "tfoot":
6240
+ return true;
6241
+ default:
6242
+ return false;
6243
+ }
6244
+ };
6245
+ var isTableDirectAllowed = (tagName) => {
6246
+ switch (tagName) {
6247
+ case "caption":
6248
+ case "colgroup":
6249
+ case "thead":
6250
+ case "tbody":
6251
+ case "tfoot":
6252
+ case "tr":
6253
+ return true;
6254
+ default:
6255
+ return false;
6256
+ }
6257
+ };
6211
6258
  var voidElements = /* @__PURE__ */ new Set([
6212
6259
  "area",
6213
6260
  "base",
@@ -6224,12 +6271,62 @@ var voidElements = /* @__PURE__ */ new Set([
6224
6271
  "track",
6225
6272
  "wbr"
6226
6273
  ]);
6274
+ var getTableAliasHost = (tagName) => {
6275
+ switch (tagName) {
6276
+ case "caption":
6277
+ return "captionx";
6278
+ case "thead":
6279
+ return "theadx";
6280
+ case "tbody":
6281
+ return "tbodyx";
6282
+ case "tfoot":
6283
+ return "tfootx";
6284
+ case "tr":
6285
+ return "trx";
6286
+ case "td":
6287
+ return "tdx";
6288
+ case "th":
6289
+ return "thx";
6290
+ case "colgroup":
6291
+ return "colgroupx";
6292
+ case "col":
6293
+ return "colx";
6294
+ default:
6295
+ return null;
6296
+ }
6297
+ };
6298
+ var getTableAliasTag = (host) => {
6299
+ switch (host) {
6300
+ case "captionx":
6301
+ return "caption";
6302
+ case "theadx":
6303
+ return "thead";
6304
+ case "tbodyx":
6305
+ return "tbody";
6306
+ case "tfootx":
6307
+ return "tfoot";
6308
+ case "trx":
6309
+ return "tr";
6310
+ case "tdx":
6311
+ return "td";
6312
+ case "thx":
6313
+ return "th";
6314
+ case "colgroupx":
6315
+ return "colgroup";
6316
+ case "colx":
6317
+ return "col";
6318
+ default:
6319
+ return void 0;
6320
+ }
6321
+ };
6322
+ var closeTag = (tagText, tagName) => `${tagText}</${tagName}>`;
6227
6323
  var expandSelfClosingTag = (tagText, tagName) => `${tagText.slice(0, tagText.length - 2)}></${tagName}>`;
6228
6324
  var preprocess = (template) => {
6229
- var _a;
6325
+ var _a, _b;
6230
6326
  let i = 0;
6231
6327
  const out = [];
6232
6328
  const stack = [];
6329
+ const ignoredClosingTags = [];
6233
6330
  let tableScopeDepth = 0;
6234
6331
  while (i < template.length) {
6235
6332
  const lt = template.indexOf("<", i);
@@ -6268,12 +6365,21 @@ var preprocess = (template) => {
6268
6365
  continue;
6269
6366
  }
6270
6367
  const tagName = rawTag.slice(range.start, range.end);
6368
+ const nativeTagName = range.hasUppercase ? "" : tagName;
6271
6369
  if (isClosing) {
6370
+ const ignoredClosing = ignoredClosingTags[ignoredClosingTags.length - 1];
6371
+ if ((ignoredClosing == null ? void 0 : ignoredClosing.tagName) === tagName) {
6372
+ ignoredClosingTags.pop();
6373
+ if (ignoredClosing.emit) out.push(rawTag);
6374
+ i = tagEnd + 1;
6375
+ continue;
6376
+ }
6272
6377
  const top = stack[stack.length - 1];
6273
6378
  if (top) {
6274
6379
  stack.pop();
6275
6380
  out.push(top.replacementHost ? `</${top.replacementHost}>` : rawTag);
6276
- if (tableScopeTags.has(top.effectiveTag)) --tableScopeDepth;
6381
+ if (!top.isTableAlias && isTableScopeTag(top.effectiveTag))
6382
+ --tableScopeDepth;
6277
6383
  } else {
6278
6384
  out.push(rawTag);
6279
6385
  }
@@ -6284,35 +6390,47 @@ var preprocess = (template) => {
6284
6390
  const parent = stack[stack.length - 1];
6285
6391
  let replacementHost = null;
6286
6392
  if (tableScopeDepth === 0) {
6287
- if (tagName === "tr") replacementHost = "trx";
6288
- else if (tagName === "td") replacementHost = "tdx";
6289
- else if (tagName === "th") replacementHost = "thx";
6290
- } else if (rowParentTags.has((_a = parent == null ? void 0 : parent.effectiveTag) != null ? _a : "")) {
6291
- replacementHost = tagName === "tr" ? null : "tr";
6393
+ replacementHost = getTableAliasHost(nativeTagName);
6394
+ } else if (isRowParentTag((_a = parent == null ? void 0 : parent.effectiveTag) != null ? _a : "")) {
6395
+ replacementHost = nativeTagName === "tr" ? null : "tr";
6292
6396
  } else if ((parent == null ? void 0 : parent.effectiveTag) === "table") {
6293
- replacementHost = tableDirectAllowed.has(tagName) ? null : "tr";
6397
+ replacementHost = isTableDirectAllowed(nativeTagName) ? null : "tr";
6294
6398
  } else if ((parent == null ? void 0 : parent.effectiveTag) === "tr") {
6295
- replacementHost = tagName === "td" || tagName === "th" ? null : "td";
6296
- }
6297
- const shouldExpandSelfClosing = selfClosing && !voidElements.has(replacementHost || tagName);
6399
+ replacementHost = nativeTagName === "td" || nativeTagName === "th" ? null : "td";
6400
+ } else if ((parent == null ? void 0 : parent.effectiveTag) === "colgroup") {
6401
+ replacementHost = nativeTagName === "col" ? null : "col";
6402
+ }
6403
+ const aliasTag = getTableAliasTag(replacementHost);
6404
+ const isTableAlias = aliasTag !== void 0;
6405
+ const shouldExpandSelfClosing = selfClosing && !voidElements.has(replacementHost || nativeTagName);
6406
+ const shouldCloseVoidAlias = !!replacementHost && aliasTag === nativeTagName && voidElements.has(nativeTagName);
6407
+ const shouldIgnoreClosingTag = !selfClosing && !!replacementHost && voidElements.has(replacementHost) && !shouldCloseVoidAlias;
6408
+ const shouldIgnoreNativeVoidClosingTag = !selfClosing && !replacementHost && voidElements.has(nativeTagName);
6298
6409
  if (replacementHost) {
6299
- const isAlias = replacementHost === "trx" || replacementHost === "tdx" || replacementHost === "thx";
6300
- const rewrittenTag = `${rawTag.slice(0, range.start)}${replacementHost} is="${isAlias ? `r-${tagName}` : `regor:${tagName}`}"${rawTag.slice(range.end)}`;
6410
+ const rewrittenTag = `${rawTag.slice(0, range.start)}${replacementHost} is="${aliasTag ? `r-${aliasTag}` : `regor:${tagName}`}"${rawTag.slice(range.end)}`;
6301
6411
  out.push(
6302
- shouldExpandSelfClosing ? expandSelfClosingTag(rewrittenTag, replacementHost) : rewrittenTag
6412
+ shouldExpandSelfClosing ? expandSelfClosingTag(rewrittenTag, replacementHost) : shouldCloseVoidAlias ? closeTag(rewrittenTag, replacementHost) : rewrittenTag
6303
6413
  );
6304
6414
  } else {
6305
6415
  out.push(
6306
6416
  shouldExpandSelfClosing ? expandSelfClosingTag(rawTag, tagName) : rawTag
6307
6417
  );
6308
6418
  }
6309
- if (!selfClosing) {
6310
- const effectiveTag = replacementHost === "trx" ? "tr" : replacementHost === "tdx" ? "td" : replacementHost === "thx" ? "th" : replacementHost || tagName;
6419
+ if (shouldIgnoreClosingTag) {
6420
+ ignoredClosingTags.push({ tagName, emit: false });
6421
+ } else if (shouldCloseVoidAlias && !selfClosing) {
6422
+ ignoredClosingTags.push({ tagName, emit: false });
6423
+ } else if (shouldIgnoreNativeVoidClosingTag) {
6424
+ ignoredClosingTags.push({ tagName, emit: true });
6425
+ }
6426
+ if (!selfClosing && !shouldCloseVoidAlias && !shouldIgnoreClosingTag && !shouldIgnoreNativeVoidClosingTag && !voidElements.has(replacementHost != null ? replacementHost : nativeTagName)) {
6427
+ const effectiveTag = (_b = aliasTag != null ? aliasTag : replacementHost) != null ? _b : nativeTagName || tagName;
6311
6428
  stack.push({
6312
6429
  replacementHost,
6313
- effectiveTag
6430
+ effectiveTag,
6431
+ isTableAlias
6314
6432
  });
6315
- if (tableScopeTags.has(effectiveTag)) ++tableScopeDepth;
6433
+ if (!isTableAlias && isTableScopeTag(effectiveTag)) ++tableScopeDepth;
6316
6434
  }
6317
6435
  i = tagEnd + 1;
6318
6436
  }