sinho 0.1.0 → 0.1.1
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/dist/bundle.d.ts +8 -1
- package/dist/bundle.js +6 -8
- package/dist/bundle.min.js +1 -1
- package/dist/mod.d.ts +1 -1
- package/dist/mod.js +1 -1
- package/dist/mod.js.map +1 -1
- package/dist/renderer.d.ts +2 -2
- package/dist/renderer.js.map +1 -1
- package/dist/scope.js +5 -7
- package/dist/scope.js.map +1 -1
- package/package.json +1 -1
- package/src/mod.ts +1 -0
- package/src/renderer.ts +2 -2
- package/src/scope.ts +6 -6
package/dist/bundle.d.ts
CHANGED
|
@@ -77,6 +77,13 @@ declare const useBatch: <T>(fn: () => T) => T;
|
|
|
77
77
|
* @param fn The computation function.
|
|
78
78
|
*/
|
|
79
79
|
declare const useMemo: <T>(fn: () => T, opts?: SetSignalOptions) => Signal<T>;
|
|
80
|
+
/**
|
|
81
|
+
* Executes a function inside a subscope which can be manually destroyed.
|
|
82
|
+
*
|
|
83
|
+
* @param fn The function to run in the subscope.
|
|
84
|
+
* @returns A function to manually destroy the subscope.
|
|
85
|
+
*/
|
|
86
|
+
declare const useSubscope: <T>(fn: () => T, opts?: SubscopeOptions) => [T, () => void];
|
|
80
87
|
/**
|
|
81
88
|
* Provide write capabilities to a signal.
|
|
82
89
|
*/
|
|
@@ -1123,4 +1130,4 @@ declare namespace JSX {
|
|
|
1123
1130
|
}
|
|
1124
1131
|
}
|
|
1125
1132
|
|
|
1126
|
-
export { type AttributeOptions, type Children, type Cleanup, Component, type ComponentConstructor, type ComponentOptions, type Context, type DangerousHtml, Else, ElseIf, type EventConstructor, For, Fragment, type FunctionalComponent, If, JSX, MaybeSignal, type Metadata, Portal, type PropOptions, type RefSignal, type RefSignalSetter, type SetSignalOptions, type Signal, type SignalLike, type SignalSetter, Style, type Styles, type SubscopeOptions, type Template, createContext, createElement, css, defineComponents, event, h, isComponent, jsx, jsx as jsxDEV, jsx as jsxs, prop, useBatch, useContext, useMountEffect as useEffect, useMemo, useRef, useSignal };
|
|
1133
|
+
export { type AttributeOptions, type Children, type Cleanup, Component, type ComponentConstructor, type ComponentOptions, type Context, type DangerousHtml, Else, ElseIf, type EventConstructor, For, Fragment, type FunctionalComponent, If, JSX, MaybeSignal, type Metadata, Portal, type PropOptions, type RefSignal, type RefSignalSetter, type SetSignalOptions, type Signal, type SignalLike, type SignalSetter, Style, type Styles, type SubscopeOptions, type Template, createContext, createElement, css, defineComponents, event, h, isComponent, jsx, jsx as jsxDEV, jsx as jsxs, prop, useBatch, useContext, useMountEffect as useEffect, useMemo, useRef, useSignal, useSubscope };
|
package/dist/bundle.js
CHANGED
|
@@ -22,6 +22,7 @@ const createScope = (parent) => {
|
|
|
22
22
|
for (let i = this._effects.length - 1; i >= 0; i--) {
|
|
23
23
|
const effect = this._effects[i];
|
|
24
24
|
effect._clean?.();
|
|
25
|
+
effect._run = () => { };
|
|
25
26
|
effect._deps.forEach((signal) => signal._effects.delete(effect));
|
|
26
27
|
effect._deps.clear();
|
|
27
28
|
}
|
|
@@ -117,13 +118,10 @@ const useEffect = (fn, deps) => {
|
|
|
117
118
|
const prevUntracked = currUntracked;
|
|
118
119
|
currEffect = this;
|
|
119
120
|
try {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
this._deps.clear();
|
|
125
|
-
}
|
|
126
|
-
else if (!this._deps.size) {
|
|
121
|
+
// Clean up dependencies and listeners
|
|
122
|
+
this._deps.forEach((dep) => dep._effects.delete(this));
|
|
123
|
+
this._deps.clear();
|
|
124
|
+
if (deps) {
|
|
127
125
|
// Track specified dependencies
|
|
128
126
|
deps.forEach((dep) => dep());
|
|
129
127
|
}
|
|
@@ -1071,4 +1069,4 @@ const jsx = (type, props, key) => {
|
|
|
1071
1069
|
return createElement(type, props);
|
|
1072
1070
|
};
|
|
1073
1071
|
|
|
1074
|
-
export { Component, Else, ElseIf, For, Fragment, If, MaybeSignal, Portal, Style, createContext, createElement, css, defineComponents, event, h, isComponent, jsx, jsx as jsxDEV, jsx as jsxs, prop, useBatch, useContext, useMountEffect as useEffect, useMemo, useRef, useSignal };
|
|
1072
|
+
export { Component, Else, ElseIf, For, Fragment, If, MaybeSignal, Portal, Style, createContext, createElement, css, defineComponents, event, h, isComponent, jsx, jsx as jsxDEV, jsx as jsxs, prop, useBatch, useContext, useMountEffect as useEffect, useMemo, useRef, useSignal, useSubscope };
|
package/dist/bundle.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const t=t=>({t:t,o:[],i:[],l:{...t?.l},u(t){const n=o;o=this;try{return t()}finally{o=n}},h(){for(let t=this.i.length-1;t>=0;t--)this.i[t].h();this.i=[];for(let t=this.o.length-1;t>=0;t--){const n=this.o[t];n._?.(),n.p.forEach((t=>t.o.delete(n))),n.p.clear()}this.o=[]}});let n,e,o=t(),s=!1;const r=()=>o,c=(t,o)=>{const r=()=>(!s&&n&&(n.p.add(r),r.o.add(n)),r.peek());r.o=new Set,r.peek=()=>t;const c=(n,s)=>{if(s={...o,...s},e){const o="function"==typeof n?n(r.peek()):n;(s?.force||o!==r.peek())&&(s?.force?t=o:e.m.push((()=>t=o)),s?.silent||r.o.forEach((t=>e.o.add(t))))}else i((()=>c(n,s)))};return[r,c]},i=t=>{const n=e;e={m:[],o:new Set};try{const n=t();for(;e.m.length>0||e.o.size>0;){const t=e.o;e.o=new Set,t.forEach((t=>t._?.())),e.m.forEach((t=>t())),e.m=[],t.forEach((t=>t.u()))}return n}finally{e=n}},l=(t,e)=>{const r=!!e,c={v:o,p:new Set,u(){const o=n,c=s;n=this;try{
|
|
1
|
+
const t=t=>({t:t,o:[],i:[],l:{...t?.l},u(t){const n=o;o=this;try{return t()}finally{o=n}},h(){for(let t=this.i.length-1;t>=0;t--)this.i[t].h();this.i=[];for(let t=this.o.length-1;t>=0;t--){const n=this.o[t];n._?.(),n.u=()=>{},n.p.forEach((t=>t.o.delete(n))),n.p.clear()}this.o=[]}});let n,e,o=t(),s=!1;const r=()=>o,c=(t,o)=>{const r=()=>(!s&&n&&(n.p.add(r),r.o.add(n)),r.peek());r.o=new Set,r.peek=()=>t;const c=(n,s)=>{if(s={...o,...s},e){const o="function"==typeof n?n(r.peek()):n;(s?.force||o!==r.peek())&&(s?.force?t=o:e.m.push((()=>t=o)),s?.silent||r.o.forEach((t=>e.o.add(t))))}else i((()=>c(n,s)))};return[r,c]},i=t=>{const n=e;e={m:[],o:new Set};try{const n=t();for(;e.m.length>0||e.o.size>0;){const t=e.o;e.o=new Set,t.forEach((t=>t._?.())),e.m.forEach((t=>t())),e.m=[],t.forEach((t=>t.u()))}return n}finally{e=n}},l=(t,e)=>{const r=!!e,c={v:o,p:new Set,u(){const o=n,c=s;n=this;try{this.p.forEach((t=>t.o.delete(this))),this.p.clear(),e&&e.forEach((t=>t())),s=r,this._?.();const n=this.v.u((()=>i(t)));this._=n?()=>{this.v.u((()=>i(n))),this._=null}:null}finally{n=o,s=c}}};c.p.forEach((t=>t.o.add(c))),o.o.push(c),c.u(),c.p.size||c._||o.o.pop()},u=(t,n)=>{const[e,o]=c();let s=!0;return l((()=>{o(t,s?{...n,force:!0}:n),s=!1})),e},f=(n,e)=>{const s=o,r=t(s);Object.assign(r.l,e?.details),s.i.push(r);return[r.u(n),()=>{const t=s.i.indexOf(r);t>=0&&s.i.splice(t,1),r.h()}]},a=(t,n)=>{const[e,o]=c(t,n);return e.set=o,e},d={upgrade:t=>()=>d.get(t),get:t=>"function"==typeof t?t():t,peek(t){const n=s;s=!0;try{return this.get(t)}finally{s=n}}},h=(t={})=>({S:[],M(t){return this.k?.next().value??t()},...t}),_=()=>{const t=r();return t.l.C??=h()},p=(t,n)=>{const e=_(),o=h({...e,...t}),[s,r]=f(n,{details:{C:o}});return l((()=>r)),s},m=t=>(t[0]??"").toLowerCase()+t.slice(1).replace(/[A-Z]/g,(t=>"-"+t.toLowerCase())),y=t=>t.startsWith("on:")?t.slice(3):m(t.slice(2)),w=Symbol(),b=(t,n)=>({[w]:Math.random().toString(36).slice(2),N:t,j:n}),g=t=>!!t?.[w],v=(t,n,e)=>{n.addEventListener(t[w],(t=>{const n=d.get(e);void 0!==n&&(t.stopPropagation(),t.detail(n))}))},x=t=>{const n=_();return u((()=>{let e=t.N;return n.H?.dispatchEvent(new CustomEvent(t[w],{detail:t=>e=t,bubbles:!0,composed:!0})),e}))},S=(t,n)=>({L:"p",T:t,...n}),M=(t=CustomEvent)=>({L:"e",A:t}),k=Symbol();let C;const E=(t,n)=>{C?C.push([t,n]):l(t,n)},N=(t,n={},e={})=>{const o=[],s=new Map;for(const t in n){const e=n[t];if("p"==e.L&&e.attribute){"function"==typeof e.attribute&&(e.attribute={transform:e.attribute});const n=e.attribute={name:m(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[k]={O:t};static observedAttributes=o;props={};events={};[k]={};constructor(){super();for(const t in n){const e=n[t];if("p"==e.L){const n=g(e.T)?e.T:null,[o,s]=c(n?void 0:e.T);this.props[t]=o,n&&v(n,this,o),Object.defineProperty(this,t,{get:o.peek,set:t=>s((()=>t),{force:!0})})}else if("e"==e.L&&t.startsWith("on")){const n=y(t);this.events[t]=t=>this.dispatchEvent(new e.A(n,t))}}}connectedCallback(){const t=(n=this,e.shadow?n.shadowRoot??n.attachShadow(e.shadow):n);var n;this[k].D=f((()=>p({I:!1,H:this,k:t.childNodes.values()},(()=>{this[k].v=r();const n=C;C=[];try{t?.append(...this.render().build()),C.forEach((([t,n])=>l(t,n)))}finally{C=n}}))))[1]}disconnectedCallback(){this[k].D?.()}attributeChangedCallback(t,n,e){const o=s.get(t);o&&(this[o.name]=null!=e?o.meta.attribute.transform.call(this,e):g(o.meta.T)?void 0:o.meta.T)}}return i},j=t=>!!t?.[k],H=(...t)=>{const[n,e]="string"==typeof t[0]?[t[0],t.slice(1)]:["",t];for(const t of e)customElements.define(n+t[k].O,t)},L=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,T=(t,n,e)=>{"-"==n[0]?t.style.setProperty(n,""+e):t.style[n]=null==e?"":"number"!=typeof e||L.test(n)?""+e:e+"px"},A=(t,n,e,o)=>{const s=null==e||!1===e&&!n.includes("-");if(n.startsWith("prop:"))t[n]=e;else if(n.startsWith("attr:"))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))}},O=t=>({build(){const n=t();return n.build?.()??n}}),D=({text:t,marker:n})=>O((()=>{const e=_(),o=n&&e.M((()=>document.createComment(""))),s=e.M((()=>document.createTextNode("")));return l((()=>{const n=""+(d.get(t)??"");s.textContent!=n&&(s.textContent=n)})),o?[o,s]:[s]})),I=({children:t})=>O((()=>Array.isArray(t)?t.flatMap((t=>I({children:t}).build())):null==t?[]:"object"==typeof t?t:D({text:t}))),$=(t,n,e,o)=>{const{ref:s,style:c,children:u,dangerouslySetInnerHTML:f,...a}=e;for(const n in c??{}){const e=c[n];l((()=>{T(t,n,d.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=y(n);l((()=>(t.addEventListener(c,s),()=>t.removeEventListener(c,s))))}else l((()=>{A(t,n,d.get(e),o)}))}return f&&l((()=>{const n=d.get(f).__html;t.innerHTML!=n&&(t.innerHTML=n)})),s&&l((()=>(s.set(t),()=>s.set(void 0)))),null!=e.children&&t.append(...p({I:n,k:t.childNodes.values()},(()=>I({children:e.children}).build()))),t},z=(t,n={},e)=>(null!=e&&(n.children=e),j(t)?((t,n)=>O((()=>{const e=_().M((()=>new t));return customElements.upgrade(e),$(e,!1,n),[e]})))(t,n):"function"==typeof t?O((()=>t(n))):((t,n={})=>O((()=>{const e=_(),o="svg"==t||!!e.I;return[$(e.M((()=>o?document.createElementNS("http://www.w3.org/2000/svg",t):document.createElement(t))),o,n,!0)]})))(t,n)),P=new Proxy(z,{get:(t,n)=>(e,o)=>t(n,e,o)}),V=(t,n)=>{const[e,o]=c({$:[],P:new Map});let s=new Map;return l((()=>{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.V?n=>n<t.Z?n:n==t.Z?NaN:n-1:"a"==t.V?n=>n<t.Z?n:n+1:"m"==t.V?n=>t.q<=n&&n<t.B?n+1:n==t.B?t.q: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({V:"r",F:t,Z:n})}for(let o=0;o<t().length;o++){const s=n(t()[o],o),c=i(r.get(s));isNaN(c)?e.push({V:"a",F:s,Z:o}):c!=o&&e.push({V:"m",F:s,B:c,q:o})}e.length>0&&o({$:e,P:c}),s=c})),e},Z=t=>O((()=>{const n=_(),e=d.upgrade(t.each??[]),o=n.M((()=>document.createComment(""))),s=t.key??((t,n)=>n),r=[o],i=new Map,u=V(e,s),a=t=>{for(let n=t-1;n>=0;n--){const n=s(e()[t-1],t-1),o=i.get(n)?.G??[];if(o.length>0)return o[o.length-1]}return o};return l((()=>{for(const n of u().$)if("r"==n.V){const{G:t=[],D:e}=i.get(n.F)??{};e?.();const o=r.indexOf(t[0]);o>0&&r.splice(o,t.length),t.forEach((t=>t.parentNode?.removeChild(t))),i.delete(n.F)}else if("a"==n.V){let o=[];const[,s]=f((()=>{const[s,i]=c(n.Z),[f,d]=c(e()[n.Z]);l((()=>{0<=s()&&s()<e().length&&d((()=>e()[s()]))})),l((()=>{const t=u().P.get(n.F);null!=t&&i(t)})),o=t.children?.(f,s,e).build()??[];const h=a(n.Z),_=r.indexOf(h);_>=0&&r.splice(_+1,0,...o),o.forEach((t=>h.parentNode?.insertBefore(t,h.nextSibling)))}));i.set(n.F,{G:o,D:s})}else if("m"==n.V){const{G:t=[]}=i.get(n.F)??{},e=r.indexOf(t[0]);e>=0&&r.splice(e,t.length);const o=a(n.q),s=r.indexOf(o);s>=0&&r.splice(s+1,0,...t),t.forEach((t=>o.parentNode?.insertBefore(t,o.nextSibling)))}}),[u]),r})),q=t=>(_().S=[],B({condition:t.condition,children:t.children})),B=t=>{const n=_(),e=n.S,o=u((()=>e.every((t=>!t()))&&d.get(t.condition)));return n.S=[...e,o],p({S:[]},(()=>O((()=>{const e=n.M((()=>document.createComment(""))),s=[e],r=u((()=>o()?I({children:t.children}):null));let c=[];return l((()=>{c.forEach((t=>t.parentNode?.removeChild(t))),s.length=1;const[,t]=f((()=>{c=r()?.build()??[],e.after(...c),s.push(...c)}));return t}),[r]),s}))))},F=({children:t})=>B({condition:!0,children:t}),G=({mount:t,children:n})=>O((()=>p({k:void 0},(()=>{const e=I({children:n}).build();return l((()=>(e.forEach((n=>t.appendChild(n))),()=>{e.forEach((t=>t.parentNode?.removeChild(t)))}))),[]})))),J=Symbol(),K=new Map,Q=t=>{const n=t.children;if("function"==typeof n){const e=z("style",{},D({text:n,marker:!1}));return t.light?G({mount:document.head,children:e}):e}if(n){const o=_(),s=t.light?document:o.H?.shadowRoot??document,r=((t,n,e)=>{if(!K.has(n)){const t=new CSSStyleSheet;t.replaceSync(n),K.set(n,{J:t,K:0})}const o=K.get(n);o.K++,t.has(n)||t.set(n,{J:o.J,K:0});const s=t.get(n);return s.K++,l((()=>()=>{--s.K||(t.delete(n),e()),--o.K||K.delete(n)})),s.J})((e=s,e[J]??=new Map),n,(()=>{s.adoptedStyleSheets=s.adoptedStyleSheets.filter((t=>t!=r))}));s.adoptedStyleSheets.push(r)}var e;return I({})},R=(t,...n)=>{const e=()=>t.reduce(((t,e,o)=>t+e+(d.get(n[o])??"")),"");return n.some((t=>"function"==typeof t))?e:e()},U=(t,n,e)=>(n&&null!=e&&(n.key=e),z(t,n));export{N as Component,F as Else,B as ElseIf,Z as For,I as Fragment,q as If,d as MaybeSignal,G as Portal,Q as Style,b as createContext,z as createElement,R as css,H as defineComponents,M as event,P as h,j as isComponent,U as jsx,U as jsxDEV,U as jsxs,S as prop,i as useBatch,x as useContext,E as useEffect,u as useMemo,a as useRef,c as useSignal,f as useSubscope};
|
package/dist/mod.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ export { type Context, createContext, useContext } from "./context.js";
|
|
|
3
3
|
export { createElement, h } from "./create_element.js";
|
|
4
4
|
export { DangerousHtml, Styles } from "./dom.js";
|
|
5
5
|
export { type Template } from "./template.js";
|
|
6
|
-
export { type Cleanup, MaybeSignal, type SetSignalOptions, type Signal, type SignalLike, type SignalSetter, type SubscopeOptions, type RefSignal, type RefSignalSetter, useBatch, useMemo, useSignal, useRef, } from "./scope.js";
|
|
6
|
+
export { type Cleanup, MaybeSignal, type SetSignalOptions, type Signal, type SignalLike, type SignalSetter, type SubscopeOptions, type RefSignal, type RefSignalSetter, useBatch, useMemo, useSignal, useRef, useSubscope, } from "./scope.js";
|
|
7
7
|
export * from "./intrinsic/mod.js";
|
|
8
8
|
export * from "./jsx-runtime/mod.js";
|
package/dist/mod.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { Component, defineComponents, event, isComponent, prop, useMountEffect as useEffect, } from "./component.js";
|
|
2
2
|
export { createContext, useContext } from "./context.js";
|
|
3
3
|
export { createElement, h } from "./create_element.js";
|
|
4
|
-
export { MaybeSignal, useBatch, useMemo, useSignal, useRef, } from "./scope.js";
|
|
4
|
+
export { MaybeSignal, useBatch, useMemo, useSignal, useRef, useSubscope, } from "./scope.js";
|
|
5
5
|
export * from "./intrinsic/mod.js";
|
|
6
6
|
export * from "./jsx-runtime/mod.js";
|
|
7
7
|
//# sourceMappingURL=mod.js.map
|
package/dist/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EAGT,gBAAgB,EAChB,KAAK,EAGL,WAAW,EAEX,IAAI,EAEJ,cAAc,IAAI,SAAS,GAC5B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAgB,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAC;AAGvD,OAAO,EAEL,WAAW,EAQX,QAAQ,EACR,OAAO,EACP,SAAS,EACT,MAAM,
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EAGT,gBAAgB,EAChB,KAAK,EAGL,WAAW,EAEX,IAAI,EAEJ,cAAc,IAAI,SAAS,GAC5B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAgB,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAC;AAGvD,OAAO,EAEL,WAAW,EAQX,QAAQ,EACR,OAAO,EACP,SAAS,EACT,MAAM,EACN,WAAW,GACZ,MAAM,YAAY,CAAC;AAEpB,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC"}
|
package/dist/renderer.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Component } from "./component.js";
|
|
2
|
-
import {
|
|
2
|
+
import { SignalLike } from "./scope.js";
|
|
3
3
|
interface Renderer {
|
|
4
4
|
_component?: Component;
|
|
5
5
|
_svg?: boolean;
|
|
6
6
|
_nodes?: IterableIterator<Node>;
|
|
7
|
-
_ifConditions:
|
|
7
|
+
_ifConditions: SignalLike<boolean | undefined>[];
|
|
8
8
|
_node<N extends Node>(fallback: () => N): N;
|
|
9
9
|
}
|
|
10
10
|
type RendererOverrides = Partial<Omit<Renderer, "_node">>;
|
package/dist/renderer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAa1E,MAAM,cAAc,GAAG,CAAC,WAA8B,EAAE,EAAY,EAAE,CAAC,CAAC;IACtE,aAAa,EAAE,EAAE;IACjB,KAAK,CAAiB,QAAiB;QACrC,OAAQ,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,KAAuB,IAAI,QAAQ,EAAE,CAAC;IACpE,CAAC;IACD,GAAG,QAAQ;CACZ,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE;IAC9B,MAAM,KAAK,GAAG,QAAQ,EAA4B,CAAC;IACnD,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,KAAK,cAAc,EAAE,CAAC,CAAC;AACzD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,QAA2B,EAC3B,EAAW,EACR,EAAE;IACL,MAAM,YAAY,GAAG,WAAW,EAAE,CAAC;IACnC,MAAM,SAAS,GAAG,cAAc,CAAC;QAC/B,GAAG,YAAY;QACf,GAAG,QAAQ;KACZ,CAAC,CAAC;IAEH,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,WAAW,CAAC,EAAE,EAAE;QACxC,OAAO,EAAE,EAAE,SAAS,EAAE;KACvB,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC;IAEzB,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
package/dist/scope.js
CHANGED
|
@@ -22,6 +22,7 @@ const createScope = (parent) => {
|
|
|
22
22
|
for (let i = this._effects.length - 1; i >= 0; i--) {
|
|
23
23
|
const effect = this._effects[i];
|
|
24
24
|
effect._clean?.();
|
|
25
|
+
effect._run = () => { };
|
|
25
26
|
effect._deps.forEach((signal) => signal._effects.delete(effect));
|
|
26
27
|
effect._deps.clear();
|
|
27
28
|
}
|
|
@@ -117,13 +118,10 @@ export const useEffect = (fn, deps) => {
|
|
|
117
118
|
const prevUntracked = currUntracked;
|
|
118
119
|
currEffect = this;
|
|
119
120
|
try {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
this._deps.clear();
|
|
125
|
-
}
|
|
126
|
-
else if (!this._deps.size) {
|
|
121
|
+
// Clean up dependencies and listeners
|
|
122
|
+
this._deps.forEach((dep) => dep._effects.delete(this));
|
|
123
|
+
this._deps.clear();
|
|
124
|
+
if (deps) {
|
|
127
125
|
// Track specified dependencies
|
|
128
126
|
deps.forEach((dep) => dep());
|
|
129
127
|
}
|
package/dist/scope.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAsEA,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;QAEjC,IAAI,CAAI,EAAW;YACjB,MAAM,SAAS,GAAG,SAAS,CAAC;YAC5B,SAAS,GAAG,IAAI,CAAC;YAEjB,IAAI,CAAC;gBACH,OAAO,EAAE,EAAE,CAAC;YACd,CAAC;oBAAS,CAAC;gBACT,SAAS,GAAG,SAAS,CAAC;YACxB,CAAC;QACH,CAAC;QAED,QAAQ;YACN,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,G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C;AAsBF;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GACuD,CACxE,KAAS,EACT,IAAuB,EACkB,EAAE;IAC3C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC/C,MAAmC,CAAC,GAAG,GAAG,MAAM,CAAC;IAClD,OAAO,MAAiD,CAAC;AAC3D,CAAC,CAAC;AASF;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB;;OAEG;IACH,OAAO,EACL,CAAI,MAAsB,EAAiB,EAAE,CAC7C,GAAG,EAAE,CACH,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC;IAE3B;;OAEG;IACH,GAAG,EAAE,CAAI,MAAsB,EAAK,EAAE,CACpC,OAAO,MAAM,IAAI,UAAU,CAAC,CAAC,CAAE,MAAwB,EAAE,CAAC,CAAC,CAAC,MAAM;IAEpE;;OAEG;IACH,IAAI,CAAI,MAAsB;QAC5B,MAAM,aAAa,GAAG,aAAa,CAAC;QACpC,aAAa,GAAG,IAAI,CAAC;QAErB,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC1B,CAAC;gBAAS,CAAC;YACT,aAAa,GAAG,aAAa,CAAC;QAChC,CAAC;IACH,CAAC;CACF,CAAC"}
|
package/package.json
CHANGED
package/src/mod.ts
CHANGED
package/src/renderer.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Component } from "./component.js";
|
|
2
|
-
import {
|
|
2
|
+
import { SignalLike, useEffect, useScope, useSubscope } from "./scope.js";
|
|
3
3
|
|
|
4
4
|
interface Renderer {
|
|
5
5
|
_component?: Component;
|
|
6
6
|
_svg?: boolean;
|
|
7
7
|
_nodes?: IterableIterator<Node>;
|
|
8
|
-
_ifConditions:
|
|
8
|
+
_ifConditions: SignalLike<boolean | undefined>[];
|
|
9
9
|
|
|
10
10
|
_node<N extends Node>(fallback: () => N): N;
|
|
11
11
|
}
|
package/src/scope.ts
CHANGED
|
@@ -96,6 +96,7 @@ const createScope = (parent?: Scope): Scope => {
|
|
|
96
96
|
for (let i = this._effects.length - 1; i >= 0; i--) {
|
|
97
97
|
const effect = this._effects[i];
|
|
98
98
|
effect._clean?.();
|
|
99
|
+
effect._run = () => {}
|
|
99
100
|
|
|
100
101
|
effect._deps.forEach((signal) => signal._effects.delete(effect));
|
|
101
102
|
effect._deps.clear();
|
|
@@ -234,13 +235,12 @@ export const useEffect = (
|
|
|
234
235
|
currEffect = this;
|
|
235
236
|
|
|
236
237
|
try {
|
|
237
|
-
|
|
238
|
-
// For automatic dependency tracking
|
|
239
|
-
// clean up dependencies and listeners
|
|
238
|
+
// Clean up dependencies and listeners
|
|
240
239
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
240
|
+
this._deps.forEach((dep) => dep._effects.delete(this));
|
|
241
|
+
this._deps.clear();
|
|
242
|
+
|
|
243
|
+
if (deps) {
|
|
244
244
|
// Track specified dependencies
|
|
245
245
|
|
|
246
246
|
deps.forEach((dep) => dep());
|