mini-jsx-test-pb 0.1.3 → 0.1.5

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.
@@ -0,0 +1,37 @@
1
+ // src/reactivity/state.ts
2
+ var activeEffect = null;
3
+ function State(initial) {
4
+ let value = initial;
5
+ const subscribers = /* @__PURE__ */ new Set();
6
+ return {
7
+ get val() {
8
+ if (activeEffect) {
9
+ subscribers.add(activeEffect);
10
+ }
11
+ return value;
12
+ },
13
+ set val(next) {
14
+ if (Object.is(value, next)) return;
15
+ value = next;
16
+ subscribers.forEach((fn) => fn());
17
+ }
18
+ };
19
+ }
20
+ function setActiveEffect(effect2) {
21
+ activeEffect = effect2;
22
+ }
23
+
24
+ // src/reactivity/effect.ts
25
+ function effect(fn) {
26
+ const runner = () => {
27
+ setActiveEffect(runner);
28
+ fn();
29
+ setActiveEffect(null);
30
+ };
31
+ runner();
32
+ }
33
+
34
+ export {
35
+ State,
36
+ effect
37
+ };
@@ -0,0 +1,58 @@
1
+ import {
2
+ effect
3
+ } from "./chunk-DIUGWQ3J.js";
4
+
5
+ // src/jsx/mount.ts
6
+ function mountChild(parent, child) {
7
+ if (child == null || child === true || child === false) return;
8
+ if (Array.isArray(child)) {
9
+ for (const c of child) mountChild(parent, c);
10
+ return;
11
+ }
12
+ if (child instanceof Node) {
13
+ parent.appendChild(child);
14
+ return;
15
+ }
16
+ if (typeof child === "function") {
17
+ const text = document.createTextNode("");
18
+ parent.appendChild(text);
19
+ effect(() => {
20
+ const v = child();
21
+ text.nodeValue = v == null ? "" : String(v);
22
+ });
23
+ return;
24
+ }
25
+ if (typeof child === "object" && child && "val" in child) {
26
+ mountChild(parent, () => child.val);
27
+ return;
28
+ }
29
+ parent.appendChild(document.createTextNode(String(child)));
30
+ }
31
+
32
+ // src/jsx/jsx.ts
33
+ function h(type, props, ...rest) {
34
+ if (typeof type === "function") {
35
+ return type(props ?? {});
36
+ }
37
+ const el = document.createElement(type);
38
+ if (props) {
39
+ for (const key in props) {
40
+ if (key === "children") continue;
41
+ const value = props[key];
42
+ if (key.startsWith("on")) {
43
+ el.addEventListener(key.slice(2).toLowerCase(), value);
44
+ } else {
45
+ el.setAttribute(key, String(value));
46
+ }
47
+ }
48
+ }
49
+ const children = rest.length > 0 ? rest : props?.children != null ? Array.isArray(props.children) ? props.children : [props.children] : [];
50
+ for (const child of children) {
51
+ mountChild(el, child);
52
+ }
53
+ return el;
54
+ }
55
+
56
+ export {
57
+ h
58
+ };
package/dist/index.js CHANGED
@@ -1,35 +1,7 @@
1
- // src/reactivity/state.ts
2
- var activeEffect = null;
3
- function State(initial) {
4
- let value = initial;
5
- const subscribers = /* @__PURE__ */ new Set();
6
- return {
7
- get val() {
8
- if (activeEffect) {
9
- subscribers.add(activeEffect);
10
- }
11
- return value;
12
- },
13
- set val(next) {
14
- if (Object.is(value, next)) return;
15
- value = next;
16
- subscribers.forEach((fn) => fn());
17
- }
18
- };
19
- }
20
- function setActiveEffect(effect2) {
21
- activeEffect = effect2;
22
- }
23
-
24
- // src/reactivity/effect.ts
25
- function effect(fn) {
26
- const runner = () => {
27
- setActiveEffect(runner);
28
- fn();
29
- setActiveEffect(null);
30
- };
31
- runner();
32
- }
1
+ import {
2
+ State,
3
+ effect
4
+ } from "./chunk-DIUGWQ3J.js";
33
5
  export {
34
6
  State,
35
7
  effect
@@ -0,0 +1,3 @@
1
+ declare function jsxDEV(type: any, props: any): any;
2
+
3
+ export { jsxDEV };
@@ -0,0 +1,12 @@
1
+ import {
2
+ h
3
+ } from "./chunk-VFKTCWRG.js";
4
+ import "./chunk-DIUGWQ3J.js";
5
+
6
+ // src/jsx/jsx-dev-runtime.ts
7
+ function jsxDEV(type, props) {
8
+ return h(type, props);
9
+ }
10
+ export {
11
+ jsxDEV
12
+ };
@@ -0,0 +1,4 @@
1
+ declare function jsx(type: any, props: any): any;
2
+ declare function jsxs(type: any, props: any): any;
3
+
4
+ export { jsx, jsxs };
@@ -0,0 +1,16 @@
1
+ import {
2
+ h
3
+ } from "./chunk-VFKTCWRG.js";
4
+ import "./chunk-DIUGWQ3J.js";
5
+
6
+ // src/jsx/jsx-runtime.ts
7
+ function jsx(type, props) {
8
+ return h(type, props);
9
+ }
10
+ function jsxs(type, props) {
11
+ return h(type, props);
12
+ }
13
+ export {
14
+ jsx,
15
+ jsxs
16
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mini-jsx-test-pb",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",