Comparing version 0.3.0-alpha to 0.4.0-next.0
@@ -1,2 +0,2 @@ | ||
import e,{useContext as n,useState as t,useEffect as r}from"react";function o(t){const r=e.createContext({});return{EnsureWrapper:n=>{let o=t();return o?e.createElement(r.Provider,{value:o},n.children):n.fallback?n.fallback:null},contextHook:function(){return n(r)}}}function c(e,n,o){const[c,u]=t(void 0),[i,a]=t();return r(()=>{if(n)return n(e=>u(e))},[n]),r(()=>{e().then(e=>{u(e)}).catch(e=>a(e))},[]),[c,i,o]}function u(e,n,t){Object.defineProperty(e,n,{get:()=>t(),enumerable:!0})}function i(e){return{useContainer:function(){return function(e){let n={},t=e.getTokens();for(let r in t)u(n,r,()=>c(()=>e.containers[r],n=>e.subscribeToContiner(r,n),r));return n}(n(e))},useContainerSet:function(o){const[c,u]=t(void 0),i=n(e),a="function"==typeof o?i._extractTokens(o):o;return r(()=>{i.getContainerSet(a).then(e=>{u(e)})},a),r(()=>i.subscribeToContinerSet(a,e=>{u(e)}),a),c}}}export{o as generateEnsureContainerSet,i as getContainerSetHooks}; | ||
import n,{useContext as t,useState as e,useEffect as r}from"react";function o(e){const r=n.createContext({});return{EnsureWrapper:t=>{let[o,c]=e();return o&&null==c?n.createElement(r.Provider,{value:o},t.children):t.fallback?t.fallback:null},contextHook:function(){return t(r)}}}function c(n,t,o){const[c,u]=e(void 0),[i,a]=e(void 0);return r(()=>t((n,t)=>{n&&(a(n),u(null)),u(t)}),[t]),r(()=>{try{n().then(n=>{u(n)}).catch(n=>{a(n)})}catch(n){a(n)}},[]),[c,i,o]}function u(n,t,e){Object.defineProperty(n,t,{get:()=>e(),enumerable:!0})}function i(n){return{useContainer:function(){return function(n){let t={},e=n.getTokens();for(let r in e)u(t,r,()=>c(()=>n.containers[r],t=>n.subscribeToContiner(r,t),r));return t}(t(n))},useContainerSet:function(o){const[c,u]=e(void 0),[i,a]=e(void 0),l=t(n),f="function"==typeof o?l._extractTokens(o):o;return r(()=>{l.getContainerSet(f).then(n=>{u(n)})},f),r(()=>{const n=l.subscribeToContinerSet(f,(n,t)=>{n?a(n):u(t)});return n},f),[c,i]}}}export{o as generateEnsureContainerSet,i as getContainerSetHooks}; | ||
//# sourceMappingURL=iti-react.modern.js.map |
@@ -1,2 +0,2 @@ | ||
import n,{useContext as t,useState as r,useEffect as e}from"react";function o(r){var e=n.createContext({});return{EnsureWrapper:function(t){var o=r();return o?n.createElement(e.Provider,{value:o},t.children):t.fallback?t.fallback:null},contextHook:function(){return t(e)}}}function u(n){return{useContainer:function(){return function(n){var t={},o=n.getTokens(),u=function(o){var u;u=function(){return t=function(){return n.containers[o]},u=function(t){return n.subscribeToContiner(o,t)},i=o,f=(c=r(void 0))[0],a=c[1],l=(v=r())[0],s=v[1],e(function(){if(u)return u(function(n){return a(n)})},[u]),e(function(){t().then(function(n){a(n)}).catch(function(n){return s(n)})},[]),[f,l,i];var t,u,i,c,f,a,v,l,s},Object.defineProperty(t,o,{get:function(){return u()},enumerable:!0})};for(var i in o)u(i);return t}(t(n))},useContainerSet:function(o){var u=r(void 0),i=u[0],c=u[1],f=t(n),a="function"==typeof o?f._extractTokens(o):o;return e(function(){f.getContainerSet(a).then(function(n){c(n)})},a),e(function(){return f.subscribeToContinerSet(a,function(n){c(n)})},a),i}}}export{o as generateEnsureContainerSet,u as getContainerSetHooks}; | ||
import n,{useContext as t,useState as r,useEffect as e}from"react";function o(r){var e=n.createContext({});return{EnsureWrapper:function(t){var o=r(),u=o[0];return u&&null==o[1]?n.createElement(e.Provider,{value:u},t.children):t.fallback?t.fallback:null},contextHook:function(){return t(e)}}}function u(n){return{useContainer:function(){return function(n){var t={},o=n.getTokens(),u=function(o){var u;u=function(){return t=function(){return n.containers[o]},u=function(t){return n.subscribeToContiner(o,t)},i=o,f=(c=r(void 0))[0],a=c[1],v=(l=r(void 0))[0],s=l[1],e(function(){return u(function(n,t){n&&(s(n),a(null)),a(t)})},[u]),e(function(){try{t().then(function(n){a(n)}).catch(function(n){s(n)})}catch(n){s(n)}},[]),[f,v,i];var t,u,i,c,f,a,l,v,s},Object.defineProperty(t,o,{get:function(){return u()},enumerable:!0})};for(var i in o)u(i);return t}(t(n))},useContainerSet:function(o){var u=r(void 0),i=u[0],c=u[1],f=r(void 0),a=f[0],l=f[1],v=t(n),s="function"==typeof o?v._extractTokens(o):o;return e(function(){v.getContainerSet(s).then(function(n){c(n)})},s),e(function(){var n=v.subscribeToContinerSet(s,function(n,t){n?l(n):c(t)});return n},s),[i,a]}}}export{o as generateEnsureContainerSet,u as getContainerSetHooks}; | ||
//# sourceMappingURL=iti-react.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e||self).itiReact={},e.react)}(this,function(e,t){function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=/*#__PURE__*/n(t);e.generateEnsureContainerSet=function(e){var n=r.default.createContext({});return{EnsureWrapper:function(t){var u=e();return u?r.default.createElement(n.Provider,{value:u},t.children):t.fallback?t.fallback:null},contextHook:function(){return t.useContext(n)}}},e.getContainerSetHooks=function(e){return{useContainer:function(){return function(e){var n={},r=e.getTokens(),u=function(r){var u;u=function(){return n=function(){return e.containers[r]},u=function(t){return e.subscribeToContiner(r,t)},o=r,i=(f=t.useState(void 0))[0],c=f[1],s=(a=t.useState())[0],l=a[1],t.useEffect(function(){if(u)return u(function(e){return c(e)})},[u]),t.useEffect(function(){n().then(function(e){c(e)}).catch(function(e){return l(e)})},[]),[i,s,o];var n,u,o,f,i,c,a,s,l},Object.defineProperty(n,r,{get:function(){return u()},enumerable:!0})};for(var o in r)u(o);return n}(t.useContext(e))},useContainerSet:function(n){var r=t.useState(void 0),u=r[0],o=r[1],f=t.useContext(e),i="function"==typeof n?f._extractTokens(n):n;return t.useEffect(function(){f.getContainerSet(i).then(function(e){o(e)})},i),t.useEffect(function(){return f.subscribeToContinerSet(i,function(e){o(e)})},i),u}}}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e||self).itiReact={},e.react)}(this,function(e,t){function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=/*#__PURE__*/n(t);e.generateEnsureContainerSet=function(e){var n=r.default.createContext({});return{EnsureWrapper:function(t){var u=e(),o=u[0];return o&&null==u[1]?r.default.createElement(n.Provider,{value:o},t.children):t.fallback?t.fallback:null},contextHook:function(){return t.useContext(n)}}},e.getContainerSetHooks=function(e){return{useContainer:function(){return function(e){var n={},r=e.getTokens(),u=function(r){var u;u=function(){return n=function(){return e.containers[r]},u=function(t){return e.subscribeToContiner(r,t)},o=r,f=(i=t.useState(void 0))[0],c=i[1],s=(a=t.useState(void 0))[0],l=a[1],t.useEffect(function(){return u(function(e,t){e&&(l(e),c(null)),c(t)})},[u]),t.useEffect(function(){try{n().then(function(e){c(e)}).catch(function(e){l(e)})}catch(e){l(e)}},[]),[f,s,o];var n,u,o,i,f,c,a,s,l},Object.defineProperty(n,r,{get:function(){return u()},enumerable:!0})};for(var o in r)u(o);return n}(t.useContext(e))},useContainerSet:function(n){var r=t.useState(void 0),u=r[0],o=r[1],i=t.useState(void 0),f=i[0],c=i[1],a=t.useContext(e),s="function"==typeof n?a._extractTokens(n):n;return t.useEffect(function(){a.getContainerSet(s).then(function(e){o(e)})},s),t.useEffect(function(){var e=a.subscribeToContinerSet(s,function(e,t){e?c(e):o(t)});return e},s),[u,f]}}}}); | ||
//# sourceMappingURL=iti-react.umd.js.map |
import React from "react"; | ||
export declare function generateEnsureContainerSet<Hook extends (...args: any) => any>(containerSetGetterHook: Hook): { | ||
export declare function generateEnsureContainerSet<ContainerSetContext>(containerSetGetterHook: (...args: any) => [ContainerSetContext, any]): { | ||
EnsureWrapper: (props: { | ||
@@ -7,3 +7,3 @@ fallback?: JSX.Element; | ||
}) => JSX.Element | null; | ||
contextHook: () => ReturnType<Hook>; | ||
contextHook: () => ContainerSetContext; | ||
}; |
@@ -10,4 +10,4 @@ import type { NodeApi, UnpackFunction } from "iti"; | ||
useContainer: () => { [CK in keyof Context]: Context[CK] extends any ? [UnPromisify<UnpackFunction<Context[CK]>> | undefined, any, CK] : never; }; | ||
useContainerSet: <Tokens extends keyof Context, TokenMap extends { [T in keyof Context]: T; }>(tokensOrCallback: Tokens[] | ((keyMap: TokenMap) => Tokens[])) => ContainerSet<Tokens, Context>; | ||
useContainerSet: <Tokens extends keyof Context, TokenMap extends { [T in keyof Context]: T; }>(tokensOrCallback: Tokens[] | ((keyMap: TokenMap) => Tokens[])) => [ContainerSet<Tokens, Context>, any]; | ||
}; | ||
export {}; |
@@ -11,2 +11,2 @@ export declare type ContainerGeneric<T> = { | ||
]; | ||
export declare function useBetterGenericContainer<T>(containerPromise: () => Promise<T>, subscribeFunction: (cb: (container: T) => void) => () => void, containerKey: string): ContainerGenericBettter<T>; | ||
export declare function useBetterGenericContainer<T>(containerPromise: () => Promise<T>, subscribeFunction: (cb: (err: any, container: T) => void) => () => void, containerKey: string): ContainerGenericBettter<T>; |
@@ -13,3 +13,3 @@ import React from "react"; | ||
cCont: "cCont"; | ||
}>(tokensOrCallback: Tokens[] | ((keyMap: TokenMap) => Tokens[])) => { [S in Tokens]: import("../../src").UnPromisify<import("iti").UnpackFunction<import("iti/dist/src/_utils").Assign4<import("iti/dist/src/_utils").Assign4<import("iti/dist/src/_utils").Assign4<{}, { | ||
}>(tokensOrCallback: Tokens[] | ((keyMap: TokenMap) => Tokens[])) => [{ [S in Tokens]: import("../../src").UnPromisify<import("iti").UnpackFunction<import("iti/dist/src/_utils").Assign4<import("iti/dist/src/_utils").Assign4<import("iti/dist/src/_utils").Assign4<{}, { | ||
aCont: () => Promise<import("./container.a").A_Container>; | ||
@@ -20,3 +20,3 @@ }>, { | ||
cCont: () => Promise<import("./container.c").C_Container>; | ||
}>[S]>>; }; | ||
}>[S]>>; }, any]; | ||
export declare const useMockAppContainer: () => { | ||
@@ -23,0 +23,0 @@ aCont: [import("./container.a").A_Container | undefined, any, "aCont"]; |
{ | ||
"name": "iti-react", | ||
"version": "0.3.0-alpha", | ||
"version": "0.4.0-next.0", | ||
"description": "Handy React bindings for iti", | ||
@@ -29,7 +29,8 @@ "type": "module", | ||
"devDependencies": { | ||
"@testing-library/react": "^12.1.2", | ||
"@testing-library/react": "^12.1.4", | ||
"@testing-library/react-hooks": "^7.0.2", | ||
"@types/jest": "^27.4.0", | ||
"@types/react": "^17.0.38", | ||
"@types/jest": "^27.4.1", | ||
"@types/react": "^17.0.40", | ||
"install-peers-cli": "^2.2.0", | ||
"iti": "0.4.0-next.0", | ||
"jest": "^27.4.7", | ||
@@ -39,5 +40,4 @@ "microbundle": "^0.14.2", | ||
"ts-jest": "^27.1.3", | ||
"iti": "0.3.0-alpha", | ||
"tsd": "^0.19.1", | ||
"typescript": "^4.5.5" | ||
"typescript": "^4.6.2" | ||
}, | ||
@@ -44,0 +44,0 @@ "peerDependencies": { |
@@ -1,8 +0,8 @@ | ||
<a href="https://www.npmjs.org/package/snow-splash"><img src="https://img.shields.io/npm/v/snow-splash.svg" alt="npm"></a> | ||
![CI](https://github.com/molszanski/snow-splash/actions/workflows/lib-test.yml/badge.svg) | ||
<a href="https://unpkg.com/snow-splash/dist/snow-splash.modern.js"><img src="https://img.badgesize.io/https://unpkg.com/snow-splash/dist/snow-splash.modern.js?compression=gzip" alt="gzip size"></a> | ||
<a href="https://www.npmjs.org/package/iti-react"><img src="https://img.shields.io/npm/v/iti-react.svg" alt="npm"></a> | ||
![CI](https://github.com/molszanski/iti/actions/workflows/lib-test.yml/badge.svg) | ||
<a href="https://unpkg.com/iti-react/dist/iti-react.modern.js"><img src="https://img.badgesize.io/https://unpkg.com/iti-react/dist/iti-react.modern.js?compression=gzip" alt="gzip size"></a> | ||
🚧 **library is in alpha dev mode** 🚧 | ||
🚧 **library in beta** 🚧 | ||
# Snow Splash React | ||
# Iti React | ||
@@ -16,3 +16,3 @@ > ~2kB inversion of control container for Typescript/Javascript for constructor injection with a focus on async flow | ||
``` | ||
npm install -S snow-splash-react | ||
npm install -S iti-react | ||
``` | ||
@@ -41,3 +41,3 @@ | ||
import React, { useContext } from "react" | ||
import { getContainerSetHooks } from "snow-splash" | ||
import { getContainerSetHooks } from "iti-react" | ||
import { getProviders, PizzaAppContainer } from "./_root.store" | ||
@@ -102,3 +102,3 @@ | ||
import { useContainerSet } from "../containers/_container.hooks" | ||
import { generateEnsureContainerSet } from "snow-splash" | ||
import { generateEnsureContainerSet } from "iti-react" | ||
@@ -105,0 +105,0 @@ const x = generateEnsureContainerSet(() => |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45402
165