Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@iatools/rxdom

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iatools/rxdom - npm Package Compare versions

Comparing version 0.5.0 to 0.5.1

94

dist/index.d.ts

@@ -7,5 +7,2 @@ declare type NodeProps = {

declare type Attrs = Record<string, any>;
declare type ValueOf<T> = T[keyof T];
declare type OptionalPick<T, K extends keyof T> = Partial<Pick<T, K>>;
declare type RequiredKeys<T, K extends keyof T> = Partial<T> & Required<OptionalPick<T, K>>;
declare type Unsubscribe = () => void;

@@ -15,3 +12,3 @@

props: Attrs & {
content: RxNode[];
content?: RxNode[];
key: string;

@@ -24,3 +21,3 @@ };

provider?: ContextProvider;
consumer: Record<keyof C, ContextProvider<ValueOf<C>>>;
consumer: Record<keyof C, ContextSelector>;
};

@@ -33,18 +30,12 @@ template: RxComponentTemplate<S, P, C>;

};
render?: (props: P, context: C) => RxNode;
render?: (args: {
props: NodeProps & P;
context: C;
fiber: FiberComponent;
}) => RxNode;
};
interface RxFragment extends RxBase {
type: keyof HTMLElementTagNameMap | "text" | "context";
type: keyof HTMLElementTagNameMap | "text" | "element";
}
interface RxElement extends RxBase {
type: "element";
template: {
onUpdate: (props: {
fiber: FiberInstance;
dom: DOMElement;
}) => DOMElement;
dom: DOMElement;
};
}
declare type RxNode = RxFragment | RxComponent | RxElement;
declare type RxNode = RxComponent | RxFragment;
declare type DOMElement = HTMLElement | Text;

