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.
@@ -176,7 +176,7 @@ var rawSymbol = Symbol("raw");
176
176
 
177
177
  // src/reactivity/isRef.ts
178
178
  var isRef = (value) => {
179
- return value != null && value[srefSymbol] === 1;
179
+ return value != null && value[srefSymbol] > 0;
180
180
  };
181
181
 
182
182
  // src/app/propValidators.ts
@@ -1032,6 +1032,8 @@ var readonlyRefValueDescriptor = {
1032
1032
  configurable: false
1033
1033
  };
1034
1034
  var defineRefValue = (result, isReadOnly) => {
1035
+ ;
1036
+ result[srefSymbol] = isReadOnly ? 2 : 1;
1035
1037
  Object.defineProperty(
1036
1038
  result,
1037
1039
  "value",
@@ -1169,9 +1171,24 @@ var observe = (source, observer, init, trackUnmount = true) => {
1169
1171
  };
1170
1172
 
1171
1173
  // src/reactivity/entangle.ts
1174
+ var isReadonly = (value) => value[srefSymbol] === 2;
1172
1175
  var entangle = (r1, r2) => {
1173
1176
  if (r1 === r2) return () => {
1174
1177
  };
1178
+ const r1Readonly = isReadonly(r1);
1179
+ const r2Readonly = isReadonly(r2);
1180
+ if (r1Readonly && r2Readonly) return () => {
1181
+ };
1182
+ if (r1Readonly) {
1183
+ const stop = observe(r1, () => r2(r1()));
1184
+ r2(r1());
1185
+ return stop;
1186
+ }
1187
+ if (r2Readonly) {
1188
+ const stop = observe(r2, () => r1(r2()));
1189
+ r1(r2());
1190
+ return stop;
1191
+ }
1175
1192
  const stop1 = observe(r1, (v) => r2(v));
1176
1193
  const stop2 = observe(r2, (v) => r1(v));
1177
1194
  r2(r1());
@@ -1434,7 +1451,6 @@ var sref = (value) => {
1434
1451
  }
1435
1452
  return refObj._value;
1436
1453
  };
1437
- srefFunction[srefSymbol] = 1;
1438
1454
  defineRefValue(srefFunction, false);
1439
1455
  if (isProxy) attachProxyHandle(value);
1440
1456
  return srefFunction;
@@ -2195,7 +2211,7 @@ var DynamicBinder = class {
2195
2211
  // src/reactivity/unref.ts
2196
2212
  var unref = (value) => {
2197
2213
  const anyValue = value;
2198
- return anyValue != null && anyValue[srefSymbol] === 1 ? anyValue() : anyValue;
2214
+ return anyValue != null && anyValue[srefSymbol] > 0 ? anyValue() : anyValue;
2199
2215
  };
2200
2216
 
2201
2217
  // src/directives/html.ts
@@ -6157,19 +6173,50 @@ var parseTagNameRange = (tagText, isClosing) => {
6157
6173
  while (i < tagText.length && (tagText[i] === " " || tagText[i] === "\n")) ++i;
6158
6174
  if (i >= tagText.length || !isNameChar(tagText[i])) return null;
6159
6175
  const start = i;
6160
- while (i < tagText.length && isNameChar(tagText[i])) ++i;
6161
- return { start, end: i };
6162
- };
6163
- var tableScopeTags = /* @__PURE__ */ new Set(["table", "thead", "tbody", "tfoot"]);
6164
- var rowParentTags = /* @__PURE__ */ new Set(["thead", "tbody", "tfoot"]);
6165
- var tableDirectAllowed = /* @__PURE__ */ new Set([
6166
- "caption",
6167
- "colgroup",
6168
- "thead",
6169
- "tbody",
6170
- "tfoot",
6171
- "tr"
6172
- ]);
6176
+ let hasUppercase = false;
6177
+ while (i < tagText.length && isNameChar(tagText[i])) {
6178
+ const c = tagText.charCodeAt(i);
6179
+ if (c >= 65 && c <= 90) {
6180
+ hasUppercase = true;
6181
+ }
6182
+ ++i;
6183
+ }
6184
+ return { start, end: i, hasUppercase };
6185
+ };
6186
+ var isTableScopeTag = (tagName) => {
6187
+ switch (tagName) {
6188
+ case "table":
6189
+ case "thead":
6190
+ case "tbody":
6191
+ case "tfoot":
6192
+ return true;
6193
+ default:
6194
+ return false;
6195
+ }
6196
+ };
6197
+ var isRowParentTag = (tagName) => {
6198
+ switch (tagName) {
6199
+ case "thead":
6200
+ case "tbody":
6201
+ case "tfoot":
6202
+ return true;
6203
+ default:
6204
+ return false;
6205
+ }
6206
+ };
6207
+ var isTableDirectAllowed = (tagName) => {
6208
+ switch (tagName) {
6209
+ case "caption":
6210
+ case "colgroup":
6211
+ case "thead":
6212
+ case "tbody":
6213
+ case "tfoot":
6214
+ case "tr":
6215
+ return true;
6216
+ default:
6217
+ return false;
6218
+ }
6219
+ };
6173
6220
  var voidElements = /* @__PURE__ */ new Set([
6174
6221
  "area",
6175
6222
  "base",
@@ -6186,12 +6233,62 @@ var voidElements = /* @__PURE__ */ new Set([
6186
6233
  "track",
6187
6234
  "wbr"
6188
6235
  ]);
6236
+ var getTableAliasHost = (tagName) => {
6237
+ switch (tagName) {
6238
+ case "caption":
6239
+ return "captionx";
6240
+ case "thead":
6241
+ return "theadx";
6242
+ case "tbody":
6243
+ return "tbodyx";
6244
+ case "tfoot":
6245
+ return "tfootx";
6246
+ case "tr":
6247
+ return "trx";
6248
+ case "td":
6249
+ return "tdx";
6250
+ case "th":
6251
+ return "thx";
6252
+ case "colgroup":
6253
+ return "colgroupx";
6254
+ case "col":
6255
+ return "colx";
6256
+ default:
6257
+ return null;
6258
+ }
6259
+ };
6260
+ var getTableAliasTag = (host) => {
6261
+ switch (host) {
6262
+ case "captionx":
6263
+ return "caption";
6264
+ case "theadx":
6265
+ return "thead";
6266
+ case "tbodyx":
6267
+ return "tbody";
6268
+ case "tfootx":
6269
+ return "tfoot";
6270
+ case "trx":
6271
+ return "tr";
6272
+ case "tdx":
6273
+ return "td";
6274
+ case "thx":
6275
+ return "th";
6276
+ case "colgroupx":
6277
+ return "colgroup";
6278
+ case "colx":
6279
+ return "col";
6280
+ default:
6281
+ return void 0;
6282
+ }
6283
+ };
6284
+ var closeTag = (tagText, tagName) => `${tagText}</${tagName}>`;
6189
6285
  var expandSelfClosingTag = (tagText, tagName) => `${tagText.slice(0, tagText.length - 2)}></${tagName}>`;
6190
6286
  var preprocess = (template) => {
6191
- var _a;
6287
+ var _a, _b;
6192
6288
  let i = 0;
6193
6289
  const out = [];
6194
6290
  const stack = [];
6291
+ const ignoredClosingTags = [];
6195
6292
  let tableScopeDepth = 0;
6196
6293
  while (i < template.length) {
6197
6294
  const lt = template.indexOf("<", i);
@@ -6230,12 +6327,21 @@ var preprocess = (template) => {
6230
6327
  continue;
6231
6328
  }
6232
6329
  const tagName = rawTag.slice(range.start, range.end);
6330
+ const nativeTagName = range.hasUppercase ? "" : tagName;
6233
6331
  if (isClosing) {
6332
+ const ignoredClosing = ignoredClosingTags[ignoredClosingTags.length - 1];
6333
+ if ((ignoredClosing == null ? void 0 : ignoredClosing.tagName) === tagName) {
6334
+ ignoredClosingTags.pop();
6335
+ if (ignoredClosing.emit) out.push(rawTag);
6336
+ i = tagEnd + 1;
6337
+ continue;
6338
+ }
6234
6339
  const top = stack[stack.length - 1];
6235
6340
  if (top) {
6236
6341
  stack.pop();
6237
6342
  out.push(top.replacementHost ? `</${top.replacementHost}>` : rawTag);
6238
- if (tableScopeTags.has(top.effectiveTag)) --tableScopeDepth;
6343
+ if (!top.isTableAlias && isTableScopeTag(top.effectiveTag))
6344
+ --tableScopeDepth;
6239
6345
  } else {
6240
6346
  out.push(rawTag);
6241
6347
  }
@@ -6246,35 +6352,47 @@ var preprocess = (template) => {
6246
6352
  const parent = stack[stack.length - 1];
6247
6353
  let replacementHost = null;
6248
6354
  if (tableScopeDepth === 0) {
6249
- if (tagName === "tr") replacementHost = "trx";
6250
- else if (tagName === "td") replacementHost = "tdx";
6251
- else if (tagName === "th") replacementHost = "thx";
6252
- } else if (rowParentTags.has((_a = parent == null ? void 0 : parent.effectiveTag) != null ? _a : "")) {
6253
- replacementHost = tagName === "tr" ? null : "tr";
6355
+ replacementHost = getTableAliasHost(nativeTagName);
6356
+ } else if (isRowParentTag((_a = parent == null ? void 0 : parent.effectiveTag) != null ? _a : "")) {
6357
+ replacementHost = nativeTagName === "tr" ? null : "tr";
6254
6358
  } else if ((parent == null ? void 0 : parent.effectiveTag) === "table") {
6255
- replacementHost = tableDirectAllowed.has(tagName) ? null : "tr";
6359
+ replacementHost = isTableDirectAllowed(nativeTagName) ? null : "tr";
6256
6360
  } else if ((parent == null ? void 0 : parent.effectiveTag) === "tr") {
6257
- replacementHost = tagName === "td" || tagName === "th" ? null : "td";
6258
- }
6259
- const shouldExpandSelfClosing = selfClosing && !voidElements.has(replacementHost || tagName);
6361
+ replacementHost = nativeTagName === "td" || nativeTagName === "th" ? null : "td";
6362
+ } else if ((parent == null ? void 0 : parent.effectiveTag) === "colgroup") {
6363
+ replacementHost = nativeTagName === "col" ? null : "col";
6364
+ }
6365
+ const aliasTag = getTableAliasTag(replacementHost);
6366
+ const isTableAlias = aliasTag !== void 0;
6367
+ const shouldExpandSelfClosing = selfClosing && !voidElements.has(replacementHost || nativeTagName);
6368
+ const shouldCloseVoidAlias = !!replacementHost && aliasTag === nativeTagName && voidElements.has(nativeTagName);
6369
+ const shouldIgnoreClosingTag = !selfClosing && !!replacementHost && voidElements.has(replacementHost) && !shouldCloseVoidAlias;
6370
+ const shouldIgnoreNativeVoidClosingTag = !selfClosing && !replacementHost && voidElements.has(nativeTagName);
6260
6371
  if (replacementHost) {
6261
- const isAlias = replacementHost === "trx" || replacementHost === "tdx" || replacementHost === "thx";
6262
- const rewrittenTag = `${rawTag.slice(0, range.start)}${replacementHost} is="${isAlias ? `r-${tagName}` : `regor:${tagName}`}"${rawTag.slice(range.end)}`;
6372
+ const rewrittenTag = `${rawTag.slice(0, range.start)}${replacementHost} is="${aliasTag ? `r-${aliasTag}` : `regor:${tagName}`}"${rawTag.slice(range.end)}`;
6263
6373
  out.push(
6264
- shouldExpandSelfClosing ? expandSelfClosingTag(rewrittenTag, replacementHost) : rewrittenTag
6374
+ shouldExpandSelfClosing ? expandSelfClosingTag(rewrittenTag, replacementHost) : shouldCloseVoidAlias ? closeTag(rewrittenTag, replacementHost) : rewrittenTag
6265
6375
  );
6266
6376
  } else {
6267
6377
  out.push(
6268
6378
  shouldExpandSelfClosing ? expandSelfClosingTag(rawTag, tagName) : rawTag
6269
6379
  );
6270
6380
  }
6271
- if (!selfClosing) {
6272
- const effectiveTag = replacementHost === "trx" ? "tr" : replacementHost === "tdx" ? "td" : replacementHost === "thx" ? "th" : replacementHost || tagName;
6381
+ if (shouldIgnoreClosingTag) {
6382
+ ignoredClosingTags.push({ tagName, emit: false });
6383
+ } else if (shouldCloseVoidAlias && !selfClosing) {
6384
+ ignoredClosingTags.push({ tagName, emit: false });
6385
+ } else if (shouldIgnoreNativeVoidClosingTag) {
6386
+ ignoredClosingTags.push({ tagName, emit: true });
6387
+ }
6388
+ if (!selfClosing && !shouldCloseVoidAlias && !shouldIgnoreClosingTag && !shouldIgnoreNativeVoidClosingTag && !voidElements.has(replacementHost != null ? replacementHost : nativeTagName)) {
6389
+ const effectiveTag = (_b = aliasTag != null ? aliasTag : replacementHost) != null ? _b : nativeTagName || tagName;
6273
6390
  stack.push({
6274
6391
  replacementHost,
6275
- effectiveTag
6392
+ effectiveTag,
6393
+ isTableAlias
6276
6394
  });
6277
- if (tableScopeTags.has(effectiveTag)) ++tableScopeDepth;
6395
+ if (!isTableAlias && isTableScopeTag(effectiveTag)) ++tableScopeDepth;
6278
6396
  }
6279
6397
  i = tagEnd + 1;
6280
6398
  }