Skip to content

Commit

Permalink
deprecate export default for the module atomico/html
Browse files Browse the repository at this point in the history
  • Loading branch information
UpperCod committed May 6, 2022
1 parent 0e3af6d commit 98cba8b
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 11 deletions.
118 changes: 115 additions & 3 deletions html.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,120 @@
import { h } from './src/render.js';
import { h } from "./src/render.js";

var n=function(t,s,r,e){var u;s[0]=0;for(var h=1;h<s.length;h++){var p=s[h++],a=s[h]?(s[0]|=p?1:2,r[s[h++]]):s[++h];3===p?e[0]=a:4===p?e[1]=Object.assign(e[1]||{},a):5===p?(e[1]=e[1]||{})[s[++h]]=a:6===p?e[1][s[++h]]+=a+"":p?(u=t.apply(a,n(t,a,r,["",null])),e.push(u),a[0]?s[0]|=2:(s[h-2]=0,s[h]=u)):e.push(a);}return e},t=new Map;function htm(s){var r=t.get(this);return r||(r=new Map,t.set(this,r)),(r=n(this,r.get(s)||(r.set(s,r=function(n){for(var t,s,r=1,e="",u="",h=[0],p=function(n){1===r&&(n||(e=e.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?h.push(0,n,e):3===r&&(n||e)?(h.push(3,n,e),r=2):2===r&&"..."===e&&n?h.push(4,n,0):2===r&&e&&!n?h.push(5,0,!0,e):r>=5&&((e||!n&&5===r)&&(h.push(r,0,e,s),r=6),n&&(h.push(r,n,0,s),r=6)),e="";},a=0;a<n.length;a++){a&&(1===r&&p(),p(a));for(var l=0;l<n[a].length;l++)t=n[a][l],1===r?"<"===t?(p(),h=[h],r=3):e+=t:4===r?"--"===e&&">"===t?(r=1,e=""):e=t+e[0]:u?t===u?u="":e+=t:'"'===t||"'"===t?u=t:">"===t?(p(),r=1):r&&("="===t?(r=5,s=e,e=""):"/"===t&&(r<5||">"===n[a][l+1])?(p(),3===r&&(h=h[0]),r=h,(h=h[0]).push(2,0,r),r=0):" "===t||"\t"===t||"\n"===t||"\r"===t?(p(),r=2):e+=t),3===r&&"!--"===e&&(r=4,h=h[0]);}return p(),h}(s)),r),arguments,[])).length>1?r:r[0]}
var n = function (t, s, r, e) {
var u;
s[0] = 0;
for (var h = 1; h < s.length; h++) {
var p = s[h++],
a = s[h] ? ((s[0] |= p ? 1 : 2), r[s[h++]]) : s[++h];
3 === p
? (e[0] = a)
: 4 === p
? (e[1] = Object.assign(e[1] || {}, a))
: 5 === p
? ((e[1] = e[1] || {})[s[++h]] = a)
: 6 === p
? (e[1][s[++h]] += a + "")
: p
? ((u = t.apply(a, n(t, a, r, ["", null]))),
e.push(u),
a[0] ? (s[0] |= 2) : ((s[h - 2] = 0), (s[h] = u)))
: e.push(a);
}
return e;
},
t = new Map();
function htm(s) {
var r = t.get(this);
return (
r || ((r = new Map()), t.set(this, r)),
(r = n(
this,
r.get(s) ||
(r.set(
s,
(r = (function (n) {
for (
var t,
s,
r = 1,
e = "",
u = "",
h = [0],
p = function (n) {
1 === r &&
(n ||
(e = e.replace(
/^\s*\n\s*|\s*\n\s*$/g,
""
)))
? h.push(0, n, e)
: 3 === r && (n || e)
? (h.push(3, n, e), (r = 2))
: 2 === r && "..." === e && n
? h.push(4, n, 0)
: 2 === r && e && !n
? h.push(5, 0, !0, e)
: r >= 5 &&
((e || (!n && 5 === r)) &&
(h.push(r, 0, e, s), (r = 6)),
n && (h.push(r, n, 0, s), (r = 6))),
(e = "");
},
a = 0;
a < n.length;
a++
) {
a && (1 === r && p(), p(a));
for (var l = 0; l < n[a].length; l++)
(t = n[a][l]),
1 === r
? "<" === t
? (p(), (h = [h]), (r = 3))
: (e += t)
: 4 === r
? "--" === e && ">" === t
? ((r = 1), (e = ""))
: (e = t + e[0])
: u
? t === u
? (u = "")
: (e += t)
: '"' === t || "'" === t
? (u = t)
: ">" === t
? (p(), (r = 1))
: r &&
("=" === t
? ((r = 5), (s = e), (e = ""))
: "/" === t &&
(r < 5 || ">" === n[a][l + 1])
? (p(),
3 === r && (h = h[0]),
(r = h),
(h = h[0]).push(2, 0, r),
(r = 0))
: " " === t ||
"\t" === t ||
"\n" === t ||
"\r" === t
? (p(), (r = 2))
: (e += t)),
3 === r &&
"!--" === e &&
((r = 4), (h = h[0]));
}
return p(), h;
})(s))
),
r),
arguments,
[]
)).length > 1
? r
: r[0]
);
}

const html = htm.bind(h);

export default html;
export { html };
2 changes: 0 additions & 2 deletions html/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@ import htm from "htm";
import { h } from "../src/render.js";

export let html = htm.bind(h);

export default html;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "atomico",
"version": "1.54.5",
"version": "1.55.0",
"description": "Atomico is a small library for the creation of interfaces based on web-components, only using functions and hooks.",
"type": "module",
"main": "./core.js",
Expand Down
2 changes: 1 addition & 1 deletion src/tests/element.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect } from "@esm-bundle/chai";
import { c, Any } from "../element/custom-element.js";
import { css } from "../css.js";
import { PropError } from "../element/errors.js";
import html from "../../html/html.js";
import { html } from "../../html/html.js";
import { options } from "../options.js";
import { useState } from "../hooks/hooks.js";

Expand Down
2 changes: 1 addition & 1 deletion src/tests/render-children.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from "@esm-bundle/chai";
import { renderChildren } from "../render.js";
import html from "../../html/html";
import { html } from "../../html/html";
/**
* @param {import("../render").Fragment} fragment
* @returns {Node[]}
Expand Down
2 changes: 1 addition & 1 deletion src/tests/render.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from "@esm-bundle/chai";
import { h, render } from "../render.js";
import html from "../../html/html";
import { html } from "../../html/html";

describe("src/render", () => {
it("attach shadowDom", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/tests/ssr.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from "@esm-bundle/chai";
import { render } from "../render.js";
import { c } from "../element/custom-element.js";
import html from "../../html/html";
import { html } from "../../html/html";

describe("src/render#ssr", () => {
it("without hydration", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/tests/template.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "@esm-bundle/chai";
import html from "../../html/html";
import { html } from "../../html/html";
import { template } from "../template";

describe("src/template", () => {
Expand Down

0 comments on commit 98cba8b

Please sign in to comment.