@@ -63,24 +54,4 @@ interface FiberBase {

}
interface FiberElement extends FiberBase {
node: RxElement;
}
declare type FiberInstance = FiberComponent | FiberFragment | FiberElement;
declare type FiberInstance = FiberComponent | FiberFragment;
declare type Provider = FiberComponent;
declare type Consumer = FiberComponent;
declare type Callback = (attrs: Attrs) => void;
declare class ContextProvider<V extends Attrs = Attrs> {
private key;
providerConsumers: Map<Provider, Map<Consumer, Callback>>;
registerProvider(provider: Provider): Unsubscribe;
private unregisterProvider;
registerConsumer(provider: Provider, consumer: Consumer, cb: Callback): Unsubscribe;
private unregisterConsumer;
getValue(provider: Provider): {
[k: string]: any;
};
Context(props: NodeProps & V): RxComponent;
}
declare const createProvider: <P extends Attrs>() => ContextProvider<P>;
interface Renderer {

@@ -113,3 +84,3 @@ render: (root: FiberInstance, dom: DOMElement, fiber?: FiberInstance, node?: RxNode) => FiberInstance | undefined;

setState(update: S | ((s: S) => S)): void;
setProps(node: RxComponent): FiberComponent;
setProps(node: RxComponent): void;
protected onMount(): void | (() => void);

@@ -122,3 +93,3 @@ mount(): void;

render(): RxNode;
static FC: <S_1 extends Attrs, P_1 extends Attrs, C_1 extends Attrs>(constructor: new (config: ComponentConfig) => Component<S_1, P_1, C_1>, consumer?: Record<keyof C_1, ContextProvider<ValueOf<C_1>>>) => (props: P_1 & {
static compose: <S_1 extends Attrs, P_1 extends Attrs, C_1 extends Attrs>(constructor: new (config: ComponentConfig) => Component<S_1, P_1, C_1>, consumer?: Record<keyof C_1, ContextSelector>) => (props: P_1 & {
content?: (RxNode | (string | number | boolean))[] | undefined;

@@ -130,11 +101,42 @@ key?: string | undefined;

}
declare const FC: <P extends Attrs = Attrs, C extends Attrs = Attrs>(render: ((props: P, context: C) => RxNode) | undefined, consumer?: Record<keyof C, ContextProvider<ValueOf<C>>>) => (props?: Props<P>) => RxComponent<any, any, any>;
declare const composeFunction: <P extends Attrs = Attrs, C extends Attrs = Attrs>(render: (args: {
props: {
content?: (RxNode | (string | number | boolean))[] | undefined;
key?: string | undefined;
} & Attrs & P;
context: C;
fiber: FiberComponent;
}) => RxNode, consumer?: Record<keyof C, ContextSelector>) => (props?: Props<P>) => RxComponent<any, any, any>;
declare class ContextProvider {
providerConsumers: Map<FiberComponent, Set<Callback>>;
registerProvider(fiber: FiberComponent): Unsubscribe;
private unregisterProvider;
registerConsumer(fiber: FiberComponent, cb: Callback): Unsubscribe;
private unregisterConsumer;
accessValue(fiber: FiberComponent): {
[k: string]: any;
};
}
declare const composeContext: <P extends Attrs = Attrs, C extends Attrs = Attrs>(render: (args: {
props: {
content?: (RxNode | (string | number | boolean))[] | undefined;
key?: string | undefined;
} & Attrs & P;
context: C;
fiber: FiberComponent;
}) => RxNode, consumer?: Record<keyof C, ContextSelector>) => readonly [(props?: Props<P>) => RxComponent<any, any, any>, <T = P>(selector?: (props: P) => T) => ContextSelector];
declare type ContextSelector = {
contextProvider: ContextProvider;
selector: (s: any) => any;
};
declare type Callback = (attrs: Attrs) => void;
declare type Props<P> = P & NodeProps;
declare const createElement: (template: RequiredKeys<RxElement["template"], "dom">) => RxElement;
declare type FragmentProps = Partial<Attrs & Partial<GlobalEventHandlers> & {
style?: Partial<CSSStyleDeclaration>;
} & NodeProps>;
declare const context: (props?: Partial<FragmentProps>) => RxFragment;
declare const el: (props: {
dom: DOMElement;
key?: string;
}) => RxFragment;
declare const a: (props?: Partial<FragmentProps>) => RxFragment;

@@ -265,2 +267,2 @@ declare const abbr: (props?: Partial<FragmentProps>) => RxFragment;

export { Component, FC, Renderer, RxDOM, SyncRenderer, a, abbr, address, area, article, aside, audio, b, base, bdi, bdo, blockquote, body, br, button, canvas, caption, cite, code, col, colgroup, context, createElement, createProvider, data, datalist, dd, del, details, dfn, dialog, dir, div, dl, dt, em, embed, fieldset, figcaption, figure, font, footer, form, frame, frameset, h1, h2, h3, h4, h5, h6, head, header, hgroup, hr, html, i, iframe, img, input, ins, kbd, label, legend, li, link, main, map, mark, marquee, menu, meta, meter, nav, noscript, object, ol, optgroup, option, output, p, param, picture, pre, progress, q, rp, rt, ruby, s, samp, script, section, select, slot, small, source, span, strong, style, sub, summary, sup, table, tbody, td, template, textarea, tfoot, th, thead, time, title, tr, track, u, ul, video, wbr };
export { Component, Renderer, RxDOM, SyncRenderer, a, abbr, address, area, article, aside, audio, b, base, bdi, bdo, blockquote, body, br, button, canvas, caption, cite, code, col, colgroup, composeContext, composeFunction, data, datalist, dd, del, details, dfn, dialog, dir, div, dl, dt, el, em, embed, fieldset, figcaption, figure, font, footer, form, frame, frameset, h1, h2, h3, h4, h5, h6, head, header, hgroup, hr, html, i, iframe, img, input, ins, kbd, label, legend, li, link, main, map, mark, marquee, menu, meta, meter, nav, noscript, object, ol, optgroup, option, output, p, param, picture, pre, progress, q, rp, rt, ruby, s, samp, script, section, select, slot, small, source, span, strong, style, sub, summary, sup, table, tbody, td, template, textarea, tfoot, th, thead, time, title, tr, track, u, ul, video, wbr };

@@ -1,1 +0,1 @@

"use strict";var f=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var I=(n,e,o)=>e in n?f(n,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[e]=o;var U=(n,e)=>{for(var o in e)f(n,o,{get:e[o],enumerable:!0})},K=(n,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of M(e))!O.call(n,p)&&p!==o&&f(n,p,{get:()=>e[p],enumerable:!(r=w(e,p))||r.enumerable});return n};var q=n=>K(f({},"__esModule",{value:!0}),n);var F=(n,e,o)=>(I(n,typeof e!="symbol"?e+"":e,o),o);var Qe={};U(Qe,{Component:()=>a,FC:()=>T,RxDOM:()=>C,SyncRenderer:()=>d,a:()=>H,abbr:()=>$,address:()=>G,area:()=>L,article:()=>_,aside:()=>B,audio:()=>z,b:()=>J,base:()=>Q,bdi:()=>W,bdo:()=>X,blockquote:()=>Y,body:()=>Z,br:()=>tt,button:()=>et,canvas:()=>ot,caption:()=>rt,cite:()=>nt,code:()=>st,col:()=>pt,colgroup:()=>ct,context:()=>P,createElement:()=>y,createProvider:()=>N,data:()=>it,datalist:()=>at,dd:()=>mt,del:()=>xt,details:()=>dt,dfn:()=>lt,dialog:()=>ut,dir:()=>ht,div:()=>ft,dl:()=>bt,dt:()=>yt,em:()=>Ct,embed:()=>gt,fieldset:()=>Pt,figcaption:()=>Rt,figure:()=>Ft,font:()=>vt,footer:()=>kt,form:()=>At,frame:()=>Et,frameset:()=>Tt,h1:()=>Nt,h2:()=>St,h3:()=>wt,h4:()=>Mt,h5:()=>Ot,h6:()=>It,head:()=>Ut,header:()=>Kt,hgroup:()=>qt,hr:()=>Dt,html:()=>jt,i:()=>Vt,iframe:()=>Ht,img:()=>$t,input:()=>Gt,ins:()=>Lt,kbd:()=>_t,label:()=>Bt,legend:()=>zt,li:()=>Jt,link:()=>Qt,main:()=>Wt,map:()=>Xt,mark:()=>Yt,marquee:()=>Zt,menu:()=>te,meta:()=>ee,meter:()=>oe,nav:()=>re,noscript:()=>ne,object:()=>se,ol:()=>pe,optgroup:()=>ce,option:()=>ie,output:()=>ae,p:()=>me,param:()=>xe,picture:()=>de,pre:()=>le,progress:()=>ue,q:()=>he,rp:()=>fe,rt:()=>be,ruby:()=>ye,s:()=>Ce,samp:()=>ge,script:()=>Pe,section:()=>Re,select:()=>Fe,slot:()=>ve,small:()=>ke,source:()=>Ae,span:()=>Ee,strong:()=>Te,style:()=>Ne,sub:()=>Se,summary:()=>we,sup:()=>Me,table:()=>Oe,tbody:()=>Ie,td:()=>Ue,template:()=>Ke,textarea:()=>qe,tfoot:()=>De,th:()=>je,thead:()=>Ve,time:()=>He,title:()=>$e,tr:()=>Ge,track:()=>Le,u:()=>_e,ul:()=>Be,video:()=>ze,wbr:()=>Je});module.exports=q(Qe);var x=({content:n=[],key:e=l(),...o})=>({...o,content:n.map(r=>typeof r=="object"?r:D(r)),key:e}),D=n=>({type:"text",props:{nodeValue:n.toString(),content:[],key:"text"}});function g(n,e,o){Object.keys(e).filter(v).filter(A(e,o)).forEach(r=>n[r]=null),Object.keys(o).filter(v).filter(k(e,o)).forEach(r=>n[r]=o[r]),n instanceof HTMLElement&&(e.style=e.style||{},o.style=o.style||{},Object.keys(o.style).filter(k(e.style,o.style)).forEach(r=>n.style[r]=o.style[r]),Object.keys(e.style).filter(A(e.style,o.style)).forEach(r=>n.style[r]=""))}var j=n=>n==="style",v=n=>n!=="content"&&!j(n),k=(n,e)=>o=>n[o]!==e[o],A=(n,e)=>o=>!(o in e),l=()=>Date.now().toString(36)+Math.random().toString(36).substring(2),E=(n,e)=>Object.fromEntries(Object.entries(n).filter(([o])=>!e.includes(o)));var a=class{unsubscribes=[];renderer;template;fiber;state;props;context;constructor({renderer:e,fiber:o}){this.renderer=e,this.template=o.node.template,this.fiber=o,this.state={},this.props=o.node.props,this.context=this.initContext()}initContext(){let{provider:e,consumer:o}=this.fiber.node.context;e&&this.unsubscribes.push(e.registerProvider(this.fiber));let r=new Map(Object.entries(o).map(([c,i])=>[i,c])),p={},s=c=>{if(!!c){if("component"in c&&c.node.context.provider){let i=c.node.context.provider,m=r.get(i);m&&(r.delete(i),this.unsubscribes.push(i.registerConsumer(c,this.fiber,h=>this.setContext(S=>({...S,[m]:h})))),p[m]=i.getValue(c))}return s(c.parent)}};return s(this.fiber.parent),p}removeContext(){this.unsubscribes.forEach(e=>e())}setContext(e){this.context=typeof e=="function"?e(this.context):e,this.update(this.fiber.node)}setState(e){this.state=typeof e=="function"?e(this.state):e,this.update(this.fiber.node)}setProps(e){return this.props=e.props,this.update(e)}onMount(){}mount(){setTimeout(()=>{let e=this.onMount();e&&(this.onUnmount=e)})}onUnmount(){}unmount(){this.onUnmount&&this.onUnmount(),this.removeContext()}onUpdate(){}update(e){this.fiber.node=e;let o=this.renderer.render(this.fiber,this.fiber.dom.parentNode,this.fiber.content[0],this.render());return this.fiber.dom=o.dom,this.fiber.content=[o],setTimeout(()=>this.onUpdate()),this.fiber}render(){if(!this.template.render)throw new Error("Todo - render expected");return this.template.render(this.props,this.context)}};F(a,"FC",(e,o={})=>r=>b({constructor:e},{props:r,context:{consumer:o}}));var T=(n,e={})=>{let o=l();return(r={})=>b({render:n,constructor:a},{props:{key:o,...r},context:{consumer:e}})},b=(n,e)=>{let{props:o,context:r}=e;return{type:"component",props:x(o),context:r,template:{...n}}};var y=n=>({type:"element",props:x({}),template:{onUpdate:()=>n.dom,...n}});var V=(n,{key:e=n,...o}={})=>({type:n,props:x({key:e,...o})}),t=n=>(e={})=>V(n,e),P=t("context"),H=t("a"),$=t("abbr"),G=t("address"),L=t("area"),_=t("article"),B=t("aside"),z=t("audio"),J=t("b"),Q=t("base"),W=t("bdi"),X=t("bdo"),Y=t("blockquote"),Z=t("body"),tt=t("br"),et=t("button"),ot=t("canvas"),rt=t("caption"),nt=t("cite"),st=t("code"),pt=t("col"),ct=t("colgroup"),it=t("data"),at=t("datalist"),mt=t("dd"),xt=t("del"),dt=t("details"),lt=t("dfn"),ut=t("dialog"),ht=t("dir"),ft=t("div"),bt=t("dl"),yt=t("dt"),Ct=t("em"),gt=t("embed"),Pt=t("fieldset"),Rt=t("figcaption"),Ft=t("figure"),vt=t("font"),kt=t("footer"),At=t("form"),Et=t("frame"),Tt=t("frameset"),Nt=t("h1"),St=t("h2"),wt=t("h3"),Mt=t("h4"),Ot=t("h5"),It=t("h6"),Ut=t("head"),Kt=t("header"),qt=t("hgroup"),Dt=t("hr"),jt=t("html"),Vt=t("i"),Ht=t("iframe"),$t=t("img"),Gt=t("input"),Lt=t("ins"),_t=t("kbd"),Bt=t("label"),zt=t("legend"),Jt=t("li"),Qt=t("link"),Wt=t("main"),Xt=t("map"),Yt=t("mark"),Zt=t("marquee"),te=t("menu"),ee=t("meta"),oe=t("meter"),re=t("nav"),ne=t("noscript"),se=t("object"),pe=t("ol"),ce=t("optgroup"),ie=t("option"),ae=t("output"),me=t("p"),xe=t("param"),de=t("picture"),le=t("pre"),ue=t("progress"),he=t("q"),fe=t("rp"),be=t("rt"),ye=t("ruby"),Ce=t("s"),ge=t("samp"),Pe=t("script"),Re=t("section"),Fe=t("select"),ve=t("slot"),ke=t("small"),Ae=t("source"),Ee=t("span"),Te=t("strong"),Ne=t("style"),Se=t("sub"),we=t("summary"),Me=t("sup"),Oe=t("table"),Ie=t("tbody"),Ue=t("td"),Ke=t("template"),qe=t("textarea"),De=t("tfoot"),je=t("th"),Ve=t("thead"),He=t("time"),$e=t("title"),Ge=t("tr"),Le=t("track"),_e=t("u"),Be=t("ul"),ze=t("video"),Je=t("wbr");var R=class{key=l();providerConsumers=new Map;registerProvider(e){return this.providerConsumers.has(e)||this.providerConsumers.set(e,new Map),()=>this.unregisterProvider(e)}unregisterProvider(e){this.providerConsumers.delete(e)}registerConsumer(e,o,r){return this.providerConsumers.get(e).set(o,r),()=>this.unregisterConsumer(e,o)}unregisterConsumer(e,o){this.providerConsumers.get(e).delete(o)}getValue(e){return E(e.node.props,["key","content"])}Context(e){return b({constructor:u},{props:{key:this.key,...e},context:{provider:this,consumer:{}}})}},u=class extends a{emitValues(){let e=this.fiber.node.context.provider;if(!e)return;let o=e.providerConsumers.get(this.fiber);if(!o)return;let r=e.getValue(this.fiber);for(let[p,s]of o)s(r)}render(){return this.emitValues(),P(this.props)}},N=()=>new R;var d=class{render=(e,o,r,p)=>{if(r)if(p)if(r.node.props.key!==p.props.key){let s=this.construct(e,p);return o.replaceChild(s.dom,r.dom),r.content.forEach(c=>this.render(r,r.dom,c)),"component"in r&&r.component.unmount(),s}else{if(p.type==="element")return r.dom=p.template.onUpdate({fiber:r,dom:p.template.dom}),r.node=p,r;if(p.type==="component")return r.component.setProps(p);{let s=r;return g(s.dom,s.node.props,p.props),s.content=this.reconcile(s,p),s.node=p,s}}else{r.content.forEach(s=>this.render(r,r.dom,s)),r.dom.remove(),"component"in r&&r.component.unmount();return}else{let s=this.construct(e,p);return o.appendChild(s.dom),s}};reconcile=(e,o)=>{let r=e.dom,p=e.content,s=o.props.content,c=[],i=Math.max(p.length,s.length);for(let m=0;m<i;m++){let h=this.render(e,r,p[m],s[m]);h&&c.push(h)}return c};construct=(e,o)=>{if(o.type==="element")return{dom:o.template.dom,node:o,content:[],parent:e};if(o.type==="component"){let s={node:o,parent:e,content:[]};s.component=new o.template.constructor({renderer:this,fiber:s});let c=this.construct(s,s.component.render());return s.dom=c.dom,s.content=[c],s.component.mount(),s}let r=o.type==="text"?document.createTextNode(""):document.createElement(o.type);g(r,{},o.props);let p={dom:r,node:o,content:[],parent:e};return this.warnDuplicateKeys(p,o.props.content),p.content=o.props.content.map(s=>this.construct(p,s)),p.content.forEach(s=>r.appendChild(s.dom)),p};warnDuplicateKeys(e,o){let r=o.filter(s=>s.type==="component"&&s.template.constructor!==a&&s.template.constructor!==u),p=new Map;r.forEach(({template:{constructor:s},props:c})=>{let i=p.get(c.key)||{name:s.name,count:0};p.set(c.key,{...i,count:i.count+1})});for(let[s,{count:c,name:i}]of p)c>1&&console.warn(`Each class component in a 'content' list should have a unique 'key' prop (detected ${c} ${i}s with key ${s}).`,e)}};var C=class{fiber;renderer;constructor(e=new d){this.renderer=e}render(e,o){let r=this.fiber;this.fiber=this.renderer.render(this.createRoot(o),o,r,e)}createRoot(e){return{dom:e,content:[],node:y({dom:e})}}};0&&(module.exports={Component,FC,RxDOM,SyncRenderer,a,abbr,address,area,article,aside,audio,b,base,bdi,bdo,blockquote,body,br,button,canvas,caption,cite,code,col,colgroup,context,createElement,createProvider,data,datalist,dd,del,details,dfn,dialog,dir,div,dl,dt,em,embed,fieldset,figcaption,figure,font,footer,form,frame,frameset,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,img,input,ins,kbd,label,legend,li,link,main,map,mark,marquee,menu,meta,meter,nav,noscript,object,ol,optgroup,option,output,p,param,picture,pre,progress,q,rp,rt,ruby,s,samp,script,section,select,slot,small,source,span,strong,style,sub,summary,sup,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,u,ul,video,wbr});
"use strict";var u=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var q=Object.prototype.hasOwnProperty;var D=(r,e,o)=>e in r?u(r,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[e]=o;var I=(r,e)=>{for(var o in e)u(r,o,{get:e[o],enumerable:!0})},K=(r,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of M(e))!q.call(r,s)&&s!==o&&u(r,s,{get:()=>e[s],enumerable:!(n=j(e,s))||n.enumerable});return r};var U=r=>K(u({},"__esModule",{value:!0}),r);var v=(r,e,o)=>(D(r,typeof e!="symbol"?e+"":e,o),o);var We={};I(We,{Component:()=>m,RxDOM:()=>y,SyncRenderer:()=>d,a:()=>H,abbr:()=>$,address:()=>G,area:()=>L,article:()=>_,aside:()=>z,audio:()=>J,b:()=>Q,base:()=>W,bdi:()=>X,bdo:()=>Y,blockquote:()=>Z,body:()=>tt,br:()=>et,button:()=>ot,canvas:()=>rt,caption:()=>nt,cite:()=>st,code:()=>ct,col:()=>pt,colgroup:()=>it,composeContext:()=>O,composeFunction:()=>E,data:()=>at,datalist:()=>mt,dd:()=>xt,del:()=>dt,details:()=>lt,dfn:()=>ut,dialog:()=>ht,dir:()=>bt,div:()=>ft,dl:()=>yt,dt:()=>Ct,el:()=>R,em:()=>gt,embed:()=>Ft,fieldset:()=>Pt,figcaption:()=>Rt,figure:()=>vt,font:()=>kt,footer:()=>At,form:()=>Tt,frame:()=>St,frameset:()=>Et,h1:()=>Ot,h2:()=>wt,h3:()=>Nt,h4:()=>jt,h5:()=>Mt,h6:()=>qt,head:()=>Dt,header:()=>It,hgroup:()=>Kt,hr:()=>Ut,html:()=>Vt,i:()=>Bt,iframe:()=>Ht,img:()=>$t,input:()=>Gt,ins:()=>Lt,kbd:()=>_t,label:()=>zt,legend:()=>Jt,li:()=>Qt,link:()=>Wt,main:()=>Xt,map:()=>Yt,mark:()=>Zt,marquee:()=>te,menu:()=>ee,meta:()=>oe,meter:()=>re,nav:()=>ne,noscript:()=>se,object:()=>ce,ol:()=>pe,optgroup:()=>ie,option:()=>ae,output:()=>me,p:()=>xe,param:()=>de,picture:()=>le,pre:()=>ue,progress:()=>he,q:()=>be,rp:()=>fe,rt:()=>ye,ruby:()=>Ce,s:()=>ge,samp:()=>Fe,script:()=>Pe,section:()=>Re,select:()=>ve,slot:()=>ke,small:()=>Ae,source:()=>Te,span:()=>Se,strong:()=>Ee,style:()=>Oe,sub:()=>we,summary:()=>Ne,sup:()=>je,table:()=>Me,tbody:()=>qe,td:()=>De,template:()=>Ie,textarea:()=>Ke,tfoot:()=>Ue,th:()=>Ve,thead:()=>Be,time:()=>He,title:()=>$e,tr:()=>Ge,track:()=>Le,u:()=>_e,ul:()=>ze,video:()=>Je,wbr:()=>Qe});module.exports=U(We);var h=({content:r,key:e=f(),...o})=>({...o,content:r==null?void 0:r.map(n=>typeof n=="object"?n:V(n)),key:e}),V=r=>({type:"text",props:{nodeValue:r.toString(),content:[],key:"text"}});function g(r,e,o){Object.keys(e).filter(k).filter(T(e,o)).forEach(n=>r[n]=null),Object.keys(o).filter(k).filter(A(e,o)).forEach(n=>r[n]=o[n]),r instanceof HTMLElement&&(e.style=e.style||{},o.style=o.style||{},Object.keys(o.style).filter(A(e.style,o.style)).forEach(n=>r.style[n]=o.style[n]),Object.keys(e.style).filter(T(e.style,o.style)).forEach(n=>r.style[n]=""))}var B=r=>r==="style",k=r=>r!=="content"&&!B(r),A=(r,e)=>o=>r[o]!==e[o],T=(r,e)=>o=>!(o in e),b=(r,e)=>r!==null&&typeof r=="object"&&(e!==null&&typeof e=="object")?Object.keys(r).length===Object.keys(e).length&&Object.keys(r).every(s=>e.hasOwnProperty(s)&&r[s]===e[s]):r===e,f=()=>Date.now().toString(36)+Math.random().toString(36).substring(2),S=(r,e)=>Object.fromEntries(Object.entries(r).filter(([o])=>!e.includes(o)));var m=class{unsubscribes=[];renderer;template;fiber;state;props;context;constructor({renderer:e,fiber:o}){this.renderer=e,this.template=o.node.template,this.fiber=o,this.state={},this.props=o.node.props,this.context=this.initContext()}initContext(){let{provider:e,consumer:o}=this.fiber.node.context;e&&this.unsubscribes.push(e.registerProvider(this.fiber));let n=new Map(Object.entries(o).map(([p,{contextProvider:i,selector:a}])=>[i,{key:p,selector:a}])),s={},c=p=>{if(!!p){if("component"in p&&p.node.context.provider){let i=p.node.context.provider,a=n.get(i);if(a){let{key:x,selector:l}=a;n.delete(i),this.unsubscribes.push(i.registerConsumer(p,C=>this.setContext(N=>({...N,[x]:l(C)})))),s[x]=l(i.accessValue(p))}}return c(p.parent)}};return c(this.fiber.parent),s}removeContext(){this.unsubscribes.forEach(e=>e())}setContext(e){let o=typeof e=="function"?e(this.context):e;Object.entries(o).every(([s,c])=>b(this.context[s],c))||(this.context=o,this.update(this.fiber.node))}setState(e){let o=typeof e=="function"?e(this.state):e;b(this.state,o)||(this.state=o,this.update(this.fiber.node))}setProps(e){let o=e.props;b(this.props,o)||(this.props=o,this.update(e))}onMount(){}mount(){setTimeout(()=>{let e=this.onMount();e&&(this.onUnmount=e)})}onUnmount(){}unmount(){this.onUnmount&&this.onUnmount(),this.removeContext()}onUpdate(){}update(e){this.fiber.node=e;let o=this.renderer.render(this.fiber,this.fiber.dom.parentNode,this.fiber.content[0],this.render());this.fiber.dom=o.dom,this.fiber.content=[o],setTimeout(()=>this.onUpdate())}render(){if(!this.template.render)throw new Error("Todo - render expected");return this.template.render({props:this.props,context:this.context,fiber:this.fiber})}};v(m,"compose",(e,o={})=>n=>P({constructor:e},{props:n,context:{consumer:o}}));var E=(r,e={})=>{let o=f();return(n={})=>P({render:r,constructor:m},{props:{key:o,...n},context:{consumer:e}})},F=class{providerConsumers=new Map;registerProvider(e){return this.providerConsumers.has(e)||this.providerConsumers.set(e,new Set),()=>this.unregisterProvider(e)}unregisterProvider(e){this.providerConsumers.delete(e)}registerConsumer(e,o){return this.providerConsumers.get(e).add(o),()=>this.unregisterConsumer(e,o)}unregisterConsumer(e,o){this.providerConsumers.get(e).delete(o)}accessValue(e){return S(e.node.props,["key","content"])}},O=(r,e={})=>{let o=f(),n=new F,s=i=>{let a=i.node.context.provider;if(!a)return;let x=a.providerConsumers.get(i);if(!x)return;let l=a.accessValue(i);for(let C of x)C(l)};return[(i={})=>P({constructor:m,render:a=>(s(a.fiber),r(a))},{props:{key:o,...i},context:{provider:n,consumer:e}}),(i=a=>a)=>({contextProvider:n,selector:i})]},P=(r,e)=>{let{props:o,context:n}=e;return{type:"component",props:h(o),context:n,template:{...r}}};var w=(r,{key:e=r,...o}={})=>({type:r,props:h({key:e,...o})}),t=r=>(e={})=>w(r,e),R=r=>w("element",r),H=t("a"),$=t("abbr"),G=t("address"),L=t("area"),_=t("article"),z=t("aside"),J=t("audio"),Q=t("b"),W=t("base"),X=t("bdi"),Y=t("bdo"),Z=t("blockquote"),tt=t("body"),et=t("br"),ot=t("button"),rt=t("canvas"),nt=t("caption"),st=t("cite"),ct=t("code"),pt=t("col"),it=t("colgroup"),at=t("data"),mt=t("datalist"),xt=t("dd"),dt=t("del"),lt=t("details"),ut=t("dfn"),ht=t("dialog"),bt=t("dir"),ft=t("div"),yt=t("dl"),Ct=t("dt"),gt=t("em"),Ft=t("embed"),Pt=t("fieldset"),Rt=t("figcaption"),vt=t("figure"),kt=t("font"),At=t("footer"),Tt=t("form"),St=t("frame"),Et=t("frameset"),Ot=t("h1"),wt=t("h2"),Nt=t("h3"),jt=t("h4"),Mt=t("h5"),qt=t("h6"),Dt=t("head"),It=t("header"),Kt=t("hgroup"),Ut=t("hr"),Vt=t("html"),Bt=t("i"),Ht=t("iframe"),$t=t("img"),Gt=t("input"),Lt=t("ins"),_t=t("kbd"),zt=t("label"),Jt=t("legend"),Qt=t("li"),Wt=t("link"),Xt=t("main"),Yt=t("map"),Zt=t("mark"),te=t("marquee"),ee=t("menu"),oe=t("meta"),re=t("meter"),ne=t("nav"),se=t("noscript"),ce=t("object"),pe=t("ol"),ie=t("optgroup"),ae=t("option"),me=t("output"),xe=t("p"),de=t("param"),le=t("picture"),ue=t("pre"),he=t("progress"),be=t("q"),fe=t("rp"),ye=t("rt"),Ce=t("ruby"),ge=t("s"),Fe=t("samp"),Pe=t("script"),Re=t("section"),ve=t("select"),ke=t("slot"),Ae=t("small"),Te=t("source"),Se=t("span"),Ee=t("strong"),Oe=t("style"),we=t("sub"),Ne=t("summary"),je=t("sup"),Me=t("table"),qe=t("tbody"),De=t("td"),Ie=t("template"),Ke=t("textarea"),Ue=t("tfoot"),Ve=t("th"),Be=t("thead"),He=t("time"),$e=t("title"),Ge=t("tr"),Le=t("track"),_e=t("u"),ze=t("ul"),Je=t("video"),Qe=t("wbr");var d=class{render=(e,o,n,s)=>{if(n)if(s)if(n.node.props.key!==s.props.key){let c=this.construct(e,s);return o.replaceChild(c.dom,n.dom),n.content.forEach(p=>this.render(n,n.dom,p)),"component"in n&&n.component.unmount(),c}else if(s.type==="component"){let c=n;return c.component.setProps(s),c}else{if(s.type==="element")return n.node=s,n;{let c=n;return g(c.dom,c.node.props,s.props),c.content=this.reconcile(c,s),c.node=s,c}}else{n.content.forEach(c=>this.render(n,n.dom,c)),n.dom.remove(),"component"in n&&n.component.unmount();return}else{let c=this.construct(e,s);return o.appendChild(c.dom),c}};reconcile=(e,o)=>{let n=e.dom,s=e.content,c=o.props.content||[],p=[],i=Math.max(s.length,c.length);for(let a=0;a<i;a++){let x=this.render(e,n,s[a],c[a]);x&&p.push(x)}return p};construct=(e,o)=>{if(o.type==="component"){let p={node:o,parent:e,content:[]};p.component=new o.template.constructor({renderer:this,fiber:p});let i=this.construct(p,p.component.render());return p.dom=i.dom,p.content=[i],p.component.mount(),p}if(o.type==="element")return{dom:o.props.dom,node:o,content:[],parent:e};let n=o.type==="text"?document.createTextNode(""):document.createElement(o.type);g(n,{},o.props);let s={dom:n,node:o,content:[],parent:e},c=o.props.content||[];return this.warnDuplicateKeys(s,c),s.content=c.map(p=>this.construct(s,p)),s.content.forEach(p=>n.appendChild(p.dom)),s};warnDuplicateKeys(e,o){let n=o.filter(c=>c.type==="component"&&c.template.constructor!==m),s=new Map;n.forEach(({template:{constructor:c},props:p})=>{let i=s.get(p.key)||{name:c.name,count:0};s.set(p.key,{...i,count:i.count+1})});for(let[c,{count:p,name:i}]of s)p>1&&console.warn(`Each class component in a 'content' list should have a unique 'key' prop (detected ${p} ${i}s with key ${c}).`,e)}};var y=class{fiber;renderer;constructor(e=new d){this.renderer=e}render(e,o){let n=this.fiber;this.fiber=this.renderer.render(this.createRoot(o),o,n,e)}createRoot(e){return{dom:e,content:[],node:R({dom:e})}}};0&&(module.exports={Component,RxDOM,SyncRenderer,a,abbr,address,area,article,aside,audio,b,base,bdi,bdo,blockquote,body,br,button,canvas,caption,cite,code,col,colgroup,composeContext,composeFunction,data,datalist,dd,del,details,dfn,dialog,dir,div,dl,dt,el,em,embed,fieldset,figcaption,figure,font,footer,form,frame,frameset,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,img,input,ins,kbd,label,legend,li,link,main,map,mark,marquee,menu,meta,meter,nav,noscript,object,ol,optgroup,option,output,p,param,picture,pre,progress,q,rp,rt,ruby,s,samp,script,section,select,slot,small,source,span,strong,style,sub,summary,sup,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,u,ul,video,wbr});
{
"name": "@iatools/rxdom",
"version": "0.5.0",
"version": "0.5.1",
"description": "",

@@ -24,3 +24,4 @@ "main": "dist/index.js",

"build": "tsup src/index.ts --format esm,cjs --dts --minify",
"preview": "vite preview"
"preview": "vite preview",
"prepublish": "npm run build"
},

@@ -27,0 +28,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc