best-unit 0.0.5 → 0.0.6

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";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function d(){console.log("npm package test!!!")}function s(){console.log("Current time:",new Date().toISOString())}var u;function a(r){return r.children}u={__e:function(r,t,l,f){for(var e,c,o;t=t.__;)if((e=t.__c)&&!e.__)try{if((c=e.constructor)&&c.getDerivedStateFromError!=null&&(e.setState(c.getDerivedStateFromError(r)),o=e.__d),e.componentDidCatch!=null&&(e.componentDidCatch(r,f||{}),o=e.__d),o)return e.__E=e}catch(n){r=n}throw r}},typeof Promise=="function"&&Promise.prototype.then.bind(Promise.resolve());var m=0;function i(r,t,l,f,e,c){t||(t={});var o,n,_=t;if("ref"in _)for(n in _={},t)n=="ref"?o=t[n]:_[n]=t[n];var p={type:r,props:_,key:l,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--m,__i:-1,__u:0,__source:e,__self:c};if(typeof r=="function"&&(o=r.defaultProps))for(n in o)_[n]===void 0&&(_[n]=o[n]);return u.vnode&&u.vnode(p),p}function v(){return i(a,{children:i("div",{children:i("h1",{children:"Hello World"})})})}exports.App=v;exports.npmTest=d;exports.printCurrentTime=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function de(){console.log("npm package test!!!")}function ve(){console.log("Current time:",new Date().toISOString())}var O,d,te,C,Q,ne,_e,re,z,R,B,L={},oe=[],me=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,H=Array.isArray;function k(t,e){for(var n in e)t[n]=e[n];return t}function G(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function x(t,e,n){var o,l,_,i={};for(_ in e)_=="key"?o=e[_]:_=="ref"?l=e[_]:i[_]=e[_];if(arguments.length>2&&(i.children=arguments.length>3?O.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(_ in t.defaultProps)i[_]===void 0&&(i[_]=t.defaultProps[_]);return $(t,i,o,l,null)}function $(t,e,n,o,l){var _={type:t,props:e,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:l??++te,__i:-1,__u:0};return l==null&&d.vnode!=null&&d.vnode(_),_}function F(t){return t.children}function j(t,e){this.props=t,this.context=e}function P(t,e){if(e==null)return t.__?P(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?P(t):null}function le(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return le(t)}}function X(t){(!t.__d&&(t.__d=!0)&&C.push(t)&&!N.__r++||Q!=d.debounceRendering)&&((Q=d.debounceRendering)||ne)(N)}function N(){for(var t,e,n,o,l,_,i,s=1;C.length;)C.length>s&&C.sort(_e),t=C.shift(),s=C.length,t.__d&&(n=void 0,l=(o=(e=t).__v).__e,_=[],i=[],e.__P&&((n=k({},o)).__v=o.__v+1,d.vnode&&d.vnode(n),V(e.__P,n,o,e.__n,e.__P.namespaceURI,32&o.__u?[l]:null,_,l??P(o),!!(32&o.__u),i),n.__v=o.__v,n.__.__k[n.__i]=n,ue(_,n,i),n.__e!=l&&le(n)));N.__r=0}function ie(t,e,n,o,l,_,i,s,c,u,a){var r,v,p,m,g,y,f=o&&o.__k||oe,h=e.length;for(c=ye(n,e,f,c,h),r=0;r<h;r++)(p=n.__k[r])!=null&&(v=p.__i==-1?L:f[p.__i]||L,p.__i=r,y=V(t,p,v,l,_,i,s,c,u,a),m=p.__e,p.ref&&v.ref!=p.ref&&(v.ref&&q(v.ref,null,p),a.push(p.ref,p.__c||m,p)),g==null&&m!=null&&(g=m),4&p.__u||v.__k===p.__k?c=se(p,c,t):typeof p.type=="function"&&y!==void 0?c=y:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=g,c}function ye(t,e,n,o,l){var _,i,s,c,u,a=n.length,r=a,v=0;for(t.__k=new Array(l),_=0;_<l;_++)(i=e[_])!=null&&typeof i!="boolean"&&typeof i!="function"?(c=_+v,(i=t.__k[_]=typeof i=="string"||typeof i=="number"||typeof i=="bigint"||i.constructor==String?$(null,i,null,null,null):H(i)?$(F,{children:i},null,null,null):i.constructor==null&&i.__b>0?$(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i).__=t,i.__b=t.__b+1,s=null,(u=i.__i=ge(i,n,c,r))!=-1&&(r--,(s=n[u])&&(s.__u|=2)),s==null||s.__v==null?(u==-1&&(l>a?v--:l<a&&v++),typeof i.type!="function"&&(i.__u|=4)):u!=c&&(u==c-1?v--:u==c+1?v++:(u>c?v--:v++,i.__u|=4))):t.__k[_]=null;if(r)for(_=0;_<a;_++)(s=n[_])!=null&&(2&s.__u)==0&&(s.__e==o&&(o=P(s)),pe(s,s));return o}function se(t,e,n){var o,l;if(typeof t.type=="function"){for(o=t.__k,l=0;o&&l<o.length;l++)o[l]&&(o[l].__=t,e=se(o[l],e,n));return e}t.__e!=e&&(e&&t.type&&!n.contains(e)&&(e=P(t)),n.insertBefore(t.__e,e||null),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function ge(t,e,n,o){var l,_,i=t.key,s=t.type,c=e[n];if(c===null&&t.key==null||c&&i==c.key&&s==c.type&&(2&c.__u)==0)return n;if(o>(c!=null&&(2&c.__u)==0?1:0))for(l=n-1,_=n+1;l>=0||_<e.length;){if(l>=0){if((c=e[l])&&(2&c.__u)==0&&i==c.key&&s==c.type)return l;l--}if(_<e.length){if((c=e[_])&&(2&c.__u)==0&&i==c.key&&s==c.type)return _;_++}}return-1}function Y(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||me.test(e)?n:n+"px"}function A(t,e,n,o,l){var _,i;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof o=="string"&&(t.style.cssText=o=""),o)for(e in o)n&&e in n||Y(t.style,e,"");if(n)for(e in n)o&&n[e]==o[e]||Y(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")_=e!=(e=e.replace(re,"$1")),i=e.toLowerCase(),e=i in t||e=="onFocusOut"||e=="onFocusIn"?i.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+_]=n,n?o?n.u=o.u:(n.u=z,t.addEventListener(e,_?B:R,_)):t.removeEventListener(e,_?B:R,_);else{if(l=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function Z(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=z++;else if(e.t<n.u)return;return n(d.event?d.event(e):e)}}}function V(t,e,n,o,l,_,i,s,c,u){var a,r,v,p,m,g,y,f,h,S,w,D,T,K,U,E,I,b=e.type;if(e.constructor!=null)return null;128&n.__u&&(c=!!(32&n.__u),_=[s=e.__e=n.__e]),(a=d.__b)&&a(e);e:if(typeof b=="function")try{if(f=e.props,h="prototype"in b&&b.prototype.render,S=(a=b.contextType)&&o[a.__c],w=a?S?S.props.value:a.__:o,n.__c?y=(r=e.__c=n.__c).__=r.__E:(h?e.__c=r=new b(f,w):(e.__c=r=new j(f,w),r.constructor=b,r.render=ke),S&&S.sub(r),r.props=f,r.state||(r.state={}),r.context=w,r.__n=o,v=r.__d=!0,r.__h=[],r._sb=[]),h&&r.__s==null&&(r.__s=r.state),h&&b.getDerivedStateFromProps!=null&&(r.__s==r.state&&(r.__s=k({},r.__s)),k(r.__s,b.getDerivedStateFromProps(f,r.__s))),p=r.props,m=r.state,r.__v=e,v)h&&b.getDerivedStateFromProps==null&&r.componentWillMount!=null&&r.componentWillMount(),h&&r.componentDidMount!=null&&r.__h.push(r.componentDidMount);else{if(h&&b.getDerivedStateFromProps==null&&f!==p&&r.componentWillReceiveProps!=null&&r.componentWillReceiveProps(f,w),!r.__e&&r.shouldComponentUpdate!=null&&r.shouldComponentUpdate(f,r.__s,w)===!1||e.__v==n.__v){for(e.__v!=n.__v&&(r.props=f,r.state=r.__s,r.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(M){M&&(M.__=e)}),D=0;D<r._sb.length;D++)r.__h.push(r._sb[D]);r._sb=[],r.__h.length&&i.push(r);break e}r.componentWillUpdate!=null&&r.componentWillUpdate(f,r.__s,w),h&&r.componentDidUpdate!=null&&r.__h.push(function(){r.componentDidUpdate(p,m,g)})}if(r.context=w,r.props=f,r.__P=t,r.__e=!1,T=d.__r,K=0,h){for(r.state=r.__s,r.__d=!1,T&&T(e),a=r.render(r.props,r.state,r.context),U=0;U<r._sb.length;U++)r.__h.push(r._sb[U]);r._sb=[]}else do r.__d=!1,T&&T(e),a=r.render(r.props,r.state,r.context),r.state=r.__s;while(r.__d&&++K<25);r.state=r.__s,r.getChildContext!=null&&(o=k(k({},o),r.getChildContext())),h&&!v&&r.getSnapshotBeforeUpdate!=null&&(g=r.getSnapshotBeforeUpdate(p,m)),E=a,a!=null&&a.type===F&&a.key==null&&(E=ce(a.props.children)),s=ie(t,H(E)?E:[E],e,n,o,l,_,i,s,c,u),r.base=e.__e,e.__u&=-161,r.__h.length&&i.push(r),y&&(r.__E=r.__=null)}catch(M){if(e.__v=null,c||_!=null)if(M.then){for(e.__u|=c?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;_[_.indexOf(s)]=null,e.__e=s}else for(I=_.length;I--;)G(_[I]);else e.__e=n.__e,e.__k=n.__k;d.__e(M,e,n)}else _==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):s=e.__e=be(n.__e,e,n,o,l,_,i,c,u);return(a=d.diffed)&&a(e),128&e.__u?void 0:s}function ue(t,e,n){for(var o=0;o<n.length;o++)q(n[o],n[++o],n[++o]);d.__c&&d.__c(e,t),t.some(function(l){try{t=l.__h,l.__h=[],t.some(function(_){_.call(l)})}catch(_){d.__e(_,l.__v)}})}function ce(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:H(t)?t.map(ce):k({},t)}function be(t,e,n,o,l,_,i,s,c){var u,a,r,v,p,m,g,y=n.props,f=e.props,h=e.type;if(h=="svg"?l="http://www.w3.org/2000/svg":h=="math"?l="http://www.w3.org/1998/Math/MathML":l||(l="http://www.w3.org/1999/xhtml"),_!=null){for(u=0;u<_.length;u++)if((p=_[u])&&"setAttribute"in p==!!h&&(h?p.localName==h:p.nodeType==3)){t=p,_[u]=null;break}}if(t==null){if(h==null)return document.createTextNode(f);t=document.createElementNS(l,h,f.is&&f),s&&(d.__m&&d.__m(e,_),s=!1),_=null}if(h==null)y===f||s&&t.data==f||(t.data=f);else{if(_=_&&O.call(t.childNodes),y=n.props||L,!s&&_!=null)for(y={},u=0;u<t.attributes.length;u++)y[(p=t.attributes[u]).name]=p.value;for(u in y)if(p=y[u],u!="children"){if(u=="dangerouslySetInnerHTML")r=p;else if(!(u in f)){if(u=="value"&&"defaultValue"in f||u=="checked"&&"defaultChecked"in f)continue;A(t,u,null,p,l)}}for(u in f)p=f[u],u=="children"?v=p:u=="dangerouslySetInnerHTML"?a=p:u=="value"?m=p:u=="checked"?g=p:s&&typeof p!="function"||y[u]===p||A(t,u,p,y[u],l);if(a)s||r&&(a.__html==r.__html||a.__html==t.innerHTML)||(t.innerHTML=a.__html),e.__k=[];else if(r&&(t.innerHTML=""),ie(e.type=="template"?t.content:t,H(v)?v:[v],e,n,o,h=="foreignObject"?"http://www.w3.org/1999/xhtml":l,_,i,_?_[0]:n.__k&&P(n,0),s,c),_!=null)for(u=_.length;u--;)G(_[u]);s||(u="value",h=="progress"&&m==null?t.removeAttribute("value"):m!=null&&(m!==t[u]||h=="progress"&&!m||h=="option"&&m!=y[u])&&A(t,u,m,y[u],l),u="checked",g!=null&&g!=t[u]&&A(t,u,g,y[u],l))}return t}function q(t,e,n){try{if(typeof t=="function"){var o=typeof t.__u=="function";o&&t.__u(),o&&e==null||(t.__u=t(e))}else t.current=e}catch(l){d.__e(l,n)}}function pe(t,e,n){var o,l;if(d.unmount&&d.unmount(t),(o=t.ref)&&(o.current&&o.current!=t.__e||q(o,null,e)),(o=t.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(_){d.__e(_,e)}o.base=o.__P=null}if(o=t.__k)for(l=0;l<o.length;l++)o[l]&&pe(o[l],e,n||typeof t.type!="function");n||G(t.__e),t.__c=t.__=t.__e=void 0}function ke(t,e,n){return this.constructor(t,n)}function W(t,e,n){var o,l,_,i;e==document&&(e=document.documentElement),d.__&&d.__(t,e),l=(o=typeof n=="function")?null:n&&n.__k||e.__k,_=[],i=[],V(e,t=(!o&&n||e).__k=x(F,null,[t]),l||L,L,e.namespaceURI,!o&&n?[n]:l?null:e.firstChild?O.call(e.childNodes):null,_,!o&&n?n:l?l.__e:e.firstChild,o,i),ue(_,t,i)}function ae(t,e){W(t,e,ae)}function fe(t,e,n){var o,l,_,i,s=k({},t.props);for(_ in t.type&&t.type.defaultProps&&(i=t.type.defaultProps),e)_=="key"?o=e[_]:_=="ref"?l=e[_]:s[_]=e[_]===void 0&&i!=null?i[_]:e[_];return arguments.length>2&&(s.children=arguments.length>3?O.call(arguments,2):n),$(t.type,s,o||t.key,l||t.ref,null)}O=oe.slice,d={__e:function(t,e,n,o){for(var l,_,i;e=e.__;)if((l=e.__c)&&!l.__)try{if((_=l.constructor)&&_.getDerivedStateFromError!=null&&(l.setState(_.getDerivedStateFromError(t)),i=l.__d),l.componentDidCatch!=null&&(l.componentDidCatch(t,o||{}),i=l.__d),i)return l.__E=l}catch(s){t=s}throw t}},te=0,j.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=k({},this.state),typeof t=="function"&&(t=t(k({},n),this.props)),t&&k(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),X(this))},j.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),X(this))},j.prototype.render=F,C=[],ne=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,_e=function(t,e){return t.__v.__b-e.__v.__b},N.__r=0,re=/(PointerCapture)$|Capture$/i,z=0,R=Z(!1),B=Z(!0);var we=0;function Ce(t,e,n,o,l,_){e||(e={});var i,s,c=e;if("ref"in c)for(s in c={},e)s=="ref"?i=e[s]:c[s]=e[s];var u={type:t,props:c,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--we,__i:-1,__u:0,__source:l,__self:_};return d.vnode&&d.vnode(u),u}function J(){return(J=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}).apply(this,arguments)}var xe=["context","children"];function Pe(t){this.getChildContext=function(){return t.context};var e=t.children,n=function(o,l){if(o==null)return{};var _,i,s={},c=Object.keys(o);for(i=0;i<c.length;i++)l.indexOf(_=c[i])>=0||(s[_]=o[_]);return s}(t,xe);return fe(e,n)}function Se(){var t=new CustomEvent("_preact",{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(t),this._vdom=x(Pe,J({},this._props,{context:t.detail.context}),function e(n,o){if(n.nodeType===3)return n.data;if(n.nodeType!==1)return null;var l=[],_={},i=0,s=n.attributes,c=n.childNodes;for(i=s.length;i--;)s[i].name!=="slot"&&(_[s[i].name]=s[i].value,_[he(s[i].name)]=s[i].value);for(i=c.length;i--;){var u=e(c[i],null),a=c[i].slot;a?_[a]=x(ee,{name:a},u):l[i]=u}var r=o?x(ee,null,l):l;return x(o||n.nodeName.toLowerCase(),_,r)}(this,this._vdomComponent)),(this.hasAttribute("hydrate")?ae:W)(this._vdom,this._root)}function he(t){return t.replace(/-(\w)/g,function(e,n){return n?n.toUpperCase():""})}function Te(t,e,n){if(this._vdom){var o={};o[t]=n=n??void 0,o[he(t)]=n,this._vdom=fe(this._vdom,o),W(this._vdom,this._root)}}function Ee(){W(this._vdom=null,this._root)}function ee(t,e){var n=this;return x("slot",J({},t,{ref:function(o){o?(n.ref=o,n._listener||(n._listener=function(l){l.stopPropagation(),l.detail.context=e},o.addEventListener("_preact",n._listener))):n.ref.removeEventListener("_preact",n._listener)}}))}function Me(t,e,n,o){function l(){var _=Reflect.construct(HTMLElement,[],l);return _._vdomComponent=t,_._root=_,_}return(l.prototype=Object.create(HTMLElement.prototype)).constructor=l,l.prototype.connectedCallback=Se,l.prototype.attributeChangedCallback=Te,l.prototype.disconnectedCallback=Ee,n=n||t.observedAttributes||Object.keys(t.propTypes||{}),l.observedAttributes=n,n.forEach(function(_){Object.defineProperty(l.prototype,_,{get:function(){return this._vdom.props[_]},set:function(i){this._vdom?this.attributeChangedCallback(_,null,i):(this._props||(this._props={}),this._props[_]=i,this.connectedCallback());var s=typeof i;i!=null&&s!=="string"&&s!=="boolean"&&s!=="number"||this.setAttribute(_,i)}})}),customElements.define(e,l)}const $e=({name:t="World"})=>Ce("p",{children:["Hello, ",t,"!"]});Me($e,"x-greeting",["name"]);const Le=["x-greeting"];exports.components=Le;exports.npmTest=de;exports.printCurrentTime=ve;
package/dist/best-unit.js CHANGED
@@ -1,35 +1,348 @@
1
- function a() {
1
+ function $e() {
2
2
  console.log("npm package test!!!");
3
3
  }
4
- function v() {
4
+ function Le() {
5
5
  console.log("Current time:", (/* @__PURE__ */ new Date()).toISOString());
6
6
  }
7
- var i;
8
- function p(r) {
9
- return r.children;
10
- }
11
- i = { __e: function(r, o, l, f) {
12
- for (var e, c, t; o = o.__; ) if ((e = o.__c) && !e.__) try {
13
- if ((c = e.constructor) && c.getDerivedStateFromError != null && (e.setState(c.getDerivedStateFromError(r)), t = e.__d), e.componentDidCatch != null && (e.componentDidCatch(r, f || {}), t = e.__d), t) return e.__E = e;
14
- } catch (n) {
15
- r = n;
16
- }
17
- throw r;
18
- } }, typeof Promise == "function" && Promise.prototype.then.bind(Promise.resolve());
19
- var s = 0;
20
- function u(r, o, l, f, e, c) {
21
- o || (o = {});
22
- var t, n, _ = o;
23
- if ("ref" in _) for (n in _ = {}, o) n == "ref" ? t = o[n] : _[n] = o[n];
24
- var d = { type: r, props: _, key: l, ref: t, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --s, __i: -1, __u: 0, __source: e, __self: c };
25
- if (typeof r == "function" && (t = r.defaultProps)) for (n in t) _[n] === void 0 && (_[n] = t[n]);
26
- return i.vnode && i.vnode(d), d;
27
- }
28
- function m() {
29
- return /* @__PURE__ */ u(p, { children: /* @__PURE__ */ u("div", { children: /* @__PURE__ */ u("h1", { children: "Hello World" }) }) });
7
+ var D, d, te, x, Q, ne, _e, re, z, R, B, M = {}, oe = [], de = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, H = Array.isArray;
8
+ function k(t, e) {
9
+ for (var n in e) t[n] = e[n];
10
+ return t;
30
11
  }
12
+ function G(t) {
13
+ t && t.parentNode && t.parentNode.removeChild(t);
14
+ }
15
+ function C(t, e, n) {
16
+ var o, l, _, i = {};
17
+ for (_ in e) _ == "key" ? o = e[_] : _ == "ref" ? l = e[_] : i[_] = e[_];
18
+ if (arguments.length > 2 && (i.children = arguments.length > 3 ? D.call(arguments, 2) : n), typeof t == "function" && t.defaultProps != null) for (_ in t.defaultProps) i[_] === void 0 && (i[_] = t.defaultProps[_]);
19
+ return L(t, i, o, l, null);
20
+ }
21
+ function L(t, e, n, o, l) {
22
+ var _ = { type: t, props: e, key: n, ref: o, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: l ?? ++te, __i: -1, __u: 0 };
23
+ return l == null && d.vnode != null && d.vnode(_), _;
24
+ }
25
+ function F(t) {
26
+ return t.children;
27
+ }
28
+ function j(t, e) {
29
+ this.props = t, this.context = e;
30
+ }
31
+ function P(t, e) {
32
+ if (e == null) return t.__ ? P(t.__, t.__i + 1) : null;
33
+ for (var n; e < t.__k.length; e++) if ((n = t.__k[e]) != null && n.__e != null) return n.__e;
34
+ return typeof t.type == "function" ? P(t) : null;
35
+ }
36
+ function le(t) {
37
+ var e, n;
38
+ if ((t = t.__) != null && t.__c != null) {
39
+ for (t.__e = t.__c.base = null, e = 0; e < t.__k.length; e++) if ((n = t.__k[e]) != null && n.__e != null) {
40
+ t.__e = t.__c.base = n.__e;
41
+ break;
42
+ }
43
+ return le(t);
44
+ }
45
+ }
46
+ function X(t) {
47
+ (!t.__d && (t.__d = !0) && x.push(t) && !N.__r++ || Q != d.debounceRendering) && ((Q = d.debounceRendering) || ne)(N);
48
+ }
49
+ function N() {
50
+ for (var t, e, n, o, l, _, i, s = 1; x.length; ) x.length > s && x.sort(_e), t = x.shift(), s = x.length, t.__d && (n = void 0, l = (o = (e = t).__v).__e, _ = [], i = [], e.__P && ((n = k({}, o)).__v = o.__v + 1, d.vnode && d.vnode(n), V(e.__P, n, o, e.__n, e.__P.namespaceURI, 32 & o.__u ? [l] : null, _, l ?? P(o), !!(32 & o.__u), i), n.__v = o.__v, n.__.__k[n.__i] = n, ue(_, n, i), n.__e != l && le(n)));
51
+ N.__r = 0;
52
+ }
53
+ function ie(t, e, n, o, l, _, i, s, c, u, a) {
54
+ var r, v, p, m, g, y, f = o && o.__k || oe, h = e.length;
55
+ for (c = ve(n, e, f, c, h), r = 0; r < h; r++) (p = n.__k[r]) != null && (v = p.__i == -1 ? M : f[p.__i] || M, p.__i = r, y = V(t, p, v, l, _, i, s, c, u, a), m = p.__e, p.ref && v.ref != p.ref && (v.ref && q(v.ref, null, p), a.push(p.ref, p.__c || m, p)), g == null && m != null && (g = m), 4 & p.__u || v.__k === p.__k ? c = se(p, c, t) : typeof p.type == "function" && y !== void 0 ? c = y : m && (c = m.nextSibling), p.__u &= -7);
56
+ return n.__e = g, c;
57
+ }
58
+ function ve(t, e, n, o, l) {
59
+ var _, i, s, c, u, a = n.length, r = a, v = 0;
60
+ for (t.__k = new Array(l), _ = 0; _ < l; _++) (i = e[_]) != null && typeof i != "boolean" && typeof i != "function" ? (c = _ + v, (i = t.__k[_] = typeof i == "string" || typeof i == "number" || typeof i == "bigint" || i.constructor == String ? L(null, i, null, null, null) : H(i) ? L(F, { children: i }, null, null, null) : i.constructor == null && i.__b > 0 ? L(i.type, i.props, i.key, i.ref ? i.ref : null, i.__v) : i).__ = t, i.__b = t.__b + 1, s = null, (u = i.__i = me(i, n, c, r)) != -1 && (r--, (s = n[u]) && (s.__u |= 2)), s == null || s.__v == null ? (u == -1 && (l > a ? v-- : l < a && v++), typeof i.type != "function" && (i.__u |= 4)) : u != c && (u == c - 1 ? v-- : u == c + 1 ? v++ : (u > c ? v-- : v++, i.__u |= 4))) : t.__k[_] = null;
61
+ if (r) for (_ = 0; _ < a; _++) (s = n[_]) != null && (2 & s.__u) == 0 && (s.__e == o && (o = P(s)), pe(s, s));
62
+ return o;
63
+ }
64
+ function se(t, e, n) {
65
+ var o, l;
66
+ if (typeof t.type == "function") {
67
+ for (o = t.__k, l = 0; o && l < o.length; l++) o[l] && (o[l].__ = t, e = se(o[l], e, n));
68
+ return e;
69
+ }
70
+ t.__e != e && (e && t.type && !n.contains(e) && (e = P(t)), n.insertBefore(t.__e, e || null), e = t.__e);
71
+ do
72
+ e = e && e.nextSibling;
73
+ while (e != null && e.nodeType == 8);
74
+ return e;
75
+ }
76
+ function me(t, e, n, o) {
77
+ var l, _, i = t.key, s = t.type, c = e[n];
78
+ if (c === null && t.key == null || c && i == c.key && s == c.type && (2 & c.__u) == 0) return n;
79
+ if (o > (c != null && (2 & c.__u) == 0 ? 1 : 0)) for (l = n - 1, _ = n + 1; l >= 0 || _ < e.length; ) {
80
+ if (l >= 0) {
81
+ if ((c = e[l]) && (2 & c.__u) == 0 && i == c.key && s == c.type) return l;
82
+ l--;
83
+ }
84
+ if (_ < e.length) {
85
+ if ((c = e[_]) && (2 & c.__u) == 0 && i == c.key && s == c.type) return _;
86
+ _++;
87
+ }
88
+ }
89
+ return -1;
90
+ }
91
+ function Y(t, e, n) {
92
+ e[0] == "-" ? t.setProperty(e, n ?? "") : t[e] = n == null ? "" : typeof n != "number" || de.test(e) ? n : n + "px";
93
+ }
94
+ function A(t, e, n, o, l) {
95
+ var _, i;
96
+ e: if (e == "style") if (typeof n == "string") t.style.cssText = n;
97
+ else {
98
+ if (typeof o == "string" && (t.style.cssText = o = ""), o) for (e in o) n && e in n || Y(t.style, e, "");
99
+ if (n) for (e in n) o && n[e] == o[e] || Y(t.style, e, n[e]);
100
+ }
101
+ else if (e[0] == "o" && e[1] == "n") _ = e != (e = e.replace(re, "$1")), i = e.toLowerCase(), e = i in t || e == "onFocusOut" || e == "onFocusIn" ? i.slice(2) : e.slice(2), t.l || (t.l = {}), t.l[e + _] = n, n ? o ? n.u = o.u : (n.u = z, t.addEventListener(e, _ ? B : R, _)) : t.removeEventListener(e, _ ? B : R, _);
102
+ else {
103
+ if (l == "http://www.w3.org/2000/svg") e = e.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
104
+ else if (e != "width" && e != "height" && e != "href" && e != "list" && e != "form" && e != "tabIndex" && e != "download" && e != "rowSpan" && e != "colSpan" && e != "role" && e != "popover" && e in t) try {
105
+ t[e] = n ?? "";
106
+ break e;
107
+ } catch {
108
+ }
109
+ typeof n == "function" || (n == null || n === !1 && e[4] != "-" ? t.removeAttribute(e) : t.setAttribute(e, e == "popover" && n == 1 ? "" : n));
110
+ }
111
+ }
112
+ function Z(t) {
113
+ return function(e) {
114
+ if (this.l) {
115
+ var n = this.l[e.type + t];
116
+ if (e.t == null) e.t = z++;
117
+ else if (e.t < n.u) return;
118
+ return n(d.event ? d.event(e) : e);
119
+ }
120
+ };
121
+ }
122
+ function V(t, e, n, o, l, _, i, s, c, u) {
123
+ var a, r, v, p, m, g, y, f, h, S, w, O, T, K, U, E, I, b = e.type;
124
+ if (e.constructor != null) return null;
125
+ 128 & n.__u && (c = !!(32 & n.__u), _ = [s = e.__e = n.__e]), (a = d.__b) && a(e);
126
+ e: if (typeof b == "function") try {
127
+ if (f = e.props, h = "prototype" in b && b.prototype.render, S = (a = b.contextType) && o[a.__c], w = a ? S ? S.props.value : a.__ : o, n.__c ? y = (r = e.__c = n.__c).__ = r.__E : (h ? e.__c = r = new b(f, w) : (e.__c = r = new j(f, w), r.constructor = b, r.render = ge), S && S.sub(r), r.props = f, r.state || (r.state = {}), r.context = w, r.__n = o, v = r.__d = !0, r.__h = [], r._sb = []), h && r.__s == null && (r.__s = r.state), h && b.getDerivedStateFromProps != null && (r.__s == r.state && (r.__s = k({}, r.__s)), k(r.__s, b.getDerivedStateFromProps(f, r.__s))), p = r.props, m = r.state, r.__v = e, v) h && b.getDerivedStateFromProps == null && r.componentWillMount != null && r.componentWillMount(), h && r.componentDidMount != null && r.__h.push(r.componentDidMount);
128
+ else {
129
+ if (h && b.getDerivedStateFromProps == null && f !== p && r.componentWillReceiveProps != null && r.componentWillReceiveProps(f, w), !r.__e && r.shouldComponentUpdate != null && r.shouldComponentUpdate(f, r.__s, w) === !1 || e.__v == n.__v) {
130
+ for (e.__v != n.__v && (r.props = f, r.state = r.__s, r.__d = !1), e.__e = n.__e, e.__k = n.__k, e.__k.some(function($) {
131
+ $ && ($.__ = e);
132
+ }), O = 0; O < r._sb.length; O++) r.__h.push(r._sb[O]);
133
+ r._sb = [], r.__h.length && i.push(r);
134
+ break e;
135
+ }
136
+ r.componentWillUpdate != null && r.componentWillUpdate(f, r.__s, w), h && r.componentDidUpdate != null && r.__h.push(function() {
137
+ r.componentDidUpdate(p, m, g);
138
+ });
139
+ }
140
+ if (r.context = w, r.props = f, r.__P = t, r.__e = !1, T = d.__r, K = 0, h) {
141
+ for (r.state = r.__s, r.__d = !1, T && T(e), a = r.render(r.props, r.state, r.context), U = 0; U < r._sb.length; U++) r.__h.push(r._sb[U]);
142
+ r._sb = [];
143
+ } else do
144
+ r.__d = !1, T && T(e), a = r.render(r.props, r.state, r.context), r.state = r.__s;
145
+ while (r.__d && ++K < 25);
146
+ r.state = r.__s, r.getChildContext != null && (o = k(k({}, o), r.getChildContext())), h && !v && r.getSnapshotBeforeUpdate != null && (g = r.getSnapshotBeforeUpdate(p, m)), E = a, a != null && a.type === F && a.key == null && (E = ce(a.props.children)), s = ie(t, H(E) ? E : [E], e, n, o, l, _, i, s, c, u), r.base = e.__e, e.__u &= -161, r.__h.length && i.push(r), y && (r.__E = r.__ = null);
147
+ } catch ($) {
148
+ if (e.__v = null, c || _ != null) if ($.then) {
149
+ for (e.__u |= c ? 160 : 128; s && s.nodeType == 8 && s.nextSibling; ) s = s.nextSibling;
150
+ _[_.indexOf(s)] = null, e.__e = s;
151
+ } else for (I = _.length; I--; ) G(_[I]);
152
+ else e.__e = n.__e, e.__k = n.__k;
153
+ d.__e($, e, n);
154
+ }
155
+ else _ == null && e.__v == n.__v ? (e.__k = n.__k, e.__e = n.__e) : s = e.__e = ye(n.__e, e, n, o, l, _, i, c, u);
156
+ return (a = d.diffed) && a(e), 128 & e.__u ? void 0 : s;
157
+ }
158
+ function ue(t, e, n) {
159
+ for (var o = 0; o < n.length; o++) q(n[o], n[++o], n[++o]);
160
+ d.__c && d.__c(e, t), t.some(function(l) {
161
+ try {
162
+ t = l.__h, l.__h = [], t.some(function(_) {
163
+ _.call(l);
164
+ });
165
+ } catch (_) {
166
+ d.__e(_, l.__v);
167
+ }
168
+ });
169
+ }
170
+ function ce(t) {
171
+ return typeof t != "object" || t == null || t.__b && t.__b > 0 ? t : H(t) ? t.map(ce) : k({}, t);
172
+ }
173
+ function ye(t, e, n, o, l, _, i, s, c) {
174
+ var u, a, r, v, p, m, g, y = n.props, f = e.props, h = e.type;
175
+ if (h == "svg" ? l = "http://www.w3.org/2000/svg" : h == "math" ? l = "http://www.w3.org/1998/Math/MathML" : l || (l = "http://www.w3.org/1999/xhtml"), _ != null) {
176
+ for (u = 0; u < _.length; u++) if ((p = _[u]) && "setAttribute" in p == !!h && (h ? p.localName == h : p.nodeType == 3)) {
177
+ t = p, _[u] = null;
178
+ break;
179
+ }
180
+ }
181
+ if (t == null) {
182
+ if (h == null) return document.createTextNode(f);
183
+ t = document.createElementNS(l, h, f.is && f), s && (d.__m && d.__m(e, _), s = !1), _ = null;
184
+ }
185
+ if (h == null) y === f || s && t.data == f || (t.data = f);
186
+ else {
187
+ if (_ = _ && D.call(t.childNodes), y = n.props || M, !s && _ != null) for (y = {}, u = 0; u < t.attributes.length; u++) y[(p = t.attributes[u]).name] = p.value;
188
+ for (u in y) if (p = y[u], u != "children") {
189
+ if (u == "dangerouslySetInnerHTML") r = p;
190
+ else if (!(u in f)) {
191
+ if (u == "value" && "defaultValue" in f || u == "checked" && "defaultChecked" in f) continue;
192
+ A(t, u, null, p, l);
193
+ }
194
+ }
195
+ for (u in f) p = f[u], u == "children" ? v = p : u == "dangerouslySetInnerHTML" ? a = p : u == "value" ? m = p : u == "checked" ? g = p : s && typeof p != "function" || y[u] === p || A(t, u, p, y[u], l);
196
+ if (a) s || r && (a.__html == r.__html || a.__html == t.innerHTML) || (t.innerHTML = a.__html), e.__k = [];
197
+ else if (r && (t.innerHTML = ""), ie(e.type == "template" ? t.content : t, H(v) ? v : [v], e, n, o, h == "foreignObject" ? "http://www.w3.org/1999/xhtml" : l, _, i, _ ? _[0] : n.__k && P(n, 0), s, c), _ != null) for (u = _.length; u--; ) G(_[u]);
198
+ s || (u = "value", h == "progress" && m == null ? t.removeAttribute("value") : m != null && (m !== t[u] || h == "progress" && !m || h == "option" && m != y[u]) && A(t, u, m, y[u], l), u = "checked", g != null && g != t[u] && A(t, u, g, y[u], l));
199
+ }
200
+ return t;
201
+ }
202
+ function q(t, e, n) {
203
+ try {
204
+ if (typeof t == "function") {
205
+ var o = typeof t.__u == "function";
206
+ o && t.__u(), o && e == null || (t.__u = t(e));
207
+ } else t.current = e;
208
+ } catch (l) {
209
+ d.__e(l, n);
210
+ }
211
+ }
212
+ function pe(t, e, n) {
213
+ var o, l;
214
+ if (d.unmount && d.unmount(t), (o = t.ref) && (o.current && o.current != t.__e || q(o, null, e)), (o = t.__c) != null) {
215
+ if (o.componentWillUnmount) try {
216
+ o.componentWillUnmount();
217
+ } catch (_) {
218
+ d.__e(_, e);
219
+ }
220
+ o.base = o.__P = null;
221
+ }
222
+ if (o = t.__k) for (l = 0; l < o.length; l++) o[l] && pe(o[l], e, n || typeof t.type != "function");
223
+ n || G(t.__e), t.__c = t.__ = t.__e = void 0;
224
+ }
225
+ function ge(t, e, n) {
226
+ return this.constructor(t, n);
227
+ }
228
+ function W(t, e, n) {
229
+ var o, l, _, i;
230
+ e == document && (e = document.documentElement), d.__ && d.__(t, e), l = (o = typeof n == "function") ? null : n && n.__k || e.__k, _ = [], i = [], V(e, t = (!o && n || e).__k = C(F, null, [t]), l || M, M, e.namespaceURI, !o && n ? [n] : l ? null : e.firstChild ? D.call(e.childNodes) : null, _, !o && n ? n : l ? l.__e : e.firstChild, o, i), ue(_, t, i);
231
+ }
232
+ function ae(t, e) {
233
+ W(t, e, ae);
234
+ }
235
+ function fe(t, e, n) {
236
+ var o, l, _, i, s = k({}, t.props);
237
+ for (_ in t.type && t.type.defaultProps && (i = t.type.defaultProps), e) _ == "key" ? o = e[_] : _ == "ref" ? l = e[_] : s[_] = e[_] === void 0 && i != null ? i[_] : e[_];
238
+ return arguments.length > 2 && (s.children = arguments.length > 3 ? D.call(arguments, 2) : n), L(t.type, s, o || t.key, l || t.ref, null);
239
+ }
240
+ D = oe.slice, d = { __e: function(t, e, n, o) {
241
+ for (var l, _, i; e = e.__; ) if ((l = e.__c) && !l.__) try {
242
+ if ((_ = l.constructor) && _.getDerivedStateFromError != null && (l.setState(_.getDerivedStateFromError(t)), i = l.__d), l.componentDidCatch != null && (l.componentDidCatch(t, o || {}), i = l.__d), i) return l.__E = l;
243
+ } catch (s) {
244
+ t = s;
245
+ }
246
+ throw t;
247
+ } }, te = 0, j.prototype.setState = function(t, e) {
248
+ var n;
249
+ n = this.__s != null && this.__s != this.state ? this.__s : this.__s = k({}, this.state), typeof t == "function" && (t = t(k({}, n), this.props)), t && k(n, t), t != null && this.__v && (e && this._sb.push(e), X(this));
250
+ }, j.prototype.forceUpdate = function(t) {
251
+ this.__v && (this.__e = !0, t && this.__h.push(t), X(this));
252
+ }, j.prototype.render = F, x = [], ne = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, _e = function(t, e) {
253
+ return t.__v.__b - e.__v.__b;
254
+ }, N.__r = 0, re = /(PointerCapture)$|Capture$/i, z = 0, R = Z(!1), B = Z(!0);
255
+ var be = 0;
256
+ function ke(t, e, n, o, l, _) {
257
+ e || (e = {});
258
+ var i, s, c = e;
259
+ if ("ref" in c) for (s in c = {}, e) s == "ref" ? i = e[s] : c[s] = e[s];
260
+ var u = { type: t, props: c, key: n, ref: i, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --be, __i: -1, __u: 0, __source: l, __self: _ };
261
+ return d.vnode && d.vnode(u), u;
262
+ }
263
+ function J() {
264
+ return (J = Object.assign ? Object.assign.bind() : function(t) {
265
+ for (var e = 1; e < arguments.length; e++) {
266
+ var n = arguments[e];
267
+ for (var o in n) Object.prototype.hasOwnProperty.call(n, o) && (t[o] = n[o]);
268
+ }
269
+ return t;
270
+ }).apply(this, arguments);
271
+ }
272
+ var we = ["context", "children"];
273
+ function xe(t) {
274
+ this.getChildContext = function() {
275
+ return t.context;
276
+ };
277
+ var e = t.children, n = function(o, l) {
278
+ if (o == null) return {};
279
+ var _, i, s = {}, c = Object.keys(o);
280
+ for (i = 0; i < c.length; i++) l.indexOf(_ = c[i]) >= 0 || (s[_] = o[_]);
281
+ return s;
282
+ }(t, we);
283
+ return fe(e, n);
284
+ }
285
+ function Ce() {
286
+ var t = new CustomEvent("_preact", { detail: {}, bubbles: !0, cancelable: !0 });
287
+ this.dispatchEvent(t), this._vdom = C(xe, J({}, this._props, { context: t.detail.context }), function e(n, o) {
288
+ if (n.nodeType === 3) return n.data;
289
+ if (n.nodeType !== 1) return null;
290
+ var l = [], _ = {}, i = 0, s = n.attributes, c = n.childNodes;
291
+ for (i = s.length; i--; ) s[i].name !== "slot" && (_[s[i].name] = s[i].value, _[he(s[i].name)] = s[i].value);
292
+ for (i = c.length; i--; ) {
293
+ var u = e(c[i], null), a = c[i].slot;
294
+ a ? _[a] = C(ee, { name: a }, u) : l[i] = u;
295
+ }
296
+ var r = o ? C(ee, null, l) : l;
297
+ return C(o || n.nodeName.toLowerCase(), _, r);
298
+ }(this, this._vdomComponent)), (this.hasAttribute("hydrate") ? ae : W)(this._vdom, this._root);
299
+ }
300
+ function he(t) {
301
+ return t.replace(/-(\w)/g, function(e, n) {
302
+ return n ? n.toUpperCase() : "";
303
+ });
304
+ }
305
+ function Pe(t, e, n) {
306
+ if (this._vdom) {
307
+ var o = {};
308
+ o[t] = n = n ?? void 0, o[he(t)] = n, this._vdom = fe(this._vdom, o), W(this._vdom, this._root);
309
+ }
310
+ }
311
+ function Se() {
312
+ W(this._vdom = null, this._root);
313
+ }
314
+ function ee(t, e) {
315
+ var n = this;
316
+ return C("slot", J({}, t, { ref: function(o) {
317
+ o ? (n.ref = o, n._listener || (n._listener = function(l) {
318
+ l.stopPropagation(), l.detail.context = e;
319
+ }, o.addEventListener("_preact", n._listener))) : n.ref.removeEventListener("_preact", n._listener);
320
+ } }));
321
+ }
322
+ function Te(t, e, n, o) {
323
+ function l() {
324
+ var _ = Reflect.construct(HTMLElement, [], l);
325
+ return _._vdomComponent = t, _._root = _, _;
326
+ }
327
+ return (l.prototype = Object.create(HTMLElement.prototype)).constructor = l, l.prototype.connectedCallback = Ce, l.prototype.attributeChangedCallback = Pe, l.prototype.disconnectedCallback = Se, n = n || t.observedAttributes || Object.keys(t.propTypes || {}), l.observedAttributes = n, n.forEach(function(_) {
328
+ Object.defineProperty(l.prototype, _, { get: function() {
329
+ return this._vdom.props[_];
330
+ }, set: function(i) {
331
+ this._vdom ? this.attributeChangedCallback(_, null, i) : (this._props || (this._props = {}), this._props[_] = i, this.connectedCallback());
332
+ var s = typeof i;
333
+ i != null && s !== "string" && s !== "boolean" && s !== "number" || this.setAttribute(_, i);
334
+ } });
335
+ }), customElements.define(e, l);
336
+ }
337
+ const Ee = ({ name: t = "World" }) => /* @__PURE__ */ ke("p", { children: [
338
+ "Hello, ",
339
+ t,
340
+ "!"
341
+ ] });
342
+ Te(Ee, "x-greeting", ["name"]);
343
+ const Me = ["x-greeting"];
31
344
  export {
32
- m as App,
33
- a as npmTest,
34
- v as printCurrentTime
345
+ Me as components,
346
+ $e as npmTest,
347
+ Le as printCurrentTime
35
348
  };
@@ -0,0 +1,14 @@
1
+ export declare function npmTest(): void;
2
+
3
+ export declare function printCurrentTime(): void;
4
+
5
+ declare namespace JSX {
6
+ interface IntrinsicElements {
7
+ 'x-greeting': {
8
+ name?: string; // 组件支持的属性
9
+ [key: string]: any;
10
+ };
11
+ }
12
+ }
13
+
14
+ /// <reference path="./preact-custom-element.d.ts" />
@@ -0,0 +1 @@
1
+ declare module 'preact-custom-element'
package/package.json CHANGED
@@ -1,18 +1,20 @@
1
1
  {
2
2
  "name": "best-unit",
3
3
  "private": false,
4
- "version": "0.0.5",
4
+ "version": "0.0.6",
5
5
  "type": "module",
6
6
  "main": "dist/best-unit.cjs",
7
7
  "module": "dist/best-unit.js",
8
- "types": "dist/best-unit.d.ts",
8
+ "types": "dist/types/index.d.ts",
9
9
  "scripts": {
10
10
  "dev": "vite",
11
- "build": "tsc -b && vite build",
11
+ "build": "tsc -b && vite build && cp -r src/types dist/types",
12
+ "prepublishOnly": "npm version patch --no-git-tag-version",
12
13
  "preview": "vite preview"
13
14
  },
14
15
  "dependencies": {
15
- "preact": "^10.26.9"
16
+ "preact": "^10.26.9",
17
+ "preact-custom-element": "^4.3.0"
16
18
  },
17
19
  "devDependencies": {
18
20
  "@preact/preset-vite": "^2.10.2",
package/src/app.tsx CHANGED
@@ -1,10 +1,9 @@
1
+ import register from 'preact-custom-element';
1
2
 
2
- export function App() {
3
- return (
4
- <>
5
- <div>
6
- <h1>Hello World</h1>
7
- </div>
8
- </>
9
- )
10
- }
3
+ const Greeting = ({ name = 'World' }) => (
4
+ <p>Hello, {name}!</p>
5
+ );
6
+
7
+ register(Greeting, 'x-greeting', ['name'], { shadow: false });
8
+
9
+ export default Greeting;
package/src/main.ts CHANGED
@@ -1,9 +1,10 @@
1
1
 
2
2
  import { npmTest, printCurrentTime } from './index.ts'
3
- import { App } from './app.tsx'
3
+ import './app.tsx'
4
4
 
5
+ // 可选:导出组件列表或版本信息
6
+ export const components = ['x-greeting'];
5
7
  export {
6
8
  npmTest,
7
9
  printCurrentTime,
8
- App
9
10
  }
@@ -0,0 +1,14 @@
1
+ export declare function npmTest(): void;
2
+
3
+ export declare function printCurrentTime(): void;
4
+
5
+ declare namespace JSX {
6
+ interface IntrinsicElements {
7
+ 'x-greeting': {
8
+ name?: string; // 组件支持的属性
9
+ [key: string]: any;
10
+ };
11
+ }
12
+ }
13
+
14
+ /// <reference path="./preact-custom-element.d.ts" />
@@ -0,0 +1 @@
1
+ declare module 'preact-custom-element'
@@ -1,6 +0,0 @@
1
- export declare function npmTest(): void;
2
-
3
- export declare function printCurrentTime(): void;
4
-
5
- import * as Preact from 'preact';
6
- export declare const App: Preact.FC;