@r2wc/react-to-web-component 1.0.0-alpha.1 → 1.0.0-alpha.3

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.
@@ -1 +1 @@
1
- "use strict";const k=require("/home/runner/work/react-to-web-component/react-to-web-component/node_modules/react/index.js"),A=require("/home/runner/work/react-to-web-component/react-to-web-component/node_modules/react-dom/index.js");var v=Object.defineProperty,C=(t,e,n)=>e in t?v(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,l=(t,e,n)=>(C(t,typeof e!="symbol"?e+"":e,n),n);const x={stringify:t=>t,parse:t=>t},N={stringify:t=>`${t}`,parse:t=>parseFloat(t)},T={stringify:t=>t?"true":"false",parse:t=>/^[ty1-9]/i.test(t)},$={stringify:t=>t.name,parse:(t,e)=>{const n=(()=>{if(typeof window<"u"&&t in window)return window[t];if(typeof global<"u"&&t in global)return global[t]})();return typeof n=="function"?n.bind(e):void 0}},E={stringify:t=>JSON.stringify(t),parse:t=>JSON.parse(t)},m={string:x,number:N,boolean:T,function:$,json:E},w=Symbol.for("r2wc.render"),b=Symbol.for("r2wc.connected"),u=Symbol.for("r2wc.context"),i=Symbol.for("r2wc.props");function L(t,e,n){var a,O,S;e.props||(e.props=t.propTypes?Object.keys(t.propTypes):[]);const y=(Array.isArray(e.props)?e.props.slice():Object.keys(e.props)).filter(r=>r!=="container"),p={},d={},g={};for(const r of y){p[r]=Array.isArray(e.props)?"string":e.props[r];const s=P(r);d[r]=s,g[s]=r}class j extends HTMLElement{constructor(){super(),l(this,a,!0),l(this,O),l(this,S,{}),l(this,"container"),e.shadow?this.container=this.attachShadow({mode:e.shadow}):this.container=this,this[i].container=this.container;for(const s of y){const f=d[s],c=this.getAttribute(f),o=p[s];c&&(this[i][s]=m[o].parse(c,this))}}static get observedAttributes(){return Object.keys(g)}connectedCallback(){this[b]=!0,this[w]()}disconnectedCallback(){this[b]=!1,this[u]&&n.unmount(this[u])}attributeChangedCallback(s,f,c){const o=g[s],h=p[o];o in p&&(this[i][o]=m[h].parse(c,this),this[w]())}[(a=b,O=u,S=i,w)](){this[b]&&(this[u]?n.update(this[u],this[i]):this[u]=n.mount(this.container,t,this[i]))}}for(const r of y){const s=d[r],f=p[r];Object.defineProperty(j.prototype,r,{enumerable:!0,configurable:!0,get(){return this[i][r]},set(c){this[i][r]=c;const o=m[f].stringify;if(o){const h=o(c);this.getAttribute(s)!==h&&this.setAttribute(s,h)}}})}return j}function P(t=""){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function q(t,e,n){const a=k.createElement(e,n);return A.render(a,t),{container:t,ReactComponent:e}}function J({container:t,ReactComponent:e},n){const a=k.createElement(e,n);A.render(a,t)}function M({container:t}){A.unmountComponentAtNode(t)}function z(t,e={}){return L(t,e,{mount:q,update:J,unmount:M})}module.exports=z;
1
+ "use strict";const c=require("react"),u=require("react-dom"),o=require("@r2wc/core");function s(e,t,n){const r=c.createElement(t,n);return u.render(r,e),{container:e,ReactComponent:t}}function i({container:e,ReactComponent:t},n){const r=c.createElement(t,n);u.render(r,e)}function m({container:e}){u.unmountComponentAtNode(e)}function d(e,t={}){return o(e,t,{mount:s,update:i,unmount:m})}module.exports=d;
@@ -1,116 +1,23 @@
1
- import k from "/home/runner/work/react-to-web-component/react-to-web-component/node_modules/react/index.js";
2
- import A from "/home/runner/work/react-to-web-component/react-to-web-component/node_modules/react-dom/index.js";
3
- var v = Object.defineProperty, C = (t, e, n) => e in t ? v(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, l = (t, e, n) => (C(t, typeof e != "symbol" ? e + "" : e, n), n);
4
- const x = {
5
- stringify: (t) => t,
6
- parse: (t) => t
7
- }, N = {
8
- stringify: (t) => `${t}`,
9
- parse: (t) => parseFloat(t)
10
- }, T = {
11
- stringify: (t) => t ? "true" : "false",
12
- parse: (t) => /^[ty1-9]/i.test(t)
13
- }, $ = {
14
- stringify: (t) => t.name,
15
- parse: (t, e) => {
16
- const n = (() => {
17
- if (typeof window < "u" && t in window)
18
- return window[t];
19
- if (typeof global < "u" && t in global)
20
- return global[t];
21
- })();
22
- return typeof n == "function" ? n.bind(e) : void 0;
23
- }
24
- }, E = {
25
- stringify: (t) => JSON.stringify(t),
26
- parse: (t) => JSON.parse(t)
27
- }, g = {
28
- string: x,
29
- number: N,
30
- boolean: T,
31
- function: $,
32
- json: E
33
- }, w = Symbol.for("r2wc.render"), b = Symbol.for("r2wc.connected"), p = Symbol.for("r2wc.context"), i = Symbol.for("r2wc.props");
34
- function L(t, e, n) {
35
- var c, O, S;
36
- e.props || (e.props = t.propTypes ? Object.keys(t.propTypes) : []);
37
- const y = (Array.isArray(e.props) ? e.props.slice() : Object.keys(e.props)).filter((r) => r !== "container"), u = {}, d = {}, m = {};
38
- for (const r of y) {
39
- u[r] = Array.isArray(e.props) ? "string" : e.props[r];
40
- const o = P(r);
41
- d[r] = o, m[o] = r;
42
- }
43
- class j extends HTMLElement {
44
- constructor() {
45
- super(), l(this, c, !0), l(this, O), l(this, S, {}), l(this, "container"), e.shadow ? this.container = this.attachShadow({
46
- mode: e.shadow
47
- }) : this.container = this, this[i].container = this.container;
48
- for (const o of y) {
49
- const f = d[o], a = this.getAttribute(f), s = u[o];
50
- a && (this[i][o] = g[s].parse(a, this));
51
- }
52
- }
53
- static get observedAttributes() {
54
- return Object.keys(m);
55
- }
56
- connectedCallback() {
57
- this[b] = !0, this[w]();
58
- }
59
- disconnectedCallback() {
60
- this[b] = !1, this[p] && n.unmount(this[p]);
61
- }
62
- attributeChangedCallback(o, f, a) {
63
- const s = m[o], h = u[s];
64
- s in u && (this[i][s] = g[h].parse(a, this), this[w]());
65
- }
66
- [(c = b, O = p, S = i, w)]() {
67
- this[b] && (this[p] ? n.update(this[p], this[i]) : this[p] = n.mount(
68
- this.container,
69
- t,
70
- this[i]
71
- ));
72
- }
73
- }
74
- for (const r of y) {
75
- const o = d[r], f = u[r];
76
- Object.defineProperty(j.prototype, r, {
77
- enumerable: !0,
78
- configurable: !0,
79
- get() {
80
- return this[i][r];
81
- },
82
- set(a) {
83
- this[i][r] = a;
84
- const s = g[f].stringify;
85
- if (s) {
86
- const h = s(a);
87
- this.getAttribute(o) !== h && this.setAttribute(o, h);
88
- }
89
- }
90
- });
91
- }
92
- return j;
93
- }
94
- function P(t = "") {
95
- return t.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
96
- }
97
- function J(t, e, n) {
98
- const c = k.createElement(e, n);
99
- return A.render(c, t), {
100
- container: t,
101
- ReactComponent: e
1
+ import m from "react";
2
+ import o from "react-dom";
3
+ import u from "@r2wc/core";
4
+ function c(e, t, n) {
5
+ const r = m.createElement(t, n);
6
+ return o.render(r, e), {
7
+ container: e,
8
+ ReactComponent: t
102
9
  };
103
10
  }
104
- function M({ container: t, ReactComponent: e }, n) {
105
- const c = k.createElement(e, n);
106
- A.render(c, t);
11
+ function f({ container: e, ReactComponent: t }, n) {
12
+ const r = m.createElement(t, n);
13
+ o.render(r, e);
107
14
  }
108
- function z({ container: t }) {
109
- A.unmountComponentAtNode(t);
15
+ function i({ container: e }) {
16
+ o.unmountComponentAtNode(e);
110
17
  }
111
- function H(t, e = {}) {
112
- return L(t, e, { mount: J, update: M, unmount: z });
18
+ function p(e, t = {}) {
19
+ return u(e, t, { mount: c, update: f, unmount: i });
113
20
  }
114
21
  export {
115
- H as default
22
+ p as default
116
23
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@r2wc/react-to-web-component",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.3",
4
4
  "description": "Convert React components to native Web Components.",
5
5
  "homepage": "https://www.bitovi.com/frontend-javascript-consulting/react-consulting",
6
6
  "author": "Bitovi",
@@ -45,12 +45,8 @@
45
45
  "@r2wc/core": "^1.0.0-alpha.0"
46
46
  },
47
47
  "devDependencies": {
48
- "@testing-library/jest-dom": "^5.16.5",
49
48
  "@types/react": "^17.0.0",
50
- "@types/react-dom": "^17.0.0",
51
- "vite": "^4.3.1",
52
- "vite-plugin-dts": "^2.3.0",
53
- "vitest": "^0.30.1"
49
+ "@types/react-dom": "^17.0.0"
54
50
  },
55
51
  "peerDependencies": {
56
52
  "react": "^16.0.0 || ^17.0.0",