sinho 0.3.2 → 0.3.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.
package/README.md CHANGED
@@ -13,7 +13,7 @@ API.
13
13
  ```tsx
14
14
  import { Component, useSignal, defineComponents } from "sinho";
15
15
 
16
- class Counter extends Component("x-counter") {
16
+ class MyCounter extends Component() {
17
17
  render() {
18
18
  const [value, setValue] = useSignal(0);
19
19
 
@@ -29,5 +29,5 @@ class Counter extends Component("x-counter") {
29
29
  }
30
30
  }
31
31
 
32
- defineComponents(Counter);
32
+ defineComponents(MyCounter);
33
33
  ```
package/dist/bundle.d.ts CHANGED
@@ -46,7 +46,6 @@ interface SubscopeOptions {
46
46
  details?: object;
47
47
  }
48
48
  interface Effect {
49
- readonly _fn: Function;
50
49
  _scope: Scope;
51
50
  _pure: boolean;
52
51
  _clean?: Cleanup;
@@ -58,10 +57,9 @@ interface Effect {
58
57
  */
59
58
  type Cleanup = (() => void) | void | undefined | null;
60
59
  interface Scope<out T = {}> {
61
- _fn?: Function;
62
60
  readonly _parent?: Scope;
63
- _effects: Effect[];
64
- _subscopes: Scope[];
61
+ _effects: Set<Effect>;
62
+ _subscopes: Set<Scope>;
65
63
  _details: T;
66
64
  _run<T>(fn: () => T): T;
67
65
  _cleanup(): void;
@@ -947,7 +945,7 @@ declare abstract class ComponentInner<M extends Metadata> {
947
945
  interface ComponentConstructor<M extends Metadata = {}> {
948
946
  /** @ignore */
949
947
  readonly [componentSym]: {
950
- readonly _tagName: string;
948
+ readonly _tagName: string | null;
951
949
  };
952
950
  readonly observedAttributes: readonly string[];
953
951
  new (): Component<M>;
@@ -980,7 +978,7 @@ type Component<M extends Metadata = {}> = {
980
978
  *
981
979
  * @example
982
980
  * ```tsx
983
- * class MyComponent extends Component("my-component", {
981
+ * class MyComponent extends Component({
984
982
  * myProp: prop<string>("Hello, world!"),
985
983
  * onMyEvent: event(),
986
984
  * }) {
@@ -994,10 +992,10 @@ type Component<M extends Metadata = {}> = {
994
992
  * },
995
993
  * }
996
994
  *
997
- * customElements.define("my-component", MyComponent);
995
+ * defineComponents(MyComponent);
998
996
  * ```
999
997
  */
1000
- declare const Component: ((tagName: string) => ComponentConstructor<{}>) & (<const M extends Metadata>(tagName: string, metadata: M, opts?: ComponentOptions) => ComponentConstructor<M>);
998
+ declare const Component: ((tagName?: string) => ComponentConstructor<{}>) & (<const M extends Metadata>(tagName: string, metadata: M, opts?: ComponentOptions) => ComponentConstructor<M>) & (<const M extends Metadata>(metadata: M, opts?: ComponentOptions) => ComponentConstructor<M>);
1001
999
  /**
1002
1000
  * Determines whether the given value is a component created by
1003
1001
  * extending {@link ComponentConstructor}.
package/dist/bundle.js CHANGED
@@ -1,14 +1,13 @@
1
1
  const createScope = (parent) => {
2
2
  return {
3
3
  _parent: parent,
4
- _effects: [],
5
- _subscopes: [],
4
+ _effects: new Set(),
5
+ _subscopes: new Set(),
6
6
  _details: { ...parent?._details },
7
7
  _run(fn) {
8
8
  const prevScope = currScope;
9
9
  currScope = this;
10
10
  try {
11
- this._fn = fn;
12
11
  return fn();
13
12
  }
14
13
  finally {
@@ -16,18 +15,19 @@ const createScope = (parent) => {
16
15
  }
17
16
  },
18
17
  _cleanup() {
19
- for (let i = this._subscopes.length - 1; i >= 0; i--) {
20
- this._subscopes[i]._cleanup();
21
- }
22
- this._subscopes = [];
23
- for (let i = this._effects.length - 1; i >= 0; i--) {
24
- const effect = this._effects[i];
18
+ [...this._subscopes].forEach((_, i, arr) => {
19
+ const subscope = arr[arr.length - 1 - i];
20
+ subscope._cleanup();
21
+ });
22
+ this._subscopes = new Set();
23
+ [...this._effects].forEach((_, i, arr) => {
24
+ const effect = arr[arr.length - 1 - i];
25
25
  effect._clean?.();
26
26
  effect._run = () => { };
27
27
  effect._deps.forEach((signal) => signal._effects.delete(effect));
28
28
  effect._deps.clear();
29
- }
30
- this._effects = [];
29
+ });
30
+ this._effects = new Set();
31
31
  },
32
32
  };
33
33
  };
@@ -137,7 +137,6 @@ let pureEffectFlag = false;
137
137
  const useEffect = (fn, deps) => {
138
138
  const untracked = !!deps;
139
139
  const effect = {
140
- _fn: fn,
141
140
  _scope: currScope,
142
141
  _pure: pureEffectFlag,
143
142
  _deps: new Set(),
@@ -172,12 +171,12 @@ const useEffect = (fn, deps) => {
172
171
  }
173
172
  },
174
173
  };
175
- currScope._effects.push(effect);
174
+ currScope._effects.add(effect);
176
175
  effect._run();
177
176
  if (!effect._deps.size && !effect._clean) {
178
177
  // Optimization: Destroy effect since there's no cleanup and this effect
179
178
  // won't be called again
180
- currScope._effects.pop();
179
+ currScope._effects.delete(effect);
181
180
  }
182
181
  };
183
182
  /**
@@ -213,15 +212,12 @@ const useSubscope = (fn, opts) => {
213
212
  const scope = createScope(parent);
214
213
  Object.assign(scope._details, opts?.details);
215
214
  try {
216
- parent._subscopes.push(scope);
215
+ parent._subscopes.add(scope);
217
216
  const result = scope._run(fn);
218
217
  return [
219
218
  result,
220
219
  () => {
221
- const index = parent._subscopes.indexOf(scope);
222
- if (index >= 0) {
223
- parent._subscopes.splice(index, 1);
224
- }
220
+ parent._subscopes.delete(scope);
225
221
  scope._cleanup();
226
222
  },
227
223
  ];
@@ -474,7 +470,7 @@ const useMountEffect = (fn, deps) => {
474
470
  *
475
471
  * @example
476
472
  * ```tsx
477
- * class MyComponent extends Component("my-component", {
473
+ * class MyComponent extends Component({
478
474
  * myProp: prop<string>("Hello, world!"),
479
475
  * onMyEvent: event(),
480
476
  * }) {
@@ -488,10 +484,17 @@ const useMountEffect = (fn, deps) => {
488
484
  * },
489
485
  * }
490
486
  *
491
- * customElements.define("my-component", MyComponent);
487
+ * defineComponents(MyComponent);
492
488
  * ```
493
489
  */
494
- const Component = ((tagName, metadata = {}, opts = {}) => {
490
+ const Component = ((tagNameOrMetadata, metadataOrOpts, optsParam) => {
491
+ const tagName = typeof tagNameOrMetadata === "string" ? tagNameOrMetadata : null;
492
+ const metadata = typeof tagNameOrMetadata === "string"
493
+ ? metadataOrOpts
494
+ : tagNameOrMetadata;
495
+ const opts = (typeof tagNameOrMetadata === "string"
496
+ ? optsParam
497
+ : metadataOrOpts) ?? {};
495
498
  // Extract attribute information
496
499
  const observedAttributes = [];
497
500
  const attributePropMap = new Map();
@@ -519,7 +522,7 @@ const Component = ((tagName, metadata = {}, opts = {}) => {
519
522
  // Create base class
520
523
  opts.shadow ??= { mode: "open" };
521
524
  const getRenderParent = (component) => opts.shadow
522
- ? component.shadowRoot ?? component.attachShadow(opts.shadow)
525
+ ? (component.shadowRoot ?? component.attachShadow(opts.shadow))
523
526
  : component;
524
527
  class _Component extends HTMLElement {
525
528
  static [componentSym] = {
@@ -606,7 +609,9 @@ const defineComponents = (...args) => {
606
609
  ? [args[0], args.slice(1)]
607
610
  : ["", args];
608
611
  for (const component of components) {
609
- customElements.define(prefix + component[componentSym]._tagName, component);
612
+ customElements.define(prefix +
613
+ (component[componentSym]._tagName ??
614
+ camelCaseToKebabCase(component.name)), component);
610
615
  }
611
616
  };
612
617
 
@@ -804,7 +809,7 @@ const TagComponent = (tagName, props = {}) => createTemplate(() => {
804
809
  const svg = tagName == "svg" ? true : !!renderer._svg;
805
810
  const node = hydrateElement(renderer._node(() => !svg
806
811
  ? document.createElement(tagName)
807
- : document.createElementNS("http://www.w3.org/2000/svg", tagName)), svg, props, true);
812
+ : document.createElementNS("http://www.w3.org/2000/svg", tagName)), svg && tagName === "foreignObject" ? false : svg, props, true);
808
813
  return [node];
809
814
  });
810
815
 
@@ -1 +1 @@
1
- const t=t=>({t:t,o:[],i:[],l:{...t?.l},u(t){const n=o;o=this;try{return this.h=t,t()}finally{o=n}},_(){for(let t=this.i.length-1;t>=0;t--)this.i[t]._();this.i=[];for(let t=this.o.length-1;t>=0;t--){const n=this.o[t];n.p?.(),n.u=()=>{},n.m.forEach(t=>t.o.delete(n)),n.m.clear()}this.o=[]}});let n,e,o=t(),s=!1;const r=()=>o,c=(t,o)=>{const r=()=>(!s&&n&&(n.m.add(r),r.o.add(n)),r.peek());r.o=new Set,r.peek=()=>t;const c=(n,s)=>{const l={...o,...s};if(l.equals??=(t,n)=>t===n,e){const o="function"==typeof n?n(r.peek()):n;!l?.force&&l.equals(o,r.peek())||(l?.force?t=o:e.v.push(()=>t=o),l?.silent||r.o.forEach(t=>{t.S?e.M.add(t):e.o.add(t)}))}else i(()=>c(n,l))};return[r,c]},i=t=>{if(e)return t();e={v:[],o:new Set,M:new Set};try{const n=t();return l(),n}finally{e=void 0}},l=()=>{for(;e&&e.v.length+e.o.size+e.M.size>0;){e.o.forEach(t=>t.p?.()),e.v.forEach(t=>t()),e.v=[];const t=e.M.values().next().value??e.o.values().next().value;t&&(t.u(),e.M.delete(t),e.o.delete(t))}};let u=!1;const f=(t,e)=>{const r=!!e,c={h:t,k:o,S:u,m:new Set,u(){const o=n,c=s;n=this;try{this.m.forEach(t=>t.o.delete(this)),this.m.clear(),e&&(s=!1,e.forEach(t=>t())),s=r,this.p?.();const n=this.k.u(()=>i(t));this.p=n?()=>{this.k.u(()=>i(n)),this.p=null}:null}finally{n=o,s=c}}};o.o.push(c),c.u(),c.m.size||c.p||o.o.pop()},a=(t,n)=>{const[e,o]=c(void 0,n);let s=!0;u=!0;try{f(()=>{o(t,s?{force:!0}:{}),s=!1})}finally{u=!1}return e},d=(n,s)=>{const r=e;e=void 0;const c=o,i=t(c);Object.assign(i.l,s?.details);try{c.i.push(i);return[i.u(n),()=>{const t=c.i.indexOf(i);t>=0&&c.i.splice(t,1),i._()}]}finally{e=r}},h=(t,n)=>{const[e,o]=c(t,n);return e.set=o,e},_={upgrade:t=>()=>_.get(t),get:t=>"function"==typeof t?t():t,peek(t){const n=s;s=!0;try{return this.get(t)}finally{s=n}}},p=(t={})=>({C:[],N(t){return this.j?.next().value??t()},...t}),y=()=>{const t=r();return t.l.A??=p()},m=(t,n)=>{const e=y(),o=p({...e,...t}),[s,r]=d(n,{details:{A:o}});return f(()=>r),s},w=t=>(t[0]??"").toLowerCase()+t.slice(1).replace(/[A-Z]/g,t=>"-"+t.toLowerCase()),b=t=>t.startsWith("on:")?t.slice(3):w(t.slice(2)),v=Symbol(),g=(t,n)=>({[v]:Math.random().toString(36).slice(2),H:t,L:n}),x=t=>!!t?.[v],S=(t,n,e)=>{n.addEventListener(t[v],t=>{const n=_.get(e);void 0!==n&&(t.stopPropagation(),t.detail(n))})},M=t=>{const n=y();return a(()=>{let e=t.H;return n.T?.dispatchEvent(new CustomEvent(t[v],{detail:t=>e=t,bubbles:!0,composed:!0})),e})};var k;!function(t){t.forEach=(n,e)=>n.forEach(n=>Array.isArray(n)?t.forEach(n,e):e(n)),t.last=(n,e=n.length-1)=>{if(n.length)for(let o=e;o>=0;o--){const e=n[o];if(!Array.isArray(e))return e;const s=t.last(e);if(s)return s}}}(k||(k={}));const C=t=>({build(){const n=t();return n.build?.()??n}}),E=(t,n)=>({O:"p",D:t,...n}),N=(t=CustomEvent)=>({O:"e",I:t}),j=Symbol();let A;const H=(t,n)=>{A?A.push([t,n]):f(t,n)},L=(t,n={},e={})=>{const o=[],s=new Map;for(const t in n){const e=n[t];if("p"==e.O&&e.attribute){"function"==typeof e.attribute&&(e.attribute={transform:e.attribute});const n=e.attribute={name:w(t),static:!1,transform:t=>t,...e.attribute};s.set(n.name,{name:t,meta:e}),n.static||o.push(n.name)}}e.shadow??={mode:"open"};class i extends HTMLElement{static[j]={$:t};static observedAttributes=o;props={};events={};[j]={};constructor(){super();for(const t in n){const e=n[t];if("p"==e.O){const n=x(e.D)?e.D:null,[o,s]=c(n?void 0:e.D);this.props[t]=o,n&&S(n,this,o),Object.defineProperty(this,t,{get:o.peek,set:t=>s(()=>t,{force:!0})})}else if("e"==e.O&&t.startsWith("on")){const n=b(t);this.events[t]=t=>this.dispatchEvent(new e.I(n,t))}}}connectedCallback(){const t=(n=this,e.shadow?n.shadowRoot??n.attachShadow(e.shadow):n);var n;this[j].P=d(()=>m({V:!1,T:this,j:t.childNodes.values()},()=>{this[j].k=r();const n=A;A=[];try{k.forEach(this.render().build(),n=>{t.append(n)}),A.forEach(([t,n])=>f(t,n))}finally{A=n}}))[1]}disconnectedCallback(){this[j].P?.()}attributeChangedCallback(t,n,e){const o=s.get(t);o&&(this[o.name]=null!=e?o.meta.attribute.transform.call(this,e):x(o.meta.D)?void 0:o.meta.D)}}return i},T=t=>!!t?.[j],O=(...t)=>{const[n,e]="string"==typeof t[0]?[t[0],t.slice(1)]:["",t];for(const t of e)customElements.define(n+t[j].$,t)},D=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,I=(t,n,e)=>{"-"==n[0]?t.style.setProperty(n,""+e):t.style[n]=null==e?"":"number"!=typeof e||D.test(n)?""+e:e+"px"},$=(t,n,e,o)=>{const s=null==e||!1===e&&!n.includes("-");if(n.startsWith("prop:"))t[n.slice(5)]=e;else if(n.startsWith("attr:"))n=n.slice(5),s?t.removeAttribute(n):t.setAttribute(n,e);else if(!["innerHTML","outerHTML"].includes(n)){if(!["tabIndex","role",...o?["width","height","href","list","form","download","rowSpan","colSpan"]:[]].includes(n)&&n in t)try{return void(t[n]=e)}catch(t){}"function"==typeof e||(s?t.removeAttribute(n):t.setAttribute(n,e))}},z=({text:t,marker:n})=>C(()=>{const e=y(),o=n&&e.N(()=>document.createComment("")),s=e.N(()=>document.createTextNode(""));return f(()=>{const n=""+(_.get(t)??"");s.textContent!=n&&(s.textContent=n)}),o?[o,s]:[s]}),P=({children:t})=>C(()=>Array.isArray(t)?t.flatMap(t=>P({children:t}).build()):null==t?[]:["object"==typeof t?t.build():z({text:t}).build()]),V=(t,n,e,o)=>{const{ref:s,style:c,children:l,dangerouslySetInnerHTML:u,...a}=e;for(const n in c??{}){const e=c[n];f(()=>{I(t,n,_.get(e))})}for(const n in a){const e=a[n];if(n.startsWith("on")){const o=r(),s=t=>{o.u(()=>i(()=>e(t)))},c=b(n);f(()=>(t.addEventListener(c,s),()=>t.removeEventListener(c,s)))}else f(()=>{$(t,n,_.get(e),o)})}return u&&f(()=>{const n=_.get(u).__html;t.innerHTML!=n&&(t.innerHTML=n)}),s&&f(()=>(s.set(t),()=>s.set(void 0))),null!=e.children&&k.forEach(m({V:n,j:t.childNodes.values()},()=>P({children:e.children}).build()),n=>t.append(n)),t},Z=(t,n={},e)=>(null!=e&&(n.children=e),T(t)?((t,n)=>C(()=>{const e=y().N(()=>new t);return customElements.upgrade(e),V(e,!1,n),[e]}))(t,n):"function"==typeof t?C(()=>t(n)):((t,n={})=>C(()=>{const e=y(),o="svg"==t||!!e.V;return[V(e.N(()=>o?document.createElementNS("http://www.w3.org/2000/svg",t):document.createElement(t)),o,n,!0)]}))(t,n)),q=new Proxy(Z,{get:(t,n)=>(e,o)=>t(n,e,o)}),B=(t,n)=>{const[e,o]=c({Z:[],q:new Map},{force:!0});let s=new Map;return f(()=>{const e=[],r=s,c=((t,n)=>{const e=new Map;for(let o=0;o<t.length;o++){const s=n(t[o],o);if(e.has(s))throw Error(`Duplicate key '${s}'`);e.set(s,o)}return e})(t(),n),i=(t=NaN)=>e.map(t=>"r"==t.B?n=>n<t.F?n:n==t.F?NaN:n-1:"a"==t.B?n=>n<t.F?n:n+1:"m"==t.B?n=>t.G<=n&&n<t.J?n+1:n==t.J?t.G:n:t=>t).reduce((t,n)=>n(t),t);for(const t of r.keys()){const n=i(r.get(t));c.has(t)||e.push({B:"r",K:t,F:n})}for(let o=0;o<t().length;o++){const s=n(t()[o],o),c=i(r.get(s));isNaN(c)?e.push({B:"a",K:s,F:o}):c!=o&&e.push({B:"m",K:s,J:c,G:o})}e.length>0&&o({Z:e,q:c}),s=c}),e},F=t=>C(()=>{const n=y(),e=_.upgrade(t.each??[]),o=n.N(()=>document.createComment("")),s=t.key??((t,n)=>n),r=[o,[]],i=new Map,l=B(e,s),u=t=>k.last(r[1],t-1)??o;return f(()=>{for(const n of l().Z)if("r"==n.B){const{R:t,P:e}=i.get(n.K)??{};e?.(),r[1].splice(n.F,1),k.forEach(t??[],t=>t.parentNode?.removeChild(t)),i.delete(n.K)}else if("a"==n.B){let o;const[,s]=d(()=>{const[s,i]=c(n.F),[a,d]=c(e()[n.F]);f(()=>{0<=s()&&s()<e().length&&d(()=>e()[s()])}),f(()=>{const t=l().q.get(n.K);null!=t&&i(t)}),o=t.children?.(a,s,e).build()??[],r[1].splice(n.F,0,o);let h=u(n.F);k.forEach(o,t=>{h.parentNode?.insertBefore(t,h.nextSibling),h=t})});i.set(n.K,{R:o,P:s})}else if("m"==n.B){const{R:t}=i.get(n.K)??{};r[1].splice(n.J,1),r[1].splice(n.G,0,t??[]);let e=u(n.G);k.forEach(t??[],t=>{e.parentNode?.insertBefore(t,e.nextSibling),e=t})}},[l]),r}),G=t=>(y().C=[],J({condition:t.condition,children:t.children})),J=t=>{const n=y(),e=n.C,o=_.upgrade(t.condition),s=a(()=>e.every(t=>!t())&&o());return n.C=[...e,o],C(()=>m({C:[]},()=>{const e=n.N(()=>document.createComment("")),o=[e,[]],r=a(()=>s()?P({children:t.children}):null);let c=[];return f(()=>{k.forEach(c,t=>t.parentNode?.removeChild(t)),o[1]=[];const[,t]=d(()=>{c=r()?.build()??[],o[1]=c;let t=e;k.forEach(c,n=>{t.parentNode?.insertBefore(n,t.nextSibling),t=n})});return t},[r]),o}))},K=({children:t})=>J({condition:!0,children:t}),Q=({mount:t,children:n})=>C(()=>m({j:void 0},()=>{const e=P({children:n}).build();return f(()=>(k.forEach(e,n=>t.appendChild(n)),()=>{k.forEach(e,t=>t.parentNode?.removeChild(t))}),[]),[]})),R=Symbol(),U=new Map,W=t=>{const n=t.children;if("function"==typeof n){const e=Z("style",{},z({text:n,marker:!1}));return t.light?Q({mount:document.head,children:e}):e}if(n){const o=y(),s=t.light?document:o.T?.shadowRoot??document,r=((t,n,e)=>{if(!U.has(n)){const t=new CSSStyleSheet;t.replaceSync(n),U.set(n,{U:t,W:0})}const o=U.get(n);o.W++,t.has(n)||t.set(n,{U:o.U,W:0});const s=t.get(n);return s.W++,f(()=>()=>{--s.W||(t.delete(n),e()),--o.W||U.delete(n)}),s.U})((e=s,e[R]??=new Map),n,()=>{s.adoptedStyleSheets=s.adoptedStyleSheets.filter(t=>t!=r)});s.adoptedStyleSheets.push(r)}var e;return P({})},X=(t,...n)=>{const e=()=>t.reduce((t,e,o)=>t+e+(_.get(n[o])??""),"");return n.some(t=>"function"==typeof t)?e:e()},Y=(t,n,e)=>(n&&null!=e&&(n.key=e),Z(t,n));export{L as Component,K as Else,J as ElseIf,F as For,P as Fragment,G as If,_ as MaybeSignal,Q as Portal,W as Style,k as TemplateNodes,g as createContext,Z as createElement,X as css,O as defineComponents,N as event,l as flushBatch,q as h,T as isComponent,Y as jsx,Y as jsxDEV,Y as jsxs,E as prop,i as useBatch,M as useContext,H as useEffect,a as useMemo,h as useRef,c as useSignal,d as useSubscope};
1
+ const t=t=>({t:t,o:new Set,i:new Set,l:{...t?.l},u(t){const n=o;o=this;try{return t()}finally{o=n}},h(){[...this.i].forEach((t,n,e)=>{e[e.length-1-n].h()}),this.i=new Set,[...this.o].forEach((t,n,e)=>{const o=e[e.length-1-n];o.p?.(),o.u=()=>{},o._.forEach(t=>t.o.delete(o)),o._.clear()}),this.o=new Set}});let n,e,o=t(),s=!1;const r=()=>o,c=(t,o)=>{const r=()=>(!s&&n&&(n._.add(r),r.o.add(n)),r.peek());r.o=new Set,r.peek=()=>t;const c=(n,s)=>{const l={...o,...s};if(l.equals??=(t,n)=>t===n,e){const o="function"==typeof n?n(r.peek()):n;!l?.force&&l.equals(o,r.peek())||(l?.force?t=o:e.m.push(()=>t=o),l?.silent||r.o.forEach(t=>{t.v?e.S.add(t):e.o.add(t)}))}else i(()=>c(n,l))};return[r,c]},i=t=>{if(e)return t();e={m:[],o:new Set,S:new Set};try{const n=t();return l(),n}finally{e=void 0}},l=()=>{for(;e&&e.m.length+e.o.size+e.S.size>0;){e.o.forEach(t=>t.p?.()),e.m.forEach(t=>t()),e.m=[];const t=e.S.values().next().value??e.o.values().next().value;t&&(t.u(),e.S.delete(t),e.o.delete(t))}};let u=!1;const f=(t,e)=>{const r=!!e,c={M:o,v:u,_:new Set,u(){const o=n,c=s;n=this;try{this._.forEach(t=>t.o.delete(this)),this._.clear(),e&&(s=!1,e.forEach(t=>t())),s=r,this.p?.();const n=this.M.u(()=>i(t));this.p=n?()=>{this.M.u(()=>i(n)),this.p=null}:null}finally{n=o,s=c}}};o.o.add(c),c.u(),c._.size||c.p||o.o.delete(c)},a=(t,n)=>{const[e,o]=c(void 0,n);let s=!0;u=!0;try{f(()=>{o(t,s?{force:!0}:{}),s=!1})}finally{u=!1}return e},d=(n,s)=>{const r=e;e=void 0;const c=o,i=t(c);Object.assign(i.l,s?.details);try{c.i.add(i);return[i.u(n),()=>{c.i.delete(i),i.h()}]}finally{e=r}},h=(t,n)=>{const[e,o]=c(t,n);return e.set=o,e},p={upgrade:t=>()=>p.get(t),get:t=>"function"==typeof t?t():t,peek(t){const n=s;s=!0;try{return this.get(t)}finally{s=n}}},_=(t={})=>({k:[],C(t){return this.N?.next().value??t()},...t}),y=()=>{const t=r();return t.l.j??=_()},m=(t,n)=>{const e=y(),o=_({...e,...t}),[s,r]=d(n,{details:{j:o}});return f(()=>r),s},w=t=>(t[0]??"").toLowerCase()+t.slice(1).replace(/[A-Z]/g,t=>"-"+t.toLowerCase()),b=t=>t.startsWith("on:")?t.slice(3):w(t.slice(2)),g=Symbol(),v=(t,n)=>({[g]:Math.random().toString(36).slice(2),A:t,H:n}),S=t=>!!t?.[g],x=(t,n,e)=>{n.addEventListener(t[g],t=>{const n=p.get(e);void 0!==n&&(t.stopPropagation(),t.detail(n))})},M=t=>{const n=y();return a(()=>{let e=t.A;return n.L?.dispatchEvent(new CustomEvent(t[g],{detail:t=>e=t,bubbles:!0,composed:!0})),e})};var k;!function(t){t.forEach=(n,e)=>n.forEach(n=>Array.isArray(n)?t.forEach(n,e):e(n)),t.last=(n,e=n.length-1)=>{if(n.length)for(let o=e;o>=0;o--){const e=n[o];if(!Array.isArray(e))return e;const s=t.last(e);if(s)return s}}}(k||(k={}));const C=t=>({build(){const n=t();return n.build?.()??n}}),E=(t,n)=>({O:"p",T:t,...n}),N=(t=CustomEvent)=>({O:"e",D:t}),j=Symbol();let A;const H=(t,n)=>{A?A.push([t,n]):f(t,n)},L=(t,n,e)=>{const o="string"==typeof t?t:null,s="string"==typeof t?n:t,i=("string"==typeof t?e:n)??{},l=[],u=new Map;for(const t in s){const n=s[t];if("p"==n.O&&n.attribute){"function"==typeof n.attribute&&(n.attribute={transform:n.attribute});const e=n.attribute={name:w(t),static:!1,transform:t=>t,...n.attribute};u.set(e.name,{name:t,meta:n}),e.static||l.push(e.name)}}i.shadow??={mode:"open"};class a extends HTMLElement{static[j]={I:o};static observedAttributes=l;props={};events={};[j]={};constructor(){super();for(const t in s){const n=s[t];if("p"==n.O){const e=S(n.T)?n.T:null,[o,s]=c(e?void 0:n.T);this.props[t]=o,e&&x(e,this,o),Object.defineProperty(this,t,{get:o.peek,set:t=>s(()=>t,{force:!0})})}else if("e"==n.O&&t.startsWith("on")){const e=b(t);this.events[t]=t=>this.dispatchEvent(new n.D(e,t))}}}connectedCallback(){const t=(n=this,i.shadow?n.shadowRoot??n.attachShadow(i.shadow):n);var n;this[j].$=d(()=>m({P:!1,L:this,N:t.childNodes.values()},()=>{this[j].M=r();const n=A;A=[];try{k.forEach(this.render().build(),n=>{t.append(n)}),A.forEach(([t,n])=>f(t,n))}finally{A=n}}))[1]}disconnectedCallback(){this[j].$?.()}attributeChangedCallback(t,n,e){const o=u.get(t);o&&(this[o.name]=null!=e?o.meta.attribute.transform.call(this,e):S(o.meta.T)?void 0:o.meta.T)}}return a},O=t=>!!t?.[j],T=(...t)=>{const[n,e]="string"==typeof t[0]?[t[0],t.slice(1)]:["",t];for(const t of e)customElements.define(n+(t[j].I??w(t.name)),t)},D=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,I=(t,n,e)=>{"-"==n[0]?t.style.setProperty(n,""+e):t.style[n]=null==e?"":"number"!=typeof e||D.test(n)?""+e:e+"px"},$=(t,n,e,o)=>{const s=null==e||!1===e&&!n.includes("-");if(n.startsWith("prop:"))t[n.slice(5)]=e;else if(n.startsWith("attr:"))n=n.slice(5),s?t.removeAttribute(n):t.setAttribute(n,e);else if(!["innerHTML","outerHTML"].includes(n)){if(!["tabIndex","role",...o?["width","height","href","list","form","download","rowSpan","colSpan"]:[]].includes(n)&&n in t)try{return void(t[n]=e)}catch(t){}"function"==typeof e||(s?t.removeAttribute(n):t.setAttribute(n,e))}},z=({text:t,marker:n})=>C(()=>{const e=y(),o=n&&e.C(()=>document.createComment("")),s=e.C(()=>document.createTextNode(""));return f(()=>{const n=""+(p.get(t)??"");s.textContent!=n&&(s.textContent=n)}),o?[o,s]:[s]}),P=({children:t})=>C(()=>Array.isArray(t)?t.flatMap(t=>P({children:t}).build()):null==t?[]:["object"==typeof t?t.build():z({text:t}).build()]),V=(t,n,e,o)=>{const{ref:s,style:c,children:l,dangerouslySetInnerHTML:u,...a}=e;for(const n in c??{}){const e=c[n];f(()=>{I(t,n,p.get(e))})}for(const n in a){const e=a[n];if(n.startsWith("on")){const o=r(),s=t=>{o.u(()=>i(()=>e(t)))},c=b(n);f(()=>(t.addEventListener(c,s),()=>t.removeEventListener(c,s)))}else f(()=>{$(t,n,p.get(e),o)})}return u&&f(()=>{const n=p.get(u).__html;t.innerHTML!=n&&(t.innerHTML=n)}),s&&f(()=>(s.set(t),()=>s.set(void 0))),null!=e.children&&k.forEach(m({P:n,N:t.childNodes.values()},()=>P({children:e.children}).build()),n=>t.append(n)),t},Z=(t,n={},e)=>(null!=e&&(n.children=e),O(t)?((t,n)=>C(()=>{const e=y().C(()=>new t);return customElements.upgrade(e),V(e,!1,n),[e]}))(t,n):"function"==typeof t?C(()=>t(n)):((t,n={})=>C(()=>{const e=y(),o="svg"==t||!!e.P;return[V(e.C(()=>o?document.createElementNS("http://www.w3.org/2000/svg",t):document.createElement(t)),(!o||"foreignObject"!==t)&&o,n,!0)]}))(t,n)),q=new Proxy(Z,{get:(t,n)=>(e,o)=>t(n,e,o)}),B=(t,n)=>{const[e,o]=c({V:[],Z:new Map},{force:!0});let s=new Map;return f(()=>{const e=[],r=s,c=((t,n)=>{const e=new Map;for(let o=0;o<t.length;o++){const s=n(t[o],o);if(e.has(s))throw Error(`Duplicate key '${s}'`);e.set(s,o)}return e})(t(),n),i=(t=NaN)=>e.map(t=>"r"==t.q?n=>n<t.B?n:n==t.B?NaN:n-1:"a"==t.q?n=>n<t.B?n:n+1:"m"==t.q?n=>t.F<=n&&n<t.G?n+1:n==t.G?t.F:n:t=>t).reduce((t,n)=>n(t),t);for(const t of r.keys()){const n=i(r.get(t));c.has(t)||e.push({q:"r",J:t,B:n})}for(let o=0;o<t().length;o++){const s=n(t()[o],o),c=i(r.get(s));isNaN(c)?e.push({q:"a",J:s,B:o}):c!=o&&e.push({q:"m",J:s,G:c,F:o})}e.length>0&&o({V:e,Z:c}),s=c}),e},F=t=>C(()=>{const n=y(),e=p.upgrade(t.each??[]),o=n.C(()=>document.createComment("")),s=t.key??((t,n)=>n),r=[o,[]],i=new Map,l=B(e,s),u=t=>k.last(r[1],t-1)??o;return f(()=>{for(const n of l().V)if("r"==n.q){const{K:t,$:e}=i.get(n.J)??{};e?.(),r[1].splice(n.B,1),k.forEach(t??[],t=>t.parentNode?.removeChild(t)),i.delete(n.J)}else if("a"==n.q){let o;const[,s]=d(()=>{const[s,i]=c(n.B),[a,d]=c(e()[n.B]);f(()=>{0<=s()&&s()<e().length&&d(()=>e()[s()])}),f(()=>{const t=l().Z.get(n.J);null!=t&&i(t)}),o=t.children?.(a,s,e).build()??[],r[1].splice(n.B,0,o);let h=u(n.B);k.forEach(o,t=>{h.parentNode?.insertBefore(t,h.nextSibling),h=t})});i.set(n.J,{K:o,$:s})}else if("m"==n.q){const{K:t}=i.get(n.J)??{};r[1].splice(n.G,1),r[1].splice(n.F,0,t??[]);let e=u(n.F);k.forEach(t??[],t=>{e.parentNode?.insertBefore(t,e.nextSibling),e=t})}},[l]),r}),G=t=>(y().k=[],J({condition:t.condition,children:t.children})),J=t=>{const n=y(),e=n.k,o=p.upgrade(t.condition),s=a(()=>e.every(t=>!t())&&o());return n.k=[...e,o],C(()=>m({k:[]},()=>{const e=n.C(()=>document.createComment("")),o=[e,[]],r=a(()=>s()?P({children:t.children}):null);let c=[];return f(()=>{k.forEach(c,t=>t.parentNode?.removeChild(t)),o[1]=[];const[,t]=d(()=>{c=r()?.build()??[],o[1]=c;let t=e;k.forEach(c,n=>{t.parentNode?.insertBefore(n,t.nextSibling),t=n})});return t},[r]),o}))},K=({children:t})=>J({condition:!0,children:t}),Q=({mount:t,children:n})=>C(()=>m({N:void 0},()=>{const e=P({children:n}).build();return f(()=>(k.forEach(e,n=>t.appendChild(n)),()=>{k.forEach(e,t=>t.parentNode?.removeChild(t))}),[]),[]})),R=Symbol(),U=new Map,W=t=>{const n=t.children;if("function"==typeof n){const e=Z("style",{},z({text:n,marker:!1}));return t.light?Q({mount:document.head,children:e}):e}if(n){const o=y(),s=t.light?document:o.L?.shadowRoot??document,r=((t,n,e)=>{if(!U.has(n)){const t=new CSSStyleSheet;t.replaceSync(n),U.set(n,{R:t,U:0})}const o=U.get(n);o.U++,t.has(n)||t.set(n,{R:o.R,U:0});const s=t.get(n);return s.U++,f(()=>()=>{--s.U||(t.delete(n),e()),--o.U||U.delete(n)}),s.R})((e=s,e[R]??=new Map),n,()=>{s.adoptedStyleSheets=s.adoptedStyleSheets.filter(t=>t!=r)});s.adoptedStyleSheets.push(r)}var e;return P({})},X=(t,...n)=>{const e=()=>t.reduce((t,e,o)=>t+e+(p.get(n[o])??""),"");return n.some(t=>"function"==typeof t)?e:e()},Y=(t,n,e)=>(n&&null!=e&&(n.key=e),Z(t,n));export{L as Component,K as Else,J as ElseIf,F as For,P as Fragment,G as If,p as MaybeSignal,Q as Portal,W as Style,k as TemplateNodes,v as createContext,Z as createElement,X as css,T as defineComponents,N as event,l as flushBatch,q as h,O as isComponent,Y as jsx,Y as jsxDEV,Y as jsxs,E as prop,i as useBatch,M as useContext,H as useEffect,a as useMemo,h as useRef,c as useSignal,d as useSubscope};
@@ -178,7 +178,7 @@ export type Component<M extends Metadata = {}> = {
178
178
  export interface ComponentConstructor<M extends Metadata = {}> {
179
179
  /** @ignore */
180
180
  readonly [componentSym]: {
181
- readonly _tagName: string;
181
+ readonly _tagName: string | null;
182
182
  };
183
183
  readonly observedAttributes: readonly string[];
184
184
  new (): Component<M>;
@@ -208,7 +208,7 @@ export declare const useMountEffect: (fn: () => Cleanup, deps?: SignalLike<unkno
208
208
  *
209
209
  * @example
210
210
  * ```tsx
211
- * class MyComponent extends Component("my-component", {
211
+ * class MyComponent extends Component({
212
212
  * myProp: prop<string>("Hello, world!"),
213
213
  * onMyEvent: event(),
214
214
  * }) {
@@ -222,10 +222,10 @@ export declare const useMountEffect: (fn: () => Cleanup, deps?: SignalLike<unkno
222
222
  * },
223
223
  * }
224
224
  *
225
- * customElements.define("my-component", MyComponent);
225
+ * defineComponents(MyComponent);
226
226
  * ```
227
227
  */
228
- export declare const Component: ((tagName: string) => ComponentConstructor<{}>) & (<const M extends Metadata>(tagName: string, metadata: M, opts?: ComponentOptions) => ComponentConstructor<M>);
228
+ export declare const Component: ((tagName?: string) => ComponentConstructor<{}>) & (<const M extends Metadata>(tagName: string, metadata: M, opts?: ComponentOptions) => ComponentConstructor<M>) & (<const M extends Metadata>(metadata: M, opts?: ComponentOptions) => ComponentConstructor<M>);
229
229
  /**
230
230
  * Determines whether the given value is a component created by
231
231
  * extending {@link ComponentConstructor}.
package/dist/component.js CHANGED
@@ -121,7 +121,7 @@ export const useMountEffect = (fn, deps) => {
121
121
  *
122
122
  * @example
123
123
  * ```tsx
124
- * class MyComponent extends Component("my-component", {
124
+ * class MyComponent extends Component({
125
125
  * myProp: prop<string>("Hello, world!"),
126
126
  * onMyEvent: event(),
127
127
  * }) {
@@ -135,10 +135,17 @@ export const useMountEffect = (fn, deps) => {
135
135
  * },
136
136
  * }
137
137
  *
138
- * customElements.define("my-component", MyComponent);
138
+ * defineComponents(MyComponent);
139
139
  * ```
140
140
  */
141
- export const Component = ((tagName, metadata = {}, opts = {}) => {
141
+ export const Component = ((tagNameOrMetadata, metadataOrOpts, optsParam) => {
142
+ const tagName = typeof tagNameOrMetadata === "string" ? tagNameOrMetadata : null;
143
+ const metadata = typeof tagNameOrMetadata === "string"
144
+ ? metadataOrOpts
145
+ : tagNameOrMetadata;
146
+ const opts = (typeof tagNameOrMetadata === "string"
147
+ ? optsParam
148
+ : metadataOrOpts) ?? {};
142
149
  // Extract attribute information
143
150
  const observedAttributes = [];
144
151
  const attributePropMap = new Map();
@@ -166,7 +173,7 @@ export const Component = ((tagName, metadata = {}, opts = {}) => {
166
173
  // Create base class
167
174
  opts.shadow ??= { mode: "open" };
168
175
  const getRenderParent = (component) => opts.shadow
169
- ? component.shadowRoot ?? component.attachShadow(opts.shadow)
176
+ ? (component.shadowRoot ?? component.attachShadow(opts.shadow))
170
177
  : component;
171
178
  class _Component extends HTMLElement {
172
179
  static [componentSym] = {
@@ -253,7 +260,9 @@ export const defineComponents = (...args) => {
253
260
  ? [args[0], args.slice(1)]
254
261
  : ["", args];
255
262
  for (const component of components) {
256
- customElements.define(prefix + component[componentSym]._tagName, component);
263
+ customElements.define(prefix +
264
+ (component[componentSym]._tagName ??
265
+ camelCaseToKebabCase(component.name)), component);
257
266
  }
258
267
  };
259
268
  //# sourceMappingURL=component.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,SAAS,EACT,WAAW,EACX,SAAS,GAEV,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACL,oBAAoB,EAEpB,sBAAsB,GACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;A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C,IAAI,QAAQ;QACxB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAA2B,CAAC;QACpD,CAAC,CAAC,CAAC,EAAE,EAAE,IAA8B,CAAC,CAAC;IAE3C,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,cAAc,CAAC,MAAM,CACnB,MAAM;YACJ,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,QAAQ;gBAC/B,oBAAoB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EACzC,SAAS,CACV,CAAC;IACJ,CAAC;AACH,CAAC,CAAC"}
@@ -61,7 +61,7 @@ export const TagComponent = (tagName, props = {}) => createTemplate(() => {
61
61
  const svg = tagName == "svg" ? true : !!renderer._svg;
62
62
  const node = hydrateElement(renderer._node(() => !svg
63
63
  ? document.createElement(tagName)
64
- : document.createElementNS("http://www.w3.org/2000/svg", tagName)), svg, props, true);
64
+ : document.createElementNS("http://www.w3.org/2000/svg", tagName)), svg && tagName === "foreignObject" ? false : svg, props, true);
65
65
  return [node];
66
66
  });
67
67
  //# sourceMappingURL=TagComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TagComponent.js","sourceRoot":"","sources":["../../src/intrinsic/TagComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAY,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEzE,MAAM,CAAC,MAAM,cAAc,GAAG,C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,EAAE,OAAO,CAAC,CACpE,EACD,GAAG,IAAI,OAAO,KAAK,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAChD,KAAK,EACL,IAAI,CACL,CAAC;IAEF,OAAO,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC,CAAC,CAAC"}
package/dist/scope.d.ts CHANGED
@@ -46,7 +46,6 @@ export interface SubscopeOptions {
46
46
  details?: object;
47
47
  }
48
48
  interface Effect {
49
- readonly _fn: Function;
50
49
  _scope: Scope;
51
50
  _pure: boolean;
52
51
  _clean?: Cleanup;
@@ -58,10 +57,9 @@ interface Effect {
58
57
  */
59
58
  export type Cleanup = (() => void) | void | undefined | null;
60
59
  export interface Scope<out T = {}> {
61
- _fn?: Function;
62
60
  readonly _parent?: Scope;
63
- _effects: Effect[];
64
- _subscopes: Scope[];
61
+ _effects: Set<Effect>;
62
+ _subscopes: Set<Scope>;
65
63
  _details: T;
66
64
  _run<T>(fn: () => T): T;
67
65
  _cleanup(): void;
package/dist/scope.js CHANGED
@@ -1,14 +1,13 @@
1
1
  const createScope = (parent) => {
2
2
  return {
3
3
  _parent: parent,
4
- _effects: [],
5
- _subscopes: [],
4
+ _effects: new Set(),
5
+ _subscopes: new Set(),
6
6
  _details: { ...parent?._details },
7
7
  _run(fn) {
8
8
  const prevScope = currScope;
9
9
  currScope = this;
10
10
  try {
11
- this._fn = fn;
12
11
  return fn();
13
12
  }
14
13
  finally {
@@ -16,18 +15,19 @@ const createScope = (parent) => {
16
15
  }
17
16
  },
18
17
  _cleanup() {
19
- for (let i = this._subscopes.length - 1; i >= 0; i--) {
20
- this._subscopes[i]._cleanup();
21
- }
22
- this._subscopes = [];
23
- for (let i = this._effects.length - 1; i >= 0; i--) {
24
- const effect = this._effects[i];
18
+ [...this._subscopes].forEach((_, i, arr) => {
19
+ const subscope = arr[arr.length - 1 - i];
20
+ subscope._cleanup();
21
+ });
22
+ this._subscopes = new Set();
23
+ [...this._effects].forEach((_, i, arr) => {
24
+ const effect = arr[arr.length - 1 - i];
25
25
  effect._clean?.();
26
26
  effect._run = () => { };
27
27
  effect._deps.forEach((signal) => signal._effects.delete(effect));
28
28
  effect._deps.clear();
29
- }
30
- this._effects = [];
29
+ });
30
+ this._effects = new Set();
31
31
  },
32
32
  };
33
33
  };
@@ -137,7 +137,6 @@ let pureEffectFlag = false;
137
137
  export const useEffect = (fn, deps) => {
138
138
  const untracked = !!deps;
139
139
  const effect = {
140
- _fn: fn,
141
140
  _scope: currScope,
142
141
  _pure: pureEffectFlag,
143
142
  _deps: new Set(),
@@ -172,12 +171,12 @@ export const useEffect = (fn, deps) => {
172
171
  }
173
172
  },
174
173
  };
175
- currScope._effects.push(effect);
174
+ currScope._effects.add(effect);
176
175
  effect._run();
177
176
  if (!effect._deps.size && !effect._clean) {
178
177
  // Optimization: Destroy effect since there's no cleanup and this effect
179
178
  // won't be called again
180
- currScope._effects.pop();
179
+ currScope._effects.delete(effect);
181
180
  }
182
181
  };
183
182
  /**
@@ -213,15 +212,12 @@ export const useSubscope = (fn, opts) => {
213
212
  const scope = createScope(parent);
214
213
  Object.assign(scope._details, opts?.details);
215
214
  try {
216
- parent._subscopes.push(scope);
215
+ parent._subscopes.add(scope);
217
216
  const result = scope._run(fn);
218
217
  return [
219
218
  result,
220
219
  () => {
221
- const index = parent._subscopes.indexOf(scope);
222
- if (index >= 0) {
223
- parent._subscopes.splice(index, 1);
224
- }
220
+ parent._subscopes.delete(scope);
225
221
  scope._cleanup();
226
222
  },
227
223
  ];
package/dist/scope.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"scope.js","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAgFA,MAAM,WAAW,GAAG,CAAC,MAAc,EAAS,EAAE;IAC5C,OAAO;QACL,OAAO,EAAE,MAAM;QACf,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE;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0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "A lightweight signal-based library for building web components with a React-like API.",
5
5
  "keywords": [
6
6
  "ui",
package/src/component.ts CHANGED
@@ -356,7 +356,7 @@ export type Component<M extends Metadata = {}> = {
356
356
  export interface ComponentConstructor<M extends Metadata = {}> {
357
357
  /** @ignore */
358
358
  readonly [componentSym]: {
359
- readonly _tagName: string;
359
+ readonly _tagName: string | null;
360
360
  };
361
361
  readonly observedAttributes: readonly string[];
362
362
 
@@ -403,7 +403,7 @@ export const useMountEffect = (
403
403
  *
404
404
  * @example
405
405
  * ```tsx
406
- * class MyComponent extends Component("my-component", {
406
+ * class MyComponent extends Component({
407
407
  * myProp: prop<string>("Hello, world!"),
408
408
  * onMyEvent: event(),
409
409
  * }) {
@@ -417,19 +417,34 @@ export const useMountEffect = (
417
417
  * },
418
418
  * }
419
419
  *
420
- * customElements.define("my-component", MyComponent);
420
+ * defineComponents(MyComponent);
421
421
  * ```
422
422
  */
423
- export const Component: ((tagName: string) => ComponentConstructor<{}>) &
423
+ export const Component: ((tagName?: string) => ComponentConstructor<{}>) &
424
424
  (<const M extends Metadata>(
425
425
  tagName: string,
426
426
  metadata: M,
427
427
  opts?: ComponentOptions,
428
+ ) => ComponentConstructor<M>) &
429
+ (<const M extends Metadata>(
430
+ metadata: M,
431
+ opts?: ComponentOptions,
428
432
  ) => ComponentConstructor<M>) = ((
429
- tagName: string,
430
- metadata: Metadata = {},
431
- opts: ComponentOptions = {},
433
+ tagNameOrMetadata?: string | Metadata,
434
+ metadataOrOpts?: Metadata | ComponentOptions,
435
+ optsParam?: ComponentOptions,
432
436
  ): ComponentConstructor => {
437
+ const tagName =
438
+ typeof tagNameOrMetadata === "string" ? tagNameOrMetadata : null;
439
+ const metadata =
440
+ typeof tagNameOrMetadata === "string"
441
+ ? (metadataOrOpts as Metadata)
442
+ : tagNameOrMetadata;
443
+ const opts =
444
+ (typeof tagNameOrMetadata === "string"
445
+ ? optsParam
446
+ : (metadataOrOpts as ComponentOptions)) ?? {};
447
+
433
448
  // Extract attribute information
434
449
 
435
450
  const observedAttributes: string[] = [];
@@ -477,7 +492,7 @@ export const Component: ((tagName: string) => ComponentConstructor<{}>) &
477
492
 
478
493
  const getRenderParent = (component: _Component) =>
479
494
  opts.shadow
480
- ? component.shadowRoot ?? component.attachShadow(opts.shadow)
495
+ ? (component.shadowRoot ?? component.attachShadow(opts.shadow))
481
496
  : component;
482
497
  abstract class _Component extends HTMLElement {
483
498
  static readonly [componentSym]: ComponentConstructor[typeof componentSym] =
@@ -624,6 +639,11 @@ export const defineComponents: ((
624
639
  : ["", args as ComponentConstructor[]];
625
640
 
626
641
  for (const component of components) {
627
- customElements.define(prefix + component[componentSym]._tagName, component);
642
+ customElements.define(
643
+ prefix +
644
+ (component[componentSym]._tagName ??
645
+ camelCaseToKebabCase(component.name)),
646
+ component,
647
+ );
628
648
  }
629
649
  };
@@ -94,7 +94,7 @@ export const TagComponent = (
94
94
  ? document.createElement(tagName)
95
95
  : document.createElementNS("http://www.w3.org/2000/svg", tagName),
96
96
  ),
97
- svg,
97
+ svg && tagName === "foreignObject" ? false : svg,
98
98
  props,
99
99
  true,
100
100
  );
package/src/scope.ts CHANGED
@@ -68,8 +68,8 @@ export type Cleanup = (() => void) | void | undefined | null;
68
68
 
69
69
  export interface Scope<out T = {}> {
70
70
  readonly _parent?: Scope;
71
- _effects: Effect[];
72
- _subscopes: Scope[];
71
+ _effects: Set<Effect>;
72
+ _subscopes: Set<Scope>;
73
73
  _details: T;
74
74
 
75
75
  _run<T>(fn: () => T): T;
@@ -79,8 +79,8 @@ export interface Scope<out T = {}> {
79
79
  const createScope = (parent?: Scope): Scope => {
80
80
  return {
81
81
  _parent: parent,
82
- _effects: [],
83
- _subscopes: [],
82
+ _effects: new Set(),
83
+ _subscopes: new Set(),
84
84
  _details: { ...parent?._details },
85
85
 
86
86
  _run<T>(fn: () => T): T {
@@ -95,22 +95,23 @@ const createScope = (parent?: Scope): Scope => {
95
95
  },
96
96
 
97
97
  _cleanup(): void {
98
- for (let i = this._subscopes.length - 1; i >= 0; i--) {
99
- this._subscopes[i]._cleanup();
100
- }
98
+ [...this._subscopes].forEach((_, i, arr) => {
99
+ const subscope = arr[arr.length - 1 - i];
100
+ subscope._cleanup();
101
+ });
101
102
 
102
- this._subscopes = [];
103
+ this._subscopes = new Set();
103
104
 
104
- for (let i = this._effects.length - 1; i >= 0; i--) {
105
- const effect = this._effects[i];
105
+ [...this._effects].forEach((_, i, arr) => {
106
+ const effect = arr[arr.length - 1 - i];
106
107
  effect._clean?.();
107
108
  effect._run = () => {};
108
109
 
109
110
  effect._deps.forEach((signal) => signal._effects.delete(effect));
110
111
  effect._deps.clear();
111
- }
112
+ });
112
113
 
113
- this._effects = [];
114
+ this._effects = new Set();
114
115
  },
115
116
  };
116
117
  };
@@ -307,14 +308,14 @@ export const useEffect = (
307
308
  },
308
309
  };
309
310
 
310
- currScope._effects.push(effect);
311
+ currScope._effects.add(effect);
311
312
  effect._run();
312
313
 
313
314
  if (!effect._deps.size && !effect._clean) {
314
315
  // Optimization: Destroy effect since there's no cleanup and this effect
315
316
  // won't be called again
316
317
 
317
- currScope._effects.pop();
318
+ currScope._effects.delete(effect);
318
319
  }
319
320
  };
320
321
 
@@ -363,17 +364,13 @@ export const useSubscope = <T>(
363
364
  Object.assign(scope._details, opts?.details);
364
365
 
365
366
  try {
366
- parent._subscopes.push(scope);
367
+ parent._subscopes.add(scope);
367
368
  const result = scope._run(fn);
368
369
 
369
370
  return [
370
371
  result,
371
372
  () => {
372
- const index = parent._subscopes.indexOf(scope);
373
- if (index >= 0) {
374
- parent._subscopes.splice(index, 1);
375
- }
376
-
373
+ parent._subscopes.delete(scope);
377
374
  scope._cleanup();
378
375
  },
379
376
  ];
@@ -25,6 +25,12 @@ function HomepageHeader() {
25
25
  >
26
26
  Documentation
27
27
  </Link>
28
+ <Link
29
+ className="button button--secondary button--lg"
30
+ to="/playground"
31
+ >
32
+ Playground
33
+ </Link>
28
34
  </div>
29
35
  </div>
30
36
  </header>
@@ -7,7 +7,7 @@ export default function PlaygroundPage() {
7
7
  const [src, setSrc] = useState(`\
8
8
  import { Component, useSignal, defineComponents } from "sinho";
9
9
 
10
- class Counter extends Component("x-counter") {
10
+ class MyCounter extends Component() {
11
11
  render() {
12
12
  const [value, setValue] = useSignal(0);
13
13
 
@@ -23,8 +23,8 @@ class Counter extends Component("x-counter") {
23
23
  }
24
24
  }
25
25
 
26
- defineComponents(Counter);
27
- document.body.append(new Counter());`);
26
+ defineComponents(MyCounter);
27
+ document.body.append(new MyCounter());`);
28
28
 
29
29
  return (
30
30
  <Layout