@mpen/jsxhtml 0.1.15 → 0.1.16

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.
@@ -15,7 +15,7 @@ export declare function DocType(props: DocTypeProps): JsxDocType;
15
15
  /**
16
16
  * `<!DOCTYPE html><html ...>{children}</html>`
17
17
  */
18
- export declare function HtmlDocument({ children, ...htmlAttrs }: CommonProps): any;
18
+ export declare function HtmlDocument({ children, ...htmlAttrs }: CommonProps): import("./jsx-node").JsxNode;
19
19
  /**
20
20
  * No output.
21
21
  */
package/index.cjs CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var jsxRuntime = require("./jsx-runtime-NqHz6WEo.js");
7
+ var jsxRuntime = require("./jsx-runtime-fpN2EWm-.js");
8
8
 
9
9
  function RawHtml({children}) {
10
10
  return new jsxRuntime.JsxRawHtml(jsxRuntime.flattenString(children));
package/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { J as JsxRawHtml, f as flattenString, a as JsxComment, b as JsxDocType, j as jsxs, c as jsx, F as Fragment, E as EMPTY, i as isJsxNode } from "./jsx-runtime-xIDZYHgS.js";
1
+ import { J as JsxRawHtml, f as flattenString, a as JsxComment, b as JsxDocType, j as jsxs, c as jsx, F as Fragment, E as EMPTY, i as isJsxNode } from "./jsx-runtime-_xtqfR_9.js";
2
2
 
3
- export { d as JsxElement, e as JsxEmpty, g as JsxFragment } from "./jsx-runtime-xIDZYHgS.js";
3
+ export { d as JsxElement, e as JsxEmpty, g as JsxFragment } from "./jsx-runtime-_xtqfR_9.js";
4
4
 
5
5
  function RawHtml({children}) {
6
6
  return new JsxRawHtml(flattenString(children));
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var jsxRuntime = require("./jsx-runtime-NqHz6WEo.js");
3
+ var jsxRuntime = require("./jsx-runtime-fpN2EWm-.js");
4
4
 
5
5
  function jsxDEV(tag, props, key, isStaticChildren, source, self) {
6
6
  let node = jsxRuntime.jsx(...arguments);
@@ -1,6 +1,6 @@
1
- import { c as jsx, h as isJsxComponent, a as JsxComment, g as JsxFragment } from "./jsx-runtime-xIDZYHgS.js";
1
+ import { c as jsx, h as isJsxComponent, a as JsxComment, g as JsxFragment } from "./jsx-runtime-_xtqfR_9.js";
2
2
 
3
- export { F as Fragment } from "./jsx-runtime-xIDZYHgS.js";
3
+ export { F as Fragment } from "./jsx-runtime-_xtqfR_9.js";
4
4
 
5
5
  function jsxDEV(tag, props, key, isStaticChildren, source, self) {
6
6
  let node = jsx(...arguments);
@@ -1415,68 +1415,29 @@ var isPlainObject_1 = isPlainObject;
1415
1415
 
1416
1416
  var isString_1 = isString;
1417
1417
 
1418
- const _uppercasePattern = /([A-Z])/g;
1419
-
1420
- function hyphenate(string) {
1421
- return string.replace(_uppercasePattern, "-$1").toLowerCase();
1422
- }
1418
+ const uppercasePattern = /([A-Z])/g;
1423
1419
 
1424
1420
  const msPattern = /^ms-/;
1425
1421
 
1426
- function hyphenateStyleName(string) {
1427
- return hyphenate(string).replace(msPattern, "-ms-");
1422
+ function hyphenateStyleName(name) {
1423
+ return name.replace(uppercasePattern, "-$1").toLowerCase().replace(msPattern, "-ms-");
1428
1424
  }
1429
1425
 
1430
1426
  function memoizeStringOnly(callback) {
1431
- let cache = {};
1427
+ const cache = new Map;
1432
1428
  return function(string) {
1433
- if (!cache.hasOwnProperty(string)) {
1434
- cache[string] = callback.call(this, string);
1429
+ let value = cache.get(string);
1430
+ if (value === undefined) {
1431
+ value = callback.call(this, string);
1432
+ cache.set(string, value);
1435
1433
  }
1436
- return cache[string];
1434
+ return value;
1437
1435
  };
1438
1436
  }
1439
1437
 
1440
- const makeStyleName = memoizeStringOnly((function(styleName) {
1441
- return hyphenateStyleName(styleName);
1442
- }));
1438
+ const makeStyleName = memoizeStringOnly(hyphenateStyleName);
1443
1439
 
1444
- const isUnitlessNumber = {
1445
- animationIterationCount: true,
1446
- borderImageOutset: true,
1447
- borderImageSlice: true,
1448
- borderImageWidth: true,
1449
- boxFlex: true,
1450
- boxFlexGroup: true,
1451
- boxOrdinalGroup: true,
1452
- columnCount: true,
1453
- flex: true,
1454
- flexGrow: true,
1455
- flexPositive: true,
1456
- flexShrink: true,
1457
- flexNegative: true,
1458
- flexOrder: true,
1459
- gridRow: true,
1460
- gridColumn: true,
1461
- fontWeight: true,
1462
- lineClamp: true,
1463
- lineHeight: true,
1464
- opacity: true,
1465
- order: true,
1466
- orphans: true,
1467
- tabSize: true,
1468
- widows: true,
1469
- zIndex: true,
1470
- zoom: true,
1471
- fillOpacity: true,
1472
- floodOpacity: true,
1473
- stopOpacity: true,
1474
- strokeDasharray: true,
1475
- strokeDashoffset: true,
1476
- strokeMiterlimit: true,
1477
- strokeOpacity: true,
1478
- strokeWidth: true
1479
- };
1440
+ const unitlessNumbers = new Set([ "animationIterationCount", "aspectRatio", "borderImageOutset", "borderImageSlice", "borderImageWidth", "boxFlex", "boxFlexGroup", "boxOrdinalGroup", "columnCount", "columns", "flex", "flexGrow", "flexPositive", "flexShrink", "flexNegative", "flexOrder", "gridArea", "gridRow", "gridRowEnd", "gridRowSpan", "gridRowStart", "gridColumn", "gridColumnEnd", "gridColumnSpan", "gridColumnStart", "fontWeight", "lineClamp", "lineHeight", "opacity", "order", "orphans", "scale", "tabSize", "widows", "zIndex", "zoom", "fillOpacity", "floodOpacity", "stopOpacity", "strokeDasharray", "strokeDashoffset", "strokeMiterlimit", "strokeOpacity", "strokeWidth", "MozAnimationIterationCount", "MozBoxFlex", "MozBoxFlexGroup", "MozLineClamp", "msAnimationIterationCount", "msFlex", "msZoom", "msFlexGrow", "msFlexNegative", "msFlexOrder", "msFlexPositive", "msFlexShrink", "msGridColumn", "msGridColumnSpan", "msGridRow", "msGridRowSpan", "WebkitAnimationIterationCount", "WebkitBoxFlex", "WebKitBoxFlexGroup", "WebkitBoxOrdinalGroup", "WebkitColumnCount", "WebkitColumns", "WebkitFlex", "WebkitFlexGrow", "WebkitFlexPositive", "WebkitFlexShrink", "WebkitLineClamp" ]);
1480
1441
 
1481
1442
  function makeStyleValue(name, value) {
1482
1443
  let isEmpty = value == null || typeof value === "boolean" || value === "";
@@ -1484,7 +1445,7 @@ function makeStyleValue(name, value) {
1484
1445
  return "";
1485
1446
  }
1486
1447
  let isNonNumeric = isNaN(value);
1487
- if (isNonNumeric || value === 0 || Object.hasOwn(isUnitlessNumber, name) && isUnitlessNumber[name]) {
1448
+ if (isNonNumeric || value === 0 || unitlessNumbers.has(name)) {
1488
1449
  return "" + value;
1489
1450
  }
1490
1451
  if (typeof value === "string") {
@@ -1495,11 +1456,7 @@ function makeStyleValue(name, value) {
1495
1456
 
1496
1457
  function styleObjectToString(styles) {
1497
1458
  let serialized = "";
1498
- for (let styleName in styles) {
1499
- if (!Object.hasOwn(styles, styleName)) {
1500
- continue;
1501
- }
1502
- let styleValue = styles[styleName];
1459
+ for (const [styleName, styleValue] of Object.entries(styles)) {
1503
1460
  if (styleValue != null) {
1504
1461
  serialized += makeStyleName(styleName) + ":";
1505
1462
  serialized += makeStyleValue(styleName, styleValue) + ";";
@@ -1417,68 +1417,29 @@ var isPlainObject_1 = isPlainObject;
1417
1417
 
1418
1418
  var isString_1 = isString;
1419
1419
 
1420
- const _uppercasePattern = /([A-Z])/g;
1421
-
1422
- function hyphenate(string) {
1423
- return string.replace(_uppercasePattern, "-$1").toLowerCase();
1424
- }
1420
+ const uppercasePattern = /([A-Z])/g;
1425
1421
 
1426
1422
  const msPattern = /^ms-/;
1427
1423
 
1428
- function hyphenateStyleName(string) {
1429
- return hyphenate(string).replace(msPattern, "-ms-");
1424
+ function hyphenateStyleName(name) {
1425
+ return name.replace(uppercasePattern, "-$1").toLowerCase().replace(msPattern, "-ms-");
1430
1426
  }
1431
1427
 
1432
1428
  function memoizeStringOnly(callback) {
1433
- let cache = {};
1429
+ const cache = new Map;
1434
1430
  return function(string) {
1435
- if (!cache.hasOwnProperty(string)) {
1436
- cache[string] = callback.call(this, string);
1431
+ let value = cache.get(string);
1432
+ if (value === undefined) {
1433
+ value = callback.call(this, string);
1434
+ cache.set(string, value);
1437
1435
  }
1438
- return cache[string];
1436
+ return value;
1439
1437
  };
1440
1438
  }
1441
1439
 
1442
- const makeStyleName = memoizeStringOnly((function(styleName) {
1443
- return hyphenateStyleName(styleName);
1444
- }));
1445
-
1446
- const isUnitlessNumber = {
1447
- animationIterationCount: true,
1448
- borderImageOutset: true,
1449
- borderImageSlice: true,
1450
- borderImageWidth: true,
1451
- boxFlex: true,
1452
- boxFlexGroup: true,
1453
- boxOrdinalGroup: true,
1454
- columnCount: true,
1455
- flex: true,
1456
- flexGrow: true,
1457
- flexPositive: true,
1458
- flexShrink: true,
1459
- flexNegative: true,
1460
- flexOrder: true,
1461
- gridRow: true,
1462
- gridColumn: true,
1463
- fontWeight: true,
1464
- lineClamp: true,
1465
- lineHeight: true,
1466
- opacity: true,
1467
- order: true,
1468
- orphans: true,
1469
- tabSize: true,
1470
- widows: true,
1471
- zIndex: true,
1472
- zoom: true,
1473
- fillOpacity: true,
1474
- floodOpacity: true,
1475
- stopOpacity: true,
1476
- strokeDasharray: true,
1477
- strokeDashoffset: true,
1478
- strokeMiterlimit: true,
1479
- strokeOpacity: true,
1480
- strokeWidth: true
1481
- };
1440
+ const makeStyleName = memoizeStringOnly(hyphenateStyleName);
1441
+
1442
+ const unitlessNumbers = new Set([ "animationIterationCount", "aspectRatio", "borderImageOutset", "borderImageSlice", "borderImageWidth", "boxFlex", "boxFlexGroup", "boxOrdinalGroup", "columnCount", "columns", "flex", "flexGrow", "flexPositive", "flexShrink", "flexNegative", "flexOrder", "gridArea", "gridRow", "gridRowEnd", "gridRowSpan", "gridRowStart", "gridColumn", "gridColumnEnd", "gridColumnSpan", "gridColumnStart", "fontWeight", "lineClamp", "lineHeight", "opacity", "order", "orphans", "scale", "tabSize", "widows", "zIndex", "zoom", "fillOpacity", "floodOpacity", "stopOpacity", "strokeDasharray", "strokeDashoffset", "strokeMiterlimit", "strokeOpacity", "strokeWidth", "MozAnimationIterationCount", "MozBoxFlex", "MozBoxFlexGroup", "MozLineClamp", "msAnimationIterationCount", "msFlex", "msZoom", "msFlexGrow", "msFlexNegative", "msFlexOrder", "msFlexPositive", "msFlexShrink", "msGridColumn", "msGridColumnSpan", "msGridRow", "msGridRowSpan", "WebkitAnimationIterationCount", "WebkitBoxFlex", "WebKitBoxFlexGroup", "WebkitBoxOrdinalGroup", "WebkitColumnCount", "WebkitColumns", "WebkitFlex", "WebkitFlexGrow", "WebkitFlexPositive", "WebkitFlexShrink", "WebkitLineClamp" ]);
1482
1443
 
1483
1444
  function makeStyleValue(name, value) {
1484
1445
  let isEmpty = value == null || typeof value === "boolean" || value === "";
@@ -1486,7 +1447,7 @@ function makeStyleValue(name, value) {
1486
1447
  return "";
1487
1448
  }
1488
1449
  let isNonNumeric = isNaN(value);
1489
- if (isNonNumeric || value === 0 || Object.hasOwn(isUnitlessNumber, name) && isUnitlessNumber[name]) {
1450
+ if (isNonNumeric || value === 0 || unitlessNumbers.has(name)) {
1490
1451
  return "" + value;
1491
1452
  }
1492
1453
  if (typeof value === "string") {
@@ -1497,11 +1458,7 @@ function makeStyleValue(name, value) {
1497
1458
 
1498
1459
  function styleObjectToString(styles) {
1499
1460
  let serialized = "";
1500
- for (let styleName in styles) {
1501
- if (!Object.hasOwn(styles, styleName)) {
1502
- continue;
1503
- }
1504
- let styleValue = styles[styleName];
1461
+ for (const [styleName, styleValue] of Object.entries(styles)) {
1505
1462
  if (styleValue != null) {
1506
1463
  serialized += makeStyleName(styleName) + ":";
1507
1464
  serialized += makeStyleValue(styleName, styleValue) + ";";
package/jsx-runtime.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var jsxRuntime = require("./jsx-runtime-NqHz6WEo.js");
3
+ var jsxRuntime = require("./jsx-runtime-fpN2EWm-.js");
4
4
 
5
5
  exports.Fragment = jsxRuntime.Fragment;
6
6
 
package/jsx-runtime.mjs CHANGED
@@ -1 +1 @@
1
- export { F as Fragment, c as jsx, j as jsxs } from "./jsx-runtime-xIDZYHgS.js";
1
+ export { F as Fragment, c as jsx, j as jsxs } from "./jsx-runtime-_xtqfR_9.js";
package/jsx.d.ts CHANGED
@@ -2,4 +2,5 @@ declare namespace JSX {
2
2
  type IntrinsicElements = {
3
3
  [_ in import('./htmlspec/IntrinsicElements').HtmlElements]: import('./types').CommonProps;
4
4
  };
5
+ type Element = import('./jsx-node').JsxNode;
5
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpen/jsxhtml",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "packageManager": "bun@1.0.7",
5
5
  "exports": "./index.cjs",
6
6
  "module": "./index.mjs",
@@ -1,3 +1,4 @@
1
+ import { StyleObject } from './types';
1
2
  /**
2
3
  * Serializes a mapping of style properties for use as inline styles:
3
4
  *
@@ -11,4 +12,3 @@
11
12
  * @return {?string}
12
13
  */
13
14
  export default function styleObjectToString(styles: StyleObject): string;
14
- export type StyleObject = Record<string, any>;
package/types.d.ts ADDED
@@ -0,0 +1,35 @@
1
+ import { JsxNode } from './jsx-node';
2
+ export interface Stringable {
3
+ toString(): string;
4
+ }
5
+ export type PlainObject = Record<PropertyKey, unknown>;
6
+ export type ClassNames = import('classnames').Argument;
7
+ export type StyleObject = import('csstype').Properties | import('csstype').PropertiesHyphen;
8
+ export type AttributeValue = Stringable | StyleObject | ClassNames;
9
+ export type AttrKvPair = [name: string, value: AttributeValue];
10
+ export type AttrArr = AttrKvPair[];
11
+ export type AttrObj = Record<string, AttributeValue>;
12
+ export type Attributes = AttrObj | AttrArr;
13
+ export type UnkFn = (...args: unknown[]) => unknown;
14
+ export type AnyFn = (...args: any[]) => any;
15
+ export type HtmlSafe = {
16
+ __html: string;
17
+ };
18
+ export type JsxRenderable = any;
19
+ export type JsxChildren = JsxRenderable | Iterable<JsxRenderable>;
20
+ export type CommonProps = Omit<AttrObj, 'children' | 'style' | 'class'> & {
21
+ children?: JsxChildren;
22
+ style?: StyleObject | string;
23
+ class?: ClassNames;
24
+ };
25
+ export type JsxComponent<P = CommonProps> = ((props: P) => JsxNode) & {
26
+ displayName?: string;
27
+ name?: string;
28
+ };
29
+ export type FlatString = string | Iterable<string>;
30
+ export interface StringChildren {
31
+ children: FlatString;
32
+ }
33
+ export interface ChildrenOnly {
34
+ children: JsxChildren;
35
+ }