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

react-solid-flow

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

react-solid-flow - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

5

CHANGELOG.md

@@ -9,2 +9,7 @@ # managed-timeout changelog

## [0.2.2] - 2023-01-25
### Changed
- actually change react jsx-runtime back to classic in the bundle,
because of the issue with webpack5 mjs imports
## [0.2.1] - 2023-01-24

@@ -11,0 +16,0 @@ ### Changed

3

dist/components/Await.d.ts

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

import React from 'react';
import { ReactNode } from "react";

@@ -14,3 +15,3 @@ import { ResourceLike } from "../models/Resource";

/** Component for displaying a Resource */
export declare function Await<T>(props: AwaitProps<T>): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null;
export declare function Await<T>(props: AwaitProps<T>): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
export {};

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

import React from 'react';
import { Component } from "react";

@@ -23,4 +24,4 @@ import type { ReactNode } from "react";

resetError(): void;
render(): ReactNode;
render(): React.ReactNode;
}
export {};

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

(function(t,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],a):(t=typeof globalThis<"u"?globalThis:t||self,a(t["react-solid-flow"]={},t.jsxRuntime,t.React,t.ReactDOM))})(this,function(t,a,o,T){"use strict";var Q=Object.defineProperty;var W=(t,a,o)=>a in t?Q(t,a,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[a]=o;var d=(t,a,o)=>(W(t,typeof a!="symbol"?a+"":a,o),o);function E(e){return e==null?null:o.isValidElement(e)?e:a.jsx(a.Fragment,{children:e})}function R({children:e,each:r,fallback:n=null}){if(!Array.isArray(r)||!r.length||e==null)return E(n);if(typeof e!="function")return a.jsx(a.Fragment,{children:r.map((s,l)=>a.jsx(o.Fragment,{children:e},l))});const u=[];for(let s=0;s<r.length;s++){const l=e(r[s],s);l!=null&&(!o.isValidElement(l)||!l.key?u.push(a.jsx(o.Fragment,{children:l},s)):u.push(l))}return u.length?a.jsx(a.Fragment,{children:u}):E(n)}function w(e,...r){return e instanceof Function?E(e(...r)):E(e)}function D({fallback:e=null,...r}){return r.when?w(r.children,r.when):E(e)}function P(e){for(const r of o.Children.toArray(e.children))if(o.isValidElement(r)&&r.props.when)return r;return E(e.fallback)}function N({when:e,children:r}){return e?w(r,e):null}class k extends o.Component{constructor(n){super(n);d(this,"state",{error:void 0});this.resetError=this.resetError.bind(this)}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,u){var s,l;(l=(s=this.props).onCatch)==null||l.call(s,n,u),this.setState({error:n})}resetError(){this.setState({error:void 0})}render(){return this.state.error===void 0?this.props.children:this.props.fallback instanceof Function?this.props.fallback(this.state.error,this.resetError):this.props.fallback}}const L=o.forwardRef,V=L(function({component:r,...n},u){return r?a.jsx(r,{...n,ref:u}):null});function j({mount:e,...r}){const n=e==null||e instanceof Element||e instanceof DocumentFragment?e:document.querySelector(e);return n?T.createPortal(r.children,n):null}function q(e){return e.for.loading?w(e.fallback):e.for.error!=null?w(e.catch,e.for.error):w(e.children,e.for.data)}class h{constructor(r,n){d(this,"loading");d(this,"data");d(this,"error");d(this,"state");d(this,"latest");this.data=r==null?void 0:r.data,this.error=r==null?void 0:r.error,this.loading=!!(r!=null&&r.loading),this.data!==void 0?this.latest=this.data:this.latest=n==null?void 0:n.latest,this.state=h.getState(this)}static from(r,n){const u=r instanceof Promise;return new h(u?{loading:!0}:{data:r,loading:!!n})}static getState(r){return r.data!==void 0&&r.loading?"refreshing":r.loading?"pending":r.error!==void 0?"errored":r.data!==void 0?"ready":"unresolved"}}class M extends Error{constructor(n="The operation was aborted."){super(n);d(this,"name","AbortError");d(this,"code",20)}}class F extends Error{constructor(){super(...arguments);d(this,"name","NullishError")}}function O(e,r){return o.useReducer(J,[e,r],p)}function p(e){const[r,n=!1]=e,u=r instanceof Function?r():r;return h.from(u,!n)}function J(e,r){switch(r==null?void 0:r.type){case"PEND":return new h({loading:!0,error:void 0,data:e.data},e);case"RESOLVE":return new h({...e,loading:!1,error:void 0,data:r.payload},e);case"SYNC-RESULT":return new h({loading:!1,error:void 0,data:r.payload},e);case"REJECT":return new h({loading:!1,error:r.payload??new F("resource rejected with a nullish error",{cause:r.payload}),data:void 0},e);default:return e}}function U(e,r=[],{initialValue:n,onCompleted:u,onError:s,skipFirstRun:l=!1,skip:v=!1,skipFnMemoization:B}={}){const i=o.useRef(),C=o.useRef(l),[z,y]=O(n,v||l),I=o.useCallback(c=>{var f;(f=i.current)==null||f.abort(),i.current=new AbortController,y({type:"SYNC-RESULT",payload:c})},[y]),S=o.useCallback((c,...f)=>{let b;const m=i.current;try{if(m==null)throw new Error("resource state error, abort controller is null during the fetch operation");return b=e(...f,{signal:m.signal,refetching:c}),b instanceof Promise?K(b):y({type:"SYNC-RESULT",payload:b}),b}catch(A){if(y({type:"REJECT",payload:A}),c)throw A;return}async function K(A){y({type:"PEND"});try{const g=await A;if(m!==i.current)return;y({type:"RESOLVE",payload:g}),u==null||u(g)}catch(g){if(Y(g)||m!==i.current)return;y({type:"REJECT",payload:g}),s==null||s(g)}}},B?[e]:[]),G=o.useCallback((...c)=>{var f;return(f=i.current)==null||f.abort(),i.current=new AbortController,S(!0,...c)},[S]),H=o.useCallback(c=>{var f;(f=i.current)==null||f.abort(c)},[]);return o.useEffect(()=>{C.current=l,i.current||(i.current=new AbortController)},[l]),o.useEffect(()=>{if(C.current){C.current=!1;return}if(!v)return S(!1,...r),()=>{var c;(c=i.current)==null||c.abort(),i.current=new AbortController}},[...r,v,S]),[z,{mutate:I,refetch:G,abort:H}]}function Y(e){return e!=null&&e.name==="AbortError"}t.AbortError=M,t.Await=q,t.Dynamic=V,t.ErrorBoundary=k,t.For=R,t.Match=N,t.NullishError=F,t.Portal=j,t.Resource=h,t.Show=D,t.Switch=P,t.useResource=U,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
(function(o,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],t):(o=typeof globalThis<"u"?globalThis:o||self,t(o["react-solid-flow"]={},o.React,o.ReactDOM))})(this,function(o,t,h){"use strict";var Q=Object.defineProperty;var W=(o,t,h)=>t in o?Q(o,t,{enumerable:!0,configurable:!0,writable:!0,value:h}):o[t]=h;var f=(o,t,h)=>(W(o,typeof t!="symbol"?t+"":t,h),h);function y(e){return e==null?null:t.isValidElement(e)?e:t.createElement(t.Fragment,null,e)}function T({children:e,each:r,fallback:n=null}){if(!Array.isArray(r)||!r.length||e==null)return y(n);if(typeof e!="function")return t.createElement(t.Fragment,null,r.map((u,l)=>t.createElement(t.Fragment,{key:l},e)));const a=[];for(let u=0;u<r.length;u++){const l=e(r[u],u);l!=null&&(!t.isValidElement(l)||!l.key?a.push(t.createElement(t.Fragment,{key:u},l)):a.push(l))}return a.length?t.createElement(t.Fragment,null,a):y(n)}function m(e,...r){return e instanceof Function?y(e(...r)):y(e)}function D({fallback:e=null,...r}){return r.when?m(r.children,r.when):y(e)}function P(e){for(const r of t.Children.toArray(e.children))if(t.isValidElement(r)&&r.props.when)return r;return y(e.fallback)}function k({when:e,children:r}){return e?m(r,e):null}class N extends t.Component{constructor(n){super(n);f(this,"state",{error:void 0});this.resetError=this.resetError.bind(this)}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,a){var u,l;(l=(u=this.props).onCatch)==null||l.call(u,n,a),this.setState({error:n})}resetError(){this.setState({error:void 0})}render(){return this.state.error===void 0?this.props.children:this.props.fallback instanceof Function?this.props.fallback(this.state.error,this.resetError):this.props.fallback}}const L=t.forwardRef,V=L(function({component:r,...n},a){return r?t.createElement(r,{...n,ref:a}):null});function M({mount:e,...r}){const n=e==null||e instanceof Element||e instanceof DocumentFragment?e:document.querySelector(e);return n?h.createPortal(r.children,n):null}function O(e){return e.for.loading?m(e.fallback):e.for.error!=null?m(e.catch,e.for.error):m(e.children,e.for.data)}class d{constructor(r,n){f(this,"loading");f(this,"data");f(this,"error");f(this,"state");f(this,"latest");this.data=r==null?void 0:r.data,this.error=r==null?void 0:r.error,this.loading=!!(r!=null&&r.loading),this.data!==void 0?this.latest=this.data:this.latest=n==null?void 0:n.latest,this.state=d.getState(this)}static from(r,n){const a=r instanceof Promise;return new d(a?{loading:!0}:{data:r,loading:!!n})}static getState(r){return r.data!==void 0&&r.loading?"refreshing":r.loading?"pending":r.error!==void 0?"errored":r.data!==void 0?"ready":"unresolved"}}class j extends Error{constructor(n="The operation was aborted."){super(n);f(this,"name","AbortError");f(this,"code",20)}}class F extends Error{constructor(){super(...arguments);f(this,"name","NullishError")}}function p(e,r){return t.useReducer(J,[e,r],q)}function q(e){const[r,n=!1]=e,a=r instanceof Function?r():r;return d.from(a,!n)}function J(e,r){switch(r==null?void 0:r.type){case"PEND":return new d({loading:!0,error:void 0,data:e.data},e);case"RESOLVE":return new d({...e,loading:!1,error:void 0,data:r.payload},e);case"SYNC-RESULT":return new d({loading:!1,error:void 0,data:r.payload},e);case"REJECT":return new d({loading:!1,error:r.payload??new F("resource rejected with a nullish error",{cause:r.payload}),data:void 0},e);default:return e}}function U(e,r=[],{initialValue:n,onCompleted:a,onError:u,skipFirstRun:l=!1,skip:v=!1,skipFnMemoization:B}={}){const i=t.useRef(),C=t.useRef(l),[z,E]=p(n,v||l),I=t.useCallback(s=>{var c;(c=i.current)==null||c.abort(),i.current=new AbortController,E({type:"SYNC-RESULT",payload:s})},[E]),b=t.useCallback((s,...c)=>{let w;const S=i.current;try{if(S==null)throw new Error("resource state error, abort controller is null during the fetch operation");return w=e(...c,{signal:S.signal,refetching:s}),w instanceof Promise?K(w):E({type:"SYNC-RESULT",payload:w}),w}catch(A){if(E({type:"REJECT",payload:A}),s)throw A;return}async function K(A){E({type:"PEND"});try{const g=await A;if(S!==i.current)return;E({type:"RESOLVE",payload:g}),a==null||a(g)}catch(g){if(Y(g)||S!==i.current)return;E({type:"REJECT",payload:g}),u==null||u(g)}}},B?[e]:[]),G=t.useCallback((...s)=>{var c;return(c=i.current)==null||c.abort(),i.current=new AbortController,b(!0,...s)},[b]),H=t.useCallback(s=>{var c;(c=i.current)==null||c.abort(s)},[]);return t.useEffect(()=>{C.current=l,i.current||(i.current=new AbortController)},[l]),t.useEffect(()=>{if(C.current){C.current=!1;return}if(!v)return b(!1,...r),()=>{var s;(s=i.current)==null||s.abort(),i.current=new AbortController}},[...r,v,b]),[z,{mutate:I,refetch:G,abort:H}]}function Y(e){return e!=null&&e.name==="AbortError"}o.AbortError=j,o.Await=O,o.Dynamic=V,o.ErrorBoundary=N,o.For=T,o.Match=k,o.NullishError=F,o.Portal=M,o.Resource=d,o.Show=D,o.Switch=P,o.useResource=U,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
{
"name": "react-solid-flow",
"version": "0.2.1",
"version": "0.2.2",
"license": "MIT",

@@ -17,4 +17,4 @@ "scripts": {

"peerDependencies": {
"react": ">=16.14",
"react-dom": ">=16.14"
"react": ">=16.8",
"react-dom": ">=16.8"
},

@@ -21,0 +21,0 @@ "devDependencies": {

@@ -13,3 +13,3 @@ # react-solid-flow

- Zero third-party dependencies, except React and React-DOM
- Modern: React 16.14+ .. 18.x, no legacy APIs or weird hacks
- Modern: React 16.8+ .. 18.x, no legacy APIs or weird hacks
- Fully tested

@@ -16,0 +16,0 @@ - Easy to use

@@ -11,3 +11,5 @@ /// <reference types="vitest" />

plugins: [
react(),
react({
jsxRuntime: "classic",
}),
dts({ insertTypesEntry: true }),

@@ -30,3 +32,2 @@ ],

"react",
"react/jsx-runtime",
"react-dom",

@@ -37,3 +38,2 @@ ],

react: "React",
"react/jsx-runtime": "jsxRuntime",
"react-dom": "ReactDOM",

@@ -40,0 +40,0 @@ },

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