@mpen/jsxhtml 0.2.2 → 0.4.0

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.
Files changed (169) hide show
  1. package/dist/classnames.d.ts +11 -0
  2. package/dist/classnames.test.d.ts +1 -0
  3. package/dist/css-escape.d.ts +25 -0
  4. package/dist/custom/C.d.ts +6 -0
  5. package/dist/custom/Checkbox.d.ts +5 -0
  6. package/dist/custom/ColorInput.d.ts +5 -0
  7. package/dist/custom/DateInput.d.ts +5 -0
  8. package/dist/custom/DocType.d.ts +6 -0
  9. package/dist/custom/EmailInput.d.ts +5 -0
  10. package/dist/custom/Empty.d.ts +4 -0
  11. package/dist/custom/FileInput.d.ts +5 -0
  12. package/dist/custom/HtmlDocument.d.ts +5 -0
  13. package/dist/custom/NumberInput.d.ts +5 -0
  14. package/dist/custom/PasswordInput.d.ts +5 -0
  15. package/dist/custom/RadioButton.d.ts +5 -0
  16. package/dist/custom/RangeInput.d.ts +5 -0
  17. package/dist/custom/RawHtml.d.ts +6 -0
  18. package/dist/custom/SearchInput.d.ts +5 -0
  19. package/dist/custom/TelephoneInput.d.ts +5 -0
  20. package/dist/custom/TextInput.d.ts +5 -0
  21. package/dist/custom/TimeInput.d.ts +5 -0
  22. package/dist/custom/UrlInput.d.ts +5 -0
  23. package/dist/custom/WeekInput.d.ts +5 -0
  24. package/dist/custom/index.d.ts +20 -0
  25. package/dist/custom-components.d.ts +1 -23
  26. package/dist/htmlspec/IntrinsicElements.d.ts +568 -147
  27. package/dist/htmlspec/attributes/AriaAttributes.d.ts +11 -0
  28. package/dist/htmlspec/attributes/ElementAttributes.d.ts +28 -0
  29. package/dist/htmlspec/attributes/EventHandlers.d.ts +102 -0
  30. package/dist/htmlspec/attributes/GlobalAttributes.d.ts +11 -0
  31. package/dist/htmlspec/{GlobalAttributes.d.ts → attributes/StandardGlobalAttributes.d.ts} +26 -37
  32. package/dist/htmlspec/attributes/index.d.ts +7 -0
  33. package/dist/htmlspec/elements/a.d.ts +71 -0
  34. package/dist/htmlspec/elements/abbr.d.ts +4 -0
  35. package/dist/htmlspec/elements/address.d.ts +4 -0
  36. package/dist/htmlspec/elements/area.d.ts +66 -0
  37. package/dist/htmlspec/elements/article.d.ts +4 -0
  38. package/dist/htmlspec/elements/aside.d.ts +4 -0
  39. package/dist/htmlspec/elements/audio.d.ts +45 -0
  40. package/dist/htmlspec/elements/b.d.ts +4 -0
  41. package/dist/htmlspec/elements/base.d.ts +18 -0
  42. package/dist/htmlspec/elements/bdi.d.ts +4 -0
  43. package/dist/htmlspec/elements/bdo.d.ts +4 -0
  44. package/dist/htmlspec/elements/blockquote.d.ts +8 -0
  45. package/dist/htmlspec/elements/body.d.ts +92 -0
  46. package/dist/htmlspec/elements/br.d.ts +4 -0
  47. package/dist/htmlspec/elements/button.d.ts +103 -0
  48. package/dist/htmlspec/elements/canvas.d.ts +13 -0
  49. package/dist/htmlspec/elements/caption.d.ts +4 -0
  50. package/dist/htmlspec/elements/cite.d.ts +4 -0
  51. package/dist/htmlspec/elements/code.d.ts +4 -0
  52. package/dist/htmlspec/elements/col.d.ts +9 -0
  53. package/dist/htmlspec/elements/colgroup.d.ts +9 -0
  54. package/dist/htmlspec/elements/data.d.ts +9 -0
  55. package/dist/htmlspec/elements/datalist.d.ts +4 -0
  56. package/dist/htmlspec/elements/dd.d.ts +4 -0
  57. package/dist/htmlspec/elements/del.d.ts +12 -0
  58. package/dist/htmlspec/elements/details.d.ts +12 -0
  59. package/dist/htmlspec/elements/dfn.d.ts +4 -0
  60. package/dist/htmlspec/elements/dialog.d.ts +17 -0
  61. package/dist/htmlspec/elements/div.d.ts +4 -0
  62. package/dist/htmlspec/elements/dl.d.ts +4 -0
  63. package/dist/htmlspec/elements/dt.d.ts +4 -0
  64. package/dist/htmlspec/elements/element-types.d.ts +1 -0
  65. package/dist/htmlspec/elements/em.d.ts +4 -0
  66. package/dist/htmlspec/elements/embed.d.ts +21 -0
  67. package/dist/htmlspec/elements/fencedframe.d.ts +23 -0
  68. package/dist/htmlspec/elements/fieldset.d.ts +16 -0
  69. package/dist/htmlspec/elements/figcaption.d.ts +4 -0
  70. package/dist/htmlspec/elements/figure.d.ts +4 -0
  71. package/dist/htmlspec/elements/footer.d.ts +4 -0
  72. package/dist/htmlspec/elements/form.d.ts +61 -0
  73. package/dist/htmlspec/elements/h1.d.ts +4 -0
  74. package/dist/htmlspec/elements/h2.d.ts +4 -0
  75. package/dist/htmlspec/elements/h3.d.ts +4 -0
  76. package/dist/htmlspec/elements/h4.d.ts +4 -0
  77. package/dist/htmlspec/elements/h5.d.ts +4 -0
  78. package/dist/htmlspec/elements/h6.d.ts +4 -0
  79. package/dist/htmlspec/elements/head.d.ts +4 -0
  80. package/dist/htmlspec/elements/header.d.ts +4 -0
  81. package/dist/htmlspec/elements/hgroup.d.ts +4 -0
  82. package/dist/htmlspec/elements/hr.d.ts +4 -0
  83. package/dist/htmlspec/elements/html.d.ts +8 -0
  84. package/dist/htmlspec/elements/i.d.ts +4 -0
  85. package/dist/htmlspec/elements/iframe.d.ts +82 -0
  86. package/dist/htmlspec/elements/img.d.ts +90 -0
  87. package/dist/htmlspec/elements/index.d.ts +114 -0
  88. package/dist/htmlspec/elements/input.d.ts +189 -0
  89. package/dist/htmlspec/elements/ins.d.ts +12 -0
  90. package/dist/htmlspec/elements/kbd.d.ts +4 -0
  91. package/dist/htmlspec/elements/label.d.ts +8 -0
  92. package/dist/htmlspec/elements/legend.d.ts +4 -0
  93. package/dist/htmlspec/elements/li.d.ts +19 -0
  94. package/dist/htmlspec/elements/link.d.ts +77 -0
  95. package/dist/htmlspec/elements/main.d.ts +4 -0
  96. package/dist/htmlspec/elements/map.d.ts +8 -0
  97. package/dist/htmlspec/elements/mark.d.ts +4 -0
  98. package/dist/htmlspec/elements/menu.d.ts +4 -0
  99. package/dist/htmlspec/elements/meta.d.ts +24 -0
  100. package/dist/htmlspec/elements/meter.d.ts +29 -0
  101. package/dist/htmlspec/elements/nav.d.ts +4 -0
  102. package/dist/htmlspec/elements/noscript.d.ts +4 -0
  103. package/dist/htmlspec/elements/object.d.ts +29 -0
  104. package/dist/htmlspec/elements/ol.d.ts +24 -0
  105. package/dist/htmlspec/elements/optgroup.d.ts +12 -0
  106. package/dist/htmlspec/elements/option.d.ts +21 -0
  107. package/dist/htmlspec/elements/output.d.ts +16 -0
  108. package/dist/htmlspec/elements/p.d.ts +4 -0
  109. package/dist/htmlspec/elements/picture.d.ts +4 -0
  110. package/dist/htmlspec/elements/pre.d.ts +4 -0
  111. package/dist/htmlspec/elements/progress.d.ts +13 -0
  112. package/dist/htmlspec/elements/q.d.ts +8 -0
  113. package/dist/htmlspec/elements/rp.d.ts +4 -0
  114. package/dist/htmlspec/elements/rt.d.ts +4 -0
  115. package/dist/htmlspec/elements/ruby.d.ts +4 -0
  116. package/dist/htmlspec/elements/s.d.ts +4 -0
  117. package/dist/htmlspec/elements/samp.d.ts +4 -0
  118. package/dist/htmlspec/elements/script.d.ts +57 -0
  119. package/dist/htmlspec/elements/search.d.ts +4 -0
  120. package/dist/htmlspec/elements/section.d.ts +4 -0
  121. package/dist/htmlspec/elements/select.d.ts +37 -0
  122. package/dist/htmlspec/elements/selectedcontent.d.ts +7 -0
  123. package/dist/htmlspec/elements/slot.d.ts +8 -0
  124. package/dist/htmlspec/elements/small.d.ts +4 -0
  125. package/dist/htmlspec/elements/source.d.ts +33 -0
  126. package/dist/htmlspec/elements/span.d.ts +4 -0
  127. package/dist/htmlspec/elements/strong.d.ts +4 -0
  128. package/dist/htmlspec/elements/style.d.ts +21 -0
  129. package/dist/htmlspec/elements/sub.d.ts +4 -0
  130. package/dist/htmlspec/elements/summary.d.ts +4 -0
  131. package/dist/htmlspec/elements/sup.d.ts +4 -0
  132. package/dist/htmlspec/elements/table.d.ts +4 -0
  133. package/dist/htmlspec/elements/tbody.d.ts +4 -0
  134. package/dist/htmlspec/elements/td.d.ts +17 -0
  135. package/dist/htmlspec/elements/template.d.ts +29 -0
  136. package/dist/htmlspec/elements/textarea.d.ts +66 -0
  137. package/dist/htmlspec/elements/tfoot.d.ts +4 -0
  138. package/dist/htmlspec/elements/th.d.ts +31 -0
  139. package/dist/htmlspec/elements/thead.d.ts +4 -0
  140. package/dist/htmlspec/elements/time.d.ts +8 -0
  141. package/dist/htmlspec/elements/title.d.ts +4 -0
  142. package/dist/htmlspec/elements/tr.d.ts +4 -0
  143. package/dist/htmlspec/elements/track.d.ts +31 -0
  144. package/dist/htmlspec/elements/u.d.ts +4 -0
  145. package/dist/htmlspec/elements/ul.d.ts +12 -0
  146. package/dist/htmlspec/elements/var.d.ts +4 -0
  147. package/dist/htmlspec/elements/video.d.ts +66 -0
  148. package/dist/htmlspec/elements/wbr.d.ts +4 -0
  149. package/dist/index.cjs +144 -7
  150. package/dist/index.d.ts +1 -0
  151. package/dist/index.mjs +114 -9
  152. package/dist/internal/dev.d.ts +1 -0
  153. package/dist/internal/kitchen-sink-dev.d.ts +7 -0
  154. package/dist/internal/kitchen-sink.d.ts +2 -0
  155. package/dist/internal/log.d.ts +2 -0
  156. package/dist/internal/type-assert.d.ts +39 -0
  157. package/dist/jsx-dev-runtime.cjs +3 -2
  158. package/dist/jsx-dev-runtime.mjs +2 -3
  159. package/dist/{jsx-runtime-DpEMYmD9.js → jsx-runtime-BQPDXeiv.js} +675 -32
  160. package/dist/{jsx-runtime-CsQM2fQb.js → jsx-runtime-DlHYwToA.js} +672 -33
  161. package/dist/jsx-runtime.cjs +3 -1
  162. package/dist/jsx-runtime.mjs +1 -1
  163. package/dist/jsx-types.d.ts +6 -24
  164. package/dist/jsx.d.ts +3 -2
  165. package/dist/jsx.test.d.ts +1 -0
  166. package/dist/template-strings.d.ts +12 -0
  167. package/dist/template-strings.test.d.ts +6 -0
  168. package/package.json +93 -82
  169. package/dist/htmlspec/AnchorElement.d.ts +0 -83
@@ -1318,29 +1318,43 @@ const entityMap = {
1318
1318
  ffl: "ffllig"
1319
1319
  };
1320
1320
 
1321
- function cc(names) {
1322
- if (typeof names === "string" || typeof names === "number") return "" + names;
1323
- let out = "";
1324
- if (Array.isArray(names)) {
1325
- for (let i = 0, tmp; i < names.length; i++) {
1326
- if ((tmp = cc(names[i])) !== "") {
1327
- out += (out && " ") + tmp;
1328
- }
1321
+ function pushClassNames(value, classes) {
1322
+ if (value == null || value === false || value === true) return;
1323
+ if (typeof value === "string") {
1324
+ if (value) classes.push(value);
1325
+ return;
1326
+ }
1327
+ if (typeof value === "number" || typeof value === "bigint") {
1328
+ classes.push(String(value));
1329
+ return;
1330
+ }
1331
+ if (Array.isArray(value)) {
1332
+ for (const item of value) {
1333
+ pushClassNames(item, classes);
1329
1334
  }
1330
- } else {
1331
- for (let k in names) {
1332
- if (names[k]) out += (out && " ") + k;
1335
+ return;
1336
+ }
1337
+ for (const key of Object.keys(value)) {
1338
+ if (value[key]) {
1339
+ classes.push(key);
1333
1340
  }
1334
1341
  }
1335
- return out;
1336
1342
  }
1337
1343
 
1338
- function isFunction(obj) {
1344
+ function classCat(...values) {
1345
+ const classes = [];
1346
+ for (const value of values) {
1347
+ pushClassNames(value, classes);
1348
+ }
1349
+ return classes.join(" ");
1350
+ }
1351
+
1352
+ function isFunction$1(obj) {
1339
1353
  return typeof obj === "function";
1340
1354
  }
1341
1355
 
1342
1356
  function isIterable(obj) {
1343
- return isObjectLike(obj) && isFunction(obj[Symbol.iterator]);
1357
+ return isObjectLike(obj) && isFunction$1(obj[Symbol.iterator]);
1344
1358
  }
1345
1359
 
1346
1360
  function isNumber(obj) {
@@ -1351,7 +1365,7 @@ function isObjectLike(obj) {
1351
1365
  return typeof obj === "object" && obj !== null;
1352
1366
  }
1353
1367
 
1354
- function isObject(obj) {
1368
+ function isObject$1(obj) {
1355
1369
  return obj != null && (typeof obj === "object" || typeof obj === "function");
1356
1370
  }
1357
1371
 
@@ -1361,7 +1375,7 @@ function isPlainObject(obj) {
1361
1375
  return proto === null || proto === Object.prototype;
1362
1376
  }
1363
1377
 
1364
- function isString(obj) {
1378
+ function isString$1(obj) {
1365
1379
  return typeof obj === "string";
1366
1380
  }
1367
1381
 
@@ -1416,7 +1430,7 @@ function styleObjectToString(styles) {
1416
1430
  }
1417
1431
 
1418
1432
  function entity(ch) {
1419
- return Object.hasOwn(entityMap, ch) ? `&${entityMap[ch]};` : `&#x${ch.codePointAt(0).toString(16)};`;
1433
+ return Object.prototype.hasOwnProperty.call(entityMap, ch) ? `&${entityMap[ch]};` : `&#x${ch.codePointAt(0).toString(16)};`;
1420
1434
  }
1421
1435
 
1422
1436
  function tagName(string) {
@@ -1428,15 +1442,15 @@ function attrName(string) {
1428
1442
  }
1429
1443
 
1430
1444
  function attrValue(value) {
1431
- if (isFunction(value)) {
1432
- value = `(${value}).call(this)`;
1445
+ if (isFunction$1(value)) {
1446
+ value = `(${value}).call(this,event)`;
1433
1447
  }
1434
1448
  return `"${String(value).replace(/"/gu, entity)}"`;
1435
1449
  }
1436
1450
 
1437
1451
  function attrKvPair(rawAttr, rawVal) {
1438
1452
  let escAttr = attrName(rawAttr);
1439
- if (/^data-/.test(rawAttr) && !isString(rawVal)) {
1453
+ if (/^data-/.test(rawAttr) && !isString$1(rawVal)) {
1440
1454
  rawVal = JSON.stringify(rawVal);
1441
1455
  }
1442
1456
  if (rawVal === true) {
@@ -1445,8 +1459,8 @@ function attrKvPair(rawAttr, rawVal) {
1445
1459
  if (rawVal === false || rawVal == null) {
1446
1460
  return null;
1447
1461
  }
1448
- if (rawAttr === "class" && !isString(rawVal)) {
1449
- rawVal = cc(rawVal);
1462
+ if (rawAttr === "class" && !isString$1(rawVal)) {
1463
+ rawVal = classCat(rawVal);
1450
1464
  }
1451
1465
  if (rawAttr === "style" && isPlainObject(rawVal)) {
1452
1466
  rawVal = styleObjectToString(rawVal);
@@ -1456,7 +1470,7 @@ function attrKvPair(rawAttr, rawVal) {
1456
1470
 
1457
1471
  function attrs(attributes) {
1458
1472
  if (attributes == null) return "";
1459
- if (isObject(attributes)) {
1473
+ if (isObject$1(attributes)) {
1460
1474
  attributes = Object.entries(attributes);
1461
1475
  }
1462
1476
  return attributes.map((([k, v]) => attrKvPair(k, v))).filter((x => x)).map((x => ` ${x}`)).join("");
@@ -1484,6 +1498,598 @@ function isJsxNode(x) {
1484
1498
  return x instanceof JsxNode;
1485
1499
  }
1486
1500
 
1501
+ /*! Adapted from https://github.com/mathiasbynens/CSS.escape/blob/4b25c283eaf4dd443f44a7096463e973d56dd1b2/css.escape.js */ function cssEscape(value) {
1502
+ const string = String(value);
1503
+ const length = string.length;
1504
+ let index = -1;
1505
+ let codeUnit;
1506
+ let result = "";
1507
+ const firstCodeUnit = string.charCodeAt(0);
1508
+ if (length === 1 && firstCodeUnit === 45) {
1509
+ return "\\" + string;
1510
+ }
1511
+ while (++index < length) {
1512
+ codeUnit = string.charCodeAt(index);
1513
+ if (codeUnit === 0) {
1514
+ result += "�";
1515
+ continue;
1516
+ }
1517
+ if (codeUnit >= 1 && codeUnit <= 31 || codeUnit === 127 || index === 0 && codeUnit >= 48 && codeUnit <= 57 || index === 1 && codeUnit >= 48 && codeUnit <= 57 && firstCodeUnit === 45) {
1518
+ result += "\\" + codeUnit.toString(16) + " ";
1519
+ continue;
1520
+ }
1521
+ if (codeUnit >= 128 || codeUnit === 45 || codeUnit === 95 || codeUnit >= 48 && codeUnit <= 57 || codeUnit >= 65 && codeUnit <= 90 || codeUnit >= 97 && codeUnit <= 122) {
1522
+ result += string.charAt(index);
1523
+ continue;
1524
+ }
1525
+ result += "\\" + string.charAt(index);
1526
+ }
1527
+ return result;
1528
+ }
1529
+
1530
+ function isFunction(obj) {
1531
+ return typeof obj === "function";
1532
+ }
1533
+
1534
+ function isString(obj) {
1535
+ return typeof obj === "string";
1536
+ }
1537
+
1538
+ function isStringLike(obj) {
1539
+ return typeof obj === "string" || obj instanceof String;
1540
+ }
1541
+
1542
+ function isNumberLike(obj) {
1543
+ return typeof obj === "number" || obj instanceof Number;
1544
+ }
1545
+
1546
+ function isBigInt(obj) {
1547
+ return typeof obj === "bigint";
1548
+ }
1549
+
1550
+ function isBoolean(obj) {
1551
+ return obj === true || obj === false;
1552
+ }
1553
+
1554
+ function isRegExp(obj) {
1555
+ return obj instanceof RegExp;
1556
+ }
1557
+
1558
+ function isArray(obj) {
1559
+ return Array.isArray(obj);
1560
+ }
1561
+
1562
+ function isObject(obj) {
1563
+ return obj !== null && typeof obj === "object";
1564
+ }
1565
+
1566
+ function isSymbol(obj) {
1567
+ return Object.prototype.toString.call(obj) === "[object Symbol]";
1568
+ }
1569
+
1570
+ function findFunction(lib, fn, maxDepth = 3) {
1571
+ let queue = [];
1572
+ let path = [];
1573
+ let seen = new Set;
1574
+ --maxDepth;
1575
+ for (;;) {
1576
+ if (lib[fn.name] === fn) {
1577
+ return [ ...path, fn.name ];
1578
+ }
1579
+ seen.add(lib);
1580
+ if (path.length < maxDepth) {
1581
+ for (let n of Object.getOwnPropertyNames(lib)) {
1582
+ if (n[0] !== "_" && n !== "prototype" && lib[n] && !seen.has(lib[n])) {
1583
+ queue.push([ [ ...path, n ], lib[n] ]);
1584
+ }
1585
+ }
1586
+ }
1587
+ if (!queue.length) {
1588
+ return null;
1589
+ }
1590
+ [path, lib] = queue.shift();
1591
+ }
1592
+ }
1593
+
1594
+ var nativeFuncs = new Map;
1595
+
1596
+ var isRaw = Symbol("isRaw");
1597
+
1598
+ var wellKnownSymbols;
1599
+
1600
+ function merge(target, ...sources) {
1601
+ for (let obj of sources) {
1602
+ if (obj) {
1603
+ for (let key of Object.keys(obj)) {
1604
+ if (obj[key] !== undefined) {
1605
+ target[key] = obj[key];
1606
+ }
1607
+ }
1608
+ }
1609
+ }
1610
+ return target;
1611
+ }
1612
+
1613
+ function jsSerialize(object, options) {
1614
+ return startSerialize(object, options).replace(/<\/(script)/gi, "<\\/$1");
1615
+ }
1616
+
1617
+ function startSerialize(object, options) {
1618
+ const counts = referenceCount(object);
1619
+ let c = 0;
1620
+ const dupes = [ ...counts ].filter((x => x[1] > 1)).sort(((a, b) => b[1] - a[1])).map((x => [ x[0], `$${c++}` ]));
1621
+ const refs = new Map(dupes);
1622
+ let ctx = {
1623
+ seen: new Set,
1624
+ refs,
1625
+ opts: Object.freeze(merge({
1626
+ compact: false,
1627
+ safe: true
1628
+ }, options))
1629
+ };
1630
+ let js = serializeAny(object, ctx);
1631
+ if (dupes.length) {
1632
+ let varDecl = dupes.map((x => x[1])).join(",");
1633
+ if (dupes.length > 1) {
1634
+ varDecl = `(${varDecl})`;
1635
+ }
1636
+ if (js.startsWith("{")) {
1637
+ js = `(${js})`;
1638
+ }
1639
+ return `(${varDecl}=>${js})()`;
1640
+ }
1641
+ return js;
1642
+ }
1643
+
1644
+ var STRING_REF_MIN_LENGTH = 12;
1645
+
1646
+ function referenceCount(object) {
1647
+ const m = new Map;
1648
+ function r(o) {
1649
+ let c = m.get(o);
1650
+ if (c) {
1651
+ m.set(o, c + 1);
1652
+ return;
1653
+ }
1654
+ if (isArray(o) || o instanceof Set) {
1655
+ m.set(o, 1);
1656
+ for (const v of o) {
1657
+ r(v);
1658
+ }
1659
+ } else if (isString(o)) {
1660
+ if (o.length >= STRING_REF_MIN_LENGTH) {
1661
+ m.set(o, 1);
1662
+ }
1663
+ } else if (o instanceof Map) {
1664
+ m.set(o, 1);
1665
+ for (const v of o.values()) {
1666
+ r(v);
1667
+ }
1668
+ } else if (isRegExp(o) || o instanceof Date || isSymbol(o) || isFunction(o)) {
1669
+ m.set(o, 1);
1670
+ } else if (isObject(o)) {
1671
+ m.set(o, 1);
1672
+ for (const k of Reflect.ownKeys(o)) {
1673
+ r(o[k]);
1674
+ }
1675
+ }
1676
+ }
1677
+ r(object);
1678
+ return m;
1679
+ }
1680
+
1681
+ function isNegativeZero(value) {
1682
+ return 1 / value === -Infinity;
1683
+ }
1684
+
1685
+ function serializeArray(obj, ctx) {
1686
+ const varName = ctx.refs.get(obj);
1687
+ const assign = varName ? `${varName}=` : "";
1688
+ if (obj.length === 0) {
1689
+ return `${assign}[]`;
1690
+ }
1691
+ let sb = [];
1692
+ let hasProp = false;
1693
+ let isSparse = false;
1694
+ for (let i = 0; i < obj.length; ++i) {
1695
+ if (obj.hasOwnProperty(i)) {
1696
+ hasProp = true;
1697
+ sb.push(serializeAny(obj[i], ctx));
1698
+ } else {
1699
+ isSparse = true;
1700
+ sb.push("");
1701
+ }
1702
+ }
1703
+ if (!hasProp) {
1704
+ return `${assign}new Array(${obj.length})`;
1705
+ }
1706
+ if (sb[sb.length - 1] === "") {
1707
+ sb.push("");
1708
+ }
1709
+ const inner = sb.join(",");
1710
+ if (varName) {
1711
+ if (isSparse) {
1712
+ let sb2 = [ `(${varName}=new Array(${obj.length})` ];
1713
+ for (let i = 0; i < obj.length; ++i) {
1714
+ if (obj.hasOwnProperty(i)) {
1715
+ sb2.push(`${varName}[${i}]=${serializeAny(obj[i], ctx)}`);
1716
+ }
1717
+ }
1718
+ sb2.push(`${varName})`);
1719
+ return sb2.join(",");
1720
+ }
1721
+ return `(${varName}=[],${varName}.push(${inner}),${varName})`;
1722
+ }
1723
+ return `[${inner}]`;
1724
+ }
1725
+
1726
+ function serializeSet(obj, ctx) {
1727
+ const varName = ctx.refs.get(obj);
1728
+ if (obj.size) {
1729
+ if (varName) {
1730
+ return `(${varName}=new Set,${varName}` + Array.from(obj).map((x => `.add(${serializeAny(x, ctx)})`)).join("") + ")";
1731
+ }
1732
+ return "new Set(" + serializeAny(Array.from(obj), ctx) + ")";
1733
+ }
1734
+ if (varName) {
1735
+ return `${varName}=new Set`;
1736
+ }
1737
+ return "new Set";
1738
+ }
1739
+
1740
+ function serializeMap(obj, ctx) {
1741
+ const varName = ctx.refs.get(obj);
1742
+ if (obj.size) {
1743
+ if (varName) {
1744
+ return `(${varName}=new Map,${varName}` + Array.from(obj).map((([k, v]) => `.set(${serializeAny(k, ctx)},${serializeAny(v, ctx)})`)).join("") + ")";
1745
+ }
1746
+ return "new Map(" + serializeAny(Array.from(obj), ctx) + ")";
1747
+ }
1748
+ if (varName) {
1749
+ return `${varName}=new Map`;
1750
+ }
1751
+ return "new Map";
1752
+ }
1753
+
1754
+ function serializeDate(obj, ctx) {
1755
+ if (ctx.opts.compact) {
1756
+ return `new Date(${obj.valueOf()})`;
1757
+ }
1758
+ const parts = [ obj.getUTCFullYear(), obj.getUTCMonth(), obj.getUTCDate() ];
1759
+ if (+obj % 864e5 !== 0) {
1760
+ parts.push(obj.getUTCHours(), obj.getUTCMinutes(), obj.getUTCSeconds());
1761
+ const ms = obj.getUTCMilliseconds();
1762
+ if (ms) {
1763
+ parts.push(ms);
1764
+ }
1765
+ }
1766
+ return `new Date(Date.UTC(${parts.join(",")}))`;
1767
+ }
1768
+
1769
+ function wrapSimpleRef(serialize) {
1770
+ return (obj, ctx) => {
1771
+ const js = serialize(obj, ctx);
1772
+ const varName = ctx.refs.get(obj);
1773
+ if (varName) {
1774
+ ctx.seen.add(obj);
1775
+ return `${varName}=${js}`;
1776
+ }
1777
+ return js;
1778
+ };
1779
+ }
1780
+
1781
+ function serializeAnySymbol(obj, ctx) {
1782
+ if (!wellKnownSymbols) {
1783
+ wellKnownSymbols = new Map(Object.getOwnPropertyNames(Symbol).filter((k => isSymbol(Symbol[k]))).map((k => [ Symbol[k], k ])));
1784
+ }
1785
+ let symbolName = wellKnownSymbols.get(obj);
1786
+ if (symbolName) {
1787
+ return `Symbol.${symbolName}`;
1788
+ }
1789
+ return serializeSymbol(obj, ctx);
1790
+ }
1791
+
1792
+ function serializeNativeFunction(obj, ctx) {
1793
+ let cachedPath = nativeFuncs.get(obj);
1794
+ if (cachedPath !== undefined) {
1795
+ return cachedPath;
1796
+ }
1797
+ const foundPath = findFunction(global, obj);
1798
+ if (foundPath === null) {
1799
+ throw new Error(`Could not determine fully-qualified name of native function '${obj.name}'`);
1800
+ }
1801
+ const joinedPath = foundPath.join(".");
1802
+ nativeFuncs.set(obj, joinedPath);
1803
+ return joinedPath;
1804
+ }
1805
+
1806
+ function serializeNonNativeFunction(obj, ctx) {
1807
+ return obj.toString();
1808
+ }
1809
+
1810
+ function serializeAnyFunction(obj, ctx) {
1811
+ if (/\{\s*\[native code]\s*}$/.test(obj.toString())) {
1812
+ return serializeNativeFunction(obj);
1813
+ }
1814
+ return serializeNonNativeFunction(obj);
1815
+ }
1816
+
1817
+ function serializeBoolean(obj, ctx) {
1818
+ if (obj) {
1819
+ return ctx.opts.compact ? "!0" : "true";
1820
+ }
1821
+ return ctx.opts.compact ? "!1" : "false";
1822
+ }
1823
+
1824
+ function serializeRegExp(obj, ctx) {
1825
+ return obj.toString();
1826
+ }
1827
+
1828
+ function serializeUndefined(obj, ctx) {
1829
+ return ctx.opts.compact ? "void 0" : "undefined";
1830
+ }
1831
+
1832
+ function serializeNull(obj, ctx) {
1833
+ return "null";
1834
+ }
1835
+
1836
+ function maybeFreeze(obj, js) {
1837
+ if (Object.isFrozen(obj)) {
1838
+ return `Object.freeze(${js})`;
1839
+ }
1840
+ if (Object.isSealed(obj)) {
1841
+ return `Object.seal(${js})`;
1842
+ }
1843
+ if (!Object.isExtensible(obj)) {
1844
+ return `Object.preventExtensions(${js})`;
1845
+ }
1846
+ return js;
1847
+ }
1848
+
1849
+ function serializeAnyObject(obj, ctx) {
1850
+ const tmp = serializeObject(obj, ctx);
1851
+ const name = ctx.refs.get(obj);
1852
+ if (name) {
1853
+ if (Reflect.ownKeys(obj).length) {
1854
+ return `(${name}={},${maybeFreeze(obj, `Object.assign(${name},${tmp})`)})`;
1855
+ }
1856
+ return `${name}=${maybeFreeze(obj, "{}")}`;
1857
+ }
1858
+ return maybeFreeze(obj, tmp);
1859
+ }
1860
+
1861
+ function serializeAny(obj, ctx) {
1862
+ if (ctx.seen.has(obj) && ctx.refs.has(obj)) {
1863
+ return ctx.refs.get(obj);
1864
+ }
1865
+ if (isArray(obj)) {
1866
+ ctx.seen.add(obj);
1867
+ return serializeArray(obj, ctx);
1868
+ }
1869
+ if (obj instanceof Set) {
1870
+ ctx.seen.add(obj);
1871
+ return serializeSet(obj, ctx);
1872
+ }
1873
+ if (obj instanceof Map) {
1874
+ ctx.seen.add(obj);
1875
+ return serializeMap(obj, ctx);
1876
+ }
1877
+ if (obj instanceof Date) {
1878
+ return wrapSimpleRef(serializeDate)(obj, ctx);
1879
+ }
1880
+ if (isSymbol(obj)) {
1881
+ return wrapSimpleRef(serializeAnySymbol)(obj, ctx);
1882
+ }
1883
+ if (isFunction(obj)) {
1884
+ return wrapSimpleRef(serializeAnyFunction)(obj, ctx);
1885
+ }
1886
+ if (isRegExp(obj)) {
1887
+ return wrapSimpleRef(serializeRegExp)(obj, ctx);
1888
+ }
1889
+ if (isNumberLike(obj)) {
1890
+ return serializeNumberLike(obj, ctx);
1891
+ }
1892
+ if (isBigInt(obj)) {
1893
+ return serializeBigInt(obj, ctx);
1894
+ }
1895
+ if (isBoolean(obj)) {
1896
+ return serializeBoolean(obj, ctx);
1897
+ }
1898
+ if (isStringLike(obj)) {
1899
+ return serializeStringLike(obj, ctx);
1900
+ }
1901
+ if (obj === undefined) {
1902
+ return serializeUndefined(obj, ctx);
1903
+ }
1904
+ if (obj === null) {
1905
+ return serializeNull();
1906
+ }
1907
+ if (isObject(obj)) {
1908
+ ctx.seen.add(obj);
1909
+ return serializeAnyObject(obj, ctx);
1910
+ }
1911
+ throw new Error("Could not serialize unknown type");
1912
+ }
1913
+
1914
+ function serializeNumberLike(obj, ctx) {
1915
+ const tmp = serializeNumber(Number(obj), ctx);
1916
+ if (obj instanceof Number) {
1917
+ return `new Number(${tmp})`;
1918
+ }
1919
+ return tmp;
1920
+ }
1921
+
1922
+ function serializeNumber(obj, ctx) {
1923
+ switch (obj) {
1924
+ case Math.E:
1925
+ return "Math.E";
1926
+
1927
+ case Math.LN2:
1928
+ return "Math.LN2";
1929
+
1930
+ case Math.LN10:
1931
+ return "Math.LN10";
1932
+
1933
+ case Math.LOG2E:
1934
+ return "Math.LOG2E";
1935
+
1936
+ case Math.PI:
1937
+ return "Math.PI";
1938
+
1939
+ case Math.SQRT1_2:
1940
+ return "Math.SQRT1_2";
1941
+
1942
+ case Math.SQRT2:
1943
+ return "Math.SQRT2";
1944
+
1945
+ case Number.EPSILON:
1946
+ return "Number.EPSILON";
1947
+
1948
+ case Infinity:
1949
+ return ctx.opts.compact ? "1/0" : "Infinity";
1950
+
1951
+ case -Infinity:
1952
+ return ctx.opts.compact ? "1/-0" : "-Infinity";
1953
+ }
1954
+ if (isNegativeZero(obj)) return "-0";
1955
+ if (ctx.opts.compact && Number.isInteger(obj) && obj >= 1e12) {
1956
+ return "0x" + obj.toString(16);
1957
+ }
1958
+ return String(obj);
1959
+ }
1960
+
1961
+ function serializeBigInt(obj, ctx) {
1962
+ if (ctx.opts.compact && obj >= 1000000000000n) {
1963
+ return "0x" + obj.toString(16) + "n";
1964
+ }
1965
+ return `${obj}n`;
1966
+ }
1967
+
1968
+ function serializeStringLike(obj, ctx) {
1969
+ const js = doSerializeStringLike(obj, ctx);
1970
+ if (obj.length >= STRING_REF_MIN_LENGTH) {
1971
+ const varName = ctx.refs.get(obj);
1972
+ if (varName) {
1973
+ ctx.seen.add(obj);
1974
+ return `${varName}=${js}`;
1975
+ }
1976
+ }
1977
+ return js;
1978
+ }
1979
+
1980
+ function doSerializeStringLike(obj, ctx) {
1981
+ const tmp = serializeString(String(obj), ctx);
1982
+ if (obj instanceof String) {
1983
+ return `new String(${tmp})`;
1984
+ }
1985
+ return tmp;
1986
+ }
1987
+
1988
+ function serializeString(obj, ctx) {
1989
+ return '"' + Array.from(obj).map((ch => {
1990
+ const cp = ch.codePointAt(0);
1991
+ switch (cp) {
1992
+ case 8:
1993
+ return "\\b";
1994
+
1995
+ case 12:
1996
+ return "\\f";
1997
+
1998
+ case 10:
1999
+ return "\\n";
2000
+
2001
+ case 13:
2002
+ return "\\r";
2003
+
2004
+ case 9:
2005
+ return "\\t";
2006
+
2007
+ case 11:
2008
+ return ctx.opts.safe ? "\\x0B" : "\\v";
2009
+
2010
+ case 34:
2011
+ return '\\"';
2012
+
2013
+ case 92:
2014
+ return "\\\\";
2015
+ }
2016
+ if (cp >= 32 && cp <= 126) {
2017
+ return ch;
2018
+ }
2019
+ if (cp <= 255) {
2020
+ return "\\x" + cp.toString(16).padStart(2, "0");
2021
+ }
2022
+ if (cp <= 65535) {
2023
+ return "\\u" + cp.toString(16).padStart(4, "0");
2024
+ }
2025
+ return "\\u{" + cp.toString(16) + "}";
2026
+ })).join("") + '"';
2027
+ }
2028
+
2029
+ function serializeObject(obj, ctx) {
2030
+ if (obj[isRaw]) {
2031
+ return obj.value;
2032
+ }
2033
+ if (isFunction(obj.toSource)) {
2034
+ return obj.toSource();
2035
+ }
2036
+ if (isFunction(obj.toJSON)) {
2037
+ return serializeAny(obj.toJSON(), ctx);
2038
+ }
2039
+ return serializePlainObject(obj, ctx);
2040
+ }
2041
+
2042
+ function serializePlainObject(obj, ctx) {
2043
+ let tmp = [];
2044
+ for (let key of Reflect.ownKeys(obj)) {
2045
+ tmp.push(serializePropertyName(key, ctx) + ":" + serializeAny(obj[key], ctx));
2046
+ }
2047
+ return "{" + tmp.join(",") + "}";
2048
+ }
2049
+
2050
+ jsSerialize.raw = function raw(jsCode) {
2051
+ return Object.create({
2052
+ [isRaw]: true,
2053
+ value: jsCode
2054
+ });
2055
+ };
2056
+
2057
+ function serializeSymbol(sym, ctx) {
2058
+ let key = Symbol.keyFor(sym);
2059
+ if (key === undefined) {
2060
+ let m = sym.toString().match(/^Symbol\((.+)\)$/);
2061
+ if (m) {
2062
+ return `Symbol(${serializeString(m[1], ctx)})`;
2063
+ }
2064
+ return `Symbol()`;
2065
+ } else {
2066
+ return `Symbol.for(${serializeString(key, ctx)})`;
2067
+ }
2068
+ }
2069
+
2070
+ var keywords = new Set([ "do", "if", "in", "for", "let", "new", "try", "var", "case", "else", "enum", "eval", "false", "null", "this", "true", "void", "with", "break", "catch", "class", "const", "super", "throw", "while", "yield", "delete", "export", "import", "public", "return", "static", "switch", "typeof", "default", "extends", "finally", "package", "private", "continue", "debugger", "function", "arguments", "interface", "protected", "implements", "instanceof" ]);
2071
+
2072
+ var propName = /^[$_a-zA-Z][$_a-zA-Z0-9]*$/;
2073
+
2074
+ function isSafePropName(name, ctx) {
2075
+ return (!ctx.opts.safe || !keywords.has(name)) && propName.test(name);
2076
+ }
2077
+
2078
+ function serializePropertyName(name, ctx) {
2079
+ if (isSymbol(name)) {
2080
+ return "[" + serializeSymbol(name, ctx) + "]";
2081
+ }
2082
+ if (isStringLike(name)) {
2083
+ if (isSafePropName(name, ctx)) {
2084
+ return name;
2085
+ }
2086
+ return serializeString(name, ctx);
2087
+ }
2088
+ throw new Error(`Cannot make property name`);
2089
+ }
2090
+
2091
+ var src_default = jsSerialize;
2092
+
1487
2093
  function mapIter(iterable, cb) {
1488
2094
  const out = [];
1489
2095
  let i = 0;
@@ -1533,7 +2139,7 @@ function scriptChild(el) {
1533
2139
  if (isJsxNode(el)) {
1534
2140
  throw new Error(`<script> cannot contain JSX nodes.`);
1535
2141
  }
1536
- return JSON.stringify(el);
2142
+ return src_default(el);
1537
2143
  }
1538
2144
 
1539
2145
  function styleChild(el) {
@@ -1544,19 +2150,19 @@ function styleChild(el) {
1544
2150
  return "";
1545
2151
  }
1546
2152
  if (isJsxNode(el)) {
1547
- throw new Error(`<sty;e> cannot contain JSX nodes.`);
2153
+ throw new Error(`<style> cannot contain JSX nodes.`);
1548
2154
  }
1549
- return CSS.escape(String(el));
2155
+ return cssEscape(String(el));
1550
2156
  }
1551
2157
 
1552
2158
  function flattenChildren(children, callback) {
1553
2159
  return Array.isArray(children) ? children.map(callback).join("") : callback(children);
1554
2160
  }
1555
2161
 
1556
- const isJsxComponent = isFunction;
2162
+ const isJsxComponent = isFunction$1;
1557
2163
 
1558
2164
  function isHtmlSafe(x) {
1559
- return isPlainObject(x) && isString(x.__html);
2165
+ return isPlainObject(x) && isString$1(x.__html);
1560
2166
  }
1561
2167
 
1562
2168
  function render(el) {
@@ -1569,7 +2175,7 @@ function render(el) {
1569
2175
  if (isHtmlSafe(el)) {
1570
2176
  return el.__html;
1571
2177
  }
1572
- if (isString(el)) {
2178
+ if (isString$1(el)) {
1573
2179
  return htmlContent(el);
1574
2180
  }
1575
2181
  if (isNumber(el)) {
@@ -1578,7 +2184,7 @@ function render(el) {
1578
2184
  if (Array.isArray(el)) {
1579
2185
  return el.map((x => render(x))).join("");
1580
2186
  }
1581
- if (isFunction(el)) {
2187
+ if (isFunction$1(el)) {
1582
2188
  return render(el());
1583
2189
  }
1584
2190
  if (isIterable(el)) {
@@ -1587,6 +2193,37 @@ function render(el) {
1587
2193
  throw new Error(`Unsupported type: ${getStringTag(el)}`);
1588
2194
  }
1589
2195
 
2196
+ class JsFrag {
2197
+ str;
2198
+ constructor(str) {
2199
+ this.str = str;
2200
+ }
2201
+ toString() {
2202
+ return this.str;
2203
+ }
2204
+ }
2205
+
2206
+ function escapeJs(obj) {
2207
+ if (obj instanceof JsFrag) {
2208
+ return obj;
2209
+ }
2210
+ return src_default(obj);
2211
+ }
2212
+
2213
+ function js(strings, ...values) {
2214
+ return new JsFrag(strings.reduce(((out, str, i) => out + str + (i < values.length ? escapeJs(values[i]) : "")), ""));
2215
+ }
2216
+
2217
+ class CssFrag {
2218
+ str;
2219
+ constructor(str) {
2220
+ this.str = str;
2221
+ }
2222
+ toString() {
2223
+ return this.str;
2224
+ }
2225
+ }
2226
+
1590
2227
  const voidElements = new Set([ "area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr" ]);
1591
2228
 
1592
2229
  class JsxElement extends JsxNode {
@@ -1615,10 +2252,10 @@ class JsxElement extends JsxNode {
1615
2252
  return `<${tag}${attrs$1}></${tag}>`;
1616
2253
  }
1617
2254
  if (normalizedTagName === "script") {
1618
- return `<${tag}${attrs$1}>${escapeScript(flattenChildren(children, scriptChild))}</${tag}>`;
2255
+ return `<${tag}${attrs$1}>${escapeScript(children instanceof JsFrag ? children.toString() : flattenChildren(children, scriptChild))}</${tag}>`;
1619
2256
  }
1620
2257
  if (normalizedTagName === "style") {
1621
- return `<${tag}${attrs$1}>${escapeStyle(flattenChildren(children, styleChild))}</${tag}>`;
2258
+ return `<${tag}${attrs$1}>${escapeStyle(children instanceof CssFrag ? children.toString() : flattenChildren(children, styleChild))}</${tag}>`;
1622
2259
  }
1623
2260
  return `<${tag}${attrs$1}>${flattenChildren(children, render)}</${tag}>`;
1624
2261
  }
@@ -1691,6 +2328,8 @@ class JsxFragment extends JsxNode {
1691
2328
  }
1692
2329
  }
1693
2330
 
2331
+ const JSX = {};
2332
+
1694
2333
  function jsx(tag, props, key, isStaticChildren, source, self) {
1695
2334
  if (isJsxComponent(tag)) {
1696
2335
  const node = tag(props);
@@ -1717,6 +2356,8 @@ exports.EMPTY = EMPTY;
1717
2356
 
1718
2357
  exports.Fragment = Fragment;
1719
2358
 
2359
+ exports.JSX = JSX;
2360
+
1720
2361
  exports.JsxComment = JsxComment;
1721
2362
 
1722
2363
  exports.JsxDocType = JsxDocType;
@@ -1737,6 +2378,8 @@ exports.isJsxComponent = isJsxComponent;
1737
2378
 
1738
2379
  exports.isJsxNode = isJsxNode;
1739
2380
 
2381
+ exports.js = js;
2382
+
1740
2383
  exports.jsx = jsx;
1741
2384
 
1742
2385
  exports.jsxs = jsxs;